예제 #1
0
 * This is just a demo application with only one controller.
 * Controller logic runs from here as well as some template
 * handling in lack of a template engine. We assume that
 * every template file exists and is accessible.
 * Error handling (e.g. invalid $_REQUEST value handling) is
 * not part of this demonstration.
 *
 */
require_once './app/config/config.php';
require_once APP_PATH . 'models/CalendarModel.php';
$authCode = isset($_POST['authCode']) ? $_POST['authCode'] : '';
$calendar = new CalendarModel();
if (isset($_GET['logout'])) {
    $calendar->logout();
}
$client = $calendar->getClient($authCode);
$site_title = APPLICATION_NAME;
if ($client[0] == CalendarModel::CLIENT_ERROR_AUTH_NEEDED) {
    // "login" page
    $site_title .= ' | Login';
    $session_lifetime = ini_get("session.gc_maxlifetime");
    if ($session_lifetime === false) {
        $session_lifetime = 86400;
    }
    $session_lifetime_hours = floor($session_lifetime / 3600);
    $template = str_replace(array('[AUTH_URL]', '[SESSION_HOURS]'), array($client[1], $session_lifetime_hours), file_get_contents(VIEW_PATH . 'login.html'));
} elseif ($client[0] == CalendarModel::NO_ERRORS) {
    if (isset($_POST['addEvent']) && isset($_POST['calendarId']) && strlen($_POST['calendarId'])) {
        // event creator
        $site_title .= ' | Esemény';
        $event_date_ts = strtotime('tomorrow 12:00:00');