本文整理汇总了PHP中loader::get_root方法的典型用法代码示例。如果您正苦于以下问题:PHP loader::get_root方法的具体用法?PHP loader::get_root怎么用?PHP loader::get_root使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类loader
的用法示例。
在下文中一共展示了loader::get_root方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($base = null)
{
if (!$base) {
$base = loader::get_root() . '../cache/';
}
$this->set_root($base);
}
示例2: connect
/**
* @param array
* server = path to file
*/
function connect()
{
if (!class_exists('SQLite3', 0)) {
throw new dbal_exception('Sqlite support not compiled with PHP!');
}
if (empty($this->dbname)) {
throw new dbal_exception('Sqlite connect empty database!');
}
// check is relative path (to site root)
// $dbname = (substr($this->dbname, 0, 1) == '/')
// ? substr($this->dbname, 1)
// : ('../' . $this->dbname);
$this->_db_file = loader::get_root($this->dbname);
if (!file_exists($this->_db_file)) {
throw new dbal_exception('No database: ' . $this->_db_file);
}
core::dprint(array('CONNECT %s %s', __CLASS__, $this->_db_file), core::E_SQL);
$error = '';
$this->_connect_id = new SQLite3($this->_db_file, SQLITE3_OPEN_READWRITE);
if ($this->_connect_id) {
$this->_connect_id->exec('PRAGMA short_column_names = 1');
$this->_connect_id->exec('PRAGMA encoding = "UTF-8"');
} else {
throw new dbal_exception('Cant connect to database ' . $this->_db_file);
}
return $this->_connect_id;
}
示例3: configure
/**
* To disable chroot
* [lib_sape_cacher]
* root = cache
*
* @param mixed $config
*/
function configure($config)
{
if (isset($config['root'])) {
$this->set_root(loader::get_root($config['root'] . '/'));
}
if (isset($config['subdir_length'])) {
$this->subdir_length = $config['subdir_length'];
}
}
示例4: __construct
/**
* Create
*/
function __construct()
{
$memcache_domain = 'i' . substr(md5(loader::get_root()), 27);
try {
$this->engines['mem'] = new MultiCacheMemcache();
$this->engines['mem']->set_domain($memcache_domain);
} catch (exception $e) {
// no memcache
$this->engines['mem'] = false;
}
$this->engines['file'] = new MultiCacheFile();
$this->engines['file']->cacheDir = loader::get_root() . '../cache/system';
}
示例5: register
/**
* Register module
* @throws modules_exception
* @return object|bool module
*/
public function register($module)
{
core::dprint('[mod_register] ' . $module);
$module_class = loader::CLASS_PREFIX . $module;
$module_path = loader::get_root() . loader::DIR_MODULES . $module . '/';
$module_file = $module_path . 'module' . loader::DOT_PHP;
if (!fs::file_exists($module_file)) {
throw new modules_exception('Failed to register module ' . $module . '. File does not exists');
}
require_once $module_file;
$this->set($module, new $module_class($module_path));
return $this->get($module);
}
示例6: __construct
function __construct($config)
{
$this->_config = $config;
$this->persistency = @$config['persistency'];
$this->user = $config['login'];
$this->password = $config['password'];
$this->server = isset($config['server']) ? $config['server'] : 'localhost';
$this->dbname = $config['database'];
$this->prefix = $config['prefix'];
$this->root = loader::get_root();
if (is_callable(array($this, 'configure'))) {
$this->configure($config);
}
}
示例7: set_template
/**
* Set root
*/
static function set_template($template)
{
if (defined('IN_EDITOR')) {
self::$template_dir = loader::get_root() . loader::DIR_EDITOR . loader::DIR_TEMPLATES;
} else {
self::$template_dir = loader::get_root() . loader::DIR_TEMPLATES . $template;
}
self::$parser->template_dir = self::$template_dir;
/*
* If using template, compile directory must exists /cache/tpl/{template}
*/
$c_postfix = defined('IN_EDITOR') ? 'editor/' : $template . '/';
self::$parser->compile_dir = loader::get_root() . loader::DIR_TEMPLATES_C . $c_postfix;
self::$parser->cache_dir = loader::get_root() . loader::DIR_TEMPLATES_C . $c_postfix;
}
示例8: get_doctrine
/**
* Create a database handle
* Factory method
* @param array params
* engine - pdo
* type - mysql
*
* @return \Doctrine\DBAL\Connection
*/
public static function get_doctrine($id = self::DEFAULT_CONNECTION, array $config = array())
{
if (empty($config) && !isset(self::$dbs[$id])) {
throw new dbal_exception('Try to get unloaded db connection : ' . $id);
}
$engine = @$config['engine'] ?: 'pdo_mysql';
if (isset(self::$dbs[$id])) {
return self::$dbs[$id];
}
core::dprint('[dbloader|doctrine::get] ' . $id . '(' . $engine . ')');
if ($engine == 'null') {
if (!class_exists('null_db', 0)) {
require "modules/core/dbal/null.php";
}
$conn = new null_db();
self::$dbs[$id] = $conn;
} else {
$d_config = new \Doctrine\DBAL\Configuration();
$d_config->setSQLLogger(new \SatCMS\Modules\Core\Dbal\Doctrine\Logger());
/*
* 'dbname' => @$config['database']
, 'user' => @$config['login'] ?: 'root'
, 'password' => @$config['password']
, 'host' => @$config['server'] ?: 'localhost'
, 'driver' => $engine
, 'path' => (isset($config['path']) ? loader::get_root($config['path']) : null)
*/
$connection_params = array('driver' => $engine, 'prefix' => @$config['prefix'], 'charset' => 'UTF8');
unset($config['engine']);
// fix path
if (isset($config['path'])) {
$config['path'] = loader::get_root($config['path']);
}
// merge params
$connection_params = array_merge($connection_params, $config);
core::dprint_r($connection_params);
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connection_params, $d_config);
self::$dbs[$id] = $conn;
} catch (Exception $e) {
core::dprint($e->getMessage());
return false;
}
}
return self::$dbs[$id];
}
示例9: get
/**
* Create a database handle
* Factory method
* @param array params
*/
public static function get(array $config)
{
$engine = $config['engine'];
if (isset(self::$dbs[$engine])) {
return self::$dbs[$engine];
}
$engine_script = loader::get_root() . loader::DIR_MODULES . 'core/dbal/' . $engine . loader::DOT_PHP;
core::dprint('[db] ' . $engine_script);
fs::req($engine_script, true);
if (!isset($config['server'])) {
$config['server'] = 'localhost';
}
// create instance
$class = "{$engine}_db";
try {
return self::$dbs[$engine] = new $class($config['server'], $config['login'], $config['password'], $config['database'], $config['prefix']);
} catch (dbal_exception $e) {
return false;
}
}
示例10: configure
/**
* To disable chroot
* [lib_cache]
* file_root = cache/system
*
* @param mixed $c
*/
function configure($c)
{
if (isset($c['file_root'])) {
$this->cacheDir = loader::get_root($c['file_root']);
}
}
示例11: ini_set
*/
// header("X-LIGHTTPD-send-file: " . $_GET['id']);
// header("X-Sendfile: " . $_GET['id']);
// header("X-Sendfile: /home/thumb/lexiclips.com/public_html/uploads/videos/original/48.mp4");
require "../modules/core/loader.php";
core::set_debug(666);
ini_set('display_errors', 'on');
error_reporting(E_ALL);
$core = core::get_instance();
if (($user = core::lib('auth')->get_user()) && !$user->payd_user) {
die('Restricted');
} else {
// Send file
$id = functions::request_var('id', '');
$file = loader::get_root() . substr($id, 1);
if (strpos($id, '/uploads/videos') !== false && ($file = loader::get_root() . substr($id, 1)) && file_exists($file) && is_readable($file)) {
$mime_type = 'video/mp4';
// 'video/H264';
if (false !== strpos($id, 'videos/original')) {
$mime_type = "application/force-download";
}
//header('Content-disposition: attachment;filename="' . (basename($file)) . '";');
header('Content-type: ' . $mime_type);
header('Content-length: ' . filesize($file));
header("X-LIGHTTPD-send-file: " . $file);
die;
// readfile($file);
} else {
header(' ', true, 403);
echo "Restticted";
}
示例12: create_upload_dir
/**
* Create uploads
*/
function create_upload_dir()
{
if ($dir = $this->get_uploads_path()) {
$dir = loader::get_root() . $dir;
return mkdir($dir, 0770);
}
return false;
}
示例13: define
<?php
/**
* Sape interface
*
* @package TwoFace
* @author Golovkin Vladimir <r00t@skillz.ru> http://www.skillz.ru
* @copyright SurSoft (C) 2008
* @version $Id: sape.php,v 1.2 2009/08/05 08:45:21 surg30n Exp $
*/
$_su = core::get_instance()->get_cfg_var('sape_user');
if (!empty($_su)) {
if (!defined('_SAPE_USER')) {
define(_SAPE_USER, $_su);
}
require_once loader::get_root() . $_su . '/sape.php';
}
if (!class_exists('SAPE_client')) {
class SAPE_client
{
function SAPE_client($p = array())
{
// mock
core::dprint('[LIB_SAPE] Using mock', core::E_ERROR);
}
}
}
class sape extends SAPE_client
{
function __construct()
{
示例14: set_template
/**
* Set root
*/
static function set_template($template)
{
if (core::in_editor()) {
self::$template_dir = loader::get_public() . loader::DIR_EDITOR . loader::DIR_TEMPLATES;
} else {
self::$template_dir = loader::get_public() . loader::DIR_TEMPLATES . $template;
}
self::$parser->template_dir = self::$template_dir;
/*
* If using template, compile directory must exists /cache/tpl/{template}
*/
$c_postfix = core::in_editor() ? 'editor/' : $template . '/';
self::$parser->compile_dir = loader::get_root(loader::DIR_TEMPLATES_C . $c_postfix);
self::$parser->cache_dir = loader::get_root(loader::DIR_TEMPLATES_C . $c_postfix);
if (!file_exists(self::$parser->compile_dir)) {
mkdir(self::$parser->compile_dir, 0777, true);
// chmod this right
}
/*
if (!file_exists(self::$parser->cache_dir)) {
mkdir(self::$parser->cache_dir, 0777, true); // chmod this right
}
*/
}
示例15: import_langwords
/**
* Parse module langwords into one
* huge array. Used in templates later.
* Module lang start with m_
* [lang.var]
*/
public function import_langwords($module)
{
$lang = $this->get_cfg_var('lang');
$lang_file = loader::get_root() . loader::DIR_MODULES . $module . '/' . loader::DIR_LANGS . $lang;
if (fs::file_exists($lang_file)) {
$temp = parse_ini_file($lang_file, true);
self::dprint('[LANG_INCLUDE] ' . $lang_file . " (x" . count($temp) . ")");
if ('core' == $module) {
$this->langwords = array_merge_recursive($this->langwords, $temp);
} else {
$this->langwords['m_'][$module] = $temp;
}
}
}