/** * Converts the response in JSON format to the value object i.e Storage * * @params json * - response in JSON format * * @return Storage object filled with json data * */ function buildResponse($json) { $storageObj = new Storage(); $jsonDocList = array(); $storageObj->setJsonDocList($jsonDocList); $storageObj->setStrResponse($json); $jsonObj = new JSONObject($json); $jsonObjApp42 = $jsonObj->__get("app42"); $jsonObjResponse = $jsonObjApp42->__get("response"); $storageObj->setResponseSuccess($jsonObjResponse->__get("success")); $jsonObjStorage = $jsonObjResponse->__get("storage"); $this->buildObjectFromJSONTree($storageObj, $jsonObjStorage); if (!$jsonObjStorage->has("jsonDoc")) { return $storageObj; } if ($jsonObjStorage->__get("jsonDoc") instanceof JSONObject) { // Only One attribute is there $jsonObjDoc = $jsonObjStorage->__get("jsonDoc"); $document = new JSONDocument($storageObj); $this->buildJsonDocument($document, $jsonObjDoc); } else { // There is an Array of attribute $jsonObjDocArray = $jsonObjStorage->getJSONArray("jsonDoc"); for ($i = 0; $i < count($jsonObjDocArray); $i++) { // Get Individual Attribute Node and set it into Object $jsonObjDoc = $jsonObjDocArray[$i]; $document = new JSONDocument($storageObj); //$jsonObjDoc = new JSONObject($jsonObjDoc); $this->buildJsonDocument($document, $jsonObjDoc); } } return $storageObj; }
/** * Serialize/Unserialize testing */ public function testSerialize() { $storage = new Storage(); $alphabet = new Alphabet('en', array(), array(), array()); $storage->add($alphabet); $serialized = serialize($storage); $this->assertEquals($storage, unserialize($serialized)); }
public function testCanUnsetAVariable() { $this->namespace->testUnset = 5; $this->assertEquals(5, $this->storage->get('testUnset')); $this->storage->remove('testUnset'); $this->assertFalse(isset($this->namespace->testUnset)); $this->assertFalse($this->storage->has('testUnset')); }
public function testKeysErrorWithEmptyPrefix() { $redis = $this->getMockBuilder('\\Redis')->getMock(); // we expect the exception is thrown, fails if it isn't $this->setExpectedException('Kaavii\\StorageException'); $storage = new Storage($redis, ''); $keys = $storage->keys(); }
function storageAction() { $this->view->title = $this->view->translate->_("Storages"); // get data for form $storages = new Storage(); $this->view->storages = $storages->fetchAll(); $this->view->meta_refresh = 300; // meta http-equiv="refresh" }
public function testFindCompositeKey() { if (!$this->storage->supportsCompositePrimaryKeys()) { $this->markTestSkipped('Composite keys need to be supported for this test to run.'); } $key = ['dist' => 'foo', 'range' => 100]; $this->mockFindCompositeKey($key); $data = $this->storage->find('stdClass', $key); $this->assertEquals(['dist' => 'foo', 'range' => '100', 'timestamp' => new \DateTime('2008-09-18 23:46:19', new \DateTimeZone('UTC')), 'name' => 'Test', 'value' => 23, 'amount' => 200.23, 'bool' => true], $data); }
/** * remove the entry for the storage * * @param string $storageId */ public static function remove($storageId) { $storageCache = new Storage($storageId); $numericId = $storageCache->getNumericId(); if (strlen($storageId) > 64) { $storageId = md5($storageId); } $sql = 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?'; \OC_DB::executeAudited($sql, array($storageId)); $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `storage` = ?'; \OC_DB::executeAudited($sql, array($numericId)); }
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'); } } }
public function store(Request $request) { //dd('jajaja'); $file = $request->file('file'); //obtenemos el campo file obtenido por el formulario $nombre = $file->getClientOriginalName(); //indicamos que queremos guardar un nuevo archivo en el disco local \Storage::disk('local')->put($nombre, \File::get($file)); \Excel::load('/storage/public/files/' . $nombre, function ($archivo) use(&$falla) { $result = $archivo->get(); //leer todas las filas del archivo foreach ($result as $key => $value) { $var = new Periodo(); $datos = ['bloque' => $value->bloque, 'inicio' => $value->inicio, 'fin' => $value->fin]; $validator = Validator::make($datos, Periodo::storeRules()); if ($validator->fails()) { Session::flash('message', 'Los Periodos ya existen o el archivo ingresado no es valido'); $falla = true; } else { $var->fill($datos); $var->save(); } } })->get(); if ($falla) { // Fallo la validacion de algun campus, retornar al index con mensaje return redirect()->route('Administrador.periodos.index'); } \Storage::delete($nombre); Session::flash('message', 'Los Periodos fueron agregados exitosamente!'); return redirect()->route('Administrador.periodos.index'); }
private function getSearch() { if (null === $this->search) { $this->search = new Search($this->storage->getConfig()); } return $this->search; }
/** * @brief clean up user specific settings if user gets deleted * @param array with uid * * This function is connected to the pre_deleteUser signal of OC_Users * to remove the used space for versions stored in the database */ public static function deleteUser_hook($params) { if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') { $uid = $params['uid']; Storage::deleteUser($uid); } }
protected function tearDown() { if ($this->instance) { $this->instance->rmdir('/'); } parent::tearDown(); }
protected function tearDown() { if ($this->instance) { \OCP\Files::rmdirr($this->instance->constructUrl('')); } parent::tearDown(); }
public static function draw($slug, $options = false) { $menu = Storage::where('module', 'menu')->where('name', $slug)->first(); $value = json_decode($menu->value, 1); #Helper::dd($value); #$menu = self::get_menu_level($value->items, $options); }
/** * 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; }
/** * (non-PHPdoc) * @see util/Phirehose::log() */ protected function log($message) { if (!isset($this->db)) { $this->db = Storage::getDatabase(); } $this->db->log('Phirehose', $message); }
/** * Возвращет единственный экземпляр данного класса. * @return object - объект класса Storage */ public static function getInstance() { if (is_null(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
public function postUpload(Request $req) { $response = array(); if ($req->file('excelF')) { $file = $req->file('excelF'); $extension = $file->getClientOriginalExtension(); $filename = $file->getClientOriginalName(); /*periksa extensi file */ if ('xlsx' !== $extension) { $response['code'] = 404; $response['msg'] = "File berextensi {$extension} dengan nama {$filename}, file Seharusnya Berupa Excel"; // $response['msg']="File Anda $file->getClientOriginalName(), Pastikan File yang Anda upload sesuai dengan format "; return $response; // return $response; } elseif (\Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) { // simpan kedadalam table $entry = new Fileentry(); $entry->mime = $file->getClientMimeType(); $entry->original_filename = $file->getClientOriginalName(); $entry->filename = $file->getFilename() . '.' . $extension; $entry->save(); $response['code'] = 200; $response['msg'] = "File {$entry->original_filename} Telah disimpan"; return $response; } } $response['code'] = 404; $response['msg'] = "Gagal Upload File !!!"; return json_encode($response); // echo '{"TEST1": 454535353,"TEST2": "test2"}'; }
/** * function that launch the framework * @param void * @return bool **/ public static function render() : bool { self::get('confs'); self::get(DIR_MODELS); self::get(DIR_CONTROLLERS); // ------------------------------------------------------------------------ // get arguments $args = array_merge($_GET, $_POST); if (empty($args['url'])) { $args['url'] = '/'; } try { // ------------------------------------------------------------------------ // load external librairies Server::loadLibs(); // ------------------------------------------------------------------------ // allow storage for all applications Storage::init(); // ------------------------------------------------------------------------ // allow access to database Database::autoConnect(); // ------------------------------------------------------------------------ // launch controller if (!empty($args['task'])) { Task::exec($args['task'], $args); } else { Route::run($args['url'], $args); } } catch (Exception $e) { echo $e->getMessage(); } return true; }
function salvaArquivosLocal($local, $arquivo, $prefix) { $extArquivo = $arquivo->getClientOriginalExtension(); $nomeArquivo = $prefix . '.' . $extArquivo; $salvaArquivo = Storage::disk($local)->put($nomeArquivo, File::get($arquivo)); return $nomeArquivo; }
/** * validate * * Run validation process * * @return null */ public function validate() { parent::validate(); // compare protection code if (property_exists($this->_data, 'protection_code')) { $protectionCode = \Storage::read('protection-code-register'); \Storage::remove('protection-code-register'); if ($this->_data->protection_code !== $protectionCode) { $this->addMessage('protection_code', \View::$language->register_form_protection_code_invalid); } } // compare password confirmation if (property_exists($this->_data, 'password') && property_exists($this->_data, 'confirm_password') && $this->_data->password !== $this->_data->confirm_password) { $this->addMessage('confirm_password', \View::$language->register_form_password_confirm_mismatch); } // check for existence if ($this->isValid()) { $checkedFields = array('email', 'login'); $UserModel = \App::getInstance('common\\UserModel'); foreach ($checkedFields as $fName) { if ($UserModel->isExists($fName, $this->_data->{$fName})) { $mKey = 'register_form_' . $fName . '_is_exists'; $this->addMessage($fName, \View::$language->{$mKey}); } } } }
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; } }
public function getBaseURL($projectFile) { switch ($this->storage->getDefaultDriver()) { case 'local': return $this->storage->getDriver()->getAdapter()->getPathPrefix() . '/' . $projectFile->getFileName(); } }
/** * lists the documents the user has access to (including shared files, once the code in core has been fixed) * also adds session and member info for these files */ public static function listAll() { self::preDispatch(); $found = Storage::getDocuments(); $fileIds = array(); $documents = array(); foreach ($found as $key => $document) { if (is_object($document)) { $documents[] = $document->getData(); } else { $documents[$key] = $document; } $documents[$key]['icon'] = preg_replace('/\\.png$/', '.svg', \OC_Helper::mimetypeIcon($document['mimetype'])); $fileIds[] = $document['fileid']; } usort($documents, function ($a, $b) { return @$b['mtime'] - @$a['mtime']; }); $session = new Db\Session(); $sessions = $session->getCollectionBy('file_id', $fileIds); $members = array(); $member = new Db\Member(); foreach ($sessions as $session) { $members[$session['es_id']] = $member->getActiveCollection($session['es_id']); } \OCP\JSON::success(array('documents' => $documents, 'sessions' => $sessions, 'members' => $members)); }
/** * Store a newly created resource in storage. * * @param CreatePersonRequest $request * @return Response */ public function postStorepeople(CreatePersonRequest $request) { $people = new People(); $people->document = $request->get('document'); $people->names = $request->get('names'); $people->surnames = $request->get('surnames'); $people->date_of_birth = $request->get('date_of_birth'); $people->landline = $request->get('landline'); $people->address = $request->get('address'); $people->date_of_admission = $request->get('date_of_admission'); $people->cellular = $request->get('cellular'); $upload_dir = \Storage::disk('photos'); $img = $request->get('photo'); $img = str_replace('data:image/png;base64,', '', $img); $data = base64_decode($img); $name = date('YmdHis') . '.png'; $upload_dir->put($name, $data); $people->photo = $name; $people->save(); $email = $request->get('email'); $password = $request->get('password'); $user = new User(['email' => $email, 'password' => $password]); $people->user()->save($user); Session::flash('message', 'Usuario registro correctamente en el sistema.'); return redirect('auth/login'); }
/** * 获取Filesystem * @return Filesystem */ public static function getFileSystem() { if (is_null(static::$driver)) { static::$driver = \Storage::drive('local'); } return static::$driver; }
/** * Register the service provider. * * @return void */ public function register() { // Version specific registering if (abs($this->version()) == 5) { $this->registerLaravel5Lumen(); } // Bind the Croppa URL generator and parser $this->app->singleton('Bkwld\\Croppa\\URL', function ($app) { return new URL($this->getConfig()); }); // Handle the request for an image, this cooridnates the main logic $this->app->singleton('Bkwld\\Croppa\\Handler', function ($app) { return new Handler($app['Bkwld\\Croppa\\URL'], $app['Bkwld\\Croppa\\Storage'], $app['request'], $this->getConfig()); }); // Interact with the disk $this->app->singleton('Bkwld\\Croppa\\Storage', function ($app) { return Storage::make($app, $this->getConfig()); }); // API for use in apps $this->app->singleton('Bkwld\\Croppa\\Helpers', function ($app) { return new Helpers($app['Bkwld\\Croppa\\URL'], $app['Bkwld\\Croppa\\Storage'], $app['Bkwld\\Croppa\\Handler']); }); // Register command to delte all crops $this->app->singleton('Bkwld\\Croppa\\Commands\\Purge', function ($app) { return new Commands\Purge($app['Bkwld\\Croppa\\Storage']); }); // Register all commadns $this->commands('Bkwld\\Croppa\\Commands\\Purge'); }
public static function instance() { if (!isset(self::$instance)) { self::$instance = new self(); } return self::$instance; }
public function destroy($id) { \Storage::delete(Bodega::find($id)->foto); Bodega::destroy($id); Session::flash('message', 'Bodega Eliminada'); return Redirect::to('/bodega'); }
/** * 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; }