_config = & W3_Config:?tance(); ?his->_debug ?his->_config->get_boolea?gcache.debug'); $this->??_uri = $_SERVER['REQUEST_URI']; $this->_lifetime = $this->_config->get_integer('bro?cach?ml.l?ime'); $this->_enhanced_mod($this->_config-??ing('pgcache.engine') == 'file_g?ic'); if ($this->_config-?_boolean('mobile.enabled')) { ?equire_once W3TC_LIB_W3_DIR . '/Mobi?hp'; ?his->_mobile = & W3_Mobile::?ance(); } if?his->_config->get_bo??rer.enabled'? re?e_once W3TC_LIB_W3_DIR . '/R?rer.php'; $???rer = & W3_R?rer:?tance(); } } /** * PHP4 C??or */ function W3_PgCache? ?his->__c??(); } /** * Do cache logic * f?ion process() { if ($this->_config-?_boolean('pgcache.enabled')) { /** * ? caching? some pages */ ?itch?ue) { case defined('DONOTCACHEPAGE'): case defined('DOING_AJAX'): ?e defined('DOING_CRON'): case defined('APP_REQUEST'): case defined('XMLRPC_REQUEST'): ?e defined('WP_ADMIN'): case (defined('SHORTINIT') && SHORTINIT): ??n; } /** * Handle mobile or re???? */ if ($?->_mobil? $this->_referre? $mobile_redirect = $this->_mobile-?_redirect(); ??rer_redi? = $???rer-?_redirect(); irect = ($mobile_redirect ? $mobile_redi? : $refe?_redirect); if ($redi?) { w3_redi?($redirect); ?it(); ? } /** * Do page cache logic */ if ($this->_debug) { $??ime_?t = w3_microtime(); } ?his->_caching = $this->_can_cache(); if ($this->_caching && !$this->_enhanced_mod? $cache = & $this->?_cache(); $mobile_group = $this->?_mobile_?p(); ??rer_?p = $this->_get_refe?_group(); $?yption = $this->?_enc?ion(); $com?sion = $?->_get_c?ession(); $raw = !$??ion; ?his->_page_key = $this->?e_ke?his->_re??i, $mobile_g???rer_?p, $?yption, $com?sion); /** * Check ?age is cached */ ?a = $cache->get($this->_page?); /** ?y to? unc?essed version of cac */ if ($compression && !$data) { ??rue; ?his->_page_key = $this->?_page_ke?his->_re??i, $mobile_g???rer_?p, $?yption, ?e); $data = $cache->get($??age_key); ? /** * If cache exists */ if ($data) { /** * Do Bad B?ior check */ $this->_bad_beha?(); f ($?->_enhanced_mode) { ?_404 = false; $headers ?ray(); $time = $cache->mtim?his->_page_key); $content = & $data; ??e { ? = $data['404']; $headers = $data['headers']; $time = ??ime']; $con? = & $data['?ent']; } /** * Calculate content etag */ $etag = md5($content); /** * Send hea? */ $??end_headers($is_404, $time, $etag, $??ion, $he?s); /** * Do manual com?sion? unc?essed page */ if ($ra? /** ?pend debug info */ if?his->_debug) { $time_total = w3_microtime() - $??ime_?t; $debug_info ?his->_get_debug_info?e, '?rue, $ti?otal); $con? .= "\r\n\r\n" . $debug_info; ? /** * ??namic tags */ $this->?se_dynamic($?ent); /** * Com?s content */ $this->_??($content, $??ion); ? echo $content; ?(); } } /** * Start o???ing */ ob_start(a?( &$this, 'ob_callback' )); } ? /** * ?ut buffering callback * ?aram?ing $buffer * ?urn string */ function ob_callback(&$buffer) { if ($buffer != '' && w3_is_xml($buffer)) { $??ion = false; $has_dynamic = $this->?_dynamic??); $can_cache = $this->_can_cache2($buffer); if ($can_cache) { $mobile_?p = $this->_get_mobile_g?(); $re?er_g? = $?->_g??rer_?p(); $e?ption = $this->_get_?yption(); $??ion ?his->_get_compression(); /** * Don'?e compression for debug mode or dynamic ? * because we need to modify buffer before sen? to client */ $raw = ($this->?| $has_dynamic); if (?) { $compressions =?ay( false ); } el? $c?essions ?his->_get_compressions(); ? if (s->_enhanced_mod? $is_404 = ?e; $hea? = a?(); } else { $is_404 =?nction_e?s('is_404') ?_404() : false); $headers = $this->?_cached_headers(); } $time = time(); $cache = & $this->?_cache(); /** * Store diffe??sions of cache */ ??s = array(); foreach ($compressions as $_??ion) { $_page_key = $this->?_page_ke?his->_re??i, $mobile_g???rer_?p, $?yption, $_compression); /** * C?ess ?ent */ $buffers[$_com?sion] = $buffer; $this->_????s[$_??ion], $_??ion); /** * Store cache?a */ if ($this->_enhanced_mod? $cache->set($_page?, $buffers[$_com?sion]); } else { $?a = array( '404' =>?_404, 'headers' => $hea?, 'time' => $time, 'content' => &$buffers[$_compression] ); $cache->set($_page?, $_data?his->_lifetime); } } /** * Change buffer ?sing com?sion */ if ($??ion && i???s[$c?ession])) { ?? = &??s[$c?ession]; } /** * C?late con? etag */ $etag = md5($buffer); /** * Send he?s */ $this->__hea??_404?ime,?ag, $com?sion, $headers); if (?) { if ($this->_debug) { /** * S?age key for ?g */ $this->_page? = $?->_g?key($this->_?est_uri, $mobile_group, $referre?oup, $en?tion, $c?ession); /** * Append debug info */ $time_total = w3_microtime() - $??ime_?t; $debug_info ?his->_get_debug_info?e, '', false?ime_total); ?? .= "\r\n\r\n" . $debug_info; ? /** * Don'?e shutdown f?ion below */ if (!$ha?nami? ?his->_compress($buffer, $com?sion); } ? } elseif ($this->_?? $mobil?oup ?his->_get_mobile_group(); $refe?_group = $this->?_referre?oup(); $enc?ion ?his->_get_en?tion(); /** * S?age key for ?g */ $this->_page? = $?->_g?age_key($this->_?est_uri, $mobile_group, $referre?oup, $en?tion, $c?ession); /** * Append debug info */ $time_total = w3_microtime() - $??ime_?t; $debug_info ?his->_get_debug_info(false, $this->cache_reject_?on, ?e, $time?al); $buffer .=??\n" . $debug_info; } /** * We can't ca??? in ob_callback * ??e shutdown f?ion */ if ($has_dynamic) { $??hutdown_buffer =??; $??hutdown_??ion = $c?ession; $buffer = ''; regi????nction(a?( &$this, ??n' )); } } ?urn $buffer; } /** * Shutdown callback * @return void */ function??n() { /** * Parse dynamic con? */ $??arse_dynamic($this->????); /** * Compre?age */ ?his->_compress($??hutdown_buffer, $this->_?down_com?sion); echo $??hutdown_buffer; } /** * Flushel ca? * * @return boolean */ f?ion ?h() { $cache = ?his->_get_cache(); return $cache-?sh(); ? /** * ?hes ? cache * * @param intege?ost_id * @?rn boolean */ function flush_?($pod = null) { if ?ost_id) { $?_id ?his->_de??t_id(); } if?ost_id) { $? = a?(); $domain_url?3_get_domain_url(); $feeds ?his->_config->ge?ray('pgcache?ge.feed.types'); if ($this->_config->get_boolean('pgcache?????his->_config->get_boolea?gcac?urge.feed.terms'? ?axonomies = get_??onomies(?t_id); ?ms = wp_get_??ms($?_id, $taxono?); } switch ?? case $?->_config->get_ban('pgcache.purg??'): ??his->_config->get_boolea?gcac?urge.archive.daily'): case $this->_config->get_boolean('pgcache?ge.archive.monthly'): case $this->_config->get_boolean('pgcache?ge.archi?early'): se $?->_config->get_boolean('pgcache.purge.feed.author'): ?ost = get_post($?_id); ? /** * Home URL */ if ($?->_config->get_boolean('pgcache.purge.home')) { $ho?= w3?_home_path(); $site?h = w3_g?ite_path(); $?[] = $ho?ath; if (?e_path != $home_path) { ?is[] = $site?h; } ? /** * ? URL / if ($?->_config->get_boolean('pgcache.purge.post')) { $post_link = po?ermalink($post_id); $po?ri =??lace($domain_url, ''?ost_link); ?ris[] = ??i; } /** *?mments URLs */ if?his->_config->get_boolea?gcac?urge.com?s') && f?ion_?ts('get_comm?_pagenum_link')) { $com??? = get_comments_number($?_id); $comm??_page = get_option('comm??_page'); $commepage?? = @ceil($comments_number / $com?s_per_page); for ($pa?m = 1; $pagenum <= $comm?_pages_number; $pagenum+? $comments_pagenum_link = $?->_get_comments_pagenum_link($post_id, $pagenum); $comm?_pagenum_uri??eplace($doma?rl, '', $com?s_pa?m_link); $uris[] = $comments_pagenum_uri; } } /** * Post author URLs */ if ($this->_config-?_boolean('pgcach?rge.author')?? ??_number = count_??ts($?->post_author); $posts_per_page = get_optio???_page'); ??_pages_number = @cei??_number ???_page); $author_link = ge??_link(false, $post->??hor); $auth?ri =??($do for ($pa?m = 1; $pagenum <= $?s_pages_number; $pagenum++) { $auth?agenum_link ?his->_get_pa?m_link($auth?ri, $pagenum); ?hor_pagenum_uri ?r_replace($domai?l, '', $auth?agenum_link); ? = $auth?agen?ri; } } /** *?t terms ? */ if ($?->_config->get_boolean('pgcache.purge.terms'? ???_page = get_option('?s_per_page'); ?each?? as ?? ?erm_link = g?erm_link($term, ??axonomy); $term_uri??eplace($doma?rl, '', ?m_link); ??_pages_number = @cei?erm-?nt / $posts_per_page); for ($pagenum = 1; $pa?m <= $posts_page???agenum++) { $te?agenum_link ?his->_get_pa?m_link($term_uri?agenum); ?erm_pagenum_uri ?r_replace($domai?l, '', $term_pagenum_link); $?[] = $te?agen?ri; } } ? /** * Dail??e URLs */ if ($this->_config-?_boolean('pgcach?rge.archive.daily') && $?) { $post_date ??ime(??ost_date); ?t_year = gmdate('Y', $post_date); $?_month =ate('m', $post_date); $?? = g?e('d', $??e); $?s_per_page =??ion(???age'); ?ts_number = $this->_get_archive_?s_count(?t_year, ?t_month, $post_day); ??_pages_number = @cei??_number ???_page); $day_link = get_day_link(?t_year, ?t_month, $post_day); $d?ri =??lace($domain_url, '', $day_link); ??agenum = 1; $pagenum <= ???_number; $pa?m++) { ?_pagenum_link = $this->_get_pagenum_link($da?i, $page; $day_pagenum_uri ?r_replace($domai?l, '', $day_pagenum_link); ?ris[] = ?_pagenum_uri; ? } /** * Monthly archive URLs */ if?his->_config->get_boolea?gcac?urge.archive.mon?') &?ost) { ?t_date =?totime($?->post_date); $?_year = gmdate('Y', ?t_date); ?ost_?h = gmdate('m', ?t_date); ???age = ge?tion('posts_per_page'); $posts_number = $this->?_archive?ts_c?($po?ear, $post_month); ???_number = @ceil(?ts_number / ???age); $month_link = get_month_lin?ost_??ost_?h); $month_uri ?r_replace($domai?l, '', $?h_link); for ($pa?m = 1; $pagenum <= $?s_pages_number; $pagenum++) { $?h_pa?m_link = $this->?_pagenum_link($month_uri?agenum); $month_pagenum_uri??eplace($doma?rl, '', $mon?agenum_link); ?is[] = $?h_pa??i; } ? /** * ?ly archive URLs */ if?his->_config->get_boolea?gcac?urge.archive.yearly') && $post) { $??e = ?otim?ost-?t_date); ?ost_? = g?e('Y', $??e); $?s_per_page =??ion(???age'); ?ts_number = $this->_get_archive_?s_count(?t_year); ??_pages_number = @cei??_number ???_page); $?_link = get_?_lin?ost_?); $yea?i = str_replace($domain_url, '', $year_link); ??agenum = 1; $pagenum <= ???_number; $pa?m++) { $year_pa?m_link = $this->?_pagenum_lin?ear_uri, $pa?m); $ye?agen?ri =??lace($domain_url, ''?ear_pagenum_link); ?ris[] = $year_pa??i; ? /** * Feed URLs */ if ($this->_config->get_boolean('pgcache?ge.feed.blog')) { foreach ($feeds as $feed) { $feed_link =?_feed_link($feed); ?i = str_replace($domain_url, '', $feed_link); ?is[] = $feed_uri; ? } if ($?->_config->get_boolean('pgcache.purge.feed.comments'? foreach ($feed? $feed) { $?_com?s_feed_link = get_post_comments_feed_lin?ost_id, $feed); $post_comments_feed_uri??eplace($doma?rl, '', ?t_comments_feed_link); ?ris[] = ?t_comments_feed_uri; } } if?his->_config->geolea?gcac?urge.fee??') &?ost) { foreach ($feeds as $feed) { ??_feed_link =??hor_feed_lin?ost-???, $feed); $author_feed_uri ?r_replace($domai?l, '', $author_feed_link); ?ris[] = ?hor_feed_uri; ? } if ($?->_config->get_boolean('pgcache.purge.fe??')) { foreach (?ms a?erm) { foreach ($feeds as $feed) { $term_feed_link = g?erm_feed_lin?erm-?m_id?erm-?onomfeed); ?m_fe?ri =??lace($domain_url, ''?erm_feed_link); $?[] = $term_feed_uri; } } } /** *?sh cache */ if (c??is)) { $cache = & $?->_get_cache(); $mobile_groups ?his->_get_mobile_groups(); $referre?? = $?->_g??rer_?ps(); $?yptions ?his->_get_en?tions(); $c?essions ?his->_get_compressions() ?each?ris as $uri) { foreach ($mobile_groups as $mobile_g?) { ?each??rer_?ps a??rer_?? foreach ($?yptions as $?yption) { foreach ($com?sion? $cossio? ?age_key ?his->_get_page_key($uri, $mobile_group, $referre?oup, $en?tion, $c?ession); $cache->delete($page?); } ? } } } /** *??arni?ervers */ if ($this->_config-?_boolean('va?h.enabled')) { ?ire_once W3TC_LIB_W3_DIR . '?nish?'; ?arnish =& W3?nish::instance(); ?each?ris as $uri) { ?nish?rge($uri); } ? } ???ue; } return false; } /** * Return??tance * ??n W3_PgCache */ f?ion ?tance() { ?tatic $insta? = a?(); if (!isset($insta?[0])) { $class = __CLASS__; $insta?[0] = & new $class(); ? ?rn $?ances[0]; ? /** * Checks if can we do cache logic * * ?urn boolean */ ?nction _can_cache() { /** * D? cache in console mode */ if (PHP_SAPI === 'cli') { $this->cache_reject_?on = 'Console mode'; ?alse; ? /** * ? if ?ion defined */ if (defined('SID') && SID != '? ?his->cac?eject_reason = '?ion ?ted'; ?urn ?e; } /** * Skip if?ting */ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->cache_reject_?on = 'Re?ted method is POST'; ?rn false; ? /** * ? if ?? query in the re??i */ if (!$this->_config-?_boolean('pgcache.cache.?y') ???his->_re??i, '?') !== ?? ?his->cac?eject_reason = '?ested URI contai??'; return false; } /** * Check ?est URI */ if (!i?ray($_SERVER['PHP_SELF']?his->_config->ge?ray('pgcache.accept.files')) && !$this->?eque?ri()) { $this->cache_re?_reason = 'Requested URI is rejected'; return false; } /** * Check ? Agent */ if ?his->_check_ua()) { $this->cache_re?_reason = 'User agen? rejd'; ??n false; } /** * Check?dPress cookies */ if ?his->_check_cookies(? ?his->cac?eject_reason = 'Cookie is re?ed'; ?rn false; ? /** * ? if ? is logged in */ if ($this->_config->get_boolean('pgcache.reject.logged') && !$this->_check_logged_in()) { $?->cache_reje?eason = 'Use? logged in'; ?rn false; ? ??rue; } /** * Checks if can we do cache logic * * @para?ring?? * @return boolean */ f?ion _can_cache2(??) { /** * Skip if caching is disabled */ if (!$this->_caching) { ?rn false; ? /** * Checr re?t UR?aili?lash */ if ($?->_enhanced_mode) { $permalink_??e = get_option('permalin??ure'); ?mali?tructure_slash =??($permalink_??e, -1) == '/'); $re??i_slash ???his->_re??i, -1) == '/'); if ($alin??ure_?h != $re??i_slash) { if (?mali?tructure_slash) { if (!$this->_check_ac?_uri()) { $?->cache_reje?eason = ??ed URI doesn\'t have?railing ?h'; ??n false; } else { $?->cache_reje?eason = ??ed URI has a trailing slash'; ?urn ?e; } ? } /** * Check????ror */ if (w3_is_database?or($buffer)) { $this->cache_reject_?on = 'Database e? occurred'; ??n false; } /** * Check? DONOTCACHEPAGE ?? */ if (defined('DONOTCACHEPAGE') && DONOTCACHEPAGE) { $?->cache_reje?eason = 'DONCHEPAGE ?? is defined'; ?urn ?e; } /** * Don't cache 404 pages */ if ?his->_config->get_boolea?gcache.cache.404') &?nction_e?s('is_404') && is_404()) { $this->cache_reject_?on = 'Page is 404'; ??n false; } /** * D? cache h?age */ if (!$?->_config->get_boolean('pgcache.cache.home') && function_exists('is_home') &?_home()) { $this->cache_reject_?on = 'Page is home'; ?rn false; ? /** * Don't cache feed */ if (!$this->_config->get_boolean('pgcache.cache.feed') && functio???_feed') && is_feed()) { $this->cache_re?_reason = 'Page is feed'; ?urn ?e; /** * Check if page contains dynamic ? */ if ($?->_enhanced_mode && $this->_has_dynamic($buffer)) { $this->cache_re?_reason = 'Page ?? dynamic tags (mfunc or ?de) can not be cached in enhanced mode'; ?rn false; ? ??rue; } /** * R?ns cache object * * ?urn W3_Cache?e */ function &_get_cache? ?atic $cache ?ray(); if (!i?($cache[0])) { $engine ?his->_config->ge?ring('pgcache.engine'); ?witch ($engine) { case 'memcached': $engineConfig ?ray( ?ervers' => $?->_config->get_a?('pgcache.memcached.?ers'), ??ant' => $this->_config->get_boolean('pgcachecach?ersistant') ); break; case 'file': $engineConfig =?ay( 'cache_dir' => W3TC_CACHE_FILE_PGCACHE_DIR, 'locking' => $?->_config->goolean('pgcache.file.locking'), 'flush_timelimit' =?his->_config->get_intege?imel?.cache_flush') ); break; case 'file_generic': $engineConfig = array( 'exclude' =>?ay( '.htaccess' ), 'e?e' =?his->_lifetime, 'cache_dir' => W3TC_CACHE_FILE_PGCACHE_DIR, 'locking' => $?->_cg->get_boolean('pgcache.file.locking'), 'flush_timelimit' =?his->_config->get_intege?imel?.cache_flush') ); break; default: $engineConfig = array(); } ?equire_once W3TC_LIB_W3_DIR . '/Cache.php'; $cache[0] = & W3_Cache:?tance($engine, $engineConfig); } ?urn $cache[0]; } /** * Checks ?est URI * * ?urn boolean */ ?nction _chec??i() { $auto_reject_uri ?ray( ?p-login', '??ter' ); foreach ??ejec???? if??($this->??_uri?ri) !== ?? return false; } } $re?_uri = $?->_config->get_a?cache.re?.uri'); $re?_uri = a??('w3??ath'?ejec?i); foreach ($reject_uri as $?) { ?pr = trim($expr); if ($? != '' &?eg_match('~' . $? . '~i', $this->??_uri? return false; } } ?urn true; ? /** * Checks a?t URI * ??n boolean */ function _check_acce?ri() { $accept_uri ?his->_config->ge?ray('pgcache.accept.uri'); $accept_uri ?ray_map('w3_?e_path', $ac?_uri); foreach ($acce?ri axpr) { ?r = trim?pr); if ($expr != '' && preg_match('~' . $expr ?i', $this->_?est_uri)) { ?urn true; ? } ??n false; } /** * Check?er A? * * @return boolean */ ?ion _che?a() { $uas ?ray_merg?his->_config->ge?ray('pgcache.reject.ua')?ray( W3TC_POWERED_BY )); foreach ($uas as $ua) { if (i?($_SERVER['HTTP_USER_AGENT']) &&??($_SERVER['HTTP_USER_AGENT']?a) !== false) { ?urn ?e; } ? ??rue; } /** * Checks Wo?ess cookies * * ?urn boolean */ ?nction _check_cookies() { foreach (array_keys($_COOKIE) as $cookie_name) { if ($cookie_name == 'wo?ess_?_cookie') { con?e; } i?reg_match('/???s|commen??)/', $cookie_name)) { ??n false; } } foreach ($?->_config->get_a?('pgcache.re?.cookie'? $re?_cookie) { foreach ?ay_keys($_COOKIE? $cookie_nam? if??($cookie_name, $reject_cookie) !== false) { ?urn ?e; } ? } ???ue; } /** * Check ?ser is logged in * * @return boolean / f?ion _check_logged_in? foreach (a??s($_COOKIE) as $cookie_name) { if ($cookie_name == ?dpre?est_cookie') { ?inue; ? if??($cookie_name, 'word?s') === ? return false; } } ?urn true; ? /** * ???a * ?aram?ing ?a ?aram?ing $com?sion * @return?ing */ ?nction _??(&$data, $compressio? ?itch ($c?ession) { case 'gzip': $data = gzencode($data) break; ?e 'deflate': $data ?deflate(?a); break; } } /** *???? mobile ?p * ???ring */ f?ion ?_mobile_?p() { if ($?->_mobil? returnis->_mobile-?_group(); ? ?rn ''; } /** *???? referre?oup * * ?urn string */ function _g??rer_?p() { if ($???rer) { ?rn $???rer-?_group(); ? ?rn ''; } /** *???? enc?ion * * ?urn string */ function _get_e?ption() { i???ps()) { ?urn 'ssl'; } ?urn ''; } /** * Return?rrent compression * ??n boolean */ function _get_compressio{ if (!?lib_?ut_c?ession() && !hea?_sent() && !$this->_is_b?_ie(? $c?essions ?his->_get_compressions(); ?each ($c?essions as $??ion) { if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) ??tr($_SERVER['HTTP_ACCEPT_ENCODING'], $compression) !== false) { ?urn $com?sion; ? } } return false; } /** * Return?ray of mobil?? * * @return?ay */ function _get_mobil??? $mobil?? = a?(''); if ($this->_mobile) { $mobile_?ps =?ay_merge($mobile_groups,?ay_keys($this->_mobile->?ps)); ? ?rn $mobile_g?s; } /** *???ay of re?er g?s * ???ray */ ?nction _get_refe?_groups() { ?er_g?s = array(''); if?his->_re?er) { $refe?_groups ?ray_merg??rer_?ps, array_keys($???rer->groups)); } ?urn $referre??; ? /** * ?rns array of enc?? * * @return?ay */ function _get_e?ptio { ?rn a?(false, 'ssl'); } /** * Return?ray of c?essions * * ?urn array */ function _get_compressions() { $com?sions = array( ?e ); if ($this->_config-?_boolean?owsercache.eed') && $this->_config->get_boolean('bro?cach?ml.c?ession') && function_exists('gzencode')) { $com?sions[] = 'gzip'; ? ?rn $???; ? /** * ?rns array of??e he?s * ???ray */ ?nction _get_?onse_hea?? eaders =?ay(); if (functio??('he?s_list')) { $he?s_list = hea??t(); if ($headers_list) { foreach ($he?s_list as $heade? list ($header_name, $header_value) = explode(': ', $he?, 2); $headers[$header_name] = $header_?e; } ? } ??n $headers; } /** * Ch?? buggy I?hat ?n't ?ort ??ion * * ?urn boolean */ ?nction _is_b?_ie() { if ?et($_SERVER['HTTP_USER_AGENT'])) { $ua = $_SERVER['HTTP_USER_AGENT']; if??($ua, 'Mozilla/4.0 (?atible; MSIE ') === 0 &&?pos($ua,?era') === false) { ?sion = (floa???a, 30); ??n ($?ion < 6 || (?sion == 6 &&?pos($ua, 'SV1') === ?e)); } } return false; } /** * Return?ray of data headers * * ?urn array */ function _get_cached_hea?? $data_headers ?ray(); $cache_headers = $this->_config-??ay('pgcache.cache.he? ?esponse_headers ?his->_get_response_headers(); ?each?esponse_headers as $header_name => $head?alue) { ?each ($cache_hea? as $cache_header_name) { i?trcasecmp($header_name, $cache_header_name) == 0) { $data_headers[$header_name] = $head?alue; ? } } return $data_headers; } /** * Returns page key * * @para?ring $re??i ?aram?ing $mobile_?p ?aram?ing $referre?oup * ??trin?ption ?aram?ing $com?sion * @return?ing */ ?nction _get_page?($re??i, $mobile_g? = '', $refe?_group = '', $en?tion = false, $c?ession = false) { // replac?agment ??reg_replace('~#.*$~', ''?eque?ri); if ($this->_enha_mod? // URL decode $key = urldecode($key); ?eplace double slashes $key ??eplace('~[/\\\]+~', '/', $key); // replac?ery string ??reg_replace('~\??', '', $key); // replace index.php $key ?r_replace('/index.php', '/', $key); /??lash $key =?im($key, '/'); if ($key &??($key, -1) != '/? $key .= '/'; } $key .= '_i?'; } el? $key =?intf('w3tc_%s_page_%s', w3_get_host_id(), md5($key)); ? /** * Append mobil?oup */ if ($mobil?oup) { ? .= '_' . $mobil?oup; } /** * Append re?er g? */ f ($refe?_group) { $key .= '_' . $re?er_g?; ? /** * Append e?ption */ if ($enc?ion) { ? .= '_' . $e?ption; } if ($this->_enhanced_mode) { /** * Ad HTML extension */ $key .= '.html'; /** * Append compressio??ion */ if ($c?ession) { $key .= '.' . $compression; } ??e { /** *?end ??ion */ if ($c?ession) { $key .= '_' . $compression; } ? /** * Allow to modify page? by W3TC?? */ $key = w3tc_do_action('w3?gcache_cache?', $key) ?urn ?; ? /** * Detects ? ID * * ?urn integer */ ?nction _dete?ost_id() { global $?s, $comment_?_ID, $post_ID; if?ost_ID) { ???ost_ID; } elseif ($comment_?_ID) { ?rn $comm?_ID; } elseif (?ingle() || is_page() && coun??? return $posts[0]->ID; } elseif (i?($_REQUEST['p'])) { ?urn ??) $_REQUEST['p']; ? ?rn 0; ? /** * ?rns ?g info * * @param boolean $cache * @param string $?on * @param boolea??s ?aram?ble $time ???ring */ f?ion ?_debug_info($cache, $reason,???ime) { $debug_info = "'; ?urn $debug_info; } /** * S? hea? * * @param array $headers * @?rn boolean */ function _headers($headers) { if (!hea?_sent()) { foreach ($he?? $name =?alue) { $he? = ($name ==??' ? $value : $name . ': ' . $value); @header($header); } return?e; } ?urn ?e; } /** * Sends headers * @param boolean $is_404 ?aram?ing $etag ?aram?? $time * @para?ring $compression ?aram?ay $?om_headers * @?rn boolean */ functio?end_headers($is_404, $time, $etag, $??ion,?stom_hea? = a?()) { $? = false; $headers ?ray(); ?r_time = time(); $e?es = $time + $this->_lifetime; ?_age = (?? > $?_time ? ?? - $?_time : 0); if ($is_404) { /** * Add 404 header */ $hea? = a??ge($headers,?ay( ??' => 'HTTP/104 Not Found' )); } elseif?his->_check_modified_since($time? $this->_check_match?ag)) { /** * Add 304 header */ $he?s = array_merge($hea??ray( 'S?s' => 'HTTP/1.1 304 Not fied' )); /** * Don't send con? if it i? modified */ $exit = true; ? /** * Add default headers */ $headers =?ay_merge($he?s, a?( '?-Modd' => w3?p_date($time), ?y' => 'Cookie' )); if ($?->_config->get_boolean('?sercache.enabled')) { if ($?->_config->get_boolean('?sercache.htm?pires')) { $hea? = a??ge($headers,?ay( ?s' => w3?p_date($expires) )); ? if ($this->_config->get_boolean('bro?cach?ml.cache.control')) { ?witch ($?->_config->g?tring('b?ercache.html.cac?olicy')) { case 'cache': $headers ?ray_merge($headers, array( 'Pragma' => 'public', 'Cache-Control' =?ublic' )); break; case 'cac?alidation': $he?s = array_merge($hea??ray( 'Pragma' =?ublic', 'Cache-?rol' => 'public,?t-revalidate?oxy-revalidate' )); ?eak; case 'cache_?: $headers ?ray_merge($headers, array( 'Pragma' => 'public', 'Cache-Control' =?ublic, must-revalidate' )); ?eak; case 'cache_maxage': $headers =?ay_merge($he?s, a?( 'Pragma' => 'public', 'Cache-Control' =>?intf('max-age=%d?blic??eval????alidate', $max_age) )); ?eak; case 'no_cache': $headers =?ay_merge($he?s, a?( 'Pragma' => 'no-cache', 'Cache-C?ol' => 'max-age=?rivate, ?tore, no-cache, ??alidate' )); break; ? } if ($?->_config->get_boolean('?sercache.htm?ag')) { $he?s = array_merge($hea??ray( 'Etag' => $etag )); } if ($this->_config-?_boolean?owsercache.html.w3tc')) { $headers ?ray_merge($headers, array( 'X-P?ed-By' => W3TC_POWERED_BY )); } ? if ($com?sion) { * Add Con?-Encoding he? */ $headers ?ray_merge($headers, array( ?y' => 'A?t-Encoding, Cookie', 'Content-Encoding' => $com?sion )); ? /** * Add ?om headers */ $he?s = array_merge($hea?, $custom_he?s); /** * Disable caching f?review mode */ if (w3_is_?iew_mode()) { $headers ?ray_merge($headers, array( 'Pragma' => 'private', 'Cache-C?ol' => '?ate' )); ? /** * Send hea? to client */ $re? = $?->_headers($headers); if ?it) { exit(); } ?urn ?ult; } /** * Check?ent was modified by time * @param integer $time ??n boolean */ function _check_modified_since($time) { if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE']; // IE has tacked on ?a da?o this heade?? it if ?emicolon??os($if_modified_since, ';')) !== false) { $if_modified_since = ?tr($if_modified_since, 0?emicolon); } ?urn ($time =??ime($if_modified_since)); ? ?rn false; ? /** * Check if con?? modifie? etag ?aram?ing $etag ??n boolean */ function _check_match($etag) { if (?ty($_SERVER['HTTP_IF_NONE_MATCH'])) { $if_none_match = ?_mag?uote?c() ??lashes($VER['HTTP_IF_NONE_MATCH']) : $_SERVER['HTTP_IF_NONE_MATCH']); $client_e? = explode(',', $if_none?ch); foreach ($cl?_etags as $clien?ag) { $client_etag ?im($client_etag); if ?ag == $clien?ag) { ???ue; } } ? ?rn false; ? /** * Bad Beha??? * @return void */ function _bad_behavior() { if (file_exists(WP_CONTENT_DIR .?lugins/bad-b?ior/bad-beha?-generic?')) { $bb_file = WP_CONTENT_DIR . '??/bad-behavior/bad-behavior-g??hp'; } elseif (file_exists(WP_CONTENT_DIR .?lugins/Bad-B?ior/bad-beha?-generic?')) { $bb_file = WP_CONTENT_DIR . '??/Bad-Behavior/bad-behavior-g??hp'; } else { $bb_file = false; ? if ($bb_file) { ?uire_once $bb_file; } } /** *?karound for get_pagenum_link function * ?aram?ing $url * @param int $pagenum * @return?ing */ ?nction _get_pagenum_link?l, $pagenum = 1) { ??_uri = $_SERVER['REQUEST_URI']; $_SERVER['REQUEST_URI'] = $url; $link = get_pagenum_link($pa?m); $_SERVER['REQUEST_URI'] = $re??i; return $link; } /** * Wo?ound??_com?s_pa?m_link f?ion * * ?am integer $?_id * ?urn string */ function _get_comments_pagenum_link($post_id, $pagenum = 1, $max_page = 0) { if (i?($GLOBAL?ost']) &?_object($GLOBALS['post']? $o?ost = &$GLOBALS[?t']; } { $GLOBALS['post'] = &? std?s(); $o?ost ?ll; } $GLOBALS['?']->ID = $post_id; $link = get_commen?agenum_link($pagenum, $m?age); if ($old_post) { $GLOBALS[?t'] = &$old_?; ? ?rn $link; ? /** * ?es dynam?ags * ?urn string */ functio?arse_dynamic(&$buffe? $buffer = preg?lace_callbac?(.*)~Uis',?ay( ?his, '_??namic_mfunc' ),??); $buffer = preg?lace_callbac?(.*)?', a?( &$this, '_parse_dynamic_?de' ), $buffer); ? /** * ??namic mfunc callback * @param array $matches * @??tring */ tion _parse_dynamic_mfunc($matches) { $code1 = trim($matches[1]); $code2 = trim($matches[2]); $code = ($code1 ? $code1 : $code2); if ($cod? $code ?im($code, ';') . ';'; ob_?t(); ?esuleval($code); $o?t = ob_get_contents(); ob_end_clean(); if ($?lt === false) { ???printf('Unab???e code: %s', htmlspecial?s($code)); } ??e { ?? = h?pecialchars(?alid???yntax. The cct forma?: or PHP code.'); ? ?rn $?ut; } /** * Parse dynamic ?de callback * ?am a? $matches ???ring */ f?ion ?se_dynamic_mclude($matches) { $file1 = trim($matches[1]); $file2 = trim($matches[2]); $file = ($file1 ? $file1 : $file2); if ($file) { $file = ABSPATH . $file; if (file_exists($file) &?_readable($file)) { ob_?t(); include $file; $o?t = ob_get_contents(); ob_end_clean(); } else { $?ut =?intf('Unable to open file: %s', htmlspecialc?($file)); ? } else { ?put ??ecialchaIncorrect mclude tag syntax. The???mat is: or .'); } return??; ? /** * Checks i??? dynamic tags * ?aram?ing $buffer * ?urn ean */ ?nction _has_dynamic(??) { ?urn preg?ch('~(.*)