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:
authorMatthieu Aubry <mattab@users.noreply.github.com>2017-05-09 12:40:37 +0300
committerGitHub <noreply@github.com>2017-05-09 12:40:37 +0300
commitbaff589b91fd1af70c32b4282c71c4fa3b03697c (patch)
treef55ff25793111526945d85cdaff0401564d43179 /plugins
parent51e34b5d8b6d65e95707a7a4388cf2337fadddbc (diff)
Use SSL to fetch SEO stats metrics (#11672)
* Use SSL to fetch SEO stats metrics Fixes WARNING: Error while getting SEO stats (domain age): curl_exec: Connection timed out after 10001 milliseconds. Reported in https://forum.piwik.org/t/piwik-3-0-1-warning-error-while-getting-seo-stats-domain-age/23136 * Fallback https -> http in SEO metrics
Diffstat (limited to 'plugins')
-rw-r--r--plugins/SEO/Metric/DomainAge.php19
1 files changed, 15 insertions, 4 deletions
diff --git a/plugins/SEO/Metric/DomainAge.php b/plugins/SEO/Metric/DomainAge.php
index e08dc3fa98..54038a7dae 100644
--- a/plugins/SEO/Metric/DomainAge.php
+++ b/plugins/SEO/Metric/DomainAge.php
@@ -74,7 +74,7 @@ class DomainAge implements MetricsProvider
*/
private function getAgeArchiveOrg($domain)
{
- $data = $this->getUrl('http://wayback.archive.org/web/*/' . urlencode($domain));
+ $data = $this->getUrl('https://wayback.archive.org/web/*/' . urlencode($domain));
preg_match('#<a href=\"([^>]*)' . preg_quote($domain) . '/\">([^<]*)<\/a>#', $data, $p);
if (!empty($p[2])) {
$value = strtotime($p[2]);
@@ -94,7 +94,7 @@ class DomainAge implements MetricsProvider
*/
private function getAgeWhoIs($domain)
{
- $data = $this->getUrl('http://www.who.is/whois/' . urlencode($domain));
+ $data = $this->getUrl('https://www.who.is/whois/' . urlencode($domain));
preg_match('#(?:Creation Date|Created On|created|Registered on)\.*:\s*([ \ta-z0-9\/\-:\.]+)#si', $data, $p);
if (!empty($p[1])) {
$value = strtotime(trim($p[1]));
@@ -114,7 +114,7 @@ class DomainAge implements MetricsProvider
*/
private function getAgeWhoisCom($domain)
{
- $data = $this->getUrl('http://www.whois.com/whois/' . urlencode($domain));
+ $data = $this->getUrl('https://www.whois.com/whois/' . urlencode($domain));
preg_match('#(?:Creation Date|Created On|created):\s*([ \ta-z0-9\/\-:\.]+)#si', $data, $p);
if (!empty($p[1])) {
$value = strtotime(trim($p[1]));
@@ -129,10 +129,21 @@ class DomainAge implements MetricsProvider
private function getUrl($url)
{
try {
- return str_replace('&nbsp;', ' ', Http::sendHttpRequest($url, $timeout = 10, @$_SERVER['HTTP_USER_AGENT']));
+ return $this->getHttpResponse($url);
+ } catch (\Exception $e) {
+ }
+
+ $httpUrl = str_replace('https://', 'http://', $url);
+ try {
+ return $this->getHttpResponse($httpUrl);
} catch (\Exception $e) {
$this->logger->warning('Error while getting SEO stats (domain age): {message}', array('message' => $e->getMessage()));
return '';
}
}
+
+ private function getHttpResponse($url)
+ {
+ return str_replace('&nbsp;', ' ', Http::sendHttpRequest($url, $timeout = 10, @$_SERVER['HTTP_USER_AGENT']));
+ }
}