function MakeWizardPath($wizardName) { if (!CWizardUtil::CheckName($wizardName)) { return ""; } return Rel2Abs("/", "/" . str_replace(":", "/", $wizardName)); }
function __ConvPathParam($path) { if (substr($path, 0, 1) == '/' || substr($path, 1, 2) == ":\\") { $path_vhosts = $path; } else { $root = rtrim($_SERVER['DOCUMENT_ROOT'], '\\/'); $path_vhosts = Rel2Abs($root . '/', $path); } return $path_vhosts; }
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; }
function _IsItemSelected($arLinks = array()) { if (!is_array($arLinks)) { $arLinks = array($arLinks); } $cur_page = $GLOBALS["APPLICATION"]->GetCurPage(true); $cur_dir = $GLOBALS["APPLICATION"]->GetCurDir(); $selected = false; foreach ($arLinks as $tested_link) { if (strlen($tested_link) <= 0) { continue; } $tested_link = trim(Rel2Abs($cur_dir, $tested_link)); if (strpos($cur_page, $tested_link) === 0) { $selected = true; break; } if (($pos = strpos($tested_link, "?")) !== false) { if (substr($tested_link, 0, $pos) == $cur_page) { $params = explode("&", substr($tested_link, $pos + 1)); $bOK = true; foreach ($params as $param) { $eqpos = strpos($param, "="); $varvalue = ""; if ($eqpos === false) { $varname = $param; } elseif ($eqpos == 0) { continue; } else { $varname = substr($param, 0, $eqpos); $varvalue = urldecode(substr($param, $eqpos + 1)); } $globvarvalue = isset($GLOBALS[$varname]) ? $GLOBALS[$varname] : ""; if ($globvarvalue != $varvalue) { $bOK = false; break; } } if ($bOK) { $selected = true; break; } } } } return $selected; }
function getSkinsEx($path) { $basePath = $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $path); $arSkins = array(); if (!is_dir($basePath)) { // Not valid folder return $arSkins; } $arSkins = getSkinsFromDir($path); $handle = @opendir($basePath); while (false !== ($skinDir = @readdir($handle))) { if (!is_dir($basePath . '/' . $skinDir) || $skinDir == "." || $skinDir == "..") { continue; } $arDirSkins = getSkinsFromDir($path . '/' . $skinDir); $arSkins = array_merge($arSkins, $arDirSkins); } return $arSkins; }
function OnPostForm() { $wizard =& $this->GetWizard(); $templateID = $wizard->GetSiteTemplateID(); $templatePath = BX_PERSONAL_ROOT . "/templates/" . $templateID; $arReplace = array("COMPANY_NAME" => $wizard->GetVar("company_name"), "COMPANY_SLOGAN" => $wizard->GetVar("company_slogan")); CWizardUtil::ReplaceMacros($_SERVER["DOCUMENT_ROOT"] . $templatePath . "/include_areas/company_name.php", $arReplace); $server_name = $_SERVER["HTTP_HOST"] != '' ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"]; if ($_SERVER["SERVER_PORT"] != 80 && $_SERVER["SERVER_PORT"] != 443 && $_SERVER["SERVER_PORT"] > 0 && strpos($_SERVER["HTTP_HOST"], ":") === false) { $server_name .= ":" . $_SERVER["SERVER_PORT"]; } COption::SetOptionString("main", "server_name", $server_name); COption::SetOptionString("main", "site_name", htmlspecialcharsEx($wizard->GetVar("company_name"))); COption::SetOptionString("main", "wizard_company_slogan", $wizard->GetVar("company_slogan")); $themeVarName = $templateID . "_themeID"; $themeID = $wizard->GetVar($themeVarName); $themeID = Rel2Abs("/", $themeID); $themePath = $_SERVER["DOCUMENT_ROOT"] . DemoSiteUtil::GetTemplatesPath($wizard->GetPath()) . "/" . $templateID . "/themes/" . $themeID; CopyDirFiles($themePath, $_SERVER["DOCUMENT_ROOT"] . $templatePath, $rewrite = true, $recursive = true, $delete_after_copy = false, $exclude = "description.php"); $companyLogo = $wizard->GetVar("company_logo"); CWizardUtil::CopyFile($companyLogo, $templatePath . "/images/logo.gif", false); COption::SetOptionString("main", "wizard_site_logo", $companyLogo); }
<? require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/prolog_admin_before.php"); require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/prolog_admin_js.php"); $bFileMan = CModule::IncludeModule('fileman'); if(!$bFileMan) $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); CUtil::JSPostUnescape(); CComponentUtil::__IncludeLang(FX_PERSONAL_ROOT."/components/freetrix/player", "player_playlist_edit.php"); $strWarning = ""; $menufilename = ""; $path = Rel2Abs("/", $path); $arPath = Array($site, $path); $DOC_ROOT = CSite::GetSiteDocRoot($site); $abs_path = $DOC_ROOT.$path; $bCreate = !file_exists($abs_path); if (($bCreate && (!$USER->CanDoFileOperation('fm_create_new_file', $arPath) || !$USER->CanDoOperation('fileman_edit_existent_files'))) || (!$bCreate && (!$USER->CanDoFileOperation('fm_edit_existent_file', $arPath) || !$USER->CanDoOperation('fileman_admin_files')))) $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); $arTracks = Array(); /* * * * * * * * * * * * * * POST * * * * * * * * * * * * * */ if($REQUEST_METHOD=="POST" && $_REQUEST['save'] == 'Y') { require_once($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/classes/general/xml.php"); $objXML = new CDataXML(); $xmlsrc = '<?xml version="1.0" encoding="UTF-8"?>
} if ($extended == "Y") { $bSimple = false; } else { $bSimple = true; } $arPath_m = array($site, $menufilename); $only_edit = !$USER->CanDoOperation('fileman_add_element_to_menu') || !$USER->CanDoFileOperation('fm_create_new_file', $arPath_m); // Check access to folder if (!$USER->CanDoOperation('fileman_edit_existent_files') || !$USER->CanDoFileOperation('fm_edit_existent_file', $arPath_m) || !$bEdit && $only_edit) { $strWarning = GetMessage("ACCESS_DENIED"); } else { if ($REQUEST_METHOD == "POST" && strlen($save) > 0 && is_array($ids) && check_bitrix_sessid()) { $sMenuTemplateTmp = ""; if (strlen($template) > 0 && $template != GetMessage("FILEMAN_MENU_EDIT_DEF")) { $sMenuTemplateTmp = Rel2Abs("/", $template); } $res = CFileMan::GetMenuArray($abs_path); if ($bSimple) { $aMenuLinksTmp = $res["aMenuLinks"]; $sMenuTemplateTmp = $res["sMenuTemplate"]; } else { $aMenuLinksTmp = $res["aMenuLinks"]; $aMenuLinksTmp_ = array(); } //соберем $aMenuLinksTmp из того что пришло с формы $aMenuSort = array(); for ($i = 0, $l = count($ids); $i < $l; $i++) { $num = $ids[$i]; if (!isset($aMenuLinksTmp[$num - 1]) && $only_edit) { continue;
} $ph = ""; } } else { GetTDirList($path, true); } $strFile = ''; $arFileFilter = array(); if (isset($_REQUEST['file'])) { $strFile = strval($_REQUEST['file']); } if (preg_match("#\\.\\.[\\/]#" . BX_UTF_PCRE_MODIFIER, $strFile)) { $strFile = ""; } if ('' != $strFile) { $strFile = Rel2Abs("/", "/" . $strFile); foreach ($arTLangs as $hlang) { $ph = add_lang_id($strFile, $hlang, $arTLangs); if ('' != $ph) { $arFileFilter[] = $ph; } } } if (!empty($arFileFilter) && !empty($arFiles)) { $arTemp = array(); foreach ($arFiles as &$arOneFile) { if ('N' == $arOneFile['IS_DIR'] && in_array($arOneFile['PATH'], $arFileFilter)) { $arTemp[] = $arOneFile; } } if (isset($arOneFile)) {
require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/filter_tools.php"; CModule::IncludeModule("controller"); require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/controller/prolog.php"; $MOD_RIGHT = $APPLICATION->GetGroupRight("controller"); if ($MOD_RIGHT < "V") { $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); } IncludeModuleLangFile(__FILE__); $maxSafeCount = isset($_REQUEST["force"]) && $_REQUEST["force"] == "Y" ? false : COption::GetOptionString("controller", "safe_count"); $cnt = 0; $sTableID = "tbl_controller_upload"; $lAdmin = new CAdminList($sTableID); $filename = Rel2Abs("/", trim($_REQUEST['filename'])); //Trailing slash indicates that we have a directory here //never remove it due to security reasons $path_to = Rel2Abs("/", trim($_REQUEST['path_to']) . "/"); if (strlen($filename) > 0 && strlen($path_to) > 0 && $USER->IsAdmin() && check_bitrix_sessid()) { $lAdmin->BeginPrologContent(); $arFilter = array("CONTROLLER_GROUP_ID" => $_REQUEST['controller_group_id'], "DISCONNECTED" => "N"); $arFilter["ID"] = $_REQUEST['controller_member_id']; if (!is_array($arFilter["ID"])) { $IDs = explode(" ", $arFilter["ID"]); $arFilter["ID"] = array(); foreach ($IDs as $id) { $id = intval(trim($id)); if ($id > 0) { $arFilter["ID"][] = $id; } } } if (is_array($arFilter["ID"]) && count($arFilter["ID"]) <= 0) {
function BaseConvertToDB($value) { $io = CBXVirtualIo::GetInstance(); $arRes = array("path" => ""); if (!is_array($value)) { $value = array(); } //In case of DB value just serialize it if (implode("|", array_keys($value)) === 'path|width|height|title|duration|author|date|desc') { return serialize($value); } if ($value["B_NEW_FILE"] != "N") { if (strlen($value["CUR_PATH"]) > 0 && $value["DEL_CUR_FILE"] == "Y" && CIBlockPropertyVideo::CheckFileInUploadDir($value["CUR_PATH"])) { // del current file $cur_path_ = $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $value["CUR_PATH"]); $flTmp = $io->GetFile($cur_path_); $flSzTmp = $flTmp->GetFileSize(); if ($io->Delete($cur_path_)) { // Quota if (COption::GetOptionInt("main", "disk_space") > 0) { CDiskQuota::updateDiskQuota("file", $flSzTmp, "delete"); } } } // Get video if (strlen($value["PATH"]) > 0) { $arRes["path"] = $value["PATH"]; } else { if (isset($value["FILE"]) && strlen($value["FILE"]["tmp_name"]) > 0) { $pathToDir = CIBlockPropertyVideo::GetUploadDirPath(); if (!$io->DirectoryExists($_SERVER["DOCUMENT_ROOT"] . $pathToDir)) { CFileMan::CreateDir($pathToDir); } // 1. Convert name $name = preg_replace("/[^a-zA-Z0-9_:\\.]/is", "_", $value["FILE"]["name"]); $baseNamePart = substr($name, 0, strpos($name, '.')); $ext = GetFileExtension($name); if (strlen($ext) > 0 && !HasScriptExtension($name) && !substr($name, 0, 1) != ".") { $ind = 0; // 2. Check if file already exists while ($io->FileExists($_SERVER["DOCUMENT_ROOT"] . Rel2Abs($pathToDir, $name))) { $name = $baseNamePart . "_(" . ++$ind . ")." . $ext; } // 3. Rename $pathto = Rel2Abs($pathToDir, $name); if (is_uploaded_file($value["FILE"]["tmp_name"]) && $io->Copy($value["FILE"]["tmp_name"], $_SERVER["DOCUMENT_ROOT"] . $pathto)) { $arRes["path"] = Rel2Abs("/", $pathto); // Quota if (COption::GetOptionInt("main", "disk_space") > 0) { CDiskQuota::updateDiskQuota("file", $value["FILE"]["size"], "add"); } } } } } } elseif (strlen($value["CUR_PATH"]) > 0) { if (preg_match("/^(http|https):\\/\\//", $value["CUR_PATH"])) { $arRes["path"] = $value["CUR_PATH"]; } else { $arRes["path"] = Rel2Abs("/", $value["CUR_PATH"]); } } // Width & height $arRes["width"] = intVal($value["WIDTH"]); $arRes["height"] = intVal($value["HEIGHT"]); if ($arRes["width"] < 0) { $arRes["width"] = 400; } if ($arRes["height"] < 0) { $arRes["height"] = 300; } // Video info $arRes["title"] = $value["TITLE"]; $arRes["duration"] = $value["DURATION"]; $arRes["author"] = $value["AUTHOR"]; $arRes["date"] = $value["DATE"]; $arRes["desc"] = $value["DESC"]; $strRes = serialize($arRes); if ($arRes["path"] == "" && $arRes["title"] == "" && $arRes["author"] == "") { return ""; } return $strRes; }
$max_execution_time = 0; } if (defined("CATALOG_LOAD_NO_STEP") && CATALOG_LOAD_NO_STEP) { $max_execution_time = 0; } $bAllLinesLoaded = true; $io = CBXVirtualIo::GetInstance(); if (!function_exists('CSVCheckTimeout')) { function CSVCheckTimeout($max_execution_time) { return $max_execution_time <= 0 || getmicrotime() - START_EXEC_TIME <= $max_execution_time; } } $DATA_FILE_NAME = ""; if (strlen($URL_DATA_FILE) > 0) { $URL_DATA_FILE = Rel2Abs("/", $URL_DATA_FILE); if (file_exists($_SERVER["DOCUMENT_ROOT"] . $URL_DATA_FILE) && is_file($_SERVER["DOCUMENT_ROOT"] . $URL_DATA_FILE)) { $DATA_FILE_NAME = $URL_DATA_FILE; } } if (strlen($DATA_FILE_NAME) <= 0) { $strImportErrorMessage .= GetMessage("CATI_NO_DATA_FILE") . "<br>"; } $IBLOCK_ID = intval($IBLOCK_ID); if ($IBLOCK_ID <= 0) { $strImportErrorMessage .= GetMessage("CATI_NO_IBLOCK") . "<br>"; } else { $arIBlock = CIBlock::GetArrayByID($IBLOCK_ID); if (false === $arIBlock) { $strImportErrorMessage .= GetMessage("CATI_NO_IBLOCK") . "<br>"; }
Option::set('catalog', $name, $val, ''); } } $default_outfile_action = (isset($_REQUEST['default_outfile_action']) ? (string)$_REQUEST['default_outfile_action'] : ''); if ($default_outfile_action!="D" && $default_outfile_action!="H" && $default_outfile_action!="F") { $default_outfile_action = "D"; } Option::set('catalog', 'default_outfile_action', $default_outfile_action, ''); $strYandexAgent = ''; $strYandexAgent = trim($_POST['yandex_agent_file']); if (!empty($strYandexAgent)) { $strYandexAgent = Rel2Abs('/', $strYandexAgent); if (preg_match(BX_CATALOG_FILENAME_REG, $val) || (!file_exists($_SERVER['DOCUMENT_ROOT'].$strYandexAgent) || !is_file($_SERVER['DOCUMENT_ROOT'].$strYandexAgent))) { $strWarning .= Loc::getMessage('CAT_PATH_ERR_YANDEX_AGENT').'<br />'; $strYandexAgent = ''; } } Option::set('catalog', 'yandex_agent_file', $strYandexAgent, ''); $num_catalog_levels = (isset($_POST['num_catalog_levels']) ? (int)$_POST['num_catalog_levels'] : 3); if ($num_catalog_levels <= 0) $num_catalog_levels = 3; Option::set('catalog', 'num_catalog_levels', $num_catalog_levels, ''); $serialSelectFields = array( 'allowed_product_fields',
function GetTreeRecursive($PARENT_PATH, $level, $max_depth, $get_description = false) { global $arrMainMenu, $arrChildMenu, $arrSearchPath, $APPLICATION, $USER; static $arIndexes = false; if ($arIndexes === false) { $arIndexes = GetDirIndexArray(); } $i = 0; $arrMenu = $level == 0 ? $arrMainMenu : $arrChildMenu; $map = array(); if (is_array($arrMenu) && count($arrMenu) > 0) { foreach ($arrMenu as $mmenu) { $menu_file = "." . trim($mmenu) . ".menu.php"; $menu_file_ext = "." . trim($mmenu) . ".menu_ext.php"; $aMenuLinks = array(); if (file_exists($PARENT_PATH . $menu_file)) { include $PARENT_PATH . $menu_file; $bExists = true; } if (file_exists($PARENT_PATH . $menu_file_ext)) { include $PARENT_PATH . $menu_file_ext; $bExists = true; } if ($bExists && is_array($aMenuLinks)) { foreach ($aMenuLinks as $aMenu) { if (strlen($aMenu[0]) <= 0) { continue; } if (count($aMenu) > 4) { $CONDITION = $aMenu[4]; if (strlen($CONDITION) > 0 && !eval("return " . $CONDITION . ";")) { continue; } } $search_child = false; $search_path = ''; if (strlen($aMenu[1]) > 0) { if (preg_match("'^(([A-Za-z]+://)|mailto:|javascript:)'i", $aMenu[1])) { $full_path = $aMenu[1]; } else { $full_path = trim(Rel2Abs(substr($PARENT_PATH, strlen($_SERVER["DOCUMENT_ROOT"])), $aMenu[1])); $slash_pos = strrpos($full_path, "/"); if ($slash_pos !== false) { $page = substr($full_path, $slash_pos + 1); if (($pos = strpos($page, '?')) !== false) { $page = substr($page, 0, $pos); } if ($page == '' || $page == 'index.php' || in_array($page, $arIndexes)) { $search_path = substr($full_path, 0, $slash_pos + 1); $search_child = true; } } } } else { $full_path = $PARENT_PATH; } if (strlen($full_path) > 0) { $FILE_ACCESS = preg_match("'^(([A-Za-z]+://)|mailto:|javascript:)'i", $full_path) ? "R" : $APPLICATION->GetFileAccessPermission($full_path); if ($FILE_ACCESS != "D" && $aMenu[3]["SEPARATOR"] != "Y") { $is_dir = $search_child && is_dir($_SERVER["DOCUMENT_ROOT"] . $search_path) ? "Y" : "N"; if ($is_dir == "Y") { $search_child &= $level < $max_depth; $search_child &= !in_array($search_path, $arrSearchPath); } else { $search_child = false; } $ar = array(); $ar["LEVEL"] = $level; if (isset($aMenu[3]["DEPTH_LEVEL"]) && $aMenu[3]["DEPTH_LEVEL"] > 1) { $ar["LEVEL"] += $aMenu[3]["DEPTH_LEVEL"] - 1; } if ($ar["LEVEL"] > $max_depth) { continue; } $ar["ID"] = md5($full_path . $ar["COUNTER"]); $ar["IS_DIR"] = is_dir($_SERVER["DOCUMENT_ROOT"] . $full_path) ? "Y" : "N"; $ar["NAME"] = $aMenu[0]; $ar["PATH"] = $PARENT_PATH; $ar["FULL_PATH"] = $full_path; $ar["SEARCH_PATH"] = $search_path; $ar["DESCRIPTION"] = ""; if ($get_description && $ar["IS_DIR"] == "Y") { if (file_exists($_SERVER["DOCUMENT_ROOT"] . $full_path . ".section.php")) { $arDirProperties = array(); include $_SERVER["DOCUMENT_ROOT"] . $full_path . ".section.php"; if ($arDirProperties["description"] != '') { $ar["DESCRIPTION"] = $arDirProperties["description"]; } } } if ($search_child) { $arrSearchPath[] = $search_path; $ar["CHILDREN"] = GetTreeRecursive($_SERVER["DOCUMENT_ROOT"] . $ar["SEARCH_PATH"], $level + 1, $max_depth, $get_description); } $map[] = $ar; } } } } } } return $map; }
$delimiter_r_char = isset($delimiter_other_r) ? substr($delimiter_other_r, 0, 1) : ''; $delimiter_other_r = $delimiter_r_char; break; case "TZP": $delimiter_r_char = ";"; break; } } if (strlen($delimiter_r_char) != 1) { $arSetupErrors[] = GetMessage("CATI_NO_DELIMITER"); } if (!isset($SETUP_FILE_NAME) || strlen($SETUP_FILE_NAME) <= 0) { $arSetupErrors[] = GetMessage("CATI_NO_SAVE_FILE"); } if (empty($arSetupErrors)) { $SETUP_FILE_NAME = str_replace('//', '/', $strCatalogDefaultFolder . Rel2Abs("/", $SETUP_FILE_NAME)); if (preg_match(BX_CATALOG_FILENAME_REG, $SETUP_FILE_NAME)) { $arSetupErrors[] = GetMessage("CES_ERROR_BAD_EXPORT_FILENAME"); } elseif ($strCatalogDefaultFolder == $SETUP_FILE_NAME) { $arSetupErrors[] = GetMessage("CATI_NO_SAVE_FILE"); } } if (empty($arSetupErrors)) { if (strtolower(substr($SETUP_FILE_NAME, strlen($SETUP_FILE_NAME) - 4)) != ".csv") { $SETUP_FILE_NAME .= ".csv"; } if (HasScriptExtension($SETUP_FILE_NAME)) { $arSetupErrors[] = GetMessage("CES_ERROR_BAD_EXPORT_FILENAME_EXTENTIONS"); } } if (empty($arSetupErrors)) {
if ((strlen($save) > 0 || strlen($apply) > 0) && $WORKFLOW_RIGHT > "R" && $REQUEST_METHOD == "POST" && check_bitrix_sessid()) { if (CheckFields()) { $nums = intval($nums); if ($nums > 0) { for ($i = 1; $i <= $nums; $i++) { $arFile = $HTTP_POST_FILES["file_" . $i]; if (strlen($arFile["name"]) <= 0 || $arFile["tmp_name"] == "none") { continue; } $arFile["name"] = GetFileName($arFile["name"]); $fname = ${"fname_" . $i}; if (strlen($fname) <= 0) { $fname = $arFile["name"]; } $path = GetDirPath($FILENAME); $pathto = Rel2Abs($path, $fname); $ext = GetFileExtension($pathto); if (!$USER->IsAdmin() && in_array($ext, $arExt)) { $message = new CAdminMessage(array("MESSAGE" => GetMessage("FLOW_ERROR"), "DETAILS" => GetMessage("FLOW_FILEUPLOAD_PHPERROR") . " \"" . $pathto . "\"", "TYPE" => "ERROR")); } elseif (!$USER->CanDoFileOperation('fm_edit_in_workflow', array($SITE_ID, $pathto))) { $message = new CAdminMessage(array("MESSAGE" => GetMessage("FLOW_ERROR"), "DETAILS" => GetMessage("FLOW_FILEUPLOAD_ACCESS_DENIED") . " \"" . $pathto . "\": " . GetMessage("FLOW_MIN_RIGHTS"), "TYPE" => "ERROR")); } elseif (!CBXVirtualIoFileSystem::ValidatePathString($pathto)) { $message = new CAdminMessage(array("MESSAGE" => GetMessage("FLOW_ERROR"), "DETAILS" => GetMessage("FLOW_FILE_NAME_NOT_VALID"), "TYPE" => "ERROR")); } else { $z = CWorkflow::GetFileByID($ID, $pathto); if ($zr = $z->Fetch()) { $message = new CAdminMessage(array("MESSAGE" => GetMessage("FLOW_ERROR"), "DETAILS" => str_replace("#FILE#", "{$pathto}", GetMessage("FLOW_FILE_ALREADY_EXIST")), "TYPE" => "ERROR")); } else { $temp_file = CWorkflow::GetUniqueFilename($pathto); $temp_dir = CWorkflow::GetTempDir(); if (!file_exists($temp_dir)) {
# mailto:admin@bitrixsoft.com # ############################################## */ require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php"; require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/translate/prolog.php"; if (!$USER->CanDoOperation('edit_php')) { $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); } require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/translate/include.php"; IncludeModuleLangFile(__FILE__); define("HELP_FILE", "translate_list.php"); /*************************************************************************** GET | POST ***************************************************************************/ $strError = ""; $file = Rel2Abs("/", $file); $abs_path = CSite::GetSiteDocRoot(false) . htmlspecialcharsbx($file); if (strpos($file, "/bitrix/") !== 0 || strpos($file, "/lang/") === false || GetFileExtension($file) != "php") { $strError = GetMessage("trans_edit_err") . "<br>"; } $APPLICATION->SetTitle(GetMessage("TRANS_TITLE")); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; if ($strError == "") { $aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("TRANS_TITLE"), "ICON" => "translate_edit", "TITLE" => GetMessage("TRANS_TITLE_TITLE"))); $tabControl = new CAdminTabControl("tabControl", $aTabs); $chain = ""; $arPath = array(); $path_back = dirname($file); $arSlash = explode("/", $path_back); if (is_array($arSlash)) { $arSlash_tmp = $arSlash;
function __MoveDirFiles(&$arFiles) { if (!is_array($arFiles) || !array_key_exists("FILES", $arFiles)) return; foreach ($arFiles["FILES"] as $arFile) { //Delete if (array_key_exists("DELETE", $arFile) && strlen($arFile["DELETE"]) > 0) { if ($arFile["DELETE"] == "/" || $arFile["DELETE"] == "/freetrix" || $arFile["DELETE"] == "/freetrix/") continue; DeleteDirFilesEx($arFile["DELETE"]); continue; } //Copy if (!array_key_exists("FROM", $arFile) && !array_key_exists("TO", $arFile)) continue; $rewrite = (array_key_exists("REWRITE", $arFile) && $arFile["REWRITE"] == "N" ? false : true); $recursive = (array_key_exists("RECURSIVE", $arFile) && $arFile["RECURSIVE"] == "N" ? false : true); $arFile["TO"] = Rel2Abs("/", $arFile["TO"]); CopyDirFiles( $_SERVER["DOCUMENT_ROOT"].$this->path."/".$arFile["FROM"], $_SERVER["DOCUMENT_ROOT"].$arFile["TO"], $rewrite, $recursive ); } }
function Update($ID, $arFields, $bResort = true, $bUpdateSearch = true, $bResizePictures = false) { global $USER, $DB, $APPLICATION; $ID = intval($ID); $db_record = CIBlockSection::GetList(array(), array("ID" => $ID, "CHECK_PERMISSIONS" => "N")); if (!($db_record = $db_record->Fetch())) { return false; } if (is_set($arFields, "EXTERNAL_ID")) { $arFields["XML_ID"] = $arFields["EXTERNAL_ID"]; } unset($arFields["GLOBAL_ACTIVE"]); unset($arFields["DEPTH_LEVEL"]); unset($arFields["LEFT_MARGIN"]); unset($arFields["RIGHT_MARGIN"]); unset($arFields["IBLOCK_ID"]); unset($arFields["DATE_CREATE"]); unset($arFields["CREATED_BY"]); $arIBlock = CIBlock::GetArrayByID($db_record["IBLOCK_ID"]); if ($bResizePictures) { $arDef = $arIBlock["FIELDS"]["SECTION_PICTURE"]["DEFAULT_VALUE"]; if ($arDef["DELETE_WITH_DETAIL"] === "Y" && $arFields["DETAIL_PICTURE"]["del"] === "Y") { $arFields["PICTURE"]["del"] = "Y"; } if ($arDef["FROM_DETAIL"] === "Y" && ($arFields["PICTURE"]["size"] <= 0 || $arDef["UPDATE_WITH_DETAIL"] === "Y") && is_array($arFields["DETAIL_PICTURE"]) && $arFields["DETAIL_PICTURE"]["size"] > 0) { if ($arFields["PICTURE"]["del"] !== "Y" && $arDef["UPDATE_WITH_DETAIL"] !== "Y") { $arOldSection = $db_record; } else { $arOldSection = false; } if (!$arOldSection || !$arOldSection["PICTURE"]) { $arNewPreview = $arFields["DETAIL_PICTURE"]; $arNewPreview["COPY_FILE"] = "Y"; $arNewPreview["description"] = $arFields["PICTURE"]["description"]; $arFields["PICTURE"] = $arNewPreview; } } if (array_key_exists("PICTURE", $arFields) && is_array($arFields["PICTURE"]) && $arFields["PICTURE"]["size"] > 0 && $arDef["SCALE"] === "Y") { $arNewPicture = CIBlock::ResizePicture($arFields["PICTURE"], $arDef); if (is_array($arNewPicture)) { $arNewPicture["description"] = $arFields["PICTURE"]["description"]; $arFields["PICTURE"] = $arNewPicture; } elseif ($arDef["IGNORE_ERRORS"] !== "Y") { unset($arFields["PICTURE"]); $strWarning .= GetMessage("IBLOCK_FIELD_PREVIEW_PICTURE") . ": " . $arNewPicture . "<br>"; } } if (array_key_exists("PICTURE", $arFields) && is_array($arFields["PICTURE"]) && $arDef["USE_WATERMARK_FILE"] === "Y") { if (strlen($arFields["PICTURE"]["tmp_name"]) > 0 && $arFields["PICTURE"]["tmp_name"] === $arFields["DETAIL_PICTURE"]["tmp_name"]) { $arFields["PICTURE"]["tmp_name"] = CTempFile::GetFileName(basename($arFields["PICTURE"]["tmp_name"])); CheckDirPath($arFields["PICTURE"]["tmp_name"]); copy($arFields["DETAIL_PICTURE"]["tmp_name"], $arFields["PICTURE"]["tmp_name"]); } CIBLock::FilterPicture($arFields["PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_FILE_POSITION"], "type" => "file", "size" => "real", "alpha_level" => 100 - min(max($arDef["WATERMARK_FILE_ALPHA"], 0), 100), "file" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_FILE"]))); } if (array_key_exists("PICTURE", $arFields) && is_array($arFields["PICTURE"]) && $arDef["USE_WATERMARK_TEXT"] === "Y") { if (strlen($arFields["PICTURE"]["tmp_name"]) > 0 && $arFields["PICTURE"]["tmp_name"] === $arFields["DETAIL_PICTURE"]["tmp_name"]) { $arFields["PICTURE"]["tmp_name"] = CTempFile::GetFileName(basename($arFields["PICTURE"]["tmp_name"])); CheckDirPath($arFields["PICTURE"]["tmp_name"]); copy($arFields["DETAIL_PICTURE"]["tmp_name"], $arFields["PICTURE"]["tmp_name"]); } CIBLock::FilterPicture($arFields["PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_TEXT_POSITION"], "type" => "text", "coefficient" => $arDef["WATERMARK_TEXT_SIZE"], "text" => $arDef["WATERMARK_TEXT"], "font" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_TEXT_FONT"]), "color" => $arDef["WATERMARK_TEXT_COLOR"])); } $arDef = $arIBlock["FIELDS"]["SECTION_DETAIL_PICTURE"]["DEFAULT_VALUE"]; if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["SCALE"] === "Y") { $arNewPicture = CIBlock::ResizePicture($arFields["DETAIL_PICTURE"], $arDef); if (is_array($arNewPicture)) { $arNewPicture["description"] = $arFields["DETAIL_PICTURE"]["description"]; $arFields["DETAIL_PICTURE"] = $arNewPicture; } elseif ($arDef["IGNORE_ERRORS"] !== "Y") { unset($arFields["DETAIL_PICTURE"]); $strWarning .= GetMessage("IBLOCK_FIELD_DETAIL_PICTURE") . ": " . $arNewPicture . "<br>"; } } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["USE_WATERMARK_FILE"] === "Y") { if (strlen($arFields["DETAIL_PICTURE"]["tmp_name"]) > 0 && $arFields["DETAIL_PICTURE"]["tmp_name"] === $arFields["PICTURE"]["tmp_name"]) { $arFields["DETAIL_PICTURE"]["tmp_name"] = CTempFile::GetFileName(basename($arFields["DETAIL_PICTURE"]["tmp_name"])); CheckDirPath($arFields["DETAIL_PICTURE"]["tmp_name"]); copy($arFields["PICTURE"]["tmp_name"], $arFields["DETAIL_PICTURE"]["tmp_name"]); } CIBLock::FilterPicture($arFields["DETAIL_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_FILE_POSITION"], "type" => "file", "size" => "real", "alpha_level" => 100 - min(max($arDef["WATERMARK_FILE_ALPHA"], 0), 100), "file" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_FILE"]), "fill" => "resize")); } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["USE_WATERMARK_TEXT"] === "Y") { if (strlen($arFields["DETAIL_PICTURE"]["tmp_name"]) > 0 && $arFields["DETAIL_PICTURE"]["tmp_name"] === $arFields["PICTURE"]["tmp_name"]) { $arFields["DETAIL_PICTURE"]["tmp_name"] = CTempFile::GetFileName(basename($arFields["DETAIL_PICTURE"]["tmp_name"])); CheckDirPath($arFields["DETAIL_PICTURE"]["tmp_name"]); copy($arFields["PICTURE"]["tmp_name"], $arFields["DETAIL_PICTURE"]["tmp_name"]); } CIBLock::FilterPicture($arFields["DETAIL_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_TEXT_POSITION"], "type" => "text", "coefficient" => $arDef["WATERMARK_TEXT_SIZE"], "text" => $arDef["WATERMARK_TEXT"], "font" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_TEXT_FONT"]), "color" => $arDef["WATERMARK_TEXT_COLOR"])); } } if (is_set($arFields, "PICTURE")) { if (strlen($arFields["PICTURE"]["name"]) <= 0 && strlen($arFields["PICTURE"]["del"]) <= 0) { unset($arFields["PICTURE"]); } else { $arFields["PICTURE"]["old_file"] = $db_record["PICTURE"]; $arFields["PICTURE"]["MODULE_ID"] = "iblock"; } } if (is_set($arFields, "DETAIL_PICTURE")) { if (strlen($arFields["DETAIL_PICTURE"]["name"]) <= 0 && strlen($arFields["DETAIL_PICTURE"]["del"]) <= 0) { unset($arFields["DETAIL_PICTURE"]); } else { $arFields["DETAIL_PICTURE"]["old_file"] = $db_record["DETAIL_PICTURE"]; $arFields["DETAIL_PICTURE"]["MODULE_ID"] = "iblock"; } } if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") { $arFields["ACTIVE"] = "N"; } if (is_set($arFields, "DESCRIPTION_TYPE") && $arFields["DESCRIPTION_TYPE"] != "html") { $arFields["DESCRIPTION_TYPE"] = "text"; } if (isset($arFields["IBLOCK_SECTION_ID"])) { $arFields["IBLOCK_SECTION_ID"] = intval($arFields["IBLOCK_SECTION_ID"]); if ($arFields["IBLOCK_SECTION_ID"] <= 0) { $arFields["IBLOCK_SECTION_ID"] = false; } } $DESC_tmp = is_set($arFields, "DESCRIPTION") ? $arFields["DESCRIPTION"] : $db_record["DESCRIPTION"]; $DESC_TYPE_tmp = is_set($arFields, "DESCRIPTION_TYPE") ? $arFields["DESCRIPTION_TYPE"] : $db_record["DESCRIPTION_TYPE"]; $arFields["SEARCHABLE_CONTENT"] = ToUpper((is_set($arFields, "NAME") ? $arFields["NAME"] : $db_record["NAME"]) . "\r\n" . ($DESC_TYPE_tmp == "html" ? HTMLToTxt($DESC_tmp) : $DESC_tmp)); if (is_object($USER)) { if (!isset($arFields["MODIFIED_BY"]) || intval($arFields["MODIFIED_BY"]) <= 0) { $arFields["MODIFIED_BY"] = intval($USER->GetID()); } } if (!$this->CheckFields($arFields, $ID)) { $Result = false; $arFields["RESULT_MESSAGE"] =& $this->LAST_ERROR; } elseif (!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("IBLOCK_" . $db_record["IBLOCK_ID"] . "_SECTION", $ID, $arFields)) { $Result = false; $err = $APPLICATION->GetException(); if (is_object($err)) { $this->LAST_ERROR .= str_replace("<br><br>", "<br>", $err->GetString() . "<br>"); } $arFields["RESULT_MESSAGE"] =& $this->LAST_ERROR; } else { if (array_key_exists("PICTURE", $arFields)) { $SAVED_PICTURE = $arFields["PICTURE"]; CFile::SaveForDB($arFields, "PICTURE", "iblock"); } if (array_key_exists("DETAIL_PICTURE", $arFields)) { $SAVED_DETAIL_PICTURE = $arFields["DETAIL_PICTURE"]; CFile::SaveForDB($arFields, "DETAIL_PICTURE", "iblock"); } unset($arFields["ID"]); $strUpdate = $DB->PrepareUpdate("b_iblock_section", $arFields, "iblock"); if (array_key_exists("PICTURE", $arFields)) { $arFields["PICTURE"] = $SAVED_PICTURE; } if (array_key_exists("DETAIL_PICTURE", $arFields)) { $arFields["DETAIL_PICTURE"] = $SAVED_DETAIL_PICTURE; } CIBlock::_transaction_lock($db_record["IBLOCK_ID"]); if (strlen($strUpdate) > 0) { $strSql = "UPDATE b_iblock_section SET " . $strUpdate . " WHERE ID = " . $ID; $arBinds = array(); if (array_key_exists("DESCRIPTION", $arFields)) { $arBinds["DESCRIPTION"] = $arFields["DESCRIPTION"]; } if (array_key_exists("SEARCHABLE_CONTENT", $arFields)) { $arBinds["SEARCHABLE_CONTENT"] = $arFields["SEARCHABLE_CONTENT"]; } $DB->QueryBind($strSql, $arBinds); } if ($bResort) { //Move inside the tree if (isset($arFields["SORT"]) && $arFields["SORT"] != $db_record["SORT"] || isset($arFields["NAME"]) && $arFields["NAME"] != $db_record["NAME"] || isset($arFields["IBLOCK_SECTION_ID"]) && $arFields["IBLOCK_SECTION_ID"] != $db_record["IBLOCK_SECTION_ID"]) { //First "delete" from the tree $distance = intval($db_record["RIGHT_MARGIN"]) - intval($db_record["LEFT_MARGIN"]) + 1; $DB->Query("\n\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t,LEFT_MARGIN = -LEFT_MARGIN\n\t\t\t\t\t\t\t,RIGHT_MARGIN = -RIGHT_MARGIN\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tIBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\tAND LEFT_MARGIN >= " . intval($db_record["LEFT_MARGIN"]) . "\n\t\t\t\t\t\t\tAND LEFT_MARGIN <= " . intval($db_record["RIGHT_MARGIN"]) . "\n\t\t\t\t\t"); $DB->Query("\n\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t,RIGHT_MARGIN = RIGHT_MARGIN - " . $distance . "\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tIBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\tAND RIGHT_MARGIN > " . $db_record["RIGHT_MARGIN"] . "\n\t\t\t\t\t"); $DB->Query("\n\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t,LEFT_MARGIN = LEFT_MARGIN - " . $distance . "\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tIBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\tAND LEFT_MARGIN > " . $db_record["LEFT_MARGIN"] . "\n\t\t\t\t\t"); //Next insert into the the tree almost as we do when inserting the new one $PARENT_ID = isset($arFields["IBLOCK_SECTION_ID"]) ? intval($arFields["IBLOCK_SECTION_ID"]) : intval($db_record["IBLOCK_SECTION_ID"]); $NAME = isset($arFields["NAME"]) ? $arFields["NAME"] : $db_record["NAME"]; $SORT = isset($arFields["SORT"]) ? intval($arFields["SORT"]) : intval($db_record["SORT"]); $arParents = array(); $strSql = "\n\t\t\t\t\t\tSELECT BS.ID, BS.ACTIVE, BS.GLOBAL_ACTIVE, BS.DEPTH_LEVEL, BS.LEFT_MARGIN, BS.RIGHT_MARGIN\n\t\t\t\t\t\tFROM b_iblock_section BS\n\t\t\t\t\t\tWHERE BS.IBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\tAND BS.ID in (" . intval($db_record["IBLOCK_SECTION_ID"]) . ", " . $PARENT_ID . ")\n\t\t\t\t\t"; $rsParents = $DB->Query($strSql); while ($arParent = $rsParents->Fetch()) { $arParents[$arParent["ID"]] = $arParent; } //Find rightmost child of the parent $strSql = "\n\t\t\t\t\t\tSELECT BS.ID, BS.RIGHT_MARGIN, BS.DEPTH_LEVEL\n\t\t\t\t\t\tFROM b_iblock_section BS\n\t\t\t\t\t\tWHERE BS.IBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\tAND " . ($PARENT_ID > 0 ? "BS.IBLOCK_SECTION_ID=" . $PARENT_ID : "BS.IBLOCK_SECTION_ID IS NULL") . "\n\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t(BS.SORT < " . $SORT . ")\n\t\t\t\t\t\t\tOR (BS.SORT = " . $SORT . " AND BS.NAME < '" . $DB->ForSQL($NAME) . "')\n\t\t\t\t\t\t)\n\t\t\t\t\t\tAND BS.ID <> " . $ID . "\n\t\t\t\t\t\tORDER BY BS.SORT DESC, BS.NAME DESC\n\t\t\t\t\t"; $rsChild = $DB->Query($strSql); if ($arChild = $rsChild->Fetch()) { //We found the left neighbour $arUpdate = array("LEFT_MARGIN" => intval($arChild["RIGHT_MARGIN"]) + 1, "DEPTH_LEVEL" => intval($arChild["DEPTH_LEVEL"])); } else { //If we have parent, when take its left_margin if (isset($arParents[$PARENT_ID]) && $arParents[$PARENT_ID]) { $arUpdate = array("LEFT_MARGIN" => intval($arParents[$PARENT_ID]["LEFT_MARGIN"]) + 1, "DEPTH_LEVEL" => intval($arParents[$PARENT_ID]["DEPTH_LEVEL"]) + 1); } else { //We are only one/leftmost section in the iblock. $arUpdate = array("LEFT_MARGIN" => 1, "DEPTH_LEVEL" => 1); } } $move_distance = intval($db_record["LEFT_MARGIN"]) - $arUpdate["LEFT_MARGIN"]; $DB->Query("\n\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t,LEFT_MARGIN = LEFT_MARGIN + " . $distance . "\n\t\t\t\t\t\t\t,RIGHT_MARGIN = RIGHT_MARGIN + " . $distance . "\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tIBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\tAND LEFT_MARGIN >= " . $arUpdate["LEFT_MARGIN"] . "\n\t\t\t\t\t"); $DB->Query("\n\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t,LEFT_MARGIN = -LEFT_MARGIN - " . $move_distance . "\n\t\t\t\t\t\t\t,RIGHT_MARGIN = -RIGHT_MARGIN - " . $move_distance . "\n\t\t\t\t\t\t\t" . ($arUpdate["DEPTH_LEVEL"] != intval($db_record["DEPTH_LEVEL"]) ? ",DEPTH_LEVEL = DEPTH_LEVEL - " . ($db_record["DEPTH_LEVEL"] - $arUpdate["DEPTH_LEVEL"]) : "") . "\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tIBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\tAND LEFT_MARGIN <= " . -intval($db_record["LEFT_MARGIN"]) . "\n\t\t\t\t\t\t\tAND LEFT_MARGIN >= " . -intval($db_record["RIGHT_MARGIN"]) . "\n\t\t\t\t\t"); if (isset($arParents[$PARENT_ID])) { $DB->Query("\n\t\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t\t,RIGHT_MARGIN = RIGHT_MARGIN + " . $distance . "\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tIBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\tAND LEFT_MARGIN <= " . $arParents[$PARENT_ID]["LEFT_MARGIN"] . "\n\t\t\t\t\t\t\t\tAND RIGHT_MARGIN >= " . $arParents[$PARENT_ID]["RIGHT_MARGIN"] . "\n\t\t\t\t\t\t"); } } //Check if parent was changed if (isset($arFields["IBLOCK_SECTION_ID"]) && $arFields["IBLOCK_SECTION_ID"] != $db_record["IBLOCK_SECTION_ID"]) { $rsSection = CIBlockSection::GetByID($ID); $arSection = $rsSection->Fetch(); $strSql = "\n\t\t\t\t\t\tSELECT ID, GLOBAL_ACTIVE\n\t\t\t\t\t\tFROM b_iblock_section\n\t\t\t\t\t\tWHERE IBLOCK_ID = " . $arSection["IBLOCK_ID"] . "\n\t\t\t\t\t\tAND ID = " . intval($arFields["IBLOCK_SECTION_ID"]) . "\n\t\t\t\t\t"; $rsParent = $DB->Query($strSql); $arParent = $rsParent->Fetch(); //If new parent is not globally active //or we are not active either //we must be not globally active too if ($arParent && $arParent["GLOBAL_ACTIVE"] == "N" || $arFields["ACTIVE"] == "N") { $DB->Query("\n\t\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t\t,GLOBAL_ACTIVE = 'N'\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tIBLOCK_ID = " . $arSection["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\tAND LEFT_MARGIN >= " . intval($arSection["LEFT_MARGIN"]) . "\n\t\t\t\t\t\t\t\tAND RIGHT_MARGIN <= " . intval($arSection["RIGHT_MARGIN"]) . "\n\t\t\t\t\t\t"); } elseif ($arSection["ACTIVE"] == "N" && $arFields["ACTIVE"] == "Y") { $this->RecalcGlobalActiveFlag($arSection); } elseif ((!$arParent || $arParent["GLOBAL_ACTIVE"] == "Y") && $arSection["GLOBAL_ACTIVE"] == "N" && ($arSection["ACTIVE"] == "Y" || $arFields["ACTIVE"] == "Y")) { $this->RecalcGlobalActiveFlag($arSection); } //Otherwise we may not to change anything } elseif (isset($arFields["ACTIVE"]) && $arFields["ACTIVE"] != $db_record["ACTIVE"]) { //Make all children globally inactive if ($arFields["ACTIVE"] == "N") { $DB->Query("\n\t\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t\t,GLOBAL_ACTIVE = 'N'\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tIBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\tAND LEFT_MARGIN >= " . intval($db_record["LEFT_MARGIN"]) . "\n\t\t\t\t\t\t\t\tAND RIGHT_MARGIN <= " . intval($db_record["RIGHT_MARGIN"]) . "\n\t\t\t\t\t\t"); } else { //Check for parent activity $strSql = "\n\t\t\t\t\t\t\tSELECT ID, GLOBAL_ACTIVE\n\t\t\t\t\t\t\tFROM b_iblock_section\n\t\t\t\t\t\t\tWHERE IBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\tAND ID = " . intval($db_record["IBLOCK_SECTION_ID"]) . "\n\t\t\t\t\t\t"; $rsParent = $DB->Query($strSql); $arParent = $rsParent->Fetch(); //Parent is active //and we changed //so need to recalc if (!$arParent || $arParent["GLOBAL_ACTIVE"] == "Y") { $this->RecalcGlobalActiveFlag($db_record); } } } } if ($arIBlock["RIGHTS_MODE"] === "E") { $obSectionRights = new CIBlockSectionRights($arIBlock["ID"], $ID); //Check if parent changed with extended rights mode if (isset($arFields["IBLOCK_SECTION_ID"]) && $arFields["IBLOCK_SECTION_ID"] != $db_record["IBLOCK_SECTION_ID"]) { $obSectionRights->ChangeParents(array($db_record["IBLOCK_SECTION_ID"]), array($arFields["IBLOCK_SECTION_ID"])); } if (array_key_exists("RIGHTS", $arFields) && is_array($arFields["RIGHTS"])) { $obSectionRights->SetRights($arFields["RIGHTS"]); } } $uf_updated = $GLOBALS["USER_FIELD_MANAGER"]->Update("IBLOCK_" . $db_record["IBLOCK_ID"] . "_SECTION", $ID, $arFields); if ($uf_updated) { $DB->Query("UPDATE b_iblock_section SET TIMESTAMP_X = " . $DB->CurrentTimeFunction() . " WHERE ID = " . $ID); } if (CIBlock::GetArrayByID($db_record["IBLOCK_ID"], "SECTION_PROPERTY") === "Y" && array_key_exists("SECTION_PROPERTY", $arFields) && is_array($arFields["SECTION_PROPERTY"])) { CIBlockSectionPropertyLink::DeleteBySection($ID); foreach ($arFields["SECTION_PROPERTY"] as $PROPERTY_ID => $arLink) { CIBlockSectionPropertyLink::Add($ID, $PROPERTY_ID, $arLink); } } if ($bUpdateSearch) { CIBlockSection::UpdateSearch($ID); } if ($arIBlock["FIELDS"]["LOG_SECTION_EDIT"]["IS_REQUIRED"] == "Y") { $USER_ID = is_object($USER) ? intval($USER->GetID()) : 0; $db_events = GetModuleEvents("main", "OnBeforeEventLog"); $arEvent = $db_events->Fetch(); if (!$arEvent || ExecuteModuleEventEx($arEvent, array($USER_ID)) === false) { $rsSection = CIBlockSection::GetList(array(), array("=ID" => $ID), false, array("LIST_PAGE_URL", "NAME", "CODE")); $arSection = $rsSection->GetNext(); $res = array("ID" => $ID, "CODE" => $arSection["CODE"], "NAME" => $arSection["NAME"], "SECTION_NAME" => $arIBlock["SECTION_NAME"], "USER_ID" => $USER_ID, "IBLOCK_PAGE_URL" => $arSection["LIST_PAGE_URL"]); CEventLog::Log("IBLOCK", "IBLOCK_SECTION_EDIT", "iblock", $arIBlock["ID"], serialize($res)); } } $Result = true; /*********** QUOTA ***************/ $_SESSION["SESS_RECOUNT_DB"] = "Y"; /*********** QUOTA ***************/ } $arFields["ID"] = $ID; $arFields["IBLOCK_ID"] = $db_record["IBLOCK_ID"]; $arFields["RESULT"] =& $Result; $events = GetModuleEvents("iblock", "OnAfterIBlockSectionUpdate"); while ($arEvent = $events->Fetch()) { ExecuteModuleEventEx($arEvent, array(&$arFields)); } if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->ClearByTag("iblock_id_" . $arIBlock["ID"]); } return $Result; }
function UploadFile($Params) { $buffer = 'parent.oWaitWindow.Hide();'; $F = $Params['file']; $io = CBXVirtualIo::GetInstance(); if (isset($F["tmp_name"]) && strlen($F["tmp_name"]) > 0 && strlen($F["name"]) > 0 || is_uploaded_file($F["tmp_name"])) { global $APPLICATION, $USER; $strWarning = ''; $filename = $Params['filename']; $path = $Params['path']; $site = $Params['site']; $upload_and_open = $Params['upload_and_open']; $rootPath = CSite::GetSiteDocRoot($site); if ($filename == '') { $filename = $F["name"]; } $pathto = Rel2Abs($path, $filename); if (strlen($filename) > 0 && ($mess = self::CheckFileName($filename)) !== true) { $strWarning = $mess; } if ($strWarning == '') { $fn = $io->ExtractNameFromPath($pathto); if ($APPLICATION->GetFileAccessPermission(array($site, $pathto)) > "R" && ($USER->IsAdmin() || !HasScriptExtension($fn) && substr($fn, 0, 1) != "." && $io->ValidateFilenameString($fn))) { if (!$io->FileExists($rootPath . $pathto) || $_REQUEST["rewrite"] == "Y") { //************************** Quota **************************// $bQuota = true; if (COption::GetOptionInt("main", "disk_space") > 0) { $bQuota = false; $quota = new CDiskQuota(); if ($quota->checkDiskQuota(array("FILE_SIZE" => filesize($F["tmp_name"])))) { $bQuota = true; } } //************************** Quota **************************// if ($bQuota) { $io->Copy($F["tmp_name"], $rootPath . $pathto); $flTmp = $io->GetFile($rootPath . $pathto); $flTmp->MarkWritable(); if (COption::GetOptionInt("main", "disk_space") > 0) { CDiskQuota::updateDiskQuota("file", $flTmp->GetFileSize(), "copy"); } $buffer = 'setTimeout(function(){parent.oBXDialogControls.Uploader.OnAfterUpload("' . $filename . '", ' . ($upload_and_open == "Y" ? 'true' : 'false') . ');}, 50);'; } else { $strWarning = $quota->LAST_ERROR; } } else { $strWarning = GetMessage("FD_LOAD_EXIST_ALERT"); } } else { $strWarning = GetMessage("FD_LOAD_DENY_ALERT"); } } } else { $strWarning = GetMessage("FD_LOAD_ERROR_ALERT"); } if ($strWarning != '') { $buffer = 'alert("' . addslashes(htmlspecialcharsex($strWarning)) . '");'; } return '<script>' . $buffer . '</script>'; }
function Update($ID, $arFields, $bWorkFlow = false, $bUpdateSearch = true, $bResizePictures = false, $bCheckDiskQuota = true) { global $DB, $USER; $ID = intval($ID); $db_element = CIBlockElement::GetList(array(), array("ID" => $ID, "SHOW_HISTORY" => "Y"), false, false, array("ID", "TIMESTAMP_X", "MODIFIED_BY", "DATE_CREATE", "CREATED_BY", "IBLOCK_ID", "ACTIVE", "ACTIVE_FROM", "ACTIVE_TO", "SORT", "NAME", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "WF_STATUS_ID", "WF_PARENT_ELEMENT_ID", "WF_NEW", "WF_COMMENTS", "IN_SECTIONS", "CODE", "TAGS", "XML_ID", "TMP_ID")); if (!($ar_element = $db_element->Fetch())) { return false; } $arIBlock = CIBlock::GetArrayByID($ar_element["IBLOCK_ID"]); $bWorkFlow = $bWorkFlow && is_array($arIBlock) && $arIBlock["WORKFLOW"] != "N" && CModule::IncludeModule("workflow"); $ar_wf_element = $ar_element; $LAST_ID = 0; if ($bWorkFlow) { $LAST_ID = CIBlockElement::WF_GetLast($ID); if ($LAST_ID != $ID) { $db_element = CIBlockElement::GetByID($LAST_ID); if (!($ar_wf_element = $db_element->Fetch())) { return false; } } $arFields["WF_PARENT_ELEMENT_ID"] = $ID; if (!array_key_exists("PROPERTY_VALUES", $arFields) || !is_array($arFields["PROPERTY_VALUES"])) { $arFields["PROPERTY_VALUES"] = array(); } $bFieldProps = array(); foreach ($arFields["PROPERTY_VALUES"] as $k => $v) { $bFieldProps[$k] = true; } $arFieldProps =& $arFields['PROPERTY_VALUES']; $props = CIBlockElement::GetProperty($ar_element["IBLOCK_ID"], $ar_wf_element["ID"]); while ($arProp = $props->Fetch()) { $pr_val_id = $arProp['PROPERTY_VALUE_ID']; if ($arProp['PROPERTY_TYPE'] == 'F' && strlen($pr_val_id) > 0) { if (strlen($arProp["CODE"]) > 0 && is_set($arFieldProps, $arProp["CODE"])) { $pr_id = $arProp["CODE"]; } else { $pr_id = $arProp['ID']; } if (array_key_exists($pr_id, $arFieldProps) && array_key_exists($pr_val_id, $arFieldProps[$pr_id]) && is_array($arFieldProps[$pr_id][$pr_val_id])) { $new_value = $arFieldProps[$pr_id][$pr_val_id]; if (strlen($new_value['name']) <= 0 && $new_value['del'] != "Y" && strlen($new_value['VALUE']['name']) <= 0 && $new_value['VALUE']['del'] != "Y") { if (array_key_exists('DESCRIPTION', $new_value) && $new_value['DESCRIPTION'] != $arProp['DESCRIPTION']) { $p = array("VALUE" => CFile::MakeFileArray($arProp['VALUE'])); $p["DESCRIPTION"] = $new_value["DESCRIPTION"]; $p["MODULE_ID"] = "iblock"; $arFieldProps[$pr_id][$pr_val_id] = $p; } elseif ($arProp['VALUE'] > 0) { $arFieldProps[$pr_id][$pr_val_id] = array("VALUE" => $arProp['VALUE'], "DESCRIPTION" => $arProp["DESCRIPTION"]); } } } else { $arFieldProps[$pr_id][$pr_val_id] = array("VALUE" => $arProp['VALUE'], "DESCRIPTION" => $arProp["DESCRIPTION"]); } continue; } if (strlen($pr_val_id) <= 0 || array_key_exists($arProp["ID"], $bFieldProps) || strlen($arProp["CODE"]) > 0 && array_key_exists($arProp["CODE"], $bFieldProps)) { continue; } $arFieldProps[$arProp["ID"]][$pr_val_id] = array("VALUE" => $arProp['VALUE'], "DESCRIPTION" => $arProp["DESCRIPTION"]); } if ($ar_wf_element["IN_SECTIONS"] == "Y") { $ar_wf_element["IBLOCK_SECTION"] = array(); $rsSections = CIBlockElement::GetElementGroups($ar_element["ID"], true, array('ID', 'IBLOCK_ELEMENT_ID')); while ($arSection = $rsSections->Fetch()) { $ar_wf_element["IBLOCK_SECTION"][] = $arSection["ID"]; } } unset($ar_wf_element["DATE_ACTIVE_FROM"]); unset($ar_wf_element["DATE_ACTIVE_TO"]); unset($ar_wf_element["EXTERNAL_ID"]); unset($ar_wf_element["TIMESTAMP_X"]); unset($ar_wf_element["ID"]); $arFields = $arFields + $ar_wf_element; } $arFields["WF"] = $bWorkFlow ? "Y" : "N"; $bBizProc = is_array($arIBlock) && $arIBlock["BIZPROC"] == "Y" && IsModuleInstalled("bizproc"); if (array_key_exists("BP_PUBLISHED", $arFields)) { if ($bBizProc) { if ($arFields["BP_PUBLISHED"] == "Y") { $arFields["WF_STATUS_ID"] = 1; $arFields["WF_NEW"] = false; } else { $arFields["WF_STATUS_ID"] = 2; $arFields["WF_NEW"] = "Y"; $arFields["BP_PUBLISHED"] = "N"; } } else { $arFields["WF_NEW"] = false; unset($arFields["BP_PUBLISHED"]); } } else { $arFields["WF_NEW"] = false; } if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") { $arFields["ACTIVE"] = "N"; } if (is_set($arFields, "PREVIEW_TEXT_TYPE") && $arFields["PREVIEW_TEXT_TYPE"] != "html") { $arFields["PREVIEW_TEXT_TYPE"] = "text"; } if (is_set($arFields, "DETAIL_TEXT_TYPE") && $arFields["DETAIL_TEXT_TYPE"] != "html") { $arFields["DETAIL_TEXT_TYPE"] = "text"; } $strWarning = ""; if ($bResizePictures) { $arDef = $arIBlock["FIELDS"]["PREVIEW_PICTURE"]["DEFAULT_VALUE"]; if ($arDef["DELETE_WITH_DETAIL"] === "Y" && $arFields["DETAIL_PICTURE"]["del"] === "Y") { $arFields["PREVIEW_PICTURE"]["del"] = "Y"; } if ($arDef["FROM_DETAIL"] === "Y" && ($arFields["PREVIEW_PICTURE"]["size"] <= 0 || $arDef["UPDATE_WITH_DETAIL"] === "Y") && is_array($arFields["DETAIL_PICTURE"]) && $arFields["DETAIL_PICTURE"]["size"] > 0) { if ($arFields["PREVIEW_PICTURE"]["del"] !== "Y" && $arDef["UPDATE_WITH_DETAIL"] !== "Y") { $rsElement = CIBlockElement::GetList(array("ID" => "DESC"), array("ID" => $ar_wf_element["ID"], "IBLOCK_ID" => $ar_wf_element["IBLOCK_ID"], "SHOW_HISTORY" => "Y"), false, false, array("ID", "PREVIEW_PICTURE")); $arOldElement = $rsElement->Fetch(); } else { $arOldElement = false; } if (!$arOldElement || !$arOldElement["PREVIEW_PICTURE"]) { $arNewPreview = $arFields["DETAIL_PICTURE"]; $arNewPreview["COPY_FILE"] = "Y"; $arNewPreview["description"] = $arFields["PREVIEW_PICTURE"]["description"]; $arFields["PREVIEW_PICTURE"] = $arNewPreview; } } if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arFields["PREVIEW_PICTURE"]["size"] > 0 && $arDef["SCALE"] === "Y") { $arNewPicture = CIBlock::ResizePicture($arFields["PREVIEW_PICTURE"], $arDef); if (is_array($arNewPicture)) { $arNewPicture["description"] = $arFields["PREVIEW_PICTURE"]["description"]; $arFields["PREVIEW_PICTURE"] = $arNewPicture; } elseif ($arDef["IGNORE_ERRORS"] !== "Y") { unset($arFields["PREVIEW_PICTURE"]); $strWarning .= GetMessage("IBLOCK_FIELD_PREVIEW_PICTURE") . ": " . $arNewPicture . "<br>"; } } if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arDef["USE_WATERMARK_FILE"] === "Y") { if (strlen($arFields["PREVIEW_PICTURE"]["tmp_name"]) > 0 && ($arFields["PREVIEW_PICTURE"]["tmp_name"] === $arFields["DETAIL_PICTURE"]["tmp_name"] || $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["PREVIEW_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["PREVIEW_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["PREVIEW_PICTURE"]["tmp_name"], $tmp_name); $arFields["PREVIEW_PICTURE"]["copy"] = true; $arFields["PREVIEW_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["PREVIEW_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_FILE_POSITION"], "type" => "file", "size" => "real", "alpha_level" => 100 - min(max($arDef["WATERMARK_FILE_ALPHA"], 0), 100), "file" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_FILE"]))); } if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arDef["USE_WATERMARK_TEXT"] === "Y") { if (strlen($arFields["PREVIEW_PICTURE"]["tmp_name"]) > 0 && ($arFields["PREVIEW_PICTURE"]["tmp_name"] === $arFields["DETAIL_PICTURE"]["tmp_name"] || $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["PREVIEW_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["PREVIEW_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["PREVIEW_PICTURE"]["tmp_name"], $tmp_name); $arFields["PREVIEW_PICTURE"]["copy"] = true; $arFields["PREVIEW_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["PREVIEW_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_TEXT_POSITION"], "type" => "text", "coefficient" => $arDef["WATERMARK_TEXT_SIZE"], "text" => $arDef["WATERMARK_TEXT"], "font" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_TEXT_FONT"]), "color" => $arDef["WATERMARK_TEXT_COLOR"])); } $arDef = $arIBlock["FIELDS"]["DETAIL_PICTURE"]["DEFAULT_VALUE"]; if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["SCALE"] === "Y") { $arNewPicture = CIBlock::ResizePicture($arFields["DETAIL_PICTURE"], $arDef); if (is_array($arNewPicture)) { $arNewPicture["description"] = $arFields["DETAIL_PICTURE"]["description"]; $arFields["DETAIL_PICTURE"] = $arNewPicture; } elseif ($arDef["IGNORE_ERRORS"] !== "Y") { unset($arFields["DETAIL_PICTURE"]); $strWarning .= GetMessage("IBLOCK_FIELD_DETAIL_PICTURE") . ": " . $arNewPicture . "<br>"; } } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["USE_WATERMARK_FILE"] === "Y") { if (strlen($arFields["DETAIL_PICTURE"]["tmp_name"]) > 0 && ($arFields["DETAIL_PICTURE"]["tmp_name"] === $arFields["PREVIEW_PICTURE"]["tmp_name"] || $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["DETAIL_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["DETAIL_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["DETAIL_PICTURE"]["tmp_name"], $tmp_name); $arFields["DETAIL_PICTURE"]["copy"] = true; $arFields["DETAIL_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["DETAIL_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_FILE_POSITION"], "type" => "file", "size" => "real", "alpha_level" => 100 - min(max($arDef["WATERMARK_FILE_ALPHA"], 0), 100), "file" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_FILE"]))); } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["USE_WATERMARK_TEXT"] === "Y") { if (strlen($arFields["DETAIL_PICTURE"]["tmp_name"]) > 0 && ($arFields["DETAIL_PICTURE"]["tmp_name"] === $arFields["PREVIEW_PICTURE"]["tmp_name"] || $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["DETAIL_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["DETAIL_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["DETAIL_PICTURE"]["tmp_name"], $tmp_name); $arFields["DETAIL_PICTURE"]["copy"] = true; $arFields["DETAIL_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["DETAIL_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_TEXT_POSITION"], "type" => "text", "coefficient" => $arDef["WATERMARK_TEXT_SIZE"], "text" => $arDef["WATERMARK_TEXT"], "font" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_TEXT_FONT"]), "color" => $arDef["WATERMARK_TEXT_COLOR"])); } } $ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($ar_element["IBLOCK_ID"], $ar_element["ID"]); if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"])) { if (strlen($arFields["PREVIEW_PICTURE"]["name"]) <= 0 && strlen($arFields["PREVIEW_PICTURE"]["del"]) <= 0 && !is_set($arFields["PREVIEW_PICTURE"], "description")) { unset($arFields["PREVIEW_PICTURE"]); } else { $arFields["PREVIEW_PICTURE"]["MODULE_ID"] = "iblock"; $arFields["PREVIEW_PICTURE"]["old_file"] = $ar_wf_element["PREVIEW_PICTURE"]; $arFields["PREVIEW_PICTURE"]["name"] = \Bitrix\Iblock\Template\Helper::makeFileName($ipropTemplates, "ELEMENT_PREVIEW_PICTURE_FILE_NAME", array_merge($ar_element, $arFields), $arFields["PREVIEW_PICTURE"]); } } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"])) { if (strlen($arFields["DETAIL_PICTURE"]["name"]) <= 0 && strlen($arFields["DETAIL_PICTURE"]["del"]) <= 0 && !is_set($arFields["DETAIL_PICTURE"], "description")) { unset($arFields["DETAIL_PICTURE"]); } else { $arFields["DETAIL_PICTURE"]["MODULE_ID"] = "iblock"; $arFields["DETAIL_PICTURE"]["old_file"] = $ar_wf_element["DETAIL_PICTURE"]; $arFields["DETAIL_PICTURE"]["name"] = \Bitrix\Iblock\Template\Helper::makeFileName($ipropTemplates, "ELEMENT_DETAIL_PICTURE_FILE_NAME", array_merge($ar_element, $arFields), $arFields["DETAIL_PICTURE"]); } } if (is_set($arFields, "DATE_ACTIVE_FROM")) { $arFields["ACTIVE_FROM"] = $arFields["DATE_ACTIVE_FROM"]; } if (is_set($arFields, "DATE_ACTIVE_TO")) { $arFields["ACTIVE_TO"] = $arFields["DATE_ACTIVE_TO"]; } if (is_set($arFields, "EXTERNAL_ID")) { $arFields["XML_ID"] = $arFields["EXTERNAL_ID"]; } $PREVIEW_tmp = is_set($arFields, "PREVIEW_TEXT") ? $arFields["PREVIEW_TEXT"] : $ar_wf_element["PREVIEW_TEXT"]; $PREVIEW_TYPE_tmp = is_set($arFields, "PREVIEW_TEXT_TYPE") ? $arFields["PREVIEW_TEXT_TYPE"] : $ar_wf_element["PREVIEW_TEXT_TYPE"]; $DETAIL_tmp = is_set($arFields, "DETAIL_TEXT") ? $arFields["DETAIL_TEXT"] : $ar_wf_element["DETAIL_TEXT"]; $DETAIL_TYPE_tmp = is_set($arFields, "DETAIL_TEXT_TYPE") ? $arFields["DETAIL_TEXT_TYPE"] : $ar_wf_element["DETAIL_TEXT_TYPE"]; $arFields["SEARCHABLE_CONTENT"] = ToUpper((is_set($arFields, "NAME") ? $arFields["NAME"] : $ar_wf_element["NAME"]) . "\r\n" . ($PREVIEW_TYPE_tmp == "html" ? HTMLToTxt($PREVIEW_tmp) : $PREVIEW_tmp) . "\r\n" . ($DETAIL_TYPE_tmp == "html" ? HTMLToTxt($DETAIL_tmp) : $DETAIL_tmp)); if (is_set($arFields["IBLOCK_SECTION_ID"]) && !is_set($arFields, "IBLOCK_SECTION")) { $arFields["IBLOCK_SECTION"] = array($arFields["IBLOCK_SECTION_ID"]); } $arFields["IBLOCK_ID"] = $ar_element["IBLOCK_ID"]; if (!$this->CheckFields($arFields, $ID, $bCheckDiskQuota) || strlen($strWarning)) { $this->LAST_ERROR .= $strWarning; $Result = false; $arFields["RESULT_MESSAGE"] =& $this->LAST_ERROR; } else { unset($arFields["ID"]); if (array_key_exists("PREVIEW_PICTURE", $arFields)) { $SAVED_PREVIEW_PICTURE = $arFields["PREVIEW_PICTURE"]; } else { $SAVED_PREVIEW_PICTURE = false; } if (array_key_exists("DETAIL_PICTURE", $arFields)) { $SAVED_DETAIL_PICTURE = $arFields["DETAIL_PICTURE"]; } else { $SAVED_DETAIL_PICTURE = false; } // edit was done in workflow mode if ($bWorkFlow) { $arFields["WF_PARENT_ELEMENT_ID"] = $ID; if (array_key_exists("PREVIEW_PICTURE", $arFields)) { if (is_array($arFields["PREVIEW_PICTURE"])) { if (strlen($arFields["PREVIEW_PICTURE"]["name"]) <= 0 && strlen($arFields["PREVIEW_PICTURE"]["del"]) <= 0) { if (array_key_exists("description", $arFields["PREVIEW_PICTURE"])) { $arFile = CFile::GetFileArray($ar_wf_element["PREVIEW_PICTURE"]); if ($arFields["PREVIEW_PICTURE"]["description"] != $arFile["DESCRIPTION"]) { //Description updated, so it's new file $arNewFile = CFile::MakeFileArray($ar_wf_element["PREVIEW_PICTURE"]); $arNewFile["description"] = $arFields["PREVIEW_PICTURE"]["description"]; $arNewFile["MODULE_ID"] = "iblock"; $arFields["PREVIEW_PICTURE"] = $arNewFile; } else { $arFields["PREVIEW_PICTURE"] = $ar_wf_element["PREVIEW_PICTURE"]; } } else { //File was not changed at all $arFields["PREVIEW_PICTURE"] = $ar_wf_element["PREVIEW_PICTURE"]; } } else { unset($arFields["PREVIEW_PICTURE"]["old_file"]); } } } else { $arFields["PREVIEW_PICTURE"] = $ar_wf_element["PREVIEW_PICTURE"]; } if (array_key_exists("DETAIL_PICTURE", $arFields)) { if (is_array($arFields["DETAIL_PICTURE"])) { if (strlen($arFields["DETAIL_PICTURE"]["name"]) <= 0 && strlen($arFields["DETAIL_PICTURE"]["del"]) <= 0) { if (array_key_exists("description", $arFields["DETAIL_PICTURE"])) { $arFile = CFile::GetFileArray($ar_wf_element["DETAIL_PICTURE"]); if ($arFields["DETAIL_PICTURE"]["description"] != $arFile["DESCRIPTION"]) { //Description updated, so it's new file $arNewFile = CFile::MakeFileArray($ar_wf_element["DETAIL_PICTURE"]); $arNewFile["description"] = $arFields["DETAIL_PICTURE"]["description"]; $arNewFile["MODULE_ID"] = "iblock"; $arFields["DETAIL_PICTURE"] = $arNewFile; } else { $arFields["DETAIL_PICTURE"] = $ar_wf_element["DETAIL_PICTURE"]; } } else { //File was not changed at all $arFields["DETAIL_PICTURE"] = $ar_wf_element["DETAIL_PICTURE"]; } } else { unset($arFields["DETAIL_PICTURE"]["old_file"]); } } } else { $arFields["DETAIL_PICTURE"] = $ar_wf_element["DETAIL_PICTURE"]; } $NID = $this->Add($arFields); if ($NID > 0) { if ($arFields["WF_STATUS_ID"] == 1) { $DB->Query("UPDATE b_iblock_element SET TIMESTAMP_X=TIMESTAMP_X, WF_NEW=null WHERE ID=" . $ID); $DB->Query("UPDATE b_iblock_element SET TIMESTAMP_X=TIMESTAMP_X, WF_NEW=null WHERE WF_PARENT_ELEMENT_ID=" . $ID); $ar_wf_element["WF_NEW"] = false; } if ($this->bWF_SetMove) { CIBlockElement::WF_SetMove($NID, $LAST_ID); } if ($ar_element["WF_STATUS_ID"] != 1 && $ar_wf_element["WF_STATUS_ID"] != $arFields["WF_STATUS_ID"] && $arFields["WF_STATUS_ID"] != 1) { $DB->Query("UPDATE b_iblock_element SET TIMESTAMP_X=TIMESTAMP_X, WF_STATUS_ID=" . $arFields["WF_STATUS_ID"] . " WHERE ID=" . $ID); } } //element was not published, so keep original if (is_set($arFields, "WF_STATUS_ID") && $arFields["WF_STATUS_ID"] != 1 && $ar_element["WF_STATUS_ID"] == 1 || !is_set($arFields, "WF_STATUS_ID") && $ar_wf_element["WF_STATUS_ID"] != 1) { CIBlockElement::WF_CleanUpHistoryCopies($ID); return true; } $arFields['WF_PARENT_ELEMENT_ID'] = false; $rs = $DB->Query("SELECT PREVIEW_PICTURE, DETAIL_PICTURE from b_iblock_element WHERE ID = " . $NID); $ar_new_element = $rs->Fetch(); } else { $ar_new_element = false; } if ($ar_new_element) { if (!intval($ar_new_element["PREVIEW_PICTURE"])) { $arFields["PREVIEW_PICTURE"] = false; } else { $arFields["PREVIEW_PICTURE"] = $ar_new_element["PREVIEW_PICTURE"]; } if (!intval($ar_new_element["DETAIL_PICTURE"])) { $arFields["DETAIL_PICTURE"] = false; } else { $arFields["DETAIL_PICTURE"] = $ar_new_element["DETAIL_PICTURE"]; } if (is_array($arFields["PROPERTY_VALUES"]) && count($arFields["PROPERTY_VALUES"]) > 0) { $i = 0; $db_prop = CIBlockProperty::GetList(array(), array("IBLOCK_ID" => $arFields["IBLOCK_ID"], "CHECK_PERMISSIONS" => "N", "PROPERTY_TYPE" => "F")); while ($arProp = $db_prop->Fetch()) { $i++; unset($arFields["PROPERTY_VALUES"][$arProp["CODE"]]); unset($arFields["PROPERTY_VALUES"][$arProp["ID"]]); $arFields["PROPERTY_VALUES"][$arProp["ID"]] = array(); } if ($i > 0) { //Delete previous files $props = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $ID, "sort", "asc", array("PROPERTY_TYPE" => "F", "EMPTY" => "N")); while ($arProp = $props->Fetch()) { $arFields["PROPERTY_VALUES"][$arProp["ID"]][$arProp['PROPERTY_VALUE_ID']] = array("VALUE" => array("del" => "Y"), "DESCRIPTION" => false); } //Add copy from history $arDup = array(); //This is cure for files duplication bug (just save element one more time) $props = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $NID, "sort", "asc", array("PROPERTY_TYPE" => "F", "EMPTY" => "N")); while ($arProp = $props->Fetch()) { if (!array_key_exists($arProp["VALUE"], $arDup)) { $arFields["PROPERTY_VALUES"][$arProp["ID"]][$arProp['PROPERTY_VALUE_ID']] = array("VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"]); $arDup[$arProp["VALUE"]] = true; //This is cure for files duplication bug } } } } } else { if (array_key_exists("PREVIEW_PICTURE", $arFields)) { CFile::SaveForDB($arFields, "PREVIEW_PICTURE", "iblock"); } if (array_key_exists("DETAIL_PICTURE", $arFields)) { CFile::SaveForDB($arFields, "DETAIL_PICTURE", "iblock"); } } unset($arFields["IBLOCK_ID"]); unset($arFields["WF_NEW"]); unset($arFields["IBLOCK_SECTION_ID"]); $bTimeStampNA = false; if (is_set($arFields, "TIMESTAMP_X") && ($arFields["TIMESTAMP_X"] === NULL || $arFields["TIMESTAMP_X"] === false)) { $bTimeStampNA = true; unset($arFields["TIMESTAMP_X"]); } $strUpdate = $DB->PrepareUpdate("b_iblock_element", $arFields, "iblock"); if (strlen($strUpdate) > 0) { $strUpdate .= ", "; } $strSql = "UPDATE b_iblock_element SET " . $strUpdate . ($bTimeStampNA ? "TIMESTAMP_X=TIMESTAMP_X" : "TIMESTAMP_X=now()") . " WHERE ID=" . $ID; $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); if (array_key_exists("PROPERTY_VALUES", $arFields) && is_array($arFields["PROPERTY_VALUES"]) && count($arFields["PROPERTY_VALUES"]) > 0) { CIBlockElement::SetPropertyValues($ID, $ar_element["IBLOCK_ID"], $arFields["PROPERTY_VALUES"]); } if (is_set($arFields, "IBLOCK_SECTION")) { CIBlockElement::SetElementSection($ID, $arFields["IBLOCK_SECTION"], false, $arIBlock["RIGHTS_MODE"] === "E" ? $arIBlock["ID"] : 0); } if ($arIBlock["RIGHTS_MODE"] === "E") { $obElementRights = new CIBlockElementRights($arIBlock["ID"], $ID); if (array_key_exists("RIGHTS", $arFields) && is_array($arFields["RIGHTS"])) { $obElementRights->SetRights($arFields["RIGHTS"]); } } if (array_key_exists("IPROPERTY_TEMPLATES", $arFields)) { $ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($arIBlock["ID"], $ID); $ipropTemplates->set($arFields["IPROPERTY_TEMPLATES"]); } if ($bUpdateSearch) { CIBlockElement::UpdateSearch($ID, true); } if ($bWorkFlow) { CIBlockElement::WF_CleanUpHistoryCopies($ID); } //Restore saved values if ($SAVED_PREVIEW_PICTURE !== false) { $arFields["PREVIEW_PICTURE_ID"] = $arFields["PREVIEW_PICTURE"]; $arFields["PREVIEW_PICTURE"] = $SAVED_PREVIEW_PICTURE; } else { unset($arFields["PREVIEW_PICTURE"]); } if ($SAVED_DETAIL_PICTURE !== false) { $arFields["DETAIL_PICTURE_ID"] = $arFields["DETAIL_PICTURE"]; $arFields["DETAIL_PICTURE"] = $SAVED_DETAIL_PICTURE; } else { unset($arFields["DETAIL_PICTURE"]); } if ($arIBlock["FIELDS"]["LOG_ELEMENT_EDIT"]["IS_REQUIRED"] == "Y") { $USER_ID = is_object($USER) ? intval($USER->GetID()) : 0; $arEvents = GetModuleEvents("main", "OnBeforeEventLog", true); if (empty($arEvents) || ExecuteModuleEventEx($arEvents[0], array($USER_ID)) === false) { $rsElement = CIBlockElement::GetList(array(), array("=ID" => $ID, "CHECK_PERMISSIONS" => "N", "SHOW_NEW" => "Y"), false, false, array("ID", "NAME", "LIST_PAGE_URL", "CODE")); $arElement = $rsElement->GetNext(); $res = array("ID" => $ID, "CODE" => $arElement["CODE"], "NAME" => $arElement["NAME"], "ELEMENT_NAME" => $arIBlock["ELEMENT_NAME"], "USER_ID" => $USER_ID, "IBLOCK_PAGE_URL" => $arElement["LIST_PAGE_URL"]); CEventLog::Log("IBLOCK", "IBLOCK_ELEMENT_EDIT", "iblock", $arIBlock["ID"], serialize($res)); } } $Result = true; /************* QUOTA *************/ $_SESSION["SESS_RECOUNT_DB"] = "Y"; /************* QUOTA *************/ } $arFields["ID"] = $ID; $arFields["IBLOCK_ID"] = $ar_element["IBLOCK_ID"]; $arFields["RESULT"] =& $Result; if (isset($arFields["PREVIEW_PICTURE"]) && $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && $arFields["PREVIEW_PICTURE"]["copy"]) { @unlink($arFields["PREVIEW_PICTURE"]["tmp_name"]); @rmdir(dirname($arFields["PREVIEW_PICTURE"]["tmp_name"])); } if (isset($arFields["DETAIL_PICTURE"]) && $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && $arFields["DETAIL_PICTURE"]["copy"]) { @unlink($arFields["DETAIL_PICTURE"]["tmp_name"]); @rmdir(dirname($arFields["DETAIL_PICTURE"]["tmp_name"])); } foreach (GetModuleEvents("iblock", "OnAfterIBlockElementUpdate", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array(&$arFields)); } if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->ClearByTag("iblock_id_" . $arIBlock["ID"]); } return $Result; }
function ShowHTMLEditControl($name, $content, $arParams = array()) { global $USER; // We have to avoid of showing HTML-editor with probably unsecure content when loosing the session [mantis:#0007986] if ($_SERVER["REQUEST_METHOD"] == "POST" && !check_bitrix_sessid()) { return; } CUtil::InitJSCore(array('window', 'ajax')); $relPath = isset($arParams["path"]) ? $arParams["path"] : "/"; $site = isset($arParams["site"]) ? $arParams["site"] : ""; $__path = Rel2Abs("/", $relPath); $site = CFileMan::__CheckSite($site); $name = preg_replace("/[^a-zA-Z0-9_:\\.]/is", "", $name); if (!isset($arParams["limit_php_access"])) { $arParams["limit_php_access"] = false; } $arParams["light_mode"] = defined('BX_PUBLIC_MODE') && BX_PUBLIC_MODE == 1 || isset($arParams["light_mode"]) && $arParams["light_mode"] == 'Y'; $io = CBXVirtualIo::GetInstance(); $direction_rtl = false; if ($site) { $DOC_ROOT = CSite::GetSiteDocRoot($site); $abs_path = $DOC_ROOT . $__path; if ($io->FileExists($abs_path)) { $relPath = substr($relPath, 0, strrpos($relPath, "/")); if ($relPath == "") { $relPath = "/"; } } } static $bFirstUsed; $template = $arParams["templateID"]; if (!isset($template) && defined('SITE_TEMPLATE_ID')) { $template = SITE_TEMPLATE_ID; } if (!isset($template) && isset($_GET['siteTemplateId'])) { $template = $_GET['siteTemplateId']; } if (!isset($template) && isset($site)) { $dbSiteRes = CSite::GetTemplateList($site); $SITE_TEMPLATE = array(); while ($arSiteRes = $dbSiteRes->Fetch()) { if ($arSiteRes['CONDITION'] == "" || !isset($template)) { $template = $arSiteRes['TEMPLATE']; } } } if (isset($arParams['use_editor_3'])) { $useEditor3 = $arParams['use_editor_3'] == "Y"; } else { $useEditor3 = COption::GetOptionString('fileman', "use_editor_3", "Y") == "Y"; } if ($useEditor3) { $Editor = new CHTMLEditor(); $Editor->Show(array('name' => $name, 'id' => $name, 'siteId' => $arParams["site"], 'width' => $arParams["width"], 'height' => $arParams["height"], 'content' => $content, 'bAllowPhp' => !$arParams["bWithoutPHP"] && $USER->CanDoOperation('edit_php'), "limitPhpAccess" => $arParams["limit_php_access"], "display" => $arParams['bDisplay'], "componentFilter" => isset($arParams['componentFilter']) ? $arParams['componentFilter'] : false, "setFocusAfterShow" => isset($arParams['setFocusAfterShow']) ? $arParams['setFocusAfterShow'] : true, "relPath" => $relPath, "templateId" => $template)); return; } //Taskbars $arTaskbars = isset($arParams["arTaskbars"]) ? $arParams["arTaskbars"] : array(); //Toolbars $arToolbars = isset($arParams["arToolbars"]) ? $arParams["arToolbars"] : false; // Toolbar config $arParams["toolbarConfig"] = is_array($arParams["toolbarConfig"]) ? $arParams["toolbarConfig"] : false; $arParams["use_advanced_php_parser"] = COption::GetOptionString("fileman", "use_advanced_php_parser", "Y"); $arParams["ar_entities"] = COption::GetOptionString("fileman", "ar_entities", 'umlya,greek,other'); if ($arParams["ar_entities"] == 'none') { $arParams["ar_entities"] = ''; } if (!isset($arParams["usePspell"])) { $arParams["usePspell"] = COption::GetOptionString("fileman", "use_pspell", "N"); } if (!isset($arParams["useCustomSpell"])) { $arParams["useCustomSpell"] = COption::GetOptionString("fileman", "use_custom_spell", "Y"); } $arParams['allowRenderComp2'] = COption::GetOptionString('fileman', "allow_render_components", "N") == 'Y'; $arParams['renderComponents'] = $arParams['allowRenderComp2'] && CUserOptions::GetOption('fileman', "render_components", "Y") == 'Y'; $lca = COption::GetOptionString("fileman", "use_lca", "N"); $styleList_render_style = COption::GetOptionString("fileman", "render_styles_in_classlist", "Y") == 'Y' ? 'true' : 'false'; $arAdditionalParams = isset($arParams["arAdditionalParams"]) ? $arParams["arAdditionalParams"] : array(); $arResult = CFileman::GetAllTemplateParams($template, $site, $arParams["bWithoutPHP"] != true, $arAdditionalParams); $arParams["TEMPLATE"] = $arResult; if ($bUseOnlyDefinedStyles && !is_set($arResult, "STYLES_TITLE")) { $bUseOnlyDefinedStyles = false; } $arParams["body_class"] = COption::GetOptionString("fileman", "editor_body_class", ""); $arParams["body_id"] = COption::GetOptionString("fileman", "editor_body_id", ""); ?> <script bxrunfirst="true"> var relPath = "<?php echo CUtil::JSEscape($relPath); ?> "; var <?php echo 'ar_' . $name . '_taskbars'; ?> = {}; <?php for ($k = 0, $l = count($arTaskbars); $k < $l; $k++) { echo 'ar_' . $name . '_taskbars["' . $arTaskbars[$k] . '"] = true;'; } if ($arToolbars !== false) { echo 'var ar_' . $name . '_toolbars = {};'; for ($k = 0, $l = count($arToolbars); $k < $l; $k++) { echo 'ar_' . $name . '_toolbars["' . $arToolbars[$k] . '"] = true;'; } } else { echo 'var ar_' . $name . '_toolbars = false;'; } ?> window.ar_<?php echo $name; ?> _config = <?php echo CUtil::PhpToJSObject($arParams); ?> ; // editor-config </script> <?php $str_taskbars = ""; CFileman::GetHTMLEditorSettings($name, $arParams["light_mode"], $arTaskbars, $str_taskbars); $str_taskbars .= '_' . CFileman::GetVersion(); if (!$bFirstUsed) { $arTemplates = array(array('value' => '.default', 'name' => GetMessage("FILEMAN_DEFTEMPL"))); $db_site_templates = CSiteTemplate::GetList(array(), array(), array()); while ($ar_site_templates = $db_site_templates->Fetch()) { $arTemplates[] = array('value' => $ar_site_templates['ID'], 'name' => $ar_site_templates['NAME']); } ?> <script bxrunfirst="true"> var arBXTemplates = <?php echo CUtil::PhpToJSObject($arTemplates); ?> , BXSite = "<?php echo CUtil::JSEscape($site); ?> ", BXLang = "<?php echo CUtil::JSEscape(LANGUAGE_ID); ?> ", styleList_render_style = <?php echo $styleList_render_style; ?> , limit_php_access = <?php echo $arParams["limit_php_access"] ? 'true' : 'false'; ?> , lca = <?php echo $lca == 'Y' ? 'true' : 'false'; ?> , lightMode = <?php echo $arParams["light_mode"] ? 'true' : 'false'; ?> , BX_PERSONAL_ROOT = "<?php echo BX_PERSONAL_ROOT; ?> "; window.limit_php_access = top.limit_php_access = limit_php_access; window.lightMode = top.lightMode = lightMode; window.lca = top.lca = lca; window.BXLang = top.BXLang = BXLang; window.BXSite = top.BXSite = BXSite; window.BX_PERSONAL_ROOT = top.BX_PERSONAL_ROOT = BX_PERSONAL_ROOT; </script> <?php $arJS = array(); $arCSS = array(); $events = GetModuleEvents("fileman", "OnBeforeHTMLEditorScriptsGet"); while ($arEvent = $events->Fetch()) { $tmp = ExecuteModuleEventEx($arEvent, array($name, $arParams)); if (!is_array($tmp)) { continue; } if (is_array($tmp['JS'])) { $arJS = array_merge($arJS, $tmp['JS']); } if (is_array($tmp['CSS'])) { $arCSS = array_merge($arCSS, $tmp['CSS']); } } $arr = array(); // Additional JS files from event OnBeforeHtmlEditorScriptGet for ($i = 0, $c = count($arJS); $i < $c; $i++) { $arJS[$i] = preg_replace("/[^a-zA-Z0-9_:\\.]/is", "", $arJS[$i]); if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/admin/htmleditor2/' . $arJS[$i])) { $arr[] = $arJS[$i]; } } ?> <script type="text/javascript" src="/bitrix/admin/fileman_js.php?lang=<?php echo LANGUAGE_ID; ?> &v=<?php echo @filemtime($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/fileman/lang/' . LANGUAGE_ID . '/admin/fileman_js.php'); ?> "></script> <script type="text/javascript" src="/bitrix/admin/fileman_common_js.php?s=<?php echo $str_taskbars; ?> "></script> <?php for ($i = 0, $l = count($arr); $i < $l; $i++) { $script_filename = $arr[$i]; ?> <script type="text/javascript" src="/bitrix/admin/htmleditor2/<?php echo $script_filename; ?> ?v=<?php echo @filemtime($_SERVER['DOCUMENT_ROOT'] . '/bitrix/admin/htmleditor2/' . $script_filename); ?> "></script><?php } ?> <script type="text/javascript" src="/bitrix/js/main/popup_menu.js?v=<?php echo @filemtime($_SERVER['DOCUMENT_ROOT'] . '/bitrix/js/main/popup_menu.js'); ?> "></script> <?php for ($i = 0, $l = count($arCSS); $i < $l; $i++) { $arCSS[$i] = preg_replace("/[^a-zA-Z0-9_:\\.]/is", "", $arCSS[$i]); if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/admin/htmleditor2/' . $arCSS[$i])) { continue; } ?> <link rel="stylesheet" type="text/css" href="/bitrix/admin/htmleditor2/<?php echo $arCSS[$i]; ?> ?v=<?php echo @filemtime($_SERVER['DOCUMENT_ROOT'] . '/bitrix/admin/htmleditor2/' . $arCSS[$i]); ?> "/><?php } $db_events = GetModuleEvents("fileman", "OnIncludeHTMLEditorScript"); while ($arEvent = $db_events->Fetch()) { ExecuteModuleEventEx($arEvent); } $bFirstUsed = true; } ?> <div class="bxedmain-cont" id="<?php echo $name . '_object'; ?> "><table id="<?php echo $name; ?> _pFrame" class="bxedmainframe dim100x100" style="display:none;"> <tr style="height: 1%;"><td id="<?php echo $name; ?> _toolBarSet0" colspan="2" style="width: 100%; display: none; border-bottom: 1px solid #808080 !important;"></td></tr> <tr> <td id="<?php echo $name; ?> _toolBarSet1" style="width:0%; display: none; border-right: 1px solid #808080 !important;"></td> <td vAlign="top" style="width: 4000px; padding: 0!important;"> <table class="dim100x100"> <tr> <td class="bx-ceditor" id="<?php echo $name; ?> _cEditor"></td> <td id="<?php echo $name; ?> _taskBarSet2" class="bxedtaskbarset" style="width:0%; display: none;"> <table> <tr><td class="bx-move-col-v" rowSpan="3"><img src="/bitrix/images/1.gif" /></td><td style="height:26px;"></td></tr> <tr><td style="vertical-align: top;"></td></tr> <tr><td class="bx-taskbar-tabs"></td></tr> </table> </td> </tr> <tr style="height:0%; display: none;"> <td id="<?php echo $name; ?> _taskBarSet3" colspan="2"> <table> <tr><td class="bx-move-col-h"><img src="/bitrix/images/1.gif" /></td></tr> <tr><td style="height:26px;"></td></tr> <tr><td style="vertical-align: top; background: #F4F4F4 none !important;"></td></tr> <tr><td class="bx-taskbar-tabs"></td></tr> </table> </td> </tr> </table> </td> </tr> <tr id="bx-css-tt"><td id="<?php echo $name; ?> _taskBarTabs" colspan="2" class="tasktabcell"></td></tr> </table> </div> <script> BX.loadCSS('/bitrix/admin/htmleditor2/editor.css'); var bEd = BX("bxed_<?php echo $name; ?> _editor"); if (bEd && !bEd.checked) BX("<?php echo $name; ?> _object").style.display = "none"; </script> <?php if (!$arParams["bFromTextarea"]) { echo '<input type="hidden" name="' . $name . '" id="bxed_' . $name . '" value="' . htmlspecialcharsbx($content) . '">'; } if ($arParams["bDisplay"] !== false) { setEditorEventHandlers($name); ?> <script> BX.ready(function(){ BX.showWait(); BX("bxed_<?php echo $name; ?> ").pMainObj = new BXHTMLEditor("<?php echo $name; ?> "); }); </script> <?php } }
public function RecalcMenu($bMultiSelect = false, $bCheckSelected = true) { if ($this->bMenuCalc !== false) { return true; } /** * @global CAllMain $APPLICATION * @global CCacheManager $CACHE_MANAGER * @noinspection PhpUnusedLocalVariableInspection */ global $USER, $DB, $APPLICATION, $CACHE_MANAGER; $result = array(); $cur_page = $APPLICATION->GetCurPage(true); $cur_page_no_index = $APPLICATION->GetCurPage(false); $APPLICATION->_menu_recalc_counter++; $this->bMenuCalc = true; if (strlen($this->template) > 0 && file_exists($_SERVER["DOCUMENT_ROOT"] . $this->template)) { $this->MenuTemplate = $_SERVER["DOCUMENT_ROOT"] . $this->template; } else { if (defined("SITE_TEMPLATE_PATH") && file_exists($_SERVER["DOCUMENT_ROOT"] . SITE_TEMPLATE_PATH . "/" . $this->type . ".menu_template.php")) { $this->template = SITE_TEMPLATE_PATH . "/" . $this->type . ".menu_template.php"; $this->MenuTemplate = $_SERVER["DOCUMENT_ROOT"] . $this->template; } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/" . LANG . "/" . $this->type . ".menu_template.php")) { $this->template = BX_PERSONAL_ROOT . "/php_interface/" . LANG . "/" . $this->type . ".menu_template.php"; $this->MenuTemplate = $_SERVER["DOCUMENT_ROOT"] . $this->template; } else { $this->template = BX_PERSONAL_ROOT . "/templates/.default/" . $this->type . ".menu_template.php"; $this->MenuTemplate = $_SERVER["DOCUMENT_ROOT"] . $this->template; } } if (!file_exists($this->MenuTemplate)) { $this->LAST_ERROR = "Template " . $this->MenuTemplate . " is not found."; return false; } $arMenuCache = false; $bCached = false; $bCacheIsAllowed = CACHED_menu !== false && !$USER->IsAuthorized() && !$this->MenuExtDir; if ($bCacheIsAllowed) { $cache_id = $_SERVER["DOCUMENT_ROOT"] . "," . $this->MenuDir . "," . $this->MenuExtDir . "," . $this->type; if ($CACHE_MANAGER->Read(CACHED_menu, $cache_id, "menu")) { $arMenuCache = $CACHE_MANAGER->Get($cache_id); $bCached = true; } } $arUserRights = $USER->GetAccessCodes(); $ITEM_INDEX = -1; $cur_selected = -1; $cur_selected_len = -1; $previousDepthLevel = -1; $arParents = array(); //Stack of menu items foreach ($this->arMenu as $iMenuItem => $MenuItem) { $TEXT = $MenuItem[0]; if ($bCached) { $LINK = $arMenuCache[$iMenuItem]["LINK"]; } else { //if the link is relative let's transform it to absolute if (!preg_match("'^(([A-Za-z]+://)|mailto:|javascript:|#)'i", $MenuItem[1])) { $LINK = Rel2Abs($this->MenuDir, $MenuItem[1]); } else { $LINK = $MenuItem[1]; } $arMenuCache[$iMenuItem]["LINK"] = $LINK; } $bSkipMenuItem = false; $ADDITIONAL_LINKS = $MenuItem[2]; $PARAMS = $MenuItem[3]; //Calculate menu items stack for iblock items only if ($this->MenuExtDir && is_array($PARAMS) && isset($PARAMS["FROM_IBLOCK"])) { if ($previousDepthLevel == -1) { $previousDepthLevel = $PARAMS["DEPTH_LEVEL"]; } if ($PARAMS["DEPTH_LEVEL"] > $previousDepthLevel) { //Deeper into sections tree if ($iMenuItem > 0) { $arParents[] = array("INDEX" => $iMenuItem - 1, "DEPTH_LEVEL" => $PARAMS["DEPTH_LEVEL"]); } } else { //Unwind parents stack while (count($arParents) > 0 && $arParents[count($arParents) - 1]["DEPTH_LEVEL"] > $PARAMS["DEPTH_LEVEL"]) { array_pop($arParents); } } $previousDepthLevel = $PARAMS["DEPTH_LEVEL"]; } elseif ($previousDepthLevel != -1) { //End of tree, so reset the stack $previousDepthLevel = -1; $arParents = array(); } if (count($MenuItem) > 4) { $CONDITION = $MenuItem[4]; if (strlen($CONDITION) > 0 && !eval("return " . $CONDITION . ";")) { $bSkipMenuItem = true; } } if (!$bSkipMenuItem) { $ITEM_INDEX++; } if (($pos = strpos($LINK, "?")) !== false) { $ITEM_TYPE = "U"; } elseif (substr($LINK, -1) == "/") { $ITEM_TYPE = "D"; } else { $ITEM_TYPE = "P"; } $SELECTED = false; if ($bCached) { $all_links = $arMenuCache[$iMenuItem]["LINKS"]; if (!is_array($all_links)) { $all_links = array(); } } else { $all_links = array(); if (is_array($ADDITIONAL_LINKS)) { foreach ($ADDITIONAL_LINKS as $link) { $tested_link = trim(Rel2Abs($this->MenuDir, $link)); if (strlen($tested_link) > 0) { $all_links[] = $tested_link; } } } $all_links[] = $LINK; $arMenuCache[$iMenuItem]["LINKS"] = $all_links; } if (preg_match("'^(([A-Za-z]+://)|mailto:|javascript:|#)'i", $MenuItem[1])) { $PERMISSION = "Z"; } else { if (!$bSkipMenuItem && $bCheckSelected) { foreach ($all_links as $tested_link) { if ($tested_link == '') { continue; } $SELECTED = self::IsItemSelected($tested_link, $cur_page, $cur_page_no_index); if ($SELECTED) { break; } } } if ($bCached) { $PERMISSION = $arMenuCache[$iMenuItem]["PERM"]; } else { $arMenuCache[$iMenuItem]["PERM"] = $PERMISSION = $APPLICATION->GetFileAccessPermission(GetFileFromURL($LINK), $arUserRights); } } if ($SELECTED && !$bMultiSelect) { /** @noinspection PhpUndefinedVariableInspection */ $new_len = strlen($tested_link); if ($new_len > $cur_selected_len) { if ($cur_selected !== -1) { $result[$cur_selected]['SELECTED'] = false; } $cur_selected = count($result); $cur_selected_len = $new_len; } else { $SELECTED = false; } } //Adjust selection for iblock sections tree if ($SELECTED && $this->MenuExtDir && is_array($PARAMS) && isset($PARAMS["FROM_IBLOCK"])) { foreach ($arParents as $parentMenuItem) { $parentIndex = $parentMenuItem["INDEX"]; if (is_array($result[$parentIndex]["PARAMS"]) && isset($result[$parentIndex]["PARAMS"]["FROM_IBLOCK"])) { $result[$parentIndex]["SELECTED"] = true; } } } if (!$bSkipMenuItem) { $r = array("TEXT" => $TEXT, "LINK" => $LINK, "SELECTED" => $SELECTED, "PERMISSION" => $PERMISSION, "ADDITIONAL_LINKS" => $ADDITIONAL_LINKS, "ITEM_TYPE" => $ITEM_TYPE, "ITEM_INDEX" => $ITEM_INDEX, "PARAMS" => $PARAMS); $result[] = $r; } } $this->arMenu = $result; if ($bCacheIsAllowed && !$bCached) { /** @noinspection PhpUndefinedVariableInspection */ $CACHE_MANAGER->Set($cache_id, $arMenuCache); } return true; }
$DB->Query("create table b_catalog_cml_tmp (\n\t\t\t\tID int(11) not null default '0',\n\t\t\t\tXML_ID varchar(100) not null,\n\t\t\t\tCATALOG_ID int(11) not null,\n\t\t\t\tVALUE_ID int(11),\n\t\t\t\tprimary key (CATALOG_ID, XML_ID),\n\t\t\t\tindex IXS_CAT_CML_TMP (ID))"); } } } /************************ END FUNCTIONS *******************************/ if (StrToUpper($DB->type) != "MYSQL") { $strImportErrorMessage .= GetMessage("CML_R_MYSQL_ONLY") . ". "; } if (strlen($strImportErrorMessage) <= 0) { $DATA_FILE_NAME = ""; if (isset($_FILES["FILE_1C"]) && is_uploaded_file($_FILES["FILE_1C"]["tmp_name"])) { $DATA_FILE_NAME = $_FILES["FILE_1C"]["tmp_name"]; } if (strlen($DATA_FILE_NAME) <= 0) { if (strlen($URL_FILE_1C) > 0) { $URL_FILE_1C = Rel2Abs("/", $URL_FILE_1C); if (file_exists($_SERVER["DOCUMENT_ROOT"] . $URL_FILE_1C) && is_file($_SERVER["DOCUMENT_ROOT"] . $URL_FILE_1C)) { $DATA_FILE_NAME = $_SERVER["DOCUMENT_ROOT"] . $URL_FILE_1C; } } } if (strlen($DATA_FILE_NAME) <= 0) { $strImportErrorMessage .= GetMessage("CICML_NO_LOAD_FILE") . "<br>"; } global $IBLOCK_TYPE_ID; $IBLOCK_TYPE_ID = trim(strval($IBLOCK_TYPE_ID)); if (0 < strlen($IBLOCK_TYPE_ID)) { $rsIBlockTypes = CIBlockType::GetByID($IBLOCK_TYPE_ID); if (!($arIBlockType = $rsIBlockTypes->Fetch())) { $IBLOCK_TYPE_ID = ''; }
function SetImageFilePath($relativePath) { $relativePath = Rel2Abs("/", $relativePath); if (is_dir($_SERVER["DOCUMENT_ROOT"] . $relativePath)) { $this->imageFilePath = rtrim($_SERVER["DOCUMENT_ROOT"] . $relativePath, "/"); } }
function GetPagePath($page=false, $get_index_page=null) { if (null === $get_index_page) { if (defined('BX_DISABLE_INDEX_PAGE')) $get_index_page = !BX_DISABLE_INDEX_PAGE; else $get_index_page = true; } if($page===false && $_SERVER["REQUEST_URI"]<>"") $page = $_SERVER["REQUEST_URI"]; if($page===false) $page = $_SERVER["SCRIPT_NAME"]; $found = strpos($page, "?"); $sPath = ($found !== false? substr($page, 0, $found) : $page); $sPath = urldecode($sPath); //Decoding UTF uri $sPath = CUtil::ConvertToLangCharset($sPath); if(substr($sPath, -1, 1) == "/" && $get_index_page) $sPath .= GetDirectoryIndex($sPath); static $aSearch = array("<", ">", "\"", "'"); static $aReplace = array("<", ">", """, "'"); $sPath = str_replace($aSearch, $aReplace, $sPath); return Rel2Abs("/", $sPath); }
function Add($arFields, $bWorkFlow = false, $bUpdateSearch = true, $bResizePictures = false) { global $DB, $USER; $arIBlock = CIBlock::GetArrayByID($arFields["IBLOCK_ID"]); $bWorkFlow = $bWorkFlow && is_array($arIBlock) && $arIBlock["WORKFLOW"] != "N" && CModule::IncludeModule("workflow"); $bBizProc = is_array($arIBlock) && $arIBlock["BIZPROC"] == "Y" && IsModuleInstalled("bizproc"); if (array_key_exists("BP_PUBLISHED", $arFields)) { if ($bBizProc) { if ($arFields["BP_PUBLISHED"] == "Y") { $arFields["WF_STATUS_ID"] = 1; $arFields["WF_NEW"] = false; } else { $arFields["WF_STATUS_ID"] = 2; $arFields["WF_NEW"] = "Y"; $arFields["BP_PUBLISHED"] = "N"; } } else { unset($arFields["BP_PUBLISHED"]); } } if (array_key_exists("IBLOCK_SECTION_ID", $arFields)) { if (!array_key_exists("IBLOCK_SECTION", $arFields)) { $arFields["IBLOCK_SECTION"] = array($arFields["IBLOCK_SECTION_ID"]); } elseif (is_array($arFields["IBLOCK_SECTION"]) && !in_array($arFields["IBLOCK_SECTION_ID"], $arFields["IBLOCK_SECTION"])) { unset($arFields["IBLOCK_SECTION_ID"]); } } $strWarning = ""; if ($bResizePictures) { $arDef = $arIBlock["FIELDS"]["PREVIEW_PICTURE"]["DEFAULT_VALUE"]; if ($arDef["FROM_DETAIL"] === "Y" && is_array($arFields["DETAIL_PICTURE"]) && $arFields["DETAIL_PICTURE"]["size"] > 0 && ($arDef["UPDATE_WITH_DETAIL"] === "Y" || $arFields["PREVIEW_PICTURE"]["size"] <= 0)) { $arNewPreview = $arFields["DETAIL_PICTURE"]; $arNewPreview["COPY_FILE"] = "Y"; if (isset($arFields["PREVIEW_PICTURE"]) && is_array($arFields["PREVIEW_PICTURE"]) && isset($arFields["PREVIEW_PICTURE"]["description"])) { $arNewPreview["description"] = $arFields["PREVIEW_PICTURE"]["description"]; } $arFields["PREVIEW_PICTURE"] = $arNewPreview; } if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arDef["SCALE"] === "Y") { $arNewPicture = CIBlock::ResizePicture($arFields["PREVIEW_PICTURE"], $arDef); if (is_array($arNewPicture)) { $arNewPicture["description"] = $arFields["PREVIEW_PICTURE"]["description"]; $arFields["PREVIEW_PICTURE"] = $arNewPicture; } elseif ($arDef["IGNORE_ERRORS"] !== "Y") { unset($arFields["PREVIEW_PICTURE"]); $strWarning .= GetMessage("IBLOCK_FIELD_PREVIEW_PICTURE") . ": " . $arNewPicture . "<br>"; } } if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arDef["USE_WATERMARK_FILE"] === "Y") { if (strlen($arFields["PREVIEW_PICTURE"]["tmp_name"]) > 0 && ($arFields["PREVIEW_PICTURE"]["tmp_name"] === $arFields["DETAIL_PICTURE"]["tmp_name"] || $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["PREVIEW_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["PREVIEW_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["PREVIEW_PICTURE"]["tmp_name"], $tmp_name); $arFields["PREVIEW_PICTURE"]["copy"] = true; $arFields["PREVIEW_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["PREVIEW_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_FILE_POSITION"], "type" => "file", "size" => "real", "alpha_level" => 100 - min(max($arDef["WATERMARK_FILE_ALPHA"], 0), 100), "file" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_FILE"]))); } if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arDef["USE_WATERMARK_TEXT"] === "Y") { if (strlen($arFields["PREVIEW_PICTURE"]["tmp_name"]) > 0 && ($arFields["PREVIEW_PICTURE"]["tmp_name"] === $arFields["DETAIL_PICTURE"]["tmp_name"] || $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["PREVIEW_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["PREVIEW_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["PREVIEW_PICTURE"]["tmp_name"], $tmp_name); $arFields["PREVIEW_PICTURE"]["copy"] = true; $arFields["PREVIEW_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["PREVIEW_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_TEXT_POSITION"], "type" => "text", "coefficient" => $arDef["WATERMARK_TEXT_SIZE"], "text" => $arDef["WATERMARK_TEXT"], "font" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_TEXT_FONT"]), "color" => $arDef["WATERMARK_TEXT_COLOR"])); } $arDef = $arIBlock["FIELDS"]["DETAIL_PICTURE"]["DEFAULT_VALUE"]; if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["SCALE"] === "Y") { $arNewPicture = CIBlock::ResizePicture($arFields["DETAIL_PICTURE"], $arDef); if (is_array($arNewPicture)) { $arNewPicture["description"] = $arFields["DETAIL_PICTURE"]["description"]; $arFields["DETAIL_PICTURE"] = $arNewPicture; } elseif ($arDef["IGNORE_ERRORS"] !== "Y") { unset($arFields["DETAIL_PICTURE"]); $strWarning .= GetMessage("IBLOCK_FIELD_DETAIL_PICTURE") . ": " . $arNewPicture . "<br>"; } } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["USE_WATERMARK_FILE"] === "Y") { if (strlen($arFields["DETAIL_PICTURE"]["tmp_name"]) > 0 && ($arFields["DETAIL_PICTURE"]["tmp_name"] === $arFields["PREVIEW_PICTURE"]["tmp_name"] || $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["DETAIL_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["DETAIL_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["DETAIL_PICTURE"]["tmp_name"], $tmp_name); $arFields["DETAIL_PICTURE"]["copy"] = true; $arFields["DETAIL_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["DETAIL_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_FILE_POSITION"], "type" => "file", "size" => "real", "alpha_level" => 100 - min(max($arDef["WATERMARK_FILE_ALPHA"], 0), 100), "file" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_FILE"]))); } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["USE_WATERMARK_TEXT"] === "Y") { if (strlen($arFields["DETAIL_PICTURE"]["tmp_name"]) > 0 && ($arFields["DETAIL_PICTURE"]["tmp_name"] === $arFields["PREVIEW_PICTURE"]["tmp_name"] || $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["DETAIL_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["DETAIL_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["DETAIL_PICTURE"]["tmp_name"], $tmp_name); $arFields["DETAIL_PICTURE"]["copy"] = true; $arFields["DETAIL_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["DETAIL_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_TEXT_POSITION"], "type" => "text", "coefficient" => $arDef["WATERMARK_TEXT_SIZE"], "text" => $arDef["WATERMARK_TEXT"], "font" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_TEXT_FONT"]), "color" => $arDef["WATERMARK_TEXT_COLOR"])); } } $ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($arFields["IBLOCK_ID"], 0); if (is_set($arFields, "PREVIEW_PICTURE")) { if (is_array($arFields["PREVIEW_PICTURE"])) { if (strlen($arFields["PREVIEW_PICTURE"]["name"]) <= 0 && strlen($arFields["PREVIEW_PICTURE"]["del"]) <= 0) { unset($arFields["PREVIEW_PICTURE"]); } else { $arFields["PREVIEW_PICTURE"]["MODULE_ID"] = "iblock"; $arFields["PREVIEW_PICTURE"]["name"] = \Bitrix\Iblock\Template\Helper::makeFileName($ipropTemplates, "ELEMENT_PREVIEW_PICTURE_FILE_NAME", $arFields, $arFields["PREVIEW_PICTURE"]); } } else { if (intval($arFields["PREVIEW_PICTURE"]) <= 0) { unset($arFields["PREVIEW_PICTURE"]); } } } if (is_set($arFields, "DETAIL_PICTURE")) { if (is_array($arFields["DETAIL_PICTURE"])) { if (strlen($arFields["DETAIL_PICTURE"]["name"]) <= 0 && strlen($arFields["DETAIL_PICTURE"]["del"]) <= 0) { unset($arFields["DETAIL_PICTURE"]); } else { $arFields["DETAIL_PICTURE"]["MODULE_ID"] = "iblock"; $arFields["DETAIL_PICTURE"]["name"] = \Bitrix\Iblock\Template\Helper::makeFileName($ipropTemplates, "ELEMENT_DETAIL_PICTURE_FILE_NAME", $arFields, $arFields["DETAIL_PICTURE"]); } } else { if (intval($arFields["DETAIL_PICTURE"]) <= 0) { unset($arFields["DETAIL_PICTURE"]); } } } if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") { $arFields["ACTIVE"] = "N"; } if (is_set($arFields, "PREVIEW_TEXT_TYPE") && $arFields["PREVIEW_TEXT_TYPE"] != "html") { $arFields["PREVIEW_TEXT_TYPE"] = "text"; } if (is_set($arFields, "DETAIL_TEXT_TYPE") && $arFields["DETAIL_TEXT_TYPE"] != "html") { $arFields["DETAIL_TEXT_TYPE"] = "text"; } if (is_set($arFields, "DATE_ACTIVE_FROM")) { $arFields["ACTIVE_FROM"] = $arFields["DATE_ACTIVE_FROM"]; } if (is_set($arFields, "DATE_ACTIVE_TO")) { $arFields["ACTIVE_TO"] = $arFields["DATE_ACTIVE_TO"]; } if (is_set($arFields, "EXTERNAL_ID")) { $arFields["XML_ID"] = $arFields["EXTERNAL_ID"]; } if ($bWorkFlow) { $arFields["WF"] = "Y"; if ($arFields["WF_STATUS_ID"] != 1) { $arFields["WF_NEW"] = "Y"; } else { $arFields["WF_NEW"] = ""; } } $arFields["SEARCHABLE_CONTENT"] = $arFields["NAME"]; if (isset($arFields["PREVIEW_TEXT"])) { if (isset($arFields["PREVIEW_TEXT_TYPE"]) && $arFields["PREVIEW_TEXT_TYPE"] == "html") { $arFields["SEARCHABLE_CONTENT"] .= "\r\n" . HTMLToTxt($arFields["PREVIEW_TEXT"]); } else { $arFields["SEARCHABLE_CONTENT"] .= "\r\n" . $arFields["PREVIEW_TEXT"]; } } if (isset($arFields["DETAIL_TEXT"])) { if (isset($arFields["DETAIL_TEXT_TYPE"]) && $arFields["DETAIL_TEXT_TYPE"] == "html") { $arFields["SEARCHABLE_CONTENT"] .= "\r\n" . HTMLToTxt($arFields["DETAIL_TEXT"]); } else { $arFields["SEARCHABLE_CONTENT"] .= "\r\n" . $arFields["DETAIL_TEXT"]; } } $arFields["SEARCHABLE_CONTENT"] = ToUpper($arFields["SEARCHABLE_CONTENT"]); if (!$this->CheckFields($arFields) || strlen($strWarning)) { $this->LAST_ERROR .= $strWarning; $Result = false; $arFields["RESULT_MESSAGE"] =& $this->LAST_ERROR; } else { if (array_key_exists("PREVIEW_PICTURE", $arFields)) { $SAVED_PREVIEW_PICTURE = $arFields["PREVIEW_PICTURE"]; if (is_array($arFields["PREVIEW_PICTURE"])) { CFile::SaveForDB($arFields, "PREVIEW_PICTURE", "iblock"); } if ($bWorkFlow) { $COPY_PREVIEW_PICTURE = $arFields["PREVIEW_PICTURE"]; } } if (array_key_exists("DETAIL_PICTURE", $arFields)) { $SAVED_DETAIL_PICTURE = $arFields["DETAIL_PICTURE"]; if (is_array($arFields["DETAIL_PICTURE"])) { CFile::SaveForDB($arFields, "DETAIL_PICTURE", "iblock"); } if ($bWorkFlow) { $COPY_DETAIL_PICTURE = $arFields["DETAIL_PICTURE"]; } } unset($arFields["ID"]); if (is_object($USER)) { if (!isset($arFields["CREATED_BY"]) || intval($arFields["CREATED_BY"]) <= 0) { $arFields["CREATED_BY"] = intval($USER->GetID()); } if (!isset($arFields["MODIFIED_BY"]) || intval($arFields["MODIFIED_BY"]) <= 0) { $arFields["MODIFIED_BY"] = intval($USER->GetID()); } } $arFields["~TIMESTAMP_X"] = $arFields["~DATE_CREATE"] = $DB->CurrentTimeFunction(); foreach (GetModuleEvents("iblock", "OnIBlockElementAdd", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($arFields)); } $IBLOCK_SECTION_ID = $arFields["IBLOCK_SECTION_ID"]; unset($arFields["IBLOCK_SECTION_ID"]); $ID = $DB->Add("b_iblock_element", $arFields, array("DETAIL_TEXT", "SEARCHABLE_CONTENT"), "iblock"); if (array_key_exists("PREVIEW_PICTURE", $arFields)) { $arFields["PREVIEW_PICTURE_ID"] = $arFields["PREVIEW_PICTURE"]; $arFields["PREVIEW_PICTURE"] = $SAVED_PREVIEW_PICTURE; } if (array_key_exists("DETAIL_PICTURE", $arFields)) { $arFields["DETAIL_PICTURE_ID"] = $arFields["DETAIL_PICTURE"]; $arFields["DETAIL_PICTURE"] = $SAVED_DETAIL_PICTURE; } if (CIBlockElement::GetIBVersion($arFields["IBLOCK_ID"]) == 2) { $DB->Query("INSERT INTO b_iblock_element_prop_s" . $arFields["IBLOCK_ID"] . "(IBLOCK_ELEMENT_ID)VALUES(" . $ID . ")"); } if (!isset($arFields["XML_ID"]) || strlen($arFields["XML_ID"]) <= 0) { $arFields["XML_ID"] = $ID; $DB->Query("UPDATE b_iblock_element SET XML_ID = " . $ID . " WHERE ID = " . $ID); } if (is_set($arFields, "PROPERTY_VALUES")) { CIBlockElement::SetPropertyValues($ID, $arFields["IBLOCK_ID"], $arFields["PROPERTY_VALUES"]); } if (is_set($arFields, "IBLOCK_SECTION")) { CIBlockElement::SetElementSection($ID, $arFields["IBLOCK_SECTION"], true, $arIBlock["RIGHTS_MODE"] === "E" ? $arIBlock["ID"] : 0, $IBLOCK_SECTION_ID); } if ($arIBlock["RIGHTS_MODE"] === "E") { $obElementRights = new CIBlockElementRights($arIBlock["ID"], $ID); if (!is_set($arFields, "IBLOCK_SECTION") || empty($arFields["IBLOCK_SECTION"])) { $obElementRights->ChangeParents(array(), array(0)); } if (array_key_exists("RIGHTS", $arFields) && is_array($arFields["RIGHTS"])) { $obElementRights->SetRights($arFields["RIGHTS"]); } } if (array_key_exists("IPROPERTY_TEMPLATES", $arFields)) { $ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($arIBlock["ID"], $ID); $ipropTemplates->set($arFields["IPROPERTY_TEMPLATES"]); } if ($bUpdateSearch) { CIBlockElement::UpdateSearch($ID); } \Bitrix\Iblock\PropertyIndex\Manager::updateElementIndex($arIBlock["ID"], $ID); if (!isset($arFields["WF_PARENT_ELEMENT_ID"]) && $arIBlock["FIELDS"]["LOG_ELEMENT_ADD"]["IS_REQUIRED"] == "Y") { $USER_ID = is_object($USER) ? intval($USER->GetID()) : 0; $arEvents = GetModuleEvents("main", "OnBeforeEventLog", true); if (empty($arEvents) || ExecuteModuleEventEx($arEvents[0], array($USER_ID)) === false) { $rsElement = CIBlockElement::GetList(array(), array("=ID" => $ID), false, false, array("LIST_PAGE_URL", "NAME", "CODE")); $arElement = $rsElement->GetNext(); $res = array("ID" => $ID, "CODE" => $arElement["CODE"], "NAME" => $arElement["NAME"], "ELEMENT_NAME" => $arIBlock["ELEMENT_NAME"], "USER_ID" => $USER_ID, "IBLOCK_PAGE_URL" => $arElement["LIST_PAGE_URL"]); CEventLog::Log("IBLOCK", "IBLOCK_ELEMENT_ADD", "iblock", $arIBlock["ID"], serialize($res)); } } if ($bWorkFlow && intval($arFields["WF_PARENT_ELEMENT_ID"]) <= 0) { // It is completly new element - so make it copy unset($arFields["WF_NEW"]); $arFields["WF_PARENT_ELEMENT_ID"] = $ID; $arNewFields = $arFields; $arNewFields["PREVIEW_PICTURE"] = $COPY_PREVIEW_PICTURE; $arNewFields["DETAIL_PICTURE"] = $COPY_DETAIL_PICTURE; if (is_array($arNewFields["PROPERTY_VALUES"])) { $i = 0; $db_prop = CIBlockProperty::GetList(array(), array("IBLOCK_ID" => $arFields["IBLOCK_ID"], "CHECK_PERMISSIONS" => "N", "PROPERTY_TYPE" => "F")); while ($arProp = $db_prop->Fetch()) { $i++; unset($arNewFields["PROPERTY_VALUES"][$arProp["CODE"]]); unset($arNewFields["PROPERTY_VALUES"][$arProp["ID"]]); $arNewFields["PROPERTY_VALUES"][$arProp["ID"]] = array(); } if ($i > 0) { $props = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $ID, "sort", "asc", array("PROPERTY_TYPE" => "F", "EMPTY" => "N")); while ($arProp = $props->Fetch()) { $arNewFields["PROPERTY_VALUES"][$arProp["ID"]][$arProp['PROPERTY_VALUE_ID']] = array("VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"]); } } } $WF_ID = $this->Add($arNewFields); if ($this->bWF_SetMove) { CIBlockElement::WF_SetMove($WF_ID); } } $Result = $ID; $arFields["ID"] =& $ID; $_SESSION["SESS_RECOUNT_DB"] = "Y"; self::$elementIblock[$ID] = $arIBlock['ID']; } if (isset($arFields["PREVIEW_PICTURE"]) && is_array($arFields["PREVIEW_PICTURE"]) && isset($arFields["PREVIEW_PICTURE"]["COPY_FILE"]) && $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && $arFields["PREVIEW_PICTURE"]["copy"]) { @unlink($arFields["PREVIEW_PICTURE"]["tmp_name"]); @rmdir(dirname($arFields["PREVIEW_PICTURE"]["tmp_name"])); } if (isset($arFields["DETAIL_PICTURE"]) && is_array($arFields["DETAIL_PICTURE"]) && isset($arFields["DETAIL_PICTURE"]["COPY_FILE"]) && $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && $arFields["DETAIL_PICTURE"]["copy"]) { @unlink($arFields["DETAIL_PICTURE"]["tmp_name"]); @rmdir(dirname($arFields["DETAIL_PICTURE"]["tmp_name"])); } $arFields["RESULT"] =& $Result; foreach (GetModuleEvents("iblock", "OnAfterIBlockElementAdd", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array(&$arFields)); } CIBlock::clearIblockTagCache($arIBlock['ID']); return $Result; }
public function Init($Params) { $this->value = $Params['value']; $this->startTime = time(); $this->Params = $Params; $this->Result = array(); $this->bSkip = $this->Params['lastPath'] ? true : false; if ($this->bSkip) { $this->Params['lastPath'] = Rel2Abs("/", $this->Params['lastPath']); $this->Params['lastPath'] = $_SERVER["DOCUMENT_ROOT"] . $this->Params['lastPath']; } }
if ($TRANS_RIGHT == "D") { $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); } require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/translate/include.php"; IncludeModuleLangFile(__FILE__); define("HELP_FILE", "translate_list.php"); $APPLICATION->SetTitle(GetMessage("TRANS_TITLE")); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; if (preg_match("#\\.\\.[\\/]#" . BX_UTF_PCRE_MODIFIER, $path)) { $path = ""; } // If not specified then if (strlen($path) <= 0) { $path = COption::GetOptionString("translate", "INIT_FOLDERS"); } $path = Rel2Abs("/", "/" . $path . "/"); if (strpos($path, "/bitrix/") !== 0) { $path = "/bitrix/"; } $path = htmlspecialcharsbx($path); $aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("TRANS_SEARCH"), "ICON" => "translate_search", "TITLE" => GetMessage("TRANS_SEARCH_TITLE"), 'ONSELECT' => "_trSetBTN('search');"), array("DIV" => "edit2", "TAB" => GetMessage("TRANS_REPLACE"), "ICON" => "translate_replace", "TITLE" => GetMessage("TRANS_REPLACE_TITLE"), 'ONSELECT' => "_trSetBTN('replace');")); $tabControl = new CAdminTabControl("tabControl2", $aTabs, false); ?> <form name="form_search" method="POST" action=""> <input type="hidden" name="path" value="<?php echo $path; ?> "> <input type="hidden" name="tr_search" value="1"> <input type="hidden" id="replace_oper" name="replace_oper" value="N"> <?php
$arPTypes = array(); while ($ar_res = $db_res->Fetch()) { if (!in_array($ar_res["CATALOG_GROUP_ID"], $arPTypes)) { $arPTypes[] = $ar_res["CATALOG_GROUP_ID"]; $arSelect[] = "CATALOG_GROUP_" . $ar_res["CATALOG_GROUP_ID"]; } } $arSectionPaths = array(); } if (strlen($SETUP_FILE_NAME) <= 0) { $strExportErrorMessage .= GetMessage("CATI_NO_SAVE_FILE") . "<br>"; } elseif (preg_match(BX_CATALOG_FILENAME_REG, $SETUP_FILE_NAME)) { $strExportErrorMessage .= GetMessage("CES_ERROR_BAD_EXPORT_FILENAME") . "<br>"; } if (strlen($strExportErrorMessage) <= 0) { $SETUP_FILE_NAME = Rel2Abs("/", $SETUP_FILE_NAME); if (strtolower(substr($SETUP_FILE_NAME, strlen($SETUP_FILE_NAME) - 4)) != ".txt") { $SETUP_FILE_NAME .= ".txt"; } /* if ($GLOBALS["APPLICATION"]->GetFileAccessPermission($SETUP_FILE_NAME) < "W") $strExportErrorMessage .= str_replace("#FILE#", $SETUP_FILE_NAME, "You do not have access rights to add or modify #FILE#")."<br>"; */ } if (strlen($strExportErrorMessage) <= 0) { if (!($fp = @fopen($_SERVER["DOCUMENT_ROOT"] . $SETUP_FILE_NAME, "wb"))) { $strExportErrorMessage .= "Can not open \"" . $_SERVER["DOCUMENT_ROOT"] . $SETUP_FILE_NAME . "\" file for writing.\n"; } else { if (!@fwrite($fp, "product_url\tname\tdescription\timage_url\tcategory\tprice\n")) { $strExportErrorMessage .= "Can not write in \"" . $_SERVER["DOCUMENT_ROOT"] . $SETUP_FILE_NAME . "\" file.\n"; @fclose($fp); } }