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

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

    +158

    1. 1
    return $lines[(rand(0,count($lines)-1)*10)/10]; // ололо, говнокод, но так лучше работает 0_o

    Нашел в своём, относительно недавно, написанном коде. Под чем я это писал?! В упор не помню..
    А что самое страшное - я же знаю про array_rand(). Хотя, тут больше доставляет *10/10.

    mr.The, 25 Декабря 2010

    Комментарии (15)
  3. ActionScript / Говнокод #5049

    −106

    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
    function onClick(e:MouseEvent):void{
    	window.visible=true;
    	clos.visible=true;
    	count=Math.round(Math.random()*5);
    	trace (count);
    	for(i; i<6; i++){
    		trace ("вцикле")
    		if(i==count){
    			window.fish.text=arr1[i];
    			count=0;
    		}
    	}
    }

    Удивительная фантазия - сначала вычисляем рандом, а потом в цикле с ним сравниваем. И если "да, наконец-то это оно", то тогда присваиваем значение.
    (с) flasher.ru

    gloomybrain, 24 Декабря 2010

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

    +150

    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
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Scouting table</title>
    </head>
    <?php
    $t=floor((time()-1286582400)/86400);
    $a=17+floor($t/112);
    $b=(($t/112)-(floor($t/112)))*112;
    $c=17+floor(($t+1)/112);
    $d=((($t+1)/112)-(floor(($t+1)/112)))*112;
    $e=$a+1;
    $f=$e+1;
    {echo
    ("<table align=\"center\" border=\"1\">
      <tr align=\"center\">
        <td>Scouting table</td><td colspan=\"3\"> Scout by age</td>
      </tr>
       <tr align=\"center\">
        <td>Position</td><td>WC17 - 17 years 0 days - $a years $b days</td><td>WC16 - $c years $d days - $e years $b days</td><td>WC15 - $f years $d days - 20 years 111 days</td>
      </tr>
      <tr align=\"center\">
        <td>Goalkeepers</td><td>***** <a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td><td>*****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td><td>*****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td>
      </tr>
      <tr align=\"center\">
        <td>Defenders</td><td>***** <a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td><td>*****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td><td>*****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td>
      </tr>
      <tr align=\"center\">
        <td>Playmakers</td><td>*****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td><td>*****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td><td>*****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td>
      </tr>
      <tr align=\"center\">
        <td>Wingers</td><td>*****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td><td>*****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td><td>***** <a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td>
      </tr>
      <tr align=\"center\">
        <td>Forwards</td><td>*****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td><td>*****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td><td>*****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td>
      </tr>
    </table>
    <table align=\"center\">
      <tr align=\"center\">
        <td>Chief Scout: *****<a href=\"http://www.hattrick.org/Club/?TeamID=*****\">(*****)</a></td>
        </tr>
    </table>");}
    ?>
    
    <body>
    </body>
    </html>

    Вместо звездочек строки html) Замазал)

    vasya1, 16 Декабря 2010

    Комментарии (15)
  5. SQL / Говнокод #4927

    −188

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if @WhatShow=0 /*  Teachers and Students */
    SELECT FieldName, TableName, Action, FieldValue, ComputerName, UserName, DateInput FROM tblLog WHERE RowID=-3456123 OR RowID=-3456124 ORDER BY DateInput DESC
    
    if @WhatShow=1 /*  Teachers ONLY */
    SELECT FieldName, TableName, Action, FieldValue, ComputerName, UserName, DateInput FROM tblLog WHERE RowID=-3456123 ORDER BY DateInput DESC
    
    if @WhatShow=2 /*  Students ONLY */
    SELECT FieldName, TableName, Action, FieldValue, ComputerName, UserName, DateInput FROM tblLog WHERE RowID=-3456124 ORDER BY DateInput DESC

    Код TSQL процедурки используемой приложением сторонних девелоперов. ID строк с информацией по логинам впечатляют. Эти цифры явно несут на себе какую-либо магическую нагрузку и имеют смысл, который далеко не каждому дано понять.

    MAK, 15 Декабря 2010

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

    +159

    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
    <?php 
    session_start();
    define('_JEXEC', 1);
    $host = $_SERVER['DOCUMENT_ROOT'];
    include $host.'/admin/function.php';
    include $host.'/data/conf.php';
    include $host.'/data/settings.php';
    
    $templates = $system['templates'];
    
    $content = file_get_contents($host.'/design/'.$templates.'/index.tpl');
    
    $result = mysql_query(" SELECT * FROM news WHERE section='index' ");
    $myrow = mysql_fetch_array($result);
    
    $result2 = mysql_query(" SELECT * FROM slogan ");
    $myrow2 = mysql_fetch_array($result2);
    
    $index_news = $myrow['news'];
    $title = $myrow['title'];
    $description = $myrow['description'];
    $keywords = $myrow['keywords'];
    
    $menu=''; 
    function callback($s) {$GLOBALS['menu'].=$s; }
    ob_start('callback');
    include $host.'/data/site_content/menu.php'; 
    ob_end_flush();   
    $menu="$menu";
    
    $content=str_replace('{templates}', $templates, $content);
    $content=str_replace('{menu}', $menu, $content);
    $content=str_replace('{content}', $index_news, $content);
    
    $content=str_replace('{slogan_name}', $myrow2['slogan_name'], $content);
    $content=str_replace('{slogan}',$myrow2['slogan'], $content);
    
    $content=str_replace('{title}', $title, $content);
    $content=str_replace('{description}', $description, $content);
    $content=str_replace('{keywords}', $keywords, $content);
    
    echo $content;
    
    ?>

    qbasic, 07 Декабря 2010

    Комментарии (15)
  7. SQL / Говнокод #4789

    −178

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if <fr_Pipeline1."OPERNAME"> = 'Тупаков Н.В.' then Memo50.Text:='Телефон: 350-24-53';
    if <fr_Pipeline1."OPERNAME"> = 'Абрамовна Мария Н.' then Memo50.Text:='Телефон: 531-39-86';
    if <fr_Pipeline1."OPERNAME"> = 'Кошкина Р.Ф.' then Memo50.Text:='Телефон: 170-83-28'; 
    if <fr_Pipeline1."OPERNAME"> = 'Шабанов Д.Л.' then Memo50.Text:='Телефон: 981-04-61';
    if <fr_Pipeline1."OPERNAME"> = 'Ирискина Рита Н.' then Memo50.Text:='Телефон: 330-58-55';
    if <fr_Pipeline1."OPERNAME"> = 'Бъенсе Н.Б.' then Memo50.Text:='Телефон: 761-77-93'; 
    if <fr_Pipeline1."OPERNAME"> = 'Батрудинова О.П.' then Memo50.Text:='Телефон: 580-55-42';
    if <fr_Pipeline1."OPERNAME"> = 'Кудина Д.М.' then Memo50.Text:='Телефон: 440-61-62';

    Повторение мать учения :))

    Vasbin, 30 Ноября 2010

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

    +166

    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
    if (isset($_GET["url"])) {
    	$nombre_archivo = $_GET["url"];
    	
    	$consulta = "SELECT * FROM descargas_archivos WHERE nombre_archivo LIKE '".$nombre_archivo."' ";
    	$resultado = mysql_query($consulta);
    	
    	if (mysql_num_rows($resultado)>0) {
        	$actualiza = "UPDATE descargas_archivos SET num_descargas = num_descargas + 1 WHERE nombre_archivo LIKE '".$nombre_archivo."' ";
        	mysql_query($actualiza);
    	}
    	else {
    		$inserta_nuevo = "INSERT INTO descargas_archivos (nombre_archivo) VALUES ('".$nombre_archivo."')";
    		mysql_query($inserta_nuevo);
    	}
    	
    }

    Классика.

    Yurik, 19 Ноября 2010

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

    +164

    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
    # Обрабатываем встроенные теги
    $msg = str_replace("[u]", "<u>", $msg);
    $msg = str_replace("[U]", "<u>", $msg);
    $msg = str_replace("[i]", "<i>", $msg);
    $msg = str_replace("[I]", "<i>", $msg);
    $msg = str_replace("[b]", "<b>", $msg);
    $msg = str_replace("[B]", "<b>", $msg);
    $msg = str_replace("[sub]", "<sub>", $msg);
    $msg = str_replace("[SUB]", "<SUB>", $msg);
    $msg = str_replace("[sup]", "<sup>", $msg);
    $msg = str_replace("[SUP]", "<sup>", $msg);
    $msg = str_replace("[/u]", "</u>", $msg);
    $msg = str_replace("[/U]", "</u>", $msg);
    $msg = str_replace("[/i]", "</i>", $msg);
    $msg = str_replace("[/I]", "</i>", $msg);
    $msg = str_replace("[/b]", "</b>", $msg);
    $msg = str_replace("[/B]", "</b>", $msg);
    $msg = str_replace("[/SUB]", "<sub>", $msg);
    $msg = str_replace("[/sub]", "</sub>", $msg);
    $msg = str_replace("[/SUP]", "</sup>", $msg);
    $msg = str_replace("[/sup]", "</sup>", $msg);

    Года 4 назад пришлось лазить и исправлять код чужой гостевухи,
    вот такое встретилось, и это ещё не хит ;-)

    dwinner, 17 Ноября 2010

    Комментарии (15)
  10. Perl / Говнокод #4591

    −155

    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
    sub write_cookie {
    	my %params = @_;
    
    	if ($params{'-expires'} =~ /\+(\d+)m/) {
    		my ($sec, $min, $hour, $mday, $mon, $year, $wday) = gmtime($date + $1 * 60);
    
    		$year += 1900;
    		my @mos = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    		my @dys = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
    		$mon  = $mos[$mon];
    		$wday = $dys[$wday];
    
    		$params{'-expires'} = sprintf("%s, %02i-%s-%04i %02i:%02i:%02i GMT", $wday, $mday, $mon, $year, $hour, $min, $sec);
    	}
    
    	$params{'-path'}    = " path=$params{'-path'};"       if $params{'-path'};
    	$params{'-expires'} = " expires=$params{'-expires'};" if $params{'-expires'};
    
    	"$params{'-name'}=$params{'-value'};$params{'-path'}$params{'-expires'}";
    }

    setcookie() Perl-вариант.

    Arigato, 11 Ноября 2010

    Комментарии (15)
  11. Pascal / Говнокод #4558

    +106

    1. 1
    2. 2
    3. 3
    FilterKey = 'Software'+'\'+CompanyName+'\'+ApplName+'\'+ApplVersion+'\'+SettingsKey+'\'+'FilterDD';
    OrderKey = 'Software'+'\'+CompanyName+'\'+ApplName+'\'+ApplVersion+'\'+SettingsKey+'\'+'OrderDD';
    NotepadKey = 'Software'+'\'+CompanyName+'\'+ApplName+'\'+ApplVersion+'\'+SettingsKey+'\'+'Notepad';

    повторение - мать учения

    gorsash, 08 Ноября 2010

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