Beispiel #1
0
$pattern = '/src\s?=\s?\'((?!http)[\w\d\.\/?= -]*)\'/i';
$replace = 'src="'.$url.'/$1"';
$data =  preg_replace($pattern, $replace, $data);

$pattern = '/background\s?=\s?"((?!http)[\w\d\.\/?= -]*)"/i';
$replace = 'background="'.$url.'/$1"';
$data =  preg_replace($pattern, $replace, $data);

$pattern = '/action\s?=\s?"((?!http)[\w\d\.\/?= -]*)"/i';
$replace = 'action="'.$url.'/$1"';
$data =  preg_replace($pattern, $replace, $data);

$pattern = '/,\'\',\'((?!http)[\w\d\.\/?= -]*)\'/i';
$replace = ',\'\',\''.$url.'/$1\'';
$data =  preg_replace($pattern, $replace, $data);

$pattern = array( "\r", "\n" );
$finalPageHtml =  str_replace($pattern, '', $data);
*/
$finalPageHtml = AMP_absolute_urls($nav_output);
if ($format == 'js') {
    $nav_id = $position . mt_rand(1000, 10000);
    $finalPageHtml = AMP_js_write($finalPageHtml, $nav_id);
    //$finalPageHtml = 'var '.$nav_id.'=  { value: \''. str_replace( "'", "\'", $finalPageHtml ) . "'};\ndocument.write( ".$nav_id.".value );";
}
print $finalPageHtml;
if (AMP_is_cacheable_url()) {
    $cache_key = AMP_CACHE_TOKEN_URL_CONTENT . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    $user_id = defined('AMP_SYSTEM_USER_ID') && AMP_SYSTEM_USER_ID ? AMP_SYSTEM_USER_ID : null;
    AMP_cache_set($cache_key, $finalPageHtml, $user_id);
}
function AMP_cache_this_request($finalPageHtml)
{
    if (!AMP_is_cacheable_url()) {
        return;
    }
    $cache_key = AMP_CACHE_TOKEN_URL_CONTENT . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    $user_id = defined('AMP_SYSTEM_USER_ID') && AMP_SYSTEM_USER_ID ? AMP_SYSTEM_USER_ID : null;
    AMP_cache_set($cache_key, $finalPageHtml, $user_id);
    //HTML caching code for apache redirection
    $url_values = AMP_url_read();
    if ($url_values) {
        $section_okay = count($url_values) == 2 && isset($url_values['list']) && isset($url_values['type']);
        $class_okay = count($url_values) == 2 && isset($url_values['list']) && isset($url_values['class']);
        $article_okay = count($url_values) == 1 && isset($url_values['id']);
        $pretty_url_okay = count($url_values) == 1 && isset($url_values['q_url']);
        if (!($section_okay || $article_okay || $class_okay || $pretty_url_okay)) {
            //don't cache pages with any funny vars on them
            return;
        }
    }
    $cache_file = false;
    $cache_folder = false;
    $currentPage = AMPContent_Page::instance();
    if ($currentPage->isArticle()) {
        $cache_folder = AMP_pathFlip(AMP_SYSTEM_CACHE_PATH . DIRECTORY_SEPARATOR . 'article');
        $cache_file = $cache_folder . DIRECTORY_SEPARATOR . $currentPage->getArticleId() . '.html';
    }
    if ($currentPage->isList('type')) {
        $cache_folder = AMP_pathFlip(AMP_SYSTEM_CACHE_PATH . DIRECTORY_SEPARATOR . 'section');
        $cache_file = $cache_folder . DIRECTORY_SEPARATOR . $currentPage->getSectionId() . '.html';
    }
    if ($currentPage->isList('index')) {
        $cache_folder = AMP_pathFlip(AMP_SYSTEM_CACHE_PATH);
        $cache_file = $cache_folder . DIRECTORY_SEPARATOR . 'index.html';
    }
    if (isset($_GET['q_url']) && $_GET['q_url']) {
        $cache_folder = AMP_pathFlip(AMP_SYSTEM_CACHE_PATH . DIRECTORY_SEPARATOR . 'pretty_url');
        $cache_file = $cache_folder . DIRECTORY_SEPARATOR . $_GET['q_url'] . '.html';
    }
    if ($cache_folder) {
        AMP_mkdir($cache_folder);
    }
    if ($cache_file && !file_exists($cache_file)) {
        $cache_out = fopen($cache_file, 'w');
        fwrite($cache_out, $finalPageHtml);
        fclose($cache_out);
    }
}