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

    0

    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
    $collections = Yii::app()->db->createCommand()
        ->selectDistinct('prod.product_id,cc.category_id AS id, cc.code AS code,cc.img AS '
            . 'pic,cc.category_name AS name, pl.category_name AS ln_name, '
            . 'fvs.value AS country,c2.category_name AS parent_category,'
            . 'c2.category_id AS p_id, c2.code AS p_code')
    // ->select()
        ->from('Products prod')
        ->join('Products_Categoryes pc', 'prod.product_id = pc.product_id')
        ->join('Categories c', 'c.category_id = pc.category_id')
        ->join('Products_Categoryes ppp', 'ppp.category_id = c.category_id')
        ->join('Products p', 'p.product_id = ppp.product_id')
        ->join('Products_Categoryes pppccc', 'pppccc.product_id = ppp.product_id ')
        ->join('Categories cc', 'cc.category_id = pppccc.category_id
    AND cc.category_left > :cat_left
    AND cc.category_right < :cat_right
    AND cc.category_level = 3', array(':cat_left' => $brends['category_left'], ':cat_right' => $brends['category_right']))
        ->join('Categories c2', 'cc.category_left > c2.category_left
    AND cc.category_right < c2.category_right
    AND c2.category_level = cc.category_level - 1')
        ->leftJoin('kk_categories_ln pl', ' pl.ln_id = :ln '
            . 'AND pl.category_id = cc.category_id', array(':ln' => $ln_id))
        ->leftJoin('Feature_Product_Values fpv', 'p.product_id = fpv.product_id '
            . 'AND feature_id = :country_id ', array(':country_id' => $counrty_id))
        ->leftJoin('Feature_Values_string fvs', 'fvs.feature_id = fpv.feature_id')
        ->group('cc.category_id')
        ->where($where, $params)
        ->queryAll();

    j488538trbvmcom, 15 Декабря 2015

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

    +7

    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
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    //скрытно убираем левых гидов по их ид. Id с релиза.
            $select->where('self.id NOT IN (
                        1054063,
                        1054065,
                        1054232,
                        1054233,
                        1054220,
                        1054213,
                        1054212,
                        1054201,
                        1054199,
                        1054198,
                        1054197,
                        1054053,
                        1054058,
                        1054395,
                        1054445,
                        1054069,
                        1055221,
                        1055241,
                        1055386,
                        1055405,
                        1055406,
                        1055407,
                        1055408,
                        1055409,
                        1055410,
                        1055411,
                        1055412,
                        1054279,
                        1055259,
                        1054066,
                        1054067,
                        1054068,
                        1054070,
                        1054072,
                        1054075,
                        1054064,
                        1054073,
                        1054059,
                        1054060,
                        1054061,
                        1054062,
                        1054071,
                        1054077,
                        1054078,
                        1054079,
                        1054080,
                        1054081,
                        1054187,
                        1054128,
                        1054144,
                        1054129,
                        1054082,
                        1054076,
                        1054119,
                        1054118,
                        1054117,
                        1054116,
                        1054108,
                        1054106,
                        1054103,
                        1054111,
                        1054113,
                        1054102,
                        1054100,
                        1054098,
                        1054096,
                        1054095,
                        1054094,
                        1054093,
                        1054092,
                        1054120,
                        1054152,
                        1054150,
                        1054149,
                        1054148,
                        1054142,
                        1054141,
                        1054140,
                        1054139,
                        1054143,
                        1054138,
                        1054137,
                        1054136,
                        1054130,
                        1054126,
                        1054125,
                        1054186,
                        1054185,
                        1054184,
                        1054158,
                        1054182,
                        1054181,
                        1054180,
                        1054179,

    Это код из контроллера. И это примерно 1/20 всей простыни.

    seladir, 15 Декабря 2015

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

    0

    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
    public function callCost($fromCity, $fromStreet, $fromHouse, $fromHousing, $fromBuilding, $fromPorch, $fromLat, $fromLon, $toCity, $toStreet, $toHouse, $toHousing, $toBuilding, $toPorch, $toLat, $toLon, $clientName, $phone, $priorTime, $customCarId, $customCar, $carType, $carGroupId, $tariffGroupId, $comment, $additional = '')
        {
            if ($json = $this->reqCache->getValue($fromLat . $fromLon . $toLat . $toLon . $phone . $priorTime . $tariffGroupId . $comment . $additional)) {
                $data = json_decode($json);
                return $data;
            } else {
    			$tariffGroupId = $this->findTariffOnCarType($carType);
    			$additional = explode(';', $additional);
    			$route = new TaxiRouteAnalyzer($this->dbHost, $this->database, $this->dbLogin, $this->dbPass);
    			$this->writeLog($tariffGroupId);
    			$data = $route->analyzeRoute(1, $fromCity, $fromStreet, $fromHouse, $fromHousing, $fromLat, $fromLon, $toCity, $toStreet, $toHouse, $toHousing, $toLat, $toLon, $additional, $tariffGroupId, $this->isDay(), 1);
                $res = json_encode($data);
                $this->reqCache->setValue($fromLat . $fromLon . $toLat . $toLon . $phone . $priorTime . $tariffGroupId . $comment . $additional, $res, $this->cacheTime);
    			return $data; 
            }
        }

    человеку доверили сделать кэширование данных...

    akanit, 14 Декабря 2015

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

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    var cloths = {
      <?php foreach ($clothList as $cloth): ?>
        "<?=$cloth->id()?>": {
          "id": <?=$cloth->id()?>,
          "name": "<?=$cloth->name()?>",
          "public_name": "<?=str_replace('"', '\"', $cloth->public_name())?>"
        },
      <?php endforeach; ?>
      "dummy": {}
    };

    kgm-rj, 14 Декабря 2015

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    if (!$subscription) {
        return $this->redirect(['action' => 'cancel_success']);
        throw new BadRequestException();
    }

    epadqwbd, 11 Декабря 2015

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

    +2

    1. 1
    https://toster.ru/q/274179

    Ученики Mr.Shit (беднягу зачмырили и он сменил домен на php. webtm.ru) продолжают радовать

    loki90, 11 Декабря 2015

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

    +5

    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
    $scales = db_select('_scale', 'q')
            ->condition('q.gender', $gender)
            ->fields('q', array('id'))
            ->execute();
    
        $i = 1;
        while ($scale = $scales->fetchObject()) {
            $raw_score = 0;
    
            $query = db_select('_scale_question', 'q')
                ->condition('q.scale_id', $scale->id)
                ->fields('q')
                ->execute();
    
            while ($item = $query->fetchObject()) {
                $user_answer = db_select('_user_answer', 'q')
                    ->condition('q.question_id', $item->question_id)
                    ->condition('q.result_id', $result_id)
                    ->fields('q', array('answer'))
                    ->execute()
                    ->fetchField();
    
                if ($user_answer == $item->expected_answer) {
                    $raw_score++;
                }
            }
    
    
            $raw_scores_item['scale_id'] = $scale->id;
            $raw_scores_item['score'] = $raw_score;
    
            $raw_scores[$i] = $raw_scores_item;
            $i++;
        }

    Drupal 7, SQL-запросы с DB API Drupal в двойном цикле(!).
    ...А заменить можно 1 нормальным SQL-запросом.

    skigf, 10 Декабря 2015

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

    +1

    1. 1
    2. 2
    3. 3
    If (!isset($_GET['mode']) || !ereg("^[a-z0-9_-]{1,15}$",$_GET['mode'])) $mode='read'; else $mode=$_GET['mode'];
    
    switch ($mode){

    Как же я люблю в говнодвигах ковырятся Гг

    Vocaloid_IA, 09 Декабря 2015

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

    +1

    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
    <? 
    
          $login= _string($_COOKIE['login']);
          $password = _string($_COOKIE['password']);
    
      if($login && $password) { 
         
      $q = mysql_query('SELECT * FROM `users` WHERE `login` = "'.$login.'" AND `password` = "'.$password.'"');
      $user = mysql_fetch_array($q); 
    
      if(!$user) { 
         
      setCookie('login', ''); 
    
      setCookie('password', ''); 
       
      } 
    
          mysql_query('UPDATE `users` SET `online` = "'.time().'",
                                              `ip` = "'.$_SERVER['REMOTE_ADDR'].'",
                                              `ua` = "'.$_SERVER['HTTP_USER_AGENT'].'",
                                            `self` = "'.$_SERVER['PHP_SELF'].'" WHERE `id` = "'.$user['id'].'"');
    ?> 
    <? 
    } 
    ?>

    Нашел на бумасе Хд

    Vocaloid_IA, 09 Декабря 2015

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public function validate($value) {
        try {
            $date = new \DateTime($value);
            return true;
        } catch (\Exception $e) {
            return false;
        }
    }

    DateTime Validator

    bykovski, 08 Декабря 2015

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