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

    В номинации:
    За время:
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. 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)
  7. 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)
  8. 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)
  9. PHP / Говнокод #8452

    +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
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    function implode_get($ar) {
        $first = true;
        $output = '';
        foreach($ar as $key => $value) {
            if ($first) {
                $output = '?'.$key.'='.$value;
                $first = false;
            } else {
                $output .= '&'.$key.'='.$value;
            }
        }
        return $output;
    }
    function explode_get() {
        $ar = array();
        foreach ($_GET as $key => $value) {
            $ar[$key] = $value;
        }
        return $ar;
    }

    после первой функции дурная голова сказала что нужна обратная функция.

    LmSys, 08 Ноября 2011

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

    +133

    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
    static string ContentTypeDecode(string contentTypeName)
            {
                if (contentTypeName.Equals("Поручение")) return "Задание";
                if (contentTypeName.Equals("Поручение с результатом типа текст")) return "Задание с результатом типа текст";
                if (contentTypeName.Contains("Поручение с результатом типа выбор")) return "Задание с результатом типа выбор";
                if (contentTypeName.Equals("Поручение с результатом типа документ")) return "Задание с результатом типа документ";
                if (contentTypeName.Equals("Поручение с результатом типа форма")) return  "Задание с результатом типа форма";
                if (contentTypeName.Equals("Поручение с результатом типа флаг")) return "Задание с результатом типа флаг";
                if (contentTypeName.Equals("Поручение с результатом типа число")) return "Задание с результатом типа число";
                if (contentTypeName.Equals("Поручение с результатом типа дата")) return "Задание с результатом типа дата";
                if (contentTypeName.Equals("Поручение с результатом типа пользователь")) return "Задание с результатом типа пользователь";
                if (contentTypeName.Equals("Поручение с результатом типа список пользователей")) return "Задание с результатом типа список пользователей";
                if (contentTypeName.Equals("Поручение на сканирование")) return "Задание на сканирование";
                if (contentTypeName.Equals("Задача на контроль поручения")) return "Задание на контроль";
                if (contentTypeName.StartsWith("Утверждение документа v3")) return "Утверждение документа";
                if (contentTypeName.StartsWith("Согласование документа v3")) return "Согласование документа";
                if (contentTypeName.StartsWith("Утверждение документа v4")) return "Утверждение документа";
                if (contentTypeName.StartsWith("Согласование документа v4")) return "Согласование документа";
                return null;
            }///string ContentTypeDecode(string ContentTypeName)

    Из реального комерческого проекта

    VasyaPupkin, 02 Ноября 2011

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

    −123

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    СпрСклады = СоздатьОбъект("Справочник.Склады");
    НСкл = 0;
    СпрСклады.ВыбратьЭлементы();
    Пока СпрСклады.ПолучитьЭлемент() = 1 Цикл
    	Склад = СпрСклады.ТекущийЭлемент();
    	НСкл = НСкл + 1;
    	Если НСкл = 1 Тогда
    		Прервать
    	КонецЕсли;
    КонецЦикла;

    Вот такую "красоту" оставили предыдущие программисты.

    droff, 31 Октября 2011

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