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 - <?php echo $config->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 { ?> threadparent == "0") { ?>
Edit Post
Topic:
Message:
threadparent == "0") { print "- url."votes/create.php?tid=".$postid."\">Add vote
"; } print "- url."attachment.php?tid=".$postid."\">Attachment
"; if($post->nosmilies == "0") { $checked=""; } else{ $checked="checked=\"checked\""; } ?> > Disable Smilies


/////////////////////////////// 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",'$1',$string); $string = preg_replace("(\[blink\](.+?)\[\/blink])is",'$1',$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","
by $2$1
",$string); $string = preg_replace("(\[quote=(.+?)\](.+?)\[\/quote])is","
by $1$2
",$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, ''.htmlspecialchars($alt).'', $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 .= "
url."showforum.php\">"; $jumphtml .= ""; $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 .= "
url."blog/showblog.php\">"; $jumphtml .= ""; $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 .= "
url."files.php\">"; $jumphtml .= ""; $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 ""; print "
"; print " $msgtitle - $config->title Message
$msg

"; print $end; print "
"; include dirname(dirname(__FILE__))."/footer.php"; exit; } function msgbox($msgtitle,$msg){ global $config; $val = ""; $val .= ""; $val .= "
"; $val .= " $msgtitle - $config->title Message
$msg

"; return $val; } /** * Returns pagination list in array * * @param integer $total Total no of records * @param integer $current Current page * @param integer $perpage Record to be shown on 1 page [optional] * @return array * */ function pagination($total,$current,$perpage='10'){ if($total >= $perpage){ $totalpages=round($total/$perpage); $totalpages2=$total/$perpage; if($totalpages2>$totalpages) $totalpages=$totalpages+1; $pagesar['First'] = "1"; if($current > 1){ $cd=$current-1; $pagesar['Prev'] = $cd; if($cd==1) $st=1; else if($cd==2) $st=$cd-1; else if($cd>=3) $st=$cd-2; for($i=$st;$i<=$cd;$i++){ $pagesar[$i] = $i; } } if($totalpages > $current+4) $finalstop=$current+4; else $finalstop=$totalpages; for($j=$current;$j<=$finalstop;$j++){ $pagesar[$j] = $j; } if($totalpages > $current) $pagesar['Next'] = $current+1; $pagesar['Last'] = $totalpages; }else{ $pagesar['1'] = "1"; } return $pagesar; } function naventry($total,$page,$url,$title) { if ($page != 1) $pervpage = ' << '; if ($page != $total) $nextpage = ' >>'; if ($page - 4 > 0) $first = '1...'; if ($page + 4 <= $total) $last = '...'.$total.''; if($page - 2 > 0) $page2left = ' '. ($page - 2) .' '; if($page - 1 > 0) $page1left = ''. ($page - 1) .' '; if($page + 2 <= $total) $page2right = ' '. ($page + 2) .''; if($page + 1 <= $total) $page1right = ' '. ($page + 1) .''; echo ''; } function entry($thread_post,$page,$threadid,$threadname){ global $config; $entry_page = 1; $text_start = 0; $strrpos = mb_strrpos($thread_post, " "); if ($strrpos) { while ($text_start < $strrpos) { $string = mb_substr($thread_post, $text_start, $config->numtextentry); $text_end = mb_strrpos($string, " "); $strings[$entry_page] = $string; $text_start = $text_end + $text_start; if ($page == $entry_page) { $page_text = $strings[$entry_page]; } if ($strings[$entry_page] == "") { $text_start = $strrpos++; } else { $entry_page++; } } if ($page >= $entry_page) { $page = $entry_page - 1; $page_text = $strings[$page]; } $entry_page = $entry_page - 1; if ($page != $entry_page) { $prb = mb_strrpos($page_text, " "); $page_text = mb_substr($page_text, 0, $prb); } } else { $page_text = $thread_post; } echo $page_text; if ($entry_page > 1) { echo naventry($entry_page, $page, $config->url."e/".$threadid."/r/",converturl($threadname)); } } function first_img($text,$thumb) { global $config; $res = preg_match('#\[img\](.*?)\[\/img\]#is', $text, $matches); if (!$thumb == '') $text = ''; elseif(!$matches[1] == '') $text = ''; else $text = ''; return $text; } function mobile() { if(isset($_SERVER["HTTP_X_OPERAMINI_FEATURES"]) || isset($_SERVER["HTTP_X_OPERAMINI_PHONE"]) || isset($_SERVER["HTTP_X_OPERAMINI_PHONE_UA"])) return 1; $s = $_SERVER['HTTP_USER_AGENT']; $_j2me = array(0 => "MIDP",1 => "CLDC",2 => "MSIE"); $_os = array(0 => "Linux",1 => "Windows",2 => "Macintosh",3 => "Mac OS",4 => "Solaris",5 => "NT"); for($i = 0; $i < sizeof($_j2me); $i++) { if(preg_match('/'.$_j2me[$i].'/i',$s)) $mobile = true; } for($i = 0; $i < sizeof($_os); $i++) { if(preg_match('/'.$_os[$i].'/i',$s)) $mobile = false; } return $mobile; } function get2ses($name) { global $_GET,$_SESSION; if(isset($_GET[$name])) $_SESSION[$name] = $_GET[$name]; return $name = $_SESSION[$name]; } function sel($value,$real) { if($value != $real) { return; } else { return'selected="selected"'; } } ///////////////////////////////// function clicklink($text) { $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1\2', $text); $text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '\1', $text); return $text; } //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// function timez($time,$format) { global $user,$config; if($user->utimezone) $TimeZone=$user->utimezone; else $TimeZone=$config->timezone; // default vietnam if($format) $format=$format; else $format="D M d, Y H:i:s"; $time=$time + ($TimeZone * 60 * 60); $time=date($format,$time); return $time; } ////////////////////////////////////////////////////////// ?>