コード例 #1
0
ファイル: cache.apc.php プロジェクト: Sywooch/dobox
 public function init()
 {
     parent::init();
     if (!func::extensionLoaded('apc')) {
         throw new Exception('CApcCache requires PHP apc extension to be loaded.');
     }
 }
コード例 #2
0
ファイル: cache.eaccelerator.php プロジェクト: Sywooch/dobox
 public function init()
 {
     parent::init();
     if (!function_exists('eaccelerator_get')) {
         throw new Exception('CEAcceleratorCache requires PHP eAccelerator extension to be loaded, enabled or compiled with the "--with-eaccelerator-shared-memory" option.');
     }
 }
コード例 #3
0
ファイル: Morfy.php プロジェクト: zorca/morfy
 /**
  * Constructor.
  *
  * @access protected
  */
 protected function __construct()
 {
     // Init Config
     Config::init();
     // Turn on output buffering
     ob_start();
     // Display Errors
     Config::get('system.errors.display') and error_reporting(-1);
     // Set internal encoding
     function_exists('mb_language') and mb_language('uni');
     function_exists('mb_regex_encoding') and mb_regex_encoding(Config::get('system.charset'));
     function_exists('mb_internal_encoding') and mb_internal_encoding(Config::get('system.charset'));
     // Set default timezone
     date_default_timezone_set(Config::get('system.timezone'));
     // Start the session
     Session::start();
     // Init Cache
     Cache::init();
     // Init Plugins
     Plugins::init();
     // Init Blocks
     Blocks::init();
     // Init Pages
     Pages::init();
     // Flush (send) the output buffer and turn off output buffering
     ob_end_flush();
 }
コード例 #4
0
ファイル: cache.php プロジェクト: almaopen/SwissMVC
 public static function delete($key)
 {
     if (Cache::$_selfInstance == null) {
         Cache::init();
     }
     Cache::$_selfInstance->_mc->delete($key);
 }
コード例 #5
0
ファイル: Lastfm.class.php プロジェクト: n8kowald/php-classes
 /**
  * getLovedSongs()
  * Gets user's loved songs. From cache file or from the feed.
  *
  * @return array $songs Returns formatted songs
  */
 public static function getLovedSongs($username = '', $num_songs = 30)
 {
     if (!self::isValidUsername($username)) {
         return array(self::$error);
     }
     // Check Feeder and Cache classes are accessible
     if (!class_exists('Feeder')) {
         return array('Could not find Feeder.class.php.');
     }
     if (!class_exists('Cache')) {
         return array('Could not find Cache.class.php.');
     }
     self::$username = $username;
     self::$num_songs = $num_songs;
     $cache_filename = self::$username . '-loved-tracks.cache';
     $cache_life = 86400;
     // 1 day
     Cache::init($cache_filename, $cache_life);
     if (Cache::cacheFileExists()) {
         return Cache::getCache();
     }
     $song_data = Feeder::getItems(self::getLovedSongsFeed(), self::$num_songs, array('title', 'link'));
     if (!is_array($song_data)) {
         self::$error = "Last.fm loved tracks feed not found";
         return array(self::$error);
     }
     $songs = self::formatSongData($song_data);
     Cache::setCache($songs);
     return $songs;
 }
コード例 #6
0
ファイル: BaseTestCase.php プロジェクト: ekowabaka/cfx
 protected function setUp()
 {
     parent::setUp();
     error_reporting(E_ALL ^ E_NOTICE);
     Cache::init('volatile');
     $_SESSION["user_id"] = "1";
     Application::$config['log_level'] = 550;
 }
コード例 #7
0
ファイル: Cache.class.php プロジェクト: jayxtt999/me
 /**
  * 取得缓存类实例
  * @static
  * @access public
  * @return mixed
  */
 static function getInstance($type = '', $options = array())
 {
     static $_instance = array();
     $guid = $type . to_guid_string($options);
     if (!isset($_instance[$guid])) {
         $obj = new Cache();
         $_instance[$guid] = $obj->init($type, $options);
     }
     return $_instance[$guid];
 }
コード例 #8
0
ファイル: listModel.php プロジェクト: akaiidle/newborn
 public function getCode()
 {
     $cache = Cache::init('memcache')->get('code');
     if ($cache) {
         return $cache;
     }
     $res = $this->getColumn(array('id' => 4), 'code');
     Cache::init('memcache')->set('code', $res);
     return $res;
 }
