Пример #1
0
    exit;
}
if (isset($_GET["myisamchk"])) {
    myisamchk();
    exit;
}
if (isset($_GET["filesize"])) {
    _filesize();
    exit;
}
if (isset($_GET["chmod"])) {
    _chmod();
    exit;
}
if (isset($_GET["readfile"])) {
    _readfile();
    exit;
}
if (isset($_GET["TCP_NICS_STATUS_ARRAY"])) {
    TCP_NICS_STATUS_ARRAY();
    exit;
}
if (isset($_GET["LaunchRemoteInstall"])) {
    LaunchRemoteInstall();
    exit;
}
if (isset($_GET["restart-web-server"])) {
    RestartWebServer();
    exit;
}
if (isset($_GET["restart-artica-status"])) {
Пример #2
0
 /**
  * Serve static files through php proxy.
  *
  * It performs the following actions:
  *    - Checks the file is readable or returns "HTTP/1.0 404 Not Found"
  *  - Returns "HTTP/1.1 304 Not Modified" after comparing the HTTP_IF_MODIFIED_SINCE
  *      with the modification date of the static file
  *    - Will try to compress the static file according to HTTP_ACCEPT_ENCODING. Compressed files are store in
  *      the /tmp directory. If compressing extensions are not available, a manually gzip compressed file
  *      can be provided in the /tmp directory. It has to bear the same name with an added .gz extension.
  *      Using manually compressed static files requires you to manually update the compressed file when
  *      the static file is updated.
  *    - Overrides server cache control config to allow caching
  *    - Sends Very Accept-Encoding to tell proxies to store different version of the static file according
  *      to users encoding capacities.
  *
  * Warning:
  *        Compressed filed are stored in the /tmp directory.
  *        If this method is used with two files bearing the same name but located in different locations,
  *        there is a risk of conflict. One file could be served with the content of the other.
  *        A future upgrade of this method would be to recreate the directory structure of the static file
  *        within a /tmp/compressed-static-files directory.
  *
  * @param string $file The location of the static file to serve
  * @param string $contentType The content type of the static file.
  * @param bool $expireFarFuture Day in the far future to set the Expires header to.
  *                              Should be set to false for files that should not be cached.
  * @param int|false $byteStart The starting byte in the file to serve. If false, the data from the beginning
  *                             of the file will be served.
  * @param int|false $byteEnd The ending byte in the file to serve. If false, the data from $byteStart to the
  *                           end of the file will be served.
  * @param string|false $filename By default the filename of $file is reused as Content-Disposition. If the
  *                               file should be sent as a different filename to the client you can specify
  *                               a custom filename here.
  */
 public static function serverStaticFile($file, $contentType, $expireFarFutureDays = 100, $byteStart = false, $byteEnd = false, $filename = false)
 {
     // if the file cannot be found return HTTP status code '404'
     if (!file_exists($file)) {
         Common::sendResponseCode(404);
         return;
     }
     $modifiedSince = Http::getModifiedSinceHeader();
     $fileModifiedTime = @filemtime($file);
     $lastModified = gmdate('D, d M Y H:i:s', $fileModifiedTime) . ' GMT';
     // set some HTTP response headers
     self::overrideCacheControlHeaders('public');
     Common::sendHeader('Vary: Accept-Encoding');
     if (false === $filename) {
         $filename = basename($file);
     }
     Common::sendHeader('Content-Disposition: inline; filename=' . $filename);
     if ($expireFarFutureDays) {
         // Required by proxy caches potentially in between the browser and server to cache the request indeed
         Common::sendHeader(self::getExpiresHeaderForFutureDay($expireFarFutureDays));
     }
     // Return 304 if the file has not modified since
     if ($modifiedSince === $lastModified) {
         Common::sendResponseCode(304);
         return;
     }
     // if we have to serve the file, serve it now, either in the clear or compressed
     if ($byteStart === false) {
         $byteStart = 0;
     }
     if ($byteEnd === false) {
         $byteEnd = filesize($file);
     }
     $compressed = false;
     $encoding = '';
     $compressedFileLocation = AssetManager::getInstance()->getAssetDirectory() . '/' . basename($file);
     if (!($byteStart == 0 && $byteEnd == filesize($file))) {
         $compressedFileLocation .= ".{$byteStart}.{$byteEnd}";
     }
     $phpOutputCompressionEnabled = self::isPhpOutputCompressed();
     if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && !$phpOutputCompressionEnabled) {
         list($encoding, $extension) = self::getCompressionEncodingAcceptedByClient();
         $filegz = $compressedFileLocation . $extension;
         if (self::canCompressInPhp()) {
             if (!empty($encoding)) {
                 // compress the file if it doesn't exist or is newer than the existing cached file, and cache
                 // the compressed result
                 if (self::shouldCompressFile($file, $filegz)) {
                     self::compressFile($file, $filegz, $encoding, $byteStart, $byteEnd);
                 }
                 $compressed = true;
                 $file = $filegz;
                 $byteStart = 0;
                 $byteEnd = filesize($file);
             }
         } else {
             // if a compressed file exists, the file was manually compressed so we just serve that
             if ($extension == '.gz' && !self::shouldCompressFile($file, $filegz)) {
                 $compressed = true;
                 $file = $filegz;
                 $byteStart = 0;
                 $byteEnd = filesize($file);
             }
         }
     }
     Common::sendHeader('Last-Modified: ' . $lastModified);
     if (!$phpOutputCompressionEnabled) {
         Common::sendHeader('Content-Length: ' . ($byteEnd - $byteStart));
     }
     if (!empty($contentType)) {
         Common::sendHeader('Content-Type: ' . $contentType);
     }
     if ($compressed) {
         Common::sendHeader('Content-Encoding: ' . $encoding);
     }
     if (!_readfile($file, $byteStart, $byteEnd)) {
         Common::sendResponseCode(500);
     }
 }
