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_zebra.php

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 6.67 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_zebra
 021  * @package ucp
 022  */
 023  class ucp_zebra
 024  {
 025      var $u_action;
 026   
 027      function main($id, $mode)
 028      {
 029          global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
 030   
 031          $submit    = (isset($_POST['submit']) || isset($_GET['add']) || isset($_GET['remove'])) ? true : false;
 032          $s_hidden_fields = '';
 033   
 034          $l_mode = strtoupper($mode);
 035   
 036          if ($submit)
 037          {
 038              $data = $error = array();
 039              $updated = false;
 040   
 041              $var_ary = array(
 042                  'usernames'    => array(0),
 043                  'add'        => '',
 044              );
 045   
 046              foreach ($var_ary as $var => $default)
 047              {
 048                  $data[$var] = request_var($var, $default, true);
 049              }
 050   
 051              if (!empty($data['add']) || sizeof($data['usernames']))
 052              {
 053                  if (confirm_box(true))
 054                  {
 055                      if ($data['add'])
 056                      {
 057                          $data['add'] = array_map('trim', array_map('utf8_clean_string', explode("\n", $data['add'])));
 058   
 059                          // Do these name/s exist on a list already? If so, ignore ... we could be
 060                          // 'nice' and automatically handle names added to one list present on
 061                          // the other (by removing the existing one) ... but I have a feeling this
 062                          // may lead to complaints
 063                          $sql = 'SELECT z.*, u.username, u.username_clean
 064                              FROM ' . ZEBRA_TABLE . ' z, ' . USERS_TABLE . ' u
 065                              WHERE z.user_id = ' . $user->data['user_id'] . '
 066                                  AND u.user_id = z.zebra_id';
 067                          $result = $db->sql_query($sql);
 068   
 069                          $friends = $foes = array();
 070                          while ($row = $db->sql_fetchrow($result))
 071                          {
 072                              if ($row['friend'])
 073                              {
 074                                  $friends[] = utf8_clean_string($row['username']);
 075                              }
 076                              else
 077                              {
 078                                  $foes[] = utf8_clean_string($row['username']);
 079                              }
 080                          }
 081                          $db->sql_freeresult($result);
 082   
 083                          // remove friends from the username array
 084                          $n = sizeof($data['add']);
 085                          $data['add'] = array_diff($data['add'], $friends);
 086   
 087                          if (sizeof($data['add']) < $n && $mode == 'foes')
 088                          {
 089                              $error[] = $user->lang['NOT_ADDED_FOES_FRIENDS'];
 090                          }
 091   
 092                          // remove foes from the username array
 093                          $n = sizeof($data['add']);
 094                          $data['add'] = array_diff($data['add'], $foes);
 095   
 096                          if (sizeof($data['add']) < $n && $mode == 'friends')
 097                          {
 098                              $error[] = $user->lang['NOT_ADDED_FRIENDS_FOES'];
 099                          }
 100   
 101                          // remove the user himself from the username array
 102                          $n = sizeof($data['add']);
 103                          $data['add'] = array_diff($data['add'], array(utf8_clean_string($user->data['username'])));
 104   
 105                          if (sizeof($data['add']) < $n)
 106                          {
 107                              $error[] = $user->lang['NOT_ADDED_' . $l_mode . '_SELF'];
 108                          }
 109   
 110                          unset($friends, $foes, $n);
 111   
 112                          if (sizeof($data['add']))
 113                          {
 114                              $sql = 'SELECT user_id, user_type
 115                                  FROM ' . USERS_TABLE . '
 116                                  WHERE ' . $db->sql_in_set('username_clean', $data['add']) . '
 117                                      AND user_type <> ' . USER_INACTIVE;
 118                              $result = $db->sql_query($sql);
 119   
 120                              $user_id_ary = array();
 121                              while ($row = $db->sql_fetchrow($result))
 122                              {
 123                                  if ($row['user_id'] != ANONYMOUS && $row['user_type'] != USER_IGNORE)
 124                                  {
 125                                      $user_id_ary[] = $row['user_id'];
 126                                  }
 127                                  else
 128                                  {
 129                                      $error[] = $user->lang['NOT_ADDED_' . $l_mode . '_ANONYMOUS'];
 130                                  }
 131                              }
 132                              $db->sql_freeresult($result);
 133   
 134                              if (sizeof($user_id_ary))
 135                              {
 136                                  // Remove users from foe list if they are admins or moderators
 137                                  if ($mode == 'foes')
 138                                  {
 139                                      $perms = array();
 140                                      foreach ($auth->acl_get_list($user_id_ary, array('a_', 'm_')) as $forum_id => $forum_ary)
 141                                      {
 142                                          foreach ($forum_ary as $auth_option => $user_ary)
 143                                          {
 144                                              $perms = array_merge($perms, $user_ary);
 145                                          }
 146                                      }
 147   
 148                                      $perms = array_unique($perms);
 149   
 150                                      if (sizeof($perms))
 151                                      {
 152                                          $error[] = $user->lang['NOT_ADDED_FOES_MOD_ADMIN'];
 153                                      }
 154   
 155                                      // This may not be right ... it may yield true when perms equate to deny
 156                                      $user_id_ary = array_diff($user_id_ary, $perms);
 157                                      unset($perms);
 158                                  }
 159   
 160                                  if (sizeof($user_id_ary))
 161                                  {
 162                                      $sql_mode = ($mode == 'friends') ? 'friend' : 'foe';
 163   
 164                                      $sql_ary = array();
 165                                      foreach ($user_id_ary as $zebra_id)
 166                                      {
 167                                          $sql_ary[] = array(
 168                                              'user_id'        => (int) $user->data['user_id'],
 169                                              'zebra_id'        => (int) $zebra_id,
 170                                              $sql_mode        => 1
 171                                          );
 172                                      }
 173   
 174                                      $db->sql_multi_insert(ZEBRA_TABLE, $sql_ary);
 175   
 176                                      $updated = true;
 177                                  }
 178                                  unset($user_id_ary);
 179                              }
 180                              else if (!sizeof($error))
 181                              {
 182                                  $error[] = $user->lang['USER_NOT_FOUND_OR_INACTIVE'];
 183                              }
 184                          }
 185                      }
 186                      else if (sizeof($data['usernames']))
 187                      {
 188                          // Force integer values
 189                          $data['usernames'] = array_map('intval', $data['usernames']);
 190   
 191                          $sql = 'DELETE FROM ' . ZEBRA_TABLE . '
 192                              WHERE user_id = ' . $user->data['user_id'] . '
 193                                  AND ' . $db->sql_in_set('zebra_id', $data['usernames']);
 194                          $db->sql_query($sql);
 195   
 196                          $updated = true;
 197                      }
 198   
 199                      if ($updated)
 200                      {
 201                          meta_refresh(3, $this->u_action);
 202                          $message = $user->lang[$l_mode . '_UPDATED'] . '<br />' . implode('<br />', $error) . ((sizeof($error)) ? '<br />' : '') . '<br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
 203                          trigger_error($message);
 204                      }
 205                      else
 206                      {
 207                          $template->assign_var('ERROR', implode('<br />', $error));
 208                      }
 209                  }
 210                  else
 211                  {
 212                      confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
 213                          'mode'        => $mode,
 214                          'submit'    => true,
 215                          'usernames'    => $data['usernames'],
 216                          'add'        => $data['add']))
 217                      );
 218                  }
 219              }
 220          }
 221   
 222          $sql_and = ($mode == 'friends') ? 'z.friend = 1' : 'z.foe = 1';
 223          $sql = 'SELECT z.*, u.username, u.username_clean
 224              FROM ' . ZEBRA_TABLE . ' z, ' . USERS_TABLE . ' u
 225              WHERE z.user_id = ' . $user->data['user_id'] . "
 226                  AND $sql_and
 227                  AND u.user_id = z.zebra_id
 228              ORDER BY u.username_clean ASC";
 229          $result = $db->sql_query($sql);
 230   
 231          $s_username_options = '';
 232          while ($row = $db->sql_fetchrow($result))
 233          {
 234              $s_username_options .= '<option value="' . $row['zebra_id'] . '">' . $row['username'] . '</option>';
 235          }
 236          $db->sql_freeresult($result);
 237   
 238          $template->assign_vars(array(
 239              'L_TITLE'            => $user->lang['UCP_ZEBRA_' . $l_mode],
 240   
 241              'U_FIND_USERNAME'    => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=ucp&amp;field=add'),
 242   
 243              'S_USERNAME_OPTIONS'    => $s_username_options,
 244              'S_HIDDEN_FIELDS'        => $s_hidden_fields,
 245              'S_UCP_ACTION'            => $this->u_action)
 246          );
 247   
 248          $this->tpl_name = 'ucp_zebra_' . $mode;
 249          $this->page_title = 'UCP_ZEBRA_' . $l_mode;
 250      }
 251  }
 252   
 253  ?>