%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /data/www_bck/varak.net_bck/suiteshooters.varak.net/www/
Upload File :
Create Path :
Current File : //data/www_bck/varak.net_bck/suiteshooters.varak.net/www/calendar.php

<?php
/**
 * Created by IntelliJ IDEA.
 * User: mvarak
 * Date: 4/25/2017
 * Time: 9:50 AM
 */
ob_start();

require_once "../lib/dibi.min.php";
require_once "../lib/smarty/Smarty.class.php";
dibi::connect(array(
    'driver'   => 'mysql',
    'host'     => 'localhost',
    'username' => 'suiteshooters',
    'password' => '6dMEYDjnNR5rjBEp',
    'database' => 'suiteshooters',
    'charset'  => 'utf8',
    'profiler' => [
        'run' => TRUE,
        'file' => __DIR__ . '/../log/log-' . date('Y-m-d') . '.txt',
    ],
));
$smarty = new Smarty();
$smarty->setTemplateDir( __DIR__ . '/../templates/');
$smarty->setCompileDir( __DIR__ . '/../templates_c/');
$smarty->setConfigDir( __DIR__ . '/../configs/');
$smarty->setCacheDir( __DIR__ . '/../cache/');
$smarty->assign('baseUrl', 'https://' . $_SERVER['SERVER_NAME']);

$smarty->debugging = false;
$smarty->setCaching(Smarty::CACHING_LIFETIME_CURRENT);
header("Content-Type: text/calendar");

if(isset($_GET['token']))
{
    $token = $_GET['token'];
    header("Cache-Control: private, max-age=3600");
    header("Content-Disposition: inline; filename=\"suiteshooters-$token.ics\"");
    $eventData = dibi::query("SELECT [events].[id], [startDate], [endDate], [events].[name] FROM [events] JOIN [attendees] ON [attendees].[event] = [events].[id] JOIN [users] ON [users].[id] = [attendees].[user] WHERE [users].[calendarToken]=%s AND [startDate] > %t AND [events].[active]=1 ORDER BY [startDate]", $token, time() - 7200);
}
else
{
    header("Cache-Control: public, max-age=3600");
    header("Content-Disposition: inline; filename=\"suiteshooters.ics\"");
    $eventData = dibi::query("SELECT [id], [startDate], [endDate], [name] FROM [events] WHERE [startDate] > %t AND [events].[active]=1 ORDER BY [startDate]", time() - 7200);
    $token = "all";
}

$smarty->assign('eventData', $eventData);
$smarty->assign('tz', new DateTimeZone("UTC"));

$smarty->display("ical.tpl", $token);

$ret = ob_get_clean();
header("X-Original-Content-Lenght: " . strlen($ret));
// Gzip/Deflate/Bzip2 compression
if(stristr($_SERVER["HTTP_ACCEPT_ENCODING"], "bzip2"))
{
    $ret = bzcompress($ret, 9);
    header("Content-Encoding: bzip2");
}
elseif(stristr($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip"))
{
    $ret = gzencode($ret, 9);
    header("Content-Encoding: gzip");
}
elseif (stristr($_SERVER["HTTP_ACCEPT_ENCODING"], "deflate"))
{
    $ret = gzdeflate($ret, 9);
    header("Content-Encoding: deflate");
}

header("Content-length: " . strlen($ret));
echo $ret;

Zerion Mini Shell 1.0