예제 #1
0
	function Init($modules)
	{
		/** @noinspection PhpUnusedLocalVariableInspection */
		global $APPLICATION, $USER, $DB, $MESS;

		if($this->bInit)
			return;
		$this->bInit = true;

		$aOptMenu = CUserOptions::GetOption("admin_menu", "pos", array());
		$this->AddOpenedSections($aOptMenu["sections"]);
		
		$aModuleMenu = array();
		if(is_array($modules))
		{
			foreach($modules as $module)
			{
				$module = _normalizePath($module);

				//trying to include file menu.php in the /admin/ folder of the current module
				$fname = getLocalPath("modules/".$module."/admin/menu.php");
				if($fname !== false)
				{
					$menu = CAdminMenu::_IncludeMenu($_SERVER["DOCUMENT_ROOT"].$fname);
					if(is_array($menu) && !empty($menu))
					{
						if(isset($menu["parent_menu"]) && $menu["parent_menu"] <> "")
						{
							//one section
							$aModuleMenu[] = $menu;
						}
						else
						{
							//multiple sections
							foreach($menu as $submenu)
								$aModuleMenu[] = $submenu;
						}
					}
				}
			}
		}

		//additional user menu
		$aMenuLinks = array();
		if(file_exists($_SERVER["DOCUMENT_ROOT"].FX_ROOT."/admin/.left.menu.php"))
			include($_SERVER["DOCUMENT_ROOT"].FX_ROOT."/admin/.left.menu.php");
		if(!empty($aMenuLinks))
		{
			$bWasSeparator = false;
			$menu = array();
			foreach($aMenuLinks as $module_menu)
			{
				if($module_menu[3]["SEPARATOR"] == "Y")
				{
					//first level
					if(!empty($menu))
						$aModuleMenu[] = $menu;

					$menu = array(
						"parent_menu" => "global_menu_services",
						"icon" => "default_menu_icon",
						"page_icon" => "default_page_icon",
						"items_id"=>$module_menu[3]["SECTION_ID"],
						"items"=>array(),
						"sort"=>$module_menu[3]["SORT"],
						"text" => $module_menu[0],
					);
					$bWasSeparator = true;
				}
				elseif($bWasSeparator && $module_menu[3]["SECTION_ID"] == "")
				{
					//section items
					$menu["items"][] = array(
						"text" => $module_menu[0],
						"title"=>$module_menu[3]["ALT"],
						"url" => $module_menu[1],
						"more_url"=>$module_menu[2],
					);
				}
				elseif($module_menu[3]["SECTION_ID"] == "" || $module_menu[3]["SECTION_ID"] == "statistic" || $module_menu[3]["SECTION_ID"] == "sale")
				{
					//item in root
					$aModuleMenu[] = array(
						"parent_menu" => ($module_menu[3]["SECTION_ID"] == "statistic"? "global_menu_statistics" : ($module_menu[3]["SECTION_ID"] == "sale"? "global_menu_store":"global_menu_services")),
						"icon" => "default_menu_icon",
						"page_icon" => "default_page_icon",
						"sort"=>$module_menu[3]["SORT"],
						"text" => $module_menu[0],
						"title"=>$module_menu[3]["ALT"],
						"url" => $module_menu[1],
						"more_url"=>$module_menu[2],
					);
				}
				else
				{
					//item in section
					foreach($aModuleMenu as $i=>$section)
					{
						if($section["section"] == $module_menu[3]["SECTION_ID"])
						{
							if(!is_array($aModuleMenu[$i]["items"]))
								$aModuleMenu[$i]["items"] = array();

							$aModuleMenu[$i]["items"][] = array(
								"text" => $module_menu[0],
								"title"=>$module_menu[3]["ALT"],
								"url" => $module_menu[1],
								"more_url"=>$module_menu[2],
							);
							break;
						}
					}
				}
			}
			if(!empty($menu))
				$aModuleMenu[] = $menu;
		}

		$this->aGlobalMenu = array(
			"global_menu_content" => array(
				"menu_id" => "content",
				//"icon" => "button_content",
				"page_icon" => "content_title_icon",
				"index_icon" => "content_page_icon",
				"text" => GetMessage("admin_lib_menu_content"),
				"title" => GetMessage("admin_lib_menu_content_title"),
				"sort" => 100,
				"items_id" => "global_menu_content",
				"help_section" => "content",
				"items" => array()
			),
			"global_menu_services" => array(
				"menu_id" => "services",
				//"icon" => "button_services",
				"page_icon" => "services_title_icon",
				"index_icon" => "services_page_icon",
				"text" => GetMessage("admin_lib_menu_services"),
				"title" => GetMessage("admin_lib_menu_service_title"),
				"sort" => 200,
				"items_id" => "global_menu_services",
				"help_section" => "service",
				"items" => array()
			),
			"global_menu_store" => array(
				"menu_id" => "store",
				//"icon" => "button_store",
				"page_icon" => "store_title_icon",
				"index_icon" => "store_page_icon",
				"text" => GetMessage("admin_lib_menu_store"),
				"title" => GetMessage("admin_lib_menu_store_title"),
				"sort" => 300,
				"items_id" => "global_menu_store",
				"help_section" => "store",
				"items" => array()
			),
			"global_menu_statistics" => array(
				"menu_id" => "analytics",
				//"icon" => "button_statistics",
				"page_icon" => "statistics_title_icon",
				"index_icon" => "statistics_page_icon",
				"text" => GetMessage("admin_lib_menu_stat"),
				"title" => GetMessage("admin_lib_menu_stat_title"),
				"sort" => 400,
				"items_id" => "global_menu_statistics",
				"help_section" => "statistic",
				"items" => array()
			),
			
			"global_menu_settings" => array(
				"menu_id" => "settings",
				//"icon" => "button_settings",
				"page_icon" => "settings_title_icon",
				"index_icon" => "settings_page_icon",
				"text" => GetMessage("admin_lib_menu_settings"),
				"title" => GetMessage("admin_lib_menu_settings_title"),
				"sort" => 500,
				"items_id" => "global_menu_settings",
				"help_section" => "settings",
				"items" => array()
			),
		);

		//User defined global sections
		$bSort = false;
		foreach(GetModuleEvents("main", "OnBuildGlobalMenu", true) as $arEvent)
		{
			$bSort = true;
			$arRes = ExecuteModuleEventEx($arEvent, array(&$this->aGlobalMenu, &$aModuleMenu));
			if(is_array($arRes))
				$this->aGlobalMenu = array_merge($this->aGlobalMenu, $arRes);
		}
		if($bSort)
			uasort($this->aGlobalMenu, array($this, '_sort'));

		foreach($aModuleMenu as $menu)
			$this->aGlobalMenu[$menu["parent_menu"]]["items"][] = $menu;

		$sort_func = array($this, '_sort');
		
		foreach($this->aGlobalMenu as $key => $menu)
		{
			if(empty($menu["items"]) && $key != "global_menu_desktop")
			{
				unset($this->aGlobalMenu[$key]);
			}
			elseif(is_array($this->aGlobalMenu[$key]["items"]))
			{
				usort($this->aGlobalMenu[$key]["items"], $sort_func);
			}
		}

		foreach($this->aGlobalMenu as $key=>$menu)
			if($this->_SetActiveItems($this->aGlobalMenu[$key]))
				break;
	}
