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

    +148

    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
    <?php
    /**
     * Зиг хайль!
     *
     * @author Adolf Hitler <mein.fü[email protected]>
     * @version 1.0
     *
     * Date: 01.09.1939 14:18
     */
    
    namespace system\api\exception {
    
    	class ziga extends \Exception {
    		public function __construct($message = "Sieg Heil!", $code = 1488, \Exception $previous = NULL) {
    			parent::__construct($message, $code, $previous);
    		}
    	}
    
    }

    Сначала я нашел в проекте кусок кода throw new exception\ziga(); ...

    WinnerWolf, 23 Марта 2012

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    static public function vkontakte_enabled()
    	{
    		return ( ipsRegistry::$settings['vk_enabled'] AND ipsRegistry::$settings['vk_api_id'] AND ipsRegistry::$settings['vk_secret'] ) ? TRUE : FALSE;
    	}

    * IP.Board v3.1.4
    И почему я пишу форумы сам?..

    skryisli, 23 Марта 2012

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

    +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
    function return_report($new,$do) {
     $dosec = $do - $new;
     $days = floor($dosec / 86400);
     $hour = floor(($dosec - ($days*86400))/3600);
     $min = floor(($dosec - ($days*86400) - ($hour*3600))/60);
     $sec = floor(($dosec - ($days*86400) - ($hour*3600) - ($min*60)));
     switch(substr($days, -2)) { // какое выводить слово
     case 1: case 21: $ost = 'остался '; break;
     default: $ost = 'осталось '; break;
     }
     switch(substr($days, -2)) { // вывод дней
     case 1: case 21: case 31: case 41: $d=' день '; break;
     case 2: case 3: case 4: case 22: case 23: case 24: case 32: case 33: case 34: case 42: case 43: case 44: $d=' дня '; break;
     default: $d=' дней '; 
     }
     switch(substr($hour, -2)) { // вывод часов
     case 1: case 21: $h=' час '; break;
     case 2: case 3: case 4: case 22: case 23: case 24: $h=' часа '; break;
     default: $h=' часов '; 
     }
     switch(substr($min, -2)) { // вывод минут
     case 1: case 21: case 31: case 41: case 51: $m=' минута '; break;
     case 2: case 3: case 4: case 22: case 23: case 24: case 32: case 33: case 34: case 42: case 43: case 44: case 52: case 53: case 54: $m=' минуты '; break;
     default:$m=' минут ';
     }
     switch(substr($sec, -2)) { // вывод секунд
     case 1: case 21: case 31: case 41: case 51: $s=' секунда'; break;
     case 2: case 3: case 4: case 22: case 23: case 24: case 32: case 33: case 34: case 42: case 43: case 44: case 52: case 53: case 54: $s=' секунды'; break;
     default:$s=' секунд';
     }
     if ($dosec > 0) {
     $period = $ost;
     if ($days > 0) $period .= '<b>'.$days.'</b>'
    .$d;
     if ($hour > 0) $period .= '<b>'.$hour.'</b>'
    .$h;
     if ($min > 0) $period .= '<b>'.$min.'</b>'.
    $m;
     if ($sec > 0) $period .= '<b>'.$sec.'</b>'.
    $s;
     return $period;
     }
    return false;
    }

    Человек пытался сделать вывод времени, прошедшего с определенного момента *FACEPALM*

    pro100shureg, 22 Марта 2012

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

    +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
    class UserAPI
    {
       function GetUserName($UserId)
       {
          $SqlQuery = mysql_query("SELECT UserName FROM users WHERE id='$UserId'");
          $Response = mysql_fetch_array($SqlQuery);
          return  $Response['UserName'];
       }
         
       function GetUserSurname($UserId)
       {
          $SqlQuery = mysql_query("SELECT UserSurname FROM users WHERE id='$UserId'");
          $Response = mysql_fetch_array($SqlQuery);
          return  $Response['UserSurname'];
       }
       
       function GetUserPhoto($UserId)
       {
          $SqlQuery = mysql_query("SELECT UserPhoto FROM users WHERE id='$UserId'");
          $Response = mysql_fetch_array($SqlQuery);
          return  $Response['UserPhoto'];
       }
       
       function GetUserCountry($UserId)
       {
          $SqlQuery = mysql_query("SELECT country FROM users WHERE id='$UserId'");
          $Response = mysql_fetch_array($SqlQuery);
          return  $Response['country'];
       }
    }

    О да!

    Govnisti_Diavol, 22 Марта 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    //.....
    $post['avatar'] = @$imgpath;
    //.....
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    //.....

    "файлы не загружаются, не знаю в чем проблема"

    _jokz, 21 Марта 2012

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

    +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
    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
    public function getSaleDepartment()
        {
            $_linkToDepLabel = '';
    		
            switch ($this->getfs_sale_department()) {
                case '0':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/1.png';
                    break; //Moda
                case '1':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/2.png';
                    break; //Belleza
                case '2':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/3.png';
                    break; //Novia
                case '3':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/4.png';
                    break; //Ocio
                case '4':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/5.png';
                    break; //Deporte
                case '5':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/6.png';
                    break; //Familia
                case '6':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/7.png';
                    break; //Hogar
                case '7':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/8.png';
                    break; //Viaje
                case '8':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/9.png';
                    break; //Moda
                case '9':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/10.png';
                    break; //Belleza
                case '10':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/11.png';
                    break; //Novia
                case '11':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/12.png';
                    break; //Ocio
                case '12':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/13.png';
                    break; //Deporte
    
                default:
                    $_linkToDepLabel = '';
                    break;
            }
            return $_linkToDepLabel;
        }

    ппц

    CheshirskyCode, 21 Марта 2012

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

    +153

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    $sql_query_result = mysql_query("select * from Organisations
    inner join Goods on (Organisations.ID = Goods.OrgID)
    where 1");
    while($result_string = mysql_fetch_array($sql_query_result)) { array_push ($search_array, $result_string[3]); }
    for($i=0;$i<=count($search_array);$i++)
    {
     if(eregi($search_string, $search_array[$i]))
     {
      array_push($search_matches, $search_array[$i]);
     }
    }

    поиск в интернет магазине:
    13000 записей
    в строке 15 полей
    в каждом строке есть 3 BLOB
    2 с текстом и одно с картинкой товара
    а жаловались что база тормозит

    papavel, 21 Марта 2012

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <div style="display: none;">
    	<input type="hidden" name="_wpcf7" value="251" />
    	<input type="hidden" name="_wpcf7_version" value="3.1.1" />
    	<input type="hidden" name="_wpcf7_unit_tag" value="wpcf7-f251-t1-o1" />
    	<input type="hidden" name="_wpnonce" value="5963830b40" />
    </div>

    Плагин Contact Form 7 для Wordpress

    glutaminefee, 20 Марта 2012

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

    +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
    <?php
    class User
    {
       protected $_user_id;
       protected $_user_email;
       protected $_user_password;
     
       public function __construct($user_id)
       {
          $user_record = self::_getUserRecord($user_id);
          $this->_user_id = $user_record['id'];
          $this->_user_email = $user_record['email'];
          $this->_user_password = $user_record['password'];
       }
     
       public function __get($value) {}
       public function __set($name, $value) {}
     
       private static function _getUserRecord($user_id)
       {
          $user_record = array();
          switch($user_id) {
             case 1:
                $user_record['id'] = 1;
                $user_record['email'] = '[email protected]';
                $user_record['password'] = 'i like croissants';
                break;
     
             case 2:
                $user_record['id'] = 2;
                $user_record['email'] = '[email protected]';
                $user_record['password'] = 'me too!';
                break;
     
             case 'error':
                throw new Exception('Ошибка библиотеки SQL!');
                break;
          }
     
          return $user_record;
       }
    }
    ?>

    PHP исключения...

    Govnisti_Diavol, 19 Марта 2012

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    <?php
    if ($_GET['type']) $link = 'type='.$_GET['type'];
    if ($_GET['cat']) $link = 'cat='.$_GET['cat'];
    if ($_GET['param']) $link = 'param='.$_GET['param'];

    isset, 19 Марта 2012

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