Changeset 6110


Ignore:
Timestamp:
05/08/10 01:08:51 (9 years ago)
Author:
patdenice
Message:

Upgrade can be launched automaticaly if user is already connected as webmaster.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_upgrade.php

    r5982 r6110  
    113113 
    114114// Check access rights 
    115 function check_upgrade_access_rights($current_release, $username, $password) 
    116 { 
    117   global $conf, $page; 
     115function check_upgrade_access_rights() 
     116{ 
     117  global $conf, $page, $current_release; 
     118 
     119  if (version_compare($current_release, '2.0', '>=') and isset($_COOKIE[session_name()])) 
     120  { 
     121    // Check if user is already connected as webmaster 
     122    session_start(); 
     123    if (!empty($_SESSION['pwg_uid'])) 
     124    { 
     125      $query = ' 
     126SELECT status 
     127  FROM '.USER_INFOS_TABLE.' 
     128  WHERE user_id = '.$_SESSION['pwg_uid'].' 
     129;'; 
     130      pwg_query($query); 
     131 
     132      $row = pwg_db_fetch_assoc(pwg_query($query)); 
     133      if (isset($row['status']) and $row['status'] == 'webmaster') 
     134      { 
     135        define('PHPWG_IN_UPGRADE', true); 
     136        return; 
     137      } 
     138    } 
     139  } 
     140 
     141  if (!isset($_POST['username']) or !isset($_POST['password'])) 
     142  { 
     143    return; 
     144  } 
     145 
     146  $username = $_POST['password']; 
     147  $password = $_POST['password']; 
    118148 
    119149  if(!@get_magic_quotes_gpc()) 
     
    231261  } 
    232262} 
    233  
    234 /** 
    235  *  Get languages defined in the language directory 
    236  */   
    237 function get_fs_languages($target_charset = null) 
    238 { 
    239   if ( empty($target_charset) ) 
    240   { 
    241     $target_charset = get_pwg_charset(); 
    242   } 
    243   $target_charset = strtolower($target_charset); 
    244    
    245   $dir = opendir(PHPWG_ROOT_PATH.'language'); 
    246    
    247   while ($file = readdir($dir)) 
    248   { 
    249     $path = PHPWG_ROOT_PATH.'language/'.$file; 
    250     if (!is_link($path) and is_dir($path) and file_exists($path.'/iso.txt')) 
    251     { 
    252       list($language_name) = @file($path.'/iso.txt'); 
    253        
    254       $languages[$file] = convert_charset($language_name, $target_charset); 
    255     } 
    256   } 
    257   closedir($dir); 
    258   @asort($languages); 
    259    
    260   return $languages; 
    261 } 
    262  
    263263?> 
  • trunk/upgrade.php

    r5982 r6110  
    3737} 
    3838 
    39 include_once(PHPWG_ROOT_PATH.'include/functions.inc.php'); 
    40 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
    41  
    4239include(PHPWG_ROOT_PATH.'local/config/database.inc.php'); 
    4340include(PHPWG_ROOT_PATH . 'include/config_default.inc.php'); 
     
    4946define('PREFIX_TABLE', $prefixeTable); 
    5047define('UPGRADES_PATH', PHPWG_ROOT_PATH.'install/db'); 
     48 
     49include_once(PHPWG_ROOT_PATH.'include/functions.inc.php'); 
     50include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
    5151 
    5252// +-----------------------------------------------------------------------+ 
     
    280280$mysql_changes = array(); 
    281281 
    282 if (isset($_POST['username']) and isset($_POST['password'])) 
    283 { 
    284   check_upgrade_access_rights($current_release, $_POST['username'], $_POST['password']); 
    285 } 
    286  
    287 if (isset($_POST['submit']) and check_upgrade()) 
     282check_upgrade_access_rights(); 
     283 
     284if ((isset($_POST['submit']) or isset($_GET['now'])) 
     285  and check_upgrade()) 
    288286{ 
    289287  $upgrade_file = PHPWG_ROOT_PATH.'install/upgrade_'.$current_release.'.php'; 
Note: See TracChangeset for help on using the changeset viewer.