本文整理汇总了PHP中Storage::store方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::store方法的具体用法?PHP Storage::store怎么用?PHP Storage::store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Storage
的用法示例。
在下文中一共展示了Storage::store方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFileCreateAndSaveData
/**
* @depends testIfFileNotExist
*/
public function testFileCreateAndSaveData()
{
$this->storage->store($this->storeArray);
$this->assertFileExists($this->fullpath, 'File exist already');
$testString = serialize($this->storeArray);
$this->assertStringEqualsFile($this->fullpath, $testString, 'Equals string which we set and what we create by hand');
}
示例2: load
/**
* function that load packages and register them in storage
* @param integer
* @return void
**/
public static function load(int $group) : bool
{
$packages = Database::query(TABLE_PACKAGE_TO_GROUP, ['packageid'], '`groupid` = ' . $group);
$list = [];
$store = [];
foreach ($packages as $package) {
$list[] = $package['packageid'];
}
if (!empty($list)) {
$packages = Database::query(TABLE_PACKAGE, ['*'], '`packageid` IN ( ' . implode(', ', $list) . ' )');
foreach ($packages as $package) {
if (file_exists(DIR_PACKAGES . '/' . $package['repertory'] . '/confs.php')) {
require DIR_PACKAGES . '/' . $package['repertory'] . '/confs.php';
}
if (file_exists(DIR_PACKAGES . '/' . $package['repertory'] . '/models')) {
Document::get(DIR_PACKAGES . '/' . $package['repertory'] . '/models');
}
if (file_exists(DIR_PACKAGES . '/' . $package['repertory'] . '/controllers')) {
Document::get(DIR_PACKAGES . '/' . $package['repertory'] . '/controllers');
}
$store[] = $package;
}
}
Storage::store(['packages' => $store]);
return true;
}
示例3: __construct
public function __construct($args)
{
//$script = file_get_contents(LIB . "/OrongoScript/Tests/test.osc");
//$parser = new OrongoScriptParser($script);
//$parser->startParser();
require 'TerminalPlugin.php';
Plugin::hookTerminalPlugin(new TerminalPlugin());
$stored = Plugin::getSettings($args['auth_key']);
//Access the settings in the array.
if (isset($stored['example_setting_2']) && $stored['example_setting_2']) {
$this->injectHTML = true;
$this->htmlToInject = $stored['example_setting_1'];
} else {
$this->injectHTML = false;
}
$store_string = 'this is a variable';
$bool = Storage::store('a_storage_key', $store_string, true);
if ($bool) {
//This will fail and return false, because overwrite = false
$bool2 = Storage::store('a_storage_key', 'will this overwrite?', false);
if ($bool2 == false) {
//This wil return: this is a variable
$returnString = Storage::get('a_storage_key');
//Delete the storage
Storage::delete('a_storage_key');
}
}
}
示例4: parse
/**
* Fetches the given URL and parses products and stores them.
*
* @return int Number of processed products.
* @exception Exception
*/
static function parse($url)
{
$fp = @fopen($url, 'r');
if (!$fp) {
throw new \Exception("Could not open url: " . $url);
}
$result = 0;
$start = false;
$xml = '';
while (!feof($fp)) {
// Get onle line
$buffer = fgets($fp);
if (strpos($buffer, '<product>') !== false) {
$start = true;
}
if ($start) {
$xml .= $buffer;
}
if (strpos($buffer, '</product>') !== false) {
$start = false;
if (Storage::store(self::product($xml))) {
$result++;
}
$xml = "";
}
}
fclose($fp);
if ($start) {
throw new \Exception("Could not find </product>");
}
if (!$result) {
throw new \Exception("No products found.");
}
return $result;
}
示例5: execute
public function execute($parameters, $db)
{
global $base;
chdir($base);
if (sizeof($parameters) == 0 || $parameters[0] == "") {
CLI::out("Usage: |g|help <command>|n| To see a list of commands, use: |g|list", true);
}
$command = $parameters[0];
switch ($command) {
case "all":
// Cleanup old sessions
$db->execute("delete from zz_users_sessions where validTill < now()");
$killsLastHour = $db->queryField("select count(*) count from zz_killmails where insertTime > date_sub(now(), interval 1 hour)", "count");
Storage::store("KillsLastHour", $killsLastHour);
$db->execute("delete from zz_analytics where dttm < date_sub(now(), interval 24 hour)");
$fc = new FileCache("{$base}/cache/queryCache/");
$fc->cleanUp();
break;
case "killsLastHour":
$killsLastHour = $db->queryField("select count(*) count from zz_killmails where insertTime > date_sub(now(), interval 1 hour)", "count");
Storage::store("KillsLastHour", $killsLastHour);
break;
case "fileCacheClean":
$fc = new FileCache();
$fc->cleanUp();
break;
}
}
示例6: write_hook
/**
* listen to write event.
*/
public static function write_hook($params)
{
if (\OCP\App::isEnabled('files_versions')) {
$path = $params[\OC\Files\Filesystem::signal_param_path];
if ($path != '') {
Storage::store($path);
}
}
}
示例7: write_hook
/**
* listen to write event.
*/
public static function write_hook($params)
{
if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
$path = $params[\OC\Files\Filesystem::signal_param_path];
if ($path != '') {
Storage::store($path);
}
}
}
示例8: loadLibs
/**
* function that load librairies
* @param void
* @return bool
**/
public static function loadLibs() : bool
{
$libs = [];
foreach (get_defined_constants() as $constant => $value) {
if (preg_match('#^LIB_[A-Z_]+$#', $constant)) {
require_once constant($constant);
$libs[] = ['name' => constant($constant), 'realname' => $constant];
}
}
Storage::store(['libs' => $libs]);
return true;
}
示例9: findConversations
public static function findConversations()
{
$locker = "Social:lastSocialTime";
$lastSocialTime = Storage::retrieve($locker, null);
if ($lastSocialTime == null) {
$result = Db::query("select killID, insertTime from zz_killmails where killID > 0 and processed = 1 and insertTime >= date_sub(now(), interval 10 minute)", array(), 0);
} else {
$result = Db::query("select killID, insertTime from zz_killmails where killID > 0 and processed = 1 and insertTime >= :last", array(":last" => $lastSocialTime), 0);
}
foreach ($result as $row) {
$lastSocialTime = $row["insertTime"];
self::beSocial($row["killID"]);
}
Storage::store($locker, $lastSocialTime);
}
示例10: execute
public function execute($parameters, $db)
{
$p = array();
$p["limit"] = 5;
$p["pastSeconds"] = 3 * 86400;
$p["kills"] = true;
Storage::store("Top3dayChars", json_encode(Info::doMakeCommon("Top Characters - Last 3 Days", "characterID", Stats::getTopPilots($p))));
Storage::store("Top3dayCorps", json_encode(Info::doMakeCommon("Top Corporations - Last 3 Days", "corporationID", Stats::getTopCorps($p))));
Storage::store("Top3dayAlli", json_encode(Info::doMakeCommon("Top Alliances - Last 3 Days", "allianceID", Stats::getTopAllis($p))));
Storage::store("TopIsk", json_encode(Stats::getTopIsk(array("pastSeconds" => 3 * 86400, "limit" => 5))));
Storage::store("TopPods", json_encode(Stats::getTopIsk(array("groupID" => 29, "pastSeconds" => 3 * 86400, "limit" => 5))));
Storage::store("TopPoints", json_encode(Stats::getTopPoints("killID", array("losses" => true, "pastSeconds" => 3 * 86400, "limit" => 5))));
Storage::store("KillCount", $db->queryField("select count(*) count from zz_killmails", "count"));
Storage::store("ActualKillCount", $db->queryField("select count(*) count from zz_killmails where processed = 1", "count"));
}
示例11: execute
public function execute($parameters, $db)
{
global $stompServer, $stompUser, $stompPassword;
// Ensure the class exists
if (!class_exists("Stomp")) {
die("ERROR! Stomp not installed! Check the README to learn how to install Stomp...\n");
}
$stomp = new Stomp($stompServer, $stompUser, $stompPassword);
$stompKey = "StompSend::lastFetch";
$lastFetch = date("Y-m-d H:i:s", time() - 12 * 3600);
$lastFetch = Storage::retrieve($stompKey, $lastFetch);
$stompCount = 0;
$timer = new Timer();
while ($timer->stop() < 60000) {
if (Util::isMaintenanceMode()) {
return;
}
$result = $db->query("SELECT killID, insertTime, kill_json FROM zz_killmails WHERE insertTime > :lastFetch AND processed > 0 ORDER BY killID limit 1000", array(":lastFetch" => $lastFetch), 0);
foreach ($result as $kill) {
$lastFetch = max($lastFetch, $kill["insertTime"]);
if (!empty($kill["kill_json"])) {
if ($kill["killID"] > 0) {
$stompCount++;
$destinations = self::getDestinations($kill["kill_json"]);
foreach ($destinations as $destination) {
$stomp->send($destination, $kill["kill_json"]);
}
}
$data = json_decode($kill["kill_json"], true);
$json = json_encode(array("solarSystemID" => $data["solarSystemID"], "killID" => $data["killID"], "characterID" => $data["victim"]["characterID"], "corporationID" => $data["victim"]["corporationID"], "allianceID" => $data["victim"]["allianceID"], "shipTypeID" => $data["victim"]["shipTypeID"], "killTime" => $data["killTime"]));
$stomp->send("/topic/starmap.systems.active", $json);
}
}
Storage::store($stompKey, $lastFetch);
sleep(5);
}
if ($stompCount > 0) {
Log::log("Stomped {$stompCount} killmails");
}
}
示例12: pre_renameOrCopy_hook
/**
* Remember owner and the owner path of the source file.
* If the file already exists, then it was a upload of a existing file
* over the web interface and we call Storage::store() directly
*
* @param array $params array with oldpath and newpath
*
*/
public static function pre_renameOrCopy_hook($params)
{
if (\OCP\App::isEnabled('files_versions')) {
// if we rename a movable mount point, then the versions don't have
// to be renamed
$absOldPath = \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files' . $params['oldpath']);
$manager = \OC\Files\Filesystem::getMountManager();
$mount = $manager->find($absOldPath);
$internalPath = $mount->getInternalPath($absOldPath);
if ($internalPath === '' and $mount instanceof \OC\Files\Mount\MoveableMount) {
return;
}
$view = new \OC\Files\View(\OCP\User::getUser() . '/files');
if ($view->file_exists($params['newpath'])) {
Storage::store($params['newpath']);
} else {
Storage::setSourcePathAndUser($params['oldpath']);
}
}
}
示例13: Storage
<?php
/**
* User: Dacascas
* Date: 31/01/2016
* Time: 22:56
*/
include_once 'lib/conf.php';
include_once 'lib/class.php';
$storage = new Storage('bee.txt');
if (isset($_REQUEST['reset'])) {
$storage->store('');
Response::redirect('/');
}
if ($storage->isEmpty()) {
$bees = new BeeBuilder($config);
$bees->createBees();
$storage->store($bees);
} else {
$bees = $storage->get();
}
if (isset($_REQUEST['bee'])) {
$bees = new BeeHit($bees);
$bees = $bees->hit($_REQUEST['bee']);
$storage->store($bees);
}
echo new Response($bees);
示例14: doPopulateRareItemPrices
/**
* Enters values into the lookup table that are not generally found on the market.
*
* @pararm $todaysLookup string Today's lookup value
*/
protected static function doPopulateRareItemPrices($todaysLookup)
{
global $mdb;
$isDone = (bool) Storage::retrieve($todaysLookup, false);
if ($isDone) {
return;
}
// Base lookups for today have been populated - do it here to allow later recursion
Storage::store($todaysLookup, 'true');
$motherships = $mdb->find('information', ['type' => 'typeID', 'groupID' => 659]);
if (sizeof($motherships) == 0) {
exit('no motherships, bailing');
}
// Haven't loaded all data yet, bail!
foreach ($motherships as $mothership) {
$typeID = $mothership['typeid'];
if ($typeID == 3514) {
continue;
}
static::setPrice($typeID, 20000000000);
// 20b
}
static::setPrice(3514, 100000000000);
// Revenant, 100b
$titans = $mdb->find('information', ['type' => 'typeID', 'groupID' => 30]);
if (sizeof($titans) == 0) {
exit('no titans, bailing');
}
// Haven't loaded all data yet, bail!
foreach ($titans as $titan) {
$typeID = $titan['typeid'];
static::setPrice($typeID, 100000000000);
// 100b
}
// We don't need daily prices on the following ships...
Db::execute('delete from zz_item_price_lookup where typeID in (2834, 3516, 11375, 33397, 32788, 2836, 3518, 32790, 33395, 32209, 33673, 33675, 11940, 11942, 635, 11011, 25560, 13202, 26840, 11936, 11938, 26842)');
$tourneyFrigates = array(2834, 3516, 11375);
foreach ($tourneyFrigates as $typeID) {
static::setPrice($typeID, 80000000000);
}
// 80b
static::setPrice(33397, 120000000000);
// Chremoas, 120b
static::setPrice(32788, 100000000000);
// Cambion, 100b
static::setPrice(2836, 150000000000);
// Adrestia, 150b
static::setPrice(3518, 90000000000);
// Vangel, 90b
static::setPrice(32790, 100000000000);
// Etana, 100b
static::setPrice(33395, 125000000000);
// Moracha, 125b
static::setPrice(32209, 100000000000);
// Mimir, 100b
// AT XII Prizes
static::setPrice(33675, 120000000000);
// Chameleon
static::setPrice(33673, 100000000000);
// Whiptail
// AT XIII Prizes
static::setPrice(35871, 140000000000);
// Fiend
static::setPrice(35779, 120000000000);
// Imp
// Rare CCP Ships (1 trillion! cuz why not)
static::setPrice(9860, 1000000000000);
// Polaris
static::setPrice(11019, 1000000000000);
// Cockroach
$rareCruisers = array(11940, 11942, 635, 11011, 25560);
foreach ($rareCruisers as $typeID) {
static::setPrice($typeID, 500000000000);
}
// 500b
$rareBattleships = array(13202, 26840, 11936, 11938, 26842);
foreach ($rareBattleships as $typeID) {
static::setPrice($typeID, 750000000000);
}
// 750b
// Clear all older lookup entries and leave today's lookup entries
Db::execute("delete from zz_storage where locker not like '{$todaysLookup}%' and locker like 'CREST-Market%'");
}
示例15: runCron
function runCron($command, $interval, $args)
{
global $base;
$curTime = time();
if (is_array($args)) {
array_unshift($args, $command);
} else {
if ($args != "") {
$args = explode(" ", "{$command} {$args}");
} else {
$args = array($command);
}
}
$cronName = implode(".", $args);
$locker = "lastCronRun.{$cronName}";
$lastRun = (int) Storage::retrieve($locker, 0);
$dateFormat = "D M j G:i:s T Y";
if ($curTime - $lastRun < $interval) {
// No need to say we're not running...
return;
}
Log::log("Cron {$cronName} running at " . date($dateFormat, $curTime));
Storage::store($locker, $curTime);
$pid = pcntl_fork();
if ($pid < 0) {
Storage::store($locker, $lastRun);
return;
}
if ($pid != 0) {
return;
}
putenv("SILENT_CLI=1");
pcntl_exec("{$base}/cliLock.sh", $args);
Storage::store($locker, $lastRun);
die("Executing {$command} failed!");
}