This blob has been accessed 553 times via Git panel.
- <?php
- if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
- exit;
- }
- /* Andy Bailey - http://fiddyp.co.uk/text-between-strings-php/ */
- function get_between($text, $s1, $s2, $sn = 0) {
- $mid = "";
- $pos_s = mb_strpos($text, $s1);
- $pos_e = mb_strpos($text, $s2);
- for ($i = $pos_s + mb_strlen($s1); (($i < ($pos_e)) && $i < mb_strlen($text)); $i++) {
- $mid.= $text[$i];
- }
- if ($sn > 0) {
- return $s1 . $mid . "\n$s2";
- }
- else {
- return $mid;
- }
- }
- $raw_fetch = imap_utf8(imap_fetchheader($mbox, $msgno, FT_UID | FT_PREFETCHTEXT)) . mb_convert_encoding(mb_convert_encoding(imap_body($mbox, $msgno, FT_UID) , "UTF-8", "auto") , "UTF-8", "UTF-8");
- if (mb_strpos($raw_fetch, "BEGIN:VCALENDAR") and mb_strpos($raw_fetch, "END:VCALENDAR")) {
- if (!file_exists($filePath)) {
- mkdir($filePath, 0700, 1);
- }
- file_put_contents("$filePath/meeting.ics",get_between($raw_fetch,"BEGIN:VCALENDAR","END:VCALENDAR",1));
- }
- ?>