本文整理汇总了PHP中HTTP::ExtractURL方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP::ExtractURL方法的具体用法?PHP HTTP::ExtractURL怎么用?PHP HTTP::ExtractURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTP
的用法示例。
在下文中一共展示了HTTP::ExtractURL方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: curl_exec
function curl_exec($ch)
{
global $curl_init__map;
$key = get_check_curl_init_key($ch);
// Set allowed protocols.
$allowedprotocols = array("http" => true, "https" => true);
if (isset($curl_init__map[$key]["options"][CURLOPT_PROTOCOLS])) {
$allowedprotocols["http"] = (bool) ($curl_init__map[$key]["options"][CURLOPT_PROTOCOLS] & CURLPROTO_HTTP);
$allowedprotocols["https"] = (bool) ($curl_init__map[$key]["options"][CURLOPT_PROTOCOLS] & CURLPROTO_HTTPS);
}
$curl_init__map[$key]["browser"]->SetState(array("allowedprotocols" => $allowedprotocols));
// Set allowed redirect protocols.
$allowedprotocols = array("http" => true, "https" => true);
if (isset($curl_init__map[$key]["options"][CURLOPT_REDIR_PROTOCOLS])) {
$allowedprotocols["http"] = (bool) ($curl_init__map[$key]["options"][CURLOPT_REDIR_PROTOCOLS] & CURLPROTO_HTTP);
$allowedprotocols["https"] = (bool) ($curl_init__map[$key]["options"][CURLOPT_REDIR_PROTOCOLS] & CURLPROTO_HTTPS);
}
$curl_init__map[$key]["browser"]->SetState(array("allowedredirprotocols" => $allowedprotocols));
// Load cookies. Violates the PHP/cURL definition a lot. Whatever.
if (isset($curl_init__map[$key]["options"][CURLOPT_COOKIEFILE]) && is_string($curl_init__map[$key]["options"][CURLOPT_COOKIEFILE]) && $curl_init__map[$key]["options"][CURLOPT_COOKIEFILE] != "") {
$data = @unserialize(@file_get_contents($curl_init__map[$key]["options"][CURLOPT_COOKIEFILE]));
if ($data !== false && is_array($data)) {
// Load the WebBrowser() object with the cookies.
$curl_init__map[$key]["browser"]->SetState(array("cookies" => $data));
}
$curl_init__map[$key]["options"][CURLOPT_COOKIEFILE] = "";
}
if (isset($curl_init__map[$key]["options"][CURLOPT_COOKIESESSION]) && $curl_init__map[$key]["options"][CURLOPT_COOKIESESSION]) {
$curl_init__map[$key]["browser"]->DeleteSessionCookies();
}
// Set the autoreferer setting.
$curl_init__map[$key]["browser"]->SetState(array("autoreferer" => isset($curl_init__map[$key]["options"][CURLOPT_AUTOREFERER]) && $curl_init__map[$key]["options"][CURLOPT_AUTOREFERER]));
// Set the Referer.
if (isset($curl_init__map[$key]["options"][CURLOPT_REFERER]) && is_string($curl_init__map[$key]["options"][CURLOPT_REFERER])) {
$curl_init__map[$key]["browser"]->SetState(array("referer" => $curl_init__map[$key]["options"][CURLOPT_REFERER]));
}
// Set the followlocation and maxfollow settings.
$curl_init__map[$key]["browser"]->SetState(array("followlocation" => isset($curl_init__map[$key]["options"][CURLOPT_FOLLOWLOCATION]) && $curl_init__map[$key]["options"][CURLOPT_FOLLOWLOCATION]));
$curl_init__map[$key]["browser"]->SetState(array("maxfollow" => isset($curl_init__map[$key]["options"][CURLOPT_MAXREDIRS]) ? $curl_init__map[$key]["options"][CURLOPT_MAXREDIRS] : 20));
// Set up the options array.
$options = array();
// Set connect and total timeout options.
if (isset($curl_init__map[$key]["options"][CURLOPT_CONNECTTIMEOUT]) || isset($curl_init__map[$key]["options"][CURLOPT_CONNECTTIMEOUT_MS])) {
$timeout = (isset($curl_init__map[$key]["options"][CURLOPT_CONNECTTIMEOUT]) ? $curl_init__map[$key]["options"][CURLOPT_CONNECTTIMEOUT] : 0) + (isset($curl_init__map[$key]["options"][CURLOPT_CONNECTTIMEOUT_MS]) ? $curl_init__map[$key]["options"][CURLOPT_CONNECTTIMEOUT_MS] : 0) / 1000;
if ($timeout > 0) {
$options["connecttimeout"] = $timeout;
$options["proxyconnecttimeout"] = $timeout;
}
}
if (isset($curl_init__map[$key]["options"][CURLOPT_TIMEOUT]) || isset($curl_init__map[$key]["options"][CURLOPT_TIMEOUT_MS])) {
$timeout = (isset($curl_init__map[$key]["options"][CURLOPT_TIMEOUT]) ? $curl_init__map[$key]["options"][CURLOPT_TIMEOUT] : 0) + (isset($curl_init__map[$key]["options"][CURLOPT_TIMEOUT_MS]) ? $curl_init__map[$key]["options"][CURLOPT_TIMEOUT_MS] : 0) / 1000;
if ($timeout > 0) {
$options["connecttimeout"] = $timeout;
$options["proxyconnecttimeout"] = $timeout;
}
}
// Set proxy options.
if (isset($curl_init__map[$key]["options"][CURLOPT_PROXY])) {
if (isset($curl_init__map[$key]["options"][CURLOPT_PROXYTYPE]) && $curl_init__map[$key]["options"][CURLOPT_PROXYTYPE] != CURLPROXY_HTTP) {
$curl_init__map[$key]["errorno"] = CURLE_UNSUPPORTED_PROTOCOL;
$curl_init__map[$key]["errorinfo"] = HTTP::HTTPTranslate("CURLOPT_PROXYTYPE option is unsupported.");
return false;
}
$proxyurl = $curl_init__map[$key]["options"][CURLOPT_PROXY];
$proxyport = (int) (isset($curl_init__map[$key]["options"][CURLOPT_PROXYPORT]) ? $curl_init__map[$key]["options"][CURLOPT_PROXYPORT] : false);
if ($proxyport < 1 || $proxyport > 65535) {
$proxyport = false;
}
if (strpos($proxyurl, "://") === false) {
$proxyurl = ($proxyport == 443 ? "https://" : "http://") . $proxyurl;
}
$proxyurl = HTTP::ExtractURL($proxyurl);
if ($proxyport !== false) {
$proxyurl["port"] = $proxyport;
}
if (isset($curl_init__map[$key]["options"][CURLOPT_PROXYUSERPWD])) {
$userpass = explode(":", $curl_init__map[$key]["options"][CURLOPT_PROXYUSERPWD]);
if (count($userpass) == 2) {
$proxyurl["loginusername"] = urldecode($userpass[0]);
$proxyurl["loginpassword"] = urldecode($userpass[1]);
}
}
$options["proxyurl"] = HTTP::CondenseURL($proxyurl);
if (isset($curl_init__map[$key]["options"][CURLOPT_HTTPPROXYTUNNEL])) {
$options["proxyconnect"] = $curl_init__map[$key]["options"][CURLOPT_HTTPPROXYTUNNEL];
}
}
// Set SSL options.
$options["sslopts"] = array();
$options["sslopts"]["verify_peer"] = isset($curl_init__map[$key]["options"][CURLOPT_SSL_VERIFYPEER]) ? $curl_init__map[$key]["options"][CURLOPT_SSL_VERIFYPEER] : true;
if (isset($curl_init__map[$key]["options"][CURLOPT_CAINFO])) {
$options["sslopts"]["cafile"] = $curl_init__map[$key]["options"][CURLOPT_CAINFO];
}
if (isset($curl_init__map[$key]["options"][CURLOPT_CAPATH])) {
$options["sslopts"]["capath"] = $curl_init__map[$key]["options"][CURLOPT_CAPATH];
}
if (!isset($options["sslopts"]["cafile"]) && !isset($options["sslopts"]["capath"])) {
$options["sslopts"]["auto_cainfo"] = true;
}
if (isset($curl_init__map[$key]["options"][CURLOPT_SSLCERT]) && isset($curl_init__map[$key]["options"][CURLOPT_SSLKEY])) {
//.........这里部分代码省略.........
示例2: Connect
public function Connect($url, $origin, $profile = "auto", $options = array(), $web = false)
{
$this->Disconnect();
if (class_exists("CSPRNG") && $this->csprng === false) {
$this->csprng = new CSPRNG();
}
if (isset($options["fp"]) && is_resource($options["fp"])) {
$this->fp = $options["fp"];
} else {
// Use WebBrowser to initiate the connection.
if ($web === false) {
$web = new WebBrowser();
}
// Transform URL.
$url2 = HTTP::ExtractURL($url);
if ($url2["scheme"] != "ws" && $url2["scheme"] != "wss") {
return array("success" => false, "error" => HTTP::HTTPTranslate("WebSocket::Connect() only supports the 'ws' and 'wss' protocols."), "errorcode" => "protocol_check");
}
$url2["scheme"] = str_replace("ws", "http", $url2["scheme"]);
$url2 = HTTP::CondenseURL($url2);
// Generate correct request headers.
if (!isset($options["headers"])) {
$options["headers"] = array();
}
$options["headers"]["Connection"] = "keep-alive, Upgrade";
if ($origin != "") {
$options["headers"]["Origin"] = $origin;
}
$options["headers"]["Pragma"] = "no-cache";
$key = base64_encode($this->PRNGBytes(16));
$options["headers"]["Sec-WebSocket-Key"] = $key;
$options["headers"]["Sec-WebSocket-Version"] = "13";
$options["headers"]["Upgrade"] = "websocket";
// No async support for connecting at this time. Async mode is enabled AFTER connecting though.
unset($options["async"]);
// Connect to the WebSocket.
$result = $web->Process($url2, $profile, $options);
if (!$result["success"]) {
return $result;
}
if ($result["response"]["code"] != 101) {
return array("success" => false, "error" => HTTP::HTTPTranslate("WebSocket::Connect() failed to connect to the WebSocket. Server returned: %s %s", $result["response"]["code"], $result["response"]["meaning"]), "errorcode" => "incorrect_server_response");
}
if (!isset($result["headers"]["Sec-Websocket-Accept"])) {
return array("success" => false, "error" => HTTP::HTTPTranslate("Server failed to include a 'Sec-WebSocket-Accept' header in its response to the request."), "errorcode" => "missing_server_websocket_accept_header");
}
// Verify the Sec-WebSocket-Accept response.
if ($result["headers"]["Sec-Websocket-Accept"][0] !== base64_encode(sha1($key . self::KEY_GUID, true))) {
return array("success" => false, "error" => HTTP::HTTPTranslate("The server's 'Sec-WebSocket-Accept' header is invalid."), "errorcode" => "invalid_server_websocket_accept_header");
}
$this->fp = $result["fp"];
}
// Enable non-blocking mode.
stream_set_blocking($this->fp, 0);
$this->state = self::STATE_OPEN;
$this->readdata = "";
$this->readmessages = array();
$this->writedata = "";
$this->writemessages = array();
$this->lastkeepalive = time();
$this->keepalivesent = false;
return array("success" => true);
}
示例3: var_dump
echo "Starting server...\n";
$result = $wsserver->Start("127.0.0.1", "5578");
if (!$result["success"]) {
var_dump($result);
exit;
}
echo "Ready.\n";
$tracker = array();
do {
$result = $wsserver->Wait();
// Do something with active clients.
foreach ($result["clients"] as $id => $client) {
if (!isset($tracker[$id])) {
echo "Client ID " . $id . " connected.\n";
// Example of checking for an API key.
$url = HTTP::ExtractURL($client["url"]);
if (!isset($url["queryvars"]["apikey"]) || $url["queryvars"]["apikey"][0] !== "123456789101112") {
$wsserver->RemoveClient($id);
} else {
echo "Valid API key used.\n";
}
$tracker[$id] = array();
}
// This example processes the client input (add/multiply two numbers together) and sends back the result.
$ws = $client["websocket"];
$result2 = $ws->Read();
while ($result2["success"] && $result2["data"] !== false) {
$data = json_decode($result2["data"]["payload"], true);
$question = $data["pre"] . " " . $data["op"] . " " . $data["post"];
if ($data["op"] === "+") {
$answer = $data["pre"] + $data["post"];
示例4: Config
public function Config()
{
global $sso_site_admin, $sso_settings, $sso_menuopts, $sso_select_fields;
if ($sso_site_admin && $sso_settings["sso_ldap"]["enabled"] && $_REQUEST["action2"] == "config") {
if (isset($_REQUEST["configsave"])) {
$_REQUEST["server"] = trim($_REQUEST["server"]);
$_REQUEST["dn"] = trim($_REQUEST["dn"]);
if ($_REQUEST["server"] == "") {
BB_SetPageMessage("info", "The 'LDAP Server URL' field is empty.");
} else {
if ($_REQUEST["dn"] == "") {
BB_SetPageMessage("info", "The 'LDAP Distinguished Name' field is empty.");
} else {
if (!function_exists("ldap_connect")) {
BB_SetPageMessage("info", "The ldap_connect() function does not exist. LDAP won't work until the LDAP PHP extension is enabled.");
}
}
}
require_once SSO_ROOT_PATH . "/" . SSO_SUPPORT_PATH . "/http.php";
$url = HTTP::ExtractURL($_REQUEST["server"]);
if ($url["scheme"] != "ldap") {
BB_SetPageMessage("error", "The 'LDAP Server URL' field has an invalid scheme.");
} else {
if ($url["host"] == "") {
BB_SetPageMessage("error", "The 'LDAP Server URL' field has an invalid host.");
}
}
$sso_settings["sso_ldap"]["iprestrict"] = SSO_ProcessIPFields();
if (BB_GetPageMessageType() != "error") {
$sso_settings["sso_ldap"]["server"] = $_REQUEST["server"];
$sso_settings["sso_ldap"]["dn"] = $_REQUEST["dn"];
$sso_settings["sso_ldap"]["map_username"] = SSO_IsField($_REQUEST["map_username"]) ? $_REQUEST["map_username"] : "";
$sso_settings["sso_ldap"]["remove_domain"] = $_REQUEST["remove_domain"] > 0;
$sso_settings["sso_ldap"]["map_custom"] = trim($_REQUEST["map_custom"]);
$sso_settings["sso_ldap"]["password"] = $_REQUEST["password"] > 0;
$sso_settings["sso_ldap"]["debug"] = $_REQUEST["debug"] > 0;
if (!SSO_SaveSettings()) {
BB_SetPageMessage("error", "Unable to save settings.");
} else {
if (BB_GetPageMessageType() == "info") {
SSO_ConfigRedirect("config", array(), "info", $_REQUEST["bb_msg"] . " " . BB_Translate("Successfully updated the %s provider configuration.", $this->DisplayName()));
} else {
SSO_ConfigRedirect("config", array(), "success", BB_Translate("Successfully updated the %s provider configuration.", $this->DisplayName()));
}
}
}
}
$contentopts = array("desc" => BB_Translate("Configure the %s provider. This provider is intended to be used behind a firewall in a relatively trusted environment. Use the IP whitelist to control access to this provider.", $this->DisplayName()), "nonce" => "action", "hidden" => array("action" => "config", "provider" => "sso_ldap", "action2" => "config", "configsave" => "1"), "fields" => array(array("title" => "LDAP Server URL", "type" => "text", "name" => "server", "value" => BB_GetValue("server", $sso_settings["sso_ldap"]["server"]), "desc" => "The LDAP URL to a LDAP server. Should be in the format 'ldap://server[:port]/'. Default port is 389."), array("title" => "LDAP Distinguished Name", "type" => "text", "name" => "dn", "value" => BB_GetValue("dn", $sso_settings["sso_ldap"]["dn"]), "desc" => "The LDAP Distinguished Name (DN) pattern to use to check logins against and load user information. Should be in the format 'CN=@USERNAME@,OU=users,DC=somewhere,DC=com' or similar. The special string @USERNAME@ will be replaced with the username."), array("title" => "Map Username", "type" => "select", "name" => "map_username", "options" => $sso_select_fields, "select" => BB_GetValue("map_username", (string) $sso_settings["sso_ldap"]["map_username"]), "desc" => "The field in the SSO system to map the username to. Overrides any custom mapping."), array("title" => "Remove Domain", "type" => "select", "name" => "remove_domain", "options" => array(1 => "Yes", 0 => "No"), "select" => BB_GetValue("remove_domain", (string) (int) $sso_settings["sso_ldap"]["remove_domain"]), "desc" => "Remove domain prefix from the above mapped username. (e.g. 'NT\\username' becomes 'username')"), array("title" => "Custom Mapping", "type" => "textarea", "name" => "map_custom", "value" => BB_GetValue("map_custom", $sso_settings["sso_ldap"]["map_custom"]), "desc" => "The fields in the SSO system to map LDAP fields to. Format is 'ldapfield=ssofield'. One mapping per line. See 'Debugging Mode' below to turn on debugging to discover valid LDAP field names. See the 'Map Username' dropdown above for valid SSO field names."), array("title" => "Require Password", "type" => "select", "name" => "password", "options" => array(1 => "Yes", 0 => "No"), "select" => BB_GetValue("password", (string) (int) $sso_settings["sso_ldap"]["password"]), "desc" => "Require passwords to not be empty strings."), array("title" => "Debugging Mode", "type" => "select", "name" => "debug", "options" => array(1 => "Yes", 0 => "No"), "select" => BB_GetValue("debug", (string) (int) $sso_settings["sso_ldap"]["debug"]), "desc" => "Turn on debugging mode to get an idea of what LDAP fields are available for your LDAP server. When enabled and a login is successful, this will output the fields and data of the user, then output successfully mapped LDAP to SSO fields, and then exit.")), "submit" => "Save", "focus" => true);
SSO_AppendIPFields($contentopts, $sso_settings["sso_ldap"]["iprestrict"]);
BB_GeneratePage(BB_Translate("Configure %s", $this->DisplayName()), $sso_menuopts, $contentopts);
} else {
if ($sso_site_admin && $sso_settings["sso_ldap"]["enabled"] && $_REQUEST["action2"] == "disable") {
$sso_settings["sso_ldap"]["enabled"] = false;
if (!SSO_SaveSettings()) {
BB_RedirectPage("error", "Unable to save settings.");
} else {
BB_RedirectPage("success", BB_Translate("Successfully disabled the %s provider.", $this->DisplayName()));
}
} else {
if ($sso_site_admin && !$sso_settings["sso_ldap"]["enabled"] && $_REQUEST["action2"] == "enable") {
if (!function_exists("ldap_connect")) {
BB_RedirectPage("error", "The ldap_connect() function does not exist. LDAP won't work until the LDAP PHP extension is enabled.");
}
$sso_settings["sso_ldap"]["enabled"] = true;
if (!SSO_SaveSettings()) {
BB_RedirectPage("error", "Unable to save settings.");
} else {
BB_RedirectPage("success", BB_Translate("Successfully enabled the %s provider.", $this->DisplayName()));
}
}
}
}
}
示例5: GenerateFormRequest
public function GenerateFormRequest($submitname = false, $submitvalue = false)
{
$method = $this->info["method"];
$fields = array();
$files = array();
foreach ($this->fields as $field) {
if ($field["type"] == "input.file") {
if (is_array($field["value"])) {
$field["value"]["name"] = $field["name"];
$files[] = $field["value"];
$method = "post";
}
} else {
if ($field["type"] == "input.reset" || $field["type"] == "button.reset") {
} else {
if ($field["type"] == "input.submit" || $field["type"] == "button.submit") {
if (($submitname === false || $field["name"] === $submitname) && ($submitvalue === false || $field["value"] === $submitvalue)) {
if (!isset($fields[$field["name"]])) {
$fields[$field["name"]] = array();
}
$fields[$field["name"]][] = $field["value"];
}
} else {
if ($field["type"] != "input.radio" && $field["type"] != "input.checkbox" || $field["checked"]) {
if (!isset($fields[$field["name"]])) {
$fields[$field["name"]] = array();
}
$fields[$field["name"]][] = $field["value"];
}
}
}
}
}
if ($method == "get") {
$url = HTTP::ExtractURL($this->info["action"]);
unset($url["query"]);
$url["queryvars"] = $fields;
$result = array("url" => HTTP::CondenseURL($url), "options" => array());
} else {
$result = array("url" => $this->info["action"], "options" => array("postvars" => $fields, "files" => $files));
}
return $result;
}
示例6: SignupUpdateCheck
private function SignupUpdateCheck(&$result, $update, $userrow)
{
global $sso_target_url, $sso_session_info;
// Generate the QR code.
$info = $this->GetInfo();
if ($info["generate_qr_codes"]) {
if (isset($_REQUEST["sso_google_authenticator_qr_u"]) && isset($_REQUEST["sso_google_authenticator_qr_h"]) && isset($_REQUEST["sso_google_authenticator_qr_k"])) {
require_once SSO_ROOT_PATH . "/" . SSO_SUPPORT_PATH . "/phpqrcode.php";
$url = "otpauth://totp/" . urlencode($_REQUEST["sso_google_authenticator_qr_u"]) . "@" . urlencode($_REQUEST["sso_google_authenticator_qr_h"]) . "?secret=" . $_REQUEST["sso_google_authenticator_qr_k"];
QRcode::png($url, false, QR_ECLEVEL_Q, 4);
} else {
if ($update) {
$username = SSO_FrontendFieldValue("update_username", $userrow !== false ? $userrow->username : "");
} else {
$username = SSO_FrontendFieldValue("username", "");
}
if ($username == "") {
if ($update) {
$email = SSO_FrontendFieldValue("update_email", $userrow !== false ? $userrow->email : "");
} else {
$email = SSO_FrontendFieldValue("email", "");
}
if ($email != "") {
$pos = strpos($email, "@");
if ($pos !== false) {
$username = substr($email, 0, $pos);
}
}
}
require_once SSO_ROOT_PATH . "/" . SSO_SUPPORT_PATH . "/http.php";
$host = BB_GetRequestHost();
$result2 = HTTP::ExtractURL($host);
$host = $result2["host"];
$key = isset($sso_session_info["sso_login_two_factor_key"]) ? $sso_session_info["sso_login_two_factor_key"] : "";
if ($username != "" && $host != "" && $key != "") {
$url = $sso_target_url . "&sso_login_action=" . ($update ? "update_info&sso_v=" . urlencode($_REQUEST["sso_v"]) : "signup_check") . "&sso_ajax=1&sso_google_authenticator_qr_u=" . urlencode($username) . "&sso_google_authenticator_qr_h=" . urlencode($host) . "&sso_google_authenticator_qr_k=" . urlencode($key);
?>
<script type="text/javascript">
jQuery('.sso_google_authenticator_qrcode').html('<div class="sso_main_formitem"><div class="sso_main_formtitle"><?php
echo htmlspecialchars(BB_Translate("Google Authenticator QR Code"));
?>
</div><div class="sso_main_formdata"><div class="sso_main_static"><img src="<?php
echo htmlspecialchars($url);
?>
" alt="<?php
echo htmlspecialchars(BB_Translate("Google Authenticator QR Code"));
?>
" /></div></div>');
</script>
<?php
} else {
if (SSO_FrontendFieldValue($update ? "update_username" : "username") !== false || SSO_FrontendFieldValue($update ? "update_email" : "email") !== false) {
?>
<script type="text/javascript">
jQuery('.sso_google_authenticator_qrcode').html('');
</script>
<?php
}
}
}
}
}