--- a/includes/comment.php Mon Feb 08 17:04:08 2010 -0500
+++ b/includes/comment.php Mon Feb 08 17:04:43 2010 -0500
@@ -456,8 +456,8 @@
$name = $db->escape($name);
$username = $db->escape($session->username);
// log this action
- $q = $db->sql_query('INSERT INTO ' . table_prefix . "logs(time_id, log_type, action, page_text, author, edit_summary) VALUES\n "
- . "( " . time() . ", 'security', 'view_comment_ip', '$name', '$username', '{$_SERVER['REMOTE_ADDR']}' );");
+ $q = $db->sql_query('INSERT INTO ' . table_prefix . "logs(time_id, log_type, action, page_text, author, author_uid, edit_summary) VALUES\n "
+ . "( " . time() . ", 'security', 'view_comment_ip', '$name', '$username', $session->user_id, '{$_SERVER['REMOTE_ADDR']}' );");
if ( !$q )
$db->die_json();
--- a/includes/pageprocess.php Mon Feb 08 17:04:08 2010 -0500
+++ b/includes/pageprocess.php Mon Feb 08 17:04:43 2010 -0500
@@ -764,8 +764,8 @@
// add reupload log entry
$username = $db->escape($session->username);
- $q = $db->sql_query('INSERT INTO ' . table_prefix . "logs ( log_type, action, time_id, page_id, namespace, author, edit_summary ) VALUES\n"
- . " ( 'page', 'reupload', $time, '$this->page_id', '$this->namespace', '$username', '__ROLLBACK__' )");
+ $q = $db->sql_query('INSERT INTO ' . table_prefix . "logs ( log_type, action, time_id, page_id, namespace, author, author_uid, edit_summary ) VALUES\n"
+ . " ( 'page', 'reupload', $time, '$this->page_id', '$this->namespace', '$username', $session->user_id, '__ROLLBACK__' )");
if ( !$q )
$db->die_json();
@@ -952,8 +952,8 @@
case PROTECT_SEMI: $action = 'semiprot'; break;
}
- $sql = 'INSERT INTO ' . table_prefix . "logs ( log_type, action, page_id, namespace, author, edit_summary, time_id, page_text, date_string ) VALUES\n"
- . " ( 'page', '$action', '{$this->page_id}', '{$this->namespace}', '$username', '$reason', '$time', '$existing_protection', 'DATE_STRING COLUMN OBSOLETE, USE time_id' );";
+ $sql = 'INSERT INTO ' . table_prefix . "logs ( log_type, action, page_id, namespace, author, author_uid, edit_summary, time_id, page_text, date_string ) VALUES\n"
+ . " ( 'page', '$action', '{$this->page_id}', '{$this->namespace}', '$username', $author_uid, '$reason', '$time', '$existing_protection', 'DATE_STRING COLUMN OBSOLETE, USE time_id' );";
if ( !$db->sql_query($sql) )
{
$db->die_json();
--- a/includes/pageutils.php Mon Feb 08 17:04:08 2010 -0500
+++ b/includes/pageutils.php Mon Feb 08 17:04:43 2010 -0500
@@ -1060,8 +1060,8 @@
$db->free_result();
$minor_edit = ( ENANO_DBLAYER == 'MYSQL' ) ? 'false' : '0';
$username = $db->escape($session->username);
- $q = 'INSERT INTO ' . table_prefix . "logs ( log_type, action, time_id, date_string, page_id, namespace, page_text, char_tag, author, edit_summary, minor_edit ) VALUES\n"
- . " ('page', 'edit', " . time() . ", 'DEPRECATED', '$page_id', '$namespace', '" . $db->escape($row['page_text']) . "', '', '{$username}', '" . $lang->get('page_flushlogs_backup_summary') . "', $minor_edit);";
+ $q = 'INSERT INTO ' . table_prefix . "logs ( log_type, action, time_id, date_string, page_id, namespace, page_text, char_tag, author, author_uid, edit_summary, minor_edit ) VALUES\n"
+ . " ('page', 'edit', " . time() . ", 'DEPRECATED', '$page_id', '$namespace', '" . $db->escape($row['page_text']) . "', '', '{$username}', $session->user_id, '" . $lang->get('page_flushlogs_backup_summary') . "', $minor_edit);";
if ( !$db->sql_query($q) )
$db->_die('The history (log) entry could not be inserted into the logs table.');
}
@@ -1274,8 +1274,8 @@
// log action
$time = time();
- $q = $db->sql_query('INSERT INTO ' . table_prefix . "logs (time_id, log_type, action, edit_summary, page_text, author, page_id, namespace) VALUES\n"
- . " ( $time, 'page', 'votereset', '$delvotes', '$delvote_ips', '$username', '$page_id', '$namespace' )");
+ $q = $db->sql_query('INSERT INTO ' . table_prefix . "logs (time_id, log_type, action, edit_summary, page_text, author, author_uid, page_id, namespace) VALUES\n"
+ . " ( $time, 'page', 'votereset', '$delvotes', '$delvote_ips', '$username', $session->user_id, '$page_id', '$namespace' )");
if ( !$q )
$db->_die();
--- a/includes/plugins.php Mon Feb 08 17:04:08 2010 -0500
+++ b/includes/plugins.php Mon Feb 08 17:04:43 2010 -0500
@@ -634,7 +634,13 @@
else
{
if ( !$db->sql_query($query) )
- $db->die_json();
+ {
+ $return = array(
+ 'mode' => 'error',
+ 'error' => "[SQL] " . $db->sql_error()
+ );
+ break 2;
+ }
}
}
@@ -643,8 +649,8 @@
$ip_db = $db->escape($_SERVER['REMOTE_ADDR']);
$username_db = $db->escape($session->username);
$file_db = $db->escape($filename);
- $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
- . " ('security', 'plugin_install', $time, '$ip_db', '$username_db', '$file_db');");
+ $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, author_uid, page_text) VALUES\n"
+ . " ('security', 'plugin_install', $time, '$ip_db', '$username_db', $session->user_id, '$file_db');");
if ( !$q )
$db->_die();
@@ -790,7 +796,13 @@
else
{
if ( !$db->sql_query($query) )
- $db->die_json();
+ {
+ $return = array(
+ 'mode' => 'error',
+ 'error' => "[SQL] " . $db->sql_error()
+ );
+ break 2;
+ }
}
}
@@ -799,8 +811,8 @@
$ip_db = $db->escape($_SERVER['REMOTE_ADDR']);
$username_db = $db->escape($session->username);
$file_db = $db->escape($filename);
- $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
- . " ('security', 'plugin_uninstall', $time, '$ip_db', '$username_db', '$file_db');");
+ $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, author_uid, page_text) VALUES\n"
+ . " ('security', 'plugin_uninstall', $time, '$ip_db', '$username_db', $session->user_id, '$file_db');");
if ( !$q )
$db->_die();
@@ -1016,7 +1028,13 @@
else
{
if ( !$db->sql_query($query) )
- $db->die_json();
+ {
+ $return = array(
+ 'mode' => 'error',
+ 'error' => "[SQL] " . $db->sql_error()
+ );
+ break 2;
+ }
}
}
@@ -1025,8 +1043,8 @@
$ip_db = $db->escape($_SERVER['REMOTE_ADDR']);
$username_db = $db->escape($session->username);
$file_db = $db->escape($filename);
- $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
- . " ('security', 'plugin_upgrade', $time, '$ip_db', '$username_db', '$file_db');");
+ $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, author_uid, page_text) VALUES\n"
+ . " ('security', 'plugin_upgrade', $time, '$ip_db', '$username_db', $session->user_id, '$file_db');");
if ( !$q )
$db->_die();
--- a/includes/render.php Mon Feb 08 17:04:08 2010 -0500
+++ b/includes/render.php Mon Feb 08 17:04:43 2010 -0500
@@ -351,6 +351,32 @@
}
/**
+ * Strip out an arbitrary HTML tag, pushing on to the existing list of stripped data.
+ * @access private
+ */
+
+ public static function tag_strip_push($tag, &$text, &$stripdata)
+ {
+ if ( !is_array($stripdata) )
+ {
+ $stripdata = array(
+ 'random_id' => md5( time() . mt_rand() ),
+ 'blocks' => array()
+ );
+ }
+ $random_id =& $stripdata['random_id'];
+
+ preg_match_all("#<$tag>(.*?)</$tag>#is", $text, $blocks);
+
+ foreach ( $blocks[0] as $i => $match )
+ {
+ $j = count($stripdata['blocks']);
+ $stripdata['blocks'][] = $blocks[1][$i];
+ $text = str_replace($match, "{{$tag}:{$random_id}:{$j}}", $text);
+ }
+ }
+
+ /**
* Restore stripped <nowiki> tags.
* @access private
*/
--- a/includes/sessions.php Mon Feb 08 17:04:08 2010 -0500
+++ b/includes/sessions.php Mon Feb 08 17:04:43 2010 -0500
@@ -834,9 +834,9 @@
if($sess)
{
if($level > USER_LEVEL_MEMBER)
- $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'admin_auth_good\', '.time().', \''.enano_date(ED_DATE | ED_TIME).'\', \''.$db->escape($username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', ' . intval($level) . ')');
+ $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,author_uid,edit_summary,page_text) VALUES(\'security\', \'admin_auth_good\', '.time().', \''.enano_date(ED_DATE | ED_TIME).'\', \''.$db->escape($username).'\', ' . $row['user_id'] . ', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', ' . intval($level) . ')');
else
- $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary) VALUES(\'security\', \'auth_good\', '.time().', \''.enano_date(ED_DATE | ED_TIME).'\', \''.$db->escape($username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\')');
+ $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,author_uid,edit_summary) VALUES(\'security\', \'auth_good\', '.time().', \''.enano_date(ED_DATE | ED_TIME).'\', \''.$db->escape($username).'\', ' . $row['user_id'] . ', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\')');
$code = $plugins->setHook('login_success');
foreach ( $code as $cmd )
--- a/includes/wikiengine/parse_mediawiki.php Mon Feb 08 17:04:08 2010 -0500
+++ b/includes/wikiengine/parse_mediawiki.php Mon Feb 08 17:04:43 2010 -0500
@@ -22,7 +22,7 @@
'mailtonotext' => '#\[mailto:([^ \]]+?)\]#',
'mailtowithtext' => '#\[mailto:([^ \]]+?) (.+?)\]#',
'hr' => '/^[-]{4,} *$/m',
- 'code' => '/^<code>(?:\r?\n)?(.+?)(?:\r?\n)?<\/code>$/mis'
+ 'code' => '/^(?:<code>(?:\r?\n)?|<pre>)(.+?)(?:<\/pre>|(?:\r?\n)?<\/code>)$/mis'
);
private $blockquote_rand_id;
@@ -186,35 +186,9 @@
// Wrap all block level tags
RenderMan::tag_strip('_paragraph_bypass', $text, $_nw);
- // I'm not sure why I had to go through all these alternatives. Trying to bring it
- // all down to one by ?'ing subpatterns was causing things to return empty and throwing
- // errors in the parser. Eventually, around ~3:57AM I just settled on this motherf---er
- // of a regular expression.
-
- // FIXME: This regexp triggers a known PHP stack size issue under win32 and possibly
- // other platforms (<http://bugs.php.net/bug.php?id=47689>). The workaround is going to
- // involve writing our own parser that takes care of recursion without using the stack,
- // which is going to be a bitch, and may not make it in until Caoineag RCs.
+ // Find all opening and closing tags
- $regex = ";
- <($blocklevel)
- (?:
- # self closing, no attributes
- [ ]*/>
- |
- # self closing, attributes
- [ ][^>]+? />
- |
- # with inner text, no attributes
- >
- (?: (?R) | .*? )*</\\1>
- |
- # with inner text and attributes
- [ ][^>]+? # attributes
- >
- (?: (?R) | .*? )*</\\1>
- )
- ;sx";
+ $regex = ";(<(?:/(?:$blocklevel)|(?:$blocklevel)(?: [^>]*?)?)>);s";
// oh. and we're using this tokens thing because for identical matches, the first match will
// get wrapped X number of times instead of all matches getting wrapped once; replacing each
@@ -222,27 +196,46 @@
$tokens = array();
$rand_id = sha1(microtime() . mt_rand());
+ $tag_stack = array();
- // Temporary hack to fix crashes under win32. Sometime I'll write a loop based
- // parser for this whole section. Maybe. Perhaps the Apache folks will fix their
- // Windows binaries first.
- if ( PHP_OS == 'WIN32' || PHP_OS == 'WINNT' )
+ if ( $text_split = preg_split($regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE) )
{
- $regex = str_replace("(?: (?R) | .*? )*", "(?: .*? )", $regex);
- }
- if ( preg_match_all($regex, $text, $matches) )
- {
- foreach ( $matches[0] as $i => $match )
+ $text = '';
+ // go through the text, extract tag names, and push them to a stack.
+ foreach ( $text_split as $splitpart )
{
- $text = str_replace_once($match, "{_pb_:$rand_id:$i}", $text);
- $tokens[$i] = '<_paragraph_bypass>' . $match . '</_paragraph_bypass>';
+ if ( preg_match(";^<(/)?($blocklevel)( |>);i", $splitpart, $match) )
+ {
+ $tagname = $match[2];
+ if ( $match[1] == '/' )
+ {
+ // closing tag
+ if ( $tagname != ($top = array_pop($tag_stack)) )
+ {
+ // invalid - push back
+ array_push($tag_stack, $top);
+ }
+ else
+ {
+ // valid - if stack's at zero, add a </_paragraph_bypass>
+ if ( count($tag_stack) == 0 )
+ $splitpart .= '</_paragraph_bypass>';
+ }
+ }
+ else
+ {
+ // push
+ array_push($tag_stack, $tagname);
+ if ( count($tag_stack) == 1 )
+ $splitpart = '<_paragraph_bypass>' . $splitpart;
+ }
+ }
+ $text .= $splitpart;
}
+ //echo '<pre>' . htmlspecialchars(print_r($text, true)) . '</pre>';
}
- foreach ( $tokens as $i => $match )
- {
- $text = str_replace_once("{_pb_:$rand_id:$i}", $match, $text);
- }
+ // All things that should be para-bypassed now are surrounded by _paragraph_bypass tags.
// die('<pre>' . htmlspecialchars($text) . '</pre>');
--- a/includes/wikiengine/render_xhtml.php Mon Feb 08 17:04:08 2010 -0500
+++ b/includes/wikiengine/render_xhtml.php Mon Feb 08 17:04:43 2010 -0500
@@ -159,7 +159,7 @@
public function code($match)
{
- return '<pre>' . htmlspecialchars($match[1]) . '</pre>';
+ return '<pre class="wikitext-code"><final>' . htmlspecialchars($match[1]) . '</final></pre>';
}
}
--- a/includes/wikiformat.php Mon Feb 08 17:04:08 2010 -0500
+++ b/includes/wikiformat.php Mon Feb 08 17:04:43 2010 -0500
@@ -103,7 +103,7 @@
$parser_class = "Carpenter_Parse_" . ucwords($this->parser);
$renderer_class = "Carpenter_Render_" . ucwords($this->renderer);
- // empty?
+ // empty? (don't remove this. the parser will shit bricks later about rules returning empty strings)
if ( trim($text) === '' )
return $text;
@@ -159,7 +159,7 @@
$text = $this->perform_render_step($text, $rule, $parser, $renderer);
if ( empty($text) )
{
- trigger_error("Wikitext was empty after rule \"$rule\"; restoring backup", E_USER_WARNING);
+ trigger_error("Wikitext was completely empty after rule \"$rule\"; restoring backup", E_USER_WARNING);
$text = $text_before;
}
unset($text_before);
@@ -178,8 +178,12 @@
}
}
}
+
+ RenderMan::tag_strip_push('final', $text, $final_stripdata);
}
+ RenderMan::tag_unstrip('final', $text, $final_stripdata);
+
// run posthooks
foreach ( $this->hooks as $hook )
{
--- a/install/includes/ui.php Mon Feb 08 17:04:08 2010 -0500
+++ b/install/includes/ui.php Mon Feb 08 17:04:43 2010 -0500
@@ -173,6 +173,7 @@
var pagepass=\'\';
var ENANO_LANG_ID = 1;
var DISABLE_MCE = true;
+ var enano_version = \'' . installer_enano_version() . '\';
var msg_loading_component = \'Loading %component%...\';
</script>';
--- a/language/english/admin.json Mon Feb 08 17:04:08 2010 -0500
+++ b/language/english/admin.json Mon Feb 08 17:04:43 2010 -0500
@@ -231,6 +231,7 @@
stat_dbsize: 'Database size:',
stat_dbsize_unsupported: 'Unsupported',
stat_installdate: 'Site started:',
+ stat_installdate_ago: '(%days% %this.etc_unit_days% ago)',
stat_lastupdate: 'Last Enano upgrade:',
stat_lastupdate_never: 'Never',
--- a/plugins/admin/Home.php Mon Feb 08 17:04:08 2010 -0500
+++ b/plugins/admin/Home.php Mon Feb 08 17:04:43 2010 -0500
@@ -315,7 +315,14 @@
}
// Install date
+ $site_age = floor((time() - $install_date) / 86400);
$install_date_human = MemberlistFormatter::format_date($install_date);
+ if ( $site_age > 7 )
+ {
+ $install_date_human .= ' ' . $lang->get('acphome_stat_installdate_ago', array(
+ 'days' => number_format($site_age)
+ ));
+ }
// Last upgrade
$q = $db->sql_query('SELECT time_id FROM ' . table_prefix . "logs WHERE log_type = 'security' AND action = 'upgrade_enano' ORDER BY time_id DESC LIMIT 1;");
@@ -329,7 +336,14 @@
else
{
list($last_upgrade) = $db->fetchrow_num();
+ $ver_age = floor((time() - $last_upgrade) / 86400);
$last_upgrade = MemberlistFormatter::format_date($last_upgrade);
+ if ( $ver_age > 7 )
+ {
+ $last_upgrade .= ' ' . $lang->get('acphome_stat_installdate_ago', array(
+ 'days' => number_format($ver_age)
+ ));
+ }
}
$db->free_result();