Пример #1
0
 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);
 }