Skip to content

Instantly share code, notes, and snippets.

View xombra's full-sized avatar

Hector A. Mantellini xombra

View GitHub Profile
@xombra
xombra / exif
Created April 27, 2014 02:00
exif de una imagen
$exif = exif_read_data('aqui_la_imagen.jpg', 0, true);
header("Content-type: image/jpeg");
$imagen = exif_thumbnail("IMG-20140326-WA0010.jpg");
imagejpeg($imagen,NULL,100);
foreach ($exif as $clave => $seccion) {
foreach ($seccion as $nombre => $valor) {
if ( "$clave.$nombre" == 'FILE.FileDateTime'){ $valor = date("d-m-Y",$valor); }
echo "$clave.$nombre : $valor<br />\n";
}
}
@xombra
xombra / compress
Created April 27, 2014 02:03
Comprimir Texto o sitio web
function compress($buffer)
{ $search = array('/\>[^\S ]+/s','/[^\S ]+\</s','/(\s)+/s',"/\s+/");
$replace = array('>','<','\\1',' ');
$buffer = trim(preg_replace($search, $replace, $buffer));
$buffer = str_replace(' }','}', $buffer);
$buffer = str_replace('{ ','{', $buffer);
return $buffer;
}
@xombra
xombra / verifica_puertos
Created April 27, 2014 02:07
Verifica Puertos Abiertos
// Verificación de puertos
$ip = gethostbyaddr($_SERVER['REMOTE_ADDR']); // direccion IP
$timeout = 1; // 1 segundo de espera Máximo recomendado 10
$puertos_TCP = array(21, // puertos usados
22,
23,
25,
79,
80,
110,
@xombra
xombra / get_source
Created April 27, 2014 02:11
Extraer código HTML de un sitio web
function get_source($url,$quitar,$show_headers=0)
{ if(preg_match('!^http://!',$url))
$url=substr($url,7,strlen($url));
if($start=strpos($url,'/')) $uri=substr($url,$start,strlen($url));
else $uri='';
$fp= @fsockopen($url,80,$errno,$errstr,4);
if(!$fp)
{ echo "Imposible conectar $url o no ha indicado URL";
return false;
}
@xombra
xombra / dtermina_movil
Created April 27, 2014 02:12
Determinar si se accede desde un Móvil
function MOVIL($lista_user_agents, $user_agents_capturado){
$List_User_Agent = array(
'android' => 'android', 'AvantGo' => 'AvantGo', 'PLAYSTATION' => 'PLAYSTATION','Mobile','Mobile',
'BlackBerry' => 'BlackBerry', 'blazer' => 'blazer', 'hiptop' => 'hiptop', 'GoBrowser' => 'GoBrowser',
'Cellphone' => 'Cellphone', 'EudoraWeb' => 'EudoraWeb', 'fennec' => 'fennec', 'IEMobile' => 'IEMobile',
'iPhone' => 'iPhone', 'iPod' => 'iPod', 'Googlebot-Mobile' => 'Googlebot-Mobile', 'Iris' => 'Iris',
'iphone' => 'iphone', 'GoogleMobilizer' => 'Google Wireless Transcoder', 'KYOCERA' => 'KYOCERA',
'LGE' => 'LGE', 'midp' => 'midp', 'Minimo' => 'Minimo', 'NetFront' => 'NetFront', 'Dorothy' => 'Dorothy',
'Nintendo' => 'Nintendo', 'Nitro' => 'Nitro', 'Nokia' => 'Nokia', 'Motorola' => 'mot-', 'TeaShark' => 'TeaShark',
'OperaMini' => 'Opera Mini', 'Palm' => 'Palm', 'PDA' => 'PDA', 'Blazer' => 'Blazer', 'iPad' => 'iPad',
@xombra
xombra / pub_google
Created April 27, 2014 02:15
Para mostrar publicidad de Google
function PUB_GOOGLE($google_ad_client,$google_ad_slot,$google_ad_width,$google_ad_height)
{
?>
<script async type="text/javascript">
google_ad_client = "<?php echo $google_ad_client; ?>";
google_ad_slot = "<?php echo $google_ad_slot; ?>";
google_ad_width = <?php echo $google_ad_width; ?>;
google_ad_height = <?php echo $google_ad_height; ?>;
</script>
<script async type="text/javascript"
@xombra
xombra / timezone
Created April 27, 2014 02:17
Formato Fecha y Localizacion
function TIMEZONE($time, $zone) {
setlocale(LC_ALL, 'es_VE');
$output = date("D, j-M-Y", ($time + (3600 * $zone)));
return $output;
}
function TIMEZONE_SHORT($time, $zone) {
setlocale(LC_ALL, 'es_VE');
$output = date("d/m/Y", ($time + (3600 * $zone)));
return $output;
@xombra
xombra / User_Agent
Created May 6, 2014 15:24
User_Agent para moviles (redireccionamiento)
$List_User_Agent = array(
'android' => 'android', 'AvantGo' => 'AvantGo', 'PLAYSTATION' => 'PLAYSTATION','Mobile','Mobile',
'BlackBerry' => 'BlackBerry', 'blazer' => 'blazer', 'hiptop' => 'hiptop', 'GoBrowser' => 'GoBrowser',
'Cellphone' => 'Cellphone', 'EudoraWeb' => 'EudoraWeb', 'fennec' => 'fennec', 'IEMobile' => 'IEMobile',
'iPhone' => 'iPhone', 'iPod' => 'iPod', 'Googlebot-Mobile' => 'Googlebot-Mobile', 'Iris' => 'Iris',
'iphone' => 'iphone', 'GoogleMobilizer' => 'Google Wireless Transcoder', 'KYOCERA' => 'KYOCERA',
'LGE' => 'LGE', 'midp' => 'midp', 'Minimo' => 'Minimo', 'NetFront' => 'NetFront', 'Dorothy' => 'Dorothy',
'Nintendo' => 'Nintendo', 'Nitro' => 'Nitro', 'Nokia' => 'Nokia', 'Motorola' => 'mot-', 'TeaShark' => 'TeaShark',
'OperaMini' => 'Opera Mini', 'Palm' => 'Palm', 'PDA' => 'PDA', 'Blazer' => 'Blazer', 'iPad' => 'iPad',
'BOLT' => 'BOLT', 'Fennec' => 'Fennec', 'Opera Mobi' => 'Opera Mobi', 'Series60' => 'Se
<?php
# Extrae imagenes de un usuario y se filtra por los hastag
#
# Uso:
# Debe crear un archivo .txt de nombre data.txt
# Debe crear una carpeta de nombre grabar
#
/*
@xombra
xombra / TOKEN.php
Created June 17, 2014 22:23
Crear y verificar Token para evitar csrf
function CREAR_TOKEN($TokenForm)
{ $token = md5(uniqid(microtime(), true));
$token_time = time();
$_SESSION['csrf'][$TokenForm.'_token'] = array('token'=>$token, 'time'=>$token_time);
return $token;
}
function VERIFICA_TOKEN($TokenForm, $token)
{ if(!isset($_SESSION['csrf'][$TokenForm.'_token'])) {
return false;
}