1. PHP / Говнокод #7606

    +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
    // mysql_affected_rows порядка 200 записей
    while ($row_ex=mysql_fetch_array($res_ex)){
       $e_arr[trim(strtoupper($row_ex[0]))] = $row_ex[1];
        $exc .= "(".preg_replace("/(\*|\+|\(|\))/","\\\\$0",$row_ex[0])."(\ |\,|\<|\n|\.)+)|";
    }
    
    if ($exc){
        preg_match_all("/(".$exc.")(?!<\/a>)/i",$Tour['info'],$maches);
         $mach=array_unique($maches[0]);
         unset($maches);
         foreach ($mach as $e_name){
           $last_c=substr($e_name,-1);
           if ($last_c=="<" || $last_c=="," || $last_c==".") $e_name = substr($e_name,0,-1);
           if ($e_name[trim(strtoupper($e_name))])
           $Tour['info'] = preg_replace("/$e_name(?!.?<\/a>)/","<a href='".$e_arr[trim(strtoupper($e_name))]."\.html'>".$e_name."<\/a>",$Tour['info']);
         }
    
        preg_match_all("/(".$exc.")(?!<\/a>)/i",$Tour['info1'],$maches);
         $mach=array_unique($maches[0]);
         unset($maches);
         foreach ($mach as $e_name){
           $last_c=substr($e_name,-1);
           if ($last_c=="<" || $last_c=="," || $last_c==".") $e_name = substr($e_name,0,-1);
    $e_arr[trim(strtoupper($e_name))]."\.html'>".$e_name."<\/a>",$Tour['info1']);
         }
    
        preg_match_all("/(".$exc.")(?!<\/a>)/i",$Tour['info2'],$maches);
         $mach=array_unique($maches[0]);
         unset($maches);
         foreach ($mach as $e_name){
           $last_c=substr($e_name,-1);
           if ($last_c=="<" || $last_c=="," || $last_c==".") $e_name = substr($e_name,0,-1);
    $e_arr[trim(strtoupper($e_name))]."\.html'>".$e_name."<\/a>",$Tour['info2']);
         }
    
        preg_match_all("/(".$exc.")(?!<\/a>)/i",$Tour['shedulle'],$maches);
         $mach=array_unique($maches[0]);
         unset($maches);
         foreach ($mach as $e_name){
           $last_c=substr($e_name,-1);
           if ($last_c=="<" || $last_c=="," || $last_c==".") $e_name = substr($e_name,0,-1);
         }
    
      }

    http://govnokod.ru/7602 "Регулярки? Да, слышал!"
    Итого + 8-10 секунд на исполнение.

    govnoacc, 21 Августа 2011

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function grabb($str, $start, $end) {
            $start = strpos($str, $start) + strlen($start);
            $end = strpos($str, $end, $start);
            $result = substr($str, $start, $end - $start);
            flush();
    return $result;
    }

    Человек, писавший это явно хоть раз произносил фразу "Регулярки ? Нет, не слышал."

    Marker689, 21 Августа 2011

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

    +155

    1. 1
    2. 2
    $hour = date('H'); if ($hour>23){$hour=$hour-24;$day++;}
    echo "".$hour.":"."$minute."";

    Без комментариев...

    Marker689, 20 Августа 2011

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

    +146

    1. 1
    $now = strtotime(date('Y-m-d'));

    Ну нахрена!?

    Веб-Система "Социальная сеть" версия 4.0
    /engine/modules/content/afisha/afisha.php on line 41

    XyHb, 20 Августа 2011

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

    +149

    1. 1
    INSERT INTO `wp_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES (NULL, '0', '2011-08-19 00:00:00', '2011-08-19 00:00:00', '$content', '$title', '', 'publish', 'open', 'open', '', '$cpu', '', '', '2011-08-19 00:00:00', '2011-08-19 00:00:00', '', '0', '$cpu_num', '0', 'post', '', '0');

    maeln0r, 19 Августа 2011

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $used_vars = Array ("s_user","s_roles","s_error");
    
    	for ($i = 0; $i < sizeof($used_vars); $i++) {
    		eval ("unset(\$".$used_vars[$i].");");
    	}

    humbug, 19 Августа 2011

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

    +152

    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
    public function getObject()
    	{
    		$args = func_get_args();
    		if (empty($args)) {
    			$this->_throwException('wrong call of method - interface should be as 1st parameter');
    		}
    
    		$interface = array_shift($args);
    		
    		$class = $this->getInjection($interface);
    
            $argsCnt = count($args);
            if ($argsCnt == 0) {
                $object = new $class;
            }
            else if ($argsCnt == 1) {
                $object = new $class($args[0]);
            }
            else if ($argsCnt == 2) {
                $object = new $class($args[0], $args[1]);
            }
            else if ($argsCnt == 3) {
                $object = new $class($args[0], $args[1], $args[2]);
            }
            else if ($argsCnt == 4) {
                $object = new $class($args[0], $args[1], $args[2], $args[3]);
            }
            else if ($argsCnt == 5) {
                $object = new $class($args[0], $args[1], $args[2], $args[3], $args[4]);
            }
            else if ($argsCnt == 6) {
                $object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]);
            }
            else if ($argsCnt == 7) {
                $object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6]);
            }
            else if ($argsCnt == 8) {
                $object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7]);
            }
            else if ($argsCnt == 9) {
                $object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8]);
            }
            else if ($argsCnt == 10) {
                $object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9]);
            }
            else if ($argsCnt == 11) {
                $object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10]);
            }
            else if ($argsCnt == 12) {
                $object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10], $args[11]);
            }
            else if ($argsCnt == 13) {
                $object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10], $args[11], $args[12]);
            }
            else if ($argsCnt == 14) {
                $object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10], $args[11], $args[12], $args[13]);
            }
            else if ($argsCnt == 15) {
                $object = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10], $args[11], $args[12], $args[13], $args[14]);
            }
            else {
        	   $this->_throwException('it looks like you use more than 15 arguments when trying to instantiate an object of class '.$class.' - that\'s ugly');
            }
    
            return $object;
    	}

    webeith, 18 Августа 2011

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

    +169

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php
    
     $xml = simplexml_load_string($xmlstring);
    $json = json_encode($xml);
    $array = json_decode($json,TRUE);
    
    ?>

    "Three line xml2array"
    http://www.php.net/manual/en/book.simplexml.php#105330

    striker, 18 Августа 2011

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

    +173

    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
    $translation = array(
    
    	"äï" => "am",
    
    	"ïï" => "pm",
    
    	"ÄÏ" => "AM",
    
    	"ÏÏ" => "PM",
    
    	"Ïîíåäåëüíèê" => "Monday",
    
    	"ïíä" => "Mon",
    
    	"Âòîðíèê" => "Tuesday",
    
    	"âòð" => "Tue",
    
    	"Ñðåäà" => "Wednesday",
    
    	"ñðä" => "Wed",
    
    	"×åòâåðã" => "Thursday",
    
    	"÷òâ" => "Thu",
    
    	"Ïÿòíèöà" => "Friday",
    
    	"ïòí" => "Fri",
    
    	"Ñóááîòà" => "Saturday",
    
    	"ñáò" => "Sat",
    
    	"Âîñêðåñåíüå" => "Sunday",
    
    	"âñê" => "Sun",
    
    	"ÿíâàðü" => "January",
    
    	"ÿíâ" => "Jan",
    
    	"ôåâðàëü" => "February",
    
    	"ôåâ" => "Feb",
    
    	"ìàðò" => "March",
    
    	"ìàðò" => "Mar",
    
    	"àïðåëü" => "April",
    
    	"àïð" => "Apr",
    
    	"ìàÿ" => "May",
    
    	"Ìàé" => "May",
    
    	"èþíü" => "June",
    
    	"èþí" => "Jun",
    
    	"èþëü" => "July",
    
    	"èþë" => "Jul",
    
    	"àâãóñò" => "August",
    
    	"àâã" => "Aug",
    
    	"ñåíòÿáðü" => "September",
    
    	"ñåí" => "Sep",
    
    	"îêòÿáðü" => "October",
    
    	"Oct" => "îêò",
    
    	"íîÿáðü" => "November",
    
    	"íîÿ" => "Nov",
    
    	"äåêàáðü" => "December",
    
    	"äåê" => "Dec",
    
    	"st" => "îå",
    
    	"nd" => "îå",
    
    	"rd" => "å",
    
    	"th" => "îå");

    Допиливал проект одного идиота...
    Решение проблем с кодировкой в лоб.

    hash, 17 Августа 2011

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $username = $vbulletin->userinfo['username'];
    .
    .
    .
    .
    .
    .
    $nickname = $username;
    $nickname = mysql_real_escape_string($nickname);

    PHP, булка, Эстонский код.

    swat54, 17 Августа 2011

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