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

  1. <?php
  2.  
  3.   require("core.php");
  4.  
  5.   if (isset($_POST['title_input']) and isset($_POST['body_input'])) {
  6.       header("Location: edit.php?entry=$maj_req_entry");
  7.   }
  8.  
  9.   if (!isset($maj_req_entry)) {
  10.       exit();
  11.   }
  12.  
  13.   if (!file_exists("$maj_data_directory/items/$maj_req_entry")) {
  14.       exit();
  15.   }
  16.  
  17.   if (!isset($maj_logged_in_username)) {
  18.       exit();
  19.   }
  20.  
  21.   $do = 0;
  22.  
  23.   if (file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-rw.txt") and file_exists("$maj_data_directory/wiki.txt") and (file_exists("$maj_data_directory/items/$maj_req_entry/edit.txt") or (file_get_contents("$maj_data_directory/items/$maj_req_entry/author.txt") == $maj_logged_in_username))) {
  24.       $do = 1;
  25.   }
  26.  
  27.   if (file_exists("$maj_data_directory/items/$maj_req_entry/lock.txt")) {
  28.       $do = 0;
  29.   }
  30.  
  31.   if ($maj_logged_in_username == $maj_admin_username) {
  32.       $do = 1;
  33.   }
  34.  
  35.   if ($do == 0) {
  36.       exit();
  37.   }
  38.  
  39.   $title_file = "$maj_data_directory/items/$maj_req_entry/title.txt";
  40.   $body_file = "$maj_data_directory/items/$maj_req_entry/body.txt";
  41.   $date_file = "$maj_data_directory/items/$maj_req_entry/date.txt";
  42.   $img_file = "$maj_data_directory/items/$maj_req_entry/image.txt";
  43.   $revisions_file = "$maj_data_directory/items/$maj_req_entry/revisions.txt";
  44.  
  45.   include("css.php");
  46.  
  47.   echo "\n<style>body { margin: {$maj_wspace}px; } .input, .click { width: 520px; }</style>\n";
  48.    
  49. ?>
  50.  
  51. <title>Edit</title>
  52.  
  53. <?php
  54.   if (isset($_POST['auth_member']) and !empty($_POST['auth_member']) and isset($_POST['auth_toggle']) and !empty($_POST['auth_toggle'])) {
  55.       if (($_POST['auth_toggle'] == "ack") and file_exists("$maj_data_directory/members/active/{$_POST['auth_member']}")) {
  56.           if (!file_exists("$maj_data_directory/items/$maj_req_entry/members")) {
  57.               mkdir("$maj_data_directory/items/$maj_req_entry/members");
  58.           }
  59.          
  60.           if (!file_exists("$maj_data_directory/items/$maj_req_entry/members/{$_POST['auth_member']}")) {
  61.               mkdir("$maj_data_directory/items/$maj_req_entry/members/{$_POST['auth_member']}");
  62.           }
  63.          
  64.           if (!file_exists("$maj_data_directory/items/$maj_req_entry/imembers")) {
  65.               mkdir("$maj_data_directory/items/$maj_req_entry/imembers");
  66.           }
  67.          
  68.           if (!file_exists("$maj_data_directory/items/$maj_req_entry/imembers/{$_POST['auth_member']}")) {
  69.               mkdir("$maj_data_directory/items/$maj_req_entry/imembers/{$_POST['auth_member']}");
  70.           }
  71.       }
  72.      
  73.       if (($_POST['auth_toggle'] == "nak") and file_exists("$maj_data_directory/members/active/{$_POST['auth_member']}")) {
  74.           if (file_exists("$maj_data_directory/items/$maj_req_entry/members/{$_POST['auth_member']}")) {
  75.               rmdirr("$maj_data_directory/items/$maj_req_entry/members/{$_POST['auth_member']}");
  76.           }
  77.          
  78.           if (file_exists("$maj_data_directory/items/$maj_req_entry/imembers/{$_POST['auth_member']}")) {
  79.               rmdirr("$maj_data_directory/items/$maj_req_entry/imembers/{$_POST['auth_member']}");
  80.           }
  81.       }
  82.   }
  83.  
  84.   if (isset($maj_req_category) and !empty($maj_req_category)) {
  85.       if (file_exists("$maj_data_directory/categories/$maj_req_category/members")) {
  86.           if ($dh_cat_members = opendir("$maj_data_directory/categories/$maj_req_category/members")) {
  87.               while (($get_cat_member = readdir($dh_cat_members)) !== false) {
  88.                   if ($get_cat_member != "." && $get_cat_member != "..") {
  89.                       if (file_exists("$maj_data_directory/members/active/$get_cat_member")) {
  90.                           $get_cat_members[] = $get_cat_member;
  91.                       } else {
  92.                           rmdirr("$maj_data_directory/categories/$maj_req_category/members/$get_cat_member");
  93.                       }
  94.                   }
  95.               }
  96.               closedir($dh_cat_members);
  97.           }
  98.       }
  99.      
  100.       if (($_POST['do'] == "unfile") and file_exists("$maj_data_directory/items/$maj_req_entry/categories/$maj_req_category")) {
  101.           rmdirr("$maj_data_directory/items/$maj_req_entry/categories/$maj_req_category");
  102.          
  103.           if (count(glob("$maj_data_directory/items/$maj_req_entry/categories/*")) < 1) {
  104.               rmdirr("$maj_data_directory/items/$maj_req_entry/categories");
  105.           }
  106.          
  107.           if (file_exists("$maj_data_directory/categories")) {
  108.               if ($dh_get_categories = opendir("$maj_data_directory/categories")) {
  109.                   while (($get_category = readdir($dh_get_categories)) !== false) {
  110.                       if ($get_category != "." && $get_category != "..") {
  111.                           $get_categories[] = $get_category;
  112.                       }
  113.                   }
  114.                   closedir($dh_get_categories);
  115.               }
  116.              
  117.               foreach ($get_cat_members as $get_cat_mem) {
  118.                   $count_mem = 0;
  119.                  
  120.                   foreach ($get_categories as $get_category) {
  121.                       if (file_exists("$maj_data_directory/categories/$get_category/members/$get_cat_mem") and ($maj_req_category != $get_category) and file_exists("$maj_data_directory/items/$maj_req_entry/categories/$get_category")) {
  122.                           $count_mem = $count_mem + 1;
  123.                       }
  124.                   }
  125.                  
  126.                   if (($count_mem < 1) and !file_exists("$maj_data_directory/items/$maj_req_entry/imembers/$get_cat_mem")) {
  127.                       rmdirr("$maj_data_directory/items/$maj_req_entry/members/$get_cat_mem");
  128.                   }
  129.               }
  130.           }
  131.       }
  132.      
  133.       if (($_POST['do'] == "file") and !file_exists("$maj_data_directory/items/$maj_req_entry/categories/$maj_req_category")) {
  134.           if (!file_exists("$maj_data_directory/items/$maj_req_entry/categories")) {
  135.               mkdir("$maj_data_directory/items/$maj_req_entry/categories");
  136.           }
  137.          
  138.           mkdir("$maj_data_directory/items/$maj_req_entry/categories/$maj_req_category");
  139.          
  140.           foreach ($get_cat_members as $get_cat_mem) {
  141.               if (!file_exists("$maj_data_directory/items/$maj_req_entry/members/$get_cat_mem")) {
  142.                   mkdir("$maj_data_directory/items/$maj_req_entry/members/$get_cat_mem");
  143.               }
  144.           }
  145.       }
  146.   }
  147.  
  148.   if (isset($_REQUEST['comment']) and !empty($_REQUEST['comment']) and isset($_POST['comment_txt']) and !empty($_POST['comment_txt']) and isset($_REQUEST['type']) and !empty($_REQUEST['type']) and (($_REQUEST['type'] == "live") or ($_REQUEST['type'] == "pending"))) {
  149.       $comment_txt = ucfirst($_POST['comment_txt']);
  150.       $comment_txt = str_replace("\n", '<br />', $comment_txt);
  151.       $comment_txt = str_replace(':((', '<img src="images/smileys/crying.png" border="0">', $comment_txt);
  152.       $comment_txt = str_replace(':(', '<img src="images/smileys/frown.png" border="0">', $comment_txt);
  153.       $comment_txt = str_replace(':|', '<img src="images/smileys/indifferent.png" border="0">', $comment_txt);
  154.       $comment_txt = str_replace(':D', '<img src="images/smileys/laughing.png" border="0">', $comment_txt);
  155.       $comment_txt = str_replace(':P', '<img src="images/smileys/lick.png" border="0">', $comment_txt);
  156.       $comment_txt = str_replace(':O', '<img src="images/smileys/ohno.png" border="0">', $comment_txt);
  157.       $comment_txt = str_replace(':)', '<img src="images/smileys/smile.png" border="0">', $comment_txt);
  158.       $comment_txt = str_replace('=)', '<img src="images/smileys/surprised.png" border="0">', $comment_txt);
  159.       $comment_txt = str_replace(':\\', '<img src="images/smileys/undecided.png" border="0">', $comment_txt);
  160.       $comment_txt = str_replace(';)', '<img src="images/smileys/wink.png" border="0">', $comment_txt);
  161.       $comment_txt_file = "$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/comment.txt";
  162.       $open_comment_txt_file = fopen($comment_txt_file, "w");
  163.       fwrite($open_comment_txt_file, $comment_txt);
  164.       fclose($open_comment_txt_file);
  165.      
  166.       $comment_revisions_file = "$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/revisions.txt";
  167.       $fp_comment_revisions_file = fopen($comment_revisions_file, "r");
  168.       $comment_revisions_count = fread($fp_comment_revisions_file, filesize($comment_revisions_file));
  169.       fclose($fp_comment_revisions_file);
  170.      
  171.       $comment_revisions_count = $comment_revisions_count + 1;
  172.       $fp_comment_revisions_file = fopen($comment_revisions_file, "w");
  173.       fwrite($fp_comment_revisions_file, $comment_revisions_count);
  174.       fclose($fp_comment_revisions_file);
  175.   }
  176.  
  177.   if (isset($_REQUEST['comment']) and !empty($_REQUEST['comment']) and isset($_REQUEST['type']) and !empty($_REQUEST['type']) and (($_REQUEST['type'] == "live") or ($_REQUEST['type'] == "pending"))) {
  178.       if (!file_exists("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}")) {
  179.           exit();
  180.       }
  181. ?>
  182.   <table border="0" cellspacing="0" cellpadding="0"><tr><td width="520">
  183.   <div class="panel_title"><?php
  184.       readfile("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/firstname.txt");
  185. ?>&nbsp;<?php
  186.       readfile("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/lastname.txt");
  187. ?>&nbsp;&lt;<?php
  188.       readfile("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/email.txt");
  189. ?>&gt;</div>
  190.   <div class="panel_body"><?php
  191.  
  192.   echo "<font style=\"font-size: $maj_font_Spx; color: #999999;\">";
  193.  
  194.   if (file_exists("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/author.txt")) {
  195.       readfile("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/author.txt");
  196.       echo " - ";
  197.   }
  198.  
  199.   entry2date($_REQUEST['comment']);
  200.  
  201.   if (file_exists($revisions_file)) {
  202.       echo ' (Revision ';
  203.       readfile("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/revisions.txt");
  204.       echo " - ";
  205.       echo date("l, M j, Y, g:i A", filemtime("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/comment.txt"));
  206.       echo ')';
  207.   }
  208.  
  209.   echo "</font><div style=\"height: {$maj_wspace}px;\"></div>";  
  210.  
  211.       readfile("$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/comment.txt");
  212. ?></div>
  213.  
  214.   </td></tr></table>
  215.  
  216.   <table border="0" cellspacing="2" cellpadding="0">
  217.   <form enctype="multipart/form-data" action="edit.php" method="post">
  218.   <tr><td><textarea class="input" name="comment_txt" rows="10"><?php
  219.       $comment_txt_file = "$maj_data_directory/items/$maj_req_entry/comments/{$_REQUEST['type']}/{$_REQUEST['comment']}/comment.txt";
  220.       $open_comment_txt_file = fopen($comment_txt_file, "r");
  221.       $read_comment_txt_file = fread($open_comment_txt_file, filesize($comment_txt_file));
  222.       fclose($open_comment_txt_file);
  223.      
  224.       $comment_smiley2emoticon = str_replace('<br />', "\n", $read_comment_txt_file);
  225.       $comment_smiley2emoticon = str_replace('<img src="images/smileys/crying.png" border="0">', ':((', $comment_smiley2emoticon);
  226.       $comment_smiley2emoticon = str_replace('<img src="images/smileys/frown.png" border="0">', ':(', $comment_smiley2emoticon);
  227.       $comment_smiley2emoticon = str_replace('<img src="images/smileys/indifferent.png" border="0">', ':|', $comment_smiley2emoticon);
  228.       $comment_smiley2emoticon = str_replace('<img src="images/smileys/laughing.png" border="0">', ':D', $comment_smiley2emoticon);
  229.       $comment_smiley2emoticon = str_replace('<img src="images/smileys/lick.png" border="0">', ':P', $comment_smiley2emoticon);
  230.       $comment_smiley2emoticon = str_replace('<img src="images/smileys/ohno.png" border="0">', ':O', $comment_smiley2emoticon);
  231.       $comment_smiley2emoticon = str_replace('<img src="images/smileys/smile.png" border="0">', ':)', $comment_smiley2emoticon);
  232.       $comment_smiley2emoticon = str_replace('<img src="images/smileys/surprised.png" border="0">', '=)', $comment_smiley2emoticon);
  233.       $comment_smiley2emoticon = str_replace('<img src="images/smileys/undecided.png" border="0">', ':\\', $comment_smiley2emoticon);
  234.       $comment_smiley2emoticon = str_replace('<img src="images/smileys/wink.png" border="0">', ';)', $comment_smiley2emoticon);
  235.      
  236.       echo $comment_smiley2emoticon;
  237. ?></textarea></td></tr>
  238.   <tr><td><input type="hidden" name="entry" value="<?php
  239.       echo $maj_req_entry;
  240. ?>"></td></tr>
  241.   <tr><td><input type="hidden" name="comment" value="<?php
  242.       echo $_REQUEST['comment'];
  243. ?>"></td></tr>
  244.   <tr><td><input type="hidden" name="type" value="<?php
  245.       echo $_REQUEST['type'];
  246. ?>"></td></tr>
  247.   <tr><td><input class="click" type="submit" value="click here to update this comment"></td></tr>
  248.   </form>
  249.  
  250.   <form enctype="multipart/form-data" action="index.php?entry=<?php
  251.       echo $maj_req_entry;
  252. ?>&show=comments" method="post">
  253.   <tr><td><input class="click" type="submit" value="click here to view posted entry"></td></tr>
  254.   </form>
  255.  
  256.   <form enctype="multipart/form-data" action="index.php" method="post">
  257.   <tr><td><input class="click" type="submit" value="click here to go to the index page"></td></tr>
  258.   </form>
  259.   </table>
  260.  
  261. <?php
  262.       exit();
  263.   }
  264. ?>
  265.  
  266. <table border="0" cellspacing="0" cellpadding="0">
  267.  
  268. <tr><td valign="top">
  269.  
  270. <table border="0" cellspacing="0" cellpadding="0"><tr><td width="520">
  271.  
  272. <div class="panel_wrapper">
  273.  
  274. <div class="panel_title"><?php
  275.   readfile($title_file);
  276. ?></div>
  277. <div class="panel_body"><table border="0" cellspacing="0" cellpadding="0"><tr><td><?php
  278.  
  279.   echo "<font style=\"font-size: $maj_font_Spx; color: #999999;\">";
  280.  
  281.   if (file_exists("$maj_data_directory/items/$maj_req_entry/author.txt")) {
  282.       readfile("$maj_data_directory/items/$maj_req_entry/author.txt");
  283.       echo " - ";
  284.   }
  285.  
  286.   entry2date($maj_req_entry);
  287.  
  288.   if (file_exists($revisions_file)) {
  289.       echo ' (Revision ';
  290.       readfile($revisions_file);
  291.       echo " - ";
  292.       echo date("l, M j, Y, g:i A", filemtime("$maj_data_directory/items/$maj_req_entry/body.txt"));
  293.       echo ')';
  294.   }
  295.  
  296.   echo "</font><div style=\"height: {$maj_wspace}px;\"></div>";  
  297.  
  298.   readfile($body_file);
  299. ?></td></tr></table></div></div>
  300. </td></tr></table>
  301.  
  302. <form enctype="multipart/form-data" action="edit.php" method="post">
  303.  
  304. <table border="0" cellspacing="2" cellpadding="0">
  305.  
  306. <?php
  307.   if (($maj_logged_in_username == $maj_admin_username) or (file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-ul.txt") and file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-rw.txt"))) {
  308. ?>
  309.  
  310. <input type="hidden" name="max_file_size" value="<?php
  311.       echo $max_file_size;
  312. ?>">
  313.  
  314. <tr><td><input autocomplete="off" type="file" name="entry_image_input"> Upload optional GIF, JPG, or PNG entry image.</td></tr>
  315. <tr><td><input type="hidden" name="max_file_size" value="<?php
  316.       echo $max_file_size;
  317. ?>"></td></tr>
  318. <tr><td><input autocomplete="off" type="file" name="file_input"> Upload optional file. Max size supported by server is <?php
  319.       echo($max_file_size / (1024 * 1024));
  320. ?>MB.</td></tr>
  321.  
  322. <tr><td><input autocomplete="off" type="file" name="album_image_input"> Upload optional album image.</td></tr>
  323. <tr><td><input autocomplete="off" type="text" name="caption" class="input" style="width: 300px;"> Enter optional album image caption.</td></tr>
  324. <tr><td><input type="hidden" name="max_file_size" value="<?php
  325.       echo $max_file_size;
  326. ?>"></td></tr>
  327.  
  328. <?php
  329.   }
  330.  
  331.   if ($maj_logged_in_username == $maj_admin_username) {
  332. ?>
  333.  
  334.   <tr><td><input class="input" style="width: 300px;" autocomplete="off" type="password" name="passwd" <?php
  335.       if (file_exists("$maj_data_directory/items/$maj_req_entry/passwd.txt")) {
  336.           echo "value=\"password\"";
  337.       }
  338. ?>
  339.  
  340.   > <?php
  341.       if (file_exists("$maj_data_directory/items/$maj_req_entry/passwd.txt")) {
  342.           echo "Enter new password or clear field to disable password protection.";
  343.       } else {
  344.           echo "Enter optional entry access password.";
  345.       }
  346. ?></td></tr>
  347.  
  348.   <tr><td><input class="input" style="width: 300px;" autocomplete="off" type="text" name="maxlines" <?php
  349.       if (file_exists("$maj_data_directory/items/$maj_req_entry/maxlines.txt")) {
  350.           echo "value=\"";
  351.           readfile("$maj_data_directory/items/$maj_req_entry/maxlines.txt");
  352.           echo "\"";
  353.       }
  354. ?>
  355.  
  356.   > <?php
  357.       if (file_exists("$maj_data_directory/items/$maj_req_entry/maxlines.txt")) {
  358.           echo "Enter new maximum lines for initial display or clear field to disable.";
  359.       } else {
  360.           echo "Enter optional maximum lines for initial display.";
  361.       }
  362. ?></td></tr>
  363.  
  364.   <tr><td><input type="checkbox" name="sticky" <?php
  365.       $sticky_sem = 'data/sticky/' . $maj_req_entry;
  366.       if (file_exists($sticky_sem)) {
  367.           echo checked;
  368.       }
  369. ?>>Put entry title in Quick Links box.</td></tr>
  370.   <tr><td><input type="checkbox" name="display" <?php
  371.       $display_sem = "$maj_data_directory/items/$maj_req_entry/cat.txt";
  372.       if (file_exists($display_sem)) {
  373.           echo checked;
  374.       }
  375. ?>>Always display. If this is not a private entry, it will be displayed even if its category is hidden or isolated.</td></tr>
  376.   <tr><td><input type="checkbox" name="private" <?php
  377.       $private_sem = "$maj_data_directory/items/$maj_req_entry/private.txt";
  378.       if (file_exists($private_sem)) {
  379.           echo checked;
  380.       }
  381. ?>>Private entry. This entry will unconditionally be invisible to visitors<?php
  382.       if (file_exists("$maj_data_directory/ml.txt")) {
  383.           echo " and to the mailing list";
  384.       }
  385. ?>, even if always display is set.</td></tr>
  386.  
  387.   <?php
  388.       if (file_exists("$maj_data_directory/bb.txt")) {
  389. ?>
  390.  
  391.   <tr><td><input type="checkbox" name="member" <?php
  392.           $member_sem = "$maj_data_directory/items/$maj_req_entry/member.txt";
  393.           if (file_exists($member_sem)) {
  394.               echo checked;
  395.           }
  396. ?>>Only registered members can view this entry.</td></tr>
  397.  
  398.   <?php
  399.       }
  400. ?>
  401.  
  402.   <?php
  403.       if (file_exists("$maj_data_directory/bb.txt") and file_exists("$maj_data_directory/wiki.txt")) {
  404. ?>
  405.  
  406.   <tr><td><input type="checkbox" name="edit" <?php
  407.           $edit_sem = "$maj_data_directory/items/$maj_req_entry/edit.txt";
  408.           if (file_exists($edit_sem)) {
  409.               echo checked;
  410.           }
  411. ?>>Registered members can edit this entry.</td></tr>
  412.   <tr><td><input type="checkbox" name="lock" <?php
  413.           if (file_exists("$maj_data_directory/items/$maj_req_entry/lock.txt")) {
  414.               echo checked;
  415.           }
  416. ?>>Only the administrator can edit this entry. </td></tr>
  417.  
  418.   <?php
  419.       }
  420.   }
  421.  
  422.   if (($maj_logged_in_username == $maj_admin_username) or file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-adm.txt")) {
  423. ?>
  424.  
  425.   <tr><td><input type="checkbox" name="xtitle" <?php
  426.       $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/xtitle.txt";
  427.       if (file_exists($lastmod_sem)) {
  428.           echo checked;
  429.       }
  430. ?>>Do not display the entry title.</td></tr>
  431.  
  432.   <tr><td><input type="checkbox" name="xdate" <?php
  433.       $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/xdate.txt";
  434.       if (file_exists($lastmod_sem)) {
  435.           echo checked;
  436.       }
  437. ?>>Do not display the entry date.</td></tr>
  438.  
  439. <?php
  440.  
  441. if (!file_exists("$maj_data_directory/avatar.txt")) {
  442.  
  443.         echo "<tr><td><input type=\"checkbox\" name=\"xauthor\"";
  444.  
  445.         if (file_exists("$maj_data_directory/items/$maj_req_entry/xauthor.txt")) {
  446.                 echo checked;
  447.         }
  448.        
  449.         echo ">Do not display the entry author.</td></tr>";
  450. }
  451. else {
  452.         echo "<tr><td><input type=\"checkbox\" name=\"xavatar\"";
  453.  
  454.         if (file_exists("$maj_data_directory/items/$maj_req_entry/xavatar.txt")) {
  455.                 echo checked;
  456.         }
  457.        
  458.         echo ">Do not display the entry avatar.</td></tr>";
  459. }
  460.  
  461. ?>
  462.  
  463.  
  464.   <tr><td><input type="checkbox" name="lastmod" <?php
  465.       $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/lastmod.txt";
  466.       if (file_exists($lastmod_sem)) {
  467.           echo checked;
  468.       }
  469. ?>>Display last modification date and time.</td></tr>
  470.  
  471. <?php
  472.  
  473. if (file_exists("$maj_data_directory/gl.txt")) {
  474.  
  475.         echo "<tr><td><input type=\"checkbox\" name=\"gl\"";
  476.  
  477.         if (file_exists("$maj_data_directory/items/$maj_req_entry/gl.txt")) {
  478.                 echo checked;
  479.         }
  480.        
  481.         echo ">Enable Google support.</td></tr>";
  482. }
  483.  
  484. if (file_exists("$maj_data_directory/fb.txt")) {
  485.  
  486.         echo "<tr><td><input type=\"checkbox\" name=\"fb\"";
  487.  
  488.         if (file_exists("$maj_data_directory/items/$maj_req_entry/fb.txt")) {
  489.                 echo checked;
  490.         }
  491.        
  492.         echo ">Enable Facebook support.</td></tr>";
  493. }
  494.  
  495. if (file_exists("images/$maj_req_entry/album")) {
  496.  
  497.         $count_album_images = count(glob("images/$maj_req_entry/album/*"));
  498.        
  499.         if ($count_album_images < 1) {
  500.                 rmdirr("images/$maj_req_entry/album");
  501.         }
  502.         else {
  503.                 if (file_exists("$maj_data_directory/items/$maj_req_entry/auto-album.txt")) {
  504.                         echo "<tr><td><input type=\"checkbox\" name=\"auto_album\" checked>";
  505.                 }
  506.                 else {
  507.                         echo "<tr><td><input type=\"checkbox\" name=\"auto_album\">";
  508.                 }
  509.        
  510.                 if ($count_album_images > 1) {
  511.                         echo "Automatically display album (<a href=\"index.php?entry=$maj_req_entry&show=album\">$count_album_images images</a>).</td></tr>";
  512.                 }
  513.                 else {
  514.                         echo "Automatically display album (<a href=\"index.php?entry=$maj_req_entry&show=album\">$count_album_images image</a>).</td></tr>";
  515.                 }
  516.         }
  517. }
  518.  
  519. }
  520.  
  521. ?>
  522.  
  523. </table></p>
  524.  
  525. <input type="hidden" name="entry" value="<?php echo $maj_req_entry; ?>">
  526.  
  527. <table border="0" cellspacing="0" cellpadding="0"><tr><td>
  528.  
  529. <table border="0" cellspacing="2" cellpadding="0">
  530. <tr><td><input required autocomplete="off" class="input" style="font-size: <?php echo $maj_font_Lpx; ?>; font-weight: bold;" type="text" name="title_input" value="<?php readfile($title_file); ?>"></td></tr>
  531. <tr><td><textarea class="input" style="font-size: <?php echo $maj_font_Mpx; ?>;" name="body_input" rows="15" required>
  532. <?php
  533.   $open_body_file = fopen($body_file, "r");
  534.   $read_body_file = fread($open_body_file, filesize($body_file));
  535.   fclose($open_body_file);
  536.  
  537.   $body_read_content = str_replace('<br />', "\n", $read_body_file);
  538.   $body_read_content = str_replace('<img src="images/smileys/crying.png" border="0">', ':((', $body_read_content);
  539.   $body_read_content = str_replace('<img src="images/smileys/frown.png" border="0">', ':(', $body_read_content);
  540.   $body_read_content = str_replace('<img src="images/smileys/indifferent.png" border="0">', ':|', $body_read_content);
  541.   $body_read_content = str_replace('<img src="images/smileys/laughing.png" border="0">', ':D', $body_read_content);
  542.   $body_read_content = str_replace('<img src="images/smileys/lick.png" border="0">', ':P', $body_read_content);
  543.   $body_read_content = str_replace('<img src="images/smileys/ohno.png" border="0">', ':O', $body_read_content);
  544.   $body_read_content = str_replace('<img src="images/smileys/smile.png" border="0">', ':)', $body_read_content);
  545.   $body_read_content = str_replace('<img src="images/smileys/surprised.png" border="0">', '=)', $body_read_content);
  546.   $body_read_content = str_replace('<img src="images/smileys/undecided.png" border="0">', ':\\', $body_read_content);
  547.   $body_read_content = str_replace('<img src="images/smileys/wink.png" border="0">', ';)', $body_read_content);
  548.   $body_read_content = str_replace('<!-- html -->', '<html>', $body_read_content);
  549.   $body_read_content = str_replace('<!-- /html -->', '</html>', $body_read_content);
  550.   $body_read_content = str_replace('<span style="background-color: #ffff00;">', '<highlight>', $body_read_content);
  551.   $body_read_content = str_replace('</span>', '</highlight>', $body_read_content);
  552.  
  553.   echo $body_read_content;
  554. ?>
  555. </textarea></td></tr>
  556. <tr><td><input class="click" type="submit" value="click here to update this entry"></td></tr>
  557. </form>
  558.  
  559. <form enctype="multipart/form-data" action="index.php?entry=<?php echo $maj_req_entry; ?>" method="post">
  560. <tr><td><input class="click" type="submit" value="click here to view posted entry"></td></tr>
  561. </form>
  562.  
  563. <form enctype="multipart/form-data" action="index.php" method="post">
  564. <tr><td><input class="click" type="submit" value="click here to go to the index page"></td></tr>
  565. </form>
  566.  
  567. </table>
  568.  
  569. </td><td width="10"></td><td>
  570.  
  571. <table border="0" cellspacing="1" cellpadding="2">
  572. <tr><td><img src="images/smileys/crying.png" border="0"></td><td>:((</td><td >crying</td></tr>
  573. <tr><td><img src="images/smileys/frown.png" border="0"></td><td>:(</td><td>frown</td></tr>
  574. <tr><td><img src="images/smileys/indifferent.png" border="0"></td><td>:|</td><td>indifferent</td></tr>
  575. <tr><td><img src="images/smileys/laughing.png" border="0"></td><td>:D</td><td>laughing</td></tr>
  576. <tr><td><img src="images/smileys/lick.png" border="0"></td><td>:P</td><td>lick</td></tr>
  577. <tr><td><img src="images/smileys/ohno.png" border="0"></td><td>:O</td><td>oh no!</td></tr>
  578. <tr><td><img src="images/smileys/smile.png" border="0"></td><td>:)</td><td>smile</td></tr>
  579. <tr><td><img src="images/smileys/surprised.png" border="0"></td><td>=)</td><td>surprised</td></tr>
  580. <tr><td><img src="images/smileys/undecided.png" border="0"></td><td>:\</td><td>undecided</td></tr>
  581. <tr><td><img src="images/smileys/wink.png" border="0"></td><td>;)</td><td>wink</td></tr>
  582. </table>
  583.  
  584. </td></tr></table>
  585.  
  586. </td><td width="25"></td><td valign="top">
  587.  
  588. <?php
  589.   // improve category handling (20100221) - start
  590.  
  591.   if (file_exists("$maj_data_directory/categories")) {
  592.       echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\"><tr><td valign=\"top\" width=\"150\">";
  593.      
  594.       if ($dh_cat = opendir("$maj_data_directory/categories")) {
  595.           while (($entry_cat = readdir($dh_cat)) !== false) {
  596.               if ($entry_cat != "." && $entry_cat != "..") {
  597.                   if (file_exists("$maj_data_directory/categories/$entry_cat/private.txt") and ($maj_admin_username != $maj_logged_in_username)) {
  598.                       continue;
  599.                   }
  600.                  
  601.                   if (($maj_admin_username != $maj_logged_in_username) and !file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-adm.txt")) {
  602.                         continue;
  603.                   }
  604.                  
  605.                   if (file_exists("$maj_data_directory/items/$maj_req_entry/categories/$entry_cat")) {
  606.                       $filed_cat[] = $entry_cat;
  607.                   }
  608.                  
  609.                   if (!file_exists("$maj_data_directory/items/$maj_req_entry/categories/$entry_cat")) {
  610.                       $unfiled_cat[] = $entry_cat;
  611.                   }
  612.               }
  613.           }
  614.           closedir($dh_cat);
  615.          
  616.           sort($filed_cat);
  617.           sort($unfiled_cat);
  618.          
  619.           $count_filed_cat = count($filed_cat);
  620.           $count_unfiled_cat = count($unfiled_cat);
  621.       }
  622.      
  623.       if ($count_filed_cat > 0) {
  624.           echo "<p><b>Filed Under</b></p>";
  625.          
  626.           echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"150\">";
  627.          
  628.           foreach ($filed_cat as $filed_category) {
  629.               echo "<form enctype=\"multipart/form-data\" action=\"edit.php\" method=\"post\">";
  630.               echo "<input type=\"hidden\" name=\"entry\" value=\"$maj_req_entry\">";
  631.               echo "<input type=\"hidden\" name=\"category\" value=\"$filed_category\">";
  632.               echo "<input type=\"hidden\" name=\"do\" value=\"unfile\">";
  633.               echo "<tr bgcolor=\"#ffffff\"><td><a href=\"index.php?category=$filed_category\">$filed_category</a></td>";
  634.               echo "<td width=\"14\"><input type=\"image\" src=\"images/widget.x.png\"></td></tr>";
  635.               echo "</form>";
  636.           }
  637.          
  638.           echo "</table>";
  639.       }
  640.      
  641.       echo "</td><td width=\"25\"></td><td valign=\"top\" width=\"150\">";
  642.      
  643.       if ($count_unfiled_cat > 0) {
  644.           echo "<p><b>Available Categories</b></p>";
  645.          
  646.           echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"150\">";
  647.          
  648.           foreach ($unfiled_cat as $unfiled_category) {
  649.               echo "<form enctype=\"multipart/form-data\" action=\"edit.php\" method=\"post\">";
  650.               echo "<input type=\"hidden\" name=\"entry\" value=\"$maj_req_entry\">";
  651.               echo "<input type=\"hidden\" name=\"category\" value=\"$unfiled_category\">";
  652.               echo "<input type=\"hidden\" name=\"do\" value=\"file\">";
  653.               echo "<tr bgcolor=\"#ffffff\"><td width=\"14\"><input type=\"image\" src=\"images/widget.ok.png\"></td>";
  654.               echo "<td align=\"right\"><a href=\"index.php?category=$unfiled_category\">$unfiled_category</a></td></tr>";
  655.               echo "</form>";
  656.           }
  657.          
  658.           echo "</table>";
  659.       }
  660.      
  661.       echo "</td></tr></table><br>";
  662.   }
  663.  
  664.   // improve category handling (20100221) - end
  665.  
  666.   // add member authorization (20100221) - start
  667.  
  668.   if (file_exists("$maj_data_directory/members/active") and (($maj_admin_username == $maj_logged_in_username) or (($maj_admin_username != $maj_logged_in_username) and file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-adm.txt")))) {
  669.       echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\"><tr><td valign=\"top\" width=\"150\">";
  670.      
  671.       if ($dh_ack_members = opendir("$maj_data_directory/items/$maj_req_entry/members")) {
  672.           while (($ack_member = readdir($dh_ack_members)) !== false) {
  673.               if ($ack_member != "." && $ack_member != "..") {
  674.                   if (file_exists("$maj_data_directory/members/active/$ack_member")) {
  675.                       $ack_members[] = $ack_member;
  676.                   } else {
  677.                       rmdirr("$maj_data_directory/items/$maj_req_entry/members/$ack_member");
  678.                   }
  679.               }
  680.           }
  681.           closedir($dh_ack_members);
  682.           sort($ack_members);
  683.           $count_ack_members = count($ack_members);
  684.       }
  685.      
  686.       if ($dh_nak_members = opendir("$maj_data_directory/members/active")) {
  687.           while (($nak_member = readdir($dh_nak_members)) !== false) {
  688.               if ($nak_member != "." && $nak_member != "..") {
  689.                   if (file_exists("$maj_data_directory/items/$maj_req_entry/members/$nak_member")) {
  690.                       continue;
  691.                   }
  692.                  
  693.                   if (!file_exists("$maj_data_directory/items/$maj_req_entry/members/$nak_member")) {
  694.                       $nak_members[] = $nak_member;
  695.                   }
  696.               }
  697.           }
  698.           closedir($dh_nak_members);
  699.           sort($nak_members);
  700.           $count_nak_members = count($nak_members);
  701.       }
  702.      
  703.       if ($count_ack_members > 0) {
  704.           echo "<p><b>Authorized Members</b></p>";
  705.          
  706.           echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"150\">";
  707.          
  708.           foreach ($ack_members as $ack_member) {
  709.  
  710.                 if ($maj_logged_in_username == $nak_member) {
  711.                         continue;
  712.                 }
  713.                          
  714.               echo "<form enctype=\"multipart/form-data\" action=\"edit.php\" method=\"post\">";
  715.               echo "<input type=\"hidden\" name=\"entry\" value=\"$maj_req_entry\">";
  716.               echo "<input type=\"hidden\" name=\"auth_member\" value=\"$ack_member\">";
  717.               echo "<input type=\"hidden\" name=\"auth_toggle\" value=\"nak\">";
  718.               echo "<tr bgcolor=\"#ffffff\"><td><a href=\"member.php?id=$ack_member\">$ack_member</a></td>";
  719.               echo "<td width=\"14\"><input type=\"image\" src=\"images/widget.x.png\"></td></tr>";
  720.               echo "</form>";
  721.           }
  722.           echo "</table>";
  723.       }
  724.      
  725.       echo "</td><td width=\"25\"></td><td valign=\"top\" width=\"150\">";
  726.      
  727.       if ($count_nak_members > 0) {
  728.           echo "<p><b>Registered Members</b></p>";
  729.          
  730.           echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"150\">";
  731.          
  732.           foreach ($nak_members as $nak_member) {
  733.          
  734.                 if ($maj_logged_in_username == $nak_member) {
  735.                         continue;
  736.                 }
  737.          
  738.               echo "<form enctype=\"multipart/form-data\" action=\"edit.php\" method=\"post\">";
  739.               echo "<input type=\"hidden\" name=\"entry\" value=\"$maj_req_entry\">";
  740.               echo "<input type=\"hidden\" name=\"auth_member\" value=\"$nak_member\">";
  741.               echo "<input type=\"hidden\" name=\"auth_toggle\" value=\"ack\">";
  742.               echo "<tr bgcolor=\"#ffffff\"><td width=\"14\"><input type=\"image\" src=\"images/widget.ok.png\"></td>";
  743.               echo "<td align=\"right\"><a href=\"member.php?id=$nak_member\">$nak_member</a></td></tr>";
  744.               echo "</form>";
  745.           }
  746.           echo "</table>";
  747.       }
  748.      
  749.       echo "</td></tr></table><br>";
  750.   }
  751.  
  752.   // add member authorization (20100221) - end
  753. ?>
  754.  
  755. </td></tr></table>
  756.  
  757. <?php
  758.   if (!isset($_POST['title_input']) or !isset($_POST['body_input']) or empty($_POST['title_input']) or empty($_POST['body_input'])) {
  759.       exit();
  760.   }
  761.  
  762.   if (file_exists("$maj_data_directory/items/$maj_req_entry/title.old")) {
  763.       unlink("$maj_data_directory/items/$maj_req_entry/title.old");
  764.   }
  765.  
  766.   if (file_exists("$maj_data_directory/items/$maj_req_entry/body.old")) {
  767.       unlink("$maj_data_directory/items/$maj_req_entry/body.old");
  768.   }
  769.  
  770.   copy("$maj_data_directory/items/$maj_req_entry/title.txt", "$maj_data_directory/items/$maj_req_entry/title.old");
  771.   copy("$maj_data_directory/items/$maj_req_entry/body.txt", "$maj_data_directory/items/$maj_req_entry/body.old");
  772.  
  773.   $title_write_content = format_title_put($_POST['title_input']);
  774.   $body_write_content = format_body_put($_POST['body_input']);
  775.  
  776.   $fp_revisions_file = fopen($revisions_file, "r");
  777.   $revisions_count = fread($fp_revisions_file, filesize($revisions_file));
  778.   fclose($fp_revisions_file);
  779.  
  780.   $revisions_count = $revisions_count + 1;
  781.  
  782.   $fp_revisions_file = fopen($revisions_file, "w");
  783.   fwrite($fp_revisions_file, $revisions_count);
  784.   fclose($fp_revisions_file);
  785.  
  786.   if (isset($_FILES['album_image_input']) and !empty($_FILES['album_image_input'])) {
  787.       if (is_uploaded_file($_FILES['album_image_input']['tmp_name'])) {
  788.           if ($_FILES['album_image_input']['size'] <= $max_file_size) {
  789.               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")) {
  790.                   $album_image_input_name = str_replace(" ", "_", $_FILES['album_image_input']['name']);
  791.                  
  792.                   if (!file_exists("images/$maj_req_entry/album/$album_image_input_name")) {
  793.                       if (!file_exists("images/$maj_req_entry")) {
  794.                           mkdir("images/$maj_req_entry");
  795.                       }
  796.                      
  797.                       if (!file_exists("images/$maj_req_entry/album")) {
  798.                           mkdir("images/$maj_req_entry/album");
  799.                       }
  800.                      
  801.                       if (!file_exists("$maj_data_directory/albums")) {
  802.                           mkdir("$maj_data_directory/albums");
  803.                       }
  804.                      
  805.                       if (!file_exists("$maj_data_directory/albums/$maj_req_entry")) {
  806.                           mkdir("$maj_data_directory/albums/$maj_req_entry");
  807.                       }
  808.                      
  809.                       if (isset($_POST['caption']) and !empty($_POST['caption'])) {
  810.                           if (!file_exists("$maj_data_directory/items/$maj_req_entry/album")) {
  811.                               mkdir("$maj_data_directory/items/$maj_req_entry/album");
  812.                           }
  813.                          
  814.                           if (!file_exists("$maj_data_directory/items/$maj_req_entry/album/captions")) {
  815.                               mkdir("$maj_data_directory/items/$maj_req_entry/album/captions");
  816.                           }
  817.                          
  818.                           if (!file_exists("$maj_data_directory/items/$maj_req_entry/album/captions/{$album_image_input_name}.txt")) {
  819.                               $caption_txt = ucfirst($_POST['caption']);
  820.                               $caption_txt = str_replace(':((', '<img src="images/smileys/crying.png" border="0">', $caption_txt);
  821.                               $caption_txt = str_replace(':(', '<img src="images/smileys/frown.png" border="0">', $caption_txt);
  822.                               $caption_txt = str_replace(':|', '<img src="images/smileys/indifferent.png" border="0">', $caption_txt);
  823.                               $caption_txt = str_replace(':D', '<img src="images/smileys/laughing.png" border="0">', $caption_txt);
  824.                               $caption_txt = str_replace(':P', '<img src="images/smileys/lick.png" border="0">', $caption_txt);
  825.                               $caption_txt = str_replace(':O', '<img src="images/smileys/ohno.png" border="0">', $caption_txt);
  826.                               $caption_txt = str_replace(':)', '<img src="images/smileys/smile.png" border="0">', $caption_txt);
  827.                               $caption_txt = str_replace('=)', '<img src="images/smileys/surprised.png" border="0">', $caption_txt);
  828.                               $caption_txt = str_replace(':\\', '<img src="images/smileys/undecided.png" border="0">', $caption_txt);
  829.                               $caption_txt = str_replace(';)', '<img src="images/smileys/wink.png" border="0">', $caption_txt);
  830.                               $caption_txt = str_replace('[code]', '<code>', $caption_txt);
  831.                               $caption_txt = str_replace('[/code]', '</code>', $caption_txt);
  832.                               $caption_txt = str_replace("\n", '<br />', $caption_txt);
  833.                               $caption_txt = str_replace('[b]', '<b>', $caption_txt);
  834.                               $caption_txt = str_replace('[/b]', '</b>', $caption_txt);
  835.                               $caption_txt = str_replace('[i]', '<i>', $caption_txt);
  836.                               $caption_txt = str_replace('[/i]', '</i>', $caption_txt);
  837.                               $caption_txt = str_replace('[u]', '<u>', $caption_txt);
  838.                               $caption_txt = str_replace('[/u]', '</u>', $caption_txt);
  839.                               $caption_txt = str_replace('[strike]', '<strike>', $caption_txt);
  840.                               $caption_txt = str_replace('[/strike]', '</strike>', $caption_txt);
  841.                               $caption_txt = str_replace('[sup]', '<sup>', $caption_txt);
  842.                               $caption_txt = str_replace('[/sup]', '</sup>', $caption_txt);
  843.                               $caption_txt = str_replace('[sub]', '<sub>', $caption_txt);
  844.                               $caption_txt = str_replace('[/sub]', '</sub>', $caption_txt);
  845.                               $caption_txt = str_replace('[highlight]', '<highlight>', $caption_txt);
  846.                               $caption_txt = str_replace('[/highlight]', '</highlight>', $caption_txt);
  847.                               $caption_txt = str_replace('<highlight>', '<span style="background-color: #ffff00;">', $caption_txt);
  848.                               $caption_txt = str_replace('</highlight>', '</span>', $caption_txt);
  849.                              
  850.                               $fp_caption_txt = fopen("$maj_data_directory/items/$maj_req_entry/album/captions/{$album_image_input_name}.txt", "w");
  851.                               fwrite($fp_caption_txt, $caption_txt);
  852.                               fclose($fp_caption_txt);
  853.                           }
  854.                       }
  855.                      
  856.                      
  857.                       $res = copy($_FILES['album_image_input']['tmp_name'], "images/$maj_req_entry/album/$album_image_input_name");
  858.                       unlink($_FILES['album_image_input']['tmp_name']);
  859.                   } else {
  860.                       unlink($_FILES['album_image_input']['tmp_name']);
  861.                   }
  862.               } else {
  863.                   unlink($_FILES['album_image_input']['tmp_name']);
  864.               }
  865.           } else {
  866.               unlink($_FILES['album_image_input']['tmp_name']);
  867.           }
  868.       } else {
  869.           unlink($_FILES['album_image_input']['tmp_name']);
  870.       }
  871.   }
  872.  
  873.   if (isset($_FILES['entry_image_input']) and !empty($_FILES['entry_image_input'])) {
  874.       if (is_uploaded_file($_FILES['entry_image_input']['tmp_name'])) {
  875.           if ($_FILES['entry_image_input']['size'] <= $max_file_size) {
  876.               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")) {
  877.                   $entry_image_input_name = str_replace(" ", "_", $_FILES['entry_image_input']['name']);
  878.                  
  879.                  
  880.                   if (!file_exists("images/$maj_req_entry/$entry_image_input_name")) {
  881.                       if (!file_exists("images/$maj_req_entry")) {
  882.                           mkdir("images/$maj_req_entry");
  883.                       }
  884.                      
  885.                      
  886.                       $res = copy($_FILES['entry_image_input']['tmp_name'], "images/$maj_req_entry/$entry_image_input_name");
  887.                       unlink($_FILES['entry_image_input']['tmp_name']);
  888.                      
  889.                       $entry_image_size = getimagesize("images/$maj_req_entry/$entry_image_input_name");
  890.                       $entry_image_width = $entry_image_size[0];
  891.                       $entry_image_height = $entry_image_size[1];
  892.                      
  893.                       if ($entry_image_width > $maj_eimage) {
  894.                           $sizefactor = (double)($maj_eimage / $entry_image_width);
  895.                           $entry_image_width = (int)($entry_image_width * $sizefactor);
  896.                           $entry_image_height = (int)($entry_image_height * $sizefactor);
  897.                       }
  898.                      
  899.                       $body_write_content = "<img src=\"images/$maj_req_entry/$entry_image_input_name\" border=\"0\" width=\"$entry_image_width\" height=\"$entry_image_height\">\n\r$body_write_content";
  900.                   } else {
  901.                       unlink($_FILES['entry_image_input']['tmp_name']);
  902.                   }
  903.               } else {
  904.                   unlink($_FILES['entry_image_input']['tmp_name']);
  905.               }
  906.           } else {
  907.               unlink($_FILES['entry_image_input']['tmp_name']);
  908.           }
  909.       } else {
  910.           unlink($_FILES['entry_image_input']['tmp_name']);
  911.       }
  912.   }
  913.  
  914.   if (isset($_FILES['file_input']) and !empty($_FILES['file_input'])) {
  915.       if (is_uploaded_file($_FILES['file_input']['tmp_name'])) {
  916.           if ($_FILES['file_input']['size'] <= $max_file_size) {
  917.               if (!file_exists("$maj_data_directory/items/$maj_req_entry/filedrop")) {
  918.                   mkdir("$maj_data_directory/items/$maj_req_entry/filedrop");
  919.               }
  920.              
  921.               if (!file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/files")) {
  922.                   mkdir("$maj_data_directory/items/$maj_req_entry/filedrop/files");
  923.               }
  924.              
  925.               $file_input_name = str_replace(" ", "_", $_FILES['file_input']['name']);
  926.              
  927.               if (!file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/files/$file_input_name")) {
  928.                   $res = copy($_FILES['file_input']['tmp_name'], "$maj_data_directory/items/$maj_req_entry/filedrop/files/$file_input_name");
  929.                   unlink($_FILES['file_input']['tmp_name']);
  930.                  
  931.                  
  932.                   $fp_file_txt = fopen("$maj_data_directory/items/$maj_req_entry/filedrop/{$file_input_name}.txt", "w");
  933.                   fwrite($fp_file_txt, "$maj_data_directory/items/$maj_req_entry/filedrop/files/$file_input_name");
  934.                   fclose($fp_file_txt);
  935.               } else {
  936.                   unlink($_FILES['file_input']['tmp_name']);
  937.               }
  938.           } else {
  939.               unlink($_FILES['file_input']['tmp_name']);
  940.           }
  941.       } else {
  942.           unlink($_FILES['file_input']['tmp_name']);
  943.       }
  944.   }
  945.  
  946.   if (file_exists("$maj_data_directory/wiki.txt")) {
  947.       $old_title = file_get_contents("$maj_data_directory/items/$maj_req_entry/title.old");
  948.       $old_body = file_get_contents("$maj_data_directory/items/$maj_req_entry/body.old");
  949.      
  950.       if (($old_title != $title_write_content) or ($old_body != $body_write_content)) {
  951.           if (!file_exists("$maj_data_directory/items/$maj_req_entry/wiki")) {
  952.               mkdir("$maj_data_directory/items/$maj_req_entry/wiki");
  953.           }
  954.          
  955.           if (!file_exists("$maj_data_directory/items/$maj_req_entry/wiki/delta")) {
  956.               mkdir("$maj_data_directory/items/$maj_req_entry/wiki/delta");
  957.           }
  958.          
  959.           $ddate = date("YmdHis", time() + $maj_offset);
  960.          
  961.           if (!file_exists("$maj_data_directory/items/$maj_req_entry/wiki/delta/$ddate")) {
  962.               mkdir("$maj_data_directory/items/$maj_req_entry/wiki/delta/$ddate");
  963.           }
  964.          
  965.           $new_body = fopen("$maj_data_directory/items/$maj_req_entry/wiki/delta/$ddate/body.txt", "w");
  966.           fwrite($new_body, $body_write_content);
  967.           fclose($new_body);
  968.          
  969.           $new_title = fopen("$maj_data_directory/items/$maj_req_entry/wiki/delta/$ddate/title.txt", "w");
  970.           fwrite($new_title, $title_write_content);
  971.           fclose($new_title);
  972.          
  973.           copy("$maj_data_directory/items/$maj_req_entry/title.txt", "$maj_data_directory/items/$maj_req_entry/wiki/delta/$ddate/ptitle.txt");
  974.           copy("$maj_data_directory/items/$maj_req_entry/body.txt", "$maj_data_directory/items/$maj_req_entry/wiki/delta/$ddate/prev.txt");
  975.           copy("$maj_data_directory/items/$maj_req_entry/date.txt", "$maj_data_directory/items/$maj_req_entry/wiki/delta/$ddate/date.txt");
  976.          
  977.           if (file_exists("$maj_data_directory/items/$maj_req_entry/contrib.txt")) {
  978.               copy("$maj_data_directory/items/$maj_req_entry/contrib.txt", "$maj_data_directory/items/$maj_req_entry/wiki/delta/$ddate/contrib.txt");
  979.           }
  980.          
  981.           $open_editor_file = fopen("$maj_data_directory/items/$maj_req_entry/wiki/delta/$ddate/editor.txt", "w");
  982.           fwrite($open_editor_file, $maj_logged_in_username);
  983.           fclose($open_editor_file);
  984.       }
  985.   }
  986.  
  987.   $open_title_file = fopen($title_file, "w");
  988.   fwrite($open_title_file, $title_write_content);
  989.   fclose($open_title_file);
  990.  
  991.   $open_body_file = fopen($body_file, "w");
  992.   fwrite($open_body_file, $body_write_content);
  993.   fclose($open_body_file);
  994.  
  995.   if (file_exists("$maj_data_directory/wiki.txt") and (file_exists("$maj_data_directory/items/$maj_req_entry/edit.txt") or (file_get_contents("$maj_data_directory/items/$maj_req_entry/author.txt") == $maj_logged_in_username))) {
  996.       $open_contrib_file = fopen("$maj_data_directory/items/$maj_req_entry/contrib.txt", "w");
  997.       fwrite($open_contrib_file, $maj_logged_in_username);
  998.       fclose($open_contrib_file);
  999.   }
  1000.  
  1001.   if ($maj_logged_in_username == $maj_admin_username) {
  1002.       $sticky_sem = 'data/sticky/' . $maj_req_entry;
  1003.      
  1004.       if (isset($_POST['sticky']) and !empty($_POST['sticky']) and ($_POST['sticky'] == "on")) {
  1005.           if (!file_exists("$maj_data_directory/sticky")) {
  1006.               mkdir("$maj_data_directory/sticky");
  1007.           }
  1008.           if (!file_exists($sticky_sem)) {
  1009.               touch($sticky_sem);
  1010.           }
  1011.       }
  1012.       if (!isset($_POST['sticky']) or empty($_POST['sticky'])) {
  1013.           if (file_exists($sticky_sem)) {
  1014.               unlink($sticky_sem);
  1015.           }
  1016.       }
  1017.      
  1018.       $display_sem = "$maj_data_directory/items/$maj_req_entry/cat.txt";
  1019.      
  1020.       if (isset($_POST['display']) and !empty($_POST['display']) and ($_POST['display'] == "on")) {
  1021.           if (!file_exists($display_sem)) {
  1022.               touch($display_sem);
  1023.           }
  1024.       }
  1025.       if (!isset($_POST['display']) or empty($_POST['display'])) {
  1026.           if (file_exists($display_sem)) {
  1027.               unlink($display_sem);
  1028.           }
  1029.       }
  1030.      
  1031.       $private_sem = "$maj_data_directory/items/$maj_req_entry/private.txt";
  1032.      
  1033.       if (isset($_POST['private']) and !empty($_POST['private']) and ($_POST['private'] == "on")) {
  1034.           if (!file_exists($private_sem)) {
  1035.               touch($private_sem);
  1036.           }
  1037.       }
  1038.       if (!isset($_POST['private']) or empty($_POST['private'])) {
  1039.           if (file_exists($private_sem)) {
  1040.               unlink($private_sem);
  1041.           }
  1042.       }
  1043.      
  1044.       $member_sem = "$maj_data_directory/items/$maj_req_entry/member.txt";
  1045.      
  1046.       if (isset($_POST['member']) and !empty($_POST['member']) and ($_POST['member'] == "on")) {
  1047.           if (!file_exists($member_sem)) {
  1048.               touch($member_sem);
  1049.           }
  1050.       }
  1051.       if (!isset($_POST['member']) or empty($_POST['member'])) {
  1052.           if (file_exists($member_sem)) {
  1053.               unlink($member_sem);
  1054.           }
  1055.       }
  1056.      
  1057.       $edit_sem = "$maj_data_directory/items/$maj_req_entry/edit.txt";
  1058.      
  1059.       if (isset($_POST['edit']) and !empty($_POST['edit']) and ($_POST['edit'] == "on")) {
  1060.           if (!file_exists($edit_sem)) {
  1061.               touch($edit_sem);
  1062.           }
  1063.       }
  1064.      
  1065.       if (!isset($_POST['edit']) or empty($_POST['edit'])) {
  1066.           if (file_exists($edit_sem)) {
  1067.               unlink($edit_sem);
  1068.           }
  1069.       }
  1070.      
  1071.       if (isset($_POST['lock']) and !empty($_POST['lock']) and ($_POST['lock'] == "on")) {
  1072.           if (file_exists("$maj_data_directory/items/$maj_req_entry/edit.txt")) {
  1073.               unlink("$maj_data_directory/items/$maj_req_entry/edit.txt");
  1074.           }
  1075.          
  1076.           if (!file_exists("$maj_data_directory/items/$maj_req_entry/lock.txt")) {
  1077.               touch("$maj_data_directory/items/$maj_req_entry/lock.txt");
  1078.           }
  1079.       }
  1080.       if (!isset($_POST['lock']) or empty($_POST['lock'])) {
  1081.           if (file_exists("$maj_data_directory/items/$maj_req_entry/lock.txt")) {
  1082.               unlink("$maj_data_directory/items/$maj_req_entry/lock.txt");
  1083.           }
  1084.       }
  1085.  
  1086.       $xauthor_sem = "$maj_data_directory/items/$maj_req_entry/xauthor.txt";
  1087.      
  1088.       if (isset($_POST['xauthor']) and !empty($_POST['xauthor']) and ($_POST['xauthor'] == "on")) {
  1089.           if (!file_exists($xauthor_sem)) {
  1090.               touch($xauthor_sem);
  1091.           }
  1092.       }
  1093.      
  1094.       if (!isset($_POST['xauthor']) or empty($_POST['xauthor'])) {
  1095.           if (file_exists($xauthor_sem)) {
  1096.               unlink($xauthor_sem);
  1097.           }
  1098.       }
  1099.      
  1100.       $passwd_file = "$maj_data_directory/items/$maj_req_entry/passwd.txt";
  1101.      
  1102.       if (isset($_POST['passwd']) and !empty($_POST['passwd'])) {
  1103.           $fp_passwd_txt = fopen("$passwd_file", "w");
  1104.           $passwd_crypt = sha1($_POST['passwd']);
  1105.           $passwd_crypt = md5($passwd_crypt);
  1106.           $passwd_crypt = crypt($passwd_crypt, $passwd_crypt);
  1107.           fwrite($fp_passwd_txt, $passwd_crypt);
  1108.           fclose($fp_passwd_txt);
  1109.       }
  1110.      
  1111.       if (!isset($_POST['passwd']) or empty($_POST['passwd'])) {
  1112.           if (file_exists($passwd_file)) {
  1113.               unlink($passwd_file);
  1114.           }
  1115.       }
  1116.      
  1117.       if (isset($_POST['maxlines']) and !empty($_POST['maxlines']) and is_numeric($_POST['maxlines'])) {
  1118.           $fp_maxlines_txt = fopen("$maj_data_directory/items/$maj_req_entry/maxlines.txt", "w");
  1119.           fwrite($fp_maxlines_txt, $_POST['maxlines']);
  1120.           fclose($fp_maxlines_txt);
  1121.       }
  1122.      
  1123.       if (!isset($_POST['maxlines']) or empty($_POST['maxlines'])) {
  1124.           if (file_exists("$maj_data_directory/items/$maj_req_entry/maxlines.txt")) {
  1125.               unlink("$maj_data_directory/items/$maj_req_entry/maxlines.txt");
  1126.           }
  1127.       }
  1128.   }
  1129.  
  1130.   if (($maj_logged_in_username == $maj_admin_username) or file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-adm.txt")) {
  1131.       $xtitle_sem = "$maj_data_directory/items/$maj_req_entry/xtitle.txt";
  1132.      
  1133.       if (isset($_POST['xtitle']) and !empty($_POST['xtitle']) and ($_POST['xtitle'] == "on")) {
  1134.           if (!file_exists($xtitle_sem)) {
  1135.               touch($xtitle_sem);
  1136.           }
  1137.       }
  1138.      
  1139.       if (!isset($_POST['xtitle']) or empty($_POST['xtitle'])) {
  1140.           if (file_exists($xtitle_sem)) {
  1141.               unlink($xtitle_sem);
  1142.           }
  1143.       }
  1144.  
  1145.       $xdate_sem = "$maj_data_directory/items/$maj_req_entry/xdate.txt";
  1146.      
  1147.       if (isset($_POST['xdate']) and !empty($_POST['xdate']) and ($_POST['xdate'] == "on")) {
  1148.           if (!file_exists($xdate_sem)) {
  1149.               touch($xdate_sem);
  1150.           }
  1151.       }
  1152.      
  1153.       if (!isset($_POST['xdate']) or empty($_POST['xdate'])) {
  1154.           if (file_exists($xdate_sem)) {
  1155.               unlink($xdate_sem);
  1156.           }
  1157.       }
  1158.  
  1159.  
  1160.       $xavatar_sem = "$maj_data_directory/items/$maj_req_entry/xavatar.txt";
  1161.      
  1162.       if (isset($_POST['xavatar']) and !empty($_POST['xavatar']) and ($_POST['xavatar'] == "on")) {
  1163.           if (!file_exists($xavatar_sem)) {
  1164.               touch($xavatar_sem);
  1165.           }
  1166.       }
  1167.      
  1168.       if (!isset($_POST['xavatar']) or empty($_POST['xavatar'])) {
  1169.           if (file_exists($xavatar_sem)) {
  1170.               unlink($xavatar_sem);
  1171.           }
  1172.       }
  1173.      
  1174.       $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/lastmod.txt";
  1175.      
  1176.       if (isset($_POST['lastmod']) and !empty($_POST['lastmod']) and ($_POST['lastmod'] == "on")) {
  1177.           if (!file_exists($lastmod_sem)) {
  1178.               touch($lastmod_sem);
  1179.           }
  1180.       }
  1181.      
  1182.       if (!isset($_POST['lastmod']) or empty($_POST['lastmod'])) {
  1183.           if (file_exists($lastmod_sem)) {
  1184.               unlink($lastmod_sem);
  1185.           }
  1186.       }
  1187.  
  1188.  
  1189.       $gl_sem = "$maj_data_directory/items/$maj_req_entry/gl.txt";
  1190.      
  1191.       if (isset($_POST['gl']) and !empty($_POST['gl']) and ($_POST['gl'] == "on")) {
  1192.           if (!file_exists($gl_sem)) {
  1193.               touch($gl_sem);
  1194.           }
  1195.       }
  1196.      
  1197.       if (!isset($_POST['gl']) or empty($_POST['gl'])) {
  1198.           if (file_exists($gl_sem)) {
  1199.               unlink($gl_sem);
  1200.           }
  1201.       }
  1202.  
  1203.       $fb_sem = "$maj_data_directory/items/$maj_req_entry/fb.txt";
  1204.      
  1205.       if (isset($_POST['fb']) and !empty($_POST['fb']) and ($_POST['fb'] == "on")) {
  1206.           if (!file_exists($fb_sem)) {
  1207.               touch($fb_sem);
  1208.           }
  1209.       }
  1210.      
  1211.       if (!isset($_POST['fb']) or empty($_POST['fb'])) {
  1212.           if (file_exists($fb_sem)) {
  1213.               unlink($fb_sem);
  1214.           }
  1215.       }
  1216.  
  1217.         if (isset($_POST['auto_album']) and !empty($_POST['auto_album']) and ($_POST['auto_album'] == "on")) {
  1218.        
  1219.                 if (!file_exists("$maj_data_directory/items/$maj_req_entry/auto-album.txt")) {
  1220.                         touch("$maj_data_directory/items/$maj_req_entry/auto-album.txt");
  1221.                 }
  1222.         }
  1223.        
  1224.         if (!isset($_POST['auto_album']) or empty($_POST['auto_album'])) {
  1225.        
  1226.                 if (file_exists("$maj_data_directory/items/$maj_req_entry/auto-album.txt")) {
  1227.                         unlink("$maj_data_directory/items/$maj_req_entry/auto-album.txt");
  1228.                 }
  1229.         }
  1230.   }  
  1231.  
  1232.   if (file_exists("$maj_data_directory/items/$maj_req_entry/title.old")) {
  1233.       unlink("$maj_data_directory/items/$maj_req_entry/title.old");
  1234.   }
  1235.  
  1236.   if (file_exists("$maj_data_directory/items/$maj_req_entry/body.old")) {
  1237.       unlink("$maj_data_directory/items/$maj_req_entry/body.old");
  1238.   }
  1239.  
  1240.   if (file_exists("$maj_data_directory/ping.txt")) {
  1241.       $ping_urls = explode("|", file_get_contents("$maj_data_directory/ping.txt"));
  1242.      
  1243.       foreach ($ping_urls as $ping_url) {
  1244.           $ping = file_get_contents($ping_url);
  1245.           unset($ping);
  1246.       }
  1247.   }
  1248. ?>
  1249.  
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
33241 downloads
MAJ 1.0
26 files
13223 downloads
MAJ 0.14
45 files
35161 downloads