!!! Session Refresh Update !!!

All code and questions for Urban Realms, Forsaken Sanctum, ect...
Post Reply
User avatar
Asgarth
Posts: 62
Joined: Tue Aug 10, 2010 11:57 am

!!! Session Refresh Update !!!

Post by Asgarth »

Hey guys.

I saw people asking or well telling that the login redirection thing well it is a bugger, and they asked if it was possible to make it auto redirect to the login instead of clicking a link...

Well people here it is:

Code: Select all

<?php
	if (isset($_SESSION['player'])) 
	{
		$player=$_SESSION['player'];
		$playerinfo="SELECT * from players where name='$player'";
		$playerinfo2=mysql_query($playerinfo) or die("Could not get user stats");
		$playerinfo3=mysql_fetch_array($playerinfo2);

		echo "<input type='hidden' name='id' value='$playerinfo3[id]'>";
		
		$updaterefresh="update players set lastattacked=0 where ID='$playerinfo3[id]'";

		mysql_query($updaterefresh) or die("Died");
	}
	else
	{
		echo "Sorry, not logged in, please wait you will be redirected to the appropriate place in 5 seconds <meta http-equiv='refresh' content='5;url=../forsaken1/login.php'>";
		echo "<br>";
		echo "If you are not being redirected within 5 seconds, please click <a href='../forsaken1/login.php'>HERE</a> to go there manually";
		exit;
	}

	$currentbar = ($playerinfo3['stamina']/$playerinfo3['maxstamina']) * 100;
	$healthbar = ($playerinfo3['hp']/$playerinfo3['maxhp']) * 100;

?>
Have Fun.
Image
rapid3642
Posts: 45
Joined: Thu Nov 26, 2009 9:38 pm

Re: !!! Session Refresh Update !!!

Post by rapid3642 »

Yea i was a bugger and its not really nice to say we are buggers i mean yea we did bug you guys i guess but we dont know this stuff and thats why we are here. to learn from others and to help form a better community by teaching others what we learned.

besides that. this scripts works thanks for the post it helped me out.

Note
-------------------
(1) To anyone else that may have problems with this script all you have to do is redo the url redirect "IF" yours is different.

Example
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The above url in the script would not originally work for me because my scripts are in a different directory
The original script's url is typed like this
.../forsaken1/login.php
The url above was directing the user to the forsaken1 folder then to the login.php script
This did not work for me because i had my scripts in the main directory so i had to change mine to
.../login.php

(2) This script obviously doesn't replace the entire index script. This just replaces the second php portion of the script.

Example - This is not the revised script do not just copy paste this over your index script because this is the original i am just posting this so everone can learn how to do this and starting to get the feel of changing your scripts around.

I added a comment in the script to show you where to copy paste the new lines of code at in the script. Hope this helps.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Code: Select all

?php
include 'connect.php';
session_start();
?>
<style type="text/css">
<!--
body {
	background-color: #000000;
}
body,td,th {
	color: #FFFFFF;
	font-size: 12px;
	font-weight: bold;
}
.style2 {
	font-size: 14px;
	color: #CCCCCC;
}
-->
</style>

/////////////////////////REPLACE THIS PART OF THE SCRIPT WITH THE ABOVE SCRIPT FROM THE FIRST POST
<?php                                                                                      
if (isset($_SESSION['player'])) 
  {
    $player=$_SESSION['player'];
    $playerinfo="SELECT * from players where name='$player'";
    $playerinfo2=mysql_query($playerinfo) or die("Could not get user stats");
    $playerinfo3=mysql_fetch_array($playerinfo2);
      print "<input type='hidden' name='id' value='$playerinfo3[id]'>";
	 $updaterefresh="update players set lastattacked=0 where ID='$playerinfo3[id]'";
      mysql_query($updaterefresh) or die("Died");
	 }
	else
	{
	print "Sorry, not logged in  please <A href='login.php'>Login</a><br>";
  exit;
  }

