public function apkisgeneratedAction() { $appName = $this->getRequest()->getParam('app_name'); $apk_base_path = Core_Model_Directory::getBasePathTo("var/tmp/applications/android/{$appName}/Siberian/app/build/outputs/apk/app-release.apk"); $apk_path = Core_Model_Directory::getPathTo("var/tmp/applications/android/{$appName}/Siberian/app/build/outputs/apk/app-release.apk"); $apk_is_generated = false; $link = $this->getUrl() . $apk_path; $link = str_replace("//", "/", $link); if (file_exists($apk_base_path)) { if (time() - filemtime($apk_base_path) <= 600) { $apk_is_generated = true; } } $user = new Backoffice_Model_User(); try { $user = $user->findAll(null, "user_id ASC", array("limit" => "1"))->current(); $sender = System_Model_Config::getValueFor("support_email"); $support_name = System_Model_Config::getValueFor("support_name"); $layout = $this->getLayout()->loadEmail('application', 'download_source'); $subject = $this->_('Android APK Generation'); $layout->getPartial('content_email')->setLink($link); $layout->getPartial('content_email')->setApkStatus($apk_is_generated); $content = $layout->render(); $mail = new Zend_Mail('UTF-8'); $mail->setBodyHtml($content); $mail->setFrom($sender, $support_name); $mail->addTo($user->getEmail()); $mail->setSubject($subject); $mail->send(); } catch (Exception $e) { $logger = Zend_Registry::get("logger"); $logger->sendException("Fatal Error Sending the APK Generation Email: \n" . print_r($e, true), "apk_generation_"); } die('ok'); }
public static function getImagePathTo($path = '') { if (!empty($path) and substr($path, 0, 1) != '/') { $path = '/' . $path; } return Core_Model_Directory::getPathTo(self::PATH . $path); }
public function uploadAction() { if ($code = $this->getRequest()->getPost("code")) { try { if (empty($_FILES) || empty($_FILES['file']['name'])) { throw new Exception("No file has been sent"); } $path = Core_Model_Directory::getPathTo(System_Model_Config::IMAGE_PATH); $base_path = Core_Model_Directory::getBasePathTo(System_Model_Config::IMAGE_PATH); if (!is_dir($base_path)) { mkdir($base_path, 0777, true); } $adapter = new Zend_File_Transfer_Adapter_Http(); $adapter->setDestination($base_path); if ($adapter->receive()) { $file = $adapter->getFileInfo(); $config = new System_Model_Config(); $config->find($code, "code"); $config->setValue($path . DS . $file['file']['name'])->save(); $message = sprintf("Your %s has been successfully saved", $code); $this->_sendHtml(array("success" => 1, "message" => $this->_($message))); } else { $messages = $adapter->getMessages(); if (!empty($messages)) { $message = implode("\n", $messages); } else { $message = $this->_("An error occurred during the process. Please try again later."); } throw new Exception($message); } } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } } }
protected function _initHtaccess() { $old_htaccess = Core_Model_Directory::getBasePathTo('htaccess.txt'); $new_htaccess = Core_Model_Directory::getBasePathTo('.htaccess'); if (!file_exists($new_htaccess) and is_readable($old_htaccess) and is_writable(Core_Model_Directory::getBasePathTo())) { $content = file_get_contents($old_htaccess); $content = str_replace('# ${RewriteBase}', 'RewriteBase ' . Core_Model_Directory::getPathTo(), $content); $htaccess = fopen($new_htaccess, 'w'); fputs($htaccess, $content); fclose($htaccess); } }
public static function getImagePathTo($path = '', $app_id = null) { if (!empty($path) and substr($path, 0, 1) != '/') { $path = '/' . $path; } if (!is_null($app_id)) { $path = sprintf(self::APPLICATION_PATH . $path, $app_id); } else { $path = self::PATH . $path; } return Core_Model_Directory::getPathTo($path); }
public function getBackgroundImageTablet($base = false) { return $base ? Core_Model_Directory::getBasePathTo(self::PATH_IMAGE . $this->getData('background_image_tablet')) : Core_Model_Directory::getPathTo($this->getData('background_image_tablet')); }
public function getImagePath() { return Core_Model_Directory::getPathTo(self::IMAGE_PATH); }
public function getUrl($base = false) { return $base ? $this->getImagePath() : Core_Model_Directory::getPathTo(str_replace(Core_Model_Directory::getBasePathTo(), '', $this->getImagePath())); }
public static function getImagePath() { return Core_Model_Directory::getPathTo(self::PATH_IMAGE); }
<?php $this->query("\n ALTER TABLE `application_layout_homepage`\n ADD `use_horizontal_scroll` TINYINT(1) NOT NULL DEFAULT '0' AFTER `use_more_button`,\n ADD `order` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1 AFTER `position`,\n ADD `is_active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1 AFTER `order`\n ;\n"); $layout = new Application_Model_Layout_Homepage(); $layouts = $layout->findAll(); $position = 0; $positions = array(); foreach ($layouts as $layout) { $position += 10; $positions[$layout->getCode()] = $position; $layout->setOrder($position); if ($layout->getCode() == "layout_8" and !file_exists(Core_Model_Directory::getPathTo("app/design/mobile/angular/template/home/l8/view.phtml"))) { $layout->setIsActive(false); } $layout->save(); } $layouts = array(array('name' => 'Layout 3 - Horizontal', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_3_h', 'preview' => '/customization/layout/homepage/layout_3-h.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 1, "number_of_displayed_icons" => 6, 'position' => "bottom", "order" => $positions["layout_3"] + 5, "is_active" => 1), array('name' => 'Layout 4 - Horizontal', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_4_h', 'preview' => '/customization/layout/homepage/layout_4-h.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 1, "number_of_displayed_icons" => 6, 'position' => "bottom", "order" => $positions["layout_4"] + 5, "is_active" => 1), array('name' => 'Layout 5 - Horizontal', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_5_h', 'preview' => '/customization/layout/homepage/layout_5-h.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 1, "number_of_displayed_icons" => 4, 'position' => "bottom", "order" => $positions["layout_5"] + 5, "is_active" => 1)); foreach ($layouts as $data) { $layout = new Application_Model_Layout_Homepage(); $layout->setData($data)->save(); }
public function getNoImage() { return Core_Model_Directory::getPathTo("images/application/placeholder/no-image-wordpress.png"); }
public static function getLogoPathTo($path = '') { return Core_Model_Directory::getPathTo(self::LOGO_PATH . $path); }
public static function getTemplatePath() { return Core_Model_Directory::getPathTo(self::PATH_TEMPLATES); }
public function uploadcertificateAction() { if ($app_id = $this->getRequest()->getParam("app_id")) { try { if (empty($_FILES) || empty($_FILES['file']['name'])) { throw new Exception("No file has been sent"); } $application = new Application_Model_Application(); $application->find($app_id); $base_path = Core_Model_Directory::getBasePathTo("var/apps/iphone/"); $path = Core_Model_Directory::getPathTo("var/apps/iphone/"); $adapter = new Zend_File_Transfer_Adapter_Http(); $adapter->setDestination(Core_Model_Directory::getTmpDirectory(true)); if ($adapter->receive()) { $file = $adapter->getFileInfo(); $certificat = new Push_Model_Certificate(); $certificat->find(array('type' => 'ios', 'app_id' => $app_id)); if (!$certificat->getId()) { $certificat->setType("ios")->setAppId($app_id); } $new_name = uniqid("cert_") . ".pem"; if (!rename($file["file"]["tmp_name"], $base_path . $new_name)) { throw new Exception($this->_("An error occurred while saving. Please try again later.")); } $certificat->setPath($path . $new_name)->save(); $data = array("success" => 1, "message" => $this->_("The file has been successfully uploaded")); } else { $messages = $adapter->getMessages(); if (!empty($messages)) { $message = implode("\n", $messages); } else { $message = $this->_("An error occurred during the process. Please try again later."); } throw new Exception($message); } } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }
public function saveAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { try { $previews = $data["previews"]; $option_id = !empty($data["option_id"]) ? $data["option_id"] : null; $preview_id = !empty($data["preview_id"]) ? $data["preview_id"] : null; if (empty($previews)) { throw new Exception($this->_("An error occurred while saving your previews. Please try again later.")); } $preview = new Preview_Model_Preview(); if (!empty($option_id) and empty($preview_id)) { //No preview for this option yet, we create one if it doesn't exists. $preview->find($option_id, "option_id"); if ($preview->getId()) { throw new Exception($this->_("Sorry, but an existing preview for this feature has been found. Please edit existing one.")); } $preview->setData("option_id", $option_id); } else { //Existing preview if (!empty($preview_id)) { $preview->find($data["preview_id"]); } else { throw new Exception($this->_("An error occurred while saving your previews. Please try again later.")); } } $previews_language_data = array(); foreach ($previews as $language_code => $data) { $option = new Application_Model_Option(); $option->find($preview->getOptionId()); if ($preview->getId()) { $library_id = $preview->findLibraryIdByLanguageCode($language_code); } else { $library_id = null; } if (!$library_id) { $library = new Media_Model_Library(); $library->setName('preview_' . $language_code . '_' . $option->getCode())->save(); $data["library_id"] = $library->getId(); } else { $data["library_id"] = $library_id; } //IMAGES------------------------------------------------ foreach ($data["images"] as $key => $image) { $library_image = new Media_Model_Library_Image(); //We only copy new files if ($image["new"] == 1) { $old_path = Core_Model_Directory::getTmpDirectory(true); $new_path = Core_Model_Directory::getBasePathTo("images/previews/" . $language_code . "/" . $option->getCode()); $new_path_base = Core_Model_Directory::getPathTo("images/previews/" . $language_code . "/" . $option->getCode()); if (!is_dir($new_path)) { if (!@mkdir($new_path, 0777, true)) { throw new Exception($this->_("Unable to create the directory.")); } } if (!@rename($old_path . "/" . $image["filename"], $new_path . "/" . $image["filename"])) { throw new Exception($this->_("Unable to copy the file.")); } $data_image = array("library_id" => $data["library_id"], "link" => $new_path_base . "/" . $image["filename"], "can_be_colorized" => 0, "position" => $key); $library_image->setData($data_image)->save(); } else { //For existing images, we save position $library_image->find($image["id"]); if ($library_image->getImageId()) { $library_image->setPosition($key)->save(); } } //We delete images to delete if ($image["to_delete"] == 1 and $image["new"] == 0) { if (!@unlink(Core_Model_Directory::getBasePathTo($image["link"]))) { throw new Exception($this->_("Unable to delete the file.")); } $library_image = new Media_Model_Library_Image(); $library_image->find($image["id"]); $library_image->delete(); } } unset($data["images"]); //<--IMAGES------------------------------------------------ unset($data["from_database"]); $data['language_code'] = $language_code; $data['preview_id'] = $preview->getId(); $previews_language_data[] = $data; } $preview->setLanguageData($previews_language_data); $preview->save(); $data = array("success" => 1, "message" => $this->_("Preview successfully saved")); } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }