PDA

View Full Version : Making a page members only


jaredwilli
05-27-2009, 11:57 AM
I have made a page on my site using a method I found on this site somewhere, but I would like to make the page viewable only by members of the site. The page I am talking about is here: http://tweeaks.com/forums/chat.php

Any help I can get to make this page only viewable by members that are logged into the forum would be very much appreciated. I want to write a code that would do something like,
If your a member/logged in, then you can see this page with the chats on it
otherwise you will see a landing page that tells you to go register


and the code that I have that makes the page is this

chat.php
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'chat.php'); // change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(

);

// get special data templates from the datastore
$specialtemplates = array(

);

// pre-cache templates used by all actions
$globaltemplates = array(
'CHAT',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

$navbits = array();
$navbits[$parent] = 'Tweeaks Chat';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('CHAT') . '");');

?>


custom template: CHAT
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header

$navbar

<table>
<tr>
<td>
Page stuff goes in here.
</td>
</tr>
</table>

$footer
</body>
</html>


Thank you in advance :)

bananalive
05-27-2009, 12:30 PM
This will show not logged in users/ unregistered users the standard no permission box, i.e. asking them to login or register

<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'chat.php'); // change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(

);

// get special data templates from the datastore
$specialtemplates = array(

);

// pre-cache templates used by all actions
$globaltemplates = array(
'CHAT',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

if (!$vbulletin->userinfo[userid])
{
print_no_permission();
}

$navbits = array();
$navbits[$parent] = 'Tweeaks Chat';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('CHAT') . '");');

?>

jaredwilli
05-27-2009, 12:46 PM
That's great thanks alot. It works perfect.