| #1 | Phalcon\Mvc\Model::findFirst
/var/www/service-micro.mygreatdeals.shop/www/apps/auth/controllers/IndexController.php (58) <?php
namespace App\Auth\Controllers;
use App\Backend\Models\Options;
use Auth\Auth;
use Phalcon\Mvc\Controller;
class IndexController extends Controller {
private $auth;
public function onConstruct() {
$this->auth = Auth::isAuth();
}
public function initialize() {
$this->initCss();
$this->initJs();
$this->view->setVar('domain', DOMAIN);
$this->view->setVar('api_url', API_URL);
}
protected function initCss(){
$this->assets
->collection('headerCSS')
->addCss('//fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons', false, true, ['rel' => 'stylesheet'] );
$this->assets
->collection('headerCSS')
->addCss('https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css', false, true, ['rel' => 'stylesheet'] );
$this->assets
->collection('headerCSS')
->addCss('/assets/auth/css/app.css', true, true, ['rel' => 'stylesheet'], RT_VERSION );
$this->assets
->collection('footerCSS');
}
protected function initJs(){
$this->assets
->collection('headerJS');
$this->assets
->collection('footerJS')
->addJs('/assets/auth/js/app.js', true, true, [], RT_VERSION);
}
public function indexAction() {
$option = Options::findFirst( "option_name = 'recaptcha_settings'" );
$recaptcha = Options::prepareCaptcha(
$option ? maybe_unserialize( $option->option_value ) : []
);
$this->view->setVar('recaptcha_status', $recaptcha['status'] ? $recaptcha['status'] : 0 );
$this->view->setVar('recaptcha_site_key', $recaptcha['site_key'] );
}
public function loginAction() {
if( ! $this->isAuth() ) {
header("Location: " . HOME_URL . "/login");
} else {
header("Location: " . HOME_URL . "/admin");
}
exit();
}
/**
* @return false|object
*/
protected function isAuth() {
return $this->auth ? $this->auth: false;
}
} |
| #5 | Phalcon\Mvc\Application->handle
/var/www/service-micro.mygreatdeals.shop/www/public/index.php (63) <?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
date_default_timezone_set('UTC');
const RT_VERSION = '1.0.0';
define( 'DOMAIN', $_SERVER['SERVER_NAME'] );
define( 'HOME_URL', 'https://' . DOMAIN );
define( 'API_URL', HOME_URL . '/rest/v1' );
define( 'BASE_PATH', dirname( __DIR__ ) );
const APP_PATH = BASE_PATH . '/apps';
const UPLOAD_PATH = BASE_PATH . '/public';
const UPLOAD_FOLDER = '/uploads';
//REST API
const API_PUBLIC = 'HWRMUBPJ7DK8FVTG53QCENYX46Z2S9L';
const API_SECRET = 'D9CSLTNZAXR8Y6V74HF3GJ2BWEK5QPM';
//AUTH
const SECRET_KEY = 'WT4NRGY3UPAL2JFCM8QZV6XBSDKH579';
include APP_PATH . '/filters.php';
include APP_PATH . '/core.php';
if( file_exists(APP_PATH . '/library/vendor/autoload.php') ){
require_once(APP_PATH . '/library/vendor/autoload.php');
}
use Phalcon\Autoload\Loader;
use Phalcon\Mvc\Router;
use Phalcon\DI\FactoryDefault;
use Phalcon\Mvc\Application as BaseApplication;
$debug = new Phalcon\Support\Debug();
$debug->listenExceptions()
->listenLowSeverity()
->listen();
class Application extends BaseApplication {
public function main() {
$this->registerServices();
// Зарегистрация установленных модулей
$this->registerModules( [
'auth' => [ //авторизация пользователей
'className' => 'App\Auth\Module',
'path' => APP_PATH . '/auth/Module.php'
],
'admin' => [ //админка
'className' => 'App\Admin\Module',
'path' => APP_PATH . '/admin/Module.php'
],
] );
try {
$response = $this->handle( $_SERVER["REQUEST_URI"] );
$response->send();
} catch ( \Exception $e ) {
echo '<pre>';
echo $e->getMessage();
echo " ";
echo $e->getCode();
echo "\n";
echo $e->getFile();
echo '('.$e->getLine().')';
echo "\n";
echo $e->getTraceAsString();
echo '</pre>';
}
}
/**
* Зарегистрация сервисов, чтобы сделать их общими, или в ModuleDefinition, чтобы сделать их специфичными для модуля.
*/
protected function registerServices() {
$di = new FactoryDefault();
$loader = new Loader();
$loader
->setDirectories( [
APP_PATH . '/vendor/'
] )
->register();
// Registering a router
$di->set( 'router', function () {
$router = new Router(false);
$router->setDefaultModule("auth");
// нельзя открыть главную страницу не авторизованным
$router->add('/', [
'module' => 'admin',
'controller' => 'index',
'action' => 'checkAuth',
])->setName('admin');
// авторизация
$router->add('/login', [
'module' => 'auth',
'controller' => 'index',
'action' => 'index',
])->setName('auth');
// открытие страниц в админке
$router->add('/admin/:params', [
'module' => 'admin',
'controller' => 'index',
'action' => 'index',
'params' => 1
])->setName('admin');
// запросы к REST админке
$router->add('/rest/v1/:controller/:action', [
'module' => 'admin',
'controller' => 1,
'action' => 2,
])->setName('rest');
// обработка 404 страниц
$router->notFound( [
'module' => 'auth',
'controller' => 'index',
'action' => 'index'
] );
return $router;
} );
$this->setDI($di);
}
}
$application = new Application();
$application->main(); |
| #6 | Application->main
/var/www/service-micro.mygreatdeals.shop/www/public/index.php (147) <?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
date_default_timezone_set('UTC');
const RT_VERSION = '1.0.0';
define( 'DOMAIN', $_SERVER['SERVER_NAME'] );
define( 'HOME_URL', 'https://' . DOMAIN );
define( 'API_URL', HOME_URL . '/rest/v1' );
define( 'BASE_PATH', dirname( __DIR__ ) );
const APP_PATH = BASE_PATH . '/apps';
const UPLOAD_PATH = BASE_PATH . '/public';
const UPLOAD_FOLDER = '/uploads';
//REST API
const API_PUBLIC = 'HWRMUBPJ7DK8FVTG53QCENYX46Z2S9L';
const API_SECRET = 'D9CSLTNZAXR8Y6V74HF3GJ2BWEK5QPM';
//AUTH
const SECRET_KEY = 'WT4NRGY3UPAL2JFCM8QZV6XBSDKH579';
include APP_PATH . '/filters.php';
include APP_PATH . '/core.php';
if( file_exists(APP_PATH . '/library/vendor/autoload.php') ){
require_once(APP_PATH . '/library/vendor/autoload.php');
}
use Phalcon\Autoload\Loader;
use Phalcon\Mvc\Router;
use Phalcon\DI\FactoryDefault;
use Phalcon\Mvc\Application as BaseApplication;
$debug = new Phalcon\Support\Debug();
$debug->listenExceptions()
->listenLowSeverity()
->listen();
class Application extends BaseApplication {
public function main() {
$this->registerServices();
// Зарегистрация установленных модулей
$this->registerModules( [
'auth' => [ //авторизация пользователей
'className' => 'App\Auth\Module',
'path' => APP_PATH . '/auth/Module.php'
],
'admin' => [ //админка
'className' => 'App\Admin\Module',
'path' => APP_PATH . '/admin/Module.php'
],
] );
try {
$response = $this->handle( $_SERVER["REQUEST_URI"] );
$response->send();
} catch ( \Exception $e ) {
echo '<pre>';
echo $e->getMessage();
echo " ";
echo $e->getCode();
echo "\n";
echo $e->getFile();
echo '('.$e->getLine().')';
echo "\n";
echo $e->getTraceAsString();
echo '</pre>';
}
}
/**
* Зарегистрация сервисов, чтобы сделать их общими, или в ModuleDefinition, чтобы сделать их специфичными для модуля.
*/
protected function registerServices() {
$di = new FactoryDefault();
$loader = new Loader();
$loader
->setDirectories( [
APP_PATH . '/vendor/'
] )
->register();
// Registering a router
$di->set( 'router', function () {
$router = new Router(false);
$router->setDefaultModule("auth");
// нельзя открыть главную страницу не авторизованным
$router->add('/', [
'module' => 'admin',
'controller' => 'index',
'action' => 'checkAuth',
])->setName('admin');
// авторизация
$router->add('/login', [
'module' => 'auth',
'controller' => 'index',
'action' => 'index',
])->setName('auth');
// открытие страниц в админке
$router->add('/admin/:params', [
'module' => 'admin',
'controller' => 'index',
'action' => 'index',
'params' => 1
])->setName('admin');
// запросы к REST админке
$router->add('/rest/v1/:controller/:action', [
'module' => 'admin',
'controller' => 1,
'action' => 2,
])->setName('rest');
// обработка 404 страниц
$router->notFound( [
'module' => 'auth',
'controller' => 'index',
'action' => 'index'
] );
return $router;
} );
$this->setDI($di);
}
}
$application = new Application();
$application->main(); |