This blob has been accessed 330 times via Git panel.
- <?php
- session_start();
- header("Cache-control: private");
- error_reporting(E_ERROR);
- if (isset($_SESSION['logged_in']) and ($_SESSION['user_agent'] != $_SERVER['HTTP_USER_AGENT'])) {
- header("Location: login.php");
- }
- if (get_magic_quotes_gpc()) {
- function stripslashes_array($data) {
- if (is_array($data)) {
- foreach ($data as $key => $value){
- $data[$key] = stripslashes_array($value);
- }
- return $data;
- }
- else {
- return stripslashes($data);
- }
- }
- $_POST = stripslashes_array($_POST);
- }
- if (isset($_POST['title_input']) and isset($_POST['body_input']) and !empty($_POST['title_input']) and !empty($_POST['body_input'])) {
- header("Location: index.php");
- }
- if ($_SESSION['logged_in'] == file_get_contents("data/username.txt")) {
- $login_username = file_get_contents("data/username.txt");
- }
- if ($_SESSION['logged_in'] != file_get_contents("data/username.txt")) {
- if (file_exists("data/members/active/{$_SESSION['logged_in']}/category.txt")) {
- $bb_cat = file_get_contents("data/members/active/{$_SESSION['logged_in']}/category.txt");
- if (!file_exists("data/categories/$bb_cat") or ($bb_cat == "")) {
- unlink("data/members/active/{$_SESSION['logged_in']}/category.txt");
- }
- }
- if ((file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt") or file_exists("data/members/active/{$_SESSION['logged_in']}/category.txt")) and file_exists("data/bb.txt") and !file_exists("data/noadd.txt")) {
- $login_username = $_SESSION['logged_in'];
- }
- }
- if (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username)) {
- }
- ?>
- <title>Add</title>
- <style>
- body {
- color: #666666;
- margin: 10px;
- padding: 0px;
- text-align: left;
- font-family: <?php
- if (file_exists("data/fonts/body.txt")) {
- $font_body = file_get_contents("data/fonts/body.txt");
- echo "$font_body,";
- }
- ?> arial, helvetica, sans-serif;
- background-color: #FFFFFF;
- }
- p, td {
- font-size: 11px;
- }
- a {
- font-weight: bold;
- text-decoration: none;
- }
- a:link, a:visited {
- color: #666666;
- }
- a:hover {
- color: #336699;
- }
- a:active {
- color: #336699;
- }
- .input_title {
- color: #666666;
- background: #ffffff;
- border: #999999 solid 1px;
- width: 512px;
- 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,";
- }
- ?> arial, helvetica, sans-serif;
- font-size: 11px;
- font-weight: bold
- }
- .input_body {
- color: #666666;
- background: #ffffff;
- border: #999999 solid 1px;
- width: 512px;
- 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,";
- }
- ?> arial, helvetica, sans-serif;
- font-size: 11px
- }
- </style>
- <?php
- if (file_exists("data/offset.txt")) {
- $offset = file_get_contents("data/offset.txt");
- }
- else {
- $offset = 0;
- }
- function return_bytes($val) {
- $val = trim($val);
- 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;
- }
- ?>
- <form enctype="multipart/form-data" action="add.php" method="post">
- <p>
- <?php
- 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_file_size; ?>">
- <input autocomplete="off" type="file" name="image_input"> Upload optional GIF, JPG, or PNG entry image.</p>
- <p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
- <input autocomplete="off" type="file" name="file_input"> Upload optional file. Max size supported by server is <?php echo ($max_file_size/(1024*1024)); ?>MB.</p>
- <?php } ?>
- <?php
- if ($_SESSION['logged_in'] == file_get_contents("data/username.txt")) {
- ?>
- <select name="select_year">
- <option selected>
- <option><?php echo $entry_year; ?>
- <option><?php $ante_year_1 = $entry_year - 1; echo $ante_year_1; ?>
- <option><?php $ante_year_2 = $entry_year - 2; echo $ante_year_2; ?>
- <option><?php $ante_year_3 = $entry_year - 3; echo $ante_year_3; ?>
- <option><?php $ante_year_4 = $entry_year - 4; echo $ante_year_4; ?>
- <option><?php $ante_year_5 = $entry_year - 5; echo $ante_year_5; ?>
- <option><?php $ante_year_6 = $entry_year - 6; echo $ante_year_6; ?>
- <option><?php $ante_year_7 = $entry_year - 7; echo $ante_year_7; ?>
- <option><?php $ante_year_8 = $entry_year - 8; echo $ante_year_8; ?>
- <option><?php $ante_year_9 = $entry_year - 9; echo $ante_year_9; ?>
- <option><?php $ante_year_10 = $entry_year - 10; echo $ante_year_10; ?>
- </select>
- <select name="select_month">
- <option selected>
- <option><?php echo $entry_month; ?>
- <option>01
- <option>02
- <option>03
- <option>04
- <option>05
- <option>06
- <option>07
- <option>08
- <option>09
- <option>10
- <option>11
- <option>12
- </select>
- <select name="select_day">
- <option selected>
- <option><?php echo $entry_day; ?>
- <option>01
- <option>02
- <option>03
- <option>04
- <option>05
- <option>06
- <option>07
- <option>08
- <option>09
- <option>10
- <option>11
- <option>12
- <option>13
- <option>14
- <option>15
- <option>16
- <option>17
- <option>18
- <option>19
- <option>20
- <option>21
- <option>22
- <option>23
- <option>24
- <option>25
- <option>26
- <option>27
- <option>28
- <option>29
- <option>30
- <option>31
- </select>
- <select name="select_hour">
- <option selected>
- <option><?php echo $entry_hour; ?>
- <option>00
- <option>01
- <option>02
- <option>03
- <option>04
- <option>05
- <option>06
- <option>07
- <option>08
- <option>09
- <option>10
- <option>11
- <option>12
- <option>13
- <option>14
- <option>15
- <option>16
- <option>17
- <option>18
- <option>19
- <option>20
- <option>21
- <option>22
- <option>23
- </select>
- <select name="select_min">
- <option selected>
- <option><?php echo $entry_min; ?>
- <option>00
- <option>01
- <option>02
- <option>03
- <option>04
- <option>05
- <option>06
- <option>07
- <option>08
- <option>09
- <option>10
- <option>11
- <option>12
- <option>13
- <option>14
- <option>15
- <option>16
- <option>17
- <option>18
- <option>19
- <option>20
- <option>21
- <option>22
- <option>23
- <option>24
- <option>25
- <option>26
- <option>27
- <option>28
- <option>29
- <option>30
- <option>31
- <option>32
- <option>33
- <option>34
- <option>35
- <option>36
- <option>37
- <option>38
- <option>39
- <option>40
- <option>41
- <option>42
- <option>43
- <option>44
- <option>45
- <option>46
- <option>47
- <option>48
- <option>49
- <option>50
- <option>51
- <option>52
- <option>53
- <option>54
- <option>55
- <option>56
- <option>57
- <option>58
- <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_file_size; ?>">
- <input autocomplete="off" type="file" name="image_input"> Upload optional GIF, JPG, or PNG entry image.</p>
- <p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
- <input autocomplete="off" type="file" name="file_input"> Upload optional file. Max size supported by server is <?php echo ($max_file_size/(1024*1024)); ?>MB.</p>
- <p><input autocomplete="off" type="password" name="passwd"> Enter optional password.</p>
- <?php
- if (file_exists("data/categories")) {
- if ($dh_cat = opendir("data/categories")) {
- while (($entry_cat = readdir($dh_cat)) !== false) {
- if ($entry_cat != "." && $entry_cat != ".." && fnmatch("*", $entry_cat)) {
- $show_cat[] = $entry_cat;
- }
- }
- closedir($dh_cat);
- }
- sort($show_cat);
- reset($show_cat);
- $count_cat = count($show_cat);
- if ($count_cat > 0) {
- echo "<p><select name=\"category\"><option value=\"\" selected>unfiled";
- foreach ($show_cat as $category) {
- echo "<option value=\"";
- echo strtolower($category);
- echo "\">";
- if (file_exists("data/categories/$category/title.txt")) {
- readfile("data/categories/$category/title.txt");
- }
- else {
- echo strtolower($category);
- }
- }
- echo "</select> Select category.</p>";
- }
- }
- ?>
- <p><input type="checkbox" name="sticky">Put entry title in Quick Links box.<br>
- <input type="checkbox" name="pdf">Allow PDF generation for this entry.<br>
- <input type="checkbox" name="display">Always display. If this is not a private entry, it will be displayed even if its category is hidden or isolated.<br>
- <input type="checkbox" name="private" <?php if (file_exists("data/ml.txt")) { echo checked; } ?>>Private entry. This entry will unconditionally be invisible to visitors<?php if (file_exists("data/ml.txt")) { echo " and to the mailing list"; } ?>, even if always display is set.
- <?php if (file_exists("data/bb.txt")) { ?>
- <br>
- <input type="checkbox" name="member" <?php if (file_exists("data/member.txt")) { echo checked; } ?>>Only registered members can view this entry.
- <?php } ?>
- </p>
- <?php } ?>
- <table border="0" cellspacing="0" cellpadding="0"><tr><td>
- <table border="0" cellspacing="2" cellpadding="0">
- <tr><td><input autocomplete="off" class="input_title" type="text" name="title_input"></td></tr>
- <tr><td><textarea class="input_body" name="body_input" rows="15"></textarea></td></tr>
- <tr><td><input class="input_body" type="submit" value="click here to post this new entry"></td></tr>
- </form>
- <form enctype="multipart/form-data" action="index.php" method="post">
- <tr><td><input class=input_body type=submit value="click here to go to the index page"></td></tr>
- </form>
- </table>
- </td><td width="10"></td><td>
- <table border="0" cellspacing="1" cellpadding="2">
- <tr><td><img src="images/smileys/crying.png" border="0"></td><td><p>:((</p></td><td ><p>crying</p></td></tr>
- <tr><td><img src="images/smileys/frown.png" border="0"></td><td><p>:(</p></td><td><p>frown</p></td></tr>
- <tr><td><img src="images/smileys/indifferent.png" border="0"></td><td><p>:|</p></td><td><p>indifferent</p></td></tr>
- <tr><td><img src="images/smileys/laughing.png" border="0"></td><td><p>:D</p></td><td><p>laughing</p></td></tr>
- <tr><td><img src="images/smileys/lick.png" border="0"></td><td><p>:P</p></td><td><p>lick</p></td></tr>
- <tr><td><img src="images/smileys/ohno.png" border="0"></td><td><p>:O</p></td><td><p>oh no!</p></td></tr>
- <tr><td><img src="images/smileys/smile.png" border="0"></td><td><p>:)</p></td><td><p>smile</p></td></tr>
- <tr><td><img src="images/smileys/surprised.png" border="0"></td><td><p>=)</p></td><td><p>surprised</p></td></tr>
- <tr><td><img src="images/smileys/undecided.png" border="0"></td><td><p>:\</p></td><td><p>undecided</p></td></tr>
- <tr><td><img src="images/smileys/wink.png" border="0"></td><td><p>;)</p></td><td><p>wink</p></td></tr>
- </td></tr>
- </table>
- </td></tr></table>
- <?php
- if (!isset($_POST['title_input']) or !isset($_POST['body_input']) or empty($_POST['title_input']) or empty($_POST['body_input'])) {
- }
- if (!isset($_POST['select_year']) or !isset($_POST['select_month']) or !isset($_POST['select_day']) or !isset($_POST['select_hour']) or !isset($_POST['select_min']) or empty($_POST['select_year']) or empty($_POST['select_month']) or empty($_POST['select_day']) or empty($_POST['select_hour']) or empty($_POST['select_min'])) {
- }
- else {
- $entry = $_POST['select_year'] . $_POST['select_month'] . $_POST['select_day'] . $_POST['select_hour'] . $_POST['select_min'] . $entry_sec;
- $timestamp = date("l, M j, Y, g:i A", mktime($_POST['select_hour'], $_POST['select_min'], $entry_sec, $_POST['select_month'], $_POST['select_day'], $_POST['select_year']));
- }
- if (!file_exists("data/items")) {
- mkdir("data/items");
- }
- $dir = "data/items/";
- $item_dir = $dir . $entry;
- if (!file_exists("images")) {
- mkdir("images");
- }
- $image_dir = 'images/' . $entry;
- $file_dir = $item_dir . '/filedrop';
- function reformat_html($defang_html) {
- $store_html=split("<html>",$defang_html);
- $defang_html="";
- $defang_html.=$store_html[0];
- foreach($store_html as $itm_html=>$refh_html) {
- if(eregi("</html>",$refh_html)) {
- $store_html1=split("</html>",$refh_html);
- $store_html1[0]=eregi_replace("\n","",$store_html1[0]);
- foreach($store_html1 as $itm_html1=>$refh_html1) {
- if($itm_html1==0)
- $refh_html1="<!-- html -->$refh_html1<!-- /html -->";
- $defang_html.=$refh_html1;
- }
- }
- }
- return $defang_html;
- }
- function reformat_code($defang_code) {
- $store_code=split("<code>",$defang_code);
- $defang_code="";
- $defang_code.=$store_code[0];
- foreach($store_code as $itm_code=>$refh_code) {
- if(eregi("</code>",$refh_code)) {
- $store_code1=split("</code>",$refh_code);
- $store_code1[0] = eregi_replace('<img src="images/smileys/crying.png" border="0">',':((',$store_code1[0]);
- $store_code1[0] = eregi_replace('<img src="images/smileys/frown.png" border="0">',':(',$store_code1[0]);
- $store_code1[0] = eregi_replace('<img src="images/smileys/indifferent.png" border="0">',':|',$store_code1[0]);
- $store_code1[0] = eregi_replace('<img src="images/smileys/laughing.png" border="0">',':D',$store_code1[0]);
- $store_code1[0] = eregi_replace('<img src="images/smileys/lick.png" border="0">',':P',$store_code1[0]);
- $store_code1[0] = eregi_replace('<img src="images/smileys/ohno.png" border="0">',':O',$store_code1[0]);
- $store_code1[0] = eregi_replace('<img src="images/smileys/smile.png" border="0">',':)',$store_code1[0]);
- $store_code1[0] = eregi_replace('<img src="images/smileys/surprised.png" border="0">','=)',$store_code1[0]);
- $store_code1[0] = eregi_replace('<img src="images/smileys/undecided.png" border="0">',':\\',$store_code1[0]);
- $store_code1[0] = eregi_replace('<img src="images/smileys/wink.png" border="0">',';)',$store_code1[0]);
- $store_code1[0]=htmlentities($store_code1[0],ENT_NOQUOTES);
- foreach($store_code1 as $itm_code1=>$refh_code1) {
- if($itm_code1==0)
- $refh_code1="<code>$refh_code1</code>";
- $defang_code.=$refh_code1;
- }
- }
- }
- return $defang_code;
- }
- $body_write_content = ucfirst($_POST['body_input']);
- $body_write_content = str_replace("[html]", '<html>', $body_write_content);
- $body_write_content = str_replace("[/html]", '</html>', $body_write_content);
- $body_write_content = reformat_html($body_write_content);
- $body_write_content = str_replace(':((', '<img src="images/smileys/crying.png" border="0">', $body_write_content);
- $body_write_content = str_replace(':(', '<img src="images/smileys/frown.png" border="0">', $body_write_content);
- $body_write_content = str_replace(':|', '<img src="images/smileys/indifferent.png" border="0">', $body_write_content);
- $body_write_content = str_replace(':D', '<img src="images/smileys/laughing.png" border="0">', $body_write_content);
- $body_write_content = str_replace(':P', '<img src="images/smileys/lick.png" border="0">', $body_write_content);
- $body_write_content = str_replace(':O', '<img src="images/smileys/ohno.png" border="0">', $body_write_content);
- $body_write_content = str_replace(':)', '<img src="images/smileys/smile.png" border="0">', $body_write_content);
- $body_write_content = str_replace('=)', '<img src="images/smileys/surprised.png" border="0">', $body_write_content);
- $body_write_content = str_replace(':\\', '<img src="images/smileys/undecided.png" border="0">', $body_write_content);
- $body_write_content = str_replace(';)', '<img src="images/smileys/wink.png" border="0">', $body_write_content);
- $body_write_content = str_replace('[code]', '<code>', $body_write_content);
- $body_write_content = str_replace('[/code]', '</code>', $body_write_content);
- $body_write_content = reformat_code($body_write_content);
- $body_write_content = str_replace("\n", '<br />', $body_write_content);
- $body_write_content = str_replace('[b]', '<b>', $body_write_content);
- $body_write_content = str_replace('[/b]', '</b>', $body_write_content);
- $body_write_content = str_replace('[i]', '<i>', $body_write_content);
- $body_write_content = str_replace('[/i]', '</i>', $body_write_content);
- $body_write_content = str_replace('[u]', '<u>', $body_write_content);
- $body_write_content = str_replace('[/u]', '</u>', $body_write_content);
- $body_write_content = str_replace('[strike]', '<strike>', $body_write_content);
- $body_write_content = str_replace('[/strike]', '</strike>', $body_write_content);
- $body_write_content = str_replace('[sup]', '<sup>', $body_write_content);
- $body_write_content = str_replace('[/sup]', '</sup>', $body_write_content);
- $body_write_content = str_replace('[sub]', '<sub>', $body_write_content);
- $body_write_content = str_replace('[/sub]', '</sub>', $body_write_content);
- $body_write_content = str_replace('[highlight]', '<highlight>', $body_write_content);
- $body_write_content = str_replace('[/highlight]', '</highlight>', $body_write_content);
- $body_write_content = str_replace('<highlight>', '<span style="background-color: #ffff00;">', $body_write_content);
- $body_write_content = str_replace('</highlight>', '</span>', $body_write_content);
- $body_write_content = preg_replace("/<([_\.0-9a-z-]+)@([0-9a-z][0-9a-z-]+)\.([_\.0-9a-z-]+)>/", '<$1@$2.$3>',$body_write_content);
- mkdir($item_dir);
- // 20100113 - auto-captialize title except articles, prepositions and conjunctions less tha 4 letters, and particle "to"
- $title_write_content = ucwords($_POST['title_input']);
- $title_write_content = str_replace('<','<',$title_write_content);
- $title_write_content = str_replace('>','>',$title_write_content);
- $title_write_content = str_replace(' A ',' a ',$title_write_content);
- $title_write_content = str_replace(' An ',' an ',$title_write_content);
- $title_write_content = str_replace(' And ',' and ',$title_write_content);
- $title_write_content = str_replace(' As ',' as ',$title_write_content);
- $title_write_content = str_replace(' At ',' at ',$title_write_content);
- $title_write_content = str_replace(' But ',' but ',$title_write_content);
- $title_write_content = str_replace(' By ',' by ',$title_write_content);
- $title_write_content = str_replace(' For ',' for ',$title_write_content);
- $title_write_content = str_replace(' In ',' in ',$title_write_content);
- $title_write_content = str_replace(' Of ',' of ',$title_write_content);
- $title_write_content = str_replace(' On ',' on ',$title_write_content);
- $title_write_content = str_replace(' Or ',' or ',$title_write_content);
- $title_write_content = str_replace(' The ',' the ',$title_write_content);
- $title_write_content = str_replace(' To ',' to ',$title_write_content);
- $title_file = $item_dir . '/title.txt';
- $author_file = $item_dir . '/author.txt';
- if (file_get_contents("data/username.txt") == $_SESSION['logged_in']) {
- $post_file = "data/lastpost.txt";
- }
- elseif (file_exists("data/members/active/{$_SESSION['logged_in']}")) {
- $post_file = "data/members/active/{$_SESSION['logged_in']}/bb-post.txt";
- }
- $date_file = $item_dir . '/date.txt';
- 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_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")) {
- if (!file_exists($image_dir)) {
- mkdir($image_dir);
- }
- $image_input_name = str_replace(" ","_",$_FILES['image_input']['name']);
- if (!file_exists("$image_dir/$image_input_name")) {
- $res = copy($_FILES['image_input']['tmp_name'], "$image_dir/$image_input_name");
- unlink($_FILES['image_input']['tmp_name']);
- }
- else {
- unlink($_FILES['image_input']['tmp_name']);
- }
- }
- else {
- unlink($_FILES['image_input']['tmp_name']);
- }
- }
- else {
- unlink($_FILES['image_input']['tmp_name']);
- }
- }
- else {
- unlink($_FILES['image_input']['tmp_name']);
- }
- }
- if (isset($_FILES['file_input']) and !empty($_FILES['file_input'])) {
- if (is_uploaded_file($_FILES['file_input']['tmp_name'])) {
- if ($_FILES['file_input']['size']<=$max_file_size) {
- $filedrop_dir = "$item_dir/filedrop";
- if (!file_exists($filedrop_dir)) {
- mkdir($filedrop_dir);
- }
- $file_dir = "$filedrop_dir/files";
- if (!file_exists($file_dir)) {
- mkdir($file_dir);
- }
- $file_input_name = str_replace(" ","_",$_FILES['file_input']['name']);
- if (!file_exists("$file_dir/$file_input_name")) {
- $res = copy($_FILES['file_input']['tmp_name'], "$file_dir/$file_input_name");
- unlink($_FILES['file_input']['tmp_name']);
- }
- else {
- unlink($_FILES['file_input']['tmp_name']);
- }
- }
- else {
- unlink($_FILES['file_input']['tmp_name']);
- }
- }
- else {
- unlink($_FILES['file_input']['tmp_name']);
- }
- }
- $body_file = "$item_dir/body.txt";
- if (isset($_FILES['image_input']) and !empty($_FILES['image_input'])) {
- if (file_exists("$image_dir/$image_input_name")) {
- $entry_image_size = getimagesize("$image_dir/$image_input_name");
- $entry_image_width = $entry_image_size[0];
- $entry_image_height = $entry_image_size[1];
- $max_entry_image_width = 513;
- if ($entry_image_width > $max_entry_image_width) {
- $sizefactor = (double) ($max_entry_image_width / $entry_image_width) ;
- $entry_image_width = (int) ($entry_image_width * $sizefactor);
- $entry_image_height = (int) ($entry_image_height * $sizefactor);
- }
- $body_write_content = "<img src=\"$image_dir/$image_input_name\" border=\"0\" width=\"$entry_image_width\" height=\"$entry_image_height\"><br>$body_write_content";
- }
- }
- $sticky_sem = "data/sticky/$entry";
- if (isset($_POST['sticky']) and !empty($_POST['sticky']) and ($_POST['sticky'] == "on")) {
- if (!file_exists("data/sticky")) {
- mkdir("data/sticky");
- }
- if (!file_exists($sticky_sem)) {
- touch($sticky_sem);
- }
- }
- $display_sem = "data/items/$entry/cat.txt";
- if (isset($_POST['display']) and !empty($_POST['display']) and ($_POST['display'] == "on")) {
- if (!file_exists($display_sem)) {
- touch($display_sem);
- }
- }
- $private_sem = "data/items/$entry/private.txt";
- if (isset($_POST['private']) and !empty($_POST['private']) and ($_POST['private'] == "on")) {
- if (!file_exists($private_sem)) {
- touch($private_sem);
- }
- }
- if (file_exists("data/bb.txt") and file_exists("data/member.txt") and (($_SESSION['logged_in'] != file_get_contents("data/username.txt")) or (isset($_POST['member']) and !empty($_POST['member']) and ($_POST['member'] == "on")))) {
- touch("data/items/$entry/member.txt");
- }
- if (file_exists("data/members/active") and file_exists("data/ml.txt") and file_exists("data/email.txt") and !file_exists($private_sem)) {
- if (file_exists("data/ml-reply2.txt")) {
- $ml_reply2 = file_get_contents("data/ml-reply2.txt");
- }
- if ($_SESSION['logged_in'] == file_get_contents("data/username.txt")) {
- $ml_author = file_get_contents("data/author.txt");
- if (file_exists("data/ml-from.txt")) {
- $ml_from = $ml_reply2;
- }
- else {
- $ml_from = file_get_contents("data/email.txt");
- }
- $ml_from = '"' . $ml_author . '" <' . $ml_from . '>';
- }
- if ($_SESSION['logged_in'] != file_get_contents("data/username.txt")) {
- if (file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt") and file_exists("data/bb.txt")) {
- $ml_from_firstname = file_get_contents("data/members/active/{$_SESSION['logged_in']}/firstname.txt");
- $ml_from_lastname = file_get_contents("data/members/active/{$_SESSION['logged_in']}/lastname.txt");
- if (file_exists("data/ml-from.txt")) {
- $ml_from = $ml_reply2;
- }
- else {
- $ml_from = file_get_contents("data/members/active/{$_SESSION['logged_in']}/email.txt");
- }
- $ml_from = '"' . "$ml_from_firstname $ml_from_lastname" . '" <' . $ml_from . '>';
- }
- }
- $ml_subject = ucfirst($_POST['title_input']);
- if (file_exists("data/ml-prepend.txt")) {
- $ml_subject = file_get_contents("data/ml-prepend.txt") . " " . $ml_subject;
- }
- $ml_mailer = 'MAJ/0.14 (PHP/' . phpversion() . ')';
- $ml_body = ucfirst($_POST['body_input']);
- $ml_body = str_replace('<br />', "\n", $ml_body);
- $ml_body = str_replace('<img src="images/smileys/crying.png" border="0">', ':((', $ml_body);
- $ml_body = str_replace('<img src="images/smileys/frown.png" border="0">', ':(', $ml_body);
- $ml_body = str_replace('<img src="images/smileys/indifferent.png" border="0">', ':|', $ml_body);
- $ml_body = str_replace('<img src="images/smileys/laughing.png" border="0">', ':D', $ml_body);
- $ml_body = str_replace('<img src="images/smileys/lick.png" border="0">', ':P', $ml_body);
- $ml_body = str_replace('<img src="images/smileys/ohno.png" border="0">', ':O', $ml_body);
- $ml_body = str_replace('<img src="images/smileys/smile.png" border="0">', ':)', $ml_body);
- $ml_body = str_replace('<img src="images/smileys/surprised.png" border="0">', '=)', $ml_body);
- $ml_body = str_replace('<img src="images/smileys/undecided.png" border="0">', ':\\', $ml_body);
- $ml_body = str_replace('<img src="images/smileys/wink.png" border="0">', ';)', $ml_body);
- $ml_body = str_replace('&','&',$ml_body);
- $ml_body = str_replace('®','(R)',$ml_body);
- $ml_body = strip_tags($ml_body);
- if (file_exists("data/ml-header.txt")) {
- $ml_header = file_get_contents("data/ml-header.txt");
- $ml_body = $ml_header . "\n\n" . $ml_body;
- }
- $ml_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/";
- $ml_url = str_replace('//', '/', $ml_url);
- $ml_url = "http://" . $ml_url . "index.php?entry={$entry}&show=comments";
- $ml_body = $ml_body . "\n\nPlease visit the following URL for the online version of this message:\n\n" . $ml_url;
- if (file_exists("data/items/$entry/member.txt")) {
- $ml_body = $ml_body . "\n\nYou need to login first to view the entry or to add a comment.";
- }
- if (file_exists("data/ml-footer.txt")) {
- $ml_footer = file_get_contents("data/ml-footer.txt");
- $ml_body = $ml_body . "\n\n" . $ml_footer;
- }
- if ($dh_ml_member = opendir("data/members/active")) {
- while (($ml_member = readdir($dh_ml_member)) !== false) {
- if ($ml_member != "." && $ml_member != ".." && fnmatch("*", $ml_member)) {
- if (file_exists("data/members/active/$ml_member/noml.txt")) {
- continue;
- }
- if (file_exists("data/members/active/$ml_member/vacation.txt")) {
- continue;
- }
- $ml_to_firstname = file_get_contents("data/members/active/$ml_member/firstname.txt");
- $ml_to_lastname = file_get_contents("data/members/active/$ml_member/lastname.txt");
- $ml_to = file_get_contents("data/members/active/$ml_member/email.txt");
- $ml_to = '"' . "$ml_to_firstname $ml_to_lastname" . '" <' . $ml_to . '>';
- if (file_exists("data/ml-reply2.txt")) {
- mail($ml_to, $ml_subject, $ml_body,
- "From: $ml_from\r\n" .
- "Reply-To: $ml_reply2\r\n" .
- "References: $entry\r\n" .
- "X-Mailer: $ml_mailer");
- }
- else {
- mail($ml_to, $ml_subject, $ml_body,
- "From: $ml_from\r\n" .
- "References: $entry\r\n" .
- "X-Mailer: $ml_mailer");
- }
- }
- }
- closedir($dh_ml_member);
- }
- }
- if (isset($_POST['pdf']) and !empty($_POST['pdf']) and ($_POST['pdf'] == "on")) {
- if (!file_exists("data/items/$entry/pdf")) {
- mkdir("data/items/$entry/pdf");
- }
- if (!file_exists("data/items/$entry/pdf/file")) {
- mkdir("data/items/$entry/pdf/file");
- }
- if (!file_exists("data/items/$entry/pdf/count")) {
- mkdir("data/items/$entry/pdf/count");
- }
- $author_file = "data/author.txt";
- $title_file = "data/items/$entry/title.txt";
- $date_file = "data/items/$entry/date.txt";
- $body_file = "data/items/$entry/body.txt";
- $author = file_get_contents($author_file);
- $title = file_get_contents($title_file);
- $date = file_get_contents($date_file);
- $link = "<a href=\"http://{$_SERVER['SERVER_NAME']}{$_SERVER['PHP_SELF']}?entry=$entry\">http://{$_SERVER['SERVER_NAME']}{$_SERVER['PHP_SELF']}?entry=$entry</a>";
- $link = str_replace("pdf.php?entry=","index.php?entry=",$link);
- $link = str_replace("add.php?entry=","index.php?entry=",$link);
- $body = file_get_contents($body_file);
- $body = str_replace("\n","<br />",$body);
- $html = "<br><i>by $author</i><br><br>$date<br><br>Canonical Source<br>$link<br><br><br>$body";
- $filename = strtolower($title);
- $filename = strtolower($_SERVER['SERVER_NAME']) . "-" . $entry . "-" . $filename . ".pdf";
- $filename = str_replace(" ","-",$filename);
- $filename = "data/items/$entry/pdf/file/$filename";
- require('fpdf.php');
- class PDF extends FPDF
- {
- var $B;
- var $I;
- var $U;
- var $HREF;
- function PDF($orientation='P',$unit='mm',$format='letter')
- {
- $this->FPDF($orientation,$unit,$format);
- $this->B=0;
- $this->I=0;
- $this->U=0;
- $this->HREF='';
- }
- function WriteHTML($html)
- {
- $html=str_replace("\n",' ',$html);
- $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
- foreach($a as $i=>$e)
- {
- if($i%2==0)
- {
- if($this->HREF)
- $this->PutLink($this->HREF,$e);
- else
- $this->Write(5,$e);
- }
- else
- {
- if($e{0}=='/')
- $this->CloseTag(strtoupper(substr($e,1)));
- else
- {
- $a2=explode(' ',$e);
- $tag=strtoupper(array_shift($a2));
- $attr=array();
- foreach($a2 as $v)
- if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3))
- $attr[strtoupper($a3[1])]=$a3[2];
- $this->OpenTag($tag,$attr);
- }
- }
- }
- }
- function OpenTag($tag,$attr)
- {
- if($tag=='B' or $tag=='I' or $tag=='U')
- $this->SetStyle($tag,true);
- if($tag=='A')
- $this->HREF=$attr['HREF'];
- if($tag=='BR')
- $this->Ln(5);
- }
- function CloseTag($tag)
- {
- if($tag=='B' or $tag=='I' or $tag=='U')
- $this->SetStyle($tag,false);
- if($tag=='A')
- $this->HREF='';
- }
- function SetStyle($tag,$enable)
- {
- $this->$tag+=($enable ? 1 : -1);
- $style='';
- foreach(array('B','I','U') as $s)
- if($this->$s>0)
- $style.=$s;
- $this->SetFont('',$style);
- }
- function PutLink($URL,$txt)
- {
- $this->SetTextColor(0,0,255);
- $this->SetStyle('U',true);
- $this->Write(5,$txt,$URL);
- $this->SetStyle('U',false);
- $this->SetTextColor(0);
- }
- }
- $pdf=new PDF();
- $pdf->AddPage();
- $pdf->SetTitle($title);
- $pdf->SetAuthor($author);
- $pdf->SetFont('Helvetica','B',14);
- $pdf->WriteHTML($title);
- $pdf->SetFont('Helvetica','',10);
- $pdf->WriteHTML($html);
- $pdf->Output($filename);
- }
- if (isset($_POST['category']) and !empty($_POST['category']) and file_exists("data/categories/{$_POST['category']}")) {
- if (!file_exists("data/items/$entry/categories")) {
- mkdir("data/items/$entry/categories");
- }
- if (!file_exists("data/items/$entry/categories/{$_POST['category']}")) {
- mkdir("data/items/$entry/categories/{$_POST['category']}");
- }
- }
- if (file_exists("data/members/active/{$_SESSION['logged_in']}/category.txt") and file_exists("data/bb.txt")) {
- $bb_cat = file_get_contents("data/members/active/{$_SESSION['logged_in']}/category.txt");
- if (file_exists("data/categories/$bb_cat")) {
- if (!file_exists("data/items/$entry/categories")) {
- mkdir("data/items/$entry/categories");
- }
- if (!file_exists("data/items/$entry/categories/$bb_cat")) {
- mkdir("data/items/$entry/categories/$bb_cat");
- }
- }
- }
- if (isset($_POST['passwd']) and !empty($_POST['passwd'])) {
- if (($_POST['passwd'] == "password") or empty($_POST['passwd'])) {
- unlink("data/items/$entry/passwd.txt");
- }
- else {
- $passwd_crypt = sha1($_POST['passwd']);
- $passwd_crypt = md5($passwd_crypt);
- $passwd_crypt = crypt($passwd_crypt, $passwd_crypt);
- }
- }
- if (file_exists("data/ping.txt")) {
- $ping_urls = file_get_contents("data/ping.txt");
- $get_ping_urls = explode("|", $ping_urls);
- foreach ($get_ping_urls as $ping_url) {
- $ping = file_get_contents($ping_url);
- unset($ping);
- }
- }
- ?>