コード例 #9
0
ファイル: Model.class.php プロジェクト: jayxtt999/me
 static final function getCache()
 {
     if (isset(self::$cache)) {
         return self::$cache;
     } else {
         $cache = new Cache();
         $cache->init(C('cache'));
         self::$cache = $cache;
         return $cache;
     }
 }
コード例 #10
0
ファイル: Core.php プロジェクト: wave-framework/wave
 public static function bootstrap(array $config)
 {
     if (!isset($config['mode'])) {
         $config['mode'] = Config::get('deploy')->mode;
     }
     Debug::init($config['debug']);
     self::$_MODE = $config['mode'];
     self::setErrorReporting($config['mode'] !== self::MODE_PRODUCTION);
     Cache::init();
     Debug::getInstance()->addCheckpoint('bootstrapped');
 }
コード例 #11
0
 /**
  * 清除Memcache缓存
  */
 public function del_memcache()
 {
     if (!IS_POST) {
         $this->error("页面不存在!");
     }
     $host = Q("post.host");
     $port = Q("post.port", null, "intval");
     $time = Q("post.time", null, "intval");
     $cache = Cache::init(array("driver" => "memcache", "host" => array("host" => $host, "port" => $port)));
     $time ? $cache->delAll($time) : $cache->delAll();
     $url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
     $this->success('缓存已经全部删除成功', $url);
 }
コード例 #12
0
ファイル: FileCache.php プロジェクト: aliazizi/CShop
 public function init($cachePath = null)
 {
     parent::init();
     if ($cachePath) {
         $this->cachePath = $cachePath;
     }
     if ($this->cachePath === null) {
         $this->cachePath = CShop::$corepath . DIRECTORY_SEPARATOR . 'cache';
     }
     if (!is_dir($this->cachePath)) {
         mkdir($this->cachePath, 0777, true);
     }
 }
コード例 #13
0
 /**
  * getBooksFromShelf()
  * Gets the array of books from a cache_file if found (and less than a week old).
  * If no cache_file is found it creates this array of books and adds them to the cache_file - for fast loading next time
  *
  * @return array Returns a nicely formatted array of books
  */
 private static function getBooksFromShelf()
 {
     $cache_filename = self::$goodreads_id . '-' . self::$shelf . '.cache';
     $cache_life = 604800;
     // 1 week
     Cache::init($cache_filename, $cache_life);
     if (Cache::cacheFileExists()) {
         return Cache::getCache();
     }
     $book_data = Feeder::getItems(self::getGoodreadsFeed(), self::$num_books, array('title', 'author_name'));
     if (!is_array($book_data)) {
         self::$error = "Goodreads feed does not exist. Check user: "******" and shelf: '" . self::$shelf . "' exist";
         return array(self::$error);
     }
     $books = self::formatBookData($book_data);
     Cache::setCache($books);
     return $books;
 }
コード例 #14
0
 /**
  * 缓存选择
  * @param string $key 缓存键名
  * @param number $set 是否写入缓存,0为读取,1为写入
  * @param string $value 缓存内容
  * @param string $prefix 缓存的前缀
  * @param string $mod 缓存模式
  * @param number $expire 缓存时间
  * @param string $dir 缓存目录
  * @return boolean string $result 读取模式时为读取的内容,写入模式时为0或1
  */
 public function cache_collect($key, $set = 0, $value = "", $prefix = "", $mod = "file", $expire = 36000, $dir = "")
 {
     if ($mod == "file") {
         if ($dir) {
             $driver = array("driver" => $mod, "dir" => $dir);
         } else {
             $driver = array("driver" => $mod, "dir" => ROOT_PATH . "Cache/Data");
         }
     } elseif ($mod == "memcache") {
         $driver = array("driver" => $mod, "host" => array("host" => "127.0.0.1", "port" => 11211), "timeout" => 1, "weight" => 1);
     }
     $driver["zip"] = true;
     $driver["prefix"] = $prefix;
     $driver["expire"] = $expire;
     $cache = Cache::init($driver);
     if ($set) {
         $result = $cache->{$key} = $value;
     } else {
         $result = $cache->{$key};
     }
     return $result;
 }