예제 #2
0
파일: zip.php 프로젝트: ASDAFF/entask.ru
 private function _extractFile(&$arEntry, $path, $removePath, $removeAllPath, &$arParams)
 {
     if (($res = $this->_readFileHeader($header)) != 1) {
         return $res;
     }
     //to be checked: file header should be coherent with $arEntry info
     $arEntry["filename"] = CharsetConverter::ConvertCharset($arEntry["filename"], "cp866", $this->fileSystemEncoding);
     $arEntry["stored_filename"] = CharsetConverter::ConvertCharset($arEntry["stored_filename"], "cp866", $this->fileSystemEncoding);
     //protecting against ../ etc in file path
     //only absolute path should be in the $arEntry
     $arEntry['filename'] = _normalizePath($arEntry['filename']);
     $arEntry['stored_filename'] = _normalizePath($arEntry['stored_filename']);
     if ($removeAllPath == true) {
         $arEntry['filename'] = basename($arEntry['filename']);
     } else {
         if ($removePath != "") {
             if ($this->_containsPath($removePath, $arEntry['filename']) == 2) {
                 //change file status
                 $arEntry['status'] = "filtered";
                 return $res;
             }
             $removePath_size = strlen($removePath);
             if (substr($arEntry['filename'], 0, $removePath_size) == $removePath) {
                 //remove path
                 $arEntry['filename'] = substr($arEntry['filename'], $removePath_size);
             }
         }
     }
     //making absolute path to the extracted file out of filename stored in the zip header and passed extracting path
     if ($path != '') {
         $arEntry['filename'] = $path . "/" . $arEntry['filename'];
     }
     //pre-extract callback
     if (isset($arParams['callback_pre_extract']) && $arParams['callback_pre_extract'] != '') {
         //generate local info
         $arLocalHeader = array();
         $this->_convertHeader2FileInfo($arEntry, $arLocalHeader);
         //callback call
         eval('$res = ' . $arParams['callback_pre_extract'] . '(\'callback_pre_extract\', $arLocalHeader);');
         //change file status
         if ($res == 0) {
             $arEntry['status'] = "skipped";
             $res = 1;
         }
         //update the info, only some fields can be modified
         $arEntry['filename'] = $arLocalHeader['filename'];
     }
     //check if extraction should be done
     if ($arEntry['status'] == 'ok') {
         $logicalFilename = $this->io->GetLogicalName($arEntry['filename']);
         if ((HasScriptExtension($arEntry['filename']) || IsFileUnsafe($arEntry['filename']) || !$this->io->ValidatePathString($logicalFilename) || !$this->io->ValidateFilenameString(GetFileName($logicalFilename))) && $this->checkBXPermissions == true) {
             $arEntry['status'] = "no_permissions";
         } else {
             //if the file exists, change status
             if (file_exists($arEntry['filename'])) {
                 if (is_dir($arEntry['filename'])) {
                     $arEntry['status'] = "already_a_directory";
                 } else {
                     if (!is_writeable($arEntry['filename'])) {
                         $arEntry['status'] = "write_protected";
                     } else {
                         if (filemtime($arEntry['filename']) > $arEntry['mtime'] && !$this->replaceExistentFiles) {
                             $arEntry['status'] = "newer_exist";
                         }
                     }
                 }
             } else {
                 //check the directory availability and create it if necessary
                 if (($arEntry['external'] & 0x10) == 0x10 || substr($arEntry['filename'], -1) == '/') {
                     $checkDir = $arEntry['filename'];
                 } else {
                     if (!strstr($arEntry['filename'], "/")) {
                         $checkDir = "";
                     } else {
                         $checkDir = dirname($arEntry['filename']);
                     }
                 }
                 if (($res = $this->_checkDir($checkDir, ($arEntry['external'] & 0x10) == 0x10)) != 1) {
                     //change file status
                     $arEntry['status'] = "path_creation_fail";
                     //return $res;
                     $res = 1;
                 }
             }
         }
     }
     //check if extraction should be done
     if ($arEntry['status'] == 'ok') {
         //if not a folder - extract
         if (!(($arEntry['external'] & 0x10) == 0x10)) {
             //if zip file with 0 compression
             if ($arEntry['compression'] == 0 && $arEntry['compressed_size'] == $arEntry['size']) {
                 if (($destFile = @fopen($arEntry['filename'], 'wb')) == 0) {
                     $arEntry['status'] = "write_error";
                     return $res;
                 }
                 //reading the fileby by self::ReadBlockSize octets blocks
                 $size = $arEntry['compressed_size'];
                 while ($size != 0) {
                     $length = $size < self::ReadBlockSize ? $size : self::ReadBlockSize;
                     $buffer = fread($this->zipfile, $length);
                     $binary_data = pack('a' . $length, $buffer);
                     @fwrite($destFile, $binary_data, $length);
                     $size -= $length;
                 }
                 //close the destination file
                 fclose($destFile);
                 //changing file modification time
                 touch($arEntry['filename'], $arEntry['mtime']);
             } else {
                 if (($destFile = @fopen($arEntry['filename'], 'wb')) == 0) {
                     //change file status
                     $arEntry['status'] = "write_error";
                     return $res;
                 }
                 //read the compressed file in a buffer (one shot)
                 $buffer = @fread($this->zipfile, $arEntry['compressed_size']);
                 //decompress the file
                 $fileContent = gzinflate($buffer);
                 unset($buffer);
                 //write uncompressed data
                 @fwrite($destFile, $fileContent, $arEntry['size']);
                 unset($fileContent);
                 @fclose($destFile);
                 touch($arEntry['filename'], $arEntry['mtime']);
             }
             if (isset($arParams['set_chmod']) && $arParams['set_chmod'] != 0) {
                 chmod($arEntry['filename'], $arParams['set_chmod']);
             }
         }
     }
     //post-extract callback
     if (isset($arParams['callback_post_extract']) && $arParams['callback_post_extract'] != '') {
         //make local info
         $arLocalHeader = array();
         $this->_convertHeader2FileInfo($arEntry, $arLocalHeader);
         //callback call
         eval('$res = ' . $arParams['callback_post_extract'] . '(\'callback_post_extract\', $arLocalHeader);');
     }
     return $res;
 }
