Example #1
0
function generate_event_page()
{
    ob_start();
    $ical = new ICal(get_option('nev-file_path'));
    $events = $ical->events();
    $FORMAT = 'd-m-Y';
    $time = time();
    echo '<ul>';
    foreach ($events as $event) {
        $eventTime = strtotime($event['DTSTART']);
        //those in a past are not bolded
        if ($time - 60 * 60 * 24 > $eventTime) {
            echo '<li><p>';
            $date = substr($event['DTSTART'], 6, 2) . "/" . substr($event['DTSTART'], 4, 2) . "/" . substr($event['DTSTART'], 0, 4);
            echo $date . ': ' . $event['SUMMARY'] . ", " . @$event['DESCRIPTION'];
            echo '</p></li>';
        } else {
            echo '<li><p><strong>';
            $date = substr($event['DTSTART'], 6, 2) . "/" . substr($event['DTSTART'], 4, 2) . "/" . substr($event['DTSTART'], 0, 4);
            echo $date . ':</strong>  ' . $event['SUMMARY'] . ", " . @$event['DESCRIPTION'];
            echo '</p></li>';
        }
    }
    echo '</ul>';
    //Show link to download ical file
    $file_name = get_option('nev-file_path');
    $upload_path = wp_upload_dir()['url'] . substr($file_name, strripos($file_name, '/'));
    echo '<p>Download <a href="' . $upload_path . '" download>.ics file</a></p>';
    return ob_get_clean();
}
Example #2
0
 public function validate($value, Constraint $constraint)
 {
     if ($value !== null) {
         $ical = new \ICal($value->getPathName());
         $events = $ical->events();
         if ($events === null || count($events) === 0) {
             $this->context->addViolation($constraint->message);
         }
     }
 }
