mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Improved logging of the upgrade process.
This commit is contained in:
@@ -484,11 +484,11 @@ function update_706_to_800($type='')
|
||||
|
||||
//$mes = new messageLog; // Combined logging and message displaying handler
|
||||
//$mes = e107::getMessage();
|
||||
$log = e107::getAdminLog(); // Used for combined logging and message displaying
|
||||
$sql = e107::getDb();
|
||||
$sql2 = e107::getDb('sql2');
|
||||
$tp = e107::getParser();
|
||||
$ns = e107::getRender();
|
||||
$log = e107::getAdminLog(); // Used for combined logging and message displaying
|
||||
$sql = e107::getDb();
|
||||
$sql2 = e107::getDb('sql2');
|
||||
$tp = e107::getParser();
|
||||
$ns = e107::getRender();
|
||||
|
||||
e107::getCache()->clearAll('db');
|
||||
e107::getCache()->clearAll('system');
|
||||
@@ -612,12 +612,11 @@ function update_706_to_800($type='')
|
||||
|
||||
|
||||
|
||||
|
||||
$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('Rename a core pref');
|
||||
if ($just_check) return update_needed('pref: forum_user_customtitle needs to be renamed');
|
||||
$pref['signup_option_customtitle'] = $pref['forum_user_customtitle'];
|
||||
unset($pref['forum_user_customtitle']);
|
||||
$log->logMessage(LAN_UPDATE_20.'customtitle', E_MESSAGE_SUCCESS);
|
||||
@@ -632,8 +631,9 @@ function update_706_to_800($type='')
|
||||
if ($just_check) return update_needed('Convert serialized core prefs');
|
||||
while ($row = e107::getDb()->fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$status = e107::getDb('sql2')->update('core',"e107_value=\"".convert_serialized($row['e107_value'])."\" WHERE e107_name='".$row['e107_name']."'");
|
||||
$log->logMessage(LAN_UPDATE_22.$row['e107_name'], $status);
|
||||
$status = e107::getDb('sql2')->update('core',"e107_value=\"".convert_serialized($row['e107_value'])."\" WHERE e107_name='".$row['e107_name']."'") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
|
||||
|
||||
$log->addDebug(LAN_UPDATE_22.$row['e107_name'].": ". $status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -694,7 +694,7 @@ function update_706_to_800($type='')
|
||||
$log->logMessage($resultMessage,$status); // User message
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ++++++++ Modify Menu Paths +++++++.
|
||||
if(varset($changeMenuPaths))
|
||||
@@ -764,12 +764,12 @@ function update_706_to_800($type='')
|
||||
|
||||
if(count($chgPath))
|
||||
{
|
||||
e107::getMessage()->addWarning('Before continuing, please manually delete the following outdated folders from your system: ');
|
||||
$log->addWarning('Before continuing, please manually delete the following outdated folders from your system: ');
|
||||
array_unique($chgPath);
|
||||
asort($chgPath);
|
||||
foreach($chgPath as $cgp)
|
||||
{
|
||||
e107::getMessage()->addWarning(e_PLUGIN_ABS."<b>".$cgp."</b>");
|
||||
$log->addWarning(e_PLUGIN_ABS."<b>".$cgp."</b>");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -813,7 +813,7 @@ function update_706_to_800($type='')
|
||||
$log->logMessage(LAN_UPDATE_21.'comments', E_MESSAGE_DEBUG);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Add index to download history
|
||||
// Deprecated by db-verify-class
|
||||
@@ -948,7 +948,6 @@ function update_706_to_800($type='')
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------
|
||||
if ($sql->db_Table_exists('dblog') && !$sql->db_Table_exists('admin_log'))
|
||||
{
|
||||
@@ -1120,7 +1119,7 @@ function update_706_to_800($type='')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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)
|
||||
@@ -1160,7 +1159,8 @@ function update_706_to_800($type='')
|
||||
if ($just_check) return update_needed('Remove obsolete prefs');
|
||||
unset($pref[$p]);
|
||||
$do_save = TRUE;
|
||||
$accum[] = $p;
|
||||
$log->addDebug('Removed obsolete pref: '.$p);
|
||||
// $accum[] = $p;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1188,7 +1188,7 @@ function update_706_to_800($type='')
|
||||
if ($just_check)
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
$mes->addDebug(print_a($dbv->errors,true));
|
||||
$log->addDebug(print_a($dbv->errors,true));
|
||||
return update_needed("Database Tables require updating.");
|
||||
}
|
||||
|
||||
@@ -1214,7 +1214,7 @@ function update_706_to_800($type='')
|
||||
{
|
||||
$sql->gen("ALTER TABLE `#page` DROP `page_theme`");
|
||||
$mes = e107::getMessage();
|
||||
$mes->addDebug("Successfully updated pages/menus table to new format. ");
|
||||
$log->addDebug("Successfully updated pages/menus table to new format. ");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1224,18 +1224,20 @@ function update_706_to_800($type='')
|
||||
if ($just_check) return update_needed('plugin_releaseUrl is deprecated and needs to be removed. ');
|
||||
if($sql->gen("ALTER TABLE `#plugin` DROP `plugin_releaseUrl`"))
|
||||
{
|
||||
e107::getMessage()->addDebug("Successfully removed plugin_releaseUrl. ");
|
||||
$log->addDebug("Successfully removed plugin_releaseUrl. ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --- Notify Prefs
|
||||
|
||||
// $notify_prefs = $sysprefs -> get('notify_prefs');
|
||||
// $notify_prefs = $eArrayStorage -> ReadArray($notify_prefs);
|
||||
e107::getCache()->clearAll('system');
|
||||
|
||||
|
||||
|
||||
$notify_prefs = e107::getConfig('notify',true,true)->getPref();
|
||||
|
||||
$nt_changed = 0;
|
||||
@@ -1279,7 +1281,7 @@ function update_706_to_800($type='')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// --------------- Saved emails - copy across
|
||||
@@ -1310,31 +1312,32 @@ function update_706_to_800($type='')
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------- Populate Plugin Table With Changes ------------------
|
||||
|
||||
|
||||
if (!isset($pref['shortcode_legacy_list']))
|
||||
{
|
||||
if ($just_check) return update_needed('Legacy shortcode conversion');
|
||||
// Reset, legacy and new shortcode list will be generated in plugin update routine
|
||||
$pref['shortcode_legacy_list'] = array();
|
||||
$pref['shortcode_list'] = array();
|
||||
save_prefs();
|
||||
save_prefs();
|
||||
|
||||
$ep = e107::getPlugin();
|
||||
$ep->update_plugins_table($mode); // scan for e_xxx changes and save to plugin table.
|
||||
$ep->save_addon_prefs($mode); // generate global e_xxx_list prefs from plugin table.
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This has to be done after the table is upgraded
|
||||
if($sql->db_Select('plugin', 'plugin_category', "plugin_category = ''"))
|
||||
if($sql->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('update');
|
||||
$ep->update_plugins_table('update');
|
||||
// $_pdateMessages[] = LAN_UPDATE_XX24;
|
||||
// catch_error($sql);
|
||||
}
|
||||
@@ -1342,7 +1345,7 @@ function update_706_to_800($type='')
|
||||
|
||||
//-- Media-manger import --------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
// Autogenerate filetypes.xml if not found.
|
||||
if(!is_readable(e_SYSTEM."filetypes.xml"))
|
||||
@@ -1416,10 +1419,10 @@ function update_706_to_800($type='')
|
||||
$sql->update('core_media_cat', "media_cat_owner = 'download', media_cat_category='download_image' WHERE media_cat_nick = 'download' ");
|
||||
$sql->update('core_media_cat', "media_cat_owner = 'download', media_cat_category='download_thumb' WHERE media_cat_nick = 'downloadthumb' ");
|
||||
$sql->update('core_media_cat', "media_cat_owner = 'news', media_cat_category='news_thumb' WHERE media_cat_nick = 'newsthumb' ");
|
||||
e107::getMessage()->addDebug("core-media-cat Categories and Ownership updated");
|
||||
$log->addDebug("core-media-cat Categories and Ownership updated");
|
||||
if($sql->gen("ALTER TABLE `".MPREFIX."core_media_cat` DROP `media_cat_nick`"))
|
||||
{
|
||||
e107::getMessage()->addDebug("core-media-cat `media_cat_nick` field removed.");
|
||||
$log->addDebug("core-media-cat `media_cat_nick` field removed.");
|
||||
}
|
||||
|
||||
// $query = "INSERT INTO `".MPREFIX."core_media_cat` (`media_cat_id`, `media_cat_owner`, `media_cat_category`, `media_cat_title`, `media_cat_diz`, `media_cat_class`, `media_cat_image`, `media_cat_order`) VALUES
|
||||
@@ -1428,11 +1431,11 @@ function update_706_to_800($type='')
|
||||
//
|
||||
// if(mysql_query($query))
|
||||
// {
|
||||
// e107::getMessage()->addDebug("Added core-media-cat Gallery.");
|
||||
// $log->addDebug("Added core-media-cat Gallery.");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Media Update
|
||||
$count = $sql->gen("SELECT * FROM `#core_media` WHERE media_category = 'newsthumb' OR media_category = 'downloadthumb' LIMIT 1 ");
|
||||
@@ -1442,7 +1445,7 @@ function update_706_to_800($type='')
|
||||
$sql->update('core_media', "media_category='download_image' WHERE media_category = 'download' ");
|
||||
$sql->update('core_media', "media_category='download_thumb' WHERE media_category = 'downloadthumb' ");
|
||||
$sql->update('core_media', "media_category='news_thumb' WHERE media_category = 'newsthumb' ");
|
||||
e107::getMessage()->addDebug("core-media Category names updated");
|
||||
$log->addDebug("core-media Category names updated");
|
||||
}
|
||||
|
||||
|
||||
@@ -1452,7 +1455,7 @@ function update_706_to_800($type='')
|
||||
{
|
||||
if ($just_check) return update_needed('Media-Manager Category Data needs to be updated.');
|
||||
$sql->update('core_media', "media_category='_common_image' WHERE media_category = '_common' ");
|
||||
e107::getMessage()->addDebug("core-media _common Category updated");
|
||||
$log->addDebug("core-media _common Category updated");
|
||||
}
|
||||
|
||||
|
||||
@@ -1465,7 +1468,7 @@ function update_706_to_800($type='')
|
||||
$sql->update('core_media_cat', "media_cat_category='_common_image' WHERE media_cat_category = '_common' ");
|
||||
$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, '_common', '_common_file', '(Common Area)', 'Media in this category will be available in all areas of admin. ', 253, '', 0);");
|
||||
$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_file', 'Download Files', '', 253, '', 0);");
|
||||
e107::getMessage()->addDebug("core-media-cat _common Category updated");
|
||||
$log->addDebug("core-media-cat _common Category updated");
|
||||
}
|
||||
|
||||
$count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE `media_cat_owner` = '_common' LIMIT 1 ");
|
||||
@@ -1515,7 +1518,7 @@ function update_706_to_800($type='')
|
||||
}
|
||||
else
|
||||
{
|
||||
// e107::getMessage()->addDebug("Media COUNT was ".$count. " LINE: ".__LINE__);
|
||||
// $log->addDebug("Media COUNT was ".$count. " LINE: ".__LINE__);
|
||||
}
|
||||
|
||||
// Check for Legacy Download Images.
|
||||
@@ -1563,7 +1566,7 @@ function update_706_to_800($type='')
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE media_cat_owner='_icon' ");
|
||||
|
||||
@@ -1587,7 +1590,7 @@ function update_706_to_800($type='')
|
||||
$med->importIcons(e_PLUGIN);
|
||||
$med->importIcons(e_IMAGE."icons/");
|
||||
$med->importIcons(e_THEME.$pref['sitetheme']."/images/");
|
||||
e107::getMessage()->addDebug("Icon category added");
|
||||
$log->addDebug("Icon category added");
|
||||
}
|
||||
|
||||
|
||||
@@ -1597,38 +1600,54 @@ function update_706_to_800($type='')
|
||||
|
||||
// Check that custompages have been imported from current theme.php file
|
||||
|
||||
if (!$just_check)
|
||||
|
||||
|
||||
if (!$just_check) // Running the Upgrade Process.
|
||||
{
|
||||
$th = e107::getSingleton('themeHandler');
|
||||
$tmp = $th->getThemeInfo($pref['sitetheme']);
|
||||
if($th->setTheme($pref['sitetheme'], false))
|
||||
{
|
||||
e107::getMessage()->addDebug("Updated SiteTheme prefs");
|
||||
$log->addDebug("Updated SiteTheme prefs");
|
||||
}
|
||||
else
|
||||
{
|
||||
e107::getMessage()->addDebug("Couldn't update SiteTheme prefs");
|
||||
$log->addDebug("Couldn't update SiteTheme prefs");
|
||||
}
|
||||
|
||||
$log->toFile('upgrade_v1_to_v2');
|
||||
|
||||
|
||||
if ($do_save)
|
||||
{
|
||||
save_prefs();
|
||||
$log->logMessage(LAN_UPDATE_50);
|
||||
// $log->logMessage(implode(', ', $accum), E_MESSAGE_NODISPLAY);
|
||||
|
||||
|
||||
//$updateMessages[] = LAN_UPDATE_50.implode(', ',$accum); // Note for admin log
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$log->toFile('upgrade_v1_to_v2_check');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($do_save)
|
||||
{
|
||||
save_prefs();
|
||||
$log->logMessage(LAN_UPDATE_50);
|
||||
$log->logMessage(implode(', ', $accum), E_MESSAGE_NODISPLAY);
|
||||
//$updateMessages[] = LAN_UPDATE_50.implode(', ',$accum); // Note for admin log
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//FIXME grab message-stack from $log for the log.
|
||||
|
||||
//if ($just_check) return TRUE;
|
||||
|
||||
$log->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;
|
||||
}
|
||||
@@ -1888,7 +1907,7 @@ function get_default_prefs()
|
||||
function convert_serialized($serializedData)
|
||||
{
|
||||
$arrayData = unserialize($serializedData);
|
||||
return e107::getArrayStorage()->WriteArray($arrayData,FALSE);
|
||||
return e107::serialize($arrayData,FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -39,11 +39,19 @@ class e_admin_log
|
||||
protected $_options = array('log_level'=>2, 'backtrace'=>false, );
|
||||
|
||||
protected $rldb = NULL; // Database used by logging routine
|
||||
|
||||
|
||||
|
||||
protected $logFile = null;
|
||||
/**
|
||||
* Log messages
|
||||
* @var array
|
||||
*/
|
||||
protected $_messages;
|
||||
protected $_messages;
|
||||
|
||||
|
||||
protected $_allMessages; // similar to $_messages except it is never flushed.
|
||||
|
||||
|
||||
/**
|
||||
* Constructor. Sets up constants and overwrites default options where set.
|
||||
@@ -91,10 +99,13 @@ class e_admin_log
|
||||
// e107::getMessage(); - just include, message handler is creating session in construct
|
||||
// it breaks stuff (see class2 - language detection and comments)
|
||||
require_once(e_HANDLER.'message_handler.php');
|
||||
$this->_messages = array();
|
||||
$this->_messages = array();
|
||||
$this->_allMessages = array();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @DEPRECATED
|
||||
* BC Alias of add();
|
||||
*/
|
||||
public function log_event($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE , $event_code = '')
|
||||
@@ -231,16 +242,31 @@ class e_admin_log
|
||||
$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 = " null, ".intval($time_sec).','.intval($time_usec).", '{$importance}', '{$eventcode}', {$userid}, '{$userIP}', '{$event_title}', '{$explain}' ";
|
||||
$this->rldb->db_Insert("admin_log", $qry);
|
||||
if ($target_logs & LOG_TO_ADMIN) // Admin log - assume all fields valid
|
||||
{
|
||||
// $qry = " null, ".intval($time_sec).','.intval($time_usec).", '{$importance}', '{$eventcode}', {$userid}, '{$userIP}', '{$event_title}', '{$explain}' ";
|
||||
|
||||
$adminLogInsert = array(
|
||||
'dblog_id' => null,
|
||||
'dblog_type' => $importance,
|
||||
'dblog_eventcode' => $eventcode,
|
||||
'dblog_datestamp' => time(),
|
||||
'dblog_microtime' => intval($time_usec),
|
||||
'dblog_user_id' => $userid,
|
||||
'dblog_ip' => $userIP,
|
||||
'dblog_title' => $event_title,
|
||||
'dblog_remarks' => $explain
|
||||
);
|
||||
|
||||
$this->rldb->db_Insert("admin_log", $adminLogInsert);
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
@@ -413,7 +439,7 @@ class e_admin_log
|
||||
}
|
||||
if (count($changes))
|
||||
{
|
||||
if($logNow) $this->log_event($event, implode('[!br!]', $changes), E_LOG_INFORMATIVE, '');
|
||||
if($logNow) $this->add($event, implode('[!br!]', $changes), E_LOG_INFORMATIVE, '');
|
||||
else $this->logMessage(implode('[!br!]', $changes), LOG_MESSAGE_NODISPLAY, E_MESSAGE_INFO);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -453,7 +479,7 @@ class e_admin_log
|
||||
}
|
||||
$spacer = '[!br!]';
|
||||
}
|
||||
$this->log_event($event, $logString, E_LOG_INFORMATIVE, '');
|
||||
$this->add($event, $logString, E_LOG_INFORMATIVE, '');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -476,24 +502,53 @@ class e_admin_log
|
||||
{
|
||||
if(empty($text)) return;
|
||||
if(!$type) $type = E_MESSAGE_INFO;
|
||||
if($logLevel === TRUE) $logLevel = $type;
|
||||
$this->_messages[] = array('message' => $text, 'dislevel' => $type, 'loglevel' => $logLevel, 'session' => $session);
|
||||
if($logLevel === TRUE) $logLevel = $type;
|
||||
|
||||
$logArray = array('message' => $text, 'dislevel' => $type, 'loglevel' => $logLevel, 'session' => $session, 'time'=>time());
|
||||
|
||||
$this->_messages[] = $logArray;
|
||||
$this->_allMessages[] = $logArray;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log success
|
||||
*
|
||||
* @param string $text
|
||||
* @param boolean $message if true - register with eMessage handler
|
||||
* @param boolean $session add session message
|
||||
* @return e_admin_log
|
||||
*/
|
||||
public function logSuccess($text, $message = true, $session = false)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @DEPRECATED
|
||||
* BC Alias for addSuccess();
|
||||
*/
|
||||
public function logSuccess($text, $message = true, $session = false)
|
||||
{
|
||||
return $this->logMessage($text, ($message ? E_MESSAGE_SUCCESS : LOG_MESSAGE_NODISPLAY), E_MESSAGE_SUCCESS, $session);
|
||||
return $this->addSuccess($text,$message,$session);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @DEPRECATED
|
||||
* BC Alias for addError();
|
||||
*/
|
||||
public function logError($text, $message = true, $session = false)
|
||||
{
|
||||
return $this->addError($text,$message,$session);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log success
|
||||
*
|
||||
* @param string $text
|
||||
* @param boolean $message if true - register with eMessage handler
|
||||
* @param boolean $session add session message
|
||||
* @return e_admin_log
|
||||
*/
|
||||
public function addSuccess($text, $message = true, $session = false)
|
||||
{
|
||||
return $this->logMessage($text, ($message ? E_MESSAGE_SUCCESS : LOG_MESSAGE_NODISPLAY), E_MESSAGE_SUCCESS, $session);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log error
|
||||
*
|
||||
@@ -502,11 +557,39 @@ class e_admin_log
|
||||
* @param boolean $session add session message
|
||||
* @return e_admin_log
|
||||
*/
|
||||
public function logError($text, $message = true, $session = false)
|
||||
public function addError($text, $message = true, $session = false)
|
||||
{
|
||||
return $this->logMessage($text, ($message ? E_MESSAGE_ERROR : LOG_MESSAGE_NODISPLAY), E_MESSAGE_ERROR, $session);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log Debug
|
||||
*
|
||||
* @param string $text
|
||||
* @param boolean $message if true - register with eMessage handler
|
||||
* @param boolean $session add session message
|
||||
* @return e_admin_log
|
||||
*/
|
||||
public function addDebug($text, $message = true, $session = false)
|
||||
{
|
||||
return $this->logMessage($text, ($message ? E_MESSAGE_DEBUG : LOG_MESSAGE_NODISPLAY), E_MESSAGE_NOTICE, $session);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log Warning
|
||||
*
|
||||
* @param string $text
|
||||
* @param boolean $message if true - register with eMessage handler
|
||||
* @param boolean $session add session message
|
||||
* @return e_admin_log
|
||||
*/
|
||||
public function addWarning($text, $message = true, $session = false)
|
||||
{
|
||||
return $this->logMessage($text, ($message ? E_MESSAGE_WARNING : LOG_MESSAGE_NODISPLAY), E_MESSAGE_WARNING, $session);
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty the messages - pass to both admin log and message handler
|
||||
*
|
||||
@@ -519,7 +602,7 @@ class e_admin_log
|
||||
public function flushMessages($logTitle, $logImportance = E_LOG_INFORMATIVE, $logEventCode = '', $mstack = false)
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
|
||||
|
||||
$resultTypes = array(E_MESSAGE_SUCCESS - 'Success', E_MESSAGE_ERROR => 'Fail'); // Add LANS here. Could add other codes
|
||||
$separator = '';
|
||||
$logString = '';
|
||||
@@ -547,8 +630,63 @@ class e_admin_log
|
||||
else $mes->add($m['message'], $m['dislevel'], $m['session']);
|
||||
}
|
||||
}
|
||||
e107::getAdminLog()->log_event($logTitle, $logString, $logImportance, $logEventCode);
|
||||
$this->_messages = array(); // Clear the memory for reuse
|
||||
e107::getAdminLog()->add($logTitle, $logString, $logImportance, $logEventCode);
|
||||
$this->_messages = array(); // Clear the memory for reuse
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save Message stack to File.
|
||||
*/
|
||||
private function saveToFile($logTitle='')
|
||||
{
|
||||
if($this->logFile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$text = "";
|
||||
|
||||
if(count($this->_allMessages))
|
||||
{
|
||||
$text .= " e107 CMS Log file : ".$logTitle." ".date('Y-m-d_H-i-s')."\n";
|
||||
$text .= "-------------------------------------------------------------------------------------------\n\n";
|
||||
}
|
||||
|
||||
foreach($this->_allMessages as $m)
|
||||
{
|
||||
$text .= date('Y-m-d H:i:s',$m['time'])." \t".str_pad($m['dislevel'],10," ",STR_PAD_RIGHT)."\t".strip_tags($m['message'])."\n";
|
||||
}
|
||||
|
||||
|
||||
if(file_put_contents($this->logFile,$text))
|
||||
{
|
||||
$this->_allMessages = array();
|
||||
return $this->logFile;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set and enable logging to a file.
|
||||
* Must be set PRIOR to flushMessages(). (which saves the results)
|
||||
* @param name without the extension. (ie. data prefix and .log suffix will be added automatically)
|
||||
*/
|
||||
public function toFile($name,$logTitle='')
|
||||
{
|
||||
|
||||
$date = date('Y-m-d_H-i-s');
|
||||
|
||||
$this->logFile = e_LOG.$date."_".$name.".log";
|
||||
$this->saveToFile($logTitle);
|
||||
$this->logFile = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -20,20 +20,25 @@ class ArrayData {
|
||||
function __construct()
|
||||
{
|
||||
// DO Not translate - debug info only.
|
||||
|
||||
$log = e107::getAdminLog();
|
||||
|
||||
if(E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
$dep = debug_backtrace();
|
||||
foreach($dep as $d)
|
||||
{
|
||||
e107::getMessage()->addDebug("Deprecated ArrayStorage Class called by ".str_replace(e_ROOT,"",$d['file'])." on line ".$d['line']);
|
||||
$log->addDebug("Deprecated ArrayStorage Class called by ".str_replace(e_ROOT,"",$d['file'])." on line ".$d['line']);
|
||||
}
|
||||
|
||||
$log->flushMessages('Deprecated ArrayStorage Class used.');
|
||||
|
||||
e107::getMessage()->addDebug("Please remove references to <b>arraystorage_class.php</b> and use e107::getArrayStorage(); instead.");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Return a string containg exported array data.
|
||||
*
|
||||
* @DEPRECATED use e107::serialize() instead.
|
||||
* @param array $ArrayData array to be stored
|
||||
* @param bool $AddSlashes default true, add slashes for db storage, else false
|
||||
* @return string
|
||||
@@ -51,7 +56,7 @@ class ArrayData {
|
||||
|
||||
/**
|
||||
* Returns an array from stored array data.
|
||||
*
|
||||
* @DEPRECATED use e107::unserialize() instead.
|
||||
* @param string $ArrayData
|
||||
* @return array stored data
|
||||
*/
|
||||
|
@@ -619,6 +619,7 @@ class db_verify
|
||||
function runFix($fixArray='')
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
$log = e107::getAdminLog();
|
||||
|
||||
if(!is_array($fixArray))
|
||||
{
|
||||
@@ -686,14 +687,14 @@ class db_verify
|
||||
|
||||
if(mysql_query($query))
|
||||
{
|
||||
$mes->add(LAN_UPDATED.' [ '.$query.' ]', E_MESSAGE_DEBUG);
|
||||
$log->addDebug(LAN_UPDATED.' ['.$query.']');
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->add(LAN_UPDATED_FAILED.' [ '.$query.' ]', E_MESSAGE_WARNING);
|
||||
$log->addWarning(LAN_UPDATED_FAILED.' ['.$query.']');
|
||||
if(mysql_errno())
|
||||
{
|
||||
$mes->add(' SQL #'.mysql_errno().': '.mysql_error(), E_MESSAGE_WARNING);
|
||||
$log->addWarning('SQL #'.mysql_errno().': '.mysql_error());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -701,6 +702,8 @@ class db_verify
|
||||
|
||||
} //
|
||||
}
|
||||
|
||||
$log->flushMessages();
|
||||
|
||||
}
|
||||
|
||||
|
@@ -231,12 +231,15 @@ class e107plugin
|
||||
function update_plugins_table($mode = 'upgrade')
|
||||
{
|
||||
|
||||
$sql = e107::getDb();
|
||||
$sql2 = e107::getDb('sql2');
|
||||
$tp = e107::getParser();
|
||||
$fl = e107::getFile();
|
||||
$mes = e107::getMessage();
|
||||
$sql = e107::getDb();
|
||||
$sql2 = e107::getDb('sql2');
|
||||
$tp = e107::getParser();
|
||||
$fl = e107::getFile();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
$mes->addDebug("Updating plugins Table");
|
||||
|
||||
$log = e107::getAdminLog();
|
||||
|
||||
global $mySQLprefix, $menu_pref;
|
||||
$pref = e107::getPref();
|
||||
@@ -380,12 +383,14 @@ class e107plugin
|
||||
// if (e107::getDb()->db_Insert("plugin", "0, '".$tp->toDB($pName, true)."', '".$tp->toDB($plug_info['@attributes']['version'], true)."', '".$tp->toDB($plugin_path, true)."',{$_installed}, '{$eplug_addons}', '".$this->manage_category($plug_info['category'])."' "))
|
||||
if (e107::getDb()->insert("plugin", $pInsert))
|
||||
{
|
||||
$mes->addDebug("Added <b>".$tp->toHTML($pName,false,"defs")."</b> to the plugin table.");
|
||||
$log->addDebug("Added <b>".$tp->toHTML($pName,false,"defs")."</b> to the plugin table.");
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->addDebug("Failed to add ".$tp->toHTML($pName,false,"defs")." to the plugin table.");
|
||||
$log->addDebug("Failed to add ".$tp->toHTML($pName,false,"defs")." to the plugin table.");
|
||||
}
|
||||
|
||||
$log->flushMessages("Updated Plugins table");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -473,7 +473,7 @@ class e_pref extends e_front_model
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = e107::getArrayStorage()->ReadArray($row['e107_value']);
|
||||
$data = e107::unserialize($row['e107_value']);
|
||||
}
|
||||
|
||||
$this->pref_cache = $row['e107_value']; //runtime cache
|
||||
@@ -541,7 +541,7 @@ class e_pref extends e_front_model
|
||||
|
||||
if($this->set_backup === true && !empty($this->pref_cache))
|
||||
{
|
||||
$old = e107::getArrayStorage()->ReadArray($this->pref_cache);
|
||||
$old = e107::unserialize($this->pref_cache);
|
||||
if($this->serial_bc)
|
||||
{
|
||||
$dbdata = serialize($old);
|
||||
@@ -620,7 +620,7 @@ class e_pref extends e_front_model
|
||||
$this->pref_cache = e107::getCache()->retrieve_sys('Config_'.$this->alias, 24 * 60, true);
|
||||
}
|
||||
|
||||
return ($toArray && $this->pref_cache ? e107::getArrayStorage()->ReadArray($this->pref_cache) : $this->pref_cache);
|
||||
return ($toArray && $this->pref_cache ? e107::unserialize($this->pref_cache) : $this->pref_cache);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -996,7 +996,7 @@ class prefs
|
||||
// retrieve prefs as an array of values
|
||||
function getArray($name)
|
||||
{
|
||||
return e107::getArrayStorage()->ReadArray($this->get($name));
|
||||
return e107::unserialize($this->get($name));
|
||||
// return unserialize($this->get($name));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user