本文整理汇总了PHP中fetchUrl函数的典型用法代码示例。如果您正苦于以下问题:PHP fetchUrl函数的具体用法?PHP fetchUrl怎么用?PHP fetchUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fetchUrl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFeed
public function getFeed()
{
function fetchUrl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
// You may need to add the line below
// curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
$feedData = curl_exec($ch);
curl_close($ch);
return $feedData;
}
if ($this->fields) {
$fields_array = explode(',', $this->fields);
foreach ($fields_array as $k => $v) {
if (!in_array($v, $this->default_fields)) {
array_push($this->default_fields, $v);
}
}
}
$final_fields = implode(',', $this->default_fields);
//Retrieve auth token via old method
$tokenFetchUrl = "https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id={$this->app_id}&client_secret={$this->app_secret}";
$authToken = fetchUrl($tokenFetchUrl);
$jsonFetchUrl = "https://graph.facebook.com/{$this->profile_id}/feed?{$authToken}&fields={$final_fields}&limit={$this->limit}";
//echo $jsonFetchUrl . '<br>';
$json_object = fetchUrl($jsonFetchUrl);
return $json_object;
}
示例2: getData
function getData($pid, $l, $appid, $appsec)
{
$authToken = fetchUrl("https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id={$appid}&client_secret={$appsec}");
$json_object = fetchUrl("https://graph.facebook.com/{$pid}/feed?{$authToken}&limit={$l}");
$json_object = fetchUrl("https://graph.facebook.com/{$pid}/");
echo $json_object;
$json_output = json_decode($json_object);
foreach ($json_output->data as $post) {
echo "<h2>{$post->name}</h2><br />";
echo "{$post->message}<br /><br />";
}
}
示例3: precacheMessage
function precacheMessage($messageid, $forwardContent = 0)
{
global $cached, $tables;
$domain = getConfig('domain');
# $message = Sql_query("select * from {$GLOBALS["tables"]["message"]} where id = $messageid");
# $cached[$messageid] = array();
# $message = Sql_fetch_array($message);
$message = loadMessageData($messageid);
## the reply to is actually not in use
if (preg_match('/([^ ]+@[^ ]+)/', $message['replyto'], $regs)) {
# if there is an email in the from, rewrite it as "name <email>"
$message['replyto'] = str_replace($regs[0], '', $message['replyto']);
$cached[$messageid]['replytoemail'] = $regs[0];
# if the email has < and > take them out here
$cached[$messageid]['replytoemail'] = str_replace('<', '', $cached[$messageid]['replytoemail']);
$cached[$messageid]['replytoemail'] = str_replace('>', '', $cached[$messageid]['replytoemail']);
# make sure there are no quotes around the name
$cached[$messageid]['replytoname'] = str_replace('"', '', ltrim(rtrim($message['replyto'])));
} elseif (strpos($message['replyto'], ' ')) {
# if there is a space, we need to add the email
$cached[$messageid]['replytoname'] = $message['replyto'];
$cached[$messageid]['replytoemail'] = "listmaster@{$domain}";
} else {
if (!empty($message['replyto'])) {
$cached[$messageid]['replytoemail'] = $message['replyto'] . "@{$domain}";
## makes more sense not to add the domain to the word, but the help says it does
## so let's keep it for now
$cached[$messageid]['replytoname'] = $message['replyto'] . "@{$domain}";
}
}
$cached[$messageid]['fromname'] = $message['fromname'];
$cached[$messageid]['fromemail'] = $message['fromemail'];
$cached[$messageid]['to'] = $message['tofield'];
#0013076: different content when forwarding 'to a friend'
$cached[$messageid]['subject'] = $forwardContent ? stripslashes($message['forwardsubject']) : $message['subject'];
#0013076: different content when forwarding 'to a friend'
$cached[$messageid]['content'] = $forwardContent ? stripslashes($message['forwardmessage']) : $message['message'];
if (USE_MANUAL_TEXT_PART && !$forwardContent) {
$cached[$messageid]['textcontent'] = $message['textmessage'];
} else {
$cached[$messageid]['textcontent'] = '';
}
# var_dump($cached);exit;
#0013076: different content when forwarding 'to a friend'
$cached[$messageid]['footer'] = $forwardContent ? stripslashes($message['forwardfooter']) : $message['footer'];
if (strip_tags($cached[$messageid]['footer']) != $cached[$messageid]['footer']) {
$cached[$messageid]['textfooter'] = HTML2Text($cached[$messageid]['footer']);
$cached[$messageid]['htmlfooter'] = $cached[$messageid]['footer'];
} else {
$cached[$messageid]['textfooter'] = $cached[$messageid]['footer'];
$cached[$messageid]['htmlfooter'] = parseText($cached[$messageid]['footer']);
}
$cached[$messageid]['htmlformatted'] = strip_tags($cached[$messageid]['content']) != $cached[$messageid]['content'];
$cached[$messageid]['sendformat'] = $message['sendformat'];
if ($message['template']) {
$req = Sql_Fetch_Row_Query("select template from {$GLOBALS['tables']['template']} where id = {$message['template']}");
$cached[$messageid]['template'] = stripslashes($req[0]);
$cached[$messageid]['templateid'] = $message['template'];
# dbg("TEMPLATE: ".$req[0]);
} else {
$cached[$messageid]['template'] = '';
$cached[$messageid]['templateid'] = 0;
}
## @@ put this here, so it can become editable per email sent out at a later stage
$cached[$messageid]['html_charset'] = 'UTF-8';
#getConfig("html_charset");
## @@ need to check on validity of charset
if (!$cached[$messageid]['html_charset']) {
$cached[$messageid]['html_charset'] = 'UTF-8';
#'iso-8859-1';
}
$cached[$messageid]['text_charset'] = 'UTF-8';
#getConfig("text_charset");
if (!$cached[$messageid]['text_charset']) {
$cached[$messageid]['text_charset'] = 'UTF-8';
#'iso-8859-1';
}
## if we are sending a URL that contains user attributes, we cannot pre-parse the message here
## but that has quite some impact on speed. So check if that's the case and apply
$cached[$messageid]['userspecific_url'] = preg_match('/\\[.+\\]/', $message['sendurl']);
if (!$cached[$messageid]['userspecific_url']) {
## Fetch external content here, because URL does not contain placeholders
if ($GLOBALS['can_fetchUrl'] && preg_match("/\\[URL:([^\\s]+)\\]/i", $cached[$messageid]['content'], $regs)) {
$remote_content = fetchUrl($regs[1], array());
# $remote_content = fetchUrl($message['sendurl'],array());
# @@ don't use this
# $remote_content = includeStyles($remote_content);
if ($remote_content) {
$cached[$messageid]['content'] = str_replace($regs[0], $remote_content, $cached[$messageid]['content']);
# $cached[$messageid]['content'] = $remote_content;
$cached[$messageid]['htmlformatted'] = strip_tags($remote_content) != $remote_content;
## 17086 - disregard any template settings when we have a valid remote URL
$cached[$messageid]['template'] = null;
$cached[$messageid]['templateid'] = null;
} else {
#print Error(s('unable to fetch web page for sending'));
logEvent('Error fetching URL: ' . $message['sendurl'] . ' cannot proceed');
return false;
}
}
//.........这里部分代码省略.........
示例4: array
}
$news = array();
// we only need it once per language per system, regardless of admins
$phpListNewsLastChecked = getConfig('phpListNewsLastChecked-' . $_SESSION['adminlanguage']['iso']);
if (empty($phpListNewsLastChecked) || $phpListNewsLastChecked + 86400 < time()) {
SaveConfig('phpListNewsLastChecked-' . $_SESSION['adminlanguage']['iso'], time(), 0, 1);
$newsIndex = fetchUrl(PHPLISTNEWSROOT . '/' . VERSION . '-' . $_SESSION['adminlanguage']['iso'] . '-index.txt');
SaveConfig('phpListNewsIndex-' . $_SESSION['adminlanguage']['iso'], $newsIndex, 0, 1);
}
$newsIndex = getConfig('phpListNewsIndex-' . $_SESSION['adminlanguage']['iso']);
if (!empty($newsIndex)) {
$newsitems = explode("\n", $newsIndex);
foreach ($newsitems as $newsitem) {
$newsitem = trim($newsitem);
if (!empty($newsitem) && !in_array(md5($newsitem), $readmessages) && (empty($viewedmessages[md5($newsitem)]['count']) || $viewedmessages[md5($newsitem)]['count'] < 20)) {
$newscontent = fetchUrl(PHPLISTNEWSROOT . '/' . $newsitem);
if (!empty($newscontent)) {
$news[$newsitem] = $newscontent;
}
}
}
ksort($news);
$newscontent = '';
foreach ($news as $newsitem => $newscontent) {
$newsid = md5($newsitem);
if (!isset($viewedmessages[$newsid])) {
$viewedmessages[$newsid] = array('time' => time(), 'count' => 1);
} else {
++$viewedmessages[$newsid]['count'];
}
SaveConfig('viewednews' . $_SESSION['logindetails']['id'], serialize($viewedmessages), 0, 1);
示例5: sendEmail
//.........这里部分代码省略.........
/*
We request you retain the signature below in your emails including the links.
This not only gives respect to the large amount of time given freely
by the developers but also helps build interest, traffic and use of
PHPlist, which is beneficial to it's future development.
You can configure how the credits are added to your pages and emails in your
config file.
Michiel Dethmers, Tincan Ltd 2003, 2004, 2005, 2006
*/
if (!EMAILTEXTCREDITS) {
$html["signature"] = $PoweredByImage;
#'<div align="center" id="signature"><a href="http://www.phplist.com"><img src="powerphplist.png" width=88 height=31 title="Powered by PHPlist" alt="Powered by PHPlist" border="0"></a></div>';
# oops, accidentally became spyware, never intended that, so take it out again :-)
$html["signature"] = preg_replace('/src=".*power-phplist.png"/', 'src="powerphplist.png"', $html["signature"]);
} else {
$html["signature"] = $PoweredByText;
}
$content = $cached[$messageid]["content"];
if (preg_match("/##LISTOWNER=(.*)/", $content, $regs)) {
$listowner = $regs[1];
$content = ereg_replace($regs[0], "", $content);
} else {
$listowner = 0;
}
## Fetch external content
if ($GLOBALS["has_pear_http_request"] && preg_match("/\\[URL:([^\\s]+)\\]/i", $content, $regs)) {
while (isset($regs[1]) && strlen($regs[1])) {
$url = $regs[1];
if (!preg_match('/^http/i', $url)) {
$url = 'http://' . $url;
}
$remote_content = fetchUrl($url, $userdata);
if ($remote_content) {
$content = eregi_replace(preg_quote($regs[0]), $remote_content, $content);
$cached[$messageid]["htmlformatted"] = strip_tags($content) != $content;
} else {
logEvent("Error fetching URL: {$regs['1']} to send to {$email}");
return 0;
}
preg_match("/\\[URL:([^\\s]+)\\]/i", $content, $regs);
}
}
#~Bas 0008857
// @@ Switched off for now, needs rigid testing, or config setting
// $content = mailto2href($content);
// $content = encodeLinks($content);
## Fill text and html versions depending on given versions.
if ($cached[$messageid]["htmlformatted"]) {
if (!$cached[$messageid]["textcontent"]) {
$textcontent = stripHTML($content);
} else {
$textcontent = $cached[$messageid]["textcontent"];
}
$htmlcontent = $content;
} else {
# $textcontent = $content;
if (!$cached[$messageid]["textcontent"]) {
$textcontent = $content;
} else {
$textcontent = $cached[$messageid]["textcontent"];
}
$htmlcontent = parseText($content);
}
$defaultstyle = getConfig("html_email_style");
示例6: define
<?php
define("SUMMETA", "<!--this is the first view page created at " . date("Y-m-d H:i:s") . " by summer -->");
$kv = new SaeKV();
$kv->init();
if ($_GET['s']) {
$url = $_SERVER['SCRIPT_URI'] . '?s=' . $_GET['s'];
echo fetchUrl($url);
exit;
}
$sitemap = $kv->get($_SERVER['SCRIPT_URI'] . 'index.html');
if ($sitemap) {
header('Content-type:text/html; charset=utf-8');
echo $sitemap;
} else {
echo fetchUrl($_SERVER['SCRIPT_URI']) . SUMMETA;
}
function fetchUrl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, 0);
curl_setopt($ch, CURLOPT_REFERER, 'staticindex');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($ch);
curl_close($ch);
if ($ret) {
return $ret;
} else {
return false;
}
示例7: importPageMod
function importPageMod($hPage)
{
global $pagesTable, $requestsTable;
$t_CVSNO = time();
$pageid = $hPage['pageid'];
$wptid = $hPage['wptid'];
$wptrun = $hPage['wptrun'];
if (!$wptid || !$wptrun) {
tprint("ERROR: importPageMod({$pageid}): failed to find wptid and wptrun: {$wptid}, {$wptrun}");
return;
}
// lifted from importWptResults
$wptServer = wptServer();
$request = $wptServer . "export.php?test={$wptid}&run={$wptrun}&cached=0&php=1";
$response = fetchUrl($request);
//tprint("after fetchUrl", $t_CVSNO);
if (!strlen($response)) {
tprint("ERROR: importPageMod({$pageid}): URL failed: {$request}");
return;
}
// lifted from importHarJson
$json_text = $response;
$HAR = json_decode($json_text);
if (NULL == $HAR) {
tprint("ERROR: importPageMod({$pageid}): JSON decode failed");
return;
}
$log = $HAR->{'log'};
$pages = $log->{'pages'};
$pagecount = count($pages);
if (0 == $pagecount) {
tprint("ERROR: importPageMod({$pageid}): No pages found");
return;
}
// lifted from importPage
$page = $pages[0];
if (array_key_exists('_TTFB', $page)) {
$hPage['TTFB'] = $page->{'_TTFB'};
}
if (array_key_exists('_fullyLoaded', $page)) {
$hPage['fullyLoaded'] = $page->{'_fullyLoaded'};
}
if (array_key_exists('_visualComplete', $page)) {
$hPage['visualComplete'] = $page->{'_visualComplete'};
}
if (array_key_exists('_gzip_total', $page)) {
$hPage['gzipTotal'] = $page->{'_gzip_total'};
$hPage['gzipSavings'] = $page->{'_gzip_savings'};
}
if (array_key_exists('_domElements', $page)) {
$hPage['numDomElements'] = $page->{'_domElements'};
}
if (array_key_exists('_domContentLoadedEventStart', $page)) {
$hPage['onContentLoaded'] = $page->{'_domContentLoadedEventStart'};
}
if (array_key_exists('_base_page_cdn', $page)) {
$hPage['cdn'] = $page->{'_base_page_cdn'};
}
if (array_key_exists('_SpeedIndex', $page)) {
$hPage['SpeedIndex'] = $page->{'_SpeedIndex'};
}
// lifted from aggregateStats
// initialize variables for counting the page's stats
$hPage['bytesTotal'] = 0;
$hPage['reqTotal'] = 0;
$typeMap = array("flash" => "Flash", "css" => "CSS", "image" => "Img", "script" => "JS", "html" => "Html", "font" => "Font", "other" => "Other", "gif" => "Gif", "jpg" => "Jpg", "png" => "Png");
foreach (array_keys($typeMap) as $type) {
// initialize the hashes
$hPage['req' . $typeMap[$type]] = 0;
$hPage['bytes' . $typeMap[$type]] = 0;
}
$hDomains = array();
$hPage['maxageNull'] = $hPage['maxage0'] = $hPage['maxage1'] = $hPage['maxage30'] = $hPage['maxage365'] = $hPage['maxageMore'] = 0;
$hPage['bytesHtmlDoc'] = $hPage['numRedirects'] = $hPage['numErrors'] = $hPage['numGlibs'] = $hPage['numHttps'] = $hPage['numCompressed'] = $hPage['maxDomainReqs'] = 0;
$result = doQuery("select mimeType, urlShort, resp_content_type, respSize, expAge, firstHtml, status, resp_content_encoding, req_host from {$requestsTable} where pageid = {$pageid};");
//tprint("after query", $t_CVSNO);
while ($row = mysql_fetch_assoc($result)) {
$reqUrl = $row['urlShort'];
$mimeType = prettyType($row['mimeType'], $reqUrl);
$respSize = intval($row['respSize']);
$hPage['reqTotal']++;
$hPage['bytesTotal'] += $respSize;
$hPage['req' . $typeMap[$mimeType]]++;
$hPage['bytes' . $typeMap[$mimeType]] += $respSize;
if ("image" === $mimeType) {
$content_type = $row['resp_content_type'];
$imgformat = false !== stripos($content_type, "image/gif") ? "gif" : (false !== stripos($content_type, "image/jpg") || false !== stripos($content_type, "image/jpeg") ? "jpg" : (false !== stripos($content_type, "image/png") ? "png" : ""));
if ($imgformat) {
$hPage['req' . $typeMap[$imgformat]]++;
$hPage['bytes' . $typeMap[$imgformat]] += $respSize;
}
}
// count unique domains (really hostnames)
$aMatches = array();
if ($reqUrl && preg_match('/http[s]*:\\/\\/([^\\/]*)/', $reqUrl, $aMatches)) {
$hostname = $aMatches[1];
if (!array_key_exists($hostname, $hDomains)) {
$hDomains[$hostname] = 0;
}
$hDomains[$hostname]++;
//.........这里部分代码省略.........
示例8: BuildFileName
// NOT mobile
echo <<<OUTPUT
<style>
#pagespeedreport UL { max-width: 100%; }
</style>
<div id="pagespeedreport" style="margin-top: 10px; font-size: 0.9em;"></div>
<script type="text/javascript" src="{$wptServer}widgets/pagespeed/tree?test={$wptid}&div=pagespeedreport"></script>
OUTPUT;
} else {
// mobile
$file = BuildFileName($url);
$fullpath = "./harfiles-delme/{$gPageid}.{$file}.har";
$bWritten = false;
if (strlen($file)) {
$response = fetchUrl($harfileWptUrl);
if (strlen($response)) {
file_put_contents("{$fullpath}", $response);
$bWritten = true;
}
}
if ($bWritten) {
doFile($fullpath);
unlink($fullpath);
}
echo <<<OUTPUT
<script>
var curDetails;
function toggleDetails(elem) {
\tif ( "undefined" != typeof(curDetails) ) {
示例9: getFat
function getFat($appid, $appsec)
{
$authToken = fetchUrl("https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id={$appid}&client_secret={$appsec}");
return $authToken;
}
示例10: getTranslationUpdates
function getTranslationUpdates()
{
## @@@TODO add some more error handling
$LU = false;
$lan_update = fetchUrl(TRANSLATIONS_XML);
if (!empty($lan_update)) {
$LU = @simplexml_load_string($lan_update);
}
return $LU;
}
示例11: forwardPage
//.........这里部分代码省略.........
# forward the message
# sendEmail will take care of blacklisting
### CHECK $email vs $forwardemail
if (sendEmail($mid, $email, 'forwarded', $userdata['htmlemail'], array(), $userdata)) {
$info .= $GLOBALS['strForwardSuccessInfo'];
sendAdminCopy(s('Message Forwarded'), s('%s has forwarded message %d to %s', $userdata['email'], $mid, $email), $messagelists);
Sql_Query(sprintf('insert into %s (user,message,forward,status,time)
values(%d,%d,"%s","sent",now())', $tables['user_message_forward'], $userdata['id'], $mid, $email));
if ($iCountFriends) {
++$nFriends;
}
} else {
$info .= $GLOBALS['strForwardFailInfo'];
sendAdminCopy(s('Message Forwarded'), s('%s tried forwarding message %d to %s but failed', $userdata['email'], $mid, $email), $messagelists);
Sql_Query(sprintf('insert into %s (user,message,forward,status,time)
values(%d,%d,"%s","failed",now())', $tables['user_message_forward'], $userdata['id'], $mid, $email));
$ok = false;
}
}
}
}
# foreach friend
if ($iCountFriends) {
saveUserAttribute($userdata['id'], $iCountFriends, array('name' => FORWARD_FRIEND_COUNT_ATTRIBUTE, 'value' => $nFriends));
}
}
#ok & emails
} else {
# no valid sender
logEvent(s('Forward request from invalid user ID: %s', substr($_REQUEST['uid'], 0, 150)));
$info .= '<BR />' . $GLOBALS['strForwardFailInfo'];
$ok = false;
}
/*
$data = PageData($id);
if (isset($data['language_file']) && is_file(dirname(__FILE__).'/texts/'.basename($data['language_file']))) {
@include dirname(__FILE__).'/texts/'.basename($data['language_file']);
}
*/
## BAS Multiple Forward
## build response page
$form = '<form method="post" action="">';
$form .= sprintf('<input type=hidden name="mid" value="%d">', $mid);
$form .= sprintf('<input type=hidden name="id" value="%d">', $id);
$form .= sprintf('<input type=hidden name="uid" value="%s">', $userdata['uniqid']);
$form .= sprintf('<input type=hidden name="p" value="forward">');
if (!$ok) {
#0011860: forward to friend, multiple emails
if (FORWARD_EMAIL_COUNT == 1) {
$form .= '<br /><h2>' . $GLOBALS['strForwardEnterEmail'] . '</h2>';
$form .= sprintf('<input type=text name="email" value="%s" size=50 class="attributeinput">', $forwardemail);
} else {
$form .= '<br /><h2>' . sprintf($GLOBALS['strForwardEnterEmails'], FORWARD_EMAIL_COUNT) . '</h2>';
$form .= sprintf('<textarea name="email" rows="10" cols="50" class="attributeinput">%s</textarea>', $forwardemail);
}
#0011996: forward to friend - personal message
if (FORWARD_PERSONAL_NOTE_SIZE) {
$form .= sprintf('<h2>' . $GLOBALS['strForwardPersonalNote'] . '</h2>', FORWARD_PERSONAL_NOTE_SIZE);
$cols = 50;
$rows = min(10, ceil(FORWARD_PERSONAL_NOTE_SIZE / 40));
$form .= sprintf('<br/><textarea type="text" name="personalNote" rows="%d" cols="%d" class="attributeinput">%s</textarea>', $rows, $cols, $personalNote);
}
$form .= sprintf('<br /><input type="submit" value="%s"></form>', $GLOBALS['strContinue']);
}
### END BAS
### Michiel, remote response page
$remote_content = '';
if (preg_match("/\\[URL:([^\\s]+)\\]/i", $messagedata['message'], $regs)) {
if (isset($regs[1]) && strlen($regs[1])) {
$url = $regs[1];
if (!preg_match('/^http/i', $url)) {
$url = 'http://' . $url;
}
$remote_content = fetchUrl($url);
}
}
if (!empty($remote_content) && preg_match('/\\[FORWARDFORM\\]/', $remote_content, $regs)) {
if ($firstpage) {
## this is the initial page, not a follow up one.
$remote_content = str_replace($regs[0], $info . $form, $remote_content);
} else {
$remote_content = str_replace($regs[0], $info, $remote_content);
}
$res = $remote_content;
} else {
$res = '<title>' . $GLOBALS['strForwardTitle'] . '</title>';
$res .= $GLOBALS['pagedata']['header'];
$res .= '<h3>' . $subtitle . '</h3>';
if ($ok) {
$res .= '<h4>' . $info . '</h4>';
} elseif (!empty($info)) {
$res .= '<div class="error missing">' . $info . '</div>';
}
$res .= $form;
$res .= '<p>' . $GLOBALS['PoweredBy'] . '</p>';
$res .= $GLOBALS['pagedata']['footer'];
}
### END MICHIEL
return $res;
}
示例12: getParam
<?php
require_once "ui.inc";
require_once "utils.inc";
require_once "dbapi.inc";
require_once "urls.inc";
require_once "pages.inc";
// Return a redirect to the filmstrip frame closest to but BEFORE the time specified.
$gTime = getParam('t', '2500');
// milliseconds
$wptid = getParam('wptid');
$wptrun = getParam('wptrun');
$gPageid = getParam('pageid');
$wptServer = wptServer();
$xmlurl = "{$wptServer}xmlResult.php?test={$wptid}";
$xmlstr = fetchUrl($xmlurl);
$xml = new SimpleXMLElement($xmlstr);
$frames = $xml->data->run[$wptrun - 1]->firstView->videoFrames;
$tbefore = 0;
$tafter = 0;
if ($frames->frame) {
foreach ($frames->frame as $frame) {
// Find the time of a frame that is BEFORE the requested time.
$ms = floatval($frame->time) * 1000;
if ($ms > $gTime) {
$tafter = $ms;
break;
}
$tbefore = $ms;
}
}
示例13: preg_replace
<?php
#updatetranslation
#sleep(20);
$lan = '';
if (isset($_GET['lan'])) {
$lan = $_GET['lan'];
$lan = preg_replace('/[^\\w_]/', '', $lan);
}
$LU = getTranslationUpdates();
if (!$LU || !is_object($LU)) {
print Error(s('Unable to fetch list of languages, please check your network or try again later'));
return;
}
$translations = array();
foreach ($LU->translation as $update) {
if ($update->iso == $lan) {
# $status = $update->updateurl;
$translationUpdate = fetchUrl($update->updateurl);
$translations = parsePo($translationUpdate);
}
}
$status = '';
if (count($translations)) {
$I18N->updateDBtranslations($translations, time());
$status = sprintf(s('updated %d language terms'), count($translations));
} else {
$status = Error(s('Network error updating language, please try again later'));
}
示例14: fetchUrl
public function fetchUrl($url, $user)
{
return fetchUrl($url, $user);
}
示例15: fetchUrl
if ($debug == 'on') {
echo '<p style="color:green;"> -connection found in line #' . $j . '</p>';
}
$jsurl = 'https://certificates.theodi.org/en/datasets' . $res3 . '/certificate/badge.js';
if ($debug == 'on') {
echo '<p style="color:grey;">----trying_methods_to_read_url:_' . $jsurl . '<br>';
}
if ($method != -1) {
$getype = $method;
}
if ($getype == 0) {
if ($debug == 'on') {
echo '<p style="color:grey;"> -trying method 0..</p>';
}
try {
$bgurl = fetchUrl($jsurl);
} catch (Exception $e) {
if ($bgurl == '') {
if ($debug == 'on') {
echo '<p style="color:red;"> failed to open file ' . '</p>';
}
if ($method == -1) {
$getype = 1;
}
}
}
}
if ($getype == 1) {
if ($debug == 'on') {
echo '<p style="color:grey;"> -trying method 1..';
}