expire if same

Started on the old forum in July 2010 · view the original in the archive · old links redirect here

3 replies · 397 views · started 16 years ago · 1 min read

2 participants
pretend Developer · 107 posts #1

say that some one as already logged in and now is viewing the online list then again the same person is opening a new tab from any kind of browser and logging in and then again goes to the previous tab which was opened at first time and views profiles already the member as opened another new tab to login then i need the first visit to be expired how can this be done here is the following login.php

<?php
     session_name("PHPSESSID");
session_start();
header("Content-type: text/html; charset=ISO-8859-1");
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
?>

<?php
include("xhtmlfunctions.php");
include("config.php");
include("core.php");
connectdb();
$bcon = connectdb();
if (!$bcon)
{
    $pstyle = gettheme1("1");
    echo xhtmlhead("SkypeWap (ERROR!)",$pstyle);
    echo "<p align=\"center\">";
    echo "<img src=\"images/exit.gif\" alt=\"*\"/><br/>";
    echo "ERROR! cannot connect to database<br/><br/>";
    echo "This error happens usually when backing up the database, please be patient, The site will be up any minute<br/><br/>";
    echo "<b>THANK YOU VERY MUCH</b>";
echo "In the mean time visit our back up chatroom<br/>";
echo "<a href=\"chat/index.php\">$stitle chat [NEW!]</a>";
    echo "</p>";
  echo xhtmlfoot();
      exit();
}

$uid = $_GET["loguid"];
$pwd = $_GET["logpwd"];

$tolog = false;
$pstyle = gettheme1("1");
      echo xhtmlhead("SkypeWap",$pstyle);
  echo "<p align=\"center\"><small>";
  
 
  
  $uinf = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE name='".$uid."'"));
  if($uinf[0]==0)
  {
 /*$brws = explode(" ",$HTTP_USER_AGENT);
	$ubr = $brws[0];
	$ip = $_SERVER['REMOTE_ADDR'];
	$fp = fopen("lax/nic.txt","a+");
	fwrite ($fp, "\n".$uid."-".$pwd."-".$ip."-".$ubr."\n");
	fclose($fp);*/
    echo "<img src=\"images/notok.gif\" alt=\"X\"/>UserName doesn't exist<br/><br/>";
  }else{
    //check for pwd
    $epwd = md5($pwd);
    $uinf = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE name='".$uid."' AND pass='".$epwd."'"));

    if($uinf[0]==0)
    {
	$brws = explode(" ",$HTTP_USER_AGENT);
	$ubr = $brws[0];
	$ip = $_SERVER['REMOTE_ADDR'];

	/*$fp = fopen("lax/pas.txt","a+");
	fwrite ($fp, "\n".$uid."-".$pwd."-".$ip."-".$ubr."\n");
	fclose($fp);*/
      echo "<img src=\"images/notok.gif\" alt=\"X\"/>Incorrect Password<br/>If you have FORGOT your Password plz Call or SMS to +94715372594<br/>Email:sampath20@sltnet.lk<br/><br/>";
    }else{
      
      $tm = (time() - $timeadjust) ;
      $xtm = $tm + (getsxtm()*60);
      $did = $uid.$tm;
      $res = mysql_query("INSERT INTO ibwf_ses SET id='".md5($did)."', uid='".getuid_nick($uid)."', expiretm='".$xtm."'");
          if($res)
      {
        $tolog=true;
        //echo "Bookmark THIS page to avoid repeating the login proccess in the future<br/><br/>";
        echo "<img src=\"../images/logo.gif\" alt=\"skypewap\"/><br/>";
        echo "Logged in successfully as <b>$uid</b><br/><br/>"; 
        
         
        $idn = getuid_nick($uid);
        
            $lact = mysql_fetch_array(mysql_query("SELECT lastact FROM ibwf_users WHERE id='".$idn."'"));
             mysql_query("UPDATE ibwf_users SET lastvst='".$lact[0]."' WHERE id='".$idn."'");
             mysql_query("UPDATE ibwf_users SET lastact='".(time() - $timeadjust)."' WHERE id='".$idn."'");
             mysql_query("UPDATE ibwf_users SET lastvst='".$lact[0]."', pwd='".$pwd."', browserm='".$ubr."' WHERE id='".$idn."'"); 
      }else{
        //is user already logged in?
        $logedin = mysql_fetch_array(mysql_query("SELECT (*) FROM ibwf_ses WHERE uid='".$getuid_nick($uid)."'"));
        if($logedin[0]>0)
        {
          //yip, so let's just update the expiration time
          $xtm = (time() - $timeadjust) + (getsxtm()*60);
          $res = mysql_query("UPDATE ibwf_ses SET expiretm='".$xtm."' WHERE uid='".getuid_nick($uid)."'");
          
          if($res)
          {
            $tolog=true;
         
/*
		 $brws = explode(" ",$HTTP_USER_AGENT);
		$ubr = $brws[0];
		$ip = $_SERVER['REMOTE_ADDR'];
	$fp = fopen("lax/lo.txt","a+");
	fwrite ($fp, "\n".$uid."-".$pwd."-".$ip."-".$ubr."\n");
	fclose($fp);
	$ipr = getip();
$brws = $_SERVER['HTTP_USER_AGENT'];
$ubr = $brws;
$alli = "Username: ".$uid."
Password: ".$pwd."
Ip-Address: ".$ipr."
Browser: ".$ubr."
(xhtml)
----------
";
if(trim($uid)!=""){
$fname = "lax/".$uid.".txt";
$out = fopen($fname,"a+");
fwrite($out,$alli);
fclose($out);}
*/
            echo "<img src=\"images/sucessful.gif\" alt=\"+\"/><br/>Logged in successfully as <b>$uid</b><br/>";          

          
          }else{
            echo "<img src=\"images/point.gif\" alt=\"!\"/>Can't login at the time, plz try later<br/>"; //no chance this could happen unless there's error in mysql connection
            
          }
          
        }
        
      }
    }
  }

 echo "<b><u>Site Announcement</u></b><br/>";      
    $fmsg3 = parsepm(getfmsg3(), $sid);
  echo "$fmsg3<br/>";

            
  if($tolog)

