Skip to content

Instantly share code, notes, and snippets.

View xombra's full-sized avatar

Hector A. Mantellini xombra

View GitHub Profile
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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 / bancos
Last active May 30, 2023 18:16
Codigo y Bancos correspondientes de Venezuela
Banco:
<select name="banco">
<option value=""></option>
<option value="0156">100%BANCO</option>
<option value="0196">ABN AMRO BANK</option>
<option value="0172">BANCAMIGA BANCO MICROFINANCIERO, C.A.</option>
<option value="0171">BANCO ACTIVO BANCO COMERCIAL, C.A.</option>
<option value="0166">BANCO AGRICOLA</option>
<option value="0175">BANCO BICENTENARIO</option>
<option value="0128">BANCO CARONI, C.A. BANCO UNIVERSAL</option>
@xombra
xombra / redimensiona
Last active August 5, 2017 13:29
Redimensionar imagen en caliente
function REDIMENSIONAR($anchura,$maxima_y,$nombre)
{ $img_nueva = $nombre;
$datos = getimagesize($nombre);
$maxima_y = $datos[1];
switch ($datos[2]) {
case 2:
$img = imagecreatefromjpeg($nombre);
break;
case 3:
$img = imagecreatefrompng($nombre);