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

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

    +154

    1. 1
    Insert into reading_count_pages (page_id, reading_count) values (973, 1)

    Любителям простых SQL-инъекций:
    Сайт одного университета: http://impuls.vntu.edu.ua/, писали, видимо, студенты должники.

    На разных страницах сайта можно наблюдать MySQL ерроры, подставляя данные в GET-запрос. Так же, по запросам можно судить о качестве проектирования сайта.
    Пример (http://impuls.vntu.edu.ua/?news_id=973%60):
    Insert into reading_count_pages (page_id, reading_count) values (973, 1), потом выполняется group by по айдишке и считается каунт. Еще пример: http://impuls.vntu.edu.ua/?all&t=50000&f=0

    rO_ot, 16 Июня 2011

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

    +157

    1. 1
    2. 2
    //header("Location:fbattle.php");
    die("<script>location.href='fbattle.php';</script>");

    header для лохов.

    jQuery, 18 Мая 2011

    Комментарии (28)
  4. C++ / Говнокод #6682

    +173

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    NNLayer::~NNLayer()
    {
    	// call Initialize(); makes sense if you think
    	
    	Initialize();
    }

    Отсюда: http://www.codeproject.com/KB/library/NeuralNetRecognition.aspx

    eigenein, 16 Мая 2011

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

    +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
    45. 45
    46. 46
    47. 47
    48. 48
    function colorQuote($message) {
        global $tinyib, $mysql_posts_table, $mysql_database, $mysql_password, $mysql_username, $mysql_host;
        $message=str_replace("<", "<", $message);
        $message=str_replace("'", "'", $message);
        $message=str_replace("\n", "<br>\n", $message);
        $cd = getcwd();
        $lastSlash = 0;
        if (($lastSlash = strrpos($cd, '/')) === false)
        {
            if (($lastSlash = strrpos($cd, '\\')) === false)
            {
                $lastSlash = 0;
            }
        }
        $message_lines=explode("\n", $message);
        for($i=0; $i<count($message_lines); $i++) {
            if(preg_match("#^(\*|\+|-) .*#si", $message_lines[$i])) {
                if(!preg_match("#^(\*|\+|-) .*#si", $message_lines[$i-1]) && substr($message_lines[$i-1], 0, 4)!="<ul>" && substr($message_lines[$i-1], 0, 4)!="<li>"){
                    $message_lines[$i]="<ul>".preg_replace("#^(\*|\+|-) (.*)#si", "<li>\\2</li>", $message_lines[$i]);
                }
                $message_lines[$i]=preg_replace("#^(\*|\+|-) (.*)#si", "<li>\\2</li>", $message_lines[$i]);
                if(!preg_match("#^(\*|\+|-) .*#si", $message_lines[$i+1]) && substr($message_lines[$i+1], 0, 5)!="</ul>" && substr($message_lines[$i+1], 0, 4)!="<li>"){
                    $message_lines[$i].="</ul>";
                }
            }
            if(preg_match("|^[0-9]+\..*|si", $message_lines[$i])) {
                if(!preg_match("|^[0-9]+\..*|si", $message_lines[$i-1]) && substr($message_lines[$i-1], 0, 4)!="<ol>" && substr($message_lines[$i-1], 0, 4)!="<li>"){
                    $message_lines[$i]="<ol>".$message_lines[$i];
                }
                $message_lines[$i]=preg_replace("|[0-9]+\.(.*)|si", "<li>\\1</li>", $message_lines[$i]);
                if(!preg_match("|^[0-9]+\..*|si", $message_lines[$i+1]) && substr($message_lines[$i+1], 0, 5)!="</ol>" && substr($message_lines[$i+1], 0, 4)!="<li>"){
                    $message_lines[$i].="</ol>";
                }
            }
            $message_lines[$i]=preg_replace("|^>(.*)|is", "<span class=\"unkfunc\">>\\1</span>", $message_lines[$i]);
            if(preg_match("|^[\s]{4}.+$|si", $message_lines[$i])){
                $message_lines[$i]=preg_replace("|^[\s]{4}(.+)$|si", "<pre>\\1</pre>", $message_lines[$i]);
            }
        }
        $message=implode("\n", $message_lines);
        $message=preg_replace("|\*\*([^\*\*]+)\*\*|si", "<strong>\\1</strong>", $message);
        $message=preg_replace("|\*([^\*]+)\*|si", "<em>\\1</em>", $message);
        $message=preg_replace("|__([^__]+)__|si", "<span style='text-decoration: underline;'>\\1</span>", $message);
        $message=preg_replace("#(http://|ftp://|mailto:|irc:|news:)([^\s]+[^\s\.,?(!):;])#si", "<a href='\\1\\2'>\\1\\2</a>", $message);
        $message=preg_replace("|%%([^%%]+)%%|si", "<span class='spoiler'>\\1</span>", $message);
        $message=preg_replace("|`([^`]+)`|si", "<pre>\\1</pre>", $message);
        return $message;
    }

    Вставил почти целиком, только кусочек вырезал. PHP делает просто лютый пиздец!
    Откуда - сами догадаетесь.

    Skelet0n, 13 Мая 2011

    Комментарии (28)
  6. Python / Говнокод #6609

    −176

    1. 1
    2. 2
    3. 3
    4. 4
    def reverse(s, rs=''):
        for i in range(1, len(s)):
            rs = rs + s[len(s)-i]
        return rs+s[0]

    Reverse String по-питоновски с говном

    Govnocoder#0xFF, 10 Мая 2011

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

    +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
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    // Подходы различной национальности
    
    /* Первый */
    function filesize_format($bytes, $format = '', $force = ''){
       $force = strtoupper($force);
       $defaultFormat = '%01d %s';
       if (strlen($format) == 0)
       $format = $defaultFormat;
       $bytes = max(0, (int) $bytes);
       $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
       $power = array_search($force, $units);
       if ($power === false)
       $power = $bytes > 0 ? floor(log($bytes, 1024)) : 0;
       return sprintf($format, $bytes / pow(1024, $power), $units[$power]);
    }
    /* Второй */
    function files_size( $size )
    {
        $name = array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
        $mysize = $size ? round( $size / pow(1024, ( $i = floor( log( $size, 1024 ) ) ) ), 2) .' ' .$name[$i] : $size.' Bytes';
        return $mysize;
    }
    /* Третий */
       function humanSize($size) {
          $a = array("bytes", "kb", "Mb", "Gb", "Tb", "Pb");
          $pos = 0;
          while ($size >= 1024) {
           $size /= 1024;
           $pos++;
          }
          return round($size,2)." ".$a[$pos];
         }

    Вопрос: Определите географические координаты места написания каждого...

    DoctorHouse, 27 Апреля 2011

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function sorti()
        {
        	if($_GET['where']=='desc'?$where='asc':$where='desc');
        	return 'where='.$where;
        }

    GoodTalkBot, 19 Апреля 2011

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    <table>
         <form method="post" action="/ololo/onatole.html?step={{if $step eq '2'}}3{{else}}6{{/if}}">
         <tr><td><a id="submit">...
    ....

    фаерфокс отлично парсит такие формы внутри таблиц, jQuery(this).closest('form') тоже возвращает все превосходно

    govno, 18 Апреля 2011

    Комментарии (28)
  10. PHP / Говнокод #6299

    +176

    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
    $navChain=array();
       for($i = 0; $i < count($menu); $i++){
    		if (is_array($menu[$i]['subMenu'])) {
    			for($j = 0; $j < count($menu[$i]['subMenu']); $j++){
    				if (is_array($menu[$i]['subMenu'][$j]['subMenu'])) {
    					for($k = 0; $k < count($menu[$i]['subMenu'][$j]['subMenu']); $k++){
    						if (is_array($menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'])) {
    							for($l = 0; $l < count($menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu']); $l++){
    								if (is_array($menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l]['subMenu'])) {
    									for($m = 0; $m < count($menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l]['subMenu']);$m++){
    										if ($menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l]['subMenu'][$m]['selected']=='1') {
    											$navChain[]=$menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l]['subMenu'][$m];
    											$menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l]['selected']=1;
    											$navChain[]=$menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l];
    											$menu[$i]['subMenu'][$j]['subMenu'][$k]['selected']=1;
    											$navChain[]=$menu[$i]['subMenu'][$j]['subMenu'][$k];
    											$menu[$i]['subMenu'][$j]['selected']=1;
    											$navChain[]=$menu[$i]['subMenu'][$j];
    											$menu[$i]['selected']=1;
    											$navChain[]=$menu[$i];
    										}
    									} // for
    								}
    								if ($menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l]['selected']=='1') {
    									$navChain[]=$menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l];
    									$menu[$i]['subMenu'][$j]['subMenu'][$k]['selected']=1;
    									$navChain[]=$menu[$i]['subMenu'][$j]['subMenu'][$k];
    									$menu[$i]['subMenu'][$j]['selected']=1;
    									$navChain[]=$menu[$i]['subMenu'][$j];
    									$menu[$i]['selected']=1;
    									$navChain[]=$menu[$i];
    								}
    							} // for
    						}
    						if ($menu[$i]['subMenu'][$j]['subMenu'][$k]['selected']=='1') {
    						$navChain[]=$menu[$i]['subMenu'][$j]['subMenu'][$k];
    							$menu[$i]['subMenu'][$j]['selected']=1;
    							$navChain[]=$menu[$i]['subMenu'][$j];
    							$menu[$i]['selected']=1;
    							$navChain[]=$menu[$i];
    						}
    					} // for
    				}
    				if ($menu[$i]['subMenu'][$j]['selected']=='1') {
    					$navChain[]=$menu[$i]['subMenu'][$j];
    					$menu[$i]['selected']=1;
    					$navChain[]=$menu[$i];
    				}
    			} // for
    		}
    		if ($menu[$i][selected] && empty($navChain)) {
    			$navChain[]=$menu[$i];
    		}
    	} // for

    volatile, 09 Апреля 2011

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

    +160

    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
    #include <iostream>
    #include <string>
    using namespace std;
    int main()
    {
    	const int hz_limit = 20000;
    	string str;
    	string str_mass[] = {"a", "b", "ais", "h", "ces", "c", "his", "cis", "des",
    		"d", "dis", "es", "e", "fes", "f", "eis", "fis", "ges", "g", "gis", "as"};
    	begin:
    	while (cin>>str)
    	{
    		for (size_t ix = 0; ix != str.size(); ++ix)
    		{
    			str[ix] = tolower(str[ix]);
    		}
    		size_t f = 0;
    		for (size_t ix = 0; ix != 21; ++ix)
    		{
    			if(str == str_mass[ix])
    			{
    				f = ix;
    			}
    		}
    		if (str != str_mass[f])
    		{
    			goto begin;
    		}
    		double mass[] = {27.500, 29.135, 29.135, 30.868, 30.868, 32.703, 32.703, 34.648, 34.648,
    		36.708, 38.891, 38.891, 41.203, 41.203, 43.654, 43.654, 46.249, 46.249, 48.999, 51.913, 51.913};
    		for (; mass[f] < hz_limit; mass[f] *= 2)
    			{
    				cout<<mass[f]<<" Hz"<<endl;
    			}
    	}
    	return 0;
    }

    Моя первая прога. Выводит частоты на которых находится введенная нота...

    Extrawelt, 21 Марта 2011

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