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 blob has been accessed 709 times via Git panel.

  1. <?php
  2.  
  3. header("Cache-control: private");
  4.  
  5. error_reporting(E_ERROR);
  6.  
  7.         function stripslashes_array($data) {
  8.                 if (is_array($data)){
  9.                          foreach ($data as $key => $value){
  10.                                   $data[$key] = stripslashes_array($value);
  11.                          }
  12.                          return $data;
  13.                 }
  14.                 else{
  15.                          return stripslashes($data);
  16.                 }
  17.         }
  18.  
  19.         $_REQUEST = stripslashes_array($_REQUEST);
  20. }
  21.  
  22. if (!isset($_REQUEST['entry']) or empty($_REQUEST['entry'])) {
  23.         exit();
  24. }
  25.  
  26. if (!isset($_REQUEST['show']) or empty($_REQUEST['show'])) {
  27.         exit();
  28. }
  29.  
  30. if (!file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
  31.         exit();
  32. }
  33.  
  34. $login_username = file_get_contents("data/username.txt");
  35.  
  36. //if (file_exists("data/items/{$_REQUEST['entry']}/passwd.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username))) {
  37. //      exit();
  38. //}
  39.  
  40. if (isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_POST['edit']) and ($_POST['edit'] == "delete")) {
  41.  
  42.         unlink("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}");
  43.  
  44.         if (file_exists("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt")) {
  45.                 unlink("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt");
  46.         }
  47.  
  48.         if (file_exists("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt")) {
  49.                 unlink("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt");
  50.         }
  51. }
  52.  
  53. if (isset($_POST['filename']) and !empty($_POST['filename']) and isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_POST['edit']) and ($_POST['edit'] == "rename") and !file_exists("images/{$_REQUEST['entry']}/album/{$_POST['filename']}")) {
  54.  
  55.         $filename = strtolower($_POST['filename']);
  56.         $filename = str_replace(" ","_",$filename);
  57.         $filename = trim($filename);
  58.  
  59.         rename("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}","images/{$_REQUEST['entry']}/album/{$filename}");
  60.  
  61.         if (file_exists("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt")) {
  62.                 rename("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt","data/items/{$_REQUEST['entry']}/album/captions/{$filename}.txt");
  63.         }
  64.  
  65.         if (file_exists("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt")) {
  66.                 rename("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt","data/items/{$_REQUEST['entry']}/album/views/{$filename}.txt");
  67.         }
  68. }
  69.  
  70. if ((!isset($_POST['caption']) or empty($_POST['caption'])) and isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_POST['edit']) and ($_POST['edit'] == "caption")) {
  71.  
  72.         if (file_exists("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt")) {
  73.                 unlink("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt");
  74.         }
  75. }
  76.  
  77. if (isset($_POST['caption']) and !empty($_POST['caption']) and isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username) and isset($_POST['edit']) and ($_POST['edit'] == "caption")) {
  78.         $caption_put = ucfirst($_POST['caption']);
  79.         $caption_put = str_replace(':((', '<img src=images/smileys/crying.png border=0>', $caption_put);
  80.         $caption_put = str_replace(':(', '<img src=images/smileys/frown.png border=0>', $caption_put);
  81.         $caption_put = str_replace(':|', '<img src=images/smileys/indifferent.png border=0>', $caption_put);
  82.         $caption_put = str_replace(':D', '<img src=images/smileys/laughing.png border=0>', $caption_put);
  83.         $caption_put = str_replace(':P', '<img src=images/smileys/lick.png border=0>', $caption_put);
  84.         $caption_put = str_replace(':O', '<img src=images/smileys/ohno.png border=0>', $caption_put);
  85.         $caption_put = str_replace(':)', '<img src=images/smileys/smile.png border=0>', $caption_put);
  86.         $caption_put = str_replace('=)', '<img src=images/smileys/surprised.png border=0>', $caption_put);
  87.         $caption_put = str_replace(':\\', '<img src=images/smileys/undecided.png border=0>', $caption_put);
  88.         $caption_put = str_replace(';)', '<img src=images/smileys/wink.png border=0>', $caption_put);
  89.         $caption_put = str_replace('[code]', '<code>', $caption_put);
  90.         $caption_put = str_replace('[/code]', '</code>', $caption_put);
  91.         $caption_put = str_replace("\n", '<br />', $caption_put);
  92.         $caption_put = str_replace('[b]', '<b>', $caption_put);
  93.         $caption_put = str_replace('[/b]', '</b>', $caption_put);
  94.         $caption_put = str_replace('[i]', '<i>', $caption_put);
  95.         $caption_put = str_replace('[/i]', '</i>', $caption_put);
  96.         $caption_put = str_replace('[u]', '<u>', $caption_put);
  97.         $caption_put = str_replace('[/u]', '</u>', $caption_put);
  98.         $caption_put = str_replace('[strike]', '<strike>', $caption_put);
  99.         $caption_put = str_replace('[/strike]', '</strike>', $caption_put);
  100.         $caption_put = str_replace('[sup]', '<sup>', $caption_put);
  101.         $caption_put = str_replace('[/sup]', '</sup>', $caption_put);
  102.         $caption_put = str_replace('[sub]', '<sub>', $caption_put);
  103.         $caption_put = str_replace('[/sub]', '</sub>', $caption_put);
  104.         $caption_put = str_replace('[highlight]', '<highlight>', $caption_put);
  105.         $caption_put = str_replace('[/highlight]', '</highlight>', $caption_put);
  106.         $caption_put = str_replace('<highlight>', '<span style="background-color: #ffff00;">', $caption_put);
  107.         $caption_put = str_replace('</highlight>', '</span>', $caption_put);
  108.  
  109.         if (!file_exists("data/items/{$_REQUEST['entry']}/album")) {
  110.                 mkdir("data/items/{$_REQUEST['entry']}/album");
  111.         }
  112.  
  113.         if (!file_exists("data/items/{$_REQUEST['entry']}/album/captions")) {
  114.                 mkdir("data/items/{$_REQUEST['entry']}/album/captions");
  115.         }
  116.  
  117.         $open_caption_txt_file = fopen("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt","w");
  118.         fwrite($open_caption_txt_file,$caption_put);
  119.         fclose($open_caption_txt_file);
  120. }
  121.  
  122. ?>
  123.  
  124. <style>
  125. body {
  126.         color: #666666;
  127.         margin: 10px;
  128.         padding: 0px;
  129.         text-align: left;
  130.         font-family: <?php
  131.                                 if (file_exists("data/fonts/body.txt")) {
  132.                                         $font_body = file_get_contents("data/fonts/body.txt");
  133.                                         echo "{$font_body},";
  134.                                 }
  135.         ?> arial, helvetica, sans-serif;
  136.         background-color: #FFFFFF;
  137. }
  138.  
  139. p {
  140.         font-size: 11px;
  141. }
  142.  
  143. a {
  144.         font-weight: bold;
  145.         text-decoration: none;
  146. }
  147.  
  148. a:link, a:visited {
  149.         color: #666666;
  150. }
  151.  
  152. a:hover {
  153.         color: #336699;
  154. }
  155.  
  156. a:active {
  157.         color: #336699;
  158. }
  159.  
  160. .input {        
  161.         color: #666666;
  162.         background: #FFFFFF;
  163.         border: #999999 solid 1px;
  164.         width: 100%;
  165.         font-family: <?php
  166.                                 if (file_exists("data/fonts/input.txt")) {
  167.                                         $font_input = file_get_contents("data/fonts/input.txt");
  168.                                         echo "{$font_input},";
  169.                                 }
  170.         ?> arial, helvetica, sans-serif;
  171.         font-size: 11px;
  172. }
  173. </style>
  174.  
  175. <?php
  176.  
  177. if (file_exists("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}")) {
  178.  
  179.         if (!file_exists("data/items/{$_REQUEST['entry']}/album/views")) {
  180.                 mkdir("data/items/{$_REQUEST['entry']}/album/views");
  181.         }
  182.  
  183.         if (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username)) {
  184.                 $fp_image_views_txt = fopen("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt","r");
  185.                 $image_views_value = fread($fp_image_views_txt,filesize("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt"));
  186.                 fclose($fp_image_views_txt);
  187.                 $image_views_value = $image_views_value + 1;
  188.                 $fp_image_views_txt = fopen("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt","w");
  189.                 fwrite($fp_image_views_txt, $image_views_value);
  190.                 fclose($fp_image_views_txt);
  191.         }
  192.  
  193.         echo "<table cellspacing=1 cellpadding=2 border=0 bgcolor=#cccccc>";
  194.  
  195.         echo "<tr bgcolor=#ffffff><td><p align=center><b>{$_REQUEST['show']}</b></p></td><td><p align=center>";
  196.  
  197.         $album_image_size = getimagesize("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}");
  198.         $album_image_width = $album_image_size[0];
  199.         $album_image_height = $album_image_size[1];
  200.  
  201.         echo "$album_image_width x $album_image_height pixels";
  202.  
  203.         $size = filesize("images/{$_REQUEST['entry']}/album/{$_REQUEST['show']}");
  204.         $size_string = ($size > 512)?(  ($size/1024 > 512)  ?sprintf("%.02f MB",($size/1024)/1024)  :sprintf("%.02f KB",$size/1024))  :sprintf("%d B",$size);
  205.         echo "</p></td><td><p align=center>$size_string</p></td><td><p align=center>";
  206.  
  207.         $album_image_views = file_get_contents("data/items/{$_REQUEST['entry']}/album/views/{$_REQUEST['show']}.txt");
  208.         echo "$album_image_views view";
  209.  
  210.         if ($album_image_views > 1) {
  211.                 echo "s";
  212.         }
  213.  
  214.         echo "</p></td></tr>";
  215.  
  216.         echo "<tr bgcolor=#ffffff><td colspan=4>";
  217.         echo "<img src=images/{$_REQUEST['entry']}/album/{$_REQUEST['show']} width=$album_image_width height=$album_image_height border=0>";
  218.         echo "</td></tr>";
  219.         if (isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username)) {
  220.                 echo "<form enctype=\"multipart\/form-data\" action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
  221.                 echo "<input type=hidden name=entry value={$_REQUEST['entry']}>";
  222.                 echo "<input type=hidden name=show value={$_REQUEST['show']}>";
  223.                 echo "<input type=hidden name=edit value=delete>";
  224.                 echo "<tr bgcolor=#ffffff><td colspan=4><input type=submit class=input value=\"click here to delete image\"></td></tr>";
  225.                 echo "</form>";
  226.                 echo "<form enctype=\"multipart\/form-data\" action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
  227.                 echo "<input type=hidden name=entry value={$_REQUEST['entry']}>";
  228.                 echo "<input type=hidden name=show value={$_REQUEST['show']}>";
  229.                 echo "<input type=hidden name=edit value=rename>";
  230.                 echo "<tr bgcolor=#ffffff><td colspan=4><input type=text autocomplete=off class=input name=filename value={$_REQUEST['show']}></td></tr>";
  231.                 echo "<tr bgcolor=#ffffff><td colspan=4><input type=submit class=input value=\"click here to rename image\"></td></tr>";
  232.                 echo "</form>";
  233.                 echo "<form enctype=\"multipart\/form-data\" action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
  234.                 echo "<input type=hidden name=entry value={$_REQUEST['entry']}>";
  235.                 echo "<input type=hidden name=show value={$_REQUEST['show']}>";
  236.                 echo "<input type=hidden name=edit value=caption>";
  237.                 echo "<tr bgcolor=#ffffff><td colspan=4>";
  238.                 echo "<textarea class=input name=caption rows=3>";
  239.                 if (file_exists("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt")) {
  240.                         $caption_get = file_get_contents("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt");
  241.                         $caption_get = str_replace('<br />', "\n", $caption_get);
  242.                         $caption_get = str_replace('<img src=images/smileys/crying.png border=0>', ':((', $caption_get);
  243.                         $caption_get = str_replace('<img src=images/smileys/frown.png border=0>', ':(', $caption_get);
  244.                         $caption_get = str_replace('<img src=images/smileys/indifferent.png border=0>', ':|', $caption_get);
  245.                         $caption_get = str_replace('<img src=images/smileys/laughing.png border=0>', ':D', $caption_get);
  246.                         $caption_get = str_replace('<img src=images/smileys/lick.png border=0>', ':P', $caption_get);
  247.                         $caption_get = str_replace('<img src=images/smileys/ohno.png border=0>', ':O', $caption_get);
  248.                         $caption_get = str_replace('<img src=images/smileys/smile.png border=0>', ':)', $caption_get);
  249.                         $caption_get = str_replace('<img src=images/smileys/surprised.png border=0>', '=)', $caption_get);
  250.                         $caption_get = str_replace('<img src=images/smileys/undecided.png border=0>', ':\\', $caption_get);
  251.                         $caption_get = str_replace('<img src=images/smileys/wink.png border=0>', ';)', $caption_get);
  252.                         $caption_get = str_replace('<span style="background-color: #ffff00;">', '<highlight>', $caption_get);
  253.                         $caption_get = str_replace('</span>', '</highlight>', $caption_get);
  254.                         echo $caption_get;
  255.                 }
  256.                 echo "</textarea>";
  257.                 echo "<input type=submit class=input value=\"click here to update caption\">";
  258.                 echo "</td></tr></form>";
  259.         }
  260.         if (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username)) {
  261.                 if (file_exists("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt")) {
  262.                         echo "<tr bgcolor=#ffffff><td colspan=4 width=$album_image_width><p>";
  263.                         $caption_get = file_get_contents("data/items/{$_REQUEST['entry']}/album/captions/{$_REQUEST['show']}.txt");
  264.                         echo $caption_get;
  265.                         echo "</p></td></tr>";
  266.                 }
  267.         }
  268.  
  269.         echo "</table>";
  270.  
  271. }
  272.  
  273. echo "<p></p>";
  274.  
  275. echo "<table cellspacing=1 cellpadding=2 border=0 bgcolor=#cccccc><tr bgcolor=#ffffff><td width={$album_image_width}><p><b>Album</b></p></td></tr><tr bgcolor=#ffffff><td width={$album_image_width}>";
  276.  
  277. if (file_exists("images/{$_REQUEST['entry']}/thumbnails")) {
  278.         if ($dh_album = opendir("images/{$_REQUEST['entry']}/thumbnails")) {
  279.                 while (($thumbnail_album = readdir($dh_album)) !== false) {
  280.                         if ($thumbnail_album != "." && $thumbnail_album != ".." && fnmatch("*",$thumbnail_album)) {
  281.                                 $current_thumbnail = "images/{$_REQUEST['entry']}/thumbnails/$thumbnail_album";
  282.                                 $parent_image = str_replace("-thumbnail.jpg","",$thumbnail_album);
  283.                                 $parent_image = "images/{$_REQUEST['entry']}/album/$parent_image";
  284.                                 if (file_exists($current_thumbnail) and !file_exists($parent_image)) {
  285.                                         unlink($current_thumbnail);
  286.                                 }
  287.                         }
  288.                 }
  289.         }
  290. }
  291.        
  292.  
  293. if (file_exists("images/{$_REQUEST['entry']}/album")) {
  294.         if ($dh_album = opendir("images/{$_REQUEST['entry']}/album")) {
  295.                 while (($entry_album = readdir($dh_album)) !== false) {
  296.                         if ($entry_album != "." && $entry_album != ".." && fnmatch("*", $entry_album)) {
  297.                                 $sort_album[] = $entry_album;
  298.                         }
  299.                 }
  300.         closedir($dh_album);
  301.         }
  302.        
  303.         sort($sort_album);
  304.         reset($sort_album);
  305.         $count_album_entry = count($sort_album);
  306.                                
  307.         if ($count_album_entry < 1) {
  308.                 rmdirr("images/{$_REQUEST['entry']}/album");
  309.                 rmdirr("images/{$_REQUEST['entry']}/thumbnails");                              
  310.         }
  311.         else {
  312.                 foreach($sort_album as $album_entry) {
  313.                         $current_image = "images/{$_REQUEST['entry']}/album/$album_entry";
  314.                         $current_image_size = getimagesize($current_image);
  315.                         $current_width = $current_image_size[0];
  316.                         $current_height = $current_image_size[1];
  317.                         $max_width = 98;
  318.                         $max_height = 73;
  319.        
  320.                         if (($current_width > $max_width) || ($current_height > $max_height)) {  
  321.  
  322.                                 if ($current_height > $current_width) {
  323.                                         $sizefactor = (double) ($max_height / $current_height);
  324.                                 }
  325.                                 else {
  326.                                         $sizefactor = (double) ($max_width / $current_width) ;
  327.                                 }
  328.  
  329.                                 $new_width = (int) ($current_width * $sizefactor);
  330.                                 $new_height = (int) ($current_height * $sizefactor);
  331.                         }
  332.                         else {
  333.                                 $new_width = $current_width;
  334.                                 $new_height = $current_height;
  335.                         }
  336.  
  337.                         if (!file_exists("images/{$_REQUEST['entry']}/thumbnails/{$album_entry}-thumbnail.jpg")) {
  338.        
  339.                                 $work_thumb = imagecreatetruecolor($new_width,$new_height);
  340.                                 $get_mimetype = image_type_to_mime_type(exif_imagetype($current_image));
  341.  
  342.                                 switch($get_mimetype) {
  343.                                         case "image/jpg":
  344.                                         case "image/jpeg":
  345.                                                 $work_image = imagecreatefromjpeg($current_image);
  346.                                                 break;
  347.                                         case "image/gif":
  348.                                                 $work_image = imagecreatefromgif($current_image);
  349.                                                 break;
  350.                                         case "image/png":
  351.                                                 $work_image = imagecreatefrompng($current_image);
  352.                                                 break;
  353.                                 }
  354.        
  355.                                 imagecopyresampled($work_thumb,$work_image,0,0,0,0,$new_width,$new_height,$current_width,$current_height);
  356.        
  357.                                 if (!file_exists("images/{$_REQUEST['entry']}/thumbnails")) {
  358.                                         mkdir("images/{$_REQUEST['entry']}/thumbnails");
  359.                                 }
  360.        
  361.                                 imagejpeg($work_thumb,"images/{$_REQUEST['entry']}/thumbnails/{$album_entry}-thumbnail.jpg",80);
  362.        
  363.                         }
  364.  
  365.                         echo "<a href=\"album.php?entry={$_REQUEST['entry']}&show=$album_entry\">";
  366.  
  367.                         if (!file_exists("images/{$_REQUEST['entry']}/thumbnails/{$album_entry}-thumbnail.jpg")) {
  368.                                 echo "<img src=\"images/{$_REQUEST['entry']}/album/$album_entry\" width=$new_width height=$new_height border=0 hspace=2 vspace=2";
  369.                         }
  370.                         else {
  371.                                 echo "<img src=\"images/{$_REQUEST['entry']}/thumbnails/{$album_entry}-thumbnail.jpg\" width=$new_width height=$new_height border=0 hspace=2 vspace=2";
  372.                         }
  373.  
  374.                         if (file_exists("data/items/{$_REQUEST['entry']}/album/captions/{$album_entry}.txt")) {
  375.                                 echo ' alt="';
  376.                                 $img_alt = file_get_contents("data/items/{$_REQUEST['entry']}/album/captions/{$album_entry}.txt");
  377.                                 $img_alt = strip_tags($img_alt);
  378.                                 echo $img_alt;
  379.                                 echo '"';
  380.                         }
  381.                         echo "></a>";
  382.                 }
  383.         }
  384. }
  385.  
  386. echo "</td></tr><form method=post action=index.php?entry={$_REQUEST['entry']}&show=album><tr bgcolor=#ffffff><td><input class=input type=submit value=\"click here to go to the main entry\"></td></tr></form><form method=post action=index.php><tr bgcolor=#ffffff><td><input class=input type=submit value=\"click here to go to the index page\"></td></tr></form></table>";
  387.  
  388. ?>
  389.  
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
35387 downloads
MAJ 1.0
26 files
14152 downloads
MAJ 0.14
45 files
36716 downloads