Jump to content

Recommended Posts

Posted

Hi, again got a problem.

 

As the title describing, everything in a function inside a class repeating every value twice. For example, when using 'echo', transferring a value to another function/class. I'm attaching a screenshot of the page. On that page you will see, "HELLO4HELLO4", The two four had transferred from the class-1(where the problem occurs) and printed on the class-2. Class-1 transferring 4 two times to class-2. And also I'm posting the function:

function setSession($uid){
		session_start();
		if(!empty($uid)){
			$this->uid_md5 = $uid;
			if($q=db_query("SELECT uid,uid_md5,username,login_cookie,uid_md5,status,suspended,suspension_reason FROM users WHERE uid_md5='".$this->uid_md5."'",$this->db)){
				if(db_num_rows($q)==1){
					$r=db_fetch_array($q);
					$this->uid_md5 = sha1($r['uid_md5']);
					$this->sessid = sha1($r['uid']).'-'.sha1($this->ip);
					$this->login_cookie = sha1($r['username']).'-'.sha1($this->ip).'-'.sha1($this->device);
					if($this->login_cookie == $r['login_cookie']){
						if($update=db_query("UPDATE users SET uid_md5='".$this->uid_md5."', autologin='0', login_ip='".$this->ip."',login_device='".$this->device."',login_platform='".$this->platform."',login_browser='".$this->browser."',login_ua='".$this->ua."',login_country='".$this->country."',login_state='".$this->state."',login_location='".$this->city."',login_date='".$this->date."',login_time='".$this->time."',login_timestamp='".$this->timestamp."',login_cookie='".$this->login_cookie."' WHERE uid_md5='".$this->uid_md5."'", $this->db)){
							setcookie('uid','',0);
							$_SESSION['expires'] = time();
							$_SESSION['uid'] = $uid;
							$_SESSION['sessid'] = $this->sessid;
							if($r['status']==0){
								$this->nmi->redirectByRefId(3,'do=confirm');
							} elseif($r['status']==1){
								$this->nmi->redirectByRefId(2,2);
							} elseif($r['status']==2){
								echo "HELLO";
								$this->nmi->redirectByRefId(4);
							} elseif($r['status']==3){
								$this->nmi->redirectByRefId(3,'do=renew');
							} elseif($r['status']==4){
								$this->nmi->redirectByRefId(3,'do=status');
							} elseif($r['status']==5){
								$this->nmi->redirectByRefId(3,'do=status');
							}
						} else {
							echo '<div class="error">Unable to update database</div>';
						}
					} else {
						setcookie('uid','');
						unset($_SESSION['expires']);
						unset($_SESSION['uid']);
						unset($_SESSION['sessid']);
						echo '<div class="error">Your login device was changed. Please login again.</div>';
					}
				} else {
					echo '<div class="error">Your login details were changed. Please login again: '.$this->uid_md5.'/'.$r['uid_md5'].'</div>';
				}
			} else {
				echo '<div class="error">Unable to query database</div>';
			}
		} else {
			echo '<div class="error">UID cannot be left empty</div>';
		}
	}
Take a look at the screenshot:

  • 2 weeks later...
Posted

My guess is that somewhere in the function $this->nmi->redirectByRefId(4); (line 167) is an echo statement that outputs the parameter given (4). What I can't quite figure out is what would cause the statements given in elseif($r['status']==2) (lines 165-168) to execute twice. Maybe the entire function setSession() is called twice somewhere else in your code? Possibly if called from within a loop?

Posted

Yeah, you are right.. The problem was caused by a second call to the setSession(). Now it solved. I've removed the second call. And thanks for your help.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...