コード例 #15
0
ファイル: admin.cache.php プロジェクト: Andreyjktl/Cotonti
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('admin', 'a');
cot_block($usr['isadmin']);
$t = new XTemplate(cot_tplfile('admin.cache', 'core'));
$adminpath[] = array(cot_url('admin', 'm=other'), $L['Other']);
$adminpath[] = array(cot_url('admin', 'm=cache'), $L['adm_internalcache']);
$adminsubtitle = $L['adm_internalcache'];
/* === Hook === */
foreach (cot_getextplugins('admin.cache.first') as $pl) {
    include $pl;
}
/* ===== */
if (!$cache) {
    // Enforce cache loading
    require_once $cfg['system_dir'] . '/cache.php';
    $cache = new Cache();
    $cache->init();
}
if ($a == 'purge' && $cache) {
    if (cot_check_xg() && $cache->clear()) {
        $db->update($db_users, array('user_auth' => ''), "user_auth != ''");
        cot_message('adm_purgeall_done');
    } else {
        cot_error('Error');
    }
} elseif ($a == 'delete') {
    cot_check_xg();
    $name = $db->prep(cot_import('name', 'G', 'TXT'));
    $db->delete($db_cache, "c_name = '{$name}'") ? cot_message('adm_delcacheitem') : cot_error('Error');
}
if ($cache && $cache->mem) {
    $info = $cache->get_info();
コード例 #16
0
ファイル: cache.php プロジェクト: 62BRAINS/EPESI
        }
        if ($name === null) {
            $this->data = array();
        } else {
            unset($this->data[$name]);
        }
        $this->save();
    }
}
class Cache
{
    protected static $cache_object;
    public static function init($cache_object)
    {
        self::$cache_object = $cache_object;
    }
    public static function get($name, $default = null)
    {
        return self::$cache_object->get($name, $default);
    }
    public static function set($name, $value)
    {
        return self::$cache_object->set($name, $value);
    }
    public static function clear($name = null)
    {
        return self::$cache_object->clear($name);
    }
}
Cache::init(new FileCache(DATA_DIR . '/cache/common_cache.php'));
コード例 #17
0
ファイル: AppTest.php プロジェクト: Selwyn-b/elefant
 /**
  * Initializes the `$i18n`, `$cache`, `$page`, and `$tpl` objects
  * for use with the controller in testing handlers.
  */
 public static function setUpBeforeClass()
 {
     require_once 'lib/Functions.php';
     require_once 'lib/DB.php';
     error_reporting(E_ALL & ~E_NOTICE);
     if (!defined('ELEFANT_ENV')) {
         define('ELEFANT_ENV', 'config');
     }
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en';
     $_SERVER['REQUEST_URI'] = '/';
     global $conf, $i18n, $cache, $page, $tpl;
     // Set up the database connection to be in memory
     $conf = parse_ini_file('conf/config.php', TRUE);
     $conf['Database'] = array('master' => array('driver' => 'sqlite', 'file' => ':memory:'));
     // Initializes PDO connection automatically
     foreach (sql_split(file_get_contents('conf/install_sqlite.sql')) as $sql) {
         if (!DB::execute($sql)) {
             die('SQL failed: ' . $sql);
         }
     }
     // Create default admin and member users
     $date = gmdate('Y-m-d H:i:s');
     DB::execute("insert into `user` (id, email, password, session_id, expires, name, type, signed_up, updated, userdata) values (1, ?, ?, null, ?, 'Admin User', 'admin', ?, ?, ?)", '*****@*****.**', User::encrypt_pass('testing'), $date, $date, $date, json_encode(array()));
     DB::execute("insert into `user` (id, email, password, session_id, expires, name, type, signed_up, updated, userdata) values (2, ?, ?, null, ?, 'Joe Member', 'member', ?, ?, ?)", '*****@*****.**', User::encrypt_pass('testing'), $date, $date, $date, json_encode(array()));
     $i18n = new I18n('lang', array('negotiation_method' => 'http'));
     $page = new Page();
     self::$c = new Controller();
     $tpl = new Template('utf-8', self::$c);
     $cache = Cache::init(array());
     self::$c->template($tpl);
     self::$c->cache($cache);
     self::$c->page($page);
     self::$c->i18n($i18n);
 }
