rendered paste body<?php
if (!defined("PROJECT")){
die("Please use the main site...");
}
/*******************************************************************
* forum - Performs all the forum maintenance in different languiages
* accordinfg to $_SESSION["lang"]
* Users can add threads and posts but these will be seen only after
* administrator aprooval. Email is sent to admin of the site with
* SendMAIL fucntion located in functii.php
*******************************************************************/
class forum{
var $email;
Function forum($logat, $level, $userid, $email){
$this->email = $email;
$this->messages();
$this->createdatabases();
if ($_POST){
$this->processposts($level,$userid);
}
if (!isset($_GET["forum_threads"])){
echo "<h3>WELCOME TO OUR FORUM</h3>";
$this->list_threads($logat,$level,$userid);
} else {
echo "<h3>FORUM SECTION : ".getfieldvalue("forum_threads_".$_SESSION["lang"], "forum_threads_name","forum_threads_id",$_GET["forum_threads"])."</h3>";
$this->list_posts($_GET["forum_threads"],$logat,$level,$userid);
}
if ($logat){
echo "<form method=\"POST\" id=\"forum\" action=\"".$_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING']."\">";
echo "<br>";
if (!isset($_GET["forum_threads"])){
echo "<p class=\"forum\">Add a new thread:<br>";
echo "<input class=\"forum\" type=\"text\" size=\"50\" name=\"text\" value=\"New thread name\"><br><br>";
echo "<input class=\"forumbuttons\" type=\"submit\" name=\"submit[addthread]\" value=\"Submit\"></p>";
} else {
echo "<p class=\"forum\">";
echo "Post name : <br>";
echo "<input class=\"forum\" type=\"text\" name=\"name\" value=\"New post:\"><br>";
echo "<br>";
echo "Text to insert: <br>";
echo "<textarea class=\"forum\" rows=\"15\" name=\"text\" cols=\"100\">Your message...</textarea><br>";
echo " <input class=\"forumbuttons\" type=\"submit\" name=\"submit[addpost]\" value=\"Submit\">";
echo "</p>";
}
echo "</form>";
} else {
echo "<br><span class=\"warning\">";
echo "Please register to be able to post into this forum...";
echo "</span><br>";
}
$this->forumrules();
}
/*******************************************************************
* addthread - add a active or inactive thread according to userlevel
*******************************************************************/
Function addthread($text,$level,$userid){\
if($level==9){
$query = '
INSERT INTO forum_threads_'.$_SESSION["lang"].' (
forum_threads_id ,
forum_threads_name ,
forum_threads_user ,
forum_threads_active
)
VALUES (
"0",
"'.quote_smart($text).'",
"'.quote_smart($userid).'",
"1"
)';
} else {
$query = '
INSERT INTO forum_threads_'.$_SESSION["lang"].' (
forum_threads_id ,
forum_threads_name ,
forum_threads_user ,
forum_threads_active
)
VALUES (
"0",
"'.quote_smart($text).'",
"'.quote_smart($userid).'",
"0"
)';
sendMail($this->email,"New thread on your site","\n\nNew thread on your site\n".$text);
}
$result = mysql_query($query);
}
/*******************************************************************
* list_threads - list threads of the current forum
*******************************************************************/
Function list_threads($logat,$level,$userid){
$query = "select * from forum_threads_".$_SESSION["lang"]." where forum_threads_active = 1 ORDER by forum_threads_name";
$result = mysql_query($query) or die (mysql_error());
echo "<ul>";
While ( $row = mysql_fetch_array($result) )
{
echo "<li>";
if ($logat && ($level==9 || $row["forum_threads_user"]==$userid)){
echo "<input class=\"forum\" type=\"checkbox\" name=\"C1[".$row["forum_threads_id"]."]\" value=\"ON\"> ";
if ($level==9){
if ($row["forum_threads_active"]==0){
echo "<input class=\"forum\" type=\"checkbox\" name=\"R1[".$row["forum_threads_id"]."]\" value=\"ON\"> ";
} else {
echo "<input class=\"forum\" type=\"checkbox\" name=\"R1[".$row["forum_threads_id"]."]\" value=\"ON\" checked> ";
}
}
}
if ($row["forum_threads_active"]==0){
echo "<span class=\"warning\">(W)</span> ";
}
$forum_threads_name = htmlspecialchars($row["forum_threads_name"]);
echo " <a href=\"{$_SERVER['SCRIPT_NAME']}?{$_SERVER['QUERY_STRING']}&forum_threads=".$row["forum_threads_id"]."\">".$forum_threads_name."</a> (".$this->threads_count($row["forum_threads_id"]).")";
echo "</li>";
}
echo "</ul>";
if ($logat){
echo " <input class=\"forumbuttons\" type=\"submit\" name=\"submit[deletethread]\" value=\"Delete\">";
if ($level==9){
echo " <input class=\"forumbuttons\" type=\"submit\" name=\"submit[aproovethread]\" value=\"Aproove\">";
}
echo "</form>";
}
if ($logat){
echo "<p><br><span class=\"warning\">(W)</span> = waiting for approval</p>";
}
}
/*******************************************************************
* processposts - is processing the POST situation
*******************************************************************/
Function processposts($level,$userid){
if ($_POST){
$submit_array = array_keys($_POST['submit']);
$action = $submit_array[0];
//echo $action;
switch ($action)
{
case 'addthread':
echo "<p class=\"info\">Thread added...</p>";
$text = $_POST["text"];
$this->addthread($text,$level,$userid);
echo "<p class=\"info\">The new threads are moderated ! Please allow 1-24 hrs for aproval.</p>";
break;
}
}
}
}
if ($session->username!=="Guest"){
$email = $session->userinfo["email"];
} else {
$email = "EMAIL UNKNOWNED";
}
$forum = new forum($session->logged_in, $session->userlevel, $session->username, $email);
?>