1- <?php
2-
3- /*
4- Copyright (c) 2007, Till Brehm, projektfarm Gmbh
5- All rights reserved.
6-
7- Redistribution and use in source and binary forms, with or without modification,
8- are permitted provided that the following conditions are met:
9-
10- * Redistributions of source code must retain the above copyright notice,
11- this list of conditions and the following disclaimer.
12- * Redistributions in binary form must reproduce the above copyright notice,
13- this list of conditions and the following disclaimer in the documentation
14- and/or other materials provided with the distribution.
15- * Neither the name of ISPConfig nor the names of its contributors
16- may be used to endorse or promote products derived from this software without
17- specific prior written permission.
18-
19- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22- IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29- */
30-
31- /*
32- Application Class
33- */
34-
35- ob_start ('ob_gzhandler ' );
36-
37- class app {
38-
39- private $ _language_inc = 0 ;
40- private $ _wb ;
41- private $ _loaded_classes = array ();
42- private $ _conf ;
43-
44- public function __construct ()
45- {
46- global $ conf ;
47- $ this ->_conf = $ conf ;
48- if ($ this ->_conf ['start_db ' ] == true ) {
49- $ this ->load ('db_ ' .$ this ->_conf ['db_type ' ]);
50- $ this ->db = new db ;
51- }
52-
53- //* Start the session
54- if ($ this ->_conf ['start_session ' ] == true ) {
55- session_start ();
56-
57- //* Initialize session variables
58- if (!isset ($ _SESSION ['s ' ]['id ' ]) ) $ _SESSION ['s ' ]['id ' ] = session_id ();
59- if (empty ($ _SESSION ['s ' ]['theme ' ])) $ _SESSION ['s ' ]['theme ' ] = $ conf ['theme ' ];
60- if (empty ($ _SESSION ['s ' ]['language ' ])) $ _SESSION ['s ' ]['language ' ] = $ conf ['language ' ];
61- }
62-
63- $ this ->uses ('auth ' );
64- }
65-
66- public function uses ($ classes )
67- {
68- $ cl = explode (', ' , $ classes );
69- if (is_array ($ cl )) {
70- foreach ($ cl as $ classname ){
71- $ classname = trim ($ classname );
72- //* Class is not loaded so load it
73- if (!array_key_exists ($ classname , $ this ->_loaded_classes )){
74- include_once (ISPC_CLASS_PATH ."/ $ classname.inc.php " );
75- $ this ->$ classname = new $ classname ();
76- $ this ->_loaded_classes [$ classname ] = true ;
77- }
78- }
79- }
80- }
81-
82- public function load ($ files )
83- {
84- $ fl = explode (', ' , $ files );
85- if (is_array ($ fl )) {
86- foreach ($ fl as $ file ){
87- $ file = trim ($ file );
88- include_once (ISPC_CLASS_PATH ."/ $ file.inc.php " );
89- }
90- }
91- }
92-
93- /** Priority values are: 0 = DEBUG, 1 = WARNING, 2 = ERROR */
94- public function log ($ msg , $ priority = 0 )
95- {
96- if ($ priority >= $ this ->_conf ['log_priority ' ]) {
97- if (is_writable ($ this ->_conf ['log_file ' ])) {
98- if (!$ fp = fopen ($ this ->_conf ['log_file ' ], 'a ' )) {
99- $ this ->error ('Unable to open logfile. ' );
100- }
101- if (!fwrite ($ fp , date ('d.m.Y-H:i ' ).' - ' . $ msg ."\r\n" )) {
102- $ this ->error ('Unable to write to logfile. ' );
103- }
104- fclose ($ fp );
105- } else {
106- $ this ->error ('Unable to write to logfile. ' );
107- }
108- }
109- }
110-
111- /** Priority values are: 0 = DEBUG, 1 = WARNING, 2 = ERROR */
112- public function error ($ msg , $ next_link = '' , $ stop = true , $ priority = 1 )
113- {
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=utf-8">
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- /** Loads language */
142- public function lng ($ text )
143- {
144- if ($ this ->_language_inc != 1 ) {
145- //* loading global and module Wordbook
146- // TODO: this need to be made clearer somehow - pedro
147- @include_once (ISPC_ROOT_PATH .'/lib/lang/ ' .$ _SESSION ['s ' ]['language ' ].'.lng ' );
148- @include_once (ISPC_ROOT_PATH .'/web/ ' .$ _SESSION ['s ' ]['module ' ]['name ' ].'/lib/lang/ ' .$ _SESSION ['s ' ]['language ' ].'.lng ' );
149- $ this ->_wb = $ wb ;
150- $ this ->_language_inc = 1 ;
151- }
152- if (!empty ($ this ->_wb [$ text ])) {
153- $ text = $ this ->_wb [$ text ];
154- }
155- return $ text ;
156- }
157-
158- public function tpl_defaults ()
159- {
160- $ this ->tpl ->setVar ('app_title ' , $ this ->_conf ['app_title ' ]);
161- $ this ->tpl ->setVar ('app_version ' , $ this ->_conf ['app_version ' ]);
162- $ this ->tpl ->setVar ('app_link ' , $ this ->_conf ['app_link ' ]);
163- if (isset ($ this ->_conf ['app_logo ' ]) && $ this ->_conf ['app_logo ' ] != '' && @is_file ($ this ->_conf ['app_logo ' ])){
164- $ this ->tpl ->setVar ('app_logo ' , '<img src=" ' .$ this ->_conf ['app_logo ' ].'"> ' );
165- } else {
166- $ this ->tpl ->setVar ('app_logo ' , ' ' );
167- }
168-
169- $ this ->tpl ->setVar ('phpsessid ' , session_id ());
170-
171- $ this ->tpl ->setVar ('theme ' , $ _SESSION ['s ' ]['theme ' ]);
172- $ this ->tpl ->setVar ('html_content_encoding ' , $ this ->_conf ['html_content_encoding ' ]);
173-
174- $ this ->tpl ->setVar ('delete_confirmation ' , $ this ->lng ('delete_confirmation ' ));
175- //print_r($_SESSION);
176- if (isset ($ _SESSION ['s ' ]['module ' ]['name ' ])) {
177- $ this ->tpl ->setVar ('app_module ' , $ _SESSION ['s ' ]['module ' ]['name ' ]);
178- }
179- if (isset ($ _SESSION ['s ' ]['user ' ]) && $ _SESSION ['s ' ]['user ' ]['typ ' ] == 'admin ' ) {
180- $ this ->tpl ->setVar ('is_admin ' , 1 );
181- }
182- if (isset ($ _SESSION ['s ' ]['user ' ]) && $ this ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ])) {
183- $ this ->tpl ->setVar ('is_reseller ' , 1 );
184- }
185- }
186-
187- } // end class
188-
189- //** Initialize application (app) object
190- //* possible future = new app($conf);
191- $ app = new app ();
192-
1+ <?php
2+
3+ /*
4+ Copyright (c) 2007, Till Brehm, projektfarm Gmbh
5+ All rights reserved.
6+
7+ Redistribution and use in source and binary forms, with or without modification,
8+ are permitted provided that the following conditions are met:
9+
10+ * Redistributions of source code must retain the above copyright notice,
11+ this list of conditions and the following disclaimer.
12+ * Redistributions in binary form must reproduce the above copyright notice,
13+ this list of conditions and the following disclaimer in the documentation
14+ and/or other materials provided with the distribution.
15+ * Neither the name of ISPConfig nor the names of its contributors
16+ may be used to endorse or promote products derived from this software without
17+ specific prior written permission.
18+
19+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+ IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+ */
30+
31+ /*
32+ Application Class
33+ */
34+
35+ ob_start ('ob_gzhandler ' );
36+
37+ class app {
38+
39+ private $ _language_inc = 0 ;
40+ private $ _wb ;
41+ private $ _loaded_classes = array ();
42+ private $ _conf ;
43+
44+ public function __construct ()
45+ {
46+ global $ conf ;
47+ $ this ->_conf = $ conf ;
48+ if ($ this ->_conf ['start_db ' ] == true ) {
49+ $ this ->load ('db_ ' .$ this ->_conf ['db_type ' ]);
50+ $ this ->db = new db ;
51+ }
52+
53+ //* Start the session
54+ if ($ this ->_conf ['start_session ' ] == true ) {
55+ session_start ();
56+
57+ //* Initialize session variables
58+ if (!isset ($ _SESSION ['s ' ]['id ' ]) ) $ _SESSION ['s ' ]['id ' ] = session_id ();
59+ if (empty ($ _SESSION ['s ' ]['theme ' ])) $ _SESSION ['s ' ]['theme ' ] = $ conf ['theme ' ];
60+ if (empty ($ _SESSION ['s ' ]['language ' ])) $ _SESSION ['s ' ]['language ' ] = $ conf ['language ' ];
61+ }
62+
63+ $ this ->uses ('auth ' );
64+ }
65+
66+ public function uses ($ classes )
67+ {
68+ $ cl = explode (', ' , $ classes );
69+ if (is_array ($ cl )) {
70+ foreach ($ cl as $ classname ){
71+ $ classname = trim ($ classname );
72+ //* Class is not loaded so load it
73+ if (!array_key_exists ($ classname , $ this ->_loaded_classes )){
74+ include_once (ISPC_CLASS_PATH ."/ $ classname.inc.php " );
75+ $ this ->$ classname = new $ classname ();
76+ $ this ->_loaded_classes [$ classname ] = true ;
77+ }
78+ }
79+ }
80+ }
81+
82+ public function load ($ files )
83+ {
84+ $ fl = explode (', ' , $ files );
85+ if (is_array ($ fl )) {
86+ foreach ($ fl as $ file ){
87+ $ file = trim ($ file );
88+ include_once (ISPC_CLASS_PATH ."/ $ file.inc.php " );
89+ }
90+ }
91+ }
92+
93+ /** Priority values are: 0 = DEBUG, 1 = WARNING, 2 = ERROR */
94+ public function log ($ msg , $ priority = 0 )
95+ {
96+ if ($ priority >= $ this ->_conf ['log_priority ' ]) {
97+ if (is_writable ($ this ->_conf ['log_file ' ])) {
98+ if (!$ fp = fopen ($ this ->_conf ['log_file ' ], 'a ' )) {
99+ $ this ->error ('Unable to open logfile. ' );
100+ }
101+ if (!fwrite ($ fp , date ('d.m.Y-H:i ' ).' - ' . $ msg ."\r\n" )) {
102+ $ this ->error ('Unable to write to logfile. ' );
103+ }
104+ fclose ($ fp );
105+ } else {
106+ $ this ->error ('Unable to write to logfile. ' );
107+ }
108+ }
109+ }
110+
111+ /** Priority values are: 0 = DEBUG, 1 = WARNING, 2 = ERROR */
112+ public function error ($ msg , $ next_link = '' , $ stop = true , $ priority = 1 )
113+ {
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=utf-8">
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+ /** Loads language */
142+ public function lng ($ text )
143+ {
144+ if ($ this ->_language_inc != 1 ) {
145+ //* loading global and module Wordbook
146+ // TODO: this need to be made clearer somehow - pedro
147+ @include_once (ISPC_ROOT_PATH .'/lib/lang/ ' .$ _SESSION ['s ' ]['language ' ].'.lng ' );
148+ @include_once (ISPC_ROOT_PATH .'/web/ ' .$ _SESSION ['s ' ]['module ' ]['name ' ].'/lib/lang/ ' .$ _SESSION ['s ' ]['language ' ].'.lng ' );
149+ $ this ->_wb = $ wb ;
150+ $ this ->_language_inc = 1 ;
151+ }
152+ if (!empty ($ this ->_wb [$ text ])) {
153+ $ text = $ this ->_wb [$ text ];
154+ }
155+ return $ text ;
156+ }
157+
158+ public function tpl_defaults ()
159+ {
160+ $ this ->tpl ->setVar ('app_title ' , $ this ->_conf ['app_title ' ]);
161+ $ this ->tpl ->setVar ('app_version ' , $ this ->_conf ['app_version ' ]);
162+ $ this ->tpl ->setVar ('app_link ' , $ this ->_conf ['app_link ' ]);
163+ if (isset ($ this ->_conf ['app_logo ' ]) && $ this ->_conf ['app_logo ' ] != '' && @is_file ($ this ->_conf ['app_logo ' ])){
164+ $ this ->tpl ->setVar ('app_logo ' , '<img src=" ' .$ this ->_conf ['app_logo ' ].'"> ' );
165+ } else {
166+ $ this ->tpl ->setVar ('app_logo ' , ' ' );
167+ }
168+
169+ $ this ->tpl ->setVar ('phpsessid ' , session_id ());
170+
171+ $ this ->tpl ->setVar ('theme ' , $ _SESSION ['s ' ]['theme ' ]);
172+ $ this ->tpl ->setVar ('html_content_encoding ' , $ this ->_conf ['html_content_encoding ' ]);
173+
174+ $ this ->tpl ->setVar ('delete_confirmation ' , $ this ->lng ('delete_confirmation ' ));
175+ //print_r($_SESSION);
176+ if (isset ($ _SESSION ['s ' ]['module ' ]['name ' ])) {
177+ $ this ->tpl ->setVar ('app_module ' , $ _SESSION ['s ' ]['module ' ]['name ' ]);
178+ }
179+ if (isset ($ _SESSION ['s ' ]['user ' ]) && $ _SESSION ['s ' ]['user ' ]['typ ' ] == 'admin ' ) {
180+ $ this ->tpl ->setVar ('is_admin ' , 1 );
181+ }
182+ if (isset ($ _SESSION ['s ' ]['user ' ]) && $ this ->auth ->has_clients ($ _SESSION ['s ' ]['user ' ]['userid ' ])) {
183+ $ this ->tpl ->setVar ('is_reseller ' , 1 );
184+ }
185+ }
186+
187+ } // end class
188+
189+ //** Initialize application (app) object
190+ //* possible future = new app($conf);
191+ $ app = new app ();
192+
193193?>
0 commit comments