예제 #3
0
 public static function GetById($id, $bWithParameters = false, $arAllCurrentValues = false)
 {
     $id = _normalizePath(strtolower($id));
     $folders = array("/bitrix/gadgets", "/local/gadgets");
     if (($p = strpos($id, "/")) > 0) {
         //specific namespace
         $arGdNS = array(substr($id, 0, $p));
         $id = substr($id, $p + 1);
     } else {
         // Find all namespaces of gadgets
         $arGdNS = array("bitrix");
         foreach ($folders as $folder) {
             $gdDir = $_SERVER["DOCUMENT_ROOT"] . $folder;
             if (is_dir($gdDir) && ($handle = opendir($gdDir))) {
                 while (false !== ($item = readdir($handle))) {
                     if (is_dir($gdDir . "/" . $item) && $item != "." && $item != ".." && $item != "bitrix") {
                         $arGdNS[] = $item;
                     }
                 }
                 closedir($handle);
             }
         }
     }
     // Find all gadgets
     $arGadget = false;
     foreach ($folders as $folder) {
         foreach ($arGdNS as $NS) {
             $gdDir = $_SERVER["DOCUMENT_ROOT"] . $folder . "/" . $NS;
             $gdDirSiteRoot = $folder . "/" . $NS;
             if (is_dir($gdDir . "/" . $id)) {
                 $arDescription = array();
                 CComponentUtil::__IncludeLang($gdDirSiteRoot . "/" . $id, "/.description.php");
                 if (!file_exists($gdDir . "/" . $id . "/.description.php")) {
                     continue;
                 }
                 if (!@(include $gdDir . "/" . $id . "/.description.php")) {
                     $arGadget = false;
                     continue;
                 }
                 if (isset($arDescription["LANG_ONLY"]) && $arDescription["LANG_ONLY"] != LANGUAGE_ID) {
                     $arGadget = false;
                     continue;
                 }
                 if ($bWithParameters) {
                     $arCurrentValues = array();
                     if (is_array($arAllCurrentValues)) {
                         foreach ($arAllCurrentValues as $k => $v) {
                             $pref = "G_" . strtoupper($id) . "_";
                             if (substr($k, 0, strlen($pref)) == $pref) {
                                 $arCurrentValues[substr($k, strlen($pref))] = $v;
                             } else {
                                 $pref = "GU_" . strtoupper($id) . "_";
                                 if (substr($k, 0, strlen($pref)) == $pref) {
                                     $arCurrentValues[substr($k, strlen($pref))] = $v;
                                 }
                             }
                         }
                     }
                     CComponentUtil::__IncludeLang($gdDirSiteRoot . "/" . $id, "/.parameters.php");
                     $arParameters = array();
                     if (file_exists($gdDir . "/" . $id . "/.parameters.php")) {
                         include $gdDir . "/" . $id . "/.parameters.php";
                     }
                     $arDescription["PARAMETERS"] = $arParameters["PARAMETERS"];
                     $arDescription["USER_PARAMETERS"] = array("TITLE_STD" => array("NAME" => GetMessage("CMDESKTOP_UP_TITLE_STD"), "TYPE" => "STRING", "DEFAULT" => ""));
                     if (array_key_exists("USER_PARAMETERS", $arParameters) && is_array($arParameters["USER_PARAMETERS"])) {
                         $arDescription["USER_PARAMETERS"] = array_merge($arDescription["USER_PARAMETERS"], $arParameters["USER_PARAMETERS"]);
                     }
                 }
                 $arDescription["PATH"] = $gdDir . "/" . $id;
                 $arDescription["PATH_SITEROOT"] = $gdDirSiteRoot . "/" . $id;
                 $arDescription["ID"] = strtoupper($id);
                 if ($arDescription["ICON"] && substr($arDescription["ICON"], 0, 1) != "/") {
                     $arDescription["ICON"] = "/bitrix/gadgets/" . $NS . "/" . $id . "/" . $arDescription["ICON"];
                 }
                 unset($arDescription["NOPARAMS"]);
                 $arGadget = $arDescription;
             }
         }
     }
     return $arGadget;
 }
