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

    +53

    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
    if(!function_exists('stripos')) { // функция stripos (из ПХП5), клонированная для ПХП4      # использовать
        function stripos_clone($haystack, $needle, $offset=0) {
          $return = strpos(strtoupper($haystack), strtoupper($needle), $offset);
          if ($return === false) {
            return false;
          } else {
            return true;
          }
        }
    } else { // Но если это ПХП5 - используем оригинал!
        function stripos_clone($haystack, $needle, $offset=0) {
          $return = stripos($haystack, $needle, $offset=0);
          if ($return === false) {
            return false;
          } else {
            return true;
          }
        }
    }

    Dveezhok https://github.com/dveezhok/Dveezhok/blob/master/page/functions.php

    inso, 16 Октября 2012

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

    +66

    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
    <?php
    
       //You can even add more Dollar Signs
    
       $Bar = "a";
       $Foo = "Bar";
       $World = "Foo";
       $Hello = "World";
       $a = "Hello";
    
       $a; //Returns Hello
       $$a; //Returns World
       $$$a; //Returns Foo
       $$$$a; //Returns Bar
       $$$$$a; //Returns a
    
       $$$$$$a; //Returns Hello
       $$$$$$$a; //Returns World
    
       //... and so on ...//
    
    ?>

    Из комментов на http://www.php.net/manual/en/language.variables.variable.php

    xaionaro, 12 Октября 2012

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

    +48

    1. 1
    2. 2
    3. 3
    PHP supports eight primitive types - four scalar types, two compound types and finally three special types.
    
    8 == 4+2+3?

    http://www.php.net/manual/en/language.types.intro.php

    defecate-plusplus, 09 Октября 2012

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

    +47

    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
    private function getLastDate($year, $month)
        {
            $next_year = $year;
            $next_month = $month + 1;
            if ($next_month == 13) {
                $next_month = 1;
                $next_year++;
            }
            $next_time = mktime(0, 0, 0, $next_month, 1, intval($next_year));
    
            $lastdate = strtotime('-1 day', $next_time);
            $last_day = date('d', $lastdate);
    
            return $last_day;
        }

    date('t', strtotime("$year-$month-01"));

    nekufa, 09 Октября 2012

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

    +50

    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
    //Зарплата с пересчетом в уях
    $salary = NULL;
    $parse_array[2] = str_replace('от','',$parse_array[2]); //Выпиливаем слово "от", на нем спотыкается прегматч и дергалка ЗП
    $parse_array[2] = str_replace('От','',$parse_array[2]);
    $parse_array[2] = trim($parse_array[2]);
    if (strpos($parse_array[2],"у.е."))
                	{
                    	$salary_currency = "у.е.";
                    } else
                    {
                    $salary_currency = "руб.";
                    }
    $salary = substr($parse_array[2], 0 , strpos($parse_array[2]," "));
    if ($salary_currency!="руб.") {$salary = $salary*$options["ue_value"];}
    //конец выдергивания зарплаты

    Внимание! Все комментарии в коде - реальны...

    SnaIK, 09 Октября 2012

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

    +48

    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
    $sql='SELECT DISTINCT id,title,img,description,adder,added,
    GROUP_CONCAT(DISTINCT cid,"-",caty ) AS caty,
    GROUP_CONCAT(DISTINCT oid,"-",obs,"-",face,"-",rola,"-",typ) AS obs
    FROM film
    LEFT JOIN f_c ON f_c.f_id = film.id
    LEFT JOIN cat ON f_c.c_id = cat.cid
    
    LEFT JOIN f_o ON f_o.f_id = film.id
    LEFT JOIN obs ON f_o.o_id = obs.oid
    
    WHERE film.id ='.$fid;
    
    $wynik=mysql_fetch_assoc(mysql_query($sql));
    if(isset($wynik['id'])){
    $array  = explode(',', $wynik['obs']);
    
    $r=array();//director - 0
    $s=array();//Screenwriter - 1
    $ak=array();//actors - 2
    $akn=array();//actors 2 plan - 3
    $np=array();//From Idea By - 4
    $p=array();//producers - 5
    $m=array();//music - 6
    
    foreach ($array as $item)
    {
        $a = explode('-', $item);
        if( $a[4] == 0 ) {
            $r[] = $a[0].','.$a[1].','.$a[2].','.$a[3];
        }  elseif($a[4] == 1 ) {
            $s[] = $a[0].','.$a[1].','.$a[2].','.$a[3];
        }  elseif($a[4] == 2 ) {
            $ak[] = $a[0].','.$a[1].','.$a[2].','.$a[3];
        }  elseif($a[4] == 3 ) {
            $akn[] = $a[0].','.$a[1].','.$a[2].','.$a[3];
        }  elseif($a[4] == 4 ) {
            $np[] = $a[0].','.$a[1].','.$a[2].','.$a[3];
        }  elseif($a[4] == 5 ) {
            $p[] = $a[0].','.$a[1].','.$a[2].','.$a[3];
        }  elseif($a[4] == 6 ) {
            $m[] = $a[0].','.$a[1].','.$a[2].','.$a[3];
        }
    }
    
    function dzielperson($data){    
        $i = 0;
        $ile=count($data);
        while ($i < $ile) {
            $a  = explode(",", $data[$i]);
            $caty='<a href="/person/'.dolink($a[1]).'-'.$a[0].'" class="link1">'.$a[1].'</a>'.($i==($ile-1) ? '':', ');
            $i++;
        }
        return $caty;
    }
    
    echo '<br>Title: '.$wynik[title];
    echo '<br>Desription: '.$wynik[description];
    echo '<br>directors: '.dzielperson($r);
    echo '<br>screenwriters: '.dzielperson($s);
    echo '<br>actors: '.dzielperson($ak);
    echo '<br>actors 2 plan: '.dzielperson($akn);
    echo '<br>From Idea By '.dzielperson($np);
    echo '<br>Producers: '.dzielperson($p);
    echo '<br>Music: '.dzielperson($m);

    Lowezar, 08 Октября 2012

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

    +51

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function fatal($msg = ''){
      echo 'ERROR';
      if( strlen($msg) > 0 ) echo ': '.$msg;
      echo '<br />'COMPLETE'<br />';
      if($f_opened)@fclose($fh);
     }

    Ещё попалось из серии "потом допилю".
    Что он курил, когда это писал?

    virtual_cia, 08 Октября 2012

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

    +55

    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
    function GetNumberOfLinks ($cat){ 
      $queue[] = intval($cat);
      $query = "select count(*) from #__jxlspp_prices  where ( 0!=0";
       while (list($key, $cat) = each($queue)) {
         $query .= " or catid = $cat";
       }
     $query = $query . " ) and published=1";
    	$database->setQuery($query);//это от Джумлы
      $result = $database->query();//и это от Джумлы
    	$val = mysql_fetch_row($result);//а это с бодуна
      return $val[0];
    
    }

    Сижу, скучаю, ковыряю очередной говносайт и, вдруг!
    Аж от души отлегло.

    virtual_cia, 07 Октября 2012

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

    +52

    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
    foreach ($sxe->categories->category as $category) {
    			$cid = $category['id'];
    			if ($clear == 0) {
    				$query = "SELECT `id` FROM `" . PREF . "category` WHERE `id`='" . $cid . "' LIMIT 1;";
    				$result = mysql_query($query);
    				if (mysql_num_rows($result) == 0) {
    					$parent = $category['parentId'];
    					$name = quote_smart($category);
    					$query = "INSERT IGNORE INTO `" . PREF . "category` VALUES('$cid','$parent','$name','1', 0);";
    					mysql_query($query);
    				}
    			} else {
    				$parent = $category['parentId'];
    				$name = quote_smart($category);
    				$query = "INSERT IGNORE INTO `" . PREF . "category` VALUES('$cid','$parent','$name','1');";
    				mysql_query($query);
    			}
    			$cat_i++;
    		}

    uadeveloper, 05 Октября 2012

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

    +122

    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
    class xxxxxxxxxx
    {
    	
    	private $string_services;
    	
    	public  function init() {
    		$this->string_services  = '<script type="text/javascript" src="//yandex.st/share/share.js" charset="utf-8"></script>
    		<div class="yashare-auto-init" data-yashareL10n="ru" data-yashareType="none" data-yashareQuickServices="yaru,vkontakte,facebook,twitter,odnoklassniki,moimir,lj,friendfeed,moikrug,gplus"></div> ';
    	}
    	
    	public function run() {
    		if(empty($this->string_services))
    		{
    			$this->init();
    		}
    		echo $this->string_services;
    	}
    }

    В нашел в проекте над которым работаю.

    Vasiliy, 05 Октября 2012

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