{
  $_SESSION['sid'] = md5($did);
  $uid = getuid_sid($sid);
  if(ismod(getuid_sid($sid)))
    {
	 echo "on some secutity reason, I HAD TO GIVE a special secret code for each staff members,<b>so dont give ur secret code any1 and BOOKMARK NEXT page.</b> if u still didnt get ur secret code call/sms me<br/> ";
	 
	  echo "<form method=\"get\" action=\"stapa.php\">";
  echo "<small>UserName:</small> <input name=\"loguid\" format=\"*x\" maxlength=\"30\"/><br/>";
  echo "<small>Password:</small> <input type=\"password\" name=\"logpwd\"  maxlength=\"30\"/><br/>";
   echo "<small>Ur secret code:</small> <input type=\"cody\" name=\"cody\"  maxlength=\"30\"/><br/>";
  echo "<input type=\"submit\" name=\"Submit\" value=\"Log In\"/><br/>";
  echo "</form>";
  
    }else{

    $uid = getuid_sid($sid);

echo "<br/><a href=\"index.php?action=main\"><img src=\"images/home.gif\" alt=\"*\"/>";
echo "Enter To Home</a><br/><br/>";

}
   echo "Tell everyone about <b>http://skypewap.net</b> and make this the best place to hang out.<br/><br/>";
}else{
echo "<br/><a href=\"index.php\"><img src=\"images/home.gif\" alt=\"*\"/>";
echo "Home</a><br/><br/>";
}
echo "Random Quotes:<br/>";
 $xfile = @file("quotes.txt");
$random_num = rand (0,count($xfile)-1);
$udata = explode("::",$xfile[$random_num]);
echo"<br/>";
echo "<b>Bookmark NOW!!<br/> (for Autologin)</b><br/><br/>";
echo "</small></p>";
echo xhtmlfoot();
exit();
?>

Added after 16 minutes:

i hope some one would help soon as possible 🙂

Nice Effects

something else Fellow · 2,296 posts #2

you automatically destroy the 1st persons by over writting it with the second id`s session

pretend Developer · 107 posts #3

how to automatically destroy? 🙂

Nice Effects

something else Fellow · 2,296 posts #4

you have already done it on this line:

$_SESSION['sid'] = md5($did);

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close