Server : LiteSpeed System : Linux server321.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64 User : apotdzgr ( 7060) PHP Version : 8.0.30 Disable Function : NONE Directory : /home/apotdzgr/www/wp-content/plugins/nextend-facebook-connect/NSL/Persistent/Storage/ |
Upload File : |
<?php namespace NSL\Persistent\Storage; abstract class StorageAbstract { protected $sessionId = null; protected $data = array(); public function set($key, $value) { $this->load(true); $this->data[$key] = $value; $this->store(); } public function get($key) { $this->load(); if (isset($this->data[$key])) { return $this->data[$key]; } return null; } public function delete($key) { $this->load(); if (isset($this->data[$key])) { unset($this->data[$key]); $this->store(); } } public function clear() { $this->data = array(); $this->store(); } protected function load($createSession = false) { static $isLoaded = false; if (!$isLoaded) { $data = maybe_unserialize(get_site_transient($this->sessionId)); if (is_array($data)) { $this->data = $data; } $isLoaded = true; } } private function store() { if (empty($this->data)) { delete_site_transient($this->sessionId); } else { set_site_transient($this->sessionId, $this->data, apply_filters('nsl_persistent_expiration', HOUR_IN_SECONDS)); } } /** * @param StorageAbstract $storage */ public function transferData($storage) { $this->data = $storage->data; $this->store(); $storage->clear(); } }