diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php
index 4d9638ebb..215f06f1c 100644
--- a/e107_admin/update_routines.php
+++ b/e107_admin/update_routines.php
@@ -1,901 +1,915 @@
-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'))
- {
- while ($row = $sql->db_Fetch())
- { // 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'))
- {
- $dbupdateplugs[$row['plugin_path']] = $row['plugin_version'];
- }
- }
- }
-
-
- // Read in each update file - this will add an entry to the $dbupdatep array if a potential update exists
- foreach ($dbupdateplugs as $path => $ver)
- {
- $fname = e_PLUGIN.$path.'/'.$path.'_update_check.php';
- if (is_readable($fname)) include_once($fname);
- }
-
-
- // List of potential updates
- if (defined('TEST_UPDATE'))
- {
- $dbupdate['test_code'] = 'Test update routine';
- }
- $dbupdate['core_prefs'] = LAN_UPDATE_13; // Prefs check
- $dbupdate['706_to_800'] = LAN_UPDATE_8.' .706 '.LAN_UPDATE_9.' .8';
- $dbupdate['70x_to_706'] = LAN_UPDATE_8.' .70x '.LAN_UPDATE_9.' .706';
-} // End if (!$dont_check_update)
-
-
-
-
-/**
- * Master routine to call to check for updates
- */
-function update_check()
-{
- global $ns, $dont_check_update, $e107info;
-
-
- $update_needed = FALSE;
-
- if ($dont_check_update === FALSE)
- {
- global $dbupdate, $dbupdatep, $e107cache;
-
- // See which core functions need update
- foreach($dbupdate as $func => $rmks)
- {
- if (function_exists('update_'.$func))
- {
- if (!call_user_func('update_'.$func, FALSE))
- {
- $update_needed = TRUE;
- continue;
- }
- }
- }
-
-
-
-
- // Now check plugins
- foreach($dbupdatep as $func => $rmks)
- {
- if (function_exists('update_'.$func))
- {
- if (!call_user_func('update_'.$func, FALSE))
- {
- $update_needed = TRUE;
- continue;
- }
- }
- }
-
- $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)
- {
- require_once (e_HANDLER.'form_handler.php');
- $frm = new e_form();
- $txt = "
-
- ";
-
- require_once (e_HANDLER.'message_handler.php');
- $emessage = &eMessage::getInstance();
- $emessage->add($txt);
- }
-}
-
-
-
-require_once(e_HANDLER.'e_upgrade_class.php');
-// $upg = new e_upgrade;
- //TODO Enable this before release!!
-// $upg->checkSiteTheme();
-// $upg->checkAllPlugins();
-
-
-//--------------------------------------------
-// Check current prefs against latest list
-//--------------------------------------------
-function update_core_prefs($type='')
-{
- global $pref, $admin_log, $e107info;
- $do_save = FALSE;
- $should = get_default_prefs();
- $accum = array();
-
- $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing if an update is needed
-
- foreach ($should as $k => $v)
- {
- if ($k && !array_key_exists($k,$pref))
- {
- if ($just_check) return update_needed('Missing pref: '.$k);
- $pref[$k] = $v;
- $accum[] = $k;
- $do_save = TRUE;
- }
- }
- if ($do_save)
- {
- save_prefs();
- $admin_log->log_event('UPDATE_03',LAN_UPDATE_14.$e107info['e107_version'].'[!br!]'.implode(', ',$accum),E_LOG_INFORMATIVE,''); // Log result of actual update
- }
- return $just_check;
-}
-
-
-
-if (defined('TEST_UPDATE'))
-{
-//--------------------------------------------
-// Test routine - to activate, define TEST_UPDATE
-//--------------------------------------------
- function update_test_code($type='')
- {
- global $sql,$ns, $pref;
- $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing whether an update is needed
- //--------------**************---------------
- // Add your test code in here
- //--------------**************---------------
-
- //--------------**************---------------
- // End of test code
- //--------------**************---------------
- return $just_check;
- }
-} // End of test routine
-
-
-
-
-//--------------------------------------------
-// Upgrade later versions of 0.7.x to 0.8
-//--------------------------------------------
-function update_706_to_800($type='')
-{
- global $sql,$ns, $pref, $admin_log, $e107info;
- $mes = e107::getMessage();
-
- // List of unwanted $pref values which can go
- $obs_prefs = array('frontpage_type','rss_feeds', 'log_lvcount', 'zone', 'upload_allowedfiletype', 'real', 'forum_user_customtitle',
- 'utf-compatmode','frontpage_method','standards_mode','image_owner','im_quality', 'signup_option_timezone',
- 'modules', 'plug_sc', 'plug_bb', 'plug_status', 'plug_latest', 'subnews_hide_news', 'upload_storagetype'
-);
-
- // List of DB tables not required (includes a few from 0.6xx)
- $obs_tables = array('flood', 'headlines', 'stat_info', 'stat_counter', 'stat_last');
-
-
- // List of DB tables newly required (defined in core_sql.php) (The existing dblog table gets renamed)
- $new_tables = array('admin_log','audit_log', 'dblog','news_rewrite', 'core_media', 'mail_recipients', 'mail_content');
+ *
+ * Update routines from older e107 versions to current.
+ *
+ * Also links to plugin update routines.
+ *
+ * 2-stage process - routines identify whether update is required, and then execute as instructed.
+ */
+
+// [debug=8] shows the operations on major table update
+
+require_once('../class2.php');
+require_once(e_HANDLER.'db_table_admin_class.php');
+include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_e107_update.php');
+// Modified update routine - combines checking and update code into one block per function
+// - reduces code size typically 30%.
+// - keeping check and update code together should improve clarity/reduce mis-types etc
+
+
+// TODO: how do we handle update of multi-language tables?
+
+// If following line uncommented, enables a test routine
+// define('TEST_UPDATE',TRUE);
+$update_debug = FALSE; // TRUE gives extra messages in places
+//$update_debug = TRUE; // TRUE gives extra messages in places
+if (defined('TEST_UPDATE')) $update_debug = TRUE;
+
+
+if (!defined('LAN_UPDATE_8')) { define('LAN_UPDATE_8', ''); }
+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
+$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(); // Array of core upgrade actions
+
+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'))
+ {
+ while ($row = $sql->db_Fetch())
+ { // 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'))
+ {
+ $dbupdateplugs[$row['plugin_path']] = $row['plugin_version'];
+ }
+ }
+ }
+
+
+ // Read in each update file - this will add an entry to the $dbupdatep array if a potential update exists
+ foreach ($dbupdateplugs as $path => $ver)
+ {
+ $fname = e_PLUGIN.$path.'/'.$path.'_update_check.php';
+ if (is_readable($fname)) include_once($fname);
+ }
+
+
+ // List of potential updates
+ if (defined('TEST_UPDATE'))
+ {
+ $dbupdate['test_code'] = 'Test update routine';
+ }
+ $dbupdate['core_prefs'] = LAN_UPDATE_13; // Prefs check
+ $dbupdate['706_to_800'] = LAN_UPDATE_8.' .706 '.LAN_UPDATE_9.' .8';
+ $dbupdate['70x_to_706'] = LAN_UPDATE_8.' .70x '.LAN_UPDATE_9.' .706';
+} // End if (!$dont_check_update)
+
+
+
+
+/**
+ * Master routine to call to check for updates
+ */
+function update_check()
+{
+ global $ns, $dont_check_update, $e107info;
+
+
+ $update_needed = FALSE;
+
+ if ($dont_check_update === FALSE)
+ {
+ global $dbupdate, $dbupdatep, $e107cache;
+
+ // See which core functions need update
+ foreach($dbupdate as $func => $rmks)
+ {
+ if (function_exists('update_'.$func))
+ {
+ if (!call_user_func('update_'.$func, FALSE))
+ {
+ $update_needed = TRUE;
+ continue;
+ }
+ }
+ }
+
+
+
+
+ // Now check plugins
+ foreach($dbupdatep as $func => $rmks)
+ {
+ if (function_exists('update_'.$func))
+ {
+ if (!call_user_func('update_'.$func, FALSE))
+ {
+ $update_needed = TRUE;
+ continue;
+ }
+ }
+ }
+
+ $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)
+ {
+ require_once (e_HANDLER.'form_handler.php');
+ $frm = new e_form();
+ $txt = "
+
+ ";
+
+ require_once (e_HANDLER.'message_handler.php');
+ $emessage = &eMessage::getInstance();
+ $emessage->add($txt);
+ }
+}
+
+
+
+require_once(e_HANDLER.'e_upgrade_class.php');
+// $upg = new e_upgrade;
+ //TODO Enable this before release!!
+// $upg->checkSiteTheme();
+// $upg->checkAllPlugins();
+
+
+//--------------------------------------------
+// Check current prefs against latest list
+//--------------------------------------------
+function update_core_prefs($type='')
+{
+ global $pref, $e107info;
+ $admin_log = e107::getAdminLog();
+ $do_save = FALSE;
+ $should = get_default_prefs();
+
+ $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing if an update is needed
+
+ foreach ($should as $k => $v)
+ {
+ if ($k && !array_key_exists($k,$pref))
+ {
+ if ($just_check) return update_needed('Missing pref: '.$k);
+ $pref[$k] = $v;
+ $admin_log->logMessage($k.' => '.$v, E_MESSAGE_NODISPLAY, E_MESSAGE_INFO);
+ $do_save = TRUE;
+ }
+ }
+ if ($do_save)
+ {
+ save_prefs();
+ $admin_log->logMessage(LAN_UPDATE_14.$e107info['e107_version'], E_MESSAGE_NODISPLAY, E_MESSAGE_INFO);
+ $admin_log->flushMessages('UPDATE_03',E_LOG_INFORMATIVE);
+ //$admin_log->log_event('UPDATE_03',LAN_UPDATE_14.$e107info['e107_version'].'[!br!]'.implode(', ',$accum),E_LOG_INFORMATIVE,''); // Log result of actual update
+ }
+ return $just_check;
+}
+
+
+
+if (defined('TEST_UPDATE'))
+{
+//--------------------------------------------
+// Test routine - to activate, define TEST_UPDATE
+//--------------------------------------------
+ function update_test_code($type='')
+ {
+ global $sql,$ns, $pref;
+ $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing whether an update is needed
+ //--------------**************---------------
+ // Add your test code in here
+ //--------------**************---------------
+
+ //--------------**************---------------
+ // End of test code
+ //--------------**************---------------
+ return $just_check;
+ }
+} // End of test routine
+
+
+
+
+//--------------------------------------------
+// Upgrade later versions of 0.7.x to 0.8
+//--------------------------------------------
+function update_706_to_800($type='')
+{
+ global $sql,$ns, $pref, $e107info;
+ //$mes = new messageLog; // Combined logging and message displaying handler
+ //$mes = e107::getMessage();
+ $mes = e107::getAdminLog(); // Used for combined logging and message displaying
+
+ // List of unwanted $pref values which can go
+ $obs_prefs = array('frontpage_type','rss_feeds', 'log_lvcount', 'zone', 'upload_allowedfiletype', 'real', 'forum_user_customtitle',
+ 'utf-compatmode','frontpage_method','standards_mode','image_owner','im_quality', 'signup_option_timezone',
+ 'modules', 'plug_sc', 'plug_bb', 'plug_status', 'plug_latest', 'subnews_hide_news', 'upload_storagetype'
+);
+
+ // List of DB tables not required (includes a few from 0.6xx)
+ $obs_tables = array('flood', 'headlines', 'stat_info', 'stat_counter', 'stat_last');
+
+
+ // List of DB tables newly required (defined in core_sql.php) (The existing dblog table gets renamed)
+ $new_tables = array('admin_log','audit_log', 'dblog','news_rewrite', 'core_media', 'mail_recipients', 'mail_content');
// List of core prefs that need to be converted from serialized to e107ArrayStorage.
- $serialized_prefs = array("'emote'", "'menu_pref'", "'search_prefs'", "'emote_default'");
-
-
- // List of changed DB tables (defined in core_sql.php)
- // (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
- $changed_tables = array('user', 'dblog','admin_log', 'userclass_classes', 'banlist', 'menus',
- 'plugin', 'news', 'news_category','online', 'page', 'links', 'comments');
-
-
- // List of changed DB tables from core plugins (defined in pluginname_sql.php file)
- // key = plugin directory name. Data = comma-separated list of tables to check
- // (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
+ $serialized_prefs = array("'emote'", "'menu_pref'", "'search_prefs'", "'emote_default'");
+
+
+ // List of changed DB tables (defined in core_sql.php)
+ // (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
+ $changed_tables = array('user', 'dblog','admin_log', 'userclass_classes', 'banlist', 'menus',
+ 'plugin', 'news', 'news_category','online', 'page', 'links', 'comments');
+
+
+ // List of changed DB tables from core plugins (defined in pluginname_sql.php file)
+ // key = plugin directory name. Data = comma-separated list of tables to check
+ // (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
$pluginChangedTables = array('linkwords' => 'linkwords',
- 'featurebox' => 'featurebox',
- 'links_page' => 'links_page',
- 'poll' => 'polls',
- 'content' => 'pcontent'
- );
+ 'featurebox' => 'featurebox',
+ 'links_page' => 'links_page',
+ 'poll' => 'polls',
+ 'content' => 'pcontent'
+ );
$setCorePrefs = array( //modified prefs during upgrade.
- 'adminstyle' => 'infopanel',
- 'admintheme' => 'jayya'
- );
-
+ 'adminstyle' => 'infopanel',
+ 'admintheme' => 'jayya'
+ );
+
$do_save = TRUE;
-
- foreach($setCorePrefs as $k=>$v)
- {
+
+ foreach($setCorePrefs as $k=>$v)
+ {
$pref[$k] = $v;
- }
+ }
// List of changed menu locations.
- $changeMenuPaths = array(
- array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'),
- array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'compliance_menu'),
- array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'powered_by_menu'),
- array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'),
- array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'),
+ $changeMenuPaths = array(
+ array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'),
+ array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'compliance_menu'),
+ array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'powered_by_menu'),
+ array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'),
+ array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'),
array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'latestnews_menu'),
- array('oldpath' => 'compliance_menu', 'newpath' => 'siteinfo', 'menu' => 'compliance_menu'),
- array('oldpath' => 'powered_by_menu', 'newpath' => 'siteinfo', 'menu' => 'powered_by_menu'),
- array('oldpath' => 'sitebutton_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'),
- array('oldpath' => 'counter_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'),
- array('oldpath' => 'usertheme_menu', 'newpath' => 'user_menu', 'menu' => 'usertheme_menu'),
- array('oldpath' => 'userlanguage_menu', 'newpath' => 'user_menu', 'menu' => 'userlanguage_menu'),
- array('oldpath' => 'lastseen_menu', 'newpath' => 'online', 'menu' => 'lastseen_menu')
+ array('oldpath' => 'compliance_menu', 'newpath' => 'siteinfo', 'menu' => 'compliance_menu'),
+ array('oldpath' => 'powered_by_menu', 'newpath' => 'siteinfo', 'menu' => 'powered_by_menu'),
+ array('oldpath' => 'sitebutton_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'),
+ array('oldpath' => 'counter_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'),
+ array('oldpath' => 'usertheme_menu', 'newpath' => 'user_menu', 'menu' => 'usertheme_menu'),
+ array('oldpath' => 'userlanguage_menu', 'newpath' => 'user_menu', 'menu' => 'userlanguage_menu'),
+ array('oldpath' => 'lastseen_menu', 'newpath' => 'online', 'menu' => 'lastseen_menu')
);
-
-
- // List of DB tables (key) and field (value) which need changing to accommodate IPV6 addresses
- $ip_upgrade = array('download_requests' => 'download_request_ip',
- 'submitnews' => 'submitnews_ip',
- 'tmp' => 'tmp_ip',
- 'chatbox' => 'cb_ip'
- );
-
- $db_parser = new db_table_admin; // Class to read table defs and process them
- $do_save = FALSE; // Set TRUE to update prefs when update complete
- $updateMessages = array(); // Used to log actions for the admin log
-
- $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing whether an update is needed
-
-
-
- // Check that custompages have been imported from current theme.php file
- if(!array_key_exists('sitetheme_custompages',$pref))
- {
- $th = e107::getSingleton('themeHandler');
- $tmp = $th->getThemeInfo($pref['sitetheme']);
- if(is_array($tmp['custompages']))
- {
- if ($just_check) return update_needed();
- $pref['sitetheme_custompages'] = $tmp['custompages'];
- $do_save = TRUE;
- }
- }
-
-
-
- // Check notify prefs
- global $sysprefs, $eArrayStorage, $tp;
- $notify_prefs = $sysprefs -> get('notify_prefs');
- $notify_prefs = $eArrayStorage -> ReadArray($notify_prefs);
-
- $nt_changed = 0;
- if(vartrue($notify_prefs['event']))
- {
- foreach ($notify_prefs['event'] as $e => $d)
- {
- if (isset($d['type']))
- {
- if ($just_check) return update_needed('Notify pref: '.$e.' outdated');
- switch ($d['type'])
- {
- case 'main' :
- $notify_prefs['event'][$e]['class'] = e_UC_MAINADMIN;
- break;
- case 'class' : // Should already have class defined
- break;
- case 'email' :
- $notify_prefs['event'][$e]['class'] = 'email';
- break;
- case 'off' : // Need to disable
- default :
- $notify_prefs['event'][$e]['class'] = e_UC_NOBODY; // Just disable if we don't know what else to do
- }
- $nt_changed++;
- unset($notify_prefs['event'][$e]['type']);
- }
- }
- }
- if ($nt_changed)
- {
- $s_prefs = $tp -> toDB($notify_prefs);
- $s_prefs = $eArrayStorage -> WriteArray($s_prefs);
- // Could we use $sysprefs->set($s_prefs,'notify_prefs') instead - avoids caching problems ????
- $status = ($sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'") === FALSE) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- $message = str_replace('--COUNT--',$nt_changed,LAN_UPDATE_20);
- $mes->add($message, $status);
- }
-
-
- $statusTexts = array(E_MESSAGE_SUCCESS => 'Success', E_MESSAGE_ERROR => 'Fail', E_MESSAGE_INFO => 'Info');
-
- if (isset($pref['forum_user_customtitle']) && !isset($pref['signup_option_customtitle']))
- {
- if ($just_check) return update_needed();
- $pref['signup_option_customtitle'] = $pref['forum_user_customtitle'];
- unset($pref['forum_user_customtitle']);
- $mes->add(LAN_UPDATE_20.'customtitle', E_MESSAGE_SUCCESS);
- $do_save = TRUE;
- }
-
- // convert all serialized core prefs to e107 ArrayStorage;
- $serialz_qry = "SUBSTRING( e107_value,1,5)!='array' AND e107_value !='' ";
- $serialz_qry .= "AND e107_name IN (".implode(",",$serialized_prefs).") ";
- if(e107::getDb()->db_Select("core", "*", $serialz_qry))
- {
- if ($just_check) return update_needed();
- while ($row = e107::getDb()->db_Fetch(MYSQL_ASSOC))
- {
- $status = e107::getDb('sql2')->db_Update('core',"e107_value=\"".convert_serialized($row['e107_value'])."\" WHERE e107_name='".$row['e107_name']."'");
- $mes->add(LAN_UPDATE_22.$row['e107_name'], $status);
- }
- }
-
- //TODO de-serialize the user_prefs also.
-
-
-
- // Move the maximum online counts from menu prefs to a separate pref - 'history'
- $menuConfig = e107::getConfig('menu');
- if ($menuConfig->get('most_members_online') || $menuConfig->get('most_guests_online') || $menuConfig->get('most_online_datestamp'))
- {
- $status = E_MESSAGE_SUCCESS;
- if ($just_check) return update_needed('Move online counts from menupref');
- $newPrefs = e107::getConfig('history');
- foreach (array('most_members_online', 'most_guests_online', 'most_online_datestamp') as $v)
- {
- if (FALSE === $newPrefs->get($v, FALSE))
- {
- if (FALSE !== $menuConfig->get($v, FALSE))
- {
- $newPrefs->set($v,$menuConfig->get($v));
- }
- else
- {
- $newPrefs->set($v, 0);
- }
- }
- $menuConfig->remove($v);
- }
- $result = $newPrefs->save(false, true, false);
- if ($result === TRUE)
- {
- $resultMessage = 'Historic member counts updated';
- }
- elseif ($result === FALSE)
- {
- $resultMessage = 'moving historic member counts';
- $status = E_MESSAGE_ERROR;
- }
- else
- { // No change
- $resultMessage = 'Historic member counts already updated';
- $status = E_MESSAGE_INFO;
- }
- $result = $menuConfig->save(false, true, false); // Save updated menuprefs - without the counts
- $updateMessages[] = $statusTexts[$status].': '.$resultMessage; // Admin log message
- $mes->add($resultMessage,$status); // User message
- }
-
-
-
- // ++++++++ Modify Menu Paths +++++++.
- if(varset($changeMenuPaths))
- {
- foreach($changeMenuPaths as $val)
- {
- $qry = "SELECT menu_path FROM `#menus` WHERE menu_name = '".$val['menu']."' AND (menu_path='".$val['oldpath']."' || menu_path='".$val['oldpath']."/' ) LIMIT 1";
- if($sql->db_Select_gen($qry))
- {
- if ($just_check) return update_needed('Menu path changed required: '.$val['menu'].' ');
- $updqry = "menu_path='".$val['newpath']."/' WHERE menu_name = '".$val['menu']."' AND (menu_path='".$val['oldpath']."' || menu_path='".$val['oldpath']."/' ) ";
- $status = $sql->db_Update('menus', $updqry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- $mes->add(LAN_UPDATE_23.''.$val['menu'].' : '.$val['oldpath'].' => '.$val['newpath'], $status); // LAN_UPDATE_25;
- // catch_error($sql);
- }
- }
- }
-
- // Leave this one here.. just in case..
- //delete record for online_extended_menu (now only using one online menu)
- if($sql->db_Select('menus', '*', "menu_path='online_extended_menu' || menu_path='online_extended_menu/'"))
- {
- if ($just_check) return update_needed();
-
- $row=$sql->db_Fetch();
-
- //if online_extended is activated, we need to activate the new 'online' menu, and delete this record
- if($row['menu_location']!=0)
- {
- $status = $sql->db_Update('menus', "menu_name='online_menu', menu_path='online/' WHERE menu_path='online_extended_menu' || menu_path='online_extended_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- $mes->add(LAN_UPDATE_23."online_menu : online/", $status);
- }
- else
- { //else if the menu is not active
- //we need to delete the online_extended menu row, and change the online_menu to online
- $sql->db_Delete('menus', " menu_path='online_extended_menu' || menu_path='online_extended_menu/' ");
- // $updateMessages[] = LAN_UPXXDATE_31;
- }
- catch_error($sql);
- }
-
- //change menu_path for online_menu (if it still exists)
- if($sql->db_Select('menus', 'menu_path', "menu_path='online_menu' || menu_path='online_menu/'"))
- {
- if ($just_check) return update_needed();
-
- $status = $sql->db_Update('menus', "menu_path='online/' WHERE menu_path='online_menu' || menu_path='online_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- $mes->add(LAN_UPDATE_23."online_menu : online/", $status);
- catch_error($sql);
- }
-
-
-//---------------------------------------------------------
-// Comments - split user field
-//---------------------------------------------------------
- if($sql->db_Field('comments','comment_author'))
- {
- if ($just_check) return update_needed('Comment table author field update');
-
- if ((!$sql->db_Field('comments','comment_author_id')) // Check to see whether new fields already added - maybe data copy failed part way through
- && (!$sql->db_Select_gen("ALTER TABLE `#comments`
- ADD COLUMN comment_author_id int(10) unsigned NOT NULL default '0' AFTER `comment_author`,
- ADD COLUMN comment_author_name varchar(100) NOT NULL default '' AFTER `comment_author_id`")))
- {
- // Flag error
- // $commentMessage = LAN_UPDAXXTE_34;
- $mes->add(LAN_UPDATE_21."comments", E_MESSAGE_ERROR);
- }
- else
- {
- if (FALSE ===$sql->db_Update('comments',"comment_author_id=SUBSTRING_INDEX(`comment_author`,'.',1), comment_author_name=SUBSTRING(`comment_author` FROM POSITION('.' IN `comment_author`)+1)"))
- {
- // Flag error
- $mes->add(LAN_UPDATE_21.'comments', E_MESSAGE_ERROR);
- }
- else
- { // Delete superceded field - comment_author
- if (!$sql->db_Select_gen("ALTER TABLE `#comments` DROP COLUMN `comment_author`"))
- {
- // Flag error
- $mes->add(LAN_UPDATE_24.'comments - comment_author', E_MESSAGE_ERROR);
- }
- }
- }
-
- $mes->add(LAN_UPDATE_21.'comments', E_MESSAGE_SUCCESS);
- }
-
-
-
- // Add index to download history
- if (FALSE !== ($temp = addIndexToTable('download_requests', 'download_request_datestamp', $just_check, $updateMessages)))
- {
- if ($just_check)
- {
- return update_needed($temp);
- }
- }
-
- // Extra index to tmp table
- if (FALSE !== ($temp = addIndexToTable('tmp', 'tmp_time', $just_check, $updateMessages)))
- {
- if ($just_check)
- {
- return update_needed($temp);
- }
- }
-
- // Extra index to rss table (if used)
- if (FALSE !== ($temp = addIndexToTable('rss', 'rss_name', $just_check, $updateMessages, TRUE)))
- {
- if ($just_check)
- {
- return update_needed($temp);
- }
- }
-
- // 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('Change front page prefs');
- $pref['frontpage_force'] = array(e_UC_PUBLIC => '');
- $pref['frontpage'] = array(e_UC_PUBLIC => 'news.php');
- // $_pdateMessages[] = LAN_UPDATE_38; //FIXME
- $mes->add(LAN_UPDATE_20."frontpage",E_MESSAGE_SUCCESS);
- $do_save = TRUE;
- }
-
-
- if ($sql->db_Table_exists('newsfeed'))
- { // Need to extend field newsfeed_url varchar(250) NOT NULL default ''
- if ($sql->db_Query("SHOW FIELDS FROM ".MPREFIX."newsfeed LIKE 'newsfeed_url'"))
- {
- $row = $sql -> db_Fetch();
- if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(250)')
- {
- if ($just_check) return update_needed('Update newsfeed field definition');
- $status = $sql->db_Select_gen("ALTER TABLE `".MPREFIX."newsfeed` MODIFY `newsfeed_url` VARCHAR(250) NOT NULL DEFAULT '' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- $updateMessages[] = LAN_UPDATE_40;
- $mes->add(LAN_UPDATE_21."newsfeed",$status);
- // catch_error($sql);
- }
- }
- }
-
-
- //TODO use generic function for this update.
- if ($sql->db_Table_exists('download'))
- { // Need to extend field download_url varchar(255) NOT NULL default ''
- if ($sql->db_Query("SHOW FIELDS FROM ".MPREFIX."download LIKE 'download_url'"))
- {
- $row = $sql -> db_Fetch();
- if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(255)')
- {
- if ($just_check) return update_needed('Update download table field definition');
- $sql->db_Select_gen("ALTER TABLE `#download` MODIFY `download_url` VARCHAR(255) NOT NULL DEFAULT '' ");
- $updateMessages[] = LAN_UPDATE_52; //FIXME
- catch_error($sql);
- }
- }
- }
-
- //TODO use generic function for this update.
- if ($sql->db_Table_exists('download_mirror'))
- { // Need to extend field download_url varchar(255) NOT NULL default ''
- if ($sql->db_Select_gen("SHOW FIELDS FROM ".MPREFIX."download_mirror LIKE 'mirror_url'"))
- {
- $row = $sql -> db_Fetch();
- if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(255)')
- {
- if ($just_check) return update_needed('Update download mirror table field definition');
- $sql->db_Select_gen("ALTER TABLE `".MPREFIX."download_mirror` MODIFY `mirror_url` VARCHAR(255) NOT NULL DEFAULT '' ");
- $updateMessages[] = LAN_UPDATE_53; //FIXME
- catch_error($sql);
- }
- }
- }
-
-
- // Check need for user timezone before we delete the field
- if (varsettrue($pref['signup_option_timezone']))
- {
- if ($sql->db_Field('user', 'user_timezone', '', TRUE) && !$sql->db_Field('user_extended','user_timezone','',TRUE))
- {
- if ($just_check) return update_needed('Move user timezone info');
- if (!copy_user_timezone())
- { // Error doing the transfer
- $updateMessages[] = LAN_UPDATE_42; //FIXME
- return FALSE;
- }
- $updateMessages[] = LAN_UPDATE_41;
- }
- }
-
-
- // Tables defined in core_sql.php
- //---------------------------------
- if ($sql->db_Table_exists('dblog') && !$sql->db_Table_exists('admin_log'))
- {
- if ($just_check) return update_needed('Rename dblog to admin_log');
- $sql->db_Select_gen('ALTER TABLE `'.MPREFIX.'dblog` RENAME `'.MPREFIX.'admin_log`');
- catch_error($sql);
- $updateMessages[] = LAN_UPDATE_43; //FIXME
- }
-
-
- // Next bit will be needed only by the brave souls who used an early CVS - probably delete before release
- if ($sql->db_Table_exists('rl_history') && !$sql->db_Table_exists('dblog'))
- {
- if ($just_check) return update_needed('Rename rl_history to dblog');
- $sql->db_Select_gen('ALTER TABLE `'.MPREFIX.'rl_history` RENAME `'.MPREFIX.'dblog`');
- $updateMessages[] = LAN_UPDATE_44; //FIXME
- catch_error($sql);
- }
-
- // New tables required (list at top. Definitions in core_sql.php)
- foreach ($new_tables as $nt)
- {
- if (!$sql->db_Table_exists($nt))
- {
- if ($just_check) return update_needed('Add table: '.$nt);
- // Get the definition
- $defs = $db_parser->get_table_def($nt,e_ADMIN.'sql/core_sql.php');
- if (count($defs)) // **** Add in table here
- {
- $status = $sql->db_Select_gen('CREATE TABLE `'.MPREFIX.$defs[0][1].'` ('.$defs[0][2].') TYPE='.$defs[0][3]) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- // $updateMessages[] = LAN_UPDATE_45.$defs[0][1];
- $mes->add(LAN_UPDATE_27.$defs[0][1], $status); //TODO - all update messages should work like this. But also need $updateMessages[] for admin log
- // catch_error($sql);
- }
- else
- { // error parsing defs file
- $mes->add(LAN_UPDATE_46.$defs[0][1], E_MESSAGE_ERROR);
- }
- unset($defs);
- }
- }
-
-
- // Tables whose definition needs changing significantly
- $debugLevel = E107_DBG_SQLDETAILS;
-
- foreach ($changed_tables as $ct)
- {
- $req_defs = $db_parser->get_table_def($ct,e_ADMIN."sql/core_sql.php");
- $req_fields = $db_parser->parse_field_defs($req_defs[0][2]); // Required definitions
- if ($debugLevel)
- {
- $mes->add("Required table structure:
".$db_parser->make_field_list($req_fields), E_MESSAGE_DEBUG);
- }
-
- if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs)) // Adds current default prefix
- {
- $mes->add("Couldn't get table structure: ".$ct, E_MESSAGE_DEBUG);
- }
- else
- {
-// echo $db_parser->make_table_list($actual_defs);
- $actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]);
- if ($debugLevel)
- {
- $mes->add("Actual table structure:
".$db_parser->make_field_list($actual_fields), E_MESSAGE_DEBUG);
- }
-
- $diffs = $db_parser->compare_field_lists($req_fields,$actual_fields);
- if (count($diffs[0]))
- { // Changes needed
- if ($just_check) return update_needed("Field changes rqd; table: ".$ct);
-
- // Do the changes here
- if ($debugLevel)
- {
- $mes->add("List of changes found:
".$db_parser->make_changes_list($diffs), E_MESSAGE_DEBUG);
- }
-
- $qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]);
-
- if ($debugLevel)
- {
- $mes->add("Update Query used: ".$qry, E_MESSAGE_DEBUG);
- }
-
- $status = $sql->db_Select_gen($qry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- $mes->add(LAN_UPDATE_21.$ct, $status);
- catch_error($sql);
- }
- }
- }
-
-
- // Plugin tables whose definition needs changing significantly
- foreach ($pluginChangedTables as $plugName => $plugList)
- {
- if (plugInstalled($plugName))
- {
- $ttc = explode(',',$plugList);
- $mes = e107::getMessage();
- foreach ($ttc as $ct)
- {
- $sqlDefs = e_PLUGIN.$plugName.'/'.str_replace('_menu','',$plugName).'_sql.php'; // Filename containing definitions
-// echo "Looking at file: {$sqlDefs}, table {$ct}
";
- $req_defs = $db_parser->get_table_def($ct,$sqlDefs);
- if (!is_array($req_defs))
- {
- echo "Couldn't get definitions from file {$sqlDefs}
";
- continue;
- }
- $req_fields = $db_parser->parse_field_defs($req_defs[0][2]); // Required definitions
- if (E107_DBG_SQLDETAILS)
- {
- $message = "Required plugin table structure:
".$db_parser->make_field_list($req_fields);
-
- $mes->add($message, E_MESSAGE_DEBUG);
-
- }
-
- if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs)) // Adds current default prefix
- {
-// echo "Couldn't get table structure: {$ct}
";
- }
- else
- {
-// echo $db_parser->make_table_list($actual_defs);
- $actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]);
- if (E107_DBG_SQLDETAILS)
- {
- $message= "Actual table structure:
".$db_parser->make_field_list($actual_fields);
- $mes->add($message, E_MESSAGE_DEBUG);
- }
-
- $diffs = $db_parser->compare_field_lists($req_fields,$actual_fields);
- if (count($diffs[0]))
- { // Changes needed
- if (E107_DBG_SQLDETAILS)
- {
- $message = "List of changes found:
".$db_parser->make_changes_list($diffs);
- $mes->add($message, E_MESSAGE_DEBUG);
- }
- if ($just_check) return update_needed("Field changes rqd; plugin table: ".$ct);
- // Do the changes here
- $qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]);
- if (E107_DBG_SQLDETAILS)
- {
- $message = "Update Query used: ".$qry."
";
- $mes->add($message, E_MESSAGE_DEBUG);
- }
- $sql->db_Select_gen($qry);
- $updateMessages[] = LAN_UPDATE_51.$ct; //FIXME
- catch_error($sql);
- }
- }
- }
- }
- }
-
- // This has to be done after the table is upgraded
- if($sql->db_Select('plugin', 'plugin_category', "plugin_category = ''"))
- {
- if ($just_check) return update_needed('Update plugin table');
- require_once(e_HANDLER.'plugin_class.php');
- $ep = new e107plugin;
- $ep -> update_plugins_table();
- // $_pdateMessages[] = LAN_UPDATE_XX24;
- // catch_error($sql);
- }
-
-
- // Obsolete tables (list at top)
- foreach ($obs_tables as $ot)
- {
- if ($sql->db_Table_exists($ot))
- {
- if ($just_check) return update_needed("Delete table: ".$ot);
- $status = $sql->db_Select_gen('DROP TABLE `'.MPREFIX.$ot.'`') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- $mes->add(LAN_UPDATE_25.$ot, $status);
- }
- }
-
-
- // Tables where IP address field needs updating to accommodate IPV6
- // Set to varchar(45) - just in case something uses the IPV4 subnet (see http://en.wikipedia.org/wiki/IPV6#Notation)
- foreach ($ip_upgrade as $t => $f)
- {
- if ($sql->db_Table_exists($t))
- { // Check for table - might add some core plugin tables in here
- if ($field_info = ($sql->db_Field($t, $f, '', TRUE)))
- {
- if (strtolower($field_info['Type']) != 'varchar(45)')
- {
- if ($just_check) return update_needed('Update IP address field '.$f.' in table '.$t);
- $status = $sql->db_Select_gen("ALTER TABLE `".MPREFIX.$t."` MODIFY `{$f}` VARCHAR(45) NOT NULL DEFAULT '';") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
- $mes->add(LAN_UPDATE_26.$t.' - '.$f, $status);
- // catch_error($sql);
- }
- }
- else
- {
- // Got a strange error here
- }
- }
- }
-
- // Obsolete prefs (list at top)
- // Intentionally do this last - we may check some of them during the update
- $accum = array();
- foreach ($obs_prefs as $p)
- {
- if (isset($pref[$p]))
- {
- if ($just_check) return update_needed('Remove obsolete prefs');
- unset($pref[$p]);
- $do_save = TRUE;
- $accum[] = $p;
- }
- }
+
+
+ // List of DB tables (key) and field (value) which need changing to accommodate IPV6 addresses
+ $ip_upgrade = array('download_requests' => 'download_request_ip',
+ 'submitnews' => 'submitnews_ip',
+ 'tmp' => 'tmp_ip',
+ 'chatbox' => 'cb_ip'
+ );
+
+ $db_parser = new db_table_admin; // Class to read table defs and process them
+ $do_save = FALSE; // Set TRUE to update prefs when update complete
+ $updateMessages = array(); // Used to log actions for the admin log - TODO: will go once all converted to new class
+
+ $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing whether an update is needed
+
+
+ if (!$just_check)
+ {
+ $mes->logMessage(LAN_UPDATE_14.$e107info['e107_version'], E_MESSAGE_NODISPLAY);
+ }
+
+ // Check that custompages have been imported from current theme.php file
+ if(!array_key_exists('sitetheme_custompages',$pref))
+ {
+ $th = e107::getSingleton('themeHandler');
+ $tmp = $th->getThemeInfo($pref['sitetheme']);
+ if(is_array($tmp['custompages']))
+ {
+ if ($just_check) return update_needed();
+ $pref['sitetheme_custompages'] = $tmp['custompages'];
+ $do_save = TRUE;
+ }
+ }
+
+
+
+ // Check notify prefs
+ global $sysprefs, $eArrayStorage, $tp;
+ $notify_prefs = $sysprefs -> get('notify_prefs');
+ $notify_prefs = $eArrayStorage -> ReadArray($notify_prefs);
+
+ $nt_changed = 0;
+ if(vartrue($notify_prefs['event']))
+ {
+ foreach ($notify_prefs['event'] as $e => $d)
+ {
+ if (isset($d['type']))
+ {
+ if ($just_check) return update_needed('Notify pref: '.$e.' outdated');
+ switch ($d['type'])
+ {
+ case 'main' :
+ $notify_prefs['event'][$e]['class'] = e_UC_MAINADMIN;
+ break;
+ case 'class' : // Should already have class defined
+ break;
+ case 'email' :
+ $notify_prefs['event'][$e]['class'] = 'email';
+ break;
+ case 'off' : // Need to disable
+ default :
+ $notify_prefs['event'][$e]['class'] = e_UC_NOBODY; // Just disable if we don't know what else to do
+ }
+ $nt_changed++;
+ unset($notify_prefs['event'][$e]['type']);
+ }
+ }
+ }
+ if ($nt_changed)
+ {
+ $s_prefs = $tp -> toDB($notify_prefs);
+ $s_prefs = $eArrayStorage -> WriteArray($s_prefs);
+ // Could we use $sysprefs->set($s_prefs,'notify_prefs') instead - avoids caching problems ????
+ $status = ($sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'") === FALSE) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
+ $message = str_replace('--COUNT--',$nt_changed,LAN_UPDATE_20);
+ $mes->logMessage($message, $status);
+ }
+
+
+ $statusTexts = array(E_MESSAGE_SUCCESS => 'Success', E_MESSAGE_ERROR => 'Fail', E_MESSAGE_INFO => 'Info');
+
+ if (isset($pref['forum_user_customtitle']) && !isset($pref['signup_option_customtitle']))
+ {
+ if ($just_check) return update_needed();
+ $pref['signup_option_customtitle'] = $pref['forum_user_customtitle'];
+ unset($pref['forum_user_customtitle']);
+ $mes->logMessage(LAN_UPDATE_20.'customtitle', E_MESSAGE_SUCCESS);
+ $do_save = TRUE;
+ }
+
+ // convert all serialized core prefs to e107 ArrayStorage;
+ $serialz_qry = "SUBSTRING( e107_value,1,5)!='array' AND e107_value !='' ";
+ $serialz_qry .= "AND e107_name IN (".implode(",",$serialized_prefs).") ";
+ if(e107::getDb()->db_Select("core", "*", $serialz_qry))
+ {
+ if ($just_check) return update_needed();
+ while ($row = e107::getDb()->db_Fetch(MYSQL_ASSOC))
+ {
+ $status = e107::getDb('sql2')->db_Update('core',"e107_value=\"".convert_serialized($row['e107_value'])."\" WHERE e107_name='".$row['e107_name']."'");
+ $mes->logMessage(LAN_UPDATE_22.$row['e107_name'], $status);
+ }
+ }
+
+ //TODO de-serialize the user_prefs also.
+
+
+
+ // Move the maximum online counts from menu prefs to a separate pref - 'history'
+ $menuConfig = e107::getConfig('menu');
+ if ($menuConfig->get('most_members_online') || $menuConfig->get('most_guests_online') || $menuConfig->get('most_online_datestamp'))
+ {
+ $status = E_MESSAGE_SUCCESS;
+ if ($just_check) return update_needed('Move online counts from menupref');
+ $newPrefs = e107::getConfig('history');
+ foreach (array('most_members_online', 'most_guests_online', 'most_online_datestamp') as $v)
+ {
+ if (FALSE === $newPrefs->get($v, FALSE))
+ {
+ if (FALSE !== $menuConfig->get($v, FALSE))
+ {
+ $newPrefs->set($v,$menuConfig->get($v));
+ }
+ else
+ {
+ $newPrefs->set($v, 0);
+ }
+ }
+ $menuConfig->remove($v);
+ }
+ $result = $newPrefs->save(false, true, false);
+ if ($result === TRUE)
+ {
+ $resultMessage = 'Historic member counts updated';
+ }
+ elseif ($result === FALSE)
+ {
+ $resultMessage = 'moving historic member counts';
+ $status = E_MESSAGE_ERROR;
+ }
+ else
+ { // No change
+ $resultMessage = 'Historic member counts already updated';
+ $status = E_MESSAGE_INFO;
+ }
+ $result = $menuConfig->save(false, true, false); // Save updated menuprefs - without the counts
+ //$updateMessages[] = $statusTexts[$status].': '.$resultMessage; // Admin log message
+ $mes->logMessage($resultMessage,$status); // User message
+ }
+
+
+
+ // ++++++++ Modify Menu Paths +++++++.
+ if(varset($changeMenuPaths))
+ {
+ foreach($changeMenuPaths as $val)
+ {
+ $qry = "SELECT menu_path FROM `#menus` WHERE menu_name = '".$val['menu']."' AND (menu_path='".$val['oldpath']."' || menu_path='".$val['oldpath']."/' ) LIMIT 1";
+ if($sql->db_Select_gen($qry))
+ {
+ if ($just_check) return update_needed('Menu path changed required: '.$val['menu'].' ');
+ $updqry = "menu_path='".$val['newpath']."/' WHERE menu_name = '".$val['menu']."' AND (menu_path='".$val['oldpath']."' || menu_path='".$val['oldpath']."/' ) ";
+ $status = $sql->db_Update('menus', $updqry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
+ $mes->logMessage(LAN_UPDATE_23.''.$val['menu'].' : '.$val['oldpath'].' => '.$val['newpath'], $status); // LAN_UPDATE_25;
+ // catch_error($sql);
+ }
+ }
+ }
+
+ // Leave this one here.. just in case..
+ //delete record for online_extended_menu (now only using one online menu)
+ if($sql->db_Select('menus', '*', "menu_path='online_extended_menu' || menu_path='online_extended_menu/'"))
+ {
+ if ($just_check) return update_needed();
+
+ $row=$sql->db_Fetch();
+
+ //if online_extended is activated, we need to activate the new 'online' menu, and delete this record
+ if($row['menu_location']!=0)
+ {
+ $status = $sql->db_Update('menus', "menu_name='online_menu', menu_path='online/' WHERE menu_path='online_extended_menu' || menu_path='online_extended_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
+ $mes->logMessage(LAN_UPDATE_23."online_menu : online/", $status);
+ }
+ else
+ { //else if the menu is not active
+ //we need to delete the online_extended menu row, and change the online_menu to online
+ $sql->db_Delete('menus', " menu_path='online_extended_menu' || menu_path='online_extended_menu/' ");
+ $mes->logMessage(LAN_UPDATE_31, E_MESSAGE_SUCCESS);
+ }
+ catch_error($sql);
+ }
+
+ //change menu_path for online_menu (if it still exists)
+ if($sql->db_Select('menus', 'menu_path', "menu_path='online_menu' || menu_path='online_menu/'"))
+ {
+ if ($just_check) return update_needed();
+
+ $status = $sql->db_Update('menus', "menu_path='online/' WHERE menu_path='online_menu' || menu_path='online_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
+ $mes->logMessage(LAN_UPDATE_23."online_menu : online/", $status);
+ catch_error($sql);
+ }
+
+
+//---------------------------------------------------------
+// Comments - split user field
+//---------------------------------------------------------
+ if($sql->db_Field('comments','comment_author'))
+ {
+ if ($just_check) return update_needed('Comment table author field update');
+
+ if ((!$sql->db_Field('comments','comment_author_id')) // Check to see whether new fields already added - maybe data copy failed part way through
+ && (!$sql->db_Select_gen("ALTER TABLE `#comments`
+ ADD COLUMN comment_author_id int(10) unsigned NOT NULL default '0' AFTER `comment_author`,
+ ADD COLUMN comment_author_name varchar(100) NOT NULL default '' AFTER `comment_author_id`")))
+ {
+ // Flag error
+ // $commentMessage = LAN_UPDAXXTE_34;
+ $mes->logMessage(LAN_UPDATE_21."comments", E_MESSAGE_ERROR);
+ }
+ else
+ {
+ if (FALSE ===$sql->db_Update('comments',"comment_author_id=SUBSTRING_INDEX(`comment_author`,'.',1), comment_author_name=SUBSTRING(`comment_author` FROM POSITION('.' IN `comment_author`)+1)"))
+ {
+ // Flag error
+ $mes->logMessage(LAN_UPDATE_21.'comments', E_MESSAGE_ERROR);
+ }
+ else
+ { // Delete superceded field - comment_author
+ if (!$sql->db_Select_gen("ALTER TABLE `#comments` DROP COLUMN `comment_author`"))
+ {
+ // Flag error
+ $mes->logMessage(LAN_UPDATE_24.'comments - comment_author', E_MESSAGE_ERROR);
+ }
+ }
+ }
+
+ $mes->logMessage(LAN_UPDATE_21.'comments', E_MESSAGE_SUCCESS);
+ }
+
+
+
+ // Add index to download history
+ if (FALSE !== ($temp = addIndexToTable('download_requests', 'download_request_datestamp', $just_check, $updateMessages)))
+ {
+ if ($just_check)
+ {
+ return update_needed($temp);
+ }
+ }
+
+ // Extra index to tmp table
+ if (FALSE !== ($temp = addIndexToTable('tmp', 'tmp_time', $just_check, $updateMessages)))
+ {
+ if ($just_check)
+ {
+ return update_needed($temp);
+ }
+ }
+
+ // Extra index to rss table (if used)
+ if (FALSE !== ($temp = addIndexToTable('rss', 'rss_name', $just_check, $updateMessages, TRUE)))
+ {
+ if ($just_check)
+ {
+ return update_needed($temp);
+ }
+ }
+
+ // 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('Change front page prefs');
+ $pref['frontpage_force'] = array(e_UC_PUBLIC => '');
+ $pref['frontpage'] = array(e_UC_PUBLIC => 'news.php');
+ // $_pdateMessages[] = LAN_UPDATE_38; //FIXME
+ $mes->logMessage(LAN_UPDATE_20."frontpage",E_MESSAGE_SUCCESS);
+ $do_save = TRUE;
+ }
+
+
+ if ($sql->db_Table_exists('newsfeed'))
+ { // Need to extend field newsfeed_url varchar(250) NOT NULL default ''
+ if ($sql->db_Query("SHOW FIELDS FROM ".MPREFIX."newsfeed LIKE 'newsfeed_url'"))
+ {
+ $row = $sql -> db_Fetch();
+ if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(250)')
+ {
+ if ($just_check) return update_needed('Update newsfeed field definition');
+ $status = $sql->db_Select_gen("ALTER TABLE `".MPREFIX."newsfeed` MODIFY `newsfeed_url` VARCHAR(250) NOT NULL DEFAULT '' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
+ //$updateMessages[] = LAN_UPDATE_40;
+ $mes->logMessage(LAN_UPDATE_21."newsfeed",$status);
+ // catch_error($sql);
+ }
+ }
+ }
+
+
+ //TODO use generic function for this update.
+ if ($sql->db_Table_exists('download'))
+ { // Need to extend field download_url varchar(255) NOT NULL default ''
+ if ($sql->db_Query("SHOW FIELDS FROM ".MPREFIX."download LIKE 'download_url'"))
+ {
+ $row = $sql -> db_Fetch();
+ if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(255)')
+ {
+ if ($just_check) return update_needed('Update download table field definition');
+ $sql->db_Select_gen("ALTER TABLE `#download` MODIFY `download_url` VARCHAR(255) NOT NULL DEFAULT '' ");
+ //$updateMessages[] = LAN_UPDATE_52; //FIXME
+ $mes->logMessage(LAN_UPDATE_52, E_MESSAGE_SUCCESS);
+ catch_error($sql);
+ }
+ }
+ }
+
+ //TODO use generic function for this update.
+ if ($sql->db_Table_exists('download_mirror'))
+ { // Need to extend field download_url varchar(255) NOT NULL default ''
+ if ($sql->db_Select_gen("SHOW FIELDS FROM ".MPREFIX."download_mirror LIKE 'mirror_url'"))
+ {
+ $row = $sql -> db_Fetch();
+ if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(255)')
+ {
+ if ($just_check) return update_needed('Update download mirror table field definition');
+ $sql->db_Select_gen("ALTER TABLE `".MPREFIX."download_mirror` MODIFY `mirror_url` VARCHAR(255) NOT NULL DEFAULT '' ");
+ $mes->logMessage(LAN_UPDATE_53, E_MESSAGE_SUCCESS);
+
+ catch_error($sql);
+ }
+ }
+ }
+
+
+ // Check need for user timezone before we delete the field
+ if (varsettrue($pref['signup_option_timezone']))
+ {
+ if ($sql->db_Field('user', 'user_timezone', '', TRUE) && !$sql->db_Field('user_extended','user_timezone','',TRUE))
+ {
+ if ($just_check) return update_needed('Move user timezone info');
+ if (!copy_user_timezone())
+ { // Error doing the transfer
+ //$updateMessages[] = LAN_UPDATE_42;
+ $mes->logMessage(LAN_UPDATE_42, E_MESSAGE_ERROR);
+ return FALSE;
+ }
+ //$updateMessages[] = LAN_UPDATE_41;
+ $mes->logMessage(LAN_UPDATE_41);
+ }
+ }
+
+
+ // Tables defined in core_sql.php
+ //---------------------------------
+ if ($sql->db_Table_exists('dblog') && !$sql->db_Table_exists('admin_log'))
+ {
+ if ($just_check) return update_needed('Rename dblog to admin_log');
+ $sql->db_Select_gen('ALTER TABLE `'.MPREFIX.'dblog` RENAME `'.MPREFIX.'admin_log`');
+ catch_error($sql);
+ //$updateMessages[] = LAN_UPDATE_43;
+ $mes->logMessage(LAN_UPDATE_43, E_MESSAGE_SUCCESS);
+ }
+
+
+ // Next bit will be needed only by the brave souls who used an early CVS - probably delete before release
+ if ($sql->db_Table_exists('rl_history') && !$sql->db_Table_exists('dblog'))
+ {
+ if ($just_check) return update_needed('Rename rl_history to dblog');
+ $sql->db_Select_gen('ALTER TABLE `'.MPREFIX.'rl_history` RENAME `'.MPREFIX.'dblog`');
+ //$updateMessages[] = LAN_UPDATE_44;
+ $mes->logMessage(LAN_UPDATE_44, E_MESSAGE_SUCCESS);
+ catch_error($sql);
+ }
+
+ // New tables required (list at top. Definitions in core_sql.php)
+ foreach ($new_tables as $nt)
+ {
+ if (!$sql->db_Table_exists($nt))
+ {
+ if ($just_check) return update_needed('Add table: '.$nt);
+ // Get the definition
+ $defs = $db_parser->get_table_def($nt,e_ADMIN.'sql/core_sql.php');
+ if (count($defs)) // **** Add in table here
+ {
+ $status = $sql->db_Select_gen('CREATE TABLE `'.MPREFIX.$defs[0][1].'` ('.$defs[0][2].') TYPE='.$defs[0][3]) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
+ // $updateMessages[] = LAN_UPDATE_45.$defs[0][1];
+ $mes->logMessage(LAN_UPDATE_27.$defs[0][1], $status);
+ // catch_error($sql);
+ }
+ else
+ { // error parsing defs file
+ $mes->logMessage(LAN_UPDATE_46.$defs[0][1], E_MESSAGE_ERROR);
+ }
+ unset($defs);
+ }
+ }
+
+
+ // Tables whose definition needs changing significantly
+ $debugLevel = E107_DBG_SQLDETAILS;
+
+ foreach ($changed_tables as $ct)
+ {
+ $req_defs = $db_parser->get_table_def($ct,e_ADMIN."sql/core_sql.php");
+ $req_fields = $db_parser->parse_field_defs($req_defs[0][2]); // Required definitions
+ if ($debugLevel)
+ {
+ $mes->logMessage("Required table structure:
".$db_parser->make_field_list($req_fields), E_MESSAGE_DEBUG);
+ }
+
+ if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs)) // Adds current default prefix
+ {
+ $mes->logMessage("Couldn't get table structure: ".$ct, E_MESSAGE_DEBUG);
+ }
+ else
+ {
+// echo $db_parser->make_table_list($actual_defs);
+ $actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]);
+ if ($debugLevel)
+ {
+ $mes->logMessage("Actual table structure:
".$db_parser->make_field_list($actual_fields), E_MESSAGE_DEBUG);
+ }
+
+ $diffs = $db_parser->compare_field_lists($req_fields,$actual_fields);
+ if (count($diffs[0]))
+ { // Changes needed
+ if ($just_check) return update_needed("Field changes rqd; table: ".$ct);
+
+ // Do the changes here
+ if ($debugLevel)
+ {
+ $mes->logMessage("List of changes found:
".$db_parser->make_changes_list($diffs), E_MESSAGE_DEBUG);
+ }
+
+ $qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]);
+
+ if ($debugLevel)
+ {
+ $mes->logMessage("Update Query used: ".$qry, E_MESSAGE_DEBUG);
+ }
+
+ $status = $sql->db_Select_gen($qry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
+ $mes->logMessage(LAN_UPDATE_21.$ct, $status);
+ catch_error($sql);
+ }
+ }
+ }
+
+
+ // Plugin tables whose definition needs changing significantly
+ foreach ($pluginChangedTables as $plugName => $plugList)
+ {
+ if (plugInstalled($plugName))
+ {
+ $ttc = explode(',',$plugList);
+ foreach ($ttc as $ct)
+ {
+ $sqlDefs = e_PLUGIN.$plugName.'/'.str_replace('_menu','',$plugName).'_sql.php'; // Filename containing definitions
+// echo "Looking at file: {$sqlDefs}, table {$ct}
";
+ $req_defs = $db_parser->get_table_def($ct,$sqlDefs);
+ if (!is_array($req_defs))
+ {
+ echo "Couldn't get definitions from file {$sqlDefs}
";
+ continue;
+ }
+ $req_fields = $db_parser->parse_field_defs($req_defs[0][2]); // Required definitions
+ if (E107_DBG_SQLDETAILS)
+ {
+ $message = "Required plugin table structure:
".$db_parser->make_field_list($req_fields);
+
+ $mes->logMessage($message, E_MESSAGE_DEBUG);
+
+ }
+
+ if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs)) // Adds current default prefix
+ {
+// echo "Couldn't get table structure: {$ct}
";
+ }
+ else
+ {
+// echo $db_parser->make_table_list($actual_defs);
+ $actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]);
+ if (E107_DBG_SQLDETAILS)
+ {
+ $message= "Actual table structure:
".$db_parser->make_field_list($actual_fields);
+ $mes->logMessage($message, E_MESSAGE_DEBUG);
+ }
+
+ $diffs = $db_parser->compare_field_lists($req_fields,$actual_fields);
+ if (count($diffs[0]))
+ { // Changes needed
+ if (E107_DBG_SQLDETAILS)
+ {
+ $message = "List of changes found:
".$db_parser->make_changes_list($diffs);
+ $mes->logMessage($message, E_MESSAGE_DEBUG);
+ }
+ if ($just_check) return update_needed("Field changes rqd; plugin table: ".$ct);
+ // Do the changes here
+ $qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]);
+ if (E107_DBG_SQLDETAILS)
+ {
+ $message = "Update Query used: ".$qry."
";
+ $mes->logMessage($message, E_MESSAGE_DEBUG);
+ }
+ $sql->db_Select_gen($qry);
+ $updateMessages[] = LAN_UPDATE_51.$ct;
+ $mes->logMessage(LAN_UPDATE_51.$ct, E_MESSAGE_SUCCESS);
+ catch_error($sql);
+ }
+ }
+ }
+ }
+ }
+
+ // This has to be done after the table is upgraded
+ if($sql->db_Select('plugin', 'plugin_category', "plugin_category = ''"))
+ {
+ if ($just_check) return update_needed('Update plugin table');
+ require_once(e_HANDLER.'plugin_class.php');
+ $ep = new e107plugin;
+ $ep -> update_plugins_table();
+ // $_pdateMessages[] = LAN_UPDATE_XX24;
+ // catch_error($sql);
+ }
+
+
+ // Obsolete tables (list at top)
+ foreach ($obs_tables as $ot)
+ {
+ if ($sql->db_Table_exists($ot))
+ {
+ if ($just_check) return update_needed("Delete table: ".$ot);
+ $status = $sql->db_Select_gen('DROP TABLE `'.MPREFIX.$ot.'`') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
+ $mes->logMessage(LAN_UPDATE_25.$ot, $status);
+ }
+ }
+
+
+ // Tables where IP address field needs updating to accommodate IPV6
+ // Set to varchar(45) - just in case something uses the IPV4 subnet (see http://en.wikipedia.org/wiki/IPV6#Notation)
+ foreach ($ip_upgrade as $t => $f)
+ {
+ if ($sql->db_Table_exists($t))
+ { // Check for table - might add some core plugin tables in here
+ if ($field_info = ($sql->db_Field($t, $f, '', TRUE)))
+ {
+ if (strtolower($field_info['Type']) != 'varchar(45)')
+ {
+ if ($just_check) return update_needed('Update IP address field '.$f.' in table '.$t);
+ $status = $sql->db_Select_gen("ALTER TABLE `".MPREFIX.$t."` MODIFY `{$f}` VARCHAR(45) NOT NULL DEFAULT '';") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
+ $mes->logMessage(LAN_UPDATE_26.$t.' - '.$f, $status);
+ // catch_error($sql);
+ }
+ }
+ else
+ {
+ // Got a strange error here
+ }
+ }
+ }
+
+ // Obsolete prefs (list at top)
+ // Intentionally do this last - we may check some of them during the update
+ $accum = array();
+ foreach ($obs_prefs as $p)
+ {
+ if (isset($pref[$p]))
+ {
+ if ($just_check) return update_needed('Remove obsolete prefs');
+ unset($pref[$p]);
+ $do_save = TRUE;
+ $accum[] = $p;
+ }
+ }
//-- Media-manger import --------------------------------------------------
-
+
$med = e107::getMedia();
-
+
$count = $sql->db_Select_gen("SELECT * FROM `#core_media_cat` WHERE `media_cat_nick` = '_common' ");
if($count != 1)
- {
+ {
if ($just_check) return update_needed('Add Media-Manager Categories and Import existing images.');
- $query = "INSERT INTO `".MPREFIX."core_media_cat` (`media_cat_id`, `media_cat_nick`, `media_cat_title`, `media_cat_diz`, `media_cat_class`) VALUES
+ $query = "INSERT INTO `".MPREFIX."core_media_cat` (`media_cat_id`, `media_cat_nick`, `media_cat_title`, `media_cat_diz`, `media_cat_class`) VALUES
(0, '_common', '(Common Area)', 'Media in this category will be available in all areas of admin. ', 253),
(0, 'news', 'News', 'Will be available in the news area. ', 253),
(0, 'page', 'Custom Pages', 'Will be available in the custom pages area of admin. ', 253),
@@ -903,16 +917,16 @@ function update_706_to_800($type='')
(0, 'downloadthumb', 'Download Thumbnails', '', 253);";
mysql_query($query);
-
+
$med->import('news',e_IMAGE.'newspost_images');
$med->import('page',e_IMAGE.'custom');
$med->import('download',e_FILE.'downloadimages');
$med->import('downloadthumb',e_IMAGE.'downloadthumbs');
- }
+ }
$count = $sql->db_Select_gen("SELECT * FROM `#core_media_cat` WHERE media_cat_nick='_icon_16' OR media_cat_nick='_icon_32' ");
-
+
if($count < 2)
{
if ($just_check) return update_needed('Add icons to media-manager');
@@ -922,13 +936,13 @@ function update_706_to_800($type='')
(0, '_icon_32', 'Icons 32px', 'Available where icons are used in admin. ', 253),
(0, '_icon_48', 'Icons 48px', 'Available where icons are used in admin. ', 253),
(0, '_icon_64', 'Icons 64px', 'Available where icons are used in admin. ', 253);";
-
+
if(!mysql_query($query))
{
// echo "mysyql error";
// error or already exists.
}
-
+
$med->importIcons(e_PLUGIN);
$med->importIcons(e_IMAGE."icons/");
$med->importIcons(e_THEME.$pref['sitetheme']."/images/");
@@ -938,226 +952,282 @@ function update_706_to_800($type='')
// Any other images should be imported manually via Media Manager batch-import.
- // ------------------------------------------------------------------
-
-
- if ($do_save)
- {
- save_prefs();
- $mes->add(LAN_UPDATE_50);
- $updateMessages[] = LAN_UPDATE_50.implode(', ',$accum); // Note for admin log
- }
-
- //FIXME grab message-stack from $mes for the log.
-
- if ($just_check) return TRUE;
- $admin_log->log_event('UPDATE_01',LAN_UPDATE_14.$e107info['e107_version'].'[!br!]'.implode('[!br!]',$updateMessages),E_LOG_INFORMATIVE,''); // Log result of actual update
- return $just_check;
-}
-
-
-function update_70x_to_706($type='')
-{
- global $sql,$ns, $pref, $e107info, $admin_log, $emessage;
-
- $just_check = $type == 'do' ? FALSE : TRUE;
- if(!$sql->db_Field("plugin",5)) // not plugin_rss so just add the new one.
- {
- if ($just_check) return update_needed();
- $sql->db_Select_gen("ALTER TABLE `".MPREFIX."plugin` ADD `plugin_addons` TEXT NOT NULL ;");
- catch_error($sql);
- }
-
- //rename plugin_rss field
- if($sql->db_Field("plugin",5) == "plugin_rss")
- {
- if ($just_check) return update_needed();
- $sql->db_Select_gen("ALTER TABLE `".MPREFIX."plugin` CHANGE `plugin_rss` `plugin_addons` TEXT NOT NULL;");
- catch_error($sql);
- }
-
-
- if($sql->db_Field("dblog",5) == "dblog_query")
- {
- if ($just_check) return update_needed();
- $sql->db_Select_gen("ALTER TABLE `".MPREFIX."dblog` CHANGE `dblog_query` `dblog_title` VARCHAR( 255 ) NOT NULL DEFAULT '';");
- catch_error($sql);
- $sql->db_Select_gen("ALTER TABLE `".MPREFIX."dblog` CHANGE `dblog_remarks` `dblog_remarks` TEXT NOT NULL;");
- catch_error($sql);
- }
-
- if(!$sql->db_Field("plugin","plugin_path","UNIQUE"))
- {
- if ($just_check) return update_needed();
- if(!$sql->db_Select_gen("ALTER TABLE `".MPREFIX."plugin` ADD UNIQUE (`plugin_path`);"))
- {
- $mes = LAN_UPDATE_12." : ".ADLAN_145.".";
- //$ns -> tablerender(LAN_ERROR,$mes);
- $emessage->add($mes, E_MESSAGE_ERROR);
- catch_error($sql);
- }
- }
-
- if(!$sql->db_Field("online",6)) // online_active field
- {
- if ($just_check) return update_needed();
- $sql->db_Select_gen("ALTER TABLE ".MPREFIX."online ADD online_active INT(10) UNSIGNED NOT NULL DEFAULT '0'");
- catch_error($sql);
- }
-
- if ($sql -> db_Query("SHOW INDEX FROM ".MPREFIX."tmp"))
- {
- $row = $sql -> db_Fetch();
- if (!in_array('tmp_ip', $row))
- {
- if ($just_check) return update_needed();
- $sql->db_Select_gen("ALTER TABLE `".MPREFIX."tmp` ADD INDEX `tmp_ip` (`tmp_ip`);");
- $sql->db_Select_gen("ALTER TABLE `".MPREFIX."upload` ADD INDEX `upload_active` (`upload_active`);");
- $sql->db_Select_gen("ALTER TABLE `".MPREFIX."generic` ADD INDEX `gen_type` (`gen_type`);");
- }
- }
-
- if (!$just_check)
- {
- // update new fields
- require_once(e_HANDLER."plugin_class.php");
- $ep = new e107plugin;
- $ep->update_plugins_table();
- $ep->save_addon_prefs();
- }
-
- if (!isset($pref['displayname_maxlength']))
- {
- if ($just_check) return update_needed();
- $pref['displayname_maxlength'] = 15;
- save_prefs();
- }
-
- // If we get to here, in checking mode no updates are required. In update mode, all done.
- if ($just_check) return TRUE;
- $admin_log->log_event('UPDATE_02',LAN_UPDATE_14.$e107info['e107_version'],E_LOG_INFORMATIVE,''); // Log result of actual update
- return $just_check; // TRUE if no updates needed, FALSE if updates needed and completed
-
-}
-
-
-
-// Carries out the copy of timezone data from the user record to an extended user field
-// Return TRUE on success, FALSE on failure
-function copy_user_timezone()
-{
- global $sql, $sql2, $tp;
- require_once(e_HANDLER.'user_extended_class.php');
- $ue = new e107_user_extended;
- $tmp = $ue->parse_extended_xml('getfile');
- $tmp['timezone']['parms'] = $tp->toDB($tmp['timezone']['parms']);
- if(!$ue->user_extended_add($tmp['timezone']))
- {
- return FALSE;
- }
-
-// Created the field - now copy existing data
- if ($sql->db_Select('user','user_id, user_timezone'))
- {
- while ($row = $sql->db_Fetch())
- {
- $sql2->db_Update('user_extended',"`user_timezone`='{$row['user_timezone']}' WHERE `user_extended_id`={$row['user_id']}");
- }
- }
- return TRUE; // All done!
-}
-
-
-function update_needed($message='')
-{
- global $ns, $update_debug;
-
- $emessage = e107::getMessage();
-
- if ($update_debug) $emessage->add("Update: ".$message, E_MESSAGE_DEBUG);
- if(E107_DEBUG_LEVEL)
- {
- $tmp = debug_backtrace();
- //$ns->tablerender("", "Update required in ".basename(__FILE__)." on line ".$tmp[0]['line']."
");
- $emessage->add("Update required in ".basename(__FILE__)." on line ".$tmp[0]['line']." (".$message.")", E_MESSAGE_DEBUG);
- }
- return FALSE;
-}
-
-
-/*
-function mysql_table_exists($table)
-{
- $exists = mysql_query("SELECT 1 FROM ".MPREFIX."$table LIMIT 0");
- if ($exists) return TRUE;
- return FALSE;
-}
-*/
-
-
-// Add index to a table. Returns FALSE if not required. Returns a message if required and just checking
-function addIndexToTable($target, $indexSpec, $just_check, &$updateMessages, $optionalTable=FALSE)
-{
- global $sql;
- if (!$sql->db_Table_exists($target))
- {
- if ($optionalTable)
- {
- return !$just_check; // Nothing to do it table is optional and not there
- }
- $updateMessages[] = str_replace(array('--TABLE--','--INDEX--'),array($target,$indexSpec),LAN_UPDATE_54);
- return !$just_check; // No point carrying on - return 'nothing to do'
- }
- if ($sql->db_Select_gen("SHOW INDEX FROM ".MPREFIX.$target))
- {
- $found = FALSE;
- while ($row = $sql -> db_Fetch())
- { // One index per field
- if (in_array($indexSpec, $row))
- {
- return !$just_check; // Found - nothing to do
- }
- }
- // Index not found here
- if ($just_check)
- {
- return 'Required to add index to '.$target;
- }
- $sql->db_Select_gen("ALTER TABLE `".MPREFIX.$target."` ADD INDEX `".$indexSpec."` (`".$indexSpec."`);");
- $updateMessages[] = str_replace(array('--TABLE--','--INDEX--'),array($target,$indexSpec),LAN_UPDATE_37);
- }
- return FALSE;
-}
-
-
-/** Check for database access errors
- * @param reference $target - pointer to db object
- * @return none
- */
-function catch_error(&$target)
-{
- if (vartrue($target->getLastErrorText()) && E107_DEBUG_LEVEL != 0)
- {
- $tmp2 = debug_backtrace();
- $tmp = $target->getLastErrorText();
- echo $tmp." [ ".basename(__FILE__)." on line ".$tmp2[0]['line']."]
";
- }
- return;
-}
-
-
-function get_default_prefs()
-{
+ // ------------------------------------------------------------------
+
+
+ if ($do_save)
+ {
+ save_prefs();
+ $mes->logMessage(LAN_UPDATE_50);
+ $mes->logMessage(implode(', ', $accum), E_MESSAGE_NODISPLAY);
+ //$updateMessages[] = LAN_UPDATE_50.implode(', ',$accum); // Note for admin log
+ }
+
+ //FIXME grab message-stack from $mes for the log.
+
+ if ($just_check) return TRUE;
+ $mes->flushMessages('UPDATE_01'); // Write admin log entry, update message handler
+ //$admin_log->log_event('UPDATE_01',LAN_UPDATE_14.$e107info['e107_version'].'[!br!]'.implode('[!br!]',$updateMessages),E_LOG_INFORMATIVE,''); // Log result of actual update
+ return $just_check;
+}
+
+function core_media_import($cat,$epath)
+{
+ if(!vartrue($cat)){ return;}
+
+ if(!is_readable($epath))
+ {
+ return;
+ }
+
+ $fl = e107::getFile();
+ $tp = e107::getParser();
+ $sql = e107::getDb();
+ $mes = e107::getMessage();
+
+ $fl->setFileInfo('all');
+ $img_array = $fl->get_files($epath,'','',2);
+
+ if(!count($img_array)){ return;}
+
+ foreach($img_array as $f)
+ {
+ $fullpath = $tp->createConstants($f['path'].$f['fname'],1);
+
+ $insert = array(
+ 'media_caption' => $f['fname'],
+ 'media_description' => '',
+ 'media_category' => $cat,
+ 'media_datestamp' => $f['modified'],
+ 'media_url' => $fullpath,
+ 'media_userclass' => 0,
+ 'media_name' => $f['fname'],
+ 'media_author' => USERID,
+ 'media_size' => $f['fsize'],
+ 'media_dimensions' => $f['img-width']." x ".$f['img-height'],
+ 'media_usedby' => '',
+ 'media_tags' => '',
+ 'media_type' => $f['mime']
+ );
+
+ if(!$sql->db_Select('core_media','media_url',"media_url = '".$fullpath."' LIMIT 1"))
+ {
+ if($sql->db_Insert("core_media",$insert))
+ {
+ $mes->add("Importing Media: ".$f['fname'], E_MESSAGE_SUCCESS);
+ }
+ }
+ }
+}
+
+
+function update_70x_to_706($type='')
+{
+ global $sql,$ns, $pref, $e107info, $admin_log, $emessage;
+
+ $just_check = $type == 'do' ? FALSE : TRUE;
+ if(!$sql->db_Field("plugin",5)) // not plugin_rss so just add the new one.
+ {
+ if ($just_check) return update_needed();
+ $sql->db_Select_gen("ALTER TABLE `".MPREFIX."plugin` ADD `plugin_addons` TEXT NOT NULL ;");
+ catch_error($sql);
+ }
+
+ //rename plugin_rss field
+ if($sql->db_Field("plugin",5) == "plugin_rss")
+ {
+ if ($just_check) return update_needed();
+ $sql->db_Select_gen("ALTER TABLE `".MPREFIX."plugin` CHANGE `plugin_rss` `plugin_addons` TEXT NOT NULL;");
+ catch_error($sql);
+ }
+
+
+ if($sql->db_Field("dblog",5) == "dblog_query")
+ {
+ if ($just_check) return update_needed();
+ $sql->db_Select_gen("ALTER TABLE `".MPREFIX."dblog` CHANGE `dblog_query` `dblog_title` VARCHAR( 255 ) NOT NULL DEFAULT '';");
+ catch_error($sql);
+ $sql->db_Select_gen("ALTER TABLE `".MPREFIX."dblog` CHANGE `dblog_remarks` `dblog_remarks` TEXT NOT NULL;");
+ catch_error($sql);
+ }
+
+ if(!$sql->db_Field("plugin","plugin_path","UNIQUE"))
+ {
+ if ($just_check) return update_needed();
+ if(!$sql->db_Select_gen("ALTER TABLE `".MPREFIX."plugin` ADD UNIQUE (`plugin_path`);"))
+ {
+ $mes = LAN_UPDATE_12." : ".ADLAN_145.".";
+ //$ns -> tablerender(LAN_ERROR,$mes);
+ $emessage->add($mes, E_MESSAGE_ERROR);
+ catch_error($sql);
+ }
+ }
+
+ if(!$sql->db_Field("online",6)) // online_active field
+ {
+ if ($just_check) return update_needed();
+ $sql->db_Select_gen("ALTER TABLE ".MPREFIX."online ADD online_active INT(10) UNSIGNED NOT NULL DEFAULT '0'");
+ catch_error($sql);
+ }
+
+ if ($sql -> db_Query("SHOW INDEX FROM ".MPREFIX."tmp"))
+ {
+ $row = $sql -> db_Fetch();
+ if (!in_array('tmp_ip', $row))
+ {
+ if ($just_check) return update_needed();
+ $sql->db_Select_gen("ALTER TABLE `".MPREFIX."tmp` ADD INDEX `tmp_ip` (`tmp_ip`);");
+ $sql->db_Select_gen("ALTER TABLE `".MPREFIX."upload` ADD INDEX `upload_active` (`upload_active`);");
+ $sql->db_Select_gen("ALTER TABLE `".MPREFIX."generic` ADD INDEX `gen_type` (`gen_type`);");
+ }
+ }
+
+ if (!$just_check)
+ {
+ // update new fields
+ require_once(e_HANDLER."plugin_class.php");
+ $ep = new e107plugin;
+ $ep->update_plugins_table();
+ $ep->save_addon_prefs();
+ }
+
+ if (!isset($pref['displayname_maxlength']))
+ {
+ if ($just_check) return update_needed();
+ $pref['displayname_maxlength'] = 15;
+ save_prefs();
+ }
+
+ // If we get to here, in checking mode no updates are required. In update mode, all done.
+ if ($just_check) return TRUE;
+ $admin_log->log_event('UPDATE_02',LAN_UPDATE_14.$e107info['e107_version'],E_LOG_INFORMATIVE,''); // Log result of actual update
+ return $just_check; // TRUE if no updates needed, FALSE if updates needed and completed
+
+}
+
+
+
+// Carries out the copy of timezone data from the user record to an extended user field
+// Return TRUE on success, FALSE on failure
+function copy_user_timezone()
+{
+ global $sql, $sql2, $tp;
+ require_once(e_HANDLER.'user_extended_class.php');
+ $ue = new e107_user_extended;
+ $tmp = $ue->parse_extended_xml('getfile');
+ $tmp['timezone']['parms'] = $tp->toDB($tmp['timezone']['parms']);
+ if(!$ue->user_extended_add($tmp['timezone']))
+ {
+ return FALSE;
+ }
+
+// Created the field - now copy existing data
+ if ($sql->db_Select('user','user_id, user_timezone'))
+ {
+ while ($row = $sql->db_Fetch())
+ {
+ $sql2->db_Update('user_extended',"`user_timezone`='{$row['user_timezone']}' WHERE `user_extended_id`={$row['user_id']}");
+ }
+ }
+ return TRUE; // All done!
+}
+
+
+function update_needed($message='')
+{
+ global $ns, $update_debug;
+
+ $emessage = e107::getMessage();
+
+ if ($update_debug) $emessage->add("Update: ".$message, E_MESSAGE_DEBUG);
+ if(E107_DEBUG_LEVEL)
+ {
+ $tmp = debug_backtrace();
+ //$ns->tablerender("", "Update required in ".basename(__FILE__)." on line ".$tmp[0]['line']."
");
+ $emessage->add("Update required in ".basename(__FILE__)." on line ".$tmp[0]['line']." (".$message.")", E_MESSAGE_DEBUG);
+ }
+ return FALSE;
+}
+
+
+/*
+function mysql_table_exists($table)
+{
+ $exists = mysql_query("SELECT 1 FROM ".MPREFIX."$table LIMIT 0");
+ if ($exists) return TRUE;
+ return FALSE;
+}
+*/
+
+
+
+/**
+ * Add index to a table. Returns FALSE if not required. Returns a message if required and just checking
+ *
+ * @todo - get rid of $updateMessages parameter once log/message display method finalised, call the relevant method
+ */
+function addIndexToTable($target, $indexSpec, $just_check, &$updateMessages, $optionalTable=FALSE)
+{
+ global $sql;
+ if (!$sql->db_Table_exists($target))
+ {
+ if ($optionalTable)
+ {
+ return !$just_check; // Nothing to do it table is optional and not there
+ }
+ $updateMessages[] = str_replace(array('--TABLE--','--INDEX--'),array($target,$indexSpec),LAN_UPDATE_54);
+ return !$just_check; // No point carrying on - return 'nothing to do'
+ }
+ if ($sql->db_Select_gen("SHOW INDEX FROM ".MPREFIX.$target))
+ {
+ $found = FALSE;
+ while ($row = $sql -> db_Fetch())
+ { // One index per field
+ if (in_array($indexSpec, $row))
+ {
+ return !$just_check; // Found - nothing to do
+ }
+ }
+ // Index not found here
+ if ($just_check)
+ {
+ return 'Required to add index to '.$target;
+ }
+ $sql->db_Select_gen("ALTER TABLE `".MPREFIX.$target."` ADD INDEX `".$indexSpec."` (`".$indexSpec."`);");
+ $updateMessages[] = str_replace(array('--TABLE--','--INDEX--'),array($target,$indexSpec),LAN_UPDATE_37);
+ }
+ return FALSE;
+}
+
+
+/** Check for database access errors
+ * @param reference $target - pointer to db object
+ * @return none
+ */
+function catch_error(&$target)
+{
+ if (vartrue($target->getLastErrorText()) && E107_DEBUG_LEVEL != 0)
+ {
+ $tmp2 = debug_backtrace();
+ $tmp = $target->getLastErrorText();
+ echo $tmp." [ ".basename(__FILE__)." on line ".$tmp2[0]['line']."]
";
+ }
+ return;
+}
+
+
+function get_default_prefs()
+{
$xmlArray = e107::getSingleton('xmlClass')->loadXMLfile(e_CORE."xml/default_install.xml",'advanced');
- $pref = e107::getSingleton('xmlClass')->e107ImportPrefs($xmlArray,'core');
- return $pref;
-}
-
-function convert_serialized($serializedData)
-{
- $arrayData = unserialize($serializedData);
- return e107::getArrayStorage()->WriteArray($arrayData,FALSE);
-}
-
-
-?>
+ $pref = e107::getSingleton('xmlClass')->e107ImportPrefs($xmlArray,'core');
+ return $pref;
+}
+
+function convert_serialized($serializedData)
+{
+ $arrayData = unserialize($serializedData);
+ return e107::getArrayStorage()->WriteArray($arrayData,FALSE);
+}
+
+
+?>
diff --git a/e107_handlers/admin_log_class.php b/e107_handlers/admin_log_class.php
index f8f947299..519043859 100644
--- a/e107_handlers/admin_log_class.php
+++ b/e107_handlers/admin_log_class.php
@@ -1,5 +1,5 @@
-2, 'backtrace'=>false, );
- public $rldb = NULL; // Database used by logging routine
-
+ */
+class e_admin_log
+{
+
+ /**
+ * Contains default class options, plus any that are overidden by the constructor
+ *
+ * @var array
+ */
+ protected $_options = array('log_level'=>2, 'backtrace'=>false, );
+
+ protected $rldb = NULL; // Database used by logging routine
/**
* Log messages
* @var array
*/
protected $_messages;
- /**
- * Constructor. Sets up constants and overwrites default options where set.
- *
- * @param array $options
- * @return e_admin_log
- */
- function __construct($options = array())
- {
- foreach ($options as $key=>$val)
- {
- $this->_options[$key] = $val;
- }
-
- define("E_LOG_INFORMATIVE", 0); // Minimal Log Level, including really minor stuff
- define("E_LOG_NOTICE", 1); // More important than informative, but less important than notice
- define("E_LOG_WARNING", 2); // Not anything serious, but important information
- define("E_LOG_FATAL", 3); // An event so bad your site ceased execution.
- define("E_LOG_PLUGIN", 4); // Plugin information
-
- // Logging actions
- define("LOG_TO_ADMIN", 1);
- define("LOG_TO_AUDIT", 2);
- define("LOG_TO_ROLLING", 4);
-
- // User audit logging (intentionally start at 10 - stick to 2 digits)
- // The last two digits must match that for the corresponding log message
- define('USER_AUDIT_ADMIN', 10); // User data changed by admin
- define('USER_AUDIT_SIGNUP', 11); // User signed up
- define('USER_AUDIT_EMAILACK', 12); // User responded to registration email
- define('USER_AUDIT_LOGIN', 13); // User logged in
- define('USER_AUDIT_LOGOUT', 14); // User logged out
- define('USER_AUDIT_NEW_DN', 15); // User changed display name
- define('USER_AUDIT_NEW_PW', 16); // User changed password
- define('USER_AUDIT_NEW_EML', 17); // User changed email
- define('USER_AUDIT_PW_RES', 18); // Password reset/resent activation email
- define('USER_AUDIT_NEW_SET', 19); // User changed other settings
- define('USER_AUDIT_ADD_ADMIN', 20); // User added by admin
- define('USER_AUDIT_MAIL_BOUNCE', 21); // User mail bounce
- define('USER_AUDIT_BANNED', 22); // User banned
- define('USER_AUDIT_BOUNCE_RESET', 23); // User bounce reset
- define('USER_AUDIT_TEMP_ACCOUNT', 24); // User temporary account
+ /**
+ * Constructor. Sets up constants and overwrites default options where set.
+ *
+ * @param array $options
+ * @return none
+ */
+ public function __construct($options = array())
+ {
+ foreach ($options as $key=>$val)
+ {
+ $this->_options[$key] = $val;
+ }
+
+ define("E_LOG_INFORMATIVE", 0); // Minimal Log Level, including really minor stuff
+ define("E_LOG_NOTICE", 1); // More important than informative, but less important than notice
+ define("E_LOG_WARNING", 2); // Not anything serious, but important information
+ define("E_LOG_FATAL", 3); // An event so bad your site ceased execution.
+ define("E_LOG_PLUGIN", 4); // Plugin information
+
+ // Logging actions
+ define("LOG_TO_ADMIN", 1);
+ define("LOG_TO_AUDIT", 2);
+ define("LOG_TO_ROLLING", 4);
+
+ // User audit logging (intentionally start at 10 - stick to 2 digits)
+ // The last two digits must match that for the corresponding log message
+ define('USER_AUDIT_ADMIN', 10); // User data changed by admin
+ define('USER_AUDIT_SIGNUP', 11); // User signed up
+ define('USER_AUDIT_EMAILACK', 12); // User responded to registration email
+ define('USER_AUDIT_LOGIN', 13); // User logged in
+ define('USER_AUDIT_LOGOUT', 14); // User logged out
+ define('USER_AUDIT_NEW_DN', 15); // User changed display name
+ define('USER_AUDIT_NEW_PW', 16); // User changed password
+ define('USER_AUDIT_NEW_EML', 17); // User changed email
+ define('USER_AUDIT_PW_RES', 18); // Password reset/resent activation email
+ define('USER_AUDIT_NEW_SET', 19); // User changed other settings
+ define('USER_AUDIT_ADD_ADMIN', 20); // User added by admin
+ define('USER_AUDIT_MAIL_BOUNCE', 21); // User mail bounce
+ define('USER_AUDIT_BANNED', 22); // User banned
+ define('USER_AUDIT_BOUNCE_RESET', 23); // User bounce reset
+ define('USER_AUDIT_TEMP_ACCOUNT', 24); // User temporary account
// Init E_MESSAGE_* constants if not already done
e107::getMessage();
$this->_messages = array();
- }
-
- /**
- * Alternative admin log entry point - compatible with legacy calls, and a bit simpler to use than the generic entry point.
- * ($eventcode has been added - give it a reference to identify the source module, such as 'NEWS_12' or 'ECAL_03')
- * We also log everything (unlike 0.7, where admin log and debug stuff were all mixed up together)
- *
- * @param string $event_title
- * @param mixed $event_detail
- * @param integer $event_type [optional] Log level
- * @param unknown $event_code [optional]
- * @return e_admin_log
- */
- function log_event($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE , $event_code = '')
- {
- if ($event_code == '')
- {
- if (strlen($event_title) <= 10)
- { // Assume the title is actually a reference to the event
- $event_code = $event_title;
- $event_title = 'LAN_AL_'.$event_title;
- }
- else
- {
- $event_code = 'ADMIN';
- }
- }
- //SecretR - now supports DB array as event_detail (see e.g. db::db_Insert())
- if (is_array($event_detail))
- {
- $tmp = array();
- if (isset($event_detail['data']))
- {
- $event_detail = $event_detail['data'];
- }
- foreach ($event_detail as $k => $v)
- {
- $tmp[] = $k.'=>'.$v;
- }
- $event_detail = implode("[!br!]\n", $tmp);
- unset($tmp);
- }
-
- if ($this->_options['backtrace'] == true)
- {
- $event_detail .= "\n\n".debug_backtrace();
- }
- $this->e_log_event($event_type, -1, $event_code, $event_title, $event_detail, FALSE, LOG_TO_ADMIN);
-
- return $this;
- }
-
- /*
- Generic log entry point
- -----------------------
- Example call: (Deliberately pick separators that shouldn't be in file names)
- e_log_event(E_LOG_NOTICE,__FILE__."|".__FUNCTION__."@".__LINE__,"ECODE","Event Title","explanatory message",FALSE,LOG_TO_ADMIN);
- or:
- e_log_event(E_LOG_NOTICE,debug_backtrace(),"ECODE","Event Title","explanatory message",TRUE,LOG_TO_ROLLING);
-
- Parameters:
- $importance - importance of event - 0..4 or so
- $source_call - either: string identifying calling file/routine
- or: a number 0..9 identifying info to log from debug_backtrace()
- or: empty string, in which case first entry from debug_backtrace() logged
- or: an array, assumed to be from passing debug_backtrace() as a parameter, in which case relevant
- information is extracted and the argument list from the first entry logged
- or: -1, in which case no information logged
- $eventcode - abbreviation listing event type
- $event_title - title of event - pass standard 'LAN_ERROR_nn' defines to allow language translation
- $explain - detail of event
- $finished - if TRUE, aborts execution
- $target_logs - flags indicating which logs to update - if entry to be posted in several logs, add (or 'OR') their defines:
- LOG_TO_ADMIN - admin log
- LOG_TO_AUDIT - audit log
- LOG_TO_ROLLING - rolling log
- */
- function e_log_event($importance, $source_call, $eventcode = "GEN", $event_title = "Untitled", $explain = "", $finished = FALSE, $target_logs = LOG_TO_AUDIT )
- {
- global $pref,$e107,$tp;
-
- list($time_usec, $time_sec) = explode(" ", microtime()); // Log event time immediately to minimise uncertainty
- $time_usec = $time_usec * 1000000;
-
- if ($this->rldb == NULL)
- $this->rldb = new db; // Better use our own db - don't know what else is going on
-
- if (is_bool($target_logs))
- { // Handle the legacy stuff for now - some old code used a boolean to select admin or rolling logs
- $target_logs = $target_logs ? LOG_TO_ADMIN : LOG_TO_ROLLING;
- }
-
- //---------------------------------------
- // Calculations common to all logs
- //---------------------------------------
- $userid = (USER === TRUE) ? USERID : 0;
- $userstring = (USER === true ? USERNAME : "LAN_ANONYMOUS");
- $userIP = $e107->getip();
-
- $importance = $tp->toDB($importance, true, false, 'no_html');
- $eventcode = $tp->toDB($eventcode, true, false, 'no_html');
-
- if (is_array($explain))
- {
- $line = '';
- $spacer = '';
- foreach ($explain as $k=>$v)
- {
- $line .= $spacer.$k.'=>'.$v;
- $spacer = '[!br!]';
- }
- $explain = $line;
- unset($line);
- }
- $explain = mysql_real_escape_string($tp->toDB($explain, true, false, 'no_html'));
- $event_title = $tp->toDB($event_title, true, false, 'no_html');
-
- //---------------------------------------
- // Admin Log
- //---------------------------------------
- if ($target_logs & LOG_TO_ADMIN)
- { // Admin log - assume all fields valid
- $qry = " 0, ".intval($time_sec).','.intval($time_usec).", '{$importance}', '{$eventcode}', {$userid}, '{$userIP}', '{$event_title}', '{$explain}' ";
- $this->rldb->db_Insert("admin_log", $qry);
- }
-
- //---------------------------------------
- // Audit Log
- //---------------------------------------
- // Add in audit log here
-
- //---------------------------------------
- // Rolling Log
- //---------------------------------------
- if (($target_logs & LOG_TO_ROLLING) && varsettrue($pref['roll_log_active']))
- { // Rolling log
-
- // Process source_call info
- //---------------------------------------
- if (is_numeric($source_call) && ($source_call >= 0))
- {
- $back_count = 1;
- $i = 0;
- if (is_numeric($source_call) || ($source_call == ''))
- {
- $back_count = $source_call + 1;
- $source_call = debug_backtrace();
- $i = 1; // Don't want to print the entry parameters to this function - we know all that!
- }
- }
-
- if (is_array($source_call))
- { // Print the debug_backtrace() array
- while ($i < $back_count)
- {
- $source_call[$i]['file'] = $e107->fix_windows_paths($source_call[$i]['file']); // Needed for Windoze hosts.
- $source_call[$i]['file'] = str_replace($e107->file_path, "", $source_call[$i]['file']); // We really just want a e107 root-relative path. Strip out the root bit
- $tmp = $source_call[$i]['file']."|".$source_call[$i]['class'].$source_call[$i]['type'].$source_call[$i]['function']."@".$source_call[$i]['line'];
- foreach ($source_call[$i]['args'] as $k=>$v)
- { // Add in the arguments
- $explain .= "[!br!]".$k."=".$v;
- }
- $i++;
- if ($i < $back_count)
- $explain .= "[!br!]-------------------";
- if (!isset($tmp1))
- $tmp1 = $tmp; // Pick off the immediate caller as the source
- }
- if (isset($tmp1)) $source_call = $tmp1;
- else $source_call = 'Root level';
- }
- else
- {
- $source_call = $e107->fix_windows_paths($source_call); // Needed for Windoze hosts.
- $source_call = str_replace($e107->file_path, "", $source_call); // We really just want a e107 root-relative path. Strip out the root bit
- $source_call = $tp->toDB($source_call, true, false, 'no_html');
- }
- // else $source_call is a string
-
- // Save new rolling log record
- $this->rldb->db_Insert("dblog", "0, ".intval($time_sec).', '.intval($time_usec).", '{$importance}', '{$eventcode}', {$userid}, '{$userstring}', '{$userIP}', '{$source_call}', '{$event_title}', '{$explain}' ");
-
- // Now delete any old stuff
- $this->rldb->db_Delete("dblog", "dblog_datestamp < '".intval(time() - (varset($pref['roll_log_days'], 7) * 86400))."' ");
- }
-
- if ($finished)
- exit; // Optional abort for all logs
- }
-
- //--------------------------------------
- // USER AUDIT ENTRY
- //--------------------------------------
- // $event_code is a defined constant (see above) which specifies the event
- // $event_data is an array of data fields whose keys and values are logged (usually user data, but doesn't have to be - can add messages here)
- // $id and $u_name are left blank except for admin edits and user login, where they specify the id and login name of the 'target' user
- function user_audit($event_type, $event_data, $id = '', $u_name = '')
- {
- global $e107,$tp,$pref;
- list($time_usec, $time_sec) = explode(" ", microtime()); // Log event time immediately to minimise uncertainty
- $time_usec = $time_usec * 1000000;
-
- // See whether we should log this
- $user_logging_opts = array_flip(explode(',', varset($pref['user_audit_opts'], '')));
- if (!isset($user_logging_opts[$event_type]))
- return; // Finished if not set to log this event type
-
- if ($this->rldb == NULL)
- $this->rldb = new db; // Better use our own db - don't know what else is going on
-
- if ($id) $userid = $id;
- else $userid = (USER === TRUE) ? USERID : 0;
- if ($u_name) $userstring = $u_name;
- else $userstring = (USER === true ? USERNAME : "LAN_ANONYMOUS");
- $userIP = $e107->getip();
- $eventcode = 'USER_'.$event_type;
-
- $title = 'LAN_AUDIT_LOG_0'.$event_type; // This creates a string which will be displayed as a constant
- $spacer = '';
- $detail = '';
- foreach ($event_data as $k=>$v)
- {
- $detail .= $spacer.$k.'=>'.$v;
- $spacer = '
';
- }
- $this->rldb->db_Insert("audit_log", "0, ".intval($time_sec).', '.intval($time_usec).", '{$eventcode}', {$userid}, '{$userstring}', '{$userIP}', '{$title}', '{$detail}' ");
- }
-
- function get_log_events($count = 15, $offset)
- {
- global $sql;
- $count = intval($count);
- return "Not implemented yet";
- }
-
- /**
- * Removes all events older than $days, or truncates the table if $days == false
- *
- * @param integer|false $days
- * @return void
- */
- function purge_log_events($days)
- {
- global $sql;
- if ($days == false)
- { // $days is false, so truncate the log table
- $sql->db_Select_gen("TRUNCATE TABLE #dblog ");
- }
- else
- { // $days is set, so remove all entries older than that.
- $days = intval($days);
- $mintime = $days * 24 * 60 * 60;
- $time = time() - $mintime;
- $sql->db_Delete("dblog", "WHERE `dblog_datestamp` < {$time}", true);
- }
- }
-
- //--------------------------------------
- // HELPER ROUTINES
- //--------------------------------------
- // Generic routine to log changes to an array. Only elements in $new are checked
- // Returns true if changes, false otherwise.
- // Only makes log entry if changes detected.
- // The $old array is updated with changes, but not saved anywhere
+ }
+
+
+ /**
+ * Alternative admin log entry point - compatible with legacy calls, and a bit simpler to use than the generic entry point.
+ * ($eventcode has been added - give it a reference to identify the source module, such as 'NEWS_12' or 'ECAL_03')
+ * We also log everything (unlike 0.7, where admin log and debug stuff were all mixed up together)
+ *
+ * For multi-lingual logging (where the event title is shown in the language of the current user), LAN defines may be used in the title
+ *
+ * For generic calls, leave $event_code as empty, and specify a constant string STRING_nn of less than 10 characters for the event title
+ * Typically the 'STRING' part of the name defines the area originating the log event, and the 'nn' is a numeric code
+ * This is stored as 'LAN_AL_STRING_NN', and must be defined in a language file which is loaded during log display.
+ *
+ * @param string $event_title
+ * @param mixed $event_detail
+ * @param integer $event_type [optional] Log level
+ * @param unknown $event_code [optional]
+ * @return e_admin_log
+ */
+ public function log_event($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE , $event_code = '')
+ {
+ if ($event_code == '')
+ {
+ if (strlen($event_title) <= 10)
+ { // Assume the title is actually a reference to the event
+ $event_code = $event_title;
+ $event_title = 'LAN_AL_'.$event_title;
+ }
+ else
+ {
+ $event_code = 'ADMIN';
+ }
+ }
+ //SecretR - now supports DB array as event_detail (see e.g. db::db_Insert())
+ if (is_array($event_detail))
+ {
+ $tmp = array();
+ if (isset($event_detail['data']))
+ {
+ $event_detail = $event_detail['data'];
+ }
+ foreach ($event_detail as $k => $v)
+ {
+ $tmp[] = $k.'=>'.$v;
+ }
+ $event_detail = implode("[!br!]\n", $tmp);
+ unset($tmp);
+ }
+
+ if ($this->_options['backtrace'] == true)
+ {
+ $event_detail .= "\n\n".debug_backtrace();
+ }
+ $this->e_log_event($event_type, -1, $event_code, $event_title, $event_detail, FALSE, LOG_TO_ADMIN);
+
+ return $this;
+ }
+
+ /**
+ Generic log entry point
+ -----------------------
+ Example call: (Deliberately pick separators that shouldn't be in file names)
+ e_log_event(E_LOG_NOTICE,__FILE__."|".__FUNCTION__."@".__LINE__,"ECODE","Event Title","explanatory message",FALSE,LOG_TO_ADMIN);
+ or:
+ e_log_event(E_LOG_NOTICE,debug_backtrace(),"ECODE","Event Title","explanatory message",TRUE,LOG_TO_ROLLING);
+ *
+ * @param int $importance - importance of event - 0..4 or so
+ * @param mixed $source_call - either: string identifying calling file/routine
+ * or: a number 0..9 identifying info to log from debug_backtrace()
+ * or: empty string, in which case first entry from debug_backtrace() logged
+ * or: an array, assumed to be from passing debug_backtrace() as a parameter, in which case relevant
+ * information is extracted and the argument list from the first entry logged
+ * or: -1, in which case no information logged
+ * @param string $eventcode - abbreviation listing event type
+ * @param string $event_title - title of event - pass standard 'LAN_ERROR_nn' defines to allow language translation
+ * @param string $explain - detail of event
+ * @param bool $finished - if TRUE, aborts execution
+ * @param int $target_logs - flags indicating which logs to update - if entry to be posted in several logs, add (or 'OR') their defines:
+ * LOG_TO_ADMIN - admin log
+ * LOG_TO_AUDIT - audit log
+ * LOG_TO_ROLLING - rolling log
+ *
+ * @return none
+
+ * @todo - check microtime() call
+ */
+ public function e_log_event($importance, $source_call, $eventcode = "GEN", $event_title = "Untitled", $explain = "", $finished = FALSE, $target_logs = LOG_TO_AUDIT )
+ {
+ global $pref,$e107,$tp;
+
+ list($time_usec, $time_sec) = explode(" ", microtime(FALSE)); // Log event time immediately to minimise uncertainty
+ $time_usec = $time_usec * 1000000;
+
+ if ($this->rldb == NULL)
+ $this->rldb = new db; // Better use our own db - don't know what else is going on
+
+ if (is_bool($target_logs))
+ { // Handle the legacy stuff for now - some old code used a boolean to select admin or rolling logs
+ $target_logs = $target_logs ? LOG_TO_ADMIN : LOG_TO_ROLLING;
+ }
+
+ //---------------------------------------
+ // Calculations common to all logs
+ //---------------------------------------
+ $userid = (USER === TRUE) ? USERID : 0;
+ $userstring = (USER === true ? USERNAME : "LAN_ANONYMOUS");
+ $userIP = $e107->getip();
+
+ $importance = $tp->toDB($importance, true, false, 'no_html');
+ $eventcode = $tp->toDB($eventcode, true, false, 'no_html');
+
+ if (is_array($explain))
+ {
+ $line = '';
+ $spacer = '';
+ foreach ($explain as $k=>$v)
+ {
+ $line .= $spacer.$k.'=>'.$v;
+ $spacer = '[!br!]';
+ }
+ $explain = $line;
+ unset($line);
+ }
+ $explain = mysql_real_escape_string($tp->toDB($explain, true, false, 'no_html'));
+ $event_title = $tp->toDB($event_title, true, false, 'no_html');
+
+ //---------------------------------------
+ // Admin Log
+ //---------------------------------------
+ if ($target_logs & LOG_TO_ADMIN)
+ { // Admin log - assume all fields valid
+ $qry = " 0, ".intval($time_sec).','.intval($time_usec).", '{$importance}', '{$eventcode}', {$userid}, '{$userIP}', '{$event_title}', '{$explain}' ";
+ $this->rldb->db_Insert("admin_log", $qry);
+ }
+
+ //---------------------------------------
+ // Audit Log
+ //---------------------------------------
+ // Add in audit log here
+
+ //---------------------------------------
+ // Rolling Log
+ //---------------------------------------
+ if (($target_logs & LOG_TO_ROLLING) && varsettrue($pref['roll_log_active']))
+ { // Rolling log
+
+ // Process source_call info
+ //---------------------------------------
+ if (is_numeric($source_call) && ($source_call >= 0))
+ {
+ $back_count = 1;
+ $i = 0;
+ if (is_numeric($source_call) || ($source_call == ''))
+ {
+ $back_count = $source_call + 1;
+ $source_call = debug_backtrace();
+ $i = 1; // Don't want to print the entry parameters to this function - we know all that!
+ }
+ }
+
+ if (is_array($source_call))
+ { // Print the debug_backtrace() array
+ while ($i < $back_count)
+ {
+ $source_call[$i]['file'] = $e107->fix_windows_paths($source_call[$i]['file']); // Needed for Windoze hosts.
+ $source_call[$i]['file'] = str_replace($e107->file_path, "", $source_call[$i]['file']); // We really just want a e107 root-relative path. Strip out the root bit
+ $tmp = $source_call[$i]['file']."|".$source_call[$i]['class'].$source_call[$i]['type'].$source_call[$i]['function']."@".$source_call[$i]['line'];
+ foreach ($source_call[$i]['args'] as $k=>$v)
+ { // Add in the arguments
+ $explain .= "[!br!]".$k."=".$v;
+ }
+ $i++;
+ if ($i < $back_count)
+ $explain .= "[!br!]-------------------";
+ if (!isset($tmp1))
+ $tmp1 = $tmp; // Pick off the immediate caller as the source
+ }
+ if (isset($tmp1)) $source_call = $tmp1;
+ else $source_call = 'Root level';
+ }
+ else
+ {
+ $source_call = $e107->fix_windows_paths($source_call); // Needed for Windoze hosts.
+ $source_call = str_replace($e107->file_path, "", $source_call); // We really just want a e107 root-relative path. Strip out the root bit
+ $source_call = $tp->toDB($source_call, true, false, 'no_html');
+ }
+ // else $source_call is a string
+
+ // Save new rolling log record
+ $this->rldb->db_Insert("dblog", "0, ".intval($time_sec).', '.intval($time_usec).", '{$importance}', '{$eventcode}', {$userid}, '{$userstring}', '{$userIP}', '{$source_call}', '{$event_title}', '{$explain}' ");
+
+ // Now delete any old stuff
+ $this->rldb->db_Delete("dblog", "dblog_datestamp < '".intval(time() - (varset($pref['roll_log_days'], 7) * 86400))."' ");
+ }
+
+ if ($finished)
+ exit; // Optional abort for all logs
+ }
+
+
+
+ /**--------------------------------------
+ * USER AUDIT ENTRY
+ *--------------------------------------
+ * Log user-related events
+ * @param int $event_code is a defined constant (see above) which specifies the event
+ * @param array $event_data is an array of data fields whose keys and values are logged (usually user data, but doesn't have to be - can add messages here)
+ * @param int $id
+ * @param string $u_name
+ * both $id and $u_name are left blank except for admin edits and user login, where they specify the id and login name of the 'target' user
+ *
+ * @return none
+ */
+ function user_audit($event_type, $event_data, $id = '', $u_name = '')
+ {
+ global $e107,$tp,$pref;
+ list($time_usec, $time_sec) = explode(" ", microtime()); // Log event time immediately to minimise uncertainty
+ $time_usec = $time_usec * 1000000;
+
+ // See whether we should log this
+ $user_logging_opts = array_flip(explode(',', varset($pref['user_audit_opts'], '')));
+ if (!isset($user_logging_opts[$event_type]))
+ return; // Finished if not set to log this event type
+
+ if ($this->rldb == NULL)
+ $this->rldb = new db; // Better use our own db - don't know what else is going on
+
+ if ($id) $userid = $id;
+ else $userid = (USER === TRUE) ? USERID : 0;
+ if ($u_name) $userstring = $u_name;
+ else $userstring = (USER === true ? USERNAME : "LAN_ANONYMOUS");
+ $userIP = $e107->getip();
+ $eventcode = 'USER_'.$event_type;
+
+ $title = 'LAN_AUDIT_LOG_0'.$event_type; // This creates a string which will be displayed as a constant
+ $spacer = '';
+ $detail = '';
+ foreach ($event_data as $k=>$v)
+ {
+ $detail .= $spacer.$k.'=>'.$v;
+ $spacer = '
';
+ }
+ $this->rldb->db_Insert("audit_log", "0, ".intval($time_sec).', '.intval($time_usec).", '{$eventcode}', {$userid}, '{$userstring}', '{$userIP}', '{$title}', '{$detail}' ");
+ }
+
+
+ /* Legacy function probably not needed
+ function get_log_events($count = 15, $offset)
+ {
+ global $sql;
+ $count = intval($count);
+ return "Not implemented yet";
+ }
+ */
+
+
+
+ /**
+ * Removes all events older than $days, or truncates the table if $days == false
+ *
+ * @param integer|false $days
+ * @return void
+ */
+ public function purge_log_events($days)
+ {
+ global $sql;
+ if ($days == false)
+ { // $days is false, so truncate the log table
+ $sql->db_Select_gen("TRUNCATE TABLE #dblog ");
+ }
+ else
+ { // $days is set, so remove all entries older than that.
+ $days = intval($days);
+ $mintime = $days * 24 * 60 * 60;
+ $time = time() - $mintime;
+ $sql->db_Delete("dblog", "WHERE `dblog_datestamp` < {$time}", true);
+ }
+ }
+
+ //--------------------------------------
+ // HELPER ROUTINES
+ //--------------------------------------
+ /**
+ * Generic routine to log changes to an array. Only elements in $new are checked
+ *
+ * @param array $new - most recent data being saved
+ * @param array $old existing data - array is updated with changes, but not saved anywhere
+ * @param string $event - LAN define or string used as title in log
+ *
+ * @return bool true if changes found and logged, false otherwise.
+ */
function logArrayDiffs(&$new, &$old, $event, $logNow = true)
- {
- $changes = array();
- foreach ($new as $k=>$v)
- {
+ {
+ $changes = array();
+ foreach ($new as $k=>$v)
+ {
// FIXME - what about '' == '0'?
if ($v != varset($old[$k], ''))
- {
- $old[$k] = $v;
- $changes[] = $k.'=>'.$v;
- }
- }
- if (count($changes))
- {
+ {
+ $old[$k] = $v;
+ $changes[] = $k.'=>'.$v;
+ }
+ }
+ if (count($changes))
+ {
if($logNow) $this->log_event($event, implode('[!br!]', $changes), E_LOG_INFORMATIVE, '');
else $this->logMessage(implode('[!br!]', $changes), LOG_MESSAGE_NODISPLAY, E_MESSAGE_INFO);
- return TRUE;
- }
- return FALSE;
- }
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+
+ /**
+ * Logs an entry with all the data from an array, one field per line.
+ *
+ * @param string $event - LAN define or string used as title in log
+ * @param array $target - data to be logged
+ * @param string $extra - if non-empty, it goes on the first line.
+ * @param array $niceNames - Normally data is logged in the format keyname=>value, one per line.
+ * If the $niceName array exists and has a definition, the 'nice Name' is displayed instead of the key name
+ *
+ * @return none
+ */
+ public function logArrayAll($event, $target, $extra = '', $niceNames = NULL)
+ {
+ $logString = '';
+ if ($extra)
+ {
+ $logString = $extra.'[!br!]';
+ }
+ $spacer = '';
+ $checkNice = ($niceNames != NULL) && is_array($niceNames);
+ foreach ($target as $k=>$v)
+ {
+ if ($checkNice && isset($niceNames[$k]['niceName']))
+ {
+ $logString .= $spacer.$niceNames[$k]['niceName'].'=>'.$v;
+ }
+ else
+ {
+ $logString .= $spacer.$k.'=>'.$v;
+ }
+ $spacer = '[!br!]';
+ }
+ $this->log_event($event, $logString, E_LOG_INFORMATIVE, '');
+ }
- // Logs an entry with all the data from an array, one field per line.
- // If $extra is non-empty, it goes on the first line.
- // Normally data is in the format keyname=>value, one per line.
- // If the $niceName array exists and has a definition, the 'nice Name' is displayed instead of the key name
- function logArrayAll($event, $target, $extra = '', $niceNames = NULL)
- {
- $logString = '';
- if ($extra)
- {
- $logString = $extra.'[!br!]';
- }
- $spacer = '';
- $checkNice = ($niceNames != NULL) && is_array($niceNames);
- foreach ($target as $k=>$v)
- {
- if ($checkNice && isset($niceNames[$k]['niceName']))
- {
- $logString .= $spacer.$niceNames[$k]['niceName'].'=>'.$v;
- }
- else
- {
- $logString .= $spacer.$k.'=>'.$v;
- }
- $spacer = '[!br!]';
- }
- $this->log_event($event, $logString, E_LOG_INFORMATIVE, '');
- }
-
- /**
+ /**
* The next two routines accept and buffers messages which are destined for both admin log and message handler
- */
-
- /**
- * Add a message to the queue
- *
- * @param string $text - the message text for logging/display
+ */
+
+ /**
+ * Add a message to the queue
+ *
+ * @param string $text - the message text for logging/display
* @param int $type - the 'importance' of the message. E_MESSAGE_SUCCESS|E_MESSAGE_ERROR|E_MESSAGE_INFO|E_MESSAGE_DEBUG|E_MESSAGE_NODISPLAY
- * (Values as used in message handler, apart from the last, which causes the message to not be passed to the message handler
- * @param boolean|int $logLevel - TRUE to give same importance as for message display. FALSE to not log.
- * one of the values specified for $mesLevel to determine the prefix attached to the log message
+ * (Values as used in message handler, apart from the last, which causes the message to not be passed to the message handler
+ * @param boolean|int $logLevel - TRUE to give same importance as for message display. FALSE to not log.
+ * one of the values specified for $mesLevel to determine the prefix attached to the log message
* @param boolean $session add session message
*
* @return e_admin_log
- */
+ */
public function logMessage($text, $type = '', $logLevel = TRUE, $session = FALSE)
{
if(empty($text)) return;
@@ -437,10 +473,10 @@ class e_admin_log
* @return e_admin_log
*/
public function logSuccess($text, $message = true, $session = false)
- {
+ {
return $this->logMessage($text, ($message ? E_MESSAGE_SUCCESS : LOG_MESSAGE_NODISPLAY), E_MESSAGE_SUCCESS, $session);
- }
-
+ }
+
/**
* Log error
*
@@ -453,43 +489,44 @@ class e_admin_log
{
return $this->logMessage($text, ($message ? E_MESSAGE_ERROR : LOG_MESSAGE_NODISPLAY), E_MESSAGE_ERROR, $session);
}
-
- /**
- * Empty the messages - pass to both admin log and message handler
- *
- * @param string $logTitle - title for log entry
- * @param int $logImportance - passed directly to admin log
- * @param string $logEventCode - passed directly to admin log
- *
+
+ /**
+ * Empty the messages - pass to both admin log and message handler
+ *
+ * @param string $logTitle - title for log entry
+ * @param int $logImportance - passed directly to admin log
+ * @param string $logEventCode - passed directly to admin log
+ *
* @return e_admin_log
- */
- public function flushMessages($logTitle, $logImportance = E_LOG_INFORMATIVE, $logEventCode = '')
- {
- $mes = e107::getMessage();
-
- $resultTypes = array(E_MESSAGE_SUCCESS - 'Success', E_MESSAGE_ERROR => 'Fail'); // Add LANS here. Could add other codes
- $separator = '';
- $logString = '';
+ */
+ public function flushMessages($logTitle, $logImportance = E_LOG_INFORMATIVE, $logEventCode = '')
+ {
+ $mes = e107::getMessage();
+
+ $resultTypes = array(E_MESSAGE_SUCCESS - 'Success', E_MESSAGE_ERROR => 'Fail'); // Add LANS here. Could add other codes
+ $separator = '';
+ $logString = '';
foreach ($this->_messages as $m)
- {
- if ($m['loglevel'] !== FALSE)
- {
- $logString .= $separator;
- if ($m['loglevel'] == LOG_MESSAGE_NODISPLAY) { $logString .= ' '; } // Indent supplementary messages
+ {
+ if ($m['loglevel'] !== FALSE)
+ {
+ $logString .= $separator;
+ if ($m['loglevel'] == LOG_MESSAGE_NODISPLAY) { $logString .= ' '; } // Indent supplementary messages
+ // Not sure about next line - might want to log the
as text, rather than it forcing a newline
$logString .= strip_tags(str_replace(array('
', '
', '
'), '[!br!]', $m['message']));
- if (isset($resultTypes[$m['loglevel']]))
- {
- $logString .= ' - '.$resultTypes[$m['loglevel']];
- }
- $separator = '[!br!]';
- }
+ if (isset($resultTypes[$m['loglevel']]))
+ {
+ $logString .= ' - '.$resultTypes[$m['loglevel']];
+ }
+ $separator = '[!br!]';
+ }
if ($m['dislevel'] != LOG_MESSAGE_NODISPLAY)
- {
+ {
$mes->add($m['message'], $m['dislevel'], $m['session']);
- }
- }
- e107::getAdminLog()->log_event($logTitle, $logString, $logImportance, $logEventCode);
+ }
+ }
+ e107::getAdminLog()->log_event($logTitle, $logString, $logImportance, $logEventCode);
$this->_messages = array(); // Clear the memory for reuse
return $this;
- }
-}
+ }
+}
diff --git a/e107_handlers/pref_class.php b/e107_handlers/pref_class.php
index b895e905d..c245def17 100644
--- a/e107_handlers/pref_class.php
+++ b/e107_handlers/pref_class.php
@@ -539,7 +539,7 @@ class e_pref extends e_admin_model
if(is_array($old)) // fix install problems - no old prefs available
{
$new = $this->getPref();
- $admin_log->logArrayDiffs($new, $old, 'LAN_FIXME', false);
+ $admin_log->logArrayDiffs($new, $old, 'PREFS_02', false);
unset($new, $old);
}
if(e107::getDb()->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('".$this->prefid."_Backup', '".addslashes($dbdata)."') "))
@@ -550,7 +550,7 @@ class e_pref extends e_admin_model
}
$this->setPrefCache($this->toString(false), true); //reset pref cache - runtime & file
- $admin_log->logSuccess('Settings successfully saved.', true, $session_messages)->flushMessages('LAN_FIXME');
+ $admin_log->logSuccess('Settings successfully saved.', true, $session_messages)->flushMessages('PREFS_01');
//BC
if($this->alias === 'core')
{
@@ -562,7 +562,7 @@ class e_pref extends e_admin_model
{
$admin_log->logError('mySQL error #'.e107::getDb()->getLastErrorNumber().': '.e107::getDb()->getLastErrorText(), true, $session_messages)
->logError('Settings not saved.', true, $session_messages)
- ->flushMessages('LAN_FIXME');
+ ->flushMessages('PREFS_03');
return false;
}
}
diff --git a/e107_languages/English/admin/lan_log_messages.php b/e107_languages/English/admin/lan_log_messages.php
index 1d01bf74c..8dfc2246e 100644
--- a/e107_languages/English/admin/lan_log_messages.php
+++ b/e107_languages/English/admin/lan_log_messages.php
@@ -110,6 +110,8 @@ define('LAN_ROLL_LOG_11','Admin login fail');
// Prefs events
//-------------
define('LAN_AL_PREFS_01', 'Preferences changed');
+define('LAN_AL_PREFS_02', 'New Preferences created');
+define('LAN_AL_PREFS_03', 'Error saving prefs');
// Front Page events