예제 #4
0
파일: tools.php 프로젝트: nProfessor/Mytb
function Rel2Abs($curdir, $relpath)
{
	if($relpath == "")
		return false;

	$relpath = preg_replace("'[\\\/]+'", "/", $relpath);

	if($relpath[0] == "/" || preg_match("#^[a-z]:/#i", $relpath))
	{
		$res = $relpath;
	}
	else
	{
		$curdir = preg_replace("'[\\\/]+'", "/", $curdir);
		if($curdir[0] != "/" && !preg_match("#^[a-z]:/#i", $curdir))
			$curdir = "/".$curdir;
		if(substr($curdir, -1) != "/")
			$curdir .= "/";
		$res = $curdir.$relpath;
	}

	if(($p = strpos($res, "\0")) !== false)
		$res = substr($res, 0, $p);

	$res = _normalizePath($res);

	if(substr($res, 0, 1) !== "/" && !preg_match("#^[a-z]:/#i", $res))
		$res = "/".$res;

	$res = rtrim($res, ".\\+ ");

	return $res;
}
예제 #5
0
				$url = $val["PATH"];

			if(($pos=strpos($url, "?"))!==false)
			{
				$params = substr($url, $pos+1);
				parse_str($params, $vars);
				unset($vars["SEF_APPLICATION_CUR_PAGE_URL"]);

				$_GET += $vars;
				$_REQUEST += $vars;
				//$GLOBALS += $vars;
				$_SERVER["QUERY_STRING"] = $QUERY_STRING = $params;
				$url = substr($url, 0, $pos);
			}

			$url = _normalizePath($url);

			if(!$io->FileExists($_SERVER['DOCUMENT_ROOT'].$url))
				continue;

			if (!$io->ValidatePathString($url))
				continue;

			$urlTmp = strtolower(ltrim($url, "/\\"));
			$urlTmp = str_replace(".", "", $urlTmp);
			$urlTmp = substr($urlTmp, 0, 7);
			if (($urlTmp == "bitrix/") || ($urlTmp == "upload/"))
				continue;

			$ext = strtolower(GetFileExtension($url));
			if ($ext != "php")
