@@ -48,14 +48,16 @@ class app {
4848 private $ _wb ;
4949 private $ _loaded_classes = array ();
5050 private $ _conf ;
51+
52+ public $ loaded_plugins = array ();
5153
5254 public function __construct () {
5355 global $ conf ;
5456
5557 if (isset ($ _REQUEST ['GLOBALS ' ]) || isset ($ _FILES ['GLOBALS ' ]) || isset ($ _REQUEST ['s ' ]) || isset ($ _REQUEST ['s_old ' ]) || isset ($ _REQUEST ['conf ' ])) {
5658 die ('Internal Error: var override attempt detected ' );
5759 }
58-
60+
5961 $ this ->_conf = $ conf ;
6062 if ($ this ->_conf ['start_db ' ] == true ) {
6163 $ this ->load ('db_ ' .$ this ->_conf ['db_type ' ]);
@@ -66,26 +68,26 @@ public function __construct() {
6668 if ($ this ->_conf ['start_session ' ] == true ) {
6769
6870 $ this ->uses ('session ' );
69- $ tmp = $ this ->db -> queryOneRecord ( " SELECT `value` FROM sys_config WHERE `config_id` = 2 AND `group` = 'interface' AND `name` = 'session_timeout'" );
70- if ($ tmp && $ tmp [ ' value ' ] > 0 ) {
71+ $ sess_timeout = $ this ->conf ( 'interface ' , 'session_timeout ' );
72+ if ($ sess_timeout ) {
7173 /* check if user wants to stay logged in */
7274 if (isset ($ _POST ['s_mod ' ]) && isset ($ _POST ['s_pg ' ]) && $ _POST ['s_mod ' ] == 'login ' && $ _POST ['s_pg ' ] == 'index ' && isset ($ _POST ['stay ' ]) && $ _POST ['stay ' ] == '1 ' ) {
7375 /* check if staying logged in is allowed */
7476 $ this ->uses ('ini_parser ' );
7577 $ tmp = $ this ->db ->queryOneRecord ('SELECT config FROM sys_ini WHERE sysini_id = 1 ' );
7678 $ tmp = $ this ->ini_parser ->parse_ini_string (stripslashes ($ tmp ['config ' ]));
7779 if (!isset ($ tmp ['misc ' ]['session_allow_endless ' ]) || $ tmp ['misc ' ]['session_allow_endless ' ] != 'y ' ) {
78- $ this ->session ->set_timeout ($ tmp [ ' value ' ] );
79- session_set_cookie_params (($ tmp [ ' value ' ] * 60 ) + 300 ); // make the cookie live 5 minutes longer
80+ $ this ->session ->set_timeout ($ sess_timeout );
81+ session_set_cookie_params (($ sess_timeout * 60 ) + 300 ); // make the cookie live 5 minutes longer
8082 } else {
8183 // we are doing login here, so we need to set the session data
8284 $ this ->session ->set_permanent (true );
8385 $ this ->session ->set_timeout (365 * 24 * 3600 ); // one year
8486 session_set_cookie_params (365 * 24 * 3600 ); // make the cookie live 5 minutes longer
8587 }
8688 } else {
87- $ this ->session ->set_timeout ($ tmp [ ' value ' ] );
88- session_set_cookie_params (($ tmp [ ' value ' ] * 60 ) + 300 ); // make the cookie live 5 minutes longer
89+ $ this ->session ->set_timeout ($ sess_timeout );
90+ session_set_cookie_params (($ sess_timeout * 60 ) + 300 ); // make the cookie live 5 minutes longer
8991 }
9092 } else {
9193 session_set_cookie_params (0 ); // until browser is closed
@@ -110,6 +112,14 @@ public function __construct() {
110112 $ this ->uses ('auth,plugin ' );
111113 }
112114
115+ public function __get ($ prop ) {
116+ if (property_exists ($ this , $ prop )) return $ this ->{$ prop };
117+
118+ $ this ->uses ($ prop );
119+ if (property_exists ($ this , $ prop )) return $ this ->{$ prop };
120+ else return null ;
121+ }
122+
113123 public function __destruct () {
114124 session_write_close ();
115125 }
@@ -120,7 +130,7 @@ public function uses($classes) {
120130 foreach ($ cl as $ classname ) {
121131 $ classname = trim ($ classname );
122132 //* Class is not loaded so load it
123- if (!array_key_exists ($ classname , $ this ->_loaded_classes )) {
133+ if (!array_key_exists ($ classname , $ this ->_loaded_classes ) && is_file ( ISPC_CLASS_PATH . " / $ classname .inc.php " ) ) {
124134 include_once ISPC_CLASS_PATH ."/ $ classname.inc.php " ;
125135 $ this ->$ classname = new $ classname ();
126136 $ this ->_loaded_classes [$ classname ] = true ;
@@ -138,6 +148,22 @@ public function load($files) {
138148 }
139149 }
140150 }
151+
152+ public function conf ($ plugin , $ key , $ value = null ) {
153+ if (is_null ($ value )) {
154+ $ tmpconf = $ this ->db ->queryOneRecord ("SELECT `value` FROM `sys_config` WHERE `group` = ' " . $ this ->db ->quote ($ plugin ) . "' AND `name` = ' " . $ this ->db ->quote ($ key ) . "' " );
155+ if ($ tmpconf ) return $ tmpconf ['value ' ];
156+ else return null ;
157+ } else {
158+ if ($ value === false ) {
159+ $ this ->db ->query ("DELETE FROM `sys_config` WHERE `group` = ' " . $ this ->db ->quote ($ plugin ) . "' AND `name` = ' " . $ this ->db ->quote ($ key ) . "' " );
160+ return null ;
161+ } else {
162+ $ this ->db ->query ("REPLACE INTO `sys_config` (`group`, `name`, `value`) VALUES (' " . $ this ->db ->quote ($ plugin ) . "', ' " . $ this ->db ->quote ($ key ) . "', ' " . $ this ->db ->quote ($ value ) . "') " );
163+ return $ value ;
164+ }
165+ }
166+ }
141167
142168 /** Priority values are: 0 = DEBUG, 1 = WARNING, 2 = ERROR */
143169
0 commit comments