Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Joined: Jan 2000
Posts: 5,833
Likes: 20
UBBDev / UBBWiki Owner
Time Lord
UBBDev / UBBWiki Owner
Time Lord
Joined: Jan 2000
Posts: 5,833
Likes: 20
Originally Posted by swebs
The problem is that I have a bunch of dynamic pages that call eachother. I would have to create a bunch of wrapper pages.

Is there any way to create 1 file the I can include in my code to add the header and footer of the site?
I did this for a client over at www.jrdrags.com actually... Let me know if it's what you're looking for and I'll throw the mockup up here... (check out the side navbar, all links go through a central location)


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, My UBB Scripts
Sponsored Links
Joined: Jun 2001
Posts: 58
Power User
Power User
Offline
Joined: Jun 2001
Posts: 58
I'm getting this weird error. Any ideas? Running php.v.5.2.6 and threads.v.7.3.1

Fatal error: Call to undefined function array_get() in xxx/forum/libs/mysql.inc.php on line 150

Joined: Jan 2000
Posts: 5,833
Likes: 20
UBBDev / UBBWiki Owner
Time Lord
UBBDev / UBBWiki Owner
Time Lord
Joined: Jan 2000
Posts: 5,833
Likes: 20
i don't think its compatible with 7.3 or newer


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, My UBB Scripts
Joined: Jun 2001
Posts: 58
Power User
Power User
Offline
Joined: Jun 2001
Posts: 58
I wasn't sure when Blaaskaak said he has it working if he meant unmodified or if he had to modify it. Nonetheless the error is a bit weird. Any help getting this working for me would be hugely appreciated.

Joined: Feb 2007
Posts: 329
Yarp™
Yarp™
Offline
Joined: Feb 2007
Posts: 329
Will post my updated version tomorrow. Do mind that it does not support the new 7.3 permission matrix.

Sponsored Links
Joined: Feb 2007
Posts: 329
Yarp™
Yarp™
Offline
Joined: Feb 2007
Posts: 329
PHP Code


<?php
require('/home/themeparknl/html/themepark.nl/ubb/libs/smarty/Smarty.class.php');
$smarty = new Smarty();

$smarty->template_dir = 'templates/default';
$smarty->compile_dir = 'templates/compile';

require_once(
"/home/themeparknl/html/themepark.nl/ubb/includes/config.inc.php" );
require_once(
"/home/themeparknl/html/themepark.nl/ubb/libs/mysql.inc.php" );
require_once(
"/home/themeparknl/html/themepark.nl/ubb/libs/html.inc.php");
require_once(
"/home/themeparknl/html/themepark.nl/ubb/libs/ubbthreads.inc.php" );

$dbh = new sql;
$dbh->connect();

class
admin {
function
error( $x ) {
echo
'SQL error';
die;
}
}

//function getmicrotime(){
// list( $usec, $sec ) = explode( " ", microtime() );
// return ( (float) $usec + (float) $sec );
//}

//function find_environmental( $x ) {
// return isset( $_SERVER[$x] ) ? $_SERVER[$x] : "";
//}

