phpbb / sessionid nightmare
| From: | Brad Sumrall | Date: | Sat, 28 Apr 2007 16:03:41 +0000 |
| Subject: | phpbb / sessionid nightmare | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-254061@lists.php.net to get a copy of this message | ||
Users log into web site in a sudo phpbb login which works fine.
Users are able to browse around phpbb and a sudo phpbb program called
photopost.
But when the goto a differen't part of the site which is not phpbb related,
the sessionid does not carry over.
The other pages are calling on the same isset variable???
This is blowing my mind for weeks now!!!
Would some kind code help a frazzed brother out?
Sincerely,
Brad
brads@ftnco.com
First is the login page
define("IN_LOGIN", true);
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path .
'common.'.$phpEx); session_start();
//checking whether the user is logged in or nor and redirecting accordingly
if(isset($_GET["forum"]))
{
if(!isset($_SESSION["userid"]))
{
header("location:index.php");
}
}
//
// Set page ID for session management
//
Now the code from the page that it DOES NOT carry to and starts a new
session:
<?php
ob_start();
session_start();
header("Cache-control: private");
require("includes/configure.php");
$conn=mysql_connect(DB_SERVER,DB_SERVER_USERNAME,DB_SERVER_PASSWORD);
mysql_select_db(DB_DATABASE) or die(mysql_error().": database not
available");
$show="no";
if(isset($_SESSION['userid']) &&
$_SESSION['userid']!="")
$show="yes";
$contestid=$_REQUEST[cid];
$contestid = $_GET[cid];
if ($contestid == 0){
$contestid = $_POST[cid];
}
$contestid=$_REQUEST[cid];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function textCounter(field, countfield, maxlimit) { if (field.value.length >
maxlimit) field.value = field.value.substring(0, maxlimit); else
countfield.value = maxlimit - field.value.length; } // End --> </script>
<head> <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>.: Color Me Gorgeous</title>
<link href="colorme.css" rel="stylesheet" type="text/css" />
<STYLE
TYPE="text/css"> a:link { color: blue; text-decoration: underline } a:active
{ color: red; text-decoration: none } a:visited { color: blue;
text-decoration: underline } a:hover { color: blue; text-decoration:
underline } </STYLE> <style type="text/css"> .msgtext {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color:#FF0000;
text-align:center;
font-weight:bold;
}
.style1 {font-size: 12px}
</style>
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
x.src=x.oSrc; }
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x; }
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];} } function checkSession() {
if(document.form1.txt_comment.value=="")
{
alert("Please enter Comment");
document.form1.txt_comment.focus();
return false;
}
<?php if(!isset($_SESSION['userid']) && $_SESSION['userid'] ==
"")
{ ?>
alert("You must first login to Post Comment");
return false;
<?php } else { ?>
document.form1.action="operation.php?mode=checksession&pid="+document.form1.
pid.value+"";
document.form1.submit();
return true;
<?php } ?>
}
function logincheck()
{
if(document.frm.txtusername.value=="")
{
alert("Please Enter Username.");
document.frm.txtusername.focus();
return false;
}
if(document.frm.txtpwd.value=="")
{
alert("Please Enter Password.");
document.frm.txtpwd.focus();
return false;
}
document.frm.login.value="Success";
document.frm.action="operation.php?mode=login";
document.frm.submit();
return true;
}
function showlogin()
{
document.getElementById("tbllogin").style.visibility="visible";
document.frm.txtusername.focus();
}
//-->
</script>
</head>
<body
onload="MM_preloadImages('images/home_b_h.jpg','images/about_b_h.jpg','image
s/forum_b_h.jpg','images/photo_gallery_b_h.jpg','images/protfolio_b_h.jpg','
images/crictic_b_h.jpg','images/contest_b_h.jpg','images/contact_b_nhjpg','i
mages/contact_b_h.jpg')">
<table width="779" border="0" align="center"
cellpadding="0"
cellspacing="0">
<?php include_once("header1.php") ?>
<tr>
<td><img src="images/header_bottom.jpg" width="779"
height="8" alt=""
/></td>
</tr>
</table>
<table width="779" border="0" align="center"
cellpadding="0" cellspacing="0"
class="centerbg">
<tr>
<td width="558" align="left" valign="top"><table
width="100%" border="0"
cellspacing="0" cellpadding="0">
<tr>
<td height="68" align="left" valign="bottom" ><table
width="100%"
border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/inner_top.jpg" width="559"
height="68" /></td>
<td><img src="images/right_img.jpg" width="221"
height="68" /></td>
</tr>
</table></td>
</tr>
<tr>
<td height="15" align="center" valign="middle">
<div align="center" class="style1"></div> <table
width="558" border="0"
align="center" cellpadding="0" cellspacing="0">
<tr>
<td><strong> Contest Entries </strong><br /> <?
if(isset($_POST['Submit'])) { ?>
<div align="center"><strong>Entry submitted!</strong></div>
<?
}
?></td>
</tr>
<tr>
<td align="center" valign="top"><table width="760"
border="0"
cellpadding="0" cellspacing="0">
<tr>
<td width="760" align="center"><table width="760"
border="0"
cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">
<?php if($_POST['hiddensubmit']){
if (!$_POST['story']){
echo "<font color=\"red\">please feel out the form before hitting
submit</a><br>"; } else { //Varify that only one entry per user per contest
$get_count5 = mysql_query("SELECT * FROM
contest_stories WHERE
contest_id = '".$_POST['cid']."' AND year='2007' AND
username
='".$_SESSION["userid"]."'");
$startcount5 = mysql_num_rows($get_count5);
if($startcount5 < 3){
$query2 = mysql_query("INSERT INTO contest_stories SET
contest_id='".$_POST['cid']."', year='2007'
,story='".$_POST['story']."',
time='" . time() . "',
username='".$_SESSION["userid"]."', approved='1'");
$contestid = $_POST['cid'];
}else{
echo "<font color=\"red\">You can only submit 3 stories per
contest.</a><br>";
}
}
}
/*
$vara=$_REQUEST['increment'];
if($vara!="") {$increment=10*$vara-10;}
else {$increment=0;}
$cer=mysql_query("SELECT * FROM contest_stories WHERE approved = 1 AND
year='2007' AND contest_id = '".$contestid."' ORDER BY time DESC
");
$linii=mysql_num_rows($cer); $rez=$linii/10;
$linii=round($linii/10);
if($rez>$linii) $linii+=1;
$query = mysql_query("SELECT * FROM contest_stories WHERE approved = 1 AND
year='2007' AND contest_id = '".$contestid."' ORDER BY time DESC LIMIT
$increment , 10");
?></td>
</tr>
<tr>
<td colspan="2">
<table width="760" align="center"
cellpadding="6"
cellspacing="20">
<?php
while ($row = mysql_fetch_array($query)){
echo "<tr >
<td style=\"border-style:solid;\" style=\"border-width:1px;\"
style=\"border:#12B683;\"><div align=\"left\"
style=\"vertical-align:top;\"><strong>Posted by
".$row['username']." ";
echo "<br /><br /></div><div
align=\"left\">".$row['story']."<br /><br
/></div>";
}
?> </table></td>
</tr>
<tr><td> <strong>Page <?
$page=$_REQUEST['page'];
if($page=="") $page=1;
echo $page; ?></strong></td>
<td>
<?
for($i=1;$i<=$linii;$i++)
{
?>
<a href="contest_storiesm.php?cid=<?
echo $contestid;?>&increment=<? echo $i;?>&page=<? echo $i;?>"><?
echo $i;
?></a>
<?
}
?>
</td>
</tr>
<?php
*/
if(!isset($_SESSION["userid"]))
{
?>
<tr>
<td colspan="2"><div align="left"><br /><br
/><strong> Login to submit your
contest
entry!</strong></div></td>
</tr>
<?php
}
else
{
?>
<tr>
<td colspan="2"><div align="left"><br /><br
/>
<strong> Submit your
entry
into the contest. </strong></div></td>
</tr>
<tr>
<td width="125"><div
align="right"> </div></td>
<td width="433">
<label>
<div align="left"> </div>
</label> </td>
</tr>
<form id="form2" name="form2" method="post"
action="contest_storiesm.php?cid=<?php echo $contestid ?>">
<tr>
<td height="62" colspan="2">
<div align="center"><span class="style1">( You may
enter up
to 1600 characters. )</span><br>
<textarea name="story" maxlength="1600"
style="width:500px;" rows="5"
onKeyDown="textCounter(this.form.story,this.form.remLen,1600);"
onKeyUp="textCounter(this.form.story,this.form.remLen,1600);"></textarea>
<br>
<input readonly type=text name=remLen size=4 maxlength=4 value="1600">
<span class="style1">characters left
</span></div></td>
</tr>
<tr>
<td colspan="2" align="center"><label>
<div align="right"><br />
<input type="hidden" name="hiddensubmit"
value="3" />
<input type="hidden" name="cid"
value="<?php
echo $contestid ?>" />
<input type="submit" name="Submit"
value="Submit"
/>
</div>
</label> </td>
</tr></form>
<?php
}
?>
</table></td>
</tr>
</table> </td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
<tr><td align="right"><a title="Top"
href="#"><img
src="images/top_button.jpg" width="81" height="21" alt=""
border="0"
/></a></td></tr>
<tr><td align="right" height="10"></td></tr>
</table>
<?php include_once("footer.php") ?>
</body></html>