<?
$GLOBALS["INCLUDED_LIBS"]["STATIZIER"] = true;
/**
* Statizier. A simple way to hide dinamic sites to web spiders so they can index it.
*
* Almost all web-spiders (like Google) can't index dinamic sites, because the parameters present on almost all links in the site.
* This class, along a simple modification onto your Apache configuration file, allows yo to hide all the parameters and dinamic-like links and URLs of your site, so all web spiders will catch it.
* Best of all, this will not take you too work to get this working into your dinamic site.
*
* Look at http://phpspain.hexoplastia.com/projects/statizier for full documentation on how to work with statizier
*
* @author Llorenç Herrera <hide@address.com>
* @version 1.0
* @package statizier
*/
class statizier
{
var $redirector_query_fragment;
var $dot_replacer;
var $section_parameters_separator;
var $parameters_separator;
var $parameters_equal;
function statizier
(
$redirector_query_fragment = "/statizier",
$dot_replacer = "_dot_",
$section_parameters_separator = "_params_",
$parameters_separator = "__",
$parameters_equal = "_"
)
{
$this->redirector_query_fragment = $redirector_query_fragment;
$this->dot_replacer = $dot_replacer;
$this->section_parameters_separator = $section_parameters_separator;
$this->parameters_separator = $parameters_separator;
$this->parameters_equal = $parameters_equal;
}
function getquery()
{
return $GLOBALS["HTTP_SERVER_VARS"]["REQUEST_URI"];
}
function dorequest()
{
$query = $this->getquery();
// Strip redirector_query_fragment
$query = substr($query, strlen($this->redirector_query_fragment));
// Replace dots
$query = str_replace($this->dot_replacer, ".", $query);
// Divide file from parameters
list($file, $parameters) = explode($this->section_parameters_separator, $query);
// If there are parameters
if($parameters != "")
{
// Parse them into an array
// Get tokens
$atokens = explode($this->parameters_separator, $parameters);
while(list(, $token) = each($atokens))
$aparameters[] = explode($this->parameters_equal, $token);
if(!is_array($aparameters))
$aparameters = null;
}else
$aparameters = null;
$this->redirect($this->buildrealquery($file, $aparameters));
}
function buildrealquery($file, $aparameters)
{
$retr = $file;
if(is_array($aparameters))
{
$retr .= "?";
while(list(, $parameter) = each($aparameters))
$retr .= $parameter[0]."=".$parameter[1]."&";
$retr = substr($retr, 0, strlen($retr)-1);
}
return $retr;
}
function redirect($url)
{
header("location: $url");
}
function buildquery($file, $aparameters)
{
list($domain, $file) = $this->dividequery($file);
$file = str_replace(".", $this->dot_replacer, $file);
if(is_array($aparameters))
{
$parameters = $this->section_parameters_separator;
while(list($name, $value) = each($aparameters))
$parameters .= $name.$this->parameters_equal.$value.$this->parameters_separator;
$parameters = substr($parameters, 0, strlen($parameters)-strlen($this->parameters_separator));
}
return $domain.$this->redirector_query_fragment."/".$file.$parameters;
}
function buildquery_fromhttp($query)
{
list($domain, $request) = $this->dividequery($query);
$retr = str_replace(".", $this->dot_replacer, $request);
$retr = str_replace("?", $this->section_parameters_separator, $retr);
$retr = str_replace("&", $this->parameters_separator, $retr);
$retr = str_replace("=", $this->parameters_equal, $retr);
return $domain.$this->redirector_query_fragment."/".$retr;
}
function dividequery($query)
{
if(stristr($query, "http://"))
{
$query = substr($query, 7);
$firstslash = strpos($query, "/");
$domain = substr($query, 0, $firstslash);
$file = substr($query, $firstslash+1);
return array("http://".$domain, $file);
}else
return array("", $query);
}
function error($string)
{
echo "<b>Statizier error:</b> ".$string."<br>";
die;
}
}
?>