/src/seostats.php

https://github.com/fahrettinaksoy/SEOstats · PHP · 160 lines · 64 code · 18 blank · 78 comment · 2 complexity · ff69449333b14142c1cf171d65c54fd2 MD5 · raw file

  1. <?php
  2. /** SEOstats
  3. * ================================================================================
  4. * PHP class package to request a bunch of SEO-related data, such as looking up the
  5. * visibilty of a URL within organic search results, Pagespeed analysis, the
  6. * Google Toolbar PageRank, Page-Authority, Backlink-Details, Traffic Statistics,
  7. * social media relevance, comparing competing websites and a lot more.
  8. * ================================================================================
  9. * @category
  10. * @package SEOstats
  11. * @copyright 2010 - present, Stephan Schmitz
  12. * @license http://eyecatchup.mit-license.org
  13. * @version CVS: $Id: SEOstats.php, v2.5.1 Rev 31 2013/01/29 03:57:17 ssc Exp $
  14. * @author Stephan Schmitz <eyecatchup@gmail.com>
  15. * @link https://github.com/eyecatchup/SEOstats/
  16. * ================================================================================
  17. * LICENSE: Permission is hereby granted, free of charge, to any person obtaining
  18. * a copy of this software and associated documentation files (the "Software'),
  19. * to deal in the Software without restriction, including without limitation the
  20. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21. * copies of the Software, and to permit persons to whom the Software is furnished
  22. * to do so, subject to the following conditions:
  23. *
  24. * The above copyright notice and this permission notice shall be included in all
  25. * copies or substantial portions of the Software.
  26. *
  27. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  28. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  29. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  30. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY
  31. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  32. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  33. * ================================================================================
  34. */
  35. /*
  36. *---------------------------------------------------------------
  37. * SEOSTATS BASE PATH
  38. *---------------------------------------------------------------
  39. * For increased reliability, resolve os-specific system path.
  40. */
  41. $base_path = __DIR__;
  42. if (realpath( $base_path ) !== false) {
  43. $base_path = realpath($base_path).'/';
  44. }
  45. $base_path = rtrim($base_path, '/').'/';
  46. $base_path = str_replace('\\', '/', $base_path);
  47. define('SEOSTATSPATH', $base_path);
  48. /*
  49. *---------------------------------------------------------------
  50. * SEOSTATS INTERFACES
  51. *---------------------------------------------------------------
  52. */
  53. // Doesn't follow typical include path conventions, but is more convenient for users.
  54. require SEOSTATSPATH . 'interfaces/default-settings.php';
  55. require SEOSTATSPATH . 'interfaces/services.php';
  56. require SEOSTATSPATH . 'interfaces/api-keys.php';
  57. require SEOSTATSPATH . 'interfaces/package.php';
  58. /*
  59. *---------------------------------------------------------------
  60. * SEOSTATS CORE CLASS
  61. *---------------------------------------------------------------
  62. */
  63. /**
  64. * Starting point for the SEOstats class library. Represents a URL resource and has
  65. * methods for pinging, adding, deleting, committing, optimizing and searching.
  66. *
  67. * Example Usage:
  68. * <code>
  69. * ...
  70. * $url = new SEOstats();
  71. * $url->setUrl('http://www.domain.tld'); //or explicitly new SEOstats('http://www.domain.tld')
  72. *
  73. * $url->Google()->getPageRank(); //returns the Google Toolbar PageRank value
  74. * $url->Google()->getSerps('query string'); //returns the first 100 results for a Google search for 'query string'
  75. * $url->Google()->getSerps('query string', 500); //returns the first 500 results for a Google search for 'query string'
  76. *
  77. * //checks the first 500 results for a Google search for 'query string' for occurrences of the given domain name
  78. * //and returns an array of matching URL's and their position within serps.
  79. * $url->Google()->getSerps('query string', 500, 'http://www.domain.tld');
  80. *
  81. * ...
  82. * </code>
  83. *
  84. */
  85. class SEOstats implements default_settings, services, api_keys, package
  86. {
  87. const BUILD_NO = package::VERSION_CODE;
  88. protected static $_url;
  89. public function __construct($url = false)
  90. {
  91. if (false !== $url) {
  92. self::setUrl($url);
  93. }
  94. }
  95. public function getUrl()
  96. {
  97. return self::$_url;
  98. }
  99. public function setUrl($url)
  100. {
  101. self::$_url = $url;
  102. }
  103. public function Alexa()
  104. {
  105. require_once SEOSTATSPATH . 'modules/seostats.alexa.php';
  106. return new SEOstats_Alexa();
  107. }
  108. public function Google()
  109. {
  110. require_once SEOSTATSPATH . 'modules/seostats.google.php';
  111. return new SEOstats_Google();
  112. }
  113. public function OpenSiteExplorer()
  114. {
  115. require_once SEOSTATSPATH . 'modules/seostats.opensiteexplorer.php';
  116. return new SEOstats_OpenSiteExplorer();
  117. }
  118. public function SEMRush()
  119. {
  120. require_once SEOSTATSPATH . 'modules/seostats.semrush.php';
  121. return new SEOstats_SEMRush();
  122. }
  123. public function Sistrix()
  124. {
  125. require_once SEOSTATSPATH . 'modules/seostats.sistrix.php';
  126. return new SEOstats_Sistrix();
  127. }
  128. public function Social()
  129. {
  130. require_once SEOSTATSPATH . 'modules/seostats.social.php';
  131. return new SEOstats_Social();
  132. }
  133. }
  134. // URL-String Helper Class
  135. require SEOSTATSPATH . 'helper/seostats.urlhelper.php';
  136. // HTTP Request Helper Class
  137. require SEOSTATSPATH . 'helper/seostats.httprequest.php';
  138. // SEOstats Exception Class
  139. require SEOSTATSPATH . 'helper/seostats.exception.php';
  140. /* End of file seostats.php */
  141. /* Location: ./src/seostats.php */