예제 #6
0
function CheckFields()
{
    global $DB, $strError, $FILENAME, $APPLICATION, $ID, $BODY, $USER, $SITE_ID, $STATUS_ID, $DOC_ROOT;
    $str = "";
    $arMsg = array();
    $SCRIPT_FILE_TYPE = GetFileType($FILENAME);
    $FILENAME = trim($FILENAME);
    $FILENAME = "/" . ltrim(_normalizePath($FILENAME), "/");
    $io = CBXVirtualIo::GetInstance();
    if (strlen($FILENAME) <= 0) {
        $arMsg[] = array("id" => "FILENAME", "text" => GetMessage("FLOW_FORGOT_FILENAME"));
    } elseif (!$io->ValidatePathString($FILENAME)) {
        $arMsg[] = array("id" => "FILENAME", "text" => GetMessage("FLOW_FILE_NAME_NOT_VALID"));
    } elseif ($SCRIPT_FILE_TYPE != "SOURCE") {
        $arMsg[] = array("id" => "FILENAME", "text" => GetMessage("FLOW_INCORRECT_FILETYPE"));
    } else {
        $SITE_ID = CWorkflow::__CheckSite($SITE_ID);
        if (!$SITE_ID) {
            $SITE_ID = CSite::GetSiteByFullPath($_SERVER['DOCUMENT_ROOT'] . $FILENAME);
        }
        if (!$USER->CanDoFileOperation('fm_edit_in_workflow', array($SITE_ID, $FILENAME))) {
            $s = str_replace("#FILENAME#", "{$FILENAME}", GetMessage("FLOW_ACCESS_DENIED"));
            $arMsg[] = array("id" => "FILENAME", "text" => $s . ": " . GetMessage("FLOW_MIN_RIGHTS"));
        } elseif ($STATUS_ID == 1 && !($USER->CanDoFileOperation('fm_edit_existent_file', array($SITE_ID, $FILENAME)) && $USER->CanDoFileOperation('fm_create_new_file', array($SITE_ID, $FILENAME)))) {
            $arMsg[] = array("id" => "FILENAME", "text" => GetMessage("FLOW_ACCESS_DENIED_FOR_FILE_WRITE", array("#FILENAME#" => $FILENAME)));
        } else {
            $z = CWorkflow::GetByFilename($FILENAME, $SITE_ID);
            if ($zr = $z->Fetch()) {
                if ($zr["ID"] != $ID && $zr["STATUS_ID"] != 1) {
                    $arMsg[] = array("id" => "FILENAME", "text" => str_replace("#FILENAME#", $FILENAME, GetMessage("FLOW_FILENAME_EXIST")));
                }
            }
        }
    }
    if (!CWorkflow::IsAdmin()) {
        $arGroups = $USER->GetUserGroupArray();
        if (!is_array($arGroups)) {
            $arGroups = array(2);
        }
        $arFilter = array("GROUP_ID" => $arGroups, "PERMISSION_TYPE_1" => 1, "ID_EXACT_MATCH" => "Y", "ID" => $STATUS_ID);
        $rsStatuses = CWorkflowStatus::GetList($by = "s_c_sort", $strOrder, $arFilter, $is_filtered, array("ID"));
        if (!$rsStatuses->Fetch()) {
            $arMsg[] = array("id" => "STATUS_ID", "text" => GetMessage("FLOW_ERROR_WRONG_STATUS"));
        }
    }
    $bIsPhp = IsPHP($BODY);
    if ($bIsPhp) {
        if ($USER->CanDoFileOperation('fm_lpa', array($SITE_ID, $FILENAME)) && !$USER->CanDoOperation('edit_php')) {
            if (CModule::IncludeModule("fileman")) {
                $old_res = CFileman::ParseFileContent($APPLICATION->GetFileContent($DOC_ROOT . $FILENAME), true);
                $old_BODY = $old_res["CONTENT"];
                $BODY = CMain::ProcessLPA($BODY, $old_BODY);
            } else {
                $arMsg[] = array("id" => "BODY", "text" => "Error! Fileman is not included!");
            }
        } else {
            if (!$USER->CanDoOperation('edit_php')) {
                $arMsg[] = array("id" => "BODY", "text" => GetMessage("FLOW_PHP_IS_NOT_AVAILABLE"));
            }
        }
    }
    if (!empty($arMsg)) {
        $e = new CAdminException($arMsg);
        $GLOBALS["APPLICATION"]->ThrowException($e);
        return false;
    }
    return true;
}
예제 #7
0
 /**
  * @param string $componentName
  * @param string $templateName
  * @param string $siteTemplate
  * @param array $arCurrentValues Don't change the name! It's used in the .parameters.php file.
  * @return array
  */
 public static function GetTemplateProps($componentName, $templateName, $siteTemplate = "", $arCurrentValues = array())
 {
     $arTemplateParameters = array();
     $componentName = trim($componentName);
     if (strlen($componentName) <= 0) {
         return $arTemplateParameters;
     }
     if (strlen($templateName) <= 0) {
         $templateName = ".default";
     }
     if (!preg_match("#[A-Za-z0-9_.-]#i", $templateName)) {
         return $arTemplateParameters;
     }
     $path2Comp = CComponentEngine::MakeComponentPath($componentName);
     if (strlen($path2Comp) <= 0) {
         return $arTemplateParameters;
     }
     $componentPath = getLocalPath("components" . $path2Comp);
     if (!CComponentUtil::isComponent($componentPath)) {
         return $arTemplateParameters;
     }
     if ($siteTemplate != "") {
         $siteTemplate = _normalizePath($siteTemplate);
     }
     $folders = array();
     if ($siteTemplate != "") {
         $folders[] = "/local/templates/" . $siteTemplate . "/components" . $path2Comp . "/" . $templateName;
     }
     $folders[] = "/local/templates/.default/components" . $path2Comp . "/" . $templateName;
     $folders[] = "/local/components" . $path2Comp . "/templates/" . $templateName;
     if ($siteTemplate != "") {
         $folders[] = BX_PERSONAL_ROOT . "/templates/" . $siteTemplate . "/components" . $path2Comp . "/" . $templateName;
     }
     $folders[] = BX_PERSONAL_ROOT . "/templates/.default/components" . $path2Comp . "/" . $templateName;
     $folders[] = "/bitrix/components" . $path2Comp . "/templates/" . $templateName;
     foreach ($folders as $templateFolder) {
         if (file_exists($_SERVER["DOCUMENT_ROOT"] . $templateFolder)) {
             if (file_exists($_SERVER["DOCUMENT_ROOT"] . $templateFolder . "/.parameters.php")) {
                 CComponentUtil::__IncludeLang($templateFolder, ".parameters.php");
                 include $_SERVER["DOCUMENT_ROOT"] . $templateFolder . "/.parameters.php";
             }
             return $arTemplateParameters;
         }
     }
     return $arTemplateParameters;
 }
