diff -r 1c7f59df9474 -r 93ef7df77847 plugins/admin/SecurityLog.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/admin/SecurityLog.php Wed Aug 29 23:35:06 2007 -0400
@@ -0,0 +1,160 @@
+auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ {
+ echo '
Error: Not authenticated
It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
';
+ return;
+ }
+
+ if ( defined('ENANO_DEMO_MODE') )
+ {
+ die('Security log is disabled in demo mode.');
+ }
+
+ echo 'System security log
';
+
+ // Not calling the real fetcher because we have to paginate the results
+ $offset = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0;
+ $q = $db->sql_query('SELECT COUNT(time_id) as num FROM '.table_prefix.'logs WHERE log_type=\'security\' ORDER BY time_id DESC, action ASC;');
+ if ( !$q )
+ $db->_die();
+ $row = $db->fetchrow();
+ $db->free_result();
+ $count = intval($row['num']);
+ $q = $db->sql_unbuffered_query('SELECT action,date_string,author,edit_summary,time_id,page_text FROM '.table_prefix.'logs WHERE log_type=\'security\' ORDER BY time_id DESC, action ASC;');
+ if ( !$q )
+ $db->_die();
+
+ $html = paginate(
+ $q,
+ '{time_id}',
+ $count,
+ makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'SecurityLog&offset=%s'),
+ $offset,
+ 50,
+ array('time_id' => 'seclog_format_inner'),
+ '
+ Type | Date | Username | IP Address |
',
+ '
'
+ );
+
+ echo $html;
+
+}
+
+function get_security_log($num = false)
+{
+ global $db, $session, $paths, $template, $plugins; // Common objects
+ if ( $session->auth_level < USER_LEVEL_ADMIN )
+ {
+ $q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author) VALUES("security","seclog_unauth",UNIX_TIMESTAMP(),"' . $db->escape($_SERVER['REMOTE_ADDR']) . '","' . $db->escape($session->username) . '");');
+ if ( !$q )
+ $db->_die();
+ die('Security log: unauthorized attempt to fetch. Call has been logged and reported to the administrators.');
+ }
+
+ $return = '';
+ $cls = 'row2';
+ $return .= 'Type | Date | Username | IP Address |
';
+ $hash = sha1(microtime());
+ if ( defined('ENANO_DEMO_MODE') )
+ {
+ require('config.php');
+ $hash = md5($dbpasswd);
+ unset($dbname, $dbhost, $dbuser, $dbpasswd);
+ unset($dbname, $dbhost, $dbuser, $dbpasswd); // PHP5 Zend bug
+ }
+ if ( defined('ENANO_DEMO_MODE') && !isset($_GET[ $hash ]) && substr($_SERVER['REMOTE_ADDR'], 0, 8) != '192.168.' )
+ {
+ $return .= 'Logs are recorded but not displayed for privacy purposes in the demo. |
';
+ }
+ else
+ {
+ if(is_int($num))
+ {
+ $l = 'SELECT action,date_string,author,edit_summary,time_id,page_text FROM '.table_prefix.'logs WHERE log_type=\'security\' ORDER BY time_id DESC, action ASC LIMIT '.$num.';';
+ }
+ else
+ {
+ $l = 'SELECT action,date_string,author,edit_summary,time_id,page_text FROM '.table_prefix.'logs WHERE log_type=\'security\' ORDER BY time_id DESC, action ASC;';
+ }
+ $q = $db->sql_query($l);
+ while($r = $db->fetchrow())
+ {
+ $return .= seclog_format_inner($r);
+ }
+ $db->free_result();
+ }
+ $return .= '
';
+
+ return $return;
+}
+
+function seclog_format_inner($r, $f = false)
+{
+ if ( is_array($f) )
+ {
+ unset($r);
+ $r =& $f;
+ }
+ global $db, $session, $paths, $template, $plugins; // Common objects
+ $return = '';
+ static $cls = 'row2';
+ if ( $r['action'] == 'illegal_page' )
+ {
+ list($illegal_id, $illegal_ns) = unserialize($r['page_text']);
+ $url = makeUrlNS($illegal_ns, $illegal_id, false, true);
+ $title = get_page_title_ns($illegal_id, $illegal_ns);
+ $class = ( isPage($paths->nslist[$illegal_ns] . $illegal_id) ) ? '' : ' class="wikilink-nonexistent"';
+ $illegal_link = '' . $title . '';
+ }
+ else if ( $r['action'] == 'plugin_enable' || $r['action'] == 'plugin_disable' )
+ {
+ $row['page_text'] = htmlspecialchars($row['page_text']);
+ }
+ $cls = ( $cls == 'row2' ) ? 'row1' : 'row2';
+ $return .= '';
+ switch($r['action'])
+ {
+ case "admin_auth_good": $return .= 'Successful elevated authentication'; if ( !empty($r['page_text']) ) { $level = $session->userlevel_to_string( intval($r['page_text']) ); $return .= " Authentication level: $level"; } break;
+ case "admin_auth_bad": $return .= 'Failed elevated authentication'; if ( !empty($r['page_text']) ) { $level = $session->userlevel_to_string( intval($r['page_text']) ); $return .= " Attempted auth level: $level"; } break;
+ case "activ_good": $return .= 'Successful account activation'; break;
+ case "auth_good": $return .= 'Successful regular user logon'; break;
+ case "activ_bad": $return .= 'Failed account activation'; break;
+ case "auth_bad": $return .= 'Failed regular user logon'; break;
+ case "sql_inject": $return .= 'SQL injection attemptOffending query: ' . htmlspecialchars($r['page_text']) . ' '; break;
+ case "db_backup": $return .= 'Database backup created Tables: ' . $r['page_text'] . ''; break;
+ case "install_enano": $return .= "Installed Enano version {$r['page_text']}"; break;
+ case "upgrade_enano": $return .= "Upgraded Enano to version {$r['page_text']}"; break;
+ case "illegal_page": $return .= "Unauthorized viewing attempt Page: {$illegal_link}"; break;
+ case "upload_enable": $return .= "Enabled file uploads"; break;
+ case "upload_disable": $return .= "Disabled file uploads"; break;
+ case "magick_enable": $return .= "Enabled ImageMagick for uploaded images"; break;
+ case "magick_disable": $return .= "Disabled ImageMagick for uploaded images"; break;
+ case "filehist_enable": $return .= "Enabled revision tracking for uploaded files"; break;
+ case "filehist_disable": $return .= "Disabled revision tracking for uploaded files"; break;
+ case "magick_path": $return .= "Changed path to ImageMagick executable"; break;
+ case "plugin_disable": $return .= "Disabled plugin: {$r['page_text']}"; break;
+ case "plugin_enable": $return .= "Enabled plugin: {$r['page_text']}"; break;
+ case "seclog_unauth": $return .= "Unauthorized attempt to call security log fetcher"; break;
+ }
+ $return .= ' | '.date('d M Y h:i a', $r['time_id']).' | '.$r['author'].' | '.$r['edit_summary'].' |
';
+ return $return;
+}
+
+?>