• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 12:02
CEST 18:02
KST 01:02
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
TL.net Map Contest #21: Voting10[ASL20] Ro4 Preview: Descent11Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5
Community News
Chinese SC2 server to reopen; live all-star event in Hangzhou7Weekly Cups (Oct 13-19): Clem Goes for Four0BSL Team A vs Koreans - Sat-Sun 16:00 CET6Weekly Cups (Oct 6-12): Four star herO85.0.15 Patch Balance Hotfix (2025-10-8)80
StarCraft 2
General
RotterdaM "Serral is the GOAT, and it's not close" DreamHack Open 2013 revealed The New Patch Killed Mech! Chinese SC2 server to reopen; live all-star event in Hangzhou Team Liquid Map Contest #21 - Presented by Monster Energy
Tourneys
SC2's Safe House 2 - October 18 & 19 INu's Battles #13 - ByuN vs Zoun Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament $1,200 WardiTV October (Oct 21st-31st)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 496 Endless Infection Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment Mutation # 493 Quick Killers
Brood War
General
Is there anyway to get a private coach? The Lose More Card BW General Discussion BSL Season 21 OGN to release AI-upscaled StarLeague from Feb 24
Tourneys
300$ 3D!Community Brood War Super Cup #4 [ASL20] Semifinal B Azhi's Colosseum - Anonymous Tournament [Megathread] Daily Proleagues
Strategy
[I] TvZ Strategies and Builds [I] TvP Strategies and Build Roaring Currents ASL final Current Meta
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile Dawn of War IV ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
The Chess Thread Things Aren’t Peaceful in Palestine US Politics Mega-thread Russo-Ukrainian War Thread Men's Fashion Thread
Fan Clubs
The herO Fan Club!
Media & Entertainment
Series you have seen recently... Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
MLB/Baseball 2023 2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Certified Crazy
Hildegard
The Heroism of Pepe the Fro…
Peanutsc
Rocket League: Traits, Abili…
TrAiDoS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1152 users

Life as a Web Developer

Blogs > tofucake
Post a Reply
1 2 3 Next All
tofucake
Profile Blog Joined October 2009
Hyrule19144 Posts
Last Edited: 2010-07-06 21:34:07
July 03 2010 15:33 GMT
#1
So I recently started my new job as a web developer at a company that does auto financing. One of the internal tools they use is a system designed by a guy named Bob. Bob is not good at PHP. Below is an unedited snippet of his code, which is present in almost every single one of about 3000 files (the $message assignment is different on every page, but basically the same). Retarded spacing aside, it's just dumb. Also, the passwords are stored in plaintext.


....and this is just the start. The rest of the code is worse.

$systempath           =  $_SESSION[ 'systempath'         ];
$systemname = $_SESSION[ 'systemname' ];
$systemid = $_SESSION[ 'systemid' ];
$userid = $_SESSION[ 'userid' ];
$userpassword = $_SESSION[ 'userpassword' ];
$username = $_SESSION[ 'username' ];
$systemaccesslevel = $_SESSION[ 'systemaccesslevel' ];
$loginstatus = $_SESSION[ 'loginstatus' ];
$message = $_SESSION[ 'message' ];

$message = 'Perform Loan History Processing';

// set the session variables

$_SESSION[ 'systempath' ] = $systempath;
$_SESSION[ 'systemname' ] = $systemname;
$_SESSION[ 'systemid' ] = $systemid;
$_SESSION[ 'userid' ] = $userid;
$_SESSION[ 'userpassword' ] = $userpassword;
$_SESSION[ 'username' ] = $username;
$_SESSION[ 'systemaccesslevel' ] = $systemaccesslevel;
$_SESSION[ 'loginstatus' ] = $loginstatus;


[Update]
switched quotes to codes. Now you can see the dumb spacing.

*
Liquipediaasante sana squash banana
ilovezil
Profile Blog Joined August 2006
United States4143 Posts
July 03 2010 15:41 GMT
#2
ya, simply terrible!



??
RumZ
Profile Blog Joined March 2010
United States956 Posts
July 03 2010 15:43 GMT
#3
Wow.... that is going to take some time fixing eh?

It could be worse, I am doing some network administration on a server client setup that has not been updated from service pack 0 in 2 years on windows xp, the computers are also running incompatible version of symantec endpoint protection, and not only are they not supported anymore, each client is running a different version of the software.


But, I digress, I think your problem is way more painful if not able to be dealt with systematically.
fabiano
Profile Blog Joined August 2009
Brazil4644 Posts
July 03 2010 15:44 GMT
#4
lol

I guess its a good place to ask, which one is the best programming practice for php: use directly the $_SESSION[] variables or pass its content to a common variable?

