Exemplo n.º 1
0
 /**
  * Returns action response XML
  *
  * @param string $action
  * @return CDataXML
  * @throws CBitrixCloudException
  */
 protected function action($action)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     $url = $this->getActionURL(array("action" => $action, "debug" => $this->debug ? "y" : "n"));
     $server = new CHTTP();
     $strXML = $server->Get($url);
     if ($strXML === false) {
         $e = $APPLICATION->GetException();
         if (is_object($e)) {
             throw new CBitrixCloudException($e->GetString(), "");
         } else {
             throw new CBitrixCloudException(GetMessage("BCL_CDN_WS_SERVER", array("#STATUS#" => "-1")), "");
         }
     }
     if ($server->status != 200) {
         throw new CBitrixCloudException(GetMessage("BCL_CDN_WS_SERVER", array("#STATUS#" => (string) $server->status)), "");
     }
     $obXML = new CDataXML();
     if (!$obXML->LoadString($strXML)) {
         throw new CBitrixCloudException(GetMessage("BCL_CDN_WS_XML_PARSE", array("#CODE#" => "1")), "");
     }
     $node = $obXML->SelectNodes("/error/code");
     if (is_object($node)) {
         $error_code = $node->textContent();
         $message_id = "BCL_CDN_WS_" . $error_code;
         /*
         GetMessage("BCL_CDN_WS_LICENSE_EXPIRE");
         GetMessage("BCL_CDN_WS_LICENSE_NOT_FOUND");
         GetMessage("BCL_CDN_WS_QUOTA_EXCEEDED");
         GetMessage("BCL_CDN_WS_CMS_LICENSE_NOT_FOUND");
         GetMessage("BCL_CDN_WS_DOMAIN_NOT_REACHABLE");
         GetMessage("BCL_CDN_WS_LICENSE_DEMO");
         GetMessage("BCL_CDN_WS_LICENSE_NOT_ACTIVE");
         GetMessage("BCL_CDN_WS_NOT_POWERED_BY_BITRIX_CMS");
         GetMessage("BCL_CDN_WS_WRONG_DOMAIN_SPECIFIED");
         */
         $debug_content = "";
         $node = $obXML->SelectNodes("/error/debug");
         if (is_object($node)) {
             $debug_content = $node->textContent();
         }
         //if (HasMessage($message_id))
         //    throw new CBitrixCloudException(GetMessage($message_id), $error_code, $debug_content);
         //else
         //    throw new CBitrixCloudException(GetMessage("BCL_CDN_WS_SERVER", array(
         //        "#STATUS#" => $error_code,
         //    )), $error_code, $debug_content);
     }
     return $obXML;
 }
Exemplo n.º 2
0
 function MultySend($arNumbers, $message)
 {
     if (!empty($arNumbers)) {
         if (!defined("BX_UTF")) {
             $message = iconv("windows-1251", "utf-8", $message);
         }
         $res = new CHTTP();
         $token = $res->Get("http://sms.ru/auth/get_token");
         $arrep = array(" ", ",", "(", ")", "-");
         foreach ($arNumbers as $k => $v) {
             $arNumbers[$k] = str_replace($arrep, "", $v);
         }
         $arr = array("login" => COption::GetOptionString("echogroup.smsru", "LOGIN"), "sha512" => hash("sha512", COption::GetOptionString("echogroup.smsru", "PASSWORD") . $token . COption::GetOptionString("echogroup.smsru", "API_KEY")), "token" => $token, "to" => implode($arNumbers, $number), "text" => $message);
         $html = $res->Post("http://sms.ru/sms/send", $arr);
         return $html;
     }
 }
