本文整理汇总了PHP中functions::acurl方法的典型用法代码示例。如果您正苦于以下问题:PHP functions::acurl方法的具体用法?PHP functions::acurl怎么用?PHP functions::acurl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类functions
的用法示例。
在下文中一共展示了functions::acurl方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nextDepartureFromRuddammen
public static function nextDepartureFromRuddammen($maxNumber = 3)
{
$times = array();
$url = "https://api.resrobot.se/departureBoard.json?" . "maxJourneys=5" . "&passlist=0" . "&id=" . self::$ruddammen_locationid . "&key=" . self::$norditas_api_nyckel_stolptidtabeller;
$json = functions::acurl($url);
$djson = json_decode($json, 1);
if (is_array($djson) && isset($djson["Departure"])) {
$darray = $djson["Departure"];
foreach ($darray as $array) {
if (strtotime($array["time"]) >= time()) {
$times[] = preg_replace("/:\\d\\d\$/", "", $array["time"]);
}
}
}
return array_slice($times, 0, $maxNumber);
}
示例2: getYoutubeApiResponse
static function getYoutubeApiResponse($url)
{
$apiResponse = functions::acurl($url, true);
$res = preg_split("/[\r]?[\n][\r]?[\n]/", $apiResponse);
if (!$res || empty($res[1])) {
return NULL;
}
//echo "<hr>".$url."<hr>";debug::rr(json_decode($res[1]));echo "<hr>";
return json_decode($res[1]);
}
示例3: getAgendaRawData
private static function getAgendaRawData($args)
{
if (!functions::testTcpConnection(str_replace("http://", "", AGENDA_URI), 80)) {
return "";
}
sleep(5);
// to avoid DoS
if (IS_TESTSERVER || isInPath("_admin")) {
echo "<br>fromdb_agenda->getAgendaRawData(): ";
var_dump(AGENDA_TOOLS_URI . "?" . $args);
}
$data = functions::acurl(AGENDA_TOOLS_URI . "?" . $args);
// assign to variable before returning
return $data;
}
示例4: checkUserHomepages
public static function checkUserHomepages()
{
// -------------------------------------
// Select source of person data
// -------------------------------------
if (!isset($GLOBALS["peopleClass"])) {
self::loadClass(PEOPLE_DATA_SOURCE_DB);
}
// --> $GLOBALS["peopleClass"]
// -------------------------------------
// Obtain data
// -------------------------------------
$activeusers = $GLOBALS["peopleClass"]->getActiveUserArray();
if (empty($activeusers)) {
return "<p class='red bold'>» No records found</p>\r\n";
}
$types = array("standard" => array("legend" => "Redirected to standard 'people' page", "color" => "purple"), "fysikum" => array("legend" => "Redirected to Fysikum page", "color" => "red"), "nbi" => array("legend" => "Redirected to NBI page", "color" => "fuchsia"), "empty" => array("legend" => "Directory is empty", "color" => "gray"), "noaccount" => array("legend" => "403 or 404 (no account)", "color" => "orange"), "exists" => array("legend" => "Proper homepage exists", "color" => "green"));
$data = array();
foreach ($activeusers as $name => $user) {
$fysikumpage = "<body bgcolor=white text=003366 vlink=003366 alink=red link=003366>";
// sic!
$nbipage = "ocation: http://www.nbi.dk";
$standardpage1 = "maildb_single";
$standardpage2 = "u=" . $user["maildb"];
$emptypage = ">Index of /~";
foreach (array("acc_kth", "acc_su", "acc_nbi") as $account) {
// array("acc_kth","acc_su","acc_nbi","acc_maildb")
$data[$user["maildb"]][$account] = array("usr" => "", "type" => "", "code" => 404);
if (isset($user[$account]) && strpos($user[$account], ".") === false) {
$url = "http://www.nordita.org/~" . $user[$account] . "/";
$homepage = functions::acurl($url, true);
if ($homepage) {
$response = preg_match("#^HTTP/1.1 ([^ ]*) (.*)\$#im", $homepage, $code);
$homepagetype = "exists";
if (strpos($homepage, $standardpage1) !== false || strpos($homepage, $standardpage2) !== false || $user == "belokop" && strpos($homepage, "u=yb") !== false) {
$homepagetype = "standard";
} elseif (strpos($homepage, $fysikumpage) !== false) {
$homepagetype = "fysikum";
} elseif (strpos($homepage, $nbipage) !== false) {
$homepagetype = "nbi";
} elseif (strpos($homepage, $emptypage) !== false) {
$homepagetype = "empty";
} elseif (strpos($homepage, "200 OK") === false) {
$homepagetype = "noaccount";
} else {
$homepagetype = "exists";
}
$data[$user["maildb"]][$account] = array("usr" => $user[$account], "type" => $homepagetype, "code" => $code[1]);
}
// end if
}
}
// end foreach
}
// end foreach
// -------------------------------------
// Output result
// -------------------------------------
$stdout = "<p>Check if <strong style='font-family:monospace'>http://www.nordita.org/~<<em>username</em>></strong> works for different usernames that Nordita people have, at KTH, SU or NBI.</p>\r\n" . "<h4>Legend</h4>\r\n" . "<ul class='box padding blackborder'>\r\n";
foreach ($types as $type) {
$stdout .= " <li><strong style='color:" . $type["color"] . "'>" . $type["legend"] . "</strong></li>\r\n";
}
$stdout .= "</ul>\r\n" . "";
$stdout .= "<table>\r\n" . " <tr>\r\n" . " <th></th>\r\n" . " <th>MAILDB ID</th>\r\n" . " <th>KTH username</th>\r\n" . " <th>SU username</th>\r\n" . " <th>NBI username</th>\r\n" . " </tr>\r\n";
foreach ($activeusers as $name => $user) {
$stdout .= " <tr>\r\n" . " <tr>\r\n" . " <td>" . functions::straightenName($name) . "</td>\r\n" . " <td class='b_zebra2'><strong>" . $user["maildb"] . "</strong></td>\r\n";
$i = 1;
foreach ($data[$user["maildb"]] as $account => $item) {
if (empty($item["type"])) {
$stdout .= " <td class='b_zebra" . $i . "'>-</td>\r\n";
} else {
$usertext = "<strong style='color:" . $types[$item["type"]]["color"] . ";text-decoration:none' " . "title='" . $types[$item["type"]]["legend"] . "'>" . $item["usr"] . "</strong>";
if ($item["code"] < 400 || 500 <= $item["code"]) {
$usertext = "<a href='http://www.nordita.org/~" . $item["usr"] . "/' " . TARGET_BLANK . ">" . str_replace("none", "underline", $usertext) . "</a>";
}
$stdout .= " <td class='b_zebra" . $i . "'>[" . $item["code"] . "] " . $usertext . "</td>\r\n";
}
$i = 3 - $i;
}
}
// end foreach
$stdout .= " </tr>\r\n" . "</table>\r\n";
return $stdout;
}
示例5: getSubscriberStatusByEmail
function getSubscriberStatusByEmail($table = "", $email = "")
{
$curl_cookie = self::getLoginCookie(1);
$qs["findmember"] = $email;
$qs["findmember_btn"] = "Search...";
$theurl = self::$url . "members/";
if (!empty($qs)) {
$theurl .= "?" . http_build_query($qs);
}
//var_dump($theurl);
$output = functions::acurl($theurl, 0, 1, $curl_cookie);
//var_dump($output);
$pattern = "\\<center\\>\\<em\\>0 members total\\<\\/em\\>\\<\\/center\\>";
if (preg_match("/" . $pattern . "/is", $output)) {
return false;
}
$pattern = "_nomail\" type=\"CHECKBOX\" value=\"on\"";
if (preg_match("/" . $pattern . "/is", $output)) {
return NEWS_REMOVED;
}
return NEWS_ACTIVE;
}
示例6: OutputFromPreprintArchive
public static function OutputFromPreprintArchive()
{
$stdout = "";
$wid = "preprintsample";
// ---------------------------
// Obtain data
// ---------------------------
self::loadClass(PREPRINT_DATA_SOURCE_DB);
// --> $GLOBALS["preprintClass"]
$preprints_row = $GLOBALS["preprintClass"]->getRecentPreprints("", 20, TRUE);
if (!is_array($preprints_row)) {
return "";
}
$paper = $preprints_row[array_rand($preprints_row)];
if (empty($paper["location"])) {
return "";
}
$arxiv_number = preg_match("~/abs/(.*)\$~i", $paper["location"], $res) ? trim($res[1]) : "";
if (empty($arxiv_number)) {
return "";
}
$url = "http://arxiv.org/abs/" . $arxiv_number;
$arxiv_dump = functions::acurl($url, TRUE);
if (!$arxiv_dump) {
return "";
}
$arxiv_dump = preg_replace("#\\s#", " ", $arxiv_dump);
// seems to be needed for the preg_matches below...
if (preg_match("#<h1 class=\"title[^\"]*\">.*</span>\\s*(.*)</h1>#iU", $arxiv_dump, $titleArr)) {
$title = trim($titleArr[1]);
} elseif (!empty($paper["title"])) {
$title = $paper["title"];
} else {
$title = "";
}
$authors = preg_match("#<div class=\"authors\">.*</span>\\s*(.*)</div>#iU", $arxiv_dump, $authorArr) ? trim($authorArr[1]) : "";
$author = preg_match_all("#<a href=[^>]*>(.*)</a>#iU", $authors, $authArr) ? trim(join(", ", $authArr[1])) : "";
$author = preg_replace("#,([^,]*)\$#i", " <span style='font-weight:normal'>and</span> \\1", $author);
$abstract = preg_match("#<blockquote class=\"abstract[^\"]*\">.*</span>\\s*(.*)</blockquote>#iU", $arxiv_dump, $abstractArr) ? trim($abstractArr[1]) : "";
// ---------------------------
// Output data
// ---------------------------
$stdout .= " <div id='" . $wid . "'>\r\n" . " <h3>From the <a href='science/preprints/index.php' rel='nofollow'>Preprint Archive</a></h3>\r\n" . " <div class='box paper shadow'>\r\n" . (empty($title) ? "" : " <p class='title'><a href='http://arxiv.org/abs/" . $arxiv_number . "'>" . $title . "</a></p>\r\n") . (empty($author) ? "" : " <p class='author'><span style='font-weight:normal'>by</span> " . $author . "</p>\r\n") . (empty($abstract) ? "" : " <p class='abstract'>" . $abstract . "</p>\r\n") . " </div>\r\n" . " </div> <!-- " . $wid . " -->\r\n" . "\r\n";
return $stdout;
}
示例7: getBookingsFromTimeedit
function getBookingsFromTimeedit($dateFrom, $dateTo, $roomid)
{
// ----------------------
// -- Fetch webpage from TimeEdit site
// NB: Must use "&" and not "&"
// ----------------------
$url = "http://lokal2.timeedit.se/kth/scheduleservlet?" . "fromDate=" . $dateFrom . "&toDate=" . $dateTo . "&resultsroomName=" . $roomid;
// minSeats=50&maxSeats=55
//$url2 = "http://lokal2.timeedit.se/kth/resourceservlet?fromDate=2012-10-15&selectMode=many&resourceTypeDropDown=Room®ionDropDown=4&houseDropDown=3&roomType=&minSeats=100&maxSeats=&sortType=Room&bookButton=S%C3%B6k#bookingSearchResults";
//$url3 = "http://lokal2.timeedit.se/kth/roombookings.jsp?element=week&roomId=100&date=2012-10-15";
$raw = functions::acurl($url);
// ----------------------
// -- Keep only table code [may be skipped?]
// ----------------------
if ($raw && preg_match("#<h1 id=\"headline\">.*</h1>[\\s]*<div>(.*)[\\s]*</div>[\\s]*</div>[\\s]*<div class=\"footnote\"></div>#mUs", $raw, $res)) {
$raw = $res[1];
}
// ----------------------
// -- Parse code
// ----------------------
$booking = array();
if (preg_match_all("#<div class=\"weekDay\">[^&].*<br>(.*)</div>[\\s]*</div>#mUs", $raw, $res1)) {
foreach ($res1[1] as $r) {
$date = preg_match("#^(....-..-..)#mUs", $r, $res2) ? $res2[1] : "0000-00-00";
if (preg_match_all("#<div class=\"bookingDiv\".*title=\"(.*)\"#mUs", $r, $res3)) {
foreach ($res3[1] as $evt) {
$part = preg_split("/,\\s*/", $evt);
$times = preg_split("/\\s*-\\s*/", $part[0]);
$title = implode(", ", array(preg_replace("/[\\s]*\\(.*\\)/", "", $part[1]), $part[2]));
$booking[] = array("id" => isset($this->kthToId[$roomid]) ? $this->kthToId[$roomid] : "", "start_time" => strtotime($date . " " . $times[0] . ":00"), "end_time" => strtotime($date . " " . $times[1] . ":00"), "entry_type" => "", "repeat_id" => "0", "kth_id" => $roomid, "timestamp" => DATETIME_NULL, "create_by" => "", "name" => "", "roomtype_id" => "", "description" => "", "title" => $title);
}
}
}
}
// ----------------------
return $booking;
}
示例8: analyzeOauthResponse
public static function analyzeOauthResponse($returnUrl, $domain)
{
$_SESSION["oauth_access_token"] = "";
// -- (1) OAuth return values from first call (validation)
// $_REQUEST["state"]
// $_REQUEST["code"]
functions::gpc_declare_input("code", "", false, array(), false);
functions::gpc_declare_input("state", "", false, array(), false);
$GLOBALS["oauth_state"] = $GLOBALS["state"];
functions::gpc_declare_input("error", "", false, array(), false);
functions::gpc_declare_input("error_reason", "", false, array(), false);
functions::gpc_declare_input("error_description", "", false, array(), false);
switch ($domain) {
case "facebook":
$accessTokenUrl = "https://graph.facebook.com/oauth/access_token?" . "redirect_uri=" . urlencode($returnUrl) . "&client_id=" . FACEBBOK_NEWS_APP_ID . "&client_secret=" . FACEBBOK_NEWS_APP_SECRET . "&code=" . $GLOBALS["code"];
$authorizeUrl = "https://graph.facebook.com/me";
break;
case "twitter":
$accessTokenUrl = "https://api.twitter.com/oauth/access_token?" . "redirect_uri=" . urlencode($returnUrl) . "&client_id=" . FACEBBOK_NEWS_APP_ID . "&client_secret=" . FACEBBOK_NEWS_APP_SECRET . "&code=" . $GLOBALS["code"];
$authorizeUrl = "https://api.twitter.com/oauth/authorize";
break;
}
if (OPENIDDEBUG) {
echo "<hr><h4>START OAUTH RESPONSE:</h4>state=";
var_dump($GLOBALS["state"]);
echo "<br><br>SESSION(state)=";
if (isset($_SESSION["oauth_state"])) {
var_dump($_SESSION["oauth_state"]);
} else {
echo "-";
}
echo "<br><br>code=";
var_dump($GLOBALS["code"]);
}
if (!empty($GLOBALS["error"])) {
//TODO:
if (OPENIDDEBUG) {
echo "<br>OAUTH ERROR: ";
var_dump($GLOBALS["error"]);
var_dump($GLOBALS["error_reason"]);
var_dump($GLOBALS["error_description"]);
}
if (OPENIDDEBUG) {
echo "<h4>END OAUTH RESPONSE</h4><hr>";
}
return false;
}
if (isset($_SESSION["oauth_state"]) && $_SESSION["oauth_state"] === $GLOBALS["state"]) {
$response = functions::acurl($accessTokenUrl);
// do NOT use file_get_contents()
$params = null;
parse_str($response, $params);
} else {
//TODO: more user-friendly text
if (OPENIDDEBUG) {
echo "<h4>END OAUTH RESPONSE</h4><hr>";
}
return "The state does not match. You may be a victim of CSRF.";
}
// -- (2) OAuth return values from second call (exchange code for access token)
if (isset($params["access_token"])) {
// User data was returned:
$_SESSION["oauth_access_token"] = $params["access_token"];
//$_SESSION["oauth_expires"] = $params["expires"]; // seconds
$authorizeUrl .= "?access_token=" . $params['access_token'];
$user = json_decode(functions::acurl($authorizeUrl));
if (OPENIDDEBUG) {
debug::rr($user);
}
if (OPENIDDEBUG) {
echo "<h4>END OAUTH RESPONSE</h4><hr>";
}
//echo("Hello " . $user->name);
//$user->id
//$user->name
//$user->first_name
//$user->last_name
//Extended:
// email
// picture->url and picture->is_silhouette
$idData["display_identifyer"] = isset($_SESSION["openid_identifier"]) ? $_SESSION["openid_identifier"] : "";
//TODO: fragile:
if (!empty($idData["display_identifyer"])) {
$_SESSION["openid_last_valid_identifier"] = $idData["display_identifyer"];
}
$idData["data"]["nickname"][] = isset($user->name) ? $user->name : "";
// no nickanme available
$idData["data"]["email"][] = isset($user->email) ? $user->email : "";
$idData["data"]["fullname"][] = isset($user->name) ? $user->name : "";
//TODO:
$idData["data"]["image"] = array();
$idData["data"]["guid"] = array();
$idData["data"]["dob"] = array();
$idData["data"]["gender"] = array();
$idData["data"]["postcode"] = array();
$idData["data"]["country"] = array();
$idData["data"]["language"] = array();
$idData["data"]["timezone"] = array();
// Dummy arrays for compatibility with OpenID output
$idData["sreg"] = array();
//.........这里部分代码省略.........