Skip to content

Commit 1d751b0

Browse files
author
pedro_morgan
committed
* Got rid of $conf['cachedir']
* tidy tpl.php , removed $conf global
1 parent 6fa4b7b commit 1d751b0

File tree

3 files changed

+37
-49
lines changed

3 files changed

+37
-49
lines changed

interface/lib/classes/tpl.inc.php

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ class tpl{
157157
*/
158158
public function newTemplate($tmplfile)
159159
{
160-
if (!$tfile = $this->_fileSearch($tmplfile)) vlibTemplateError::raiseError('VT_ERROR_NOFILE',KILL,$tmplfile);
160+
if (!$tfile = $this->_fileSearch($tmplfile)){
161+
vlibTemplateError::raiseError('VT_ERROR_NOFILE', KILL, $tmplfile);
162+
}
161163

162164
//* make sure that any parsing vars are cleared for the new template
163165
$this->_tmplfile = null;
@@ -169,8 +171,9 @@ public function newTemplate($tmplfile)
169171
$this->_totalparsetime = null;
170172

171173
//* reset debug module
172-
if ($this->_debug) $this->_debugReset();
173-
174+
if ($this->_debug){
175+
$this->_debugReset();
176+
}
174177
$this->_tmplfilename = $tfile;
175178
return true;
176179
}
@@ -253,8 +256,7 @@ public function unsetVar()
253256
*/
254257
public function getVars()
255258
{
256-
if (empty($this->_vars)) return false;
257-
return $this->_vars;
259+
return empty($this->_vars) ? false : $this->_vars;
258260
}
259261

260262
/**
@@ -265,8 +267,7 @@ public function getVars()
265267
public function getVar($var)
266268
{
267269
if ($this->OPTIONS['CASELESS']) $var = strtolower($var);
268-
if (empty($var) || !isset($this->_vars[$var])) return false;
269-
return $this->_vars[$var];
270+
return (empty($var) || !isset($this->_vars[$var])) ? false : $this->_vars[$var];
270271
}
271272

272273
/**
@@ -304,7 +305,7 @@ public function setLoop($k, $v)
304305
$this->_arrvars[$k] = array();
305306
if ($this->OPTIONS['SET_LOOP_VAR'] && !empty($v)) $this->setvar($k, 1);
306307
if (($this->_arrvars[$k] = $this->_arrayBuild($v)) == false) {
307-
vlibTemplateError::raiseError('VT_WARNING_INVALID_ARR',WARNING,$k);
308+
vlibTemplateError::raiseError('VT_WARNING_INVALID_ARR', WARNING, $k);
308309
}
309310
}
310311
return true;
@@ -323,16 +324,17 @@ public function setDbLoop($loopname, $result, $db_type = 'MYSQL')
323324
{
324325
$db_type = strtoupper($db_type);
325326
if (!in_array($db_type, $this->allowed_loop_dbs)) {
326-
vlibTemplateError::raiseError('VT_WARNING_INVALID_LOOP_DB',WARNING, $db_type);
327+
vlibTemplateError::raiseError('VT_WARNING_INVALID_LOOP_DB', WARNING, $db_type);
327328
return false;
328329
}
329330

330331
$loop_arr = array();
332+
// TODO: Are all these necessary as were onyl using mysql and possible postgres ? - pedro
331333
switch ($db_type) {
332334

333335
case 'MYSQL':
334336
if (get_resource_type($result) != 'mysql result') {
335-
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
337+
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
336338
return false;
337339
}
338340
while($r = mysql_fetch_assoc($result)) {
@@ -342,7 +344,7 @@ public function setDbLoop($loopname, $result, $db_type = 'MYSQL')
342344

343345
case 'POSTGRESQL':
344346
if (get_resource_type($result) != 'pgsql result') {
345-
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
347+
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
346348
return false;
347349
}
348350

@@ -355,7 +357,7 @@ public function setDbLoop($loopname, $result, $db_type = 'MYSQL')
355357

356358
case 'INFORMIX':
357359
if (!$result) {
358-
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
360+
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
359361
return false;
360362
}
361363
while($r = ifx_fetch_row($result, 'NEXT')) {
@@ -365,7 +367,7 @@ public function setDbLoop($loopname, $result, $db_type = 'MYSQL')
365367

366368
case 'INTERBASE':
367369
if (get_resource_type($result) != 'interbase result') {
368-
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
370+
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
369371
return false;
370372
}
371373
while($r = ibase_fetch_row($result)) {
@@ -375,7 +377,7 @@ public function setDbLoop($loopname, $result, $db_type = 'MYSQL')
375377

376378
case 'INGRES':
377379
if (!$result) {
378-
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
380+
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
379381
return false;
380382
}
381383
while($r = ingres_fetch_array(INGRES_ASSOC, $result)) {
@@ -385,7 +387,7 @@ public function setDbLoop($loopname, $result, $db_type = 'MYSQL')
385387

386388
case 'MSSQL':
387389
if (get_resource_type($result) != 'mssql result') {
388-
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
390+
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
389391
return false;
390392
}
391393
while($r = mssql_fetch_array($result)) {
@@ -395,7 +397,7 @@ public function setDbLoop($loopname, $result, $db_type = 'MYSQL')
395397

396398
case 'MSQL':
397399
if (get_resource_type($result) != 'msql result') {
398-
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
400+
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
399401
return false;
400402
}
401403
while($r = msql_fetch_array($result, MSQL_ASSOC)) {
@@ -405,7 +407,7 @@ public function setDbLoop($loopname, $result, $db_type = 'MYSQL')
405407

406408
case 'OCI8':
407409
if (get_resource_type($result) != 'oci8 statement') {
408-
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
410+
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
409411
return false;
410412
}
411413
while(OCIFetchInto($result, &$r, OCI_ASSOC+OCI_RETURN_LOBS)) {
@@ -415,7 +417,7 @@ public function setDbLoop($loopname, $result, $db_type = 'MYSQL')
415417

416418
case 'ORACLE':
417419
if (get_resource_type($result) != 'oracle Cursor') {
418-
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
420+
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
419421
return false;
420422
}
421423
while(ora_fetch_into($result, &$r, ORA_FETCHINTO_ASSOC)) {
@@ -425,7 +427,7 @@ public function setDbLoop($loopname, $result, $db_type = 'MYSQL')
425427

426428
case 'OVRIMOS':
427429
if (!$result) {
428-
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
430+
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
429431
return false;
430432
}
431433
while(ovrimos_fetch_into($result, &$r, 'NEXT')) {
@@ -435,7 +437,7 @@ public function setDbLoop($loopname, $result, $db_type = 'MYSQL')
435437

436438
case 'SYBASE':
437439
if (get_resource_type($result) != 'sybase-db result') {
438-
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE',WARNING, $db_type);
440+
vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
439441
return false;
440442
}
441443

@@ -477,7 +479,7 @@ public function addRow($row, $loopname = null)
477479
if (!$loopname) $loopname = $this->_currloopname[(count($this->_currloopname)-1)];
478480

479481
if (!isset($this->_currloop[$loopname]) || empty($this->_currloopname)) {
480-
vlibTemplateError::raiseError('VT_WARNING_LOOP_NOT_SET',WARNING);
482+
vlibTemplateError::raiseError('VT_WARNING_LOOP_NOT_SET', WARNING);
481483
return false;
482484
}
483485
if (is_array($row)) {
@@ -795,7 +797,9 @@ private function _getData ($tmplfile, $do_eval=false)
795797
if ($this->_includedepth > $this->OPTIONS['MAX_INCLUDES'] || $tmplfile == false) {
796798
return;
797799
} else {
798-
if ($this->_debug) array_push ($this->_debugIncludedfiles, $tmplfile);
800+
if ($this->_debug){
801+
array_push ($this->_debugIncludedfiles, $tmplfile);
802+
}
799803
if ($do_eval) {
800804
array_push($this->_currentincludedir, dirname($tmplfile));
801805
$this->_includedepth++;

interface/lib/classes/tpl_ini.inc.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ class vlibIni{
4848
/** Returns $array of config vars for vlibTemplate */
4949
public static function vlibTemplate()
5050
{
51-
52-
global $conf;
5351

5452
$tpl_dir = ISPC_THEMES_PATH.'/'.$_SESSION['s']['theme'].'/templates';
5553
return array(
@@ -89,7 +87,7 @@ public static function vlibTemplate()
8987

9088
/* the following are only used by the vlibTemplateCache class. */
9189
// pedro notes:: triggers a notice as its not set - was $conf['template']['cache_dir'],
92-
'CACHE_DIRECTORY' => $conf['cache_dir'],
90+
'CACHE_DIRECTORY' => ISPC_CACHE_PATH,
9391
// Directory where the cached filesystem
9492
// will be set up (full path, and must be writable)
9593
// '/' or '\' off the end of the directory.

interface/lib/config.inc.php

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@
4141
$conf['app_version'] = '3.0.0';
4242
$conf['modules_available'] = 'admin,mail,sites,monitor,client,dns';
4343

44+
//** The main ROOT is the parent directory to this file, ie Interface/. NO trailing slashes.
45+
define('ISPC_ROOT_PATH', realpath(dirname(__FILE__).'/../'));
46+
define('ISPC_LIB_PATH', ISPC_ROOT_PATH.'/lib');
47+
define('ISPC_CLASS_PATH', ISPC_ROOT_PATH.'/lib/classes');
48+
define('ISPC_WEB_PATH', ISPC_ROOT_PATH.'/web');
49+
define('ISPC_THEMES_PATH', ISPC_ROOT_PATH.'/web/themes');
50+
51+
define('ISPC_TEMP_PATH', ISPC_ROOT_PATH.'/temp');
52+
define('ISPC_CACHE_PATH', ISPC_ROOT_PATH.'/cache');
53+
4454

4555
//********************************************************************************
4656
//** Future Code idea - pedro - rfc
@@ -86,18 +96,6 @@
8696
$conf['db_database'] = 'ispconfig3';
8797
}
8898

89-
90-
//** The main ROOT is the parent directory to this file, ie Interface/. NO trailing slashes.
91-
define('ISPC_ROOT_PATH', realpath(dirname(__FILE__).'/../'));
92-
define('ISPC_LIB_PATH', ISPC_ROOT_PATH.'/lib');
93-
define('ISPC_CLASS_PATH', ISPC_ROOT_PATH.'/lib/classes');
94-
define('ISPC_WEB_PATH', ISPC_ROOT_PATH.'/web');
95-
define('ISPC_THEMES_PATH', ISPC_ROOT_PATH.'/web/themes');
96-
97-
define('ISPC_TEMP_PATH', ISPC_ROOT_PATH.'/temp');
98-
define('ISPC_CACHE_PATH', ISPC_ROOT_PATH.'/cache');
99-
100-
10199
//** Database Settings
102100
/* See above
103101
$conf['db_type'] = 'mysql';
@@ -108,18 +106,6 @@
108106
*/
109107

110108

111-
$conf['cache_dir'] = ISPC_ROOT_PATH.'/cache';
112-
113-
114-
/* pedro notes ? this stuff is REALLY not necessay, can leak everywhere
115-
Don think this lot is being used so commented out
116-
define('DB_TYPE', $conf['db_type']);
117-
define('DB_HOST', $conf['db_host']);
118-
define('DB_DATABASE',$conf['db_database']);
119-
define('DB_USER', $conf['db_user']);
120-
define('DB_PASSWORD', $conf['db_password']);
121-
*/
122-
123109
//** External programs
124110
//$conf["programs"]["convert"] = "/usr/bin/convert";
125111
$conf['programs']['wput'] = ISPC_ROOT_PATH."\\tools\\wput\\wput.exe";

0 commit comments

Comments
 (0)