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

commit 355df227986be7bfeaceb1907d29824304e73a62
tree 3b25d71e84166b4c17ba58647dddda0c79ff6853
parent 03c46636ebc8009045987886bb5ccd167b7dd1cc
author Engels Antonio <engels@majcms.org> 1277314210 +0800
committer Engels Antonio <engels@majcms.org> 1277314210 +0800

    maj-1.0-20090211-bb.zip

diff --git a/add.php b/add.php
index 65eb3de..6f36741 100644
--- a/add.php
+++ b/add.php
@@ -70,7 +70,7 @@ body {
        font-family: <?php
                                if (file_exists("data/fonts/body.txt")) {
                                        $font_body = file_get_contents("data/fonts/body.txt");
-                                       echo "{$font_body},";
+                                       echo "$font_body,";
                                }
        ?> arial, helvetica, sans-serif;
        background-color: #FFFFFF;
@@ -105,7 +105,7 @@ a:active {
        font-family: <?php
                                if (file_exists("data/fonts/panel-title.txt")) {
                                        $font_panel_title = file_get_contents("data/fonts/panel-title.txt");
-                                       echo "{$font_panel_title},";
+                                       echo "$font_panel_title,";
                                }
        ?> arial, helvetica, sans-serif;
        font-size: 11px;
@@ -120,7 +120,7 @@ a:active {
        font-family: <?php
                                if (file_exists("data/fonts/panel-body.txt")) {
                                        $font_panel_body = file_get_contents("data/fonts/panel-body.txt");
-                                       echo "{$font_panel_body},";
+                                       echo "$font_panel_body,";
                                }
        ?> arial, helvetica, sans-serif;
        font-size: 11px
@@ -144,8 +144,37 @@ $entry_hour = date("H", time() + $offset);
 $entry_min = date("i", time() + $offset);
 $entry_sec = date("s", time() + $offset);
 
-$max_image_size = 8000000;
-$max_file_size = 8000000;
+function return_bytes($val) {
+       $val = trim($val);
+       $last = $val{strlen($val)-1};
+    
+       switch($last) {
+               case 'k':
+               case 'K':
+                       return (int) $val * 1024;
+                       break;
+               case 'm':
+               case 'M':
+                       return (int) $val * 1048576;
+                       break;
+               default:
+                       return $val;
+       }
+}
+
+$server_upload_max_filesize = return_bytes(ini_get('upload_max_filesize'));
+$server_post_max_size = return_bytes(ini_get('post_max_size'));
+$server_memory_limit = return_bytes(ini_get('memory_limit'));
+
+$max_file_size = $server_upload_max_filesize;
+
+if ($server_upload_max_filesize > $server_post_max_size) {
+       $max_file_size = $server_post_max_size;
+}
+
+if ($server_post_max_size > $server_memory_limit) {
+       $max_file_size = $server_memory_limit;
+}
 
 ?>
 
@@ -156,7 +185,7 @@ $max_file_size = 8000000;
 
 if ($_SESSION['logged_in'] != file_get_contents("data/username.txt") and file_exists("data/members/active/{$_SESSION['logged_in']}") and file_exists("data/members/active/{$_SESSION['logged_in']}/ul.txt")) { ?>
 
-<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_image_size; ?>">
+<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
 <input autocomplete="off" type="file" name="image_input"> Select optional image.</p>
 
 <p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
@@ -333,7 +362,7 @@ if ($_SESSION['logged_in'] == file_get_contents("data/username.txt")) {
 <option>59
 </select>   Enter antedate value in YYYY-MM-DD-HH-MM format.</p>
 
-<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_image_size; ?>">
+<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
 <input autocomplete="off" type="file" name="image_input"> Select optional image.</p>
 
 <p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
@@ -573,7 +602,7 @@ if (isset($_FILES['image_input']) and !empty($_FILES['image_input'])) {
 
        if (is_uploaded_file($_FILES['image_input']['tmp_name'])) {
 
-               if ($_FILES['image_input']['size']<=$max_image_size) {
+               if ($_FILES['image_input']['size']<=$max_file_size) {
 
                        if (($_FILES['image_input']['type']=="image/gif") || ($_FILES['image_input']['type']=="image/pjpeg") || ($_FILES['image_input']['type']=="image/jpeg") || ($_FILES['image_input']['type']=="image/png")) {
 
diff --git a/edit.php b/edit.php
index eb4c29b..1aab751 100644
--- a/edit.php
+++ b/edit.php
@@ -103,8 +103,37 @@ $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;
+function return_bytes($val) {
+       $val = trim($val);
+       $last = $val{strlen($val)-1};
+    
+       switch($last) {
+               case 'k':
+               case 'K':
+                       return (int) $val * 1024;
+                       break;
+               case 'm':
+               case 'M':
+                       return (int) $val * 1048576;
+                       break;
+               default:
+                       return $val;
+       }
+}
+
+$server_upload_max_filesize = return_bytes(ini_get('upload_max_filesize'));
+$server_post_max_size = return_bytes(ini_get('post_max_size'));
+$server_memory_limit = return_bytes(ini_get('memory_limit'));
+
+$max_file_size = $server_upload_max_filesize;
+
+if ($server_upload_max_filesize > $server_post_max_size) {
+       $max_file_size = $server_post_max_size;
+}
+
+if ($server_post_max_size > $server_memory_limit) {
+       $max_file_size = $server_memory_limit;
+}
 
 ?>
 
@@ -397,7 +426,7 @@ if (file_exists($revisions_file)) {
 
 <?php if (($_SESSION['logged_in'] == $login_username) or (file_exists("data/members/active/{$_SESSION['logged_in']}/ul.txt") and file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt"))) { ?>
 
-<input type="hidden" name="max_file_size" value="<?php echo $max_image_size; ?>">
+<input type="hidden" name="max_file_size" value="<?php echo $max_file_size; ?>">
 
 <p><table border="0" cellspacing="2" cellpadding="0" bgcolor="#ffffff">
 
@@ -746,7 +775,7 @@ if (isset($_FILES['album_image_input']) and !empty($_FILES['album_image_input'])
 
        if (is_uploaded_file($_FILES['album_image_input']['tmp_name'])) {
 
-               if ($_FILES['album_image_input']['size']<=$max_image_size) {
+               if ($_FILES['album_image_input']['size']<=$max_file_size) {
 
                        if (($_FILES['album_image_input']['type']=="image/gif") || ($_FILES['album_image_input']['type']=="image/pjpeg") || ($_FILES['album_image_input']['type']=="image/jpeg") || ($_FILES['album_image_input']['type']=="image/png")) {
 
@@ -842,7 +871,7 @@ if (isset($_FILES['entry_image_input']) and !empty($_FILES['entry_image_input'])
 
        if (is_uploaded_file($_FILES['entry_image_input']['tmp_name'])) {
 
-               if ($_FILES['entry_image_input']['size']<=$max_image_size) {
+               if ($_FILES['entry_image_input']['size']<=$max_file_size) {
 
                        if (($_FILES['entry_image_input']['type']=="image/gif") || ($_FILES['entry_image_input']['type']=="image/pjpeg") || ($_FILES['entry_image_input']['type']=="image/jpeg") || ($_FILES['entry_image_input']['type']=="image/png")) {
 
diff --git a/reg.php b/reg.php
index 1ea3735..be845a0 100644
--- a/reg.php
+++ b/reg.php
@@ -95,7 +95,7 @@ a:active {
        font-family: <?php
                                if (file_exists("data/fonts/input.txt")) {
                                        $font_input = file_get_contents("data/fonts/input.txt");
-                                       echo "{$font_input},";
+                                       echo "$font_input,";
                                }
        ?> arial, helvetica, sans-serif;
        font-size: 11px;
@@ -110,7 +110,7 @@ a:active {
        font-family: <?php
                                if (file_exists("data/fonts/input.txt")) {
                                        $font_input = file_get_contents("data/fonts/input.txt");
-                                       echo "{$font_input},";
+                                       echo "$font_input,";
                                }
        ?> arial, helvetica, sans-serif;
        font-size: 11px;
@@ -159,7 +159,7 @@ function rmdirr($recurse_dirname) {
     return rmdir($recurse_dirname);
 }
 
-if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_REQUEST['key']) and !empty($_REQUEST['key']) and isset($_REQUEST['action']) and !empty($_REQUEST['action'])) {
+if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_REQUEST['key']) and !empty($_REQUEST['key']) and isset($_REQUEST['action']) and !empty($_REQUEST['action']) and ereg('^[^./][^/]*$', $_REQUEST['username'])) {
 
        $username = $_REQUEST['username'];
 
@@ -239,7 +239,7 @@ if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_R
        exit();
 }
 
-if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_REQUEST['key']) and !empty($_REQUEST['key'])) {
+if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_REQUEST['key']) and !empty($_REQUEST['key']) and ereg('^[^./][^/]*$', $_REQUEST['username'])) {
 
        $username = $_REQUEST['username'];
 
@@ -361,7 +361,7 @@ if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and isset($_R
        exit();
 }
 
-if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and ($_REQUEST['username'] != "all") and isset($_POST['captcha_put']) and !empty($_POST['captcha_get']) and isset($_POST['firstname']) and !empty($_POST['firstname']) and isset($_POST['lastname']) and !empty($_POST['lastname']) and isset($_POST['email']) and !empty($_POST['email']) and isset($_POST['captcha_put']) and !empty($_POST['captcha_put']) and ($_POST['captcha_get'] == $_POST['captcha_put']) and (ereg("@", $_POST['email'])) and (ereg("\.", $_POST['email'])) and (strpos(file_get_contents("data/bb-reserved.txt"), $_REQUEST['username']) === false) and isset($_POST['bd_year']) and !empty($_POST['bd_year']) and isset($_POST['bd_month']) and !empty($_POST['bd_month']) and isset($_POST['bd_day']) and !empty($_POST['bd_day']) and (strlen($_POST['bd_year']) == "4") and (strlen($_POST['bd_month']) == "2") and (strlen($_POST['bd_day']) == "2") and is_numeric($_POST['bd_year']) and is_numeric($_POST['bd_month']) and is_numeric($_POST['bd_day']) and ((date("Y", time() + $offset) - $_POST['bd_year']) <= $maxage) and ((date("Y", time() + $offset) - $_POST['bd_year']) >= $minage) and ($_POST['bd_month'] >= 1) and ($_POST['bd_month'] <= 12) and ($_POST['bd_day'] >= 1) and ($_POST['bd_day'] <= 31) and isset($_POST['country']) and !empty($_POST['country']) and isset($_POST['city']) and !empty($_POST['city'])) {
+if (isset($_REQUEST['username']) and !empty($_REQUEST['username']) and ($_REQUEST['username'] != "all") and isset($_POST['captcha_put']) and !empty($_POST['captcha_get']) and isset($_POST['firstname']) and !empty($_POST['firstname']) and isset($_POST['lastname']) and !empty($_POST['lastname']) and isset($_POST['email']) and !empty($_POST['email']) and isset($_POST['captcha_put']) and !empty($_POST['captcha_put']) and ($_POST['captcha_get'] == $_POST['captcha_put']) and (ereg("@", $_POST['email'])) and (ereg("\.", $_POST['email'])) and (strpos(file_get_contents("data/bb-reserved.txt"), $_REQUEST['username']) === false) and isset($_POST['bd_year']) and !empty($_POST['bd_year']) and isset($_POST['bd_month']) and !empty($_POST['bd_month']) and isset($_POST['bd_day']) and !empty($_POST['bd_day']) and (strlen($_POST['bd_year']) == "4") and (strlen($_POST['bd_month']) == "2") and (strlen($_POST['bd_day']) == "2") and is_numeric($_POST['bd_year']) and is_numeric($_POST['bd_month']) and is_numeric($_POST['bd_day']) and ((date("Y", time() + $offset) - $_POST['bd_year']) <= $maxage) and ((date("Y", time() + $offset) - $_POST['bd_year']) >= $minage) and ($_POST['bd_month'] >= 1) and ($_POST['bd_month'] <= 12) and ($_POST['bd_day'] >= 1) and ($_POST['bd_day'] <= 31) and isset($_POST['country']) and !empty($_POST['country']) and isset($_POST['city']) and !empty($_POST['city']) and ereg('^[^./][^/]*$', $_REQUEST['username'])) {
 
        $username = strtolower($_REQUEST['username']);
        $username = str_replace(" ","_",$username);
diff --git a/rel.txt b/rel.txt
index 8b28649..d80faf4 100644
--- a/rel.txt
+++ b/rel.txt
@@ -1 +1 @@
-20090210
\ No newline at end of file
+20090211
\ 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
33164 downloads
MAJ 1.0
26 files
13196 downloads
MAJ 0.14
45 files
35116 downloads