?>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 <p><img src="images/homebutt.png" width="181" height="36" /><img src="images/marketbutt.png" width="181" height="36" /></p>
 <table width="100%" height="204" border="0">
   <tr>
      
     <td width="18%"><img src="/images/sidebarstats12.png" width="167" height="455" />  <div
 style="
    top: 299;
    left: 35;
    position: absolute; 	<?php
  if(!isset($start))
  {
    $start=0;
  }
  $order="SELECT * from players";
  $order2=mysql_query($order);
  $t=0;
  $d=0;
  $f=0;
  $g=1;
   while($order3=mysql_fetch_array($order2))
  {
    if($f%10==0)
    {
     $g++;
	 }
    $d=$d+1;
    $f++;
  }
  $topplayers="SELECT * from players order by level DESC Limit $start, 20";
  $topplayers2=mysql_query($topplayers) or die("Could not query players");
  while($topplayer3=mysql_fetch_array($topplayers2))
  {
    $t++;
	$topplayer3[playername]=strip_tags($topplayer3[playername]);
    print $t . ". " . $topplayer3[playername] . "  (" . $topplayer3[level] . ")" .  "<br />";
  }
   
?>
    z-index: 2;
    visibility: show;">
 </div></td>
  
 </div>
    </td>
  
   </tr>
   <tr>
     <td> </td>
     <td> </td>
     <td> </td>
   </tr>
   <tr>
     <td> </td>
     <td> </td>
     <td> </td>
   </tr>
 </table>
 <p align="left"> 
 <p align="left">
 
 <p align="left">
 
 <p align="left"> 
 <p align="left">



<map name="Map2" id="Map2"><area shape="rect" coords="23,212,119,235" href="/watermill.php" />
<area shape="rect" coords="225,269,300,304" href="steelmill.php" />
<area shape="rect" coords="360,232,449,253" href="oilrefinery.php" />
<area shape="rect" coords="220,193,317,218" href="hydrolabs.php" />
<area shape="rect" coords="395,171,485,191" href="tarininglabs.php" />
<area shape="rect" coords="350,340,454,363" href="researchlabs.php" />
<area shape="rect" coords="539,244,620,268" href="housing.php" />
<area shape="rect" coords="82,62,183,89" href="spacezone1.php" />
</map>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
User avatar
Asgarth
Posts: 62
Joined: Tue Aug 10, 2010 11:57 am

Re: !!! Session Refresh Update !!!

Post by Asgarth »

rapid3642 wrote:Yea i was a bugger and its not really nice to say we are buggers i mean yea we did bug you guys i guess but we dont know this stuff and thats why we are here. to learn from others and to help form a better community by teaching others what we learned.

besides that. this scripts works thanks for the post it helped me out.

Note
-------------------
(1) To anyone else that may have problems with this script all you have to do is redo the url redirect "IF" yours is different.

Example
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The above url in the script would not originally work for me because my scripts are in a different directory
The original script's url is typed like this
.../forsaken1/login.php
The url above was directing the user to the forsaken1 folder then to the login.php script
This did not work for me because i had my scripts in the main directory so i had to change mine to
.../login.php

(2) This script obviously doesn't replace the entire index script. This just replaces the second php portion of the script.

Example - This is not the revised script do not just copy paste this over your index script because this is the original i am just posting this so everone can learn how to do this and starting to get the feel of changing your scripts around.

I added a comment in the script to show you where to copy paste the new lines of code at in the script. Hope this helps.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Code: Select all

?php
include 'connect.php';
session_start();
?>
<style type="text/css">
<!--
body {
	background-color: #000000;
}
body,td,th {
	color: #FFFFFF;
	font-size: 12px;
	font-weight: bold;
}
.style2 {
	font-size: 14px;
	color: #CCCCCC;
}
-->
</style>

