本文整理汇总了PHP中Piwik\ProxyHttp::serverStaticFile方法的典型用法代码示例。如果您正苦于以下问题:PHP ProxyHttp::serverStaticFile方法的具体用法?PHP ProxyHttp::serverStaticFile怎么用?PHP ProxyHttp::serverStaticFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\ProxyHttp
的用法示例。
在下文中一共展示了ProxyHttp::serverStaticFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
exit;
}
/**
* piwik.js proxy
*
* @see core/Piwik.php
*/
define('PIWIK_INCLUDE_PATH', '..');
define('PIWIK_DOCUMENT_ROOT', '..');
define('PIWIK_USER_PATH', '..');
require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php';
// Composer autoloader
if (file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php')) {
$path = PIWIK_INCLUDE_PATH . '/vendor/autoload.php';
// Piwik is the main project
} else {
$path = PIWIK_INCLUDE_PATH . '/../../autoload.php';
// Piwik is installed as a dependency
}
require $path;
$file = '../piwik.js';
$daysExpireFarFuture = 10;
$byteStart = $byteEnd = false;
if (!defined("PIWIK_KEEP_JS_TRACKER_COMMENT") || !PIWIK_KEEP_JS_TRACKER_COMMENT) {
$byteStart = 369;
// length of comment header in bytes
}
$environment = new \Piwik\Application\Environment(null);
$environment->init();
ProxyHttp::serverStaticFile($file, "application/javascript; charset=UTF-8", $daysExpireFarFuture, $byteStart, $byteEnd);
exit;
示例2: serveJsFile
/**
* @param UIAsset $uiAsset
*/
private function serveJsFile($uiAsset)
{
ProxyHttp::serverStaticFile($uiAsset->getAbsoluteLocation(), self::JS_MIME_TYPE);
}
示例3: Exception
* the execution of Piwik:serverStaticFile(). In this case, unit tests won't be executed
*/
// Getting the server mode
$staticFileServerMode = Common::getRequestVar(SRV_MODE_REQUEST_VAR, "");
// Setting zlib output compression as requested
ini_set('zlib.output_compression', Common::getRequestVar(ZLIB_OUTPUT_REQUEST_VAR, '0'));
if ($staticFileServerMode === "") {
throw new Exception("When this testing file is used as a static file server, the request parameter " . SRV_MODE_REQUEST_VAR . " must be provided.");
}
switch ($staticFileServerMode) {
// The static file server calls Piwik::serverStaticFile with a null file
case NULL_FILE_SRV_MODE:
ProxyHttp::serverStaticFile(null, TEST_FILE_CONTENT_TYPE);
break;
// The static file server calls Piwik::serverStaticFile with a non-existing file
// The static file server calls Piwik::serverStaticFile with a non-existing file
case GHOST_FILE_SRV_MODE:
ProxyHttp::serverStaticFile(TEST_FILE_LOCATION . ".ghost", TEST_FILE_CONTENT_TYPE);
break;
// The static file server calls Piwik::serverStaticFile with the test file
// The static file server calls Piwik::serverStaticFile with the test file
case TEST_FILE_SRV_MODE:
ProxyHttp::serverStaticFile(TEST_FILE_LOCATION, TEST_FILE_CONTENT_TYPE);
break;
case PARTIAL_TEST_FILE_SRV_MODE:
ProxyHttp::serverStaticFile(TEST_FILE_LOCATION, TEST_FILE_CONTENT_TYPE, $expireFarFutureDays = 100, PARTIAL_BYTE_START, PARTIAL_BYTE_END);
break;
case WHOLE_TEST_FILE_WITH_RANGE_SRV_MODE:
ProxyHttp::serverStaticFile(TEST_FILE_LOCATION, TEST_FILE_CONTENT_TYPE, $expireFarFutureDays = 100, 0, filesize(TEST_FILE_LOCATION));
break;
}
示例4:
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\ProxyHttp;
/**
* Tracker proxy
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST' || !empty($_SERVER['QUERY_STRING'])) {
include '../piwik.php';
exit;
}
/**
* piwik.js proxy
*
* @see core/Piwik.php
*/
define('PIWIK_INCLUDE_PATH', '..');
define('PIWIK_DOCUMENT_ROOT', '..');
define('PIWIK_USER_PATH', '..');
require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php';
require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
$file = '../piwik.js';
// There is no cache buster parameter so we don't set Expires: header
$expireFarFuture = false;
ProxyHttp::serverStaticFile($file, "application/javascript; charset=UTF-8", $expireFarFuture);
exit;
示例5: download
public function download()
{
Piwik::checkUserHasSuperUserAccess();
$this->dieIfPluginsAdminIsDisabled();
$pluginName = new PluginName();
$pluginName = $pluginName->getPluginName();
Nonce::checkNonce($pluginName);
$filename = $pluginName . '.zip';
try {
$pathToPlugin = $this->marketplaceApi->download($pluginName);
ProxyHttp::serverStaticFile($pathToPlugin, 'application/zip', $expire = 0, $start = false, $end = false, $filename);
} catch (Exception $e) {
Common::sendResponseCode(500);
Log::warning('Could not download file . ' . $e->getMessage());
}
if (!empty($pathToPlugin)) {
Filesystem::deleteFileIfExists($pathToPlugin);
}
}
示例6: Exception
// These constants define which action will be performed by the static server.
define("NULL_FILE_SRV_MODE", "nullFile");
define("GHOST_FILE_SRV_MODE", "ghostFile");
define("TEST_FILE_SRV_MODE", "testFile");
/**
* If the static file server has been requested, the response sent back to the browser will be the content produced by
* the execution of Piwik:serverStaticFile(). In this case, unit tests won't be executed
*/
// Getting the server mode
$staticFileServerMode = Common::getRequestVar(SRV_MODE_REQUEST_VAR, "");
// Setting zlib output compression as requested
ini_set('zlib.output_compression', Common::getRequestVar(ZLIB_OUTPUT_REQUEST_VAR, '0'));
if ($staticFileServerMode === "") {
throw new Exception("When this testing file is used as a static file server, the request parameter " . SRV_MODE_REQUEST_VAR . " must be provided.");
}
switch ($staticFileServerMode) {
// The static file server calls Piwik::serverStaticFile with a null file
case NULL_FILE_SRV_MODE:
ProxyHttp::serverStaticFile(null, TEST_FILE_CONTENT_TYPE);
break;
// The static file server calls Piwik::serverStaticFile with a non-existing file
// The static file server calls Piwik::serverStaticFile with a non-existing file
case GHOST_FILE_SRV_MODE:
ProxyHttp::serverStaticFile(TEST_FILE_LOCATION . ".ghost", TEST_FILE_CONTENT_TYPE);
break;
// The static file server calls Piwik::serverStaticFile with the test file
// The static file server calls Piwik::serverStaticFile with the test file
case TEST_FILE_SRV_MODE:
ProxyHttp::serverStaticFile(TEST_FILE_LOCATION, TEST_FILE_CONTENT_TYPE);
break;
}