Jump to content
xisto Community
Sign in to follow this  
Arne-Christian

[forum] Double Posting Happening By An Error

Recommended Posts

Hello,
I am currently working on EvilBoard 0.1.1, for those who know about this project versjon 0.1b can be downloaded from http://forums.xisto.com/no_longer_exists/

Well over to the reason why i am posting this,
I am currently experincing a problem with my new posting code wich has been rewrited in version 0.1.1, You see, it is double posting by an error, i thouht i could fix that myself, but no, so i just thought, Xisto is perfect, they problety know how to fix this,

Here is the code:

<?/** @Name: Post Topic* @Author: Arne-Christian Blystad* @Copyright: Copyright 2006 EvilServices** @ID: $i29-10-06-eb011*/session_start();global $template;include("source/lib/eb.php");include("smarty/smarty.class.php");$template = new Smarty;$post = new post;if(isset($_POST['Submit'])) {		echo $post->post();		$x = $post->get_last_topic();		$f = $_GET['forumid'];		@header("location: redirect.php?url=index.php?act=showtopic_t={$x}_forumid={$f}");}else {	echo $post->post_new();}//===========================// Class: Post// Desc: Required for posting new topics, and replies//===========================class post {	function post_new()	{		include("lang/en/lang_en.php");		$template = new smarty;			$eb = new eb;		$eboard = new eboard;		$forumname = $eboard->forum_name();		$template = new smarty;		$name = $_SESSION['user_name'];		if($name) {			$template->assign("name","$name");		}		$template->assign("lvl","{$_SESSION[user_level]}");			$menu = $_SESSION['user_name'];		if($menu) {			$template->assign("menu","true");		}		$lvl = $_SESSION['user_level'];		if($lvl == "3") {			$template->assign("lvl","3");		}		if($_GET['do'] == "post_new") { $title = "Post new topic"; }		else { $title = "Post reply"; }		$template->assign("title","{$title} - {$forumname}");		$template->assign("forum_name","{$forumname}");		$template->template_dir = "/Themes/Default/";		$template->compile_dir = "cache/";		if($_GET['do'] == "post_new") {			$template->assign("post_new","true");		}		else {				}		$template->display("post.tpl");	}	function post()	{		// Connect to DB		$db = new db;		$db->connect();		// Check if topic is submited				// Defines variables for title, description and post message				$title	=	$_POST['t_title'];				$desc	=	$_POST['t_desc'];				$msg	=	$_POST['writer'];								// Conencts to DB				$db = new db;				$db->connect();				// Check if t_title or writer is null				if($_GET['do'] == "post_new") {					if(empty($title)) { $err = "102 - Could not post - Title is null"; }				}				if(empty($msg)) { $err = "103 - Could not post - Message is null"; }				// If something is null, cancel the sending!				if($err) {					$template = new smarty;					// this is smarty stuff required for the first page					$name = $_SESSION['user_name'];					if($name) {						$template->assign("name","$name");					}					$template->assign("lvl","{$_SESSION[user_level]}");						$menu = $_SESSION['user_name'];					if($menu) {						$template->assign("menu","true");					}					$lvl = $_SESSION['user_level'];					if($lvl == "3") {						$template->assign("lvl","3");					}					// Sets title to Post new topic ,or port reply					if($_GET['do'] == "post_new") { $title = "Post new topic"; }					else { $title = "Post reply"; }					// Asigns title and forum name					$template->assign("title","{$title} - {$forumname}");					$template->assign("forum_name","{$forumname}");					// Sets folders for template and cache dir.					$template->template_dir = "/Themes/Default/";					$template->compile_dir = "cache/";					// If were posting a new topic, we need to show the Title: and Description:.					if($_GET['do'] == "post_new") { $template->assign("post_new","true"); }					$template->assign("err","{$err}"); $template->display("post.tpl"); exit();				}				else {					// Ok here we are, now it is going to send the info to DB, because we know its error free.									// Defines variables.					$this->userid		=	$_SESSION['userid'];					$this->title		=	$_POST['t_title'];					$this->desc			=	$_POST['t_desc'];					$this->usrn			=	$_SESSION['user_name'];					$this->forumid		=	$_GET['forumid'];					$this->ip_addrs		=	$_SERVER['REMOTE_ADDR'];					$this->is_sticky	=	$_POST['is_sticky'];					$this->is_closed	=	$_POST['is_closed'];					$this->msg			=	$_POST['writer'];					$this->time			=	time();										// If this is a new topic, create the topic!					if($_GET['do'] == "post_new") {						$db->query("INSERT INTO `eb_topic` ( `UserID` , `title` , `TopicID` , `replies` , `desc` , `Username` , `ForumID`, `is_sticky`, `is_closed` )		VALUES ('$this->userid', '$this->title', NULL , '0', '$this->desc', '$this->username', '$this->forumid','$this->is_sticky','$this->is_closed');") or die("MySQL Error: " . mysql_error());					}					else {					// * If this isn't a topic, simply don't create the topic!					}					// Get the last topic from the database					$this->last = $this->get_last_topic();					// Inserts Reply					$post = $db->query("INSERT INTO `eb_post` ( `message` , `postdate` , `UserID` , `Username` , `PostID` , `TopicID` , `ForumID` , `title` , `user_ip` )		VALUES (		'$this->msg', '$this->time' , '$this->userid', '$this->username', '' , '$this->last', '$this->forumid', '$this->title', '$this->ip_addrs');") or die("MySQL Error: " . mysql_error());				} // End Error free inserting.	}	function get_last_topic()	{		$db = new db;		$db->connect();		$topic = $db->query("SELECT * FROM `eb_topic` ORDER BY `TopicID` DESC LIMIT 0,1");		$topic = $db->fetch_array($topic);		$topic = $topic['TopicID'];		return $topic;	}}?>
I hope any of you can help me, The one who helps me can get added to * Special Thanks to: [uSERNAME HERE]
in the file, and Xisto is allready added to the special thanks to file :lol:

Arne-Chrisitan Blystad - EvilBoard Devloper :(

Share this post


Link to post
Share on other sites

Although I can't see it right now, but I would think you have an extra line possibly an echo that makes the 2 posts try your search around that conclusion.

Share this post


Link to post
Share on other sites

Although I can't see it right now, but I would think you have an extra line possibly an echo that makes the 2 posts try your search around that conclusion.

Thanks, that fixed it, i just changed $post->post(); to $post->post_topic(); and including changing the name, that fixed it all :(:lol:

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.