Listar en nombre de archivos de un directorio con PHP

Tags:

if ($handle = opendir($path)) {

$ret = ”;
while (false !== ($file = readdir($handle))) {
if($file!=”.” && $file!=”..”){
$ret =  $ret . ‘<li>
<a class=”thumb” href=”‘.$path.’/’.”$file\n”.’” title=”your image title”>
<img src=”‘.$path.’/’.”$file\n”.’” alt=”‘.$titulo.’” />
</a>
<div class=”caption”>
‘.$titulo.’
</div>
</li>’;
}

}
closedir($handle);
return $ret;

}

Continue reading » No comments

Función PHP para forzar la descarga de archivos

Tags: ,

function force_download($file)
{
if ((isset($file))&&(file_exists($file)))
{
header(“Content-length: “.filesize($file));
header(‘Content-Type: application/octet-stream’);
header(‘Content-Disposition: attachment; filename=”‘ . $file . ‘”‘);
readfile(“$file”);
}
else
{
echo “No se ha seleccionado ningún fichero”;
}
}

Continue reading » No comments

Acceder a Google Weather en PHP

Tags: , ,

Interesante clase para acceder de un modo sencillo al servicio metereológico de Google.Ejemplo:

<?php class GoogleWeatherAPI {
private $city_code = ”;
private $city = ”;
private $domain = ‘www.google.com’;
private $prefix_images = ”;
private $current_conditions = array();
private $forecast_conditions = array();
private $is_found = true;

/** * Class constructor
* @param $city_code is the label of the city
* @param $lang the lang of the [...]

Continue reading » No comments

Highlight menu in php

Tags:

Siempre he preferido incluir un archivo de menú de mis sitios en lugar de repetirlos en todas las páginas por la obvia razón de que los elementos de menú cambian a veces y que sea más fácil de cambiar un archivo que cambiar los enlaces en todas las páginas que muestran que el menú.
Así que [...]

Continue reading » 1 Comment