home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / upgrade / index.php < prev    next >
Encoding:
PHP Script  |  2007-12-10  |  4.4 KB  |  119 lines

  1. <?php
  2. // $Id: index.php 1179 2007-12-09 13:37:37Z phppp $
  3. //  ------------------------------------------------------------------------ //
  4. //                XOOPS - PHP Content Management System                      //
  5. //                    Copyright (c) 2000 XOOPS.org                           //
  6. //                       <http://www.xoops.org/>                             //
  7. //  ------------------------------------------------------------------------ //
  8. //  This program is free software; you can redistribute it and/or modify     //
  9. //  it under the terms of the GNU General Public License as published by     //
  10. //  the Free Software Foundation; either version 2 of the License, or        //
  11. //  (at your option) any later version.                                      //
  12. //                                                                           //
  13. //  You may not change or alter any portion of this comment or credits       //
  14. //  of supporting developers from this source code or any supporting         //
  15. //  source code which is considered copyrighted (c) material of the          //
  16. //  original comment or credit authors.                                      //
  17. //                                                                           //
  18. //  This program is distributed in the hope that it will be useful,          //
  19. //  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
  20. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
  21. //  GNU General Public License for more details.                             //
  22. //                                                                           //
  23. //  You should have received a copy of the GNU General Public License        //
  24. //  along with this program; if not, write to the Free Software              //
  25. //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
  26. //  ------------------------------------------------------------------------ //
  27. @include_once '../mainfile.php';
  28.  
  29. error_reporting( E_ALL );
  30.  
  31. if ( !defined( 'XOOPS_ROOT_PATH' ) ) {
  32.     die( 'Bad installation: please add this folder to the XOOPS install you want to upgrade');
  33. }
  34. /*
  35.  * gets list of name of directories inside a directory
  36.  */
  37. function getDirList($dirname) {
  38.     $dirlist = array();
  39.     if ( is_dir($dirname) && $handle = opendir($dirname) ) {
  40.         while (false !== ($file = readdir($handle))) {
  41.             if ( substr( $file, 0, 1 ) != '.'  && strtolower($file) != 'cvs' ) {
  42.                 if ( is_dir( "$dirname/$file" ) ) {
  43.                     $dirlist[] = $file;
  44.                 }
  45.             }
  46.         }
  47.         closedir($handle);
  48.         asort($dirlist);
  49.         reset($dirlist);
  50.     }
  51.     return $dirlist;
  52. }
  53. function getDbValue( &$db, $table, $field, $condition = '' ) {
  54.     $table = $db->prefix( $table );
  55.     $sql = "SELECT `$field` FROM `$table`";
  56.     if ( $condition ) {
  57.         $sql .= " WHERE $condition";
  58.     }
  59.     $result = $db->query($sql);
  60.     if ( $result ) {
  61.         $row = $db->fetchRow($result);
  62.         if ( $row ) {
  63.             return $row[0];
  64.         }
  65.     }
  66.     return false;
  67. }
  68.  
  69.  
  70.  
  71. if ( file_exists("./language/".$xoopsConfig['language']."/upgrade.php") ) {
  72.     include_once "./language/".$xoopsConfig['language']."/upgrade.php";
  73.     $language = $xoopsConfig['language'];
  74. } elseif ( file_exists("./language/english/upgrade.php") ) {
  75.     include_once "./language/english/upgrade.php";
  76.     $language = 'english';
  77. } else {
  78.     echo 'no language file.';
  79.     exit();
  80. }
  81.  
  82. ob_start();
  83.  
  84. global $xoopsUser;
  85. if ( !$xoopsUser || !$xoopsUser->isAdmin() ) {
  86.     include_once "login.php";    
  87. } else {
  88.     $op = @$_REQUEST['action'];
  89.     if ( empty( $_SESSION['xoops_upgrade'] ) ) {
  90.         $op = '';
  91.     }
  92.     if ( empty( $op ) ) {
  93.         include_once 'check_version.php';
  94.     } else {
  95.         $next = array_shift( $_SESSION['xoops_upgrade'] );
  96.         printf( '<h2>' . _PERFORMING_UPGRADE . '</h2>', $next );
  97.         $upgrader = include_once "$next/index.php";
  98.         $res = $upgrader->apply();
  99.         if ( !$res ) {
  100.             array_unshift( $_SESSION['xoops_upgrade'], $next );
  101.             echo '<a id="link-next" href="index.php?action=next">' . _RELOAD . '</a>';
  102.         } else {
  103.             if ( empty( $_SESSION['xoops_upgrade'] ) ) {
  104.                  $text = _FINISH;
  105.             } else {
  106.                 list($key, $val) = each( $_SESSION['xoops_upgrade'] );
  107.                 $text = sprintf( _APPLY_NEXT, $val);
  108.             }
  109.             echo '<a id="link-next" href="index.php?action=next">' . $text . '</a>';
  110.         }
  111.     }
  112. }
  113.  
  114. $content = ob_get_contents();
  115. ob_end_clean();
  116.  
  117. include_once 'upgrade_tpl.php';
  118.  
  119. ?>