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

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

    +149

    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
    function footer_menu()
    {
        global $tbl_lng;
        $result_str = '';
        $first = true;
        
        $sql = mysql_query('SELECT section_id, section_name, section_level, section_url FROM '.$tbl_lng.' WHERE section_level = 1 ORDER BY section_order')
          or die("Invalid query: " . mysql_error()); 
        while($row = mysql_fetch_array($sql))  
        {
            if ($row['section_url'] != '')
            {
                if ($first)
                {
                  $first = false;
                  $result_str = $result_str.'<a class="header_menu2_txt" href="' . $row["section_url"] . '">' . $row["section_name"] . '</a>';
                }
                else
                {
                    $result_str = $result_str.'<img src="images/footer_s.png" width="26" height="20" alt="" /><a class="header_menu2_txt" href="' . $row["section_url"] . '">' . $row["section_name"] . '</a>';
                }
            }
            else
            {
                if ($first)
                {
                  $first = false;
                  $result_str = $result_str.'<a class="header_menu2_txt" href="index.php?section_id=' . $row["section_id"] . '">' . $row["section_name"] . '</a>';
                }
                else
                {
                    $result_str = $result_str.'<img src="images/footer_s.png" width="26" height="20" alt="" /><a class="header_menu2_txt" href="index.php?section_id=' . $row["section_id"] . '">' . $row["section_name"] . '</a>';
                }
                
            }
        }
        
        mysql_free_result($sql);
       
        return $result_str;
    }

    Реализация нижнего меню.

    enemis, 21 Июля 2011

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

    +157

    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 parse_req($value) 
    {
        global $log_conf;
        if(!is_array($value)) 
        {
            if(preg_match("#UNION|OUTFILE|SELECT|ALTER|INSERT|DROP|TRUNCATE#i", base64_decode($value))) 
            {
                if($log_conf['queryError'] == 1) writeInLog('Попытка произвести SQL-Inj текст: '.$value, 'sql');
                //fatal_error(_ERROR, _UNKNOWN_ERROR);	
    			die();
            }
        }
        else
        {
            foreach($value as $val) 
            {
                parse_req($val);
            }
        }
    }

    Баян конечно, но всегда удивляюсь на что они рассчитывают?
    Как-бы борится с SQL-Injection...

    nethak, 20 Июля 2011

    Комментарии (18)
  4. JavaScript / Говнокод #6823

    +168

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function randlogo(){
    arr=new Array('<img src="http://site.com/logo-pomegranate.png" border="0" width="677" height="345">','<img src="http://site.com/logo-leaves.png" border="0" width="677" height="345">','<img src="http://site.com/logo-lime.png" border="0" width="677" height="345">','<img src="http://site.com/logo-coffee.png" border="0" width="677" height="345">','<img src="http://site.com/logo-lime.png" border="0" width="677" height="345">','<img src="http://site.com/logo-peach.png" border="0" width="677" height="345">','<img src="http://site.com/logo-lemon.png" border="0" width="677" height="345">','<img src="http://site.com/logo-leaf.png" border="0" width="677" height="345">','<img src="http://site.com/logo-apples.png" border="0" width="677" height="345">','<img src="http://site.com/logo-grapes.png" border="0" width="677" height="345">','<img src="http://site.com/logo-autumn.png" border="0" width="677" height="345">','<img src="http://site.com/logo-strawberry.png" border="0" width="677" height="345">')
    rand=Math.floor(Math.random()*arr.length)
    document.getElementById('randlogo').innerHTML=arr[rand]
    }
    randlogo()

    Код для генерации случайного логотипа.

    undiscovered, 02 Июня 2011

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

    +115

    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
    private object[] select ( string tablename, Type type, string addict ) 
            {
                object[] returned_objects = new object[0];
                string sql = "SELECT ";
                sql += this.buildFieldNames( type );
                sql += " FROM `" + tablename + "`" + addict;
                MySqlDataReader reader = this.TryQueryReader( sql );
                while (reader.Read( ))
                {
                    var obj = Activator.CreateInstance( type );
                    FieldInfo[] fields = type.GetFields( );
                    foreach (FieldInfo finfo in fields)
                    {
                        if (finfo.FieldType == typeof( int ))
                        {
                            finfo.SetValue( obj, reader.GetInt32( finfo.Name ) );
                        }
                        else if (finfo.FieldType == typeof( bool ))
                        {
                            if (reader.GetString( finfo.Name ).Equals( "true" ))
                            {
                                finfo.SetValue( obj, true );
                            }
                            else
                            {
                                finfo.SetValue( obj, false );
                            }
                        }
                        else if (finfo.FieldType == typeof( float ))
                        {
                            finfo.SetValue( obj, reader.GetFloat( finfo.Name ) );
                        }
                        else if (finfo.FieldType == typeof( double ))
                        {
                            finfo.SetValue( obj, reader.GetDouble( finfo.Name ) );
                        }
                        else if (finfo.FieldType == typeof( string ))
                        {
                            finfo.SetValue( obj, reader.GetString( finfo.Name ) );
                        }
                    }
                    provider.IncreaseLength( ref returned_objects, 1 );
                    returned_objects.SetValue( obj, returned_objects.Length - 1 );
    
                }
                reader.Close( );
                return returned_objects;
            }

    самопальный орм, нот комментс

    glilya, 30 Мая 2011

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

    +165

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // создает массив с заданным кол-вом ячеек
    function array_from_int($count,$val=true,$start=0)
    {
    	$fcount = $count+$start;
    	for($i=$start;$i<$fcount;$i++)
    	{
    		$arr[$i] = $val;
    	}
    	return $arr;
    }

    _tL, 20 Мая 2011

    Комментарии (18)
  7. Куча / Говнокод #6606

    +131

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <tr> <td width="209" valign="top"><font color="#1674b5">Русский язык</font></td> <td width="244" valign="top"><font color="#1674b5">История России</font></td> <td width="218" valign="top"><font color="#1674b5">Биология</font></td> </tr>
                 
                  <tr> <td width="209" valign="top"><font color="#1674b5">Литература</font></td> <td width="244" valign="top"><font color="#1674b5">Обществознание</font></td> <td width="218" valign="top"><font color="#1674b5">Химия</font></td> </tr>
    
                 
                  <tr> <td width="209" valign="top"><font color="#1674b5">Математика</font></td> <td width="244" valign="top"><font color="#1674b5">Физика</font></td> <td width="218" valign="top"><font color="#1674b5">География</font></td> </tr>
                 
                  <tr> <td width="209" valign="top"><font color="#1674b5">Информатика и ИКТ</font></td> <td width="244" valign="top"><font color="#1674b5">Иностранный язык</font></td> <td width="218" valign="top">

    Вёрстка сайта на Битриксе.

    RaZeR, 09 Мая 2011

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

    +142

    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
    function categories_all()
    {
    	// Запрос.
    	$query = "SELECT id, title FROM categories ORDER BY id DESC";
    	$result = mysql_query($query) or die (mysql_error());
    							
    	if (!$result)
    		die(mysql_error());
    	
    	// Извлечение из БД.
    	$n = mysql_num_rows($result);
    	$cat = array();
    
    	for ($i = 0; $i < $n; $i++)
    	{
    		$row = mysql_fetch_assoc($result);		
    		$cat[] = $row;
    	}
    	
    	return $cat;
    }

    Выборка всех категорий Такого я еще нигде не видел.

    Vasiliy, 01 Мая 2011

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

    +38

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Drupal.parseJson = function (data) {
      if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) {
        return { status: 0, data: data.length ? data : Drupal.t('Unspecified error') };
      }
      return eval('(' + data + ');');
    };

    no comments. и как я понимаю нормальные люди делают eval завернутый в try

    brainstorm, 30 Апреля 2011

    Комментарии (18)
  10. Си / Говнокод #6480

    +142

    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
    char version[80] = "       POSIX compliant Communications test program version 1.00 4-25-1999\r\n";
       char version1[80] = "          Copyright(C) Mark Zehner/Peter Baumann 1999\r\n";
      
    fputs(version,output);               //display the program introduction
       fputs(version1,output);
       fputs(version2,output);
       fputs(version3,output);
       fputs(version4,output);
       fputs(version5,output);
       fputs(version6,output);
       fputs(version7,output);
       fputs(version8,output);
       fputs(version9,output);
       fputs(version10,output);
       fputs(version11,output); 
       fputs(version12,output);
       fputs(version13,output);

    http://www.comptechdoc.org/os/linux/programming/c/linux_pgcserial.html
    кришну вроде не вызывают. код странным образом напоминает индусский...

    ursus, 26 Апреля 2011

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

    +173

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    echo("
    <div id='navigation'>
    	<center>
    		<ul>
    			<li><a href='http://URL' id='homelink' onmouseover=" . '"Enlarge(' ."'#homelink')" . '"'. " onmouseout='" . 'Normalize("#homelink")' . "'>Домой</a></li>
    			<li><a href='#' id='aboutlink' onmouseover=" . '"Enlarge(' ."'#aboutlink')" . '"'. " onmouseout='" . 'Normalize("#aboutlink")' . "'>О нас</a></li>
    			<li><a href='http://URL' id='bdlink' onmouseover=" . '"Enlarge(' ."'#bdlink')" . '"'. " onmouseout='" . 'Normalize("#bdlink")' . "'>База знаний</a></li>
    			<li><a href='#' id='chatlink' onmouseover=" . '"Enlarge(' ."'#chatlink')" . '"'. " onmouseout='" . 'Normalize("#chatlink")' . "'>Общение</a></li>");

    Вот так вот справляемся с двумя видами кавычек.

    RaZeR, 14 Апреля 2011

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