CanDoOperation('edit_other_settings')) $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); $ID = intval($_REQUEST['ID'] ?? 0); $arError = $arSmile = $arFields = $arLang = array(); $message = null; /* LANGS */ $arLangTitle = array("reference_id" => array(), "reference" => array()); $db_res = CLanguage::GetList(); while ($res = $db_res->Fetch()) { $arLang[$res["LID"]] = $res; $arLangTitle["reference_id"][] = $res["LID"]; $arLangTitle["reference"][] = htmlspecialcharsbx($res["NAME"]); } $bInitVars = false; $bImportComplete = false; $APPLICATION->SetTitle(GetMessage("SMILE_IMPORT_TITLE")); $fileName = ''; if ($REQUEST_METHOD == "POST" && (!empty($_POST['save']) || !empty($_POST['apply']))) { $fileName = 'import'.$USER->GetID().time().'.zip'; if (!check_bitrix_sessid()) { $arError[] = array( "id" => "bad_sessid", "text" => GetMessage("ERROR_BAD_SESSID")); } elseif (!empty($_FILES["IMPORT"]["tmp_name"])) { $sUploadDir = CTempFile::GetDirectoryName(1); CheckDirPath($sUploadDir); $res = CFile::CheckFile($_FILES["IMPORT"], 0, false, 'zip'); if ($res <> '') { $arError[] = array( "id" => "IMPORT", "text" => $res ); } elseif (file_exists($sUploadDir.$fileName)) { $arError[] = array( "id" => "IMPORT", "text" => GetMessage("ERROR_EXISTS_FILE") ); } elseif (!@copy($_FILES["IMPORT"]["tmp_name"], $sUploadDir.$fileName)) { $arError[] = array( "id" => "IMPORT", "text" => GetMessage("ERROR_COPY_FILE")); } else { @chmod($sUploadDir.$fileName, BX_FILE_PERMISSIONS); } } elseif (empty($_FILES["IMPORT"]["tmp_name"])) { $arError[] = array( "id" => "IMPORT", "text" => GetMessage("ERROR_EXISTS_FILE") ); } if (empty($arError)) { $GLOBALS["APPLICATION"]->ResetException(); $importCount = CSmile::import(array( 'FILE' => $sUploadDir.$fileName, 'SET_ID' => intval($_REQUEST['SET_ID']) )); if ($e = $GLOBALS["APPLICATION"]->GetException()) { $arError[] = array( "id" => "", "text" => $e->getString() ); @unlink($sUploadDir.$fileName); } else { @unlink($sUploadDir.$fileName); $bImportComplete = true; } } $e = new CAdminException($arError); $message = new CAdminMessage(GetMessage("ERROR_IMPORT_SMILE"), $e); $bInitVars = true; } $arSmile = array( "SET_ID" => $_REQUEST['SET_ID'] ?? 0, "GALLERY_ID" => $_REQUEST['GALLERY_ID'] ?? 0, ); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); if ($bImportComplete) { CAdminMessage::ShowMessage(array( "MESSAGE"=>GetMessage("IM_IMPORT_COMPLETE"), "DETAILS"=>GetMessage("IM_IMPORT_TOTAL", Array('#COUNT#' => $importCount)), "HTML"=>true, "TYPE"=>"OK", )); LocalRedirect("smile.php?SET_ID=".$arSmile['SET_ID']."&lang=".LANG); } else if (isset($message) && $message) echo $message->Show(); ?>