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

    +159

    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
    if (isset($this->request->post['config_image_manufacturer_height'])) {
    			$this->data['config_image_manufacturer_height'] = $this->request->post['config_image_manufacturer_height'];
    		} else {
    			$this->data['config_image_manufacturer_height'] = $this->config->get('config_image_manufacturer_height');
    		}
    
    		if (isset($this->request->post['config_image_additional_width'])) {
    			$this->data['config_image_additional_width'] = $this->request->post['config_image_additional_width'];
    		} else {
    			$this->data['config_image_additional_width'] = $this->config->get('config_image_additional_width');
    		}
    		
    		if (isset($this->request->post['config_image_additional_height'])) {
    			$this->data['config_image_additional_height'] = $this->request->post['config_image_additional_height'];
    		} else {
    			$this->data['config_image_additional_height'] = $this->config->get('config_image_additional_height');
    		}
    		
    		if (isset($this->request->post['config_image_related_width'])) {
    			$this->data['config_image_related_width'] = $this->request->post['config_image_related_width'];
    		} else {
    			$this->data['config_image_related_width'] = $this->config->get('config_image_related_width');
    		}
    		
    		if (isset($this->request->post['config_image_related_height'])) {
    			$this->data['config_image_related_height'] = $this->request->post['config_image_related_height'];
    		} else {
    			$this->data['config_image_related_height'] = $this->config->get('config_image_related_height');
    		}
    		
    		if (isset($this->request->post['config_image_compare_width'])) {
    			$this->data['config_image_compare_width'] = $this->request->post['config_image_compare_width'];
    		} else {
    			$this->data['config_image_compare_width'] = $this->config->get('config_image_compare_width');
    		}

    Всего лишь небольшой кусок кода из админки OpenCart-а.
    Люди! OpenCart - гамно.

    cybervantyz, 06 Сентября 2011

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

    +146

    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
    function define_week_start_and_end($what)
    {
            $time_stamp = time();
            $cur_day = getdate($time_stamp); 
            $month_day = $cur_day['mday'];        
            $month_num = $cur_day['mon'];        
            $year_num = $cur_day['year'];        
            $day_num = $cur_day['wday'];
            if ($day_num!=0)
            {
                    $week_start = $month_day-$day_num+1;
            }
            else
            {
                    $week_start = $month_day-6;
            }
            $week_end = $week_start+6;
            $week_start_month_num = $month_num;
            $week_end_month_num = $month_num;
            $week_start_year_num = $year_num;
            $week_end_year_num = $year_num;
            
            if ($week_start < 1)
            {
                    if ($month_num == 1)
                    {
                            $week_start_year_num--;
                            $week_start_month_num = 12;
                    }
                    else
                    {
                            $week_start_month_num--;
                    }
                    $last_day_in_previous_month = 31;
                    while (!checkdate ($week_start_month_num, $last_day_in_previous_month, $week_start_year_num))
                    {
                            $last_day_in_previous_month--;
                    }
                    $week_start += $last_day_in_previous_month;
            }
    
            $last_day_in_month = 31;
            while (!checkdate ($week_start_month_num, $last_day_in_month, $week_start_year_num))
            {
                    $last_day_in_month--;
            }
    
            if ($week_end > $last_day_in_month)
            {
                    if ($month_num == 12)
                    {
                            $week_end_year_num++;
                            $week_end_month_num = 1;
                    }
                    else
                    {
                            $week_end_month_num++;
                    }
                    $week_end = $week_end-$last_day_in_month;
            }
    
            $week_start_time_stamp = gmmktime (0, 0, 0, $week_start_month_num, $week_start, $week_start_year_num);
            $week_end_time_stamp = gmmktime (23, 59, 59,  $week_end_month_num, $week_end, $week_end_year_num);
    
            if ($what == "start")
            {
                    return $week_start_time_stamp;
            }
            else if ($what == "end")
            {
                    return $week_end_time_stamp;
            }
            return NULL;
    }

    определение конца недели

    Lure Of Chaos, 05 Сентября 2011

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

    +147

    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
    function ckos() {
            $so = $_SERVER['HTTP_USER_AGENT'];
            $windowsxp = preg_match("/windows nt 5.1/i", $so);
            $windowsxp2 = preg_match("/windows xp/i", $so);
            $linux = preg_match("/linux/i", $so);
            $windowsme = preg_match("/win 9x 4.90/i", $so);
            $windowsme2 = preg_match("/windows me/i", $so);
            $windows2k = preg_match("/windows nt 5.0/i", $so);
            $windows2kb = preg_match("/windows 2000/i", $so);
            $windowsnt = preg_match("/windows nt 3.1/i", $so);
            $windowsnt2 = preg_match("/windows nt 3.5.0/i", $so);
            $windowsnt3 = preg_match("/windows nt 3.5.1/i", $so);
            $windowsnt4 = preg_match("/windows nt 4.0/i", $so);
            $windows98 = preg_match("/windows 98/i", $so);
            $windows95 = preg_match("/windows 95/i", $so);
            if ($windowsxp == 1 or $windowsxp2 == 1) {
            $sys = "Windows XP";
            } else if ($linux == 1) {
            $sys = "Linux";
            } else if ($windowsme == 1 or $windowsme2 == 1) {
            $sys = "Windows ME";
            } else if ($windows2k == 1 or $windows2kb == 1) {
            $sys = "Windows 2000";
            } else if ($windowsnt == 1 or $windowsnt2 == 1 or $windowsnt3 == 1 or $windowsnt4 == 1) {
            $sys = "Windows NT";
            } else if ($windows98 == 1 and $windowsme != 1) {
            $sys = "Windows 98";
            } else if ($windows95 == 1) {
            $sys = "Windows 95";
            } else {
            $sys = "Not identified";
            }
            return($sys);
    }

    вариация на тему броузеросниффера

    Lure Of Chaos, 05 Сентября 2011

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

    +170

    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
    <?php
    // $Id: post.php, v 1.12 2010/08/09 11:42:55 dries Exp $
    
    /**
     * Description of post
     *		Sending Email
     *
     * @author Unknown
     */
    class post {
    
    	public function send ( $email, $subject, $message, $addHeaders, $addParameters ) {
    
    		return mail($email, $subject, $message, $addHeaders, $addParameters);
    	}
    }
    ?>

    Цит: "Говорят, что сначала была нарисована какая-то картина, а потом Малевич закрасил ее в черный цвет".
    Ну мы ХОТЕЛИ нарисовать. Очень очень...

    istem, 05 Сентября 2011

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

    +168

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function get_os($user_agent) 
    {    
    $oses = array ('(Windows 95)|(Win95)|(Windows_95)', '(Windows 98)|(Win98)',  '(Windows NT 5.0)|(Windows 2000)', '(Windows NT 5.1)|(Windows XP)', 'Windows NT 5.2', '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)', 'Windows ME', 'OpenBSD',   'SunOS',  '(Linux)|(X11)',   '(Mac_PowerPC)|(Macintosh)',   'QNX',  'BeOS', 'OS/2'); 
    foreach($oses as $os) 
    { 
    if (eregi($os, $user_agent)) return 'PC'; 
    } 
    return 'Mobile'; 
    }

    И снова мастер-класс по определению какую версию сайта отдать.

    И ведь хоть бы кто-то додумался, начиная писать свой костыль, думать от обратного - легче опознать телефон.

    7ion, 04 Сентября 2011

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

    +159

    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
    <?php 
    function greeting($_lang="ru", $_offset=""){ 
        //// Функция greeting 
        //// Возвращает приветствие 
         
        // Языковые переменные 
        $lang = array( 
            'ru' => array( 
                'morning' => 'Доброе утро!', 
                'afternoon' => 'Добрый день!', 
                'evening' => 'Добрый вечер!', 
                'night' => 'Доброй ночи!' 
            ), 
            'en' => array( 
                'morning' => 'Good morning!', 
                'afternoon' => 'Good afternoon!', 
                'evening' => 'Good evening!', 
                'night' => 'Good night!' 
            ) 
        ); 
         
        if(empty($_offset)){ 
            // Если время на Вашем сервере отличается от Вашего, поменяйте сдвиг в переменной $offset 
            $_offset = 0; 
        } 
        if(empty($_lang)){ 
            // язык по умолчанию 
            $_lang = 'ru'; 
        } 
             
        // $curr_hour = текущий час 
        $curr_hour = date('G', time() + (60 * 60 * $_offset)); 
         
        if($curr_hour >= "5" && $curr_hour <= "11"){ 
            // если текущий час больше 5 и менее 11 
            return $lang[$_lang]['morning']; 
        }elseif($curr_hour >= "12" && $curr_hour <= "17"){ 
            // если текущий час больше 12 и менее 17 
            return $lang[$_lang]['afternoon']; 
        }elseif($curr_hour >= "18" && $curr_hour <= "20"){ 
            // если текущий час больше 18 и менее 20 
            return $lang[$_lang]['evening']; 
        }else{ 
            // все другие случаи 
            return $lang[$_lang]['night']; 
        } 
    } 
    ?>

    Концептуально новый серьезный подход к приветствию пользователя.

    7ion, 04 Сентября 2011

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

    +170

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    .....
    include("funkcei.phps");
    .....
    if(proverka_polzavatelskih_dannblh())
        mysql_query("Create Table {$POST['imye']}($id, $POST['parol'])");
    ?>

    "Тормозит, жрет дисковое пространство"....
    Люблю вас. фрилансеры. Мне после вашего пьяного бреда голды пересыпают за исправление :3

    Но как бы там ни было, какого хрена функции хранятся в .phps?!

    AlexT, 04 Сентября 2011

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php
    /*.......*/
    
    $x =& J_USER;
    
    /*.......*/
    ?>

    Ошибка порадовала.

    "Parse error: syntax error, unexpected ';', expecting T_PAAMAYIM_NEKUDOTAYIM"

    "а, да ебать, говно вопрос.

    jokz, 03 Сентября 2011

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

    +150

    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
    <!--/ Блок логина /-->
    <div class="icemodule"><div><div><div><div><h3><span>Мы</span> знакомы?!</h3></div></div></div></div></div>
    <div id="loginarea">
        <?php echo CHtml::form(Yii::app()->createUrl('site/login'),'post',array('id' => 'loginform')); ?>
        <p id="login_username">
            <?php echo CHtml::label('Логин','id_login'); ?>
            <?php echo CHtml::textField($model->login, 'Логин', array('alt' => 'Логин', 'class' => 'inputbox', 'id' => 'id_login', 'onfocus' => 'if(this.value==\'Логин\') this.value=\'\';', 'onblur' => 'if(this.value==\'\') this.value=\'Логин\';',)); ?>
        </p>
        <p id="login_password">
            <?php echo CHtml::label('Пароль','id_pass'); ?>
            <?php echo CHtml::passwordField($model->pass, 'Пароль', array('alt' => 'Пароль', 'class' => 'inputbox', 'id' => 'id_pass', 'onfocus' => 'if(this.value==\'Пароль\') this.value=\'\';', 'onblur' => 'if(this.value==\'\') this.value=\'Пароль\';',)); ?>
        </p>
        <p id="login_button">
            <button type="submit"><span class="round"><span>Войти</span></span></button>
        </p>
        <p id="login_remember">
            <?php echo CHtml::checkBox($model->rememberMe, '', array('alt' => 'Запомнить Меня', 'class' => 'checkbox', 'id' => 'id_rememberMe',)); ?>
            <?php echo CHtml::label('Запомнить','id_rememberMe'); ?>
        </p>
        <?php echo CHtml::endForm(); ?>
    </div>
    <div style="overflow: hidden; margin:0px 0px 10px 5px;">
        <ul class="loginimages">
            <li><?php echo CHtml::link('Забыли пароль', array('site/lostpass'));?> | </li>
            <li><?php echo CHtml::link('Регистрация', array('site/rules'));?></li>
        </ul>
    </div>
    <!--/ Конец блока логина /-->

    xyzdsnxyz, 03 Сентября 2011

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

    +147

    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
    <?php
    /*
    	Виджет для формы логина
    */
    class UserLogin extends CWidget
    {
    	public function run()
    	{
                $model = new Login;
                if(!Yii::app()->user->isGuest)
                {
                    $this->render('loginOut', array('model'=>$model));
                } else {
                    $this->render('loginForm', array('model'=>$model));
                }
    	}
    }
    
    /**
     * модель логина
     */
    class Login extends CFormModel
    {
    	public $login;
    	public $pass;
    	public $rememberMe;
    
    	private $_identity;
    
    	public function rules()
    	{
                return array(
                    // username and password are required
                    array('login, pass', 'required', 'message'=>'поле {attribute} не может быть пустым'),
                    // rememberMe needs to be a boolean
                    array('rememberMe', 'boolean'),
                    // password needs to be authenticated
                    array('pass', 'authenticate'),
                );
    	}
    
    	/**
    	 * Declares attribute labels.
    	 */
    	public function attributeLabels()
    	{
                return array(
                    'login'=>'Логин',
                    'pass'=>'Пароль',
                    'rememberMe'=>'Запомнить',
                );
    	}
    
    	/**
    	 * Authenticates the password.
    	 * This is the 'authenticate' validator as declared in rules().
    	 */
    	public function authenticate($pass,$params)
    	{
                $this->_identity=new UserIdentity($this->login,$this->pass);
                if(!$this->_identity->authenticate())
                    $this->addError($pass, empty($params['message'])?'неправильный лоин или пароль':$params['message']);
    	}
    
    	/**
    	 * Logs in the user using the given username and password in the model.
    	 * @return boolean whether login is successful
    	 */
    	public function login()
    	{
                if($this->_identity===null)
                {
                    $this->_identity=new UserIdentity($this->login,$this->pass);
                    $this->_identity->authenticate();
                }
                if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
                {
                    $duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
                    Yii::app()->user->login($this->_identity,$duration);
                    return true;
                } else {
                    return false;
                }
    	}
    }

    xyzdsnxyz, 03 Сентября 2011

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