Skip to content

Commit 0d5152c

Browse files
author
pedro_morgan
committed
Made app.inc.php php5 and moved as class var
1 parent e6c1c42 commit 0d5152c

File tree

1 file changed

+56
-57
lines changed

1 file changed

+56
-57
lines changed

interface/lib/app.inc.php

Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
<?php
2+
/**
3+
* Application Class
4+
*
5+
* @author Till Brehm
6+
* @copyright 2005, Till Brehm, projektfarm Gmbh
7+
* @version 0.1
8+
* @package ISPConfig
9+
*/
10+
211
/*
312
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
413
All rights reserved.
@@ -31,64 +40,61 @@
3140

3241
class app {
3342

34-
private $_language_inc = 0;
43+
private $_language_inc = 0;
3544
private $_wb;
3645
private $_loaded_classes = array();
46+
private $_conf;
3747

38-
public function __construct() {
48+
public function __construct()
49+
{
3950
global $conf;
40-
41-
if($conf['start_db'] == true) {
42-
$this->load('db_'.$conf['db_type']);
51+
$this->_conf = $conf;
52+
if($this->_conf['start_db'] == true) {
53+
$this->load('db_'.$this->_conf['db_type']);
4354
$this->db = new db;
4455
}
45-
46-
if($conf['start_session'] == true) {
56+
if($this->_conf['start_session'] == true) {
4757
session_start();
4858
//* Initialise vars if session is not set
4959
if( !isset($_SESSION['s']['id']) ){
50-
$_SESSION['s'] = array('id' => session_id(), 'theme' => $conf['theme'], 'language' => $conf['language']);
60+
$_SESSION['s'] = array( 'id' => session_id(),
61+
'theme' => $this->_conf['theme'],
62+
'language' => $this->_conf['language']
63+
);
5164
}
5265
}
5366
}
5467

55-
public function uses($classes) {
56-
global $conf;
57-
68+
public function uses($classes)
69+
{
5870
$cl = explode(',',$classes);
5971
if(is_array($cl)) {
6072
foreach($cl as $classname){
6173
if(!array_key_exists($classname, $this->_loaded_classes)){
62-
include_once($conf['classpath'] . '/'.$classname.'.inc.php');
74+
include_once($this->_conf['classpath'] . '/'.$classname.'.inc.php');
6375
$this->$classname = new $classname;
6476
$this->_loaded_classes[$classname] = true;
6577
}
6678
}
6779
}
6880
}
6981

70-
public function load($files) {
71-
global $conf;
72-
82+
public function load($files)
83+
{
7384
$fl = explode(',',$files);
7485
if(is_array($fl)) {
7586
foreach($fl as $file) {
76-
include_once($conf['classpath'] . '/'.$file.'.inc.php');
87+
include_once($this->_conf['classpath'] . '/'.$file.'.inc.php');
7788
}
7889
}
7990
}
8091

81-
/*
82-
0 = DEBUG
83-
1 = WARNING
84-
2 = ERROR
85-
*/
86-
public function log($msg, $priority = 0) {
87-
global $conf;
88-
89-
if($priority >= $conf['log_priority']) {
90-
if (is_writable($conf['log_file'])) {
91-
if (!$fp = fopen ($conf['log_file'], 'a')) {
92+
/** Priority values are: 0 = DEBUG, 1 = WARNING, 2 = ERROR */
93+
public function log($msg, $priority = 0)
94+
{
95+
if($priority >= $this->_conf['log_priority']) {
96+
if (is_writable($this->_conf['log_file'])) {
97+
if (!$fp = fopen ($this->_conf['log_file'], 'a')) {
9298
$this->error('Logfile konnte nicht ge�ffnet werden.');
9399
}
94100
if (!fwrite($fp, date('d.m.Y-H:i').' - '. $msg."\r\n")) {
@@ -101,12 +107,9 @@ public function log($msg, $priority = 0) {
101107
}
102108
}
103109

104-
/*
105-
0 = DEBUG
106-
1 = WARNING
107-
2 = ERROR
108-
*/
109-
public function error($msg, $next_link = '', $stop = true, $priority = 1) {
110+
/** Priority values are: 0 = DEBUG, 1 = WARNING, 2 = ERROR */
111+
public function error($msg, $next_link = '', $stop = true, $priority = 1)
112+
{
110113
//$this->uses("error");
111114
//$this->error->message($msg, $priority);
112115
if($stop == true){
@@ -134,48 +137,44 @@ public function error($msg, $next_link = '', $stop = true, $priority = 1) {
134137
}
135138
}
136139

137-
public function lng($text){
138-
global $conf;
139-
140+
/** Loads language */
141+
public function lng($text)
142+
{
140143
if($this->_language_inc != 1) {
141144
//* loading global and module Wordbook
142-
@include_once($conf['rootpath'].'/lib/lang/'.$_SESSION['s']['language'].'.lng');
143-
@include_once($conf['rootpath'].'/web/'.$_SESSION['s']['module']['name'].'/lib/lang/'.$_SESSION['s']['language'].'.lng');
145+
@include_once($this->_conf['rootpath'].'/lib/lang/'.$_SESSION['s']['language'].'.lng');
146+
@include_once($this->_conf['rootpath'].'/web/'.$_SESSION['s']['module']['name'].'/lib/lang/'.$_SESSION['s']['language'].'.lng');
144147
$this->_wb = $wb;
145148
$this->_language_inc = 1;
146-
}
147-
149+
}
148150
if(!empty($this->_wb[$text])) {
149151
$text = $this->_wb[$text];
150152
}
151-
152153
return $text;
153154
}
154155

155-
public function tpl_defaults() {
156-
global $conf;
157-
158-
$this->tpl->setVar('theme',$_SESSION['s']['theme']);
159-
$this->tpl->setVar('phpsessid',session_id());
160-
$this->tpl->setVar('html_content_encoding',$conf['html_content_encoding']);
161-
if($conf['logo'] != '' && @is_file($conf['logo'])){
162-
$this->tpl->setVar('logo', '<img src="'.$conf['logo'].'" border="0" alt="">');
156+
public function tpl_defaults()
157+
{
158+
$this->tpl->setVar('theme', $_SESSION['s']['theme']);
159+
$this->tpl->setVar('phpsessid', session_id());
160+
$this->tpl->setVar('html_content_encoding', $this->_conf['html_content_encoding']);
161+
if($this->_conf['logo'] != '' && @is_file($this->_conf['logo'])){
162+
$this->tpl->setVar('logo', '<img src="'.$this->_conf['logo'].'" border="0" alt="">');
163163
} else {
164164
$this->tpl->setVar('logo', '&nbsp;');
165165
}
166-
$this->tpl->setVar('app_title',$conf["app_title"]);
167-
$this->tpl->setVar('delete_confirmation',$this->lng('delete_confirmation'));
168-
$this->tpl->setVar('app_module',$_SESSION['s']['module']['name']);
166+
$this->tpl->setVar('app_title', $this->_conf['app_title']);
167+
$this->tpl->setVar('delete_confirmation', $this->lng('delete_confirmation'));
168+
$this->tpl->setVar('app_module', $_SESSION['s']['module']['name']);
169169
if(isset($_SESSION['s']['user']) && $_SESSION['s']['user']['typ'] == 'admin') {
170-
$this->tpl->setVar('is_admin',1);
170+
$this->tpl->setVar('is_admin', 1);
171171
}
172172
}
173173

174174
} // end class
175175

176-
/*
177-
Initialize application (app) object
178-
*/
179-
$app = new app(); // new app($conf);
176+
//** Initialize application (app) object
177+
//* possible future = new app($conf);
178+
$app = new app();
180179

181180
?>

0 commit comments

Comments
 (0)