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

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

    +156.3

    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
    final class HelperCurrency {
      
      	public function format($number, $currency = '', $value = '', $format = TRUE) {
    		/*** .... some code .... ***/
        	if ($value) {
          		$value = $value;
        	} else {
          		$value = $this->currencies[$currency]['value'];
        	}
    
        	if ($value) {
          		$value = $number * $value;
        	} else {
          		$value = $number;
        	}
    
    		/*** .... some code .... ***/
    		
    		if ($format) {
    			$decimal_point = $this->language->get('decimal_point');
    		} else {
    			$decimal_point = '.';
    		}
    		
    		if ($format) {
    			$thousand_point = $this->language->get('thousand_point');
    		} else {
    			$thousand_point = '';
    		}
    
    		/*** .... some code .... ***/
      	}
    }

    класика от OpenCart v. 1.3.2

    Under, 27 Октября 2009

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

    +156.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    switch ($result['state']) 
    {
        case 'Oregon':
    	$row->state = 'OR';
        break;
       case $row->state=='Washington':
    	$row->state = 'WA';
       break;
    }

    нашел у своего потрудника, долго не мог понять что второй кейс делает и как это вообще работало

    quard, 09 Апреля 2010

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

    +156.2

    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
    // from views_bonus: grid.inc
    function theme_og_picture_grid($result, $column_count = 5) {
      $content = '<table class="og-picture-grid">';
      $count = 0;
      $total = db_num_rows($result);
      while ($user = db_fetch_object($result)) {
        $classes = 'og-picture-grid-item';
        if ($count < $column_count) {
          $classes .= ' first';
        }
        
        $item = '';
        if ($count % $column_count == 0) { 
          $content .= '<tr>'; 
        }
        $picture = theme('user_picture', $user);
        $name = theme('username', $user);
        $group_role = $user->is_admin ? t('admin') : '&nbsp;';
        $content .= "<td class=\"$classes\">$picture<div class=\"og-name\">$name</div>";
        if ($user->is_admin) {
          $txt = t('admin');
          $content .= "<div class=\"group-role\">$txt</div>"; 
        }
        $content .= "</td>\n";
    
        $count++;
        if ($count % $column_count == 0 || $count == $total) {
          $content .= '</tr>';
        }
      }
      $content .= '</table>';
      
      if ($total) {
        return $content;
      }
    }

    Меня ДУРЬпаловские финты просто бесят.

    типа тема

    paranoid, 14 Сентября 2009

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

    +156.2

    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
    function ChangeDisc(n, size, l_x, l_y, r_x, r_y)//а-а-а-а-а-а убейте меня
    {
        var disc_left = document.getElementById('sDisc1');
        var disc_right = document.getElementById('sDisc2');
        var disc_left_div = document.getElementById('sDisc1_div');
        var disc_right_div = document.getElementById('sDisc2_div');
        switch (size)
        {
            case 13:
                disc_left_div.style.paddingLeft = (l_x+3)+'px';
                disc_left_div.style.paddingTop = (l_y+2)+'px';
                disc_right_div.style.paddingLeft = (r_x+6)+'px';
                disc_right_div.style.paddingTop = (r_y+2)+'px';
                break;
            case 14:
                disc_left_div.style.paddingLeft = (l_x+1)+'px';
                disc_left_div.style.paddingTop = (l_y+1)+'px';
                disc_right_div.style.paddingLeft = (r_x+1)+'px';
                disc_right_div.style.paddingTop = (r_y+1)+'px';
                break;
            case 15:
                disc_left_div.style.paddingLeft = l_x+'px';
                disc_left_div.style.paddingTop = l_y+'px';
                disc_right_div.style.paddingLeft = r_x+'px';
                disc_right_div.style.paddingTop = r_y+'px';
                break;
            case 16:
                disc_left_div.style.paddingLeft = (l_x-2)+'px';
                disc_left_div.style.paddingTop = (l_y-2)+'px';
                disc_right_div.style.paddingLeft = (r_x-2)+'px';
                disc_right_div.style.paddingTop = (r_y-2)+'px';
                break;
            case 17:
                disc_left_div.style.paddingLeft = (l_x-3)+'px';
                disc_left_div.style.paddingTop = (l_y-4)+'px';
                disc_right_div.style.paddingLeft = (r_x-5)+'px';
                disc_right_div.style.paddingTop = (r_y-4)+'px';
                break;
            case 18:
                disc_left_div.style.paddingLeft = (l_x-5)+'px';
                disc_left_div.style.paddingTop = (l_y-5)+'px';
                disc_right_div.style.paddingLeft = (r_x-8)+'px';
                disc_right_div.style.paddingTop = (r_y-6)+'px';
                break;
            case 19:
                disc_left_div.style.paddingLeft = (l_x-8)+'px';
                disc_left_div.style.paddingTop = (l_y-8)+'px';
                disc_right_div.style.paddingLeft = (r_x-8)+'px';
                disc_right_div.style.paddingTop = (r_y-8)+'px';
                break;
            case 20:
                disc_left_div.style.paddingLeft = (l_x-10)+'px';
                disc_left_div.style.paddingTop = (l_y-10)+'px';
                disc_right_div.style.paddingLeft = (r_x-10)+'px';
                disc_right_div.style.paddingTop = (r_y-10)+'px';
                break;
        }
        disc_left.src = Images[n].src;
        disc_right.src = Images[n].src;
        scroll(0,0);
    }

    копипаста процветает... правильно, зачем структурировать код? проще так.

    gorky, 09 Сентября 2009

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

    +156.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if($started==true && !empty($query))
    do { } while ($todo===$berry);
    
    /*
     * if started equals true,
     * and isn't empty query,
     * do nothing while todo
     * really more, than berry
     */

    no comments

    greevex, 03 Сентября 2009

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

    +156.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    class BaseDateTimeField extends SmartField{
    var $years = array("1999"=>"1999","2000"=>"2000","2001"=>"2001","2002"=>"2002","2003"=>"2003","2004"=>"2004","2005"=>"2005","2006"=>"2006","2007"=>"2007","2008"=>"2008","2009"=>"2009","2010"=>"2010");
    var $months = array('01'=>'Jan','02'=>'Feb', '03'=>'Mar', '04'=>'Apr', '05'=>'May', '06'=>'Jun', '07'=>'Jul', '08'=>'Aug','09'=>'Sep', '10'=>'Oct', '11'=>'Nov', '12'=>'Dec');
    var $days = array('01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06','07'=>'07','08'=>'08','09'=>'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');
    var $hours = array('00'=>'00','01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06','07'=>'07','08'=>'08','09'=>'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');
    var $minutes = array('00'=>'00','01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06','07'=>'07','08'=>'08','09'=>'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');
    var $secundes = array('00'=>'00','01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06','07'=>'07','08'=>'08','09'=>'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');
    
    }

    Самописная CMS для веб-сайта

    nikl, 18 Января 2010

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

    +156.1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    <wddxPacket>
    	<data>
    		<recordset>
    		<?php foreach($array_xml_string as $xml)  { ?>
    			<field name='<?php print ($xml['name']); ?>'>
    				<?php while ($data = $xml['name']['string']) ?>
    					<string><?php print ($data['name']['string']); ?></string>
    				<?php ?>
    		<?php }?>
    		</recordset>
    	</data>
    </wddxPacket>

    Человек долго не мог понять что он делает не так

    Darth_Ashesss, 06 Ноября 2009

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

    +156.1

    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
    function CompletesGetTableOld($clist, $mid =0)
    {
      if(strlen($clist) or $mid > 0)
      {
        $com = CatalogComplsCostsGet(0, 0, $clist, $mid);
        $csz = sizeof($com['id']);
        if($csz > 0)
        {
            $param = CatalogComplParamsGet();
            $psz = sizeof($param);
            $tds = '';
            
            $cVals = CatalogComplParamValsGet(implode(",", $com['cid']));
            
            echo '
    		<table cellpadding="4" cellspacing="0" border="0" width="700" class="table-comp">
    		 <tr><td width="50%" class="first"></td>
           	';
            for($i = 0; $i < $csz; $i++)
     	    {
     	        echo '<td align="center">'.$com['name'][$i].'</td>';
     	        $tds .= '<td> &nbsp; </td>';
     	    }
            echo '</tr>';
            
            $prgrnm = '';
            for($i = 0; $i < $psz; $i++)
     	    {
     	        $data = false;
     	        $html = '';
     	        if($i==0||$param[$i]['gr_name']!=$prgrnm)
     	        {
    				$html='
    				<tr>
    					<td class="first"><br><b>'.$param[$i]['gr_name'].'</b></td>';for($ii = 0; $ii < $csz; $ii++)$html.='<td class="second" > &nbsp; </td>';
    					$html.= $tds.'
    				</tr>';
     	        }
     	        $html.= '
     	        <tr>
     	          <td class="first">'.$param[$i]['name'].'</td>';
     	        
     	        for($ii = 0; $ii < $csz; $ii++)
         	    {
         	        @$val = $cVals[$com['cid'][$ii]][$param[$i]['id']];
         	        if(isset($val) and strlen($val))
         	        {
         	            if($param[$i]['type'] == 'CH') 
         	            {
         	                if($val == 1)
         	                {
         	                    $html.= '<td class="second" align="center"><img src="/images/tochka.gif" ></td>'; 
         	                    $data = true;
         	                }
         	                else $html.= '<td class="second"> &nbsp; </td>';
         	                
         	            }
         	            else 
         	            {
         	                $html.= '<td class="second" align="center">'.$val.'</td>';
         	                $data = true;
         	            }
         	        }
         	        else $html.= '<td class="second"> &nbsp; </td>';
         	    }
         	    $html.= '</tr>';
         	    
         	    if($data) 
         	    {
         	        $prgrnm = $param[$i]['gr_name'];
         	        echo $html;
         	    }
     	    }
     	    
     	    echo '
     	     <tr><td width="50%" class="first"><b>????</b></td>';
     	    for($i = 0; $i < $csz; $i++)
     	    {
     	    	$cost = intval($com['cost'][$i]);
     	        if($cost > 1000000) $cost = '<nobr>'.substr($cost, 0, -6)." ".substr($cost, 1, -3).". ".substr($cost, 4).'</nobr> ???';
     	        elseif($cost > 100) $cost = '<nobr>'.substr($cost, 0, -3)." ".substr($cost, strlen($cost)-3).'</nobr> ???';
     	        else $cost = '';
         	        
     	        echo '<td class="second" align="center" height="30">'.$cost.'</td>';
     	    }
                   
            echo '</tr>
            </table>';
             
            return true;
        }
      }
       
      return false;
    }

    обратите внимание на переменную $data. долго и упорно собираем из кусочков $html, и только если $data истинно тогда выводим $html (примерно 5-10% случаев)

    gorky, 18 Сентября 2009

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

    +156.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $_REQUEST['trigger']['event_params']['duration'] = $_REQUEST['trigger']['event_params']['duration']['hour']*60*60 + $_REQUEST['trigger']['event_params']['duration']['minute']*60 + $_REQUEST['trigger']['event_params']['duration']['seconds'];
                if (empty($_REQUEST['trigger']['event_params']['frequency_period'])) {
                    $_REQUEST['trigger']['event_params']['frequency_count'] = '';
                }
                if (empty($_REQUEST['trigger']['event_params']['frequency_count'])) {
                    $_REQUEST['trigger']['event_params']['frequency_period'] = '';
                }

    phoenix, 10 Сентября 2009

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

    +156.1

    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
    class I_Mysql
    {
    	var
    	$host="localhost",
    	$user="root",
    	$password="",
    	$database="gorodokbox",
    	$charset="utf8",
    	$connected=false,
    	$db_selected=true,
    	$r_connection=null,
    	$result=null,
    	$row=array(),
    	$field=null,
    	$debug=false;
    
    	function I_Mysql()
    	{
    
    	}
    
    	function connect($host="localhost", $user="roo", $password="", $type=0)
    	{
    		$this->host=$host;
    		$this->user=$user;
    		$this->password=$password;
    		$this->database=$password;
    		if(defined('MYSQLDEBUG'))$this->debug=1;
    		@$this->r_connection = mysql_connect($this->host, $this->user, $this->password);
    		@$er=mysql_errno($this->r_connection);
    		if(!$er)
    		{
    			if($this->debug) echo "mySQL connected<br>";
    			$GLOBALS['CVARS']['DB']['connected']=true;
    			$GLOBALS['CVARS']['DB']['rcon']=$this->r_connection;
    			$this->connected = true;
    			$GLOBALS['CVARS']['DB']['mysql']=&$this;
    			return true;
    		}
    		return false;
    	}
    ..................................................

    Ковырял самописный двиг магазина.

    mac1nt0sh, 03 Сентября 2009

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