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"); } } } else { $arResult["RESULT"]['ERROR'] = $req->errstr;
$_REQUEST['server']=$_REQUEST['current_path']; if ($_REQUEST['server']) setcookie("DV_SERVER", $_REQUEST['server'],0); /*$_REQUEST['current_path']=trim($_REQUEST['current_path'],'/'); $_REQUEST['root']=trim($_REQUEST['root'],'/'); $_REQUEST['server']=trim($_REQUEST['server'],'/');*/ } 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)
public function LoadFile($listName, $arParams) { if ($arParams['URL']) { // hack! $URL = str_replace(array('%3A', '%2F'), array(':', '/'), rawurlencode($GLOBALS['APPLICATION']->ConvertCharset(urldecode($arParams['URL']), LANG_CHARSET, 'utf-8'))); $CLIENT = new CHTTP(); $res = false; if ($this->arConnectionParams['user']) { $CLIENT->SetAuthBasic($this->arConnectionParams['user'], $this->arConnectionParams['pass']); } if ($file_contents = $CLIENT->Get($URL)) { $point_pos = strrpos($URL, '.'); $ext = ''; $new_filename = md5($URL) . ($point_pos > 0 ? substr($URL, $point_pos) : ''); $new_filepath = $_SERVER['DOCUMENT_ROOT'] . $this->ATTACHMENTS_PATH . '/' . substr($new_filename, 0, 2) . '/' . $new_filename; CheckDirPath($new_filepath); $fp = fopen($new_filepath, 'wb'); fwrite($fp, $file_contents); fclose($fp); $res = CFile::MakeFileArray($new_filepath); } } unset($CLIENT); return $res; }
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; } } } } } $this->IncludeComponentTemplate('form_server_test'); break; } return;