1 #include <infodrom.style>
2 #include "calendar.inc"
4 <page func="Infodrom Oldenburg" title="Events">
8 $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
9 or die("Unable to connect to SQL server");
11 pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
13 $query = "SELECT $event_cols FROM events WHERE ";
17 if (strlen ($_POST[city])) {
18 if (strlen ($where)) $where .= "AND ";
19 $where .= sprintf ("city = '%s' ", $_POST[city]);
22 if (strlen ($_POST[country])) {
23 if (strlen ($where)) $where .= "AND ";
24 $where .= sprintf ("country = '%s' ", $_POST[country]);
27 if (strlen ($_POST[year])) {
28 if (strlen ($where)) $where .= "AND ";
29 $where .= sprintf ("( start >= %d AND start < %d ) ", $_POST[year], (integer)$_POST[year] + 1);
32 if (strlen ($_POST[key])) {
33 if (strlen ($where)) $where .= "AND ";
34 if (strlen ($_POST[city]) || strlen ($_POST[country])) {
35 $where = sprintf ("( name ~* '%s' OR url ~* '%s' OR comment ~* '%s' ) ",
36 addslashes ($_POST[key]), addslashes ($_POST[key]), addslashes ($_POST[key]));
38 $where = sprintf ("( name ~* '%s' OR city ~* '%s' OR url ~* '%s' OR comment ~* '%s' ) ",
39 addslashes ($_POST[key]), addslashes ($_POST[key]), addslashes ($_POST[key]), addslashes ($_POST[key]));
42 if (!strlen ($where)) {
43 echo "<h3>Empty search? Euh?</h3>";
45 $query .= $where . " ORDER BY start,name";
47 if (strlen ($where)) {
48 $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
51 for ($i=0; $i < pg_NumRows ($sth); $i++) {
52 $row = pg_fetch_array ($sth, $i);
54 $date = explode (" ", $row['start']);
55 $date = explode ("-", $date[0]);
56 $end = explode (" ", $row[3]);
57 $end = explode ("-", $end[0]);
60 $date = format_date ($date, $end);
62 if ($thisyear != $year) {
64 echo ($event_table_end);
67 printf ("<h3>Events in %s</h3>", $thisyear);
68 echo ($event_table_start);
72 $row['name'] = ereg_replace (" ", " ", $row['name']);
73 $row['city'] = ereg_replace (" ", " ", $row['city']);
74 $row['country'] = ereg_replace (" ", " ", $row['country']);
76 $color = $color == "<cold>"?"<coln>" : "<cold>";
77 printf ($event_row, $color, $row['oid'], $row['name'], $row['cancelled'] == 1?" *cancelled*":"",
78 $row['city'], $row['country'], $date);
81 echo ($event_table_end);