/** * action to download a zip file directly form the API * @return [type] [description] */ public function action_download() { $this->auto_render = FALSE; $license = $this->request->param('id'); $domain = Core::request('domain'); if ($license != NULL and $domain != NULL) { //ok, let's download the zip file if validated license if (Model_License::verify($license, $domain) === TRUE) { $license = Model_License::get_license($license); if ($license->loaded()) { $license->order->download(); } } } //by default return false since downlaod could not be done $this->response->headers('Content-type', 'application/javascript'); $this->response->body(json_encode(FALSE)); }
/** * Handle GET requests. */ public function action_domain() { try { $result = FALSE; if (($license = $this->request->param('id')) != NULL) { //getting domain from referrer if (($domain = $this->request->referrer()) !== NULL) { $domain = parse_url($domain, PHP_URL_HOST); } else { //TODO remove in few versions, we should use only referrer $domain = Core::request('domain'); } if ($license != NULL and $domain != NULL) { $result = Model_License::verify($license, $domain); } } $this->rest_output(array('valid' => $result)); } catch (Kohana_HTTP_Exception $khe) { $this->_error($khe); } }
public function action_create() { try { if (!Valid::email(core::request('email'))) { $this->_error(__('Invalid email'), 501); } elseif (!is_numeric(core::request('id_product'))) { $this->_error(__('Invalid product'), 501); } else { $product = new Model_Product(core::request('id_product')); if ($product->loaded()) { $user = Model_User::create_email(core::request('email'), core::request('name')); $order = Model_Order::new_order($user, $product); $order->confirm_payment(core::request('paymethod', 'API'), core::request('txn_id'), core::request('pay_date'), core::request('amount'), core::request('currency'), core::request('fee')); //adding the notes $order->notes = core::request('notes'); $order->save(); //in case the device id or domain is provided if (core::request('device_id') !== NULL or core::request('domain') !== NULL) { $license = $order->licenses->find(1); if ($license->loaded()) { if (core::request('device_id') !== NULL) { Model_License::verify_device($license->license, core::request('device_id')); } if (core::request('domain') !== NULL) { Model_License::verify($license->license, core::request('domain')); } } } $this->rest_output(array('order' => self::get_order_array($order))); } else { $this->_error(__('Something went wrong'), 501); } } } catch (Kohana_HTTP_Exception $khe) { $this->_error($khe); } }