Exemplo n.º 3
0
 /**
  * Returns action response XML
  *
  * @param string $action
  * @return CDataXML
  *
  */
 protected function action($action)
 {
     global $APPLICATION;
     $url = $this->getActionURL(array("action" => $action));
     $server = new CHTTP();
     $strXML = $server->Get($url);
     if ($strXML === false) {
         $e = $APPLICATION->GetException();
         if (is_object($e)) {
             throw new CBitrixCloudException($e->GetString(), "");
         } else {
             throw new CBitrixCloudException(GetMessage("BCL_CDN_WS_SERVER", array("#STATUS#" => "-1")), "");
         }
     }
     if ($server->status != 200) {
         throw new CBitrixCloudException(GetMessage("BCL_CDN_WS_SERVER", array("#STATUS#" => (string) $server->status)), "");
     }
     $obXML = new CDataXML();
     if (!$obXML->LoadString($strXML)) {
         throw new CBitrixCloudException(GetMessage("BCL_CDN_WS_XML_PARSE", array("#CODE#" => "1")), "");
     }
     $node = $obXML->SelectNodes("/error/code");
     if (is_object($node)) {
         $error_code = $node->textContent();
         $message_id = "BCL_CDN_WS_" . $error_code;
         /*
         GetMessage("BCL_CDN_WS_LICENSE_EXPIRE");
         GetMessage("BCL_CDN_WS_LICENSE_NOT_FOUND");
         GetMessage("BCL_CDN_WS_QUOTA_EXCEEDED");
         */
         if (HasMessage($message_id)) {
             throw new CBitrixCloudException(GetMessage($message_id), $error_code);
         } else {
             throw new CBitrixCloudException(GetMessage("BCL_CDN_WS_SERVER", array("#STATUS#" => $error_code)), $error_code);
         }
     }
     return $obXML;
 }
Exemplo n.º 4
0
	public static function sGet($url, $follow_redirect = false) //static get
	{
		$ob = new CHTTP();
		$ob->setFollowRedirect($follow_redirect);
		return $ob->Get($url);
	}
Exemplo n.º 5
0
 /**
  * Parses the passed content to find css, js and images. Returns the array of files.
  *
  * @param $content
  *
  * @return array
  */
 public function getFilesFromContent($content)
 {
     $files = array();
     $arFilesByType = array();
     $arExtensions = array("js", "css");
     $extension_regex = "(?:" . implode("|", $arExtensions) . ")";
     $regex = "/\n\t\t\t\t((?i:\n\t\t\t\t\thref=\n\t\t\t\t\t|src=\n\t\t\t\t\t|BX\\.loadCSS\\(\n\t\t\t\t\t|BX\\.loadScript\\(\n\t\t\t\t\t|jsUtils\\.loadJSFile\\(\n\t\t\t\t\t|background\\s*:\\s*url\\(\n\t\t\t\t))                                                   #attribute\n\t\t\t\t(\"|')                                               #open_quote\n\t\t\t\t([^?'\"]+\\.)                                        #href body\n\t\t\t\t(" . $extension_regex . ")                           #extentions\n\t\t\t\t(|\\?\\d+|\\?v=\\d+)                                 #params\n\t\t\t\t(\\2)                                                #close_quote\n\t\t\t/x";
     $match = array();
     preg_match_all($regex, $content, $match);
     $link = $match[3];
     $extension = $match[4];
     $params = $match[5];
     $linkCount = count($link);
     $fileData = array("FULL_FILE_LIST" => array(), "FILE_TIMESTAMPS" => array(), "CSS_FILE_IMAGES" => array());
     for ($i = 0; $i < $linkCount; $i++) {
         $fileData["FULL_FILE_LIST"][] = $files[] = $link[$i] . $extension[$i] . $params[$i];
         $fileData["FILE_TIMESTAMPS"][$link[$i] . $extension[$i]] = $params[$i];
         $arFilesByType[$extension[$i]][] = $link[$i] . $extension[$i];
     }
     $manifestCache = $this->readManifestCache($this->getCurrentManifestID());
     if (array_key_exists("css", $arFilesByType)) {
         $cssCount = count($arFilesByType["css"]);
         for ($j = 0; $j < $cssCount; $j++) {
             $cssFilePath = $arFilesByType["css"][$j];
             if ($manifestCache["FILE_DATA"]["FILE_TIMESTAMPS"][$cssFilePath] != $fileData["FILE_TIMESTAMPS"][$cssFilePath]) {
                 $fileContent = false;
                 $fileUrl = parse_url($cssFilePath);
                 $file = new \Freetrix\Main\IO\File(Application::getDocumentRoot() . $fileUrl['path']);
                 if ($file->isExists() && $file->isReadable()) {
                     $fileContent = $file->getContents();
                 } elseif ($fileUrl["scheme"]) {
                     $req = new \CHTTP();
                     $req->http_timeout = 20;
                     $fileContent = $req->Get($cssFilePath);
                 }
                 if ($fileContent != false) {
                     $regex = '#([;\\s:]*(?:url|@import)\\s*\\(\\s*)(\'|"|)(.+?)(\\2)\\s*\\)#si';
                     $cssFileRelative = new \Freetrix\Main\IO\File($cssFilePath);
                     $cssPath = $cssFileRelative->getDirectoryName();
                     preg_match_all($regex, $fileContent, $match);
                     $matchCount = count($match[3]);
                     for ($k = 0; $k < $matchCount; $k++) {
                         $file = self::replaceUrlCSS($match[3][$k], addslashes($cssPath));
                         if (!in_array($file, $files) && !strpos($file, ";base64")) {
                             $fileData["FULL_FILE_LIST"][] = $files[] = $file;
                             $fileData["CSS_FILE_IMAGES"][$cssFilePath][] = $file;
                         }
                     }
                 }
             } else {
                 $fileData["CSS_FILE_IMAGES"][$cssFilePath] = $manifestCache["FILE_DATA"]["CSS_FILE_IMAGES"][$cssFilePath];
                 if (is_array($manifestCache["FILE_DATA"]["CSS_FILE_IMAGES"][$cssFilePath])) {
                     $fileData["FULL_FILE_LIST"] = array_merge($fileData["FULL_FILE_LIST"], $manifestCache["FILE_DATA"]["CSS_FILE_IMAGES"][$cssFilePath]);
                 }
             }
         }
     }
     return $fileData;
 }
