Skip to content

Commit 99bf8ff

Browse files
author
pedro_morgan
committed
* Removing all references to $conf['rootpath'] and using contants
* introduciton ISPC_WEB_PATH and ISPC_THEMES_PATH
1 parent dcff571 commit 99bf8ff

File tree

6 files changed

+106
-111
lines changed

6 files changed

+106
-111
lines changed

interface/lib/classes/tpl_ini.inc.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public static function vlibTemplate()
5151

5252
global $conf;
5353

54-
$tpl_dir = $conf['rootpath'].'/web/themes/'.$_SESSION['s']['theme'].'/templates';
55-
54+
$tpl_dir = ISPC_THEMES_PATH.'/'.$_SESSION['s']['theme'].'/templates';
5655
return array(
5756

5857
'TEMPLATE_DIR' => $tpl_dir, // Default directory for your template files (full path)

interface/lib/config.inc.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,14 @@
8888

8989

9090
//** 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_TEMP_PATH', ISPC_ROOT_PATH.'/temp');
95-
define('ISPC_CACHE_PATH', ISPC_ROOT_PATH.'/cache');
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');
9699

97100

98101
//** Database Settings
@@ -104,11 +107,10 @@
104107
$conf['db_database'] = 'ispconfig3';
105108
*/
106109

107-
$conf['rootpath'] = substr(dirname(__FILE__),0,-4);
110+
//$conf['rootpath'] = substr(dirname(__FILE__),0,-4);
108111
$conf['fs_div'] = '/'; // File system divider, \\ on windows and / on linux and unix
109-
$conf['temppath'] = $conf['rootpath'].$conf['fs_div'].'temp';
110112
// predro notes: not sure this is the right thing ?
111-
$conf['cache_dir'] = $conf['rootpath'].$conf['fs_div'].'/cache';
113+
$conf['cache_dir'] = ISPC_ROOT_PATH.'/cache';
112114

113115

114116
/* pedro notes ? this stuff is REALLY not necessay, can leak everywhere
@@ -122,7 +124,7 @@
122124

123125
//** External programs
124126
//$conf["programs"]["convert"] = "/usr/bin/convert";
125-
$conf['programs']['wput'] = $conf['rootpath']."\\tools\\wput\\wput.exe";
127+
$conf['programs']['wput'] = ISPC_ROOT_PATH."\\tools\\wput\\wput.exe";
126128

127129

128130
//** Themes

interface/web/admin/form/users.tform.php

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
may be used to endorse or promote products derived from this software without
1717
specific prior written permission.
1818
19-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
2020
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2121
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2222
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
@@ -34,9 +34,9 @@
3434
Tabellendefinition
3535
3636
Datentypen:
37-
- INTEGER (Wandelt Ausdrücke in Int um)
37+
- INTEGER (Wandelt Ausdr�cke in Int um)
3838
- DOUBLE
39-
- CURRENCY (Formatiert Zahlen nach Währungsnotation)
39+
- CURRENCY (Formatiert Zahlen nach W�hrungsnotation)
4040
- VARCHAR (kein weiterer Format Check)
4141
- TEXT (kein weiterer Format Check)
4242
- DATE (Datumsformat, Timestamp Umwandlung)
@@ -55,77 +55,80 @@
5555
- Wert oder Array
5656
5757
Hinweis:
58-
Das ID-Feld ist nicht bei den Table Values einzufügen.
58+
Das ID-Feld ist nicht bei den Table Values einzuf�gen.
5959
6060
6161
*/
6262

63-
$form["title"] = "Users";
64-
$form["description"] = "Form to edit systemusers.";
65-
$form["name"] = "users";
66-
$form["action"] = "users_edit.php";
67-
$form["db_table"] = "sys_user";
68-
$form["db_table_idx"] = "userid";
69-
$form["tab_default"] = "users";
70-
$form["list_default"] = "users_list.php";
71-
$form["auth"] = 'yes';
63+
$form['title'] = 'Users';
64+
$form['description'] = 'Form to edit systemusers.';
65+
$form['name'] = 'users';
66+
$form['action'] = 'users_edit.php';
67+
$form['db_table'] = 'sys_user';
68+
$form['db_table_idx'] = 'userid';
69+
$form['tab_default'] = 'users';
70+
$form['list_default'] = 'users_list.php';
71+
$form['auth'] = 'yes';
7272

73-
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
74-
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
75-
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
76-
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
77-
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
73+
//* 0 = id of the user, > 0 id must match with id of current user
74+
$form['auth_preset']['userid'] = 0;
75+
//* 0 = default groupid of the user, > 0 id must match with groupid of current user
76+
$form['auth_preset']['groupid'] = 0;
7877

79-
// lese Module aus
78+
//** Permissions are: r = read, i = insert, u = update, d = delete
79+
$form['auth_preset']['perm_user'] = 'riud';
80+
$form['auth_preset']['perm_group'] = 'riud'; //r = read, i = insert, u = update, d = delete
81+
$form['auth_preset']['perm_other'] = ''; //r = read, i = insert, u = update, d = delete
82+
83+
//* Pick out modules
8084
$modules_list = array();
81-
$handle = @opendir($conf["rootpath"]."/web");
85+
$handle = @opendir(ISPC_WEB_PATH);
8286
while ($file = @readdir ($handle)) {
83-
if ($file != "." && $file != "..") {
84-
if(@is_dir($conf["rootpath"]."/web/".$file)) {
85-
if(is_file($conf["rootpath"]."/web/".$file."/lib/module.conf.php") and $file != 'login') {
87+
if ($file != '.' && $file != '..') {
88+
if(@is_dir(ISPC_WEB_PATH."/$file")) {
89+
if(is_file(ISPC_WEB_PATH."/$file/lib/module.conf.php") and $file != 'login') {
8690
$modules_list[$file] = $file;
8791
}
8892
}
8993
}
9094
}
9195

92-
// lese Themes aus
96+
//* Load themes
9397
$themes_list = array();
94-
$handle = @opendir($conf["rootpath"]."/web/themes");
98+
$handle = @opendir(ISPC_THEMES_PATH);
9599
while ($file = @readdir ($handle)) {
96-
if (substr($file,0,1) != '.') {
97-
if(@is_dir($conf["rootpath"]."/web/themes/".$file)) {
100+
if (substr($file, 0, 1) != '.') {
101+
if(@is_dir(ISPC_THEMES_PATH."/$file")) {
98102
$themes_list[$file] = $file;
99103
}
100104
}
101105
}
102106

103-
// lese verfügbare Sprachen aus
107+
//* Languages
104108
$language_list = array();
105-
$handle = @opendir($conf["rootpath"]."/lib/lang");
109+
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
106110
while ($file = @readdir ($handle)) {
107-
if ($file != "." && $file != "..") {
108-
if(@is_file($conf["rootpath"]."/lib/lang/".$file) and substr($file,-4,4) == '.lng') {
109-
$tmp = substr($file,0,2);
111+
if ($file != '.' && $file != '..') {
112+
if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
113+
$tmp = substr($file, 0, 2);
110114
$language_list[$tmp] = $tmp;
111115
}
112116
}
113117
}
114118

115-
// lese verfügbare Gruppen aus.
119+
//* Pick out groups
116120
$groups_list = array();
117-
$tmp_records = $app->db->queryAllRecords("SELECT groupid, name FROM sys_group ORDER BY name");
121+
$tmp_records = $app->db->queryAllRecords('SELECT groupid, name FROM sys_group ORDER BY name');
118122
if(is_array($tmp_records)) {
119123
foreach($tmp_records as $tmp_rec) {
120-
$tmp_id = $tmp_rec["groupid"];
121-
$groups_list[$tmp_id] = $tmp_rec["name"];
124+
$groups_list[$tmp_rec['groupid']] = $tmp_rec['name'];
122125
}
123126
}
124127

125-
$form["tabs"]['users'] = array (
126-
'title' => "Users",
128+
$form['tabs']['users'] = array (
129+
'title' => 'Users',
127130
'width' => 80,
128-
'template' => "templates/users_user_edit.htm",
131+
'template' => 'templates/users_user_edit.htm',
129132
'fields' => array (
130133
##################################
131134
# Beginn Datenbankfelder
@@ -240,10 +243,10 @@
240243
)
241244
);
242245
/*
243-
$form["tabs"]['address'] = array (
244-
'title' => "Address",
246+
$form['tabs']['address'] = array (
247+
'title' => 'Address',
245248
'width' => 80,
246-
'template' => "templates/users_address_edit.htm",
249+
'template' => 'templates/users_address_edit.htm',
247250
'fields' => array (
248251
##################################
249252
# Beginn Datenbankfelder
@@ -399,10 +402,10 @@
399402
);
400403
*/
401404

402-
$form["tabs"]['groups'] = array (
403-
'title' => "Groups",
405+
$form['tabs']['groups'] = array (
406+
'title' => 'Groups',
404407
'width' => 80,
405-
'template' => "templates/users_groups_edit.htm",
408+
'template' => 'templates/users_groups_edit.htm',
406409
'fields' => array (
407410
##################################
408411
# Beginn Datenbankfelder

interface/web/admin/lib/module.conf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@
110110

111111

112112
// Getting the admin options from other modules
113-
$modules = explode(',',$_SESSION['s']['user']['modules']);
113+
$modules = explode(',', $_SESSION['s']['user']['modules']);
114114
if(is_array($modules)) {
115115
foreach($modules as $mt) {
116116
if(is_file($mt.'/lib/admin.conf.php')) {
117117
$options = array();
118-
include_once($conf['rootpath'].'/web/'.$mt.'/lib/admin.conf.php');
118+
include_once(ISPC_WEB_PATH."/$mt/lib/admin.conf.php");
119119
if(is_array($options)) {
120120
foreach($options as $opt) {
121121
$module['nav'][] = $opt;

interface/web/designer/form_list.php

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,48 +31,45 @@
3131
require_once('../../lib/app.inc.php');
3232

3333
// Checking permissions for the module
34-
if(!stristr($_SESSION["s"]["user"]["modules"],$_SESSION["s"]["module"]["name"])) {
35-
header("Location: ../index.php");
34+
if(!stristr($_SESSION['s']['user']['modules'],$_SESSION['s']['module']['name'])) {
35+
header('Location: ../index.php');
3636
exit;
3737
}
3838

3939
$app->uses('tpl');
4040

41-
$app->tpl->newTemplate("form.tpl.htm");
42-
$app->tpl->setInclude('content_tpl','templates/form_list.htm');
41+
$app->tpl->newTemplate('form.tpl.htm');
42+
$app->tpl->setInclude('content_tpl', 'templates/form_list.htm');
4343

44-
function getinfo($file,$form_file,$bgcolor) {
45-
global $conf,$app;
44+
function getinfo($file, $form_file, $bgcolor) {
4645
$module_name = $file;
47-
include($conf["rootpath"]."/web/".$file."/form/$form_file");
48-
return array( 'name' => $form["name"],
49-
'title' => $form["title"],
50-
'description' => $form["description"],
46+
include(ISPC_WEB_PATH."/$file/form/$form_file");
47+
return array( 'name' => $form['name'],
48+
'title' => $form['title'],
49+
'description' => $form['description'],
5150
'module_name' => $module_name,
52-
'bgcolor' => $bgcolor);
53-
//unset($form);
51+
'bgcolor' => $bgcolor
52+
);
5453
}
5554

5655
// lese Module aus
57-
$bgcolor = "#FFFFFF";
56+
$bgcolor = '#FFFFFF';
5857
$modules_list = array();
59-
$handle = @opendir($conf["rootpath"]."/web");
58+
$handle = @opendir(ISPC_WEB_PATH);
6059
while ($file = @readdir ($handle)) {
61-
if ($file != "." && $file != "..") {
62-
if(@is_dir($conf["rootpath"]."/web/".$file)) {
63-
if(is_file($conf["rootpath"]."/web/".$file."/lib/module.conf.php") and $file != 'login') {
64-
65-
if(@is_dir($conf["rootpath"]."/web/".$file."/form")) {
66-
$handle2 = opendir($conf["rootpath"]."/web/".$file."/form");
60+
if ($file != '.' && $file != '..') {
61+
if(@is_dir(ISPC_WEB_PATH."/$file")) {
62+
if(ISPC_WEB_PATH.'/'.$file.'/lib/module.conf.php') and $file != 'login') {
63+
if(@is_dir(ISPC_WEB_PATH."/$file/form")) {
64+
$handle2 = opendir(ISPC_WEB_PATH."/$file/form");
6765
while ($form_file = @readdir ($handle2)) {
6866
if (substr($form_file,0,1) != ".") {
69-
//echo $conf["rootpath"]."/web/".$file."/form/$form_file<br>";
70-
//include_once($conf["rootpath"]."/web/".$file."/form/$form_file");
67+
//echo ISPC_ROOT_PATH."/web/".$file."/form/$form_file<br>";
68+
//include_once(ISPC_ROOT_PATH."/web/".$file."/form/$form_file");
7169
// Farbwechsel
72-
$bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
73-
74-
$modules_list[] = getinfo($file,$form_file,$bgcolor);
75-
70+
$bgcolor = ($bgcolor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF';
71+
$modules_list[] = getinfo($file, $form_file, $bgcolor);
72+
7673
}
7774
}
7875
}
@@ -81,17 +78,15 @@ function getinfo($file,$form_file,$bgcolor) {
8178
}
8279
}
8380

81+
$app->tpl->setLoop('records', $modules_list);
8482

85-
$app->tpl->setLoop('records',$modules_list);
86-
87-
// loading language file
88-
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_form_list.lng";
83+
//* load language file
84+
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_form_list.lng';
8985
include($lng_file);
9086
$app->tpl->setVar($wb);
9187

9288
$app->tpl_defaults();
9389
$app->tpl->pparse();
9490

9591

96-
9792
?>

interface/web/designer/module_list.php

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,49 +30,45 @@
3030
require_once('../../lib/config.inc.php');
3131
require_once('../../lib/app.inc.php');
3232

33-
// Checking permissions for the module
34-
if(!stristr($_SESSION["s"]["user"]["modules"],$_SESSION["s"]["module"]["name"])) {
35-
header("Location: ../index.php");
33+
//* Check permissions for the module
34+
if(!stristr($_SESSION['s']['user']['modules'],$_SESSION['s']['module']['name'])) {
35+
header('Location: ../index.php');
3636
exit;
3737
}
3838

3939
$app->uses('tpl');
4040

41-
$app->tpl->newTemplate("form.tpl.htm");
41+
$app->tpl->newTemplate('form.tpl.htm');
4242
$app->tpl->setInclude('content_tpl','templates/module_list.htm');
4343

44-
// lese Module aus
45-
$bgcolor = "#FFFFFF";
44+
//* Pick out modules
45+
$bgcolor = '#FFFFFF';
4646
$modules_list = array();
47-
$handle = @opendir($conf["rootpath"]."/web");
47+
$handle = @opendir(ISPC_WEB_PATH);
4848
while ($file = @readdir ($handle)) {
49-
if ($file != "." && $file != "..") {
50-
if(@is_dir($conf["rootpath"]."/web/".$file)) {
51-
if(is_file($conf["rootpath"]."/web/".$file."/lib/module.conf.php") and $file != 'login') {
52-
include_once($conf["rootpath"]."/web/".$file."/lib/module.conf.php");
53-
54-
// Farbwechsel
55-
$bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
56-
57-
$modules_list[] = array( 'module' => $module["name"],
58-
'title' => $module["title"],
59-
'bgcolor' => $bgcolor);
49+
if ($file != '.' && $file != '..') {
50+
if(@is_dir(ISPC_WEB_PATH."/$file")) {
51+
if(is_file(ISPC_WEB_PATH."/$file/lib/module.conf.php") and $file != 'login') {
52+
include_once(ISPC_WEB_PATH."/$file/lib/module.conf.php");
53+
$bgcolor = ($bgcolor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF';
54+
$modules_list[] = array( 'module' => $module['name'],
55+
'title' => $module['title'],
56+
'bgcolor' => $bgcolor
57+
);
6058
}
6159
}
6260
}
6361
}
6462

65-
66-
$app->tpl->setLoop('records',$modules_list);
63+
$app->tpl->setLoop('records', $modules_list);
6764

6865
// loading language file
69-
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_module_list.lng";
66+
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_module_list.lng';
7067
include($lng_file);
7168
$app->tpl->setVar($wb);
7269

7370
$app->tpl_defaults();
7471
$app->tpl->pparse();
7572

7673

77-
7874
?>

0 commit comments

Comments
 (0)