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

ucp_attachments.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 7.10 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  /**
023  * ucp_attachments
024  * User attachments
025  */
026  class ucp_attachments
027  {
028      var $u_action;
029   
030      function main($id, $mode)
031      {
032          global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container;
033   
034          $start        = request_var('start', 0);
035          $sort_key    = request_var('sk', 'a');
036          $sort_dir    = request_var('sd', 'a');
037   
038          $delete        = (isset($_POST['delete'])) ? true : false;
039          $confirm    = (isset($_POST['confirm'])) ? true : false;
040          $delete_ids    = array_keys(request_var('attachment', array(0)));
041   
042          if ($delete && sizeof($delete_ids))
043          {
044              // Validate $delete_ids...
045              $sql = 'SELECT attach_id
046                  FROM ' . ATTACHMENTS_TABLE . '
047                  WHERE poster_id = ' . $user->data['user_id'] . '
048                      AND is_orphan = 0
049                      AND ' . $db->sql_in_set('attach_id', $delete_ids);
050              $result = $db->sql_query($sql);
051   
052              $delete_ids = array();
053              while ($row = $db->sql_fetchrow($result))
054              {
055                  $delete_ids[] = $row['attach_id'];
056              }
057              $db->sql_freeresult($result);
058          }
059   
060          if ($delete && sizeof($delete_ids))
061          {
062              $s_hidden_fields = array(
063                  'delete'    => 1
064              );
065   
066              foreach ($delete_ids as $attachment_id)
067              {
068                  $s_hidden_fields['attachment'][$attachment_id] = 1;
069              }
070   
071              if (confirm_box(true))
072              {
073                  if (!function_exists('delete_attachments'))
074                  {
075                      include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
076                  }
077   
078                  delete_attachments('attach', $delete_ids);
079   
080                  meta_refresh(3, $this->u_action);
081                  $message = ((sizeof($delete_ids) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']) . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
082                  trigger_error($message);
083              }
084              else
085              {
086                  confirm_box(false, (sizeof($delete_ids) == 1) ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields));
087              }
088          }
089   
090          // Select box eventually
091          $sort_key_text = array('a' => $user->lang['SORT_FILENAME'], 'b' => $user->lang['SORT_COMMENT'], 'c' => $user->lang['SORT_EXTENSION'], 'd' => $user->lang['SORT_SIZE'], 'e' => $user->lang['SORT_DOWNLOADS'], 'f' => $user->lang['SORT_POST_TIME'], 'g' => $user->lang['SORT_TOPIC_TITLE']);
092          $sort_key_sql = array('a' => 'a.real_filename', 'b' => 'a.attach_comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title');
093   
094          $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
095   
096          $s_sort_key = '';
097          foreach ($sort_key_text as $key => $value)
098          {
099              $selected = ($sort_key == $key) ? ' selected="selected"' : '';
100              $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
101          }
102   
103          $s_sort_dir = '';
104          foreach ($sort_dir_text as $key => $value)
105          {
106              $selected = ($sort_dir == $key) ? ' selected="selected"' : '';
107              $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
108          }
109   
110          if (!isset($sort_key_sql[$sort_key]))
111          {
112              $sort_key = 'a';
113          }
114   
115          $order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');
116   
117          $sql = 'SELECT COUNT(attach_id) as num_attachments
118              FROM ' . ATTACHMENTS_TABLE . '
119              WHERE poster_id = ' . $user->data['user_id'] . '
120                  AND is_orphan = 0';
121          $result = $db->sql_query($sql);
122          $num_attachments = $db->sql_fetchfield('num_attachments');
123          $db->sql_freeresult($result);
124   
125          // Ensure start is a valid value
126          $pagination = $phpbb_container->get('pagination');
127          $start = $pagination->validate_start($start, $config['topics_per_page'], $num_attachments);
128   
129          $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title
130              FROM ' . ATTACHMENTS_TABLE . ' a
131                  LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0)
132                  LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1)
133              WHERE a.poster_id = ' . $user->data['user_id'] . "
134                  AND a.is_orphan = 0
135              ORDER BY $order_by";
136          $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
137   
138          $row_count = 0;
139          if ($row = $db->sql_fetchrow($result))
140          {
141              $template->assign_var('S_ATTACHMENT_ROWS', true);
142   
143              do
144              {
145                  if ($row['in_message'])
146                  {
147                      $view_topic = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&amp;p={$row['post_msg_id']}");
148                  }
149                  else
150                  {
151                      $view_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&amp;p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}";
152                  }
153   
154                  $template->assign_block_vars('attachrow', array(
155                      'ROW_NUMBER'        => $row_count + ($start + 1),
156                      'FILENAME'            => $row['real_filename'],
157                      'COMMENT'            => bbcode_nl2br($row['attach_comment']),
158                      'EXTENSION'            => $row['extension'],
159                      'SIZE'                => get_formatted_filesize($row['filesize']),
160                      'DOWNLOAD_COUNT'    => $row['download_count'],
161                      'POST_TIME'            => $user->format_date($row['filetime']),
162                      'TOPIC_TITLE'        => ($row['in_message']) ? $row['message_title'] : $row['topic_title'],
163   
164                      'ATTACH_ID'            => $row['attach_id'],
165                      'POST_ID'            => $row['post_msg_id'],
166                      'TOPIC_ID'            => $row['topic_id'],
167   
168                      'S_IN_MESSAGE'        => $row['in_message'],
169   
170                      'U_VIEW_ATTACHMENT'    => append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $row['attach_id']),
171                      'U_VIEW_TOPIC'        => $view_topic)
172                  );
173   
174                  $row_count++;
175              }
176              while ($row = $db->sql_fetchrow($result));
177          }
178          $db->sql_freeresult($result);
179   
180          $base_url = $this->u_action . "&amp;sk=$sort_key&amp;sd=$sort_dir";
181          $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start);
182   
183          $template->assign_vars(array(
184              'TOTAL_ATTACHMENTS'        => $num_attachments,
185              'NUM_ATTACHMENTS'        => $user->lang('NUM_ATTACHMENTS', $num_attachments),
186   
187              'L_TITLE'                => $user->lang['UCP_ATTACHMENTS'],
188   
189              'U_SORT_FILENAME'        => $this->u_action . "&amp;sk=a&amp;sd=" . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
190              'U_SORT_FILE_COMMENT'    => $this->u_action . "&amp;sk=b&amp;sd=" . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
191              'U_SORT_EXTENSION'        => $this->u_action . "&amp;sk=c&amp;sd=" . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'),
192              'U_SORT_FILESIZE'        => $this->u_action . "&amp;sk=d&amp;sd=" . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'),
193              'U_SORT_DOWNLOADS'        => $this->u_action . "&amp;sk=e&amp;sd=" . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'),
194              'U_SORT_POST_TIME'        => $this->u_action . "&amp;sk=f&amp;sd=" . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'),
195              'U_SORT_TOPIC_TITLE'    => $this->u_action . "&amp;sk=g&amp;sd=" . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'),
196   
197              'S_DISPLAY_MARK_ALL'    => ($num_attachments) ? true : false,
198              'S_DISPLAY_PAGINATION'    => ($num_attachments) ? true : false,
199              'S_UCP_ACTION'            => $this->u_action,
200              'S_SORT_OPTIONS'         => $s_sort_key,
201              'S_ORDER_SELECT'        => $s_sort_dir)
202          );
203   
204          $this->tpl_name = 'ucp_attachments';
205          $this->page_title = 'UCP_ATTACHMENTS';
206      }
207  }
208