Example #3
0
function updateRessources($db, $ressources, $startdate = null, $enddate = null, $GMT = "+1 hour")
{
    if ($startdate == null) {
        $startdate = date("Y-m-d");
    }
    if ($enddate == null) {
        $enddate = date("Y-m-d", strtotime("+30 days"));
    }
    $nb = array();
    foreach ($ressources as $ressource) {
        $ical = new ICal('https://planning.univ-rennes1.fr/jsp/custom/modules/plannings/anonymous_cal.jsp?resources=' . $ressource . '&projectId=1&calType=ical&firstDate=' . $startdate . '&lastDate=' . $enddate);
        $events = $ical->events();
        $insertNb = 0;
        purge_events($db, $ressource);
        if ($events) {
            foreach ($events as $event) {
                $export_d = date("Y/m/d H:i:s", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTSTAMP'])));
                $start_d = date("Y-m-d", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTSTART'])));
                $start_t = date("H:i:s", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTSTART'])));
                $end_d = date("Y-m-d", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTEND'])));
                $end_t = date("H:i:s", strtotime($GMT, $ical->iCalDateToUnixTimestamp($event['DTEND'])));
                $description = desc2json($event['DESCRIPTION']);
                $req = $db->prepare('insert into events (UID,ressource, StartDate, StartTime, EndDate, EndTime, Title, Location, Description,Export) VALUES (?,?,?,?,?,?,?,?,?,?)');
                $res = $req->execute(array(issetor($event['UID']), $ressource, $start_d, $start_t, $end_d, $end_t, $event['SUMMARY'], issetor($event['LOCATION']), $description, $export_d));
                $insertNb += $res;
            }
        }
        $nb[$ressource] = $insertNb;
    }
    $req = $db->prepare("UPDATE ressources r inner join events e on r.number = e.ressource set r.last_sync = e.Export");
    $req->execute();
    return $nb;
}
 /**
  * Hierbei handelt es sich um eine Funktion, die über die URL nicht aufgerufen werden kann.
  * Stattdessen wird sie vom AutoController aufgerufen, wenn die Ferien automatisch importiert werden sollen
  * Dabei werden Daten, die bereits als Specialdate markiert sind, übersprungen.
  *
  * @author aloeser
  * @return void
  */
 public function importVacations()
 {
     try {
         $importyear = date('Y') + 1;
         $sourceURL = 'http://www.schulferien.org/iCal/Ferien/icals/Ferien_Berlin_' . $importyear . '.ics';
         $icalreader = new ICal($sourceURL);
         $events = $icalreader->events();
         if ($events == array()) {
             //Die angegebene Datei existiert nicht
             throw new Exception();
         }
         $tmpSpecialdates = $this->Specialdate->find('all', array('recursive' => -1, 'conditions' => array('Specialdate.date LIKE ' => $importyear . '-__-__')));
         $specialdates = array();
         foreach ($tmpSpecialdates as $tmpSpecialdate) {
             array_push($specialdates, $tmpSpecialdate['Specialdate']['date']);
         }
         foreach ($events as $event) {
             $timeBegin = $this->icalToUnixtime($event['DTSTART']);
             $timeEnd = $this->icalToUnixtime($event['DTEND']);
             $datetime = new Datetime(date('Y-m-d', $timeBegin));
             for ($i = $timeBegin; $i <= $timeEnd; $i += DAY) {
                 $dateString = $datetime->format('Y-m-d');
                 if (!in_array($dateString, $specialdates)) {
                     //Datum existiert noch nicht
                     if (!($datetime->format('N') >= 6)) {
                         //Kein Wochenende -> Specialdate eintragen, um das Datum zu deaktivieren
                         $this->Specialdate->create();
                         $this->Specialdate->save(array('Specialdate' => array('date' => $dateString)));
                     }
                 } else {
                     //Datum existiert bereits
                 }
                 $datetime->modify("+1 day");
             }
         }
         AutoController::saveLog('Ferienimport', 0, 'SpecialdatesController', 'importVacations');
     } catch (Exception $e) {
         AutoController::saveLog('Ferienimport', 3, 'SpecialdatesController', 'importVacations');
     }
 }
Example #5
0
/**
 * This example demonstrates how the Ics-Parser should be used.
 *
 * PHP Version 5
 *
 * @category Example
 * @package  Ics-parser
 * @author   Martin Thoma <*****@*****.**>
 * @license  http://www.opensource.org/licenses/mit-license.php  MIT License
 * @version  SVN: <svn_id>
 * @link     http://code.google.com/p/ics-parser/
 * @example  $ical = new ical('MyCal.ics');
 *           print_r( $ical->get_event_array() );
 */
require 'class.iCalReader.php';
$ical = new ICal('Calendar.ics');
$events = $ical->events();
$date = $events[0]['DTSTART'];
echo 'The ical date: ';
echo $date;
echo "<br />\n";
echo 'The Unix timestamp: ';
echo $ical->iCalDateToUnixTimestamp($date);
echo "<br />\n";
echo 'The number of events: ';
echo $ical->event_count;
echo "<br />\n";
echo 'The number of todos: ';
echo $ical->todo_count;
echo "<br />\n";
echo '<hr/><hr/>';
Example #6
0
/**
 * This example demonstrates how the Ics-Parser should be used.
 *
 * PHP Version 5
 *
 * @category Example
 * @package  Ics-parser
 * @author   Martin Thoma <*****@*****.**>
 * @license  http://www.opensource.org/licenses/mit-license.php  MIT License
 * @version  SVN: <svn_id>
 * @link     http://code.google.com/p/ics-parser/
 * @example  $ical = new ical('MyCal.ics');
 *           print_r( $ical->get_event_array() );
 */
require 'class.iCalReader.php';
$ical = new ICal('MyCal.ics');
$events = $ical->events();
$date = $events[0]['DTSTART'];
echo "The ical date: ";
echo $date;
echo "<br/>";
echo "The Unix timestamp: ";
echo $ical->iCalDateToUnixTimestamp($date);
echo "<br/>";
echo "The number of events: ";
echo $ical->event_count;
echo "<br/>";
echo "The number of todos: ";
echo $ical->todo_count;
echo "<br/>";
echo "<hr/><hr/>";
Example #7
0
 /**
  * Import ICal files
  *
  * @since 0.1
  *
  * @return json
  */
 function import_ical()
 {
     $this->verify_nonce('wp-erp-hr-nonce');
     if (empty($_FILES['ics']['tmp_name'])) {
         $this->send_error(__('File upload error!', 'wp-erp'));
     }
     /*
      * An iCal may contain events from previous and future years.
      * We'll import only events from current year
      */
     $first_day_of_year = strtotime(date('Y-01-01 00:00:00'));
     $last_day_of_year = strtotime(date('Y-12-31 23:59:59'));
     /*
      * We'll ignore duplicate entries with the same title and
      * start date in the foreach loop when inserting an entry
      */
     $holiday_model = new \WeDevs\ERP\HRM\Models\Leave_Holiday();
     // create the ical parser object
     $ical = new \ICal($_FILES['ics']['tmp_name']);
     $events = $ical->events();
     foreach ($events as $event) {
         $start = strtotime($event['DTSTART']);
         $end = strtotime($event['DTEND']);
         if ($start >= $first_day_of_year && $end <= $last_day_of_year) {
             $title = sanitize_text_field($event['SUMMARY']);
             $start = date('Y-m-d H:i:s', $start);
             $end = date('Y-m-d H:i:s', $end);
             $description = !empty($event['DESCRIPTION']) ? $event['DESCRIPTION'] : $event['SUMMARY'];
             // check for duplicate entries
             $holiday = $holiday_model->where('title', '=', $title)->where('start', '=', $start);
             // insert only unique one
             if (!$holiday->count()) {
                 erp_hr_leave_insert_holiday(array('id' => 0, 'title' => $title, 'start' => $start, 'end' => $end, 'description' => sanitize_text_field($description)));
             }
         }
     }
     $this->send_success();
 }
Example #8
0
<?php

require 'class.iCalReader.php';
$ical = new ICal('originals/' . $_GET['klas'] . '.ics');
$events = $ical->events();
$classes = array();
foreach ($events as $event) {
    if (!in_array($event['SUMMARY'], $classes, true)) {
        array_push($classes, $event['SUMMARY']);
    }
}
sort($classes);
$counter = 0;
foreach ($classes as $class) {
    echo '<label><input type="checkbox" name="vak" value="' . $class . '" />' . $class . '</label>';
    $counter++;
}
function wp_gc_my_calendar()
{
    ?>
    <div id="eventContent" title="Event Details" style="display:none;" class="contact-content">
        <div class="contact-loading" style="display:none"></div>
        <div class="success_msg"></div>
        <form class="cmxform" id="eventform" method="get" action="">
            <fieldset>
                <p class="txt-fld">
                    <label for="pName">Your Name</label>
                    <input id="pName" name="pName" minlength="2" type="text" required>
                </p>

                <p class="txt-fld">
                    <label for="pEmail">Your E-Mail</label>
                    <input id="pEmail" type="email" name="pEmail" required>
                </p>

                <p class="txt-fld">
                    <label for="pPhone">Your Phone</label>
                    <input id="pPhone" type="text" name="pPhone" required>
                </p>

                <p class="txt-fld">
                    <label for="pNotes">Your Message</label>
                    <textarea id="pNotes" name="pNotes" rows="10"></textarea>
                </p>

                <p class="btn-fld">
                    <input id="start_date" name="start_date" type="hidden">
                    <input id="end_date" name="end_date" type="hidden">
                    <input id="savebtn" class="btn-frm" type="submit" value="Book Appointment">
                </p>
            </fieldset>
        </form>
        <p id="eventInfo"></p>
    </div>
    <?php 
    include_once 'class.iCalReader.php';
    date_default_timezone_set('US/Eastern');
    // set default timezone
    $calendar_file = get_option('google_cal_file');
    if ($calendar_file == '') {
        ?>
        <h2>Settings required ! </h2>
        <p><a href="<?php 
        echo admin_url('admin.php?page=wp-google-calendar-settings');
        ?>
">Go to settings</a></p>
        <?php 
        exit;
    }
    $ical = new ICal($calendar_file);
    $events = $ical->eventsFromRange(true, true);
    foreach ($events as $event) {
        if (isset($event['TRANSP'])) {
            $key = "url";
            $value = "javascript: showForm()";
        } else {
            $key = "busy";
            $value = "1";
        }
        $ev[] = array('title' => addslashes($event['SUMMARY']), 'start' => date('Y-m-d\\TH:i:s', strtotime($event['DTSTART'])), 'end' => date('Y-m-d\\TH:i:s', strtotime($event['DTEND'])), 'allDay' => strlen($event['DTSTART']) == 8 ? true : false, $key => $value);
    }
    $e = json_encode($ev);
    ?>
    <div style="display:none" class="eventJson" defaultDate="<?php 
    echo date('Y-m-d');
    ?>
"
         data='<?php 
    echo $e;
    ?>
'></div>
    <?php 
    return "<div id='calendar'></div>";
}
			.grey_row2 {background-color: #d3d3d3; padding:8px 0 8px 5px; text-align: left;width: 300px;}
			.white_row {padding:5px 0 5px 5px; text-align: left;width: 200px;}
			.white_row2 {padding:5px 0 5px 5px; text-align: left;width: 495px;}
			.room {padding:5px 0 0 0; font-size: 14px;font-weight: bolder;}
		</style>
	</head>
	<body>
	<div class="container">
		<table cellspacing="0" cellpadding="1" border="0" align="center" class="table_grid row">
			<thead>
				<th class="grey_row">TIME</th>
				<th class="grey_row2">EVENT</th>
			</thead>
<?php 
require 'IcalReader.php';
$ical = new ICal();
$files = $ical->findAllFiles('ics-files');
$i = 0;
date_default_timezone_set('Australia/ACT');
foreach ($files as $key => $file) {
    $caldata = array();
    $ical->cal = '';
    $caldata = $ical->getEventsByFileName($file);
    foreach ($caldata['VEVENT'] as $data) {
        $e[$i]['UID'] = $data['UID'];
        $e[$i]['SUMMARY'] = $data['SUMMARY'];
        $e[$i]['LOCATION'] = isset($data['LOCATION']) ? $data['LOCATION'] : '';
        //
        $ts = strtotime($data['DTSTART']);
        $changedDate = date('YmdHis', $ts);
        $e[$i]['DTSTART'] = $changedDate;
Example #11
0
    $activiteit->organisatievorm = \Request::get('organisatievorm');
    $activiteit->tijd = \Request::get('tijd');
    $activiteit->werkvormsoort = \Request::get('werkvormsoort');
    $activiteit->intelligenties = \Request::get('intelligenties', []);
    $activiteit->inhoud = \Request::get('inhoud');
    $activiteit->save();
    return redirect()->back()->withInput(['activiteit.updated', []]);
});
Route::get('/contactmoment/import', function () {
    return makeBlade()->render('contactmoment.import', []);
});
Route::post('/contactmoment/import', function () {
    switch (\Request::get("type")) {
        case "ics":
            $url = \Request::get("url");
            $icalReader = new \ICal($url);
            foreach ($icalReader->events() as $event) {
                if (array_key_exists('SUMMARY', $event) === false) {
                    continue;
                }
                $module = extractModule($event['SUMMARY']);
                if ($module === null) {
                    continue;
                }
                if (preg_match('/Groepen:\\s+(?<groepen>[^\\n]+)\\\\n\\\\n/', $event['DESCRIPTION'], $groepMatches) === 1) {
                    $groepen = explode('\\, ', $groepMatches['groepen']);
                }
                importEvent($module, new \DateTime($event['DTSTART']), new \DateTime($event['DTEND']), $event['UID'], $event['LOCATION'], $groepen);
            }
            // remove future, imported contactmomenten which where not touched in this batch (today)
            \App\Contactmoment::where(function ($query) {
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<meta http-equiv="Content-Language" content="en">
		<!-- refresh page in every 60 seconds 
		<meta http-equiv="refresh" content="60" /> -->
		<title>Upcoming Event</title>
	</head>
	<body>

		<table cellspacing="1" cellpadding="1" border="0" style="width:720px;height:1280" align="center">
			<thead>
				<th colspan="3" colspan="center" height="80" style="font-size:22px">Next Event</th>
			</thead>
	
	<?php 
require 'IcalReader.php';
$ical = new ICal();
$i = 0;
date_default_timezone_set('Australia/ACT');
//Either pass filename from url eg [...... screen-two.php?file=xyz.ics] or directly put here
$filename = isset($_GET['file']) ? trim($_GET['file']) : 'Auditorium.ics';
$events = $ical->getEventsByFileName('ics-files/' . $filename);
foreach ($events['VEVENT'] as $data) {
    $e[$i]['UID'] = $data['UID'];
    $e[$i]['SUMMARY'] = $data['SUMMARY'];
    $e[$i]['LOCATION'] = isset($data['LOCATION']) ? $data['LOCATION'] : '';
    //
    $ts = strtotime($data['DTSTART']);
    $changedDate = date('YmdHis', $ts);
    $e[$i]['DTSTART'] = $changedDate;
    $e[$i]['DTEND'] = $data['DTEND'];
    $i++;
Example #13
0
 		    echo "Sorry, your file is too large.";
 		    $uploadOk = 0;
 		}*/
 // Allow certain file formats
 if ($FileType != 'ics') {
     echo "Sorry, only ics files are allowed.";
     $uploadOk = 0;
 }
 // Check if $uploadOk is set to 0 by an error
 if ($uploadOk == 0) {
     echo "Sorry, your file was not uploaded.";
     // if everything is ok, try to upload file
 } else {
     if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
         $success_message = "The file " . basename($_FILES["fileToUpload"]["name"]) . " has been uploaded successfully.";
         $ical = new ICal($target_file);
         $time = time();
         $date = new DateTime(null);
         $todaystart = strtotime('today midnight');
         $todayend = strtotime('tomorrow midnight');
         $events = $ical->eventsFromRange($todaystart, $todayend);
         $counter = 0;
         foreach ($events as $event) {
             $ics_events[$counter] = [];
             array_push($ics_events[$counter], $counter + 1);
             array_push($ics_events[$counter], $event['SUMMARY']);
             array_push($ics_events[$counter], $event['LOCATION']);
             $startTime = $ical->iCalDateToUnixTimestamp($event['DTSTART']);
             $startTimeString = date('H:i', $startTime);
             array_push($ics_events[$counter], $startTimeString);
             $endTime = $ical->iCalDateToUnixTimestamp($event['DTEND']);
Example #14
0
 		echo "<p style='color:red'>Échec de l'accès au dossier temporaire.</p>";
 		require("../lib/footer.inc.php");
 		die();
 	}
 */
 $content = file_get_contents("http://cache.media.education.gouv.fr/ics/Calendrier_Scolaire_Zone_" . mb_strtoupper($zone) . ".ics");
 $temp_perso = "../temp/" . get_user_temp_directory();
 if (!file_put_contents($temp_perso . "/fichier_vacances_scolaires.ics", $content)) {
     echo "<p style='color:red'>Échec de l'écriture du fichier temporaire.</p>";
     require "../lib/footer.inc.php";
     die;
 }
 echo "<form action='" . $_SERVER['PHP_SELF'] . "' method='post'>\n\t<fieldset class='fieldset_opacite50'>\n\t\t" . add_token_field() . "\n\t\t<p style='margin-bottom:1em;'>L'année scolaire telle que saisie dans <a href='../gestion/param_gen.php'>Gestion générale/Configuration générale</a> court du " . strftime("%d/%m/%Y", $begin_bookings) . " au " . strftime("%d/%m/%Y", $end_bookings) . "</p>\n\t\t<p>Choisissez les dates à importer&nbsp;</p>";
 require "./edt_ics_lib.php";
 require "../lib/class.iCalReader.php";
 $ical2 = new ICal($temp_perso . "/fichier_vacances_scolaires.ics");
 // Mode debug:
 $debug_edt = "n";
 echo "<p style='margin-bottom:1em; font-size:x-small;'>" . $ical2->event_count . " enregistrements dans ce fichier (<em>une partie seulement sera affichée (celle correspondant à l'année scolaire en cours)</em>).</p>";
 if ($debug_edt == "y") {
     echo '<pre>';
 }
 $cpt = 0;
 foreach ($ical2->events() as $event) {
     $tmp_ts_debut = $ical2->iCalDateToUnixTimestamp($event['DTSTART']);
     if ($tmp_ts_debut > $begin_bookings && $tmp_ts_debut < $end_bookings) {
         if ($debug_edt == "y") {
             echo "<hr />";
             print_r($event);
         }
         $annee_courante = strftime("%Y", $tmp_ts_debut);
Example #15
0
  <!-- Main Footer -->
	<?php 
include '../plugins/ics-parser/class.iCalReader.php';
$ical = new ICal('../plugins/ics-parser/MyCal.ics');
$eventsCal = $ical->events();
?>

</div>
<!-- ./wrapper -->

    <!-- jQuery UI 1.11.4 -->
    <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
    <!-- Slimscroll -->
    <script src="../plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="../plugins/fastclick/fastclick.min.js"></script>
    <!-- fullCalendar 2.2.5 -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
    <script src="../plugins/fullcalendar/fullcalendar.min.js"></script>
    <script src="../plugins/fullcalendar/fr.js"></script>
    <!-- Page specific script -->
    <script>
      $(function () {

        /* initialize the calendar
         -----------------------------------------------------------------*/
        //Date for the calendar events (dummy data)
        var date = new Date();
        var d = date.getDate(),
                m = date.getMonth(),
    /**
     * Insert a rendered h-Event list from a VCal feed
     * @param array $atts 
     * @param string $content
     * @return string
     */
    public static function shortcode($atts, $content = "")
    {
        $atts = shortcode_atts(array('url' => '', 'paginated' => '10'), $atts);
        $body = $content;
        $vcal = new ICal();
        // Request VCalendar and cache the response for 7 days
        $vcal->setCache(dirname(__FILE__) . '/cache', 7 * 24 * 3600)->initURL($atts['url']);
        if ($vcal->hasEvents()) {
            ob_start();
            ?>
<div class="icalfeed">
<ul>
<?php 
            foreach ($vcal->events() as $event) {
                $event['DTSTART'] = new \DateTime($event['DTSTART']);
                $event['DTEND'] = new \DateTime($event['DTEND']);
                // Render an event
                ?>
  
        <li class="hevent">
          <p><strong class="p-name"><?php 
                echo $event['SUMMARY'];
                ?>
</strong><br/>
            Du <time class="dt-start" datetime="<?php 
                echo $event['DTSTART']->format(\DateTime::ISO8601);
                ?>
"><?php 
                echo $event['DTSTART']->format('d/m');
                ?>
</time>
            au <time class="dt-end" datetime="<?php 
                echo $event['DTEND']->format(\DateTime::ISO8601);
                ?>
"><?php 
                echo $event['DTEND']->format('d/m');
                ?>
</time><br/>
            <!--span class="p-location">Some bar in SF</span-->
            <?php 
                if (strpos('://', $event['DESCRIPTION'])) {
                    ?>
            <span class="p-summary"><?php 
                    echo preg_replace('#.*(https?://.+)$#is', '<a href="$1" target="icalfeedNewWindow">Voir le site</a>', $event['DESCRIPTION']);
                    ?>
</span>
            <?php 
                }
                ?>
</p>
        </li>
<?php 
            }
            ?>
</ul>
</div>
<?php 
            $body = ob_get_contents();
            ob_clean();
        } else {
            $body = '<p>Aucun événement...</p>';
        }
        return $body;
    }
Example #17
0
    } else {
        dol_print_error($db);
    }
}
// Complete $eventarray with external import Ical
if (count($listofextcals)) {
    require_once DOL_DOCUMENT_ROOT . '/comm/action/class/ical.class.php';
    foreach ($listofextcals as $extcal) {
        $url = $extcal['src'];
        // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics
        $namecal = $extcal['name'];
        $offsettz = $extcal['offsettz'];
        $colorcal = $extcal['color'];
        $buggedfile = $extcal['buggedfile'];
        //print "url=".$url." namecal=".$namecal." colorcal=".$colorcal." buggedfile=".$buggedfile;
        $ical = new ICal();
        $ical->parse($url);
        // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ...
        //var_dump($ical->cal); exit;
        $icalevents = array();
        if (is_array($ical->get_event_list())) {
            $icalevents = array_merge($icalevents, $ical->get_event_list());
        }
        // Add $ical->cal['VEVENT']
        if (is_array($ical->get_freebusy_list())) {
            $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
        }
        // Add $ical->cal['VFREEBUSY']
        if (count($icalevents) > 0) {
            // Duplicate all repeatable events into new entries
            $moreicalevents = array();
Example #18
0
<?php

// Set the url of the calendar feed.
//$url = 'https://p01-calendarws.icloud.com/ca/subscribe/1/n6x7Farxpt7m9S8bHg1TGArSj7J6kanm_2KEoJPL5YIAk3y70FpRo4GyWwO-6QfHSY5mXtHcRGVxYZUf7U3HPDOTG5x0qYnno1Zr_VuKH2M';
$url = isset($_REQUEST['url']) ? $_REQUEST['url'] : '';
/*****************************************/
// Run the helper function with the desired URL and save the contents.
$data = get_url($url);
include 'class.iCalReader.php';
$cal = new ICal(preg_split('/$\\R?^/m', $data));
$events = $cal->eventsFromRange('now', '2 weeks');
echo ical2json($events);
// Define the helper function that retrieved the data and decodes the content.
function get_url($url)
{
    //user agent is very necessary, otherwise some websites like google.com wont give zipped content
    $opts = array('http' => array('method' => "GET", 'header' => "Accept-Language: en-US,en;q=0.8rn" . "Accept-Encoding: gzip,deflate,sdchrn" . "Accept-Charset:UTF-8,*;q=0.5rn" . "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0 FirePHP/0.4rn", "ignore_errors" => true), "ssl" => array("verify_peer" => false, "verify_peer_name" => false));
    $context = stream_context_create($opts);
    $content = file_get_contents($url, false, $context);
    //If http response header mentions that content is gzipped, then uncompress it
    foreach ($http_response_header as $c => $h) {
        if (stristr($h, 'content-encoding') and stristr($h, 'gzip')) {
            //Now lets uncompress the compressed data
            $content = gzinflate(substr($content, 10, -8));
        }
    }
    return $content;
}
function ical2json($cal)
{
    $json = array();
Example #19
0
 public function put()
 {
     $this->requiresLogin();
     $this->check_input(['tags' => ['*' => 1]]);
     if (isset($this->data['id'])) {
         unset($this->data['id']);
     }
     if (isset($this->data['email'])) {
         unset($this->data['email']);
     }
     if (isset($this->data['country'])) {
         $this->data['country'] = substr(preg_replace('/[^a-z]/i', '', $this->data['country']), 0, 3);
     }
     if (isset($this->data['lang'])) {
         $this->data['lang'] = substr(preg_replace('/[^a-z]/', '', $this->data['lang']), 0, 2);
     }
     if (isset($this->data['city']) && isset($this->data['country']) && isset($this->data['address']) && isset($this->data['postal']) && (isset($this->data['lat']) && !$this->data['lat'] || isset($this->data['lng']) && !$this->data['lng'] || $this->data['city'] != Bootstrap::$main->user['city'] || $this->data['country'] != Bootstrap::$main->user['country'] || $this->data['address'] != Bootstrap::$main->user['address'] || $this->data['postal'] != Bootstrap::$main->user['postal'])) {
         $url = 'https://maps.google.com/maps/api/geocode/json?address=' . urlencode($this->data['address'] . ', ' . $this->data['postal'] . ' ' . $this->data['city']) . '&sensor=false&region=' . $this->data['country'] . '&key=' . Bootstrap::$main->getConfig('maps.api_key');
         $place = json_decode($this->req($url), true);
         if (isset($place['results'][0]['geometry']['location'])) {
             $this->data['lat'] = $place['results'][0]['geometry']['location']['lat'];
             $this->data['lng'] = $place['results'][0]['geometry']['location']['lng'];
         }
     }
     if (isset($this->data['lat'])) {
         $this->data['lat'] += 0;
     }
     if (isset($this->data['lng'])) {
         $this->data['lng'] += 0;
     }
     if (Bootstrap::$main->isAdmin() && $this->id) {
         $user = $this->user()->get($this->id);
     } else {
         $user = Bootstrap::$main->user;
     }
     if (isset($this->data['url'])) {
         $this->data['url'] = trim(Tools::str_to_url($this->data['url']));
         if ($this->data['url'] != $user['url']) {
             if ($this->user()->find_one_by_url($this->data['url']) || in_array($this->data['url'], Bootstrap::$main->getConfig('forbidden_url'))) {
                 return $this->error(17);
             }
         }
     }
     if (isset($this->data['password']) && strlen($this->data['password']) != 32) {
         Tools::log('password-change', $this->data);
         $this->data['password'] = $this->hashPass($this->data['password']);
     }
     if (isset($this->data['ical']) && $this->data['ical']) {
         require_once __DIR__ . '/../class/iCalReader/class.iCalReader.php';
         $ical = new ICal($this->data['ical']);
         $events = $ical->events();
         if (!is_array($events)) {
             return $this->error(50);
         }
     }
     $model = new userModel($user['id']);
     foreach ($this->data as $k => $v) {
         if (!is_array($v)) {
             $model->{$k} = $v;
         }
     }
     if ($this->data('payment')) {
         $this->check_payment($model->country, $this->data('payment'));
     }
     if ($model->save()) {
         $data = $user = $model->data();
         if (isset($this->data['tags'])) {
             $user['tags'] = Tools::tags(Bootstrap::$main->getConfig('profile.tags'), $this->add_tags($user['id'], $this->data['tags']));
         }
         if (Bootstrap::$main->user['id'] == $model->id) {
             Bootstrap::$main->session('user', $data);
         }
         $this->getPublicUser($user, true);
         return array('status' => true, 'id' => $user['id'], 'user' => $user);
     }
     error(9);
 }
Example #20
0
function churchcal_updateICalSource($id)
{
    // Set modified date to not load this calendar each cron job
    //db_query("UPDATE {cc_calcategory} SET modified_date = now() WHERE id = :id", (array(":id"=>$id)));
    $cat = db_query("SELECT * FROM {cc_calcategory}\n                    WHERE id = :id", array(":id" => $id))->fetch();
    if (!$cat) {
        throw new CTException("No calcategory found");
    }
    include_once ASSETS . '/ics-parser/class.iCalReader.php';
    $ical = new ICal($cat->ical_source_url);
    $events = $ical->events();
    if (!$events) {
        ct_log("iCal Source from {$cat->bezeichnung} could not readed and processed!", 2, "calcategory", $id);
    } else {
        db_query("DELETE FROM {cc_cal} WHERE category_id = :id", array(":id" => $id));
        include_once CHURCHCAL . '/churchcal_db.php';
        foreach ($events as $event) {
            $data = array();
            $data["startdate"] = churchcore_icalToDate($event["DTSTART"]);
            if (isset($event["DTEND"])) {
                $data["enddate"] = churchcore_icalToDate($event["DTEND"]);
            }
            $data["bezeichnung"] = utf8_encode(getVar("SUMMARY", "", $event));
            $data["category_id"] = $id;
            $data["repeat_id"] = 0;
            $data["intern_yn"] = 0;
            $data["modified_pid"] = -1;
            $data["notizen"] = getVar("SUMMARY", "", $event) . " " . getVar("DESCRIPTION", "", $event);
            $data["link"] = getVar("URL", "", $event);
            $data["ort"] = "";
            if ($data["startdate"] != "") {
                // Substract one day if it is a whole day date
                $sd = new Datetime($data["startdate"]);
                if (!isset($data["enddate"])) {
                    $ed = new Datetime($data["startdate"]);
                } else {
                    $ed = new Datetime($data["enddate"]);
                    if (isFullDay($sd, $ed)) {
                        $ed->modify("-1 DAY");
                    }
                }
                $data["startdate"] = $sd->format("Y-m-d H:i");
                $data["enddate"] = $ed->format("Y-m-d H:i");
                churchcal_createEvent($data, null, true);
            }
        }
        ct_log("iCal Source from {$cat->bezeichnung} readed and processed!", 2, $id, "category");
    }
}