From f8c9cee4df136e004a08ac10b6a45982aa450c0e Mon Sep 17 00:00:00 2001
From: Self-Evident
From e477434ae9149c1b81bf235d22075bb73b965d72 Mon Sep 17 00:00:00 2001
From: Self-Evident Edit “”
- ?i=" class="back">Back
+ Edit “”
Delete “
@@ -452,11 +551,12 @@ function FileTimeStamp(php_filemtime, show_offset){
'.basename($file).' /'; + $folders = glob($varvar."*",GLOB_ONLYDIR); + natcasesort($folders); + foreach ($folders as $folder) { + echo ''; + + echo basename($folder).' /'; } ?>
- @@ -761,7 +835,7 @@ function BLOCK_view() { function list_view() { - global $varvar, $config_excluded, $ftypes, $fclasses ; + global $ONESCRIPT, $varvar, $config_excluded, $ftypes, $fclasses; $files = glob($varvar."{,.}*", GLOB_BRACE); natcasesort($files); @@ -791,8 +865,8 @@ function list_view() { ?>- "> + /">
- -// NEW FOLDER ****************************************************************** + @@ -895,16 +967,16 @@ function list_view() {
- "> + /">
- -// RENAME FILE ***************************************************************** +
- " class="textinput"> + /" class="textinput">
diff --git a/readme.markdown b/readme.markdown
index 142dfe7..2ae5f5f 100644
--- a/readme.markdown
+++ b/readme.markdown
@@ -45,7 +45,7 @@ Coupling a utilitarian code editor with all the basic necessities of an FTP appl
## Features
-- All the basic features of an FTP application like renaming, deleting, copying, and uploading
+- All the basic features of an FTP application like renaming, deleting, copying, and uploading
_(Of course, for more complex processes like batch renaming or mass uploads/deletions, you're going to want to break out an actual FTP program.)_
- Smart alert if you try to leave without saving your edits
- Gracefully degrading CSS and Javascript
@@ -111,6 +111,10 @@ It isn't entirely necessary, but it does provide nice enhancements, like warning
## Change Log
+### 1.2.4
+
+- Mostly a bunch of code modifications/improvements.
+
### 1.2.3
- Fixed check for local css. If not found, loads hosted copy.
From 35037853e94cea1b06526e797590fdbb86feb4d8 Mon Sep 17 00:00:00 2001
From: Self-Evident
- '
+ '
onclick='document.getElementById("message").innerHTML = " ";return false'>
[X]
@@ -230,6 +242,11 @@ function show_image(){ //************************
if ($_GET["p"] == "deletefolder") {
$pagetitle = "Delete Folder";
}
+
+
+
+
+
if (isset($_POST["delete_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
$foldername = $_POST["delete_foldername"];
if (@rmdir($foldername)) {
@@ -241,6 +258,8 @@ function show_image(){ //************************
+
+
// EDIT ************************************************************************
//*** If on Edit page, and [Save] clicked:
@@ -255,6 +274,9 @@ function show_image(){ //************************
$message = '"'.$filename.'" saved successfully.';
}//***
+
+
+
//*** If in directory list, and a filename is clicked:
if (isset($_GET["f"])) {
$filename = stripslashes($_GET["f"]);
@@ -280,6 +302,7 @@ function show_image(){ //************************
if ($_GET["p"] == "new") {$pagetitle = "New File"; }
if (isset($_POST["new_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
$filename = $_POST["new_filename"];
+
if (file_exists($filename)) {
$message = '"'.$filename.'" not created. A file with that name already exists.';
} else {
@@ -296,12 +319,14 @@ function show_image(){ //************************
if ($_GET["p"] == "folder") {$pagetitle = "New Folder"; }
if (isset($_POST["new_folder"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
$foldername = $_POST["new_folder"];
+
if (!is_dir($foldername)) {
mkdir($foldername);
$message = '"'.$foldername.'" created successfully.';
$_GET["i"] = $foldername; //change to new directory
} else {
$message = 'A folder by that name already exists.';
+
}
}
@@ -326,12 +351,16 @@ function show_image(){ //************************
+
+
// RENAME FOLDER ***************************************************************
if ($_GET["p"] == "renamefolder") {$pagetitle = "Rename Folder"; }
if (isset($_POST["rename_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
+
$old_foldername = $_POST["old_foldername"];
$foldername = $_POST["rename_foldername"];
+
//Removed any trailing slashes
while (substr($old_foldername, -1) == '/') {
$old_foldername = rtrim($old_foldername, '/');
@@ -353,6 +382,7 @@ function show_image(){ //************************
// UPLOAD FILE *****************************************************************
if ($_GET["p"] == "upload") {$pagetitle = "Upload File"; }
if (isset($_FILES['upload_filename']['name']) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
+
$filename = $_FILES['upload_filename']['name'];
$newfilename = $filename;
$destination = $_POST["upload_destination"];
From 01fc3bb446653967f48fc3760b92fa2f50655741 Mon Sep 17 00:00:00 2001
From: Self-Evident Folders have to be empty before they can be deleted.
- ">
-
+ ">
+
Are you sure?
@@ -658,8 +668,8 @@ function FileTimeStamp(php_filemtime, show_offset){
From 58557347f1ba1469c2ad3e1bcec513b999144e66 Mon Sep 17 00:00:00 2001
From: Self-Evident
Upload File
New File
- New Folder
+ New Folder
Rename Folder
@@ -967,7 +961,7 @@ function list_view() {
';
+ $page = "index";
+ }
+ else { $pagetitle = "Delete Folder"; }
}
-
-
-
-
if (isset($_POST["delete_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
$foldername = $_POST["delete_foldername"];
+ $_GET["i"] = $foldername;
if (@rmdir($foldername)) {
+ $_GET["i"] = dirname($foldername);
$message = '"'.$foldername.'" successfully deleted.';
} else {
$message = '(!) "'.$foldername.'" is not empty, or other error occurred.';
@@ -258,8 +260,6 @@ function show_image(){ //************************
-
-
// EDIT ************************************************************************
//*** If on Edit page, and [Save] clicked:
@@ -270,13 +270,12 @@ function show_image(){ //************************
if ($fp) {
fwrite($fp, $content);
fclose($fp);
+ $message = '"'.$filename.'" saved successfully.';
+ }else{
+ $message = '(!) There was an error saving file.';
}
- $message = '"'.$filename.'" saved successfully.';
}//***
-
-
-
//*** If in directory list, and a filename is clicked:
if (isset($_GET["f"])) {
$filename = stripslashes($_GET["f"]);
@@ -301,10 +300,10 @@ function show_image(){ //************************
// NEW FILE ********************************************************************
if ($_GET["p"] == "new") {$pagetitle = "New File"; }
if (isset($_POST["new_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
- $filename = $_POST["new_filename"];
-
+ $filename = $_POST["new_filename"];
+ $_GET["i"] = $filename; Check_ipath();
if (file_exists($filename)) {
- $message = '"'.$filename.'" not created. A file with that name already exists.';
+ $message = '(!) "'.$filename.'" not created. A file with that name already exists.';
} else {
$handle = fopen($filename, 'w') or die("can't open file");
fclose($handle);
@@ -319,14 +318,14 @@ function show_image(){ //************************
if ($_GET["p"] == "folder") {$pagetitle = "New Folder"; }
if (isset($_POST["new_folder"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
$foldername = $_POST["new_folder"];
-
+ $_GET["i"] = $foldername; Check_ipath();
if (!is_dir($foldername)) {
mkdir($foldername);
$message = '"'.$foldername.'" created successfully.';
$_GET["i"] = $foldername; //change to new directory
} else {
- $message = 'A folder by that name already exists.';
-
+ $message = '(!) Folder already exists: ';
+ $message .= ''.$foldername.'';
}
}
@@ -346,13 +345,13 @@ function show_image(){ //************************
while (substr($filename, -1) == '/') { $filename = rtrim($filename, '/'); }
rename($old_filename, $filename);
- $message = 'Successfully renamed:
"'.$old_filename.'"
To: "'.$filename.'"';
+ $message = 'Successfully renamed:
';
+ $message .='"'.$old_filename.'"
To:
';
+ $message .='"'.$filename.'"';
}
-
-
// RENAME FOLDER ***************************************************************
if ($_GET["p"] == "renamefolder") {$pagetitle = "Rename Folder"; }
if (isset($_POST["rename_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
@@ -495,6 +494,25 @@ function FileTimeStamp(php_filemtime, show_offset){
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
//******************************************************************************
@@ -524,16 +542,18 @@ function FileTimeStamp(php_filemtime, show_offset){
Delete Folder “”
- Delete Folder “ / ” ?
-
-
- ?>
-
-
-
function list_view() {
@@ -915,11 +887,8 @@ function list_view() {
-
- if ($VIEW_MODE == "BLOCK"){ BLOCK_view(); }
- else { list_view(); }
- ?>
-
+
+
From 26d061694364f4e63b449bef1934bf52e2bb5918 Mon Sep 17 00:00:00 2001
From: David
"'.$old_foldername.'"
To:
"'.$foldername.'".';
+ $message = 'Successfully renamed:
"'.$old_foldername.'"
';
+ $message .= 'To:
"'.$foldername.'".';
$_GET["i"] = $foldername; //return to new folder
} else {
- $message = "There was an error. Try again and/or contact your admin.";
+ $message = "(!) There was an error during rename. Try again and/or contact your admin.";
}
}
@@ -382,32 +384,38 @@ function show_image(){ //************************
if ($_GET["p"] == "upload") {$pagetitle = "Upload File"; }
if (isset($_FILES['upload_filename']['name']) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
- $filename = $_FILES['upload_filename']['name'];
+ $filename = $_FILES['upload_filename']['name'];
$newfilename = $filename;
$destination = $_POST["upload_destination"];
$destintaion = rtrim($destination,"/").'/'; //make sure only a single trailing slash
- $savefile = $destination.$filename;
-
- //if file_exists(), serialize filename until it doesn't
- $serialize = 0;
- $message = 'Uploading: "'.$filename.'" to "'.$destination.'"
';
- if (file_exists($savefile)) {
- $message .= 'However, a file with that name already exists in the target directory.
';
- $savefile_info = pathinfo($savefile);
- }
- while (file_exists($savefile)) {
- $serialize = sprintf("%04d", ++$serialize); // 0001, 0002, 0003, etc...
- $newfilename = $savefile_info['filename'].'.'.$serialize.'.'.$savefile_info['extension'];
- $savefile = $destination . $newfilename;
- }
- $message .= 'Saving as: "'.''.$newfilename.'"';
- //end serialize filename *****************************/
-
- if(move_uploaded_file($_FILES['upload_filename']['tmp_name'], $savefile)) {
- $message .= '
Upload successful.';
- $_GET["i"] = rtrim($destination,"/");
- } else{
- $message .= "
(!) There was an error. Try again and/or contact your host admin.";
+ $savefile = $destination.$filename;
+ $_GET["i"] = rtrim($destination,"/");
+
+ if (($filename == "")){
+ $message = "(!) No file selected for upload... ";
+ }else{
+ $message = 'Uploading: "'.$filename.'" to "'.$destination.'"';
+
+ //if file_exists(), serialize filename until it doesn't
+ $serialize = 0;
+ if (file_exists($savefile)) {
+ $message .= '
(!) A file with that name already exists in the target directory.
';
+ $savefile_info = pathinfo($savefile);
+
+ while (file_exists($savefile)) {
+ $serialize = sprintf("%04d", ++$serialize); // 0001, 0002, 0003, etc...
+ $newfilename = $savefile_info['filename'].'.'.$serialize.'.'.$savefile_info['extension'];
+ $savefile = $destination . $newfilename;
+ }
+ $message .= 'Saving as: "'.''.$newfilename.'"';
+ }
+ //end serialize filename *****************************/
+
+ if(move_uploaded_file($_FILES['upload_filename']['tmp_name'], $savefile)) {
+ $message .= '
Upload successful.';
+ } else{
+ $message .= "
(!) There was an error. Try again and/or contact your host admin.";
+ }
}
} //end Upload file
@@ -589,8 +597,9 @@ function FileTimeStamp(php_filemtime, show_offset){
- Delete “
+ $varvar = '?i='.dirname($_GET["d"]);
+
+?>
Delete “
”
Delete Folder “ / ” ?
+ $varvar = "?i=".substr($_GET["i"],0,strrpos(substr_replace($_GET["i"],"",-1),"/"));
+
+?> Delete Folder “ / ” ?
Rename Folder “”
Upload
- Upload
+ ';
-}// end show_image() ****************************
+}// end show_image() ***********************************
+
+function show_favicon(){
+ global $config_favicon, $DOC_ROOT;
+ if (file_exists($DOC_ROOT.$config_favicon)) {
+ echo '
';
+ }
+}// end show_favicon()
+
// End of misc funtions ********************************************************
-// COPY FILE *******************************************************************
+
+
+// COPY FILE response code *****************************************************
if (isset($_GET["c"])) {
$page = "copy"; $filename = $_GET["c"]; $pagetitle = "Copy";
}
@@ -219,13 +233,20 @@ function show_image(){ //************************
if (isset($_POST["copy_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
$old_filename = $_POST["old_filename"];
$filename = $_POST["copy_filename"];
- copy($old_filename, $filename);
- $message = '"'.$old_filename.'" copied successfully to "'.$filename.'".';
-}
+
+ if (copy($old_filename, $filename)){
+ $message = '"'.$old_filename.'"
';
+ $message .= ' --- successfully copied to ---
';
+ $message .= '"'.$filename.'".';
+ }else{
+ $message .= '(!) Error copying file:
"'.$filename.'".';
+ }
+}//end COPY FILE response code *************************************************
+
-// DELETE FILE *****************************************************************
+// DELETE FILE response code ***************************************************
if (isset($_GET["d"])) {
$page = "delete"; $filename = $_GET["d"]; $pagetitle = "Delete";
}
@@ -234,15 +255,16 @@ function show_image(){ //************************
$filename = $_POST["delete_filename"];
if (unlink($filename)) {
- $message = '"'.$filename.'" successfully deleted.';
+ $message = '"'.basename($filename).'" successfully deleted.';
}else{
$message = '(!) Error deleting "'.$filename.'".';
}
-}
+}//end DELETE FILE response code ***********************************************
+
-// DELETE FOLDER ***************************************************************
+// DELETE FOLDER response code *************************************************
if ($_GET["p"] == "deletefolder") {
if (!is_empty($_GET["i"])){
$message = '(!) Folder is not empty. Folders must be empty before they can be deleted.
';
@@ -256,15 +278,16 @@ function show_image(){ //************************
$_GET["i"] = $foldername;
if (@rmdir($foldername)) {
$_GET["i"] = dirname($foldername);
- $message = '"'.$foldername.'" successfully deleted.';
+ $message = '"'.basename($foldername).'/" successfully deleted.';
} else {
- $message = '(!) "'.$foldername.'" is not empty, or other error occurred.';
+ $message = '(!) "'.$foldername.'/" is not empty, or other error occurred.';
}
-}
+}//end DELETE FOLDER response code *********************************************
+
-// EDIT ************************************************************************
+// EDIT Page response code *****************************************************
//*** If on Edit page, and [Save] clicked:
if (isset($_POST["filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
@@ -298,10 +321,12 @@ function show_image(){ //************************
unset ($filename);
}
}//***
+//End Edit page response code **************************************************
-// NEW FILE ********************************************************************
+
+// NEW FILE response code ******************************************************
if ($_GET["p"] == "new") {$pagetitle = "New File"; }
if (isset($_POST["new_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
$filename = $_POST["new_filename"];
@@ -311,31 +336,33 @@ function show_image(){ //************************
} else {
$handle = fopen($filename, 'w') or die("can't open file");
fclose($handle);
- $message = '"'.$filename.'" created successfully.';
+ $message = '"'.$filename.'" created successfully.';
$_GET["i"] = dirname($filename); //return to file's directory.
}
-}
+}//end NEW FILE response code **************************************************
-// NEW FOLDER ******************************************************************
-if ($_GET["p"] == "folder") {$pagetitle = "New Folder"; }
+
+// NEW FOLDER response code ****************************************************
+if ($_GET["p"] == "newfolder") {$pagetitle = "New Folder"; }
if (isset($_POST["new_folder"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
$foldername = $_POST["new_folder"];
$_GET["i"] = $foldername; Check_ipath();
if (!is_dir($foldername)) {
mkdir($foldername);
- $message = '"'.$foldername.'" created successfully.';
+ $message = '"'.$foldername.'/" created successfully.';
$_GET["i"] = $foldername; //change to new directory
} else {
$message = '(!) Folder already exists: ';
- $message .= ''.$foldername.'';
+ $message .= ''.$foldername.'/';
}
-}
+}//end NEW FOLDER response code ************************************************
-// RENAME FILE *****************************************************************
+
+// RENAME FILE response code ***************************************************
if (isset($_GET["r"])) {
$filename = $_GET["r"];
$pagetitle = "Rename File";
@@ -346,41 +373,44 @@ function show_image(){ //************************
$filename = $_POST["rename_filename"];
//Removed any trailing slashes
- while (substr($filename, -1) == '/') { $filename = rtrim($filename, '/'); }
+ $filename = rtrim($filename, '/');
rename($old_filename, $filename);
- $message = 'Successfully renamed:
';
- $message .='"'.$old_filename.'"
To:
';
- $message .='"'.$filename.'"';
-}
+ $message .= '"'.$old_filename.'"
';
+ $message .= ' successfully renamed to:
';
+ $message .= '"'.$filename.'"';
+}//end RENAME FILE response code ***********************************************
-// RENAME FOLDER ***************************************************************
+
+// RENAME FOLDER response code *************************************************
if ($_GET["p"] == "renamefolder") {$pagetitle = "Rename Folder"; }
-if (isset($_POST["rename_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
+if (isset($_POST["new_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
$old_foldername = $_POST["old_foldername"];
- $foldername = $_POST["rename_foldername"];
+ $new_foldername = $_POST["new_foldername"];
$_GET["i"] = $old_foldername;
Check_ipath();
//Removed any trailing slashes
$old_foldername = rtrim($old_foldername, '/');
- $foldername = rtrim($foldername, '/');
+ $new_foldername = rtrim($new_foldername, '/');
- if (rename($old_foldername, $foldername)) {
- $message = 'Successfully renamed:
"'.$old_foldername.'"
';
- $message .= 'To:
"'.$foldername.'".';
- $_GET["i"] = $foldername; //return to new folder
+ if (rename($old_foldername, $new_foldername)) {
+ $message .= '"'.$old_foldername.'/"
';
+ $message .= ' successfully renamed to:
';
+ $message .= '"'.$new_foldername.'/"';
+ $_GET["i"] = $new_foldername; //return to new folder
} else {
$message = "(!) There was an error during rename. Try again and/or contact your admin.";
}
-}
+}//end RENAME FOLDER response code *********************************************
+
-// UPLOAD FILE *****************************************************************
+// UPLOAD FILE response code ***************************************************
if ($_GET["p"] == "upload") {$pagetitle = "Upload File"; }
if (isset($_FILES['upload_filename']['name']) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
@@ -414,10 +444,10 @@ function show_image(){ //************************
if(move_uploaded_file($_FILES['upload_filename']['tmp_name'], $savefile)) {
$message .= '
Upload successful.';
} else{
- $message .= "
(!) There was an error. Try again and/or contact your host admin.";
+ $message .= "
(!) There was an error. Upload or rename may have failed.";
}
}
-} //end Upload file
+} //end Upload file response code **********************************************
@@ -425,22 +455,6 @@ function show_image(){ //************************
-//*** local or a hosted style sheet? *******************************************
-function style_sheet() {
-global $DOC_ROOT, $config_csslocal, $CWD;
-$STYLE_SHEET = $config_csslocal;
-$ROOT = $DOC_ROOT;
-
-// If csslocal has a leading /, assume it's location relative to $DOC_ROOT
-// If it has no leading /, assume it is relative to this file.
-if (substr($config_csslocal,0,1) != "/"){ $ROOT = $CWD.'/'; }
-
-//Check for local style sheet. If not found, use hosted copy.
-if (!file_exists($ROOT.$config_csslocal) || is_dir($ROOT.$config_csslocal)) { $STYLE_SHEET = $config_csshosted; }
-
-
-?>
+
+
-
-
+
-
-
-
-
New Folder
@@ -1023,8 +1017,8 @@ function list_view() {
" class="textinput" disabled="disabled">
- - "> + + ">
diff --git a/readme.markdown b/readme.markdown old mode 100644 new mode 100755 index 2ae5f5f..257e7ac --- a/readme.markdown +++ b/readme.markdown @@ -111,9 +111,9 @@ It isn't entirely necessary, but it does provide nice enhancements, like warning ## Change Log -### 1.2.4 +### 1.2.4 - 1.2.8 -- Mostly a bunch of code modifications/improvements. +- Mostly just a bunch of code modifications/improvements. ### 1.2.3 @@ -216,8 +216,6 @@ To report a bug or request a feature, please file an issue via Github. Forks enc - With Chrome, and possibly Safari, issue with Edit page: Clicking browser [back] & then browser [forward], with file changed and not saved. On return (after [forward] clicked), file still has changes, but indicators are green (saved/unchanged). Does not affect FF 7+ or IE 8+. - Prompt to prevent automatic overwrite when uploading or renaming files. -- Clickable option to switch between original OneFileCMS view and a common list view. - (Currently accomplished with a config variable.) - Embed css and remove or swtich to svg icons to create a true "OneFileCMS" (in the works) - Check size of file to upload, verify under max post/upload limits. From 923e11f5648bc148fbfaa4c07ad1df5d7ce7eead Mon Sep 17 00:00:00 2001 From: Self-EvidentExisting files with the same filename are automatically overwritten... Be careful!
+( ! ) Existing files with the same filename are automatically overwritten... Be careful!
+@@ -684,7 +688,8 @@ function Reset_File() {
- "> +
@@ -761,17 +765,15 @@ function Reset_File() {
- - - - + +Existing files with the same name will not be overwritten.
-@@ -963,10 +966,11 @@ function list_view() { + if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; } +?>
Existing folders with the same name will not be overwritten.
-@@ -981,12 +985,13 @@ function list_view() { + $varvar = "?i=".dirname($_GET["r"]); +?>
Existing files with the same filename are automatically overwritten... Be - careful!
+Existing files with the same filename are automatically overwritten... Be careful!
To move a file, preface its name with the folder's name, as in "foldername/filename.txt." The folder must already exist.
+
From f9858ec468c5b5f73b5cac38e7c7b1559deb4d62 Mon Sep 17 00:00:00 2001
From: Self-Evident
+ ';
+
+ echo basename($folder).' /';
+ } ?>
+
+ Upload File
+ New File
+ New Folder
+
+
+ Rename Folder
+
+ Delete Folder
+
+
+
+
+
+
+
+
+ /" class="textinput">
+
+
+
+ Existing files with the same name will not be overwritten.
+
+ /">
+ Existing files with the same filename are automatically overwritten... Be careful! To move a file, preface its name with the folder's name, as in
+ "foldername/filename.txt." The folder must already exist.
+
+
+
+
+
+
+ Are you sure? Existing folders with the same name will not be overwritten.
- ">
-
+
+ /">
+ ">
+ " class="textinput" disabled="disabled">
+
+ ">
+
-
-
-
-
-
+ ">
+
- ';
- echo basename($folder).' /';
- } ?>
-
- Upload File
- New File
- New Folder
-
-
- Rename Folder
-
- Delete Folder
-
- Existing files with the same name will not be overwritten.
-
- /">
- Existing folders with the same name will not be overwritten.
-
- /">
- Existing files with the same filename are automatically overwritten... Be careful! To move a file, preface its name with the folder's name, as in
- "foldername/filename.txt." The folder must already exist.
-
-
-
-
-
-
-
- ">
- " class="textinput" disabled="disabled">
-
-
- ">
-
-
- /" class="textinput">
-
-
-
-
-
-
-
+ Upload File
+ New File
+ New Folder
+
+
+ Rename Folder
+
+ Delete Folder
+
+
+
+
+
-
-
+
+
-
-
+
+
- ';
+ $folders = glob($ipath."*",GLOB_ONLYDIR);
natcasesort($folders);
foreach ($folders as $folder) {
- echo '';
-
+ echo '';
echo basename($folder).' /';
- } ?>
-
- Upload File
- New File
- New Folder
-
-
- Rename Folder
-
- Delete Folder
-
-
-
+
+
-
+
-
- /" class="textinput">
-
-
-
- Existing files with the same name will not be overwritten.
-
- /">
- ( ! ) Existing files with the same filename are automatically overwritten... Be careful!
+
-
+
+
+ class="textinput" value="">
Existing files with the same filename are automatically overwritten... Be careful! To move a file, preface its name with the folder's name, as in
- "foldername/filename.txt." The folder must already exist. To move a file, change the folder's name, as in
+ "newfolder/filename.txt". The new folder must already exist.
-
-
+
+
+
Are you sure?
-
-
- Are you sure? Existing folders with the same name will not be overwritten.
-
- /">
-
- ">
- " class="textinput" disabled="disabled">
+
+
+
- ">
+
+
- ">
-
- Are you sure?
- Upload File
- New File
- New Folder
-
-
- Rename Folder
-
- Delete Folder
-
- ';
$folders = glob($ipath."*",GLOB_ONLYDIR);
natcasesort($folders);
foreach ($folders as $folder) {
echo '';
+
echo basename($folder).' /';
}
echo '
-
- Non-text or unkown file type. Edit disabled.
+?>
@@ -980,7 +933,7 @@ function New_Folder_response(){ //**********************************************
$message .= $EX.' Folder already exists: ';
$message .= htmlentities($new_folder).'';
}elseif (mkdir($new_folder)) {
- $message .= 'Created folder '.htmlentities(basename($new_folder)).'';
+ $message .= 'Created folder: '.htmlentities(basename($new_folder)).'';
$ipath = $new_folder; //return to new folder
$param1 = '?i='.URLencode_path($ipath);
}else{
@@ -1031,16 +984,6 @@ function Delete_Folder_response() { //******************************************
-// Login Page response message**************************************************
-if (isset($_POST["username"])) {
- if (($_SESSION['username'] != $config_username) || ($_SESSION['password'] != $config_password))
- { $message = "(!) INVALID LOGIN ATTEMPT"; }
-}//end Login Page response message**********************************************
-
-
-
-
-
//Logout ***********************************************************************
if ($page == "logout") {
$page = "login";
@@ -1448,8 +1391,6 @@ function style_sheet(){ //****************************************************?>
/* [Upload File] [New File] [New Folder] etc... */
-.front_links { clear: both; }
-
.front_links a {
display: inline-block;
border : 1px solid #807568;
@@ -1460,6 +1401,9 @@ function style_sheet(){ //****************************************************?>
background-color: #EEE;
}
+.front_links a .icon_fldr {margin : 1.5px 5px 0 0; }
+.front_links a .icon_file {margin : 1.0px 5px 0 0; }
+
.front_links a:hover { background-color: rgb(255,250,150); }
.front_links a:focus { background-color: rgb(255,250,150); }
@@ -1479,7 +1423,15 @@ function style_sheet(){ //****************************************************?>
height: 30em;
}
-textarea[disabled] { width : 99.5%; height: 50px; background-color: #EEE; color: #777;}
+.edit_disabled {
+ border : 1px solid #807568;
+ width : 99%;
+ padding: .2em;
+ margin : 0;
+ color: #444;
+ background-color: #F8F8F8;
+ line-height: 1.4em;
+ }
textarea:focus { border: 1px solid #Faa; }
@@ -1542,7 +1494,7 @@ function style_sheet(){ //****************************************************?>
#file_content {height: 24em;}
-.file_meta {float: left; margin-top: .5em; font-size: .9em; color: #333; font-family: courier;}
+.file_meta {float: left; margin-top: .5em; font-size: 1em; color: #333; font-family: courier;}
.close {float: right; margin-bottom: .5em;}
@@ -1590,16 +1542,16 @@ function style_sheet(){ //****************************************************?>
.web_root { font:1.2em Courier; }
.verify {
- border: 1px solid #807568;
+ border: 1px solid #F44;
color: #333;
- background-color: #FEE;
+ background-color: #FFE7E7;
padding: .1em .2em;
font: 1.2em Courier;
}
.sure { margin: .7em 0em .5em 0; }
-.icon {float: left; margin: 0 5px 0 0;}
+.icon {float: left; margin: 0 .3em 0 0;}
Date: Sun, 3 Jun 2012 19:29:44 -0400
Subject: [PATCH 070/228] Version 3.1.4 Added basic validation of "f"
(filename) parameter. Moved validation for $page up to where GET param's are
got. Added max file size checks to upload page & response. Added error code
responses to upload message.
---
onefilecms.php | 93 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 63 insertions(+), 30 deletions(-)
diff --git a/onefilecms.php b/onefilecms.php
index 8da9a75..cc555f5 100755
--- a/onefilecms.php
+++ b/onefilecms.php
@@ -1,7 +1,7 @@
File does not exist: '.$filename.' Note: Maximum upload file size is: '.$large_file_message1.' Non-text or unkown file type. Edit disabled.
-
-
- '.$large_file_message2.'
-
+
[X]
@@ -287,11 +264,12 @@ function message_box() { //*********************************
// Used on Edit Page to preserve vertical spacing, so edit area doesn't jump as much.
if ($page == "edit") {echo '';}
-}//end message_box() **************************************
+}//end message_box() **********************************************************
+
-function Upload_New_Rename_Delete_Links() { //**************
+function Upload_New_Rename_Delete_Links() { //**********************************
global $ONESCRIPT, $ipath, $param1;
echo ' ';
echo '' ; svg_icon_upload() ; echo 'Upload File';
@@ -302,20 +280,22 @@ function Upload_New_Rename_Delete_Links() { //**************
echo ''; svg_icon_folder_del(); echo 'Delete Folder';
}
echo '
-
-
+
-
- '.$large_file_message2.' '.$too_large_to_view_message.' Note: Maximum upload file size is: Note: Maximum upload file size is:
-
[X]
@@ -303,7 +303,7 @@ function message_box() { //*****************************************************
} //end isset($message)
// Used on Edit Page to preserve vertical spacing, so edit area doesn't jump as much.
- if ($page == "edit") {echo '';}
+ if ($page == "edit") {echo '';}
}//end message_box() **********************************************************
@@ -1375,13 +1375,13 @@ function Reset_File() {
function style_sheet(){ //****************************************************?>
From 03e53139346a2b6b9d8436674d4f263e8de6c125 Mon Sep 17 00:00:00 2001
From: Self-Evident
-
-
- There are two ways to change your OneFileCMS password:
+ 1) Simply use the $PASSWORD config variable to store your desired password, and set $USE_HASH = 0 (zero). Keep in mind that due to a number of widely varied considerations, this is largely an academic excersize. Anyway, to use the $HASHWORD password option:
+ You can use OneFileCMS to edit itself. However, be sure to have a backup ready for the inevitable tupo...
+ *Note: While still largely academic, you can improve security a bit more by changing the default salt and/or method used by OneFileCMS to hash the password (and keep 'em secret, of course). ';
+ echo 'Image shown at ~'. round($SCALE*100) .'% of full size (W x H = '.$img_info[0].' x '.$img_info[1].').
-
-document.getElementById("'.$focus.'").focus();'; }
-
+ //Do not close the tag yet/here. Need to leave it open for edit btn on hash page.
}// End Cancel_Submit_Buttons() //**********************************************
@@ -437,23 +445,13 @@ function show_favicon(){ //*****************************************************
-function Timeout_Timer($TIMER, $CLASS) { //***************************************************
- global $MAX_IDLE_TIME;
-?>
-
-
-'.
+ 'Start_Countdown('.$COUNT.', "'.$ID.'", "'.$CLASS.'", "'.$ACTION.'");'.
+ '';
+
+} //end Timeout_Timer() **************************************************
@@ -661,7 +659,7 @@ function Hash_Page() { //******************************************************
Keep in mind that due to a number of widely varied considerations, this is largely an academic excersize.
That is, take the idea that this adds much of an improvement to security with a grain of cryptographic salt.
- However, it does eleminate the storage of your password in plain text, which is definitely an improvement.*
+ However, it does eleminate the storage of your password in plain text, which is always a good thing.*
Anyway, to use the $HASHWORD password option:
Are you sure? Are you sure? Are you sure? Are you sure? Admin'; }
//Countdown timer...
-if ( $page != "edit" && $page != login) {
- Timeout_Timer('timer', 'timeout');
+if ( $page != "login" ) {
+ echo Timeout_Timer($MAX_IDLE_TIME, 'timer0', 'timer timeout', 'LOGOUT');
echo 'Session time out in: ';
-}
+}
?>
-
\ No newline at end of file
diff --git a/readme.markdown b/readme.markdown
index 6b821ba..4b8e2a7 100755
--- a/readme.markdown
+++ b/readme.markdown
@@ -1,10 +1,4 @@
-### June 25, 2012
-
-### Unable to upload current version to the download page.
-
-- If you are interested in obtaining the current version - 3.2.0, just get it from the list of project files. For some reason, whenever I try to upload it to the download page, I get the error:
- "Something went wrong that shouldn't have. Please try again or contact support if the problem persists."
-
+### June 28, 2012
Most of the recent changes have been to increase login and session security. However, I'm slowly learning that there's only so much that can be done, particulary when the base connection is un-encrypted. Online security, it seems, is a nebulous subject of a rather dubious nature. Never-the-less, I have tried to do those things that can be done.
@@ -24,10 +18,10 @@ Now, keep in mind that while, individually, any one of these measures may not pr
Lastly, always remember that some of the most important security measures concern user behavior - such as avoiding the use of un-encrypted wifi connections...
-# Current stable version: 3.2.0
+# Current stable version: 3.2.1
-- 3.0+ : "Full" version - uses svg icons
-- 2.0+ : "Lite" version - uses no icons.
+- 3+ : "Full" version - uses svg icons
+- 2+ : "Lite" version - uses no icons.
--------------------------------------------------------------------------------
@@ -100,9 +94,9 @@ Probably not, as that would also most likely make it more than "OneFile".
### Can I have more than one username/password?
-Well, indirectly - yes: Upload or create addional copies of OneFileCMS, but give them different file names.(ie: OneFile1.php and OneFile2.php etc...) Then, with each copy, maintain different user names and passwords. Also, so one user does not log out the other, change the session names set in session_startup().
+Yes! Well, sort of, indirectly. Upload or create addional copies of OneFileCMS, but give them different file names.(ie: OneFile1.php and OneFile2.php etc...) Then, with each copy, maintain different user names and passwords. Also, so one user does not log out the other, change the session names.
-Now, since there is no data base or other means of granular control and acess logging, multiple users may be kind of pointless. On the other hand, having at least one working backup copy of OneFileCMS available is recommended in case the primary copy get's corrupted.
+Now, since there is no data base or other means of granular control and acess logging, multiple users may be kind of pointless. On the other hand, having at least one working backup copy of OneFileCMS available is recommended in case the primary copy gets corrupted.
## Requirements
@@ -170,6 +164,11 @@ GENERATE THE PAGE
## Change Log
+### 3.2.1
+
+- Added timer to "Please wait..." message after too many invalid login attempts.
+- Mostly some misc code cleanup & improvement.
+
### 3.2.0
- Added a few security improvements.
@@ -311,4 +310,3 @@ GENERATE THE PAGE
### 1.0 (9/5/09)
- Launch!
-
\ No newline at end of file
From ec2eb2c25b3db7d7fe482f877bccf17f4804eb11 Mon Sep 17 00:00:00 2001
From: David
+
+
+ [X]
+
+
+ ';
+ echo '' ; echo 'Upload File';
+ echo '' ; echo 'New File' ;
+ echo ''; echo 'New Folder' ;
+ if ($ipath !== "") { //if at root, don't show Rename & Delete links
+ echo ''; echo 'Rename/Move Folder';
+ echo ''; echo 'Delete Folder';
+ }
+ echo '
+
+
+document.getElementById("'.$focus.'").focus();'; }
+ //Do not close the tag yet/here. Need to leave it open for edit btn on hash page.
+}// End Cancel_Submit_Buttons() //**********************************************
+
+
+
+
+function show_image(){ //*******************************************************
+ global $filename, $MAX_IMG_W, $MAX_IMG_H;
+
+ $IMG = $filename;
+ $img_info = getimagesize($IMG);
+
+ $W=0; $H=1;
+ $SCALE = 1; $TOOWIDE = 0; $TOOHIGH = 0;
+ if ($img_info[$W] > $MAX_IMG_W) { $TOOWIDE = ( $MAX_IMG_W/$img_info[$W] );}
+ if ($img_info[$H] > $MAX_IMG_H) { $TOOHIGH = ( $MAX_IMG_H/$img_info[$H] );}
+
+ if ($TOOHIGH || $TOOWIDE) {
+ if (!$TOOWIDE) {$SCALE = $TOOHIGH;}
+ elseif (!$TOOHIGH) {$SCALE = $TOOWIDE;}
+ elseif ($TOOHIGH > $TOOWIDE) {$SCALE = $TOOWIDE;} //ex:if (.90 > .50)
+ else {$SCALE = $TOOHIGH;}
+ }
+
+ echo ' ';
+ echo 'Image shown at ~'. round($SCALE*100) .'% of full size (W x H = '.$img_info[0].' x '.$img_info[1].'). There are two ways to change your OneFileCMS password:
+ 1) Simply use the $PASSWORD config variable to store your desired password, and set $USE_HASH = 0 (zero). Keep in mind that due to a number of widely varied considerations, this is largely an academic excersize.
+ That is, take the idea that this adds much of an improvement to security with a grain of cryptographic salt.
+ However, it does eleminate the storage of your password in plain text, which is always a good thing.*
+
+ Anyway, to use the $HASHWORD password option:
+ You can use OneFileCMS to edit itself. However, be sure to have a backup ready for the inevitable ytpo...
+
+ *For another small improvement to security, change the default salt and/or method used by OneFileCMS to hash the password (and keep 'em secret, of course). Remever, every little bit helps...
+
+
+
+
+
+ ';
+ $folders = glob($ipath."*",GLOB_ONLYDIR);
+ natcasesort($folders);
+ foreach ($folders as $folder) {
+ echo ''.PHP_EOL;
+
+ echo htmlentities(basename($folder)).' /';
+ }
+ echo ' '.$too_large_to_edit_message.' '.$too_large_to_view_message.' Note: Maximum upload file size is: File will be created in the current folder.
+ Some invalid characters are: To move a file or folder, change the path/to/folder/or_file. The new location must already exist.
+
+
+
+
+
+ Are you sure? Folder will be created in the current folder.
+ Some invalid characters are: Are you sure?
-
-
- [X]
-
-
- ';
- echo '' ; svg_icon_upload() ; echo 'Upload File';
- echo '' ; svg_icon_file_new() ; echo 'New File' ;
- echo ''; svg_icon_folder_new(); echo 'New Folder' ;
- if ($ipath !== "") { //if at root, don't show Rename & Delete links
- echo ''; svg_icon_folder_ren(); echo 'Rename/Move Folder';
- echo ''; svg_icon_folder_del(); echo 'Delete Folder';
- }
- echo '
-
-
-document.getElementById("'.$focus.'").focus();'; }
- //Do not close the tag yet/here. Need to leave it open for edit btn on hash page.
-}// End Cancel_Submit_Buttons() //**********************************************
-
-
-
-
-function show_image(){ //*******************************************************
- global $filename, $MAX_IMG_W, $MAX_IMG_H;
-
- $IMG = $filename;
- $img_info = getimagesize($IMG);
-
- $W=0; $H=1;
- $SCALE = 1; $TOOWIDE = 0; $TOOHIGH = 0;
- if ($img_info[$W] > $MAX_IMG_W) { $TOOWIDE = ( $MAX_IMG_W/$img_info[$W] );}
- if ($img_info[$H] > $MAX_IMG_H) { $TOOHIGH = ( $MAX_IMG_H/$img_info[$H] );}
-
- if ($TOOHIGH || $TOOWIDE) {
- if (!$TOOWIDE) {$SCALE = $TOOHIGH;}
- elseif (!$TOOHIGH) {$SCALE = $TOOWIDE;}
- elseif ($TOOHIGH > $TOOWIDE) {$SCALE = $TOOWIDE;} //ex:if (.90 > .50)
- else {$SCALE = $TOOHIGH;}
- }
-
- echo ' ';
- echo 'Image shown at ~'. round($SCALE*100) .'% of full size (W x H = '.$img_info[0].' x '.$img_info[1].'). There are two ways to change your OneFileCMS password:
- 1) Simply use the $PASSWORD config variable to store your desired password, and set $USE_HASH = 0 (zero). Keep in mind that due to a number of widely varied considerations, this is largely an academic excersize.
- That is, take the idea that this adds much of an improvement to security with a grain of cryptographic salt.
- However, it does eleminate the storage of your password in plain text, which is always a good thing.*
-
- Anyway, to use the $HASHWORD password option:
- You can use OneFileCMS to edit itself. However, be sure to have a backup ready for the inevitable ytpo...
-
- *For another small improvement to security, change the default salt and/or method used by OneFileCMS to hash the password (and keep 'em secret, of course). Remever, every little bit helps...
-
-
-
-
-
- ';
- $folders = glob($ipath."*",GLOB_ONLYDIR);
- natcasesort($folders);
- foreach ($folders as $folder) {
- echo ''.PHP_EOL;
- svg_icon_folder();
- echo htmlentities(basename($folder)).' /';
- }
- echo ' '.$too_large_to_edit_message.' '.$too_large_to_view_message.' Note: Maximum upload file size is: File will be created in the current folder.
- Some invalid characters are: To move a file or folder, change the path/to/folder/or_file. The new location must already exist.
-
-
-
-
-
- Are you sure? Folder will be created in the current folder.
- Some invalid characters are: Are you sure?
+
+
+ [X]
+
+
+ ';
+ echo '' ; svg_icon_upload() ; echo 'Upload File';
+ echo '' ; svg_icon_file_new() ; echo 'New File' ;
+ echo ''; svg_icon_folder_new(); echo 'New Folder' ;
+ if ($ipath !== "") { //if at root, don't show Rename & Delete links
+ echo ''; svg_icon_folder_ren(); echo 'Rename/Move Folder';
+ echo ''; svg_icon_folder_del(); echo 'Delete Folder';
+ }
+ echo '
+
+
+document.getElementById("'.$focus.'").focus();'; }
+ //Do not close the tag yet/here. Need to leave it open for edit btn on hash page.
+}// End Cancel_Submit_Buttons() //**********************************************
+
+
+
+
+function show_image(){ //*******************************************************
+ global $filename, $MAX_IMG_W, $MAX_IMG_H;
+
+ $IMG = $filename;
+ $img_info = getimagesize($IMG);
+
+ $W=0; $H=1; //indexes for $img_info[]
+ $SCALE = 1; $TOOWIDE = 0; $TOOHIGH = 0;
+ if ($img_info[$W] > $MAX_IMG_W) { $TOOWIDE = ( $MAX_IMG_W/$img_info[$W] );}
+ if ($img_info[$H] > $MAX_IMG_H) { $TOOHIGH = ( $MAX_IMG_H/$img_info[$H] );}
+
+ if ($TOOHIGH || $TOOWIDE) {
+ if (!$TOOWIDE) {$SCALE = $TOOHIGH;}
+ elseif (!$TOOHIGH) {$SCALE = $TOOWIDE;}
+ elseif ($TOOHIGH > $TOOWIDE) {$SCALE = $TOOWIDE;} //ex: if (.90 > .50)
+ else {$SCALE = $TOOHIGH;}
+ }
+
+ echo ' ';
+ echo 'Image shown at ~'. round($SCALE*100) .'% of full size (W x H = '.$img_info[0].' x '.$img_info[1].'). There are two ways to change your OneFileCMS password:
+ 1) Use the $PASSWORD config variable to store your desired password, and set $USE_HASH = 0 (zero). Keep in mind that due to a number of widely varied considerations, this is largely an academic excersize.
+ That is, take the idea that this adds much of an improvement to security with a grain of cryptographic salt.
+ However, it does eleminate the storage of your password in plain text, which is a good thing*
+
+ Anyway, to use the $HASHWORD password option:
+ You can use OneFileCMS to edit itself. However, be sure to have a backup ready for the inevitable ytpo...
+
+ *For another small improvement to security, change the default salt and/or method used by OneFileCMS to hash the password (and keep 'em secret, of course). Remever, every little bit helps...
+
+
+
+
+
+ ';
+ $folders = glob($ipath."*",GLOB_ONLYDIR);
+ natcasesort($folders);
+ foreach ($folders as $folder) {
+ echo ''.PHP_EOL;
+ svg_icon_folder();
+ echo htmlentities(basename($folder)).' /';
+ }
+ echo ' '.$too_large_to_edit_message.' '.$too_large_to_view_message.' Note: Maximum upload file size is: File will be created in the current folder.
+ Some invalid characters are: To move a file or folder, change the path/to/folder/or_file. The new location must already exist.
+
+
+
+
+
+ Are you sure? Folder will be created in the current folder.
+ Some invalid characters are: Are you sure? Keep in mind that due to a number of widely varied considerations, this is largely an academic excersize.
That is, take the idea that this adds much of an improvement to security with a grain of cryptographic salt.
- However, it does eleminate the storage of your password in plain text, which is a good thing*
+ However, it does eleminate the storage of your password in plain text, which is a good thing.
Anyway, to use the $HASHWORD password option:
You can use OneFileCMS to edit itself. However, be sure to have a backup ready for the inevitable ytpo...
- *For another small improvement to security, change the default salt and/or method used by OneFileCMS to hash the password (and keep 'em secret, of course). Remever, every little bit helps... '.$too_large_to_view_message.' '.$too_large_to_view_message.'
+
+
+ [X]
+
+
+ ';
+ echo '' ; svg_icon_upload() ; echo $_['Upload_File'].'';
+ echo '' ; svg_icon_file_new() ; echo $_['New_File'] .'';
+ echo ''; svg_icon_folder_new(); echo $_['New_Folder'] .'';
+ if ($ipath !== "") { //if at root, don't show Rename & Delete links
+ echo ''; svg_icon_folder_ren(); echo $_['Ren_Folder'].'';
+ echo ''; svg_icon_folder_del(); echo $_['Del_Folder'].'';
+ }
+ echo '
+
+
+document.getElementById("'.$focus.'").focus();'; }
+ //Do not close the tag yet/here. Need to leave it open for edit btn on hash page.
+}// End Cancel_Submit_Buttons() //**********************************************
+
+
+
+
+function show_image(){ //*******************************************************
+ global $_, $filename, $MAX_IMG_W, $MAX_IMG_H;
+
+ $IMG = $filename;
+ $img_info = getimagesize($IMG);
+
+ $W=0; $H=1; //indexes for $img_info[]
+ $SCALE = 1; $TOOWIDE = 0; $TOOHIGH = 0;
+ if ($img_info[$W] > $MAX_IMG_W) { $TOOWIDE = ( $MAX_IMG_W/$img_info[$W] );}
+ if ($img_info[$H] > $MAX_IMG_H) { $TOOHIGH = ( $MAX_IMG_H/$img_info[$H] );}
+
+ if ($TOOHIGH || $TOOWIDE) {
+ if (!$TOOWIDE) {$SCALE = $TOOHIGH;}
+ elseif (!$TOOHIGH) {$SCALE = $TOOWIDE;}
+ elseif ($TOOHIGH > $TOOWIDE) {$SCALE = $TOOWIDE;} //ex: if (.90 > .50)
+ else {$SCALE = $TOOHIGH;}
+ }
+
+ echo ' ';
+ echo $_['show_img_msg_01']. round($SCALE*100) .$_['show_img_msg_02'].$img_info[0].' x '.$img_info[1].').
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ';
+ $folders = glob($ipath."*",GLOB_ONLYDIR);
+ natcasesort($folders);
+ foreach ($folders as $folder) {
+ echo ''.PHP_EOL;
+ svg_icon_folder();
+ echo htmlentities(basename($folder)).' /';
+ }
+ echo ' '.$too_large_to_edit_message.' '.$too_large_to_view_message.'
+
+
+
+
+
+
+
+
+
+'.$_['delete_msg_01'].' '.htmlentities(basename($filename)).'';
+ }else{
+ $message .= $EX.''.$_['delete_msg_02'].' "'.htmlentities($filename).'".';
+ $page = "edit";
+ }
+}//end Delete_File_response() **************************************************
+
+
+
+
+function New_Folder_Page() { //*************************************************
+ global $_, $FORM_COMMON, $INVALID_CHARS;
+?>
+
+
+
+
+
+
+'.$_['delete_folder_msg_01'].'';
+ $page = "index";
+ }elseif (@rmdir($foldername)) {
+ $message .= ''.$_['delete_folder_msg_02'].' '.htmlentities(basename($foldername));
+ $ipath = Check_path($foldername); //Return to parent dir.
+ $param1 = '?i='.URLencode_path($ipath);
+ }else {
+ $message .= $EX.'"'.htmlentities($foldername).'/" '.$_['delete_folder_msg_03'];
+ }
+}//end Delete_Folder_response() ************************************************
+
+
+
+
+function Page_Title(){ //*** '.$_['Admin'].'';
+}
+?>
+
+ ';
- echo '' ; svg_icon_upload() ; echo 'Upload File';
- echo '' ; svg_icon_file_new() ; echo 'New File' ;
- echo ''; svg_icon_folder_new(); echo 'New Folder' ;
+ echo '' ; svg_icon_upload() ; echo hsc($_['Upload_File']).'';
+ echo '' ; svg_icon_file_new() ; echo hsc($_['New_File']) .'';
+ echo ''; svg_icon_folder_new(); echo hsc($_['New_Folder']) .'';
if ($ipath !== "") { //if at root, don't show Rename & Delete links
- echo ''; svg_icon_folder_ren(); echo 'Rename/Move Folder';
- echo ''; svg_icon_folder_del(); echo 'Delete Folder';
+ echo ''; svg_icon_folder_ren(); echo hsc($_['Ren_Folder']).'';
+ echo ''; svg_icon_folder_del(); echo hsc($_['Del_Folder']).'';
}
echo '
-
';
- echo 'Image shown at ~'. round($SCALE*100) .'% of full size (W x H = '.$img_info[0].' x '.$img_info[1].'). ';
+ echo hsc($_['show_img_msg_01']). round($SCALE*100) .hsc($_['show_img_msg_02']).$img_info[0].' x '.$img_info[1].'). There are two ways to change your OneFileCMS password:
- 1) Use the $PASSWORD config variable to store your desired password, and set $USE_HASH = 0 (zero). Keep in mind that due to a number of widely varied considerations, this is largely an academic excersize.
- That is, take the idea that this adds much of an improvement to security with a grain of cryptographic salt.
- However, it does eleminate the storage of your password in plain text, which is a good thing.
-
- Anyway, to use the $HASHWORD password option:
-
+
+
+ You can use OneFileCMS to edit itself. However, be sure to have a backup ready for the inevitable ytpo...
+
- For another small improvement to security, change the default salt and/or method used by OneFileCMS to hash the password (and keep 'em secret, of course). Remever, every little bit helps...
-
-
-
-
-
- Non-text or unkown file type. Edit disabled. '.hsc($_['edit_txt_01']).' '.$too_large_to_edit_message.' Note: Maximum upload file size is: File will be created in the current folder.
- Some invalid characters are:
+ To move a file or folder, change the path/to/folder/or_file. The new location must already exist.
-
+
+ name="old_name" value="" readonly="readonly">
-
+
+ value="">
Are you sure?
+
Deleted file: '.htmlentities(basename($filename));
+ $message .= ''.hsc($_['delete_msg_01']).' '.htmlentities(basename($filename)).'';
}else{
- $message .= $EX.' Error deleting "'.htmlentities($filename).'".';
+ $message .= $EX.''.hsc($_['delete_msg_02']).' "'.htmlentities($filename).'".';
$page = "edit";
}
}//end Delete_File_response() **************************************************
@@ -1294,14 +1534,14 @@ function Delete_File_response(){ //*********************************************
function New_Folder_Page() { //*************************************************
- global $FORM_COMMON, $INVALID_CHARS;
+ global $_, $FORM_COMMON, $INVALID_CHARS;
?>
- Folder will be created in the current folder.
- Some invalid characters are:
+ Are you sure?
+
Folder not empty. Folders must be empty before they can be deleted.';
+ $message .= $EX.''.hsc($_['delete_folder_msg_01']).'';
$page = "index";
}elseif (@rmdir($foldername)) {
- $message .= 'Deleted folder: '.htmlentities(basename($foldername));
+ $message .= ''.hsc($_['delete_folder_msg_02']).' '.htmlentities(basename($foldername));
$ipath = Check_path($foldername); //Return to parent dir.
$param1 = '?i='.URLencode_path($ipath);
}else {
- $message .= $EX.' "'.htmlentities($foldername).'/" an error occurred during delete.';
+ $message .= $EX.'"'.htmlentities($foldername).'/" '.hsc($_['delete_folder_msg_03']);
}
}//end Delete_Folder_response() ************************************************
@@ -1382,19 +1622,19 @@ function Delete_Folder_response() { //******************************************
function Page_Title(){ //***
-
-
- [X]
-
-
- ';
- echo '' ; svg_icon_upload() ; echo $_['Upload_File'].'';
- echo '' ; svg_icon_file_new() ; echo $_['New_File'] .'';
- echo ''; svg_icon_folder_new(); echo $_['New_Folder'] .'';
- if ($ipath !== "") { //if at root, don't show Rename & Delete links
- echo ''; svg_icon_folder_ren(); echo $_['Ren_Folder'].'';
- echo ''; svg_icon_folder_del(); echo $_['Del_Folder'].'';
- }
- echo '
-
-
-document.getElementById("'.$focus.'").focus();'; }
- //Do not close the tag yet/here. Need to leave it open for edit btn on hash page.
-}// End Cancel_Submit_Buttons() //**********************************************
-
-
-
-
-function show_image(){ //*******************************************************
- global $_, $filename, $MAX_IMG_W, $MAX_IMG_H;
-
- $IMG = $filename;
- $img_info = getimagesize($IMG);
-
- $W=0; $H=1; //indexes for $img_info[]
- $SCALE = 1; $TOOWIDE = 0; $TOOHIGH = 0;
- if ($img_info[$W] > $MAX_IMG_W) { $TOOWIDE = ( $MAX_IMG_W/$img_info[$W] );}
- if ($img_info[$H] > $MAX_IMG_H) { $TOOHIGH = ( $MAX_IMG_H/$img_info[$H] );}
-
- if ($TOOHIGH || $TOOWIDE) {
- if (!$TOOWIDE) {$SCALE = $TOOHIGH;}
- elseif (!$TOOHIGH) {$SCALE = $TOOWIDE;}
- elseif ($TOOHIGH > $TOOWIDE) {$SCALE = $TOOWIDE;} //ex: if (.90 > .50)
- else {$SCALE = $TOOHIGH;}
- }
-
- echo ' ';
- echo $_['show_img_msg_01']. round($SCALE*100) .$_['show_img_msg_02'].$img_info[0].' x '.$img_info[1].').
-
-
-
-
-
-
-
-
-
-
-
-
-
- ';
- $folders = glob($ipath."*",GLOB_ONLYDIR);
- natcasesort($folders);
- foreach ($folders as $folder) {
- echo ''.PHP_EOL;
- svg_icon_folder();
- echo htmlentities(basename($folder)).' /';
- }
- echo ' '.$too_large_to_edit_message.' '.$too_large_to_view_message.'
-
-
-
-
-
-
-
-
-
-'.$_['delete_msg_01'].' '.htmlentities(basename($filename)).'';
- }else{
- $message .= $EX.''.$_['delete_msg_02'].' "'.htmlentities($filename).'".';
- $page = "edit";
- }
-}//end Delete_File_response() **************************************************
-
-
-
-
-function New_Folder_Page() { //*************************************************
- global $_, $FORM_COMMON, $INVALID_CHARS;
-?>
-
-
-
-
-
-
-'.$_['delete_folder_msg_01'].'';
- $page = "index";
- }elseif (@rmdir($foldername)) {
- $message .= ''.$_['delete_folder_msg_02'].' '.htmlentities(basename($foldername));
- $ipath = Check_path($foldername); //Return to parent dir.
- $param1 = '?i='.URLencode_path($ipath);
- }else {
- $message .= $EX.'"'.htmlentities($foldername).'/" '.$_['delete_folder_msg_03'];
- }
-}//end Delete_Folder_response() ************************************************
-
-
-
-
-function Page_Title(){ //*** '.$_['Admin'].'';
-}
-?>
-
-
-
-
- [X]
-
-
- ';
- echo '' ; echo 'Upload File';
- echo '' ; echo 'New File' ;
- echo ''; echo 'New Folder' ;
- if ($ipath !== "") { //if at root, don't show Rename & Delete links
- echo ''; echo 'Rename/Move Folder';
- echo ''; echo 'Delete Folder';
- }
- echo '
-
-
-document.getElementById("'.$focus.'").focus();'; }
- //Do not close the tag yet/here. Need to leave it open for edit btn on hash page.
-}// End Cancel_Submit_Buttons() //**********************************************
-
-
-
-
-function show_image(){ //*******************************************************
- global $filename, $MAX_IMG_W, $MAX_IMG_H;
-
- $IMG = $filename;
- $img_info = getimagesize($IMG);
-
- $W=0; $H=1;
- $SCALE = 1; $TOOWIDE = 0; $TOOHIGH = 0;
- if ($img_info[$W] > $MAX_IMG_W) { $TOOWIDE = ( $MAX_IMG_W/$img_info[$W] );}
- if ($img_info[$H] > $MAX_IMG_H) { $TOOHIGH = ( $MAX_IMG_H/$img_info[$H] );}
-
- if ($TOOHIGH || $TOOWIDE) {
- if (!$TOOWIDE) {$SCALE = $TOOHIGH;}
- elseif (!$TOOHIGH) {$SCALE = $TOOWIDE;}
- elseif ($TOOHIGH > $TOOWIDE) {$SCALE = $TOOWIDE;} //ex:if (.90 > .50)
- else {$SCALE = $TOOHIGH;}
- }
-
- echo ' ';
- echo 'Image shown at ~'. round($SCALE*100) .'% of full size (W x H = '.$img_info[0].' x '.$img_info[1].'). There are two ways to change your OneFileCMS password:
- 1) Simply use the $PASSWORD config variable to store your desired password, and set $USE_HASH = 0 (zero). Keep in mind that due to a number of widely varied considerations, this is largely an academic excersize.
- That is, take the idea that this adds much of an improvement to security with a grain of cryptographic salt.
- However, it does eleminate the storage of your password in plain text, which is always a good thing.*
-
- Anyway, to use the $HASHWORD password option:
- You can use OneFileCMS to edit itself. However, be sure to have a backup ready for the inevitable ytpo...
-
- *For another small improvement to security, change the default salt and/or method used by OneFileCMS to hash the password (and keep 'em secret, of course). Remever, every little bit helps...
-
-
-
-
-
- ';
- $folders = glob($ipath."*",GLOB_ONLYDIR);
- natcasesort($folders);
- foreach ($folders as $folder) {
- echo ''.PHP_EOL;
-
- echo htmlentities(basename($folder)).' /';
- }
- echo ' '.$too_large_to_edit_message.' '.$too_large_to_view_message.' Note: Maximum upload file size is: File will be created in the current folder.
- Some invalid characters are: To move a file or folder, change the path/to/folder/or_file. The new location must already exist.
-
-
-
-
-
- Are you sure? Folder will be created in the current folder.
- Some invalid characters are: Are you sure? ';
- echo '' ; svg_icon_upload() ; echo hsc($_['Upload_File']).'';
- echo '' ; svg_icon_file_new() ; echo hsc($_['New_File']) .'';
- echo ''; svg_icon_folder_new(); echo hsc($_['New_Folder']) .'';
+ echo '' ; echo svg_icon_upload() ; echo hsc($_['Upload_File']).'';
+ echo '' ; echo svg_icon_file_new() ; echo hsc($_['New_File']) .'';
+ echo ''; echo svg_icon_folder_new(); echo hsc($_['New_Folder']) .'';
if ($ipath !== "") { //if at root, don't show Rename & Delete links
- echo ''; svg_icon_folder_ren(); echo hsc($_['Ren_Folder']).'';
- echo ''; svg_icon_folder_del(); echo hsc($_['Del_Folder']).'';
+ echo ''; echo svg_icon_folder_ren(); echo hsc($_['Ren_Folder']).'';
+ echo ''; echo svg_icon_folder_del(); echo hsc($_['Del_Folder']).'';
}
echo ' '.$too_large_to_view_message.'
-
-
-
-
-
-
@@ -1523,9 +1531,9 @@ function Delete_File_response(){ //*********************************************
$filename = $_POST["delete_file"];
if (unlink($filename)) {
- $message .= ''.hsc($_['delete_msg_01']).' '.htmlentities(basename($filename)).'';
+ $message .= ''.hsc($_['delete_msg_01']).' '.htmlentities(basename($filename)).'
+
+ /
+
@@ -1767,7 +1777,7 @@ function FileTimeStamp(php_filemtime, show_date, show_offset){
function Edit_Page_scripts() { //***********************************************
- global $_;
+ global $_, $WIDE_VIEW_WIDTH;
?>
+
+
'.hsc($_['session_warning']).' '.hsc($_['delete_txt_01']).' '.hsc($_['session_warning']).'
-'.hsc($_['change_pw_02']).' '; }
- else /*$PWUN == "un"*/ { $error_msg = $EX.''.hsc($_['change_un_02']).' '; }
+ $error_msg = $EX.''.hsc($msg).' ';
//If nothing entered...
if ( ($current_pass == "") && ($new_pwun == "") && ($confirm_pwun == "") ) {
@@ -1409,7 +1390,7 @@ function Change_PWUN_response($PWUN){ //****************************************
$HASHWORD = hashit($new_pwun);
$replace_with = '$HASHWORD = "'.$HASHWORD.'";';
}else { //$PWUN = "un"
- $USERNAME = $new_pwun;
+ $USERNAME = $new_pwun;
$search_for = '$USERNAME '; //include space after $USERNAME
$success_msg = ''.hsc($_['change_un_01']).'';
$replace_with = '$USERNAME = "'.$USERNAME.'";';
@@ -1420,7 +1401,7 @@ function Change_PWUN_response($PWUN){ //****************************************
//$CONFIG_file, uppercase name, includes full filesystem path.
if ( isset($config_file) && is_file($CONFIG_file) ) {
$message .= $_['change_pw_05'].' '.$_['change_pw_06'].'. . . ';
- $updated = Update_config($search_for, $replace_with, $CONFIG_file, $CONFIG_file_backup);
+ $updated = Update_config($search_for, $replace_with, $CONFIG_file, $CONFIG_file_backup);
}else{ //Update OneFileCMS
$message .= $_['change_pw_05'].' OneFileCMS . . . ';
$updated = Update_config($search_for, $replace_with, $ONESCRIPT_file, $ONESCRIPT_file_backup);
@@ -1452,9 +1433,9 @@ function Logout() { //**********************************************************
function Login_Page() { //******************************************************
- global $_, $ONESCRIPT, $message;
+ global $_, $ONESCRIPT;
?>
-
+ onclick="parent.location = ''">
document.getElementById("'.$focus.'").focus();'; }
@@ -1253,7 +1283,7 @@ function Hash_Page() { //*******************************************************
function Hash_response() { //***************************************************
global $_, $message;
- $_POST['whattohash'] = trim($_POST['whattohash']); // trim leading & trailing spaces.
+ $_POST['whattohash'] = trim($_POST['whattohash']); // trim whitespace.
//Ignore/don't hash empty string - passwords can't be blank.
if ($_POST['whattohash'] == "") { return; }
@@ -1358,7 +1388,7 @@ function Change_PWUN_response($PWUN, $msg){ //**********************************
global $_, $ONESCRIPT, $USERNAME, $HASHWORD, $EX, $message, $page, $config_file,
$ONESCRIPT_file, $ONESCRIPT_file_backup, $CONFIG_file, $CONFIG_file_backup;
- // trim leading & trailing white-space from input values
+ // trim white-space from input values
$current_pass = trim($_POST['current_pw']);
$new_pwun = trim($_POST['new1']);
$confirm_pwun = trim($_POST['new2']);
@@ -1472,7 +1502,7 @@ function Login_response() { //**************************************************
return;
}
- //Trim any incidental leading or trailing spaces before validating.
+ //Trim any incidental whitespace before validating.
$_POST['password'] = trim($_POST['password']);
$_POST['username'] = trim($_POST['username']);
@@ -1549,7 +1579,7 @@ function Table_of_Files($files, $R, $C, $D) { //********************************
} ?>
- '.hsc($_['new_file_txt_01'].' '.$_['new_file_txt_02']);
+ echo ''.hte($INVALID_CHARS).'
-
-
+
/
@@ -2232,7 +2243,9 @@ function Delete_Folder_Page(){ //***********************************************
function Delete_Folder_response() { //******************************************
global $_, $ipath, $param1, $page, $message, $EX;
$page = "index"; //Return to index
- $foldername = trim($_POST["delete_folder"], '/');
+ $foldername = Check_path($_POST["delete_folder"]);
+ $foldername = trim($foldername,'/');
+ if ($foldername == "") {return;}
if ( !is_empty($ipath) ) {
$message .= $EX.''.hsc($_['delete_folder_msg_01']).'';
@@ -2240,7 +2253,7 @@ function Delete_Folder_response() { //******************************************
}elseif (@rmdir($foldername)) {
$message .= ''.hsc($_['delete_folder_msg_02']).' ';
$message .= ''.hte(basename($foldername)).'';
- $ipath = Check_path($foldername); //Return to parent dir.
+ $ipath = dirname($foldername).'/'; //Return to parent dir.
$param1 = '?i='.URLencode_path($ipath);
}else {
$message .= $EX.'"'.hte($foldername).'/" '.hsc($_['delete_folder_msg_03']);
@@ -2312,26 +2325,28 @@ function MCD_response($action, $msg1, $success_msg = '') { //*******************
$count = count($files);
$errors = 0; //number of failed moves or copies
- $isfile = 1;
+ $isfile = 1; //only working with files, not folders.
$show_message = 1; //1= show error msg only. 2= show success msg only. 3= show all msg's.
if ($action == 'delete') {
foreach ($files as $file){
$errors += Delete_File_response($ipath.$file, $show_message);
}
+
}else { //move or copy
- $mcd_ipath = $ipath; //$Copy_Ren_Move_response() changes $ipath to $new_location
- $new_location = trim($_POST['new_location'],'/').'/'; //make sure no leading, and only 1 trailing, slash.
- if ( !is_dir($new_location) ){
- $message .= $EX.' '.hsc($_['upload_msg_02']).' ';
- echo '' .svg_icon_upload() .hsc($_['Upload_File']).'';
- echo '' .svg_icon_file_new() .hsc($_['New_File']) .'';
- echo ''.svg_icon_folder_new().hsc($_['New_Folder']) .'';
- if ($ipath !== "") { //if at root, don't show Rename & Delete links
- echo ''.svg_icon_folder_ren().hsc($_['Ren_Folder']).'';
- echo ''.svg_icon_folder_del().hsc($_['Del_Folder']).'';
- }
- echo ' tag yet/here. Leave it open for potential content on individual pages.
-}// End Cancel_Submit_Buttons() //**********************************************
+}//end Cancel_Submit_Buttons() //***********************************************
@@ -963,7 +940,7 @@ function show_image(){ //*******************************************************
echo ' '.hsc($_['admin_txt_01']);
@@ -1291,7 +1268,7 @@ function Admin_Page() { //******************************************************
';
+ //dummy input to make sure files[] is always an array in js for Select_All() & Confirm_Ready().
+ echo '';
- $X = 1; //index for list of checkboxes;
+ echo ' ';
@@ -1714,13 +1689,20 @@ function Index_Page(){ //*******************************************************
}
echo ' ';
+ echo '' .svg_icon_upload() .hsc($_['Upload_File']).'';
+ echo '' .svg_icon_file_new() .hsc($_['New_File']) .'';
+ echo ''.svg_icon_folder_new().hsc($_['New_Folder']) .'';
+ if ($ipath !== "") { //if at root, don't show Rename & Delete links
+ echo ''.svg_icon_folder_ren().hsc($_['Ren_Folder']).'';
+ echo ''.svg_icon_folder_del().hsc($_['Del_Folder']).'';
+ }
+ echo ' ';
+ echo hsc($_['upload_txt_03']).' '.ini_get('upload_max_filesize').' '.hsc($_['upload_txt_01']).' ';
+ for ($x = 0; $x < $UPLOAD_FIELDS; $x++) {
+ echo ' '.hsc($_['new_file_txt_01'].' '.$_['new_file_txt_02']);
echo ''.hte($INVALID_CHARS).' ';
foreach ($folders as $folder) {
echo ''.PHP_EOL;
@@ -1700,7 +1731,7 @@ function Index_Page(){ //*******************************************************
echo '' .svg_icon_upload() .hsc($_['Upload_File']).'';
echo '' .svg_icon_file_new() .hsc($_['New_File']) .'';
echo ''.svg_icon_folder_new().hsc($_['New_Folder']) .'';
- if ($ipath !== "") { //if at root, don't show Rename & Delete links
+ if ($ipath !== "") { //if at root, don't show [Rename] & [Delete] links
echo ''.svg_icon_folder_ren().hsc($_['Ren_Folder']).'';
echo ''.svg_icon_folder_del().hsc($_['Del_Folder']).'';
}
@@ -1770,7 +1801,7 @@ function Edit_Page_buttons($text_editable, $too_large_to_edit) { //*************
if (!$Editing_OFCMS) { echo $Button.hsc($_['Ren_Move']).$ACTION.'rename\'">'; }
echo $Button.hsc($_['Copy']) .$ACTION.'copy\'">';
- if (!$Editing_OFCMS) { echo $Button.hsc($_['Delete']) .$ACTION.'delete\'" id="delete">'; }
+ if (!$Editing_OFCMS) { echo $Button.hsc($_['Delete']) .$ACTION.'deletefile\'" id="delete">'; }
echo $Button.hsc($_['Close']).'" onclick="parent.location = \''.$ONESCRIPT.$params.'\'">'
?>
@@ -2011,7 +2042,7 @@ function New_File_or_Folder_Page($title, $id) { //******************************
echo ' '.hsc($_['new_file_txt_01'].' '.$_['new_file_txt_02']);
- echo ''.hte($INVALID_CHARS).'
-
-
-
-'.hte($WEB_ROOT.dir_name($target)).'';
+ $slash = '/';
+ }
+
+ echo ' '.$web_root.''.hte(basename($target)).' '.$slash.' '.hsc($_['Are_you_sure']).'
- /
-
-
-
-'.hsc($_['delete_folder_msg_01']).'';
- $page = "index";
- }elseif (@rmdir($foldername)) {
- $message .= ''.hsc($_['delete_folder_msg_02']).' ';
- $message .= ''.hte(basename($foldername)).'';
- $ipath = dir_name($foldername); //Return to parent dir.
- $param1 = '?i='.URLencode_path($ipath);
- }else {
- $message .= $EX.'"'.hte($foldername).'/" '.hsc($_['delete_folder_msg_03']);
- }
-}//end Delete_Folder_response() //**********************************************
+}//end Delete_response() //*****************************************************
@@ -2299,20 +2314,10 @@ function MCD_Page($page_title, $action, $classes = '', $focus = 'new_location')
echo '';
}
- echo ' '.hsc($_['Are_you_sure']).' '.hsc($_['Are_you_sure']).'
-
-
-
+
- ';
+ echo '' .svg_icon_upload() .hsc($_['Upload_File']).'';
+ echo '' .svg_icon_file_new() .hsc($_['New_File']) .'';
+ echo ' ';
foreach ($folders as $folder) {
- echo ''.PHP_EOL;
- echo svg_icon_folder();
- echo hte(basename($folder)).' /';
+ echo ''."\n";
+ echo svg_icon_folder()."\n";
+ echo hte($folder).' /';
}
echo ' ';
- echo '' .svg_icon_upload() .hsc($_['Upload_File']).'';
- echo '' .svg_icon_file_new() .hsc($_['New_File']) .'';
echo ''.svg_icon_folder_new().hsc($_['New_Folder']) .'';
if ($ipath !== "") { //if at root, don't show [Rename] & [Delete] links
echo ''.svg_icon_folder_ren().hsc($_['Ren_Folder']).'';
+ echo '' .svg_icon_folder_cpy().hsc($_['Copy_Folder']).'';
echo ''.svg_icon_folder_del().hsc($_['Del_Folder']).'';
}
echo ' '.hsc($_['admin_txt_01']).' '.hsc($_['edit_txt_01']).' '.$too_large_to_view_message.' ';
@@ -2570,7 +2569,6 @@ function MCD_Page($action, $page_title, $classes = '') { //*********************
if ( ($_POST['mcdaction'] == 'copy') || ($_POST['mcdaction'] == 'move') ) {
echo ' ('.hsc($_['CRM_txt_02']).') ';
Cancel_Submit_Buttons($_['Upload']);
echo '';
}//end Upload_Page() //*********************************************************
@@ -2409,7 +2407,7 @@ function CRM_Page($action, $title, $action_id, $old_full_name) { //*************
echo '';
echo ' '.hsc($_['admin_txt_00']).' '.hsc($_['admin_txt_01']);
+ }
+ echo ' '.hsc($_['admin_txt_01']).'
-
-
- '.hsc($_['admin_txt_02']).'';
+ echo ' ' .hsc($_['admin_txt_16']);
+ echo ' '.hsc($_['admin_txt_14']);
+ echo '
to contain directory, including buttons at top.
echo '
- ';
echo hsc($_['show_img_msg_01']).round($SCALE*100).
hsc($_['show_img_msg_02']).' '.$img_info[0].' x '.$img_info[1].'). '.hsc($_['edit_txt_01']).' '.$too_large_to_edit_message.' '.$too_large_to_view_message.' ';
Cancel_Submit_Buttons($action);
echo '';
-
-//#####
-?>
-
-'.hsc($page_title).'';
echo ' The $ACCESS_ROOT option has been reimplemented and is now fully functional*. This option limits access to a specified folder (and it's sub-folders). To use, just specify a valid path relative to the root of the website (no leading slash). All OneFileCMS configuration variables that reference external files ($CONFIG_file, $LANGUAGE_FILE, $WYSIWYG_PLUGIN) must be specified in one of two ways: Slightly adjusted how wysiwyg plugins are implemented - removed $WYSIWIG_SOURCE config variable. Two steps forward, one step back... A solution is in the works, but I'm going to take some time to make sure no new problems are introduced by the eventual fix. (hahaha...) It will probably end up being simple, but it's not yet... Just a general note on security: due to the fundamental structure of OneFileCMS - primarily that it's one file, and that there is no seperate database for authentication - there are certain inherent security limitations that should be kept in mind: Of course, everything comes with a price (exacerbated by my apparent lack of testing...) WYSIWYG is here! No actual WYSIWYG editors are included with OneFileCMS - any desired editor must be obtained seperately. A brief how-to on using either editor can be found in their respective sample "init" files included in the plugins folder of the OneFileCMS repo. Any suitable init file for a given editor may be used, as long as the correct path to the editor's javascript source file is specified, and - for CKEditor - the id of the OneFileCMS textarea, "file_editor", is also be specified. Now, while everything seems to work, I have little to no experience using TinyMCE, CKEditor, or any other such application. So, if there is something missing or not working as expected, please let me know (open an "issue" on the Issues page). Notes: These editors have their own, extensive, event controls (responses to keyboard & mouse input), so the OneFileCMS edit page event scripts are not loaded when an editor is in use. The primary effect is the loss of incidental file status indicators - [Save] will not change to [SAVE CHANGES!], background color will not change, etc., and any "unsaved changes" alerts should be handled by the active editor. Also, the [Wide View] button will be unavailable. The TinyMCE "init" file included in the OneFileCMS repo specifies the use of the TinyMCE "fullpage" plugin, which produces an "unsaved changes" alert every time you exit the Edit page - even if no changes have been made to the file in the editor. The CKEditor, on the other hand, does not seem to present an alert at all when you leave the editor page - even with unsaved changes. Added client-side hashing of passwords.
-This is primarily a benefit for the user, as it does not really add any security to the server side application that uses it (such as OneFileCMS). The reason is that this "pre-hash" simply becomes the actual password as far as the server is concerned, and is just as vulnerable to exposure while in transit. However, it does help to protect the user's plain-text password, which may be used elsewhere. Also added a "please wait..." message while computing the client-side hashes - primarily for IE versions < 9, which are MUCH slower than FF or Chrome (by a factor of 37 or more). Subsequently, the number of iterations for the client-side hashing is quite low (compared to the server side), but still causes a 1 - 2 second delay on the login screen, and a 3 - 6 second delay on the Change Password screen. On FF and Chrome, however, the delay is much shorter, almost unnoticable. I want to thank fermuch for the client-side hashing suggestion. While a somewhat different approach was ultlimately employed, his original solution provided the insight needed to approach the idea in general. OneFileCMS is now actually ONE FILE! No external style sheets or icons. This is OneFileCMS "Lite", and will be maintained along with v3.0 '.hsc($_['pw_txt_02']).' '.hsc($_['pw_txt_02']);
+ $PWUN_RULES .= '
-
+
'.hsc($_['pw_txt_02']);
$PWUN_RULES .= '
'.hsc($_['admin_txt_00']).' '.hsc($_['admin_txt_00']).' '.hsc($_['admin_txt_01']);
}
echo '
-
+
= hsc($_['hash_txt_01']) ?> = hsc($_['pw_current']) ?> = hsc($label_new) ?> = hsc($label_confirm) ?>
-
+
+
-
+ = $PWUN_RULES ?>
+ = hsc($_['pw_txt_12']) ?>
+ = hsc($_['pw_txt_14']) ?>
';
+ foreach ($files as $file) {
+ $fc++;
+ $excludeme = 0;
+ $config_excludeds = explode(",", $config_excluded);
+
+ foreach ($config_excludeds as $config_exclusion) {
+ if (strrpos(basename($file),$config_exclusion) !== False &&
+ strrpos(basename($file),$config_exclusion) !== "") {
+ $excludeme = 1;
+ }
+ }
-
+
+
+';
+}//end list_files() ************************************************************
-function pad(num){
- if ( num < 10 ){ num = "0" + num; }
- return num
-}
-function FileTimeStamp(php_filemtime, show_offset){
- //php's filemtime returns seconds, javascript's date() uses milliseconds.
- var FileMTime = php_filemtime * 1000;
- var TIMESTAMP = new Date(FileMTime);
- var YEAR = TIMESTAMP.getFullYear();
- var MONTH = pad(TIMESTAMP.getMonth() + 1);
- var DATE = pad(TIMESTAMP.getDate());
- var HOURS = TIMESTAMP.getHours();
- var MINS = pad(TIMESTAMP.getMinutes());
- var SECS = pad(TIMESTAMP.getSeconds());
+function Index_Page(){ //*******************************************************
+ global $ONESCRIPT, $varvar, $config_excluded, $ftypes, $fclasses;
+ $varvar = ""; //must be global - also used in list_files()
+ if (isset($_GET["i"])) { $varvar = $_GET["i"]."/"; }
- if( HOURS < 12){ AMPM = "am"; }
- else { AMPM = "pm"; HOURS = HOURS - 12; }
- HOURS = pad(HOURS);
+ // Current path. ie: docroot/current/path/
+ // Each level is a link to that level.
+ echo '
';
+ $full_path = basename(getcwd());
+ if (isset($_GET["i"])) { $full_path = basename(getcwd()).'/'.$_GET["i"]; }
- var GMT_offset = -(TIMESTAMP.getTimezoneOffset()); //Yes, I know - seems wrong, but it's works.
+ $path_levels = explode("/",$full_path);
+ $levels = count($path_levels); //If levels=3, indexes = 0, 1, 2 etc...
- if (GMT_offset < 0) { NEG=-1; SIGN="-"; } else { NEG=1; SIGN="+"; }
+ //docroot folder of site
+ if ($_GET["i"] == "") {
+ echo $path_levels[0].' /'; // if at root, no need for link.
+ } else {
+ echo ' '.$path_levels[0].' /';
+ }
- var offset_HOURS = Math.floor(NEG*GMT_offset/60);
- var offset_MINS = pad( NEG * GMT_offset % 60 );
- var offset_FULL = "UTC " + SIGN + offset_HOURS + ":" + offset_MINS;
+ //Remainder of current/path
+ for ($x=1; $x < $levels; $x++) {
+ if ($x !== 1){ $current_path .= '/'; }
+ $current_path = $current_path.$path_levels[$x];
+ echo ' ';
+ echo ' '.$path_levels[$x]." /";
+ }
+ ?>
- if (show_offset){ var DATETIME = YEAR+"-"+MONTH+"-"+DATE+" "+HOURS+":"+MINS+" "+AMPM+" ("+offset_FULL+")"; }
- else { var DATETIME = YEAR+"-"+MONTH+"-"+DATE+" "+HOURS+":"+MINS+" "+AMPM; }
+
+
+
+
+
+
+ Upload
+ New File
+ Rename “ ”
+ Delete “
- ”
+ Delete “
+ ” ?
Delete Folder “ / ” ?
+function New_Folder_Page() { //*************************************************
+ global $ONESCRIPT, $varvar;
+ $varvar = "";
+ if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; }
+?>
+ New Folder
+ File: “
-
- ”
-
- Rename Folder “”
+ Delete Folder “ / ” ?
+ ';
- foreach ($files as $file) {
- $fc++;
- $excludeme = 0;
- $config_excludeds = explode(",", $config_excluded);
-
- foreach ($config_excludeds as $config_exclusion) {
- if (strrpos(basename($file),$config_exclusion) !== False &&
- strrpos(basename($file),$config_exclusion) !== "") {
- $excludeme = 1;
- }
- }
-
- if (!is_dir($file) && $excludeme == 0) {
-
- //Determine file type & set cooresponding class.
- $file_class = "";
- $ext = end( explode(".", strtolower($file)) );
-
- for ($x=0; $x < count($ftypes); $x++ ){
- if ($ext == $ftypes[$x]){ $file_class = $fclasses[$x]; }
- }
- ?>
-
-
- ';
-
- }//end list_view() =================================-->
- ?>
+//******************************************************************************
+function time_stamp_scripts() { ?>
+
+
+
-
-
- ', basename($file), ''; ?>
-
-
- B
-
-
-
-
- New File
- New Folder
- Rename “ ”
- Rename Folder “”
- Upload
-
'; }
-//Check if "i" path exists & trim trailing slashes ///
-function Check_ipath() { global $message;
- if (isset($_GET["i"])) {
- $_GET["i"] = rtrim($_GET["i"],"/");
- if (!is_dir($_GET["i"])) { $message = "Does not exist: ".$_GET["i"]; }
- while (!is_dir($_GET["i"])) { $_GET["i"] = dirname($_GET["i"]); }
- if ($_GET["i"] == '.') {unset($_GET["i"]);}
+ while ( (strlen($path) > 0) && (!is_dir($path)) ) {
+ $path = dirname($path);
+ }
+ $path = $path.'/';
+ if ($path == './') { $path = ""; }
}
-}//end Check_ipath()
-Check_ipath();
+ return $path;
+}//end Check_path() ********************
-if ( ($page == "login") and ($_SESSION['onefilecms_valid']) ) {
- $page = "index";
- header("Location: ".$ONESCRIPT);
-}
-if ($_GET["p"] == "login") { $pagetitle = "Log In"; }
-if ($_GET["p"] == "logout") {
- $page = "login";
- $pagetitle = "Login";
- $_SESSION['onefilecms_valid'] = "0";
- session_destroy();
- $message = 'You have successfully logged out.';
-}
+//*** Get main parameters **************
+if (isset($_GET["i"])) { $ipath = Check_path($_GET["i"]); }else{ $ipath = ""; }
+if (isset($_GET["f"])) { $filename = $ipath.$_GET["f"]; }else{ $filename = ""; }
+if (isset($_GET["p"])) { $page = $_GET["p"]; } // default $page set above
-if ($_GET["i"] == "") { unset($_GET["i"]); }
-// End session startup**********************************************************
+$varvar = "?i=".$ipath;
+//*** Verify valid $page ***************
+if ($page != "") {
+ if (!in_array(strtolower($page), $valid_pages)) {
+ header("Location: ".$ONESCRIPT); // redirect on invalid page attempts
+ $page = "index";
+ }
+}
+//
+//End session startup***********************************************************
-// entitize $_GET params *******************************************************
-foreach ($_GET as $name => $value) { $_GET[$name] = htmlentities($value); }
@@ -123,67 +133,115 @@ function Check_ipath() { global $message;
//******************************************************************************
// Misc Functions
-function is_empty($path){
- $empty = false;
- $dh = opendir($path);
- for($i = 3; $i; $i--) { $empty = (readdir($dh) === FALSE); }
- closedir($dh);
- return $empty;
-}//end is_emtpy()
+function Current_Path_Header(){ //**************************
+ // Current path. ie: webroot/current/path/
+ // Each level is a link to that level.
+ global $ONESCRIPT, $ipath, $WEB_ROOT;
-function Close_Button($classes) { //********************
- echo '';
- ?>';
+ $path_levels = explode("/",trim($ipath,'/') );
+ $levels = count($path_levels); //If levels=3, indexes = 0, 1, 2 etc...
+ if ($ipath == "" ){ $levels = 0;} //if at root
+ $current_path = "";
+ //Root folder of web site.
+ echo ' '.trim($WEB_ROOT, '/').' /';
+ //Remainder of current/path
+ for ($x=0; $x < $levels; $x++) {
+ $current_path .= $path_levels[$x].'/';
+ echo ' ';
+ echo ' '.$path_levels[$x]." /";
+ }
+ echo '';
+}//end Current_Path_Header() //*****************************
-function Cancel_Submit_Buttons($button_label) { //******
- global $ONESCRIPT, $varvar;
- // [Cancel] returns to either the current/path, or current/path/file
- if ( isset($_GET["c"]) ) { $ipath = '?f='.$_GET["c"]; }
- else if ( isset($_GET["d"]) ) { $ipath = '?f='.$_GET["d"]; }
- else if ( isset($_GET["r"]) ) { $ipath = '?f='.$_GET["r"]; }
- else if ( isset($_GET["i"]) ) { $ipath = '?i='.rtrim($_GET["i"],"/"); }
- else { $ipath = rtrim($varvar,"/"); }//end if/else
- ?>
- ';
-}// end show_image() ***********************************
+}// end show_image() ***************************************
-function show_favicon(){
- global $config_favicon, $DOC_ROOT;
- if (file_exists($DOC_ROOT.$config_favicon)) {
- echo '
';
- }
-}// end show_favicon()
+//if file_exists(), ordinalize filename until it doesn't ***
+function ordinalize($destination,$filename, &$message) {
-// End of misc funtions ********************************************************
+ $ordinal = 0;
+ $savefile = $destination.$filename;
+ if (file_exists($savefile)) {
+ $message .= '
(!) A file with that name already exists in the target directory.
';
+ $savefile_info = pathinfo($savefile);
+ while (file_exists($savefile)) {
+ $ordinal = sprintf("%03d", ++$ordinal); // 001, 002, 003, etc...
+ $newfilename = $savefile_info['filename'].'.'.$ordinal.'.'.$savefile_info['extension'];
+ $savefile = $destination.$newfilename;
-
-
-// COPY FILE response code *****************************************************
-if (isset($_GET["c"])) {
- $page = "copy"; $filename = $_GET["c"]; $pagetitle = "Copy";
-}
-
-if (isset($_POST["copy_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
- $old_filename = $_POST["old_filename"];
- $filename = $_POST["copy_filename"];
-
- if (copy($old_filename, $filename)){
- $message = '"'.$old_filename.'"
';
- $message .= ' --- successfully copied to ---
';
- $message .= '"'.$filename.'".';
- }else{
- $message .= '(!) Error copying file:
"'.$filename.'".';
- }
-}//end COPY FILE response code *************************************************
-
-
-
-
-
-// DELETE FILE response code ***************************************************
-if (isset($_GET["d"])) {
- $page = "delete"; $filename = $_GET["d"]; $pagetitle = "Delete";
-}
-
-if (isset($_POST["delete_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
- $filename = $_POST["delete_filename"];
-
- if (unlink($filename)) {
- $message = '"'.basename($filename).'" successfully deleted.';
- }else{
- $message = '(!) Error deleting "'.$filename.'".';
- }
-}//end DELETE FILE response code ***********************************************
-
-
-
-
-
-// DELETE FOLDER response code *************************************************
-if ($_GET["p"] == "deletefolder") {
- if (!is_empty($_GET["i"])){
- $message = '(!) Folder is not empty. Folders must be empty before they can be deleted.
';
- $page = "index";
}
- else { $pagetitle = "Delete Folder"; }
-}
-
-if (isset($_POST["delete_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
- $foldername = $_POST["delete_foldername"];
- $_GET["i"] = $foldername;
- if (@rmdir($foldername)) {
- $_GET["i"] = dirname($foldername);
- $message = '"'.basename($foldername).'/" successfully deleted.';
- } else {
- $message = '(!) "'.$foldername.'/" is not empty, or other error occurred.';
- }
-}//end DELETE FOLDER response code *********************************************
-
-
-
-
-
-// EDIT Page response code *****************************************************
-
-//*** If on Edit page, and [Save] clicked:
-if (isset($_POST["filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
- $filename = $_POST["filename"];
- $content = stripslashes($_POST["content"]);
- $fp = @fopen($filename, "w");
- if ($fp) {
- fwrite($fp, $content);
- fclose($fp);
- $message = '"'.$filename.'" saved successfully.';
- }else{
- $message = '(!) There was an error saving file.';
- }
-}//***
-
-//*** If in directory list, and a filename is clicked:
-if (isset($_GET["f"])) {
- $filename = stripslashes($_GET["f"]);
- if (file_exists($filename)) {
- $page = "edit";
- $pagetitle = "Edit/View File";
- $fp = @fopen($filename, "r");
- if (filesize($filename) !== 0) {
- $filecontent = fread($fp, filesize($filename));
- $filecontent = htmlspecialchars($filecontent);
- }
- fclose($fp);
- } else {
- $page = "index";
- $message = '"'.$filename.'" does not exist.';
- unset ($filename);
- }
-}//***
-//End Edit page response code **************************************************
-
-
-
-
-
-// NEW FILE response code ******************************************************
-if ($_GET["p"] == "new") {$pagetitle = "New File"; }
-if (isset($_POST["new_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
- $filename = $_POST["new_filename"];
- $_GET["i"] = $filename; Check_ipath();
- if (file_exists($filename)) {
- $message = '(!) "'.$filename.'" not created. A file with that name already exists.';
- } else {
- $handle = fopen($filename, 'w') or die("can't open file");
- fclose($handle);
- $message = '"'.$filename.'" created successfully.';
- $_GET["i"] = dirname($filename); //return to file's directory.
+ $message .= 'Saving as: "'.''.$newfilename.'"';
}
-}//end NEW FILE response code **************************************************
+ return $savefile;
+}//end ordinalize filename *********************************
-
-
-// NEW FOLDER response code ****************************************************
-if ($_GET["p"] == "newfolder") {$pagetitle = "New Folder"; }
-if (isset($_POST["new_folder"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
- $foldername = $_POST["new_folder"];
- $_GET["i"] = $foldername; Check_ipath();
- if (!is_dir($foldername)) {
- mkdir($foldername);
- $message = '"'.$foldername.'/" created successfully.';
- $_GET["i"] = $foldername; //change to new directory
- } else {
- $message = '(!) Folder already exists: ';
- $message .= ''.$foldername.'/';
+function show_favicon(){
+ global $config_favicon, $DOC_ROOT;
+ if (file_exists($DOC_ROOT.$config_favicon)) {
+ echo '';
}
-}//end NEW FOLDER response code ************************************************
-
-
-
-
-
-// RENAME FILE response code ***************************************************
-if (isset($_GET["r"])) {
- $filename = $_GET["r"];
- $pagetitle = "Rename File";
- $page = "rename";
-}
-if (isset($_POST["rename_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
- $old_filename = $_POST["old_filename"];
- $filename = $_POST["rename_filename"];
-
- //Removed any trailing slashes
- $filename = rtrim($filename, '/');
-
- rename($old_filename, $filename);
- $message .= '"'.$old_filename.'"
';
- $message .= ' successfully renamed to:
';
- $message .= '"'.$filename.'"';
-}//end RENAME FILE response code ***********************************************
-
+}// end show_favicon()
+//
+// End of misc funtions ********************************************************
-// RENAME FOLDER response code *************************************************
-if ($_GET["p"] == "renamefolder") {$pagetitle = "Rename Folder"; }
-if (isset($_POST["new_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
- $old_foldername = $_POST["old_foldername"];
- $new_foldername = $_POST["new_foldername"];
- $_GET["i"] = $old_foldername;
- Check_ipath();
-
- //Removed any trailing slashes
- $old_foldername = rtrim($old_foldername, '/');
- $new_foldername = rtrim($new_foldername, '/');
-
- if (rename($old_foldername, $new_foldername)) {
- $message .= '"'.$old_foldername.'/"
';
- $message .= ' successfully renamed to:
';
- $message .= '"'.$new_foldername.'/"';
- $_GET["i"] = $new_foldername; //return to new folder
- } else {
- $message = "(!) There was an error during rename. Try again and/or contact your admin.";
- }
-}//end RENAME FOLDER response code *********************************************
+//Don't load login screen if already in a valid session *************
+if (($page == "login") and ($_SESSION['valid'])) { $page = "index"; }
-// UPLOAD FILE response code ***************************************************
-if ($_GET["p"] == "upload") {$pagetitle = "Upload File"; }
-if (isset($_FILES['upload_filename']['name']) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) {
-
- $filename = $_FILES['upload_filename']['name'];
- $newfilename = $filename;
- $destination = $_POST["upload_destination"];
- $destintaion = rtrim($destination,"/").'/'; //make sure only a single trailing slash
- $savefile = $destination.$filename;
- $_GET["i"] = rtrim($destination,"/");
-
- if (($filename == "")){
- $message = "(!) No file selected for upload... ";
- }else{
- $message = 'Uploading: "'.$filename.'" to "'.$destination.'"';
-
- //if file_exists(), serialize filename until it doesn't
- $serialize = 0;
- if (file_exists($savefile)) {
- $message .= '
(!) A file with that name already exists in the target directory.
';
- $savefile_info = pathinfo($savefile);
-
- while (file_exists($savefile)) {
- $serialize = sprintf("%04d", ++$serialize); // 0001, 0002, 0003, etc...
- $newfilename = $savefile_info['filename'].'.'.$serialize.'.'.$savefile_info['extension'];
- $savefile = $destination . $newfilename;
- }
- $message .= 'Saving as: "'.''.$newfilename.'"';
- }
- //end serialize filename *****************************/
-
- if(move_uploaded_file($_FILES['upload_filename']['tmp_name'], $savefile)) {
- $message .= '
Upload successful.';
- } else{
- $message .= "
(!) There was an error. Upload or rename may have failed.";
- }
- }
-} //end Upload file response code **********************************************
+if ($page == "login") { $pagetitle = "Log In"; }
+if ($page == "edit") { $pagetitle = "Edit/View File"; }
+if ($page == "upload") { $pagetitle = "Upload File"; }
+if ($page == "new") { $pagetitle = "New File"; }
+if ($page == "copy" ) { $pagetitle = "Copy"; }
+if ($page == "rename") { $pagetitle = "Rename File"; }
+if ($page == "delete") { $pagetitle = "Delete"; }
+if ($page == "newfolder") { $pagetitle = "New Folder"; }
+if ($page == "renamefolder") { $pagetitle = "Rename Folder"; }
+if ($page == "deletefolder") { $pagetitle = "Delete Folder"; }
+//Logout ***********************************************************************
+if ($page == "logout") {
+ $page = "login"; $pagetitle = "Login";
+ $_SESSION['valid'] = "0";
+ session_destroy();
+ $message = 'You have successfully logged out.';
+}//*****************************************************************************
@@ -472,45 +346,56 @@ function Login_Page() { //******************************************************
Log In
';
+ $files = scandir('./'.$ipath);
+ natcasesort($files);
+
+ echo '
';
foreach ($files as $file) {
$fc++;
$excludeme = 0;
$config_excludeds = explode(",", $config_excluded);
-
+
foreach ($config_excludeds as $config_exclusion) {
if (strrpos(basename($file),$config_exclusion) !== False &&
strrpos(basename($file),$config_exclusion) !== "") {
$excludeme = 1;
}
}
-
- if (!is_dir($file) && $excludeme == 0) {
-
+
+ if (!is_dir($ipath.$file) && $excludeme == 0) {
//Determine file type & set cooresponding class.
$file_class = "";
$ext = end( explode(".", strtolower($file)) );
@@ -520,15 +405,14 @@ function list_files() { // ...in a vertical table ******************************
}
?>
-
';
- $full_path = basename(getcwd());
- if (isset($_GET["i"])) { $full_path = basename(getcwd()).'/'.$_GET["i"]; }
-
- $path_levels = explode("/",$full_path);
- $levels = count($path_levels); //If levels=3, indexes = 0, 1, 2 etc...
-
- //docroot folder of site
- if ($_GET["i"] == "") {
- echo $path_levels[0].' /'; // if at root, no need for link.
- } else {
- echo ' '.$path_levels[0].' /';
- }
-
- //Remainder of current/path
- for ($x=1; $x < $levels; $x++) {
- if ($x !== 1){ $current_path .= '/'; }
- $current_path = $current_path.$path_levels[$x];
- echo ' ';
- echo ' '.$path_levels[$x]." /";
- }
- ?>
+ global $ONESCRIPT, $WEB_ROOT, $ipath, $config_excluded, $ftypes, $fclasses;
+ Upload_New_Rename_Delete_Links();
+?>
-
-
- ', basename($file), ''; ?>
+
+ ', $file, ''; ?>
- B
+ B
-
+
File: “
-
- ”
+ Edit/View:
+
+
- Upload
+ Upload File
';
+ $message .= ''.$WEB_ROOT.$destination.'
Upload cancelled.';
+ }else{
+ $message .= 'Uploading: "'.$filename.'" to "'.$WEB_ROOT.$destination.'"';
+
+ $savefile = ordinalize($destination, $filename, $message);
+
+ if(move_uploaded_file($_FILES['upload_filename']['tmp_name'], $savefile)) {
+ $message .= '
Upload successful.';
+ } else{
+ $message .= "
(!) There was an error. Upload or rename may have failed.";
+ }
+ }
+} //end Upload file response code **********************************************
+
+
+
+
+
+
function New_File_Page() { //***************************************************
- global $ONESCRIPT, $varvar;
- $varvar = "";
- if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; }
+ global $ONESCRIPT, $WEB_ROOT, $ipath, $varvar;
?>
- New File
- New File
+ Copy “ ”
- Copy File
A file with that name already exists.';
+ $page = "edit";
+ $filename = basename($old_filename);
+ }elseif (copy($old_filename, $new_filename)){
+ $message = '"'.$old_filename.'"
';
+ $message .= ' --- successfully copied to ---
';
+ $message .= '"'.$new_filename.'"';
+ }else{
+ $message .= '(!) Error copying file:
"'.$new_filename.'"';
+ }
+}//end COPY FILE response code *************************************************
+
+
+
+
function Rename_File_Page() { //************************************************
- global $ONESCRIPT, $varvar, $filename;
- $varvar = "?i=".dirname($_GET["r"]);
+ global $ONESCRIPT, $WEB_ROOT, $ipath, $varvar, $filename;
?>
- Rename “ ”
- Rename/Move File
-
';
+ $message .= '(!) Target filename already exists: '.$new_filename.'
';
+ }elseif (rename($old_filename, $new_filename)) {
+ $message .= '"'.$old_filename.'"
';
+ $message .= ' --- successfully renamed to ---
';
+ $message .= '"'.$new_filename.'"
';
+ }else{
+ $message .= '(!) Error renaming/moving file from:
"'.$old_filename.'"';
+ $message .= '(!) To:
"'.$new_filename.'"';
+ }
+}//end RENAME FILE response code ***********************************************
+
+
+
+
+
function Delete_File_Page() { //************************************************
- global $ONESCRIPT, $varvar, $filename;
- $varvar = '?i='.dirname($_GET["d"]);
+ global $ONESCRIPT, $WEB_ROOT, $ipath, $varvar, $filename;
?>
- Delete “
- ” ?
- Delete File
New Folder
- New Folder
Rename Folder “”
+ Rename Folder
';
+ $message .= ' '.$WEB_ROOT.$new_foldername.'
';
+ }elseif (rename($old_foldername, $new_foldername)) {
+ $message .= '"'.$old_foldername.'"
';
+ $message .= ' --- successfully renamed to ---
';
+ $message .= '"'.$new_foldername.'/"
';
+ $ipath = Check_path($new_foldername); //Return to new folder
+ $varvar = "?i=".$ipath;
+ } else {
+ $message = "(!) There was an error during rename. Try again and/or contact your admin.";
+ }
+}//end RENAME FOLDER response code *********************************************
+
+
+
+
+
function Delete_Folder_Page(){ //***********************************************
- global $ONESCRIPT, $varvar;
- $varvar = "?i=".dirname($_GET['i']);
+ global $ONESCRIPT, $WEB_ROOT, $ipath, $varvar;
?>
- Delete Folder “ / ” ?
+ Delete Folder
+
';
+ $page = "index";
+}
+
+if (isset($_POST["delete_foldername"]) && $_SESSION['valid'] = "1" && $_POST["sessionid"] == session_id()) {
+
+ $page = "index"; //Return to index
+ $foldername = trim($_POST["delete_foldername"], '/');
+
+ if (@rmdir($foldername)) {
+ $message = 'Folder "'.basename($foldername).'" successfully deleted.';
+ $ipath = Check_path($foldername);
+ $varvar = "?i=".$ipath;
+ } else {
+ $message .= '(!) "'.$foldername.'/" an error occurred during delete.';
+ }
+}//end DELETE FOLDER response code *********************************************
+
+
+
@@ -863,7 +910,7 @@ function Load_Selected_Page(){ //***********************************************
global $page;
if ($page == "login") { Login_Page(); }
if ($page == "index") { Index_Page(); }
- if ($page == "edit") { Edit_Page(); }
+ if ($page == "edit") { $pagetitle = "Edit/View File"; Edit_Page();}
if ($page == "upload") { Upload_Page(); }
if ($page == "new") { New_File_Page(); }
if ($page == "copy") { Copy_File_Page(); }
@@ -884,7 +931,7 @@ function Load_Selected_Page(){ //***********************************************
//******************************************************************************
-function time_stamp_scripts() { ?>
+function Time_Stamp_javascripts() { ?>
-
@@ -1042,7 +1089,6 @@ function Reset_File() {
-
//******************************************************************************
//******************************************************************************
?>
@@ -1058,19 +1104,22 @@ function Reset_File() {
-
+
-
+
-';
foreach ($files as $file) {
- $fc++;
- $excludeme = 0;
- $config_excludeds = explode(",", $config_excluded);
- foreach ($config_excludeds as $config_exclusion) {
- if (strrpos(basename($file),$config_exclusion) !== False &&
- strrpos(basename($file),$config_exclusion) !== "") {
- $excludeme = 1;
- }
- }
+ $excluded = FALSE;
+ if (in_array(basename($file), $excluded_list)) { $excluded = TRUE; };
+
+ if (!is_dir($ipath.$file) && !$excluded) {
- if (!is_dir($ipath.$file) && $excludeme == 0) {
//Determine file type & set cooresponding class.
$file_class = "";
$ext = end( explode(".", strtolower($file)) );
-
for ($x=0; $x < count($ftypes); $x++ ){
if ($ext == $ftypes[$x]){ $file_class = $fclasses[$x]; }
}
?>
';
}//end list_files() ************************************************************
@@ -675,7 +629,7 @@ function Edit_Page() { //*******************************************************
$editable = FALSE; if (in_array($ext, $etypes)) { $editable = TRUE; };
?>
-
+
+
', $file, ''; ?>
+
B
@@ -426,21 +418,21 @@ function list_files() { // ...in a vertical table ******************************
function Index_Page(){ //*******************************************************
- global $ONESCRIPT, $WEB_ROOT, $ipath, $config_excluded, $ftypes, $fclasses;
+ global $ONESCRIPT, $ipath;
- Upload_New_Rename_Delete_Links();
-?>
-
-
echo ' Edit/View:
-
+ '.basename($filename) ?>
-
A file with that name already exists.';
+ $message .= '(!) Error copying file - target filename already exists:
';
+ $message .= '(!) '.$new_filename.'';
$page = "edit";
- $filename = basename($old_filename);
+ $filename = $old_filename;
}elseif (copy($old_filename, $new_filename)){
$message = '"'.$old_filename.'"
';
$message .= ' --- successfully copied to ---
';
@@ -718,14 +710,20 @@ function Rename_File_Page() { //************************************************
$old_filename = $_POST["old_filename"];
$new_filename = trim($_POST["rename_filename"], '/');
-
+ $page = "edit"; //return to edit page
+
if (file_exists($new_filename)) {
- $message .= '(!) Error renaming or moving file : '.$old_filename.'
';
- $message .= '(!) Target filename already exists: '.$new_filename.'
';
+ $message .= '(!) Error renaming or moving file - target filename already exists:
';
+ $message .= '(!) '.$new_filename.'';
+ $page = "edit";
+ $filename = $old_filename;
}elseif (rename($old_filename, $new_filename)) {
$message .= '"'.$old_filename.'"
';
$message .= ' --- successfully renamed to ---
';
$message .= '"'.$new_filename.'"
';
+ $filename = $new_filename;
+ $ipath = Check_path(dirname($filename)); //if changed, return to new dir.
+ $varvar = '?i='.$ipath;
}else{
$message .= '(!) Error renaming/moving file from:
"'.$old_filename.'"';
$message .= '(!) To:
"'.$new_filename.'"';
@@ -762,6 +760,7 @@ function Delete_File_Page() { //************************************************
$message = '"'.basename($filename).'" successfully deleted.';
}else{
$message = '(!) Error deleting "'.$filename.'".';
+ $page = "edit";
}
}//end DELETE FILE response code ***********************************************
@@ -892,7 +891,7 @@ function Delete_Folder_Page(){ //***********************************************
if (@rmdir($foldername)) {
$message = 'Folder "'.basename($foldername).'" successfully deleted.';
- $ipath = Check_path($foldername);
+ $ipath = Check_path($foldername); //Return to parent dir.
$varvar = "?i=".$ipath;
} else {
$message .= '(!) "'.$foldername.'/" an error occurred during delete.';
@@ -903,14 +902,11 @@ function Delete_Folder_Page(){ //***********************************************
-
-
-
function Load_Selected_Page(){ //***********************************************
global $page;
if ($page == "login") { Login_Page(); }
if ($page == "index") { Index_Page(); }
- if ($page == "edit") { $pagetitle = "Edit/View File"; Edit_Page();}
+ if ($page == "edit") { Edit_Page(); }
if ($page == "upload") { Upload_Page(); }
if ($page == "new") { New_File_Page(); }
if ($page == "copy") { Copy_File_Page(); }
@@ -926,12 +922,8 @@ function Load_Selected_Page(){ //***********************************************
-
-
-
-
//******************************************************************************
-function Time_Stamp_javascripts() { ?>
+function Time_Stamp_scripts() { ?>
-
-
+
+
-Edit/View:
- '.htmlentities(basename($filename)) ?>
+ '.htmlentities(basename($filename)) ?>
-
+
+
'; $filename = ""; }
+ if ( !is_file($filename) ) {
+ $message .= $EX.' File does not exist: '.$filename.'
'; $filename = "";
+ }
}else{ $filename = ""; }
-if (isset($_GET["p"])) { $page = $_GET["p"]; } // default $page set above
+if (isset($_GET["p"])) { $page = $_GET["p"]; } // default $page set above
$param1 = '?i='.URLencode_path($ipath);
//******************************************************************************
@@ -176,6 +178,33 @@ function Check_path($path) { // returns first valid path in some/supplied/path/
+//*** Verify valid $page *******************************************************
+
+if ($page != "") {
+ if (!in_array(strtolower($page), $valid_pages)) {
+ header("Location: ".$ONESCRIPT); // redirect on invalid page attempts
+ $page = "index";
+ }
+}
+
+
+//Don't load login screen if already in a valid session
+if ( ($page == "login") and ($_SESSION['valid']) ) { $page = "index"; }
+
+
+if ( ($page == "deletefolder") && !is_empty($ipath) ) {
+ $message = $EX.' Folder not empty. Folders must be empty before they can be deleted.';
+ $page = "index";
+}
+
+
+if ( $page == "edit" && !is_file($filename) ) { $page = "index"; }
+//******************************************************************************
+
+
+
+
+
//******************************************************************************
// Misc Functions
@@ -708,11 +737,21 @@ function Edit_Page_response(){ //***If on Edit page, and [Save] clicked ********
function Upload_Page() { //*****************************************************
global $ONESCRIPT, $ipath, $param1, $INPUT_SESSIONID;
+
+ //Determine $MAX_FILE_SIZE to upload
+ $UMF = ini_get('upload_max_filesize'); //assumes it's < post_max_size. If not, oh well.
+ $KMB = strtoupper(substr($UMF, -1));
+
+ if ($KMB == "K") { $MAX_FILE_SIZE = $UMF * 1024; }
+ elseif ($KMB == "M") { $MAX_FILE_SIZE = $UMF * 1048576; }
+ elseif ($KMB == "G") { $MAX_FILE_SIZE = $UMF * 1073741824; }
+ else { $MAX_FILE_SIZE = $UMF; }
?>
Upload File
+
';
- $message .= ''.htmlentities($WEB_ROOT.$destination).'
Upload cancelled.';
+ $message .= htmlentities($WEB_ROOT.$destination).'
Upload cancelled.';
}else{
$message .= 'Uploading: "'.htmlentities($filename).'"...';
$savefile = ordinalize($destination, $filename, $savefile_msg);
if(move_uploaded_file($_FILES['upload_file']['tmp_name'], $savefile)) {
- $message .= '
Upload successful.'.$savefile_msg;
+ $message .= '
Upload successful! '.$savefile_msg;
} else{
- $message .= '
'.$EX.' There was an error. Upload or rename may have failed.';
+ $message .= '
'.$EX.' Error '.$ERROR.' - Upload failed: '.$ERRMSG.'';
}
}
}//end Upload_File_response() **************************************************
@@ -1030,25 +1082,6 @@ function Delete_Folder_response() { //******************************************
-//*** Verify valid $page *******************************************************
-if ($page != "") {
- if (!in_array(strtolower($page), $valid_pages)) {
- header("Location: ".$ONESCRIPT); // redirect on invalid page attempts
- $page = "index";
- }
-}
-if ( ($page == "deletefolder") && !is_empty($ipath) ) {
- $message = '(!) Folder not empty. Folders must be empty before they can be deleted.';
- $page = "index";
-}
-//Don't load login screen if already in a valid session
-if (($page == "login") and ($_SESSION['valid'])) { $page = "index"; }
-//******************************************************************************
-
-
-
-
-
function Load_Selected_Page(){ //***********************************************
global $ONESCRIPT, $page;
From 64e03a3d82167c0c683def98a34fa820ef09ac50 Mon Sep 17 00:00:00 2001
From: David Edit/View:
- '.htmlentities(basename($filename)) ?>
-
-
';
+
+ }elseif ( $too_large_to_edit ) {
+ echo '
+Some browsers (on my PC) bog down or become unstable while editing a large file in an HTML <textarea>.
+$MAX_EDIT_SIZE is in the configuration section of OneFileCMS, and may be adjusted as needed.
+A simple trial and error test can determine a practical limit for a given browser/computer.';
+ $large_file_message2 =
+'View disabled. Filesize > '.number_format($MAX_VIEW_SIZE).' bytes. ($MAX_VIEW_SIZE)
+Click the the file name above to view normally in a browser window.
+(The default value for $MAX_VIEW_SIZE is completely arbitrary, and may be adjusted as desired to suit individual perceptions of neccessity.)';
+
+ echo ''.$header2;
+ echo ''.htmlentities(basename($filename)).'';
+ echo '
';
+
+ Edit_Page_form($ext, $text_editable, $too_large_to_edit, $large_file_message1);
-
-
- '.$filecontent.'
';
+ }elseif ( $text_editable && $too_large_to_view ){
+ echo '
'; }
+ if ( !is_file($filename) ) { $filename = ""; $page = "index"; }
+ }else{ $filename = ""; }
+
+ if (isset($_GET["p"])) { $page = $_GET["p"]; } // default $page set in session startup
+
+ $param1 = '?i='.URLencode_path($ipath);
+}//end Get_GET()****************************************************************
-//******************************************************************************
-// A couple functions needed early
-function URLencode_path($path){ // don't encode the forward slashes
+
+
+function URLencode_path($path){ // don't encode the forward slashes ************
$TS = '';
if (substr($path, -1) == '/' ) { $TS = '/'; } //start with a trailing slash?
$path_array = explode('/',$path);
@@ -95,11 +141,11 @@ function URLencode_path($path){ // don't encode the forward slashes
foreach ($path_array as $level) { $path .= rawurlencode($level).'/'; }
$path = rtrim($path,'/').$TS; //end with trailing slash only if started with one
return $path;
-}//end URLencode_path($path)
+}//end URLencode_path($path) ***************************************************
+
-//*** Clean up & check a path **********
function Check_path($path) { // returns first valid path in some/supplied/path/
global $message, $EX;
$invalidpath = $path; //used for message if supplied $path doesn't exist.
@@ -130,94 +176,25 @@ function Check_path($path) { // returns first valid path in some/supplied/path/
}
return $path;
-}//end Check_path() ********************
-//end a couple functions needed early ******************************************
-
-
-
-
-//******************************************************************************
-//Some global values & $_GET parameters
-//
-$ONESCRIPT = URLencode_path($_SERVER["SCRIPT_NAME"]);
-$DOC_ROOT = $_SERVER["DOCUMENT_ROOT"].'/';
-$WEB_ROOT = URLencode_path(basename($DOC_ROOT)).'/';
-$WEBSITE = $_SERVER["HTTP_HOST"].'/';
-
-//Make arrays out of a few $config_variables for actual use later.
-//Also, remove spaces and make lowercase.
-$etypes = explode(',', strtolower(str_replace(' ', '', $config_etypes))); //editable file types
-$itypes = explode(',', strtolower(str_replace(' ', '', $config_itypes))); //images types to display
-$ftypes = explode(',', strtolower(str_replace(' ', '', $config_ftypes))); //file types with icons
-$fclasses = explode(',', strtolower(str_replace(' ', '', $config_fclass))); //for file types with icons
-$excluded_list = (explode(",", $config_excluded));
-
-
-$valid_pages = array("login","logout","index","edit","upload","newfile","copy","rename","delete","newfolder","renamefolder","deletefolder" );
-
-$INVALID_CHARS = '< > ? * : " | / \\'; //Illegal characters for file/folder names. (Space deliminated)
-$INVALID_CHARS_array = explode(' ', $INVALID_CHARS);
-
-//*** Get main parameters: i=some/path/, f=somefile.xyz, p=somepage
- if (isset($_GET["i"])) { $ipath = Check_path($_GET["i"]); }else{ $ipath = ""; }
-
- if (isset($_GET["f"])) {
- $filename = $ipath.$_GET["f"];
- if ( !is_file($filename) && $_SESSION['valid'] )//Don't set $message for login page.
- { $message .= $EX.' File does not exist: '.htmlentities($filename).'
'; }
- if ( !is_file($filename) ) { $filename = ""; $page = "index"; }
- }else{ $filename = ""; }
-
- if (isset($_GET["p"])) { $page = $_GET["p"]; } // default $page set in session startup
-
- $param1 = '?i='.URLencode_path($ipath);
-//******************************************************************************
-
+}//end Check_path() ************************************************************
-//*** Verify valid $page *******************************************************
-if ($page != "") {
- if (!in_array(strtolower($page), $valid_pages)) {
- header("Location: ".$ONESCRIPT); // redirect on invalid page attempts
- $page = "index";
- }
-}
-
-
-//Don't load login screen if already in a valid session
-if ( ($page == "login") and ($_SESSION['valid']) ) { $page = "index"; }
-
-
-if ( ($page == "deletefolder") && !is_empty($ipath) ) {
- $message = $EX.' Folder not empty. Folders must be empty before they can be deleted.';
- $page = "index";
-}
-
-
-if ( $page == "edit" && !is_file($filename) ) { $page = "index"; }
-//******************************************************************************
-
-
-
-
-//******************************************************************************
-// Misc Functions
-
-
-function is_empty($path){ //********************************
+function is_empty($path){ //****************************************************
$empty = false;
$dh = opendir($path);
for($i = 3; $i; $i--) { $empty = (readdir($dh) === FALSE); }
closedir($dh);
return $empty;
-}//end is_emtpy() //****************************************
+}//end is_emtpy() //************************************************************
+
-//if file_exists(), ordinalize filename until it doesn't ***
-function ordinalize($destination,$filename, &$msg) {
+function ordinalize($destination,$filename, &$msg) { //*************************
+//if file_exists(file.txt), ordinalize filename until it doesn't
+//ie: file.txt.001, file.txt.002, file.txt.003 etc...
global $EX;
$ordinal = 0;
@@ -226,21 +203,20 @@ function ordinalize($destination,$filename, &$msg) {
if (file_exists($savefile)) {
$msg .= $EX.' A file with that name already exists in the target directory.
';
- $savefile_info = pathinfo($savefile);
while (file_exists($savefile)) {
$ordinal = sprintf("%03d", ++$ordinal); // 001, 002, 003, etc...
- $newfilename = $savefile_info['filename'].'.'.$ordinal.'.'.$savefile_info['extension'];
- $savefile = $destination.$newfilename;
+ $savefile = $destination.$filename.'.'.$ordinal;
}
- $msg .= 'Saving as: "'.htmlentities($newfilename).'"';
+ $msg .= 'Saving as: "'.htmlentities(basename($savefile)).'"';
}
return $savefile;
-}//end ordinalize() filename *******************************
+}//end ordinalize() filename ***************************************************
-function Current_Path_Header(){ //**************************
+
+function Current_Path_Header(){ //**********************************************
// Current path. ie: webroot/current/path/
// Each level is a link to that level.
@@ -262,17 +238,18 @@ function Current_Path_Header(){ //**************************
}
}//end if (not at root)
echo '';
-}//end Current_Path_Header() //*****************************
+}//end Current_Path_Header() //*************************************************
+
-function message_box() { //*********************************
+function message_box() { //*****************************************************
global $ONESCRIPT, $message, $page;
if (isset($message)) {
?>
';
-}// end show_image() ***************************************
+}// end show_image() ***********************************************************
-function show_favicon(){
+
+function show_favicon(){ //*****************************************************
global $config_favicon, $DOC_ROOT;
if (file_exists($DOC_ROOT.$config_favicon)) {
echo '
';
}
-}// end show_favicon()
+}// end show_favicon() *********************************************************
+
-//
-// End of misc functions ********************************************************
+function Init_Macros(){ //*** ($varibale="some reusable chunk of code")*********
+global $ONESCRIPT, $param1, $INPUT_SESSIONID, $FORM_COMMON,
+ $SVG_icon_circle_plus, $SVG_icon_circle_x, $SVG_icon_pencil, $SVG_icon_img_0;
-//A few macros ($varibale="some reusable chunk of code")************************
-$INPUT_SESSIONID = ''.PHP_EOL;
+$INPUT_SESSIONID = ''.PHP_EOL;
$FORM_COMMON = '
'.
' Name contains invalid character(s): '.
@@ -900,14 +883,13 @@ function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //******
';
$message .= htmlentities($WEB_ROOT.$new_location).'/
';
}elseif ( !file_exists($filename) ){
- $message .= $EX.' '.$msg1.' Error - Source file does not exist:
';
+ $message .= $EX.' '.$msg1.' Error - source file does not exist:
';
$message .= htmlentities($filename);
}elseif (file_exists($new_name)) {
$message .= $EX.' '.$msg1.' Error - target filename already exists:
';
@@ -1077,45 +1059,21 @@ function Delete_Folder_response() { //******************************************
-//Logout ***********************************************************************
-if ($page == "logout") {
- $page = "login";
- $_SESSION['valid'] = "0";
- session_destroy();
- $message = 'You have successfully logged out.';
-}//*****************************************************************************
-
+function Page_Title(){ //***
+ $too_large_to_edit_message =
+'Edit disabled. Filesize > '.number_format($MAX_EDIT_SIZE).' bytes.
Some browsers (on my PC) bog down or become unstable while editing a large file in an HTML <textarea>.
-$MAX_EDIT_SIZE is in the configuration section of OneFileCMS, and may be adjusted as needed.
+Adjust $MAX_EDIT_SIZE in the configuration section of OneFileCMS as needed.
A simple trial and error test can determine a practical limit for a given browser/computer.';
- $large_file_message2 =
-'View disabled. Filesize > '.number_format($MAX_VIEW_SIZE).' bytes. ($MAX_VIEW_SIZE)
+ $too_large_to_view_message =
+'View disabled. Filesize > '.number_format($MAX_VIEW_SIZE).' bytes.
Click the the file name above to view normally in a browser window.
+Adjust $MAX_VIEW_SIZE in the configuration section of OneFileCMS as needed.
(The default value for $MAX_VIEW_SIZE is completely arbitrary, and may be adjusted as desired to suit individual perceptions of neccessity.)';
echo ''.$header2;
echo ''.htmlentities(basename($filename)).'';
- echo '
';
+ echo ''.PHP_EOL;
- Edit_Page_form($ext, $text_editable, $too_large_to_edit, $large_file_message1);
+ Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_edit_message);
if ( in_array( $ext, $itypes) ) { show_image(); }
echo '';
if ( $text_editable && $too_large_to_edit && !$too_large_to_view ) {
- $filecontent = htmlspecialchars(file_get_contents($filename), ENT_SUBSTITUTE,'UTF-8');
+ $filecontent = htmlspecialchars(file_get_contents($filename), ENT_COMPAT,'UTF-8');
echo ''.$filecontent.'
';
}elseif ( $text_editable && $too_large_to_view ){
- echo '
';
- $message .= $EX.' Error durring '.$msg1.' from the above to the following:
';
+ $message .= $EX.' Error during '.$msg1.' from the above to the following:
';
$message .= ''.htmlentities($WEB_ROOT.$new_name).'';
}
}//end Copy_Ren_Move_response() ************************************************
@@ -958,7 +988,7 @@ function Delete_File_response(){ //*********************************************
global $filename, $message, $EX, $page;
$page = "index"; //Return to index
- $filename = htmlspecialchars_decode($_POST["delete_file"]);
+ $filename = $_POST["delete_file"];
if (unlink($filename)) {
$message .= 'Deleted file: '.htmlentities(basename($filename));
@@ -1042,7 +1072,7 @@ class="verify"> /
function Delete_Folder_response() { //******************************************
global $ipath, $param1, $page, $message, $EX;
$page = "index"; //Return to index
- $foldername = htmlspecialchars_decode(trim($_POST["delete_folder"], '/'));
+ $foldername = trim($_POST["delete_folder"], '/');
if ( !is_empty($ipath) ) {
$message .= $EX.' Folder not empty. Folders must be empty before they can be deleted.';
@@ -1456,8 +1486,7 @@ function style_sheet(){ //****************************************************?>
width : 99%;
padding: .2em;
margin : 0;
- color: #444;
- background-color: #F0F0F0;
+ background-color: #FFF000;
line-height: 1.4em;
}
@@ -1664,7 +1693,7 @@ function style_sheet(){ //****************************************************?>
Upload File
-
'.$EX.' Error '.$ERROR.' - Upload failed: '.$ERRMSG.'';
+ $message .= '
'.$EX.' Upload failed: '.$ERRMSG.'';
}
}
}//end Upload_File_response() **************************************************
@@ -874,6 +959,7 @@ function New_File_response() { //***********************************************
$filename = $ipath.$new_name;
$page = "index"; // return to index if new file fails
+ $invalid = false;
foreach ($INVALID_CHARS_array as $bad_char) {
if (strpos($new_name, $bad_char) !== false) { $invalid = true; }
}
@@ -958,6 +1044,8 @@ function Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $msg2, $is
if ($isfile) { $ipath = Check_path(dirname($filename)); } //if changed,
else { $ipath = Check_path($filename); } //return to new dir.
$param1 = '?i='.URLencode_path($ipath);
+
+
}else{
$message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
$message .= $EX.' Error during '.$msg1.' from the above to the following:
';
@@ -1022,6 +1110,7 @@ function New_Folder_response(){ //**********************************************
$new_name = trim($_POST["new_folder"],'/ '); //Trim spaces, and make sure only has a single trailing slash.
+
foreach ($INVALID_CHARS_array as $bad_char) {
if (strpos($new_name, $bad_char) !== false) { $invalid = true; }
}
@@ -1093,6 +1182,7 @@ function Page_Title(){ //***
';}
+ $message .= '';
+ $message .= $BR.$EX.' CAUTION '.$EX.' You are editing the active copy of OneFileCMS - BACK IT UP & BE CAREFUL !!'; }
-if ( ($page == "deletefolder") && !is_empty($ipath) ) { //Don't load delete page if can't delete.
- $message = $EX.' Folder not empty. Folders must be empty before they can be deleted.';
- $page = "index";
-}
//******************************************************************************
@@ -1710,8 +1828,11 @@ function style_sheet(){ //****************************************************?>
+
+
+
+
'.$EX.' File contains an invalid character. Edit and view disabled.
';
+ echo ' This behavior can be inconsistant from version to version of php.
';
echo ' htmlspecialchars() returned and empty string from what may be an otherwise valid file.
';
- echo ' This behavior can be inconsistant from version to version (of php).
';
}else{
echo '';
echo ''.$header2;
echo ''.htmlentities(basename($filename)).'';
echo '
'.PHP_EOL;
+?>
+
+
+
+
+
Date: Thu, 14 Jun 2012 16:20:08 -0400
Subject: [PATCH 079/228] Version 3.1.9 OneFileCMS can now store a password
hash instead of the plain text password itself. Added Hash_Page() &
_response() Minor fix to Upload_Page_response() Updated readme
---
OneFileCMS_structure.txt | 5 +-
onefilecms.php | 212 +++++++++++++++++++--------------------
readme.markdown | 19 ++--
3 files changed, 123 insertions(+), 113 deletions(-)
diff --git a/OneFileCMS_structure.txt b/OneFileCMS_structure.txt
index a3f2b5f..f674c03 100755
--- a/OneFileCMS_structure.txt
+++ b/OneFileCMS_structure.txt
@@ -4,6 +4,7 @@ SOME STANDARD GLOBAL VARIABLES
MISC FUNCTIONS:
Session_Startup()
+ hashit()
undo_magic_quotes()
Get_GET()
URLencode_path()
@@ -13,7 +14,6 @@ MISC FUNCTIONS:
Current_Path_Header()
message_box()
Upload_New_Rename_Delete_Links()
- Close_Button()
Cancel_Submit_Buttons()
show_image()
show_favicon()
@@ -40,6 +40,8 @@ SVG ICON FUNCTIONS:
show_icon()
PAGE & RESPONSE FUNCTIONS:
+ Hash_Page()
+ Hash_Page_response()
Login_Page()
list_files()
Index_Page()
@@ -68,6 +70,7 @@ JAVASCRIPT & STYLESHEET FUNCTIONS:
style_sheet() //css
LOGIC TO DETERMINE PAGE ACTION
+ Verify good PHP version
Call Session_Startup()
Call Get_GET()
Call Init_Macros()
diff --git a/onefilecms.php b/onefilecms.php
index 49d5af5..3dd860b 100755
--- a/onefilecms.php
+++ b/onefilecms.php
@@ -1,7 +1,7 @@
? * : " | / \\'; //Illegal characters for file/folder names. (Space deliminated)
+$INVALID_CHARS_array = explode(' ', $INVALID_CHARS);
+
//Make arrays out of a few $config_variables for actual use later.
//Also, remove spaces and make lowercase.
$etypes = explode(',', strtolower(str_replace(' ', '', $config_etypes))); //editable file types
@@ -80,36 +85,31 @@
$ftypes = explode(',', strtolower(str_replace(' ', '', $config_ftypes))); //file types with icons
$fclasses = explode(',', strtolower(str_replace(' ', '', $config_fclass))); //for file types with icons
$excluded_list = (explode(",", $config_excluded));
-
-$valid_pages = array("login","logout","index","edit","upload","newfile","copy","rename","delete","newfolder","renamefolder","deletefolder" );
-
-$INVALID_CHARS = '< > ? * : " | / \\'; //Illegal characters for file/folder names. (Space deliminated)
-$INVALID_CHARS_array = explode(' ', $INVALID_CHARS);
//******************************************************************************
function Session_Startup() {//**************************************************
- global $config_username, $config_password, $message , $page, $VALID_POST;
+ global $USERNAME, $PASSWORD, $HASHWORD, $USE_HASH, $SALT, $message , $page, $VALID_POST;
session_start();
undo_magic_quotes();
-
+ if ($USE_HASH){ $PASS = $HASHWORD; }else{ $PASS = $PASSWORD; }
if ( isset($_POST["username"]) || isset($_POST["password"]) ) {
$_SESSION['username'] = $_POST["username"];
- $_SESSION['password'] = $_POST["password"];
-
+ if ($USE_HASH) { $_SESSION['password'] = hashit($_POST["password"]); }
+ else { $_SESSION['password'] = $_POST["password"]; }
- if (($_POST["username"] != $config_username) || ($_POST["password"] != $config_password))
- { $message = $EX.' INVALID LOGIN ATTEMPT'; }
+ if (($_SESSION['username'] != $USERNAME) || ($_SESSION['password'] != $PASS))
+ { $message .= $EX.' INVALID LOGIN ATTEMPT'; }
}
- if (($_SESSION['username'] == $config_username) and ( $_SESSION['password'] == $config_password ))
+ if (($_SESSION['username'] == $USERNAME) && ( $_SESSION['password'] == $PASS ))
{ $_SESSION['valid'] = "1"; $page = "index"; }
else { $_SESSION['valid'] = "0"; $page = "login"; unset($_GET["p"]); session_destroy() ;}
@@ -121,14 +121,14 @@ function Session_Startup() {//**************************************************
-
-
-
-
-
-
-
-
+function hashit($key){ //*******************************************************
+ //This is the super-secret stuff - don't tell anyone!!
+ //If you change anything here, redo the hash for your password.
+ $hash = hash('sha256', trim($key).$salt); // trim off leading & trailing spaces.
+ $salt = 'somerandomesalt';
+ for ( $x=0; $x < 1000; $x++ ) { $hash = hash('sha256', $hash.$salt); }
+ return $hash;
+}//end hashit() ****************************************************************
@@ -338,16 +338,16 @@ function Upload_New_Rename_Delete_Links() { //**********************************
function Cancel_Submit_Buttons($submit_label, $focus) { //**********************
//$submit_label = Rename, Copy, Delete, etc...
//$focus is ID of element to receive focus(). (element may be outside this function)
- global $ONESCRIPT, $ipath, $param1, $filename, $page;
+ global $ONESCRIPT, $ipath, $param1, $param2, $filename, $page;
- // [Cancel] returns to either the current/path, or current/path/file
- if ($filename != "") { $param1 .= '&f='.rawurlencode(basename($filename)).'&p='.edit; }
+ // [Cancel] returns to either the index, or edit page.
+ if ($filename == "") {$params = "";}else{ $params .= $param2.'&p=edit'; }
?>
- Generate a Password Hash
+
+
+
+ 2) Or, use $HASHWORD to store the hash of your password, and set $USE_HASH = 1.
+
+
+ In other words, take the idea that this adds much of an improvement to security with a grain of cryptographic salt...*
+
+
+ The hash will be displayed in a yellow message box above that.
+
+ 'Make sure the hash ends up in quotes.'
+ Make sure to copy ALL of, and ONLY, the hash (no spaces etc). A double-click should select it...
+
+ PS: Everything I know about security - you just read...
+
';
$message .= htmlentities($new_name);
@@ -1022,7 +1022,7 @@ function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //******
//******************************************************************************
function Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $msg2, $isfile){
//$action = 'copy' or 'rename'. $isfile = 1 if acting on a file, not a folder
- global $WEB_ROOT, $ipath, $param1, $message, $EX, $page, $filename;
+ global $WEB_ROOT, $ipath, $param1, $param2, $message, $EX, $page, $filename;
$old_name = trim($old_name,'/ ');
$new_name = trim($new_name,'/ ');
@@ -1047,8 +1047,8 @@ function Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $msg2, $is
if ($isfile) { $ipath = Check_path(dirname($filename)); } //if changed,
else { $ipath = Check_path($filename); } //return to new dir.
$param1 = '?i='.URLencode_path($ipath);
-
-
+ $param2 = '&f='.rawurlencode(basename($filename));
+ $param3 = '&p=edit';
}else{
$message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
$message .= $EX.' Error during '.$msg1.' from the above to the following:
';
@@ -1113,7 +1113,7 @@ function New_Folder_response(){ //**********************************************
$new_name = trim($_POST["new_folder"],'/ '); //Trim spaces, and make sure only has a single trailing slash.
-
+ $invalid = false;
foreach ($INVALID_CHARS_array as $bad_char) {
if (strpos($new_name, $bad_char) !== false) { $invalid = true; }
}
@@ -1185,7 +1185,7 @@ function Page_Title(){ //***';
+ echo '
Please wait ';
+ $message .= ($LOGIN_DELAY - $elapsed) .' seconds to try again.';
+ $_SESSION['valid'] = '0';
+ return 0;
+ }
+
+ if ($USE_HASH){ $VALID_PASSWORD = (hashit($_POST['password']) == $HASHWORD); }
+ else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
+
+ //Validate login attempt
+ if ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
+ session_regenerate_id(true);
+ $_SESSION['USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']); //for simple user consistancy check later.
+ $_SESSION['valid'] = '1';
+ $page = "index";
+ unlink($Login_Attempts); //delete invalid login count file
+ }else{
+ Logout();
+ $message .= $EX.' INVALID LOGIN ATTEMPT # '.$attempts.' ';
+ file_put_contents($Login_Attempts, $attempts);
+ }
+}//end Login_response() //******************************************************
+
+
+
+
function hashit($key){ //*******************************************************
//This is the super-secret stuff - Keep it secret, keep it safe!
//If you change anything here, redo the hash for your password.
@@ -162,7 +195,7 @@ function strip_array($var) {
function Get_GET() { //*** Get main parameters *********************************
// i=some/path/, f=somefile.xyz, p=somepage
- global $ipath, $filename, $page, $param1, $param2, $param3, $message, $EX;
+ global $ipath, $filename, $page, $valid_pages, $param1, $param2, $param3, $message, $EX;
undo_magic_quotes();
@@ -175,7 +208,8 @@ function Get_GET() { //*** Get main parameters *********************************
if ( !is_file($filename) ) { $filename = ""; $page = "index"; }
}else{ $filename = ""; }
- if (isset($_GET["p"])) { $page = $_GET["p"]; } // default $page set in session startup
+ if (isset($_GET["p"])) { $page = $_GET["p"]; }
+ if (!in_array(strtolower($page), $valid_pages)) { $page = "index"; }
$param1 = '?i='.URLencode_path($ipath);
if ($filename == "") { $param2 = ""; }else{ $param2 = '&f='.rawurlencode(basename($filename)); }
@@ -337,16 +371,6 @@ function Upload_New_Rename_Delete_Links() { //**********************************
-
-
-
-
-
-
-
-
-
-
function Cancel_Submit_Buttons($submit_label, $focus) { //**********************
//$submit_label = Rename, Copy, Delete, etc...
//$focus is ID of element to receive focus(). (element may be outside this function)
@@ -823,7 +847,7 @@ function Edit_Page() { //*******************************************************
$too_large_to_edit_message =
'Edit disabled. Filesize > '.number_format($MAX_EDIT_SIZE).' bytes.
-Some browsers (on my PC) bog down or become unstable while editing a large file in an HTML <textarea>.
+Some browsers (ie: IE) bog down or become unstable while editing a large file in an HTML <textarea>.
Adjust $MAX_EDIT_SIZE in the configuration section of OneFileCMS as needed.
A simple trial and error test can determine a practical limit for a given browser/computer.';
$too_large_to_view_message =
@@ -971,7 +995,7 @@ function New_File_Page() { //***************************************************
function New_File_response() { //***********************************************
- global $ipath, $param2, $filename, $page, $message, $EX, $INVALID_CHARS, $INVALID_CHARS_array;
+ global $ipath, $param2, $param3, $filename, $page, $message, $EX, $INVALID_CHARS, $INVALID_CHARS_array;
$new_name = trim($_POST["new_file"],'/ '); //Trim spaces and slashes.
$filename = $ipath.$new_name;
@@ -996,6 +1020,7 @@ function New_File_response() { //***********************************************
$message .= 'Created file: '.htmlentities($new_name);
$page = "edit";
$param2 = '&f='.rawurlencode(basename($filename));// for Edit_Page() buttons
+ $param3 = '&p=edit'; // for Edit_Page() buttons
}else{
$message .= $EX.' Error - new file not created:
';
$message .= htmlentities($new_name);
@@ -1423,7 +1448,7 @@ function style_sheet(){ //****************************************************?>
form p { margin-bottom: .3em; }
-label { display: inline-block; width : 6em; font-size : 1em; }
+label { display: inline-block; width : 6em; font-size : 1em; font-weight: bold; }
svg { margin: 0; padding: 0; }
@@ -1573,7 +1598,7 @@ function style_sheet(){ //****************************************************?>
input[type="text"] {
border: 1px solid #807568;
padding: 2px;
- width: 40em;
+ width: 50em;
font: 1em "Courier New", Courier, monospace;
}
@@ -1701,7 +1726,7 @@ function style_sheet(){ //****************************************************?>
overflow: visible;
}
-.web_root { font:1.2em Courier; }
+.web_root { font:1em Courier; }
.verify {
border: 1px solid #F44;
@@ -1771,17 +1796,14 @@ function style_sheet(){ //****************************************************?>
//*** Verify valid $page and/or $filename **************************************
-if (!in_array(strtolower($page), $valid_pages)) { $page = "index"; }
-
//Don't load login screen if already in a valid session.
-elseif ( ($page == "login") && ($_SESSION['valid']) ) { $page = "index"; }
+if ( ($page == "login") && ($_SESSION['valid']) ) { $page = "index"; }
//Don't load edit page if $filename doesn't exist.
elseif ( ($page == "edit") && !is_file($filename) ) { $page = "index"; }
-elseif ($page == "logout") { $page = "login"; $_SESSION['valid'] = "0"; session_destroy();
- session_regenerate_id(true);
- session_unset(); session_destroy(); session_write_close();// setcookie(session_name(),'',0,'/');
+elseif ($page == "logout") {
+ Logout();
$message .= 'You have successfully logged out.'; }
//Don't load delete page if folder not empty.
From ea431d37c287a90a9bdbaff7bac1062b95596534 Mon Sep 17 00:00:00 2001
From: Self-Evident
'.$EX.' Upload failed: '.$ERRMSG.'';
}
}
-}//end Upload_File_response() **************************************************
+}//end Upload_response() **************************************************
@@ -1779,7 +1781,7 @@ function style_sheet(){ //****************************************************?>
if ($VALID_POST) { //***********************************************************
- if (isset($_FILES['upload_file']['name'])) { Upload_File_response(); }
+ if (isset($_FILES['upload_file']['name'])) { Upload_response(); }
elseif (isset($_POST["whattohash"] )) { Hash_Page_response(); }
elseif (isset($_POST["filename"] )) { Edit_Page_response(); }
elseif (isset($_POST["new_file"] )) { New_File_response(); }
@@ -1855,8 +1857,7 @@ function style_sheet(){ //****************************************************?>
From a0a0abff8c7efa12d6b9f56b0a7d88c6013899ab Mon Sep 17 00:00:00 2001
From: Self-Evident
Please wait ';
- $message .= ($LOGIN_DELAY - $elapsed) .' seconds to try again.';
- $_SESSION['valid'] = '0';
- return 0;
- }
-
- if ($USE_HASH){ $VALID_PASSWORD = (hashit($_POST['password']) == $HASHWORD); }
- else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
-
- //Validate login attempt
- if ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
- session_regenerate_id(true);
- $_SESSION['USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']); //for simple user consistancy check later.
- $_SESSION['valid'] = '1';
- $page = "index";
- unlink($Login_Attempts); //delete invalid login count file
- }else{
- Logout();
- $message .= $EX.' INVALID LOGIN ATTEMPT # '.$attempts.' ';
- file_put_contents($Login_Attempts, $attempts);
- }
-}//end Login_response() //******************************************************
+ chdir($_SERVER["DOCUMENT_ROOT"]); //Allow OneFileCMS.php to be started from any dir on the site.
+}//End Session_Startup() *******************************************************
@@ -664,6 +643,20 @@ function Hash_Page_response() { //**********************************************
+function Logout(){ //***********************************************************
+ global $page;
+ session_regenerate_id(true);
+ session_unset();
+ session_destroy();
+ session_write_close();
+ unset($_GET);
+ unset($_POST);
+ $page = 'login';
+}//end Logout() ****************************************************************
+
+
+
+
function Login_Page() { //******************************************************
global $ONESCRIPT, $message;
?>
@@ -687,6 +680,41 @@ function Login_Page() { //******************************************************
+function Login_response() { //**************************************************
+ global $USERNAME, $PASSWORD, $USE_HASH, $HASHWORD, $MAX_ATTEMPTS, $LOGIN_DELAY, $message, $EX, $page, $DOC_ROOT;
+
+ $Login_Attempts = $DOC_ROOT.trim($_SERVER["SCRIPT_NAME"],'/').'.invalid_login_attempts';
+ $attempts = (int)file_get_contents($Login_Attempts) + 1;
+ clearstatcache();
+ $elapsed = time() - filemtime($Login_Attempts);
+
+ if ( ($attempts > $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
+ $message = $EX.' Too many invalid login attempts.
Please wait ';
+ $message .= ($LOGIN_DELAY - $elapsed) .' seconds to try again.';
+ $_SESSION['valid'] = '0';
+ return 0;
+ }
+
+ if ($USE_HASH){ $VALID_PASSWORD = (hashit($_POST['password']) == $HASHWORD); }
+ else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
+
+ //Validate login attempt
+ if ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
+ session_regenerate_id(true);
+ $_SESSION['USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']); //for simple user consistancy check later.
+ $_SESSION['valid'] = '1';
+ $page = "index";
+ unlink($Login_Attempts); //delete invalid login count file
+ }else{
+ Logout();
+ $message .= $EX.' INVALID LOGIN ATTEMPT # '.$attempts.' ';
+ file_put_contents($Login_Attempts, $attempts);
+ }
+}//end Login_response() //******************************************************
+
+
+
+
function list_files() { // ...in a vertical table ******************************
//called from Index Page
@@ -821,7 +849,7 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_
Edit_Page_scripts();
echo '';
echo '
';}
$message .= '';
$message .= $BR.$EX.' CAUTION '.$EX.' You are editing the active copy of OneFileCMS - BACK IT UP & BE CAREFUL !!'; }
From 59daa939c77c74938abffca605d58e7db03f6e1c Mon Sep 17 00:00:00 2001
From: David
';
+ return;
+ }
+ }
+ $_SESSION['last_active_time'] = time() ;
- $VALID_POST = ($_SESSION['valid'] && $_POST["sessionid"] == session_id());
+ //If POSTing, verify...
+ $VALID_POST = 0; //Default until verified otherwise
+ if ( $_SESSION['valid'] && isset($_POST['nuonce']) ) {
+ if ( $_POST['nuonce'] == $_SESSION['nuonce'] ) {
+ $VALID_POST = 1;
+ }else{
+ Logout();
+ $message .= $EX.' INVALID POST
';
+ return;
+ }
+ }
session_regenerate_id(true);
+ $_SESSION['nuonce'] = sha1(mt_rand().microtime()); //provided in
'; }
if ( !is_file($filename) ) { $filename = ""; $page = "index"; }
}else{ $filename = ""; }
@@ -358,7 +382,7 @@ function Cancel_Submit_Buttons($submit_label, $focus) { //**********************
global $ONESCRIPT, $ipath, $param1, $param2, $filename, $page;
// [Cancel] returns to either the index, or edit page.
- if ($filename == "") {$params = "";}else{ $params .= $param2.'&p=edit'; }
+ if ($filename == "") {$params = "";}else{ $params = $param2.'&p=edit'; }
?>
';
- echo 'Image shown at ~'. round($SCALE*100) .'% of full size.
('.$img_info[3].')';
+ echo ''.PHP_EOL;
@@ -416,7 +440,7 @@ function Init_Macros(){ //*** ($varibale="some reusable chunk of code")*********
global $ONESCRIPT, $param1, $param2, $INPUT_SESSIONID, $FORM_COMMON,
$SVG_icon_circle_plus, $SVG_icon_circle_x, $SVG_icon_pencil, $SVG_icon_img_0;
-$INPUT_SESSIONID = ''.PHP_EOL;
+$INPUT_SESSIONID = ''.PHP_EOL;
$FORM_COMMON = '
-Admin'; }
+Admin'; }
+
+//Countdown timer...
+if ( $page != "edit" && $page != login) {
+ Timeout_Timer('timer', 'timeout');
+ echo 'Session time out in: ';
+}
?>
';
- return;
+ $message .= 'Session expired.
';
}
}
- $_SESSION['last_active_time'] = time() ;
+
+ $_SESSION['last_active_time'] = time();
//If POSTing, verify...
- if ( $_SESSION['valid'] && isset($_POST['nuonce']) ) {
+ if ( isset($_POST['nuonce']) ) {
if ( $_POST['nuonce'] == $_SESSION['nuonce'] ) {
$VALID_POST = 1;
}else{
Logout();
$message .= $EX.' INVALID POST
';
- return;
}
}
-
- session_regenerate_id(true);
- $_SESSION['nuonce'] = sha1(mt_rand().microtime()); //provided in www \ current \ path \
+ //Remove any '.' and '..' parts of the path. Causes issues in www / current / path /
$pathparts = explode( '/', $path);
$len = count($pathparts);
$path = ""; //Cleaned path.
@@ -386,14 +395,13 @@ function Cancel_Submit_Buttons($submit_label, $focus) { //**********************
// [Cancel] returns to either the index, or edit page.
if ($filename == "") {$params = "";}else{ $params = $param2.'&p=edit'; }
?>
-
+
@@ -693,7 +691,7 @@ function Hash_response() { //***************************************************
-function Logout(){ //***********************************************************
+function Logout() { //**********************************************************
global $page;
session_regenerate_id(true);
session_unset();
@@ -708,7 +706,6 @@ function Logout(){ //***********************************************************
-
function Login_Page() { //******************************************************
global $ONESCRIPT, $message;
?>
@@ -723,7 +720,7 @@ function Login_Page() { //******************************************************
-
+
= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){ //if already > max,
- $message .= $EX.' Too many invalid login attempts. ('.$attempts.')
';
- $message .= 'Please wait '.($LOGIN_DELAY - $elapsed) .' seconds to try again. ';
+ if ($attempts > 0) { $message .= 'There have been '.$attempts.' invalid login attempts.
';}
+ if ( ($attempts >= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
+ $message .= 'Please wait '.Timeout_Timer(($LOGIN_DELAY - $elapsed), 'timer0', '', '').' seconds to try again. ';
return;
}
- //Validate login attempt
- if ($USE_HASH){ $VALID_PASSWORD = (hashit($_POST['password']) == $HASHWORD); }
- else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
+ //Validate password
+ if ($USE_HASH) { $VALID_PASSWORD = (hashit($_POST['password']) == $HASHWORD); }
+ else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
- if ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
+ //validate login. Ignore attempt if username & password are blank.
+ if ( ($_POST['password'] == "") && ($_POST['username'] == "") ) { return;
+ }elseif ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
session_regenerate_id(true);
- $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; //for simple user consistancy check later.
+ $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; //for user consistancy check.
$_SESSION['valid'] = 1;
$page = "index";
unlink($LOGIN_ATTEMPTS); //delete invalid attempt count file
}else{
file_put_contents($LOGIN_ATTEMPTS, ++$attempts); //increment & save attempt
+ $message = $EX.' INVALID LOGIN ATTEMPT #'.$attempts.'
';
if ($attempts >= $MAX_ATTEMPTS) {
- $message .= $EX.' INVALID LOGIN ATTEMPT #'.$attempts.'
';
- $message .= 'Please wait '.$LOGIN_DELAY.' seconds to try again. ';
- }else{
- $message .= $EX.' INVALID LOGIN ATTEMPT #'.$attempts.' ';
+ $message .= 'Please wait '.Timeout_Timer($LOGIN_DELAY, 'timer0', '', '').' seconds to try again. ';
}
}
}//end Login_response() //******************************************************
@@ -840,12 +837,13 @@ function Index_Page(){ //*******************************************************
function Edit_Page_Buttons($text_editable, $too_large_to_edit) { //*************
- global $ONESCRIPT, $param1, $param2;
+ global $ONESCRIPT, $param1, $param2, $MAX_IDLE_TIME;
$Button = '
+
,'?>
+
+ ,'?>
-
';}
- $message .= '';
- $message .= $BR.$EX.' CAUTION '.$EX.' You are editing the active copy of OneFileCMS - BACK IT UP & BE CAREFUL !!'; }
-
-//******************************************************************************
+ elseif ($page == "uploaded" && !$VALID_POST){
+ $message .= $EX.' Upload Error. Total POST data (mostly filesize) exceeded post_max_size = '.ini_get('post_max_size').' (from php.ini).';
+ $page = "index";}
+
+ elseif ( ($page == "edit") && ($filename == trim(rawurldecode($ONESCRIPT), '/')) ) {
+ if ( $message == "" ) { $BR = ""; } else { $BR = '
';}
+ $message .= '';
+ $message .= $BR.$EX.' CAUTION '.$EX.' You are editing the active copy of OneFileCMS - BACK IT UP & BE CAREFUL !!';
+ }
+ //**************************************************************************
+}//end if $_SESSION[valid] *****************************************************
@@ -1988,10 +1992,10 @@ function style_sheet(){ //****************************************************?>
-
-
+
+
@@ -2012,27 +2016,26 @@ function style_sheet(){ //****************************************************?>
-
+
-
+'; } ?>
Admin'; }
+if ( ($page != "login") && ($page != "hash") ){
+echo '
';
+ }
+ }
+
+ $_SESSION['last_active_time'] = time();
+
+ //If POSTing, verify...
+ if ( isset($_POST['nuonce']) ) {
+ if ( $_POST['nuonce'] == $_SESSION['nuonce'] ) {
+ $VALID_POST = 1;
+ }else{
+ Logout();
+ $message .= $EX.' INVALID POST
';
+ }
+ }
+}//end Verify_IDLE_POST_etc() //************************************************
+
+
+
+
+function hashit($key){ //*******************************************************
+ //This is the super-secret stuff - Keep it secret, keep it safe!
+ //If you change anything here, or the $SALT, redo the hash for your password.
+ global $SALT;
+ $hash = hash('sha256', trim($key).$SALT); // trim off leading & trailing spaces.
+ for ( $x=0; $x < 1000; $x++ ) { $hash = hash('sha256', $hash.$SALT); }
+ return $hash;
+}//end hashit() ****************************************************************
+
+
+
+
+function undo_magic_quotes(){ //************************************************
+
+ function strip_array($var) {
+ if (is_array($var)) {return array_map("strip_array", $var); }
+ else {return stripslashes($var); }
+ } //Note: stripslashes also handles cases when magic_quotes_sybase is on.
+
+ if (get_magic_quotes_gpc()) {
+ if (isset($_GET)) { $_GET = strip_array($_GET); }
+ if (isset($_POST)) { $_POST = strip_array($_POST); }
+ if (isset($_COOKIE)) { $_COOKIE = strip_array($_COOKIE); }
+ }
+}//end undo_magic_quotes() *****************************************************
+
+
+
+
+function Get_GET() { //*** Get main parameters *********************************
+ // i=some/path/, f=somefile.xyz, p=somepage
+ global $ipath, $filename, $page, $valid_pages, $param1, $param2, $param3, $message, $EX;
+
+ undo_magic_quotes();
+
+ if (isset($_GET["i"])) { $ipath = Check_path($_GET["i"]); }else{ $ipath = ""; }
+
+ if (isset($_GET["f"])) {
+ $filename = $ipath.$_GET["f"];
+ if ( !is_file($filename) && $_SESSION['valid'] )//Set $message except for login page.
+ { $message .= $EX.' File does not exist: '.htmlentities($filename).'
'; }
+ if ( !is_file($filename) ) { $filename = ""; $page = "index"; }
+ }else{ $filename = ""; }
+
+ if (isset($_GET["p"])) { $page = $_GET["p"]; }
+ if (!in_array(strtolower($page), $valid_pages)) { $page = "index"; }
+
+ $param1 = '?i='.URLencode_path($ipath);
+ if ($filename == "") { $param2 = ""; }else{ $param2 = '&f='.rawurlencode(basename($filename)); }
+ if ($page == "" ) { $param3 = ""; }else{ $param3 = '&p='.$page; }
+}//end Get_GET()****************************************************************
+
+
+
+
+function URLencode_path($path){ // don't encode the forward slashes ************
+ $TS = ''; // Trailing Slash/
+ if (substr($path, -1) == '/' ) { $TS = '/'; } //start with a $TS?
+ $path_array = explode('/',$path);
+ $path = "";
+ foreach ($path_array as $level) { $path .= rawurlencode($level).'/'; }
+ $path = rtrim($path,'/').$TS; //end with $TS only if started with one
+ return $path;
+}//end URLencode_path($path) ***************************************************
+
+
+
+
+function Check_path($path) { // returns first valid path in some/supplied/path/
+ global $message, $EX;
+ $invalidpath = $path; //used for message if supplied $path doesn't exist.
+ $path = str_replace('\\','/',$path); //Make sure all forward slashes.
+ $path = trim($path,"/ ."); // trim slashes, dots, and spaces
+
+ //Remove any '.' and '..' parts of the path. Causes issues in www / current / path /
+ $pathparts = explode( '/', $path);
+ $len = count($pathparts);
+ $path = ""; //Cleaned path.
+ foreach ($pathparts as $value) { //(More reliable than str_replace(entire_string).)
+ if ( !(($value == '.') && (!value == '..')) ) { $path .= $value.'/'; }
+ }
+
+ $path = trim($path,"/"); // Remove -for now- final trailing slash.
+
+ if (strlen($path) < 1) { return ""; } //If at site root
+ else {
+ if (!is_dir($path) && (strlen($message) < 1))
+ { $message .= $EX.' Directory does not exist: '.htmlentities($invalidpath).'
'; }
+
+ while ( (strlen($path) > 0) && (!is_dir($path)) ) {
+ $path = dirname($path);
+ }
+
+ $path = $path.'/';
+ if ($path == './') { $path = ""; } // ./ means path not found, so clear for root.
+ }
+
+ return $path;
+}//end Check_path() ************************************************************
+
+
+
+
+function is_empty($path){ //****************************************************
+ $empty = false;
+ $dh = opendir($path);
+ for($i = 3; $i; $i--) { $empty = (readdir($dh) === FALSE); }
+ closedir($dh);
+ return $empty;
+}//end is_emtpy() //************************************************************
+
+
+
+
+function ordinalize($destination,$filename, &$msg) { //*************************
+//if file_exists(file.txt), ordinalize filename until it doesn't
+//ie: file.txt.001, file.txt.002, file.txt.003 etc...
+ global $EX;
+
+ $ordinal = 0;
+ $savefile = $destination.$filename;
+
+ if (file_exists($savefile)) {
+
+ $msg .= $EX.' A file with that name already exists in the target directory.
';
+
+ while (file_exists($savefile)) {
+ $ordinal = sprintf("%03d", ++$ordinal); // 001, 002, 003, etc...
+ $savefile = $destination.$filename.'.'.$ordinal;
+ }
+ $msg .= 'Saving as: "'.htmlentities(basename($savefile)).'"';
+ }
+ return $savefile;
+}//end ordinalize() filename ***************************************************
+
+
+
+
+function Current_Path_Header(){ //**********************************************
+ // Current path. ie: webroot/current/path/
+ // Each level is a link to that level.
+
+ global $ONESCRIPT, $ipath, $WEB_ROOT;
+
+ echo '';
+ //Root folder of web site.
+ echo ' '.htmlentities(trim($WEB_ROOT, '/')).'/';
+ $x=0; //need here for focus() in case at webroot.
+
+ if ($ipath != "" ) { //if not at root, show the rest
+ $path_levels = explode("/",trim($ipath,'/') );
+ $levels = count($path_levels); //If levels=3, indexes = 0, 1, 2 etc...
+ $current_path = "";
+
+ for ($x=0; $x < $levels; $x++) {
+ $current_path .= $path_levels[$x].'/';
+ echo '';
+ echo htmlentities($path_levels[$x]).'/';
+ }
+ }//end if (not at root)
+ echo '
';
+ echo '';
+}//end Current_Path_Header() //*************************************************
+
+
+
+
+function message_box() { //*****************************************************
+ global $ONESCRIPT, $param1, $param2, $param3, $message, $page;
+
+ if (isset($message)) {
+?>
+ '.PHP_EOL;
+}// end show_image() ***********************************************************
+
+
+
+
+function show_favicon(){ //*****************************************************
+ global $config_favicon, $DOC_ROOT;
+ if (file_exists($DOC_ROOT.$config_favicon)) {
+ echo '
';
+ }
+}// end show_favicon() *********************************************************
+
+
+
+
+function Timeout_Timer($COUNT, $ID, $CLASS, $ACTION) { //************************
+
+ return '';
+
+} //end Timeout_Timer() **************************************************
+
+
+
+
+function Init_Macros(){ //*** ($varibale="some reusable chunk of code")*********
+
+global $ONESCRIPT, $param1, $param2, $INPUT_NUONCE, $FORM_COMMON;
+
+
+$INPUT_NUONCE = ''.PHP_EOL;
+$FORM_COMMON = '
Generate a Password Hash
+
+
+
+ 2) Or, use $HASHWORD to store the hash of your password, and set $USE_HASH = 1.
+
+
+
+ The hash will be displayed in a yellow message box above that.
+
+ 'Make sure the hash ends up in quotes.'
+ Make sure to copy ALL of, and ONLY, the hash (no spaces etc). A double-click should select it...
+
+ PS: Everything I know about security - you just read...
+ Log In
+
';}
+ if ( ($attempts >= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
+ $message .= 'Please wait '.Timeout_Timer(($LOGIN_DELAY - $elapsed), 'timer0', '', '').' seconds to try again. ';
+ return;
+ }
+
+ //Validate password
+ if ($USE_HASH) { $VALID_PASSWORD = (hashit($_POST['password']) == $HASHWORD); }
+ else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
+
+ //validate login. Ignore attempt if username & password are blank.
+ if ( ($_POST['password'] == "") && ($_POST['username'] == "") ) { return;
+ }elseif ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
+ session_regenerate_id(true);
+ $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; //for user consistancy check.
+ $_SESSION['valid'] = 1;
+ $page = "index";
+ unlink($LOGIN_ATTEMPTS); //delete invalid attempt count file
+ }else{
+ file_put_contents($LOGIN_ATTEMPTS, ++$attempts); //increment & save attempt
+ $message = $EX.' INVALID LOGIN ATTEMPT #'.$attempts.'
';
+ if ($attempts >= $MAX_ATTEMPTS) {
+ $message .= 'Please wait '.Timeout_Timer($LOGIN_DELAY, 'timer0', '', '').' seconds to try again. ';
+ }
+ }
+}//end Login_response() //******************************************************
+
+
+
+
+function List_Files() { // ...in a vertical table ******************************
+//called from Index Page
+
+ global $ONESCRIPT, $ipath, $param1, $ftypes, $fclasses, $excluded_list;
+
+ $files = scandir('./'.$ipath);
+ natcasesort($files);
+
+ echo '';
+ foreach ($files as $file) {
+
+ $excluded = FALSE;
+ if (in_array(basename($file), $excluded_list)) { $excluded = TRUE; };
+
+ if (!is_dir($ipath.$file) && !$excluded) {
+
+
+
+
+?>
+
+
+';
+}//end List_Files() ************************************************************
+
+
+
+
+function Index_Page(){ //*******************************************************
+ global $ONESCRIPT, $ipath;
+
+ //
+ echo '
+ '; ?>
+ '; ?>
+
+
+ B
+
+
+
+
+
';
+
+ }elseif ( $too_large_to_edit ) {
+ echo ''.$EX.' File contains an invalid character. Edit and view disabled.
';
+ }else{
+ echo '';
+ echo '
';
+ echo ' htmlspecialchars() returned and empty string from what may be an otherwise valid file.
';
+ echo ' This behavior can be inconsistant from version to version of php.
+
+
+
+ ,'?>
+
+
+Some browsers (ie: IE) bog down or become unstable while editing a large file in an HTML <textarea>.
+Adjust $MAX_EDIT_SIZE in the configuration section of OneFileCMS as needed.
+A simple trial and error test can determine a practical limit for a given browser/computer.';
+ $too_large_to_view_message =
+'View disabled. Filesize > '.number_format($MAX_VIEW_SIZE).' bytes.
+Click the the file name above to view normally in a browser window.
+Adjust $MAX_VIEW_SIZE in the configuration section of OneFileCMS as needed.
+(The default value for $MAX_VIEW_SIZE is completely arbitrary, and may be adjusted as desired to suit individual perceptions of neccessity.)';
+
+ echo ''.$header2;
+ echo ''.htmlentities(basename($filename)).'';
+ echo '
'.PHP_EOL;
+?>
+
+
+
+
+
+';
+
+ if ( $text_editable && $too_large_to_edit && !$too_large_to_view ) {
+ $filecontent = htmlspecialchars(file_get_contents($filename), ENT_COMPAT,'UTF-8');
+ echo ''.$filecontent.'
';
+ }elseif ( $text_editable && $too_large_to_view ){
+ echo 'Upload File
+
';
+ $message .= htmlentities($WEB_ROOT.$destination).'
Upload cancelled.';
+ }else{
+ $message .= 'Uploading: "'.htmlentities($filename).'"...';
+ $savefile = ordinalize($destination, $filename, $savefile_msg);
+ if(move_uploaded_file($_FILES['upload_file']['tmp_name'], $savefile)) {
+ $message .= '
Upload successful! '.$savefile_msg;
+ } else{
+ $message .= '
'.$EX.' Upload failed: '.$ERRMSG.'';
+ }
+ }
+}//end Upload_response() *******************************************************
+
+
+
+
+function New_File_Page() { //***************************************************
+ global $FORM_COMMON, $INVALID_CHARS;
+?>
+ New File
+
+
'.
+ ' Name contains invalid character(s): '.
+ ''.htmlentities($INVALID_CHARS).'';
+ }elseif ($new_name == ""){
+ $message .= $EX.' New file not created - no name given';
+ }elseif (file_exists($filename)) {
+ $message .= $EX.' File already exists: ';
+ $message .= htmlentities($new_name).'';
+ }elseif ($handle = fopen($filename, 'w')) {
+ fclose($handle);
+ $message .= 'Created file: '.htmlentities($new_name);
+ $page = "edit";
+ $param2 = '&f='.rawurlencode(basename($filename));// for Edit_Page() buttons
+ $param3 = '&p=edit'; // for Edit_Page() buttons
+ }else{
+ $message .= $EX.' Error - new file not created:
';
+ $message .= htmlentities($new_name);
+ }
+}//end New_File_response() *****************************************************
+
+
+
+
+function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //************
+ //$action = 'Copy' or 'Rename'. $isfile = 1 if acting on a file, not a folder
+ global $WEB_ROOT, $ipath, $filename, $FORM_COMMON;
+ if ($isfile) { $old_name = $filename; }else{ $old_name = $ipath; }
+ if ($isfile) { $new_name = $filename; }else{ $new_name = $ipath; }
+ if ($action == "Copy" ) { $new_name = ordinalize($ipath, basename($filename), $msg); }
+?>
+
+
';
+ $message .= htmlentities($WEB_ROOT.$new_location).'/
';
+ }elseif ( !file_exists($filename) ){
+ $message .= $EX.' '.$msg1.' Error - source file does not exist:
';
+ $message .= htmlentities($filename);
+ }elseif (file_exists($new_name)) {
+ $message .= $EX.' '.$msg1.' Error - target filename already exists:
';
+ $message .= htmlentities($WEB_ROOT.$new_name).'';
+ }elseif ($action($old_name, $new_name)) {
+ $message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
+ $message .= ' --- '.$msg2.' to ---
';
+ $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
+ $filename = $new_name; //so edit page knows what to edit
+ if ($isfile) { $ipath = Check_path(dirname($filename)); } //if changed,
+ else { $ipath = Check_path($filename); } //return to new dir.
+ $param1 = '?i='.URLencode_path($ipath);
+ $param2 = '&f='.rawurlencode(basename($filename));
+ $param3 = '&p=edit';
+ }else{
+ $message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
+ $message .= $EX.' Error during '.$msg1.' from the above to the following:
';
+ $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
+ }
+}//end Copy_Ren_Move_response() ************************************************
+
+
+
+
+function Delete_File_Page() { //************************************************
+ global $filename, $FORM_COMMON;
+?>
+ Delete File
+
+
+
+ New Folder
+
+
'.
+ ' Name contains invalid character(s): '.
+ ''.htmlentities($INVALID_CHARS).'';
+ }elseif ($new_name == ""){
+ $message .= $EX.' New folder not created - no name given.';
+ }elseif (is_dir($new_ipath)) {
+ $message .= $EX.' Folder already exists: ';
+ $message .= htmlentities($new_ipath).'';
+ }elseif (mkdir($new_ipath)) {
+
+ $message .= 'Created folder: '.htmlentities($new_name);
+ $ipath = $new_ipath; //return to new folder
+ $param1 = '?i='.URLencode_path($ipath);
+ }else{
+ $message .= $EX.' Error - new folder not created:
';
+ $message .= htmlentities($new_name);
+ }
+}//end New_Folder_response *****************************************************
+
+
+
+
+function Delete_Folder_Page(){ //***********************************************
+ global $WEB_ROOT, $ipath, $FORM_COMMON;
+?>
+ Delete Folder
+
+
+ /
+
';}
+ $message .= '';
+ $message .= $BR.$EX.' CAUTION '.$EX.' You are editing the active copy of OneFileCMS - BACK IT UP & BE CAREFUL !!';
+ }
+ //**************************************************************************
+}//end if $_SESSION[valid] *****************************************************
+
+
+
+
+//******************************************************************************
+//******************************************************************************
+?>
+
+
+
+
+
';
- }
- }
-
- $_SESSION['last_active_time'] = time();
-
- //If POSTing, verify...
- if ( isset($_POST['nuonce']) ) {
- if ( $_POST['nuonce'] == $_SESSION['nuonce'] ) {
- $VALID_POST = 1;
- }else{
- Logout();
- $message .= $EX.' INVALID POST
';
- }
- }
-}//end Verify_IDLE_POST_etc() //************************************************
-
-
-
-
-function hashit($key){ //*******************************************************
- //This is the super-secret stuff - Keep it secret, keep it safe!
- //If you change anything here, or the $SALT, redo the hash for your password.
- global $SALT;
- $hash = hash('sha256', trim($key).$SALT); // trim off leading & trailing spaces.
- for ( $x=0; $x < 1000; $x++ ) { $hash = hash('sha256', $hash.$SALT); }
- return $hash;
-}//end hashit() ****************************************************************
-
-
-
-
-function undo_magic_quotes(){ //************************************************
-
- function strip_array($var) {
- if (is_array($var)) {return array_map("strip_array", $var); }
- else {return stripslashes($var); }
- } //Note: stripslashes also handles cases when magic_quotes_sybase is on.
-
- if (get_magic_quotes_gpc()) {
- if (isset($_GET)) { $_GET = strip_array($_GET); }
- if (isset($_POST)) { $_POST = strip_array($_POST); }
- if (isset($_COOKIE)) { $_COOKIE = strip_array($_COOKIE); }
- }
-}//end undo_magic_quotes() *****************************************************
-
-
-
-
-function Get_GET() { //*** Get main parameters *********************************
- // i=some/path/, f=somefile.xyz, p=somepage
- global $ipath, $filename, $page, $valid_pages, $param1, $param2, $param3, $message, $EX;
-
- undo_magic_quotes();
-
- if (isset($_GET["i"])) { $ipath = Check_path($_GET["i"]); }else{ $ipath = ""; }
-
- if (isset($_GET["f"])) {
- $filename = $ipath.$_GET["f"];
- if ( !is_file($filename) && $_SESSION['valid'] )//Set $message except for login page.
- { $message .= $EX.' File does not exist: '.htmlentities($filename).'
'; }
- if ( !is_file($filename) ) { $filename = ""; $page = "index"; }
- }else{ $filename = ""; }
-
- if (isset($_GET["p"])) { $page = $_GET["p"]; }
- if (!in_array(strtolower($page), $valid_pages)) { $page = "index"; }
-
- $param1 = '?i='.URLencode_path($ipath);
- if ($filename == "") { $param2 = ""; }else{ $param2 = '&f='.rawurlencode(basename($filename)); }
- if ($page == "" ) { $param3 = ""; }else{ $param3 = '&p='.$page; }
-}//end Get_GET()****************************************************************
-
-
-
-
-function URLencode_path($path){ // don't encode the forward slashes ************
- $TS = ''; // Trailing Slash/
- if (substr($path, -1) == '/' ) { $TS = '/'; } //start with a $TS?
- $path_array = explode('/',$path);
- $path = "";
- foreach ($path_array as $level) { $path .= rawurlencode($level).'/'; }
- $path = rtrim($path,'/').$TS; //end with $TS only if started with one
- return $path;
-}//end URLencode_path($path) ***************************************************
-
-
-
-
-function Check_path($path) { // returns first valid path in some/supplied/path/
- global $message, $EX;
- $invalidpath = $path; //used for message if supplied $path doesn't exist.
- $path = str_replace('\\','/',$path); //Make sure all forward slashes.
- $path = trim($path,"/ ."); // trim slashes, dots, and spaces
-
- //Remove any '.' and '..' parts of the path. Causes issues in www / current / path /
- $pathparts = explode( '/', $path);
- $len = count($pathparts);
- $path = ""; //Cleaned path.
- foreach ($pathparts as $value) { //(More reliable than str_replace(entire_string).)
- if ( !(($value == '.') && (!value == '..')) ) { $path .= $value.'/'; }
- }
-
- $path = trim($path,"/"); // Remove -for now- final trailing slash.
-
- if (strlen($path) < 1) { return ""; } //If at site root
- else {
- if (!is_dir($path) && (strlen($message) < 1))
- { $message .= $EX.' Directory does not exist: '.htmlentities($invalidpath).'
'; }
-
- while ( (strlen($path) > 0) && (!is_dir($path)) ) {
- $path = dirname($path);
- }
-
- $path = $path.'/';
- if ($path == './') { $path = ""; } // ./ means path not found, so clear for root.
- }
-
- return $path;
-}//end Check_path() ************************************************************
-
-
-
-
-function is_empty($path){ //****************************************************
- $empty = false;
- $dh = opendir($path);
- for($i = 3; $i; $i--) { $empty = (readdir($dh) === FALSE); }
- closedir($dh);
- return $empty;
-}//end is_emtpy() //************************************************************
-
-
-
-
-function ordinalize($destination,$filename, &$msg) { //*************************
-//if file_exists(file.txt), ordinalize filename until it doesn't
-//ie: file.txt.001, file.txt.002, file.txt.003 etc...
- global $EX;
-
- $ordinal = 0;
- $savefile = $destination.$filename;
-
- if (file_exists($savefile)) {
-
- $msg .= $EX.' A file with that name already exists in the target directory.
';
-
- while (file_exists($savefile)) {
- $ordinal = sprintf("%03d", ++$ordinal); // 001, 002, 003, etc...
- $savefile = $destination.$filename.'.'.$ordinal;
- }
- $msg .= 'Saving as: "'.htmlentities(basename($savefile)).'"';
- }
- return $savefile;
-}//end ordinalize() filename ***************************************************
-
-
-
-
-function Current_Path_Header(){ //**********************************************
- // Current path. ie: webroot/current/path/
- // Each level is a link to that level.
-
- global $ONESCRIPT, $ipath, $WEB_ROOT;
-
- echo '';
- //Root folder of web site.
- echo ' '.htmlentities(trim($WEB_ROOT, '/')).'/';
- $x=0; //need here for focus() in case at webroot.
-
- if ($ipath != "" ) { //if not at root, show the rest
- $path_levels = explode("/",trim($ipath,'/') );
- $levels = count($path_levels); //If levels=3, indexes = 0, 1, 2 etc...
- $current_path = "";
-
- for ($x=0; $x < $levels; $x++) {
- $current_path .= $path_levels[$x].'/';
- echo '';
- echo htmlentities($path_levels[$x]).'/';
- }
- }//end if (not at root)
- echo '
';
- echo '';
-}//end Current_Path_Header() //*************************************************
-
-
-
-
-function message_box() { //*****************************************************
- global $ONESCRIPT, $param1, $param2, $param3, $message, $page;
-
- if (isset($message)) {
-?>
- '.PHP_EOL;
-}// end show_image() ***********************************************************
-
-
-
-
-function show_favicon(){ //*****************************************************
- global $config_favicon, $DOC_ROOT;
- if (file_exists($DOC_ROOT.$config_favicon)) {
- echo '
';
- }
-}// end show_favicon() *********************************************************
-
-
-
-
-function Timeout_Timer($COUNT, $ID, $CLASS, $ACTION) { //************************
-
- return '';
-
-} //end Timeout_Timer() **************************************************
-
-
-
-
-function Init_Macros(){ //*** ($varibale="some reusable chunk of code")*********
-
-global $ONESCRIPT, $param1, $param2, $INPUT_NUONCE, $FORM_COMMON,
- $SVG_icon_circle_plus, $SVG_icon_circle_x, $SVG_icon_pencil, $SVG_icon_img_0;
-
-$INPUT_NUONCE = ''.PHP_EOL;
-$FORM_COMMON = '
Generate a Password Hash
-
-
-
- 2) Or, use $HASHWORD to store the hash of your password, and set $USE_HASH = 1.
-
-
-
- The hash will be displayed in a yellow message box above that.
-
- 'Make sure the hash ends up in quotes.'
- Make sure to copy ALL of, and ONLY, the hash (no spaces etc). A double-click should select it...
-
- PS: Everything I know about security - you just read...
- Log In
-
';}
- if ( ($attempts >= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
- $message .= 'Please wait '.Timeout_Timer(($LOGIN_DELAY - $elapsed), 'timer0', '', '').' seconds to try again. ';
- return;
- }
-
- //Validate password
- if ($USE_HASH) { $VALID_PASSWORD = (hashit($_POST['password']) == $HASHWORD); }
- else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
-
- //validate login. Ignore attempt if username & password are blank.
- if ( ($_POST['password'] == "") && ($_POST['username'] == "") ) { return;
- }elseif ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
- session_regenerate_id(true);
- $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; //for user consistancy check.
- $_SESSION['valid'] = 1;
- $page = "index";
- unlink($LOGIN_ATTEMPTS); //delete invalid attempt count file
- }else{
- file_put_contents($LOGIN_ATTEMPTS, ++$attempts); //increment & save attempt
- $message = $EX.' INVALID LOGIN ATTEMPT #'.$attempts.'
';
- if ($attempts >= $MAX_ATTEMPTS) {
- $message .= 'Please wait '.Timeout_Timer($LOGIN_DELAY, 'timer0', '', '').' seconds to try again. ';
- }
- }
-}//end Login_response() //******************************************************
-
-
-
-
-function List_Files() { // ...in a vertical table ******************************
-//called from Index Page
-
- global $ONESCRIPT, $ipath, $param1, $ftypes, $fclasses, $excluded_list;
-
- $files = scandir('./'.$ipath);
- natcasesort($files);
-
- echo '';
- foreach ($files as $file) {
-
- $excluded = FALSE;
- if (in_array(basename($file), $excluded_list)) { $excluded = TRUE; };
-
- if (!is_dir($ipath.$file) && !$excluded) {
-
- //Determine file type & set cooresponding icon type.
- $ext = end( explode(".", strtolower($file)) );
- $type = $fclasses[array_search($ext, $ftypes)];
-?>
-
@@ -2385,12 +2385,12 @@ function Edit_Page_Notes() {//**************************************************
$HRS_MIN_SEC = $HRS.':'.$MIN.':'.$SEC;
?>
-
-';
-}//end List_Files() ************************************************************
-
-
-
-
-function Index_Page(){ //*******************************************************
- global $ONESCRIPT, $ipath;
-
- //
- echo '
- '; ?>
- '; ?>
-
-
- B
-
-
-
-
-
';
-
- }elseif ( $too_large_to_edit ) {
- echo ''.$EX.' File contains an invalid character. Edit and view disabled.
';
- }else{
- echo '';
- echo '
';
- echo ' htmlspecialchars() returned and empty string from what may be an otherwise valid file.
';
- echo ' This behavior can be inconsistant from version to version of php.
-
-
-
- ,'?>
-
-
-Some browsers (ie: IE) bog down or become unstable while editing a large file in an HTML <textarea>.
-Adjust $MAX_EDIT_SIZE in the configuration section of OneFileCMS as needed.
-A simple trial and error test can determine a practical limit for a given browser/computer.';
- $too_large_to_view_message =
-'View disabled. Filesize > '.number_format($MAX_VIEW_SIZE).' bytes.
-Click the the file name above to view normally in a browser window.
-Adjust $MAX_VIEW_SIZE in the configuration section of OneFileCMS as needed.
-(The default value for $MAX_VIEW_SIZE is completely arbitrary, and may be adjusted as desired to suit individual perceptions of neccessity.)';
-
- echo ''.$header2;
- echo ''.htmlentities(basename($filename)).'';
- echo '
'.PHP_EOL;
-?>
-
-
-
-
-
-';
-
- if ( $text_editable && $too_large_to_edit && !$too_large_to_view ) {
- $filecontent = htmlspecialchars(file_get_contents($filename), ENT_COMPAT,'UTF-8');
- echo ''.$filecontent.'
';
- }elseif ( $text_editable && $too_large_to_view ){
- echo 'Upload File
-
';
- $message .= htmlentities($WEB_ROOT.$destination).'
Upload cancelled.';
- }else{
- $message .= 'Uploading: "'.htmlentities($filename).'"...';
- $savefile = ordinalize($destination, $filename, $savefile_msg);
- if(move_uploaded_file($_FILES['upload_file']['tmp_name'], $savefile)) {
- $message .= '
Upload successful! '.$savefile_msg;
- } else{
- $message .= '
'.$EX.' Upload failed: '.$ERRMSG.'';
- }
- }
-}//end Upload_response() *******************************************************
-
-
-
-
-function New_File_Page() { //***************************************************
- global $FORM_COMMON, $INVALID_CHARS;
-?>
- New File
-
-
'.
- ' Name contains invalid character(s): '.
- ''.htmlentities($INVALID_CHARS).'';
- }elseif ($new_name == ""){
- $message .= $EX.' New file not created - no name given';
- }elseif (file_exists($filename)) {
- $message .= $EX.' File already exists: ';
- $message .= htmlentities($new_name).'';
- }elseif ($handle = fopen($filename, 'w')) {
- fclose($handle);
- $message .= 'Created file: '.htmlentities($new_name);
- $page = "edit";
- $param2 = '&f='.rawurlencode(basename($filename));// for Edit_Page() buttons
- $param3 = '&p=edit'; // for Edit_Page() buttons
- }else{
- $message .= $EX.' Error - new file not created:
';
- $message .= htmlentities($new_name);
- }
-}//end New_File_response() *****************************************************
-
-
-
-
-function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //************
- //$action = 'Copy' or 'Rename'. $isfile = 1 if acting on a file, not a folder
- global $WEB_ROOT, $ipath, $filename, $FORM_COMMON;
- if ($isfile) { $old_name = $filename; }else{ $old_name = $ipath; }
- if ($isfile) { $new_name = $filename; }else{ $new_name = $ipath; }
- if ($action == "Copy" ) { $new_name = ordinalize($ipath, basename($filename), $msg); }
-?>
-
-
';
- $message .= htmlentities($WEB_ROOT.$new_location).'/
';
- }elseif ( !file_exists($filename) ){
- $message .= $EX.' '.$msg1.' Error - source file does not exist:
';
- $message .= htmlentities($filename);
- }elseif (file_exists($new_name)) {
- $message .= $EX.' '.$msg1.' Error - target filename already exists:
';
- $message .= htmlentities($WEB_ROOT.$new_name).'';
- }elseif ($action($old_name, $new_name)) {
- $message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
- $message .= ' --- '.$msg2.' to ---
';
- $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
- $filename = $new_name; //so edit page knows what to edit
- if ($isfile) { $ipath = Check_path(dirname($filename)); } //if changed,
- else { $ipath = Check_path($filename); } //return to new dir.
- $param1 = '?i='.URLencode_path($ipath);
- $param2 = '&f='.rawurlencode(basename($filename));
- $param3 = '&p=edit';
- }else{
- $message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
- $message .= $EX.' Error during '.$msg1.' from the above to the following:
';
- $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
- }
-}//end Copy_Ren_Move_response() ************************************************
-
-
-
-
-function Delete_File_Page() { //************************************************
- global $filename, $FORM_COMMON;
-?>
- Delete File
-
-
-
- New Folder
-
-
'.
- ' Name contains invalid character(s): '.
- ''.htmlentities($INVALID_CHARS).'';
- }elseif ($new_name == ""){
- $message .= $EX.' New folder not created - no name given.';
- }elseif (is_dir($new_ipath)) {
- $message .= $EX.' Folder already exists: ';
- $message .= htmlentities($new_ipath).'';
- }elseif (mkdir($new_ipath)) {
-
- $message .= 'Created folder: '.htmlentities($new_name);
- $ipath = $new_ipath; //return to new folder
- $param1 = '?i='.URLencode_path($ipath);
- }else{
- $message .= $EX.' Error - new folder not created:
';
- $message .= htmlentities($new_name);
- }
-}//end New_Folder_response *****************************************************
-
-
-
-
-function Delete_Folder_Page(){ //***********************************************
- global $WEB_ROOT, $ipath, $FORM_COMMON;
-?>
- Delete Folder
-
-
- /
-
';}
- $message .= '';
- $message .= $BR.$EX.' CAUTION '.$EX.' You are editing the active copy of OneFileCMS - BACK IT UP & BE CAREFUL !!';
- }
- //**************************************************************************
-}//end if $_SESSION[valid] *****************************************************
-
-
-
-
-//******************************************************************************
-//******************************************************************************
-?>
-
-
-
-
-
';
+ }
+ }
+
+ $_SESSION['last_active_time'] = time();
+
+ //If POSTing, verify...
+ if ( isset($_POST['nuonce']) ) {
+ if ( $_POST['nuonce'] == $_SESSION['nuonce'] ) {
+ $VALID_POST = 1;
+ }else{
+ Logout();
+ $message .= $EX.' INVALID POST
';
+ }
+ }
+}//end Verify_IDLE_POST_etc() //************************************************
+
+
+
+
+function hashit($key){ //*******************************************************
+ //This is the super-secret stuff - Keep it secret, keep it safe!
+ //If you change anything here, or the $SALT, redo the hash for your password.
+ global $SALT;
+ $hash = hash('sha256', trim($key).$SALT); // trim off leading & trailing spaces.
+ for ( $x=0; $x < 1000; $x++ ) { $hash = hash('sha256', $hash.$SALT); }
+ return $hash;
+}//end hashit() ****************************************************************
+
+
+
+
+function undo_magic_quotes(){ //************************************************
+
+ function strip_array($var) {
+ if (is_array($var)) {return array_map("strip_array", $var); }
+ else {return stripslashes($var); }
+ } //Note: stripslashes also handles cases when magic_quotes_sybase is on.
+
+ if (get_magic_quotes_gpc()) {
+ if (isset($_GET)) { $_GET = strip_array($_GET); }
+ if (isset($_POST)) { $_POST = strip_array($_POST); }
+ if (isset($_COOKIE)) { $_COOKIE = strip_array($_COOKIE); }
+ }
+}//end undo_magic_quotes() *****************************************************
+
+
+
+
+function Get_GET() { //*** Get main parameters *********************************
+ // i=some/path/, f=somefile.xyz, p=somepage
+ global $ipath, $filename, $page, $valid_pages, $param1, $param2, $param3, $message, $EX;
+
+ undo_magic_quotes();
+
+ if (isset($_GET["i"])) { $ipath = Check_path($_GET["i"]); }else{ $ipath = ""; }
+
+ if (isset($_GET["f"])) {
+ $filename = $ipath.$_GET["f"];
+ if ( !is_file($filename) ) { $filename = ""; $page = "index"; }
+ if ( !is_file($filename) && $_SESSION['valid'] )//Set $message except for login page.
+ { $message .= $EX.' File does not exist: '.htmlentities($filename).'
'; }
+ }else{ $filename = ""; }
+
+ if (isset($_GET["p"])) { $page = $_GET["p"]; }
+ if (!in_array(strtolower($page), $valid_pages)) { $page = "index"; }
+
+ $param1 = '?i='.URLencode_path($ipath);
+ if ($filename == "") { $param2 = ""; }else{ $param2 = '&f='.rawurlencode(basename($filename)); }
+ if ($page == "" ) { $param3 = ""; }else{ $param3 = '&p='.$page; }
+}//end Get_GET()****************************************************************
+
+
+
+
+function URLencode_path($path){ // don't encode the forward slashes ************
+ $TS = ''; // Trailing Slash/
+ if (substr($path, -1) == '/' ) { $TS = '/'; } //start with a $TS?
+ $path_array = explode('/',$path);
+ $path = "";
+ foreach ($path_array as $level) { $path .= rawurlencode($level).'/'; }
+ $path = rtrim($path,'/').$TS; //end with $TS only if started with one
+ return $path;
+}//end URLencode_path($path) ***************************************************
+
+
+
+
+function Check_path($path) { // returns first valid path in some/supplied/path/
+ global $message, $EX;
+ $invalidpath = $path; //used for message if supplied $path doesn't exist.
+ $path = str_replace('\\','/',$path); //Make sure all forward slashes.
+ $path = trim($path,"/ ."); // trim slashes, dots, and spaces
+
+ //Remove any '.' and '..' parts of the path. Causes issues in www / current / path /
+ $pathparts = explode( '/', $path);
+ $len = count($pathparts);
+ $path = ""; //Cleaned path.
+ foreach ($pathparts as $value) { //(More reliable than str_replace(entire_string).)
+ if ( !(($value == '.') && (!value == '..')) ) { $path .= $value.'/'; }
+ }
+
+ $path = trim($path,"/"); // Remove -for now- final trailing slash.
+
+ if (strlen($path) < 1) { return ""; } //If at site root
+ else {
+ if (!is_dir($path) && (strlen($message) < 1))
+ { $message .= $EX.' Directory does not exist: '.htmlentities($invalidpath).'
'; }
+
+ while ( (strlen($path) > 0) && (!is_dir($path)) ) {
+ $path = dirname($path);
+ }
+
+ $path = $path.'/';
+ if ($path == './') { $path = ""; } // ./ means path not found, so clear for root.
+ }
+
+ return $path;
+}//end Check_path() ************************************************************
+
+
+
+
+function is_empty($path){ //****************************************************
+ $empty = false;
+ $dh = opendir($path);
+ for($i = 3; $i; $i--) { $empty = (readdir($dh) === FALSE); }
+ closedir($dh);
+ return $empty;
+}//end is_empty() //************************************************************
+
+
+
+
+function ordinalize($destination,$filename, &$msg) { //*************************
+//if file_exists(file.txt), ordinalize filename until it doesn't
+//ie: file.txt.001, file.txt.002, file.txt.003 etc...
+ global $EX;
+
+ $ordinal = 0;
+ $savefile = $destination.$filename;
+
+ if (file_exists($savefile)) {
+
+ $msg .= $EX.' A file with that name already exists in the target directory.
';
+
+ while (file_exists($savefile)) {
+ $ordinal = sprintf("%03d", ++$ordinal); // 001, 002, 003, etc...
+ $savefile = $destination.$filename.'.'.$ordinal;
+ }
+ $msg .= 'Saving as: "'.htmlentities(basename($savefile)).'"';
+ }
+ return $savefile;
+}//end ordinalize() filename ***************************************************
+
+
+
+
+function Current_Path_Header(){ //**********************************************
+ // Current path. ie: webroot/current/path/
+ // Each level is a link to that level.
+
+ global $ONESCRIPT, $ipath, $WEB_ROOT;
+
+ echo '';
+ //Root folder of web site.
+ echo ' '.htmlentities(trim($WEB_ROOT, '/')).'/';
+ $x=0; //need here for focus() in case at webroot.
+
+ if ($ipath != "" ) { //if not at root, show the rest
+ $path_levels = explode("/",trim($ipath,'/') );
+ $levels = count($path_levels); //If levels=3, indexes = 0, 1, 2 etc...
+ $current_path = "";
+
+ for ($x=0; $x < $levels; $x++) {
+ $current_path .= $path_levels[$x].'/';
+ echo '';
+ echo htmlentities($path_levels[$x]).'/';
+ }
+ }//end if (not at root)
+ echo '
';
+ echo '';
+}//end Current_Path_Header() //*************************************************
+
+
+
+
+function message_box() { //*****************************************************
+ global $ONESCRIPT, $param1, $param2, $param3, $message, $page;
+
+ if (isset($message)) {
+?>
+ '.PHP_EOL;
+}// end show_image() ***********************************************************
+
+
+
+
+function show_favicon(){ //*****************************************************
+ global $config_favicon, $DOC_ROOT;
+ if (file_exists($DOC_ROOT.$config_favicon)) {
+ echo '
';
+ }
+}// end show_favicon() *********************************************************
+
+
+
+
+function Timeout_Timer($COUNT, $ID, $CLASS, $ACTION) { //************************
+
+ return '';
+
+} //end Timeout_Timer() **************************************************
+
+
+
+
+function Init_Macros(){ //*** ($varibale="some reusable chunk of code")*********
+
+global $ONESCRIPT, $param1, $param2, $INPUT_NUONCE, $FORM_COMMON,
+ $SVG_icon_circle_plus, $SVG_icon_circle_x, $SVG_icon_pencil, $SVG_icon_img_0;
+
+$INPUT_NUONCE = ''.PHP_EOL;
+$FORM_COMMON = '
Generate a Password Hash
+
+
+
+ 2) Or, use $HASHWORD to store the hash of your password, and set $USE_HASH = 1.
+
+
+
+ The hash will be displayed in a yellow message box above that.
+
+ 'Make sure the hash ends up in quotes.'
+ Make sure to copy ALL of, and ONLY, the hash (no spaces etc). A double-click should select it...
+
+ PS: Everything I know about security - you just read...
+ Log In
+
';}
+ if ( ($attempts >= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
+ $message .= 'Please wait '.Timeout_Timer(($LOGIN_DELAY - $elapsed), 'timer0', '', '').' seconds to try again. ';
+ return;
+ }
+
+ //Validate password
+ if ($USE_HASH) { $VALID_PASSWORD = (hashit($_POST['password']) == $HASHWORD); }
+ else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
+
+ //validate login. Ignore attempt if username & password are blank.
+ if ( ($_POST['password'] == "") && ($_POST['username'] == "") ) { return;
+ }elseif ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
+ session_regenerate_id(true);
+ $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; //for user consistancy check.
+ $_SESSION['valid'] = 1;
+ $page = "index";
+ unlink($LOGIN_ATTEMPTS); //delete invalid attempt count file
+ }else{
+ file_put_contents($LOGIN_ATTEMPTS, ++$attempts); //increment & save attempt
+ $message = $EX.' INVALID LOGIN ATTEMPT #'.$attempts.'
';
+ if ($attempts >= $MAX_ATTEMPTS) {
+ $message .= 'Please wait '.Timeout_Timer($LOGIN_DELAY, 'timer0', '', '').' seconds to try again. ';
+ }
+ }
+}//end Login_response() //******************************************************
+
+
+
+
+function List_Files() { // ...in a vertical table ******************************
+//called from Index Page
+
+ global $ONESCRIPT, $ipath, $param1, $ftypes, $fclasses, $excluded_list, $stypes, $SHOWALLFILES;
+
+ $files = scandir('./'.$ipath);
+ natcasesort($files);
+
+ echo '';
+ foreach ($files as $file) {
+
+ $excluded = FALSE;
+ if (in_array(basename($file), $excluded_list)) { $excluded = TRUE; };
+
+ //Get file type & check against $stypes (files types to show)
+ $ext = end( explode(".", strtolower($file)) );
+ if ($SHOWALLFILES || in_array($ext, $stypes)) { $SHOWTYPE = TRUE; } else { $SHOWTYPE = FALSE; }
+
+ if ( $SHOWTYPE && !is_dir($ipath.$file) && !$excluded ) {
+
+ //Set icon type based on file type ($ext).
+ $type = $fclasses[array_search($ext, $ftypes)];
+?>
+
".readlink($filename_OS);
+ }
+ else {
+ $link_target = "";
+ }
+
//Store data
- $DIRECTORY_DATA[$DIRECTORY_COUNT] = array('', '', 0, 0, 0, '', '', '', '');
- $DIRECTORY_DATA[$DIRECTORY_COUNT][0] = $type; //used to determine icon & f_or_f
- $DIRECTORY_DATA[$DIRECTORY_COUNT][1] = $filename;
- $DIRECTORY_DATA[$DIRECTORY_COUNT][2] = $file_size_raw;
- $DIRECTORY_DATA[$DIRECTORY_COUNT][3] = $file_time_raw;
- $DIRECTORY_DATA[$DIRECTORY_COUNT][4] = $is_ofcms; //If = 1, Don't show ren, del, ckbox.
- $DIRECTORY_DATA[$DIRECTORY_COUNT][5] = $ext; //##### Is this used?
- $DIRECTORY_DATA[$DIRECTORY_COUNT][6] = decoct(fileperms($filename_OS) & 07777);
- $DIRECTORY_DATA[$DIRECTORY_COUNT][7] = $fileowner_name;
- $DIRECTORY_DATA[$DIRECTORY_COUNT][8] = $filegroup_name;
-
- $DIRECTORY_COUNT++;
+ $DIRECTORY_DATA[$file_count] = array('', '', 0, 0, 0, '', '', '', '', '');
+ $DIRECTORY_DATA[$file_count][0] = $type; //used to determine icon & f_or_f
+ $DIRECTORY_DATA[$file_count][1] = $filename;
+ $DIRECTORY_DATA[$file_count][2] = $file_size;
+ $DIRECTORY_DATA[$file_count][3] = $file_mtime;
+ $DIRECTORY_DATA[$file_count][4] = Set_IS_OFCMS($ipath.$filename); //If = 1, Don't show ren, del, ckbox.
+ $DIRECTORY_DATA[$file_count][5] = $ext; //##### Is this used?
+ $DIRECTORY_DATA[$file_count][6] = $file_perms;
+ $DIRECTORY_DATA[$file_count][7] = $fileowner_name;
+ $DIRECTORY_DATA[$file_count][8] = $filegroup_name;
+ $DIRECTORY_DATA[$file_count][9] = $link_target;
+
+ $file_count++;
}//end foreach file
- return $DIRECTORY_COUNT;
+ return $file_count;
}//end Get_DIRECTORY_DATA() //**************************************************
@@ -2148,26 +2171,26 @@ function Index_Page() {//*******************************************************
global $ONESCRIPT, $ipath_OS, $param1, $INPUT_NUONCE, $DIRECTORY_DATA, $DIRECTORY_COUNT;
$raw_list = scandir('./'.$ipath_OS); //Get current directory list (unsorted)
- $file_count = Get_DIRECTORY_DATA($raw_list);
+ $DIRECTORY_COUNT = Get_DIRECTORY_DATA($raw_list);
//
+
+';
+}//end List_Files() ************************************************************
+
+
+
+
+function Index_Page(){ //*******************************************************
+ global $ONESCRIPT, $ipath;
+
+ //
+ echo '
+ '; ?>
+ '; ?>
+
+
+ B
+
+
+
+
+
';
+
+ }elseif ( $too_large_to_edit ) {
+ echo ''.$EX.' File contains an invalid character. Edit and view disabled.
';
+ }else{
+ echo '';
+ echo '
';
+ echo ' htmlspecialchars() returned and empty string from what may be an otherwise valid file.
';
+ echo ' This behavior can be inconsistant from version to version of php.
+
+
+
+ ,'?>
+
+
+Some browsers (ie: IE) bog down or become unstable while editing a large file in an HTML <textarea>.
+Adjust $MAX_EDIT_SIZE in the configuration section of OneFileCMS as needed.
+A simple trial and error test can determine a practical limit for a given browser/computer.';
+ $too_large_to_view_message =
+'View disabled. Filesize > '.number_format($MAX_VIEW_SIZE).' bytes.
+Click the the file name above to view normally in a browser window.
+Adjust $MAX_VIEW_SIZE in the configuration section of OneFileCMS as needed.
+(The default value for $MAX_VIEW_SIZE is completely arbitrary, and may be adjusted as desired to suit individual perceptions of neccessity.)';
+
+ echo ''.$header2;
+ echo ''.htmlentities(basename($filename)).'';
+ echo '
'.PHP_EOL;
+?>
+
+
+
+
+
+';
+
+ if ( $text_editable && $too_large_to_edit && !$too_large_to_view ) {
+ $filecontent = htmlspecialchars(file_get_contents($filename), ENT_COMPAT,'UTF-8');
+ echo ''.$filecontent.'
';
+ }elseif ( $text_editable && $too_large_to_view ){
+ echo 'Upload File
+
';
+ $message .= htmlentities($WEB_ROOT.$destination).'
Upload cancelled.';
+ }else{
+ $message .= 'Uploading: "'.htmlentities($filename).'"...';
+ $savefile = ordinalize($destination, $filename, $savefile_msg);
+ if(move_uploaded_file($_FILES['upload_file']['tmp_name'], $savefile)) {
+ $message .= '
Upload successful! '.$savefile_msg;
+ } else{
+ $message .= '
'.$EX.' Upload failed: '.$ERRMSG.'';
+ }
+ }
+}//end Upload_response() *******************************************************
+
+
+
+
+function New_File_Page() { //***************************************************
+ global $FORM_COMMON, $INVALID_CHARS;
+?>
+ New File
+
+
'.
+ ' Name contains invalid character(s): '.
+ ''.htmlentities($INVALID_CHARS).'';
+ }elseif ($new_name == ""){
+ $message .= $EX.' New file not created - no name given';
+ }elseif (file_exists($filename)) {
+ $message .= $EX.' File already exists: ';
+ $message .= htmlentities($new_name).'';
+ }elseif ($handle = fopen($filename, 'w')) {
+ fclose($handle);
+ $message .= 'Created file: '.htmlentities($new_name);
+ $page = "edit";
+ $param2 = '&f='.rawurlencode(basename($filename));// for Edit_Page() buttons
+ $param3 = '&p=edit'; // for Edit_Page() buttons
+ }else{
+ $message .= $EX.' Error - new file not created:
';
+ $message .= htmlentities($new_name);
+ }
+}//end New_File_response() *****************************************************
+
+
+
+
+function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //************
+ //$action = 'Copy' or 'Rename'. $isfile = 1 if acting on a file, not a folder
+ global $WEB_ROOT, $ipath, $filename, $FORM_COMMON;
+ if ($isfile) { $old_name = $filename; }else{ $old_name = $ipath; }
+ if ($isfile) { $new_name = $filename; }else{ $new_name = $ipath; }
+ if ($action == "Copy" ) { $new_name = ordinalize($ipath, basename($filename), $msg); }
+?>
+
+
';
+ $message .= htmlentities($WEB_ROOT.$new_location).'/
';
+ }elseif ( !file_exists($filename) ){
+ $message .= $EX.' '.$msg1.' Error - source file does not exist:
';
+ $message .= htmlentities($filename);
+ }elseif (file_exists($new_name)) {
+ $message .= $EX.' '.$msg1.' Error - target filename already exists:
';
+ $message .= htmlentities($WEB_ROOT.$new_name).'';
+ }elseif ($action($old_name, $new_name)) {
+ $message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
+ $message .= ' --- '.$msg2.' to ---
';
+ $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
+ $filename = $new_name; //so edit page knows what to edit
+ if ($isfile) { $ipath = Check_path(dirname($filename)); } //if changed,
+ else { $ipath = Check_path($filename); } //return to new dir.
+ $param1 = '?i='.URLencode_path($ipath);
+ $param2 = '&f='.rawurlencode(basename($filename));
+ $param3 = '&p=edit';
+ }else{
+ $message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
+ $message .= $EX.' Error during '.$msg1.' from the above to the following:
';
+ $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
+ }
+}//end Copy_Ren_Move_response() ************************************************
+
+
+
+
+function Delete_File_Page() { //************************************************
+ global $filename, $FORM_COMMON;
+?>
+ Delete File
+
+
+
+ New Folder
+
+
'.
+ ' Name contains invalid character(s): '.
+ ''.htmlentities($INVALID_CHARS).'';
+ }elseif ($new_name == ""){
+ $message .= $EX.' New folder not created - no name given.';
+ }elseif (is_dir($new_ipath)) {
+ $message .= $EX.' Folder already exists: ';
+ $message .= htmlentities($new_ipath).'';
+ }elseif (mkdir($new_ipath)) {
+ $message .= 'Created folder: '.htmlentities($new_name);
+ $ipath = $new_ipath; //return to new folder
+ $param1 = '?i='.URLencode_path($ipath);
+ }else{
+ $message .= $EX.' Error - new folder not created:
';
+ $message .= htmlentities($new_name);
+ }
+}//end New_Folder_response *****************************************************
+
+
+
+
+function Delete_Folder_Page(){ //***********************************************
+ global $WEB_ROOT, $ipath, $FORM_COMMON;
+?>
+ Delete Folder
+
+
+ /
+
';}
+ $message .= '';
+ $message .= $BR.$EX.' CAUTION '.$EX.' You are editing the active copy of OneFileCMS - BACK IT UP & BE CAREFUL !!';
+ }
+ //**************************************************************************
+}//end if $_SESSION[valid] *****************************************************
+
+
+
+
+//******************************************************************************
+//******************************************************************************
+?>
+
+
+
+
+'.PHP_EOL;
}// end show_image() ***********************************************************
@@ -699,20 +699,20 @@ function Hash_Page() { //******************************************************
The hash will be displayed in a yellow message box above that.
- 'Make sure the hash ends up in quotes.'
- Make sure to copy ALL of, and ONLY, the hash (no spaces etc). A double-click should select it...
+ Make sure to copy ALL of, and ONLY, the hash (no leading or trailing spaces etc).
+ A double-click should select it...
+ For another small improvement to security, change the default salt and/or method used by OneFileCMS to hash the password (and keep 'em secret, of course). Remever, every little bit helps...
PS: Everything I know about security - you just read...
0) { $message .= 'There have been '.$attempts.' invalid login attempts.
';}
if ( ($attempts >= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
@@ -791,13 +794,13 @@ function Login_response() { //**************************************************
else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
//validate login. Ignore attempt if username & password are blank.
- if ( ($_POST['password'] == "") && ($_POST['username'] == "") ) { return;
+ if ( ($_POST['password'] == "") && ($_POST['username'] == "") ) { ; //
}elseif ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
session_regenerate_id(true);
$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; //for user consistancy check.
$_SESSION['valid'] = 1;
$page = "index";
- unlink($LOGIN_ATTEMPTS); //delete invalid attempt count file
+ if ( is_file($LOGIN_ATTEMPTS) ) { unlink($LOGIN_ATTEMPTS); } //delete invalid attempt count file
}else{
file_put_contents($LOGIN_ATTEMPTS, ++$attempts); //increment & save attempt
$message = $EX.' INVALID LOGIN ATTEMPT #'.$attempts.'
';
@@ -884,9 +887,9 @@ function Edit_Page_Buttons($text_editable, $too_large_to_edit) { //*************
$Button = '
+
';
}elseif ( $too_large_to_edit ) {
@@ -930,13 +960,13 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_
}
$bad_chars = ($filecontent == "" && filesize($filename) > 0);
- if ($bad_chars){ //did specialchars return an empty string?
+ if ($bad_chars){ //did htmlspecialchars return an empty string?
echo ''.$EX.' File contains an invalid character. Edit and view disabled.
';
}else{
echo '';
- echo '
';
echo ' htmlspecialchars() returned and empty string from what may be an otherwise valid file.
';
echo ' This behavior can be inconsistant from version to version of php.
-
-
-
- ,'?>
-
-
@@ -993,36 +1005,44 @@ function Edit_Page() { //*******************************************************
A simple trial and error test can determine a practical limit for a given browser/computer.';
$too_large_to_view_message =
'View disabled. Filesize > '.number_format($MAX_VIEW_SIZE).' bytes.
-Click the the file name above to view normally in a browser window.
+Click the the file name above to view as normally rendered in a browser window.
Adjust $MAX_VIEW_SIZE in the configuration section of OneFileCMS as needed.
-(The default value for $MAX_VIEW_SIZE is completely arbitrary, and may be adjusted as desired to suit individual perceptions of neccessity.)';
+(The default value is completely arbitrary, and may be adjusted as desired to suit individual perceptions of reality.)';
echo ''.$header2;
echo ''.htmlentities(basename($filename)).'';
echo '
'.PHP_EOL;
?>
-
-
-
-
-
+ '.$filecontent.'
';
- }elseif ( $text_editable && $too_large_to_view ){
- echo '
';
+ }
+ }
+
+ $_SESSION['last_active_time'] = time();
+
+ //If POSTing, verify...
+ if ( isset($_POST['nuonce']) ) {
+ if ( $_POST['nuonce'] == $_SESSION['nuonce'] ) {
+ $VALID_POST = 1;
+ }else{
+ Logout();
+ $message .= $EX.''.$_['verify_msg_02'].'
';
+ }
+ }
+}//end Verify_IDLE_POST_etc() //************************************************
+
+
+
+
+function hashit($key){ //*******************************************************
+ //This is the super-secret stuff - Keep it secret, keep it safe!
+ //If you change anything here, or the $SALT, redo the hash for your password.
+ global $SALT;
+ $hash = hash('sha256', trim($key).$SALT); // trim off leading & trailing spaces.
+ for ( $x=0; $x < 1000; $x++ ) { $hash = hash('sha256', $hash.$SALT); }
+ return $hash;
+}//end hashit() ****************************************************************
+
+
+
+
+function undo_magic_quotes(){ //************************************************
+
+ function strip_array($var) {
+ if (is_array($var)) {return array_map("strip_array", $var); }
+ else {return stripslashes($var); }
+ } //Note: stripslashes also handles cases when magic_quotes_sybase is on.
+
+ if (get_magic_quotes_gpc()) {
+ if (isset($_GET)) { $_GET = strip_array($_GET); }
+ if (isset($_POST)) { $_POST = strip_array($_POST); }
+ if (isset($_COOKIE)) { $_COOKIE = strip_array($_COOKIE); }
+ }
+}//end undo_magic_quotes() *****************************************************
+
+
+
+
+function Get_GET() { //*** Get main parameters *********************************
+ // i=some/path/, f=somefile.xyz, p=somepage
+ global $_, $ipath, $filename, $page, $valid_pages, $param1, $param2, $param3, $message, $EX;
+
+ undo_magic_quotes();
+
+ if (isset($_GET["i"])) { $ipath = Check_path($_GET["i"]); }else{ $ipath = ""; }
+
+ if (isset($_GET["f"])) {
+ $filename = $ipath.$_GET["f"];
+ if ( !is_file($filename) && $_SESSION['valid'] )//Set $message except for login page.
+ { $message .= $EX.''.$_['get_get_msg_01'].' '.htmlentities($filename).'
'; }
+ if ( !is_file($filename) ) { $filename = ""; $page = "index"; }
+ }else{ $filename = ""; }
+
+ if (isset($_GET["p"])) { $page = $_GET["p"]; }
+ if (!in_array(strtolower($page), $valid_pages)) { $page = "index"; }
+
+ $param1 = '?i='.URLencode_path($ipath);
+ if ($filename == "") { $param2 = ""; }else{ $param2 = '&f='.rawurlencode(basename($filename)); }
+ if ($page == "" ) { $param3 = ""; }else{ $param3 = '&p='.$page; }
+}//end Get_GET()****************************************************************
+
+
+
+
+function URLencode_path($path){ // don't encode the forward slashes ************
+ $TS = ''; // Trailing Slash/
+ if (substr($path, -1) == '/' ) { $TS = '/'; } //start with a $TS?
+ $path_array = explode('/',$path);
+ $path = "";
+ foreach ($path_array as $level) { $path .= rawurlencode($level).'/'; }
+ $path = rtrim($path,'/').$TS; //end with $TS only if started with one
+ return $path;
+}//end URLencode_path($path) ***************************************************
+
+
+
+
+function Check_path($path) { // returns first valid path in some/supplied/path/
+ global $_, $message, $EX;
+ $invalidpath = $path; //used for message if supplied $path doesn't exist.
+ $path = str_replace('\\','/',$path); //Make sure all forward slashes.
+ $path = trim($path,"/ ."); // trim slashes, dots, and spaces
+
+ //Remove any '.' and '..' parts of the path. Causes issues in www / current / path /
+ $pathparts = explode( '/', $path);
+ $len = count($pathparts);
+ $path = ""; //Cleaned path.
+ foreach ($pathparts as $value) { //(More reliable than str_replace(entire_string).)
+ if ( !(($value == '.') && (!value == '..')) ) { $path .= $value.'/'; }
+ }
+
+ $path = trim($path,"/"); // Remove -for now- final trailing slash.
+
+ if (strlen($path) < 1) { return ""; } //If at site root
+ else {
+ if (!is_dir($path) && (strlen($message) < 1))
+ { $message .= $EX.''.$_['check_path_msg_01'].''.htmlentities($invalidpath).'
'; }
+
+ while ( (strlen($path) > 0) && (!is_dir($path)) ) {
+ $path = dirname($path);
+ }
+
+ $path = $path.'/';
+ if ($path == './') { $path = ""; } // ./ means path not found, so clear for root.
+ }
+
+ return $path;
+}//end Check_path() ************************************************************
+
+
+
+
+function is_empty($path){ //****************************************************
+ $empty = false;
+ $dh = opendir($path);
+ for($i = 3; $i; $i--) { $empty = (readdir($dh) === FALSE); }
+ closedir($dh);
+ return $empty;
+}//end is_empty() //************************************************************
+
+
+
+
+function ordinalize($destination,$filename, &$msg) { //*************************
+//if file_exists(file.txt), ordinalize filename until it doesn't
+//ie: file.txt.001, file.txt.002, file.txt.003 etc...
+ global $_, $EX;
+
+ $ordinal = 0;
+ $savefile = $destination.$filename;
+
+ if (file_exists($savefile)) {
+
+ $msg .= $EX.$_['ord_msg_01'].'
';
+
+ while (file_exists($savefile)) {
+ $ordinal = sprintf("%03d", ++$ordinal); // 001, 002, 003, etc...
+ $savefile = $destination.$filename.'.'.$ordinal;
+ }
+ $msg .= $_['ord_msg_02'].'"'.htmlentities(basename($savefile)).'"';
+ }
+ return $savefile;
+}//end ordinalize() filename ***************************************************
+
+
+
+
+function Current_Path_Header(){ //**********************************************
+ // Current path. ie: webroot/current/path/
+ // Each level is a link to that level.
+
+ global $ONESCRIPT, $ipath, $WEB_ROOT;
+
+ echo '';
+ //Root folder of web site.
+ echo ' '.htmlentities(trim($WEB_ROOT, '/')).'/';
+ $x=0; //need here for focus() in case at webroot.
+
+ if ($ipath != "" ) { //if not at root, show the rest
+ $path_levels = explode("/",trim($ipath,'/') );
+ $levels = count($path_levels); //If levels=3, indexes = 0, 1, 2 etc...
+ $current_path = "";
+
+ for ($x=0; $x < $levels; $x++) {
+ $current_path .= $path_levels[$x].'/';
+ echo '';
+ echo htmlentities($path_levels[$x]).'/';
+ }
+ }//end if (not at root)
+ echo '
';
+ echo '';
+}//end Current_Path_Header() //*************************************************
+
+
+
+
+function message_box() { //*****************************************************
+ global $ONESCRIPT, $param1, $param2, $param3, $message, $page;
+
+ if (isset($message)) {
+?>
+ '.PHP_EOL;
+}// end show_image() ***********************************************************
+
+
+
+
+function show_favicon(){ //*****************************************************
+ global $config_favicon, $DOC_ROOT;
+ if (file_exists($DOC_ROOT.$config_favicon)) {
+ echo '
';
+ }
+}// end show_favicon() *********************************************************
+
+
+
+
+function Timeout_Timer($COUNT, $ID, $CLASS, $ACTION) { //************************
+
+ return '';
+
+} //end Timeout_Timer() **************************************************
+
+
+
+
+function Init_Macros(){ //*** ($varibale="some reusable chunk of code")*********
+
+global $ONESCRIPT, $param1, $param2, $INPUT_NUONCE, $FORM_COMMON,
+ $SVG_icon_circle_plus, $SVG_icon_circle_x, $SVG_icon_pencil, $SVG_icon_img_0;
+
+$INPUT_NUONCE = ''.PHP_EOL;
+$FORM_COMMON = '
+
+
+
+
+
+
+
+
+
+
';}
+ if ( ($attempts >= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
+ $message .= $_['login_msg_02a'].' '.Timeout_Timer(($LOGIN_DELAY - $elapsed), 'timer0', '', '').' '.$_['login_msg_02b'];
+ return;
+ }
+
+ //Validate password
+ if ($USE_HASH) { $VALID_PASSWORD = (hashit($_POST['password']) == $HASHWORD); }
+ else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
+
+ //validate login. Ignore attempt if username & password are blank.
+ if ( ($_POST['password'] == "") && ($_POST['username'] == "") ) { ; //
+ }elseif ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
+ session_regenerate_id(true);
+ $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; //for user consistancy check.
+ $_SESSION['valid'] = 1;
+ $page = "index";
+ if ( is_file($LOGIN_ATTEMPTS) ) { unlink($LOGIN_ATTEMPTS); } //delete invalid attempts count file
+ }else{
+ file_put_contents($LOGIN_ATTEMPTS, ++$attempts); //increment & save attempt
+ $message = $EX.''.$_['login_msg_03'].$attempts.'
';
+ if ($attempts >= $MAX_ATTEMPTS) {
+ $message .= $_['login_msg_02a'].' '.Timeout_Timer($LOGIN_DELAY, 'timer0', '', '').' '.$_['login_msg_02b'];
+ }
+ }
+}//end Login_response() //******************************************************
+
+
+
+
+function List_Files() { // ...in a vertical table ******************************
+//called from Index Page
+
+ global $ONESCRIPT, $ipath, $param1, $ftypes, $fclasses, $excluded_list, $stypes, $SHOWALLFILES;
+
+ $files = scandir('./'.$ipath);
+ natcasesort($files);
+
+ echo '';
+ foreach ($files as $file) {
+
+ $excluded = FALSE;
+ if (in_array(basename($file), $excluded_list)) { $excluded = TRUE; };
+
+ //Get file type & check against $stypes (files types to show)
+ $ext = end( explode(".", strtolower($file)) );
+ if ($SHOWALLFILES || in_array($ext, $stypes)) { $SHOWTYPE = TRUE; } else { $SHOWTYPE = FALSE; }
+
+ if ( $SHOWTYPE && !is_dir($ipath.$file) && !$excluded ) {
+
+ //Set icon type based on file type ($ext).
+ $type = $fclasses[array_search($ext, $ftypes)];
+?>
+
\n";
-
- $row = 0; //index after filter of . & ..
- for ($x = 0; $x < $DIRECTORY_COUNT; $x++) {
- $filename = $DIRECTORY_DATA[$x][1];
- if ( ($filename != '.') && ($filename != '..') ) {; // skip . & ..
- $data_for_js .= 'DIRECTORY_DATA['.$row++.'] = [';
- $data_for_js .= '"' .$DIRECTORY_DATA[$x][0].'"'; // "type"
- $data_for_js .= ', "'.addslashes($DIRECTORY_DATA[$x][1]).'"'; // "file name"
- $data_for_js .= ', ' .$DIRECTORY_DATA[$x][2]; // filesize
- $data_for_js .= ', ' .$DIRECTORY_DATA[$x][3]; // timestamp
- $data_for_js .= ', ' .$DIRECTORY_DATA[$x][4]; // is_ofcms
- $data_for_js .= ', "'.addslashes($DIRECTORY_DATA[$x][5]).'"'; // "ext"
- $data_for_js .= ', ' .$DIRECTORY_DATA[$x][6]; // file permissions
- $data_for_js .= "];\n";
- }//end skip . & ..
- }//end for x
-
- $data_for_js .= "var DIRECTORY_ITEMS = DIRECTORY_DATA.length;\n";
-
- $data_for_js .= "\n\n";
- echo $data_for_js;
-
-}//end Send_directory_data_to_js() {//******************************************
-
-
-
function Index_Page_buttons_top($file_count) {//********************************
global $_, $ONESCRIPT, $param1, $ICONS, $TABINDEX;
@@ -2139,28 +2143,36 @@ function Index_Page_buttons_top($file_count) {//********************************
-
-function Index_Page() {//*******************************************************
- global $ONESCRIPT, $ipath_OS, $param1, $INPUT_NUONCE;
- init_ICONS_js();
+function Index_Page() {//*******************************************************
+ global $ONESCRIPT, $ipath_OS, $param1, $INPUT_NUONCE, $DIRECTORY_DATA, $DIRECTORY_COUNT;
$raw_list = scandir('./'.$ipath_OS); //Get current directory list (unsorted)
$file_count = Get_DIRECTORY_DATA($raw_list);
//
+
+';
+}//end List_Files() ************************************************************
+
+
+
+
+function Index_Page(){ //*******************************************************
+ global $ONESCRIPT, $ipath;
+
+ //
+ echo '
+ '; ?>
+ '; ?>
+
+
+ B
+
+
+
+
+
';
+
+ }elseif ( $too_large_to_edit ) {
+ echo ''.$EX.$_['edit_txt_02'].'
';
+ }else{
+ echo '';
+ echo '
';
+ echo $_['edit_txt_03'].'
';
+ echo $_['edit_txt_04'].'
'.
+$_['too_large_to_edit_02'].'
'.$_['too_large_to_edit_03'].'
'.$_['too_large_to_edit_04'];
+
+ $too_large_to_view_message =
+''.$_['too_large_to_view_01a'].number_format($MAX_VIEW_SIZE).' '.$_['too_large_to_view_01b'].'
'.
+$_['too_large_to_view_02'].'
'.$_['too_large_to_view_03'].'
'.$_['too_large_to_view_04'];
+
+ echo ''.$header2;
+ echo ''.htmlentities(basename($filename)).'';
+ echo '
'.PHP_EOL;
+
+ Edit_Page_buttons_top($text_editable);
+
+ Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_edit_message);
+
+ if ( in_array( $ext, $itypes) ) { show_image(); }
+
+ echo '';
+
+ if ( $text_editable && $too_large_to_view ) {
+ echo ''.$filecontent.'
';
+ }
+}//End Edit_Page ***************************************************************
+
+
+
+
+function Edit_response(){ //***If on Edit page, and [Save] clicked *************
+ global $_, $EX, $message, $filename;
+ $filename = $_POST["filename"];
+ $content = $_POST["content"];
+
+ $bytes = file_put_contents($filename, $content);
+
+ if ($bytes !== false) {
+ $message .= ''.$_['edit_msg_01'].' '.$bytes.' '.$_['edit_msg_02'].'';
+ }else{
+ $message .= $EX.''.$_['edit_msg_03'].'';
+ }
+}//end Edit_response() *********************************************************
+
+
+
+
+function Upload_Page() { //*****************************************************
+ global $_, $ONESCRIPT, $ipath, $param1, $INPUT_NUONCE;
+
+ //Determine $MAX_FILE_SIZE to upload
+ $upload_max_filesize = ini_get('upload_max_filesize'); //This should be < post_max_size,
+ $post_max_size = ini_get('post_max_size'); //but, just in case, check both...
+
+ function shorthand_to_int($SHORTHAND){ //*******************
+ $KMG = strtoupper(substr($SHORTHAND, -1));
+ if ($KMG == "K") { return $SHORTHAND * 1024; }
+ elseif ($KMG == "M") { return $SHORTHAND * 1048576; }
+ elseif ($KMG == "G") { return $SHORTHAND * 1073741824; }
+ else { return $SHORTHAND; }
+ }//end function shorthand_to_int() *************************
+
+ $UMF = shorthand_to_int($upload_max_filesize);
+ $PMS = shorthand_to_int($post_max_size);
+
+ if ($UMF <= $PMS){ $MAX_FILE_SIZE = $UMF; $max_msg = $upload_max_filesize.' '.$_['upload_txt_01']; }
+ else { $MAX_FILE_SIZE = $PMS; $max_msg = $post_max_size .' '.$_['upload_txt_02']; }
+?>
+
+
+
';
+ $message .= htmlentities($WEB_ROOT.$destination).'
'.$_['upload_msg_03'].'';
+ }else{
+ $message .= $_['upload_msg_04'].' "'.htmlentities($filename).'"...';
+ $savefile = ordinalize($destination, $filename, $savefile_msg);
+ if(move_uploaded_file($_FILES['upload_file']['tmp_name'], $savefile)) {
+ $message .= '
'.$_['upload_msg_05'].' '.$savefile_msg;
+ } else{
+ $message .= '
'.$EX.''.$_['upload_msg_06'].' '.$ERRMSG.'';
+ }
+ }
+}//end Upload_response() *******************************************************
+
+
+
+
+function New_File_Page() { //***************************************************
+ global $_, $FORM_COMMON, $INVALID_CHARS;
+?>
+
+
+
'.
+ ' '.$_['new_file_msg_02'].
+ ''.htmlentities($INVALID_CHARS).'';
+ }elseif ($new_name == ""){
+ $message .= $EX.''.$_['new_file_msg_03'].'';
+ }elseif (file_exists($filename)) {
+ $message .= $EX.''.$_['new_file_msg_04'];
+ $message .= htmlentities($new_name).'';
+ }elseif ($handle = fopen($filename, 'w')) {
+ fclose($handle);
+ $message .= ''.$_['new_file_msg_05'].' '.htmlentities($new_name);
+ $page = "edit";
+ $param2 = '&f='.rawurlencode(basename($filename));// for Edit_Page() buttons
+ $param3 = '&p=edit'; // for Edit_Page() buttons
+ }else{
+ $message .= $EX.''.$_['new_file_msg_06'];
+ $message .= htmlentities($new_name);
+ }
+}//end New_File_response() *****************************************************
+
+
+
+
+function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //************
+ //$action = 'Copy' or 'Rename'. $isfile = 1 if acting on a file, not a folder
+ global $_, $WEB_ROOT, $ipath, $filename, $FORM_COMMON;
+ if ($isfile) { $old_name = $filename; }else{ $old_name = $ipath; }
+ if ($isfile) { $new_name = $filename; }else{ $new_name = $ipath; }
+ //if ($action == "Copy" ) { $new_name = ordinalize($ipath, basename($filename), $msg); }
+?>
+
+
+
+
';
+ $message .= htmlentities($WEB_ROOT.$new_location).'/
';
+ }elseif ( !file_exists($filename) ){
+ $message .= $EX.''.$msg1.' '.$_['CRM_msg_02'].'
';
+ $message .= htmlentities($filename);
+ }elseif (file_exists($new_name)) {
+ $message .= $EX.''.$msg1.' '.$_['CRM_msg_03'].'
';
+ $message .= htmlentities($WEB_ROOT.$new_name).'';
+ }elseif ($action($old_name, $new_name)) {
+ $message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
+ $message .= ' --- '.$msg2.' '.$_['CRM_msg_04'].' ---
';
+ $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
+ $filename = $new_name; //so edit page knows what to edit
+ if ($isfile) { $ipath = Check_path(dirname($filename)); } //if changed,
+ else { $ipath = Check_path($filename); } //return to new dir.
+ $param1 = '?i='.URLencode_path($ipath);
+ $param2 = '&f='.rawurlencode(basename($filename));
+ $param3 = '&p=edit';
+ }else{
+ $message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
+ $message .= $EX.''.$_['CRM_msg_05a'].' '.$msg1.' '.$_['CRM_msg_05b'].'
';
+ $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
+ }
+}//end Copy_Ren_Move_response() ************************************************
+
+
+
+
+function Delete_File_Page() { //************************************************
+ global $_, $filename, $FORM_COMMON;
+?>
+
+
+
+
+
'.
+ ''.$_['new_folder_msg_02'].
+ ''.htmlentities($INVALID_CHARS).'';
+ }elseif ($new_name == ""){
+ $message .= $EX.''.$_['new_folder_msg_03'].'';
+ }elseif (is_dir($new_ipath)) {
+ $message .= $EX.''.$_['new_folder_msg_04'].' ';
+ $message .= htmlentities($new_ipath).'';
+ }elseif (mkdir($new_ipath)) {
+ $message .= ''.$_['new_folder_msg_05'].' '.htmlentities($new_name);
+ $ipath = $new_ipath; //return to new folder
+ $param1 = '?i='.URLencode_path($ipath);
+ }else{
+ $message .= $EX.''.$_['new_folder_msg_06'].'
';
+ $message .= htmlentities($new_name);
+ }
+}//end New_Folder_response *****************************************************
+
+
+
+
+function Delete_Folder_Page(){ //***********************************************
+ global $_, $WEB_ROOT, $ipath, $FORM_COMMON;
+?>
+
+
+
+ /
+
';}
+ $message .= '';
+ $message .= $BR.$EX.''.$_['edit_caution_01'].' '.$EX.$_['edit_caution_02'].'';
+ }
+ //**************************************************************************
+}//end if $_SESSION[valid] *****************************************************
+
+
+
+
+//******************************************************************************
+//******************************************************************************
+?>
+
+
+
+
+
';
+ $message .= hsc($_['verify_msg_01']).'
';
}
}
@@ -209,7 +448,7 @@ function Verify_IDLE_POST_etc() { //********************************************
$VALID_POST = 1;
}else{
Logout();
- $message .= $EX.' INVALID POST
';
+ $message .= $EX.''.hsc($_['verify_msg_02']).'
';
}
}
}//end Verify_IDLE_POST_etc() //************************************************
@@ -248,7 +487,7 @@ function strip_array($var) {
function Get_GET() { //*** Get main parameters *********************************
// i=some/path/, f=somefile.xyz, p=somepage
- global $ipath, $filename, $page, $valid_pages, $param1, $param2, $param3, $message, $EX;
+ global $_, $ipath, $filename, $page, $valid_pages, $param1, $param2, $param3, $message, $EX;
undo_magic_quotes();
@@ -256,9 +495,9 @@ function Get_GET() { //*** Get main parameters *********************************
if (isset($_GET["f"])) {
$filename = $ipath.$_GET["f"];
- if ( !is_file($filename) ) { $filename = ""; $page = "index"; }
if ( !is_file($filename) && $_SESSION['valid'] )//Set $message except for login page.
- { $message .= $EX.' File does not exist: '.htmlentities($filename).'
'; }
+ { $message .= $EX.''.hsc($_['get_get_msg_01']).' '.htmlentities($filename).'
'; }
+ if ( !is_file($filename) ) { $filename = ""; $page = "index"; }
}else{ $filename = ""; }
if (isset($_GET["p"])) { $page = $_GET["p"]; }
@@ -286,7 +525,7 @@ function URLencode_path($path){ // don't encode the forward slashes ************
function Check_path($path) { // returns first valid path in some/supplied/path/
- global $message, $EX;
+ global $_, $message, $EX;
$invalidpath = $path; //used for message if supplied $path doesn't exist.
$path = str_replace('\\','/',$path); //Make sure all forward slashes.
$path = trim($path,"/ ."); // trim slashes, dots, and spaces
@@ -304,7 +543,7 @@ function Check_path($path) { // returns first valid path in some/supplied/path/
if (strlen($path) < 1) { return ""; } //If at site root
else {
if (!is_dir($path) && (strlen($message) < 1))
- { $message .= $EX.' Directory does not exist: '.htmlentities($invalidpath).'
'; }
+ { $message .= $EX.''.hsc($_['check_path_msg_01']).''.htmlentities($invalidpath).'
'; }
while ( (strlen($path) > 0) && (!is_dir($path)) ) {
$path = dirname($path);
@@ -334,20 +573,20 @@ function is_empty($path){ //****************************************************
function ordinalize($destination,$filename, &$msg) { //*************************
//if file_exists(file.txt), ordinalize filename until it doesn't
//ie: file.txt.001, file.txt.002, file.txt.003 etc...
- global $EX;
+ global $_, $EX;
$ordinal = 0;
$savefile = $destination.$filename;
if (file_exists($savefile)) {
- $msg .= $EX.' A file with that name already exists in the target directory.
';
+ $msg .= $EX.hsc($_['ord_msg_01']).'
';
while (file_exists($savefile)) {
$ordinal = sprintf("%03d", ++$ordinal); // 001, 002, 003, etc...
$savefile = $destination.$filename.'.'.$ordinal;
}
- $msg .= 'Saving as: "'.htmlentities(basename($savefile)).'"';
+ $msg .= hsc($_['ord_msg_02']).'"'.htmlentities(basename($savefile)).'"';
}
return $savefile;
}//end ordinalize() filename ***************************************************
@@ -411,14 +650,14 @@ function message_box() { //*****************************************************
function Upload_New_Rename_Delete_Links() { //**********************************
- global $ONESCRIPT, $ipath, $param1;
+ global $_, $ONESCRIPT, $ipath, $param1;
echo ''.PHP_EOL;
@@ -674,46 +913,44 @@ function show_icon($type){ //***************************************************
function Hash_Page() { //******************************************************
- global $DOC_ROOT, $ONESCRIPT, $param1, $param2, $message, $INPUT_NUONCE, $config_title;
+ global $_, $DOC_ROOT, $ONESCRIPT, $param1, $param2, $message, $INPUT_NUONCE, $config_title;
$params = '?i='.dirname($ONESCRIPT).'&f='.basename($ONESCRIPT).'&p=edit';
if (!isset($_POST['whattohash'])) { $_POST['whattohash'] = ''; }
?>
-
Generate a Password Hash
+
+
- 2) Or, use $HASHWORD to store the hash of your password, and set $USE_HASH = 1.
-
-
- The hash will be displayed in a yellow message box above that.
-
- Make sure to copy ALL of, and ONLY, the hash (no leading or trailing spaces etc).
- A double-click should select it...
-
+
+
+
-
+
+
+
+
+
- PS: Everything I know about security - you just read...
+
+
';
+ $message .= hsc($_['hash_msg_02']).hashit($_POST["whattohash"]);
} //end Hash_response() ********************************************************
@@ -747,20 +984,15 @@ function Logout() { //**********************************************************
function Login_Page() { //******************************************************
- global $ONESCRIPT, $message;
+ global $_, $ONESCRIPT, $message;
?>
- Log In
+
';}
+ if ($attempts > 0) { $message .= ''.hsc($_['login_msg_01a']).' '.$attempts.' '.hsc($_['login_msg_01b']).'
';}
if ( ($attempts >= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
- $message .= 'Please wait '.Timeout_Timer(($LOGIN_DELAY - $elapsed), 'timer0', '', '').' seconds to try again. ';
+ $message .= hsc($_['login_msg_02a']).' '.Timeout_Timer(($LOGIN_DELAY - $elapsed), 'timer0', '', '').' '.hsc($_['login_msg_02b']);
return;
}
@@ -800,12 +1032,12 @@ function Login_response() { //**************************************************
$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; //for user consistancy check.
$_SESSION['valid'] = 1;
$page = "index";
- if ( is_file($LOGIN_ATTEMPTS) ) { unlink($LOGIN_ATTEMPTS); } //delete invalid attempt count file
+ if ( is_file($LOGIN_ATTEMPTS) ) { unlink($LOGIN_ATTEMPTS); } //delete invalid attempts count file
}else{
file_put_contents($LOGIN_ATTEMPTS, ++$attempts); //increment & save attempt
- $message = $EX.' INVALID LOGIN ATTEMPT #'.$attempts.'
';
+ $message = $EX.''.hsc($_['login_msg_03']).$attempts.'
';
if ($attempts >= $MAX_ATTEMPTS) {
- $message .= 'Please wait '.Timeout_Timer($LOGIN_DELAY, 'timer0', '', '').' seconds to try again. ';
+ $message .= hsc($_['login_msg_02a']).' '.Timeout_Timer($LOGIN_DELAY, 'timer0', '', '').' '.hsc($_['login_msg_02b']);
}
}
}//end Login_response() //******************************************************
@@ -882,10 +1114,39 @@ function Index_Page(){ //*******************************************************
-function Edit_Page_Buttons($text_editable, $too_large_to_edit) { //*************
- global $ONESCRIPT, $param1, $param2, $MAX_IDLE_TIME;
- $Button = '
+
+
+
+
+
+
-
-
-
-
- ,'?>
-
- '.$EX.' File contains an invalid character. Edit and view disabled.
';
+ echo '
';
- echo ' htmlspecialchars() returned and empty string from what may be an otherwise valid file.
';
- echo ' This behavior can be inconsistant from version to version of php.'.$EX.hsc($_['edit_txt_02']).'
';
}else{
- echo '';
+ echo '';
echo '
';
+ echo hsc($_['edit_txt_03']).'
';
+ echo hsc($_['edit_txt_04']).'
-Some browsers (ie: IE) bog down or become unstable while editing a large file in an HTML <textarea>.
-Adjust $MAX_EDIT_SIZE in the configuration section of OneFileCMS as needed.
-A simple trial and error test can determine a practical limit for a given browser/computer.';
+''.hsc($_['too_large_to_edit_01a']).number_format($MAX_EDIT_SIZE).' '.hsc($_['too_large_to_edit_01b']).'
'.
+hsc($_['too_large_to_edit_02']).'
'.hsc($_['too_large_to_edit_03']).'
'.hsc($_['too_large_to_edit_04']);
+
$too_large_to_view_message =
-'View disabled. Filesize > '.number_format($MAX_VIEW_SIZE).' bytes.
-Click the the file name above to view as normally rendered in a browser window.
-Adjust $MAX_VIEW_SIZE in the configuration section of OneFileCMS as needed.
-(The default value is completely arbitrary, and may be adjusted as desired to suit individual perceptions of reality.)';
+''.hsc($_['too_large_to_view_01a']).number_format($MAX_VIEW_SIZE).' '.hsc($_['too_large_to_view_01b']).'
'.
+hsc($_['too_large_to_view_02']).'
'.hsc($_['too_large_to_view_03']).'
'.hsc($_['too_large_to_view_04']);
echo ''.$header2;
echo ''.htmlentities(basename($filename)).'';
echo '
'.PHP_EOL;
-?>
- '.$filecontent.'
';
}
}//End Edit_Page ***************************************************************
@@ -1049,16 +1289,16 @@ function Edit_Page() { //*******************************************************
function Edit_response(){ //***If on Edit page, and [Save] clicked *************
- global $filename, $message, $EX;
+ global $_, $EX, $message, $filename;
$filename = $_POST["filename"];
$content = $_POST["content"];
$bytes = file_put_contents($filename, $content);
if ($bytes !== false) {
- $message .= 'File saved: '.$bytes.' bytes written.';
+ $message .= ''.hsc($_['edit_msg_01']).' '.$bytes.' '.hsc($_['edit_msg_02']).'';
}else{
- $message .= $EX.' There was an error saving file.';
+ $message .= $EX.''.hsc($_['edit_msg_03']).'';
}
}//end Edit_response() *********************************************************
@@ -1066,7 +1306,7 @@ function Edit_response(){ //***If on Edit page, and [Save] clicked *************
function Upload_Page() { //*****************************************************
- global $ONESCRIPT, $ipath, $param1, $INPUT_NUONCE;
+ global $_, $ONESCRIPT, $ipath, $param1, $INPUT_NUONCE;
//Determine $MAX_FILE_SIZE to upload
$upload_max_filesize = ini_get('upload_max_filesize'); //This should be < post_max_size,
@@ -1083,17 +1323,17 @@ function shorthand_to_int($SHORTHAND){ //*******************
$UMF = shorthand_to_int($upload_max_filesize);
$PMS = shorthand_to_int($post_max_size);
- if ($UMF <= $PMS){ $MAX_FILE_SIZE = $UMF; $max_msg = $upload_max_filesize.' per upload_max_filesize in php.ini.'; }
- else { $MAX_FILE_SIZE = $PMS; $max_msg = $post_max_size.' per post_max_size in php.ini'; }
+ if ($UMF <= $PMS){ $MAX_FILE_SIZE = $UMF; $max_msg = $upload_max_filesize.' '.hsc($_['upload_txt_01']); }
+ else { $MAX_FILE_SIZE = $PMS; $max_msg = $post_max_size .' '.hsc($_['upload_txt_02']); }
?>
- Upload File
-
';
- $message .= htmlentities($WEB_ROOT.$destination).'
Upload cancelled.';
+ $message .= $EX.hsc($_['upload_msg_02']).'
';
+ $message .= htmlentities($WEB_ROOT.$destination).'
'.hsc($_['upload_msg_03']).'';
}else{
- $message .= 'Uploading: "'.htmlentities($filename).'"...';
+ $message .= hsc($_['upload_msg_04']).' "'.htmlentities($filename).'"...';
$savefile = ordinalize($destination, $filename, $savefile_msg);
if(move_uploaded_file($_FILES['upload_file']['tmp_name'], $savefile)) {
- $message .= '
Upload successful! '.$savefile_msg;
+ $message .= '
'.hsc($_['upload_msg_05']).' '.$savefile_msg;
} else{
- $message .= '
'.$EX.' Upload failed: '.$ERRMSG.'';
+ $message .= '
'.$EX.''.hsc($_['upload_msg_06']).' '.$ERRMSG.'';
}
}
}//end Upload_response() *******************************************************
@@ -1140,14 +1380,14 @@ function Upload_response() { //*************************************************
function New_File_Page() { //***************************************************
- global $FORM_COMMON, $INVALID_CHARS;
+ global $_, $FORM_COMMON, $INVALID_CHARS;
?>
- New File
+
-
'.
- ' Name contains invalid character(s): '.
+ $message .= $EX.''.hsc($_['new_file_msg_01']).' '.htmlentities($new_name).'
'.
+ ' '.hsc($_['new_file_msg_02']).
''.htmlentities($INVALID_CHARS).'';
}elseif ($new_name == ""){
- $message .= $EX.' New file not created - no name given';
+ $message .= $EX.''.hsc($_['new_file_msg_03']).'';
}elseif (file_exists($filename)) {
- $message .= $EX.' File already exists: ';
+ $message .= $EX.''.hsc($_['new_file_msg_04']);
$message .= htmlentities($new_name).'';
}elseif ($handle = fopen($filename, 'w')) {
fclose($handle);
- $message .= 'Created file: '.htmlentities($new_name);
+ $message .= ''.hsc($_['new_file_msg_05']).' '.htmlentities($new_name);
$page = "edit";
$param2 = '&f='.rawurlencode(basename($filename));// for Edit_Page() buttons
$param3 = '&p=edit'; // for Edit_Page() buttons
}else{
- $message .= $EX.' Error - new file not created:
';
+ $message .= $EX.''.hsc($_['new_file_msg_06']);
$message .= htmlentities($new_name);
}
}//end New_File_response() *****************************************************
@@ -1193,24 +1433,24 @@ function New_File_response() { //***********************************************
function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //************
//$action = 'Copy' or 'Rename'. $isfile = 1 if acting on a file, not a folder
- global $WEB_ROOT, $ipath, $filename, $FORM_COMMON;
+ global $_, $WEB_ROOT, $ipath, $filename, $FORM_COMMON;
if ($isfile) { $old_name = $filename; }else{ $old_name = $ipath; }
if ($isfile) { $new_name = $filename; }else{ $new_name = $ipath; }
- if ($action == "Copy" ) { $new_name = ordinalize($ipath, basename($filename), $msg); }
+ //if ($action == "Copy" ) { $new_name = ordinalize($ipath, basename($filename), $msg); }
?>
-
';
+ $message .= $EX.''.$msg1.' '.hsc($_['CRM_msg_01']).'
';
$message .= htmlentities($WEB_ROOT.$new_location).'/
';
}elseif ( !file_exists($filename) ){
- $message .= $EX.' '.$msg1.' Error - source file does not exist:
';
+ $message .= $EX.''.$msg1.' '.hsc($_['CRM_msg_02']).'
';
$message .= htmlentities($filename);
}elseif (file_exists($new_name)) {
- $message .= $EX.' '.$msg1.' Error - target filename already exists:
';
+ $message .= $EX.''.$msg1.' '.hsc($_['CRM_msg_03']).'
';
$message .= htmlentities($WEB_ROOT.$new_name).'';
}elseif ($action($old_name, $new_name)) {
$message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
- $message .= ' --- '.$msg2.' to ---
';
+ $message .= ' --- '.$msg2.' '.hsc($_['CRM_msg_04']).' ---
';
$message .= ''.htmlentities($WEB_ROOT.$new_name).'';
$filename = $new_name; //so edit page knows what to edit
if ($isfile) { $ipath = Check_path(dirname($filename)); } //if changed,
@@ -1252,7 +1492,7 @@ function Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $msg2, $is
$param3 = '&p=edit';
}else{
$message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
- $message .= $EX.' Error during '.$msg1.' from the above to the following:
';
+ $message .= $EX.''.hsc($_['CRM_msg_05a']).' '.$msg1.' '.hsc($_['CRM_msg_05b']).'
';
$message .= ''.htmlentities($WEB_ROOT.$new_name).'';
}
}//end Copy_Ren_Move_response() ************************************************
@@ -1261,14 +1501,14 @@ function Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $msg2, $is
function Delete_File_Page() { //************************************************
- global $filename, $FORM_COMMON;
+ global $_, $filename, $FORM_COMMON;
?>
- Delete File
+
-
+
- New Folder
+
-
'.
- ' Name contains invalid character(s): '.
+ $message .= $EX.''.hsc($_['new_folder_msg_01']).' '.htmlentities($new_name).'
'.
+ ''.hsc($_['new_folder_msg_02']).
''.htmlentities($INVALID_CHARS).'';
}elseif ($new_name == ""){
- $message .= $EX.' New folder not created - no name given.';
+ $message .= $EX.''.hsc($_['new_folder_msg_03']).'';
}elseif (is_dir($new_ipath)) {
- $message .= $EX.' Folder already exists: ';
+ $message .= $EX.''.hsc($_['new_folder_msg_04']).' ';
$message .= htmlentities($new_ipath).'';
}elseif (mkdir($new_ipath)) {
- $message .= 'Created folder: '.htmlentities($new_name);
+ $message .= ''.hsc($_['new_folder_msg_05']).' '.htmlentities($new_name);
$ipath = $new_ipath; //return to new folder
$param1 = '?i='.URLencode_path($ipath);
}else{
- $message .= $EX.' Error - new folder not created:
';
+ $message .= $EX.''.hsc($_['new_folder_msg_06']).'
';
$message .= htmlentities($new_name);
}
}//end New_Folder_response *****************************************************
@@ -1345,15 +1585,15 @@ function New_Folder_response(){ //**********************************************
function Delete_Folder_Page(){ //***********************************************
- global $WEB_ROOT, $ipath, $FORM_COMMON;
+ global $_, $WEB_ROOT, $ipath, $FORM_COMMON;
?>
- Delete Folder
+
-
+
/
-
';}
$message .= '';
- $message .= $BR.$EX.' CAUTION '.$EX.' You are editing the active copy of OneFileCMS - BACK IT UP & BE CAREFUL !!';
+ $message .= $EX.''.hsc($_['edit_caution_01']).' '.$EX.hsc($_['edit_caution_02']).'';
}
//**************************************************************************
}//end if $_SESSION[valid] *****************************************************
@@ -2088,13 +2338,13 @@ function style_sheet(){ //****************************************************?>
@@ -2105,17 +2355,17 @@ function style_sheet(){ //****************************************************?>
-'; } ?>
-
Admin'; }
-
//Countdown timer...
-if ( $page != "login" ) {
+if ( $page != "login" ) {
+ echo '
';
echo Timeout_Timer($MAX_IDLE_TIME, 'timer0', 'timer timeout', 'LOGOUT');
- echo 'Session time out in: ';
+ echo ''.hsc($_['time_out_txt']).' ';
+}
+
+//Admin link
+if ( ($page != "login") && ($page != "hash") ){
+ echo ''.hsc($_['Admin']).'';
}
?>
diff --git a/onefilecms_3.2.04.BETA.php b/onefilecms_3.2.04.BETA.php
deleted file mode 100755
index 34280a3..0000000
--- a/onefilecms_3.2.04.BETA.php
+++ /dev/null
@@ -1,2348 +0,0 @@
-3.2.4 BETA'; //#####
-
-/*******************************************************************************
-Copyright © 2009-2012 https://github.com/rocktronica
-Copyright © 2012- https://github.com/Self-Evident David W. Gay
-
-This software is copyright under terms of the "MIT" license:
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*******************************************************************************/
-
-
-
-
-//Some basic security & error log settings
-ini_set('session.use_trans_sid', 0); //make sure URL supplied SESSID's are not used
-ini_set('session.use_only_cookies', 1); //make sure URL supplied SESSID's are not used
-error_reporting(E_ALL &~ E_STRICT); //0, or (E_ALL &~ E_STRICT) if display and/or log are on.
-ini_set('display_errors', 'off');
-ini_set('log_errors' , 'off'); //Ok to turn on for trouble-shooting.
-ini_set('error_log' , $_SERVER['SCRIPT_FILENAME'].'.log');
-//Determine good folder for session file? Default is tmp/, which is not secure.
-//session_save_path($safepath) or ini_set('session.save_path', $safepath)
-
-
-
-
-// CONFIGURABLE INFO ***********************************************************
-$config_title = "OneFileCMS";
-
-$USERNAME = 'username';
-
-$PASSWORD = 'password'; //If using $HASHWORD, you may leave this value empty.
-$USE_HASH = 0 ; // If = 0, use $PASSWORD. If = 1, use $HASHWORD.
-$HASHWORD = 'c3e70af96ab1bfc5669280e98b438e1a8c08ca5e0bb3354c05ceaa6f339fd3f6'; //hash for "password"
-$SALT = 'somerandomsalt';
-
-$MAX_ATTEMPTS = 3; //Max failed login attempts before LOGIN_DELAY starts.
-$LOGIN_DELAY = 10; //In seconds.
-$MAX_IDLE_TIME = 600; //In seconds. 600 = 10 minutes. Other PHP settings may limit its max effective value.
- // For instance, 24 minutes is the PHP default for garbage collection.
-$MAX_IMG_W = 810; // Max width to display images. (page container = 810)
-$MAX_IMG_H = 1000; // Max height. I don't know, it just looks reasonable.
-
-$MAX_EDIT_SIZE = 150000; // Edit gets flaky with large files in some browsers. Trial and error your's.
-$MAX_VIEW_SIZE = 1000000; // If file > $MAX_EDIT_SIZE, don't even view in OneFileCMS.
- // The default max view size is completely arbitrary. It was 2am and seemed like a good idea at the time.
-$config_favicon = "/favicon.ico";
-$config_excluded = ""; //files to exclude from directory listings- CaSe sEnsaTive!
-
-$config_etypes = "html,htm,xhtml,php,css,js,txt,text,cfg,conf,ini,csv,svg,log"; //Editable file types.
-$config_stypes = "*"; // Shown types; only files of the given types should show up in the file-listing
- // Use $config_stypes exactly like $config_etypes (list of extensions separated by semicolons).
- // If $config_stypes is set to null - by intention or by error - OFCMS will only display folders.
- // If $config_stypes is set to the *-wildcard (as per default), all files will show up.
- // If $config_stypes is set to "html,htm" for example, only file with the extension "html" or "htm" will get listed.
-
-$config_itypes = "jpg,gif,png,bmp,ico"; //image types to display on edit page.
-$config_ftypes = "bin,jpg,gif,png,bmp,ico,svg,txt,cvs,css,php,ini,cfg,conf,asp,js ,htm,html"; // _ftype & _fclass must have same
-$config_fclass = "bin,img,img,img,img,img,svg,txt,txt,css,php,txt,cfg,cfg ,txt,txt,htm,htm"; // number of values. bin is default.
-
-$EX = '( ! ) '; //EXclaimation point "icon" Used in $message's
-
-$SESSION_NAME = 'OFCMS'; //Also the cookie name. Change if using multiple copies of OneFileCMS.
-// End CONFIGURABLE INFO *******************************************************
-
-
-
-
-// PROCESS CONFIGURATION FILE **************************************************
-# Check if a configuration file does exist:
-$config_file = 'ofcms.ini';
-if (is_file($config_file)) {
- # Parse file
- $settings = parse_ini_file($config_file);
-
- # Configure which variables can get overwritten by the config file:
- $overwritable_variables = array(
- 'config_title',
- 'USERNAME',
- 'PASSWORD',
- 'USE_HASH',
- 'HASHWORD',
- 'SALT',
- 'config_stypes');
-
- # Loop through options and overwrite default configuration
- foreach($settings as $key => $value) {
- # Check if variable can get overwritten:
- if (in_array($key, $overwritable_variables)) {
- $GLOBALS[$key] = $value;
- }
- }
-}
-// End PROCESS CONFIGURATION FILE **********************************************
-
-
-
-
-//******************************************************************************
-//Some global system values
-
-ini_set('session.gc_maxlifetime', $MAX_IDLE_TIME + 100); //in case the default is less.
-
-//PHP_VERSION_ID is better to use when checking current version as it's an actual number, not a string.
-if (!defined('PHP_VERSION_ID')) { //PHP_VERSION_ID only available since 5.2.7
- $phpversion = explode('.', PHP_VERSION); //PHP_VERSION, however, available even in older versions. (but it's a string)
- define('PHP_VERSION_ID', ($phpversion[0] * 10000 + $phpversion[1] * 100 + $phpversion[2]));
-}
-
-$ONESCRIPT = URLencode_path($_SERVER["SCRIPT_NAME"]);
-$DOC_ROOT = $_SERVER["DOCUMENT_ROOT"].'/';
-$WEB_ROOT = URLencode_path(basename($DOC_ROOT)).'/';
-$WEBSITE = $_SERVER["HTTP_HOST"].'/';
-$LOGIN_ATTEMPTS = $DOC_ROOT.trim($_SERVER["SCRIPT_NAME"],'/').'.invalid_login_attempts';
-
-$valid_pages = array("hash", "login","logout","index","edit","upload","uploaded","newfile","copy","rename","delete","newfolder","renamefolder","deletefolder" );
-
-$INVALID_CHARS = '< > ? * : " | / \\'; //Illegal characters for file/folder names.
-$INVALID_CHARS_array = explode(' ', $INVALID_CHARS); // (Space deliminated)
-
-//Make arrays out of a few $config_variables for actual use later.
-//Also, remove spaces and make lowercase.
-$SHOWALLFILES = $stypes = false;
- if ($config_stypes == '*') { $SHOWALLFILES = true; }
- else { $stypes = explode(',', strtolower(str_replace(' ', '', $config_stypes))); }//shown file types
-$etypes = explode(',', strtolower(str_replace(' ', '', $config_etypes))); //editable file types
-$itypes = explode(',', strtolower(str_replace(' ', '', $config_itypes))); //images types to display
-$ftypes = explode(',', strtolower(str_replace(' ', '', $config_ftypes))); //file types with icons
-$fclasses = explode(',', strtolower(str_replace(' ', '', $config_fclass))); //for file types with icons
-$excluded_list = (explode(",", $config_excluded));
-//******************************************************************************
-
-
-
-
-//******************************************************************************
-// Language: English
-//
-$_['Upload_File'] = 'Upload File';
-$_['New_File'] = 'New File';
-$_['Ren_Move'] = 'Rename/Move';
-$_['Ren_Moved'] = 'Renamed/Moved';
-$_['New_Folder'] = 'New Folder';
-$_['Ren_Folder'] = 'Rename/Move Folder';
-$_['Del_Folder'] = 'Delete Folder';
-
-$_['Admin'] = 'Admin';
-$_['Enter'] = 'Enter';
-$_['Edit'] = 'Edit';
-$_['Close'] = 'Close';
-$_['Cancel'] = 'Cancel';
-$_['Upload'] = 'Upload';
-$_['Create'] = 'Create';
-$_['Copy'] = 'Copy';
-$_['Copied'] = 'Copied';
-$_['Rename'] = 'Rename';
-$_['Delete'] = 'Delete';
-$_['DELETE'] = 'DELETE';
-$_['File'] = 'File';
-$_['Folder'] = 'Folder';
-
-$_['Log_In'] = 'Log In';
-$_['Log_Out'] = 'Log Out';
-$_['Hash'] = 'Hash';
-$_['Generate_Hash'] = 'Generate Hash';
-
-$_['save_1'] = 'Save';
-$_['save_2'] = 'SAVE CHANGES!';
-$_['reset'] = 'Reset - loose changes';
-$_['Wide_View'] = 'Wide View';
-$_['Normal_View'] = 'Normal View';
-
-$_['on'] = 'on';
-$_['bytes_01'] = ' bytes.';
-
-$_['verify_msg_01'] = 'Session expired.';
-$_['verify_msg_02'] = 'INVALID POST';
-
-$_['get_get_msg_01'] = 'File does not exist:';
-
-$_['check_path_msg_01'] = 'Directory does not exist: ';
-
-$_['ord_msg_01'] = 'A file with that name already exists in the target directory.';
-$_['ord_msg_02'] = 'Saving as';
-
-$_['show_img_msg_01'] = 'Image shown at ~';
-$_['show_img_msg_02'] = '% of full size (W x H = ';
-
-$_['hash_h2'] = 'Generate a Password Hash';
-$_['hash_txt_01'] = 'There are two ways to change your OneFileCMS password:';
-$_['hash_txt_02'] = '1) Use the $PASSWORD config variable to store your desired password, and set $USE_HASH = 0 (zero).';
-$_['hash_txt_03'] = '2) Or, use $HASHWORD to store the hash of your password, and set $USE_HASH = 1.';
-$_['hash_txt_04'] = 'Keep in mind that due to a number of widely varied considerations, this is largely an academic excersize. That is, take the idea that this adds much of an improvement to security with a grain of cryptographic salt. However, it does eleminate the storage of your password in plain text, which is a good thing.';
-$_['hash_txt_05'] = 'Anyway, to use the $HASHWORD password option:';
-$_['hash_txt_06'] = 'Type your desired password in the input field above and hit Enter.';
-$_['hash_txt_07'] = 'The hash will be displayed in a yellow message box above that.';
-$_['hash_txt_08'] = 'Copy and paste the new hash to the $HASHWORD variable in the config section.';
-$_['hash_txt_09'] = 'Make sure to copy ALL of, and ONLY, the hash (no leading or trailing spaces etc).';
-$_['hash_txt_10'] = 'A double-click should select it...';
-$_['hash_txt_11'] = 'Make sure $USE_HASH is set to 1 (or true).';
-$_['hash_txt_12'] = 'When ready, logout and login.';
-$_['hash_txt_13'] = 'You can use OneFileCMS to edit itself. However, be sure to have a backup ready for the inevitable ytpo...';
-$_['hash_txt_14'] = 'For another small improvement to security, change the default salt and/or method used by OneFileCMS to hash the password (and keep \'em secret, of course). Remever, every little bit helps...';
-
-$_['hash_msg_01'] = 'Password: ';
-$_['hash_msg_02'] = 'Hash : ';
-
-$_['login_h2'] = 'Log In';
-$_['login_txt_01'] = 'Username:';
-$_['login_txt_02'] = 'Password:';
-
-$_['login_msg_01a'] = 'There have been';
-$_['login_msg_01b'] = 'invalid login attempts.';
-$_['login_msg_02a'] = 'Please wait';
-$_['login_msg_02b'] = 'seconds to try again.';
-$_['login_msg_03'] = 'INVALID LOGIN ATTEMPT #';
-
-$_['edit_notes_00'] = 'NOTES:';
-$_['edit_note_01a'] = 'Remember- your ';
-$_['edit_note_01b'] = ' is ';
-$_['edit_note_02'] = 'So save changes before the clock runs out, or the changes will be lost!';
-$_['edit_note_03'] = 'some browsers, such as Chrome, if you click the browser [Back] then browser [Forward] (or vice versa), the file state may not be accurate. To correct, click the browser\'s [Reload].';
-$_['edit_note_04'] = 'Chrome\'s XSS filters may disable some javascript in a page if the page even appears to contain inline javascript in certain contexts. This can affect some features of the OneFileCMS edit page when editing files that legitimately contain such code, such as OneFileCMS itself. However, such files can still be edited and saved with OneFileCMS. The primary function lost is the incidental change of background colors (red/green) indicating whether or not the file has unsaved changes. The issue will be noticed after the first save of such a file.';
-
-$_['edit_h2_1'] = 'Viewing: ';
-$_['edit_h2_2'] = 'Editing: ';
-$_['edit_txt_01'] = 'Non-text or unkown file type. Edit disabled.';
-$_['edit_txt_02'] = 'File possibly contains an invalid character. Edit and view disabled.';
-$_['edit_txt_03'] = 'htmlspecialchars() returned and empty string from what may be an otherwise valid file.';
-$_['edit_txt_04'] = 'This behavior can be inconsistant from version to version of php.';
-
-$_['too_large_to_edit_01a'] = 'Edit disabled. Filesize > ';
-$_['too_large_to_edit_01b'] = $_['bytes_01'];
-$_['too_large_to_edit_02'] = 'Some browsers (ie: IE) bog down or become unstable while editing a large file in an HTML <textarea>.';
-$_['too_large_to_edit_03'] = 'Adjust $MAX_EDIT_SIZE in the configuration section of OneFileCMS as needed.';
-$_['too_large_to_edit_04'] = 'A simple trial and error test can determine a practical limit for a given browser/computer.';
-
-$_['too_large_to_view_01a'] = 'View disabled. Filesize > ';
-$_['too_large_to_view_01b'] = $_['bytes_01'];
-$_['too_large_to_view_02'] = 'Click the the file name above to view as normally rendered in a browser window.';
-$_['too_large_to_view_03'] = 'Adjust $MAX_VIEW_SIZE in the configuration section of OneFileCMS as needed.';
-$_['too_large_to_view_04'] = '(The default value for $MAX_VIEW_SIZE is completely arbitrary, and may be adjusted as desired.)';
-
-$_['meta_txt_01'] = 'Filesize: ';
-$_['meta_txt_02'] = $_['bytes_01'];
-$_['meta_txt_03'] = 'Updated: ';
-
-$_['edit_msg_01'] = 'File saved: ';
-$_['edit_msg_02'] = 'bytes written.';
-$_['edit_msg_03'] = 'There was an error saving file.';
-
-$_['upload_h2'] = 'Upload File';
-$_['upload_txt_01'] = ' per upload_max_filesize in php.ini.';
-$_['upload_txt_02'] = 'per post_max_size in php.ini';
-$_['upload_txt_03'] = 'Note: Maximum upload file size is: ';
-
-$_['upload_err_01a'] = 'Error 1: File too large. ';
-$_['upload_err_01b'] = ' (From php.ini)';
-$_['upload_err_02a'] = 'Error 2: File too large. ';
-$_['upload_err_02b'] = ' (From OneFileCMS)';
-$_['upload_err_03'] = 'Error 3: The uploaded file was only partially uploaded.';
-$_['upload_err_04'] = 'Error 4: No file was uploaded.';
-$_['upload_err_05'] = 'Error 5:';
-$_['upload_err_06'] = 'Error 6: Missing a temporary folder.';
-$_['upload_err_07'] = 'Error 7: Failed to write file to disk.';
-$_['upload_err_08'] = 'Error 8: A PHP extension stopped the file upload.';
-
-$_['upload_msg_01'] = 'No file selected for upload.';
-$_['upload_msg_02'] = 'Destination folder does not exist: ';
-$_['upload_msg_03'] = 'Upload cancelled.';
-$_['upload_msg_04'] = 'Uploading: ';
-$_['upload_msg_05'] = 'Upload successful! ';
-$_['upload_msg_06'] = 'Upload failed: ';
-
-$_['new_file_h2'] = 'New File';
-$_['new_file_txt_01'] = 'File will be created in the current folder. ';
-$_['new_file_txt_02'] = 'Some invalid characters are: ';
-
-$_['new_file_msg_01'] = 'New file not created:';
-$_['new_file_msg_02'] = 'Name contains invalid character(s): ';
-$_['new_file_msg_03'] = 'New file not created - no name given';
-$_['new_file_msg_04'] = 'File already exists: ';
-$_['new_file_msg_05'] = 'Created file:';
-$_['new_file_msg_06'] = 'Error - new file not created:';
-
-$_['CRM_txt_01'] = 'To move a file or folder, change the path/to/folder/or_file. The new location must already exist.';
-$_['CRM_txt_02'] = 'Old name:';
-$_['CRM_txt_03'] = 'New name:';
-
-$_['CRM_msg_01'] = ' Error - new parent location does not exist:';
-$_['CRM_msg_02'] = ' Error - source file does not exist:';
-$_['CRM_msg_03'] = ' Error - target filename already exists:';
-$_['CRM_msg_04'] = ' to ';
-$_['CRM_msg_05a'] = 'Error during ';
-$_['CRM_msg_05b'] = ' from the above to the following:';
-
-$_['delete_h2'] = 'Delete File';
-$_['delete_txt_01'] = 'Are you sure?';
-
-$_['delete_msg_01'] = 'Deleted file:';
-$_['delete_msg_02'] = 'Error deleting ';
-
-$_['new_folder_h2'] = 'New Folder';
-$_['new_folder_txt_1'] = 'Folder will be created in the current folder. ';
-$_['new_folder_txt_2'] = 'Some invalid characters are: ';
-
-$_['new_folder_msg_01'] = 'New folder not created:';
-$_['new_folder_msg_02'] = 'Name contains invalid character(s): ';
-$_['new_folder_msg_03'] = 'New folder not created - no name given.';
-$_['new_folder_msg_04'] = 'Folder already exists: ';
-$_['new_folder_msg_05'] = 'Created folder:';
-$_['new_folder_msg_06'] = 'Error - new folder not created: ';
-
-$_['delete_folder_h2'] = 'Delete Folder';
-$_['delete_folder_txt_01'] = 'Are you sure?';
-
-$_['delete_folder_msg_01'] = 'Folder not empty. Folders must be empty before they can be deleted.';
-$_['delete_folder_msg_02'] = 'Deleted folder:';
-$_['delete_folder_msg_03'] = 'an error occurred during delete.';
-
-$_['page_title_login'] = 'Log In';
-$_['page_title_hash'] = 'Hash Page';
-$_['page_title_edit'] = 'Edit/View File';
-$_['page_title_upload'] = 'Upload File';
-$_['page_title_new_file'] = 'New File';
-$_['page_title_copy'] = 'Copy File';
-$_['page_title_ren'] = 'Rename File';
-$_['page_title_del'] = 'Delete File';
-$_['page_title_folder_new'] = 'New Folder';
-$_['page_title_folder_ren'] = 'Rename/Move Folder';
-$_['page_title_folder_del'] = 'Delete Folder';
-
-$_['session_expired'] = 'SESSION EXPIRED';
-$_['unload_unsaved'] = ' Unsaved changes will be lost!';
-$_['confirm_reset'] = 'Reset file and loose unsaved changes?';
-
-$_['OFCMS_requires'] = 'OneFileCMS requires PHP5 to operate. Tested on versions 5.2.17, 5.3.3 & 5.4';
-
-$_['logout_msg'] = 'You have successfully logged out.';
-$_['folder_del_msg'] = 'Folder not empty. Folders must be empty before they can be deleted.';
-$_['upload_error_01a'] = ' Upload Error. Total POST data (mostly filesize) exceeded post_max_size = ';
-$_['upload_error_01b'] = ' (from php.ini)';
-$_['edit_caution_01'] = 'CAUTION ';
-$_['edit_caution_02'] = ' You are editing the active copy of OneFileCMS - BACK IT UP & BE CAREFUL !!';
-
-$_['time_out_txt'] = 'Session time out in:';
-//******************************************************************************
-
-
-
-
-function Session_Startup() {//**************************************************
- global $USERNAME, $PASSWORD, $USE_HASH, $HASHWORD, $page, $VALID_POST, $MAX_IDLE_TIME, $SESSION_NAME;
-
- $limit = 0; //0 = session.
- $path = dirname($_SERVER['SCRIPT_NAME']);
- $domain = ''; // '' = hostname
- $https = false;
- $httponly = true;//true = unaccessable via javascript. Some XSS protection.
- session_set_cookie_params($limit, $path, $domain, $https, $httponly);
-
- session_name($SESSION_NAME);
- session_start();
-
- //Set initial defaults...
- $page = 'login';
- $VALID_POST = 0;
- if ( !isset($_SESSION['valid']) ) { $_SESSION['valid'] = 0; }
-
- //Logging in?
- if ( isset($_POST["username"]) || isset($_POST["password"]) ) { Login_response(); }
-
- session_regenerate_id(true); //Helps prevent session fixation & hijacking.
-
- if ( $_SESSION['valid'] ) { Verify_IDLE_POST_etc(); }
-
- $_SESSION['nuonce'] = sha1(mt_rand().microtime()); //provided in
';
- }
- }
-
- $_SESSION['last_active_time'] = time();
-
- //If POSTing, verify...
- if ( isset($_POST['nuonce']) ) {
- if ( $_POST['nuonce'] == $_SESSION['nuonce'] ) {
- $VALID_POST = 1;
- }else{
- Logout();
- $message .= $EX.''.$_['verify_msg_02'].'
';
- }
- }
-}//end Verify_IDLE_POST_etc() //************************************************
-
-
-
-
-function hashit($key){ //*******************************************************
- //This is the super-secret stuff - Keep it secret, keep it safe!
- //If you change anything here, or the $SALT, redo the hash for your password.
- global $SALT;
- $hash = hash('sha256', trim($key).$SALT); // trim off leading & trailing spaces.
- for ( $x=0; $x < 1000; $x++ ) { $hash = hash('sha256', $hash.$SALT); }
- return $hash;
-}//end hashit() ****************************************************************
-
-
-
-
-function undo_magic_quotes(){ //************************************************
-
- function strip_array($var) {
- if (is_array($var)) {return array_map("strip_array", $var); }
- else {return stripslashes($var); }
- } //Note: stripslashes also handles cases when magic_quotes_sybase is on.
-
- if (get_magic_quotes_gpc()) {
- if (isset($_GET)) { $_GET = strip_array($_GET); }
- if (isset($_POST)) { $_POST = strip_array($_POST); }
- if (isset($_COOKIE)) { $_COOKIE = strip_array($_COOKIE); }
- }
-}//end undo_magic_quotes() *****************************************************
-
-
-
-
-function Get_GET() { //*** Get main parameters *********************************
- // i=some/path/, f=somefile.xyz, p=somepage
- global $_, $ipath, $filename, $page, $valid_pages, $param1, $param2, $param3, $message, $EX;
-
- undo_magic_quotes();
-
- if (isset($_GET["i"])) { $ipath = Check_path($_GET["i"]); }else{ $ipath = ""; }
-
- if (isset($_GET["f"])) {
- $filename = $ipath.$_GET["f"];
- if ( !is_file($filename) && $_SESSION['valid'] )//Set $message except for login page.
- { $message .= $EX.''.$_['get_get_msg_01'].' '.htmlentities($filename).'
'; }
- if ( !is_file($filename) ) { $filename = ""; $page = "index"; }
- }else{ $filename = ""; }
-
- if (isset($_GET["p"])) { $page = $_GET["p"]; }
- if (!in_array(strtolower($page), $valid_pages)) { $page = "index"; }
-
- $param1 = '?i='.URLencode_path($ipath);
- if ($filename == "") { $param2 = ""; }else{ $param2 = '&f='.rawurlencode(basename($filename)); }
- if ($page == "" ) { $param3 = ""; }else{ $param3 = '&p='.$page; }
-}//end Get_GET()****************************************************************
-
-
-
-
-function URLencode_path($path){ // don't encode the forward slashes ************
- $TS = ''; // Trailing Slash/
- if (substr($path, -1) == '/' ) { $TS = '/'; } //start with a $TS?
- $path_array = explode('/',$path);
- $path = "";
- foreach ($path_array as $level) { $path .= rawurlencode($level).'/'; }
- $path = rtrim($path,'/').$TS; //end with $TS only if started with one
- return $path;
-}//end URLencode_path($path) ***************************************************
-
-
-
-
-function Check_path($path) { // returns first valid path in some/supplied/path/
- global $_, $message, $EX;
- $invalidpath = $path; //used for message if supplied $path doesn't exist.
- $path = str_replace('\\','/',$path); //Make sure all forward slashes.
- $path = trim($path,"/ ."); // trim slashes, dots, and spaces
-
- //Remove any '.' and '..' parts of the path. Causes issues in www / current / path /
- $pathparts = explode( '/', $path);
- $len = count($pathparts);
- $path = ""; //Cleaned path.
- foreach ($pathparts as $value) { //(More reliable than str_replace(entire_string).)
- if ( !(($value == '.') && (!value == '..')) ) { $path .= $value.'/'; }
- }
-
- $path = trim($path,"/"); // Remove -for now- final trailing slash.
-
- if (strlen($path) < 1) { return ""; } //If at site root
- else {
- if (!is_dir($path) && (strlen($message) < 1))
- { $message .= $EX.''.$_['check_path_msg_01'].''.htmlentities($invalidpath).'
'; }
-
- while ( (strlen($path) > 0) && (!is_dir($path)) ) {
- $path = dirname($path);
- }
-
- $path = $path.'/';
- if ($path == './') { $path = ""; } // ./ means path not found, so clear for root.
- }
-
- return $path;
-}//end Check_path() ************************************************************
-
-
-
-
-function is_empty($path){ //****************************************************
- $empty = false;
- $dh = opendir($path);
- for($i = 3; $i; $i--) { $empty = (readdir($dh) === FALSE); }
- closedir($dh);
- return $empty;
-}//end is_empty() //************************************************************
-
-
-
-
-function ordinalize($destination,$filename, &$msg) { //*************************
-//if file_exists(file.txt), ordinalize filename until it doesn't
-//ie: file.txt.001, file.txt.002, file.txt.003 etc...
- global $_, $EX;
-
- $ordinal = 0;
- $savefile = $destination.$filename;
-
- if (file_exists($savefile)) {
-
- $msg .= $EX.$_['ord_msg_01'].'
';
-
- while (file_exists($savefile)) {
- $ordinal = sprintf("%03d", ++$ordinal); // 001, 002, 003, etc...
- $savefile = $destination.$filename.'.'.$ordinal;
- }
- $msg .= $_['ord_msg_02'].'"'.htmlentities(basename($savefile)).'"';
- }
- return $savefile;
-}//end ordinalize() filename ***************************************************
-
-
-
-
-function Current_Path_Header(){ //**********************************************
- // Current path. ie: webroot/current/path/
- // Each level is a link to that level.
-
- global $ONESCRIPT, $ipath, $WEB_ROOT;
-
- echo '';
- //Root folder of web site.
- echo ' '.htmlentities(trim($WEB_ROOT, '/')).'/';
- $x=0; //need here for focus() in case at webroot.
-
- if ($ipath != "" ) { //if not at root, show the rest
- $path_levels = explode("/",trim($ipath,'/') );
- $levels = count($path_levels); //If levels=3, indexes = 0, 1, 2 etc...
- $current_path = "";
-
- for ($x=0; $x < $levels; $x++) {
- $current_path .= $path_levels[$x].'/';
- echo '';
- echo htmlentities($path_levels[$x]).'/';
- }
- }//end if (not at root)
- echo '
';
- echo '';
-}//end Current_Path_Header() //*************************************************
-
-
-
-
-function message_box() { //*****************************************************
- global $ONESCRIPT, $param1, $param2, $param3, $message, $page;
-
- if (isset($message)) {
-?>
- '.PHP_EOL;
-}// end show_image() ***********************************************************
-
-
-
-
-function show_favicon(){ //*****************************************************
- global $config_favicon, $DOC_ROOT;
- if (file_exists($DOC_ROOT.$config_favicon)) {
- echo '
';
- }
-}// end show_favicon() *********************************************************
-
-
-
-
-function Timeout_Timer($COUNT, $ID, $CLASS, $ACTION) { //************************
-
- return '';
-
-} //end Timeout_Timer() **************************************************
-
-
-
-
-function Init_Macros(){ //*** ($varibale="some reusable chunk of code")*********
-
-global $ONESCRIPT, $param1, $param2, $INPUT_NUONCE, $FORM_COMMON,
- $SVG_icon_circle_plus, $SVG_icon_circle_x, $SVG_icon_pencil, $SVG_icon_img_0;
-
-$INPUT_NUONCE = ''.PHP_EOL;
-$FORM_COMMON = '
-
-
-
-
-
-
-
-
-
-
';}
- if ( ($attempts >= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
- $message .= $_['login_msg_02a'].' '.Timeout_Timer(($LOGIN_DELAY - $elapsed), 'timer0', '', '').' '.$_['login_msg_02b'];
- return;
- }
-
- //Validate password
- if ($USE_HASH) { $VALID_PASSWORD = (hashit($_POST['password']) == $HASHWORD); }
- else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
-
- //validate login. Ignore attempt if username & password are blank.
- if ( ($_POST['password'] == "") && ($_POST['username'] == "") ) { ; //
- }elseif ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
- session_regenerate_id(true);
- $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; //for user consistancy check.
- $_SESSION['valid'] = 1;
- $page = "index";
- if ( is_file($LOGIN_ATTEMPTS) ) { unlink($LOGIN_ATTEMPTS); } //delete invalid attempts count file
- }else{
- file_put_contents($LOGIN_ATTEMPTS, ++$attempts); //increment & save attempt
- $message = $EX.''.$_['login_msg_03'].$attempts.'
';
- if ($attempts >= $MAX_ATTEMPTS) {
- $message .= $_['login_msg_02a'].' '.Timeout_Timer($LOGIN_DELAY, 'timer0', '', '').' '.$_['login_msg_02b'];
- }
- }
-}//end Login_response() //******************************************************
-
-
-
-
-function List_Files() { // ...in a vertical table ******************************
-//called from Index Page
-
- global $ONESCRIPT, $ipath, $param1, $ftypes, $fclasses, $excluded_list, $stypes, $SHOWALLFILES;
-
- $files = scandir('./'.$ipath);
- natcasesort($files);
-
- echo '';
- foreach ($files as $file) {
-
- $excluded = FALSE;
- if (in_array(basename($file), $excluded_list)) { $excluded = TRUE; };
-
- //Get file type & check against $stypes (files types to show)
- $ext = end( explode(".", strtolower($file)) );
- if ($SHOWALLFILES || in_array($ext, $stypes)) { $SHOWTYPE = TRUE; } else { $SHOWTYPE = FALSE; }
-
- if ( $SHOWTYPE && !is_dir($ipath.$file) && !$excluded ) {
-
- //Set icon type based on file type ($ext).
- $type = $fclasses[array_search($ext, $ftypes)];
-?>
-
-
+
';
@@ -1946,7 +1955,7 @@ function Index_Page_buttons_top($file_count) { //*******************************
-function Index_Page() { //******************************************************
+function Index_Page() {//*******************************************************
global $ONESCRIPT, $ipath_OS, $param1;
init_ICONS_js();
@@ -1967,20 +1976,22 @@ function Index_Page() { //******************************************************
Send_data_to_js_and_display();
- Index_Page_onclicks();
+ Index_Page_events();
}//end Index_Page() //**********************************************************
-function Edit_Page_buttons_top($text_editable,$file_ENC){ //********************
+function Edit_Page_buttons_top($text_editable,$file_ENC) {//********************
global $_, $ONESCRIPT, $param1, $param2, $filename, $filename_OS, $IS_OFCMS,
$WYSIWYG_VALID, $EDIT_WYSIWYG, $WYSIWYG_label, $message;
clearstatcache ();
//[View Raw] button.
- $view_raw_button = '
-
-';
-}//end List_Files() ************************************************************
-
-
-
-
-function Index_Page(){ //*******************************************************
- global $ONESCRIPT, $ipath;
-
- //
- echo '
- '; ?>
- '; ?>
-
-
- B
-
-
-
-
-
';
-
- }elseif ( $too_large_to_edit ) {
- echo ''.$EX.$_['edit_txt_02'].'
';
- }else{
- echo '';
- echo '
';
- echo $_['edit_txt_03'].'
';
- echo $_['edit_txt_04'].'
'.
-$_['too_large_to_edit_02'].'
'.$_['too_large_to_edit_03'].'
'.$_['too_large_to_edit_04'];
-
- $too_large_to_view_message =
-''.$_['too_large_to_view_01a'].number_format($MAX_VIEW_SIZE).' '.$_['too_large_to_view_01b'].'
'.
-$_['too_large_to_view_02'].'
'.$_['too_large_to_view_03'].'
'.$_['too_large_to_view_04'];
-
- echo ''.$header2;
- echo ''.htmlentities(basename($filename)).'';
- echo '
'.PHP_EOL;
-
- Edit_Page_buttons_top($text_editable);
-
- Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_edit_message);
-
- if ( in_array( $ext, $itypes) ) { show_image(); }
-
- echo '';
-
- if ( $text_editable && $too_large_to_view ) {
- echo ''.$filecontent.'
';
- }
-}//End Edit_Page ***************************************************************
-
-
-
-
-function Edit_response(){ //***If on Edit page, and [Save] clicked *************
- global $_, $EX, $message, $filename;
- $filename = $_POST["filename"];
- $content = $_POST["content"];
-
- $bytes = file_put_contents($filename, $content);
-
- if ($bytes !== false) {
- $message .= ''.$_['edit_msg_01'].' '.$bytes.' '.$_['edit_msg_02'].'';
- }else{
- $message .= $EX.''.$_['edit_msg_03'].'';
- }
-}//end Edit_response() *********************************************************
-
-
-
-
-function Upload_Page() { //*****************************************************
- global $_, $ONESCRIPT, $ipath, $param1, $INPUT_NUONCE;
-
- //Determine $MAX_FILE_SIZE to upload
- $upload_max_filesize = ini_get('upload_max_filesize'); //This should be < post_max_size,
- $post_max_size = ini_get('post_max_size'); //but, just in case, check both...
-
- function shorthand_to_int($SHORTHAND){ //*******************
- $KMG = strtoupper(substr($SHORTHAND, -1));
- if ($KMG == "K") { return $SHORTHAND * 1024; }
- elseif ($KMG == "M") { return $SHORTHAND * 1048576; }
- elseif ($KMG == "G") { return $SHORTHAND * 1073741824; }
- else { return $SHORTHAND; }
- }//end function shorthand_to_int() *************************
-
- $UMF = shorthand_to_int($upload_max_filesize);
- $PMS = shorthand_to_int($post_max_size);
-
- if ($UMF <= $PMS){ $MAX_FILE_SIZE = $UMF; $max_msg = $upload_max_filesize.' '.$_['upload_txt_01']; }
- else { $MAX_FILE_SIZE = $PMS; $max_msg = $post_max_size .' '.$_['upload_txt_02']; }
-?>
-
-
-
';
- $message .= htmlentities($WEB_ROOT.$destination).'
'.$_['upload_msg_03'].'';
- }else{
- $message .= $_['upload_msg_04'].' "'.htmlentities($filename).'"...';
- $savefile = ordinalize($destination, $filename, $savefile_msg);
- if(move_uploaded_file($_FILES['upload_file']['tmp_name'], $savefile)) {
- $message .= '
'.$_['upload_msg_05'].' '.$savefile_msg;
- } else{
- $message .= '
'.$EX.''.$_['upload_msg_06'].' '.$ERRMSG.'';
- }
- }
-}//end Upload_response() *******************************************************
-
-
-
-
-function New_File_Page() { //***************************************************
- global $_, $FORM_COMMON, $INVALID_CHARS;
-?>
-
-
-
'.
- ' '.$_['new_file_msg_02'].
- ''.htmlentities($INVALID_CHARS).'';
- }elseif ($new_name == ""){
- $message .= $EX.''.$_['new_file_msg_03'].'';
- }elseif (file_exists($filename)) {
- $message .= $EX.''.$_['new_file_msg_04'];
- $message .= htmlentities($new_name).'';
- }elseif ($handle = fopen($filename, 'w')) {
- fclose($handle);
- $message .= ''.$_['new_file_msg_05'].' '.htmlentities($new_name);
- $page = "edit";
- $param2 = '&f='.rawurlencode(basename($filename));// for Edit_Page() buttons
- $param3 = '&p=edit'; // for Edit_Page() buttons
- }else{
- $message .= $EX.''.$_['new_file_msg_06'];
- $message .= htmlentities($new_name);
- }
-}//end New_File_response() *****************************************************
-
-
-
-
-function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //************
- //$action = 'Copy' or 'Rename'. $isfile = 1 if acting on a file, not a folder
- global $_, $WEB_ROOT, $ipath, $filename, $FORM_COMMON;
- if ($isfile) { $old_name = $filename; }else{ $old_name = $ipath; }
- if ($isfile) { $new_name = $filename; }else{ $new_name = $ipath; }
- //if ($action == "Copy" ) { $new_name = ordinalize($ipath, basename($filename), $msg); }
-?>
-
-
-
-
';
- $message .= htmlentities($WEB_ROOT.$new_location).'/
';
- }elseif ( !file_exists($filename) ){
- $message .= $EX.''.$msg1.' '.$_['CRM_msg_02'].'
';
- $message .= htmlentities($filename);
- }elseif (file_exists($new_name)) {
- $message .= $EX.''.$msg1.' '.$_['CRM_msg_03'].'
';
- $message .= htmlentities($WEB_ROOT.$new_name).'';
- }elseif ($action($old_name, $new_name)) {
- $message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
- $message .= ' --- '.$msg2.' '.$_['CRM_msg_04'].' ---
';
- $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
- $filename = $new_name; //so edit page knows what to edit
- if ($isfile) { $ipath = Check_path(dirname($filename)); } //if changed,
- else { $ipath = Check_path($filename); } //return to new dir.
- $param1 = '?i='.URLencode_path($ipath);
- $param2 = '&f='.rawurlencode(basename($filename));
- $param3 = '&p=edit';
- }else{
- $message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
- $message .= $EX.''.$_['CRM_msg_05a'].' '.$msg1.' '.$_['CRM_msg_05b'].'
';
- $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
- }
-}//end Copy_Ren_Move_response() ************************************************
-
-
-
-
-function Delete_File_Page() { //************************************************
- global $_, $filename, $FORM_COMMON;
-?>
-
-
-
-
-
'.
- ''.$_['new_folder_msg_02'].
- ''.htmlentities($INVALID_CHARS).'';
- }elseif ($new_name == ""){
- $message .= $EX.''.$_['new_folder_msg_03'].'';
- }elseif (is_dir($new_ipath)) {
- $message .= $EX.''.$_['new_folder_msg_04'].' ';
- $message .= htmlentities($new_ipath).'';
- }elseif (mkdir($new_ipath)) {
- $message .= ''.$_['new_folder_msg_05'].' '.htmlentities($new_name);
- $ipath = $new_ipath; //return to new folder
- $param1 = '?i='.URLencode_path($ipath);
- }else{
- $message .= $EX.''.$_['new_folder_msg_06'].'
';
- $message .= htmlentities($new_name);
- }
-}//end New_Folder_response *****************************************************
-
-
-
-
-function Delete_Folder_Page(){ //***********************************************
- global $_, $WEB_ROOT, $ipath, $FORM_COMMON;
-?>
-
-
-
- /
-
';}
- $message .= '';
- $message .= $BR.$EX.''.$_['edit_caution_01'].' '.$EX.$_['edit_caution_02'].'';
- }
- //**************************************************************************
-}//end if $_SESSION[valid] *****************************************************
-
-
-
-
-//******************************************************************************
-//******************************************************************************
-?>
-
-
-
-
-
';
- }
- }
-
- $_SESSION['last_active_time'] = time();
-
- //If POSTing, verify...
- if ( isset($_POST['nuonce']) ) {
- if ( $_POST['nuonce'] == $_SESSION['nuonce'] ) {
- $VALID_POST = 1;
- }else{
- Logout();
- $message .= $EX.' INVALID POST
';
- }
- }
-}//end Verify_IDLE_POST_etc() //************************************************
-
-
-
-
-function hashit($key){ //*******************************************************
- //This is the super-secret stuff - Keep it secret, keep it safe!
- //If you change anything here, or the $SALT, redo the hash for your password.
- global $SALT;
- $hash = hash('sha256', trim($key).$SALT); // trim off leading & trailing spaces.
- for ( $x=0; $x < 1000; $x++ ) { $hash = hash('sha256', $hash.$SALT); }
- return $hash;
-}//end hashit() ****************************************************************
-
-
-
-
-function undo_magic_quotes(){ //************************************************
-
- function strip_array($var) {
- if (is_array($var)) {return array_map("strip_array", $var); }
- else {return stripslashes($var); }
- } //Note: stripslashes also handles cases when magic_quotes_sybase is on.
-
- if (get_magic_quotes_gpc()) {
- if (isset($_GET)) { $_GET = strip_array($_GET); }
- if (isset($_POST)) { $_POST = strip_array($_POST); }
- if (isset($_COOKIE)) { $_COOKIE = strip_array($_COOKIE); }
- }
-}//end undo_magic_quotes() *****************************************************
-
-
-
-
-function Get_GET() { //*** Get main parameters *********************************
- // i=some/path/, f=somefile.xyz, p=somepage
- global $ipath, $filename, $page, $valid_pages, $param1, $param2, $param3, $message, $EX;
-
- undo_magic_quotes();
-
- if (isset($_GET["i"])) { $ipath = Check_path($_GET["i"]); }else{ $ipath = ""; }
-
- if (isset($_GET["f"])) {
- $filename = $ipath.$_GET["f"];
- if ( !is_file($filename) && $_SESSION['valid'] )//Set $message except for login page.
- { $message .= $EX.' File does not exist: '.htmlentities($filename).'
'; }
- if ( !is_file($filename) ) { $filename = ""; $page = "index"; }
- }else{ $filename = ""; }
-
- if (isset($_GET["p"])) { $page = $_GET["p"]; }
- if (!in_array(strtolower($page), $valid_pages)) { $page = "index"; }
-
- $param1 = '?i='.URLencode_path($ipath);
- if ($filename == "") { $param2 = ""; }else{ $param2 = '&f='.rawurlencode(basename($filename)); }
- if ($page == "" ) { $param3 = ""; }else{ $param3 = '&p='.$page; }
-}//end Get_GET()****************************************************************
-
-
-
-
-function URLencode_path($path){ // don't encode the forward slashes ************
- $TS = ''; // Trailing Slash/
- if (substr($path, -1) == '/' ) { $TS = '/'; } //start with a $TS?
- $path_array = explode('/',$path);
- $path = "";
- foreach ($path_array as $level) { $path .= rawurlencode($level).'/'; }
- $path = rtrim($path,'/').$TS; //end with $TS only if started with one
- return $path;
-}//end URLencode_path($path) ***************************************************
-
-
-
-
-function Check_path($path) { // returns first valid path in some/supplied/path/
- global $message, $EX;
- $invalidpath = $path; //used for message if supplied $path doesn't exist.
- $path = str_replace('\\','/',$path); //Make sure all forward slashes.
- $path = trim($path,"/ ."); // trim slashes, dots, and spaces
-
- //Remove any '.' and '..' parts of the path. Causes issues in www / current / path /
- $pathparts = explode( '/', $path);
- $len = count($pathparts);
- $path = ""; //Cleaned path.
- foreach ($pathparts as $value) { //(More reliable than str_replace(entire_string).)
- if ( !(($value == '.') && (!value == '..')) ) { $path .= $value.'/'; }
- }
-
- $path = trim($path,"/"); // Remove -for now- final trailing slash.
-
- if (strlen($path) < 1) { return ""; } //If at site root
- else {
- if (!is_dir($path) && (strlen($message) < 1))
- { $message .= $EX.' Directory does not exist: '.htmlentities($invalidpath).'
'; }
-
- while ( (strlen($path) > 0) && (!is_dir($path)) ) {
- $path = dirname($path);
- }
-
- $path = $path.'/';
- if ($path == './') { $path = ""; } // ./ means path not found, so clear for root.
- }
-
- return $path;
-}//end Check_path() ************************************************************
-
-
-
-
-function is_empty($path){ //****************************************************
- $empty = false;
- $dh = opendir($path);
- for($i = 3; $i; $i--) { $empty = (readdir($dh) === FALSE); }
- closedir($dh);
- return $empty;
-}//end is_emtpy() //************************************************************
-
-
-
-
-function ordinalize($destination,$filename, &$msg) { //*************************
-//if file_exists(file.txt), ordinalize filename until it doesn't
-//ie: file.txt.001, file.txt.002, file.txt.003 etc...
- global $EX;
-
- $ordinal = 0;
- $savefile = $destination.$filename;
-
- if (file_exists($savefile)) {
-
- $msg .= $EX.' A file with that name already exists in the target directory.
';
-
- while (file_exists($savefile)) {
- $ordinal = sprintf("%03d", ++$ordinal); // 001, 002, 003, etc...
- $savefile = $destination.$filename.'.'.$ordinal;
- }
- $msg .= 'Saving as: "'.htmlentities(basename($savefile)).'"';
- }
- return $savefile;
-}//end ordinalize() filename ***************************************************
-
-
-
-
-function Current_Path_Header(){ //**********************************************
- // Current path. ie: webroot/current/path/
- // Each level is a link to that level.
-
- global $ONESCRIPT, $ipath, $WEB_ROOT;
-
- echo '';
- //Root folder of web site.
- echo ' '.htmlentities(trim($WEB_ROOT, '/')).'/';
- $x=0; //need here for focus() in case at webroot.
-
- if ($ipath != "" ) { //if not at root, show the rest
- $path_levels = explode("/",trim($ipath,'/') );
- $levels = count($path_levels); //If levels=3, indexes = 0, 1, 2 etc...
- $current_path = "";
-
- for ($x=0; $x < $levels; $x++) {
- $current_path .= $path_levels[$x].'/';
- echo '';
- echo htmlentities($path_levels[$x]).'/';
- }
- }//end if (not at root)
- echo '
';
- echo '';
-}//end Current_Path_Header() //*************************************************
-
-
-
-
-function message_box() { //*****************************************************
- global $ONESCRIPT, $param1, $param2, $param3, $message, $page;
-
- if (isset($message)) {
-?>
- '.PHP_EOL;
-}// end show_image() ***********************************************************
-
-
-
-
-function show_favicon(){ //*****************************************************
- global $config_favicon, $DOC_ROOT;
- if (file_exists($DOC_ROOT.$config_favicon)) {
- echo '
';
- }
-}// end show_favicon() *********************************************************
-
-
-
-
-function Timeout_Timer($COUNT, $ID, $CLASS, $ACTION) { //************************
-
- return '';
-
-} //end Timeout_Timer() **************************************************
-
-
-
-
-function Init_Macros(){ //*** ($varibale="some reusable chunk of code")*********
-
-global $ONESCRIPT, $param1, $param2, $INPUT_NUONCE, $FORM_COMMON;
-
-
-$INPUT_NUONCE = ''.PHP_EOL;
-$FORM_COMMON = '
Generate a Password Hash
-
-
-
- 2) Or, use $HASHWORD to store the hash of your password, and set $USE_HASH = 1.
-
-
-
- The hash will be displayed in a yellow message box above that.
-
- 'Make sure the hash ends up in quotes.'
- Make sure to copy ALL of, and ONLY, the hash (no spaces etc). A double-click should select it...
-
- PS: Everything I know about security - you just read...
- Log In
-
';}
- if ( ($attempts >= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
- $message .= 'Please wait '.Timeout_Timer(($LOGIN_DELAY - $elapsed), 'timer0', '', '').' seconds to try again. ';
- return;
- }
-
- //Validate password
- if ($USE_HASH) { $VALID_PASSWORD = (hashit($_POST['password']) == $HASHWORD); }
- else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
-
- //validate login. Ignore attempt if username & password are blank.
- if ( ($_POST['password'] == "") && ($_POST['username'] == "") ) { return;
- }elseif ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
- session_regenerate_id(true);
- $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; //for user consistancy check.
- $_SESSION['valid'] = 1;
- $page = "index";
- unlink($LOGIN_ATTEMPTS); //delete invalid attempt count file
- }else{
- file_put_contents($LOGIN_ATTEMPTS, ++$attempts); //increment & save attempt
- $message = $EX.' INVALID LOGIN ATTEMPT #'.$attempts.'
';
- if ($attempts >= $MAX_ATTEMPTS) {
- $message .= 'Please wait '.Timeout_Timer($LOGIN_DELAY, 'timer0', '', '').' seconds to try again. ';
- }
- }
-}//end Login_response() //******************************************************
-
-
-
-
-function List_Files() { // ...in a vertical table ******************************
-//called from Index Page
-
- global $ONESCRIPT, $ipath, $param1, $ftypes, $fclasses, $excluded_list;
-
- $files = scandir('./'.$ipath);
- natcasesort($files);
-
- echo '';
- foreach ($files as $file) {
-
- $excluded = FALSE;
- if (in_array(basename($file), $excluded_list)) { $excluded = TRUE; };
-
- if (!is_dir($ipath.$file) && !$excluded) {
-
-
-
-
-?>
-
';
- if ($_POST['action'] == 'move') {
- echo ' ('.hsc($_['CRM_txt_02']).')
-
-';
-}//end List_Files() ************************************************************
-
-
-
-
-function Index_Page(){ //*******************************************************
- global $ONESCRIPT, $ipath;
-
- //
- echo '
- '; ?>
- '; ?>
-
-
- B
-
-
-
-
-
';
-
- }elseif ( $too_large_to_edit ) {
- echo ''.$EX.' File contains an invalid character. Edit and view disabled.
';
- }else{
- echo '';
- echo '
';
- echo ' htmlspecialchars() returned and empty string from what may be an otherwise valid file.
';
- echo ' This behavior can be inconsistant from version to version of php.
-
-
-
- ,'?>
-
-
-Some browsers (ie: IE) bog down or become unstable while editing a large file in an HTML <textarea>.
-Adjust $MAX_EDIT_SIZE in the configuration section of OneFileCMS as needed.
-A simple trial and error test can determine a practical limit for a given browser/computer.';
- $too_large_to_view_message =
-'View disabled. Filesize > '.number_format($MAX_VIEW_SIZE).' bytes.
-Click the the file name above to view normally in a browser window.
-Adjust $MAX_VIEW_SIZE in the configuration section of OneFileCMS as needed.
-(The default value for $MAX_VIEW_SIZE is completely arbitrary, and may be adjusted as desired to suit individual perceptions of neccessity.)';
-
- echo ''.$header2;
- echo ''.htmlentities(basename($filename)).'';
- echo '
'.PHP_EOL;
-?>
-
-
-
-
-
-';
-
- if ( $text_editable && $too_large_to_edit && !$too_large_to_view ) {
- $filecontent = htmlspecialchars(file_get_contents($filename), ENT_COMPAT,'UTF-8');
- echo ''.$filecontent.'
';
- }elseif ( $text_editable && $too_large_to_view ){
- echo 'Upload File
-
';
- $message .= htmlentities($WEB_ROOT.$destination).'
Upload cancelled.';
- }else{
- $message .= 'Uploading: "'.htmlentities($filename).'"...';
- $savefile = ordinalize($destination, $filename, $savefile_msg);
- if(move_uploaded_file($_FILES['upload_file']['tmp_name'], $savefile)) {
- $message .= '
Upload successful! '.$savefile_msg;
- } else{
- $message .= '
'.$EX.' Upload failed: '.$ERRMSG.'';
- }
- }
-}//end Upload_response() *******************************************************
-
-
-
-
-function New_File_Page() { //***************************************************
- global $FORM_COMMON, $INVALID_CHARS;
-?>
- New File
-
-
'.
- ' Name contains invalid character(s): '.
- ''.htmlentities($INVALID_CHARS).'';
- }elseif ($new_name == ""){
- $message .= $EX.' New file not created - no name given';
- }elseif (file_exists($filename)) {
- $message .= $EX.' File already exists: ';
- $message .= htmlentities($new_name).'';
- }elseif ($handle = fopen($filename, 'w')) {
- fclose($handle);
- $message .= 'Created file: '.htmlentities($new_name);
- $page = "edit";
- $param2 = '&f='.rawurlencode(basename($filename));// for Edit_Page() buttons
- $param3 = '&p=edit'; // for Edit_Page() buttons
- }else{
- $message .= $EX.' Error - new file not created:
';
- $message .= htmlentities($new_name);
- }
-}//end New_File_response() *****************************************************
-
-
-
-
-function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //************
- //$action = 'Copy' or 'Rename'. $isfile = 1 if acting on a file, not a folder
- global $WEB_ROOT, $ipath, $filename, $FORM_COMMON;
- if ($isfile) { $old_name = $filename; }else{ $old_name = $ipath; }
- if ($isfile) { $new_name = $filename; }else{ $new_name = $ipath; }
- if ($action == "Copy" ) { $new_name = ordinalize($ipath, basename($filename), $msg); }
-?>
-
-
';
- $message .= htmlentities($WEB_ROOT.$new_location).'/
';
- }elseif ( !file_exists($filename) ){
- $message .= $EX.' '.$msg1.' Error - source file does not exist:
';
- $message .= htmlentities($filename);
- }elseif (file_exists($new_name)) {
- $message .= $EX.' '.$msg1.' Error - target filename already exists:
';
- $message .= htmlentities($WEB_ROOT.$new_name).'';
- }elseif ($action($old_name, $new_name)) {
- $message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
- $message .= ' --- '.$msg2.' to ---
';
- $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
- $filename = $new_name; //so edit page knows what to edit
- if ($isfile) { $ipath = Check_path(dirname($filename)); } //if changed,
- else { $ipath = Check_path($filename); } //return to new dir.
- $param1 = '?i='.URLencode_path($ipath);
- $param2 = '&f='.rawurlencode(basename($filename));
- $param3 = '&p=edit';
- }else{
- $message .= ''.htmlentities($WEB_ROOT.$old_name).'
';
- $message .= $EX.' Error during '.$msg1.' from the above to the following:
';
- $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
- }
-}//end Copy_Ren_Move_response() ************************************************
-
-
-
-
-function Delete_File_Page() { //************************************************
- global $filename, $FORM_COMMON;
-?>
- Delete File
-
-
-
- New Folder
-
-
'.
- ' Name contains invalid character(s): '.
- ''.htmlentities($INVALID_CHARS).'';
- }elseif ($new_name == ""){
- $message .= $EX.' New folder not created - no name given.';
- }elseif (is_dir($new_ipath)) {
- $message .= $EX.' Folder already exists: ';
- $message .= htmlentities($new_ipath).'';
- }elseif (mkdir($new_ipath)) {
-
- $message .= 'Created folder: '.htmlentities($new_name);
- $ipath = $new_ipath; //return to new folder
- $param1 = '?i='.URLencode_path($ipath);
- }else{
- $message .= $EX.' Error - new folder not created:
';
- $message .= htmlentities($new_name);
- }
-}//end New_Folder_response *****************************************************
-
-
-
-
-function Delete_Folder_Page(){ //***********************************************
- global $WEB_ROOT, $ipath, $FORM_COMMON;
-?>
- Delete Folder
-
-
- /
-
';}
- $message .= '';
- $message .= $BR.$EX.' CAUTION '.$EX.' You are editing the active copy of OneFileCMS - BACK IT UP & BE CAREFUL !!';
- }
- //**************************************************************************
-}//end if $_SESSION[valid] *****************************************************
-
-
-
-
-//******************************************************************************
-//******************************************************************************
-?>
-
-
-
-
-
- Installation is still as usual, but, now, if you have _onefilecms.css_ in the same folder as _onefilecms.php_, it'll be linked instead of the normal [http://onefilecms.com/style.css](http://onefilecms.com/style.css).
+- Breadcrumb navigation (courtesy of [Self-Evident](https://github.com/Self-Evident/)), CSS file and some minor changes to it
+- Installation is still as usual, but now, if you have _onefilecms.css_ in the same folder as _onefilecms.php_, it'll be linked instead of the normal [http://onefilecms.com/style.css](http://onefilecms.com/style.css).
### 1.1.5
-- Fixed a disallowed redirect vulnerability
Many thanks to Abhi M Balakrishnan from [OWASP Mantra Team](http://www.getmantra.com/) for his help
+- Fixed a disallowed redirect vulnerability
+Many thanks to Abhi M Balakrishnan from [OWASP Mantra Team](http://www.getmantra.com/) for his help
### 1.1.4
From e32e0ad6edb8e326a45a24d4fb08b84902c9930a Mon Sep 17 00:00:00 2001
From: David
';}
+
if ( ($attempts >= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
$message .= hsc($_['login_msg_02a']).' '.Timeout_Timer(($LOGIN_DELAY - $elapsed), 'timer0', '', '').' '.hsc($_['login_msg_02b']);
return;
@@ -1025,8 +1031,8 @@ function Login_response() { //**************************************************
if ($USE_HASH) { $VALID_PASSWORD = (hashit($_POST['password']) == $HASHWORD); }
else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD); }
- //validate login. Ignore attempt if username & password are blank.
- if ( ($_POST['password'] == "") && ($_POST['username'] == "") ) { ; //
+ //validate login.
+ if ( ($_POST['password'] == "") && ($_POST['username'] == "") ) { ; //Ignore attempt if username & password are blank.
}elseif ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
session_regenerate_id(true);
$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; //for user consistancy check.
@@ -1069,14 +1075,14 @@ function List_Files() { // ...in a vertical table ******************************
$type = $fclasses[array_search($ext, $ftypes)];
?>
-
@@ -1098,7 +1104,7 @@ function Index_Page(){ //*******************************************************
natcasesort($folders);
foreach ($folders as $folder) {
echo ''.PHP_EOL;
- svg_icon_folder();
+ echo svg_icon_folder();
echo htmlentities(basename($folder)).' /';
}
echo '';
@@ -1119,10 +1125,10 @@ function Edit_Page_buttons_top($text_editable){ //******************************
?>
+
'; ?>
- '; ?>
+ '; ?>
-
+
B
-
+
'.$EX.hsc($_['edit_txt_02']).'
';
@@ -1201,7 +1207,7 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_
}else{
echo '';
echo ''.$filecontent.'
';
+ $filecontents = hsc(file_get_contents($filename), ENT_COMPAT,'UTF-8');
+ echo ''.$filecontents.'
';
}
}//End Edit_Page ***************************************************************
@@ -1296,7 +1302,7 @@ function Edit_response(){ //***If on Edit page, and [Save] clicked *************
$bytes = file_put_contents($filename, $content);
if ($bytes !== false) {
- $message .= ''.hsc($_['edit_msg_01']).' '.$bytes.' '.hsc($_['edit_msg_02']).'';
+ $message .= ''.hsc($_['edit_msg_01']).' '.$bytes.' '.hsc($_['edit_msg_02']).'
';
}else{
$message .= $EX.''.hsc($_['edit_msg_03']).'';
}
@@ -1439,20 +1445,22 @@ function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //************
//if ($action == "Copy" ) { $new_name = ordinalize($ipath, basename($filename), $msg); }
?>
+
+
-
';
$message .= ' --- '.$msg2.' '.hsc($_['CRM_msg_04']).' ---
';
- $message .= ''.htmlentities($WEB_ROOT.$new_name).'';
+ $message .= ''.htmlentities($WEB_ROOT.$new_name).'
';
$filename = $new_name; //so edit page knows what to edit
if ($isfile) { $ipath = Check_path(dirname($filename)); } //if changed,
else { $ipath = Check_path($filename); } //return to new dir.
@@ -1506,7 +1514,7 @@ function Delete_File_Page() { //************************************************
-
+
';
}else{
- $message .= $EX.''.hsc($_['delete_msg_02']).' "'.htmlentities($filename).'".';
+ $message .= $EX.''.hsc($_['delete_msg_02']).' "'.htmlentities($filename).'".
';
$page = "edit";
}
}//end Delete_File_response() **************************************************
@@ -1590,8 +1598,10 @@ function Delete_Folder_Page(){ //***********************************************
- /
+
'.
+''.hsc($_['too_large_to_edit_01a']).' '.number_format($MAX_EDIT_SIZE).' '.hsc($_['too_large_to_edit_01b']).'
'.
hsc($_['too_large_to_edit_02']).'
'.hsc($_['too_large_to_edit_03']).'
'.hsc($_['too_large_to_edit_04']);
$too_large_to_view_message =
-''.hsc($_['too_large_to_view_01a']).number_format($MAX_VIEW_SIZE).' '.hsc($_['too_large_to_view_01b']).'
'.
+''.hsc($_['too_large_to_view_01a']).' '.number_format($MAX_VIEW_SIZE).' '.hsc($_['too_large_to_view_01b']).'
'.
hsc($_['too_large_to_view_02']).'
'.hsc($_['too_large_to_view_03']).'
'.hsc($_['too_large_to_view_04']);
- echo ''.$header2;
+ echo '
'.$header2.' ';
echo ''.htmlentities(basename($filename)).'';
echo '
'.PHP_EOL;
@@ -1390,7 +1389,7 @@ function New_File_Page() { //***************************************************
?>
-
'.
- ' '.hsc($_['new_file_msg_02']).
+ ' '.hsc($_['new_file_msg_02']).' '.
''.htmlentities($INVALID_CHARS).'';
}elseif ($new_name == ""){
$message .= $EX.''.hsc($_['new_file_msg_03']).'';
}elseif (file_exists($filename)) {
- $message .= $EX.''.hsc($_['new_file_msg_04']);
+ $message .= $EX.''.hsc($_['new_file_msg_04']).' ';
$message .= htmlentities($new_name).'';
}elseif ($handle = fopen($filename, 'w')) {
fclose($handle);
@@ -1430,7 +1429,7 @@ function New_File_response() { //***********************************************
$param3 = '&p=edit'; // for Edit_Page() buttons
}else{
$message .= $EX.''.hsc($_['new_file_msg_06']);
- $message .= htmlentities($new_name);
+ $message .= htmlentities($new_name).'';
}
}//end New_File_response() *****************************************************
@@ -1573,7 +1572,7 @@ function New_Folder_response(){ //**********************************************
if ($invalid){
$message .= $EX.''.hsc($_['new_folder_msg_01']).' '.htmlentities($new_name).'
'.
''.hsc($_['new_folder_msg_02']).
- ''.htmlentities($INVALID_CHARS).'';
+ ' '.htmlentities($INVALID_CHARS).'';
}elseif ($new_name == ""){
$message .= $EX.''.hsc($_['new_folder_msg_03']).'';
}elseif (is_dir($new_ipath)) {
@@ -1612,7 +1611,7 @@ function Delete_Folder_Page(){ //***********************************************
function Delete_Folder_response() { //******************************************
- global $ipath, $param1, $page, $message, $EX;
+ global $_, $ipath, $param1, $page, $message, $EX;
$page = "index"; //Return to index
$foldername = trim($_POST["delete_folder"], '/');
@@ -1672,7 +1671,9 @@ function Load_Selected_Page(){ //***********************************************
function Timer_scripts() { //***************************************************
- global $_;
+ global $_, $page;
+
+ $timeout_warning = '
';
+ if ($_POST['action'] != 'delete') {
+ echo ' ('.hsc($_['CRM_txt_02']).')
';
echo ''.hte($WEB_ROOT).'';
- echo '';
-
- }elseif ($_POST['action'] == 'copy') {
- ; //Coming soon to a computer near you! //#####
- }else{ // $_POST['action'] == 'delete'
- ; //Coming soon to a computer near you! //#####
+ echo '';
}
echo '
';
- $message .= hte($WEB_ROOT.$new_location).'
';
- return;
+ if ($action == 'rename') { //rename = move
+ $msg1 = hsc($_['Ren_Move']); $msg2 = hsc($_['Ren_Moved']);
+ $success_msg = hsc($_['mcd_msg_01']);
}
+ elseif ($action == 'copy') {
+ $msg1 = hsc($_['Copy']); $msg2 = hsc($_['Copied']);
+ $success_msg = hsc($_['mcd_msg_02']);
+ }else{//$action == delete
+ $success_msg = hsc($_['mcd_msg_03']);
+ }
+
+ $isfile = 1;
+ $show_message = 1; //1= show error msg only. 2= show success msg only. 3= show all msg's.
- foreach ($files as $file){
- $old_name = $md_ipath.$file;
- $new_name = $new_location.$file;
- $action = 'rename';
- $msg1 = hsc($_['Ren_Move']);
- $msg2 = hsc($_['Ren_Moved']);
- $isfile = 1;
- $show_msg = 1; //1= show error msg only. 2= show success msg only. 3= show all msg's.
- $errors += Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $msg2, $isfile, $show_msg);
+ if ($action == 'delete') {
+ foreach ($files as $file){
+ $errors += Delete_File_response($ipath.$file, $show_message);
+ }
+ }else { //move or copy
+ $mcd_ipath = $ipath; //$Copy_Ren_Move_response() changes $ipath to $new_location
+ $new_location = trim($_POST['new_location'],'/').'/'; //make sure no leading, and only 1 trailing, slash.
+ if ( !is_dir($new_location) ){
+ $message .= $EX.' '.hsc($_['upload_msg_02']).'
';
+ $message .= ''.hte($WEB_ROOT.$new_location).'
';
+ return;
+ }
+
+ foreach ($files as $file){
+ $old_name = $mcd_ipath.$file;
+ $new_name = $new_location.$file;
+ $errors += Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $msg2, $isfile, $show_message);
+ }
}
$successful = $count - $errors;
if ($errors) { $message .= $EX.' '.$errors.' '.hsc($_['errors']).'. '; }
- $message .= ''.$successful.' '.hsc($_['md_mov_01']).'
';
+ $message .= ''.$successful.' '.$success_msg.'
';
- if ($successful != 0) { //if all errors, don't bother...
- $message .= ''.hsc($_['Old_location']).': '.hsc($WEB_ROOT).$md_ipath.'
';
- $message .= ''.hsc($_['New_location']).': '.hsc($WEB_ROOT).$ipath.'
';
+ if ($action != 'delete') {
+ if ($successful != 0) { //if all errors, don't bother...
+ $message .= '
'.hsc($_['To']).'
';
+ $message .= ': '.hsc($WEB_ROOT).$ipath.'
';
+ }
}
-}//end MD_Action_mov() *********************************************************
-
-
-
-
-function MD_Action_del() { //***************************************************
- global $EX, $message;
- $message .= 'Sorry, not ready yet, but "Coming soon" to a computer near you!
'; //#####
-}//end MD_Action_del() *********************************************************
+}//end MCD_response() **********************************************************
@@ -2360,7 +2420,7 @@ function Load_Selected_Page(){ //***********************************************
elseif ($page == "newfolder") { New_Folder_Page(); }
elseif ($page == "renamefolder") { Copy_Ren_Move_Page(hsc($_['Ren_Move']), hsc($_['Folder']), 'rename_folder', 0); }
elseif ($page == "deletefolder") { Delete_Folder_Page(); }
- elseif ($page == "mdaction") { MD_Action_Page(); }
+ elseif ($page == "mcdaction") { MCD_Page(); }
else { Login_Page(); } //default
}//end Load_Selected_Page() ****************************************************
@@ -2372,17 +2432,18 @@ function Respond_to_POST() {//**************************************************
if ($VALID_POST) {
if (isset($_FILES['upload_file']['name'])) { Upload_response(); }
- elseif ($page == "mdaction") {
- //There must be at least one 'file', and 'action' must = "move" or "delete"
- if (!isset($_POST['mdaction'] )) { $page = "index"; }
- if (!isset($_POST['files']) ) { $page = "index"; }
- if (!isset($_POST['action'])) { $page = "index"; }
- if ( isset($_POST['action']) && ($_POST['action'] != "move") && ($_POST['action'] != "delete") ) {
+ elseif ($page == "mcdaction") {
+ //There must be at least one 'file', and 'action' must = "move", "copy", or "delete"
+ if (!isset($_POST['mcdaction'] )) { $page = "index"; }
+ if (!isset($_POST['files']) ) { $page = "index"; }
+ if (!isset($_POST['action'])) { $page = "index"; }
+ if ( isset($_POST['action']) && ($_POST['action'] != "move") && ($_POST['action'] != "copy") && ($_POST['action'] != "delete") ) {
$page = "index";
}
}
- elseif (isset($_POST["md_action_mov"])) { MD_Action_mov(); }
- elseif (isset($_POST["md_action_del"])) { MD_Action_del(); }
+ elseif (isset($_POST["mcd_mov"] )) { MCD_response('rename'); } //move == rename
+ elseif (isset($_POST["mcd_cpy"] )) { MCD_response('copy'); }
+ elseif (isset($_POST["mcd_del"] )) { MCD_response('delete'); }
elseif (isset($_POST["whattohash"] )) { Hash_response(); }
elseif (isset($_POST["pw"] )) { Change_PWUN_response('pw');}
elseif (isset($_POST["un"] )) { Change_PWUN_response('un');}
@@ -2401,16 +2462,16 @@ function Respond_to_POST() {//**************************************************
-function Timer_scripts() { //***************************************************
- global $_, $page, $TO_WARNING;
+function common_scripts() { //**************************************************
+ global $_, $TO_WARNING;
- $timeout_warning = '
';
}
//end Verify a few $page restrictions ************
@@ -3141,8 +3306,8 @@ function Language_and_config_adjusted_styles() {//******************************
//Don't show path header or admin link on some pages.
$Show_header_and_Admin = true;
-$pages_to_show_admin = array("login","admin","hash","changepw","changeun");
-if ( $Editing_OFCMS || in_array($page, $pages_to_show_admin) ){
+$pages_dont_show_admin = array("login","admin","hash","changepw","changeun");
+if ( $Editing_OFCMS || in_array($page, $pages_dont_show_admin) ){
$Show_header_and_Admin = false;
}
@@ -3170,9 +3335,7 @@ function Language_and_config_adjusted_styles() {//******************************
-
-
-
+
From 0f2bb5bf44ee2da38f6cfda87acf4fbfe060c68e Mon Sep 17 00:00:00 2001
From: David
';
}
-?>
-
-
+
-
+
@@ -1325,7 +1307,7 @@ function Change_PWUN_Page($config_key) { //*************************************
-';
@@ -1579,7 +1569,7 @@ function Table_of_Files($files, $R, $C, $D) { //********************************
function List_Files() { //******************************************************
//called from Index Page
- global $_, $ONESCRIPT, $ipath, $param1, $ftypes, $fclasses, $excluded_list, $INPUT_NUONCE;
+ global $_, $ONESCRIPT, $ipath, $param1, $ftypes, $fclasses, $excluded_list, $INPUT_NUONCE, $CHECKBOX_OFFSET;
$files = scandir('./'.$ipath);
natcasesort($files);
@@ -1607,11 +1597,11 @@ function List_Files() { //******************************************************
//*The parameter for the Select_All() and Confirm_ready() javascript functions
// is the number of form elements before the first file select checkbox.
// As of Version 3.3.18, that number is 7.
- $checkbox_offset = 7;
-
+ $CHECKBOX_OFFSET = 7;
+
if (supports_svg()) { //Checks if IE < 9.
$select_all_attribs = 'TYPE=checkbox NAME=select_all id=select_all VALUE=select_all';
- $select_all_input = '';
+ $select_all_input = '';
echo ''.$select_all_input;
}
@@ -1624,7 +1614,7 @@ function input_mcd($mcd) {
echo ' ';
echo '';
+ '" onclick="return Confirm_ready('.$CHECKBOX_OFFSET.');">';
echo ''; //end class=action
echo ''; //clear select_all
@@ -1664,11 +1654,9 @@ function Index_Page(){ //*******************************************************
function Edit_Page_buttons_top($text_editable,$file_ENC){ //********************
global $_, $ONESCRIPT, $param1, $filename;
- //For [Close] button: if came from admin page, restore admin_ipath
+ //For [Close] button: if came from admin page, return there.
$params = $param1;
- if ($_SESSION['recent_pages'][1] == "admin") {
- $params = '?i='.URLencode_path($_SESSION['admin_ipath']).'&p=admin';
- }
+ if ( $_SESSION['admin_page'] ) { $params .= '&p=admin'; }
?>
-
-
+ '.$R.'';
+ } ?>
+
-
-
+ '.$C.'' ?>
+
-
-
-
-
-
+ '.$D.'';
+ } ?>
+
+
+ ';
+ } ?>
+
- '; ?>
+ '; ?>
'; ?>
-
B
@@ -1569,7 +1559,7 @@ function Table_of_Files($files, $R, $C, $D) { //********************************
';
+ $page = "index";
+ }
+ //If editing OneFileCMS itself, show caution message.
+ elseif ($filename == trim(rawurldecode($ONESCRIPT), '/')) {
$message .= '';
$message .= '';
$message .= $EX.''.hsc($_['edit_caution_01']).' '.$EX.hsc($_['edit_caution_02']).'
';
}
//end Verify a few $page restrictions ************
+
+ Update_Recent_Pages();
}//end if $_SESSION[valid] *************************************
@@ -3304,12 +3289,10 @@ function Language_and_config_adjusted_styles() {//******************************
$Editing_OFCMS = false;
if ( isset($filename) && ($filename == trim(rawurldecode($ONESCRIPT), '/')) ) { $Editing_OFCMS = true; }
-//Don't show path header or admin link on some pages.
-$Show_header_and_Admin = true;
-$pages_dont_show_admin = array("login","admin","hash","changepw","changeun");
-if ( $Editing_OFCMS || in_array($page, $pages_dont_show_admin) ){
- $Show_header_and_Admin = false;
-}
+//Don't show path header on some pages.
+$Show_Path = true;
+$pages_dont_show_path = array("login","admin","hash","changepw","changeun");
+if ( in_array($page, $pages_dont_show_path) ){ $Show_Path = false; } //
//Finish up/prepare to send page contents.
$early_output = ob_get_clean(); // Should be blank unless trouble-shooting.
@@ -3327,7 +3310,7 @@ function Language_and_config_adjusted_styles() {//******************************
echo '';
echo '';
-echo '
';
echo Timeout_Timer($MAX_IDLE_TIME, 'timer0', 'timer timeout', 'LOGOUT');
echo ''.hsc($_['time_out_txt']).' ';
}
//Admin link
-if ($Show_header_and_Admin) {
+if ( $page != "login" && ($_SESSION['admin_page'] === false) ) {
echo ''.hsc($_['Admin']).'';
}elseif ($page != 'login') {
echo '
';
diff --git a/readme.markdown b/readme.markdown
index 269ddcb..4832c9f 100755
--- a/readme.markdown
+++ b/readme.markdown
@@ -1,4 +1,8 @@
-# Current stable version: 3.4
+# Current stable version: 3.4.01
+
+### September 9, 2012
+
+- A couple minor fixes, and some code improvements & cleanup.
### Auguest 29, 2012
@@ -33,7 +37,7 @@ If an external config file is used to store your password and/or hash, make sure
;Possibly The easiest installation process ever!
## Installation
@@ -90,7 +94,7 @@ You can also change the file name of OneFileCMS.php to something else, such as "
### Where's the WYSIWYG? What about syntax highlighting?
-WYSWIWYG editors have been requested, but probably won't become standard, as they'd make it more than one file, sort of defeating the "OneFile" point. Plus, if you're working in PHP or non-HTML code, they're can be more of a hindrance than an asset.
+WYSWIWYG editors have been requested, but probably won't become standard, as they'd make it more than one file, sort of defeating the "OneFile" point. Plus, if you're working in PHP or non-HTML code, they can be more of a hindrance than an asset.
However, just because I don't want to do it, doesn't mean it's impossible. Look for the Edit_Page_form() function. Its textarea can be modified to work with whatever editor you like.
@@ -100,19 +104,21 @@ Yes, of course!
I may not have the time/bandwidth/inclination to implement every feature, but I 'll do what I can. If it's urgent, contact me.
-### This is basically just a file manager with a text editor. Why is it being called a Content Management System?
+### This is basically just a file manager with a text editor- why is it being called a CMS?
-Well, because "OneFileFileManagerTextEditor" just doesn't have the same ring to it...
+Well, because "OneFileCMS" sounds way cooler than "OneFileFileManagerwithTextEditor".
### Multi-Language Support?
-Yes! Currently, English, German, and Spanish are available. (Someone told me he was working on an Esparento translation, but that might have been a joke...)
+Yes! Currently, English, German, and Spanish are available.
+
+If you speak another language and would like to contribute, translations into other languages are welcomed and appreciated! Just use the English language file as a template, and translate each word, phrase, etc., as appropriate. (Someone told me he was working on an Esparento translation, but that might have been a joke...)
### Can I have more than one username/password?
-Yes! Well, sort of - indirectly. Upload or create addional copies of OneFileCMS, but give them different file names.(ie: OneFile1.php and OneFile2.php etc...) Then, in each copy, maintain different user names and passwords. Also, so that one user does not log out the other, change the $session_name config variables.
+Yes! Well, sort of - indirectly. Upload or create addional copies of OneFileCMS, but give them different file names.(ie: OneFile1.php and OneFile2.php etc...) Then, in each copy, maintain different user names and passwords. Also, so that one user does not log out the other, change the value of the $session_name config variables.
-Now, since there is no database or other means of granular control and access logging, multiple users may be kind of pointless. On the other hand, having at least one working backup copy of OneFileCMS available is recommended in case the primary copy gets corrupted.
+Now, since there is no database or other means of granular control and access logging, multiple usernames may be kind of pointless. On the other hand, having at least one working backup copy of OneFileCMS available is recommended in case the primary copy gets corrupted.
## Requirements
@@ -120,8 +126,8 @@ Now, since there is no database or other means of granular control and access lo
(Only tested on versions 5.2.8, 5.2.17, 5.3.3, and 5.4 + )
- File permission privileges on your host
- Javascript enabled browswer
-- And, for OneFileCMS 3+, a browser that supports inline SVG.
- (However, even if your browser doesn't support inline SVG, OneFileCMS will still work, just without any icons.)
+- And a browser that supports inline SVG, but only if you wish to see the icons
+ (If your browser doesn't support inline SVG, OneFileCMS will still work, just without any icons.)
## Credit, License, Et Cetera
@@ -139,9 +145,9 @@ Now, since there is no database or other means of granular control and access lo
- With Chrome, and possibly Safari, issue with Edit page: Clicking browser [back] & then browser [forward], with file changed and not saved. On return (after [forward] clicked), file still has changes, but indicators are green (saved/unchanged). Does not affect FF 7+ or IE 8+.
- Issue with Chrome's XSS filter: Editing some legitimate files with OneFileCMS will trigger the filter and disable much of the javascript provided functionallity, but only while on the edit page with such a file, and only after a [Save].
- The connection is not encrypted (doesn't use SSL), so passwords & usernames are sent in clear text during login.
- (However, this is true of most online login systems, unless SSL or the like is employed.)
+ However, this is true of most online login systems, unless SSL or the like is employed.
- Be aware that only some very basic data & error checking is performed. (But, it's getting better...)
- On Windows, for instance, it was possible to create folders that are subsequently inaccessible and undeletable by Windows. (Yea, I found out the hard way...) (However, I *think* that issue is fixed.)
+ On Windows, for instance, it was possible to create folders that were subsequently inaccessible and undeletable by Windows. (Yea, I found out the hard way...) (However, I *think* that issue is fixed.)
- Anything else?
--------------------------------------------------------------------------------
@@ -150,7 +156,7 @@ Now, since there is no database or other means of granular control and access lo
CONFIGURATION SECTION
-SYSTEM GLOBAL VARIABLES
+SYSTEM SETUP/VARIABLES
DEFAULT LANGUAGE
@@ -172,6 +178,11 @@ GENERATE/OUTPUT THE PAGE
## Change Log
+### 3.4.01
+
+- A couple of minor bux fixes.
+- Some code cleanup & improvements.
+
### 3.3.17 - 3.4.0
- Added option to select and move, copy, or delete multiple files.
@@ -288,7 +299,7 @@ GENERATE/OUTPUT THE PAGE
### 3.1.1
-- Fixed minor issue with data encoding of file to exit in
';
- }
+ $errors = 0;
+
+ $pathparts = explode( '/', $path);
+
+ foreach ($pathparts as $part) {
- while ( (strlen($path) > 0) && (!is_dir($path)) ) {
- $path = dirname($path);
+ //Check for any '.' and '..' parts of the path to protect directories outside webroot.
+ //They also cause issues in www / current / path /
+ if ( ($part == '.') || ($part == '..') ) {
+ $err_msg .= $EX.' "dot" or "dot dot" segments are not permitted.
'; //##### Needs $_[]
+ $errors++;
+ break;
}
- $path = $path.'/';
- if ($path == './') { $path = ""; } // ./ means path not found, so clear for root.
+ //Check for invalid characters
+ $invalid_chars = str_replace(' /','',$INVALID_CHARS); // The forward slash is not exactly invalid in this context.
+ if ( has_invalid_char($part) ) {
+ $err_msg .= $EX.' Path contains an invalid character: '.$invalid_chars.'
'; //##### Needs $_[]
+ $errors++;
+ break;
+ }
}
- return $path;
+ if (!is_dir($path) && !$errors) { //final overall check
+ $err_msg .= $EX.' Invalid directory name.
'; //##### Needs $_[] $_['check_path_msg_01']
+ $errors++;
+ }
+
+ if ($errors > 0) {
+ if ($show_msg) { $message .= $err_msg; }
+ return false;
+ }
+
+ return $path.'/';
}//end Check_path() ************************************************************
@@ -737,7 +767,7 @@ function supports_svg() { //****************************************************
$ie_ver = substr($USER_AGENT, ($pos_MSIE+5), 1);
$old_ie = ( $ie_ver < 9 );
}
- if ($old_ie) { false; }else{ return true; }
+ return !$old_ie;
}//end supports_svg ************************************************************
@@ -753,12 +783,12 @@ function Current_Path_Header(){ //**********************************************
//Root folder of web site.
echo ' '.hte(trim($WEB_ROOT, '/')).'/';
$x=0; //need here for focus() in case at webroot.
-
+
if ($ipath != "" ) { //if not at root, show the rest
$path_levels = explode("/",trim($ipath,'/') );
$levels = count($path_levels); //If levels=3, indexes = 0, 1, 2 etc...
$current_path = "";
-
+
for ($x=0; $x < $levels; $x++) {
$current_path .= $path_levels[$x].'/';
echo '';
@@ -848,7 +878,7 @@ function Cancel_Submit_Buttons($submit_label, $focus) { //**********************
?>
- '; ?>
+ '; ?>
'; ?>
@@ -1594,11 +1624,6 @@ function List_Files() { //******************************************************
echo '
';
}else{
echo '';
- echo '
'.
- ' '.hsc($_['new_file_msg_02']).' '.
- ''.hte($INVALID_CHARS).'';
+ $msg_new = ''.hte($new_name).'
';
+
+ if (has_invalid_char($new_name)){
+ $message .= $EX.''.hsc($_['Error']).': '.hsc($_['new_file_msg_02']);
+ $message .= ' '.hte($INVALID_CHARS).'
'.$msg_new;
}elseif ($new_name == ""){
$message .= $EX.''.hsc($_['new_file_msg_03']).'';
}elseif (file_exists($filename)) {
- $message .= $EX.''.hsc($_['new_file_msg_04']).' ';
- $message .= hte($new_name).'';
- }elseif ($handle = fopen($filename, 'w')) {
- fclose($handle);
- $message .= ''.hsc($_['new_file_msg_05']).' '.hte($new_name);
- $page = "edit";
+ $message .= $EX.''.hsc($_['new_file_msg_04']).' '.$msg_new;
+ }elseif ( touch($filename) ) {
+ $message .= ''.hsc($_['new_file_msg_05']).' '.$msg_new;
+ $page = "edit"; //Return to edit page.
$param2 = '&f='.rawurlencode(basename($filename));// for Edit_Page() buttons
$param3 = '&p=edit'; // for Edit_Page() buttons
}else{
- $message .= $EX.''.hsc($_['new_file_msg_06']);
- $message .= hte($new_name).'';
+ $message .= $EX.''.hsc($_['new_file_msg_06']).$msg_new;
}
}//end New_File_response() *****************************************************
@@ -2027,7 +2044,7 @@ function Set_Input_width() { //*************************************************
-function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //************
+function CRM_Page($action, $title, $name_id, $isfile) { //**********************
//$action = 'Copy' or 'Rename'. $isfile = 1 if acting on a file, not a folder
global $_, $WEB_ROOT, $ipath, $filename, $FORM_COMMON;
@@ -2042,77 +2059,92 @@ function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //************
-
+
+
-
+
'.hte($WEB_ROOT.$old_name).'
';
+ $com_new = ''.hte($WEB_ROOT.$new_name).'
';
$com_msg = '
'.hte($_['To']).'
';
- $com_msg .= ': '.hte($WEB_ROOT.$new_name).'
';
+ $com_msg .= ': '.$com_old.': '.$com_new;
$err_msg = ''; //Error message.
$scs_msg = ''; //Success message.
- $error = 1; //0= no error, 1 = an error.
+ $error = 1; //0 = no error, 1 = an error. Default to error. Used for return value.
+
+ $invalid_new = has_invalid_char(basename($new_name));
- if ( !is_dir($new_location) ) {
- $err_msg = $EX.''.hsc($msg1.' '.$_['CRM_msg_01']).'
';
- $err_msg .= ''.hte($WEB_ROOT.$new_name).'/
';
+ //Check new name for invalid characters.
+ if ( $invalid_new ) {
+ $err_msg .= $EX.''.hsc($_['Error'].': '.$_['new_file_msg_02']).' '.$invalid_new.'
';
+ $err_msg .= ''.hte(basename($new_name)).'
';
+
+ //Check old parent location. (Unlikely to be false outside a malicious attempt)
+ }elseif ( Check_path($old_location,$show_message) === false ) {
+ $err_msg .= ''.hte($WEB_ROOT.$old_location).'/
';
+
+ //Check new parent location.
+ }elseif ( Check_path($new_location,$show_message) === false ) {
+ $err_msg .= ''.hte($WEB_ROOT.$new_location).'/
';
+
}elseif ( !file_exists($old_name) ) {
- $err_msg = $EX.''.hsc($msg1.' '.$_['CRM_msg_02']).'
';
- $err_msg .= ''.hte($WEB_ROOT.$old_name).'
';
+ $err_msg .= $EX.''.hsc($msg1.' '.$_['CRM_msg_02']).'
'.$com_old;
+
}elseif ( file_exists($new_name) ) {
- $err_msg = $EX.''.hsc($msg1.' '.$_['CRM_msg_03']).'
';
- $err_msg .= ''.hte($WEB_ROOT.$new_name).'
';
- }elseif ($action($old_name, $new_name)) {
- $scs_msg = ''.hsc($msg1.' '.$_['successful']).'
'.$com_msg;
- if ($isfile) {
- $ipath = Check_path(dirname($new_name));
+ $err_msg .= $EX.''.hsc($msg1.' '.$_['CRM_msg_03']).'
'.$com_new;
+
+ }elseif ( $action($old_name, $new_name )) {
+ $scs_msg .= ''.hsc($msg1.' '.$_['successful']).'
'.$com_msg;
+ if ($isfile) {
+ $ipath = dirname($new_name).'/';
$filename = $new_name;
- }else { //folder
- $ipath = Check_path($new_name);
+ }else {/*folder*/
+ $ipath = $new_name.'/';
}
$error = 0;
}else{
$err_msg .= $EX.''.hsc($_['CRM_msg_05a'].' '.$msg1).'
'.$com_msg;
}
- if ($show_message & 1) { $message .= $err_msg; } //Show error message.
- if ($show_message & 2) { $message .= $scs_msg; } //Show success message.
+ if ( ($show_message & 1) && $error ) { $message .= $err_msg; } //Show error message.
+ if ( $show_message & 2) { $message .= $scs_msg; } //Show success message.
//Prior page should be either index or edit
$page = $_SESSION["recent_pages"][1];
$param1 = '?i='.URLencode_path($ipath);
- $param2 = '&f='.rawurlencode(basename($filename));
+ if ($isfile) {$param2 = '&f='.rawurlencode(basename($filename));}
return $error; //
-}//end Copy_Ren_Move_response() ************************************************
+}//end CRM_response() **********************************************************
@@ -2160,50 +2192,29 @@ function Delete_File_response($del_file = "", $show_message = 3){ //************
-function New_Folder_Page() { //*************************************************
- global $_, $FORM_COMMON, $INVALID_CHARS;
-?>
-
-
-
';
- $message .= ''.hsc($_['new_folder_msg_02']).' '.hte($INVALID_CHARS).'';
+ $msg_new = ''.hte($new_name).'
';
+
+ if (has_invalid_char($new_name)){
+ $message .= $EX.''.hsc($_['Error']).': '.hsc($_['new_folder_msg_02']);
+ $message .= ' '.hte($INVALID_CHARS).'
'.$msg_new;
}elseif ($new_name == ""){
$message .= $EX.''.hsc($_['new_folder_msg_03']).'';
}elseif (is_dir($new_ipath)) {
- $message .= $EX.''.hsc($_['new_folder_msg_04']).' ';
- $message .= ''.hte($WEB_ROOT.$new_ipath).'
';
+ $message .= $EX.''.hsc($_['new_folder_msg_04']).' '.$msg_new;
}elseif (mkdir($new_ipath)) {
- $message .= ''.hsc($_['new_folder_msg_05']).' '.hte($new_name).'
';
+ $message .= ''.hsc($_['new_folder_msg_05']).' '.$msg_new;
$ipath = $new_ipath; //return to new folder
$param1 = '?i='.URLencode_path($ipath);
+
}else{
- $message .= $EX.''.hsc($_['new_folder_msg_06']).':
';
- $message .= ''.hte($new_name).'
';
+ $message .= $EX.''.hsc($_['new_folder_msg_06']).':
'.$msg_new;
}
}//end New_Folder_response *****************************************************
@@ -2217,7 +2228,7 @@ function Delete_Folder_Page(){ //***********************************************
';
+ $mcd_ipath = $ipath; //$CRM_response() changes $ipath to $new_location
+
+ //Trim whitespace & slashes, leaving only 1 trailing slash.
+ $new_location = trim($_POST['new_location'],"\x00..\x20/").'/';
+ if ( Check_path($new_location, $show_message) === false ){
$message .= ''.hte($WEB_ROOT.$new_location).'
';
return;
}
foreach ($files as $file){
- $old_name = $mcd_ipath.$file;
- $new_name = $new_location.$file;
- $errors += Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $isfile, $show_message);
+ $_POST['old_name'] = $mcd_ipath.$file;
+ $_POST['new_name'] = $new_location.$file;
+ $errors += CRM_response($action, $msg1, $isfile, $show_message);
}
}
@@ -2370,6 +2385,9 @@ function Page_Title(){ //***
';
}
//end Verify a few $page restrictions ************
-
+
Update_Recent_Pages();
}//end if $_SESSION[valid] *************************************
From 717bfb78bbf39982d8b9ffe1308ee807acc54299 Mon Sep 17 00:00:00 2001
From: David
';
}
}
@@ -554,7 +540,7 @@ function Error_reporting_and_early_output($show_status = 0, $show_types = 0) {//
-function Update_Recent_Pages($pop_current = 0) { //*****************************
+function Update_Recent_Pages() { //*********************************************
global $page;
$recent_pages = array("");
@@ -563,15 +549,11 @@ function Update_Recent_Pages($pop_current = 0) { //*****************************
if (!isset($_SESSION['recent_pages'])) { $_SESSION['recent_pages'] = array(""); }
$pages = count($_SESSION['recent_pages']) - 1;
- //Reverse so index [0] is oldest page (re-reversed at end of function)
+ //Re-reverse so index [0] is oldest page (reversed at end of function)
$_SESSION['recent_pages'] = array_reverse($_SESSION['recent_pages']);
- //Sometimes we just want to discard the most recent page.
- if ($pop_current) {
- array_pop($_SESSION['recent_pages']);
- }
- //Only if actually a new new page, add to arrray of recent_pages
- elseif ( $page != $_SESSION['recent_pages'][$pages] ) {
+ //Only update if actually a new page
+ if ( $page != $_SESSION['recent_pages'][$pages] ) {
$_SESSION['recent_pages'][$pages+1] = $page;
$pages = count($_SESSION['recent_pages']);
}
@@ -579,7 +561,7 @@ function Update_Recent_Pages($pop_current = 0) { //*****************************
//Only need 3 most recent pages (increase if needed)
if ($pages > 3) { array_shift($_SESSION['recent_pages']); }
- //Reverse order so the current page is index [0]
+ //Reverse order so index [0] is the current page
$_SESSION['recent_pages'] = array_reverse($_SESSION['recent_pages']);
}//end Update_Recent_Pages() ***************************************************
@@ -608,16 +590,21 @@ function Get_GET() { //*** Get main parameters *********************************
// i=some/path/, f=somefile.xyz, p=somepage
// $ipath , $filename , $page
// Get_GET() should not be called unless $_SESSION['valid'] == 1
- global $_, $ipath, $filename, $page, $valid_pages, $VALID_POST, $param1, $param2, $param3, $EX, $message;
+ global $_, $ipath, $filename, $page, $valid_pages, $param1, $param2, $param3, $EX, $message;
//Initialize & validate $ipath
- if (isset($_GET["i"])) { $ipath = Check_path($_GET["i"]); } else { $ipath = ""; }
+ if (isset($_GET["i"])) {
+ $ipath = Check_path($_GET["i"],1);
+ if ( $ipath === false || !is_dir($ipath)) { $ipath = ""; }
+ }else {
+ $ipath = "";
+ }
//Initialize & validate $filename
if (isset($_GET["f"])) { $filename = $ipath.$_GET["f"]; } else { $filename = ""; }
if ( ($filename != "") && !is_file($filename) ) {
$message .= $EX.''.hsc($_['get_get_msg_01']).' ';
- $message .= hte(dirname($filename)).'/'.hte(basename($filename)).'
';
+ $message .= hte(dir_name($filename)).''.hte(basename($filename)).'
';
$filename = "";
}
@@ -626,9 +613,6 @@ function Get_GET() { //*** Get main parameters *********************************
if (!in_array($page, $valid_pages)) {
$message .= $EX.hsc($_['get_get_msg_02']).' '.hte($page).'
';
$page = "index"; //If invalid $_GET["p"]
- }elseif ($page == "mcdaction" && !$VALID_POST ){ //not likely, but just in case.
- $message .= hsc($_['get_get_msg_03']).": $page
";
- $page = "index";
}
//Pages that require a valid $filename
@@ -647,6 +631,66 @@ function Get_GET() { //*** Get main parameters *********************************
+function Verify_page_conditions() { //******************************************
+ global $_, $ONESCRIPT, $ipath, $filename, $page, $EX, $message, $VALID_POST;
+
+ //If exited admin pages, restore $ipath
+ if ( ($page == "index") && $_SESSION['admin_page'] ) {
+ //Unless clicked www/some/path/ from edit or copy page.
+ if ( ($_SESSION['recent_pages'][1] != 'edit') && ($_SESSION['recent_pages'][1] != 'copy') ){
+ $ipath = $_SESSION['admin_ipath'];
+ $param1 = '?i='.URLencode_path($ipath);
+ }
+ $_SESSION['admin_page'] = false;
+ $_SESSION['admin_ipath'] = '';
+ }
+ //Don't load login screen when already in a valid session.
+ //$_SESSION['valid'] may be false after Respond_to_POST()
+ elseif ( ($page == "login") && $_SESSION['valid'] ) { $page = "index"; }
+
+ elseif ( $page == "logout" ) {
+ Logout();
+ $message .= hsc($_['logout_msg']);
+ }
+ //Don't load delete or rename folder pages at webroot.
+ elseif ( ($page == "deletefolder" || $page == "renamefolder") && ($ipath == "") ) {
+ $page = "index";
+ }
+ //Don't load delete folder page if folder not empty.
+ elseif ( ($page == "deletefolder") && !is_empty($ipath) ) {
+ $message .= $EX.''.hsc($_['folder_del_msg']).'
';
+ $page = "index";
+ }
+ //If page reloaded, or malicious page load...
+ elseif ($page == "mcdaction" && !$VALID_POST ){
+ $_POST = "";
+ $page = "index";
+ }
+ elseif ($page == "mcdaction") {
+ //There must be at least one 'file', and 'action' must = "move", "copy", or "delete"
+ if (!isset($_POST['mcdselect'] )) { $page = "index"; }
+ elseif (!isset($_POST['files']) ) { $page = "index"; }
+ elseif (!isset($_POST['action'])) { $page = "index"; }
+ elseif ( ($_POST['action'] != "move") && ($_POST['action'] != "copy") && ($_POST['action'] != "delete") ) {
+ $page = "index";
+ }
+ }
+ //if size of $_POST > post_max_size, PHP only returns empty $_POST & $_FILE arrays.
+ elseif ( ($page == "uploaded") && !$VALID_POST ) {
+ $message .= $EX.' '.hsc($_['upload_error_01a']).' '.ini_get('post_max_size').' '.hsc($_['upload_error_01b']).'
';
+ $page = "index";
+ }
+ //If editing OneFileCMS itself, show caution message.
+ elseif ($filename == trim(rawurldecode($ONESCRIPT), '/')) {
+ $message .= '';
+ $message .= '';
+ $message .= $EX.''.hsc($_['edit_caution_01']).' '.$EX.hsc($_['edit_caution_02']).'
';
+ }
+}//end Verify_page_conditions() //**********************************************
+
+
+
+
function URLencode_path($path){ // don't encode the forward slashes ************
$TS = ''; // Trailing Slash/
if (substr($path, -1) == '/' ) { $TS = '/'; } //start with a $TS?
@@ -660,6 +704,16 @@ function URLencode_path($path){ // don't encode the forward slashes ************
+function dir_name($path){ //****************************************************
+ //Modified dirname().
+ $parent = dirname($path);
+ if ($parent == "." || $parent == "/" || $parent == '\\') { return ""; }
+ return $parent.'/';
+}//end dir_name() //************************************************************
+
+
+
+
function has_invalid_char($string) { //*****************************************
global $INVALID_CHARS, $INVALID_CHARS_array;
foreach ($INVALID_CHARS_array as $bad_char) {
@@ -672,17 +726,16 @@ function has_invalid_char($string) { //*****************************************
function Check_path($path, $show_msg = false) { //******************************
- // check for valid existing $path.
+ // check for invalid characters & "dot dot" segments.
global $_, $WEB_ROOT, $message, $EX, $INVALID_CHARS;
$path = str_replace('\\','/',$path); //Make sure all forward slashes.
$path = trim($path,"\x00..\x20/"); // trim whitespace & slashes
- $err_msg = ""; //
-
if (strlen($path) < 1) { return ""; } // At root.
- $errors = 0;
+ $err_msg = "";
+ $errors = 0;
$pathparts = explode( '/', $path);
@@ -691,25 +744,20 @@ function Check_path($path, $show_msg = false) { //******************************
//Check for any '.' and '..' parts of the path to protect directories outside webroot.
//They also cause issues in www / current / path /
if ( ($part == '.') || ($part == '..') ) {
- $err_msg .= $EX.' "dot" or "dot dot" segments are not permitted.
'; //##### Needs $_[]
+ $err_msg .= $EX.' '.$_['check_path_msg_02'].'
';
$errors++;
break;
}
//Check for invalid characters
- $invalid_chars = str_replace(' /','',$INVALID_CHARS); // The forward slash is not exactly invalid in this context.
+ $invalid_chars = str_replace(' /','',$INVALID_CHARS); //The forward slash is not present in this context.
if ( has_invalid_char($part) ) {
- $err_msg .= $EX.' Path contains an invalid character: '.$invalid_chars.'
'; //##### Needs $_[]
+ $err_msg .= $EX.' '.$_['check_path_msg_03'].' '.$invalid_chars.'
';
$errors++;
break;
}
}
- if (!is_dir($path) && !$errors) { //final overall check
- $err_msg .= $EX.' Invalid directory name.
'; //##### Needs $_[] $_['check_path_msg_01']
- $errors++;
- }
-
if ($errors > 0) {
if ($show_msg) { $message .= $err_msg; }
return false;
@@ -1155,7 +1203,7 @@ function List_Backup($file, $file_url){ //**************************************
global $_, $ONESCRIPT;
clearstatcache ();
- $href = $ONESCRIPT.'?i='.dirname($file_url).'&f='.basename($file_url);
+ $href = $ONESCRIPT.'?i='.dir_name($file_url).'&f='.basename($file_url);
?>
+
';
if ($text_editable && !$too_large_to_edit && !$IS_OFCMS) { //Show save & reset only if editable file
- echo Timeout_Timer($MAX_IDLE_TIME, 'timer1','timer', 'LOGOUT');
+ echo '';
echo '
@@ -1761,69 +1794,76 @@ function Create_Table_for_Listing() { //****************************************
-//#####
-function Get_DIRECTORY_DATA($basic_list) { //***********************************
- global $_, $ONESCRIPT, $ipath, $param1, $ICONS,
+
+function Get_DIRECTORY_DATA() { //**********************************************
+ global $_, $ONESCRIPT, $ipath, $ipath_OS, $param1, $ICONS, $message,
$ftypes, $fclasses, $excluded_list, $stypes, $SHOWALLFILES,
- $DIRECTORY_COUNT, $DIRECTORY_DATA;
+ $DIRECTORY_COUNT, $DIRECTORY_DATA, $ENC_OS;
+
+ //Doesn't use global $filename or $filename_OS in this function (because they shouldn't exist on the Index page)
+ //$filename below is JUST the file's name. In some functions, it's the full/path/filename
+
+ $raw_list = scandir('./'.$ipath_OS); //Get current directory list (unsorted)
+
+ $DIRECTORY_COUNT = 0; //final count to exclude . & .., and possibly $excluded file names
+ foreach ($raw_list as $raw_filename) { //$raw_list is in server's File System encoding
- foreach ($basic_list as $filename) {
+ if ( ($raw_filename == '.') || ($raw_filename == '..') ) {continue;}
- if (in_array($filename, $excluded_list)) {$excluded = TRUE;} else {$excluded = FALSE;}
+ $filename_OS = $ipath_OS.$raw_filename; //for is_dir() & file_exists() below
- //Get file type & check against $stypes (files types to show)
- $filename_parts = explode(".", strtolower($filename));
+ //Normalize filename encoding for general use & display. (UTF-8, which may not be same as the server's File System)
+ if ($ENC_OS != 'UTF-8') {$filename = Convert_encoding($raw_filename,'UTF-8');}
+ //Get file .ext & check against $stypes (files types to show)
+ $filename_parts = explode(".", mb_strtolower($filename));
+
+ //First check for no $ext: "filename" or ".filename"
$segments = count($filename_parts);
- //Check for no $ext: "filename" or ".filename"
if( $segments === 1 || ( ($segments === 2) && ($filename_parts[0] === ""))) {
$ext = '';
} else { $ext = end($filename_parts); }
+ //Check $filename & $ext against white & black lists. If not to be shown, get next $filename...
if ($SHOWALLFILES || in_array($ext, $stypes)) { $SHOWTYPE = TRUE; } else { $SHOWTYPE = FALSE; }
-
- //Used to not show rename & delete options for active copy of OneFileCMS.
+ if (in_array($filename, $excluded_list)) {$excluded = TRUE;} else {$excluded = FALSE;}
+ if ( !$SHOWTYPE || $excluded ) { continue; }
+
+ //Used to hide rename & delete options for active copy of OneFileCMS.
$IS_OFCMS = 0;
if ( $ipath.$filename == trim($_SERVER['SCRIPT_NAME'], '/') ) { $IS_OFCMS = 1; }
- //If $filename is to be shown, save data...
- if ( $SHOWTYPE && !$excluded ) {
-
- //Set icon type based on if dir, or file type ($ext).
- if (is_dir($ipath.$filename)) { $type = 'dir'; }
- else { $type = $fclasses[array_search($ext, $ftypes)]; }
-
- //Determine icon to show
- if (in_array($type,$fclasses)) { $icon = $ICONS[$type];}
- elseif ($type == 'dir') { $icon = $ICONS['folder']; }
- else { $icon = $ICONS['bin']; } //default
+ //Set icon type based on if dir, or file type ($ext).
+ if (is_dir($filename_OS)) { $type = 'dir'; }
+ else { $type = $fclasses[array_search($ext, $ftypes)]; }
+
+ //Determine icon to show
+ if (in_array($type,$fclasses)) { $icon = $ICONS[$type];}
+ elseif ($type == 'dir') { $icon = $ICONS['folder']; }
+ else { $icon = $ICONS['bin']; } //default
- //Get file size & date. Check if file_exists() in case of encoding conflicts with filename.
- if (file_exists($ipath.$filename)) {
- $file_size_raw = filesize($ipath.$filename);
- $file_time_raw = filemtime($ipath.$filename);
- } else {
- $file_size_raw = -1; //Use -1 as an unobtrusive, but obvious, error flag.
- $file_time_raw = 0; //Same as above, except use 0 which is 1970 Jan 1 00:00:00 GMT.
- }
+ //Get file size & date.
+ $file_size_raw = filesize($filename_OS);
+ $file_time_raw = filemtime($filename_OS);
- //Store data
- $DIRECTORY_DATA[$DIRECTORY_COUNT] = array('', '', 0, 0, 0, '');
- $DIRECTORY_DATA[$DIRECTORY_COUNT][0] = $type; //used to determine icon & f_or_f
- $DIRECTORY_DATA[$DIRECTORY_COUNT][1] = $filename;
- $DIRECTORY_DATA[$DIRECTORY_COUNT][2] = $file_size_raw;
- $DIRECTORY_DATA[$DIRECTORY_COUNT][3] = $file_time_raw;
- $DIRECTORY_DATA[$DIRECTORY_COUNT][4] = $IS_OFCMS; //If = 1, Don't show ren, del, ckbox.
- $DIRECTORY_DATA[$DIRECTORY_COUNT][5] = $ext;
- $DIRECTORY_COUNT++;
- }//end if $SHOW...
+ //Store data
+ $DIRECTORY_DATA[$DIRECTORY_COUNT] = array('', '', 0, 0, 0, '');
+ $DIRECTORY_DATA[$DIRECTORY_COUNT][0] = $type; //used to determine icon & f_or_f
+ $DIRECTORY_DATA[$DIRECTORY_COUNT][1] = $filename;
+ $DIRECTORY_DATA[$DIRECTORY_COUNT][2] = $file_size_raw;
+ $DIRECTORY_DATA[$DIRECTORY_COUNT][3] = $file_time_raw;
+ $DIRECTORY_DATA[$DIRECTORY_COUNT][4] = $IS_OFCMS; //If = 1, Don't show ren, del, ckbox.
+ $DIRECTORY_DATA[$DIRECTORY_COUNT][5] = $ext;
+ $DIRECTORY_COUNT++;
}//end foreach file
+
+ return $DIRECTORY_COUNT;
}//end Get_DIRECTORY_DATA() //**************************************************
-function Send_data_to_js() {//**************************************************
+function Send_data_to_js_and_display() {//**************************************
global $DIRECTORY_DATA, $DIRECTORY_COUNT;
//"send" DIRECTORY_DATA to javascript.
$data_for_js = "\n";
echo $data_for_js;
-}//end Send_data_to_js() {//****************************************************
+}//end Send_data_to_js_and_display() {//****************************************
@@ -1880,21 +1920,16 @@ function Index_Page_buttons_top($file_count) { //*******************************
-//#####
+
function Index_Page(){ //*******************************************************
- global $_, $ICONS, $ONESCRIPT, $ipath, $param1, $param3, $HREF_params,
- $ftypes, $fclasses, $DIRECTORY_COUNT, $DIRECTORY_DATA;
+ global $ONESCRIPT, $param1;
init_ICONS_js();
Index_Page_scripts();
- $DIRECTORY_COUNT = 0;
+ $file_count = Get_DIRECTORY_DATA();
- //Get current directory list (unsorted)
- $basic_list = scandir('./'.$ipath);
- $file_count = count($basic_list);
-
- //
@@ -1172,7 +1220,6 @@ function List_Backup($file, $file_url){ //**************************************
-
@@ -1210,7 +1257,7 @@ function Admin_Page() { //******************************************************
-
@@ -1618,9 +1665,9 @@ function List_Files() { //******************************************************
$D = ''.hsc($_['D']).'';
}
- echo ' '.PHP_EOL;
-}// end show_image() ***********************************************************
+}//end show_image() //**********************************************************
@@ -974,7 +951,7 @@ function Timeout_Timer($COUNT, $ID, $CLASS="", $ACTION="") { //*****************
'Start_Countdown('.$COUNT.', "'.$ID.'", "'.$CLASS.'", "'.$ACTION.'");'.
'';
-} //end Timeout_Timer() ********************************************************
+}//end Timeout_Timer() //*******************************************************
@@ -1013,7 +990,7 @@ function Init_Macros(){ //*** ($varibale="some reusable chunk of code")*********
';
-} //end Hash_response() ********************************************************
+}//end Hash_response() //*******************************************************
@@ -1387,7 +1364,7 @@ function Change_PWUN_Page($config_key) { //*************************************
';
foreach ($files as $file) {
$excluded = FALSE;
@@ -1624,7 +1602,7 @@ function Table_of_Files($files, $R, $C, $D) { //********************************
';
-}//end Table_of_Files() //******************************************************
-
+}//end Get_DIRECTORY_DATA() //**************************************************
-function Index_Page(){ //*******************************************************
- global $_, $ICONS, $ONESCRIPT, $ipath, $param1, $ftypes, $fclasses;
- $full_list = Sort_Seperate($ipath, scandir('./'.$ipath));
- $file_count = count($full_list);
-
- echo '
';
+ echo '';
} ?>
@@ -1647,8 +1625,8 @@ function Table_of_Files($files, $R, $C, $D) { //********************************
function List_Files() { //******************************************************
-//called from Index Page
- global $_, $ONESCRIPT, $ipath, $param1, $ftypes, $fclasses, $excluded_list, $INPUT_NUONCE, $CHECKBOX_OFFSET;
+ //called from Index Page
+ global $_, $ONESCRIPT, $ipath, $param1, $ftypes, $fclasses, $excluded_list;
$files = scandir('./'.$ipath);
natcasesort($files);
@@ -1668,40 +1646,37 @@ function List_Files() { //******************************************************
}
echo '
';
}
-}//end Edit_response() *********************************************************
+}//end Edit_response() //*******************************************************
function Upload_Page() { //*****************************************************
- global $_, $ONESCRIPT, $ipath, $param1, $INPUT_NUONCE;
+ global $_, $ONESCRIPT, $ipath, $param1, $INPUT_NUONCE, $UPLOAD_FIELDS;
- //Determine $MAX_FILE_SIZE to upload
- $upload_max_filesize = ini_get('upload_max_filesize'); //This should be < post_max_size,
- $post_max_size = ini_get('post_max_size'); //but, just in case, check both...
+ echo ''.hsc($_['Upload_File']).'
';
+ echo '
';
+ echo hsc($_['upload_txt_04']).' '.ini_get('post_max_size') .' '.hsc($_['upload_txt_02']);
+
+ echo '
'."\n";
+ }
+
+ Cancel_Submit_Buttons(hsc($_['Upload']),"cancel");
+ echo '
';
- }elseif ( ($destination === false) || (($destination != "") && !is_dir($destination))) {
- $message .= $EX.''.hsc($_['upload_msg_02']).'
';
- $message .= ''.hte($destination).'
';
- $message .= hsc($_['upload_msg_03']).'
';
- }else{
- $message .= ''.hsc($_['upload_msg_04']).' '.hte($filename).'
';
- $savefile = ordinalize($destination, $filename, $savefile_msg);
+ $filecount = 0;
+ foreach ($_FILES['upload_file']['name'] as $N => $name) {
+ if ($name == "") { continue; } //ignore empty upload fields
+
+ $filecount++;
+ $filename = $_FILES['upload_file']['name'][$N];
+ $destination = Check_path($_POST["upload_destination"]);
+
+ $MAXUP1 = ini_get('upload_max_filesize');
+ $MAXUP2 = ''; //number_format($_POST['MAX_FILE_SIZE']).' '.hsc($_['bytes']);
+ $ERROR = $_FILES['upload_file']['error'][$N];
- if(move_uploaded_file($_FILES['upload_file']['tmp_name'], $savefile)) {
- $message .= ''.hsc($_['upload_msg_05']).' '.$savefile_msg.'
';
- } else{
- $message .= ''.$EX.''.hsc($_['upload_msg_06']).' '.$ERRMSG.'
';
+ if ( $ERROR == 1 ){ $ERRMSG = hsc($_['upload_err_01']).' upload_max_filesize = '.$MAXUP1;}
+ elseif ( $ERROR == 2 ){ $ERRMSG = hsc($_['upload_err_02']).' MAX_FILE_SIZE = ' .$MAXUP2;}
+ elseif ( $ERROR == 3 ){ $ERRMSG = hsc($_['upload_err_03']); }
+ elseif ( $ERROR == 4 ){ $ERRMSG = hsc($_['upload_err_04']); }
+ elseif ( $ERROR == 5 ){ $ERRMSG = hsc($_['upload_err_05']); }
+ elseif ( $ERROR == 6 ){ $ERRMSG = hsc($_['upload_err_06']); }
+ elseif ( $ERROR == 7 ){ $ERRMSG = hsc($_['upload_err_07']); }
+ elseif ( $ERROR == 8 ){ $ERRMSG = hsc($_['upload_err_08']); }
+ else { $ERRMSG = ''; }
+
+ if ( ($destination === false) || (($destination != "") && !is_dir($destination))) {
+ $message .= $EX.''.hsc($_['upload_msg_02']).'
';
+ $message .= ''.hte($destination).'
';
+ $message .= hsc($_['upload_msg_03']).'
';
+ }else{
+ $message .= ''.hsc($_['upload_msg_04']).' '.hte($filename).'
';
+ $savefile = ordinalize($destination, $filename, $savefile_msg);
+
+ if(move_uploaded_file($_FILES['upload_file']['tmp_name'][$N], $savefile)) {
+ $message .= ''.hsc($_['upload_msg_05']).' '.$savefile_msg.'
';
+ } else{
+ $message .= ''.$EX.''.hsc($_['upload_msg_06']).' '.$ERRMSG.'
';
+ }
}
- }
-}//end Upload_response() *******************************************************
+ }//end foreach $_FILES
+
+ if ($filecount == 0) { $message .= $EX.''.hsc($_['upload_msg_01']).'
'; }
+}//end Upload_response() //*****************************************************
@@ -2024,7 +2002,7 @@ function Upload_response() { //*************************************************
function New_File_or_Folder_Page($title, $id) { //******************************
global $_, $FORM_COMMON, $INVALID_CHARS;
- echo ''.hsc($title).'
';
+ echo ''.hte($title).'
';
echo $FORM_COMMON;
echo '
'.$msg_new; //'Error - new file not created:'
}
-}//end New_File_or_Folder_response *********************************************
+}//end New_File_or_Folder_response //*******************************************
@@ -2089,19 +2067,17 @@ function Set_Input_width() { //*************************************************
$main_width = $MAIN_WIDTH * 1; //set in config section. Default is 810px.
$main_units = substr($MAIN_WIDTH, -2); //should be em, px, or pt
- //convert to em
- if ( $main_units == "px") { $main_width = $main_width / 16 ;}
- elseif ( $main_units == "pt") { $main_width = $main_width / 12 ;}
- else { $main_width = $main_width ;}
-
//convert to em
$root_len = $root_len *.625;
+ if ( $main_units == "px") { $main_width = $main_width / 16 ; }
+ elseif ( $main_units == "pt") { $main_width = $main_width / 12 ; }
+ else { $main_width = $main_width ; }
$input_type_text_width = ($main_width - $root_len).'em';
echo '';
-}//end Set_Input_width() *******************************************************
+}//end Set_Input_width() //*****************************************************
@@ -2135,7 +2111,7 @@ function CRM_Page($action, $title, $name_id, $isfile) { //**********************
'.hsc($msg1.' '.$_['CRM_msg_02']).'
'; //file does not exist
+ $err_msg .= $EX.''.hsc($msg1.' '.$_['CRM_msg_02']).'
';
$bad_name = $old_name;
-
//Check new name & location for invalid chars etc.
}elseif ( Check_path($new_name,$show_message) === false ) {
$bad_name = $new_name;
-
}elseif ( ($new_location != "") && !is_dir($new_location) ) {
- $err_msg .= $EX.''.hsc($msg1.' '.$_['CRM_msg_01']).'
'; //parent does not exist
+ $err_msg .= $EX.''.hsc($msg1.' '.$_['CRM_msg_01']).'
';
$bad_name = $new_location;
-
}elseif ( file_exists($new_name) ) {
$bad_name = $new_name;
- $err_msg .= $EX.''.hsc($msg1.' '.$_['CRM_msg_03']).'
'; //already exists
-
+ $err_msg .= $EX.''.hsc($msg1.' '.$_['CRM_msg_03']).'
';
}elseif ( $action($old_name, $new_name )) {
$scs_msg .= ''.hsc($msg1.' '.$_['successful']).'
'.$com_msg;
if ($isfile) {
@@ -2193,10 +2164,9 @@ function CRM_response($action, $msg1, $isfile, $show_message = 3){ //***********
$ipath = $new_name.'/';
}
$error = 0;
-
}else{
$bad_name = "";
- $err_msg .= $EX.''.hsc($_['CRM_msg_05a'].' '.$msg1).'
'.$com_msg;
+ $err_msg .= $EX.''.hsc($_['CRM_msg_05'].' '.$msg1).'
'.$com_msg;
}
if ($error) { $err_msg .= ''.hte($bad_name).'
'; }
@@ -2210,7 +2180,7 @@ function CRM_response($action, $msg1, $isfile, $show_message = 3){ //***********
if ($isfile & $page == "edit") {$param2 = '&f='.rawurlencode(basename($filename));}
return $error; //
-}//end CRM_response() **********************************************************
+}//end CRM_response() //********************************************************
@@ -2226,7 +2196,7 @@ function Delete_File_Page() { //************************************************
/
"'.hte($foldername).'/" '.hsc($_['delete_folder_msg_03']);
}
-}//end Delete_Folder_response() ************************************************
+}//end Delete_Folder_response() //**********************************************
+
//******************************************************************************
-function MCD_Page($page_title, $action, $classes = 'verify', $focus = 'new_location') {
+function MCD_Page($page_title, $action, $classes = '', $focus = 'new_location') {
global $_, $WEB_ROOT, $ONESCRIPT, $ipath, $param1, $INPUT_NUONCE;
Set_Input_width();
@@ -2310,7 +2282,7 @@ function MCD_Page($page_title, $action, $classes = 'verify', $focus = 'new_locat
echo '
';
echo ''.hte($WEB_ROOT).'';
echo '';
@@ -2320,29 +2292,31 @@ function MCD_Page($page_title, $action, $classes = 'verify', $focus = 'new_locat
Cancel_Submit_Buttons(hsc($page_title), $focus);
//List selected files
- echo '';
+ $count = count($_POST['files']);
+ echo '
-
+
-
-
';
echo '
';
echo '';
-} //end MCD_Page() *************************************************************
+}//end MCD_Page() //************************************************************
function MCD_response($action, $msg1, $success_msg = '') { //*******************
- global $_, $WEB_ROOT, $ipath, $param1, $param2, $param3, $message, $EX, $filename;
+ global $_, $WEB_ROOT, $ipath, $param1, $param2, $param3, $message, $EX, $filename, $WHSPC_SLASH;
$files = $_POST['files']; //List of files to delete (path not included)
$count = count($files);
$errors = 0; //number of failed moves or copies
$isfile = 1; //only working with files, not folders.
- $show_message = 1; //1= show error msg only. 2= show success msg only. 3= show all msg's.
+ $show_message = 1; //1= show error msg only.
if ($action == 'delete') {
foreach ($files as $file){
@@ -2353,7 +2327,7 @@ function MCD_response($action, $msg1, $success_msg = '') { //*******************
$mcd_ipath = $ipath; //$CRM_response() changes $ipath to $new_location
//Trim whitespace & slashes, leaving only 1 trailing slash.
- $new_location = trim($_POST['new_location'],"\x00..\x20/").'/';
+ $new_location = trim($_POST['new_location'], $WHSPC_SLASH).'/';
if ( Check_path($new_location, $show_message) === false ){
$message .= ''.hte($new_location).' '."\n";
- $X = 1;
+
foreach($_POST['files'] as $file) {
+ if ($file == "") {continue;} //Skip blanks. [0] will always be blank.
echo ''.$_['Selected_Files'].': ';
- echo ''."\n";
+ echo ''."\n";
}
echo ''.hte($file).'
';
return;
@@ -2374,13 +2348,13 @@ function MCD_response($action, $msg1, $success_msg = '') { //*******************
$message .= ''.$successful.' '.hsc($success_msg).'
';
if ($action != 'delete') {
- if ($successful > 0) { //if all errors, don't bother...
+ if ($successful > 0) { //"From:" & "To:" lines if any successes.
$message .= '
'.hsc($_['To']).'
';
$message .= ': '.hsc($ipath).'
';
}
}
-}//end MCD_response() **********************************************************
+}//end MCD_response() //********************************************************
@@ -2402,11 +2376,11 @@ function Page_Title(){ //***';
+ echo '
';
echo hsc($_['error_reporting_05']).' ';
echo hsc($_['error_reporting_06']).': ';
echo '';
@@ -856,7 +855,7 @@ function Page_Header(){ //******************************************************
';
@@ -1422,7 +1453,7 @@ function Change_PWUN_response($PWUN, $msg){ //**********************************
//If nothing entered...
if ( ($current_pass == "") && ($new_pwun == "") && ($confirm_pwun == "") ) {
- ;//do nothing.
+ return ;//do nothing.
//If no new & confirm values entered, display $message to that effect.
}elseif ( ($new_pwun == "") && ($confirm_pwun == "") ) {
@@ -1536,7 +1567,7 @@ function Login_response() { //**************************************************
//validate login.
if ( ($_POST['password'] == "") || ($_POST['username'] == "") ) {
- ; //Ignore attempt if either username OR password is blank.
+ return; //Ignore attempt if either username OR password is blank.
}elseif ( $VALID_PASSWORD && ($_POST['username'] == $USERNAME) ) {
session_regenerate_id(true);
$_SESSION['user_agent'] = $_SERVER['HTTP_USER_AGENT']; //for user consistancy check.
@@ -1596,7 +1627,7 @@ function Table_of_Files($files, $R, $C, $D) { //********************************
'.$D.'';
+ echo ''.$D.'';
} ?>
@@ -1686,7 +1717,7 @@ function Index_Page(){ //*******************************************************
else { $files[$F++] = $item; }
}
- //List folders/sub-directores
+ //List folders
echo ' '.hte($title).'
';
echo $FORM_COMMON;
echo '
';
$bad_name = $old_name;
- //Check new name & location for invalid chars etc.
- }elseif ( Check_path($new_name,$show_message) === false ) {
- $bad_name = $new_name;
+ //Check new name for invalid chars, including slashes.
+ }elseif ( has_invalid_char($new_name_only) ) {
+ $err_msg .= $EX.''.hsc($_['new_file_msg_02']).' '.hte($INVALID_CHARS).'
';
+ $bad_name = $new_name_only;
+ //Check new location for invalid chars etc.
+ }elseif ( Check_path($new_location,$show_message) === false ) {
+ $bad_name = $new_location;
}elseif ( ($new_location != "") && !is_dir($new_location) ) {
$err_msg .= $EX.''.hsc($msg1.' '.$_['CRM_msg_01']).'
';
$bad_name = $new_location;
@@ -2191,42 +2226,64 @@ function CRM_response($action, $msg1, $isfile, $show_message = 3){ //***********
-function Delete_File_Page() { //************************************************
- global $_, $filename, $FORM_COMMON;
-?>
-
-
-
- '.hsc($title).'
';
+
+ echo $FORM_COMMON;
+ echo '';
+
+ echo '
';
+ if (rDel($target)) {
+ $scs_msg .= ''.hsc($_['Deleted']).': ';
+ $scs_msg .= ''.hte(basename($target)).'';
+ $ipath = dir_name($target); //Return to parent dir.
+ $param1 = '?i='.URLencode_path($ipath);
$filename = "";
$param2 = "";
$error = 0; //0= no error, 1 = an error.
- }else{
- $err_msg .= $EX.''.hsc($_['delete_msg_02']).' "'.hte($del_file).'".
';
+ }else { //Error
+ $err_msg .= $EX.''.hsc($_['delete_folder_msg_03']).' '.hte($target).'
'; //Error message
$page = $_SESSION['recent_pages'][1];
if ($page == "edit") {
- $filename = $del_file;
- $param2 = '&f='.basename($filename);
+ $filename = $target;
+ $param2 = '&f='.basename($filename);
}
$error = 1;
}
@@ -2235,49 +2292,7 @@ function Delete_File_response($del_file = "", $show_message = 3){ //************
if ($show_message & 2) { $message .= $scs_msg; } //Show success message.
return $error;
-}//end Delete_File_response() //************************************************
-
-
-
-
-function Delete_Folder_Page(){ //***********************************************
- global $_, $WEB_ROOT, $ipath, $FORM_COMMON;
-?>
-
-
-
- ';
- echo '
';
+ List_Selected($_POST['files'],$classes,true);
echo '';
}//end MCD_Page() //************************************************************
@@ -2331,11 +2336,13 @@ function MCD_response($action, $msg1, $success_msg = '') { //*******************
if ($action == 'delete') {
foreach ($files as $file){
- $errors += Delete_File_response($ipath.$file, $show_message);
+ //While unlikely, protect against a malicious attempt
+ if ($file == "") {continue;} //a blank file name would cause $ipath to be deleted.
+ $errors += Delete_response($ipath.$file, $show_message);
}
}else { //move or copy
- $mcd_ipath = $ipath; //$CRM_response() changes $ipath to $new_location
+ $mcd_ipath = $ipath; //CRM_response() changes $ipath to $new_location
//Trim whitespace & slashes, leaving only 1 trailing slash.
$new_location = trim($_POST['new_location'], $WHSPC_SLASH).'/';
@@ -2383,10 +2390,10 @@ function Page_Title(){ //*** '."\n";
-
- foreach($_POST['files'] as $file) {
- if ($file == "") {continue;} //Skip blanks. [0] will always be blank.
- echo ''.$_['Selected_Files'].': ';
- echo ''."\n";
- }
- echo ''.hte($file).'
+
-
+
-
+
@@ -1524,7 +1561,7 @@ function Login_Page() { //******************************************************
';
}//end Table_of_Files() //******************************************************
-function List_Files($files) { //************************************************
+function List_Files($files, $folders) { //************************************************
//called from Index Page
global $_, $ONESCRIPT, $ipath, $param1, $ftypes, $fclasses, $excluded_list;
@@ -1689,10 +1737,15 @@ function input_mcd_action($label, $mcd, $icon="") {
echo input_mcd_action($_['Move'] , 'move' , 'svg_icon_ren' );
echo input_mcd_action($_['Copy'] , 'copy' , 'svg_icon_copy');
echo input_mcd_action($_['Delete'], 'delete', 'svg_icon_del' );
-
+
+ echo '
'.$R.'';
- } ?>
-
-
- '.$C.'' ?>
-
+ echo ''.$R.'';
+ } ?>
+
- '.$D.'';
- } ?>
-
-
- '.$C.''
+ ?>
+
+ '.$D.'';
+ } ?>
+
+ ';
- } ?>
-
+ } ?>
+
- '; ?>
+ '; ?>
'; ?>
@@ -1647,14 +1695,14 @@ function Table_of_Files($files, $R, $C, $D) { //********************************
@@ -2636,6 +2649,36 @@ function Respond_to_POST() { //*************************************************
+function init_ICONS_js() { //***************************************************
+ global $ICONS;
+
+ //Currently, only icons for dir listing needed in js
+?>
+
+/g, ">")
+ .replace(/"/g, """)
+ .replace(/'/g, "'");
+}
+
+
+
function trim($string) {
//trim leading whitespace
@@ -2692,7 +2747,7 @@ function format_number(number, sep) {
result = number.substring(a,b) + result;
if (a > 0) {result = sep + result} //add sep if still have more digits
}
- document.write( result );
+ return result;
}//end format_number()
@@ -2736,7 +2791,7 @@ function Start_Countdown(count, ID, CLASS, Action){
-function FileTimeStamp(php_filemtime, show_date, show_offset){
+function FileTimeStamp(php_filemtime, show_date, show_offset, write_return){
//php's filemtime returns seconds, javascript's date() uses milliseconds.
var FileMTime = php_filemtime * 1000;
@@ -2768,7 +2823,8 @@ function FileTimeStamp(php_filemtime, show_date, show_offset){
if (show_date) { DATETIME = FULLDATE + " " + FULLTIME;}
if (show_offset){ DATETIME += " ("+offset_FULL+")"; }
- document.write( DATETIME );
+ if (write_return) { document.write(DATETIME); }
+ else { return DATETIME; }
}
@@ -2821,6 +2877,124 @@ function Confirm_Submit(action){
+function Index_Page_scripts() { //**********************************************
+ global $_, $ONESCRIPT, $param1, $ipath;
+?>
+
+
; /*Default 1em */
}
-#mcd_submit button{ margin-right: ;} /*Default 1em */
+#mcd_submit button{ margin-right: ;} /*Default 1em*/
.image_info { font-size: ; } /*Default 1em*/
diff --git a/readme.markdown b/readme.markdown
index 71f87e9..72eb7ff 100755
--- a/readme.markdown
+++ b/readme.markdown
@@ -1,4 +1,4 @@
-(Updated: 2014-02-10)
+(Updated: 2014-02-12)
# OneFileCMS
## Yes, that's exactly what it is!
From f331669193860dbd256347e04cb8332bb41c43d4 Mon Sep 17 00:00:00 2001
From: Self-Evident ';
-
- //Header row: | Select All|[ ]| Name | Size | Date |
- echo '
';
-
+ //Header row: | Select All|[ ]|[ ](folders first) Name [ext] | Size | Date |
+
+ // is a dummy input to make sure files[] is always an array for Select_All() & Confirm_Ready().
+?>
+
+
+ ';
- echo ' ';
-
- //For directory content. Will insert the list later via innerHTML.
- echo '';
-
- echo '';
- echo ' ';
- echo '';
- $input_attribs = 'TYPE=checkbox NAME=select_all id=select_all VALUE=select_all';
- echo '';
- echo ' ';
- echo ''.$_['Name'].' '.$_['Size'].' '.$_['Date'].' ';
- echo '
+
+
+ to contain entire list, and buttons at top.
+ //
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
';
- $message .= 'getcwd() == '.getcwd().'
';
+ $message .= $EX.'$CONFIG_FILE '.hsc($_['Not_found']).': '.$CONFIG_FILE.'
';
+ $message .= 'getcwd() == '.hsc(getcwd()).'
';
$CONFIG_FILE = '';
}
@@ -211,7 +218,7 @@ function System_Setup() { //****************************************************
//If specified, clean up & validate $ACCESS_ROOT.
if (!isset($ACCESS_ROOT)) { $ACCESS_ROOT = ''; } //At least make sure it's set.
if (!is_dir($_SERVER['DOCUMENT_ROOT'].'/'.$ACCESS_ROOT) || (Check_path($ACCESS_ROOT,1) === false) ) {
- $message .= $EX.'$ACCESS_ROOT '.$_['Invalid_path'].': '.$ACCESS_ROOT.'
';
+ $message .= $EX.'$ACCESS_ROOT '.hsc($_['Invalid_path']).': '.$ACCESS_ROOT.'
';
$ACCESS_ROOT = '';
}
if ($ACCESS_ROOT != '') { $ACCESS_ROOT = trim($ACCESS_ROOT, ' /').'/';}
@@ -219,18 +226,18 @@ function System_Setup() { //****************************************************
$ACCESS_ROOT_len = mb_strlen($ACCESS_ROOT, $ACCESS_ROOT_enc);
-//Determine if valid units are set for $MAIN_WIDTH. If not, assume px.
-$main_units = substr($MAIN_WIDTH, -2); //should be px, pt, em, or %.
-if ( ($main_units != "px") && ($main_units != "pt") && ($main_units != "em") && (substr($MAIN_WIDTH, -1) != '%')) {
- $MAIN_WIDTH = ($MAIN_WIDTH * 1).'px';
-}
+function validate_units($cssvalue) { //****************
+ //Determine if valid units are set for $cssvalue: px, pt, em, or %.
+ $main_units = substr($cssvalue, -2);
+ if ( ($main_units != "px") && ($main_units != "pt") && ($main_units != "em") && (substr($cssvalue, -1) != '%')) {
+ $cssvalue = ($cssvalue * 1).'px'; //If not, assume px.
+ }
+ return $cssvalue;
+}//end valid_units() //********************************
+$MAIN_WIDTH = validate_units($MAIN_WIDTH);
-//Determine if valid units are set for $WIDE_VIEW_WIDTH. If not, assume px.
-$main_units = substr($WIDE_VIEW_WIDTH, -2); //should be px, pt, em, or %.
-if ( ($main_units != "px") && ($main_units != "pt") && ($main_units != "em") && (substr($WIDE_VIEW_WIDTH, -1) != '%')) {
- $WIDE_VIEW_WIDTH = ($WIDE_VIEW_WIDTH * 1).'px';
-}
+$WIDE_VIEW_WIDTH = validate_units($WIDE_VIEW_WIDTH);
//Requires PHP 5.1, due to changes in some functions.
@@ -276,11 +283,10 @@ function System_Setup() { //****************************************************
//##### #######################################################################
//Regarding hsc() & hte():
//Using mb_detect_encoding() (partly) solves an issue on my XP based test setup.
-//But, mb_detect_encoding() return ASCII as appropriate, which htmlentities doesn't recognize.
-//So, we just change it to UTF-8.
-//However, since everything should be in UTF-8, use of htmlentities() is superfluous
-//and may be replaced with just htmlspecialchars() / hsc().
-//But, the replacement will happen only after additional research to confirm the logic/results.
+//But, mb_detect_encoding() may return ASCII, which htmlentities/speicalchars don't recognize.
+//So, just change $enc to UTF-8, of which ASCII is a subset.
+//Additionally, since everything is displayed in UTF-8, use of htmlentities() is superfluous,
+//and was replaced with just htmlspecialchars() / hsc() in v3.5.01
//##### #######################################################################
function hsc($input) { //*******************************************************
@@ -289,18 +295,12 @@ function hsc($input) { //*******************************************************
return htmlspecialchars($input, ENT_QUOTES, $enc);
}//end hsc() //*****************************************************************
-function hte($input) { //*******************************************************
- $enc = mb_detect_encoding($input);
- if ($enc == 'ASCII') {$enc = 'UTF-8';}
- return htmlentities($input, ENT_QUOTES, $enc);
-}//end hte() //*****************************************************************
-
function Default_Language() { // ***********************************************
global $_;
-// OneFileCMS Language Settings v3.4.23
+// OneFileCMS Language Settings v3.5.01
$_['LANGUAGE'] = 'English';
$_['LANG'] = 'EN';
@@ -344,7 +344,7 @@ function Default_Language() { // ***********************************************
$_['Enter'] = 'Enter';
$_['Error'] = 'Error';
$_['errors'] = 'errors';
-$_['ext'] = 'ext'; // filename.ext(ension)
+$_['ext'] = '.ext'; // filename[.ext]ension
$_['File'] = 'File';
$_['files'] = 'files';
$_['Folder'] = 'Folder';
@@ -374,6 +374,7 @@ function Default_Language() { // ***********************************************
$_['Ren_Move'] = 'Rename / Move';
$_['Ren_Moved'] = 'Renamed / Moved';
$_['folders_first'] = 'folders first'; //## NT ##
+$_['folders_first_info'] = 'Sort folders first, but don\'t change primary sort.'; //## NT ##
$_['New_Folder'] = 'New Folder';
$_['Ren_Folder'] = 'Rename / Move Folder';
$_['Submit'] = 'Submit Request';
@@ -803,14 +804,14 @@ function Get_GET() { //*** Get main parameters *********************************
if (isset($_GET["f"])) { $filename = $ipath.$_GET["f"]; } else { $filename = ""; }
if ( ($filename != "") && !is_file($filename) ) {
$message .= $EX.''.hsc($_['get_get_msg_01']).' ';
- $message .= hte(dir_name($filename)).''.hte(basename($filename)).'
';
+ $message .= hsc(dir_name($filename)).''.hsc(basename($filename)).'
';
$filename = "";
}
//Initialize & validate $page
if (isset($_GET["p"])) { $page = $_GET["p"]; } else { $page = "index"; }
if (!in_array($page, $VALID_PAGES)) {
- $message .= $EX.hsc($_['get_get_msg_02']).' '.hte($page).'
';
+ $message .= $EX.hsc($_['get_get_msg_02']).' '.hsc($page).'
';
$page = "index"; //If invalid $_GET["p"]
}
}//end Get_GET() //*************************************************************
@@ -947,7 +948,7 @@ function Check_path($path, $show_msg = false) { //******************************
-
+//#####
function is_empty($path){ //****************************************************
if ($path == "") {$path = '.';}
$empty = false;
@@ -959,7 +960,7 @@ function is_empty($path){ //****************************************************
-
+//#####
function Sort_Seperate($path, $full_list){ //***********************************
//Sort list, then seperate folders & files
@@ -978,7 +979,7 @@ function Sort_Seperate($path, $full_list){ //***********************************
-
+//#####
function ordinalize($destination,$filename, &$msg) { //*************************
//if file_exists(file.txt), ordinalize filename until it doesn't
//ie: file.txt.001, file.txt.002, file.txt.003 etc...
@@ -995,7 +996,7 @@ function ordinalize($destination,$filename, &$msg) { //*************************
$ordinal = sprintf("%03d", ++$ordinal); // 001, 002, 003, etc...
$savefile = $destination.$filename.'.'.$ordinal;
}
- $msg .= ''.hsc($_['ord_msg_02']).': '.hte(basename($savefile)).'';
+ $msg .= ''.hsc($_['ord_msg_02']).': '.hsc(basename($savefile)).'';
}
return $savefile;
}//end ordinalize() //**********************************************************
@@ -1018,7 +1019,7 @@ function supports_svg() { //****************************************************
-
+//#####
function rCopy( $old_path, $new_path ) { //*************************************
//Recursively copy $old_path to $new_path
global $_, $WHSPC_SLASH, $EX, $message;
@@ -1035,7 +1036,7 @@ function rCopy( $old_path, $new_path ) { //*************************************
while (strlen($test_path) >= strlen($old_path)) {
$test_path = dirname($test_path);
if ( $test_path == $old_path ) {
- $message .= $EX.' '.$_['rCopy_msg_01'].'
';
+ $message .= $EX.' '.hsc($_['rCopy_msg_01']).'
';
return false;
}
}
@@ -1062,7 +1063,7 @@ function rCopy( $old_path, $new_path ) { //*************************************
-
+//#####
function rDel($path){ //********************************************************
//Recursively delete $path & all sub-folders & files.
//Returns number of successful unlinks & rmdirs.
@@ -1111,7 +1112,7 @@ function Current_Path_Header(){ //**********************************************
echo '';
//Root (or $ACCESS_ROOT) folder of web site.
$p1 = '?i='.URLencode_path($ACCESS_ROOT);
- echo hte($unaccessable).''.hte($_1st_accessable).'/';
+ echo hsc($unaccessable).''.hsc($_1st_accessable).'/';
$x=0; //need here for focus() in case at webroot.
if ($remaining_path != "" ) { //if not at root, show the rest
@@ -1123,7 +1124,7 @@ function Current_Path_Header(){ //**********************************************
$current_path .= $path_levels[$x].'/';
$p1 = '?i='.URLencode_path($ACCESS_ROOT.$current_path);
echo '';
- echo hte($path_levels[$x]).'/';
+ echo hsc($path_levels[$x]).'/';
}
}//end if (not at root)
echo '
';
@@ -1150,7 +1151,7 @@ function Page_Header(){ //******************************************************
echo '';
echo '';//
@@ -1352,13 +1353,13 @@ function icon_folder($extra = ""){ //**********************************
-
+//#####
function List_Backup($file, $file_url){ //**************************************
global $_, $ONESCRIPT, $ICONS;
clearstatcache ();
$href = $ONESCRIPT.'?i='.dir_name(trim($file_url,'/')).'&f='.basename($file_url);
- $edit_link = ''.hte(basename($file)).'';
+ $edit_link = ''.hsc(basename($file)).'';
?>
@@ -1380,6 +1406,9 @@ function Admin_Page() { //******************************************************
global $_, $ONESCRIPT, $ONESCRIPT_backup, $ONESCRIPT_file_backup, $CONFIG_backup,
$ipath, $filename, $param1, $param2, $EX, $config_title, $CONFIG_FILE_backup;
+ $CONFIG_FILE_backup_OS = Convert_encoding($CONFIG_FILE_backup);
+ $ONESCRIPT_file_backup_OS = Convert_encoding($ONESCRIPT_file_backup);
+
// Restore/Preserve $ipath prior to admin page in case OneFileCMS is edited (which would change $ipath).
if ( $_SESSION['admin_page'] ) { $ipath = $_SESSION['admin_ipath'];
$param1 = '?i='.URLencode_path($ipath); }
@@ -1411,10 +1440,10 @@ function Admin_Page() { //******************************************************
'.hsc($_['admin_txt_00']).'';
- if (is_file($ONESCRIPT_file_backup)) { List_Backup($ONESCRIPT_file_backup, $ONESCRIPT_backup); }
- if (is_file($CONFIG_FILE_backup)) { List_Backup($CONFIG_FILE_backup, $CONFIG_backup); }
+ if (is_file($ONESCRIPT_file_backup_OS)) { List_Backup($ONESCRIPT_file_backup, $ONESCRIPT_backup); }
+ if (is_file($CONFIG_FILE_backup_OS)) { List_Backup($CONFIG_FILE_backup, $CONFIG_backup); }
echo '
@@ -1529,13 +1530,13 @@ function Change_PWUN_Page($pwun, $type, $page_title, $label_new, $label_confirm)
-
+//#####
//******************************************************************************
function Update_config($search_for, $replace_with, $search_file, $backup_file) {
global $_, $EX, $message;
if ( !is_file($search_file) ) {
- $message .= $EX.' '.$_['Not_found'].': '.$search_file.'
';
+ $message .= $EX.' '.hsc($_['Not_found']).': '.hsc($search_file).'
';
return false;
}
@@ -1554,8 +1555,8 @@ function Update_config($search_for, $replace_with, $search_file, $backup_file) {
}
}
- //This should not happen...
- if (!$found){ $message .= $EX.' '.$_['Not_found'].': '.$search_for.'
'; return false; }
+ //This should not happen, but just in case...
+ if (!$found){ $message .= $EX.' '.hsc($_['Not_found']).': '.hsc($search_for).'
'; return false; }
copy($search_file, $backup_file); // Just in case...
@@ -1569,7 +1570,7 @@ function Update_config($search_for, $replace_with, $search_file, $backup_file) {
-
+//#####
function Change_PWUN_response($PWUN, $msg){ //**********************************
//Update $USERNAME or $HASHWORD. Default $page = changepw or changeun
global $_, $ONESCRIPT, $USERNAME, $HASHWORD, $EX, $message, $page,
@@ -1613,10 +1614,10 @@ function Change_PWUN_response($PWUN, $msg){ //**********************************
//If specified & it exists, update external config file.
if ( $VALID_CONFIG_FILE ) {
- $message .= $_['change_pw_05'].' '.$_['change_pw_06'].'. . . ';
+ $message .= hsc($_['change_pw_05']).' '.hsc($_['change_pw_06']).'. . . ';
$updated = Update_config($search_for, $replace_with, $CONFIG_FILE, $CONFIG_FILE_backup);
}else{ //Update OneFileCMS
- $message .= $_['change_pw_05'].' OneFileCMS . . . ';
+ $message .= hsc($_['change_pw_05']).' OneFileCMS . . . ';
$updated = Update_config($search_for, $replace_with, $ONESCRIPT_file, $ONESCRIPT_file_backup);
}
@@ -1669,7 +1670,7 @@ function Login_Page() { //******************************************************
-
+//#####
function Login_response() { //**************************************************
global $_, $EX, $message, $page, $LOGIN_ATTEMPTS, $MAX_ATTEMPTS, $LOGIN_DELAY, $USERNAME, $HASHWORD;
@@ -1734,21 +1735,21 @@ function Create_Table_for_Listing() { //****************************************
@@ -1760,22 +1761,21 @@ function Create_Table_for_Listing() { //****************************************
-
+//#####
function Get_DIRECTORY_DATA($basic_list) { //***********************************
global $_, $ONESCRIPT, $ipath, $param1, $ICONS,
$ftypes, $fclasses, $excluded_list, $stypes, $SHOWALLFILES,
$DIRECTORY_COUNT, $DIRECTORY_DATA;
-
+
foreach ($basic_list as $filename) {
- $excluded = FALSE;
- if (in_array($filename, $excluded_list)) { $excluded = TRUE; };
+ if (in_array($filename, $excluded_list)) {$excluded = TRUE;} else {$excluded = FALSE;}
//Get file type & check against $stypes (files types to show)
$filename_parts = explode(".", strtolower($filename));
$segments = count($filename_parts);
- //Ignore if no $ext: "filename" or ".filename"
+ //Check for no $ext: "filename" or ".filename"
if( $segments === 1 || ( ($segments === 2) && ($filename_parts[0] === ""))) {
$ext = '';
} else { $ext = end($filename_parts); }
@@ -1786,7 +1786,7 @@ function Get_DIRECTORY_DATA($basic_list) { //***********************************
$IS_OFCMS = 0;
if ( $ipath.$filename == trim($_SERVER['SCRIPT_NAME'], '/') ) { $IS_OFCMS = 1; }
- //Determine if $filename is to be shown, save data
+ //If $filename is to be shown, save data...
if ( $SHOWTYPE && !$excluded ) {
//Set icon type based on if dir, or file type ($ext).
@@ -1798,8 +1798,14 @@ function Get_DIRECTORY_DATA($basic_list) { //***********************************
elseif ($type == 'dir') { $icon = $ICONS['folder']; }
else { $icon = $ICONS['bin']; } //default
- $file_size_raw = filesize($ipath.$filename);
- $file_time_raw = filemtime($ipath.$filename);
+ //Get file size & date. Check if file_exists() in case of encoding conflicts with filename.
+ if (file_exists($ipath.$filename)) {
+ $file_size_raw = filesize($ipath.$filename);
+ $file_time_raw = filemtime($ipath.$filename);
+ } else {
+ $file_size_raw = -1; //Use -1 as an unobtrusive, but obvious, error flag.
+ $file_time_raw = 0; //Same as above, except use 0 which is 1970 Jan 1 00:00:00 GMT.
+ }
//Store data
$DIRECTORY_DATA[$DIRECTORY_COUNT] = array('', '', 0, 0, 0, '');
@@ -1816,6 +1822,36 @@ function Get_DIRECTORY_DATA($basic_list) { //***********************************
+
+function Send_data_to_js() {//**************************************************
+ global $DIRECTORY_DATA, $DIRECTORY_COUNT;
+ //"send" DIRECTORY_DATA to javascript.
+ $data_for_js = "\n";
+ echo $data_for_js;
+}//end Send_data_to_js() {//****************************************************
+
+
+
function Index_Page_buttons_top($file_count) { //*******************************
global $_, $ONESCRIPT, $param1, $ICONS;
@@ -1844,7 +1880,7 @@ function Index_Page_buttons_top($file_count) { //*******************************
-
+//#####
function Index_Page(){ //*******************************************************
global $_, $ICONS, $ONESCRIPT, $ipath, $param1, $param3, $HREF_params,
$ftypes, $fclasses, $DIRECTORY_COUNT, $DIRECTORY_DATA;
@@ -1868,31 +1904,9 @@ function Index_Page(){ //*******************************************************
if ($file_count > 0) { Get_DIRECTORY_DATA($basic_list); }
- echo "\n\n";
-
- //"send" DIRECTORY_DATA to javascript.
- echo "\n";
+ Send_data_to_js();
}//end Index_Page() //**********************************************************
@@ -1907,7 +1921,7 @@ function Edit_Page_buttons_top($text_editable,$file_ENC){ //********************
$set_cookie = "document.cookie='edit_mode=".(!$EDIT_MODE*1)."'; ";
$edit_page = "parent.location='".$ONESCRIPT.$param1.$param2."&p=edit';";
$attribs = 'type=button class=button id=on_off onclick="'.$set_cookie.$edit_page.'"';
- $ON_OFF_button = '
-
+
-
+
+ ()
-
+
-
+
B
+
';
$focus_on = 'old_backup'; //id of filename listed
}else {
@@ -1530,25 +1559,28 @@ function Change_PWUN_Page($pwun, $type, $page_title, $label_new, $label_confirm)
-//#####
+
//******************************************************************************
function Update_config($search_for, $replace_with, $search_file, $backup_file) {
global $_, $EX, $message;
+
+ $search_file_OS = Convert_encoding($search_file);
+ $backup_file_OS = Convert_encoding($backup_file);
- if ( !is_file($search_file) ) {
+ if ( !is_file($search_file_OS) ) {
$message .= $EX.' '.hsc($_['Not_found']).': '.hsc($search_file).'
';
return false;
}
//Read file into an array for searching.
- $search_lines = file($search_file, FILE_IGNORE_NEW_LINES);
+ $search_lines = file($search_file_OS, FILE_IGNORE_NEW_LINES);
//Search start of each $line in (array)$search_lines for (string)$search_for.
//If match found, replace $line with $replace_with, end search.
- $search_len = strlen($search_for);
+ $search_len = mb_strlen($search_for);
$found = false;
foreach ($search_lines as $key => $line) {
- if ( substr($line,0,$search_len) == $search_for ) {
+ if ( mb_substr($line,0,$search_len) == $search_for ) {
$found = true;
$search_lines[$key] = $replace_with;
break 1; //only replace first occurrance of $search_for
@@ -1558,11 +1590,11 @@ function Update_config($search_for, $replace_with, $search_file, $backup_file) {
//This should not happen, but just in case...
if (!$found){ $message .= $EX.' '.hsc($_['Not_found']).': '.hsc($search_for).'
'; return false; }
- copy($search_file, $backup_file); // Just in case...
+ copy($search_file_OS, $backup_file_OS); // Just in case...
$updated_contents = implode("\n", $search_lines);
- if (file_put_contents($search_file, $updated_contents, LOCK_EX) === false) {
+ if (file_put_contents($search_file_OS, $updated_contents, LOCK_EX) === false) {
$message .= $EX.''.hsc($_['update_failed']).'
';
return false;
}else {return true;}
@@ -1570,7 +1602,7 @@ function Update_config($search_for, $replace_with, $search_file, $backup_file) {
-//#####
+
function Change_PWUN_response($PWUN, $msg){ //**********************************
//Update $USERNAME or $HASHWORD. Default $page = changepw or changeun
global $_, $ONESCRIPT, $USERNAME, $HASHWORD, $EX, $message, $page,
@@ -1670,7 +1702,7 @@ function Login_Page() { //******************************************************
-//#####
+
function Login_response() { //**************************************************
global $_, $EX, $message, $page, $LOGIN_ATTEMPTS, $MAX_ATTEMPTS, $LOGIN_DELAY, $USERNAME, $HASHWORD;
@@ -1678,6 +1710,7 @@ function Login_response() { //**************************************************
$_SESSION['valid'] = 0; //Default to failed login.
$attempts = 0;
$elapsed = 0;
+ $LOGIN_ATTEMPTS = Convert_encoding($LOGIN_ATTEMPTS); //$LOGIN_ATTEMPTS only used for filesystem access.
//Check for prior login attempts (but don't increment count just yet)
if (is_file($LOGIN_ATTEMPTS)) {
@@ -1739,17 +1772,17 @@ function Create_Table_for_Listing() { //****************************************
+ ()
+
+ onclick="Sort_and_Show(SORT_by, SORT_order);">
+
-
+
-
+
'.$EX.hsc($_['edit_txt_02']).'
';
}else{
- echo '';
+ //##### where is this needed??? It's not used in Edit_response()
+ //Commented out as of 3.5.02
+ //echo '';
echo '
';
echo hsc($_['edit_txt_03']).'
';
echo hsc($_['edit_txt_04']).''.$filecontents.'
';
}
}//end Edit_Page() //***********************************************************
@@ -2147,14 +2184,14 @@ function Edit_Page() { //*******************************************************
function Edit_response(){ //***If on Edit page, and [Save] clicked *************
- global $_, $EX, $message, $filename;
- $filename = $_POST['filename'];
- $contents = $_POST['contents'];
+ global $_, $EX, $message, $filename, $filename_OS;
- $contents = str_replace("\r\n", "\n", $contents); //Make sure EOL is only newline char.
- $contents = str_replace("\r" , "\n", $contents); //Make sure EOL is only newline char.
+ $contents = $_POST['contents'];
+
+ $contents = str_replace("\r\n", "\n", $contents); //Normalize EOL
+ $contents = str_replace("\r" , "\n", $contents); //Normalize EOL
- $bytes = file_put_contents($filename, $contents);
+ $bytes = file_put_contents($filename_OS, $contents);
if ($bytes !== false) {
$message .= ''.hsc($_['edit_msg_01']).' '.number_format($bytes).' '.hsc($_['edit_msg_02']).'
';
@@ -2174,8 +2211,8 @@ function Upload_Page() { //*****************************************************
if ($max_file_uploads < $UPLOAD_FIELDS) { $UPLOAD_FIELDS = $max_file_uploads; }
//$main_width is used below to determine size (width) of in FF.
- $main_width = $MAIN_WIDTH * 1; //set in config section. Default is 810px.
- $main_units = substr($MAIN_WIDTH, -2); //should be px, pt, or em.
+ $main_width = $MAIN_WIDTH * 1; //set in config section. Default is 810px.
+ $main_units = mb_substr($MAIN_WIDTH, -2); //should be px, pt, or em.
//convert to px. 16px = 12pt = 1em
if ( $main_units == "em") { $main_width = $main_width * 16 ; }
elseif ( $main_units == "pt") { $main_width = $main_width * (16 / 12); }
@@ -2209,7 +2246,7 @@ function Upload_Page() { //*****************************************************
function Upload_response() { //*************************************************
- global $_, $filename, $ipath, $page, $EX, $message, $UPLOAD_FIELDS;
+ global $_, $ipath, $ipath_OS, $page, $EX, $message, $UPLOAD_FIELDS;
$page = "index"; //return to index.
@@ -2218,46 +2255,41 @@ function Upload_response() { //*************************************************
if ($name == "") { continue; } //ignore empty upload fields
$filecount++;
- $filename = $_FILES['upload_file']['name'][$N];
- $destination = $ipath;
- $savefile_msg = '';
+ $filename_up = $ipath.$_FILES['upload_file']['name'][$N]; //just filename, no path.
+ $filename_OS = Convert_encoding($filename_up);
+
+ $savefile_msg = '';
$MAXUP1 = ini_get('upload_max_filesize');
//$MAXUP2 = ''; //number_format($_POST['MAX_FILE_SIZE']).' '.hsc($_['bytes']);
$ERROR = $_FILES['upload_file']['error'][$N];
if ( $ERROR == 1 ){ $ERRMSG = hsc($_['upload_err_01']).' upload_max_filesize = '.$MAXUP1;}
- elseif ( $ERROR == 2 ){ $ERRMSG = hsc($_['upload_err_02']); } //.' MAX_FILE_SIZE = ' .$MAXUP2;}
- elseif ( $ERROR == 3 ){ $ERRMSG = hsc($_['upload_err_03']); }
- elseif ( $ERROR == 4 ){ $ERRMSG = hsc($_['upload_err_04']); }
- elseif ( $ERROR == 5 ){ $ERRMSG = hsc($_['upload_err_05']); }
- elseif ( $ERROR == 6 ){ $ERRMSG = hsc($_['upload_err_06']); }
- elseif ( $ERROR == 7 ){ $ERRMSG = hsc($_['upload_err_07']); }
- elseif ( $ERROR == 8 ){ $ERRMSG = hsc($_['upload_err_08']); }
+ elseif (($ERROR > 1) && ($ERROR < 9)) { $ERRMSG = hsc($_['upload_err_0'.$ERROR]); }
else { $ERRMSG = ''; }
- if ( ($destination === false) || (($destination != "") && !is_dir($destination))) {
+ if ( ($ipath === false) || (($ipath != "") && !is_dir($ipath_OS))) {
$message .= $EX.''.hsc($_['upload_msg_02']).'
';
- $message .= ''.hsc($destination).'
';
+ $message .= ''.hsc($ipath).'
';
$message .= hsc($_['upload_msg_03']).'
';
}else{
- $message .= ''.hsc($_['upload_msg_04']).' '.hsc($filename).'
';
+ $message .= ''.hsc($_['upload_msg_04']).' '.hsc(basename($filename_up)).'
';
if ( isset($_POST['ifexists']) && ($_POST['ifexists'] == 'overwrite') ) {
- $savefile = $destination.$filename;
- if (is_file($savefile)) { $savefile_msg .= hsc($_['upload_msg_07']) ; }
+ if (is_file($filename_OS)) { $savefile_msg .= hsc($_['upload_msg_07']) ; }
}else{ //rename to "file.etc.001" etc...
- $savefile = ordinalize($destination, $filename, $savefile_msg);
+ $filename_up = add_serial_num($filename_up, $savefile_msg);
}
- if(move_uploaded_file($_FILES['upload_file']['tmp_name'][$N], $savefile)) {
+ $filename_OS = Convert_encoding($filename_up);
+ if(move_uploaded_file($_FILES['upload_file']['tmp_name'][$N], $filename_OS)) {
$message .= ''.hsc($_['upload_msg_05']).' '.$savefile_msg.'
';
} else{
$message .= ''.$EX.hsc($_['upload_msg_06']).' '.$ERRMSG.'
';
}
}
}//end foreach $_FILES
-
+
if ($filecount == 0) { $page = "upload"; } //If nothing selected, just reload Upload page.
}//end Upload_response() //*****************************************************
@@ -2280,14 +2312,17 @@ function New_Page($title, $new_f_or_f) { //*************************************
function New_response($post, $isfile){ //***************************************
- global $_, $ipath, $filename, $page, $param1, $param2, $param3, $message, $EX, $INVALID_CHARS, $WHSPC_SLASH;
+ global $_, $ipath, $ipath_OS, $filename, $filename_OS, $page, $param1, $param2, $param3, $message, $EX, $INVALID_CHARS, $WHSPC_SLASH;
$page = "index"; //Return to index if folder, or on error.
- $new_name = trim($_POST[$post], $WHSPC_SLASH); //Trim whitespace & slashes.
-
- if ($isfile) { $f_or_f = "file"; $filename = $ipath.$new_name; }
- else { $f_or_f = "folder"; $new_ipath = $ipath.$new_name.'/'; }
+ $new_name = trim($_POST[$post], $WHSPC_SLASH); //Trim whitespace & slashes.
+
+ $filename = $ipath.$new_name;
+ $filename_OS = Convert_encoding($filename);
+
+ if ($isfile) { $f_or_f = "file"; }
+ else { $f_or_f = "folder"; }
$msg_new = ''.hsc($new_name).'
';
@@ -2299,18 +2334,19 @@ function New_response($post, $isfile){ //***************************************
$page = "new".$f_or_f;
$param3 = '&p=index'; //For [Cancel] button
- }elseif (file_exists($filename)) { //Does file or folder already exist ?
+ }elseif (file_exists($filename_OS)) { //Does file or folder already exist ?
$message .= $EX.''.hsc($_['new_file_msg_04']).' '.$msg_new;
- }elseif ( $isfile && touch($filename) ) { //Create File
+ }elseif ($isfile && touch($filename_OS) ) { //Create File
$message .= ''.hsc($_['new_file_msg_05']).' '.$msg_new; //New File success.
$page = "edit"; //Return to edit page.
$param2 = '&f='.rawurlencode(basename($filename)); //for Edit_Page() buttons
$param3 = '&p=edit'; //for Edit_Page() buttons
- }elseif ( !$isfile && mkdir($new_ipath,0755)) { //Create Folder
+ }elseif (!$isfile && mkdir($filename_OS,0755)) { //Create Folder
$message .= ''.hsc($_['new_file_msg_07']).' '.$msg_new; //New folder success
- $ipath = $new_ipath; //return to new folder
+ $ipath = $filename; //return to new folder
+ $ipath_OS = Convert_encoding($filename);
$param1 = '?i='.URLencode_path($ipath);
}else{
@@ -2328,14 +2364,11 @@ function Set_Input_width() { //*************************************************
// $MAIN_WIDTH: Set in config section, may be in em, px, pt, or %. Ignoring % for now.
// Width of 1 character = .625em = 10px = 7.5pt (1em = 16px = 12pt)
- $main_units = substr($MAIN_WIDTH, -2);
+ $main_units = mb_substr($MAIN_WIDTH, -2);
$main_width = $MAIN_WIDTH * 1;
- $root_enc = mb_detect_encoding($WEB_ROOT.$ACCESS_ROOT); //ASCII? UTF8? etc...
- $root_width = mb_strlen($WEB_ROOT.$ACCESS_ROOT, $root_enc);
-
- $label_enc = mb_detect_encoding($_['New_Location']); //ASCII? UTF8? etc...
- $label_width = mb_strlen($_['New_Location'], $label_enc);
+ $root_width = mb_strlen($WEB_ROOT.$ACCESS_ROOT);
+ $label_width = mb_strlen($_['New_Location']);
//convert to em
$root_width *= .625;
@@ -2361,10 +2394,10 @@ function CRM_Page($action, $title, $action_id, $old_full_name) { //*************
$new_full_name = $old_full_name; //default
- if (is_dir($old_full_name)) {
+ if (is_dir(Convert_encoding($old_full_name))) {
$param1 = '?i='.dir_name($ipath); //If dir, return to parent on [Cancel]
$ACCESS_PATH = dir_name($ACCESS_PATH);
- }
+ }
Set_Input_width();
@@ -2390,11 +2423,11 @@ function CRM_Page($action, $title, $action_id, $old_full_name) { //*************
-
+
function CRM_response($action, $msg1, $show_message = 3){ //********************
//$action = 'rCopy' or 'rename'. Returns 0 if successful, 1 on error.
//$show_message: 0 = none; 1 = errors only; 2 = successes only; 3 = all messages (default).
- global $_, $ipath, $filename, $page, $param1, $param2, $message, $EX, $INVALID_CHARS, $WHSPC_SLASH;
+ global $_, $ipath, $ipath_OS, $filename, $page, $param1, $param2, $message, $EX, $INVALID_CHARS, $WHSPC_SLASH;
$old_full_name = trim($_POST['old_full_name'], $WHSPC_SLASH); //Trim whitespace & slashes.
$new_name_only = trim($_POST['new_name'], $WHSPC_SLASH);
@@ -2403,22 +2436,29 @@ function CRM_response($action, $msg1, $show_message = 3){ //********************
$new_full_name = $new_location.$new_name_only;
$filename = $old_full_name; //default if error.
- $isfile = 0; if (is_file($old_full_name)) { $isfile = 1;} //File or folder?
+ //for function calls that access the server file system, such as rCopy, rename, file_exists, etc...
+ $old_full_name_OS = Convert_encoding($old_full_name);
+ $new_full_name_OS = Convert_encoding($new_full_name);
+ $new_location_OS = Convert_encoding($new_location);
+
+ $isfile = 0; if (is_file($old_full_name_OS)) { $isfile = 1;} //File or folder?
//Common message lines
$com_msg = '
'.hsc($_['To']).'
';
$com_msg .= ': '.hsc($new_full_name).'
';
+ $bad_name = ""; //bad file or folder name (can be either old_ or new_)
+
$err_msg = ''; //Error message.
$scs_msg = ''; //Success message.
- $error = 1; //0 = no error, 1 = an error. Default to error. Used for return value.
+ $error_code = 0; //1 = success (no error), 0 = an error. Used for return value.
//Check old name for invalid chars (like .. ) (Unlikely to be false outside a malicious attempt)
if ( Check_path($old_full_name,$show_message) === false ) {
$bad_name = $old_full_name;
- }elseif ( !file_exists($old_full_name) ) {
+ }elseif ( !file_exists($old_full_name_OS) ) {
$err_msg .= $EX.''.hsc($msg1.' '.hsc($_['CRM_msg_02'])).'
';
$bad_name = $old_full_name;
//Check new name for invalid chars, including slashes.
@@ -2429,45 +2469,43 @@ function CRM_response($action, $msg1, $show_message = 3){ //********************
}elseif ( Check_path($new_location,$show_message) === false ) {
$bad_name = $new_location;
//$new_location must already exist as a directory
- }elseif ( ($new_location != "") && !is_dir($new_location) ) {
+ }elseif ( ($new_location != "") && !is_dir($new_location_OS) ) {
$err_msg .= $EX.''.hsc($msg1.' '.hsc($_['CRM_msg_01'])).'
';
$bad_name = $new_location;
//Don't overwrite existing files.
- }elseif ( file_exists($new_full_name) ) {
+ }elseif ( file_exists($new_full_name_OS) ) {
$bad_name = $new_full_name;
$err_msg .= $EX.''.hsc($msg1.' '.hsc($_['CRM_msg_03'])).'
';
- }elseif ( $action($old_full_name, $new_full_name )) {
- $scs_msg .= ''.hsc($msg1.' '.hsc($_['successful'])).'
'.$com_msg;
- if ($isfile) {
+ }else{ //attempt $action
+ $error_code = $action($old_full_name_OS, $new_full_name_OS);
+ if ( $error_code > 0 ) {
+ $scs_msg .= ''.hsc($msg1.' '.hsc($_['successful'])).'
'.$com_msg;
+ if ($isfile) { $filename = $new_full_name; }
$ipath = $new_location;
- $filename = $new_full_name;
- }else {//folder
- $ipath = $new_full_name.'/';
+ $ipath_OS = $new_location_OS;
+ }else{
+ $err_msg .= $EX.''.hsc($_['CRM_msg_05'].' '.$msg1).'
'.$com_msg;
}
- $error = 0;
- }else{
- $bad_name = "";
- $err_msg .= $EX.''.hsc($_['CRM_msg_05'].' '.$msg1).'
'.$com_msg;
- }
-
- if ($error && ($bad_name !='' )) { $err_msg .= ''.hsc($bad_name).'
'; }
+ }//
- if ( ($show_message & 1) && $error ) { $message .= $err_msg; } //Show error message.
- if ( $show_message & 2) { $message .= $scs_msg; } //Show success message.
+ if (($bad_name !='' ) && ($error_code == 0)) { $err_msg .= ''.hsc($bad_name).'
'; }
+
+ if (($show_message & 1) && ($error_code == 0)) { $message .= $err_msg; } //Show error message.
+ if ( $show_message & 2) { $message .= $scs_msg; } //Show success message.
//Prior page should be either index or edit
$page = $_SESSION['recent_pages'][1];
$param1 = '?i='.URLencode_path($ipath);
if ($isfile & $page == "edit") {$param2 = '&f='.rawurlencode(basename($filename));}
- return $error; //
+ return $error_code; //
}//end CRM_response() //********************************************************
function Delete_response($target, $show_message=3) { //*************************
- global $_, $ipath, $param1, $filename, $param2, $page, $message, $EX;
+ global $_, $ipath, $ipath_OS, $param1, $filename, $param2, $page, $message, $EX;
if ($target == "") { return 0; } //Prevent accidental delete of entire website.
@@ -2481,14 +2519,15 @@ function Delete_response($target, $show_message=3) { //*************************
$err_msg = ''; //On error, set this message.
$scs_msg = ''; //On success, set this message.
- if (rDel($target)) {
+ $error_code = rDel($target);
+ if ($error_code > 0) { // 0 = error, > 0 is number of successes
$scs_msg .= ''.hsc($_['Deleted']).': ';
$scs_msg .= ''.hsc(basename($target)).'';
$ipath = dir_name($target); //Return to parent dir.
+ $ipath_OS = Convert_encoding($ipath);
$param1 = '?i='.URLencode_path($ipath);
$filename = "";
$param2 = "";
- $error = 0; //0= no error, 1 = an error.
}else { //Error
$err_msg .= $EX.''.hsc($_['delete_msg_03']).' '.hsc($target).'
';
$page = $_SESSION['recent_pages'][1];
@@ -2496,21 +2535,21 @@ function Delete_response($target, $show_message=3) { //*************************
$filename = $target;
$param2 = '&f='.basename($filename);
}
- $error = 1;
}
if ($show_message & 1) { $message .= $err_msg; } //Show error message.
if ($show_message & 2) { $message .= $scs_msg; } //Show success message.
- return $error;
+ return $error_code;
}//end Delete_response() //*****************************************************
-
+
function MCD_Page($action, $page_title, $classes = '') { //*********************
//$action = mcd_mov or mcd_cpy or mcd_del
- global $_, $ICONS, $WEB_ROOT, $ONESCRIPT, $ipath, $param1, $filename, $page, $ACCESS_ROOT, $ACCESS_PATH, $INPUT_NUONCE;
+ global $_, $WEB_ROOT, $ONESCRIPT, $ipath, $ipath_OS, $param1, $filename, $page,
+ $ICONS, $ACCESS_ROOT, $ACCESS_PATH, $INPUT_NUONCE, $message;
//Prep for a single file or folder
if( $page == "deletefile" || $page == "deletefolder" ){
@@ -2539,14 +2578,14 @@ function MCD_Page($action, $page_title, $classes = '') { //*********************
Cancel_Submit_Buttons($page_title);
//List selected folders & files
- $full_list = Sort_Seperate($ipath, $_POST['files']);
+ $full_list = Sort_Seperate($ipath, $_POST['files']);
echo '';
echo '
\n";
@@ -1931,7 +1932,7 @@ function Index_Page_buttons_top($file_count) { //*******************************
-function Index_Page(){ //*******************************************************
+function Index_Page() { //******************************************************
global $ONESCRIPT, $ipath_OS, $param1;
init_ICONS_js();
@@ -3076,32 +3077,91 @@ function sort_DIRECTORY(col, direction) { //**************************
+function Init_Dir_table_rows(DIR_LIST) { //***************************
+
+ var row, cell, cells, tr, td;
+
+ for (row = 0; row < DIRECTORY_ITEMS; row++){
+
+ //initialize '."\n";
-
foreach($full_list as $file) {
- if (is_dir($ipath.$file)) { echo ''.hsc($_['Selected_Files']).': '; }
- else { echo ''.$ICONS['folder'].' '.hsc($file).' / '; }
+ $file_OS = Convert_encoding($file);
+ if (is_dir($ipath_OS.$file_OS)) { echo ''.hsc($file).' '; }
+ else { echo ''.$ICONS['folder'].' '.hsc($file).' / '; }
echo ''."\n";
}
@@ -2558,24 +2597,31 @@ function MCD_Page($action, $page_title, $classes = '') { //*********************
function MCD_response($action, $msg1, $success_msg = '') { //*******************
- global $_, $ipath, $filename, $EX, $message, $WHSPC_SLASH;
+ global $_, $ipath, $ipath_OS, $EX, $message, $WHSPC_SLASH;
- $files = $_POST['files']; //List of files to delete (path not included)
- $count = count($files); //Doesn't include any sub-folders & files.
- $errors = 0; //number of failed moves, copies, or deletes - not counting recursion.
+ $files = $_POST['files']; //List of files to delete (path not included)
+ $errors = 0; //number of failed moves, copies, or deletes
+ $successful = 0;
+
+ $new_location = "";
+ if (isset($_POST['new_location'])) {
+ $new_location = $_POST['new_location'];
+ $new_location_OS = Convert_encoding($_POST['new_location']);
+ }
$show_message = 1; //1= show error msg only.
- if ($count == 1) {$show_message = 3;} //show error or success msg.
- if ($action == 'rDel') {
- foreach ($files as $file){
- if ($file == "") {continue;} //a blank file name would cause $ipath to be deleted.
- $errors += Delete_response($ipath.$file, $show_message);
- }
- }elseif ( ($_POST['new_location'] != "") && !is_dir($_POST['new_location']) ) {
+ if ( ($new_location != "") && !is_dir($new_location_OS)) {
$message .= $EX.''.hsc($msg1.' '.$_['CRM_msg_01']).'' .hsc($file).'
';
$message .= ''.hsc($_POST['new_location']).'
';
return;
+ }elseif ($action == 'rDel') {
+ foreach ($files as $file){
+ if ($file == "") {continue;} //a blank file name would cause $ipath to be deleted.
+ $error_code = Delete_response($ipath.$file, $show_message);
+ $successful += $error_code;
+ if ($error_code == 0) {$errors++;}
+ }
}else { //move or rCopy
$mcd_ipath = $ipath; //CRM_response() changes $ipath to $new_location
@@ -2583,15 +2629,15 @@ function MCD_response($action, $msg1, $success_msg = '') { //*******************
$_POST['old_full_name'] = $mcd_ipath.$file;
$_POST['new_name'] = $file;
//$_POST['new_location'] should already be set by the client ( via MCD_Page() ).
- $errors += CRM_response($action, $msg1, $show_message);
+ $error_code = CRM_response($action, $msg1, $show_message);
+ $successful += $error_code;
+ if ($error_code == 0) {$errors++;}
}
}
- $successful = $count - $errors;
-
if ($errors) {$message .= $EX.' '.$errors.' '.hsc($_['errors']).'.
';}
- if ($count > 1) {$message .= ''.$successful.' '.hsc($success_msg).'
';}
+ $message .= ''.$successful.' '.hsc($success_msg).'
';
if ($action != 'rDel') {
if ($successful > 0) { //"From:" & "To:" lines if any successes.
@@ -2631,7 +2677,7 @@ function Page_Title(){ //***'s
-function Build_Directory(target) { //*********************************
- //Build directory & insert into tag of an existing . And, since the alternative/fix/workaround would be a whole bunch more work, IE is currently not supported.
+
- It's probably existed for a while, but I just noticed (v3.4.23) that, on some systems - such as Windows, OneFileCMS doesn't like non-ascii characters in file names. A solution is in the works, but it's not quite ready for prime time...
- With Chrome, and possibly Safari, issue with Edit page: Clicking browser [back] & then browser [forward], with file changed and not saved. On return (after [forward] clicked), file still has changes, but indicators are green (saved/unchanged). Does not affect FF 7+ or IE 8+.
- Issue with Chrome's XSS filter: Editing some legitimate files with OneFileCMS will trigger the filter and disable much of the javascript provided functionallity, but only while on the edit page with such a file, and only after a [Save].
From eb4a7bb44f6ad137e2e00362131c0043e0070f1e Mon Sep 17 00:00:00 2001
From: Self-Evident
@@ -1955,6 +1951,8 @@ function Index_Page(){ //*******************************************************
echo "\n";
Send_data_to_js_and_display();
+
+ Index_Page_onclicks();
}//end Index_Page() //**********************************************************
@@ -2019,7 +2017,7 @@ function Edit_Page_buttons_top($text_editable,$file_ENC){ //********************
function Edit_Page_buttons($text_editable, $too_large_to_edit) { //*************
- global $_, $message, $ICONS, $ONESCRIPT, $param1, $param2, $MAX_IDLE_TIME, $IS_OFCMS, $WYSIWYG_VALID, $EDIT_WYSIWYG;
+ global $_, $message, $ICONS, $MAX_IDLE_TIME, $IS_OFCMS, $WYSIWYG_VALID, $EDIT_WYSIWYG;
//Using ckeditor WYSIWYG editor, button doesn't work. (I don't know why.)
$reset_button = '';
@@ -2034,7 +2032,7 @@ function Edit_Page_buttons($text_editable, $too_large_to_edit) { //*************
}//end if editable
function RCD_button($action, $icon, $label){ //***************
- global $ONESCRIPT, $param1, $param2, $ICONS;
+ global $ICONS;
echo '. And, since the alternative/fix/workaround would be a whole bunch more work, IE is currently not supported.
-
-- It's probably existed for a while, but I just noticed (v3.4.23) that, on some systems - such as Windows, OneFileCMS doesn't like non-ascii characters in file names. A solution is in the works, but it's not quite ready for prime time...
+- As of v3.4.23, doesn't work in IE. It seems IE doesn't support changing the innerHTML of some tags. OneFile builds the directory in javascript, then displays it by changing the innerHTML of a <tbody> tag of an existing <table>. And, since the alternative/fix/workaround would be a whole bunch more work, IE is currently not supported.
- With Chrome, and possibly Safari, issue with Edit page: Clicking browser [back] & then browser [forward], with file changed and not saved. On return (after [forward] clicked), file still has changes, but indicators are green (saved/unchanged). Does not affect FF 7+ or IE 8+.
- Issue with Chrome's XSS filter: Editing some legitimate files with OneFileCMS will trigger the filter and disable much of the javascript provided functionallity, but only while on the edit page with such a file, and only after a [Save].
- The connection is not encrypted (doesn't use SSL), so passwords & usernames are sent in clear text* during login. However, this is true of most online login systems, unless SSL or the like is employed.
From 1ca2639c346cc288c2c2f302d53ad5baeb44c33e Mon Sep 17 00:00:00 2001
From: Self-Evident
';
+
+ if ($backup_found) {
+ echo '
'.hsc($_['OFCMS_requires']).' '.PHP_VERSION_REQUIRED );
+}
+
+
mb_detect_order("UTF-8, ASCII, Windows-1252, ISO-8859-1");
//Get server's File System encoding. Windows NTFS uses ISO-8859-1 or Windows-1252.
@@ -243,20 +257,6 @@ function System_Setup() { //****************************************************
$MAIN_WIDTH = validate_units($MAIN_WIDTH);
$WIDE_VIEW_WIDTH = validate_units($WIDE_VIEW_WIDTH);
-
-//Requires PHP 5.1 or newer, due to changes in some functions.
-define('PHP_VERSION_ID_REQUIRED',50100); //Ex: 5.1.23 is 50123
-define('PHP_VERSION_REQUIRED' ,'5.1 + '); //Used in exit() message.
-
-//The predefined constant PHP_VERSION_ID has only been available since 5.2.7.
-//So, if needed, convert PHP_VERSION (a string) to PHP_VERSION_ID (an integer).
-//Ex: 5.1.23 converts to 50123.
-if (!defined('PHP_VERSION_ID')) {
- $phpversion = explode('.', PHP_VERSION);
- define('PHP_VERSION_ID', ($phpversion[0] * 10000 + $phpversion[1] * 100 + $phpversion[2]));
-}
-
-
ini_set('session.gc_maxlifetime', $MAX_IDLE_TIME + 100); //in case the default is less.
$TO_WARNING = 120; //seconds. When idle time remaining is less than this value, $timeout_warning is displayed
@@ -284,37 +284,6 @@ function System_Setup() { //****************************************************
-function validate_units($cssvalue) { //*****************************************
- //Determine if valid units are set for $cssvalue: px, pt, em, or %.
- $main_units = mb_substr($cssvalue, -2);
- if ( ($main_units != "px") && ($main_units != "pt") && ($main_units != "em") && (mb_substr($cssvalue, -1) != '%')) {
- $cssvalue = ($cssvalue * 1).'px'; //If not, assume px.
- }
- return $cssvalue;
-}//end valid_units() //*********************************************************
-
-
-
-
-function hsc($input) { //*******************************************************
- $enc = mb_detect_encoding($input); //It should always be UTF-8 (or ASCII), but, just in case...
- if ($enc == 'ASCII') {$enc = 'UTF-8';} //htmlspecialchars() doesn't recognize "ASCII"
- return htmlspecialchars($input, ENT_QUOTES, $enc);
-}//end hsc() //*****************************************************************
-
-
-
-
-function Convert_encoding($string, $to_enc = "") { //***************************
- global $ENC_OS;
- //mb_convert_encoding($string, $to_enc, $from_enc)
- if ($to_enc == 'UTF-8') {return mb_convert_encoding($string, 'UTF-8', $ENC_OS);} // Convert to UTF-8
- else /* default */ {return mb_convert_encoding($string, $ENC_OS, 'UTF-8');} // Convert to server's/OS's filesystem enc
-}//end Convert_encoding() //****************************************************
-
-
-
-
function Default_Language() { // ***********************************************
global $_;
// OneFileCMS Language Settings v3.5.01
@@ -552,6 +521,37 @@ function Default_Language() { // ***********************************************
+function validate_units($cssvalue) { //*****************************************
+ //Determine if valid units are set for $cssvalue: px, pt, em, or %.
+ $main_units = mb_substr($cssvalue, -2);
+ if ( ($main_units != "px") && ($main_units != "pt") && ($main_units != "em") && (mb_substr($cssvalue, -1) != '%')) {
+ $cssvalue = ($cssvalue * 1).'px'; //If not, assume px.
+ }
+ return $cssvalue;
+}//end valid_units() //*********************************************************
+
+
+
+
+function hsc($input) { //*******************************************************
+ $enc = mb_detect_encoding($input); //It should always be UTF-8 (or ASCII), but, just in case...
+ if ($enc == 'ASCII') {$enc = 'UTF-8';} //htmlspecialchars() doesn't recognize "ASCII"
+ return htmlspecialchars($input, ENT_QUOTES, $enc);
+}//end hsc() //*****************************************************************
+
+
+
+
+function Convert_encoding($string, $to_enc = "") { //***************************
+ global $ENC_OS;
+ //mb_convert_encoding($string, $to_enc, $from_enc)
+ if ($to_enc == 'UTF-8') {return mb_convert_encoding($string, 'UTF-8', $ENC_OS);} // Convert to UTF-8
+ else /* default */ {return mb_convert_encoding($string, $ENC_OS, 'UTF-8');} // Convert to server's/OS's filesystem enc
+}//end Convert_encoding() //****************************************************
+
+
+
+
function Session_Startup() { //*************************************************
global $SESSION_NAME, $page, $VALID_POST;
@@ -1131,13 +1131,13 @@ function Current_Path_Header(){ //**********************************************
if ($unaccessable == '.') { $unaccessable = $WEB_ROOT; }
else { $unaccessable = $WEB_ROOT.dirname($ACCESS_ROOT).'/'; }
- $unaccessable = trim(str_replace('/', ' / ',$unaccessable));
+ $unaccessable = ' '.hsc(trim(str_replace('/', ' / ',$unaccessable)));
}
echo '';
//Root (or $ACCESS_ROOT) folder of web site.
$p1 = '?i='.URLencode_path($ACCESS_ROOT);
- echo hsc($unaccessable).''.hsc($_1st_accessable).'/';
+ echo $unaccessable.''.hsc($_1st_accessable).'/';
$x=0; //need here for focus() in case at webroot.
if ($remaining_path != "" ) { //if not at root, show the rest
@@ -1153,7 +1153,7 @@ function Current_Path_Header(){ //**********************************************
}
}//end if (not at root)
echo '
';
- echo '';
+ //echo ''; //Removed focus as of 3.5.04
}//end Current_Path_Header() //*************************************************
@@ -1898,24 +1898,25 @@ function Index_Page_buttons_top($file_count) { //*******************************
global $_, $ONESCRIPT, $param1, $ICONS;
echo ''; //end index_page_buttons
- echo '';
} //end Index_Page_buttons_top() //*********************************************
@@ -2077,9 +2078,8 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_
echo hsc($_['edit_txt_03']).'
';
echo hsc($_['edit_txt_04']).'
';
}else{
- //##### where is this needed??? It's not used in Edit_response()
- //Commented out as of 3.5.02
- //echo '';
+ // is used only to signal an Edit_response().
+ echo '';
echo '
';
echo '('.hsc($_['CRM_txt_02']).')
';
+ echo '
';
echo Timeout_Timer($MAX_IDLE_TIME, 'timer0', 'timer timeout', 'LOGOUT');
echo ''.hsc($_['time_out_txt']).' ';
diff --git a/readme.markdown b/readme.markdown
index b491133..b567895 100755
--- a/readme.markdown
+++ b/readme.markdown
@@ -1,4 +1,5 @@
-(OnefileCMS updated: 2014-03-06)
+(updated: 2014-03-08)
+
# OneFileCMS
## Yes, that's exactly what it is!
@@ -22,7 +23,6 @@ Coupling a utilitarian code editor with basic upload and file managing functions
## Features
- All the basic file management features like renaming, moving, copying, deleting, and uploading.
- (For complex processes, like batch renaming or mass uploads, you're going to want to use an FTP program.)
- Sort directory listings by file name, extension, size, or date.
- A basic text editor.
- A WYSIWYG editor may be added as a plugin.
From 7af105163931bbd85d2358502265e446f6e1975b Mon Sep 17 00:00:00 2001
From: Self-Evident
-
-
-
+
-
-
-
-
-
+
+
+
+
+
+
+
'."\n";
}
-
+ echo '
';
+ echo '
'; //##### added id
echo '
';
$bad_name = $old_full_name;
+ //Ignore if new name is blank.
+ }elseif ( mb_strlen($new_name_only) == 0 ) {
+ $page = 'copyfile';
+ $param3 = '&p=copyfile';
+ return 0;
//Check new name for invalid chars, including slashes.
}elseif ( has_invalid_char($new_name_only) ) {
$err_msg .= $EX.''.hsc($_['new_file_msg_02']).' '.hsc($INVALID_CHARS).'
';
@@ -2778,10 +2788,9 @@ function init_ICONS_js() { //***************************************************
function common_scripts() { //**************************************************
global $_, $TO_WARNING;
-
- $timeout_warning = '
';
@@ -1378,7 +1381,7 @@ function icon_folder($extra = ""){ //**********************************
-function List_Backup($file, $file_url){ //**************************************
+function List_File($file, $file_url){ //****************************************
global $_, $ONESCRIPT, $ICONS;
$file_OS = Convert_encoding($file);
@@ -1386,76 +1389,88 @@ function List_Backup($file, $file_url){ //**************************************
$href = $ONESCRIPT.'?i='.dir_name(trim($file_url,'/')).'&f='.basename($file_url);
$edit_link = ''.hsc(basename($file)).'';
?>
-
-
-
-
-
+
';
+ if ($log_found) { List_File($LOGIN_LOG_file, $LOGIN_LOG_url); }
+ if (is_file($ONESCRIPT_file_backup_OS)) { List_File($ONESCRIPT_file_backup, $ONESCRIPT_backup); }
+ if (is_file($CONFIG_FILE_backup_OS)) { List_File($CONFIG_FILE_backup, $CONFIG_backup); }
+ echo '
+
+
+
B
-
';
+ }//end of check for backup
+}//end List_Backups_and_Logs() //***********************************************
+
+
+
+
+function Admin_Page() { //******************************************************
+ global $_, $ONESCRIPT, $ipath, $filename, $param1, $param2, $config_title;
// Restore/Preserve $ipath prior to admin page in case OneFileCMS is edited (which would change $ipath).
if ( $_SESSION['admin_page'] ) { $ipath = $_SESSION['admin_ipath'];
$param1 = '?i='.URLencode_path($ipath); }
else { $_SESSION['admin_page'] = true;
$_SESSION['admin_ipath'] = $ipath; }
-
+
// [Close] returns to either the index or edit page.
$params = "";
if ($filename != "") { $params = $param2.'&p=edit'; }
+ $button_attribs = ''.hsc($_['Admin_Options']).'
';
-'.hsc($_['admin_txt_00']).'';
- if (is_file($ONESCRIPT_file_backup_OS)) { List_Backup($ONESCRIPT_file_backup, $ONESCRIPT_backup); }
- if (is_file($CONFIG_FILE_backup_OS)) { List_Backup($CONFIG_FILE_backup, $CONFIG_backup); }
- echo '
';
- $focus_on = 'old_backup'; //id of filename listed
- }else {
- $focus_on = 'cancel';
- }//end of check for backup
-
- echo '';
-?>
- '.PHP_EOL;
+ echo ''."\n";
+ echo ''."\n";
+ echo '
'."\n";
}//end show_image() //**********************************************************
@@ -1285,7 +1272,7 @@ function Init_ICONS() { //******************************************************
//*********************************************************************
function icon_txt($border='#333', $lines='#000', $fill='#FFF', $extra1="", $extra2=""){
- return '
'.
+ hsc($_['too_large_to_edit_02']).'
'.hsc($_['too_large_to_edit_03']).'
'.hsc($_['too_large_to_edit_04']);
+
+ $too_large_to_view_message =
+ ''.hsc($_['too_large_to_view_01']).' '.number_format($MAX_VIEW_SIZE).' '.hsc($_['bytes']).'
'.
+ hsc($_['too_large_to_view_02']).'
'.hsc($_['too_large_to_view_03']).'
';
+ echo '
'; }
+ elseif ( $too_large_to_edit ) { $message .= $too_large_to_edit_message; }
+ elseif (!$IS_OFCMS) {
//Did htmlspecialchars return an empty string from a non-empty file?
- $bad_chars = ( ($filecontents == "") && (filesize($filename_OS) > 0) );
+ $bad_chars = ( ($FILECONTENTS == "") && (filesize($filename_OS) > 0) );
- if ($bad_chars){
+ if ($bad_chars){ //Show message: may be a bad character in file
echo ''.$EX.hsc($_['edit_txt_02']).'
';
- }else{
+ echo hsc($_['edit_txt_04']).'
';
echo hsc($_['edit_txt_03']).'
';
- echo hsc($_['edit_txt_04']).'
'."\n";
+ }else{ //show editable '.$FILECONTENTS.'
'."\n"; }
}//end if non-image
Edit_Page_buttons($text_editable, $too_large_to_edit);
echo '
'.
- hsc($_['too_large_to_edit_02']).'
'.hsc($_['too_large_to_edit_03']).'
'.hsc($_['too_large_to_edit_04']);
-
- $too_large_to_view_message =
- ''.hsc($_['too_large_to_view_01']).' '.number_format($MAX_VIEW_SIZE).' '.hsc($_['bytes']).'
'.
- hsc($_['too_large_to_view_02']).'
'.hsc($_['too_large_to_view_03']).'
';//.hsc($_['too_large_to_view_04']);
+ if ($too_large_to_view || !$text_editable) { $header2 = "";}
+ elseif ($text_editable && !$too_large_to_edit && !$IS_OFCMS) { $header2 = hsc($_['edit_h2_2']); }
+ else { $header2 = hsc($_['edit_h2_1']); }
//Preserves vertical spacing when message is closed, so edit area doesn't jump as much.
echo '';
@@ -2190,20 +2169,19 @@ function Edit_Page() { //*******************************************************
echo ''.$header2.' ';
echo '';
echo hsc(basename($filename)).'';
- echo '
'.PHP_EOL;
+ echo ''."\n";
- Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_edit_message, $file_ENC);
+ Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_view, $file_ENC);
- if ( in_array( $ext, $itypes) ) { show_image(); }
+ if ( in_array( $ext, $itypes) ) { show_image(); } //If image, show below the [Rename/Move] [Copy] [Delete] buttons
echo '';
- if ( $text_editable && $too_large_to_view ) {
- echo ''.$filecontents.'
';
+ //If viewing OneFileCMS itself, show Edit Disabled message.
+ if ($IS_OFCMS && $page == "edit") {
+ $message .= '';
+ $message .= '';
+ $message .= ''.$EX.hsc($_['edit_caution_02']).' '.$_['edit_txt_00'].'
';
}
}//end Edit_Page() //***********************************************************
@@ -2435,22 +2413,15 @@ function CRM_Page($action, $title, $action_id, $old_full_name) { //*************
echo '';
echo '
'; //##### added id
+ echo '
';
echo '
';
+ echo '
';
echo '('.hsc($_['CRM_txt_02']).')";
TABLE_ROW += ' ' + ren_mov + ' ';
@@ -3133,15 +3117,11 @@ function Build_Directory() { //***************************************
//Build data from DIRECTORY_DATA into a set of 's
var DIRECTORY_LIST = "";
- var DS = ''; // ' /' for folders, blank otherwise.
- var f_or_f = ''; // 'file' or 'folder'
-
- var HREF_params = '';
var filetype = '';
- var filename = '';
+ var filename = file_name = time_stamp = '';
var filesize = 0;
- for (x=0; x < DIRECTORY_DATA.length; x++) {
+ for (var x=0; x < DIRECTORY_DATA.length; x++) {
filetype = DIRECTORY_DATA[x][0];
filename = DIRECTORY_DATA[x][1];
@@ -3149,22 +3129,23 @@ function Build_Directory() { //***************************************
//folder or file? And file_size
if (filetype == "dir"){
- DS = ' /';
- f_or_f = 'folder';
- HREF_params = ONESCRIPT + PARAM1 + encodeURIComponent(filename);
- file_size = '';
+ var DS = ' /'; // ' /' for folders, blank otherwise.
+ var f_or_f = 'folder'; // 'file' or 'folder'
+ var HREF_params = ONESCRIPT + PARAM1 + encodeURIComponent(filename);
+ var file_size = '';
} else {
- DS = '';
- f_or_f = 'file';
- HREF_params = ONESCRIPT + PARAM1 + '&f=' + encodeURIComponent(filename);
- file_size = format_number(filesize) + ' B';
+ var DS = '';
+ var f_or_f = 'file';
+ var HREF_params = ONESCRIPT + PARAM1 + '&f=' + encodeURIComponent(filename);
+ var file_size = format_number(filesize) + ' B';
}
- file_name = '';
+ file_name = '';
file_name += ICONS[filetype] + ' ' + hsc(filename) + DS + '';
time_stamp = FileTimeStamp(DIRECTORY_DATA[x][3], 1, 0, 0);
- DIRECTORY_LIST += Assemble_row(HREF_params, f_or_f, filetype, filename, file_name)
+ DIRECTORY_LIST += Assemble_row(x, HREF_params, f_or_f, filename, file_name, time_stamp, file_size)
}//end for x
@@ -3236,7 +3217,8 @@ function Confirm_Submit(action){ //***********************************
function Edit_Page_scripts() { //***********************************************
- global $_, $MAIN_WIDTH, $WIDE_VIEW_WIDTH, $current_view;
+ global $_, $ONESCRIPT, $ONESCRIPT_file, $ipath, $param1, $param2, $filename,
+ $MAIN_WIDTH, $WIDE_VIEW_WIDTH, $current_view, $WYSIWYG_VALID, $EDIT_WYSIWYG;
//Determine edit_view width.
$current_view = $MAIN_WIDTH;
@@ -3245,38 +3227,41 @@ function Edit_Page_scripts() { //***********************************************
$current_view = $_COOKIE['edit_view'];
}
}
+
+ //For [Edit WYSIWYG/Source] button
+ $set_cookie = "document.cookie='edit_wysiwyg=".(!$EDIT_WYSIWYG*1)."';";
+ $WYSIWYG_onclick = "parent.location = onclick_params + 'edit'; ".$set_cookie;
+
+ //For [Close] button
+ $close_params = $ONESCRIPT.$param1; //If came from admin page, return there.
+ if ( $_SESSION['admin_page'] ) { $close_params .= '&p=admin'; } //##### But, as of 3.5.07, does this occur?
?>
; } /*Default 810px*/
.button {
- padding : ; /*Default 4px 10px */
- font-size: ; /*Default .9em */
+ padding : ; /*Default 4px 7px 4px 7px */
+ font-size: ; /*Default .9em */
}
.front_links a {
@@ -4020,11 +4019,6 @@ function Load_style_sheet(){ //*************************************************
undo_magic_quotes();
- //Set current $EDIT_MODE & text for Edit page [Edit WYSIWIG/Source] button
- if ( $WYSIWYG_VALID && isset($_COOKIE['edit_mode']) && ($_COOKIE['edit_mode'] == '1')) {
- $EDIT_MODE = '1'; $ON_OFF_label = $_['Source']; }
- else { $EDIT_MODE = '0'; $ON_OFF_label = $_['WYSIWYG']; }
-
Init_ICONS();
Get_GET();
@@ -4033,6 +4027,10 @@ function Load_style_sheet(){ //*************************************************
Valid_Path($ipath, true);
+ Validate_params();
+
+ Init_Macros(); //Needs to be after Get_Get()/Validate_params()/Valid_Path()
+
//$ACCESS_ROOT.$ACCESS_PATH == $ipath
$ipath_len = mb_strlen($ipath);
$ACCESS_PATH = '';
@@ -4040,10 +4038,6 @@ function Load_style_sheet(){ //*************************************************
$ACCESS_PATH = trim(mb_substr($ipath, $ACCESS_ROOT_len), ' /').'/';
}
- Validate_params();
-
- Init_Macros(); //Needs to be after Get_Get()/Validate_params()/Valid_Path()
-
Respond_to_POST();
Verify_Page_Conditions(); //Must come after Respond_to_POST()
@@ -4091,7 +4085,7 @@ function Load_style_sheet(){ //*************************************************
if ($_SESSION['valid'] && $Show_Path) { Current_Path_Header(); }
-message_box();
+echo '';
Load_Selected_Page();
@@ -4111,6 +4105,8 @@ function Load_style_sheet(){ //*************************************************
echo ''; //end container/login_page
echo '';
-if ( ($page == "edit") && $WYSIWYG_VALID && ($EDIT_MODE == 1) ) { include($WYSIWYG_PLUGIN_OS); }
+if ( ($page == "edit") && $WYSIWYG_VALID && $EDIT_WYSIWYG ) { include($WYSIWYG_PLUGIN_OS); }
+//Display any $message's
+if ($message != '') {echo '';}
//END OF FILE ##################################################################
\ No newline at end of file
diff --git a/readme.markdown b/readme.markdown
index 0117a31..4f101f0 100755
--- a/readme.markdown
+++ b/readme.markdown
@@ -57,9 +57,9 @@ I may not have the time/bandwidth/inclination to implement every feature, but I
### Multi-Language Support?
-Yes! Currently, English (EN), German (DE), Spanish (ES), Dutch (NL), and Russian (RU) are available.
+Yes! While English (EN) is the default - German (DE), Spanish (ES), Dutch (NL), and Russian (RU) are also available.
+
-- English courtesy of me.
- German (Deutsch) courtesy of [codeless](http://github.com/codeless).
- Spanish (Espanõla) courtesy of [fermuch](http://github.com/fermuch).
- Dutch (Nederlands) courtesy of [symsec](http://github.com/symsec).
@@ -120,7 +120,6 @@ OneFileCMS can be configured to work with [TinyMCE](http://tinymce.moxiecode.com
- As of v3.4.23, doesn't work in IE. It seems IE doesn't support changing the innerHTML of some tags. OneFile builds the directory in javascript, then displays it by changing the innerHTML of a <tbody> tag of an existing <table>. And, since the alternative/fix/workaround would be a whole bunch more work, IE is currently not supported.
- With Chrome, and possibly Safari, issue with Edit page: Clicking browser [back] & then browser [forward], with file changed and not saved. On return (after [forward] clicked), file still has changes, but indicators are green (saved/unchanged). Does not affect FF 7+ or IE 8+.
-- Issue with Chrome's XSS filter: Editing some legitimate files with OneFileCMS will trigger the filter and disable much of the javascript provided functionallity, but only while on the edit page with such a file, and only after a [Save].
- The connection is not encrypted (doesn't use SSL), so passwords & usernames are sent in clear text* during login. However, this is true of most online login systems, unless SSL or the like is employed.
*As of version 3.4.15, a client-side hash of the user's "plain-text" password is sent to the server. So, while this client-side hash is still a "plain-text" password as far as the server is concerned, the user's raw password is protected from immediate exposure.
- Be aware that only some very basic data & error checking is performed. (But, it's getting better...)
From c5587981a5c537aee04b24a2085eb84d36919071 Mon Sep 17 00:00:00 2001
From: Self-Evident
-
+
-
+
- ()
-
- onclick="Sort_and_Show(SORT_by, SORT_order);">
+ ()
+
-
-
-
-
+
+
+
";
- TABLE_ROW += ' \n";
-
+
return TABLE_ROW;
}//end Assemble_row() //**********************************************
@@ -3116,36 +3137,48 @@ function Directory_Summary() { //*************************************
function Build_Directory() { //***************************************
//Build data from DIRECTORY_DATA into a set of ' + ren_mov + ' ';
- TABLE_ROW += '' + copy + ' ';
- TABLE_ROW += '' + del + ' ';
- TABLE_ROW += '' + checkbox + ' ';
+ TABLE_ROW += '' + ren_mov + ' ';
+ TABLE_ROW += '' + copy + ' ';
+ TABLE_ROW += '' + del + ' ';
+ TABLE_ROW += '' + checkbox + ' ';
TABLE_ROW += '' + file_name + ' ';
TABLE_ROW += '' + file_size + ' ';
- TABLE_ROW += '' + time_stamp + ' ';
+ TABLE_ROW += '' + file_time + ' ';
TABLE_ROW += "'s
+ //raw directory info
var DIRECTORY_LIST = "";
var filetype = '';
- var filename = file_name = time_stamp = '';
+ var filename = '';
var filesize = 0;
+ var filetime = '';
+
+ //formatted and/or marked up directory info
+ var file_name = '';
+ var file_size = '';
+ var file_time = '';
+
+ var DS = ''; // ' /' for folders, blank otherwise.
+ var f_or_f = ''; // 'file' or 'folder'
+ var HREF_params = ''; // file_name
for (var x=0; x < DIRECTORY_DATA.length; x++) {
filetype = DIRECTORY_DATA[x][0];
filename = DIRECTORY_DATA[x][1];
filesize = DIRECTORY_DATA[x][2];
+ filetime = DIRECTORY_DATA[x][3]
//folder or file? And file_size
if (filetype == "dir"){
- var DS = ' /'; // ' /' for folders, blank otherwise.
- var f_or_f = 'folder'; // 'file' or 'folder'
- var HREF_params = ONESCRIPT + PARAM1 + encodeURIComponent(filename);
- var file_size = '';
+ DS = ' /';
+ f_or_f = 'folder';
+ HREF_params = ONESCRIPT + PARAM1 + encodeURIComponent(filename);
+ file_size = '';
} else {
- var DS = '';
- var f_or_f = 'file';
- var HREF_params = ONESCRIPT + PARAM1 + '&f=' + encodeURIComponent(filename);
- var file_size = format_number(filesize) + ' B';
+ DS = '';
+ f_or_f = 'file';
+ HREF_params = ONESCRIPT + PARAM1 + '&f=' + encodeURIComponent(filename) + '&p=edit';
+ file_size = format_number(filesize) + ' B';
}
- file_name = '';
file_name += ICONS[filetype] + ' ' + hsc(filename) + DS + '';
- time_stamp = FileTimeStamp(DIRECTORY_DATA[x][3], 1, 0, 0);
+ file_time = FileTimeStamp(filetime, 1, 0, 0);
- DIRECTORY_LIST += Assemble_row(x, HREF_params, f_or_f, filename, file_name, time_stamp, file_size)
+ DIRECTORY_LIST += Assemble_row(x, HREF_params, f_or_f, filename, file_name, file_time, file_size)
}//end for x
@@ -3233,8 +3266,8 @@ function Edit_Page_scripts() { //***********************************************
$WYSIWYG_onclick = "parent.location = onclick_params + 'edit'; ".$set_cookie;
//For [Close] button
- $close_params = $ONESCRIPT.$param1; //If came from admin page, return there.
- if ( $_SESSION['admin_page'] ) { $close_params .= '&p=admin'; } //##### But, as of 3.5.07, does this occur?
+ $close_params = $ONESCRIPT.$param1;
+ if ( $_SESSION['admin_page'] ) { $close_params .= '&p=admin'; } //If came from admin page, return there.
?>
';}
-//END OF FILE ##################################################################
\ No newline at end of file
+//##### END OF FILE ############################################################
\ No newline at end of file
diff --git a/readme.markdown b/readme.markdown
index 4f101f0..21423c1 100755
--- a/readme.markdown
+++ b/readme.markdown
@@ -100,8 +100,8 @@ OneFileCMS can be configured to work with [TinyMCE](http://tinymce.moxiecode.com
(Only tested on versions 5.2.8, 5.2.17, 5.3.3, and 5.4 + )
- File permission privileges on your host.
- A Javascript enabled browswer.
-- Most modern browsers probably work, but I only test on Firefox and Chrome.
- IE is currently a no go, as of v3.4.23. [v3.4.22 is available here](http://self-evident.github.com/OneFileCMS/onefilecms_3.4.22.zip)
+- Most* modern browsers probably work, but I only test on Firefox and Chrome.
+ *IE, however, is currently a no go, as of OneFileCMS v3.4.23. [v3.4.22 is available here](http://self-evident.github.com/OneFileCMS/onefilecms_3.4.22.zip)
- And- but only if you wish to see the icons- a browser that supports inline SVG.
(If your browser doesn't support inline SVG, OneFileCMS will still work, just without any icons.)
@@ -121,7 +121,7 @@ OneFileCMS can be configured to work with [TinyMCE](http://tinymce.moxiecode.com
- As of v3.4.23, doesn't work in IE. It seems IE doesn't support changing the innerHTML of some tags. OneFile builds the directory in javascript, then displays it by changing the innerHTML of a <tbody> tag of an existing <table>. And, since the alternative/fix/workaround would be a whole bunch more work, IE is currently not supported.
- With Chrome, and possibly Safari, issue with Edit page: Clicking browser [back] & then browser [forward], with file changed and not saved. On return (after [forward] clicked), file still has changes, but indicators are green (saved/unchanged). Does not affect FF 7+ or IE 8+.
- The connection is not encrypted (doesn't use SSL), so passwords & usernames are sent in clear text* during login. However, this is true of most online login systems, unless SSL or the like is employed.
- *As of version 3.4.15, a client-side hash of the user's "plain-text" password is sent to the server. So, while this client-side hash is still a "plain-text" password as far as the server is concerned, the user's raw password is protected from immediate exposure.
+ *As of version 3.4.15, a client-side hash of the user's "plain-text" password is sent to the server. So, while this client-side hash is still a "plain-text" password as far as the server is concerned, the user's actual raw password is protected from immediate exposure.
- Be aware that only some very basic data & error checking is performed. (But, it's getting better...)
- Anything else?
From f034a787afc27ce4eefa8bf4e50e828df6aaa18d Mon Sep 17 00:00:00 2001
From: Self-Evident to
-
Send_data_to_js_and_display: added DIRECTORY_ITEMS js global var Added
Init_Dir_table_rows() js function. Assemble_row() is now
Assemble_Insert_row() Build_Directory() redone for Assemble_Insert_row(),
cleaned up. Directory_Summary(): no longer genrerates here.
Sort_and_Show(): minor adjustment for new Build_Directory(). Some css
adjustments for the above, and some general tweaks.
---
info/OneFileCMS_structure.txt | 5 +-
info/changelog.markdown | 5 +
onefilecms.php | 187 ++++++++++++++++++----------------
readme.markdown | 4 +-
4 files changed, 106 insertions(+), 95 deletions(-)
diff --git a/info/OneFileCMS_structure.txt b/info/OneFileCMS_structure.txt
index c0c8443..8f7be4b 100755
--- a/info/OneFileCMS_structure.txt
+++ b/info/OneFileCMS_structure.txt
@@ -1,4 +1,4 @@
-OneFileCMS Version 3.5.08 structure/layout
+OneFileCMS Version 3.5.09 structure/layout
LICENSE
@@ -101,9 +101,10 @@ JAVASCRIPT FUNCTIONS:
Index_Page_scripts()
Sort_FOlder_First()
sort_DIRECTORY()
+ Init_Dir_table_rows()
Assemble_row()
- Directory_Summary()
Build_Directory
+ Directory_Summary()
Sort_and_Show()
Select_All()
Confirm_Submit()
diff --git a/info/changelog.markdown b/info/changelog.markdown
index f7a3b3b..cb66ee0 100755
--- a/info/changelog.markdown
+++ b/info/changelog.markdown
@@ -1,5 +1,10 @@
# OneFileCMS Change Log
+### v3.5.09 (2014-03-22)
+
+- Restored IE 8+ support.
+- And, you know, tweaked some css...
+
### v3.5.08 (2014-03-21)
- Mostly just some code improvements/cleanup.
diff --git a/onefilecms.php b/onefilecms.php
index ae1eb19..75b7cf8 100755
--- a/onefilecms.php
+++ b/onefilecms.php
@@ -2,7 +2,7 @@
// OneFileCMS - github.com/Self-Evident/OneFileCMS
-$OFCMS_version = '3.5.08';
+$OFCMS_version = '3.5.09';
/*******************************************************************************
Except where noted otherwise:
@@ -1797,7 +1797,7 @@ function Create_Table_for_Listing() { //****************************************
+
with empty 's
+ tr = DIR_LIST.insertRow(row);
+ for (cell = 0; cell < 7; cell++) {td = tr.insertCell(-1);}
+ cells = tr.cells;
+
+ //assign css classes
+ cells[4].className = 'file_name';
+ cells[5].className = 'file_size meta_T';
+ cells[6].className = 'file_time meta_T';
+ }
+}//end Init_Dir_table_rows() { //*************************************
+
+
+
+
//********************************************************************
-function Assemble_row(x, HREF_params, f_or_f, filename, file_name, file_time, file_size){
- var TABLE_ROW = '';
+function Assemble_Insert_row(IS_OFCMS, trow, href, f_or_f, filename, file_name, file_size, file_time){
- //Assemble cell contents: [move] [copy] [delete] [x] file name etc...
- var ren_mov = '' + ICONS['ren_mov'] + '';
- var copy = '' + ICONS['copy'] + '';
- var del = '' + ICONS['delete'] + '';
+ //Assemble [move] [copy] [delete] [x]
+ var ren_mov = '' + ICONS['ren_mov'] + '';
+ var copy = '' + ICONS['copy'] + '';
+ var del = '' + ICONS['delete'] + '';
var checkbox = '';
//Don't show remove, delete, or checkbox options for active copy of OneFileCMS.
- var IS_OFCMS = DIRECTORY_DATA[x][4];
if (IS_OFCMS) { ren_mov = del = checkbox = ''; }
- TABLE_ROW += " ";
- TABLE_ROW += ' \n";
+ //fill the ' + ren_mov + ' ';
- TABLE_ROW += '' + copy + ' ';
- TABLE_ROW += '' + del + ' ';
- TABLE_ROW += '' + checkbox + ' ';
- TABLE_ROW += '' + file_name + ' ';
- TABLE_ROW += '' + file_size + ' ';
- TABLE_ROW += '' + file_time + ' ';
- TABLE_ROW += "'s
+ cells = trow.cells;
+ cells[0].innerHTML = ren_mov;
+ cells[1].innerHTML = copy;
+ cells[2].innerHTML = del;
+ cells[3].innerHTML = checkbox;
+ cells[4].innerHTML = file_name;
+ cells[5].innerHTML = file_size;
+ cells[6].innerHTML = file_time;
+
+}//end Assemble_Insert_row() //***************************************
+
+
+
- return TABLE_ROW;
-}//end Assemble_row() //**********************************************
+function Build_Directory() { //***************************************
+
+ var DIR_LIST = document.getElementById("DIRECTORY_LISTING");
+
+ if (DIR_LIST.rows.length < 1) {Init_Dir_table_rows(DIR_LIST);}
+
+ for (var row = 0; row < DIRECTORY_ITEMS; row++) {
+
+ var filetype = DIRECTORY_DATA[row][0];
+ var filename = DIRECTORY_DATA[row][1];
+ var filesize = DIRECTORY_DATA[row][2];
+ var filetime = DIRECTORY_DATA[row][3];
+
+ //folder or file?
+ if (filetype == "dir"){
+ var DS = ' /';
+ var f_or_f = 'folder';
+ var href = ONESCRIPT + PARAM1 + encodeURIComponent(filename);
+ var file_size = '';
+ } else {
+ var DS = '';
+ var f_or_f = 'file';
+ var href = ONESCRIPT + PARAM1 + '&f=' + encodeURIComponent(filename) + '&p=edit';
+ var file_size = format_number(filesize) + ' B';
+ }
+
+ var file_name = '';
+ file_name += ICONS[filetype] + ' ' + hsc(filename) + DS + '';
+ var file_time = FileTimeStamp(filetime, 1, 0, 0);
+
+ var IS_OFCMS = DIRECTORY_DATA[row][4];
+ var trow = DIR_LIST.rows[row];
+
+ Assemble_Insert_row(IS_OFCMS, trow, href, f_or_f, filename, file_name, file_size, file_time);
+ }//end for (row...
+}//end Build_Directory() //*******************************************
@@ -3122,10 +3182,9 @@ function Directory_Summary() { //*************************************
}
//Directory Summary
- SUMMARY += ' ';
SUMMARY += folder_count + " , ";
SUMMARY += total_items - folder_count + ' , ';
- SUMMARY += ' ' + format_number(total_bytes) + " ";
+ SUMMARY += ' ' + format_number(total_bytes) + " ";
return SUMMARY;
@@ -3134,65 +3193,11 @@ function Directory_Summary() { //*************************************
-function Build_Directory() { //***************************************
- //Build data from DIRECTORY_DATA into a set of 's
-
- //raw directory info
- var DIRECTORY_LIST = "";
- var filetype = '';
- var filename = '';
- var filesize = 0;
- var filetime = '';
-
- //formatted and/or marked up directory info
- var file_name = '';
- var file_size = '';
- var file_time = '';
-
- var DS = ''; // ' /' for folders, blank otherwise.
- var f_or_f = ''; // 'file' or 'folder'
- var HREF_params = ''; // file_name
-
- for (var x=0; x < DIRECTORY_DATA.length; x++) {
-
- filetype = DIRECTORY_DATA[x][0];
- filename = DIRECTORY_DATA[x][1];
- filesize = DIRECTORY_DATA[x][2];
- filetime = DIRECTORY_DATA[x][3]
-
- //folder or file? And file_size
- if (filetype == "dir"){
- DS = ' /';
- f_or_f = 'folder';
- HREF_params = ONESCRIPT + PARAM1 + encodeURIComponent(filename);
- file_size = '';
- } else {
- DS = '';
- f_or_f = 'file';
- HREF_params = ONESCRIPT + PARAM1 + '&f=' + encodeURIComponent(filename) + '&p=edit';
- file_size = format_number(filesize) + ' B';
- }
-
- file_name = '';
- file_name += ICONS[filetype] + ' ' + hsc(filename) + DS + '';
- file_time = FileTimeStamp(filetime, 1, 0, 0);
-
- DIRECTORY_LIST += Assemble_row(x, HREF_params, f_or_f, filename, file_name, file_time, file_size)
-
- }//end for x
-
- return DIRECTORY_LIST;
-
-} //end Build_Directory() //******************************************
-
-
-
function Sort_and_Show(col, direction) { //***************************
sort_DIRECTORY(col, direction); //Sort DIRECTORY_DATA
- document.getElementById('DIRECTORY_LISTING').innerHTML = Build_Directory();
+ Build_Directory();
document.getElementById('DIRECTORY_FOOTER').innerHTML = Directory_Summary();
@@ -3200,6 +3205,7 @@ function Sort_and_Show(col, direction) { //***************************
+
function Select_All() { //*******************************************
//Does not work in IE if the variable name is spelled the same as the Element Id
@@ -3743,7 +3749,7 @@ function style_sheet(){ //******************************************************
.meta_T { padding-right: 4px; text-align: right; font-family: courier; font-size: .9em; color: #222; }
-#DIRECTORY_FOOTER td {text-align: center; font-size: .9em; color: #333; padding: 3px 0 0 0; }
+#DIRECTORY_FOOTER {text-align: center; font-size: .9em; color: #333; padding: 3px 0 0 0; }
/*** front_links: [New File] [New Folder] [Upload File] ***/
@@ -3762,9 +3768,9 @@ function style_sheet(){ //******************************************************
/*These must go after .front_links and other style that affect tags*/
a { border: 1px solid transparent; text-decoration: none; } /*color: rgb(100,45,0);*/
-a:focus { border: 1px solid #777; background-color: rgb(255,250,150); }
-a:hover { border: 1px solid #777; background-color: rgb(255,250,150); }
-a:active { border: 1px solid #777; background-color: rgb(245,245,50); }
+a:focus { border: 1px solid #333; background-color: rgb(255,250,150); }
+a:hover { border: 1px solid #333; background-color: rgb(255,250,150); }
+a:active { border: 1px solid #333; background-color: rgb(245,245,50); }
/*** [Move] [Copy] [Delete] ***/
@@ -3784,9 +3790,9 @@ function style_sheet(){ //******************************************************
background-color: #EEE;
}
-#mcd_submit button:focus { background-color: rgb(255,250,150); }
-#mcd_submit button:hover { background-color: rgb(255,250,150); }
-#mcd_submit button:active { background-color: rgb(245,245,50); }
+#mcd_submit button:focus { border: 1px solid #333; background-color: rgb(255,250,150); }
+#mcd_submit button:hover { border: 1px solid #333; background-color: rgb(255,250,150); }
+#mcd_submit button:active { border: 1px solid #333; background-color: rgb(245,245, 50); }
.buttons_right { float: right; }
.buttons_right .button { margin-left: .5em; }
@@ -3811,14 +3817,15 @@ function style_sheet(){ //******************************************************
.nav { float: right; display: inline-block; margin-top: 1.35em; font-size : 1em; }
.nav a { border: 1px solid transparent; font-weight: bold; padding: .2em .6em .1em .6em; }
-.nav a:hover { border: 1px solid #777; }
-.nav a:focus { border: 1px solid #777; }
-.nav a:active { border: 1px solid #777; }
+.nav a:hover { border: 1px solid #333; }
+.nav a:focus { border: 1px solid #333; }
+.nav a:active { border: 1px solid #333; }
/* --- edit --- */
#edit_header {margin: .5em 0 0 0;}
+#edit_header a:hover { border: 1px solid #000; }
#edit_form {margin: 0;}
@@ -3973,7 +3980,7 @@ function style_sheet(){ //******************************************************
font-weight: normal;
padding: 0 .5em 0 0;
margin: .5em 0 0 0;
-}
+ }
#path_header a {
outline: none;
@@ -3982,7 +3989,7 @@ function style_sheet(){ //******************************************************
border-right: solid 1px transparent;
display: inline-block;
padding: 1px 5px 0 5px;
-}
+ }
#path_header a:hover { border-left : solid 1px #777; border-right: solid 1px #777; background-color: rgb(255,250,150); }
#path_header a:focus { border-left : solid 1px #777; border-right: solid 1px #777; background-color: rgb(255,250,150); }
diff --git a/readme.markdown b/readme.markdown
index 21423c1..cc47b20 100755
--- a/readme.markdown
+++ b/readme.markdown
@@ -100,8 +100,7 @@ OneFileCMS can be configured to work with [TinyMCE](http://tinymce.moxiecode.com
(Only tested on versions 5.2.8, 5.2.17, 5.3.3, and 5.4 + )
- File permission privileges on your host.
- A Javascript enabled browswer.
-- Most* modern browsers probably work, but I only test on Firefox and Chrome.
- *IE, however, is currently a no go, as of OneFileCMS v3.4.23. [v3.4.22 is available here](http://self-evident.github.com/OneFileCMS/onefilecms_3.4.22.zip)
+- Most* modern browsers probably work, but I only test on Firefox, Chrome, and IE 8.
- And- but only if you wish to see the icons- a browser that supports inline SVG.
(If your browser doesn't support inline SVG, OneFileCMS will still work, just without any icons.)
@@ -118,7 +117,6 @@ OneFileCMS can be configured to work with [TinyMCE](http://tinymce.moxiecode.com
##Needed/potential improvements
-- As of v3.4.23, doesn't work in IE. It seems IE doesn't support changing the innerHTML of some tags. OneFile builds the directory in javascript, then displays it by changing the innerHTML of a <tbody> tag of an existing <table>. And, since the alternative/fix/workaround would be a whole bunch more work, IE is currently not supported.
- With Chrome, and possibly Safari, issue with Edit page: Clicking browser [back] & then browser [forward], with file changed and not saved. On return (after [forward] clicked), file still has changes, but indicators are green (saved/unchanged). Does not affect FF 7+ or IE 8+.
- The connection is not encrypted (doesn't use SSL), so passwords & usernames are sent in clear text* during login. However, this is true of most online login systems, unless SSL or the like is employed.
*As of version 3.4.15, a client-side hash of the user's "plain-text" password is sent to the server. So, while this client-side hash is still a "plain-text" password as far as the server is concerned, the user's actual raw password is protected from immediate exposure.
From 12c70c6c0989ff8f273ff525bf544250651cd1b0 Mon Sep 17 00:00:00 2001
From: Self-Evident OneFileCMS Change Log
-
-v3.5.07 (2014-03-15)
-
-
-
-
-v3.5.06 (2014-03-11)
-
-
-
-
-v3.5.05 (2014-03-09)
-
-
-
-
-v3.5.04 (2014-03-08)
-
-
-
-
-v3.5.03 (2014-03-06)
-
-
-
-
-v3.5.02 (2014-03-06)
-
-
-
-
-
-(However, OneFileCMS does not currenly work in IE, so it's kinda academic for now.)v3.5.01 (2014-02-22)
-
-
-
-
-v3.5 (2014-02-19)
-
-
-
-
-v3.4.23 (2014-02-12)
-
-
-
-
-v3.4.22 (2014-02-10)
-
-
-
-
-v3.4.21 (2014-02-08)
-
-
-
-
-(2013-01-19)
-
-
-
-
-v3.4.20 (2012-12-19)
-
-
-
-
-
-(*Well, as best as I can tell...)
-
-(On Windows, the drive letter may also be used, but it is not required if all is on same drive.)v3.4.19 (2012-12-12)
-
-
-
-
-
-(It's value is now specified directly in the "init" file specified by $WYSIWYG_PLUGIN.)
-Just for now - removed the $ACCESS_ROOT option. I was coding in circles and getting no where while trying to reconcile various issues:
-
-
-
-
v3.4.18 (2012-12-03)
-
-
-
-
-2012-12-03
-
-
-
-
-v3.4.17 (2012-11-29)
-
-
-
-
-
-Due to popular demand (ie: it has been requested more than once), WYSYWIG editors can now be "plugged in" and used with OneFileCMS. Currently, only TinyMCE and CKEditor have been tested (and on a very limited scale). Others may work - but I don't know yet. And, naturally, the use or inclusion of such editors is completely optional, of course.
-
v3.4.16 (2012-11-23)
-
-
-
-
-v3.4.15 (2012-11-18)
-
-
-
-
-3.4.14 (2012-11-12)
-
-
-
-
-(2012-11-11)
-
-
-
-
-3.4.13 (2012-11-05)
-
-
-
-
-3.4.12 (2012-10-21)
-
-
-
-
-3.4.11 (2012-10-16)
-
-
-
-
-3.4.10 (2012-10-08)
-
-
-
-
-3.4.09
-
-
-
-
-3.4.07
-
-
-
-
-3.4.06
-
-
-
-
-3.4.05
-
-
-
-
-3.4.04
-
-
-
-
-3.4.02-3.4.03
-
-
-
-
-3.4.01
-
-
-
-
-3.3.17 - 3.4.0 (2012-08-29)
-
-
-
-
-3.3.11 - 3.3.16
-
-
-
-
-3.3.10
-
-
-
-
-3.3.09
-
-
-
-
-3.3.08
-
-
-
-
-3.3.07
-
-
-
-
-3.3.06
-
-
-
-
-3.3.05a
-
-
-
-
-3.3.05
-
-
-
-
-3.3.04
-
-
-
-
-3.3.03
-
-
-
-
-3.3.02
-
-
-
-
-3.3.01
-
-
-
-
-3.3.0
-
-
-
-
-3.2.3
-
-
-
-
-
-(This is just an option for flexibility, and is not required)3.2.2
-
-
-
-
-3.2.1
-
-
-
-
-3.2.0
-
-
-
-
-3.1.9
-
-
-
-
-3.1.6 thru 3.1.8
-
-
-
-
-3.1.2 thru 3.1.5
-
-
-
-
-3.1.1
-
-
-
-
-3.1
-
-
-
-
-3.0
-
-
-
-
-2.0
-
-
-
-
-
-(Of course, external style sheets & icons can be added back in, if you like.)1.5
-
-
-
-
-1.4.0
-
-
-
-
-1.2.4 - 1.3.0
-
-
-
-
-1.2.3
-
-
-
-
-1.2.2
-
-
-
-
-1.2.1
-
-
-
-
-1.2.0
-
-
-
-
-1.1.9
-
-
-
-
-1.1.8
-
-
-
-
-1.1.7
-
-
-
-
-1.1.6
-
-
-
-
-1.1.5
-
-
-
-
-
-Many thanks to Abhi M Balakrishnan from OWASP Mantra Team for his help1.1.4
-
-
-
-
-1.1.3 (1/10/2012)
-
-
-
-
-1.1.2 (9/21/11)
-
-
-
-
-1.1.1 (1/9/10)
-
-
-
-
-1.1.0 (10/18/09)
-
-
-
-
-1.0.1 (9/24/09)
-
-
-
-
-1.0 (9/5/09)
-
-
-
From 8898e29fdf9f657c5e094874db48d50783fb7471 Mon Sep 17 00:00:00 2001
From: Self-Evident
'; }
if ( ($attempts >= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
- $message .= hsc($_['login_msg_02a']).' ';
- $message .= Timeout_Timer(($LOGIN_DELAY - $elapsed), 'timer0');
- $message .= ' '.hsc($_['login_msg_02b']);
+ $LOGIN_DELAYED = ($LOGIN_DELAY - $elapsed);
+ $message .= hsc($_['login_msg_02a']).' '.hsc($_['login_msg_02b']);
return;
}
@@ -1747,9 +1761,8 @@ function Login_response() { //**************************************************
file_put_contents($LOGIN_ATTEMPTS, ++$attempts); //increment attempts
$message = $EX.''.hsc($_['login_msg_03']).$attempts.'
';
if ($attempts >= $MAX_ATTEMPTS) {
- $message .= hsc($_['login_msg_02a']).' ';
- $message .= Timeout_Timer($LOGIN_DELAY, 'timer0', '', '');
- $message .= ' '.hsc($_['login_msg_02b']);
+ $LOGIN_DELAYED = $LOGIN_DELAY;
+ $message .= hsc($_['login_msg_02a']).' '.hsc($_['login_msg_02b']);
}
}
@@ -1799,6 +1812,7 @@ function Create_Table_for_Listing() { //****************************************
Possibly The easiest installation process ever!
-## Installation
+--------------------------------------------------------------------------------
+## Installation
1) **Download** the [current version](https://raw.github.com/Self-Evident/OneFileCMS/master/onefilecms.php).
@@ -45,21 +59,20 @@ As with any CMS, you may also have to modify the file permissions of your site's
You can also change the file name from "onefilecms.php" to something else, such as "admin.php". (Be careful about making it a folder's default file: your server may get stuck in redirects.)
--------------------------------------------------------------------------------
+## FAQ
-## FAQ
-
-### I found something that could be better. Can I suggest it to you?
-
-Yes, of course!
-
-I may not have the time/bandwidth/inclination to implement every feature, but I 'll do what I can. If you find a bug, please file a report on the issues page.
+- [Multi-Language Support?](#language)
+- [I found something that could be better. Can I suggest it to you?](#suggestions)
+- [Can I have more than one username/password?](#multiuser)
+- [This is basically just a file manager with a text editor- why is it being called a CMS?](#handsaw)
+- [Where's the WYSISWYG?](#WYSIWYG)
+- [Why do I get a "Stop running script?" pop-up during login?](#slowlogin)
-### Multi-Language Support?
+### Multi-Language Support?
Yes! While English (EN) is the default - German (DE), Spanish (ES), Dutch (NL), and Russian (RU) are also available.
-
- German (Deutsch) courtesy of [codeless](http://github.com/codeless).
- Spanish (Espanõla) courtesy of [fermuch](http://github.com/fermuch).
- Dutch (Nederlands) courtesy of [symsec](http://github.com/symsec).
@@ -67,22 +80,28 @@ Yes! While English (EN) is the default - German (DE), Spanish (ES), Dutch (NL),
If you speak another language and would like to contribute, translations are welcomed and appreciated! Just use the English language file (or any of the others) as a template, and translate each word, phrase, etc., as appropriate.
-### Can I have more than one username/password?
+### I found something that could be better. Can I suggest it to you?
+
+Yes, of course!
+
+I may not have the time/bandwidth/inclination to implement every feature, but I 'll do what I can. If you find a bug, please file a report on the issues page.
+
+### Can I have more than one username/password?
Yes! Well, sort of... indirectly. Upload or create addional copies of OneFileCMS, but give them different file names.(ex: OneFile1.php and OneFile2.php etc...) Then, in each copy, maintain different usernames, passwords, and $session_name config values.
Now, since there is no database or other means of granular control or access logging, multiple usernames provides limited utility. However, having at least one working backup copy of OneFileCMS available is recommended in case the primary copy gets corrupted.
-### This is basically just a file manager with a text editor- why is it being called a CMS?
+### This is basically just a file manager with a text editor- why is it being called a CMS?
-Well, because "OneFileCMS" sounds way cooler (relatively speaking) than "OneFileFileManagerwithTextEditor".
+It may be simple, bit it can get the job done. While you wouldn't want to build an entire house with just a hammer and hand saw, you can "manage" quite a bit with just those two tools (and nails, of course). Besides, "OneFileCMS" sounds cool.
-### Where's the WYSISWYG?
+### Where's the WYSISWYG?
OneFileCMS can be easily configured to work with [TinyMCE](http://tinymce.moxiecode.com) or [CKEditor](http://ckeditor.com) (and possibly others), but the editors themselves must be obtained from their respective sites. For basic setup instructions, read the appropriate "init" file from the extras/ directory in the OneFileCMS repo.
-### Why do I get a "Stop running script?" pop-up during login?
+### Why do I get a "Stop running script?" pop-up during login?
IE, version 8 at least, takes condsiderably longer (about 8 seconds on my test system) to run OneFile's javascript login functions than Chrome or Firefox. Just click [No] and the login should continue normally after a few more seconds.
@@ -90,7 +109,19 @@ Not counting the time the pop-up is waiting for a response, the 8 seconds previo
See the global variable "$PRE\_ITERATIONS" at the end of System\_Setup(). It can be adjusted, but it's best to do so on a local copy in a development setup, then upload the updated copy.
-### Limitations & Considerations
+--------------------------------------------------------------------------------
+## Requirements
+
+- PHP 5.1+
+ (Only tested on versions 5.2.8, 5.2.17, 5.3.3, and 5.4 + )
+- File permission privileges on your host.
+- A Javascript enabled browswer.
+- Most* modern browsers probably work, but I only test on Firefox, Chrome, and IE 8.
+- And- but only if you wish to see the icons- a browser that supports inline SVG.
+ (If your browser doesn't support inline SVG, OneFileCMS will still work, just without any icons.)
+
+--------------------------------------------------------------------------------
+## Limitations & Considerations
- OneFileCMS would not be the best option for a site that requires different levels of privileges, unless all of the users are trusted to stay within their designated areas of responsibility. Since OneFileCMS allows file uploads and editing files directly on the web server, there is simply no way to secure against any particular action.
@@ -98,24 +129,13 @@ See the global variable "$PRE\_ITERATIONS" at the end of System\_Setup(). It ca
- If you need to upload a lots of files, an FTP program may be a bit more flexible & practicle.
-- Directories with many (hundreds) of files, may take a few seconds to display. For instance, on my system- a 2.5gz desktop running XP, it takes 2 to 4 seconds to display a directory with 200 files.
+- Directories with hundreds of files can take a several seconds to display. For instance, on my system- a 2.5gz desktop running XP, it takes 2 to 4 seconds to display a directory with 200 files.
-- If your website's connection is not encrypted (doesn't use SSL/TLS), passwords & usernames will be sent in clear text* during login. However, this is true of any online login system that's over an unencrypted connection.
+- If your website's connection is not encrypted (doesn't use SSL/TLS), passwords & usernames will be sent in clear text* during login. However, this is true of any login system that's over an unencrypted connection.
*As of version 3.4.15, a client-side hash of the user's "plain-text" password is sent to the server. So, while this client-side hash is still a "plain-text" password as far as the server is concerned, the user's actual raw password is protected from immediate exposure.
--------------------------------------------------------------------------------
-
-## Requirements
-
-- PHP 5.1+
- (Only tested on versions 5.2.8, 5.2.17, 5.3.3, and 5.4 + )
-- File permission privileges on your host.
-- A Javascript enabled browswer.
-- Most* modern browsers probably work, but I only test on Firefox, Chrome, and IE 8.
-- And- but only if you wish to see the icons- a browser that supports inline SVG.
- (If your browser doesn't support inline SVG, OneFileCMS will still work, just without any icons.)
-
-## License, Credit, Et Cetera
+## License, Credit, Et Cetera
- Available under the MIT and BSD licenses.
- Original concept and development by github.com/rocktronica
@@ -126,15 +146,15 @@ See the global variable "$PRE\_ITERATIONS" at the end of System\_Setup(). It ca
- To report a bug or request a feature, please file an issue via Github.
- And, of course, please feel free to fork away!
-##Needed/potential improvements
+--------------------------------------------------------------------------------
+## Needed/potential improvements
- With Chrome, and possibly Safari, issue with Edit page: Clicking browser [back] & then browser [forward], with file changed and not saved. On return (after [forward] clicked), file still has changes, but indicators are green (saved/unchanged). Does not affect FF 7+ or IE 8+.
- Be aware that only some very basic data & error checking is performed. (But, it's getting better...)
- Anything else?
--------------------------------------------------------------------------------
-
-### General layout/structure of OneFileCMS.php
+### General layout/structure of OneFileCMS.php
CONFIGURATION SECTION
@@ -157,7 +177,6 @@ LOGIC TO DETERMINE PAGE ACTION
GENERATE/OUTPUT THE PAGE
--------------------------------------------------------------------------------
-
-## [Change Log](http://self-evident.github.com/OneFileCMS/changelog.html)
+## [Change Log](http://self-evident.github.com/OneFileCMS/changelog.html)
## [Git Log](https://raw.github.com/Self-Evident/OneFileCMS/gh-pages/master-branch.git.log)
From 5d51a50148a2be1c819dacba929bdfa9805ae667 Mon Sep 17 00:00:00 2001
From: Self-Evident
\ No newline at end of file
From b30329a005810e9ca12a480b9a0162010dc50fa2 Mon Sep 17 00:00:00 2001
From: Self-Evident '.hsc($title).'
';
@@ -2326,7 +2331,7 @@ function New_Page($title, $new_f_or_f) { //*************************************
-function New_response($post, $isfile){ //***************************************
+function New_response($post, $isfile) {//***************************************
global $_, $ipath, $ipath_OS, $filename, $filename_OS, $page, $param1, $param2, $param3, $message, $EX, $INVALID_CHARS, $WHSPC_SLASH;
$page = "index"; //Return to index if folder, or on error.
@@ -2372,7 +2377,7 @@ function New_response($post, $isfile){ //***************************************
-function Set_Input_width() { //*************************************************
+function Set_Input_width() {//**************************************************
global $_, $WEB_ROOT, $MAIN_WIDTH, $ACCESS_ROOT;
// (width of ) = $MAIN_WIDTH - (Width of 's & 's that contain */
+/*ckbox is assigned to 's
cells = trow.cells;
@@ -3872,7 +3882,6 @@ function style_sheet() {//******************************************************
input[type="text"] { width: 100%; border: 1px solid #777; padding: 1px 1px 1px 0; font : 1em Courier; }
input[type="password"] { width: 100%; border: 1px solid #777; padding: 0 1px 0 0; }
input[type="file"] { width: 100%; border: 1px solid #777; background-color: white; margin: 0; }
-input[type="checkbox"] { cursor : pointer; }
input[readonly] { color: #333; background-color: #EEE; }
input[disabled] { color: #555; background-color: #EEE; }
@@ -3880,6 +3889,9 @@ function style_sheet() {//******************************************************
input:focus { background-color: rgb(255,250,150); border: 1px solid #333; }
input:hover { background-color: rgb(255,250,150); }
+/*-- Must be after input:focus, as it alters border --*/
+input[type="checkbox"] { cursor: pointer; border: none;}
+
button:hover { background-color: rgb(255,250,150); border-color: #333;}
button:focus { background-color: rgb(255,250,150); border-color: #333;}
button:active { background-color: rgb(245,245,50); border-color: #333;}
@@ -3970,7 +3982,7 @@ function style_sheet() {//******************************************************
/*** Directory list file select boxes ***/
-/*ckbox is assigned to 's & 's that contain */
+/*ckbox is assigned to
-
'.hsc($_['OFCMS_requires']).' '.PHP_VERSION_REQUIRED );
}
@@ -303,7 +310,7 @@ function System_Setup() {//*****************************************************
function Default_Language() { // ***********************************************
global $_;
-// OneFileCMS Language Settings v3.5.07
+// OneFileCMS Language Settings v3.5.17
$_['LANGUAGE'] = 'English';
$_['LANG'] = 'EN';
@@ -1369,11 +1376,13 @@ function icon_folder($extra = "") {//**********************************
$ICONS['move'] = icon_folder($arc_arrow);
$ICONS['copy'] = '
+
+
';
- echo '';
+ echo "\n\n";
}//end MCD_Page() //************************************************************
@@ -2685,7 +2701,7 @@ function MCD_response($action, $msg1, $success_msg = '') {//********************
$files = $_POST['files']; //List of files to delete (path not included)
$errors = 0; //number of failed moves, copies, or deletes
$successful = 0;
-
+
$new_location = "";
if (isset($_POST['new_location'])) {
$new_location = $_POST['new_location'];
@@ -2693,7 +2709,7 @@ function MCD_response($action, $msg1, $success_msg = '') {//********************
}
$show_message = 1; //1= show error msg only.
-
+
if ( ($new_location != "") && !is_dir($new_location_OS)) {
$MESSAGE .= $EX.''.hsc($msg1.' '.$_['CRM_msg_01']).'
';
echo '
-
-
+
+
-
+ href="#" id=header_filesize>
href="#" id=header_filedate>
- href="'.$ICONS['dir'] ?> ../
+
+
+ ';
+ }
+ else {
+ echo ' .. /'; //#### '.$ICONS['up_dir'].'
+ }
+?>
+
-
+
@@ -1849,7 +1880,7 @@ function Get_DIRECTORY_DATA($raw_list) {//**************************************
//Get file .ext & check against $stypes (files types to show)
$filename_parts = explode(".", mb_strtolower($filename));
- //First check for no $ext: "filename" or ".filename"
+ //Check for no $ext: "filename" or ".filename"
$segments = count($filename_parts);
if( $segments === 1 || (($segments === 2) && ($filename_parts[0] === "")) ) {
$ext = '';
@@ -2772,19 +2803,19 @@ function Respond_to_POST() {//**************************************************
function init_ICONS_js() {//****************************************************
global $ICONS;
- //Currently, only icons for dir listing needed in js
+ //Currently, only icons for dir listing are needed in js
?>
';
//start any timers (Yea, they could probably be put in a window.onload function or something...)
@@ -4492,5 +4550,5 @@ function Load_style_sheet() {//*************************************************
//##### Header (UTF-8) for [View Raw] incorrect or not getting sent??
//##### If file has non-ascii characters, browers display in ISO-8859-1/Windows-1252,
-//##### Except IE asks to download the file...
-//##### When I manually select UTF-8, files display fine.
+//##### Except IE, which asks to download the file...
+//##### When browsers manually set to UTF-8, files display fine.
diff --git a/readme.markdown b/readme.markdown
index 38d84e9..cf42631 100755
--- a/readme.markdown
+++ b/readme.markdown
@@ -34,9 +34,9 @@ With basic editing, upload, and file managing functions, OneFileCMS can maintain
## Features
- All the basic file management features like renaming, moving, copying, deleting, and uploading.
+- A basic text editor.
- Sort directory listings by file name, extension, size, or date.
- Keyboard navigation of directory list. (Arrows, Page Up/Down, Home, End)
-- A basic text editor.
- A WYSIWYG editor may be added as a plugin.
- A login delay after too many invalid login attempts.
- Adjustable idle time before auto-logout.
@@ -65,7 +65,7 @@ You can also change the file name from "onefilecms.php" to something else, such
- PHP 5.1+
(Only tested on versions 5.2.8, 5.2.17, 5.3.3, and 5.4 + )
-- A Javascript enabled browswer.
+- A Javascript enabled browser.
- Most modern browsers probably work, but I only test on Firefox, Chrome, and IE 8.
- And if you wish to see the icons- a browser that supports inline SVG.
(If your browser doesn't support inline SVG, OneFileCMS will still work, just without any icons.)
@@ -106,7 +106,9 @@ Now, since there is no database or other means of granular control or access log
### This is basically just a file manager with a text editor- why is it being called a CMS?
-Becaus "OneFileCMS" sounds cool. And, because it is. It may be simple, but it can get the job done. While you wouldn't want to build a new house from the ground up with just a hammer, hand saw, and tape measure, you can "manage" quite a bit with just those tools (and nails, of course).
+Because it is. It may be simple, but it can get the job done. While you wouldn't want to build a new house from the ground up with just a hammer, hand saw, and tape measure, you can "manage" quite a bit with just those tools.
+
+And, because "OneFileCMS" sounds cool.
### Why do I get a "Stop running this script?" alert during login?
From 24617e1d1a7d4f2d6bb62e464d4294f2993ae25a Mon Sep 17 00:00:00 2001
From: Self-Evident ';
+ $favicon_img = '';
+ if (file_exists($DOC_ROOT.trim($FAVICON,'/'))) {
+ $favicon_img = '
';
}
echo '
';
+ $PWUN_RULES = '
';
}//end Init_Macros() //*********************************************************
@@ -1448,7 +1452,7 @@ function List_Backups_and_Logs() {//********************************************
function Admin_Page() {//*******************************************************
- global $_, $ONESCRIPT, $ipath, $filename, $param1, $param2, $config_title;
+ global $_, $ONESCRIPT, $ipath, $filename, $param1, $param2, $MAIN_TITLE;
// Restore/Preserve $ipath prior to admin page in case OneFileCMS is edited (which would change $ipath).
if ( $_SESSION['admin_page'] ) { $ipath = $_SESSION['admin_ipath'];
@@ -1470,7 +1474,7 @@ function Admin_Page() {//*******************************************************
echo $button_attribs.$param1.'&p=changepw\'">'.hsc($_['pw_change']).'';
echo $button_attribs.$param1.'&p=changeun\'">'.hsc($_['un_change']).'';
echo $button_attribs.$param1.'&p=hash\'">'.hsc($_['Generate_Hash']).'';
- echo $button_attribs.$edit_params.'\'">'.hsc($_['View'].' '.$config_title).'';
+ echo $button_attribs.$edit_params.'\'">'.hsc($_['View'].' '.$MAIN_TITLE).'';
echo '';
echo '
';
+ echo ' ';
}
else {
- echo ' .. /'; //#### '.$ICONS['up_dir'].'
+ echo ''.$ICONS['up_dir'].' .. /'; //#### '.$ICONS['up_dir'].'
}
?>
@@ -1850,7 +1854,7 @@ function Create_Table_for_Listing() {//*****************************************
-
+ '."\n";
- foreach($full_list as $file) {
+ foreach ($full_list as $file) {
$file_OS = Convert_encoding($file);
if (is_dir($ipath_OS.$file_OS)) { echo ''.hsc($_['Selected_Files']).': '; }
else { echo ''.$ICONS['folder'].' '.hsc($file).' / '; }
@@ -2995,7 +3001,7 @@ function Display_Messages($msg, take_focus) {//***********************
var $page = '';
var new_focus = '';
- take_focus = typeof new_focus == 'undefined' ? 0 : take_focus ;//default is X_box doesn't take focus()
+ take_focus = typeof new_focus == 'undefined' ? 0 : take_focus ; //default is X_box doesn't take focus()
if ($page == 'index') { new_focus = 'header_filename'; }
else if ($page == 'edit') { new_focus = 'close1'; }
@@ -3003,7 +3009,7 @@ function Display_Messages($msg, take_focus) {//***********************
else if ($page == 'hash') { new_focus = 'whattohash'; }
else if ($page == 'admin') { new_focus = 'close'; }
- var $X_box = '' .hsc($file).'
';
+ $MESSAGE .= $EX.'$CONFIG_FILE '.hsc($_['Not_found']).': '.$CONFIG_FILE.'
';
$CONFIG_FILE = $CONFIG_FILE_OS = '';
}
}
@@ -260,7 +263,7 @@ function System_Setup() {//*****************************************************
$ACCESS_ROOT_OS = Convert_encoding($ACCESS_ROOT);
if (!is_dir($DOC_ROOT_OS.$ACCESS_ROOT_OS) || (Check_path($ACCESS_ROOT,1) === false) ) {
- $message .= __LINE__.$EX.'$ACCESS_ROOT '.hsc($_['Invalid_path']).': '.$ACCESS_ROOT.'
';
+ $MESSAGE .= __LINE__.$EX.'$ACCESS_ROOT '.hsc($_['Invalid_path']).': '.$ACCESS_ROOT.'
';
$ACCESS_ROOT = $ACCESS_ROOT_OS = '';
}
if ($ACCESS_ROOT != '') {
@@ -280,14 +283,14 @@ function System_Setup() {//*****************************************************
//Make arrays out of a few config variables for actual use later.
//First, remove spaces and make lowercase (for *types).
-$SHOWALLFILES = $stypes = false;
+$SHOWALLFILES = $STYPES = false;
if ($SHOW_FILES == '*') { $SHOWALLFILES = true; }
- else { $stypes = explode(',', mb_strtolower(str_replace(' ', '', $SHOW_FILES))); }//shown file types
-$etypes = explode(',', mb_strtolower(str_replace(' ', '', $EDIT_FILES))); //editable file types
-$itypes = explode(',', mb_strtolower(str_replace(' ', '', $SHOW_IMGS))); //images types to display
-$ftypes = explode(',', mb_strtolower(str_replace(' ', '', $FILE_TYPES))); //file types with icons
-$fclasses = explode(',', mb_strtolower(str_replace(' ', '', $FILE_CLASSES))); //for file types with icons
-$excluded_list = explode(',', str_replace(' ', '', $EXCLUDED_FILES));
+ else { $STYPES = explode(',', mb_strtolower(str_replace(' ', '', $SHOW_FILES))); }//shown file types
+$ETYPES = explode(',', mb_strtolower(str_replace(' ', '', $EDIT_FILES))); //editable file types
+$ITYPES = explode(',', mb_strtolower(str_replace(' ', '', $SHOW_IMGS))); //images types to display
+$FTYPES = explode(',', mb_strtolower(str_replace(' ', '', $FILE_TYPES))); //file types with icons
+$FCLASSES = explode(',', mb_strtolower(str_replace(' ', '', $FILE_CLASSES))); //for file types with icons
+$EXCLUDED_LIST = explode(',', str_replace(' ', '', $EXCLUDED_FILES));
//A few variables for values that were otherwise hardcoded in js.
@@ -312,7 +315,7 @@ function System_Setup() {//*****************************************************
function Default_Language() { // ***********************************************
global $_;
-// OneFileCMS Language Settings v3.5.18
+// OneFileCMS Language Settings v3.5.19
$_['LANGUAGE'] = 'English';
$_['LANG'] = 'EN';
@@ -334,7 +337,7 @@ function Default_Language() { // ***********************************************
$_['MCD_margin_R'] = '1.0em'; //[Move] [Copy] [Delete] buttons
$_['button_font_size'] = '0.9em'; //Buttons on Edit page.
$_['button_margin_L'] = '0.7em';
-$_['button_padding'] = '4px 7px 4px 7px'; //T R B L
+$_['button_padding'] = '4px 4px 4px 4px'; //T R B L
$_['image_info_font_size'] = '1em'; //show_img_msg_01 & _02
$_['image_info_pos'] = ''; //If 1 or true, moves the info down a line for more space.
$_['select_all_label_size'] = '.84em'; //Font size of $_['Select_All']
@@ -368,6 +371,7 @@ function Default_Language() { // ***********************************************
$_['Moved'] = 'Moved';
$_['Name'] = 'Name';
$_['on'] = 'on';
+$_['off'] = 'off'; //## NT ## as of 3.5.19
$_['Password'] = 'Password';
$_['Rename'] = 'Rename';
$_['reset'] = 'Reset';
@@ -390,6 +394,7 @@ function Default_Language() { // ***********************************************
$_['Edit_View'] = 'Edit / View';
$_['Wide_View'] = 'Wide View';
$_['Normal_View'] = 'Normal View';
+$_['Word_Wrap'] = 'Word Wrap'; //## NT ## as of 3.5.19
$_['Upload_File'] = 'Upload File';
$_['New_File'] = 'New File';
$_['Ren_Move'] = 'Rename / Move';
@@ -613,7 +618,7 @@ function Session_Startup() {//**************************************************
function Verify_IDLE_POST_etc() {//*********************************************
- global $_, $page, $EX, $message, $VALID_POST, $MAX_IDLE_TIME;
+ global $_, $page, $EX, $MESSAGE, $VALID_POST, $MAX_IDLE_TIME;
//Verify consistant user agent. This is set during login. (every little bit helps every little bit)
if ( !isset($_SESSION['user_agent']) || ($_SESSION['user_agent'] != $_SERVER['HTTP_USER_AGENT']) ) { Logout(); }
@@ -623,7 +628,7 @@ function Verify_IDLE_POST_etc() {//*********************************************
$idle_time = ( time() - $_SESSION['last_active_time'] );
if ( $idle_time > $MAX_IDLE_TIME ) {
Logout();
- $message .= hsc($_['verify_msg_01']).'
';
+ $MESSAGE .= hsc($_['verify_msg_01']).'
';
return;
}
}
@@ -637,7 +642,7 @@ function Verify_IDLE_POST_etc() {//*********************************************
}else{ //If it exists but doesn't match - something's wrong. Probably a page reload.
$page = "index";
$_POST = "";
- $message .= $EX.''.hsc($_['verify_msg_02']).'
';
+ $MESSAGE .= $EX.''.hsc($_['verify_msg_02']).'
';
}
}
}//end Verify_IDLE_POST_etc() //************************************************
@@ -761,7 +766,7 @@ function strip_array($var) {
function Validate_params() {//**************************************************
- global $_, $ipath, $filename, $page, $param1, $param2, $param3, $IS_OFCMS, $EX, $message;
+ global $_, $ipath, $filename, $page, $param1, $param2, $param3, $IS_OFCMS, $EX, $MESSAGE;
//Pages that require a valid $filename
$file_pages = array("edit", "renamefile", "copyfile", "deletefile");
@@ -786,7 +791,7 @@ function Validate_params() {//**************************************************
function Valid_Path($path, $gotoroot=true) {//**********************************
//$gotoroot: if true, return to index page of $ACCESS_ROOT.
- global $ipath, $ipath_OS, $filename, $param1, $param2, $param3, $ACCESS_ROOT, $ACCESS_ROOT_len, $message;
+ global $ipath, $ipath_OS, $filename, $param1, $param2, $param3, $ACCESS_ROOT, $ACCESS_ROOT_len, $MESSAGE;
//Limit access to the folder $ACCESS_ROOT:
//$ACCESS_ROOT = some/root/path/
@@ -827,9 +832,9 @@ function Valid_Path($path, $gotoroot=true) {//**********************************
function Get_GET() {//**** Get URL passed parameters ***************************
- global $_, $ipath, $ipath_OS, $filename, $filename_OS, $page, $VALID_PAGES, $EX, $message;
+ global $_, $ipath, $ipath_OS, $filename, $filename_OS, $page, $VALID_PAGES, $EX, $MESSAGE;
// i=some/path/, f=somefile.xyz, p=somepage, m=somemessage
- // $ipath = i , $filename = $ipath.f , $page = p , $message
+ // $ipath = i , $filename = $ipath.f , $page = p , $MESSAGE
// (NOTE: in some functions $filename = just the file's name, ie: $_GET['f'], with no path/)
//##### (Normalize $filename program-wide??)
// Perform initial, basic, validation.
@@ -848,27 +853,27 @@ function Get_GET() {//**** Get URL passed parameters ***************************
$filename_OS = Convert_encoding($filename);
if ( ($filename != "") && !is_file($filename_OS) ) {
- $message .= $EX.''.hsc($_['get_get_msg_01']).' ';
- $message .= hsc(dir_name($filename)).''.hsc(basename($filename)).'
';
+ $MESSAGE .= $EX.''.hsc($_['get_get_msg_01']).' ';
+ $MESSAGE .= hsc(dir_name($filename)).''.hsc(basename($filename)).'
';
$filename = $filename_OS = "";
}
//Initialize & validate $page
if (isset($_GET["p"])) { $page = $_GET["p"]; } else { $page = "index"; }
if (!in_array($page, $VALID_PAGES)) {
- $message .= $EX.hsc($_['get_get_msg_02']).' '.hsc($page).'
';
+ $MESSAGE .= $EX.hsc($_['get_get_msg_02']).' '.hsc($page).'
';
$page = "index"; //If invalid $_GET["p"]
}
//Sanitize any message. Initialized on line 1 / top of this file.
- if (isset($_GET["m"])) { $message .= hsc($_GET["m"]); }
+ if (isset($_GET["m"])) { $MESSAGE .= hsc($_GET["m"]); }
}//end Get_GET() //*************************************************************
function Verify_Page_Conditions() {//*******************************************
- global $_, $ONESCRIPT_file, $ipath, $ipath_OS, $param1, $filename, $filename_OS, $page, $EX, $message,
+ global $_, $ONESCRIPT_file, $ipath, $ipath_OS, $param1, $filename, $filename_OS, $page, $EX, $MESSAGE,
$VALID_POST, $IS_OFCMS;
//If exited admin pages, restore $ipath
@@ -887,7 +892,7 @@ function Verify_Page_Conditions() {//*******************************************
elseif ( $page == "logout" ) {
Logout();
- $message .= hsc($_['logout_msg']);
+ $MESSAGE .= hsc($_['logout_msg']);
}
//Don't load rename or delete folder pages at webroot.
elseif ( ($page == "deletefolder" || $page == "renamefolder") && ($ipath == "") ) {
@@ -910,7 +915,7 @@ function Verify_Page_Conditions() {//*******************************************
}
//if size of $_POST > post_max_size, PHP only returns empty $_POST & $_FILE arrays.
elseif ( ($page == "uploaded") && !$VALID_POST ) {
- $message .= $EX.' '.hsc($_['upload_error_01a']).' '.ini_get('post_max_size').' '.hsc($_['upload_error_01b']).'
';
+ $MESSAGE .= $EX.' '.hsc($_['upload_error_01a']).' '.ini_get('post_max_size').' '.hsc($_['upload_error_01b']).'
';
$page = "index";
}
@@ -967,7 +972,7 @@ function dir_name($path) {//****************************************************
function Check_path($path, $show_msg = false) {//*******************************
// check for invalid characters & "dot" or "dot dot" path segments.
// Does NOT check if exists - only if of valid construction.
- global $_, $message, $EX, $INVALID_CHARS, $WHSPC_SLASH;
+ global $_, $MESSAGE, $EX, $INVALID_CHARS, $WHSPC_SLASH;
$path = str_replace('\\','/',$path); //Make sure all forward slashes.
$path = trim($path, $WHSPC_SLASH); // trim whitespace & slashes
@@ -999,7 +1004,7 @@ function Check_path($path, $show_msg = false) {//*******************************
}
if ($errors > 0) {
- if ($show_msg) { $message .= $err_msg; }
+ if ($show_msg) { $MESSAGE .= $err_msg; }
return false;
}
@@ -1074,7 +1079,7 @@ function supports_svg() {//*****************************************************
function rCopy( $old_path, $new_path ) {//**************************************
- global $_, $WHSPC_SLASH, $EX, $message;
+ global $_, $WHSPC_SLASH, $EX, $MESSAGE;
//Recursively copy $old_path to $new_path
//Both $old_ & $new_path must ALREADY be in OS/file system's encoding.
//(ie: usually UTF-8, but often ISO-8859-1 for Windows.)
@@ -1097,7 +1102,7 @@ function rCopy( $old_path, $new_path ) {//**************************************
while (mb_strlen($test_path) >= mb_strlen($old_path)) {
$test_path = dirname($test_path);
if ( $test_path == $old_path ) {
- $message .= $EX.' '.hsc($_['rCopy_msg_01']).'
';
+ $MESSAGE .= $EX.' '.hsc($_['rCopy_msg_01']).'
';
return 0;
}
}
@@ -1158,7 +1163,7 @@ function rDel($path) {//********************************************************
function Current_Path_Header() {//**********************************************
// Current path. ie: webroot/current/path/
// Each level is a link to that level.
- global $ONESCRIPT, $ipath, $WEB_ROOT, $ACCESS_ROOT, $ACCESS_ROOT_len, $TABINDEX, $message;
+ global $ONESCRIPT, $ipath, $WEB_ROOT, $ACCESS_ROOT, $ACCESS_ROOT_len, $TABINDEX, $MESSAGE;
$unaccessable = '';
$_1st_accessable = trim($WEB_ROOT, ' /');
@@ -1198,7 +1203,7 @@ function Current_Path_Header() {//**********************************************
function Page_Header() {//******************************************************
- global $_, $DOC_ROOT, $ONESCRIPT, $page, $WEBSITE, $MAIN_TITLE, $OFCMS_version, $FAVICON, $TABINDEX, $message;
+ global $_, $DOC_ROOT, $ONESCRIPT, $page, $WEBSITE, $MAIN_TITLE, $OFCMS_version, $FAVICON, $TABINDEX, $MESSAGE;
$TABINDEX = 1; //Initial tabindex
@@ -1527,7 +1532,7 @@ function Hash_Page() {//********************************************************
function Hash_response() {//****************************************************
- global $_, $message;
+ global $_, $MESSAGE;
$_POST['whattohash'] = trim($_POST['whattohash']); // trim whitespace.
//Ignore/don't hash an empty string - passwords can't be blank.
@@ -1535,8 +1540,8 @@ function Hash_response() {//****************************************************
//The second parameter to hashit(), 1, tells hashit() to also do the "pre-hash", which is
//normally done client-side during a login attempt, p/w change, or u/n change.
- $message .= hsc($_['Password']).': '.hsc($_POST['whattohash']).'
';
- $message .= hsc($_['Hash']).': '.hashit($_POST['whattohash'], 1).'
';
+ $MESSAGE .= hsc($_['Password']).': '.hsc($_POST['whattohash']).'
';
+ $MESSAGE .= hsc($_['Hash']).': '.hashit($_POST['whattohash'], 1).'
';
}//end Hash_response() //*******************************************************
@@ -1592,13 +1597,13 @@ function Change_PWUN_Page($pwun, $type, $page_title, $label_new, $label_confirm)
//******************************************************************************
function Update_config($search_for, $replace_with, $search_file, $backup_file) {
- global $_, $EX, $message;
+ global $_, $EX, $MESSAGE;
$search_file_OS = Convert_encoding($search_file);
$backup_file_OS = Convert_encoding($backup_file);
if ( !is_file($search_file_OS) ) {
- $message .= $EX.' '.hsc($_['Not_found']).': '.hsc($search_file).'
';
+ $MESSAGE .= $EX.' '.hsc($_['Not_found']).': '.hsc($search_file).'
';
return false;
}
@@ -1618,14 +1623,14 @@ function Update_config($search_for, $replace_with, $search_file, $backup_file) {
}
//This should not happen, but just in case...
- if (!$found){ $message .= $EX.' '.hsc($_['Not_found']).': '.hsc($search_for).'
'; return false; }
+ if (!$found){ $MESSAGE .= $EX.' '.hsc($_['Not_found']).': '.hsc($search_for).'
'; return false; }
copy($search_file_OS, $backup_file_OS); // Just in case...
$updated_contents = implode("\n", $search_lines);
if (file_put_contents($search_file_OS, $updated_contents, LOCK_EX) === false) {
- $message .= $EX.''.hsc($_['update_failed']).'
';
+ $MESSAGE .= $EX.''.hsc($_['update_failed']).'
';
return false;
}else {return true;}
}//end Update_config() //*******************************************************
@@ -1635,7 +1640,7 @@ function Update_config($search_for, $replace_with, $search_file, $backup_file) {
function Change_PWUN_response($PWUN, $msg) {//**********************************
//Update $USERNAME or $HASHWORD. Default $page = changepw or changeun
- global $_, $ONESCRIPT, $USERNAME, $HASHWORD, $EX, $message, $page,
+ global $_, $ONESCRIPT, $USERNAME, $HASHWORD, $EX, $MESSAGE, $page,
$ONESCRIPT_file, $ONESCRIPT_file_backup, $CONFIG_FILE, $CONFIG_FILE_backup, $VALID_CONFIG_FILE;
// trim white-space from input values
@@ -1651,15 +1656,15 @@ function Change_PWUN_response($PWUN, $msg) {//**********************************
}
//If any field is blank...
elseif ( ($current_pass == "") || ($new_pwun == "") || ($confirm_pwun == "") ) {
- $message .= $error_msg.hsc($_['change_pw_07']).'
';
+ $MESSAGE .= $error_msg.hsc($_['change_pw_07']).'
';
}
//If new & Confirm values don't match...
elseif ($new_pwun != $confirm_pwun) {
- $message .= $error_msg.hsc($_['change_pw_04']).'
';
+ $MESSAGE .= $error_msg.hsc($_['change_pw_04']).'
';
}
//If incorrect current p/w, logout. (new == confirm at this point)
elseif (hashit($current_pass) != $HASHWORD) {
- $message .= $error_msg.'
'.hsc($_['change_pw_03']).'
';
+ $MESSAGE .= $error_msg.'
'.hsc($_['change_pw_03']).'
';
Logout();
}
//Else change username or password
@@ -1676,15 +1681,15 @@ function Change_PWUN_response($PWUN, $msg) {//**********************************
//If specified & it exists, update external config file.
if ( $VALID_CONFIG_FILE ) {
- $message .= hsc($_['change_pw_05']).' '.hsc($_['change_pw_06']).'. . . ';
+ $MESSAGE .= hsc($_['change_pw_05']).' '.hsc($_['change_pw_06']).'. . . ';
$updated = Update_config($search_for, $replace_with, $CONFIG_FILE, $CONFIG_FILE_backup);
}else{ //Update OneFileCMS
- $message .= hsc($_['change_pw_05']).' OneFileCMS . . . ';
+ $MESSAGE .= hsc($_['change_pw_05']).' OneFileCMS . . . ';
$updated = Update_config($search_for, $replace_with, $ONESCRIPT_file, $ONESCRIPT_file_backup);
}
- if ($updated === false) { $message .= $error_msg.'
'; }
- else { $message .= $success_msg.'
'; }
+ if ($updated === false) { $MESSAGE .= $error_msg.'
'; }
+ else { $MESSAGE .= $success_msg.'
'; }
$page = "admin"; //Return to Admin page.
}
@@ -1734,7 +1739,7 @@ function Login_Page() {//*******************************************************
function Login_response() {//***************************************************
- global $_, $EX, $ONESCRIPT_file, $message, $page, $USERNAME, $HASHWORD,
+ global $_, $EX, $ONESCRIPT_file, $MESSAGE, $page, $USERNAME, $HASHWORD,
$LOGIN_ATTEMPTS, $MAX_ATTEMPTS, $LOGIN_DELAY, $LOGIN_DELAYED, $LOG_LOGINS, $LOGIN_LOG_file;
$_SESSION = array(); //make sure it's empty
@@ -1750,11 +1755,11 @@ function Login_response() {//***************************************************
$attempts = (int)file_get_contents($LOGIN_ATTEMPTS);
$elapsed = time() - filemtime($LOGIN_ATTEMPTS);
}
- if ($attempts > 0) { $message .= ''.hsc($_['login_msg_01a']).' '.$attempts.' '.hsc($_['login_msg_01b']).'
'; }
+ if ($attempts > 0) { $MESSAGE .= ''.hsc($_['login_msg_01a']).' '.$attempts.' '.hsc($_['login_msg_01b']).'
'; }
if ( ($attempts >= $MAX_ATTEMPTS) && ($elapsed < $LOGIN_DELAY) ){
$LOGIN_DELAYED = ($LOGIN_DELAY - $elapsed);
- $message .= hsc($_['login_msg_02a']).' '.hsc($_['login_msg_02b']);
+ $MESSAGE .= hsc($_['login_msg_02a']).' '.hsc($_['login_msg_02b']);
return;
}
@@ -1775,10 +1780,10 @@ function Login_response() {//***************************************************
}else{
file_put_contents($LOGIN_ATTEMPTS, ++$attempts); //increment attempts
- $message = $EX.''.hsc($_['login_msg_03']).$attempts.'
';
+ $MESSAGE = $EX.''.hsc($_['login_msg_03']).$attempts.'
';
if ($attempts >= $MAX_ATTEMPTS) {
$LOGIN_DELAYED = $LOGIN_DELAY;
- $message .= hsc($_['login_msg_02a']).' '.hsc($_['login_msg_02b']);
+ $MESSAGE .= hsc($_['login_msg_02a']).' '.hsc($_['login_msg_02b']);
}
}
@@ -1863,8 +1868,8 @@ function Create_Table_for_Listing() {//*****************************************
function Get_DIRECTORY_DATA($raw_list) {//**************************************
- global $_, $ONESCRIPT, $ipath, $ipath_OS, $param1, $ICONS, $message,
- $ftypes, $fclasses, $excluded_list, $stypes, $SHOWALLFILES,
+ global $_, $ONESCRIPT, $ipath, $ipath_OS, $param1, $ICONS, $MESSAGE,
+ $FTYPES, $FCLASSES, $EXCLUDED_LIST, $STYPES, $SHOWALLFILES,
$DIRECTORY_COUNT, $DIRECTORY_DATA, $ENC_OS;
//Doesn't use global $filename or $filename_OS in this function (because they shouldn't exist on the Index page)
@@ -1881,7 +1886,7 @@ function Get_DIRECTORY_DATA($raw_list) {//**************************************
if ($ENC_OS == 'UTF-8') {$filename = $raw_filename;}
else {$filename = Convert_encoding($raw_filename,'UTF-8');}
- //Get file .ext & check against $stypes (files types to show)
+ //Get file .ext & check against $STYPES (files types to show)
$filename_parts = explode(".", mb_strtolower($filename));
//Check for no $ext: "filename" or ".filename"
@@ -1892,9 +1897,9 @@ function Get_DIRECTORY_DATA($raw_list) {//**************************************
//Check $filename & $ext against white & black lists. If not to be shown, get next $filename...
if (!is_dir($filename_OS)) {
- if ($SHOWALLFILES || in_array($ext, $stypes)) { $SHOWTYPE = TRUE; } else { $SHOWTYPE = FALSE; }
- if (in_array($filename, $excluded_list)) { $excluded = TRUE; } else { $excluded = FALSE; }
- if ( !$SHOWTYPE || in_array($filename, $excluded_list) ) { continue; }
+ if ($SHOWALLFILES || in_array($ext, $STYPES)) { $SHOWTYPE = TRUE; } else { $SHOWTYPE = FALSE; }
+ if (in_array($filename, $EXCLUDED_LIST)) { $excluded = TRUE; } else { $excluded = FALSE; }
+ if ( !$SHOWTYPE || in_array($filename, $EXCLUDED_LIST) ) { continue; }
}
//Used to hide rename & delete options for active copy of OneFileCMS.
@@ -1903,10 +1908,10 @@ function Get_DIRECTORY_DATA($raw_list) {//**************************************
//Set icon type based on if dir, or file type ($ext).
if (is_dir($filename_OS)) { $type = 'dir'; }
- else { $type = $fclasses[array_search($ext, $ftypes)]; }
+ else { $type = $FCLASSES[array_search($ext, $FTYPES)]; }
//Determine icon to show
- if (in_array($type,$fclasses)) { $icon = $ICONS[$type];}
+ if (in_array($type,$FCLASSES)) { $icon = $ICONS[$type];}
elseif ($type == 'dir') { $icon = $ICONS['folder']; }
else { $icon = $ICONS['bin']; } //default
@@ -2019,7 +2024,7 @@ function Index_Page() {//*******************************************************
function Edit_Page_buttons_top($text_editable,$file_ENC) {//********************
global $_, $ONESCRIPT, $param1, $param2, $filename, $filename_OS, $IS_OFCMS,
- $WYSIWYG_VALID, $EDIT_WYSIWYG, $WYSIWYG_label, $message;
+ $WYSIWYG_VALID, $EDIT_WYSIWYG, $WYSIWYG_label, $MESSAGE;
clearstatcache ();
@@ -2072,7 +2077,7 @@ function Edit_Page_buttons_top($text_editable,$file_ENC) {//********************
function Edit_Page_buttons($text_editable, $too_large_to_edit) {//**************
- global $_, $message, $ICONS, $MAX_IDLE_TIME, $IS_OFCMS, $WYSIWYG_VALID, $EDIT_WYSIWYG;
+ global $_, $MESSAGE, $ICONS, $MAX_IDLE_TIME, $IS_OFCMS, $WYSIWYG_VALID, $EDIT_WYSIWYG;
//Using ckeditor WYSIWYG editor, button doesn't work. (I don't know why.)
$reset_button = '';
@@ -2105,8 +2110,8 @@ function RCD_button($action, $icon, $label) {//***************
//******************************************************************************
function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_view, $file_ENC){
- global $_, $ONESCRIPT, $param1, $param2, $param3, $filename, $filename_OS, $itypes, $INPUT_NUONCE, $EX, $message,
- $FILECONTENTS, $WYSIWYG_VALID, $EDIT_WYSIWYG, $IS_OFCMS, $MAX_EDIT_SIZE, $MAX_VIEW_SIZE;
+ global $_, $ONESCRIPT, $param1, $param2, $param3, $filename, $filename_OS, $ITYPES, $INPUT_NUONCE, $EX, $MESSAGE,
+ $FILECONTENTS, $WYSIWYG_VALID, $EDIT_WYSIWYG, $IS_OFCMS, $MAX_EDIT_SIZE, $MAX_VIEW_SIZE, $WORD_WRAP;
$too_large_to_edit_message =
''.hsc($_['too_large_to_edit_01']).' '.number_format($MAX_EDIT_SIZE).' '.hsc($_['bytes']).'
'.
@@ -2122,10 +2127,10 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_
Edit_Page_buttons_top($text_editable, $file_ENC);
- if ( !in_array( mb_strtolower($ext), $itypes) ) { //If non-image...
+ if ( !in_array( mb_strtolower($ext), $ITYPES) ) { //If non-image...
- if (!$text_editable) { $message .= hsc($_['edit_txt_01']).'
'; }
- elseif ( $too_large_to_edit ) { $message .= $too_large_to_edit_message; }
+ if (!$text_editable) { $MESSAGE .= hsc($_['edit_txt_01']).'
'; }
+ elseif ( $too_large_to_edit ) { $MESSAGE .= $too_large_to_edit_message; }
elseif (!$IS_OFCMS) {
//Did htmlspecialchars return an empty string from a non-empty file?
$bad_chars = ( ($FILECONTENTS == "") && (filesize($filename_OS) > 0) );
@@ -2135,10 +2140,22 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_
echo hsc($_['edit_txt_03']).'
';
echo hsc($_['edit_txt_04']).'
'."\n";
}else{ //show editable
';
+ $MESSAGE .= '';
+ $MESSAGE .= '';
+ $MESSAGE .= ''.$EX.hsc($_['edit_caution_02']).' '.$_['edit_txt_00'].'
';
}
}//end Edit_Page() //***********************************************************
@@ -2239,7 +2256,7 @@ function Edit_Page() {//********************************************************
function Edit_response() {//***If on Edit page, and [Save] clicked *************
- global $_, $EX, $message, $filename, $filename_OS;
+ global $_, $EX, $MESSAGE, $filename, $filename_OS;
$contents = $_POST['contents'];
@@ -2249,9 +2266,9 @@ function Edit_response() {//***If on Edit page, and [Save] clicked *************
$bytes = file_put_contents($filename_OS, $contents);
if ($bytes !== false) {
- $message .= ''.hsc($_['edit_msg_01']).' '.number_format($bytes).' '.hsc($_['edit_msg_02']).'
';
+ $MESSAGE .= ''.hsc($_['edit_msg_01']).' '.number_format($bytes).' '.hsc($_['edit_msg_02']).'
';
}else{
- $message .= $EX.''.hsc($_['edit_msg_03']).'
';
+ $MESSAGE .= $EX.''.hsc($_['edit_msg_03']).'
';
}
}//end Edit_response() //*******************************************************
@@ -2301,7 +2318,7 @@ function Upload_Page() {//******************************************************
function Upload_response() {//**************************************************
- global $_, $ipath, $ipath_OS, $page, $EX, $message, $UPLOAD_FIELDS;
+ global $_, $ipath, $ipath_OS, $page, $EX, $MESSAGE, $UPLOAD_FIELDS;
$page = "index"; //return to index.
@@ -2324,11 +2341,11 @@ function Upload_response() {//**************************************************
else { $ERRMSG = ''; }
if ( ($ipath === false) || (($ipath != "") && !is_dir($ipath_OS))) {
- $message .= $EX.''.hsc($_['upload_msg_02']).'
';
- $message .= ''.hsc($ipath).'
';
- $message .= hsc($_['upload_msg_03']).'
';
+ $MESSAGE .= $EX.''.hsc($_['upload_msg_02']).'
';
+ $MESSAGE .= ''.hsc($ipath).'
';
+ $MESSAGE .= hsc($_['upload_msg_03']).'
';
}else{
- $message .= ''.hsc($_['upload_msg_04']).' '.hsc(basename($filename_up)).'
';
+ $MESSAGE .= ''.hsc($_['upload_msg_04']).' '.hsc(basename($filename_up)).'
';
if ( isset($_POST['ifexists']) && ($_POST['ifexists'] == 'overwrite') ) {
if (is_file($filename_OS)) { $savefile_msg .= hsc($_['upload_msg_07']) ; }
@@ -2338,9 +2355,9 @@ function Upload_response() {//**************************************************
$filename_OS = Convert_encoding($filename_up);
if(move_uploaded_file($_FILES['upload_file']['tmp_name'][$N], $filename_OS)) {
- $message .= ''.hsc($_['upload_msg_05']).' '.$savefile_msg.'
';
+ $MESSAGE .= ''.hsc($_['upload_msg_05']).' '.$savefile_msg.'
';
} else{
- $message .= ''.$EX.hsc($_['upload_msg_06']).' '.$ERRMSG.'
';
+ $MESSAGE .= ''.$EX.hsc($_['upload_msg_06']).' '.$ERRMSG.'
';
}
}
}//end foreach $_FILES
@@ -2367,7 +2384,7 @@ function New_Page($title, $new_f_or_f) {//**************************************
function New_response($post, $isfile) {//***************************************
- global $_, $ipath, $ipath_OS, $filename, $filename_OS, $page, $param1, $param2, $param3, $message, $EX, $INVALID_CHARS, $WHSPC_SLASH;
+ global $_, $ipath, $ipath_OS, $filename, $filename_OS, $page, $param1, $param2, $param3, $MESSAGE, $EX, $INVALID_CHARS, $WHSPC_SLASH;
$page = "index"; //Return to index if folder, or on error.
@@ -2382,30 +2399,30 @@ function New_response($post, $isfile) {//***************************************
$msg_new = ''.hsc($new_name).'
';
if (has_invalid_char($new_name)){
- $message .= $EX.''.hsc($_['new_file_msg_01']).' '.$msg_new;
- $message .= ''.hsc($_['new_file_msg_02']).' '.hsc($INVALID_CHARS).'';
+ $MESSAGE .= $EX.''.hsc($_['new_file_msg_01']).' '.$msg_new;
+ $MESSAGE .= ''.hsc($_['new_file_msg_02']).' '.hsc($INVALID_CHARS).'';
}elseif ($new_name == ""){ //No new name given.
$page = "new".$f_or_f;
$param3 = '&p=index'; //For [Cancel] button
}elseif (file_exists($filename_OS)) { //Does file or folder already exist ?
- $message .= $EX.''.hsc($_['new_file_msg_04']).' '.$msg_new;
+ $MESSAGE .= $EX.''.hsc($_['new_file_msg_04']).' '.$msg_new;
}elseif ($isfile && touch($filename_OS) ) { //Create File
- $message .= ''.hsc($_['new_file_msg_05']).' '.$msg_new; //New File success.
+ $MESSAGE .= ''.hsc($_['new_file_msg_05']).' '.$msg_new; //New File success.
$page = "edit"; //Return to edit page.
$param2 = '&f='.rawurlencode(basename($filename)); //for Edit_Page() buttons
$param3 = '&p=edit'; //for Edit_Page() buttons
}elseif (!$isfile && mkdir($filename_OS,0755)) { //Create Folder
- $message .= ''.hsc($_['new_file_msg_07']).' '.$msg_new; //New folder success
+ $MESSAGE .= ''.hsc($_['new_file_msg_07']).' '.$msg_new; //New folder success
$ipath = $filename; //return to new folder
$ipath_OS = Convert_encoding($filename);
$param1 = '?i='.URLencode_path($ipath);
}else{
- $message .= $EX.''.hsc($_['new_file_msg_01']).':
'.$msg_new; //'Error - new file not created:'
+ $MESSAGE .= $EX.''.hsc($_['new_file_msg_01']).':
'.$msg_new; //'Error - new file not created:'
}
}//end New_response() //********************************************************
@@ -2481,7 +2498,7 @@ function CRM_response($action, $msg1, $show_message = 3) {//********************
//$action = 'rCopy' or 'rename'. Returns 0 if successful, 1 on error.
//$show_message: 0 = none; 1 = errors only; 2 = successes only; 3 = all messages (default).
global $_, $ONESCRIPT, $ipath, $ipath_OS, $filename, $page, $param1, $param2, $param3,
- $message, $EX, $INVALID_CHARS, $WHSPC_SLASH;
+ $MESSAGE, $EX, $INVALID_CHARS, $WHSPC_SLASH;
$old_full_name = trim($_POST['old_full_name'], $WHSPC_SLASH); //Trim whitespace & slashes.
$new_name_only = trim($_POST['new_name'], $WHSPC_SLASH);
@@ -2549,8 +2566,8 @@ function CRM_response($action, $msg1, $show_message = 3) {//********************
if (($bad_name !='' ) && ($error_code == 0)) { $err_msg .= ''.hsc($bad_name).'
'; }
- if (($show_message & 1) && ($error_code == 0)) { $message .= $err_msg; } //Show error message.
- if ( $show_message & 2) { $message .= $scs_msg; } //Show success message.
+ if (($show_message & 1) && ($error_code == 0)) { $MESSAGE .= $err_msg; } //Show error message.
+ if ( $show_message & 2) { $MESSAGE .= $scs_msg; } //Show success message.
//Prior page should be either index or edit
$page = $_SESSION['recent_pages'][1];
@@ -2564,7 +2581,7 @@ function CRM_response($action, $msg1, $show_message = 3) {//********************
function Delete_response($target, $show_message=3) {//**************************
- global $_, $ipath, $ipath_OS, $param1, $filename, $param2, $page, $message, $EX;
+ global $_, $ipath, $ipath_OS, $param1, $filename, $param2, $page, $MESSAGE, $EX;
if ($target == "") { return 0; } //Prevent accidental delete of entire website.
@@ -2596,8 +2613,8 @@ function Delete_response($target, $show_message=3) {//**************************
}
}
- if ($show_message & 1) { $message .= $err_msg; } //Show error message.
- if ($show_message & 2) { $message .= $scs_msg; } //Show success message.
+ if ($show_message & 1) { $MESSAGE .= $err_msg; } //Show error message.
+ if ($show_message & 2) { $MESSAGE .= $scs_msg; } //Show success message.
return $error_code;
}//end Delete_response() //*****************************************************
@@ -2608,7 +2625,7 @@ function Delete_response($target, $show_message=3) {//**************************
function MCD_Page($action, $page_title, $classes = '') {//**********************
//$action = mcd_mov or mcd_cpy or mcd_del
global $_, $WEB_ROOT, $ONESCRIPT, $ipath, $ipath_OS, $param1, $filename, $page,
- $ICONS, $ACCESS_ROOT, $ACCESS_PATH, $INPUT_NUONCE, $message;
+ $ICONS, $ACCESS_ROOT, $ACCESS_PATH, $INPUT_NUONCE, $MESSAGE;
//Prep for a single file or folder
if( $page == "deletefile" || $page == "deletefolder" ){
@@ -2655,7 +2672,7 @@ function MCD_Page($action, $page_title, $classes = '') {//**********************
function MCD_response($action, $msg1, $success_msg = '') {//********************
- global $_, $ipath, $ipath_OS, $EX, $message, $WHSPC_SLASH;
+ global $_, $ipath, $ipath_OS, $EX, $MESSAGE, $WHSPC_SLASH;
$files = $_POST['files']; //List of files to delete (path not included)
$errors = 0; //number of failed moves, copies, or deletes
@@ -2670,8 +2687,8 @@ function MCD_response($action, $msg1, $success_msg = '') {//********************
$show_message = 1; //1= show error msg only.
if ( ($new_location != "") && !is_dir($new_location_OS)) {
- $message .= $EX.''.hsc($msg1.' '.$_['CRM_msg_01']).'
';
- $message .= ''.hsc($_POST['new_location']).'
';
+ $MESSAGE .= $EX.''.hsc($msg1.' '.$_['CRM_msg_01']).'
';
+ $MESSAGE .= ''.hsc($_POST['new_location']).'
';
return;
}elseif ($action == 'rDel') {
foreach ($files as $file){
@@ -2693,15 +2710,15 @@ function MCD_response($action, $msg1, $success_msg = '') {//********************
}
}
- if ($errors) {$message .= $EX.' '.$errors.' '.hsc($_['errors']).'.
';}
+ if ($errors) {$MESSAGE .= $EX.' '.$errors.' '.hsc($_['errors']).'.
';}
- $message .= ''.$successful.' '.hsc($success_msg).'
';
+ $MESSAGE .= ''.$successful.' '.hsc($success_msg).'
';
if ($action != 'rDel') {
if ($successful > 0) { //"From:" & "To:" lines if any successes.
- $message .= '
'.hsc($_['To']).'
';
- $message .= ': '.hsc($ipath).'
';
+ $MESSAGE .= '
'.hsc($_['To']).'
';
+ $MESSAGE .= ': '.hsc($ipath).'
';
}
}
}//end MCD_response() //********************************************************
@@ -2766,21 +2783,21 @@ function Load_Selected_Page() {//***********************************************
function Respond_to_POST() {//**************************************************
- global $_, $VALID_POST, $ipath, $page, $EX, $ACCESS_ROOT, $message;
+ global $_, $VALID_POST, $ipath, $page, $EX, $ACCESS_ROOT, $MESSAGE;
if (!$VALID_POST) { return; }
//First, validate any $_POST'ed paths against $ACCESS_ROOT.
if (isset($_POST["old_full_name"]) && !Valid_Path($_POST["old_full_name"], false)) {
//unlikely, but just in case
- $message .= $EX.''.hsc($_['Invalid_path']).': '.hsc($_POST["old_full_name"]).'';
+ $MESSAGE .= $EX.''.hsc($_['Invalid_path']).': '.hsc($_POST["old_full_name"]).'';
$VALID_POST = 0;
return;
}
if (isset($_POST["new_location"])) {
$_POST["new_location"] = $ACCESS_ROOT.$_POST["new_location"];
if (!Valid_Path($_POST["new_location"], false)) {
- $message .= $EX.''.hsc($_['Invalid_path']).': '.hsc($_POST["new_location"]).'';
+ $MESSAGE .= $EX.''.hsc($_['Invalid_path']).': '.hsc($_POST["new_location"]).'';
$VALID_POST = 0;
return;
}
@@ -2836,9 +2853,11 @@ function init_ICONS_js() {//****************************************************
function common_scripts() {//***************************************************
- global $_, $TO_WARNING, $message, $page, $DELAY_Expired_Reload;
+ global $_, $TO_WARNING, $MESSAGE, $page, $DELAY_Expired_Reload;
?>
var $form = document.getElementById('');
var $submit_button = document.getElementById('');
-var $message_box = document.getElementById('message_box');
+var $pwun_msg_box = document.getElementById('message_box');
var $thispage = false; //Used to ignore keyup if keydown started on prior page.
var $submitdown = false; //Used in document.mouseup event
@@ -3841,7 +4090,7 @@ function events_down(event, capture_key) {
if (!event) {var event = window.event;} //if IE
$thispage = true; //Make sure keydown was on this page.
if ((event.type.substr(0,3) == 'key') && (event.keyCode != capture_key)) {return true;}
- $message_box.innerHTML = '
';
$MESSAGE .= ''.hsc($_POST['new_location']).'
';
@@ -2719,7 +2735,7 @@ function MCD_response($action, $msg1, $success_msg = '') {//********************
}
if ($errors) {$MESSAGE .= $EX.' '.$errors.' '.hsc($_['errors']).'.
';}
-
+
$MESSAGE .= ''.$successful.' '.hsc($success_msg).'
';
if ($action != 'rDel') {
@@ -2794,7 +2810,7 @@ function Respond_to_POST() {//**************************************************
global $_, $VALID_POST, $ipath, $page, $EX, $ACCESS_ROOT, $MESSAGE;
if (!$VALID_POST) { return; }
-
+
//First, validate any $_POST'ed paths against $ACCESS_ROOT.
if (isset($_POST["old_full_name"]) && !Valid_Path($_POST["old_full_name"], false)) {
//unlikely, but just in case
@@ -2863,6 +2879,7 @@ function init_ICONS_js() {//****************************************************
function common_scripts() {//***************************************************
global $_, $TO_WARNING, $MESSAGE, $page, $DELAY_Expired_Reload;
?>
+
+
;//# of rows to jump with Page Up/Page Down.
var highlight1 = "rgb(255,250,150)";
var highlight2 = "rgb(255,240,140)";
-
+
//Get key pressed...
if (!event) {var event = window.event;} //for IE
var key = event.keyCode;
//Assign a few handy "constants": Arrow U/D/L/R, Page Up/Down, etc...
var AU = 38, AD = 40, AL = 37, AR = 39, PU = 33, PD = 34; END = 35, HOME = 36, ESC = 27, TAB = 9, ENTER = 13;
-
+
//Ignore any other key presses...
if ((key != AU) && (key != AD) && (key != AL) && (key != AR) && (key != PU) && (key != PD) &&
(key != HOME) && (key != END) && (key != ESC) && (key != TAB) && (key != ENTER)) { return }
@@ -3340,7 +3358,7 @@ function on_Tab_down(ID, FR,shifted) { //*****************************
if (document.activeElement.type == "checkbox") {document.getElementById(ID).parentNode.style.backgroundColor = highlight2;}
if (ID == "select_all_ckbox") {document.getElementById('select_all_label').style.backgroundColor = highlight1;}
if (ID == "folders_first_ckbox") {document.getElementById('folders_first_label').style.backgroundColor = highlight1;}
-
+
//Prevent default browser scrolling via arrow & Page keys, so focus()'d element stays visible/in view port.
//(A few exceptions skip this via a return in the above if/else's.)
if ( (ID != 'path_0') || ((ID == 'path_0') && (key == AD)) || ((ID == 'path_0') && (key == PD))) {
@@ -3401,7 +3419,7 @@ function Sort_Folders_First() {//*************************************
row = 0
for (D = 0; D < folders.length; D++) { DIRECTORY_DATA[row++] = folders[D]; }
for (F = 0; F < files.length; F++) { DIRECTORY_DATA[row++] = files[F]; }
-
+
SORT_folders_1st = true;
}//end Sort_Folders_First() //****************************************
@@ -3414,7 +3432,7 @@ function sort_DIRECTORY(col, direction) {//***************************
if (DIRECTORY_DATA.length < 2) {return} //can't sort 1 or zero items.
//sort DIRECTORY_DATA[] by col and direction
-
+
//col: 1 for "file name", 2 for filesize, 3 for timestamp, 5 for "ext"
//direction: 0 = desending, 1 = ascending, 2 = flip, 3 = flip only if new col != SORT_by
@@ -3675,104 +3693,41 @@ function Edit_Page_scripts() {//************************************************
global $_, $ONESCRIPT, $ONESCRIPT_file, $ipath, $param1, $param2, $filename, $LINE_WRAP,
$MAIN_WIDTH, $WIDE_VIEW_WIDTH, $current_view, $WYSIWYG_VALID, $EDIT_WYSIWYG, $TAB_SIZE;
- //Determine edit_view width.
- $current_view = $MAIN_WIDTH;
- if ( isset($_COOKIE['edit_view']) ) {
- if ( ($_COOKIE['edit_view'] == $MAIN_WIDTH) || ($_COOKIE['edit_view'] == $WIDE_VIEW_WIDTH) ) {
- $current_view = $_COOKIE['edit_view'];
- }
- }
+ //Get current view width.
+ $current_view = $MAIN_WIDTH; //default
+ if ( $_COOKIE['wide_view'] === "on" ) { $current_view = $WIDE_VIEW_WIDTH; }
//For [Edit WYSIWYG/Source] button
- $set_cookie = "document.cookie='edit_wysiwyg=".(!$EDIT_WYSIWYG*1)."';";
- $WYSIWYG_onclick = "parent.location = onclick_params + 'edit'; ".$set_cookie;
+ $WYSIWYG_onclick = "parent.location = onclick_params + 'edit'; ";
+ $WYSIWYG_onclick .= "document.cookie='edit_wysiwyg=".(!$EDIT_WYSIWYG*1)."';";
//For [Close] button
$close_params = $ONESCRIPT.$param1;
if ( $_SESSION['admin_page'] ) { $close_params .= '&p=admin'; } //If came from admin page, return there.
-
?>
-
+
+
+
+
+
+
+
'; }
-else { echo '
'; //#####
+ $MESSAGE .= ''.__LINE__.') session_save_path: "'.ini_get('session.save_path').'"
';
}
//******************************************************************************
@@ -382,7 +382,7 @@ function System_Setup() {//*****************************************************
function Default_Language() { // ***********************************************
global $_;
-// OneFileCMS Language Settings v3.6.02 (Not always in sync with OFCMS version#, if no changes to displayed wording.)
+// OneFileCMS Language Settings v3.6.03 (Not always in sync with OFCMS version#, if no changes to displayed wording.)
$_['LANGUAGE'] = 'English';
$_['LANG'] = 'EN';
@@ -529,6 +529,7 @@ function Default_Language() { // ***********************************************
$_['edit_txt_02'] = 'File possibly contains an invalid character. Edit and view disabled.';
$_['edit_txt_03'] = 'htmlspecialchars() returned an empty string from what may be an otherwise valid file.';
$_['edit_txt_04'] = 'This behavior can be inconsistant from version to version of php.';
+$_['edit_txt_05'] = 'File is readonly.'; //## NT ## as of 3.6.03
$_['too_large_to_edit_01'] = 'Edit disabled. Filesize >';
$_['too_large_to_edit_02'] = 'Some browsers (ie: IE) bog down or become unstable while editing a large file in an HTML
'.
hsc($_['too_large_to_edit_02']).'
'.hsc($_['too_large_to_edit_03']).'
'.hsc($_['too_large_to_edit_04']);
@@ -2280,6 +2279,11 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_
''.hsc($_['too_large_to_view_01']).' '.number_format($MAX_VIEW_SIZE).' '.hsc($_['bytes']).'
'.
hsc($_['too_large_to_view_02']).'
'.hsc($_['too_large_to_view_03']).'
';
+ $writable = (fileperms($filename_OS) & 0200)/0200;
+ $file_perms = decoct(fileperms($filename_OS) & 07777);
+
+ if (!$writable) { $MESSAGE .= $file_perms." : ".$_['edit_txt_05']." ".$_['edit_txt_00']."
"; }
+
echo "\n".''.$EX.hsc($_['edit_txt_02']).'
'."\n";
@@ -2324,12 +2328,12 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_
}//end if non-image
- Edit_Page_buttons($text_editable, $too_large_to_edit);
+ Edit_Page_buttons($text_editable, $too_large_to_edit, $writable);
echo "\n
';
echo hsc($_['edit_txt_03']).'
';
echo hsc($_['edit_txt_04']).''s
- var c=0;
cells = trow.cells;
- cells[c++].innerHTML = ren_mov;
- cells[c++].innerHTML = copy;
- cells[c++].innerHTML = del;
- cells[c++].innerHTML = checkbox;
- cells[c++].innerHTML = perms;
- cells[c++].innerHTML = file_name;
- cells[c++].innerHTML = file_size;
- cells[c++].innerHTML = file_time;
+ cells[0].innerHTML = ren_mov;
+ cells[1].innerHTML = copy;
+ cells[2].innerHTML = del;
+ cells[3].innerHTML = checkbox;
+ cells[4].innerHTML = perms;
+ cells[5].innerHTML = file_name;
+ cells[6].innerHTML = file_size;
+ cells[7].innerHTML = file_time;
+
+
+ E(ckbox_id).onblur = function() { E(ckbox_id).parentNode.style.backgroundColor = ""; }
+ E(perms_id).onfocus = function(event) { this.prior_value = this.value; }
+ E(perms_id).onkeydown = function(event) { Octal_Input_Only(event); } //##### Not actually used yet as still readonly above.
+ E(perms_id).onchange = function(event) {
+
+ this.value = this.prior_value; //##### Will be used in future if there's an input error.
+ return; //##### just not yet...
+
+ //##### NEED LANGUAGE $_[] values...
+ Display_Messages('Permissions updated: ' + this.value + ' for "' + filename + '"');
+ }
}//end Assemble_Insert_row() //***************************************
@@ -5105,7 +5164,6 @@ function Load_style_sheet() {//*************************************************
if ($_SESSION['valid']) { echo ' sogw
+ sogw
-
';
+ $MESSAGE .= $EX.''.hsc($_['Update_failed']).'
';
return false;
}else {return true;}
}//end Update_config() //*******************************************************
@@ -2067,7 +2063,7 @@ function Get_DIRECTORY_DATA($raw_list) {//**************************************
$file_time_raw = filemtime($filename_OS);
//Store data
- $DIRECTORY_DATA[$DIRECTORY_COUNT] = array('', '', 0, 0, 0, '');
+ $DIRECTORY_DATA[$DIRECTORY_COUNT] = array('', '', 0, 0, 0, '', '');
$DIRECTORY_DATA[$DIRECTORY_COUNT][0] = $type; //used to determine icon & f_or_f
$DIRECTORY_DATA[$DIRECTORY_COUNT][1] = $filename;
$DIRECTORY_DATA[$DIRECTORY_COUNT][2] = $file_size_raw;
@@ -2142,7 +2138,7 @@ function Index_Page_buttons_top($file_count) {//********************************
function Index_Page() {//*******************************************************
- global $ONESCRIPT, $ipath_OS, $param1;
+ global $ONESCRIPT, $ipath_OS, $param1, $INPUT_NUONCE;
init_ICONS_js();
@@ -2152,6 +2148,7 @@ function Index_Page() {//*******************************************************
//
";
+ }
+
+ $new_perms_response = "";
+ $new_perms_response['new_perms'] = $new_perms;
+ $new_perms_response['perms_filename'] = $ipath.$filename;
+ $new_perms_response['nuonce'] = $_SESSION['nuonce'];
+ $new_perms_response['early_output'] = hsc(ob_get_clean()); //Should always be empty unless error or trouble-shooting.
+ $new_perms_response['errors'] = $errors."";
+ $new_perms_response['MESSAGE'] = $MESSAGE;
+ echo json_encode($new_perms_response);
+}//end Update_File_Permissions() //*********************************************
+
+
+
+
function Page_Title() {//***
';
@@ -1716,7 +1719,7 @@ function Change_PWUN_Page($pwun, $type, $page_title, $label_new, $label_confirm)
sogw
+ sogw
-
-
+
';
@@ -2892,52 +2894,72 @@ function MCD_response($action, $msg1, $success_msg = '') {//********************
-function Update_File_Permissions() { //*****************************************
+function Format_Perms($perms_oct) {//*******************************************
+ //$pemrs_oct is a 3 or 4 digit octal string (7777).
+
+ //file file | s s s | owner | group | world
+ //permissions t y p e | u g t | r w x | r w x | r w x
+ //
+ //bits | 0 0 1 | 4 2 1 | 4 2 1 | 4 2 1 | 4 2 1 | 4 2 1
+ //octal 1 7 7 7 7 7
+ //
+ //bits 8 4 2 1 | 8 4 2 1 | 8 4 2 1 | 8 4 2 1
+ //hex F F F F
+
+ $ugt = ['---', '--t', '-g-', '-gt', 'u--', 'u-t', 'ug-', 'ugt']; //SetUid SetGid sTicky
+ $rwx = ['---', '--x', '-w-', '-wx', 'r--', 'r-x', 'rw-', 'rwx'];
+
+ if (strlen($perms_oct) > 3) { $ugidsticky = substr($perms_oct, -4, 1); }
+ else { $ugidsticky = 0; }
+ $owner = substr($perms_oct, -3, 1);
+ $group = substr($perms_oct, -2, 1);
+ $world = substr($perms_oct, -1, 1);
+
+ return "[$perms_oct][".$ugt[$ugidsticky]." ".$rwx[$owner]." ".$rwx[$group]." ".$rwx[$world]."]";
+
+}//end Format_Perms() {//*******************************************************
+
+
+
+
+function Update_File_Permissions() {//******************************************
//Validate new_perms & update.
//$_POST['new_perms'] must be an octal value with 3 or 4 digits (0-7) only.
- global $_, $ACCESS_ROOT, $ACCESS_ROOT_len, $MESSAGE;
+ global $_, $MESSAGE;
$new_perms = trim($_POST['new_perms']);
$len = strlen($new_perms);
- $errors = 0;
+ $errors = 0; //No errrors
$ipath = $_POST['ipath'];
$ipath_OS = Convert_encoding($ipath);
$filename = $_POST['perms_filename'];
$filename_OS = Convert_encoding($ipath.$filename); //Full path/filename
//Verify that each digit is octal (0-7), and that $new_perms is only 3 or 4 digits in length.
- $digit = "";
- for ($p = 0; $p < $len; $p++) {
- $digit = substr($new_perms, $p, 1);
- if (($digit < '0') || ($digit > '7')) {
- $errors++ ; break;
- }
- }
- if (($len < 3) || ($len > 4)) {
- $errors++;
- }
- //##### //##### Needs language $_[]
- if ($errors) { $MESSAGE .= $_['Invalid'].": [$new_perms]. Must be exactly 3 or 4 octal digits (0-7)"; }
+ if (preg_match("/^[0-7]{3,4}$/", $new_perms) != 1) { $errors++; }
- //Validate path & filename.
- if (!Valid_Path($ipath_OS, false)) { $MESSAGE = $_['Invalid_path'].". \n"; }
- if (!file_exists($filename_OS)) { $MESSAGE .= $_['get_get_msg_01']."\n "; }
+ if ($errors > 0) { $MESSAGE .= "".$_['Invalid'].": [$new_perms] ".$_['Permissions_msg_1']."."; }
- if (!$errors) {
+ //Validate path & filename. Valid_Path() required to prevent access outside $ACCESS_ROOT.
+ if (!Valid_Path($ipath_OS, false)) { $errors++; $MESSAGE .= $_['Invalid_path'].". \n"; }
+ if (!file_exists($filename_OS)) { $errors++; $MESSAGE .= $_['get_get_msg_01']."\n "; }
+
+ if ($errors == 0) {
//Update the file permissions...
- $chmod = chmod($filename_OS, octdec($new_perms));
- if (!$chmod) {
+ if (!chmod($filename_OS, octdec($new_perms))) {
$errors++;
- $MESSAGE .= "".$_['Update_failed'].": ";
- $MESSAGE .= "chmod(\"$filename_OS\", octdec($new_perms))";
+ $MESSAGE .= "".$_['Update_failed'].": ";
}
}
clearstatcache ();
$new_perms = decoct((fileperms($filename_OS) & 07777)); //May not actually be new, if update failed.
+ $new_perms = str_pad($new_perms, 3, "0", STR_PAD_LEFT); //Always at least three digits: 000
+
if ($errors == 0) {
$MESSAGE .= "".hsc($_['meta_txt_03'])." ";
- $MESSAGE .= " [".hsc($new_perms)."] ".hsc($filename)."
";
+ $MESSAGE .= " ".Format_Perms($new_perms)." ".hsc($filename)."
";
}
$new_perms_response = "";
@@ -3536,7 +3558,7 @@ function Index_Page_events() {//************************************************
-function Perms_onkeydown(event, $perms) {//***************************
+function Perms_onkeydown(event, $perms, filename) {//*****************
//Get key pressed...
if (!event) {var event = window.event;} //for IE
@@ -3549,11 +3571,9 @@ function Perms_onkeydown(event, $perms) {//***************************
$perms.readOnly = !$perms.readOnly;
if ($perms.readOnly) {
Display_Messages("");
- $perms.style.backgroundColor = ""; //##### Remove .class instead?
- $perms.style.boxShadow = ""; //##### Remove .class instead?
+ $perms.classList.remove("edit_perms");
- //onchange doesn't seem to occur until looses focus, which ENTER doesn't do.
- if ($perms.value != $perms.prior_value) { $perms.onchange(); }
+ if ($perms.value != $perms.prior_value) { Validate_and_Post($perms, filename); }
}
else {
Enable_Edit_Perms($perms);
@@ -3567,14 +3587,8 @@ function Perms_onkeydown(event, $perms) {//***************************
event.stopPropagation();
- //if ESC or TAB, cancel any changes, & return to readonly.
- if ((key == 27) || (key == TAB)) {
- $perms.value = $perms.prior_value;
- Display_Messages("");
- $perms.readOnly = true;
- $perms.style.backgroundColor = ""; //##### Remove .class instead?
- $perms.style.boxShadow = ""; //##### Remove .class instead?
- }//end ESC or TAB
+ //if ESC or TAB...
+ if ((key == 27) || (key == TAB)) { Cancel_Perm_Changes($perms) }
Octal_Input_Only(event);
@@ -3585,17 +3599,22 @@ function Perms_onkeydown(event, $perms) {//***************************
+function Cancel_Perm_Changes($perms) {//******************************
+ $perms.value = $perms.prior_value;
+ $perms.readOnly = true;
+ $perms.classList.remove("edit_perms");
+ Display_Messages("");
+}//end Cancel_Perm_Changes() {//**************************************
+
+
+
+
function Directory_Events($ckbox, $perms, $file, filename) {//********
- //##### add/remove a class instead of setting/clearing value directly? ##############
- $ckbox.onfocus = function() { $ckbox.parentNode.style.backgroundColor = "rgb(255,240,140)"; }
- $ckbox.onblur = function() { $ckbox.parentNode.style.backgroundColor = ""; }
+ $ckbox.onfocus = function() { this.parentNode.classList.add("ckbox_parent"); }
+ $ckbox.onblur = function() { this.parentNode.classList.remove("ckbox_parent"); }
- $perms.onblur = function(event) {
- $perms.readOnly = true;
- $perms.style.backgroundColor = ""; //##### Remove .class instead?
- $perms.style.boxShadow = ""; //##### Remove .class instead?
- }
+ $perms.onblur = function(event) { Cancel_Perm_Changes($perms) }
$perms.onfocus = function(event) {
var deselect = function() { $perms.setSelectionRange(0, 0); }
@@ -3603,9 +3622,7 @@ function Directory_Events($ckbox, $perms, $file, filename) {//********
$perms.prior_value = $perms.value;
}
- $perms.onkeydown = function(event) { return Perms_onkeydown(event, $perms); }
-
- $perms.onchange = function(event) { Validate_and_Post($perms, filename); }
+ $perms.onkeydown = function(event) { return Perms_onkeydown(event, $perms, filename); }
$perms.onclick = function(event) { Enable_Edit_Perms($perms); }
@@ -3618,23 +3635,20 @@ function Validate_and_Post($perms, filename) { //*********************
$perms.value = $perms.value.trim();
- //$perms.onchange sometimes fires when there isn't any. Usually by $perms.onblur,
- //after perms already updated by a $perms.onchange(), in Perms_onkeydown(), after [Enter].
if ($perms.value == $perms.prior_value) { return };
//Verify that each digit is octal (0-7), and that $perms is only 3 or 4 digits in length.
var octal = /^[0-7]{3,4}$/;
- var valid = octal.test($perms.value);
+ var valid = octal.test($perms.value);
if (!valid) {
- var msg = "" + hsc(": [" + $perms.value + "].") + "";
- msg += hsc(" Permissions must be exactly 3 or 4 octal digits (0-7)."); //##### Needs language $_[]; //#####
+ var msg = "" + hsc(": [" + $perms.value + "]") + " ";
+ msg += hsc(".");
$perms.value = $perms.prior_value;
Display_Messages(msg);
return false;
}
- $perms.prior_value = $perms.value;
Post_New_File_Perms($perms, filename);
return true;
@@ -3645,14 +3659,14 @@ function Validate_and_Post($perms, filename) { //*********************
function Enable_Edit_Perms($perms) {//********************************
- //##### NEED LANGUAGE $_[] values #####################################################
- var msg = "Press [Enter] to save changes. Press [Esc] or [Tab] to cancel.";
+ var msg = hsc(" ");
Display_Messages(msg);
$perms.readOnly = false;
$perms.setSelectionRange(0, 0); //Just for consistency.
- $perms.style.backgroundColor = "rgb(255,240,140)"; //##### Add .class instead?
- $perms.style.boxShadow = "0 0 10px 2px #F44"; //##### Add .class instead?
+
+ $perms.classList.add("edit_perms");
+
}//end Enable_Edit_Perms() {//****************************************
@@ -3661,9 +3675,8 @@ function Enable_Edit_Perms($perms) {//********************************
function Octal_Input_Only(event) { //*********************************
//Restrict input to digits & a few special keys.
- //##### This function works with keyboards, but may inhibit number inputs on
- //##### touchscreens / android / Samsung Galaxy S III mini / etc. I don't know.
- //##### return;
+ //This function works with keyboards, but not touchscreens etc.
+ //However, total input is validated on enter anyway, regardless of device.
function Stop_Prop(event) { event.stopImmediatePropagation() }
@@ -3873,6 +3886,46 @@ function Init_Dir_table_rows(DIR_LIST) {//****************************
+//********************************************************************
+function Insert_mov_del_ckbox(IS_OFCMS, row, cells, writable, href, f_or_f, filename, tabindex) {
+
+ //Assemble [mov], [del], & [x]
+ //[mov], [del], and [x] are not available for OFCMS or readonly files.
+ //([copy] & [perms] are always available)
+ //The empty 's are to accommodate keyboard nav via onkeydown() in Index_Page_events()...
+
+ var ren_id = 'f' + row + 'c0';
+ var del_id = 'f' + row + 'c2';
+ var ckbox_id = 'f' + row + 'c3';
+
+ var mov = del = ckbox = '';
+
+ if (IS_OFCMS || !writable) {
+ //Used when file is read only, or IS_OFCMS. (These options are unavailable.)
+ mov = ' '
+ del = ' '
+ ckbox = ' '
+ }
+ else {
+ //Used when file is writable.
+ mov = '' + ICONS['ren_mov'] + '';
+ del = '' + ICONS['delete'] + '';
+ ckbox = '';
+ }
+
+ //fill the 's
+ cells[0].innerHTML = mov;
+ cells[2].innerHTML = del;
+ cells[3].innerHTML = ckbox;
+
+}//end Insert_mov_del_ckbox() {//*************************************
+
+
+
+
//********************************************************************
function Assemble_Insert_row(IS_OFCMS, row, trow, href, f_or_f, filename, file_name, file_size, file_time){
@@ -3887,56 +3940,33 @@ function Assemble_Insert_row(IS_OFCMS, row, trow, href, f_or_f, filename, file_n
row++;
//[Move] [Copy] [Delete] [x] [perms]
- var ren_mov = copy = del = checkbox = perms = cells = '';
+ var ren_mov = copy = del = checkbox = perms = '';
+ var cells = trow.cells;
- var ren_id = 'f' + row + 'c0';
var copy_id = 'f' + row + 'c1';
- var del_id = 'f' + row + 'c2';
var ckbox_id = 'f' + row + 'c3';
var perms_id = 'f' + row + 'c4';
var file_id = 'f' + row + 'c5';
var sogw = DIRECTORY_DATA[row - 1][6] + ""; //File permissions (suid sgid sticky)(owner)(group)(world)
sogw = parseInt(sogw,8);
- var writable = (sogw & 0o200)/0o0200; //Only check file owner write bit.
+ var writable = (sogw & 0o200)/0o200; //Only check file owner write bit.
- //Assemble [move] [copy] [delete] [x] [perms] ([copy] & [perms] are always available)
- //[move], [delete], and [x] are not available for OFCMS or readonly files.
- //The empty 's are to accommodate keyboard nav via onkeydown() in Index_Page_events()...
-
- if (IS_OFCMS || !writable) { //[Move] not available
- ren_mov = ' '
- }
- else {
- ren_mov = '">' + ICONS['ren_mov'] + '';
- }
+ //[mov], [del], & [x] are only available when while is writable.
+ Insert_mov_del_ckbox(IS_OFCMS, row, cells, writable, href, f_or_f, filename, TABINDEX);
- copy = '' + ICONS['copy'] + '';
- if (IS_OFCMS || !writable) { //[delete] & [checkbox] are not available
- del = ' '
- checkbox = ' '
- }
- else {
- del = '' + ICONS['delete'] + '';
- checkbox = '';
- }
-
- perms = '';
+ TABINDEX = TABINDEX + 5;
//fill the 's
- cells = trow.cells;
- cells[0].innerHTML = ren_mov;
+ //( 0, 2, & 3 are filled in Insert_mov_del_ckbox() )
cells[1].innerHTML = copy;
- cells[2].innerHTML = del;
- cells[3].innerHTML = checkbox;
cells[4].innerHTML = perms;
cells[5].innerHTML = file_name;
cells[6].innerHTML = file_size;
@@ -4090,6 +4120,37 @@ function Confirm_Submit(action) {//***********************************
E('mcdselect').submit(); //submit form.
}//end Confirm_Submit() //********************************************
+
+
+
+function Format_Perms(perms_oct) {//**********************************
+ //##### Not used yet. Had grand ideas, but now not sure...
+ //returns [7777][ugt rwx rwx rwx]
+
+ //$pemrs_oct is a 3 or 4 digit octal string (7777).
+
+ //file file | s s s | owner | group | world
+ //permissions t y p e | u g t | r w x | r w x | r w x
+ //
+ //bits | 0 0 1 | 4 2 1 | 4 2 1 | 4 2 1 | 4 2 1 | 4 2 1
+ //octal 1 7 7 7 7 7
+ //
+ //bits 8 4 2 1 | 8 4 2 1 | 8 4 2 1 | 8 4 2 1
+ //hex F F F F
+
+ var ugt = ['---', '--t', '-g-', '-gt', 'u--', 'u-t', 'ug-', 'ugt']; //setUid setGid sTicky
+ var rwx = ['---', '--x', '-w-', '-wx', 'r--', 'r-x', 'rw-', 'rwx'];
+
+ if ((perms_oct.length * 1) > 3) { var ugidsticky = perms_oct.substr(-4, 1); }
+ else { var ugidsticky = 0; }
+ var owner = perms_oct.substr(-3, 1);
+ var group = perms_oct.substr(-2, 1);
+ var world = perms_oct.substr(-1, 1);
+
+ return "[" + perms_oct + "][" + ugt[ugidsticky] + " " + rwx[owner] + " " + rwx[group] + " " + rwx[world] + "]";
+
+}//end Format_Perms() {//*********************************************
+
\n";
+ echo "
\n";
echo "";
echo "".hsc($_['time_out_txt'])."";
From bae1ec972f4bc21d50cd4c9b2bcb70fcfd1fada5 Mon Sep 17 00:00:00 2001
From: Self-Evident 's with empty 's
+
+ var drow, cell, cells, tr, td;
var last_cell = 8; // number of columns in directory listing.
- for (row = 0; row < DIRECTORY_ITEMS; row++){
-
- //initialize with empty 's
- tr = DIR_LIST.insertRow(row);
- for (cell = 0; cell < last_cell; cell++) {td = tr.insertCell(-1);}
+ for (drow = 0; drow < DIRECTORY_ITEMS; drow++){
+ tr = E("DIRECTORY_LISTING").insertRow(-1); //-1 adds row after last row.
+ for (cell = 0; cell < last_cell; cell++) { td = tr.insertCell(-1); }
cells = tr.cells;
- //assign css classes
+ //assign classes
var c = 4;
cells[c++].className = 'meta_T perms'; //file permissions
cells[c++].className = 'file_name';
@@ -3887,85 +3897,112 @@ function Init_Dir_table_rows(DIR_LIST) {//****************************
//********************************************************************
-function Insert_mov_del_ckbox(IS_OFCMS, row, cells, writable, href, f_or_f, filename, tabindex) {
+function Assemble_mdx(drow, cells, href, f_or_f, filename, tabindex) {
- //Assemble [mov], [del], & [x]
+ //Assemble [mov], [del], & [x](checkbox)
//[mov], [del], and [x] are not available for OFCMS or readonly files.
//([copy] & [perms] are always available)
//The empty 's are to accommodate keyboard nav via onkeydown() in Index_Page_events()...
- var ren_id = 'f' + row + 'c0';
- var del_id = 'f' + row + 'c2';
- var ckbox_id = 'f' + row + 'c3';
+ var frow = drow + 1;
- var mov = del = ckbox = '';
+ var ren_id = 'f' + frow + 'c0';
+ var del_id = 'f' + frow + 'c2';
+ var ckbox_id = 'f' + frow + 'c3';
+
+ var IS_OFCMS = DIRECTORY_DATA[drow][4];
+ var sogw = parseInt(DIRECTORY_DATA[drow][6] + "",8); //File permissions (suid sgid sticky)(owner)(group)(world)
+ var read_write = (((sogw & 0o200)/0o200) && !IS_OFCMS) * 1 ; //Check file owner write bit, or if IS_OFCMS.
+
+ //Store both verions of these options for each file.
+ //[0] empty placeholder (needed for keyboard nav), & [1] actual working option.
+ MOV_rw[frow] = [];
+ DEL_rw[frow] = [];
+ CBX_rw[frow] = [];
+
+ //Used when file is read only, or IS_OFCMS. ([M], [D], & [X], are unavailable.)
+ MOV_rw[frow][0] = ' ';
+ DEL_rw[frow][0] = ' ';
+ CBX_rw[frow][0] = ' ';
+
+ //Used when file is read_write.
+ MOV_rw[frow][1] = '' + ICONS['ren_mov'] + '';
+ DEL_rw[frow][1] = '' + ICONS['delete'] + '';
+ CBX_rw[frow][1] = '';
+
+}//end Assemble_mdx() {//*********************************************
- if (IS_OFCMS || !writable) {
- //Used when file is read only, or IS_OFCMS. (These options are unavailable.)
- mov = ' '
- del = ' '
- ckbox = ' '
- }
- else {
- //Used when file is writable.
- mov = '' + ICONS['ren_mov'] + '';
- del = '' + ICONS['delete'] + '';
- ckbox = '';
- }
- //fill the 's
- cells[0].innerHTML = mov;
- cells[2].innerHTML = del;
- cells[3].innerHTML = ckbox;
-}//end Insert_mov_del_ckbox() {//*************************************
+
+function Insert_mdx(drow, cells) {//**********************************
+
+ var IS_OFCMS = DIRECTORY_DATA[drow][4];
+ var sogw = parseInt(DIRECTORY_DATA[drow][6] + "",8); //File permissions (suid sgid sticky)(owner)(group)(world)
+ var read_write = (((sogw & 0o200)/0o200) && !IS_OFCMS) * 1 ; //Check file owner write bit, or if IS_OFCMS.
+
+ var frow = drow + 1;
+
+ //MOV_rw, DEL_rw, & CBX_rw, are globals, with values set in Assemble_mdx()
+ cells[0].innerHTML = MOV_rw[frow][read_write];
+ cells[2].innerHTML = DEL_rw[frow][read_write];
+ cells[3].innerHTML = CBX_rw[frow][read_write];
+
+ //Re-assign checkbox events. (Initially assigned in Directory_Events()).
+ $ckbox = E('f' + frow + 'c' + 3);
+ $ckbox.onfocus = function() { this.parentNode.classList.add("ckbox_parent_focus"); }
+ $ckbox.onblur = function() { this.parentNode.classList.remove("ckbox_parent_focus"); }
+
+}//end Insert_mdx() {//***********************************************
//********************************************************************
-function Assemble_Insert_row(IS_OFCMS, row, trow, href, f_or_f, filename, file_name, file_size, file_time){
+function Assemble_Insert_row(drow, href, filename, file_name, file_time){
- //While DIRECTORY_DATA, and the table rows created to list the data, are indexed from 0 (zero),
- //the id's of files in the directory list are indexed from 1 (f1, f2...), as "../" is listed first with id=f0 (f-zero).
- //The id's are used in Index_Page_events() "cursor" control.
- //Note: Number of tab-able items per row affects the (TABINDEX + 5) offset near end of Build_Directory(),
- // and the $TABINDEX calculation for the [Admin] link in page footer.
- // There are currently 6 tab-able items per (file) row: [m] [c] [d] [x] [sogw] [file name]
- // [m][c][d][x][sogw] tabindexes are set below. [filename]'s tabinex is set in Build_Directory().
+ //The number of tab-able items per row affects the (TABINDEX + 5) offset near end of Build_Directory(),
+ //and the $TABINDEX calculation for the [Admin] link in page footer.
+ //There are currently 6 tab-able items per (file) row: [m] [c] [d] [x] [sogw] [file name]
+ //[m][c][d][x][sogw] tabindexes are set below. [filename]'s tabinex is set in Build_Directory().
- row++;
+ var cells = E("DIRECTORY_LISTING").rows[drow].cells; //Must come before the row++ a little later in this function.
- //[Move] [Copy] [Delete] [x] [perms]
- var ren_mov = copy = del = checkbox = perms = '';
- var cells = trow.cells;
+ var filetype = DIRECTORY_DATA[drow][0];
+ var filesize = DIRECTORY_DATA[drow][2];
- var copy_id = 'f' + row + 'c1';
- var ckbox_id = 'f' + row + 'c3';
- var perms_id = 'f' + row + 'c4';
- var file_id = 'f' + row + 'c5';
+ //folder or file?
+ if (filetype == "dir") { var f_or_f = 'folder'; var file_size = ''; }
+ else { var f_or_f = 'file'; var file_size = format_number(filesize); }
- var sogw = DIRECTORY_DATA[row - 1][6] + ""; //File permissions (suid sgid sticky)(owner)(group)(world)
- sogw = parseInt(sogw,8);
- var writable = (sogw & 0o200)/0o200; //Only check file owner write bit.
+ //While DIRECTORY_DATA, and the table rows created to list the data, are indexed from 0 (zero),
+ //the id's of files in the directory list are indexed from 1 (f1, f2...), as "../" is listed first with id=f0 (f-zero).
+ //The id's are used in Index_Page_events() "cursor" control.
+ var frow = drow + 1;
- //[mov], [del], & [x] are only available when while is writable.
- Insert_mov_del_ckbox(IS_OFCMS, row, cells, writable, href, f_or_f, filename, TABINDEX);
+ var copy, perms;
+
+ var copy_id = 'f' + frow + 'c1';
+ var ckbox_id = 'f' + frow + 'c3';
+ var perms_id = 'f' + frow + 'c4';
+ var file_id = 'f' + frow + 'c5';
//[copy] & [perms] are always available.
copy = '' + ICONS['copy'] + '';
- perms = '';
+ perms = '';
+ //Assemble & Insert contents for cells[0], [2], & [3] ([Mov], [Del], [ckbox])
+ Assemble_mdx(drow, cells, href, f_or_f, filename, TABINDEX);
+ Insert_mdx(drow, cells);
TABINDEX = TABINDEX + 5;
- //fill the 's
- //( 0, 2, & 3 are filled in Insert_mov_del_ckbox() )
+ //Insert contents for the remaining cells...
cells[1].innerHTML = copy;
cells[4].innerHTML = perms;
cells[5].innerHTML = file_name;
@@ -3983,10 +4020,10 @@ function Build_Directory() {//****************************************
TABINDEX = ; //Rest TABINDEX
- var DIR_LIST = E("DIRECTORY_LISTING");
-
- if (DIR_LIST.rows.length < 1) {Init_Dir_table_rows(DIR_LIST);}
+ //Has the directory table been init'd yet?
+ if (E("DIRECTORY_LISTING").rows.length < 1) { Init_Dir_table_rows(E("DIRECTORY_LISTING")); }
+ //Fill 'er up!
for (var row = 0; row < DIRECTORY_ITEMS; row++) {
var filetype = DIRECTORY_DATA[row][0];
@@ -3997,14 +4034,10 @@ function Build_Directory() {//****************************************
//folder or file?
if (filetype == "dir"){
var DS = ' /';
- var f_or_f = 'folder';
var href = ONESCRIPT + PARAM1 + encodeURIComponent(filename);
- var file_size = '';
} else {
var DS = '';
- var f_or_f = 'file';
var href = ONESCRIPT + PARAM1 + '&f=' + encodeURIComponent(filename) + '&p=edit';
- var file_size = format_number(filesize);
}
var file_col = 5; //column of file names
@@ -4015,10 +4048,8 @@ function Build_Directory() {//****************************************
file_name += ICONS[filetype] + ' ' + hsc(filename) + DS + '';
var file_time = FileTimeStamp(filetime, 1, 0, 0);
- var IS_OFCMS = DIRECTORY_DATA[row][4];
- var trow = DIR_LIST.rows[row];
+ Assemble_Insert_row(row, href, filename, file_name, file_time);
- Assemble_Insert_row(IS_OFCMS, row, trow, href, f_or_f, filename, file_name, file_size, file_time);
TABINDEX++; //To accuont for file_name above
}//end for (row...
}//end Build_Directory() //*******************************************
@@ -4864,17 +4895,49 @@ function style_sheet() {//******************************************************
#select_all_label:hover { background-color: rgb(255,250,150); }
#select_all_label:active { background-color: rgb(245,245, 50); }
+label.ckbox_label_focus { background-color: rgb(255,250,150) }
+.ckbox.ckbox_label_focus { background-color: rgb(255,250,150) }
+
/*** Directory list file select boxes ***/
-/*ckbox is assigned to
\ No newline at end of file
+
From 509ee2adcecdee3496ba29937ce16cbf7d912f22 Mon Sep 17 00:00:00 2001
From: Self-Evident
@@ -1977,38 +1997,37 @@ function Create_Table_for_Listing() {//*****************************************
- href="#" id=header_filesize>
- href="#" id=header_filedate>
+
+ href="#" id=header_filesize>
+ href="#" id=header_filedate>
+
+
+
-
- ';
- }
- else {
- echo ''.$ICONS['up_dir'].' .. /';
- }
-?>
-
-
+
+
+
+
+
-
+
" + hsc(update_response.early_output); }
+ if (update_response.early_output != "") { msg += "
" + update_response.early_output; }
//##### msg += "
" + hsc(request.responseText); //For trouble-shooting...
E('nuonce').value = update_response.nuonce; //For the next post...
var frow = $perms.id.split('c')[0].substr(1); //id = "fNNcN", frow = the NN after the "f"
- var drow = frow - 1; //See frow & drow notes in Assemble_Insert_row()
+ var drow = frow - 1; //See Assemble_Insert_row() for description/explanation.
DIRECTORY_DATA[drow][6] = $perms.value;
@@ -3766,9 +3789,6 @@ function Index_Page_scripts() {//***********************************************
global $_, $ONESCRIPT, $param1, $ipath, $MESSAGE, $DELAY_Sort_and_Show_msgs, $MIN_DIR_ITEMS, $TABINDEX;
?>
\n\n";
+echo "\n\n\n";
//##### ACTUAL COUNTDOWN STARTS ON THE SERVER.
//##### DO I NEED TO ACCOUNT FOR TIME RECEIVING & LOADING PAGE CLIENT SIDE?
@@ -5514,6 +5553,7 @@ function Load_style_sheet() {//*************************************************
if ($page == 'edit') { echo Timeout_Timer($MAX_IDLE_TIME, 'timer1', 'LOGOUT'); }
if ($LOGIN_DELAYED > 0) { echo Timeout_Timer($LOGIN_DELAYED, 'timer0', ''); }
+echo "\n"; //***********************************************************
//##### Header (UTF-8) for [View Raw] incorrect or not getting sent??
//##### If file has non-ascii characters, browers display in ISO-8859-1/Windows-1252,
//##### Except IE, which asks to download the file...
From 06ed75e100ffabfc0154abfb65be125b6ee2f428 Mon Sep 17 00:00:00 2001
From: Self-Evident
+ / home / [user] / [www1] / [some] / [path] /
+ //path_items[x]: [0] /(no id)/ [1] / [2] / [3] / [4]
+ //path_items.length = 5
+ //path_items[x] id's: path_header /(no id)/ path_0 / path_1 / path_2 / path_3
+ // So, path_END id = path_(5 - 2) = path_3.
+ if ( (key == PU) || (key == PD) || (key == AU) || (key == AD) || ((x_focus == "p") && (key == HOME || key == END)) ) {
+ var path_items = document.querySelectorAll('[id^="path_"]');
+ var path_END = "path_" + (path_items.length - 2);
}
@@ -3446,18 +3477,18 @@ function Index_Page_events() {//************************************************
// ENTER - enabled to check/unckeck checkboxes, and respond as needed.
// Tab- handle checkbox's (parent
-
-
+
-
-
- B
-
+
+ = $ICONS['delete'].' '.hsc($_['Delete']) ?>
+ = $edit_link; ?>
+ = number_format(filesize($file_OS)); ?> B
+
= hsc($_['Generate_Hash']) ?>
-
-
-
-
-
-
-
+
-
+ = $PWUN_RULES ?>
+ = hsc($_['hash_txt_07']) ?>
+
+ = hsc($_['hash_txt_09']) ?>
+ = hsc($_['hash_txt_10']) ?>
+ = hsc($page_title) ?>
-
+
-
-
+
+
-
-
+
+
- = hsc($_['Log_In']) ?>
+
-
+
@@ -2003,25 +2003,25 @@ function Create_Table_for_Listing() {//*****************************************
- href="#" id=header_filesize>
- href="#" id=header_filedate>
+ href="#" id=header_filesize>= hsc($_['Size']." (".$_['bytes'].")") ?>
+ href="#" id=header_filedate>= hsc($_['Date']) ?>
-
-
+ = $file_owner_header ?>
+ = $file_group_header ?>
-
-
+ = $file_0 ?>
@@ -2030,7 +2030,7 @@ function Create_Table_for_Listing() {//*****************************************
+
'.
hsc($_['too_large_to_view_02']).'
'.hsc($_['too_large_to_view_03']).'
';
- $writable = (fileperms($filename_OS) & 0200)/0200;
- $file_perms = decoct(fileperms($filename_OS) & 07777);
+ clearstatcache();
+
+ $file_stats = Get_File_Stats($filename_OS);
+ $file_perms = Format_Perms($file_stats['perms']);
+ $writable = $file_stats['is_writable'];
- if (!$writable) { $MESSAGE .= $file_perms." : ".$_['edit_txt_05']." ".$_['edit_txt_00']."
"; }
+ if (!$writable) {
+ $MESSAGE .= "";
+ $MESSAGE .= $file_perms." ".$file_stats['owner']." ".$file_stats['group']." :".get_current_user().": ";
+ $MESSAGE .= $_['edit_txt_05']." ".$_['edit_txt_00']."
";
+ }
echo "\n".'
'; }
+ if (!$text_editable) { $MESSAGE .= hsc($_['edit_txt_01']).'
'; }
elseif ( $text_editable && $too_large_to_view ) {
echo '';
} else {
@@ -2989,10 +3007,9 @@ function Update_File_Permissions() {//******************************************
}
}
clearstatcache();
- $new_perms = decoct((fileperms($filename_OS) & 07777)); //May not actually be new, if update failed.
+ $new_perms = decoct((fileperms($filename_OS) & 07777)); //May not actually be new, if chmod() failed.
$new_perms = str_pad($new_perms, 3, "0", STR_PAD_LEFT); //Always at least three digits: 000
-
if ($errors == 0) {
$MESSAGE .= "".hsc($_['meta_txt_03'])." ";
$MESSAGE .= " ".Format_Perms($new_perms)." ".hsc($filename)."
";
@@ -3005,6 +3022,7 @@ function Update_File_Permissions() {//******************************************
$new_perms_response['early_output'] = ob_get_clean(); //Should always be empty unless error or trouble-shooting.
$new_perms_response['errors'] = $errors."";
$new_perms_response['MESSAGE'] = $MESSAGE;
+ $new_perms_response['writable'] = is_writable($filename_OS) * 1; //1 or 0 (true or false)
echo json_encode($new_perms_response);
}//end Update_File_Permissions() //*********************************************
@@ -3741,6 +3759,7 @@ function Validate_and_Post($perms, filename) { //*********************
function Enable_Edit_Perms($perms) {//********************************
var msg = hsc(" = $_['Press_Enter'] ?>");
+ msg += "
" + Format_Perms($perms.value) + "";
Display_Messages(msg);
$perms.readOnly = false;
$perms.setSelectionRange(0, 0); //Just for consistency.
@@ -3791,24 +3810,27 @@ function Perms_Update_Response(request, $perms) { //******************
$perms.prior_value = $perms.value;
- var msg = update_response.MESSAGE;
-
- //Should always be blank unless troubleshooting, or an error server side.
- if (update_response.early_output != "") { msg += "
" + update_response.early_output; }
-
- //##### msg += "
" + hsc(request.responseText); //For trouble-shooting...
-
E('nuonce').value = update_response.nuonce; //For the next post...
var frow = $perms.id.split('c')[0].substr(1); //id = "fNNcN", frow = the NN after the "f"
var drow = frow - 1; //See Assemble_Insert_row() for description/explanation.
- DIRECTORY_DATA[drow][6] = $perms.value;
+ DIRECTORY_DATA[drow][6] = $perms.value;
+ DIRECTORY_DATA[drow][10] = update_response.writable;
var cells = E("DIRECTORY_LISTING").rows[drow].cells;
Insert_mdx(drow, cells); //Show/Hide [M] [D][X] file options
+
+ var msg = update_response.MESSAGE;
+
+ //Should always be blank unless troubleshooting, or an error server side.
+ if (update_response.early_output != "") { msg += "
" + update_response.early_output; }
+
+ //##### msg += "
" + hsc(request.responseText); //For trouble-shooting...
+
Display_Messages(msg);
+ window.scroll(0,0); //Leave focus on perms of file, but scroll message box into view if needed.
}//end Perms_Update_Response() //*************************************
@@ -4028,7 +4050,8 @@ function Insert_mdx(drow, cells) {//**********************************
var IS_OFCMS = DIRECTORY_DATA[drow][4];
var sogw = parseInt(DIRECTORY_DATA[drow][6] + "",8); //File permissions (suid sgid sticky)(owner)(group)(world)
- var writable = (((sogw & 0o200)/0o200) && !IS_OFCMS) * 1 ; //Check file owner write bit, or if IS_OFCMS.
+ var writable = DIRECTORY_DATA[drow][10]; //1 or 0 (true or false)
+ writable = (writable && !IS_OFCMS) * 1; //1 or 0 (true or false)
var frow = drow + 1; //See Assemble_Insert_row() for description/explanation.
@@ -4261,8 +4284,7 @@ function Confirm_Submit(action) {//***********************************
function Format_Perms(perms_oct) {//**********************************
- //##### Not used yet. Had grand ideas, but now not sure...
- //returns [7777][ugt rwx rwx rwx]
+ //returns them formatted as [7777][ugt rwx rwx rwx]
//$perms_oct is a 3 or 4 digit octal string (7777).
From 76f3917c55c80eb7567fb355c197bcb984d9ec3b Mon Sep 17 00:00:00 2001
From: Self-Evident
"; }
+ else { $setup_messages .= '$LANGUAGE_FILE '.hsc($_['Not_found']).": ".hsc($LANGUAGE_FILE)."
"; }
}
@@ -265,7 +269,7 @@ function System_Setup() {//*****************************************************
$WYSIWYG_PLUGIN_OS = Convert_encoding($WYSIWYG_PLUGIN); //Also used for include()
if (is_file($WYSIWYG_PLUGIN_OS)) { $WYSIWYG_VALID = 1; }
- else { $MESSAGE .= '$WYSIWYG_PLUGIN '.hsc($_['Not_found']).': '.hsc($WYSIWYG_PLUGIN)."
"; }
+ else { $setup_messages .= '$WYSIWYG_PLUGIN '.hsc($_['Not_found']).': '.hsc($WYSIWYG_PLUGIN)."
"; }
}
@@ -280,7 +284,7 @@ function System_Setup() {//*****************************************************
$CONFIG_FILE_backup = $CONFIG_FILE.'-BACKUP.txt'; //used for p/w & u/n updates.
}
else {
- $MESSAGE .= $EX.'$CONFIG_FILE '.hsc($_['Not_found']).': '.hsc($CONFIG_FILE).'
';
+ $setup_messages .= $EX.'$CONFIG_FILE '.hsc($_['Not_found']).': '.hsc($CONFIG_FILE).'
';
$CONFIG_FILE = $CONFIG_FILE_OS = '';
}
}
@@ -288,13 +292,13 @@ function System_Setup() {//*****************************************************
//Clean up & validate $ACCESS_ROOT
-if (!isset($ACCESS_ROOT)) { $ACCESS_ROOT = $DOC_ROOT; } //Make sure it's set.
+if (!isset($ACCESS_ROOT) || $ACCESS_ROOT == '') { $ACCESS_ROOT = $DOC_ROOT; } //Make sure it's set.
$ACCESS_ROOT = trim($ACCESS_ROOT, ' /'); //Trim to '' or 'some/path'
if ($ACCESS_ROOT != '') { $ACCESS_ROOT = $ACCESS_ROOT.'/'; }
$ACCESS_ROOT_OS = Convert_encoding($ACCESS_ROOT);
if (!is_dir('/'.$ACCESS_ROOT_OS)) {
- $MESSAGE .= $EX.'$ACCESS_ROOT '.hsc($_['Invalid']).": $ACCESS_ROOT
";
+ $setup_messages .= $EX.'$ACCESS_ROOT '.hsc($_['Invalid']).": $ACCESS_ROOT
";
$ACCESS_ROOT = $DOC_ROOT;
$ACCESS_ROOT_OS = Convert_encoding($ACCESS_ROOT);
}
@@ -305,26 +309,26 @@ function System_Setup() {//*****************************************************
//Clean up & validate $DEFAULT_PATH
//It must either be = $ACCESS_ROOT, or $ACCESS_ROOT."some/valid/path/"
-if (!isset($DEFAULT_PATH)) { $DEFAULT_PATH = $ACCESS_ROOT; } //Make sure it's set.
+if (!isset($DEFAULT_PATH) || $DEFAULT_PATH == '') { $DEFAULT_PATH = $ACCESS_ROOT; } //Make sure it's set.
$DEFAULT_PATH = trim($DEFAULT_PATH, ' /'); //Trim to 'some/path'
if ($DEFAULT_PATH != '') {$DEFAULT_PATH .= '/'; }
$DEFAULT_PATH_OS = Convert_encoding($DEFAULT_PATH);
-//Verify that $DEFAULT_PATH is equal to, or is a decendant of, $ACCESS_ROOT.
+//Verify that $DEFAULT_PATH is equal to, or a decendant of, $ACCESS_ROOT.
$needle = realpath($ACCESS_ROOT); //ex: /some/access/root
$haystack = realpath($DEFAULT_PATH); //ex: /some/access/root/some/default/path
$needle_len = strlen($needle);
$valid_subpath = (substr($haystack, 0, $needle_len) === $needle);
if (!is_dir('/'.$DEFAULT_PATH_OS)) {
- $MESSAGE .= $EX.'$DEFAULT_PATH '.$_['Invalid'].": $DEFAULT_PATH
";
+ $setup_messages .= $EX.'$DEFAULT_PATH '.$_['Invalid'].": $DEFAULT_PATH
";
$DEFAULT_PATH = $ACCESS_ROOT;
$DEFAULT_PATH_OS = Convert_encoding($DEFAULT_PATH);
}
else if (!$valid_subpath) {
- $MESSAGE .= $EX.''.$_['must_be_decendant'].'
';
- $MESSAGE .= "\$ACCESS_ROOT = $ACCESS_ROOT
";
- $MESSAGE .= "\$DEFAULT_PATH = $DEFAULT_PATH
";
+ $setup_messages .= $EX.''.$_['must_be_decendant'].'
';
+ $setup_messages .= "\$ACCESS_ROOT = $ACCESS_ROOT
";
+ $setup_messages .= "\$DEFAULT_PATH = $DEFAULT_PATH
";
$DEFAULT_PATH = $ACCESS_ROOT;
$DEFAULT_PATH_OS = Convert_encoding($DEFAULT_PATH);
}
@@ -381,6 +385,8 @@ function System_Setup() {//*****************************************************
//If you change this, or any other aspect of either hashit() or js_hash_scripts(), do so while logged in.
//Then, manually update your password as instructed on the Admin/Generate Hash page.
$PRE_ITERATIONS = 10000;
+
+return $setup_messages;
}//end System_Setup() //*******************************************************
@@ -707,16 +713,15 @@ function Session_Startup() {//**************************************************
session_name($SESSION_NAME);
session_start();
- //Set initial defaults...
- $page = 'login';
- $VALID_POST = 0;
- if ( !isset($_SESSION['valid']) ) { $_SESSION['valid'] = 0; }
-
//Logging in?
+ $page = 'login'; //Changed later in Login_response() or Get_GET() as appropriate.
if ( isset($_POST['username']) && isset($_POST['password']) ) { Login_response(); }
+ if ( !isset($_SESSION['valid']) ) { $_SESSION['valid'] = 0; }
+
session_regenerate_id(true); //Helps prevent session fixation & hijacking.
+ $VALID_POST = 0;
if ( $_SESSION['valid'] ) { Verify_IDLE_POST_etc(); }
$_SESSION['nuonce'] = sha1(mt_rand().microtime()); //provided in