示例#1
0
文件: view.php 项目: abachi/MVC
 /**
  * display file from project views folder.
  *
  * @param (string) $file - file name.
  * @param (string) $folder - if view file in folder but the folder name.
  * @param (array) $data - put data in view files.
  * @access public.
  */
 public function display($file, $folder = '', $data = null)
 {
     $view_path = null;
     // check path for view file
     if ($folder == '') {
         $view_path = APP_PATH . 'views' . DS . $file . self::$ext;
     } else {
         $view_path = APP_PATH . 'views' . DS . c_trim_path($folder) . DS . $file . self::$ext;
     }
     // extract data if exsists
     if (!is_null($data) && is_array($data)) {
         extract($data);
     }
     // include and show view file
     if (file_exists($view_path)) {
         require_once $view_path;
     } else {
         if (C_DEVELOPMENT_ENVIRONMENT == true) {
             trigger_error($view_path . " file not exists.");
         } else {
             cliprz::system(error)->show_404();
         }
     }
     // unset data
     unset($data, $view_path, $folder);
 }
示例#2
0
文件: sleep.php 项目: abachi/MVC
/**
 * Copyright :
 *  Cliprz model view controller framework.
 *  Copyright (C) 2012 - 2013 By Yousef Ismaeil.
 *
 * Framework information :
 *  Version 1.0.0 - Incomplete version for real use 7.
 *  Official website http://www.cliprz.org .
 *
 * File information :
 *  File path BASE_PATH/cliprz_application/config/ .
 *  File name sleep.php .
 *  Created date 21/11/2012 01:00 AM.
 *  Last modification date 06/01/2013 07:05 PM.
 *
 * Description :
 *  Sleep project jobs.
 *
 * Licenses :
 *  This program is released as free software under the Affero GPL license. You can redistribute it and/or
 *  modify it under the terms of this license which you can read by viewing the included agpl.txt or online
 *  at www.gnu.org/licenses/agpl.html. Removal of this copyright header is strictly prohibited without
 *  written permission from the original author(s).
 */
if (!defined("IN_CLIPRZ")) {
    die('Access Denied');
}
if ($_config['db']['use_database'] == true) {
    cliprz::system(database)->close();
}
#unset($_config,$_lang);
示例#3
0
文件: router.php 项目: abachi/MVC
 /**
  * Handling router to access project.
  *
  * @access public.
  */
 public static function handler()
 {
     if (self::get_router() === true) {
         $regex = null;
         $class = null;
         $class_path = null;
         $object = null;
         $function = null;
         $parameters = null;
         foreach (self::$_rule as $rule) {
             $regex = self::resource_to_regex($rule['regex']);
             if (preg_match($regex, self::$_requested['resource'])) {
                 if ($rule['method'] == self::$_requested['method']) {
                     // check class
                     $class = $rule['class'];
                     $class_path = APP_PATH . 'controllers' . DS . $rule['path'] . $class . '.php';
                     if (file_exists($class_path)) {
                         require_once $class_path;
                         // check if class exists
                         if (class_exists($class)) {
                             $object = new $class();
                             // check object functions (methods).
                             $function = $rule['function'];
                             $parameters = $rule['parameters'];
                             if (method_exists($class, $function)) {
                                 if (!is_null($parameters) && is_array($parameters)) {
                                     call_user_func_array(array($object, $function), self::get_parameters($parameters));
                                 } else {
                                     $object->{$function}();
                                 }
                             } else {
                                 cliprz::system(error)->show_404();
                             }
                         } else {
                             cliprz::system(error)->show_404();
                         }
                     } else {
                         cliprz::system(error)->show_404();
                     }
                 }
                 // if regex matched break the loop
                 break;
             }
         }
         // Unset data
         unset($regex, $class, $class_path, $object, $function, $parameters);
         self::$_rule = array();
         self::$_map = array();
         self::$_requested = array();
     } else {
         cliprz::system(error)->show_404();
     }
 }
示例#4
0
文件: router.php 项目: abachi/MVC
 * Framework information :
 *  Version 1.0.0 - Incomplete version for real use 7.
 *  Official website http://www.cliprz.org .
 *
 * File information :
 *  File path BASE_PATH/cliprz_application/config/ .
 *  File name router.php .
 *  Created date 21/11/2012 01:01 AM.
 *  Last modification date 03/12/2012 10:05 AM.
 *
 * Description :
 *  Routing file.
 *
 * Licenses :
 *  This program is released as free software under the Affero GPL license. You can redistribute it and/or
 *  modify it under the terms of this license which you can read by viewing the included agpl.txt or online
 *  at www.gnu.org/licenses/agpl.html. Removal of this copyright header is strictly prohibited without
 *  written permission from the original author(s).
 */
