Beispiel #1
0
 function CSeoPageChecker($site, $url, $get = true, $check_errors = true)
 {
     global $APPLICATION;
     if (CModule::IncludeModule('search')) {
         $this->bSearch = true;
     } else {
         $APPLICATION->ThrowException(GetMessage('SEO_ERROR_NO_SEARCH'));
     }
     // don't return false or set bError!
     $this->__bCheckErrors = $check_errors;
     $this->__site = $site;
     $dbRes = CSite::GetByID($this->__site);
     if ($arRes = $dbRes->Fetch()) {
         $this->__lang = $arRes['LANGUAGE_ID'];
         $this->__server_name = $arRes['SERVER_NAME'];
         if (strlen($this->__server_name) <= 0) {
             $this->__server_name = COption::GetOptionString('main', 'server_name', '');
         }
         if (strlen($this->__server_name) > 0) {
             $this->__url = (CMain::IsHTTPS() ? "https://" : "http://") . CBXPunycode::ToASCII($this->__server_name, $e = null) . $url;
             return $get ? $this->GetHTTPData() : true;
         } else {
             $this->bError = true;
             $APPLICATION->ThrowException(str_replace('#SITE_ID#', $this->__site, GetMessage('SEO_ERROR_NO_SERVER_NAME')));
             return false;
         }
     }
     return false;
 }
 /**
  * Return current domain name (in puny code for cyrillic domain)
  *
  * @return string
  */
 public static function getCurrentHost()
 {
     $host = COption::GetOptionString("main", "server_name", $_SERVER["HTTP_HOST"]);
     if ($host == "") {
         $host = $_SERVER["HTTP_HOST"];
     }
     return CBXPunycode::ToASCII($host, $arErrors);
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
	public static function getDomainsList()
	{
		static $arDomains = null;

		if($arDomains === null)
		{
			$arDomains = array();

			$dbSites = Freetrix\Main\SiteDomainTable::getList(
				array(
					'select'=>array(
						'DOMAIN', 'LID',
						'SITE_NAME'=>'SITE.NAME', 'SITE_ACTIVE' => 'SITE.ACTIVE',
						'SITE_DIR' => 'SITE.DIR', 'SITE_DOC_ROOT' => 'SITE.DOC_ROOT'
					)
				)
			);

			$defaultDomain = CBXPunycode::ToASCII(Freetrix\Main\Config\Option::getRealValue('main', 'server_name'), $e = null);

			$bCurrentHostFound = false;
			while($arSite = $dbSites->fetch())
			{
				$arDomains[] = $arSite;
				if($arSite['DOMAIN'] == $defaultDomain)
					$bCurrentHostFound = true;
			}

			if(!$bCurrentHostFound)
			{
				$dbDefSite = Freetrix\Main\SiteTable::getList(array(
					'filter' => array('DEF' => 'Y'),
					'select' => array('LID', 'NAME', 'ACTIVE'),
				));
				$arDefSite = $dbDefSite->fetch();
				if($arDefSite)
				{
					array_unshift($arDomains, array(
						'DOMAIN' => $defaultDomain,
						'LID' => $arDefSite['LID'],
						'SITE_NAME' => $arDefSite['NAME'],
						'SITE_ACTIVE' => $arDefSite['ACTIVE'],
						'SITE_DIR' => $arDefSite['DIR'],
						'SITE_DOC_ROOT' => $arDefSite['DOC_ROOT'],
					));
				}
			}
		}

		return $arDomains;
	}
 /**
  * Returns URL to update policy
  *
  * @param array[string]string $arParams
  * @return string
  *
  */
 protected function getActionURL($arParams = array())
 {
     $arErrors = array();
     $domainTmp = CBXPunycode::ToASCII($this->domain, $arErrors);
     if (strlen($domainTmp) > 0) {
         $domain = $domainTmp;
     } else {
         $domain = $this->domain;
     }
     $arParams["license"] = md5(LICENSE_KEY);
     $arParams["domain"] = $domain;
     $url = COption::GetOptionString("bitrixcloud", "cdn_policy_url");
     $url = CHTTP::urlAddParams($url, $arParams, array("encode" => true));
     return $url;
 }
Beispiel #6
0
 function SaveDomains($LID, $domains)
 {
     global $DB, $CACHE_MANAGER;
     if (CACHED_b_lang_domain !== false) {
         $CACHE_MANAGER->CleanDir("b_lang_domain");
     }
     $DB->Query("DELETE FROM b_lang_domain WHERE LID='" . $DB->ForSQL($LID) . "'");
     $domains = str_replace("\r", "\n", $domains);
     $arDomains = explode("\n", $domains);
     for ($i = 0, $n = count($arDomains); $i < $n; $i++) {
         $arDomains[$i] = preg_replace("#^(http://|https://)#", "", trim(strtolower($arDomains[$i])));
     }
     $arDomains = array_unique($arDomains);
     $bIsDomain = false;
     foreach ($arDomains as $domain) {
         if ($domain != '') {
             $arErrors = array();
             if ($domainTmp = CBXPunycode::ToASCII($domain, $arErrors)) {
                 $domain = $domainTmp;
             }
             $DB->Query("INSERT INTO b_lang_domain(LID, DOMAIN) VALUES('" . $DB->ForSQL($LID, 2) . "', '" . $DB->ForSQL($domain, 255) . "')");
             $bIsDomain = true;
         }
     }
     $DB->Query("UPDATE b_lang SET DOMAIN_LIMITED='" . ($bIsDomain ? "Y" : "N") . "' WHERE LID='" . $DB->ForSql($LID) . "'");
 }
Beispiel #7
0
	function __construct($step = 0, $fix_mode = 0)
	{
		$this->step = intval($step);
		$this->test_percent = 0;
		$this->strError = '';
		$this->timeout = 10; // sec for one step
		$this->strResult = '';
		$this->fix_mode = intval($fix_mode);

		$this->host = $_REQUEST['HTTP_HOST'] ? $_REQUEST['HTTP_HOST'] : 'localhost';
		if (!$fix_mode) // no kernel
		{
			if (!preg_match('/^[a-z0-9\.\-]+$/i', $this->host))
				$this->host = CBXPunycode::ToASCII($this->host, ($err=""));
		}
		$this->ssl = $_REQUEST['HTTPS'] == 'on';
		$this->port = $_REQUEST['SERVER_PORT'] ? $_REQUEST['SERVER_PORT'] : ($this->ssl ? 443 : 80);

		$this->arTest = array(
			array('OpenLog' => GetMessage('SC_T_LOG')),
			/**/
			array('check_php_modules' =>GetMessage('SC_T_MODULES')),
			array('check_php_settings' =>GetMessage('SC_T_PHP')),
			array('check_server_vars' =>GetMessage('SC_T_SERVER')),
			array('check_suhosin' => GetMessage('SC_T_SUHOSIN')),
			array('check_security' => GetMessage('SC_T_APACHE')),
			array('check_install_scripts' => GetMessage('SC_T_INSTALL_SCRIPTS')),
			array('check_mbstring' =>GetMessage('SC_T_MBSTRING')),
			array('check_backtrack_limit' =>GetMessage('SC_T_BACKTRACK_LIMIT')),
			array('check_pcre_recursion' => GetMessage('SC_T_RECURSION')),
			array('check_method_exists' => GetMessage('SC_T_METHOD_EXISTS')),
			array('check_sites' =>GetMessage('SC_T_SITES')),
			array('check_socket' => GetMessage('SC_T_SOCK')),
			array('check_dbconn' => GetMessage('SC_T_DBCONN')),
			array('check_upload' => GetMessage('SC_T_UPLOAD')),
			array('check_upload_big' => GetMessage('SC_T_UPLOAD_BIG')),
			array('check_upload_raw' => GetMessage('SC_T_UPLOAD_RAW')),
			array('check_post' => GetMessage('SC_T_POST')),
			array('check_mail' => GetMessage('SC_T_MAIL')),
			array('check_mail_big' => GetMessage('SC_T_MAIL_BIG')),
			array('check_mail_b_event' => GetMessage('SC_T_MAIL_B_EVENT')),
			array('check_localredirect' => GetMessage('SC_T_REDIRECT')),
			array('check_memory_limit' => GetMessage('SC_T_MEMORY')),
			array('check_session' => GetMessage('SC_T_SESS')),
			array('check_session_ua' => GetMessage('SC_T_SESS_UA')),
			array('check_cache' => GetMessage('SC_T_CACHE')),
			array('check_update' => GetMessage('SC_UPDATE_ACCESS')),
			array('check_http_auth' => GetMessage('SC_T_AUTH')),
			array('check_exec' => GetMessage('SC_T_EXEC')),
			array('check_bx_crontab' => GetMessage('SC_T_BX_CRONTAB')),
			array('check_divider' => GetMessage('SC_T_DELIMITER')),
			array('check_precision' => GetMessage('SC_T_PRECISION')),
			array('check_clone' => GetMessage('SC_T_CLONE')),
			array('check_getimagesize' => GetMessage('SC_T_GETIMAGESIZE')),
			/**/
		);

		$this->arTestDB = array(
			array('check_mysql_bug_version' => GetMessage('SC_T_MYSQL_VER')),
			array('check_mysql_time' => GetMessage('SC_T_TIME')),
			array('check_mysql_mode' => GetMessage('SC_T_SQL_MODE')),
			array('check_mysql_increment' => GetMessage('SC_T_AUTOINC')),
//			array('check_mysql_table_status' => GetMessage('SC_T_CHECK')),
			array('check_mysql_connection_charset' => GetMessage('SC_CONNECTION_CHARSET')),
			array('check_mysql_db_charset' => GetMessage('SC_DB_CHARSET')),
			array('check_mysql_table_charset' => GetMessage('SC_T_CHARSET')),
			array('check_mysql_table_structure' => GetMessage('SC_T_STRUCTURE')),
		);

		if ($this->fix_mode == 1)
			$this->arTest = array(
				array('check_mysql_table_status' => GetMessage('SC_T_CHECK')),
			);
		elseif ($this->fix_mode == 2)
			$this->arTest = array(
				array('check_mysql_connection_charset' => GetMessage('SC_CONNECTION_CHARSET')),
				array('check_mysql_db_charset' => GetMessage('SC_DB_CHARSET')),
				array('check_mysql_table_charset' => GetMessage('SC_T_CHARSET')),
			);
		elseif ($this->fix_mode == 3)
			$this->arTest = array(
				array('check_mysql_table_structure' => GetMessage('SC_T_STRUCTURE')),
			);
		elseif (strtolower($GLOBALS['DB']->type) == 'mysql')
		{
			$this->arTest = array_merge($this->arTest, $this->arTestDB);
//			$this->arTest = array_merge(array(array('OpenLog'=>GetMessage('SC_T_LOG'))), $this->arTestDB);
		}

		list($this->function, $this->strCurrentTestName) = each($this->arTest[$this->step]);
		$this->strNextTestName = $this->strCurrentTestName;

		$LICENSE_KEY = '';
		if (file_exists($file = $_SERVER['DOCUMENT_ROOT'].'/bitrix'.'/license_key.php'))
			include($file);

		if ($LICENSE_KEY == '')
			$LICENSE_KEY = 'DEMO';
		$this->LogFile = '/bitrix'.'/site_checker_'.md5('SITE_CHECKER'.$LICENSE_KEY).'.log';
	}
Beispiel #8
0
 /**
  * Return current domain name (in puny code for cyrillic domain)
  * @return string
  */
 protected static function getCurrentHost()
 {
     $host = $_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : 'localhost';
     return CBXPunycode::ToASCII($host, $arErrors);
 }