Пример #3
0
 /**
  * Serve static files through php proxy.
  *
  * It performs the following actions:
  * 	- Checks the file is readable or returns "HTTP/1.0 404 Not Found"
  *  - Returns "HTTP/1.1 304 Not Modified" after comparing the HTTP_IF_MODIFIED_SINCE
  *	  with the modification date of the static file
  *	- Will try to compress the static file according to HTTP_ACCEPT_ENCODING. Compressed files are store in
  *	  the /tmp directory. If compressing extensions are not available, a manually gzip compressed file
  *	  can be provided in the /tmp directory. It has to bear the same name with an added .gz extension.
  *	  Using manually compressed static files requires you to manually update the compressed file when
  *	  the static file is updated.
  *	- Overrides server cache control config to allow caching
  *	- Sends Very Accept-Encoding to tell proxies to store different version of the static file according
  *	  to users encoding capacities.
  *
  * Warning:
  * 		Compressed filed are stored in the /tmp directory.
  * 		If this method is used with two files bearing the same name but located in different locations,
  * 		there is a risk of conflict. One file could be served with the content of the other.
  * 		A future upgrade of this method would be to recreate the directory structure of the static file
  * 		within a /tmp/compressed-static-files directory.
  *
  * @param string $file The location of the static file to serve
  * @param string $contentType The content type of the static file.
  * @param bool $expireFarFuture If set to true, will set Expires: header in far future. 
  * 							Should be set to false for files that don't have a cache buster (eg. piwik.js)
  */
 public static function serveStaticFile($file, $contentType, $expireFarFuture = true)
 {
     if (file_exists($file)) {
         // conditional GET
         $modifiedSince = '';
         if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
             $modifiedSince = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
             // strip any trailing data appended to header
             if (false !== ($semicolon = strpos($modifiedSince, ';'))) {
                 $modifiedSince = substr($modifiedSince, 0, $semicolon);
             }
         }
         $fileModifiedTime = @filemtime($file);
         $lastModified = gmdate('D, d M Y H:i:s', $fileModifiedTime) . ' GMT';
         // set HTTP response headers
         self::overrideCacheControlHeaders('public');
         @header('Vary: Accept-Encoding');
         @header('Content-Disposition: inline; filename=' . basename($file));
         if ($expireFarFuture) {
             // Required by proxy caches potentially in between the browser and server to cache the request indeed
             @header("Expires: " . gmdate('D, d M Y H:i:s', time() + 86400 * 100) . ' GMT');
         }
         // Returns 304 if not modified since
         if ($modifiedSince === $lastModified) {
             self::setHttpStatus('304 Not Modified');
         } else {
             // optional compression
             $compressed = false;
             $encoding = '';
             $compressedFileLocation = PIWIK_USER_PATH . self::COMPRESSED_FILE_LOCATION . basename($file);
             $phpOutputCompressionEnabled = self::isPhpOutputCompressed();
             if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && !$phpOutputCompressionEnabled) {
                 $acceptEncoding = $_SERVER['HTTP_ACCEPT_ENCODING'];
                 if (extension_loaded('zlib') && function_exists('file_get_contents') && function_exists('file_put_contents')) {
                     if (preg_match('/(?:^|, ?)(deflate)(?:,|$)/', $acceptEncoding, $matches)) {
                         $encoding = 'deflate';
                         $filegz = $compressedFileLocation . '.deflate';
                     } else {
                         if (preg_match('/(?:^|, ?)((x-)?gzip)(?:,|$)/', $acceptEncoding, $matches)) {
                             $encoding = $matches[1];
                             $filegz = $compressedFileLocation . '.gz';
                         }
                     }
                     if (!empty($encoding)) {
                         // compress-on-demand and use cache
                         if (!file_exists($filegz) || $fileModifiedTime > @filemtime($filegz)) {
                             $data = file_get_contents($file);
                             if ($encoding == 'deflate') {
                                 $data = gzdeflate($data, 9);
                             } else {
                                 if ($encoding == 'gzip' || $encoding == 'x-gzip') {
                                     $data = gzencode($data, 9);
                                 }
                             }
                             file_put_contents($filegz, $data);
                         }
                         $compressed = true;
                         $file = $filegz;
                     }
                 } else {
                     // manually compressed
                     $filegz = $compressedFileLocation . '.gz';
                     if (preg_match('/(?:^|, ?)((x-)?gzip)(?:,|$)/', $acceptEncoding, $matches) && file_exists($filegz) && $fileModifiedTime < @filemtime($filegz)) {
                         $encoding = $matches[1];
                         $compressed = true;
                         $file = $filegz;
                     }
                 }
             }
             @header('Last-Modified: ' . $lastModified);
             if (!$phpOutputCompressionEnabled) {
                 @header('Content-Length: ' . filesize($file));
             }
             if (!empty($contentType)) {
                 @header('Content-Type: ' . $contentType);
             }
             if ($compressed) {
                 @header('Content-Encoding: ' . $encoding);
             }
             if (!_readfile($file)) {
                 self::setHttpStatus('505 Internal server error');
             }
         }
     } else {
         self::setHttpStatus('404 Not Found');
     }
 }