コード例 #1
0
ファイル: Core.php プロジェクト: akahan/lan5e
 public static function instance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #2
0
 /**
  * Constructor
  * @param int $type
  */
 public function __construct($type = PAGECONTROL_TYPE_CONTROL)
 {
     $this->type = $type;
     try {
         parent::__construct();
     } catch (Exception $e) {
         throw new \Exception($e->getMessage());
     }
 }
コード例 #3
0
 * Date: 2/2/2016
 * Time: 9:29 PM
 */
$app->add(function ($request, $response, $next) {
    if (!isset($_SESSION[ApiConfig::TOKEN_NAME])) {
        $gs = new GuardSevice();
        $url = $request->getUri()->getPath();
        if ($url != 'init-session' && isset($_COOKIE[ApiConfig::TOKEN_NAME])) {
            $gs->InitSession();
            $response = $response->withJson(['Reload' => 1]);
            return $response;
        }
    }
    //The code for the function like 'BeforeExecute' in .NET MVC here
    //..
    if (AppCore::CheckIgnoreRoute($request->getUri()->getPath())) {
        $response = $next($request, $response);
    } else {
        if (!isset($_COOKIE[ApiConfig::TOKEN_NAME])) {
            $response = DenyAccess($request, $response);
        } else {
            $headerTooken = $request->getHeader(ApiConfig::TOKEN_HEADER_NAME);
            if (isset($headerTooken) && !empty($headerTooken[0]) && isset($_SESSION[ApiConfig::TOKEN_NAME])) {
                $sessionToken = $_SESSION[ApiConfig::TOKEN_NAME];
                if ($headerTooken[0] == $sessionToken) {
                    $response = $next($request, $response);
                } else {
                    $response = DenyAccess($request, $response);
                }
            } else {
                $response = DenyAccess($request, $response);
コード例 #4
0
 /**
  * Get this modal dialogue as a HTML string
  * @since Version 3.10.0
  * @return string
  */
 public function __toString()
 {
     $Smarty = AppCore::GetSmarty();
     $tpl = $Smarty->ResolveTemplate("template.modal");
     // Add a default "ok" action to the dialogue
     if (empty($this->actions)) {
         $this->addButtonAction("Close", "btn btn-primary", "button", ["data-dismiss" => "modal"]);
     }
     $modal = ["id" => "globalModal", "class" => "modal hide", "hide" => true, "header" => $this->header, "body" => function_exists("wpautop") ? wpautop($this->body) : $this->body, "formaction" => $this->formaction, "actions" => $this->actions];
     $Smarty->Assign("modal", $modal);
     return $Smarty->Fetch($tpl);
 }
コード例 #5
0
<?php

/**
 * Created by PhpStorm.
 * User: Poka
 * Date: 2/12/2016
 * Time: 1:36 PM
 */
require_once __DIR__ . '/../../services/contact.service.php';
$app->post('/web/contact/create-contact', function ($request, $response, $agrs) {
    $service = new ContactService();
    $params = $request->getParams();
    $service->createContact($params['name'], $params['email'], $params['messages']);
    return AppCore::JsonResponse($response, null, 200, null);
});
コード例 #6
0
 public function __construct()
 {
     parent::__construct();
 }
コード例 #7
0
<?php

/**
 * Created by PhpStorm.
 * User: Poka
 * Date: 2/12/2016
 * Time: 1:36 PM
 */
require_once __DIR__ . '/../../services/SiteService.php';
$app->get('/admin/site/get-site-data/{catName}', function ($request, $response, $args) {
    $contact = new SiteService();
    $catName = $args['catName'];
    $result = $contact->getSiteInfo($catName);
    $error = null;
    if (!$result) {
        $error = 'Unable fetch data';
    }
    //TODO: Detail error for client
    return AppCore::JsonResponse($response, $result, 200, $error);
});
コード例 #8
0
<!DOCTYPE html>
<html>
    <head>
        <title>Testing</title>
        <meta charset="utf8"/>
    </head>
    <body>



        <?php 
AppCore::Run();
?>

        <footer>

        </footer>
    </body>
</html>
コード例 #9
0
 /**
  * Constructor
  * @param int $type
  */
 public function __construct($type = PAGECONTROL_TYPE_CONTROL)
 {
     $this->type = $type;
     parent::__construct();
 }