Class Class_GetPage
{
private $xml;
private $page;
private $lien;
private $select;
private $nbPage;
private $arrayPage;
function __construct($xml="")
{
if(!empty($xml))
$this->xml = $xml;
$this->nbPage = -1;
}
public function load($xml)
{
if(!empty($xml))
{
if(is_array($xml))
$this->xml = $xml;
else
{
$this->page = $xml;
$this->lien = "page/".$this->page;
}
}
}
public function hasHtml()
{
for($i=1;$i<=4;$i++)
{
if(@file("page/".$i.".txt"))
return true;
}
return false;
}
public function getPageHTML()
{
$array = array();
for($i=1;$i<=4;$i++)
{
if(@file("page/".$i.".txt"))
$array[] = $i.".txt";
}
return $array;
}
public function htmlExist()
{
if(@file($this->lien))
return true;
return false;
}
public function getHtml($limit,$more,$h1)
{
$html = file_get_contents($this->lien);
if($limit)
{
if(strlen($html) > 200)
$html = substr($html,0,$limit)."...";
}
if($h1)
$html = preg_replace("#
.*?
(
)?#","",$html);
if($more)
$html .= '
>> Lire la suite';
return $html;
}
public function getPages()
{
if(!empty($this->arrayPage))
return $this->arrayPage;
$this->arrayPage = array();
foreach($this->xml as $xml)
{
foreach($xml as $key => $val)
{
if(preg_match("/page/",$key))
{
if($val != "" && $this->getTitre($key))
{
$this->arrayPage[] = $key;
}
}
}
}
if($this->hasHtml())
{
foreach($this->getPageHTML() as $val)
{
$this->arrayPage[] = $val;
}
}
// print_r($this->arrayPage);
$this->nbPage = sizeof($this->arrayPage);
return $this->arrayPage;
}
public function setPageSelect($select)
{
if(!empty($select))
{
if(is_numeric($select))
$this->select = "page".$select;
else
$this->select = $select;
}
}
public function setText($page,$txt){
preg_replace(array("<",">","é","è"),array("<",">","é","è"),$txt);
file_put_contents("./page/".$page,$txt);
}
public function getText()
{
global $lang;
if($this->getType()=="xml")
{
$s = $this->select;
$this->xml->$s = preg_replace("#<!\-\-.*?>(.*?)</.*?>#","",$this->xml->$s);
$this->xml->$s = preg_replace("#’#","'",$this->xml->$s);
if(preg_match("#(<EN.*?>(.*?)</EN.*?>)|((.*?))#",$this->xml->$s,$r))
{
if($lang=="fr")
{
preg_match("#(^(.*?)<EN.*?>)|(^(.*?))#",$this->xml->$s,$r);
return $r[0];
}
else
return $r[0];
}
else
{
return $this->xml->$s;
}
}
elseif($this->getType()=="page")
{
global $agence;
global $logo;
global $ovh;
global $capital;
global $devise;
global $siege;
global $siret;
global $responsablepub;
global $mailres;
global $tva;
global $RCS;
global $numcartepro;
global $raison;
global $ndd;
global $oneandone;
global $hebergeur;
global $telhebergeur;
$txt = file_get_contents("./page/".$this->select);
preg_match_all("/(\[.*?\])+/",$txt,$array);
foreach($array[0] as $a)
{
$eval = str_replace(array("[","]"),"",$a);
eval("\$eval = ".$eval.";");
$txt = str_replace($a,$eval,$txt);
}
if(preg_match("#(<EN.*?>(.*?)</EN.*?>)|((.*?))#",$txt,$r))
{
if($lang=="fr")
{
$txt = preg_replace("#(<EN.*?>(.*?)</EN.*?>)|((.*?))#","",$txt);
return $txt;
}
else
return $r[0];
}
else
{
return $txt;
}
}
}
public function setName($name){
$this->select = $name;
}
public function getName()
{
return $this->select;
}
public function getType()
{
if(preg_match("/txt/",$this->select))
{
return "page";
}
elseif(preg_match("/page/",$this->select))
{
return "xml";
}
}
public function getTitre($sel="")
{
global $t;
if(!empty($sel))$s = $sel;
else $s = $this->select;
if(preg_match("/txt/",$s))
$txt = file_get_contents("./page/".$s);
else
$txt = $this->xml->$s;
preg_match("#(.*?)#",$txt,$r);
if(empty($r[1]))
preg_match("#<!\-\-.*?>(.*?)</#",$txt,$r);
if($t->t(car($r[1],"low-é")) != car($r[1],"low-é"))
return $t->t(car($r[1],"low-é"));
return $r[1];
}
public function getNameByTitle($title,$ty=false)
{
foreach($this->getPages() as $val)
{
$this->setPageSelect($val);
if($title == car($this->getTitre(),"élow-"))
return $val;
}
}
public function getNbPage()
{
if($this->nbPage == -1)
{
$this->getPages();
}
return $this->nbPage;
}
}
?>
class Class_GoogleBot
{
private $GGB;
private $GGB_DATA;
private $hash;
function __construct()
{
if(isset($_GET['_escaped_fragment_']))
{
$this->GGB = true;
$this->hash = $_GET["_escaped_fragment_"];
// $this->GGB_DATA["txt"] = false;
// $this->GGB_DATA["bien"] = false;
// $this->GGB_DATA["annonces"] = false;
// $this->run();
}
else
$this->GGB = false;
}
public function run()
{
if(empty($this->hash))
{
$this->GGB_DATA["annonces"] = true;
$this->GGB_DATA["loc"] = "tou les";
}
elseif(preg_match("#annonce\-#",$this->hash))
{
$split = explode("-",$this->hash);
$this->GGB_DATA["pos"] = $split[sizeof($split)-1];
$this->GGB_DATA["pos"] = substr($this->GGB_DATA["pos"],0,-1);
global $C_bien;
$pos = $C_bien->getPosBienByRef($this->GGB_DATA["pos"]);
$this->GGB_DATA["pos"] = $pos;
$this->GGB_DATA["bien"] = true;
}
elseif(preg_match("#page\-#",$this->hash))
{
$this->GGB_DATA["txt"] = true;
$this->GGB_DATA["titre"] = car($this->hash);
if(preg_match("#-xml-#",$this->hash))
{
$this->GGB_DATA["type"] = "xml";
}
elseif(preg_match("#-page-#",$this->hash))
{
$this->GGB_DATA["type"] = "page";
}
elseif(preg_match("#-frame-#",$this->hash))
{
$this->GGB_DATA["type"] = "frame";
}
}
elseif(preg_match("#annonces\-#",$this->hash))
{
$this->GGB_DATA["annonces"] = true;
if(preg_match("#\-secteur#",$this->hash))
$this->GGB_DATA["type"] = "secteur";
elseif(preg_match("#\-ville#",$this->hash))
$this->GGB_DATA["type"] = "ville";
else
$this->GGB_DATA["type"] = "all";
if($this->GGB_DATA["type"] == "all")
$this->GGB_DATA["loc"] = "tou les";
else
{
preg_match("#annonces-immobilieres-(.*?)-".$this->GGB_DATA["type"]."/#",$this->hash,$r);
$this->GGB_DATA["loc"] = $r[1];
}
}
}
public function getTitrePage()
{
global $C_page;
global $C_bien;
if($this->GGB_DATA["bien"])
{
$C_bien->setBienByPos($C_bien->getPosBienByRef($this->GGB_DATA["pos"],true));
$titrePage = car($C_bien->getTypeBien())." - ".$C_bien->getPrix(true)." - ".$C_bien->getLocalisation();
}
elseif($this->GGB_DATA["type"] == "xml" || $this->GGB_DATA["type"] == "page")
{
$this->GGB_DATA["page"] = $C_page->getNameByTitle(str_replace("/","",$this->GGB_DATA["titre"]),$this->GGB_DATA["type"]);
$C_page->setPageSelect($this->GGB_DATA["page"]);
$titrePage = car($C_page->getTitre());
}
elseif($this->GGB_DATA["type"] == "frame")
{
$this->GGB_DATA["titreP"] = str_replace(array("page-frame-","-","/"),array(""," ",""),$this->GGB_DATA["titre"]);
$this->GGB_DATA["titreP"] = preg_split("/ /",$this->GGB_DATA["titreP"]);
foreach($this->GGB_DATA["titreP"] as $ch)
$this->GGB_DATA["t"] .= ucfirst($ch)." ";
$titrePage = substr($this->GGB_DATA["t"],0,-1);
}
elseif($this->GGB_DATA["annonces"])
{
if(preg_match("/tou.*?les/",$this->GGB_DATA["loc"]))
$titrePage = "Annonces immobilières ".$agence->nom_agence;
else
{
$titrePage = "Annonces immobilières ".ucfirst(str_replace("-"," ",$this->GGB_DATA["loc"]));
}
}
return $titrePage;
}
public function getLoc()
{
return $this->GGB_DATA["loc"];
}
public function getHash()
{
return $this->hash;
}
public function getUrl()
{
global $dir;
return "http://".$_SERVER['HTTP_HOST']."/#!".$dir.$this->hash;
}
public function getData()
{
return $this->GGB_DATA;
}
public function getText()
{
global $C_page;
global $agence;
if($this->GGB_DATA["type"] == "xml")
{
// echo $GGB_DATA["titre"];
$this->GGB_DATA["page"] = $C_page->getNameByTitle(str_replace("/","",car($this->GGB_DATA["titre"],"low-é")),$this->GGB_DATA["type"]);
$C_page->setPageSelect($this->GGB_DATA["page"]);
$html = '
'.$this->getUrl().'
'.$agence->nom_agence.'
'.car($C_page->getTitre()).'
'.car($C_page->getText()).'
';
}
elseif($this->GGB_DATA["type"] == "page")
{
$this->GGB_DATA["page"] = $C_page->getNameByTitle(str_replace("/","",$this->GGB_DATA["titre"]),$this->GGB_DATA["type"]);
$html = '
'.$this->getUrl().'
'.$agence->nom_agence.'
'.car($C_page->getTitre()).'
'.car($C_page->getText()).'
';
}
elseif($this->GGB_DATA["type"] == "frame")
{
$this->GGB_DATA["page"] = str_replace(array("page-frame-","-","/"),"",$this->GGB_DATA["titre"]);
$html = '';
}
return $html;
}
public function getPos()
{
return $this->GGB_DATA["pos"];
}
public function isGGB()
{
return $this->GGB;
}
public function isText()
{
if($this->GGB_DATA["txt"])return true;
return false;
}
public function isAnnonces()
{
if($this->GGB_DATA["annonces"])return true;
return false;
}
public function isBien()
{
if($this->GGB_DATA["bien"])return true;
return false;
}
public function forceShow($t)
{
if($this->GGB_DATA[$t])
return " force-show ";
return "";
}
}
?>
Class Class_GetVisite
{
private $pos;
private $data;
public function __construct($pos = 0)
{
if($this->setPos($pos))
{
$this->getData();
$this->addVisiteurByPosBien();
$this->del30daysNbVisiteur();
$this->saveData();
}
}
public function addVisiteurByPosBien()
{
if(empty($this->pos))
return false;
if($this->hasShowThisPage())
return false;
$date = date("Ymd");
if(empty($this->data[$this->pos]))
$this->data[$this->pos][$date] = 0;
$this->data[$this->pos][$date]++;
$_SESSION["visite"] .= "|".$this->pos."|";
return true;
}
public function getAllVisiteurByPosBien()
{
if(empty($this->pos))
return false;
$nb = 0;
/*print_r("
DATA : ");
print_r($this->data);*/
foreach($this->data[$this->pos] as $v)
{
$nb += $v;
}
return $nb;
}
public function hasShowThisPage()
{
if(preg_match("/\|".$this->pos."\|/",$_SESSION["visite"]))
return true;
return false;
}
public function setPos($pos)
{
if($pos === 0 || empty($pos))
return false;
$this->pos = $pos;
return true;
}
public function getPos()
{
return $this->pos;
}
public function saveData($file = "./visites.json")
{
if(file_put_contents($file,json_encode($this->data)))
return true;
return false;
}
public function getData($file = "./visites.json")
{
$json = file_get_contents($file);
$this->data = json_decode($json,true);
return true;
}
public function del30daysNbVisiteur()
{
$ddj = date("Ymd");
$d1m = date("Ymd",(time-3600*24*30));
unset($this->data[$this->pos][$d1m]);
}
}
?>