Skip to content

Instantly share code, notes, and snippets.

View xabikip's full-sized avatar
🐱
lear

Xabi xabikip

🐱
lear
View GitHub Profile
@xabikip
xabikip / UsoDeFunciones.php
Last active August 29, 2015 14:02
Pequeñas función para validar campos de un formulario que vienen a través de $_POST. Cada función va guardando el respectivo mensaje de error en un array.
ERROR_MSG_REQUIERE = "beharrezkoa da" ; mensaje de error para campos de formulario requeridos
ERROR_MSG_MAIL_FORMAT = "Emaila ez da egokia" ; mensaje de error si el formato de mail no es caracte@caracter.com
ERROR_MSG_TIME_FORMAT = "formatua honakoa izan behar da OO:MM" ; mensaje de error si el formato de hora no es HH:MM
ERROR_MSG_MYME_TYPE = "Irudiaren formatua ez da egokia. .jpg, .png, .gif, .bmp edo .tiff izan behar da" ; mensaje de error si el tipo myme no esta permitido
ERROR_MSG_IMG_MAXSIZE = "Irudiaren tamaina handiegia da." ; mensaje de error si el archivo subido excede la directiva upload_max_filesize del php.ini
ERROR_MSG_IMG = "Irudia igotzean arazo bat izan da" ; mensaje de error si ha habido algun error de tipo 2,3,6,7,8 de $_FILES en PHP
$errores = array();
$campoMail = 'email';
@xabikip
xabikip / cron_delete_files
Created January 14, 2015 15:32
cron in php to delete files recursively
#!/usr/bin/php
<?php
delete_file("/home/piko/curso-php/uploads/astinddu/");
function delete_file($ruta){
if (is_dir($ruta)) {
if ($dir = opendir($ruta)) {
while (($file = readdir($dir)) !== false) {
if(is_dir($ruta . $file) !== true && $file!="." && $file!=".."){
@xabikip
xabikip / graphicsmagick.sh
Last active August 29, 2015 14:13
Install graphics magick & it's php extension from source. Gaur egun bertsio berriena 1.3.20 da.
# Install graphics magick v1.3.20 from source (run as root)
# Install dependencies
apt-get build-dep graphicsmagick -y
# Download source
wget http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.18/GraphicsMagick-1.3.20.tar.bz2
tar -xvjf GraphicsMagick-1.3.20.tar.bz2
cd GraphicsMagick-1.3.20
@xabikip
xabikip / ascii.php
Last active June 14, 2017 13:06
Testu baten karaktere denak banan-banan berain ascii kodea jakiteko.
<?php
$testua = "Hau izango zan testua";
for ($i=0; $i < strlen($testua); $i++) {
print("\n karakterea: ");var_dump($testua[$i]);
print(" - htmlspecialchars: ");var_dump(htmlspecialchars($testua[$i]));
print(" - htmlentities: ");var_dump(htmlentities($testua[$i]));
print(" - htmlspecialchars_decode: ");var_dump(htmlspecialchars_decode($testua[$i]));
print(" - utf8_decode: ");var_dump(utf8_decode($testua[$i]));
@xabikip
xabikip / index.html
Last active February 15, 2023 14:40
HTML5 empty template
<!DOCTYPE html>
<html lang="eu">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<title>Titulua</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="keywords" content=""/>
<meta name="viewport" content="width=device-width, initial-scale=1">
@xabikip
xabikip / url.php
Last active September 21, 2015 13:40
Obtener URL actual
<?php
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$url_with_port = "http://".$_SERVER['HTTP_HOST'].":".$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'];
?>
@xabikip
xabikip / .htaccess
Created June 15, 2016 10:54 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/