Profile
MAJ is an Open Source, PHP-based content management system (CMS) that can be deployed as a blog, bulletin or message board, Internet forum, and wiki. It is extensible via PHP panels and is HTML5 and CSS3 ready.
Git
This commit has been accessed 827 times via Git panel.

commit f5857046e48407a8e2a3763afb328bd5db1edcf4
tree 5b6c01d1986fd28aab7e80054557146fc4d3d39a
parent 73154ff659b8bf22cba60ab651b1c3f9197a6682
author Engels Antonio <engels@majcms.org> 1277314208 +0800
committer Engels Antonio <engels@majcms.org> 1277314208 +0800

    maj-1.0-20090112-bb.zip

diff --git a/edit.php b/edit.php
index 7caf5ca..944a671 100644
--- a/edit.php
+++ b/edit.php
@@ -94,11 +94,11 @@ function entry2date($f_entry) {
        echo date("l, M j, Y, g:i A",mktime($f_entry_hour,$f_entry_min,$f_entry_sec,$f_entry_month,$f_entry_day,$f_entry_year));
 }
 
-$title_file = 'data/items/' . $_REQUEST['entry'] . '/title.txt';
-$body_file = 'data/items/' . $_REQUEST['entry'] . '/body.txt';
-$date_file = 'data/items/' . $_REQUEST['entry'] . '/date.txt';
-$img_file = 'data/items/' . $_REQUEST['entry'] . '/image.txt';
-$revisions_file = 'data/items/' . $_REQUEST['entry'] . '/revisions.txt';
+$title_file = "data/items/{$_REQUEST['entry']}/title.txt";
+$body_file = "data/items/{$_REQUEST['entry']}/body.txt";
+$date_file = "data/items/{$_REQUEST['entry']}/date.txt";
+$img_file = "data/items/{$_REQUEST['entry']}/image.txt";
+$revisions_file = "data/items/{$_REQUEST['entry']}/revisions.txt";
 
 $max_image_size = 8000000;
 $max_file_size = 8000000;
