1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
<?php
// include/functions.inc.php
// General functions
//
// Part of the ht://Check package
//
// Copyright (c) 1999-2004 Comune di Prato - Prato - Italy
// Author: Gabriele Bartolini - Prato - Italy <angusgb@users.sourceforge.net>
//
// For copyright details, see the file COPYING in your distribution
// or the GNU General Public License version 2 or later
// <http://www.gnu.org/copyleft/gpl.html>
//
// $Id: functions.inc.php,v 1.11 2004/06/01 08:56:19 angusgb Exp $
if ( defined( '__FUNCTIONS_INC' ) ) return;
define( '__FUNCTIONS_INC', 1 );
include ("./include/global.inc.php");
// Get the translation table for characters
$XSS_table = get_html_translation_table(HTML_ENTITIES);
$XSS_table['('] = '(';
$XSS_table[')'] = ')';
// Function for XSS safe writing (www.cgisecurity.com)
function WriteHTML($str)
{
global $XSS_table;
return strtr($str, $XSS_table);
}
function DisplayErrMsg($errmsg)
{
?>
<B><?php echo WriteHTML($errmsg); ?></B><BR>
<?php
}
///////
// Page Management
///////
function WritePageLink($initpage,$pagesize,$count,$dbname,$otherinfo="")
{
$nextoffset=$initpage+$pagesize;
$justone=false;
global $PHP_SELF;
global $strNext;
global $strPrevious;
if ($initpage >= $pagesize)
{
$justone=true;
if ($initpage >= $pagesize*2)
{
// Show the first page Link
global $strFirst;
?>
| <A href="<?php echo $PHP_SELF; ?>?dbname=<?php echo $dbname; ?>&initpage=0&pagesize=<?php echo $pagesize; ?>&count=<?php echo $count; ?><?php echo $otherinfo; ?>"><?php echo $strFirst; ?></A>
<?php
}
?>
| <A href="<?php echo $PHP_SELF; ?>?dbname=<?php echo $dbname; ?>&initpage=<?php echo $initpage-$pagesize; ?>&pagesize=<?php echo $pagesize; ?>&count=<?php echo $count; ?><?php echo $otherinfo; ?>"><?php echo $strPrevious; ?></A>
<?php
}
if ($nextoffset < $count)
{
$justone=true;
?>
| <A href="<?php echo $PHP_SELF; ?>?dbname=<?php echo $dbname; ?>&initpage=<?php echo $nextoffset; ?>&pagesize=<?php echo $pagesize; ?>&count=<?php echo $count; ?><?php echo $otherinfo; ?>"><?php echo $strNext; ?></A>
<?php
if ($nextoffset+$pagesize < $count)
{
// Show the last page Link
global $strLast;
$lastoffset=((int)((int)($count-1)/$pagesize))*$pagesize;
?>
| <A href="<?php echo $PHP_SELF; ?>?dbname=<?php echo $dbname; ?>&initpage=<?php echo $lastoffset; ?>&pagesize=<?php echo $pagesize; ?>&count=<?php echo $count; ?><?php echo $otherinfo; ?>"><?php echo $strLast; ?></A>
<?php
}
}
if ($justone)
{
echo "|";
// Show the full list Link
?>
<a href="<?php echo $PHP_SELF; ?>?dbname=<?php echo $dbname; ?>&initpage=0&pagesize=<?php echo $count; ?>&count=<?php echo $count; ?><?php echo $otherinfo; ?>">Elenco completo</a> |
<?php
}
}
function GetTextString($str)
{
if (empty($str))
$str='Unknown';
$str2 = "\$str" . (string) $str;
eval("global $str2;");
eval("\$tmp=$str2;");
return $tmp;
}
function GetURL($url)
{
global $MaxURLStrLength;
if ($MaxURLStrLength > 0 && strlen($url) > $MaxURLStrLength)
return WriteHTML(substr($url, 0, $MaxURLStrLength) . '[...]');
else return WriteHTML($url);
}
?>
|