Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1480 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Poorly written code hurts my soul...

Thread title: Poorly written code hurts my soul...
Closed Thread  
Page 1 of 3 1 2 3 >
    Thread tools Search this thread Display Modes  
11-03-2007, 01:42 AM
#1
patrickPaul is offline patrickPaul
Status:
Join date: Dec 2004
Location: California, US
Expertise:
Software:
 
Posts: 406
iTrader: 1 / 100%
 

patrickPaul is on a distinguished road

Send a message via AIM to patrickPaul Send a message via MSN to patrickPaul Send a message via Yahoo to patrickPaul

  Old  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
Haris is offline Haris
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
 
Posts: 2,741
iTrader: 9 / 100%
 

Haris is on a distinguished road

  Old

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
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

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
yoes_san is offline yoes_san
yoes_san's Avatar
Status: I'm new around here
Join date: Nov 2007
Location:
Expertise:
Software:
 
Posts: 7
iTrader: 0 / 0%
 

yoes_san is on a distinguished road

Send a message via MSN to yoes_san Send a message via Skype™ to yoes_san

  Old

The worst I've seen is code with all variables and comments written in Vietnamese language.

11-06-2007, 02:44 PM
#5
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

Originally Posted by yoes_san View Post
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
yoes_san is offline yoes_san
yoes_san's Avatar
Status: I'm new around here
Join date: Nov 2007
Location:
Expertise:
Software:
 
Posts: 7
iTrader: 0 / 0%
 

yoes_san is on a distinguished road

Send a message via MSN to yoes_san Send a message via Skype™ to yoes_san

  Old

Originally Posted by Village Idiot View Post
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
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

Originally Posted by yoes_san View Post
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
nickcmp is offline nickcmp
nickcmp's Avatar
Status: I'm new around here
Join date: Nov 2007
Location: UK
Expertise:
Software:
 
Posts: 17
iTrader: 0 / 0%
 

nickcmp is on a distinguished road

Send a message via MSN to nickcmp Send a message via Skype™ to nickcmp

  Old

Wow thats just plain bad.

lol....
whats this bit about:
<?
}

//...

?>

thats just chuckle worthy =P.

11-09-2007, 02:22 AM
#9
bluesaga is offline bluesaga
Status: Member
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 137
iTrader: 1 / 100%
 

bluesaga is on a distinguished road

  Old

Originally Posted by Village Idiot View Post
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
bluesaga is offline bluesaga
Status: Member
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 137
iTrader: 1 / 100%
 

bluesaga is on a distinguished road

  Old

Originally Posted by Village Idiot View Post
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

Closed Thread  
Page 1 of 3 1 2 3 >


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed