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

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

    +142

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Zend_Validate::is('20120225 21:57:44', 'Date', array('Ymd H:i:s') // return false
    
    Zend_Validate::is('20120225', 'Date', array('Ymd') // return true
    
    Zend_Validate::is('21:57:44', 'Date', array('H:i:s') // return true

    Как сделать, что бы первая строка возвращала true?

    Slackline, 25 Февраля 2012

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

    +157

    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
    <?php
    function getRusMonth($month)
    {
      if($month > 12 || $month < 1) return FALSE;
      $aMonth = array('январь',
    		  'февраль',
    		  'март',
    		  'апрель',
    		  'май',
    		  'июнь',
    		  'июль',
    		  'август',
    		  'сентябрь',
    		  'октябрь',
    		  'ноябрь',
    		  'декабрь');
      return $aMonth[$month - 1];
    }
    
    function gen_months_list()
    {
    	global $monthnum;
    	$year = date("Y");
    	
    	for($month = 1; $month <= 12; $month++)
    	{
    		if($month <= 9)
    		{
    			if("0".$month == $monthnum) $mn_active = " class=\"active\"";
    			$month_list .= "<li><a href=\"/".$year."/0".$month."/\"".$mn_active.">".getRusMonth($month)."</a></li>\n";
    		}
    		else
    		{
    			if($month == $monthnum) $mn_active = " class=\"active\"";
    			$month_list .= "<li><a href=\"/".$year."/".$month."/\"".$mn_active.">".getRusMonth($month)."</a></li>\n";
    		}
    		$mn_active = "";
    	}
    	
    	return $month_list;
    }
    ?>

    V 2.0

    varg242, 25 Февраля 2012

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

    +155

    1. 1
    2. 2
    3. 3
    $pathToAction = str_replace("\\", "/", $pathToAction);
    while (substr($pathToAction, strlen($pathToAction) - 1, 1) == "/")
        $pathToAction = substr($pathToAction, 0, strlen($pathToAction) - 1);

    nikita2206, 24 Февраля 2012

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

    +172

    1. 1
    2. 2
    if ( is_int(intval($_GET['y'])) ) {
      //...

    Lowezar, 22 Февраля 2012

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

    +168

    1. 1
    2. 2
    3. 3
    $isHttp = $_tumbpath[0] == 'h' && $_tumbpath[1] == 't' && $_tumbpath[2] == 't' && $_tumbpath[3] == 'p';
    
    if ($isHttp){...}

    хорошо еще, что слово - http :)

    unVooDoo, 22 Февраля 2012

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

    +160

    1. 1
    2. 2
    $v2 = str_replace('\"', '"', $v2);
    $v2 = str_replace("\'", "'", $v2);

    no comments

    englandpost, 22 Февраля 2012

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

    −178

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    cursor.execute(bla)
    count = cursor.fetchone()
    
    if count[0] > 0 or True:
        cursor.execute(bla)

    ragzovkii, 21 Февраля 2012

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

    +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
    function get($sel, $od='', $show_error=1)
    {
      global $__DB_CONN;
      $select=$sel;
      //echo $select.'<br>';
      if($od=="")
      {
        $res=sql_execute($select, $show_error);
        if(!$res)
          return array();
        $mc_runtime=get_magic_quotes_runtime();
        set_magic_quotes_runtime(0);
        $mas=array();
        while($v=@mysql_fetch_assoc($res))
          array_push($mas, $v);
        set_magic_quotes_runtime($mc_runtime);
        return $mas;
      }
    ... //тоже самое еще пару раз
      if($od=="by id")
      {
        $res=sql_execute($select, $show_error);
        if(!$res)
          return array();
        $mc_runtime=get_magic_quotes_runtime();
        set_magic_quotes_runtime(0);
        $mas=array();
        while($v=mysql_fetch_assoc($res))
          $mas[$v["id"]]=$v;
        set_magic_quotes_runtime($mc_runtime);
        return $mas;
      }
      if($od=="ins")
      {
        $res=sql_execute($select, $show_error);
        return mysql_insert_id($__DB_CONN);
      }
      return;
    }
    
    function get2($sel, $od='', $show_error=1)
    {
      global $__DB_CONN2;
      $select=$sel;
      //echo $select.'<br>';
      if($od=="")
      {
        $res=sql_execute2($select, $show_error);
        if(!$res)
          return array();
        $mc_runtime=get_magic_quotes_runtime();
        set_magic_quotes_runtime(0);
        $mas=array();
        while($v=@mysql_fetch_assoc($res)) {
    	foreach($v as $ii=>$vv)
            $v[$ii] = iconv('windows-1251','utf-8' ,$vv);
       array_push($mas,$v);
      }
        set_magic_quotes_runtime($mc_runtime);
        return $mas;
      }
    ... //тоже самое еще пару раз
      if($od=="ins")
      {
        $res=sql_execute2($select, $show_error);
        return mysql_insert_id($__DB_CONN2);
      }
      return;
    }

    Функции для работы с бд!

    uint, 19 Февраля 2012

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

    −118

    1. 1
    my $res_id = $q->param('ordernumber')?$q->param('ordernumber'):$q->param('order_idp')?$q->param('order_idp'):undef

    santa_microbe, 16 Февраля 2012

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

    +148

    1. 1
    2. 2
    3. 3
    4. 4
    /**
    	 * Assign
    	 **/
        function Assign ($mTplArray, $mTrailer = "")

    Зачем этот комментарий, над каждым методов вообще?!
    Будто я не вижу как называется метод класса.

    Zerstoren, 15 Февраля 2012

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