Codice PHP:
<?php
// limit the id lenth to 6 characters... added security. If you think you'll have more than 999,999 events, you can increase this number.
$maxLen = 6;
$id = substr($_GET['id'],0,$maxLen);
//Connect To Database
include("admin/config.php");
mysql_connect($dbhost,$dbuser,$dbpass) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname) or die( "Unable to select database");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES utf8");
//minimized SQL injection attacks
$id = mysql_real_escape_string($id);
//if the event is in the future, print it out
$query="SELECT * FROM events WHERE location = '".$location."'
AND ((year_opening >= $current_year AND month_opening > $current_month)
OR (year_opening >= $current_year AND month_opening = $current_month AND day_opening >= $current_day))
ORDER BY year, month, day LIMIT 0, $maxnum";
$result=mysql_query($query);
//$num=mysql_numrows($result);
echo $query;
mysql_close();
$i=0;
//Get all the data and assign variables
$event=mysql_result($result,$i,"event");
$titolonuova=mysql_result($result,$i,"titolonuova");
$hour=mysql_result($result,$i,"hour");
$minute=mysql_result($result,$i,"minute");
$ampm=mysql_result($result,$i,"ampm");
$month=mysql_result($result,$i,"month");
$day=mysql_result($result,$i,"day");
$year=mysql_result($result,$i,"year");
$datenuova=mysql_result($result,$i,"datenuova");
$month_opening=mysql_result($result,$i,"month_opening");
$day_opening=mysql_result($result,$i,"day_opening");
$year_opening=mysql_result($result,$i,"year_opening");
$hour_opening=mysql_result($result,$i,"hour_opening");
$minute_opening=mysql_result($result,$i,"minute_opening");
$ampm_opening=mysql_result($result,$i,"ampm_opening");
$month_end=mysql_result($result,$i,"month_end");
$day_end=mysql_result($result,$i,"day_end");
$year_end=mysql_result($result,$i,"year_end");
$month_show=mysql_result($result,$i,"month_show");
$day_show=mysql_result($result,$i,"day_show");
$year_show=mysql_result($result,$i,"year_show");
$location=mysql_result($result,$i,"location");
$address=mysql_result($result,$i,"address");
$townn=mysql_result($result,$i,"town");
$email=mysql_result($result,$i,"email");
$phone=mysql_result($result,$i,"phone");
$link=mysql_result($result,$i,"link");
$link_name=mysql_result($result,$i,"link_name");
$description=mysql_result($result,$i,"description");
$descriznuova=mysql_result($result,$i,"descriznuova");
$html=mysql_result($result,$i,"html");
// removes slashes
$description=stripslashes($description);
//replaces carriage returns with html line breaks
if ($html =="0") {
$description=preg_replace("/\n/","
", ($description));
}
// removes the first zero from the hour. We need the zero at first, to keep the numbering in order.
//Of course the number ten needs the zero left in.
if ($hour !="10") {
$hour=preg_replace("/0/","", ($hour));
}
?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="events.css" rel="stylesheet" type="text/css">
<title><?php echo $event; ?></title>
</head>
<body>
<center>
<div class="myBox">
<font color="#660066">o<big>pen<sup>o</sup>pen</big><sup>[size="1"]©[/size]</sup>[size="1"]<small> mobile[/size]</small></font>
</div>
<hr>
</center>
[size="1"][url="../index.html"]<font color="#990066">home</font>[/url] < [url="../openopen/torino.html"]<font color="#990066">turin</font>[/url] < [url="torino.php"]<font color="#990066">opening</font>[/url]
< <?php echo $location; ?>[/size]
<hr>
<div class="main_area">
<?php
// removes the first zero from the hour. We need the zero at first, to keep the numbering in order.
//Of course the number ten needs the zero left in.
if ($hour !="10") {
$hour=preg_replace("/0/","", ($hour));
}
if ($hour_opening !="10") {
$hour_opening=preg_replace("/0/","", ($hour_opening));
}
if (($hour_opening =='') && ($minute_opening =='') && ($ampm_opening =='')) { $opening_time ='';}
else { $opening_time= " - $hour_opening:$minute_opening $ampm_opening"; }
if (($month_end =='') && ($day_end =='') && ($year_end =='')) { $end_date ='';}
else { $end_date= "- $month_end/$day_end/$year_end"; }
// Here is where we actually print out the events.
echo " <div class=\"myBoxEvent\">[size="1"]
[b]$location[/b]
$address
phone: $phone
[email='$email']$email[/email]
[url='$link']$link_name[/url][/size]</div>
current:
[b]$event[/b]
$day/$month/$year $day_end/$month_end/$year_end/
<span style=\"text-transform: none\">
$description </span><hr>
upcoming:
[b]$titolonuova[/b]
$datenuova
<span style=\"text-transform: none\">
$descriznuova </span><hr>
$html ";
?>
</div>
</body>
</html>