@@ -249,6 +249,10 @@ if (isset($_POST['category']) and !empty($_POST['category'])) {
 
        if (($_POST['do'] == "unfile") and file_exists("data/items/{$_REQUEST['entry']}/categories/{$_REQUEST['category']}")) {
                rmdirr("data/items/{$_REQUEST['entry']}/categories/{$_REQUEST['category']}");
+
+               if (count(glob("data/items/{$_REQUEST['entry']}/categories/*")) < 1) {
+                       rmdirr("data/items/{$_REQUEST['entry']}/categories");
+               }
        }
 
        if (($_POST['do'] == "file") and !file_exists("data/items/{$_REQUEST['entry']}/categories/{$_REQUEST['category']}")) {
@@ -600,10 +604,22 @@ if ($count_unfiled_cat > 0) {
 </td></tr></table>
 
 <?php
+
 if (!isset($_POST['title_input']) or !isset($_POST['body_input']) or empty($_POST['title_input']) or empty($_POST['body_input'])) {
        exit();
 }
 
+if (file_exists("data/items/{$_REQUEST['entry']}/title.old")) {
+       unlink("data/items/{$_REQUEST['entry']}/title.old");
+}
+
+if (file_exists("data/items/{$_REQUEST['entry']}/body.old")) {
+       unlink("data/items/{$_REQUEST['entry']}/body.old");
+}
+
+copy("data/items/{$_REQUEST['entry']}/title.txt","data/items/{$_REQUEST['entry']}/title.old");
+copy("data/items/{$_REQUEST['entry']}/body.txt","data/items/{$_REQUEST['entry']}/body.old");
+
 $title_write_content = ucfirst($_POST['title_input']);
 $title_write_content = str_replace('<','&lt;',$title_write_content);
 $title_write_content = str_replace('>','&gt;',$title_write_content);
@@ -696,7 +712,9 @@ $body_write_content =  preg_replace("/<([_\.0-9a-z-]+)@([0-9a-z][0-9a-z-]+)\.([_
 $fp_revisions_file = fopen($revisions_file, "r");
 $revisions_count = fread($fp_revisions_file, filesize($revisions_file));
 fclose($fp_revisions_file);
+
 $revisions_count = $revisions_count + 1;
+
 $fp_revisions_file = fopen($revisions_file, "w");
 fwrite($fp_revisions_file, $revisions_count);
 fclose($fp_revisions_file);
@@ -886,46 +904,51 @@ if (isset($_FILES['file_input']) and !empty($_FILES['file_input'])) {
 
 if (file_exists("data/wiki.txt")) {
 
-       if (!file_exists("data/items/{$_REQUEST['entry']}/wiki")) {
-               mkdir("data/items/{$_REQUEST['entry']}/wiki");
-       }
+       $old_title = file_get_contents("data/items/{$_REQUEST['entry']}/title.old");
+       $old_body = file_get_contents("data/items/{$_REQUEST['entry']}/body.old");
 
-       if (!file_exists("data/items/{$_REQUEST['entry']}/wiki/delta")) {
-               mkdir("data/items/{$_REQUEST['entry']}/wiki/delta");
-       }
+       if (($old_title != $title_write_content) or ($old_body != $body_write_content)) {
 
-       if (file_exists("data/offset.txt")) {
-               $offset = file_get_contents("data/offset.txt");
-       }
-       else {
-               $offset = 0;
-       }
+               if (!file_exists("data/items/{$_REQUEST['entry']}/wiki")) {
+                       mkdir("data/items/{$_REQUEST['entry']}/wiki");
+               }
 
-       $ddate = date("YmdHis", time() + $offset);
+               if (!file_exists("data/items/{$_REQUEST['entry']}/wiki/delta")) {
+                       mkdir("data/items/{$_REQUEST['entry']}/wiki/delta");
+               }
 
-       if (!file_exists("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate")) {
-               mkdir("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate");
-       }
+               if (file_exists("data/offset.txt")) {
+                       $offset = file_get_contents("data/offset.txt");
+               }
+               else {
+                       $offset = 0;
+               }
 
-       $new_body = fopen("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/body.txt","w");
-       fwrite($new_body,$body_write_content);
-       fclose($new_body);
+               $ddate = date("YmdHis", time() + $offset);
 
-       $new_title = fopen("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/title.txt","w");
-       fwrite($new_title,$title_write_content);
-       fclose($new_title);
+               if (!file_exists("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate")) {
+                       mkdir("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate");
+               }
 
-       copy("data/items/{$_REQUEST['entry']}/body.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/prev.txt");
-       copy("data/items/{$_REQUEST['entry']}/date.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/date.txt");
+               $new_body = fopen("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/body.txt","w");
+               fwrite($new_body,$body_write_content);
+               fclose($new_body);
 
-       if (file_exists("data/items/{$_REQUEST['entry']}/contrib.txt")) {
-               copy("data/items/{$_REQUEST['entry']}/contrib.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/contrib.txt");
-       }
+               $new_title = fopen("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/title.txt","w");
+               fwrite($new_title,$title_write_content);
+               fclose($new_title);
 
-       $open_editor_file = fopen("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/editor.txt","w");
-       fwrite($open_editor_file,$_SESSION['logged_in']);
-       fclose($open_editor_file);
+               copy("data/items/{$_REQUEST['entry']}/body.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/prev.txt");
+               copy("data/items/{$_REQUEST['entry']}/date.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/date.txt");
 
+               if (file_exists("data/items/{$_REQUEST['entry']}/contrib.txt")) {
+                       copy("data/items/{$_REQUEST['entry']}/contrib.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/contrib.txt");
+               }
+
+               $open_editor_file = fopen("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/editor.txt","w");
+               fwrite($open_editor_file,$_SESSION['logged_in']);
+               fclose($open_editor_file);
+       }
 }
 
 $open_body_file = fopen($body_file,"w");
@@ -1173,22 +1196,25 @@ if ($_SESSION['logged_in'] == $login_username) {
        }
 }
 
-$default_ping_urls = "http://technorati.com/ping/http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
-$ping_urls_file = "data/ping.txt";
+if (file_exists("data/items/{$_REQUEST['entry']}/title.old")) {
+       unlink("data/items/{$_REQUEST['entry']}/title.old");
+}
 
-if (!file_exists($ping_urls_file)) {
-       $fp_default_ping_txt = fopen($ping_urls_file,"w");
-       fwrite($fp_default_ping_txt, $default_ping_urls);
-       fclose($fp_default_ping_txt);
+if (file_exists("data/items/{$_REQUEST['entry']}/body.old")) {
+       unlink("data/items/{$_REQUEST['entry']}/body.old");
 }
 
-$fp_ping_urls = fopen($ping_urls_file, "r");
-$ping_urls = fread($fp_ping_urls, filesize($ping_urls_file));
-fclose($fp_ping_urls);
+$default_ping_url = "http://technorati.com/ping/http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
+
+if (!file_exists("data/ping.txt")) {
+       $fp_default_ping_txt = fopen("data/ping.txt","w");
+       fwrite($fp_default_ping_txt, $default_ping_url);
+       fclose($fp_default_ping_txt);
+}
 
-$get_ping_urls = explode("|", $ping_urls);
+$ping_urls = explode("|", file_get_contents("data/ping.txt"));
 
-foreach ($get_ping_urls as $ping_url) {
+foreach ($ping_urls as $ping_url) {
        $ping = file_get_contents($ping_url);
        unset($ping);
 }
diff --git a/rel.txt b/rel.txt
index ae8828e..56d9d61 100644
--- a/rel.txt
+++ b/rel.txt
@@ -1 +1 @@
-20081231
\ No newline at end of file
+20090112
\ No newline at end of file
 
Credits
Sunday, Sep 18, 2005, 12:00 AM (Revision 11 - Thursday, Jul 14, 2011, 7:30 PM)
Open Source enables software developers to stand on the shoulders of giants instead of reinventing the wheel, so to speak. Kudos and many thanks to the folks who made their work freely available for reuse in MAJ.

read more
Bugs and Exploits
Friday, Aug 26, 2005, 12:00 AM (Revision 23 - Wednesday, May 29, 2013, 5:25 AM)
Although MAJ started as a family project, care has been taken to make it as "safe" as possible. With more people now working on MAJ, bugs and exploitable code may sometimes slip in. We invite you to poke around and see if you can find any. Generally, there are two things you can do when you find a MAJ or PHP-related bug or exploit:

1. Take advantage of it. But hey, what's so exciting about messing up someone's blog? Ho-hum, right?
2. Report it here so that we can work on a fix and make MAJ better.

read more
Search
Download
MAJ 2.0
75 files
33012 downloads
MAJ 1.0
26 files
13144 downloads
MAJ 0.14
45 files
35026 downloads