get_row("SELECT * FROM f_posts WHERE id='$postid'");
if(!$post)
{
forward("index.php"); // post is invalid so redirect user
}
$forum=$db->get_row("SELECT * FROM f_forums f, f_permissions p WHERE f.forumid='$post->postforum' AND f.forumid=p.forumid AND p.groupid='$user->groupid'");
$forumid=$post->postforum;
?>
Edit post - title;?>
banned)
{
err_msg("Edit Post","You dont have right to perform this action.");
}
$thedate=date("U");
if($post->authorid == $user->userid && $forum->editpost != 1)
{
err_msg("Edit Post","You don't have this permission.");
}
else if($post->authorid != $user->userid)
{
if($forum->editotherpost == 1)
{
$gid=groupidbyuserid($post->authorid);
if($group[$user->groupid]['type'] < $group[$gid]['type'])
{
err_msg("Edit Post","You don't have this permission");
}
else if(($group[$user->groupid]['type'] == $group[$gid]['type']) && ($group[$user->userid]['sort'] <= $group[$gid]['sort']))
{
err_msg("Edit Post","You don't have this permission");
}
}
else
err_msg("Edit Post","You don't have this permission");
}
if(!get_magic_quotes_gpc())
{
$text= mysql_real_escape_string($text);
}
if(isset($_POST['submitpost']))
{
if($post->threadparent == "0")
{
$topictitle=strip_tags(trim($_POST['topictitle']));
}
else
{
$topictitle="";
}
$description=trim($_POST['description']);
if(strlen($description) == "0")
{
err_msg("Edit Post","Message was blank. Please post something.");
}
if($post->threadparent == "0")
{
if(strlen($topictitle) == "0")
{
err_msg("Edit Post","Topic title was blank. Please post something.");
}
}
if(isset($_POST['nosmiley']))
$nosmiley=1;
else
$nosmiley=0;
$timegone=date("U");
$posting="UPDATE f_posts SET title='$topictitle', post='$description', nosmilies='$nosmiley', ipaddress='$config->ip', editedby='$user->userid' WHERE id='$postid'";
$db->update_data($posting);
if($post->threadparent=="0")
{
$posting="UPDATE f_threads SET title='$topictitle' WHERE id='$postid'";
$db->update_data($posting);
}
/*
if($s==1)
{
$db->update_data("UPDATE f_threads SET stick=1 WHERE id='$threadid'");
}
*/
$tlapse=date("U");
$updates2="UPDATE c_users SET lastposttime='$tlapse' WHERE userid='$user->userid'";
$db->update_data($updates2);
forward2("f/".$forumid."/".converturl($forum->name).".html","2");
err_msg("Edit Post","Message is edited successfully. Please wait while we redirect you to Forum.");
}
else
{
?>
Edit Post
///////////////////////////////
get_row("SELECT * FROM c_settings");
define('SPAK',$config->url.'images/smilies/Set_Smiles_YarNET.pak');
/**
* Redirects to new URL, If header not passed
*
* @param string $uri New URI to redirect
* @param bool $type If false then full URI is passed, If true then half URI(no domain) is passed.
*
*/
function forward($uri,$type=false){
global $config;
if(!headers_sent()){
if($type){
header("Location:"."$uri");
exit;
}else{
header("Location:".$config->url."$uri");
exit;
}
}
}
/**
* Redirects to new URL using META tag of html
*
* @param string $uri New URI to redirect
* @param integer $time After this seconds to redirect
* @param bool $type If false then full URI is passed, If true then half URI(no domain) is passed.
*
*/
function forward2($uri,$time="2",$type=false){
global $config;
if($type){
print "";
}else{
print "";
}
}
/**
* Removes the unwanted words from string.
*
* @param string $str
* @return string
*
*/
function filterwords($str){
$string = preg_replace("/(l?n |d? |dkm|dkm|fuck)/",
'xxx',$str);
return $string;
}
/**
* converts bbcode to HTML format
*
* @param string $string
* @return string HTML string
*
*/
////////////////////////////////
function bbcode($string){
$string = str_replace("php","",$string);
$string = str_replace("<","<",$string);
$string = str_replace(">",">",$string);
$string = str_replace('"','\"',$string);
$string = str_replace(array("\n", "\r", "\r\n"), ' ', $string);
$string = preg_replace("(\[b\](.+?)\[\/b])is",'$1',$string);
$string = preg_replace("(\[i\](.+?)\[\/i])is",'$1',$string);
$string = preg_replace("(\[u\](.+?)\[\/u])is",'$1',$string);
$string = preg_replace("(\[s\](.+?)\[\/s])is",'$1',$string);
$string = preg_replace("(\[marquee\](.+?)\[\/marquee])is",'',$string);
$string = preg_replace("(\[blink\](.+?)\[\/blink])is",'',$string);
$urlstring = " a-zA-Z0-9\:\&\/\-\?\.\=\_\~\#\'\#\@\%\,\[\]\{\}\~\!\^\|";
//$string = preg_replace("(\[url\]([$urlstring]*)\[/url\])", '$1', $string);
//$string = preg_replace("(\[url\=([$urlstring]*)\]([$urlstring]*)\[/url\])", '$2', $string);
$string = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","$2",$string);
$string = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])is","$2",$string);
$string = preg_replace("(\[size=(.+?)\](.+?)\[\/size])is",'$2',$string);
$string = preg_replace("(\[quote\](.+?)\[\/quote])is","",$string);
$string = preg_replace("(\[quote=(.+?)\](.+?)\[\/quote])is","",$string);
if(isloggedin()){ $url= '$1'; $url2= '$2';}//hide url from visitors!
else { $url= '[Log in to see this link!]'; $url2= '[Log in to see this link!]';}
//creating the array
$bbcodeArray= array(
#bbcodes section
'/\[em\](.*?)\[\/em\]/is' => '$1',
'/\[code\](.*?)\[\/code\]/is' => '$1',
'/\[big\](.*?)\[\/big\]/is' => '$1',
'/\[center\](.*?)\[\/center\]/is' => '
$1
',
'/\[right\](.*?)\[\/right\]/is' => '
$1
',
'/\[left\](.*?)\[\/left\]/is' => '
$1
',
'/\[hr\]/is' => '',
'/\[url\](.*?)\[\/url\]/is' => $url,
'/\[link\](.*?)\[\/link\]/is' => $url,
'/\[link\=(.*?)\](.*?)\[\/link\]/is' => $url2,
'/\[url\=(.*?)\](.*?)\[\/url\]/is' => $url2,
'/\[img\](.*?)\[\/img\]/is' => '',
'/\[img\=(.*?)\]\[\/img\]/is' => '',
#comes down so it does not interfere with the smiley codes using '*' and '*'
#parses bold tag only after all possible smileys have been parsed
'/\*(.*?)\*/is' => '$1',
);
$string= preg_replace(array_keys($bbcodeArray),array_values($bbcodeArray),$string);
$string=nl2br($string);
return $string;
}
/////////////////////////////////////////////////////////////
/*function highlight_code($var)
{
if (!function_exists('process_code')) {
function process_code($php)
{
$php = strtr($php, array(' ' => '', '\\' => '\'));
$php = html_entity_decode(trim($php), ENT_QUOTES, 'UTF-8');
$php = substr($php, 0, 2) != "" ? "" : $php;
$php = highlight_string(stripslashes($php), true);
$php = strtr($php, array('\' => '\', ':' => ':', '[' => '['));
return '
' . $php . '
';
}
}
return preg_replace(array('#\[php\](.+?)\[\/php\]#se'), array("''.process_code('$1').''"), str_replace("]\n", "]", $var));
}
*/
//////////////////////////////////////////////////////////////////////
function atuser_search_name($user){
$atuser_q = mysql_query("select * from c_users WHERE username = '$user'");
$atuser_n = mysql_num_rows($atuser_q);
$at = mysql_fetch_object($atuser_q);
if($atuser_n == 0)
{return "@$user";}
else
{return "url."profile.php?uid=".$at->userid."\">color."\">".$at->username."";}
}
function atuser_name($matches){
while($m = $matches[2]){
return atuser_search_name($m);}
}
function at_user($text){
return preg_replace_callback("/([@]+)([a-zA-z-0-9]+)/", "atuser_name", $text);
}
/*///////////////////////////////////////////////////////
/**
* Finds smileys format and add those images of smileys.
*
* @param string $string
* @return string HTML string
*
*/
$config->spak = @file(SPAK);
function smiley($string){
global $config;
foreach ($config->spak as $val ) {
$val = trim($val);
if (! $val || '#' == $val{0}) { continue; }
list($gif,$alt,$symbol) = explode('=+:',$val);
$string=str_replace($symbol, '', $string);
}
return $string;
}
/**
* Finds rank for the post count and returns rank
*
* @param integer $post Post count e.g: 0 , 20 or 810
* @return mixed
*
*/
function get_rank($posts){
global $db;
$getrank=$db->get_row("SELECT * FROM c_ranks WHERE postsneeded<=$posts ORDER BY postsneeded DESC");
$rank=$getrank->rankname;
return $rank;
}
/**
* Fetchs all group details global variable $group.
*
*/
function fetchgroups(){
global $group, $db;
$g=$db->select("SELECT * FROM c_groups ORDER BY grouptype ASC, groupsort ASC");
foreach($g as $gr2){
$group[$gr2->groupid]['name']=$gr2->groupname;
$group[$gr2->groupid]['type']=$gr2->grouptype;
$group[$gr2->groupid]['sort']=$gr2->groupsort;
$group[$gr2->groupid]['color']=$gr2->color;
$group[$gr2->groupid]['canban']=$gr2->canban;
}
return true;
}
/**
* Finds group type and returns group type and false if no such group type.
*
* @param integer $typeid Group type id
* @return bool
*
*/
function getgrouptypebyid($typeid){
if($typeid == "0")
return "Not Registered"; // not registered user
else if($typeid == "1")
return "Registered"; // simple registred user
else if($typeid == "2")
return "Moderator"; // who can access mod panel and has rights of mod
else if($typeid == "3")
return "Admin"; // who can access admin panel has rights of admin
else if($typeid == "4")
return "Head Admin"; // big boss...
return false;
}
/**
* Finds group id of the user.
*
* @param integer $userid user id of which group id whats to be found
* @return bool
*
*/
function groupidbyuserid($userid){
global $db;
if($u=$db->get_row("SELECT groupid FROM c_users WHERE userid='$userid'"))
return $u->groupid;
return false;
}
/**
* Returns username when passed userid, if no such user then returns false
*
* @param integer $userid userid of the user
* @return string
*
*/
function getusernamebyid($userid,$username){
global $db;
if($userid==0)
return "Guest";
if($u=$db->get_row("SELECT username FROM c_users WHERE userid='$userid'"))
return $u->username;
else
return $username;
return false;
}
/**
* Returns userid when passed username, if no such username then returns false
*
* @param string $username username of the user
* @return string
*
*/
function getidbyusername($username){
global $db;
if($u=$db->get_row("SELECT userid FROM c_users WHERE username='$username'"))
return $u->userid;
return false;
}
/**
* Sends peronal message. Returns true if pm is sent and false if fails.
*
* @param integer $to userid to whom pm is to be sent
* @param integer $from userid from whom pm is to be sent
* @param integer $sub Subject for the pm
* @param integer $msg Message for the pm
* @param integer $ack 0 : dont send read reciept, 1: send read reciept
* @return string
*
*/
function sendpm($to,$from,$sub,$msg,$ack='0'){
global $db;
$d=date("U");
if($db->insert_data("INSERT INTO c_pms(sendid, recid, subject, message, hasread, sendtime, ack) VALUES($from,$to,'$sub','$msg','0','$d','$ack')"))
return true;
return false;
}
//////////////////////////////////////////////////////////
function sendfr($to,$from,$ack='0'){
global $db;
$d=date("U");
if($db->insert_data("INSERT INTO f_pms(sendid, recid, hasread, sendtime, ack) VALUES($from,$to,'0','$d','$ack')"))
return true;
return false;
}
////////////////////////////////////////////////////////////////
function forumjump($forumid){
global $db, $user, $config;
$jumphtml="";
if($catlist=$db->select("SELECT * FROM f_categories ORDER BY catsort ASC")){
$jumphtml .= "";
return $jumphtml;
}
return false;
}
function blogjump($blogid){
global $db, $user, $config;
$jumphtml="";
if($catlist=$db->select("SELECT * FROM b_categories ORDER BY catsort ASC")){
$jumphtml .= "";
return $jumphtml;
}
return false;
}
function filejump($categoryid){
global $db, $user, $config;
$jumphtml="";
if($catlist=$db->select("SELECT * FROM a_categories ORDER BY catsort ASC")){
$jumphtml .= "";
return $jumphtml;
}
return false;
}
/**
* Converts the string to string which can be used for url. Basically used for converting title
* to URL for url rewriting.
*
* @param string $string String to be converted
* @return string
*
*/
function converturl($string){
/* viet seo*/
$a_str = array("a", "?", "?", "?", "?", "?", "á", "à", "?", "ã", "?", "â", "?", "?", "?", "?", "?", "Á", "À", "?", "Ã", "?", "A", "?", "?", "?", "?", "?", "Â", "?", "?", "?", "?", "?" );
$e_str = array("é","è","?","?","?","ê","?","?","?","?","?","É","È","?","?","?","Ê","?","?","?","?","?");
$d_str = array("d","Ð");
$o_str = array("ó","ò","?","õ","?","ô","?","?","?","?","?","o","?","?","?","?","?","Ó","Ò","?","Õ","?","Ô","?","?","?","?","?","O","?","?","?","?","?");
$u_str = array("ú","ù","?","u","?","u","?","?","?","?","?","Ú","Ù","?","U","?","U","?","?","?","?","?");
$i_str = array("í","ì","?","?","i","Í","Ì","?","?","I");
$y_str = array("ý","?","?","?","?","Ý","?","?","?","?");
$da_str = array("´","`","?","~","?");
$string = str_replace($i_str,"i",$string);
$string = str_replace($da_str,"",$string);
$string = str_replace($y_str,"y",$string);
$string = str_replace($a_str,"a",$string);
$string = str_replace($e_str,"e",$string);
$string = str_replace($d_str,"d",$string);
$string = str_replace($o_str,"o",$string);
$string = str_replace($u_str,"u",$string);
/* */
$string=strtolower($string);
$string=str_replace(" ","-",$string);
$string=str_replace("@","-",$string);
$string=str_replace("/","-",$string);
$string=str_replace("\\","-",$string);
$string=str_replace(":","",$string);
$string=str_replace("\"","",$string);
$string=str_replace("'","",$string);
$string=str_replace("<","",$string);
$string=str_replace(">","",$string);
$string=str_replace(",","",$string);
$string=str_replace("?","",$string);
$string=str_replace(";","",$string);
$string=str_replace(".","",$string);
$string=str_replace("[","",$string);
$string=str_replace("]","",$string);
$string=str_replace("(","",$string);
$string=str_replace(")","",$string);
$string=str_replace("*","",$string);
$string=str_replace("!","",$string);
$string=str_replace("$","-",$string);
$string=str_replace("&","-and-",$string);
$string=str_replace("%","",$string);
$string=str_replace("#","",$string);
$string=str_replace("^","",$string);
$string=str_replace("=","",$string);
$string=str_replace("+","",$string);
$string=str_replace("~","",$string);
$string=str_replace("`","",$string);
return $string;
}
/**
* Messages are shown in this blog and then program exits
*
* @param string $msgtitle Title of the message box
* @param string $msg Mesage to be displayed
* @param string Append anyting at the end/bottom of messagebox. [optional]
* @return string
*
*/
function err_msg($msgtitle,$msg,$end=""){
global $group, $config, $db, $user,$headtime;
print "
";
print " $msgtitle - $config->title Message
";
print "
$msg
";
print "
";
print $end;
print " ";
include dirname(dirname(__FILE__))."/footer.php";
exit;
}
function msgbox($msgtitle,$msg){
global $config;
$val = "