| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | require_once(dirname(dirname(__FILE__))."/plog-load-config.php"); |
|---|
| 4 | require(PLOGGER_DIR."plog-admin/plog-admin.php"); |
|---|
| 5 | |
|---|
| 6 | global $inHead; |
|---|
| 7 | |
|---|
| 8 | $inHead = '<script type="text/javascript" src="'.$config['gallery_url'].'plog-admin/js/ajax_editing.js"></script>'; |
|---|
| 9 | |
|---|
| 10 | $output = "\n\t" . '<h1>'. plog_tr("Manage Feedback") . '</h1>' . "\n"; |
|---|
| 11 | |
|---|
| 12 | if (isset($_REQUEST['action'])) { |
|---|
| 13 | if ($_REQUEST['action'] == "approve-delete") { |
|---|
| 14 | |
|---|
| 15 | $num_items = 0; |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | if (isset($_REQUEST['delete_checked'])) { |
|---|
| 19 | if (isset($_REQUEST['selected'])) { |
|---|
| 20 | foreach($_REQUEST['selected'] as $del_id) { |
|---|
| 21 | |
|---|
| 22 | $del_id = intval($del_id); |
|---|
| 23 | |
|---|
| 24 | $query = "DELETE FROM ".TABLE_PREFIX."comments WHERE `id`= '".$del_id."'"; |
|---|
| 25 | $result = run_query($query); |
|---|
| 26 | |
|---|
| 27 | $num_items++; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | $output .= "\n\t".'<p class="actions">'.sprintf(plog_tr('You have deleted %d comment(s) successfully.'),$num_items).'</p>'; |
|---|
| 31 | |
|---|
| 32 | } else{ |
|---|
| 33 | $output .= "\n\t".'<p class="errors">'.plog_tr('Nothing selected to delete!').'</p>'; |
|---|
| 34 | } |
|---|
| 35 | } else if (isset($_REQUEST['approve_checked'])) { |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | if (isset($_REQUEST['selected'])) { |
|---|
| 39 | foreach($_REQUEST['selected'] as $appr_id) { |
|---|
| 40 | |
|---|
| 41 | $appr_id = intval($appr_id); |
|---|
| 42 | |
|---|
| 43 | $query = "UPDATE ".TABLE_PREFIX."comments SET `approved` = 1 WHERE `id`= '".$appr_id."'"; |
|---|
| 44 | $result = run_query($query); |
|---|
| 45 | |
|---|
| 46 | $num_items++; |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | $output .= "\n\t<p class=\"actions\">" . sprintf(plog_tr('You have approved %d comment(s) successfully.'),$num_items) . "</p>"; |
|---|
| 50 | } else { |
|---|
| 51 | $output .= "\n\t<p class=\"errors\">". plog_tr('Nothing selected to approve!') . "</p>"; |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | } else if ($_REQUEST['action'] == "edit-comment") { |
|---|
| 55 | |
|---|
| 56 | $output .= plog_edit_comment_form($_REQUEST['pid']); |
|---|
| 57 | $edit_page = 1; |
|---|
| 58 | } else if ($_REQUEST['action'] == "update-comment") { |
|---|
| 59 | if (!isset($_REQUEST['cancel'])) { |
|---|
| 60 | |
|---|
| 61 | $result = update_comment($_POST['pid'],$_POST['author'],$_POST['email'],$_POST['url'],$_POST['comment']); |
|---|
| 62 | if (isset($result['errors'])) { |
|---|
| 63 | $output .= "\n\t" . '<p class="errors">' . $result['errors'] . '</p>'; |
|---|
| 64 | } else if (isset($result['output'])) { |
|---|
| 65 | $output .= "\n\t" . '<p class="actions">' . $result['output'] . '</p>'; |
|---|
| 66 | } |
|---|
| 67 | } |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | if (!isset($edit_page)) { |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | if (isset($_REQUEST['entries_per_page'])) { |
|---|
| 78 | $_SESSION['entries_per_page'] = $_REQUEST['entries_per_page']; |
|---|
| 79 | } else if (!isset($_SESSION['entries_per_page'])){ |
|---|
| 80 | $_SESSION['entries_per_page'] = 20; |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | $plog_page = isset($_REQUEST['plog_page']) ? $_REQUEST['plog_page'] : 1; |
|---|
| 84 | |
|---|
| 85 | $first_item = ($plog_page - 1) * $_SESSION['entries_per_page']; |
|---|
| 86 | if ($first_item < 0) { |
|---|
| 87 | $first_item = 0; |
|---|
| 88 | } |
|---|
| 89 | $limit = "LIMIT ".$first_item.", ".$_SESSION['entries_per_page']; |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | $recordCount = "SELECT count(*) AS num_comments FROM ".TABLE_PREFIX."comments WHERE `approved` = 1"; |
|---|
| 93 | $totalRowsResult = mysql_query($recordCount); |
|---|
| 94 | $num_comments = mysql_result($totalRowsResult,"num_comments"); |
|---|
| 95 | |
|---|
| 96 | $query = "SELECT COUNT(*) as in_moderation from ".TABLE_PREFIX."comments WHERE `approved` = 0"; |
|---|
| 97 | $mod_result = run_query($query); |
|---|
| 98 | $num_comments_im = mysql_result($mod_result, "in_moderation"); |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | if (isset($_REQUEST['moderate']) && $_REQUEST['moderate'] == 1) { |
|---|
| 102 | $approved = 0; |
|---|
| 103 | $moderate = 1; |
|---|
| 104 | } else { |
|---|
| 105 | $approved = 1; |
|---|
| 106 | $moderate = 0; |
|---|
| 107 | } |
|---|
| 108 | $output .= "\n\t\t" . '<form id="contentList" action="'.$_SERVER['PHP_SELF'].'?moderate='.$moderate.'" method="post">'; |
|---|
| 109 | |
|---|
| 110 | if ($approved) { |
|---|
| 111 | $pagination_menu = generate_pagination("admin", "feedback", $plog_page, $num_comments, $_SESSION['entries_per_page']); |
|---|
| 112 | } else { |
|---|
| 113 | $pagination_menu = generate_pagination("admin", "feedback", $plog_page, $num_comments_im, $_SESSION['entries_per_page'], array("moderate" => 1)); |
|---|
| 114 | } |
|---|
| 115 | $pagination_menu = "\n\t\t" . '<div class="pagination">'.$pagination_menu.'</div>'; |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | $query = "SELECT *, UNIX_TIMESTAMP(`date`) AS `unix_date` from ".TABLE_PREFIX."comments WHERE `approved` = ".$approved." ORDER BY `id` DESC ".$limit; |
|---|
| 119 | $result = run_query($query); |
|---|
| 120 | |
|---|
| 121 | if (mysql_num_rows($result) > 0) { |
|---|
| 122 | $output .= "\n\t\t" . '<script type="text/javascript">'; |
|---|
| 123 | $output .= "\n\t\t\tEvent.observe(window, 'load', init, false);"; |
|---|
| 124 | $output .= "\n\t\t\tfunction init() {"; |
|---|
| 125 | |
|---|
| 126 | while($row = mysql_fetch_assoc($result)) { |
|---|
| 127 | $output .= "\n\t\t\tmakeEditable('comment-comment-".$row['id']."'); |
|---|
| 128 | makeEditable('comment-author-".$row['id']."'); |
|---|
| 129 | makeEditable('comment-url-".$row['id']."'); |
|---|
| 130 | makeEditable('comment-email-".$row['id']."');"; |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | $output .= "\n\t\t\t}"; |
|---|
| 134 | $output .= "\n\t\t</script>"; |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | $query = "SELECT *, UNIX_TIMESTAMP(`date`) AS `unix_date` from ".TABLE_PREFIX."comments WHERE `approved` = ".$approved." ORDER BY `id` DESC ".$limit; |
|---|
| 138 | $result = run_query($query); |
|---|
| 139 | |
|---|
| 140 | $empty = 0; |
|---|
| 141 | $allowedCommentKeys = array("unix_date", "author", "email", "url", "comment"); |
|---|
| 142 | if ($result) { |
|---|
| 143 | if (mysql_num_rows($result) == 0) { |
|---|
| 144 | if ($approved) { |
|---|
| 145 | $output .= "\n\t\t" . '<p class="actions">' . plog_tr('You have no user comments on your gallery.') . '</p>'; |
|---|
| 146 | } else { |
|---|
| 147 | $output .= "\n\t\t" . '<p class="actions">' . plog_tr('You have no comments waiting for approval.') . '</p>'; |
|---|
| 148 | } |
|---|
| 149 | $empty = 1; |
|---|
| 150 | } |
|---|
| 151 | if ($approved) { |
|---|
| 152 | if ($num_comments_im > 0) { |
|---|
| 153 | $output.= "\n\t\t" . '<p class="actions">' . sprintf(plog_tr('You have %d comment(s) waiting for approval.'),$num_comments_im) . ' <a href="plog-feedback.php?moderate=1">' . plog_tr('Click here') . '</a> to review and approve/delete the moderated comment(s).</p>'; |
|---|
| 154 | } |
|---|
| 155 | } |
|---|
| 156 | |
|---|
| 157 | $counter = 0; |
|---|
| 158 | $allowedCommentKeys = array("unix_date", "author", "email", "url", "comment"); |
|---|
| 159 | |
|---|
| 160 | $output .= "\n\n\t\t" . '<div class="entries-page">'.generate_pagination_view_menu().' |
|---|
| 161 | </div>' . "\n"; |
|---|
| 162 | |
|---|
| 163 | if (!$empty) { $output .= $pagination_menu; } |
|---|
| 164 | |
|---|
| 165 | while($row = mysql_fetch_assoc($result)) { |
|---|
| 166 | |
|---|
| 167 | if ($counter == 0) { |
|---|
| 168 | if ($approved) { |
|---|
| 169 | |
|---|
| 170 | $output .= "\n\n\t\t" . '<div id="comment-count">' . sprintf(plog_tr('You have <strong>%d</strong> user comment(s).'),$num_comments) . '</div>'; |
|---|
| 171 | |
|---|
| 172 | } else { |
|---|
| 173 | |
|---|
| 174 | $output .= "\n\n\t\t" . '<div id="comment-count">' . sprintf(plog_tr('You have <strong>%d</strong> user comment(s) awaiting approval.'),$num_comments_im) . '</div>'; |
|---|
| 175 | |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | $output .= "\n\n\t\t" . '<table style="width: 100%;" cellpadding="4"> |
|---|
| 179 | <tr class="header"> |
|---|
| 180 | <th class="table-header-left"></th> |
|---|
| 181 | <th class="table-header-middle">' . plog_tr('Thumb') . '</th>'; |
|---|
| 182 | |
|---|
| 183 | foreach ($row as $name => $value) { |
|---|
| 184 | if (in_array($name, $allowedCommentKeys)) { |
|---|
| 185 | $output .= "\n\t\t\t\t<th class=\"table-header-middle\">". plog_tr(ucfirst($name)) ."</th>"; |
|---|
| 186 | } |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | $output .= "\n\t\t\t\t" . '<th class="table-header-right">' . plog_tr('Actions') . '</th> |
|---|
| 190 | </tr>'; |
|---|
| 191 | } |
|---|
| 192 | |
|---|
| 193 | if ($counter%2 == 0) { |
|---|
| 194 | $table_row_color = "color-1"; |
|---|
| 195 | } else { |
|---|
| 196 | $table_row_color = "color-2"; |
|---|
| 197 | } |
|---|
| 198 | |
|---|
| 199 | |
|---|
| 200 | $output .= "\n\t\t\t".'<tr class="'.$table_row_color.'">'; |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | $output .= "\n\t\t\t\t" . '<td><input type="checkbox" name="selected[]" value="'.$row['id'].'" /></td>'; |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | $picture = get_picture_by_id($row['parent_id']); |
|---|
| 207 | $thumbpath = generate_thumb($picture['path'], $picture['id'], THUMB_SMALL); |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | $imgtag = '<img src="'.$thumbpath.'" title="'.$picture['caption'].'" alt="'.$picture['caption'].'" />'; |
|---|
| 211 | $output .= "\n\t\t\t\t" . '<td><div class="img-shadow"><a href="'.generate_thumb($picture['path'], $picture['id'], THUMB_LARGE).'" rel="lightbox" title="'.plogger_get_picture_caption().'">'.$imgtag.'</a></div></td>'; |
|---|
| 212 | |
|---|
| 213 | foreach ($row as $key => $value) { |
|---|
| 214 | $value = SmartStripSlashes(htmlspecialchars($value)); |
|---|
| 215 | if ($value == '') { |
|---|
| 216 | $value = ' '; |
|---|
| 217 | } |
|---|
| 218 | |
|---|
| 219 | if ($key == "unix_date") { |
|---|
| 220 | $output .= "\n\t\t\t\t" . '<td>'.date($config['date_format'], $value).'</td>'; |
|---|
| 221 | } else if ($key == "allow_comments") { |
|---|
| 222 | if ($value) { |
|---|
| 223 | $output .= "\n\t\t\t\t<td>". plog_tr('Yes') . "</td>"; |
|---|
| 224 | } else { |
|---|
| 225 | $output .= "\n\t\t\t\t<td>" . plog_tr('No') . "</td>"; |
|---|
| 226 | } |
|---|
| 227 | } |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | |
|---|
| 231 | else { |
|---|
| 232 | if (in_array($key, $allowedCommentKeys)) |
|---|
| 233 | $output .= "\n\t\t\t\t".'<td><p id="comment-'.$key.'-'.$row['id'].'">'.$value.'</p></td>'; |
|---|
| 234 | } |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | $query = "?action=edit-comment&pid=$row[id]"; |
|---|
| 239 | $output .= "\n\t\t\t\t" . '<td> |
|---|
| 240 | <div style="text-align: center;"> |
|---|
| 241 | <a href="'.$_SERVER['PHP_SELF'].$query.'&entries_per_page='.$_SESSION['entries_per_page'].'&moderate='.$moderate.'"><img src="'.$config['gallery_url'].'plog-admin/images/edit.gif" alt="'.plog_tr('Edit').'" title="'.plog_tr('Edit').'" /></a> |
|---|
| 242 | <a href="'.$_SERVER['PHP_SELF'].'?action=approve-delete&delete_checked=1&selected[]='.$row['id'].'&moderate='.$moderate.'" onclick="return confirm(\'' . plog_tr('Are you sure you want to delete this comment?') . '\');"><img src="'.$config['gallery_url'].'plog-admin/images/x.gif" alt="'.plog_tr('Delete').'" title="'.plog_tr('Delete').'" /></a>'; |
|---|
| 243 | |
|---|
| 244 | if (!$approved){ |
|---|
| 245 | $output .= "\n\t\t\t\t\t\t".' <a href="'.$_SERVER['PHP_SELF'].'?action=approve-delete&approve_checked=1&selected[]='.$row['id'].'&moderate=1" onclick="return confirm(\''.plog_tr('Are you sure you want to approve this comment?').'\');"><img src="'.$config['gallery_url'].'plog-admin/images/new_file.gif" alt="'.plog_tr('Approve').'" title="'.plog_tr('Approve').'" /></a>'; |
|---|
| 246 | } |
|---|
| 247 | |
|---|
| 248 | $output .= "\n\t\t\t\t\t</div>\n\t\t\t\t</td>\n\t\t\t</tr>"; |
|---|
| 249 | $counter++; |
|---|
| 250 | } |
|---|
| 251 | |
|---|
| 252 | if ($counter > 0) { |
|---|
| 253 | $output .= "\n\t\t\t" . '<tr class="footer"> |
|---|
| 254 | <td colspan="9"></td> |
|---|
| 255 | </tr> |
|---|
| 256 | </table>'; |
|---|
| 257 | } |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | if (!$empty) { |
|---|
| 261 | $output .= "\n\n\t\t" . '<div class="invert-selection"><a href="#" onclick="checkAll(document.getElementById(\'contentList\')); return false;">' . plog_tr('Invert Checkbox Selection') . '</a></div> |
|---|
| 262 | '.$pagination_menu; |
|---|
| 263 | } |
|---|
| 264 | |
|---|
| 265 | $output .= "\n\n\t\t" . '<div> |
|---|
| 266 | <input type="hidden" name="action" value="approve-delete" /> |
|---|
| 267 | <input class="submit" type="submit" name="delete_checked" onclick="return confirm(\''. plog_tr('Are you sure you want to delete the selected comments?') . '\');" value="' . plog_tr('Delete Checked') . '" />'; |
|---|
| 268 | |
|---|
| 269 | if (!$approved) { |
|---|
| 270 | $output .= "\n\t\t\t" . '<input class="submit" type="submit" name="approve_checked" onclick="return confirm(\'' . plog_tr('Are you sure you want to approve the selected comments?') . '\');" value="' . plog_tr('Approve Checked') . '" />'; |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | $output .= "\n\t\t" . '</div>' . "\n\t\t" . '</form>'. "\n"; |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | display($output, "feedback"); |
|---|
| 277 | |
|---|
| 278 | ?> |
|---|