camp_html_goto_page("/$ADMIN/templates/new_template.php?Path=".urlencode($f_path)); } $f_name = strtr($f_name,'?~#%*&|"\'\\/<>', '_____________'); // Set the extension of the new file if it doesnt have one already. $new_path_info = pathinfo($f_name); $newExtension = isset($new_path_info["extension"]) ? $new_path_info["extension"] : ""; if (empty($newExtension)) { if ($f_name[strlen($f_name)-1] != ".") { $f_name .= "."; } $f_name .= "tpl"; } $newTempl = Template::GetFullPath($f_path, $f_name); $ok = 0; $file_exists = file_exists($newTempl); if (!$file_exists) { $ok = touch ($newTempl); Template::UpdateStatus(); $logtext = getGS('New template $1 created',$f_path."/".$f_name); Log::Message($logtext, $g_user->getUserId(), 114); camp_html_add_msg($logtext, "ok"); camp_html_goto_page("/$ADMIN/templates/edit_template.php?f_path=$f_path&f_name=$f_name"); } else { camp_html_add_msg(getGS('A file or folder having the name $1 already exists','<b>'.$f_name.'</B>')); camp_html_goto_page("/$ADMIN/templates/new_template.php?Path=".urlencode($f_path)); }
$f_name = Input::Get('f_name', 'string', ''); } $f_path = preg_replace('#//+#', '/', $f_path); if ($f_path == '/') { $f_path = ''; } $f_content = Input::Get('f_content', 'string', '', true); $backLink = "/$ADMIN/templates/"; if (!Template::IsValidPath($f_path.DIR_SEP.$f_name)) { camp_html_goto_page($backLink); } $filename = Template::GetFullPath($f_path, $f_name); $templateName = (!empty($f_path) ? $f_path."/" : "").$f_name; if ($templateName[0] == '/') { $templateName = substr($templateName, 1); } $templateObj = new Template($templateName); if (!file_exists($filename)) { camp_html_display_error(getGS("Invalid template file $1" , $f_path."/$f_name"), $backLink); exit; } if (!is_writable($filename)) { camp_html_add_msg(camp_get_error_message(CAMP_ERROR_WRITE_FILE, $filename)); }
exit; } $Path = Input::Get('Path', 'string', ''); $Name = Input::Get('Name', 'string', ''); $isFile = Input::Get('What', 'int', 0); $Path = preg_replace('#/+#', '/', $Path); if (!Template::IsValidPath($Path.DIR_SEP.$Name)) { camp_html_goto_page("/$ADMIN/templates/"); } $backLink = "/$ADMIN/templates/?Path=".urlencode($Path); $fileFullName = preg_replace('#^/+#', '', (!empty($Path)) ? $Path.DIR_SEP.$Name : $Name); $fileFullPath = Template::GetFullPath($Path, ''); $errorMsgs = array(); $deleted = false; if (!$isFile) { $deleted = rmdir($fileFullPath.$Name); if ($deleted) { $logtext = getGS('Directory $1 was deleted', mysql_real_escape_string($fileFullName)); Log::Message($logtext, $g_user->getUserId(), 112); camp_html_add_msg($logtext, "ok"); } else { camp_html_add_msg(camp_get_error_message(CAMP_ERROR_RMDIR, $fileFullPath)); } } else { $inUse = Template::InUse($fileFullName); if ($inUse === CAMP_ERROR_READ_FILE || $inUse === CAMP_ERROR_READ_DIR) {
if (!$g_user->hasPermission('ManageTempl')) { camp_html_display_error(getGS("You do not have the right to modify templates.")); exit; } $Path = Input::Get('Path', 'string', ''); $Name = Input::Get('Name', 'string', ''); if (!Template::IsValidPath($Path.DIR_SEP.$Name)) { camp_html_goto_page("/$ADMIN/templates/"); } $cField = Input::Get('cField', 'string', ''); $nField = str_replace("\\r", "\r", $cField); $nField = str_replace("\\n", "\n", $nField); $filename = Template::GetFullPath($Path, $Name); $Lifetime = Input::Get('Lifetime', 'integer', 0); $templateName = (!empty($Path) ? $Path."/" : "").$Name; if ($templateName[0] == '/') { $templateName = substr($templateName, 1); } $template = new Template($templateName); $template->setCacheLifetime($Lifetime); $result = false; if (file_exists($filename)) { if (is_writable($filename)) { if (@$handle = fopen($filename, 'w')) { $result = fwrite($handle, $nField); fclose($handle);
$cName = Input::Get('cName', 'string', ''); $backLink = "/$ADMIN/templates/new_dir.php?Path=".urlencode($cPath); if (trim($cName) == '') { camp_html_add_msg(getGS('You must fill in the $1 field.','<B>'.getGS('Name').'</B>')); camp_html_goto_page($backLink); } if (trim($cName) == '..' || trim($cName) == '.') { camp_html_add_msg(getGS("The folder name can't be '..' or '.'")); camp_html_goto_page($backLink); } $cName = strtr($cName, '?~#%*&|"\'\\/<>', '_____________'); $newdir = Template::GetFullPath($cPath, $cName); $file_exists = file_exists($newdir); if (!$file_exists) { $dir = mkdir($newdir, 0755); if ($dir === true) { camp_html_add_msg(getGS("Directory $1 created.", """.$cName."""), "ok"); camp_html_goto_page("/$ADMIN/templates/?Path=" . urlencode("$cPath/$cName")); } else { camp_html_add_msg(camp_get_error_message(CAMP_ERROR_MKDIR, $newdir)); } } else { camp_html_add_msg(getGS('A file or folder having the name $1 already exists','"'.$cName.'"')); } camp_html_goto_page($backLink); ?>
<?php require_once($GLOBALS['g_campsiteDir']. "/$ADMIN_DIR/templates/template_common.php"); if (!$g_user->hasPermission('ManageTempl')) { camp_html_display_error(getGS("You do not have the right to rename templates.")); exit; } $path = Input::Get('Path', 'string', ''); $Name = Input::Get('Name', 'string', ''); if (!Template::IsValidPath($path)) { $path = ""; } $print_path = ($path != "") ? $path : "/"; $fileFullPath = Template::GetFullPath($path, $Name); if (!is_writable($fileFullPath)) { camp_html_add_msg(getGS("Unable to $1 template.", 'rename')); camp_html_add_msg(camp_get_error_message(CAMP_ERROR_WRITE_DIR, $fileFullPath)); camp_html_goto_page("/$ADMIN/templates/?Path=".urlencode($path)); exit; } $crumbs = array(); $crumbs[] = array(getGS("Configure"), ""); $crumbs[] = array(getGS("Templates"), "/$ADMIN/templates/"); $crumbs = array_merge($crumbs, camp_template_path_crumbs($path)); $crumbs[] = array(getGS("Rename template").": $Name", ""); echo camp_html_breadcrumbs($crumbs); include_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/javascript_common.php");
camp_html_display_error(getGS("You do not have the right to modify templates.")); exit; } $f_path = Input::Get('f_path'); $f_old_name = Input::Get('f_old_name'); $fileName = isset($_FILES['f_file']['name']) ? $_FILES['f_file']['name'] : ''; if (!Template::IsValidPath($f_path) || !Template::IsValidPath($f_path.DIR_SEP.$f_old_name)) { camp_html_goto_page("/$ADMIN/templates/"); } $backLink = "/$ADMIN/templates/edit_template.php?f_path=" . urlencode($f_path)."&f_name=$f_old_name"; // Check that the mime types match $oldFilePath = Template::GetFullPath($f_path, $f_old_name); $oldMimeType = (function_exists('mime_content_type')) ? mime_content_type($oldFilePath) : camp_mime_content_type($oldFilePath); $oldRelativeFilePath = (!empty($f_path)) ? ltrim($f_path.DIR_SEP.$f_old_name, '/') : $f_old_name; $newMimeType = $_FILES['f_file']['type']; $equivalentTextTypes = array("text/plain", "text/html", "application/x-php", "application/octet-stream", "application/javascript", "text/x-c", "text/css" , "text/x-php", "application/x-httpd-php", "text/x-c++"); $matched = false; if (in_array($oldMimeType, $equivalentTextTypes) && in_array($newMimeType, $equivalentTextTypes)) { $matched = true; } if (!$matched && ($oldMimeType != $newMimeType)) { camp_html_add_msg(getGS('You can only replace a file with a file of the same type. The original file is of type "$1", and the file you uploaded was of type "$2".', $oldMimeType, $newMimeType)); camp_html_goto_page($backLink); } // Move the new file it its place