<?php
/**********************************************************
* ______ ______ ___ _______ ___ ___ _______ *
* | _ \ | _ \ | | | _ || Y || _ | *
* |. | \|. | \|. | |. 1___||. || 1___| *
* |. | |. | |. |___ |. |___ |. \_/ ||____ | *
* |: 1 |: 1 |: 1 ||: 1 ||: | ||: 1 | *
* |::.. . /|::.. . /|::.. . ||::.. . ||::.|:. ||::.. . | *
* `------' `------' `-------'`-------'`--- ---'`-------' *
* _______ _______ *
* .--.--. | _ | | | *
* | | | |___| | __ |___| | *
* \___/ _(__ | |__| / ___/ *
* |: 1 | |: 1 \ *
* |::.. . | |::.. . | *
* `-------' `-------' *
* *
* Script: DDLCMS v3.2 *
* Author: Little Dragon *
* Email: hide@address.com *
* Website: http://www.ddlcms.com *
* *
* Please direct bug reports, suggestions or feedback *
* to the DDLCMS forums: *
* *
* http://www.ddlcms.com/forums *
* *
* DDLCMS is a commercial grade content management *
* system for DDL site owners. It is provided free *
* of charge, provided: *
* *
* 1. You keep the linkback to http://www.ddlcms.com *
* in the footer. *
* *
* 2. You keep the sponsored links to Sharingzone.net *
* on your site. *
* *
* By using this script, you agree that you will not *
* modify, remove, or replace any encoded parts of *
* this script. All encoded parts MUST remain intact *
* for your site to remain in good standing. *
* *
**********************************************************/
define('WWWROOT', dirname(__FILE__) . '/');
define('BASEDIR', substr(WWWROOT, 0, ##BASEDIR##));
require(BASEDIR . 'funcs.inc');
require(BASEDIR . 'config.php');
function getGooglePages($host) {
$request = "http://www.google.com/search?q=" . urlencode("site:" . $host) . "&hl=en";
$data = getPageData($request);
preg_match('/<b>([\d,]+)<\/b> from <b>' . $host . '/si', $data, $p);
$value = ($p[1]) ? $p[1] : "n/a";
$string = "<a href=\"" . $request . "\">" . $value . "</a>";
return $string;
}
function getGoogleLinks($host) {
$request = "http://www.google.com/search?q=" . urlencode("link:" . $host) . "&hl=en";
$data = getPageData($request);
preg_match('/<b>([\d,]+)<\/b> linking to <b>' . $host . '/si', $data, $l);
$value = ($l[1]) ? $l[1] : "n/a";
$string = "<a href=\"" . $request . "\">" . $value . "</a>";
return $string;
}
function getYahooPages($host) {
$request = "http://siteexplorer.search.yahoo.com/search?p=" . urlencode("http://" . $host);
$data = getPageData($request);
preg_match('/Pages \(([\d,]+)/si', $data, $p);
$value = ($p[1]) ? $p[1] : "n/a";
$string = "<a href=\"" . $request . "\">" . $value . "</a>";
return $string;
}
function getYahooLinks($host) {
$request = "http://siteexplorer.search.yahoo.com/search?p=" . urlencode("http://" . $host);
$data = getPageData($request);
preg_match('/Inlinks \(([\d,]+)/si', $data, $l);
$value = ($l[1]) ? $l[1] : "n/a";
$string.= "<a href=\"" . $request . "&bwm=i\">" . $value . "</a>";
return $string;
}
function getMSNPages($host) {
$request = "http://search.live.com/results.aspx?q=" . urlencode("site:" . $host);
$data = getPageData($request);
preg_match('/1-([\d]+) of ([\d,]+)/si', $data, $p);
$value = ($p[2]) ? $p[2] : "n/a";
$string = "<a href=\"" . $request . "\">" . $value . "</a>";
return $string;
}
function getMSNLinks($host) { // CURRENTLY SUSPENDED!
$request = "http://search.live.com/results.aspx?q=" . urlencode("linkdomain:" . $host);
$data = getPageData($request2);
preg_match('/1-([\d]+) of ([\d,]+)/si', $data, $l);
$value = ($l[2]) ? $l[2] : "n/a";
$string.= "<a href=\"" . $request . "\">" . $value . "</a>";
return $string;
}
function getAskPages($host) {
$request = "http://www.ask.com/web?q=" . urlencode($host . " site:" . $host);
$data = getPageData($request);
preg_match('/<span id=\'indexLast\' class=\'b\'>([\d]+)<\/span> of ([\d,]+)/si', $data, $p);
$value = ($p[2]) ? $p[2] : "n/a";
$string = "<a href=\"" . $request . "\">" . $value . "</a>";
return $string;
}
function getAlexaRank($domain) {
$request = "http://data.alexa.com/data?cli=10&dat=s&url=" . $domain;
$data = getPageData($request);
preg_match('/<POPULARITY URL="(.*?)" TEXT="([\d]+)"\/>/si', $data, $p);
$value = ($p[2]) ? $p[2] : "n/a";
$string = "<a href=\"http://www.alexa.com/data/details/traffic_details?url=" . $domain . "\">" . number_format($value) . "</a>";
return $string;
}
function getAlexaLinks($domain) {
$request = "http://data.alexa.com/data?cli=10&dat=s&url=" . $domain;
$data = getPageData($request);
preg_match('/<LINKSIN NUM="([\d]+)"\/>/si', $data, $l);
$value = ($l[1]) ? $l[1] : "n/a";
$string.= "<a href=\"http://www.alexa.com/data/ds/linksin?url=" . $domain . "\">" . number_format($value) . "</a>";
return $string;
}
function getDMOZListings($domain) {
$request = "http://data.alexa.com/data?cli=10&url=" . $domain;
$data = getPageData($request);
preg_match('/<SITE BASE="(.*?)" TITLE="(.*?)" DESC="(.*?)">/si', $data, $s);
$value1 = ($s[1]) ? $s[1] : "";
$value2 = ($s[2]) ? $s[2] : "";
$value3 = ($s[3]) ? $s[3] : "";
preg_match('/<CAT ID="(.*?)" TITLE="(.*?)" CID="(.*?)"\/>/si', $data, $c);
$value4 = ($c[1]) ? $c[1] : "";
$value5 = ($c[2]) ? $c[2] : "";
$value6 = ($c[3]) ? $c[3] : "";
$string = "";
if($value4) {
$string = "<a href=\"http://www.dmoz.org/" . str_replace("Top/","", $value4) . "\" title=\"" . $value2 . " - " . $value3 . "\">" . $value5 . "</a>";
}
else $string = "n/a";
return $string;
}
function getSiteAdvisorRating($domain) {
$request = "http://www.siteadvisor.com/sites/" . $domain . "?ref=safe&locale=en-US";
$data = getPageData($request);
preg_match('/(green|yellow|red)-xbg2\.gif/si', $data, $r);
$value = ($r[1]) ? $r[1] : "grey";
$string = "<a href=\"" . $request . "\">" . $value . "</a>";
return $string;
}
function getPageData($url) {
if(function_exists('curl_init')) {
$ch = curl_init($url); // initialize curl with given url
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // add useragent
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable
if((ini_get('open_basedir') == '') && (ini_get('safe_mode') == 'Off')) {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any
}
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // max. seconds to execute
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error
return @curl_exec($ch);
}
else {
return @file_get_contents($url);
}
}
function getHostName($url) {
$urlary = @parse_url($url);
$host = $urlary['host'];
return $host;
}
function getDomainName($host) {
$hostparts = explode('.', $host); // split host name to parts
$num = count($hostparts); // get parts number
if(preg_match('/^(ac|arpa|biz|co|com|edu|gov|info|int|me|mil|mobi|museum|name|net|org|pp|tv)$/i', $hostparts[$num-2])) { // for ccTLDs like .co.uk etc.
$domain = $hostparts[$num-3] . '.' . $hostparts[$num-2] . '.' . $hostparts[$num-1];
}
else {
$domain = $hostparts[$num-2] . '.' . $hostparts[$num-1];
}
return $domain;
}
$sitehost = $_SERVER['HTTP_HOST'];
$sitedomain = getDomainName($sitehost);
require(WWWROOT . 'skins/' . $skin . '/header.php');
?>
<!-- BEGIN BODY -->
<table border="0" width="90%">
<tr>
<td align="left">
<h2><?php echo $site_name; ?> SEO Report</h2>
<ul>
<li>Google indexed pages: <?php echo getGooglePages($sitehost); ?></li>
<li>Google inbound links: <?php echo getGoogleLinks($sitehost); ?></li>
<li>Yahoo indexed pages: <?php echo getYahooPages($sitehost); ?></li>
<li>Yahoo inbound links: <?php echo getYahooLinks($sitehost); ?></li>
<li>MSN/Live indexed pages: <?php echo getMSNPages($sitehost); ?></li>
<!-- MSN/Live inbound links feature is currently suspended: -->
<li>MSN/Live inbound links: <?php echo getMSNLinks($sitehost); ?></li>
<li>Ask indexed pages: <?php echo getAskPages($sitehost); ?></li>
<li>Alexa Rank: <?php echo getAlexaRank($sitedomain); ?></li>
<li>Alexa inbound links: <?php echo getAlexaLinks($sitedomain); ?></li>
<li>DMOZ listing: <?php echo getDMOZListings($sitedomain); ?></li>
<li>SiteAdvisor rating: <?php echo getSiteAdvisorRating($sitedomain); ?></li>
</ul>
</td>
</tr>
</table>
<!-- END BODY -->
<?php
require(WWWROOT . 'skins/' . $skin . '/footer.php');
?>