<?php
/**************************************************************************
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
@Authors: Ryan Thompson(hide@address.com)
***************************************************************************/
/*$Id: osgw.inc.php,v 1.47 2004/05/04 05:32:42 rthomp Exp $*/
//Create required classes
$O = create_class('osgw','osgw');
$session = create_class('session','session');
$user = create_class('user','user');
$setup = create_class('setup','config');
$db = create_class('db',"db_".$db_type);
$date = create_class('date','date');
$groups = create_class('groups','groups');
$help = create_class('help','help');
$lang = create_class('lang','language');
$html = create_class('html','html'); //MUST be created ahead of layout as layout is an extension of
$layout = create_class('layout','layout');
$error = create_class('error','error');
$tracker = create_class('tracker','tracker');
$security = create_class('security','security');
$share = create_class('share', 'sharing');
$category = create_class('category', 'categories');
//Set some varibles
$O->url = $root_url;
$O->dir = $root_dir;
$O->ssl = $ssl;
//Get rid of.
$O->debug = $debug;
$error->debug_status = $debug;
$layout->sitename = $sitename;
$layout->sitelogo = $logo;
$db->host = $db_host;
$db->user = $db_user;
$db->password = $db_password;
$db->database = $db_name;
$db->db_type = $db_type;
//Deprecated
$security->ssl = $ssl;
//Get global variables and constants.
require "{$O->dir}/osgw/global.inc.php";
if(!$db->db_connect())
{
die("Error Connecting to database");
}
//We can't run if the db version and script version are incompatible
$O->verify_version();
//If we require a session to access this page then make sure the session is valid
//If it's not redirect to login.
if(!$service['no_session'])
{
//Need to verify integrity of COOKIE still.
if(!isset($_COOKIE['o_session']) || !$session->verify_session($_COOKIE['o_session']))
{
$session->drop_cookie();
$O->redirect('/login.php');
}
}
//Deprecated
$security->protocol();
$lang->get_language($user->user_id);
$O->current_service = $service['name'];
//We need this condition or it will look for root theme data in a place that doesn't exist.
//----Needs further testing
if(getcwd() != $O->dir)
{
$service_location = explode($O->change_str('/'),getcwd());
$l = count($service_location);
$l--;
$O->current_location = $service_location[$l];
} else {
$O->current_location = 'osgw';
}
//If a valid session exist load it. Otherwise Startup defaults or redirect
if($session->get_session_id())
{
$session->load_session();
if($security->get_access_level($user->user_id, $service['code']) == 0)
{
//Home is a specially handled service and therefore not in the user rights table.
//This may change in the future
if($service['code'] != 'hm')
{
//Add admin notification The adminstrator has been notified
exit('You\'re not allowed to access this script so stop trying.');
}
}
} else {
//This means we don't have a user - No session.
//To prevent crashes we use the default. This is only effective for global access pages like login
$user->user_id = 1;
}
//Don't like this working like it does.
if(!strstr(getcwd(), '/config'))
{
$date->set_date_format();
//$layout->create_layout($service['add_header']);
$layout->initialize_layout($service['add_header'], $user->user_id, $service['code']);
$tracker->update_tracker(getcwd(), $user->user_id);
$lang->current_service = $service['code'];
$text = &$lang->get_messages($service['code']);
}
//May not need anymore. Can't remember it's requirement
$here = getcwd();
/*
@Function: create_class()
@Date: 7-Apr-2002
@Author: Ryan Thompson
@Description: Creates Classes
@Variables: $classname - The name of class being created
$classfile - The file the class is in.
*/
function create_class($classname, $classfile)
{
GLOBAL $root_dir;
$class_path = $root_dir ."/osgw/classes";
$classfile = "class.".$classfile.".php";
require("$class_path/$classfile");
$cls = new $classname;
return $cls;
}