Advertisement
kolyaventuri

Cal - index.php

Jan 12th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2.     include 'clean.php';
  3.     include 'sp.php';
  4.  
  5.     $cal_feed = "//CALENDAR.URL";
  6.    
  7.     $cal_data = json_decode(json_encode((array)simplexml_load_file($cal_feed)),1);
  8.    
  9.     $cal = array();
  10.     $dates = array();
  11.     $datec = array();
  12.    
  13.     $spanish = getSpanish();
  14.     $next_sun = strtotime("next Monday");
  15.    
  16.     foreach($cal_data['Events']['Event'] as $event) {
  17.         $e = array();
  18.         $date = $event['Date'];
  19.         $desc = $event['ShortDesc'];
  20.         $status = $event['StatusDesc'];
  21.         if($status != "Cancelled") {
  22.             if(!cleanCheck($desc)) {
  23.                 $dates[$date]['en'][] = $desc;
  24.                 $event_name = str_replace(' ', '_', $desc);
  25.                 $event_name = str_replace('.', '_', $event_name);
  26.                 if($spanish[$event_name] != null) {
  27.                     $event_data = htmlentities($spanish[$event_name]);
  28.                     $dates[$date]['sp'][] = $event_data;
  29.                 }
  30.             }
  31.         }
  32.        
  33.     }
  34.    
  35.     array_push($cal, $dates);
  36.    
  37.     if($_GET['type'] == "json") {
  38.         echo pretty_json(json_encode($cal));
  39.     } elseif($_GET['type'] == "jsonp") {
  40.         echo "<pre>".pretty_json(json_encode($cal))."</pre>";
  41.     }
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement