tbrehm
2007-03-17 cf71a4677eff547c9cedeb1871fc109ae181b0c2
commit | author | age
cb2063 1 <?php
T 2 /*
3 Copyright (c) 2005, Till Brehm, projektfarm Gmbh
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without modification,
7 are permitted provided that the following conditions are met:
8
9     * Redistributions of source code must retain the above copyright notice,
10       this list of conditions and the following disclaimer.
11     * Redistributions in binary form must reproduce the above copyright notice,
12       this list of conditions and the following disclaimer in the documentation
13       and/or other materials provided with the distribution.
14     * Neither the name of ISPConfig nor the names of its contributors
15       may be used to endorse or promote products derived from this software without
16       specific prior written permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 ob_start("ob_gzhandler");
31
32 class app {
33
34         var $_language_inc = 0;
35         var $_wb;
36
37         function app() {
38
39                 global $conf;
40
41                 if($conf["start_db"] == true) {
42                         $this->load('db_'.$conf["db_type"]);
43                         $this->db = new db;
44                 }
45
46                 if($conf["start_session"] == true) {
47                         session_start();
48                         $_SESSION["s"]['id'] = session_id();
49                         if($_SESSION["s"]["theme"] == '') $_SESSION["s"]['theme'] = $conf['theme'];
50                         if($_SESSION["s"]["language"] == '') $_SESSION["s"]['language'] = $conf['language'];
51                 }
52
53         }
54
55         function uses($classes) {
56                 global $conf;
57
58                 $cl = explode(',',$classes);
59                 if(is_array($cl)) {
60                         foreach($cl as $classname) {
61                                 if(!is_object($this->$classname)) {
62                                         include_once($conf['classpath'] . "/".$classname.".inc.php");
63                                         $this->$classname = new $classname;
64                                 }
65                         }
66                 }
67
68         }
69
70         function load($files) {
71
72                 global $conf;
73                 $fl = explode(',',$files);
74                 if(is_array($fl)) {
75                         foreach($fl as $file) {
76                                 include_once($conf['classpath'] . "/".$file.".inc.php");
77                         }
78                 }
79
80         }
81
82         /*
83          0 = DEBUG
84          1 = WARNING
85          2 = ERROR
86         */
87
88         function log($msg, $priority = 0) {
89
90                 if($priority >= $conf["log_priority"]) {
91                         if (is_writable($conf["log_file"])) {
92
93                             if (!$fp = fopen ($conf["log_file"], "a")) {
94                                 $this->error("Logfile konnte nicht geöffnet werden.");
95                             }
96                             if (!fwrite($fp, date("d.m.Y-H:i")." - ". $msg."\r\n")) {
97                                 $this->error("Schreiben in Logfile nicht möglich.");
98                             }
99                             fclose($fp);
100
101                         } else {
102                             $this->error("Logfile ist nicht beschreibbar.");
103                         }
104                 } // if
105         } // func
106
107         /*
108          0 = DEBUG
109          1 = WARNING
110          2 = ERROR
111         */
112
113         function error($msg, $next_link = '', $stop = true, $priority = 1) {
114                 //$this->uses("error");
115                 //$this->error->message($msg, $priority);
116                 if($stop == true){
117                   $msg = '<html>
118 <head>
119 <title>Error</title>
120 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
121 <link href="../themes/default/style.css" rel="stylesheet" type="text/css">
122 </head>
123 <body>
124 <br><br><br>
125 <table width="100%" border="0" cellspacing="0" cellpadding="2">
126 <tr>
127 <td class="error"><b>Error:</b><br>'.$msg;
128                   if($next_link != "") $msg .= '<a href="'.$next_link.'">Next</a><br>';
129                   $msg .= '</td>
130 </tr>
131 </table>
132 </body>
133 </html>';
134                   die($msg);
135                 } else {
136                   echo $msg;
137                   if($next_link != "") echo "<a href='$next_link'>Next</a>";
138                 }
139         }
140
141         function lng($text)
142       {
143         global $conf;
144         if($this->_language_inc != 1) {
145             // loading global and module Wordbook
146             @include_once($conf["rootpath"]."/lib/lang/".$_SESSION["s"]["language"].".lng");
147             @include_once($conf["rootpath"]."/web/".$_SESSION["s"]["module"]["name"]."/lib/lang/".$_SESSION["s"]["language"].".lng");
148             $this->_wb = $wb;
149             $this->_language_inc = 1;
150         }
151
152         if(!empty($this->_wb[$text])) {
153             $text = $this->_wb[$text];
154         }
155
156         return $text;
157       }
158
159           function tpl_defaults() {
160                 global $conf;
161
162                 $this->tpl->setVar('theme',$_SESSION["s"]["theme"]);
163                 $this->tpl->setVar('phpsessid',session_id());
164                 $this->tpl->setVar('html_content_encoding',$conf["html_content_encoding"]);
165                 if($conf["logo"] != '' && @is_file($conf["logo"])){
166                   $this->tpl->setVar('logo', '<img src="'.$conf["logo"].'" border="0" alt="">');
167                 } else {
168                   $this->tpl->setVar('logo', '&nbsp;');
169                 }
170                 $this->tpl->setVar('app_title',$conf["app_title"]);
171                 $this->tpl->setVar('delete_confirmation',$this->lng('delete_confirmation'));
cf71a4 172                 $this->tpl->setVar('app_module',$_SESSION["s"]["module"]["name"]);
cb2063 173
T 174           }
175
176 }
177
178 /*
179  Initialize application (app) object
180 */
181
182 $app = new app;
183
b5a2f8 184 ?>