[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/update/common/scripts/ -> updatesession.php (source)

   1  #!/usr/bin/env php
   2  <?php
   3  //
   4  // Created on: <19-Apr-2004 11:42:29 amos>
   5  //
   6  // SOFTWARE NAME: eZ publish
   7  // SOFTWARE RELEASE: 3.9.0
   8  // BUILD VERSION: 17785
   9  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  10  // SOFTWARE LICENSE: GNU General Public License v2.0
  11  // NOTICE: >
  12  //   This program is free software; you can redistribute it and/or
  13  //   modify it under the terms of version 2.0  of the GNU General
  14  //   Public License as published by the Free Software Foundation.
  15  //
  16  //   This program is distributed in the hope that it will be useful,
  17  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  18  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19  //   GNU General Public License for more details.
  20  //
  21  //   You should have received a copy of version 2.0 of the GNU General
  22  //   Public License along with this program; if not, write to the Free
  23  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  24  //   MA 02110-1301, USA.
  25  //
  26  //
  27  
  28  include_once ( 'lib/ezutils/classes/ezcli.php' );
  29  include_once ( 'kernel/classes/ezscript.php' );
  30  
  31  $cli =& eZCLI::instance();
  32  $script =& eZScript::instance( array( 'description' => ( "eZ publish Session Updater\n\n" .
  33                                                           "This script will update entries in the session table*.\n" .
  34                                                           "* This is only required when updating from 3.3 or lower" .
  35                                                           "\n" .
  36                                                           "updatesession.php" ),
  37                                        'use-session' => false,
  38                                        'use-modules' => true,
  39                                        'use-extensions' => true ) );
  40  
  41  $script->startup();
  42  
  43  $options = $script->getOptions( "", "",
  44                                  array() );
  45  $script->initialize();
  46  
  47  $db =& eZDB::instance();
  48  
  49  include_once ( 'kernel/classes/datatypes/ezuser/ezuser.php' );
  50  
  51  include_once ( 'lib/ezutils/classes/ezsession.php' );
  52  
  53  $db =& eZDB::instance();
  54  
  55  $sql = "SELECT count( session_key ) as count FROM ezsession";
  56  $rows = $db->arrayQuery( $sql );
  57  $count = $rows[0]['count'];
  58  
  59  $script->setIterationData( '.', '~' );
  60  $script->resetIteration( $count );
  61  
  62  $limit = 50;
  63  $index = 0;
  64  session_start();
  65  while ( $index < $count )
  66  {
  67      $sql = "SELECT session_key, user_id, data FROM ezsession";
  68      $rows = $db->arrayQuery( $sql, array( 'limit' => $limit, 'offset' => $index ) );
  69      foreach ( $rows as $row )
  70      {
  71          $_SESSION = array();
  72          $status = session_decode( $row['data'] );
  73          if ( $status and isset( $_SESSION['eZUserLoggedInID'] ) )
  74          {
  75              $userID = $_SESSION['eZUserLoggedInID'];
  76              if ( $userID != $row['user_id'] )
  77              {
  78                  $sql = "UPDATE ezsession SET user_id='" . (int)$userID . "' WHERE session_key='" . $db->escapeString( $row['session_key'] ) . "'";
  79                  $db->query( $sql );
  80                  $status = true;
  81              }
  82              else
  83              {
  84                  $status = false;
  85              }
  86          }
  87          $script->iterate( $cli, $status, '' );
  88      }
  89      $index += count( $rows );
  90  }
  91  
  92  $script->shutdown();
  93  
  94  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7