eg. use $_SESSION['username'] all over the code or $username = $_SESSION['username'] and use $username for the rest of the code?
"When the geyser died, a probe came out" - SirJolt
Count9
Profile Blog Joined May 2009
China10928 Posts
July 03 2010 15:55 GMT
#5
Well... at least you know he read the PHP in 20 minutes book =) It's usually better when they write horrible code, and then leave you awesome comments with justifications.
tofucake
Profile Blog Joined October 2009
Hyrule19144 Posts
Last Edited: 2010-07-04 13:17:20
July 04 2010 13:09 GMT
#6
You guys haven't see the javascript yet. EVERY SINGLE LINE HAS AN EXPLANATORY COMMENT.

// resets the flag indicating whether the up or down key has been pressed
isKeyUpDownPressed = false;




On July 04 2010 00:41 ilovezil wrote:
ya, simply terrible!



??

He sets some variables, and then without changing any of them (sans $message), he sets them back again. It's a waste of space and processing power.


On July 04 2010 00:44 fabiano wrote:
lol

I guess its a good place to ask, which one is the best programming practice for php: use directly the $_SESSION[] variables or pass its content to a common variable?

eg. use $_SESSION['username'] all over the code or $username = $_SESSION['username'] and use $username for the rest of the code?
Both are acceptable, but only in certain situations. If you're doing processing and only want to display something, using local variables is best. I only use SESSION scope variables for tracking things that rarely or never change (a user ID) or things I don't want to be exposed (redirect after login). Other things he used SESSION scope for are things that should never, ever, for any reason, be stored anyway (plaintext password). Much of what he does could be sped up by using relational databases.
Liquipediaasante sana squash banana
vnlegend
Profile Blog Joined December 2006
United States1389 Posts
July 04 2010 13:56 GMT
#7
I don't really understand what this means but the guy could just be older and not too good with new technology.

** 30 years later **
16-yr old kid looks at tofucake's work: Who the hell wrote this dumb ancient code?

But anyway, looks like a good opportunity to get credit for making improvements.
Marines > everything
thedeadhaji *
Profile Blog Joined January 2006
39489 Posts
July 04 2010 14:17 GMT
#8
btw I like your ID
Count9
Profile Blog Joined May 2009
China10928 Posts
Last Edited: 2010-07-04 14:40:57
July 04 2010 14:39 GMT
#9
Wow, awesome, don't know how I missed this >.> I love thedailywtf, this is just as bad as some of code they got on there. (Of course, I don't have to work with this guy)

Maybe he auto generated some of those javascript things :/
tarpman
Profile Joined February 2009
Canada719 Posts
July 04 2010 16:38 GMT
#10
yeah, this sort of thing smells like copy-paste to me. likely he copy-pasted a bunch of stuff, tweaked it until it sort of worked, and then never touched it again :D
Saving the world, one kilobyte at a time.
QueueQueue
Profile Joined July 2009
Canada1000 Posts
July 04 2010 16:41 GMT
#11
On July 04 2010 22:09 tofucake wrote:
You guys haven't see the javascript yet. EVERY SINGLE LINE HAS AN EXPLANATORY COMMENT.

Show nested quote +
// resets the flag indicating whether the up or down key has been pressed
isKeyUpDownPressed = false;




At least people won't be lost >.<
tofucake
Profile Blog Joined October 2009
Hyrule19144 Posts
July 05 2010 20:54 GMT
#12
I want to submit something to DailyWTF...but I have no clue what to....it's all so bad.
Liquipediaasante sana squash banana
King K. Rool
Profile Blog Joined May 2009
Canada4408 Posts
July 05 2010 22:20 GMT
#13
lololol

Is bob still working there?
haduken
Profile Blog Joined April 2003
Australia8267 Posts
Last Edited: 2010-07-05 22:23:00
July 05 2010 22:22 GMT
#14
I've seen worse. I've worked on a project where the lead developer refused to use any control statements what so ever believing that they have a risk of malfunctioning. So the whole project was done assembly style except... in C#.

I still can't believe why this guy was hired and why he still works there.
Rillanon.au
NoHrt
Profile Blog Joined May 2010
Canada236 Posts
July 05 2010 23:37 GMT
#15
heh,

are you interested in assisting a fellow SC2 with your programming skills ? Im looking for help with a few things.

PM me if interested
l2sc.net | Lead Director | l2sc.tv NoHrt.518
tofucake
Profile Blog Joined October 2009
Hyrule19144 Posts
July 06 2010 00:46 GMT
#16
No...Bob was fired. Actually, about half way through the project he stopped responding to emails and phone calls (he was a contract hire, apparently).

On July 06 2010 07:22 haduken wrote:
I've seen worse. I've worked on a project where the lead developer refused to use any control statements what so ever believing that they have a risk of malfunctioning. So the whole project was done assembly style except... in C#.

I still can't believe why this guy was hired and why he still works there.

That hurts to think about.
Liquipediaasante sana squash banana
michiko
Profile Joined April 2010
United States75 Posts
July 06 2010 15:07 GMT
#17
I like the comment line you showed, rofl.

I mean it is a great practice to comment lines of code often, but E-V-E-R-Y line?

Espcially, ROFL, when the line itself describes what it does

//This resets the is key down flag to not being enabled
isKeyDown=false;

