diff options
Diffstat (limited to 'inc/common.php')
-rw-r--r-- | inc/common.php | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/inc/common.php b/inc/common.php index 33da2523a..20baed6c0 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1150,14 +1150,18 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = } elseif($rev) { $subject = $lang['mail_changed'].' '.$id; $trep['OLDPAGE'] = wl($id, "rev=$rev", true, '&'); - $df = new Diff(explode("\n", rawWiki($id, $rev)), - explode("\n", rawWiki($id))); + $old_content = rawWiki($id, $rev); + $new_content = rawWiki($id); + $df = new Diff(explode("\n", $old_content), + explode("\n", $new_content)); $dformat = new UnifiedDiffFormatter(); $tdiff = $dformat->format($df); $DIFF_INLINESTYLES = true; + $hdf = new Diff(explode("\n", hsc($old_content)), + explode("\n", hsc($new_content))); $dformat = new InlineDiffFormatter(); - $hdiff = $dformat->format($df); + $hdiff = $dformat->format($hdf); $hdiff = '<table>'.$hdiff.'</table>'; $DIFF_INLINESTYLES = false; } else { @@ -1197,8 +1201,10 @@ function getGoogleQuery() { } $url = parse_url($_SERVER['HTTP_REFERER']); - $query = array(); + // only handle common SEs + if(!preg_match('/(google|bing|yahoo|ask|duckduckgo|babylon|aol|yandex)/',$url['host'])) return ''; + $query = array(); // temporary workaround against PHP bug #49733 // see http://bugs.php.net/bug.php?id=49733 if(UTF8_MBSTRING) $enc = mb_internal_encoding(); @@ -1206,16 +1212,16 @@ function getGoogleQuery() { if(UTF8_MBSTRING) mb_internal_encoding($enc); $q = ''; - if(isset($query['q'])) - $q = $query['q']; // google, live/msn, aol, ask, altavista, alltheweb, gigablast - elseif(isset($query['p'])) - $q = $query['p']; // yahoo - elseif(isset($query['query'])) - $q = $query['query']; // lycos, netscape, clusty, hotbot - elseif(preg_match("#a9\.com#i", $url['host'])) // a9 - $q = urldecode(ltrim($url['path'], '/')); - - if($q === '') return ''; + if(isset($query['q'])){ + $q = $query['q']; + }elseif(isset($query['p'])){ + $q = $query['p']; + }elseif(isset($query['query'])){ + $q = $query['query']; + } + $q = trim($q); + + if(!$q) return ''; $q = preg_split('/[\s\'"\\\\`()\]\[?:!\.{};,#+*<>\\/]+/', $q, -1, PREG_SPLIT_NO_EMPTY); return $q; } |