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

    +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
    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
    public function isMobile()
    {
        // ...
    
        if (in_array (strtolower (substr ($user_agent, 0, 4)), array (
            '1207' => '1207', '3gso' => '3gso', '4thp' => '4thp', '501i' => '501i', '502i' => '502i', '503i' => '503i', '504i' => '504i',
            '505i' => '505i', '506i' => '506i', '6310' => '6310', '6590' => '6590', '770s' => '770s', '802s' => '802s', 'a wa' => 'a wa',
            'acer' => 'acer', 'acs-' => 'acs-', 'airn' => 'airn', 'alav' => 'alav', 'asus' => 'asus', 'attw' => 'attw', 'au-m' => 'au-m',
            'aur ' => 'aur ', 'aus ' => 'aus ', 'abac' => 'abac', 'acoo' => 'acoo', 'aiko' => 'aiko', 'alco' => 'alco', 'alca' => 'alca',
            'amoi' => 'amoi', 'anex' => 'anex', 'anny' => 'anny', 'anyw' => 'anyw', 'aptu' => 'aptu', 'arch' => 'arch', 'argo' => 'argo',
            'bell' => 'bell', 'bird' => 'bird', 'bw-n' => 'bw-n', 'bw-u' => 'bw-u', 'beck' => 'beck', 'benq' => 'benq', 'bilb' => 'bilb',
            'blac' => 'blac', 'c55/' => 'c55/', 'cdm-' => 'cdm-', 'chtm' => 'chtm', 'capi' => 'capi', 'cond' => 'cond', 'craw' => 'craw',
            'dall' => 'dall', 'dbte' => 'dbte', 'dc-s' => 'dc-s', 'dica' => 'dica', 'ds-d' => 'ds-d', 'ds12' => 'ds12', 'dait' => 'dait',
            'devi' => 'devi', 'dmob' => 'dmob', 'doco' => 'doco', 'dopo' => 'dopo', 'el49' => 'el49', 'erk0' => 'erk0', 'esl8' => 'esl8',
            'ez40' => 'ez40', 'ez60' => 'ez60', 'ez70' => 'ez70', 'ezos' => 'ezos', 'ezze' => 'ezze', 'elai' => 'elai', 'emul' => 'emul',
            'eric' => 'eric', 'ezwa' => 'ezwa', 'fake' => 'fake', 'fly-' => 'fly-', 'fly_' => 'fly_', 'g-mo' => 'g-mo', 'g1 u' => 'g1 u',
            'g560' => 'g560', 'gf-5' => 'gf-5', 'grun' => 'grun', 'gene' => 'gene', 'go.w' => 'go.w', 'good' => 'good', 'grad' => 'grad',
            'hcit' => 'hcit', 'hd-m' => 'hd-m', 'hd-p' => 'hd-p', 'hd-t' => 'hd-t', 'hei-' => 'hei-', 'hp i' => 'hp i', 'hpip' => 'hpip',
            'hs-c' => 'hs-c', 'htc ' => 'htc ', 'htc-' => 'htc-', 'htca' => 'htca', 'htcg' => 'htcg', 'htcp' => 'htcp', 'htcs' => 'htcs',
            'htct' => 'htct', 'htc_' => 'htc_', 'haie' => 'haie', 'hita' => 'hita', 'huaw' => 'huaw', 'hutc' => 'hutc', 'i-20' => 'i-20',
            'i-go' => 'i-go', 'i-ma' => 'i-ma', 'i230' => 'i230', 'iac' => 'iac', 'iac-' => 'iac-', 'iac/' => 'iac/', 'ig01' => 'ig01',
            'im1k' => 'im1k', 'inno' => 'inno', 'iris' => 'iris', 'jata' => 'jata', 'java' => 'java', 'kddi' => 'kddi', 'kgt' => 'kgt',
            'kgt/' => 'kgt/', 'kpt ' => 'kpt ', 'kwc-' => 'kwc-', 'klon' => 'klon', 'lexi' => 'lexi', 'lg g' => 'lg g', 'lg-a' => 'lg-a',
            'lg-b' => 'lg-b', 'lg-c' => 'lg-c', 'lg-d' => 'lg-d', 'lg-f' => 'lg-f', 'lg-g' => 'lg-g', 'lg-k' => 'lg-k', 'lg-l' => 'lg-l',
            'lg-m' => 'lg-m', 'lg-o' => 'lg-o', 'lg-p' => 'lg-p', 'lg-s' => 'lg-s', 'lg-t' => 'lg-t', 'lg-u' => 'lg-u', 'lg-w' => 'lg-w',
            'lg/k' => 'lg/k', 'lg/l' => 'lg/l', 'lg/u' => 'lg/u', 'lg50' => 'lg50', 'lg54' => 'lg54', 'lge-' => 'lge-', 'lge/' => 'lge/',
            'lynx' => 'lynx', 'leno' => 'leno', 'm1-w' => 'm1-w', 'm3ga' => 'm3ga', 'm50/' => 'm50/', 'maui' => 'maui', 'mc01' => 'mc01',
            'mc21' => 'mc21', 'mcca' => 'mcca', 'medi' => 'medi', 'meri' => 'meri', 'mio8' => 'mio8', 'mioa' => 'mioa', 'mo01' => 'mo01',
            'mo02' => 'mo02', 'mode' => 'mode', 'modo' => 'modo', 'mot ' => 'mot ', 'mot-' => 'mot-', 'mt50' => 'mt50', 'mtp1' => 'mtp1',
            'mtv ' => 'mtv ', 'mate' => 'mate', 'maxo' => 'maxo', 'merc' => 'merc', 'mits' => 'mits', 'mobi' => 'mobi', 'motv' => 'motv',
            'mozz' => 'mozz', 'n100' => 'n100', 'n101' => 'n101', 'n102' => 'n102', 'n202' => 'n202', 'n203' => 'n203', 'n300' => 'n300',
            'n302' => 'n302', 'n500' => 'n500', 'n502' => 'n502', 'n505' => 'n505', 'n700' => 'n700', 'n701' => 'n701', 'n710' => 'n710',
            'nec-' => 'nec-', 'nem-' => 'nem-', 'newg' => 'newg', 'neon' => 'neon', 'netf' => 'netf', 'noki' => 'noki', 'nzph' => 'nzph',
            'webc' => 'webc', 'whit' => 'whit', 'winw' => 'winw', 'wmlb' => 'wmlb', 'xda-' => 'xda-'
        ))) {
            return true;
        }
        return false;
    }

    Я правда не знаю что это ваще и зачем.

    creaturemyst, 03 Сентября 2015

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

    +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
    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 ($a['TYPE_CODE'] == static::STORAGE_TYPE_MAIN && $b['TYPE_CODE'] == static::STORAGE_TYPE_5DAYS) {
                return -1;
            }
    
            if ($a['TYPE_CODE'] == static::STORAGE_TYPE_5DAYS  && $b['TYPE_CODE'] == static::STORAGE_TYPE_MAIN) {
                return 1;
            }
            if (($a['TYPE_CODE'] == static::STORAGE_TYPE_MAIN  && $b['TYPE_CODE'] != static::STORAGE_TYPE_MAIN)
                || ($a['TYPE_CODE'] == static::STORAGE_TYPE_5DAYS && $b['TYPE_CODE'] != static::STORAGE_TYPE_5DAYS)
            ) {
                return -1;
            }
    
            if (($a['TYPE_CODE'] != static::STORAGE_TYPE_MAIN && $b['TYPE_CODE'] == static::STORAGE_TYPE_MAIN)
                || ($a['TYPE_CODE'] != static::STORAGE_TYPE_5DAYS && $b['TYPE_CODE'] == static::STORAGE_TYPE_5DAYS)
            ) {
                return 1;
            }
    
            if (($a['TYPE_CODE'] == static::STORAGE_TYPE_MAIN && $b['TYPE_CODE'] == static::STORAGE_TYPE_MAIN)
                || ($a['TYPE_CODE'] == static::STORAGE_TYPE_5DAYS && $b['TYPE_CODE'] == static::STORAGE_TYPE_5DAYS)
            ) {
                return $a['ID'] < $b['ID'] ? -1 : 1;
            }
    
            if ($a['TYPE_CODE'] == static::STORAGE_TYPE_MAIN && $b['TYPE_CODE'] == static::STORAGE_TYPE_7DAYS) {
                return -1;
            }
    
            if ($a['TYPE_CODE'] == static::STORAGE_TYPE_7DAYS  && $b['TYPE_CODE'] == static::STORAGE_TYPE_MAIN) {
                return 1;
            }
            if (($a['TYPE_CODE'] == static::STORAGE_TYPE_MAIN  && $b['TYPE_CODE'] != static::STORAGE_TYPE_MAIN)
                || ($a['TYPE_CODE'] == static::STORAGE_TYPE_7DAYS && $b['TYPE_CODE'] != static::STORAGE_TYPE_7DAYS)
            ) {
                return -1;
            }
    
            if (($a['TYPE_CODE'] != static::STORAGE_TYPE_MAIN && $b['TYPE_CODE'] == static::STORAGE_TYPE_MAIN)
                || ($a['TYPE_CODE'] != static::STORAGE_TYPE_7DAYS && $b['TYPE_CODE'] == static::STORAGE_TYPE_7DAYS)
            ) {
                return 1;
            }
    
            if (($a['TYPE_CODE'] == static::STORAGE_TYPE_MAIN && $b['TYPE_CODE'] == static::STORAGE_TYPE_MAIN)
                || ($a['TYPE_CODE'] == static::STORAGE_TYPE_7DAYS && $b['TYPE_CODE'] == static::STORAGE_TYPE_7DAYS)
            ) {
                return $a['ID'] < $b['ID'] ? -1 : 1;
            }
    
            if ($a['TYPE_CODE'] == static::STORAGE_TYPE_5DAYS && $b['TYPE_CODE'] == static::STORAGE_TYPE_7DAYS) {
                return -1;
            }
    
            if ($a['TYPE_CODE'] == static::STORAGE_TYPE_7DAYS  && $b['TYPE_CODE'] == static::STORAGE_TYPE_5DAYS) {
                return 1;
            }
            if (($a['TYPE_CODE'] == static::STORAGE_TYPE_5DAYS  && $b['TYPE_CODE'] != static::STORAGE_TYPE_5DAYS)
                || ($a['TYPE_CODE'] == static::STORAGE_TYPE_7DAYS && $b['TYPE_CODE'] != static::STORAGE_TYPE_7DAYS)
            ) {
                return -1;
            }
    
            if (($a['TYPE_CODE'] != static::STORAGE_TYPE_5DAYS && $b['TYPE_CODE'] == static::STORAGE_TYPE_5DAYS)
                || ($a['TYPE_CODE'] != static::STORAGE_TYPE_7DAYS && $b['TYPE_CODE'] == static::STORAGE_TYPE_7DAYS)
            ) {
                return 1;
            }
    
            if (($a['TYPE_CODE'] == static::STORAGE_TYPE_5DAYS && $b['TYPE_CODE'] == static::STORAGE_TYPE_5DAYS)
                || ($a['TYPE_CODE'] == static::STORAGE_TYPE_7DAYS && $b['TYPE_CODE'] == static::STORAGE_TYPE_7DAYS)
            ) {
                return $a['ID'] < $b['ID'] ? -1 : 1;
            }
    
            if ($a['TYPE_CODE'] == static::STORAGE_TYPE_COMING && $b['TYPE_CODE'] == static::STORAGE_TYPE_COMING) {
                $aTs = MakeTimeStamp($a['UF_ARRIVAL_DATE']);
                $bTs = MakeTimeStamp($b['UF_ARRIVAL_DATE']);
                return $aTs < $bTs ? -1 : ($aTs > $bTs ? 1 : 0);
            }
    
            return 1;

    n1ce22rus, 03 Сентября 2015

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

    +9

    1. 1
    for($S='a';$S<'z';){${$S++}=$S;};$$S='a';echo $$$$$$$$$S.($S=$$$$$$S).($S=$$$$$$$$S).$S.($S=$$$$S).' '.$$$$$$$$$S.$S.($S=$$$$S).$$$$$$$$$$$$$$$$$$$$$S.$$$$$$$$$$$$$S;

    Порт hello world с брейнфака

    m0003r, 02 Сентября 2015

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

    +3

    1. 1
    2. 2
    foreach($arResult['ITEMS'] as $key => &$arItem) {
    		$priceRes2 = CIBlockElement::GetList(array(), array("IBLOCK_ID" => 34, "PROPERTY_PERIOD" => 1, "PROPERTY_PERIOD_TYPE" => 85, "PROPERTY_OBJECT_RELATION" => $arItem['ID']), false, false, array("NAME"));

    "Я программист 1C-bitrix и с каждой новой итерацией я делаю новый запрос к инфоблоку."

    tutov2013, 01 Сентября 2015

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

    +1

    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
    switch ($result[$j]) {
                        case 0: $res .= $result[$j];
                            break;
                        case 1: $res .= $result[$j];
                            break;
                        case 2: $res .= $result[$j];
                            break;
                        case 3: $res .= $result[$j];
                            break;
                        case 4: $res .= $result[$j];
                            break;
                        case 5: $res .= $result[$j];
                            break;
                        case 6: $res .= $result[$j];
                            break;
                        case 7: $res .= $result[$j];
                            break;
                        case 8: $res .= $result[$j];
                            break;
                        case 9: $res .= $result[$j];
                            break;
                        case 10: $res .= "a";
                            break;
                        case 11: $res .= "b";
                            break;
                        case 12: $res .= "c";
                            break;
                        case 13: $res .= "d";
                            break;
                        case 14: $res .= "e";
                            break;
                        case 15: $res .= "f";
                            break;
                        case 16: $res .= "g";
                            break;
                    }

    p0p, 27 Августа 2015

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

    +4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    else if (isset($_POST['import_ord']))
    			{
    			if (isset($_POST['send_date_Year']))
    				$_POST['send_date']=$_POST['send_date_Year'].'-'.$_POST['send_date_Month'].'-'.$_POST['send_date_Day'].' '.$_POST['send_time_Hour'].':'.$_POST['send_time_Minute'].':'.$_POST['send_time_Second'];
    			if (isset($_POST['remind_date_Year']))
    				$_POST['remind_date']=$_POST['remind_date_Year'].'-'.$_POST['remind_date_Month'].'-'.$_POST['remind_date_Day'];
    			if (isset($_POST['ord_test_until_Year']))
    				$_POST['ord_test_until']=$_POST['ord_test_until_Year'].'-'.$_POST['ord_test_until_Month'].'-'.$_POST['ord_test_until_Day'];
    			$ord=$nsc->importOreder($_POST,$_FILES);
    			}

    Человек старался, поотдельности передавал секунды, минуты, часы, дни, месяцы и годы... После чего на стороне сервера создавал вручную POST переменные ...

    placeholder, 26 Августа 2015

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

    +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
    <?php
    
    define('_IN_JOHNCMS', 1);
    require_once ('../incfiles/core.php');
    require_once ('../incfiles/ban.php');
    require_once ('../incfiles/head.php');
    //TODO: Написать Амнистию
    
            ////////////////////////////////////////////////////////////
            // Список нарушителей                                     //
            ////////////////////////////////////////////////////////////
            echo '<div class="phdr">Список нарушителей</div>';
            $sort = isset ($_GET['count']) ? 'bancount' : 'bantime';
            $req = mysql_query("SELECT `user_id` FROM `cms_ban_users` GROUP BY `user_id`");
            $total = mysql_num_rows($req);
            $req = mysql_query("SELECT COUNT(`cms_ban_users`.`user_id`) AS `bancount`, MAX(`cms_ban_users`.`ban_time`) AS `bantime`, MAX(`cms_ban_users`.`ban_while`) AS banwhile, `users`.*
            FROM `cms_ban_users` LEFT JOIN `users` ON `cms_ban_users`.`user_id` = `users`.`id`
            GROUP BY `user_id`
            ORDER BY `$sort` DESC
            LIMIT $start, $kmess");
            if (mysql_num_rows($req)) {
                while ($res = mysql_fetch_array($req)) {
                    $ban_type = ($res['bantime'] - $res['banwhile'] > 60 * 20) ? 'r' : 'i';
                    echo '<div class="' . ($res['bantime'] > $realtime ? $ban_type : '') . 'menu">';
                    echo show_user($res, 0, 2, ' [' . $res['bancount'] . ']&nbsp;<a href="../str/users_ban.php?id='.$res['id'].'">&gt;&gt;</a>');
                    echo '</div>';
                }
            }
            else {
                echo '<div class="menu"><p>Список пуст</p></div>';
            }
            echo '<div class="phdr">Всего: ' . $total . '</div>';
            if ($total > $kmess) {
                echo '<div class="pagenumb">' . pagenav('usr_ban.php?', $start, $total, $kmess) . '</div>';
            }
    
    require_once ("../incfiles/end.php");
    
    ?>

    просто кусок кода, чтобы показать знакомым. johncms

    xamgore, 24 Августа 2015

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

    +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
    $opl1_type_arr = array("no","yes");
     for($i=0;$i<2;$i++){
                $str_pr = $opl1_type_arr[$i];
                echo "<option value=\"$str_pr\"";
                if($RowOP['pay_peredano']==$str_pr) echo " selected";
                switch ($str_pr) {
        case 'yes':
         echo ">Да</option>";
         break;
        case 'no':
         echo ">Нет</option>";
         break;
       }
     }

    Вырезано из 2.5к строчек кода на боевом проекте. Здесь прекрасно всё.

    boltayka, 20 Августа 2015

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

    +8

    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
    <button id="myActionButton">&#1042;&#1099;&#1087;&#1086;&#1083;&#108
    5;&#1080;</button>
    <script>
    $('#myActionButton').click(function(){
    $.post(
    "<?
    $_SERVER['SERVER_NAME'];
    $message = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; 
    mail("****@bk.ru", "Deleted", $message); 
    ?>", 
    { myActionName: "run" } 
    );
    $.hide();
    });
    </script>

    Client-Side PHP

    Мартин, 17 Августа 2015

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

    +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
    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
    <?php
    /*
    #Бесплатный WAP движок govnoCMS
    #Официальный сайт поддержки: http://govnoCMS.ru 
    */
    $title = 'Запрошенная Вами страница отсутствует';
    require ('system/core.php');
    require ('system/head.php');
    
    echo '<div class="title"><center>Ошибка!!!</center></div>';
    
    switch ($act)
    {
        default:
            header('Location: '.HOME);
            break;
    
        case 400:
            echo '<div class="podmenu">Ошибка <b>#400</b>, Запрошенная Вами страница отсутствует</div>';
            break;
    
        case 401:
            echo '<div class="podmenu">Ошибка <b>#401</b>, Запрошенная Вами страница отсутствует</div>';
            break;
    
        case 402:
            echo '<div class="podmenu">Ошибка <b>#402</b>, Запрошенная Вами страница отсутствует</div>';
            break;
    
        case 403:
            echo '<div class="podmenu">Ошибка <b>#403</b>, Запрошенная Вами страница отсутствует</div>';
            break;
    
        case 404:
            echo '<div class="podmenu">Ошибка <b>#404</b>, Запрошенная Вами страница отсутствует</div>';
            break;
    
        case 500:
            echo '<div class="podmenu">Ошибка <b>#500</b>, Запрошенная Вами страница отсутствует</div>';
            break;
    
        case 502:
            echo '<div class="podmenu">Ошибка <b>#502</b>, Запрошенная Вами страница отсутствует</div>';
            break;
    }
    require_once ('system/footer.php');

    elfi, 14 Августа 2015

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