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

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

    +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
    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
    function replaceBBCodes($text){ 
    $text=str_replace("/\n/m", "$0<br/>", $text);
    $text = htmlspecialchars($text);
    $text=nl2br($text);
    $text=stripslashes($text);   
    $text=str_replace("!#3040#!", "&", $text);
    $text=str_replace('[b]', '<strong>', $text);
    $text=str_replace('[/b]', '</strong>', $text);
    $text=str_replace('[i]', '<em>', $text);
    $text=str_replace('[/i]', '</em>', $text);
    $text=str_replace('[u]', '<u>', $text);
    $text=str_replace('[/u]', '</u>', $text);
    $text=str_replace('[s]', '<s>', $text);
    $text=str_replace('[/s]', '</s>', $text);
    $text=str_replace('[left]', '<span class="bb_left">', $text);
    $text=str_replace('[/left]', '</span>', $text);
    $text=str_replace('[right]', '<span class="bb_right">', $text);
    $text=str_replace('[/right]', '</span>', $text);
    $text=str_replace('[center]', '<span class="bb_center">', $text);
    $text=str_replace('[/center]', '</span>', $text);
    $text=str_replace('[justify]', '<span class="bb_justify">', $text);
    $text=str_replace('[/justify]', '</span>', $text);
    $text=preg_replace("#\[color=(.*?)](.*?)\[/color\]#si", '<span style="color:$1">$2</span>',$text);
    $text=preg_replace("#\[size=(.*?)](.*?)\[/size\]#si", '<span style="font-size:$1px">$2</span>',$text);
    $text=preg_replace("#\[a=(.*?)](.*?)\[/a\]#si", '<a href="$1">$2</a>',$text);
    $text=preg_replace("#\[img=(.*?)](.*?)\[/img\]#si", '<img src="$2" alt="images" style="float:$1;margin:5px;" />',$text);
    $text=preg_replace("#\[youtube](.*?)\[/youtube\]#si",'<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>',$text);
    $text=preg_replace("#\[youtube](.*?)\[/youtube\]#si",'<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>',$text);
    $text=preg_replace("#\[spoiler=(.*?)](.*?)\[/spoiler\]#si", '<div id=\'video\'><h1 class="headtt2" onclick="expandit(this)">$1</h1>
    <div style="display:none;" class="sdsp">         $2</div> </div>', $text);
    $text=preg_replace("#\[podspoiler=(.*?)](.*?)\[/podspoiler\]#si", '<h1 class="headtt" onclick="expandit(this)">$1</h1>
    <div style="display:none;text-align:center">$2</div>', $text);
    return $text; 
    }

    qbasic, 10 Декабря 2010

    Комментарии (24)
  3. Pascal / Говнокод #4887

    +102

    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 FileIsBusy(AFileName: string): Boolean;
    var
      F: Integer;
    begin
      F := FileOpen(AFileName, fmShareExclusive);
      Result := F = -1;
      FileClose(F);
    end;
    
    function WaitFile(AFileName: string; ASpeepDelay: integer): Boolean;
    begin
      while FileIsBusy(AFileName) do
        Sleep(ASpeepDelay);
      Result := True;
    end;

    пока юзверь ковыряется в Ворде, другой процесс мечтает овладеть файлом
    "It is necessary to wait of end of editing Microsoft Office files.I use next conventional approach: file is editing While file is busy" (ингриш - питерского разлива)

    это stackoverflow такими сниппетами переполнено

    bugmenot, 10 Декабря 2010

    Комментарии (24)
  4. Куча / Говнокод #4737

    +143

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    RewriteRule info/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/(.*) /content.php?d1=$1&d2=$2&d3=$3&d4=$4&d5=$5&d6=$6&d7=$7&d8=$8&d9=$9&d10=$10&d11=$11 [L]
    RewriteRule info/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/(.*) /content.php?d1=$1&d2=$2&d3=$3&d4=$4&d5=$5&d6=$6&d7=$7&d8=$8&d9=$9&d10=$10 [L]
    RewriteRule info/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/(.*) /content.php?d1=$1&d2=$2&d3=$3&d4=$4&d5=$5&d6=$6&d7=$7&d8=$8&d9=$9 [L]
    RewriteRule info/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/(.*) /content.php?d1=$1&d2=$2&d3=$3&d4=$4&d5=$5&d6=$6&d7=$7&d8=$8 [L]
    RewriteRule info/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/(.*) /content.php?d1=$1&d2=$2&d3=$3&d4=$4&d5=$5&d6=$6&d7=$7 [L]
    RewriteRule info/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/(.*) /content.php?d1=$1&d2=$2&d3=$3&d4=$4&d5=$5&d6=$6 [L]
    RewriteRule info/([^/]+)/([^/]+)/([^/]+)/([^/]+)/(.*) /content.php?d1=$1&d2=$2&d3=$3&d4=$4&d5=$5 [L]
    RewriteRule info/([^/]+)/([^/]+)/([^/]+)/(.*) /content.php?d1=$1&d2=$2&d3=$3&d4=$4 [L]
    RewriteRule info/([^/]+)/([^/]+)/(.*) /content.php?d1=$1&d2=$2&d3=$3 [L]
    RewriteRule info/([^/]+)/(.*) /content.php?d1=$1&d2=$2 [L]
    RewriteRule info/(.*) /content.php?d1=$1 [L]

    facepalm.php

    wiz, 24 Ноября 2010

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

    +169

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php
    
            if($key === false){
                return false;
            }else{
                return $key;
            }

    user654321, 03 Ноября 2010

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

    +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
    function SortArray(&$array,$coll,$desc=false)
    {
    	global $temp;
    	if(!function_exists('SorterUp')){
    		function SorterUp($x,$y)
    		{
    			global $temp;
    			if ($x[$temp] == $y[$temp]) return 0;
    			return ($x[$temp] < $y[$temp]) ? -1 : 1;
    		}
    		function SorterDown($x,$y)
    		{
    			global $temp;
    			if ($x[$temp] == $y[$temp]) return 0;
    			return ($x[$temp] > $y[$temp]) ? -1 : 1;
    		}
    	}
    	$temp = $coll;
    	if(!$desc){
    		usort($array,'SorterUp');
    	}else{
    		usort($array,'SorterDown');
    	}
    	unset($temp);
    }

    Продолжаю цикл "Из одной русской CMS". Этот код - PHP замена ORDER BY в мускуле.

    Мартин, 17 Октября 2010

    Комментарии (24)
  7. C++ / Говнокод #4260

    +144

    1. 1
    2. 2
    int a;
    if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){if(a=0){}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

    fatal error C1061: ограничение компилятора: недопустимая степень вложения блоков
    MSVS 2010; C++ win32 console

    Ivan0x32, 16 Сентября 2010

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

    +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
    13. 13
    <? foreach (  $menus as $menu  ){ ?>
         <li class="menu-item menu-item-type-post_type"><a href="<?=($menu->link) ?>"><?=desafelySqlStr($menu->name) ?></a>
         <?    $submenus = ggsql (  " select * from #__menu where parent=".$menu->id  ); 
         
         if (  count($submenus)>0  ){
          ?><ul class="sub-menu"><?
          foreach (  $submenus as $submenu){
           ?><li><a href="<?=($submenu->link) ?>"><?=desafelySqlStr($submenu->name) ?></a></li><?
          }
          ?><span></span></ul><?
         }
         ?></li>
        <? } ?>

    Друг устроился на работу верстальщиком, попросил помочь разобраться с этим кодом

    [12:56:24] nolka: чо за desafelySqlStr?
    [12:56:27] nolka: кто это писал?
    [12:56:37] anonymous: тут главный какой-то
    [12:56:41] anonymous: он все время это пишет
    [12:56:43] anonymous: а чего?
    [12:56:56] nolka: дать пезды ему за это и отправить на урановые рудники блять
    [12:57:08] anonymous: :) Почему?
    [12:57:28] nolka: ты сам щас ответишь себе на этот вопрос
    [12:57:33] nolka: тебе нравится такой код?
    [12:57:39] nolka: стиль кодинга такой
    [12:58:29] anonymous: еба еба тут а не код
    [12:58:37] anonymous: я уже с ума схожу за 3 дня

    nolka4, 15 Сентября 2010

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

    +192

    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
    С праздником, коллеги!
    
    Пожалуй, нет профессии престижней
    Сейчас, чем толковый программист,
    А ведь когда-то в моде был учитель,
    Потом – банкир, экономист.
    Программы для компьютера писать -
    В этом ты действительно мастер!
    С Днем программиста поздравляем,
    Желаем радости, здоровья, счастья.
    
    С уважением, 
    1_and_0

    1_and_0, 13 Сентября 2010

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if ( p->m_p ) 
    {
          m_p = p->m_p;
    }
    else 
    {
          m_p = NULL;
    }

    Мля, ну а вдруг

    J0hnny, 02 Сентября 2010

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

    +172

    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
    <?
    @session_start();
    
    $fini=rand(0,9);
    
    if($fini==1){
    
    $_SESSION['idi']='ZM55PKL216';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka1.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==2){
    
    $_SESSION['idi']='2K1P6LZ55M';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka2.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==3){
    
    $_SESSION['idi']='LK561MP5Z2';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka3.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==4){
    
    $_SESSION['idi']='65ZP1MLK25';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka4.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==5){
    
    $_SESSION['idi']='552P6LM1ZK';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka5.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==6){
    
    $_SESSION['idi']='ZP2M615LK5';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka6.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==7){
    
    $_SESSION['idi']='KM5P2Z615L';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka7.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==8){
    
    $_SESSION['idi']='2KP5Z16L5M';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka8.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==9){
    
    $_SESSION['idi']='PKM15Z25L6';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka9.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    if($fini==0){
    
    $_SESSION['idi']='6ZP5L25M1K';
    
    echo"<div style='position:absolute; background-image:url(images/proverochnoe%20chislo/proverka10.png); width:112px; height:30; left: 390px; top: 260px;'></div>";}
    
    ?>
    
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
    
    <div style="position:absolute; top:-10px; left:25px; width: 340px; height: 49px; z-index:8;"><font size="+2" color="#333399" style="position:absolute; top:236px; left:-5px; width: 284px;">Контрольное значение для ячейки значение:</font>
    
    </div>

    Содержимое файла "kontrolnoe znachenie.php".
    Великий и ужасный "генератор капчи". Особая прелесть в том, что файл начинается с пустой строки, а потом уже идет <?@session_start(). Кто сталкивался с проблемой "Headers are already sent" поймет, поймет также почему автор наивно пытается исправить эту проблему с помощью @.
    Продолжение серии: #4101, #4100.

    SunnyMagadan, 26 Августа 2010

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