PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /home/jairosvt/public_html/afmedios.com/components/com_qcache/
Server: Linux server2.noticiasdecolima.com 4.18.0-553.30.1.el8_10.x86_64 #1 SMP Tue Nov 26 02:30:26 EST 2024 x86_64
IP: 107.161.180.42
Choose File :

Url:
Dir : /home/jairosvt/public_html/afmedios.com/components/com_qcache/qcache.php

<?php
/**
**/
// Check to ensure this file is within the rest of the framework
(defined('_VALID_MOS')||defined('_JEXEC')) or die();

//loadConfig...
include_once('config.qcache.php');

if(!defined('QCACHE_SITE_ID')) {
	$config = JFactory::getConfig();
	$param = $config->db;
	define('QCACHE_SITE_ID',$param);
}

if(!class_exists('qcache_backend')) {
	require_once('backends/'.QCACHE_BACKEND.'.php');
}

$test = rand(1,50);
if($test == 2) {
	register_shutdown_function(array("qcache_main","gc_check"));
}

class qcache_main {
		
	function get($query, $method, $data='') {
		if(!qcache_backend::check($query)) return false;
		$id = qcache_backend::get_id($query, $method, $data);
		$d = qcache_backend::fetch($id);
		if($d === false || !is_string($d)) return false;
		$d = unserialize($d);
		if($d!==false) return $d;
		return false;
	}

	function get_num_rows($query) {
		$id = qcache_backend::get_id($query,'_numRows','');
		$d = qcache_backend::fetch($id);
		if($d!==false) return $d;
		return false;
	}

	function set($query, $method, $data, $array, $pattern, $num_rows) {
		if(!qcache_backend::check($query)) return false;
		$tables = qcache_backend::get_tables($query, $pattern);
		$id = qcache_backend::get_id($query, $method, $data);
		qcache_backend::store(qcache_backend::get_id($query,'_numRows',''),$num_rows);
		foreach($tables AS $val) {
			qcache_backend::set_tables($val[0], $id);
		}
		return qcache_backend::store($id, serialize($array));
	}

	function check_clear($query, $prefix) {
		if((strstr(strtoupper($query),'SELECT') || strstr(strtoupper($query),'SET')) && !strstr(strtoupper($query),'INSERT') && !strstr(strtoupper($query),'UPDATE') && !strstr(strtoupper($query),'REPLACE') && !strstr(strtoupper($query),'ALTER') && ! strstr(strtoupper($query),'DELETE')) {
			//Read Only Query
			return false;
		}
		$tables = qcache_backend::get_tables($query, $prefix);
		$ids = qcache_backend::get_ids($tables);
		foreach($ids AS $val) {
			qcache_backend::_delete($val);
		}
		foreach($tables AS $table) {
			qcache_backend::_delete(QCACHE_SITE_ID.'_qcache_tables_'.$table);
		}
	}

	function get_id($query, $method, $data='') {
		return QCACHE_SITE_ID.'_'.md5(strtoupper($query.$data)).'_'.strtolower($method);
	}

	function check($query) {
		if(!strstr(strtoupper($query),'SELECT') || strstr(strtoupper($query),'INSERT') || strstr(strtoupper($query),'UPDATE') || strstr(strtoupper($query),'REPLACE') || strstr(strtoupper($query),'ALTER') || strstr(strtoupper($query), 'DELETE')) {
			return false;
		}
		$nocache = array("#__session", "session_id");
		foreach($nocache AS $val) if(strstr(strtoupper($query), strtoupper($val))) return false;
		return true;
	}
	
	function get_tables($sql, $pattern) {
		$pattern = "/".preg_quote($pattern)."[\w]*/";
		preg_match_all($pattern, $sql, $tables);
		if(!is_array($tables)) return array();
		return $tables;
	}

	function get_ids($tables) {
		$ids = array();
		foreach($tables AS $val) {
			if(empty($val)) continue;
			$d = qcache_backend::fetch(QCACHE_SITE_ID.'_qcache_tables_'.$val[0]);
			if($d === false || !is_string($d)) continue;
			$cached_items = unserialize($d);
			if(!is_array($cached_items)) continue;
			$ids = array_merge($ids, $cached_items);
		}
		return $ids;
	}

	function set_tables($table, $id) {
		$tables = qcache_backend::fetch(QCACHE_SITE_ID.'_qcache_tables');
		if($tables !== false && is_string($tables)) $tables = unserialize($tables);
		if(!is_array($tables)) $tables = array();
		if(!array_key_exists($table, $tables)) {
			$tables[$table] = true;
			qcache_backend::store(QCACHE_SITE_ID.'_qcache_tables', serialize($tables));
		}
		$items = qcache_backend::fetch(QCACHE_SITE_ID.'_qcache_tables_'.$table);
		if($items !== false&&is_string($items)) $cached_items = unserialize($items);
		if(!is_array($cached_items)) $cached_items = array();
		$cached_items[] = $id;
		return qcache_backend::store(QCACHE_SITE_ID.'_qcache_tables_'.$table, serialize($cached_items));
	}

	function gc_check() {
		$tables = qcache_backend::fetch(QCACHE_SITE_ID.'_qcache_tables');
		if($tables !== false && is_string($tables)) $tables = unserialize($tables);
		if(!is_array($tables)) return false;
		$ids = array();
		foreach($tables AS $key => $val) {
			$items = qcache_backend::fetch(QCACHE_SITE_ID.'_qcache_tables_'.$key);
			if($items=== false || !is_string($items)) continue;
			$cached_items = unserialize($items);
			if(is_array($cached_items)) {
				foreach($cached_items AS $kid => $id) {
					if(!qcache_backend::_isset($id)) {	
						unset($cached_items[$kid]);
					}
				}
				qcache_backend::store(QCACHE_SITE_ID.'_qcache_tables_'.$key, serialize($cached_items));
			} 
		}
	}

}