本文整理汇总了PHP中storage::load方法的典型用法代码示例。如果您正苦于以下问题:PHP storage::load方法的具体用法?PHP storage::load怎么用?PHP storage::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类storage
的用法示例。
在下文中一共展示了storage::load方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: savecoins
private static function savecoins($coins)
{
$old = storage::load();
if (!$old) {
$old = array();
}
foreach ($coins as $val => $ccs) {
foreach ($ccs as $id => $coin) {
$old[$val][$id] = $coin;
}
}
if (storage::save($old)) {
return true;
}
return false;
}
示例2: spentcoins
public static function spentcoins($coins, $account)
{
if (!is_array($coins)) {
return false;
}
$old = storage::load($account);
if (!$old) {
return false;
}
foreach ($coins as $id => $coin) {
$val = $coin['value'];
if (array_key_exists($id, $old[$val])) {
unset($old[$val][$id]);
}
}
$ret = storage::save($old, $account);
$ret = $ret ? 1 : 0;
return $ret;
}
示例3: log
public static function log(&$in)
{
list($oid, $t) = each($in);
if (!is_array($t) || !isset($t['order id'])) {
$t = $in;
$oid = $t['order id'];
}
if (isset($t['coins'])) {
unset($t['coins']);
}
if (isset($t['change'])) {
unset($t['change']);
}
$acc = Tools::address($t['client']);
$acm = Tools::address($t['merchant']);
$ac = $acc['account'];
$am = $acm['account'];
$tr[$oid] = $t;
if (account::exists($ac) || $ac == config::$accountId) {
$oldc = storage::load("{$ac}.transaction");
if (!$oldc) {
$oldc = array();
}
$oldc[$oid] = $tr[$oid];
storage::save($oldc, "{$ac}.transaction");
}
if (account::exists($am) || $am == config::$accountId) {
$oldm = storage::load("{$am}.transaction");
if (!$oldm) {
$oldm = array();
}
$oldm[$oid] = $tr[$oid];
storage::save($oldm, "{$am}.transaction");
}
}
示例4: log
public static function log(&$t)
{
if (isset($t['coins'])) {
unset($t['coins']);
}
if (isset($t['change'])) {
unset($t['change']);
}
$tid = $t['acknowledgement']['id'];
$tr[$tid] = $t;
$old = storage::load('__Transactions__.lg');
if (!$old) {
$old = array();
}
$new = array_merge($old, $tr);
storage::save($new, '__Transactions__.lg');
}
示例5: pullcoins
public static function pullcoins()
{
$m = Gmsg::create(Gmsg::prepare(GsonCrypt::sign(Gmsg::create(array('account' => config::$accountId))), 'pullcoins', config::$bankId));
$net = new Gnet();
$r = $net->send($m);
$v = GsonCrypt::verify($r, config::$bankId);
if (!$v) {
$status = 0;
gio::log("Unable to verify response from bank while pulling coins", E_USER_WARNING);
} else {
$v = Gmsg::extract($v);
if (!$v) {
$status = 0;
gio::log("Unable to understand the response while pulling coins", E_USER_WARNING);
} else {
$status = $v['status'];
$res = $v['response'];
}
}
if (!$status) {
gio::output("Could not pull eCash from bank");
} else {
if (!is_array($res)) {
gio::output("Could not pull eCash from bank");
} else {
$check = 1;
foreach ($res as $val => $ccs) {
foreach ($ccs as $id => $coin) {
$res[$val][$id]['secret'] = GsonCrypt::unseal($coin['secret']);
if (!$res[$val][$id]['secret']) {
$check = 0;
}
}
}
if (!$check) {
gio::output("Could not get the secret of some eCash");
}
}
if (is_array($res) && count($res)) {
$old = storage::load();
if (!$old) {
$old = array();
}
foreach ($res as $val => $ccs) {
foreach ($ccs as $id => $coin) {
$val = $coin['value'];
$old[$val][$id] = $coin;
}
}
storage::save($old);
}
}
}
示例6: spentcoins
public static function spentcoins($coins, $account)
{
if (!is_array($coins) || $account != config::$accountId && !account::exists($account)) {
return false;
}
if (!is_array($coins)) {
return false;
}
$dest = strtolower($account) == strtolower(config::$accountId) ? config::$walfile : $account;
$old = storage::load($dest);
if (!$old) {
return false;
}
foreach ($coins as $id => $coin) {
$val = $coin['value'];
if (array_key_exists($id, $old[$val])) {
unset($old[$val][$id]);
}
}
$ret = storage::save($old, $dest);
$ret = $ret ? 1 : 0;
return $ret;
}
示例7: balance
public static function balance(&$coins)
{
self::pullcoins();
$coins = storage::load();
if (!$coins) {
$coins = array();
}
$cnt = 0;
foreach ($coins as $val => $ccs) {
$cnt += intval(count($ccs)) * intval($val);
}
return $cnt;
}
示例8: explode
/**
Get database object
@param $force_reload boolean
@public
**/
static function &getDBO($force_reload = false)
{
static $dbo;
if ($force_reload) {
// re-init db instance
$dbo = null;
}
// create if don't exists
if (!is_object($dbo)) {
$config = Factory::getConfig();
// extract timezone for DB
@(list($tz_script, $tz_db) = explode('|', $config->timezone));
$storage = new storage();
// set timezone
$storage->set_timezone($tz_db);
// load db instance
$dbo = $storage->load($config->dsn);
if (!$dbo) {
die('Cannot connect to database.');
}
}
return $dbo;
}