예제 #8
0
파일: option.php 프로젝트: ASDAFF/bitrix-5
	public static function SetOptionString($module_id, $name, $value="", $desc=false, $site="")
	{
		global $DB,$CACHE_MANAGER;
		if(CACHED_b_option!==false) $CACHE_MANAGER->Clean("b_option");

		if($site === false)
			$site = SITE_ID;

		$strSqlWhere = " SITE_ID".($site==""?" IS NULL":"='".$DB->ForSql($site, 2)."'")." ";

		$name = $DB->ForSql($name, 50);
		$res = $DB->Query(
			"SELECT 'x' ".
			"FROM b_option ".
			"WHERE ".$strSqlWhere.
			"	AND MODULE_ID='".$DB->ForSql($module_id)."' ".
			"	AND NAME='".$name."'"
			);

		if($res_array = $res->Fetch())
		{
			$DB->Query(
				"UPDATE b_option SET ".
				"	VALUE='".$DB->ForSql($value, 2000)."'".
				($desc!==false?", DESCRIPTION='".$DB->ForSql($desc, 255)."'":"")." ".
				"WHERE ".$strSqlWhere.
				"	AND MODULE_ID='".$DB->ForSql($module_id)."' ".
				"	AND NAME='".$name."'"
				);
		}
		else
		{
			$DB->Query(
				"INSERT INTO b_option(SITE_ID, MODULE_ID, NAME, VALUE, DESCRIPTION) ".
				"VALUES(".($site==""?"NULL":"'".$DB->ForSQL($site, 2)."'").", ".
				"'".$DB->ForSql($module_id, 50)."', '".$name."', ".
				"'".$DB->ForSql($value, 2000)."', '".$DB->ForSql($desc, 255)."') "
				);
		}

		if($site == "")
			$site = '-';

		global $MAIN_OPTIONS;
		$MAIN_OPTIONS[$site][$module_id][$name] = $value;

		$module_id = _normalizePath($module_id);
		$fname = $_SERVER['DOCUMENT_ROOT'].BX_ROOT.'/modules/'.$module_id.'/option_triggers.php';
		if(file_exists($fname))
			include_once($fname);

		$events = GetModuleEvents("main", "OnAfterSetOption_".$name);
		while ($arEvent = $events->Fetch())
			ExecuteModuleEventEx($arEvent, array($value));

		return true;
	}
