+<<<<<<< HEAD
+<?php\r
+/*\r
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
+ * Copyright (C) 2002-2012 The Nucleus Group\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ * (see nucleus/documentation/index.html#license for more info)\r
+ */\r
+/**\r
+ * Actionlog class for Nucleus\r
+ *\r
+ * @license http://nucleuscms.org/license.txt GNU General Public License\r
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group\r
+ * @version $Id: ACTIONLOG.php 1470 2010-11-29 22:10:16Z ftruscot $\r
+ */\r
+define('ERROR',1); // only errors\r
+define('WARNING',2); // errors and warnings\r
+define('INFO',3); // info, errors and warnings\r
+define('DEBUG',4); // everything\r
+$CONF['LogLevel'] = INFO;\r
+\r
+class ActionLog\r
+{\r
+ /**\r
+ * ActionLog::add()\r
+ * Method to add a message to the action log\r
+ * \r
+ * @static\r
+ * @param Integer $level log level\r
+ * @param String $message log message\r
+ * @return \r
+ * \r
+ */\r
+ function add($level, $message)\r
+ {\r
+ global $member, $CONF;\r
+ \r
+ if ( $CONF['LogLevel'] < $level )\r
+ {\r
+ return;\r
+ }\r
+ \r
+ if ( $member && $member->isLoggedIn() )\r
+ {\r
+ $message = "[" . $member->getDisplayName() . "] " . $message;\r
+ }\r
+ \r
+ $query = "INSERT INTO %s (timestamp, message) VALUES (%s, %s)";\r
+ $query = sprintf($query, sql_table('actionlog'), DB::formatDateTime(), DB::quoteValue($message));\r
+ DB::execute($query);\r
+ \r
+ self::trimLog();\r
+ return;\r
+ }\r
+ \r
+ /**\r
+ * (Static) Method to clear the whole action log\r
+ */\r
+ function clear() {\r
+ global $manager;\r
+\r
+ $query = sprintf('DELETE FROM %s', sql_table('actionlog'));\r
+\r
+ $manager->notify('ActionLogCleared',array());\r
+\r
+ return DB::execute($query) !== FALSE;\r
+ }\r
+\r
+ /**\r
+ * (Static) Method to trim the action log (from over 500 back to 250 entries)\r
+ */\r
+ function trimLog() {\r
+ static $checked = 0;\r
+\r
+ // only check once per run\r
+ if ($checked) return;\r
+\r
+ // trim\r
+ $checked = 1;\r
+\r
+ $query = sprintf('SELECT COUNT(*) AS result FROM %s', sql_table('actionlog'));\r
+ $iTotal = DB::getValue($query);\r
+\r
+ // if size > 500, drop back to about 250\r
+ $iMaxSize = 500;\r
+ $iDropSize = 250;\r
+ if ($iTotal > $iMaxSize) {\r
+ $query = sprintf('SELECT timestamp as result FROM %s ORDER BY timestamp DESC LIMIT %d,1',\r
+ sql_table('actionlog'), intval($iDropSize));\r
+ $tsChop = DB::getValue($query);\r
+ $query = sprintf("DELETE FROM %s WHERE timestamp < '%s'", sql_table('actionlog'), $tsChop);\r
+ DB::execute($query);\r
+ }\r
+\r
+ }\r
+\r
+}\r
+\r
+?>\r
+=======
<?php
/*
* Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
*
* @license http://nucleuscms.org/license.txt GNU General Public License
* @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: ACTIONLOG.php 1470 2010-11-29 22:10:16Z ftruscot $
+ * @version $Id: ACTIONLOG.php 1822 2012-05-04 13:47:22Z sakamocchi $
*/
define('ERROR',1); // only errors
define('WARNING',2); // errors and warnings
define('DEBUG',4); // everything
$CONF['LogLevel'] = INFO;
-class ACTIONLOG
+class ActionLog
{
/**
- * ACTIONLOG::add()
+ * ActionLog::add()
* Method to add a message to the action log
*
* @static
$message = "[" . $member->getDisplayName() . "] " . $message;
}
- $message = sql_real_escape_string($message); // add slashes
- $timestamp = date("Y-m-d H:i:s",time()); // format timestamp
- $query = "INSERT INTO %s (timestamp, message) VALUES ('%s', '%s')";
- $query = sprintf($query, sql_table('actionlog'), $timestamp, $message);
- sql_query($query);
+ $query = "INSERT INTO %s (timestamp, message) VALUES (%s, %s)";
+ $query = sprintf($query, sql_table('actionlog'), DB::formatDateTime(), DB::quoteValue($message));
+ DB::execute($query);
self::trimLog();
return;
function clear() {
global $manager;
- $query = 'DELETE FROM ' . sql_table('actionlog');
+ $query = sprintf('DELETE FROM %s', sql_table('actionlog'));
- $manager->notify('ActionLogCleared',array());
+ $data = array();
+ $manager->notify('ActionLogCleared', $data);
- return sql_query($query);
+ return DB::execute($query) !== FALSE;
}
/**
// trim
$checked = 1;
- $iTotal = quickQuery('SELECT COUNT(*) AS result FROM ' . sql_table('actionlog'));
+ $query = sprintf('SELECT COUNT(*) AS result FROM %s', sql_table('actionlog'));
+ $iTotal = DB::getValue($query);
// if size > 500, drop back to about 250
$iMaxSize = 500;
$iDropSize = 250;
if ($iTotal > $iMaxSize) {
- $tsChop = quickQuery('SELECT timestamp as result FROM ' . sql_table('actionlog') . ' ORDER BY timestamp DESC LIMIT '.$iDropSize.',1');
- sql_query('DELETE FROM ' . sql_table('actionlog') . ' WHERE timestamp < \'' . $tsChop . '\'');
+ $query = sprintf('SELECT timestamp as result FROM %s ORDER BY timestamp DESC LIMIT %d,1',
+ sql_table('actionlog'), intval($iDropSize));
+ $tsChop = DB::getValue($query);
+ $query = sprintf("DELETE FROM %s WHERE timestamp < '%s'", sql_table('actionlog'), $tsChop);
+ DB::execute($query);
}
}
}
-?>
\ No newline at end of file
+?>
+>>>>>>> skinnable-master