Verzeichnisstruktur phpBB-3.0.0


Veröffentlicht
12.12.2007

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:51 - Dateigröße: 6.93 KiB


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