WebEdit Pro requires Microsoft Internet Explorer 5.5 or above Please visit Microsoft to download the latest version of Internet Explorer ", "");
} else if ($ToDo == "PrintVersion") {
PrintVersion();
} else if ($ToDo == "ShowHelp") {
ShowHelp();
} else {
Pass();
}
// Don't print the footer if editing a page...
$footerless_actions = array (
'Edit', 'ShowHelp', 'SavePage', 'EditText', 'SaveTextPage'
);
if (!in_array($ToDo, $footerless_actions)) {
PrintFooter();
}
// Flush the output buffer
ob_end_flush();
//*************************************************************
// Start Functions
//*************************************************************
/**
* DoLogin
* Check a users credentials and log them in if they are a valid user
*
* @return void
*/
function DoLogin()
{
$loginError = false;
$Username = $_POST['ezy_username'];
$Password = $_POST['ezy_password'];
PrintPageHedaer();
// should be array_key_exists for PHP version 4.1 and above
if (array_key_exists($Username, $GLOBALS['users'])) {
if ($Password == $GLOBALS['users'][$Username][0]) {
$_SESSION['auth'] = true;
$_SESSION['access'] = true;
$_SESSION['StartDir'] = $GLOBALS['users'][$Username][1];
$_SESSION['ImageDir'] = $GLOBALS['users'][$Username][2];
$_SESSION['ExcludeDirs'] = explode(',',$GLOBALS['users'][$Username][3]);
// Remove leading and trailing spaces from the directory names to exclude
array_walk($_SESSION['ExcludeDirs'], 'trim');
} else {
$loginError = true;
}
} else {
$loginError = true;
}
if ($loginError == true) {
PrintHeader();
PrintError("Login","Incorrect Login / Password combination Please try again", "");
}
}
/**
* PrintError
* Display an error an die
*
* @param string $str_error_header The title of the errror
* @param string $str_error_message The description of the error
* @param string $str_system_message An additional message to display after the
* description of the error
*
* @return void
*/
function PrintError($str_error_header, $str_error_message, $str_system_message)
{
// Define this variable as static so that if we get an error about the
// footer the first time we can skip it the second time, avoiding an
// infinite loop
static $bool_footer_error= false;
if ($str_error_header == '') {
$str_error_header = 'Error';
}
if ($str_error_message == '') {
$str_error_message = 'A system error has occured. Could not continue.';
}
?>
Incorrect Login / Password combination Please try again", "");
}
}
$includeFile = "webedit_includes/login.inc";
if (file_exists($includeFile)) {
$fileContent = "";
$fileContent = getIncludeFile($includeFile,"Template", "Cannot open Login Template: webedit_includes/login.inc");
$fileContent = str_replace("\$URL", $GLOBALS['URL'], $fileContent);
$fileContent = str_replace("\$SCRIPTNAME", $GLOBALS['scriptName'], $fileContent);
$fileContent = str_replace("\$SERVERNAME", $GLOBALS['URL'], $fileContent);
$fileContent = str_replace("\$HTTP", $GLOBALS['HTTPStr'], $fileContent);
$fileContent = str_replace("\$CHARSET", CHARSET, $fileContent);
echo $fileContent;
} else {
PrintError("Template", "Cannot open Login Template: webedit_includes/login.inc", "File not Found");
}
}
/**
* PrintJSCommon
* Parse and display the jscommon.inc file
*
* @return void
*/
function PrintJSCommon()
{
$includeFile = "webedit_includes/jscommon.inc";
if (file_exists($includeFile)) {
ob_start();
$fileContent = getIncludeFile($includeFile,"Javascript Functions", "Cannot open Javascript Functions include file: webedit_includes/jscommon.inc");
// added for SSL
$fileContent = str_replace("\$HTTP", $GLOBALS['HTTPStr'], $fileContent);
// End addition
$fileContent = str_replace("\$URL", $GLOBALS['URL'], $fileContent);
$fileContent = str_replace("\$SCRIPTNAME", $GLOBALS['scriptName'], $fileContent);
$fileContent = str_replace("\$NEWDIR", $GLOBALS['NewDir'], $fileContent);
echo $fileContent;
} else {
PrintError("Javascript Functions", "Cannot open Javascript Functions include file: webedit_includes/jscommon.inc", "");
}
}
/**
* PrintDir
* Display the directory listing
*
* @return void
*/
function PrintDir()
{
$php_errormsg = '';
$fileImages = array(
"gif,jpg,bmp" => "icon_image.gif",
"mov,avi,wmv" => "icon_movie.gif",
"txt" => "icon_text.gif",
"swf,fla" => "icon_flash.gif",
"pdf" => "icon_pdf.gif",
"doc" => "icon_word.gif",
);
// Print the contents of the directory
// First, load the javascript functions
if ($GLOBALS['CurrentDirectory'] == "/") {
$GLOBALS['CurrentDirectory'] = "";
}
PrintJSCommon();
$objFolder = @opendir($GLOBALS['docRoot'] . "/" . $GLOBALS['CurrentDirectory']) or PrintError("Print Directory", "Cannot open directory for reading: " . $GLOBALS['CurrentDirectory']."", "$php_errormsg");
?>
Please select a file or folder to delete","");
} else {
global $toDelete;
$toDelete = $GLOBALS['CurrentDirectory'] . "/" . $str_file_to_delete;
if ($isFolder == 1) {
$theFile = "";
$theFile = $GLOBALS['CurrentDirectory'] . "/" . $str_file_to_delete;
@rmdir($GLOBALS['docRoot'] . $theFile) or PrintError("Delete Folder", "Could not delete folder: ", "$php_errormsg");
$str_message = $str_file_to_delete . " Deleted Successfully";
$icon = "info.gif";
} else {
$theFile = "";
$theFile = $GLOBALS['CurrentDirectory'] . "/" . $str_file_to_delete;
@unlink($GLOBALS['docRoot'] . $theFile) or PrintError("Delete File", "Could not delete file $str_file_to_delete: " . $php_errormsg, "");;
$str_message = $str_file_to_delete . " Deleted Successfully";
$icon = "info.gif";
}
}
PrintInfoMessage("Delete");
?>
Please select a file to rename.", "");
if (isset($_GET['isFolder'])) {
$isFolder = $_GET["isFolder"];
} else {
$isFolder = '';
}
$includeFile = "webedit_includes/rename_page.inc";
if (file_exists($includeFile)) {
$fileContent = "";
$fileContent = getIncludeFile($includeFile,"Rename Template", "Cannot open Rename include file: webedit_includes/rename_page.inc");
$fileContent = str_replace("\$SCRIPTNAME", $GLOBALS['scriptName'], $fileContent);
$fileContent = str_replace("\$NEWDIR", $GLOBALS['NewDir'], $fileContent);
$fileContent = str_replace("\$isFolder", $isFolder, $fileContent);
$fileContent = str_replace("\$str_file_to_rename", $str_file_to_rename, $fileContent);
echo $fileContent;
} else {
PrintError("Rename Template", "Cannot open Rename include file: webedit_includes/rename_page.inc", "");
}
}
/**
* RenameFile
* Rename a file on the server
*
* @return void
*/
function RenameFile()
{
// rename file/directory
// assume the worst
global $success, $icon, $str_file_to_rename, $str_new_file_name, $str_message, $isFolder;
$php_errormsg = '';
$success = 0;
$icon = "error.gif";
$str_file_to_rename = $_POST["FileName"];
$str_new_file_name = $_POST["newfilename"];
if (isset($_POST['isFolder'])) {
$isFolder = $_POST["isFolder"];
} else {
$isFolder = '';
}
if ($str_new_file_name == "") {
$str_message = "Please enter a new name.";
} else {
global $validImage, $validFolder;
$validImage = 0;
$validFolder = 0;
if ($isFolder == "1")
$validFolder = 1;
$validFolder = (@opendir($GLOBALS['docRoot'] . $GLOBALS['CurrentDirectory'] . "/" . $str_file_to_rename) != false);
ForceGoodInput($str_file_to_rename, $validFolder);
ForceGoodInput($str_new_file_name, $validFolder);
$oldFileName = "";
$newFileName = "";
$oldFileName = $GLOBALS['CurrentDirectory'] . "/" . $str_file_to_rename;
$newFileName = $GLOBALS['CurrentDirectory'] . "/" . $str_new_file_name;
if (file_exists($GLOBALS['docRoot'] . "/" . $newFileName))
$str_message = "A file or folder with that name already exists.";
else
{
@rename($GLOBALS['docRoot'] . $oldFileName, $GLOBALS['docRoot'] . $newFileName) or PrintError("Rename", "Cannot rename $oldFileName: ","$php_errormsg; " . __LINE__);
$success = 1;
$str_message = $str_file_to_rename . " renamed to " . $str_new_file_name . " Successfully.";
$icon = "info.gif";
}
}
PrintInfoMessage("Rename");
?>
>
Please select a file to copy.", "");
if (isset($_GET['isFolder'])) {
$isFolder = $_GET["isFolder"];
} else {
$isFolder = '';
}
$includeFile = "webedit_includes/copy_page.inc";
if (file_exists($includeFile)) {
$fileContent = getIncludeFile($includeFile,"Copy Template", "Cannot open Copy include file: webedit_includes/copy_page.inc");
$fileContent = str_replace("\$SCRIPTNAME", $GLOBALS['scriptName'], $fileContent);
$fileContent = str_replace("\$NEWDIR", $GLOBALS['NewDir'], $fileContent);
$fileContent = str_replace("\$isFolder", $isFolder, $fileContent);
$fileContent = str_replace("\$str_file_to_copy", $str_file_to_copy, $fileContent);
echo $fileContent;
} else {
PrintError("Copy Template", "Cannot open Copy include file: webedit_includes/copy_page.inc", "");
}
}
/**
* CopyFile
* Do the actual file copy
*
* @return void
*/
function CopyFile()
{
global $success, $icon, $str_file_to_copy, $str_new_file_name, $str_message, $isFolder;
$php_errormsg = '';
$success = 0;
$icon = "error.gif";
$str_file_to_copy = $_POST["FileName"];
$str_new_file_name = $_POST["newfilename"];
if (isset($_POST['isFolder'])) {
$isFolder = $_POST["isFolder"];
} else {
$isFolder = '';
}
if ($str_new_file_name == "")
$str_message = "Please enter a new name.";
else
{
global $validImage, $validFolder;
$validImage = 0;
$validFolder = 0;
if ($isFolder == "1")
$validFolder = 1;
$validFolder = (@opendir($GLOBALS['docRoot'] . $GLOBALS['CurrentDirectory'] . "/" . $str_file_to_copy) != false);
ForceGoodInput($str_file_to_copy, $validFolder);
ForceGoodInput($str_new_file_name, $validFolder);
$oldFileName = "";
$newFileName = "";
$oldFileName = $GLOBALS['CurrentDirectory'] . "/" . $str_file_to_copy;
$newFileName = $GLOBALS['CurrentDirectory'] . "/" . $str_new_file_name;
if (file_exists($GLOBALS['docRoot'] . "/" . $newFileName))
$str_message = "A file or folder with that name already exists.";
else
{
$umask = umask(0);
@copy($GLOBALS['docRoot'] . $oldFileName, $GLOBALS['docRoot'] . $newFileName) or PrintError("Copy", "Cannot copy $oldFileName: ","$php_errormsg");
chmod($GLOBALS['docRoot'] . $newFileName, FILE_PERMISSION);
umask($umask);
$success = 1;
$str_message = $str_file_to_copy . " copied to " . $str_new_file_name . " Successfully.";
$icon = "info.gif";
}
}
PrintInfoMessage("Copy");
?>
>
Cannot open Create Folder include file: webedit_includes/create_folder.inc");
$fileContent = str_replace("\$NEWDIR", $GLOBALS['NewDir'], $fileContent);
$fileContent = str_replace("\$SCRIPTNAME", $GLOBALS['scriptName'], $fileContent);
echo $fileContent;
} else {
PrintError("Create Folder Template", "Cannot open Create Folder include file: webedit_includes/create_folder.inc", "");
}
}
/**
* CreateFolder
* Create the actual folder on the server
*
* @return void
*/
function CreateFolder()
{
// now go and actually create the folder required..
// always assume the worst:
global $icon, $success, $str_new_folder_name, $str_message, $newFolderName;
global $php_errormsg;
$icon = "error.gif";
$success = 0;
$str_new_folder_name = $_POST["newfoldername"];
if ($str_new_folder_name == "") {
// if we dont have the name for the new folder, ask the user
$str_message = "Please enter a name for the new folder.";
} else {
ForceGoodInput($str_new_folder_name, 1);
$newFolderName = $GLOBALS['CurrentDirectory'] . "/" . $str_new_folder_name;
if (@opendir($GLOBALS['docRoot'] . $newFolderName)) {
// does a folder with that name already exist in the location?
$str_message = "A file or folder with that name already exists.";
} else {
// okay, we have all we need... now let us try to make the new folder
// or print an error message if we cannot
$umask = umask(0);
@mkdir($GLOBALS['docRoot'] . $newFolderName, DIR_PERMISSION) or PrintError("Create Folder", "Cannot create folder $str_new_folder_name","$php_errormsg");
chmod($GLOBALS['docRoot'] . $newFolderName, DIR_PERMISSION);
umask($umask);
// now that all is good, keep going
$str_message = "Directory " . $str_new_folder_name . " Created Successfully.";
$success = 1;
$icon = "info.gif";
}
}
PrintInfoMessage("Create Folder");
if ($success == 1) {
?>
Cannot open template directory: " . $GLOBALS['TemplateDirectory'] ."", "");
}
}
/**
* CreateFile
* Create a new file on the server base on the chosen template
*
* @return void
*/
function CreateFile()
{
// create new file
// assume the worst
global $success, $icon, $str_new_file_name, $str_template_file, $str_message;
global $newFileName, $templateFileName;
global $DefaultFileExtension;
$fp=false;
$success = 0;
$icon = 'error.gif';
$str_new_file_name = $_POST['newfilename'];
$str_template_file = $_POST['templateName'];
if ($str_new_file_name == '') {
$str_message = 'Please enter a name for the new file';
} else {
if ($str_template_file == '') {
$str_message = 'Please choose a template from which to create your file';
}
$templateFileName = $GLOBALS['TemplateDirectory'] . '/' . $str_template_file;
$str_new_file_name = $str_new_file_name . $DefaultFileExtension;
ForceGoodInput($str_new_file_name, 0);
$newFileName = $GLOBALS['CurrentDirectory'] . '/' . $str_new_file_name;
if (file_exists($GLOBALS['docRoot'] . $newFileName) || @opendir($GLOBALS['docRoot'] . $newFileName)) {
$str_message = 'A file or folder with that name already exists.';
} else {
$fileContent = getIncludeFile($GLOBALS['docRoot'] . $templateFileName,"Error", "Cannot open File: ".$GLOBALS['docRoot']." . $templateFileName");
$pattern = "/(?siU)_template_files/";
$replace = $GLOBALS['TemplateDirectory'].'/_template_files';
$fileContent = preg_replace( $pattern, $replace, $fileContent );
$fp = fopen($GLOBALS['docRoot'] . $newFileName, 'wb');
if ($fp) {
fputs($fp, $fileContent, strlen($fileContent));
fclose($fp);
}
if (file_exists($GLOBALS['docRoot'] . $newFileName)) {
$umask = umask(0);
chmod($GLOBALS['docRoot'] . $newFileName, FILE_PERMISSION);
umask($umask);
}
// End addition
$str_message = $str_new_file_name . ' Created Successfully.';
$success = 1;
$icon = 'info.gif';
}
}
PrintInfoMessage("Create New Page");
?>
", $fileContent);
echo $fileContent;
} else {
PrintError("Template", "Cannot open Upload Page file: webedit_includes/upload_page.inc", "File not Found");
}
}
/**
* UploadPage
* Process the uploaded file
*
* @return void
*/
function UploadPage()
{
ob_start();
$php_errormsg = '';
$pathToFile = '';
$msgExists = '';
$success = true;
$GLOBALS['icon'] = 'info.gif';
$GLOBALS['err_msg'] = '';
$GLOBALS['ok_msg'] = '';
$file = $_FILES["sourcefile"];
//
// Continue with uploading :)
if ($file["size"] < 1){
// If no files have been selected to upload
$GLOBALS['icon'] = "error.gif";
$GLOBALS['err_msg'] = "Please select a file to upload. (No Greater than " . $GLOBALS['maxfilesize'] . " bytes)";
}
else {
if ($file['size'] > $GLOBALS['maxfilesize']) {
$GLOBALS['err_msg'] .= 'The file "'.$file['name'].'" is too big. (Maximum size '.$GLOBALS['maxfilesize'].' bytes). ';
$GLOBALS['icon'] = "error.gif";
}
else {
ForceGoodInput($file['name'], 0);
$pathToFile = $GLOBALS['CurrentDirectory'] . "/" . $file['name'];
if (file_exists($GLOBALS['docRoot'] . "/" . $pathToFile) || @opendir($GLOBALS['docRoot'] . "/" . $pathToFile)) {
$GLOBALS['err_msg'] .= 'Could not upload the file "'.$file['name'].'". A file or folder with that name already exists ';
}
else {
// Uploading file data
if (@move_uploaded_file($file['tmp_name'], $GLOBALS['docRoot'] . $pathToFile)) {
$GLOBALS['ok_msg'] .= $file['name'] . " uploaded successfully. ";
$umask = umask(0);
chmod($GLOBALS['docRoot'] . $pathToFile, FILE_PERMISSION);
umask($umask);
}
else
$GLOBALS['err_msg'] .= 'The file "'.$file['name'] . '" could not be uploaded: '.$php_errormsg.'. ';
}
}
}
PrintUploadInfoMessage("Upload File / Image");
?>
Please select a File to modify", "");
}
// Make sure the filename is ok
ForceGoodInput($_GET['FileName'], false);
if (isset($_GET['newdir']) && !empty($_GET['newdir'])) {
ForceGoodPath($_GET['newdir'], true);
}
if (!empty($_GET['newdir'])) {
$baseHREF = $GLOBALS['HTTPStr'].'://'.$_SERVER['HTTP_HOST'].$_GET['newdir'].'/';
$baseDIR = $GLOBALS['docRoot'].$_GET['newdir'].'/';
$relativeBaseDir = $_GET['newdir'].'/';
} else {
$baseHREF = $GLOBALS['HTTPStr'].'://'.$_SERVER['HTTP_HOST'].$GLOBALS['CurrentDirectory'].'/';
$baseDIR = $GLOBALS['docRoot'].$GLOBALS['CurrentDirectory'].'/';
$relativeBaseDir = $GLOBALS['CurrentDirectory'].'/';
}
ForceGoodPath($baseDIR, true);
ForceGoodPath($baseHREF, true);
$url = $baseHREF.$str_file_name;
$file = str_replace('\\', '/', $baseDIR.$str_file_name);
$extParts = explode('.', $str_file_name);
$extension = array_pop($extParts);
if (!file_exists($file)) {
PrintError('Edit', 'Cannot open file to edit:: ' . $relativeBaseDir.$str_file_name, 'File not Found');
}
include_once(dirname(__FILE__).'/webedit_includes/de/class.devedit.php');
SetDevEditPath('webedit_includes/de');
$editor = new DevEdit();
$editor->SetName('editor');
$editor->SetBaseHref($baseHREF);
$editor->SetFlashPath($_SESSION['ImageDir']);
$editor->SetMediaPath($_SESSION['ImageDir']);
$editor->SetLinkPath($GLOBALS['CurrentDirectory']);
$editor->SetDevEditSkin("default");
$editor->SetDevEditMode("Complete");
$editor->HideFullScreenButton();
$editor->HideSaveButton();
$editor->HideHelpButton();
$editor->AddEventListener("onLoad", "activateToolbar");
// Show the buttons if the config option isn't set
if (isset($GLOBALS['AllowFormattingButtons']) && $GLOBALS['AllowFormattingButtons'] == 0) {
$editor->HideFontList();
$editor->HideSizeList();
$editor->HideFormatList();
$editor->HideForeColorButton();
$editor->HideBackColorButton();
$editor->HideBoldButton();
$editor->HideUnderlineButton();
$editor->HideItalicButton();
$editor->HideStrikethroughButton();
}
//$editor->SetSnippetStyleSheet("/webedit/snippetstyles.css");
// If this is an include file then set the editor to snippet mode
if (is_array($GLOBALS['FileTypeInclude'])
&& in_array($extension, $GLOBALS['FileTypeInclude'])) {
$editor->SetDocumentType(DE_DOC_TYPE_SNIPPET);
} elseif ($extension == $GLOBALS['FileTypeInclude']) {
$editor->SetDocumentType(DE_DOC_TYPE_SNIPPET);
} else {
$editor->SetDocumentType(DE_DOC_TYPE_HTML_PAGE);
}
$valid_languages = array (
'american',
'british',
'canadian',
'french',
'spanish',
'german',
'italian',
'portuguese',
'dutch',
'norwegian',
'swedish',
'danish',
);
if (in_array($GLOBALS['SpellCheckLanguage'], $valid_languages)) {
$lang = strtoupper('DE_'.$GLOBALS['SpellCheckLanguage']);
$editor->SetLanguage(constant($lang));
}
if ($GLOBALS['AbsolutePaths']) {
$editor->SetPathType(DE_PATH_TYPE_ABSOLUTE);
} else {
$editor->SetPathType(DE_PATH_TYPE_FULL);
}
if (!$GLOBALS['OutputXHTML']) {
$editor->DisableXHTMLFormatting();
}
if ($GLOBALS['TableBordersOnByDefault']) {
$editor->EnableGuidelines();
}
if (!$GLOBALS['AllowDeleteImage']) {
$editor->DisableImageDeleting();
}
if (!$GLOBALS['AllowUploadImage']) {
$editor->DisableImageUploading();
}
if (!$GLOBALS['SingleLineReturn']) {
$editor->DisableSingleLineReturn();
}
$errDesc = GetPage($file, $url, $editor);
if ($errDesc != '') {
echo "An error occured: $errDesc";
}
$tbrHeight1 = 27;
$tbrHeight2 = 26;
if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") !== FALSE) {
$tbrHeight1 = 26;
$tbeHeight2 = 20;
} else {
$tbrHeight1 = 27;
$tbrHeight2 = 26;
}
?>