A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

96 lines
3.6 KiB

<?php
/**
* @package uForum
* @file includes/class_mod.php
* @version $Id$
* @copyright 2009(c) PioDer <[email protected]>
* @link http://pioder.gim2przemysl.int.pl/
* @license GNU GPL v3
**/
if ( !defined('IN_uF') )
{
die('Hacking attempt');
}
class Mod
{
function MoveTopic($tid, $fid)
{
$sql = "UPDATE `".TOPICS_TABLE."` SET `f_id`='$fid' WHERE `t_id`='$tid'";
DataBase::sql_query($sql,'GENERAL','Could not update topic');
$sql = "UPDATE `".POSTS_TABLE."` SET `f_id`='$fid' WHERE `t_id`='$tid'";
DataBase::sql_query($sql,'GENERAL','Could not update post');
}
function TopicLocked($tid)
{
global $default_skin;
global $default_lang;
$lock = Topic::TopicInformation($tid,'lock');
if ($lock=='1')
{
return '<a href="moderate.php?action=unlock&amp;id='.$tid.'"><img border="0" src="skins/'.$default_skin.'/images/unlock.gif" width="20" height="20" alt="unlock">';
}
else
{
return '<a href="moderate.php?action=lock&amp;id='.$tid.'"><img border="0" src="skins/'.$default_skin.'/images/lock.gif" width="20" height="20" alt="lock"></a>';
}
}
function DeleteTopic($topicid)
{
$sql="SELECT * FROM ".POSTS_TABLE." WHERE `t_id`='$topicid'";
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain post information');
while($item = @mysql_fetch_array($query))
{
$uid = Topic::PostInformation($item['p_id'],'u_id');
$posts = User::UserInformation($uid,'posts');
$posts = $posts -1;
$sql = "UPDATE `".USERS_TABLE."` SET `posts`='$posts' WHERE `u_id`='$uid'";
DataBase::sql_query($sql,'GENERAL','Could not update user amout of posts');
}
$sql = "DELETE FROM ".POSTS_TABLE." WHERE t_id='$topicid';";
DataBase::sql_query($sql,'GENERAL','Could not delete topic posts.');
$sql = "DELETE FROM ".TOPICS_TABLE." WHERE t_id='$topicid';";
DataBase::sql_query($sql,'GENERAL','Could not delete topic posts.');
}
function LockTopic($topicid)
{
$sql = "UPDATE `".TOPICS_TABLE."` SET `lock` = '1' WHERE `t_id` =$topicid;";
DataBase::sql_query($sql,'GENERAL','Could not lock topic.');
}
function StickTopic($topicid, $mode)
{
$sql = "UPDATE `".TOPICS_TABLE."` SET `sticky` = '$mode' WHERE `t_id` =$topicid;";
DataBase::sql_query($sql,'GENERAL','Could not stick topic.');
}
function UnlockTopic($topicid)
{
$sql = "UPDATE `".TOPICS_TABLE."` SET `lock` = '0' WHERE `t_id` =$topicid;";
DataBase::sql_query($sql,'GENERAL','Could not unlock topic.');
}
function DeletePost($postid)
{
$uid = Topic::PostInformation($postid,'u_id');
$tid = Topic::PostInformation($postid,'t_id');
$posts = User::UserInformation($uid,'posts');
$posts = $posts -1;
$sql = "UPDATE `".USERS_TABLE."` SET `posts`='$posts' WHERE `u_id`='$uid'";
DataBase::sql_query($sql,'GENERAL','Could not update user amout of posts');
$sql2 = "DELETE FROM ".POSTS_TABLE." WHERE p_id='$postid';";
DataBase::sql_query($sql2,'GENERAL','Could not delete post.');
$sql = "SELECT * FROM ".POSTS_TABLE." WHERE p_id>'$postid' AND `t_id`='$tid';";
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain post information.');
while($item=mysql_fetch_array($query))
{
$number = $item['tp_id'];
$number = $number-1;
$number2 = $item['p_id'];
$sql3 = "UPDATE `".POSTS_TABLE."` SET `tp_id` = '$number' WHERE `p_id` =$number2;";
DataBase::sql_query($sql3,'GENERAL','Could not update post.');
}
}
function AcceptPost($postid)
{
$sql = "UPDATE `".POSTS_TABLE."` SET `moderated`='0' WHERE `p_id`='$postid'";
DataBase::sql_query($sql, 'GENERAL', 'Could not accept post');
}
}
?>