1. Список говнокодов пользователя asfalanaft

    Всего: 6

  2. SQL / Говнокод #10433

    −118

    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
    SELECT x.org_spec_id, (
                    SELECT count(c.id) FROM customers c , government_customers_require gcr               
                    WHERE c.org_spec_id=x.org_spec_id AND gcr.customer_id=c.id                
                ) as bal_ins, 
                sum(x.type_b1) as type_b1, sum(x.type_b2) as type_b2, sum(x.type_b3) as type_b3, sum(x.bus_debit) as bus_debit,
                sum(x.gost_ac1) as gost_ac1, sum(x.gost_ac2) as gost_ac2, sum(x.nav_ac1) as nav_ac1, sum(x.nav_ac2) as nav_ac2,
                \'-\' as price1, \'-\' as price2, \'-\' as price3, \'-\' as price4, sum(x.scope_b1) as scope_b1,
                sum(x.scope_b2) as scope_b2, sum(x.scope_b3) as scope_b3, sum(x.scope_b4) as scope_b4, sum(x.scope_b5) as scope_b5,
                sum(x.scope_b6) as scope_b6, sum(x.add11) as add11, sum(x.add12) as add12, sum(x.add21) as add21, 
                sum(x.add22) as add22, sum(x.add23) as add23, sum(x.add31) as add31, sum(x.add32) as add32, sum(x.add33) as add33
                
                FROM (SELECT c.org_spec_id, b.id , c.id as bal_ins,
                case when bsd.id is not null then 1 else 0 end as bus_debit,
                case when bsd.id is null then case when bm.type_id = 1 then 1 else 0 end else 0 end as type_b1, 
                case when bsd.id is null then case when bm.type_id = 2 then 1 else 0 end else 0 end as type_b2, 
                case when bsd.id is null then case when bm.type_id = 3 then 1 else 0 end else 0 end as type_b3,            
                case when bsd.id is null AND bm.type_id = 1 then case when gst.accepted then 1 else 0 end else 0 end as gost_ac1,
                case when bsd.id is null AND bm.type_id = 1 then case when gst.accepted then 0 else 1 end else 0 end as gost_ac2,
                case when bsd.id is null AND bm.type_id = 1 then case when nav.id is not null then 1 else 0 end else 0 end as nav_ac1,
                case when bsd.id is null AND bm.type_id = 1 then case when nav.id is not null then 0 else 1 end else 0 end as nav_ac2,
                case when bsd.id is null AND b.scope_id = 2 then 1 else 0 end as scope_b1,
                case when bsd.id is null AND b.scope_id = 1 then 1 else 0 end as scope_b2,
                case when bsd.id is null AND b.scope_id = 3 then 1 else 0 end as scope_b3,
                case when bsd.id is null AND b.scope_id = 4 then 1 else 0 end as scope_b4,
                case when bsd.id is null AND b.scope_id = 6 then 1 else 0 end as scope_b5,
                case when bsd.id is null AND b.scope_id = 5 then 1 else 0 end as scope_b6,
                case when bsd.id is null then case when add1.id is not null then case when add1.selected_variant=\'on\' then 1 else 0 end else 1 end else 0 end as add11,
                case when bsd.id is null then case when add1.id is not null then case when add1.selected_variant=\'off\' then 1 else 0 end else 0 end else 0 end as add12,
                case when bsd.id is null then case when add2.id is not null then case when add2.selected_variant=\'on\' then 1 else 0 end else 0 end else 0 end as add21,
                case when bsd.id is null then case when add2.id is not null then case when add2.selected_variant=\'off\' then 1 else 0 end else 0 end else 0 end as add22,
                case when bsd.id is null then case when add2.id is not null then case when add2.selected_variant=\'no\' then 1 else 0 end else 1 end else 0 end as add23,
                case when bsd.id is null then case when add3.id is not null then case when add3.selected_variant=\'on\' then 1 else 0 end else 0 end else 0 end as add31,
                case when bsd.id is null then case when add3.id is not null then case when add3.selected_variant=\'off\' then 1 else 0 end else 0 end else 0 end as add32,
                case when bsd.id is null then case when add3.id is not null then case when add3.selected_variant=\'no\' then 1 else 0 end else 1 end else 0 end as add33

    asfalanaft, 29 Мая 2012

    Комментарии (12)
  3. 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)
  4. PHP / Говнокод #8527

    +156

    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
    f (isset(self::$_namespaceLocks[$this->_namespace])) {
                /*
                  @see Zend_Session_Exception
                 /
                require_once 'Zend/Session/Exception.php';
                throw new Zend_Session_Exception('This session/namespace has been marked as read-only.');
            }
    
            if ($name === '') {
                /*
                 * @see Zend_Session_Exception
                 /
                require_once 'Zend/Session/Exception.php';
                throw new Zend_Session_Exception("The '$name' key must be a non-empty string");
            }
    
            if (parent::$_writable === false) {
                /*
                 * @see Zend_Session_Exception
                 */
                require_once 'Zend/Session/Exception.php';
                throw new Zend_Session_Exception(parent::_THROW_NOT_WRITABLE_MSG);
            }

    asfalanaft, 15 Ноября 2011

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

    +149

    1. 1
    2. 2
    define('DEBUG', !isset($_REQUEST["debug"]) ? false : true);
    define('DEV', !isset($_REQUEST["dev"]) ? false : true);

    asfalanaft, 15 Ноября 2011

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

    +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
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    class Super_Loader extends Zend_Loader {
        public static function loadClass($class, $dirs = null)
        {
            parent::loadClass($class, $dirs);
        }
    
        private function moduleIsExist($name) {
            if(is_dir(APPLICATION_PATH . "/modules/" . $name . "/")) {
                return true;
            }
    
            return false;
        }
    
        public static function autoload($class)
        {
            $classArray = explode("_", $class);
            $firstPart = array_shift($classArray);
    
            if(self::moduleIsExist($firstPart)) {
    
                $moduleDir = APPLICATION_PATH . "/modules/";
                $typePart = array_shift($classArray);
                switch($typePart) {
                    case "Lib":
                        $file_name = $moduleDir . $firstPart . "/lib/" . implode("/", $classArray) . ".php";
                        break;
                    case "Model":
                        $file_name = $moduleDir . $firstPart . "/models/" . implode("/", $classArray) . ".php";
                        break;
                    default:
    
                        break;
                }
    
                if($file_name) {
                    try {
                        self::loadFile($file_name);
                        return $class;
                    } catch (Exception $e) {
                        return false;
                    }
                }
            } else {
                try {
                    self::loadClass($class);
                    return $class;
                } catch (Exception $e) {
                    return false;
                }
            }
        }
    }

    Свой супер-автолоадер для ZF

    asfalanaft, 03 Ноября 2011

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $id = $fInt->filter($this->_getParam('id'));
            $sort = $fInt->filter($this->_getParam('sort'));
            $c_name = $this->mbtrim($fStr->filter($this->_getParam('c_name')));
            $c_shortname = $this->mbtrim($fStr->filter($this->_getParam('c_shortname')));
            $email = $this->mbtrim($fStr->filter($this->_getParam('email')));
            $d_firstname = $this->mbtrim($fStr->filter($this->_getParam('d_firstname')));
            $d_lastname = $this->mbtrim($fStr->filter($this->_getParam('d_lastname')));
    ...

    И так около 20 строк. Какие есть хорошие варианты фильтровать множество разнотипных данных?

    asfalanaft, 15 Сентября 2010

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