Browse Source

updated script to add event (WARNING: broken editEvent)

master
n0m1s 10 years ago
parent
commit
0445bc05a3
1 changed files with 24 additions and 5 deletions
  1. +24
    -5
      eventAdded.php

+ 24
- 5
eventAdded.php View File

@ -1,5 +1,6 @@
<?php
session_start();
include_once('databaseOperations.php');
include('datetimeOperations.php');
$db = connect();
@ -7,18 +8,36 @@ if(isset($_POST['id']))
$id = intval($_POST['id']);
$titre = htmlentities($_POST['title']);
$localisation = htmlentities($_POST['address']);
$dtstart = strtotime($_POST['dtstart']);
$dtend = strtotime($_POST['dtend']);
$description = htmlentities($_POST['description']);
$url = htmlspecialchars($_POST['site']);
$urlImage = htmlspecialchars($_POST['urlImage']);
$contact = htmlspecialchars($_POST['contact']);
$catArray = htmlspecialchars($_POST['chk_group']);
$dateTypes = array('debut', 'fin');
foreach($dateTypes as $dateType)
{
$year = intval($_POST[$dateType.'-select-year']);
$month = sprintf('%02d', intval($_POST[$dateType.'-select-mois']));
$day = sprintf('%02d', intval($_POST[$dateType.'-select-jour']));
$hour = sprintf('%02d', intval($_POST[$dateType.'-select-hour']));
$minutes = sprintf('%02d', intval($_POST[$dateType.'-select-minutes']));
$date[$dateType] = strtotime($year.'-'.$month.'-'.$day.' '.$hour.':'.$minutes);
}
$availableCategories = getCategories($db);
$catArray = array();
foreach($availableCategories as $cat)
{
if(isset($_POST['checkbox-cat-'.$cat['cat_id']]))
$catArray[] = $cat['cat_id'];
}
if(!isset($_POST['id']))
addEvent($db, $titre, $catArray, $localisation, $dtstart, $dtend, $description, $url, $urlImage, $contact);
addEvent($db, $titre, $catArray, $localisation, $date['debut'], $date['fin'], $description, $url, $urlImage, $contact);
else
updateEvent($db, $id, $titre, $catArray, $localisation, $dtstart, $dtend, $description, $url, $urlImage, $contact);
updateEvent($db, $id, $titre, $catArray, $localisation, $date['debut'], $date['fin'], $description, $url, $urlImage, $contact);
header('Location:./');
exit;
?>

Loading…
Cancel
Save