Esempio n. 1
0
 function send($request)
 {
     $fullUrl = ($this->Port == 443 ? "https" : "http") . "://" . $this->Server . ":" . $this->Port . $this->Path;
     $uri = new \Bitrix\Main\Web\Uri($fullUrl);
     if ($uri->getHost() == '') {
         $this->ErrorString = '<b>Error:</b> CSOAPClient::send() : Wrong server parameters.';
         return 0;
     } else {
         $this->Server = $uri->getHost();
         $this->Port = $uri->getPort();
         $this->Path = $uri->getPathQuery();
     }
     if ($this->Timeout != 0) {
         $fp = fsockopen($this->Server, $this->Port, $this->errorNumber, $this->errorString, $this->Timeout);
     } else {
         $fp = fsockopen($this->Server, $this->Port, $this->errorNumber, $this->errorString);
     }
     if ($fp == 0) {
         $this->ErrorString = '<b>Error:</b> CSOAPClient::send() : Unable to open connection to ' . $this->Server . '.';
         return 0;
     }
     $payload = $request->payload();
     $authentification = "";
     if ($this->login() != "") {
         $authentification = "Authorization: Basic " . base64_encode($this->login() . ":" . $this->password()) . "\r\n";
     }
     $name = $request->name();
     $namespace = $request->get_namespace();
     if ($namespace[strlen($namespace) - 1] != "/") {
         $namespace .= "/";
     }
     $HTTPRequest = "POST " . $this->Path . " HTTP/1.0\r\n" . "User-Agent: BITRIX SOAP Client\r\n" . "Host: " . $this->Server . "\r\n" . $authentification . "Content-Type: text/xml; charset=utf-8\r\n" . "SOAPAction: \"" . $namespace . $request->name() . "\"\r\n" . "Content-Length: " . (defined('BX_UTF') && BX_UTF == 1 && function_exists('mb_strlen') ? mb_strlen($payload, 'latin1') : strlen($payload)) . "\r\n\r\n" . $payload;
     $this->SOAPRawRequest = $HTTPRequest;
     if (!fwrite($fp, $HTTPRequest)) {
         $this->ErrorString = "<b>Error:</b> could not send the SOAP request. Could not write to the socket.";
         $response = 0;
         return $response;
     }
     $rawResponse = "";
     // fetch the SOAP response
     while ($data = fread($fp, 32768)) {
         $rawResponse .= $data;
     }
     // close the socket
     fclose($fp);
     $this->SOAPRawResponse = $rawResponse;
     $response = new CSOAPResponse();
     $response->decodeStream($request, $rawResponse);
     return $response;
 }
Esempio n. 2
0
 protected function makeUrl()
 {
     /** @var \Bitrix\Main\UI\PageNavigation $nav */
     $nav = $this->arParams["~NAV_OBJECT"];
     if ($this->arParams["~BASE_LINK"] != '') {
         $uri = new \Bitrix\Main\Web\Uri($this->arParams["~BASE_LINK"]);
     } else {
         $uri = new \Bitrix\Main\Web\Uri($this->request->getRequestUri());
         $uri->deleteParams(\Bitrix\Main\HttpRequest::getSystemParameters());
         $nav->clearParams($uri, $this->arParams["SEF_MODE"]);
     }
     $this->arResult["URL"] = $uri->getUri();
     $this->arResult["URL_TEMPLATE"] = $nav->addParams($uri, $this->arParams["SEF_MODE"], "--page--", count($this->arResult["PAGE_SIZES"]) > 1 ? "--size--" : null)->getUri();
 }
