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

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

    +148

    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
    bsz = (bsz + 3) & ~3L;
    
      tp->beg = alloc_malloc(bsz, tp->almark);
      tp->end = tp->beg + bsz;
      tp->cur = tp->beg;
      tp->aux = tp->beg;
    
      tp->mode = TAPE_MODE_IDLE;
      tp->err = FAKE_OK;
    
      tp->drv = drv;
      tp->info = NULL;
    
      ret = tp->drv->init(tp, argv);
    
      if (ret == FAKE_FAIL) {
        alloc_free_by_mark(almark);

    http://www.gamedev.ru/flame/forum/?id=153724&page=13#m190

    AnimeGovno-_-, 26 Октября 2011

    Комментарии (4)
  3. Java / Говнокод #8286

    +75

    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
    /**
     * Workaround ObjectInputStream for maintaining backward compatibility with serialization.
     * 
     * In the future, please, please, PLEASE assign each serializable class an explicit serialVersionUID.
     * 
     */
    public final class DecompressibleInputStream extends ObjectInputStream {
    	private static final Logger logger = Logger.getLogger(DecompressibleInputStream.class);
    
        public DecompressibleInputStream(InputStream in) throws IOException {
            super(in);
        }
    
        protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
            ObjectStreamClass resultClassDescriptor = super.readClassDescriptor();
            Class<?> localClass;
            
            try {
                localClass = Class.forName(resultClassDescriptor.getName()); 
            } catch (ClassNotFoundException e) {
                logger.error("No local class for " + resultClassDescriptor.getName(), e);
                return resultClassDescriptor;
            }
            
            ObjectStreamClass localClassDescriptor = ObjectStreamClass.lookup(localClass);
            
            if (localClassDescriptor != null) { // only if class implements serializable
                final long localSUID = localClassDescriptor.getSerialVersionUID();
                final long streamSUID = resultClassDescriptor.getSerialVersionUID();
                
                if (streamSUID != localSUID &&
                		(localClass == ByteArraySerial.class || localClass == Vector2D.class)) {
                	// Workaround: check for serialVersionUID mismatch with two specific classes
                    logger.error(String.format("Overriding serialized class version mismatch for %s: " +
                    		"local serialVersionUID = %s, stream serialVersionUID = %s",
                    		localClass.getName(), localSUID, streamSUID));
                    resultClassDescriptor = localClassDescriptor; // Use local class descriptor for deserialization
                }
            }
            
            return resultClassDescriptor;
        }
    }

    Продукт использует в качестве бинарного формата сохранённых файлов встроенную сериализацию. При этом ранние версии полагались на встроенный serialVersionUID.

    Вот теперь приходится расхлёбывать. Наши воркэраунды - самые воркэраундные воркэраунды в мире.

    lucidfox, 24 Октября 2011

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

    +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
    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
    <script src=scripts.js></script>
    <?
    
        if (isset($remove) && $user1 !="selectuser"):  //to remove user from DB
    	print "Was updated sucsessfully: user '$user1' was removed<br>";
    	print "<font color=red>If You want to reload this page use <u>our 'Reload' button only</u></font>";
    	$query="delete from users where login=\"$user1\"";
            $result=mysql_query($query);     
    
       if (!isset($reloadme) ):
    
    
       //decremet when registered users removed users.txt
    	$file_loc="users.txt";
    	chmod ($file_loc,0755);
    	$newfile = fopen($file_loc, "r");
    	$file_contents = fread($newfile, filesize($file_loc));
            $file_contents=$file_contents-1;   //value contains how many users
    	$newfile = fopen($file_loc, "w+");
    	fwrite($newfile, "$file_contents");
    	fclose($newfile);
    	chmod ($file_loc,0700);       // end of adding data to file
    	endif;
       endif;   //end of reloadme
    //counting of users
    	$file_loc = "users.txt";
    //	chmod ($file_loc,0644);
    	$whattoread = fopen($file_loc, "r");
    	$file_contents = fread($whattoread, filesize($file_loc));
    	fclose($whattoread);
    //	chmod ($file_loc,0755);       // end of adding data to file
    //end of counting
    
    
    
        $query="select * from users order by id";
        $result=mysql_query($query);     // for first while	
        $result1=mysql_query($query);   // for second while
    	print "<table border=1 cellspacing=0 cellpadding=0 bordercolor=#007898><tr><td>";   //external table
    	print "<table border=0 cellspacing=2 cellpadding=2 width=590><tr><td>
    	<form action=$PHP_SELF method=post><select name=\"user1\" class=select1><option value=\"selectuser\"> Select user ";
        while($row=mysql_fetch_object($result)):	
    	print"<option value=\"$row->login\" style=\"background-color:#FFFFFF;\">$row->login";	
    	endwhile;
    	print "</select><br>
    	<input type=hidden name=remove>
    	<input type=hidden name=show>
    	<input type=hidden name=admin_login value=$admin_login_compare>";   // to enter one more time to login.php
    	print "<input type=hidden name=admin_password value=$admin_password_compare>"; // if ($admin_password!=$admin_password_compare) etc....
    	print "<input type=submit value=\"Remove User\" class=button1></form>";
    
    //reload this page
    	print "<form action=$PHP_SELF method=post>
    	<input type=hidden name=show>
    	<input type=hidden name=admin_login value=$admin_login_compare>";   // to enter one more time to login.php
    	print "<input type=hidden name=admin_password value=$admin_password_compare>"; // if ($admin_password!=$admin_password_compare) etc....
    	print "<input type=hidden name=reloadme ><input type=submit value=Reload  class=button1></form>";
    
    
    	print "Counter: $file_contents users
    	</td>";
    
    
    	print "<td>
    	<table border=1 cellspacing=0 cellpadding=4 bordercolor=#007898><tr><td>ID</td><td>Login</td><td>Password</td><td>Email</td><td>Last visit (Y/M/D)</td></tr></tr>";
        while($row=mysql_fetch_object($result1)):	
            print "<tr>";
    	print "<td>$row->id</td>";
    	print "<td><a href=\"javascript:showuserdata('$row->login','$row->address','$row->fax','$row->tel','$row->site')\" title=\"Show about $row->login\">$row->login</td>";
    	print "<td>$row->password </td>";
    	print "<td><a href=\"mailto:$row->email\" title=\"Email to $row->login\">$row->email</td>";
    	print "<td>$row->last_date</td>";
    	print "</tr>";
    	endwhile;
    	print "</table></td></tr></table>";
    	print "	</table>";  //end of external table
    	print "<br>&nbsp; Click user name to view data about him";
    
    	exit;
    
    ?>

    ITdocer, 23 Октября 2011

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

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    Электронная почта (e-mail) - если указано, то проверяем корректность
    
    p_email = document.myform.email.value.toString();
    if (p_email != "") {
    t = p_email.indexOf("@");
    if((p_email.indexOf(".") == -1) || (t == -1) || (t < 1) || (t > p_email.length - 5) || (p_email.charAt(t - 1) == '.') || (p_email.charAt(t + 1) == '.')) {
    alert("Некорректно указан E-mail !");
    document.myform.email.focus();
    return false;
    }
    }

    http://www.whatis.ru/razn/razn14.shtml

    denis90, 22 Октября 2011

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

    +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
    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
    $searchCondition1 = ''; 
     $searchCondition2 = ''; 
     $searchCondition3 = ''; 
     $flag = false; 
     $sql = 'SELECT f.flight_id,
                   (SELECT city
                    FROM airports
                    WHERE airport_id = f.from) as _from,
                   (SELECT city
                    FROM airports
                    WHERE airport_id = f.to) as _to,
                    f.flight_date as fdate,
                    f.flight_time,
                    f.distance,
                    p.plain_name as plain
            FROM flight f JOIN planes p
                ON f.plain_id = p.plain_id
            WHERE '; 
     $fields = 0; 
     if($_POST['txtSearch']){ 
         if($_POST['txtFrom'] != ''){ 
             $searchCondition1 = " city = '".$_POST['txtFrom']."'"; 
             $flag = true; // set flag to TRUE
             $fields++; 
         }
         if($_POST['txtTo'] != ''){ // if To field is not empty
             $searchCondition2 = " city = '".$_POST['txtTo']."'"; 
             $flag = true;  // set flag to TRUE
             $fields++; 
         }
         if ($_POST['txtDate'] != ''){ // if Date field is not empty
             $searchCondition3 = " DATE(f.flight_date) = '".$_POST['txtDate']."'";
             $fields++; // and inc 
         }
         if($fields == 0){                             
             echo "<br/><div style=\"color:red\">Please, enter at least one filed to search</div>"; 
         }else{ 
             if($searchCondition1 != '' && $searchCondition2 == ''){ 
             $sql .= " f.from IN (SELECT airport_id
                                        FROM airports
                                        WHERE ".$searchCondition1.")"; 
             }
             if($searchCondition1 == '' && $searchCondition2 != ''){ 
                 $sql .= " f.to IN (SELECT airport_id
                                            FROM airports
                                            WHERE ".$searchCondition2.")"; 
             }                                                              
             if($searchCondition1 != '' && $searchCondition2 != ''){ 
                 $sql .= " f.from IN (SELECT airport_id
                                            FROM airports
                                            WHERE ".$searchCondition1.")
                                 AND f.to IN (SELECT airport_id
                                            FROM airports
                                            WHERE ".$searchCondition2.")"; 
             }
             if($searchCondition3 != ''){ 
                 if($flag){ 
                     $sql .= " AND ".$searchCondition3; 
                 }else{
                     $sql .= $searchCondition3; 
                 }
    
             }
             include_once('database.php'); 
             $db = createPDO();
             $result = $db->query($sql);
             echo '<table>
                  <tr>
                    <th>
                        From
                    </th>
                    <th>
                        To
                    </th>
                    <th>
                        Flight Date
                    </th>
                    <th>
                        Flight Time
                    </th>
                    <th>
                        Distance
                    </th>
                    <th>
                        Plane
                    </th>
                    <th>
                        Action
                    </th>
                </tr>'; // create an HTML table with headers
             while($row = $result->fetch()){...}

    Ищем в табличке в зависимости от заполненных полей в форме

    denis90, 22 Октября 2011

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

    +164

    1. 1
    2. 2
    var exists = eval(model.get('posting').exists);
    if ( typeof(exists) == "undefined" ) exists = true;

    ужос

    marg, 19 Октября 2011

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

    +166

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    $my_query = new WP_Query(array("post_status" => "publish",
                                   "post_type" => "portfolio",
                                   "post_parent" => $post->ID,
                                   "orderby" => "date",
                                   "posts_per_page" => 1));
    
    /*
     * Пиздец конечно, но это видимо самое гениальное, что я мог придумать
     * в 3 часа ночи
     */
    header("Location: ".get_permalink($my_query->posts[0]->ID));

    WordPress.

    varg242, 18 Октября 2011

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

    +162

    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
    /*
      Нужно получить параметры arrFilter_ff[SECTION_ID] и/или arrFilter_pf[VO_MANUF]
      и отправить форму ПУСТЫМ get-запросом на значение /search/arrFilter_ff[SECTION_ID]/arrFilter_pf[VO_MANUF]/
      Если заполнены все (или не только arrFilter_ff/arrFilter_pf) - просто тупо по-обычному отправлять форму
    */
    
    function send_form()
    {
        var section_id, vo_manuf, ff_name, cf_left, cf_right, fully;
        section_id = $('form[name=arrFilter_form] select[name=arrFilter_ff[SECTION_ID]]').val();
        vo_manuf = $('form[name=arrFilter_form] select[name=arrFilter_pf[VO_MANUF]]').val();
        
        ff_name = $('form[name=arrFilter_form] input[name=arrFilter_ff[NAME]]').val();
        cf_left = $('form[name=arrFilter_form] input[name=arrFilter_cf[1][LEFT]]').val();
        cf_right = $('form[name=arrFilter_form] input[name=arrFilter_cf[1][RIGHT]]').val();
        
        if(cf_left == undefined) cf_left = "";
        if(cf_right == undefined) cf_right = "";
        
        fully = ff_name+cf_left+cf_right;
          
        if(fully != "")
        {
    	$('form[name=arrFilter_form]').submit();
        }
        else
        {    
        if(section_id != 0 && vo_manuf == "") window.location.href = "/search/"+section_id+"/";
        if(section_id == 0 && vo_manuf != "") window.location.href = "/search/0/"+vo_manuf+"/";
        if(section_id != 0 && vo_manuf != "") window.location.href = "/search/"+section_id+"/"+vo_manuf+"/";
        }
    }

    Да, вы не ошиблись, всё это ещё как-то завязано с Битриксом.

    varg242, 11 Октября 2011

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

    +170

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    //...
    include_once("includes/global.php");
    //check_license("license/license.zl");
    db_connection();
    //...

    jokz, 10 Октября 2011

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

    +146

    1. 1
    2. 2
    3. 3
    int *inter = (int[]){1, 8}; 
      /*...*/ 
      inter = (int[]){8, 9};

    RS-232, 08 Октября 2011

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