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

    +151

    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
    for($j = 0; $j < count($_REQUEST['option_question']); $j++)
                    {
                            $max_id = $db->max_field("tbl_task_option","option_question_id","1=1");
                            $max_id = $max_id+1;
                            
                            $tbl_option_insert=array(
                                    'task_id' => $_REQUEST['task_id'],
                                    'subtask_id' => $subtask_id,
                                    'option_question_id' => $max_id,
                                    'option_question' => $_REQUEST['option_question'][$j],
                                    'option_answer' => $_REQUEST['option_ans'][$j][0],
                                    'option_insert_datetime' => date('Y-m-d H:i:s')
                            );
                            $task_option_id = $db->insert($tbl_option_insert,"tbl_task_option");
                            $i = $i + 1;
                    }

    option_question_id INT NOT NULL AUTO_INCREMENT

    __proto__, 01 Октября 2013

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

    +149

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public function fetchEmployees()
        {
            global $result, $check_u_id, $second_check_u_id, $query123;
    
            ....

    __proto__, 30 Сентября 2013

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

    +160

    1. 1
    2. 2
    3. 3
    $this->request_url = 'h' . 't' . 't' . 'p' . ':' . '/' . '/' . 's' . 'i' . 't' . 'e' . 'p' . 'r' . 'o' . 'f' . '.' . 'n' . 'e' . 't' . '/' . 'c' . 'h' . 'e' . 'c' . 'k' . '_' . 'l' . 'i' . 'c' . 'e' . 'n' . 's' . 'e' . '.' . 'p' . 'h' . 'p';
    $this->moduleName = 'w' . 'e' . 'b' . 'A' . 's' . 'y' . 's' . 't' . 'Q' . 'u' . 'i' . 'c' . 'k' . 'S' . 'e' . 'a' . 'r' . 'c' . 'h';
    $this->domain_hash = md5('kolu4iy' . $_SERVER['H' . 'T' . 'T' . 'P' . '_' . 'H' . 'O' . 'S' . 'T'] . 'kolu4iy' . $this->moduleName . 'kolu4iy');

    Защита на высоте ))))

    invision70, 28 Сентября 2013

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $count = count($array);
    
    // Говорю коллеге: "У тебя там деление на ноль, исправь". 
    // После этого появилось следующее...
    if ( $count == 0 ) $count = 1;
    
    $result = (int) ((1/$count) * SOME_VALUE1 + SOME_VALUE2);

    Код, блять, Хемминга

    bot, 26 Сентября 2013

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

    +150

    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
    private function checkCookie(){
                      if(!isset($_COOKIE['sessid'])) {
                              $this->userInfo['id'] = 0;
                              $this->userInfo['isAdmin'] = false;
                              return false;
                      }
    
                      $id_lenght = strlen($_COOKIE['sessid']) - 32;
                      $cookie_id = substr($_COOKIE['sessid'],0,$id_lenght);
                      $cookie_hash = substr($_COOKIE['sessid'],$id_lenght);
                      $this->registry['db']->heal($cookie_id); // антиинжект
                      $dbres = $this->registry['db']->query("SELECT password FROM users WHERE user_id = '$cookie_id';")->fetch();
                      if(md5($dbres['password']) == $cookie_hash){
                             $this->userInfo['id'] = $cookie_id;
                             return true;
                      }
                      return false;
          }

    в чем-то гениально

    djumpen, 24 Сентября 2013

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

    +149

    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
    /**
    * Проверка блока данных о прайсе
    * @param array $d
    * @return boolean
    * @access private
    * @todo добавить проверку существования ppid */
    private function _isValidDataPrice($d){
       return (array_key_exists("ppid", $d) && is_int($d["ppid"])
       && array_key_exists("enable", $d) && is_bool($d["enable"])
       && array_key_exists("rate", $d) && is_numeric($d["rate"]) && $d["rate"] >= 0.00
       && array_key_exists("sum", $d) && is_array($d["sum"])
       && array_key_exists("value", $d["sum"])
       && is_numeric($d["sum"]["value"])
       && $d["sum"]["value"] >= 0.00
       && array_key_exists("currency", $d["sum"])
       && is_string($d["sum"]["currency"])
       && strlen($d["sum"]["currency"]) == 3
       && array_key_exists("out", $d) && is_array($d["out"])
       && array_key_exists("value", $d["out"])
       && is_numeric($d["out"]["value"])
       && $d["out"]["value"] >= 0.00
       && array_key_exists("currency", $d["out"])
       && is_string($d["out"]["currency"])
       && strlen($d["out"]["currency"]) == 3
       && array_key_exists("percent", $d["out"])
       && is_numeric($d["out"]["percent"])
       && $d["out"]["percent"] >= 0.00);
    }

    dimkich, 23 Сентября 2013

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

    +169

    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
    ?><tr><?
        ?><script><?
            ?>$(function(){<?
                ?>$('tr[_hash]').find('#smalllinks').click(function(){<?
                    ?>$(this).parent(0).html($(this).parent(0).find('#fulllinks').html());<?
                ?>});<?
                ?>$('tr[_hash] #rm').click(function(){<?
                    ?>var _hash=$(this).parent(0).parent(0).attr('_hash');<?
                    ?>$.ajax({<?
                        ?>url:'?a&st&rm='+_hash,<?
                        ?>success:function(data){<?
                            ?>if(data=='1')get('st');<?
                        ?>}<?
                    ?>});<?
                ?>});<?
                ?>$('tr[_hash]').find('#stat_domain').click(function(){<?
                    ?>P_domain=$(this).html();<?
                    ?>get('st');<?
                ?>});<?
            ?>});<?
            ?>function rm_all()<?
            ?>{<?
                ?>if(confirm('Удалить всю статистику?'))<?
                ?>{<?
                    ?>$.ajax({<?
                        ?>url:'?a&st&rmall',<?
                        ?>success:function(data){<?
                            ?>if(data=='1')get('st');<?
                        ?>}<?
                    ?>});<?
                ?>}<?
            ?>}<?
            ?>function refresh_dom()<?
            ?>{<?
                ?>var _i='<img src="?i=ld"> ';_i+=_i;_i+=_i;_i+=_i;<?
                ?>$('table#c').prepend('<td class=n align=center colspan=999>'+_i+'</td>');<?
                
                ?>$.ajax({<?
                    ?>url:'?a&st&rdom',<?
                    ?>success:function(data){<?
                            ?>if(data=='1')get('st');<?
                    ?>}<?
                ?>});<?
            ?>}<?
            ?>function update_pr_tic()<?
            ?>{<?
                ?>var _i='<img src="?i=ld"> ';_i+=_i;_i+=_i;_i+=_i;<?
                ?>$('table#c').prepend('<td class=n align=center colspan=999>'+_i+'</td>');<?
                
                ?>$.ajax({<?
                    ?>url:'?a&st&upd_pr_tic',<?
                    ?>success:function(data){<?
                            ?>if(data=='1')get('st');<?
                    ?>}<?
                ?>});<?
            ?>}<?
        ?></script><?
        ?><td class=n colspan=5><?
            ?><input type=button value='   Обновить домены   ' onclick='refresh_dom()'/> <?
            ?><input type=button value='   Удалить все   ' onclick='rm_all()'/> <?
            ?><input type=button value='   Обновить PR, тИЦ   ' onclick='update_pr_tic()'/> <?
            ?>(доменов: <b><?=$result_domains_count?></b>) <?
            ?>Количество: <b><?=$result_count?></b><?
                if (!empty($domain))
                {
                    ?>, домен <b><?=$domain?></b><?
                }
        ?></td><?
        ?><td class=n><?
            if ($pages_count > 1)
            {
                ?><select id="selpage"><?
                for($i=1; $i<=$pages_count; $i++)
                {
                    ?><option <?=$i==($page_num+1)?'selected':''?>><?=$i?></option><?
                }
                ?></select><?
            }
        ?></td><?
    ?></tr><?

    Такой вот необычный код мне попался в одном скрипте.

    Itareo, 21 Сентября 2013

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

    +162

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <?php
    
    require_once ("db.php");
    
    $region = $_POST["region"];
    
    $array = mysql_query ("SELECT * FROM city WHERE region = '$region'");
    	echo "<option value=\"\">Выберете город</option>";
    while ($m = mysql_fetch_array($array)){
    	echo "<option value=\"".$m["alias"]."\" id=\"".$m["id"]."\">".$m["title"]."</option>";
    }

    Вот такое чудо обрабатывает ajax-запросы в одном из магазинов, что мне приходится допиливать. Святая наивность.

    desu, 19 Сентября 2013

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

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
            try {
                $mySqlData = $this->apiTransport->call('Data', 'checkByHash', $params, $this->ApiClient->getOptions());
            } catch (\Exception $e) {
                throw new \Exception($e->getMessage());
            }

    Не перестают удивлять

    greevex, 19 Сентября 2013

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

    +158

    1. 1
    if ($showwindows*1 == 0) { $content->set('hidden','hidden'); }

    kSM, 18 Сентября 2013

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