$module_id = "fileman";
$dicsRelPath = '/bitrix/modules/fileman/dictionaries';
$gzDicsRelPath = BX_PERSONAL_ROOT.'/tmp/dics';
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/fileman/include.php");
CUtil::InitJSCore();
if (!$USER->CanDoOperation('fileman_view_all_settings'))
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
function isValidLang($lang)
{
$rsLang = CLanguage::GetList("sort", "desc");
$is_valid_lang = false;
while ($arLang = $rsLang->Fetch())
{
if ($lang==$arLang["LID"])
{
$is_valid_lang = true;
break;
}
}
return $is_valid_lang;
}
if ($REQUEST_METHOD=="GET" && $USER->CanDoOperation('fileman_edit_all_settings') && $RestoreDefaults <> '' && check_bitrix_sessid())
{
COption::RemoveOption("fileman");
$z = CGroup::GetList("id", "asc", array("ACTIVE" => "Y", "ADMIN" => "N"));
while($zr = $z->Fetch())
$APPLICATION->DelGroupRight($module_id, array($zr["ID"]));
}
global $MESS;
IncludeModuleLangFile(__FILE__);
//Default file extensions;
$script_files_default = "php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,exe,ico,shtm,shtml";
if($REQUEST_METHOD == "POST" && $Update <> '' && $USER->CanDoOperation('fileman_edit_all_settings') && check_bitrix_sessid())
{
if($default_edit!="html" && $default_edit!="php")
$default_edit="text";
COption::SetOptionString($module_id, "default_edit", $default_edit);
COption::SetOptionString($module_id, "use_medialib", $use_medialib == 'Y' ? 'Y' : 'N');
COption::SetOptionString($module_id, "use_editor_3", $use_editor_3 == 'Y' ? 'Y' : 'N');
$useEditor3 = $use_editor_3 == "Y";
if (!$useEditor3)
{
COption::SetOptionString($module_id, "htmleditor_fullscreen", $htmleditor_fullscreen == "Y" ? "Y" : "N");
COption::SetOptionString($module_id, "show_untitled_styles", $show_untitled_styles);
COption::SetOptionString($module_id, "render_styles_in_classlist", $render_styles_in_classlist);
COption::SetOptionString($module_id, "allow_render_components", $allow_render_components == 'Y' ? 'Y' : 'N');
/* ********** Toolbars config ************/
if (isset($_POST['tlbr']) && is_array($_POST['tlbr']))
{
foreach ($_POST['tlbr'] as $type => $arToolbars)
{
if ($arToolbars == 'clean')
COption::RemoveOption($module_id, "toolbar_config_".$type);
// Global toolbar
if (count($arToolbars) == 1 && is_array($arToolbars['global']))
COption::SetOptionString($module_id, "toolbar_config_".$type, serialize($arToolbars['global']));
else // Standart mode
COption::SetOptionString($module_id, "toolbar_config_".$type, serialize($arToolbars));
}
}
// LCA - limit component access
COption::SetOptionString($module_id, "use_lca", ($use_lca == 'Y' ? 'Y' : 'N'));
}
COption::SetOptionString($module_id, "replace_new_lines", isset($_POST['replace_new_lines'])? "Y" : "N");
// ******** Spell ********
COption::SetOptionString($module_id, "use_pspell", isset($_POST['use_pspell'])? "Y" : "N");
if (isset($_POST['user_dics_path']) && $_POST['user_dics_path']!='')
COption::SetOptionString($module_id, "user_dics_path", $_POST['user_dics_path']);
else
COption::SetOptionString($module_id, "user_dics_path","/bitrix/modules/fileman/u_dics");
if (isset($_POST['use_separeted_dics']))
COption::SetOptionString($module_id, "use_separeted_dics", "Y");
else
COption::SetOptionString($module_id, "use_separeted_dics", "N");
COption::SetOptionString($module_id, "use_custom_spell", "N");
//Handle dictionary loading
if (isset($_POST['dic_lang']) && isset($_FILES['dic_aff']) && isset($_FILES['dic_base']) && $_FILES['dic_aff']['name'] != '' && $_FILES['dic_base']['name'] != '')
{
$dic_lang = $_POST['dic_lang'];
if (isValidLang($dic_lang))
{
$lang_dir = $_SERVER['DOCUMENT_ROOT'].$dicsRelPath.'/'.$dic_lang;
$dics_dir = $_SERVER['DOCUMENT_ROOT'].$dicsRelPath.'/'.$dic_lang.'/dics';
if (!file_exists($lang_dir))
mkdir($lang_dir, BX_DIR_PERMISSIONS);
$source=$_FILES['dic_base']['tmp_name'];
$target = $lang_dir.'/'.$dic_lang.'.dic';
if (file_exists($target))
unlink ($target);
move_uploaded_file($source, $target);
$source=$_FILES['dic_aff']['tmp_name'];
$target = $lang_dir.'/'.$dic_lang.'.aff';
if (file_exists($target))
unlink ($target);
move_uploaded_file($source, $target);
if (!file_exists($dics_dir))
mkdir($dics_dir, BX_DIR_PERMISSIONS);
COption::SetOptionString($module_id, $dic_lang."_dic_indexed", "N");
}
}
//Handle dictionary removing
if (isset($_POST['del_dic']))
{
$lang_dir = $_SERVER['DOCUMENT_ROOT'].$dicsRelPath.'/'.$_POST['del_dic'];
if (file_exists($lang_dir) && is_dir($lang_dir))
{
$dicDir = dir($lang_dir);
while (false !== ($entry = $dicDir->read()))
{
$entry_path = $dicDir->path.'/'.$entry;
if (is_dir($entry_path) && $entry=='dics')
{
//Removing files from 'dics' directory
$dicsDir = dir($entry_path);
while (false !== ($dic = $dicsDir->read()))
{
$dic_path = $dicsDir->path.'/'.$dic;
if (is_file($dic_path))
unlink ($dic_path);
}
$dicsDir->close();
//removing 'dics' directory
rmdir($entry_path);
}
elseif (is_file($entry_path))
{
unlink ($entry_path);
}
}
$dicDir->close();
rmdir($lang_dir);
}
}
//Handle dictionary indexing
if (isset($_POST['index_dic']))
{
$lang_dir = $_SERVER['DOCUMENT_ROOT'].$dicsRelPath.'/'.$_POST['index_dic'];
if (file_exists($lang_dir) && is_dir($lang_dir))
{
$dicsDir = dir($lang_dir.'/dics');
while (false !== ($dic = $dicsDir->read()))
{
$dic_path = $dicsDir->path.'/'.$dic;
if (is_file($dic_path))
unlink ($dic_path);
}
$dicsDir->close();
require($_SERVER['DOCUMENT_ROOT'].BX_ROOT.'/modules/fileman/admin/spell_createDictionary.php');
$CD = new createDictionary();
$lang = $_POST['index_dic'];
$CD->init($lang,$lang_dir);
if ($CD->create())
COption::SetOptionString($module_id, $dic_lang."_dic_indexed", "Y");
}
}
// ******** Spell END ********
//Entities
if (isset($_POST['ar_entities']))
{
$ar_entities = is_array($_POST['ar_entities']) ? $_POST['ar_entities'] : [];
COption::SetOptionString($module_id, "ar_entities", count($ar_entities) <= 0 ? 'none' : implode(',', $ar_entities));
}
COption::SetOptionString($module_id, "editor_body_id", htmlspecialcharsbx($editor_body_id));
COption::SetOptionString($module_id, "editor_body_class", htmlspecialcharsbx($editor_body_class));
/* ********** Medialib ************/
$cur_ml_width = COption::GetOptionInt($module_id, "ml_thumb_width", 140);
$cur_ml_height = COption::GetOptionInt($module_id, "ml_thumb_height", 105);
$ml_width = intval($medialib_thumb_width, 10);
if ($ml_width <=0)
$ml_width = 140;
$ml_height = intval($medialib_thumb_height, 10);
if ($ml_height <=0)
$ml_height = 105;
if (abs($cur_ml_width - $ml_width) > 10 || abs($cur_ml_height - $ml_height) > 10)
CMedialib::DeleteThumbnails();
COption::SetOptionInt($module_id, "ml_thumb_width", $ml_width);
COption::SetOptionInt($module_id, "ml_thumb_height", $ml_height);
$arMLExt = explode(',', $medialib_ext);
$arMLExt_ = array();
for ($i = 0, $l = count($arMLExt); $i < $l; $i++)
{
$ext = mb_strtolower(trim($arMLExt[$i], ' .'));
if ($ext <> '')
$arMLExt_[] = $ext;
}
$medialib_ext = implode(',', $arMLExt_);
COption::SetOptionString($module_id, "ml_media_extentions", $medialib_ext);
/* Max size*/
$ml_max_width = intval($medialib_max_width);
if ($ml_max_width <=0)
$ml_max_width = 1024;
$ml_max_height = intval($medialib_max_height);
if ($ml_max_height <=0)
$ml_max_height = 1024;
COption::SetOptionInt($module_id, "ml_max_width", $ml_max_width);
COption::SetOptionInt($module_id, "ml_max_height", $ml_max_height);
/* MEDIALIB TYPES*/
$arMLTypes = array();
$arMLDelTypes = array();
$strAvExt = $medialib_ext;
foreach ($_POST['ML_TYPE'] as $key => $type)
{
if ($type["DEL"] == "Y")
{
$arMLDelTypes[] = $key;
}
//elseif(trim($type["EXT"]) != "" && trim($type["NAME"]) != "" && trim($type["CODE"]) != "")
elseif(trim($type["EXT"]) != "" && trim($type["CODE"]) != "")
{
if ($type["SYS"] == "Y")
{
$arMLTypes[] = array(
'EXT' => $type["EXT"],
'CODE' => $type["CODE"],
'ID' => $key
);
}
else
{
$arMLTypes[] = array(
'NEW' => $type["NEW"] == "Y",
'ID' => $key,
'NAME' => $type["NAME"],
'CODE' => $type["CODE"],
'EXT' => $type["EXT"],
'DESCRIPTION' => $type["DESC"],
'SYSTEM' => $type["SYS"] == "Y" ? "Y" : "N"
);
}
$strAvExt .= ','.$type["EXT"];
}
}
CMedialib::DelTypes($arMLDelTypes);
CMedialib::SetTypes($arMLTypes);
$arExt_ = explode(',', $strAvExt);
$arAvExt = array();
for ($i = 0, $l = count($arExt_); $i < $l; $i++)
{
$ext = mb_strtolower(trim($arExt_[$i], ' .'));
if ($ext <> '' && !in_array($ext, $arAvExt))
$arAvExt[] = $ext;
}
$strAvExt = implode(',', $arAvExt);
COption::SetOptionString($module_id, "ml_media_available_ext", $strAvExt);
/* MEDIALIB END*/
// Using medialib (or file dialog) by default in HTML-editor and other...
COption::SetOptionString($module_id, "ml_use_default", $medialib_use_default == 'Y');
//File extensions
if ($USER->CanDoOperation('edit_php'))
{
COption::SetOptionString($module_id, "~script_files", $script_files);
COption::SetOptionString($module_id, "~allowed_components", $allowed_components);
}
$addError = false;
$siteList_ID = unserialize($mSiteList, ['allowed_classes' => false]);
if(isset($dif_settings))
{
COption::SetOptionString($module_id, "different_set", "Y");
$j = 0;
while($j < count($siteList_ID))
{
COption::SetOptionInt($module_id, "num_menu_param", ${"num_".$siteList_ID[$j]["ID"]."_menu_param"}, false, $siteList_ID[$j]["ID"]);
$menutypes = "";
$armt = Array();
for($i=0; $i<${"menutypes_".$siteList_ID[$j]["ID"]."_count"}; $i++)
{
if(${"menutypes_".$siteList_ID[$j]["ID"]."_".$i."_type"} <> '')
$armt[${"menutypes_".$siteList_ID[$j]["ID"]."_".$i."_type"}] = ${"menutypes_".$siteList_ID[$j]["ID"]."_".$i."_name"};
}
if(${"menutypes_".$siteList_ID[$j]["ID"]."_new_type"} <> '' && $USER->CanDoOperation('fileman_edit_menu_types'))
$armt[${"menutypes_".$siteList_ID[$j]["ID"]."_new_type"}] = ${"menutypes_".$siteList_ID[$j]["ID"]."_new_name"};
if (mb_strlen(addslashes(serialize($armt))) <= 2000)
SetMenuTypes($armt, $siteList_ID[$j]["ID"]);
else
$addError = GetMessage("FILEMAN_OPTION_ADD_ERROR_MENU").'
';
$arPT = Array();
for($i=0; $i<${"propstypes_".$siteList_ID[$j]["ID"]."_count"}; $i++)
{
if(${"propstypes_".$siteList_ID[$j]["ID"]."_".$i."_type"} <> '')
$arPT[${"propstypes_".$siteList_ID[$j]["ID"]."_".$i."_type"}] = ${"propstypes_".$siteList_ID[$j]["ID"]."_".$i."_name"};
}
if(${"propstypes_".$siteList_ID[$j]["ID"]."_new_type"} <> '')
$arPT[${"propstypes_".$siteList_ID[$j]["ID"]."_new_type"}] = ${"propstypes_".$siteList_ID[$j]["ID"]."_new_name"};
if(!CFileMan::SetPropstypes($arPT, false, $siteList_ID[$j]["ID"]))
$addError .= GetMessage("FILEMAN_OPTION_ADD_ERROR_PROPS");
$j++;
}
}
else
{
COption::SetOptionString($module_id, "different_set", "N");
COption::SetOptionInt($module_id, "num_menu_param", $num_menu_param);
$armt = Array();
$menutypes = "";
for($i=0; $i<$menutypes_count; $i++)
{
if(${"menutypes_".$i."_type"} <> '')
$armt[${"menutypes_".$i."_type"}] = ${"menutypes_".$i."_name"};
}
if($menutypes_new_type <> '' && $USER->CanDoOperation('fileman_edit_menu_types'))
$armt[$menutypes_new_type] = $menutypes_new_name;
if (mb_strlen(addslashes(serialize($armt))) <= 2000)
SetMenuTypes($armt, $siteList_ID[$j]["ID"]);
else
$addError = GetMessage("FILEMAN_OPTION_ADD_ERROR_MENU").'
';
$propstypes = "";
$arPT = Array();
for($i=0; $i<$propstypes_count; $i++)
{
if(${"propstypes_".$i."_type"} <> '')
$arPT[${"propstypes_".$i."_type"}] = ${"propstypes_".$i."_name"};
}
if($propstypes_new_type <> '')
$arPT[$propstypes_new_type] = $propstypes_new_name;
if(!CFileMan::SetPropstypes($arPT))
$addError .= GetMessage("FILEMAN_OPTION_ADD_ERROR_PROPS");
$j = 0;
while($j < count($siteList_ID))
{
COption::RemoveOption($module_id, "menutypes", $siteList_ID[$j]["ID"]);
COption::RemoveOption($module_id, "propstypes", $siteList_ID[$j]["ID"]);
COption::RemoveOption($module_id, "num_menu_param", $siteList_ID[$j]["ID"]);
$j++;
}
}
// Search
$search_max_open_file_size = intval($_POST['search_max_open_file_size']);
if ($search_max_open_file_size <= 0)
$search_max_open_file_size = 1024;
COption::SetOptionString($module_id, "search_max_open_file_size", $search_max_open_file_size);
$search_max_res_count = intval($_POST['search_max_res_count']);
if ($search_max_res_count <= 0)
$search_max_res_count = '';
COption::SetOptionString($module_id, "search_max_res_count", $search_max_res_count);
$search_time_step = intval($_POST['search_time_step']);
if ($search_time_step <= 0)
$search_time_step = 5;
COption::SetOptionString($module_id, "search_time_step", $search_time_step);
$search_mask = $_POST['search_mask'];
if ($search_mask == "")
$search_mask = "*.php";
COption::SetOptionString($module_id, "search_mask", $search_mask);
COption::SetOptionString($module_id, "show_inc_icons", (isset($_POST['show_inc_icons']) ? 'Y' : 'N'));
COption::SetOptionString($module_id, "hide_physical_struc", (isset($_POST['hide_physical_struc'])));
COption::SetOptionString($module_id, "use_translit", (isset($_POST['use_translit'])));
COption::SetOptionString($module_id, "use_translit_google", (isset($_POST['use_translit_google'])));
COption::SetOptionString($module_id, "log_menu", (isset($_POST['log_menu']) ? 'Y' : 'N'));
COption::SetOptionString($module_id, "log_page", (isset($_POST['log_page']) ? 'Y' : 'N'));
COption::SetOptionString($module_id, "use_code_editor", (isset($_POST['use_code_editor']) ? 'Y' : 'N'));
COption::SetOptionString($module_id, "google_map_api_key", isset($_POST['google_map_api_key']) ? $_POST['google_map_api_key'] : '');
COption::SetOptionString($module_id, "yandex_map_api_key", isset($_POST['yandex_map_api_key']) ? $_POST['yandex_map_api_key'] : '');
//default groups
$sGroups = '';
if(is_array($_POST["DEFAULT_EDIT_GROUPS"]))
foreach($_POST["DEFAULT_EDIT_GROUPS"] as $gr)
$sGroups .= ($sGroups <> ''? ',':'').intval($gr);
COption::SetOptionString('fileman', 'default_edit_groups', $sGroups);
$archive_step_time = intval($_POST['archive_step_time']);
if ($archive_step_time <= 0)
$archive_step_time = 30;
COption::SetOptionString($module_id, "archive_step_time", $archive_step_time);
}
if ($REQUEST_METHOD=="GET" && isset($_GET['load_dic']) &&
$USER->CanDoOperation('fileman_edit_all_settings') &&
COption::GetOptionString($module_id, "use_editor_3", "N") == "Y")
{
if (isValidLang($_GET['load_dic']))
{
$l_id = $_GET['load_dic'];
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/tar_gz.php");
$indexedDicPath = $_SERVER['DOCUMENT_ROOT'].$gzDicsRelPath.'/'.$l_id.'.tar.gz';
$oArchiver = new CArchiver($indexedDicPath);
if ($oArchiver->extractFiles($_SERVER['DOCUMENT_ROOT'].$dicsRelPath.'/'.$l_id))
COption::SetOptionString($module_id, $l_id."_dic_indexed", "Y");
}
}
$aTabs = array(
array("DIV" => "edit1", "TAB" => GetMessage("MAIN_TAB_SET"), "ICON" => "fileman_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_SET")),
array("DIV" => "edit2", "TAB" => GetMessage("MAIN_TAB_VISUAL_EDITOR"), "ICON" => "fileman_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_VIS_ED_SET")),
array("DIV" => "edit5", "TAB" => GetMessage("MAIN_TAB_MEDIALIB"), "ICON" => "fileman_settings", "TITLE" => GetMessage("FILEMAN_SEC_MEDIALIB")),
);
if($USER->isAdmin())
{
$rightsTab = array("DIV" => "edit3", "TAB" => GetMessage("MAIN_TAB_RIGHTS"), "ICON" => "fileman_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_RIGHTS"));
$aTabs[] = $rightsTab;
}
$siteList = array();
$rsSites = CSite::GetList();
$i = 0;
while($arRes = $rsSites->Fetch())
{
$siteList[$i]["ID"] = $arRes["ID"];
$siteList[$i]["NAME"] = $arRes["NAME"];
$i++;
}
$siteCount = $i;
$useEditor3 = COption::GetOptionString($module_id, "use_editor_3", "Y") == "Y";
unset($rsSites);
unset($arRes);
if ($addError)
{
CAdminMessage::ShowMessage(array(
"DETAILS" => $addError,
"TYPE" => "ERROR",
));
}
$tabControl = new CAdmintabControl("tabControl", $aTabs);
$tabControl->Begin();
?>