Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

acp_inactive.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 10.61 KiB


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_inactive
023  {
024      var $u_action;
025      var $p_master;
026   
027      function acp_inactive(&$p_master)
028      {
029          $this->p_master = &$p_master;
030      }
031   
032      function main($id, $mode)
033      {
034          global $config, $db, $user, $auth, $template, $phpbb_container;
035          global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
036   
037          include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
038   
039          $user->add_lang('memberlist');
040   
041          $action = request_var('action', '');
042          $mark    = (isset($_REQUEST['mark'])) ? request_var('mark', array(0)) : array();
043          $start    = request_var('start', 0);
044          $submit = isset($_POST['submit']);
045   
046          // Sort keys
047          $sort_days    = request_var('st', 0);
048          $sort_key    = request_var('sk', 'i');
049          $sort_dir    = request_var('sd', 'd');
050   
051          $form_key = 'acp_inactive';
052          add_form_key($form_key);
053          $pagination = $phpbb_container->get('pagination');
054   
055          // We build the sort key and per page settings here, because they may be needed later
056   
057          // Number of entries to display
058          $per_page = request_var('users_per_page', (int) $config['topics_per_page']);
059   
060          // Sorting
061          $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
062          $sort_by_text = array('i' => $user->lang['SORT_INACTIVE'], 'j' => $user->lang['SORT_REG_DATE'], 'l' => $user->lang['SORT_LAST_VISIT'], 'd' => $user->lang['SORT_LAST_REMINDER'], 'r' => $user->lang['SORT_REASON'], 'u' => $user->lang['SORT_USERNAME'], 'p' => $user->lang['SORT_POSTS'], 'e' => $user->lang['SORT_REMINDER']);
063          $sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'd' => 'user_reminded_time', 'r' => 'user_inactive_reason', 'u' => 'username_clean', 'p' => 'user_posts', 'e' => 'user_reminded');
064   
065          $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
066          gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
067   
068          if ($submit && sizeof($mark))
069          {
070              if ($action !== 'delete' && !check_form_key($form_key))
071              {
072                  trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
073              }
074   
075              switch ($action)
076              {
077                  case 'activate':
078                  case 'delete':
079   
080                      $sql = 'SELECT user_id, username
081                          FROM ' . USERS_TABLE . '
082                          WHERE ' . $db->sql_in_set('user_id', $mark);
083                      $result = $db->sql_query($sql);
084   
085                      $user_affected = array();
086                      while ($row = $db->sql_fetchrow($result))
087                      {
088                          $user_affected[$row['user_id']] = $row['username'];
089                      }
090                      $db->sql_freeresult($result);
091   
092                      if ($action == 'activate')
093                      {
094                          // Get those 'being activated'...
095                          $sql = 'SELECT user_id, username' . (($config['require_activation'] == USER_ACTIVATION_ADMIN) ? ', user_email, user_lang' : '') . '
096                              FROM ' . USERS_TABLE . '
097                              WHERE ' . $db->sql_in_set('user_id', $mark) . '
098                                  AND user_type = ' . USER_INACTIVE;
099                          $result = $db->sql_query($sql);
100   
101                          $inactive_users = array();
102                          while ($row = $db->sql_fetchrow($result))
103                          {
104                              $inactive_users[] = $row;
105                          }
106                          $db->sql_freeresult($result);
107   
108                          user_active_flip('activate', $mark);
109   
110                          if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !empty($inactive_users))
111                          {
112                              include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
113   
114                              $messenger = new messenger(false);
115   
116                              foreach ($inactive_users as $row)
117                              {
118                                  $messenger->template('admin_welcome_activated', $row['user_lang']);
119   
120                                  $messenger->set_addresses($row);
121   
122                                  $messenger->anti_abuse_headers($config, $user);
123   
124                                  $messenger->assign_vars(array(
125                                      'USERNAME'    => htmlspecialchars_decode($row['username']))
126                                  );
127   
128                                  $messenger->send(NOTIFY_EMAIL);
129                              }
130   
131                              $messenger->save_queue();
132                          }
133   
134                          if (!empty($inactive_users))
135                          {
136                              foreach ($inactive_users as $row)
137                              {
138                                  add_log('admin', 'LOG_USER_ACTIVE', $row['username']);
139                                  add_log('user', $row['user_id'], 'LOG_USER_ACTIVE_USER');
140                              }
141   
142                              trigger_error(sprintf($user->lang['LOG_INACTIVE_ACTIVATE'], implode($user->lang['COMMA_SEPARATOR'], $user_affected) . ' ' . adm_back_link($this->u_action)));
143                          }
144   
145                          // For activate we really need to redirect, else a refresh can result in users being deactivated again
146                          $u_action = $this->u_action . "&amp;$u_sort_param&amp;start=$start";
147                          $u_action .= ($per_page != $config['topics_per_page']) ? "&amp;users_per_page=$per_page" : '';
148   
149                          redirect($u_action);
150                      }
151                      else if ($action == 'delete')
152                      {
153                          if (confirm_box(true))
154                          {
155                              if (!$auth->acl_get('a_userdel'))
156                              {
157                                  trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
158                              }
159   
160                              user_delete('retain', $mark, true);
161   
162                              add_log('admin', 'LOG_INACTIVE_' . strtoupper($action), implode(', ', $user_affected));
163   
164                              trigger_error(sprintf($user->lang['LOG_INACTIVE_DELETE'], implode($user->lang['COMMA_SEPARATOR'], $user_affected) . ' ' . adm_back_link($this->u_action)));
165                          }
166                          else
167                          {
168                              $s_hidden_fields = array(
169                                  'mode'            => $mode,
170                                  'action'        => $action,
171                                  'mark'            => $mark,
172                                  'submit'        => 1,
173                                  'start'            => $start,
174                              );
175                              confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields));
176                          }
177                      }
178   
179                  break;
180   
181                  case 'remind':
182                      if (empty($config['email_enable']))
183                      {
184                          trigger_error($user->lang['EMAIL_DISABLED'] . adm_back_link($this->u_action), E_USER_WARNING);
185                      }
186   
187                      $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey
188                          FROM ' . USERS_TABLE . '
189                          WHERE ' . $db->sql_in_set('user_id', $mark) . '
190                              AND user_inactive_reason';
191   
192                      $sql .= ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? ' = ' . INACTIVE_REMIND : ' <> ' . INACTIVE_MANUAL;
193   
194                      $result = $db->sql_query($sql);
195   
196                      if ($row = $db->sql_fetchrow($result))
197                      {
198                          // Send the messages
199                          include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
200   
201                          $messenger = new messenger();
202                          $usernames = $user_ids = array();
203   
204                          do
205                          {
206                              $messenger->template('user_remind_inactive', $row['user_lang']);
207   
208                              $messenger->set_addresses($row);
209   
210                              $messenger->anti_abuse_headers($config, $user);
211   
212                              $messenger->assign_vars(array(
213                                  'USERNAME'        => htmlspecialchars_decode($row['username']),
214                                  'REGISTER_DATE'    => $user->format_date($row['user_regdate'], false, true),
215                                  'U_ACTIVATE'    => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'])
216                              );
217   
218                              $messenger->send($row['user_notify_type']);
219   
220                              $usernames[] = $row['username'];
221                              $user_ids[] = (int) $row['user_id'];
222                          }
223                          while ($row = $db->sql_fetchrow($result));
224   
225                          $messenger->save_queue();
226   
227                          // Add the remind state to the database
228                          $sql = 'UPDATE ' . USERS_TABLE . '
229                              SET user_reminded = user_reminded + 1,
230                                  user_reminded_time = ' . time() . '
231                              WHERE ' . $db->sql_in_set('user_id', $user_ids);
232                          $db->sql_query($sql);
233   
234                          add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames));
235   
236                          trigger_error(sprintf($user->lang['LOG_INACTIVE_REMIND'], implode($user->lang['COMMA_SEPARATOR'], $usernames) . ' ' . adm_back_link($this->u_action)));
237                      }
238                      $db->sql_freeresult($result);
239   
240                      // For remind we really need to redirect, else a refresh can result in more than one reminder
241                      $u_action = $this->u_action . "&amp;$u_sort_param&amp;start=$start";
242                      $u_action .= ($per_page != $config['topics_per_page']) ? "&amp;users_per_page=$per_page" : '';
243   
244                      redirect($u_action);
245   
246                  break;
247              }
248          }
249   
250          // Define where and sort sql for use in displaying logs
251          $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
252          $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
253   
254          $inactive = array();
255          $inactive_count = 0;
256   
257          $start = view_inactive_users($inactive, $inactive_count, $per_page, $start, $sql_where, $sql_sort);
258   
259          foreach ($inactive as $row)
260          {
261              $template->assign_block_vars('inactive', array(
262                  'INACTIVE_DATE'    => $user->format_date($row['user_inactive_time']),
263                  'REMINDED_DATE'    => $user->format_date($row['user_reminded_time']),
264                  'JOINED'        => $user->format_date($row['user_regdate']),
265                  'LAST_VISIT'    => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']),
266   
267                  'REASON'        => $row['inactive_reason'],
268                  'USER_ID'        => $row['user_id'],
269                  'POSTS'            => ($row['user_posts']) ? $row['user_posts'] : 0,
270                  'REMINDED'        => $row['user_reminded'],
271   
272                  'REMINDED_EXPLAIN'    => $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])),
273   
274                  'USERNAME_FULL'        => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&amp;mode=overview')),
275                  'USERNAME'            => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
276                  'USER_COLOR'        => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
277   
278                  'U_USER_ADMIN'    => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&amp;mode=overview&amp;u={$row['user_id']}"),
279                  'U_SEARCH_USER'    => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$row['user_id']}&amp;sr=posts") : '',
280              ));
281          }
282   
283          $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
284          if ($config['email_enable'])
285          {
286              $option_ary += array('remind' => 'REMIND');
287          }
288   
289          $base_url = $this->u_action . "&amp;$u_sort_param&amp;users_per_page=$per_page";
290          $pagination->generate_template_pagination($base_url, 'pagination', 'start', $inactive_count, $per_page, $start);
291   
292          $template->assign_vars(array(
293              'S_INACTIVE_USERS'        => true,
294              'S_INACTIVE_OPTIONS'    => build_select($option_ary),
295   
296              'S_LIMIT_DAYS'    => $s_limit_days,
297              'S_SORT_KEY'    => $s_sort_key,
298              'S_SORT_DIR'    => $s_sort_dir,
299              'USERS_PER_PAGE'    => $per_page,
300   
301              'U_ACTION'        => $this->u_action . "&amp;$u_sort_param&amp;users_per_page=$per_page&amp;start=$start",
302          ));
303   
304          $this->tpl_name = 'acp_inactive';
305          $this->page_title = 'ACP_INACTIVE_USERS';
306      }
307  }
308