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

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

    −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
    15. 15
    16. 16
    17. 17
    18. 18
    Private Sub btnNew_Click()
        Dim i As Integer
        Dim asCopy() As clsCitizen
        ReDim asCopy(LBound(modCitizen.asDB) To UBound(modCitizen.asDB)) As clsCitizen
        For i = LBound(modCitizen.asDB) To UBound(modCitizen.asDB)
            Set asCopy(i) = modCitizen.asDB(i)
        Next i
        ReDim modCitizen.asDB(UBound(modCitizen.asDB) + 1) As clsCitizen
        For i = LBound(asCopy) To UBound(asCopy)
            Set modCitizen.asDB(i) = asCopy(i)
        Next i
        Set modCitizen.asDB(UBound(modCitizen.asDB)) = New clsCitizen
        modCitizen.asDB(UBound(modCitizen.asDB)).bNew = True
        iRecNum = UBound(modCitizen.asDB)
        RecordRead
        UpdateControls
        LockMe True
    End Sub

    вот через какое место мучительно вспоминал давно забытый, старый добрый VB6

    процедура дополняет массив новым элементом

    Lure Of Chaos, 10 Января 2011

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

    +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
    $query = mysql_query("SELECT * FROM `accounts` WHERE `login` = '".@$_COOKIE['sc2tACC']."' LIMIT 1");
    if ($query and @isset($_COOKIE['sc2tACC']) AND mysql_num_rows($query)) {
    	$auth = mysql_fetch_array($query);
    	if($auth['password'] == $_COOKIE['sc2tPASS'] and @isset($_COOKIE['sc2tPASS'])) {
    		$AS = "OK";
    		if($_SERVER['PHP_SELF'] != "/chat.php" and $auth['status'] != 1) {
    			mysql_query("UPDATE `accounts` SET `timestamp` = '".microtime(1)."', `ip` = '".$_SERVER['REMOTE_ADDR']."', `lastpage` = '".$_SERVER['REQUEST_URI']."'  WHERE `id` = '".$auth['id']."' LIMIT 1;");
    		}
    	} else {
    		$loginError = "Неверный пароль";
    	}
    } else {
    	$loginError = "Неверный логин";
    }

    ne0n, 09 Января 2011

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

    +145

    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
    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>QRSelector</class>
     <widget class="QWidget" name="QRSelector">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>400</width>
        <height>300</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>QRSelector</string>
      </property>
      <widget class="QLabel" name="label">
       <property name="geometry">
        <rect>
         <x>10</x>
         <y>10</y>
         <width>371</width>
         <height>16</height>
        </rect>
       </property>
       <property name="text">
        <string/>
       </property>
      </widget>
     </widget>
     <layoutdefault spacing="6" margin="11"/>
     <resources/>
     <connections/>
    </ui>

    qrselector.ui

    Resager, 06 Января 2011

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

    +100

    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
    dats:=datetostr(DateTimePicker1.Date);
    datp:=datetostr(DateTimePicker2.Date);
    datsc:=copy(dats,1,2);
    datsm:=copy(dats,4,2);
    datsg:=copy(dats,7,4);
    datpc:=copy(datp,1,2);
    datpm:=copy(datp,4,2);
    datpg:=copy(datp,7,4);
    idatsc:=strtoint(datsc);
    idatsm:=strtoint(datsm);
    idatsg:=strtoint(datsg);
    idatpc:=strtoint(datpc);
    idatpm:=strtoint(datpm);
    idatpg:=strtoint(datpg);
    tdatc:=strtoint(copy(p[i,6],1,2));
    tdatm:=strtoint(copy(p[i,6],4,2));
    tdatg:=strtoint(copy(p[i,6],7,4)); 
    if not ((idatsg>tdatg) or ((idatsg=tdatg) and (idatsm>tdatm)) or ((idatsc>tdatc) and (idatsm>=tdatm)) or (idatpg<tdatg) or ((idatpg=tdatg) and (idatpm<tdatm)) or ((idatpc<tdatc) and (idatpm<=tdatm))) then

    Проверка или дата с массива включена в диапазон дат с DateTimePicker'ов (еще и с ошибкой в условии)
    И вся эта фигня в цикле... Как это увидел, валерьянкой отпаивали меня долго

    Nikitiy_II, 04 Января 2011

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

    +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
    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
    /** Связанный JavaScript **/
    /*	
    	var script = new Array();
    	var s = 0;
    	
    
    
    	linked = e.match(/<script type=("|')text\/javascript("|') src=("|').*?("|')><\/script>/gi);
    	
    	if (linked != null)
    	{
    		src_link = new Array();
    		j = 0;
    		
    		for (i = 0; i < linked.length; i++)
    		{
    			e = e.replace(linked[i], '');
    			
    			new_link = linked[i].match(/src=("|').*?("|')>/gi);
    			
    			if (new_link != null)
    			{
    				script[s] = document.createElement('script');
    				script[s].setAttribute('type', 'text/javascript');		
    				script[s].id = 'JavaScript_' + hist.length + '_' + j;
    		
    				script[s].setAttribute('src', new_link[0].substr(5, (new_link[0].length - (5 + 2))));
    				
    				s++; j++;
    			}	
    		}
    	}
    	*/
    	/** Внедрённый JavaScript **/
    /*
    	e = e.replace(/[\r\n]/g, ' ');
    	intruded = e.match(/<script type=("|')text\/javascript("|')>.*?<\/script>/gi);
    		
    	if (intruded != null)
    	{			
    		for (i = 0; i < intruded.length; i++)
    		{
    			inner = '';
    		
    			e = e.replace(intruded[i], '');
    			inner = intruded[i].replace(/<script type=("|')text\/javascript("|')>/, '').replace(/<\/script>/, '');
    			
    			if (navigator.appName == 'Microsoft Internet Explorer')
    			{
    				script[s] = inner;
    			}
    			else
    			{
    				script[s] = document.createElement('script');
    				script[s].setAttribute('type', 'text/javascript');
    				script[s].id = 'JavaScript_' + hist.length + '_' + i;
    			
    				script[s].innerHTML = inner;
    			}
    			
    			s++;
    		}
    	}
    	*/

    А вставить в элемент и найти через getElementsByTagName("script") слишком просто :D

    Genka, 28 Декабря 2010

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

    +159

    1. 1
    2. 2
    3. 3
    function is_int_string ($str) {
    	return ((string)(int)($str) == $str);
    }

    Уже даже не помню зачем оно было нужно.

    byss, 27 Декабря 2010

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

    +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
    function bonus($host, $uri, $go_form)
    {
        if (is_array($go_form)) {
            $body = "";
            foreach ($go_form as $name => $value) {
                $body .= $go_form[] = $name . '=' . urlencode($value) . "&";
            }
        }
        
        $length = strlen($body);
        
        $socket = fsockopen($host, 80);
        fwrite($socket, "POST {$uri} HTTP/1.0\r\n");
        fwrite($socket, "Host: {$host}\r\n");
        fwrite($socket, "User-Agent: Mozilla/4.0\r\n");
        fwrite($socket, "Content-Type: application/x-www-form-urlencoded\r\n");
        fwrite($socket, "Content-Length: $length\r\n\r\n");
        fwrite($socket, "$body\r\n");
        $fgets = '';
        while (!feof($socket)) {
            $fgets .= fread($socket, 4096);
        }
        
        //print_r($fgets);
        //echo '<br><br>$fgets<br><br>';
        
        fclose($socket);
    }
    
    bonus("balans.kz","/bonus/",$go_form = Array( 'pursedest' => 'Rxxxxxxxxx',));

    Unknown, 27 Декабря 2010

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

    +164

    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
    for($i = 0; $i < $fs_num; $i++)
    {
       for($j = 0; $j < $sps_num; $j++)
       {
          if($sps[$j][3] > 0 && $sps[$j][8] == $fc[$i][0])
          {
             for($k = 0; $k < $max_k; $k++)
             {
                for($l = 0; $l < $max_g; $l++)
                {
                   if($grp[$sps[$j][0]][$k][$l][0] > 0)
                   {
                      $grp[$sps[$j][0]][$k][$l][6]	= ($grp[$sps[$j][0]][$k][$l][2]+$grp[$sps[$j][0]][$k][$l][3]+$grp[$sps[$j][0]][$k][$l][4])* $grp[$sps[$j][0]][$k][$l][0];
                      $sps[$j][6]	+= $grp[$sps[$j][0]][$k][$l][6];
                      $fs[$sps[$j][9]][6]	+=$grp[$sps[$j][0]][$k][$l][6];
                   }
                }
             }
          }
       }
    }

    Из скрипта расчета статистики. Это, наверно, писал какой то гений, свободно оперирующий четерырехмерными массивами, я так и не смог с этим разобраться.

    xandrster, 27 Декабря 2010

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

    +145

    1. 1
    for(rptr=0;rptr<10;rptr++) // пока очередь не опустела

    выборка элементов из FIFO =D

    resettik, 22 Декабря 2010

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

    +82

    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
    /**
     * Delete. * 
     * @param entity the entity 
     * @return true, if successful 
     */ 
    public boolean delete(T entity) {
     	boolean deleted=false; 
    	getSession().delete(entity); 
    	flush(); 
    	//when no hibernate runtime exception has arised...set to true.
    	deleted = true;
    	return deleted;
    }

    Our lovely tech lead has written this

    vovano, 21 Декабря 2010

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