class UserAuth {
var
$fields;
var
$is_logged_in;
var
$permissions;
var
$is_banned;
var
$groups;

function
UserAuth() {
global
$config, $dbh;

// First, the stupid stuff we do in every constructor
$this->fields = array();
$this->is_logged_in = false;
$this->permissions = "";
$this->is_banned = false;
$this->groups = array();

// Now, the real meat
$id = $this->fetch_cookie( "ubbt_myid" );
$pass = $this->fetch_cookie( "ubbt_pass" );

if(
$id == 0 ) {
$this->is_logged_in = false;
$this->fields = array(
'USER_ID' => 1,
'USER_DISPLAY_NAME' => "Anonymous",
);
$this->get_permissions();
return;
}

$query = "
SELECT t1.USER_ID, t1.USER_DISPLAY_NAME, t1.USER_PASSWORD, t1.USER_MEMBERSHIP_LEVEL, t1.USER_IS_BANNED,
t2.*
FROM
{$config['TABLE_PREFIX']}USERS as t1,
{$config['TABLE_PREFIX']}USER_PROFILE as t2
WHERE t1.USER_ID = t2.USER_ID AND t1.USER_ID = ?
"
;

$sth = $dbh->do_placeholder_query( $query, array( $id ), __LINE__, __FILE__ );
$temp = $dbh->fetch_array( $sth );

foreach(
$temp as $k => $v ) {
if(
is_numeric( $k ) ) {
unset(
$temp[$k] );
}
}

$this->fields =& $temp;

$this->get_permissions();


$key = $this->fetch_cookie( "ubbt_key" );
$session = $this->fetch_cookie( "ubbt_mysess" );

if(
$this->fields['USER_SESSION_ID'] == $session ) {
$this->is_logged_in = true;
$this->check_ban();
return;
}

if(
$key == md5( $this->fields['USER_ID'] . $this->fields['USER_PASSWORD'] ) ) {
srand( (double) ( microtime() * 1000000 ) );

$new_session_id = md5( rand( 0, 32767 ) );

$now = time() + ( $config['SERVER_TIME_OFFSET'] * 3600 );

$query = "
UPDATE
{$config['TABLE_PREFIX']}USERS
SET USER_SESSION_ID = ?
WHERE USER_ID = ?
"
;

$dbh->do_placeholder_query( $query, array( $new_session_id, $this->fields['USER_ID'] ), __LINE__, __FILE__ );

$this->set_cookie( "ubbt_mysess", $new_session_id );
$this->is_logged_in = true;

$query = "
UPDATE
{$config['TABLE_PREFIX']}USER_DATA
SET USER_LAST_VISIT_TIME = ?
WHERE USER_ID = ?
"
;

$dbh->do_placeholder_query( $query, array( $now, $this->fields['USER_ID'] ), __LINE__, __FILE__ );
$this->check_ban();
return;
}
}

function
check_ban() {
// This will be especially long, since I refuse to require
// an html object, since that makes this class pointless.
global $config, $dbh;

// First, is his status actually set to banned?
if( $this->fields['USER_IS_BANNED'] ) {
// This user was specifically banned, so find out for how long
require_once( "/home/themeparknl/html/themepark.nl/ubb/libs/triggers.inc.php" );
$free = trigger_ban_expiration();

if( ! isset(
$free[ $this->fields['USER_ID'] ] ) ) {
$this->is_banned = true;
}
}

$ip = $_SERVER['REMOTE_ADDR'];

$query = "
SELECT COUNT( BANNED_HOST )
FROM
{$config['TABLE_PREFIX']}BANNED_HOSTS
WHERE ? LIKE BANNED_HOST
"
;

$sth = $dbh->do_placeholder_query( $query, array( $ip ), __LINE__, __FILE__ );
list(
$banned ) = $dbh->fetch_array( $sth );

if(
$banned ) {
$this->is_banned = true;
}
}



function
fetch_cookie( $name ) {
global
$config;

$k = $config['COOKIE_PREFIX'] . $name;

return isset(
$_COOKIE[$k] ) ? $_COOKIE[$k] : "";
}

function
set_cookie( $name, $value ) {
global
$config;

$name = $config['COOKIE_PREFIX'] . $name;
$path = ( $config['COOKIE_PATH'] ? $config['COOKIE_PATH'] : ( $config['SEARCH_FRIENDLY_URLS'] ? "/" : "" ) );

setcookie( $name, $value, 0, $path );

if(
$value ) {
$_SESSION[$name] = $value;
} else {
unset(
$_SESSION[$name] );
}
}

function
in_group( $id ) {
return
in_array( $id, $this->groups );
}

function
build_permissions() {
global
$config, $dbh;

if(
is_array( $this->permissions ) ) {
return
true;
}

$this->permissions = array();

$query = "
SELECT GROUP_ID
FROM
{$config['TABLE_PREFIX']}USER_GROUPS
WHERE USER_ID = ?
"
;

$sth = $dbh->do_placeholder_query( $query, array( $this->fields['USER_ID'] ), __LINE__, __FILE__ );

$groups = array();
while(
$x = $dbh->fetch_array( $sth ) ) {
$groups[] = $x[0];
}

if(
count( $groups ) == 0 ) {
$groups[] = "4";
}

$this->groups = $groups;

$query = "
SELECT *
FROM
{$config['TABLE_PREFIX']}FORUM_PERMISSIONS
WHERE GROUP_ID in ( ? )
"
;

$sth = $dbh->do_placeholder_query( $query, array( $groups ), __LINE__, __FILE__ );

while(
$result = $dbh->fetch_array( $sth ) ) {
if( !
$this->check_access( $result['FORUM_ID'], "read" ) ) {
$this->set_access( $result['FORUM_ID'], "read", $result['FORUM_PERMISSION_CAN_READ'] );
}

if( !
$this->check_access( $result['FORUM_ID'], "topic" ) ) {
$this->set_access( $result['FORUM_ID'], "topic", $result['FORUM_PERMISSION_CAN_CREATE_TOPIC'] );
}

if( !
$this->check_access( $result['FORUM_ID'], "reply" ) ) {
$this->set_access( $result['FORUM_ID'], "reply", $result['FORUM_PERMISSION_CAN_CREATE_REPLY'] );
}
}

$now = time();
$cutoff = $now - ( 3600 * 4 );

$query = "
DELETE FROM
{$config['TABLE_PREFIX']}CACHED_PERMISSIONS
WHERE CACHED_TIMESTAMP < ?
"
;

$dbh->do_placeholder_query( $query, array( $cutoff ), __LINE__, __FILE__ );

$query = "
REPLACE INTO
{$config['TABLE_PREFIX']}CACHED_PERMISSIONS
( USER_ID, CACHED_PERMISSION_DATA, CACHED_TIMESTAMP )
VALUES ( ?, ?, ? )
"
;

// $dbh->do_placeholder_query( $query, array( $this->fields['USER_ID'], serialize( $this->permissions ), $now ), __LINE__, __FILE__ );
}

function
get_permissions() {
global
$config, $dbh;

// First, check to see if we have permissions cached
$query = "
SELECT CACHED_PERMISSION_DATA
FROM
{$config['TABLE_PREFIX']}CACHED_PERMISSIONS
WHERE USER_ID = ?
"
;

// $sth = $dbh->do_placeholder_query( $query, array( $this->user_id ), __LINE__, __FILE__ );
list( $data ) = $dbh->fetch_array( $sth );

//if( ! $data ) {
$this->build_permissions();
return
true;
// }

$this->permissions = unserialize( $data );
return
is_array( $this->permissions );
}

function
check_access( $id, $type ) {
return isset(
$this->permissions[$id][$type] ) && $this->permissions[$id][$type] == 1;
}

function
set_access( $id, $type, $val ) {
if( ! isset(
$this->permissions[$id] ) ) {
$this->permissions[$id] = array();
}

$this->permissions[$id][$type] = $val;
}
}
?>



