AnonSec Team
Server IP : 10.2.73.233  /  Your IP : 216.73.216.59
Web Server : Apache/2.4.59 (Debian)
System : Linux polon 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64
User : www-data ( 33)
PHP Version : 5.6.40-64+0~20230107.71+debian10~1.gbp673146
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/ilpnowa/../ifk/web/prado4.3.2/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/ilpnowa/../ifk/web/prado4.3.2/TApplicationStatePersister.php
<?php
/**
 * TApplication class file
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @link https://github.com/pradosoft/prado
 * @license https://github.com/pradosoft/prado/blob/master/LICENSE
 */

namespace Prado;

/**
 * TApplicationStatePersister class.
 * TApplicationStatePersister provides a file-based persistent storage
 * for application state. Application state, when serialized, is stored
 * in a file named 'global.cache' under the 'runtime' directory of the application.
 * Cache will be exploited if it is enabled.
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @since 3.0
 */
class TApplicationStatePersister extends \Prado\TModule implements IStatePersister
{
	/**
	 * Name of the value stored in cache
	 */
	public const CACHE_NAME = 'prado:appstate';

	/**
	 * Initializes module.
	 * @param \Prado\Xml\TXmlElement $config module configuration (may be null)
	 */
	public function init($config)
	{
		$this->getApplication()->setApplicationStatePersister($this);
		parent::init($config);
	}

	/**
	 * @return string the file path storing the application state
	 */
	protected function getStateFilePath()
	{
		return $this->getApplication()->getRuntimePath() . '/global.cache';
	}

	/**
	 * Loads application state from persistent storage.
	 * @return mixed application state
	 */
	public function load()
	{
		if (($cache = $this->getApplication()->getCache()) !== null && ($value = $cache->get(self::CACHE_NAME)) !== false) {
			return unserialize($value);
		} else {
			if (($content = @file_get_contents($this->getStateFilePath())) !== false) {
				return unserialize($content);
			} else {
				return null;
			}
		}
	}

	/**
	 * Saves application state in persistent storage.
	 * @param mixed $state application state
	 */
	public function save($state)
	{
		$content = serialize($state);
		$saveFile = true;
		if (($cache = $this->getApplication()->getCache()) !== null) {
			if ($cache->get(self::CACHE_NAME) === $content) {
				$saveFile = false;
			} else {
				$cache->set(self::CACHE_NAME, $content);
			}
		}
		if ($saveFile) {
			$fileName = $this->getStateFilePath();
			file_put_contents($fileName, $content, LOCK_EX);
		}
	}
}

AnonSec - 2021