Code: Select all
require_once("$DOCUMENT_ROOT/include/content/scripts/auth_group.php");
Code: Select all
<?
require ('access.php');
// Put this after the include/require to check if logged in.
if ($logincheck == 1)
{
// Yes
}
else
{
// No
}
// Put this after the include/require to check if in group.
if ($accesscheck == 1)
{
// Yes
}
else
{
// No
}
?>
Code: Select all
<?php
/*###############################################################
## Mod Title: phpBB2 External Group Auth
## Mod Version: 2.1.0
## Author: Lars Beijar < [email protected] > Edited By: Sir AL < [email protected] >
## Description: Authenticate from other .php files against your phpBB2 userdatabase!
## Allowing only members of the group[s] you specify.
##
## Installation Level: EASY
## Installation Time: 5 Minute
## Files To Edit: 1 (this file)
## Included Files: (n/a)
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/
##############################################################
##
## Author Note:
## Put this file somewhere, name it to whatever you wish, and
## edit it, then use it as an include file in your scripts.
##
## Just add one line at the top of your .php files
## include('/the/path/to/this/file/andthefilename.php');
## or more secure with:
## require('/the/path/to/this/file/andthefilename.php');
##
##
## The Following Variables in the script below need to be edited.
##
### $phpbb_root_path='/usr/local/apache/phpBB2/';
### $phpbb_web_path='/phpBB2/';
### $secure_against_group_name = ('Administrators','Members');
### OR
### $secure_against_group_name = ('11','22');
### $name_or_id = "1";
### $table_prefix = "phpbb_";
### $notamemberofgroup = "
### <p align='center'>
### You are not a Member of this group.<br>
### To request Membership to a Group <a href='". $phpbb_web_path . "groupcp.php'><b>Click Here</b></a>.</p>
### ";
##
##
## (the phpBB Group Reserves The Right To Remove/Edit Author Notes, Should It Be Warranted)
##
#################################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
###############################################################*/
// Change this to the full path to your phpBB2 forum
$phpbb_root_path='c://phpdev//www//phpbb2/';
// Change this to the relative path to your phpBB2 forum
// You can have this in here or delete it from here and have it before the insert script
// This is not the path from this page, it is the path from the page incuding this one
// $phpbb_web_path="/buildforum/";
// Change this to the group name or Group ID
// Depending on which one you pick change the $name_or_id Variable to the proper Value.
// $secure_against_group_name = ('Administrators','Members');
// Or
$secure_against_group_name = 2;
// Group Name, Make 1
// Group ID, Make 0
$name_or_id = "0";
// Only change this if you have changed the default
// Prefix in your phpBB2 installation
$table_prefix = "phpbb_ptc_";
/*##########################################
## STOP #
## DO NOT MODIFY ANYTHING BELOW THIS LINE #
##########################################*/
define('IN_PHPBB', true);
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 user is not logged in - redirect to the login page with this scriptname as a redirect to...
if( !$userdata['session_logged_in'] )
{
$logincheck = 0;
}
else
{
$logincheck = 1;
}
// Start to get group_id
if ($name_or_id == "1")
{
$sql="SELECT group_id FROM " . $table_prefix . "groups WHERE group_name IN " . $secure_against_group_name . " ";
if ( !($result = $db->sql_query($sql)) )
{
die("<B>Error:</B> Could not query group name information<BR>SQL: $sql");
}
if ($db->sql_numrows($result) == 0)
{
die("<B>Error:</B> The group <b>$secure_against_group_name</b> does not exist.");
}
$jj = "0";
// Puts Ids Togeather
while ($row = mysql_fetch_array($result))
{
if ($jj == "0")
{
// First ID
$alltheids = " '$row[group_id]' ";
$jj++;
}
else
{
// Adding the rest of the IDs
$alltheids = "$alltheids, '$row[group_id]' ";
}
}
// Add Brackets
$idsandstuff = "( $alltheids )";
}
// If Group ID and not Name
if($name_or_id == "0")
{
$secure_against_group_no = $secure_against_group_name;
}
else
{
// Move to different Variable
$secure_against_group_no = $idsandstuff;
}
// Check if user is member of the proper group..
$sql="SELECT * FROM " . $table_prefix . "user_group WHERE group_id IN " . $secure_against_group_no . " AND user_id=
'" . $userdata[user_id] . "' LIMIT 1";
if ( !($result = $db->sql_query($sql)) )
{
die("<B>Error:</B> Could not query group rights information<BR>SQL: $sql");
}
if ($db->sql_numrows($result) == 0)
{
$accesscheck = 0;
}
else
{
$accesscheck = 1;
}
?>
Code: Select all
Outdated code removed
Code: Select all
Warning: REG_BADRPT:repetition-operator operand invalid in c:\phpdev\www\phpbb2\secure.php on line 112
Warning: Cannot add header information - headers already sent by (output started at c:\phpdev\www\phpbb2\secure.php:112) in c:\phpdev\www\phpbb2\secure.php on line 113
Code: Select all
Error: Could not query group rights information
SQL: SELECT * FROM phpbb_user_group WHERE group_id IN () AND user_id='-1' LIMIT 1