1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category module
|
5
|
* @package droplet
|
6
|
* @author Ruud Eisinga (Ruud) John (PCWacht)
|
7
|
* @author WebsiteBaker Project
|
8
|
* @copyright 2004-2009, Ryan Djurovich
|
9
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
10
|
* @link http://www.websitebaker2.org/
|
11
|
* @license http://www.gnu.org/licenses/gpl.html
|
12
|
* @platform WebsiteBaker 2.8.x
|
13
|
* @requirements PHP 5.2.2 and higher
|
14
|
* @version $Id: tool.php 1543 2011-12-14 00:13:54Z Luisehahne $
|
15
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/droplets/tool.php $
|
16
|
* @lastmodified $Date: 2011-12-14 01:13:54 +0100 (Wed, 14 Dec 2011) $
|
17
|
*
|
18
|
*/
|
19
|
/* -------------------------------------------------------- */
|
20
|
// Must include code to stop this file being accessed directly
|
21
|
if(!defined('WB_PATH')) {
|
22
|
|
23
|
require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
|
24
|
throw new IllegalFileException();
|
25
|
}
|
26
|
/* -------------------------------------------------------- */
|
27
|
|
28
|
$msg = array();
|
29
|
// Load Language file
|
30
|
if(LANGUAGE_LOADED) {
|
31
|
if(!file_exists(WB_PATH.'/modules/droplets/languages/'.LANGUAGE.'.php')) {
|
32
|
require_once(WB_PATH.'/modules/droplets/languages/EN.php');
|
33
|
} else {
|
34
|
require_once(WB_PATH.'/modules/droplets/languages/'.LANGUAGE.'.php');
|
35
|
}
|
36
|
}
|
37
|
|
38
|
// check if backend.css file needs to be included into the <body></body>
|
39
|
if(!method_exists($admin, 'register_backend_modfiles') && file_exists(WB_PATH .'/modules/droplets/backend.css')) {
|
40
|
echo '<style type="text/css">';
|
41
|
include(WB_PATH .'/modules/droplets/backend.css');
|
42
|
echo "\n</style>\n";
|
43
|
}
|
44
|
|
45
|
// Get userid for showing admin only droplets or not
|
46
|
$loggedin_user = ($admin->ami_group_member('1') ? 1 : $admin->user_id());
|
47
|
$loggedin_group = $admin->get_groups_id();
|
48
|
$admin_user = ( ($admin->get_home_folder() == '') && ($admin->ami_group_member('1') ) || ($loggedin_user == '1'));
|
49
|
|
50
|
// And... action
|
51
|
$admintool_url = ADMIN_URL .'/admintools/index.php';
|
52
|
|
53
|
//removes empty entries from the table so they will not be displayed
|
54
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'mod_droplets` ';
|
55
|
$sql .= 'WHERE name = \'\' ';
|
56
|
if( !$database->query($sql) ) {
|
57
|
$msg[] = $database->get_error();
|
58
|
}
|
59
|
// if import failed after installation, should be only 1 time
|
60
|
$sql = 'SELECT COUNT(`id`) FROM `'.TABLE_PREFIX.'mod_droplets` ';
|
61
|
if( !$database->get_one($sql) ) {
|
62
|
include('install.php');
|
63
|
}
|
64
|
?><br />
|
65
|
<table summary="" cellpadding="0" cellspacing="0" border="0" width="100%">
|
66
|
<tr>
|
67
|
<td valign="bottom" width="50%">
|
68
|
<button class="add" type="button" name="add_droplet" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/droplets/add_droplet.php';"><?php echo $TEXT['ADD'].' '.$DR_TEXT['DROPLETS']; ?></button>
|
69
|
</td>
|
70
|
<!-- commentet out the droplets logo for a more similar backend design with other admin tools
|
71
|
<td align="center"><img src="<?php /*echo WB_URL;*/ ?>/modules/droplets/img/droplets_logo.png" border="1" alt=""/></td>
|
72
|
-->
|
73
|
<td valign="top" width="50%" align="right">
|
74
|
<a href="#" onclick="javascript: window.open('<?php echo WB_URL; ?>/modules/droplets/readme/<?php echo $DR_TEXT['README']; ?>','helpwindow','width=700,height=550,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');"><?php echo $DR_TEXT['HELP']; ?></a>
|
75
|
<br /><br />
|
76
|
<a href="#" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/droplets/backup_droplets.php?id=<?php echo $admin->getIDKEY(999); ?>'"><?php echo $DR_TEXT['BACKUP']; ?></a>
|
77
|
</td>
|
78
|
</tr>
|
79
|
</table>
|
80
|
<br />
|
81
|
|
82
|
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$DR_TEXT['DROPLETS']; ?></h2>
|
83
|
<?php
|
84
|
|
85
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_droplets` ';
|
86
|
if (!$admin_user) {
|
87
|
$sql .= 'WHERE `admin_view` <> 1 ';
|
88
|
}
|
89
|
$sql .= 'ORDER BY `modified_when` DESC';
|
90
|
$query_droplets = $database->query($sql);
|
91
|
$num_droplets = $query_droplets->numRows();
|
92
|
if($num_droplets > 0) {
|
93
|
?>
|
94
|
<table summary="" class="row_a" border="0" cellspacing="0" cellpadding="3" width="100%">
|
95
|
<thead>
|
96
|
<tr>
|
97
|
<td width="3%"></td>
|
98
|
<td width="21%"><?php echo $TEXT['NAME']; ?></td>
|
99
|
<td width="68%"><?php echo $TEXT['DESCRIPTION']; ?></td>
|
100
|
<td width="4%"><?php echo $TEXT['ACTIVE']; ?></td>
|
101
|
<td width="3%"></td>
|
102
|
</tr>
|
103
|
</thead>
|
104
|
<?php
|
105
|
$row = 'a';
|
106
|
while($droplet = $query_droplets->fetchRow()) {
|
107
|
$get_modified_user = $database->query("SELECT display_name,username, user_id FROM ".TABLE_PREFIX."users WHERE user_id = '".$droplet['modified_by']."' LIMIT 1");
|
108
|
if($get_modified_user->numRows() > 0) {
|
109
|
$fetch_modified_user = $get_modified_user->fetchRow();
|
110
|
$modified_user = $fetch_modified_user['username'];
|
111
|
$modified_userid = $fetch_modified_user['user_id'];
|
112
|
} else {
|
113
|
$modified_user = $TEXT['UNKNOWN'];
|
114
|
$modified_userid = 0;
|
115
|
}
|
116
|
$iDropletIdKey = $admin->getIDKEY($droplet['id']);
|
117
|
$comments = str_replace(array("\r\n", "\n", "\r"), '<br />', $droplet['comments']);
|
118
|
if (!strpos($comments,"[[")) $comments = "Use: [[".$droplet['name']."]]<br />".$comments;
|
119
|
$comments = str_replace(array("[[", "]]"), array('<b>[[',']]</b>'), $comments);
|
120
|
$valid_code = check_syntax($droplet['code']);
|
121
|
if (!$valid_code === true) $comments = '<font color=\'red\'><strong>'.$DR_TEXT['INVALIDCODE'].'</strong></font><br /><br />'.$comments;
|
122
|
$unique_droplet = check_unique ($droplet['name']);
|
123
|
if ($unique_droplet === false ) {$comments = '<font color=\'red\'><strong>'.$DR_TEXT['NOTUNIQUE'].'</strong></font><br /><br />'.$comments;}
|
124
|
$comments = '<span>'.$comments.'</span>';
|
125
|
?>
|
126
|
|
127
|
<tr class="row_<?php echo $row; ?>" >
|
128
|
<td >
|
129
|
<a href="<?php echo WB_URL; ?>/modules/droplets/modify_droplet.php?droplet_id=<?php echo $iDropletIdKey; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
|
130
|
<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="Modify" />
|
131
|
</a>
|
132
|
</td>
|
133
|
<td >
|
134
|
<a href="<?php echo WB_URL; ?>/modules/droplets/modify_droplet.php?droplet_id=<?php echo $iDropletIdKey; ?>" class="tooltip">
|
135
|
<?php if ($valid_code && $unique_droplet) { ?><img src="<?php echo WB_URL; ?>/modules/droplets/img/droplet.png" border="0" alt=""/>
|
136
|
<?php } else { ?><img src="<?php echo WB_URL; ?>/modules/droplets/img/invalid.gif" border="0" title="" alt=""/><?php } ?>
|
137
|
<?php echo $droplet['name']; ?><?php echo $comments; ?>
|
138
|
</a>
|
139
|
</td>
|
140
|
<td >
|
141
|
<small><?php echo substr($droplet['description'],0,90); ?></small>
|
142
|
</td>
|
143
|
<td >
|
144
|
<b><?php if($droplet['active'] == 1){ echo '<span style="color: green;">'. $TEXT['YES']. '</span>'; } else { echo '<span style="color: red;">'.$TEXT['NO'].'</span>'; } ?></b>
|
145
|
</td>
|
146
|
<td >
|
147
|
<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/droplets/delete_droplet.php?droplet_id=<?php echo $iDropletIdKey; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
|
148
|
<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
|
149
|
</a>
|
150
|
</td>
|
151
|
</tr>
|
152
|
<?php
|
153
|
// Alternate row color
|
154
|
if($row == 'a') {
|
155
|
$row = 'b';
|
156
|
} else {
|
157
|
$row = 'a';
|
158
|
}
|
159
|
}
|
160
|
?>
|
161
|
</table>
|
162
|
<?php
|
163
|
}
|
164
|
|
165
|
function check_syntax($code) {
|
166
|
return @eval('return true;' . $code);
|
167
|
}
|
168
|
|
169
|
function check_unique($name) {
|
170
|
global $database;
|
171
|
$retVal = 0;
|
172
|
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'mod_droplets` ';
|
173
|
$sql .= 'WHERE `name` = \''.$name.'\'';
|
174
|
$retVal = intval($database->get_one($sql));
|
175
|
return ($retVal == 1);
|
176
|
}
|