예제 #9
0
 function GetTemplateProps($componentName, $templateName, $siteTemplate = "", $arCurrentValues = array())
 {
     $arTemplateParameters = array();
     $componentName = trim($componentName);
     if (strlen($componentName) <= 0) {
         return $arTemplateParameters;
     }
     if (strlen($templateName) <= 0) {
         $templateName = ".default";
     }
     if (!preg_match("#[A-Za-z0-9_.-]#i", $templateName)) {
         return $arTemplateParameters;
     }
     $path2Comp = CComponentEngine::MakeComponentPath($componentName);
     if (strlen($path2Comp) <= 0) {
         return $arTemplateParameters;
     }
     $componentPath = "/bitrix/components" . $path2Comp;
     if (!CComponentUtil::isComponent($componentPath)) {
         return $arTemplateParameters;
     }
     if ($siteTemplate && strlen($siteTemplate) > 0) {
         $siteTemplate = _normalizePath($siteTemplate);
         if (file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $siteTemplate . "/components" . $path2Comp . "/" . $templateName)) {
             if (is_dir($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $siteTemplate . "/components" . $path2Comp . "/" . $templateName) && file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $siteTemplate . "/components" . $path2Comp . "/" . $templateName . "/.parameters.php")) {
                 CComponentUtil::__IncludeLang(BX_PERSONAL_ROOT . "/templates/" . $siteTemplate . "/components" . $path2Comp . "/" . $templateName, ".parameters.php");
                 include $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $siteTemplate . "/components" . $path2Comp . "/" . $templateName . "/.parameters.php";
             }
             return $arTemplateParameters;
         }
     }
     if (file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/.default/components" . $path2Comp . "/" . $templateName)) {
         if (is_dir($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/.default/components" . $path2Comp . "/" . $templateName) && file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/.default/components" . $path2Comp . "/" . $templateName . "/.parameters.php")) {
             CComponentUtil::__IncludeLang(BX_PERSONAL_ROOT . "/templates/.default/components" . $path2Comp . "/" . $templateName, ".parameters.php");
             include $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/.default/components" . $path2Comp . "/" . $templateName . "/.parameters.php";
         }
         return $arTemplateParameters;
     }
     if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/bitrix/components" . $path2Comp . "/templates/" . $templateName)) {
         if (is_dir($_SERVER["DOCUMENT_ROOT"] . "/bitrix/components" . $path2Comp . "/templates/" . $templateName) && file_exists($_SERVER["DOCUMENT_ROOT"] . "/bitrix/components" . $path2Comp . "/templates/" . $templateName . "/.parameters.php")) {
             CComponentUtil::__IncludeLang("/bitrix/components" . $path2Comp . "/templates/" . $templateName, ".parameters.php");
             include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/components" . $path2Comp . "/templates/" . $templateName . "/.parameters.php";
         }
         return $arTemplateParameters;
     }
     return $arTemplateParameters;
 }
예제 #10
0
ClearVars();

$edit_php = $USER->CanDoOperation('edit_php');
if(!$edit_php && !$USER->CanDoOperation('view_other_settings') && !$USER->CanDoOperation('lpa_template_edit'))
	$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));

IncludeModuleLangFile(__FILE__);

$lpa = ($USER->CanDoOperation('lpa_template_edit') && !$edit_php); // Limit PHP access: for non admin users
$lpa_view = !$USER->CanDoOperation('edit_other_settings') && !$USER->CanDoOperation('lpa_template_edit'); //

$strError="";
$strOK="";
$bVarsFromForm = false;

$ID = _normalizePath($ID);

if($lpa && $_REQUEST['edit'] != "Y" && strlen($ID) <= 0) // In lpa mode users can only edit existent templates
	$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));

$bEdit = false;
if(strlen($ID)>0 && $_REQUEST['edit'] != "N")
{
	$templ = CSiteTemplate::GetByID($ID);
	if($x = $templ->ExtractFields("str_"))
		$bEdit=true;
}

$aTabs = array(
	array("DIV" => "edit1", "TAB" => GetMessage("MAIN_TAB1"), "ICON" => "template_edit", "TITLE" => GetMessage("MAIN_TAB1_TITLE")),
	array("DIV" => "edit2", "TAB" => GetMessage("MAIN_TAB2"), "ICON" => "template_edit", "TITLE" => GetMessage("MAIN_TAB2_TITLE")),
예제 #11
0
<?php

##############################################
# Bitrix Site Manager                        #
# Copyright (c) 2002-2007 Bitrix             #
# http://www.bitrixsoft.com                  #
# mailto:admin@bitrixsoft.com                #
##############################################
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
if (!$USER->CanDoOperation('edit_php')) {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
IncludeModuleLangFile(__FILE__);
$from = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/admin/restore.php";
$to = $_SERVER["DOCUMENT_ROOT"] . "/restore.php";
$path = _normalizePath($f_id);
if (check_bitrix_sessid() && copy($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/backup/" . $path, $_SERVER["DOCUMENT_ROOT"] . "/" . $path) && file_put_contents($to, str_replace("%DEFAULT_LANG_ID%", LANG, file_get_contents($from)))) {
    LocalRedirect("/restore.php?lang=" . LANG);
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
CAdminMessage::ShowMessage(array("MESSAGE" => GetMessage("MAIN_EXEC_RESTORE_MSG"), "DETAILS" => GetMessage("MAIN_EXEC_RESTORE_TEXT") . ' ' . htmlspecialcharsbx($path), "HTML" => true));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
예제 #12
0
ClearVars();

$edit_php = $USER->CanDoOperation('edit_php');
if(!$edit_php && !$USER->CanDoOperation('view_other_settings') && !$USER->CanDoOperation('lpa_template_edit'))
	$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));

IncludeModuleLangFile(__FILE__);

$lpa = ($USER->CanDoOperation('lpa_template_edit') && !$edit_php); // Limit PHP access: for non admin users
$lpa_view = !$USER->CanDoOperation('edit_other_settings') && !$USER->CanDoOperation('lpa_template_edit'); //

$strError="";
$strOK="";
$bVarsFromForm = false;

$ID = _normalizePath($_REQUEST["ID"]);

if($lpa && $_REQUEST['edit'] != "Y" && strlen($ID) <= 0) // In lpa mode users can only edit existent templates
	$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));