I am dropping this in as-is on my site. You'd need to adjust the include paths for your site.

Lots of stuff that game me errors just got commented out, I never did a cleanup and as I said, reading out forum permissions does not work anymore.

Joined: Jun 2001
Posts: 58
Power User
Power User
Offline
Joined: Jun 2001
Posts: 58
Sweet! It works! Thanks Yarp!

Joined: Oct 2004
Posts: 14
User
User
Offline
Joined: Oct 2004
Posts: 14
thanks blaaskaak

Last edited by swebs; 05/31/2010 2:32 PM.
Joined: Jan 2000
Posts: 5,833
Likes: 20
UBBDev / UBBWiki Owner
Time Lord
UBBDev / UBBWiki Owner
Time Lord
Joined: Jan 2000
Posts: 5,833
Likes: 20
Has anyone got this working under 7.5?


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, My UBB Scripts
Joined: Jan 2000
Posts: 5,833
Likes: 20
UBBDev / UBBWiki Owner
Time Lord
UBBDev / UBBWiki Owner
Time Lord
Joined: Jan 2000
Posts: 5,833
Likes: 20
Played around and got yarp's version running on 7.5.6; not sure why it didn't like me at first lol...


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, My UBB Scripts
Sponsored Links
Page 2 of 2 1 2

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)