コード例 #18
0
ファイル: class.Cache.php プロジェクト: Kocal/LoLAPI
        if (!self::exists($fileName)) {
            return true;
        }
        $datas = self::get($fileName);
        if (time() > $datas->timestamp + self::$expire) {
            return true;
        }
        return false;
    }
    /**
     * Récupère des données mises en cache
     * @param string nom du fichier de cache
     * @return array Données mises en cache
     */
    public static function get($fileName)
    {
        return unserialize(file_get_contents(self::path($fileName)));
    }
    private static function path($fileName)
    {
        $fileName = self::sanitize($fileName);
        return self::$path . '/' . $fileName;
    }
    private static function sanitize($fileName)
    {
        $fileName = str_replace(array(DIRECTORY_SEPARATOR, '/', '?'), '.', $fileName);
        return $fileName;
    }
}
Cache::init();
コード例 #19
0
ファイル: Boot.php プロジェクト: sxau-web-team/wish-web
function S($name, $value = false, $expire = null, $options = array())
{
    static $_data = array();
    $cacheObj = Cache::init($options);
    if (is_null($value)) {
        return $cacheObj->del($name);
    }
    $driver = isset($options['Driver']) ? $options['Driver'] : '';
    $key = $name . $driver;
    if ($value === false) {
        if (isset($_data[$key])) {
            Debug::$cache['read_s']++;
            return $_data[$key];
        } else {
            return $cacheObj->get($name, $expire);
        }
    }
    $cacheObj->set($name, $value, $expire);
    $_data[$key] = $value;
    return true;
}
コード例 #20
0
ファイル: FrontController.php プロジェクト: R-J/elefant
	/**
	 * The front controller only has one static method, `run()`, which
	 * 
	 */
	public static function run ($argv, $argc) {
		/**
		 * For compatibility with PHP 5.4's built-in web server, we bypass
		 * the front controller for requests with file extensions and
		 * return false.
		 */
		if (php_sapi_name () === 'cli-server' && isset ($_SERVER['REQUEST_URI']) && preg_match ('/\.[a-zA-Z0-9]+$/', parse_url ($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
			return false;
		}

		/**
		 * Normalize slashes for servers that are still poorly
		 * configured...
		 */
		if (get_magic_quotes_gpc ()) {
			function stripslashes_gpc (&$value) {
				$value = stripslashes ($value);
			}
			array_walk_recursive ($_GET, 'stripslashes_gpc');
			array_walk_recursive ($_POST, 'stripslashes_gpc');
			array_walk_recursive ($_COOKIE, 'stripslashes_gpc');
			array_walk_recursive ($_REQUEST, 'stripslashes_gpc');
		}

		/**
		 * Check ELEFANT_ENV environment variable to determine which
		 * configuration to load. Also include the Elefant version,
		 * autoloader, and core functions, and set the default
		 * timezone to avoid warnings in date functions.
		 */
		define ('ELEFANT_ENV', getenv ('ELEFANT_ENV') ? getenv ('ELEFANT_ENV') : 'config');
		require ('conf/version.php');
		require ('lib/Autoloader.php');
		require ('lib/Functions.php');
		date_default_timezone_set(conf ('General', 'timezone'));
		ini_set ('session.cookie_httponly', 1);
		ini_set ('session.use_only_cookies', 1);

		/**
		 * Set the default error reporting level to All except Notices,
		 * and turn off displaying errors. Error handling/debugging can
		 * be done by setting conf[General][debug] to true, causing full
		 * debug traces to be displayed with highlighted code in the
		 * browser (*for development purposes only*), or by checking
		 * the error log for errors.
		 */
		error_reporting (E_ALL & ~E_NOTICE);
		if (conf ('General', 'display_errors')) {
			ini_set ('display_errors', 'On');
		} else {
			ini_set ('display_errors', 'Off');
		}

		/**
		 * Enable the debugger if conf[General][debug] is true.
		 */
		require ('lib/Debugger.php');
		Debugger::start (conf ('General', 'debug'));

		/**
		 * Include the core libraries used by the front controller
		 * to dispatch and respond to requests.
		 */
		require ('lib/DB.php');
		require ('lib/Page.php');
		require ('lib/I18n.php');
		require ('lib/Controller.php');
		require ('lib/Template.php');
		require ('lib/View.php');

		/**
		 * If we're on the command line, set the request to use
		 * the first argument passed to the script.
		 */
		if (defined ('STDIN')) {
			$_SERVER['REQUEST_URI'] = '/' . $argv[1];
		}

		/**
		 * Initialize some core objects. These function as singletons
		 * because only one instance of them per request is desired
		 * (no duplicate execution for things like loading translation
		 * files).
		 */
		$i18n = new I18n ('lang', conf ('I18n'));
		$page = new Page;
		$controller = new Controller (conf ('Hooks'));
		$tpl = new Template (conf ('General', 'charset'), $controller);
		$controller->page ($page);
		$controller->i18n ($i18n);
		$controller->template ($tpl);
		View::init ($tpl);

		/**
		 * Check for a bootstrap.php file in the root of the site
		 * and if found, use it for additional app-level configurations
		 * (Dependency Injection, custom logging settings, etc.).
		 */
		if (file_exists ('bootstrap.php')) {
			require ('bootstrap.php');
		}

		/**
		 * Initialize the built-in cache support. Provides a
		 * consistent cache API (based on Memcache) so we can always
		 * include caching in our handlers and in the front controller.
		 */
		if (! isset ($cache) || ! is_object ($cache)) {
			$cache = Cache::init (conf ('Cache'));
		}
		$controller->cache ($cache);

		/**
		 * Provide global access to core objects, although the preferred
		 * way of accessing these is via the Controller object (`$this`
		 * in handlers).
		 */
		$GLOBALS['i18n'] = $i18n;
		$GLOBALS['page'] = $page;
		$GLOBALS['controller'] = $controller;
		$GLOBALS['tpl'] = $tpl;
		$GLOBALS['cache'] = $cache;

		/**
		 * Run any config level route overrides.
		 */
		if (file_exists ('conf/routes.php')) {
			$_routes = parse_ini_file ('conf/routes.php',true);
			if (isset($_routes['Disable'])){
			foreach ($_routes['Disable'] as $_route => $_strict) {
				if (
					(!$_strict && strpos($_SERVER['REQUEST_URI'],$_route) === 0 && $_SERVER['REQUEST_URI'] !== $_route) //match from left, exclude exact
					|| 
					($_strict && $_SERVER['REQUEST_URI'] == $_route) // match exact
				) {
					$page->body = $controller->run (conf ('General', 'error_handler'), array (
						'code' => 404,
						'title' => 'Page not found.',
						'message' => ''
					));
					echo $page->render ($tpl, $controller); // render 404 page and exit
					return true;
				}
			}}
			if (isset($_routes['Redirect'])){
			foreach ($_routes['Redirect'] as $_old => $_new) {
				if ($_old !== $_new && $_SERVER['REQUEST_URI'] == $_old) $controller->redirect($_new);
			}}
			if (isset($_routes['Alias'])){
			foreach ($_routes['Alias'] as $_old => $_new) {
				if (strpos($_SERVER['REQUEST_URI'],$_old) === 0) {
					$_SERVER['REQUEST_URI'] = str_replace($_old,$_new,$_SERVER['REQUEST_URI']);
					break;
				}
			}}
			unset($_routes);
		}

		/**
		 * Route the request to the appropriate handler and get
		 * the handler's response.
		 */
		if ($i18n->url_includes_lang) {
			$handler = $controller->route ($i18n->new_request_uri);
		} else {
			$handler = $controller->route ($_SERVER['REQUEST_URI']);
		}
		$page->body = $controller->handle ($handler, false);

		/**
		 * Control caching of the response
		 */
		if (conf ('Cache', 'control') && !conf ('General', 'debug')) {
			/* Cache control is ON */
			if (session_id () === '' && $page->cache_control)
			{
				if (isset ($_SERVER["SERVER_SOFTWARE"]) && strpos ($_SERVER["SERVER_SOFTWARE"],"nginx") !== false) {
					/* Allow NGINX to cache this request  - see http://wiki.nginx.org/X-accel */
					$controller->header ('X-Accel-Buffering: yes');
					$controller->header ('X-Accel-Expires: ' . conf ('Cache', 'expires'));
				}
				/* Standard http headers */
				$controller->header ('Cache-Control: public, no-cache="set-cookie", must-revalidate, proxy-revalidate, max-age=0');
				$controller->header ('Pragma: public');
				$controller->header ('Expires: ' . gmdate ('D, d M Y H:i:s', time () + conf ('Cache', 'expires')) . ' GMT');
			} else {
				if (isset ($_SERVER["SERVER_SOFTWARE"]) && strpos ($_SERVER["SERVER_SOFTWARE"],"nginx") !== false) {
					/* Do NOT allow NGINX to cache this request - see http://wiki.nginx.org/X-accel */
					$controller->header ('X-Accel-Buffering: no');
					$controller->header ('X-Accel-Expires: 0');
				}

				/* Standard http headers */
				$controller->header ('Pragma: no-cache');
				$controller->header ('Cache-Control: no-cache, must-revalidate');
				$controller->header ('Expires: 0');
			}
		} else {
			if (isset ($_SERVER["SERVER_SOFTWARE"]) && strpos ($_SERVER["SERVER_SOFTWARE"],"nginx") !== false) {
				/* Do NOT allow NGINX to cache this request by default  - see http://wiki.nginx.org/X-accel */
				$controller->header ('X-Accel-Buffering: no');
				$controller->header ('X-Accel-Expires: 0');
			}
		}

		/**
		 * Render and send the output to the client, using gzip
		 * compression if conf[General][compress_output] is true.
		 */
		$out = $page->render ($tpl, $controller);
		if (extension_loaded ('zlib') && conf ('General', 'compress_output')) {
			ini_set ('zlib.output_compression', 4096);
		}
		@session_write_close ();
		echo $out;
		return true;
	}
コード例 #21
0
ファイル: wyf_bootstrap.php プロジェクト: nthc/cfx
add_include_path($directoryPath . "constraints", false);
add_include_path($directoryPath . "login", false);
add_include_path($directoryPath . "logout", false);
add_include_path($directoryPath . "password_history", false);
add_include_path($directoryPath . "role_validity", false);
add_include_path($directoryPath . "roles", false);
add_include_path($directoryPath . "users", false);
add_include_path($directoryPath . "users_roles", false);
//Add lib for auth
add_include_path(__DIR__ . "/lib", false);
// Load the applications configuration file and define the home
require "app/config.php";
define("SOFTWARE_HOME", $config['home']);
// Add the script which contains the third party libraries
require "app/includes.php";
// Setup the global variables needed by the redirected packages
global $redirectedPackage;
global $packageSchema;
$selected = getenv('CFX_SELECTED_DATABASE') !== false ? getenv('CFX_SELECTED_DATABASE') : $selected;
// Setup the database driver and other boilerplate stuff
$dbDriver = $config['db'][$selected]['driver'];
$dbDriverClass = Application::camelize($dbDriver);
add_include_path(Application::getWyfHome("models/datastores/databases/{$dbDriver}"));
Db::$defaultDatabase = $selected;
SQLDBDataStore::$activeDriverClass = $dbDriverClass;
Application::$config = $config;
Application::$prefix = $config['prefix'];
Cache::init($config['cache']['method']);
define('CACHE_MODELS', $config['cache']['models']);
define('CACHE_PREFIX', "");
define('ENABLE_AUDIT_TRAILS', $config['audit_trails']);
コード例 #22
0
ファイル: cache.php プロジェクト: cretzu89/EPESI
        }
        if ($name === null) {
            $this->data = array();
        } else {
            unset($this->data[$name]);
        }
        $this->save();
    }
}
class Cache
{
    protected static $cache_object;
    public static function init($cache_object)
    {
        self::$cache_object = $cache_object;
    }
    public static function get($name, $default = null)
    {
        return self::$cache_object->get($name, $default);
    }
    public static function set($name, $value)
    {
        return self::$cache_object->set($name, $value);
    }
    public static function clear($name = null)
    {
        return self::$cache_object->clear($name);
    }
}
Cache::init(new FileCache(EPESI_LOCAL_DIR . '/' . DATA_DIR . '/cache/common_cache.php'));
コード例 #23
0
 /**
  * Constructor
  *
  * Initialises the internal app cache and the
  * HTTP client to use for requests.
  */
 public function __construct()
 {
     $this->cache = Cache::init();
     $this->client = new \GuzzleHttp\Client(array('defaults' => array('timeout' => 35)));
 }
