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

    +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
    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
    $data = [];
            $firstGenreId = Genre::where('homepage_filter_band', 1)->first()->id;
            $bandSearch = [
                'limit' => request('limit') ?? 6,
                'genre' => $firstGenreId,
                'category' => BandCategory::where('homepage_filter', 1)->first()->id,
                'status' => 1
            ];
    
            $subGenres = Genre::getGenresByCategory($bandSearch['genre']);
            $bandSearch['genre'] = [$bandSearch['genre']];
            foreach ($subGenres as $subGenre){
                array_push($bandSearch['genre'], $subGenre->id);
            }
    
            $data['bandsGenre']['bands'] = Band::getBandsLimitListByGenre($bandSearch);
            $data['bandsGenre']['filters'] = Genre::isExistGenreByBandFilter();
            $data['bandsGenre']['active_filter'] = $firstGenreId;
            $data['bandsGenre']['type'] = 'genre';
    
            $data['bandsCategories']['bands'] = Band::getBandsLimitListByCategory($bandSearch);
            $data['bandsCategories']['filters'] = BandCategory::isExistCategoryByBandFilter();
            $data['bandsCategories']['active_filter'] = $bandSearch['category'];
            $data['bandsCategories']['type'] = 'category';
    
            $data['bandsStatus']['bands'] = Band::getBandsLimitListByStatus($bandSearch);
            $data['bandsStatus']['active_filter'] = 1;
            $data['bandsStatus']['filters'] = (object)[
                0 => [
                    'id' => 1,
                    'name' => trans('validation-custom.newest')
                ],
                1 => [
                    'id' => 2,
                    'name' => trans('validation-custom.lastUpdated')
                ]
            ];
            $data['bandsStatus']['type'] = 'status';
    
            $firstGenreId = Genre::where('homepage_filter_musician', 1)->first()->id;
            $firstInstrumentId = Instrument::where('homepage_filter', 1)->first()->id;
            $musicianSearch = [
                'limit' => request('limit') ?? 6,
                'genre' => $firstGenreId,
                'instrument' => $firstInstrumentId,
                'status' => 1
            ];
    
            $subGenres = Genre::getGenresByCategory($musicianSearch['genre']);
            $musicianSearch['genre'] = [$musicianSearch['genre']];
            foreach ($subGenres as $subGenre){
                array_push($musicianSearch['genre'], $subGenre->id);
            }
    
            $subInstruments = Instrument::getInstrumentsByCategory($musicianSearch['instrument']);
            $musicianSearch['instrument'] = [$musicianSearch['instrument']];
            foreach ($subInstruments as $subInstrument){
                array_push($musicianSearch['instrument'], $subInstrument->id);
            }
    
            $data['musiciansGenre']['musicians'] = User::getMusiciansLimitListByGenre($musicianSearch);
            $data['musiciansGenre']['filters'] = Genre::isExistGenreByFilter();
            $data['musiciansGenre']['active_filter'] = $firstGenreId;
            $data['musiciansGenre']['type'] = 'genre';
    
            $data['musiciansInstrument']['musicians'] = User::getMusiciansLimitListByInstrument($musicianSearch);
            $data['musiciansInstrument']['filters'] = Instrument::isExistInstrumentByFilter();
            $data['musiciansInstrument']['active_filter'] = $firstInstrumentId;
            $data['musiciansInstrument']['type'] = 'instrument';
    
            $data['musiciansStatus']['musicians'] = User::getMusiciansLimitListByStatus($musicianSearch);
            $data['musiciansStatus']['active_filter'] = 1;
            $data['musiciansStatus']['filters'] = (object)[
                0 => [
                    'id' => 1,
                    'name' => trans('validation-custom.newest')
                ],
                1 => [
                    'id' => 2,
                    'name' => trans('validation-custom.lastUpdated')
                ]
            ];
            $data['musiciansStatus']['type'] = 'status';
    
            return response()->json($data, 200);

    Кажуть - шота сторінка довго грузиться :)

    Запостил: silverreve23, 07 Августа 2020

    Комментарии (8) RSS

    • > Genre::where('homepage_filter_band', 1)
      Ох уж эти говнопрослойки-недоORM…
      Ответить
      • еще и вручную писаные под каждый сайт, небось
        Ответить
        • Конечно, любой сайт на «PHP» обязан содержать подобные прослойки. В особо тяжёлых случаях — какой-нибудь «class DB», намертво прибитый к мускулу.
          Ответить
    • много хороших SQL запросов вижу я
      Ответить
    • Это в чеховской кибальче
      class mysql
      {
      private $host     = ''; 
      private $user     = '';
      private $passwort     = ''; 
      private $dbname     = '';
      private $last_injection = '';
      private $conn_id = null;
      public function __construct($host, $user, $passwort, $dbname)
      {
      $this->host     = $host;
      $this->user     = $user;
      $this->passwort = $passwort;
      $this->dbname     = $dbname;
      $this->connect_mysql();
      return($this->conn_id);
      }
      private function connect_mysql()
      {
      $this->conn_id = mysql_connect($this->host,$this->user,$this->passwort);
      if($this->conn_id === false)
      {
      $message  = "Verbindung zur Datenbank nicht möglich.<br />\n";
      $message .= "Mysql-fehlermeldung: <br />\n";
      $message .= mysql_error();
      trigger_error($message);
      } 
      else 
      {
      $this->select_db();
      }
      }
      private function select_db()
      {
      $select = mysql_select_db($this->dbname,$this->conn_id);
      if($select === false)
          {
              $message  = "Die angegebene Datenbank \"".$this->dbname."\" 
      existiert nicht.<br />\n";
              $message .= "Mysql-fehlermeldung: <br />\n";
              $message .= mysql_error();
              trigger_error($message);
          }
      }
      public function query($sqlcode)
      {
          $this->last_injection = mysql_query($sqlcode);
                 if($this->last_injection === false)
              {
                  $message  = "Fehler bei dem Ausführen eines Mysql-codes!<br />\n";
                  $message .= "Mysql-Code: " . htmlspecialchars($sqlcode, ENT_QUOTES) . 
                  "<br />\n";
                  $message .= "Mysql-fehlermeldung:<br />\n";
                  $message .= mysql_error();
                  trigger_error($message);
              }
             return($this->last_injection);
      }
      Ответить
      • $this->last_injection = mysql_query($sqlcode);

        Какой мудрый класс. Изначально подразумевается, что в SQL коде будет инъекция.
        Ответить
    • Саме тому я за «PHP».
      Ответить

    Добавить комментарий