Файловый менеджер - Редактировать - /var/www/html/Storage.zip
Ðазад
PK ! �x�� � LogStore.phpnu �Iw�� <?php namespace MediaWiki\Extension\Thanks\Storage; use DatabaseLogEntry; use ManualLogEntry; use MediaWiki\CheckUser\Hooks; use MediaWiki\Config\ServiceOptions; use MediaWiki\Extension\Thanks\Storage\Exceptions\InvalidLogType; use MediaWiki\Extension\Thanks\Storage\Exceptions\LogDeleted; use MediaWiki\Registration\ExtensionRegistry; use MediaWiki\User\ActorNormalization; use MediaWiki\User\User; use Wikimedia\Rdbms\IConnectionProvider; /** * Manages the storage for Thank events. * Thanks are stored as logs with relations between users. * Each thank action should have an unique ID generated by callers. */ class LogStore { protected IConnectionProvider $conn; protected ActorNormalization $actorNormalization; public const CONSTRUCTOR_OPTIONS = [ 'ThanksLogging', 'ThanksAllowedLogTypes' ]; protected ServiceOptions $serviceOptions; public function __construct( IConnectionProvider $conn, ActorNormalization $actorNormalization, ServiceOptions $serviceOptions ) { $this->conn = $conn; $this->actorNormalization = $actorNormalization; $serviceOptions->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS ); $this->serviceOptions = $serviceOptions; } /** * @param User $user The user performing the thanks (and the log entry). * @param User $recipient The target of the thanks (and the log entry). * @param string $uniqueId A unique Id to identify the event being thanked for, to use * when checking for duplicate thanks */ public function thank( User $user, User $recipient, string $uniqueId ): void { if ( !$this->serviceOptions->get( 'ThanksLogging' ) ) { return; } $logEntry = new ManualLogEntry( 'thanks', 'thank' ); $logEntry->setPerformer( $user ); $logEntry->setRelations( [ 'thankid' => $uniqueId ] ); $target = $recipient->getUserPage(); $logEntry->setTarget( $target ); $logId = $logEntry->insert(); $logEntry->publish( $logId, 'udp' ); if ( ExtensionRegistry::getInstance()->isLoaded( 'CheckUser' ) ) { $recentChange = $logEntry->getRecentChange(); // TODO: This should be done in a separate hook handler Hooks::updateCheckUserData( $recentChange ); } } /** * This checks the log_search data. * * @param User $thanker The user sending the thanks. * @param string $uniqueId The identifier for the thanks. * @return bool Whether thanks has already been sent */ public function haveThanked( User $thanker, string $uniqueId ): bool { // TODO: Figure out why it's not getting the data from a replica $dbw = $this->conn->getPrimaryDatabase(); $thankerActor = $this->actorNormalization->acquireActorId( $thanker, $dbw ); return (bool)$dbw->newSelectQueryBuilder() ->select( 'ls_value' ) ->from( 'log_search' ) ->join( 'logging', null, [ 'ls_log_id=log_id' ] ) ->where( [ 'log_actor' => $thankerActor, 'ls_field' => 'thankid', 'ls_value' => $uniqueId, ] ) ->caller( __METHOD__ ) ->fetchRow(); } /** * @throws InvalidLogType * @throws LogDeleted */ public function getLogEntryFromId( int $logId ): ?DatabaseLogEntry { $logEntry = DatabaseLogEntry::newFromId( $logId, $this->conn->getPrimaryDatabase() ); if ( !$logEntry ) { return null; } // Make sure this log type is allowed. $allowedLogTypes = $this->serviceOptions->get( 'ThanksAllowedLogTypes' ); if ( !in_array( $logEntry->getType(), $allowedLogTypes ) && !in_array( $logEntry->getType() . '/' . $logEntry->getSubtype(), $allowedLogTypes ) ) { throw new InvalidLogType( $logEntry->getType() ); } // Don't permit thanks if any part of the log entry is deleted. if ( $logEntry->getDeleted() ) { throw new LogDeleted(); } return $logEntry; } } PK ! ^y)�G G Exceptions/InvalidLogType.phpnu �Iw�� <?php namespace MediaWiki\Extension\Thanks\Storage\Exceptions; use Exception; class InvalidLogType extends Exception { private string $logType; public function __construct( string $logType ) { parent::__construct(); $this->logType = $logType; } public function getLogType(): string { return $this->logType; } } PK ! s5��x x Exceptions/LogDeleted.phpnu �Iw�� <?php namespace MediaWiki\Extension\Thanks\Storage\Exceptions; use Exception; class LogDeleted extends Exception { } PK ! ~�1� � JoomlaStorage.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Session\Storage; use Joomla\Input\Input; use Joomla\Registry\Registry; use Joomla\Session\Storage\NativeStorage; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Service provider for the application's session dependency * * @since 4.0.0 */ class JoomlaStorage extends NativeStorage { /** * Internal data store for the session data * * @var Registry * @since 4.0.0 */ private $data; /** * Force cookies to be SSL only * * @var boolean * @since 4.0.0 */ private $forceSSL = false; /** * The domain to set in the session cookie * * @var string * @since 5.0.0 */ private $cookieDomain = ''; /** * The path to set in the session cookie * * @var string * @since 5.0.0 */ private $cookiePath = '/'; /** * Input object * * @var Input * @since 4.0.0 */ private $input; /** * Constructor * * @param Input $input Input object * @param ?\SessionHandlerInterface $handler Session save handler * @param array $options Session options * * @since 4.0.0 */ public function __construct(Input $input, ?\SessionHandlerInterface $handler = null, array $options = []) { // Disable transparent sid support and default use cookies $options += [ 'use_cookies' => 1, 'use_trans_sid' => 0, ]; if (!headers_sent() && !$this->isActive()) { session_cache_limiter('none'); } $this->setOptions($options); $this->setHandler($handler); $this->setCookieParams(); $this->data = new Registry(); $this->input = $input; // Register our function as shutdown method, so we can manipulate it register_shutdown_function([$this, 'close']); } /** * Retrieves all variables from the session store * * @return array * * @since 4.0.0 */ public function all(): array { return $this->data->toArray(); } /** * Clears all variables from the session store * * @return void * * @since 4.0.0 */ public function clear(): void { $session_name = $this->getName(); /* * In order to kill the session altogether, such as to log the user out, the session id * must also be unset. If a cookie is used to propagate the session id (default behavior), * then the session cookie must be deleted. */ if (isset($_COOKIE[$session_name])) { $cookie = session_get_cookie_params(); setcookie($session_name, '', time() - 42000, $this->cookiePath, $this->cookieDomain, $cookie['secure'], true); } $this->data = new Registry(); } /** * Writes session data and ends session * * @return void * * @see session_write_close() * @since 4.0.0 */ public function close(): void { // Before storing data to the session, we serialize and encode the Registry $_SESSION['joomla'] = base64_encode(serialize($this->data)); parent::close(); } /** * Get data from the session store * * @param string $name Name of a variable * @param mixed $default Default value of a variable if not set * * @return mixed Value of a variable * * @since 4.0.0 */ public function get(string $name, $default) { if (!$this->isStarted()) { $this->start(); } return $this->data->get($name, $default); } /** * Check whether data exists in the session store * * @param string $name Name of variable * * @return boolean True if the variable exists * * @since 4.0.0 */ public function has(string $name): bool { if (!$this->isStarted()) { $this->start(); } return $this->data->exists($name); } /** * Unset a variable from the session store * * @param string $name Name of variable * * @return mixed The value from session or NULL if not set * * @since 4.0.0 */ public function remove(string $name) { if (!$this->isStarted()) { $this->start(); } $old = $this->data->get($name); unset($this->data[$name]); return $old; } /** * Set data into the session store * * @param string $name Name of a variable. * @param mixed $value Value of a variable. * * @return mixed Old value of a variable. * * @since 4.0.0 */ public function set(string $name, $value = null) { if (!$this->isStarted()) { $this->start(); } $old = $this->data->get($name); $this->data->set($name, $value); return $old; } /** * Set session cookie parameters * * @return void * * @since 4.0.0 */ protected function setCookieParams(): void { if (headers_sent() || $this->isActive()) { return; } $cookie = session_get_cookie_params(); if ($this->forceSSL) { $cookie['secure'] = true; } if ($this->cookieDomain !== '') { $cookie['domain'] = $this->cookieDomain; } if ($this->cookiePath !== '') { $cookie['path'] = $this->cookiePath; } session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], true); } /** * Sets session options * * @param array $options Session ini directives array(key => value). * * @return $this * * @link http://php.net/session.configuration * @since 4.0.0 */ public function setOptions(array $options): NativeStorage { if (isset($options['cookie_domain'])) { $this->cookieDomain = $options['cookie_domain']; } if (isset($options['cookie_path'])) { $this->cookiePath = $options['cookie_path']; } if (isset($options['force_ssl'])) { $this->forceSSL = (bool) $options['force_ssl']; } return parent::setOptions($options); } /** * Start a session * * @return void * * @since 4.0.0 */ public function start(): void { $session_name = $this->getName(); // Get the cookie object $cookie = $this->input->cookie; if (empty(\ini_get('session.use_only_cookies')) && \is_null($cookie->get($session_name))) { $session_clean = $this->input->getString($session_name); if ($session_clean) { $this->setId($session_clean); $cookie->set($session_name, '', ['expires' => time() - 3600 ]); } } parent::start(); // Try loading data from the session if (!empty($_SESSION['joomla'])) { $this->data = unserialize(base64_decode($_SESSION['joomla'])); } } } PK ! �x�� � LogStore.phpnu �Iw�� PK ! ^y)�G G � Exceptions/InvalidLogType.phpnu �Iw�� PK ! s5��x x Y Exceptions/LogDeleted.phpnu �Iw�� PK ! ~�1� � JoomlaStorage.phpnu �[��� PK S /
| ver. 1.1 | |
.
| PHP 8.4.18 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка