From ed964ea980be63999860aaa5f39274768eca5d59 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 14 Feb 2009 21:55:25 -0500 Subject: [PATCH 1/2] Optionally ignore some notice sources for public page We optionally ignore some notice sources from the public page. Typically these are automatic notice sources like twitterfeed that don't usually represent the community on the site very well. --- classes/Notice.php | 4 +++- config.php.sample | 8 ++++++++ lib/common.php | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 3299883686..cc7de63c20 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -136,10 +136,12 @@ class Notice extends Memcached_DataObject $notice->profile_id = $profile_id; $blacklist = common_config('public', 'blacklist'); + $autosource = common_config('public', 'autosource'); # Blacklisted are non-false, but not 1, either - if ($blacklist && in_array($profile_id, $blacklist)) { + if (($blacklist && in_array($profile_id, $blacklist)) || + ($source && $autosource && in_array($source, $autosource))) { $notice->is_local = -1; } else { $notice->is_local = $is_local; diff --git a/config.php.sample b/config.php.sample index db1a216635..efb5aa4432 100644 --- a/config.php.sample +++ b/config.php.sample @@ -107,6 +107,14 @@ $config['sphinx']['port'] = 3312; #$config['public']['blacklist'][] = 123; #$config['public']['blacklist'][] = 2307; +#Mark certain notice sources as automatic and thus not +#appropriate for public feed +#$config['public]['autosource'][] = 'twitterfeed'; +#$config['public]['autosource'][] = 'rssdent'; +#$config['public]['autosource'][] = 'Ping.Fm'; +#$config['public]['autosource'][] = 'HelloTxt'; +#$config['public]['autosource'][] = 'Updating.Me'; + #Do notice broadcasts offline #If you use this, you must run the six offline daemons in the #background. See the README for details. diff --git a/lib/common.php b/lib/common.php index 5b4e3c40c8..bf49fff6b4 100644 --- a/lib/common.php +++ b/lib/common.php @@ -100,7 +100,8 @@ $config = array('server' => null), 'public' => array('localonly' => true, - 'blacklist' => array()), + 'blacklist' => array(), + 'autosource' => array()), 'theme' => array('server' => null), 'throttle' => From 75ebd45ebdcf26849e47d3c11a2cc2aa6e946c01 Mon Sep 17 00:00:00 2001 From: Sean Murphy Date: Mon, 9 Feb 2009 17:29:27 -0500 Subject: [PATCH 2/2] Fixed #1170: Auto-linking bug when URL cotains special chars. --- lib/util.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/util.php b/lib/util.php index 7ce4e229eb..5204693bc5 100644 --- a/lib/util.php +++ b/lib/util.php @@ -412,8 +412,8 @@ function common_replace_urls_callback($text, $callback) { // Then clean up what the regex left behind $offset = 0; - foreach($matches[0] as $url) { - $url = htmlspecialchars_decode($url); + foreach($matches[0] as $orig_url) { + $url = htmlspecialchars_decode($orig_url); // Make sure we didn't pick up an email address if (preg_match('#^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$#i', $url)) continue; @@ -456,6 +456,9 @@ function common_replace_urls_callback($text, $callback) { if (!in_array($url_parts[2], $tlds)) continue; + // Put the url back the way we found it. + $url = (mb_strpos($orig_url, htmlspecialchars($url)) === FALSE) ? $url:htmlspecialchars($url); + // Call user specified func $modified_url = $callback($url);