Project

General

Profile

1 989 aldus
<?php
2 1296 Luisehahne
/**
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 1349 Luisehahne
 * @copyright       2009-2011, Website Baker Org. e.V.
10 1296 Luisehahne
 * @link			http://www.websitebaker2.org/
11
 * @license         http://www.gnu.org/licenses/gpl.html
12
 * @platform        WebsiteBaker 2.8.x
13 1349 Luisehahne
 * @requirements    PHP 5.2.2 and higher
14 1296 Luisehahne
 * @version         $Id$
15
 * @filesource		$HeadURL$
16
 * @lastmodified    $Date$
17
 *
18
 */
19 991 Ruebenwurz
20 989 aldus
// Direct access prevention
21
defined('WB_PATH') OR die(header('Location: ../index.php'));
22
23
// Load Language file
24
if(LANGUAGE_LOADED) {
25
	if(!file_exists(WB_PATH.'/modules/droplets/languages/'.LANGUAGE.'.php')) {
26
		require_once(WB_PATH.'/modules/droplets/languages/EN.php');
27
	} else {
28
		require_once(WB_PATH.'/modules/droplets/languages/'.LANGUAGE.'.php');
29
	}
30
}
31
32
// check if backend.css file needs to be included into the <body></body>
33
if(!method_exists($admin, 'register_backend_modfiles') && file_exists(WB_PATH .'/modules/droplets/backend.css')) {
34
	echo '<style type="text/css">';
35
	include(WB_PATH .'/modules/droplets/backend.css');
36
	echo "\n</style>\n";
37
}
38
39
// Get userid for showing admin only droplets or not
40
$loggedin_user = $admin->get_user_id();
41
42
// And... action
43
$admintool_url = ADMIN_URL .'/admintools/index.php';
44
45
//removes empty entries from the table so they will not be displayed
46
$database->query("DELETE FROM ".TABLE_PREFIX."mod_droplets WHERE name=''");
47
?>
48
49
<br />
50
<table cellpadding="0" cellspacing="0" border="0" width="100%">
51
<tr>
52 1122 Ruebenwurz
	<td valign="bottom" width="50%">
53 989 aldus
		<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>
54
	</td>
55 1122 Ruebenwurz
	<!-- commentet out the droplets logo for a more similar backend design with other admin tools
56
	<td align="center"><img src="<?php /*echo WB_URL;*/ ?>/modules/droplets/img/droplets_logo.png" border="1" alt=""/></td>
57
	-->
58
	<td valign="top" width="50%" align="right">
59 989 aldus
		<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>
60
		<br /><br />
61
		<a href="#" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/droplets/backup_droplets.php';"><?php echo $DR_TEXT['BACKUP']; ?></a>
62
	</td>
63
</tr>
64
</table>
65
<br />
66
67
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$DR_TEXT['DROPLETS']; ?></h2>
68
<?php
69
if ($loggedin_user == '1') {
70
	$query_droplets = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_droplets ORDER BY modified_when DESC");
71
} else {
72
	$query_droplets = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_droplets WHERE admin_view <> '1' ORDER BY modified_when DESC");
73
}
74
$num_droplets = $query_droplets->numRows();
75
if($num_droplets > 0) {
76
	?>
77
	<table class="row_a" border="0" cellspacing="0" cellpadding="3" width="100%">
78 1069 Ruebenwurz
	<thead>
79
		<tr>
80 989 aldus
			<td width="3%"></td>
81
			<td width="21%"><?php echo $TEXT['NAME']; ?></td>
82
			<td width="68%"><?php echo $TEXT['DESCRIPTION']; ?></td>
83 1069 Ruebenwurz
			<td width="4%"><?php echo $TEXT['ACTIVE']; ?></td>
84 989 aldus
			<td width="3%"></td>
85 1069 Ruebenwurz
		</tr>
86
	</thead>
87 989 aldus
	<?php
88
	$row = 'a';
89
	while($droplet = $query_droplets->fetchRow()) {
90
		$get_modified_user = $database->query("SELECT display_name,username, user_id FROM ".TABLE_PREFIX."users WHERE user_id = '".$droplet['modified_by']."' LIMIT 1");
91
		if($get_modified_user->numRows() > 0) {
92
			$fetch_modified_user = $get_modified_user->fetchRow();
93
			$modified_user = $fetch_modified_user['username'];
94
			$modified_userid = $fetch_modified_user['user_id'];
95
		} else {
96
			$modified_user = $TEXT['UNKNOWN'];
97
			$modified_userid = 0;
98
		}
99
		$comments = str_replace(array("\r\n", "\n", "\r"), '<br />', $droplet['comments']);
100
		if (!strpos($comments,"[[")) $comments = "Use: [[".$droplet['name']."]]<br />".$comments;
101
		$comments = str_replace(array("[[", "]]"), array('<b>[[',']]</b>'), $comments);
102
		$valid_code = check_syntax($droplet['code']);
103
		if (!$valid_code === true) $comments = '<font color=\'red\'><strong>'.$DR_TEXT['INVALIDCODE'].'</strong></font><br /><br />'.$comments;
104
		$unique_droplet = check_unique ($droplet['name']);
105
		if ($unique_droplet === false) $comments = '<font color=\'red\'><strong>'.$DR_TEXT['NOTUNIQUE'].'</strong></font><br /><br />'.$comments;
106
		$comments = '<span>'.$comments.'</span>';
107
		?>
108
109 1069 Ruebenwurz
		<tr class="row_<?php echo $row; ?>" >
110 989 aldus
			<td >
111
				<a href="<?php echo WB_URL; ?>/modules/droplets/modify_droplet.php?droplet_id=<?php echo $droplet['id']?>" title="<?php echo $TEXT['MODIFY']; ?>">
112
					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="Modify" />
113
				</a>
114
			</td>
115
			<td >
116
				<a href="<?php echo WB_URL; ?>/modules/droplets/modify_droplet.php?droplet_id=<?php echo $droplet['id']?>" class="tooltip">
117
							<?php if ($valid_code && $unique_droplet) { ?><img src="<?php echo WB_URL; ?>/modules/droplets/img/droplet.png" border="0" alt=""/>
118
							<?php } else {  ?><img src="<?php echo WB_URL; ?>/modules/droplets/img/invalid.gif" border="0" title="" alt=""/><?php }  ?>
119
					<?php echo $droplet['name']; ?><?php echo $comments; ?>
120
				</a>
121
			</td>
122
			<td >
123
				<small><?php echo substr($droplet['description'],0,90); ?></small>
124
			</td>
125
			<td >
126
				<b><?php if($droplet['active'] == 1){ echo '<span style="color: green;">'. $TEXT['YES']. '</span>'; } else { echo '<span style="color: red;">'.$TEXT['NO'].'</span>';  } ?></b>
127
			</td>
128
			<td >
129
				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/droplets/delete_droplet.php?droplet_id=<?php echo $droplet['id']?>');" title="<?php echo $TEXT['DELETE']; ?>">
130
					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
131
				</a>
132
			</td>
133
		</tr>
134
		<?php
135
		// Alternate row color
136
		if($row == 'a') {
137
			$row = 'b';
138
		} else {
139
			$row = 'a';
140
		}
141
	}
142
	?>
143
	</table>
144
	<?php
145
}
146
147
function check_syntax($code) {
148
    return @eval('return true;' . $code);
149
}
150
151
function check_unique($name) {
152
	global $database;
153
	$query_droplets = $database->query("SELECT name FROM ".TABLE_PREFIX."mod_droplets WHERE name = '$name'");
154
	return ($query_droplets->numRows() == 1);
155
}
156
?>