Location: PHPKode > projects > QuickTicket > quickticket/bin/qti_init.php
<?php

// QuickTicket 2.5.1 build:20110304

// -----------------
// Connection config
// -----------------
require_once('bin/config.php');
if ( isset($qti_install) ) { define('QT','qti'.substr($qti_install,-1)); } else { define('QT','qti'); }

// -----------------
// System constants (this CANNOT be changed by webmasters)
// -----------------
if ( !defined('PHP_VERSION_ID') ) { $version=explode('.',PHP_VERSION); define('PHP_VERSION_ID',($version[0]*10000+$version[1]*100+$version[2])); }
define('TABDOMAIN', $qti_prefix.'qtidomain');
define('TABSECTION', $qti_prefix.'qtiforum');
define('TABUSER', $qti_prefix.'qtiuser');
define('TABTOPIC', $qti_prefix.'qtitopic');
define('TABPOST', $qti_prefix.'qtipost');
define('TABSTATUS', $qti_prefix.'qtistatus');
define('TABSETTING', $qti_prefix.'qtisetting');
define('TABLANG', $qti_prefix.'qtilang');
define('QTIVERSION', '2.5.1 build:20110304');
define('QSEL', ' selected="selected"');
define('QCHE', ' checked="checked"');
define('QDIS', ' disabled="disabled"');
define('N', "\n");
define('S', '&nbsp;');

// -----------------
// Interface constants (this can be changed by webmasters)
// -----------------
define('QTI_BACKBUTTON', '&nbsp;&laquo;&nbsp;'); // use FALSE to hide backbutton
define('QTI_DFLT_VIEWMODE',   'N');   // default view mode: N=normal view, C=compact view
define('QTI_SHOW_VIEWMODE',   true);  // allow user changing view mode
define('QTI_SHOW_CONTRAST',   true);  // allow user changing view: hight/default contrast
define('QTI_SHOW_TIME',       true);  // show time in the bottom bar
define('QTI_SHOW_MEMBERLIST', true);  // show memberlist in the menu
define('QTI_SHOW_MODERATOR',  true);  // show moderator in the bottom bar
define('QTI_SHOW_GOTOLIST',   true);  // show gotolist in the bottom bar
define('QTI_SHOW_DOMAIN',     false); // show domain + section name in the crumb trail bar
define('QTI_USE_COPPA',       false); // apply coppa registration rule (child protection act)
define('QTI_CHILDREN',        13);    // end children age (for coppa)
define('QTI_CRUMBTRAIL',' &middot; ');// crumbtrail separator (dont forget spaces)
define('QTI_MENUSEPARATOR', ' &middot; '); // bottom menu separator (dont forget spaces)
define('QTI_NOTIFY_NEWACTOR', true);  // notify new actor when topic actor changes (this option is applicable only in sections having notification activated!)
define('QTI_NOTIFY_OLDACTOR', true);  // notify old actor when topic actor changes (this option is applicable only in sections having notification activated!)
define('QTI_CONVERT_AMP',     false); // save &amp; instead of &. Use TRUE to make &#0000; symbols NOT working.
define('QTI_SIMPLESEARCH',    true);  // simple search by default (use false to directly search as advanced)
define('QTI_DIR_PIC', 'avatar/'); // where to store uploaded userphoto, if allowed, (with final '/')
define('QTI_DIR_DOC', 'upload/'); // where to store uploaded files, if allowed, (with final '/')
define('QTI_LIST_ME', true);      // execute the 'i-replied' search in section list. Set False to improve speed.
define('QTI_LIST_TAG', true);     // display a quick search link for the tags in section list.
define('QTI_JAVA_MAIL', false);   // Protect e-mail by a javascript
define('QTI_WEEKSTART', 1);       // Start of the week (use code 1=monday,...,7=sunday)
define('QTI_STAFFEDITSTAFF',true); // Staff member can edit posts issued by an other staff member
define('QTI_STAFFEDITADMIN',true); // Staff member can edit posts issued by an administrator
define('QTI_CHANGE_USERNAME',true); // User can change username (if false, only admin can change usernames)

define('QTI_URLREWRITE',false);
// URL rewriting (for expert only):
// Rewriting url requires that your server is configured with following rule for the application folder: RewriteRule ^(.+)\.html(.*) qti_$1.php$2 [L]
// This can NOT be activated if you application folder contains html pages (they will not be accessible anymore when urlrewriting is acticated) 

// -----------------
// Class and functions
// -----------------
require_once('bin/qt_lib_db.php');
require_once('bin/qt_lib_html.php');
require_once('bin/qt_lib_txt.php');
require_once('bin/qt_abstracts.php');
require_once('bin/qti_class_vip.php');
require_once('bin/qti_class_sec.php');
require_once('bin/qti_class_topic.php');
require_once('bin/qti_class_post.php');
require_once('bin/qti_fn_base.php');
require_once('bin/qti_fn_html.php');

// -----------------
//  Installation wizard (if file exists)
// -----------------
if ( !isset($qti_install) ) $qti_install='';
if ( empty($qti_install) )
{
  if ( file_exists('install/index.php') )
  {
  echo 'QuickTicket ',QTIVERSION,' <a href="install/index.php">starting installation</a>...';
  echo '<meta http-equiv="REFRESH" content="1;url=install/index.php">';
  exit;
  }
}

