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

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

    +167

    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
    class xsspolice 
    { 
    function getip() { 
    $ipno = getenv("REMOTE_ADDR");  
    return $ipno; 
    } 
    function look_data($data) { 
    $ip=$this->getip(); 
    $data = strtolower($data); 
    $br=$_SERVER['HTTP_USER_AGENT']; 
    $datenow=date("y-m-d h:m:s"); 
    if(isset($_SESSION['user'])) { 
    $username=$_SESSION['user']; 
    }else { 
    $username="unknown"; 
    } 
    if (strstr($data,"<") OR strstr($data,">") OR strstr($data,"(") OR strstr($data,")") OR 
    strstr($data,"..") OR 
    strstr($data,"%") OR 
    strstr($data,"*") OR 
    strstr($data,"+") OR 
    strstr($data,"!") OR 
    strstr($data,"@")) { 
    $this->validate_befor(); 
    $dirtystuff = array("\"", "\\", "/", "*", "'", "=", "- 
    ", "#", ";", "<", ">", "+", "%","(",")","}","{"); 
    $data = str_replace($dirtystuff, "", $data); 
    $data = htmlspecialchars($data); 
    $data = strip_tags($data); 
    $sql="INSERT INTO `attack` (`attacker_id`, `attacker_ip`, `attacker_username`, `attacker_date`, `attacker_comname`, `attacker_browsername`) VALUES (NULL, '".$ip."', '".$username."', '".$datenow."', 'test', '".$br."')";
    mysql_query($sql)or die("ٍError message"); 
    return $data; 
    }else 
    { 
    return $data; 
    } 
    } 
    function validate_befor() { 
    $ip=$this->getip(); 
    $sql="SELECT COUNT(`attacker_id`) FROM `attack` WHERE `attacker_ip`='".$ip."'"; 
    $sql=mysql_query($sql); 
    $sql=mysql_fetch_row($sql); 
    if ($sql[0]>=3) { 
    header("location: police.htm"); 
    } 
    } 
    } 
    ?>

    По ходу у Попова учился...
    Доставляет всё(к die() уже прувык...), но строка 26-29 О_о
    Это мания ???
    [url]http://www.phpclasses.org/package/7110-PHP-Block-accesses-attempting-to-perform-XSS-attacks.html[/url]

    AlexanderC, 26 Августа 2011

    Комментарии (12)
  3. C++ / Говнокод #7642

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    char *sLoop = new char[4];
    _itoa(i, sLoop, 10);
    string strField = fp1 + sLoop + fp2;
    char *str = new char[255];
    for (int i=0; i<=sizeof(strField); i++)
        str[i] = strField[i];
    _bstr_t impFieldName(str);
    // думаю, очевдно, что delete нигде не было. ;)

    Говногость, 25 Августа 2011

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $used_vars = Array ("s_user","s_roles","s_error");
    
    	for ($i = 0; $i < sizeof($used_vars); $i++) {
    		eval ("unset(\$".$used_vars[$i].");");
    	}

    humbug, 19 Августа 2011

    Комментарии (15)
  5. JavaScript / Говнокод #7463

    +167

    1. 1
    $('.menu-left li:last').parent().parent().attr('class', $('#menu-menu_building li:last').parent().parent().attr('class')+' last');

    К классу последнего li главного ul в выпадающем списке добавляется 'last'.

    EugeneC, 05 Августа 2011

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

    +167

    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
    $select = $db->select()
    ->from('advertisement AS a', $columns)
    ->joinLeft('resid_apt_secondary AS ras', 'ras.resid_apartment_residental_advertisement_id=a.id', array())
    ->joinLeft('resid_apt_newly_unready AS ranu', 'ranu.resid_apartment_residental_advertisement_id=a.id', array())
    ->joinLeft('resid_apt_newly_ready AS ranr', 'ranr.resid_apartment_residental_advertisement_id=a.id', array())
    ->joinLeft('resid_house_house AS rh', 'rh.resid_house_residental_advertisement_id=a.id', array())
    ->joinLeft('resid_house_cottage AS rc', 'rc.resid_house_residental_advertisement_id=a.id', array())
    ->joinLeft('resid_house_dacha AS rd', 'rd.resid_house_residental_advertisement_id=a.id', array())
    ->joinLeft('resid_garage AS rg', 'rg.residental_advertisement_id=a.id', array())
    ->joinLeft('sec_residental AS sr', 'sr.section_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_common AS bpc', 'bpc.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_food AS bpf', 'bpf.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_restaurant AS bpr', 'bpr.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_warehouse AS bpw', 'bpw.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_garage AS bpg', 'bpg.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_service_station AS bpss', 'bpss.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_other AS bpo', 'bpo.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_office_any AS boa', 'boa.bld_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_office_admin AS boad', 'boad.bld_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_office_sales AS bos', 'bos.bld_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_office_kiosk AS bok', 'bok.bld_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_farm_cowshed AS bfc', 'bfc.bld_farm_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_farm_workshop AS bfw', 'bfw.bld_farm_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_farm_chicken_house AS bfch', 'bfch.bld_farm_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_farm_other AS bfo', 'bfo.bld_farm_commercial_advertisement_id=a.id', array())
    ->joinLeft('gas_station AS gs', 'gs.commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_common AS rpc', 'rpc.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_food AS rpf', 'rpf.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_restaurant AS rpr', 'rpr.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_warehouse AS rpw', 'rpw.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_garage AS rpg', 'rpg.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_service_station AS rpss', 'rpss.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_other AS rpo', 'rpo.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_office_any AS roa', 'roa.rm_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_office_sales AS ros', 'ros.rm_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_office_off AS roo', 'roo.rm_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_office_admin AS road', 'road.rm_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_office_hall_rental AS roh', 'roh.rm_office_commercial_advertisement_id=a.id', array())
    ->where('is_recycled = ?', 'no')
    ->where('is_published = ?', 'yes')
    ->group(array('a.type', 'a.in_archive'));

    Переделываем проект. В старой версии нашел следующие строчки.

    nkarakin, 25 Июля 2011

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

    +167

    1. 1
    $r = $this->client->getBerechneteGrundversorgungsTarifebyPLZundVerbrauchKundenart($this->params);

    По сути не говнокод, но нечитабельность налицо...

    vov4ik, 13 Июня 2011

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

    +167

    1. 1
    <a title="Главная" href="http://<?php echo $_SERVER['HTTP_HOST'].str_replace('\\', '', dirname($_SERVER['PHP_SELF'])); ?>">Главная</a>

    нашел в одном проекте, я бы и не смог до такого додуматься

    alextg, 04 Июня 2011

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function mysql_escape($s)
    {
    	if (preg_match('/\b(select|union|update|replace|delete|create)\b/ui', $s))
    		return null;
    
    	return mysql_escape_string($s);
    }

    SQL Injection не пройдёт!

    vsu, 14 Мая 2011

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    /* DO NOT UNCOMMENT THIS CODE AGAIN.  THIS IS THE 3rd TIME I'VE HAD TO REMOVE THIS.
        if($("form#purchase_form").length) {
            var currentPaymentValue = $("input[name='paymentFormOverride']:checked", "#purchase_form").val();
            if (currentPaymentValue == 'cc')
                $("#pp_payment_method").click(function(){paymentRedirect('pp')});
            else
                $("#cc_payment_method").click(function(){paymentRedirect('cc')});
        }
    	*/

    Чоткая обратная связь :))

    kovel, 11 Мая 2011

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

    +167

    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
    struct LexicalToken
            {
            public:
                LexicalToken(DataStructs::Lexem &lex,
                             SyntaxTree::SyntaxNode::Type type,
                             const IOSystem::Position &pos = IOSystem::Position()) :
                    lexem(lex), position(pos), type(type)
                {}
    
                LexicalToken(const LexicalToken &other) :
                    lexem(other.lexem), position(other.position), type(other.type)
                {}
    
                LexicalToken& operator = (const LexicalToken &other)
                {
                    memcpy(this, &other, sizeof(LexicalToken));
                    return *this;
                }
    
                DataStructs::Lexem &lexem;
                IOSystem::Position position;
                SyntaxTree::SyntaxNode::Type type;
            };

    Use pointers, Luke

    Elvenfighter, 09 Мая 2011

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