David Fullard
WikkaForum Modifications
See the WikkaForum page for details on how to set-up the forum.
wikkaforum.php
Place this file in the actions directory
<?php
// wikkaforum.php Version 1.0k - Aug 4, 2007 - added delete thread and post options for site administrators by DaveFullard
// Use: {{wikkaforum [topic="topic description"] [main="mainpage"] [page="pagename"] [share="name1 name2 name3 etc"]}}
// "main" is used if there is a collection of threads accessed from one wiki page, "main" allows the user
// to easily return to that page by placing a link on the page automatically
// The file wikkaforumfunctions.php MUST be included in a directory in wikka root called "scripts"
//{{wikkaforum main="WikkaForum" topic="Bakhtin"}}
/**********************************
* SForum class
* @author: Wojciech Napierala XII.2004
* @help: Ondra Marek [email protected]
* @
* [email protected]
*
* @license: GNU GPL
**********************************
*/
$link = $this->config["base_url"].$this->MiniHref($method, $tag);
$username=$this->GetUserName();
$prefix=$this->config["table_prefix"];
if (empty($page)) {
$tag=$this->getPageTag();
$pageX=$tag;
}
else
{
$tag=$page;
}
// code to determine who can contribute to the threads
if(empty($share)){$share = 'ALL';}
$tok = strtok($share, " \n\t");
while ($tok) {
if($tok == $this->GetUserName() || $tok == "ALL") { $use = 'true';}
$tok = strtok(" \n\t");
}
if (strtoupper($this->GetUserName())==strtoupper($this->GetPageOwner())){$use = 'true';}
// check so that when there are multiple instances of the action one cannot "add" to the database
// in response to having a thread from another page open (trust me, this code is necessary)
$tablepgname = $this->LoadSingle("SELECT tag FROM ".$this->config['table_prefix']."wikkaforum WHERE wid='".$_GET['wid']."' LIMIT 0,1");
$shouldwrite = $tablepgname[tag];
if (($shouldwrite==$this->getPageTag()) || (empty($shouldwrite))) {$use2 = 'true';}
// CLASS STATEMENT STARTS HERE. Using include_once prevents function conflicts & allows multiple instances on the same page
include_once("./scripts/wikkaforumfunctions.php");
// CLASS STATEMENT ENDS HERE.
if ($this->IsAdmin($this->GetUser())) {
$isadmin=true;
}
if (!isset($forum)) {
$forum = new SForum;
}
?>
<div align="center">
<table WIDTH='90%' border='0'><tr ALIGN='left'><td>
<?php
$forum->Show_SFname($topic);
if ($main==""){
if (!empty($_GET['wid'])) {
echo " <A HREF=\"".$link."\"><small>Return to Thread List</small></A>\n";
print("<br>\n");
}
else {
echo "<A HREF=\"".$link."\"><small> </small></A>\n";
print("<br>\n");
}
}
else
{
if ($this->IsWikiName($main)) {$link2 = "<A HREF=\"".$this->config["base_url"].$main."\">".$main."</A>";}
else {
echo $main;
}
if (!empty($_GET['wid'])) {$joiner=">>";}
if (empty($topic) && ($page!=$this->getPageTag())) {$topic=$tag;}
else{
$topic=$this->MiniHref($method, $tag);
}
echo $link2.">><A HREF=\"".$link."\">".$topic."</A> $adminfunc".$joiner;
$forum->Show_SForum_Thread_Name($_GET['wid'], $tag, $prefix);
}
if (isset($_POST['submit'])) {
if (!empty($_POST['frm_ptitle']))
{
if(empty($page))
{
$forum->Add_new_post($_POST['frm_ptitle'],$_POST['frm_text'],$tag,$_POST['frm_ip'],$username,$_POST['frm_wid'],$link,$prefix);
}
}
}
if (isset($_GET['wid'])) {
#phpinfo();
$forum->Show_SForum_Threads($_GET['wid'], $tag, $prefix, $link, $isadmin);
$forum->pansw = $_GET['wid'];
} else {
$forum->Show_SForum($link, $tag, $prefix, $isadmin);
$forum->pansw = 0;
}
if (isset($_GET['deletethread'])) {
$forum->delete_thread($_GET['deletethread'], $prefix, $link, $isadmin);
}
if (isset($_GET['deletepost'])) {
$forum->delete_post($_GET['deletepost'], $prefix, $link, $_GET['wid'], $isadmin);
}
print("\n");
if ($main==""){
if (!empty($_GET['wid'])) {
echo " <A HREF=\"".$link."\"><small>Return to Thread List</small></A>\n";
print("<br>\n");
}
else {
echo "<A HREF=\"".$link."\"><small> </small></A>\n";
print("<br>\n");
}
}
else
{
if ($this->IsWikiName($main)) {$link2 = "<A HREF=\"".$this->config["base_url"].$main."\">".$main."</A>";}
else {
echo $main;
}
if (!empty($_GET['wid'])) {$joiner=">>";}
if (empty($topic) && ($page!=$this->getPageTag())) {$topic=$tag;}
else{
$topic=$this->MiniHref($method, $tag);
}
echo $link2.">><A HREF=\"".$link."\">".$topic."</A>".$joiner;
$forum->Show_SForum_Thread_Name($_GET['wid'], $tag, $prefix);
}
if ($user = $this->GetUser())
{
if ($pageX==$this->getPageTag())
{
if ($use == 'true')
{
if(empty($page))
{
if ($use2 == 'true')
{
$forum->Show_frm($forum->ptitle, $link, $_GET['wid']);
}
}
}
}
else
{
echo "<small> This forum originates from ".$page.".</small><br>";
}
}
else
{
print("<small>Sorry, you need to be a registered & logged-in user to contribute to the forums.</small>");
if ($pageX!=$this->getPageTag()){print("<small> This forum originates from ".$pageX.".</small><br>");}
}
?>
</td></tr></table></div>
// wikkaforum.php Version 1.0k - Aug 4, 2007 - added delete thread and post options for site administrators by DaveFullard
// Use: {{wikkaforum [topic="topic description"] [main="mainpage"] [page="pagename"] [share="name1 name2 name3 etc"]}}
// "main" is used if there is a collection of threads accessed from one wiki page, "main" allows the user
// to easily return to that page by placing a link on the page automatically
// The file wikkaforumfunctions.php MUST be included in a directory in wikka root called "scripts"
//{{wikkaforum main="WikkaForum" topic="Bakhtin"}}
/**********************************
* SForum class
* @author: Wojciech Napierala XII.2004
* @help: Ondra Marek [email protected]
* @
* [email protected]
*
* @license: GNU GPL
**********************************
*/
$link = $this->config["base_url"].$this->MiniHref($method, $tag);
$username=$this->GetUserName();
$prefix=$this->config["table_prefix"];
if (empty($page)) {
$tag=$this->getPageTag();
$pageX=$tag;
}
else
{
$tag=$page;
}
// code to determine who can contribute to the threads
if(empty($share)){$share = 'ALL';}
$tok = strtok($share, " \n\t");
while ($tok) {
if($tok == $this->GetUserName() || $tok == "ALL") { $use = 'true';}
$tok = strtok(" \n\t");
}
if (strtoupper($this->GetUserName())==strtoupper($this->GetPageOwner())){$use = 'true';}
// check so that when there are multiple instances of the action one cannot "add" to the database
// in response to having a thread from another page open (trust me, this code is necessary)
$tablepgname = $this->LoadSingle("SELECT tag FROM ".$this->config['table_prefix']."wikkaforum WHERE wid='".$_GET['wid']."' LIMIT 0,1");
$shouldwrite = $tablepgname[tag];
if (($shouldwrite==$this->getPageTag()) || (empty($shouldwrite))) {$use2 = 'true';}
// CLASS STATEMENT STARTS HERE. Using include_once prevents function conflicts & allows multiple instances on the same page
include_once("./scripts/wikkaforumfunctions.php");
// CLASS STATEMENT ENDS HERE.
if ($this->IsAdmin($this->GetUser())) {
$isadmin=true;
}
if (!isset($forum)) {
$forum = new SForum;
}
?>
<div align="center">
<table WIDTH='90%' border='0'><tr ALIGN='left'><td>
<?php
$forum->Show_SFname($topic);
if ($main==""){
if (!empty($_GET['wid'])) {
echo " <A HREF=\"".$link."\"><small>Return to Thread List</small></A>\n";
print("<br>\n");
}
else {
echo "<A HREF=\"".$link."\"><small> </small></A>\n";
print("<br>\n");
}
}
else
{
if ($this->IsWikiName($main)) {$link2 = "<A HREF=\"".$this->config["base_url"].$main."\">".$main."</A>";}
else {
echo $main;
}
if (!empty($_GET['wid'])) {$joiner=">>";}
if (empty($topic) && ($page!=$this->getPageTag())) {$topic=$tag;}
else{
$topic=$this->MiniHref($method, $tag);
}
echo $link2.">><A HREF=\"".$link."\">".$topic."</A> $adminfunc".$joiner;
$forum->Show_SForum_Thread_Name($_GET['wid'], $tag, $prefix);
}
if (isset($_POST['submit'])) {
if (!empty($_POST['frm_ptitle']))
{
if(empty($page))
{
$forum->Add_new_post($_POST['frm_ptitle'],$_POST['frm_text'],$tag,$_POST['frm_ip'],$username,$_POST['frm_wid'],$link,$prefix);
}
}
}
if (isset($_GET['wid'])) {
#phpinfo();
$forum->Show_SForum_Threads($_GET['wid'], $tag, $prefix, $link, $isadmin);
$forum->pansw = $_GET['wid'];
} else {
$forum->Show_SForum($link, $tag, $prefix, $isadmin);
$forum->pansw = 0;
}
if (isset($_GET['deletethread'])) {
$forum->delete_thread($_GET['deletethread'], $prefix, $link, $isadmin);
}
if (isset($_GET['deletepost'])) {
$forum->delete_post($_GET['deletepost'], $prefix, $link, $_GET['wid'], $isadmin);
}
print("\n");
if ($main==""){
if (!empty($_GET['wid'])) {
echo " <A HREF=\"".$link."\"><small>Return to Thread List</small></A>\n";
print("<br>\n");
}
else {
echo "<A HREF=\"".$link."\"><small> </small></A>\n";
print("<br>\n");
}
}
else
{
if ($this->IsWikiName($main)) {$link2 = "<A HREF=\"".$this->config["base_url"].$main."\">".$main."</A>";}
else {
echo $main;
}
if (!empty($_GET['wid'])) {$joiner=">>";}
if (empty($topic) && ($page!=$this->getPageTag())) {$topic=$tag;}
else{
$topic=$this->MiniHref($method, $tag);
}
echo $link2.">><A HREF=\"".$link."\">".$topic."</A>".$joiner;
$forum->Show_SForum_Thread_Name($_GET['wid'], $tag, $prefix);
}
if ($user = $this->GetUser())
{
if ($pageX==$this->getPageTag())
{
if ($use == 'true')
{
if(empty($page))
{
if ($use2 == 'true')
{
$forum->Show_frm($forum->ptitle, $link, $_GET['wid']);
}
}
}
}
else
{
echo "<small> This forum originates from ".$page.".</small><br>";
}
}
else
{
print("<small>Sorry, you need to be a registered & logged-in user to contribute to the forums.</small>");
if ($pageX!=$this->getPageTag()){print("<small> This forum originates from ".$pageX.".</small><br>");}
}
?>
</td></tr></table></div>
wikkaforumfunctions.php
Place this file in the scripts directory.
<?php
// wikkaforumfunctions.php Version 1.0j - Aug 4, 2007 - added delete thread and delete post functions by DaveFullard
// USE: required to be able to use wikkaforum.php & forumcounter.php actions.
// This file **must** be placed in a directory in wikka root called "scripts".
// Modifications & original code released under GPL
// **NOTE** for inclusion on a wiki page double percents were replaced by #0025 on line 154, they need
// to be replaced as double percents. It is not advised that you do not replace code formatting marks.
/**********************************
* SForum class
* @author: Wojciech Napierała XII.2004
* @help: Ondra Marek [email protected]
* @
* [email protected]
*
* @license: GNU GPL
**********************************
*/
class SForum {
var $ptitle;
var $react; // number of answers in a thread
var $pansw;
var $title;
// SForum: constructor
function SForum() {
$this->ptitle = NULL;
$this->pansw = 0;
$this->title = "<TITLE>$this->SFname</TITLE>";
print($this->title);
}
// Show_frm: displays the form
function Show_frm($ptitle=NULL, $link, $wid) {
if(!empty($ptitle)) {
$this->ptitle = "Re: ".$ptitle;
}
$showrules="";
if (!EMPTY($wid)){$showrules="<small>Except in titles, several wiki formatting codes (bold(<bold>**</bold>), italics(<strong>//</strong>), underline(<strong>__</strong>),<br /> strikethrough(<strong>++</strong>), highlight (two single quotes...<strong>''</strong>), centering (<strong>@@</strong>) and bulleted lists(<strong>~-</strong>) <br />(and other lists)) are active. Headings, actions, tables, and external linking are not activated. </small>";}
$zawartosc = "\n\n<FORM ACTION=\"".$link."\" METHOD=\"post\" NAME=\"frm\">\n"
. "<TABLE><TR>\n"
. "<TD>Title:</TD><TD><INPUT TYPE=\"text\" NAME=\"frm_ptitle\" VALUE=\"$this->ptitle\" SIZE=\"65\"></TD>\n"
. "</TR><TR>\n"
. "<TD VALIGN=top>Text:</TD><TD><TEXTAREA NAME=\"frm_text\" cols=\"65\" rows=\"10\"></TEXTAREA></TD>\n"
. "</TR><TR>\n"
. "<TD></TD><TD COLLSPAN=\"2\"><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Submit Comment\"></TD>\n"
. "</tr><tr><td></td><td>".$showrules."</td></tr></TABLE>\n"
. "<INPUT TYPE=\"hidden\" NAME=\"frm_ip\" VALUE=\"".$_SERVER['REMOTE_ADDR']."\">\n"
. "<INPUT TYPE=\"hidden\" NAME=\"frm_wid\" VALUE=\"".$this->pansw."\">\n"
. "</FORM>\n\n";
print($zawartosc);
}
// Show_SFname : Show SForum name as text
function Show_SFname($topic) {
print("<H2>$topic</H2>\n");
}
function delete_post($id,$prefix,$link,$wid,$isadmin) {
if ($isadmin==true) {
$delete = "DELETE FROM ".$prefix."wikkaforum WHERE id='".$id."';";
$sql = mysql_query($delete) or die (mysql_error());
} else {
echo "Sorry, but you're not allowed to delete posts!";
}
$link = $link."&wid=".$wid;
header("Location: $link");
}
function delete_thread($wid,$prefix,$link,$isadmin) {
if ($isadmin==true) {
$delete = "DELETE FROM ".$prefix."wikkaforum WHERE wid='".$wid."';";
$sql = mysql_query($delete) or die (mysql_error());
} else {
echo "Sorry, but you're not allowed to delete threads!";
}
header("Location: $link");
}
// Add_new_post: Adds new record to DB (updated 10 Jan 2005)
function Add_new_post($ptitle,$text,$tag,$ip,$name,$frm_wid,$link,$prefix) {
if($ptitle=="" or $text==""){
return;
}
$this->ptitle = addslashes(htmlspecialchars(trim($ptitle)));
$this->text = addslashes(htmlspecialchars(trim($text)));
if ($frm_wid == 0) {
$zapytanie = "INSERT INTO ".$prefix."wikkaforum (wid,for_ptitle,for_text,tag,for_data,for_dataw,for_ip,for_name) VALUES('$frm_wid', '$this->ptitle', '$this->text', '$tag', now(), now(), '$ip', '$name')";
$sql = mysql_query($zapytanie) or die (mysql_error());
} else {
$zapytanie = "INSERT INTO ".$prefix."wikkaforum (wid,for_ptitle,for_text,tag,for_data,for_ip,for_name) VALUES('$frm_wid', '$this->ptitle', '$this->text', '$tag', now(), '$ip', '$name')";
$sql = mysql_query($zapytanie) or die (mysql_error());
}
$id = mysql_insert_id();
if ($frm_wid == 0) {
$zapytanie = "UPDATE ".$prefix."wikkaforum SET wid='$id' WHERE id='$id'";
#print $zapytanie;
$sql = mysql_query($zapytanie) or die (mysql_error());
} else {
$zapytanie = "UPDATE ".$prefix."wikkaforum SET for_dataw=now() WHERE id='$frm_wid'";
#print $zapytanie;
$sql = mysql_query($zapytanie) or die (mysql_error());
$link = $link . "&wid=" . $frm_wid;
header("Location: $link");
}
}
// Show_SForum: Displays the main message of threads
function Show_SForum($link, $tag, $prefix, $isadmin) {
$sql = "SELECT * FROM ".$prefix."wikkaforum WHERE id=wid AND tag='$tag' ORDER BY for_dataw DESC";
#print $sql."<br>\n";
$sql = mysql_query($sql) or die (mysql_error());
$iledokumentow = mysql_affected_rows();
if ($iledokumentow > 0) {
print("<TABLE BORDER=\"1\" WIDTH=\"100%\" id=\"forum\">\n");
print("<tr><td bgcolor=\"#F8F8F8\"><b>Topic</b></td><td align=\"center\" bgcolor=\"#F8F8F8\"><b>Replies</b></td><td align=\"center\" bgcolor=\"#F8F8F8\"><b>Posted by</b></td><td align=\"center\" bgcolor=\"#F8F8F8\"><b>Timestamp</b></td>");
while ($row = mysql_fetch_array($sql)) {
$sql1 = "SELECT COUNT(wid)-1 AS num FROM ".$prefix."wikkaforum WHERE wid=".$row['id']." AND tag='$tag' GROUP BY wid";
#print $sql1."<br>\n";
$sql1 = mysql_query($sql1) or die (mysql_error());
$row1 = mysql_fetch_array($sql1);
//number of reactions
$this->react=$row1['num'];
if ($row['for_name'] == "") {
$row['for_name'] = "Guest";
}
$this->ptitle = stripslashes($row['for_ptitle']);
if ($isadmin) {
$adminfunc = "<td width=\"5%\" align=\"center\"><a href=\"".$link."&deletethread=".$row['id']."\">delete</a></td>";
}
print("<tr ALIGN='left'><TD width=\"60%\">$link2<A HREF=\"".$link."&wid=".$row['id']."\">".$this->ptitle."</A></TD><TD ALIGN=\"center\" width=\"5%\">".$this->react."</TD><TD ALIGN=\"center\" WIDTH=\"10%\">".$row['for_name']."</TD><TD ALIGN=\"center\" WIDTH=\"20%\">".$row['for_dataw']."</TD>".$adminfunc."</tr>\n\n");
}
unset($this->react);
print("</TABLE>\n");
} else {
print("<br> There are no threaded topics yet. Why don't you start one?<br>\n");
}
$this->ptitle = ""; //the new thread's title is empty
}
// Show_ForumCount: Displays the count of the number of threads
function Show_SForumCounter($tag, $prefix) {
$sql = "SELECT * FROM ".$prefix."wikkaforum WHERE id=wid AND tag='$tag' ORDER BY for_dataw DESC";
$sql = mysql_query($sql) or die (mysql_error());
$iledokumentow = mysql_affected_rows();
if ($iledokumentow > 0) {
while ($row = mysql_fetch_array($sql)) {
$sql1 = "SELECT COUNT(wid)-1 AS num FROM ".$prefix."wikkaforum WHERE wid=".$row['id']." AND tag='$tag' GROUP BY wid";
#print $sql1."<br>\n";
$sql1 = mysql_query($sql1) or die (mysql_error());
$row1 = mysql_fetch_array($sql1);
//number of reactions
$this->react=$row1['num'];
$count=$count + 1;
}
unset($this->react);
echo "<small>[# of threads:".$count.$row['for_data']."</small>";
}else{
echo "<small>[# of threads: 0</small>";
}
}
// Show_SForum_Threads: Displays all messages of a thread
function Show_SForum_Threads($wid, $tag, $prefix, $link, $isadmin) {
global $wakka;
//$this->pansw = $wid;
$zapytanie = "SELECT * FROM ".$prefix."wikkaforum WHERE wid='$wid' AND tag='$tag' ORDER BY for_data ASC";
//print $zapytanie;
$sql = mysql_query($zapytanie) or die (mysql_error());
$iledokumentow = mysql_affected_rows();
if ($iledokumentow > 0) {
print("<TABLE BORDER=\"1\" WIDTH=\"100%\" id=\"forum\">\n");
while ($row = mysql_fetch_array($sql)) {
$this->ptitle = stripslashes($row['for_ptitle']);
$printtext = (stripslashes($row['for_text']));
$brackets = Array ('/{{/i', '/}}/i');
$changeto = '|.|';
$printtext = preg_replace($brackets, $changeto, $printtext);
$remove = array('#%', '======', '=====', '====', '===', '==', '[[', | ']]', '||', '#0025#0025', '<<', '>>', '::c::', '""');
$printtext = str_replace($remove, '', $printtext);
$printtext = $wakka->format($printtext);
if ($row['for_name'] == "") {
$row['for_name'] = "Guest";
}
$pmail = NULL;
$kmail = NULL;
if ($isadmin) {
if ($wid==$row['id']) {
$adminfunc = " [<a href=\"".$link."&deletethread=".$wid."\">delete thread</a>]";
} else {
$adminfunc = " [<a href=\"".$link."&wid=".$wid."&deletepost=".$row['id']."\">delete</a>]";
}
}
print("<tr ALIGN='left'><TD><b>".$this->ptitle."</b><div ALIGN=\"right\"><i>$pmail".$row['for_name']."$kmail <FONT SIZE=\"1\">".$row['for_data']."</FONT></i>".$adminfunc."</div>\n\n");
print("<hr>".$printtext."<br><br></TD></tr>\n\n");
}
print("</TABLE>\n");
} else {
print(" No threads(s) exist for this topic.<br>\n");
}
$zapytanie = "SELECT * FROM ".$prefix."wikkaforum WHERE id='$wid' AND tag='$tag' LIMIT 0,1";
$sql = mysql_query($zapytanie) or die (mysql_error());
$row = mysql_fetch_array($sql);
$this->ptitle = stripslashes($row['for_ptitle']); //Re title for form
}
// Show_SForum_Thread_Name: Displays all messages of a thread
function Show_SForum_Thread_Name($wid, $tag, $prefix) {
$zapytanie = "SELECT for_ptitle FROM ".$prefix."wikkaforum WHERE id='$wid' AND tag='$tag' LIMIT 0,1";
$sql = mysql_query($zapytanie) or die (mysql_error());
$row = mysql_fetch_array($sql);
$this->ptitle = stripslashes($row['for_ptitle']); //Re title for form
print($this->ptitle);
}
}
?>
// wikkaforumfunctions.php Version 1.0j - Aug 4, 2007 - added delete thread and delete post functions by DaveFullard
// USE: required to be able to use wikkaforum.php & forumcounter.php actions.
// This file **must** be placed in a directory in wikka root called "scripts".
// Modifications & original code released under GPL
// **NOTE** for inclusion on a wiki page double percents were replaced by #0025 on line 154, they need
// to be replaced as double percents. It is not advised that you do not replace code formatting marks.
/**********************************
* SForum class
* @author: Wojciech Napierała XII.2004
* @help: Ondra Marek [email protected]
* @
* [email protected]
*
* @license: GNU GPL
**********************************
*/
class SForum {
var $ptitle;
var $react; // number of answers in a thread
var $pansw;
var $title;
// SForum: constructor
function SForum() {
$this->ptitle = NULL;
$this->pansw = 0;
$this->title = "<TITLE>$this->SFname</TITLE>";
print($this->title);
}
// Show_frm: displays the form
function Show_frm($ptitle=NULL, $link, $wid) {
if(!empty($ptitle)) {
$this->ptitle = "Re: ".$ptitle;
}
$showrules="";
if (!EMPTY($wid)){$showrules="<small>Except in titles, several wiki formatting codes (bold(<bold>**</bold>), italics(<strong>//</strong>), underline(<strong>__</strong>),<br /> strikethrough(<strong>++</strong>), highlight (two single quotes...<strong>''</strong>), centering (<strong>@@</strong>) and bulleted lists(<strong>~-</strong>) <br />(and other lists)) are active. Headings, actions, tables, and external linking are not activated. </small>";}
$zawartosc = "\n\n<FORM ACTION=\"".$link."\" METHOD=\"post\" NAME=\"frm\">\n"
. "<TABLE><TR>\n"
. "<TD>Title:</TD><TD><INPUT TYPE=\"text\" NAME=\"frm_ptitle\" VALUE=\"$this->ptitle\" SIZE=\"65\"></TD>\n"
. "</TR><TR>\n"
. "<TD VALIGN=top>Text:</TD><TD><TEXTAREA NAME=\"frm_text\" cols=\"65\" rows=\"10\"></TEXTAREA></TD>\n"
. "</TR><TR>\n"
. "<TD></TD><TD COLLSPAN=\"2\"><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Submit Comment\"></TD>\n"
. "</tr><tr><td></td><td>".$showrules."</td></tr></TABLE>\n"
. "<INPUT TYPE=\"hidden\" NAME=\"frm_ip\" VALUE=\"".$_SERVER['REMOTE_ADDR']."\">\n"
. "<INPUT TYPE=\"hidden\" NAME=\"frm_wid\" VALUE=\"".$this->pansw."\">\n"
. "</FORM>\n\n";
print($zawartosc);
}
// Show_SFname : Show SForum name as text
function Show_SFname($topic) {
print("<H2>$topic</H2>\n");
}
function delete_post($id,$prefix,$link,$wid,$isadmin) {
if ($isadmin==true) {
$delete = "DELETE FROM ".$prefix."wikkaforum WHERE id='".$id."';";
$sql = mysql_query($delete) or die (mysql_error());
} else {
echo "Sorry, but you're not allowed to delete posts!";
}
$link = $link."&wid=".$wid;
header("Location: $link");
}
function delete_thread($wid,$prefix,$link,$isadmin) {
if ($isadmin==true) {
$delete = "DELETE FROM ".$prefix."wikkaforum WHERE wid='".$wid."';";
$sql = mysql_query($delete) or die (mysql_error());
} else {
echo "Sorry, but you're not allowed to delete threads!";
}
header("Location: $link");
}
// Add_new_post: Adds new record to DB (updated 10 Jan 2005)
function Add_new_post($ptitle,$text,$tag,$ip,$name,$frm_wid,$link,$prefix) {
if($ptitle=="" or $text==""){
return;
}
$this->ptitle = addslashes(htmlspecialchars(trim($ptitle)));
$this->text = addslashes(htmlspecialchars(trim($text)));
if ($frm_wid == 0) {
$zapytanie = "INSERT INTO ".$prefix."wikkaforum (wid,for_ptitle,for_text,tag,for_data,for_dataw,for_ip,for_name) VALUES('$frm_wid', '$this->ptitle', '$this->text', '$tag', now(), now(), '$ip', '$name')";
$sql = mysql_query($zapytanie) or die (mysql_error());
} else {
$zapytanie = "INSERT INTO ".$prefix."wikkaforum (wid,for_ptitle,for_text,tag,for_data,for_ip,for_name) VALUES('$frm_wid', '$this->ptitle', '$this->text', '$tag', now(), '$ip', '$name')";
$sql = mysql_query($zapytanie) or die (mysql_error());
}
$id = mysql_insert_id();
if ($frm_wid == 0) {
$zapytanie = "UPDATE ".$prefix."wikkaforum SET wid='$id' WHERE id='$id'";
#print $zapytanie;
$sql = mysql_query($zapytanie) or die (mysql_error());
} else {
$zapytanie = "UPDATE ".$prefix."wikkaforum SET for_dataw=now() WHERE id='$frm_wid'";
#print $zapytanie;
$sql = mysql_query($zapytanie) or die (mysql_error());
$link = $link . "&wid=" . $frm_wid;
header("Location: $link");
}
}
// Show_SForum: Displays the main message of threads
function Show_SForum($link, $tag, $prefix, $isadmin) {
$sql = "SELECT * FROM ".$prefix."wikkaforum WHERE id=wid AND tag='$tag' ORDER BY for_dataw DESC";
#print $sql."<br>\n";
$sql = mysql_query($sql) or die (mysql_error());
$iledokumentow = mysql_affected_rows();
if ($iledokumentow > 0) {
print("<TABLE BORDER=\"1\" WIDTH=\"100%\" id=\"forum\">\n");
print("<tr><td bgcolor=\"#F8F8F8\"><b>Topic</b></td><td align=\"center\" bgcolor=\"#F8F8F8\"><b>Replies</b></td><td align=\"center\" bgcolor=\"#F8F8F8\"><b>Posted by</b></td><td align=\"center\" bgcolor=\"#F8F8F8\"><b>Timestamp</b></td>");
while ($row = mysql_fetch_array($sql)) {
$sql1 = "SELECT COUNT(wid)-1 AS num FROM ".$prefix."wikkaforum WHERE wid=".$row['id']." AND tag='$tag' GROUP BY wid";
#print $sql1."<br>\n";
$sql1 = mysql_query($sql1) or die (mysql_error());
$row1 = mysql_fetch_array($sql1);
//number of reactions
$this->react=$row1['num'];
if ($row['for_name'] == "") {
$row['for_name'] = "Guest";
}
$this->ptitle = stripslashes($row['for_ptitle']);
if ($isadmin) {
$adminfunc = "<td width=\"5%\" align=\"center\"><a href=\"".$link."&deletethread=".$row['id']."\">delete</a></td>";
}
print("<tr ALIGN='left'><TD width=\"60%\">$link2<A HREF=\"".$link."&wid=".$row['id']."\">".$this->ptitle."</A></TD><TD ALIGN=\"center\" width=\"5%\">".$this->react."</TD><TD ALIGN=\"center\" WIDTH=\"10%\">".$row['for_name']."</TD><TD ALIGN=\"center\" WIDTH=\"20%\">".$row['for_dataw']."</TD>".$adminfunc."</tr>\n\n");
}
unset($this->react);
print("</TABLE>\n");
} else {
print("<br> There are no threaded topics yet. Why don't you start one?<br>\n");
}
$this->ptitle = ""; //the new thread's title is empty
}
// Show_ForumCount: Displays the count of the number of threads
function Show_SForumCounter($tag, $prefix) {
$sql = "SELECT * FROM ".$prefix."wikkaforum WHERE id=wid AND tag='$tag' ORDER BY for_dataw DESC";
$sql = mysql_query($sql) or die (mysql_error());
$iledokumentow = mysql_affected_rows();
if ($iledokumentow > 0) {
while ($row = mysql_fetch_array($sql)) {
$sql1 = "SELECT COUNT(wid)-1 AS num FROM ".$prefix."wikkaforum WHERE wid=".$row['id']." AND tag='$tag' GROUP BY wid";
#print $sql1."<br>\n";
$sql1 = mysql_query($sql1) or die (mysql_error());
$row1 = mysql_fetch_array($sql1);
//number of reactions
$this->react=$row1['num'];
$count=$count + 1;
}
unset($this->react);
echo "<small>[# of threads:".$count.$row['for_data']."</small>";
}else{
echo "<small>[# of threads: 0</small>";
}
}
// Show_SForum_Threads: Displays all messages of a thread
function Show_SForum_Threads($wid, $tag, $prefix, $link, $isadmin) {
global $wakka;
//$this->pansw = $wid;
$zapytanie = "SELECT * FROM ".$prefix."wikkaforum WHERE wid='$wid' AND tag='$tag' ORDER BY for_data ASC";
//print $zapytanie;
$sql = mysql_query($zapytanie) or die (mysql_error());
$iledokumentow = mysql_affected_rows();
if ($iledokumentow > 0) {
print("<TABLE BORDER=\"1\" WIDTH=\"100%\" id=\"forum\">\n");
while ($row = mysql_fetch_array($sql)) {
$this->ptitle = stripslashes($row['for_ptitle']);
$printtext = (stripslashes($row['for_text']));
$brackets = Array ('/{{/i', '/}}/i');
$changeto = '|.|';
$printtext = preg_replace($brackets, $changeto, $printtext);
$remove = array('#%', '======', '=====', '====', '===', '==', '[[', | ']]', '||', '#0025#0025', '<<', '>>', '::c::', '""');
$printtext = str_replace($remove, '', $printtext);
$printtext = $wakka->format($printtext);
if ($row['for_name'] == "") {
$row['for_name'] = "Guest";
}
$pmail = NULL;
$kmail = NULL;
if ($isadmin) {
if ($wid==$row['id']) {
$adminfunc = " [<a href=\"".$link."&deletethread=".$wid."\">delete thread</a>]";
} else {
$adminfunc = " [<a href=\"".$link."&wid=".$wid."&deletepost=".$row['id']."\">delete</a>]";
}
}
print("<tr ALIGN='left'><TD><b>".$this->ptitle."</b><div ALIGN=\"right\"><i>$pmail".$row['for_name']."$kmail <FONT SIZE=\"1\">".$row['for_data']."</FONT></i>".$adminfunc."</div>\n\n");
print("<hr>".$printtext."<br><br></TD></tr>\n\n");
}
print("</TABLE>\n");
} else {
print(" No threads(s) exist for this topic.<br>\n");
}
$zapytanie = "SELECT * FROM ".$prefix."wikkaforum WHERE id='$wid' AND tag='$tag' LIMIT 0,1";
$sql = mysql_query($zapytanie) or die (mysql_error());
$row = mysql_fetch_array($sql);
$this->ptitle = stripslashes($row['for_ptitle']); //Re title for form
}
// Show_SForum_Thread_Name: Displays all messages of a thread
function Show_SForum_Thread_Name($wid, $tag, $prefix) {
$zapytanie = "SELECT for_ptitle FROM ".$prefix."wikkaforum WHERE id='$wid' AND tag='$tag' LIMIT 0,1";
$sql = mysql_query($zapytanie) or die (mysql_error());
$row = mysql_fetch_array($sql);
$this->ptitle = stripslashes($row['for_ptitle']); //Re title for form
print($this->ptitle);
}
}
?>
WikkaMail Addons
newmail.php
Place this file in the actions directory
<?php
// This newmail.php (Version 0.1a) is an addon to mail.php. Released under GPL.
// Use: {{newmail}} (no parameters). Requires WikkaMail
$pmpage="PrivateMessages"; //Set the page with the {{mail}} action
$username = $this->GetUserName();
$query="SELECT * FROM ".$this->config["table_prefix"]."mail where UserTo='".$username."' and status='unread' and viewrecipient='Y'";
$result=mysql_query($query) or die ("cant do it");
$num_rows = mysql_num_rows($result);
if ($num_rows>0) {
echo "<a href='".$link.$pmpage."'><img src='images/newmail.gif' border='0' alt='You have ".$num_rows." new messages'></a>";
} else {
echo "<a href='".$link.$pmpage."'><img src='images/mail.gif' border='0' alt='You have no new messages'></a>";
}
?>
// This newmail.php (Version 0.1a) is an addon to mail.php. Released under GPL.
// Use: {{newmail}} (no parameters). Requires WikkaMail
$pmpage="PrivateMessages"; //Set the page with the {{mail}} action
$username = $this->GetUserName();
$query="SELECT * FROM ".$this->config["table_prefix"]."mail where UserTo='".$username."' and status='unread' and viewrecipient='Y'";
$result=mysql_query($query) or die ("cant do it");
$num_rows = mysql_num_rows($result);
if ($num_rows>0) {
echo "<a href='".$link.$pmpage."'><img src='images/newmail.gif' border='0' alt='You have ".$num_rows." new messages'></a>";
} else {
echo "<a href='".$link.$pmpage."'><img src='images/mail.gif' border='0' alt='You have no new messages'></a>";
}
?>