summaryrefslogtreecommitdiff
path: root/inc/common.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/common.php')
-rw-r--r--inc/common.php45
1 files changed, 27 insertions, 18 deletions
diff --git a/inc/common.php b/inc/common.php
index 02ed2432b..3c40a47dc 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -320,13 +320,15 @@ function idfilter($id, $ue = true) {
if($conf['useslash'] && $conf['userewrite']) {
$id = strtr($id, ':', '/');
} elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' &&
- $conf['userewrite']
+ $conf['userewrite'] &&
+ strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') === false
) {
$id = strtr($id, ':', ';');
}
if($ue) {
$id = rawurlencode($id);
$id = str_replace('%3A', ':', $id); //keep as colon
+ $id = str_replace('%3B', ';', $id); //keep as semicolon
$id = str_replace('%2F', '/', $id); //keep as slash
}
return $id;
@@ -495,12 +497,13 @@ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false)
}
/**
- * Just builds a link to a script
+ * Returns the URL to the DokuWiki base script
+ *
+ * Consider using wl() instead, unless you absoutely need the doku.php endpoint
*
- * @todo maybe obsolete
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function script($script = 'doku.php') {
+function script() {
return DOKU_BASE.DOKU_SCRIPT;
}
@@ -1149,14 +1152,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 {
@@ -1196,8 +1203,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();
@@ -1205,16 +1214,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;
}