本文整理汇总了PHP中storage类的典型用法代码示例。如果您正苦于以下问题:PHP storage类的具体用法?PHP storage怎么用?PHP storage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了storage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_lvm_iscsi_deployment_image_rootdevice_identifier
function get_lvm_iscsi_deployment_image_rootdevice_identifier($lvm_iscsi_storage_id)
{
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_ADMIN;
global $event;
// place for the storage stat files
$StorageDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/plugins/lvm-storage/storage';
$rootdevice_identifier_array = array();
$storage = new storage();
$storage->get_instance_by_id($lvm_iscsi_storage_id);
$storage_resource = new resource();
$storage_resource->get_instance_by_id($storage->resource_id);
$storage_resource_id = $storage_resource->id;
$ident_file = "{$StorageDir}/{$storage_resource_id}.lv.lvm-iscsi-deployment.ident";
if (file_exists($ident_file)) {
unlink($ident_file);
}
// send command
$resource_command = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/lvm-storage/bin/openqrm-lvm-storage post_identifier -t lvm-iscsi-deployment -u {$OPENQRM_ADMIN->name} -p {$OPENQRM_ADMIN->password}";
$storage_resource->send_command($storage_resource->ip, $resource_command);
if (!lvm_iscsi_deployment_wait_for_identfile($ident_file)) {
$event->log("get_image_rootdevice_identifier", $_SERVER['REQUEST_TIME'], 2, "image.lvm-iscsi-deployment", "Timeout while requesting image identifier from storage id {$storage->id}", "", "", 0, 0, 0);
return;
}
$fcontent = file($ident_file);
foreach ($fcontent as $lun_info) {
$tpos = strpos($lun_info, ",");
$timage_name = trim(substr($lun_info, 0, $tpos));
$troot_device = trim(substr($lun_info, $tpos + 1));
$rootdevice_identifier_array[] = array("value" => "{$troot_device}", "label" => "{$timage_name}");
}
return $rootdevice_identifier_array;
}
示例2: install
public function install($db_type)
{
$f3 = \Base::instance();
$db_type = strtoupper($db_type);
if ($db = storage::instance()->get($db_type)) {
$f3->set('DB', $db);
} else {
$f3->error(256, 'no valid DB specified');
}
// setup the models
\Model\Post::setup();
\Model\Tag::setup();
\Model\Comment::setup();
\Model\User::setup();
// create demo admin user
$user = new \Model\User();
$user->load(array('username = ?', 'admin'));
if ($user->dry()) {
$user->username = 'admin';
$user->name = 'Administrator';
$user->password = 'fabulog';
$user->save();
\Flash::instance()->addMessage('Admin User created,' . ' username: admin, password: fabulog', 'success');
}
\Flash::instance()->addMessage('Setup complete', 'success');
}
示例3: __construct
function __construct($openqrm, $response)
{
$this->response = $response;
$this->openqrm = $openqrm;
$this->file = $this->openqrm->file();
$this->openqrm = $openqrm;
$this->user = $openqrm->user();
$storage_id = $this->response->html->request()->get('storage_id');
$storage = new storage();
$resource = new resource();
$deployment = new deployment();
$this->storage = $storage->get_instance_by_id($storage_id);
$this->resource = $resource->get_instance_by_id($storage->resource_id);
$this->deployment = $deployment->get_instance_by_id($storage->type);
$this->response->add('storage_id', $storage_id);
}
示例4: __construct
function __construct($openqrm, $response)
{
$this->openqrm = $openqrm;
$this->user = $this->openqrm->user();
$this->rootdir = $this->openqrm->get('webdir');
$this->response = $response;
$this->file = $this->openqrm->file();
$this->tpldir = $this->rootdir . '/plugins/device-manager/tpl';
$id = $this->response->html->request()->get('storage_id');
$this->response->add('storage_id', $id);
$this->response->add('volgroup', $this->response->html->request()->get('volgroup'));
$storage = new storage();
$this->storage = $storage->get_instance_by_id($id);
$resource = new resource();
$this->resource = $resource->get_instance_by_id($this->storage->resource_id);
$this->statfile = $this->openqrm->get('basedir') . '/plugins/device-manager/web/storage/' . $this->resource->id . '.device.stat';
}
示例5: checkOut
/**
* Checkout cart
*/
public function checkOut($drop)
{
if (!empty($this->storage->db)) {
$this->storage->lock($drop, $this);
} else {
$this->deleteAll();
}
}
示例6: testClear
/**
* @covers ZfcUser\Authentication\Storage\Db::clear
*/
public function testClear()
{
$reflectionClass = new \ReflectionClass('ZfcUser\\Authentication\\Storage\\Db');
$reflectionProperty = $reflectionClass->getProperty('resolvedIdentity');
$reflectionProperty->setAccessible(true);
$this->storage->expects($this->once())->method('clear');
$this->db->setStorage($this->storage);
$this->db->clear();
$this->assertNull($reflectionProperty->getValue($this->db));
}
示例7: setAuthenticationCredentials
protected function setAuthenticationCredentials($identity = 'ZfcUser', $credential = 'ZfcUserPassword')
{
$this->storage->expects($this->at(0))->method('read')->will($this->returnValue(array('is_satisfied' => false)));
$post = $this->getMock('Zend\\Stdlib\\Parameters');
$post->expects($this->at(0))->method('get')->with('identity')->will($this->returnValue($identity));
$post->expects($this->at(1))->method('get')->with('credential')->will($this->returnValue($credential));
$request = $this->getMock('Zend\\Http\\Request');
$request->expects($this->exactly(2))->method('getPost')->will($this->returnValue($post));
$this->authEvent->expects($this->exactly(2))->method('getRequest')->will($this->returnValue($request));
}
示例8: setHeaders
/**
* Set the headers for the request
* @param array $options
* @return array $headers
*/
private function setHeaders(array $options)
{
$format = $options['format'];
$authToken = $this->storage->getTokenData();
$accessToken = $authToken['access_token'];
$tokenType = $authToken['token_type'];
$this->headers['Authorization'] = "{$tokenType} {$accessToken}";
$this->setRequestFormat($options['format']);
$this->setCompression($options);
}
示例9: get_nfs_deployment_image_rootdevice_identifier
function get_nfs_deployment_image_rootdevice_identifier($nfs_storage_id)
{
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_ADMIN;
global $event;
// place for the storage stat files
$StorageDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/plugins/nfs-storage/storage';
$rootdevice_identifier_array = array();
$storage = new storage();
$storage->get_instance_by_id($nfs_storage_id);
$storage_resource = new resource();
$storage_resource->get_instance_by_id($storage->resource_id);
$storage_resource_id = $storage_resource->id;
$ident_file = "{$StorageDir}/{$storage_resource_id}.nfs.ident";
$statfile_manual = "{$StorageDir}/" . $storage_resource_id . ".nfs.stat.manual";
// manual configured ?
if (file_exists($statfile_manual)) {
$fcontent = file($statfile_manual);
foreach ($fcontent as $lun_info) {
$troot_device = trim($lun_info);
$rootdevice_identifier_array[] = array("value" => "{$troot_device}", "label" => "{$troot_device}");
}
} else {
if (file_exists($ident_file)) {
unlink($ident_file);
}
// send command
$resource_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/nfs-storage/bin/openqrm-nfs-storage post_identifier -u " . $OPENQRM_ADMIN->name . " -p " . $OPENQRM_ADMIN->password . " --openqrm-cmd-mode background";
$storage_resource->send_command($storage_resource->ip, $resource_command);
if (!nfs_deployment_wait_for_identfile($ident_file)) {
$event->log("get_image_rootdevice_identifier", $_SERVER['REQUEST_TIME'], 2, "image.nfs-deployment", "Timeout while requesting image identifier from storage id {$storage->id}", "", "", 0, 0, 0);
return;
}
$fcontent = file($ident_file);
foreach ($fcontent as $lun_info) {
$tpos = strpos($lun_info, ",");
$timage_name = trim(substr($lun_info, 0, $tpos));
$troot_device = trim(substr($lun_info, $tpos + 1));
$rootdevice_identifier_array[] = array("value" => "{$troot_device}", "label" => "{$timage_name}");
}
}
return $rootdevice_identifier_array;
}
示例10: get_kvm_lvm_deployment_image_rootdevice_identifier
function get_kvm_lvm_deployment_image_rootdevice_identifier($kvm_lvm_id)
{
global $OPENQRM_SERVER_BASE_DIR;
global $OPENQRM_ADMIN;
global $event;
// place for the storage stat files
$StorageDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/plugins/kvm/storage';
$rootdevice_identifier_array = array();
$storage = new storage();
$storage->get_instance_by_id($kvm_lvm_id);
// get deployment type
$deployment = new deployment();
$deployment->get_instance_by_id($storage->type);
// get storage resource
$storage_resource = new resource();
$storage_resource->get_instance_by_id($storage->resource_id);
$storage_resource_id = $storage_resource->id;
$ident_file = $StorageDir . "/" . $storage_resource_id . ".lv.kvm-lvm-deployment.ident";
if (file_exists($ident_file)) {
unlink($ident_file);
}
// send command
$resource_command = $OPENQRM_SERVER_BASE_DIR . "/openqrm/plugins/kvm/bin/openqrm-kvm post_identifier -u " . $OPENQRM_ADMIN->name . " -p " . $OPENQRM_ADMIN->password . " -t " . $deployment->type;
$storage_resource->send_command($storage_resource->ip, $resource_command);
if (!kvm_lvm_deployment_wait_for_identfile($ident_file)) {
$event->log("get_image_rootdevice_identifier", $_SERVER['REQUEST_TIME'], 2, "image.kvm-lvm-deployment", "Timeout while requesting image identifier from storage id {$storage->id}", "", "", 0, 0, 0);
return;
}
$fcontent = file($ident_file);
foreach ($fcontent as $lun_info) {
$tpos = strpos($lun_info, ":");
$timage_name = trim(substr($lun_info, 0, $tpos));
$troot_device = trim(substr($lun_info, $tpos + 1));
$rootdevice_identifier_array[] = array("value" => "{$troot_device}", "label" => "{$timage_name}");
}
return $rootdevice_identifier_array;
}
示例11: revokeToken
/**
* Revokes an authorization token. This both revokes the token by making a
* Google Accounts API request to revoke the token as well as deleting the
* token from the storage mechanism. If any errors occur, the authorization
* exception is caught and the message is stored in error.
*/
public function revokeToken()
{
$accessToken = $this->storage->get();
if ($accessToken) {
$tokenObj = json_decode($accessToken);
try {
$this->client->revokeToken($tokenObj->refresh_token);
$this->storage->delete();
} catch (Google_AuthException $e) {
$this->errorMsg = $e->getMessage();
}
}
// Keep things pretty. Removes the auth code from the URL.
header("Location: {$this->controllerUrl}");
}
示例12: 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;
}
示例13: setup
/**
* @param $contract
* @return array
* @throws \Exception
*/
public function setup($contract)
{
$this->logger->info('Download started...', ['file' => $contract->file]);
$pdfFile = '';
try {
$pdfFile = $this->storage->disk('s3')->get($contract->file);
} catch (\Exception $e) {
$this->logger->error($e->getMessage(), ['contract id' => $contract->id, 'file' => $contract->file]);
}
$this->storage->disk('local')->put($contract->file, $pdfFile);
$this->logger->info('Download completed...', ['file' => $pdfFile]);
if (!$this->fileSystem->isDirectory($this->getContractDirectory($contract->id))) {
$this->addDirectory($contract->id, $this->getWriteDirectory());
}
$writeFolderPath = $this->getContractDirectory($contract->id);
$readFilePath = sprintf('%s/app/%s', storage_path(), $contract->file);
return [$writeFolderPath, $readFilePath];
}
示例14: handle
/**
* 获取内容并输出
* 如果stroage里面不存在,则从URL里面获取
* */
private function handle($filename, $key, $delete = false, $direct = false)
{
$content = '';
if ($this->succeed) {
$storage = storage::gethandle();
if ($delete) {
if (!$storage->exists($key)) {
die(json_encode(array('purge' => $filename, 'key' => $key, 'success' => 'not exists')));
}
$return = $storage->delete($key);
die(json_encode(array('purge' => $filename, 'key' => $key, 'success' => $return)));
}
if ($storage->exists($key) && !$direct) {
if (!NO_LOCATE && ($url = $storage->url($key))) {
$this->locate($url);
}
$content = $storage->read($key);
$this->hit = $key;
if (empty($content)) {
$this->succeed = false;
$this->error_type = 'empty_conent';
}
} else {
//$content = @file_get_contents(BASE_URL.$filename);
$content = lib::fetch_url(BASE_URL . $filename);
if (!is_array($content) || count($content) < 2) {
$this->succeed = false;
$this->error_type = 'fetch_error';
} elseif ($content[0] == 200) {
//返回200,才写入
if (!$direct) {
$storage->write($key, $content[1]);
}
} else {
header('HTTP/1.1 ' . $content[0]);
}
$content = $content[1];
}
}
//显示内容
$this->render($content);
}
示例15: duplicate
function duplicate()
{
$response = $this->get_response();
$form = $response->form;
if (!$form->get_errors() && $this->response->submit()) {
$storage_id = $this->response->html->request()->get('storage_id');
$storage = new storage();
$resource = new resource();
$deployment = new deployment();
$storage->get_instance_by_id($storage_id);
$resource->get_instance_by_id($storage->resource_id);
$deployment->get_instance_by_id($storage->type);
$name = $form->get_request('name');
$command = $this->openqrm->get('basedir') . '/plugins/nfs-storage/bin/openqrm-nfs-storage clone';
$command .= ' -n ' . $this->volume;
$command .= ' -s ' . $name;
$command .= ' -u ' . $this->openqrm->admin()->name . ' -p ' . $this->openqrm->admin()->password;
$command .= ' --openqrm-ui-user ' . $this->user->name;
$command .= ' --openqrm-cmd-mode background';
$statfile = $this->openqrm->get('basedir') . '/plugins/nfs-storage/web/storage/' . $storage->resource_id . '.nfs.stat';
$origin_volume_path = '';
$volume_path = "";
if (file_exists($statfile)) {
$lines = explode("\n", file_get_contents($statfile));
if (count($lines) >= 1) {
foreach ($lines as $line) {
if ($line !== '') {
$line = explode('@', $line);
$check = basename($line[1]);
if ($name === $check) {
$error = sprintf($this->lang['error_exists'], $name);
}
if ($this->volume === $check) {
$origin_volume_path = $line[1];
}
}
}
}
}
if (!strlen($origin_volume_path)) {
$error = sprintf($this->lang['msg_clone_failed'], $name);
} else {
$export_path = dirname($origin_volume_path);
$volume_path = $export_path . '/' . $name;
}
if (isset($error)) {
$response->error = $error;
} else {
$file = $this->openqrm->get('basedir') . '/plugins/nfs-storage/web/storage/' . $resource->id . '.nfs.' . $name . '.sync_progress';
if ($this->file->exists($file)) {
$this->file->remove($file);
}
$resource->send_command($resource->ip, $command);
while (!$this->file->exists($file)) {
usleep(10000);
// sleep 10ms to unload the CPU
clearstatcache();
}
$tables = $this->openqrm->get('table');
$image_fields = array();
$image_fields["image_id"] = (int) str_replace(".", "", str_pad(microtime(true), 15, "0"));
$image_fields['image_name'] = $name;
$image_fields['image_type'] = $deployment->type;
$image_fields['image_rootfstype'] = 'nfs';
$image_fields['image_storageid'] = $storage->id;
$image_fields['image_comment'] = "Image Object for volume {$name}";
$image_fields['image_rootdevice'] = $volume_path;
$image = new image();
$image->add($image_fields);
$response->msg = sprintf($this->lang['msg_cloned'], $this->volume, $name);
// save image id in response for the wizard
$response->image_id = $image_fields["image_id"];
}
}
return $response;
}