/** * 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); }
/** * singleton, Creates and gives a new Cliprz instance and keeps a record of it. * * @return Cliprz Instance. * @access public. */ public static function get_instance() { $call_class_name = function_exists('get_called_class') ? get_called_class() : __CLASS__; if (!isset(self::$_instances)) { $class = (string) $call_class_name; self::$_instances = new $class(); } return self::$_instances; }
/** * 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);
<?php echo cliprz::get_framework('name'); ?> Functions. </div> <div class="f"> <div class="f-center"><?php echo $functions; ?> </div> </div> <div class="head"> <?php echo cliprz::get_framework('name'); ?> Developers. </div> <div class="f"> <div class="f-center"><?php echo $developers; ?> </div> </div> </div> </div>
/** * 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(); } }
* 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"));
public function index() { cliprz::system(view)->display("home"); }
/** * 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; } }
/** * 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; } }
//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();
Don't forget to edit value to true in use database and choose your driver you prefer <div class="code"> <?php highlight_string('<?php $_config[\'db\'][\'use_database\'] = true; $_config[\'db\'][\'driver\'] = "mysqli"; ?>'); ?> </div> <br /> <h2>Information</h2> <pre> Version : <?php echo cliprz::get_framework("version"); ?> <?php echo cliprz::get_framework("stability"); ?> </pre> </div> <div class="under"> <?php echo cliprz::get_framework("under"); ?> </div> </body> </html>
/** * Get a lanuage array value by the key. * * @param (string) $key - array key. */ function c_lang($key) { return cliprz::system(language)->lang($key); }