$bEdit = false;
$templFields = array();
if(strlen($ID)>0 && $_REQUEST['edit'] != "N")
{
	$templ = CSiteTemplate::GetByID($ID);
	if(($templFields = $templ->ExtractFields("str_")))
		$bEdit = true;
}

$aTabs = array(
	array("DIV" => "edit1", "TAB" => GetMessage("MAIN_TAB1"), "ICON" => "template_edit", "TITLE" => GetMessage("MAIN_TAB1_TITLE")),
예제 #13
0
파일: tools.php 프로젝트: gitkv/bash
function Rel2Abs($curdir, $relpath)
{
    if ($relpath == "") {
        return false;
    }
    if (substr($relpath, 0, 1) == "/" || preg_match("#^[a-z]:/#i", $relpath)) {
        $res = $relpath;
    } else {
        if (substr($curdir, 0, 1) != "/" && !preg_match("#^[a-z]:/#i", $curdir)) {
            $curdir = "/" . $curdir;
        }
        if (substr($curdir, -1) != "/") {
            $curdir .= "/";
        }
        $res = $curdir . $relpath;
    }
    if (($p = strpos($res, "")) !== false) {
        $res = substr($res, 0, $p);
    }
    $res = _normalizePath($res);
    if (substr($res, 0, 1) !== "/" && !preg_match("#^[a-z]:/#i", $res)) {
        $res = "/" . $res;
    }
    $res = rtrim($res, ".\\+ ");
    return $res;
}
예제 #14
0
 public static function GetTemplate($template, $arSiteTemplates = array())
 {
     global $APPLICATION;
     $arDirs = array("templates/.default/page_templates");
     foreach ($arSiteTemplates as $val) {
         $arDirs[] = "templates/" . $val . "/page_templates";
     }
     $template = _normalizePath($template);
     $sFile = false;
     foreach ($arDirs as $dir) {
         $path = getLocalPath($dir, BX_PERSONAL_ROOT);
         if ($path === false) {
             continue;
         }
         $template_dir = $_SERVER["DOCUMENT_ROOT"] . $path;
         $template_file = $template_dir . "/" . $template . "/template.php";
         if (!file_exists($template_file)) {
             continue;
         }
         if ($APPLICATION->GetFileAccessPermission($path . "/" . $template . "/template.php") < "R") {
             continue;
         }
         $sFile = $template_file;
     }
     if ($sFile !== false) {
         $pageTemplate = false;
         include_once $sFile;
         if (is_object($pageTemplate)) {
             return $pageTemplate;
         }
     }
     return false;
 }
예제 #15
0
jsDD.Reset();
//jsDD.registerContainer(BX.findParent(window.structPopup.GetContent(), {tag: 'DIV'}));
jsDD.registerContainer(BX.WindowManager.Get().GetContent());

</script>

<?
$obJSPopup->ShowTitlebar();
$obJSPopup->StartDescription('bx-structure');
?>
<p><b><?echo GetMessage("pub_struct_desc_title")?></b></p>
<div class="bx-struct-settings" onclick="structShowSettingsMenu(this)" onmouseover="this.className+=' bx-struct-settings-over'" onmouseout="this.className=this.className.replace(/\s*bx-struct-settings-over/ig, '')" title="<?echo GetMessage("pub_struct_settings_title")?>"><?echo GetMessage("pub_struct_settings")?></div>
<div class="bx-struct-settings bx-struct-button" onclick="structOpenDirs(this)" onmouseover="this.className+=' bx-struct-settings-over'" onmouseout="this.className=this.className.replace(/\s*bx-struct-settings-over/ig, '')" title="<?echo GetMessage("pub_struct_folders_title")?>"><?echo GetMessage("pub_struct_folders_button")?></div>
<br />
<br style="clear:both;" />
<?
$obJSPopup->StartContent();
?>
<div id="structure_content">
<?
//display first level tree
$arRoot = __struct_get_file_info($DOC_ROOT, "/");
echo __struct_show_files(array($arRoot), $DOC_ROOT, "", _normalizePath($_GET["path"]));
?>
</div>
<?
$obJSPopup->ShowStandardButtons(array("close"));
?>
<?
require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/epilog_admin_js.php");
?>
예제 #16
0
 function GetTemplate($template, $arSiteTemplates = array())
 {
     $arDirs = array("/templates/.default/page_templates");
     foreach ($arSiteTemplates as $val) {
         $arDirs[] = "/templates/" . $val . "/page_templates";
     }
     $template = _normalizePath($template);
     $sFile = false;
     foreach ($arDirs as $dir) {
         $template_dir = $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . $dir;
         $template_file = $template_dir . "/" . $template . "/template.php";
         if (!file_exists($template_file)) {
             continue;
         }
         if ($GLOBALS['APPLICATION']->GetFileAccessPermission(BX_PERSONAL_ROOT . $dir . "/" . $template . "/template.php") < "R") {
             continue;
         }
         $sFile = $template_file;
     }
     if ($sFile !== false) {
         $pageTemplate = false;
         include_once $sFile;
         if (is_object($pageTemplate)) {
             return $pageTemplate;
         }
     }
     return false;
 }