1. Python / Говнокод #7866

    −179

    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
    def mac_search(*args):
        db = MySQLdb.connect(host="localhost",user="test",passwd="test",db="test")
        cursor = db.cursor()
        cursor.execute('SELECT * FROM ip_groups WHERE mac="%s" AND is_deleted=0;' %args[0].split()[0])
        for j in cursor.fetchall():
            cursor.execute("SELECT * FROM iptraffic_service_links WHERE ip_group_id=%s and is_deleted=0;" %j[1])
            for j1 in cursor.fetchall():
                cursor.execute("SELECT * FROM service_links WHERE id=%s AND is_deleted=0;" %j1[0])
                for j2 in cursor.fetchall():
                    cursor.execute("SELECT * FROM accounts WHERE is_deleted=0 AND id=%s AND is_blocked=0;" %j2[2])
                    for j3 in cursor.fetchall():
                        cursor.execute("SELECT * FROM service_links WHERE account_id=%s AND is_deleted=0;" %j2[2])
                        for j4 in cursor.fetchall():
                            if j4[3]==465 or j4[3]==641:
                                cursor.execute("SELECT * FROM s_multicast WHERE service_id=%s AND %s>=ip_start AND %s<=ip_end;" %(j4[3],args[0].split()[1],args[0].split()[1]))
                                for j5 in cursor.fetchall():
                                    return j5

    Я конечно понимаю, таким уже не удивить. Но все же.

    http://www.python.su/forum/viewtopic.php?pid=76855

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

    Комментарии (5)
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. 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)
  7. PHP / Говнокод #7860

    +40

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

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

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

    Комментарии (7)
  8. 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)
  9. 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)
  10. 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)