示例#1
0
	if(strlen($strError) <= 0)
	{
		$ST = new CSiteTemplate();
		$arFields = Array(
			"ID" => $ID,
			"NAME" => $NAME,
			"DESCRIPTION" => $DESCRIPTION,
			"CONTENT" => $CONTENT,
			"STYLES" => $STYLES,
			"TEMPLATE_STYLES" => $TEMPLATE_STYLES,
		);

		if($_REQUEST['edit']=="Y")
			$res = $ST->Update($ID, $arFields);
		else
			$res = (strlen($ST->Add($arFields))>0);

		if(!$res)
		{
			$strError .= $ST->LAST_ERROR."<br>";
			$bVarsFromForm = true;
		}
		else
		{
			$maxind = $_POST['maxind'];
			$str_CONTENT_for_save = "<?\n\$arStyles = array(\n";
			for ($i=0;$i<=$maxind;$i++)
			{
				if (trim($_POST["CODE_".$i]) == '')
					continue;
 if (class_exists('CFileMan') && method_exists(CFileMan, CheckOnAllowedComponents)) {
     if (!CFileMan::CheckOnAllowedComponents($CONTENT)) {
         $str_err = $APPLICATION->GetException();
         if ($str_err && ($err = $str_err->GetString())) {
             $strError .= $err;
         }
         $bVarsFromForm = true;
     }
 }
 if (strlen($strError) <= 0) {
     $ST = new CSiteTemplate();
     $arFields = array("ID" => $ID, "NAME" => $NAME, "DESCRIPTION" => $DESCRIPTION, "CONTENT" => $CONTENT, "STYLES" => $STYLES, "TEMPLATE_STYLES" => $TEMPLATE_STYLES);
     if ($_REQUEST['edit'] == "Y") {
         $res = $ST->Update($ID, $arFields);
     } else {
         $res = strlen($ST->Add($arFields)) > 0;
     }
     if (!$res) {
         $strError .= $ST->LAST_ERROR . "<br>";
         $bVarsFromForm = true;
     } else {
         $maxind = $_POST['maxind'];
         $str_CONTENT_for_save = "<?\n\$arStyles = array(\n";
         for ($i = 0; $i <= $maxind; $i++) {
             if (trim($_POST["CODE_" . $i]) == '') {
                 continue;
             }
             $code = ltrim($_POST["CODE_" . $i], ".");
             $val = $_POST["VALUE_" . $i];
             $str_CONTENT_for_save .= "\t\"" . EscapePHPString($code) . '" => "' . EscapePHPString($val) . "\",\n";
         }