Sélectionner une révision Git
-
Alexandre Morignot a rédigéAlexandre Morignot a rédigé
index.php 1,61 Kio
<?php
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$bdd = new PDO('mysql:host=mysql.iiens.net;dbname=assoce_nightiies', 'assoce_nightiies', 'VwuQREP5JwJQTF5h', array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
$samPics = array('sam1.jpg', 'sam2.jpg', 'sam3.jpg');
$app->get(
'/',
function () {
global $samPics;
global $bdd;
$sam = $samPics[array_rand($samPics)];
$events = $bdd->prepare('SELECT s.id, title, date, place, description, GROUP_CONCAT(nick SEPARATOR ", ") as nicks
FROM sam s
LEFT OUTER JOIN sam_users su ON s.id = su.event
WHERE date > '.time().'
GROUP BY s.id
ORDER BY date');
$events->execute();
echo <<<EOF
<html>
<head>
<link rel="stylesheet" type="text/css" href="/links/common.css">
</head>
<body>
<div class="header">
<img src="assets/sam/$sam" style="margin:auto">
</div>
<div class="content">
<table class="calendar">
<thead>
<tr>
<th>id</th>
<th>Date</th>
<th>Titre</th>
<th>Description</th>
<th>Salle</th>
<th>Participants</th>
</tr>
</thead>
<tbody>
EOF;
while ($event = $events->fetch()) {
$date = date('d/m/y', $event[2]);
$description = preg_replace("#(^|[\n ])(https?://[\w\#$%&~/.\-;:=,?@\[\]+]+)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $event[4]);
echo <<<EOF
<tr>
<td>$event[0]</td>
<td>$date</td>
<td>$event[1]</td>
<td>$description</td>
<td>$event[3]</td>
<td>$event[5]</td>
</tr>
EOF;
}
echo <<<EOF
</tbody>
</table>
</div>
</body>
</html>
EOF;
}
);
$app->run();
?>