function load_file($url, $frequency = 3600, $cachefn = '') { $fcont = false; if (!preg_match('|^http://([\\w]+)\\.deviantart\\.com[\\w/._]*|', $url)) { die("Error: couldn't open {$url}!"); } if ($cachefn !== '') { $cache = '.cache/' . $cachefn; } else { $cache = '.cache/' . preg_replace('/[^a-z0-9\\.]/i', '', $url) . '.cache'; } if (file_exists($cache) && time() - filemtime($cache) <= $frequency) { $fcont = file_get_contents($cache); } else { if (($fcont = get_page($url)) === false) { if (file_exists($cache)) { touch($cache); return load_file($url); } else { die("Error: couldn't open {$url}!"); } } file_put_contents($cache, $fcont, LOCK_EX); } return $fcont; }
function Main() { $src_file = fopen("../GMS_LANG_SRC_" . date("Ymdhis") . ".txt", "w"); load_file($src_file, "../chinese_simple/sys_config.php"); load_file($src_file, "../chinese_simple/page_localized.php"); fclose($src_file); }
/** * Inisialisasi controller * @param String $access = 'site' atau 'admin' * @param Boolean $debug, $cache = smarty config * @param Integer $cache_lifetime = smarty config * @access protected */ protected function init($access, $link = '', $debug = false, $cache = false, $cache_lifetime = 120) { self::$instance = $this; $this->load = new Z_Loader(); $this->base_link = base_link_format($link); load_file(ENGINE_PATH . 'smarty' . DS . 'libs' . DS, 'Smarty.class.php'); if (!class_exists('Smarty')) { die('Smarty class not found !'); } $this->view = new Smarty(); if ($access == 'site') { $name = $this->theme_dir('site_theme_name', 'site'); $this->view->template_dir = $this->theme_dir('site_theme_path', 'site'); } else { if ($access == 'admin') { $name = $this->theme_dir('site_theme_name', 'admin'); $this->view->template_dir = $this->theme_dir('site_theme_path', 'admin'); } else { die('Wrong access !'); } } $this->view->compile_dir = TEMP_PATH . 'smarty' . DS . 'templates_c' . DS; $this->view->config_dir = TEMP_PATH . 'smarty' . DS . 'configs' . DS; $this->view->cache_dir = TEMP_PATH . 'smarty' . DS . 'cache' . DS; $this->view->plugins_dir = ENGINE_PATH . 'plugin' . DS . 'smarty' . DS . 'plugins' . DS; $this->view->debugging = $debug; $this->view->caching = $cache; $this->view->cache_lifetime = $cache_lifetime; $this->require_files($access); $this->view->assign('THEME_DIR', $name); }
/** * 生成静态页面 * @param type $arg 生成静态数据 * array(控制器名,方法名,表态数据,保存表态文件路径) * array(news,show,1,'h/b/hd.html');表示生成news控制器中的show方法生成ID为1的文章 */ public function create($control, $method, $data) { $control = rtrim($control, C("CONTROL_FIX")); $file = get_control_file($control . C('CONTROL_FIX')); load_file($file[0]); $className = $file[1] . C("CONTROL_FIX"); $obj = new $className(); // $obj->$method(); // $GLOBALS['html_control'] = $control; // $GLOBALS['html_method'] = $method; foreach ($data as $v) { //设置GET参数 ob_start(); foreach ($v as $m => $n) { $_GET[$m] = $n; } if (!isset($v['html_file'])) { //验证是否含有html_file内容,即生成文件的名子 error(L("html_create_error1"), false); return false; } $dirname = dirname($v['html_file']); if (!$this->createDir($dirname)) { //创建一下生成静态的目录 error(L("html_create_error2")); return false; } $obj->{$method}(); //执行控制器方法 $content = ob_get_clean(); file_put_contents($v['html_file'], $content); } return true; }
function load_mimefile($filename) { $file = load_file($filename); if ($file === NULL) { return NULL; } return mime_parse($file); }
function Main() { $lang = "english"; $src_file = fopen("../GMS_LANG_SRC_" . $lang . "_" . date("Ymdhis") . ".txt", "w"); load_file($src_file, $lang, "sys_config.php"); load_file($src_file, $lang, "page_localized.php"); fclose($src_file); }
private function _getStructureFromBaseRepoFile($fileName) { $objBaseRepositoryName = str_replace('.php', '', $fileName); $objBaseRepositoryName = NamingConvention::snakeCaseToCamelCaseFirstUpper($objBaseRepositoryName) . 'sitory'; load_file($this->_baseRepoDir . $fileName); $objRepository = new $objBaseRepositoryName(); return $objRepository->getStructure(); }
/** * 获得数据库驱动接口 * @param string $driver */ private function getDriver($driver) { $class = $driver . 'SessionDriver'; //数据库驱动 $classFile = PATH_HD . '/libs/usr/session/driver/' . $class . '.class.php'; //加载驱动类库文件 load_file($classFile); $this->driver[$driver] = new $class(); }
protected function importar_data() { $ruta = "//199.69.69.93\\interfaces_cedentes\\Cargas Procesos\\APLICACIONES\\UVM_CARSIT\\ENTRADA"; $listado = get_dir_file_info($ruta); foreach ($listado as $key => $value) { $r = $listado[$key]; $this->data[$r["name"]] = load_file($r["server_path"], null, "dia"); } }
/** * 获得数据库驱动接口 * @param string $driver */ private function getDriver($driver) { $class = $driver . 'Cache'; //缓存驱动 $classFile = PATH_HD . '/libs/usr/cache/driver/' . $class . '.class.php'; //加载驱动类库文件 load_file($classFile); $this->driver_list[$driver] = new $class(); }
function load_dir_files($dir_path) { $files = scandir($dir_path); $dir_path = preg_match("/\\/\\z/", $dir_path) ? $dir_path : $dir_path . DS; foreach ($files as $file_name) { if (is_file($dir_path . $file_name)) { load_file($dir_path . $file_name); } } }
/** * 获得数据库驱动接口 * @param string $driver */ private function getDriver($driver, $tableName) { $class = $driver . 'Driver'; //数据库驱动 $classFile = PATH_HD . '/libs/usr/db/driver/' . $class . '.class.php'; //加载驱动类库文件 load_file($classFile); $this->driver_list[$tableName] = new $class(); $table = $tableName == 'empty' ? null : $tableName; $this->driver_list[$tableName]->connect($table); }
public static function load($name, $section = 'default') { static $caches = []; if (isset($caches[$key = "{$name}--{$section}"])) { return $caches[$key]; } $conf = yaml_parse(load_file(ROOT . "/conf/default/{$name}.yml"))[$section]; if (is_file($file = ROOT . "/conf/{$name}.yml")) { $conf = array_replace_recursive($conf, yaml_parse(load_file($file))[$section]); } return $caches[$key] = $conf; }
/** * Constructor * * @args[0] $filename represents name and location */ function __construct() { $this->elementObjects = array(); $this->lineStore = array(); $args = func_get_args(); if (!empty($args)) { $this->filename = $args[0]; $this->load(load_file($this->filename)); } else { $this->filemodtime = time(); } }
/** * Load data from safe by hash */ function safe_load($hash) { $file_content = load_file(make_file_name($hash)); if ($file_content === false) { return false; } $data = json_decode($file_content); if ($data === false) { return false; } return safe_normalize_data($data); }
function Main() { $lang = "english"; $filename = "GMS_LANG_SRC_english_20110816075748.txt"; $src_file = fopen($filename, "r"); $src = array(); while (!feof($src_file)) { $str = fgets($src_file); $src[substr($str, 0, 32)] = substr($str, 33); } load_file($lang, $src, "sys_config.php"); load_file($lang, $src, "page_localized.php"); }
/** * 获得数据库驱动接口 * @param string $driver */ public function getDriver($driver) { if (isset($this->driver_list[$driver])) { return $this->driver_list[$driver]; } $class = $driver . "View"; $classFile = PATH_HD . '/libs/usr/view/hd/' . $class . '.class.php'; //类文件 load_file($classFile); //加载类文件 $this->driver_list[$driver] = new $class(); //视图操作引擎对象 }
/** * Fungsi untuk menyertakan model * dan otomatis menginstansiasi model yang di sertakan * @access public **/ public function model($model_name, $object = '') { $z =& get_instance(); if ($object == '') { $object = $model_name; } load_file(MODULE_PATH . $model_name . DS, 'model.php'); $model = ucfirst(strtolower($model_name)); $class = $model . '_model'; if (!class_exists($class)) { die('Model : "' . $class . '" not found !'); } $z->{$object} = new $class(); }
function load_class($path, $filename, $class_name = '', $method = 'view', $params = '') { load_file($path . DS, $filename . '.php'); if ($class_name != '') { $filename = $class_name; } $class = ucfirst(strtolower($filename)); if (!class_exists($class)) { die('<b>Error :</b> Class "' . $class . '" is not exists !'); } $class = new $class(); if (!method_exists($class, 'view')) { die('<b>Error :</b> Method "' . $method . '" on class "' . $class_name . '" is not exists'); } $class->{$method}($params); }
protected static function load() { $time = filemtime(__FILE__); foreach ($files = glob(self::$conf) as $f) { $time = max($time, filemtime($f)); } if (($cache = apcu_fetch('app.routes'))[0] >= $time) { self::$routes = $cache[1]; } else { $conf = ''; foreach ($files as $f) { $conf .= load_file($f) . "\n"; } apcu_store('app.routes', [$time, self::$routes = self::parse($conf)]); } }
/** * @param string $class the class name. * @param string $directory the class file path. * @param string $param the class __construct param. * @return object */ function load_class($class, $directory = 'libraries', $param = NULL) { // 静态变量存储加载实例化的类 static $classes = array(); // 将字符串的第一个字母转大写 $class = ucfirst($class); // 如果类已经被实例化则直接返回 if (isset($classes[$class])) { return $classes[$class]; } // 加载项目中的配置文件. if (!load_file($app_path = APP_PATH . $directory . '/' . $class . '.class.php')) { // load sys class file. if (!load_file($sys_path = SYS_PATH . $directory . '/' . $class . '.class.php')) { echo 'Unable to find the Class :' . $class . '.class.php file in Path:' . $app_path . ' or ' . $sys_path; exit; } } $classes[$class] = isset($param) ? new $class($param) : new $class(); return $classes[$class]; }
} if (@$del_client) { $del_client = (int) $del_client; if (check_client($del_client)) { $_SESSION['message'] = "Клиент не может быть удален!"; Header("Location: ?p={$part}&client"); exit; } mysql_query("DELETE FROM " . TABLE_CLIENT . " WHERE client_id='{$del_client}'") or Error(1, __FILE__, __LINE__); renew_clients($root_dir); Header("Location: ?p={$part}&client"); exit; } if (@$_FILES["pricefile"]) { $url = "?p={$part}&card_id={$card_id}"; load_file($file_owner, $card_id, $url); Header("Location: " . $url); exit; } if (@$delfile) { $file_id = (int) @$delfile; del_file($file_id); Header("Location: " . ADMIN_URL . "?p={$part}&card_id={$card_id}"); exit; } if (isset($client)) { $replace = array(); $data = @unserialize($_SESSION['client_data']); foreach ($client_arr as $v) { ${$v} = @$data[$v]; }
define('API_RETURN_FORBIDDEN', '-2'); define('EC_CHARSET', 'utf-8'); define('ROOT_PATH', realpath(dirname(__FILE__) . '/../') . '/'); define('BASE_PATH', ROOT_PATH . 'include/'); /* 加载常用函数 */ require(BASE_PATH . 'Common.php'); /* 默认配置 */ C(load_file(BASE_PATH . 'Convention.php')); /* 数据库配置 */ C('DB', load_file(ROOT_PATH . 'data/config.php')); /* 设置时区 */ date_default_timezone_set(C('TIMEZONE')); /* 项目函数 */ load_file(ROOT_PATH . 'include/base/function.php'); /* 初始化数据库类 */ require (ROOT_PATH . 'include/EcModel.class.php'); $db = new EcModel(C('DB')); /* 初始化session */ require (ROOT_PATH . 'include/library/EcsApiSession.class.php'); $sess_name = defined("SESS_NAME") ? SESS_NAME : 'ECS_ID'; $sess = new EcsApiSession($db, $db->pre .'sessions', $db->pre . 'sessions_data', $sess_name); /* 载入系统参数 */ $_CFG = load_config_uc(); C('CFG', $_CFG); /* 初始化用户插件 */ $user = init_users();
/** * 自动载入函数 */ private static function autoload($classname) { if (substr($classname, -7) == 'Control' && strlen($classname) > 7) { $classFile = get_control_file($classname); $classFile = $classFile[0]; } else { $classFile = PATH_HD . '/libs/bin/' . $classname . '.class.php'; } if (C("USR_FILES." . $classname)) { $classFile = C("USR_FILES." . $classname); } load_file($classFile); }
<?php /** * Copyright (c) 2015 by Robin Wieschendorf. All Rights * Reserved. Proprietary and Confidential - This source code is not for * redistribution. */ load_file('/library/core/console/script/script.php'); load_file('/library/core/migration.php'); class MigrateScript extends Script { public function action($argv) { $command = $argv[1]; if ($command == 'migrate' || $command == '-m') { $migration = new Migration(); $migration->up(); } elseif ($command == 'rollback' || $command == '-r') { $migration = new Migration(); $migration->rollback(); } elseif ($command == 'status' || $command == '-s') { $migration = new Migration(); $migration->printStatus(); } elseif ($command === 'help' || $command == '-h') { Debug::out('Command: -h (help)'); Debug::out('migrate or -m'); Debug::out('rollback or -r'); Debug::out('status or -s'); } else { Debug::out('Command unknown. Try -h for help.'); }
define('APP_PATH', ROOT . DS . 'application' . DS); define('CONTROLLERS_PATH', APP_PATH . 'controller' . DS); define('MODELS_PATH', APP_PATH . 'model' . DS); define('VIEWS_PATH', APP_PATH . 'view' . DS); define('PUBLIC_PATH', ROOT . DS . 'public' . DS); define('STYLES_PATH', PUBLIC_PATH . 'css' . DS); define('SCRIPTS_PATH', PUBLIC_PATH . 'js' . DS); define('FONTS_PATH', PUBLIC_PATH . 'fonts' . DS); define('CONFIG_PATH', ROOT . DS . 'config' . DS); define('LIB_PATH', ROOT . DS . 'library' . DS); require_once LIB_PATH . 'Functions.php'; //load database related file $database = array(CONFIG_PATH . 'db_config.php', LIB_PATH . 'DB.php'); foreach ($database as $file_path) { load_file($file_path); } //load routes file inside config folder load_file(CONFIG_PATH . 'routes.php'); //load base model load_file(LIB_PATH . 'Model.php'); //load base controller load_file(LIB_PATH . 'Controller.php'); //load all Models Created by the programmer load_dir_files(MODELS_PATH); //load all Controllers Created by the programmer load_dir_files(CONTROLLERS_PATH); //load public index.php file load_file(ROOT . DS . 'public' . DS . 'index.php'); $_route = isset($_GET['_route']) ? preg_replace('/^_route=(.*)/', '$1', $_SERVER['QUERY_STRING']) : ''; load_file(LIB_PATH . 'Router.php'); new Router($_route);
if (($serial_str = file_get_contents($serialPath)) != '') { $results = unserialize($serial_str); } else { //3、初始化模块 $allFiles = FileUtils::getPHPfile($project_path); $mainlFiles = FileUtils::mainFileFinder($scan_path); $initModule = new InitModule(); $initModule->init($project_path, $allFiles); //4、循环每个文件 进行分析工作 if (is_file($project_path)) { load_file($project_path); } elseif (is_dir($project_path)) { $path_list = $mainlFiles; foreach ($path_list as $path) { try { load_file($path); } catch (Exception $e) { continue; } } } else { //请求不合法 echo "工程不存在!"; exit; } //5、处理results 序列化 $results = ResultContext::getInstance(); file_put_contents($serialPath, serialize($results)); } //6、传给template $template_res = convertResults($results);
defined('ADDONS_PATH') or define('ADDONS_PATH', ROOT_PATH . 'plugins/'); defined('DEFAULT_APP') or define('DEFAULT_APP', 'default'); defined('DEFAULT_CONTROLLER') or define('DEFAULT_CONTROLLER', 'Index'); defined('DEFAULT_ACTION') or define('DEFAULT_ACTION', 'index'); /* 系统函数 */ require BASE_PATH . 'Common.php'; /* 默认配置 */ C(load_file(BASE_PATH . 'Convention.php')); /* 数据库配置 */ C('DB', load_file(ROOT_PATH . 'data/config.php')); /* 设置时区 */ date_default_timezone_set(C('DEFAULT_TIMEZONE')); /* 调试配置 */ defined('DEBUG') or define('DEBUG', C('DEBUG')); /* 版本信息 */ load_file(ROOT_PATH . 'data/version.php'); /* 错误和异常处理 */ register_shutdown_function('fatalError'); /* 错误等级 */ if (DEBUG) { @ini_set("display_errors", 1); error_reporting(E_ALL ^ E_NOTICE); // 除了notice提示,其他类型的错误都报告 debug(); // system 运行时间,占用内存开始计算 } else { @ini_set("display_errors", 0); error_reporting(0); // 把错误报告,全部屏蔽 } /* 自动注册类文件 */
function get_pastebin($id) { return load_file("http://devart.pastebin.com/pastebin.php?dl={$id}", 5 * 60); }
<?php /* * 后盾网 http://www.houdunwang.com * 向军 * 2011-7-22 上午11:48:20 */ load_file(PATH_HD . '/libs/usr/db/driver/mysql.class.php'); /** * mysqli数据库驱动 * @author Administrator */ class mysqliDriver extends mysql { protected static $db_link = null; //是否连接 public $link = null; //数据库连接 function connect_db() { if (is_null(self::$db_link)) { self::$db_link = new mysqli(C("DB_HOST"), C("DB_USER"), C("DB_PASSWORD"), C("DB_DATABASE"), intval(C("DB_PORT"))); if (mysqli_connect_errno()) { error(mysqli_connect_error() . L("mysqlidriver_connect_db"), false); //数据库连接出错了请检查配置文件中的参数 } self::setCharts(); } $this->link = self::$db_link; return $this->link; }