[839] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 5 | // | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | |
---|
[2297] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
[839] | 23 | |
---|
| 24 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 25 | { |
---|
| 26 | die ("Hacking attempt!"); |
---|
| 27 | } |
---|
| 28 | |
---|
[1072] | 29 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 30 | |
---|
[839] | 31 | // +-----------------------------------------------------------------------+ |
---|
[1072] | 32 | // | Check Access and exit when user status is not ok | |
---|
| 33 | // +-----------------------------------------------------------------------+ |
---|
| 34 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 35 | |
---|
| 36 | // +-----------------------------------------------------------------------+ |
---|
[839] | 37 | // | actions | |
---|
| 38 | // +-----------------------------------------------------------------------+ |
---|
| 39 | |
---|
[8126] | 40 | if (!empty($_POST)) |
---|
[839] | 41 | { |
---|
[5381] | 42 | if (empty($_POST['comments'])) |
---|
[1598] | 43 | { |
---|
[5381] | 44 | array_push( |
---|
| 45 | $page['errors'], |
---|
| 46 | l10n('Select at least one comment') |
---|
| 47 | ); |
---|
[839] | 48 | } |
---|
[5381] | 49 | else |
---|
[839] | 50 | { |
---|
[5381] | 51 | check_input_parameter('comments', $_POST, true, PATTERN_ID); |
---|
| 52 | |
---|
| 53 | if (isset($_POST['validate'])) |
---|
| 54 | { |
---|
| 55 | $query = ' |
---|
[839] | 56 | UPDATE '.COMMENTS_TABLE.' |
---|
| 57 | SET validated = \'true\' |
---|
| 58 | , validation_date = NOW() |
---|
[5381] | 59 | WHERE id IN ('.implode(',', $_POST['comments']).') |
---|
[839] | 60 | ;'; |
---|
| 61 | pwg_query($query); |
---|
| 62 | |
---|
| 63 | array_push( |
---|
| 64 | $page['infos'], |
---|
[1932] | 65 | l10n_dec( |
---|
| 66 | '%d user comment validated', '%d user comments validated', |
---|
[5381] | 67 | count($_POST['comments']) |
---|
[839] | 68 | ) |
---|
| 69 | ); |
---|
[5381] | 70 | } |
---|
[839] | 71 | |
---|
[5381] | 72 | if (isset($_POST['reject'])) |
---|
| 73 | { |
---|
| 74 | $query = ' |
---|
[839] | 75 | DELETE |
---|
| 76 | FROM '.COMMENTS_TABLE.' |
---|
[5381] | 77 | WHERE id IN ('.implode(',', $_POST['comments']).') |
---|
[839] | 78 | ;'; |
---|
[5381] | 79 | pwg_query($query); |
---|
[839] | 80 | |
---|
[5381] | 81 | array_push( |
---|
| 82 | $page['infos'], |
---|
| 83 | l10n_dec( |
---|
| 84 | '%d user comment rejected', '%d user comments rejected', |
---|
| 85 | count($_POST['comments']) |
---|
| 86 | ) |
---|
| 87 | ); |
---|
| 88 | } |
---|
[839] | 89 | } |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | // +-----------------------------------------------------------------------+ |
---|
| 93 | // | template init | |
---|
| 94 | // +-----------------------------------------------------------------------+ |
---|
| 95 | |
---|
[2530] | 96 | $template->set_filenames(array('comments'=>'comments.tpl')); |
---|
[839] | 97 | |
---|
[2249] | 98 | $template->assign( |
---|
[839] | 99 | array( |
---|
[2249] | 100 | 'F_ACTION' => get_root_url().'admin.php?page=comments' |
---|
[839] | 101 | ) |
---|
| 102 | ); |
---|
| 103 | |
---|
| 104 | // +-----------------------------------------------------------------------+ |
---|
| 105 | // | comments display | |
---|
| 106 | // +-----------------------------------------------------------------------+ |
---|
| 107 | |
---|
| 108 | $list = array(); |
---|
| 109 | |
---|
| 110 | $query = ' |
---|
[3452] | 111 | SELECT c.id, c.image_id, c.date, c.author, '. |
---|
| 112 | $conf['user_fields']['username'].' AS username, c.content, i.path, i.tn_ext |
---|
[839] | 113 | FROM '.COMMENTS_TABLE.' AS c |
---|
| 114 | INNER JOIN '.IMAGES_TABLE.' AS i |
---|
| 115 | ON i.id = c.image_id |
---|
[3450] | 116 | LEFT JOIN '.USERS_TABLE.' AS u |
---|
[3452] | 117 | ON u.'.$conf['user_fields']['id'].' = c.author_id |
---|
[839] | 118 | WHERE validated = \'false\' |
---|
[3122] | 119 | ORDER BY c.date DESC |
---|
[839] | 120 | ;'; |
---|
| 121 | $result = pwg_query($query); |
---|
[4325] | 122 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[839] | 123 | { |
---|
[1598] | 124 | $thumb = get_thumbnail_url( |
---|
| 125 | array( |
---|
| 126 | 'id'=>$row['image_id'], |
---|
| 127 | 'path'=>$row['path'], |
---|
| 128 | 'tn_ext'=>@$row['tn_ext'] |
---|
| 129 | ) |
---|
| 130 | ); |
---|
[3450] | 131 | if (empty($row['author_id'])) |
---|
| 132 | { |
---|
| 133 | $author_name = $row['author']; |
---|
| 134 | } |
---|
| 135 | else |
---|
| 136 | { |
---|
[4304] | 137 | $author_name = stripslashes($row['username']); |
---|
[3450] | 138 | } |
---|
[2249] | 139 | $template->append( |
---|
| 140 | 'comments', |
---|
[839] | 141 | array( |
---|
| 142 | 'U_PICTURE' => |
---|
| 143 | PHPWG_ROOT_PATH.'admin.php?page=picture_modify'. |
---|
[1004] | 144 | '&image_id='.$row['image_id'], |
---|
[839] | 145 | 'ID' => $row['id'], |
---|
[1598] | 146 | 'TN_SRC' => $thumb, |
---|
[3450] | 147 | 'AUTHOR' => trigger_event('render_comment_author', $author_name), |
---|
[3122] | 148 | 'DATE' => format_date($row['date'], true), |
---|
[1598] | 149 | 'CONTENT' => trigger_event('render_comment_content',$row['content']) |
---|
[839] | 150 | ) |
---|
| 151 | ); |
---|
| 152 | |
---|
| 153 | array_push($list, $row['id']); |
---|
| 154 | } |
---|
| 155 | |
---|
[2249] | 156 | $template->assign('LIST', implode(',', $list) ); |
---|
[839] | 157 | |
---|
| 158 | // +-----------------------------------------------------------------------+ |
---|
| 159 | // | sending html code | |
---|
| 160 | // +-----------------------------------------------------------------------+ |
---|
| 161 | |
---|
| 162 | $template->assign_var_from_handle('ADMIN_CONTENT', 'comments'); |
---|
| 163 | |
---|
[1730] | 164 | ?> |
---|