ÿØÿà JFIF ÿÛ „ ( %"1!%)+...383,7(-.+
-+++--++++---+-+-----+---------------+---+-++7-----ÿÀ ß â" ÿÄ ÿÄ H !1AQaq"‘¡2B±ÁÑð#R“Ò Tbr‚²á3csƒ’ÂñDS¢³$CÿÄ ÿÄ % !1AQa"23‘ÿÚ ? ôÿ ¨pŸªáÿ —åYõõ\?àÒü©ŠÄï¨pŸªáÿ —åYõõ\?àÓü©ŠÄá 0Ÿªáÿ Ÿå[úƒ ú®ði~TÁbqÐ8OÕpÿ ƒOò¤Oè`–RÂáœá™êi€ßÉ< FtŸI“öÌ8úDf´°å}“¾œ6
öFá°y¥jñÇh†ˆ¢ã/ÃÐ:ªcÈ
"Y¡ðÑl>ÿ ”ÏËte:qž\oäŠe÷ó²·˜HT4&ÿ ÓÐü6ö®¿øþßèô Ÿ•7Ñi’•j|“ñì>b…þS?*Óôÿ ÓÐü*h¥£ír¶ü UãS炟[AÐaè[ûª•õ&õj?†Éö+EzP—WeÒírJFt ‘BŒ†Ï‡%#tE Øz ¥OÛ«!1›üä±Í™%ºÍãö]°î(–:@<‹ŒÊö×òÆt¦ãº+‡¦%Ìòh´OƒJŒtMÜ>ÀÜÊw3Y´•牋4ÇýÊTì>œú=Íwhyë,¾Ôò×õ¿ßÊa»«þˆÑªQ|%6ž™A õ%:øj<>É—ÿ Å_ˆCbõ¥š±ý¯Ýƒï…¶|RëócÍf溪“t.СøTÿ *Ä¿-{†çàczůŽ_–^XþŒ±miB[X±d 1,é”zEù»&
î9gœf™9Ð'.;—™i}!ôšåîqêÛ٤ёý£½ÆA–àôe"A$ËÚsäÿ
÷Û #°xŸëí(l
»ý3—¥5m!
rt`†0~'j2(]S¦¦kv,ÚÇl¦øJA£Šƒ
J3E8ÙiŽ:cÉžúeZ°€¯\®kÖ(79«Ž:¯X”¾³Š&¡* ….‰Ž(ÜíŸ2¥ª‡×Hi²TF¤ò[¨íÈRëÉä¢mgÑ.Ÿ<öäS0í„ǹÁU´f#Vß;Õ–…P@3ío<ä-±»Ž.L|kªÀê›fÂ6@»eu‚|ÓaÞÆŸ…¨ááå>åŠ?cKü6ùTÍÆ”†sĤÚ;H2RÚ†õ\Ö·Ÿn'¾ ñ#ºI¤Å´%çÁ‚â7›‹qT3Iï¨ÖÚ5I7Ë!ÅOóŸ¶øÝñØôת¦$Tcö‘[«Ö³šÒ';Aþ ¸èíg
A2Z"i¸vdÄ÷.iõ®§)¿]¤À†–‡É&ä{V¶iŽ”.Ó×Õÿ û?h¬Mt–íª[ÿ Ñÿ ÌV(í}=ibÔ¡›¥¢±b Lô¥‡piη_Z<‡z§èŒ)iÖwiÇ 2hÙ3·=’d÷8éŽ1¦¸c¤µ€7›7Ø ð\á)} ¹fËí›pAÃL%âc2 í§æQz¿;T8sæ°qø)QFMð‰XŒÂ±N¢aF¨…8¯!U Z©RÊ ÖPVÄÀÍin™Ì-GˆªÅËŠ›•zË}º±ŽÍFò¹}Uw×#ä5B¤{î}Ð<ÙD
é©¤&‡ïDbàÁôMÁ. '',
'port' => 11211,
'weight' => 0,
);
/**
* An integer index into the libraries
* @see $libraries
*/
const MCLIB = 1;
const MCLIBD = 2;
/**
* @var array Xrefs the library flag to the actual class name
*/
private $libraries = array(
self::MCLIB => 'Memcache',
self::MCLIBD => 'Memcached'
);
/**
* @var int An indicator of which library we are using
*/
private $libraryFlag;
/**
* Class Constructor.
*
* @param ADOConnection $db
*/
public function __construct($db)
{
$this->hosts = $db->memCacheHost;
$this->port = $this->serverControllerTemplate['port'] = $db->memCachePort;
$this->compress = $db->memCacheCompress;
$this->options = $db->memCacheOptions;
}
/**
* Return true if the current library is Memcached.
* @return bool
*/
public function isLibMemcached(): bool
{
return $this->libraryFlag == self::MCLIBD;
}
/**
* Lazy connection.
*
* The connection only occurs on CacheExecute call.
*
* @param string $err
*
* @return bool success of connecting to a server
*/
public function connect(&$err)
{
// do we have memcache or memcached? see the note at adodb.org on memcache
if (class_exists('Memcache')) {
$this->libraryFlag = self::MCLIB;
} elseif (class_exists('Memcached')) {
$this->libraryFlag = self::MCLIBD;
} else {
$err = 'Neither the Memcache nor Memcached PECL extensions were found!';
return false;
}
$usedLibrary = $this->libraries[$this->libraryFlag];
/** @var Memcache|Memcached $memCache */
$memCache = new $usedLibrary;
if (!$memCache) {
$err = 'Memcache library failed to initialize';
return false;
}
// Convert simple compression flag for memcached
if ($this->isLibMemcached()) {
$this->options[Memcached::OPT_COMPRESSION] = $this->compress;
}
// Are there any options available for memcached
if ($this->isLibMemcached() && count($this->options) > 0) {
$optionSuccess = $memCache->setOptions($this->options);
if (!$optionSuccess) {
$err = 'Invalid option parameters passed to Memcached';
return false;
}
}
// Have we passed a controller array
if (!is_array($this->hosts)) {
$this->hosts = array($this->hosts);
}
if (!is_array($this->hosts[0])) {
// Old way, convert to controller
foreach ($this->hosts as $ipAddress) {
$connector = $this->serverControllerTemplate;
$connector['host'] = $ipAddress;
$connector['port'] = $this->port;
$this->serverControllers[] = $connector;
}
} else {
// New way, must validate port, etc
foreach ($this->hosts as $controller) {
$connector = array_merge($this->serverControllerTemplate, $controller);
if ($this->isLibMemcached()) {
$connector['weight'] = (int)$connector['weight'];
} else {
// Cannot use weight in memcache, simply discard
$connector['weight'] = 0;
}
$this->serverControllers[] = $connector;
}
}
// Checks for existing connections ( but only for memcached )
if ($this->isLibMemcached() && !empty($memCache->getServerList())) {
// Use the existing configuration
$this->isConnected = true;
$this->memcacheLibrary = $memCache;
return true;
}
$failcnt = 0;
foreach ($this->serverControllers as $controller) {
if ($this->isLibMemcached()) {
if (!@$memCache->addServer($controller['host'], $controller['port'], $controller['weight'])) {
$failcnt++;
}
} else {
if (!@$memCache->addServer($controller['host'], $controller['port'])) {
$failcnt++;
}
}
}
if ($failcnt == sizeof($this->serverControllers)) {
$err = 'Can\'t connect to any memcache server';
return false;
}
$this->memcacheLibrary = $memCache;
// A valid memcache connection is available
$this->isConnected = true;
return true;
}
/**
* Writes a cached query to the server
*
* @param string $filename The MD5 of the query to cache
* @param string $contents The query results
* @param bool $debug
* @param int $secs2cache
*
* @return bool true or false. true if successful save
*/
public function writeCache($filename, $contents, $debug, $secs2cache)
{
$err = '';
if (!$this->isConnected && $debug) {
// Call to writeCache() before connect(), try to connect
if (!$this->connect($err)) {
ADOConnection::outp($err);
}
} else {
if (!$this->isConnected) {
$this->connect($err);
}
}
if (!$this->memcacheLibrary) {
return false;
}
$failed = false;
switch ($this->libraryFlag) {
case self::MCLIB:
if (!$this->memcacheLibrary->set($filename, $contents, $this->compress ? MEMCACHE_COMPRESSED : 0,
$secs2cache)) {
$failed = true;
}
break;
case self::MCLIBD:
if (!$this->memcacheLibrary->set($filename, $contents, $secs2cache)) {
$failed = true;
}
break;
default:
$failed = true;
break;
}
if ($failed) {
if ($debug) {
ADOConnection::outp(" Failed to save data at the memcache server!
\n");
}
return false;
}
return true;
}
/**
* Reads a cached query from the server.
*
* @param string $filename The MD5 of the query to read
* @param string $err The query results
* @param int $secs2cache
* @param object $rsClass **UNUSED**
*
* @return object|bool record or false.
*
* @noinspection PhpUnusedParameterInspection
*/
public function readCache($filename, &$err, $secs2cache, $rsClass)
{
if (!$this->isConnected) {
$this->connect($err);
}
if (!$this->memcacheLibrary) {
return false;
}
$rs = $this->memcacheLibrary->get($filename);
if (!$rs) {
$err = 'Item with such key doesn\'t exist on the memcache server.';
return false;
}
// hack, should actually use _csv2rs
$rs = explode("\n", $rs);
unset($rs[0]);
$rs = join("\n", $rs);
$rs = unserialize($rs);
if (!is_object($rs)) {
$err = 'Unable to unserialize $rs';
return false;
}
if ($rs->timeCreated == 0) {
return $rs;
} // apparently have been reports that timeCreated was set to 0 somewhere
$tdiff = intval($rs->timeCreated + $secs2cache - time());
if ($tdiff <= 2) {
switch ($tdiff) {
case 2:
if ((rand() & 15) == 0) {
$err = "Timeout 2";
return false;
}
break;
case 1:
if ((rand() & 3) == 0) {
$err = "Timeout 1";
return false;
}
break;
default:
$err = "Timeout 0";
return false;
}
}
return $rs;
}
/**
* Flushes all of the stored memcache data
*
* @param bool $debug
*
* @return bool The response from the memcache server
*/
public function flushAll($debug = false)
{
if (!$this->isConnected) {
$err = '';
if (!$this->connect($err) && $debug) {
ADOConnection::outp($err);
}
}
if (!$this->memcacheLibrary) {
return false;
}
$del = $this->memcacheLibrary->flush();
if ($debug) {
if (!$del) {
ADOConnection::outp("flushall: failed!
\n");
} else {
ADOConnection::outp("flushall: succeeded!
\n");
}
}
return $del;
}
/**
* Flushes the contents of a specified query
*
* @param string $filename The MD5 of the query to flush
* @param bool $debug
*
* @return bool The response from the memcache server
*/
public function flushCache($filename, $debug = false)
{
if (!$this->isConnected) {
$err = '';
if (!$this->connect($err) && $debug) {
ADOConnection::outp($err);
}
}
if (!$this->memcacheLibrary) {
return false;
}
$del = $this->memcacheLibrary->delete($filename);
if ($debug) {
if (!$del) {
ADOConnection::outp("flushcache: $filename entry doesn't exist on memcache server!
\n");
} else {
ADOConnection::outp("flushcache: $filename entry flushed from memcache server!
\n");
}
}
return $del;
}
}