コード例 #24
0
ファイル: model.class.php プロジェクト: wangxian/ePHP
 /**
  * 和findAll()差不多
  * 返回的数据结构:array('data'=>array(....), 'data_count'=>总数据数)
  *
  * @return array $data 结构:array('data'=>array(....), 'data_count'=>10)
  */
 public function findPage()
 {
     $_where = $this->where != '' ? ' WHERE ' . $this->where : '';
     $this->sql = $this->_read_sql();
     if ($this->expire < 0) {
         $_table_name = $this->_get_table_name();
         $sql_cout = 'SELECT count(*) AS countrows FROM ' . $_table_name . $this->join . $_where;
         $data['data'] = $this->conn()->fetch_arrays($this->sql);
         $data['data_count'] = $this->db->fetch_object($sql_cout)->countrows;
     } else {
         $cache = Cache::init();
         $cachename = 'db/findPage_' . md5($this->sql);
         if (false == ($data = $cache->get($cachename))) {
             $_table_name = $this->_get_table_name();
             $sql_cout = 'SELECT count(*) AS countrows FROM ' . $_table_name . $this->join . $_where;
             $data['data'] = $this->conn()->fetch_arrays($this->sql);
             $data['data_count'] = $this->db->fetch_object($sql_cout)->countrows;
             $cache->set($cachename, $data, $this->expire);
             $this->expire = -1;
         }
     }
     return $data;
 }
