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 805 times via Git panel.

commit 1e1fc96dc01690f1251519ed7d74c2767e7d6d95
tree a9477f13ccfd0fdf98ca512f73b865970270051b
parent a0577241d7eb702022d0d8bbee6a2b937bc92a91
author Engels Antonio <engels@majcms.org> 1277314193 +0800
committer Engels Antonio <engels@majcms.org> 1277314193 +0800

    maj-0.14-20071219-bb.zip

diff --git a/edit.php b/edit.php
index b75e7c5..ded4662 100644
--- a/edit.php
+++ b/edit.php
@@ -45,7 +45,7 @@ if ($_SESSION['logged_in'] == $login_username) {
 }
 
 
-if (file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt") and file_exists("data/wiki.txt") and file_exists("data/items/{$_REQUEST['entry']}/edit.txt")) {
+if (file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt") and file_exists("data/wiki.txt") and (file_exists("data/items/{$_REQUEST['entry']}/edit.txt") or (file_get_contents("data/items/{$_REQUEST['entry']}/author.txt") == $_SESSION['logged_in']))) {
        $do = 1;
 }
 
@@ -848,7 +848,12 @@ if (file_exists("data/wiki.txt") and (($title_get_content != file_get_contents("
                mkdir("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate");
        }
 
-       copy("data/items/{$_REQUEST['entry']}/body.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/body.txt");
+
+       $new = fopen("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/body.txt","w");
+       fwrite($new,$body_write_content);
+       fclose($new);
+
+       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");
        copy("data/items/{$_REQUEST['entry']}/title.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/title.txt");
 
@@ -870,7 +875,7 @@ fclose($open_body_file);
 
 // start of wiki mod (20071130)
 
-if (file_exists("data/wiki.txt") and file_exists("data/items/{$_REQUEST['entry']}/edit.txt")) {
+if (file_exists("data/wiki.txt") and (file_exists("data/items/{$_REQUEST['entry']}/edit.txt") or (file_get_contents("data/items/{$_REQUEST['entry']}/author.txt") == $_SESSION['logged_in']))) {
        $open_contrib_file = fopen("data/items/{$_REQUEST['entry']}/contrib.txt","w");
        fwrite($open_contrib_file,$_SESSION['logged_in']);
        fclose($open_contrib_file);
diff --git a/index.php b/index.php
index 8d3154b..27798e8 100644
--- a/index.php
+++ b/index.php
@@ -1797,7 +1797,7 @@ foreach ($disp as $d) {
 
        // start of wiki mod (20071130)
 
-       if (isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] != $login_username) and file_exists("data/members/active/{$_SESSION['logged_in']}") and file_exists("data/wiki.txt") and file_exists("$dir/$d/edit.txt") and file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt") and !file_exists("$dir/$d/passwd.txt")) {
+       if (isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] != $login_username) and file_exists("data/members/active/{$_SESSION['logged_in']}") and file_exists("data/wiki.txt") and (file_exists("$dir/$d/edit.txt") or (file_get_contents("$dir/$d/author.txt") == $_SESSION['logged_in'])) and file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt") and !file_exists("$dir/$d/passwd.txt")) {
 
                if (file_exists("$dir/$d/wiki/delta") and (count(glob("$dir/$d/wiki/delta/*")) > 0)) {
                        echo "<a href=wiki.php?entry=$d>";
diff --git a/wiki.php b/wiki.php
index 8b41e7c..247a752 100644
--- a/wiki.php
+++ b/wiki.php
@@ -41,7 +41,7 @@ if ($_SESSION['logged_in'] == $login_username) {
 }
 
 
-if (file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt") and file_exists("data/wiki.txt") and file_exists("data/items/{$_REQUEST['entry']}/edit.txt")) {
+if (file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt") and file_exists("data/wiki.txt") and (file_exists("data/items/{$_REQUEST['entry']}/edit.txt") or (file_get_contents("data/items/{$_REQUEST['entry']}/author.txt") == $_SESSION['logged_in']))) {
        $do = 1;
 }
 
@@ -73,6 +73,49 @@ function rmdirr($recurse_dirname) {
     return rmdir($recurse_dirname);
 }
 
+/*
+
+start of diff mod (20071219)
+
+Simple Diff Algorithm v 0.1
+(C) Paul Butler 2007 <http://www.paulbutler.org/>
+
+*/
+
+
+function diff($old, $new){
+       foreach($old as $oindex => $ovalue){
+               $nkeys = array_keys($new, $ovalue);
+               foreach($nkeys as $nindex){
+                       $matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1]) ?
+                               $matrix[$oindex - 1][$nindex - 1] + 1 : 1;
+                       if($matrix[$oindex][$nindex] > $maxlen){
+                               $maxlen = $matrix[$oindex][$nindex];
+                               $omax = $oindex + 1 - $maxlen;
+                               $nmax = $nindex + 1 - $maxlen;
+                       }
+               }      
+       }
+       if($maxlen == 0) return array(array('d'=>$old, 'i'=>$new));
+       return array_merge(
+               diff(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)),
+               array_slice($new, $nmax, $maxlen),
+               diff(array_slice($old, $omax + $maxlen), array_slice($new, $nmax + $maxlen)));
+}
+
+function htmlDiff($old, $new){
+       $diff = diff(explode(' ', $old), explode(' ', $new));
+       foreach($diff as $k){
+               if(is_array($k))
+                       $ret .= (!empty($k['d'])?"<del>".implode(' ',$k['d'])."</del> ":'').
+                               (!empty($k['i'])?"<ins>".implode(' ',$k['i'])."</ins> ":'');
+               else $ret .= $k . ' ';
+       }
+       return $ret;
+}
+
+// end of diff mod (20071219)
+
 ?>
 
 <style>
@@ -209,7 +252,7 @@ if (file_exists("data/items/$entry/wiki/delta")) {
                }
                closedir($dh_delta);
        }
-       sort($show_delta);
+       rsort($show_delta);
        reset($show_delta);
        $count_delta = count($show_delta);
 
@@ -232,9 +275,12 @@ if (file_exists("data/items/$entry/wiki/delta")) {
 
                        $mod = date("l, M j, g:i A", mktime($itemHour,$itemMinute,$itemSecond,$itemMonth,$itemDay,$itemYear));
 
+                       $prev = file_get_contents("data/items/$entry/wiki/delta/$item/prev.txt");
+                       $diff = htmlDiff($prev,$body);
+
                        echo "<p><table border=0 cellspacing=0 cellpadding=0 bgcolor=#CCCCCC><tr><td width=525>";
                        echo "<div id=panel_title>$title</div>";
-                       echo "<div id=panel_body><font style=\"font-size: 10px; color: #999999;\">$author - $date<br><br></font>$body</div>";
+                       echo "<div id=panel_body><font style=\"font-size: 10px; color: #999999;\">$author - $date<br><br></font>$diff</div>";
                        echo "<div id=panel_footer>Edited by $editor last $mod</div>";
                        echo "</td></tr></table></p>";
                }
 
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
33087 downloads
MAJ 1.0
26 files
13170 downloads
MAJ 0.14
45 files
35071 downloads