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

commit 7ed2998e3552daf3bec9b8a95fc4300ffb23c933
tree 8279296a1367d3966d3eff768d50d923a1d6a180
parent 3110a34b8a4715bc82b6a9a073efd6e7eaa1ddde
author Engels Antonio <engels@majcms.org> 1277314195 +0800
committer Engels Antonio <engels@majcms.org> 1277314195 +0800

    maj-0.14-20080223-bb.zip

diff --git a/add.php b/add.php
index 6ee193b..98d9acf 100644
--- a/add.php
+++ b/add.php
@@ -651,7 +651,7 @@ if (isset($_FILES['image_input']) and !empty($_FILES['image_input'])) {
                        $entry_image_height = (int) ($entry_image_height * $sizefactor);
                }
       
-               $body_write_content = '<img src=' . $image_dir . '/' . $_FILES['image_input']['name'] . ' border=0 width=' . $entry_image_width . ' height=' . $entry_image_height . '><br>' . $body_write_content;
+               $body_write_content = '<img src="' . $image_dir . '/' . $_FILES['image_input']['name'] . '" border="0" width="' . $entry_image_width . '" height="' . $entry_image_height . '"><br>' . $body_write_content;
        }
 }
 
diff --git a/edit.php b/edit.php
index b6e300f..10c522c 100644
--- a/edit.php
+++ b/edit.php
@@ -766,7 +766,7 @@ if (isset($_FILES['entry_image_input']) and !empty($_FILES['entry_image_input'])
                                                $entry_image_height = (int) ($entry_image_height * $sizefactor);
                                        }
 
-                                       $body_write_content = '<img src=' . $image_path . $_REQUEST['entry'] . '/' . $_FILES['entry_image_input']['name'] . ' border=0 width=' . $entry_image_width . ' height=' . $entry_image_height . '><br>' . $body_write_content;
+                                       $body_write_content = '<img src="' . $image_path . $_REQUEST['entry'] . '/' . $_FILES['entry_image_input']['name'] . '" border="0" width="' . $entry_image_width . '" height="' . $entry_image_height . '"><br>' . $body_write_content;
 
                                }
                                else {
diff --git a/wiki.php b/wiki.php
index 247a752..283aea5 100644
--- a/wiki.php
+++ b/wiki.php
@@ -1,5 +1,7 @@
 <?php
+
 session_start();
+
 header("Cache-control: private");
 
 error_reporting(E_ERROR);
@@ -73,49 +75,6 @@ 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>
@@ -234,6 +193,15 @@ a:active {
        border-width: 0px 1px 1px 1px;
        border-style: none solid solid solid;
 }
+
+ins {
+       background-color: #ccffcc;
+}
+
+del {
+       background-color: #ffbbbb;
+}
+
 </style>
 
 <?php
@@ -276,13 +244,59 @@ 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);
+
+                       $prev = str_replace("<br />","<br>",$prev);
+                       $prev = str_replace("\n"," ",$prev);
+                       $prev = str_replace("\r"," ",$prev);
+                       $prev = preg_replace("/<img[^>]+src[\s='\"]+([^\"'>\s]+)[^>]*>/is","[\\1]",$prev);
+                       $prev = htmlentities($prev,ENT_QUOTES);
+
+                       $body = str_replace("<br />","<br>",$body);
+                       $body = str_replace("\n"," ",$body);
+                       $body = str_replace("\r"," ",$body);
+                       $body = preg_replace("/<img[^>]+src[\s='\"]+([^\"'>\s]+)[^>]*>/is","[\\1]",$body);
+                       $body = htmlentities($body,ENT_QUOTES);
+                      
+                       $prev_array = explode(" ",$prev);
+                       $body_array = explode(" ",$body);
+
+                       if (count($prev_array) <= count($body_array)) {
+                               $elements = count($body_array);
+                       }
+                       else {
+                               $elements = count($prev_array);
+                       }
+
+                       $count = "0";
+
+                       $elements = $elements - 1;
+
+                       $diff = "";
+
+                       while ($count <= $elements) {
+
+                               if ($prev_array[$count] == $body_array[$count]) {
+                                       $diff .= $prev_array[$count] . " ";
+                               }
+                               else {
+                                       $diff .= "<del>" . $prev_array[$count] . "</del> <ins>" . $body_array[$count] . " </ins> ";
+                               }
+
+                               $count = $count + 1;
+                       }
+
+                       $diff = str_replace("&lt;br&gt;","<br>",$diff);        
+                       $diff = trim($diff);
 
                        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>$diff</div>";
                        echo "<div id=panel_footer>Edited by $editor last $mod</div>";
                        echo "</td></tr></table></p>";
+
+                       unset($diff);
+                       unset($body);
+                       unset($prev);
                }
        }
 }
 
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