From 9e6916b591bff6802e37dac813d9381393d3d791 Mon Sep 17 00:00:00 2001 From: Tommy Date: Sun, 18 Mar 2012 21:07:51 -0500 Subject: [PATCH] markup cleanup, css font and line-height changes --- style.css => onefilecms.css | 11 +- onefilecms.php | 989 ++++++++++++++++++------------------ 2 files changed, 514 insertions(+), 486 deletions(-) rename style.css => onefilecms.css (96%) diff --git a/style.css b/onefilecms.css similarity index 96% rename from style.css rename to onefilecms.css index adf6b47..bff5def 100644 --- a/style.css +++ b/onefilecms.css @@ -14,9 +14,9 @@ h1,h2,h3,h4,h5,h6{font-weight: bold;} body { font-size: 12px; - line-height: 1; + line-height: 20px; background: #d5d0cc url("/images/background.jpg") top center no-repeat; - font-family: Century Gothic, Apple Gothic, sans-serif; + font-family: sans-serif; color: #0F0901; } @@ -45,7 +45,7 @@ body { /* --- general formatting --- */ -h2, h3, p, ul { margin-bottom: 10px; } +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; } @@ -221,6 +221,7 @@ form .meta { z-index: -1; } border: 1px solid #807568; padding: 2px; width: 350px; + font: 12px/18px "Courier New", Courier, monospace; } textarea.textinput { @@ -237,11 +238,11 @@ textarea.disabled { height: 50px; } .button { border: 1px solid #807568; - padding: 2px 10px; + padding: 4px 10px; background-color: #d4d4d4; cursor: pointer; font-size: 14px; - font-family: Century Gothic, Apple Gothic, sans-serif; + font-family: sans-serif; } .button:hover { background-color: #eaeaea; } diff --git a/onefilecms.php b/onefilecms.php index c54278c..d279242 100644 --- a/onefilecms.php +++ b/onefilecms.php @@ -1,529 +1,556 @@ -OneFileCMS."; -$config_disabled = "bmp,ico,gif,jpg,png,psd,zip"; -$config_excluded = "onefilecms.php,favicon,.htaccess"; - -$version = "1.1.5"; // 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(); - -session_start(); -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"; +// CONFIGURATION INFO +$config_username = "username"; +$config_password = "password"; +$config_hint = ""; +$config_title = "OneFileCMS"; +$config_footer = date("Y")." OneFileCMS."; +$config_disabled = "bmp,ico,gif,jpg,png,psd,zip"; +$config_excluded = "onefilecms.php,favicon,.htaccess"; + +$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(); + +session_start(); +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."); - } -} - -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 - if (!in_array(strtolower($_GET["p"]), array( - "copy","delete","error","deletefolder","edit","folder","index","login","logout","new","other","rename","renamefolder","upload" + } +} + +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 + 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."); - } - $page = $_GET["p"]; -} -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"]); } - -// entitize get params -foreach ($_GET as $name => $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; ?> - - - - - -
- - - -

-

Copy “

-

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

-
"> - + } + $page = $_GET["p"]; +} +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"]); } + +// entitize get params +foreach ($_GET as $name => $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 “

+

Are you sure?

+
"> +

'" /> -

-
- -

Delete Folder “

-

Folders have to be empty before they can be deleted.

-
"> - +

+
+ +

Delete Folder “

+

Folders have to be empty before they can be deleted.

+
"> +

" /> '" /> -

-
- -

Edit “

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

+
+ +

Edit “

+ ?i=" class="back">Back +
?f="> + + if (strpos($config_disabled,end(explode(".", $lfile)))) { ?>

-

-

- - +

+

+ +

-

-

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

+

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

-
-

File Size: kb - - Last Updated:

-
-
-
- -

-

- - ?i=" class="folder">.. / - +

+

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. + ?>

+ +

+ - ?i=" class="folder"> - -

-
-
    - + ?i=" class="folder"> + +

    +
    + - - -

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

    -

    -

    -

    -
    - - - - -
- + }; + if (strrpos($lfile,".css")) { $file_class = "css"; }; + if (strrpos($lfile,".php")) { $file_class = "php"; }; ?> +
  • + ?f=" class=""> +
    + 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" /> +

    +

    + + +

    +

    +
    + + + + +
    + - - - + $(".page_edit form").submit(function() { $save_file.val("Save"); }); + window.onbeforeunload = function () { + if ($save_file.val() == "Save!") { + return "Any changes you've made will be lost!"; + } + }; + + }); + + + + \ No newline at end of file