/** * nv_xmlOutput() * * @param string $content * @param mixed $lastModified * @return void */ function nv_xmlOutput($content, $lastModified) { $tidy_options = array('input-xml' => true, 'output-xml' => true, 'indent' => true, 'indent-cdata' => true, 'wrap' => false); $content = (string) nv_valid_html($content, $tidy_options, 'utf8'); @Header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastModified) . " GMT"); @Header("Expires: " . gmdate("D, d M Y H:i:s", $lastModified) . " GMT"); @Header("Content-Type: text/xml; charset=utf-8"); if (!empty($_SERVER['SERVER_SOFTWARE']) and strstr($_SERVER['SERVER_SOFTWARE'], 'Apache/2')) { @Header("Cache-Control: no-cache, pre-check=0, post-check=0"); } else { @Header("Cache-Control: private, pre-check=0, post-check=0, max-age=0"); } @Header("Pragma: no-cache"); $encoding = "none"; if (nv_function_exists('gzencode')) { $encoding = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') ? 'gzip' : (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') ? 'deflate' : 'none'); if ($encoding != 'none') { if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Opera') && preg_match('/^Mozilla\\/4\\.0 \\(compatible; MSIE ([0-9]\\.[0-9])/i', $_SERVER['HTTP_USER_AGENT'], $matches)) { $version = floatval($matches[1]); if ($version < 6 || $version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1')) { $encoding = 'none'; } } } } if ($encoding != "none") { $content = gzencode($content, 6, $encoding == 'gzip' ? FORCE_GZIP : FORCE_DEFLATE); header("Content-Encoding: " . $encoding); header('Vary: Accept-Encoding'); } print_r($content); die; }
/** * nv_change_buffer() * * @param mixed $buffer * @return */ function nv_change_buffer($buffer) { global $db, $sys_info, $global_config; $buffer = $db->unfixdb($buffer); $buffer = nv_url_rewrite($buffer); if (defined("NV_ANTI_IFRAME") and NV_ANTI_IFRAME) { $buffer = preg_replace("/(<body[^>]*>)/", "\$1\r\n<script type=\"text/javascript\">if(window.top!==window.self){document.write=\"\";window.top.location=window.self.location;setTimeout(function(){document.body.innerHTML=\"\"},1);window.self.onload=function(){document.body.innerHTML=\"\"}};</script>", $buffer, 1); } if (!empty($global_config['googleAnalyticsID']) and preg_match('/^UA-\\d{4,}-\\d+$/', $global_config['googleAnalyticsID'])) { $dp = ""; if ($global_config['googleAnalyticsSetDomainName'] == 1) { $dp .= "_gaq.push([\"_setDomainName\",\"" . $global_config['cookie_domain'] . "\"]);"; } elseif ($global_config['googleAnalyticsSetDomainName'] == 2) { $dp .= "_gaq.push([\"_setDomainName\",\"none\"]);_gaq.push([\"_setAllowLinker\",true]);"; } $googleAnalytics = "<script type=\"text/javascript\">\r\n"; $googleAnalytics .= "//<![CDATA[\r\n"; $googleAnalytics .= "var _gaq=_gaq||[];_gaq.push([\"_setAccount\",\"" . $global_config['googleAnalyticsID'] . "\"]);" . $dp . "_gaq.push([\"_trackPageview\"]);(function(){var a=document.createElement(\"script\");a.type=\"text/javascript\";a.async=true;a.src=(\"https:\"==document.location.protocol?\"https://ssl\":\"http://www\")+\".google-analytics.com/ga.js\";var b=document.getElementsByTagName(\"script\")[0];b.parentNode.insertBefore(a,b)})();\r\n"; $googleAnalytics .= "//]]>\r\n"; $googleAnalytics .= "</script>\r\n"; $buffer = preg_replace('/(<\\/head>)/i', $googleAnalytics . "\\1", $buffer, 1); } if ($global_config['optActive'] == 1 || (!defined('NV_ADMIN') and $global_config['optActive'] == 2) || (defined('NV_ADMIN') and $global_config['optActive'] == 3)) { include_once NV_ROOTDIR . '/includes/class/optimizer.class.php'; $optimezer = new optimezer($buffer, $sys_info['supports_tidy']); $buffer = $optimezer->process(); //http://tidy.sourceforge.net/docs/quickref.html $config = array('doctype' => 'transitional', 'input-encoding' => 'utf8', 'output-encoding' => 'utf8', 'output-xhtml' => true, 'drop-empty-paras' => true, 'drop-proprietary-attributes' => true, 'word-2000' => true, 'enclose-block-text' => true, 'enclose-text' => true, 'hide-comments' => false, 'hide-endtags' => true, 'indent' => false, 'indent-spaces' => 4, 'logical-emphasis' => true, 'lower-literals' => true, 'markup' => true, 'preserve-entities' => true, 'quote-ampersand' => true, 'quote-marks' => true, 'quote-nbsp' => true, 'show-warnings' => false, 'wrap' => 0, 'alt-text' => true); $buffer = nv_valid_html($buffer, $config); } if (!$sys_info['supports_rewrite']) { $buffer = preg_replace("/\\<(script|link)(.*?)(src|href)=['\"]((?!http(s?)|ftp\\:\\/\\/).*?\\.(js|css))['\"](.*?)\\>/", "<\\1\\2\\3=\"" . NV_BASE_SITEURL . "CJzip.php?file=\\4&r=" . $global_config['timestamp'] . "\"\\7>", $buffer); } else { $buffer = preg_replace("/\\<(script|link)(.*?)(src|href)=['\"]((?!http(s?)|ftp\\:\\/\\/).*?\\.(js|css))['\"](.*?)\\>/", "<\\1\\2\\3=\"\\4?t=" . $global_config['timestamp'] . "\"\\7>", $buffer); } return $buffer; }
/** * nv_change_buffer() * * @param mixed $buffer * @return */ function nv_change_buffer($buffer) { global $db; $buffer = $db->unfixdb($buffer); $buffer = nv_url_rewrite($buffer); //http://tidy.sourceforge.net/docs/quickref.html $config = array('doctype' => 'transitional', 'input-encoding' => 'utf8', 'output-encoding' => 'utf8', 'output-xhtml' => true, 'drop-empty-paras' => true, 'drop-proprietary-attributes' => true, 'word-2000' => true, 'enclose-block-text' => true, 'enclose-text' => true, 'hide-comments' => false, 'hide-endtags' => true, 'indent' => true, 'indent-spaces' => 4, 'logical-emphasis' => true, 'lower-literals' => true, 'markup' => true, 'preserve-entities' => true, 'quote-ampersand' => true, 'quote-marks' => true, 'quote-nbsp' => true, 'show-warnings' => false, 'wrap' => 150); // Moi dong khong qua 150 ky tu $buffer = nv_valid_html($buffer, $config); return $buffer; }