Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
acp_ranks.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 /**
015 * @ignore
016 */
017 if (!defined('IN_PHPBB'))
018 {
019 exit;
020 }
021
022 class acp_ranks
023 {
024 var $u_action;
025
026 function main($id, $mode)
027 {
028 global $db, $user, $template, $cache, $request, $phpbb_dispatcher;
029 global $config, $phpbb_root_path, $phpbb_admin_path, $phpbb_log;
030
031 $user->add_lang('acp/posting');
032
033 // Set up general vars
034 $action = $request->variable('action', '');
035 $action = (isset($_POST['add'])) ? 'add' : $action;
036 $action = (isset($_POST['save'])) ? 'save' : $action;
037 $rank_id = $request->variable('id', 0);
038
039 $this->tpl_name = 'acp_ranks';
040 $this->page_title = 'ACP_MANAGE_RANKS';
041
042 $form_name = 'acp_ranks';
043 add_form_key($form_name);
044
045 switch ($action)
046 {
047 case 'save':
048
049 if (!check_form_key($form_name))
050 {
051 trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
052 }
053 $rank_title = $request->variable('title', '', true);
054 $special_rank = $request->variable('special_rank', 0);
055 $min_posts = ($special_rank) ? 0 : max(0, $request->variable('min_posts', 0));
056 $rank_image = $request->variable('rank_image', '');
057
058 // The rank image has to be a jpg, gif or png
059 if ($rank_image != '' && !preg_match('#(\.gif|\.png|\.jpg|\.jpeg)$#i', $rank_image))
060 {
061 $rank_image = '';
062 }
063
064 if (!$rank_title)
065 {
066 trigger_error($user->lang['NO_RANK_TITLE'] . adm_back_link($this->u_action), E_USER_WARNING);
067 }
068
069 $sql_ary = array(
070 'rank_title' => $rank_title,
071 'rank_special' => $special_rank,
072 'rank_min' => $min_posts,
073 'rank_image' => htmlspecialchars_decode($rank_image)
074 );
075
076 /**
077 * Modify the SQL array when saving a rank
078 *
079 * @event core.acp_ranks_save_modify_sql_ary
080 * @var int rank_id The ID of the rank (if available)
081 * @var array sql_ary Array with the rank's data
082 * @since 3.1.0-RC3
083 */
084 $vars = array('rank_id', 'sql_ary');
085 extract($phpbb_dispatcher->trigger_event('core.acp_ranks_save_modify_sql_ary', compact($vars)));
086
087 if ($rank_id)
088 {
089 $sql = 'UPDATE ' . RANKS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE rank_id = $rank_id";
090 $message = $user->lang['RANK_UPDATED'];
091
092 $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RANK_UPDATED', false, array($rank_title));
093 }
094 else
095 {
096 $sql = 'INSERT INTO ' . RANKS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
097 $message = $user->lang['RANK_ADDED'];
098
099 $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RANK_ADDED', false, array($rank_title));
100 }
101 $db->sql_query($sql);
102
103 $cache->destroy('_ranks');
104
105 trigger_error($message . adm_back_link($this->u_action));
106
107 break;
108
109 case 'delete':
110
111 if (!$rank_id)
112 {
113 trigger_error($user->lang['MUST_SELECT_RANK'] . adm_back_link($this->u_action), E_USER_WARNING);
114 }
115
116 if (confirm_box(true))
117 {
118 $sql = 'SELECT rank_title
119 FROM ' . RANKS_TABLE . '
120 WHERE rank_id = ' . $rank_id;
121 $result = $db->sql_query($sql);
122 $rank_title = (string) $db->sql_fetchfield('rank_title');
123 $db->sql_freeresult($result);
124
125 $sql = 'DELETE FROM ' . RANKS_TABLE . "
126 WHERE rank_id = $rank_id";
127 $db->sql_query($sql);
128
129 $sql = 'UPDATE ' . USERS_TABLE . "
130 SET user_rank = 0
131 WHERE user_rank = $rank_id";
132 $db->sql_query($sql);
133
134 $cache->destroy('_ranks');
135
136 $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RANK_REMOVED', false, array($rank_title));
137
138 if ($request->is_ajax())
139 {
140 $json_response = new \phpbb\json_response;
141 $json_response->send(array(
142 'MESSAGE_TITLE' => $user->lang['INFORMATION'],
143 'MESSAGE_TEXT' => $user->lang['RANK_REMOVED'],
144 'REFRESH_DATA' => array(
145 'time' => 3
146 )
147 ));
148 }
149 }
150 else
151 {
152 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
153 'i' => $id,
154 'mode' => $mode,
155 'rank_id' => $rank_id,
156 'action' => 'delete',
157 )));
158 }
159
160 break;
161
162 case 'edit':
163 case 'add':
164
165 $ranks = $existing_imgs = array();
166
167 $sql = 'SELECT *
168 FROM ' . RANKS_TABLE . '
169 ORDER BY rank_min ASC, rank_special ASC';
170 $result = $db->sql_query($sql);
171
172 while ($row = $db->sql_fetchrow($result))
173 {
174 $existing_imgs[] = $row['rank_image'];
175
176 if ($action == 'edit' && $rank_id == $row['rank_id'])
177 {
178 $ranks = $row;
179 }
180 }
181 $db->sql_freeresult($result);
182
183 $imglist = filelist($phpbb_root_path . $config['ranks_path'], '');
184 $edit_img = $filename_list = '';
185
186 foreach ($imglist as $path => $img_ary)
187 {
188 sort($img_ary);
189
190 foreach ($img_ary as $img)
191 {
192 $img = $path . $img;
193
194 if ($ranks && $img == $ranks['rank_image'])
195 {
196 $selected = ' selected="selected"';
197 $edit_img = $img;
198 }
199 else
200 {
201 $selected = '';
202 }
203
204 if (strlen($img) > 255)
205 {
206 continue;
207 }
208
209 $filename_list .= '<option value="' . htmlspecialchars($img) . '"' . $selected . '>' . $img . ((in_array($img, $existing_imgs)) ? ' ' . $user->lang['RANK_IMAGE_IN_USE'] : '') . '</option>';
210 }
211 }
212
213 $filename_list = '<option value=""' . (($edit_img == '') ? ' selected="selected"' : '') . '>----------</option>' . $filename_list;
214 unset($existing_imgs, $imglist);
215
216 $tpl_ary = array(
217 'S_EDIT' => true,
218 'U_BACK' => $this->u_action,
219 'RANKS_PATH' => $phpbb_root_path . $config['ranks_path'],
220 'U_ACTION' => $this->u_action . '&id=' . $rank_id,
221
222 'RANK_TITLE' => (isset($ranks['rank_title'])) ? $ranks['rank_title'] : '',
223 'S_FILENAME_LIST' => $filename_list,
224 'RANK_IMAGE' => ($edit_img) ? $phpbb_root_path . $config['ranks_path'] . '/' . $edit_img : htmlspecialchars($phpbb_admin_path) . 'images/spacer.gif',
225 'S_SPECIAL_RANK' => (isset($ranks['rank_special']) && $ranks['rank_special']) ? true : false,
226 'MIN_POSTS' => (isset($ranks['rank_min']) && !$ranks['rank_special']) ? $ranks['rank_min'] : 0,
227 );
228
229 /**
230 * Modify the template output array for editing/adding ranks
231 *
232 * @event core.acp_ranks_edit_modify_tpl_ary
233 * @var array ranks Array with the rank's data
234 * @var array tpl_ary Array with the rank's template data
235 * @since 3.1.0-RC3
236 */
237 $vars = array('ranks', 'tpl_ary');
238 extract($phpbb_dispatcher->trigger_event('core.acp_ranks_edit_modify_tpl_ary', compact($vars)));
239
240 $template->assign_vars($tpl_ary);
241 return;
242
243 break;
244 }
245
246 $template->assign_vars(array(
247 'U_ACTION' => $this->u_action)
248 );
249
250 $sql = 'SELECT *
251 FROM ' . RANKS_TABLE . '
252 ORDER BY rank_special DESC, rank_min ASC, rank_title ASC';
253 $result = $db->sql_query($sql);
254
255 while ($row = $db->sql_fetchrow($result))
256 {
257 $rank_row = array(
258 'S_RANK_IMAGE' => ($row['rank_image']) ? true : false,
259 'S_SPECIAL_RANK' => ($row['rank_special']) ? true : false,
260
261 'RANK_IMAGE' => $phpbb_root_path . $config['ranks_path'] . '/' . $row['rank_image'],
262 'RANK_TITLE' => $row['rank_title'],
263 'MIN_POSTS' => $row['rank_min'],
264
265 'U_EDIT' => $this->u_action . '&action=edit&id=' . $row['rank_id'],
266 'U_DELETE' => $this->u_action . '&action=delete&id=' . $row['rank_id'],
267 );
268
269 /**
270 * Modify the template output array for each listed rank
271 *
272 * @event core.acp_ranks_list_modify_rank_row
273 * @var array row Array with the rank's data
274 * @var array rank_row Array with the rank's template data
275 * @since 3.1.0-RC3
276 */
277 $vars = array('row', 'rank_row');
278 extract($phpbb_dispatcher->trigger_event('core.acp_ranks_list_modify_rank_row', compact($vars)));
279
280 $template->assign_block_vars('ranks', $rank_row);
281 }
282 $db->sql_freeresult($result);
283
284 }
285 }
286