The worst PHP code in the world

[4:16:18 PM] HS says: btw i managed to install the affiliate thing on my laptop and the data looks ok but i cant use it, i cant login in the admin backend, it just reloads the login screen without any error messages or anything, do you know if the admin backend is finished?

[4:17:20 PM] HS says: and when i press different menu buttons in the front end nothing happens

[4:18:39 PM] HS says: so im not sure if my import screwed up the database and it’s because of that that it doesn’t work but i dont think so, it all looks ok when i check it

[4:18:53 PM] HS says: i mean phpMyAdmin has no problems reading the db

[4:21:47 PM] FT says: “do you know if the admin backend is finished?” yeah, it is

[4:22:10 PM] FT says: this should be the complete data source for the application…

[4:30:56 PM] HS says: i cant login and yeah, no error messages or anything… But let’s talk about it anyway, they want us to expand on this thing or redo it or what?

[4:33:03 PM] FT says: that`s the questions. i have a catalogie of additions with me when i come to Thailand. then we see what would be the better approach to this project

[4:33:57 PM] HS says: k, I’ll start looking at the code then

[4:41:15 PM] HS says: What kind of additions do they want? Tell me one and I’ll have it in mind when I review the code.

[4:41:54 PM] FT says: ok… wait a sec

[4:44:38 PM] FT says: for the admin backend… every merchant, every affiliate, every advertisment program should be editable from the backend

[4:45:09 PM] HS says: ok, and they are not at the moment?

[4:45:39 PM] FT says: don`t think so… ;)

[4:45:52 PM] FT says: i was only able to take a short view into this myself by now.

[4:46:22 PM] HS says: ok, I’ll see if I can get it up and running somehow

[4:47:53 PM] FT says: ok. good luck! if not… tell me by tomorrow so i can try to clear things up…

[4:48:07 PM] HS says: sure

[4:51:58 PM] HS says: The code is soso, not a disaster but not super when it comes to display / logic separation

[4:52:17 PM] FT says: and no real online documentation whatsoever…

