1. PHP / Говнокод #4469

    +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
    // Обторное, свежее, сочнейшие гавнище. Давно такого не встречал.
    
    
    curl_setopt($ch, 42, 1);
    curl_setopt($ch, 47, 1);
    curl_setopt($ch, 43, 1);
    curl_setopt($ch, 41, 0);
    curl_setopt($ch, 52, 0);
    curl_setopt($ch, 81, 0);
    curl_setopt($ch, 64, 0);
    
    if($this->binary) {
           curl_setopt($ch, 19914, 1);
    }

    Вот так нужно задавать настройки cURL. И никакой обфуксации не надо. Суть гавна поймут только истиные ценители.

    j0kz, 27 Октября 2010

    Комментарии (22)
  2. C++ / Говнокод #4468

    +154

    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
    ////.....
    			// 
    			// button2
    			// 
    			this->button2->Name = L"button2";   //Кнопка с номером 2,
    			this->button2->Text = L"3";         //текстом "3"
    			            //и вызывающая обработчик кнопки 1.
    			this->button2->Click += gcnew System::EventHandler(this, &Form1::button1_Click); 
    			// 
    			// button3
    			// 
    			this->button3->Name = L"button3"; //Кнопка с номером 3,
    			this->button3->Text = L"5";       //текстом "5"
    			            //тоже вызывающая обработчик кнопки 1
    			this->button3->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
    ////.....
    #pragma endregion
    	private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
    			 }
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    
    			 if (Form1::textBox1->Text=="0")
    Form1::textBox1->Text=((System::Windows::Forms::Button^ )sender)->Text;
    			 else
    				 Form1::textBox1->Text+=((System::Windows::Forms::Button^ )sender)->Text;
    		 }
    private: System::Void button17_Click(System::Object^  sender, System::EventArgs^  e) {
    			 Form1::textBox1->Text="0";
    			 m_Box=0;		 }
    private: System::Void button15_Click(System::Object^  sender, System::EventArgs^  e) {
    			 float x = float::Parse(Form1::textBox1->Text);
    
    			 m_Box = float::Parse(Form1::textBox1->Text);
    			
    			  Form1::textBox1->Text="";
    			 oper =((System::Windows::Forms::Button^)sender)->Text;
    		 }
    private: System::Void button16_Click(System::Object^  sender, System::EventArgs^  e) {
    			 float x = float::Parse(Form1::textBox1->Text);
    			
    if (oper=="+")
    m_Box+=x;
    if(oper=="-")
    m_Box-=x;
    if(oper=="*")
    m_Box*=x;
    if (oper=="/")
    m_Box /=x;
    Form1::textBox1->Text=m_Box.ToString();
    		 }
    };
    }

    Это кусок простейшего калькулятора одной девушки. Кроме всего прочего вышеописанный код составляющий единственную логику приложения находится в "Form1.h".

    nekotwi, 27 Октября 2010

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

    −114

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    bool userNameChanged = true;
      [userName isEqualToString:oldUserName]!=YES;
      bool passwordChanged = true;
      [password isEqualToString:oldPassword]!=YES;
      bool retVal = true;
      if(userNameChanged)
      {
        retVal &= setUserNameInPreferences(userName);
      }

    Чудеса сравнения

    apodrugin, 27 Октября 2010

    Комментарии (2)
  4. Python / Говнокод #4466

    −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
    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
    def getrows(c):
        return \
            sum( # суммируем по категориям
                map(
                    lambda category:
                        sum( # суммируем по itemid
                            map(
                                lambda itemidset:
                                    sum( # суммируем по itemstring
                                        map(
                                            lambda itemstring:
                                                map(
                                                    lambda info:
                                                        transaction(category, itemstring, info),
                                                    itemidset[itemstring].values()
                                                ),
                                            itemidset.keys()
                                        ),
                                    []),
                                c[category].values()
                            ),
                            []
                        ),
                    ("completedAuctions", "failedAuctions", "completedBidsBuyouts")
                ),
                []
            )

    Залез в свой старый скрипт, генерирующий отчеты, думал кое-что подправить...
    Увидел одну из функций (эту) и решил лучше забить тут что-то править хД

    Причины такого ужаса - наверно отсутствие явной типизации в питоне и средств рефакторинга (rename variable, extract method, ...) в "IDE"

    burdakovd, 27 Октября 2010

    Комментарии (17)
  5. JavaScript / Говнокод #4465

    +158

    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
    function rateWidth($rating){
    $rating = parseFloat($rating);
    switch ($rating){
    case 0.5: $width = "14px"; break;
    case 1.0: $width = "28px"; break;
    case 1.5: $width = "42px"; break;
    case 2.0: $width = "56px"; break;
    case 2.5: $width = "70px"; break;
    case 3.0: $width = "84px"; break;
    case 3.5: $width = "98px"; break;
    case 4.0: $width = "112px"; break;
    case 4.5: $width = "126px"; break;
    case 5.0: $width = "140px"; break;
    default:  $width =  "84px";
    }
    return $width;
    }
    
    
    function starSprite($rating){
    $rating = parseFloat($rating);
    switch ($rating){
    case 0.5: $pos = "-11px"; break;
    case 1.0: $pos = "-22px"; break;
    case 1.5: $pos = "-33px"; break;
    case 2.0: $pos = "-44px"; break;
    case 2.5: $pos = "-55px"; break;
    case 3.0: $pos = "-66px"; break;
    case 3.5: $pos = "-77px"; break;
    case 4.0: $pos = "-88px"; break;
    case 4.5: $pos = "-99px"; break;
    case 5.0: $pos = "-110px"; break;
    default:  $pos =  "-77px";
    }
    return $pos;
    }
    });

    Казалось бы — [:||||:]
    Но на него я попал с туториала для jquery.com

    Взято отсюда: http://eligeske.com/jquery/jquery-star-comment-rating/

    mrbig66, 27 Октября 2010

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

    +132

    1. 1
    2. 2
    3. 3
    4. 4
    <div class="no-display">
    	<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
    	<input type="hidden" name="related_product" id="related-products-field" value="" />
    </div>

    дефолтная тема Megento. подобными вещами полна коробочка...

    govnoboy, 27 Октября 2010

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

    +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
    if (empty($whatpage)) {  
             if (empty($catpage)) { $myFile='articles/main.dat';
             } else {
                      if (empty($subcatpage)) { $myFile="articles/$catpage/main.dat"; 
                      } else { $myFile="articles/$catpage/$subcatpage/main.dat";
                      }
             }
    } else { 
            if (empty($catpage)) { $myFile="articles/$whatpage.dat";
            } else {
                      if (empty($subcatpage)) { $myFile="articles/$catpage/$whatpage.dat"; 
                      } else { $myFile="articles/$catpage/$subcatpage/$whatpage.dat";
                      }
            }
    }
    $fh = @fopen($myFile, 'r'); 
    if (!$fh) { $myFile='articles/404.dat'; header('Status: 404'); header('HTTP/1.1 404 Not Found'); $fh = @fopen($myFile, 'r'); } 
    $data = fread($fh, filesize($myFile));

    кусок CMS с кучей бесполезной работы повторяющимся кодом и без знания об file_get_contents и file_exists

    porese, 27 Октября 2010

    Комментарии (11)
  8. JavaScript / Говнокод #4462

    +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
    28. 28
    29. 29
    <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    $("#cardbutton89").click( function () {
    $("#confirmation_of_order89").css({opacity: 1}).show().animate({opacity: 0}, 3000 );
    $("#korzina").load("/korzina.php", {
    "zakaz": "Еврокнижка \"Лерида\"",
    "colvo": $("#cardinputtext89").val(),
    "zena": "10750"
    });
    } );
    
    
    //--><!]]>
    </script>
    <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    $("#cardbutton88").click( function () {
    $("#confirmation_of_order88").css({opacity: 1}).show().animate({opacity: 0}, 3000 );
    $("#korzina").load("/korzina.php", {
    "zakaz": "Еврокнижка \"Легион\"",
    "colvo": $("#cardinputtext88").val(),
    "zena": "15170"
    });
    } );
    
    
    //--><!]]>
    </script>
    ...

    Число script'ов по числу товаров на странице. С того же сайта, что и http://govnokod.ru/4404

    telnet, 27 Октября 2010

    Комментарии (20)
  9. C++ / Говнокод #4461

    +156

    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
    // #include<....>
    
    using namespace std;
    
    #if ( _WIN32 || __WIN32__ || _WIN64 || __WIN64__ )
    #define I64 "%I64d"
    #else
    #define I64 "%Ld"
    #endif
    
    #define PB(x) push_back(x)
    #define MP(x,y) make_pair(x,y)
    #define dbg(x) cerr << #x << " = " << x << endl
    #define fori(i,b,e) for(int i = (b); i < (e); i++)
    #define forall(p,s) for(typeof((s).begin()) p = (s).begin(); p != (s).end(); p++)
    #define memclr(a) memset((a), 0, sizeof(a))
    
    typedef long long int64;
    const long long inf = ((long long)1 << 63) - 1;
    
    #define PROBLEM_NAME "a"
    
    #define add(i, j, val, p, ch) \
    do { \
    	par[i][j][val] = p; \
    	c[i][j][val] = ch; \
    	was[i][j][val] = true; \
    	d[i][j][val] = d[i][j][p] + 1; \
    	a[i][j][sz[i][j]++] = val; \
    } while (0)
    
    void bfs(int n) {
    	int p[10][10][2];
    	for (int i = 0; i < 10; i++) {
    		for (int j = 0; j < 10; j++) {
    			p[i][j][0] = min(i,j);
    			p[i][j][1] = max(i,j);
    		}
    	}
    	static int par[10][10][2 << 16];
    	static int c[10][10][2 << 16];
    	static bool was[10][10][2 << 16];
    	static int a[10][10][2 << 16];
    	static int d[10][10][2 << 16];
    	static int sz[10][10];
    	static int cur[10][10];
    
            //...
    }
    int main() {
            //...
    }

    Часть шаблона, ну еще кое-какие макросы, т.к. влом было писать нормально. Зато работало. bfs не обыкновенный, если кого это смутит.

    baton, 27 Октября 2010

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

    +156

    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
    <?php
     set_time_limit(600);
    //error_reporting (E_ALL);
    #############################################################
    ## Проверка: запущен или нет фтп сервер. Зпускаю nnCron'ом ##
    #############################################################
    
    $proxy = "172.16.0.2";
    $port = "2121";
    $timeout = 10;
    $sleep = 0;
    require_once('set.php');
    $link = mysql_connect($servername, $username, $password) or die("Could not connect : ".mysql_error());
    mysql_query("SET CHARACTER SET cp1251;");
    mysql_select_db("ftp");
    $online=mysql_query("SELECT * FROM `online_sial`;");
    $offline=mysql_query("SELECT * FROM `offline_sial`;");
    $this_time = time();
    
      while ($row = mysql_fetch_array($online)) {
       $url = "ftp://".$row['ipaddr']."/";
       if($fp = fsockopen($proxy, $port, $errno, $errstr, $timeout)){
        fputs($fp, "GET $url HTTP/1.0\r\nHost: $proxy\r\n\r\n");
        stream_set_timeout($fp, 10);
        $res = fread($fp, 100);
        $info = stream_get_meta_data($fp);
        fclose($fp);
        if (!$info['timed_out']){
         $del="DELETE FROM `online_sial` WHERE ipaddr=\"".$row['ipaddr']."\";";
         $ins="INSERT INTO `online_sial` values (\"".$row['hostname']."\", \"".$row['ipaddr']."\", \"".$this_time."\", \"".$row['comment']."\");";
         mysql_query($del);
         mysql_query($ins);
         echo $row['hostname']."<br />";
        }else{
         $del="DELETE FROM `online_sial` WHERE ipaddr=\"".$row['ipaddr']."\";";
         $ins="INSERT INTO `offline_sial` values (\"".$row['hostname']."\", \"".$row['ipaddr']."\", \"".$this_time."\", \"".$row['comment']."\");";
         mysql_query($del);
         mysql_query($ins);
         echo $row['hostname']."<br />";
        }
        sleep($sleep);
    
       }else echo "Proxy упал<br />";
    
      }
    
      while ($row = mysql_fetch_array($offline)) {
    
       $url = "ftp://".$row['ipaddr']."/";
    
       if($fp = fsockopen($proxy, $port, $errno, $errstr, $timeout)){
    
        fputs($fp, "GET $url HTTP/1.0\r\nHost: $proxy\r\n\r\n");
    
        stream_set_timeout($fp, 10);
    
        $res = fread($fp, 100);
    
        $info = stream_get_meta_data($fp);
    
        fclose($fp);
    
        if (!$info['timed_out']){
    
         $del="DELETE FROM `offline_sial` WHERE ipaddr=\"".$row['ipaddr']."\";";
    
         $ins="INSERT INTO `online_sial` values (\"".$row['hostname']."\", \"".$row['ipaddr']."\", \"".$this_time."\", \"".$row['comment']."\");";
    
         mysql_query($del);
    
         mysql_query($ins);
    
         echo $row['hostname']."<br />";
    
        }
    
        sleep($sleep);
    
       } echo "Proxy упал<br />";
    
      }
    
    
    
    
    
    mysql_query("ALTER TABLE `ftp`.`online_sial` ORDER BY `hostname`;");
    
    mysql_query("ALTER TABLE `ftp`.`offline_sial` ORDER BY `hostname`;");
    
    mysql_close($link);
    
    ?>

    Пять лет назад. Этим можно пугать детей.

    Jesus, 27 Октября 2010

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