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