From 9367e9fe5a0125bf4c2f77909f2789c9dcd41e1e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 26 Aug 2018 23:00:31 -0700 Subject: Change main router request variable from 'q' to 'req'. This is necessary to implement search in the twitter api addon, because twitter requires use of the variable 'q'. --- .htaccess | 6 +++--- Zotlabs/Lib/Libzotdir.php | 2 +- Zotlabs/Module/Connections.php | 2 +- Zotlabs/Module/Directory.php | 2 +- Zotlabs/Module/Photos.php | 4 ++-- Zotlabs/Module/Rpost.php | 2 +- Zotlabs/Module/Viewconnections.php | 2 +- boot.php | 8 ++++---- include/dir_fns.php | 2 +- include/text.php | 4 ++-- library/OAuth1.php | 4 ++-- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.htaccess b/.htaccess index 3420313a5..7a265eda1 100644 --- a/.htaccess +++ b/.htaccess @@ -20,15 +20,15 @@ AddType audio/ogg .oga RewriteRule "(^|/)\.git" - [F] RewriteRule "(^|/)store" - [F] - # Rewrite current-style URLs of the form 'index.php?q=x'. + # Rewrite current-style URLs of the form 'index.php?req=x'. # Also place auth information into REMOTE_USER for sites running # in CGI mode. RewriteCond %{REQUEST_URI} ^/\.well\-known/.* - RewriteRule ^(.*)$ index.php?q=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA] + RewriteRule ^(.*)$ index.php?req=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule ^(.*)$ index.php?q=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA] + RewriteRule ^(.*)$ index.php?req=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA] diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php index 91d089c86..81a5b3319 100644 --- a/Zotlabs/Lib/Libzotdir.php +++ b/Zotlabs/Lib/Libzotdir.php @@ -152,7 +152,7 @@ class Libzotdir { unset($tmp['pubforums']); unset($tmp['global']); unset($tmp['safe']); - unset($tmp['q']); + unset($tmp['req']); unset($tmp['f']); $forumsurl = $url . http_build_query($tmp) . $suggest; diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index cecada769..48b59cb8c 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -326,7 +326,7 @@ class Connections extends \Zotlabs\Web\Controller { killme(); } else { - $o .= ""; + $o .= ""; $o .= replace_macros(get_markup_template('connections.tpl'),array( '$header' => t('Connections') . (($head) ? ': ' . $head : ''), '$tabs' => $tabs, diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index 8a7c6baf6..59b832a0f 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -395,7 +395,7 @@ class Directory extends \Zotlabs\Web\Controller { $dirtitle = (($globaldir) ? t('Global Directory') : t('Local Directory')); - $o .= ""; + $o .= ""; $o .= replace_macros($tpl, array( '$search' => $search, '$desc' => t('Find'), diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 489bffc4a..d3ef8d60b 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -838,7 +838,7 @@ class Photos extends \Zotlabs\Web\Controller { killme(); } else { - $o .= ""; + $o .= ""; $tpl = get_markup_template('photo_album.tpl'); $o .= replace_macros($tpl, array( '$photos' => $photos, @@ -1377,7 +1377,7 @@ class Photos extends \Zotlabs\Web\Controller { killme(); } else { - $o .= ""; + $o .= ""; $tpl = get_markup_template('photos_recent.tpl'); $o .= replace_macros($tpl, array( '$title' => t('Recent Photos'), diff --git a/Zotlabs/Module/Rpost.php b/Zotlabs/Module/Rpost.php index 86ee296ec..50d1ec2aa 100644 --- a/Zotlabs/Module/Rpost.php +++ b/Zotlabs/Module/Rpost.php @@ -46,7 +46,7 @@ class Rpost extends \Zotlabs\Web\Controller { // make sure we're not looping to our own hub if(($url) && (! stristr($url, \App::get_hostname()))) { foreach($_GET as $key => $arg) { - if($key === 'q') + if($key === 'req') continue; $url .= '&' . $key . '=' . $arg; } diff --git a/Zotlabs/Module/Viewconnections.php b/Zotlabs/Module/Viewconnections.php index 0a5e86907..223e185e1 100644 --- a/Zotlabs/Module/Viewconnections.php +++ b/Zotlabs/Module/Viewconnections.php @@ -107,7 +107,7 @@ class Viewconnections extends \Zotlabs\Web\Controller { killme(); } else { - $o .= ""; + $o .= ""; $tpl = get_markup_template("viewcontact_template.tpl"); $o .= replace_macros($tpl, array( '$title' => t('View Connections'), diff --git a/boot.php b/boot.php index 8518a17f6..f957f4f0e 100755 --- a/boot.php +++ b/boot.php @@ -878,8 +878,8 @@ class App { self::$path = $path; } - if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") { - self::$query_string = str_replace(['<','>'],['<','>'],substr($_SERVER['QUERY_STRING'], 2)); + if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 4) === "req=") { + self::$query_string = str_replace(['<','>'],['<','>'],substr($_SERVER['QUERY_STRING'], 4)); // removing trailing / - maybe a nginx problem if (substr(self::$query_string, 0, 1) == "/") self::$query_string = substr(self::$query_string, 1); @@ -887,8 +887,8 @@ class App { self::$query_string = preg_replace('/&/','?',self::$query_string,1); } - if(x($_GET,'q')) - self::$cmd = escape_tags(trim($_GET['q'],'/\\')); + if(x($_GET,'req')) + self::$cmd = escape_tags(trim($_GET['req'],'/\\')); // unix style "homedir" diff --git a/include/dir_fns.php b/include/dir_fns.php index 2bd1228ec..99dcb63fb 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -133,7 +133,7 @@ function dir_sort_links() { unset($tmp['pubforums']); unset($tmp['global']); unset($tmp['safe']); - unset($tmp['q']); + unset($tmp['req']); unset($tmp['f']); $forumsurl = $url . http_build_query($tmp) . $suggest; diff --git a/include/text.php b/include/text.php index 8a07dc113..2d704cff1 100644 --- a/include/text.php +++ b/include/text.php @@ -2526,7 +2526,7 @@ function extra_query_args() { if(count($_GET)) { foreach($_GET as $k => $v) { // these are request vars we don't want to duplicate - if(! in_array($k, array('q','f','zid','page','PHPSESSID'))) { + if(! in_array($k, array('req','f','zid','page','PHPSESSID'))) { $s .= '&' . $k . '=' . urlencode($v); } } @@ -2534,7 +2534,7 @@ function extra_query_args() { if(count($_POST)) { foreach($_POST as $k => $v) { // these are request vars we don't want to duplicate - if(! in_array($k, array('q','f','zid','page','PHPSESSID'))) { + if(! in_array($k, array('req','f','zid','page','PHPSESSID'))) { $s .= '&' . $k . '=' . urlencode($v); } } diff --git a/library/OAuth1.php b/library/OAuth1.php index 0a6b20b0a..e70cf0a1b 100644 --- a/library/OAuth1.php +++ b/library/OAuth1.php @@ -293,8 +293,8 @@ class OAuth1Request { } // fix for friendica redirect system // FIXME or don't, but figure out if this is absolutely necessary and act accordingly - $http_url = substr($http_url, 0, strpos($http_url,$parameters['q'])+strlen($parameters['q'])); - unset( $parameters['q'] ); + $http_url = substr($http_url, 0, strpos($http_url,$parameters['req'])+strlen($parameters['req'])); + unset( $parameters['req'] ); return new OAuth1Request($http_method, $http_url, $parameters); } -- cgit v1.2.3 From e4b6a143c7679428ecf7208274fddb5f1b37c70e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 26 Aug 2018 23:05:56 -0700 Subject: Revert "Change main router request variable from 'q' to 'req'. This is necessary to implement search in the twitter api addon, because twitter requires use of the variable 'q'." Reverting because this will only work with Apache and break nginx/other installations. This reverts commit 9367e9fe5a0125bf4c2f77909f2789c9dcd41e1e. --- .htaccess | 6 +++--- Zotlabs/Lib/Libzotdir.php | 2 +- Zotlabs/Module/Connections.php | 2 +- Zotlabs/Module/Directory.php | 2 +- Zotlabs/Module/Photos.php | 4 ++-- Zotlabs/Module/Rpost.php | 2 +- Zotlabs/Module/Viewconnections.php | 2 +- boot.php | 8 ++++---- include/dir_fns.php | 2 +- include/text.php | 4 ++-- library/OAuth1.php | 4 ++-- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.htaccess b/.htaccess index 7a265eda1..3420313a5 100644 --- a/.htaccess +++ b/.htaccess @@ -20,15 +20,15 @@ AddType audio/ogg .oga RewriteRule "(^|/)\.git" - [F] RewriteRule "(^|/)store" - [F] - # Rewrite current-style URLs of the form 'index.php?req=x'. + # Rewrite current-style URLs of the form 'index.php?q=x'. # Also place auth information into REMOTE_USER for sites running # in CGI mode. RewriteCond %{REQUEST_URI} ^/\.well\-known/.* - RewriteRule ^(.*)$ index.php?req=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA] + RewriteRule ^(.*)$ index.php?q=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule ^(.*)$ index.php?req=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA] + RewriteRule ^(.*)$ index.php?q=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA] diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php index 81a5b3319..91d089c86 100644 --- a/Zotlabs/Lib/Libzotdir.php +++ b/Zotlabs/Lib/Libzotdir.php @@ -152,7 +152,7 @@ class Libzotdir { unset($tmp['pubforums']); unset($tmp['global']); unset($tmp['safe']); - unset($tmp['req']); + unset($tmp['q']); unset($tmp['f']); $forumsurl = $url . http_build_query($tmp) . $suggest; diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index 48b59cb8c..cecada769 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -326,7 +326,7 @@ class Connections extends \Zotlabs\Web\Controller { killme(); } else { - $o .= ""; + $o .= ""; $o .= replace_macros(get_markup_template('connections.tpl'),array( '$header' => t('Connections') . (($head) ? ': ' . $head : ''), '$tabs' => $tabs, diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index 59b832a0f..8a7c6baf6 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -395,7 +395,7 @@ class Directory extends \Zotlabs\Web\Controller { $dirtitle = (($globaldir) ? t('Global Directory') : t('Local Directory')); - $o .= ""; + $o .= ""; $o .= replace_macros($tpl, array( '$search' => $search, '$desc' => t('Find'), diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index d3ef8d60b..489bffc4a 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -838,7 +838,7 @@ class Photos extends \Zotlabs\Web\Controller { killme(); } else { - $o .= ""; + $o .= ""; $tpl = get_markup_template('photo_album.tpl'); $o .= replace_macros($tpl, array( '$photos' => $photos, @@ -1377,7 +1377,7 @@ class Photos extends \Zotlabs\Web\Controller { killme(); } else { - $o .= ""; + $o .= ""; $tpl = get_markup_template('photos_recent.tpl'); $o .= replace_macros($tpl, array( '$title' => t('Recent Photos'), diff --git a/Zotlabs/Module/Rpost.php b/Zotlabs/Module/Rpost.php index 50d1ec2aa..86ee296ec 100644 --- a/Zotlabs/Module/Rpost.php +++ b/Zotlabs/Module/Rpost.php @@ -46,7 +46,7 @@ class Rpost extends \Zotlabs\Web\Controller { // make sure we're not looping to our own hub if(($url) && (! stristr($url, \App::get_hostname()))) { foreach($_GET as $key => $arg) { - if($key === 'req') + if($key === 'q') continue; $url .= '&' . $key . '=' . $arg; } diff --git a/Zotlabs/Module/Viewconnections.php b/Zotlabs/Module/Viewconnections.php index 223e185e1..0a5e86907 100644 --- a/Zotlabs/Module/Viewconnections.php +++ b/Zotlabs/Module/Viewconnections.php @@ -107,7 +107,7 @@ class Viewconnections extends \Zotlabs\Web\Controller { killme(); } else { - $o .= ""; + $o .= ""; $tpl = get_markup_template("viewcontact_template.tpl"); $o .= replace_macros($tpl, array( '$title' => t('View Connections'), diff --git a/boot.php b/boot.php index f957f4f0e..8518a17f6 100755 --- a/boot.php +++ b/boot.php @@ -878,8 +878,8 @@ class App { self::$path = $path; } - if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 4) === "req=") { - self::$query_string = str_replace(['<','>'],['<','>'],substr($_SERVER['QUERY_STRING'], 4)); + if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") { + self::$query_string = str_replace(['<','>'],['<','>'],substr($_SERVER['QUERY_STRING'], 2)); // removing trailing / - maybe a nginx problem if (substr(self::$query_string, 0, 1) == "/") self::$query_string = substr(self::$query_string, 1); @@ -887,8 +887,8 @@ class App { self::$query_string = preg_replace('/&/','?',self::$query_string,1); } - if(x($_GET,'req')) - self::$cmd = escape_tags(trim($_GET['req'],'/\\')); + if(x($_GET,'q')) + self::$cmd = escape_tags(trim($_GET['q'],'/\\')); // unix style "homedir" diff --git a/include/dir_fns.php b/include/dir_fns.php index 99dcb63fb..2bd1228ec 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -133,7 +133,7 @@ function dir_sort_links() { unset($tmp['pubforums']); unset($tmp['global']); unset($tmp['safe']); - unset($tmp['req']); + unset($tmp['q']); unset($tmp['f']); $forumsurl = $url . http_build_query($tmp) . $suggest; diff --git a/include/text.php b/include/text.php index 2d704cff1..8a07dc113 100644 --- a/include/text.php +++ b/include/text.php @@ -2526,7 +2526,7 @@ function extra_query_args() { if(count($_GET)) { foreach($_GET as $k => $v) { // these are request vars we don't want to duplicate - if(! in_array($k, array('req','f','zid','page','PHPSESSID'))) { + if(! in_array($k, array('q','f','zid','page','PHPSESSID'))) { $s .= '&' . $k . '=' . urlencode($v); } } @@ -2534,7 +2534,7 @@ function extra_query_args() { if(count($_POST)) { foreach($_POST as $k => $v) { // these are request vars we don't want to duplicate - if(! in_array($k, array('req','f','zid','page','PHPSESSID'))) { + if(! in_array($k, array('q','f','zid','page','PHPSESSID'))) { $s .= '&' . $k . '=' . urlencode($v); } } diff --git a/library/OAuth1.php b/library/OAuth1.php index e70cf0a1b..0a6b20b0a 100644 --- a/library/OAuth1.php +++ b/library/OAuth1.php @@ -293,8 +293,8 @@ class OAuth1Request { } // fix for friendica redirect system // FIXME or don't, but figure out if this is absolutely necessary and act accordingly - $http_url = substr($http_url, 0, strpos($http_url,$parameters['req'])+strlen($parameters['req'])); - unset( $parameters['req'] ); + $http_url = substr($http_url, 0, strpos($http_url,$parameters['q'])+strlen($parameters['q'])); + unset( $parameters['q'] ); return new OAuth1Request($http_method, $http_url, $parameters); } -- cgit v1.2.3