/////////////////////////REPLACE THIS PART OF THE SCRIPT WITH THE ABOVE SCRIPT FROM THE FIRST POST
<?php                                                                                      
if (isset($_SESSION['player'])) 
  {
    $player=$_SESSION['player'];
    $playerinfo="SELECT * from players where name='$player'";
    $playerinfo2=mysql_query($playerinfo) or die("Could not get user stats");
    $playerinfo3=mysql_fetch_array($playerinfo2);
      print "<input type='hidden' name='id' value='$playerinfo3[id]'>";
	 $updaterefresh="update players set lastattacked=0 where ID='$playerinfo3[id]'";
      mysql_query($updaterefresh) or die("Died");
	 }
	else
	{
	print "Sorry, not logged in  please <A href='login.php'>Login</a><br>";
  exit;
  }

?>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 <p><img src="images/homebutt.png" width="181" height="36" /><img src="images/marketbutt.png" width="181" height="36" /></p>
 <table width="100%" height="204" border="0">
   <tr>
      
     <td width="18%"><img src="/images/sidebarstats12.png" width="167" height="455" />  <div
 style="
    top: 299;
    left: 35;
    position: absolute; 	<?php
  if(!isset($start))
  {
    $start=0;
  }
  $order="SELECT * from players";
  $order2=mysql_query($order);
  $t=0;
  $d=0;
  $f=0;
  $g=1;
   while($order3=mysql_fetch_array($order2))
  {
    if($f%10==0)
    {
     $g++;
	 }
    $d=$d+1;
    $f++;
  }
  $topplayers="SELECT * from players order by level DESC Limit $start, 20";
  $topplayers2=mysql_query($topplayers) or die("Could not query players");
  while($topplayer3=mysql_fetch_array($topplayers2))
  {
    $t++;
	$topplayer3[playername]=strip_tags($topplayer3[playername]);
    print $t . ". " . $topplayer3[playername] . "  (" . $topplayer3[level] . ")" .  "<br />";
  }
   
?>
    z-index: 2;
    visibility: show;">
 </div></td>
  
 </div>
    </td>
  
   </tr>
   <tr>
     <td> </td>
     <td> </td>
     <td> </td>
   </tr>
   <tr>
     <td> </td>
     <td> </td>
     <td> </td>
   </tr>
 </table>
 <p align="left"> 
 <p align="left">
 
 <p align="left">
 
 <p align="left"> 
 <p align="left">



<map name="Map2" id="Map2"><area shape="rect" coords="23,212,119,235" href="/watermill.php" />
<area shape="rect" coords="225,269,300,304" href="steelmill.php" />
<area shape="rect" coords="360,232,449,253" href="oilrefinery.php" />
<area shape="rect" coords="220,193,317,218" href="hydrolabs.php" />
<area shape="rect" coords="395,171,485,191" href="tarininglabs.php" />
<area shape="rect" coords="350,340,454,363" href="researchlabs.php" />
<area shape="rect" coords="539,244,620,268" href="housing.php" />
<area shape="rect" coords="82,62,183,89" href="spacezone1.php" />
</map>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I know for some the 1st post will not work, reason is that i have relocated the whole session period to a new file inside a config folder.
In there i have made a file called session.php, this way it will reduce the size of any file for wich this is needed, and also this will make it more easier to use.

Look at my changelog updates, there i am filling everything i am doing with FS 1.0 with the understanding that i leave all original credits to the owner.

Also the whole index.php is never used, because now the session.php file is relocating you if you are not logged in towards the login.php file else it will relocate you towards the map where you left of.

Keep track of my changelog and you will know what i am doing with this, i already have got a message by the owner, when i am going to release the revised FS 1.0, this will soon be done so erveyone knows where i am.

Anyways, i have to edit the changelog for a new update wich i just made.

Sincere:
Asgarth aka Michael B
Image
rapid3642
Posts: 45
Joined: Thu Nov 26, 2009 9:38 pm

Re: !!! Session Refresh Update !!!

Post by rapid3642 »

oh ok gotcha i cant wait for the revised version of the source code. do you got any idea for a release date?
User avatar
Asgarth
Posts: 62
Joined: Tue Aug 10, 2010 11:57 am

Re: !!! Session Refresh Update !!!

Post by Asgarth »

rapid3642 wrote:oh ok gotcha i cant wait for the revised version of the source code. do you got any idea for a release date?
This will all be stated in my changelog.
Image
Post Reply

Return to “Hall's Games”