1. PHP / Говнокод #2584

    +175.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    function makeQuery($keywords, $item, $type="and")
    {
    	// Тут аффтар вестимо вырезает последовательности из больше чем одного пробела
            for ($i=0; $i<1000; $i++)
    	{
    		 $keywords=str_replace("  "," ", $keywords);
    	}
    	$keywords.=" ";
    	$que="";
            // А эта хуета вместо explode( " ", $keywords )
    	while (strpos($keywords, " "))
    	{
    		$que.=" $type $item like '%".substr($keywords, 0, strpos($keywords, " "))."%'";
    		$keywords=substr($keywords,strpos($keywords, " ")+1);
    	}
    return $que;
    }

    Функция генерит SQL для поиска. Нарыл в коде чужой чудо-цмски. Такой феерической реализации в жизни не встречал...

    Johnny, 10 Февраля 2010

    Комментарии (12)
  2. PHP / Говнокод #2583

    +164.5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    if($s_r1>0){
    while($s_ww_1=mysql_fetch_object($s_q_1)){
    $row_repl1["id"]=$s_ww_1->id;
    $row_repl1["name"]=$s_ww_1->name;
    $row_repl1["nick"]=$s_ww_1->nick;
    if($s_ww_1->nick==''){
    $row_tpl1 = new FileTemplate($row_repl1, "TEMPL/shabl119.tpl");
    }else{
    $row_tpl1 = new FileTemplate($row_repl1, "TEMPL/shabl120.tpl");
    }
    $row_repl0["T_level1"].=$row_tpl1->parse();
    $row_repl1=array();
    }// end while
    @mysql_free_result($s_q_1);
    }//if
    $row_tpl0 = new FileTemplate($row_repl0, "TEMPL/shabl152.tpl");
    $row_tpl0->display();
    $row_repl0=array();
    }// end while
    @mysql_free_result($s_q);
    }//if
    }elseif($lnk1==47){
    $s_q=mysql_query("SELECT id, name, descr FROM experts WHERE id=$lnk2 LIMIT 1");
    $s_r1 = mysql_error() ? 0 : mysql_num_rows($s_q);
    if($s_r1>0){
    while($s_ww=mysql_fetch_object($s_q)){
    $row_repl["id"]=$s_ww->id;
    $row_repl["name"]=$s_ww->name;
    $row_repl["descr"]=$s_ww->descr;
    $row_tpl = new FileTemplate($row_repl, "TEMPL/shabl18.tpl");
    $row_tpl->display();
    $row_repl=array();
    }// end while
    @mysql_free_result($s_q);
    }//if
    }elseif($lnk1==54){
    $s_q=mysql_query("SELECT id, name, subtitle, type, number, doclevel, body, date, descr, txt, shows, prompt FROM documents WHERE id=$lnk2 LIMIT 1");
    $s_r1 = mysql_error() ? 0 : mysql_num_rows($s_q);
    if($s_r1>0){
    while($s_ww=mysql_fetch_object($s_q)){
    $row_repl["id"]=$s_ww->id;
    $row_repl["name"]=$s_ww->name;
    $row_repl["subtitle"]=$s_ww->subtitle;
    $row_repl["ParentType"]=$s_ww->type;
    $ParentType=$row_repl["ParentType"];
    $s_q2=mysql_query("select name as type_doctypes_name from doctypes where id=".$s_ww->type."");
    $s_n2 = mysql_error() ? 0 : mysql_num_rows($s_q2);
    if($s_n2>0){
    $s_w2=mysql_fetch_object($s_q2);
    $row_repl["type_doctypes_name"]=stripslashes($s_w2->type_doctypes_name);
    @mysql_free_result($s_q2);
    }//s_n2
    $row_repl["number"]=$s_ww->number;
    $row_repl["doclevel"]=$s_ww->doclevel;
    $s_q2=mysql_query("select name as doclevel_doclevels_name from doclevels where id=".$s_ww->doclevel."");
    $s_n2 = mysql_error() ? 0 : mysql_num_rows($s_q2);
    if($s_n2>0){
    $s_w2=mysql_fetch_object($s_q2);
    $row_repl["doclevel_doclevels_name"]=stripslashes($s_w2->doclevel_doclevels_name);
    @mysql_free_result($s_q2);
    }//s_n2
    $row_repl["body"]=$s_ww->body;
    $row_repl["date"]=mysqldate_to_str($s_ww->date);
    $row_repl["descr"]=$s_ww->descr;
    $row_repl["txt"]=$s_ww->txt;
    $row_repl["shows"]=intval($s_ww->shows)+1;
    @UpdateFCounter("documents","shows","copyshows","id",$s_ww->id);

    Использовано в коде одного из проектов, оставшихся на поддержку. Такой красоты там только в одном файле - около 8000 строк.

    karevn, 10 Февраля 2010

    Комментарии (13)
  3. PHP / Говнокод #2575

    +144.4

    1. 1
    if (1 || $ar_res['NAME'] == "Московские офисы")

    У кого есть трава ?

    atarix12, 09 Февраля 2010

    Комментарии (12)
  4. PHP / Говнокод #2573

    +170.7

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    if ((($company == "1none")&&($office == "loreal"))||($company == "146/710")){
       $from = "[email protected]";
       if ($kto == "c"){
        $to = $req1['email'].",[email protected]";
       }
       else{
        $to = $req1['MAILR'].",[email protected]";
       }
      }
    
      else{
       $from = "[email protected]";
       if ($kto == "c"){
        $to = $req1['email'].",[email protected]";
       }
       else{
        $to = $req1['MAILR'].",[email protected]";
       }
      }

    сейчас вот это говно приходится переводить на нормальный язык

    CountZero, 08 Февраля 2010

    Комментарии (13)
  5. PHP / Говнокод #2570

    +158.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    if(!$result = MYSQL_QUERY("SELECT gmr_id, gam_chip, gam_price, gam_status FROM ".PREFIX."_games;")) { die(mysql_error()); exit; }
        if(MYSQL_NUMROWS($result))
        {
            while($rows = mysql_fetch_row($result))
            {
                if(isset($gmr_chip[$rows[0]])) $gmr_chip[$rows[0]] += $rows[1];
                else $gmr_chip[$rows[0]]  = $rows[1];
                if(isset($gmr_price[$rows[0]])) $gmr_price[$rows[0]] += $rows[2];
                else $gmr_price[$rows[0]]  = $rows[2];
            }
        }
    
    
        if(!$result = MYSQL_QUERY("SELECT gmr_id, gmr_regdate, gmr_login, gmr_mail, gmr_credits, gmr_money, gmr_status, gmr_birthday, adv_id FROM ".PREFIX."_gamers WHERE gmr_birthday != '';")) { die(mysql_error()); exit; }
        if(MYSQL_NUMROWS($result))
        {
            while($rows = mysql_fetch_row($result))
            {
                $gmr_id[$rows[0]]       = $rows[0];
                $gmr_regdate[$rows[0]]  = $rows[1];
                $gmr_login[$rows[0]]    = $rows[2];
                $gmr_mail[$rows[0]]     = $rows[3];
                $gmr_credits[$rows[0]]  = $rows[4];
                $gmr_money[$rows[0]]    = $rows[5];
                $gmr_status[$rows[0]]   = $rows[6];
                $gmr_birthday[$rows[0]]     = $rows[7];
                if(!isset($gmr_quations[$rows[0]])) $gmr_quations[$rows[0]] = 0;
                if(!isset($gmr_chip[$rows[0]]))     $gmr_chip[$rows[0]]     = 0;
                if(!isset($gmr_price[$rows[0]]))    $gmr_price[$rows[0]]    = 0;
                if(isset($gmr_adverted[$rows[8]])) $gmr_adverted[$rows[8]]++;
                else $gmr_adverted[$rows[8]] = 1;
                $gadv_id[$rows[0]]       = $rows[8];
            }
        }
        MYSQL_QUERY("DROP TABLE ".PREFIX."_tmp_gamers;");
    
        if (!mysql_query ("CREATE TABLE ".PREFIX."_tmp_gamers (
             gmr_id              INT UNSIGNED NOT NULL AUTO_INCREMENT,
             gmr_regdate         DATE NOT NULL,
             gmr_login           CHAR(32) NOT NULL,
             gmr_mail            CHAR(32) NOT NULL,
             gmr_credits         INT UNSIGNED NOT NULL,
             gmr_money           DEC(10, 2) UNSIGNED NOT NULL,
             gmr_status          INT UNSIGNED NOT NULL,
             gmr_birthday            CHAR(12) NOT NULL,
             gmr_quations        INT UNSIGNED NOT NULL,
             gmr_chip            DEC(10, 2) UNSIGNED NOT NULL,
             gmr_price           DEC(10, 2) UNSIGNED NOT NULL,
             gmr_adverted        INT UNSIGNED NOT NULL,
             adv_id              INT UNSIGNED NOT NULL,
                UNIQUE KEY (gmr_id));")) { die(mysql_error()); exit; }
    
    
        $first = true;
        $query = "INSERT INTO ".PREFIX."_tmp_gamers VALUES ";
        if(isset($gmr_id))
        {
            foreach($gmr_id as $key)
            {
                if(!$first) $query .= ', ';
                else $first = false;
                if(!isset($gmr_adverted[$key])) $gmr_adverted[$key] = 0;
                $query .= "($gmr_id[$key], '$gmr_regdate[$key]', '$gmr_login[$key]', '$gmr_mail[$key]', $gmr_credits[$key], $gmr_money[$key], $gmr_status[$key], '$gmr_birthday[$key]', $gmr_quations[$key], $gmr_chip[$key], $gmr_price[$key], $gmr_adverted[$key], $gadv_id[$key])";
            }
            $query .= ";";
            if(!MYSQL_QUERY($query)) { die(mysql_error()); exit; }
        }
    
        unset($gmr_id);
        unset($gmr_regdate);
        unset($gmr_login);
        unset($gmr_mail);
        unset($gmr_credits);
        unset($gmr_money);
        unset($gmr_status);
        unset($gmr_birthday);
        unset($gmr_quations);
        unset($gmr_chip);
        unset($gmr_price);
        unset($gmr_adverted);
        unset($gadv_id);
    
        $type = 'norm';

    И кучка unset-ов! Ты гляди - он еще и память экономит!
    В таблице _gamers over 5k записей. Не трудно догадаться, каких размеров получается строка $query? И главный вопрос: нахрена временная таблица?

    azzz, 08 Февраля 2010

    Комментарии (7)
  6. PHP / Говнокод #2569

    +148.7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if(!$result = MYSQL_QUERY("SELECT gmr_id, gam_chip, gam_price, gam_status FROM ".PREFIX."_games;")) { die(mysql_error()); exit; }
    if(MYSQL_NUMROWS($result))
    {
        //какой-то код
    }

    А я-то думаю, чего это скрипту не хватает памяти - а в таблице несколько тысяч записей.

    azzz, 08 Февраля 2010

    Комментарии (13)
  7. PHP / Говнокод #2566

    +148.4

    1. 1
    $a1=proverka($a1,array(',','.','\'','"','`'));

    У чела походу не только с мозгами, но и с пробелом проблемы...

    Neris, 07 Февраля 2010

    Комментарии (14)
  8. PHP / Говнокод #2560

    +161.3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    $login['name'] = stripslashes(strip_tags(trim(htmlspecialchars($login['name']))));
    $login['live'] = stripslashes(strip_tags(trim(htmlspecialchars($login['live']))));
    $login['mobile'] = stripslashes(strip_tags(trim(htmlspecialchars($login['mobile']))));
    $login['operator'] = stripslashes(strip_tags(trim(htmlspecialchars($login['operator']))));
    $login['email'] = stripslashes(strip_tags(trim(htmlspecialchars($login['email']))));
    $login['about'] = stripslashes(strip_tags(trim(htmlspecialchars($login['about']))));
    $data['photo'] = stripslashes(strip_tags(trim(htmlspecialchars($data['photo']))));
    $login['wapsite'] = stripslashes(strip_tags(trim(htmlspecialchars($login['wapsite']))));
    $login['website'] = stripslashes(strip_tags(trim(htmlspecialchars($login['website']))));
    $login['emocii'] = stripslashes(strip_tags(trim(htmlspecialchars($login['emocii']))));
    
    
        if (empty($action)) {
            print '
    
    //тут бадяга типа формы входа
        } else {	
    		if (isset($_GET['edit'])){
    		$newpass = $_POST['newpass'];
    		$name = $_POST['name'];
    		$live = $_POST['live'];
    		$sex = $_POST['sex'];
    		$mobile = $_POST['mobile'];
    		$email = $_POST['email'];
    		$wapurl = $_POST['wapurl'];
    		$uin = $_POST['uin'];
    		$foto = $_POST['foto'];
    		$about = $_POST['about'];
    		$emocii = $_POST['emocii'];
    		$q="UPDATE `chat_users` SET 
    		`name`='".mysql_real_escape_string(htmlspecialchars($name))."', 
    		`pass`='".mysql_real_escape_string(htmlspecialchars($newpass))."' 
    		`sex`='".mysql_real_escape_string(htmlspecialchars($sex))."', 
    		`bday`='".mysql_real_escape_string(htmlspecialchars($bday))."' 
    		`bmonth`='".mysql_real_escape_string(htmlspecialchars($bmonth))."', 
    		`byear`='".mysql_real_escape_string(htmlspecialchars($byear))."' 
    		`live`='".mysql_real_escape_string(htmlspecialchars($live))."', 
    		`mobile`='".mysql_real_escape_string(htmlspecialchars($mobile))."' 
    		`email`='".mysql_real_escape_string(htmlspecialchars($email))."', 
    		`website`='".mysql_real_escape_string(htmlspecialchars($wapurl))."' 
    		`website`='".mysql_real_escape_string(htmlspecialchars($weburl))."', 
    		`icq`='".mysql_real_escape_string(htmlspecialchars($uin))."' 
    		`photo`='".mysql_real_escape_string(htmlspecialchars($foto))."', 
    		`about`='".mysql_real_escape_string(htmlspecialchars($about))."' 
    		`emocii`='".mysql_real_escape_string(htmlspecialchars($emocii))."'

    аффтар не на шутку обезопасился mysql_real_escape_string(htmlspecialchar s(tratata)) и stripslashes(strip_tags(trim(htmlspecial chars(tratata))))

    GoodTalkBot, 06 Февраля 2010

    Комментарии (20)
  9. PHP / Говнокод #2548

    +144.2

    1. 1
    2. 2
    $yii=dirname(__FILE__).'/protected/yii/framework/yiilite.php';
        //$yii=dirname(__FILE__).'/protected/yii/framework/yiilite.php';

    user654321, 05 Февраля 2010

    Комментарии (6)
  10. PHP / Говнокод #2545

    +180

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    //друзья и я
            if($user=="Krik99")   {
              if($pas==32542) {
                 echo "Молодец что зашол!<BR><BR><BR><BR>";
              }
              else {
                echo "Неверно введён пароль";
                exit;
              }
              }
    
            if($user=="4eef" || $user=="4eef " || $user==" 4eef ")   {
              if($pas==3252) {
                 echo "4eef <BR> Спасибо что зашол!<BR><BR><BR><BR>";
              }
              else {
                echo "Неверно введён пароль";
                exit;
              }
              }
              
                    if($user=="WebKill" || $user=="Webkill" || $user=="webkill" || $user=="WEBKILL")   {
              if($pas==1389) {
                 echo "Вэбкилл, доступ разрешон!<BR><BR><BR>";
              }
    
              else {
    
    echo "Неверно введён пароль, введите пароль для WebKill'a <BR>-> attack $ip <br> <iframe src=ping.php width=0 heith=0></iframe><iframe src=ping.php width=0 heith=0></iframe><iframe src=ping.php width=0 heith=0></iframe>";
                
                exit;
              }
              }

    Вэбкилл, доступ разрешон! :D
    я с него не могу, ребята )) это новый мем рунета

    deniamnet, 05 Февраля 2010

    Комментарии (33)