public function check_request() { $entries = \Model\CdnRequest::find('all', array('where' => array(array('cdnType', $this->get_cdn()), array('accountName', $this->user), array('done', 0)), 'order_by' => array('created_at' => 'asc'))); $webapi = new Webapi(); $complete = array(); $incomplete = array(); foreach ($entries as $entry) { /* $result = $webapi->execute(self::PURGE_BASE . $entry->progressUri, $this->config, 'GET'); if ($result['http_code'] == 200) { $json = json_decode($result['contents'], true); if ($json['purgeStatus'] == 'Done') { $entry->done = 1; $entry->updated_at = date('Y-m-d H:i:s'); $entry->save(); $complete[] = $entry; } else { $incomplete[] = $entry; } } */ } $all = count($complete) + count($incomplete); return array('success' => true, 'message' => count($complete) . '/' . $all . ' is processed.', 'incomplete' => $incomplete, 'complete' => $complete); }
public function get_queue() { $service = $this->param('service'); $account = $this->param('account'); $queue = \Model\CdnRequest::find('all', array('where' => array(array('cdnType', $service), array('accountName', $account)), 'order_by' => array('created_at' => 'desc'), 'limit' => 5)); return $this->response($queue); }
public function view() { $this->service = $this->request()->param('service', false); $this->account = $this->request()->param('account', false); $account_config = Config::get('cdn.' . $this->service . '.' . $this->account, false); $this->defaults = $account_config['defaults']; switch ((string) $this->service) { case 'akamai': $this->service_label = 'Akamai'; $this->purge_label = 'CP Code'; $this->purge_url_label = 'ARL/URL(s)'; break; case 'keycdn': $this->service_label = 'KeyCDN'; $this->purge_label = 'Zone ID'; $this->purge_url_label = 'URL(s)'; break; case 'cloudfront': $this->service_label = 'CloudFront'; $this->purge_label = 'Distribution ID'; $this->purge_url_label = 'Pattern(s)'; break; } /* $account_config = Config::get('cdn.' . $this->service . '.' . $this->account, false); $cls_name = "\\cdn\\" . $this->service; $service = new $cls_name($this->account, $config); */ $this->history = \Model\CdnRequest::find('all', array('where' => array(array('cdnType', $this->service), array('accountName', $this->account)), 'order_by' => array('created_at' => 'desc'), 'limit' => 5)); }
public function check_request() { $entries = \Model\CdnRequest::find('all', array('where' => array(array('cdnType', $this->get_cdn()), array('accountName', $this->user), array('done', 0)), 'order_by' => array('created_at' => 'asc'))); $complete = array(); $incomplete = array(); foreach ($entries as $entry) { $entry->done = 1; $entry->updated_at = date('Y-m-d H:i:s'); $entry->save(); $entry->message = $entry->cdnType . '(' . $entry->accountName . '):: Purge done - [' . $entry->purgeId . ']'; $complete[] = $entry; } $all = count($complete) + count($incomplete); return array('success' => true, 'message' => count($complete) . '/' . $all . ' is processed.', 'incomplete' => $incomplete, 'complete' => $complete); }