function SaveHTTPFile($fFileHTTPPath, $fFileSavePath, $fFileSaveName) { //记录程序开始的时间 $BeginTime = getmicrotime(); //取得文件名 $fFileSaveName = $fFileSavePath . "/" . $fFileSaveName; make_dir(dirname($fFileSaveName)); //取得文件的内容 ob_start(); readfile($fFileHTTPPath); $img = ob_get_contents(); ob_end_clean(); //$size = strlen($img); //保存到本地 $fp2 = @fopen($fFileSaveName, "a"); fwrite($fp2, $img); fclose($fp2); /*加水印代码*/ require_once ROOT_PATH . 'includes/cls_image.php'; $ext = get_extension($fFileSaveName); $fFileSaveName = convert_GIF_to_JPG($fFileSaveName); if (CopyFiles($fFileSaveName)) { $image = new cls_image(); $image->add_watermark($fFileSaveName, '', '../../../../' . $GLOBALS['waterMark']['watermark'], $GLOBALS['waterMark']['watermark_place'], $GLOBALS['waterMark']['watermark_alpha']); } if ($ext == 'gif' || $ext == '.gif') { back_JPG_to_GIF($fFileSaveName); } /*加水印代码--end*/ //记录程序运行结束的时间 $EndTime = getmicrotime(); //返回运行时间 return $EndTime - $BeginTime; }
function CopyFiles($source, $dest) { $folder = opendir($source); while ($file = readdir($folder)) { if ($file == '.' || $file == '..') { continue; } if (is_dir($source . '/' . $file)) { mkdir($dest . '/' . $file, 0777); chmod($dest . '/' . $file, 0777); CopyFiles($source . '/' . $file, $dest . '/' . $file); } else { copy($source . '/' . $file, $dest . '/' . $file); chmod($dest . '/' . $file, 0777); } } closedir($folder); return 1; }
function MoreFileUpload($resourceType, $currentFolder, $sCommand) { if (!isset($_FILES)) { global $_FILES; } global $Config; $sErrorNumber = '0'; $sFileName = ''; if (is_array($_FILES['NewFile']['name'])) { foreach ($_FILES['NewFile']['name'] as $key => $value) { if (!empty($_FILES['NewFile']['tmp_name'][$key])) { // Map the virtual path to the local server path. $sServerDir = ServerMapFolder($resourceType, $currentFolder, $sCommand); // Get the uploaded file name. $sFileName = $_FILES['NewFile']['name'][$key]; $sFileName = SanitizeFileName($sFileName); $sOriginalFileName = $sFileName; // Get the extension. $sExtension = substr($sFileName, strrpos($sFileName, '.') + 1); $sExtension = strtolower($sExtension); if (isset($Config['SecureImageUploads'])) { if (($isImageValid = IsImageValid($_FILES['NewFile']['tmp_name'][$key], $sExtension)) === false) { $sErrorNumber = '202'; } } if (isset($Config['HtmlExtensions'])) { if (!IsHtmlExtension($sExtension, $Config['HtmlExtensions']) && ($detectHtml = DetectHtml($_FILES['NewFile']['tmp_name'][$key])) === true) { $sErrorNumber = '202'; } } // Check if it is an allowed extension. if (!$sErrorNumber && IsAllowedExt($sExtension, $resourceType)) { $iCounter = 0; while (true) { $sFilePath = $sServerDir . $sFileName; if (is_file($sFilePath)) { $iCounter++; $sFileName = RemoveExtension($sOriginalFileName) . '(' . $iCounter . ').' . $sExtension; $sErrorNumber = '201'; } else { move_uploaded_file($_FILES['NewFile']['tmp_name'][$key], $sFilePath); //判断并给符合条件图片加上水印 if ($sExtension == 'jpg' || $sExtension == 'jpeg' || $sExtension == 'png' || $sExtension == 'gif' || $sExtension == 'bmp') { require_once ROOT_PATH . '/includes/cls_image.php'; $image = new cls_image($GLOBALS['_CFG']['bgcolor']); require_once ROOT_PATH . '/includes/my_func.php'; $sFilePath = convert_GIF_to_JPG($sFilePath); if (CopyFiles($sFilePath, $sExtension)) { if (intval($GLOBALS['_CFG']['watermark_place']) > 0 && !empty($GLOBALS['_CFG']['watermark'])) { $image->add_watermark($sFilePath, '', '../../../../../' . $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']); } } if ($sExtension == 'gif' || $sExtension == '.gif') { back_JPG_to_GIF($sFilePath); } } if (is_file($sFilePath)) { if (isset($Config['ChmodOnUpload']) && !$Config['ChmodOnUpload']) { break; } $permissions = 0777; if (isset($Config['ChmodOnUpload']) && $Config['ChmodOnUpload']) { $permissions = $Config['ChmodOnUpload']; } $oldumask = umask(0); chmod($sFilePath, $permissions); umask($oldumask); } break; } } if (file_exists($sFilePath)) { //previous checks failed, try once again if (isset($isImageValid) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false) { @unlink($sFilePath); $sErrorNumber = '202'; } else { if (isset($detectHtml) && $detectHtml === -1 && DetectHtml($sFilePath) === true) { @unlink($sFilePath); $sErrorNumber = '202'; } } } } else { $sErrorNumber = '202'; } if ($sErrorNumber == '202') { $sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder); $sFileUrl = CombinePaths($sFileUrl, $sFileName); SendUploadResults($sErrorNumber, $sFileUrl, $sFileName); } } else { continue; } } $sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder); $sFileUrl = CombinePaths($sFileUrl, $sFileName); SendUploadResults($sErrorNumber, $sFileUrl, $sFileName, $key); } else { $sErrorNumber = '202'; $sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder); $sFileUrl = CombinePaths($sFileUrl, $sFileName); SendUploadResults($sErrorNumber, $sFileUrl, $sFileName); } exit; }
if (!is_readable($TMP_FOLDER . "required.txt")) { InstallationAborted(TOOLS_MODULES_ERR_CANTOPEN . " required.txt.", 'activation'); } if (!is_readable($TMP_FOLDER . "symlinks.txt")) { InstallationAborted(TOOLS_MODULES_ERR_CANTOPEN . " symlinks.txt.", 'activation'); } $Ability = CheckAbilityOfInstallation(); if ($Ability["Success"] == 0) { InstallationAborted(TOOLS_PATCH_ERROR . ": " . $Ability["ErrorMessage"] . ".", 'activation'); } $Install = InstallPatch(); if ($Install["Success"] == 0) { InstallationAborted(TOOLS_PATCH_ERROR_DURINGINSTALL . ": " . $Install["ErrorMessage"] . ".", 'activation'); } // copy files from files.txt $CopyFilesResult = CopyFiles(); // execute queries from sql.txt, one per string $ExecSQLResult = ExecSQL($TMP_FOLDER . "sql.txt"); // symlinks.txt $CreatLinksResult = CreatLinks(); // insert patch info into the database $inserted = $db->query("INSERT INTO `Patch`\n\t\t\t(`Patch_Name`, `Created`, `Description`)\n\t\t\tVALUES ('" . $db->escape($PatchName) . "', NOW(), '" . $db->escape($Description) . "')"); // don't show update notice once more $PatchResult = array(); // results if ($CopyFilesResult['files']) { $PatchResult['files'] = str_replace("%COUNT", $CopyFilesResult['files'], TOOLS_PATCH_INFO_FILES_COPIED); } if ($ExecSQLResult['sqls']) { $PatchResult['sqls'] = str_replace("%COUNT", $ExecSQLResult['sqls'], TOOLS_PATCH_INFO_QUERIES_EXEC); }
if ($Install["Success"] == 0) { //nc_print_status(TOOLS_MODULES_ERR_ITEMS, 'error'); //print $Install["ErrorMessage"].".<br><br>\n\n"; InstallationAborted(TOOLS_MODULES_ERR_ITEMS . "<br />" . $Install["ErrorMessage"], 'module'); } unset($Install); $Install = InstallThisModule(); if ($Install["Success"] == 0) { //nc_print_status(TOOLS_MODULES_ERR_DURINGINSTALL.": ".$Install["ErrorMessage"], 'error'); InstallationAborted(TOOLS_MODULES_ERR_DURINGINSTALL . ": " . $Install["ErrorMessage"], 'module'); } $db->query("INSERT INTO `Module`\n (`Module_Name`, `Keyword`, `Description`, `Parameters`, `Example_URL`, `Help_URL`, `Checked`)\n VALUES\n ('" . $db->escape($Name) . "', '" . $db->escape($Keyword) . "', '" . $db->escape($Description) . "', '" . $db->escape($Parameters) . "', '" . $db->escape($ExampleURL) . "', '" . $db->escape($HelpURL) . "', '1')"); if ($SysMessage) { InsertSystemMessage($SysMessage, $Name); } CopyFiles('module'); $current_catalogue = $nc_core->catalogue->get_by_host_name($_SERVER['HTTP_HOST']); if ($current_catalogue['Language'] == "ru") { ExecSQLMultiline($TMP_FOLDER . "sql.txt"); } else { ExecSQLMultiline($TMP_FOLDER . "sql_int.txt"); } DeleteFilesInDirectory($TMP_FOLDER); // Здесь необходимо сбрасывать кэш запроса относящегося к модулям. TitleModule(); break; case 5: # показать форму добавления модуля BeginHtml($Title2, $Title2, "http://" . $DOC_DOMAIN . "/settings/modules/"); $perm->ExitIfNotAccess(NC_PERM_MODULE, 0, 0, 0, 0); $UI_CONFIG = new ui_config_tool(TOOLS_MODULES, TOOLS_MODULES, 'i_modules_big.gif', 'tools.installmodule');
function placeInRamdisk() { ENTER("placeInRamdisk"); // By default the generic tts is used $this->myTextToSpeechLanguage[0] = ENGLISH_TTS; if (OK != $this->_myStatus) { return; } // Creating the new tree into the ramdisk $aCommand = "mkdir -p " . INSTALL_TREE; Debug($aCommand); system($aCommand); // Copying the Makefile for tcdtk.so (emacspeak) Debug("Copying the Makefile"); $aMakefile = ORALUX_RUNTIME_EMACSPEAK . "/Makefile"; if (@is_file($aMakefile)) { unset($aFile); $aFile[0] = "Makefile"; CopyFiles(ORALUX_RUNTIME_EMACSPEAK, DTK_EMACSPEAK, $aFile); } else { $this->myStatus = MAKEFILE_CANT_BE_FOUND; return; } if (FALSE == $this->_isFirstInstallation) { // This is not the first installation // We have just to copy the DECtalk files from the storage directory to the good place $oldTree = $this->_myStorageDirectory . "/DECtalk"; unset($aFile); $aFile[0] = "libtts*.so"; CopyFiles($oldTree, INSTALL_TREE . "/lib", $aFile); $aFile[0] = "*.dic"; CopyFiles($oldTree, INSTALL_TREE . "/lib/DECtalk", $aFile); $aFile[0] = "say"; CopyFiles($oldTree, INSTALL_TREE . "/bin", $aFile); $aFile[0] = "*.h"; CopyFiles($oldTree, INSTALL_TREE . "/include/dtk", $aFile); $aFile[0] = "DECtalk.conf"; CopyFiles($oldTree, RAMDISK . "/dtk", $aFile); // Copying the optional tts if present $anOptionalDirectory = 0; for ($i = 1; $i < count($this->_myTTSIdentifier); $i++) { $oldTree = $this->_myStorageDirectory . "/" . $this->_myTTSIdentifier[$i]; Debug("Is dir?"); Debug($oldTree); if (@is_dir($oldTree)) { $anOptionalDirectory = $i; break; } } if ($anOptionalDirectory) { unset($aFile); $aFile[0] = "libtts*.so"; CopyFiles($oldTree, INSTALL_TREE . "/lib", $aFile); $aFile[0] = "*.dic"; CopyFiles($oldTree, INSTALL_TREE . "/lib/DECtalk", $aFile); // Updating the Makefile (emacspeak) so that the optional library is used $aCommand = "sed 's+ltts_us+ltts_us -l" . $this->_myDECtalkLibrary[$anOptionalDirectory] . "+g' " . DTK_EMACSPEAK . "/Makefile"; //replace 'ltts_us' 'ltts_us -l".$this->_myDECtalkLibrary[$anOptionalDirectory]."' -- ".DTK_EMACSPEAK."/Makefile"; Debug($aCommand); system($aCommand); $this->myTextToSpeechLanguage[1] = $this->_myTTSIdentifier[$anOptionalDirectory]; } } else { // The BASE_DIR variable must be customized $oldTree = "/usr/local"; $installer = RAMDISK . "/DECtalk/files.sh"; $aCommand = "sed 's+BASE_DIR=\"{$oldTree}\"+BASE_DIR=\"" . INSTALL_TREE . "\"+g' {$installer} > /tmp/installer;mv /tmp/installer {$installer};chmod +x {$installer}"; // $aCommand="replace". // " 'BASE_DIR=\"$oldTree\"'". // " 'BASE_DIR=\"".INSTALL_TREE."\"'". // " -- ". // RAMDISK."/DECtalk/files.sh"; Debug($aCommand); system($aCommand); // Idem for an optional package if present $anOptionalPackageIsPresent = 0; Debug("count _myTTSIdentifier=" . count($this->_myTTSIdentifier)); for ($i = 1; $i < count($this->_myTTSIdentifier); $i++) { Debug("Is dir?"); Debug(RAMDISK . "/" . $this->_myTTSIdentifier[$i]); if (@is_dir(RAMDISK . "/" . $this->_myTTSIdentifier[$i])) { $anOptionalPackageIsPresent = $i; break; } } if ($anOptionalPackageIsPresent) { $installer = RAMDISK . "/" . $this->_myTTSIdentifier[$anOptionalPackageIsPresent] . "/installer"; $aCommand = "sed 's+BASE_DIR=\"{$oldTree}\"+BASE_DIR=\"" . INSTALL_TREE . "\"+g' {$installer} > /tmp/installer;mv /tmp/installer {$installer};chmod +x {$installer}"; // $aCommand="replace". // " 'BASE_DIR=\"$oldTree\"'". // " 'BASE_DIR=\"".INSTALL_TREE."\"'". // " -- ". // RAMDISK."/".$this->_myTTSIdentifier[$anOptionalPackageIsPresent]."/installer"; Debug($aCommand); system($aCommand); $this->myTextToSpeechLanguage[1] = $this->_myTTSIdentifier[$anOptionalPackageIsPresent]; } $this->myStatus = SERIAL_NUMBER_IS_EXPECTED; } }
$db_data_media["med_row"] = $new_dea_id; $db_data_media["med_type"] = $row["med_type"]; $db_data_media["med_order"] = $row["med_order"]; $db_data_media["med_title"] = $row["med_title"]; $db_data_media["med_file"] = $row["med_file"]; $db_data_media["med_realname"] = $row["med_realname"]; $db_data_media["med_filetype"] = $row["med_filetype"]; $db_data_media["med_filesize"] = $row["med_filesize"]; $db_data_media["med_blurb"] = $row["med_blurb"]; $db_data_media["med_dims"] = $row["med_dims"]; $db_data_media["med_features"] = $row["med_features"]; $db_data_media["med_created"] = $row["med_created"]; // images are all suffixed with one of the values fropm thumbnail_sizes. // images are gif or jpg only // just copy whole folder CopyFiles($image_path_property, $new_image_path_property); db_query($db_data_media, "INSERT", "media", "med_id"); unset($db_data_media); } // finally add note to status notes part $db_data_notes["not_type"] = 'sot'; $db_data_notes["not_row"] = $new_dea_id; $db_data_notes["not_blurb"] = 'This record was copied from id: ' . $dea_id; $db_data_notes["not_user"] = $_SESSION["auth"]["use_id"]; $db_data_notes["not_date"] = $date_mysql; db_query($db_data_notes, "INSERT", "note", "not_id"); unset($db_data_notes); } if ($copy_number > 1) { $render = "<p>You successfuly copied this property {$copy_number} times</p>"; foreach ($added as $val) {