| Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/ |
| Current File : /home/x/b/o/xbodynamge/namtation/wp-content/Cache.php.tar |
home/xbodynamge/www/wp-includes/SimplePie/Cache.php 0000604 00000010310 15112032114 0016267 0 ustar 00 <?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Used to create cache objects
*
* This class can be overloaded with {@see SimplePie::set_cache_class()},
* although the preferred way is to create your own handler
* via {@see register()}
*
* @package SimplePie
* @subpackage Caching
*/
class SimplePie_Cache
{
/**
* Cache handler classes
*
* These receive 3 parameters to their constructor, as documented in
* {@see register()}
* @var array
*/
protected static $handlers = array(
'mysql' => 'SimplePie_Cache_MySQL',
'memcache' => 'SimplePie_Cache_Memcache',
);
/**
* Don't call the constructor. Please.
*/
private function __construct() { }
/**
* Create a new SimplePie_Cache object
*
* @param string $location URL location (scheme is used to determine handler)
* @param string $filename Unique identifier for cache object
* @param string $extension 'spi' or 'spc'
* @return SimplePie_Cache_Base Type of object depends on scheme of `$location`
*/
public static function get_handler($location, $filename, $extension)
{
$type = explode(':', $location, 2);
$type = $type[0];
if (!empty(self::$handlers[$type]))
{
$class = self::$handlers[$type];
return new $class($location, $filename, $extension);
}
return new SimplePie_Cache_File($location, $filename, $extension);
}
/**
* Create a new SimplePie_Cache object
*
* @deprecated Use {@see get_handler} instead
*/
public function create($location, $filename, $extension)
{
trigger_error('Cache::create() has been replaced with Cache::get_handler(). Switch to the registry system to use this.', E_USER_DEPRECATED);
return self::get_handler($location, $filename, $extension);
}
/**
* Register a handler
*
* @param string $type DSN type to register for
* @param string $class Name of handler class. Must implement SimplePie_Cache_Base
*/
public static function register($type, $class)
{
self::$handlers[$type] = $class;
}
/**
* Parse a URL into an array
*
* @param string $url
* @return array
*/
public static function parse_URL($url)
{
$params = parse_url($url);
$params['extras'] = array();
if (isset($params['query']))
{
parse_str($params['query'], $params['extras']);
}
return $params;
}
}
home/xbodynamge/namtation/wp-includes/SimplePie/Cache.php 0000604 00000010310 15112515107 0017445 0 ustar 00 <?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Used to create cache objects
*
* This class can be overloaded with {@see SimplePie::set_cache_class()},
* although the preferred way is to create your own handler
* via {@see register()}
*
* @package SimplePie
* @subpackage Caching
*/
class SimplePie_Cache
{
/**
* Cache handler classes
*
* These receive 3 parameters to their constructor, as documented in
* {@see register()}
* @var array
*/
protected static $handlers = array(
'mysql' => 'SimplePie_Cache_MySQL',
'memcache' => 'SimplePie_Cache_Memcache',
);
/**
* Don't call the constructor. Please.
*/
private function __construct() { }
/**
* Create a new SimplePie_Cache object
*
* @param string $location URL location (scheme is used to determine handler)
* @param string $filename Unique identifier for cache object
* @param string $extension 'spi' or 'spc'
* @return SimplePie_Cache_Base Type of object depends on scheme of `$location`
*/
public static function get_handler($location, $filename, $extension)
{
$type = explode(':', $location, 2);
$type = $type[0];
if (!empty(self::$handlers[$type]))
{
$class = self::$handlers[$type];
return new $class($location, $filename, $extension);
}
return new SimplePie_Cache_File($location, $filename, $extension);
}
/**
* Create a new SimplePie_Cache object
*
* @deprecated Use {@see get_handler} instead
*/
public function create($location, $filename, $extension)
{
trigger_error('Cache::create() has been replaced with Cache::get_handler(). Switch to the registry system to use this.', E_USER_DEPRECATED);
return self::get_handler($location, $filename, $extension);
}
/**
* Register a handler
*
* @param string $type DSN type to register for
* @param string $class Name of handler class. Must implement SimplePie_Cache_Base
*/
public static function register($type, $class)
{
self::$handlers[$type] = $class;
}
/**
* Parse a URL into an array
*
* @param string $url
* @return array
*/
public static function parse_URL($url)
{
$params = parse_url($url);
$params['extras'] = array();
if (isset($params['query']))
{
parse_str($params['query'], $params['extras']);
}
return $params;
}
}
home/xbodynamge/lebauwcentre/wp-includes/SimplePie/Cache.php 0000604 00000010310 15112553410 0020132 0 ustar 00 <?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Used to create cache objects
*
* This class can be overloaded with {@see SimplePie::set_cache_class()},
* although the preferred way is to create your own handler
* via {@see register()}
*
* @package SimplePie
* @subpackage Caching
*/
class SimplePie_Cache
{
/**
* Cache handler classes
*
* These receive 3 parameters to their constructor, as documented in
* {@see register()}
* @var array
*/
protected static $handlers = array(
'mysql' => 'SimplePie_Cache_MySQL',
'memcache' => 'SimplePie_Cache_Memcache',
);
/**
* Don't call the constructor. Please.
*/
private function __construct() { }
/**
* Create a new SimplePie_Cache object
*
* @param string $location URL location (scheme is used to determine handler)
* @param string $filename Unique identifier for cache object
* @param string $extension 'spi' or 'spc'
* @return SimplePie_Cache_Base Type of object depends on scheme of `$location`
*/
public static function get_handler($location, $filename, $extension)
{
$type = explode(':', $location, 2);
$type = $type[0];
if (!empty(self::$handlers[$type]))
{
$class = self::$handlers[$type];
return new $class($location, $filename, $extension);
}
return new SimplePie_Cache_File($location, $filename, $extension);
}
/**
* Create a new SimplePie_Cache object
*
* @deprecated Use {@see get_handler} instead
*/
public function create($location, $filename, $extension)
{
trigger_error('Cache::create() has been replaced with Cache::get_handler(). Switch to the registry system to use this.', E_USER_DEPRECATED);
return self::get_handler($location, $filename, $extension);
}
/**
* Register a handler
*
* @param string $type DSN type to register for
* @param string $class Name of handler class. Must implement SimplePie_Cache_Base
*/
public static function register($type, $class)
{
self::$handlers[$type] = $class;
}
/**
* Parse a URL into an array
*
* @param string $url
* @return array
*/
public static function parse_URL($url)
{
$params = parse_url($url);
$params['extras'] = array();
if (isset($params['query']))
{
parse_str($params['query'], $params['extras']);
}
return $params;
}
}
home/xbodynamge/crosstraining/wp-includes/SimplePie/Cache.php 0000604 00000010310 15113554731 0020347 0 ustar 00 <?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Used to create cache objects
*
* This class can be overloaded with {@see SimplePie::set_cache_class()},
* although the preferred way is to create your own handler
* via {@see register()}
*
* @package SimplePie
* @subpackage Caching
*/
class SimplePie_Cache
{
/**
* Cache handler classes
*
* These receive 3 parameters to their constructor, as documented in
* {@see register()}
* @var array
*/
protected static $handlers = array(
'mysql' => 'SimplePie_Cache_MySQL',
'memcache' => 'SimplePie_Cache_Memcache',
);
/**
* Don't call the constructor. Please.
*/
private function __construct() { }
/**
* Create a new SimplePie_Cache object
*
* @param string $location URL location (scheme is used to determine handler)
* @param string $filename Unique identifier for cache object
* @param string $extension 'spi' or 'spc'
* @return SimplePie_Cache_Base Type of object depends on scheme of `$location`
*/
public static function get_handler($location, $filename, $extension)
{
$type = explode(':', $location, 2);
$type = $type[0];
if (!empty(self::$handlers[$type]))
{
$class = self::$handlers[$type];
return new $class($location, $filename, $extension);
}
return new SimplePie_Cache_File($location, $filename, $extension);
}
/**
* Create a new SimplePie_Cache object
*
* @deprecated Use {@see get_handler} instead
*/
public function create($location, $filename, $extension)
{
trigger_error('Cache::create() has been replaced with Cache::get_handler(). Switch to the registry system to use this.', E_USER_DEPRECATED);
return self::get_handler($location, $filename, $extension);
}
/**
* Register a handler
*
* @param string $type DSN type to register for
* @param string $class Name of handler class. Must implement SimplePie_Cache_Base
*/
public static function register($type, $class)
{
self::$handlers[$type] = $class;
}
/**
* Parse a URL into an array
*
* @param string $url
* @return array
*/
public static function parse_URL($url)
{
$params = parse_url($url);
$params['extras'] = array();
if (isset($params['query']))
{
parse_str($params['query'], $params['extras']);
}
return $params;
}
}
home/xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Cache.php 0000644 00000021126 15114001021 0025644 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Handles our cache.
*
* @since 4.1.5
*/
class Cache {
/**
* Our cache table.
*
* @since 4.1.5
*
* @var string
*/
private $table = 'aioseo_cache';
/**
* Our cached cache.
*
* @since 4.1.5
*
* @var array
*/
private static $cache = [];
/**
* The Cache Prune class.
*
* @since 4.1.5
*
* @var CachePrune
*/
public $prune;
/**
* Prefix for this cache.
*
* @since 4.1.5
*
* @var string
*/
protected $prefix = '';
/**
* Class constructor.
*
* @since 4.7.7.1
*/
public function __construct() {
add_action( 'init', [ $this, 'checkIfTableExists' ] ); // This needs to run on init because the DB
// class gets instantiated along with the cache class.
}
/**
* Checks if the cache table exists and creates it if it doesn't.
*
* @since 4.7.7.1
*
* @return void
*/
public function checkIfTableExists() {
if ( ! aioseo()->core->db->tableExists( $this->table ) ) {
aioseo()->preUpdates->createCacheTable();
}
}
/**
* Returns the cache value for a key if it exists and is not expired.
*
* @since 4.1.5
*
* @param string $key The cache key name. Use a '%' for a like query.
* @param bool|array $allowedClasses Whether to allow objects to be returned.
* @return mixed The value or null if the cache does not exist.
*/
public function get( $key, $allowedClasses = false ) {
$key = $this->prepareKey( $key );
if ( isset( self::$cache[ $key ] ) ) {
return self::$cache[ $key ];
}
// Are we searching for a group of keys?
$isLikeGet = preg_match( '/%/', (string) $key );
$result = aioseo()->core->db
->start( $this->table )
->select( '`key`, `value`' )
->whereRaw( '( `expiration` IS NULL OR `expiration` > \'' . aioseo()->helpers->timeToMysql( time() ) . '\' )' );
$isLikeGet ?
$result->whereRaw( '`key` LIKE \'' . $key . '\'' ) :
$result->where( 'key', $key );
$result->output( ARRAY_A )->run();
// If we have nothing in the cache let's return a hard null.
$values = $result->nullSet() ? null : $result->result();
// If we have something let's normalize it.
if ( $values ) {
foreach ( $values as &$value ) {
$value['value'] = aioseo()->helpers->maybeUnserialize( $value['value'], $allowedClasses );
}
// Return only the single cache value.
if ( ! $isLikeGet ) {
$values = $values[0]['value'];
}
}
// Return values without a static cache.
// This is here because clearing the like cache is not simple.
if ( $isLikeGet ) {
return $values;
}
self::$cache[ $key ] = $values;
return self::$cache[ $key ];
}
/**
* Updates the given cache or creates it if it doesn't exist.
*
* @since 4.1.5
*
* @param string $key The cache key name.
* @param mixed $value The value.
* @param int $expiration The expiration time in seconds. Defaults to 24 hours. 0 to no expiration.
* @return void
*/
public function update( $key, $value, $expiration = DAY_IN_SECONDS ) {
// If the value is null we'll convert it and give it a shorter expiration.
if ( null === $value ) {
$value = false;
$expiration = 10 * MINUTE_IN_SECONDS;
}
$serializedValue = serialize( $value );
$expiration = 0 < $expiration ? aioseo()->helpers->timeToMysql( time() + $expiration ) : null;
aioseo()->core->db->insert( $this->table )
->set( [
'key' => $this->prepareKey( $key ),
'value' => $serializedValue,
'expiration' => $expiration,
'created' => aioseo()->helpers->timeToMysql( time() ),
'updated' => aioseo()->helpers->timeToMysql( time() )
] )
->onDuplicate( [
'value' => $serializedValue,
'expiration' => $expiration,
'updated' => aioseo()->helpers->timeToMysql( time() )
] )
->run();
$this->updateStatic( $key, $value );
}
/**
* Deletes the given cache key.
*
* @since 4.1.5
*
* @param string $key The cache key.
* @return void
*/
public function delete( $key ) {
$key = $this->prepareKey( $key );
aioseo()->core->db->delete( $this->table )
->where( 'key', $key )
->run();
$this->clearStatic( $key );
}
/**
* Prepares the key before using the cache.
*
* @since 4.1.5
*
* @param string $key The key to prepare.
* @return string The prepared key.
*/
private function prepareKey( $key ) {
$key = trim( $key );
$key = $this->prefix && 0 !== strpos( $key, $this->prefix ) ? $this->prefix . $key : $key;
if ( aioseo()->helpers->isDev() && 80 < mb_strlen( $key, 'UTF-8' ) ) {
throw new \Exception( 'You are using a cache key that is too large, shorten your key and try again: [' . esc_html( $key ) . ']' );
}
return $key;
}
/**
* Clears all of our cache.
*
* @since 4.1.5
*
* @return void
*/
public function clear() {
// Bust the tableExists and columnExists cache.
aioseo()->internalOptions->database->installedTables = '';
if ( $this->prefix ) {
$this->clearPrefix( '' );
return;
}
// Try to acquire the lock.
if ( ! aioseo()->core->db->acquireLock( 'aioseo_cache_clear_lock', 0 ) ) {
// If we couldn't acquire the lock, exit early without doing anything.
// This means another process is already clearing the cache.
return;
}
// If we find the activation redirect, we'll need to reset it after clearing.
$activationRedirect = $this->get( 'activation_redirect' );
// Create a temporary table with the same structure.
$table = aioseo()->core->db->prefix . $this->table;
$newTable = aioseo()->core->db->prefix . $this->table . '_new';
$oldTable = aioseo()->core->db->prefix . $this->table . '_old';
try {
// Drop the temp table if it exists from a previous failed attempt.
if ( false === aioseo()->core->db->execute( "DROP TABLE IF EXISTS {$newTable}" ) ) {
throw new \Exception( 'Failed to drop temporary table' );
}
// Create the new empty table with the same structure.
if ( false === aioseo()->core->db->execute( "CREATE TABLE {$newTable} LIKE {$table}" ) ) {
throw new \Exception( 'Failed to create temporary table' );
}
// Rename tables (atomic operation in MySQL).
if ( false === aioseo()->core->db->execute( "RENAME TABLE {$table} TO {$oldTable}, {$newTable} TO {$table}" ) ) {
throw new \Exception( 'Failed to rename tables' );
}
// Drop the old table.
if ( false === aioseo()->core->db->execute( "DROP TABLE {$oldTable}" ) ) {
throw new \Exception( 'Failed to drop old table' );
}
} catch ( \Exception $e ) {
// If something fails, ensure we clean up any temporary tables.
aioseo()->core->db->execute( "DROP TABLE IF EXISTS {$newTable}" );
aioseo()->core->db->execute( "DROP TABLE IF EXISTS {$oldTable}" );
// Truncate table to clear the cache.
aioseo()->core->db->truncate( $this->table )->run();
}
$this->clearStatic();
if ( $activationRedirect ) {
$this->update( 'activation_redirect', $activationRedirect, 30 );
}
}
/**
* Clears all of our cache under a certain prefix.
*
* @since 4.1.5
*
* @param string $prefix A prefix to clear or empty to clear everything.
* @return void
*/
public function clearPrefix( $prefix ) {
$prefix = $this->prepareKey( $prefix );
aioseo()->core->db->delete( $this->table )
->whereRaw( "`key` LIKE '$prefix%'" )
->run();
$this->clearStaticPrefix( $prefix );
}
/**
* Clears all of our static in-memory cache of a prefix.
*
* @since 4.1.5
*
* @param string $prefix A prefix to clear.
* @return void
*/
private function clearStaticPrefix( $prefix ) {
$prefix = $this->prepareKey( $prefix );
foreach ( array_keys( self::$cache ) as $key ) {
if ( 0 === strpos( $key, $prefix ) ) {
unset( self::$cache[ $key ] );
}
}
}
/**
* Clears all of our static in-memory cache.
*
* @since 4.1.5
*
* @param string $key A key to clear.
* @return void
*/
private function clearStatic( $key = null ) {
if ( empty( $key ) ) {
self::$cache = [];
return;
}
unset( self::$cache[ $this->prepareKey( $key ) ] );
}
/**
* Clears all of our static in-memory cache or the cache for a single given key.
*
* @since 4.7.1
*
* @param string $key A key to clear (optional).
* @param string $value A value to update (optional).
* @return void
*/
private function updateStatic( $key = null, $value = null ) {
if ( empty( $key ) ) {
$this->clearStatic( $key );
return;
}
self::$cache[ $this->prepareKey( $key ) ] = $value;
}
/**
* Returns the cache table name.
*
* @since 4.1.5
*
* @return string
*/
public function getTableName() {
return $this->table;
}
} home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Cache.php 0000644 00000021126 15114110030 0024431 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Handles our cache.
*
* @since 4.1.5
*/
class Cache {
/**
* Our cache table.
*
* @since 4.1.5
*
* @var string
*/
private $table = 'aioseo_cache';
/**
* Our cached cache.
*
* @since 4.1.5
*
* @var array
*/
private static $cache = [];
/**
* The Cache Prune class.
*
* @since 4.1.5
*
* @var CachePrune
*/
public $prune;
/**
* Prefix for this cache.
*
* @since 4.1.5
*
* @var string
*/
protected $prefix = '';
/**
* Class constructor.
*
* @since 4.7.7.1
*/
public function __construct() {
add_action( 'init', [ $this, 'checkIfTableExists' ] ); // This needs to run on init because the DB
// class gets instantiated along with the cache class.
}
/**
* Checks if the cache table exists and creates it if it doesn't.
*
* @since 4.7.7.1
*
* @return void
*/
public function checkIfTableExists() {
if ( ! aioseo()->core->db->tableExists( $this->table ) ) {
aioseo()->preUpdates->createCacheTable();
}
}
/**
* Returns the cache value for a key if it exists and is not expired.
*
* @since 4.1.5
*
* @param string $key The cache key name. Use a '%' for a like query.
* @param bool|array $allowedClasses Whether to allow objects to be returned.
* @return mixed The value or null if the cache does not exist.
*/
public function get( $key, $allowedClasses = false ) {
$key = $this->prepareKey( $key );
if ( isset( self::$cache[ $key ] ) ) {
return self::$cache[ $key ];
}
// Are we searching for a group of keys?
$isLikeGet = preg_match( '/%/', (string) $key );
$result = aioseo()->core->db
->start( $this->table )
->select( '`key`, `value`' )
->whereRaw( '( `expiration` IS NULL OR `expiration` > \'' . aioseo()->helpers->timeToMysql( time() ) . '\' )' );
$isLikeGet ?
$result->whereRaw( '`key` LIKE \'' . $key . '\'' ) :
$result->where( 'key', $key );
$result->output( ARRAY_A )->run();
// If we have nothing in the cache let's return a hard null.
$values = $result->nullSet() ? null : $result->result();
// If we have something let's normalize it.
if ( $values ) {
foreach ( $values as &$value ) {
$value['value'] = aioseo()->helpers->maybeUnserialize( $value['value'], $allowedClasses );
}
// Return only the single cache value.
if ( ! $isLikeGet ) {
$values = $values[0]['value'];
}
}
// Return values without a static cache.
// This is here because clearing the like cache is not simple.
if ( $isLikeGet ) {
return $values;
}
self::$cache[ $key ] = $values;
return self::$cache[ $key ];
}
/**
* Updates the given cache or creates it if it doesn't exist.
*
* @since 4.1.5
*
* @param string $key The cache key name.
* @param mixed $value The value.
* @param int $expiration The expiration time in seconds. Defaults to 24 hours. 0 to no expiration.
* @return void
*/
public function update( $key, $value, $expiration = DAY_IN_SECONDS ) {
// If the value is null we'll convert it and give it a shorter expiration.
if ( null === $value ) {
$value = false;
$expiration = 10 * MINUTE_IN_SECONDS;
}
$serializedValue = serialize( $value );
$expiration = 0 < $expiration ? aioseo()->helpers->timeToMysql( time() + $expiration ) : null;
aioseo()->core->db->insert( $this->table )
->set( [
'key' => $this->prepareKey( $key ),
'value' => $serializedValue,
'expiration' => $expiration,
'created' => aioseo()->helpers->timeToMysql( time() ),
'updated' => aioseo()->helpers->timeToMysql( time() )
] )
->onDuplicate( [
'value' => $serializedValue,
'expiration' => $expiration,
'updated' => aioseo()->helpers->timeToMysql( time() )
] )
->run();
$this->updateStatic( $key, $value );
}
/**
* Deletes the given cache key.
*
* @since 4.1.5
*
* @param string $key The cache key.
* @return void
*/
public function delete( $key ) {
$key = $this->prepareKey( $key );
aioseo()->core->db->delete( $this->table )
->where( 'key', $key )
->run();
$this->clearStatic( $key );
}
/**
* Prepares the key before using the cache.
*
* @since 4.1.5
*
* @param string $key The key to prepare.
* @return string The prepared key.
*/
private function prepareKey( $key ) {
$key = trim( $key );
$key = $this->prefix && 0 !== strpos( $key, $this->prefix ) ? $this->prefix . $key : $key;
if ( aioseo()->helpers->isDev() && 80 < mb_strlen( $key, 'UTF-8' ) ) {
throw new \Exception( 'You are using a cache key that is too large, shorten your key and try again: [' . esc_html( $key ) . ']' );
}
return $key;
}
/**
* Clears all of our cache.
*
* @since 4.1.5
*
* @return void
*/
public function clear() {
// Bust the tableExists and columnExists cache.
aioseo()->internalOptions->database->installedTables = '';
if ( $this->prefix ) {
$this->clearPrefix( '' );
return;
}
// Try to acquire the lock.
if ( ! aioseo()->core->db->acquireLock( 'aioseo_cache_clear_lock', 0 ) ) {
// If we couldn't acquire the lock, exit early without doing anything.
// This means another process is already clearing the cache.
return;
}
// If we find the activation redirect, we'll need to reset it after clearing.
$activationRedirect = $this->get( 'activation_redirect' );
// Create a temporary table with the same structure.
$table = aioseo()->core->db->prefix . $this->table;
$newTable = aioseo()->core->db->prefix . $this->table . '_new';
$oldTable = aioseo()->core->db->prefix . $this->table . '_old';
try {
// Drop the temp table if it exists from a previous failed attempt.
if ( false === aioseo()->core->db->execute( "DROP TABLE IF EXISTS {$newTable}" ) ) {
throw new \Exception( 'Failed to drop temporary table' );
}
// Create the new empty table with the same structure.
if ( false === aioseo()->core->db->execute( "CREATE TABLE {$newTable} LIKE {$table}" ) ) {
throw new \Exception( 'Failed to create temporary table' );
}
// Rename tables (atomic operation in MySQL).
if ( false === aioseo()->core->db->execute( "RENAME TABLE {$table} TO {$oldTable}, {$newTable} TO {$table}" ) ) {
throw new \Exception( 'Failed to rename tables' );
}
// Drop the old table.
if ( false === aioseo()->core->db->execute( "DROP TABLE {$oldTable}" ) ) {
throw new \Exception( 'Failed to drop old table' );
}
} catch ( \Exception $e ) {
// If something fails, ensure we clean up any temporary tables.
aioseo()->core->db->execute( "DROP TABLE IF EXISTS {$newTable}" );
aioseo()->core->db->execute( "DROP TABLE IF EXISTS {$oldTable}" );
// Truncate table to clear the cache.
aioseo()->core->db->truncate( $this->table )->run();
}
$this->clearStatic();
if ( $activationRedirect ) {
$this->update( 'activation_redirect', $activationRedirect, 30 );
}
}
/**
* Clears all of our cache under a certain prefix.
*
* @since 4.1.5
*
* @param string $prefix A prefix to clear or empty to clear everything.
* @return void
*/
public function clearPrefix( $prefix ) {
$prefix = $this->prepareKey( $prefix );
aioseo()->core->db->delete( $this->table )
->whereRaw( "`key` LIKE '$prefix%'" )
->run();
$this->clearStaticPrefix( $prefix );
}
/**
* Clears all of our static in-memory cache of a prefix.
*
* @since 4.1.5
*
* @param string $prefix A prefix to clear.
* @return void
*/
private function clearStaticPrefix( $prefix ) {
$prefix = $this->prepareKey( $prefix );
foreach ( array_keys( self::$cache ) as $key ) {
if ( 0 === strpos( $key, $prefix ) ) {
unset( self::$cache[ $key ] );
}
}
}
/**
* Clears all of our static in-memory cache.
*
* @since 4.1.5
*
* @param string $key A key to clear.
* @return void
*/
private function clearStatic( $key = null ) {
if ( empty( $key ) ) {
self::$cache = [];
return;
}
unset( self::$cache[ $this->prepareKey( $key ) ] );
}
/**
* Clears all of our static in-memory cache or the cache for a single given key.
*
* @since 4.7.1
*
* @param string $key A key to clear (optional).
* @param string $value A value to update (optional).
* @return void
*/
private function updateStatic( $key = null, $value = null ) {
if ( empty( $key ) ) {
$this->clearStatic( $key );
return;
}
self::$cache[ $this->prepareKey( $key ) ] = $value;
}
/**
* Returns the cache table name.
*
* @since 4.1.5
*
* @return string
*/
public function getTableName() {
return $this->table;
}
} home/xbodynamge/dev/wp-includes/SimplePie/Cache.php 0000604 00000010310 15114404352 0016232 0 ustar 00 <?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @version 1.3.1
* @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* Used to create cache objects
*
* This class can be overloaded with {@see SimplePie::set_cache_class()},
* although the preferred way is to create your own handler
* via {@see register()}
*
* @package SimplePie
* @subpackage Caching
*/
class SimplePie_Cache
{
/**
* Cache handler classes
*
* These receive 3 parameters to their constructor, as documented in
* {@see register()}
* @var array
*/
protected static $handlers = array(
'mysql' => 'SimplePie_Cache_MySQL',
'memcache' => 'SimplePie_Cache_Memcache',
);
/**
* Don't call the constructor. Please.
*/
private function __construct() { }
/**
* Create a new SimplePie_Cache object
*
* @param string $location URL location (scheme is used to determine handler)
* @param string $filename Unique identifier for cache object
* @param string $extension 'spi' or 'spc'
* @return SimplePie_Cache_Base Type of object depends on scheme of `$location`
*/
public static function get_handler($location, $filename, $extension)
{
$type = explode(':', $location, 2);
$type = $type[0];
if (!empty(self::$handlers[$type]))
{
$class = self::$handlers[$type];
return new $class($location, $filename, $extension);
}
return new SimplePie_Cache_File($location, $filename, $extension);
}
/**
* Create a new SimplePie_Cache object
*
* @deprecated Use {@see get_handler} instead
*/
public function create($location, $filename, $extension)
{
trigger_error('Cache::create() has been replaced with Cache::get_handler(). Switch to the registry system to use this.', E_USER_DEPRECATED);
return self::get_handler($location, $filename, $extension);
}
/**
* Register a handler
*
* @param string $type DSN type to register for
* @param string $class Name of handler class. Must implement SimplePie_Cache_Base
*/
public static function register($type, $class)
{
self::$handlers[$type] = $class;
}
/**
* Parse a URL into an array
*
* @param string $url
* @return array
*/
public static function parse_URL($url)
{
$params = parse_url($url);
$params['extras'] = array();
if (isset($params['query']))
{
parse_str($params['query'], $params['extras']);
}
return $params;
}
}
home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/Options/Cache.php 0000644 00000003103 15114613221 0024771 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Options;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class that holds all the cache for the AIOSEO options.
*
* @since 4.1.4
*/
class Cache {
/**
* The DB options cache.
*
* @since 4.1.4
*
* @var array
*/
private static $db = [];
/**
* The options cache.
*
* @since 4.1.4
*
* @var array
*/
private static $options = [];
/**
* Sets the cache for the DB option.
*
* @since 4.1.4
*
* @param string $name The cache name.
* @param array $value The value.
* @return void
*/
public function setDb( $name, $value ) {
self::$db[ $name ] = $value;
}
/**
* Gets the cache for the DB option.
*
* @since 4.1.4
*
* @param string $name The cache name.
* @return array The data from the cache.
*/
public function getDb( $name ) {
return ! empty( self::$db[ $name ] ) ? self::$db[ $name ] : [];
}
/**
* Sets the cache for the options.
*
* @since 4.1.4
*
* @param string $name The cache name.
* @param array $value The value.
* @return void
*/
public function setOptions( $name, $value ) {
self::$options[ $name ] = $value;
}
/**
* Gets the cache for the options.
*
* @since 4.1.4
*
* @param string $name The cache name.
* @return array The data from the cache.
*/
public function getOptions( $name ) {
return ! empty( self::$options[ $name ] ) ? self::$options[ $name ] : [];
}
/**
* Resets the DB cache.
*
* @since 4.1.4
*
* @return void
*/
public function resetDb() {
self::$db = [];
}
} home/xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/Options/Cache.php 0000644 00000003103 15114636077 0026223 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Options;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class that holds all the cache for the AIOSEO options.
*
* @since 4.1.4
*/
class Cache {
/**
* The DB options cache.
*
* @since 4.1.4
*
* @var array
*/
private static $db = [];
/**
* The options cache.
*
* @since 4.1.4
*
* @var array
*/
private static $options = [];
/**
* Sets the cache for the DB option.
*
* @since 4.1.4
*
* @param string $name The cache name.
* @param array $value The value.
* @return void
*/
public function setDb( $name, $value ) {
self::$db[ $name ] = $value;
}
/**
* Gets the cache for the DB option.
*
* @since 4.1.4
*
* @param string $name The cache name.
* @return array The data from the cache.
*/
public function getDb( $name ) {
return ! empty( self::$db[ $name ] ) ? self::$db[ $name ] : [];
}
/**
* Sets the cache for the options.
*
* @since 4.1.4
*
* @param string $name The cache name.
* @param array $value The value.
* @return void
*/
public function setOptions( $name, $value ) {
self::$options[ $name ] = $value;
}
/**
* Gets the cache for the options.
*
* @since 4.1.4
*
* @param string $name The cache name.
* @return array The data from the cache.
*/
public function getOptions( $name ) {
return ! empty( self::$options[ $name ] ) ? self::$options[ $name ] : [];
}
/**
* Resets the DB cache.
*
* @since 4.1.4
*
* @return void
*/
public function resetDb() {
self::$db = [];
}
}