function timeCoincides($t1, $t2) { $s1 = intval(getStartTime($t1)); $e1 = intval(getEndTime($t1)); $s2 = intval(getStartTime($t2)); $e2 = intval(getEndTime($t2)); return $s1 <= $e2 and $e1 >= $s2; }
function getSongs($songsMixTitle, $sqlconn) { $songs = array(); $startTimes = array(); $songsMixTitle = str_replace("'", "\\'", $songsMixTitle); $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE MixName = '{$songsMixTitle}'", 'Mixes'); $mixid = getMixId($res); $res = $sqlconn->complexQuery("Select", "SELECT SongId FROM MixSongs WHERE MixId = '{$mixid}' ORDER BY SongId", 'MixSongs'); $songids = getSongIds($res); foreach ($songids as $songid) { $res = $sqlconn->complexQuery("Select", "SELECT * FROM Songs WHERE SongId = '{$songid}'", 'Songs'); $songs[] = getSong($res); $startTimes[] = getStartTime($res); } $args = array('VideoId' => $songs, 'StartTime' => $startTimes); $xml = createXML('Songs', $args); return $xml; }
<?php session_start(); require_once "config.php"; require_once "time.php"; require_once "getters.php"; $db = loadDatabase(); $email = $_SESSION['user']; $eventName = $_POST['eventName']; $description = $_POST['description']; $scheduleName = $_POST['scheduleName']; $eventStartTime = $_POST['eventStartTime']; $eventEndTime = $_POST['eventEndTime']; $userId = getUserId($db, $scheduleName, $email); $scheduleId = getScheduleId($db, $scheduleName, $userId); $startTime = getStartTime($db, $scheduleName, $scheduleId); $endTime = getEndTime($db, $scheduleName, $scheduleId); $placeEvent = schedule($db, $scheduleId, $eventStartTime, $eventStartTime, $startTime, $endTime); if ($placeEvent) { addToDatabase($db, $eventName, $description, $eventStartTime, $eventEndTime, $scheduleId); } function schedule($db, $scheduleId, $eventStartTime, $eventEndTime, $startTime, $endTime) { $query = "SELECT startTime, endTime FROM scheduleEvent se JOIN event e WHERE scheduleId=:id AND eventId = e.id"; $query = $db->prepare($query); $query->execute(array(':id' => $scheduleId)); $prevScheduledEnd; $isFull = false; foreach ($query->fetchAll() as $event) { if (isset($prevScheduledEnd) && greaterThanOrEqualToTime($eventStartTime, $prevScheduledEnd) && greaterThanOrEqualToTime($event['startTime'], $eventEndTime)) { return true;
} else { $showUnposted = false; } if (isset($_GET['print']) && $_GET['print'] == 1) { $printMode = true; } else { $printMode = false; } try { $hourTypesQuery = $db->prepare("SELECT ID,value,name,color FROM scheduleHourTypes WHERE area=:area AND `deleted` = 0"); $hourTypesQuery->execute(array(':area' => $area)); } catch (PDOException $e) { exit("error in query"); } $hourTypes = array(); $startTime = getStartTime(); $endTime = getEndTime(); if (!isSchedulePosted($date)) { echo "<h3 align='center' style='color:red'>Schedule For Week Not Yet Posted</h3>"; } echo "<table class='schedule' id='sched'><thead><tr><th class='schedule_time'><b>Hours</b></th>"; while ($row = $hourTypesQuery->fetch(PDO::FETCH_ASSOC)) { $hourTypes[] = $row['ID']; if (!in_array($row['ID'], $values)) { continue; } echo "<th class='schedule' style='background-color:" . $row['color'] . "'> <b> " . $row['name'] . "</b> </th>"; } echo "</tr></thead><tbody>"; for ($hour = $startTime * 1; $hour <= $endTime; $hour += $hourSize) { echo "<tr class='schedule'><td class='schedule_time'>" . hourToTime($hour) . "</td>";
function thisTimeslotIsAfterOther($other) { return dateAIsAfterDateB(getStartTime(), other . getEndTime()); }