Nickbur /
Sunrise-CMS
| 1 | <?php |
||
| 2 | /* Divine CMS - Open source CMS for widespread use. |
||
| 3 | Copyright (c) 2019 Mykola Burakov ([email protected]) |
||
| 4 | See SOURCE.txt for other and additional information. |
||
| 5 | This file is part of Divine CMS. |
||
| 6 | This program is free software: you can redistribute it and/or modify |
||
| 7 | it under the terms of the GNU General Public License as published by |
||
| 8 | the Free Software Foundation, either version 3 of the License, or |
||
| 9 | (at your option) any later version. |
||
| 10 | This program is distributed in the hope that it will be useful, |
||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | GNU General Public License for more details. |
||
| 14 | You should have received a copy of the GNU General Public License |
||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
||
| 16 | |||
| 17 | // Registry |
||
| 18 | $registry = new \Divine\Engine\Core\Registry(); |
||
| 19 | |||
| 20 | // Config |
||
| 21 | $config = new \Divine\Engine\Library\Config(); |
||
| 22 | $config->load('common'); |
||
| 23 | $config->load($application_config); |
||
| 24 | $registry->set( |
||
| 25 | 'config', |
||
| 26 | $config |
||
| 27 | ); |
||
| 28 | |||
| 29 | // Session Handler Properties Object |
||
| 30 | $dbhProperties = new \RememberMe\Properties(); |
||
| 31 | |||
| 32 | // $dbhProperties->setCookie(""); |
||
| 33 | $dbhProperties->setTableSess("sessions"); |
||
| 34 | // table name that you already save your users data |
||
| 35 | $dbhProperties->setTableUsers("session_users"); |
||
| 36 | $dbhProperties->setTableAutologin("session_autologin"); |
||
| 37 | // $dbhProperties->setColSid(""); |
||
| 38 | // $dbhProperties->setColExpiry(""); |
||
| 39 | // $dbhProperties->setColUkey(""); |
||
| 40 | // $dbhProperties->setSessUkey(""); |
||
| 41 | // column that save username,email or any id of your users in tbl_users |
||
| 42 | $dbhProperties->setColUsername("username"); |
||
| 43 | // $dbhProperties->setColData(""); |
||
| 44 | // $dbhProperties->setColToken(""); |
||
| 45 | // $dbhProperties->setColCreated(""); |
||
| 46 | // $dbhProperties->setColUsed(""); |
||
| 47 | // $dbhProperties->setSessPersist(""); |
||
| 48 | // $dbhProperties->setSessUname(""); |
||
| 49 | // $dbhProperties->setSessAuth(""); |
||
| 50 | // $dbhProperties->setSessRevalid(""); |
||
| 51 | |||
| 52 | $dbhProperties->setDb( |
||
| 53 | $config->get('db_username'), |
||
| 54 | $config->get('db_password'), |
||
| 55 | $config->get('db_database'), |
||
| 56 | $config->get('db_hostname') |
||
| 57 | ); |
||
| 58 | |||
| 59 | // $dbhProperties->setUseTransactions(""); |
||
| 60 | $dbhProperties->setCollectGarbage(true); |
||
| 61 | $dbhProperties->setLifetimeDays("365"); |
||
| 62 | |||
| 63 | $registry->set( |
||
| 64 | 'dbhProperties', |
||
| 65 | $dbhProperties |
||
| 66 | ); |
||
| 67 | |||
| 68 | // Session |
||
| 69 | $session = new \Divine\Engine\Library\Session($registry); |
||
| 70 | if ($config->get('session_autostart')) { |
||
| 71 | $session->start(); |
||
| 72 | } |
||
| 73 | $registry->set( |
||
| 74 | 'session', |
||
| 75 | $session |
||
| 76 | ); |
||
| 77 | |||
| 78 | // Tracy Debugger |
||
| 79 | if (defined('SR_TRACY_DEBUG') && SR_TRACY_DEBUG == true) { |
||
|
0 ignored issues
–
show
|
|||
| 80 | \Tracy\Debugger::enable( |
||
| 81 | \Tracy\Debugger::DEVELOPMENT, |
||
| 82 | $_SERVER['DOCUMENT_ROOT'] . '/storage/logs/' |
||
| 83 | ); |
||
| 84 | |||
| 85 | // PerformancePanel |
||
| 86 | \Tracy\Debugger::getBar() |
||
| 87 | ->addPanel(new \Zarganwar\PerformancePanel\Panel()); |
||
| 88 | \Tracy\Debugger::$showLocation = true; |
||
| 89 | \Tracy\Debugger::$strictMode = true; |
||
| 90 | \Tracy\Debugger::$maxLength = 500; |
||
| 91 | |||
| 92 | // Register opencart panels (Tracy Plugins) |
||
| 93 | $panels = new \TracyPanel\Plugin(); |
||
| 94 | |||
| 95 | // Clear last session about Tracy |
||
| 96 | if (isset($_SESSION['_tracy']['templates_log'])) { |
||
| 97 | unset($_SESSION['_tracy']['templates_log']); |
||
| 98 | } |
||
| 99 | if (isset($_SESSION['_tracy']['sql_log'])) { |
||
| 100 | unset($_SESSION['_tracy']['sql_log']); |
||
| 101 | } |
||
| 102 | } |
||
| 103 | |||
| 104 | // Loader |
||
| 105 | $loader = new \Divine\Engine\Core\Loader($registry); |
||
| 106 | $registry->set( |
||
| 107 | 'load', |
||
| 108 | $loader |
||
| 109 | ); |
||
| 110 | |||
| 111 | // Request |
||
| 112 | $request = new \Divine\Engine\Library\Request(); |
||
| 113 | $registry->set( |
||
| 114 | 'request', |
||
| 115 | $request |
||
| 116 | ); |
||
| 117 | |||
| 118 | // Response |
||
| 119 | $response = new \Divine\Engine\Library\Response(); |
||
| 120 | $response->addHeader('Content-Type: text/html; charset=utf-8'); |
||
| 121 | $registry->set( |
||
| 122 | 'response', |
||
| 123 | $response |
||
| 124 | ); |
||
| 125 | |||
| 126 | // Database |
||
| 127 | $db = new \Divine\Engine\Library\Db( |
||
| 128 | $config->get('db_hostname'), |
||
| 129 | $config->get('db_username'), |
||
| 130 | $config->get('db_password'), |
||
| 131 | $config->get('db_database') |
||
| 132 | ); |
||
| 133 | if ($config->get('db_autostart')) { |
||
| 134 | $registry->set( |
||
| 135 | 'db', |
||
| 136 | $db |
||
| 137 | ); |
||
| 138 | } |
||
| 139 | |||
| 140 | // Doctrine DBAL |
||
| 141 | $dbal_obj = new \Doctrine\DBAL\Configuration(); |
||
| 142 | $dbal_conn = array( |
||
| 143 | 'dbname' => $config->get('db_database'), |
||
| 144 | 'user' => $config->get('db_username'), |
||
| 145 | 'password' => $config->get('db_password'), |
||
| 146 | 'host' => $config->get('db_hostname'), |
||
| 147 | 'driver' => 'pdo_mysql', |
||
| 148 | ); |
||
| 149 | $dbal_qb = \Doctrine\DBAL\DriverManager::getConnection($dbal_conn, $dbal_obj) |
||
| 150 | ->createQueryBuilder(); |
||
| 151 | $registry->set( |
||
| 152 | 'dbal', |
||
| 153 | $dbal_qb |
||
| 154 | ); |
||
| 155 | |||
| 156 | // Cache |
||
| 157 | $cache = new \Divine\Engine\Library\RedisCache(); |
||
| 158 | $registry->set( |
||
| 159 | 'cache', |
||
| 160 | $cache |
||
| 161 | ); |
||
| 162 | |||
| 163 | // Url |
||
| 164 | $url = new \Divine\Engine\Library\Url( |
||
| 165 | $config->get('app_url') |
||
| 166 | ); |
||
| 167 | $registry->set( |
||
| 168 | 'url', |
||
| 169 | $url |
||
| 170 | ); |
||
| 171 | |||
| 172 | // Language |
||
| 173 | $language = new \Divine\Engine\Library\Language( |
||
| 174 | $config->get('language_default') |
||
| 175 | ); |
||
| 176 | $language->load( |
||
| 177 | $config->get('language_default') |
||
| 178 | ); |
||
| 179 | $registry->set( |
||
| 180 | 'language', |
||
| 181 | $language |
||
| 182 | ); |
||
| 183 | |||
| 184 | // Document |
||
| 185 | $document = new \Divine\Engine\Library\Document(); |
||
| 186 | $registry->set( |
||
| 187 | 'document', |
||
| 188 | $document |
||
| 189 | ); |
||
| 190 | |||
| 191 | // Mobile Detect |
||
| 192 | $detect = new \Mobile_Detect(); |
||
| 193 | define('SR_IS_MOBILE', $detect->isMobile(), false); |
||
| 194 | define('SR_IS_TABLET', $detect->isTablet(), false); |
||
| 195 | |||
| 196 | // Front Controller |
||
| 197 | $controller = new \Divine\Engine\Core\Front($registry); |
||
| 198 | |||
| 199 | // Pre Actions |
||
| 200 | if ($config->has('action_pre_action')) { |
||
| 201 | foreach ($config->get('action_pre_action') as $value) { |
||
| 202 | $controller->addPreAction( |
||
| 203 | new \Divine\Engine\Core\Action($value) |
||
| 204 | ); |
||
| 205 | } |
||
| 206 | } |
||
| 207 | |||
| 208 | // Dispatch |
||
| 209 | $action_router = new \Divine\Engine\Core\Action( |
||
| 210 | $config->get('action_router') |
||
| 211 | ); |
||
| 212 | $action_error = new \Divine\Engine\Core\Action( |
||
| 213 | $config->get('action_error') |
||
| 214 | ); |
||
| 215 | $controller->dispatch( |
||
| 216 | $action_router, |
||
| 217 | $action_error |
||
| 218 | ); |
||
| 219 | |||
| 220 | // Output |
||
| 221 | $response->output(); |
||
| 222 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.