1. 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)
  2. 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)
  3. PHP / Говнокод #13809

    +158

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

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

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    foreach (array('peer_id','port','downloaded','uploaded','left') as $x){
        if (!isset($x))
        err('', "Нет переменной - ".$x, 1);
    }

    Озадачился. Куда может пропасть $x?

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

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

    +141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    class test {
            var $пиздец = 'это он';
     
    function вывод() {
     echo $this->пиздец;
    }
     
    }
     
    $a = new test();
    $a->вывод();

    http://www.skillz.ru/dev/php/article-first_c_otkake.html

    Stealth, 17 Сентября 2013

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $imgs = glob('images/'.$url_parts[0].'/*');
        
        // Windows detection
        if(DIRECTORY_SEPARATOR == '\\') {
            $cnt = count($imgs);
            for($i = 0; $i < $cnt; $i++) $imgs[$i] = iconv('CP1251//IGNORE', 'UTF-8', $imgs[$i]);
        }

    DIX315, 17 Сентября 2013

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

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    ...
    $str = preg_replace ( array_keys ( $new ), array_values ( $new ), $str );
    $str = trim ( $str );
    $str = str_replace ( "       ", "_", $str );
    $str = str_replace ( "      ", "_", $str );
    $str = str_replace ( "     ", "_", $str );
    $str = str_replace ( "    ", "_", $str );
    $str = str_replace ( "   ", "_", $str );
    $str = str_replace ( "  ", "_", $str );
    $str = str_replace ( " ", "_", $str );

    develx0, 16 Сентября 2013

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

    +26

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $arr['body'][$row_num] = array(
                $datas,
                $tval,
                $club1_link,
                ($results['results_url'] != '' ? '<a href="' . $results['results_url'] . '"' . ($results['results_class'] != '' ? $results['results_class'] : '') . '>' : '<span>') . $results['results'] . ($results['results_url'] != '' ? '</a>' : '</span>'),
                $club2_link,
                spb_stats_show_media_icons($row),
            );

    было еще хуже. каждая строка была адовый тернарник...

    brainstorm, 16 Сентября 2013

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

    +140

    1. 1
    2. 2
    3. 3
    4. 4
    define('SECOND', 1);
    define('MINUTE', SECOND*60);
    define('HOUR', MINUTE*60);
    // ...

    количество секунд в секунде — это определённо что-то новое.

    fidelcomandante, 16 Сентября 2013

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

    +151

    1. 1
    2. 2
    if (!preg_match_all("!<tr class=\"dark\">\s+<td>.*?</td>\s+<td class=\"cell1\">.*?>stock.zip</td>\s+<td>(.*?)</td>\s+<td>.*?</td>\s+<td><a href=\"(.*?)\    ">.*?</a></td>\s+<td>.*?</td>\s+</tr>!is", $out['body'], $res))
      exit(say("Не найден файл со стоком"));

    грузим прайсы партнёра

    heyzea1, 13 Сентября 2013

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