|
|
|
|
Thread title: Poorly written code hurts my soul... |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
11-03-2007, 01:42 AM
|
#1
|
Status:
Join date: Dec 2004
Location: California, US
Expertise:
Software:
Posts: 406
|
Poorly written code hurts my soul...
Hey guys,
Just ran across this and thought it was worthy enough to start a thread...
PHP Code:
<?php
//...
function title($item) { ?> <?=$item["TITLE"];?> <? }
//...
?>
It scares me what some people do... Anyone seen worse while working on someone else's code?
Just thought I'd add for any non-programmers reading this... The proper way to do this is simply:
PHP Code:
<?php
// ...
function title($item) { echo $item['TITLE']; }
//...
?>
Best Regards,
Patrick
|
|
11-03-2007, 02:02 AM
|
#2
|
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
Posts: 2,741
|
Yes
Title was set to $a (Proper: $szTitle)
ID of the post was set to $b ($iID)
Category of the post was set to variable $c ($szCategory)
Nice, I've seen worser for XHTML.
|
|
11-03-2007, 02:57 AM
|
#3
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
Not as bad as the 500 line image upload script (all it did was upload), it used the imageGD library to verify that it is said type of image. Ive worken on allot of madness, that is among the worst ive seen.
I don't disclose clients code because I don't retain the copyright to it.
|
|
11-06-2007, 02:35 PM
|
#4
|
Status: I'm new around here
Join date: Nov 2007
Location:
Expertise:
Software:
Posts: 7
|
The worst I've seen is code with all variables and comments written in Vietnamese language.
|
|
11-06-2007, 02:44 PM
|
#5
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
Originally Posted by yoes_san
The worst I've seen is code with all variables and comments written in Vietnamese language.
|
Nothing bad about that, the coder couldnt speak english. PHP commands remain in english no matter what if I recall
|
|
11-06-2007, 03:20 PM
|
#6
|
Status: I'm new around here
Join date: Nov 2007
Location:
Expertise:
Software:
Posts: 7
|
Originally Posted by Village Idiot
Nothing bad about that, the coder couldn't speak English. PHP commands remain in English no matter what if I recall
|
But the catch is they can use English but they won't code in English.
Usually they won't do this but for that time they want to make my life miserable or something.
|
|
11-06-2007, 04:15 PM
|
#7
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
Originally Posted by yoes_san
But the catch is they can use English but they won't code in English.
Usually they won't do this but for that time they want to make my life miserable or something.
|
They know the commands as commands, they dont know what it means in english. Plus, they comment in their language since that is what comes natural, less miswording and work on it.
Or it could be to make your life hard.
|
|
11-08-2007, 04:55 PM
|
#8
|
Status: I'm new around here
Join date: Nov 2007
Location: UK
Expertise:
Software:
Posts: 17
|
Wow thats just plain bad.
lol....
whats this bit about:
<?
}
//...
?>
thats just chuckle worthy =P.
|
|
11-09-2007, 02:22 AM
|
#9
|
Status: Member
Join date: Feb 2007
Location:
Expertise:
Software:
Posts: 137
|
Originally Posted by Village Idiot
Not as bad as the 500 line image upload script (all it did was upload), it used the imageGD library to verify that it is said type of image. Ive worken on allot of madness, that is among the worst ive seen.
I don't disclose clients code because I don't retain the copyright to it.
|
Well actually, you'll find that 500 well commented, with decent type detection (and checking the extension does NOT count as decent type detection, i mean checking the MIME types are an image).
Say someone uploads: uploaded.gif, and its really a text document containing php, it can seriously damage your website.
While checking the content is actually what it says it is, and if it isn't changing it to the correct type is fairly easy, also can have a standard form for extensions that way too, no jpg, jPg, Jpeg, jPeg etc, all standardised and lower case.
What i mean by detecting and changing an extension, im sure many of you designer have cut corners before when doing a design that should have transparent corners, but instead its white and you have referenced it in hard code EVERYWHERE. Which would mean changing image.jpg to image.png in 5000 cases, why not just change the .jpg -> .png.. The latest browsers have supported that for years.
You need to make sure your image upload script supports that too!
Sorry if i went on, just trying to make a point
|
|
11-09-2007, 02:23 AM
|
#10
|
Status: Member
Join date: Feb 2007
Location:
Expertise:
Software:
Posts: 137
|
Originally Posted by Village Idiot
Not as bad as the 500 line image upload script (all it did was upload), it used the imageGD library to verify that it is said type of image. Ive worken on allot of madness, that is among the worst ive seen.
I don't disclose clients code because I don't retain the copyright to it.
|
Well actually, you'll find that 500 well commented, with decent type detection (and checking the extension does NOT count as decent type detection, i mean checking the MIME types are an image).
Say someone uploads: uploaded.gif, and its really a text document containing php, it can seriously damage your website.
While checking the content is actually what it says it is, and if it isn't changing it to the correct type is fairly easy, also can have a standard form for extensions that way too, no jpg, jPg, Jpeg, jPeg etc, all standardised and lower case.
What i mean by detecting and changing an extension, im sure many of you designer have cut corners before when doing a design that should have transparent corners, but instead its white and you have referenced it in hard code EVERYWHERE. Which would mean changing image.jpg to image.png in 5000 cases, why not just change the jpeg -> png (while keeping the name image.jpg).. The latest browsers have supported that for years.
You need to make sure your image upload script supports that too!
Sorry if i went on, just trying to make a point
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
|
|