<?
/*
Copyright (C) 2004 Mauro Franzoni
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include "inc/database.php";
include "inc/connect.php";
include "inc/copyright.php";
?>
<html>
<head>
<title><?=$PROG?> - risultati ricerca</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<font face="Arial, Helvetica, sans-serif" size="4"><b><?=$PROG?></b></font>
<center>
<?
function eubirdb_match($s, $m) {
return eregi_replace("($m)", "<b>\\1</b>", $s);
}
$font='<font face="Arial, Helvetica, sans-serif" size="2">';
$efont='</font>';
if ($Result) {
?>
<table border="1" cellspacing="0">
<?
include "inc/crosslist.php";
$Table = $DBfix."eubirdb_crosslist";
$query="SELECT ";
if (isset($columns)) {
$fields = array();
for ($i = 0; $i < count($columns); $i++) {
$fields[] = $checklist_afields[$columns[$i]];
}
} else {
$fields = $checklist_afields;
}
if (isset($vcolumns)) {
$vfields = array();
for ($i = 0; $i < count($vcolumns); $i++) {
$vfields[] = $checklist_afields[$vcolumns[$i]];
$vdescr[] = $checklist_adescr[$vcolumns[$i]];
}
} else {
$vfields = $checklist_afields;
$vdescr = $checklist_adescr;
}
for ($i = 0; $i < count($checklist_afields); $i++) {
$kdescr[$checklist_afields[$i]] = $checklist_adescr[$i];
}
echo " <tr>\n";
for ($i = 0; $i < count($vfields); $i++) {
if ($i > 0) {
$query .= ',';
}
$query .= " ".ereg_replace('"', '', $vfields[$i]);
echo " <th>$font".$vdescr[$i]."$efont</th>\n";
}
echo " </tr>\n";
$query .= " FROM $Table WHERE (";
for ($i = 0; $i < count($fields); $i++) {
if ($i > 0) {
$query .= ' OR ';
}
$query .= " $fields[$i] like '%$what%'";
}
$query .= ")";
if (isset($orderby)) {
$query .= " ORDER BY ";
for ($i = 0; $i < count($orderby); $i++) {
if ($i > 0) {
$query .= ',';
}
$query .= $orderby[$i];
}
}
if (!isset($NumEntries)) {
$NumEntries = 10;
}
if (!isset($StartIndex)) {
$StartIndex = 0;
}
$NextIndex = $StartIndex + $NumEntries;
$query .= " LIMIT $StartIndex,$NumEntries;";
if ($Result = mysql_query($query, $Session)) {
if (!$NumEntries) {
$NumEntries = 10;
}
if (!$StartIndex) {
$StartIndex = 0;
}
if (!$NextIndex) {
$NextIndex = $StartIndex + $NumEntries;
}
if ($LastIndex && ($StartIndex > $LastIndex)) {
if (($StartIndex = $LastIndex - $NumEntries) < 0) {
$StartIndex = 0;
}
}
for ($count = 0; $row=mysql_fetch_row($Result); $count++) {
echo " <tr>\n";
for ($i = 0; $i < count($vfields); $i++) {
echo " <td>$font".eubirdb_match(htmlentities($row[$i]), $what)."$efont</td>\n";
}
echo " </tr>\n";
}
$LastIndex = $StartIndex + $count;
} else {
$LastIndex = -1;
?>
<h1>errore di accesso al database</h1>
<h2><? echo $query ?></h2>
<h3><? echo mysql_error(); ?><br>
si prega di segnalare l'errore al <a href="mailto:hide@address.com">webmaster</a>
</h3>
<?
}
?>
<tr>
<td colspan="<? echo count($vfields); ?>">
<table border="0" cellspacing="0" cellpadding="0"
width="100%" vspace="0" hspace="0">
<tr>
<td align="center" width="33%" valign="top">
<?
if ($StartIndex > 0) {
if (($PrevIndex = $StartIndex - $NumEntries) < 0) {
$PrevIndex = 0;
}
?>
<form name="page" action="<?=$PHP_SELF?>" method="post">
<input type="hidden" name="eubirdb_lang" value="<?=@$eubirdb_lang?>">
<input type="submit" value="<<">
<input type="hidden" name="StartIndex" value="<? echo $PrevIndex; ?>">
<input type="hidden" name="NumEntries" value="<? echo $NumEntries; ?>">
<input type="hidden" name="sqlquery" value="<?=$query?>">
<input type="hidden" name="what" value="<?=$what?>">
<? if (isset($orderby)) { ?>
<? for ($i = 0; $i < count($orderby); $i++) { ?>
<input type="hidden" name="orderby[]" value="<? echo $orderby[$i]; ?>">
<? } ?>
<? } ?>
<? for ($i = 0; $i < count($columns); $i++) { ?>
<input type="hidden" name="columns[]" value="<? echo $columns[$i]; ?>">
<? } ?>
<? for ($i = 0; $i < count($vcolumns); $i++) { ?>
<input type="hidden" name="vcolumns[]" value="<? echo $vcolumns[$i]; ?>">
<? } ?>
<input type="hidden" name="Cmd" value="<? echo $Cmd; ?>">
</form>
<? } else { ?>
<? } ?>
</td>
<td align="center" width="34%">
<form action="cross.php" method="post">
<input type="hidden" name="eubirdb_lang" value="<?=@$eubirdb_lang?>">
<input type="submit" value="indice">
</form>
</td>
<td align="center" width="33%" valign="top">
<?
if ($NextIndex <= $LastIndex) {
?>
<form name="page" action="<?=$PHP_SELF?>" method="post">
<input type="hidden" name="eubirdb_lang" value="<?=@$eubirdb_lang?>">
<input type="submit" value=">>">
<input type="hidden" name="StartIndex" value="<? echo $NextIndex; ?>">
<input type="hidden" name="NumEntries" value="<? echo $NumEntries; ?>">
<input type="hidden" name="sqlquery" value="<?=$query?>">
<input type="hidden" name="what" value="<?=$what?>">
<? if (isset($orderby)) { ?>
<? for ($i = 0; $i < count($orderby); $i++) { ?>
<input type="hidden" name="orderby[]" value="<? echo $orderby[$i]; ?>">
<? } ?>
<? } ?>
<? for ($i = 0; $i < count($columns); $i++) { ?>
<input type="hidden" name="columns[]" value="<? echo $columns[$i]; ?>">
<? } ?>
<? for ($i = 0; $i < count($vcolumns); $i++) { ?>
<input type="hidden" name="vcolumns[]" value="<? echo $vcolumns[$i]; ?>">
<? } ?>
<input type="hidden" name="Cmd" value="<? echo $Cmd; ?>">
</form>
<? } else { ?>
<? } ?>
</td>
</tr>
</table>
</td>
</tr>
<? if (count($vfields) > 1) { ?>
<tr>
<td colspan="<? echo count($vfields); ?>" align="center">
<form name="sort" action="<?=$PHP_SELF?>" method="post">
<table border="0" cellspacing="0"><tr>
<td>
<font face="Arial, Helvetica, sans-serif" size="2">
<input type="hidden" name="eubirdb_lang" value="<?=@$eubirdb_lang?>">
<input type="submit" value="ordina" name="submit"> per
</font>
</td>
<td>
<font face="Arial, Helvetica, sans-serif" size="2">
<select name="orderby[]" size="2" multiple>
<? for ($i = 0; $i < count($vfields); $i++) {
$select="";
if (isset($orderby)) {
if (ereg(join(',', $orderby), $vfields[$i])) {
$select=" selected";
}
}
?>
<option value="<?=$vfields[$i];?>"<?=$select?>>
<?=$kdescr[$vfields[$i]];?>
</option>
<? } ?>
</select>
</font>
</td>
</tr></table>
<input type="hidden" name="StartIndex" value="<? echo $StartIndex; ?>">
<input type="hidden" name="NumEntries" value="<? echo $NumEntries; ?>">
<? /*
<input type="hidden" name="sqlquery" value="<?=$query?>">
*/ ?>
<input type="hidden" name="what" value="<?=$what?>">
<? for ($i = 0; $i < count($columns); $i++) { ?>
<input type="hidden" name="columns[]" value="<? echo $columns[$i]; ?>">
<? } ?>
<? for ($i = 0; $i < count($vcolumns); $i++) { ?>
<input type="hidden" name="vcolumns[]" value="<? echo $vcolumns[$i]; ?>">
<? } ?>
</form>
</td>
</tr>
<? } ?>
</table>
<?
} else {
?>
<h1>errore connessione al database</h1>
<h3><? echo mysql_error(); ?><br>
si prega di segnalare
l'errore al <a href="mailto:hide@address.com">webmaster</a> </h3>
<?
}
?>
<p align="center"><a href="mailto:hide@address.com">Per segnalazioni</a></p>
<? PROGnotice(@$GNUGPL) ?>
</center>
</body>
</html>