本文整理汇总了PHP中Piwik\Http::fetchRemoteFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::fetchRemoteFile方法的具体用法?PHP Http::fetchRemoteFile怎么用?PHP Http::fetchRemoteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Http
的用法示例。
在下文中一共展示了Http::fetchRemoteFile方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public function get()
{
try {
$content = Http::fetchRemoteFile($this->url);
$rss = simplexml_load_string($content);
} catch (\Exception $e) {
echo "Error while importing feed: {$e->getMessage()}\n";
exit;
}
$output = '<div style="padding:10px 15px;"><ul class="rss">';
$i = 0;
$items = array();
if (!empty($rss->channel->item)) {
$items = $rss->channel->item;
}
foreach ($items as $post) {
$title = $post->title;
$date = @strftime("%B %e, %Y", strtotime($post->pubDate));
$link = $post->link;
$output .= '<li><a class="rss-title" title="" target="_blank" href="?module=Proxy&action=redirect&url=' . $link . '">' . $title . '</a>' . '<span class="rss-date">' . $date . '</span>';
if ($this->showDescription) {
$output .= '<div class="rss-description">' . $post->description . '</div>';
}
if ($this->showContent) {
$output .= '<div class="rss-content">' . $post->content . '</div>';
}
$output .= '</li>';
if (++$i == $this->count) {
break;
}
}
$output .= '</ul></div>';
return $output;
}
示例2: testFetchLatestZip
/**
* @group Core
*/
public function testFetchLatestZip()
{
$destinationPath = PIWIK_USER_PATH . '/tmp/latest/latest.zip';
Http::fetchRemoteFile('http://builds.piwik.org/latest.zip', $destinationPath, 3, 30);
$this->assertFileExists($destinationPath);
$this->assertGreaterThan(0, filesize($destinationPath));
}
示例3: testFetchLatestZip
public function testFetchLatestZip()
{
$destinationPath = PIWIK_USER_PATH . '/tmp/latest/latest.zip';
Http::fetchRemoteFile(Fixture::getRootUrl() . 'tests/PHPUnit/Integration/Http/fixture.zip', $destinationPath, 3, 30);
$this->assertFileExists($destinationPath);
$this->assertGreaterThan(0, filesize($destinationPath));
}
示例4: download
public function download($pluginOrThemeName, $target)
{
$downloadUrl = $this->getDownloadUrl($pluginOrThemeName);
if (empty($downloadUrl)) {
return false;
}
$success = Http::fetchRemoteFile($downloadUrl, $target, 0, static::HTTP_REQUEST_TIMEOUT);
return $success;
}
示例5: trackVisits
private function trackVisits()
{
if (!$this->trackInvalidRequests) {
return;
}
$dateTime = $this->dateTime;
$idSite = $this->idSite;
API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(true);
API::getInstance()->setGlobalExcludedUserAgents('globalexcludeduseragent');
// Trigger empty request
$trackerUrl = self::getTrackerUrl();
$response = Http::fetchRemoteFile($trackerUrl);
self::assertTrue(strpos($response, 'is a free open source web') !== false, 'Piwik empty request response not correct: ' . $response);
$t = self::getTracker($idSite, $dateTime, $defaultInit = true);
// test GoogleBot UA visitor
$t->setUserAgent('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
self::checkResponse($t->doTrackPageView('bot visit, please do not record'));
// Test IP Exclusion works with or without IP exclusion
foreach (array(false, true) as $enable) {
$excludedIp = '154.1.12.34';
API::getInstance()->updateSite($idSite, 'new site name', $url = array('http://site.com'), $ecommerce = 0, $ss = 1, $ss_kwd = '', $ss_cat = '', $excludedIp . ',1.2.3.4', $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = 'excludeduseragentstring');
// Enable IP Anonymization
$t->DEBUG_APPEND_URL = '&forceIpAnonymization=' . (int) $enable;
// test with excluded User Agent
$t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729) (excludeduseragentstring)');
$t->setIp('211.1.2.3');
self::checkResponse($t->doTrackPageView('visit from excluded User Agent'));
$t->setUserAgent('Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0 Google (+https://developers.google.com/+/web/snippet/)');
self::checkResponse($t->doTrackPageView('visit from excluded User Agent'));
// test w/ global excluded User Agent
$t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729) (globalexcludeduseragent)');
$t->setIp('211.1.2.3');
self::checkResponse($t->doTrackPageView('visit from global excluded User Agent'));
// test with excluded IP
$t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)');
// restore normal user agent
$t->setIp($excludedIp);
self::checkResponse($t->doTrackPageView('visit from IP excluded'));
// test with global list of excluded IPs
$excludedIpBis = '145.5.3.4';
API::getInstance()->setGlobalExcludedIps($excludedIpBis);
$t->setIp($excludedIpBis);
self::checkResponse($t->doTrackPageView('visit from IP globally excluded'));
}
try {
@$t->setAttributionInfo(array());
self::fail();
} catch (Exception $e) {
}
try {
$t->setAttributionInfo(json_encode('test'));
self::fail();
} catch (Exception $e) {
}
$t->setAttributionInfo(json_encode(array()));
}
示例6: oneClick_Download
private function oneClick_Download()
{
$pathPiwikZip = PIWIK_USER_PATH . self::PATH_TO_EXTRACT_LATEST_VERSION . 'latest.zip';
$this->pathPiwikZip = SettingsPiwik::rewriteTmpPathWithInstanceId($pathPiwikZip);
Filechecks::dieIfDirectoriesNotWritable(array(self::PATH_TO_EXTRACT_LATEST_VERSION));
// we catch exceptions in the caller (i.e., oneClickUpdate)
$url = self::getLatestZipUrl($this->newVersion) . '?cb=' . $this->newVersion;
Http::fetchRemoteFile($url, $this->pathPiwikZip);
}
示例7: downloadArchive
private function downloadArchive($version, $url)
{
$path = $this->tmpPath . self::PATH_TO_EXTRACT_LATEST_VERSION;
$archiveFile = $path . 'latest.zip';
Filechecks::dieIfDirectoriesNotWritable(array($path));
$url .= '?cb=' . $version;
try {
Http::fetchRemoteFile($url, $archiveFile, 0, self::DOWNLOAD_TIMEOUT);
} catch (Exception $e) {
// We throw a specific exception allowing to offer HTTP download if HTTPS failed
throw new ArchiveDownloadException($e);
}
return $archiveFile;
}
示例8: fetchUnitData
protected function fetchUnitData(OutputInterface $output, $langCode, $requestLangCode, &$translations)
{
$unitsUrl = 'https://raw.githubusercontent.com/unicode-cldr/cldr-units-full/master/main/%s/units.json';
try {
$unitsData = Http::fetchRemoteFile(sprintf($unitsUrl, $requestLangCode));
$unitsData = json_decode($unitsData, true);
$unitsData = $unitsData['main'][$requestLangCode]['units'];
$translations['Intl']['NSeconds'] = $this->replacePlaceHolder($unitsData['long']['duration-second']['unitPattern-count-other']);
$translations['Intl']['NSecondsShort'] = $this->replacePlaceHolder($unitsData['narrow']['duration-second']['unitPattern-count-other']);
$translations['Intl']['Seconds'] = $unitsData['long']['duration-second']['displayName'];
$translations['Intl']['NMinutes'] = $this->replacePlaceHolder($unitsData['long']['duration-minute']['unitPattern-count-other']);
if (isset($unitsData['long']['duration-minute']['unitPattern-count-one'])) {
$translations['Intl']['OneMinute'] = $this->replacePlaceHolder($unitsData['long']['duration-minute']['unitPattern-count-one'], '1');
} else {
$translations['Intl']['OneMinute'] = $this->replacePlaceHolder($unitsData['long']['duration-minute']['unitPattern-count-other'], '1');
}
if (isset($unitsData['short']['duration-minute']['unitPattern-count-one'])) {
$translations['Intl']['OneMinuteShort'] = $this->replacePlaceHolder($unitsData['short']['duration-minute']['unitPattern-count-one'], '1');
} else {
$translations['Intl']['OneMinuteShort'] = $this->replacePlaceHolder($unitsData['short']['duration-minute']['unitPattern-count-other'], '1');
}
$translations['Intl']['NMinutesShort'] = $this->replacePlaceHolder($unitsData['short']['duration-minute']['unitPattern-count-other']);
$translations['Intl']['Minutes'] = $unitsData['long']['duration-minute']['displayName'];
$translations['Intl']['Hours'] = $unitsData['long']['duration-hour']['displayName'];
$translations['Intl']['NHoursShort'] = $this->replacePlaceHolder($unitsData['narrow']['duration-hour']['unitPattern-count-other']);
$translations['Intl']['NDays'] = $this->replacePlaceHolder($unitsData['long']['duration-day']['unitPattern-count-other']);
if (isset($unitsData['short']['duration-day']['unitPattern-count-one'])) {
$translations['Intl']['OneDay'] = $this->replacePlaceHolder($unitsData['long']['duration-day']['unitPattern-count-one'], '1');
} else {
$translations['Intl']['OneDay'] = $this->replacePlaceHolder($unitsData['long']['duration-day']['unitPattern-count-other'], '1');
}
$translations['Intl']['PeriodWeeks'] = $unitsData['long']['duration-week']['displayName'];
$translations['Intl']['PeriodYears'] = $unitsData['long']['duration-year']['displayName'];
$translations['Intl']['PeriodDays'] = $unitsData['long']['duration-day']['displayName'];
$translations['Intl']['PeriodMonths'] = $unitsData['long']['duration-month']['displayName'];
$output->writeln('Saved unit data for ' . $langCode);
} catch (\Exception $e) {
$output->writeln('Unable to import unit data for ' . $langCode);
}
}
示例9: test_piwikJs_minified_isUpToDate
public function test_piwikJs_minified_isUpToDate()
{
Http::fetchRemoteFile('https://github.com/downloads/yui/yuicompressor/yuicompressor-2.4.7.zip', PIWIK_DOCUMENT_ROOT . '/tmp/yuicompressor.zip');
shell_exec('unzip -n ' . PIWIK_DOCUMENT_ROOT . '/tmp/yuicompressor.zip');
shell_exec("sed '/<DEBUG>/,/<\\/DEBUG>/d' < " . PIWIK_DOCUMENT_ROOT . "/js/piwik.js | sed 's/eval/replacedEvilString/' | java -jar yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar --type js --line-break 1000 | sed 's/replacedEvilString/eval/' | sed 's/^[/][*]/\\/*!/' > " . PIWIK_DOCUMENT_ROOT . "/piwik-minified.js");
$this->assertFileEquals(PIWIK_DOCUMENT_ROOT . '/piwik-minified.js', PIWIK_DOCUMENT_ROOT . '/piwik.js', 'minified /piwik.js is out of date, please re-generate the minified files using instructions in /js/README');
$this->assertFileEquals(PIWIK_DOCUMENT_ROOT . '/piwik-minified.js', PIWIK_DOCUMENT_ROOT . '/js/piwik.min.js', 'minified /js/piwik.min.js is out of date, please re-generate the minified files using instructions in /js/README');
}