ROFL? What coder couldn't decipher that without the //?
----

And yes, I love that first post you make. In PHP it is very dangerous to store information in the session variables, who knows when it'll get changed or w/e as you navigate through the pages.

It's also a bad idea to store important information in there (like you said, just a session_id variable, user_ids, web cart information).

User names and passwords, any customer information stored in session? Bad News Bears.

Hell, I don't even use the $_[GET], i stick to POST so kiddies can't URL hi-jack my code.

---

Do you have a good source of code for properly storing passwords? I don't use plaintext, but I'm interested to hear your thoughts / methods on how to properly store, check and carry a PW value.

GOOD BLOG! 5/5!

tofucake
Profile Blog Joined October 2009
Hyrule19144 Posts
July 06 2010 15:18 GMT
#18
I'll post the creation bit here, and the whole password shpiel on pastebin. I create and store passwords based on SHA-1, with part of the SHA'd password used as the salt for SHA-ing the password to check it. Win.

function createpasswordhash($user, $raw_pass)
{
// this should ONLY be used to create NEW passwords, as
// the salt is based on the time
$salt = sha1($user . array_sum(explode(' ', microtime())));
$raw = $salt . sha1(sha1($user) . sha1($salt . $raw_pass));

return $raw;
}

The whole thing... http://pastebin.com/0dD00pu0
It makes use of my SQLController class for checking, but that should be easy enough to figure out. I can write up something about that later, though.
Liquipediaasante sana squash banana
michiko
Profile Joined April 2010
United States75 Posts
July 06 2010 15:30 GMT
#19
Awesome, great code. I won't steal - but that for sure helps!

I have one question:

$row = $DB->Fetch($query);

the "->"

I'm not a full-time coder, I do PHP contractually (soon-to-be full time, i hope).


Is that vanilla PHP? Are you using a framework? I recall -> calls being a big part of the Kohana framework.

$DB->Fetch sounds fricken awesome - for sure nicer than raw PHP MySQL queries...
tofucake
Profile Blog Joined October 2009
Hyrule19144 Posts
July 06 2010 15:40 GMT
#20
-> is part of PHP's OOP syntax. Like I said, I'll post my SQLController class later. I don't mind if you use my password stuff, as long as you stick a comment in there attributing it to me.
Liquipediaasante sana squash banana
1 2 3 Next All
Please log in or register to reply.
Live Events Refresh
Wardi Open
14:30
October Qualifier #2
WardiTV1087
IndyStarCraft 246
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
IndyStarCraft 254
LamboSC2 216
Codebar 40
sas.Sziky 14
UpATreeSC 1
MindelVK 1
StarCraft: Brood War
Britney 42395
Calm 4915
Rain 2364
Jaedong 1587
Horang2 1318
Bisu 1006
EffOrt 574
Mini 541
Light 522
firebathero 494
[ Show more ]
Larva 487
Soma 426
Shuttle 393
ZerO 304
Stork 256
Snow 230
actioN 217
Free 157
Soulkey 124
Pusan 122
PianO 100
Rush 97
Hyun 96
Killer 76
ggaemo 74
sSak 64
sorry 37
Shine 34
Shinee 29
Terrorterran 22
Movie 21
Sacsri 16
scan(afreeca) 16
Bale 15
HiyA 14
Hm[arnc] 5
Noble 5
Mong 1
Dota 2
Gorgc6080
qojqva4120
Dendi1191
syndereN363
BananaSlamJamma296
Fuzer 238
canceldota53
Counter-Strike
byalli316
markeloff220
fl0m121
edward43
FunKaTv 37
Other Games
singsing2455
hiko803
ceh9625
FrodaN539
Lowko380
Sick195
Liquid`VortiX148
Hui .134
ArmadaUGS129
Skadoodle107
KnowMe73
Mew2King58
QueenE58
Trikslyr42
ZerO(Twitch)16
Organizations
Counter-Strike
PGL447
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• Noizen32
League of Legends
• Jankos2789
• TFBlade910
Upcoming Events
PiGosaur Monday
7h 58m
Replay Cast
17h 58m
OSC
23h 58m
Tenacious Turtle Tussle
1d 6h
The PondCast
1d 17h
OSC
1d 19h
WardiTV Invitational
2 days
Online Event
2 days
RSL Revival
3 days
RSL Revival
3 days
[ Show More ]
WardiTV Invitational
3 days
Afreeca Starleague
4 days
Snow vs Soma
Sparkling Tuna Cup
4 days
WardiTV Invitational
4 days
CrankTV Team League
4 days
RSL Revival
5 days
Wardi Open
5 days
CrankTV Team League
5 days
Replay Cast
6 days
WardiTV Invitational
6 days
CrankTV Team League
6 days
Liquipedia Results

Completed

Acropolis #4 - TS2
WardiTV TLMC #15
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
EC S1
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
BSL 21 Non-Korean Championship
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
CranK Gathers Season 2: SC II Pro Teams
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.