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

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

    −3

    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
    [Wed Jun 01 10:13:25.866953 2016] [autoindex:error] [pid 30710] [client 77.222.112.203:24108] AH01276: Cannot serve directory /home/u325415/test.alpina-nerud.ru/www/: No matching DirectoryIndex (index.html,index.htm,index.php,index.php3,index.phtml,index.cgi,index.pl,index.shtml,default.htm,default.html) found, and server-generated directory index forbidden by Options directive
    [Wed Jun 01 10:21:28.044222 2016] [autoindex:error] [pid 4437] [client 77.222.112.203:30432] AH01276: Cannot serve directory /home/u325415/test.alpina-nerud.ru/www/: No matching DirectoryIndex (index.html,index.htm,index.php,index.php3,index.phtml,index.cgi,index.pl,index.shtml,default.htm,default.html) found, and server-generated directory index forbidden by Options directive
    [Wed Jun 01 10:28:39.825066 2016] [autoindex:error] [pid 10534] [client 77.222.112.203:36957] AH01276: Cannot serve directory /home/u325415/test.alpina-nerud.ru/www/: No matching DirectoryIndex (index.html,index.htm,index.php,index.php3,index.phtml,index.cgi,index.pl,index.shtml,default.htm,default.html) found, and server-generated directory index forbidden by Options directive
    [Wed Jun 01 12:11:48.394301 2016] [:error] [pid 6058] [client 77.222.112.203:37192] PHP Warning:  require(typo3/sysext/core/Classes/Core/Bootstrap.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in /home/u325415/test.alpina-nerud.ru/www/index.php on line 48
    [Wed Jun 01 12:11:48.394400 2016] [:error] [pid 6058] [client 77.222.112.203:37192] PHP Warning:  require(typo3/sysext/core/Classes/Core/Bootstrap.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in /home/u325415/test.alpina-nerud.ru/www/index.php on line 48
    [Wed Jun 01 12:11:48.394426 2016] [:error] [pid 6058] [client 77.222.112.203:37192] PHP Fatal error:  require() [<a href='function.require'>function.require</a>]: Failed opening required 'typo3/sysext/core/Classes/Core/Bootstrap.php' (include_path='.:/usr/share/php53:/usr/share/pear53') in /home/u325415/test.alpina-nerud.ru/www/index.php on line 48
    [Wed Jun 01 12:18:39.840563 2016] [:error] [pid 12269] [client 77.222.112.203:15356] PHP Parse error:  syntax error, unexpected T_CLASS in /home/u325415/test.alpina-nerud.ru/www/typo3conf/ext/chgallery/lib/class.tx_chgallery_tca.php on line 1, referer: http://test.alpina-nerud.ru/typo3/
    [Wed Jun 01 12:18:42.839703 2016] [:error] [pid 12319] [client 77.222.112.203:15413] PHP Parse error:  syntax error, unexpected T_CLASS in /home/u325415/test.alpina-nerud.ru/www/typo3conf/ext/chgallery/lib/class.tx_chgallery_tca.php on line 1
    [Wed Jun 01 12:18:45.376653 2016] [:error] [pid 12333] [client 77.222.112.203:15456] PHP Parse error:  syntax error, unexpected T_CLASS in /home/u325415/test.alpina-nerud.ru/www/typo3conf/ext/chgallery/lib/class.tx_chgallery_tca.php on line 1
    [Wed Jun 01 12:19:02.624195 2016] [:error] [pid 12557] [client 77.222.112.203:15794] PHP Parse error:  syntax error, unexpected T_CLASS in /home/u325415/test.alpina-nerud.ru/www/typo3conf/ext/chgallery/lib/class.tx_chgallery_tca.php on line 1
    [Wed Jun 01 12:19:04.446064 2016] [:error] [pid 12573] [client 77.222.112.203:15826] PHP Parse error:  syntax error, unexpected T_CLASS in /home/u325415/test.alpina-nerud.ru/www/typo3conf/ext/chgallery/lib/class.tx_chgallery_tca.php on line 1
    [Wed Jun 01 12:20:25.263810 2016] [:error] [pid 13455] [client 77.222.112.203:17281] PHP Parse error:  syntax error, unexpected T_CLASS in /home/u325415/test.alpina-nerud.ru/www/typo3conf/ext/chgallery/lib/class.tx_chgallery_tca.php on line 1
    [Wed Jun 01 12:21:43.511456 2016] [:error] [pid 14762] [client 77.222.112.203:18648] PHP Parse error:  syntax error, unexpected T_CLASS in /home/u325415/test.alpina-nerud.ru/www/typo3conf/ext/chgallery/lib/class.tx_chgallery_tca.php on line 1
    [Wed Jun 01 12:21:54.006698 2016] [:error] [pid 14760] [client 77.222.112.203:18644] PHP Parse error:  syntax error, unexpected T_CLASS in /home/u325415/test.alpina-nerud.ru/www/typo3conf/ext/chgallery/lib/class.tx_chgallery_tca.php on line 1
    [Wed Jun 01 12:21:56.294966 2016] [:error] [pid 14894] [client 77.222.112.203:18855] PHP Parse error:  syntax error, unexpected T_CLASS in /home/u325415/test.alpina-nerud.ru/www/typo3conf/ext/chgallery/lib/class.tx_chgallery_tca.php on line 1
    [Wed Jun 01 12:22:11.178438 2016] [:error] [pid 15124] [client 77.222.112.203:19238] PHP Parse error:  syntax error, unexpected T_CLASS in /home/u325415/test.alpina-nerud.ru/www/typo3conf/ext/chgallery/lib/class.tx_chgallery_tca.php on line 1
    [Wed Jun 01 12:23:17.882880 2016] [:error] [pid 15798] [client 77.222.112.203:20386] PHP Warning:  require(sysext/core/Classes/Core/Bootstrap.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in /home/u325415/test.alpina-nerud.ru/www/typo3/init.php on line 55
    [Wed Jun 01 12:23:17.882976 2016] [:error] [pid 15798] [client 77.222.112.203:20386] PHP Warning:  require(sysext/core/Classes/Core/Bootstrap.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in /home/u325415/test.alpina-nerud.ru/www/typo3/init.php on line 55
    [Wed Jun 01 12:23:17.883003 2016] [:error] [pid 15798] [client 77.222.112.203:20386] PHP Fatal error:  require() [<a href='function.require'>function.require</a>]: Failed opening required 'sysext/core/Classes/Core/Bootstrap.php' (include_path='.:/usr/share/php53:/usr/share/pear53') in /home/u325415/test.alpina-nerud.ru/www/typo3/init.php on line 55

    Ошибка в логах

    ponoroshca, 01 Июня 2016

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    <?
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC&destinations=Seattle&mode=driving&language=de");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    $response = curl_exec($ch);
    echo $response;
    $array = json_decode($response, true);
    echo $array["destination_addresses"];
    ?>

    viromax, 01 Июня 2016

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

    +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
    public function timeDiff( $time, $now = null ) {
    		if ( ! is_int( $time ) )
    			$time = strtotime( (string) $time ) + ( get_option( 'gmt_offset' ) * 3600 - 10800 );
    		if ( is_null( $now ) )
    			$now = time();
    		if ( $now == $time )
    			return __( 'right now', Challonge_Plugin::TEXT_DOMAIN );
    		if ( $now < $time )
    			/* translators:
    				%s is an approximate relative amount of time (eg. "2 days")
    			*/
    			return sprintf( __( 'in %s', Challonge_Plugin::TEXT_DOMAIN ), human_time_diff( $time, $now ) );
    		/* translators:
    			%s is an approximate relative amount of time (eg. "2 days")
    		*/
    		return sprintf( __( '%s ago', Challonge_Plugin::TEXT_DOMAIN ), human_time_diff( $time, $now ) );
    	}

    -10800
    починил блять!

    pstnkv, 30 Мая 2016

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

    −100

    1. 1
    ТекТаблицаСвойств = СсылкаНаОбьект.Свойства.Выгрузить().Скопировать(СсылкаНаОбьект.Свойства.НайтиСтроки(ТекОтбор));

    Выгружаем строки из табличной части, используя отбор.

    CMblCL, 18 Мая 2016

    Комментарии (8)
  6. JavaScript / Говнокод #19946

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    this.params.IsCellEditable = function(rowNumber, cellNumber) {
    	cellNumber == 1;
    	this.params.ButtonList = this.params.ButtonList.filter(b=>b[0] === "OnRefresh");
    
    	let textContr = new CTextArea('textContr');
    	textContr.SourceName = "value";
    	textContr.ViewName = "Params";
    	textContr.ComEdit = true;
    	this.params.arrEditObj[1] = textContr;
    
    }

    Найдено в нашем проекте в старом модуле, в авторстве никто не признаётся.
    Во-первых, строка 2 бессмысленна. Во-вторых, всё последующее имело бы хоть какой-то смысл _вне_ этой функции, а внутри уже на строке 3 выкидывает ошибку, потому что контекст там и есть this.param из первой строчки. В-третьих, строка 3 призвана выкидывать из тулбара виджета this.param все кнопки, кроме OnRefresh, но на самом деле она там только одна и есть. В-четвёртых, строчки 7 и 8 просто лишние (ну, это из логики используемого в проекте движка следует). В-пятых, из названия метода можно предположить (и это действительно так), что он должен бы возвращать булевское значение, но он всегда возвращает только undefined и, таким образом, все ячейки виджета оказываются нередактируемыми — что совсем лишает смысла создание контрола для редактирования в строках 5—9.
    Редкостная бредятина. Кто-то в полном затмении писал, и даже десяти секунд не потратил на тестирование.

    torbasow, 06 Мая 2016

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

    +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
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    <?
    	/*
    		Bitrix Cleaner v2.2 - https://github.com/creadome/bitrixcleaner
    		Быстрая очистка 1С-Битрикс
    		(c) 2015 Станислав Васильев - http://creado.me
    		[email protected]
    	*/
    	require $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_before.php';
    	$trash = array(
    		'cache' => array(
    			'/bitrix/cache/' => 'Неуправляемый кеш',
    			'/bitrix/managed_cache/' => 'Управляемый кеш',
    			'/bitrix/html_pages/' => 'HTML кеш'
    		),
    		'files' => array(
    			'/upload/resize_cache/' => 'Кеш изображений'
    		)
    	);
    	if ($_GET['clean']) {
    		BXClearCache(true);
    		$GLOBALS['CACHE_MANAGER']->CleanAll();
    		$GLOBALS['stackCacheManager']->CleanAll();
    		$staticHtmlCache = \Bitrix\Main\Data\StaticHtmlCache::getInstance();
    		$staticHtmlCache->deleteAll();
    		foreach ($trash['files'] as $files => $name) DeleteDirFilesEx($files);
    	}
    	function countsize($directory) {
    		$count = array('file' => 0, 'size' => 0);
    		foreach (scandir($directory) as $file) {
    			if ($file != '.' && $file != '..') {
    				if (is_dir($directory.$file)) {
    					$inner = countsize($directory.$file.'/');
    					$count['file'] += $inner['file'];
    					$count['size'] += $inner['size'];
    				} else {
    					$count['file'] ++;
    					$count['size'] += filesize($directory.$file);
    				}
    			}
    		}
    		return $count;
    	}
    ?>
    
    <table>
    	<tr>
    		<th>Описание</th>
    		<th>Путь</th>
    		<th>Файлы</th>
    		<th>Размер</th>
    	</tr>
    
    	<?
    		foreach ($trash as $type) {
    			foreach ($type as $directory => $name) {
    				$count = countsize($_SERVER['DOCUMENT_ROOT'].$directory);
    	?>
    
    				<tr>
    					<td><?=$name?></td>
    					<td><a href="/bitrix/admin/fileman_admin.php?lang=ru&amp;path=<?=$directory?>"><?=$directory?></a></td>
    					<td><?=$count['file']?></td>
    					<td><?=round($count['size'] / 1048576, 2)?> Мб</td>
    				</tr>
    
    	<?
    			}
    		}
    	?>
    </table>
    
    <input type="button" value="Очистить" class="adm-btn-save" data-action="clean">

    Битрикс. порадовала строчка "'/bitrix/cache/' => 'Неуправляемый кеш'". Оказывается даже адептам битрикса не подвластно управление кешом самого битрикса :D

    https://github.com/creadome/bitrixcleaner/blob/master/cleaner/cleaner.php

    Keeper, 05 Мая 2016

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

    +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
    <ul id="top_menu" alias="{$alias}" parentAlias="{$parentAlias}">
        {foreach $items as $i}
            {*{$i->parentId == null} :)*}
            {if $i->parentId == null}
                <li class="{if $alias === $i->alias || $parentAlias === $i->alias}active{/if}"><a href="{Yii::app()->params->languageUrl}/{$i->alias}" onclick="return false;">{$i->lang->name}</a>
                    <ul class="sub" style="display: none;">
                        {foreach $items as $ii}
                            {if $ii->parentId == $i->id}
                                <li class="{if $alias === $ii->alias || $parentAlias === $ii->alias}active{/if}">
                                    {if $ii->hasAction > 0}
                                        <a href="{if $ii->alias!==''}{Yii::app()->params->languageUrl}/{$ii->alias}{/if}">{$ii->lang->name}</a>
                                    {else}
                                        <a href="{Yii::app()->params->languageUrl}/{$i->alias}{if $ii->alias!==''}/{$ii->alias}{/if}">{$ii->lang->name}</a>
                                    {/if}
                                </li>
                            {/if}
                        {/foreach}
                    </ul>
                </li>
            {/if}
        {/foreach}
    </ul>

    Типичное меню на фреймворках.
    В данном случае Yii

    M-A-X, 26 Апреля 2016

    Комментарии (8)
  9. JavaScript / Говнокод #19825

    −9

    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
    function delMessage(id,posted) {
    				if (confirm("Удалить сообщение от "+posted+" ?")) {
                        if('corporate'=='common')
    					{   
                            window.location="/forum/theme/?id=22213&delmsg="+id;
                        }
                        else if ('corporate'=='olimpic')
                        {
                            window.location="/competitions/kazah/team/?teamId=0&tab=forum&themeId=22213&delmsg="+id;
                        }
                        else if ('corporate'=='city')
                        {
                            window.location="/city/?id=&tab=forum&themeId=22213&delmsg="+id;
                        }
                        else
                        {
                            window.location="/corporation/?id=1401150&tab=forum&themeId=22213&delmsg="+id;
                        }
    				}
    			}
                function addMessage() {
    				document.messageForm.submit();
                }
                function closeMessage() {
    				var textarea=document.getElementById("messagetext");
                    if (textarea) textarea.value="";
                    var div=document.getElementById("submit");
                    if (div) div.style.display="none";
                }
                function showSubmit() {
                	showElement("submit");
                }
                function messageKeyDown(event) {
            	if (!event) event=window.event;
                    if (event.keyCode==13 && event.ctrlKey || event.keyCode==10) {
                    addMessage();
                    }
                }

    d_fomenok, 15 Апреля 2016

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    // 1188 references
    internal static string CombinePaths(string firstPath, string secondPath)
    {
        return Path.Combine(firstPath, secondPath);
    }

    - Шо это было?!!
    - Cэкономили точку. 1188 раз )))))

    RadChand, 08 Апреля 2016

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    class Panel
    {
    // ...
    friend class Panel;
    // ...
    }

    Нашёл такое в хедерах VGUI1 -- игрового тулкита от Valve для Gold Source.
    Объясните, умные люди, зачем?

    a1batross, 01 Апреля 2016

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