Jump to content

get session logins


NSW42

Recommended Posts

Hey Guys,

 

I just purchased a chat panel and im having trouble adding in some of my own login codes to a functions file for the chat panel, the functions file uses your sessions when a user logins into the site and it logs them into the panel at the same time, I will post the function EXAMPLE below and then post my login and if anyone can help me out as to what im suppose to add in from mine to the function script would be HUGELY  appreciated.

 

The 1st example is untouched and is what needs editing:

function getUserID() {
$userid = 0;

if (!empty($_SESSION['userid'])) {
	$userid = $_SESSION['userid'];
}

return $userid;
}

 

Next example is what has been edited for phpbb

function getUserID() {
$userid = 0;

$sql = ("SELECT config_value c 
	FROM ".TABLE_PREFIX."config 
	WHERE config_name = 'cookie_name'");
$query = mysql_query($sql);
$cookie = mysql_fetch_array($query);

if (!empty($_COOKIE[$cookie['c'].'_sid'])) {
	$sql = ("SELECT session_user_id 
		FROM ".TABLE_PREFIX."sessions 
		WHERE session_id = '".mysql_real_escape_string($_COOKIE[$cookie['c'].'_sid'])."'");
	$query = mysql_query($sql);
	$session = mysql_fetch_array($query);
	if ($session['session_user_id'] != 1) {
		$userid = $session['session_user_id'];
	}
}

return $userid;
}

 

 

below is my login and need some details added into the function file as aboves examples

<?php
ob_start("ob_gzhandler");

session_start();
include("includes/conn.php");

  $email = mysql_real_escape_string(str_replace("'","",$_POST["email"]));
  $password=str_replace("'", "", $_POST["password"]);
  $password=md5($password);

        $sql="select * from members where member_email like '$email' and member_password like '$password' and enabled = '1'";
        $result=mysql_query($sql);
        $num_rows=mysql_num_rows($result);
        $RSUser=mysql_fetch_array($result);
  if ($num_rows==0)
  {
        print ("<script language='JavaScript'> window.location='index.php?err=1'; </script>");
  }
  else
  {
  //if($RSUser["email_verify"]==0)
  //{
  //      print ("<script language='JavaScript'> window.location='login.php?err=2'; </script>");
  //}
  //else
  //{
        $posted_on=date("m/d/Y");
        $ip_address=$_SERVER['REMOTE_ADDR'];


      $sql="update members set last_login = '$posted_on', last_ip = '$ip_address' where member_id = $RSUser[member_id]";
      $upd=mysql_query($sql);
      
      $sql="update members set next_email = 0 where member_id = $RSUser[member_id]";
      $upd = mysql_query($sql);
      
      $now_time = strtotime("now");

      $sql="update members set last_login_time = $now_time where member_id = $RSUser[member_id]";
      $upd_member = mysql_query($sql);


  $_SESSION["logged_in"]="yes";
  $_SESSION["member_id"]=$RSUser["member_id"];
  $_SESSION["member_name"]=$RSUser["member_name"];
  $_SESSION["member_lname"]=$RSUser["member_lname"];
  $_SESSION["member_email"]=$RSUser["member_email"];
  $_SESSION["member_password"]=$password;
  $_SESSION["package"]=$RSUser["pack_id"];
  $_SESSION["selected_package"]=$RSUser["pack_id"];
  $_SESSION["enabled"]=$RSUser["enabled"];
  
    include("includes/packages.class.php");
    $pack = new packages;

    $id=$RSUser["pack_id"];

  $allowed_info=$pack->get_pack_value($id,'Search');

  if($allowed_info["id"]!=Null)
  {
     $_SESSION["search_allowed"]="yes";
  }

  $allowed_info=$pack->get_pack_value($id,'Invite');
  if($allowed_info["id"]!=Null)
  {
     $_SESSION["invite_allowed"]="yes";
  }

  $allowed_info=$pack->get_pack_value($id,'Forum');
  if($allowed_info["id"]!=Null)
  {
     $_SESSION["forum_allowed"]="yes";
  }

  $allowed_info=$pack->get_pack_value($id,'Groups');
  if($allowed_info["id"]!=Null)
  {
     $_SESSION["groups_allowed"]="yes";
  }


  $allowed_info=$pack->get_pack_value($id,'Events');
  if($allowed_info["id"]!=Null)
  {
     $_SESSION["events_allowed"]="yes";
  }

  $allowed_info=$pack->get_pack_value($id,'Mails');
  if($allowed_info["id"]!=Null)
  {
     $_SESSION["mails_allowed"]="yes";
  }

  $allowed_info=$pack->get_pack_value($id,'Journal');
  if($allowed_info["id"]!=Null)
  {
     $_SESSION["journal_allowed"]="yes";
  }


  $allowed_info=$pack->get_pack_value($id,'Address Book');
  if($allowed_info["id"]!=Null)
  {
     $_SESSION["address_allowed"]="yes";
  }

  $allowed_info=$pack->get_pack_value($id,'Blogs');
  if($allowed_info["id"]!=Null)
  {
     $_SESSION["blog_allowed"]="yes";
  }

  $allowed_info=$pack->get_pack_value($id,'Classified');
  if($allowed_info["id"]!=Null)
  {
     $_SESSION["classified_allowed"]="yes";
  }

  $allowed_info=$pack->get_pack_value($id,'Music');
  if($allowed_info["id"]!=Null)
  {
     $_SESSION["music_allowed"]="yes";
  }

  $allowed_info=$pack->get_pack_value($id,'Videos');
  if($allowed_info["id"]!=Null)
  {
     $_SESSION["videos_allowed"]="yes";
  }


  if($_POST["remember_email"]=="on")
  {
   setcookie("exact[email]","$RSUser[member_email]", time()+60*60*24*30);
  }
  setcookie("exact[logged]",1,time()+60*60*24*30);
  setcookie("exact[member_email]","$RSUser[member_email]",time()+60*60*24*30);
  setcookie("exact[member_password]","$password",time()+60*60*24*30);

  print "<p align='center'>Your account has been validated.<br>You are being taken to the members area.<br><a href='logincomplete.php'>Click here</a> if you are not redirected.</p>";
  print ("<script language='JavaScript'> window.location='logincomplete.php'; </script>");
  //}
}
?>

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.