コード例 #25
0
ファイル: urlaccess.php プロジェクト: rocksyne/wyf
<?php

session_start();
set_include_path("../.." . PATH_SEPARATOR . get_include_path());
//set_include_path( . $path . PATH_SEPARATOR . get_include_path());
require "../wyf_bootstrap.php";
Cache::init($cache_method);
define('CACHE_PREFIX', "../../");
define('CACHE_MODELS', $cache_models);
$object = unserialize(base64_decode($_REQUEST["object"]));
$model = Model::load($object["model"]);
if (isset($_REQUEST["conditions"])) {
    $conditions = explode(",", $_REQUEST["conditions"]);
    array_pop($conditions);
    //array_shift($conditions);
    foreach ($conditions as $i => $condition) {
        if (substr_count($condition, "==")) {
            $parts = explode("==", $condition);
            $conditions[$i] = $parts[0] . "=" . $parts[1];
        } else {
            $parts = explode("=", $condition);
            $conditions[$i] = $model->getSearch($parts[1], $parts[0]);
            //"instr(lower({$parts[0]}),lower('".$model->escape($parts[1])."'))>0";//$parts[0] ." in '".$model->escape($parts[1])."'";
        }
    }
    $condition_opr = isset($_REQUEST["conditions_opr"]) ? $_REQUEST["conditions_opr"] : "AND";
    $conditions = implode(" {$condition_opr} ", $conditions);
}
$params = array("fields" => $object["fields"], "sort_field" => isset($_REQUEST["sort"]) ? $_REQUEST["sort"] : $object["sortField"], "sort_type" => isset($_REQUEST["sort_type"]) ? $_REQUEST["sort_type"] : "ASC", "limit" => $object["limit"], "offset" => $_REQUEST["offset"], "conditions" => "({$conditions}) " . ($object['and_conditions'] != '' ? " AND ({$object['and_conditions']})" : '') . ($_REQUEST['and_conditions'] != '' ? " AND ({$_REQUEST['and_conditions']})" : ''));
//$data = $model->formatData();
switch ($_REQUEST["action"]) {
コード例 #26
0
ファイル: Cacheable.php プロジェクト: agpmedia/notoj
 public function setCache($path)
 {
     $this->localCache = Cache::init($path, false);
     return $this;
 }
コード例 #27
0
ファイル: bootstrap-sample.php プロジェクト: rezaprima/icms
include ROOT_DIR . '/app/config.php';
set_include_path(ROOT_DIR . '/lib/' . PATH_SEPARATOR . ROOT_DIR . '/app/controllers/' . PATH_SEPARATOR . ROOT_DIR . '/app/models/' . PATH_SEPARATOR . get_include_path());
ini_set('display_errors', '0');
set_magic_quotes_runtime(0);
setlocale(LC_ALL, 'id_ID');
if (isset($_GET['theme'])) {
    $config['theme'] =& $_GET['theme'];
}
// for m.namadomain.com
if (strpos($_SERVER['HTTP_HOST'], 'm.') === 0) {
    $config['theme'] = 'm';
}
// Include pear module before autoload
require 'Mail.php';
function __autoload($class)
{
    if (!$class) {
        return;
    }
    $lib = strtolower($class) . '.php';
    require $lib;
}
// Cache
Cache::init($config['cache']['backend'], $config['cache']['options']);
Session::start();
User::start();
require ROOT_DIR . '/lib/controller.php';
ob_start();
Ctrl::dispatch();
$html = str_replace(array('/[\\r\\n\\t]/', '/\\s{2,}/'), array(' ', ' '), ob_get_clean());
echo $html;
コード例 #28
0
ファイル: modelMS.class.php プロジェクト: beyondzgz/mophp
 /**
  * 和findAll()差不多
  * 返回的数据结构:array('data'=>array(....), 'data_count'=>总数据数)
  *
  * @return array $data 结构:array('data'=>array(....), 'data_count'=>10)
  */
 public function findPage()
 {
     $dbdriver = C('dbdriver');
     if ($dbdriver == 'mysqli' || $dbdriver == 'mysql') {
         // mysql
         $this->field = 'SQL_CALC_FOUND_ROWS ' . $this->field;
         $this->sql = $this->_read_sql();
         if ($this->expire < 0) {
             $data['data'] = $this->conn('slave')->fetch_arrays($this->sql);
             $_count = $this->db->fetch_array('SELECT FOUND_ROWS()');
             $data['data_count'] = $_count['FOUND_ROWS()'];
         } else {
             $cache = Cache::init();
             $cachename = 'db/findPage_' . md5($this->sql);
             if (false == ($data = $cache->get($cachename))) {
                 $data['data'] = $this->conn('slave')->fetch_arrays($this->sql);
                 $_count = $this->db->fetch_array('SELECT FOUND_ROWS()');
                 $data['data_count'] = $_count['FOUND_ROWS()'];
                 $cache->set($cachename, $data, $this->expire);
                 $this->expire = -1;
             }
         }
         return $data;
     } else {
         //非mysql
         $this->sql = $this->_read_sql();
         if ($this->expire < 0) {
             $_table_name = $this->_get_table_name();
             $_where = $this->where != '' ? ' WHERE ' . $this->where : '';
             $sql_cout = 'SELECT count(*) AS count FROM ' . $_table_name . $this->join . $_where;
             $data['data'] = $this->conn('slave')->fetch_arrays($this->sql);
             $data['data_count'] = $this->db->fetch_object($sql_cout)->count;
         } else {
             $cache = Cache::init();
             $cachename = 'db/findPage_' . md5($this->sql);
             if (false == ($data = $cache->get($cachename))) {
                 $_table_name = $this->_get_table_name();
                 $_where = $this->where != '' ? ' WHERE ' . $this->where : '';
                 $sql_cout = 'SELECT count(*) AS count FROM ' . $_table_name . $this->join . $_where;
                 $data['data'] = $this->conn('slave')->fetch_arrays($this->sql);
                 $data['data_count'] = $this->db->fetch_object($sql_cout)->count;
                 $cache->set($cachename, $data, $this->expire);
                 $this->expire = -1;
             }
         }
         return $data;
     }
 }
コード例 #29
0
ファイル: index.php プロジェクト: nathanieltite/elefant
View::init($tpl);
/**
 * Check for a bootstrap.php file in the root of the site
 * and if found, use it for additional app-level configurations
 * (Dependency Injection, custom logging settings, etc.).
 */
if (file_exists('bootstrap.php')) {
    require 'bootstrap.php';
}
/**
 * Initialize the built-in cache support. Provides a
 * consistent cache API (based on Memcache) so we can always
 * include caching in our handlers and in the front controller.
 */
if (!isset($memcache) || !is_object($memcache)) {
    $memcache = Cache::init(conf('Cache'));
}
/**
 * Route the request to the appropriate handler and get
 * the handler's response.
 */
if ($i18n->url_includes_lang) {
    $handler = $controller->route($i18n->new_request_uri);
} else {
    $handler = $controller->route($_SERVER['REQUEST_URI']);
}
$page->body = $controller->handle($handler, false);
/**
 * Render and send the output to the client, using gzip
 * compression if conf[General][compress_output] is true.
 */
コード例 #30
0
ファイル: ePHP.php プロジェクト: beyondzgz/ePHP
 /**
  * 判断视图是否已缓存
  *
  * @param string $file 视图名
  * @return boolean
  */
 public function is_cached($file = '')
 {
     if (Cache::init()->get('html/' . $file)) {
         return true;
     } else {
         return false;
     }
 }