forked from eyecatchup/SEOstats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial (dev branch) commit of 2.5.2
- Loading branch information
1 parent
ff20f3f
commit 58805c8
Showing
31 changed files
with
1,198 additions
and
1,067 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
The MIT License (http://eyecatchup.mit-license.org/) | ||
Copyright � 2012 Stephan Schmitz, https://github.com/eyecatchup <[email protected]> | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the �Software�), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
The MIT License (http://eyecatchup.mit-license.org/) | ||
Copyright � 2012 Stephan Schmitz, https://github.com/eyecatchup <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the �Software�), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED �AS IS�, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
namespace SEOstats\Common; | ||
|
||
/** | ||
* PSR-0 Autoloader | ||
* | ||
* @package SEOstats | ||
* @author Stephan Schmitz <[email protected]> | ||
* @copyright Copyright (c) 2010 - present Stephan Schmitz | ||
* @license http://eyecatchup.mit-license.org/ MIT License | ||
* @updated 2013/02/03 | ||
*/ | ||
class AutoLoader | ||
{ | ||
/** | ||
* @var string The namespace prefix for this instance. | ||
*/ | ||
protected $namespace = ''; | ||
|
||
/** | ||
* @var string The filesystem prefix to use for this instance | ||
*/ | ||
protected $path = ''; | ||
|
||
/** | ||
* Build the instance of the autoloader | ||
* | ||
* @param string $namespace The prefixed namespace this instance will load | ||
* @param string $path The filesystem path to the root of the namespace | ||
*/ | ||
public function __construct($namespace, $path) | ||
{ | ||
$this->namespace = ltrim($namespace, '\\'); | ||
$this->path = rtrim($path, '/\\') . DIRECTORY_SEPARATOR; | ||
} | ||
|
||
/** | ||
* Try to load a class | ||
* | ||
* @param string $class The class name to load | ||
* | ||
* @return boolean If the loading was successful | ||
*/ | ||
public function load($class) | ||
{ | ||
$class = ltrim($class, '\\'); | ||
|
||
if (strpos($class, $this->namespace) === 0) { | ||
$nsparts = explode('\\', $class); | ||
$class = array_pop($nsparts); | ||
$nsparts[] = ''; | ||
$path = $this->path . implode(DIRECTORY_SEPARATOR, $nsparts); | ||
$path .= str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; | ||
|
||
if (file_exists($path)) { | ||
require $path; | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Register the autoloader to PHP | ||
* | ||
* @return boolean The status of the registration | ||
*/ | ||
public function register() | ||
{ | ||
return spl_autoload_register(array($this, 'load')); | ||
} | ||
|
||
/** | ||
* Unregister the autoloader to PHP | ||
* | ||
* @return boolean The status of the unregistration | ||
*/ | ||
public function unregister() | ||
{ | ||
return spl_autoload_unregister(array($this, 'load')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
namespace SEOstats\Common; | ||
|
||
/** | ||
* SEOstats Exception Class | ||
* | ||
* @package SEOstats | ||
* @author Stephan Schmitz <[email protected]> | ||
* @copyright Copyright (c) 2010 - present Stephan Schmitz | ||
* @license http://eyecatchup.mit-license.org/ MIT License | ||
* @updated 2013/02/03 | ||
*/ | ||
|
||
class SEOstatsException extends \Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
namespace SEOstats\Config; | ||
|
||
/** | ||
* Configuration constants for the SEOstats library. | ||
* | ||
* @package SEOstats | ||
* @author Stephan Schmitz <[email protected]> | ||
* @copyright Copyright (c) 2010 - present Stephan Schmitz | ||
* @license http://eyecatchup.mit-license.org/ MIT License | ||
* @updated 2013/08/14 | ||
*/ | ||
|
||
/** | ||
* Client API keys | ||
* @package SEOstats | ||
*/ | ||
interface ApiKeys | ||
{ | ||
// To acquire an API key, visit Google's APIs Console here: | ||
// https://code.google.com/apis/console | ||
// In the Services pane, activate the "PageSpeed Insights API" (not the service!). | ||
// Next, go to the API Access pane. The API key is near the bottom of that pane, | ||
// in the section titled "Simple API Access.". | ||
const GOOGLE_SIMPLE_API_ACCESS_KEY = ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
<?php if ( ! defined('SEOSTATSPATH')) exit('No direct access allowed!'); | ||
<?php | ||
namespace SEOstats\Config; | ||
|
||
/** | ||
* Default client settings | ||
* Configuration constants for the SEOstats library. | ||
* | ||
* @package SEOstats | ||
* @updated 2013/01/29 | ||
* @package SEOstats | ||
* @author Stephan Schmitz <[email protected]> | ||
* @copyright Copyright (c) 2010 - present Stephan Schmitz | ||
* @license http://eyecatchup.mit-license.org/ MIT License | ||
* @updated 2013/02/03 | ||
*/ | ||
|
||
interface default_settings | ||
/** | ||
* Default client settings | ||
* @package SEOstats | ||
*/ | ||
interface DefaultSettings | ||
{ | ||
const DEFAULT_RETURN_NO_DATA = 'n.a.'; | ||
|
||
const GOOGLE_TLD = 'com'; | ||
|
||
// Note: Google search results, doesn't matter which tld you request, vary depending on | ||
|
@@ -24,13 +35,10 @@ interface default_settings | |
const HTTP_HEADER_ACCEPT_LANGUAGE = 'en-us;q=0.8,en;q=0.3'; | ||
|
||
// For curl instances: Whether to allow Google to store cookies, or not. | ||
const ALLOW_GOOGLE_COOKIES = '0'; | ||
const ALLOW_GOOGLE_COOKIES = 0; | ||
|
||
// Choose the local SEMRush database to use. | ||
// Choose the local SEMRush database to use. | ||
const SEMRUSH_DB = 'de'; | ||
|
||
const EXPORT_DIR = 'data/'; | ||
} | ||
|
||
/* End of file default-settings.php */ | ||
/* Location: ./src/interfaces/default-settings.php */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
namespace SEOstats\Config; | ||
|
||
/** | ||
* Configuration constants for the SEOstats library. | ||
* | ||
* @package SEOstats | ||
* @author Stephan Schmitz <[email protected]> | ||
* @copyright Copyright (c) 2010 - present Stephan Schmitz | ||
* @license http://eyecatchup.mit-license.org/ MIT License | ||
* @updated 2013/02/03 | ||
*/ | ||
|
||
/** | ||
* SEOstats package info | ||
* @package SEOstats | ||
*/ | ||
interface Package | ||
{ | ||
const VERSION_CODE = '2.5.2-dev'; | ||
const LICENSE_TYPE = 'MIT Licence'; | ||
const LICENSE_URL = 'http://eyecatchup.mit-license.org/'; | ||
const AUTHOR_NAME = 'Stephan Schmitz'; | ||
const AUTHOR_MAIL = '[email protected]'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
<?php if (!defined('SEOSTATSPATH')) exit('No direct access allowed!'); | ||
<?php | ||
namespace SEOstats\Config; | ||
|
||
/** | ||
* SEOstats provider list and service URLs | ||
* Configuration constants for the SEOstats library. | ||
* | ||
* @package SEOstats | ||
* @author Stephan Schmitz <[email protected]> | ||
* @updated 2013/01/29 | ||
* @package SEOstats | ||
* @author Stephan Schmitz <[email protected]> | ||
* @copyright Copyright (c) 2010 - present Stephan Schmitz | ||
* @license http://eyecatchup.mit-license.org/ MIT License | ||
* @updated 2013/08/14 | ||
*/ | ||
|
||
interface services | ||
/** | ||
* SEOstats provider list and service URLs | ||
* @package SEOstats | ||
*/ | ||
interface Services | ||
{ | ||
const PROVIDER = '["alexa","google","ose","semrush","seomoz","sistrix","social","yahoo"]'; | ||
|
||
|
@@ -26,8 +34,8 @@ interface services | |
// Url to get Google search total counts from | ||
const GOOGLE_APISEARCH_URL = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=%s&q=%s'; | ||
|
||
// Url to get the Pagespeed analysis from | ||
const GOOGLE_PAGESPEED_URL = 'https://developers.google.com/_apps/pagespeed/run_pagespeed?url=%s&format=json'; | ||
// Url to the Page Speed Insights API | ||
const GOOGLE_PAGESPEED_URL = 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=%s&key=%s'; | ||
|
||
// Url to get the Plus One count from | ||
const GOOGLE_PLUSONE_URL = 'https://plusone.google.com/u/0/_/+1/fastbutton?count=true&url=%s'; | ||
|
@@ -63,6 +71,3 @@ interface services | |
// Url to get share count via VKontakte from | ||
const VKONTAKTE_INFO_URL = 'http://vk.com/share.php?act=count&index=1&url=%s'; | ||
} | ||
|
||
/* End of file services.php */ | ||
/* Location: ./src/interfaces/services.php */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
<?php if ( ! defined('SEOSTATSPATH')) exit('No direct access allowed!'); | ||
<?php | ||
namespace SEOstats\Helper; | ||
|
||
/** | ||
* HTTP Request Helper Class | ||
* HTTP Request Helper Class | ||
* | ||
* @package SEOstats | ||
* @author Stephan Schmitz <[email protected]> | ||
* @updated 2012/06/15 | ||
* @package SEOstats | ||
* @author Stephan Schmitz <[email protected]> | ||
* @copyright Copyright (c) 2010 - present Stephan Schmitz | ||
* @license http://eyecatchup.mit-license.org/ MIT License | ||
* @updated 2013/05/12 | ||
*/ | ||
|
||
class HttpRequest extends SEOstats | ||
class HttpRequest | ||
{ | ||
/** | ||
* HTTP GET/POST request with curl. | ||
|
@@ -20,18 +24,21 @@ class HttpRequest extends SEOstats | |
*/ | ||
public static function sendRequest($url, $postData = false, $postJson = false) | ||
{ | ||
$ua = sprintf('SEOstats %s https://github.com/eyecatchup/SEOstats', | ||
\SEOstats\SEOstats::BUILD_NO); | ||
|
||
$ch = curl_init($url); | ||
curl_setopt_array($ch, array( | ||
CURLOPT_USERAGENT => sprintf('SEOstats %s https://github.com/eyecatchup/SEOstats', SEOstats::BUILD_NO), | ||
CURLOPT_USERAGENT => $ua, | ||
CURLOPT_RETURNTRANSFER => 1, | ||
CURLOPT_CONNECTTIMEOUT => 30, | ||
CURLOPT_FOLLOWLOCATION => 1, | ||
CURLOPT_MAXREDIRS => 2, | ||
CURLOPT_SSL_VERIFYPEER => 0 | ||
CURLOPT_SSL_VERIFYPEER => 0, | ||
)); | ||
|
||
if (false != $postData) { | ||
if (false != $postJson) { | ||
if (false !== $postData) { | ||
if (false !== $postJson) { | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, | ||
array('Content-type: application/json')); | ||
$data = json_encode($postData); | ||
|
@@ -46,10 +53,7 @@ public static function sendRequest($url, $postData = false, $postJson = false) | |
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | ||
curl_close($ch); | ||
|
||
if($httpCode == 200) { | ||
return $response; | ||
} | ||
else { return $httpCode; } | ||
return (200 == (int)$httpCode) ? $response : false; | ||
} | ||
|
||
/** | ||
|
@@ -62,47 +66,50 @@ public static function sendRequest($url, $postData = false, $postJson = false) | |
*/ | ||
public static function getHttpCode($url) | ||
{ | ||
$ua = sprintf('SEOstats %s https://github.com/eyecatchup/SEOstats', | ||
\SEOstats\SEOstats::BUILD_NO); | ||
|
||
$ch = curl_init($url); | ||
curl_setopt_array($ch, array( | ||
CURLOPT_USERAGENT => sprintf('SEOstats %s https://github.com/eyecatchup/SEOstats', SEOstats::BUILD_NO), | ||
CURLOPT_USERAGENT => $ua, | ||
CURLOPT_RETURNTRANSFER => 1, | ||
CURLOPT_CONNECTTIMEOUT => 10, | ||
CURLOPT_FOLLOWLOCATION => 1, | ||
CURLOPT_MAXREDIRS => 2, | ||
CURLOPT_SSL_VERIFYPEER => 0, | ||
CURLOPT_NOBODY => 1 | ||
CURLOPT_NOBODY => 1, | ||
)); | ||
|
||
curl_exec($ch); | ||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | ||
curl_close($ch); | ||
|
||
return (int) $httpCode; | ||
return (int)$httpCode; | ||
} | ||
|
||
public function getFile($url, $file) | ||
{ | ||
$ua = sprintf('SEOstats %s https://github.com/eyecatchup/SEOstats', | ||
\SEOstats\SEOstats::BUILD_NO); | ||
|
||
$fp = fopen("$file", 'w'); | ||
|
||
$ch = curl_init($url); | ||
curl_setopt_array($ch, array( | ||
CURLOPT_USERAGENT => sprintf('SEOstats %s https://github.com/eyecatchup/SEOstats', SEOstats::BUILD_NO), | ||
CURLOPT_USERAGENT => $ua, | ||
CURLOPT_RETURNTRANSFER => 1, | ||
CURLOPT_CONNECTTIMEOUT => 30, | ||
CURLOPT_FOLLOWLOCATION => 1, | ||
CURLOPT_MAXREDIRS => 2, | ||
CURLOPT_SSL_VERIFYPEER => 0, | ||
CURLOPT_FILE => $fp | ||
CURLOPT_FILE => $fp, | ||
)); | ||
|
||
curl_exec($ch); | ||
curl_close($ch); | ||
fclose($fp); | ||
|
||
clearstatcache(); | ||
return (bool) FALSE !== stat($file); | ||
return (bool)(false !== stat($file)); | ||
} | ||
} | ||
|
||
/* End of file seostats.httprequest.php */ | ||
/* Location: ./src/helper/seostats.httprequest.php */ |
Oops, something went wrong.