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

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

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $res = mysql_query("SELECT id, name, furltag, furlspage FROM {$oCfg->prefX}core WHERE top = 9 AND act = 1");
    $num_res = mysql_num_rows($res);
    for ($i = 1; $i <= $num_res; $i++){
        $row = mysql_fetch_assoc ($res);
    }

    Моё =)

    De-Luxis, 15 Сентября 2011

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

    −343

    1. 1
    [[[[[[mainDelegate.subController.CellOfTable.subCellsArray objectAtIndex:[[sourceArray objectAtIndex:1] intValue]] objectForKey:@"Cell in subCell"] subviews] objectAtIndex:0] subviews] objectAtIndex:0];

    Доголи-коротколи, а до нужной ячейки доберемся ))))

    Psionic, 13 Сентября 2011

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

    +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
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    $id = $_POST['id'];
    //$id = 194;
    $temp = $id;
    $str = "";
    for ( $incr = 0; $incr < 100; $incr++ ) {
    	$result = $dbs -> query("SELECT * FROM 
    								market_categs 
    							WHERE 
    								categid={$temp} AND 
    								published = 1 AND 
    								status = 1");
    	if ( mysql_num_rows($result) > 0 ) {
    		$categ = mysql_fetch_array($result);
    		$result2 = $dbs -> query("SELECT * FROM 
    									market_categs_trans 
    								WHERE 
    									categid={$categ[categid]}");
    		$categ_title = mysql_fetch_array( $result2 );
    		$str2 = "";
    		$temp2 = $categ[categid];
    		for ( $incr2 = 0; $incr2 < 100; $incr2++ ) {
    			$result3 = $dbs -> query("SELECT * FROM 
    										market_categs 
    									WHERE 
    										categid={$temp2} AND 
    										published = 1 AND 
    										status = 1");
    			if ( mysql_num_rows($result3) > 0 ) {
    				$categ2 = mysql_fetch_array($result3);
    				$str2 .= "/".$categ2[url];
    				$temp2 = $categ2[parent];
    			}
    		}
    		$str2 = substr($str2,1);
    		$nb2 = substr_count($str2,"/");
    		$temp_str2 = explode ("/",$str2);
    		$str2 = "";
    		$back = "";
    		for ($i2 = $nb2; $i2 >= 0; $i2--) {
    			$str2 .="/".$temp_str2[$nb2];
    			$nb2--;
    		}
    		$str .= " / <a href='/".substr($str2,1)."'>".$categ_title[title]."</a>";
    		$temp = $categ[parent];
    	}
    }

    Рекурсия... мать его

    cephuo, 12 Сентября 2011

    Комментарии (10)
  5. Python / Говнокод #7804

    −85

    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
    def captions_and_translations_to_srt(captions_and_translations):
        output = StringIO.StringIO()
        for i in range(len(captions_and_translations)):
            translation_to_srt(captions_and_translations[i][1],
                               captions_and_translations[i][0],
                               i, output)
        srt = output.getvalue()
        output.close()
        return srt
    
    def translation_to_srt(translation, video_caption, index, output):
        subtitle_to_srt_impl(video_caption.caption_text if translation is None \
                             else translation.translation_text, 
                             video_caption, index, output)
    
    def subtitle_to_srt_impl(text, video_caption, index, output):
        output.write(str(index + 1))
        output.write("\n")
        write_srt_time_line(video_caption, output)
        output.write(text)
        output.write("\n\n")
    
    def write_srt_time_line(video_caption, output):
        write_srt_time(video_caption.start_time, output)
        output.write(" --> ")
        write_srt_time(video_caption.end_time, output)
        output.write("\n")
    
    def write_srt_time(seconds, output):
        seconds_int = int(seconds)
        write_padded_num((seconds_int / 3600) % 60, 2, output)
        output.write(":")
        write_padded_num((seconds_int / 60) % 60, 2, output)
        output.write(":")
        write_padded_num(seconds_int % 60, 2, output)
        output.write(",")
        write_padded_num(int(seconds * 1000) % 1000, 3, output)
    
    def write_padded_num(num, numchars, output):
        strnum = str(num)
        numzeros = numchars - len(strnum)
        for i in range(numzeros):
            output.write("0")
        output.write(strnum)

    Генератор SRT субтитров.

    alerion, 08 Сентября 2011

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

    +167

    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
    // Проверка на спам
    $Spam = false;
    if ( substr_count( GetParam( 'info', true ), '[url' ) > 0 )
    {
    	$Spam = true;
    };
    if ( substr_count( GetParam( 'info', true ), 'viagra' ) > 0 )
    {
    	$Spam = true;
    };
    if ( substr_count( GetParam( 'info', true ), 'cialis' ) > 0 )
    {
    	$Spam = true;
    };
    if ( substr_count( GetParam( 'info', true ), 'casino' ) > 0 )
    {
    	$Spam = true;
    };
    if ( strlen( GetParam( 'info', true ) ) < 10 )
    {
    	$Spam = true;
    };
    
    if ( $Spam )
    {
    	$Message = "В тексте сообщения находятся спам-подобные слова.";
    }

    кусок кода одного скрипта, гордо именуемого CMS

    forkhammer, 07 Сентября 2011

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

    +170

    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
    <?php
    // $Id: post.php, v 1.12 2010/08/09 11:42:55 dries Exp $
    
    /**
     * Description of post
     *		Sending Email
     *
     * @author Unknown
     */
    class post {
    
    	public function send ( $email, $subject, $message, $addHeaders, $addParameters ) {
    
    		return mail($email, $subject, $message, $addHeaders, $addParameters);
    	}
    }
    ?>

    Цит: "Говорят, что сначала была нарисована какая-то картина, а потом Малевич закрасил ее в черный цвет".
    Ну мы ХОТЕЛИ нарисовать. Очень очень...

    istem, 05 Сентября 2011

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

    +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
    <?php 
    function greeting($_lang="ru", $_offset=""){ 
        //// Функция greeting 
        //// Возвращает приветствие 
         
        // Языковые переменные 
        $lang = array( 
            'ru' => array( 
                'morning' => 'Доброе утро!', 
                'afternoon' => 'Добрый день!', 
                'evening' => 'Добрый вечер!', 
                'night' => 'Доброй ночи!' 
            ), 
            'en' => array( 
                'morning' => 'Good morning!', 
                'afternoon' => 'Good afternoon!', 
                'evening' => 'Good evening!', 
                'night' => 'Good night!' 
            ) 
        ); 
         
        if(empty($_offset)){ 
            // Если время на Вашем сервере отличается от Вашего, поменяйте сдвиг в переменной $offset 
            $_offset = 0; 
        } 
        if(empty($_lang)){ 
            // язык по умолчанию 
            $_lang = 'ru'; 
        } 
             
        // $curr_hour = текущий час 
        $curr_hour = date('G', time() + (60 * 60 * $_offset)); 
         
        if($curr_hour >= "5" && $curr_hour <= "11"){ 
            // если текущий час больше 5 и менее 11 
            return $lang[$_lang]['morning']; 
        }elseif($curr_hour >= "12" && $curr_hour <= "17"){ 
            // если текущий час больше 12 и менее 17 
            return $lang[$_lang]['afternoon']; 
        }elseif($curr_hour >= "18" && $curr_hour <= "20"){ 
            // если текущий час больше 18 и менее 20 
            return $lang[$_lang]['evening']; 
        }else{ 
            // все другие случаи 
            return $lang[$_lang]['night']; 
        } 
    } 
    ?>

    Концептуально новый серьезный подход к приветствию пользователя.

    7ion, 04 Сентября 2011

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

    +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
    function getGroupName($numg) {
        global $gname;
        if (is_file('../sys/groups.php')) {
            include ('../sys/groups.php');
        }
        else {
            include ('sys/groups.php');
        }
        if ($numg==0) {
            $gname = $gr['0'];
            return $gname;
        } else if ($numg==1) {
            $gname = $gr['1'];
            return $gname;
        } else if ($numg==2) {
            $gname = $gr['2'];
            return $gname;
        } else if ($numg==3) {
            $gname = $gr['3'];
            return $gname;
        }
    }

    skad0, 31 Августа 2011

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

    +147

    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
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    /* Dimensions */
    /* Widths */
    .w10{width:10px;}
    .w20{width:20px;}
    .w25{width:25px;}
    .w50{width:50px;}
    .w75{width:75px;}
    .w100{width:100px;}
    .w125{width:125px;}
    .w150{width:150px;}
    .w175{width:175px;}
    .w200{width:200px;}
    .w210{width:210px;}
    .w225{width:225px;}
    .w250{width:250px;}
    .w260{width:260px;}
    .w270{width:270px;}
    .w275{width:275px;}
    .w300{width:300px;}
    .w325{width:325px;}
    .w350{width:350px;}
    .w375{width:375px;}
    .w400{width:400px;}
    .w450{width:450px;}
    .w500{width:500px;}
    .w525{width:525px;}
    .w550{width:550px;}
    .w600{width:600px;}
    .w625{width:625px;}
    .w650{width:650px;}
    .w800{width:800px;}
    /* Heights */
    .h15{height:15px;}
    .h20{height:20px;}
    .h25{height:25px;}
    .h50{height:50px;}
    .h75{height:75px;}
    .h100{height:100px;}
    .h125{height:125px;}
    .h150{height:150px;}
    .h175{height:175px;}
    .h200{height:200px;}
    .h225{height:225px;}
    .h250{height:250px;}
    .h275{height:275px;}
    .h300{height:300px;}
    .h325{height:325px;}
    .h350{height:350px;}
    .h375{height:375px;}
    .h400{height:400px;}
    
    /* Padding */
    .noPad{padding:0;}
    .pad2{padding:2px;}
    .pad3{padding:3px;}
    .pad5{padding:5px;}
    .pad10{padding:10px;}
    .padTB5{padding:5px 0;}
    .padTB10{padding:10px 0;}
    .padTB15{padding:15px 0;}
    .padRL5{padding:0 5px;}
    .padRL10{padding:0 10px;}
    .padRL15{padding:0 15px;}
    .padRL20{padding-left:20px; padding-right:20px;}
    
    
    /* Margin */
    .noMar{margin:0;}
    .mar2{margin:2px;}
    .mar3{margin:3px;}
    .mar5{margin:5px;}
    .mar10{margin:10px;}
    .marTB5{margin:5px 0;}
    .marTB10{margin:10px 0;}
    .marTB15{margin:15px 0;}
    .marRL5{margin:0 5px;}
    .marRL10{margin:0 10px;}
    .marRL15{margin:0 15px;}
    .marRL20{margin-right:20px; margin-left:20px;}
    
    /* Visibility */
    .off{display:none;}
    .on{display:block;}

    myspace styleshit

    Lure Of Chaos, 31 Августа 2011

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

    +135

    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
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    const int volume=100;
    int index=0;
    struct memo
    {   int nach;
    	int size;
    	char name[1];
    }raboch[volume];
    void main()
    {	setlocale(LC_ALL, "rus");
    	int switc=0;
    	int i,r;
    	int p=1;
    	int tekadr=0;
    	int ID=0;
    	int razmer;
    	int zap;
    	int paz;
    	int realproc=0;
    	int vhod=0;
    	int tekad;
    	char c[1024];
    	for(i=1023;i>=0;i--) { c[i]='0';}
    	for(i=99;i>=0;i--) { raboch[i].name[0]=' ';}
    		while(p>0) {
    					cout<<"Выберите действие: 1-Выделить память 2-Очистить 3-Дефрагментировать 4-состояние памяти 5-содежимое памяти 6-выход \n";
    					cin>>r;
    					int k=1;
    					switch(r)
    						{
                            case 1:
    							cout<<"Введите имя процесса:";
    							cin>>raboch[ID].name;
    							cout<<"Введите размер выделяемой памяти в байтах:";
    							cin>>raboch[ID].size;
    							razmer=raboch[ID].size;
    							raboch[ID].nach=tekadr;
    							for(i=tekadr; razmer>0;razmer--) {c[i]=raboch[ID].name[0]; i++; }
    							tekadr+=raboch[ID].size;
    							ID++;
    							realproc=ID;
    							break;;
    						case 2:
                                cout<<"Введите ID убиваемого процесса:";
    							cin>>zap;
    							razmer=raboch[zap].size;
    							for(i=raboch[zap].nach;razmer>0;razmer--) { c[i]='0'; i++;}
    							raboch[zap].name[0]='0';
    							raboch[zap].size=0;
    							tekadr=raboch[zap].nach;
    							realproc--;
    							ID--;
    							index=realproc;
    							break;;
    						case 3:
    					        zap=1;
    							paz=0;
    							   for(i=0;i<=102;i++)
    							     {
    									 if(c[i]!='0')
    									  {  
    									  }
    									 else
    								      {   tekad=i;
    											while(k>0)
    											{
    												  zap++;
    												  if(c[raboch[zap].nach]!='0')
    												   {  paz=raboch[zap].size;
    														for(vhod=raboch[zap].nach;paz>0;paz--) {c[tekad]=c[vhod]; c[vhod]='0'; tekad++; vhod++; }
    														int num;
    														for(num=0;num<100;num++) { if(raboch[num].name[0]=='0') { paz=num; num=100;} else{} }
    															if (raboch[zap].name[0]!=' ') { realproc--;
    																							tekadr=tekad;
    																							raboch[paz].size=raboch[zap].size;
    																							raboch[zap].size=0;
    																							raboch[zap].nach=0;
    																							raboch[paz].name[0]=raboch[zap].name[0];
    																							raboch[zap].name[0]=' ';}
    														else {}	 }
    												  if (raboch[zap].name[0]==' ') { if (realproc>=0) {k=1;} else { k=0;} }
    												  else  { }  }}}   
    							break;;
    						case 4:
    					      for(zap=ID-1;zap>=0;zap--)
    								{cout<<"Имя блока:";cout<<raboch[zap].name;cout<<"\n";
    									cout<<"Размер блока:";cout<<raboch[zap].size;cout<<"\n";
    									cout<<"Начальный адресс:";cout<<raboch[zap].nach;cout<<"\n";}
    							break;;
    						case 5:
    					        cout<<"Введите начальный адресс памяти:";
    							cin>>zap;
    							cout<<"Введите конечный адресс памяти:";
    							cin>>paz;
    							for(i=zap;paz!=i;i++) {cout<<c[i];}
    							cout<<"\n";
    							break;;
    						case 6: p=0;
    								continue;}}}

    Лаба по моделированию работы с памятью. Растягиваем буфер в голове))))

    Horror89, 26 Августа 2011

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