Skip to content
This repository was archived by the owner on Oct 17, 2021. It is now read-only.

Commit 0a71d13

Browse files
authored
Add files via upload
1 parent 9a4c263 commit 0a71d13

29 files changed

+11768
-0
lines changed

addEvent-json.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
//echo $_POST['title'];
4+
if (isset($_POST['title']) && isset($_POST['description']) && isset($_POST['start']) && isset($_POST['end']) && isset($_POST['color'])){
5+
6+
$jsonString = file_get_contents('json/events.json');
7+
$data = json_decode($jsonString, true);
8+
9+
$last_item = end($data);
10+
$last_item_id = $last_item['id'];
11+
12+
$start = explode(" ", $_POST['start']);
13+
$end = explode(" ", $_POST['end']);
14+
if($start[1] == '00:00:00'){
15+
$_POST['start'] = $start[0];
16+
}
17+
if($end[1] == '00:00:00'){
18+
$_POST['end'] = $end[0];
19+
}
20+
21+
22+
$extra = array(
23+
'id' => ++$last_item_id,
24+
'title' => $_POST['title'],
25+
'description' => $_POST['description'],
26+
'start' => $_POST['start'],
27+
'end' => $_POST['end'],
28+
'color' => $_POST['color'],
29+
);
30+
31+
$data[] = $extra;
32+
33+
$newJsonString = json_encode($data);
34+
file_put_contents('json/events.json', $newJsonString);
35+
36+
}
37+
header('Location: '.$_SERVER['HTTP_REFERER']);
38+
39+
?>
40+

addEvent.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
// Connexion à la base de données
4+
require_once('bdd.php');
5+
//echo $_POST['title'];
6+
if (isset($_POST['title']) && isset($_POST['description']) && isset($_POST['start']) && isset($_POST['end']) && isset($_POST['color'])){
7+
8+
$title = $_POST['title'];
9+
$description = $_POST['description'];
10+
$start = $_POST['start'];
11+
$end = $_POST['end'];
12+
$color = $_POST['color'];
13+
14+
$sql = "INSERT INTO events(title, description, start, end, color) values ('$title', '$description', '$start', '$end', '$color')";
15+
//$req = $bdd->prepare($sql);
16+
//$req->execute();
17+
18+
echo $sql;
19+
20+
$query = $bdd->prepare( $sql );
21+
if ($query == false) {
22+
print_r($bdd->errorInfo());
23+
die ('Erreur prepare');
24+
}
25+
$sth = $query->execute();
26+
if ($sth == false) {
27+
print_r($query->errorInfo());
28+
die ('Erreur execute');
29+
}
30+
31+
}
32+
header('Location: '.$_SERVER['HTTP_REFERER']);
33+
34+
35+
?>

bdd.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
try
3+
{
4+
$bdd = new PDO('mysql:host=localhost;dbname=calendar;charset=utf8', 'root', 'your_password');
5+
}
6+
catch(Exception $e)
7+
{
8+
die('Erreur : '.$e->getMessage());
9+
}

calendar.sql

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
-- phpMyAdmin SQL Dump
2+
-- version 4.1.14
3+
-- http://www.phpmyadmin.net
4+
--
5+
-- Client : 127.0.0.1
6+
-- Généré le : Jeu 24 Mars 2016 à 17:51
7+
-- Version du serveur : 5.6.17
8+
-- Version de PHP : 5.5.12
9+
10+
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11+
SET time_zone = "+00:00";
12+
13+
14+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
15+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
16+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
17+
/*!40101 SET NAMES utf8 */;
18+
19+
--
20+
-- Base de données : `calendar`
21+
--
22+
23+
-- --------------------------------------------------------
24+
25+
--
26+
-- Structure de la table `events`
27+
--
28+
29+
CREATE TABLE IF NOT EXISTS `events` (
30+
`id` int(11) NOT NULL AUTO_INCREMENT,
31+
`title` varchar(255) NOT NULL,
32+
`description` varchar(255) NOT NULL,
33+
`color` varchar(7) DEFAULT NULL,
34+
`start` datetime NOT NULL,
35+
`end` datetime DEFAULT NULL,
36+
PRIMARY KEY (`id`)
37+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ;
38+
39+
--
40+
-- Contenu de la table `events`
41+
--
42+
43+
INSERT INTO `events` (`id`, `title`, `description`, `color`, `start`, `end`) VALUES
44+
(1, 'All Day Event', 'some text for all day event', '#40E0D0', '2019-01-01 00:00:00', '2019-01-02 00:00:00'),
45+
(2, 'Long Event', 'some text for long event', '#FF0000', '2019-01-07 00:00:00', '2019-01-10 00:00:00'),
46+
(3, 'Short Event', 'some text for repeating event', '#0071c5', '2019-01-09 16:00:00', '2019-01-09 16:30:00'),
47+
(4, 'Conference', 'some text for conference', '#40E0D0', '2019-01-10 00:00:00', '2019-01-12 00:00:00'),
48+
(5, 'Meeting', 'some text for meeting', '#000', '2019-01-11 10:30:00', '2019-01-11 12:30:00'),
49+
(6, 'Lunch', 'some text for lunch', '#0071c5', '2019-01-11 12:00:00', '2019-01-11 1:00:00'),
50+
(7, 'Happy Hour', 'some text for happy hour', '#0071c5', '2019-01-11 17:30:00', '2019-01-11 19:00:00'),
51+
(8, 'Dinner', 'some text for dinner', '#0071c5', '2019-01-11 16:00:00', '2019-01-11 17:30:00'),
52+
(9, 'Birthday Party', 'some text for birthday party', '#FFD700', '2019-01-13 09:00:00', '2019-01-13 12:00:00'),
53+
(10, 'Vacation', 'some text for vacation', '#008000', '2019-01-18 00:00:00', '2019-01-21 00:00:00'),
54+
(11, 'Shopping', 'some text for shopping', '#FF8C00', '2019-01-31 17:30:00', '2019-01-31 18:30:00'),
55+
(12, 'Double click to change', 'some text for double click', '#000', '2019-01-22 00:00:00', '2019-01-22 00:00:00');
56+
57+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
58+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
59+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

0 commit comments

Comments
 (0)