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

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

    +150

    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
    function getMd($module){
    	switch($module){
    		case 'dashboard': $md = 0; break;
    		case 'family': $md = 1; break;
    		case 'friends': $md = 2; break;
    		case 'neighbours': $md = 3; break;
    		case 'messages': $md = 4; break;
    		case 'photos': $md = 5; break;
    		case 'trees': $md = 6; break;
    		case 'info': $md = 7; break;
    		default: $md = 0; break;
    	}
    	return $md;
    }

    guest, 07 Апреля 2009

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

    +150

    1. 1
    tmp = (tmp <= a) ? a : tmp;

    Не то чтобы говнокод, но и от ": tmp;" никак не избавится. Да и if писать ломает...)

    -- Aquarius

    guest, 24 Марта 2009

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

    +150

    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
    [Serializable]
        public class Key
        {
            public Key(long id, string code)
            {
                m_Id = id;
                m_Code = code;
            }
    
            public Key(long id) : this(id, null)
            {
            }
    
            public Key(string code) : this(0, code)
            {
            }
    
            public Key() : this(0, null)
            {
            }
    
            public long getId()
            {
                return (m_Id);
            }
    
            public long m_Id;
    
            public string getCode()
            {
                return (m_Code);
            }
    
            public string m_Code;
    
            public static string ToString(Key k)
            {
                return ((k == null) ? "(null)" : k.ToString());
            }
        }

    guest, 18 Марта 2009

    Комментарии (5)
  5. C# / Говнокод #734

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public const char ExpMonthSeparator = ':';
    
    
    protected void BindPager()
    {
       var colon = string.Format("{0}", ExpMonthSeparator);
       /* And some lines for refactor */
    }

    Фикся очередную багу наткнулся на такую прелесть

    guest, 18 Марта 2009

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

    +150

    1. 1
    2. 2
    3. 3
    if (is_null($a)) return 'null';
    if ($a === false) return 'false';
    if ($a === true) return 'true';

    Не делайте так. Есть is_bool(), is_null(), or в конце концов.

    guest, 02 Марта 2009

    Комментарии (1)
  7. Pascal / Говнокод #573

    +150

    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
    VAR FL:TEXTFILE;
        l:string;
        i:integer;
        xmass,itrmass:array [1..100] of real;
    begin
    {...}
     ASSIGNfile(FL,'results.txt');
       reset(fl);
       readln(fl,l);
       i:=1;
        while L[i]<>' ' do begin
         xmass[i]:=strtoint(L[1]);
         i:=i+1;
                           end;
    {...}
    end;

    В файле хранилась последовательность вещественных чисел... Такой вот вариант ее оттуда выкорчевать о_О

    guest, 19 Февраля 2009

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

    +150

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    {? if (!isset($edit_style)) ?}
    <form action="disp.php?action=style_add" method="post">
    {? else ?}
    <form action="disp.php?action=style_edit" method="post">
    <input type="hidden" name="id" value="{? $edit_style.id ?}">
    {? /if ?}
    ...
    ...
    <td><input type="submit" value="{? if (isset($edit_style)) ?}Save{? else ?}Add{? /if ?}"></td>
      Ю

    guest, 29 Января 2009

    Комментарии (2)
  9. Pascal / Говнокод #2789

    +149.9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    program TheEnd2;
    uses Windows;
    begin
    repeat
    WinExec('TheEnd2.exe',SW_HIDE);
    until false;
    end.

    Добрая программа!

    Говногость, 13 Марта 2010

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

    +149.9

    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
    <?
    global $db;
    $db=new db(HOST,USER,PASS,DBNAME); //подключение к бд
    class db{
    	public $SumQuerys=false; //Temp Var
    	public $Vtime; //Temp time summ
    	public $td; //Temp date
    	public $db_id= false;
    	public $query_num=0;
    	public $query_id=NULL;
    	public $mysql_error=FALSE; 
    	public $mysql_error_num=NULL;
    	public $last_query=NULL;
    	var $error=0;
    	function __construct($host='',$user='',$pas='',$bd=''){
    		$this->db_id=mysql_connect($host,$user,$pas) or die('db connect error');
    		mysql_select_db($bd,$this->db_id) or die("db: '$bd' select error");
    		mysql_query('SET NAMES utf8');
    	}
    	function __destruct(){
    		$this->close();
    		if ($this->SumQuerys){
    			#print "<table style='font-size:10px;border-collapse:collapse;border:1px dotted black' border=1>".$this->SumQuerys."<tr><td><b>$this->Vtime</b></td><td></td></table>";
    		}
    	}
    	function query($query, $show_error=true){
    		$time = microtime(true);
    		$this->last_query = $query;
    		if(!($this->query_id = mysql_query($query, $this->db_id))){
    			$this->error=1;
    			$this->mysql_error = mysql_error();
    			$this->mysql_error_num=mysql_errno();
    			if($show_error){
    				$this->display_error($this->mysql_error, $this->mysql_error_num, $query);
    			}
    		} else {$this->error=0;}
    		$this->query_num ++;
    		
    		// ----------------------------------------------------------------------------
    		$time = round(microtime(true)-$time,5);
    		if($time>0.003){
    			$alert = "color:red";
    		}
    		$this->Vtime += $time;
    		@$this->SumQuerys .= "<tr style='$alert'><td>".$time."</td><td>".$query.'</td></tr>';
    		//------------------------------------------------------------------------------
    		return $this->query_id;
    	}
    	function qrow($query){
    		$this->query($query);
    		return mysql_fetch_row($this->query_id);
    	}
    	function get_row($query_id = ''){
    		if ($query_id == '') $query_id = $this->query_id;
    		return mysql_fetch_assoc($query_id);
    	}
    	function get_array($query_id = ''){
    		if ($query_id == '') $query_id = $this->query_id;
    		return mysql_fetch_array($query_id);
    	}
    	function fetch($query_id = ''){
    		global $d;
    		if ($query_id == '') $query_id = $this->query_id;
    		return $d=@mysql_fetch_object($query_id);
    	}
    	function fetchAll($field = ''){
    		while ($d=$this->fetch($this->query_id)){
    			if ($field == ''){
    				$arr[] = $d;
    			} else {
    				$arr[] = $d->$field;
    			}
    		}
    		return @$arr;
    	}
    	function qAll($query){
    		$this->query($query);
    		return $this->fetchAll();
    	}
    	function fetch_row($query_id = ''){
    		global $d;
    		if ($query_id == '') $query_id = $this->query_id;
    		return $d=@mysql_fetch_row($query_id);
    	}
    	function qfetch($query){
    		global $d;
    		$this->query($query);
    		return $d=@mysql_fetch_object($this->query_id);
    	}
    	function num_rows($query_id = ''){
    		if ($query_id == '') $query_id = $this->query_id;
    		return mysql_num_rows($query_id);
    	}
    	
    	function insert_id() {
    		return mysql_insert_id($this->db_id);
    	}

    интерестный класс для работы с бд=)

    Heckfi, 13 Августа 2009

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

    +149.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    /**
    	 * Convert PHP tags to entities
    	 *
    	 * @access	public
    	 * @param	string
    	 * @return	string
    	 */
    	function encode_php_tags($str)
    	{
    		$_POST[$this->_current_field] = str_replace(array('<?php', '<?PHP', '<?', '?>'),  array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
    	}

    guest, 16 Апреля 2009

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