/** * Стартуем * @param $content * @return void */ public function run(&$content) { //Путь к файлу $__path = $this->file; //Счетчик времени $time = Boot::mktime(); //Оборачиваем все в функцию $view = function ($params, $content) use($__path) { //Извлекаем переменные if (!empty($params)) { extract((array) $params); } //Запускаем отладчик ob_start(); //Подключаем файл require $__path; //Выполняем сценарий $html = ob_get_contents(); ob_end_clean(); //Возвращаем данные return $html; }; //Выполняем функцию $html = $view((array) Boot_Controller::getInstance()->view, $content); //Debug Boot::getInstance()->debug(" Rendered " . str_replace(APPLICATION_PATH . "/", "", $__path) . " (" . Boot::check_time($time) . "ms)"); echo $html; }
/** * Получаем инстанс * @static * @return Boot_Auth_Lib */ public static function getInstance() { if (!self::$_instance instanceof Boot_Auth_Lib) { self::$_instance = new Boot_Auth_Lib(); self::$_instance->skey = Boot::getInstance()->config->auth_skey; } return self::$_instance; }
public static function back() { echo <<<EOF <script type="text/javascript"> window.history.go(-1); </script> EOF; Boot::shutdown(); }
/** * Обрабатываем библиотеки, в которых добавлена прослушка на ошибки * @param Throwable $e */ public static function sendLibraryException($e) { if (Boot::getInstance()->library) { foreach (Boot::getInstance()->library->getLibraries() as $library) { if (in_array("Boot_Exception_Interface", class_implements($library, false))) { $library->onException($e); } } } }
public static function deny($base_app) { header('HTTP/1.1 403 Forbidden'); $smarty = $base_app->load('smarty'); $smarty->assign('page_title', 'Error - HTTP 403 Forbidden'); $smarty->assign('message_title', 'Your request has been expired'); $smarty->assign('message', 'Please do not report a duplicate data or refresh the page.'); $smarty->display('403'); Boot::shutdown(); }
function __construct($params) { if (!empty($params)) { $this->setUserID($params["uid"]); $this->setLinkHash($params["hash"]); $this->setExpireTime($params["expireTime"]); } $this->connection = Boot::getConnection(); $this->modelName = "ModelActivation"; }
/** * Получение только разрешенных параметров * @return array */ public function getValues() { $values = []; if (array_diff(array_keys($this->_params), $this->_permit)) { Boot::getInstance()->debug(' Unpermitted params: ' . implode(', ', array_diff(array_keys($this->_params), $this->_permit))); } foreach ($this->_params as $key => $param) { if (in_array($key, $this->_permit)) { $values[$key] = $param; } } return $values; }
/** * Конструктор */ public function __construct() { //Получаем имя драйвера $db = Boot::getInstance()->config->db; $driver = $db->adapter; $host = $db->host; $port = $db->port; $user = $db->user; $pass = $db->password; $dbase = $db->dbase; //Инитим драйвер $this->_db = new $driver($host, $port, $user, $pass, $dbase); //Подключаемся к базе $this->_db->connect(); }
public function __construct() { $this->connection = Boot::getConnection(); $this->modelName = "ModelUser"; }
/** * Инициализация библиотеки во вьюхе и контроллере * @param Boot_View|Boot_Layout|Boot_Abstract_Controller $class * @return void */ public function init(&$class) { $class->{$this->key} = Boot::getInstance()->library->{$this->key}; }
/** * Создание версии для файла * @param $path * @param null|string $name * @param array $process * @throws Boot_Exception */ private function create_version($path, $name, array $process) { //Дебаг Boot::getInstance()->debug(" * Create image version: [33m" . $this->storeDir() . '/' . $this->filename($name) . "[0m"); //Выбираем действие switch ($process[0]) { //Fill case "resize_to_fill": $this->processFill($path, $name, $process[1]); break; //Fit //Fit case "resize_to_fit": $this->processFit($path, $name, $process[1]); break; //Resize //Resize case "resize": $this->processResize($path, $name, $process[1]); break; //Неизвестный процесс //Неизвестный процесс default: throw new Boot_Exception("Unknown uploader process name: " . $process[0]); } }
/** * Offset to retrieve * @param mixed $offset * @return array Can return all value types. */ public function offsetGet($offset) { Boot::getInstance()->debug('get: ' . $offset); $messages = []; if ($this->offsetExists($offset)) { foreach ($this->errors[$offset] as $message) { $messages[] = $message; } } return $messages; }
Boot::init(BOOT_PAGE_WR); // Utils and so on require_once _base_ . '/lib/lib.platform.php'; // create instance of StdPageWriter StdPageWriter::createInstance(); // Popup content $lang =& DoceboLanguage::createInstance('popup_' . POPUP_MOD_NAME, 'framework'); $GLOBALS["page"]->setWorkingZone("content"); $GLOBALS["page"]->add(getTitleArea($lang->def("_AREA_" . strtoupper(POPUP_MOD_NAME)), strtolower(POPUP_MOD_NAME)) . '<div class="std_block">'); if (!defined('POPUP_MOD_NAME')) { die; } require_once "../" . POPUP_MOD_NAME . "/body.php"; $GLOBALS["page"]->add('</div>'); // finalize Boot::finalize(); /* output all */ $GLOBALS['page']->add(ob_get_contents(), 'debug'); ob_clean(); // layout Layout::render('popup'); // flush buffer ob_end_flush(); // Page functions: function drawMenu($menu_label, $menu_url, $sel = "") { if (is_array($menu_label)) { $GLOBALS['page']->add("<div class=\"popup_menu\"><ul>\n", "content"); foreach ($menu_label as $key => $val) { if ($sel == $key) { $class = "class=\"selected\" ";
// | Site: http://www.hdphp.com // |----------------------------------------------------------------------------------- // | Author: 向军 <*****@*****.**> // | Copyright (c) 2012-2013, http://www.houdunwang.com. All Rights Reserved. // |----------------------------------------------------------------------------------- // | License: http://www.apache.org/licenses/LICENSE-2.0 // '----------------------------------------------------------------------------------- /** * HDPHP框架入口文件 * 在应用入口引入hdphp.php即可运行框架 * @package hdphp * @supackage core * @author hdxj <*****@*****.**> */ define('HDPHP_VERSION', '2014-3-21'); defined("DEBUG") or define("DEBUG", FALSE); if (!defined('GROUP_PATH')) { defined('APP_PATH') or define('APP_PATH', './'); } defined('TEMP_PATH') or define('TEMP_PATH', (defined('APP_PATH') ? APP_PATH : GROUP_PATH) . 'Temp/'); defined("TEMP_NAME") or define("TEMP_NAME", '~boot.php'); defined('TEMP_FILE') or define('TEMP_FILE', TEMP_PATH . TEMP_NAME); //加载核心编译文件 if (!DEBUG and is_file(TEMP_FILE)) { require TEMP_FILE; } else { //编译文件 define('HDPHP_PATH', str_replace('\\', '/', dirname(__FILE__)) . '/'); require HDPHP_PATH . 'Lib/Core/Boot.class.php'; Boot::run(); }
* @package course management * @subpackage course catalogue * @category ajax server * @version $Id:$ * */ define("LMS", true); define("IN_FORMA", true); //define("IS_AJAX", true); define("_deeppath_", '../../../'); require dirname(__FILE__) . '/' . _deeppath_ . 'base.php'; // start buffer ob_start(); // initialize require _base_ . '/lib/lib.bootstrap.php'; Boot::init(BOOT_DATETIME); /* if(isset($_REQUEST['GLOBALS'])) die('GLOBALS overwrite attempt detected'); if(!defined("IN_FORMA")) define("IN_FORMA", true); $path_to_root = '../..'; // prepare refer ------------------------------------------------------------------ require_once(dirname(__FILE__).'/'.$path_to_root.'/config.php'); require_once($GLOBALS['where_config'].'/config.php'); if ($GLOBALS["where_cms_relative"] != false) $GLOBALS["where_cms_relative"]=$path_to_root.'/'.$GLOBALS["where_cms_relative"]; if ($GLOBALS["where_kms_relative"] != false) $GLOBALS["where_kms_relative"]=$path_to_root.'/'.$GLOBALS["where_kms_relative"]; if ($GLOBALS["where_lms_relative"] != false) $GLOBALS["where_lms_relative"]=$path_to_root.'/'.$GLOBALS["where_lms_relative"]; if ($GLOBALS["where_framework_relative"] != false) $GLOBALS["where_framework_relative"]=$path_to_root.'/'.$GLOBALS["where_framework_relative"];
public function set($name, $value) { $this->_flash[$name] = $value; setcookie('flash', serialize($this->_flash), null, "/", Boot::getInstance()->config->host); }
/** * Обработка ошибки * @param Throwable $e * @return mixed */ public static function onException($e) { if (APPLICATION_ENV == 'production' && ($e->getCode() >= 500 || $e->getCode() == 0) && isset(Boot::getInstance()->config->mail->error)) { self::send(Boot::getInstance()->config->mail->error, "Error", "<pre>Error " . $e->getCode() . ": " . $e->getMessage() . "\r\n" . $e->getTraceAsString() . "SERVER:\r\n" . var_export($_SERVER, true) . "POST:\r\n" . var_export($_POST, true) . "</pre>"); } }
/** * SQL query * @param $query * @return postgres */ public function query($query) { //Запоминаем время начала $time = Boot::mktime(); //Делаем запрос $this->result = @pg_query($this->_connect, $query) or $this->error($query); //Debug Boot::getInstance()->debug(" [36mSQL (" . Boot::check_time($time) . "ms)[0m " . $query); //Return return $this; }
/** * 编译核心文件 * @access private */ private static function compile() { $boot = TEMP_PATH . TEMP_FILE; if (DEBUG) { is_file($boot) and unlink($boot); return; } $compile = ''; //常量编译 $_define = get_defined_constants(true); foreach ($_define['user'] as $n => $d) { if ($d == '\\') { $d = "'\\\\'"; } else { $d = is_int($d) ? intval($d) : "'{$d}'"; } $compile .= "defined('{$n}') OR define('{$n}',{$d});"; } $files = array(HDPHP_CORE_PATH . 'HDPHP.class.php', HDPHP_CORE_PATH . 'HdphpException.class.php', HDPHP_CORE_PATH . 'App.class.php', HDPHP_CORE_PATH . 'Route.class.php', HDPHP_CORE_PATH . 'Log.class.php', HDPHP_CORE_PATH . 'Event.class.php', HDPHP_FUNCTION_PATH . 'Functions.php', HDPHP_FUNCTION_PATH . 'Common.php', HDPHP_DRIVER_PATH . 'View/View.class.php', HDPHP_DRIVER_PATH . 'View/Hd/Compile.class.php'); foreach ($files as $f) { $con = compress(trim(file_get_contents($f))); $compile .= substr($con, -2) == '?>' ? trim(substr($con, 5, -2)) : trim(substr($con, 5)); } $compile .= 'C(' . var_export(C(), true) . ');'; $compile .= 'L(' . var_export(L(), true) . ');'; $compile .= 'alias_import(' . var_export(alias_import(), true) . ');'; self::$_compile = $compile; }
public static function required($base_app, $role_id_or_name, $only_check = false) { $has_permission = false; $base_app->load('model', 'system/contrib/auth.User', false); $userinfo = User::info(); /* * Multi check */ if (is_array($role_id_or_name)) { foreach ($role_id_or_name as $value) { if (abs(intval($value)) > 0) { $field = 'id'; } else { $field = 'alias'; } $has_permission = self::__required($userinfo['role'], $value, $field); if ($has_permission) { return true; } } } /* * check by id or name */ if (abs(intval($role_id_or_name)) > 0) { $field = 'id'; } else { $field = 'alias'; } $has_permission = self::__required($userinfo['role'], $role_id_or_name, $field); if ($has_permission) { return true; } if ($only_check) { return false; } else { $base_app->smarty->display(403); Boot::shutdown(); } }
/** * Редирект * @param $url * @return void */ public function _redirect($url) { //Debug Boot::getInstance()->debug(" [33mRedirect to: " . $url . "[0m"); Boot::getInstance()->end(); Boot_Flash::getInstance()->set("referer", "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); header("Location: " . $url); exit; }
/** * @param $lang * @return array * @throws Exception */ public function parseJSON($lang) { //Если раньше до этого не парсили if (!isset($this->_parse[$lang])) { //Проверяем существование файла if (file_exists($this->_dir . $lang . ".json")) { //Читаем файл $this->_parse[$lang] = json_decode(file_get_contents($this->_dir . $lang . ".json"), true); } else { $this->_parse[$lang] = []; Boot::getInstance()->debug("Файл перевода языка не найден: {$lang}.json", true); } } return $this->_parse[$lang]; }
/** * При ошибке подключения * @param $message */ private function error($message) { $this->connected = false; Boot::getInstance()->debug(" [31m" . $message . "[0m"); }
/** * * @module soapserver.php * @version $Id: soaplms.php 469 2006-07-21 09:33:46Z fabio $ * @copyright 2004 */ if (!defined("LMS")) { define("LMS", true); define("IN_FORMA", true); define("_deeppath_", '../../../'); require dirname(__FILE__) . '/' . _deeppath_ . 'base.php'; // start buffer ob_start(); // initialize require _base_ . '/lib/lib.bootstrap.php'; Boot::init(BOOT_PAGE_WR); } $prefix = $GLOBALS['prefix_lms']; require_once dirname(__FILE__) . '/scorm_tracking.php'; require_once dirname(__FILE__) . '/scorm_items.php'; require_once dirname(__FILE__) . '/config.scorm.php'; require_once dirname(__FILE__) . '/scorm_items_track.php'; /** * SOAPLMS * * @package SCORM * @author ema Emanuele Sandri * @copyright Copyright (c) 2004 * @version $Id: soaplms.php 469 2006-07-21 09:33:46Z fabio $ * @access public **/
public function alert($msg, $to = null) { header('content:text/html; charset=utf-8'); if (!$to) { $to = 'window.history.go(-1);'; } else { $to = 'window.location.href="' . $to . '"'; } $msg = addslashes($msg); echo <<<EOF <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <script type="text/javascript"> alert('{$msg}'); {$to} </script> </head> <body></body> </html> EOF; Boot::shutdown(); }
$insert = "\$migration = " . var_export(array("change" => array($match[1] => array($table => $schema))), true) . ";"; break; case Boot_Migration::TYPE_UP: $insert = "\$migration = " . var_export(array("up" => array("sql" => isset($argv[2]) ? $argv[2] : ""), "down" => array("sql" => isset($argv[3]) ? $argv[3] : "")), true) . ";"; break; default: echo "Incorrect type of the migration"; exit(127); break; } //Добавляем в файл file_put_contents(APPLICATION_ROOT . "/db/" . date("YmdHis") . "_" . $name . ".php", "<?\r\n/**\r\n * Boot framework\r\n * Author: P.Nixx\r\n * Site: pnixx.ru\r\n*/\r\n\r\n" . $insert); echo "create migration: " . APPLICATION_ROOT . "/db/" . date("YmdHis") . "_" . $name . ".php\r\n"; if (isset($model)) { file_put_contents(APPLICATION_PATH . "/models/" . $table . ".php", $model); echo "create model: " . APPLICATION_PATH . "/models/" . $table . ".php\r\n"; } // if( isset($model_row) ) { // if( is_dir(APPLICATION_PATH . "/models/row/") == false ) { // mkdir(APPLICATION_PATH . "/models/row/"); // chmod(APPLICATION_PATH . "/models/row/", 0777); // } // file_put_contents( // APPLICATION_PATH . "/models/row/" . $table . "_row.php", // $model_row // ); // echo "create row model: " . APPLICATION_PATH . "/models/row/" . $table . "_row.php\r\n"; // } } Boot::getInstance()->end();
public static function check_time($mktime) { return round((Boot::mktime() - $mktime) * 1000, 2); }
/** * Парсинг закрытого ключа * @static * @param $skey */ public static function validKey($skey) { //Разбиваем $match = explode("_", $skey); //Если вроде всё правильно получили if ($match && count($match) == 3) { //Проверяем правильность ключа if (md5(Boot::getInstance()->config->default->skey . $match[2] . $match[1]) == $match[0]) { return true; } } return false; }
private static function getControllerRoute($param = null) { return (object) array("controller" => isset($param[0]) ? $param[0] : Boot::getInstance()->config->default->page, "action" => isset($param[1]) && $param[1] ? $param[1] : "index"); }
/** * Очистка лога * @param $file */ public static function clear($file) { //Добавляем в лог file_put_contents(Boot::getInstance()->config->log->dir . $file, ""); }