phpBB Sessions Help

Discussion in 'PHP' started by Crow, Aug 21, 2007.

  1. #1
    Hello,
    I'm trying to intergrat phpBB into my site, and I have pretty much it done, only thing I'm really having trouble with is the sessions. Shown below is my login page for my sites script. The trouble I'm having is once a member logs into my site they don't get logged into the forums, but if the member goes to the forums and logs in its fine and my logout page works, logging out the member from my site and the forums.

    So I'd like it if anyone can look at this code and tell me why its not loggin in my members to the forums.. thanks for your time! Ive checked out the Sessions Intergration in the Knowledge Base on the phpBB site, but I'm not seeing why its not working, please help, if you help me and it ends up working I'm willing to throw some paypal your way, nothing much, but at least a thank you, for your time!

    This is my login.php file:
    <?php
    ob_start("ob_gzhandler");
    
    session_start();
    $title = 'Website - Login';
    include("includes/conn.php");
         include("includes/packages.class.php");
         $pack=new packages;
    
    $send_back = $_SERVER["HTTP_REFERER"];
    if (isset($_COOKIE['exact']))
    {
       foreach ($_COOKIE['exact'] as $name => $value)
       {
          if($name=="logged")
          {
           $logged= $value;
          }
    
          if($name=="member_email")
          {
           $member_email= $value;
          }
    
    
          if($name=="member_password")
          {
           $member_password = $value;
          }
       }
    }
    
    if($logged == "1" || $logged == 1)
    {
            $sql="select * from members where member_email like '$member_email' and member_password like '$member_password' and enabled = '1'";
            $result=mysql_query($sql);
            $num_rows=mysql_num_rows($result);
            $RSUser=mysql_fetch_array($result);
    
            if ($num_rows!=0)
            {
               $_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["enabled"]=$RSUser["enabled"];
               
        $id=$RSUser["pack_id"];
    // to accomodate the package problem i added this code
      $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";
      }
    
    
               print ("<script language='JavaScript'> window.location='$send_back'; </script>");
            }
            
    
    }
    
    include("includes/top.php");
    include("includes/nav.php");
    //include("includes/right.php");
    ?>
    <!-- middle_content -->
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
    <tr>
    <td width='80%' valign='top'>
    
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="dark_b_border2">
    <tr>
    <td class="dark_blue_white2">
    <strong>&nbsp;Login&nbsp;&nbsp;</strong></span></div>
    </td>
    </tr>
    
    <tr><td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    
    <form name="form1" method="post" action="login1.php">
    <td width="1" rowspan="19"><div align="right" class="style9"></div>
    <div align="center">
    </div></td>
    </tr>
    <tr>
    <td height="10"></td>
    <td height="10"></td>
    </tr>
    <?php
    if (isset($_COOKIE['exact']))
    {
       foreach ($_COOKIE['exact'] as $name => $value)
       {
           $email_selected= $value;
       }
    }
    if(is_numeric($email_selected))
    {
        $email_selected = Null;
    }
    ?>
    <tr>
    <td width="194" class="txt_label">&nbsp;E-Mail Address:</td>
    <td width="346" height="30">
    <input type='text' name='email' size='20' value='<?=$email_selected?>'>
    </td>
    </tr>
    </tr>
    <tr>
    <td class="txt_label">&nbsp;Password:</td>
    <td height="30">
    <input type='password' name='password' size='20'>
    </td>
    </tr>
    <tr>
    <td class="txt_label" colspan='2'>&nbsp;<a href='forgot_password.php' target='_top' class="style11">Forgot Password</a></td>
    </tr>
    </tr>
    <tr>
    <td height="30" colspan="2"><div align="center">
    <input type="submit" name="Submit" value="Login">
    </div></td>
    </tr>
    </table>
    </form>    
    </tbody>
    </table>
    </td>
    <td width='20%' valign='top'>
    <!-- ad code -->
    <?php
    	$ads_set = $ads->get_top_160_banner();
    	$upd = $ads->update_impr($ads_set["campaign_id"]);
    	
    	if($ads_set["banner_code"]!=Null)
    	{
    ?>
    <?=stripslashes($ads_set["banner_code"])?>
    <?php	
    	}
    	else
    	{
    		if($ads_set["banner_type"] == 2)
    		{
    ?>
    <a href='track_ad_link.php?campaign_id=<?=$ads_set["campaign_id"]?>&url=<?=$ads_set["banner_url"]?>' target='_blank'>
    <img src='<?=$ads_set["banner_file"]?>' width='160' height='600' border='0'/>
    </a>
    <?php		
    		}
    		if($ads_set["banner_type"] == 3)
    		{
    ?>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="160" height="600" id="banner" ALIGN="">
    <PARAM NAME=movie VALUE="<?=$ads_set["banner_file"]?>?clickTAG=track_ad_link.php?campaign_id=<?=$ads_set["campaign_id"]?>&url=<?=$ads_set["banner_url"]?>"> 
    <PARAM NAME=quality VALUE=high> 
    <PARAM NAME=bgcolor VALUE=#FFFFFF> 
    <EMBED src="<?=$ads_set["banner_file"]?>?clickTAG=track_ad_link.php?campaign_id=<?=$ads_set["campaign_id"]?>&url=<?=$ads_set["banner_url"]?>" quality=high bgcolor=#FFFFFF  WIDTH="160" HEIGHT="600" NAME="banner" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
    </EMBED>
    </OBJECT>
    <?php			
    		}
    	}
    ?>	
    
    <!-- ad code -->
    </td>
    </tr>
    </table>
    <!-- middle_content -->
    
    <!-- Middle Text -->
    <?php
         include("includes/bottom.php");
    ?>
    Code (markup):
    And heres my login1.php file :
    
    <?php
    ob_start("ob_gzhandler");
    
    session_start();
    include("includes/conn.php");
    
    define("IN_PHPBB", true);
    $phpbb_root_path = 'forums/';
    include($phpbb_root_path . 'extension.inc');
    include($phpbb_root_path . 'common.'.$phpEx);
    $userdata = session_pagestart($user_ip, PAGE_INDEX);
    init_userprefs($userdata);
    
      $email=str_replace("'","",$HTTP_POST_VARS["email"]);
      $password=str_replace("'", "", $HTTP_POST_VARS["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
      {
            $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);
    
      $_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($HTTP_POST_VARS["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 "<div align='center'><img src='./images/smilie.gif' border='0' /><br />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.</div>";
      print ("<script language='JavaScript'> window.location='logincomplete.php'; </script>");
    }
    ?>
    Code (markup):

     
    Crow, Aug 21, 2007 IP
  2. Crow

    Crow Active Member

    Messages:
    59
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    65
    #2
    No one has any imput? :(
     
    Crow, Aug 22, 2007 IP