Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12

Thread: PHP Squisher?

  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Squisher?

    Hey I downloaded a file for PHP Nuke and I saw this code:



    Thats 1 line of this huge file. Obviously noone codes like that squished up (atleast I dont think heh). Does anyone know a program that does this?
    Last edited by NumBa1Stunna516; 09-19-2005 at 05:41 AM.
    ForumLaunch Staff: We post on your forum

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Um, Windows->Notepad->Edit->Word Wrap

    Why anyone would actually want to put that on one line is beyond me.
    My guess is, that the creator removed all whitespaces, including newlines and tabs to save space in the script run. Installation script of some sorts I would assume.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,100
    Thanks
    2
    Thanked 23 Times in 23 Posts
    I have some code-generation software that does this (javascript, not PHP). The code is edited using a GUI interface, but if you look at the code itself, it reads like a novel, just like the one you mentioned. Generally, no raw code that you'd have to maintain is written like this.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it's most likely they used php_strip_whitespace ( http://php.belnet.be/manual/nl/funct...whitespace.php ) or something similar. (although their $HTTP_SERVER_VARS references makes it look like older code --> probably never upgraded?)

    It doesn't significantly improve performance. More likely done to reduce filesize for downloading or to make the code more difficult to read/edit (although a bit of regex could probably partialy solve that). What some people do to make it even less userfriendly, is replacing all variablenames by random names or numbers. so all $resultcomment then become $frrskerr or so.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Sorry, I should have been more clear as well, I also meant that it would save on the filesize, not that it would run any better.
    S'all good though, I hate it when people do that, makes it tough to debug thats for sure.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #6
    New Coder
    Join Date
    Sep 2005
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well I think this is the reason why the authors made the code jumbled up. This is a security script addon for PHP Nuke CMS. So obviously the author did not want anyone to easily figure out holes in it. I highly doubt the author did it by hand as the file, in its compressed form is 150 kb. I have been searching google for a program that does this with no luck. Thanks for the replies, please let me know if anyone comes across a program for this.
    ForumLaunch Staff: We post on your forum

  • #7
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by NumBa1Stunna516
    Thanks for the replies, please let me know if anyone comes across a program for this.
    so php_strip_whitespace() is to easy?
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #8
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    That function is only in the "evil" PHP5 on which only a select few can run their scripts...
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #9
    New Coder
    Join Date
    Sep 2005
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by marek_mar
    That function is only in the "evil" PHP5 on which only a select few can run their scripts...
    Yea I am not running PHP5.
    ForumLaunch Staff: We post on your forum

  • #10
    Regular Coder
    Join Date
    Sep 2005
    Location
    Liverpool
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    surely it would be nothing more than a simple regular expression to replace all 'newlines' would it not?

    I use textpad for that...
    my mind is on a permanent tangent

  • #11
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Rich Pedley
    surely it would be nothing more than a simple regular expression to replace all 'newlines' would it not?

    I use textpad for that...
    it would be a tad more then that since you need to remove linebreaks, spaces and comments comments. removing spaces for instance can be quite tricky if you have texts inthere (feedbackmessages or so)
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #12
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by NumBa1Stunna516
    Yea I am not running PHP5.
    You could run it on your test server. You don't need to run that function more trhan once on a code block...
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •