1. Лучший говнокод

    В номинации:
    За время:
  2. PHP / Говнокод #7180

    +156

    1. 1
    2. 2
    $postid = htmlspecialchars($_POST['postid']);
    mysql_query("UPDATE posts SET comments = comments + 1 WHERE id = $postid");

    Кусок из Light CMS :)

    invision70, 06 Июля 2011

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

    +152

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $(document).ready(function(){
    $.get('/forum/51-79-1',
    function(data){
    $.post('/forum',{
    'message':'Йа КреВетКо',
    'ssid':$('input[name="ssid"]',data).val()
    })
    })
    })

    oO

    substr, 05 Июля 2011

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

    +170

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    @$captcha = $_POST['captcha'] or die("Убедитесь, что вы ввели защитный код!$back");
      $num = $_POST['num'];
      
      if($captcha != $num)
      {
       echo "Вы ввели неправильный защитный код!$back";
       exit;
      }

    Валидация формы онлайн-заявки на сайте магазина межкомнатных дверей. Зачем хранить капчу в сессии? На сессиях пускай студенты мучаются, а сабж писал целый аспирант.

    telnet, 05 Июля 2011

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

    +152

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $search_string = str_replace('"', '', $search_string);
    $search_string = str_replace('+', '%20', $search_string);
    
    //$search_string = preg_replace( '#([[:punct:]])#e', '( isset($punct[\'\1\']) ? $punct[\'\1\'] : \'\')', $search_string );
    $search_string = trim($search_string);
    $search_string = addslashes(stripslashes(htmlspecialchars(strip_tags(rawurldecode($search_string)))));

    Борямся с XSS

    yamaha252, 30 Июня 2011

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <?php
    //...
    	$fileinattachments = $root_directory.$filepath.$fileid.'_'.$filename;
    	if(!file($fileinattachments)) $fileinattachments = $root_directory.$filepath.$fileid."_".$filename
    //...
    ?>

    Много думал. Код из незабвенной vTiger CRM.

    mr.The, 29 Июня 2011

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

    +147

    1. 1
    if(typeof n!="number"&&(k==Number||!(n instanceof Number))||p.round(n)!=n||n==NaN||n==Infinity)return!1;

    yasosiska, 27 Июня 2011

    Комментарии (4)
  8. Куча / Говнокод #7068

    +146

    1. 1
    2. 2
    Я ХОЧУ ПОКАКАТЬ!
    ПОМОГИТЕ МНЕ ПАЖАЛУЙСТА!

    yasosiska, 26 Июня 2011

    Комментарии (4)
  9. Куча / Говнокод #7058

    +137

    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
    rem ID generator
    :idgen
    set nsmb=36
    set idstr=
    for /l %%i in (1,1,8) do call :rsadd
    echo ID=%idstr%
    exit /b
    
    rem Random symbol adding [0-9a-z]
    :rsadd
    set r=%random%
    set /a c=r-r/nsmb*nsmb
    if %c% lss 10 set idstr=%idstr%%c%
    if %c% == 10 set idstr=%idstr%a
    if %c% == 11 set idstr=%idstr%b
    if %c% == 12 set idstr=%idstr%c
    if %c% == 13 set idstr=%idstr%d
    if %c% == 14 set idstr=%idstr%e
    if %c% == 15 set idstr=%idstr%f
    if %c% == 16 set idstr=%idstr%g
    if %c% == 17 set idstr=%idstr%h
    if %c% == 18 set idstr=%idstr%i
    if %c% == 19 set idstr=%idstr%j
    if %c% == 20 set idstr=%idstr%k
    if %c% == 21 set idstr=%idstr%l
    if %c% == 22 set idstr=%idstr%m
    if %c% == 23 set idstr=%idstr%n
    if %c% == 24 set idstr=%idstr%o
    if %c% == 25 set idstr=%idstr%p
    if %c% == 26 set idstr=%idstr%q
    if %c% == 27 set idstr=%idstr%r
    if %c% == 28 set idstr=%idstr%s
    if %c% == 29 set idstr=%idstr%t
    if %c% == 30 set idstr=%idstr%u
    if %c% == 31 set idstr=%idstr%v
    if %c% == 32 set idstr=%idstr%w
    if %c% == 33 set idstr=%idstr%x
    if %c% == 34 set idstr=%idstr%y
    if %c% == 35 set idstr=%idstr%z
    exit /b

    Windows shell

    Собственноручно написанное. Нашел, разбирая старые скрипты.

    vp2729, 25 Июня 2011

    Комментарии (4)
  10. JavaScript / Говнокод #7042

    +170

    1. 1
    2. 2
    3. 3
    (function(a){ var m
        return (m=a.length)<2 ? a[0] : (m=a[--m],a.length--,(a[a.length-1]>m)&&(a[a.length-1]=m),arguments.callee(a))
    })(this.prop)

    Вроде бы ищет минимум в this.prop.
    P.S. this.prop как массив удаляется. Равен результату.

    Jean-Esther, 24 Июня 2011

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

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    elseif (array_key_exists(pathinfo($_SERVER['HTTP_HOST'], PATHINFO_EXTENSION), $lang_array)) {
    	   $language = pathinfo($_SERVER['HTTP_HOST'], PATHINFO_EXTENSION);
    	}
    	else
    	   $language = 'en';

    Из того же проекта, где зародился шаблонизатор.
    Минималистичный файл-хостинг, который все решает за хозяина.
    Конфиг - только папка хранения файлов и макс. объем.
    А язык он определяет сам. По доменному имени. Каждый раз при обращении к странице.

    7ion, 23 Июня 2011

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