Viewing file: consulta_documentos.php (2.99 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include ("conex.php");
function size($path, $formated = true, $retstring = null){
if(!is_dir($path) || !is_readable($path)){
if(is_file($path) || file_exists($path)){
$size = filesize($path);
} else {
return false;
}
} else {
$path_stack[] = $path;
$size = 0;
do {
$path = array_shift($path_stack);
$handle = opendir($path);
while(false !== ($file = readdir($handle))) {
if($file != '.' && $file != '..' && is_readable($path . DIRECTORY_SEPARATOR . $file)) {
if(is_dir($path . DIRECTORY_SEPARATOR . $file)){ $path_stack[] = $path . DIRECTORY_SEPARATOR . $file; }
$size += filesize($path . DIRECTORY_SEPARATOR . $file);
}
}
closedir($handle);
} while (count($path_stack)> 0);
}
if($formated){
$sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
if($retstring == null) { $retstring = '%01.2f %s'; }
$lastsizestring = end($sizes);
foreach($sizes as $sizestring){
if($size <1024){ break; }
if($sizestring != $lastsizestring){ $size /= 1024; }
}
if($sizestring == $sizes[0]){ $retstring = '%01d %s'; } // los Bytes normalmente no son fraccionales
$size = sprintf($retstring, $size, $sizestring);
}
return $size;
}
/*
echo $_GET['tipo'];
echo $_GET['sector'];
echo $_GET['ano'];
echo $_GET['resuelve'];
*/
if($_GET['tipo'] != ""){
$sqltipo= " and tipo = '$_GET[tipo]'";
}
if($_GET['nombre'] != ""){
$sqlnombre= " and nombre = '$_GET[nombre]'";
}
if($_GET['firma'] != ""){
$sqlfirma= " and firma like '%$_GET[firma]%'";
}
if($_GET['titulo'] != ""){
$sqltitulo= " and titulo like '%$_GET[titulo]%'";
}
$order = " order by id desc";
$sqlt = "SELECT `id` , `ano`, `tipo` , `nombre` , `titulo` , `firma` FROM `doc_imp` where 1=1";
$sqldef=$sqlt.$sqltipo.$sqlnombre.$sqltitulo.$sqlfirma.$sqlurl.$order;
//echo "$sqldef";
$sql=mysql_query($sqldef,$con);
$num_rows = mysql_num_rows($sql);
//muestra los datos consultados
echo "<table>
<caption>
<h5>Documentos importantes</h5></caption>
<thead>
<tr class='odd'>
<th scope='col' abbr='Home'><h5><span></span>Nombre</h5></th>
<th scope='col' abbr='Home'><h5><span></span>Título</h5></th>
<th scope='col' abbr='Home'><h5><span></span>Firma</h5></th>
<th scope='col' abbr='Home'><h5><span></span>Descarga</h5></th>
<th scope='col' abbr='Home'><h5><span></span>Tamaño</h5></th>
</tr>
</thead>
<tfoot>";
while($row = mysql_fetch_array($sql)){
$menu=ucfirst(strtolower($row['sector']));
$cont=$cont+1;
if ($cont % 2 == 0)
$class= "class='odd'";
if ($cont % 2 == 1)
$class= "";
$size_pdf = size("$row[tipo]/$row[ano]/$row[nombre].pdf");
$size_dir = size("./");
echo "
<tr $class>
<td>$row[nombre]</td>
<td>$row[titulo]</td>
<td>$row[firma]</td>
<td><a href='$row[tipo]/$row[ano]/$row[nombre].pdf'><img src='images/pdf.gif' width='32' height='35' border='0' align='absmiddle' target='_blank'/></a></td>
<td>$size_pdf</td>
";
}
?>
|