Jump to content
MakeWebGames

[question / request help] Guest view


mamba

Recommended Posts

I want to limit guest what he can see (some kind of demo mod), but guest can always be able to login and see all related pages with his(her) username.

What is best result to do that?

I am trying to avoid header location, but if I do, what shall I put for $userid variable, as there is query requesting $userid.

Any ideas?

Link to comment
Share on other sites

Insert a new row into `settings`, and call it game_demo and make the value of it 1 (TRUE)

Now, put in globals (at the bottom, just above ?>);

$demoAccount = 2; /* Demo account ID */
$demoPages = array('index.php', 'explore.php', 'gym.php'); /* Pages that the demo account can view */
if(!in_array(basename($_SERVER['PHP_SELF']), $demoPages) AND $userid == $demoAccount AND $set['game_demo'] == 1) {
   echo "You are on the demo account, meaning you cannot be here<br />
            <a href='index.php'>Back</a>";
  exit($h->endpage());
}

 

Then, add to the array and change the value of $demoAccount to the demo accounts ID in the users table.

I hope that helps.

Link to comment
Share on other sites

THANKS!

I only added

$demoAccount = 2; /* Demo account ID */

on the beginning of globals, as I am using it for checking.

It works perfectly.

Also modified globals to allow guest to see pages:

replaced

if($_SESSION['loggedin']==0) { header("Location: ".$boardurl."/login.php");exit; }

with

if($_SESSION['loggedin']==0) { $_SESSION['userid']=$demoAccount; }
Link to comment
Share on other sites

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.   Paste as plain text instead

  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...