* @link http://pioder.gim2przemysl.int.pl/dsf.html * @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 = mysql_fetch_array($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 = mysql_fetch_array($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 = mysql_fetch_array($query)) { $action = "insertSmile('".$smile['url']."','".$smile['smile']."')"; $mouse = "this.style.cursor='hand';"; $text = "\n".''.$smile['smile'].' '."\n"; $result = $result.$text; if ($i%5==0) { $i = 1; $result=$result.'
'; } 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 = mysql_fetch_array($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'],''.$smile[$i]['smile'].'', $text); $text = str_replace(' '.$smile[$i]['smile'],''.$smile[$i]['smile'].'', $text); } return $text; } } ?>