[15940] | 1 | <?php |
---|
[24889] | 2 | if (!defined('GUESTBOOK_PATH')) die('Hacking attempt!'); |
---|
[15940] | 3 | |
---|
| 4 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 5 | |
---|
| 6 | // +-----------------------------------------------------------------------+ |
---|
| 7 | // | actions | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | |
---|
| 10 | if (!empty($_POST)) |
---|
| 11 | { |
---|
| 12 | if (empty($_POST['comments'])) |
---|
| 13 | { |
---|
[26065] | 14 | $page['errors'][] =l10n('Select at least one comment'); |
---|
[15940] | 15 | } |
---|
| 16 | else |
---|
| 17 | { |
---|
[26065] | 18 | include_once(GUESTBOOK_PATH .'include/functions_comment.inc.php'); |
---|
[15940] | 19 | check_input_parameter('comments', $_POST, true, PATTERN_ID); |
---|
| 20 | |
---|
| 21 | if (isset($_POST['validate'])) |
---|
| 22 | { |
---|
| 23 | validate_user_comment_guestbook($_POST['comments']); |
---|
| 24 | |
---|
[26065] | 25 | $page['infos'][] = l10n_dec( |
---|
| 26 | '%d user comment validated', '%d user comments validated', |
---|
| 27 | count($_POST['comments']) |
---|
[15940] | 28 | ); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | if (isset($_POST['reject'])) |
---|
| 32 | { |
---|
| 33 | delete_user_comment_guestbook($_POST['comments']); |
---|
| 34 | |
---|
[26065] | 35 | $page['infos'][] =l10n_dec( |
---|
| 36 | '%d user comment rejected', '%d user comments rejected', |
---|
| 37 | count($_POST['comments']) |
---|
[15940] | 38 | ); |
---|
| 39 | } |
---|
| 40 | } |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | // +-----------------------------------------------------------------------+ |
---|
| 45 | // | comments display | |
---|
| 46 | // +-----------------------------------------------------------------------+ |
---|
| 47 | include(GUESTBOOK_PATH .'include/functions.inc.php'); |
---|
| 48 | |
---|
| 49 | $list = array(); |
---|
| 50 | |
---|
| 51 | $query = ' |
---|
| 52 | SELECT |
---|
| 53 | c.id, |
---|
| 54 | c.date, |
---|
| 55 | c.author, |
---|
| 56 | '.$conf['user_fields']['username'].' AS username, |
---|
| 57 | c.content, |
---|
| 58 | c.website, |
---|
| 59 | c.email, |
---|
| 60 | c.rate |
---|
| 61 | FROM '.GUESTBOOK_TABLE.' AS c |
---|
| 62 | LEFT JOIN '.USERS_TABLE.' AS u |
---|
| 63 | ON u.'.$conf['user_fields']['id'].' = c.author_id |
---|
| 64 | WHERE validated = \'false\' |
---|
| 65 | ORDER BY c.date DESC |
---|
| 66 | ;'; |
---|
| 67 | $result = pwg_query($query); |
---|
[26065] | 68 | |
---|
[15940] | 69 | while ($row = pwg_db_fetch_assoc($result)) |
---|
| 70 | { |
---|
| 71 | if (empty($row['author_id'])) |
---|
| 72 | { |
---|
| 73 | $author_name = $row['author']; |
---|
| 74 | } |
---|
| 75 | else |
---|
| 76 | { |
---|
| 77 | $author_name = stripslashes($row['username']); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | $template->append( |
---|
| 81 | 'comments', |
---|
| 82 | array( |
---|
| 83 | 'ID' => $row['id'], |
---|
[26851] | 84 | 'AUTHOR' => trigger_event('render_comment_author', $author_name), |
---|
[15940] | 85 | 'DATE' => format_date($row['date'], true), |
---|
[26851] | 86 | 'CONTENT' => trigger_event('render_comment_content', $row['content'], 'guestbook'), |
---|
[15940] | 87 | 'EMAIL' => $row['email'], |
---|
| 88 | 'WEBSITE' => $row['website'], |
---|
| 89 | 'WEBSITE_NAME' => preg_replace('#^(https?:\/\/)#i', null, $row['website']), |
---|
| 90 | 'STARS' => get_stars($row['rate'], GUESTBOOK_PATH .'template/jquery.raty/'), |
---|
| 91 | 'RATE' => $row['rate'], |
---|
| 92 | ) |
---|
| 93 | ); |
---|
| 94 | |
---|
[26065] | 95 | $list[] = $row['id']; |
---|
[15940] | 96 | } |
---|
| 97 | |
---|
| 98 | |
---|
[26065] | 99 | $template->assign(array( |
---|
| 100 | 'LIST' => implode(',', $list), |
---|
| 101 | 'F_ACTION' => GUESTBOOK_ADMIN . '-pending', |
---|
| 102 | )); |
---|
[15940] | 103 | |
---|
[24889] | 104 | $template->set_filename('guestbook', realpath(GUESTBOOK_PATH . 'admin/template/pending.tpl')); |
---|