Esempio n. 3
0
 /**
  * Returns script filename by URL
  *
  * @param string $site Site ID.
  * @param string $url URL.
  * @return string|null
  */
 public static function getRealPath($site, $url)
 {
     $docRoot = rtrim(\Bitrix\Main\SiteTable::getDocumentRoot($site), '/');
     $url = str_replace('\\', '/', $url);
     $url = \CHTTP::urnEncode($url);
     $uri = new \Bitrix\Main\Web\Uri($url);
     $path = \CHTTP::urnDecode($uri->getPath());
     if (substr($path, -1, 1) == '/') {
         $path .= 'index.php';
     }
     $file = new \Bitrix\Main\IO\File($docRoot . $path);
     if ($file->isExists()) {
         return substr($file->getPath(), strlen($docRoot));
     }
     if ($rewriteRules = AdminHelper::getRewriteRules($site)) {
         $pathQuery = \CHTTP::urnDecode($uri->getPathQuery());
         foreach ($rewriteRules as &$item) {
             if (preg_match($item['CONDITION'], $pathQuery)) {
                 $url = empty($item['PATH']) && !empty($item['RULE']) ? preg_replace($item['CONDITION'], $item['RULE'], $pathQuery) : $item['PATH'];
                 $url = \CHTTP::urnEncode($url);
                 $uri = new \Bitrix\Main\Web\Uri($url);
                 $path = \CHTTP::urnDecode($uri->getPath());
                 $file = new \Bitrix\Main\IO\File($docRoot . $path);
                 if ($file->isExists()) {
                     $pathTmp = str_replace('.', '', strtolower(ltrim($path, '/\\')));
                     $pathTmp7 = substr($pathTmp, 0, 7);
                     if ($pathTmp7 == 'upload/' || $pathTmp7 == 'bitrix/') {
                         continue;
                     }
                     if ($file->getExtension() != 'php') {
                         continue;
                     }
                     return substr($file->getPath(), strlen($docRoot));
                 }
             }
         }
     }
     return null;
 }
Esempio n. 4
0
	private static function onEpilogComposite()
	{
		global $USER, $APPLICATION;

		if (is_object($USER) && $USER->IsAuthorized())
		{
			if (self::isCurrentUserCC())
			{
				if ($APPLICATION->get_cookie("CC") !== "Y" || $APPLICATION->get_cookie("NCC") === "Y")
				{
					self::setCC();
				}
			}
			else
			{
				if ($APPLICATION->get_cookie("NCC") !== "Y" || $APPLICATION->get_cookie("CC") === "Y")
				{
					self::setNCC();
				}
			}
		}
		else
		{
			if ($APPLICATION->get_cookie("NCC") === "Y" || $APPLICATION->get_cookie("CC") === "Y")
			{
				self::deleteCompositeCookies();
			}
		}

		if (Main\Data\Cache::shouldClearCache())
		{
			$server = Main\Context::getCurrent()->getServer();

			$queryString = DeleteParam(array("clear_cache", "clear_cache_session"));
			$uri = new Bitrix\Main\Web\Uri($server->getRequestUri());
			$refinedUri = $queryString != "" ? $uri->getPath()."?".$queryString : $uri->getPath();

			$cachedFile = self::convertUriToPath($refinedUri, self::getHttpHost());

			$cacheStorage = Bitrix\Main\Data\StaticHtmlCache::getStaticHtmlStorage($cachedFile);
			if ($cacheStorage !== null)
			{
				$bytes = $cacheStorage->delete();
				if ($bytes !== false && $cacheStorage->shouldCountQuota())
				{
					self::updateQuota(-$bytes);
				}
			}
		}
	}
Esempio n. 5
0
 /**
  * Do click actions
  *
  * @param $recipientId
  * @param $url
  * @return void
  * @throws \Bitrix\Main\ArgumentException
  */
 public static function click($recipientId, $url)
 {
     $postingContactPrimary = array('ID' => $recipientId);
     $recipient = PostingRecipientTable::getRowById($postingContactPrimary);
     if ($recipient && $recipient['ID']) {
         $read = PostingReadTable::getRowById(array('POSTING_ID' => $recipient['POSTING_ID'], 'RECIPIENT_ID' => $recipient['ID']));
         if ($read === null) {
             static::read($recipientId);
         }
         $postingDb = PostingTable::getList(array('select' => array('ID'), 'filter' => array('ID' => $recipient['POSTING_ID'])));
         if ($postingDb->fetch()) {
             $uri = new \Bitrix\Main\Web\Uri($url);
             $fixedUrl = $uri->deleteParams(array('bx_sender_conversion_id'))->getLocator();
             $addClickDb = PostingClickTable::add(array('POSTING_ID' => $recipient['POSTING_ID'], 'RECIPIENT_ID' => $recipient['ID'], 'URL' => $fixedUrl));
             if ($addClickDb->isSuccess()) {
                 // send event
                 $eventData = array('URL' => $url, 'URL_FIXED' => $fixedUrl, 'CLICK_ID' => $addClickDb->getId(), 'RECIPIENT' => $recipient);
                 $event = new Event('sender', 'OnAfterRecipientClick', array($eventData));
                 $event->send();
             }
         }
     }
 }