-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions-log.php
278 lines (248 loc) · 11.6 KB
/
actions-log.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<?php
/**
* Show the list of activities logged.
*
* @package ProjectSend
* @subpackage Log
*
*/
$footable = 1;
$allowed_levels = array(9);
require_once('sys.includes.php');
$page_title = __('Recent activities log','cftp_admin');;
include('header.php');
?>
<script type="text/javascript">
$(document).ready( function() {
$("#do_action").click(function() {
var checks = $("td>input:checkbox").serializeArray();
var action = $('#log_actions').val();
if (action == 'delete') {
if (checks.length == 0) {
alert('<?php _e('Please select at least one activity to proceed.','cftp_admin'); ?>');
return false;
}
else {
var msg_1 = '<?php _e("You are about to delete",'cftp_admin'); ?>';
var msg_2 = '<?php _e("activities. Are you sure you want to continue?",'cftp_admin'); ?>';
if (confirm(msg_1+' '+checks.length+' '+msg_2)) {
return true;
} else {
return false;
}
}
}
if (action == 'clear') {
var msg = '<?php _e("You are about to delete all activities from the log. Only those used for statistics will remain. Are you sure you want to continue?",'cftp_admin'); ?>';
if (confirm(msg)) {
return true;
} else {
return false;
}
}
if (action == 'download') {
$(document).psendmodal();
$('.modal_content').html('<p class="loading-img">'+
'<img src="<?php echo BASE_URI; ?>img/ajax-loader.gif" alt="Loading" /></p>'+
'<p class="lead text-center text-info"><?php _e('Please wait while your download is prepared.','cftp_admin'); ?></p>'
);
$('.modal_content').append('<iframe src="<?php echo BASE_URI; ?>includes/actions.log.export.php?format=csv"></iframe>');
return false;
}
});
});
</script>
<div id="main">
<h2><?php echo $page_title; ?></h2>
<?php
/**
* Apply the corresponding action to the selected users.
*/
if(isset($_POST['log_actions']) && $_POST['log_actions'] != 'none') {
/** Continue only if 1 or more users were selected. */
switch($_POST['log_actions']) {
case 'delete':
$selected_actions = $_POST['activities'];
$deleted_actions = 0;
if(!empty($_POST['activities'])) {
foreach ($selected_actions as $selected_action) {
$del_sql = $database->query("DELETE FROM tbl_actions_log WHERE id='$selected_action'");
$deleted_actions++;
}
if ($deleted_actions > 0) {
$msg = __('The selected activities were deleted.','cftp_admin');
echo system_message('ok',$msg);
}
}
else {
$msg = __('Please select at least one activity.','cftp_admin');
echo system_message('error',$msg);
}
break;
case 'clear':
$keep = '5,8,9';
$del_sql = $database->query("DELETE FROM tbl_actions_log WHERE NOT (action IN ($keep))");
$msg = __('The log was cleared. Only data used for statistics remained. You can delete them manually if you want.','cftp_admin');
echo system_message('ok',$msg);
break;
}
}
$database->MySQLDB();
$cq = "SELECT * FROM tbl_actions_log";
/** Add the search terms */
if(isset($_POST['search']) && !empty($_POST['search'])) {
$search_terms = mysql_real_escape_string($_POST['search']);
$cq .= " WHERE (owner_user LIKE '%$search_terms%' OR affected_file_name LIKE '%$search_terms%' OR affected_account_name LIKE '%$search_terms%')";
$next_clause = ' AND';
$no_results_error = 'search';
}
else {
$next_clause = ' WHERE';
}
/** Add the activities filter */
if(isset($_POST['activity']) && $_POST['activity'] != 'all') {
$status_filter = $_POST['activity'];
$cq .= $next_clause. " action='$status_filter'";
$no_results_error = 'filter';
}
$cq .= " ORDER BY id DESC";
$sql = $database->query($cq);
$count = mysql_num_rows($sql);
?>
<div class="form_actions_left">
<div class="form_actions_limit_results">
<form action="actions-log.php" name="log_search" method="post" class="form-inline">
<input type="text" name="search" id="search" value="<?php if(isset($_POST['search']) && !empty($_POST['search'])) { echo $_POST['search']; } ?>" class="txtfield form_actions_search_box" />
<button type="submit" id="btn_proceed_search" class="btn btn-small"><?php _e('Search','cftp_admin'); ?></button>
</form>
<form action="actions-log.php" name="actions_filters" method="post" class="form-inline">
<select name="activity" id="activity" class="txtfield" style="width:360px;">
<option value="all"><?php _e('All activities','cftp_admin'); ?></option>
<option value="0"><?php _e('ProjecSend has been installed','cftp_admin'); ?></option>
<option value="1"><?php _e('Account logs in through the form','cftp_admin'); ?></option>
<option value="24"><?php _e('Account logs in through cookies','cftp_admin'); ?></option>
<option value="31"><?php _e('Account (user or client) logs out','cftp_admin'); ?></option>
<option value="2"><?php _e('A user creates a new user account','cftp_admin'); ?></option>
<option value="3"><?php _e('A user creates a new client account','cftp_admin'); ?></option>
<option value="4"><?php _e('A client registers an account for himself','cftp_admin'); ?></option>
<option value="5"><?php _e('A file is uploaded by an user','cftp_admin'); ?></option>
<option value="6"><?php _e('A file is uploaded by a client','cftp_admin'); ?></option>
<option value="7"><?php _e('A file is downloaded by a user (on "Client view" mode)','cftp_admin'); ?></option>
<option value="8"><?php _e('A file is downloaded by a client','cftp_admin'); ?></option>
<option value="9"><?php _e('A zip file was generated by a client','cftp_admin'); ?></option>
<option value="10"><?php _e('A file has been unassigned from a client.','cftp_admin'); ?></option>
<option value="11"><?php _e('A file has been unassigned from a group','cftp_admin'); ?></option>
<option value="12"><?php _e('A file has been deleted','cftp_admin'); ?></option>
<option value="13"><?php _e('A user was edited','cftp_admin'); ?></option>
<option value="14"><?php _e('A client was edited','cftp_admin'); ?></option>
<option value="15"><?php _e('A group was edited','cftp_admin'); ?></option>
<option value="16"><?php _e('A user was deleted','cftp_admin'); ?></option>
<option value="17"><?php _e('A client was deleted','cftp_admin'); ?></option>
<option value="18"><?php _e('A group was deleted','cftp_admin'); ?></option>
<option value="19"><?php _e('A client account was activated','cftp_admin'); ?></option>
<option value="20"><?php _e('A client account was deactivated','cftp_admin'); ?></option>
<option value="27"><?php _e('A user account was activated','cftp_admin'); ?></option>
<option value="28"><?php _e('A user account was deactivated','cftp_admin'); ?></option>
<option value="21"><?php _e('A file was marked as hidden','cftp_admin'); ?></option>
<option value="22"><?php _e('A file was marked as visible','cftp_admin'); ?></option>
<option value="23"><?php _e('A user creates a new group','cftp_admin'); ?></option>
<option value="25"><?php _e('A file is assigned to a client','cftp_admin'); ?></option>
<option value="26"><?php _e('A file is assigned to a group','cftp_admin'); ?></option>
<option value="27"><?php _e('A user account was marked as active','cftp_admin'); ?></option>
<option value="28"><?php _e('A user account was marked as inactive','cftp_admin'); ?></option>
<option value="29"><?php _e('The logo on "Branding" was changed','cftp_admin'); ?></option>
<option value="30"><?php _e('ProjectSend was updated','cftp_admin'); ?></option>
<option value="32"><?php _e('A system user edited a file.','cftp_admin'); ?></option>
<option value="33"><?php _e('A client edited a file.','cftp_admin'); ?></option>
</select>
<button type="submit" id="btn_proceed_filter_clients" class="btn btn-small"><?php _e('Filter','cftp_admin'); ?></button>
</form>
</div>
</div>
<form action="actions-log.php" name="actions_list" method="post" class="form-inline">
<div class="form_actions_right">
<div class="form_actions">
<div class="form_actions_submit">
<label><?php _e('Activities actions','cftp_admin'); ?>:</label>
<select name="log_actions" id="log_actions" class="txtfield">
<option value="none"><?php _e('Select action','cftp_admin'); ?></option>
<option value="download"><?php _e('Download as csv','cftp_admin'); ?></option>
<option value="delete"><?php _e('Delete selected','cftp_admin'); ?></option>
<option value="clear"><?php _e('Clear entire log','cftp_admin'); ?></option>
</select>
<button type="submit" id="do_action" name="proceed" class="btn btn-small"><?php _e('Proceed','cftp_admin'); ?></button>
</div>
</div>
</div>
<div class="clear"></div>
<div class="form_actions_count">
<p><?php _e('Showing','cftp_admin'); ?>: <span><?php echo $count; ?> <?php _e('activities','cftp_admin'); ?></span></p>
</div>
<div class="clear"></div>
<?php
if (!$count) {
if (isset($no_results_error)) {
switch ($no_results_error) {
case 'filter':
$no_results_message = __('The filters you selected returned no results.','cftp_admin');;
break;
}
}
else {
$no_results_message = __('There are no activities recorded.','cftp_admin');;
}
echo system_message('error',$no_results_message);
}
?>
<table id="activities_tbl" class="footable" data-page-size="<?php echo FOOTABLE_PAGING_NUMBER_LOG; ?>">
<thead>
<tr>
<th class="td_checkbox" data-sort-ignore="true">
<input type="checkbox" name="select_all" id="select_all" value="0" />
</th>
<th data-type="numeric" data-sort-initial="descending"><?php _e('Date','cftp_admin'); ?></th>
<th><?php _e('Author','cftp_admin'); ?></th>
<th data-hide="phone"><?php _e('Activity','cftp_admin'); ?></th>
<th data-hide="phone"> </th>
<th data-hide="phone"> </th>
<th data-hide="phone"> </th>
</tr>
</thead>
<tbody>
<?php
while($log = mysql_fetch_array($sql)) {
$this_action = render_log_action(
array(
'action' => $log['action'],
'timestamp' => $log['timestamp'],
'owner_id' => $log['owner_id'],
'owner_user' => $log['owner_user'],
'affected_file' => $log['affected_file'],
'affected_file_name' => $log['affected_file_name'],
'affected_account' => $log['affected_account'],
'affected_account_name' => $log['affected_account_name']
)
);
$date = date(TIMEFORMAT_USE,strtotime($log['timestamp']));
?>
<tr>
<td><input type="checkbox" name="activities[]" value="<?php echo $log["id"]; ?>" /></td>
<td data-value="<?php echo strtotime($log['timestamp']); ?>">
<?php echo $date; ?>
</td>
<td><?php echo (!empty($this_action["1"])) ? $this_action["1"] : ''; ?></td>
<td><?php echo $this_action["text"]; ?></td>
<td><?php echo (!empty($this_action["2"])) ? $this_action["2"] : ''; ?></td>
<td><?php echo (!empty($this_action["3"])) ? $this_action["3"] : ''; ?></td>
<td><?php echo (!empty($this_action["4"])) ? $this_action["4"] : ''; ?></td>
</tr>
<?php
}
$database->Close();
?>
</tbody>
</table>
<div class="pagination pagination-centered hide-if-no-paging"></div>
</form>
</div>
<?php include('footer.php'); ?>