Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsgiehl <stefan@piwik.org>2016-05-06 21:49:23 +0300
committersgiehl <stefan@piwik.org>2016-07-13 20:22:14 +0300
commit10e8f5ebdf39180bb19636961f52ffc45a395076 (patch)
tree046689af51f8171d6ab1902a23a6c0f53e3a79ac /plugins
parent7e5d7148e91514a192c11ea2b5a94097de63b557 (diff)
Improve detection for empty keywords by allowing to define that in search engine definitions
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Referrers/SearchEngine.php49
-rw-r--r--plugins/Referrers/images/searchEngines/search.disconnect.me.pngbin0 -> 505 bytes
-rw-r--r--plugins/Referrers/images/searchEngines/search.lookseek.com.pngbin0 -> 991 bytes
-rw-r--r--plugins/Referrers/images/searchEngines/search.smartshopping.com.pngbin0 -> 576 bytes
-rw-r--r--plugins/Referrers/images/searchEngines/searchlock.com.pngbin0 -> 3295 bytes
-rw-r--r--plugins/Referrers/images/searchEngines/startpage.com.pngbin0 -> 738 bytes
-rw-r--r--plugins/Referrers/images/searchEngines/www.only-search.com.pngbin0 -> 789 bytes
-rw-r--r--plugins/Referrers/tests/Unit/SearchEngineTest.php2
8 files changed, 30 insertions, 21 deletions
diff --git a/plugins/Referrers/SearchEngine.php b/plugins/Referrers/SearchEngine.php
index 6b8cea6eb5..e2970c61ad 100644
--- a/plugins/Referrers/SearchEngine.php
+++ b/plugins/Referrers/SearchEngine.php
@@ -224,11 +224,10 @@ class SearchEngine extends Singleton
$searchEngineName = $definitions['name'];
$variableNames = $definitions['params'];
+ $keywordsHiddenFor = !empty($definitions['hiddenkeyword']) ? $definitions['hiddenkeyword'] : array();
$key = null;
- if ($searchEngineName === 'Google Images'
- || ($searchEngineName === 'Google' && strpos($referrerUrl, '/imgres') !== false)
- ) {
+ if ($searchEngineName === 'Google Images') {
if (strpos($query, '&prev') !== false) {
$query = urldecode(trim(UrlHelper::getParameterFromQueryString($query, 'prev')));
$query = str_replace('&', '&amp;', strstr($query, '?'));
@@ -286,27 +285,13 @@ class SearchEngine extends Singleton
$key = UrlHelper::getParameterFromQueryString($query, $variableName);
$key = trim(urldecode($key));
- // Special cases: empty or no keywords
+ // Special cases: empty keywords
if (empty($key)
&& (
- // Google / Yahoo search with no keyword
- (($searchEngineName == 'Google' || $searchEngineName == 'Yahoo!' || $searchEngineName == 'Yahoo! Japan')
- && (empty($query) && (empty($referrerPath) || $referrerPath == '/' || $referrerPath == '/search') && empty($referrerParsed['fragment']))
- )
-
- // Yahoo search with no keyword
- || ($searchEngineName == 'Yahoo!'
- && ($referrerParsed['host'] == 'r.search.yahoo.com')
- )
-
// empty keyword parameter
- || strpos($query, sprintf('&%s=', $variableName)) !== false
+ strpos($query, sprintf('&%s=', $variableName)) !== false
|| strpos($query, sprintf('?%s=', $variableName)) !== false
-
- // search engines with no keyword
- || $searchEngineName == 'Ixquick'
- || $searchEngineName == 'Google Images'
- || $searchEngineName == 'DuckDuckGo')
+ )
) {
$key = false;
}
@@ -319,6 +304,30 @@ class SearchEngine extends Singleton
}
}
+ // if no keyword found, but empty keywords are allowed
+ if (!empty($keywordsHiddenFor) && ($key === null || $key === '')) {
+
+ $pathWithQueryAndFragment = $referrerPath;
+ if (!empty($query)) {
+ $pathWithQueryAndFragment .= '?'.$query;
+ }
+ if (!empty($referrerParsed['fragment'])) {
+ $pathWithQueryAndFragment .= '#'.$referrerParsed['fragment'];
+ }
+
+ foreach ($keywordsHiddenFor as $path) {
+ if (strlen($path) > 1 && substr($path, 0, 1) == '/' && substr($path, -1, 1) == '/') {
+ if (preg_match($path, $pathWithQueryAndFragment)) {
+ $key = false;
+ break;
+ }
+ } elseif ($path == $pathWithQueryAndFragment) {
+ $key = false;
+ break;
+ }
+ }
+ }
+
// $key === false is the special case "No keyword provided" which is a Search engine match
if ($key === null || $key === '') {
return false;
diff --git a/plugins/Referrers/images/searchEngines/search.disconnect.me.png b/plugins/Referrers/images/searchEngines/search.disconnect.me.png
new file mode 100644
index 0000000000..54b0eac351
--- /dev/null
+++ b/plugins/Referrers/images/searchEngines/search.disconnect.me.png
Binary files differ
diff --git a/plugins/Referrers/images/searchEngines/search.lookseek.com.png b/plugins/Referrers/images/searchEngines/search.lookseek.com.png
new file mode 100644
index 0000000000..ac1ff37a17
--- /dev/null
+++ b/plugins/Referrers/images/searchEngines/search.lookseek.com.png
Binary files differ
diff --git a/plugins/Referrers/images/searchEngines/search.smartshopping.com.png b/plugins/Referrers/images/searchEngines/search.smartshopping.com.png
new file mode 100644
index 0000000000..320ede63d5
--- /dev/null
+++ b/plugins/Referrers/images/searchEngines/search.smartshopping.com.png
Binary files differ
diff --git a/plugins/Referrers/images/searchEngines/searchlock.com.png b/plugins/Referrers/images/searchEngines/searchlock.com.png
new file mode 100644
index 0000000000..54f98183bc
--- /dev/null
+++ b/plugins/Referrers/images/searchEngines/searchlock.com.png
Binary files differ
diff --git a/plugins/Referrers/images/searchEngines/startpage.com.png b/plugins/Referrers/images/searchEngines/startpage.com.png
new file mode 100644
index 0000000000..916df91599
--- /dev/null
+++ b/plugins/Referrers/images/searchEngines/startpage.com.png
Binary files differ
diff --git a/plugins/Referrers/images/searchEngines/www.only-search.com.png b/plugins/Referrers/images/searchEngines/www.only-search.com.png
new file mode 100644
index 0000000000..543c95d88e
--- /dev/null
+++ b/plugins/Referrers/images/searchEngines/www.only-search.com.png
Binary files differ
diff --git a/plugins/Referrers/tests/Unit/SearchEngineTest.php b/plugins/Referrers/tests/Unit/SearchEngineTest.php
index e9f0c926ea..1b5cab4dbc 100644
--- a/plugins/Referrers/tests/Unit/SearchEngineTest.php
+++ b/plugins/Referrers/tests/Unit/SearchEngineTest.php
@@ -121,7 +121,7 @@ class SearchEngineTest extends \PHPUnit_Framework_TestCase
public function testMissingSearchEngineKeyword($url, $searchEngine)
{
$name = parse_url('http://' . $url);
- $this->assertTrue(!empty($searchEngine['params']), $name['host']);
+ $this->assertTrue(!empty($searchEngine['params']) || !empty($searchEngine['hiddenkeyword']), $name['host']);
}
/**