commit | author | age
|
2db42a
|
1 |
<?php |
V |
2 |
/* |
|
3 |
Copyright (c) 2010 Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com |
|
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 |
|
b1a6a5
|
30 |
require_once '../../lib/config.inc.php'; |
MC |
31 |
require_once '../../lib/app.inc.php'; |
2db42a
|
32 |
|
V |
33 |
//* Check permissions for module |
|
34 |
$app->auth->check_module_permissions('dashboard'); |
|
35 |
|
|
36 |
//* Loading Template |
|
37 |
$app->uses('tpl'); |
|
38 |
$app->tpl->newTemplate("templates/dashboard.htm"); |
|
39 |
|
|
40 |
//* load language file |
|
41 |
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'.lng'; |
b1a6a5
|
42 |
include $lng_file; |
2db42a
|
43 |
$app->tpl->setVar($wb); |
V |
44 |
|
|
45 |
//* set Default - Values |
|
46 |
$app->tpl_defaults(); |
|
47 |
|
|
48 |
/* |
|
49 |
* Let the user welcome |
|
50 |
*/ |
be7c43
|
51 |
if($_SESSION['s']['user']['typ'] == 'admin') { |
T |
52 |
$name = $_SESSION['s']['user']['username']; |
|
53 |
} else { |
cc7a82
|
54 |
$tmp = $app->db->queryOneRecord("SELECT contact_name FROM client WHERE username = ?", $_SESSION['s']['user']['username']); |
be7c43
|
55 |
$name = $tmp['contact_name']; |
T |
56 |
} |
|
57 |
|
bfcdef
|
58 |
$welcome = sprintf($wb['welcome_user_txt'], htmlentities($name, ENT_QUOTES, 'UTF-8')); |
2db42a
|
59 |
$app->tpl->setVar('welcome_user', $welcome); |
V |
60 |
|
|
61 |
|
|
62 |
/* |
|
63 |
* ToDo: Display errors, warnings and hints |
|
64 |
*/ |
|
65 |
///* |
|
66 |
// * If there is any error to display, do it... |
|
67 |
//*/ |
|
68 |
//$error = array(); |
|
69 |
// |
|
70 |
//$error[] = array('error_msg' => 'EClaus1'); |
|
71 |
//$error[] = array('error_msg' => 'EEClaus2'); |
|
72 |
//$error[] = array('error_msg' => 'EClaus3'); |
|
73 |
//$error[] = array('error_msg' => 'EClaus4'); |
|
74 |
// |
|
75 |
//$app->tpl->setloop('error', $error); |
|
76 |
// |
|
77 |
///* |
|
78 |
// * If there is any warning to display, do it... |
|
79 |
//*/ |
|
80 |
//$warning = array(); |
|
81 |
// |
|
82 |
//$warning[] = array('warning_msg' => 'WClaus1'); |
|
83 |
//$warning[] = array('warning_msg' => 'WWClaus2'); |
|
84 |
//$warning[] = array('warning_msg' => 'WClaus3'); |
|
85 |
//$warning[] = array('warning_msg' => 'WClaus4'); |
|
86 |
// |
|
87 |
//$app->tpl->setloop('warning', $warning); |
|
88 |
// |
26759e
|
89 |
|
V |
90 |
|
|
91 |
/* |
|
92 |
* If there is any information to display, do it... |
|
93 |
*/ |
|
94 |
$info = array(); |
|
95 |
|
5715f5
|
96 |
if(isset($_SESSION['show_info_msg'])) { |
b1a6a5
|
97 |
$info[] = array('info_msg' => '<p>'.$_SESSION['show_info_msg'].'</p>'); |
MC |
98 |
unset($_SESSION['show_info_msg']); |
5715f5
|
99 |
} |
M |
100 |
if(isset($_SESSION['show_error_msg'])) { |
b1a6a5
|
101 |
$app->tpl->setloop('error', array(array('error_msg' => '<p>'.$_SESSION['show_error_msg'].'</p>'))); |
MC |
102 |
unset($_SESSION['show_error_msg']); |
5715f5
|
103 |
} |
M |
104 |
|
|
105 |
|
26759e
|
106 |
/* |
05d482
|
107 |
* Check the ISPConfig-Version (only for the admin) |
26759e
|
108 |
*/ |
05d482
|
109 |
if($_SESSION["s"]["user"]["typ"] == 'admin') { |
3335f3
|
110 |
if(!isset($_SESSION['s']['new_ispconfig_version'])) { |
T |
111 |
$new_version = @file_get_contents('http://www.ispconfig.org/downloads/ispconfig3_version.txt'); |
|
112 |
$_SESSION['s']['new_ispconfig_version'] = trim($new_version); |
|
113 |
} |
3ed450
|
114 |
$v1 = ISPC_APP_VERSION; |
3335f3
|
115 |
$v2 = $_SESSION['s']['new_ispconfig_version']; |
b1a6a5
|
116 |
$this_version = explode(".", $v1); |
e88a7a
|
117 |
/* |
fb3a98
|
118 |
$this_fullversion = (($this_version[0] < 10) ? '0'.$this_version[0] : $this_version[0]) . |
edf806
|
119 |
((isset($this_version[1]) && $this_version[1] < 10) ? '0'.$this_version[1] : $this_version[1]) . |
T |
120 |
((isset($this_version[2]) && $this_version[2] < 10) ? '0'.$this_version[2] : $this_version[2]) . |
8cf78b
|
121 |
((isset($this_version[3]) && $this_version[3] < 10) ? (($this_version[3] < 1) ? '00' : '0'.$this_version[3]) : @$this_version[3]); |
fb3a98
|
122 |
|
e88a7a
|
123 |
*/ |
b1a6a5
|
124 |
|
MC |
125 |
$new_version = explode(".", $v2); |
e88a7a
|
126 |
/* |
fb3a98
|
127 |
$new_fullversion = (($new_version[0] < 10) ? '0'.$new_version[0] : $new_version[0]) . |
edf806
|
128 |
((isset($new_version[1]) && $new_version[1] < 10) ? '0'.$new_version[1] : $new_version[1]) . |
T |
129 |
((isset($new_version[2]) && $new_version[2] < 10) ? '0'.$new_version[2] : $new_version[2]) . |
8cf78b
|
130 |
((isset($new_version[3]) && $new_version[3] < 10) ? (($new_version[3] < 1) ? '00' : '0'.$new_version[3]) : @$new_version[3]); |
e88a7a
|
131 |
*/ |
b1a6a5
|
132 |
|
MC |
133 |
$this_fullversion = str_pad($this_version[0], 2, '0', STR_PAD_LEFT).str_pad($this_version[1], 2, '0', STR_PAD_LEFT).@str_pad($this_version[2], 2, '0', STR_PAD_LEFT).@str_pad($this_version[3], 2, '0', STR_PAD_LEFT); |
|
134 |
$new_fullversion = str_pad($new_version[0], 2, '0', STR_PAD_LEFT).str_pad($new_version[1], 2, '0', STR_PAD_LEFT).@str_pad($new_version[2], 2, '0', STR_PAD_LEFT).@str_pad($new_version[3], 2, '0', STR_PAD_LEFT); |
fb3a98
|
135 |
if($new_fullversion > $this_fullversion) { |
b1a6a5
|
136 |
$info[] = array('info_msg' => '<p>There is a new Version of ISPConfig 3 available!</p>' . |
MC |
137 |
'<p>This Version: <b>' . $v1 . '</b></p>' . |
f6bcfe
|
138 |
'<p>New Version : <b>' . $v2 . '</b></p>' . |
d2270c
|
139 |
'<p><a href="http://www.ispconfig.org/ispconfig-3/download" target="ISPC">See more...</a></p>'); |
05d482
|
140 |
} |
26759e
|
141 |
} |
V |
142 |
|
|
143 |
$app->tpl->setloop('info', $info); |
2db42a
|
144 |
|
c71060
|
145 |
/* Load the dashlets*/ |
T |
146 |
$dashlet_list = array(); |
b1a6a5
|
147 |
$handle = @opendir(ISPC_WEB_PATH.'/dashboard/dashlets'); |
MC |
148 |
while ($file = @readdir($handle)) { |
a563d5
|
149 |
if ($file != '.' && $file != '..' && !is_dir(ISPC_WEB_PATH.'/dashboard/dashlets/'.$file)) { |
b1a6a5
|
150 |
$dashlet_name = substr($file, 0, -4); |
c71060
|
151 |
$dashlet_class = 'dashlet_'.$dashlet_name; |
b1a6a5
|
152 |
include_once ISPC_WEB_PATH.'/dashboard/dashlets/'.$file; |
c71060
|
153 |
$dashlet_list[$dashlet_name] = new $dashlet_class; |
2db42a
|
154 |
} |
V |
155 |
} |
|
156 |
|
c71060
|
157 |
|
T |
158 |
/* Which dashlets in which column */ |
|
159 |
/******************************************************************************/ |
e9a084
|
160 |
$default_leftcol_dashlets = array('modules', 'invoices', 'quota', 'mailquota', 'databasequota'); |
15b651
|
161 |
$default_rightcol_dashlets = array('customer', 'products', 'shop', 'limits'); |
7b47c0
|
162 |
|
T |
163 |
$app->uses('getconf'); |
|
164 |
$dashlets_config = $app->getconf->get_global_config('misc'); |
|
165 |
//* Client: If the logged in user is not admin and has no sub clients (no reseller) |
|
166 |
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
|
167 |
$role = 'client'; |
b1a6a5
|
168 |
//* Reseller: If the logged in user is not admin and has sub clients (is a reseller) |
7b47c0
|
169 |
} elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
T |
170 |
$role = 'reseller'; |
b1a6a5
|
171 |
//* Admin: If the logged in user is admin |
7b47c0
|
172 |
} else { |
T |
173 |
$role = 'admin'; |
|
174 |
} |
|
175 |
$dashlets_config[$role.'_dashlets_left'] = trim($dashlets_config[$role.'_dashlets_left']); |
|
176 |
$dashlets_config[$role.'_dashlets_right'] = trim($dashlets_config[$role.'_dashlets_right']); |
|
177 |
|
|
178 |
if($dashlets_config[$role.'_dashlets_left'] != ''){ |
|
179 |
preg_match_all('@\[(.*?)\]@', $dashlets_config[$role.'_dashlets_left'], $matches); |
b1a6a5
|
180 |
$leftcol_dashlets = $matches[1]; |
7b47c0
|
181 |
} else { |
T |
182 |
$leftcol_dashlets = $default_leftcol_dashlets; |
|
183 |
} |
|
184 |
if($dashlets_config[$role.'_dashlets_right'] != ''){ |
|
185 |
preg_match_all('@\[(.*?)\]@', $dashlets_config[$role.'_dashlets_right'], $matches); |
|
186 |
$rightcol_dashlets = $matches[1]; |
|
187 |
} else { |
|
188 |
$rightcol_dashlets = $default_rightcol_dashlets; |
|
189 |
} |
c71060
|
190 |
/******************************************************************************/ |
T |
191 |
|
|
192 |
|
|
193 |
/* Fill the left column */ |
|
194 |
$leftcol = array(); |
|
195 |
foreach($leftcol_dashlets as $name) { |
|
196 |
if(isset($dashlet_list[$name])) { |
|
197 |
$leftcol[]['content'] = $dashlet_list[$name]->show(); |
|
198 |
} |
|
199 |
} |
|
200 |
$app->tpl->setloop('leftcol', $leftcol); |
|
201 |
|
|
202 |
/* Fill the right columnn */ |
|
203 |
$rightcol = array(); |
|
204 |
foreach($rightcol_dashlets as $name) { |
|
205 |
if(isset($dashlet_list[$name])) { |
|
206 |
$rightcol[]['content'] = $dashlet_list[$name]->show(); |
|
207 |
} |
|
208 |
} |
|
209 |
$app->tpl->setloop('rightcol', $rightcol); |
|
210 |
|
|
211 |
|
2db42a
|
212 |
//* Do Output |
V |
213 |
$app->tpl->pparse(); |
|
214 |
|
b1a6a5
|
215 |
?> |