Author Topic: Non-logged in userpages  (Read 2961 times)

0 Members and 1 Guest are viewing this topic.

Offline mYrAn

  • Newbie
  • *
  • Posts: 22
    • View Profile
Non-logged in userpages
« on: October 08, 2006, 04:16:43 PM »
Hello! Im in search of a code that lets only logged in people view a page. So if i have like hello.php, i dont want none-logged in people to be able too see that page, only the logged in ones can see it.

Heres the code of the php file i want it in, i have lots of copies of this file but they all link to different template files.

Code: [Select]
<?php 
$main_template 
'XX'

define('GET_CACHES'1); 
define('ROOT_PATH''./'); 
define('GET_USER_ONLINE'1); 
include(
ROOT_PATH.'global.php'); 
require(
ROOT_PATH.'includes/sessions.php');


$user_access get_permission(); 

if (isset(
$HTTP_GET_VARS['template']) || isset($HTTP_POST_VARS['template'])) { 
  $template = (isset($HTTP_GET_VARS['template'])) ? stripslashes(trim($HTTP_GET_VARS['template'])) : stripslashes(trim($HTTP_POST_VARS['template'])); 
  if (!file_exists(TEMPLATE_PATH."/".$template.".".$site_template->template_extension)) { 
    $template ""
  
  else { 
    $main_template $template
  

else { 
  $template ""

include(
ROOT_PATH.'includes/page_header.php'); 

if (!empty(
$template)) { 
  $clickstream "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">".$lang['home']."</a>".$config['category_separator'].str_replace("_"" "ucfirst($template)); 
  $site_template->register_vars("clickstream"$clickstream); 
  $site_template->print_template($site_template->parse_template($main_template)); 
  include(ROOT_PATH.'includes/page_footer.php'); 


$clickstream "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator']; 
$clickstream .= $main_template


//----------------------------------------------------- 
//--- Print Out --------------------------------------- 
//----------------------------------------------------- 
$site_template->register_vars(array( 
  "msg" => $msg
  "clickstream" => $clickstream 
)); 
  
  $site_template
->print_template($site_template->parse_template($main_template)); 
  include(ROOT_PATH.'includes/page_footer.php'); 

?>

XX = The template files name.

// mYrAn
« Last Edit: October 08, 2006, 06:43:56 PM by mYrAn »

Offline mYrAn

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Non-logged in userpages
« Reply #1 on: October 09, 2006, 08:41:36 AM »
Is it realy that hard?'

EDIT

I did it myself.

Ad this code to the page u dont want viewable for guests
Code: [Select]
//Only for members

if ($user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING) {
  show_error_page($lang['no_permission']);
  exit;
}

« Last Edit: October 09, 2006, 10:07:21 AM by mYrAn »