From f8c9cee4df136e004a08ac10b6a45982aa450c0e Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Thu, 5 Apr 2012 13:29:44 -0400 Subject: [PATCH 001/228] milli -vs- micro in footer --- onefilecms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onefilecms.php b/onefilecms.php index d279242..d418044 100644 --- a/onefilecms.php +++ b/onefilecms.php @@ -514,7 +514,7 @@ function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return From 7749e808d5b3aa2520306d9ff3a2040c4d69dd5d Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Thu, 5 Apr 2012 18:09:50 -0400 Subject: [PATCH 002/228] Implemented $config_localcss --- onefilecms.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index d418044..eccab1e 100644 --- a/onefilecms.php +++ b/onefilecms.php @@ -10,7 +10,7 @@ $config_footer = date("Y")." OneFileCMS."; $config_disabled = "bmp,ico,gif,jpg,png,psd,zip"; $config_excluded = "onefilecms.php,favicon,.htaccess"; - +$config_localcss = "onefilecms.css"; $version = "1.1.6"; // ONEFILECMS_BEGIN if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; @@ -185,8 +185,8 @@ function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return <?php echo $config_title; ?> - <?php echo $pagetitle; ?> Date: Thu, 5 Apr 2012 18:31:47 -0400 Subject: [PATCH 003/228] path/breadcrumb link spaces. Moved spaces around " / " to inside path link. --- onefilecms.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) mode change 100644 => 100755 onefilecms.php diff --git a/onefilecms.php b/onefilecms.php old mode 100644 new mode 100755 index eccab1e..ca856c7 --- a/onefilecms.php +++ b/onefilecms.php @@ -308,16 +308,16 @@ function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return if ($varvar == "") { echo $path_levels[0]; // if at root, no need for link. } else { - echo ''.$path_levels[0].' / '; + echo ' '.$path_levels[0].' /'; } $current_path = ""; for ($x=1; $x < $levels-1; $x++) { - if ($x !== 1){ $current_path .= ' / '; } + if ($x !== 1){ $current_path .= '/'; } $current_path = $current_path.$path_levels[$x]; - echo ''; - echo $path_levels[$x], ' / '; + echo ' '; + echo ' '.$path_levels[$x].' /'; } - echo $path_levels[$x].' /'; // last item is current dir. No link needed. + echo ' '.$path_levels[$x].' /'; // last item is current dir. No link needed. ?>

From e477434ae9149c1b81bf235d22075bb73b965d72 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Thu, 5 Apr 2012 18:48:18 -0400 Subject: [PATCH 004/228] .path:hover style to hightlight links in path/to/current/index --- onefilecms.css | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) mode change 100644 => 100755 onefilecms.css diff --git a/onefilecms.css b/onefilecms.css old mode 100644 new mode 100755 index bff5def..708f7ba --- a/onefilecms.css +++ b/onefilecms.css @@ -291,4 +291,11 @@ a.back { .page_login .container, .page_logout .container { width: 356px; margin-top: 60px; -} \ No newline at end of file +} + + +/* --- path/to/current/index --- */ + +.path { border: 1px solid transparent; } + +.path:hover { border: 1px solid #807568; background-color: #fffbce; } From 3eac1c354afe8536ae29138bf80dbebf4ac291d5 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Thu, 5 Apr 2012 19:19:20 -0400 Subject: [PATCH 005/228] a:hover highlighting, tweaked spacing on index_folders & front_links --- onefilecms.css | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index 708f7ba..f12873c 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -48,9 +48,9 @@ body { h2,h3,p,ul,table { margin-bottom: 10px; } p, li {line-height: 1.4em; } form p { margin-bottom: 5px; } -a { color: #774200; text-decoration: none; } +a { color: #774200; text-decoration: none; border: 1px solid transparent; } a:hover { color: #976322; } -a:hover { color: #995400; } +a:hover { color: #995400; border: 1px solid #807568; background-color: #fffbce; } h2 { font-size: 20px; } h3 { font-size: 18px; margin-top: 15px; } em, i { font-style: italic; } @@ -146,11 +146,11 @@ pre { display: inline-block; font-size: 16px; margin-right: 15px; - padding-left: 21px; + padding: 2px 4px 2px 20px;/* padding-left: 21px;*/ display: inline-block; - background: url("http://onefilecms.com/images/silk_folder.png") no-repeat; + background: url("http://onefilecms.com/images/silk_folder.png") 0 2px no-repeat; } - +.index_folders a:hover { background-color: #fffbce; } /* --- list view --- */ ul.list { @@ -199,7 +199,7 @@ ul.list .meta span { .front_links { clear: both; } -.front_links a { +.front_links a { padding: 3px; font-size: 16px; margin-right: 15px; padding-left: 21px; @@ -207,14 +207,14 @@ ul.list .meta span { display: inline-block; } -.front_links a.settings { background: url("http://onefilecms.com/images/silk_settings.png") no-repeat; } -.front_links a.new { background: url("http://onefilecms.com/images/silk_new.png") no-repeat; } -.front_links a.newfolder { background: url("http://onefilecms.com/images/silk_newfolder.png") no-repeat; } -.front_links a.deletefolder { background: url("http://onefilecms.com/images/silk_deletefolder.png") no-repeat; } -.front_links a.renamefolder { background: url("http://onefilecms.com/images/silk_renamefolder.png") no-repeat; } -.front_links a.upload { background: url("http://onefilecms.com/images/silk_upload.png") no-repeat; } -.front_links a.other { background: url("http://onefilecms.com/images/silk_other.png") no-repeat; } - +.front_links a.settings { background: url("http://onefilecms.com/images/silk_settings.png") 0 3px no-repeat; } +.front_links a.new { background: url("http://onefilecms.com/images/silk_new.png") 0 3px no-repeat; } +.front_links a.newfolder { background: url("http://onefilecms.com/images/silk_newfolder.png") 0 2px no-repeat; } +.front_links a.deletefolder { background: url("http://onefilecms.com/images/silk_deletefolder.png") 0 2px no-repeat; } +.front_links a.renamefolder { background: url("http://onefilecms.com/images/silk_renamefolder.png") 0 2px no-repeat; } +.front_links a.upload { background: url("http://onefilecms.com/images/silk_upload.png") 0 3px no-repeat; } +.front_links a.other { background: url("http://onefilecms.com/images/silk_other.png") 0 3px no-repeat; } +.front_links a:hover { border: 1px solid #807568; background-color: #fffbce; } form .meta { z-index: -1; } .textinput { From c6ae3a59c26d9b3fa25f614573744f46b331bd7a Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Thu, 5 Apr 2012 20:08:49 -0400 Subject: [PATCH 006/228] Changed "Back" link to [Close] button on Edit page. --- onefilecms.css | 12 ++++++------ onefilecms.php | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index f12873c..a80e714 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -146,7 +146,7 @@ pre { display: inline-block; font-size: 16px; margin-right: 15px; - padding: 2px 4px 2px 20px;/* padding-left: 21px;*/ + padding: 2px 4px 2px 20px; display: inline-block; background: url("http://onefilecms.com/images/silk_folder.png") 0 2px no-repeat; } @@ -280,11 +280,11 @@ h1 a:visited { color: #0F0901; } /* --- edit --- */ -a.back { - float: right; - margin-top: -24px; - font-size: 16px; -} +#edit_header {float: left;} + +.close {float: right;} + + /* --- log in --- */ diff --git a/onefilecms.php b/onefilecms.php index ca856c7..a97b5a3 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -267,9 +267,9 @@ function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return // EDIT if ($page == "edit") { ?> -

Edit “

- ?i=" class="back">Back +

Edit “

?f="> + '" /> @@ -290,8 +290,8 @@ function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return ?r='" /> ?d='" /> ?c='" /> -

-
+ '" /> +

File Size: kb - Last Updated:

From 2408bdf0677d149e52c972285ad6c4e1665aec84 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Thu, 5 Apr 2012 20:33:11 -0400 Subject: [PATCH 007/228] Added function Cancel_Submit_Buttons($submit_label). But not yet used. --- onefilecms.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/onefilecms.php b/onefilecms.php index a97b5a3..11692b6 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -18,6 +18,38 @@ function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } $starttime = getmicrotime(); + + +/***********************************************************************/ +function Cancel_Submit_Buttons($submit_label) { + global $ONESCRIPT, $varvar; + + // [Cancel] returns to either the current/path, or current/path/file + if (isset($_GET["i"])){ + $ipath = '?i='.rtrim($_GET["i"],"/"); + + }else 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{ + $ipath = rtrim($varvar,"/"); + }//end if +?> +

+ + +

+ Date: Thu, 5 Apr 2012 23:34:08 -0400 Subject: [PATCH 008/228] Added $ONESCRIPT = $_SERVER["SCRIPT_NAME"] global variable. Used in Cancel_Submit_Buttons($button_label), [Cancel] button. Will be used to in place of $_SERVER["SCRIPT_NAME"] thru-out later. --- onefilecms.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 11692b6..eb6a187 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -10,7 +10,7 @@ $config_footer = date("Y")." OneFileCMS."; $config_disabled = "bmp,ico,gif,jpg,png,psd,zip"; $config_excluded = "onefilecms.php,favicon,.htaccess"; -$config_localcss = "onefilecms.css"; +$config_localcss = "onefilecms.css"; $ONESCRIPT = $_SERVER[SCRIPT_NAME]; $version = "1.1.6"; // ONEFILECMS_BEGIN if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; @@ -21,7 +21,7 @@ function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return /***********************************************************************/ -function Cancel_Submit_Buttons($submit_label) { +function Cancel_Submit_Buttons($button_label) { global $ONESCRIPT, $varvar; // [Cancel] returns to either the current/path, or current/path/file @@ -43,7 +43,7 @@ function Cancel_Submit_Buttons($submit_label) { ?>

- +

Date: Thu, 5 Apr 2012 23:50:16 -0400 Subject: [PATCH 009/228] Added Cancel_Submit_Buttons('Action') to pages with actions such as Copy, Rename, Delete, etc... Primarily adds a [Cancel] button to those pages --- onefilecms.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index eb6a187..ee657a0 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -263,7 +263,7 @@ function Cancel_Submit_Buttons($button_label) { " />

-

+

" />

- - '" /> + +

" />

" /> - - '" /> + +

New filename: " />

-

+

Folder name: " />

-

+

New filename:

-

+

New name: " />

-

+

File:

-

+

From 8e3c6b4d0d785a8f0256d07b28f5cd8c50fce479 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Fri, 6 Apr 2012 01:27:10 -0400 Subject: [PATCH 010/228] Tweaked spacing around nav links: Visit Site | Index | Log Out --- onefilecms.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index a80e714..009456d 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -273,11 +273,11 @@ h1 a:visited { color: #0F0901; } font-size: 14px; } -.nav a { +.nav a { border: 1px solid transparent; font-weight: bold; - text-decoration: none; + text-decoration: none; padding: .2em .5em .2em .5em ; } - +.nav a:hover { color: #995400; border: 1px solid #807568; background-color: #fffbce; } /* --- edit --- */ #edit_header {float: left;} From 7edf810aa5b8f0bac1116e27bf328aedae5117ce Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Fri, 6 Apr 2012 01:44:44 -0400 Subject: [PATCH 011/228] Added .index_folders { min-height: 2em; } In folders with no sub-folders, just keeps some space between path/to/current/folder/ and list of files --- onefilecms.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onefilecms.css b/onefilecms.css index 009456d..f075979 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -141,7 +141,7 @@ pre { overflow: hidden; line-height: 1.1em; } - +.index_folders { min-height: 2em; } .index_folders a { display: inline-block; font-size: 16px; From 99a7749d16e99c690afe9c23468ae525d1430712 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sat, 7 Apr 2012 02:44:27 -0400 Subject: [PATCH 012/228] Improved check for invalid pages (?p=), lines 69-77. If ?p=SomethingInvalid, seemed to only load site root. Now loads with ?p=index --- onefilecms.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index ee657a0..2310d21 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -10,7 +10,7 @@ $config_footer = date("Y")." OneFileCMS."; $config_disabled = "bmp,ico,gif,jpg,png,psd,zip"; $config_excluded = "onefilecms.php,favicon,.htaccess"; -$config_localcss = "onefilecms.css"; $ONESCRIPT = $_SERVER[SCRIPT_NAME]; +$config_localcss = "onefilecms.css"; $ONESCRIPT = $_SERVER["SCRIPT_NAME"]; $version = "1.1.6"; // ONEFILECMS_BEGIN if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; @@ -68,13 +68,13 @@ function Cancel_Submit_Buttons($button_label) { global $page; $page = "index"; if (isset($_GET["p"])) { // redirect on invalid page attempts + $page = $_GET["p"]; if (!in_array(strtolower($_GET["p"]), array( - "copy","delete","error","deletefolder","edit","folder","index","login","logout","new","other","rename","renamefolder","upload" - ))) { - header("Location: /"); - exit("Invalid parameter. Continue."); + "copy","delete","error","deletefolder","edit","folder","index","login","logout","new","other","rename","renamefolder","upload" ))) + { + header("Location: ".$ONESCRIPT); + $page = "index"; } - $page = $_GET["p"]; } if ($_GET["p"] == "other") {$pagetitle = "Other"; } if ($_GET["p"] == "login") {$pagetitle = "Log In"; } From b59388e8b408b19056828a1def6f55c7f63822a5 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sat, 7 Apr 2012 03:19:01 -0400 Subject: [PATCH 013/228] Improved check for a valid session. --- onefilecms.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 2310d21..23eea3b 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -51,21 +51,21 @@ function Cancel_Submit_Buttons($button_label) { session_start(); +global $page; $page = "index"; + if (isset($_POST["onefilecms_username"])) { $_SESSION['onefilecms_username'] = $_POST["onefilecms_username"]; } if (isset($_POST["onefilecms_password"])) { $_SESSION['onefilecms_password'] = $_POST["onefilecms_password"]; } if (($_SESSION['onefilecms_username'] == $config_username) and ($_SESSION['onefilecms_password'] == $config_password || md5($_SESSION['onefilecms_password']) == $config_password)) { $_SESSION['onefilecms_valid'] = "1"; } else { $_SESSION['onefilecms_valid'] = "0"; - if ($_GET["p"] !== "login") { - header("Location: ".$_SERVER["php_self"]."?p=login"); - exit("Invalid session. Please log in."); - } + $page = "login"; } + global $pagetitle; $pagetitle = "/"; if ((isset($_GET["i"])) && ($_GET["i"] !== "")) { $pagetitle = "/".$_GET["i"]."/"; } -global $page; $page = "index"; + if (isset($_GET["p"])) { // redirect on invalid page attempts $page = $_GET["p"]; From 696073a3228bf74880b0300d7f410fb889b300cf Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sat, 7 Apr 2012 03:44:46 -0400 Subject: [PATCH 014/228] Added check if ?p=login and already a valid session (hit back on browser), then don't display login page. --- onefilecms.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 23eea3b..39fa1b7 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -62,10 +62,8 @@ function Cancel_Submit_Buttons($button_label) { $page = "login"; } - global $pagetitle; $pagetitle = "/"; if ((isset($_GET["i"])) && ($_GET["i"] !== "")) { $pagetitle = "/".$_GET["i"]."/"; } - if (isset($_GET["p"])) { // redirect on invalid page attempts $page = $_GET["p"]; @@ -76,6 +74,8 @@ function Cancel_Submit_Buttons($button_label) { $page = "index"; } } +if ( ($page == "login") and ($_SESSION['onefilecms_valid']) ) {$page = "index"; header("Location: ".$ONESCRIPT);}; + if ($_GET["p"] == "other") {$pagetitle = "Other"; } if ($_GET["p"] == "login") {$pagetitle = "Log In"; } if ($_GET["p"] == "logout") {$pagetitle = "Log Out"; $_SESSION['onefilecms_valid'] = "0"; session_destroy(); } From 7c436d0be981bf11b76224454bf673d58b3749ae Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sat, 7 Apr 2012 09:40:37 -0400 Subject: [PATCH 015/228] Replaced all occurences $_SERVER["SCRIPT_NAME"] of with $ONESCRIPT. Makes lines a bit shorter, and is a bit easier to read. Well, to me, at least. --- onefilecms.php | 54 +++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 39fa1b7..4286f27 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -230,15 +230,15 @@ function Cancel_Submit_Buttons($button_label) {
@@ -252,7 +252,7 @@ function Cancel_Submit_Buttons($button_label) { $varvar = "?i=".substr($_GET["c"],0,strrpos($_GET["c"],"/")); ?>

Copy “

Existing files with the same filename are automatically overwritten... Be careful!

-
"> +

@@ -272,7 +272,7 @@ function Cancel_Submit_Buttons($button_label) { $varvar = "?i=".substr($_GET["d"],0,strrpos($_GET["d"],"/")); ?>

Delete “

Are you sure?

- "> +

@@ -287,7 +287,7 @@ function Cancel_Submit_Buttons($button_label) { $varvar = "?i=".substr($_GET["i"],0,strrpos(substr_replace($_GET["i"],"",-1),"/")); ?>

Delete Folder “

Folders have to be empty before they can be deleted.

- "> +

" /> @@ -300,7 +300,7 @@ function Cancel_Submit_Buttons($button_label) { // EDIT if ($page == "edit") { ?>

Edit “

- ?f="> + '" /> - ?r='" /> - ?d='" /> - ?c='" /> + + + '" />

File Size: kb - @@ -340,13 +340,13 @@ function Cancel_Submit_Buttons($button_label) { if ($varvar == "") { echo $path_levels[0]; // if at root, no need for link. } else { - echo ' '.$path_levels[0].' /'; + echo ' '.$path_levels[0].' /'; } $current_path = ""; for ($x=1; $x < $levels-1; $x++) { if ($x !== 1){ $current_path .= '/'; } $current_path = $current_path.$path_levels[$x]; - echo ' '; + echo ' '; echo ' '.$path_levels[$x].' /'; } echo ' '.$path_levels[$x].' /'; // last item is current dir. No link needed. @@ -357,7 +357,7 @@ function Cancel_Submit_Buttons($button_label) { $files = glob($varvar."*",GLOB_ONLYDIR); sort($files); foreach ($files as $file) { ?> - ?i=" class="folder"> +

@@ -386,7 +386,7 @@ function Cancel_Submit_Buttons($button_label) { if (strrpos($lfile,".css")) { $file_class = "css"; }; if (strrpos($lfile,".php")) { $file_class = "php"; }; ?>
  • - ?f=?f=" class="">
    @@ -400,19 +400,19 @@ function Cancel_Submit_Buttons($button_label) { } ?>

    Log In

    - "> +

    @@ -439,7 +439,7 @@ function Cancel_Submit_Buttons($button_label) {

    New File

    Existing files with the same name will not be overwritten.

    "> + $ONESCRIPT.substr_replace($varvar,"",-1); ?>">

    @@ -455,7 +455,7 @@ function Cancel_Submit_Buttons($button_label) { if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; }?>

    New Folder

    Existing folders with the same name will not be overwritten.

    - "> + ">

    @@ -475,7 +475,7 @@ function Cancel_Submit_Buttons($button_label) {

    This site powered by <a href="http://onefilecms.com/">OneFileCMS</a>.

    Admin Link

    Add this to your footer (or something) for lazy/forgetful admins. They'll still have to know the username and password, of course.

    -
    [<a href="">Admin</a>]
    +
    [<a href="">Admin</a>]

    Password Hash

    By the way, MD5 hash of your currently configured password is: @@ -491,7 +491,7 @@ function Cancel_Submit_Buttons($button_label) { careful!

    To move a file, preface its name with the folder's name, as in "foldername/filename.txt." The folder must already exist.

    - "> +

    @@ -510,7 +510,7 @@ function Cancel_Submit_Buttons($button_label) { if ($page == "renamefolder") { $varvar = "?i=".substr($_GET["i"],0,strrpos(substr_replace($_GET["i"],"",-1),"/")); ?>

    Rename Folder “

    - "> +

    " /> @@ -529,7 +529,7 @@ function Cancel_Submit_Buttons($button_label) { $varvar = ""; if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; } ?>

    Upload

    " method="post"> + $ONESCRIPT.substr_replace($varvar,"",-1); ?>" method="post">

    From 59e7cb46e647fd0694ee0e88dffd7e1eb2f5bbe1 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Mon, 9 Apr 2012 13:17:13 -0400 Subject: [PATCH 016/228] Changed where .css is hosted. Moved Upload link. --- onefilecms.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 4286f27..00469be 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -220,7 +220,7 @@ function Cancel_Submit_Buttons($button_label) { if (file_exists($config_localcss)) { echo $config_localcss; } else { - echo "http://onefilecms.com/style.css"; + echo "http://self-evident.github.com/OneFileCMS/onefilecms.css"; } ?>" type="text/css" rel="stylesheet" media="screen" /> @@ -400,11 +400,11 @@ function Cancel_Submit_Buttons($button_label) { } ?>

    - +

    From 3eefa9ae3fd53b27ee58b4c9e1afd0abd354ccde Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Tue, 10 Apr 2012 00:56:11 -0400 Subject: [PATCH 017/228] Style sheet icons now hosted on self-evident.github.com --- onefilecms.css | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index f075979..2a39307 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -15,7 +15,7 @@ h1,h2,h3,h4,h5,h6{font-weight: bold;} body { font-size: 12px; line-height: 20px; - background: #d5d0cc url("/images/background.jpg") top center no-repeat; + background: #d5d0cc; font-family: sans-serif; color: #0F0901; } @@ -95,11 +95,11 @@ pre { border-bottom: 1px solid #807568; } -#message p { +#message p {font-size: 1.3em; margin: 0; padding: 5px 5px 5px 30px; border: 1px solid #807568; - background: #fff000 url("http://onefilecms.com/images/silk_error.png") 10px 5px no-repeat; + background: #fff000 url("http://self-evident.github.com/OneFileCMS/images/silk_error.png") 10px 5px no-repeat; } /* --- INDEX --- */ @@ -119,15 +119,15 @@ pre { padding: 7px 5px 7px 35px; border: 1px solid #807568; text-decoration: none; - background: white url("http://onefilecms.com/images/silk_file.png") 10px 10px no-repeat; + background: white url("http://self-evident.github.com/OneFileCMS/images/silk_file.png") 10px 10px no-repeat; overflow: hidden; line-height: 1em; } -.index a.css { background: white url("http://onefilecms.com/images/silk_css.png") 10px 10px no-repeat; } -.index a.img { background: white url("http://onefilecms.com/images/silk_image.png") 10px 10px no-repeat; } -.index a.php { background: white url("http://onefilecms.com/images/silk_php.png") 10px 10px no-repeat; } +.index a.css { background: white url("http://self-evident.github.com/OneFileCMS/images/silk_css.png") 10px 10px no-repeat; } +.index a.img { background: white url("http://self-evident.github.com/OneFileCMS/images/silk_image.png") 10px 10px no-repeat; } +.index a.php { background: white url("http://self-evident.github.com/OneFileCMS/images/silk_php.png") 10px 10px no-repeat; } .index a:hover { background-color: #fffbce; @@ -148,7 +148,7 @@ pre { margin-right: 15px; padding: 2px 4px 2px 20px; display: inline-block; - background: url("http://onefilecms.com/images/silk_folder.png") 0 2px no-repeat; + background: url("http://self-evident.github.com/OneFileCMS/images/silk_folder.png") 0 2px no-repeat; } .index_folders a:hover { background-color: #fffbce; } /* --- list view --- */ @@ -207,20 +207,20 @@ ul.list .meta span { display: inline-block; } -.front_links a.settings { background: url("http://onefilecms.com/images/silk_settings.png") 0 3px no-repeat; } -.front_links a.new { background: url("http://onefilecms.com/images/silk_new.png") 0 3px no-repeat; } -.front_links a.newfolder { background: url("http://onefilecms.com/images/silk_newfolder.png") 0 2px no-repeat; } -.front_links a.deletefolder { background: url("http://onefilecms.com/images/silk_deletefolder.png") 0 2px no-repeat; } -.front_links a.renamefolder { background: url("http://onefilecms.com/images/silk_renamefolder.png") 0 2px no-repeat; } -.front_links a.upload { background: url("http://onefilecms.com/images/silk_upload.png") 0 3px no-repeat; } -.front_links a.other { background: url("http://onefilecms.com/images/silk_other.png") 0 3px no-repeat; } +.front_links a.settings { background: url("http://self-evident.github.com/OneFileCMS/images/silk_settings.png") 0 3px no-repeat; } +.front_links a.new { background: url("http://self-evident.github.com/OneFileCMS/images/silk_new.png") 0 3px no-repeat; } +.front_links a.newfolder { background: url("http://self-evident.github.com/OneFileCMS/images/silk_newfolder.png") 0 2px no-repeat; } +.front_links a.deletefolder { background: url("http://self-evident.github.com/OneFileCMS/images/silk_deletefolder.png") 0 2px no-repeat; } +.front_links a.renamefolder { background: url("http://self-evident.github.com/OneFileCMS/images/silk_renamefolder.png") 0 2px no-repeat; } +.front_links a.upload { background: url("http://self-evident.github.com/OneFileCMS/images/silk_upload.png") 0 3px no-repeat; } +.front_links a.other { background: url("http://self-evident.github.com/OneFileCMS/images/silk_other.png") 0 3px no-repeat; } .front_links a:hover { border: 1px solid #807568; background-color: #fffbce; } form .meta { z-index: -1; } .textinput { border: 1px solid #807568; padding: 2px; - width: 350px; + width: 650px; font: 12px/18px "Courier New", Courier, monospace; } @@ -257,7 +257,7 @@ h1 a { } h1 a.onefilecms { - background: url("http://onefilecms.com/images/logo.gif") top left no-repeat; + background: url("http://self-evident.github.com/OneFileCMS/images/logo.gif") top left no-repeat; width: 208px; height: 29px; display: block; From f591686cdc8019a31e288dab1a7dea0c254080f6 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Tue, 10 Apr 2012 13:51:26 -0400 Subject: [PATCH 018/228] Removed superfluous START, FINISH, & microtime lines & footer. --- onefilecms.css | 602 ++++++++++++------------- onefilecms.php | 1167 ++++++++++++++++++++++++------------------------ 2 files changed, 881 insertions(+), 888 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index 2a39307..60bb25f 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -1,301 +1,301 @@ -/* --- reset --- */ - -html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big, -cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li, -fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{border:0;outline:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;margin:0;padding:0;} -:focus{outline:0;} -ol,ul{list-style:none;} -table{border-collapse:separate;border-spacing:0;} -caption,th,td{text-align:left;font-weight:400;} -blockquote:before,blockquote:after,q:before,q:after{content:"";} -blockquote,q{quotes:"" "";} -div{position: relative;} -h1,h2,h3,h4,h5,h6{font-weight: bold;} - -body { - font-size: 12px; - line-height: 20px; - background: #d5d0cc; - font-family: sans-serif; - color: #0F0901; -} - -/* --- layout --- */ - -.container { - width: 800px; - padding: 0 10px; - margin: 20px auto; -} - -.header { - margin-bottom: 10px; - padding-bottom: 10px; - border-bottom: 1px solid #807568; - color: #676767; - position: relative; -} - -.footer { - margin-top: 10px; - padding-top: 10px; - border-top: 1px solid #807568; - clear: both; -} - -/* --- general formatting --- */ - -h2,h3,p,ul,table { margin-bottom: 10px; } -p, li {line-height: 1.4em; } -form p { margin-bottom: 5px; } -a { color: #774200; text-decoration: none; border: 1px solid transparent; } -a:hover { color: #976322; } -a:hover { color: #995400; border: 1px solid #807568; background-color: #fffbce; } -h2 { font-size: 20px; } -h3 { font-size: 18px; margin-top: 15px; } -em, i { font-style: italic; } -strong { font-weight: bold; } - -label { - font-size: 14px; - font-style: italic; - width: 110px; - display: inline-block; -} - -pre { - background: white; - border: 1px solid #807568; - line-height: 1.25em; - overflow: auto - overflow-Y: hidden; - padding: 10px; - margin: 5px 0 10px 0; - overflow: hidden; -} - -.page_login label { - display: block; - margin-bottom: 2px; -} - -.alignleft { - margin: 0 10px 10px 0; - float: left; -} - -.left70 { - width: 70px; - display: inline-block; -} - -#message { - margin-bottom: 10px; - padding-bottom: 10px; - border-bottom: 1px solid #807568; -} - -#message p {font-size: 1.3em; - margin: 0; - padding: 5px 5px 5px 30px; - border: 1px solid #807568; - background: #fff000 url("http://self-evident.github.com/OneFileCMS/images/silk_error.png") 10px 5px no-repeat; -} - -/* --- INDEX --- */ - -.index { width: 810px; } - -.index li { - margin: 0 10px 10px 0; - width: 192.5px; - float: left; - position: relative; -} - -.index a { - height: 28px; - display: block; - padding: 7px 5px 7px 35px; - border: 1px solid #807568; - text-decoration: none; - background: white url("http://self-evident.github.com/OneFileCMS/images/silk_file.png") 10px 10px no-repeat; - overflow: hidden; - line-height: 1em; -} - - -.index a.css { background: white url("http://self-evident.github.com/OneFileCMS/images/silk_css.png") 10px 10px no-repeat; } -.index a.img { background: white url("http://self-evident.github.com/OneFileCMS/images/silk_image.png") 10px 10px no-repeat; } -.index a.php { background: white url("http://self-evident.github.com/OneFileCMS/images/silk_php.png") 10px 10px no-repeat; } - -.index a:hover { - background-color: #fffbce; - border: 1px solid #969376; -} - -.index .meta { - font-size: 11px; - height: 25px; - margin-top: 3px; - overflow: hidden; - line-height: 1.1em; -} -.index_folders { min-height: 2em; } -.index_folders a { - display: inline-block; - font-size: 16px; - margin-right: 15px; - padding: 2px 4px 2px 20px; - display: inline-block; - background: url("http://self-evident.github.com/OneFileCMS/images/silk_folder.png") 0 2px no-repeat; -} -.index_folders a:hover { background-color: #fffbce; } -/* --- list view --- */ - -ul.list { - width: 100%; - margin-bottom: 31px; -} - -ul.index.list * { - width: auto; - height: auto; - padding: 0; - margin: 0; - display: visible; - line-height: 21px; -} - -ul.index.list li { - float: none; - clear: both; -} - -ul.index.list li a { - display: block; - float: left; - background-color: transparent; - background-position: top left; - border: none; - width: 200px; - text-indent: 26px; -} - -ul.list .meta { - display: block; - float: left; - height: auto; -} - -ul.list .meta br { display: none; } - -ul.list .meta span { - display: block; - float: left; - width: 200px; -} - - -.front_links { clear: both; } - -.front_links a { padding: 3px; - font-size: 16px; - margin-right: 15px; - padding-left: 21px; - height: 16px; - display: inline-block; -} - -.front_links a.settings { background: url("http://self-evident.github.com/OneFileCMS/images/silk_settings.png") 0 3px no-repeat; } -.front_links a.new { background: url("http://self-evident.github.com/OneFileCMS/images/silk_new.png") 0 3px no-repeat; } -.front_links a.newfolder { background: url("http://self-evident.github.com/OneFileCMS/images/silk_newfolder.png") 0 2px no-repeat; } -.front_links a.deletefolder { background: url("http://self-evident.github.com/OneFileCMS/images/silk_deletefolder.png") 0 2px no-repeat; } -.front_links a.renamefolder { background: url("http://self-evident.github.com/OneFileCMS/images/silk_renamefolder.png") 0 2px no-repeat; } -.front_links a.upload { background: url("http://self-evident.github.com/OneFileCMS/images/silk_upload.png") 0 3px no-repeat; } -.front_links a.other { background: url("http://self-evident.github.com/OneFileCMS/images/silk_other.png") 0 3px no-repeat; } -.front_links a:hover { border: 1px solid #807568; background-color: #fffbce; } -form .meta { z-index: -1; } - -.textinput { - border: 1px solid #807568; - padding: 2px; - width: 650px; - font: 12px/18px "Courier New", Courier, monospace; -} - -textarea.textinput { - width: 794px; - height: 550px; -} - -textarea.disabled { height: 50px; } - -.buttons_right { float: right;} -.buttons_right .button { margin-left: 7px; } -.buttons_left { float: left;} -.buttons_left .button { margin-right: 7px; } - -.button { - border: 1px solid #807568; - padding: 4px 10px; - background-color: #d4d4d4; - cursor: pointer; - font-size: 14px; - font-family: sans-serif; -} - -.button:hover { background-color: #eaeaea; } -.button[disabled]:hover { background-color: #d4d4d4; } - -/* --- header --- */ - -h1 a { - font-size: 28px; - text-decoration: none; - color: #0F0901; -} - -h1 a.onefilecms { - background: url("http://self-evident.github.com/OneFileCMS/images/logo.gif") top left no-repeat; - width: 208px; - height: 29px; - display: block; - text-indent: -2000px; -} - -h1 a:visited { color: #0F0901; } - -.nav { - position: absolute; - bottom: 12px; - right: 0; - font-size: 14px; -} - -.nav a { border: 1px solid transparent; - font-weight: bold; - text-decoration: none; padding: .2em .5em .2em .5em ; -} -.nav a:hover { color: #995400; border: 1px solid #807568; background-color: #fffbce; } -/* --- edit --- */ - -#edit_header {float: left;} - -.close {float: right;} - - - -/* --- log in --- */ - -.page_login .container, .page_logout .container { - width: 356px; - margin-top: 60px; -} - - -/* --- path/to/current/index --- */ - -.path { border: 1px solid transparent; } - -.path:hover { border: 1px solid #807568; background-color: #fffbce; } +/* --- reset --- */ + +html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big, +cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li, +fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{border:0;outline:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;margin:0;padding:0;} +:focus{outline:0;} +ol,ul{list-style:none;} +table{border-collapse:separate;border-spacing:0;} +caption,th,td{text-align:left;font-weight:400;} +blockquote:before,blockquote:after,q:before,q:after{content:"";} +blockquote,q{quotes:"" "";} +div{position: relative;} +h1,h2,h3,h4,h5,h6{font-weight: bold;} + +body { + font-size: 12px; + line-height: 20px; + background: #d5d0cc; + font-family: sans-serif; + color: #0F0901; +} + +/* --- layout --- */ + +.container { + width: 800px; + padding: 0 10px; + margin: 20px auto; +} + +.header { + margin-bottom: 10px; + padding-bottom: 10px; + border-bottom: 1px solid #807568; + color: #676767; + position: relative; +} + +.footer { /* + margin-top: 10px; + padding-top: 10px; + border-top: 0px solid #807568; + clear: both; */ +} + +/* --- general formatting --- */ + +h2,h3,p,ul,table { margin-bottom: 10px; } +p, li {line-height: 1.4em; } +form p { margin-bottom: 5px; } +a { color: #774200; text-decoration: none; border: 1px solid transparent; } +a:hover { color: #976322; } +a:hover { color: #995400; border: 1px solid #807568; background-color: #fffbce; } +h2 { font-size: 20px; } +h3 { font-size: 18px; margin-top: 15px; } +em, i { font-style: italic; } +strong { font-weight: bold; } + +label { + font-size: 14px; + font-style: italic; + width: 110px; + display: inline-block; +} + +pre { + background: white; + border: 1px solid #807568; + line-height: 1.25em; + overflow: auto + overflow-Y: hidden; + padding: 10px; + margin: 5px 0 10px 0; + overflow: hidden; +} + +.page_login label { + display: block; + margin-bottom: 2px; +} + +.alignleft { + margin: 0 10px 10px 0; + float: left; +} + +.left70 { + width: 70px; + display: inline-block; +} + +#message { + margin-bottom: 10px; + padding-bottom: 10px; + border-bottom: 1px solid #807568; +} + +#message p {font-size: 1.3em; + margin: 0; + padding: 5px 5px 5px 30px; + border: 1px solid #807568; + background: #fff000 url("http://self-evident.github.com/OneFileCMS/images/silk_error.png") 10px 5px no-repeat; +} + +/* --- INDEX --- */ + +.index { width: 810px; } + +.index li { + margin: 0 10px 10px 0; + width: 192.5px; + float: left; + position: relative; +} + +.index a { + height: 28px; + display: block; + padding: 7px 5px 7px 35px; + border: 1px solid #807568; + text-decoration: none; + background: white url("http://self-evident.github.com/OneFileCMS/images/silk_file.png") 10px 10px no-repeat; + overflow: hidden; + line-height: 1em; +} + + +.index a.css { background: white url("http://self-evident.github.com/OneFileCMS/images/silk_css.png") 10px 10px no-repeat; } +.index a.img { background: white url("http://self-evident.github.com/OneFileCMS/images/silk_image.png") 10px 10px no-repeat; } +.index a.php { background: white url("http://self-evident.github.com/OneFileCMS/images/silk_php.png") 10px 10px no-repeat; } + +.index a:hover { + background-color: #fffbce; + border: 1px solid #969376; +} + +.index .meta { + font-size: 11px; + height: 25px; + margin-top: 3px; + overflow: hidden; + line-height: 1.1em; +} +.index_folders { min-height: 2em; } +.index_folders a { + display: inline-block; + font-size: 16px; + margin-right: 15px; + padding: 2px 4px 2px 20px; + display: inline-block; + background: url("http://self-evident.github.com/OneFileCMS/images/silk_folder.png") 0 2px no-repeat; +} +.index_folders a:hover { background-color: #fffbce; } +/* --- list view --- */ + +ul.list { + width: 100%; + margin-bottom: 31px; +} + +ul.index.list * { + width: auto; + height: auto; + padding: 0; + margin: 0; + display: visible; + line-height: 21px; +} + +ul.index.list li { + float: none; + clear: both; +} + +ul.index.list li a { + display: block; + float: left; + background-color: transparent; + background-position: top left; + border: none; + width: 200px; + text-indent: 26px; +} + +ul.list .meta { + display: block; + float: left; + height: auto; +} + +ul.list .meta br { display: none; } + +ul.list .meta span { + display: block; + float: left; + width: 200px; +} + + +.front_links { clear: both; } + +.front_links a { padding: 3px; + font-size: 16px; + margin-right: 15px; + padding-left: 21px; + height: 16px; + display: inline-block; +} + +.front_links a.settings { background: url("http://self-evident.github.com/OneFileCMS/images/silk_settings.png") 0 3px no-repeat; } +.front_links a.new { background: url("http://self-evident.github.com/OneFileCMS/images/silk_new.png") 0 3px no-repeat; } +.front_links a.newfolder { background: url("http://self-evident.github.com/OneFileCMS/images/silk_newfolder.png") 0 2px no-repeat; } +.front_links a.deletefolder { background: url("http://self-evident.github.com/OneFileCMS/images/silk_deletefolder.png") 0 2px no-repeat; } +.front_links a.renamefolder { background: url("http://self-evident.github.com/OneFileCMS/images/silk_renamefolder.png") 0 2px no-repeat; } +.front_links a.upload { background: url("http://self-evident.github.com/OneFileCMS/images/silk_upload.png") 0 3px no-repeat; } +.front_links a.other { background: url("http://self-evident.github.com/OneFileCMS/images/silk_other.png") 0 3px no-repeat; } +.front_links a:hover { border: 1px solid #807568; background-color: #fffbce; } +form .meta { z-index: -1; } + +.textinput { + border: 1px solid #807568; + padding: 2px; + width: 650px; + font: 12px/18px "Courier New", Courier, monospace; +} + +textarea.textinput { + width: 794px; + height: 550px; +} + +textarea.disabled { height: 50px; } + +.buttons_right { float: right;} +.buttons_right .button { margin-left: 7px; } +.buttons_left { float: left;} +.buttons_left .button { margin-right: 7px; } + +.button { + border: 1px solid #807568; + padding: 4px 10px; + background-color: #d4d4d4; + cursor: pointer; + font-size: 14px; + font-family: sans-serif; +} + +.button:hover { background-color: #eaeaea; } +.button[disabled]:hover { background-color: #d4d4d4; } + +/* --- header --- */ + +h1 a { + font-size: 28px; + text-decoration: none; + color: #0F0901; +} + +h1 a.onefilecms { + background: url("http://self-evident.github.com/OneFileCMS/images/logo.gif") top left no-repeat; + width: 208px; + height: 29px; + display: block; + text-indent: -2000px; +} + +h1 a:visited { color: #0F0901; } + +.nav { + position: absolute; + bottom: 12px; + right: 0; + font-size: 14px; +} + +.nav a { border: 1px solid transparent; + font-weight: bold; + text-decoration: none; padding: .2em .5em .2em .5em ; +} +.nav a:hover { color: #995400; border: 1px solid #807568; background-color: #fffbce; } +/* --- edit --- */ + +#edit_header {float: left;} + +.close {float: right;} + + + +/* --- log in --- */ + +.page_login .container, .page_logout .container { + width: 356px; + margin-top: 60px; +} + + +/* --- path/to/current/index --- */ + +.path { border: 1px solid transparent; } + +.path:hover { border: 1px solid #807568; background-color: #fffbce; } diff --git a/onefilecms.php b/onefilecms.php index 00469be..a2a91d0 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,588 +1,581 @@ -OneFileCMS."; -$config_disabled = "bmp,ico,gif,jpg,png,psd,zip"; -$config_excluded = "onefilecms.php,favicon,.htaccess"; -$config_localcss = "onefilecms.css"; $ONESCRIPT = $_SERVER["SCRIPT_NAME"]; -$version = "1.1.6"; // ONEFILECMS_BEGIN - -if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; - -function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } -$starttime = getmicrotime(); - - - -/***********************************************************************/ -function Cancel_Submit_Buttons($button_label) { - global $ONESCRIPT, $varvar; - - // [Cancel] returns to either the current/path, or current/path/file - if (isset($_GET["i"])){ - $ipath = '?i='.rtrim($_GET["i"],"/"); - - }else 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{ - $ipath = rtrim($varvar,"/"); - }//end if -?> -

    - - -

    - $value) { - $_GET[$name] = htmlentities($value); -} - -// COPY FILE -if (isset($_GET["c"])) { - $filename = $_GET["c"]; $pagetitle = "Copy “".$filename."”"; $page = "copy"; -} - -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."."; -} - -// DELETE FILE -if (isset($_GET["d"])) { - $filename = $_GET["d"]; - $pagetitle = "Delete “".$filename."”"; - $page = "delete"; -} -if (isset($_POST["delete_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { - $filename = $_POST["delete_filename"]; - unlink($filename); - $message = $filename." successfully deleted."; -} - -// DELETE FOLDER -if ($_GET["p"] == "deletefolder") { - $pagetitle = "Delete Folder “".$_GET["i"]."”"; -} -if (isset($_POST["delete_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { - $foldername = $_POST["delete_foldername"]; - if (@rmdir($foldername)) { - $message = $foldername." successfully deleted."; - } else { - $message = "That folder is not empty."; - } -} - -// EDIT -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."; -} -if (isset($_GET["f"])) { - $filename = stripslashes($_GET["f"]); - if (file_exists($filename)) { - $page = "edit"; - $pagetitle = "Edit “".$filename."”"; - $fp = @fopen($filename, "r"); - if (filesize($filename) !== 0) { - $loadcontent = fread($fp, filesize($filename)); - $loadcontent = htmlspecialchars($loadcontent); - } - fclose($fp); - } else { - $page = "error"; - unset ($filename); - $message = "File does not exist."; - } -} -// 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"]; - 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."; - } -} -// NEW FOLDER -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."; - } else { - $message = "A folder by that name already exists."; - } -} -// RENAME FILE -if (isset($_GET["r"])) { - $filename = $_GET["r"]; - $pagetitle = "Rename “".$filename."”"; - $page = "rename"; -} -if (isset($_POST["rename_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { - $old_filename = $_POST["old_filename"]; - $filename = $_POST["rename_filename"]; - rename($old_filename, $filename); - $message = $old_filename." successfully renamed to ".$filename."."; -} -// RENAME FOLDER -if ($_GET["p"] == "renamefolder") {$pagetitle = "Rename Folder “".$_GET["i"]."”"; } -if (isset($_POST["rename_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { - $old_foldername = $_POST["old_foldername"]; - $foldername = $_POST["rename_foldername"]; - if (rename($old_foldername, $foldername)) { - $message = $old_foldername." unsuccessfully renamed to ".$foldername."."; - } else { - $message = "There was an error. Try again and/or contact your admin."; - } -} -// 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']; - $destination = $_POST["upload_destination"]; - if(move_uploaded_file($_FILES['upload_filename']['tmp_name'], - $destination.basename($filename))) { - $message = basename($filename)." uploaded successfully to ".$destination."."; - } else{ - $message = "There was an error. Try again and/or contact your admin."; - } -} - -?> - - - - -<?php echo $config_title; ?> - <?php echo $pagetitle; ?> -" type="text/css" rel="stylesheet" media="screen" /> - - - - -
    - -
    -

    ">

    - - - -
    - -

    -

    Copy “

    -

    Existing files with the same filename are automatically overwritten... Be careful!

    -
    - -

    - - - -

    -

    - - " /> -

    -

    -
    - -

    Delete “

    -

    Are you sure?

    -
    - -

    - - - -

    -
    - -

    Delete Folder “

    -

    Folders have to be empty before they can be deleted.

    -
    - -

    - " /> - - -

    -
    - -

    Edit “

    -
    - '" /> - - -

    - -

    -

    - - -

    - - -

    -

    - - - - - - '" /> -

    -

    File Size: kb - - Last Updated:

    -
    -
    -
    - -

    '.$path_levels[0].' /'; - } - $current_path = ""; - for ($x=1; $x < $levels-1; $x++) { - if ($x !== 1){ $current_path .= '/'; } - $current_path = $current_path.$path_levels[$x]; - echo ' '; - echo ' '.$path_levels[$x].' /'; - } - echo ' '.$path_levels[$x].' /'; // last item is current dir. No link needed. - ?>

    - -

    - - - -

    -
    -
      - -
    • - -
      - File Size: kb
      - Last Updated: -
      -
    • - -
    - - -

    Log In

    -
    -

    - - -

    -

    - - -

    -

    Hint:

    -

    -
    - -

    Log Out

    -

    You have successfully been logged out and may close this window.

    - -

    New File

    -

    Existing files with the same name will not be overwritten.

    -
    "> - -

    - - " /> -

    -

    -
    - -

    New Folder

    -

    Existing folders with the same name will not be overwritten.

    -
    "> - -

    - - " /> -

    -

    -
    - -

    Other

    -

    Check for Updates

    -

    Future versions of OneFileCMS will have a one-click upgrade process. For now, though, you have to click this link. You are using version .

    -

    Want some good Karma?

    -

    Let people know you use OneFileCMS by putting this in your footer:

    -
    This site powered by <a href="http://onefilecms.com/">OneFileCMS</a>.
    -

    Admin Link

    -

    Add this to your footer (or something) for lazy/forgetful admins. They'll still have to know the username and password, of course.

    -
    [<a href="">Admin</a>]
    - -

    Password Hash

    -

    By the way, MD5 hash of your currently configured password is: - - -

    Rename “

    -

    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.

    -
    - -

    - - - -

    -

    - - -

    -

    -
    - -

    Rename Folder “

    -
    - -

    - " /> - " class="textinput" disabled="disabled" /> -

    -

    - - " /> -

    -

    -
    - -

    Upload

    -
    " method="post"> - - -

    - - " class="textinput" /> -

    -

    - - -

    -

    -
    - - - - -
    - - - - - +OneFileCMS."; +$config_disabled = "bmp,ico,gif,jpg,png,psd,zip"; +$config_excluded = "onefilecms.php,favicon,.htaccess"; +$config_localcss = "onefilecms.css"; $ONESCRIPT = $_SERVER["SCRIPT_NAME"]; +$version = "1.1.6"; // ONEFILECMS_BEGIN + +if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; + +/***********************************************************************/ +function Cancel_Submit_Buttons($button_label) { + global $ONESCRIPT, $varvar; + + // [Cancel] returns to either the current/path, or current/path/file + if (isset($_GET["i"])){ + $ipath = '?i='.rtrim($_GET["i"],"/"); + + }else 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{ + $ipath = rtrim($varvar,"/"); + }//end if +?> +

    + + +

    + $value) { + $_GET[$name] = htmlentities($value); +} + +// COPY FILE +if (isset($_GET["c"])) { + $filename = $_GET["c"]; $pagetitle = "Copy “".$filename."”"; $page = "copy"; +} + +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."."; +} + +// DELETE FILE +if (isset($_GET["d"])) { + $filename = $_GET["d"]; + $pagetitle = "Delete “".$filename."”"; + $page = "delete"; +} +if (isset($_POST["delete_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { + $filename = $_POST["delete_filename"]; + unlink($filename); + $message = $filename." successfully deleted."; +} + +// DELETE FOLDER +if ($_GET["p"] == "deletefolder") { + $pagetitle = "Delete Folder “".$_GET["i"]."”"; +} +if (isset($_POST["delete_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { + $foldername = $_POST["delete_foldername"]; + if (@rmdir($foldername)) { + $message = $foldername." successfully deleted."; + } else { + $message = "That folder is not empty."; + } +} + +// EDIT +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."; +} +if (isset($_GET["f"])) { + $filename = stripslashes($_GET["f"]); + if (file_exists($filename)) { + $page = "edit"; + $pagetitle = "Edit “".$filename."”"; + $fp = @fopen($filename, "r"); + if (filesize($filename) !== 0) { + $loadcontent = fread($fp, filesize($filename)); + $loadcontent = htmlspecialchars($loadcontent); + } + fclose($fp); + } else { + $page = "error"; + unset ($filename); + $message = "File does not exist."; + } +} +// 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"]; + 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."; + } +} +// NEW FOLDER +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."; + } else { + $message = "A folder by that name already exists."; + } +} +// RENAME FILE +if (isset($_GET["r"])) { + $filename = $_GET["r"]; + $pagetitle = "Rename “".$filename."”"; + $page = "rename"; +} +if (isset($_POST["rename_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { + $old_filename = $_POST["old_filename"]; + $filename = $_POST["rename_filename"]; + rename($old_filename, $filename); + $message = $old_filename." successfully renamed to ".$filename."."; +} +// RENAME FOLDER +if ($_GET["p"] == "renamefolder") {$pagetitle = "Rename Folder “".$_GET["i"]."”"; } +if (isset($_POST["rename_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { + $old_foldername = $_POST["old_foldername"]; + $foldername = $_POST["rename_foldername"]; + if (rename($old_foldername, $foldername)) { + $message = $old_foldername." unsuccessfully renamed to ".$foldername."."; + } else { + $message = "There was an error. Try again and/or contact your admin."; + } +} +// 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']; + $destination = $_POST["upload_destination"]; + if(move_uploaded_file($_FILES['upload_filename']['tmp_name'], + $destination.basename($filename))) { + $message = basename($filename)." uploaded successfully to ".$destination."."; + } else{ + $message = "There was an error. Try again and/or contact your admin."; + } +} + +?> + + + + +<?php echo $config_title; ?> - <?php echo $pagetitle; ?> +" type="text/css" rel="stylesheet" media="screen" /> + + + + +
    + +
    +

    ">

    + + + +
    + +

    +

    Copy “

    +

    Existing files with the same filename are automatically overwritten... Be careful!

    +
    + +

    + + + +

    +

    + + " /> +

    +

    +
    + +

    Delete “

    +

    Are you sure?

    +
    + +

    + + + +

    +
    + +

    Delete Folder “

    +

    Folders have to be empty before they can be deleted.

    +
    + +

    + " /> + + +

    +
    + +

    Edit “

    +
    + '" /> + + +

    + +

    +

    + + +

    + + +

    +

    + + + + + + '" /> +

    +

    File Size: kb - + Last Updated:

    +
    +
    +
    + +

    '.$path_levels[0].' /'; + } + $current_path = ""; + for ($x=1; $x < $levels-1; $x++) { + if ($x !== 1){ $current_path .= '/'; } + $current_path = $current_path.$path_levels[$x]; + echo ' '; + echo ' '.$path_levels[$x].' /'; + } + echo ' '.$path_levels[$x].' /'; // last item is current dir. No link needed. + ?>

    + +

    + + + +

    +
    +
      + +
    • + +
      + File Size: kb
      + Last Updated: +
      +
    • + +
    + + +

    Log In

    +
    +

    + + +

    +

    + + +

    +

    Hint:

    +

    +
    + +

    Log Out

    +

    You have successfully been logged out and may close this window.

    + +

    New File

    +

    Existing files with the same name will not be overwritten.

    +
    "> + +

    + + " /> +

    +

    +
    + +

    New Folder

    +

    Existing folders with the same name will not be overwritten.

    +
    "> + +

    + + " /> +

    +

    +
    + +

    Other

    +

    Check for Updates

    +

    Future versions of OneFileCMS will have a one-click upgrade process. For now, though, you have to click this link. You are using version .

    +

    Want some good Karma?

    +

    Let people know you use OneFileCMS by putting this in your footer:

    +
    This site powered by <a href="http://onefilecms.com/">OneFileCMS</a>.
    +

    Admin Link

    +

    Add this to your footer (or something) for lazy/forgetful admins. They'll still have to know the username and password, of course.

    +
    [<a href="">Admin</a>]
    + +

    Password Hash

    +

    By the way, MD5 hash of your currently configured password is: + + +

    Rename “

    +

    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.

    +
    + +

    + + + +

    +

    + + +

    +

    +
    + +

    Rename Folder “

    +
    + +

    + " /> + " class="textinput" disabled="disabled" /> +

    +

    + + " /> +

    +

    +
    + +

    Upload

    +
    " method="post"> + + +

    + + " class="textinput" /> +

    +

    + + +

    +

    +
    + + + + +
    + + + + + \ No newline at end of file From c8c39d92e149064633c7215de5a3968182cc8fa0 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Tue, 10 Apr 2012 14:08:47 -0400 Subject: [PATCH 019/228] Tweaked login screen fields. Removed hint. --- onefilecms.css | 15 +++++++++++++-- onefilecms.php | 8 ++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index 60bb25f..568db96 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -289,11 +289,22 @@ h1 a:visited { color: #0F0901; } /* --- log in --- */ .page_login .container, .page_logout .container { - width: 356px; - margin-top: 60px; + margin-top: 5em; + border : 1px solid #807568; + padding : 1em; + width : 360px; } +.login_input { + border : 1px solid #807568; + padding : 2px 0px 2px 2px; + width : 356px; + font : 1.3em Courier; +} + + + /* --- path/to/current/index --- */ .path { border: 1px solid transparent; } diff --git a/onefilecms.php b/onefilecms.php index a2a91d0..0d29de0 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -410,14 +410,14 @@ function Cancel_Submit_Buttons($button_label) {

    - +

    - +

    -

    Hint:

    -

    + +
    Date: Tue, 10 Apr 2012 20:18:03 -0400 Subject: [PATCH 020/228] Tweaked Other page, header & nav links, footer. Mostly styling changes, but some minor rewording. Removed use of logo.gif. Using styled text now. Message box that confirms success/failure of actions no longer fades out. --- onefilecms.css | 61 ++++++++++++++++++++++++++++++++++++-------------- onefilecms.php | 37 +++++++++++++++--------------- 2 files changed, 63 insertions(+), 35 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index 568db96..ffa8434 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -29,19 +29,22 @@ body { } .header { - margin-bottom: 10px; - padding-bottom: 10px; - border-bottom: 1px solid #807568; + margin-bottom: 1em; padding-bottom: .9em; + border-bottom: 1px solid #807568; /*using
    . Styles at bottom of this file*/ color: #676767; position: relative; } -.footer { /* + +#logo {font-family: 'Trebuchet MS', sans-serif; font-size:2.9em; font-weight: bold; color: black;} + + +.footer { /************************ margin-top: 10px; padding-top: 10px; - border-top: 0px solid #807568; - clear: both; */ -} + border-top: 01px solid #807568; /*using
    . Styles at bottom of this file + clear: both; ****************/ + } /* --- general formatting --- */ @@ -267,17 +270,25 @@ h1 a.onefilecms { h1 a:visited { color: #0F0901; } .nav { - position: absolute; - bottom: 12px; - right: 0; - font-size: 14px; -} + float : right; + display : inline-block; + margin-top: 1.2em; + font-size : 1em; + } + +.nav a { + border: 1px solid transparent; + font-weight : bold; + padding : .0em; + padding-top : .2em; + padding-left : .6em; + padding-right : .6em; + padding-bottom: .1em; + } + +.nav a:hover {border: 01px solid #807568;} + -.nav a { border: 1px solid transparent; - font-weight: bold; - text-decoration: none; padding: .2em .5em .2em .5em ; -} -.nav a:hover { color: #995400; border: 1px solid #807568; background-color: #fffbce; } /* --- edit --- */ #edit_header {float: left;} @@ -310,3 +321,19 @@ h1 a:visited { color: #0F0901; } .path { border: 1px solid transparent; } .path:hover { border: 1px solid #807568; background-color: #fffbce; } + + +hr { + line-height : 0; + font-size : 1px; + display : block; + position: relative; + padding : 0; + margin : 8px auto; + width : 100%; + clear : both; + border : none; + border-top : 1px solid #807568; + Xborder-bottom: 1px solid #eee; + overflow: visible; + } diff --git a/onefilecms.php b/onefilecms.php index 0d29de0..4fb235e 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -3,15 +3,16 @@ // OneFileCMS - http://onefilecms.com/ // CONFIGURATION INFO +$version = "1.1.7.BETA"; // ONEFILECMS_BEGIN +$ONESCRIPT = $_SERVER["SCRIPT_NAME"]; $config_username = "username"; $config_password = "password"; -$config_hint = ""; -$config_title = "OneFileCMS"; -$config_footer = date("Y")." OneFileCMS."; +$config_hint = ""; //Not currently used +$config_title = "OneFileCMS"; +$config_footer = date("Y")." OneFileCMS."; $config_disabled = "bmp,ico,gif,jpg,png,psd,zip"; $config_excluded = "onefilecms.php,favicon,.htaccess"; -$config_localcss = "onefilecms.css"; $ONESCRIPT = $_SERVER["SCRIPT_NAME"]; -$version = "1.1.6"; // ONEFILECMS_BEGIN +$config_localcss = "onefilecms.css"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; @@ -225,11 +226,10 @@ function Cancel_Submit_Buttons($button_label) {
    -

    ">

    - + + ', $config_title; ?> + + +

    Other

    +

    Check for Updates

    -

    Future versions of OneFileCMS will have a one-click upgrade process. For now, though, you have to click this link. You are using version .

    +

    You are using version .
    + Future versions of OneFileCMS may have a one-click upgrade process. For now, though, you have to >click this link<.

    +

    Want some good Karma?

    Let people know you use OneFileCMS by putting this in your footer:

    -
    This site powered by <a href="http://onefilecms.com/">OneFileCMS</a>.
    +
    This site managed with <a href="http://onefilecms.com/">OneFileCMS</a>.
    +

    Admin Link

    Add this to your footer (or something) for lazy/forgetful admins. They'll still have to know the username and password, of course.

    [<a href="">Admin</a>]
    - -

    Password Hash

    -

    By the way, MD5 hash of your currently configured password is: - -

    @@ -551,7 +552,7 @@ function Cancel_Submit_Buttons($button_label) { var $message = $("#message"), $save_file = $("#save_file"); - if ( $message.length > 0 ) { $message.animate({opacity: 1.0}, 3000).fadeOut(); }; + //if ( $message.length > 0 ) { $message.animate({opacity: 1.0}, 3000).fadeOut(); }; $(".button:visible:enabled:first").focus(); $(".textinput:visible:enabled:first").focus(); From 90b4e6d26908f35f703179b361bf7499a3712d21 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Tue, 10 Apr 2012 20:55:02 -0400 Subject: [PATCH 021/228] Added config variables and improved check for local .css --- onefilecms.php | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 4fb235e..c59e684 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,20 +1,28 @@ OneFileCMS."; $config_disabled = "bmp,ico,gif,jpg,png,psd,zip"; $config_excluded = "onefilecms.php,favicon,.htaccess"; -$config_localcss = "onefilecms.css"; +$config_csslocal = "_onefilecms/onefilecms.css"; //Relative to site URL root. Don't use leading '/'. +$config_csshosted = "http://self-evident.github.com/OneFileCMS/onefilecms.css"; + + + + +//Allows OneFileCMS.php to be started from any dir on the site. +chdir($_SERVER["DOCUMENT_ROOT"]); + -if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; /***********************************************************************/ function Cancel_Submit_Buttons($button_label) { @@ -208,19 +216,25 @@ function Cancel_Submit_Buttons($button_label) { ?> + + -<?php echo $config_title; ?> - <?php echo $pagetitle; ?> -" type="text/css" rel="stylesheet" media="screen" /> + +<?php echo $config_title.' - '.$pagetitle; ?> + + + + + +
    From 78482baa1ebf807f495b11bd83e15493040cb323 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Tue, 10 Apr 2012 22:28:32 -0400 Subject: [PATCH 022/228] Added a couple Edit disabled file types. Ck for local jquery. Code formating. --- onefilecms.php | 148 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 106 insertions(+), 42 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index c59e684..37e4ae2 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -4,19 +4,20 @@ if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; // CONFIGURATION INFO -$version = "1.1.7.BETA"; // ONEFILECMS_BEGIN -$ONESCRIPT = $_SERVER["SCRIPT_NAME"]; -$config_username = "username"; -$config_password = "password"; +$version = "1.1.7.BETA"; // ONEFILECMS_BEGIN +$ONESCRIPT = $_SERVER["SCRIPT_NAME"]; +$config_username = "username"; +$config_password = "password"; //$config_hint = ""; //Not currently used -$config_title = "OneFileCMS"; -$config_footer = date("Y")." OneFileCMS."; -$config_disabled = "bmp,ico,gif,jpg,png,psd,zip"; -$config_excluded = "onefilecms.php,favicon,.htaccess"; -$config_csslocal = "_onefilecms/onefilecms.css"; //Relative to site URL root. Don't use leading '/'. +$config_title = "OneFileCMS"; +$config_footer = date("Y")." OneFileCMS."; +$config_disabled = "bmp,ico,gif,jpg,png,psd,zip,exe,swf"; +$config_excluded = "onefilecms.php,favicon,.htaccess"; +$config_LOCAL = "_onefilecms/"; //local directory for icons, .css, .js, etc... +$config_csslocal = $config_LOCAL."onefilecms.css"; //Relative to site URL root. Don't use leading '/'. $config_csshosted = "http://self-evident.github.com/OneFileCMS/onefilecms.css"; - - +$config_JQlocal = $config_LOCAL."jquery.min.js"; +$config_JQhosted = "http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"; //Allows OneFileCMS.php to be started from any dir on the site. @@ -24,7 +25,7 @@ -/***********************************************************************/ +//****************************************************************************** function Cancel_Submit_Buttons($button_label) { global $ONESCRIPT, $varvar; @@ -50,10 +51,10 @@ function Cancel_Submit_Buttons($button_label) {

    $value) { $_GET[$name] = htmlentities($value); } -// COPY FILE + + +// COPY FILE ******************************************************************* if (isset($_GET["c"])) { $filename = $_GET["c"]; $pagetitle = "Copy “".$filename."”"; $page = "copy"; } @@ -102,7 +107,9 @@ function Cancel_Submit_Buttons($button_label) { $message = $old_filename." copied successfully to ".$filename."."; } -// DELETE FILE + + +// DELETE FILE ***************************************************************** if (isset($_GET["d"])) { $filename = $_GET["d"]; $pagetitle = "Delete “".$filename."”"; @@ -114,7 +121,9 @@ function Cancel_Submit_Buttons($button_label) { $message = $filename." successfully deleted."; } -// DELETE FOLDER + + +// DELETE FOLDER *************************************************************** if ($_GET["p"] == "deletefolder") { $pagetitle = "Delete Folder “".$_GET["i"]."”"; } @@ -127,7 +136,9 @@ function Cancel_Submit_Buttons($button_label) { } } -// EDIT + + +// EDIT ************************************************************************ if (isset($_POST["filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { $filename = $_POST["filename"]; $content = stripslashes($_POST["content"]); @@ -155,7 +166,10 @@ function Cancel_Submit_Buttons($button_label) { $message = "File does not exist."; } } -// NEW FILE + + + +// 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"]; @@ -167,7 +181,10 @@ function Cancel_Submit_Buttons($button_label) { $message = $filename." created successfully."; } } -// NEW FOLDER + + + +// NEW FOLDER ****************************************************************** if ($_GET["p"] == "folder") {$pagetitle = "New Folder"; } if (isset($_POST["new_folder"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { $foldername = $_POST["new_folder"]; @@ -178,7 +195,10 @@ function Cancel_Submit_Buttons($button_label) { $message = "A folder by that name already exists."; } } -// RENAME FILE + + + +// RENAME FILE ***************************************************************** if (isset($_GET["r"])) { $filename = $_GET["r"]; $pagetitle = "Rename “".$filename."”"; @@ -190,7 +210,10 @@ function Cancel_Submit_Buttons($button_label) { rename($old_filename, $filename); $message = $old_filename." successfully renamed to ".$filename."."; } -// RENAME FOLDER + + + +// RENAME FOLDER *************************************************************** if ($_GET["p"] == "renamefolder") {$pagetitle = "Rename Folder “".$_GET["i"]."”"; } if (isset($_POST["rename_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { $old_foldername = $_POST["old_foldername"]; @@ -201,7 +224,10 @@ function Cancel_Submit_Buttons($button_label) { $message = "There was an error. Try again and/or contact your admin."; } } -// UPLOAD FILE + + + +// 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']; @@ -214,6 +240,8 @@ function Cancel_Submit_Buttons($button_label) { } } + +//****************************************************************************** ?> @@ -255,7 +283,9 @@ function Cancel_Submit_Buttons($button_label) {

    Delete “

    @@ -292,7 +324,9 @@ function Cancel_Submit_Buttons($button_label) {

    Delete Folder “

    @@ -307,7 +341,9 @@ function Cancel_Submit_Buttons($button_label) {

    Edit “

    @@ -341,9 +377,13 @@ function Cancel_Submit_Buttons($button_label) {
    + if (isset($_GET["i"])) { $varvar = $_GET["i"]."/"; } ?> + +

    +

    ?i=" class="folder">

    + +
    - - + - \ No newline at end of file + From 81afb0a71fd37e947e3b8e74f0bd9e71db38c738 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Wed, 11 Apr 2012 01:21:08 -0400 Subject: [PATCH 023/228] Formated/added spacing & "//comments **********" to improve readability. Fixed link for "root/path/file.ext" on Edit, Delete, Copy, Rename File pages (It wasn't working after implemented "chdir(DOCUMENT_ROOT)" $filename in $messages Tweaked wording on Other page a bit. --- onefilecms.css | 7 +++-- onefilecms.php | 83 +++++++++++++++++++++++++++++--------------------- 2 files changed, 52 insertions(+), 38 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index ffa8434..e27f62a 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -224,7 +224,7 @@ form .meta { z-index: -1; } border: 1px solid #807568; padding: 2px; width: 650px; - font: 12px/18px "Courier New", Courier, monospace; + font: 1.3em "Courier New", Courier, monospace; } textarea.textinput { @@ -272,8 +272,8 @@ h1 a:visited { color: #0F0901; } .nav { float : right; display : inline-block; - margin-top: 1.2em; - font-size : 1em; + margin-top: .8em; + font-size : 1.2em; } .nav a { @@ -323,6 +323,7 @@ h1 a:visited { color: #0F0901; } .path:hover { border: 1px solid #807568; background-color: #fffbce; } +/* --- --- --- */ hr { line-height : 0; font-size : 1px; diff --git a/onefilecms.php b/onefilecms.php index 37e4ae2..87dface 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -12,7 +12,7 @@ $config_title = "OneFileCMS"; $config_footer = date("Y")." OneFileCMS."; $config_disabled = "bmp,ico,gif,jpg,png,psd,zip,exe,swf"; -$config_excluded = "onefilecms.php,favicon,.htaccess"; +$config_excluded = ""; //files to exclude from directory listings $config_LOCAL = "_onefilecms/"; //local directory for icons, .css, .js, etc... $config_csslocal = $config_LOCAL."onefilecms.css"; //Relative to site URL root. Don't use leading '/'. $config_csshosted = "http://self-evident.github.com/OneFileCMS/onefilecms.css"; @@ -104,7 +104,7 @@ function Cancel_Submit_Buttons($button_label) { $old_filename = $_POST["old_filename"]; $filename = $_POST["copy_filename"]; copy($old_filename, $filename); - $message = $old_filename." copied successfully to ".$filename."."; + $message = ''.$old_filename." copied successfully to ".$filename."."; } @@ -118,7 +118,7 @@ function Cancel_Submit_Buttons($button_label) { if (isset($_POST["delete_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { $filename = $_POST["delete_filename"]; unlink($filename); - $message = $filename." successfully deleted."; + $message = ''.$filename." successfully deleted."; } @@ -130,7 +130,7 @@ function Cancel_Submit_Buttons($button_label) { if (isset($_POST["delete_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { $foldername = $_POST["delete_foldername"]; if (@rmdir($foldername)) { - $message = $foldername." successfully deleted."; + $message = ''.$foldername." successfully deleted."; } else { $message = "That folder is not empty."; } @@ -147,7 +147,7 @@ function Cancel_Submit_Buttons($button_label) { fwrite($fp, $content); fclose($fp); } - $message = $filename." saved successfully."; + $message = ''.$filename." saved successfully."; } if (isset($_GET["f"])) { $filename = stripslashes($_GET["f"]); @@ -174,11 +174,11 @@ function Cancel_Submit_Buttons($button_label) { 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."; + $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."; + $message = ''.$filename." created successfully."; } } @@ -190,7 +190,7 @@ function Cancel_Submit_Buttons($button_label) { $foldername = $_POST["new_folder"]; if (!is_dir($foldername)) { mkdir($foldername); - $message = $foldername." created successfully."; + $message = ''.$foldername." created successfully."; } else { $message = "A folder by that name already exists."; } @@ -208,7 +208,7 @@ function Cancel_Submit_Buttons($button_label) { $old_filename = $_POST["old_filename"]; $filename = $_POST["rename_filename"]; rename($old_filename, $filename); - $message = $old_filename." successfully renamed to ".$filename."."; + $message = ''.$old_filename." successfully renamed to ".$filename."."; } @@ -219,7 +219,7 @@ function Cancel_Submit_Buttons($button_label) { $old_foldername = $_POST["old_foldername"]; $foldername = $_POST["rename_foldername"]; if (rename($old_foldername, $foldername)) { - $message = $old_foldername." unsuccessfully renamed to ".$foldername."."; + $message = ''.$old_foldername." unsuccessfully renamed to ".$foldername."."; } else { $message = "There was an error. Try again and/or contact your admin."; } @@ -234,13 +234,14 @@ function Cancel_Submit_Buttons($button_label) { $destination = $_POST["upload_destination"]; if(move_uploaded_file($_FILES['upload_filename']['tmp_name'], $destination.basename($filename))) { - $message = basename($filename)." uploaded successfully to ".$destination."."; + $message = ''.basename($filename)." uploaded successfully to ".$destination."."; } else{ $message = "There was an error. Try again and/or contact your admin."; } } + //****************************************************************************** ?> @@ -281,7 +282,7 @@ function Cancel_Submit_Buttons($button_label) {
    -

    '.$message.'

    '; }; @@ -290,7 +291,7 @@ function Cancel_Submit_Buttons($button_label) { $extension = strrchr($filename, "."); $slug = substr($filename, 0, strlen($filename) - strlen($extension)); $varvar = "?i=".substr($_GET["c"],0,strrpos($_GET["c"],"/")); ?> -

    Copy “

    +

    Copy “

    Existing files with the same filename are automatically overwritten... Be careful!

    @@ -312,8 +313,10 @@ function Cancel_Submit_Buttons($button_label) { // DELETE FILE ***************************************************************** if ($page == "delete") { $varvar = "?i=".substr($_GET["d"],0,strrpos($_GET["d"],"/")); ?> -

    Delete “

    +

    Delete “ +

    Are you sure?

    +

    @@ -345,8 +348,12 @@ function Cancel_Submit_Buttons($button_label) { // EDIT ************************************************************************ if ($page == "edit") { ?> -

    Edit “

    - +

    Edit “ + + +

    + + '" /> - - - - '" /> + + + + '" />

    File Size: kb - Last Updated:

    @@ -408,8 +415,8 @@ function Cancel_Submit_Buttons($button_label) { $files = glob($varvar."*",GLOB_ONLYDIR); sort($files); foreach ($files as $file) { ?> - - + '.basename($file).''; + } ?>

    @@ -439,25 +446,29 @@ function Cancel_Submit_Buttons($button_label) { if (strrpos($lfile,".css")) { $file_class = "css"; }; if (strrpos($lfile,".php")) { $file_class = "php"; }; ?>
  • - '; echo basename($file); ?>
    - File Size: kb
    - Last Updated: + File Size: + kb
    + Last Updated: +
  • Check for Updates

    You are using version .
    - Future versions of OneFileCMS may have a one-click upgrade process. For now, though, you have to >click this link<.

    + Future versions of OneFileCMS may have a one-click upgrade process. + For now, though,>check here< for current versions.

    Want some good Karma?

    Let people know you use OneFileCMS by putting this in your footer:

    @@ -550,7 +562,7 @@ function Cancel_Submit_Buttons($button_label) { // RENAME FILE ***************************************************************** if ($page == "rename") { $varvar = "?i=".substr($_GET["r"],0,strrpos($_GET["r"],"/")); ?> -

    Rename “Rename “

    Existing files with the same filename are automatically overwritten... Be careful!

    @@ -632,6 +644,7 @@ function Cancel_Submit_Buttons($button_label) { var $message = $("#message"), $save_file = $("#save_file"); + //This line fades out the message after specified time (3000 = 3 seconds) //if ( $message.length > 0 ) { $message.animate({opacity: 1.0}, 3000).fadeOut(); }; $(".button:visible:enabled:first").focus(); From 18c4ef715dbb7059f81e95b95d500024ae4803e6 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Thu, 12 Apr 2012 22:11:13 -0400 Subject: [PATCH 024/228] Improved path/to/current/folder/ breadcrumb links. --- onefilecms.css | 13 ++++++++++++- onefilecms.php | 50 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 19 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index e27f62a..fa00570 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -1,5 +1,10 @@ -/* --- reset --- */ + + + + + +/* --- reset --- */ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big, cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li, fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{border:0;outline:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;margin:0;padding:0;} @@ -46,6 +51,12 @@ body { clear: both; ****************/ } + + + + + + /* --- general formatting --- */ h2,h3,p,ul,table { margin-bottom: 10px; } diff --git a/onefilecms.php b/onefilecms.php index 87dface..c82d81c 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,6 +1,9 @@ -
    - ', $config_title; ?> @@ -282,6 +283,7 @@ function Cancel_Submit_Buttons($button_label) {
    +

    '.$message.'

    '; }; @@ -387,39 +389,48 @@ function Cancel_Submit_Buttons($button_label) { // INDEX *********************************************************************** -if ($page == "index") { $varvar = ""; - if (isset($_GET["i"])) { $varvar = $_GET["i"]."/"; } ?> +if ($page == "index") { + $varvar = ""; + if (isset($_GET["i"])) { $varvar = $_GET["i"]."/"; } + + // 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"]; } - -

    '.$path_levels[0].' /'; } - $current_path = ""; - for ($x=1; $x < $levels-1; $x++) { + + //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].' /'; + echo ' '.$path_levels[$x]." /"; } - echo ' '.$path_levels[$x].' /'; // last item is current dir. No link needed. ?>

    +

    - '.basename($file).''; + foreach ($files as $file) { + echo ''.basename($file).''; } ?>

    - + +
    + +
    From 7896d929cee4d6feb8f73f0e5d3fb9e5e5dac9bd Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Thu, 12 Apr 2012 22:24:59 -0400 Subject: [PATCH 025/228] Added license & copyright info. --- OneFileCMS.License.BSD.txt | 29 +++++++++++++++++++++++++++++ OneFileCMS.License.MIT.txt | 22 ++++++++++++++++++++++ onefilecms.css | 8 ++++---- onefilecms.php | 6 +++--- 4 files changed, 58 insertions(+), 7 deletions(-) create mode 100755 OneFileCMS.License.BSD.txt create mode 100755 OneFileCMS.License.MIT.txt diff --git a/OneFileCMS.License.BSD.txt b/OneFileCMS.License.BSD.txt new file mode 100755 index 0000000..c33a683 --- /dev/null +++ b/OneFileCMS.License.BSD.txt @@ -0,0 +1,29 @@ +OneFileCMS + +Copyright 2009-2012 https://github.com/rocktronica +Copyright 2012- https://github.com/Self-Evident David W. Gay + +(Based on the BSD new/3-clause license) + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the author or copyright holder, nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/OneFileCMS.License.MIT.txt b/OneFileCMS.License.MIT.txt new file mode 100755 index 0000000..d9e8e69 --- /dev/null +++ b/OneFileCMS.License.MIT.txt @@ -0,0 +1,22 @@ +OneFileCMS + +Copyright © 2009-2012 https://github.com/rocktronica +Copyright © 2012- https://github.com/Self-Evident David W. Gay + +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. diff --git a/onefilecms.css b/onefilecms.css index fa00570..640f9df 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -1,7 +1,7 @@ - - - - +/* OneFileCMS - http://onefilecms.com/ + * + * For license & copyright info, see OneFileCMS.License.BSD.txt + */ /* --- reset --- */ diff --git a/onefilecms.php b/onefilecms.php index c82d81c..ec7d085 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@
    From baa3dbe5840423037d64fb9fe8da61ad7202014c Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Thu, 12 Apr 2012 22:36:07 -0400 Subject: [PATCH 026/228] Version 1.1.7 --- onefilecms.css | 14 +++++++------- onefilecms.php | 6 ++++-- readme.markdown | 4 ++++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index 640f9df..8415d33 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -1,5 +1,5 @@ /* OneFileCMS - http://onefilecms.com/ - * + * Version 1.1.7 * For license & copyright info, see OneFileCMS.License.BSD.txt */ @@ -44,17 +44,17 @@ body { #logo {font-family: 'Trebuchet MS', sans-serif; font-size:2.9em; font-weight: bold; color: black;} -.footer { /************************ +.footer { + color: #777; + /***************** margin-top: 10px; padding-top: 10px; border-top: 01px solid #807568; /*using
    . Styles at bottom of this file - clear: both; ****************/ + clear: both; + *****************/ } - - - - +.footer a{ color: rgb(157, 124, 83);} /*rgb(157, 124, 83)*/ /* --- general formatting --- */ diff --git a/onefilecms.php b/onefilecms.php index ec7d085..d4b56d3 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,13 +1,13 @@ + + diff --git a/readme.markdown b/readme.markdown index 7737d2d..fd8c9f9 100644 --- a/readme.markdown +++ b/readme.markdown @@ -80,6 +80,10 @@ It isn't entirely necessary, but it does nice little progressive enhancements li ## Change Log +### 1.1.7 + +- Added [Cancel] button to most screens. Numerous minor UI & code tweaks/improvements. Changed where .css is hosted (may change back later). Removed "Rendered in (microseconds)...". Added license info & copyright notice. + ### 1.1.6 - Breadcrumb navigation (courtesy of [Self-Evident](https://github.com/Self-Evident/)), CSS file and some minor changes to it
    From f079c93ae16c5aa5ebadc1f524f3fe4c7c6b83b1 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Wed, 18 Apr 2012 01:31:16 -0400 Subject: [PATCH 027/228] Added notes regarding future changes/improvements. --- readme.markdown | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/readme.markdown b/readme.markdown index fd8c9f9..17649be 100644 --- a/readme.markdown +++ b/readme.markdown @@ -142,4 +142,17 @@ Written in PHP, XHTML, CSS, and [jQuery](http://jquery.com/). Icons by [famfamfa Available under the MIT and BSD license. -To report a bug or request a feature, please file an issue via Github. Forks encouraged! \ No newline at end of file +To report a bug or request a feature, please file an issue via Github. Forks encouraged! + +##Needed/potential/upcoming improvements + +- Prompt to prevent automatic overwrite when uploading or renaming files. +- Check size of file to upload, verify under max post/upload limits. +- Option to switch between original OneFileCMS view and a common list view. + (in the works) +- Embed css and remove or swtich to svg icons to create a true "OneFileCMS" + (in the works) +- Remove use of jquery. + Used to detect if file being edited, set focus form fields, (more?) + (in the works) +- Multiple login names From adb3f40ac64a54da66aef17ad68518b25416d525 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Wed, 18 Apr 2012 01:49:42 -0400 Subject: [PATCH 028/228] Cleared .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index b1dd607..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +0,0 @@ -onefilecms2.esproj \ No newline at end of file From bf2070a6385eca88092a8b071b27555cee82a7bd Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Fri, 20 Apr 2012 13:36:05 -0400 Subject: [PATCH 029/228] Removed "Other" page. Some minor code formatting. --- onefilecms.php | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index d4b56d3..6946764 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -76,7 +76,7 @@ function Cancel_Submit_Buttons($button_label) { // redirect on invalid page attempts $page = $_GET["p"]; if (!in_array(strtolower($_GET["p"]), array( - "copy","delete","error","deletefolder","edit","folder","index","login","logout","new","other","rename","renamefolder","upload" ))) + "copy","delete","error","deletefolder","edit","folder","index","login","logout","new","rename","renamefolder","upload" ))) { header("Location: ".$ONESCRIPT); $page = "index"; @@ -84,7 +84,6 @@ function Cancel_Submit_Buttons($button_label) { } if ( ($page == "login") and ($_SESSION['onefilecms_valid']) ) {$page = "index"; header("Location: ".$ONESCRIPT);}; -if ($_GET["p"] == "other") {$pagetitle = "Other"; } if ($_GET["p"] == "login") {$pagetitle = "Log In"; } if ($_GET["p"] == "logout") {$pagetitle = "Log Out"; $_SESSION['onefilecms_valid'] = "0"; session_destroy(); } if ($_GET["i"] == "") { unset($_GET["i"]); } @@ -482,7 +481,6 @@ function Cancel_Submit_Buttons($button_label) { Rename Folder - Other

    -

    Other

    - -

    Check for Updates

    -

    You are using version .
    - Future versions of OneFileCMS may have a one-click upgrade process. - For now, though,>check here< for current versions.

    - -

    Want some good Karma?

    -

    Let people know you use OneFileCMS by putting this in your footer:

    -
    This site managed with <a href="http://onefilecms.com/">OneFileCMS</a>.
    - -

    Admin Link

    -

    Add this to your footer (or something) for lazy/forgetful admins. They'll still have to know the username and password, of course.

    -
    [<a href="">Admin</a>]
    - -

    Rename “

    +

    Rename “ +

    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 @@ -622,8 +601,7 @@ function Cancel_Submit_Buttons($button_label) { if ($page == "upload") { $varvar = ""; if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; } ?>

    Upload

    - " method="post"> + " method="post">

    From 0bb9b952a16e88b5084e66cc0feb868d9f72980f Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Fri, 20 Apr 2012 13:47:25 -0400 Subject: [PATCH 030/228] Added [Close] button function. Used on Edit page. Also, added / after folder names in list/ of/ folders/. --- onefilecms.php | 51 +++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 6946764..8a61857 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -29,31 +29,34 @@ //****************************************************************************** +// Functions + +function Close_Button($classes) { + echo ''; +} + + function Cancel_Submit_Buttons($button_label) { global $ONESCRIPT, $varvar; // [Cancel] returns to either the current/path, or current/path/file - if (isset($_GET["i"])){ - $ipath = '?i='.rtrim($_GET["i"],"/"); - - }else 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{ - $ipath = rtrim($varvar,"/"); - }//end if -?> + if (isset($_GET["i"])){ $ipath = '?i='.rtrim($_GET["i"],"/"); } + else 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{ $ipath = rtrim($varvar,"/"); + }//end if/else if + + ?>

    - +

    -” - '" /> + @@ -376,10 +379,11 @@ function Cancel_Submit_Buttons($button_label) { - '" /> +

    -

    File Size: kb - - Last Updated:

    +

    File Size:   –   + Updated: +

    @@ -424,11 +428,12 @@ function Cancel_Submit_Buttons($button_label) { $files = glob($varvar."*",GLOB_ONLYDIR); sort($files); foreach ($files as $file) { - echo ''.basename($file).''; + echo ''.basename($file).' /'; } ?>

    +
      From a3839e1bef82133c02c9cbd1c2a4104d708bd2a9 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 20 Apr 2012 16:51:05 -0400 Subject: [PATCH 031/228] switched to generic custom icons. Also, added a couple file types/ icons cleared/emptied footer removed cookie reference (wasn't used) tweaked some styles Some code (css & php) formatting --- onefilecms.css | 295 ++++++++++++++++++++++++++++--------------------- onefilecms.php | 17 +-- 2 files changed, 180 insertions(+), 132 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index 8415d33..c5c1645 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -4,48 +4,77 @@ */ +/* #774200 #807568 #976322 #995400 #d4d4d4 #0F0901 + rgb(157, 124, 83) rgb(157, 124, 83) + */ + /* --- reset --- */ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big, cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li, -fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{border:0;outline:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;margin:0;padding:0;} +fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td + { + border : 0; + outline: 0; + margin : 0; + padding: 0; + font-weight: inherit; + font-style : inherit; + font-size : 100%; + font-family: inherit; + vertical-align: baseline; + } + :focus{outline:0;} + ol,ul{list-style:none;} + table{border-collapse:separate;border-spacing:0;} + caption,th,td{text-align:left;font-weight:400;} + blockquote:before,blockquote:after,q:before,q:after{content:"";} blockquote,q{quotes:"" "";} + div{position: relative;} + h1,h2,h3,h4,h5,h6{font-weight: bold;} body { - font-size: 12px; - line-height: 20px; + font-size: 1em; background: #d5d0cc; font-family: sans-serif; - color: #0F0901; -} + } + /* --- layout --- */ .container { - width: 800px; - padding: 0 10px; - margin: 20px auto; -} + border : 0px solid #807568; + width : 810px; + margin : 0em auto; + } + .header { - margin-bottom: 1em; padding-bottom: .9em; - border-bottom: 1px solid #807568; /*using
      . Styles at bottom of this file*/ - color: #676767; - position: relative; -} + border-bottom : 1px solid #807568; + padding: 04px 0px 04px 0px; + margin : 0; + margin-bottom : .5em; + } -#logo {font-family: 'Trebuchet MS', sans-serif; font-size:2.9em; font-weight: bold; color: black;} +#logo { + font-family: 'Trebuchet MS', sans-serif; + font-size:2.2em; + font-weight: bold; + color: black; + padding: .1em; + } .footer { color: #777; + font-size: .7em; /***************** margin-top: 10px; padding-top: 10px; @@ -60,22 +89,35 @@ body { /* --- general formatting --- */ h2,h3,p,ul,table { margin-bottom: 10px; } -p, li {line-height: 1.4em; } + +Xp, li {line-height: 1.4em; } + form p { margin-bottom: 5px; } -a { color: #774200; text-decoration: none; border: 1px solid transparent; } -a:hover { color: #976322; } -a:hover { color: #995400; border: 1px solid #807568; background-color: #fffbce; } + +a { border: 1px solid transparent; color: rgb(100,45,0); text-decoration: none; } + +a:hover { + border: 1px solid #807568; + Xcolor: #995400; + background-color: #fffbce; + } + h2 { font-size: 20px; } + h3 { font-size: 18px; margin-top: 15px; } + +h4 { font-size: 1.3em; margin-bottom: .2em; font-weight: normal;} + em, i { font-style: italic; } + strong { font-weight: bold; } label { - font-size: 14px; - font-style: italic; - width: 110px; display: inline-block; -} + width : 7em; + font-size : 14px; + font-style: italic; + } pre { background: white; @@ -86,35 +128,39 @@ pre { padding: 10px; margin: 5px 0 10px 0; overflow: hidden; -} + } .page_login label { display: block; margin-bottom: 2px; -} + } .alignleft { margin: 0 10px 10px 0; float: left; -} + } .left70 { width: 70px; display: inline-block; -} + } #message { - margin-bottom: 10px; - padding-bottom: 10px; - border-bottom: 1px solid #807568; -} + margin-bottom: .5em; + Xpadding-bottom: 10px; + Xborder-bottom : 1px solid #807568; + } -#message p {font-size: 1.3em; +#message p { margin: 0; padding: 5px 5px 5px 30px; border: 1px solid #807568; - background: #fff000 url("http://self-evident.github.com/OneFileCMS/images/silk_error.png") 10px 5px no-repeat; -} + font-family: Lucida Console, "Courier New" ; + font-size: .95em; + line-height: 1em; + background: #fff000; + } + /* --- INDEX --- */ @@ -125,7 +171,7 @@ pre { width: 192.5px; float: left; position: relative; -} + } .index a { height: 28px; @@ -133,20 +179,39 @@ pre { padding: 7px 5px 7px 35px; border: 1px solid #807568; text-decoration: none; - background: white url("http://self-evident.github.com/OneFileCMS/images/silk_file.png") 10px 10px no-repeat; + background: white url("http://self-evident.github.com/OneFileCMS/images/file-2.png") 10px 10px no-repeat; overflow: hidden; line-height: 1em; -} + } -.index a.css { background: white url("http://self-evident.github.com/OneFileCMS/images/silk_css.png") 10px 10px no-repeat; } -.index a.img { background: white url("http://self-evident.github.com/OneFileCMS/images/silk_image.png") 10px 10px no-repeat; } -.index a.php { background: white url("http://self-evident.github.com/OneFileCMS/images/silk_php.png") 10px 10px no-repeat; } +.index a.css { background: white url("http://self-evident.github.com/OneFileCMS/images/file-2s.png") 10px 10px no-repeat; } +.index a.img { background: white url("http://self-evident.github.com/OneFileCMS/images/img-2.png") 10px 10px no-repeat; } +.index a.php { background: white url("http://self-evident.github.com/OneFileCMS/images/file-2p.png") 10px 10px no-repeat; } .index a:hover { background-color: #fffbce; border: 1px solid #969376; -} + } + + +/* File size & date */ + +.meta_size { + Xwidth : 9em; + padding-left : 1em; + padding-right : .5em; + text-align : right; + font-size : .8em; color: #333; + } + +.meta_time { + width : 12em; + padding-right : .5em; + text-align : right; + font-size : .8em; color: #333; + } + .index .meta { font-size: 11px; @@ -154,94 +219,69 @@ pre { margin-top: 3px; overflow: hidden; line-height: 1.1em; -} -.index_folders { min-height: 2em; } -.index_folders a { - display: inline-block; - font-size: 16px; - margin-right: 15px; - padding: 2px 4px 2px 20px; - display: inline-block; - background: url("http://self-evident.github.com/OneFileCMS/images/silk_folder.png") 0 2px no-repeat; -} -.index_folders a:hover { background-color: #fffbce; } -/* --- list view --- */ - -ul.list { - width: 100%; - margin-bottom: 31px; -} - -ul.index.list * { - width: auto; - height: auto; - padding: 0; - margin: 0; - display: visible; - line-height: 21px; -} + } + -ul.index.list li { - float: none; - clear: both; -} -ul.index.list li a { - display: block; - float: left; - background-color: transparent; - background-position: top left; - border: none; - width: 200px; - text-indent: 26px; -} +.index_folders { + min-height: 1.4em; + margin-bottom: .2em + } -ul.list .meta { - display: block; - float: left; - height: auto; -} +.index_folders a { Xborder: 1px solid black; + display : inline-block; + line-height : 1.1em; + font-size : 1em; + margin-right : .6em; + padding : 2px 4px 2px 20px; + padding-left : 25px; + padding-right: .5em; + padding-top : .1em; + padding-bottom : .1em; + background : url("http://self-evident.github.com/OneFileCMS/images/folder-2.png") 4px 3px no-repeat; + } -ul.list .meta br { display: none; } +.index_folders a:hover { background-color: #fffbce; } -ul.list .meta span { - display: block; - float: left; - width: 200px; -} +/* [Upload File] [New File] [New Folder] etc... */ .front_links { clear: both; } -.front_links a { padding: 3px; +.front_links a { + border: 1px solid #807568; font-size: 16px; margin-right: 15px; - padding-left: 21px; + padding: 3px 5px 5px 21px; /*T R B L*/ height: 16px; display: inline-block; -} + } + +.front_links a.upload { background: url("http://self-evident.github.com/OneFileCMS/images/upload.png") 3px 3px no-repeat; } +.front_links a.new { background: url("http://self-evident.github.com/OneFileCMS/images/file-new-2.png") 3px 4px no-repeat; } +.front_links a.newfolder { background: url("http://self-evident.github.com/OneFileCMS/images/folder-new-2.png") 2px 5px no-repeat; } +.front_links a.renamefolder { background: url("http://self-evident.github.com/OneFileCMS/images/folder-rename-1.png") 1px 4px no-repeat; } +.front_links a.deletefolder { background: url("http://self-evident.github.com/OneFileCMS/images/folder-del-3.png") 1px 5px no-repeat; } +.front_links a.settings { background: url("http://self-evident.github.com/OneFileCMS/images/settings.png") 2px 3px no-repeat; } + +.front_links a:hover { border: 1px solid #807568; background-color: #fffbce; } -.front_links a.settings { background: url("http://self-evident.github.com/OneFileCMS/images/silk_settings.png") 0 3px no-repeat; } -.front_links a.new { background: url("http://self-evident.github.com/OneFileCMS/images/silk_new.png") 0 3px no-repeat; } -.front_links a.newfolder { background: url("http://self-evident.github.com/OneFileCMS/images/silk_newfolder.png") 0 2px no-repeat; } -.front_links a.deletefolder { background: url("http://self-evident.github.com/OneFileCMS/images/silk_deletefolder.png") 0 2px no-repeat; } -.front_links a.renamefolder { background: url("http://self-evident.github.com/OneFileCMS/images/silk_renamefolder.png") 0 2px no-repeat; } -.front_links a.upload { background: url("http://self-evident.github.com/OneFileCMS/images/silk_upload.png") 0 3px no-repeat; } -.front_links a.other { background: url("http://self-evident.github.com/OneFileCMS/images/silk_other.png") 0 3px no-repeat; } -.front_links a:hover { border: 1px solid #807568; background-color: #fffbce; } form .meta { z-index: -1; } .textinput { border: 1px solid #807568; padding: 2px; width: 650px; - font: 1.3em "Courier New", Courier, monospace; -} + font: 1em "Courier New", Courier, monospace; + } textarea.textinput { - width: 794px; - height: 550px; -} + font : 1em "Courier New", Courier, monospace; + margin: 0 0 .5em 0; /*T R B L*/ + width : 99.5%; + height: 30em; + height: 30em; + } textarea.disabled { height: 50px; } @@ -257,34 +297,22 @@ textarea.disabled { height: 50px; } cursor: pointer; font-size: 14px; font-family: sans-serif; -} + } .button:hover { background-color: #eaeaea; } .button[disabled]:hover { background-color: #d4d4d4; } -/* --- header --- */ -h1 a { - font-size: 28px; - text-decoration: none; - color: #0F0901; -} +#action {color: white; background-color: rgb(235,70,70); font-weight: 700;} -h1 a.onefilecms { - background: url("http://self-evident.github.com/OneFileCMS/images/logo.gif") top left no-repeat; - width: 208px; - height: 29px; - display: block; - text-indent: -2000px; -} -h1 a:visited { color: #0F0901; } +/* --- header --- */ .nav { float : right; display : inline-block; - margin-top: .8em; - font-size : 1.2em; + margin-top: 1.6em; + font-size : 1em; } .nav a { @@ -300,6 +328,23 @@ h1 a:visited { color: #0F0901; } .nav a:hover {border: 01px solid #807568;} +h1 a { + font-size: 28px; + text-decoration: none; + color: #0F0901; + } + +h1 a.onefilecms { + width: 208px; + height: 29px; + display: block; + text-indent: -2000px; + } + +h1 a:visited { color: #0F0901; } + + + /* --- edit --- */ #edit_header {float: left;} @@ -322,7 +367,7 @@ h1 a:visited { color: #0F0901; } border : 1px solid #807568; padding : 2px 0px 2px 2px; width : 356px; - font : 1.3em Courier; + font : 1em Courier; } diff --git a/onefilecms.php b/onefilecms.php index 8a61857..6552db3 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -14,6 +14,7 @@ //$config_hint = ""; //Not currently used $config_title = "OneFileCMS"; $config_footer = date("Y")." OneFileCMS."; + $config_disabled = "bmp,ico,gif,jpg,png,psd,zip,exe,swf"; $config_excluded = ""; //files to exclude from directory listings $config_LOCAL = "_onefilecms/"; //local directory for icons, .css, .js, etc... @@ -436,7 +437,7 @@ function Cancel_Submit_Buttons($button_label) {
      -
        +
          + if (strrpos($lfile,".php")) { $file_class = "php"; }; + if (strrpos($lfile,".htm")) { $file_class = "htm"; }; + if (strrpos($lfile,".html")) { $file_class = "htm"; }; + ?>
        • '; echo basename($file); ?> @@ -524,8 +528,7 @@ function Cancel_Submit_Buttons($button_label) { if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; }?>

          New File

          Existing files with the same name will not be overwritten.

          -
          "> + ">

          @@ -559,8 +562,7 @@ function Cancel_Submit_Buttons($button_label) { // RENAME FILE ***************************************************************** if ($page == "rename") { $varvar = "?i=".substr($_GET["r"],0,strrpos($_GET["r"],"/")); ?> -

          Rename “ -

          +

          Rename “

          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 @@ -624,7 +626,7 @@ function Cancel_Submit_Buttons($button_label) {

  • @@ -643,6 +645,7 @@ function Cancel_Submit_Buttons($button_label) { var $message = $("#message"), $save_file = $("#save_file"); + //This line fades out the message after specified time (3000 = 3 seconds) //if ( $message.length > 0 ) { $message.animate({opacity: 1.0}, 3000).fadeOut(); }; From 22a3afc502bfac25ad8c5f7025a4be3ae8a1a5c8 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sat, 21 Apr 2012 15:36:35 -0400 Subject: [PATCH 032/228] Changed $loadcontent to $filecontent. Seems more intuitive. --- onefilecms.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 6552db3..c9ff8eb 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -162,8 +162,8 @@ function Cancel_Submit_Buttons($button_label) { $pagetitle = "Edit “".$filename."”"; $fp = @fopen($filename, "r"); if (filesize($filename) !== 0) { - $loadcontent = fread($fp, filesize($filename)); - $loadcontent = htmlspecialchars($loadcontent); + $filecontent = fread($fp, filesize($filename)); + $filecontent = htmlspecialchars($filecontent); } fclose($fp); } else { @@ -372,7 +372,7 @@ function Cancel_Submit_Buttons($button_label) {

    - +

    From 3d1dcec7d7b978d4df86c4d7e9e6b86800dcf5e3 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sun, 22 Apr 2012 00:45:56 -0400 Subject: [PATCH 033/228] Corrected/improved handling of local -vs- hosted css... This will ultimately be for naught, once the CSS is embedded. But, I just can't leave well enought alone... --- onefilecms.php | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index c9ff8eb..5ef230d 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -6,6 +6,9 @@ if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; +$CWD = $CWD = str_replace("\\","/",getcwd()); +$DOC_ROOT = $_SERVER["DOCUMENT_ROOT"]; + // CONFIGURATION INFO $version = "1.1.7"; // ONEFILECMS_BEGIN $ONESCRIPT = $_SERVER["SCRIPT_NAME"]; @@ -14,18 +17,19 @@ //$config_hint = ""; //Not currently used $config_title = "OneFileCMS"; $config_footer = date("Y")." OneFileCMS."; - $config_disabled = "bmp,ico,gif,jpg,png,psd,zip,exe,swf"; $config_excluded = ""; //files to exclude from directory listings -$config_LOCAL = "_onefilecms/"; //local directory for icons, .css, .js, etc... -$config_csslocal = $config_LOCAL."onefilecms.css"; //Relative to site URL root. Don't use leading '/'. + +$config_LOCAL = "/onefilecms/"; //local directory for icons, .css, .js, etc... +$config_csslocal = "onefilecms.css"; //Relative to this file. +//$config_csslocal = $config_LOCAL."onefilecms.css"; //Relative to site URL root. $config_csshosted = "http://self-evident.github.com/OneFileCMS/onefilecms.css"; -$config_JQlocal = $config_LOCAL."jquery.min.js"; +$config_JQlocal = "jquery.min.js"; $config_JQhosted = "http://code.jquery.com/jquery-1.7.2.min.js"; //$config_JQhosted = "http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"; //Allows OneFileCMS.php to be started from any dir on the site. -chdir($_SERVER["DOCUMENT_ROOT"]); +chdir($DOC_ROOT); @@ -259,11 +263,19 @@ function Cancel_Submit_Buttons($button_label) { <?php echo $config_title.' - '.$pagetitle; ?> - + + @@ -634,9 +646,9 @@ function Cancel_Submit_Buttons($button_label) { From ac1d79dbf7b02dc485576b437b11d2052943618b Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sun, 22 Apr 2012 02:49:36 -0400 Subject: [PATCH 034/228] Switched from $config_disabled to $config_editable. And, of course, some minor code spacing/formatting in // Edit sections. --- onefilecms.php | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 5ef230d..976a147 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -17,12 +17,12 @@ //$config_hint = ""; //Not currently used $config_title = "OneFileCMS"; $config_footer = date("Y")." OneFileCMS."; -$config_disabled = "bmp,ico,gif,jpg,png,psd,zip,exe,swf"; +$config_editable = "html,htm,php,css,txt,text,conf,ini,csv"; $config_excluded = ""; //files to exclude from directory listings $config_LOCAL = "/onefilecms/"; //local directory for icons, .css, .js, etc... -$config_csslocal = "onefilecms.css"; //Relative to this file. -//$config_csslocal = $config_LOCAL."onefilecms.css"; //Relative to site URL root. +$config_csslocal = "onefilecms.css"; //Relative to this file. +//$config_csslocal ="/onefilecms.css"; //Relative to site URL root. $config_csshosted = "http://self-evident.github.com/OneFileCMS/onefilecms.css"; $config_JQlocal = "jquery.min.js"; $config_JQhosted = "http://code.jquery.com/jquery-1.7.2.min.js"; @@ -149,6 +149,8 @@ function Cancel_Submit_Buttons($button_label) { // EDIT ************************************************************************ + +//*** 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"]); @@ -158,7 +160,9 @@ function Cancel_Submit_Buttons($button_label) { fclose($fp); } $message = ''.$filename." saved successfully."; -} +}//*** + +//*** If in directory list, and a filename is clicked: if (isset($_GET["f"])) { $filename = stripslashes($_GET["f"]); if (file_exists($filename)) { @@ -175,7 +179,7 @@ function Cancel_Submit_Buttons($button_label) { unset ($filename); $message = "File does not exist."; } -} +}//*** @@ -252,6 +256,7 @@ function Cancel_Submit_Buttons($button_label) { +//****************************************************************************** //****************************************************************************** ?> @@ -365,23 +370,26 @@ function Cancel_Submit_Buttons($button_label) { // EDIT ************************************************************************ if ($page == "edit") { ?> -

    Edit “ - - +

    Edit “ +

    - + +

    - +

    +

    @@ -389,11 +397,12 @@ function Cancel_Submit_Buttons($button_label) {

    + -

    +

    File Size:   –   Updated:

    From 3e44c1a28d57fa977c9d27c2073c1c136b928a4d Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sun, 22 Apr 2012 10:03:28 -0400 Subject: [PATCH 035/228] in .css, added a couple file type icons; added styles for table list format Code to select table list format not yet in .php --- onefilecms.css | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index c5c1645..9254d56 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -41,7 +41,7 @@ h1,h2,h3,h4,h5,h6{font-weight: bold;} body { font-size: 1em; - background: #d5d0cc; + background: #d5d0cc; background: cyan; font-family: sans-serif; } @@ -179,15 +179,17 @@ pre { padding: 7px 5px 7px 35px; border: 1px solid #807568; text-decoration: none; - background: white url("http://self-evident.github.com/OneFileCMS/images/file-2.png") 10px 10px no-repeat; + background: white url("http://self-evident.github.com/OneFileCMS/images/binary-3.png") 10px 10px no-repeat; overflow: hidden; line-height: 1em; } +.index a.img { background: white url("http://self-evident.github.com/OneFileCMS/images/img-2.png") 10px 10px no-repeat; } +.index a.txt { background: white url("http://self-evident.github.com/OneFileCMS/images/file-2.png") 10px 10px no-repeat; } .index a.css { background: white url("http://self-evident.github.com/OneFileCMS/images/file-2s.png") 10px 10px no-repeat; } -.index a.img { background: white url("http://self-evident.github.com/OneFileCMS/images/img-2.png") 10px 10px no-repeat; } .index a.php { background: white url("http://self-evident.github.com/OneFileCMS/images/file-2p.png") 10px 10px no-repeat; } +.index a.htm { background: white url("http://self-evident.github.com/OneFileCMS/images/file-2h.png") 10px 10px no-repeat; } .index a:hover { background-color: #fffbce; @@ -195,6 +197,47 @@ pre { } +/* --- INDEX directory listing, table format --- */ +table.index_T { + min-width: 30em; + font-size: .95em; + border-style: outset; + border-width: 1px; + border-color: #807568; + border-collapse: collapse; + margin-bottom: .7em; + background-color:white; + } + +table.index_T td { + border-width: 1px; + border-color: silver; + border-style: inset; + vertical-align:middle; + } + +.index_T a { + height : 1em; + display: block; + padding: .2em 1em .3em 1.6em; + color: rgb(100,45,0); + border : none; + background : url("http://self-evident.github.com/OneFileCMS/images/binary-3.png") 3px no-repeat; + overflow : hidden; + } + +/* background : url("http://self-evident.github.com/OneFileCMS/images/silk_file.png") 4px no-repeat;*/ + +.index_T a.txt { background: url("http://self-evident.github.com/OneFileCMS/images/file-2.png") 3px no-repeat; } +.index_T a.htm { background: url("http://self-evident.github.com/OneFileCMS/images/file-2h.png") 3px no-repeat; } +.index_T a.css { background: url("http://self-evident.github.com/OneFileCMS/images/file-2s.png") 3px no-repeat; } +.index_T a.php { background: url("http://self-evident.github.com/OneFileCMS/images/file-2p.png") 3px no-repeat; } +.index_T a.cnf { background: url("http://self-evident.github.com/OneFileCMS/images/file-2.png") 3px no-repeat; } +.index_T a.img { background: url("http://self-evident.github.com/OneFileCMS/images/img-2.png") 3px no-repeat; } + +.index_T a:hover { background-color: #FFF573; } /*#fffbce #969376; rgb(255,245,115);*/ + + /* File size & date */ .meta_size { From c906d6db2d57230035ca59ca5a6cd11e42b0bad5 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sun, 22 Apr 2012 14:52:11 -0400 Subject: [PATCH 036/228] Improved how file type icons are determined & assigned. File size is now just in bytes, not kB --- onefilecms.css | 32 +++++++++++++++++--------------- onefilecms.php | 50 +++++++++++++++++++++++++++----------------------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index 9254d56..638db89 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -41,7 +41,7 @@ h1,h2,h3,h4,h5,h6{font-weight: bold;} body { font-size: 1em; - background: #d5d0cc; background: cyan; + background: #d5d0cc; font-family: sans-serif; } @@ -179,17 +179,18 @@ pre { padding: 7px 5px 7px 35px; border: 1px solid #807568; text-decoration: none; - background: white url("http://self-evident.github.com/OneFileCMS/images/binary-3.png") 10px 10px no-repeat; + background: white url("http://self-evident.github.com/OneFileCMS/images/file-bin.png") 3px no-repeat; overflow: hidden; line-height: 1em; } - -.index a.img { background: white url("http://self-evident.github.com/OneFileCMS/images/img-2.png") 10px 10px no-repeat; } -.index a.txt { background: white url("http://self-evident.github.com/OneFileCMS/images/file-2.png") 10px 10px no-repeat; } -.index a.css { background: white url("http://self-evident.github.com/OneFileCMS/images/file-2s.png") 10px 10px no-repeat; } -.index a.php { background: white url("http://self-evident.github.com/OneFileCMS/images/file-2p.png") 10px 10px no-repeat; } -.index a.htm { background: white url("http://self-evident.github.com/OneFileCMS/images/file-2h.png") 10px 10px no-repeat; } +.index a.bin { background:white url("http://self-evident.github.com/OneFileCMS/images/file-bin.png") 3px no-repeat; } +.index a.img { background:white url("http://self-evident.github.com/OneFileCMS/images/file-img.png") 3px no-repeat; } +.index a.txt { background:white url("http://self-evident.github.com/OneFileCMS/images/file-txt.png") 3px no-repeat; } +.index a.cfg { background:white url("http://self-evident.github.com/OneFileCMS/images/file-cfg.png") 3px no-repeat; } +.index a.css { background:white url("http://self-evident.github.com/OneFileCMS/images/file-css.png") 3px no-repeat; } +.index a.htm { background:white url("http://self-evident.github.com/OneFileCMS/images/file-htm.png") 3px no-repeat; } +.index a.php { background:white url("http://self-evident.github.com/OneFileCMS/images/file-php.png") 3px no-repeat; } .index a:hover { background-color: #fffbce; @@ -222,18 +223,19 @@ table.index_T td { padding: .2em 1em .3em 1.6em; color: rgb(100,45,0); border : none; - background : url("http://self-evident.github.com/OneFileCMS/images/binary-3.png") 3px no-repeat; + background : url("http://self-evident.github.com/OneFileCMS/images/file-bin.png") 3px no-repeat; overflow : hidden; } /* background : url("http://self-evident.github.com/OneFileCMS/images/silk_file.png") 4px no-repeat;*/ -.index_T a.txt { background: url("http://self-evident.github.com/OneFileCMS/images/file-2.png") 3px no-repeat; } -.index_T a.htm { background: url("http://self-evident.github.com/OneFileCMS/images/file-2h.png") 3px no-repeat; } -.index_T a.css { background: url("http://self-evident.github.com/OneFileCMS/images/file-2s.png") 3px no-repeat; } -.index_T a.php { background: url("http://self-evident.github.com/OneFileCMS/images/file-2p.png") 3px no-repeat; } -.index_T a.cnf { background: url("http://self-evident.github.com/OneFileCMS/images/file-2.png") 3px no-repeat; } -.index_T a.img { background: url("http://self-evident.github.com/OneFileCMS/images/img-2.png") 3px no-repeat; } +.index_T a.txt { background: url("http://self-evident.github.com/OneFileCMS/images/file-txt.png") 3px no-repeat; } +.index_T a.htm { background: url("http://self-evident.github.com/OneFileCMS/images/file-htm.png") 3px no-repeat; } +.index_T a.css { background: url("http://self-evident.github.com/OneFileCMS/images/file-css.png") 3px no-repeat; } +.index_T a.php { background: url("http://self-evident.github.com/OneFileCMS/images/file-php.png") 3px no-repeat; } +.index_T a.cfg { background: url("http://self-evident.github.com/OneFileCMS/images/file-cfg.png") 3px no-repeat; } +.index_T a.img { background: url("http://self-evident.github.com/OneFileCMS/images/file-img.png") 3px no-repeat; } +.index_T a.bin { background: url("http://self-evident.github.com/OneFileCMS/images/file-bin.png") 3px no-repeat; } .index_T a:hover { background-color: #FFF573; } /*#fffbce #969376; rgb(255,245,115);*/ diff --git a/onefilecms.php b/onefilecms.php index 976a147..fdeff47 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,25 +1,27 @@ OneFileCMS."; $config_editable = "html,htm,php,css,txt,text,conf,ini,csv"; $config_excluded = ""; //files to exclude from directory listings - +$config_ftypes = "jpg,gif,png,bmp,ico,txt,cvs,css,php,htm,html,cfg,conf"; //used to select file icon +$config_fclass = "img,img,img,img,img,txt,txt,css,php,htm,htm,cfg,cfg"; //used to select file icon $config_LOCAL = "/onefilecms/"; //local directory for icons, .css, .js, etc... $config_csslocal = "onefilecms.css"; //Relative to this file. //$config_csslocal ="/onefilecms.css"; //Relative to site URL root. @@ -28,6 +30,13 @@ $config_JQhosted = "http://code.jquery.com/jquery-1.7.2.min.js"; //$config_JQhosted = "http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"; + +//Make arrays out of a couple $config_variables. They are used in // Index +//Above, however, it's easier to config/change a simple string. +$ftypes = (explode(",", strtolower($config_ftypes))); +$fclasses = (explode(",", strtolower($config_fclass))); + + //Allows OneFileCMS.php to be started from any dir on the site. chdir($DOC_ROOT); @@ -469,34 +478,29 @@ function Cancel_Submit_Buttons($button_label) { $excludeme = 1; } } + if (!is_dir($file) && $excludeme == 0) { + + //Determine file type & set cooresponding class. $file_class = ""; - $lfile = strtolower($file); - if ( - (strrpos(strtolower($lfile),".jpg")) || - (strrpos($lfile,".gif")) || - (strrpos($lfile,".png")) || - (strrpos($lfile,".ico")) - ) { - $file_class = "img"; - }; - if (strrpos($lfile,".css")) { $file_class = "css"; }; - if (strrpos($lfile,".php")) { $file_class = "php"; }; - if (strrpos($lfile,".htm")) { $file_class = "htm"; }; - if (strrpos($lfile,".html")) { $file_class = "htm"; }; + $ext = end( explode(".", strtolower($file)) ); + + for ($x=0; $x < count($ftypes); $x++ ){ + if ($ext == $ftypes[$x]){ $file_class = $fclasses[$x]; } + } ?>
  • '; echo basename($file); ?>
    File Size: - kb
    +
    Last Updated:
  • - + + From bbf7a9855dc2c9486d6205f03cc7329d96e5b398 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Mon, 23 Apr 2012 19:08:46 -0400 Subject: [PATCH 037/228] Added List view/table format, and $VIEW_MODE to select List or BLOCK view. Version 1.1.8 --- onefilecms.php | 86 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 7 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index fdeff47..c102de1 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,7 +2,7 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.1.7"; +$version = "1.1.8"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; @@ -30,6 +30,7 @@ $config_JQhosted = "http://code.jquery.com/jquery-1.7.2.min.js"; //$config_JQhosted = "http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"; +$VIEW_MODE = "LIST"; // or BLOCK (Actually, anything =/= BLOCK == LIST) //Make arrays out of a couple $config_variables. They are used in // Index //Above, however, it's easier to config/change a simple string. @@ -278,8 +279,7 @@ function Cancel_Submit_Buttons($button_label) { <?php echo $config_title.' - '.$pagetitle; ?> - @@ -465,10 +464,15 @@ function Cancel_Submit_Buttons($button_label) { - + +
    + + + + + + + function list_view() { + + global $varvar, $config_excluded, $ftypes, $fclasses ; + + $files = glob($varvar."{,.}*", GLOB_BRACE); + sort($files); + $files_count = count($files); + $fc = 0; + + 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) { + + //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]; } + } + ?> + + + + + + +
    + + ", basename($file), ""; ?> + + B + +   + +
    + + ?> + + + + + + +

    - - + +

    +

    '.$message.'

    '; }; +

    '.$message.'

    '; }; + +// On Edit page only, preserve vertical spacing for message even when not there. +if (!isset($message) && ($page == "edit")) { echo '
    '; }; @@ -378,12 +380,14 @@ function Cancel_Submit_Buttons($button_label) { // EDIT ************************************************************************ if ($page == "edit") { ?> +

    Edit “

    - + +

    - +

    - +

    - + - + @@ -417,11 +420,79 @@ function Cancel_Submit_Buttons($button_label) {

    - + + + + + + + + + + + - - + ?> @@ -534,15 +604,15 @@ function list_view() { } 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]; } } - ?> + ?> @@ -567,11 +637,10 @@ function list_view() { - - + + if ($VIEW_MODE == "BLOCK"){ list_BLOCK_view(); } + else { list_view(); } + ?> @@ -589,6 +658,8 @@ function list_view() {

    +

    Log Out

    @@ -619,6 +692,7 @@ function list_view() { + // NEW FILE ******************************************************************** if ($page == "new") { $varvar = ""; @@ -637,6 +711,7 @@ function list_view() { + // NEW FOLDER ****************************************************************** if ($page == "folder") { $varvar = ""; @@ -681,6 +756,7 @@ function list_view() { + // RENAME FOLDER *************************************************************** if ($page == "renamefolder") { $varvar = "?i=".substr($_GET["i"],0,strrpos(substr_replace($_GET["i"],"",-1),"/")); ?> @@ -701,6 +777,7 @@ function list_view() { + // UPLOAD FILE ***************************************************************** if ($page == "upload") { $varvar = ""; if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; } ?> @@ -722,51 +799,15 @@ function list_view() { - + +
    - - - - + From 27c3d4389303ad790494db0497da75e5ec39d852 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Tue, 24 Apr 2012 21:00:12 -0400 Subject: [PATCH 041/228] Version 1.1.9 --- onefilecms.php | 2 +- readme.markdown | 70 +++++++++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 0bfb863..1f5b218 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,7 +2,7 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.1.8"; +$version = "1.1.9"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; diff --git a/readme.markdown b/readme.markdown index 2d03135..568b8e2 100644 --- a/readme.markdown +++ b/readme.markdown @@ -2,55 +2,60 @@ ## Yeah, it's exactly what you think. -![OneFileCMS](http://onefilecms.com/images/screenshots/branded_index.jpg) +Main screen: +![OneFileCMS](http://self-evident.github.com/OneFileCMS/images/OneFileCMS_screenshot.png) + +Edit screen: +![OneFileCMS](http://self-evident.github.com/OneFileCMS/images/OneFileCMS_screenshot_edit.png) + OneFileCMS is just that. It's a flat, light, one file CMS (Content Management System) entirely contained in an easy-to-implement, highly customizable, database-less PHP script. Coupling a utilitarian code editor with all the basic necessities of an FTP application, OneFileCMS can maintain a whole website completely in-browser without any external programs. -**Demo**: [http://php.opensourcecms.com/scripts/details.php?scriptid=340](http://php.opensourcecms.com/scripts/details.php?scriptid=340) +## Demo + +- Just download & try the current version - it's one file! ## Features -- Validating, semantic, and commented markup. Tested in FF, Safari, and IE7/IE8. -- Possibly the easiest installation process ever -- 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.)_ -- Gracefully degrading CSS and Javascript -- 100% re-brandable with title/footer text stored in variables and a modifiable filename -- Externally hosted CSS and images for smaller file size
    - _(But you can switch it out to your own stylesheet if you need to!)_ - Smart alert if you try to leave without saving your edits +- Gracefully degrading CSS and Javascript +- Easily re-brandable via the title text stored in a configurable variable, and a modifiable filename. +- Externally hosted CSS and images. + _(Of course, you can switch it out to your own stylesheet if you need to!)_ +- Possibly the easiest installation process ever! ## Installation -Download [this file](https://raw.github.com/rocktronica/OneFileCMS/master/onefilecms.php). +1) Download [this file](https://raw.github.com/Self-Evident/OneFileCMS/master/onefilecms.php). + -Your username and password are inlined. Edit them to something less obvious. +2) Set your username and password - edit them to something less obvious. // CONFIGURATION INFO $config_username = "username"; $config_password = "password"; -Optional variables thereafter: password hint, title, footer text, filetypes to disable, and filenames to ignore - -You can also change the name of the file to something else. Be careful making it a folder's default file; your server may get stuck in redirects. - -Upload! +3) Upload! Depending on how your stack is set up, you may also have to modify the file permissions of your site's folders to allow OneFileCMS to modify and create files. ([More about that here.](http://catcode.com/teachmod/)) Make sure onefilecms.php and its parent folder are allowed to execute, with CHMOD at 777 or 755. Check with your host if you're not sure, and be aware of any inherent security concerns. +You can also change the name of OneFileCMS.php to something else. _(Be careful making it a folder's default file: your server may get stuck in redirects.)_ + ## FAQ ### Where's the WYSIWYG? What about syntax highlighting? -WYSWIWYG editors have been requested but probably won’t ever come standard, as they’d bloat the system out and/or make it more than one file, sort of defeating the novelty. Plus, if you’re working in PHP or non-HTML code, they're generally more hindrance than anything else. +WYSWIWYG editors have been requested, but probably won’t ever come standard, as they’d bloat the system out and/or make it more than one file, sort of defeating the point of OneFileCMS. Plus, if you’re working in PHP or non-HTML code, they're generally more of a hindrance than anything else. -Just because I don't want to do it, though, doesn't mean it's impossible. About halfway through, look for this line (If you're searching for it, it's the second instance): +Just because I don't want to do it, though, doesn't mean it's impossible. Look for the second instance of this line: // EDIT -This is the edit page code. Its textareas can be modified to work with whatever editor you like. If the editor is initiated via jQuery, you can call it in the jQ code in the footer. +This is the edit page code. Its textarea can be modified to work with whatever editor you like. ### I found something that could be better. Can I suggest it to you? @@ -64,22 +69,27 @@ Everything's welcome! ### This is basically just a file manager with a text editor. Why is it being called a Content Management System? -Because "OneFileFileManagerTextEditor" doesn't quite have the same ring to it, duh. +Because "OneFileFileManagerTextEditor" just doesn't have the same ring to it... ### Multi-Language Support? -Maybe later! +Probably not. ### Can I have more than one username/password? The reason there isn't default support for multiple users is that all of their info will have to be stored together, more or less in plain text, at the top of onefilecms.php. Giving people different usernames and passwords then is sort of futile, since everyone who can log in can view onefilecms's source and config variables. (This answer kind of ignores MD5 hashes but is valid for most considerations.)  -### Is the JavaScript at the end of file really needed? When I remove it, everything works fine. +### Is the JavaScript in the middle of the file really needed? When I remove it, everything seems to work fine. -It isn't entirely necessary, but it does nice little progressive enhancements like warn if you try to leave w/o saving and stuff like that. Feel free to take it out if you're trying to trim down your figure. +It isn't entirely necessary, but it does provide nice enhancements, like warning you if you try to leave without saving changes, and stuff like that. ## Change Log +### 1.1.9 + +- Improved Edit page & screen feedback of file state (changed/unchanged). +- Removed use of jquery in move towards a true "OneFileCMS". + ### 1.1.8 - Added a table list view option (default). Either List or original "Block" view selectable with $VIEW_MODE variable. (On screen selection in the works) @@ -137,27 +147,25 @@ It isn't entirely necessary, but it does nice little progressive enhancements li ## Requirements -- UNIX/Linux host, Apache - PHP5 (PHP4 untested) - File permission privileges ## Credit, License, Et Cetera -Written in PHP, XHTML, CSS, and [jQuery](http://jquery.com/). Icons by [famfamfam](http://www.famfamfam.com/). +Written in PHP, JavaScript, XHTML and CSS. Available under the MIT and BSD license. +Icons for versions thru 1.1.6 by [famfamfam](http://www.famfamfam.com/). + To report a bug or request a feature, please file an issue via Github. Forks encouraged! ##Needed/potential/upcoming improvements - Prompt to prevent automatic overwrite when uploading or renaming files. -- Check size of file to upload, verify under max post/upload limits. - Option to switch between original OneFileCMS view and a common list view. - (in the works) + Currently accomplished with a config variable. Working on a - Embed css and remove or swtich to svg icons to create a true "OneFileCMS" (in the works) -- Remove use of jquery. - Used to detect if file being edited, set focus form fields, (more?) - (in the works) -- Multiple login names +- Check size of file to upload, verify under max post/upload limits. +- Multiple login names? From 387be8ef479252ee69ad74eac1f1ab2d17585514 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sat, 28 Apr 2012 12:39:21 -0400 Subject: [PATCH 042/228] Version 1.2.0 File list sorted with out regard to case. Improved Edit page feedback indicators & actions. Improved file date shown on Index & Edit pages. Uses javascript to format time value from server now shows in user's local time (well, on my machine it does:) (May update later to show time in GMT instead. Or not..) Added dismiss "button" [X] to message box. Rearranged a few styles in the .css a bit, and some other code spacing etc. /> to just > In readme, changed XHTML to just HTML. Now --- onefilecms.css | 156 +++++++++++++---------- onefilecms.php | 321 ++++++++++++++++++++++++++++++++---------------- readme.markdown | 15 ++- 3 files changed, 320 insertions(+), 172 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index c244efb..4cffb8e 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -4,11 +4,13 @@ */ -/* #774200 #807568 #976322 #995400 #d4d4d4 #0F0901 +/* #774200 #807568 #976322 #995400 #d4d4d4 #0F0901 #eaeaea rgb(255,250,150) rgb(157, 124, 83) rgb(157, 124, 83) - rgb(255,250,150) #fffbce #969376 rgb(255,245,115) + rgb(255,250,150) rgb(255,250,150) #969376 rgb(255,245,115) */ + + /* --- reset --- */ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big, cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li, @@ -25,6 +27,25 @@ fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td vertical-align: baseline; } + + + +/* --- general formatting --- */ + +body { + font-size: 1em; + background: #d5d0cc; + font-family: sans-serif; + } + +h2,h3,p,ul,table { margin-bottom: 10px; } + +em, i { font-style: italic; } + +strong { font-weight: bold; } + +li {line-height: 1.4em; } + :focus{outline:0;} ol,ul{list-style:none;} @@ -39,14 +60,40 @@ blockquote,q{quotes:"" "";} div{position: relative;} h1,h2,h3,h4,h5,h6{font-weight: bold;} +h2 { font-size: 20px; } +h3 { font-size: 18px; margin-top: 15px; } +h4 { font-size: 1.3em; margin-bottom: .2em; font-weight: normal;} -body { - font-size: 1em; - background: #d5d0cc; - font-family: sans-serif; +a { border: 1px solid transparent; color: rgb(100,45,0); text-decoration: none; } +a:hover { border: 1px solid #807568; background-color: rgb(255,250,150); } +a:focus { border: 1px solid #807568; background-color: rgb(255,250,150); } + +form p { margin-bottom: 5px; } + + +label { + display: inline-block; + width : 7em; + font-size : 14px; + font-style: italic; } +pre { + background: white; + border: 1px solid #807568; + line-height: 1.25em; + overflow: auto + overflow-Y: hidden; + padding: 10px; + margin: 5px 0 10px 0; + overflow: hidden; + } + + + + + /* --- layout --- */ .container { @@ -86,47 +133,6 @@ body { -/* --- general formatting --- */ - -h2,h3,p,ul,table { margin-bottom: 10px; } - -Xp, li {line-height: 1.4em; } - -form p { margin-bottom: 5px; } - -a { border: 1px solid transparent; color: rgb(100,45,0); text-decoration: none; } -a:hover { border: 1px solid #807568; background-color: rgb(255,250,150); } -a:focus { border: 1px solid #807568; background-color: rgb(255,250,150); } - - -h2 { font-size: 20px; } - -h3 { font-size: 18px; margin-top: 15px; } - -h4 { font-size: 1.3em; margin-bottom: .2em; font-weight: normal;} - -em, i { font-style: italic; } - -strong { font-weight: bold; } - -label { - display: inline-block; - width : 7em; - font-size : 14px; - font-style: italic; - } - -pre { - background: white; - border: 1px solid #807568; - line-height: 1.25em; - overflow: auto - overflow-Y: hidden; - padding: 10px; - margin: 5px 0 10px 0; - overflow: hidden; - } - .page_login label { display: block; margin-bottom: 2px; @@ -143,13 +149,12 @@ pre { } #message { - margin-bottom: .5em; - min-height: 1.7em; /* Leaves space when on edit page with no message. */ + min-height: 1.7em; /* Leave space when message is blank. Used by Edit page */ } - + #message p { margin: 0; - padding: 5px 5px 5px 30px; + padding: 4px 0px 4px .5em; border: 1px solid #807568; font-family: Lucida Console, "Courier New" ; font-size: .95em; @@ -157,6 +162,10 @@ pre { background: #fff000; } +#message span { float: right; } + +#message a { padding: 4px 1px 4px 1px; border-right: none; } /*T R B L*/ + /* --- INDEX --- */ @@ -164,13 +173,13 @@ pre { .index li { margin: 0 10px 10px 0; - width: 192.5px; + width: 260px; float: left; position: relative; } .index a { - height: 28px; + height: 20px; display: block; padding: 7px 5px 7px 35px; border: 1px solid #807568; @@ -242,26 +251,28 @@ table.index_T td { /* File size & date */ .meta_size { - Xwidth : 9em; - padding-left : 1em; + min-width : 6em; padding-right : .5em; text-align : right; - font-size : .8em; color: #333; + font-family : courier; + font-size : .9em; + color : #333; } .meta_time { - width : 12em; + width : 13em; padding-right : .5em; text-align : right; - font-size : .8em; color: #333; + font-family : courier; + font-size : .9em; + color : #333; } .index .meta { - font-size: 11px; + font-size: .9em; height: 25px; margin-top: 3px; - overflow: hidden; line-height: 1.1em; } @@ -337,8 +348,10 @@ textarea.disabled { height: 50px; } textarea:focus { border: 1px solid #Faa; } -input:focus { background-color: #fffbce; } -/* input[type="button"]:focus { background-color: #fffbce; } */ +input:focus { background-color: rgb(255,250,150); } +/* input[type="button"]:focus { background-color: rgb(255,250,150); } */ + +input:hover { background-color: rgb(255,250,150); } .buttons_right { float: right;} @@ -355,9 +368,15 @@ input:focus { background-color: #fffbce; } font-family: sans-serif; } -.button:hover { background-color: #eaeaea; } +.Xbutton:hover { background-color: rgb(255,250,150); } .button[disabled]:hover { background-color: #d4d4d4; } +/* +#Xsave_file { border: 1px solid red; } +#save_file a:hover { background-color: rgb(255,250,150); border: 1px solid red; } +#save_file a:focus { background-color: rgb(255,250,150); border: 1px solid red; } +*/ + #action {color: white; background-color: rgb(235,70,70); font-weight: 700;} @@ -388,11 +407,17 @@ input:focus { background-color: #fffbce; } /* --- edit --- */ -#edit_header {float: left;} +#edit_header {margin: 0;} -.close {float: right;} +#edit_form {margin: 0;} +#file_content {height: 24em; } +#file_meta {float: left; margin-top: .5em; width: 700px; border: 0px solid red; } + +.close {float: right; margin-bottom: .5em;} + +#edit_note {font-size: .8em; color: #444 ;margin-top: 1em;} /* --- log in --- */ @@ -413,7 +438,6 @@ input:focus { background-color: #fffbce; } - /* --- --- --- */ hr { line-height : 0; diff --git a/onefilecms.php b/onefilecms.php index 1f5b218..da8b174 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,32 +2,28 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.1.9"; +$version = "1.2.0"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; -$ONESCRIPT = $_SERVER["SCRIPT_NAME"]; -$DOC_ROOT = $_SERVER["DOCUMENT_ROOT"]; -$CWD = str_replace("\\","/",getcwd()); - - -// CONFIGURATION INFO +// CONFIGURABLE INFO $VIEW_MODE = "LIST"; // or BLOCK (Actually, anything =/= BLOCK == LIST) $config_username = "username"; $config_password = "password"; $config_title = "OneFileCMS"; -$config_editable = "html,htm,php,css,txt,text,cfg,conf,ini,csv"; -$config_excluded = ""; //files to exclude from directory listings $config_LOCAL = "/onefilecms/"; //local directory for icons, .css, .js, etc... $config_csslocal = "onefilecms.css"; //Relative to this file. //$config_csslocal ="/onefilecms.css"; //Relative to site URL root. $config_csshosted = "http://self-evident.github.com/OneFileCMS/onefilecms.css"; +$config_editable = "html,htm,php,css,txt,text,cfg,conf,ini,csv"; +$config_excluded = ""; //files to exclude from directory listings $config_ftypes = "jpg,gif,png,bmp,ico,txt,cvs,css,php,htm,html,cfg,conf"; //used to select file icon $config_fclass = "img,img,img,img,img,txt,txt,css,php,htm,htm,cfg,cfg"; //used to select file icon +// END CONFIGURABLE INFO //Make arrays out of a couple $config_variables. They are used in // Index . //Above, however, it's easier to config/change a simple string. @@ -35,6 +31,11 @@ $fclasses = (explode(",", strtolower($config_fclass))); +$ONESCRIPT = $_SERVER["SCRIPT_NAME"]; +$DOC_ROOT = $_SERVER["DOCUMENT_ROOT"]; +$CWD = str_replace("\\","/",getcwd()); + + //Allows OneFileCMS.php to be started from any dir on the site. chdir($DOC_ROOT); @@ -45,7 +46,7 @@ function Close_Button($classes) { echo ''; + echo $ONESCRIPT.'?i='.substr($_GET["f"],0,strrpos($_GET["f"],"/")).'\'">'; } @@ -62,7 +63,7 @@ function Cancel_Submit_Buttons($button_label) { ?>

    - +

    @@ -264,14 +265,18 @@ function Cancel_Submit_Buttons($button_label) { + + //****************************************************************************** //****************************************************************************** -?> +?> + + - + <?php echo $config_title.' - '.$pagetitle; ?> @@ -289,7 +294,60 @@ function Cancel_Submit_Buttons($button_label) { if (!file_exists($ROOT.$config_csslocal)) { $STYLE_SHEET = $config_csshosted; } //***************************************************************?> - + + + + + + + + + + + + + + + @@ -298,7 +356,7 @@ function Cancel_Submit_Buttons($button_label) {
    - ', $config_title; ?> + ', $config_title; ?> '; }; -// On Edit page only, preserve vertical spacing for message even when not there. + +

    + + + [X]

    +
    '; }; + // COPY FILE ******************************************************************* if ($page == "copy") { $extension = strrchr($filename, "."); @@ -326,15 +392,15 @@ function Cancel_Submit_Buttons($button_label) {

    Copy “

    Existing files with the same filename are automatically overwritten... Be careful!

    - +

    - - + +

    - " /> + ">

    @@ -345,14 +411,14 @@ function Cancel_Submit_Buttons($button_label) { // DELETE FILE ***************************************************************** if ($page == "delete") { $varvar = "?i=".substr($_GET["d"],0,strrpos($_GET["d"],"/")); ?> -

    Delete “ +

    Delete “

    Are you sure?

    - +

    - +

    @@ -367,9 +433,9 @@ function Cancel_Submit_Buttons($button_label) {

    Delete Folder “

    Folders have to be empty before they can be deleted.

    - +

    - " /> + ">

    @@ -381,14 +447,21 @@ function Cancel_Submit_Buttons($button_label) { // EDIT ************************************************************************ if ($page == "edit") { ?> -

    Edit “ - +

    Edit “ +

    - + + +

    + Size: bytes     + Updated:
    + +

    + - - + +

    - + +

    - +

    - + + - - - - + + + + -

    -

    File Size:   –   - Updated:

    -
    +
    + NOTE: On 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]. +
    - + @@ -491,7 +607,6 @@ function Reset_File() { - '.basename($file).' /'; } ?> @@ -537,16 +652,19 @@ function Reset_File() {
      - '; echo basename($file); ?>
      - File Size: -
      - Last Updated: - + File Size: +
      + Updated: +
    - ?> + ?> @@ -586,9 +704,7 @@ function list_view() { global $varvar, $config_excluded, $ftypes, $fclasses ; $files = glob($varvar."{,.}*", GLOB_BRACE); - sort($files); - $files_count = count($files); - $fc = 0; + natcasesort($files); echo ''; foreach ($files as $file) { @@ -618,12 +734,11 @@ function list_view() { ", basename($file), ""; ?> - - - if ($VIEW_MODE == "BLOCK"){ list_BLOCK_view(); } - else { list_view(); } + if ($VIEW_MODE == "BLOCK"){ BLOCK_view(); } + else { list_view(); } ?> @@ -669,14 +784,14 @@ function list_view() {

    - +

    - +

    - + New File

    Existing files with the same name will not be overwritten.

    "> - +

    - " /> + ">

    @@ -719,10 +834,10 @@ function list_view() {

    New Folder

    Existing folders with the same name will not be overwritten.

    "> - +

    - " /> + ">

    @@ -740,15 +855,15 @@ function list_view() {

    To move a file, preface its name with the folder's name, as in "foldername/filename.txt." The folder must already exist.

    - +

    - - + +

    - +

    @@ -762,14 +877,14 @@ function list_view() { $varvar = "?i=".substr($_GET["i"],0,strrpos(substr_replace($_GET["i"],"",-1),"/")); ?>

    Rename Folder “

    - +

    - " /> - " class="textinput" disabled="disabled" /> + "> + " class="textinput" disabled="disabled">

    - " /> + ">

    @@ -783,15 +898,15 @@ function list_view() { $varvar = ""; if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; } ?>

    Upload

    " method="post"> - - + +

    - " class="textinput" /> + " class="textinput">

    - +

    diff --git a/readme.markdown b/readme.markdown index 568b8e2..cdeaefd 100644 --- a/readme.markdown +++ b/readme.markdown @@ -85,6 +85,14 @@ It isn't entirely necessary, but it does provide nice enhancements, like warning ## Change Log +### 1.2.0 + +- List of files now sorted alphabetically, without regard to case. +- Further improved Edit page & screen feedback of file state (changed/unchanged). +- Added [X] dismiss button on message box +- File date shown on Index & Edit pages is now in user's local time. +- Moved from xhtml to html syntax & doctype. + ### 1.1.9 - Improved Edit page & screen feedback of file state (changed/unchanged). @@ -152,7 +160,7 @@ It isn't entirely necessary, but it does provide nice enhancements, like warning ## Credit, License, Et Cetera -Written in PHP, JavaScript, XHTML and CSS. +Written in PHP, JavaScript, HTML and CSS. Available under the MIT and BSD license. @@ -162,9 +170,10 @@ To report a bug or request a feature, please file an issue via Github. Forks enc ##Needed/potential/upcoming 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+. - Prompt to prevent automatic overwrite when uploading or renaming files. -- Option to switch between original OneFileCMS view and a common list view. - Currently accomplished with a config variable. Working on a +- 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 a0443ce96f3aaad269d8cdb336d44115e3582c91 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sun, 29 Apr 2012 21:55:07 -0400 Subject: [PATCH 043/228] Added svg as an editable file type. Some code & css improvment to Edit & Index pages. Added $config_itypes (image types) in prep for future enhancement. --- onefilecms.css | 38 +++++++++++++++---------------- onefilecms.php | 62 ++++++++++++++++++++++++-------------------------- 2 files changed, 48 insertions(+), 52 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index 4cffb8e..bf6301e 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -132,21 +132,17 @@ pre { } - .page_login label { display: block; margin-bottom: 2px; } + .alignleft { margin: 0 10px 10px 0; float: left; } -.left70 { - width: 70px; - display: inline-block; - } #message { min-height: 1.7em; /* Leave space when message is blank. Used by Edit page */ @@ -167,6 +163,7 @@ pre { #message a { padding: 4px 1px 4px 1px; border-right: none; } /*T R B L*/ + /* --- INDEX --- */ .index { width: 810px; } @@ -196,6 +193,7 @@ pre { .index a.css { background:white url("http://self-evident.github.com/OneFileCMS/images/file-css.png") 3px no-repeat; } .index a.htm { background:white url("http://self-evident.github.com/OneFileCMS/images/file-htm.png") 3px no-repeat; } .index a.php { background:white url("http://self-evident.github.com/OneFileCMS/images/file-php.png") 3px no-repeat; } +.index a.svg { background:white url("http://self-evident.github.com/OneFileCMS/images/file-svg.png") 3px no-repeat; } .index a:hover { background-color: rgb(255,250,150); } .index a:focus { background-color: rgb(255,250,150); } @@ -242,6 +240,7 @@ table.index_T td { .index_T a.cfg { background: url("http://self-evident.github.com/OneFileCMS/images/file-cfg.png") 3px no-repeat; } .index_T a.img { background: url("http://self-evident.github.com/OneFileCMS/images/file-img.png") 3px no-repeat; } .index_T a.bin { background: url("http://self-evident.github.com/OneFileCMS/images/file-bin.png") 3px no-repeat; } +.index_T a.svg { background: url("http://self-evident.github.com/OneFileCMS/images/file-svg.png") 3px no-repeat; } .index_T a:hover { background-color: rgb(255,250,150); } .index_T a:focus { background-color: rgb(255,250,150); } @@ -252,32 +251,31 @@ table.index_T td { .meta_size { min-width : 6em; + } + +.meta_time { + width : 13em; + } + +.meta { + height : 25px; + line-height : 1.1em; + font-size : .9em; + margin-top : 3px; padding-right : .5em; - text-align : right; - font-family : courier; font-size : .9em; color : #333; } -.meta_time { - width : 13em; +.meta_T { padding-right : .5em; text-align : right; font-family : courier; - font-size : .9em; + font-size : .9em; color : #333; } -.index .meta { - font-size: .9em; - height: 25px; - margin-top: 3px; - line-height: 1.1em; - } - - - .index_folders { min-height: 1.4em; margin-bottom: .2em @@ -413,7 +411,7 @@ input:hover { background-color: rgb(255,250,150); } #file_content {height: 24em; } -#file_meta {float: left; margin-top: .5em; width: 700px; border: 0px solid red; } +.file_meta {float: left; margin-top: .5em;} .close {float: right; margin-bottom: .5em;} diff --git a/onefilecms.php b/onefilecms.php index da8b174..3b77daf 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -14,21 +14,23 @@ $config_password = "password"; $config_title = "OneFileCMS"; -$config_LOCAL = "/onefilecms/"; //local directory for icons, .css, .js, etc... +$config_LOCAL = "/onefilecms/"; //local directory for icons, .css, .js, etc... $config_csslocal = "onefilecms.css"; //Relative to this file. //$config_csslocal ="/onefilecms.css"; //Relative to site URL root. $config_csshosted = "http://self-evident.github.com/OneFileCMS/onefilecms.css"; -$config_editable = "html,htm,php,css,txt,text,cfg,conf,ini,csv"; +$config_editable = "html,htm,php,css,txt,text,cfg,conf,ini,csv,svg"; $config_excluded = ""; //files to exclude from directory listings -$config_ftypes = "jpg,gif,png,bmp,ico,txt,cvs,css,php,htm,html,cfg,conf"; //used to select file icon -$config_fclass = "img,img,img,img,img,txt,txt,css,php,htm,htm,cfg,cfg"; //used to select file icon +$config_itypes = "jpg,gif,png,bmp,ico"; // Can be displayed on edit page. +$config_ftypes = "jpg,gif,png,bmp,ico,svg,txt,cvs,css,php,htm,html,cfg,conf"; //used to select file icon +$config_fclass = "img,img,img,img,img,svg,txt,txt,css,php,htm,htm,cfg,cfg"; //used to select file icon // END CONFIGURABLE INFO //Make arrays out of a couple $config_variables. They are used in // Index . //Above, however, it's easier to config/change a simple string. $ftypes = (explode(",", strtolower($config_ftypes))); $fclasses = (explode(",", strtolower($config_fclass))); +$itypes = (explode(",", strtolower($config_itypes))); $ONESCRIPT = $_SERVER["SCRIPT_NAME"]; @@ -47,7 +49,8 @@ function Close_Button($classes) { echo ''; -} + ?> -

    "> -

    +if ($page == "edit") { + $ext = end( explode(".", strtolower($filename)) ); + ?>

    Edit “

    -

    +

    Size: bytes     Updated:
    -

    -

    -

    - - -

    -

    - - - - - - - - -

    + + +

    + + + + + + +

    -
    - NOTE: On 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]. -
    + +
    + NOTE: On 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]. +
    + @@ -528,7 +526,7 @@ function Reset_file_status_indicators() { Save_File_button.disabled = "disabled"; Save_File_button.value = "Save"; Reset_button.disabled = "disabled"; - File_textarea.focus(); + //File_textarea.focus(); } @@ -734,10 +732,10 @@ function list_view() { ", basename($file), ""; ?> -
    - From 635bf87828e28fa04a4cf843b0c2404bbae3c338 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Mon, 30 Apr 2012 14:19:17 -0400 Subject: [PATCH 044/228] NOTICE: SECURITY HOLE! --- readme.markdown | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/readme.markdown b/readme.markdown index cdeaefd..1945104 100644 --- a/readme.markdown +++ b/readme.markdown @@ -1,3 +1,22 @@ +# NOTICE - SECURITY HOLE! + +## April 30, 2012 + +## Versions affected + +- 1.1.7 and newer. Version 1.1.6 is believed to be safe. + +## Brief description: + +- No login required if a file and path is known. + EX: http:// yourdomain.com/onefilecms.php?f=some/path/to/file.txt + +- File edit, rename, move, and copy still work in this way, without login. + +## Cause +- Me. I just noticed the problem. Some edit between 1.1.6 and now introduced the hole. + + # OneFileCMS ## Yeah, it's exactly what you think. From 591348e34a55605f397e4723c2bb1f4e1b73bb68 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 30 Apr 2012 16:20:26 -0400 Subject: [PATCH 045/228] Version 1.2.1 (security fix) --- onefilecms.css | 6 +++--- onefilecms.php | 8 +++++++- readme.markdown | 9 +++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index bf6301e..a592f97 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -1,5 +1,5 @@ /* OneFileCMS - http://onefilecms.com/ - * Version 1.1.7 + * Version 1.2.1 * For license & copyright info, see OneFileCMS.License.BSD.txt */ @@ -409,9 +409,9 @@ input:hover { background-color: rgb(255,250,150); } #edit_form {margin: 0;} -#file_content {height: 24em; } +#file_content {height: 24em;} -.file_meta {float: left; margin-top: .5em;} +.file_meta {float: left; margin-top: .5em; font-size: .9em; color: #333; font-family: courier;} .close {float: right; margin-bottom: .5em;} diff --git a/onefilecms.php b/onefilecms.php index 3b77daf..6c37e4f 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,7 +2,7 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.2.0"; +$version = "1.2.1"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; @@ -88,6 +88,12 @@ function Cancel_Submit_Buttons($button_label) { } else { $_SESSION['onefilecms_valid'] = "0"; $page = "login"; + $_GET["p"] = "login"; + unset($_GET["c"]); + unset($_GET["d"]); + unset($_GET["f"]); + unset($_GET["i"]); + unset($_GET["r"]); } global $pagetitle; $pagetitle = "/"; diff --git a/readme.markdown b/readme.markdown index 1945104..d6b1321 100644 --- a/readme.markdown +++ b/readme.markdown @@ -1,10 +1,11 @@ -# NOTICE - SECURITY HOLE! +# NOTICE - SECURITY HOLE! (Fixed in version 1.2.1) ## April 30, 2012 ## Versions affected -- 1.1.7 and newer. Version 1.1.6 is believed to be safe. +- 1.1.7 thru 1.2.0 +- Versions 1.1.6 and 1.2.1 are believed to be safe. ## Brief description: @@ -104,6 +105,10 @@ It isn't entirely necessary, but it does provide nice enhancements, like warning ## Change Log +### 1.2.1 + +- Fixed security hole that affected versions 1.1.7 - 1.2.0. + ### 1.2.0 - List of files now sorted alphabetically, without regard to case. From 6449d59b2829ff8144998097165a791d0c0d2a50 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Tue, 1 May 2012 00:32:14 -0400 Subject: [PATCH 046/228] Version 1.2.2 Images are now displayed on edit page instead of disabled textarea. Logout page now just a message on login page. Moved php misc functions to after session_start() section. Changed Edit pagetitle from Edit to View/Edit... In

    on edit page, changed Edit to File. Some files, like images, aren't editable. -

    - - -

    - - '; + ?> +

    + + +

    + +

    - -

    Edit “ + + + function show_image(){ //************************ + global $CWD, $filename; + $IMG = $filename; + //$IMG = $DOC_ROOT.$_GET[f]; + $img_info = getimagesize($IMG); + $MAX_IMG_W = 800; // width of display area in OneFileCMS + $MAX_IMG_H = 1000; // I don't know, it just looks reasonable. + + $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;} + else {$SCALE = $TOOHIGH;} + } + + echo '

    '.$img_info[3]; + echo ' (Image shown at ~'. round($SCALE*100) .'% of full size.)

    '; + echo '
    '; + echo '
    '; + echo ''; + }// end show_image() **************************** +?> + + +

    File: “

    @@ -466,23 +513,26 @@ function FileTimeStamp(php_filemtime, show_offset){ Size: bytes     Updated:

    - - + - - -

    +

    + +

    -

    - -

    +

    + +

    -

    - - +

    + + + + +

    @@ -494,6 +544,8 @@ function FileTimeStamp(php_filemtime, show_offset){

    + +
    NOTE: On 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]. @@ -501,6 +553,7 @@ function FileTimeStamp(php_filemtime, show_offset){ + + ... - +}; //End Edit page ************************************************************* - - function BLOCK_view() { global $varvar, $config_excluded, $ftypes, $fclasses ; ?> @@ -698,7 +752,7 @@ function BLOCK_view() { - ?> + ?> @@ -750,8 +804,7 @@ function list_view() { }//end foreach file ?>
    +   B -   - +   +
      +   B   +  
    - + ?> @@ -776,8 +829,16 @@ function list_view() { Rename Folder

    - -

    Log Out

    -

    You have successfully been logged out and may close this window.

    - Date: Wed, 2 May 2012 02:32:06 -0400 Subject: [PATCH 047/228] Fixed check for local css. If not found, loads hosted copy. A little general code cleanup/improvement. --- onefilecms.php | 35 ++++++++++++++++++----------------- readme.markdown | 7 ++++++- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 634d136..6eb09ea 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -19,6 +19,9 @@ //$config_csslocal ="/onefilecms.css"; //Relative to site URL root. $config_csshosted = "http://self-evident.github.com/OneFileCMS/onefilecms.css"; +$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. + $config_editable = "html,htm,php,css,txt,text,cfg,conf,ini,csv,svg"; $config_excluded = ""; //files to exclude from directory listings $config_itypes = "jpg,gif,png,bmp,ico"; // Can be displayed on edit page. @@ -26,6 +29,8 @@ $config_fclass = "img,img,img,img,img,svg,txt,txt,css,php,htm,htm,cfg,cfg"; //used to select file icon // END CONFIGURABLE INFO + + //Make arrays out of a couple $config_variables. They are used in // Index . //Above, however, it's easier to config/change a simple string. $ftypes = (explode(",", strtolower($config_ftypes))); @@ -142,7 +147,7 @@ function Cancel_Submit_Buttons($button_label) { // COPY FILE ******************************************************************* if (isset($_GET["c"])) { - $filename = $_GET["c"]; $pagetitle = "Copy “".$filename."”"; $page = "copy"; + $page = "copy"; $filename = $_GET["c"]; $pagetitle = "Copy “".$filename."”"; } if (isset($_POST["copy_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { @@ -156,10 +161,9 @@ function Cancel_Submit_Buttons($button_label) { // DELETE FILE ***************************************************************** if (isset($_GET["d"])) { - $filename = $_GET["d"]; - $pagetitle = "Delete “".$filename."”"; - $page = "delete"; + $page = "delete"; $filename = $_GET["d"]; $pagetitle = "Delete “".$filename."”"; } + if (isset($_POST["delete_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { $filename = $_POST["delete_filename"]; unlink($filename); @@ -317,7 +321,7 @@ function Cancel_Submit_Buttons($button_label) { 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)) { $STYLE_SHEET = $config_csshosted; } +if (!file_exists($ROOT.$config_csslocal) || is_dir($ROOT.$config_csslocal)) { $STYLE_SHEET = $config_csshosted; } //***************************************************************?> @@ -475,15 +479,13 @@ function FileTimeStamp(php_filemtime, show_offset){ function show_image(){ //************************ - global $CWD, $filename; + global $filename, $MAX_IMG_W, $MAX_IMG_H; + $IMG = $filename; - //$IMG = $DOC_ROOT.$_GET[f]; $img_info = getimagesize($IMG); - $MAX_IMG_W = 800; // width of display area in OneFileCMS - $MAX_IMG_H = 1000; // I don't know, it just looks reasonable. $W=0; $H=1; - $SCALE=1; $TOOWIDE = 0; $TOOHIGH = 0; + $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] );} @@ -799,12 +801,12 @@ function list_view() { - - - + echo ''; + + }//end list_view() =================================--> ?> @@ -820,8 +822,7 @@ function list_view() { diff --git a/readme.markdown b/readme.markdown index d6b1321..7a45c3a 100644 --- a/readme.markdown +++ b/readme.markdown @@ -5,7 +5,7 @@ ## Versions affected - 1.1.7 thru 1.2.0 -- Versions 1.1.6 and 1.2.1 are believed to be safe. +- Versions 1.1.6 and 1.2.1 + are believed to be safe. ## Brief description: @@ -105,6 +105,11 @@ It isn't entirely necessary, but it does provide nice enhancements, like warning ## Change Log +### 1.2.2 + +- On "Edit" page, images are now displayed directly, instead of a disabled textarea. +- Logout page replaced with standard "alert" message on login screen. + ### 1.2.1 - Fixed security hole that affected versions 1.1.7 - 1.2.0. From 7674472735b2943eda5aec06062fa0449743d4ce Mon Sep 17 00:00:00 2001 From: David Date: Wed, 2 May 2012 16:10:02 -0400 Subject: [PATCH 048/228] Minor wording/markdown tweaks... --- readme.markdown | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/readme.markdown b/readme.markdown index 7a45c3a..a55bb59 100644 --- a/readme.markdown +++ b/readme.markdown @@ -1,22 +1,28 @@ # NOTICE - SECURITY HOLE! (Fixed in version 1.2.1) -## April 30, 2012 +### April 30, 2012 ## Versions affected - 1.1.7 thru 1.2.0 -- Versions 1.1.6 and 1.2.1 + are believed to be safe. + +## Versions *Un* affected / fixed + +- Version 1.1.6 +- Versions 1.2.1 and newer ## Brief description: - No login required if a file and path is known. EX: http:// yourdomain.com/onefilecms.php?f=some/path/to/file.txt -- File edit, rename, move, and copy still work in this way, without login. +- File edit, rename, move, and copy work in this way, without login. ## Cause -- Me. I just noticed the problem. Some edit between 1.1.6 and now introduced the hole. +- Me. I just noticed the problem. Some edit after 1.1.6 introduced the hole. + +-------------------------------------------------------------------------------- # OneFileCMS @@ -39,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 From ced554dde4e3f4abf75869fb6b9b6ea728cab01f Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Wed, 2 May 2012 18:23:56 -0400 Subject: [PATCH 049/228] Added .gitignore to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e69de29..6c7b69a 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +.gitignore From 47b9d25faa9f7764e92f014e3d8a779577cf4fae Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Wed, 2 May 2012 23:55:50 -0400 Subject: [PATCH 050/228] Version 1.2.3 - some minor css adjustments. --- onefilecms.css | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index a592f97..1351582 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -1,5 +1,5 @@ /* OneFileCMS - http://onefilecms.com/ - * Version 1.2.1 + * Version 1.2.3 * For license & copyright info, see OneFileCMS.License.BSD.txt */ @@ -32,11 +32,7 @@ fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td /* --- general formatting --- */ -body { - font-size: 1em; - background: #d5d0cc; - font-family: sans-serif; - } +body { font-size: 1em; background: #d5d0cc; font-family: sans-serif; } h2,h3,p,ul,table { margin-bottom: 10px; } @@ -249,13 +245,9 @@ table.index_T td { /* File size & date */ -.meta_size { - min-width : 6em; - } +.meta_size { min-width: 6em; } -.meta_time { - width : 13em; - } +.meta_time { width : 13em;} .meta { height : 25px; @@ -282,15 +274,13 @@ table.index_T td { } .index_folders a { + Xborder : 1px solid gray; display : inline-block; line-height : 1.1em; font-size : 1em; margin-right : .6em; - padding : 2px 4px 2px 20px; - padding-left : 25px; - padding-right: .5em; - padding-top : .1em; - padding-bottom : .1em; + margin-bottom: .3em; + padding : .1em .4em .1em 25px; /*TRBL*/ background : url("http://self-evident.github.com/OneFileCMS/images/folder-2.png") 4px 3px no-repeat; } @@ -352,22 +342,22 @@ input:focus { background-color: rgb(255,250,150); } input:hover { background-color: rgb(255,250,150); } -.buttons_right { float: right;} +.buttons_right { float: right; } .buttons_right .button { margin-left: 7px; } -.buttons_left { float: left;} -.buttons_left .button { margin-right: 7px; } +.buttons_left { float: left; } +.buttons_left .button { margin-right: 7px; } .button { border: 1px solid #807568; padding: 4px 10px; background-color: #d4d4d4; cursor: pointer; - font-size: 14px; + font-size: .9em; font-family: sans-serif; } .Xbutton:hover { background-color: rgb(255,250,150); } -.button[disabled]:hover { background-color: #d4d4d4; } +.button[disabled]:hover { background-color: #d4d4d4; cursor:default } /* #Xsave_file { border: 1px solid red; } From f4ac14c040473c177620d943b50ab9cf04686e15 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Thu, 3 May 2012 00:19:49 -0400 Subject: [PATCH 051/228] Version 1.2.3 --- onefilecms.php | 2 +- readme.markdown | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 6eb09ea..fceb5b6 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,7 +2,7 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.2.2"; +$version = "1.2.3"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; diff --git a/readme.markdown b/readme.markdown index a55bb59..142dfe7 100644 --- a/readme.markdown +++ b/readme.markdown @@ -1,7 +1,7 @@ -# NOTICE - SECURITY HOLE! (Fixed in version 1.2.1) - ### April 30, 2012 +# NOTICE - SECURITY HOLE! (Fixed in version 1.2.1) + ## Versions affected - 1.1.7 thru 1.2.0 @@ -111,6 +111,11 @@ It isn't entirely necessary, but it does provide nice enhancements, like warning ## Change Log +### 1.2.3 + +- Fixed check for local css. If not found, loads hosted copy. + (This will soon be a moot point...) + ### 1.2.2 - On "Edit" page, images are now displayed directly, instead of a disabled textarea. From 0f7373b089f1dd349e9fab313eefcb558cc10d69 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Thu, 3 May 2012 23:21:35 -0400 Subject: [PATCH 052/228] Minor code spacing/formatting to .css --- onefilecms.css | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index 1351582..561f185 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -116,33 +116,17 @@ pre { } -.footer { - color: #777; - font-size: .7em; - /***************** - margin-top: 10px; - padding-top: 10px; - border-top: 01px solid #807568; /*using
    . Styles at bottom of this file - clear: both; - *****************/ - } +.footer { color: #777; font-size: .7em; } -.page_login label { - display: block; - margin-bottom: 2px; - } +.page_login label { display: block; margin-bottom: 2px; } -.alignleft { - margin: 0 10px 10px 0; - float: left; - } +.alignleft { margin: 0 10px 10px 0; float: left; } -#message { - min-height: 1.7em; /* Leave space when message is blank. Used by Edit page */ - } +/* Leave space when message is blank. Used by Edit page */ +#message { min-height: 1.7em; } #message p { margin: 0; @@ -268,10 +252,7 @@ table.index_T td { } -.index_folders { - min-height: 1.4em; - margin-bottom: .2em - } +.index_folders { min-height: 1.4em; margin-bottom: .2em; } .index_folders a { Xborder : 1px solid gray; @@ -414,7 +395,7 @@ input:hover { background-color: rgb(255,250,150); } border : 1px solid #807568; padding : 1em; width : 360px; -} + } .login_input { @@ -422,7 +403,7 @@ input:hover { background-color: rgb(255,250,150); } padding : 2px 0px 2px 2px; width : 356px; font : 1em Courier; -} + } From 5a634ed0bfebb1c72122a00b7b75848ebfcae1b0 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sat, 5 May 2012 21:48:40 -0400 Subject: [PATCH 053/228] Version 1.2.4 Made function to select style sheet (to prepare for a true "OneFileCMS") Made function to load Basic $_GET["i"] cleanup & check in session startup. Improved [Cancel] button - returns to prior page. Removed "error" from list of valid pages. (...it isn't.) Set default page title to $_SERVER['SERVER_NAME'] Shorted page titles- removed $filename. Now just "Copy", or "Delete", etc. Rename Folder returns to index of new folder (instead of parent). Improved several $message's. For several actions (new folder, new file, etc), made sure when successful to return to the new/destination directory. --- onefilecms.php | 351 +++++++++++++++++++++++++++++------------------- readme.markdown | 6 +- 2 files changed, 217 insertions(+), 140 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index fceb5b6..9f2fa1a 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,7 +2,7 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.2.3"; +$version = "1.2.4"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; @@ -52,6 +52,7 @@ //****************************************************************************** session_start(); global $page; $page = "index"; +global $pagetitle; $pagetitle = $_SERVER['SERVER_NAME']; if (isset($_POST["onefilecms_username"])) { $_SESSION['onefilecms_username'] = $_POST["onefilecms_username"]; } if (isset($_POST["onefilecms_password"])) { $_SESSION['onefilecms_password'] = $_POST["onefilecms_password"]; } @@ -69,21 +70,29 @@ unset($_GET["r"]); } -global $pagetitle; $pagetitle = "/"; -if ((isset($_GET["i"])) && ($_GET["i"] !== "")) { $pagetitle = "/".$_GET["i"]."/"; } - if (isset($_GET["p"])) { // redirect on invalid page attempts $page = $_GET["p"]; if (!in_array(strtolower($_GET["p"]), array( - "copy","delete","error","deletefolder","edit","folder","index","login","logout","new","rename","renamefolder","upload" ))) + "copy","delete","deletefolder","edit","folder","index","login","logout","new","rename","renamefolder","upload" ))) { header("Location: ".$ONESCRIPT); $page = "index"; } } -if ( ($page == "login") and ($_SESSION['onefilecms_valid']) ) {$page = "index"; header("Location: ".$ONESCRIPT);}; +//Check if "i" path exists & trim trailing slashes /// +if (isset($_GET["i"])) { + $_GET["i"] = rtrim($_GET["i"],"/"); + if (!file_exists($_GET["i"])) { $message = "Does not exist: ".$_GET["i"]; unset($_GET['p']);} + while (!is_dir($_GET["i"])) { $_GET["i"] = dirname($_GET["i"]); } + if ($_GET["i"] == '.') {unset($_GET["i"]);} +} + +if ( ($page == "login") and ($_SESSION['onefilecms_valid']) ) { + $page = "index"; + header("Location: ".$ONESCRIPT); +} if ($_GET["p"] == "login") { $pagetitle = "Log In"; } @@ -101,10 +110,8 @@ -// entitize get params ********************************************************* -foreach ($_GET as $name => $value) { - $_GET[$name] = htmlentities($value); -} +// entitize $_GET params ******************************************************* +foreach ($_GET as $name => $value) { $_GET[$name] = htmlentities($value); } @@ -112,23 +119,23 @@ //****************************************************************************** // Misc Functions -function Close_Button($classes) { + +function Close_Button($classes) { //******************** echo ''; ?>

    @@ -137,7 +144,54 @@ function Cancel_Submit_Buttons($button_label) {

    +

    + + + [X] + + +

    +

    ';} + } //end isset($message) +} //end message_box() ********************************* + + +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;} + else {$SCALE = $TOOHIGH;} + } + + echo '

    '; + echo 'Image shown at ~'. round($SCALE*100) .'% of full size ('.$img_info[3].').

    '; + echo '
    '; + echo ''; + echo ''; +}// end show_image() **************************** + // End of misc funtions ******************************************************** @@ -147,41 +201,41 @@ function Cancel_Submit_Buttons($button_label) { // COPY FILE ******************************************************************* if (isset($_GET["c"])) { - $page = "copy"; $filename = $_GET["c"]; $pagetitle = "Copy “".$filename."”"; + $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"]; copy($old_filename, $filename); - $message = ''.$old_filename." copied successfully to ".$filename."."; + $message = '"'.$old_filename.'" copied successfully to "'.$filename.'".'; } // DELETE FILE ***************************************************************** if (isset($_GET["d"])) { - $page = "delete"; $filename = $_GET["d"]; $pagetitle = "Delete “".$filename."”"; + $page = "delete"; $filename = $_GET["d"]; $pagetitle = "Delete"; } if (isset($_POST["delete_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { $filename = $_POST["delete_filename"]; unlink($filename); - $message = ''.$filename." successfully deleted."; + $message = '"'.$filename.'" successfully deleted.'; } // DELETE FOLDER *************************************************************** if ($_GET["p"] == "deletefolder") { - $pagetitle = "Delete Folder “".$_GET["i"]."”"; + $pagetitle = "Delete Folder"; } if (isset($_POST["delete_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { $foldername = $_POST["delete_foldername"]; if (@rmdir($foldername)) { - $message = ''.$foldername." successfully deleted."; + $message = '"'.$foldername.'" successfully deleted.'; } else { - $message = "That folder is not empty."; + $message = '(!) "'.$foldername.'" is not empty, or other error occurred.'; } } @@ -198,7 +252,7 @@ function Cancel_Submit_Buttons($button_label) { fwrite($fp, $content); fclose($fp); } - $message = ''.$filename." saved successfully."; + $message = '"'.$filename.'" saved successfully.'; }//*** //*** If in directory list, and a filename is clicked: @@ -206,7 +260,7 @@ function Cancel_Submit_Buttons($button_label) { $filename = stripslashes($_GET["f"]); if (file_exists($filename)) { $page = "edit"; - $pagetitle = "View/Edit “".$filename."”"; + $pagetitle = "Edit/View File"; $fp = @fopen($filename, "r"); if (filesize($filename) !== 0) { $filecontent = fread($fp, filesize($filename)); @@ -214,9 +268,9 @@ function Cancel_Submit_Buttons($button_label) { } fclose($fp); } else { - $page = "error"; + $page = "index"; + $message = '"'.$filename.'" does not exist.'; unset ($filename); - $message = "File does not exist."; } }//*** @@ -227,11 +281,12 @@ function Cancel_Submit_Buttons($button_label) { 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."; + $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."; + $message = '"'.$filename.'" created successfully.'; + $_GET["i"] = dirname($filename); //return to file's directory. } } @@ -243,9 +298,10 @@ function Cancel_Submit_Buttons($button_label) { $foldername = $_POST["new_folder"]; if (!is_dir($foldername)) { mkdir($foldername); - $message = ''.$foldername." created successfully."; + $message = '"'.$foldername.'" created successfully.'; + $_GET["i"] = $foldername; //change to new directory } else { - $message = "A folder by that name already exists."; + $message = 'A folder by that name already exists.'; } } @@ -254,25 +310,39 @@ function Cancel_Submit_Buttons($button_label) { // RENAME FILE ***************************************************************** if (isset($_GET["r"])) { $filename = $_GET["r"]; - $pagetitle = "Rename “".$filename."”"; + $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 + while (substr($filename, -1) == '/') { $filename = rtrim($filename, '/'); } + rename($old_filename, $filename); - $message = ''.$old_filename." successfully renamed to ".$filename."."; + $message = 'Successfully renamed:
    "'.$old_filename.'"
    To:
    "'.$filename.'"'; } // RENAME FOLDER *************************************************************** -if ($_GET["p"] == "renamefolder") {$pagetitle = "Rename Folder “".$_GET["i"]."”"; } +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, '/'); + } + while (substr($foldername, -1) == '/') { + $foldername = rtrim($foldername, '/'); + } + if (rename($old_foldername, $foldername)) { - $message = ''.$old_foldername." unsuccessfully renamed to ".$foldername."."; + $message = 'Successfully renamed:
    "'.$old_foldername.'"
    To:
    "'.$foldername.'".'; + $_GET["i"] = $foldername; //return to new folder } else { $message = "There was an error. Try again and/or contact your admin."; } @@ -284,35 +354,43 @@ function Cancel_Submit_Buttons($button_label) { 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"]; - if(move_uploaded_file($_FILES['upload_filename']['tmp_name'], - $destination.basename($filename))) { - $message = ''.basename($filename)." uploaded successfully to ".$destination."."; - } else{ - $message = "There was an error. Try again and/or contact your admin."; + $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."; + } +} //end Upload file -//****************************************************************************** -//****************************************************************************** -?> - - - - - -<?php echo $config_title.' - '.$pagetitle; ?> - - + +?> - + +//****************************************************************************** +function time_stamp_scripts() { ?> - + + + + + + + + + +<?php echo $config_title.' - '.$pagetitle; ?> + + + + + + + @@ -397,23 +504,13 @@ function FileTimeStamp(php_filemtime, show_offset){ + - -

    - - - [X]

    -'; }; - +

    - -// DELETE FILE ***************************************************************** + + +

    Delete “ @@ -452,11 +551,12 @@ function FileTimeStamp(php_filemtime, show_offset){

    - -// DELETE FOLDER *************************************************************** + +

    Delete Folder “

    @@ -468,43 +568,16 @@ function FileTimeStamp(php_filemtime, show_offset){

    - -// EDIT ************************************************************************ + + $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;} - else {$SCALE = $TOOHIGH;} - } - - echo '

    '.$img_info[3]; - echo ' (Image shown at ~'. round($SCALE*100) .'% of full size.)

    '; - echo '
    '; - echo '
    '; - echo ''; - }// end show_image() **************************** ?> - -

    File: “

    @@ -660,14 +733,14 @@ function Reset_File() { ... -}; //End Edit page ************************************************************* +}; //End Edit page ***********************************************************?> -// INDEX *********************************************************************** +

    '.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() { ?> - - ", basename($file), ""; ?> + + ', basename($file), ''; ?>   B @@ -831,20 +905,18 @@ function list_view() {

    - -// LOG OUT ********************************************************************* -if ($page == "logout") { - $page = "login"; -} + -// LOG IN ********************************************************************** +

    Log In

    @@ -860,13 +932,13 @@ function list_view() {
    - -// NEW FILE ******************************************************************** + @@ -876,16 +948,16 @@ function list_view() {

    - "> + /">

    - -// NEW FOLDER ****************************************************************** + @@ -895,16 +967,16 @@ function list_view() {

    - "> + /">

    - -// RENAME FILE ***************************************************************** +

    Rename “

    @@ -925,14 +997,15 @@ function list_view() {

    - -// RENAME FOLDER *************************************************************** + + $varvar = "?i=".substr($_GET["i"],0,strrpos(substr_replace($_GET["i"],"",-1),"/")); +?>

    Rename Folder “

    @@ -946,12 +1019,12 @@ function list_view() {

    - -// UPLOAD FILE ***************************************************************** +

    Upload

    @@ -960,7 +1033,7 @@ function list_view() {

    - " 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 Date: Mon, 7 May 2012 02:06:00 -0400 Subject: [PATCH 054/228] Version 1.2.5 Added js to list of editable file types. Added Check_ipath() Added is_empty($path). Will be used by Delete Folder. In message_box(), changed href in From: '?f='.$_GET["f"] To: '?'.$_SERVER['QUERY_STRING'] Some general code spacing in prep for upcoming changes. --- onefilecms.css | 9 +++++---- onefilecms.php | 48 +++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index 561f185..a5e324a 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -1,5 +1,5 @@ /* OneFileCMS - http://onefilecms.com/ - * Version 1.2.3 + * Version 1.2.5 * For license & copyright info, see OneFileCMS.License.BSD.txt */ @@ -34,7 +34,8 @@ fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td body { font-size: 1em; background: #d5d0cc; font-family: sans-serif; } -h2,h3,p,ul,table { margin-bottom: 10px; } +p, h3,ul,table { margin-bottom: .5em; } +h2 {margin-bottom: .2em;} em, i { font-style: italic; } @@ -126,7 +127,7 @@ pre { /* Leave space when message is blank. Used by Edit page */ -#message { min-height: 1.7em; } +#message { min-height: 1.7em; margin-bottom: .3em;} #message p { margin: 0; @@ -252,7 +253,7 @@ table.index_T td { } -.index_folders { min-height: 1.4em; margin-bottom: .2em; } +.index_folders { min-height: 1.7em; margin-bottom: .2em; } .index_folders a { Xborder : 1px solid gray; diff --git a/onefilecms.php b/onefilecms.php index 9f2fa1a..43b1718 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,7 +2,7 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.2.4"; +$version = "1.2.5"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; @@ -22,7 +22,7 @@ $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. -$config_editable = "html,htm,php,css,txt,text,cfg,conf,ini,csv,svg"; +$config_editable = "html,htm,php,css,js,txt,text,cfg,conf,ini,csv,svg"; $config_excluded = ""; //files to exclude from directory listings $config_itypes = "jpg,gif,png,bmp,ico"; // Can be displayed on edit page. $config_ftypes = "jpg,gif,png,bmp,ico,svg,txt,cvs,css,php,htm,html,cfg,conf"; //used to select file icon @@ -82,12 +82,15 @@ } //Check if "i" path exists & trim trailing slashes /// -if (isset($_GET["i"])) { - $_GET["i"] = rtrim($_GET["i"],"/"); - if (!file_exists($_GET["i"])) { $message = "Does not exist: ".$_GET["i"]; unset($_GET['p']);} - while (!is_dir($_GET["i"])) { $_GET["i"] = dirname($_GET["i"]); } - if ($_GET["i"] == '.') {unset($_GET["i"]);} -} +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"]);} + } +}//end Check_ipath() +Check_ipath(); if ( ($page == "login") and ($_SESSION['onefilecms_valid']) ) { $page = "index"; @@ -120,6 +123,15 @@ // 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 Close_Button($classes) { //******************** echo ''; @@ -154,7 +166,7 @@ function message_box() { //***************************** ?>

    - ' 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 Date: Mon, 7 May 2012 03:43:44 -0400 Subject: [PATCH 055/228] Version 1.2.6 Added $version after Logo Added favicon img & HTTP_HOST (name of web site) after Logo Tweaked wording on Delete Folder "..." ? page. Removed Block View (trimming down code a bit) Use (!is_empty($_GET["i"]) before Delete Folder screen. (if not empty, returns to same folder, instead of parent.) Improved New File response code a bit Improved New Folder response code a bit Tweaked Rename File $message. --- onefilecms.php | 133 +++++++++++++++++++------------------------------ 1 file changed, 51 insertions(+), 82 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 43b1718..2e6700f 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,18 +2,18 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.2.5"; +$version = "1.2.6"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; + // CONFIGURABLE INFO -$VIEW_MODE = "LIST"; // or BLOCK (Actually, anything =/= BLOCK == LIST) + $config_username = "username"; $config_password = "password"; $config_title = "OneFileCMS"; - $config_LOCAL = "/onefilecms/"; //local directory for icons, .css, .js, etc... $config_csslocal = "onefilecms.css"; //Relative to this file. //$config_csslocal ="/onefilecms.css"; //Relative to site URL root. @@ -42,13 +42,13 @@ $DOC_ROOT = $_SERVER["DOCUMENT_ROOT"]; $CWD = str_replace("\\","/",getcwd()); - //Allows OneFileCMS.php to be started from any dir on the site. chdir($DOC_ROOT); + //****************************************************************************** session_start(); global $page; $page = "index"; @@ -240,16 +240,18 @@ function show_image(){ //************************ // DELETE FOLDER *************************************************************** if ($_GET["p"] == "deletefolder") { - $pagetitle = "Delete Folder"; + 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 = '"'.$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){

    ', $config_title; ?> - + +
    + @@ -589,13 +609,12 @@ function FileTimeStamp(php_filemtime, show_offset){ -

    Delete Folder “

    -

    Folders have to be empty before they can be deleted.

    +

    Delete Folder  “ / ”  ?

    - "> - + "> +

    @@ -815,53 +834,6 @@ function Reset_File() { - - function BLOCK_view() { - global $varvar, $config_excluded, $ftypes, $fclasses ; - ?> -
    - - ?> - - - 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 Date: Mon, 7 May 2012 13:56:22 -0400 Subject: [PATCH 056/228] Version 1.2.7 Delete File - Added error response if unlink failed. Rename Folder - Simplified removal of trailing slashes Rename Folder - returns to index of new folder if rename successfull, parent otherwise. Upload File - Improved error response if no file selected for upload. Delete File - Simplified how $varvar set Delete Folder - Simplified how $varvar set Rename FOlder - Simplified how $varvar set Edit page - [Save] & [Reset] no longer disabled until loads/runs. [Rename Folder] moved to before [Delete Folder] Upload File - Improved/corrected URL for
    action. --- onefilecms.php | 109 +++++++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 49 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 2e6700f..bb072c6 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,7 +2,7 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.2.6"; +$version = "1.2.7"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; @@ -193,7 +193,7 @@ function show_image(){ //************************ if ($TOOHIGH || $TOOWIDE) { if (!$TOOWIDE) {$SCALE = $TOOHIGH;} elseif (!$TOOHIGH) {$SCALE = $TOOWIDE;} - elseif ($TOOHIGH > $TOOWIDE) {$SCALE = $TOOWIDE;} + elseif ($TOOHIGH > $TOOWIDE) {$SCALE = $TOOWIDE;} //ex:if (.90 > .50) else {$SCALE = $TOOHIGH;} } @@ -232,8 +232,12 @@ function show_image(){ //************************ if (isset($_POST["delete_filename"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { $filename = $_POST["delete_filename"]; - unlink($filename); - $message = '"'.$filename.'" successfully deleted.'; + + if (unlink($filename)) { + $message = '"'.$filename.'" successfully deleted.'; + }else{ + $message = '(!) Error deleting "'.$filename.'".'; + } } @@ -357,22 +361,20 @@ function show_image(){ //************************ if (isset($_POST["rename_foldername"]) && $_SESSION['onefilecms_valid'] = "1" && $_POST["sessionid"] == session_id()) { $old_foldername = $_POST["old_foldername"]; - $foldername = $_POST["rename_foldername"]; - + $foldername = $_POST["rename_foldername"]; + $_GET["i"] = $old_foldername; + Check_ipath(); //Removed any trailing slashes - while (substr($old_foldername, -1) == '/') { - $old_foldername = rtrim($old_foldername, '/'); - } - while (substr($foldername, -1) == '/') { - $foldername = rtrim($foldername, '/'); - } + $old_foldername = rtrim($old_foldername, '/'); + $foldername = rtrim($foldername, '/'); if (rename($old_foldername, $foldername)) { - $message = 'Successfully renamed:
    "'.$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 “

    Are you sure?

    @@ -608,8 +617,9 @@ function FileTimeStamp(php_filemtime, show_offset){ -

    Delete Folder  “ / ”  ?

    + $varvar = "?i=".substr($_GET["i"],0,strrpos(substr_replace($_GET["i"],"",-1),"/")); + +?>

    Delete Folder  “ / ”  ?

    @@ -658,8 +668,8 @@ function FileTimeStamp(php_filemtime, show_offset){

    - - + + @@ -897,10 +907,10 @@ function list_view() { New File New Folder - - Delete Folder Rename Folder + + Delete Folder

    @@ -1003,7 +1013,7 @@ function list_view() {

    Rename Folder “

    @@ -1025,9 +1035,10 @@ function list_view() { -

    Upload

    - " method="post"> + $varvar = ""; if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; } + +?>

    Upload

    +

    From 58557347f1ba1469c2ad3e1bcec513b999144e66 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Tue, 8 May 2012 20:07:01 -0400 Subject: [PATCH 057/228] Version 1.2.8 Simplified variable/s for style sheet: $config_style_sheet Deleted style_sheet() as superfluous Added show_favicon() to confirm it exists. Renamed variable values for $page & ?p=, from "folder" to "newfolder" Tweaked $message line hieght. Improved Copy File response code & $message. Adjusted Delete File $message. Adjusted Delete Folder $message. Adjusted New Folder $message. Adjusted Rename File $message. Adjusted Rename Folder $message. Adjusted Upload File $message. Wrapped edit page into a php function, moved above --- onefilecms.css | 62 ++------ onefilecms.php | 376 ++++++++++++++++++++++++------------------------ readme.markdown | 6 +- 3 files changed, 195 insertions(+), 249 deletions(-) mode change 100644 => 100755 readme.markdown diff --git a/onefilecms.css b/onefilecms.css index a5e324a..e83f15c 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -1,5 +1,5 @@ /* OneFileCMS - http://onefilecms.com/ - * Version 1.2.5 + * Version 1.2.8 * For license & copyright info, see OneFileCMS.License.BSD.txt */ @@ -15,17 +15,9 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big, cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li, fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td - { - border : 0; - outline: 0; - margin : 0; - padding: 0; - font-weight: inherit; - font-style : inherit; - font-size : 100%; - font-family: inherit; - vertical-align: baseline; - } +{border : 0; outline: 0; margin : 0; padding: 0; +font-family: inherit; font-weight: inherit; font-style : inherit; +font-size : 100%; vertical-align: baseline; } @@ -90,7 +82,6 @@ pre { - /* --- layout --- */ .container { @@ -135,50 +126,13 @@ pre { border: 1px solid #807568; font-family: Lucida Console, "Courier New" ; font-size: .95em; - line-height: 1em; + line-height: 1.2em; background: #fff000; } #message span { float: right; } -#message a { padding: 4px 1px 4px 1px; border-right: none; } /*T R B L*/ - - - -/* --- INDEX --- */ - -.index { width: 810px; } - -.index li { - margin: 0 10px 10px 0; - width: 260px; - float: left; - position: relative; - } - -.index a { - height: 20px; - display: block; - padding: 7px 5px 7px 35px; - border: 1px solid #807568; - text-decoration: none; - background: #F8F8F8 url("http://self-evident.github.com/OneFileCMS/images/file-bin.png") 3px no-repeat; - overflow: hidden; - line-height: 1em; - } - -.index a.bin { background:white url("http://self-evident.github.com/OneFileCMS/images/file-bin.png") 3px no-repeat; } -.index a.img { background:white url("http://self-evident.github.com/OneFileCMS/images/file-img.png") 3px no-repeat; } -.index a.txt { background:white url("http://self-evident.github.com/OneFileCMS/images/file-txt.png") 3px no-repeat; } -.index a.cfg { background:white url("http://self-evident.github.com/OneFileCMS/images/file-cfg.png") 3px no-repeat; } -.index a.css { background:white url("http://self-evident.github.com/OneFileCMS/images/file-css.png") 3px no-repeat; } -.index a.htm { background:white url("http://self-evident.github.com/OneFileCMS/images/file-htm.png") 3px no-repeat; } -.index a.php { background:white url("http://self-evident.github.com/OneFileCMS/images/file-php.png") 3px no-repeat; } -.index a.svg { background:white url("http://self-evident.github.com/OneFileCMS/images/file-svg.png") 3px no-repeat; } - -.index a:hover { background-color: rgb(255,250,150); } -.index a:focus { background-color: rgb(255,250,150); } - +#message a { padding: 6px 1px 5px 1px; border-right: none; } /*T R B L*/ /* --- INDEX directory listing, table format --- */ @@ -256,7 +210,7 @@ table.index_T td { .index_folders { min-height: 1.7em; margin-bottom: .2em; } .index_folders a { - Xborder : 1px solid gray; + border : 1px solid #807568; display : inline-block; line-height : 1.1em; font-size : 1em; @@ -391,7 +345,7 @@ input:hover { background-color: rgb(255,250,150); } /* --- log in --- */ -.page_login .container, .page_logout .container { +.page_login .container { margin-top: 5em; border : 1px solid #807568; padding : 1em; diff --git a/onefilecms.php b/onefilecms.php index bb072c6..3f41aca 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,7 +2,7 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.2.7"; +$version = "1.2.8"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; @@ -14,14 +14,15 @@ $config_username = "username"; $config_password = "password"; $config_title = "OneFileCMS"; -$config_LOCAL = "/onefilecms/"; //local directory for icons, .css, .js, etc... -$config_csslocal = "onefilecms.css"; //Relative to this file. -//$config_csslocal ="/onefilecms.css"; //Relative to site URL root. -$config_csshosted = "http://self-evident.github.com/OneFileCMS/onefilecms.css"; + +$config_style_sheet = "onefilecms.css"; //Relative to this file. +//$config_style_sheet ="/onefilecms.css"; //Relative to site URL root. +//$config_style_sheet = "http://self-evident.github.com/OneFileCMS/onefilecms.css"; $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. +$config_favicon = "/favicon.ico"; $config_editable = "html,htm,php,css,js,txt,text,cfg,conf,ini,csv,svg"; $config_excluded = ""; //files to exclude from directory listings $config_itypes = "jpg,gif,png,bmp,ico"; // Can be displayed on edit page. @@ -39,8 +40,8 @@ $ONESCRIPT = $_SERVER["SCRIPT_NAME"]; -$DOC_ROOT = $_SERVER["DOCUMENT_ROOT"]; -$CWD = str_replace("\\","/",getcwd()); +$DOC_ROOT = $_SERVER["DOCUMENT_ROOT"].'/'; +$WEBSITE = $_SERVER["HTTP_HOST"]; //Allows OneFileCMS.php to be started from any dir on the site. chdir($DOC_ROOT); @@ -74,7 +75,7 @@ // redirect on invalid page attempts $page = $_GET["p"]; if (!in_array(strtolower($_GET["p"]), array( - "copy","delete","deletefolder","edit","folder","index","login","logout","new","rename","renamefolder","upload" ))) + "copy","delete","deletefolder","edit","newfolder","index","login","logout","new","rename","renamefolder","upload" ))) { header("Location: ".$ONESCRIPT); $page = "index"; @@ -101,7 +102,7 @@ function Check_ipath() { global $message; if ($_GET["p"] == "logout") { $page = "login"; - $pagetitle = "Log Out"; + $pagetitle = "Login"; $_SESSION['onefilecms_valid'] = "0"; session_destroy(); $message = 'You have successfully logged out.'; @@ -122,7 +123,6 @@ function Check_ipath() { global $message; //****************************************************************************** // Misc Functions - function is_empty($path){ $empty = false; $dh = opendir($path); @@ -132,6 +132,7 @@ function is_empty($path){ }//end is_emtpy() + function Close_Button($classes) { //******************** echo ''; @@ -139,6 +140,7 @@ function Close_Button($classes) { //******************** }// End Close_Button() //******************************* + function Cancel_Submit_Buttons($button_label) { //****** global $ONESCRIPT, $varvar; @@ -159,8 +161,9 @@ function Cancel_Submit_Buttons($button_label) { //****** }// End Cancel_Submit_Buttons() //********************** + function message_box() { //***************************** - global $message, $page, $ONESCRIPT; + global $ONESCRIPT, $message, $page; if (isset($message)) { ?> @@ -179,7 +182,8 @@ function message_box() { //***************************** } //end message_box() ********************************* -function show_image(){ //************************ + +function show_image(){ //******************************* global $filename, $MAX_IMG_W, $MAX_IMG_H; $IMG = $filename; @@ -202,16 +206,26 @@ function show_image(){ //************************ echo '

    '; echo ''; echo ''; -}// 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; } - - -?> + + - - + - - - - <?php echo $config_title.' - '.$pagetitle; ?> + + - - + + @@ -554,12 +652,13 @@ function FileTimeStamp(php_filemtime, show_offset){ -
    - + @@ -680,119 +779,14 @@ function FileTimeStamp(php_filemtime, show_offset){ - + +
    NOTE: On 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].
    - - - - - - - ... + -}; //End Edit page ***********************************************************?> + @@ -905,7 +899,7 @@ function list_view() {

    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-Evident Date: Tue, 8 May 2012 20:46:04 -0400 Subject: [PATCH 058/228] Version 1.2.9 Copy File page, "simplified" how $slug is generated. Buttons on Edit page- removed unused name attributes. Use id if needed. Edit page- cleaned up a tiny bit. Copy File, Delete Folder, Edit, New File, New Folder, Rename File - adjusted how $varvar is determined. Corrected/normalized form action url among pages. --- onefilecms.php | 59 +++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 3f41aca..dc7ed90 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,7 +2,7 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.2.8"; +$version = "1.2.9"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; @@ -670,11 +670,15 @@ function Reset_File() { + + $extension = strrchr($filename, "."); + $slug = dirname($filename).'/'.pathinfo($filename,PATHINFO_FILENAME); + $varvar = "?i=".dirname($_GET["c"]); + $new_filename = $slug."_COPY_".date("YmdHi").$extension; +?>

    Copy “

    -

    Existing 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() {

    - "> +

    @@ -734,24 +739,23 @@ function Reset_File() {

    File: “

    -
    - +

    Size: bytes     Updated:

    -
    -

    @@ -761,17 +765,15 @@ function Reset_File() {

    - - - - + +

    - - - - - + + + + +

    @@ -944,10 +946,11 @@ function list_view() { + if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; } +?>

    New 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"]; } +?>

    New Folder

    Existing folders with the same name will not be overwritten.

    - "> +

    @@ -981,12 +985,13 @@ function list_view() { + $varvar = "?i=".dirname($_GET["r"]); +?>

    Rename “

    -

    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 Date: Thu, 10 May 2012 17:31:17 -0400 Subject: [PATCH 059/228] Version 1.3.0 Code for pages now in functions: Login_Page(), Edit_Page(), Index_Page(), Upload_Page(), New_File_Page(), Copy_File_Page(), Rename_File_Page(), Delete_File_Page(), Delete_Folder_Page() New_Folder_Page(), Rename_Folder_Page() -Overall, added a couple dozed lines to the code, but it's easier to manage. Added + +function list_files() { // ...in a vertical table ****************************** + +global $ONESCRIPT, $varvar, $config_excluded, $ftypes, $fclasses; + +$files = glob($varvar."{,.}*", GLOB_BRACE); +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; + } + } - + + +'; +}//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; } + +

    + '; + + echo basename($folder).' /'; + } ?> +

    + + - document.write( DATETIME ); + + + - - -
    +

    + +
    + +

    + +

    + +

    + + +

    + + + +

    + + + + + + + +

    + +
    + + + +
    + NOTE: On 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]. +
    + - // The following events only apply when the element is active. - // [Save] is disabled unless there are changes to the open file. - Save_File_button.onfocus = function() {Save_File_button.style.backgroundColor = "rgb(255,250,150)";} - Save_File_button.onblur = function() {Save_File_button.style.backgroundColor ="#Fee";} - Save_File_button.onmouseover = function() {Save_File_button.style.backgroundColor = "rgb(255,250,150)";} - Save_File_button.onmouseout = function() {Save_File_button.style.backgroundColor = "#Fee";} + +

    Upload

    + + + +

    + + /" class="textinput"> +

    +

    + + +

    +

    + + - - +

    New File

    +

    Existing files with the same name will not be overwritten.

    + + +

    + + /"> +

    +

    + + - - - - -<?php echo $config_title.' - '.$pagetitle; ?> - - - - - - - - - - - - - -
    - -
    - ', $config_title; ?> - +function Copy_File_Page(){ //*************************************************** + global $ONESCRIPT, $varvar, $filename; - - - -
    - - - - - - - - -">

    - + +

    Rename “

    +

    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.

    -?>

    Delete “ -

    +
    + +

    + + + +

    +

    + + +

    +

    + + +

    Delete “ + ” ?

    Are you sure?

    @@ -714,355 +786,312 @@ class="textinput" value="">

    - +

    Delete Folder  “ / ”  ?

    +function New_Folder_Page() { //************************************************* + global $ONESCRIPT, $varvar; + $varvar = ""; + if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; } +?> +

    New Folder

    +

    Existing folders with the same name will not be overwritten.

    - "> - + + /">

    +

    - + -

    File: “ - -

    - -
    -

    - Size: bytes     - Updated:
    +

    Rename Folder “

    + + +

    + "> + " class="textinput" disabled="disabled">

    +

    + + "> +

    +

    + + +

    Delete Folder  “ / ”  ?

    +
    -
    - -

    - -

    - -

    - - -

    - - - -

    - - - - - - +

    + "> +

    -
    + - - -
    - NOTE: On 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]. -
    - - -'; - $full_path = basename(getcwd()); - if (isset($_GET["i"])) { $full_path = basename(getcwd()).'/'.$_GET["i"]; } +function Load_Selected_Page(){ //*********************************************** + global $page; + if ($page == "login") { Login_Page(); } + if ($page == "index") { Index_Page(); } + if ($page == "edit") { Edit_Page(); } + if ($page == "upload") { Upload_Page(); } + if ($page == "new") { New_File_Page(); } + if ($page == "copy") { Copy_File_Page(); } + if ($page == "rename") { Rename_File_Page(); } + if ($page == "delete") { Delete_File_Page(); } + if ($page == "newfolder") { New_Folder_Page(); } + if ($page == "renamefolder") { Rename_Folder_Page(); } + if ($page == "deletefolder") { Delete_Folder_Page(); } +}//end Load_Selected_Page() **************************************************** - $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]." /"; - } - ?> - -

    - '; - echo basename($folder).' /'; - } ?> -

    - - function list_view() { - - global $ONESCRIPT, $varvar, $config_excluded, $ftypes, $fclasses; - - $files = glob($varvar."{,.}*", GLOB_BRACE); - 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) { - - //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() { ?> + + + - - +function Edit_Page_javascript() { //******************************************** +?> + + - + function Reset_file_status_indicators() { + changed = false; + File_textarea.style.backgroundColor = "#eFe"; //light green + Save_File_button.style.backgroundColor = ""; + Save_File_button.style.borderColor = ""; + Save_File_button.style.borderWidth = "1px"; + Save_File_button.disabled = "disabled"; + Save_File_button.value = "Save"; + Reset_button.disabled = "disabled"; + //File_textarea.focus(); + } + window.onbeforeunload = function() { + if ( changed && !submitted) { + //FF4+ Ingores the supplied msg below & only uses a system msg for the prompt. + return " Unsaved changes will be lost!"; + } + } - -

    New File

    -

    Existing files with the same name will not be overwritten.

    - - -

    - - /"> -

    -

    - - + window.onunload = function() { + //without this, a browser back then forward would reload file with local/ + // unsaved changes, but with a green b/g as tho that's the file's contents. + if (!submitted) { + File_textarea.value = start_value; + Reset_file_status_indicators(); + } + } + //With selStart & selEnd == 0, moves cursor to start of text field. + function setSelRange(inputEl, selStart, selEnd) { + if (inputEl.setSelectionRange) { + inputEl.focus(); + inputEl.setSelectionRange(selStart, selEnd); + } else if (inputEl.createTextRange) { + var range = inputEl.createTextRange(); + range.collapse(true); + range.moveEnd('character', selEnd); + range.moveStart('character', selStart); + range.select(); + } + } - -

    New Folder

    -

    Existing folders with the same name will not be overwritten.

    - - -

    - - /"> -

    -

    - - + function Check_for_changes(event){ + var keycode=event.keyCode? event.keyCode : event.charCode; + changed = (File_textarea.value != start_value); + if (changed){ + document.getElementById('message').innerHTML = " "; // Must have a space, or it won't clear the msg. + File_textarea.style.backgroundColor = "#Fee"; //light red + Save_File_button.style.backgroundColor ="#Fee"; + Save_File_button.style.borderColor = "#F44"; //less light red + Save_File_button.style.borderWidth = "1px"; + Save_File_button.disabled = ""; + Reset_button.disabled = ""; + Save_File_button.value = "SAVE CHANGES!"; + }else{ + Reset_file_status_indicators() + } + } + //Reset textarea value to when page was loaded. + //Used by [Reset] button, and when page unloads (browser back, etc). + //Needed becuase if the page is reloaded (ctl-r, or browser back/forward, etc.), + //the text stays changed, but "changed" gets set to false, which looses warning. + function Reset_File() { + if (changed) { + if ( !(confirm("Reset file and loose unsaved changes?")) ) { return; } + } + File_textarea.value = start_value; + Reset_file_status_indicators(); + setSelRange(File_textarea, 0, 0) //MOve cursor to start of textarea. + } + + + Reset_file_status_indicators() + + -

    Rename “

    -

    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.

    - - -

    - - - -

    -

    - - -

    -

    - - - -

    Rename Folder “

    - - -

    - "> - " class="textinput" disabled="disabled"> -

    -

    - - "> -

    -

    - - +//****************************************************************************** +//****************************************************************************** +?> + + +<?php echo $config_title.' - '.$pagetitle; ?> + + - + + + + + + + + +
    + +
    + ', $config_title; ?> + -?>

    Upload

    -
    - - -

    - - /" class="textinput"> -

    -

    - - -

    -

    - - + + + +
    + - + + +
    - diff --git a/readme.markdown b/readme.markdown index 257e7ac..354b05c 100755 --- a/readme.markdown +++ b/readme.markdown @@ -1,3 +1,5 @@ +# Current "stable" version: 1.2.3 +-------------------------------------------------------------------------------- ### April 30, 2012 # NOTICE - SECURITY HOLE! (Fixed in version 1.2.1) @@ -111,9 +113,13 @@ It isn't entirely necessary, but it does provide nice enhancements, like warning ## Change Log -### 1.2.4 - 1.2.8 +### 1.2.4 - 1.3.0 -- Mostly just a bunch of code modifications/improvements. +- DO NOT USE THESE VERSIONS! +- Mostly just a bunch of code modifications. +- These versions have issues, primarily when on the home/root page your site, + and attempting to [Upload File], [New File], [New Folder], or when editing + a file. ### 1.2.3 From 591e896cf9de6ad35c9126d2ae8e0719ad3e17db Mon Sep 17 00:00:00 2001 From: David Date: Fri, 18 May 2012 15:29:28 -0400 Subject: [PATCH 060/228] Version 1.4.0 Substantial code reorganization & improvements. --- onefilecms.css | 141 ++++--- onefilecms.php | 1034 +++++++++++++++++++++++++---------------------- readme.markdown | 21 +- 3 files changed, 629 insertions(+), 567 deletions(-) diff --git a/onefilecms.css b/onefilecms.css index d12d6bf..a960a00 100755 --- a/onefilecms.css +++ b/onefilecms.css @@ -1,11 +1,11 @@ /* OneFileCMS - http://onefilecms.com/ - * Version 1.3.0 + * Version 1.4.0 * For license & copyright info, see OneFileCMS.License.BSD.txt */ -/* #774200 #807568 #976322 #995400 #d4d4d4 #0F0901 #eaeaea rgb(255,250,150) - rgb(157, 124, 83) rgb(157, 124, 83) +/* #d5d0cc #774200 #807568 #976322 #995400 #d4d4d4 #0F0901 #eaeaea + rgb(255,250,150) rgb(157, 124, 83) rgb(157, 124, 83) rgb(255,250,150) rgb(255,250,150) #969376 rgb(255,245,115) */ @@ -15,7 +15,7 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big, cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li, fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td -{border : 0; outline: 0; margin : 0; padding: 0; +{border : 0; outline: 0; margin : 0; padding: 0; font-family: inherit; font-weight: inherit; font-style : inherit; font-size : 100%; vertical-align: baseline; } @@ -24,10 +24,16 @@ font-size : 100%; vertical-align: baseline; } /* --- general formatting --- */ -body { font-size: 1em; background: #d5d0cc; font-family: sans-serif; } +body { font-size: 1em; background: #DDD; font-family: sans-serif; } -p, h3,ul,table { margin-bottom: .5em; } -h2 {margin-bottom: .2em;} +p, table { margin-bottom: .5em; } + +div{position: relative;} + +h1,h2,h3,h4,h5,h6{font-weight: bold;} +h2 { font-size: 20px; margin: 0 1em .2em 0;} /*TRBL*/ +h3 { font-size: 18px; margin-top: 15px; } +h4 { font-size: 1.3em; margin-bottom: .2em; font-weight: normal;} em, i { font-style: italic; } @@ -46,13 +52,6 @@ caption,th,td{text-align:left;font-weight:400;} blockquote:before,blockquote:after,q:before,q:after{content:"";} blockquote,q{quotes:"" "";} -div{position: relative;} - -h1,h2,h3,h4,h5,h6{font-weight: bold;} -h2 { font-size: 20px; } -h3 { font-size: 18px; margin-top: 15px; } -h4 { font-size: 1.3em; margin-bottom: .2em; font-weight: normal;} - a { border: 1px solid transparent; color: rgb(100,45,0); text-decoration: none; } a:hover { border: 1px solid #807568; background-color: rgb(255,250,150); } a:focus { border: 1px solid #807568; background-color: rgb(255,250,150); } @@ -60,12 +59,7 @@ a:focus { border: 1px solid #807568; background-color: rgb(255,250,150); } form p { margin-bottom: 5px; } -label { - display: inline-block; - width : 7em; - font-size : 14px; - font-style: italic; - } +label { display: inline-block; width : 7em; font-size : 1em; } pre { @@ -80,8 +74,6 @@ pre { } - - /* --- layout --- */ .container { @@ -111,28 +103,36 @@ pre { .footer { color: #777; font-size: .7em; } -.page_login label { display: block; margin-bottom: 2px; } +.alignleft { margin: 0 10px 10px 0; float: left; } + +.dirname { font-weight: 400; } -.alignleft { margin: 0 10px 10px 0; float: left; } +.filename { + border: 1px solid #807568; + padding: .1em .2em .1em .2em; + font-weight: 700; + font-family: courier; + background-color: #EEE; + } -/* Leave space when message is blank. Used by Edit page */ -#message { min-height: 1.7em; margin-bottom: .3em;} +#message {margin: .5em 0;} #message p { margin: 0; padding: 4px 0px 4px .5em; border: 1px solid #807568; - font-family: Lucida Console, "Courier New" ; - font-size: .95em; + Xfont-family: courier; + font-size: 1em; line-height: 1.2em; background: #fff000; } #message span { float: right; } -#message a { padding: 6px 1px 5px 1px; border-right: none; } /*T R B L*/ +/* #message a { font-family: Courier; font-size: 1.2em; padding: 4px 2px 3px 2px; border-right: none;} */ +#message a { padding: 5px 4px 5px 4px; border-right: none; } /*T R B L */ /* --- INDEX directory listing, table format --- */ @@ -144,7 +144,7 @@ table.index_T { border-color: #807568; border-collapse: collapse; margin-bottom: .7em; - background-color: #F8F8F8; + background-color: #FdFdFd; } table.index_T tr:hover { border: 1px solid #807568; } @@ -166,7 +166,6 @@ table.index_T td { overflow : hidden; } -/* background : url("http://self-evident.github.com/OneFileCMS/images/silk_file.png") 4px no-repeat;*/ .index_T a.txt { background: url("http://self-evident.github.com/OneFileCMS/images/file-txt.png") 3px no-repeat; } .index_T a.htm { background: url("http://self-evident.github.com/OneFileCMS/images/file-htm.png") 3px no-repeat; } @@ -210,13 +209,13 @@ table.index_T td { .index_folders { min-height: 1.7em; margin-bottom: .2em; } .index_folders a { - border : 1px solid #807568; + Xborder : 1px solid #807568; display : inline-block; - line-height : 1.1em; + line-height : 1em; font-size : 1em; margin-right : .6em; - margin-bottom: .3em; - padding : .1em .4em .1em 25px; /*TRBL*/ + margin-bottom: .1em; + padding : 3px .4em 3px 25px; /*TRBL*/ background : url("http://self-evident.github.com/OneFileCMS/images/folder-2.png") 4px 3px no-repeat; } @@ -238,27 +237,28 @@ table.index_T td { display: inline-block; } -.front_links a.upload { background: url("http://self-evident.github.com/OneFileCMS/images/upload.png") 3px 3px no-repeat; } -.front_links a.new { background: url("http://self-evident.github.com/OneFileCMS/images/file-new-2.png") 3px 4px no-repeat; } -.front_links a.newfolder { background: url("http://self-evident.github.com/OneFileCMS/images/folder-new-2.png") 2px 5px no-repeat; } -.front_links a.renamefolder { background: url("http://self-evident.github.com/OneFileCMS/images/folder-rename-1.png") 1px 4px no-repeat; } -.front_links a.deletefolder { background: url("http://self-evident.github.com/OneFileCMS/images/folder-del-3.png") 1px 5px no-repeat; } -.front_links a.settings { background: url("http://self-evident.github.com/OneFileCMS/images/settings.png") 2px 3px no-repeat; } +.front_links a.upload { background: #EEE url("http://self-evident.github.com/OneFileCMS/images/upload.png") 3px 3px no-repeat; } +.front_links a.new { background: #EEE url("http://self-evident.github.com/OneFileCMS/images/file-new-2.png") 3px 4px no-repeat; } +.front_links a.newfolder { background: #EEE url("http://self-evident.github.com/OneFileCMS/images/folder-new-2.png") 2px 5px no-repeat; } +.front_links a.renamefolder { background: #EEE url("http://self-evident.github.com/OneFileCMS/images/folder-rename-1.png") 1px 4px no-repeat; } +.front_links a.deletefolder { background: #EEE url("http://self-evident.github.com/OneFileCMS/images/folder-del-3.png") 1px 5px no-repeat; } .front_links a:hover { background-color: rgb(255,250,150); } .front_links a:focus { background-color: rgb(255,250,150); } -form .meta { z-index: -1; } - -.textinput { +input[type="text"] { border: 1px solid #807568; padding: 2px; - width: 650px; + width: 630px; font: 1em "Courier New", Courier, monospace; } -textarea.textinput { +input.textinput1 { width: 20em; } + +input.textinput2 { width: 40em; } + +textarea { border: 1px solid #999; font : .95em "Courier New", Courier, monospace; margin: 0 0 .5em 0; /*T R B L*/ @@ -267,16 +267,20 @@ textarea.textinput { height: 30em; } -textarea.disabled { height: 50px; } +textarea[disabled ]{ width : 99.5%; height: 50px; } textarea:focus { border: 1px solid #Faa; } input:focus { background-color: rgb(255,250,150); } -/* input[type="button"]:focus { background-color: rgb(255,250,150); } */ input:hover { background-color: rgb(255,250,150); } +input[readonly] { color: #333; background-color: #EEE; } +input[disabled] { color: #555; background-color: #EEE; } +input[disabled]:hover { background-color: rgb(236,233,216); } +input[disabled]:hover { background-color: rgb(236,233,216); } + .buttons_right { float: right; } .buttons_right .button { margin-left: 7px; } @@ -286,21 +290,13 @@ input:hover { background-color: rgb(255,250,150); } .button { border: 1px solid #807568; padding: 4px 10px; - background-color: #d4d4d4; + background-color: #EEE; /*#d4d4d4*/ cursor: pointer; font-size: .9em; font-family: sans-serif; } -.Xbutton:hover { background-color: rgb(255,250,150); } -.button[disabled]:hover { background-color: #d4d4d4; cursor:default } - -/* -#Xsave_file { border: 1px solid red; } -#save_file a:hover { background-color: rgb(255,250,150); border: 1px solid red; } -#save_file a:focus { background-color: rgb(255,250,150); border: 1px solid red; } -*/ - +.button[disabled] { color: #777; background-color: #EEE; } #action {color: white; background-color: rgb(235,70,70); font-weight: 700;} @@ -343,23 +339,26 @@ input:hover { background-color: rgb(255,250,150); } #edit_note {font-size: .8em; color: #444 ;margin-top: 1em;} + + /* --- log in --- */ -.page_login .container { - margin-top: 5em; - border : 1px solid #807568; - padding : 1em; - width : 360px; +.login_page { + margin : 5em auto; + border : 1px solid #807568; + padding : 1em; + width : 360px; } - .login_input { border : 1px solid #807568; padding : 2px 0px 2px 2px; width : 356px; - font : 1em Courier; + font : 1em "Courier New"; } +input[type="text"].login_input { width : 354px; } + /* --- --- --- */ @@ -377,3 +376,15 @@ hr { Xborder-bottom: 1px solid #eee; overflow: visible; } + +.web_root { font:1.2em Courier; } + +.sure { margin: .5em 0em .5em 0; } + +.verify { + border: 1px solid #807568; + color: #333; + background-color: #FEE; + padding: 2px .3em; + font: 1.2em Courier; + } diff --git a/onefilecms.php b/onefilecms.php index b63f6e0..a70b929 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,15 +2,13 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.3.0"; +$version = "1.4.0"; if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; - -// CONFIGURABLE INFO - +// CONFIGURABLE INFO *********************************************************** $config_username = "username"; $config_password = "password"; $config_title = "OneFileCMS"; @@ -28,7 +26,7 @@ $config_itypes = "jpg,gif,png,bmp,ico"; // Can be displayed on edit page. $config_ftypes = "jpg,gif,png,bmp,ico,svg,txt,cvs,css,php,htm,html,cfg,conf,js"; //used to select file icon $config_fclass = "img,img,img,img,img,svg,txt,txt,css,php,htm,htm,cfg,cfg,txt"; //used to select file icon -// END CONFIGURABLE INFO +// END CONFIGURABLE INFO ******************************************************* @@ -39,10 +37,16 @@ $itypes = (explode(",", strtolower($config_itypes))); +$valid_pages = array("login","logout","index","edit","upload","new","copy","rename","delete","newfolder","renamefolder","deletefolder" ); + $ONESCRIPT = $_SERVER["SCRIPT_NAME"]; $DOC_ROOT = $_SERVER["DOCUMENT_ROOT"].'/'; +$WEB_ROOT = basename($DOC_ROOT).'/'; $WEBSITE = $_SERVER["HTTP_HOST"]; +$pagetitle = $_SERVER['SERVER_NAME']; + + //Allows OneFileCMS.php to be started from any dir on the site. chdir($DOC_ROOT); @@ -52,70 +56,76 @@ //****************************************************************************** session_start(); -global $page; $page = "index"; -global $pagetitle; $pagetitle = $_SERVER['SERVER_NAME']; - -if (isset($_POST["onefilecms_username"])) { $_SESSION['onefilecms_username'] = $_POST["onefilecms_username"]; } -if (isset($_POST["onefilecms_password"])) { $_SESSION['onefilecms_password'] = $_POST["onefilecms_password"]; } - -if (($_SESSION['onefilecms_username'] == $config_username) and ($_SESSION['onefilecms_password'] == $config_password || md5($_SESSION['onefilecms_password']) == $config_password)) { - $_SESSION['onefilecms_valid'] = "1"; -} else { - $_SESSION['onefilecms_valid'] = "0"; - $page = "login"; - $_GET["p"] = "login"; - unset($_GET["c"]); - unset($_GET["d"]); - unset($_GET["f"]); - unset($_GET["i"]); - unset($_GET["r"]); -} -if (isset($_GET["p"])) { - // redirect on invalid page attempts - $page = $_GET["p"]; - if (!in_array(strtolower($_GET["p"]), array( - "copy","delete","deletefolder","edit","newfolder","index","login","logout","new","rename","renamefolder","upload" ))) - { - header("Location: ".$ONESCRIPT); - $page = "index"; +//*** Verify session ******************* +if (isset($_POST["username"])) { $_SESSION['username'] = $_POST["username"]; } +if (isset($_POST["password"])) { $_SESSION['password'] = $_POST["password"]; } + +if (($_SESSION['username'] == $config_username) and + ( $_SESSION['password'] == $config_password || md5($_SESSION['password']) == $config_password)) + { $_SESSION['valid'] = "1"; $page = "index"; } +else { $_SESSION['valid'] = "0"; $page = "login"; unset($_GET["p"]); } + + + +//*** entitize $_GET params ************ +foreach ($_GET as $name => $value) { $_GET[$name] = htmlentities($value); } + + + +//*** Clean up & check a path ********** +function Check_path($path) { // returns first valid path in some/supplied/path/ + global $message; + $nopath = $path; //used for message if supplied $path doesn't exist. + $path = str_replace('\\','/',$path); //Make sure all forward slashes. + $path = trim($path,"/ ."); // trim leading & trailing slashes, dots, and spaces + + //Remove any '.' and '..' parts of the path. (More reliable than str_replace.) + $pathparts = explode( '/', $path); + $len = count($pathparts); + $path = ""; //Cleaned path. + for ($x=0 ; $x < $len; $x++ ) { + if ( !(($pathparts[$x] == '..') && (!$pathparts[$x] == '.')) ) { + $path .= $pathparts[$x].'/'; + } } -} + $path = trim($path,"/"); // Remove -for now- final trailing slash. + + if (strlen($path) < 1) { $path = ""; } + else { + if (!is_dir($path) && (strlen($message) < 1)) + { $message .= "(!) Directory does not exist: ".$nopath.'
    '; } -//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 isset($message) -} //end message_box() ********************************* +}//end message_box() ************************************** -function show_image(){ //******************************* +function Upload_New_Rename_Delete_Links() { //************** + global $ONESCRIPT, $ipath, $varvar; +?> + + +'; + ?> +

    + + +

    +document.getElementById("'.$focus.'").focus();'; } + +}// End Cancel_Submit_Buttons() //************************** + + + +function show_image(){ //*********************************** global $filename, $MAX_IMG_W, $MAX_IMG_H; $IMG = $filename; @@ -206,261 +264,77 @@ function show_image(){ //******************************* echo '
    '; echo ''; echo ''; -}// 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

    - - + +

    - - + +

    - + (!) INVALID LOGIN ATTEMPT
    "; } +}//end Login Page response message********************************************** + + + + + + function list_files() { // ...in a vertical table ****************************** - -global $ONESCRIPT, $varvar, $config_excluded, $ftypes, $fclasses; - -$files = glob($varvar."{,.}*", GLOB_BRACE); -natcasesort($files); +//called from Index Page + + global $ONESCRIPT, $WEB_ROOT, $ipath, $varvar, $config_excluded, $ftypes, $fclasses; -echo '
    - - ', basename($file), ''; ?> -   - B -   - -
    '; + $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(); +?> -

    - '; + $folders = glob($ipath."*",GLOB_ONLYDIR); natcasesort($folders); foreach ($folders as $folder) { - echo ''; - + echo ''; echo basename($folder).' /'; - } ?> -

    + } + echo '

    '; - - - - - -

    File: “ - -

    +

    Edit/View: + +

    - +

    Size: bytes     Updated:

    - +

    - +

    - -

    +

    - +

    @@ -639,12 +498,14 @@ function Edit_Page() { //******************************************************* - - - + + +

    @@ -666,23 +527,37 @@ function Edit_Page() { //******************************************************* +// EDIT Page response code ***************************************************** +//*** If on Edit page, and [Save] clicked: +if ( $page == "edit" && isset($_POST["filename"]) && $_SESSION['valid'] = "1" && $_POST["sessionid"] == session_id()) { + $filename = $_POST["filename"]; + $content = $_POST["content"]; + $fp = @fopen($filename, "w"); + if ($fp) { + fwrite($fp, $content); + fclose($fp); + $message = '"'.$filename.'" saved...'; + $page == "edit"; + }else{ + $message = '(!) There was an error saving file.'; + } +}//end EDIT Page response code************************************************** + + + + + + function Upload_Page() { //***************************************************** - global $ONESCRIPT, $varvar; - $varvar = ""; if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; } + global $ONESCRIPT, $ipath, $varvar; ?> -

    Upload

    +

    Upload File

    -

    - - /" class="textinput"> -

    -

    - - -

    -

    + + +

    (!) No file selected for upload... "; + }elseif (($destination != "") && !is_dir($_POST["upload_destination"])) { + $message .= '(!) Destination folder does not exist:
    '; + $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

    -

    Existing files with the same name will not be overwritten.

    - +

    New File

    + -

    - - /"> -

    -

    + +

    (!) New file not created - no filename given... "; + }elseif (file_exists($savefile)) { + $message = '(!) "'.$filename.'" not created. A file with that name already exists.'; + } else { + $handle = fopen($savefile, 'w') or die("can't open file"); + fclose($handle); + $message = '"'.$filename.'"successfully created.'; + $ipath = Check_path(dirname($filename)); //if changed, return to new dir. + $varvar = "?i=".$ipath; + } +}//end NEW FILE response code ************************************************** + + + + + + function Copy_File_Page(){ //*************************************************** - global $ONESCRIPT, $varvar, $filename; - - $extension = strrchr($filename, "."); - $slug = dirname($filename).'/'.pathinfo($filename,PATHINFO_FILENAME); - $varvar = "?i=".dirname($_GET["c"]); - $new_filename = $slug."_COPY_".date("YmdHi").$extension; + global $ONESCRIPT, $WEB_ROOT, $ipath, $varvar, $filename; + + $new_filename = ordinalize($ipath, basename($filename)); ?> -

    Copy “

    -

    ( ! ) Existing files with the same filename are automatically overwritten... Be careful!

    +

    Copy File

    + - +

    + + class="textinput" value="">

    -

    +

    (!) "'.$new_filename.'" not created.
    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 “

    -

    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.

    +

    Rename/Move File

    - +

    To move a file, change the folder's name, as in + "newfolder/filename.txt". The new folder must already exist.

    + +

    - - + +

    +

    -

    +

    (!) Error renaming or moving file : '.$old_filename.'
    '; + $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 “ - ” ?

    -

    Are you sure?

    +

    Delete File

    -

    - - -

    + + +

    Are you sure?

    + '.basename($filename).'" successfully deleted.'; + }else{ + $message = '(!) Error deleting "'.$filename.'".'; + } +}//end DELETE FILE response code *********************************************** + + + + + function New_Folder_Page() { //************************************************* - global $ONESCRIPT, $varvar; - $varvar = ""; - if (isset($_GET["i"])) { $varvar = "?i=".$_GET["i"]; } + global $ONESCRIPT, $WEB_ROOT, $ipath, $varvar; ?> -

    New Folder

    -

    Existing folders with the same name will not be overwritten.

    +

    New Folder

    -

    - - /"> -

    -

    + +

    + (!) New folder not created - no name given... "; + }elseif (is_dir($new_folder)) { + $message .= '(!) Folder already exists: '; + $message .= ''.$new_folder.''; + }elseif (mkdir($new_folder)) { + $message .= 'Folder "'.basename($new_folder).'" successfully created.'; + $ipath = $new_folder; //cd to new folder + $varvar = "?i=".$ipath; + }else{ + $message .= "(!) Error- new folder not created."; + } +}//end NEW FOLDER response code ************************************************ + + + + + function Rename_Folder_Page() { //********************************************** - global $ONESCRIPT, $varvar; - $varvar = '?i='.$_GET["i"]; + global $ONESCRIPT, $WEB_ROOT, $ipath, $varvar; ?> -

    Rename Folder “

    +

    Rename Folder

    - "> - " class="textinput" disabled="disabled"> + + +

    - "> + +

    -

    +

    (!) Error renaming folder- target name already exists:
    '; + $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

    + -

    - "> - -

    + + + / +

    Are you sure?

    + (!) Folder not empty. Folders must be empty before they can be deleted.
    '; + $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() { - + - + -
    +'; } + else{ echo '
    ';} +?>
    ', $config_title; ?> - + - + - diff --git a/readme.markdown b/readme.markdown index 354b05c..df01f7f 100755 --- a/readme.markdown +++ b/readme.markdown @@ -1,5 +1,9 @@ -# Current "stable" version: 1.2.3 +### May 18, 2012 + +# Current stable version: 1.4.0 + -------------------------------------------------------------------------------- + ### April 30, 2012 # NOTICE - SECURITY HOLE! (Fixed in version 1.2.1) @@ -49,8 +53,7 @@ Coupling a utilitarian code editor with all the basic necessities of an FTP appl - 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 +- Alert if you try to leave without saving your edits - Easily re-brandable via the title text stored in a configurable variable, and a modifiable filename. - Externally hosted CSS and images. _(Of course, you can switch it out to your own stylesheet if you need to!)_ @@ -107,19 +110,19 @@ Probably not. The reason there isn't default support for multiple users is that all of their info will have to be stored together, more or less in plain text, at the top of onefilecms.php. Giving people different usernames and passwords then is sort of futile, since everyone who can log in can view onefilecms's source and config variables. (This answer kind of ignores MD5 hashes but is valid for most considerations.)  -### Is the JavaScript in the middle of the file really needed? When I remove it, everything seems to work fine. +## Change Log -It isn't entirely necessary, but it does provide nice enhancements, like warning you if you try to leave without saving changes, and stuff like that. -## Change Log +### 1.4.0 + +- Substantial code reorganization & updates. + ### 1.2.4 - 1.3.0 - DO NOT USE THESE VERSIONS! - Mostly just a bunch of code modifications. -- These versions have issues, primarily when on the home/root page your site, - and attempting to [Upload File], [New File], [New Folder], or when editing - a file. +- These versions have issues, primarily when on the home/root page your site. ### 1.2.3 From a96a214f3254357a35a52821f6823cda4f7ff9f5 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 20 May 2012 18:01:35 -0400 Subject: [PATCH 061/228] Version 1.5.0 Style sheet now embedded - external .css no longer needed Improved $excluded logic Improve Edit Page "if editable" & "if image" logic --- onefilecms.php | 579 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 479 insertions(+), 100 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index a70b929..8014312 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -2,10 +2,10 @@ // OneFileCMS - http://onefilecms.com/ // For license & copyright info, see OneFileCMS.License.BSD.txt -$version = "1.4.0"; +$version = '1.5'; -if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate. Please contact your host to upgrade your PHP installation."); }; +if( phpversion() < '5.0.0' ) { exit("OneFileCMS requires PHP5 to operate (v5.4 recommended). Please contact your host to upgrade your PHP installation."); }; // CONFIGURABLE INFO *********************************************************** @@ -13,38 +13,36 @@ $config_password = "password"; $config_title = "OneFileCMS"; -$config_style_sheet = "onefilecms.css"; //Relative to this file. -//$config_style_sheet ="/onefilecms.css"; //Relative to site URL root. -//$config_style_sheet = "http://self-evident.github.com/OneFileCMS/onefilecms.css"; - $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. $config_favicon = "/favicon.ico"; -$config_editable = "html,htm,php,css,js,txt,text,cfg,conf,ini,csv,svg"; -$config_excluded = ""; //files to exclude from directory listings -$config_itypes = "jpg,gif,png,bmp,ico"; // Can be displayed on edit page. -$config_ftypes = "jpg,gif,png,bmp,ico,svg,txt,cvs,css,php,htm,html,cfg,conf,js"; //used to select file icon -$config_fclass = "img,img,img,img,img,svg,txt,txt,css,php,htm,htm,cfg,cfg,txt"; //used to select file icon +$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"; //lowercase, no spaces! +$config_itypes = "jpg,gif,png,bmp,ico"; //lowercase, no spaces! +$config_ftypes = "jpg,gif,png,bmp,ico,svg,txt,cvs,css,php,ini,cfg,conf,js,htm,html"; //lowercase, no spaces! +$config_fclass = "img,img,img,img,img,svg,txt,txt,css,php,txt,cfg,cfg,txt,htm,htm"; //lowercase, no spaces! // END CONFIGURABLE INFO ******************************************************* -//Make arrays out of a few $config_variables. They are used in Index_Page() . +//Make arrays out of a few $config_variables for actual use later. //Above, however, it's easier to config/change a simple string. -$ftypes = (explode(",", strtolower($config_ftypes))); -$fclasses = (explode(",", strtolower($config_fclass))); -$itypes = (explode(",", strtolower($config_itypes))); - +$etypes = (explode(",", strtolower($config_etypes))); //editable file types +$itypes = (explode(",", strtolower($config_itypes))); //images types to display +$ftypes = (explode(",", strtolower($config_ftypes))); //file types with icons +$fclasses = (explode(",", strtolower($config_fclass))); //for file types with icons +$excluded_list = (explode(",", $config_excluded)); -$valid_pages = array("login","logout","index","edit","upload","new","copy","rename","delete","newfolder","renamefolder","deletefolder" ); $ONESCRIPT = $_SERVER["SCRIPT_NAME"]; $DOC_ROOT = $_SERVER["DOCUMENT_ROOT"].'/'; $WEB_ROOT = basename($DOC_ROOT).'/'; $WEBSITE = $_SERVER["HTTP_HOST"]; +$pagetitle = $_SERVER['SERVER_NAME']; //Default value. May be changed per page. -$pagetitle = $_SERVER['SERVER_NAME']; +$valid_pages = array("login","logout","index","edit","upload","new","copy","rename","delete","newfolder","renamefolder","deletefolder" ); //Allows OneFileCMS.php to be started from any dir on the site. @@ -176,38 +174,37 @@ function message_box() { //********************************* if (isset($message)) { ?>
    '; + }else { + echo '
    '; // Needed on Edit page to keep js feedback from failing } //end isset($message) + + // Used on Edit Page to preserve vertical spacing. + if ($page == "edit") {echo '';} }//end message_box() ************************************** function Upload_New_Rename_Delete_Links() { //************** global $ONESCRIPT, $ipath, $varvar; -?> - - -'; + echo 'Upload File'; + echo 'New File' ; + echo 'New Folder' ; + if ($ipath !== "") { + echo 'Rename Folder'; + echo 'Delete Folder'; + } + echo '

    '; }//end Upload_New_Rename_Delete_Links() ******************* @@ -377,36 +374,31 @@ function Login_Page() { //****************************************************** function list_files() { // ...in a vertical table ****************************** //called from Index Page - global $ONESCRIPT, $WEB_ROOT, $ipath, $varvar, $config_excluded, $ftypes, $fclasses; + global $ONESCRIPT, $ipath, $varvar, $ftypes, $fclasses, $excluded_list; $files = scandir('./'.$ipath); natcasesort($files); echo '
    - - ', basename($file), ''; ?> + + ', $file, ''; ?>   - B + B   - +
    '; 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]; } } ?> -
    + + ', $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 '

    '; $folders = glob($ipath."*",GLOB_ONLYDIR); natcasesort($folders); foreach ($folders as $folder) { echo ''; + echo basename($folder).' /'; } echo '

    '; + Upload_New_Rename_Delete_Links(); + list_files(); Upload_New_Rename_Delete_Links(); @@ -452,7 +444,7 @@ function Index_Page(){ //******************************************************* function Edit_Page() { //******************************************************* - global $ONESCRIPT, $ipath, $varvar, $filename, $filecontent, $ftypes, $config_editable, $config_itypes; + global $ONESCRIPT, $ipath, $varvar, $filename, $filecontent, $etypes, $itypes, $ftypes; $varvar2 = $varvar.'&p=edit'; $varvar3 = $varvar.'&f='.basename($filename); @@ -460,13 +452,13 @@ function Edit_Page() { //******************************************************* //Determine if editable file type $ext = end( explode(".", strtolower($filename) ) ); $editable = FALSE; - if (in_array($ext, $ftypes)) { $editable = TRUE; }; + if (in_array(strtolower($ext), $etypes)) { $editable = TRUE; }; ?>

    Edit/View: - + '.basename($filename) ?>

    -
    +

    Size: bytes     Updated:
    @@ -474,7 +466,7 @@ function Edit_Page() { //*******************************************************

    -

    -

    - - + +

    - + +

    - - - - - - + + + + + + + +

    "'.$filename.'" saved...'; - $page == "edit"; + $message = 'File saved...'; }else{ $message = '(!) There was an error saving file.'; } -}//end EDIT Page response code************************************************** - +}//end Edit_Page_response() **************************************************** function Upload_Page() { //***************************************************** - global $ONESCRIPT, $ipath, $param1; + global $ONESCRIPT, $ipath, $param1, $INPUT_SESSIONID; ?>

    Upload File

    - + - - -

    + + +
    (!) No file selected for upload... "; - }elseif (($destination != "") && !is_dir($_POST["upload_destination"])) { + }elseif (($destination != "") && !is_dir($destination)) { $message .= '(!) Destination folder does not exist:
    '; - $message .= ''.$WEB_ROOT.$destination.'
    Upload cancelled.'; + $message .= ''.htmlentities($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 .= 'Uploading: "'.htmlentities($filename).'"...'; + $savefile = ordinalize($destination, $filename); + if(move_uploaded_file($_FILES['upload_file']['tmp_name'], $savefile)) { $message .= '
    Upload successful.'; } else{ - $message .= "
    (!) There was an error. Upload or rename may have failed."; + $message .= '
    (!) There was an error. Upload or rename may have failed.'; } } -} //end Upload file response code ********************************************** +}//end Upload_File_response() ************************************************** @@ -812,14 +799,13 @@ function Upload_Page() { //***************************************************** function New_File_Page() { //*************************************************** - global $ONESCRIPT, $WEB_ROOT, $ipath, $param1; + global $FORM_COMMON; ?> -

    New File

    -
    - - -

    -
    +

    New File

    + + + + (!) New file not created - no filename given... "; + $page = "index"; // return to index if new file fails + + if ( $FS !== false){ + $message .= '('.$FS.') File not created. Filename contains invalid character(s) (forward slash):
    '; + $message .= ''.htmlentities($new_name).''; + }elseif (($_POST["new_file"] == "")){ + $message = "(!) New file not created - no filename given."; }elseif (file_exists($savefile)) { - $message = '(!) "'.$filename.'" not created. A file with that name already exists.'; - } else { - $handle = fopen($savefile, 'w') or die("can't open file"); + $message = '(!) "'.htmlentities(basename($filename)).'" not created. A file with that name already exists.'; + }elseif ($handle = fopen($savefile, 'w')) { fclose($handle); - $message = '"'.$filename.'"successfully created.'; - $ipath = Check_path(dirname($filename)); //if changed, return to new dir. - $param1 = "?i=".$ipath; - $page = "edit"; - } -}//end NEW FILE response code ************************************************** - - - - - - -function Copy_File_Page(){ //*************************************************** - global $ONESCRIPT, $WEB_ROOT, $ipath, $param1, $filename; - - $new_filename = ordinalize($ipath, basename($filename)); -?> -

    Copy File

    - -
    - -

    - - - - -

    -

    - - - -

    -

    -
    -(!) Error copying file - target filename already exists:
    '; - $message .= '(!) '.$new_filename.''; + $message = '"'.htmlentities(basename($filename)).'" successfully created.'; + $ipath = Check_path(dirname($filename)); //if changed, return to new dir. + $param1 = '?i='.URLencode_path($ipath); $page = "edit"; - $filename = $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.'"
    '; + }else { + $message .= "(!) ERROR - can't open or create file:
    "; + $message .= htmlentities($filename); } -}//end COPY FILE response code ************************************************* +}//end New_File_response() ***************************************************** -function Rename_File_Page() { //************************************************ - global $ONESCRIPT, $WEB_ROOT, $ipath, $param1, $filename; +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)); } ?> -

    Rename/Move File

    - -

    To move a file, change the folder's name, as in - "newfolder/filename.txt". The new folder must already exist.

    - -
    - +

    +

    To move a file or folder, change the path/to/folder/or_file. The new location must already exist.

    +

    - - - + + +

    - - - + + +

    -

    +
    -(!) 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. - $param1 = '?i='.$ipath; + if ( !is_dir($new_location) ){ + $message .= '(!) '.$msg1.' Error - new parent location does not exist:
    '; + $message .= $WEB_ROOT.$new_location.'/
    '; + }elseif (file_exists($new_name)) { + $message .= '(!) '.$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 .= ' --- Successfully '.$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); }else{ - $message .= '(!) Error renaming/moving file from:
    "'.$old_filename.'"
    '; - $message .= '(!) To:
    "'.$new_filename.'"
    '; + $message .= ''.htmlentities($WEB_ROOT.$old_name).'
    '; + $message .= '(!) Error durring '.$msg1.' from the above to the following:
    '; + $message .= ''.htmlentities($WEB_ROOT.$new_name).''; } -}//end RENAME FILE response code *********************************************** +}//end Copy_Ren_Move_response() ************************************************ function Delete_File_Page() { //************************************************ - global $ONESCRIPT, $WEB_ROOT, $ipath, $param1, $filename; + global $filename, $FORM_COMMON; ?> -

    Delete File

    - -
    - - - +

    Delete File

    + + +

    Are you sure?

    @@ -979,31 +928,31 @@ function Delete_File_Page() { //************************************************ -// DELETE FILE response code *************************************************** -if (isset($_POST["delete_filename"]) && $_SESSION['valid'] = "1" && $_POST["sessionid"] == session_id()) { - $filename = $_POST["delete_filename"]; +function Delete_File_response(){ //********************************************* + global $filename, $message, $page; + + $page = "index"; //Return to index + $filename = htmlspecialchars_decode($_POST["delete_file"]); if (unlink($filename)) { - $message = '"'.basename($filename).'" successfully deleted.'; + $message .= '"'.htmlentities(basename($filename)).'" successfully deleted.'; }else{ - $message = '(!) Error deleting "'.$filename.'".'; + $message .= '(!) Error deleting "'.htmlentities($filename).'".'; $page = "edit"; } -}//end DELETE FILE response code *********************************************** +}//end Delete_File_response() ************************************************** function New_Folder_Page() { //************************************************* - global $ONESCRIPT, $WEB_ROOT, $ipath, $param1; + global $FORM_COMMON; ?> -

    New Folder

    -
    - - -

    - +

    New Folder

    + + +
    ? * : " | / \\'; + $invalid_char_array = explode(' ', $invalid_characters); + foreach ($invalid_char_array as $bad_char) { + if (strpos($new_name, $bad_char) !== false) { $invalid = true; } + } + //Trim spaces, and make sure only has a single trailing slash. + $new_folder = $ipath.trim($_POST["new_folder"],"/ ").'/'; - if ($_POST["new_folder"] == ""){ + if ($invalid){ + $message .= '(!) Error- new name may not contain invalid character(s): '.htmlentities($invalid_characters).'
    '; + $message .= ''.htmlentities($new_name).''; + }elseif ($_POST["new_folder"] == ""){ $message .= "(!) New folder not created - no name given... "; }elseif (is_dir($new_folder)) { $message .= '(!) Folder already exists: '; - $message .= ''.$new_folder.''; + $message .= ''.htmlentities($new_folder).''; }elseif (mkdir($new_folder)) { - $message .= 'Folder "'.basename($new_folder).'" successfully created.'; - $ipath = $new_folder; //cd to new folder - $param1 = "?i=".$ipath; + $message .= 'Folder "'.htmlentities(basename($new_folder)).'" successfully created.'; + $ipath = $new_folder; //return to new folder + $param1 = '?i='.URLencode_path($ipath); }else{ - $message .= "(!) Error- new folder not created."; + $message .= '(!) Error- new folder not created:
    '; + $message .= htmlentities($WEB_ROOT.dirname($new_folder)).'/'.htmlentities(basename($new_folder)).'/
    '; + if ( !is_dir(dirname($new_folder)) ) { $message .= '  Parent folder must already exist.';} } -}//end NEW FOLDER response code ************************************************ +}//end New_Folder_response ***************************************************** -function Rename_Folder_Page() { //********************************************** - global $ONESCRIPT, $WEB_ROOT, $ipath, $param1; +function Delete_Folder_Page(){ //*********************************************** + global $WEB_ROOT, $ipath, $FORM_COMMON; ?> -

    Rename Folder

    -
    - -

    - - - -

    -

    - - - -

    -

    +

    Delete Folder

    + + + + / +

    Are you sure?

    +
    -(!) Folder not empty.   Folders must be empty before they can be deleted.
    '; + }elseif (@rmdir($foldername)) { + $message .= 'Folder "'.htmlentities(basename($foldername)).'" successfully deleted.'; + $ipath = Check_path($foldername); //Return to parent dir. + $param1 = '?i='.URLencode_path($ipath); + }else { + $message .= '(!) "'.htmlentities($foldername).'/" an error occurred during delete.'; + } +}//end Delete_Folder_response() ************************************************ - $old_foldername = $_POST["old_foldername"]; // entire old $ipath - $new_foldername = $_POST["new_foldername"]; // not entire path - only end foldername - //Removed any trailing slashes - $new_foldername = Check_path(dirname($old_foldername)).trim($new_foldername, '/'); - if (file_exists($new_foldername)) { - $message .= '(!) Error renaming folder- target name already exists:
    '; - $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 - $param1 = "?i=".$ipath; - } else { - $message = "(!) There was an error during rename. Try again and/or contact your admin."; - } -}//end RENAME FOLDER response code ********************************************* +// 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********************************************** -function Delete_Folder_Page(){ //*********************************************** - global $ONESCRIPT, $WEB_ROOT, $ipath, $param1; -?> -

    Delete Folder

    -
    - - - - / -

    Are you sure?

    - -
    -(!) Folder not empty. Folders must be empty before they can be deleted.
    '; - $page = "index"; -} -if (isset($_POST["delete_foldername"]) && $_SESSION['valid'] = "1" && $_POST["sessionid"] == session_id()) { +if ($VALID_POST) { //*********************************************************** + if (isset($_FILES['upload_file']['name'])) { Upload_File_response(); } + if (isset($_POST["filename"] )) { Edit_Page_response(); } + if (isset($_POST["new_file"] )) { New_File_response(); } + if (isset($_POST["copy_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["copy_file"], 'copy', 'Copy', 'Copied', 1); } + if (isset($_POST["rename_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["rename_file"], 'rename', 'Rename/Move', 'Renamed/Moved', 1); } + if (isset($_POST["delete_file"] )) { Delete_File_response(); } + if (isset($_POST["new_folder"] )) { New_Folder_response(); } + if (isset($_POST["rename_folder"])) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["rename_folder"], 'rename', 'Rename/Move', 'Renamed/Moved', 0); } + if (isset($_POST["delete_folder"])) { Delete_Folder_response(); } +}//end if ($VALID_POST) ******************************************************** - $page = "index"; //Return to index - $foldername = trim($_POST["delete_foldername"], '/'); - - if (@rmdir($foldername)) { - $message = 'Folder "'.basename($foldername).'" successfully deleted.'; - $ipath = Check_path($foldername); //Return to parent dir. - $param1 = "?i=".$ipath; - } else { - $message .= '(!) "'.$foldername.'/" an error occurred during delete.'; + + + + +//$pagetitle***************************************************** +if ($page == "login") { $pagetitle = "Log In"; } +elseif ($page == "edit") { $pagetitle = "Edit/View File"; } +elseif ($page == "upload") { $pagetitle = "Upload File"; } +elseif ($page == "newfile") { $pagetitle = "New File"; } +elseif ($page == "copy" ) { $pagetitle = "Copy"; } +elseif ($page == "rename") { $pagetitle = "Rename File"; } +elseif ($page == "delete") { $pagetitle = "Delete"; } +elseif ($page == "newfolder") { $pagetitle = "New Folder"; } +elseif ($page == "renamefolder") { $pagetitle = "Rename Folder"; } +elseif ($page == "deletefolder") { $pagetitle = "Delete Folder"; } +else { $pagetitle = $_SERVER['SERVER_NAME']; } +//****************************************************************************** + + + + + +//*** Verify valid $page ******************************************************* +if ($page != "") { + if (!in_array(strtolower($page), $valid_pages)) { + header("Location: ".$ONESCRIPT); // redirect on invalid page attempts + $page = "index"; } -}//end DELETE FOLDER response code ********************************************* +} +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 $page; - if ($page == "login") { Login_Page(); } - if ($page == "index") { Index_Page(); } - if ($page == "edit") { Edit_Page(); } - if ($page == "upload") { Upload_Page(); } - if ($page == "new") { New_File_Page(); } - if ($page == "copy") { Copy_File_Page(); } - if ($page == "rename") { Rename_File_Page(); } - if ($page == "delete") { Delete_File_Page(); } - if ($page == "newfolder") { New_Folder_Page(); } - if ($page == "renamefolder") { Rename_Folder_Page(); } - if ($page == "deletefolder") { Delete_Folder_Page(); } + global $ONESCRIPT, $page, $valid_pages; + + if ($page == "login") { Login_Page(); } + elseif ($page == "edit") { Edit_Page(); } + elseif ($page == "upload") { Upload_Page(); } + elseif ($page == "newfile") { New_File_Page(); } + elseif ($page == "copy") { Copy_Ren_Move_Page('Copy', 'File', 'copy_file', 1); } + elseif ($page == "rename") { Copy_Ren_Move_Page('Rename', 'File', 'rename_file', 1); } + elseif ($page == "delete") { Delete_File_Page(); } + elseif ($page == "newfolder") { New_Folder_Page(); } + elseif ($page == "renamefolder") { Copy_Ren_Move_Page('Rename', 'Folder', 'rename_folder', 0); } + elseif ($page == "deletefolder") { Delete_Folder_Page(); } + else { Index_Page(); } //default }//end Load_Selected_Page() **************************************************** - //****************************************************************************** function Time_Stamp_scripts() { ?> @@ -631,7 +585,7 @@ function list_files() { // ...in a vertical table ****************************** '; + echo '
    '; }//end list_files() ************************************************************ @@ -675,7 +629,7 @@ function Edit_Page() { //******************************************************* $editable = FALSE; if (in_array($ext, $etypes)) { $editable = TRUE; }; ?>

    Edit/View: - '.htmlentities(basename($filename)) ?> + '.htmlentities(basename($filename)) ?>

    @@ -685,16 +639,15 @@ function Edit_Page() { //******************************************************* Updated:

    - +
    +

    - -

    +?>

    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.'
    '; $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

    +

    Note: Maximum upload file size is:

    - + @@ -727,20 +766,33 @@ function Upload_File_response() { //******************************************** global $filename, $message, $EX, $page; $filename = $_FILES['upload_file']['name']; $destination = htmlspecialchars_decode(Check_path($_POST["upload_destination"])); - $page = "index"; + $page = "index"; + $MAXUP1 = ini_get('upload_max_filesize'); + $MAXUP2 = number_format ($_POST['MAX_FILE_SIZE']).' bytes'; + $ERROR = $_FILES['upload_file']['error']; + + if ( $ERROR == 1 ){ $ERRMSG = 'File too large. upload_max_filesize = '.$MAXUP1.' (From php.ini)';} + elseif ( $ERROR == 2 ){ $ERRMSG = 'File too large. $MAX_FILE_SIZE = '.$MAXUP2.' (From OneFileCMS)';} + elseif ( $ERROR == 3 ){ $ERRMSG = 'The uploaded file was only partially uploaded.'; } + elseif ( $ERROR == 4 ){ $ERRMSG = 'No file was uploaded. '; } + elseif ( $ERROR == 5 ){ $ERRMSG = ''; } + elseif ( $ERROR == 6 ){ $ERRMSG = 'Missing a temporary folder.'; } + elseif ( $ERROR == 7 ){ $ERRMSG = 'Failed to write file to disk.'; } + elseif ( $ERROR == 8 ){ $ERRMSG = 'A PHP extension stopped the file upload.'; } + else { $ERRMSG = ''; } if (($filename == "")){ - $message = $EX.' No file selected for upload... '; + $message .= $EX.' No file selected for upload... '; }elseif (($destination != "") && !is_dir($destination)) { $message .= $EX.' Destination folder does not exist:
    '; - $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 Date: Mon, 4 Jun 2012 17:49:20 -0400 Subject: [PATCH 071/228] Version 3.1.5 Edit/View Page: Added file size checks. Edit page was becoming the Blob, so I broke it up into three functions. --- onefilecms.php | 187 ++++++++++++++++++++++++++---------------------- readme.markdown | 35 ++++++--- 2 files changed, 124 insertions(+), 98 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index cc555f5..5241e13 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@ $MAX_EDIT_SIZE, don't even view in OneFileCMS. + // The max view size is completely arbitray. 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! @@ -58,7 +59,6 @@ - //****************************************************************************** session_start(); $SID = session_id(); @@ -79,13 +79,11 @@ chdir($_SERVER["DOCUMENT_ROOT"]); //Allow OneFileCMS.php to be started from any dir on the site. -// //End session startup*********************************************************** - //****************************************************************************** // A couple functions needed early @@ -138,7 +136,6 @@ function Check_path($path) { // returns first valid path in some/supplied/path/ - //****************************************************************************** //Some global values & $_GET parameters // @@ -177,7 +174,6 @@ function Check_path($path) { // returns first valid path in some/supplied/path/ - //*** Verify valid $page ******************************************************* if ($page != "") { @@ -204,7 +200,6 @@ function Check_path($path) { // returns first valid path in some/supplied/path/ - //****************************************************************************** // Misc Functions @@ -378,7 +373,6 @@ function show_favicon(){ - //A few macros ($varibale="some reusable chunk of code")************************ $INPUT_SESSIONID = ''.PHP_EOL; $FORM_COMMON = ''.$INPUT_SESSIONID; @@ -406,7 +400,6 @@ function show_favicon(){ - function svg_icon_bin(){ //***************************************************** $zero = ''; $one = ''; @@ -554,7 +547,6 @@ function show_icon($type){ //*************************************************** - function Login_Page() { //****************************************************** global $ONESCRIPT, $message; ?> @@ -577,7 +569,6 @@ function Login_Page() { //****************************************************** - function list_files() { // ...in a vertical table ****************************** //called from Index Page @@ -620,7 +611,6 @@ function list_files() { // ...in a vertical table ****************************** - function Index_Page(){ //******************************************************* global $ONESCRIPT, $ipath; @@ -646,77 +636,122 @@ function Index_Page(){ //******************************************************* +function Edit_Page_Buttons($text_editable, $too_large_to_edit) { //************* + global $ONESCRIPT, $param2; +?> +

    + + + + + + + + + +

    + -

    Edit/View: - '.htmlentities(basename($filename)) ?> -

    -

    - Size: bytes     - Updated:
    + Filesize: bytes   + Updated:

    - -Non-text or unkown file type. Edit disabled.

    '; + + }elseif ( $too_large_to_edit ) { + echo '

    '.$large_file_message1.'

    '; - if (!$editable) { // If non-text file, disable textarea -?>

    Non-text or unkown file type. Edit disabled.

    -

    - - -

    - - + echo ''; + echo ''; + } //end if !editable /else... + } //end if non-image, show textarea + + Edit_Page_Buttons($text_editable, $too_large_to_edit); +?> + + $MAX_EDIT_SIZE); + $too_large_to_view = (filesize($filename) > $MAX_VIEW_SIZE); + + if ($too_large_to_edit){$header2 = "Viewing: ";} + else {$header2 = "Editing: ";} + + $large_file_message1 = +'Edit disabled. Filesize > '.number_format($MAX_EDIT_SIZE).' bytes. ($MAX_EDIT_SIZE)
    +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); -
    -

    - - - - - - - - - -

    - -
    -'; + + if ( $text_editable && $too_large_to_edit && !$too_large_to_view ) { + $filecontent = htmlspecialchars(file_get_contents($filename), ENT_SUBSTITUTE,'UTF-8'); + echo '
    '.$filecontent.'
    '; + }elseif ( $text_editable && $too_large_to_view ){ + echo '

    '.$large_file_message2.'

    '; + } + + if ($text_editable && !$too_large_to_edit) { Edit_Page_scripts(); echo '
    NOTE: On 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].
    '; - } //end if editable - + } }//End Edit_Page *************************************************************** - function Edit_Page_response(){ //***If on Edit page, and [Save] clicked ******** global $filename, $message, $EX; $filename = htmlspecialchars_decode($_POST["filename"]); @@ -734,7 +769,6 @@ function Edit_Page_response(){ //***If on Edit page, and [Save] clicked ******** - function Upload_Page() { //***************************************************** global $ONESCRIPT, $ipath, $param1, $INPUT_SESSIONID; @@ -761,7 +795,6 @@ function Upload_Page() { //***************************************************** - function Upload_File_response() { //******************************************** global $filename, $message, $EX, $page; $filename = $_FILES['upload_file']['name']; @@ -800,7 +833,6 @@ function Upload_File_response() { //******************************************** - function New_File_Page() { //*************************************************** global $FORM_COMMON; ?> @@ -815,7 +847,6 @@ function New_File_Page() { //*************************************************** - function New_File_response() { //*********************************************** global $ipath, $filename, $page, $message, $EX; $new_name = $_POST["new_file"]; @@ -846,7 +877,6 @@ 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; @@ -876,8 +906,6 @@ 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 @@ -913,7 +941,6 @@ function Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $msg2, $is - function Delete_File_Page() { //************************************************ global $filename, $FORM_COMMON; ?> @@ -929,7 +956,6 @@ function Delete_File_Page() { //************************************************ - function Delete_File_response(){ //********************************************* global $filename, $message, $EX, $page; @@ -947,7 +973,6 @@ function Delete_File_response(){ //********************************************* - function New_Folder_Page() { //************************************************* global $FORM_COMMON; ?> @@ -961,7 +986,6 @@ function New_Folder_Page() { //************************************************* - function New_Folder_response(){ //********************************************** global $message, $EX, $ipath, $param1, $page; @@ -998,7 +1022,6 @@ function New_Folder_response(){ //********************************************** - function Delete_Folder_Page(){ //*********************************************** global $WEB_ROOT, $ipath, $FORM_COMMON; ?> @@ -1015,7 +1038,6 @@ function Delete_Folder_Page(){ //*********************************************** - function Delete_Folder_response() { //****************************************** global $ipath, $param1, $page, $message, $EX; $page = "index"; //Return to index @@ -1035,7 +1057,6 @@ function Delete_Folder_response() { //****************************************** - //Logout *********************************************************************** if ($page == "logout") { $page = "login"; @@ -1047,7 +1068,6 @@ function Delete_Folder_response() { //****************************************** - if ($VALID_POST) { //*********************************************************** if (isset($_FILES['upload_file']['name'])) { Upload_File_response(); } if (isset($_POST["filename"] )) { Edit_Page_response(); } @@ -1063,7 +1083,6 @@ function Delete_Folder_response() { //****************************************** - //$pagetitle***************************************************** if ($page == "login") { $pagetitle = "Log In"; } elseif ($page == "edit") { $pagetitle = "Edit/View File"; } @@ -1081,7 +1100,6 @@ function Delete_Folder_response() { //****************************************** - function Load_Selected_Page(){ //*********************************************** global $ONESCRIPT, $page; @@ -1101,7 +1119,6 @@ function Load_Selected_Page(){ //*********************************************** - //****************************************************************************** function Time_Stamp_scripts() { ?> @@ -1147,7 +1164,6 @@ function FileTimeStamp(php_filemtime, show_offset){ - function Edit_Page_scripts() { //******************************************** ?> @@ -1257,7 +1273,6 @@ function Reset_File() { - function style_sheet(){ //****************************************************?> - Date: Tue, 5 Jun 2012 17:19:44 -0400 Subject: [PATCH 073/228] Version 3.1.7 Made (almost) rest of code functions: session startup, get params, etc.. Moved all logic to just ahead of Copy_Ren_Move_Page(): Tweaked spacing on rendered page Due to various filename style considerations, simplified ordinalize(): now returns: somefile.ext.001 indstead of: somefile.001.ext --- onefilecms.php | 354 +++++++++++++++++++++++++------------------------ 1 file changed, 182 insertions(+), 172 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index a4c367e..de9c30b 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@ $MAX_EDIT_SIZE, don't even view in OneFileCMS. // The max view size is completely arbitray. 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_excluded = ""; //files to exclude from directory listings- CaSe sEnsaTive! $config_etypes = "html,htm,xhtml,php,css,js,txt,text,cfg,conf,ini,csv,svg"; //Editable file types. $config_itypes = "jpg,gif,png,bmp,ico"; //image types to display on edit page. @@ -60,34 +60,80 @@ //****************************************************************************** -session_start(); $SID = session_id(); +//Some global values -if ( isset($_POST["username"]) || isset($_POST["password"]) ) { - $_SESSION['username'] = $_POST["username"]; - $_SESSION['password'] = $_POST["password"]; +$ONESCRIPT = URLencode_path($_SERVER["SCRIPT_NAME"]); +$DOC_ROOT = $_SERVER["DOCUMENT_ROOT"].'/'; +$WEB_ROOT = URLencode_path(basename($DOC_ROOT)).'/'; +$WEBSITE = $_SERVER["HTTP_HOST"].'/'; - if (($_POST["username"] != $config_username) || ($_POST["password"] != $config_password)) - { $message = $EX.' INVALID LOGIN ATTEMPT'; } -} +//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); +//****************************************************************************** -if (($_SESSION['username'] == $config_username) and ( $_SESSION['password'] == $config_password )) - { $_SESSION['valid'] = "1"; $page = "index"; } -else { $_SESSION['valid'] = "0"; $page = "login"; unset($_GET["p"]); session_destroy() ;} -$VALID_POST = ($_SESSION['valid'] == "1" && $_POST["sessionid"] == session_id()); +function Session_Startup() {//************************************************** + global $config_username, $config_password, $message , $page, $VALID_POST; -chdir($_SERVER["DOCUMENT_ROOT"]); //Allow OneFileCMS.php to be started from any dir on the site. -//End session startup*********************************************************** + session_start(); + if ( isset($_POST["username"]) || isset($_POST["password"]) ) { + $_SESSION['username'] = $_POST["username"]; + $_SESSION['password'] = $_POST["password"]; + if (($_POST["username"] != $config_username) || ($_POST["password"] != $config_password)) + { $message = $EX.' INVALID LOGIN ATTEMPT'; } + } + if (($_SESSION['username'] == $config_username) and ( $_SESSION['password'] == $config_password )) + { $_SESSION['valid'] = "1"; $page = "index"; } + else { $_SESSION['valid'] = "0"; $page = "login"; unset($_GET["p"]); session_destroy() ;} + + + $VALID_POST = ($_SESSION['valid'] == "1" && $_POST["sessionid"] == session_id()); + + + chdir($_SERVER["DOCUMENT_ROOT"]); //Allow OneFileCMS.php to be started from any dir on the site. +}//End Session_Startup() ******************************************************* + + + + +function Get_GET() { //*** Get main parameters ********************************* + // i=some/path/, f=somefile.xyz, p=somepage + global $ipath, $filename, $page, $param1, $message, $EX; + + 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 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)) { ?>

    - + [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 '

    '; -}//end Upload_New_Rename_Delete_Links() ******************* +}//end Upload_New_Rename_Delete_Links() *************************************** -function Close_Button($classes) { //************************ + +function Close_Button($classes) { //******************************************** global $ONESCRIPT, $ipath, $param1; echo ''; ?>document.getElementById("'.$focus.'").focus();'; } -}// End Cancel_Submit_Buttons() //************************** +}// End Cancel_Submit_Buttons() //********************************************** + -function show_image(){ //*********************************** +function show_image(){ //******************************************************* global $filename, $MAX_IMG_W, $MAX_IMG_H; $IMG = $filename; @@ -358,25 +339,27 @@ function show_image(){ //*********************************** echo '
    '; echo ''; echo ''; -}// 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 = '
    '.$INPUT_SESSIONID; $SVG_icon_circle_plus = ' @@ -397,7 +380,7 @@ function show_favicon(){ '; -//****************************************************************************** +}//end Init_Macros() *********************************************************** @@ -501,7 +484,7 @@ function svg_icon_folder_0($extra){ //****************************************** fill="transparent" stroke="white" stroke-width="1" /> -New file not created: '.htmlentities($new_name).'
    '. '       Name contains invalid character(s): '. @@ -900,14 +883,13 @@ function Copy_Ren_Move_Page($action, $title, $name_id, $isfile) { //******

    - - +

    - -

    @@ -933,7 +915,7 @@ function Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $msg2, $is $message .= $EX.' '.$msg1.' Error - new parent location does not exist:
    '; $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(){ //***Page_Title()************************* + global $page; - - -if ($VALID_POST) { //*********************************************************** - if (isset($_FILES['upload_file']['name'])) { Upload_File_response(); } - if (isset($_POST["filename"] )) { Edit_Page_response(); } - if (isset($_POST["new_file"] )) { New_File_response(); } - if (isset($_POST["copy_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["copy_file"], 'copy', 'Copy', 'Copied', 1); } - if (isset($_POST["rename_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["rename_file"], 'rename', 'Rename/Move', 'Renamed/Moved', 1); } - if (isset($_POST["delete_file"] )) { Delete_File_response(); } - if (isset($_POST["new_folder"] )) { New_Folder_response(); } - if (isset($_POST["rename_folder"])) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["rename_folder"], 'rename', 'Rename/Move', 'Renamed/Moved', 0); } - if (isset($_POST["delete_folder"])) { Delete_Folder_response(); } -}//end if ($VALID_POST) ******************************************************** - - - - -//$pagetitle***************************************************** -if ($page == "login") { $pagetitle = "Log In"; } -elseif ($page == "edit") { $pagetitle = "Edit/View File"; } -elseif ($page == "upload") { $pagetitle = "Upload File"; } -elseif ($page == "newfile") { $pagetitle = "New File"; } -elseif ($page == "copy" ) { $pagetitle = "Copy"; } -elseif ($page == "rename") { $pagetitle = "Rename File"; } -elseif ($page == "delete") { $pagetitle = "Delete"; } -elseif ($page == "newfolder") { $pagetitle = "New Folder"; } -elseif ($page == "renamefolder") { $pagetitle = "Rename Folder"; } -elseif ($page == "deletefolder") { $pagetitle = "Delete Folder"; } -else { $pagetitle = $_SERVER['SERVER_NAME']; } -//****************************************************************************** + if ($page == "login") { return "Log In"; } + elseif ($page == "edit") { return "Edit/View File"; } + elseif ($page == "upload") { return "Upload File"; } + elseif ($page == "newfile") { return "New File"; } + elseif ($page == "copy" ) { return "Copy"; } + elseif ($page == "rename") { return "Rename File"; } + elseif ($page == "delete") { return "Delete"; } + elseif ($page == "newfolder") { return "New Folder"; } + elseif ($page == "renamefolder") { return "Rename Folder"; } + elseif ($page == "deletefolder") { return "Delete Folder"; } + else { return $_SERVER['SERVER_NAME']; } +}//end Page_Title() ************************************************************ @@ -1491,17 +1449,19 @@ function style_sheet(){ //****************************************************?> height: 30em; } +textarea:focus { border: 1px solid #Faa; } + .edit_disabled { border : 1px solid #807568; width : 99%; padding: .2em; margin : 0; color: #444; - background-color: #F8F8F8; + background-color: #F0F0F0; line-height: 1.4em; } -textarea:focus { border: 1px solid #Faa; } +.view_file {font-family: courier; font-size: .9em; background-color: #F8F8F8;} input:focus { background-color: rgb(255,250,150); } @@ -1517,7 +1477,6 @@ function style_sheet(){ //****************************************************?> .buttons_right { float: right; } .buttons_right .button { margin-left: 7px; } - .button { border : 1px solid #807568; padding: 4px 10px; @@ -1628,6 +1587,56 @@ function style_sheet(){ //****************************************************?> +//****************************************************************************** +//****************************************************************************** +//Begin logic to determine page action + + +Session_Startup(); //*********************************************************** + +Get_GET(); //*********************************************************** + +Init_Macros(); //*********************************************************** + + + + +if ($VALID_POST) { //*********************************************************** + if (isset($_FILES['upload_file']['name'])) { Upload_File_response(); } + elseif (isset($_POST["filename"] )) { Edit_Page_response(); } + elseif (isset($_POST["new_file"] )) { New_File_response(); } + elseif (isset($_POST["copy_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["copy_file"], 'copy', 'Copy', 'Copied', 1); } + elseif (isset($_POST["rename_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["rename_file"], 'rename', 'Rename/Move', 'Renamed/Moved', 1); } + elseif (isset($_POST["delete_file"] )) { Delete_File_response(); } + elseif (isset($_POST["new_folder"] )) { New_Folder_response(); } + elseif (isset($_POST["rename_folder"])) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["rename_folder"], 'rename', 'Rename/Move', 'Renamed/Moved', 0); } + elseif (isset($_POST["delete_folder"])) { Delete_Folder_response(); } +}//end if ($VALID_POST) ******************************************************** + + + + +//*** 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 +if ( ($page == "login") and ($_SESSION['valid']) ) { $page = "index"; } + +if ( $page == "edit" && !is_file($filename) ) { $page = "index"; } + +if ($page == "logout") { $page = "login"; $_SESSION['valid'] = "0"; session_destroy(); + $message = 'You have successfully logged out.'; } + +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"; +} +//****************************************************************************** + + + + //****************************************************************************** //****************************************************************************** ?> @@ -1635,7 +1644,8 @@ function style_sheet(){ //****************************************************?> -<?php echo $config_title.' - '.$pagetitle ?> +<?php echo $config_title.' - '.Page_Title() ?> + From 122218805fbdf5032ead8b8418b52e4b23c4e2c3 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 5 Jun 2012 18:13:22 -0400 Subject: [PATCH 074/228] Version 3.1.7 Updated readme & added OneFileCMS_structure.txt --- OneFileCMS_structure.txt | 77 ++++++++++++++++ readme.markdown | 193 ++++++++++++++++----------------------- 2 files changed, 156 insertions(+), 114 deletions(-) create mode 100755 OneFileCMS_structure.txt diff --git a/OneFileCMS_structure.txt b/OneFileCMS_structure.txt new file mode 100755 index 0000000..4d29e80 --- /dev/null +++ b/OneFileCMS_structure.txt @@ -0,0 +1,77 @@ +CONFIGURATION SECTION + +SOME STANDARD GLOBAL VARIABLES + +MISC FUNCTIONS: + Session_Startup() + Get_GET() + URLencode_path() + Check_path() + is_empty() + ordinalize() + Current_Path_Header() + message_box() + Upload_New_Rename_Delete_Links() + Close_Button() + Cancel_Submit_Buttons() + show_image() + show_favicon() + Init_Macros() + +SVG ICON FUNCTIONS: + svg_icon_bin() + svg_icon_img() + svg_icon_svg() + svg_icon_txt_0() + svg_icon_txt() + svg_icon_htm() + svg_icon_php() + svg_icon_css() + svg_icon_cfg() + svg_icon_upload() + svg_icon_file_new() + svg_icon_file_del() + svg_icon_folder_0() + svg_icon_folder() + svg_icon_folder_new() + svg_icon_folder_ren() + svg_icon_folder_del() + show_icon() + +PAGE & RESPONSE FUNCTIONS: + Login_Page() + list_files() + Index_Page() + Edit_Page_Buttons() + Edit_Page_form() + Edit_Page() + Edit_Page_response() + Upload_Page() + Upload_File_response() + New_File_Page() + New_File_response() + Copy_Ren_Move_Page() + Copy_Ren_Move_response() + Delete_File_Page() + Delete_File_response() + New_Folder_Page() + New_Folder_response() + Delete_Folder_Page() + Delete_Folder_response() + Page_Title() + Load_Selected_Page() + +JAVASCRIPT & STYLESHEET FUNCTIONS: + Time_Stamp_scripts() //Javascript functions + Edit_Page_scripts() //Javascript functions + style_sheet() //css + +LOGIC TO DETERMINE PAGE ACTION + Call Session_Startup() + Call Get_GET() + Call Init_Macros() + If VALID_POST + Do $_POST['someaction'] (_response) + Validate $page to show + +GENERATE ACTUAL ... diff --git a/readme.markdown b/readme.markdown index 7e51603..5bb7eb2 100755 --- a/readme.markdown +++ b/readme.markdown @@ -1,39 +1,13 @@ -### May 29, 2012 +### June 05, 2012 -# Current stable versions: 1.5, 2.0, & 3.1.5 +# Current stable versions: 1.5, "Lite" 2.1.7, 3.1.7 -- 3.1.1: "Full" version - uses svg icons -- 2.0 : "Lite" version - uses no icons. +- 3.0+ : "Full" version - uses svg icons +- 2.0+ : "Lite" version - uses no icons. - 1.5 : style sheet is now part of onfilecms.php file, but still uses external icons. -------------------------------------------------------------------------------- -### April 30, 2012 - -## NOTICE - SECURITY HOLE! (Fixed in version 1.2.1) - -## Versions affected - -- 1.1.7 thru 1.2.0 - -## Versions *Un* affected / fixed - -- Version 1.1.6 -- Versions 1.2.1 and newer - -## Brief description: - -- No login required if a file and path is known. - EX: http:// yourdomain.com/onefilecms.php?f=some/path/to/file.txt - -- File edit, rename, move, and copy work in this way, without login. - -## Cause - -- Me. I just noticed the problem. Some edit after 1.1.6 introduced the hole. - --------------------------------------------------------------------------------- - # OneFileCMS ## Yes, that's exactly what it is! @@ -47,11 +21,11 @@ Edit screen: OneFileCMS is just that. It's a flat, light, one file CMS (Content Management System) entirely contained in an easy-to-implement, highly customizable, database-less PHP script. -Coupling a utilitarian code editor with all the basic necessities of an FTP application, OneFileCMS can maintain a whole website completely in-browser without any external programs. +Coupling a utilitarian code editor with basic file managing functions, OneFileCMS can maintain a whole website completely in-browser without any external programs. ## Demo -- Just download & try the current version - it's one file! +- Just download & try the current stable version - it's one file! ## Features @@ -71,46 +45,107 @@ Coupling a utilitarian code editor with all the basic necessities of an FTP appl $config_username = "username"; $config_password = "password"; -3) Upload! +3) Upload to anywhere on your site! Depending on how your web stack is set up, you may also have to modify the file permissions of your site's folders to allow OneFileCMS to modify and create files. ([More about that here.](http://catcode.com/teachmod/)) Make sure onefilecms.php and its parent folder are allowed to execute, with CHMOD at 755. Check with your host if you're not sure, and be aware of any inherent security concerns. -You can also change the name of OneFileCMS.php to something else. _(Be careful making it a folder's default file: your server may get stuck in redirects.)_ +You can also change the file name of OneFileCMS.php to something else, such as "Admin.php" . _(Be careful making it a folder's default file: your server may get stuck in redirects.)_ ## FAQ ### Where's the WYSIWYG? What about syntax highlighting? -WYSWIWYG editors have been requested, but probably won’t become standard, as they’d bloat the system out and/or make it more than one file, sort of defeating the point of OneFileCMS. Plus, if you’re working in PHP or non-HTML code, they're generally more of a hindrance than anything else. +WYSWIWYG editors have been requested, but probably won’t become standard, as they’d probably make it more than one file, sort of defeating the point of OneFileCMS. Plus, if you’re working in PHP or non-HTML code, they're can be more of a hindrance than an asset. -Just because I don't want to do it, though, doesn't mean it's impossible. Look for the Edit_Page() function. Its textarea can be modified to work with whatever editor you like. +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. ### I found something that could be better. Can I suggest it to you? -Yes, of course, you can! +Yes, of course! -I may not have the time/bandwidthinclination to implement every feature, but I'll do what I can. If it's urgent, contact me. +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. Otherwise, try [forking the file and submitting your changes to me](https://github.com/blog/844-forking-with-the-edit-button). -Everything's welcome! - -### This is basically just a file manager with a text editor. Why is it being a Content Management System? +### This is basically just a file manager with a text editor. Why is it being called a Content Management System? Well, because "OneFileFileManagerTextEditor" just doesn't have the same ring to it... ### Multi-Language Support? -Probably not. +Probably not, as that would also most likely make it more than "OneFile". ### Can I have more than one username/password? -The reason there isn't default support for multiple users is that all of their info will have to be stored together, more or less in plain text, at the top of onefilecms.php. Giving people different usernames and passwords then is sort of futile, since everyone who can log in can view onefilecms's source and config variables. (This answer kind of ignores MD5 hashes but is valid for most considerations.)  +The reason there isn't default support for multiple users is that all of their info will have to be stored together, more or less in plain text, at the top of onefilecms.php. Giving people different usernames and passwords then is sort of futile, since everyone who can log in can view onefilecms's source and config variables. -## Change Log +However, "it's on my to-do list!"... + +## Requirements + +- PHP 5.4 + (Older 5.x versions may work, but there will be issues editing files with back slashes, among other things. See php docs on magic_quotes_gpc & stripslashes().) +- File permission privileges on your host +- Javascript enabled browswer +- And, for OneFileCMS 3+, a browser that supports inline SVG. +## Credit, License, Et Cetera + +Original concept and development by github.com/rocktronica + +Written in PHP, JavaScript, HTML, CSS, and SVG. + +Available under the MIT and BSD licenses. + +Icons for versions thru 1.1.6 by [famfamfam](http://www.famfamfam.com/). + +To report a bug or request a feature, please file an issue via Github. Forks encouraged! + +##Needed/potential/upcoming improvements + +- Connection is not encrypted (doesn't use SSL), so passwords & usernames are sent in clear text during login. +- Be aware that only some very basic & rudimentary data & error checking is performed. + On Windows, for instance, it's possible to create folders that are subsequently inaccessible and undeletable by Windows. (Yea, I found out the hard way...) +- 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+. +- Multiple login names. +- Anything else? + +-------------------------------------------------------------------------------- + +### General layout/structure of OneFileCMS.php + +CONFIGURATION SECTION + +SOME STANDARD GLOBAL VARIABLES + +SESSION & MISC FUNCTIONS + +SVG ICON FUNCTIONS + +PAGE & RESPONSE FUNCTIONS + Index, Upload, New, Copy, Rename, etc... + +JAVASCRIPT & STYLESHEET FUNCTIONS + +LOGIC TO DETERMINE PAGE ACTION + Call Session\_Startup() + Call Get\_GET() + Call Init\_Macros() + If $VALID\_POST, do $\_POST['someaction'] + Validate which $page to show + +GENERATE THE PAGE + <HTML> + + ... + Load_Selected_Page($page) + ... + + </HTML> +-------------------------------------------------------------------------------- +## Change Log ### 3.1.2 thru 3.1.5 @@ -236,73 +271,3 @@ The reason there isn't default support for multiple users is that all of their i ### 1.0 (9/5/09) - Launch! - -## Requirements - -- PHP 5.4 - (Older 5.x versions may work, but there will be issues editing files with back slashes, among other things. See php docs on magic_quotes_gpc & stripslashes().) -- File permission privileges on your host -- Javascript enabled browswer -- And, for OneFileCMS 3+, a browser that supports inline SVG. - -## Credit, License, Et Cetera - -Original concept and development by github.com/rocktronica - -Written in PHP, JavaScript, HTML, CSS, and SVG. - -Available under the MIT and BSD licenses. - -Icons for versions thru 1.1.6 by [famfamfam](http://www.famfamfam.com/). - -To report a bug or request a feature, please file an issue via Github. Forks encouraged! - -##Needed/potential/upcoming improvements - -- Connection is not encrypted (doesn't use SSL), so passwords & usernames are sent in clear text during login. -- Be aware that only some very basic & rudimentary data & error checking is performed. - On Windows, for instance, it's possible to create folders that are subsequently inaccessible and undeletable by Windows. (Yea, I found out the hard way...) -- 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+. -- Check size of file to upload, verify under max post/upload limits. -- Multiple login names? - - --------------------------------------------------------------------------------- - -### General layout/structure of OneFileCMS.php - -Configurable Info -Session start -A few functions needed early -A few global values. -Misc functions -A few macros (reusable chunks of code) -svg\_icons\_...() functions -Login\_Page() function -list\_files() function -Index\_Page() function -<...page>_Page() functions -<...page>_response() functions -    Edit\_Page()... -    Upload\_ -    New\_File\_ -    Copy_Ren_Move\_ -    Delete\_File\_ -    New\_Folder\_ -    Delete\_Folder\_ -Invalid Login response -Logout response -If ($VALID\_POST), do \_response -Set page title -Verify valid $page -Load\_Selected\_Page() function -Time\_Stamp\_scripts() function -Edit\_Page\_script() function -style\_sheet() function -<html> -. -.. (head, body, etc...) -... -Load\_Selected\_Page() -... -</html> From 7615c73626c4819255744124b3616c9fcdd50192 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 8 Jun 2012 18:16:09 -0400 Subject: [PATCH 075/228] Version 3.1.8 Stopped using ENT_SUBSTITUTE on Edit_Page_form '; + $filecontent = htmlspecialchars(file_get_contents($filename)); + $bad_chars = ($filecontent == "" && filesize($filename) > 0); + + if ($bad_chars){ //did specialchars return an empty string? + echo '
    '.$EX.' File contains an invalid character. Edit and view disabled.
    '; + 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 ''; + } } //end if !editable /else... } //end if non-image, show textarea Edit_Page_Buttons($text_editable, $too_large_to_edit); + + if ($text_editable && !$too_large_to_edit && !$bad_chars) { + Edit_Page_scripts(); + echo '
    '; + echo '
    NOTE: On 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 disabled. Filesize > '.number_format($MAX_EDIT_SIZE).' bytes.
    ($MAX_EDIT_SIZE)
    + $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 '

    '.$large_file_message2.'

    '; - } - - if ($text_editable && !$too_large_to_edit) { - Edit_Page_scripts(); - echo '
    NOTE: On 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].
    '; + echo '

    '.$too_large_to_view_message.'

    '; } + }//End Edit_Page *************************************************************** @@ -741,13 +771,13 @@ function Edit_Page() { //******************************************************* function Edit_Page_response(){ //***If on Edit page, and [Save] clicked ******** global $filename, $message, $EX; - $filename = htmlspecialchars_decode($_POST["filename"]); - $content = htmlspecialchars_decode($_POST["content"]); - $fp = @fopen($filename, "w"); - if ($fp) { - fwrite($fp, $content); - fclose($fp); - $message = 'File saved...'; + $filename = $_POST["filename"]; + $content = $_POST["content"]; + + $bytes = file_put_contents($filename, $content); + + if ($bytes !== false) { + $message = 'File saved: '.$bytes.' bytes written.'; }else{ $message = $EX.' There was an error saving file.'; } @@ -786,7 +816,7 @@ function Upload_Page() { //***************************************************** function Upload_File_response() { //******************************************** global $filename, $message, $EX, $page; $filename = $_FILES['upload_file']['name']; - $destination = htmlspecialchars_decode(Check_path($_POST["upload_destination"])); + $destination = Check_path($_POST["upload_destination"]); $page = "index"; $MAXUP1 = ini_get('upload_max_filesize'); $MAXUP2 = number_format ($_POST['MAX_FILE_SIZE']).' bytes'; @@ -905,8 +935,8 @@ function Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $msg2, $is //$action = 'copy' or 'rename'. $isfile = 1 if acting on a file, not a folder global $WEB_ROOT, $ipath, $param1, $message, $EX, $page, $filename; - $old_name = htmlspecialchars_decode(trim($old_name,'/ ')); - $new_name = htmlspecialchars_decode(trim($new_name,'/ ')); + $old_name = trim($old_name,'/ '); + $new_name = trim($new_name,'/ '); $new_location = dirname($new_name); $filename = $old_name; //default if error if ($isfile) { $page = "edit"; }else{ $page = "index"; } @@ -930,7 +960,7 @@ function Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $msg2, $is $param1 = '?i='.URLencode_path($ipath); }else{ $message .= ''.htmlentities($WEB_ROOT.$old_name).'
    '; - $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(){ //****************************************************?>
    ', $config_title; ?> - + (on php ) '; echo '
    NOTE: On 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].
    '; } ?> @@ -790,21 +866,30 @@ 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_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.'   per upload_max_filesize in php.ini.'; } + else { $MAX_FILE_SIZE = $PMS; $max_msg = $post_max_size.'   per post_max_size in php.ini'; } ?>

    Upload File

    -

    Note: Maximum upload file size is:

    -
    +

    Note: Maximum upload file size is:

    + - +
    Upload successful! '.$savefile_msg; } else{ - $message .= '
    '.$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(){ //***Page_Title()************************* global $page; if ($page == "login") { return "Log In"; } + elseif ($page == "edit") { return "Edit/View File"; } elseif ($page == "upload") { return "Upload File"; } elseif ($page == "newfile") { return "New File"; } @@ -1112,6 +1202,7 @@ function Load_Selected_Page(){ //*********************************************** global $ONESCRIPT, $page; if ($page == "login") { Login_Page(); } + elseif ($page == "edit") { Edit_Page(); } elseif ($page == "upload") { Upload_Page(); } elseif ($page == "newfile") { New_File_Page(); } @@ -1290,10 +1381,7 @@ function style_sheet(){ //****************************************************?> { border : 0; outline: 0; margin : 0; padding: 0; font-family: inherit; font-weight: inherit; font-style : inherit; font-size : 100%; vertical-align: baseline; } - - /* --- general formatting --- */ - body { font-size: 1em; background: #DDD; font-family: sans-serif; } p, table { margin-bottom: .5em; margin-top: .5em;} @@ -1554,7 +1642,7 @@ function style_sheet(){ //****************************************************?> .close {float: right; margin-bottom: .5em;} -#edit_note {font-size: .8em; color: #444 ;margin-top: 1em;} +#edit_note {font-size: .8em; color: #444 ;margin-top: 1em; clear:both;} @@ -1610,6 +1698,21 @@ function style_sheet(){ //****************************************************?> .icon {float: left; margin: 0 .3em 0 0;} .mono {font-family: courier;} + + + + + + + + + + + + + + + //Begin logic to determine page action + + Session_Startup(); //*********************************************************** Get_GET(); //*********************************************************** @@ -1632,6 +1737,7 @@ function style_sheet(){ //****************************************************?> if ($VALID_POST) { //*********************************************************** if (isset($_FILES['upload_file']['name'])) { Upload_File_response(); } + elseif (isset($_POST["filename"] )) { Edit_Page_response(); } elseif (isset($_POST["new_file"] )) { New_File_response(); } elseif (isset($_POST["copy_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["copy_file"], 'copy', 'Copy', 'Copied', 1); } @@ -1647,20 +1753,32 @@ function style_sheet(){ //****************************************************?> //*** Verify valid $page and/or $filename ************************************** -if (!in_array(strtolower($page), $valid_pages)) { $page = "index"; } +if (!in_array(strtolower($page), $valid_pages)) { $page = "index"; } -//Don't load login screen if already in a valid session -if ( ($page == "login") and ($_SESSION['valid']) ) { $page = "index"; } + //Don't load login screen if already in a valid session. +elseif ( ($page == "login") && ($_SESSION['valid']) ) { $page = "index"; } -if ( $page == "edit" && !is_file($filename) ) { $page = "index"; } + //Don't load edit page if $filename doesn't exist. +elseif ( ($page == "edit") && !is_file($filename) ) { $page = "index"; } -if ($page == "logout") { $page = "login"; $_SESSION['valid'] = "0"; session_destroy(); - $message = 'You have successfully logged out.'; } +elseif ($page == "logout") { $page = "login"; $_SESSION['valid'] = "0"; session_destroy(); + $message .= 'You have successfully logged out.'; } + + //Don't load delete page if folder not empty. +elseif ( ($page == "deletefolder") && !is_empty($ipath) ) { + $message .= $EX.' Folder not empty.   Folders must be empty before they can be deleted.'; + $page = "index";} + + //if size of $_POST > post_max_size, PHP only returns empty $_POST & $_FILE arrays. +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($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 !!'; } -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(){ //****************************************************?> + + + +
    - From 4812b92ffac8a4742bc7a73db5675e1bff9e8ef8 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Thu, 14 Jun 2012 11:16:30 -0400 Subject: [PATCH 077/228] Version 3.1.8.2 Added default $param2 & $param3 in Get_GET(). Mostly for [X] box href when onclick (js) is not working. In current / path / folder : spacing around / now in css, instead of in code/html. Removed a couple PHP_EOL's as they slightly messed up spacing. Added css for file upload element. Cleaned up "Reset" part of style sheet. --- onefilecms.php | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index f6318ac..39d4383 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@ '; //Root folder of web site. - echo ' '.htmlentities(trim($WEB_ROOT, '/')).' /'.PHP_EOL; + echo ' '.htmlentities(trim($WEB_ROOT, '/')).'/'; if ($ipath != "" ) { //if not at root, show the rest $path_levels = explode("/",trim($ipath,'/') ); @@ -273,8 +273,8 @@ function Current_Path_Header(){ //********************************************** for ($x=0; $x < $levels; $x++) { $current_path .= $path_levels[$x].'/'; - echo ' '; - echo ' '.htmlentities($path_levels[$x]).' /'.PHP_EOL; + echo ''; + echo htmlentities($path_levels[$x]).'/'; } }//end if (not at root) echo ''; @@ -284,13 +284,13 @@ function Current_Path_Header(){ //********************************************** function message_box() { //***************************************************** - global $ONESCRIPT, $message, $page; + global $ONESCRIPT, $param1, $param2, $param3, $message, $page; if (isset($message)) { ?>

    - [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 Date: Thu, 14 Jun 2012 11:27:17 -0400 Subject: [PATCH 078/228] Version 3.1.8.3 Moved primary php version check to area with other page logic, and define a version constant in Global section. Reworked the Edit Page code a bit, including: Check PHP version to determine params for htmlspecialchars on Edit_Page(). Clearstatcache on Edit_Page() --- onefilecms.php | 55 ++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 39d4383..49d5af5 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@ $MAX_EDIT_SIZE, don't even view in OneFileCMS. - // The max view size is completely arbitray. It was 2am and seemed like a good idea at the time. +$MAX_VIEW_SIZE = 1000000; // If file > $MAX_EDIT_SIZE, don't even view in OneFileCMS. + // The 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! @@ -61,12 +61,12 @@ //****************************************************************************** -//Some global values - - - - +//Some global system values +if (!defined('PHP_VERSION_ID')) { //PHP_VERSION_ID only available since 5.2.7 + $phpversion = explode('.', PHP_VERSION); //PHP_VERSION, however, should be available even in older versions. + define('PHP_VERSION_ID', ($phpversion[0] * 10000 + $phpversion[1] * 100 + $phpversion[2])); +} $ONESCRIPT = URLencode_path($_SERVER["SCRIPT_NAME"]); $DOC_ROOT = $_SERVER["DOCUMENT_ROOT"].'/'; @@ -744,21 +744,11 @@ function Edit_Page_Buttons($text_editable, $too_large_to_edit) { //************* //****************************************************************************** function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_edit_message){ - global $ONESCRIPT, $param1, $param2, $filename, $itypes, $INPUT_SESSIONID, $EX, $message; - - $param2 = $param1.'&f='.rawurlencode(basename($filename)); - $param3 = $param2.'&p=edit'; + global $ONESCRIPT, $param1, $param2, $param3, $filename, $itypes, $INPUT_SESSIONID, $EX, $message; clearstatcache (); ?> -

    + -

    - Filesize: bytes   - Updated:
    -

    - - -
    '.$too_large_to_edit_message.'

    '; }else{ - $filecontent = htmlspecialchars(file_get_contents($filename)); + if (PHP_VERSION_ID < 50400) { // 5.4.0 + $filecontent = htmlspecialchars(file_get_contents($filename)); + }else{ + $filecontent = htmlspecialchars(file_get_contents($filename),ENT_SUBSTITUTE); + } $bad_chars = ($filecontent == "" && filesize($filename) > 0); - + if ($bad_chars){ //did specialchars return an empty string? echo '
    '.$EX.' File contains an invalid character. Edit and view disabled.
    '; 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).
    '; + echo ' This behavior can be inconsistant from version to version of php.
    '; }else{ echo ''; echo ''; + onkeyup="Check_for_changes(event);">'.$filecontent.''.PHP_EOL; } } //end if !editable /else... } //end if non-image, show textarea @@ -799,7 +793,7 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_ function Edit_Page() { //******************************************************* - global $filename, $filecontent, $etypes, $itypes, $MAX_EDIT_SIZE, $MAX_VIEW_SIZE; + global $ONESCRIPT, $param1, $filename, $filecontent, $etypes, $itypes, $MAX_EDIT_SIZE, $MAX_VIEW_SIZE; //Determine if text editable file type $ext = end( explode(".", strtolower($filename) ) ); @@ -826,7 +820,16 @@ function Edit_Page() { //******************************************************* echo '

    '.$header2; echo ''.htmlentities(basename($filename)).''; echo '

    '.PHP_EOL; +?> +

    + Filesize: bytes   + Updated:
    +

    + + +
    + 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'; } ?> -

    - - -

    +

    + + + document.getElementById("'.$focus.'").focus();'; } @@ -396,11 +396,11 @@ function show_favicon(){ //***************************************************** function Init_Macros(){ //*** ($varibale="some reusable chunk of code")********* -global $ONESCRIPT, $param1, $INPUT_SESSIONID, $FORM_COMMON, +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; -$FORM_COMMON = ''.$INPUT_SESSIONID; +$FORM_COMMON = ''.$INPUT_SESSIONID; $SVG_icon_circle_plus = ' @@ -572,56 +572,56 @@ function show_icon($type){ //*************************************************** +function Hash_Page() { //****************************************************** + global $DOC_ROOT, $ONESCRIPT, $param1, $message, $INPUT_SESSIONID, $config_title; + $params = '?i='.dirname($ONESCRIPT).'&f='.basename($ONESCRIPT).'&p=edit'; +?> + +

    Generate a Password Hash

    + + + + Password to hash: + "> + + Edit   + +
    +

    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).
    + 2) Or, use $HASHWORD to store the hash of your password, and set $USE_HASH = 1.
    + +

    Keep in mind that due to a number of widely varied considerations, this is largely an academic excersize.
    + In other words, take the idea that this adds much of an improvement to security with a grain of cryptographic salt...*
    +

    Anyway, to use the $HASHWORD password option: +

    1. Type your desired password in the input field above and hit Enter.
      + The hash will be displayed in a yellow message box above that. +
    2. Copy and paste the new hash to the $HASHWORD variable in the config section.
      + '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... +
    3. Make sure $USE_HASH is set to 1 (or true). +
    4. When ready, logout and login. +
    +

    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).
    + PS: Everything I know about security - you just read... +

    +'; + $message .= 'Hash    : '.hashit($_POST["whattohash"]); +} //end Hash_Page_response() *************************************************** @@ -956,7 +956,7 @@ function New_File_Page() { //*************************************************** function New_File_response() { //*********************************************** - global $ipath, $filename, $page, $message, $EX, $INVALID_CHARS, $INVALID_CHARS_array; + global $ipath, $param2, $filename, $page, $message, $EX, $INVALID_CHARS, $INVALID_CHARS_array; $new_name = trim($_POST["new_file"],'/ '); //Trim spaces and slashes. $filename = $ipath.$new_name; @@ -980,7 +980,7 @@ function New_File_response() { //*********************************************** fclose($handle); $message .= 'Created file: '.htmlentities($new_name); $page = "edit"; - $param1 = '?i='.URLencode_path($ipath); + $param2 = '&f='.rawurlencode(basename($filename));// for Edit_Page() buttons }else{ $message .= $EX.' Error - new file not created:
    '; $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(){ //***Page_Title()************************* global $page; if ($page == "login") { return "Log In"; } - + elseif ($page == "hash") { return "Hash"; } elseif ($page == "edit") { return "Edit/View File"; } elseif ($page == "upload") { return "Upload File"; } elseif ($page == "newfile") { return "New File"; } @@ -1205,7 +1205,7 @@ function Load_Selected_Page(){ //*********************************************** global $ONESCRIPT, $page; if ($page == "login") { Login_Page(); } - + elseif ($page == "hash") { Hash_Page(); } elseif ($page == "edit") { Edit_Page(); } elseif ($page == "upload") { Upload_Page(); } elseif ($page == "newfile") { New_File_Page(); } @@ -1709,13 +1709,13 @@ function style_sheet(){ //****************************************************?> Xfont: 1em "Courier New", Courier, monospace; } +#admin {padding: .3em;} - - +.info {margin-top: .7em; background: #f9f9f9; padding: .2em .5em;} .path {padding: 3px 5px 3px 5px} /*TRBL*/ - +.edit_onefile {padding: 5px; float: right;} //Begin logic to determine page action - +if( PHP_VERSION_ID < 50000 ) { exit("OneFileCMS requires PHP5 to operate. Tested on versions 5.2.17, 5.3.3 & 5.4"); } Session_Startup(); //*********************************************************** @@ -1740,13 +1740,13 @@ function style_sheet(){ //****************************************************?> if ($VALID_POST) { //*********************************************************** if (isset($_FILES['upload_file']['name'])) { Upload_File_response(); } - + elseif (isset($_POST["whattohash"] )) { Hash_Page_response(); } elseif (isset($_POST["filename"] )) { Edit_Page_response(); } - elseif (isset($_POST["new_file"] )) { New_File_response(); } + elseif (isset($_POST["new_file"] )) { New_File_response(); } elseif (isset($_POST["copy_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["copy_file"], 'copy', 'Copy', 'Copied', 1); } elseif (isset($_POST["rename_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["rename_file"], 'rename', 'Rename/Move', 'Renamed/Moved', 1); } elseif (isset($_POST["delete_file"] )) { Delete_File_response(); } - elseif (isset($_POST["new_folder"] )) { New_Folder_response(); } + elseif (isset($_POST["new_folder"] )) { New_Folder_response(); } elseif (isset($_POST["rename_folder"])) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["rename_folder"], 'rename', 'Rename/Move', 'Renamed/Moved', 0); } elseif (isset($_POST["delete_folder"])) { Delete_Folder_response(); } }//end if ($VALID_POST) ******************************************************** @@ -1806,17 +1806,16 @@ function style_sheet(){ //****************************************************?> -'; } - else{ echo '
    '; } +'; } + else { echo '
    '; } ?>
    - ', $config_title; ?> - - (on php ) + + +
    - + +
    +Admin'; } +?> - - -
    diff --git a/readme.markdown b/readme.markdown index 2ec523e..f85be6d 100755 --- a/readme.markdown +++ b/readme.markdown @@ -1,6 +1,6 @@ -### June 08, 2012 +### June 14, 2012 -# Current stable version: 3.1.8 +# Current stable version: 3.1.9 - 3.0+ : "Full" version - uses svg icons - 2.0+ : "Lite" version - uses no icons. @@ -41,8 +41,8 @@ Coupling a utilitarian code editor with basic file managing functions, OneFileCM 2) Set your username and password - edit them to something less obvious. // CONFIGURATION INFO - $config_username = "username"; - $config_password = "password"; + $USERNAME = "username"; + $PASSWORD = "password"; 3) Upload to anywhere on your site! @@ -102,10 +102,11 @@ To report a bug or request a feature, please file an issue via Github. Forks enc ##Needed/potential/upcoming 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+. +- Issue with Chrome's XSS filter: Editing some legitimate files with OneFileCMS will trigger the filter and disable most javascript provided functionallity, but only while on edit page of such a file. - Connection is not encrypted (doesn't use SSL), so passwords & usernames are sent in clear text during login. - Be aware that only some very basic & rudimentary data & error checking is performed. On Windows, for instance, it's possible to create folders that are subsequently inaccessible and undeletable by Windows. (Yea, I found out the hard way...) -- 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+. - Multiple login names. - Anything else? @@ -144,7 +145,13 @@ GENERATE THE PAGE ## Change Log -###3.1.6 thru 3.1.8 +### 3.1.9 + +- Password may now be stored as an encrypted hash, instead of in plain text. +- Added an "Admin" page to generate password hashes. +- A bunch of other code tweakin' & improvements. + +### 3.1.6 thru 3.1.8 - Converted bulk of rest of code into functions (easier to work with) - Resolved issue (I hope) with differing versions of PHP and how magic_quotes & stripslashes are handeled. From 13f9ecfc3963e1e0e1e0b49be246dcaca12c00ed Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sun, 17 Jun 2012 13:50:05 -0400 Subject: [PATCH 080/228] Version 3.1.9.01 Improved session_startup() login logic a bit. No longer storing username or hash/pass-word in $_SESSION. Using $_SESSION[valid] to indicated session state (good/bad). widened .login_page 10px config_info spacing. Prep for coming changes. --- onefilecms.php | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 3dd860b..1f32fa0 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@ INVALID LOGIN ATTEMPT
    '; } + if (($_POST["username"] == $USERNAME) && $VALID_PASSWORD ) { + $_SESSION['valid'] = "1"; $page = "index"; + }else{ + $_SESSION['valid'] = "0"; $page = "login"; unset($_GET["p"]); session_destroy(); + $message .= $EX.' INVALID LOGIN ATTEMPT'; + } } - if (($_SESSION['username'] == $USERNAME) && ( $_SESSION['password'] == $PASS )) - { $_SESSION['valid'] = "1"; $page = "index"; } - else { $_SESSION['valid'] = "0"; $page = "login"; unset($_GET["p"]); session_destroy() ;} + if (!$_SESSION['valid']) { session_destroy(); $page = login; } $VALID_POST = ($_SESSION['valid'] == "1" && $_POST["sessionid"] == session_id()); @@ -1655,7 +1656,7 @@ function style_sheet(){ //****************************************************?> margin : 5em auto; border : 1px solid #807568; padding : 1em 1em 0 1em; - width : 360px; + width : 370px; } .login_page .nav { margin-top: .5em; } @@ -1663,11 +1664,11 @@ function style_sheet(){ //****************************************************?> .login_input { border : 1px solid #807568; padding : 2px 0px 2px 2px; - width : 356px; + width : 366px; font : 1em "Courier New"; } -.login_page input[type="text"]{ width : 354px; } +.login_page input[type="text"]{ width : 364px; } /* --- --- --- */ From ae76a8e8700c82addf8c24c060917b403eb17d54 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sun, 17 Jun 2012 14:00:03 -0400 Subject: [PATCH 081/228] Version 3.1.9.02 Using session_regenerate_id(true) if login succeeds or fails. If invalid session or logout, "destroy" sessoin... Check for consistant HTTP_USER_AGENT Changed default session_name() Moved clearstatcache from Edit_form_page() to Edit_Page(). Moved call to undo_magic_quotes() to Get_GET() Tweaked .edit_disabled font color --- onefilecms.php | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 1f32fa0..637174d 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@ INVALID LOGIN ATTEMPT
    '; } } - if (!$_SESSION['valid']) { session_destroy(); $page = login; } + //Just a minor user consistancy check... (every little bit helps a little) + if ($_SERVER["HTTP_USER_AGENT"] != $_SESSION['HTTP_USER_AGENT']) { $_SESSION['valid'] = 0; } + + if (!$_SESSION['valid']) { + session_regenerate_id(true); + session_unset(); session_destroy(); session_write_close(); + $page = login; unset($_GET); unset($_POST); + } - $VALID_POST = ($_SESSION['valid'] == "1" && $_POST["sessionid"] == session_id()); + $VALID_POST = ($_SESSION['valid'] && $_POST["sessionid"] == session_id()); chdir($_SERVER["DOCUMENT_ROOT"]); //Allow OneFileCMS.php to be started from any dir on the site. }//End Session_Startup() ******************************************************* @@ -123,7 +132,7 @@ function Session_Startup() {//************************************************** function hashit($key){ //******************************************************* - //This is the super-secret stuff - don't tell anyone!! + //This is the super-secret stuff - Keep it secret, keep it safe! //If you change anything here, redo the hash for your password. $hash = hash('sha256', trim($key).$salt); // trim off leading & trailing spaces. $salt = 'somerandomesalt'; @@ -155,6 +164,8 @@ function Get_GET() { //*** Get main parameters ********************************* // i=some/path/, f=somefile.xyz, p=somepage global $ipath, $filename, $page, $param1, $param2, $param3, $message, $EX; + undo_magic_quotes(); + if (isset($_GET["i"])) { $ipath = Check_path($_GET["i"]); }else{ $ipath = ""; } if (isset($_GET["f"])) { @@ -746,7 +757,6 @@ function Edit_Page_Buttons($text_editable, $too_large_to_edit) { //************* //****************************************************************************** function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_edit_message){ global $ONESCRIPT, $param1, $param2, $param3, $filename, $itypes, $INPUT_SESSIONID, $EX, $message; - clearstatcache (); ?>
    @@ -783,7 +793,10 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_ if ($text_editable && !$too_large_to_edit && !$bad_chars) { Edit_Page_scripts(); - echo '
    NOTE: On 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].
    '; + echo '
    NOTES:
      '; + echo '
    1. On 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].'; + echo '
    2. Under certain circumstances, Chrome\'s XSS filters may disable some javascript in a page if it even appears to contain inline javascript. This can affect certain features of the OneFileCMS edit page when editing files that actually contain such code, such as OneFileCMS itself. However, these 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.'; + echo '
    '; } ?>
    @@ -795,6 +808,7 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_ function Edit_Page() { //******************************************************* global $ONESCRIPT, $param1, $filename, $filecontent, $etypes, $itypes, $MAX_EDIT_SIZE, $MAX_VIEW_SIZE; + clearstatcache (); //Determine if text editable file type $ext = end( explode(".", strtolower($filename) ) ); @@ -1578,7 +1592,7 @@ function style_sheet(){ //****************************************************?> width : 99%; padding: .2em; margin : 0; - background-color: #FFF000; + background-color: #FFF000; color: #333; line-height: 1.4em; } @@ -1766,6 +1780,8 @@ function style_sheet(){ //****************************************************?> 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,'/'); $message .= 'You have successfully logged out.'; } //Don't load delete page if folder not empty. From e59507ce73895dd3dde48e8308c9ff280adee90f Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Mon, 18 Jun 2012 00:11:11 -0400 Subject: [PATCH 082/228] Version 3.1.9.03 After x number of failed login attempts, delay next attempt. Created Login_response() & cleaned up Session_Startup(). Created Logout() & steps for a more secure & reliable logout. Tweaked some css Moved basic check for $valid_pages to Get_GET(). Minor fix: after New File created, Edit page opens, type stuff, [Save]. - Was returning to Index, instead of back to Edit page. --- onefilecms.php | 120 +++++++++++++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 49 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 637174d..aa8d283 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); +$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. @@ -94,34 +94,18 @@ function Session_Startup() {//************************************************** - global $USERNAME, $PASSWORD, $HASHWORD, $USE_HASH, $message , $page, $VALID_POST; + global $USERNAME, $PASSWORD, $USE_HASH, $HASHWORD, $message , $page, $VALID_POST; session_name('OFCMS'); //Change from default ('PHPSESSID') session_start(); - //Validate login - if ( isset($_POST["username"]) || isset($_POST["password"]) ) { - if ($USE_HASH){ $VALID_PASSWORD = (hashit($_POST['password'] == $HASHWORD)); } - else { $VALID_PASSWORD = ( $_POST['password'] == $PASSWORD) ; } - - if (($_POST["username"] == $USERNAME) && $VALID_PASSWORD ) { - session_regenerate_id(true); - $_SESSION['valid'] = "1"; $page = "index"; - $_SESSION['HTTP_USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; - }else{ - $_SESSION['valid'] = "0"; - $message .= $EX.' INVALID LOGIN ATTEMPT'; - } - } + //If logging in, validate + if ( isset($_POST["username"]) || isset($_POST["password"]) ) { Login_response(); } //Just a minor user consistancy check... (every little bit helps a little) - if ($_SERVER["HTTP_USER_AGENT"] != $_SESSION['HTTP_USER_AGENT']) { $_SESSION['valid'] = 0; } + if ( $_SESSION['USER_AGENT'] != md5($_SERVER["HTTP_USER_AGENT"])) { $_SESSION['valid'] = 0; } - if (!$_SESSION['valid']) { - session_regenerate_id(true); - session_unset(); session_destroy(); session_write_close(); - $page = login; unset($_GET); unset($_POST); - } + if (!$_SESSION['valid']) { Logout(); } $VALID_POST = ($_SESSION['valid'] && $_POST["sessionid"] == session_id()); @@ -131,6 +115,55 @@ function Session_Startup() {//************************************************** +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_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 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 Date: Mon, 18 Jun 2012 17:49:52 -0300 Subject: [PATCH 083/228] Error/warning messages are shown... --- readme.markdown | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/readme.markdown b/readme.markdown index f85be6d..76f9e7a 100755 --- a/readme.markdown +++ b/readme.markdown @@ -1,4 +1,10 @@ -### June 14, 2012 +### June 18, 2012 + +## error/warning messages get displayed. + +- Evidently, default PHP error/warning levels are not the same as what my test setup uses. That is, you may get a bumnch of warnings during failed login attempts, among other things. THey are nothing to worry about (probably). Anyway, to disable the warnings, add the following line to the top of onefilecms.php: +error_reporting(0); + # Current stable version: 3.1.9 From 532613fd0586e11baaccc5da1c22ccbb2154c1d5 Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Tue, 19 Jun 2012 22:35:29 -0400 Subject: [PATCH 084/228] Version 3.1.9.04 Added .$param2 to Admin link so [Cancel] from Hash page returns to either Edit page or Index, as appropriate. Removed "Visit Site" text since the favicon & URL of the site being managed are shown. In hashit(), moved $salt line up, as it was after it's first use. Edit_Page_response(), on $message lines, changed = to .= In Logout() - Missing quotes: $page = 'login' Renamed Upload_File_Response() to just Upload_response() Added ini_set('display_errors', 'off'); --- onefilecms.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index aa8d283..e4cf222 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@ File saved: '.$bytes.' bytes written.
    '; + $message .= 'File saved: '.$bytes.' bytes written.'; }else{ - $message = $EX.' There was an error saving file.'; + $message .= $EX.' There was an error saving file.'; } }//end Edit_Page_response() **************************************************** @@ -940,7 +942,7 @@ function shorthand_to_int($SHORTHAND){ //******************* -function Upload_File_response() { //******************************************** +function Upload_response() { //******************************************** global $filename, $message, $EX, $page; $filename = $_FILES['upload_file']['name']; $destination = Check_path($_POST["upload_destination"]); @@ -973,7 +975,7 @@ function Upload_File_response() { //******************************************** $message .= '
    '.$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 Date: Sat, 23 Jun 2012 13:17:27 -0400 Subject: [PATCH 085/228] Version 3.1.9.05 ini_set() some basic security & error log settings near the top. Moved $SALT back to config section Improved check of if editing OneFileCMS & path/filename has urlencoded characters. Redid hash for "password" due to hashit() fix in 3.1.9.03 session_set_cookie_params() $httponly = true; session_regenerate_id(true) every page load. I've read it's a good idea - maybe. Moved Login_Response() down to after Login_Page(). Moved Logout() down to before Login_Page(). Increased height of Edit page '.PHP_EOL; + } + } //end if !editable /else... + } //end if non-image, show textarea + + Edit_Page_Buttons($text_editable, $too_large_to_edit); + + if ($text_editable && !$too_large_to_edit && !$bad_chars) { + Edit_Page_scripts(); + $SEC = $MAX_IDLE_TIME; + $HRS = floor($SEC/3600); + $SEC = fmod($SEC,3600); + $MIN = floor($SEC/60); if ($MIN < 10) { $MIN = "0".$MIN; }; + $SEC = fmod($SEC,60); if ($SEC < 10) { $SEC = "0".$SEC; }; + $HRS_MIN_SEC = $HRS.':'.$MIN.':'.$SEC; +?> +
    NOTES:
      +
    1. Remember- your $MAX_IDLE_TIME is . + So save changes before the clock runs out, or the changes will be lost!
      + + +   ,'?> + +
    2. On 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]. +
    3. 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. +
    + + + $MAX_EDIT_SIZE); + $too_large_to_view = (filesize($filename) > $MAX_VIEW_SIZE); + + if ($too_large_to_edit){$header2 = "Viewing: ";} + else {$header2 = "Editing: ";} + + $too_large_to_edit_message = +'Edit disabled. Filesize > '.number_format($MAX_EDIT_SIZE).' bytes.
    +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; +?> +

    + Filesize: bytes   + Updated:
    +

    + + + +
    +
    '; + + 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 '

    '.$too_large_to_view_message.'

    '; + } + +}//End Edit_Page *************************************************************** + + + + +function Edit_response(){ //***If on Edit page, and [Save] clicked ************* + global $filename, $message, $EX; + $filename = $_POST["filename"]; + $content = $_POST["content"]; + + $bytes = file_put_contents($filename, $content); + + if ($bytes !== false) { + $message .= 'File saved: '.$bytes.' bytes written.'; + }else{ + $message .= $EX.' There was an error saving file.'; + } +}//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.'   per upload_max_filesize in php.ini.'; } + else { $MAX_FILE_SIZE = $PMS; $max_msg = $post_max_size.'   per post_max_size in php.ini'; } +?> +

    Upload File

    +

    Note: Maximum upload file size is:

    +
    + + + + + +
    +No file selected for upload... '; + }elseif (($destination != "") && !is_dir($destination)) { + $message .= $EX.' Destination folder does not exist:
    '; + $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

    + +

    File will be created in the current folder.   + Some invalid characters are:

    + + + +New file not created: '.htmlentities($new_name).'
    '. + '       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); } +?> +

    +

    To move a file or folder, change the path/to/folder/or_file. The new location must already exist.

    + +

    + + +

    +

    + + +

    + + +'.$msg1.' Error - new parent location does not exist:

    '; + $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

    + + + +

    Are you sure?

    + + +Deleted file: '.htmlentities(basename($filename)); + }else{ + $message .= $EX.' Error deleting "'.htmlentities($filename).'".'; + $page = "edit"; + } +}//end Delete_File_response() ************************************************** + + + + +function New_Folder_Page() { //************************************************* + global $FORM_COMMON, $INVALID_CHARS; +?> +

    New Folder

    + +

    Folder will be created in the current folder.   + Some invalid characters are:

    + + + +New folder not created: '.htmlentities($new_name).'
    '. + '       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

    + + + / +

    Are you sure?

    + + +Folder not empty.   Folders must be empty before they can be deleted.'; + $page = "index"; + }elseif (@rmdir($foldername)) { + $message .= 'Deleted folder: '.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.'; + } +}//end Delete_Folder_response() ************************************************ + + + + +function Page_Title(){ //***Page_Title()************************* + global $page; + + if ($page == "login") { return "Log In"; } + elseif ($page == "hash") { return "Hash"; } + elseif ($page == "edit") { return "Edit/View File"; } + elseif ($page == "upload") { return "Upload File"; } + elseif ($page == "newfile") { return "New File"; } + elseif ($page == "copy" ) { return "Copy"; } + elseif ($page == "rename") { return "Rename File"; } + elseif ($page == "delete") { return "Delete"; } + elseif ($page == "newfolder") { return "New Folder"; } + elseif ($page == "renamefolder") { return "Rename Folder"; } + elseif ($page == "deletefolder") { return "Delete Folder"; } + else { return $_SERVER['SERVER_NAME']; } +}//end Page_Title() ************************************************************ + + + + +function Load_Selected_Page(){ //*********************************************** + global $ONESCRIPT, $page; + + if ($page == "login") { Login_Page(); } + elseif ($page == "hash") { Hash_Page(); } + elseif ($page == "edit") { Edit_Page(); } + elseif ($page == "upload") { Upload_Page(); } + elseif ($page == "newfile") { New_File_Page(); } + elseif ($page == "copy") { Copy_Ren_Move_Page('Copy', 'File', 'copy_file', 1); } + elseif ($page == "rename") { Copy_Ren_Move_Page('Rename', 'File', 'rename_file', 1); } + elseif ($page == "delete") { Delete_File_Page(); } + elseif ($page == "newfolder") { New_Folder_Page(); } + elseif ($page == "renamefolder") { Copy_Ren_Move_Page('Rename', 'Folder', 'rename_folder', 0); } + elseif ($page == "deletefolder") { Delete_Folder_Page(); } + else { Index_Page(); } //default +}//end Load_Selected_Page() **************************************************** + + + + +function Timer_scripts() { //*************************************************** +?> + + + + + + + + +Folder not empty.   Folders must be empty before they can be deleted.'; + $page = "index";} + + //if size of $_POST > post_max_size, PHP only returns empty $_POST & $_FILE arrays. + 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] ***************************************************** + + + + +//****************************************************************************** +//****************************************************************************** +?> + + + + +<?php echo $config_title.' - '.Page_Title() ?> + + + + + + + + + + + + + +'; } + else { echo '
    '; } +?> + +
    + + + +
    +
    + + + + + + + +'; } ?> + +Admin'; } + +//Countdown timer... +if ( $page != "login" ) { + echo Timeout_Timer($MAX_IDLE_TIME, 'timer0', 'timer timeout', 'LOGOUT'); + echo 'Session time out in: '; +} +?> + +
    + + From 5648bcd9f9d2c0601684b4816a7fe19e311551ae Mon Sep 17 00:00:00 2001 From: David Date: Thu, 28 Jun 2012 18:09:12 -0400 Subject: [PATCH 092/228] Version 3.2.1 Minor readme update. --- readme.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.markdown b/readme.markdown index 4b8e2a7..84bfad1 100755 --- a/readme.markdown +++ b/readme.markdown @@ -1,5 +1,7 @@ +# Current stable version: 3.2.1 + ### 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. So, for those that care, here is a synopsis of the measures that have been employed: @@ -18,8 +20,6 @@ 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.1 - - 3+ : "Full" version - uses svg icons - 2+ : "Lite" version - uses no icons. From 530c6c6ada4c3c270f9a162557a2b702a8967c3c Mon Sep 17 00:00:00 2001 From: David Date: Sun, 1 Jul 2012 17:02:40 -0400 Subject: [PATCH 093/228] Version 3.2.2 Thanks to github.com/codeless for adding a configurable "whitelist" of files to show. Added .log to editable file types. Converted CRLF's to just LF's - cut 2040 bytes! :) Some minor code restructure in List_Files() (mostly to satisfy the OCD in me...) Tweaked Timer color when < 2:00. In Verify_IDLE_POST_etc(), removed a ['valid'] check, as it's redundant there. Hash_Page():added if (!isset($_POST['whattohash']))... Hash_response(): Removed $SALT reference as it wasn't used. Hash_response(): Added htmlspecialchars! --- onefilecms.php | 4097 ++++++++++++++++++++++++----------------------- readme.markdown | 19 +- 2 files changed, 2070 insertions(+), 2046 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index cc225b9..63bb75b 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,2041 +1,2058 @@ - $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"; //Editable file types. -$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 ******************************************************* - - - - -//****************************************************************************** -//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. -$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)); -//****************************************************************************** - - - - -function Session_Startup() {//************************************************** - global $USERNAME, $PASSWORD, $USE_HASH, $HASHWORD, $EX, $message , $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 to verify POST - - chdir($_SERVER["DOCUMENT_ROOT"]); //Allow OneFileCMS.php to be started from any dir on the site. -}//End Session_Startup() ******************************************************* - - - - -function Verify_IDLE_POST_etc() { //******************************************** - global $EX, $message, $VALID_POST, $MAX_IDLE_TIME; - - //Verify consistant user agent... (every little bit helps a little bit) - if ( ($_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) ) { Logout(); } - - //Check idle time - if ( isset($_SESSION['last_active_time']) ) { - $idle_time = ( time() - $_SESSION['last_active_time'] ); - if ( $_SESSION['valid'] && ($idle_time > $MAX_IDLE_TIME) ) { - Logout(); - $message .= 'Session expired.
    '; - } - } - - $_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)) { -?> -

    - - - [X] - - -

    - -
    '; // Needed on Edit page to keep js feedback from failing - } //end isset($message) - - // Used on Edit Page to preserve vertical spacing, so edit area doesn't jump as much. - if ($page == "edit") {echo '';} -}//end message_box() ********************************************************** - - - - -function Upload_New_Rename_Delete_Links() { //********************************** - global $ONESCRIPT, $ipath, $param1; - echo ''; -}//end 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, $param2, $filename, $page; - - // [Cancel] returns to either the index, or edit page. - if ($filename == "") {$params = "";}else{ $params = $param2.'&p=edit'; } -?> -

    - - -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].').

    '; - echo '
    '.PHP_EOL; - echo ''.PHP_EOL; - echo ''.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 = '
    '.$INPUT_NUONCE; - -$SVG_icon_circle_plus = ' - - '; - -$SVG_icon_circle_x = ' - - '; - -$SVG_icon_pencil = ' - - - - '; - -$SVG_icon_img_0 = ' - - - '; -}//end Init_Macros() *********************************************************** - - - - -function svg_icon_bin(){ //***************************************************** -$zero = ''; -$one = ''; -?> - - - - - - - - - - - - - - - - - - - - - - - - '; - svg_icon_txt_0('#333', 'black', 'white', $extra); -} //end svg_icon_upload() ****************************************************** - - - -function svg_icon_file_new(){ //************************************************ - global $SVG_icon_circle_plus; - $extra = ''.$SVG_icon_circle_plus.''; - svg_icon_txt_0('#444', 'black', 'white', $extra); -} //end svg_icon_file_new() **************************************************** - - - -function svg_icon_file_del(){ //************************************************ -global $SVG_icon_circle_x; - $extra = ''.$SVG_icon_circle_x.''; - svg_icon_txt_0('#444', 'black', 'white', $extra); -} //end svg_icon_file_del() **************************************************** - - - -function svg_icon_folder_0($extra){ //****************************************** -?> - - - - -'.$SVG_icon_circle_plus.''; - svg_icon_folder_0($extra); -} //end svg_icon_folder_new() ************************************************** - - - -function svg_icon_folder_ren(){ //********************************************** - global $SVG_icon_pencil; - $extra = ''.$SVG_icon_pencil.''; - svg_icon_folder_0($extra); -} //end svg_icon_folder_ren() ************************************************** - - - -function svg_icon_folder_del(){ //********************************************** - global $SVG_icon_circle_x; - $extra = ''.$SVG_icon_circle_x.''; - svg_icon_folder_0($extra); -} //end svg_icon_folder_del() ************************************************** - - - - -function show_icon($type){ //*************************************************** - if ($type == 'bin') { svg_icon_bin(); } - elseif ($type == 'img') { svg_icon_img(); } - elseif ($type == 'svg') { svg_icon_svg(); } - elseif ($type == 'txt') { svg_icon_txt(); } - elseif ($type == 'htm') { svg_icon_htm(); } - elseif ($type == 'php') { svg_icon_php(); } - elseif ($type == 'css') { svg_icon_css(); } - elseif ($type == 'cfg') { svg_icon_cfg(); } - else { svg_icon_bin(); } //default -}//end show_icon() ************************************************************* - - - - -function Hash_Page() { //****************************************************** - global $DOC_ROOT, $ONESCRIPT, $param1, $param2, $message, $INPUT_NUONCE, $config_title; - $params = '?i='.dirname($ONESCRIPT).'&f='.basename($ONESCRIPT).'&p=edit'; -?> - - -

    Generate a Password Hash

    - - - - Password to hash: - "> - - Edit   - - -
    -

    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).
    - 2) Or, use $HASHWORD to store the hash of your password, and set $USE_HASH = 1.
    - -

    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: -

    1. Type your desired password in the input field above and hit Enter.
      - The hash will be displayed in a yellow message box above that. -
    2. Copy and paste the new hash to the $HASHWORD variable in the config section.
      - '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... -
    3. Make sure $USE_HASH is set to 1 (or true). -
    4. When ready, logout and login. -
    -

    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...
    - PS: Everything I know about security - you just read... -

    -'; - $message .= 'Hash    : '.hashit($_POST["whattohash"]); -} //end Hash_response() ******************************************************** - - - - -function Logout() { //********************************************************** - global $page; - session_regenerate_id(true); - session_unset(); - session_destroy(); - session_write_close(); - unset($_GET); - unset($_POST); - $_SESSION['valid'] = 0; - $page = 'login'; -}//end Logout() **************************************************************** - - - - -function Login_Page() { //****************************************************** - global $ONESCRIPT, $message; -?> -

    Log In

    -
    -

    - - -

    -

    - - -

    - -

    -
    - - 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 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)]; -?> - - - - - -'; -}//end List_Files() ************************************************************ - - - - -function Index_Page(){ //******************************************************* - global $ONESCRIPT, $ipath; - - // - echo '

    '; - $folders = glob($ipath."*",GLOB_ONLYDIR); - natcasesort($folders); - foreach ($folders as $folder) { - echo ''.PHP_EOL; - svg_icon_folder(); - echo htmlentities(basename($folder)).' /'; - } - echo '

    '; - - Upload_New_Rename_Delete_Links(); - - List_Files(); - - Upload_New_Rename_Delete_Links(); - -}//end Index_Page()************************************************************* - - - - -function Edit_Page_Buttons($text_editable, $too_large_to_edit) { //************* - global $ONESCRIPT, $param1, $param2, $MAX_IDLE_TIME; - $Button = ' - - - - - - - rename'"> - copy'" > - delete'"> - onclick="parent.location = ''"> -

    - - - -Non-text or unkown file type. Edit disabled.

    '; - - }elseif ( $too_large_to_edit ) { - echo '

    '.$too_large_to_edit_message.'

    '; - - }else{ - if (PHP_VERSION_ID < 50400) { // 5.4.0 - $filecontent = htmlspecialchars(file_get_contents($filename)); - }else{ - $filecontent = htmlspecialchars(file_get_contents($filename),ENT_SUBSTITUTE); - } - $bad_chars = ($filecontent == "" && filesize($filename) > 0); - - if ($bad_chars){ //did specialchars return an empty string? - echo '
    '.$EX.' File contains an invalid character. Edit and view disabled.
    '; - 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 ''.PHP_EOL; - } - } //end if !editable /else... - } //end if non-image, show textarea - - Edit_Page_Buttons($text_editable, $too_large_to_edit); - - if ($text_editable && !$too_large_to_edit && !$bad_chars) { - Edit_Page_scripts(); - $SEC = $MAX_IDLE_TIME; - $HRS = floor($SEC/3600); - $SEC = fmod($SEC,3600); - $MIN = floor($SEC/60); if ($MIN < 10) { $MIN = "0".$MIN; }; - $SEC = fmod($SEC,60); if ($SEC < 10) { $SEC = "0".$SEC; }; - $HRS_MIN_SEC = $HRS.':'.$MIN.':'.$SEC; -?> -
    NOTES:
      -
    1. Remember- your $MAX_IDLE_TIME is . - So save changes before the clock runs out, or the changes will be lost!
      - - -   ,'?> - -
    2. On 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]. -
    3. 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. -
    - - - $MAX_EDIT_SIZE); - $too_large_to_view = (filesize($filename) > $MAX_VIEW_SIZE); - - if ($too_large_to_edit){$header2 = "Viewing: ";} - else {$header2 = "Editing: ";} - - $too_large_to_edit_message = -'Edit disabled. Filesize > '.number_format($MAX_EDIT_SIZE).' bytes.
    -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; -?> -

    - Filesize: bytes   - Updated:
    -

    - - - -
    -'; - - 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 '

    '.$too_large_to_view_message.'

    '; - } - -}//End Edit_Page *************************************************************** - - - - -function Edit_response(){ //***If on Edit page, and [Save] clicked ************* - global $filename, $message, $EX; - $filename = $_POST["filename"]; - $content = $_POST["content"]; - - $bytes = file_put_contents($filename, $content); - - if ($bytes !== false) { - $message .= 'File saved: '.$bytes.' bytes written.'; - }else{ - $message .= $EX.' There was an error saving file.'; - } -}//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.'   per upload_max_filesize in php.ini.'; } - else { $MAX_FILE_SIZE = $PMS; $max_msg = $post_max_size.'   per post_max_size in php.ini'; } -?> -

    Upload File

    -

    Note: Maximum upload file size is:

    - - - - - - - -No file selected for upload... '; - }elseif (($destination != "") && !is_dir($destination)) { - $message .= $EX.' Destination folder does not exist:
    '; - $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

    - -

    File will be created in the current folder.   - Some invalid characters are:

    - - - -New file not created: '.htmlentities($new_name).'
    '. - '       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); } -?> -

    -

    To move a file or folder, change the path/to/folder/or_file. The new location must already exist.

    - -

    - - -

    -

    - - -

    - - -'.$msg1.' Error - new parent location does not exist:

    '; - $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

    - - - -

    Are you sure?

    - - -Deleted file: '.htmlentities(basename($filename)); - }else{ - $message .= $EX.' Error deleting "'.htmlentities($filename).'".'; - $page = "edit"; - } -}//end Delete_File_response() ************************************************** - - - - -function New_Folder_Page() { //************************************************* - global $FORM_COMMON, $INVALID_CHARS; -?> -

    New Folder

    - -

    Folder will be created in the current folder.   - Some invalid characters are:

    - - - -New folder not created: '.htmlentities($new_name).'
    '. - '       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

    - - - / -

    Are you sure?

    - - -Folder not empty.   Folders must be empty before they can be deleted.'; - $page = "index"; - }elseif (@rmdir($foldername)) { - $message .= 'Deleted folder: '.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.'; - } -}//end Delete_Folder_response() ************************************************ - - - - -function Page_Title(){ //***Page_Title()************************* - global $page; - - if ($page == "login") { return "Log In"; } - elseif ($page == "hash") { return "Hash"; } - elseif ($page == "edit") { return "Edit/View File"; } - elseif ($page == "upload") { return "Upload File"; } - elseif ($page == "newfile") { return "New File"; } - elseif ($page == "copy" ) { return "Copy"; } - elseif ($page == "rename") { return "Rename File"; } - elseif ($page == "delete") { return "Delete"; } - elseif ($page == "newfolder") { return "New Folder"; } - elseif ($page == "renamefolder") { return "Rename Folder"; } - elseif ($page == "deletefolder") { return "Delete Folder"; } - else { return $_SERVER['SERVER_NAME']; } -}//end Page_Title() ************************************************************ - - - - -function Load_Selected_Page(){ //*********************************************** - global $ONESCRIPT, $page; - - if ($page == "login") { Login_Page(); } - elseif ($page == "hash") { Hash_Page(); } - elseif ($page == "edit") { Edit_Page(); } - elseif ($page == "upload") { Upload_Page(); } - elseif ($page == "newfile") { New_File_Page(); } - elseif ($page == "copy") { Copy_Ren_Move_Page('Copy', 'File', 'copy_file', 1); } - elseif ($page == "rename") { Copy_Ren_Move_Page('Rename', 'File', 'rename_file', 1); } - elseif ($page == "delete") { Delete_File_Page(); } - elseif ($page == "newfolder") { New_Folder_Page(); } - elseif ($page == "renamefolder") { Copy_Ren_Move_Page('Rename', 'Folder', 'rename_folder', 0); } - elseif ($page == "deletefolder") { Delete_Folder_Page(); } - else { Index_Page(); } //default -}//end Load_Selected_Page() **************************************************** - - - - -function Timer_scripts() { //*************************************************** -?> - - - - - - - - -Folder not empty.   Folders must be empty before they can be deleted.'; - $page = "index";} - - //if size of $_POST > post_max_size, PHP only returns empty $_POST & $_FILE arrays. - 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] ***************************************************** - - - - -//****************************************************************************** -//****************************************************************************** -?> - - - - -<?php echo $config_title.' - '.Page_Title() ?> - - - - - - - - - - - - - -'; } - else { echo '
    '; } -?> - -
    - - - -
    -
    - - - - - - - -'; } ?> - -Admin'; } - -//Countdown timer... -if ( $page != "login" ) { - echo Timeout_Timer($MAX_IDLE_TIME, 'timer0', 'timer timeout', 'LOGOUT'); - echo 'Session time out in: '; -} -?> - -
    - - + +$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 = 30; //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 ******************************************************* + + + + +//****************************************************************************** +//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)); +//****************************************************************************** + + + + +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 to verify POST + + chdir($_SERVER["DOCUMENT_ROOT"]); //Allow OneFileCMS.php to be started from any dir on the site. +}//End Session_Startup() ******************************************************* + + + + +function Verify_IDLE_POST_etc() { //******************************************** + global $EX, $message, $VALID_POST, $MAX_IDLE_TIME; + + //Verify consistant user agent... (every little bit helps a little bit) + if ( ($_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) ) { Logout(); } + + //Check idle time + if ( isset($_SESSION['last_active_time']) ) { + $idle_time = ( time() - $_SESSION['last_active_time'] ); + if ( $idle_time > $MAX_IDLE_TIME ) { + Logout(); + $message .= 'Session expired.
    '; + } + } + + $_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)) { +?> +

    + + + [X] + + +

    + +'; // Needed on Edit page to keep js feedback from failing + } //end isset($message) + + // Used on Edit Page to preserve vertical spacing, so edit area doesn't jump as much. + if ($page == "edit") {echo '';} +}//end message_box() ********************************************************** + + + + +function Upload_New_Rename_Delete_Links() { //********************************** + global $ONESCRIPT, $ipath, $param1; + echo ''; +}//end 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, $param2, $filename, $page; + + // [Cancel] returns to either the index, or edit page. + if ($filename == "") {$params = "";}else{ $params = $param2.'&p=edit'; } +?> +

    + + +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].').

    '; + echo '
    '.PHP_EOL; + echo ''.PHP_EOL; + echo ''.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 = '
    '.$INPUT_NUONCE; + +$SVG_icon_circle_plus = ' + + '; + +$SVG_icon_circle_x = ' + + '; + +$SVG_icon_pencil = ' + + + + '; + +$SVG_icon_img_0 = ' + + + '; +}//end Init_Macros() *********************************************************** + + + + +function svg_icon_bin(){ //***************************************************** +$zero = ''; +$one = ''; +?> + + + + + + + + + + + + + + + + + + + + + + + + '; + svg_icon_txt_0('#333', 'black', 'white', $extra); +} //end svg_icon_upload() ****************************************************** + + + +function svg_icon_file_new(){ //************************************************ + global $SVG_icon_circle_plus; + $extra = ''.$SVG_icon_circle_plus.''; + svg_icon_txt_0('#444', 'black', 'white', $extra); +} //end svg_icon_file_new() **************************************************** + + + +function svg_icon_file_del(){ //************************************************ +global $SVG_icon_circle_x; + $extra = ''.$SVG_icon_circle_x.''; + svg_icon_txt_0('#444', 'black', 'white', $extra); +} //end svg_icon_file_del() **************************************************** + + + +function svg_icon_folder_0($extra){ //****************************************** +?> + + + + +'.$SVG_icon_circle_plus.''; + svg_icon_folder_0($extra); +} //end svg_icon_folder_new() ************************************************** + + + +function svg_icon_folder_ren(){ //********************************************** + global $SVG_icon_pencil; + $extra = ''.$SVG_icon_pencil.''; + svg_icon_folder_0($extra); +} //end svg_icon_folder_ren() ************************************************** + + + +function svg_icon_folder_del(){ //********************************************** + global $SVG_icon_circle_x; + $extra = ''.$SVG_icon_circle_x.''; + svg_icon_folder_0($extra); +} //end svg_icon_folder_del() ************************************************** + + + + +function show_icon($type){ //*************************************************** + if ($type == 'bin') { svg_icon_bin(); } + elseif ($type == 'img') { svg_icon_img(); } + elseif ($type == 'svg') { svg_icon_svg(); } + elseif ($type == 'txt') { svg_icon_txt(); } + elseif ($type == 'htm') { svg_icon_htm(); } + elseif ($type == 'php') { svg_icon_php(); } + elseif ($type == 'css') { svg_icon_css(); } + elseif ($type == 'cfg') { svg_icon_cfg(); } + else { svg_icon_bin(); } //default +}//end show_icon() ************************************************************* + + + + +function Hash_Page() { //****************************************************** + 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

    + + + + Password to hash: + "> + + Edit   + + +
    +

    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).
    + 2) Or, use $HASHWORD to store the hash of your password, and set $USE_HASH = 1.
    + +

    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: +

    1. Type your desired password in the input field above and hit Enter.
      + The hash will be displayed in a yellow message box above that. +
    2. Copy and paste the new hash to the $HASHWORD variable in the config section.
      + '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... +
    3. Make sure $USE_HASH is set to 1 (or true). +
    4. When ready, logout and login. +
    +

    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...
    + PS: Everything I know about security - you just read... +

    +'; + $message .= 'Hash    : '.htmlspecialchars(hashit($_POST["whattohash"])); +} //end Hash_response() ******************************************************** + + + + +function Logout() { //********************************************************** + global $page; + session_regenerate_id(true); + session_unset(); + session_destroy(); + session_write_close(); + unset($_GET); + unset($_POST); + $_SESSION['valid'] = 0; + $page = 'login'; +}//end Logout() **************************************************************** + + + + +function Login_Page() { //****************************************************** + global $ONESCRIPT, $message; +?> +

    Log In

    +
    +

    + + +

    +

    + + +

    + +

    + + + 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 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 '
    - '; ?> - '; ?> -   - B -   - -
    '; + 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)]; +?> + + + + + +'; +}//end List_Files() ************************************************************ + + + + +function Index_Page(){ //******************************************************* + global $ONESCRIPT, $ipath; + + // + echo '

    '; + $folders = glob($ipath."*",GLOB_ONLYDIR); + natcasesort($folders); + foreach ($folders as $folder) { + echo ''.PHP_EOL; + svg_icon_folder(); + echo htmlentities(basename($folder)).' /'; + } + echo '

    '; + + Upload_New_Rename_Delete_Links(); + + List_Files(); + + Upload_New_Rename_Delete_Links(); + +}//end Index_Page()************************************************************* + + + + +function Edit_Page_Buttons($text_editable, $too_large_to_edit) { //************* + global $ONESCRIPT, $param1, $param2, $MAX_IDLE_TIME; + $Button = ' + + + + + + + rename'"> + copy'" > + delete'"> + onclick="parent.location = ''"> +

    + + + +Non-text or unkown file type. Edit disabled.

    '; + + }elseif ( $too_large_to_edit ) { + echo '

    '.$too_large_to_edit_message.'

    '; + + }else{ + if (PHP_VERSION_ID < 50400) { // 5.4.0 + $filecontent = htmlspecialchars(file_get_contents($filename)); + }else{ + $filecontent = htmlspecialchars(file_get_contents($filename),ENT_SUBSTITUTE); + } + $bad_chars = ($filecontent == "" && filesize($filename) > 0); + + if ($bad_chars){ //did specialchars return an empty string? + echo '
    '.$EX.' File contains an invalid character. Edit and view disabled.
    '; + 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 ''.PHP_EOL; + } + } //end if !editable /else... + } //end if non-image, show textarea + + Edit_Page_Buttons($text_editable, $too_large_to_edit); + + if ($text_editable && !$too_large_to_edit && !$bad_chars) { + Edit_Page_scripts(); + $SEC = $MAX_IDLE_TIME; + $HRS = floor($SEC/3600); + $SEC = fmod($SEC,3600); + $MIN = floor($SEC/60); if ($MIN < 10) { $MIN = "0".$MIN; }; + $SEC = fmod($SEC,60); if ($SEC < 10) { $SEC = "0".$SEC; }; + $HRS_MIN_SEC = $HRS.':'.$MIN.':'.$SEC; +?> +
    NOTES:
      +
    1. Remember- your $MAX_IDLE_TIME is . + So save changes before the clock runs out, or the changes will be lost!
      + + +   ,'?> + +
    2. On 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]. +
    3. 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. +
    + + + $MAX_EDIT_SIZE); + $too_large_to_view = (filesize($filename) > $MAX_VIEW_SIZE); + + if ($too_large_to_edit){$header2 = "Viewing: ";} + else {$header2 = "Editing: ";} + + $too_large_to_edit_message = +'Edit disabled. Filesize > '.number_format($MAX_EDIT_SIZE).' bytes.
    +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; +?> +

    + Filesize: bytes   + Updated:
    +

    + + + +
    +'; + + 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 '

    '.$too_large_to_view_message.'

    '; + } + +}//End Edit_Page *************************************************************** + + + + +function Edit_response(){ //***If on Edit page, and [Save] clicked ************* + global $filename, $message, $EX; + $filename = $_POST["filename"]; + $content = $_POST["content"]; + + $bytes = file_put_contents($filename, $content); + + if ($bytes !== false) { + $message .= 'File saved: '.$bytes.' bytes written.'; + }else{ + $message .= $EX.' There was an error saving file.'; + } +}//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.'   per upload_max_filesize in php.ini.'; } + else { $MAX_FILE_SIZE = $PMS; $max_msg = $post_max_size.'   per post_max_size in php.ini'; } +?> +

    Upload File

    +

    Note: Maximum upload file size is:

    + + + + + + + +No file selected for upload... '; + }elseif (($destination != "") && !is_dir($destination)) { + $message .= $EX.' Destination folder does not exist:
    '; + $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

    + +

    File will be created in the current folder.   + Some invalid characters are:

    + + + +New file not created: '.htmlentities($new_name).'
    '. + '       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); } +?> +

    +

    To move a file or folder, change the path/to/folder/or_file. The new location must already exist.

    + +

    + + +

    +

    + + +

    + + +'.$msg1.' Error - new parent location does not exist:

    '; + $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

    + + + +

    Are you sure?

    + + +Deleted file: '.htmlentities(basename($filename)); + }else{ + $message .= $EX.' Error deleting "'.htmlentities($filename).'".'; + $page = "edit"; + } +}//end Delete_File_response() ************************************************** + + + + +function New_Folder_Page() { //************************************************* + global $FORM_COMMON, $INVALID_CHARS; +?> +

    New Folder

    + +

    Folder will be created in the current folder.   + Some invalid characters are:

    + + + +New folder not created: '.htmlentities($new_name).'
    '. + '       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

    + + + / +

    Are you sure?

    + + +Folder not empty.   Folders must be empty before they can be deleted.'; + $page = "index"; + }elseif (@rmdir($foldername)) { + $message .= 'Deleted folder: '.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.'; + } +}//end Delete_Folder_response() ************************************************ + + + + +function Page_Title(){ //***Page_Title()************************* + global $page; + + if ($page == "login") { return "Log In"; } + elseif ($page == "hash") { return "Hash"; } + elseif ($page == "edit") { return "Edit/View File"; } + elseif ($page == "upload") { return "Upload File"; } + elseif ($page == "newfile") { return "New File"; } + elseif ($page == "copy" ) { return "Copy"; } + elseif ($page == "rename") { return "Rename File"; } + elseif ($page == "delete") { return "Delete"; } + elseif ($page == "newfolder") { return "New Folder"; } + elseif ($page == "renamefolder") { return "Rename Folder"; } + elseif ($page == "deletefolder") { return "Delete Folder"; } + else { return $_SERVER['SERVER_NAME']; } +}//end Page_Title() ************************************************************ + + + + +function Load_Selected_Page(){ //*********************************************** + global $ONESCRIPT, $page; + + if ($page == "login") { Login_Page(); } + elseif ($page == "hash") { Hash_Page(); } + elseif ($page == "edit") { Edit_Page(); } + elseif ($page == "upload") { Upload_Page(); } + elseif ($page == "newfile") { New_File_Page(); } + elseif ($page == "copy") { Copy_Ren_Move_Page('Copy', 'File', 'copy_file', 1); } + elseif ($page == "rename") { Copy_Ren_Move_Page('Rename', 'File', 'rename_file', 1); } + elseif ($page == "delete") { Delete_File_Page(); } + elseif ($page == "newfolder") { New_Folder_Page(); } + elseif ($page == "renamefolder") { Copy_Ren_Move_Page('Rename', 'Folder', 'rename_folder', 0); } + elseif ($page == "deletefolder") { Delete_Folder_Page(); } + else { Index_Page(); } //default +}//end Load_Selected_Page() **************************************************** + + + + +function Timer_scripts() { //*************************************************** +?> + + + + + + + + +Folder not empty.   Folders must be empty before they can be deleted.'; + $page = "index";} + + //if size of $_POST > post_max_size, PHP only returns empty $_POST & $_FILE arrays. + 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] ***************************************************** + + + + +//****************************************************************************** +//****************************************************************************** +?> + + + + +<?php echo $config_title.' - '.Page_Title() ?> + + + + + + + + + + + + + +'; } + else { echo '
    '; } +?> + +
    + + + +
    +
    + + + + + + + +'; } ?> + +Admin'; } + +//Countdown timer... +if ( $page != "login" ) { + echo Timeout_Timer($MAX_IDLE_TIME, 'timer0', 'timer timeout', 'LOGOUT'); + echo 'Session time out in: '; +} +?> + +
    + + diff --git a/readme.markdown b/readme.markdown index 84bfad1..b74729e 100755 --- a/readme.markdown +++ b/readme.markdown @@ -1,6 +1,6 @@ -# Current stable version: 3.2.1 +# Current stable version: 3.2.2 -### June 28, 2012 +### July 1, 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. @@ -72,7 +72,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 probably 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 probably 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. 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. @@ -96,7 +96,7 @@ Probably not, as that would also most likely make it more than "OneFile". 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 gets corrupted. +Now, since there is no database 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 @@ -121,12 +121,12 @@ To report a bug or request a feature, please file an issue via Github. Forks enc ##Needed/potential/upcoming 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+. -- Issue with Chrome's XSS filter: Editing some legitimate files with OneFileCMS will trigger the filter and disable most javascript provided functionallity, but only while on edit page of such a file. +- 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 edit page with such a file, and only after a [Save]. - 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.) - Be aware that only some very basic data & error checking is performed. (But, it's getting better...) On Windows, for instance, it's possible to create folders that are subsequently inaccessible and undeletable by Windows. (Yea, I found out the hard way...) -- Multiple login names. +- Multiple languages support - Anything else? -------------------------------------------------------------------------------- @@ -164,6 +164,13 @@ GENERATE THE PAGE ## Change Log +### 3.2.2 + +- Thanks to github.com/codeless: added a configurable whitelist of files to show. +- Fixed minor issue on hash page (needed htmlspecialchars) +- And, of course, various style & code tweaks. + + ### 3.2.1 - Added timer to "Please wait..." message after too many invalid login attempts. From fa4d5c1e6ba81bf889028ee20fffab160d09d08e Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Jul 2012 17:25:47 -0400 Subject: [PATCH 094/228] Version 3.2.2.1 Added ability to process a config file. (courtesy gitghub/codeless) --- onefilecms.php | 32 +++++++++++++++++++++++++++++++- readme.markdown | 11 +++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/onefilecms.php b/onefilecms.php index 63bb75b..9d08e55 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@ $value) { + # Check if variable can get overwritten: + if (in_array($key, $overwritable_variables)) { + $GLOBALS[$key] = $value; + } + } +} +// End PROCESSING CONFIGURATION FILE ******************************************* + + + + //****************************************************************************** //Some global system values diff --git a/readme.markdown b/readme.markdown index b74729e..bfcfede 100755 --- a/readme.markdown +++ b/readme.markdown @@ -1,4 +1,8 @@ +<<<<<<< HEAD # Current stable version: 3.2.2 +======= +# Current stable version: 3.2.3 +>>>>>>> 4c97063efc47e8bb1c0789f620e88d2dcf2c5427 ### July 1, 2012 @@ -164,6 +168,13 @@ GENERATE THE PAGE ## Change Log +<<<<<<< HEAD +======= +### 3.2.3 + +- Added support for a configuration file (ofcms.ini) + +>>>>>>> 4c97063efc47e8bb1c0789f620e88d2dcf2c5427 ### 3.2.2 - Thanks to github.com/codeless: added a configurable whitelist of files to show. From 7c5ae85e5860deb1c6d87328fc41f9b8fddb1d90 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Jul 2012 18:00:10 -0400 Subject: [PATCH 095/228] Version 3.2.3 Login_response(): Improved use of $LOGIN_ATTEMPTS. Tweaked some css. Renamed file_content to file_contents. (It just bugged me) Improved $too_large_... logic. Edit_Page(): Added [Wide View] button. (Includes some js) Split out Edit_Page_Notes() from Edit_Page_form() --- onefilecms.php | 224 ++++++++++++++++++++++++++++-------------------- readme.markdown | 48 ++++------- 2 files changed, 145 insertions(+), 127 deletions(-) diff --git a/onefilecms.php b/onefilecms.php index 9d08e55..ffc5e0f 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@ '; echo 'Image shown at ~'. round($SCALE*100) .'% of full size (W x H = '.$img_info[0].' x '.$img_info[1].').

    '; - echo '
    '.PHP_EOL; + echo '
    '.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; }// end show_image() *********************************************************** @@ -699,20 +699,20 @@ 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 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:

    1. Type your desired password in the input field above and hit Enter.
      The hash will be displayed in a yellow message box above that.
    2. Copy and paste the new hash to the $HASHWORD variable in the config section.
      - '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...
    3. Make sure $USE_HASH is set to 1 (or true).
    4. When ready, logout and login.

    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...
    + 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 = ' +

    - + ,'?> + +
  • On 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]. +
  • 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. + +
  • +"> Non-text or unkown file type. Edit disabled.

    '; }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.
    '; 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 ''.PHP_EOL; } } //end if !editable /else... @@ -944,28 +974,10 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_ Edit_Page_Buttons($text_editable, $too_large_to_edit); - if ($text_editable && !$too_large_to_edit && !$bad_chars) { - Edit_Page_scripts(); - $SEC = $MAX_IDLE_TIME; - $HRS = floor($SEC/3600); - $SEC = fmod($SEC,3600); - $MIN = floor($SEC/60); if ($MIN < 10) { $MIN = "0".$MIN; }; - $SEC = fmod($SEC,60); if ($SEC < 10) { $SEC = "0".$SEC; }; - $HRS_MIN_SEC = $HRS.':'.$MIN.':'.$SEC; -?> -
    NOTES:
      -
    1. Remember- your $MAX_IDLE_TIME is . - So save changes before the clock runs out, or the changes will be lost!
      - - -   ,'?> - -
    2. On 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]. -
    3. 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. -
    - - - + $MAX_EDIT_SIZE); $too_large_to_view = (filesize($filename) > $MAX_VIEW_SIZE); - if ($too_large_to_edit){$header2 = "Viewing: ";} - else {$header2 = "Editing: ";} + if ( $too_large_to_edit ) { $header2 = "Viewing: "; } + else { $header2 = "Editing: "; } $too_large_to_edit_message = 'Edit disabled. Filesize > '.number_format($MAX_EDIT_SIZE).' bytes.
    @@ -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; ?> -

    - Filesize: bytes   - Updated:
    -

    - - - -
    +
    +
    + Filesize: bytes   + Updated:
    +
    + +
    + + + + + +
    +
    +
    '; + echo '
    '; - if ( $text_editable && $too_large_to_edit && !$too_large_to_view ) { + if ( $text_editable && $too_large_to_view ) { + echo '

    '.$too_large_to_view_message.'

    '; + } + elseif ( $text_editable && $too_large_to_edit ){ $filecontent = htmlspecialchars(file_get_contents($filename), ENT_COMPAT,'UTF-8'); echo '
    '.$filecontent.'
    '; - }elseif ( $text_editable && $too_large_to_view ){ - echo '

    '.$too_large_to_view_message.'

    '; } - }//End Edit_Page *************************************************************** @@ -1453,7 +1473,8 @@ function Start_Countdown(count, ID, CLASS, Action){ Countdown(count, Time_End, ID, CLASS, Action); //(seconds to count, id of element) } - 12 ) {HOURS = HOURS - 12; } HOURS = pad(HOURS); @@ -1499,7 +1519,8 @@ function FileTimeStamp(php_filemtime, show_date, show_offset){ }//end FileTimeStamp(php_filemtime) - - .container { border : 0px solid #807568; width : 810px; - margin : 0em auto; + margin : 0 auto 2em auto; } @@ -1799,21 +1835,11 @@ function style_sheet(){ //****************************************************?> font: 1em "Courier New", Courier, monospace; } -textarea { - border: 1px solid #999; - font : .95em "Courier New", Courier, monospace; - margin: 0 0 0 0; /*T R B L*/ - width : 99.5%; - height: 30em; - } - -textarea:focus { border: 1px solid #Fdd; } - .edit_disabled { border : 1px solid #807568; width : 99%; padding: .2em; - margin : 0; + margin : .5em 0 0 0; background-color: #FFF000; color: #333; line-height: 1.4em; } @@ -1876,11 +1902,17 @@ function style_sheet(){ //****************************************************?> #edit_form {margin: 0;} -#file_content {height: 30em;} +#file_contents { + border: 1px solid #999; + font : .95em "Courier New", Courier, monospace; + margin: 0 0 0 0; /*T R B L*/ + width : 99.7%; + height: 30em; +} -.file_meta {float: left; margin-top: .5em; font-size: 1em; color: #333; font-family: courier;} +#file_contents:focus { border: 1px solid #Fdd; } -#close1 {float: right; margin-bottom: .5em;} +.file_meta {float: left; margin-top: .5em; font-size: 1em; color: #333; } /*font-family: courier;*/ #edit_notes {font-size: .8em; color: #333 ;margin-top: 1em; clear:both;} @@ -1952,13 +1984,17 @@ function style_sheet(){ //****************************************************?> .edit_onefile {padding: 5px; float: right;} -.xtra {color: red; background: #EEE;} - .timer {border: 1px solid gray; padding: 3px .5em 4px .5em;} -.timeout {float:right; font-size: .95em; color: #333} +.timeout {float:right; font-size: .95em; color: #333; } + +.edit_btns_top { margin: .2em 0 .5em 0;} + +.edit_btns_bottom { margin: .6em 0 0 0; float: right; } +.edit_btns_bottom .button { margin-left: .5em; } - -'; } - else { echo '
    '; } +'; } + else { echo '
    '; } ?>
    @@ -2060,7 +2096,7 @@ function style_sheet(){ //****************************************************?> | Log Out -
    +
    diff --git a/readme.markdown b/readme.markdown index bfcfede..d233b09 100755 --- a/readme.markdown +++ b/readme.markdown @@ -1,32 +1,12 @@ -<<<<<<< HEAD -# Current stable version: 3.2.2 -======= # Current stable version: 3.2.3 ->>>>>>> 4c97063efc47e8bb1c0789f620e88d2dcf2c5427 -### July 1, 2012 +### July 5, 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. - -So, for those that care, here is a synopsis of the measures that have been employed: -- A password's hash can now be stored by OneFileCMS, instead of the plain text password. - (The plain text method remains an option for those that just don't care. ) -- A Login delay is triggered after too many invalid attempts. -- Adjustable max idle time before auto-logout. -- Check consistancy of user agent during session. -- Generation of a new session id after login or logout. -- Set session.use_only_cookies == true. -- Use httponly cookies -- Ability to modify the default salt and password hash method. - (Since OneFileCMS is open source, this is recommended) - -Now, keep in mind that while, individually, any one of these measures may not provide much security, collectivly, they're a little better than nothing. +Partly to prepare for future capabilities, the ability to process an exteranal config file was added. It is not required, so OneFileCMS is still one file, but it adds some flexibility. -Lastly, always remember that some of the most important security measures concern user behavior - such as avoiding the use of un-encrypted wifi connections... +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. +However, always remember that of the most important security measures concern user behavior - such as avoiding the use of un-encrypted wifi connections... -- 3+ : "Full" version - uses svg icons -- 2+ : "Lite" version - uses no icons. - -------------------------------------------------------------------------------- # OneFileCMS @@ -52,7 +32,9 @@ Coupling a utilitarian code editor with basic file managing functions, OneFileCM - 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.)_ -- Alert if you try to leave without saving your edits +- Alert if you try to leave without saving your edits. +- A Login delay after too many invalid attempts. +- Adjustable idle time before auto-logout. - Easily modifiable & re-brandable. - Possibly the easiest installation process ever! @@ -94,7 +76,7 @@ Well, because "OneFileFileManagerTextEditor" just doesn't have the same ring to ### Multi-Language Support? -Probably not, as that would also most likely make it more than "OneFile". +Possibly! (But not yet...) ### Can I have more than one username/password? @@ -124,13 +106,13 @@ To report a bug or request a feature, please file an issue via Github. Forks enc ##Needed/potential/upcoming improvements +- Multiple languages support - 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 edit page with such a file, and only after a [Save]. - 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.) - Be aware that only some very basic data & error checking is performed. (But, it's getting better...) On Windows, for instance, it's possible to create folders that are subsequently inaccessible and undeletable by Windows. (Yea, I found out the hard way...) -- Multiple languages support - Anything else? -------------------------------------------------------------------------------- @@ -168,13 +150,13 @@ GENERATE THE PAGE ## Change Log -<<<<<<< HEAD -======= ### 3.2.3 -- Added support for a configuration file (ofcms.ini) +- Thanks to github.com/codeless: added the ability to process a seperate config file. + (This is just an option for flexibility, and is not required) +- Added a [Wide View] button to Edit page. +- Some minor code improvement & css tweaking. ->>>>>>> 4c97063efc47e8bb1c0789f620e88d2dcf2c5427 ### 3.2.2 - Thanks to github.com/codeless: added a configurable whitelist of files to show. @@ -201,12 +183,12 @@ GENERATE THE PAGE ### 3.1.6 thru 3.1.8 -- Converted bulk of rest of code into functions (easier to work with) +- Converted bulk of rest of code into functions (easier to work with). - Resolved issue (I hope) with differing versions of PHP and how magic_quotes & stripslashes are handeled. ### 3.1.2 thru 3.1.5 -- Added file size limits to the Edit/View page. (Some browsers don't like large files in an HTML textarea. +- Added file size limits to the Edit/View page. (Some browsers don't like large files in an HTML textarea.) - Added some data validation to _GET parameters - Some misc code cleanup & organization etc. - And other misc stuff... From 3351ec98f676bee71800f46e204dfc543a7bfb08 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 5 Jul 2012 19:09:31 -0400 Subject: [PATCH 096/228] Version 3.2.3 Minor ytpo... --- readme.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.markdown b/readme.markdown index d233b09..5e43155 100755 --- a/readme.markdown +++ b/readme.markdown @@ -2,7 +2,7 @@ ### July 5, 2012 -Partly to prepare for future capabilities, the ability to process an exteranal config file was added. It is not required, so OneFileCMS is still one file, but it adds some flexibility. +Partly to prepare for future capabilities, the ability to process an external config file was added. It is not required, so OneFileCMS is still one file, but it adds some flexibility. 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. However, always remember that of the most important security measures concern user behavior - such as avoiding the use of un-encrypted wifi connections... From b20e3ba2352908b33c565b83b79708580750d4e5 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 7 Jul 2012 14:02:14 -0400 Subject: [PATCH 097/228] Version 3.2.4 BETA Beta version for testing multi-language support. --- onefilecms_3.2.04.BETA.php | 2348 ++++++++++++++++++++++++++++++++++++ 1 file changed, 2348 insertions(+) create mode 100755 onefilecms_3.2.04.BETA.php diff --git a/onefilecms_3.2.04.BETA.php b/onefilecms_3.2.04.BETA.php new file mode 100755 index 0000000..34280a3 --- /dev/null +++ b/onefilecms_3.2.04.BETA.php @@ -0,0 +1,2348 @@ +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 to verify POST + + chdir($_SERVER["DOCUMENT_ROOT"]); //Allow OneFileCMS.php to be started from any dir on the site. +}//End Session_Startup() ******************************************************* + + + + +function Verify_IDLE_POST_etc() { //******************************************** + global $_, $EX, $message, $VALID_POST, $MAX_IDLE_TIME; + + //Verify consistant user agent... (every little bit helps a little bit) + if ( ($_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) ) { Logout(); } + + //Check idle time + if ( isset($_SESSION['last_active_time']) ) { + $idle_time = ( time() - $_SESSION['last_active_time'] ); + if ( $idle_time > $MAX_IDLE_TIME ) { + Logout(); + $message .= $_['verify_msg_01'].'
    '; + } + } + + $_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)) { +?> +

    + + + [X] + + +

    + +'; // Needed on Edit page to keep js feedback from failing + } //end isset($message) + + // Used on Edit Page to preserve vertical spacing, so edit area doesn't jump as much. + if ($page == "edit") {echo '';} +}//end message_box() ********************************************************** + + + + +function Upload_New_Rename_Delete_Links() { //********************************** + global $_, $ONESCRIPT, $ipath, $param1; + echo ''; +}//end 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, $param2, $filename, $page; + + // [Cancel] returns to either the index, or edit page. + if ($filename == "") {$params = "";}else{ $params = $param2.'&p=edit'; } +?> +

    + + +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].').

    '; + echo '
    '.PHP_EOL; + echo ''.PHP_EOL; + echo ''.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 = '
    '.$INPUT_NUONCE; + +$SVG_icon_circle_plus = ' + + '; + +$SVG_icon_circle_x = ' + + '; + +$SVG_icon_pencil = ' + + + + '; + +$SVG_icon_img_0 = ' + + + '; +}//end Init_Macros() *********************************************************** + + + + +function svg_icon_bin(){ //***************************************************** +$zero = ''; +$one = ''; +?> + + + + + + + + + + + + + + + + + + + + + + + + '; + svg_icon_txt_0('#333', 'black', 'white', $extra); +} //end svg_icon_upload() ****************************************************** + + + +function svg_icon_file_new(){ //************************************************ + global $SVG_icon_circle_plus; + $extra = ''.$SVG_icon_circle_plus.''; + svg_icon_txt_0('#444', 'black', 'white', $extra); +} //end svg_icon_file_new() **************************************************** + + + +function svg_icon_file_del(){ //************************************************ +global $SVG_icon_circle_x; + $extra = ''.$SVG_icon_circle_x.''; + svg_icon_txt_0('#444', 'black', 'white', $extra); +} //end svg_icon_file_del() **************************************************** + + + +function svg_icon_folder_0($extra){ //****************************************** +?> + + + + +'.$SVG_icon_circle_plus.''; + svg_icon_folder_0($extra); +} //end svg_icon_folder_new() ************************************************** + + + +function svg_icon_folder_ren(){ //********************************************** + global $SVG_icon_pencil; + $extra = ''.$SVG_icon_pencil.''; + svg_icon_folder_0($extra); +} //end svg_icon_folder_ren() ************************************************** + + + +function svg_icon_folder_del(){ //********************************************** + global $SVG_icon_circle_x; + $extra = ''.$SVG_icon_circle_x.''; + svg_icon_folder_0($extra); +} //end svg_icon_folder_del() ************************************************** + + + + +function show_icon($type){ //*************************************************** + if ($type == 'bin') { svg_icon_bin(); } + elseif ($type == 'img') { svg_icon_img(); } + elseif ($type == 'svg') { svg_icon_svg(); } + elseif ($type == 'txt') { svg_icon_txt(); } + elseif ($type == 'htm') { svg_icon_htm(); } + elseif ($type == 'php') { svg_icon_php(); } + elseif ($type == 'css') { svg_icon_css(); } + elseif ($type == 'cfg') { svg_icon_cfg(); } + else { svg_icon_bin(); } //default +}//end show_icon() ************************************************************* + + + + +function Hash_Page() { //****************************************************** + 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'] = ''; } +?> + + +

    + + + + Password to hash: + "> + + + + +
    +


    +

    +
    +
    + +

    + +

    +


    1. + +

    2. +
      +
      +
    3. +
    4. +
    +

    +

    + + +

    +'; + $message .= $_['hash_msg_02'].htmlspecialchars(hashit($_POST["whattohash"])); +} //end Hash_response() ******************************************************** + + + + +function Logout() { //********************************************************** + global $page; + session_regenerate_id(true); + session_unset(); + session_destroy(); + session_write_close(); + unset($_GET); + unset($_POST); + $_SESSION['valid'] = 0; + $page = 'login'; +}//end Logout() **************************************************************** + + + + +function Login_Page() { //****************************************************** + global $_, $ONESCRIPT, $message; +?> +

    +
    +

    + + +

    +

    + + +

    + +

    + + + 0) { $message .= ''.$_['login_msg_01a'].' '.$attempts.' '.$_['login_msg_01b'].'
    ';} + 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 '
    + '; ?> + '; ?> +   + B +   + +
    '; + 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)]; +?> + + + + + +'; +}//end List_Files() ************************************************************ + + + + +function Index_Page(){ //******************************************************* + global $ONESCRIPT, $ipath; + + // + echo '

    '; + $folders = glob($ipath."*",GLOB_ONLYDIR); + natcasesort($folders); + foreach ($folders as $folder) { + echo ''.PHP_EOL; + svg_icon_folder(); + echo htmlentities(basename($folder)).' /'; + } + echo '

    '; + + Upload_New_Rename_Delete_Links(); + + List_Files(); + + Upload_New_Rename_Delete_Links(); + +}//end Index_Page()************************************************************* + + + + +function Edit_Page_buttons_top($text_editable){ //****************************** + global $_, $ONESCRIPT, $param1, $filename; +?> +
    +
    + + +   + + +
    +
    + +
    + + + + + +
    +
    +
    + +
    + + + + + + + rename'"> + copy'" > + delete'"> + " onclick="parent.location = ''"> +
    + + + +'.$_['edit_txt_01'].'

    '; + + }elseif ( $too_large_to_edit ) { + echo '

    '.$too_large_to_edit_message.'

    '; + + }else{ + if (PHP_VERSION_ID < 50400) { // 5.4.0 + $filecontent = htmlspecialchars(file_get_contents($filename)); + }else{ + $filecontent = htmlspecialchars(file_get_contents($filename),ENT_SUBSTITUTE); + } + $bad_chars = ($filecontent == "" && filesize($filename) > 0); + + if ($bad_chars){ //did htmlspecialchars return an empty string? + echo '
    '.$EX.$_['edit_txt_02'].'
    '; + echo $_['edit_txt_03'].'
    '; + echo $_['edit_txt_04'].'
    '; + }else{ + echo ''; + echo ''.PHP_EOL; + } + } //end if !editable /else... + } //end if non-image, show textarea + + Edit_Page_buttons($text_editable, $too_large_to_edit); + + Edit_Page_scripts(); +?> + +
    +
    +
    1) + + +
    +
    2)
    +
    3)
    +
    + $MAX_EDIT_SIZE); + $too_large_to_view = (filesize($filename) > $MAX_VIEW_SIZE); + + if ( $too_large_to_edit ) { $header2 = $_['edit_h2_1']; } + else { $header2 = $_['edit_h2_2']; } + + $too_large_to_edit_message = +''.$_['too_large_to_edit_01a'].number_format($MAX_EDIT_SIZE).' '.$_['too_large_to_edit_01b'].'
    '. +$_['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 '

    '.$too_large_to_view_message.'

    '; + } + elseif ( $text_editable && $too_large_to_edit ){ + $filecontent = htmlspecialchars(file_get_contents($filename), ENT_COMPAT,'UTF-8'); + 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']; } +?> +

    +

    + + + + + + + +'.$_['upload_msg_01'].''; + }elseif (($destination != "") && !is_dir($destination)) { + $message .= $EX.$_['upload_msg_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_01'].' '.htmlentities($new_name).'
    '. + '       '.$_['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); } +?> +

    +

    + +

    + + +

    +

    + + +

    + + +'.$msg1.' '.$_['CRM_msg_01'].'

    '; + $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; +?> +

    + + + +

    + + +'.$_['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; +?> +

    + +

    +

    + + + +'.$_['new_folder_msg_01'].' '.htmlentities($new_name).'
    '. + ''.$_['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; +?> +

    + + + / +

    + + +'.$_['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(){ //***Page_Title()************************* + global $_, $page; + + if ($page == "login") { return $_['page_title_login']; } + elseif ($page == "hash") { return $_['page_title_hash']; } + elseif ($page == "edit") { return $_['page_title_edit']; } + elseif ($page == "upload") { return $_['page_title_upload']; } + elseif ($page == "newfile") { return $_['page_title_new_file']; } + elseif ($page == "copy" ) { return $_['page_title_copy']; } + elseif ($page == "rename") { return $_['page_title_ren']; } + elseif ($page == "delete") { return $_['page_title_del']; } + elseif ($page == "newfolder") { return $_['page_title_folder_new'];} + elseif ($page == "renamefolder") { return $_['page_title_folder_ren'];} + elseif ($page == "deletefolder") { return $_['page_title_folder_del'];} + else { return $_SERVER['SERVER_NAME']; } +}//end Page_Title() ************************************************************ + + + + +function Load_Selected_Page(){ //*********************************************** + global $_, $ONESCRIPT, $page; + + if ($page == "login") { Login_Page(); } + elseif ($page == "hash") { Hash_Page(); } + elseif ($page == "edit") { Edit_Page(); } + elseif ($page == "upload") { Upload_Page(); } + elseif ($page == "newfile") { New_File_Page(); } + elseif ($page == "copy") { Copy_Ren_Move_Page($_['Copy'], $_['File'], 'copy_file', 1); } + elseif ($page == "rename") { Copy_Ren_Move_Page($_['Rename'], $_['File'], 'rename_file', 1); } + elseif ($page == "delete") { Delete_File_Page(); } + elseif ($page == "newfolder") { New_Folder_Page(); } + elseif ($page == "renamefolder") { Copy_Ren_Move_Page($_['Rename'], $_['Folder'], 'rename_folder', 0); } + elseif ($page == "deletefolder") { Delete_Folder_Page(); } + else { Index_Page(); } //default +}//end Load_Selected_Page() **************************************************** + + + + +function Timer_scripts() { //*************************************************** + global $_; +?> + + + + + + + + +'.$_['folder_del_msg'].''; + $page = "index";} + + //if size of $_POST > post_max_size, PHP only returns empty $_POST & $_FILE arrays. + elseif ($page == "uploaded" && !$VALID_POST){ + $message .= $EX.''.$_['upload_error_01a'].ini_get('post_max_size').' '.$_['upload_error_01b'].''; + $page = "index";} + + elseif ( ($page == "edit") && ($filename == trim(rawurldecode($ONESCRIPT), '/')) ) { + if ( $message == "" ) { $BR = ""; } else { $BR = '
    ';} + $message .= ''; + $message .= $BR.$EX.''.$_['edit_caution_01'].' '.$EX.$_['edit_caution_02'].''; + } + //************************************************************************** +}//end if $_SESSION[valid] ***************************************************** + + + + +//****************************************************************************** +//****************************************************************************** +?> + + + + +<?php echo $config_title.' - '.Page_Title() ?> + + + + + + + + + + + + + +'; } + else { echo '
    '; } +?> + +
    + + + +
    +
    + + + + + + + +'; + echo Timeout_Timer($MAX_IDLE_TIME, 'timer0', 'timer timeout', 'LOGOUT'); + echo ''.$_['time_out_txt'].' '; +} + +//Admin link +if ( ($page != "login") && ($page != "hash") ){ + echo '

    '.$_['Admin'].''; +} +?> + +

    + + From a97b0b7f47dbc146544dfefa4fc97abca887d546 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Jul 2012 17:07:01 -0400 Subject: [PATCH 098/228] Version 3.3.0 Setup muli-languages support. (Now just need some translations...) Created hsc() to do htmlspecialchars() - saves 13 bytes with use use! :) Get_GET(): moved part with $message up so $message is not lost (by filename=""). Split out Edit_Page_buttons_top() from Edit_Page(). Fixed minor issue with [Wide View] Adjusted some css --- OneFileCMS.LANG.EN.ini | 222 ++++ onefilecms.php | 862 ++++++++----- onefilecms_3.2.04.BETA.php | 2348 ------------------------------------ onefilecms_lite.php | 1876 ---------------------------- readme.markdown | 55 +- 5 files changed, 805 insertions(+), 4558 deletions(-) create mode 100755 OneFileCMS.LANG.EN.ini delete mode 100755 onefilecms_3.2.04.BETA.php delete mode 100755 onefilecms_lite.php diff --git a/OneFileCMS.LANG.EN.ini b/OneFileCMS.LANG.EN.ini new file mode 100755 index 0000000..18685a5 --- /dev/null +++ b/OneFileCMS.LANG.EN.ini @@ -0,0 +1,222 @@ +;/////////////////////////////////////////////////////////////////////////////// +;// OneFileCMS Language Settings + +LANGUAGE = "English" + +;// These are the default values included directly in onefilecms.php. +;// +;// If no translation or value is desired for a particular setting, do not delete +;// the actual setting variable, just set it to an empty string. +;// For example: some_unused_setting = "" +;// +;// Remember to slash-escape double quotes that may be within a value: \" +;// And, if the these settings are set directly in Default_Language() in onefilecms.php, +;// single quotes must also be escaped: \' + +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" + +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." +too_large_to_edit_02 = "Some browsers (ie: IE) bog down or become unstable while editing a large file in an HTML '.PHP_EOL; } - } //end if !editable /else... - } //end if non-image, show textarea + } //end if non-text file... + } //end if non-image - Edit_Page_Buttons($text_editable, $too_large_to_edit); + Edit_Page_buttons($text_editable, $too_large_to_edit); Edit_Page_scripts(); ?> @@ -983,8 +1217,32 @@ function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_ +function Edit_Page_Notes() { //************************************************* + global $_, $MAX_IDLE_TIME; + $SEC = $MAX_IDLE_TIME; + $HRS = floor($SEC/3600); + $SEC = fmod($SEC,3600); + $MIN = floor($SEC/60); if ($MIN < 10) { $MIN = "0".$MIN; }; + $SEC = fmod($SEC,60); if ($SEC < 10) { $SEC = "0".$SEC; }; + $HRS_MIN_SEC = $HRS.':'.$MIN.':'.$SEC; +?> +
    +
    +
    1) + + +
    +
    2)
    +
    3)
    +
    + $MAX_EDIT_SIZE); $too_large_to_view = (filesize($filename) > $MAX_VIEW_SIZE); - if ( $too_large_to_edit ) { $header2 = "Viewing: "; } - else { $header2 = "Editing: "; } + if ( $too_large_to_edit ) { $header2 = hsc($_['edit_h2_1']); } + else { $header2 = hsc($_['edit_h2_2']); } $too_large_to_edit_message = -'Edit disabled. Filesize > '.number_format($MAX_EDIT_SIZE).' bytes.
    -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; -?> -
    -
    - Filesize: bytes   - Updated:
    -
    -
    - - - - - -
    -
    -
    -'.$too_large_to_view_message.'

    '; } elseif ( $text_editable && $too_large_to_edit ){ - $filecontent = htmlspecialchars(file_get_contents($filename), ENT_COMPAT,'UTF-8'); + $filecontent = hsc(file_get_contents($filename), ENT_COMPAT,'UTF-8'); echo '
    '.$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

    -

    Note: Maximum upload file size is:

    +

    +

    - + - + No file selected for upload... '; + $message .= $EX.''.hsc($_['upload_msg_01']).''; }elseif (($destination != "") && !is_dir($destination)) { - $message .= $EX.' Destination folder does not exist:
    '; - $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

    +

    -

    File will be created in the current folder.   - Some invalid characters are:

    +

    +

    - + New file not created: '.htmlentities($new_name).'
    '. - '       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); } ?>

    -

    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="">

    @@ -1223,7 +1463,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, $param2, $message, $EX, $page, $filename; + global $_, $WEB_ROOT, $ipath, $param1, $param2, $message, $EX, $page, $filename; $old_name = trim($old_name,'/ '); $new_name = trim($new_name,'/ '); @@ -1232,17 +1472,17 @@ function Copy_Ren_Move_response($old_name, $new_name, $action, $msg1, $msg2, $is if ($isfile) { $page = "edit"; }else{ $page = "index"; } if ( !is_dir($new_location) ){ - $message .= $EX.' '.$msg1.' Error - new parent location does not exist:
    '; + $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

    +

    - + -

    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; ?> -

    New Folder

    +

    -

    Folder will be created in the current folder.   - Some invalid characters are:

    +

    +

    - + New folder not created:
    '.htmlentities($new_name).'
    '. - '       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

    +

    - + / -

    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(){ //***Page_Title()************************* - global $page; - - if ($page == "login") { return "Log In"; } - elseif ($page == "hash") { return "Hash"; } - elseif ($page == "edit") { return "Edit/View File"; } - elseif ($page == "upload") { return "Upload File"; } - elseif ($page == "newfile") { return "New File"; } - elseif ($page == "copy" ) { return "Copy"; } - elseif ($page == "rename") { return "Rename File"; } - elseif ($page == "delete") { return "Delete"; } - elseif ($page == "newfolder") { return "New Folder"; } - elseif ($page == "renamefolder") { return "Rename Folder"; } - elseif ($page == "deletefolder") { return "Delete Folder"; } + global $_, $page; + + if ($page == "login") { return hsc($_['page_title_login']); } + elseif ($page == "hash") { return hsc($_['page_title_hash']); } + elseif ($page == "edit") { return hsc($_['page_title_edit']); } + elseif ($page == "upload") { return hsc($_['page_title_upload']); } + elseif ($page == "newfile") { return hsc($_['page_title_new_file']); } + elseif ($page == "copy" ) { return hsc($_['page_title_copy']); } + elseif ($page == "rename") { return hsc($_['page_title_ren']); } + elseif ($page == "delete") { return hsc($_['page_title_del']); } + elseif ($page == "newfolder") { return hsc($_['page_title_folder_new']);} + elseif ($page == "renamefolder") { return hsc($_['page_title_folder_ren']);} + elseif ($page == "deletefolder") { return hsc($_['page_title_folder_del']);} else { return $_SERVER['SERVER_NAME']; } }//end Page_Title() ************************************************************ @@ -1402,18 +1642,18 @@ function Page_Title(){ //***Page_Title()************************* function Load_Selected_Page(){ //*********************************************** - global $ONESCRIPT, $page; + global $_, $ONESCRIPT, $page; if ($page == "login") { Login_Page(); } elseif ($page == "hash") { Hash_Page(); } elseif ($page == "edit") { Edit_Page(); } elseif ($page == "upload") { Upload_Page(); } elseif ($page == "newfile") { New_File_Page(); } - elseif ($page == "copy") { Copy_Ren_Move_Page('Copy', 'File', 'copy_file', 1); } - elseif ($page == "rename") { Copy_Ren_Move_Page('Rename', 'File', 'rename_file', 1); } + elseif ($page == "copy") { Copy_Ren_Move_Page(hsc($_['Copy']), hsc($_['File']), 'copy_file', 1); } + elseif ($page == "rename") { Copy_Ren_Move_Page(hsc($_['Rename']), hsc($_['File']), 'rename_file', 1); } elseif ($page == "delete") { Delete_File_Page(); } elseif ($page == "newfolder") { New_Folder_Page(); } - elseif ($page == "renamefolder") { Copy_Ren_Move_Page('Rename', 'Folder', 'rename_folder', 0); } + elseif ($page == "renamefolder") { Copy_Ren_Move_Page(hsc($_['Rename']), hsc($_['Folder']), 'rename_folder', 0); } elseif ($page == "deletefolder") { Delete_Folder_Page(); } else { Index_Page(); } //default }//end Load_Selected_Page() **************************************************** @@ -1422,6 +1662,7 @@ function Load_Selected_Page(){ //*********************************************** function Timer_scripts() { //*************************************************** + global $_; ?> if( PHP_VERSION_ID < 50000 ) { exit("OneFileCMS requires PHP5 to operate. Tested on versions 5.2.17, 5.3.3 & 5.4"); } + +// Load language settings +if ( is_file($LANGUAGE) ) { $_ = parse_ini_file($LANGUAGE); } +else { $_ = parse_ini_string(Default_Language()); } + + Session_Startup(); if ($_SESSION['valid']) { @@ -2019,11 +2269,11 @@ function style_sheet(){ //****************************************************?> elseif (isset($_POST["whattohash"] )) { Hash_response(); } elseif (isset($_POST["filename"] )) { Edit_response(); } elseif (isset($_POST["new_file"] )) { New_File_response(); } - elseif (isset($_POST["copy_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["copy_file"], 'copy', 'Copy', 'Copied', 1); } - elseif (isset($_POST["rename_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["rename_file"], 'rename', 'Rename/Move', 'Renamed/Moved', 1); } + elseif (isset($_POST["copy_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["copy_file"], 'copy', hsc($_['Copy']), hsc($_['Copied']), 1); } + elseif (isset($_POST["rename_file"] )) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["rename_file"], 'rename', hsc($_['Ren_Move']), hsc($_['Ren_Moved']), 1); } elseif (isset($_POST["delete_file"] )) { Delete_File_response(); } elseif (isset($_POST["new_folder"] )) { New_Folder_response(); } - elseif (isset($_POST["rename_folder"])) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["rename_folder"], 'rename', 'Rename/Move', 'Renamed/Moved', 0); } + elseif (isset($_POST["rename_folder"])) { Copy_Ren_Move_response($_POST[ "old_name"], $_POST["rename_folder"], 'rename', hsc($_['Ren_Move']), hsc($_['Ren_Moved']), 0); } elseif (isset($_POST["delete_folder"])) { Delete_Folder_response(); } }//end if ($VALID_POST) **************************************************** @@ -2038,22 +2288,22 @@ function style_sheet(){ //****************************************************?> elseif ($page == "logout") { Logout(); - $message .= 'You have successfully logged out.'; } + $message .= hsc($_['logout_msg']); } //Don't load delete page if folder not empty. elseif ( ($page == "deletefolder") && !is_empty($ipath) ) { - $message .= $EX.' Folder not empty.   Folders must be empty before they can be deleted.'; + $message .= $EX.''.hsc($_['folder_del_msg']).''; $page = "index";} //if size of $_POST > post_max_size, PHP only returns empty $_POST & $_FILE arrays. 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).'; + $message .= $EX.''.hsc($_['upload_error_01a']).ini_get('post_max_size').' '.hsc($_['upload_error_01b']).''; $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 !!'; + $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 to verify POST - - chdir($_SERVER["DOCUMENT_ROOT"]); //Allow OneFileCMS.php to be started from any dir on the site. -}//End Session_Startup() ******************************************************* - - - - -function Verify_IDLE_POST_etc() { //******************************************** - global $_, $EX, $message, $VALID_POST, $MAX_IDLE_TIME; - - //Verify consistant user agent... (every little bit helps a little bit) - if ( ($_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) ) { Logout(); } - - //Check idle time - if ( isset($_SESSION['last_active_time']) ) { - $idle_time = ( time() - $_SESSION['last_active_time'] ); - if ( $idle_time > $MAX_IDLE_TIME ) { - Logout(); - $message .= $_['verify_msg_01'].'
    '; - } - } - - $_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)) { -?> -

    - - - [X] - - -

    - -'; // Needed on Edit page to keep js feedback from failing - } //end isset($message) - - // Used on Edit Page to preserve vertical spacing, so edit area doesn't jump as much. - if ($page == "edit") {echo '';} -}//end message_box() ********************************************************** - - - - -function Upload_New_Rename_Delete_Links() { //********************************** - global $_, $ONESCRIPT, $ipath, $param1; - echo ''; -}//end 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, $param2, $filename, $page; - - // [Cancel] returns to either the index, or edit page. - if ($filename == "") {$params = "";}else{ $params = $param2.'&p=edit'; } -?> -

    - - -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].').

    '; - echo '
    '.PHP_EOL; - echo ''.PHP_EOL; - echo ''.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 = '
    '.$INPUT_NUONCE; - -$SVG_icon_circle_plus = ' - - '; - -$SVG_icon_circle_x = ' - - '; - -$SVG_icon_pencil = ' - - - - '; - -$SVG_icon_img_0 = ' - - - '; -}//end Init_Macros() *********************************************************** - - - - -function svg_icon_bin(){ //***************************************************** -$zero = ''; -$one = ''; -?> - - - - - - - - - - - - - - - - - - - - - - - - '; - svg_icon_txt_0('#333', 'black', 'white', $extra); -} //end svg_icon_upload() ****************************************************** - - - -function svg_icon_file_new(){ //************************************************ - global $SVG_icon_circle_plus; - $extra = ''.$SVG_icon_circle_plus.''; - svg_icon_txt_0('#444', 'black', 'white', $extra); -} //end svg_icon_file_new() **************************************************** - - - -function svg_icon_file_del(){ //************************************************ -global $SVG_icon_circle_x; - $extra = ''.$SVG_icon_circle_x.''; - svg_icon_txt_0('#444', 'black', 'white', $extra); -} //end svg_icon_file_del() **************************************************** - - - -function svg_icon_folder_0($extra){ //****************************************** -?> - - - - -'.$SVG_icon_circle_plus.''; - svg_icon_folder_0($extra); -} //end svg_icon_folder_new() ************************************************** - - - -function svg_icon_folder_ren(){ //********************************************** - global $SVG_icon_pencil; - $extra = ''.$SVG_icon_pencil.''; - svg_icon_folder_0($extra); -} //end svg_icon_folder_ren() ************************************************** - - - -function svg_icon_folder_del(){ //********************************************** - global $SVG_icon_circle_x; - $extra = ''.$SVG_icon_circle_x.''; - svg_icon_folder_0($extra); -} //end svg_icon_folder_del() ************************************************** - - - - -function show_icon($type){ //*************************************************** - if ($type == 'bin') { svg_icon_bin(); } - elseif ($type == 'img') { svg_icon_img(); } - elseif ($type == 'svg') { svg_icon_svg(); } - elseif ($type == 'txt') { svg_icon_txt(); } - elseif ($type == 'htm') { svg_icon_htm(); } - elseif ($type == 'php') { svg_icon_php(); } - elseif ($type == 'css') { svg_icon_css(); } - elseif ($type == 'cfg') { svg_icon_cfg(); } - else { svg_icon_bin(); } //default -}//end show_icon() ************************************************************* - - - - -function Hash_Page() { //****************************************************** - 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'] = ''; } -?> - - -

    - - - - Password to hash: - "> - - - - -
    -


    -

    -
    -
    - -

    - -

    -


    1. - -

    2. -
      -
      -
    3. -
    4. -
    -

    -

    - - -

    -'; - $message .= $_['hash_msg_02'].htmlspecialchars(hashit($_POST["whattohash"])); -} //end Hash_response() ******************************************************** - - - - -function Logout() { //********************************************************** - global $page; - session_regenerate_id(true); - session_unset(); - session_destroy(); - session_write_close(); - unset($_GET); - unset($_POST); - $_SESSION['valid'] = 0; - $page = 'login'; -}//end Logout() **************************************************************** - - - - -function Login_Page() { //****************************************************** - global $_, $ONESCRIPT, $message; -?> -

    -
    -

    - - -

    -

    - - -

    - -

    - - - 0) { $message .= ''.$_['login_msg_01a'].' '.$attempts.' '.$_['login_msg_01b'].'
    ';} - 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 '
    + '; ?> + '; ?> +   + B +   + +
    '; - 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)]; -?> - - - - - -'; -}//end List_Files() ************************************************************ - - - - -function Index_Page(){ //******************************************************* - global $ONESCRIPT, $ipath; - - // - echo '

    '; - $folders = glob($ipath."*",GLOB_ONLYDIR); - natcasesort($folders); - foreach ($folders as $folder) { - echo ''.PHP_EOL; - svg_icon_folder(); - echo htmlentities(basename($folder)).' /'; - } - echo '

    '; - - Upload_New_Rename_Delete_Links(); - - List_Files(); - - Upload_New_Rename_Delete_Links(); - -}//end Index_Page()************************************************************* - - - - -function Edit_Page_buttons_top($text_editable){ //****************************** - global $_, $ONESCRIPT, $param1, $filename; -?> -
    -
    - - -   - - -
    -
    - -
    - - - - - -
    -
    -
    - -
    - - - - - - - rename'"> - copy'" > - delete'"> - " onclick="parent.location = ''"> -
    - -
    - -'.$_['edit_txt_01'].'

    '; - - }elseif ( $too_large_to_edit ) { - echo '

    '.$too_large_to_edit_message.'

    '; - - }else{ - if (PHP_VERSION_ID < 50400) { // 5.4.0 - $filecontent = htmlspecialchars(file_get_contents($filename)); - }else{ - $filecontent = htmlspecialchars(file_get_contents($filename),ENT_SUBSTITUTE); - } - $bad_chars = ($filecontent == "" && filesize($filename) > 0); - - if ($bad_chars){ //did htmlspecialchars return an empty string? - echo '
    '.$EX.$_['edit_txt_02'].'
    '; - echo $_['edit_txt_03'].'
    '; - echo $_['edit_txt_04'].'
    '; - }else{ - echo ''; - echo ''.PHP_EOL; - } - } //end if !editable /else... - } //end if non-image, show textarea - - Edit_Page_buttons($text_editable, $too_large_to_edit); - - Edit_Page_scripts(); -?> - -
    -
    -
    1) - - -
    -
    2)
    -
    3)
    -
    - $MAX_EDIT_SIZE); - $too_large_to_view = (filesize($filename) > $MAX_VIEW_SIZE); - - if ( $too_large_to_edit ) { $header2 = $_['edit_h2_1']; } - else { $header2 = $_['edit_h2_2']; } - - $too_large_to_edit_message = -''.$_['too_large_to_edit_01a'].number_format($MAX_EDIT_SIZE).' '.$_['too_large_to_edit_01b'].'
    '. -$_['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 '

    '.$too_large_to_view_message.'

    '; - } - elseif ( $text_editable && $too_large_to_edit ){ - $filecontent = htmlspecialchars(file_get_contents($filename), ENT_COMPAT,'UTF-8'); - 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']; } -?> -

    -

    -
    - - - - - - -'.$_['upload_msg_01'].'
    '; - }elseif (($destination != "") && !is_dir($destination)) { - $message .= $EX.$_['upload_msg_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_01'].' '.htmlentities($new_name).'
    '. - '       '.$_['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); } -?> -

    -

    - -

    - - -

    -

    - - -

    - - -'.$msg1.' '.$_['CRM_msg_01'].'

    '; - $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; -?> -

    - - - -

    - - -'.$_['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; -?> -

    - -

    -

    - - - -'.$_['new_folder_msg_01'].' '.htmlentities($new_name).'
    '. - ''.$_['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; -?> -

    - - - / -

    - - -'.$_['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(){ //***Page_Title()************************* - global $_, $page; - - if ($page == "login") { return $_['page_title_login']; } - elseif ($page == "hash") { return $_['page_title_hash']; } - elseif ($page == "edit") { return $_['page_title_edit']; } - elseif ($page == "upload") { return $_['page_title_upload']; } - elseif ($page == "newfile") { return $_['page_title_new_file']; } - elseif ($page == "copy" ) { return $_['page_title_copy']; } - elseif ($page == "rename") { return $_['page_title_ren']; } - elseif ($page == "delete") { return $_['page_title_del']; } - elseif ($page == "newfolder") { return $_['page_title_folder_new'];} - elseif ($page == "renamefolder") { return $_['page_title_folder_ren'];} - elseif ($page == "deletefolder") { return $_['page_title_folder_del'];} - else { return $_SERVER['SERVER_NAME']; } -}//end Page_Title() ************************************************************ - - - - -function Load_Selected_Page(){ //*********************************************** - global $_, $ONESCRIPT, $page; - - if ($page == "login") { Login_Page(); } - elseif ($page == "hash") { Hash_Page(); } - elseif ($page == "edit") { Edit_Page(); } - elseif ($page == "upload") { Upload_Page(); } - elseif ($page == "newfile") { New_File_Page(); } - elseif ($page == "copy") { Copy_Ren_Move_Page($_['Copy'], $_['File'], 'copy_file', 1); } - elseif ($page == "rename") { Copy_Ren_Move_Page($_['Rename'], $_['File'], 'rename_file', 1); } - elseif ($page == "delete") { Delete_File_Page(); } - elseif ($page == "newfolder") { New_Folder_Page(); } - elseif ($page == "renamefolder") { Copy_Ren_Move_Page($_['Rename'], $_['Folder'], 'rename_folder', 0); } - elseif ($page == "deletefolder") { Delete_Folder_Page(); } - else { Index_Page(); } //default -}//end Load_Selected_Page() **************************************************** - - - - -function Timer_scripts() { //*************************************************** - global $_; -?> - - - - - - - - -'.$_['folder_del_msg'].''; - $page = "index";} - - //if size of $_POST > post_max_size, PHP only returns empty $_POST & $_FILE arrays. - elseif ($page == "uploaded" && !$VALID_POST){ - $message .= $EX.''.$_['upload_error_01a'].ini_get('post_max_size').' '.$_['upload_error_01b'].''; - $page = "index";} - - elseif ( ($page == "edit") && ($filename == trim(rawurldecode($ONESCRIPT), '/')) ) { - if ( $message == "" ) { $BR = ""; } else { $BR = '
    ';} - $message .= ''; - $message .= $BR.$EX.''.$_['edit_caution_01'].' '.$EX.$_['edit_caution_02'].''; - } - //************************************************************************** -}//end if $_SESSION[valid] ***************************************************** - - - - -//****************************************************************************** -//****************************************************************************** -?> - - - - -<?php echo $config_title.' - '.Page_Title() ?> - - - - - - - - - - - - - -'; } - else { echo '
    '; } -?> - -
    - - - -
    -
    - - - - - - - -'; - echo Timeout_Timer($MAX_IDLE_TIME, 'timer0', 'timer timeout', 'LOGOUT'); - echo ''.$_['time_out_txt'].' '; -} - -//Admin link -if ( ($page != "login") && ($page != "hash") ){ - echo '

    '.$_['Admin'].''; -} -?> - -

    - - diff --git a/onefilecms_lite.php b/onefilecms_lite.php deleted file mode 100755 index 7d23883..0000000 --- a/onefilecms_lite.php +++ /dev/null @@ -1,1876 +0,0 @@ - $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"; //Editable file types. -$config_itypes = "jpg,gif,png,bmp,ico"; //image types to display on edit page. - - - -$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 ******************************************************* - - - - -//****************************************************************************** -//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. -$etypes = explode(',', strtolower(str_replace(' ', '', $config_etypes))); //editable file types -$itypes = explode(',', strtolower(str_replace(' ', '', $config_itypes))); //images types to display - - -$excluded_list = (explode(",", $config_excluded)); -//****************************************************************************** - - - - -function Session_Startup() {//************************************************** - global $USERNAME, $PASSWORD, $USE_HASH, $HASHWORD, $EX, $message , $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 to verify POST - - chdir($_SERVER["DOCUMENT_ROOT"]); //Allow OneFileCMS.php to be started from any dir on the site. -}//End Session_Startup() ******************************************************* - - - - -function Verify_IDLE_POST_etc() { //******************************************** - global $EX, $message, $VALID_POST, $MAX_IDLE_TIME; - - //Verify consistant user agent... (every little bit helps a little bit) - if ( ($_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) ) { Logout(); } - - //Check idle time - if ( isset($_SESSION['last_active_time']) ) { - $idle_time = ( time() - $_SESSION['last_active_time'] ); - if ( $_SESSION['valid'] && ($idle_time > $MAX_IDLE_TIME) ) { - Logout(); - $message .= 'Session expired.
    '; - } - } - - $_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)) { -?> -

    - - - [X] - - -

    - -'; // Needed on Edit page to keep js feedback from failing - } //end isset($message) - - // Used on Edit Page to preserve vertical spacing, so edit area doesn't jump as much. - if ($page == "edit") {echo '';} -}//end message_box() ********************************************************** - - - - -function Upload_New_Rename_Delete_Links() { //********************************** - global $ONESCRIPT, $ipath, $param1; - echo ''; -}//end 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, $param2, $filename, $page; - - // [Cancel] returns to either the index, or edit page. - if ($filename == "") {$params = "";}else{ $params = $param2.'&p=edit'; } -?> -

    - - -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].').

    '; - echo '
    '.PHP_EOL; - echo ''.PHP_EOL; - echo ''.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 = '
    '.$INPUT_NUONCE; - -}//end Init_Macros() *********************************************************** - - - - -function Hash_Page() { //****************************************************** - global $DOC_ROOT, $ONESCRIPT, $param1, $param2, $message, $INPUT_NUONCE, $config_title; - $params = '?i='.dirname($ONESCRIPT).'&f='.basename($ONESCRIPT).'&p=edit'; -?> - - -

    Generate a Password Hash

    - - - - Password to hash: - "> - - Edit   - - -
    -

    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).
    - 2) Or, use $HASHWORD to store the hash of your password, and set $USE_HASH = 1.
    - -

    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: -

    1. Type your desired password in the input field above and hit Enter.
      - The hash will be displayed in a yellow message box above that. -
    2. Copy and paste the new hash to the $HASHWORD variable in the config section.
      - '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... -
    3. Make sure $USE_HASH is set to 1 (or true). -
    4. When ready, logout and login. -
    -

    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...
    - PS: Everything I know about security - you just read... -

    -'; - $message .= 'Hash    : '.hashit($_POST["whattohash"]); -} //end Hash_response() ******************************************************** - - - - -function Logout() { //********************************************************** - global $page; - session_regenerate_id(true); - session_unset(); - session_destroy(); - session_write_close(); - unset($_GET); - unset($_POST); - $_SESSION['valid'] = 0; - $page = 'login'; -}//end Logout() **************************************************************** - - - - -function Login_Page() { //****************************************************** - global $ONESCRIPT, $message; -?> -

    Log In

    -
    -

    - - -

    -

    - - -

    - -

    - - - 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 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 '
    - '; ?> - '; ?> -   - B -   - -
    '; - 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 '

    '; - $folders = glob($ipath."*",GLOB_ONLYDIR); - natcasesort($folders); - foreach ($folders as $folder) { - echo ''.PHP_EOL; - - echo htmlentities(basename($folder)).' /'; - } - echo '

    '; - - Upload_New_Rename_Delete_Links(); - - List_Files(); - - Upload_New_Rename_Delete_Links(); - -}//end Index_Page()************************************************************* - - - - -function Edit_Page_Buttons($text_editable, $too_large_to_edit) { //************* - global $ONESCRIPT, $param1, $param2, $MAX_IDLE_TIME; - $Button = ' - - - - - - - rename'"> - copy'" > - delete'"> - onclick="parent.location = ''"> -

    - - - -Non-text or unkown file type. Edit disabled.

    '; - - }elseif ( $too_large_to_edit ) { - echo '

    '.$too_large_to_edit_message.'

    '; - - }else{ - if (PHP_VERSION_ID < 50400) { // 5.4.0 - $filecontent = htmlspecialchars(file_get_contents($filename)); - }else{ - $filecontent = htmlspecialchars(file_get_contents($filename),ENT_SUBSTITUTE); - } - $bad_chars = ($filecontent == "" && filesize($filename) > 0); - - if ($bad_chars){ //did specialchars return an empty string? - echo '
    '.$EX.' File contains an invalid character. Edit and view disabled.
    '; - 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 ''.PHP_EOL; - } - } //end if !editable /else... - } //end if non-image, show textarea - - Edit_Page_Buttons($text_editable, $too_large_to_edit); - - if ($text_editable && !$too_large_to_edit && !$bad_chars) { - Edit_Page_scripts(); - $SEC = $MAX_IDLE_TIME; - $HRS = floor($SEC/3600); - $SEC = fmod($SEC,3600); - $MIN = floor($SEC/60); if ($MIN < 10) { $MIN = "0".$MIN; }; - $SEC = fmod($SEC,60); if ($SEC < 10) { $SEC = "0".$SEC; }; - $HRS_MIN_SEC = $HRS.':'.$MIN.':'.$SEC; -?> -
    NOTES:
      -
    1. Remember- your $MAX_IDLE_TIME is . - So save changes before the clock runs out, or the changes will be lost!
      - - -   ,'?> - -
    2. On 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]. -
    3. 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. -
    - - - $MAX_EDIT_SIZE); - $too_large_to_view = (filesize($filename) > $MAX_VIEW_SIZE); - - if ($too_large_to_edit){$header2 = "Viewing: ";} - else {$header2 = "Editing: ";} - - $too_large_to_edit_message = -'Edit disabled. Filesize > '.number_format($MAX_EDIT_SIZE).' bytes.
    -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; -?> -

    - Filesize: bytes   - Updated:
    -

    - - - -
    -'; - - 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 '

    '.$too_large_to_view_message.'

    '; - } - -}//End Edit_Page *************************************************************** - - - - -function Edit_response(){ //***If on Edit page, and [Save] clicked ************* - global $filename, $message, $EX; - $filename = $_POST["filename"]; - $content = $_POST["content"]; - - $bytes = file_put_contents($filename, $content); - - if ($bytes !== false) { - $message .= 'File saved: '.$bytes.' bytes written.'; - }else{ - $message .= $EX.' There was an error saving file.'; - } -}//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.'   per upload_max_filesize in php.ini.'; } - else { $MAX_FILE_SIZE = $PMS; $max_msg = $post_max_size.'   per post_max_size in php.ini'; } -?> -

    Upload File

    -

    Note: Maximum upload file size is:

    - - - - - - - -No file selected for upload... '; - }elseif (($destination != "") && !is_dir($destination)) { - $message .= $EX.' Destination folder does not exist:
    '; - $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

    - -

    File will be created in the current folder.   - Some invalid characters are:

    - - - -New file not created: '.htmlentities($new_name).'
    '. - '       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); } -?> -

    -

    To move a file or folder, change the path/to/folder/or_file. The new location must already exist.

    - -

    - - -

    -

    - - -

    - - -'.$msg1.' Error - new parent location does not exist:

    '; - $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

    - - - -

    Are you sure?

    - - -Deleted file: '.htmlentities(basename($filename)); - }else{ - $message .= $EX.' Error deleting "'.htmlentities($filename).'".'; - $page = "edit"; - } -}//end Delete_File_response() ************************************************** - - - - -function New_Folder_Page() { //************************************************* - global $FORM_COMMON, $INVALID_CHARS; -?> -

    New Folder

    - -

    Folder will be created in the current folder.   - Some invalid characters are:

    - - - -New folder not created: '.htmlentities($new_name).'
    '. - '       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

    - - - / -

    Are you sure?

    - - -Folder not empty.   Folders must be empty before they can be deleted.'; - $page = "index"; - }elseif (@rmdir($foldername)) { - $message .= 'Deleted folder: '.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.'; - } -}//end Delete_Folder_response() ************************************************ - - - - -function Page_Title(){ //***Page_Title()************************* - global $page; - - if ($page == "login") { return "Log In"; } - elseif ($page == "hash") { return "Hash"; } - elseif ($page == "edit") { return "Edit/View File"; } - elseif ($page == "upload") { return "Upload File"; } - elseif ($page == "newfile") { return "New File"; } - elseif ($page == "copy" ) { return "Copy"; } - elseif ($page == "rename") { return "Rename File"; } - elseif ($page == "delete") { return "Delete"; } - elseif ($page == "newfolder") { return "New Folder"; } - elseif ($page == "renamefolder") { return "Rename Folder"; } - elseif ($page == "deletefolder") { return "Delete Folder"; } - else { return $_SERVER['SERVER_NAME']; } -}//end Page_Title() ************************************************************ - - - - -function Load_Selected_Page(){ //*********************************************** - global $ONESCRIPT, $page; - - if ($page == "login") { Login_Page(); } - elseif ($page == "hash") { Hash_Page(); } - elseif ($page == "edit") { Edit_Page(); } - elseif ($page == "upload") { Upload_Page(); } - elseif ($page == "newfile") { New_File_Page(); } - elseif ($page == "copy") { Copy_Ren_Move_Page('Copy', 'File', 'copy_file', 1); } - elseif ($page == "rename") { Copy_Ren_Move_Page('Rename', 'File', 'rename_file', 1); } - elseif ($page == "delete") { Delete_File_Page(); } - elseif ($page == "newfolder") { New_Folder_Page(); } - elseif ($page == "renamefolder") { Copy_Ren_Move_Page('Rename', 'Folder', 'rename_folder', 0); } - elseif ($page == "deletefolder") { Delete_Folder_Page(); } - else { Index_Page(); } //default -}//end Load_Selected_Page() **************************************************** - - - - -function Timer_scripts() { //*************************************************** -?> - - - - - - - - -Folder not empty.   Folders must be empty before they can be deleted.'; - $page = "index";} - - //if size of $_POST > post_max_size, PHP only returns empty $_POST & $_FILE arrays. - 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] ***************************************************** - - - - -//****************************************************************************** -//****************************************************************************** -?> - - - - -<?php echo $config_title.' - '.Page_Title() ?> - - - - - - - - - - - - - -'; } - else { echo '
    '; } -?> - -
    - - - -
    -
    - - - - - - - -'; } ?> - -Admin'; } - -//Countdown timer... -if ( $page != "login" ) { - echo Timeout_Timer($MAX_IDLE_TIME, 'timer0', 'timer timeout', 'LOGOUT'); - echo 'Session time out in: '; -} -?> - -
    - - diff --git a/readme.markdown b/readme.markdown index 5e43155..d18f7ce 100755 --- a/readme.markdown +++ b/readme.markdown @@ -1,11 +1,9 @@ -# Current stable version: 3.2.3 +# Current stable version: 3.3.0 -### July 5, 2012 +### July 10, 2012 -Partly to prepare for future capabilities, the ability to process an external config file was added. It is not required, so OneFileCMS is still one file, but it adds some flexibility. - -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. -However, always remember that of the most important security measures concern user behavior - such as avoiding the use of un-encrypted wifi connections... +Added support for optional external language files. The default, English, is included directly in OneFileCMS, of course. Now to get some translations... +A sample language file is included in the repo for reference for anyone that may be interested. -------------------------------------------------------------------------------- @@ -68,7 +66,7 @@ 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. -Otherwise, try [forking the file and submitting your changes to me](https://github.com/blog/844-forking-with-the-edit-button). +In anycase, try [forking the file and submitting your changes to me](https://github.com/blog/844-forking-with-the-edit-button). ### This is basically just a file manager with a text editor. Why is it being called a Content Management System? @@ -76,11 +74,11 @@ Well, because "OneFileFileManagerTextEditor" just doesn't have the same ring to ### Multi-Language Support? -Possibly! (But not yet...) +Yes! (But only English is included so far...) ### 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, with each copy, maintain different user names and passwords. Also, so one user does not log out the other, change the session names. +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 database 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. @@ -90,7 +88,8 @@ Now, since there is no database or other means of granular control and acess log (Only tested on versions 5.2.17, 5.3.3, 5.4, and 5.4.3) - File permission privileges on your host - Javascript enabled browswer -- And, for OneFileCMS 3+, a browser that supports inline SVG. +- And, for OneFileCMS 3+, a browser that supports inline SVG. + (Even if your browser doesn't support SVG, OneFileCMS will still work, just without any icons.) ## Credit, License, Et Cetera @@ -106,7 +105,6 @@ To report a bug or request a feature, please file an issue via Github. Forks enc ##Needed/potential/upcoming improvements -- Multiple languages support - 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 edit page with such a file, and only after a [Save]. - Connection is not encrypted (doesn't use SSL), so passwords & usernames are sent in clear text during login. @@ -122,34 +120,34 @@ To report a bug or request a feature, please file an issue via Github. Forks enc CONFIGURATION SECTION SOME STANDARD GLOBAL VARIABLES - + +DEFAULT LANGUAGE + SESSION & MISC FUNCTIONS SVG ICON FUNCTIONS PAGE & RESPONSE FUNCTIONS - Index, Upload, New, Copy, Rename, etc... -JAVASCRIPT & STYLESHEET FUNCTIONS +JAVASCRIPT FUNCTIONS + +STYLESHEET LOGIC TO DETERMINE PAGE ACTION - Call Session\_Startup() - Call Get\_GET() - Call Init\_Macros() - If $VALID\_POST, do $\_POST['someaction'] - Validate which $page to show -GENERATE THE PAGE - <HTML> - ... - Load\_Selected\_Page($page) - ... - </HTML> +GENERATE/OUTPUT THE PAGE -------------------------------------------------------------------------------- ## Change Log +### 3.3.0 + +- Added support for optional external language files. Now to get some translations... +- The default, English, is included directly in OneFileCMS, of course. +- A sample language file (English) is included in the repo for reference for anyone that may be interested. + + ### 3.2.3 - Thanks to github.com/codeless: added the ability to process a seperate config file. @@ -267,12 +265,13 @@ GENERATE THE PAGE ### 1.1.6 -- 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). +- 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 Date: Tue, 10 Jul 2012 17:17:49 -0400 Subject: [PATCH 099/228] Version 3.3.0 --- OneFileCMS_structure.txt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/OneFileCMS_structure.txt b/OneFileCMS_structure.txt index 3f59ff9..7d22164 100755 --- a/OneFileCMS_structure.txt +++ b/OneFileCMS_structure.txt @@ -4,9 +4,15 @@ SOME BASIC SECURITY & ERROR LOG SETTINGS CONFIGURATION SECTION +GET EXTERNAL CONFIG (if exists) + OTHER GLOBAL VALUES +LANGUAGE SETTINGS + MISC FUNCTIONS: + hsc() + Load_Default_Language() Session_Startup() Verify_IDLE_POST_etc() hashit() @@ -53,8 +59,10 @@ PAGE & RESPONSE FUNCTIONS: Login_Page_response() List_Files() Index_Page() - Edit_Page_Buttons() + Edit_Page_buttons_top() + Edit_Page_buttons() Edit_Page_form() + Edit_Page_notes() Edit_Page() Edit_Page_response() Upload_Page() @@ -77,15 +85,15 @@ JAVASCRIPT & STYLESHEET FUNCTIONS: Time_Stamp_scripts() Edit_Page_scripts() style_sheet() - + LOGIC TO DETERMINE PAGE ACTION Verify good PHP version + Get language settings Call Session_Startup() Call Get_GET() Call Init_Macros() If VALID_POST Do $_POST['someaction'] (_response) Validate $page to show - + GENERATE/OUTPUT ... - From ca474f83d0b08329595ec2194ec16c995b70eaf2 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Jul 2012 17:21:29 -0400 Subject: [PATCH 100/228] Removed onefile.css from repo, as it's no longer used. --- onefilecms.css | 390 ------------------------------------------------- 1 file changed, 390 deletions(-) delete mode 100755 onefilecms.css diff --git a/onefilecms.css b/onefilecms.css deleted file mode 100755 index a960a00..0000000 --- a/onefilecms.css +++ /dev/null @@ -1,390 +0,0 @@ -/* OneFileCMS - http://onefilecms.com/ - * Version 1.4.0 - * For license & copyright info, see OneFileCMS.License.BSD.txt - */ - - -/* #d5d0cc #774200 #807568 #976322 #995400 #d4d4d4 #0F0901 #eaeaea - rgb(255,250,150) rgb(157, 124, 83) rgb(157, 124, 83) - rgb(255,250,150) rgb(255,250,150) #969376 rgb(255,245,115) - */ - - - -/* --- reset --- */ -html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big, -cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li, -fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td -{border : 0; outline: 0; margin : 0; padding: 0; -font-family: inherit; font-weight: inherit; font-style : inherit; -font-size : 100%; vertical-align: baseline; } - - - - -/* --- general formatting --- */ - -body { font-size: 1em; background: #DDD; font-family: sans-serif; } - -p, table { margin-bottom: .5em; } - -div{position: relative;} - -h1,h2,h3,h4,h5,h6{font-weight: bold;} -h2 { font-size: 20px; margin: 0 1em .2em 0;} /*TRBL*/ -h3 { font-size: 18px; margin-top: 15px; } -h4 { font-size: 1.3em; margin-bottom: .2em; font-weight: normal;} - -em, i { font-style: italic; } - -strong { font-weight: bold; } - -li {line-height: 1.4em; } - -:focus{outline:0;} - -ol,ul{list-style:none;} - -table{border-collapse:separate;border-spacing:0;} - -caption,th,td{text-align:left;font-weight:400;} - -blockquote:before,blockquote:after,q:before,q:after{content:"";} -blockquote,q{quotes:"" "";} - -a { border: 1px solid transparent; color: rgb(100,45,0); text-decoration: none; } -a:hover { border: 1px solid #807568; background-color: rgb(255,250,150); } -a:focus { border: 1px solid #807568; background-color: rgb(255,250,150); } - -form p { margin-bottom: 5px; } - - -label { display: inline-block; width : 7em; font-size : 1em; } - - -pre { - background: white; - border: 1px solid #807568; - line-height: 1.25em; - overflow: auto - overflow-Y: hidden; - padding: 10px; - margin: 5px 0 10px 0; - overflow: hidden; - } - - -/* --- layout --- */ - -.container { - border : 0px solid #807568; - width : 810px; - margin : 0em auto; - } - - -.header { - border-bottom : 1px solid #807568; - padding: 04px 0px 04px 0px; - margin : 0; - margin-bottom : .5em; - } - - -#logo { - font-family: 'Trebuchet MS', sans-serif; - font-size:2.2em; - font-weight: bold; - color: black; - padding: .1em; - } - - -.footer { color: #777; font-size: .7em; } - - -.alignleft { margin: 0 10px 10px 0; float: left; } - - -.dirname { font-weight: 400; } - -.filename { - border: 1px solid #807568; - padding: .1em .2em .1em .2em; - font-weight: 700; - font-family: courier; - background-color: #EEE; - } - - -#message {margin: .5em 0;} - -#message p { - margin: 0; - padding: 4px 0px 4px .5em; - border: 1px solid #807568; - Xfont-family: courier; - font-size: 1em; - line-height: 1.2em; - background: #fff000; - } - -#message span { float: right; } - -/* #message a { font-family: Courier; font-size: 1.2em; padding: 4px 2px 3px 2px; border-right: none;} */ -#message a { padding: 5px 4px 5px 4px; border-right: none; } /*T R B L */ - - -/* --- INDEX directory listing, table format --- */ -table.index_T { - min-width: 30em; - font-size: .95em; - border-style: outset; - border-width: 1px; - border-color: #807568; - border-collapse: collapse; - margin-bottom: .7em; - background-color: #FdFdFd; - } - -table.index_T tr:hover { border: 1px solid #807568; } - -table.index_T td { - border-width : 1px; - border-color : silver; - border-style : inset; - vertical-align: middle; - } - -.index_T a { - height : 1em; - display: block; - padding: .2em 1em .3em 1.6em; - color : rgb(100,45,0); - border : none; - background : url("http://self-evident.github.com/OneFileCMS/images/file-bin.png") 3px no-repeat; - overflow : hidden; - } - - -.index_T a.txt { background: url("http://self-evident.github.com/OneFileCMS/images/file-txt.png") 3px no-repeat; } -.index_T a.htm { background: url("http://self-evident.github.com/OneFileCMS/images/file-htm.png") 3px no-repeat; } -.index_T a.css { background: url("http://self-evident.github.com/OneFileCMS/images/file-css.png") 3px no-repeat; } -.index_T a.php { background: url("http://self-evident.github.com/OneFileCMS/images/file-php.png") 3px no-repeat; } -.index_T a.cfg { background: url("http://self-evident.github.com/OneFileCMS/images/file-cfg.png") 3px no-repeat; } -.index_T a.img { background: url("http://self-evident.github.com/OneFileCMS/images/file-img.png") 3px no-repeat; } -.index_T a.bin { background: url("http://self-evident.github.com/OneFileCMS/images/file-bin.png") 3px no-repeat; } -.index_T a.svg { background: url("http://self-evident.github.com/OneFileCMS/images/file-svg.png") 3px no-repeat; } - -.index_T a:hover { background-color: rgb(255,250,150); } -.index_T a:focus { background-color: rgb(255,250,150); } - - - -/* File size & date */ - -.meta_size { min-width: 6em; } - -.meta_time { width : 13em;} - -.meta { - height : 25px; - line-height : 1.1em; - font-size : .9em; - margin-top : 3px; - padding-right : .5em; - font-size : .9em; - color : #333; - } - -.meta_T { - padding-right : .5em; - text-align : right; - font-family : courier; - font-size : .9em; - color : #333; - } - - -.index_folders { min-height: 1.7em; margin-bottom: .2em; } - -.index_folders a { - Xborder : 1px solid #807568; - display : inline-block; - line-height : 1em; - font-size : 1em; - margin-right : .6em; - margin-bottom: .1em; - padding : 3px .4em 3px 25px; /*TRBL*/ - background : url("http://self-evident.github.com/OneFileCMS/images/folder-2.png") 4px 3px no-repeat; - } - -.index_folders a:hover { background-color: rgb(255,250,150); } -.index_folders a:focus { background-color: rgb(255,250,150); } - - - -/* [Upload File] [New File] [New Folder] etc... */ - -.front_links { clear: both; } - -.front_links a { - border: 1px solid #807568; - font-size: 16px; - margin-right: 15px; - padding: 3px 5px 5px 21px; /*T R B L*/ - height: 16px; - display: inline-block; - } - -.front_links a.upload { background: #EEE url("http://self-evident.github.com/OneFileCMS/images/upload.png") 3px 3px no-repeat; } -.front_links a.new { background: #EEE url("http://self-evident.github.com/OneFileCMS/images/file-new-2.png") 3px 4px no-repeat; } -.front_links a.newfolder { background: #EEE url("http://self-evident.github.com/OneFileCMS/images/folder-new-2.png") 2px 5px no-repeat; } -.front_links a.renamefolder { background: #EEE url("http://self-evident.github.com/OneFileCMS/images/folder-rename-1.png") 1px 4px no-repeat; } -.front_links a.deletefolder { background: #EEE url("http://self-evident.github.com/OneFileCMS/images/folder-del-3.png") 1px 5px no-repeat; } - -.front_links a:hover { background-color: rgb(255,250,150); } -.front_links a:focus { background-color: rgb(255,250,150); } - - -input[type="text"] { - border: 1px solid #807568; - padding: 2px; - width: 630px; - font: 1em "Courier New", Courier, monospace; - } - -input.textinput1 { width: 20em; } - -input.textinput2 { width: 40em; } - -textarea { - border: 1px solid #999; - font : .95em "Courier New", Courier, monospace; - margin: 0 0 .5em 0; /*T R B L*/ - width : 99.5%; - height: 30em; - height: 30em; - } - -textarea[disabled ]{ width : 99.5%; height: 50px; } - -textarea:focus { border: 1px solid #Faa; } - - -input:focus { background-color: rgb(255,250,150); } - -input:hover { background-color: rgb(255,250,150); } - -input[readonly] { color: #333; background-color: #EEE; } -input[disabled] { color: #555; background-color: #EEE; } -input[disabled]:hover { background-color: rgb(236,233,216); } -input[disabled]:hover { background-color: rgb(236,233,216); } - - -.buttons_right { float: right; } -.buttons_right .button { margin-left: 7px; } -.buttons_left { float: left; } -.buttons_left .button { margin-right: 7px; } - -.button { - border: 1px solid #807568; - padding: 4px 10px; - background-color: #EEE; /*#d4d4d4*/ - cursor: pointer; - font-size: .9em; - font-family: sans-serif; - } - -.button[disabled] { color: #777; background-color: #EEE; } - -#action {color: white; background-color: rgb(235,70,70); font-weight: 700;} - - -/* --- header --- */ - -.nav { - float : right; - display : inline-block; - margin-top: 1.6em; - font-size : 1em; - } - -.nav a { - border: 1px solid transparent; - font-weight : bold; - padding : .0em; - padding-top : .2em; - padding-left : .6em; - padding-right : .6em; - padding-bottom: .1em; - } - -.nav a:hover { border: 1px solid #807568; } -.nav a:focus { border: 1px solid #807568; } - - - -/* --- edit --- */ - -#edit_header {margin: 0;} - -#edit_form {margin: 0;} - -#file_content {height: 24em;} - -.file_meta {float: left; margin-top: .5em; font-size: .9em; color: #333; font-family: courier;} - -.close {float: right; margin-bottom: .5em;} - -#edit_note {font-size: .8em; color: #444 ;margin-top: 1em;} - - - -/* --- log in --- */ - -.login_page { - margin : 5em auto; - border : 1px solid #807568; - padding : 1em; - width : 360px; - } - -.login_input { - border : 1px solid #807568; - padding : 2px 0px 2px 2px; - width : 356px; - font : 1em "Courier New"; - } - -input[type="text"].login_input { width : 354px; } - - - -/* --- --- --- */ -hr { - line-height : 0; - font-size : 1px; - display : block; - position: relative; - padding : 0; - margin : 8px auto; - width : 100%; - clear : both; - border : none; - border-top : 1px solid #807568; - Xborder-bottom: 1px solid #eee; - overflow: visible; - } - -.web_root { font:1.2em Courier; } - -.sure { margin: .5em 0em .5em 0; } - -.verify { - border: 1px solid #807568; - color: #333; - background-color: #FEE; - padding: 2px .3em; - font: 1.2em Courier; - } From ef71e88c8adb4082d6d9e24180cbd16adff857ae Mon Sep 17 00:00:00 2001 From: David Date: Fri, 13 Jul 2012 17:10:40 -0400 Subject: [PATCH 101/228] Version 3.3.01 Edit_Page_scripts(): Tweaked [Save] button event triggered css Copy_Ren_Move_response(): $param3 was missing in global svg_icons...(): now returns a string instead of echo'ing directly. Delete_Folder_response(): missing $_ in global Added $WIDE_VIEW_WIDTH config variable. Not sure if it will stay... Pulled undo_magic_quotes() out of Get_GET() so Get_GET() may be called again, if needed. Minor typo in edit_txt_03 Minor wording change to edit_note_03 Minor wording change to edit_note_04 Default_Language(): Fixed issue for PHP versions < 5.3: OFCMS failed to load - this fix may be a temporary solution, but it works for now. Ummm... and some css tweakin' too... --- OneFileCMS.LANG.EN.ini | 12 +- onefilecms.php | 696 +++++++++++++++++++++-------------------- 2 files changed, 361 insertions(+), 347 deletions(-) diff --git a/OneFileCMS.LANG.EN.ini b/OneFileCMS.LANG.EN.ini index 18685a5..7e8098d 100755 --- a/OneFileCMS.LANG.EN.ini +++ b/OneFileCMS.LANG.EN.ini @@ -9,7 +9,7 @@ LANGUAGE = "English" ;// the actual setting variable, just set it to an empty string. ;// For example: some_unused_setting = "" ;// -;// Remember to slash-escape double quotes that may be within a value: \" +;// Remember to slash-escape double quotes that may be within a value: \" ;// And, if the these settings are set directly in Default_Language() in onefilecms.php, ;// single quotes must also be escaped: \' @@ -76,7 +76,7 @@ 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_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 : " @@ -85,7 +85,7 @@ login_h2 = "Log In" login_txt_01 = "Username:" login_txt_02 = "Password:" -login_msg_01a = "There have been" +login_msg_01a = "There have been " login_msg_01b = "invalid login attempts." login_msg_02a = "Please wait" login_msg_02b = "seconds to try again." @@ -95,14 +95,14 @@ 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_note_03 = "With some browsers, such as Chrome, if you click the browser [Back] then browser [Forward], the file state may not be accurate. To correct, click the browser's [Reload]." +edit_note_04 = "Chrome 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_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." too_large_to_edit_01a = "Edit disabled. Filesize > " diff --git a/onefilecms.php b/onefilecms.php index ce73eaf..1d05411 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@ 3.3.01.BETA'; //##### /******************************************************************************* Copyright © 2009-2012 https://github.com/rocktronica @@ -54,7 +54,7 @@ $HASHWORD = 'c3e70af96ab1bfc5669280e98b438e1a8c08ca5e0bb3354c05ceaa6f339fd3f6'; //hash for "password" $SALT = 'somerandomsalt'; -$LANGUAGE = ""; //Filename of language settings. Leave blank for built-in default. +$LANGUAGE = "X-OneFileCMS.LANG.EN.ini"; //Filename of language settings. Leave blank for built-in default. $MAX_ATTEMPTS = 3; //Max failed login attempts before LOGIN_DELAY starts. $LOGIN_DELAY = 10; //In seconds. @@ -81,6 +81,7 @@ $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 +$WIDE_VIEW_WIDTH = '97%'; $SESSION_NAME = 'OFCMS'; //Also the cookie name. Change if using multiple copies of OneFileCMS. @@ -163,230 +164,229 @@ function hsc($input) { return htmlspecialchars($input); }// end hsc() ********** function Default_Language() { // *********************************************** +global $_; +// OneFileCMS Language Settings +// +$_['LANGUAGE'] = 'English (default)'; +// +// These are the default values included directly in onefilecms.php. +// +// If no translation or value is desired for a particular setting, do not delete +// the actual setting variable, just set it to an empty string. +// For example: $_['some_unused_setting'] = ""; +// +// Remember to slash-escape any single quotes that may be within a value: \' + + + +$_['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'; + +$_['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'] = 'With some browsers, such as Chrome, if you click the browser [Back] then browser [Forward], the file state may not be accurate. To correct, click the browser\'s [Reload].'; +$_['edit_note_04'] = 'Chrome 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 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.'; + +$_['too_large_to_edit_01a'] = 'Edit disabled. Filesize > '; +$_['too_large_to_edit_01b'] = ' bytes.'; +$_['too_large_to_edit_02'] = 'Some browsers (ie: IE) bog down or become unstable while editing a large file in an HTML '.PHP_EOL; + onkeyup="Check_for_changes(event);">'.$filecontents.''.PHP_EOL; } } //end if non-text file... } //end if non-image @@ -1242,7 +1248,7 @@ function Edit_Page_Notes() { //************************************************* function Edit_Page() { //******************************************************* - global $_, $ONESCRIPT, $param1, $filename, $filecontent, $etypes, $itypes, $MAX_EDIT_SIZE, $MAX_VIEW_SIZE; + global $_, $ONESCRIPT, $param1, $filename, $filecontents, $etypes, $itypes, $MAX_EDIT_SIZE, $MAX_VIEW_SIZE; clearstatcache (); //Determine if text editable file type @@ -1280,8 +1286,8 @@ function Edit_Page() { //******************************************************* echo '

    '.$too_large_to_view_message.'

    '; } elseif ( $text_editable && $too_large_to_edit ){ - $filecontent = hsc(file_get_contents($filename), ENT_COMPAT,'UTF-8'); - 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); } ?>

    +

    + -

    - - -

    -

    - - -

    + + + + + + + + '.htmlentities($WEB_ROOT.$old_name).'
    '; $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() { //************************************************

    - +

    @@ -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)).'
    '; }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(){ //***********************************************

    - / +

    + + / +

    @@ -1767,7 +1777,7 @@ function FileTimeStamp(php_filemtime, show_date, show_offset){ function Edit_Page_scripts() { //*********************************************** - global $_; + global $_, $WIDE_VIEW_WIDTH; ?> +
    @@ -1233,9 +1232,9 @@ function Edit_Page_Notes() { //************************************************* $HRS_MIN_SEC = $HRS.':'.$MIN.':'.$SEC; ?>
    -
    +
    1) - +
    2)
    @@ -1263,14 +1262,14 @@ function Edit_Page() { //******************************************************* else { $header2 = hsc($_['edit_h2_2']); } $too_large_to_edit_message = -''.hsc($_['too_large_to_edit_01a']).number_format($MAX_EDIT_SIZE).' '.hsc($_['too_large_to_edit_01b']).'
    '. +''.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() { //*************************************************** ?>

    -

    +

    @@ -1415,12 +1414,12 @@ function New_File_response() { //*********************************************** if ($invalid){ $message .= $EX.''.hsc($_['new_file_msg_01']).' '.htmlentities($new_name).'
    '. - '       '.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 = '

    '.hsc($_['session_warning']).'

    '; ?> +function style_sheet(){ //****************************************************** +global $MAIN_WIDTH; +?> //****************************************************************************** //****************************************************************************** +header('Content-type: text/html; charset=UTF-8'); + ?> - -<?php echo $config_title.' - '.Page_Title() ?> - +<?php echo $config_title.' - '.Page_Title() ?> + @@ -2371,7 +2396,7 @@ function style_sheet(){ //****************************************************?>
    - '; ?> - '; ?> -   - B -   - -
    '; - if ($_POST['action'] == 'move') { - echo ' ('.hsc($_['CRM_txt_02']).')
    '; + 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 '

    '.hsc($_['delete_txt_01']).'

    '; //"Are you sure?" - Cancel_Submit_Buttons(hsc($button), "moveto"); + Cancel_Submit_Buttons(hsc($button), $focus); echo ''; -} //end MD_Action_Page() ******************************************************* +} //end MCD_Page() ************************************************************* -function MD_Action_mov() { //*************************************************** +function MCD_response($action) { //********************************************* global $_, $WEB_ROOT, $ipath, $param1, $param2, $param3, $message, $EX, $filename; - $new_location = trim($_POST['moveto'],'/').'/'; //make sure no leading, and only 1 trailing, slash. - $md_ipath = $ipath; //$Copy_Ren_Move_response() changes $ipath to $new_location $files = $_POST['files']; //List of files to delete (path not included) $count = count($files); - $errors = 0; //number of failed moves + $errors = 0; //number of failed moves or copies - if ( !is_dir($new_location) ){ - $message .= $EX.' '.hsc($_['upload_msg_02']).'
    '; - $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($_['From']).'
    '.hsc($_['To']).'
    '; + $message .= ': '.hsc($WEB_ROOT).$mcd_ipath.'
    '; + $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 = '

    '.hsc($_['session_warning']).'

    '; + $timeout_warning = '
    '.hsc($_['session_warning']).''; ?> - - ; /*Default is .5em*/ } + + #select_all_label { font-size: ; } + #select_all_div { width: ; } #message p {background: red; color: white;}'; + $message .= ''; + $message .= ''; $message .= $EX.''.hsc($_['edit_caution_01']).' '.$EX.hsc($_['edit_caution_02']).'
    '; } //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 Date: Thu, 30 Aug 2012 15:15:00 -0400 Subject: [PATCH 139/228] Version 3.4.0 Minor improvment to Error_reporting_and_early_output(). Modified svg icon for copy. In generating HTML output, now just echo everying, instead of dropping out of php mode. URLencode_path() needed on a $params string. Updated readme & _structure.txt A couple other minor ADOCD adjustments. Or maybe the're OCADD... --- OneFileCMS.LANG.DE.php | 2 +- OneFileCMS.LANG.EN.php | 2 +- OneFileCMS.LANG.ES.php | 2 +- OneFileCMS_structure.txt | 19 +++---- onefilecms.php | 109 ++++++++++++++++++--------------------- readme.markdown | 61 ++++++++++------------ 6 files changed, 92 insertions(+), 103 deletions(-) diff --git a/OneFileCMS.LANG.DE.php b/OneFileCMS.LANG.DE.php index b4a2503..86c3460 100755 --- a/OneFileCMS.LANG.DE.php +++ b/OneFileCMS.LANG.DE.php @@ -1,5 +1,5 @@ ... diff --git a/onefilecms.php b/onefilecms.php index c9a35a2..c5067a6 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@ ' or PHP_EOL or whatever... - if ( ($E_level & 1) == 1 ) { $E_types = 'E_ERROR' .$spc; } - if ( ($E_level & 2) == 2 ) { $E_types .= 'E_WARNING' .$spc; } - if ( ($E_level & 4) == 4 ) { $E_types .= 'E_PARSE' .$spc; } - if ( ($E_level & 8) == 8 ) { $E_types .= 'E_NOTICE' .$spc; } - if ( ($E_level & 16) == 16 ) { $E_types .= 'E_CORE_ERROR' .$spc; } - if ( ($E_level & 32) == 32 ) { $E_types .= 'E_CORE_WARNING' .$spc; } - if ( ($E_level & 64) == 64 ) { $E_types .= 'E_COMPILE_ERROR' .$spc; } - if ( ($E_level & 128) == 128 ) { $E_types .= 'E_COMPILE_WARNING' .$spc; } - if ( ($E_level & 256) == 256 ) { $E_types .= 'E_USER_ERROR' .$spc; } - if ( ($E_level & 512) == 512 ) { $E_types .= 'E_USER_WARNING' .$spc; } - if ( ($E_level & 1024) == 1024 ) { $E_types .= 'E_USER_NOTICE' .$spc; } - if ( ($E_level & 2048) == 2048 ) { $E_types .= 'E_STRICT' .$spc; } - if ( ($E_level & 4096) == 4096 ) { $E_types .= 'E_RECOVERABLE_ERROR'.$spc; } - if ( ($E_level & 8192) == 8192 ) { $E_types .= 'E_DEPRECATED' .$spc; } - if ( ($E_level & 16384) == 16384 ) { $E_types .= 'E_USER_DEPRECATED' .$spc; } + if ( $E_level & 1 ) { $E_types = 'E_ERROR' .$spc; } + if ( $E_level & 2 ) { $E_types .= 'E_WARNING' .$spc; } + if ( $E_level & 4 ) { $E_types .= 'E_PARSE' .$spc; } + if ( $E_level & 8 ) { $E_types .= 'E_NOTICE' .$spc; } + if ( $E_level & 16 ) { $E_types .= 'E_CORE_ERROR' .$spc; } + if ( $E_level & 32 ) { $E_types .= 'E_CORE_WARNING' .$spc; } + if ( $E_level & 64 ) { $E_types .= 'E_COMPILE_ERROR' .$spc; } + if ( $E_level & 128 ) { $E_types .= 'E_COMPILE_WARNING' .$spc; } + if ( $E_level & 256 ) { $E_types .= 'E_USER_ERROR' .$spc; } + if ( $E_level & 512 ) { $E_types .= 'E_USER_WARNING' .$spc; } + if ( $E_level & 1024 ) { $E_types .= 'E_USER_NOTICE' .$spc; } + if ( $E_level & 2048 ) { $E_types .= 'E_STRICT' .$spc; } + if ( $E_level & 4096 ) { $E_types .= 'E_RECOVERABLE_ERROR'.$spc; } + if ( $E_level & 8192 ) { $E_types .= 'E_DEPRECATED' .$spc; } + if ( $E_level & 16384 ) { $E_types .= 'E_USER_DEPRECATED' .$spc; } if ( $show_status && ( (error_reporting() != 0) || (ini_get('display_errors') == 'on') || @@ -859,7 +859,7 @@ function Cancel_Submit_Buttons($submit_label, $focus) { //********************** global $_, $ONESCRIPT, $ONESCRIPT_url_backup, $ipath, $param1, $param2, $filename, $page, $message; //$params for Cancel. If prior page was Admin, restore admin_ipath. - if ($_SESSION['recent_pages'][1] == "admin") { $params = '?i='.$_SESSION['admin_ipath'].'&p=admin'; } + if ($_SESSION['recent_pages'][1] == "admin") { $params = '?i='.URLencode_path($_SESSION['admin_ipath']).'&p=admin'; } else { $params = $param1.$param2.'&p='.$_SESSION['recent_pages'][1]; } //If came from edit page via admin page, drop this page from recent_pages @@ -924,7 +924,8 @@ function Timeout_Timer($COUNT, $ID, $CLASS="", $ACTION="") { //***************** function Init_Macros(){ //*** ($varibale="some reusable chunk of code")********* global $_, $ONESCRIPT, $param1, $param2, $INPUT_NUONCE, $FORM_COMMON, $PWUN_RULES, - $SVG_icon_circle_plus, $SVG_icon_circle_x, $SVG_icon_pencil, $SVG_icon_img_0; + $SVG_icon_circle_plus, $SVG_icon_circle_x, $SVG_icon_pencil, $SVG_icon_img_0, + $SVG_icon_circle_plus_rev; $INPUT_NUONCE = ''.PHP_EOL; $FORM_COMMON = '
    '.$INPUT_NUONCE; @@ -936,6 +937,10 @@ function Init_Macros(){ //*** ($varibale="some reusable chunk of code")********* '; +$SVG_icon_circle_plus_rev = ' + + '; + $SVG_icon_circle_x = ' '; @@ -968,10 +973,10 @@ function svg_icon_ren(){ //***************************************************** function svg_icon_copy(){ //**************************************************** - global $SVG_icon_circle_plus; + global $SVG_icon_circle_plus_rev; - return ''. - ''.$SVG_icon_circle_plus.''; + return ''. + ''.$SVG_icon_circle_plus_rev.''; } //end svg_icon_copy() ******************************************************** @@ -1604,10 +1609,10 @@ function List_Files() { //****************************************************** // As of Version 3.3.18, that number is 7. $checkbox_offset = 7; - if (supports_svg()) { //Checks if IE < 9. I don't even know if Select_All() works in IE 9+. Does IE have diff js or DOM? //##### + if (supports_svg()) { //Checks if IE < 9. $select_all_attribs = 'TYPE=checkbox NAME=select_all id=select_all VALUE=select_all'; $select_all_input = ''; - echo '
    '.$select_all_input; //* //##### + echo '
    '.$select_all_input; } function input_mcd($mcd) { @@ -1619,7 +1624,7 @@ function input_mcd($mcd) { echo ' '; echo ''; //* + '" onclick="Confirm_ready('.$checkbox_offset.'); return false">'; echo '
    '; //end class=action echo '
    '; //clear select_all @@ -2431,8 +2436,7 @@ function Respond_to_POST() {//************************************************** global $_, $VALID_POST, $page, $message; if ($VALID_POST) { - if (isset($_FILES['upload_file']['name'])) { Upload_response(); } - elseif ($page == "mcdaction") { + if ($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"; } @@ -2444,6 +2448,7 @@ function Respond_to_POST() {//************************************************** 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($_FILES['upload_file']['name'])) { Upload_response(); } elseif (isset($_POST["whattohash"] )) { Hash_response(); } elseif (isset($_POST["pw"] )) { Change_PWUN_response('pw');} elseif (isset($_POST["un"] )) { Change_PWUN_response('un');} @@ -3124,14 +3129,9 @@ function style_sheet(){ //****************************************************** } -table.verify_del { - border: 1px solid #F44; - background-color: #FFE7E7; - } +table.verify_del { border: 1px solid #F44; background-color: #FFE7E7; } -table.verify_del td { - border: 1px solid #F44; - } +table.verify_del td { border: 1px solid #F44; } #admin {padding: .3em;} @@ -3322,39 +3322,34 @@ function Language_and_config_adjusted_styles() {//****************************** //****************************************************************************** //****************************************************************************** //Output page contents -?> - - - - - +echo ''; +echo ''; +echo ''; +echo ''; -<?php echo $config_title.' - '.Page_Title() ?> +echo ''.$config_title.' - '.Page_Title().''; - +style_sheet(); - +Language_and_config_adjusted_styles(); - +common_scripts(); - - +echo ''; - +Error_reporting_and_early_output(1,0); -'; } +if ($page == "login"){ echo ''; // +echo ''; diff --git a/readme.markdown b/readme.markdown index 60f9907..269ddcb 100755 --- a/readme.markdown +++ b/readme.markdown @@ -1,4 +1,8 @@ -# Current stable version: 3.3.16 +# Current stable version: 3.4 + +### Auguest 29, 2012 + +- Added options to select and move, copy, or delete, multiple files from the index page. ### Auguest 14, 2012 @@ -38,14 +42,6 @@ Otherwise, the file - along with your password, is world readable. For details, - Thanks to [codeless](http://github.com/codeless) for the German language file! -#### Recent improvments: -- Added a few settings to the language files to adjust certain css values if needed. - In some instances, some langauges may use significantly longer words or phrases than others. So, a smaller font or less spacing may be desirable in those places to preserve page layout. -- "Wide View" option on Edit page now persists across saves -- Hopefully improved handling of language files. Kinda' like "online security", "multi-language support" is nebulous and a bit finicky. - - - -------------------------------------------------------------------------------- # OneFileCMS @@ -70,7 +66,8 @@ Coupling a utilitarian code editor with basic file managing functions, OneFileCM ## Features - 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 use an actual FTP program.)_ + _(For complex processes like batch renaming or mass uploads/deletions, you're going to want to use an actual FTP program.)_ +- A basic text editor. - Alert if you try to leave without saving your edits. - A Login delay after too many invalid attempts. - Adjustable idle time before auto-logout. @@ -83,7 +80,7 @@ Coupling a utilitarian code editor with basic file managing functions, OneFileCM 2) Upload to anywhere on your site. -3) Using your browser, start OneFileCMS, log in with the default "username" and "password". Then click on Admin and set your own username and password! +3) Log in to OneFileCMS with the default "username" and "password", and set your own username and password! Depending on how your web stack is set up, you may also have to modify the file permissions of your site's folders to allow OneFileCMS to modify and create files. ([More about that here.](http://catcode.com/teachmod/)) Make sure onefilecms.php and its parent folder are allowed to execute, with CHMOD at 755. Check with your host if you're not sure, and be aware of any inherent security concerns. @@ -93,7 +90,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 probably 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're 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. @@ -109,17 +106,17 @@ Well, because "OneFileFileManagerTextEditor" just doesn't have the same ring to ### Multi-Language Support? -Yes! Currently, English, German, and Spanish are available. (Someone told me he was working on an Esparento translation, but he might have been kidding...) +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...) ### 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, with 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 $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. ## Requirements -- PHP 5.2+ +- 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 - Javascript enabled browswer @@ -128,30 +125,23 @@ Now, since there is no database or other means of granular control and access lo ## Credit, License, Et Cetera -Maintained by github/Self-Evident - -Original concept and development by github.com/rocktronica - -Contributors: A. M Balakrishnan, github.com/codeless, github.com/fermuch - -Written in PHP, JavaScript, HTML, CSS, and SVG. - -Available under the MIT and BSD licenses. - -Icons for versions thru 1.1.6 by [famfamfam](http://www.famfamfam.com/). - -To report a bug or request a feature, please file an issue via Github. - -And, of course, please feel free to fork away! +- Maintained by github/Self-Evident +- Original concept and development by github.com/rocktronica +- Contributors: A. M Balakrishnan, github.com/codeless, github.com/fermuch +- Written in PHP, JavaScript, HTML, CSS, and SVG. +- Available under the MIT and BSD licenses. +- Icons for versions thru 1.1.6 by [famfamfam](http://www.famfamfam.com/). +- 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/upcoming 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+. -- 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 edit page with such a file, and only after a [Save]. -- Connection is not encrypted (doesn't use SSL), so passwords & usernames are sent in clear text during login. +- 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.) - Be aware that only some very basic data & error checking is performed. (But, it's getting better...) - On Windows, for instance, it's possible to create folders that are subsequently inaccessible and undeletable by Windows. (Yea, I found out the hard way...) (However, I *think* this issue is fixed.) + 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.) - Anything else? -------------------------------------------------------------------------------- @@ -182,6 +172,11 @@ GENERATE/OUTPUT THE PAGE ## Change Log +### 3.3.17 - 3.4.0 + +- Added option to select and move, copy, or delete multiple files. +- And other general code tweaks and improvements. + ### 3.3.11 - 3.3.16 - Added screens for changing username and password. From a93c04a9964eb44cf51543b9ec97eba15042f67f Mon Sep 17 00:00:00 2001 From: Self-Evident Date: Sun, 9 Sep 2012 15:45:00 -0400 Subject: [PATCH 140/228] Version 3.4.01 Check_path(): Minor logic fix. Cancel_Submit_Buttons(): Improved/simplified use of [recent_pages]. Admin_Page(): Improved preserve/restore $ipath. Admin_Page(): Fixed minor issue with [Edit OneFileCMS] button $params. Change_PWUN_Page(): don't hsc() until echo'ing to page. Change_PWUN_response($PWUN, $msg): added $msg param and removed an if/then. Table_of_Files(): Don't show Rename, Delete, or ckbox options for OneFile itself. Edit_Page_buttons & _top(): Improved check for [admin_page]. Copy_Ren_Move_Page & _response(): Don't hsc() params until echo. Copy_Ren_Move_response(): Removed some abandonded code. Added some that was needed. Delete_File_response(): Removed check for [recent_pages]. MCD_Page(): Moved list of "Selected Files" AFTER [Cancel] [Sumbit] buttons. MCD_response(): Added a couple params & removed if/then that used to set those values. Load_Selected_Page(): Removed hsc() from params - now hsc() only when echo'd. Page_Title(): removed hsc()'s - put where Page_Title() is called. Respond_to_POST(): added new params to a few function calls. Improved the js function Confirm_ready(). In main logic section, added use of/logic for $_SESSION[admin_page & recent_pages]. Consolidated a dozen or so redundant $_[langauge] strings (page_title_...). Moved Update_Recent_Pages() down after last few $page checks. Tweaked, added, & deleted some css Changed $Show_header_and_Admin to $Show_Path, & tweaked the logic. --- OneFileCMS.LANG.DE.php | 21 +- OneFileCMS.LANG.EN.php | 23 +- OneFileCMS.LANG.ES.php | 21 +- OneFileCMS_structure.txt | 8 +- onefilecms.php | 701 +++++++++++++++++++-------------------- readme.markdown | 49 +-- 6 files changed, 388 insertions(+), 435 deletions(-) diff --git a/OneFileCMS.LANG.DE.php b/OneFileCMS.LANG.DE.php index 86c3460..1bbfa65 100755 --- a/OneFileCMS.LANG.DE.php +++ b/OneFileCMS.LANG.DE.php @@ -1,5 +1,5 @@ ... diff --git a/onefilecms.php b/onefilecms.php index c5067a6..0051cbc 100755 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,7 +1,7 @@ defining page layout. $WIDE_VIEW_WIDTH = '97%'; //Width to set Edit page if [Wide View] is clicked @@ -101,7 +102,7 @@ //****************************************************************************** //System values & setup -//If there is one, include external config file. +//If there is one, include external config file. if ( isset($config_file) && is_file($config_file) ) { include($config_file); }else{ @@ -116,7 +117,7 @@ //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 (a number). //Ex: 5.1.23 converts to 50123. -if (!defined('PHP_VERSION_ID')) { +if (!defined('PHP_VERSION_ID')) { $phpversion = explode('.', PHP_VERSION); define('PHP_VERSION_ID', ($phpversion[0] * 10000 + $phpversion[1] * 100 + $phpversion[2])); } @@ -168,9 +169,9 @@ function hte($input) { return htmlentities($input, ENT_QUOTES, 'UTF-8'); }//end function Default_Language() { // *********************************************** global $_; -// OneFileCMS Language Settings v3.3.18 +// OneFileCMS Language Settings v3.4.01 -$_['LANGUAGE'] = 'English'; //EN +$_['LANGUAGE'] = 'English'; //EN $_['LANG'] = 'EN'; // If no translation or value is desired for a particular setting, do not delete @@ -185,18 +186,18 @@ function Default_Language() { // *********************************************** // In some instances, some langauges may use significantly longer words or phrases than others. // So, a smaller font or less spacing may be desirable in those places to preserve page layout. // -$_['front_links_font_size'] = '1em'; //Buttons on Index page. +$_['front_links_font_size'] = '1em'; //Buttons on Index page. $_['front_links_margin_R'] = '1em'; -$_['button_font_size'] = '.9em'; //Buttons on Edit page. +$_['button_font_size'] = '.9em'; //Buttons on Edit page. $_['button_margin_L'] = '.7em'; $_['button_padding'] = '4px 10px'; -$_['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'] -$_['select_all_div_width'] = '73px'; //Width of space for $_['Select_All'] -$_['R'] = 'R'; //R ename -$_['C'] = 'C'; //C opy -$_['D'] = 'D'; //D elete +$_['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'] +$_['select_all_div_width'] = '73px'; //Width of space for $_['Select_All'] +$_['R'] = 'R'; //R ename +$_['C'] = 'C'; //C opy +$_['D'] = 'D'; //D elete $_['Admin'] = 'Admin'; $_['Cancel'] = 'Cancel'; $_['Close'] = 'Close'; @@ -224,6 +225,8 @@ function Default_Language() { // *********************************************** $_['Username'] = 'Username'; $_['Log_In'] = 'Log In'; $_['Log_Out'] = 'Log Out'; +$_['Admin_Options'] = 'Administration Options'; +$_['Edit_View'] = 'Edit / View File'; $_['Upload_File'] = 'Upload File'; $_['New_File'] = 'New File'; $_['Ren_Move'] = 'Rename / Move'; @@ -249,6 +252,7 @@ function Default_Language() { // *********************************************** $_['reset'] = 'Reset - loose changes'; $_['Wide_View'] = 'Wide View'; $_['Normal_View'] = 'Normal View'; +$_['Open_View'] = 'Open/View in browser window'; $_['verify_msg_01'] = 'Session expired.'; $_['verify_msg_02'] = 'INVALID POST'; $_['get_get_msg_01'] = 'File does not exist:'; @@ -353,21 +357,6 @@ function Default_Language() { // *********************************************** $_['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_admin'] = 'Administration Options'; -$_['page_title_hash'] = 'Generate a Password Hash'; -$_['page_title_change_pw'] = 'Change Password'; -$_['page_title_change_un'] = 'Change Username'; -$_['page_title_edit'] = 'Edit / View File'; -$_['page_title_upload'] = 'Upload File'; -$_['page_title_new_file'] = 'New File'; -$_['page_title_ren'] = 'Rename / Move File'; -$_['page_title_copy'] = 'Copy File(s)'; -$_['page_title_mov'] = 'Move File(s)'; -$_['page_title_del'] = 'Delete File(s)'; -$_['page_title_folder_new'] = 'New Folder'; -$_['page_title_folder_ren'] = 'Rename / Move Folder'; -$_['page_title_folder_del'] = 'Delete Folder'; $_['session_warning'] = 'Warning: Session timeout soon!'; $_['session_expired'] = 'SESSION EXPIRED'; $_['unload_unsaved'] = ' Unsaved changes will be lost!'; @@ -380,11 +369,11 @@ function Default_Language() { // *********************************************** $_['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:'; -$_['error_reporting_01'] = 'Display errors is'; -$_['error_reporting_02'] = 'Log errors is'; +$_['error_reporting_01'] = 'Display errors is'; +$_['error_reporting_02'] = 'Log errors is'; $_['error_reporting_03'] = 'Error reporting is set to'; -$_['error_reporting_04'] = 'Showing error types'; -$_['error_reporting_05'] = 'Unexpected early output'; +$_['error_reporting_04'] = 'Showing error types'; +$_['error_reporting_05'] = 'Unexpected early output'; $_['error_reporting_06'] = '(nothing, not even white-space, should have been output yet)'; $_['admin_txt_00'] = 'Old Backup Found'; $_['admin_txt_01'] = 'A backup file was created in case of an error during a username or password change. Therefore, it may contain old information and should be deleted if not needed. In any case, it will automatically be overwritten on the next password or username change.'; @@ -393,32 +382,32 @@ function Default_Language() { // *********************************************** $_['admin_txt_12'] = 'However, due to a number of considerations, this change was largely an academic exersize. That is, in this application, take the idea that it adds much of an improvement to security with a grain of cryptographic salt. Never-the-less, it does eliminate the storage of your password in plain text (if that option was used), which is generally considered to be a good thing.'; $_['admin_txt_14'] = 'For another small improvement to security, change the default salt and/or method used by OneFileCMS to hash the password (and keep them secret, of course). Every little bit helps...'; $_['admin_txt_16'] = 'Also, you can still use OneFileCMS to edit itself. However, be sure to have a backup ready for the inevitable ytpo...'; -$_['pw_change'] = 'Change Password'; -$_['pw_current'] = 'Current Password'; -$_['pw_new'] = 'New Password'; -$_['pw_confirm'] = 'Confirm New Password'; -$_['pw_txt_02'] = 'Password / Username rules:'; -$_['pw_txt_04'] = 'They are case-sensitive!'; +$_['pw_change'] = 'Change Password'; +$_['pw_current'] = 'Current Password'; +$_['pw_new'] = 'New Password'; +$_['pw_confirm'] = 'Confirm New Password'; +$_['pw_txt_02'] = 'Password / Username rules:'; +$_['pw_txt_04'] = 'They are case-sensitive!'; $_['pw_txt_06'] = 'They must contain at least one non-space character.'; $_['pw_txt_08'] = 'They may contain spaces in the middle. Ex: "This is a password or username!"'; $_['pw_txt_10'] = 'Leading and trailing spaces are removed.'; $_['pw_txt_12'] = 'To record the change, only one file is updated: either the active copy of OneFileCMS, or, if specified, an external configuration file.'; $_['pw_txt_14'] = 'If an incorrect current password is entered, you will be logged out, but you may log back in.'; -$_['change_pw_01'] = 'Password changed!'; -$_['change_pw_02'] = 'Password NOT changed:'; +$_['change_pw_01'] = 'Password changed!'; +$_['change_pw_02'] = 'Password NOT changed:'; $_['change_pw_03'] = 'Incorrect current password. Login to try again.'; -$_['change_pw_04'] = 'New and "Confirm New" values do not match.'; -$_['change_pw_05'] = 'Updating'; -$_['change_pw_06'] = 'external config file'; -$_['un_change'] = 'Change Username'; -$_['un_new'] = 'New Username'; -$_['un_confirm'] = 'Confirm New Username'; -$_['change_un_01'] = 'Username changed!'; -$_['change_un_02'] = 'Username NOT changed:'; -$_['update_failed'] = 'Update failed - could not save file.'; -$_['mcd_msg_01'] = 'files moved successfully.'; -$_['mcd_msg_02'] = 'files copied successfully.'; -$_['mcd_msg_03'] = 'files deleted successfully.'; +$_['change_pw_04'] = 'New and "Confirm New" values do not match.'; +$_['change_pw_05'] = 'Updating'; +$_['change_pw_06'] = 'external config file'; +$_['un_change'] = 'Change Username'; +$_['un_new'] = 'New Username'; +$_['un_confirm'] = 'Confirm New Username'; +$_['change_un_01'] = 'Username changed!'; +$_['change_un_02'] = 'Username NOT changed:'; +$_['update_failed'] = 'Update failed - could not save file.'; +$_['mcd_msg_01'] = 'files moved successfully.'; +$_['mcd_msg_02'] = 'files copied successfully.'; +$_['mcd_msg_03'] = 'files deleted successfully.'; }//end Default_Language() ****************************************************** @@ -427,11 +416,11 @@ function Default_Language() { // *********************************************** function Session_Startup() { //************************************************* global $SESSION_NAME, $page, $VALID_POST, $message; - $limit = 0; //0 = session. + $limit = 0; //0 = session. $path = ''; $domain = ''; // '' = hostname $https = false; - $httponly = true;//true = unaccessable via javascript. Some XSS protection. + $httponly = true; //true = unaccessable via javascript. Some XSS protection. session_set_cookie_params($limit, $path, $domain, $https, $httponly); session_name($SESSION_NAME); @@ -460,7 +449,7 @@ function Session_Startup() { //************************************************* function Verify_IDLE_POST_etc() { //******************************************** global $_, $EX, $message, $VALID_POST, $MAX_IDLE_TIME; - //Verify consistant user agent... (every little bit helps every little bit) + //Verify consistant user agent... (every little bit helps every little bit) if ( !isset($_SESSION['user_agent']) || ($_SESSION['user_agent'] != $_SERVER['HTTP_USER_AGENT']) ) { Logout(); } //Check idle time @@ -475,7 +464,7 @@ function Verify_IDLE_POST_etc() { //******************************************** $_SESSION['last_active_time'] = time(); //If POSTing, verify... - if ( isset($_POST['nuonce']) ) { + if ( isset($_POST['nuonce']) ) { if ( $_POST['nuonce'] == $_SESSION['nuonce'] ) { $VALID_POST = 1; }else{ //If it exists but doesn't match - something's wrong. @@ -525,7 +514,7 @@ function Error_reporting_and_early_output($show_status = 0, $show_types = 0) {// if ( $E_level & 16384 ) { $E_types .= 'E_USER_DEPRECATED' .$spc; } if ( $show_status && ( (error_reporting() != 0) || - (ini_get('display_errors') == 'on') || + (ini_get('display_errors') == 'on') || (ini_get('log_errors') == 'on') ) ) { ?> -

    +

    @@ -1263,7 +1245,7 @@ function Hash_Page() { //*******************************************************
    - -

    +

    @@ -1311,10 +1293,10 @@ function Change_PWUN_Page($config_key) { //*************************************
    -
    +
    -
    +
    @@ -1325,7 +1307,7 @@ function Change_PWUN_Page($config_key) { //*************************************

    -'.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; ?> -

    +

    @@ -1463,7 +1444,7 @@ function Login_Page() { //****************************************************** - - - + '.$R.''; + } ?> + - - + '.$C.'' ?> + - - - - - + '.$D.''; + } ?> + + + '; + } ?> + - '; ?> + '; ?> '; ?> -   B @@ -1569,7 +1559,7 @@ function Table_of_Files($files, $R, $C, $D) { //******************************** -'; @@ -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'; } ?>
    @@ -1685,13 +1673,13 @@ function Edit_Page_buttons_top($text_editable,$file_ENC){ //******************** -
    -
    - -"; } @@ -2734,17 +2697,17 @@ function Reset_file_status_indicators() { //With selStart & selEnd == 0, moves cursor to start of text field. - function setSelRange(inputEl, selStart, selEnd) { - if (inputEl.setSelectionRange) { + function setSelRange(inputEl, selStart, selEnd) { + if (inputEl.setSelectionRange) { inputEl.focus(); inputEl.setSelectionRange(selStart, selEnd); - } else if (inputEl.createTextRange) { + } else if (inputEl.createTextRange) { var range = inputEl.createTextRange(); range.collapse(true); range.moveEnd('character', selEnd); range.moveStart('character', selStart); range.select(); - } + } } @@ -2767,8 +2730,8 @@ function Check_for_changes(event){ //Reset textarea value to when page was loaded. - //Used by [Reset] button, and when page unloads (browser back, etc). - //Needed becuase if the page is reloaded (ctl-r, or browser back/forward, etc.), + //Used by [Reset] button, and when page unloads (browser back, etc). + //Needed becuase if the page is reloaded (ctl-r, or browser back/forward, etc.), //the text stays changed, but "changed" gets set to false, which looses warning. function Reset_File() { if (changed) { @@ -2781,7 +2744,7 @@ function Reset_File() { Reset_file_status_indicators(); - -; + color: #222; font-size: ; } .edit_btns_bottom .button { @@ -3257,6 +3227,11 @@ function Language_and_config_adjusted_styles() {//****************************** Session_Startup(); +if (!isset($_SESSION['admin_page'])) { + $_SESSION['admin_page'] = false; + $_SESSION['admin_ipath'] = ''; +} + if ($_SESSION['valid']) { undo_magic_quotes(); @@ -3267,35 +3242,45 @@ function Language_and_config_adjusted_styles() {//****************************** Respond_to_POST(); - Update_Recent_Pages(); - //*** Verify a few $page conditions ************** - + + //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() - if ( ($page == "login") && $_SESSION['valid'] ) { $page = "index"; } - + elseif ( ($page == "login") && $_SESSION['valid'] ) { $page = "index"; } + elseif ( $page == "logout" ) { Logout(); - $message .= hsc($_['logout_msg']); } - + $message .= hsc($_['logout_msg']); + } //Don't load delete page if folder not empty. elseif ( ($page == "deletefolder") && !is_empty($ipath) ) { $message .= $EX.''.hsc($_['folder_del_msg']).''; - $page = "index";} - + $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 red message box with white text. - elseif ($filename == trim(rawurldecode($ONESCRIPT), '/')) { + $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 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 ''.$config_title.' - '.Page_Title().''; +echo ''.hsc($config_title.' - '.Page_Title()).''; style_sheet(); @@ -3340,25 +3323,25 @@ function Language_and_config_adjusted_styles() {//****************************** Error_reporting_and_early_output(1,0); if ($page == "login"){ echo ''; //end class=action - Table_of_Files($files, $R, $C, $D); + Table_of_Files($files, $folders, $R, $C, $D); echo ''; }//end List_Files() //********************************************************** @@ -1713,31 +1766,30 @@ function Index_Page(){ //******************************************************* $F=1; $D=1; //indexes foreach( $full_list as $item ) { if ( ($item == '.') || ($item == '..')){ continue; } - if (is_dir($ipath.$item)){ $folders[$D++] = $ipath.$item.'/'; } + if (is_dir($ipath.$item)){ $folders[$D++] = $item; } else { $files[$F++] = $item; } } //List folders 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 '

    '; //Upload_New_Rename_Delete_Links echo ''; - List_Files($files); + List_Files($files,$folders); }//end Index_Page() //********************************************************** @@ -1799,10 +1851,10 @@ function Edit_Page_buttons($text_editable, $too_large_to_edit) { //************* '; } - echo $Button.hsc($_['Copy']) .$ACTION.'copy\'">'; + if (!$Editing_OFCMS) { echo $Button.hsc($_['Ren_Move']).$ACTION.'renamefile\'">'; } + echo $Button.hsc($_['Copy']) .$ACTION.'copyfile\'">'; if (!$Editing_OFCMS) { echo $Button.hsc($_['Delete']) .$ACTION.'deletefile\'" id="delete">'; } - echo $Button.hsc($_['Close']).'" onclick="parent.location = \''.$ONESCRIPT.$params.'\'">' + echo $Button.hsc($_['Close']).'" onclick="parent.location = \''.$ONESCRIPT.$params.'\'">' ?>
    '.$filecontents.''.PHP_EOL; } - }//end if non-text file... + }//end if/else non-text file... }//end if non-image Edit_Page_buttons($text_editable, $too_large_to_edit); @@ -2079,7 +2131,7 @@ function New_File_or_Folder_response($post, $is_file){ //*********************** $param2 = '&f='.rawurlencode(basename($filename)); //for Edit_Page() buttons $param3 = '&p=edit'; //for Edit_Page() buttons - }elseif ( !$is_file && mkdir($new_ipath)) { //Create Folder + }elseif ( !$is_file && mkdir($new_ipath,0755)) { //Create Folder $message .= ''.hsc($_['new_file_msg_07']).' '.$msg_new; //New folder success $ipath = $new_ipath; //return to new folder $param1 = '?i='.URLencode_path($ipath); @@ -2093,26 +2145,34 @@ function New_File_or_Folder_response($post, $is_file){ //*********************** function Set_Input_width() { //************************************************* - global $WEB_ROOT, $MAIN_WIDTH; + global $_, $WEB_ROOT, $MAIN_WIDTH; - // (width of ) = $MAIN_WIDTH - (Width of $WEB_ROOT) + // (width of ) = $MAIN_WIDTH - (Width of