|
<?php
|
|
/**
|
|
* @package uForum
|
|
* @file includes/classes/class_posting.php
|
|
* @version $Id: classes/class_posting.php 15 2009-05-01 17:06:40Z pioder $
|
|
* @copyright 2009(c) PioDer <[email protected]>
|
|
* @link http://pioder.gim2przemysl.int.pl/
|
|
* @license GNU GPL v3
|
|
**/
|
|
if ( !defined('IN_uF') )
|
|
{
|
|
die('Hacking attempt');
|
|
}
|
|
class Post
|
|
{
|
|
function NewPost($tid, $post, $uid)
|
|
{
|
|
#read last post
|
|
$last = DataBase::new_id(POSTS_TABLE);
|
|
#read last post in topic
|
|
$sql = "SELECT * FROM ".POSTS_TABLE." WHERE t_id='$tid' ORDER BY tp_id DESC LIMIT 1;";
|
|
$query = DataBase::sql_query($sql,'GENERAL','Could not last post information.');
|
|
$result = DataBase::fetch($query);
|
|
$forum = $result['f_id'];//forum id
|
|
$moderate = Forum::ForumInformation($forum,'moderate');
|
|
$tpid = $result['tp_id'];//post in topic id
|
|
$tpid = $tpid+1;
|
|
#
|
|
$time = time();
|
|
#add new post
|
|
$sql = "INSERT INTO `".POSTS_TABLE."` VALUES ('$last','$tid', '$uid', '$post', '".$_SERVER['HTTP_USER_AGENT']."', '$time', '$tpid', '$forum','$moderate','".$_SERVER['REMOTE_ADDR']."')";
|
|
$query = DataBase::sql_query($sql,'GENERAL','Could not add new post.');
|
|
$result=User::UserInformation($uid,'posts');
|
|
$result = $result+1;
|
|
$sql="UPDATE ".TOPICS_TABLE." SET lastpost_time='$time' WHERE t_id='$tid' ";
|
|
$query = DataBase::sql_query($sql,'GENERAL','Could not update user information.');
|
|
$sql="UPDATE ".USERS_TABLE." SET posts='$result' WHERE u_id='$uid' ";
|
|
$query = DataBase::sql_query($sql,'GENERAL','Could not update user information.');
|
|
return $tpid;
|
|
}
|
|
|
|
function EditPost($postid, $text)
|
|
{
|
|
$sql = "UPDATE `".POSTS_TABLE."` SET text='$text' WHERE `p_id`='$postid';";
|
|
$query = DataBase::sql_query($sql,'GENERAL','Could not edit post.');
|
|
}
|
|
|
|
function NewTopic($posttext, $ntopic, $forum, $uid, $sticky)
|
|
{
|
|
//Select last topic
|
|
$moderate = Forum::ForumInformation($forum,'moderate');
|
|
$time = time();
|
|
$lastt=DataBase::new_id(TOPICS_TABLE);
|
|
$sql = "INSERT INTO ".TOPICS_TABLE." VALUES ('$lastt', '$forum', '0', '$sticky', '$ntopic', '$uid','$time')";
|
|
$query = DataBase::sql_query($sql,'GENERAL','Could not add new topic');
|
|
//add post
|
|
//select last post
|
|
$last = DataBase::new_id(POSTS_TABLE);
|
|
//add post
|
|
$sql = "INSERT INTO ".POSTS_TABLE." VALUES ('$last','$lastt', '$uid', '$posttext','".$_SERVER['HTTP_USER_AGENT']."', '$time', '1', '$forum', '$moderate','".$_SERVER['REMOTE_ADDR']."');";
|
|
$query = DataBase::sql_query($sql,'GENERAL','Could not add new post.');
|
|
$sql = "SELECT * FROM ".USERS_TABLE." WHERE u_id='$uid';";
|
|
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain user information.');
|
|
$result = DataBase::fetch($query);
|
|
$result = $result['posts'];
|
|
$result = $result+1;
|
|
$sql = "UPDATE ".USERS_TABLE." SET posts='$result' WHERE u_id='$uid' ";
|
|
$query = DataBase::sql_query($sql,'GENERAL','Could not update user information.');
|
|
return $lastt;
|
|
}
|
|
|
|
function SmilesShow()
|
|
{
|
|
$text ='';
|
|
$result='';
|
|
$sql = "SELECT * FROM ".SMILES_TABLE."";
|
|
$query = DataBase::sql_query($sql,'GENERAL','Cold not obtain smiles information.');
|
|
$i = 1;
|
|
while($smile = DataBase::fetch($query))
|
|
{
|
|
$action = "insertSmile('".$smile['url']."','".$smile['smile']."')";
|
|
$mouse = "this.style.cursor='hand';";
|
|
$text = "\n".'<img src="'.$smile['url'].'" onmouseover="'.$mouse.'" onclick="'.$action.'" alt="'.$smile['smile'].'"> '."\n";
|
|
$result = $result.$text;
|
|
if ($i%5==0)
|
|
{
|
|
$i = 1;
|
|
$result=$result.'<br>';
|
|
}
|
|
else
|
|
{
|
|
$i +=1;
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
function SmilesReplace($text)
|
|
{
|
|
$sql = "SELECT * FROM ".SMILES_TABLE."";
|
|
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain emoticons information.');
|
|
$i = 1;
|
|
while($result = DataBase::fetch($query))
|
|
{
|
|
$smile[$i]['smile'] = $result['smile'];
|
|
$smile[$i]['url'] = $result['url'];
|
|
$i +=1;
|
|
}
|
|
$smile = (!isset($smile)) ? array() : $smile;
|
|
$i = 1;
|
|
for($i=1;$i<=count($smile);$i++)
|
|
{
|
|
$text = str_replace(' '.$smile[$i]['smile'],'<img src="'.$smile[$i]['url'].'" alt="'.$smile[$i]['smile'].'">', $text);
|
|
$text = str_replace(' '.$smile[$i]['smile'],'<img src="'.$smile[$i]['url'].'" alt="'.$smile[$i]['smile'].'">', $text);
|
|
}
|
|
return $text;
|
|
}
|
|
}
|
|
?>
|