[4:53:28 PM] HS says: no? No comments in the code either :( but it’s not super difficult to read, I’ve seen worse

[4:55:41 PM] FT says: yeah. i don`t think that the former programmer was bad

[4:55:50 PM] FT says: he just took sure that his company needed him… ;)

[4:55:51 PM] HS says: The admin code is much worse, not even proper indentation and echoing a lot of html

[4:56:43 PM] HS says: He is even echoing the styles as inline styles inside the PHP! Talk about telling the designers to fuck off

[4:57:20 PM] FT says: :D

[4:58:26 PM] HS says: oh god someone else must have made the admin stuff i think damn it sucks!

[4:58:57 PM] HS says:

if($controlip == ""){
 echo"<center><b><font color=red>Sie ?bertragen an unser System keine IP-Adresse und haben damit leider nicht die Rechte sich diese Seiten anzusehen!</font></b></center>";
  function func_header($text = "")
    echo "<p align='center'><font face='Verdana' size='4'><b>$text</b></font></p>";
if($goon == "logout")
$ask= "UPDATE `adminuser` SET logintime=logintime-3600 WHERE `adminuser`='$adminuser'";
$result = mysql_query($ask) or die(mysql_error());

$query1 = mysql_query("SELECT * FROM `adminuser` WHERE `adminuser`='$adminuser'");
$row1 = mysql_fetch_array($query1);
if(($row1[adminuser] == $adminuser) AND ($row1[adminpass] == $adminpasswort)) 

[4:59:31 PM] HS says: No this is not Skype screwing up the indentation, it really looks like that

[5:01:04 PM] FT says: oh…

[5:01:06 PM] HS says: I can tell you right away, I’m not gonna work with this because it will take a whole lot longer than rewriting the whole thing using a proper framework

[5:01:20 PM] FT says: you sure about it?

[5:01:38 PM] HS says: Yeah, I feel really bad when I see this crap

[5:02:43 PM] HS says: We have to rewrite everything anyway, remove all the design stuff from the code, it’s all echoed with escaping all over the place and so on, it’s a nightmare

[5:03:57 PM] HS says: This is what I think, I think he had to work in a proper way with the front end because some designer was probably working with that too. But with the backend… he was by himself and just totally fucked up everything

[5:04:06 PM] HS says:

$betreff="Ein wichtiger Hinwei? zu Ihren Partnerprogramm auf $seitentitel!";
$message="$anredemail $rowwarn2[name],<br><br>Ihr Partnerprogramm: $rowwarn1[name] auf $seitentitel hat nur noch ein Guthaben von $rowwarn1[prlimit] Euro. Daher m?chten wir Sie bitten, f?r die Fortf?hrung des Programms in Ihrem Account eine Kontoaufladung durchzuf?hren.<br><br>Vielen Dank!<br><br>Mit freundlichen Gr??en,<br>Ihr $seitentitel Team";
@mail("$rowwarn2[email]", "$betreff", "$message", "From: <$mailaddi>\nReply-To: <$mailaddi> X-Mailer: PHP\nMIME-Version: 1.0\nContent-Type: text/html; charset=iso-8859-1\n");
 $ask= "UPDATE `prg` SET `programmwarn` = 'ja' WHERE id='$ppid'";
  $result = mysql_query($ask) or die(mysql_error());
echo"<center>Guthabenwarnung wurde gesendet!</center>";
if($guthabenwarn == "all")
$resultwarn3 = mysql_query("SELECT * FROM prg WHERE `prlimit`<='$guthabenanzeige' AND `programmwarn`='nein' AND status='ok'");
while($rowwarn3 = mysql_fetch_array($resultwarn3))
$resultwarn4 = mysql_query("SELECT * FROM user WHERE `id`='$rowwarn3[owner]'");
$rowwarn4 = mysql_fetch_array($resultwarn4);

if($rowwarn4[anrede] == "Herr")
$anredemail="Sehr geehrter Herr";
$anredemail="Sehr geehrte Frau";

[5:05:12 PM] HS says:

<p align='center'><b><font face='Verdana' size='2'>Was f?r ein Programm m?chten Sie gerne anlegen?</font></b></p>
<p align='center'><b><font face='Verdana' size='2'>Sie k?nnen aus folgenden 5 Programmtypen ausw?hlen:</font></b><br></p>
<form method='POST' action='index.php?act=mm-dab&id=neu&check=$check&adminuser=$adminuser'>
  <p style='margin-top: 0; margin-bottom: 0'>
  <input type='radio' value='p1' checked name='prgtyp'><b><font face='Verdana' size='2'>PayPerClick</font></b></p>
  <p style='margin-top: 0; margin-bottom: 0'><font face='Verdana' size='2'>$proinfo_clickpp</font></p>
  <p style='margin-top: 0; margin-bottom: 0'>
  <input type='radio' name='prgtyp' value='p2'><b><font face='Verdana' size='2'>PayPerLead</font></b></p>
  <p style='margin-top: 0; margin-bottom: 0'><font face='Verdana' size='2'>$proinfo_leadpp</font></p>
  <p style='margin-top: 0; margin-bottom: 0'>
  <input type='radio' name='prgtyp' value='p3'><b><font face='Verdana' size='2'>PayPerSale</font></b></p>
  <p style='margin-top: 0; margin-bottom: 0'><font face='Verdana' size='2'>$proinfo_salepp</font></p>
  <p style='margin-top: 0; margin-bottom: 0'>
  <input type='radio' name='prgtyp' value='p4'><b><font face='Verdana' size='2'>PayPerPopUp</font></b></p>
  <p style='margin-top: 0; margin-bottom: 0'><font face='Verdana' size='2'>$proinfo_popuppp</font></p>
  <p style='margin-top: 0; margin-bottom: 0'>
  <input type='radio' name='prgtyp' value='p5'><b><font face='Verdana' size='2'>ForcedKlicks</font></b></p>
  <p style='margin-top: 0; margin-bottom: 0'><font face='Verdana' size='2'>$proinfo_forcedclickpp</font></p>
  <p style='margin-top: 0; margin-bottom: 0'>
  <input type='radio' name='prgtyp' value='p6'><b><font face='Verdana' size='2'>Kombiprogramm PayPerLead und PayPerClick</font></b></p>
  <p style='margin-top: 0; margin-bottom: 0'><font face='Verdana' size='2'>$proinfo_kombileadpp</font></p>
  <p style='margin-top: 0; margin-bottom: 0'>
  <input type='radio' name='prgtyp' value='p7'><b><font face='Verdana' size='2'>Kombiprogramm PayPerSale und PayPerClick</font></b></p>
  <p style='margin-top: 0; margin-bottom: 0'><font face='Verdana' size='2'>$proinfo_kombisalepp</font></p>
  <p style='margin-top: 0; margin-bottom: 0'>&nbsp;</p>
  <p style='margin-top: 0; margin-bottom: 0' align='center'>
  <input type='submit' value='Weiter' name='weiter_pp'></p>

[5:05:13 PM] FT says: oh… yeah… i thought this would be the ruesult of the evaluation…

[5:06:28 PM] HS says: Oh this is priceless:

[5:06:37 PM] HS says:

$querya = mysql_query("SELECT * FROM `user` where `guthaben`>='25.0000' AND `auszahl`='25.0000'");
$anza = mysql_num_rows($querya);

$queryb = mysql_query("SELECT * FROM `user` where `guthaben`>='50.0000' AND `auszahl`='50.0000'");
$anzb = mysql_num_rows($queryb);

$queryc = mysql_query("SELECT * FROM `user` where `guthaben`>='100.0000' AND `auszahl`='100.0000'");
$anzc = mysql_num_rows($queryc);

$queryd = mysql_query("SELECT * FROM `user` where `guthaben`>='500.0000' AND `auszahl`='500.0000'");
$anzd = mysql_num_rows($queryd);

$querye = mysql_query("SELECT * FROM `user` where `guthaben`>='1000.0000' AND `auszahl`='1000.0000'");
$anze = mysql_num_rows($querye);

$queryf = mysql_query("SELECT * FROM `user` where `guthaben`>='5000.0000' AND `auszahl`='5000.0000'");
$anzf = mysql_num_rows($queryf);

[5:07:07 PM] HS says: He obviously doesn’t know what a function is

[5:07:59 PM] HS says:

$ask= "UPDATE `user` SET `anrede` = '$anrede' WHERE id='$id'";
        $result = mysql_query($ask) or die(mysql_error());

 $ask1= "UPDATE `user` SET `vorname` = '$vorname' WHERE id='$id'";
        $result = mysql_query($ask1) or die(mysql_error());

 $ask2= "UPDATE `user` SET `name` = '$name' WHERE id='$id'";
        $result = mysql_query($ask2) or die(mysql_error());

 $ask3= "UPDATE `user` SET `firma` = '$firma' WHERE id='$id'";
        $result = mysql_query($ask3) or die(mysql_error());

 $ask4= "UPDATE `user` SET `str` = '$str' WHERE id='$id'";
        $result = mysql_query($ask4) or die(mysql_error());

 $ask5= "UPDATE `user` SET `plz` = '$plz' WHERE id='$id'";
        $result = mysql_query($ask5) or die(mysql_error());

 $ask6= "UPDATE `user` SET `ort` = '$ort' WHERE id='$id'";
        $result = mysql_query($ask6) or die(mysql_error());

 $ask7= "UPDATE `user` SET `land` = '$land' WHERE id='$id'";
        $result = mysql_query($ask7) or die(mysql_error());

 $ask8= "UPDATE `user` SET `tel` = '$tel' WHERE id='$id'";
        $result = mysql_query($ask8) or die(mysql_error());

 $ask9= "UPDATE `user` SET `fax` = '$fax' WHERE id='$id'";
        $result = mysql_query($ask9) or die(mysql_error());

 $ask10= "UPDATE `user` SET `email` = '$email' WHERE id='$id'";
        $result = mysql_query($ask10) or die(mysql_error());

 $ask11= "UPDATE `user` SET `stnummer` = '$stnummer' WHERE id='$id'";
        $result = mysql_query($ask11) or die(mysql_error());

 $ask12= "UPDATE `user` SET `ustid` = '$ustid' WHERE id='$id'";
        $result = mysql_query($ask12) or die(mysql_error());

 $ask13= "UPDATE `user` SET `ustpflicht` = '$ustpflicht' WHERE id='$id'";
        $result = mysql_query($ask13) or die(mysql_error());

 $ask14= "UPDATE `user` SET `pw` = '$pw' WHERE id='$id'";
        $result = mysql_query($ask14) or die(mysql_error());
 $ask15= "UPDATE `user` SET `newsletter` = '$newsletter' WHERE id='$id'";
        $result = mysql_query($ask15) or die(mysql_error());

[5:09:30 PM] HS says: So start to try and get a spec for the whole thing because I’ve got no idea what this thing can do or don’t do by looking at the code :(

[5:11:50 PM] HS says: morechnungen_old.php, morechnungenb.php, morechnungen.php

[5:12:21 PM] HS says: mm-da.php, mm-daa.php, mm-dab.php, awesome…

[5:12:21 PM] FT says: :D

[5:13:07 PM] FT says: yeah, well… try to get it running. otherwise… i need accedd to the running system over here.

[5:13:33 PM] HS says: Yeah maybe that is best because I don’t really know how I am gonna find out why it’s not running for me…

[5:13:38 PM] HS says:

<select name="kat" style="FONT-SIZE: 10px; WIDTH: 220px; COLOR: #000000; FONT-FAMILY: Verdana, Helvetica; HEIGHT: 16px; BACKGROUND-COLOR: #ffffff">
  <option value="">-- Bitte ausw?hlen --</option>
  <option<?php if ($row[kat] == "1") echo " selected"?> value="1">Auto und Verkehr</option>
  <option<?php if ($row[kat] == "2") echo " selected"?> value="2">Bekanntschaften und Kontakt</option>
  <option<?php if ($row[kat] == "3") echo " selected"?> value="3">Bildung und Karriere</option>
  <option<?php if ($row[kat] == "4") echo " selected"?> value="4">Business und Marketing</option>
  <option<?php if ($row[kat] == "5") echo " selected"?> value="5">Computer/Hard- und Software</option>
  <option<?php if ($row[kat] == "6") echo " selected"?> value="6">Dienstleistungen</option>
  <option<?php if ($row[kat] == "7") echo " selected"?> value="7">Erotik</option>
  <option<?php if ($row[kat] == "8") echo " selected"?> value="8">Essen und Trinken</option>
  <option<?php if ($row[kat] == "9") echo " selected"?> value="9">Finanzen</option>
  <option<?php if ($row[kat] == "10") echo " selected"?> value="10">Gesellschaft und Politik</option>
  <option<?php if ($row[kat] == "11") echo " selected"?> value="11">Gesundheit und Fitness</option>
  <option<?php if ($row[kat] == "12") echo " selected"?> value="12">Handel und Wirtschaft</option>
  <option<?php if ($row[kat] == "13") echo " selected"?> value="13">Hobby und Freizeit</option>
  <option<?php if ($row[kat] == "14") echo " selected"?> value="14">Geld verdienen</option>
  <option<?php if ($row[kat] == "15") echo " selected"?> value="15">Internet</option>
  <option<?php if ($row[kat] == "16") echo " selected"?> value="16">Kostenloses und Schn?ppchen</option>
  <option<?php if ($row[kat] == "17") echo " selected"?> value="17">Kunst und Kultur</option>
  <option<?php if ($row[kat] == "18") echo " selected"?> value="18">Mode und Kosmetik</option>
  <option<?php if ($row[kat] == "19") echo " selected"?> value="19">Musik und Unterhaltung</option>
  <option<?php if ($row[kat] == "20") echo " selected"?> value="20">Nachrichten und Medien</option>
  <option<?php if ($row[kat] == "21") echo " selected"?> value="21">Natur und Umwelt</option>
  <option<?php if ($row[kat] == "22") echo " selected"?> value="22">Online-Shopping</option>
  <option<?php if ($row[kat] == "23") echo " selected"?> value="23">Private Homepage</option>
  <option<?php if ($row[kat] == "24") echo " selected"?> value="24">Regionale Informationen</option>
  <option<?php if ($row[kat] == "25") echo " selected"?> value="25">Reisen und Urlaub</option>
  <option<?php if ($row[kat] == "26") echo " selected"?> value="26">Spiele</option>
  <option<?php if ($row[kat] == "27") echo " selected"?> value="27">Sport</option>
  <option<?php if ($row[kat] == "28") echo " selected"?> value="28">Telekommunikation und Mobilfunk</option>
  <option<?php if ($row[kat] == "29") echo " selected"?> value="29">Verzeichnisse und Referenzen</option>
  <option<?php if ($row[kat] == "30") echo " selected"?> value="30">Wissenschaft und Technik</option>
  <option<?php if ($row[kat] == "31") echo " selected"?> value="31">Sonstiges</option>

[5:13:50 PM] HS says: Ever heard of a loop?

[5:14:43 PM] HS says: What happened with this programmer?

[5:14:47 PM] FT says: obviously not… :D

[5:14:57 PM] HS says: They fired him and now they want us to finish it?

[5:18:36 PM] FT says: no, don`t think so…

[5:18:40 PM] HS says: You know the database was so big? It’s because this guy is logging everything, every bannerview inside the database!

[5:18:44 PM] FT says: but… I´m actually not sure about it… ;)