// ----------------
// Initialise Classes
// ----------------
$oDB = new cDB($qti_dbsystem,$qti_host,$qti_database,$qti_user,$qti_pwd,$qti_port,$qti_dsn); if ($oDB===FALSE) Exit;
if ( !empty($oDB->error) ) die ('<p><font color="red">Connection with database failed.<br />Please contact the webmaster for further information.</font></p><p>The webmaster must check that server is up and running, and that the settings in the config file are correct for the database.</p>');
$oVIP = new cVIP();

// ----------------
// Load system parameters (attention some parameters can be reserved, thus not loaded)
// ----------------
if ( !isset($_SESSION[QT]) ) GetParam(true);

// check major parameters

if ( !isset($_SESSION[QT]['skin_dir']) ) $_SESSION[QT]['skin_dir']='skin/default';
if ( !isset($_SESSION[QT]['language']) ) $_SESSION[QT]['language']='english';
if ( empty($_SESSION[QT]['skin_dir']) ) $_SESSION[QT]['skin_dir']='skin/default';
if ( empty($_SESSION[QT]['language']) ) $_SESSION[QT]['language']='english';
if ( substr($_SESSION[QT]['skin_dir'],0,5)!='skin/' ) $_SESSION[QT]['skin_dir'] = 'skin/'.$_SESSION[QT]['skin_dir'];

// change language if required (by coockies or by the menu)

$str=GetIso();
if ( isset($_COOKIE[QT.'_cooklang']) ) $str=substr($_COOKIE[QT.'_cooklang'],0,2);
if ( isset($_GET['lx']) ) $str=substr($_GET['lx'],0,2);
if ( $str!=GetIso() && !empty($str) ) 
{
  include('bin/qti_lang.php');
  if ( array_key_exists($str,$arrLang) )
  {
    $_SESSION[QT]['language'] = $arrLang[$str][2];
    if ( isset($_COOKIE[QT.'_cooklang']) ) setcookie(QT.'_cooklang', $str, time()+60*60*24*100, '/');
    // unset dictionnaries
    $_SESSION['L'] = array();
    if ( isset($_SESSION[QT]['sys_statuses']) ) unset($_SESSION[QT]['sys_statuses']);
  }
  else
  {
    die('Wrong iso code language');
  }
}

// ----------------
// Initialise variable
// ----------------
$error = ''; // Required when server uses register_global_on
$warning = ''; // Required when server uses register_global_on
$arrExtData = array(); // Can be used by extensions

if ( !isset($_SESSION[QT]['viewmode']) ) $_SESSION[QT]['viewmode']=QTI_DFLT_VIEWMODE;
if ( !isset($_SESSION[QT]['userlang']) ) $_SESSION[QT]['userlang']='1';
if ( !isset($_SESSION[QT]['cal_shownews']) ) $_SESSION[QT]['cal_shownews']=FALSE;
if ( !isset($_SESSION[QT]['cal_showall']) ) $_SESSION[QT]['cal_showall']=FALSE;

// ----------------
// Load dictionary
// ----------------
if ( !isset($_SESSION['L']) ) $_SESSION['L'] = array();

CheckDico('index domain sec secdesc');

include_once(GetLang().'qti_main.php');
include_once(GetLang().'qti_icon.php');

// ----------------
// Define types,statuses and initialise statistics
// ----------------
$oVIP->SetSys(); // must be at the end because uses language

// ----------------
// Default HTML settings
// ----------------
$oHtml = new cHtml();
$oHtml->title = $_SESSION[QT]['site_name'];
$oHtml->description = 'QT QuickTicket';
$oHtml->keywords = 'quickticket,trouble ticket,knowledge,qt-cute,OpenSource';
$oHtml->language = 'en,fr,nl';
$oHtml->contenttype = 'text/html; charset='.QTI_HTML_CHAR;
$oHtml->html = '<html xmlns="http://www.w3.org/1999/xhtml" dir="'.QTI_HTML_DIR.'" xml:lang="'.QTI_HTML_LANG.'">';
$oHtml->links[] = '<link rel="shortcut icon" href="'.$_SESSION[QT]['skin_dir'].'/qti_icon.ico" />';
$oHtml->links[] = '<link rel="stylesheet" type="text/css" href="'.$_SESSION[QT]['skin_dir'].'/qti_main.css" title="cssmain" />';
$oHtml->links[] = '<link rel="stylesheet" type="text/css" href="bin/css/qti_print.css" media="print" />';
$oHtml->scripts[] = '<script type="text/javascript" src="bin/qti_base.js"></script>';

if ( $oVIP->coockieconfirm )
{
$oVIP->exitname = $L['Continue'];
$oVIP->EndMessage(NULL,'<h2>'.$L['Welcome'].' '.$oVIP->username.'</h2><p><a href="'.Href('qti_login.php?a=out').'">'.sprintf($L['Welcome_not'],$oVIP->username).'</a></p><br />',$_SESSION[QT]['skin_dir'],0,'350px','login_header','login');
}

// -----------------
//  Time setting (for PHP >=5.2)
// -----------------
if ( PHP_VERSION_ID>=50200 ) {
if ( isset($_SESSION[QT]['defaulttimezone']) ) {
if ( $_SESSION[QT]['defaulttimezone']!=='' ) {

date_default_timezone_set($_SESSION[QT]['defaulttimezone']);

}}}
Return current item: QuickTicket