From 87956e71a435f39a29ff391bc22da0c318f327f5 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 28 Apr 2007 21:16:32 +0000 Subject: [PATCH] - magic urls should have class="postlink", added class="postlink-local" for relative magic urls [Bug #9867] run develop/adjust_magic_urls.php to modify your post/sig/pm contents to use class="postlink" - corrected a few bugs in fulltext_mysql stats [Bug #10165] git-svn-id: file:///svn/phpbb/trunk@7424 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/develop/adjust_magic_urls.php | 126 +++++++++++++++++++++++ phpBB/includes/functions.php | 17 +-- phpBB/includes/search/fulltext_mysql.php | 9 +- phpBB/language/en/acp/search.php | 3 - 4 files changed, 140 insertions(+), 15 deletions(-) create mode 100644 phpBB/develop/adjust_magic_urls.php diff --git a/phpBB/develop/adjust_magic_urls.php b/phpBB/develop/adjust_magic_urls.php new file mode 100644 index 0000000000..1430a47a12 --- /dev/null +++ b/phpBB/develop/adjust_magic_urls.php @@ -0,0 +1,126 @@ +session_begin(); +$auth->acl($user->data); +$user->setup(); + +$echos = 0; + +$replace = array( + 'sql_freeresult($result); + + +// Now adjust posts +$sql = 'SELECT post_id, post_text + FROM ' . POSTS_TABLE; +$result = $db->sql_query($sql); + +while ($row = $db->sql_fetchrow($result)) +{ + $new_content = str_replace($replace, $with, $row['post_text']); + + if ($row['post_text'] != $new_content) + { + $sql = 'UPDATE ' . POSTS_TABLE . " SET post_text = '" . $db->sql_escape($new_content) . "' + WHERE post_id = " . $row['post_id']; + $db->sql_query($sql); + + if ($echos > 200) + { + echo '
' . "\n"; + $echos = 0; + } + + echo '.'; + $echos++; + + flush(); + } +} +$db->sql_freeresult($result); + +// Now to the private messages +$sql = 'SELECT msg_id, message_text + FROM ' . PRIVMSGS_TABLE; +$result = $db->sql_query($sql); + +while ($row = $db->sql_fetchrow($result)) +{ + $new_content = str_replace($replace, $with, $row['message_text']); + + if ($row['message_text'] != $new_content) + { + $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET bbcode_bitfield = '" . $db->sql_escape($new_content) . "' + WHERE msg_id = " . $row['msg_id']; + $db->sql_query($sql); + + if ($echos > 200) + { + echo '
' . "\n"; + $echos = 0; + } + + echo '.'; + $echos++; + + flush(); + } +} +$db->sql_freeresult($result); + +// Done +$db->sql_close(); + +?> \ No newline at end of file diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index dc10fec018..8752eca0c6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2601,7 +2601,7 @@ function generate_text_for_edit($text, $uid, $flags) * Cuts down displayed size of link if over 50 chars, turns absolute links * into relative versions when the server/script path matches the link */ -function make_clickable($text, $server_url = false) +function make_clickable($text, $server_url = false, $class = 'postlink') { if ($server_url === false) { @@ -2610,23 +2610,28 @@ function make_clickable($text, $server_url = false) static $magic_url_match; static $magic_url_replace; + static $static_class; - if (!is_array($magic_url_match)) + if (!is_array($magic_url_match) || $static_class != $class) { + $static_class = $class; + $class = ($static_class) ? ' class="' . $static_class . '"' : ''; + $local_class = ($static_class) ? ' class="' . $static_class . '-local"' : ''; + $magic_url_match = $magic_url_replace = array(); // Be sure to not let the matches cross over. ;) // relative urls for this board $magic_url_match[] = '#(^|[\n\t (])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#ie'; - $magic_url_replace[] = "'\$1
' . ((strlen('\$3')) ? preg_replace('/(&|\?)sid=[0-9a-f]{32}$/', '', preg_replace('/(&|\?)sid=[0-9a-f]{32}&/', '\\\\1', '\$3')) : '\$2/') . ''"; + $magic_url_replace[] = "'\$1' . ((strlen('\$3')) ? preg_replace('/(&|\?)sid=[0-9a-f]{32}$/', '', preg_replace('/(&|\?)sid=[0-9a-f]{32}&/', '\\\\1', '\$3')) : '\$2/') . ''"; // matches a xxxx://aaaaa.bbb.cccc. ... $magic_url_match[] = '#(^|[\n\t (])(' . get_preg_expression('url_inline') . ')#ie'; - $magic_url_replace[] = "'\$1' . ((strlen('\$2') > 55) ? str_replace('&', '&', substr(str_replace('&', '&', '\$2'), 0, 39)) . ' ... ' . str_replace('&', '&', substr(str_replace('&', '&', '\$2'), -10)) : '\$2') . ''"; + $magic_url_replace[] = "'\$1' . ((strlen('\$2') > 55) ? str_replace('&', '&', substr(str_replace('&', '&', '\$2'), 0, 39)) . ' ... ' . str_replace('&', '&', substr(str_replace('&', '&', '\$2'), -10)) : '\$2') . ''"; // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing $magic_url_match[] = '#(^|[\n\t (])(' . get_preg_expression('www_url_inline') . ')#ie'; - $magic_url_replace[] = "'\$1' . ((strlen('\$2') > 55) ? str_replace('&', '&', substr(str_replace('&', '&', '\$2'), 0, 39)) . ' ... ' . str_replace('&', '&', substr(str_replace('&', '&', '\$2'), -10)) : '\$2') . ''"; + $magic_url_replace[] = "'\$1' . ((strlen('\$2') > 55) ? str_replace('&', '&', substr(str_replace('&', '&', '\$2'), 0, 39)) . ' ... ' . str_replace('&', '&', substr(str_replace('&', '&', '\$2'), -10)) : '\$2') . ''"; // matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode. $magic_url_match[] = '/(^|[\n\t )])(' . get_preg_expression('email') . ')/ie'; @@ -3260,7 +3265,7 @@ function get_preg_expression($mode) case 'bbcode_htm': return array( '#.*?#', - '#.*?#', + '#.*?#', '#.*?#', '#