Project

General

Profile

1 1420 Luisehahne
<?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$
15
 * @filesource		$HeadURL$
16
 * @lastmodified    $Date$
17
 *
18
 */
19 1503 Luisehahne
/* -------------------------------------------------------- */
20
// Must include code to stop this file being accessed directly
21
if(!defined('WB_PATH')) {
22 1420 Luisehahne
23 1503 Luisehahne
	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
24
	throw new IllegalFileException();
25
}
26
/* -------------------------------------------------------- */
27 1420 Luisehahne
28 1543 Luisehahne
$msg = array();
29 1420 Luisehahne
// 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 1503 Luisehahne
$loggedin_user = ($admin->ami_group_member('1') ? 1 : $admin->user_id());
47 1457 Luisehahne
$loggedin_group = $admin->get_groups_id();
48
$admin_user = ( ($admin->get_home_folder() == '') && ($admin->ami_group_member('1') ) || ($loggedin_user == '1'));
49
50 1420 Luisehahne
// 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 1543 Luisehahne
$sql = 'DELETE FROM `'.TABLE_PREFIX.'mod_droplets` ';
55 1503 Luisehahne
$sql .= 'WHERE name = \'\' ';
56 1543 Luisehahne
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 1457 Luisehahne
<table summary="" cellpadding="0" cellspacing="0" border="0" width="100%">
66 1420 Luisehahne
<tr>
67
	<td valign="bottom" width="50%">
68 1543 Luisehahne
		<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 1420 Luisehahne
	</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 1457 Luisehahne
		<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 1420 Luisehahne
	</td>
78
</tr>
79
</table>
80
<br />
81
82
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$DR_TEXT['DROPLETS']; ?></h2>
83
<?php
84 1503 Luisehahne
85
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_droplets` ';
86
if (!$admin_user) {
87
	$sql .= 'WHERE `admin_view` <> 1 ';
88 1420 Luisehahne
}
89 1503 Luisehahne
$sql .= 'ORDER BY `modified_when` DESC';
90
$query_droplets = $database->query($sql);
91 1420 Luisehahne
$num_droplets = $query_droplets->numRows();
92
if($num_droplets > 0) {
93
	?>
94 1658 darkviper
	<table summary="" class="row_0" border="0" cellspacing="0" cellpadding="3" width="100%">
95 1420 Luisehahne
	<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 1658 darkviper
	$row = 0;
106 1420 Luisehahne
	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 1503 Luisehahne
        $iDropletIdKey = $admin->getIDKEY($droplet['id']);
117 1420 Luisehahne
		$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 1503 Luisehahne
		if ($unique_droplet === false ) {$comments = '<font color=\'red\'><strong>'.$DR_TEXT['NOTUNIQUE'].'</strong></font><br /><br />'.$comments;}
124 1420 Luisehahne
		$comments = '<span>'.$comments.'</span>';
125
		?>
126 1503 Luisehahne
127 1420 Luisehahne
		<tr class="row_<?php echo $row; ?>" >
128
			<td >
129 1503 Luisehahne
				<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 1420 Luisehahne
				</a>
132
			</td>
133
			<td >
134 1503 Luisehahne
				<a href="<?php echo WB_URL; ?>/modules/droplets/modify_droplet.php?droplet_id=<?php echo $iDropletIdKey; ?>" class="tooltip">
135 1420 Luisehahne
							<?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 1503 Luisehahne
				<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 1420 Luisehahne
					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
149
				</a>
150
			</td>
151
		</tr>
152
		<?php
153 1658 darkviper
		// Alternate row color (toggle between 0 and 1)
154
		$row = ++$row & 1;
155 1420 Luisehahne
	}
156
	?>
157
	</table>
158
	<?php
159
}
160
161
function check_syntax($code) {
162
    return @eval('return true;' . $code);
163
}
164
165
function check_unique($name) {
166
	global $database;
167 1503 Luisehahne
	$retVal = 0;
168
	$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'mod_droplets` ';
169
	$sql .= 'WHERE `name` = \''.$name.'\'';
170
	$retVal = intval($database->get_one($sql));
171
	return ($retVal == 1);
172 1420 Luisehahne
}