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

    В номинации:
    За время:
  2. Куча / Говнокод #20433

    +3

    1. 1
    Я упал

    Xyj, 26 Июля 2016

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

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <?if( $arResult['PROPERTIES']['NOT_ALLOWED']['VALUE'] == 'да' || $arItem["PROPERTIES"]["NOT_ALLOWED"]["VALUE_XML_ID"] == "Y" ) { ?>
    				<div class="alert-empty alert--licence">
    					<?$APPLICATION->IncludeComponent(
    						"bitrix:main.include",
    						"",
    						Array(
    							"AREA_FILE_SHOW" => "file",
    							"PATH" => SITE_DIR."/inc/card_not_allowed.php",
    							"EDIT_TEMPLATE" => ""
    						)
    					);?>

    Платформа Битрикс, очередное творение Lenal в шаблоне компонента.

    Сравнение значения с КИРИЛИЦЕЙ в template.php.

    lscin, 22 Июля 2016

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

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public function favoriteCount($userId) {
    		$query = $this->db->query("SELECT * FROM ".DB_PREFIX."favorite WHERE customer_id =".$this->db->escape($userId));
    		$rows = $query->rows;
    		return count($rows);
    }

    Opencart.
    Потому что агрегатные функции для слабаков!

    Panda, 13 Июля 2016

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

    +2

    1. 1
    2. 2
    //-----Если жмут submit(кнопку)-----//
    if(isset($_REQUEST['reg']))

    Really ? :D

    eskrano, 05 Июля 2016

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

    +1

    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
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    header.php
    
     <?$APPLICATION->IncludeComponent(
                    "lenal:lenal.menu",
                    "mobile",
                    array(
                        "VIEW_MODE" => "LINE",
                        "SHOW_PARENT_NAME" => "Y",
                        "IBLOCK_TYPE" => "catalog",
                        "IBLOCK_ID" => "39",
                        "SECTION_ID" => $_REQUEST["SECTION_ID"],
                        "SECTION_CODE" => "",
                        "SECTION_URL" => "",
                        "COUNT_ELEMENTS" => "N",
                        "TOP_DEPTH" => "1",
                        "SECTION_FIELDS" => array(
                            0 => "",
                            1 => "",
                        ),
                        "SECTION_USER_FIELDS" => array(
                            0 => "UF_MOST_POPULAR",
                            1 => "",
                        ),
                        "ADD_SECTIONS_CHAIN" => "Y",
                        "CACHE_TYPE" => "A",
                        "CACHE_TIME" => "36000000",
                        "CACHE_GROUPS" => "Y",
                        "COMPONENT_TEMPLATE" => "ds_main_menu",
                        "MAX_COUNT" => "12",
                        "MAX_ACTIONS" => "4",
                        "MAX_POPULAR" => "5"
                    ),
                    false
                );?>
    
    /**************************************************************/
    
    component.php
    
    if(!isset($arParams["CACHE_TIME"]))
    	$arParams["CACHE_TIME"] = 36000000;
    
    if($this->StartResultCache(false, ($arParams["CACHE_GROUPS"]==="N"? false: $USER->GetGroups())))
    {
    
    	if(!\Bitrix\Main\Loader::includeModule("iblock"))
    	{
    		$this->AbortResultCache();
    		ShowError(GetMessage("IBLOCK_MODULE_NOT_INSTALLED"));
    		return;
    	}
    
    /**************************************************************/

    В параметрах стоит "SECTION_ID" => $_REQUEST["SECTION_ID"] и единственным условием сброса кеша ("CACHE_TIME" => "36000000") является отсутствие одного из основных модулей.

    Результат: по 99 460 файлов кеша на каждый сайт. И это - простое МЕНЮ.

    Производство компания Lenal, платформа 1С-Битрикс

    lscin, 04 Июля 2016

    Комментарии (1)
  7. Java / Говнокод #20307

    +6

    1. 1
    2. 2
    3. 3
    4. 4
    StringBuilder text = new StringBuilder();
    for (char letter : section.getName().toCharArray()){
        text.append(Character.toUpperCase(letter));
    }

    Вот так мы приводим текст к верхнему регистру

    ingenuus, 01 Июля 2016

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

    +2

    1. 1
    $this->a[$this->c[$this->m]] = my_substr($this->t, $prev[2], ($v[0] - $prev[2]));

    Кусочек кустарного говношаблонизатора.
    Без комментариев. В обоих смыслах.

    daniser, 30 Июня 2016

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

    +6

    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
    switch ($m->type) {
    			case 'photo':
    				echo sprintf('<div class="fb_photo %s"><a %s href="%s"><div style="background-image: url(\'%s\');"><b>%s</b><br>%s%s<div class="status">%s <img src="%s" /> %s <img src="%s" /></div></div></div>', ($showProfilePic ? 'padding65' : ''), (isset($_GET['nonavbar']) ? 'target="_top"' : 'target="_blank"'), $m->link . (isset($_GET['nonavbar']) ? '&openwithnavigation=1' : ''), str_replace("_s", "_n", $m->picture), $m->from->name, (!empty($m->message) ? $m->message.'<br>' : ''), ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes)  && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
    				break;
    			case 'video':
    			case 'link':
    				echo sprintf('<div class="fb_link %s"><a %s href="%s"><div style="width: 100%%; padding: 30px;  box-sizing: border-box;border-bottom:1px solid #ccc;border-top:1px solid #ccc;"><img style="max-width: none; width:100px;" src="%s" /><div style="width: 100%%"><b>%s</b><br>%s</div></div><div style="position:absolute; right: 10px; bottom: 10px;" class="status">%s <img style="display: inline-block" src="%s" /> %s <img style="display: inline-block" src="%s" /></div></a></div>', ($showProfilePic ? 'padding65' : ''), (isset($_GET['nonavbar']) ? 'target="_top"' : 'target="_blank"'), $m->link . (isset($_GET['nonavbar']) ? '&openwithnavigation=1' : ''), $m->picture, $m->name, $m->message, ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes) && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
    				//echo sprintf('<div class="fb_link"><a href="%s"><div><img src="%s" /><b>%s</b><br>%s<div class="status">%s likes, %s comments</div></div></div></div>', $m->link, str_replace("_s", "_n", $m->picture), $m->from->name, $m->message, $m->likes->count, $m->comments->count);
    				break;
    			case 'status':
    				echo sprintf('<div class="fb_link %s"><a %s href="%s"><div style="width: 100%%; padding: 30px;  box-sizing: border-box;border-bottom:1px solid #ccc;border-top:1px solid #ccc;"><img style="max-width: none; width:100px;" src="%s" /><div style="width: 100%%"><b>%s</b><br>%s</div></div><div style="position:absolute; right: 10px; bottom: 10px;" class="status">%s <img style="display: inline-block" src="%s" /> %s <img style="display: inline-block" src="%s" /></div></a></div>', ($showProfilePic ? 'padding65' : ''), '', '', $m->picture, $m->name, $m->message, ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes)  && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
    				break;
    			default:
    				//echo 'TODO: ' . $m->type;
    				//var_dump($m);
    				break;
    		}

    Верстка.
    Уровень - бог.

    valentinlazy, 27 Июня 2016

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

    −1

    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
    AnsiString message=IntToStr((int)GetTickCount());
    		if(message.Length()>=3)
    			message=message.SubString(message.Length()-3, 3);
    		else if(message.Length()==2)
    			message="0"+message;
    		else if(message.Length()==1)
    			message="00"+message;
    		message=dt.FormatString("yy")+dt.FormatString("mm")+dt.FormatString("dd")+" "+
    			dt.FormatString("hh")+dt.FormatString("nn")+dt.FormatString("ss")+" "+message;
    		message=message+" "+aMessage;
    		if(FMemoMes){
    			FMemoMes->Lines->Add(message);
    		}

    Выводит сообщение aMessage, вставляя в начало сообщения текущие дату и время с миллисекундами.

    appach, 27 Июня 2016

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

    0

    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
    function setLastHandshake ($carID) {
    	$HsList = json_decode(file_get_contents('carconnection.txt'), 1);
    	if ($HsList == "null" || $HsList == null) {
    		$HsList = json_decode("[]");
    	}
    	$carCount = count($HsList);
    	$i = 0;
    	foreach ($HsList as &$row) {
    		if ($row['car'] == $carID) {
    			$row['lastHS'] = (string)time();
    			break;
    		}
    		else {
    		$i++;
    		}
    		if ($i == $carCount) {
    			$HsList[] = array('car' => (string)$carID, 'lastHS' => (string)time());
    		}
    	}
    	if ($HsList == "null" || $HsList == null) {
    		return -1;
    	}
    	$f = fopen('carconnection.txt', 'w');
    	fwrite($f, json_encode($HsList));
    }

    tooyz, 20 Июня 2016

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