[5:19:34 PM] HS says: And I mean everything, every login everything! IN THE DB. Not in some zip file somewhere but in the DB with the rest of the stuff

[5:20:17 PM] FT says: hehe… every single click?

[5:20:41 PM] HS says: He is just creating a new log table for every new month

[5:21:18 PM] HS says: The database will grow to become bigger then anything else

[5:22:45 PM] HS says: “hehe… every single click?”
Yes, he is even storing what kind of action in a column called ‘act’ and most of them are clicks because he stores it as a string ‘click’ not a numer or something but a string, LOL

[5:23:18 PM] FT says: :D

[5:23:25 PM] FT says: your joking?

[5:23:44 PM] HS says: Nope

[5:23:50 PM] HS says: Eh it gets worse!

[5:24:56 PM] HS says: There is another log that keeps track of the time, but it must get it’s data from two different scripts because the time is formatted DIFFERENTLY in the same column!!

[5:25:42 PM] HS says:
18 01.05.06 26 67 94 40 40 0
19 Mai 2006 27 36 0 185 185 0
20 01.05.06 14 68 9 0 0 0
21 01.05.06 13 68 8 0 0 0
22 01.05.06 9 68 11 0 0 0
23 01.05.06 10 68 5 0 0 0

[5:25:56 PM] FT says: (rofl)