if (!defined("IN_CLIPRZ")) {
    die('Access Denied');
}
/**
 * Warning :
 *  Do not use
 *   ('index.php','index','public','cliprz_temporary','cliprz_system','cliprz_application') as routing regex.
 */
cliprz::system(router)->index("home");
cliprz::system(router)->rule(array("regex" => "home", "class" => "home", "function" => "index", "method" => "GET"));
cliprz::system(router)->rule(array("regex" => "cliprzinfo", "class" => "home", "function" => "info", "method" => "GET"));
示例#5
0
文件: home.php 项目: abachi/MVC
 public function index()
 {
     cliprz::system(view)->display("home");
 }
示例#6
0
文件: uri.php 项目: abachi/MVC
 /**
  * Detects the Request URI and fix the query string.
  *
  * @access protected.
  * @author CodeIgniter.
  */
 protected static function request_uri()
 {
     if (!isset($_SERVER['REQUEST_URI']) || !isset($_SERVER['SCRIPT_NAME'])) {
         if (C_DEVELOPMENT_ENVIRONMENT == true) {
             trigger_error("REQUEST_URI or SCRIPT_NAME cannot access to the request.");
         } else {
             cliprz::system(error)->show_400();
         }
     } else {
         $request_uri = $_SERVER['REQUEST_URI'];
         if (strpos($request_uri, $_SERVER['SCRIPT_NAME']) === 0) {
             $request_uri = mb_substr($request_uri, c_mb_strlen($_SERVER['SCRIPT_NAME']));
         } else {
             if (strpos($request_uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) {
                 $request_uri = mb_substr($request_uri, c_mb_strlen(dirname($_SERVER['SCRIPT_NAME'])));
             }
         }
         if (strncmp($request_uri, '?/', 2) === 0) {
             $request_uri = mb_substr($request_uri, 2);
         }
         $parts = preg_split('#\\?#i', $request_uri, 2);
         $request_uri = $parts[0];
         if (isset($parts[1])) {
             $_SERVER['QUERY_STRING'] = $parts[1];
             parse_str($_SERVER['QUERY_STRING'], $_GET);
         } else {
             $_SERVER['QUERY_STRING'] = '';
             $_GET = array();
         }
         if ($request_uri == '/' || empty($request_uri)) {
             #return '/';
             return;
         }
         $request_uri = parse_url($request_uri, PHP_URL_PATH);
         $request_uri = str_replace(array('//', '../'), '/', $request_uri);
         $uri = c_trim_path($request_uri);
         unset($request_uri);
         return $uri;
     }
 }
示例#7
0
文件: mysqli.php 项目: abachi/MVC
 /**
  * Send a MySQL query.
  *
  * @param (string) $sql - An SQL query.
  * @access public.
  */
 public function query($sql)
 {
     $query = mysqli_query($this->connection, $sql);
     if (!$query) {
         cliprz::system(error)->database(array("title" => "MySQL error " . mysqli_errno($this->connection), "content" => mysqli_error($this->connection)));
     } else {
         return $query;
     }
 }
示例#8
0
文件: autoload.php 项目: abachi/MVC
//cliprz::get_instance();
cliprz::system_use(security, security);
cliprz::system_use(language . 's', language);
cliprz::system_use(error . 's', error);
if ($_config['db']['use_database'] == true) {
    define("database", 'database', true);
    cliprz::system_use(database . 's', database);
}
cliprz::system_use(model . 's', model);
if (file_exists(APP_PATH . 'config' . DS . 'constants.php')) {
    require_once APP_PATH . 'config' . DS . 'constants.php';
}
if (file_exists(APP_PATH . 'config' . DS . 'wakeup.php')) {
    require_once APP_PATH . 'config' . DS . 'wakeup.php';
}
cliprz::system_use(session . 's', session);
if (file_exists(APP_PATH . "config" . DS . "libraries.php")) {
    require_once APP_PATH . "config" . DS . "libraries.php";
}
cliprz::system_use(view . 's', view);
cliprz::system_use(css, css);
cliprz::system_use(router, 'uri');
cliprz::system_use(router, router);
cliprz::system_use(http, http);
// get user constants file;
if (file_exists(APP_PATH . 'config' . DS . 'router.php')) {
    require_once APP_PATH . 'config' . DS . 'router.php';
}
require_once FUNCTIONS . 'system.functions.php';
cliprz::system(router)->handler();
示例#9
0
 /**
  * Get a lanuage array value by the key.
  *
  * @param (string) $key - array key.
  */
 function c_lang($key)
 {
     return cliprz::system(language)->lang($key);
 }