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

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

    +163

    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
    function BuildPath()
    {
    	global $pathroot;
    
    	$full=strtolower(trim($_SERVER["site.ru"]));
    	$full=str_replace("\\\\","\\",$full);
    	$full=str_replace("\\","/",$full);
    	$full=str_replace("//","/",$full);
    
    	$small=strtolower(trim($_SERVER["PHP_SELF"]));
    	$small=str_replace("\\\\","\\",$small);
    	$small=str_replace("\\","/",$small);
    	$small=str_replace("//","/",$small);
    
    }

    ru_maniac, 09 Января 2012

    Комментарии (10)
  3. Python / Говнокод #8767

    −89

    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
    def get_caller_module_dict(levels):
        try:
            raise RuntimeError
        except RuntimeError:
            e,b,t = sys.exc_info()
            f = t.tb_frame
            while levels > 0:
                f = f.f_back                   
                levels -= 1
            ldict = f.f_globals.copy()
            if f.f_globals != f.f_locals:
                ldict.update(f.f_locals)
    
            return ldict

    cxielamiko, 08 Декабря 2011

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

    +80

    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
    /** ���� ��������� ���� @P@R@I@V@E@T@ @1@8 - ���� ��� ���� ������ */
            public static String removeSabakaCoding(String inStr)
            {
                    try {
                            char[] chars = inStr.toCharArray();
                            StringBuffer sb = new StringBuffer();
                            boolean mustBe = true;
                            boolean sobakaCoding = true;
                            for (int i = 0; i < inStr.length(); i++)
                            {
                                    if (mustBe)
                                    {
                                            if (chars[i] == '@')
                                            { // ���� ��� sobakaCoding � ����..
                                            } else
                                            {
                                                sobakaCoding = false;
                                                break;
                                            }
                                    } else
                                            sb.append(chars[i]);
                                    mustBe=!mustBe;
                            }
                            if (sobakaCoding)
                                    return sb.toString();
                    } catch (Exception e)
                    {
                            e.printStackTrace();
                    }
                    return inStr;
            }

    Чмоке всем в этам чяте!!!111

    nikelin, 08 Декабря 2011

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

    +161

    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
    public function selectItems( $id, $withStrictment = 'no' /* $withStrictment = no, retail, discount */ ) {
    		
    		if( $withStrictment == 'discount' ) $onlyWithRetailPriceSql = " and items.articul in ( select articul from items_discount ) ";
    		if( $withStrictment == 'retail' ) $onlyWithRetailPriceSql = " and items.articul in ( select articul from retailPrice ) ";
    	
    		$a = database::select("	SELECT items.* FROM items WHERE items.id = '$id' and items.deleted = 'no' ");
    		$a = $a[0];
    
    		$this->data = database::select("SELECT items.*, 
    										IF(DATEDIFF(now(),created) <= 30, 'Новинка! ', '') as fresh,
    										( items.quantity - coalesce(view_pendeditemsquantity.sum,0) ) as quantity,
    										items_comments.comment as dopDescr, items_comments.comment as comment, items_discount.priceAsUSD as discountPrice,
    										items_packing.packing,
    										concat(items.name, ' - ', items.quantity) as name
    										FROM items 
    										LEFT JOIN view_pendeditemsquantity ON items.articul = view_pendeditemsquantity.articul
    										LEFT JOIN items_comments ON items.articul = items_comments.articul
    										left join items_discount on items.articul = items_discount.articul
    										left join items_packing on items.articul = items_packing.articul
    										WHERE items.group_id in ( select articul from items where is_group = '1' and name = '{$a['name']}' and group_id = '' )
    										  and items.deleted = 'no' 
    										  $onlyWithRetailPriceSql 
    										order by items.quantity desc, items.name asc
    										");
    	}

    guzik, 30 Ноября 2011

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

    +165

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $menu_string =  "Список устройств=sp_ustr.php~Список пользователей=sp_cl.php~Список параметров=sp_p_param.php~Список компаний=sp_comp.php~Список ролей=sp_rol.php~Список параметров отчетов=sp_repparam.php~Список наименований  датчиков=sp_sensors.php~Список групп=sp_groups.php~Список пользовательских настроек=spn_cl.php~Просмотр активаций=sp_activ.php~Выбрать организацию=vb_org.php~Экспресс-отчеты=sp_report.php".$st;
    
    $menu = explode("~",$menu_string);
    //~Оповещение=soobsh.php~Добавить лицензию=D_lic.php~Выгрузка данных=dat_out.php~Отчеты=otch.php~Експресотчеты=sp_report.php~Параметры датчиков=sp_param.php~Удаленное управление=connect.php~Активация программы=d_activ.php~Параметры отчетов=sp_repparam.php
    for ($i=0; $i < count($menu); $i++) {
    	$menu_1 = explode("=",$menu[$i]);
    	if (2 == count($menu_1)) {
    		echo "<a href=",$menu_1[1],">",$menu_1[0],"</a><br>";
    	} else {
    		echo "<a href=index-",$i+1,".php>",$menu_1[0],"</a><br>";
    	};
    };

    нужно сделать на сайте простое статическое меню.
    вот как, элегантно было решено сделать =)))

    burlak, 29 Ноября 2011

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

    +175

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <?php if ($_GET['id'] == 12 or $_GET['Itemid'] == 37 or $_GET['id'] == 13 or $_GET['id'] == 32 or $_GET['pid']) { ?>
    				<td width="65px">&nbsp;</td>
    
    
    				<? } ?>
    				<td class="otstup_content">

    контекстно независимые шаблонные конструкции.
    здравствуй joomal! здравствуй студия с большим именем!

    da4ever, 24 Ноября 2011

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

    +112

    1. 1
    result = result += (od.UnitPrice * od.Quantity);

    Источник:
    http://msdn.microsoft.com/ru-ru/library/ff852066.aspx#Y0

    ramzes_2, 19 Ноября 2011

    Комментарии (10)
  9. C++ / Говнокод #8532

    +161

    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
    #if DEBUG == 2
    	#define INFO(message) (util::debug::print(TYPE_INFO, (message), __func__, __LINE__))
    	#define WARNING(message) (util::debug::print(TYPE_WARNING, (message), __func__, __LINE__))
    	#define ERROR(message) (util::debug::print(TYPE_ERROR, (message), __func__, __LINE__))
    #elif DEBUG == 1
    	#define INFO(message) (util::debug::print(TYPE_INFO, (message), __func__))
    	#define WARNING(message) (util::debug::print(TYPE_WARNING, (message), __func__))
    	#define ERROR(message) (util::debug::print(TYPE_ERROR, (message), __func__))
    #elif DEBUG == 0
    	#define INFO(message) (util::debug::print(TYPE_INFO, (message)))
    	#define WARNING(message) (util::debug::print(TYPE_WARNING, (message)))
    	#define ERROR(message) (util::debug::print(TYPE_ERROR, (message)))
    #else
    	/* Default defines, uses if logging is disable */
    	#define INFO()
    	#define WARNING()
    	#define ERROR()
    #endif

    rootick, 16 Ноября 2011

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

    +158

    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
    ......
       )
    VALUES
      (
    '".$_POST['cat']."',
    '".$_POST['age']."',
    '".$_POST['time']."',
    '".$_POST['days']."',
    '".$_POST['price1']."',
    '".$_POST['price2']."',
    '".$_POST['price3']."',
    '".$_POST['price4']."',
    .....

    и еще много много кода

    Sulik78, 14 Ноября 2011

    Комментарии (10)
  11. Java / Говнокод #8489

    +74

    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
    public class User extends HttpApiDealer{
        private int id = 347;
        private Date lustUpdate;
        private long refreshTime = 10;
        private boolean onlineStatus;
        
        
        public boolean isOnline() {
            Date timeForRefresh = new Date();
            timeForRefresh.setTime(new Date().getTime() - refreshTime);
            if(lustUpdate == null) {
                lustUpdate = new Date();
            }else if(lustUpdate.after(timeForRefresh)) {
                
            }
            
            return true; //заглушка
        }
        
    }

    Хм, смущает меня работа с датами в этом коде.

    manyrus, 11 Ноября 2011

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