Session problem?

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
calle08
Registered User
Posts: 27
Joined: Tue Mar 11, 2008 3:15 pm

Session problem?

Post by calle08 » Tue Mar 11, 2008 3:25 pm

Have a problem with code can someone help? When i add the phpbb session login code to my code it just wont work. It works fine alone. Can somone find a error? When i press the submit button nothing happens. I think i nedd to add a POST somewhere but i dont know how i can do it. Can somone help? i understand if you can´t help.


Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

if($userdata['session_logged_in'])
{

}
else
{
header('Location: http://www.triangelns.com/phpBB3/login.php');
}

include ('/home/b2303/public_html/phpBB3/includes/page_header.php');

<?


include_once(".plupp.functions.php");


$db = mysql_connect("mysql", $GLOBALS["db_user"], $GLOBALS["db_pass"]);
mysql_select_db($GLOBALS["db_name"],$db);



isLoggedIn();


	


$user_id = $_GET['uid'];


	$sql = "select fornamn, efternamn from phpbb2_narvaro_users where id='$user_id'";
	$resultat = mysql_query($sql);


	list($fornamn, $efternamn)=mysql_fetch_array($resultat);

	//Här sparas om man valt att spara
	if(isset($B1))
	{
		//Spara alla och skicka vidare.
		
		//Ta fram id på alla som kan sparas

		//admin - admin ska se alla (hela history).
		$sql = "select n.id, n.aktivitets_id, n.plupp_val, n.viktig_plupp_text, n.plupp_text, DATE_FORMAT(a.datum,'%Y-%m-%d'), a.info, p.plupp_text from narvaro as n, aktiviteter as a, pluppar as p where n.user_id='$user_id' AND n.aktivitets_id=a.id AND n.plupp_val=p.id order by a.datum";
		//$sql = "select n.id, n.aktivitets_id from phpbb2_narvaro_narvaro as n, phpbb2_narvaro_aktiviteter as a where n.user_id='$user_id' AND n.aktivitets_id=a.id order by a.datum";
		if(!isLoggedInAdmin())
		{
			//klient - Klienten ska bara få se de som är nyare NOW()-en dag och som inte är svart eller blank.
			$sql ="select n.id, n.aktivitets_id, n.plupp_val, n.viktig_plupp_text, n.plupp_text, DATE_FORMAT(a.datum,'%Y-%m-%d'), a.info, p.plupp_text from phpbb2_narvaro_narvaro as n, phpbb2_narvaro_aktiviteter as a, phpbb2_narvaro_pluppar as p where n.user_id='$user_id' AND n.aktivitets_id=a.id AND n.plupp_val=p.id AND p.endast_admin=0 AND a.datum>DATE_SUB( NOW(), INTERVAL 1 DAY) order by a.datum";
			//$sql ="select n.id, n.aktivitets_id from narvaro as n, aktiviteter as a, pluppar as p where n.user_id='$user_id' AND n.aktivitets_id=a.id AND n.plupp_val=p.id AND p.endast_admin=0 AND a.datum>DATE_SUB( NOW(), INTERVAL 1 DAY) order by a.datum";

		}

		$resultat = mysql_query($sql);
		$antalAktiviteter = mysql_num_rows($resultat);

		$ip = getenv('REMOTE_ADDR');

		$mailbody = "";

		for($a_index=0;$a_index<$antalAktiviteter;$a_index++)
		{
			//list($narvaro_id, $aktivitets_id)=mysql_fetch_array($resultat);
			list($narvaro_id, $aktivitets_id, $plupp_val, $is_viktig_plupp_text, $plupp_text, $aktivitets_datum,  $aktivitets_info,$standardplupptext)=mysql_fetch_array($resultat);

			$bad_html = array('<', '>', '"');
			$god_html  = array('&lt', '>', '"');
			$info_viktig_ny=0;

			//radiobutton heter A
			//Checkbox heter C
			//TextBox heter T

			$plupp_val_ny =		${"A".$aktivitets_id};
			$info_ny =			str_replace($bad_html, $god_html, ${"T".$aktivitets_id});

			if(strlen(${"C".$aktivitets_id})>0) //'on' eller tom
			{
				$info_viktig_ny=1;
			}


			$sql = "UPDATE phpbb2_narvaro_narvaro SET plupp_val='$plupp_val_ny', viktig_plupp_text='$info_viktig_ny', datum=NOW(), plupp_text='$info_ny', ip='$ip' where id='$narvaro_id' AND user_id='$user_id' AND aktivitets_id='$aktivitets_id' AND ( plupp_val<>'$plupp_val_ny' OR viktig_plupp_text<>'$info_viktig_ny' OR plupp_text<>'$info_ny')";

		//	echo $sql."<br><br>";

			mysql_query($sql);
		//	echo "Antal rader som ändrades: ".mysql_affected_rows()."<br><br><br>";
			if(mysql_affected_rows()>0)
			{
				$sql = "select plupp_text from phpbb2_narvaro_pluppar where id = '$plupp_val_ny'";
				$res_namn = mysql_query($sql);
				list($plupp_text_std_ny)=mysql_fetch_array($res_namn);
				$mailbody=$mailbody."\n";
				$mailbody=$mailbody."Ändrat------------------\n";
				$mailbody=$mailbody."Datum:         $aktivitets_datum\n";
				$mailbody=$mailbody."Info:          $aktivitets_info\n";
				$mailbody=$mailbody."NärvaroID:     $narvaro_id\n";
				$mailbody=$mailbody."Aktivitets ID: $aktivitets_id\n";
				$mailbody=$mailbody."Närvaro:       $standardplupptext till $plupp_text_std_ny\n";
				$mailbody=$mailbody."Plupp ID:      $plupp_val till $plupp_val_ny\n";
				$mailbody=$mailbody."Viktig:        $is_viktig_plupp_text till $info_viktig_ny\n";
				$mailbody=$mailbody."Plupptext ga:  $plupp_text\n";
				$mailbody=$mailbody."Plupptext ny:  $info_ny\n";
			}
		}
		$tid[2]=getmicrotime();



		//mail("johan@horlen.com", "Ändrad BSK info", "Namn: $fornamn $efternamn \nAv: ".$_SESSION['bsklogin_user']." \nHost: ".gethostbyaddr(getenv('REMOTE_ADDR'))."\nIP: ".getenv('REMOTE_ADDR')."\n".$mailbody);

		$mail="info@triangelns.com";
		$subject="Ändrad TBS info";
		$body="Namn: $fornamn $efternamn \nAv: ".$_SESSION['bsklogin_user']." \nHost: ".gethostbyaddr(getenv('REMOTE_ADDR'))."\nIP: ".getenv('REMOTE_ADDR')."\n".$mailbody;

		$sql ="insert into mail (datum, mail.to, mail.from, subject, body) values (NOW(),'$mail', '$mail', '$subject', '$body')";
		mysql_query($sql);
		

		$tid[3]=getmicrotime();
		

		mysql_close();
		header("location: userinfo.php?uid=$user_id&info=Ändringarna är sparade.");
		//echo ($tid[0]-$tid[0])."<br>";
		//echo ($tid[1]-$tid[0])."<br>";
		//echo ($tid[2]-$tid[0])."<br>";
		//echo ($tid[3]-$tid[0])."<br>";
		

		//$tid[1]=getmicrotime();
		exit;
	}
	else
	{
	//Vanliga sidan där man får välja vad man vill ändra.
?>

<form method="POST" action="">
<p align="center"><font face="Arial" size="2">Ändra din närvaro <?=$fornamn?> <?=$efternamn?></font></p>
<div align="center">
  <center>

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber1">
  <tr>
  <td>&nbsp;</td>
<?php
	$narmasteAktivID=0;

	//Tar fram närmsta träning
	$sql="select id from phpbb2_narvaro_aktiviteter where DATE_FORMAT(NOW(),'%Y%m%d')<=DATE_FORMAT(datum,'%Y%m%d') order by datum limit 1";

	$resultat = mysql_query($sql);
	$antalSvar = mysql_num_rows($resultat);
	if($antalSvar==1)// && isLoggedInAdmin())
	{
		list($narmasteAktivID)=mysql_fetch_array($resultat);
	}

	$sql = "select textbild_staande, color, id, plupp_text from phpbb2_narvaro_pluppar order by sortering";
	if(!isLoggedInAdmin())
	{
		$sql ="select textbild_staande, color, id, plupp_text from phpbb2_narvaro_pluppar where endast_admin=0 order by sortering";
	}

	$resultat = mysql_query($sql);
	$antalPluppar = mysql_num_rows($resultat);

	for($tal=0;$tal<$antalPluppar;$tal++)
	{
		list($bild, $color, $plupp_id, $plupp_text)=mysql_fetch_array($resultat);
		$color_array[$tal]=$color;
		$plupp_id_array[$tal]=$plupp_id;
		?>
		<td valign="bottom" bgcolor="<?=$color?>"><img border="0" alt="<?=$plupp_text?>" src="<?=$bild?>"></td>
		<?
	}
?>
    <td valign="bottom"><img border="0" alt="Viktig info" src="viktiginfo.gif"></td>
    <td  nowrap valign="top"><font face="Arial" size="2">Info<br>
</font><font color="#000080" face="Arial" size="1">Här anges x-tra info om det 
behövs.<br>Tex varför man satt gul plupp. Om<br>infon har betydande relevans kan<br>man
även trycka i rutan "Viktig info"<br>för att uppmärksamma infon.<br>
Max 255 TECKEN.</font></td>
  </tr>

<?php
	//admin - admin ska se alla (hela history).
	$sql = "select n.id, n.aktivitets_id, n.plupp_val, n.viktig_plupp_text, n.plupp_text, DATE_FORMAT(a.datum,'%Y-%m-%d'), a.headcolor, a.info from phpbb2_narvaro_narvaro as n, phpbb2_narvaro_aktiviteter as a where n.user_id='$user_id' AND n.aktivitets_id=a.id order by a.datum";
	if(!isLoggedInAdmin())
	{
		//klient - Klienten ska bara få se de som är nyare NOW()-en dag och som inte är svart eller blank.
		$sql ="select n.id, n.aktivitets_id, n.plupp_val, n.viktig_plupp_text, n.plupp_text, DATE_FORMAT(a.datum,'%Y-%m-%d'), a.headcolor, a.info from phpbb2_narvaro_narvaro as n, phpbb2_narvaro_aktiviteter as a, phpbb2_narvaro_pluppar as p where n.user_id='$user_id' AND n.aktivitets_id=a.id AND n.plupp_val=p.id AND p.endast_admin=0 AND DATE_FORMAT(a.datum,'%Y%m%d')>=DATE_FORMAT(NOW(),'%Y%m%d') order by a.datum";

	//

	}

	$resultat = mysql_query($sql);
	$antalAktiviteter = mysql_num_rows($resultat);
	//echo  "antalPluppar = mysql_num_rows($resultat);";
	for($a_index=0;$a_index<$antalAktiviteter;$a_index++)
	{
		list($narvaro_id, $aktivitets_id, $plupp_val, $is_viktig_plupp_text, $plupp_text, $aktivitets_datum, $rubrik_color, $aktivitets_info)=mysql_fetch_array($resultat);

		$next="";
		if($aktivitets_id==$narmasteAktivID)
		{
			$next="#73B9B9";
		}


?>

  <tr>
    <td align="center" bgcolor="<?=$next?>" nowrap><font face="Arial" color="<?=$rubrik_color?>" size="2">
	<a title="<?=$aktivitets_info?>" style="color: <?=$rubrik_color?>; font-family: Arial; font-size: 10pt" href="aktivitetsinfo.php?aid=<?=$aktivitets_id?>"><?=$aktivitets_datum?></a>
	
	</font></td>
	<?
		for($tal=0;$tal<$antalPluppar;$tal++)
		{
			//Om default-bg-färgen för pluppen är tom ändras den turkos om den är den närmsta dagen som det händer en händelse. 
			if(strlen($color_array[$tal])>0)
			{
				$plupp_bg_color=$color_array[$tal];
			}
			else
			{
				$plupp_bg_color=$next;
			}
	?>
    <td bgcolor="<?=$plupp_bg_color?>" align="center"><input type="radio" value="<?=$plupp_id_array[$tal]?>" name="A<?=$aktivitets_id?>" <? if($plupp_val==$plupp_id_array[$tal]) {echo "checked"; } ?>></td>
	<?
		}
	?>
    <td bgcolor="<?=$next?>" align="center">
    <input type="checkbox" name="C<?=$aktivitets_id?>" <? if($is_viktig_plupp_text==1) {echo "value=\"ON\" checked"; } ?>></td>
    <td bgcolor="<?=$next?>" align="center">&nbsp;<input type="text" maxlength="255" value="<?=$plupp_text?>" name="T<?=$aktivitets_id?>" size="20">&nbsp;</td>
  </tr>
<?
	}
  ?>

</table>
  </center>
</div>
<form>
  <p align="center"><input type="submit" value="Spara" name="B1"></p>
</form>
<p align="center"><font face="Arial" size="2"><a href="spelarna.php">Tillbaka 
till spelarlistan</a></font></p>
<?
	}//Slut på if-else som visar den vanliga edit-sidan.
mysql_close();
function getmicrotime() 
{  
    list($usec, $sec) = explode(" ",microtime());  
    return ((float)$usec + (float)$sec);  
} 
?>
Last edited by dellsystem on Wed Mar 12, 2008 2:53 am, edited 2 times in total.
Reason: --Moved to MOD Writers from MOD Requests

z4g0rz4g0r
Registered User
Posts: 74
Joined: Fri Jun 29, 2007 10:59 pm

Re: Session problem?

Post by z4g0rz4g0r » Thu Mar 13, 2008 12:10 pm

Is this for phpbb3?

btw, is the php tag supposed to be there? The tag on line1 hasnt been closed so... :?:

Code: Select all

include ('/home/b2303/public_html/phpBB3/includes/page_header.php');

<?

include_once(".plupp.functions.php");

Post Reply

Return to “[2.0.x] MOD Writers Discussion”