Exemplo n.º 1
0
function load_events($from, $whole_month = FALSE)
{
    // Take advantage of the equality behavior of this date format
    $from_date = date("Y-m-d", $from);
    $bom = mktime(0, 0, 1, date("m", $from), 1, date("Y", $from));
    $eom = mktime(0, 0, 1, date("m", $from) + 1, 0, date("Y", $from));
    $to_date = date("Y-m-d", $whole_month ? $eom : $from);
    // Set arrays to their default
    $events = $seen = array();
    // Try to open the events file for reading, return if unable to
    $fp = @fopen("backend/events.csv", 'r');
    if (!$fp) {
        return FALSE;
    }
    // For all events, read in the event and check it if fits our scope
    while (!feof($fp)) {
        // Read the event data into $event, or continue with next
        // line, if there was an error with this line
        if (($event = read_event($fp)) === FALSE) {
            continue;
        }
        // Keep event's seen list up to date
        // (for repeating events with the same ID)
        if (!isset($seen[$event['id']])) {
            $seen[$event['id']] = 1;
        } else {
            continue;
        }
        // Check if event is in our scope, depending on type
        switch ($event['type']) {
            // Recurring event
            case 3:
                $date = date_for_recur($event['recur'], $event['recur_day'], $bom, $eom);
                $event['start'] = date("Y-m-d", $date);
                // Fall through. Now it is just like a single-day event
                // Single-day event
            // Fall through. Now it is just like a single-day event
            // Single-day event
            case 1:
                if ($event['start'] >= $from_date && $event['start'] <= $to_date) {
                    $events[] = $event;
                }
                break;
                // Multi-day event
            // Multi-day event
            case 2:
                if ($event['start'] >= $from_date && $event['start'] <= $to_date || $event['end'] >= $from_date && $event['end'] <= $to_date || $event['start'] <= $from_date && $event['end'] >= $to_date) {
                    $events[] = $event;
                }
                break;
        }
    }
    // Close file and return with results
    fclose($fp);
    return $events;
}
Exemplo n.º 2
0
<?php

include 'function.php';
if (!isset($_SESSION['client'])) {
    header('Location: callback.php');
}
$client = $_SESSION['client'];
if (isset($_GET['id'])) {
    $ev = read_event($_GET['id']);
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Event Form | Hoop</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>