public function downloadappAction() { if ($app_id = $this->getRequest()->getParam('app_id')) { $mobile = new Mobile_Detect(); $application = new Application_Model_Application(); $application->find($app_id); $redirect_to = $application->getUrl(); if ($mobile->isAndroiddevice()) { $store_url = $application->getDevice(2)->getStoreUrl(); if ($store_url) { $redirect_to = preg_match('/details/', $store_url) ? preg_replace('/(.*\\/)((details).*)/', 'market://$2', $store_url) : $store_url; } } else { if ($mobile->isIosdevice()) { $store_url = $application->getDevice(1)->getStoreUrl(); if ($store_url) { $redirect_to = str_replace(array('http:', 'https:'), 'itms-apps:', $store_url); } } } $this->getResponse()->setRedirect($redirect_to)->sendResponse(); die; } }
public function downloadsourceAction() { if ($data = $this->getRequest()->getParams()) { try { $application = new Application_Model_Application(); if (empty($data['app_id']) or empty($data['device_id'])) { throw new Exception($this->_('This application does not exist')); } $application->find($data['app_id']); if (!$application->getId()) { throw new Exception($this->_('This application does not exist')); } $device = $application->getDevice($data["device_id"]); $device->setApplication($application); $device->setDownloadType($this->getRequest()->getParam("type"))->setExcludeAds($this->getRequest()->getParam("no_ads")); $zip = $device->getResources(); if ($this->getRequest()->getParam("type") != "apk") { $path = explode('/', $zip); end($path); $this->_download($zip, current($path), 'application/octet-stream'); } else { die; } } catch (Exception $e) { Zend_Registry::get("logger")->sendException("Error When Generating Android: \n" . print_r($e, true), "source_generator_", false); if ($application->getId()) { $this->_redirect('application/backoffice_view', array("app_id" => $application->getId())); } else { $this->_redirect('application/backoffice_list'); } } } }