-
Notifications
You must be signed in to change notification settings - Fork 221
/
action_recorder.php
214 lines (181 loc) · 9.48 KB
/
action_recorder.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
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2013 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
$file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
$directory_array = array();
if ($dir = @dir(DIR_FS_CATALOG_MODULES . 'action_recorder/')) {
while ($file = $dir->read()) {
if (!is_dir(DIR_FS_CATALOG_MODULES . 'action_recorder/' . $file)) {
if (substr($file, strrpos($file, '.')) == $file_extension) {
$directory_array[] = $file;
}
}
}
sort($directory_array);
$dir->close();
}
for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {
$file = $directory_array[$i];
if (file_exists(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/action_recorder/' . $file)) {
include(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/action_recorder/' . $file);
}
include(DIR_FS_CATALOG_MODULES . 'action_recorder/' . $file);
$class = substr($file, 0, strrpos($file, '.'));
if (tep_class_exists($class)) {
${$class} = new $class;
}
}
$modules_array = array();
$modules_list_array = array(array('id' => '', 'text' => TEXT_ALL_MODULES));
$modules_query = tep_db_query("select distinct module from " . TABLE_ACTION_RECORDER . " order by module");
while ($modules = tep_db_fetch_array($modules_query)) {
$modules_array[] = $modules['module'];
$modules_list_array[] = array('id' => $modules['module'],
'text' => (is_object(${$modules['module']}) ? ${$modules['module']}->title : $modules['module']));
}
$action = (isset($_GET['action']) ? $_GET['action'] : '');
if (tep_not_null($action)) {
switch ($action) {
case 'expire':
$expired_entries = 0;
if (isset($_GET['module']) && in_array($_GET['module'], $modules_array)) {
if (is_object(${$_GET['module']})) {
$expired_entries += ${$_GET['module']}->expireEntries();
} else {
$delete_query = tep_db_query("delete from " . TABLE_ACTION_RECORDER . " where module = '" . tep_db_input($_GET['module']) . "'");
$expired_entries += tep_db_affected_rows();
}
} else {
foreach ($modules_array as $module) {
if (is_object(${$module})) {
$expired_entries += ${$module}->expireEntries();
}
}
}
$messageStack->add_session(sprintf(SUCCESS_EXPIRED_ENTRIES, $expired_entries), 'success');
tep_redirect(tep_href_link(FILENAME_ACTION_RECORDER));
break;
}
}
require(DIR_WS_INCLUDES . 'template_top.php');
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2" height="40">
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
<td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="smallText" align="right">
<?php
echo tep_draw_form('search', FILENAME_ACTION_RECORDER, '', 'get');
echo TEXT_FILTER_SEARCH . ' ' . tep_draw_input_field('search');
echo tep_draw_hidden_field('module') . tep_hide_session_id() . '</form>';
?>
</td>
</tr>
<tr>
<td class="smallText" align="right">
<?php
echo tep_draw_form('filter', FILENAME_ACTION_RECORDER, '', 'get');
echo tep_draw_pull_down_menu('module', $modules_list_array, null, 'onchange="this.form.submit();"');
echo tep_draw_hidden_field('search') . tep_hide_session_id() . '</form>';
?>
</td>
</tr>
</table></td>
<td class="smallText" align="right"><?php echo tep_draw_button(IMAGE_DELETE, 'trash', tep_href_link(FILENAME_ACTION_RECORDER, 'action=expire' . (isset($_GET['module']) && in_array($_GET['module'], $modules_array) ? '&module=' . $_GET['module'] : '')), 'primary'); ?></td>
</tr>
</table></td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent" width="20"> </td>
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_MODULE; ?></td>
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMER; ?></td>
<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_DATE_ADDED; ?></td>
<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
</tr>
<?php
$filter = array();
if (isset($_GET['module']) && in_array($_GET['module'], $modules_array)) {
$filter[] = " module = '" . tep_db_input($_GET['module']) . "' ";
}
if (isset($_GET['search']) && !empty($_GET['search'])) {
$filter[] = " identifier like '%" . tep_db_input($_GET['search']) . "%' ";
}
$actions_query_raw = "select * from " . TABLE_ACTION_RECORDER . (!empty($filter) ? " where " . implode(" and ", $filter) : "") . " order by date_added desc";
$actions_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $actions_query_raw, $actions_query_numrows);
$actions_query = tep_db_query($actions_query_raw);
while ($actions = tep_db_fetch_array($actions_query)) {
$module = $actions['module'];
$module_title = $actions['module'];
if (is_object(${$module})) {
$module_title = ${$module}->title;
}
if ((!isset($_GET['aID']) || (isset($_GET['aID']) && ($_GET['aID'] == $actions['id']))) && !isset($aInfo)) {
$actions_extra_query = tep_db_query("select identifier from " . TABLE_ACTION_RECORDER . " where id = '" . (int)$actions['id'] . "'");
$actions_extra = tep_db_fetch_array($actions_extra_query);
$aInfo_array = array_merge($actions, $actions_extra, array('module' => $module_title));
$aInfo = new objectInfo($aInfo_array);
}
if ( (isset($aInfo) && is_object($aInfo)) && ($actions['id'] == $aInfo->id) ) {
echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">' . "\n";
} else {
echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_ACTION_RECORDER, tep_get_all_get_params(array('aID')) . 'aID=' . $actions['id']) . '\'">' . "\n";
}
?>
<td class="dataTableContent" align="center"><?php echo tep_image(DIR_WS_IMAGES . 'icons/' . (($actions['success'] == '1') ? 'tick.gif' : 'cross.gif')); ?></td>
<td class="dataTableContent"><?php echo $module_title; ?></td>
<td class="dataTableContent"><?php echo tep_output_string_protected($actions['user_name']) . ' [' . (int)$actions['user_id'] . ']'; ?></td>
<td class="dataTableContent" align="right"><?php echo tep_datetime_short($actions['date_added']); ?></td>
<td class="dataTableContent" align="right"><?php if ( (isset($aInfo) && is_object($aInfo)) && ($actions['id'] == $aInfo->id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_ACTION_RECORDER, tep_get_all_get_params(array('aID')) . 'aID=' . $actions['id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
</tr>
<?php
}
?>
<tr>
<td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText" valign="top"><?php echo $actions_split->display_count($actions_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_ENTRIES); ?></td>
<td class="smallText" align="right"><?php echo $actions_split->display_links($actions_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page'], (isset($_GET['module']) && in_array($_GET['module'], $modules_array) && is_object(${$_GET['module']}) ? 'module=' . $_GET['module'] : null) . '&' . (isset($_GET['search']) && !empty($_GET['search']) ? 'search=' . $_GET['search'] : null)); ?></td>
</tr>
</table></td>
</tr>
</table></td>
<?php
$heading = array();
$contents = array();
switch ($action) {
default:
if (isset($aInfo) && is_object($aInfo)) {
$heading[] = array('text' => '<strong>' . $aInfo->module . '</strong>');
$contents[] = array('text' => TEXT_INFO_IDENTIFIER . '<br /><br />' . (!empty($aInfo->identifier) ? '<a href="' . tep_href_link(FILENAME_ACTION_RECORDER, 'search=' . $aInfo->identifier) . '"><u>' . tep_output_string_protected($aInfo->identifier) . '</u></a>': '(empty)'));
$contents[] = array('text' => '<br />' . TEXT_INFO_DATE_ADDED . ' ' . tep_datetime_short($aInfo->date_added));
}
break;
}
if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
echo ' <td width="25%" valign="top">' . "\n";
$box = new box;
echo $box->infoBox($heading, $contents);
echo ' </td>' . "\n";
}
?>
</tr>
</table></td>
</tr>
</table>
<?php
require(DIR_WS_INCLUDES . 'template_bottom.php');
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>