Example #1
0
 public function actionLogin()
 {
     $this->view->title = "Вход в систему";
     try {
         $input = \System\Engine::getInput();
         if ($input->exists("email")) {
             $email = $input->getStr("email", null, "Empty email field");
             $password = $input->getStr("password", null, "Empty Password field");
             UserModel::authorize($email, $password);
             $this->redirect("/");
         } else {
             return $this->view->htmlPage("user/auth");
         }
     } catch (Exception $e) {
         return $this->view->htmlPage("user/auth", ['message' => $e->getMessage()]);
     }
 }
Example #2
0
 public function actionSaveComment($post_id)
 {
     $post = PostModel::get($post_id);
     $input = \System\Engine::getInput();
     $data = $input->getArray("data");
     $data = array_intersect_key($data, array_flip(["name", "message"]));
     $user = UserModel::isAuthorized();
     $data['post_id'] = $post_id;
     $data['message'] = strip_tags($data['message']);
     if ($user) {
         $data['user_id'] = $user->id;
     } else {
         $data['name'] = strip_tags($data['name']);
     }
     try {
         $comment = new PostCommentModel();
         $comment->setData($data);
         $comment->save();
         $this->redirect("/post/show/{$post->id}#comments");
     } catch (Exception $e) {
         $this->redirect("/post/show/{$post->id}#comments", $e->getMessage());
     }
 }
Example #3
0
<?php

use System\Engine;
require_once "defines.php";
require_once PATH_INCLUDE . "functions.php";
require_once PATH_INCLUDE . "autoload.php";
require_once PATH_ROOT . "vendor/autoload.php";
spl_autoload_register("autoLoader");
$engine = Engine::instance();
Example #4
0
<?php

require_once "modules/system/classes/patterns/instanceable.php";
require_once "modules/system/classes/engine.php";
require_once "modules/system/debug.php";
\System\Engine::Instance()->Work();
Example #5
0
    unset($_GET);
    unset($_POST);
    if (isset($request['year']) && 2011 < $request['year']) {
        $request['year'] = 2011;
    }
    if (isset($request['week']) && 17 < $request['week']) {
        $request['week'] = 17;
    }
    $controller = null;
    if (isset($request['c'])) {
        $controller = $request['c'];
        unset($request['c']);
    }
    $method = null;
    if (isset($request['m'])) {
        $method = $request['m'];
        unset($request['m']);
    }
    $engine = new Engine($controller, $method, "POST" == $_SERVER["REQUEST_METHOD"]);
    unset($controller);
    unset($method);
    echo $engine->callControllerMethod($request);
} catch (Exception $e) {
    // handle any exception with some system, better than this
    //System\Logger::Error($e);
    print __FILE__ . " " . __LINE__ . " <pre>" . print_r($e, true) . "</pre>";
}
$end = microtime();
//echo '<h3 style="color: silver;">' . ($end - $start) . '</h3>';
//print(__FILE__ . ' ' . __LINE__ . ' <pre style="color: silver;">' . print_r($_SERVER, true) . '</pre>');
// this is EOF