[5:26:01 PM] FT says: that`too good…

[5:26:17 PM] HS says: Mai 2006…

[5:26:51 PM] HS says: (puke)

[5:28:59 PM] HS says: You know as well as I do that to try and fix something like this, or in this case, try and build upon it will just end up in a total disaster, we have to rewrite it or just forget the whole thing. There are too many fucked up things everywhere, I can not be responsible for trying to work with this

[5:29:43 PM] FT says: yeah, i`m totally with you on this.

[5:29:45 PM] HS says: Because I’ll tell you right now, I will fail

[5:30:04 PM] FT says: as would anybody… i guss.

[5:30:05 PM] HS says: I just want to delete this crap and get a fresh spec

[5:30:36 PM] FT says: yeah. but we will need the old one for part of the specs, too. i fear… this will be our specs in some way

[5:31:05 PM] HS says: Yeah I’ll try a little to get it going so we can browse the interface

[5:31:30 PM] FT says: ok, cool!

[5:31:33 PM] HS says: Or if we can get login/pass to something that is already up and running is maybe better

[5:34:44 PM] FT says: yeah. i take care of this

[5:35:35 PM] HS says: yeah i just tried to hack the login thing but it isnt working he is using some kind of javascript in the middle of the PHP to open a new window and it isn’t working

[5:40:16 PM] HS says: I need a Chang, a big one

[6:04:51 PM] FT says: chang?

[6:44:43 PM] HS says: The beer

Most Popular Posts