...

View Full Version : PHP Squisher?



NumBa1Stunna516
09-19-2005, 04:38 AM
Hey I downloaded a file for PHP Nuke and I saw this code:

http://techzentri.com/delete.gif

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?

Fou-Lu
09-19-2005, 05:16 AM
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.

vinyl-junkie
09-19-2005, 05:56 AM
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.

raf
09-19-2005, 08:34 AM
it's most likely they used php_strip_whitespace ( http://php.belnet.be/manual/nl/function.php-strip-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.

Fou-Lu
09-19-2005, 02:58 PM
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.

NumBa1Stunna516
09-19-2005, 05:42 PM
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.

raf
09-19-2005, 07:04 PM
Thanks for the replies, please let me know if anyone comes across a program for this.
so php_strip_whitespace() is to easy?

marek_mar
09-19-2005, 11:00 PM
That function is only in the "evil" PHP5 on which only a select few can run their scripts...

NumBa1Stunna516
09-20-2005, 12:41 AM
That function is only in the "evil" PHP5 on which only a select few can run their scripts...

Yea I am not running PHP5.

Rich Pedley
09-20-2005, 09:57 AM
surely it would be nothing more than a simple regular expression to replace all 'newlines' would it not?

I use textpad for that...

raf
09-20-2005, 12:30 PM
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)

marek_mar
09-20-2005, 03:49 PM
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...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum