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

    +151

    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
    foreach ($project as $key => $value) {
        if (!in_array($key, array('homepage'))) {
            if (isset($_POST['project'][$key])) {
                if (in_array($key, array('cast', 'client', 'related'))) {
                    $project->$key = $this->typograf($_POST['project'][$key]);
                } else {
                    $project->$key = $_POST['project'][$key];
                }
            }
        } elseif ($key == 'homepage') {
            $project->$key = isset($_POST['project'][$key]) ? 1 : 0;
        }
    }

    Обработка формы в проекте на yii, который мне приходится рефакторить

    dizballanze, 25 Января 2012

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $dbhost = 'localhost';
    $dbuser = 'user';
    $dbpass = '123';
    $dbtable = 'db_1';
    
    $dbname = $dbtable; // Знаю, руки кривые

    Tairesh, 24 Января 2012

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

    +150

    1. 1
    2. 2
    3. 3
    http://php.net/include/layout.inc
    http://php.net/include/site.inc
    http://php.net/include/languages.inc

    без комментариев :)

    Beat, 24 Января 2012

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if($element_id===false)
            {
            	//этот  код не должен работать
                $sql = 'SELECT `countmessage` FROM `mes_topic` WHERE `id`='.(int)$board_id;
            }else{
                ....
            }

    А зачем его писать?!

    admincheg, 23 Января 2012

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

    +154

    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
    public function invokeMethod($method, $params = array()) {
                    switch (count($params)) {
                            case 0:
                                    return $this->{$method}();
                            case 1:
                                    return $this->{$method}($params[0]);
                            case 2:
                                    return $this->{$method}($params[0], $params[1]);
                            case 3:
                                    return $this->{$method}($params[0], $params[1], $params[2]);
                            case 4:
                                    return $this->{$method}($params[0], $params[1], $params[2], $params[3]);
                            case 5:
                                    return $this->{$method}($params[0], $params[1], $params[2], $params[3], $params[4]);
                            default:
                                    return call_user_func_array(array(&$this, $method), $params);
                    }
            }

    Из сорцов Lithium

    asfalanaft, 23 Января 2012

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    foreach($_REQUEST as $_ind => $_val) { $_REQUEST[$_ind] = mysql_real_escape_string($_REQUEST[$_ind]); }
    foreach($_POST as $_ind => $_val) { $_POST[$_ind] = mysql_real_escape_string($_POST[$_ind]); }
    foreach($_GET as $_ind => $_val) { $_GET[$_ind] = mysql_real_escape_string($_GET[$_ind]); }
    foreach($_COOKIE as $_ind => $_val) { $_COOKIE[$_ind] = mysql_real_escape_string($_COOKIE[$_ind]); }

    Защита от инъекций

    ReckO, 22 Января 2012

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

    +157

    1. 1
    2. 2
    if (!isset($GLOBALS['abort']) || ! $GLOBAL['abort'] || $GLOBALS['abort'] !== true || !$_SESSION["AMP_user"]->checkSection('999')) {
    			if (core_devices_add($deviceid,$tech,$devinfo_dial,$devicetype,$deviceuser,$description,$emergency_cid)) {

    Нашёл внутри Elastix'a

    admincheg, 21 Января 2012

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

    +145

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <i id="hdrtxt"><?php echo $item['header']; ?></i>
    <style>
    ...
    #hdrtxt{
    font-style:normal;
    }
    ...
    </style>

    khaletskiy, 20 Января 2012

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

    +150

    1. 1
    2. 2
    $id = $_GET['id'];
    $id = (int) intval($id);

    Чтобы уж наверняка :)

    DropWorld, 19 Января 2012

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

    +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
    class BbCod{
    		
    		function BbCod(){
    				
    		} 
    		
    	 	static function BbB($text){
    			
    			if (is_array($text)) {
    				$text = '<b>'.$text[1].'</b>';
    			}
    			
    			return preg_replace_callback("~\[b]((?:[^[]|\[(?!/?b])|(?R))+)\[/b]~is", "BbCod::BbB" , $text); 
    		}
    		
    		
    		static function BbI($text){
    			
    			if (is_array($text)) {
    				$text = '<i>'.$text[1].'</i>';
    			}
    			
    			return preg_replace_callback("~\[i]((?:[^[]|\[(?!/?i])|(?R))+)\[/i]~is", "BbCod::BbI" , $text); 
    		}
    		
    		
    
    
    // ...
    
    		function Bb($text, $param = array()){
    			if(!isset($param['b']) || $param['b'] !== false) $text = $this->BbB($text);				
    			if(!isset($param['i']) || $param['i'] !== false) $text = $this->BbI($text);	
    			if(!isset($param['u']) || $param['u'] !== false) $text = $this->BbU($text);
    			if(!isset($param['ol']) || $param['ol'] !== false) $text = $this->BbOl($text);
    			if(!isset($param['ul']) || $param['ul'] !== false) $text = $this->BbUl($text);
    			if(!isset($param['li']) || $param['li'] !== false) $text = $this->BbLi($text);
    			if(!isset($param['quote']) || $param['quote'] !== false) $text = $this->BbQuote($text);
    			if(!isset($param['left']) || $param['left'] !== false) $text = $this->BbLeft($text);
    			if(!isset($param['right']) || $param['right'] !== false) $text = $this->BbRight($text);
    			if(!isset($param['center']) || $param['center'] !== false) $text = $this->BbCenter($text);
    			if(!isset($param['justify']) || $param['justify'] !== false) $text = $this->BbJustify($text);
    			if(!isset($param['size']) || $param['size'] !== false) $text = $this->BbSize($text);
    			if(!isset($param['color']) || $param['color'] !== false) $text = $this->BbColor($text);
    			if(!isset($param['fright']) || $param['fright'] !== false) $text = $this->BbFRight($text);
    			if(!isset($param['fleft']) || $param['fleft'] !== false) $text = $this->BbFLeft($text);
    			if(!isset($param['table']) || $param['table'] !== false) $text = $this->BbTable($text);
    			if(!isset($param['td']) || $param['td'] !== false) $text = $this->BbTd($text);
    			if(!isset($param['th']) || $param['th'] !== false) $text = $this->BbTh($text);
    			if(!isset($param['tr']) || $param['tr'] !== false) $text = $this->BbTr($text);
    			if(!isset($param['br']) || $param['br'] !== false) $text = $this->BbBr($text);
    			if(!isset($param['hr']) || $param['hr'] !== false) $text = $this->BbHr($text);
    			if(!isset($param['youtube']) || $param['youtube'] !== false) $text = $this->BbYoutube($text);
    			if(!isset($param['img']) || $param['img'] !== false) $text = $this->BbIms($text);
    			if(!isset($param['src']) || $param['src'] !== false) $text = $this->BbSrc($text);
    			if(!isset($param['mail']) || $param['mail'] !== false) $text = $this->BbMail($text);
    			
    			return $text;	
    		}
    		
    }
    		// end class

    Писал в само начале осваивания ООП в php. И причем такое ощущения что бухой писал)

    vir-mir, 19 Января 2012

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