Exemplo n.º 6
0
 /** Static Get with the ability to add headers and set the http timeout
  * @static
  * @param $url
  * @param array $arHeader
  * @param int $httpTimeout
  * @return bool|string
  */
 public static function sGetHeader($url, $arHeader = array(), $httpTimeout = 0)
 {
     $httpTimeout = intval($httpTimeout);
     $ob = new CHTTP();
     if (!empty($arHeader)) {
         $ob->SetAdditionalHeaders($arHeader);
     }
     if ($httpTimeout > 0) {
         $ob->http_timeout = $httpTimeout;
     }
     return $ob->Get($url);
 }
Exemplo n.º 7
0
			{
				foreach($v as $kk => $vv)
					$getData .= urlencode($k."[".$kk."]").'='.urlencode($vv)."&";
			}
			else
				$getData .= urlencode($k).'='.urlencode($v)."&";
		}
	}
	$getData = $APPLICATION->ConvertCharset($getData, SITE_CHARSET, "windows-1251");

	$sectionName = GetMessage("USM_ALL");
	if(strlen($_REQUEST["search_mp"]) > 0)
		$sectionName = GetMessage("USM_SEARCH");
	
	$arModules = Array();
	if($res = $ht->Get("http://marketplace.1c-bitrix.ru/".$url."?".$getData))
	{
		if(in_array($ht->status, Array("200")))
		{
			$res = $GLOBALS["APPLICATION"]->ConvertCharset($res, "windows-1251", SITE_CHARSET);
			require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/xml.php");
			$objXML = new CDataXML();
			$objXML->LoadString($res);
			$arResult = $objXML->GetArray();

			if(!empty($arResult) && is_array($arResult))
			{
				if(!empty($arResult["modules"]["#"]))
				{
					$arModules = $arResult["modules"]["#"]["items"][0]["#"]["item"];
					if(strlen($arResult["modules"]["#"]["categoryName"][0]["#"]) > 0)
Exemplo n.º 8
0
	if(method_exists($adminMenu, "IsSectionActive"))
	{
		if($adminMenu->IsSectionActive("menu_marketplace"))
		{
			$CACHE = 60*60*24;
			$obCache = new CPHPCache;
			$cache_id = "main_menu_marketplace_".LANGUAGE_ID;
			if($obCache->InitCache($CACHE, $cache_id, "/"))
			{
				$vars = $obCache->GetVars();
				$arMarket = $vars["arMarket"];
			}
			else
			{
				$ht = new CHTTP();
				if($res = $ht->Get("http://marketplace.1c-bitrix.ru/data_export.php"))
				{
					if(in_array($ht->status, Array("200")))
					{
						$res = $GLOBALS["APPLICATION"]->ConvertCharset($res, "windows-1251", SITE_CHARSET);
						require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/xml.php");

						$objXML = new CDataXML();
						$objXML->LoadString($res);
						$arResult = $objXML->GetArray();

						if(!empty($arResult) && is_array($arResult))
						{
							if(!empty($arResult["categories"]["#"]["category"]))
							{
								foreach($arResult["categories"]["#"]["category"] as $category)
Exemplo n.º 9
0
<?php

require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
$saleModulePermissions = $APPLICATION->GetGroupRight("sale");
if ($saleModulePermissions < "W") {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
IncludeModuleLangFile(__FILE__);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/include.php";
if (isset($_REQUEST["https_check"]) && $_REQUEST["https_check"] == "Y" && check_bitrix_sessid()) {
    $ob = new CHTTP();
    $ob->http_timeout = 10;
    $res = @$ob->Get("https://" . $_SERVER["SERVER_NAME"] . "/bitrix/tools/sale_ps_result.php");
    if (!$res || $ob->status != 200) {
        $res = "error";
        $text = GetMessage("SPS_HTTPS_CHECK_ERROR");
    } else {
        $res = "ok";
        $text = GetMessage("SPS_HTTPS_CHECK_SUCCESS");
    }
    header("Content-Type: application/x-javascript; charset=" . LANG_CHARSET);
    echo CUtil::PhpToJSObject(array("status" => $res, "text" => $text));
    die;
}
$lheStyle = '
<style type="text/css">
	.bxlhe_frame_hndl_dscr {
		-moz-border-bottom-colors: none;
		-moz-border-left-colors: none;
		-moz-border-right-colors: none;
		-moz-border-top-colors: none;
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
$saleModulePermissions = $APPLICATION->GetGroupRight("sale");
if ($saleModulePermissions < "W") {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
CModule::IncludeModule("sale");
$arYMSettings = array();
$bSaved = false;
if (isset($_POST["YANDEX_MARKET_ON"])) {
    CSaleYMHandler::setActivity(true);
} elseif (isset($_POST["YANDEX_MARKET_OFF"])) {
    CSaleYMHandler::setActivity(false);
}
if (isset($_REQUEST["https_check"]) && $_REQUEST["https_check"] == "Y" && check_bitrix_sessid()) {
    $ob = new CHTTP();
    $ob->http_timeout = 10;
    if (!@$ob->Get("https://" . $_SERVER["SERVER_NAME"] . $APPLICATION->GetCurPage())) {
        $res = "error";
        $text = GetMessage("SALE_YM_CHECK_HTTPS_ERROR");
    } else {
        $res = "ok";
        $text = GetMessage("SALE_YM_CHECK_HTTPS_SUCCESS");
    }
    header("Content-Type: application/x-javascript; charset=" . LANG_CHARSET);
    echo CUtil::PhpToJSObject(array("status" => $res, "text" => $text));
    die;
} else {
    if ($REQUEST_METHOD == "POST" && check_bitrix_sessid()) {
        if (isset($_POST["YMSETTINGS"]) && is_array($_POST["YMSETTINGS"]) && !empty($_POST["YMSETTINGS"])) {
            $arYMSettings = $_POST["YMSETTINGS"];
            CSaleYMHandler::saveSettings($arYMSettings);
            $bSaved = true;
Exemplo n.º 12
0
        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;
}