1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 12:48:26 +02:00

Various improvements to update routines

This commit is contained in:
e107steved
2007-06-24 16:18:53 +00:00
parent 3dd0ee80ab
commit d15aad4b2f
3 changed files with 123 additions and 55 deletions

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/e107_update.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/e107_update.php,v $
| $Revision: 1.1.1.1 $ | $Revision: 1.2 $
| $Date: 2006-12-02 04:33:20 $ | $Date: 2007-06-24 16:18:48 $
| $Author: mcfly_e107 $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
require_once("../class2.php"); require_once("../class2.php");
@@ -21,7 +21,10 @@ $e_sub_cat = 'database';
require_once("auth.php"); require_once("auth.php");
require_once("update_routines.php"); require_once("update_routines.php");
function run_updates($dbupdate) {
// Carry out core updates
function run_updates($dbupdate)
{
global $ns; global $ns;
foreach($dbupdate as $func => $rmks) { foreach($dbupdate as $func => $rmks) {
$installed = call_user_func("update_".$func); $installed = call_user_func("update_".$func);
@@ -40,7 +43,9 @@ function run_updates($dbupdate) {
} }
} }
function show_updates($dbupdate, $additional = false) {
function show_updates($dbupdate)
{
global $ns; global $ns;
$text = "<form method='POST' action='".e_SELF."'> $text = "<form method='POST' action='".e_SELF."'>
<div style='width:100%'> <div style='width:100%'>
@@ -56,6 +61,7 @@ function show_updates($dbupdate, $additional = false) {
foreach($dbupdate as $func => $rmks) { foreach($dbupdate as $func => $rmks) {
if (function_exists("update_".$func)) { if (function_exists("update_".$func)) {
$text .= "<tr><td class='forumheader3' style='width: 60%'>{$rmks}</td>"; $text .= "<tr><td class='forumheader3' style='width: 60%'>{$rmks}</td>";
// echo "Core2 Check {$func}=>{$rmks}<br />";
if (call_user_func("update_".$func)) { if (call_user_func("update_".$func)) {
$text .= "<td class='forumheader3' style='text-align:center; width: 40%'>".LAN_UPDATE_3."</td>"; $text .= "<td class='forumheader3' style='text-align:center; width: 40%'>".LAN_UPDATE_3."</td>";
} else { } else {
@@ -67,13 +73,18 @@ function show_updates($dbupdate, $additional = false) {
} }
$text .= "</table></div></form>"; $text .= "</table></div></form>";
$ns->tablerender(($additional ? (defined("LAN_UPDATE_11") ? LAN_UPDATE_11 : '.617 to .7 Update Continued') : LAN_UPDATE_10), $text); $ns->tablerender(LAN_UPDATE, $text);
} }
if ($_POST) {
if ($_POST)
{
$message = run_updates($dbupdate); $message = run_updates($dbupdate);
} }
/*
These things already done within update_routines.php
if($sql->db_Select("plugin", "plugin_version", "plugin_path = 'forum' AND plugin_installflag='1' ")) { if($sql->db_Select("plugin", "plugin_version", "plugin_path = 'forum' AND plugin_installflag='1' ")) {
if(file_exists(e_PLUGIN.'forum/forum_update_check.php')) if(file_exists(e_PLUGIN.'forum/forum_update_check.php'))
{ {
@@ -103,13 +114,18 @@ if ($sql->db_Select("plugin", "plugin_version", "plugin_path = 'pm' AND plugin_i
} }
} }
if ($_POST) { */
if ($_POST)
{ // Do plugin updates
$message = run_updates($dbupdatep); $message = run_updates($dbupdatep);
} }
if (isset($dbupdatep)) { if (isset($dbupdatep))
show_updates($dbupdatep, true); { // Show plugin updates done
show_updates($dbupdatep);
} }
// Show core updates done
show_updates($dbupdate); show_updates($dbupdate);
require_once("footer.php"); require_once("footer.php");

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $
| $Revision: 1.7 $ | $Revision: 1.8 $
| $Date: 2007-05-21 21:42:48 $ | $Date: 2007-06-24 16:18:48 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -28,33 +28,57 @@ require_once("../class2.php");
// To do - how do we handle multi-language tables? // To do - how do we handle multi-language tables?
// This is really a 0.7.0..0.7.6 or so update
if (!$pref['displayname_maxlength'])
{
$pref['displayname_maxlength'] = 15;
save_prefs();
}
if (!defined("LAN_UPDATE_8")) { define("LAN_UPDATE_8", ""); } if (!defined("LAN_UPDATE_8")) { define("LAN_UPDATE_8", ""); }
if (!defined("LAN_UPDATE_9")) { define("LAN_UPDATE_9", ""); } if (!defined("LAN_UPDATE_9")) { define("LAN_UPDATE_9", ""); }
// Determine which installed plugins have an update file - save the path and the installed version in an array // Determine which installed plugins have an update file - save the path and the installed version in an array
$dbupdatep = array(); // Array of paths to installed plugins which have a checking routine $dbupdateplugs = array(); // Array of paths to installed plugins which have a checking routine
$dbupdatep = array(); // Array of plugin upgrade actions (similar to $dbupdate)
$dbupdate = array();
global $e107cache;
if (is_readable(e_ADMIN."ver.php"))
{
include(e_ADMIN."ver.php");
}
// If $dont_check_update is both defined and TRUE on entry, a check for update is done only once per 24 hours.
$dont_check_update = varset($dont_check_update, FALSE);
if ($dont_check_update === TRUE)
{
$dont_check_update = FALSE;
if ($tempData = $e107cache->retrieve_sys("nq_admin_updatecheck",3600, TRUE))
{ // See when we last checked for an admin update
list($last_time, $dont_check_update,$last_ver) = explode(',',$tempData);
if ($last_ver != $e107info['e107_version'])
{
$dont_check_update = FALSE; // Do proper check on version change
}
}
}
if (!$dont_check_update)
{
if ($sql->db_Select("plugin", "plugin_version, plugin_path", "plugin_installflag='1' ")) if ($sql->db_Select("plugin", "plugin_version, plugin_path", "plugin_installflag='1' "))
{ {
while ($row = $sql->db_Fetch()) while ($row = $sql->db_Fetch())
{ // Mark plugins for update which have a specific update file, or a plugin.php file to check { // Mark plugins for update which have a specific update file, or a plugin.php file to check
if(is_readable(e_PLUGIN.$row['plugin_path'].'/'.$row['plugin_path'].'_update_check.php') || is_readable(e_PLUGIN.$row['plugin_path'].'/plugin.php')) if(is_readable(e_PLUGIN.$row['plugin_path'].'/'.$row['plugin_path'].'_update_check.php') || is_readable(e_PLUGIN.$row['plugin_path'].'/plugin.php'))
{ {
$dbupdatep[$row['plugin_path']] = $row['plugin_version']; $dbupdateplugs[$row['plugin_path']] = $row['plugin_version'];
} }
} }
} }
// Read in each update file // Read in each update file - this will add an entry to the $dbupdatep array if a potential update exists
foreach ($dbupdatep as $path => $ver) foreach ($dbupdateplugs as $path => $ver)
{ {
$fname = e_PLUGIN.$path.'/'.$path.'_update_check.php'; $fname = e_PLUGIN.$path.'/'.$path.'_update_check.php';
if (is_readable($fname)) include_once($fname); if (is_readable($fname)) include_once($fname);
@@ -94,19 +118,27 @@ if($sql->db_Select("plugin", "plugin_version", "plugin_path = 'pm' AND plugin_in
*/ */
// List of potential updates
$dbupdate["core_prefs"] = LAN_UPDATE_13; // Prefs check
$dbupdate["706_to_800"] = LAN_UPDATE_8." .706 ".LAN_UPDATE_9." .8"; $dbupdate["706_to_800"] = LAN_UPDATE_8." .706 ".LAN_UPDATE_9." .8";
$dbupdate["70x_to_706"] = LAN_UPDATE_8." .70x ".LAN_UPDATE_9." .706"; $dbupdate["70x_to_706"] = LAN_UPDATE_8." .70x ".LAN_UPDATE_9." .706";
} // End if (!$dont_check_update)
function update_check() function update_check()
{ {
global $ns, $dbupdate, $dbupdatep; global $ns, $dont_check_update, $e107info;
$update_needed = FALSE; $update_needed = FALSE;
if ($dont_check_update === FALSE)
{
global $dbupdate, $dbupdatep, $e107cache;
// See which core functions need update
foreach($dbupdate as $func => $rmks) foreach($dbupdate as $func => $rmks)
{ {
// echo "Core Check {$func}=>{$rmks}<br />";
if (function_exists("update_".$func)) if (function_exists("update_".$func))
{ {
if (!call_user_func("update_".$func, FALSE)) if (!call_user_func("update_".$func, FALSE))
@@ -117,8 +149,10 @@ function update_check()
} }
} }
// Now check plugins
foreach($dbupdatep as $func => $rmks) foreach($dbupdatep as $func => $rmks)
{ {
// echo "Plugin Check {$func}=>{$rmks}<br />";
if (function_exists("update_".$func)) if (function_exists("update_".$func))
{ {
if (!call_user_func("update_".$func, FALSE)) if (!call_user_func("update_".$func, FALSE))
@@ -128,6 +162,13 @@ function update_check()
} }
} }
} }
$e107cache->set_sys("nq_admin_updatecheck", time().','.($update_needed ? '2,' : '1,').$e107info['e107_version'], TRUE);
}
else
{
$update_needed = ($dont_check_update == '2');
}
if ($update_needed === TRUE) if ($update_needed === TRUE)
{ {
@@ -143,24 +184,24 @@ function update_check()
//-------------------------------------------- //--------------------------------------------
// Check current prefs against latest list // Check current prefs against latest list
//-------------------------------------------- //--------------------------------------------
function check_core_prefs($type='') function update_core_prefs($type='')
{ {
global $pref; global $pref;
$do_save = FALSE; $do_save = FALSE;
$should = get_default_prefs(); $should = get_default_prefs();
$just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing if an update is needed $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing if an update is needed
foreach ($should as $k => $v) foreach ($should as $k => $v)
{ {
if (!array_key_exists($k,$pref)) if ($k && !array_key_exists($k,$pref))
{ {
if ($just_check) return update_needed(); if ($just_check) return update_needed();
$pref[$k] = $v; $pref[$k] = $v;
$do_save = TRUE; $do_save = TRUE;
} }
} }
if ($do_save) save_prefs(); if ($do_save) { save_prefs(); }
return $just_check;
} }
@@ -172,7 +213,7 @@ function update_706_to_800($type='')
global $sql,$ns, $pref; global $sql,$ns, $pref;
// List of unwanted $pref values which can go // List of unwanted $pref values which can go
$obs_prefs = array(); $obs_prefs = array('frontpage_type');
$do_save = FALSE; $do_save = FALSE;
$just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing if an update is needed $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing if an update is needed
@@ -262,6 +303,16 @@ function update_706_to_800($type='')
} }
// Front page prefs (logic has changed)
if (!isset($pref['frontpage_force']))
{ // Just set basic options; no real method of converting the existing
if ($just_check) return update_needed();
$pref['frontpage_force'] = array(e_UC_PUBLIC => '');
$pref['frontpage'] = array(e_UC_PUBLIC => 'news.php');
$do_save = TRUE;
}
// Obsolete prefs (list at top) // Obsolete prefs (list at top)
foreach ($obs_prefs as $p) foreach ($obs_prefs as $p)
{ {
@@ -298,7 +349,7 @@ function update_706_to_800($type='')
function update_70x_to_706($type='') function update_70x_to_706($type='')
{ {
global $sql,$ns; global $sql,$ns, $pref;
$just_check = $type == 'do' ? FALSE : TRUE; $just_check = $type == 'do' ? FALSE : TRUE;
if(!$sql->db_Field("plugin",5)) // not plugin_rss so just add the new one. if(!$sql->db_Field("plugin",5)) // not plugin_rss so just add the new one.
@@ -408,7 +459,7 @@ function catch_error(){
function get_default_prefs() function get_default_prefs()
{ {
require_once(e_FILES."def_e107_prefs.php"); require(e_FILE."def_e107_prefs.php");
return $pref; return $pref;
} }

View File

@@ -4,9 +4,9 @@
| e107 website system - Language File. | e107 website system - Language File.
| |
| $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_e107_update.php,v $ | $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_e107_update.php,v $
| $Revision: 1.1.1.1 $ | $Revision: 1.2 $
| $Date: 2006-12-02 04:34:40 $ | $Date: 2007-06-24 16:18:53 $
| $Author: mcfly_e107 $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -17,9 +17,10 @@ define("LAN_UPDATE_5", "Update available");
define("LAN_UPDATE_7", "Executed"); define("LAN_UPDATE_7", "Executed");
define("LAN_UPDATE_8", "Update from"); define("LAN_UPDATE_8", "Update from");
define("LAN_UPDATE_9", "to"); define("LAN_UPDATE_9", "to");
define("LAN_UPDATE_10", "Available Updates"); //define("LAN_UPDATE_10", "Available Updates");
define("LAN_UPDATE_11", ".617 to .7 Update Continued"); //define("LAN_UPDATE_11", ".617 to .7 Update Continued");
define("LAN_UPDATE_12", "One of your tables contains duplicate entries."); define("LAN_UPDATE_12", "One of your tables contains duplicate entries.");
define("LAN_UPDATE_13", "Add additional/missing core settings");
?> ?>