static function sendPipe($pipe)
 {
     preg_match_all('/[a-zA-Z_0-9\\x80-\\xFF]+/', $pipe, $pipe);
     p::$agentClass = 'agent__pipe/' . implode('_', $pipe[0]);
     echo '(function(w){';
     foreach ($pipe[0] as $pipe) {
         echo 'w.P$', $pipe, '=';
         /**/
         if (DEBUG) {
             ob_start();
             call_user_func(array('pipe_' . $pipe, 'js'));
             echo trim(ob_get_clean(), ';');
             /**/
         } else {
             $cpipe = p::getContextualCachePath('pipe/' . $pipe, 'js');
             $readHandle = true;
             if ($h = p::fopenX($cpipe, $readHandle)) {
                 ob_start();
                 call_user_func(array('pipe_' . $pipe, 'js'));
                 $pipe = new \JSqueeze();
                 $pipe = $pipe->squeeze(ob_get_clean());
                 echo $pipe = trim($pipe, ';');
                 fwrite($h, $pipe);
                 flock($h, LOCK_UN);
                 fclose($h);
                 p::writeWatchTable('pipe', $cpipe);
             } else {
                 fpassthru($readHandle);
                 flock($readHandle, LOCK_UN);
                 fclose($readHandle);
             }
             /**/
         }
         echo ';';
     }
     echo '})(window);w()';
     p::setMaxage(-1);
 }
 static function render($agent, $liveAgent)
 {
     $config_maxage = $CONFIG['maxage'];
     // Get the calling URI
     if (isset($_COOKIE['R$'])) {
         p::$uri = $_COOKIE['R$'];
         setcookie('R$', '', 1, '/');
         // Check the Referer header
         // T$ starts with 2 when the Referer's confidence is unknown
         //                1 when it is trusted
         if (isset($_SERVER['HTTP_REFERER']) && $_COOKIE['R$'] === $_SERVER['HTTP_REFERER']) {
             if (class_exists('SESSION', false)) {
                 $_COOKIE['T$'] = '1';
                 s::regenerateId();
             } else {
                 self::$antiCsrfToken[0] = '1';
                 setcookie('T$', self::$antiCsrfToken, 0, $CONFIG['session.cookie_path'], $CONFIG['session.cookie_domain']);
             }
         }
     } else {
         p::$uri = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : p::$base;
     }
     if ($liveAgent) {
         // The output is both html and js, but iframe transport layer needs html
         p::$binaryMode = true;
         header('Content-Type: text/html');
         echo '/*<script>/**/q="';
     } else {
         echo 'w(';
     }
     p::openMeta($agent);
     try {
         if (isset($_GET['T$']) && !p::$antiCsrfMatch) {
             throw new e\PrivateResource();
         }
         $a = new $agent($_GET);
         $group = p::closeGroupStage();
         if ($is_cacheable = 'POST' !== $_SERVER['REQUEST_METHOD'] && !in_array('private', $group)) {
             $cagent = p::agentCache($agent, $a->get, 'js.ser', $group);
             $dagent = p::getContextualCachePath('jsdata.' . $agent, 'js.ser', $cagent);
             if ($liveAgent) {
                 if (file_exists($dagent)) {
                     if (filemtime($dagent) > $_SERVER['REQUEST_TIME']) {
                         $data = unserialize(file_get_contents($dagent));
                         p::setMaxage($data['maxage']);
                         p::setExpires($data['expires']);
                         p::writeWatchTable($data['watch']);
                         array_map('header', $data['headers']);
                         p::closeMeta();
                         echo str_replace(array('\\', '"', '</'), array('\\\\', '\\"', '<\\/'), $data['rawdata']), '"//</script><script src="' . p::__BASE__() . 'js/QJsrsHandler"></script>';
                         return;
                     } else {
                         @(unlink($cagent) + unlink($dagent));
                     }
                 }
             } else {
                 if (file_exists($cagent)) {
                     if (filemtime($cagent) > $_SERVER['REQUEST_TIME']) {
                         $data = unserialize(file_get_contents($cagent));
                         p::setMaxage($data['maxage']);
                         p::setExpires($data['expires']);
                         p::writeWatchTable($data['watch']);
                         array_map('header', $data['headers']);
                         p::closeMeta();
                         echo $data['rawdata'];
                         return;
                     } else {
                         @(unlink($cagent) + unlink($dagent));
                     }
                 }
             }
         }
         ob_start();
         ++p::$ob_level;
         try {
             $data = (object) $a->compose((object) array());
             if (!p::$is_enabled) {
                 p::closeMeta();
                 return;
             }
             $template = $a->getTemplate();
             echo '{';
             $comma = '';
             foreach ($data as $key => $value) {
                 $key = jsquote($key);
                 is_string($key) || ($key = "'" . $key . "'");
                 echo $comma, $key, ':';
                 if ($value instanceof \loop) {
                     self::writeAgent($value);
                 } else {
                     echo jsquote($value);
                 }
                 $comma = ',';
             }
             echo '}';
         } catch (e\PrivateResource $data) {
             ob_end_clean();
             --p::$ob_level;
             p::closeMeta();
             throw $data;
         }
         $data = ob_get_clean();
         --p::$ob_level;
         $a->metaCompose();
         list($maxage, $group, $expires, $watch, $headers) = p::closeMeta();
     } catch (e\PrivateResource $data) {
         if ($liveAgent) {
             echo 'false";(window.E||alert)("You must provide an auth token to get this liveAgent:\\n"+', jsquote($_SERVER['REQUEST_URI']), ')';
             echo '//</script><script src="' . p::__BASE__() . 'js/QJsrsHandler"></script>';
         } else {
             if ($data->getMessage()) {
                 echo 'w.r(0,' . (int) (!DEBUG) . '));';
             } else {
                 echo ');window.E&&E("You must provide an auth token to get this agent:\\n"+', jsquote($_SERVER['REQUEST_URI']), ')';
             }
         }
         exit;
     }
     if ($liveAgent) {
         echo str_replace(array('\\', '"', '</'), array('\\\\', '\\"', '<\\/'), $data), '"//</script><script src="' . p::__BASE__() . 'js/QJsrsHandler"></script>';
     } else {
         echo $data;
     }
     if ('ontouch' === $expires && !($watch || $config_maxage == $maxage)) {
         $expires = 'auto';
     }
     $expires = 'auto' === $expires && ($watch || $config_maxage == $maxage) ? 'ontouch' : 'onmaxage';
     $is_cacheable = $is_cacheable && !in_array('private', $group) && ($maxage || 'ontouch' === $expires);
     if (!$liveAgent || $is_cacheable) {
         if ($is_cacheable) {
             ob_start();
         }
         if ($config_maxage == $maxage && Superloader::$turbo) {
             $ctemplate = p::getContextualCachePath("templates/{$template}", 'txt');
             $readHandle = true;
             if ($h = p::fopenX($ctemplate, $readHandle)) {
                 p::openMeta('agent__template/' . $template, false);
                 $template = new \ptlCompiler_js($template);
                 echo $template = ',' . $template->compile() . ')';
                 fwrite($h, $template);
                 flock($h, LOCK_UN);
                 fclose($h);
                 list(, , , $template) = p::closeMeta();
                 p::writeWatchTable($template, $ctemplate);
             } else {
                 fpassthru($readHandle);
                 flock($readHandle, LOCK_UN);
                 fclose($readHandle);
             }
             $watch[] = 'public/templates/js';
         } else {
             echo ',[1,', jsquote($template), ',0,0,0])';
         }
         if ($is_cacheable) {
             $ob = true;
             $template = array('maxage' => $maxage, 'expires' => $expires, 'watch' => $watch, 'headers' => $headers, 'rawdata' => $data);
             $expires = 'ontouch' === $expires ? $config_maxage : $maxage;
             if ($h = p::fopenX($dagent)) {
                 fwrite($h, serialize($template));
                 flock($h, LOCK_UN);
                 fclose($h);
                 touch($dagent, $_SERVER['REQUEST_TIME'] + $expires);
                 p::writeWatchTable($watch, $dagent);
             }
             if ($h = p::fopenX($cagent)) {
                 $ob = false;
                 $template['rawdata'] .= $liveAgent ? ob_get_clean() : ob_get_flush();
                 fwrite($h, serialize($template));
                 flock($h, LOCK_UN);
                 fclose($h);
                 touch($cagent, $_SERVER['REQUEST_TIME'] + $expires);
                 p::writeWatchTable($watch, $cagent);
             }
             if ($ob) {
                 $liveAgent ? ob_end_clean() : ob_end_flush();
             }
         }
     }
 }
 protected static function render($agentClass)
 {
     p::openMeta($agentClass);
     $a = self::$args;
     $g = self::$get;
     $agent = new $agentClass($_GET);
     $group = p::closeGroupStage();
     $is_cacheable = !in_array('private', $group);
     $cagent = p::agentCache($agentClass, $agent->get, 'ser', $group);
     $filter = false;
     if (isset(self::$cache[$cagent])) {
         $cagent =& self::$cache[$cagent];
         $v = clone $cagent[0];
         $template = $cagent[1];
     } else {
         if (!($is_cacheable && (list($v, $template) = self::getFromCache($cagent)))) {
             ob_start();
             ++p::$ob_level;
             $v = (object) $agent->compose((object) array());
             if (!p::$is_enabled) {
                 p::closeMeta();
                 return;
             }
             $template = $agent->getTemplate();
             if (!p::$binaryMode) {
                 foreach ($v as &$h) {
                     is_string($h) && ($h = htmlspecialchars($h));
                 }
                 unset($h);
             }
             $filter = true;
             $rawdata = ob_get_flush();
             --p::$ob_level;
         }
         isset(p::$headers['content-type']) || p::header('Content-Type: text/html');
         $vClone = clone $v;
     }
     p::$catchMeta = false;
     self::$values = $v->{'$'} = $v;
     $ctemplate = p::getContextualCachePath('templates/' . $template, (p::$binaryMode ? 'bin' : 'html') . '.php');
     $ftemplate = 'template' . md5($ctemplate);
     p::$lockedContentType = true;
     if (function_exists($ftemplate)) {
         $ftemplate($v, $a, $g);
     } else {
         Superloader::$turbo || p::syncTemplate($template, $ctemplate);
         if ($h = p::fopenX($ctemplate)) {
             opcache_reset();
             p::openMeta('agent__template/' . $template, false);
             $compiler = new \ptlCompiler_php($template, p::$binaryMode);
             $ftemplate = "<?php function {$ftemplate}(&\$v,&\$a,&\$g){global \$a�,\$c�;\$d=\$v;" . $compiler->compile() . "} {$ftemplate}(\$v,\$a,\$g);";
             fwrite($h, $ftemplate);
             flock($h, LOCK_UN);
             fclose($h);
             list(, , , $watch) = p::closeMeta();
             p::writeWatchTable($watch, $ctemplate);
         }
         require $ctemplate;
     }
     if ($filter) {
         p::$catchMeta = true;
         $agent->metaCompose();
         list($maxage, $group, $expires, $watch, $headers, $canPost) = p::closeMeta();
         if ('ontouch' === $expires && !$watch) {
             $expires = 'auto';
         }
         $expires = 'auto' === $expires && $watch ? 'ontouch' : 'onmaxage';
         p::setExpires($expires);
         if ($is_cacheable && 'POST' !== $_SERVER['REQUEST_METHOD'] && !in_array('private', $group) && ($maxage || 'ontouch' === $expires)) {
             $fagent = $cagent;
             if ($canPost) {
                 $fagent = substr($cagent, 0, -4) . '.post' . substr($cagent, -4);
             }
             if ($h = p::fopenX($fagent)) {
                 $rawdata = array('rawdata' => $rawdata, 'v' => array());
                 self::freezeAgent($rawdata['v'], $vClone);
                 $rawdata['template'] = $template;
                 $rawdata['maxage'] = $maxage;
                 $rawdata['expires'] = $expires;
                 $rawdata['watch'] = $watch;
                 $rawdata['headers'] = $headers;
                 $rawdata = serialize($rawdata);
                 fwrite($h, $rawdata);
                 flock($h, LOCK_UN);
                 fclose($h);
                 touch($fagent, $_SERVER['REQUEST_TIME'] + ('ontouch' === $expires ? $CONFIG['maxage'] : $maxage));
                 p::writeWatchTable($watch, $fagent);
             }
         }
     } else {
         p::closeMeta();
     }
     if (isset($vClone)) {
         self::$cache[$cagent] = array($vClone, $template);
     }
 }