1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
index.php
|
5
|
Copyright (C) 2004, 2005 Scott Ullrich
|
6
|
All rights reserved.
|
7
|
|
8
|
Originally part of m0n0wall (http://m0n0.ch/wall)
|
9
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10
|
All rights reserved.
|
11
|
|
12
|
Redistribution and use in source and binary forms, with or without
|
13
|
modification, are permitted provided that the following conditions are met:
|
14
|
|
15
|
1. Redistributions of source code must retain the above copyright notice,
|
16
|
this list of conditions and the following disclaimer.
|
17
|
|
18
|
2. Redistributions in binary form must reproduce the above copyright
|
19
|
notice, this list of conditions and the following disclaimer in the
|
20
|
documentation and/or other materials provided with the distribution.
|
21
|
|
22
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
23
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
24
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
26
|
oR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31
|
POSSIBILITY OF SUCH DAMAGE.
|
32
|
*/
|
33
|
|
34
|
## Load Essential Includes
|
35
|
require_once('guiconfig.inc');
|
36
|
require_once('notices.inc');
|
37
|
|
38
|
## Load Functions Files
|
39
|
require_once('includes/functions.inc.php');
|
40
|
|
41
|
|
42
|
## Load AJAX, Initiate Class ###############################################
|
43
|
require_once('includes/sajax.class.php');
|
44
|
|
45
|
## Initiate Class and Set location of ajax file containing
|
46
|
## the information that we need for this page. Also set functions
|
47
|
## that SAJAX will be using.
|
48
|
$oSajax = new sajax();
|
49
|
$oSajax->sajax_remote_uri = 'sajax/index.sajax.php';
|
50
|
$oSajax->sajax_request_type = 'POST';
|
51
|
$oSajax->sajax_export("get_stats");
|
52
|
$oSajax->sajax_handle_client_request();
|
53
|
############################################################################
|
54
|
|
55
|
|
56
|
## Check to see if we have a swap space,
|
57
|
## if true, display, if false, hide it ...
|
58
|
if(file_exists("/usr/sbin/swapinfo")) {
|
59
|
$swapinfo = `/usr/sbin/swapinfo`;
|
60
|
if(stristr($swapinfo,'%') == true) $showswap=true;
|
61
|
}
|
62
|
|
63
|
|
64
|
## User recently restored his config.
|
65
|
## If packages are installed lets resync
|
66
|
if(file_exists('/conf/needs_package_sync')) {
|
67
|
if($config['installedpackages'] <> '') {
|
68
|
conf_mount_rw();
|
69
|
unlink('/conf/needs_package_sync');
|
70
|
header('Location: pkg_mgr_install.php?mode=reinstallall');
|
71
|
exit;
|
72
|
}
|
73
|
}
|
74
|
|
75
|
|
76
|
## If it is the first time webConfigurator has been
|
77
|
## accessed since initial install show this stuff.
|
78
|
if(file_exists('/conf/trigger_initial_wizard')) {
|
79
|
|
80
|
$pgtitle = array("pfSense first time setup");
|
81
|
include('head.inc');
|
82
|
|
83
|
echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
|
84
|
echo "<form>\n";
|
85
|
echo "<center>\n";
|
86
|
echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\"><p>\n";
|
87
|
echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n";
|
88
|
echo "Welcome to pfSense!<p>\n";
|
89
|
echo "One moment while we start the initial setup wizard.<p>\n";
|
90
|
echo "Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal gui.<p>\n";
|
91
|
echo "To bypass the wizard, click on the pfSense wizard on the initial page.\n";
|
92
|
echo "</div>\n";
|
93
|
echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n";
|
94
|
echo "<script type=\"text/javascript\">\n";
|
95
|
echo "NiftyCheck();\n";
|
96
|
echo "Rounded(\"div#nifty\",\"all\",\"#000\",\"#FFFFFF\",\"smooth\");\n";
|
97
|
echo "</script>\n";
|
98
|
exit;
|
99
|
}
|
100
|
|
101
|
|
102
|
## Find out whether there's hardware encryption or not
|
103
|
unset($hwcrypto);
|
104
|
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
|
105
|
if ($fd) {
|
106
|
while (!feof($fd)) {
|
107
|
$dmesgl = fgets($fd);
|
108
|
if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)) {
|
109
|
$hwcrypto = $matches[1];
|
110
|
break;
|
111
|
}
|
112
|
}
|
113
|
fclose($fd);
|
114
|
}
|
115
|
|
116
|
//build list of widgets
|
117
|
$directory = "widgets/widgets/";
|
118
|
$dirhandle = opendir($directory);
|
119
|
$filename = "";
|
120
|
$widgetnames = array ();
|
121
|
$widgetfiles = array();
|
122
|
|
123
|
while (false !== ($filename = readdir($dirhandle))) {
|
124
|
$periodpos = strpos($filename, ".");
|
125
|
$widgetname = substr($filename, 0, $periodpos);
|
126
|
$widgetnames[] = $widgetname;
|
127
|
if ($widgetname != "system_information")
|
128
|
$widgetfiles[] = $filename;
|
129
|
}
|
130
|
sort($widgetfiles);
|
131
|
array_unshift($widgetfiles, "system_information.widget.php");
|
132
|
|
133
|
|
134
|
if (!is_array($config['widgets'])) {
|
135
|
$config['widgets'] = array();
|
136
|
}
|
137
|
|
138
|
$pconfig['sequence'] = $config['widgets']['sequence'];
|
139
|
|
140
|
if ($_POST){
|
141
|
$config['widgets']['sequence'] = $_POST['sequence'];
|
142
|
|
143
|
foreach ($widgetnames as $widget){
|
144
|
if ($_POST[$widget . '-config']){
|
145
|
$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
|
146
|
}
|
147
|
}
|
148
|
|
149
|
write_config();
|
150
|
header("Location: index.php");
|
151
|
exit;
|
152
|
}
|
153
|
|
154
|
|
155
|
if ($config['widgets'])
|
156
|
{
|
157
|
$widgetlist = $pconfig['sequence'];
|
158
|
|
159
|
$colpos = array();
|
160
|
$savedwidgetfiles = array();
|
161
|
$widgetname = "";
|
162
|
$widgetlist = explode(",",$widgetlist);
|
163
|
foreach ($widgetlist as $widget){
|
164
|
$dashpos = strpos($widget, "-");
|
165
|
$widgetname = substr($widget, 0, $dashpos);
|
166
|
$colposition = strpos($widget, ":");
|
167
|
$displayposition = strrpos($widget, ":");
|
168
|
$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1);
|
169
|
$displayarray[] = substr($widget,$displayposition+1);
|
170
|
$savedwidgetfiles[] = $widgetname . ".widget.php";
|
171
|
}
|
172
|
foreach ($widgetnames as $widget){
|
173
|
if ($config['widgets'][$widget . '-config']){
|
174
|
$pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
|
175
|
}
|
176
|
}
|
177
|
}
|
178
|
|
179
|
|
180
|
//build list of php include files
|
181
|
$phpincludefiles = Array();
|
182
|
$directory = "widgets/include/";
|
183
|
$dirhandle = opendir($directory);
|
184
|
$filename = "";
|
185
|
while (false !== ($filename = readdir($dirhandle))) {
|
186
|
$phpincludefiles[] = $filename;
|
187
|
}
|
188
|
foreach($phpincludefiles as $includename) {
|
189
|
if(!stristr($includename, ".inc"))
|
190
|
continue;
|
191
|
include($directory . $includename);
|
192
|
}
|
193
|
|
194
|
//function to create widget tabs when called
|
195
|
function display_widget_tabs(& $tab_array) {
|
196
|
echo "<div id='tabs'>";
|
197
|
$tabscounter = 0;
|
198
|
foreach ($tab_array as $ta) {
|
199
|
$dashpos = strpos($ta[2],'-');
|
200
|
$tabname = $ta[2] . "-tab";
|
201
|
$tabclass = substr($ta[2],0,$dashpos);
|
202
|
$tabclass = $tabclass . "-class";
|
203
|
if ($ta[1] == true) {
|
204
|
$tabActive = "table-cell";
|
205
|
$tabNonActive = "none";
|
206
|
}
|
207
|
else {
|
208
|
$tabActive = "none";
|
209
|
$tabNonActive = "table-cell";
|
210
|
}
|
211
|
echo "<div id='{$ta[2]}-active' class='{$tabclass}-tabactive' style='display:{$tabActive}; background-color:#EEEEEE; color:black;'>";
|
212
|
echo "<B> {$ta[0]}";
|
213
|
echo " </B>";
|
214
|
echo "</div>";
|
215
|
|
216
|
echo "<div id='{$ta[2]}-deactive' class='{$tabclass}-tabdeactive' style='display:{$tabNonActive}; background-color:#777777; color:white; cursor: pointer;' onClick=\"return changeTabDIV('{$ta[2]}')\">";
|
217
|
echo "<B> {$ta[0]}";
|
218
|
echo " </B>";
|
219
|
echo "</div>";
|
220
|
}
|
221
|
|
222
|
echo "<script type=\"text/javascript\">";
|
223
|
echo "NiftyCheck();\n";
|
224
|
echo "Rounded(\"div.{$tabclass}-tabactive\",\"top\",\"#CCCCCC\",\"#EEEEEE\",\"smooth\");\n";
|
225
|
echo "Rounded(\"div.{$tabclass}-tabdeactive\",\"top\",\"#CCCCCC\",\"#777777\",\"smooth\");\n";
|
226
|
echo "</script>";
|
227
|
echo "</div>";
|
228
|
}
|
229
|
|
230
|
$jscriptstr = <<<EOD
|
231
|
<script language="javascript" type="text/javascript">
|
232
|
|
233
|
function addDiv(selectedDiv){
|
234
|
selectedDiv = selectedDiv + "-div";
|
235
|
textlink = d.getElementById(selectedDiv);
|
236
|
if (textlink.style.display != "none")
|
237
|
{
|
238
|
Effect.Shake(selectedDiv);
|
239
|
}
|
240
|
else
|
241
|
{
|
242
|
Effect.Appear(selectedDiv, {duration:1});
|
243
|
d = document;
|
244
|
selectIntLink = selectedDiv + "-input";
|
245
|
textlink = d.getElementById(selectIntLink);
|
246
|
textlink.value = "show";
|
247
|
showSave();
|
248
|
}
|
249
|
}
|
250
|
|
251
|
function configureDiv(selectedDiv){
|
252
|
selectIntLink = selectedDiv + "-settings";
|
253
|
d = document;
|
254
|
textlink = d.getElementById(selectIntLink);
|
255
|
if (textlink.style.display == "none")
|
256
|
Effect.BlindDown(selectIntLink, {duration:1});
|
257
|
else
|
258
|
Effect.BlindUp(selectIntLink, {duration:1});
|
259
|
}
|
260
|
|
261
|
function showDiv(selectedDiv,swapButtons){
|
262
|
//appear element
|
263
|
Effect.BlindDown(selectedDiv, {duration:1});
|
264
|
showSave();
|
265
|
d = document;
|
266
|
if (swapButtons){
|
267
|
selectIntLink = selectedDiv + "-min";
|
268
|
textlink = d.getElementById(selectIntLink);
|
269
|
textlink.style.display = "inline";
|
270
|
|
271
|
|
272
|
selectIntLink = selectedDiv + "-open";
|
273
|
textlink = d.getElementById(selectIntLink);
|
274
|
textlink.style.display = "none";
|
275
|
|
276
|
}
|
277
|
selectIntLink = selectedDiv + "-div-input";
|
278
|
textlink = d.getElementById(selectIntLink);
|
279
|
textlink.value = "show";
|
280
|
|
281
|
}
|
282
|
|
283
|
function minimizeDiv(selectedDiv,swapButtons){
|
284
|
//fade element
|
285
|
Effect.BlindUp(selectedDiv, {duration:1});
|
286
|
showSave();
|
287
|
d = document;
|
288
|
if (swapButtons){
|
289
|
selectIntLink = selectedDiv + "-open";
|
290
|
textlink = d.getElementById(selectIntLink);
|
291
|
textlink.style.display = "inline";
|
292
|
|
293
|
selectIntLink = selectedDiv + "-min";
|
294
|
textlink = d.getElementById(selectIntLink);
|
295
|
textlink.style.display = "none";
|
296
|
}
|
297
|
selectIntLink = selectedDiv + "-div-input";
|
298
|
textlink = d.getElementById(selectIntLink);
|
299
|
textlink.value = "hide";
|
300
|
|
301
|
}
|
302
|
|
303
|
function closeDiv(selectedDiv){
|
304
|
showSave();
|
305
|
selectedDiv = selectedDiv + "-div";
|
306
|
Effect.Fade(selectedDiv, {duration:1});
|
307
|
d = document;
|
308
|
selectIntLink = selectedDiv + "-input";
|
309
|
textlink = d.getElementById(selectIntLink);
|
310
|
textlink.value = "close";
|
311
|
}
|
312
|
|
313
|
function showSave(){
|
314
|
d = document;
|
315
|
selectIntLink = "submit";
|
316
|
textlink = d.getElementById(selectIntLink);
|
317
|
textlink.style.display = "inline";
|
318
|
}
|
319
|
|
320
|
function updatePref(){
|
321
|
var widgets = document.getElementsByClassName('widgetdiv');
|
322
|
var widgetSequence = "";
|
323
|
var firstprint = false;
|
324
|
d = document;
|
325
|
for (i=0; i<widgets.length; i++){
|
326
|
if (firstprint)
|
327
|
widgetSequence += ",";
|
328
|
var widget = widgets[i].id;
|
329
|
widgetSequence += widget + ":" + widgets[i].parentNode.id + ":";
|
330
|
widget = widget + "-input";
|
331
|
textlink = d.getElementById(widget).value;
|
332
|
widgetSequence += textlink;
|
333
|
firstprint = true;
|
334
|
}
|
335
|
selectLink = "sequence";
|
336
|
textlink = d.getElementById(selectLink);
|
337
|
textlink.value = widgetSequence;
|
338
|
return true;
|
339
|
}
|
340
|
|
341
|
function hideAllWidgets(){
|
342
|
Effect.Fade('niftyOutter', {to: 0.2});
|
343
|
}
|
344
|
|
345
|
function showAllWidgets(){
|
346
|
Effect.Fade('niftyOutter', {to: 1.0});
|
347
|
}
|
348
|
|
349
|
|
350
|
function changeTabDIV(selectedDiv){
|
351
|
var dashpos = selectedDiv.indexOf("-");
|
352
|
var tabclass = selectedDiv.substring(0,dashpos);
|
353
|
d = document;
|
354
|
|
355
|
//get deactive tabs first
|
356
|
tabclass = tabclass + "-class-tabdeactive";
|
357
|
var tabs = document.getElementsByClassName(tabclass);
|
358
|
var incTabSelected = selectedDiv + "-deactive";
|
359
|
for (i=0; i<tabs.length; i++){
|
360
|
var tab = tabs[i].id;
|
361
|
dashpos = tab.lastIndexOf("-");
|
362
|
var tab2 = tab.substring(0,dashpos) + "-deactive";
|
363
|
if (tab2 == incTabSelected){
|
364
|
tablink = d.getElementById(tab2);
|
365
|
tablink.style.display = "none";
|
366
|
tab2 = tab.substring(0,dashpos) + "-active";
|
367
|
tablink = d.getElementById(tab2);
|
368
|
tablink.style.display = "table-cell";
|
369
|
|
370
|
//now show main div associated with link clicked
|
371
|
tabmain = d.getElementById(selectedDiv);
|
372
|
tabmain.style.display = "block";
|
373
|
}
|
374
|
else
|
375
|
{
|
376
|
tab2 = tab.substring(0,dashpos) + "-deactive";
|
377
|
tablink = d.getElementById(tab2);
|
378
|
tablink.style.display = "table-cell";
|
379
|
tab2 = tab.substring(0,dashpos) + "-active";
|
380
|
tablink = d.getElementById(tab2);
|
381
|
tablink.style.display = "none";
|
382
|
|
383
|
//hide sections we don't want to see
|
384
|
tab2 = tab.substring(0,dashpos);
|
385
|
tabmain = d.getElementById(tab2);
|
386
|
tabmain.style.display = "none";
|
387
|
|
388
|
}
|
389
|
}
|
390
|
}
|
391
|
|
392
|
</script>
|
393
|
EOD;
|
394
|
$closehead = false;
|
395
|
|
396
|
## Set Page Title and Include Header
|
397
|
$pgtitle = array("pfSense webConfigurator");
|
398
|
include("head.inc");
|
399
|
|
400
|
|
401
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
|
402
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
|
403
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
|
404
|
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
|
405
|
?>
|
406
|
|
407
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
408
|
<form action="index.php" method="post">
|
409
|
<script language="javascript" type="text/javascript">
|
410
|
// <![CDATA[
|
411
|
columns = ['col1','col2'];
|
412
|
// ]]>
|
413
|
|
414
|
</script>
|
415
|
|
416
|
|
417
|
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
|
418
|
<script src="/javascript/scriptaculous/scriptaculous.js" type="text/javascript"></script>
|
419
|
|
420
|
<?php
|
421
|
include("fbegin.inc");
|
422
|
echo $jscriptstr;
|
423
|
if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo"))
|
424
|
echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\"></center><br>";
|
425
|
?>
|
426
|
|
427
|
<?php
|
428
|
?>
|
429
|
<div id="widgetcontainer" style="display:none">
|
430
|
<div id="content1"><h1>Available Widgets</h1><p><?php
|
431
|
$widgetfiles_add = $widgetfiles;
|
432
|
sort($widgetfiles_add);
|
433
|
foreach($widgetfiles_add as $widget) {
|
434
|
if(!stristr($widget, "widget.php"))
|
435
|
continue;
|
436
|
|
437
|
$periodpos = strpos($widget, ".");
|
438
|
$widgetname = substr($widget, 0, $periodpos);
|
439
|
$nicename = $widgetname;
|
440
|
$nicename = str_replace("_", " ", $nicename);
|
441
|
//make the title look nice
|
442
|
$nicename = ucwords($nicename);
|
443
|
|
444
|
$widgettitle = $widgetname . "_title";
|
445
|
$widgettitlelink = $widgetname . "_title_link";
|
446
|
if ($$widgettitle != "")
|
447
|
{
|
448
|
//echo widget title
|
449
|
?>
|
450
|
<span style="cursor: pointer;" onclick='return addDiv("<?php echo $widgetname; ?>")'>
|
451
|
<u><?php echo $$widgettitle; ?></u></span><br>
|
452
|
<?php
|
453
|
}
|
454
|
else {?>
|
455
|
<span style="cursor: pointer;" onclick='return addDiv("<?php echo $widgetname; ?>")'>
|
456
|
<u><?php echo $nicename; ?></u></span><br><?php
|
457
|
}
|
458
|
}
|
459
|
?>
|
460
|
</p>
|
461
|
</div>
|
462
|
</div>
|
463
|
|
464
|
<div id="welcomecontainer" style="display:none">
|
465
|
<div id="welcome-div">
|
466
|
<h1>
|
467
|
<div style="float:left;width:80%;padding: 2px">
|
468
|
Welcome to the New Dashboard page!
|
469
|
</div>
|
470
|
<div onclick="domTT_close(this);showAllWidgets();" style="float:right;width:8%; cursor:pointer;padding: 5px;" >
|
471
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" />
|
472
|
</div>
|
473
|
<div style="clear:both;"></div>
|
474
|
</h1>
|
475
|
<p>
|
476
|
This page allows you to customize the information you want to be displayed!<br/>
|
477
|
To get started click the <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"> icon to add widgets.<br/>
|
478
|
<br/>
|
479
|
You can move any widget around by clicking and dragging the title.
|
480
|
</p>
|
481
|
</div>
|
482
|
</div>
|
483
|
|
484
|
|
485
|
|
486
|
<input type="hidden" value="" name="sequence" id="sequence">
|
487
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="Click here to add widgets" style="cursor: pointer;" onmouseup="domTT_activate(this, event, 'content', document.getElementById('content1'), 'type', 'velcro', 'delay', 0, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');" />
|
488
|
|
489
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_info_pkg.gif" alt="Click here for help" style="cursor: help;" onmouseup="hideAllWidgets();domTT_activate(this, event, 'content', document.getElementById('welcome-div'), 'type', 'sticky', 'closeLink', '','delay', 0, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');" />
|
490
|
|
491
|
|
492
|
|
493
|
<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="Save Settings" />
|
494
|
</p>
|
495
|
|
496
|
<div id="niftyOutter">
|
497
|
<?php
|
498
|
$totalwidgets = count($widgetfiles);
|
499
|
$halftotal = $totalwidgets / 2 -1;
|
500
|
$widgetcounter = 0;
|
501
|
$directory = "widgets/widgets/";
|
502
|
$printed = false;
|
503
|
$firstprint = false;
|
504
|
?>
|
505
|
<div id="col1" style="float:left;width:49%;padding: 2px;padding-bottom:40px">
|
506
|
<?php
|
507
|
|
508
|
if ($config['widgets']){
|
509
|
$widgetlist = $savedwidgetfiles;
|
510
|
|
511
|
//add widgets that may not be in the saved configuration, in case they want to be added later
|
512
|
foreach ($widgetfiles as $defaultwidgets){
|
513
|
|
514
|
if (!in_array($defaultwidgets, $savedwidgetfiles)){
|
515
|
$widgetlist[] = $defaultwidgets;
|
516
|
}
|
517
|
}
|
518
|
|
519
|
}
|
520
|
else
|
521
|
$widgetlist = $widgetfiles;
|
522
|
|
523
|
foreach($widgetlist as $widget) {
|
524
|
|
525
|
if(!stristr($widget, "widget.php"))
|
526
|
continue;
|
527
|
|
528
|
$periodpos = strpos($widget, ".");
|
529
|
$widgetname = substr($widget, 0, $periodpos);
|
530
|
if ($widgetname != ""){
|
531
|
$nicename = $widgetname;
|
532
|
$nicename = str_replace("_", " ", $nicename);
|
533
|
|
534
|
//make the title look nice
|
535
|
$nicename = ucwords($nicename);
|
536
|
|
537
|
if ($config['widgets']){
|
538
|
if ($displayarray[$widgetcounter] == "show"){
|
539
|
$divdisplay = "block";
|
540
|
$display = "block";
|
541
|
$inputdisplay = "show";
|
542
|
$showdiv = "none";
|
543
|
$mindiv = "inline";
|
544
|
}
|
545
|
else if ($displayarray[$widgetcounter] == "hide") {
|
546
|
$divdisplay = "block";
|
547
|
$display = "none";
|
548
|
$inputdisplay = "hide";
|
549
|
$showdiv = "inline";
|
550
|
$mindiv = "none";
|
551
|
}
|
552
|
else if ($displayarray[$widgetcounter] == "close"){
|
553
|
$divdisplay = "none";
|
554
|
$display = "block";
|
555
|
$inputdisplay = "close";
|
556
|
$showdiv = "none";
|
557
|
$mindiv = "inline";
|
558
|
}
|
559
|
else{
|
560
|
$divdisplay = "none";
|
561
|
$display = "block";
|
562
|
$inputdisplay = "none";
|
563
|
$showdiv = "none";
|
564
|
$mindiv = "inline";
|
565
|
}
|
566
|
}
|
567
|
else
|
568
|
{
|
569
|
if ($firstprint == false){
|
570
|
$divdisplay = "block";
|
571
|
$display = "block";
|
572
|
$inputdisplay = "show";
|
573
|
$showdiv = "none";
|
574
|
$mindiv = "inline";
|
575
|
$firstprint = true;
|
576
|
}
|
577
|
else
|
578
|
{
|
579
|
$divdisplay = "none";
|
580
|
$display = "block";
|
581
|
$inputdisplay = "close";
|
582
|
$showdiv = "none";
|
583
|
$mindiv = "inline";
|
584
|
}
|
585
|
}
|
586
|
|
587
|
|
588
|
if ($config['widgets']){
|
589
|
if ($colpos[$widgetcounter] == "col2" && $printed == false)
|
590
|
{
|
591
|
$printed = true;
|
592
|
?>
|
593
|
</div>
|
594
|
<div id="col2" style="float:right;width:49%;padding: 2px;padding-bottom:40px">
|
595
|
<?php
|
596
|
}
|
597
|
}
|
598
|
else if ($widgetcounter >= $halftotal && $printed == false){
|
599
|
$printed = true;
|
600
|
?>
|
601
|
</div>
|
602
|
<div id="col2" style="float:right;width:49%;padding: 2px;padding-bottom:40px">
|
603
|
<?php
|
604
|
}
|
605
|
|
606
|
?>
|
607
|
<div style="clear:both;"></div>
|
608
|
<div id="<?php echo $widgetname;?>-div" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
|
609
|
<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-div-input" name="<?php echo $widgetname;?>-div-input">
|
610
|
<div id="<?php echo $widgetname;?>topic" class="widgetheader" style="cursor:move">
|
611
|
<div style="float:left;">
|
612
|
<?php
|
613
|
|
614
|
$widgettitle = $widgetname . "_title";
|
615
|
$widgettitlelink = $widgetname . "_title_link";
|
616
|
if ($$widgettitle != "")
|
617
|
{
|
618
|
//only show link if defined
|
619
|
if ($$widgettitlelink != "") {?>
|
620
|
<u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
|
621
|
<?php }
|
622
|
//echo widget title
|
623
|
echo $$widgettitle;
|
624
|
if ($$widgettitlelink != "") { ?>
|
625
|
</span></u>
|
626
|
<?php }
|
627
|
}
|
628
|
else{
|
629
|
if ($$widgettitlelink != "") {?>
|
630
|
<u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
|
631
|
<?php }
|
632
|
echo $nicename;
|
633
|
if ($$widgettitlelink != "") { ?>
|
634
|
</span></u>
|
635
|
<?php }
|
636
|
}
|
637
|
?>
|
638
|
</div>
|
639
|
<div align="right" style="float:right;">
|
640
|
<div id="<?php echo $widgetname;?>-configure" onclick='return configureDiv("<?php echo $widgetname;?>")' style="display:none; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_configure.gif" /></div>
|
641
|
<div id="<?php echo $widgetname;?>-open" onclick='return showDiv("<?php echo $widgetname;?>",true)' style="display:<?php echo $showdiv;?>; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_open.gif" /></div>
|
642
|
<div id="<?php echo $widgetname;?>-min" onclick='return minimizeDiv("<?php echo $widgetname;?>",true)' style="display:<?php echo $mindiv;?>; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_minus.gif"/></div>
|
643
|
<div id="<?php echo $widgetname;?>-close" onclick='return closeDiv("<?php echo $widgetname;?>",true)' style="display:inline; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" /></div>
|
644
|
</div>
|
645
|
<div style="clear:both;"></div>
|
646
|
</div>
|
647
|
<div id="<?php echo $widgetname;?>" style="display:<?php echo $display; ?>;">
|
648
|
<?php
|
649
|
if (file_exists($directory . $widget))
|
650
|
{
|
651
|
include($directory . $widget);
|
652
|
}
|
653
|
else
|
654
|
{
|
655
|
echo "Widget does not exists in the widget folder. <br>Please reinstall the dashboard package to correct this issue.";
|
656
|
}
|
657
|
?>
|
658
|
</div>
|
659
|
<div style="clear:both;"></div>
|
660
|
</div>
|
661
|
<?php
|
662
|
$widgetcounter++;
|
663
|
}
|
664
|
}//end foreach
|
665
|
?>
|
666
|
</div><!-- end col -->
|
667
|
<?php if ($printed == false){
|
668
|
$printed = true;
|
669
|
?>
|
670
|
</div>
|
671
|
<div id="col2" style="float:right;width:49%;padding: 2px;padding-bottom:40px"></div>
|
672
|
|
673
|
<?php } ?>
|
674
|
<div style="clear:both;"></div>
|
675
|
</div>
|
676
|
|
677
|
|
678
|
|
679
|
<?php include("fend.inc"); ?>
|
680
|
|
681
|
<script type="text/javascript">
|
682
|
|
683
|
<?php if (!$config['widgets']){ ?>
|
684
|
window.onload = function(in_event)
|
685
|
{
|
686
|
hideAllWidgets();
|
687
|
domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-div'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');
|
688
|
}
|
689
|
<?php } ?>
|
690
|
// <![CDATA[
|
691
|
Sortable.create("col1", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});
|
692
|
Sortable.create("col2", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});
|
693
|
// ]]>
|
694
|
|
695
|
<?php
|
696
|
//build list of javascript include files
|
697
|
$jsincludefiles = array();
|
698
|
$directory = "widgets/javascript/";
|
699
|
$dirhandle = opendir($directory);
|
700
|
$filename = "";
|
701
|
while (false !== ($filename = readdir($dirhandle))) {
|
702
|
$jsincludefiles[] = $filename;
|
703
|
}
|
704
|
foreach($jsincludefiles as $jsincludename) {
|
705
|
if(!stristr($jsincludename, ".js"))
|
706
|
continue;
|
707
|
include($directory . $jsincludename);
|
708
|
}
|
709
|
?>
|
710
|
</script>
|
711
|
</form>
|
712
|
</body>
|
713
|
</html>
|