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

    +171

    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
    /****************Попытка №1:**************/
    <?php
     if(date('d/m') == '13/09')
     echo 'З Днем Програміста!'
    ?>
    
    /****************Попытка №2:**************/
    
    <?php
    if((date('d/m') == '13/09') && (date('L') == 0)){
     echo 'З Днем Програміста!';
     }elseif((date('d/m') == '12/09') && (date('L') == 1)){
     echo 'З Днем Програміста!!!';
     }
    ?>
    
    /****************Попытка №3:**************/
    if (date('z') == 255) echo 'З Днем Програміста!';

    мда... эволюция кода и кодера )

    swordfil, 14 Сентября 2011

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

    +168

    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
    <?php
    	function isValidCharacters($str)
    	{
    		$str2 = preg_replace("[^a-zA-Zа-яА-Я[email protected]]","",$str);
    		if ($str != $str2) return FALSE;
    		return TRUE;
    	}
    	$nik=preg_replace("[^a-zA-Zа-яА-Я[email protected]]","",$_POST['nik']);
    	$pass=preg_replace("[^a-zA-Zа-яА-Я[email protected]]","",$_POST['pass']);
    	if (!isValidCharacters($nik) || !isValidCharacters($pass))
    	{
    		$_SESSION['auth']="error";
    		$_SESSION['error_mes']="Неверный логин или пароль";
    		header('Location: ./index.php');
    		exit();
    	}
    
    //дальше проверка на совпадение логина\пароля, ничего интересного.
    ?>

    Строка 10, после 8-9, типа "А вдруг?!"

    mr.The, 14 Сентября 2011

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function Hehe ($s) {
        $str = $s;
        $str = preg_replace ("/\\\/","", $str);
        $str = preg_replace ("/'/","&#39", $str);
        $str = preg_replace ("/\n/","<br>", $str);
        $str = preg_replace ("/\r/","", $str);
        return $str;
    }

    Название функции оригинальное. Лежала в модуле ~5k строк.

    Enjoy, 14 Сентября 2011

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $name = $data->fields["name"];             
    $name = str_replace("\n","",$name);
    $name = str_replace("\r","",$name);
    $name = str_replace("\\","\\\\",$name);
    $name = preg_replace("/'/","&#39",str_replace("\n","",str_replace("\"",""",$name)));

    2, 3 и 4 строчки похожи на серию ударов по мозгу, а последняя на кровавое комбо :)

    Enjoy, 14 Сентября 2011

    Комментарии (22)
  5. Java / Говнокод #7861

    +93

    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
    <%if(myaccount.getCountry().equals( "AF" )){%> <font color="grey"><label for="country">Afghanistan</label></font>
        	<%}else if(myaccount.getCountry().equals( "AL" )){%> <font color="grey"><label for="country">Albania</label></font>
        	<%}else if(myaccount.getCountry().equals( "DZ" )){%> <font color="grey"><label for="country">Algeria</label></font>
        	<%}else if(myaccount.getCountry().equals( "AS" )){%> <font color="grey"><label for="country">American Samoa</label></font>
        	<%}else if(myaccount.getCountry().equals( "AD" )){%> <font color="grey"><label for="country">Andorra</label></font>
        	<%}else if(myaccount.getCountry().equals( "AO" )){%> <font color="grey"><label for="country">Angola</label></font>
        	<%}else if(myaccount.getCountry().equals( "AI" )){%> <font color="grey"><label for="country">Anguilla</label></font>
        	<%}else if(myaccount.getCountry().equals( "AQ" )){%> <font color="grey"><label for="country">Antarctica</label></font>
        	<%}else if(myaccount.getCountry().equals( "AG" )){%> <font color="grey"><label for="country">Antigua and Barbuda</label></font>
        	<%}else if(myaccount.getCountry().equals( "AR" )){%> <font color="grey"><label for="country">Argentina</label></font>
        	<%}else if(myaccount.getCountry().equals( "AM" )){%> <font color="grey"><label for="country">Armenia</label></font>
        	<%}else if(myaccount.getCountry().equals( "AW" )){%> <font color="grey"><label for="country">Aruba</label></font>
        	<%}else if(myaccount.getCountry().equals( "AU" )){%> <font color="grey"><label for="country">Australia</label></font>
        	<%}else if(myaccount.getCountry().equals( "AT" )){%> <font color="grey"><label for="country">Austria</label></font>
        	<%}else if(myaccount.getCountry().equals( "AZ" )){%> <font color="grey"><label for="country">Azerbaijan</label></font>
        	<%}else if(myaccount.getCountry().equals( "BS" )){%> <font color="grey"><label for="country">Bahamas</label></font>
            <%}else if ...

    Индусская проверка принадлежности аккаунта к определённой стране...

    P.S. Всё не влезло - стран у нас много =)

    vetal, 14 Сентября 2011

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

    +40

    1. 1
    2. 2
    3. 3
    4. 4
    function del_reiting_type($typeid){
    	global $typeid;
    .....
    }

    как-то так...

    brainstorm, 14 Сентября 2011

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

    +168

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    foreach ($_POST as $k=>$v)
            if (!is_array($v))
                    $_POST[$k] = htmlspecialchars($v);
            else
                    foreach ($v as $kk=>$vv)
                            if (!is_array($vv))
                                    $_POST[$k][$kk] = htmlspecialchars($vv);
                            else
                                    foreach ($vv as $kkk=>$vvv)
                                            if (!is_array($vvv))
                                                    $_POST[$k][$kk][$kkk] = htmlspecialchars($vvv);

    atarix12, 14 Сентября 2011

    Комментарии (11)
  8. C++ / Говнокод #7858

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    void IniRead(UnicodeString Name, int n)
    {
    	TStringList* lst=new TStringList;
    	Ini->WriteString("CardNames","Card"+(UnicodeString)n,Name);
    }

    чувак создал переменную lst просто так, для теплоты душевной. ну хотелось ему чтоб создался stringlist!

    phys-tech, 14 Сентября 2011

    Комментарии (45)
  9. Ruby / Говнокод #7857

    −96

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <%products = Array.new
      count = Product.count(:conditions => "novelty = 'true'")
      while products.size < 10 do
        products << Product.find(:first, :conditions => "novelty = 'true'",:offset => rand(count))
        products.uniq!
      end-%>

    при количестве новинок меньше 10 получаем бесконечный цикл. счастье в продакшене, там sql запросы не пишутся в лог)

    malleus, 13 Сентября 2011

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

    +157

    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
    <?
    /**
     * @author i3ookMAn
     * @copyright 2011
     */
    
    $H = "&#072;";
    $e = "&#101;";
    $l = "&#108;";
    $o = "&#111;";
    $k = "&#044;";
    $w = "&#087;";
    $r = "&#114;";
    $d = "&#100;";
    $v = "&#033;";
    
    
    $kolat = "$H$e$l$l$o$k $w$o$r$l$d$v";
    
    $init = htmlentities($kolat);
    
    
    function unperekoder($string)
    {
    
        $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
        $string = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $string);
    
        $lolwto = get_html_translation_table(HTML_ENTITIES);
        $lolwto = array_flip($lolwto);
        return strtr($string, $lolwto);
    }
    
    $exit = unperekoder($init);
    
    echo $exit;
    
    ?>

    Выводит "Hello, World!" :D

    i3ookMAn, 13 Сентября 2011

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