#include <infodrom.style>
#include <phptools.inc>
+<future>
<?
function convert_date($date)
{
$date = convert_date($_POST['date']);
$orig_name = $_POST['name'];
-<:
- for $i (('name','city','country','url','deburl','localurl','comment')) {
- printf " \$%s=sql_prepare (\$_POST[%s]);\n", $i, $i;
- }
-:>
$oid = 0;
- if ($_POST['id'] > 0) {
- if (isset($_POST['delete'])) {
+
+ if ($_POST['id'] > 0 && isset($_POST['delete'])) {
$query = sprintf ("DELETE FROM events WHERE oid = %d", $_POST['id']);
- } else {
- $oid = $_POST['id'];
- $query = sprintf ("UPDATE events SET name='%s',start='%s',delta='%s',city='%s',country='%s',"
- ."conference=%d,exhibition=%d,url='%s',deburl='%s',localurl='%s',comment='%s',cancelled=%d WHERE oid = %d",
- $name,
- $date, $days, $city, $country, $_POST[conference], $_POST[exhibition], $url, $deburl, $localurl,
- $comment,
- $_POST['cancelled'], $_POST['id']);
- }
+ $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
} else {
- $query = sprintf ("INSERT INTO events "
- ."(start,delta,name,city,country,conference,exhibition,url,deburl,localurl,comment,cancelled,inserted) "
- ."VALUES ('%s','%s','%s','%s','%s',%d,%d,'%s','%s','%s','%s',%d,'now')",
- $date, $days,
- $name,
- $city, $country, $_POST['conference'], $_POST['exhibition'], $url, $deburl, $localurl,
- $comment,
- $_POST['cancelled']);
- }
- //printf ("<pre>\n%s\n</pre>\n", $query);
- $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
-
- if ($oid == 0 && empty($_POST['id'])) {
- $oid = pg_last_oid($sth);
- if ($oid === false)
- die("INSERT failed");
+ $item = ['start' => $date,
+ 'delta' => $days,
+ 'name' => $_POST['name'],
+ 'city' => $_POST['city'],
+ 'country' => $_POST['country'],
+ 'conference' => isset($_POST['conference'])?1:0,
+ 'exhibition' => isset($_POST['exhibition'])?1:0,
+ 'cancelled' => isset($_POST['cancelled'])?1:0,
+ 'url' => $_POST['url'],
+ 'deburl' => $_POST['deburl'],
+ 'localurl' => $_POST['localurl'],
+ 'comment' => $_POST['comment'],
+ ];
+
+ if ($_POST['id'] > 0) {
+ $db->update('events', $item, 'oid = ' . intval($_POST['id']));
+ } else {
+ $item['inserted'] = 'now()';
+ $db->insertInto('events', $item);
+ }
}
- if ($oid > 0) {
- printf('<h3><a href="show.php?id=%d">%s</a></h3>', $oid, $orig_name);
- } else
- printf("<h3>%s</h3>", $orig_name);
-
-?>
-
-<?
if ($_POST['id'] > 0) {
if ($_POST['delete'])
echo "<p>deleted.</p>";