This commit has been accessed 539 times via Git panel.
commit 6a45f462755236d8343e805c72445e88859bab43
tree 8b4cf2a0e46b2b7e74fc3ba8f4d8e4091c7b5bf0
parent 1fc9d7d9987989d167d2bee454afc0d5e8c0132b
author Engels Antonio <engels@majcms.org> 1277314192 +0800
committer Engels Antonio <engels@majcms.org> 1277314192 +0800
maj-0.14-20071204-bb.zip
diff --git a/edit.php b/edit.php
index 7e41985..579644a 100644
--- a/edit.php
+++ b/edit.php
@@ -22,6 +22,33 @@ if (get_magic_quotes_gpc()) {
$login_username = file_get_contents("data/username.txt");
+if (isset($_REQUEST['title_input']) and isset($_REQUEST['body_input'])) {
+ header("Location: http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?entry=" . $_REQUEST['entry']);
+}
+
+if (!isset($_REQUEST['entry'])) {
+ exit();
+}
+
+if (!isset($_SESSION['logged_in'])) {
+ exit();
+}
+
+$do = 0;
+
+if ($_SESSION['logged_in'] == $login_username) {
+ $do = 1;
+}
+
+
+if (file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt") and file_exists("data/wiki.txt") and file_exists("data/items/{$_REQUEST['entry']}/edit.txt")) {
+ $do = 1;
+}
+
+if ($do == 0) {
+ exit();
+}
+
function rmdirr($recurse_dirname) {
if (!file_exists($recurse_dirname)) {
@@ -46,18 +73,6 @@ function rmdirr($recurse_dirname) {
return rmdir($recurse_dirname);
}
-if (isset($_REQUEST['title_input']) and isset($_REQUEST['body_input'])) {
- header("Location: http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?entry=" . $_REQUEST['entry']);
-}
-
-if (!isset($_REQUEST['entry'])) {
- exit();
-}
-
-if (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username)) {
- exit();
-}
-
$title_file = 'data/items/' . $_REQUEST['entry'] . '/title.txt';
$body_file = 'data/items/' . $_REQUEST['entry'] . '/body.txt';
$date_file = 'data/items/' . $_REQUEST['entry'] . '/date.txt';
@@ -345,82 +360,113 @@ if (file_exists("data/items/{$_REQUEST['entry']}/category.txt")) {
<p>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
-<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_image_size; ?>">
-<input autocomplete=off type=file name=album_image_input> Upload optional album image. Enter optional caption below.</p>
-<p><input autocomplete=off type=text name=caption class=input_body></p>
-<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
-<input autocomplete=off type=file name=entry_image_input> Upload optional 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.</p>
-<p><input autocomplete=off type=password name=passwd <?php
-
-if (file_exists("data/items/{$_REQUEST['entry']}/passwd.txt")) {
- echo "value=password";
-}
+
+<?php if (($_SESSION['logged_in'] == $login_username) or (file_exists("data/members/active/{$_SESSION['logged_in']}/ul.txt") and file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt"))) { ?>
+
+ <p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_image_size; ?>">
+ <input autocomplete=off type=file name=album_image_input> Upload optional album image. Enter optional caption below.</p>
+ <p><input autocomplete=off type=text name=caption class=input_body></p>
+ <p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
+ <input autocomplete=off type=file name=entry_image_input> Upload optional 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.</p>
+
+<?php
+
+}
+
+if ($_SESSION['logged_in'] == $login_username) {
+
?>
-> <?php
+ <p><input autocomplete=off type=password name=passwd <?php
-if (file_exists("data/items/{$_REQUEST['entry']}/passwd.txt")) {
- echo "Enter new password or clear field to disable password protection.";
-}
-else {
- echo "Enter optional password.";
-}
-?></p>
+ if (file_exists("data/items/{$_REQUEST['entry']}/passwd.txt")) {
+ echo "value=password";
+ }
+ ?>
-<?php
- if (file_exists("data/categories")) {
- if ($dh_cat = opendir("data/categories")) {
- while (($entry_cat = readdir($dh_cat)) !== false) {
+ > <?php
+
+ if (file_exists("data/items/{$_REQUEST['entry']}/passwd.txt")) {
+ echo "Enter new password or clear field to disable password protection.";
+ }
+ else {
+ echo "Enter optional password.";
+ }
+ ?></p>
- if ($entry_cat != "." && $entry_cat != ".." && fnmatch("*", $entry_cat)) {
- $show_cat[] = $entry_cat;
+ <?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 selected>";
+ if (file_exists("data/items/{$_REQUEST['entry']}/category.txt")) {
+ readfile("data/items/{$_REQUEST['entry']}/category.txt");
+ echo '<option>unfiled';
+ }
+ else {
+ echo "unfiled";
}
+
+
+ foreach ($show_cat as $category) {
+ echo "<option>";
+ echo strtolower($category);
+ }
+
+ echo "</select> Select category.</p>";
+
}
- closedir($dh_cat);
}
+ ?>
+ <p><input type=checkbox name=sticky <?php $sticky_sem = 'data/sticky/' . $_REQUEST['entry']; if (file_exists($sticky_sem)) { echo checked; } ?>>Put entry title in Quick Links box.<br>
+ <input type=checkbox name=pdf <?php if (file_exists("data/items/{$_REQUEST['entry']}/pdf/file")) { echo checked; } ?>>Allow PDF generation for this entry.<br>
+ <input type=checkbox name=display <?php $display_sem = "data/items/{$_REQUEST['entry']}/cat.txt"; if (file_exists($display_sem)) { echo checked; } ?>>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 $private_sem = "data/items/{$_REQUEST['entry']}/private.txt"; if (file_exists($private_sem)) { 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.
- sort($show_cat);
- reset($show_cat);
- $count_cat = count($show_cat);
+ <?php if (file_exists("data/bb.txt")) { ?>
+ <br>
+ <input type=checkbox name=member <?php $member_sem = "data/items/{$_REQUEST['entry']}/member.txt"; if (file_exists($member_sem)) { echo checked; } ?>>Only registered members can view this entry.
- if ($count_cat > 0) {
+ <?php } ?>
- echo "<p><select name=category><option selected>";
- if (file_exists("data/items/{$_REQUEST['entry']}/category.txt")) {
- readfile("data/items/{$_REQUEST['entry']}/category.txt");
- echo '<option>unfiled';
- }
- else {
- echo "unfiled";
- }
+ <?php
+ // start of wiki mod (20071130)
- foreach ($show_cat as $category) {
- echo "<option>";
- echo strtolower($category);
- }
+ if (file_exists("data/bb.txt") and file_exists("data/wiki.txt")) { ?>
+ <br>
+ <input type=checkbox name=edit <?php $edit_sem = "data/items/{$_REQUEST['entry']}/edit.txt"; if (file_exists($edit_sem)) { echo checked; } ?>>Registered members can edit this entry.
- echo "</select> Select category.</p>";
+ <?php
- }
- }
-?>
-<p><input type=checkbox name=sticky <?php $sticky_sem = 'data/sticky/' . $_REQUEST['entry']; if (file_exists($sticky_sem)) { echo checked; } ?>>Put entry title in Quick Links box.<br>
-<input type=checkbox name=pdf <?php if (file_exists("data/items/{$_REQUEST['entry']}/pdf/file")) { echo checked; } ?>>Allow PDF generation for this entry.<br>
-<input type=checkbox name=display <?php $display_sem = "data/items/{$_REQUEST['entry']}/cat.txt"; if (file_exists($display_sem)) { echo checked; } ?>>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 $private_sem = "data/items/{$_REQUEST['entry']}/private.txt"; if (file_exists($private_sem)) { 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.
+ // end of wiki mod (20071130)
-<?php if (file_exists("data/bb.txt")) { ?>
-<br>
-<input type=checkbox name=member <?php $member_sem = "data/items/{$_REQUEST['entry']}/member.txt"; if (file_exists($member_sem)) { echo checked; } ?>>Only registered members can view this entry.
+ }
-<?php } ?>
+ ?>
+
+ <br><input type=checkbox name=lastmod <?php $lastmod_sem = "data/items/{$_REQUEST['entry']}/lastmod.txt"; if (file_exists($lastmod_sem)) { echo checked; } ?>>Display last modification date and time.
-<br><input type=checkbox name=lastmod <?php $lastmod_sem = "data/items/{$_REQUEST['entry']}/lastmod.txt"; if (file_exists($lastmod_sem)) { echo checked; } ?>>Display last modification date and time.
+ </p>
+
+<?php } ?>
-</p>
<input type=hidden name=entry value="<?php echo $_REQUEST['entry']; ?>">
<table border=0 cellspacing=0 cellpadding=0><tr><td>
@@ -769,247 +815,313 @@ if (isset($_FILES['file_input']) and !empty($_FILES['file_input'])) {
}
}
-$open_body_file = fopen($body_file,"w");
-fwrite($open_body_file,$body_write_content);
-fclose($open_body_file);
+// start of wiki mod (20071130)
-$sticky_sem = 'data/sticky/' . $_REQUEST['entry'];
-if (isset($_REQUEST['sticky']) and !empty($_REQUEST['sticky']) and ($_REQUEST['sticky'] == "on")) {
- if (!file_exists("data/sticky")) {
- mkdir("data/sticky");
- }
- if (!file_exists($sticky_sem)) {
- touch($sticky_sem);
- }
-}
-if (!isset($_REQUEST['sticky']) or empty($_REQUEST['sticky'])) {
- if (file_exists($sticky_sem)) {
- unlink($sticky_sem);
- }
-}
+$title_get_content = ucfirst($_REQUEST['title_input']);
+$title_get_content = str_replace('<','<',$title_get_content);
+$title_get_content = str_replace('>','>',$title_get_content);
-$display_sem = "data/items/{$_REQUEST['entry']}/cat.txt";
-if (isset($_REQUEST['display']) and !empty($_REQUEST['display']) and ($_REQUEST['display'] == "on")) {
- if (!file_exists($display_sem)) {
- touch($display_sem);
- }
-}
-if (!isset($_REQUEST['display']) or empty($_REQUEST['display'])) {
- if (file_exists($display_sem)) {
- unlink($display_sem);
- }
-}
+if (file_exists("data/wiki.txt") and (($title_get_content != file_get_contents("data/items/{$_REQUEST['entry']}/title.txt")) or ($body_write_content != file_get_contents("data/items/{$_REQUEST['entry']}/body.txt")))) {
-$private_sem = "data/items/{$_REQUEST['entry']}/private.txt";
-if (isset($_REQUEST['private']) and !empty($_REQUEST['private']) and ($_REQUEST['private'] == "on")) {
- if (!file_exists($private_sem)) {
- touch($private_sem);
+ if (!file_exists("data/items/{$_REQUEST['entry']}/wiki")) {
+ mkdir("data/items/{$_REQUEST['entry']}/wiki");
}
-}
-if (!isset($_REQUEST['private']) or empty($_REQUEST['private'])) {
- if (file_exists($private_sem)) {
- unlink($private_sem);
+
+ if (!file_exists("data/items/{$_REQUEST['entry']}/wiki/delta")) {
+ mkdir("data/items/{$_REQUEST['entry']}/wiki/delta");
}
-}
-$member_sem = "data/items/{$_REQUEST['entry']}/member.txt";
-if (isset($_REQUEST['member']) and !empty($_REQUEST['member']) and ($_REQUEST['member'] == "on")) {
- if (!file_exists($member_sem)) {
- touch($member_sem);
+ if (file_exists("data/offset.txt")) {
+ $offset = file_get_contents("data/offset.txt");
}
-}
-if (!isset($_REQUEST['member']) or empty($_REQUEST['member'])) {
- if (file_exists($member_sem)) {
- unlink($member_sem);
+ else {
+ $offset = 0;
}
-}
-$lastmod_sem = "data/items/{$_REQUEST['entry']}/lastmod.txt";
-if (isset($_REQUEST['lastmod']) and !empty($_REQUEST['lastmod']) and ($_REQUEST['lastmod'] == "on")) {
- if (!file_exists($lastmod_sem)) {
- touch($lastmod_sem);
+ $ddate = date("YmdHis", time() + $offset);
+
+ if (!file_exists("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate")) {
+ mkdir("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate");
}
-}
-if (!isset($_REQUEST['lastmod']) or empty($_REQUEST['lastmod'])) {
- if (file_exists($lastmod_sem)) {
- unlink($lastmod_sem);
+
+ copy("data/items/{$_REQUEST['entry']}/author.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/author.txt");
+ copy("data/items/{$_REQUEST['entry']}/body.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/body.txt");
+ copy("data/items/{$_REQUEST['entry']}/date.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/date.txt");
+ copy("data/items/{$_REQUEST['entry']}/title.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/title.txt");
+
+ if (file_exists("data/items/{$_REQUEST['entry']}/contrib.txt")) {
+ copy("data/items/{$_REQUEST['entry']}/contrib.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/contrib.txt");
}
}
-if (isset($_REQUEST['pdf']) and !empty($_REQUEST['pdf']) and ($_REQUEST['pdf'] == "on")) {
- if (!file_exists("data/items/{$_REQUEST['entry']}/pdf")) {
- mkdir("data/items/{$_REQUEST['entry']}/pdf");
- }
- if (!file_exists("data/items/{$_REQUEST['entry']}/pdf/file")) {
- mkdir("data/items/{$_REQUEST['entry']}/pdf/file");
- }
- if (!file_exists("data/items/{$_REQUEST['entry']}/pdf/count")) {
- mkdir("data/items/{$_REQUEST['entry']}/pdf/count");
- }
+// end of wiki mod (20071130)
- $entry = $_REQUEST['entry'];
- $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";
+$open_body_file = fopen($body_file,"w");
+fwrite($open_body_file,$body_write_content);
+fclose($open_body_file);
- $author = file_get_contents($author_file);
- $title = file_get_contents($title_file);
- $date = file_get_contents($date_file);
+// start of wiki mod (20071130)
- $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);
+if (file_exists("data/wiki.txt") and file_exists("data/items/{$_REQUEST['entry']}/edit.txt")) {
+ $open_contrib_file = fopen("data/items/{$_REQUEST['entry']}/contrib.txt","w");
+ fwrite($open_contrib_file,$_SESSION['logged_in']);
+ fclose($open_contrib_file);
+}
- $body = file_get_contents($body_file);
- $body = str_replace("\n","<br>",$body);
+// end of wiki mod (20071130)
- $html = "<br><i>by $author</i><br><br>$date<br><br>Canonical Source<br>$link<br><br><br>$body";
+if ($_SESSION['logged_in'] == $login_username) {
- $filename = strtolower($title);
- $filename = strtolower($_SERVER['SERVER_NAME']) . "-" . $entry . "-" . $filename . ".pdf";
- $filename = str_replace(" ","-",$filename);
- $filename = "data/items/$entry/pdf/file/$filename";
+ $sticky_sem = 'data/sticky/' . $_REQUEST['entry'];
+ if (isset($_REQUEST['sticky']) and !empty($_REQUEST['sticky']) and ($_REQUEST['sticky'] == "on")) {
+ if (!file_exists("data/sticky")) {
+ mkdir("data/sticky");
+ }
+ if (!file_exists($sticky_sem)) {
+ touch($sticky_sem);
+ }
+ }
+ if (!isset($_REQUEST['sticky']) or empty($_REQUEST['sticky'])) {
+ if (file_exists($sticky_sem)) {
+ unlink($sticky_sem);
+ }
+ }
- require('fpdf.php');
+ $display_sem = "data/items/{$_REQUEST['entry']}/cat.txt";
+ if (isset($_REQUEST['display']) and !empty($_REQUEST['display']) and ($_REQUEST['display'] == "on")) {
+ if (!file_exists($display_sem)) {
+ touch($display_sem);
+ }
+ }
+ if (!isset($_REQUEST['display']) or empty($_REQUEST['display'])) {
+ if (file_exists($display_sem)) {
+ unlink($display_sem);
+ }
+ }
- class PDF extends FPDF
- {
- var $B;
- var $I;
- var $U;
- var $HREF;
-
- function PDF($orientation='P',$unit='mm',$format='letter')
- {
- //Call parent constructor
- $this->FPDF($orientation,$unit,$format);
- //Initialization
- $this->B=0;
- $this->I=0;
- $this->U=0;
- $this->HREF='';
+ $private_sem = "data/items/{$_REQUEST['entry']}/private.txt";
+ if (isset($_REQUEST['private']) and !empty($_REQUEST['private']) and ($_REQUEST['private'] == "on")) {
+ if (!file_exists($private_sem)) {
+ touch($private_sem);
+ }
+ }
+ if (!isset($_REQUEST['private']) or empty($_REQUEST['private'])) {
+ if (file_exists($private_sem)) {
+ unlink($private_sem);
}
+ }
+
+ $member_sem = "data/items/{$_REQUEST['entry']}/member.txt";
+ if (isset($_REQUEST['member']) and !empty($_REQUEST['member']) and ($_REQUEST['member'] == "on")) {
+ if (!file_exists($member_sem)) {
+ touch($member_sem);
+ }
+ }
+ if (!isset($_REQUEST['member']) or empty($_REQUEST['member'])) {
+ if (file_exists($member_sem)) {
+ unlink($member_sem);
+ }
+ }
- function WriteHTML($html)
- {
- //HTML parser
- $html=str_replace("\n",' ',$html);
- $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
- foreach($a as $i=>$e)
- {
- if($i%2==0)
- {
- //Text
- if($this->HREF)
- $this->PutLink($this->HREF,$e);
- else
- $this->Write(5,$e);
- }
- else
- {
- //Tag
- if($e{0}=='/')
- $this->CloseTag(strtoupper(substr($e,1)));
- else
- {
- //Extract attributes
- $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);
- }
- }
- }
+ $edit_sem = "data/items/{$_REQUEST['entry']}/edit.txt";
+ if (isset($_REQUEST['edit']) and !empty($_REQUEST['edit']) and ($_REQUEST['edit'] == "on")) {
+ if (!file_exists($edit_sem)) {
+ touch($edit_sem);
}
-
- function OpenTag($tag,$attr)
- {
- //Opening tag
- 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);
+ }
+ if (!isset($_REQUEST['edit']) or empty($_REQUEST['edit'])) {
+ if (file_exists($edit_sem)) {
+ unlink($edit_sem);
}
-
- function CloseTag($tag)
- {
- //Closing tag
- if($tag=='B' or $tag=='I' or $tag=='U')
- $this->SetStyle($tag,false);
- if($tag=='A')
- $this->HREF='';
+ }
+
+ $lastmod_sem = "data/items/{$_REQUEST['entry']}/lastmod.txt";
+ if (isset($_REQUEST['lastmod']) and !empty($_REQUEST['lastmod']) and ($_REQUEST['lastmod'] == "on")) {
+ if (!file_exists($lastmod_sem)) {
+ touch($lastmod_sem);
}
-
- function SetStyle($tag,$enable)
- {
- //Modify style and select corresponding font
- $this->$tag+=($enable ? 1 : -1);
- $style='';
- foreach(array('B','I','U') as $s)
- if($this->$s>0)
- $style.=$s;
- $this->SetFont('',$style);
+ }
+ if (!isset($_REQUEST['lastmod']) or empty($_REQUEST['lastmod'])) {
+ if (file_exists($lastmod_sem)) {
+ unlink($lastmod_sem);
}
-
- function PutLink($URL,$txt)
+ }
+
+ if (isset($_REQUEST['pdf']) and !empty($_REQUEST['pdf']) and ($_REQUEST['pdf'] == "on")) {
+ if (!file_exists("data/items/{$_REQUEST['entry']}/pdf")) {
+ mkdir("data/items/{$_REQUEST['entry']}/pdf");
+ }
+ if (!file_exists("data/items/{$_REQUEST['entry']}/pdf/file")) {
+ mkdir("data/items/{$_REQUEST['entry']}/pdf/file");
+ }
+ if (!file_exists("data/items/{$_REQUEST['entry']}/pdf/count")) {
+ mkdir("data/items/{$_REQUEST['entry']}/pdf/count");
+ }
+
+ $entry = $_REQUEST['entry'];
+ $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);
+
+ $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
{
- //Put a hyperlink
- $this->SetTextColor(0,0,255);
- $this->SetStyle('U',true);
- $this->Write(5,$txt,$URL);
- $this->SetStyle('U',false);
- $this->SetTextColor(0);
+ var $B;
+ var $I;
+ var $U;
+ var $HREF;
+
+ function PDF($orientation='P',$unit='mm',$format='letter')
+ {
+ //Call parent constructor
+ $this->FPDF($orientation,$unit,$format);
+ //Initialization
+ $this->B=0;
+ $this->I=0;
+ $this->U=0;
+ $this->HREF='';
+ }
+
+ function WriteHTML($html)
+ {
+ //HTML parser
+ $html=str_replace("\n",' ',$html);
+ $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
+ foreach($a as $i=>$e)
+ {
+ if($i%2==0)
+ {
+ //Text
+ if($this->HREF)
+ $this->PutLink($this->HREF,$e);
+ else
+ $this->Write(5,$e);
+ }
+ else
+ {
+ //Tag
+ if($e{0}=='/')
+ $this->CloseTag(strtoupper(substr($e,1)));
+ else
+ {
+ //Extract attributes
+ $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)
+ {
+ //Opening tag
+ 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)
+ {
+ //Closing tag
+ if($tag=='B' or $tag=='I' or $tag=='U')
+ $this->SetStyle($tag,false);
+ if($tag=='A')
+ $this->HREF='';
+ }
+
+ function SetStyle($tag,$enable)
+ {
+ //Modify style and select corresponding font
+ $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)
+ {
+ //Put a hyperlink
+ $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);
}
-
- $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($_REQUEST['pdf']) or empty($_REQUEST['pdf'])) {
- if (file_exists("data/items/{$_REQUEST['entry']}/pdf/file")) {
- rmdirr("data/items/{$_REQUEST['entry']}/pdf/file");
+
+ if (!isset($_REQUEST['pdf']) or empty($_REQUEST['pdf'])) {
+ if (file_exists("data/items/{$_REQUEST['entry']}/pdf/file")) {
+ rmdirr("data/items/{$_REQUEST['entry']}/pdf/file");
+ }
}
-}
-if (isset($_REQUEST['category']) and !empty($_REQUEST['category'])) {
- if (!file_exists("data/categories")) {
- mkdir("data/categories");
- }
- if ($_REQUEST['category'] == "unfiled") {
- unlink("data/items/{$_REQUEST['entry']}/category.txt");
+ if (isset($_REQUEST['category']) and !empty($_REQUEST['category'])) {
+ if (!file_exists("data/categories")) {
+ mkdir("data/categories");
+ }
+ if ($_REQUEST['category'] == "unfiled") {
+ unlink("data/items/{$_REQUEST['entry']}/category.txt");
+ }
+ if (file_exists("data/categories/{$_REQUEST['category']}")) {
+ $fp_category_txt = fopen("data/items/{$_REQUEST['entry']}/category.txt","w");
+ fwrite($fp_category_txt, $_REQUEST['category']);
+ fclose($fp_category_txt);
+ }
}
- if (file_exists("data/categories/{$_REQUEST['category']}")) {
- $fp_category_txt = fopen("data/items/{$_REQUEST['entry']}/category.txt","w");
- fwrite($fp_category_txt, $_REQUEST['category']);
- fclose($fp_category_txt);
+
+ $passwd_file = "data/items/{$_REQUEST['entry']}/passwd.txt";
+ if (isset($_REQUEST['passwd']) and !empty($_REQUEST['passwd']) and ($_REQUEST['passwd'] != "password")) {
+ $fp_passwd_txt = fopen("$passwd_file","w");
+ $passwd_crypt = sha1($_REQUEST['passwd']);
+ $passwd_crypt = md5($passwd_crypt);
+ $passwd_crypt = crypt($passwd_crypt, $passwd_crypt);
+ fwrite($fp_passwd_txt, $passwd_crypt);
+ fclose($fp_passwd_txt);
}
-}
-
-$passwd_file = "data/items/{$_REQUEST['entry']}/passwd.txt";
-if (isset($_REQUEST['passwd']) and !empty($_REQUEST['passwd']) and ($_REQUEST['passwd'] != "password")) {
- $fp_passwd_txt = fopen("$passwd_file","w");
- $passwd_crypt = sha1($_REQUEST['passwd']);
- $passwd_crypt = md5($passwd_crypt);
- $passwd_crypt = crypt($passwd_crypt, $passwd_crypt);
- fwrite($fp_passwd_txt, $passwd_crypt);
- fclose($fp_passwd_txt);
-}
-if (!isset($_REQUEST['passwd']) or empty($_REQUEST['passwd'])) {
- if (file_exists($passwd_file)) {
- unlink($passwd_file);
+ if (!isset($_REQUEST['passwd']) or empty($_REQUEST['passwd'])) {
+ if (file_exists($passwd_file)) {
+ unlink($passwd_file);
+ }
}
}
diff --git a/index.php b/index.php
index 831a75a..531c08f 100644
--- a/index.php
+++ b/index.php
@@ -1799,8 +1799,19 @@ foreach ($disp as $d) {
}
readfile("$dir/$d/title.txt");
-
+
+ // start of wiki mod (20071130)
+
+ if (isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] != $login_username) and file_exists("data/members/active/{$_SESSION['logged_in']}") and file_exists("data/wiki.txt") and file_exists("$dir/$d/edit.txt") and file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt") and !file_exists("$dir/$d/passwd.txt")) {
+ echo '<a href=edit.php?entry=';
+ echo $d;
+ echo '><img src=images/widget.edit.png border=0 width=11 height=11 align=right alt="edit entry"></a>';
+ }
+
+ // end of wiki mod (20071130)
+
if (isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username)) {
+
echo '<a href=del.php?entry=';
echo $d;
echo '><img src=images/widget.del.png border=0 width=11 height=11 align=right alt="delete entry"></a>';
diff --git a/member.php b/member.php
index 0477b98..862295c 100644
--- a/member.php
+++ b/member.php
@@ -207,6 +207,12 @@ if (isset($_REQUEST['edit']) and !empty($_REQUEST['edit']) and ($_REQUEST['edit'
unlink("data/members/active/{$_REQUEST['username']}/category.txt");
}
+ // start of upload privileges cleanup if ro and nocat (20071204)
+ if (file_exists("data/members/active/{$_REQUEST['username']}/ul.txt") and !file_exists("data/members/active/{$_REQUEST['username']}/rw.txt") and !file_exists("data/members/active/{$_REQUEST['username']}/category.txt")) {
+ unlink("data/members/active/{$_REQUEST['username']}/ul.txt");
+ }
+ // end of upload privileges cleanup if ro and nocat (20071204)
+
if (isset($_REQUEST['del']) and !empty($_REQUEST['del']) and ($_REQUEST['del'] == "on")) {
function rmdirr($recurse_dirname)
{
diff --git a/settings.php b/settings.php
index 23dcae4..551841c 100644
--- a/settings.php
+++ b/settings.php
@@ -237,6 +237,22 @@ if (!isset($_REQUEST['old']) or empty($_REQUEST['old'])) {
}
}
+// start of wiki mod (20071130)
+
+if (isset($_REQUEST['wiki']) and !empty($_REQUEST['wiki']) and ($_REQUEST['wiki'] == "on") and !file_exists("data/wiki.txt")) {
+ touch("data/wiki.txt");
+}
+
+if (!isset($_REQUEST['wiki']) or empty($_REQUEST['wiki'])) {
+ if (isset($_REQUEST['edit']) and ($_REQUEST['edit'] == "on")) {
+ if (file_exists("data/wiki.txt")) {
+ unlink("data/wiki.txt");
+ }
+ }
+}
+
+// end of wiki mod (20071130)
+
if (isset($_REQUEST['pf']) and !empty($_REQUEST['pf']) and ($_REQUEST['pf'] == "on") and !file_exists("data/pf.txt")) {
touch("data/pf.txt");
}
@@ -910,7 +926,7 @@ body {
background-color: #FFFFFF;
}
-p {
+p, td {
font-size: 11px;
}
@@ -1114,6 +1130,8 @@ if (file_exists("data/pf-censor.txt")) {
<?php } ?>
+<tr><td>wiki</td><td><input type=checkbox name=wiki <?php if (file_exists("data/wiki.txt")) { echo checked; } ?>> Enable wiki-style editing.</td></tr>
+
<tr><td <?php if (file_exists("data/bb.txt") and !file_exists("images/avatar.jpg") and !file_exists("images/avatar.gif") and !file_exists("images/avatar.png")) { echo "rowspan=10"; } if (file_exists("data/bb.txt") and (file_exists("images/avatar.jpg") or file_exists("images/avatar.gif") or file_exists("images/avatar.png"))) { echo "rowspan=11"; } ?>><p>bulletin board</p></td><td><p><input type=checkbox name=bb <?php if (file_exists("data/bb.txt")) { echo checked; } ?>> Enable simple bulletin board.</p></td></tr>
<?php if (file_exists("data/bb.txt")) { ?>
<tr><td><p><input type=checkbox name=reg <?php if (file_exists("data/reg.txt")) { echo checked; } ?>> Enable new user registration.</p></td></tr>
tree 8b4cf2a0e46b2b7e74fc3ba8f4d8e4091c7b5bf0
parent 1fc9d7d9987989d167d2bee454afc0d5e8c0132b
author Engels Antonio <engels@majcms.org> 1277314192 +0800
committer Engels Antonio <engels@majcms.org> 1277314192 +0800
maj-0.14-20071204-bb.zip
diff --git a/edit.php b/edit.php
index 7e41985..579644a 100644
--- a/edit.php
+++ b/edit.php
@@ -22,6 +22,33 @@ if (get_magic_quotes_gpc()) {
$login_username = file_get_contents("data/username.txt");
+if (isset($_REQUEST['title_input']) and isset($_REQUEST['body_input'])) {
+ header("Location: http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?entry=" . $_REQUEST['entry']);
+}
+
+if (!isset($_REQUEST['entry'])) {
+ exit();
+}
+
+if (!isset($_SESSION['logged_in'])) {
+ exit();
+}
+
+$do = 0;
+
+if ($_SESSION['logged_in'] == $login_username) {
+ $do = 1;
+}
+
+
+if (file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt") and file_exists("data/wiki.txt") and file_exists("data/items/{$_REQUEST['entry']}/edit.txt")) {
+ $do = 1;
+}
+
+if ($do == 0) {
+ exit();
+}
+
function rmdirr($recurse_dirname) {
if (!file_exists($recurse_dirname)) {
@@ -46,18 +73,6 @@ function rmdirr($recurse_dirname) {
return rmdir($recurse_dirname);
}
-if (isset($_REQUEST['title_input']) and isset($_REQUEST['body_input'])) {
- header("Location: http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?entry=" . $_REQUEST['entry']);
-}
-
-if (!isset($_REQUEST['entry'])) {
- exit();
-}
-
-if (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username)) {
- exit();
-}
-
$title_file = 'data/items/' . $_REQUEST['entry'] . '/title.txt';
$body_file = 'data/items/' . $_REQUEST['entry'] . '/body.txt';
$date_file = 'data/items/' . $_REQUEST['entry'] . '/date.txt';
@@ -345,82 +360,113 @@ if (file_exists("data/items/{$_REQUEST['entry']}/category.txt")) {
<p>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
-<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_image_size; ?>">
-<input autocomplete=off type=file name=album_image_input> Upload optional album image. Enter optional caption below.</p>
-<p><input autocomplete=off type=text name=caption class=input_body></p>
-<p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
-<input autocomplete=off type=file name=entry_image_input> Upload optional 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.</p>
-<p><input autocomplete=off type=password name=passwd <?php
-
-if (file_exists("data/items/{$_REQUEST['entry']}/passwd.txt")) {
- echo "value=password";
-}
+
+<?php if (($_SESSION['logged_in'] == $login_username) or (file_exists("data/members/active/{$_SESSION['logged_in']}/ul.txt") and file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt"))) { ?>
+
+ <p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_image_size; ?>">
+ <input autocomplete=off type=file name=album_image_input> Upload optional album image. Enter optional caption below.</p>
+ <p><input autocomplete=off type=text name=caption class=input_body></p>
+ <p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
+ <input autocomplete=off type=file name=entry_image_input> Upload optional 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.</p>
+
+<?php
+
+}
+
+if ($_SESSION['logged_in'] == $login_username) {
+
?>
-> <?php
+ <p><input autocomplete=off type=password name=passwd <?php
-if (file_exists("data/items/{$_REQUEST['entry']}/passwd.txt")) {
- echo "Enter new password or clear field to disable password protection.";
-}
-else {
- echo "Enter optional password.";
-}
-?></p>
+ if (file_exists("data/items/{$_REQUEST['entry']}/passwd.txt")) {
+ echo "value=password";
+ }
+ ?>
-<?php
- if (file_exists("data/categories")) {
- if ($dh_cat = opendir("data/categories")) {
- while (($entry_cat = readdir($dh_cat)) !== false) {
+ > <?php
+
+ if (file_exists("data/items/{$_REQUEST['entry']}/passwd.txt")) {
+ echo "Enter new password or clear field to disable password protection.";
+ }
+ else {
+ echo "Enter optional password.";
+ }
+ ?></p>
- if ($entry_cat != "." && $entry_cat != ".." && fnmatch("*", $entry_cat)) {
- $show_cat[] = $entry_cat;
+ <?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 selected>";
+ if (file_exists("data/items/{$_REQUEST['entry']}/category.txt")) {
+ readfile("data/items/{$_REQUEST['entry']}/category.txt");
+ echo '<option>unfiled';
+ }
+ else {
+ echo "unfiled";
}
+
+
+ foreach ($show_cat as $category) {
+ echo "<option>";
+ echo strtolower($category);
+ }
+
+ echo "</select> Select category.</p>";
+
}
- closedir($dh_cat);
}
+ ?>
+ <p><input type=checkbox name=sticky <?php $sticky_sem = 'data/sticky/' . $_REQUEST['entry']; if (file_exists($sticky_sem)) { echo checked; } ?>>Put entry title in Quick Links box.<br>
+ <input type=checkbox name=pdf <?php if (file_exists("data/items/{$_REQUEST['entry']}/pdf/file")) { echo checked; } ?>>Allow PDF generation for this entry.<br>
+ <input type=checkbox name=display <?php $display_sem = "data/items/{$_REQUEST['entry']}/cat.txt"; if (file_exists($display_sem)) { echo checked; } ?>>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 $private_sem = "data/items/{$_REQUEST['entry']}/private.txt"; if (file_exists($private_sem)) { 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.
- sort($show_cat);
- reset($show_cat);
- $count_cat = count($show_cat);
+ <?php if (file_exists("data/bb.txt")) { ?>
+ <br>
+ <input type=checkbox name=member <?php $member_sem = "data/items/{$_REQUEST['entry']}/member.txt"; if (file_exists($member_sem)) { echo checked; } ?>>Only registered members can view this entry.
- if ($count_cat > 0) {
+ <?php } ?>
- echo "<p><select name=category><option selected>";
- if (file_exists("data/items/{$_REQUEST['entry']}/category.txt")) {
- readfile("data/items/{$_REQUEST['entry']}/category.txt");
- echo '<option>unfiled';
- }
- else {
- echo "unfiled";
- }
+ <?php
+ // start of wiki mod (20071130)
- foreach ($show_cat as $category) {
- echo "<option>";
- echo strtolower($category);
- }
+ if (file_exists("data/bb.txt") and file_exists("data/wiki.txt")) { ?>
+ <br>
+ <input type=checkbox name=edit <?php $edit_sem = "data/items/{$_REQUEST['entry']}/edit.txt"; if (file_exists($edit_sem)) { echo checked; } ?>>Registered members can edit this entry.
- echo "</select> Select category.</p>";
+ <?php
- }
- }
-?>
-<p><input type=checkbox name=sticky <?php $sticky_sem = 'data/sticky/' . $_REQUEST['entry']; if (file_exists($sticky_sem)) { echo checked; } ?>>Put entry title in Quick Links box.<br>
-<input type=checkbox name=pdf <?php if (file_exists("data/items/{$_REQUEST['entry']}/pdf/file")) { echo checked; } ?>>Allow PDF generation for this entry.<br>
-<input type=checkbox name=display <?php $display_sem = "data/items/{$_REQUEST['entry']}/cat.txt"; if (file_exists($display_sem)) { echo checked; } ?>>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 $private_sem = "data/items/{$_REQUEST['entry']}/private.txt"; if (file_exists($private_sem)) { 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.
+ // end of wiki mod (20071130)
-<?php if (file_exists("data/bb.txt")) { ?>
-<br>
-<input type=checkbox name=member <?php $member_sem = "data/items/{$_REQUEST['entry']}/member.txt"; if (file_exists($member_sem)) { echo checked; } ?>>Only registered members can view this entry.
+ }
-<?php } ?>
+ ?>
+
+ <br><input type=checkbox name=lastmod <?php $lastmod_sem = "data/items/{$_REQUEST['entry']}/lastmod.txt"; if (file_exists($lastmod_sem)) { echo checked; } ?>>Display last modification date and time.
-<br><input type=checkbox name=lastmod <?php $lastmod_sem = "data/items/{$_REQUEST['entry']}/lastmod.txt"; if (file_exists($lastmod_sem)) { echo checked; } ?>>Display last modification date and time.
+ </p>
+
+<?php } ?>
-</p>
<input type=hidden name=entry value="<?php echo $_REQUEST['entry']; ?>">
<table border=0 cellspacing=0 cellpadding=0><tr><td>
@@ -769,247 +815,313 @@ if (isset($_FILES['file_input']) and !empty($_FILES['file_input'])) {
}
}
-$open_body_file = fopen($body_file,"w");
-fwrite($open_body_file,$body_write_content);
-fclose($open_body_file);
+// start of wiki mod (20071130)
-$sticky_sem = 'data/sticky/' . $_REQUEST['entry'];
-if (isset($_REQUEST['sticky']) and !empty($_REQUEST['sticky']) and ($_REQUEST['sticky'] == "on")) {
- if (!file_exists("data/sticky")) {
- mkdir("data/sticky");
- }
- if (!file_exists($sticky_sem)) {
- touch($sticky_sem);
- }
-}
-if (!isset($_REQUEST['sticky']) or empty($_REQUEST['sticky'])) {
- if (file_exists($sticky_sem)) {
- unlink($sticky_sem);
- }
-}
+$title_get_content = ucfirst($_REQUEST['title_input']);
+$title_get_content = str_replace('<','<',$title_get_content);
+$title_get_content = str_replace('>','>',$title_get_content);
-$display_sem = "data/items/{$_REQUEST['entry']}/cat.txt";
-if (isset($_REQUEST['display']) and !empty($_REQUEST['display']) and ($_REQUEST['display'] == "on")) {
- if (!file_exists($display_sem)) {
- touch($display_sem);
- }
-}
-if (!isset($_REQUEST['display']) or empty($_REQUEST['display'])) {
- if (file_exists($display_sem)) {
- unlink($display_sem);
- }
-}
+if (file_exists("data/wiki.txt") and (($title_get_content != file_get_contents("data/items/{$_REQUEST['entry']}/title.txt")) or ($body_write_content != file_get_contents("data/items/{$_REQUEST['entry']}/body.txt")))) {
-$private_sem = "data/items/{$_REQUEST['entry']}/private.txt";
-if (isset($_REQUEST['private']) and !empty($_REQUEST['private']) and ($_REQUEST['private'] == "on")) {
- if (!file_exists($private_sem)) {
- touch($private_sem);
+ if (!file_exists("data/items/{$_REQUEST['entry']}/wiki")) {
+ mkdir("data/items/{$_REQUEST['entry']}/wiki");
}
-}
-if (!isset($_REQUEST['private']) or empty($_REQUEST['private'])) {
- if (file_exists($private_sem)) {
- unlink($private_sem);
+
+ if (!file_exists("data/items/{$_REQUEST['entry']}/wiki/delta")) {
+ mkdir("data/items/{$_REQUEST['entry']}/wiki/delta");
}
-}
-$member_sem = "data/items/{$_REQUEST['entry']}/member.txt";
-if (isset($_REQUEST['member']) and !empty($_REQUEST['member']) and ($_REQUEST['member'] == "on")) {
- if (!file_exists($member_sem)) {
- touch($member_sem);
+ if (file_exists("data/offset.txt")) {
+ $offset = file_get_contents("data/offset.txt");
}
-}
-if (!isset($_REQUEST['member']) or empty($_REQUEST['member'])) {
- if (file_exists($member_sem)) {
- unlink($member_sem);
+ else {
+ $offset = 0;
}
-}
-$lastmod_sem = "data/items/{$_REQUEST['entry']}/lastmod.txt";
-if (isset($_REQUEST['lastmod']) and !empty($_REQUEST['lastmod']) and ($_REQUEST['lastmod'] == "on")) {
- if (!file_exists($lastmod_sem)) {
- touch($lastmod_sem);
+ $ddate = date("YmdHis", time() + $offset);
+
+ if (!file_exists("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate")) {
+ mkdir("data/items/{$_REQUEST['entry']}/wiki/delta/$ddate");
}
-}
-if (!isset($_REQUEST['lastmod']) or empty($_REQUEST['lastmod'])) {
- if (file_exists($lastmod_sem)) {
- unlink($lastmod_sem);
+
+ copy("data/items/{$_REQUEST['entry']}/author.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/author.txt");
+ copy("data/items/{$_REQUEST['entry']}/body.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/body.txt");
+ copy("data/items/{$_REQUEST['entry']}/date.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/date.txt");
+ copy("data/items/{$_REQUEST['entry']}/title.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/title.txt");
+
+ if (file_exists("data/items/{$_REQUEST['entry']}/contrib.txt")) {
+ copy("data/items/{$_REQUEST['entry']}/contrib.txt","data/items/{$_REQUEST['entry']}/wiki/delta/$ddate/contrib.txt");
}
}
-if (isset($_REQUEST['pdf']) and !empty($_REQUEST['pdf']) and ($_REQUEST['pdf'] == "on")) {
- if (!file_exists("data/items/{$_REQUEST['entry']}/pdf")) {
- mkdir("data/items/{$_REQUEST['entry']}/pdf");
- }
- if (!file_exists("data/items/{$_REQUEST['entry']}/pdf/file")) {
- mkdir("data/items/{$_REQUEST['entry']}/pdf/file");
- }
- if (!file_exists("data/items/{$_REQUEST['entry']}/pdf/count")) {
- mkdir("data/items/{$_REQUEST['entry']}/pdf/count");
- }
+// end of wiki mod (20071130)
- $entry = $_REQUEST['entry'];
- $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";
+$open_body_file = fopen($body_file,"w");
+fwrite($open_body_file,$body_write_content);
+fclose($open_body_file);
- $author = file_get_contents($author_file);
- $title = file_get_contents($title_file);
- $date = file_get_contents($date_file);
+// start of wiki mod (20071130)
- $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);
+if (file_exists("data/wiki.txt") and file_exists("data/items/{$_REQUEST['entry']}/edit.txt")) {
+ $open_contrib_file = fopen("data/items/{$_REQUEST['entry']}/contrib.txt","w");
+ fwrite($open_contrib_file,$_SESSION['logged_in']);
+ fclose($open_contrib_file);
+}
- $body = file_get_contents($body_file);
- $body = str_replace("\n","<br>",$body);
+// end of wiki mod (20071130)
- $html = "<br><i>by $author</i><br><br>$date<br><br>Canonical Source<br>$link<br><br><br>$body";
+if ($_SESSION['logged_in'] == $login_username) {
- $filename = strtolower($title);
- $filename = strtolower($_SERVER['SERVER_NAME']) . "-" . $entry . "-" . $filename . ".pdf";
- $filename = str_replace(" ","-",$filename);
- $filename = "data/items/$entry/pdf/file/$filename";
+ $sticky_sem = 'data/sticky/' . $_REQUEST['entry'];
+ if (isset($_REQUEST['sticky']) and !empty($_REQUEST['sticky']) and ($_REQUEST['sticky'] == "on")) {
+ if (!file_exists("data/sticky")) {
+ mkdir("data/sticky");
+ }
+ if (!file_exists($sticky_sem)) {
+ touch($sticky_sem);
+ }
+ }
+ if (!isset($_REQUEST['sticky']) or empty($_REQUEST['sticky'])) {
+ if (file_exists($sticky_sem)) {
+ unlink($sticky_sem);
+ }
+ }
- require('fpdf.php');
+ $display_sem = "data/items/{$_REQUEST['entry']}/cat.txt";
+ if (isset($_REQUEST['display']) and !empty($_REQUEST['display']) and ($_REQUEST['display'] == "on")) {
+ if (!file_exists($display_sem)) {
+ touch($display_sem);
+ }
+ }
+ if (!isset($_REQUEST['display']) or empty($_REQUEST['display'])) {
+ if (file_exists($display_sem)) {
+ unlink($display_sem);
+ }
+ }
- class PDF extends FPDF
- {
- var $B;
- var $I;
- var $U;
- var $HREF;
-
- function PDF($orientation='P',$unit='mm',$format='letter')
- {
- //Call parent constructor
- $this->FPDF($orientation,$unit,$format);
- //Initialization
- $this->B=0;
- $this->I=0;
- $this->U=0;
- $this->HREF='';
+ $private_sem = "data/items/{$_REQUEST['entry']}/private.txt";
+ if (isset($_REQUEST['private']) and !empty($_REQUEST['private']) and ($_REQUEST['private'] == "on")) {
+ if (!file_exists($private_sem)) {
+ touch($private_sem);
+ }
+ }
+ if (!isset($_REQUEST['private']) or empty($_REQUEST['private'])) {
+ if (file_exists($private_sem)) {
+ unlink($private_sem);
}
+ }
+
+ $member_sem = "data/items/{$_REQUEST['entry']}/member.txt";
+ if (isset($_REQUEST['member']) and !empty($_REQUEST['member']) and ($_REQUEST['member'] == "on")) {
+ if (!file_exists($member_sem)) {
+ touch($member_sem);
+ }
+ }
+ if (!isset($_REQUEST['member']) or empty($_REQUEST['member'])) {
+ if (file_exists($member_sem)) {
+ unlink($member_sem);
+ }
+ }
- function WriteHTML($html)
- {
- //HTML parser
- $html=str_replace("\n",' ',$html);
- $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
- foreach($a as $i=>$e)
- {
- if($i%2==0)
- {
- //Text
- if($this->HREF)
- $this->PutLink($this->HREF,$e);
- else
- $this->Write(5,$e);
- }
- else
- {
- //Tag
- if($e{0}=='/')
- $this->CloseTag(strtoupper(substr($e,1)));
- else
- {
- //Extract attributes
- $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);
- }
- }
- }
+ $edit_sem = "data/items/{$_REQUEST['entry']}/edit.txt";
+ if (isset($_REQUEST['edit']) and !empty($_REQUEST['edit']) and ($_REQUEST['edit'] == "on")) {
+ if (!file_exists($edit_sem)) {
+ touch($edit_sem);
}
-
- function OpenTag($tag,$attr)
- {
- //Opening tag
- 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);
+ }
+ if (!isset($_REQUEST['edit']) or empty($_REQUEST['edit'])) {
+ if (file_exists($edit_sem)) {
+ unlink($edit_sem);
}
-
- function CloseTag($tag)
- {
- //Closing tag
- if($tag=='B' or $tag=='I' or $tag=='U')
- $this->SetStyle($tag,false);
- if($tag=='A')
- $this->HREF='';
+ }
+
+ $lastmod_sem = "data/items/{$_REQUEST['entry']}/lastmod.txt";
+ if (isset($_REQUEST['lastmod']) and !empty($_REQUEST['lastmod']) and ($_REQUEST['lastmod'] == "on")) {
+ if (!file_exists($lastmod_sem)) {
+ touch($lastmod_sem);
}
-
- function SetStyle($tag,$enable)
- {
- //Modify style and select corresponding font
- $this->$tag+=($enable ? 1 : -1);
- $style='';
- foreach(array('B','I','U') as $s)
- if($this->$s>0)
- $style.=$s;
- $this->SetFont('',$style);
+ }
+ if (!isset($_REQUEST['lastmod']) or empty($_REQUEST['lastmod'])) {
+ if (file_exists($lastmod_sem)) {
+ unlink($lastmod_sem);
}
-
- function PutLink($URL,$txt)
+ }
+
+ if (isset($_REQUEST['pdf']) and !empty($_REQUEST['pdf']) and ($_REQUEST['pdf'] == "on")) {
+ if (!file_exists("data/items/{$_REQUEST['entry']}/pdf")) {
+ mkdir("data/items/{$_REQUEST['entry']}/pdf");
+ }
+ if (!file_exists("data/items/{$_REQUEST['entry']}/pdf/file")) {
+ mkdir("data/items/{$_REQUEST['entry']}/pdf/file");
+ }
+ if (!file_exists("data/items/{$_REQUEST['entry']}/pdf/count")) {
+ mkdir("data/items/{$_REQUEST['entry']}/pdf/count");
+ }
+
+ $entry = $_REQUEST['entry'];
+ $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);
+
+ $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
{
- //Put a hyperlink
- $this->SetTextColor(0,0,255);
- $this->SetStyle('U',true);
- $this->Write(5,$txt,$URL);
- $this->SetStyle('U',false);
- $this->SetTextColor(0);
+ var $B;
+ var $I;
+ var $U;
+ var $HREF;
+
+ function PDF($orientation='P',$unit='mm',$format='letter')
+ {
+ //Call parent constructor
+ $this->FPDF($orientation,$unit,$format);
+ //Initialization
+ $this->B=0;
+ $this->I=0;
+ $this->U=0;
+ $this->HREF='';
+ }
+
+ function WriteHTML($html)
+ {
+ //HTML parser
+ $html=str_replace("\n",' ',$html);
+ $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
+ foreach($a as $i=>$e)
+ {
+ if($i%2==0)
+ {
+ //Text
+ if($this->HREF)
+ $this->PutLink($this->HREF,$e);
+ else
+ $this->Write(5,$e);
+ }
+ else
+ {
+ //Tag
+ if($e{0}=='/')
+ $this->CloseTag(strtoupper(substr($e,1)));
+ else
+ {
+ //Extract attributes
+ $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)
+ {
+ //Opening tag
+ 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)
+ {
+ //Closing tag
+ if($tag=='B' or $tag=='I' or $tag=='U')
+ $this->SetStyle($tag,false);
+ if($tag=='A')
+ $this->HREF='';
+ }
+
+ function SetStyle($tag,$enable)
+ {
+ //Modify style and select corresponding font
+ $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)
+ {
+ //Put a hyperlink
+ $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);
}
-
- $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($_REQUEST['pdf']) or empty($_REQUEST['pdf'])) {
- if (file_exists("data/items/{$_REQUEST['entry']}/pdf/file")) {
- rmdirr("data/items/{$_REQUEST['entry']}/pdf/file");
+
+ if (!isset($_REQUEST['pdf']) or empty($_REQUEST['pdf'])) {
+ if (file_exists("data/items/{$_REQUEST['entry']}/pdf/file")) {
+ rmdirr("data/items/{$_REQUEST['entry']}/pdf/file");
+ }
}
-}
-if (isset($_REQUEST['category']) and !empty($_REQUEST['category'])) {
- if (!file_exists("data/categories")) {
- mkdir("data/categories");
- }
- if ($_REQUEST['category'] == "unfiled") {
- unlink("data/items/{$_REQUEST['entry']}/category.txt");
+ if (isset($_REQUEST['category']) and !empty($_REQUEST['category'])) {
+ if (!file_exists("data/categories")) {
+ mkdir("data/categories");
+ }
+ if ($_REQUEST['category'] == "unfiled") {
+ unlink("data/items/{$_REQUEST['entry']}/category.txt");
+ }
+ if (file_exists("data/categories/{$_REQUEST['category']}")) {
+ $fp_category_txt = fopen("data/items/{$_REQUEST['entry']}/category.txt","w");
+ fwrite($fp_category_txt, $_REQUEST['category']);
+ fclose($fp_category_txt);
+ }
}
- if (file_exists("data/categories/{$_REQUEST['category']}")) {
- $fp_category_txt = fopen("data/items/{$_REQUEST['entry']}/category.txt","w");
- fwrite($fp_category_txt, $_REQUEST['category']);
- fclose($fp_category_txt);
+
+ $passwd_file = "data/items/{$_REQUEST['entry']}/passwd.txt";
+ if (isset($_REQUEST['passwd']) and !empty($_REQUEST['passwd']) and ($_REQUEST['passwd'] != "password")) {
+ $fp_passwd_txt = fopen("$passwd_file","w");
+ $passwd_crypt = sha1($_REQUEST['passwd']);
+ $passwd_crypt = md5($passwd_crypt);
+ $passwd_crypt = crypt($passwd_crypt, $passwd_crypt);
+ fwrite($fp_passwd_txt, $passwd_crypt);
+ fclose($fp_passwd_txt);
}
-}
-
-$passwd_file = "data/items/{$_REQUEST['entry']}/passwd.txt";
-if (isset($_REQUEST['passwd']) and !empty($_REQUEST['passwd']) and ($_REQUEST['passwd'] != "password")) {
- $fp_passwd_txt = fopen("$passwd_file","w");
- $passwd_crypt = sha1($_REQUEST['passwd']);
- $passwd_crypt = md5($passwd_crypt);
- $passwd_crypt = crypt($passwd_crypt, $passwd_crypt);
- fwrite($fp_passwd_txt, $passwd_crypt);
- fclose($fp_passwd_txt);
-}
-if (!isset($_REQUEST['passwd']) or empty($_REQUEST['passwd'])) {
- if (file_exists($passwd_file)) {
- unlink($passwd_file);
+ if (!isset($_REQUEST['passwd']) or empty($_REQUEST['passwd'])) {
+ if (file_exists($passwd_file)) {
+ unlink($passwd_file);
+ }
}
}
diff --git a/index.php b/index.php
index 831a75a..531c08f 100644
--- a/index.php
+++ b/index.php
@@ -1799,8 +1799,19 @@ foreach ($disp as $d) {
}
readfile("$dir/$d/title.txt");
-
+
+ // start of wiki mod (20071130)
+
+ if (isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] != $login_username) and file_exists("data/members/active/{$_SESSION['logged_in']}") and file_exists("data/wiki.txt") and file_exists("$dir/$d/edit.txt") and file_exists("data/members/active/{$_SESSION['logged_in']}/rw.txt") and !file_exists("$dir/$d/passwd.txt")) {
+ echo '<a href=edit.php?entry=';
+ echo $d;
+ echo '><img src=images/widget.edit.png border=0 width=11 height=11 align=right alt="edit entry"></a>';
+ }
+
+ // end of wiki mod (20071130)
+
if (isset($_SESSION['logged_in']) and ($_SESSION['logged_in'] == $login_username)) {
+
echo '<a href=del.php?entry=';
echo $d;
echo '><img src=images/widget.del.png border=0 width=11 height=11 align=right alt="delete entry"></a>';
diff --git a/member.php b/member.php
index 0477b98..862295c 100644
--- a/member.php
+++ b/member.php
@@ -207,6 +207,12 @@ if (isset($_REQUEST['edit']) and !empty($_REQUEST['edit']) and ($_REQUEST['edit'
unlink("data/members/active/{$_REQUEST['username']}/category.txt");
}
+ // start of upload privileges cleanup if ro and nocat (20071204)
+ if (file_exists("data/members/active/{$_REQUEST['username']}/ul.txt") and !file_exists("data/members/active/{$_REQUEST['username']}/rw.txt") and !file_exists("data/members/active/{$_REQUEST['username']}/category.txt")) {
+ unlink("data/members/active/{$_REQUEST['username']}/ul.txt");
+ }
+ // end of upload privileges cleanup if ro and nocat (20071204)
+
if (isset($_REQUEST['del']) and !empty($_REQUEST['del']) and ($_REQUEST['del'] == "on")) {
function rmdirr($recurse_dirname)
{
diff --git a/settings.php b/settings.php
index 23dcae4..551841c 100644
--- a/settings.php
+++ b/settings.php
@@ -237,6 +237,22 @@ if (!isset($_REQUEST['old']) or empty($_REQUEST['old'])) {
}
}
+// start of wiki mod (20071130)
+
+if (isset($_REQUEST['wiki']) and !empty($_REQUEST['wiki']) and ($_REQUEST['wiki'] == "on") and !file_exists("data/wiki.txt")) {
+ touch("data/wiki.txt");
+}
+
+if (!isset($_REQUEST['wiki']) or empty($_REQUEST['wiki'])) {
+ if (isset($_REQUEST['edit']) and ($_REQUEST['edit'] == "on")) {
+ if (file_exists("data/wiki.txt")) {
+ unlink("data/wiki.txt");
+ }
+ }
+}
+
+// end of wiki mod (20071130)
+
if (isset($_REQUEST['pf']) and !empty($_REQUEST['pf']) and ($_REQUEST['pf'] == "on") and !file_exists("data/pf.txt")) {
touch("data/pf.txt");
}
@@ -910,7 +926,7 @@ body {
background-color: #FFFFFF;
}
-p {
+p, td {
font-size: 11px;
}
@@ -1114,6 +1130,8 @@ if (file_exists("data/pf-censor.txt")) {
<?php } ?>
+<tr><td>wiki</td><td><input type=checkbox name=wiki <?php if (file_exists("data/wiki.txt")) { echo checked; } ?>> Enable wiki-style editing.</td></tr>
+
<tr><td <?php if (file_exists("data/bb.txt") and !file_exists("images/avatar.jpg") and !file_exists("images/avatar.gif") and !file_exists("images/avatar.png")) { echo "rowspan=10"; } if (file_exists("data/bb.txt") and (file_exists("images/avatar.jpg") or file_exists("images/avatar.gif") or file_exists("images/avatar.png"))) { echo "rowspan=11"; } ?>><p>bulletin board</p></td><td><p><input type=checkbox name=bb <?php if (file_exists("data/bb.txt")) { echo checked; } ?>> Enable simple bulletin board.</p></td></tr>
<?php if (file_exists("data/bb.txt")) { ?>
<tr><td><p><input type=checkbox name=reg <?php if (file_exists("data/reg.txt")) { echo checked; } ?>> Enable new user registration.</p></td></tr>