[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/ -> admin.php (source)

   1  <?php
   2  /**

   3   * This is the main dispatcher for the admin interface.

   4   *

   5   * IF YOU ARE READING THIS IN YOUR WEB BROWSER, IT MEANS THAT PHP IS NOT PROPERLY INSTALLED

   6   * ON YOUR WEB SERVER. IF YOU DON'T KNOW WHAT THIS MEANS, CONTACT YOUR SERVER ADMINISTRATOR

   7   * OR YOUR HOSTING COMPANY.

   8   *

   9   * This file is part of the evoCore framework - {@link http://evocore.net/}

  10   * See also {@link http://sourceforge.net/projects/evocms/}.

  11   *

  12   * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}

  13   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.

  14   * Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}.

  15   *

  16   * {@internal License choice

  17   * - If you have received this file as part of a package, please find the license.txt file in

  18   *   the same folder or the closest folder above for complete license terms.

  19   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)

  20   *   then you must choose one of the following licenses before using the file:

  21   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php

  22   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php

  23   * }}

  24   *

  25   * {@internal Open Source relicensing agreement:

  26   * Daniel HAHLER grants Francois PLANQUE the right to license

  27   * Daniel HAHLER's contributions to this file and the b2evolution project

  28   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  29   *

  30   * PROGIDISTRI S.A.S. grants Francois PLANQUE the right to license

  31   * PROGIDISTRI S.A.S.'s contributions to this file and the b2evolution project

  32   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  33   * }}

  34   *

  35   * @package main

  36   *

  37   * @version $Id: admin.php,v 1.26 2007/09/03 16:44:28 fplanque Exp $

  38   */
  39  
  40  
  41  /**

  42   * Do the MAIN initializations:

  43   */
  44  require_once dirname(__FILE__).'/conf/_config.php';
  45  
  46  
  47  /**

  48   * @global boolean Is this an admin page? Use {@link is_admin_page()} to query it, because it may change.

  49   */
  50  $is_admin_page = true;
  51  
  52  
  53  $login_required = true;
  54  require_once $inc_path.'_main.inc.php';
  55  
  56  
  57  // Check global permission:

  58  if( ! $current_User->check_perm( 'admin', 'any' ) )
  59  {    // No permission to access admin...
  60      require $adminskins_path.'_access_denied.main.php';
  61  }
  62  
  63  
  64  /*

  65   * Asynchronous processing options that may be required on any page

  66   */
  67  require_once $inc_path.'_async.inc.php';
  68  
  69  
  70  /*

  71   * Get the blog from param, defaulting to the last selected one for this user:

  72   * we need it for quite a few of the menu urls

  73   */
  74  $user_selected_blog = (int)$UserSettings->get('selected_blog');
  75  $BlogCache = & get_Cache( 'BlogCache' );
  76  if( param( 'blog', 'integer', NULL, true ) === NULL      // We got no explicit blog choice (not even '0' for 'no blog'):
  77      || ($blog != 0 && ! ($Blog = & $BlogCache->get_by_ID( $blog, false, false )) )) // or we requested a nonexistent blog
  78  { // Try the memorized blog from the previous action:
  79      $blog = $user_selected_blog;
  80      if( ! ($Blog = & $BlogCache->get_by_ID( $blog, false, false ) ) )
  81      {    // That one doesn't exist either...
  82          $blog = 0;
  83      }
  84  }
  85  elseif( $blog != $user_selected_blog )
  86  { // We have selected a new & valid blog. Update UserSettings for selected blog:
  87      set_working_blog( $blog );
  88  }
  89  
  90  
  91  // bookmarklet, upload (upload actually means sth like: select img for post):

  92  param( 'mode', 'string', '', true );
  93  
  94  
  95  /*

  96   * Get the Admin skin

  97   * TODO: Allow setting through GET param (dropdown in backoffice), respecting a checkbox "Use different setting on each computer" (if cookie_state handling is ready)

  98   */
  99  $admin_skin = $UserSettings->get( 'admin_skin' );
 100  $admin_skin_path = $adminskins_path.'%s/_adminUI.class.php';
 101  
 102  if( ! $admin_skin || ! file_exists( sprintf( $admin_skin_path, $admin_skin ) ) )
 103  { // there's no skin for the user
 104      if( !$admin_skin )
 105      {
 106          $Debuglog->add( 'The user has no admin skin set.', 'skin' );
 107      }
 108      else
 109      {
 110          $Debuglog->add( 'The admin skin ['.$admin_skin.'] set by the user does not exist.', 'skin' );
 111      }
 112  
 113      $admin_skin = $Settings->get( 'admin_skin' );
 114  
 115      if( !$admin_skin || !file_exists( sprintf( $admin_skin_path, $admin_skin ) ) )
 116      { // even the default skin does not exist!
 117          if( !$admin_skin )
 118          {
 119              $Debuglog->add( 'There is no default admin skin set!', 'skin' );
 120          }
 121          else
 122          {
 123              $Debuglog->add( 'The default admin skin ['.$admin_skin.'] does not exist!', array('skin','error') );
 124          }
 125  
 126          if( file_exists(sprintf( $admin_skin_path, 'chicago' )) )
 127          { // 'legacy' does exist
 128              $admin_skin = 'chicago';
 129  
 130              $Debuglog->add( 'Falling back to legacy admin skin.', 'skin' );
 131          }
 132          else
 133          { // get the first one available one
 134              $admin_skin_dirs = get_admin_skins();
 135  
 136              if( $admin_skin_dirs === false )
 137              {
 138                  $Debuglog->add( 'No admin skin found! Check that the path '.$adminskins_path.' exists.', array('skin','error') );
 139              }
 140              elseif( empty($admin_skin_dirs) )
 141              { // No admin skin directories found
 142                  $Debuglog->add( 'No admin skin found! Check that there are skins in '.$adminskins_path.'.', array('skin','error') );
 143              }
 144              else
 145              {
 146                  $admin_skin = array_shift($admin_skin_dirs);
 147                  $Debuglog->add( 'Falling back to first available skin.', 'skin' );
 148              }
 149          }
 150      }
 151  }
 152  if( ! $admin_skin )
 153  {
 154      $Debuglog->display( 'No admin skin available!', '', true, 'skin' );
 155      exit();
 156  }
 157  
 158  $Debuglog->add( 'Using admin skin &laquo;'.$admin_skin.'&raquo;', 'skin' );
 159  
 160  /**

 161   * Load the AdminUI class for the skin.

 162   */
 163  require_once $adminskins_path.$admin_skin.'/_adminUI.class.php';
 164  /**

 165   * This is the Admin UI object which handles the UI for the backoffice.

 166   *

 167   * @global AdminUI

 168   */
 169  $AdminUI = & new AdminUI();
 170  
 171  
 172  /*

 173   * Pass over to controller...

 174   */
 175  
 176  // Get requested controller and memorize it:

 177  param( 'ctrl', '/^[a-z0-9_]+$/', $default_ctrl, true );
 178  
 179  
 180  // Redirect old-style URLs (e.g. /admin/plugins.php), if they come here because the webserver maps "/admin/" to "/admin.php"

 181  // NOTE: this is just meant as a transformation from pre-1.8 to 1.8!

 182  if( ! empty( $_SERVER['PATH_INFO'] ) && $_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'] ) // the "!= PHP_SELF" check seems needed by IIS..
 183  {
 184      // Try to find the appropriate controller (ctrl) setting

 185      foreach( $ctrl_mappings as $k => $v )
 186      {
 187          if( preg_match( '~'.preg_quote( $_SERVER['PATH_INFO'], '~' ).'$~', $v ) )
 188          {
 189              $ctrl = $k;
 190              break;
 191          }
 192      }
 193  
 194      // Sanitize QUERY_STRING

 195      if( ! empty( $_SERVER['QUERY_STRING'] ) )
 196      {
 197          $query_string = explode( '&', $_SERVER['QUERY_STRING'] );
 198          foreach( $query_string as $k => $v )
 199          {
 200              $query_string[$k] = strip_tags($v);
 201          }
 202          $query_string = '&'.implode( '&', $query_string );
 203      }
 204      else
 205      {
 206          $query_string = '';
 207      }
 208  
 209      header_redirect( url_add_param( $admin_url, 'ctrl='.$ctrl.$query_string, '&' ), true );
 210      exit;
 211  }
 212  
 213  
 214  // Check matching controller file:

 215  if( !isset($ctrl_mappings[$ctrl]) )
 216  {
 217      debug_die( 'The requested controller ['.$ctrl.'] does not exist.' );
 218  }
 219  
 220  // Call the requested controller:

 221  require $inc_path.$ctrl_mappings[$ctrl];
 222  
 223  // log the hit on this page (according to settings) if the admin_skin hasn't already done so:

 224  $Hit->log();
 225  
 226  /*

 227   * $Log: admin.php,v $

 228   * Revision 1.26  2007/09/03 16:44:28  fplanque

 229   * chicago admin skin

 230   *

 231   * Revision 1.25  2007/07/13 23:47:36  fplanque

 232   * New start pages!

 233   *

 234   * Revision 1.24  2007/06/25 10:58:47  fplanque

 235   * MODULES (refactored MVC)

 236   *

 237   * Revision 1.23  2007/04/26 00:11:14  fplanque

 238   * (c) 2007

 239   *

 240   * Revision 1.22  2007/03/11 20:40:14  fplanque

 241   * misuse of globals

 242   *

 243   * Revision 1.21  2007/03/07 02:37:15  fplanque

 244   * OMG I decided that pregenerating the menus was getting to much of a PITA!

 245   * It's a zillion problems with the permissions.

 246   * This will be simplified a lot. Enough of these crazy stuff.

 247   *

 248   * Revision 1.20  2007/01/24 13:44:56  fplanque

 249   * cleaned up upload

 250   *

 251   * Revision 1.19  2007/01/24 00:48:57  fplanque

 252   * Refactoring

 253   *

 254   * Revision 1.18  2006/11/24 18:27:22  blueyed

 255   * Fixed link to b2evo CVS browsing interface in file docblocks

 256   *

 257   * Revision 1.17  2006/08/26 20:32:48  fplanque

 258   * fixed redirects

 259   *

 260   * Revision 1.16  2006/08/05 23:37:03  fplanque

 261   * no message

 262   *

 263   * Revision 1.14  2006/07/06 19:56:29  fplanque

 264   * no message

 265   *

 266   * Revision 1.13  2006/06/13 21:49:14  blueyed

 267   * Merged from 1.8 branch

 268   *

 269   * Revision 1.12.2.1  2006/06/12 20:00:29  fplanque

 270   * one too many massive syncs...

 271   *

 272   * Revision 1.12  2006/04/19 22:26:24  blueyed

 273   * cleanup/polish

 274   *

 275   * Revision 1.11  2006/04/19 20:13:48  fplanque

 276   * do not restrict to :// (does not catch subdomains, not even www.)

 277   *

 278   * Revision 1.10  2006/04/14 19:25:31  fplanque

 279   * evocore merge with work app

 280   *

 281   * Revision 1.9  2006/04/11 21:22:25  fplanque

 282   * partial cleanup

 283   *

 284   */
 285  ?>


Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics