本文整理汇总了PHP中CHTTP::ParseURL方法的典型用法代码示例。如果您正苦于以下问题:PHP CHTTP::ParseURL方法的具体用法?PHP CHTTP::ParseURL怎么用?PHP CHTTP::ParseURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHTTP
的用法示例。
在下文中一共展示了CHTTP::ParseURL方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findCorrectFile
function findCorrectFile($path, &$strWarn, $warning = false)
{
$arUrl = CHTTP::ParseURL($path);
if ($arUrl && is_array($arUrl)) {
if (isset($arUrl['host'], $arUrl['scheme'])) {
if (strpos($arUrl['host'], 'xn--') !== false) {
// Do nothing
} else {
$originalPath = $path;
$path = $arUrl['scheme'] . '://' . $arUrl['host'];
$arErrors = array();
if (defined("BX_UTF")) {
$punicodedPath = CBXPunycode::ToUnicode($path, $arErrors);
} else {
$punicodedPath = CBXPunycode::ToASCII($path, $arErrors);
}
if ($pathPunicoded == $path) {
return $originalPath;
} else {
$path = $punicodedPath;
}
if ($arUrl['port'] && ($arUrl['scheme'] != 'http' || $arUrl['port'] != 80) && ($arUrl['scheme'] != 'https' || $arUrl['port'] != 443)) {
$path .= ':' . $arUrl['port'];
}
$path .= $arUrl['path_query'];
}
} else {
$DOC_ROOT = $_SERVER["DOCUMENT_ROOT"];
$path = Rel2Abs("/", $path);
$path_ = $path;
$io = CBXVirtualIo::GetInstance();
if (!$io->FileExists($DOC_ROOT . $path)) {
if (CModule::IncludeModule('clouds')) {
$path = CCloudStorage::FindFileURIByURN($path, "component:player");
if ($path == "") {
if ($warning) {
$strWarn .= $warning . "<br />";
}
$path = $path_;
}
} else {
if ($warning) {
$strWarn .= $warning . "<br />";
}
$path = $path_;
}
} elseif (strpos($_SERVER['HTTP_HOST'], 'xn--') !== false) {
$path = CHTTP::URN2URI($path);
}
}
}
return $path;
}
示例2: CheckTrustProviders
function CheckTrustProviders($url)
{
if (count($this->_trust_providers) <= 0)
return true;
$arUrl = CHTTP::ParseURL($url);
foreach ($this->_trust_providers as $p)
if (strpos($arUrl['host'], $p) !== false)
return true;
return false;
}
示例3: createFile
public function createFile(array $fileData)
{
$accessToken = $this->getAccessToken();
$mimeType = $fileData['mimeType'];
$fileSrc = $fileData['src'];
$fileName = $fileData['name'];
CWebDavTools::convertToUtf8($fileName);
$fileSize = $fileData['size'] ? $fileData['size'] : filesize($fileSrc);
$content = file_get_contents($fileSrc);
$http = new CHTTP();
$http->http_timeout = 10;
$fileName = urlencode($fileName);
$arUrl = $http->ParseURL("https://apis.live.net/v5.0/me/skydrive/files/{$fileName}?access_token=" . urlencode($accessToken));
if (!$http->Query('PUT', $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $content, $arUrl['proto'], '')) {
return false;
}
$this->checkHttpResponse($http);
// error checking
if ($http->status != '200' && $http->status != '201') {
return false;
}
return json_decode($http->result, true);
}
示例4: Query
private function Query($command, $params = array())
{
if (strlen($command) <= 0 || !is_array($params)) {
return false;
}
$params['BX_COMMAND'] = $command;
$params['BX_LICENCE'] = $this->licenceCode;
$params['BX_DOMAIN'] = $this->domain;
$params['BX_TYPE'] = $this->type;
$params['BX_VERSION'] = $this->version;
$params["BX_HASH"] = $this->RequestSign($this->type, md5(implode("|", $params)));
$CHTTP = new CHTTP();
$arUrl = $CHTTP->ParseURL($this->controllerUrl);
if ($CHTTP->Query('POST', $arUrl['host'], $arUrl['port'], $arUrl['path_query'], CHTTP::PrepareData($params), $arUrl['proto'])) {
$result = json_decode($CHTTP->result);
if (!$result) {
CVoxImplantHistory::WriteToLog($CHTTP->result, 'ERROR QUERY EXECUTE');
}
} else {
$result = json_decode(json_encode(array('error' => array('code' => 'CONNECT_ERROR', 'msg' => 'Parse error or connect error from server'))));
}
return $result;
}
示例5: sendBatch
public function sendBatch($batch)
{
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/update_client.php";
$key = CUpdateClient::GetLicenseKey();
if (strlen($key) > 0 && strlen($batch) > 0) {
$request = new CHTTP();
$arPostData = array("Action" => "SendMessage", "MessageBody" => $batch);
$postdata = CHTTP::PrepareData($arPostData);
$arUrl = $request->ParseURL(self::$remoteProviderUrl . "?key=" . md5($key), false);
$request->Query('POST', $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $postdata, $arUrl['proto'], 'N', true);
return true;
}
return false;
}
示例6: SendCommand
private static function SendCommand($channelId, $message, $method = 'POST', $timeout = 5, $dont_wait_answer = true)
{
if (!is_array($channelId))
$channelId = Array($channelId);
$channelId = implode('/', array_unique($channelId));
if (strlen($channelId) <=0 || strlen($message) <= 0)
return false;
if (!in_array($method, Array('POST', 'GET')))
return false;
$nginx_error = COption::GetOptionString("pull", "nginx_error", "N");
if ($nginx_error != "N")
{
$nginx_error = unserialize($nginx_error);
if (intval($nginx_error['date'])+120 < time())
{
COption::SetOptionString("pull", "nginx_error", "N");
CAdminNotify::DeleteByTag("PULL_ERROR_SEND");
$nginx_error = "N";
}
else if ($nginx_error['count'] >= 10)
{
$ar = Array(
"MESSAGE" => GetMessage('PULL_ERROR_SEND'),
"TAG" => "PULL_ERROR_SEND",
"MODULE_ID" => "pull",
);
CAdminNotify::Add($ar);
return false;
}
}
$postdata = CHTTP::PrepareData($message);
$CHTTP = new CHTTP();
$CHTTP->http_timeout = intval($timeout);
$arUrl = $CHTTP->ParseURL(CPullOptions::GetPublishUrl($channelId), false);
if ($CHTTP->Query($method, $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $postdata, $arUrl['proto'], 'N', $dont_wait_answer))
{
$result = $dont_wait_answer? '{}': $CHTTP->result;
}
else
{
if ($nginx_error == "N")
{
$nginx_error = Array(
'count' => 1,
'date' => time(),
'date_increment' => time(),
);
}
else if (intval($nginx_error['date_increment'])+1 < time())
{
$nginx_error['count'] = intval($nginx_error['count'])+1;
$nginx_error['date_increment'] = time();
}
COption::SetOptionString("pull", "nginx_error", serialize($nginx_error));
$result = false;
}
return $result;
}
示例7: GetMessage
$arSoapParams[GetMessage("SOAP_ACTIVATION_CODE")] = $_REQUEST['ACTIVATION_CODE'];
$arSoapMethod = GetMessage("SOAP_ACTIVATION_METHOD");
break;
default:
ShowError(GetMessage("USER_AUTH_ERROR"));
return;
}
if (!$arResult["RESULT"]['ERROR']) {
$arSoapRequest = new CSOAPRequest($arSoapMethod, $arParams["PR_NAMESPACE"], $arSoapParams);
$request_body = $arSoapRequest->payload();
if (!$isUTF) {
$request_body = $APPLICATION->ConvertCharset($request_body, SITE_CHARSET, "UTF-8");
$arSoapMethod = $APPLICATION->ConvertCharset($arSoapMethod, SITE_CHARSET, "UTF-8");
}
$req = new CHTTP();
$arUrl = $req->ParseURL($arWebServiceUrl);
$arUrl["port"] = $arPort;
$req->SetAuthBasic($arLogin, $arPassword);
$req->user_agent = "BITRIX SOAP Client";
$req->http_timeout = $arTimeout;
$req->additional_headers['SOAPAction'] = $arParams["PR_NAMESPACE"] . $arSoapMethod;
$result = $req->Query("POST", $arUrl["host"], $arUrl["port"], $arUrl["path"], $request_body, $arUrl["proto"], "text/xml; charset=utf-8");
if (!$req->errstr) {
if ($req->status == 401) {
$arResult["RESULT"]['ERROR'] = GetMessage("AUTH_ERROR");
} else {
preg_match("/^<soap:Envelope.*>/i", $req->result, $preg);
if (empty($preg) || $req->status != "200") {
$arResult["RESULT"]['ERROR'] = GetMessage("WRONG_RESPONSE");
}
}
示例8: SendCommand
private static function SendCommand($channelId, $message, $options = array())
{
if (!is_array($channelId)) {
$channelId = array($channelId);
}
$channelId = implode('/', array_unique($channelId));
if (strlen($channelId) <= 0 || strlen($message) <= 0) {
return false;
}
$defaultOptions = array("method" => "POST", "timeout" => 5, "dont_wait_answer" => true);
$options = array_merge($defaultOptions, $options);
if (!in_array($options["method"], array('POST', 'GET'))) {
return false;
}
$nginx_error = COption::GetOptionString("pull", "nginx_error", "N");
if ($nginx_error != "N") {
$nginx_error = unserialize($nginx_error);
if (intval($nginx_error['date']) + 120 < time()) {
COption::SetOptionString("pull", "nginx_error", "N");
CAdminNotify::DeleteByTag("PULL_ERROR_SEND");
$nginx_error = "N";
} else {
if ($nginx_error['count'] >= 10) {
$ar = array("MESSAGE" => GetMessage('PULL_ERROR_SEND'), "TAG" => "PULL_ERROR_SEND", "MODULE_ID" => "pull");
CAdminNotify::Add($ar);
return false;
}
}
}
$postdata = CHTTP::PrepareData($message);
$CHTTP = new CHTTP();
$CHTTP->http_timeout = intval($options["timeout"]);
if (isset($options["expiry"])) {
$CHTTP->SetAdditionalHeaders(array("Message-Expiry" => intval($options["expiry"])));
}
$arUrl = $CHTTP->ParseURL(CPullOptions::GetPublishUrl($channelId), false);
try {
$sendResult = $CHTTP->Query($options["method"], $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $postdata, $arUrl['proto'], 'N', $options["dont_wait_answer"]);
} catch (Exception $e) {
$sendResult = false;
}
if ($sendResult) {
$result = $options["dont_wait_answer"] ? '{}' : $CHTTP->result;
} else {
if ($nginx_error == "N") {
$nginx_error = array('count' => 1, 'date' => time(), 'date_increment' => time());
} else {
if (intval($nginx_error['date_increment']) + 1 < time()) {
$nginx_error['count'] = intval($nginx_error['count']) + 1;
$nginx_error['date_increment'] = time();
}
}
COption::SetOptionString("pull", "nginx_error", serialize($nginx_error));
$result = false;
}
return $result;
}
示例9:
if (@$_REQUEST['mode']=='exchange')
{
$data=CUtil::JsObjectToPhp($_REQUEST['data']);
$req=new CHTTP;
$req->SetAuthBasic($data['login'],$data['pass']);
$URL=$data['url'];
if (!$data['phpsessid'])
$URL.='?mode=checkauth&type=catalog';
else
{
$URL.='?mode=import&type=catalog&filename='.$data['filename'];
$req->additional_headers['Cookie'] = 'PHPSESSID='.$data['phpsessid'].';';
}
$arUrl=$req->ParseURL($URL);
$req->Query('GET',$arUrl['host'],$arUrl['port'],$arUrl['path_query']);
$body=explode("\n",$req->result);
if (count($body)>1)
{
$response['status']=$body[0];
if ($response['status']=='success' && $body[1]=='PHPSESSID')
$response['phpsessid']=$body[2];
else
{
if (ToUpper($req->headers['Content-Type'])!=ToUpper('text/html; charset=utf-8'))
$body=$APPLICATION->ConvertCharsetArray($body,'windows-1251','UTF-8');
示例10: CHTTP
$arResult['LOG_EXISTS'] = CIntranetSharepoint::IsLog($arParams['IBLOCK_ID']);
}
}
$this->IncludeComponentTemplate('sync');
}
break;
case 'test':
if (!check_bitrix_sessid()) {
return;
}
$sp_server = $_REQUEST['sp_server'];
$sp_user = $_REQUEST['sp_user'];
$sp_pass = $_REQUEST['sp_pass'];
$arResult['SERVER'] = 0;
$arResult['AUTH'] = 0;
if ($sp_server && $sp_server != 'http://' && ($URL = CHTTP::ParseURL($sp_server))) {
if ($URL['host'] && $URL['scheme'] == 'http') {
$ob = new CHTTP();
$ob->setFollowRedirect(false);
if ($sp_user) {
$ob->SetAuthBasic($sp_user, $sp_pass);
}
if ($ob->Get($sp_server) !== false) {
if ($ob->status == 200 || $ob->status == 302 || $ob->status == 401) {
$arResult['SERVER'] = 1;
if ($ob->status != 401) {
$arResult['AUTH'] = 1;
}
}
}
}
示例11: createBlankFile
public function createBlankFile(array $fileData)
{
$accessToken = $this->getAccessToken();
$googleMimeType = $this->getInternalMimeTypeListByExtension(getFileExtension($fileData['name']));
$fileName = getFileNameWithoutExtension($fileData['name']);
CWebDavTools::convertToUtf8($fileName);
if (!$googleMimeType) {
return false;
}
$http = new CHTTP();
$http->http_timeout = 10;
$arUrl = $http->ParseURL('https://www.googleapis.com/drive/v2/files');
$http->SetAdditionalHeaders(array("Authorization" => "Bearer {$accessToken}"));
$postFields = "{\"title\":\"{$fileName}\",\"mimeType\":\"{$googleMimeType}\"}";
$postContentType = 'application/json; charset=UTF-8';
if (!$http->Query('POST', $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $postFields, $arUrl['proto'], $postContentType)) {
return false;
}
$this->checkHttpResponse($http);
// access token expired, let's get a new one and try again
if ($http->status == "401") {
//todo: invalid credential response
return false;
}
// error checking
if ($http->status != "200") {
return false;
}
$finalOutput = json_decode($http->result);
//last signed user must delete file from google drive
$this->insertPermission(array('link' => $finalOutput->alternateLink, 'id' => $finalOutput->id));
return array('link' => $finalOutput->alternateLink, 'id' => $finalOutput->id);
}