本文整理汇总了PHP中Storage::Set方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::Set方法的具体用法?PHP Storage::Set怎么用?PHP Storage::Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Storage
的用法示例。
在下文中一共展示了Storage::Set方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Cache
/**
* Função para definir uso de cache na Query
*
* @access public
* @return \MySQLTableCached
*/
public function Cache($iTimeout = 3600)
{
Storage::Set("cachedb.timeout", $iTimeout);
Events::Set("BeforeQuery", function ($sSQL, $fCallback) {
if (Storage::Get("cachedb.enabled", false)) {
$mCache = @CacheDB::Get(sha1($sSQL));
if ($mCache !== false && !is_null($mCache)) {
if ($fCallback) {
$fCallback(json_decode($mCache, true), null);
}
return true;
} else {
return false;
}
} else {
return false;
}
});
Events::Set("AfterQuery", function ($sSQL, $aResult) {
if (Storage::Get("cachedb.enabled", false)) {
@CacheDB::Set(sha1($sSQL), json_encode($aResult), Storage::Get("cachedb.timeout", 3600));
}
});
return $this;
}
示例2: Start
/**
* Function to start the module
*
* @access public
* @return void
*/
public function Start()
{
if (file_exists($this->sModuleDiretory . SP . "status.txt")) {
$iStatus = intval(file_get_contents($this->sModuleDiretory . SP . "status.txt"));
$bStatus = $iStatus == 1;
Storage::Set("app." . $this->sModuleName . ".enabled", $bStatus);
} else {
$bStatus = true;
file_put_contents($this->sModuleDiretory . SP . "status.txt", "1");
Storage::Set("app." . $this->sModuleName . ".enabled", true);
}
if ($bStatus) {
Storage::SetArray("class.list", "module." . $this->sModuleName, $this->sModuleDiretory . "core" . SP);
//Diretory Paths
Storage::Set("app." . $this->sModuleName, $this->sModuleDiretory);
Storage::Set("app." . $this->sModuleName . ".shell.css", $this->sModuleDiretory . "shell" . SP . "css" . SP);
Storage::Set("app." . $this->sModuleName . ".shell.tpl", $this->sModuleDiretory . "shell" . SP . "tpl" . SP);
Storage::Set("app." . $this->sModuleName . ".shell.js", $this->sModuleDiretory . "shell" . SP . "js" . SP);
Storage::Set("app." . $this->sModuleName . ".shell.img", $this->sModuleDiretory . "shell" . SP . "img" . SP);
//Web Paths
Storage::Set("virtual." . $this->sModuleName . ".shell.img", Storage::Join("route.root", "app/" . $this->sModuleName . "/shell/img/"));
Storage::Set("virtual." . $this->sModuleName . ".shell.tpl", Storage::Join("route.root", "app/" . $this->sModuleName . "/shell/tpl/"));
Storage::Set("virtual." . $this->sModuleName . ".shell.js", Storage::Join("route.root", "app/" . $this->sModuleName . "/shell/js/"));
Storage::Set("virtual." . $this->sModuleName . ".shell.css", Storage::Join("route.root", "app/" . $this->sModuleName . "/shell/css/"));
//Loading submodules
if (is_dir($this->sModuleDiretory . "modules")) {
$aModulesDirectories = glob($this->sModuleDiretory . "modules" . SP . "*", GLOB_ONLYDIR);
foreach ($aModulesDirectories as $sModuleDiretory) {
if (file_exists($sModuleDiretory . SP . "status.txt")) {
$bStatus = intval(file_get_contents($sModuleDiretory . SP . "status.txt")) == 1;
} else {
$bStatus = false;
}
if ($bStatus) {
if (file_exists($sModuleDiretory . SP . "settings.php") && $bStatus) {
require_once $sModuleDiretory . SP . "settings.php";
}
if (file_exists($sModuleDiretory . SP . "include.php") && $bStatus) {
require_once $sModuleDiretory . SP . "include.php";
}
if (file_exists($sModuleDiretory . SP . "routes.php") && $bStatus) {
require_once $sModuleDiretory . SP . "routes.php";
}
if (file_exists($sModuleDiretory . SP . "events.php") && $bStatus) {
require_once $sModuleDiretory . SP . "events.php";
}
}
}
}
}
}
示例3: Start
/**
* Starting the application
*
* @static
* @access public
* @return void
*/
public static function Start()
{
$oThis = self::CreateInstanceIfNotExists();
//setting autoload
spl_autoload_register(array($oThis, "AutoLoad"));
//Configuring basic directories
Storage::Set("dir.root", __DIR__ . SP);
Storage::Set("dir.public", __DIR__ . SP . "public" . SP);
Storage::Set("dir.public.assets", __DIR__ . SP . "public" . SP . "assets" . SP);
Storage::Set("dir.public.compiles", __DIR__ . SP . "public" . SP . "compiles" . SP);
Storage::Set("dir.public.configs", __DIR__ . SP . "public" . SP . "configs" . SP);
Storage::Set("dir.app", __DIR__ . SP . "app" . SP);
//Configuring default route
Storage::Set("route.root", "//" . $_SERVER["SERVER_NAME"] . str_replace(array("index.php", " "), array("", "%20"), $_SERVER["SCRIPT_NAME"]));
//Bugfix
$oThis->LoadApp();
}
示例4: RestParams
/**
* Function to return parameters passed by PUT or DELETE methods
*
* @static
* @access public
* @param boolean $bReturn
* @return mixed
*/
public static function RestParams($bReturn = false)
{
$sBuffer = file_get_contents("php://input");
$aParams = explode("&", $sBuffer);
$aReturn = array();
foreach ($aParams as $sParam) {
@(list($mKey, $mValue) = @explode("=", $sParam));
$mValue = urldecode($mValue);
if (!empty($mKey) && !empty($mValue)) {
Storage::Set(strtolower(Routes::Restful()) . "." . $mKey, $mValue);
if ($bReturn) {
$aReturn[strtolower(Routes::Restful()) . "." . $mKey] = $mValue;
}
}
}
if ($bReturn) {
return $aReturn;
}
}
示例5: Start
/**
* Função para iniciar serviço de armazenamento de cache em memória
*
* @access public
* @param string $sHostname Hostname do servidor de cache
* @param integer $iPort Porta do servidor (Padrão: 11211)
* @return boolean
*/
public static function Start($sHostname, $iPort = 11211)
{
$oThis = self::CreateInstanceIfNotExists();
if (class_exists("memcached")) {
if (!empty($sHostname) && is_int($iPort)) {
$oThis->oMemCache = new memcached(array("servers" => array($sHostname . ":" . $iPort), "debug" => false, "compress_threshold" => 10240, "persistant" => true));
if (is_object($oThis->oMemCache)) {
Storage::Set("cachedb.enabled", true);
return true;
} else {
Storage::Set("cachedb.enabled", false);
return false;
}
} else {
Storage::Set("cachedb.enabled", false);
return false;
}
} else {
Storage::Set("cachedb.enabled", false);
return false;
}
}
示例6:
<?php
/**
* Settings
*/
//Default Settings
Storage::Set("app.charset", "UTF-8");
Storage::Set("debug", true);
Storage::Set("app.minified", false);
//Smarty Settings
Storage::Set("smarty.dir.compile", __DIR__ . SP . "public" . SP . "compiles" . SP);
Storage::Set("smarty.dir.config", __DIR__ . SP . "public" . SP . "configs" . SP);
示例7: Login
/**
* Function to perform the login session
*
* @static
* @access public
* @param mixed $mId User ID
* @param string $sUsername Username
* @param string $sName Name
* @param integer $iTimeout Maximum time of permanence in the session
* @param boolean $bRoot Defines the user as root
* @return void
*/
public static function Login($mId, $sUsername, $sName, $iTimeout = 3600, $bRoot = false)
{
$oThis = self::CreateInstanceIfNotExists();
if ($oThis->bStarted) {
$iTimeout = time() + $iTimeout;
$oThis->aAuth = array("id" => $mId, "name" => $sName, "username" => $sUsername, "timeout" => $iTimeout, "root" => $bRoot);
$_SESSION[$oThis->sName]["authentication"] = $oThis->aAuth;
if (!empty($oThis->aAuth)) {
Storage::Set("user.id", $oThis->aAuth["id"]);
Storage::Set("user.name", $oThis->aAuth["name"]);
Storage::Set("user.username", $oThis->aAuth["username"]);
Storage::Set("user.root", $oThis->aAuth["root"]);
Storage::Set("session.timeout.login", $iTimeout);
}
}
}
示例8: CreateCacheJS
/**
* Function to create the Javascript file cache
*
* @access public
* @param boolean $bForce Forcing creation
* @return void
*/
public static function CreateCacheJS()
{
$oThis = self::CreateInstanceIfNotExists();
if (count($oThis->aJS) > 0) {
$sCacheFilename = Storage::Join("dir.public.assets", strtolower($oThis->sNamespace) . ".js");
Storage::Set("assets.js", Storage::Join("route.root", "public/assets/" . strtolower($oThis->sNamespace) . ".js"));
if (!file_exists($sCacheFilename) || Storage::Get("debug", false)) {
$sBuffer = "";
foreach ($oThis->aJS as $sAppendBuffer) {
$sBuffer .= $sAppendBuffer;
}
file_put_contents($sCacheFilename, $sBuffer);
}
}
}
示例9:
<?php
/**
* Settings
*
* @package MagicPHP Hello World
* @author André Ferreira <andrehrf@gmail.com>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
Storage::Set("app.title", "MagicPHP - Hello World");