public function needHttpAuthenticate() { if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="SCMS Authentication System"'); header('HTTP/1.0 401 Unauthorized'); echo $this->Response->arrayToJSON(['authenticate' => 'error', 'message' => 'Вы должны ввести корректный логин и пароль для получения доступа к ресурсу.', 'employee' => null]); exit; } $this->HTTPEmployeeAuthentication->signIn($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); if (!$this->HTTPEmployeeAuthentication->authenticated()) { header('WWW-Authenticate: Basic realm="SCMS Authentication System"'); header('HTTP/1.0 401 Unauthorized'); echo $this->Response->arrayToJSON(['authenticate' => 'error', 'message' => 'Вы должны ввести корректный логин и пароль для получения доступа к ресурсу.', 'employee' => null]); exit; } }
DataSource::setup('mysql', include 'App' . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'mysql.php'); DataSource::setCurrent('mysql'); Registry::set('config', include 'App/Config/project.php', true); Registry::set('credits', include 'credits.php'); // Пользовательская часть Registry::set('front', new Frame(SFW_APP_ROOT . 'Frames' . DIRECTORY_SEPARATOR), true); Registry::frame('front')->setFrame('front')->addCss('/public/assets/js/bower_components/bootstrap/dist/css/bootstrap.css')->addCss('/public/assets/css/general.css')->addCss('/public/assets/css/main-menu.css')->addCss('/public/assets/css/carousel-actions.css')->addJs('/public/assets/js/bower_components/requirejs/require.js', ['data-main' => '/public/assets/js/appconfig'])->addMeta(['http-equiv' => 'content-type', 'content' => 'text/html; charset=utf-8'])->addMeta(['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0'])->setFavicon(Registry::get('config')['favicon']); // Панель управления Registry::set('back', new Frame(SFW_APP_ROOT . 'Frames' . DIRECTORY_SEPARATOR), true); Registry::frame('back')->setFrame('back')->addCss('/public/assets/js/bower_components/bootstrap/dist/css/bootstrap.css')->addJs('/public/assets/js/bower_components/requirejs/require.js', ['data-main' => '/public/assets/js/appconfig'])->addMeta(['http-equiv' => 'content-type', 'content' => 'text/html; charset=utf-8'])->addMeta(['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0'])->setFavicon(Registry::get('config')['favicon']); // "Чистая" панель управления Registry::set('back_clear', new Frame(SFW_APP_ROOT . 'Frames' . DIRECTORY_SEPARATOR), true); Registry::frame('back_clear')->setFrame('back_clear')->addCss('/public/assets/js/bower_components/bootstrap/dist/css/bootstrap.css')->addJs('/public/assets/js/bower_components/requirejs/require.js', ['data-main' => '/public/assets/js/appconfig'])->addMeta(['http-equiv' => 'content-type', 'content' => 'text/html; charset=utf-8'])->addMeta(['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0'])->setFavicon(Registry::get('config')['favicon']); // Роутинг $configFileName = 'App' . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'route.php'; if (file_exists($configFileName)) { Registry::set('router', new Router(), true); $router = Registry::router(); $router->setConfig(include $configFileName); $router->setRoute($_SERVER['REQUEST_URI']); try { $router->route(); } catch (Exception $e) { SCMSNotificationLog::instance()->DBLogger->error($e->getMessage()); $response = new Response(SCMSNotificationLog::instance()); SCMSNotificationLog::instance()->pushAny(SCMSNotificationLog::TYPE_MESSAGE, $e->getMessage(), $e->getCode()); $response->send(); } } else { throw new Exception('Конфигурация роутинга отсутствует.'); }