Пример #1
0
 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');
 }
Пример #2
0
 public function forgottenpasswordAction()
 {
     if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) {
         try {
             if (empty($data['email'])) {
                 throw new Exception($this->_('Please enter your email address'));
             }
             $user = new Backoffice_Model_User();
             $user->find($data['email'], 'email');
             if (!$user->getId()) {
                 throw new Exception($this->_("Your email address does not exist"));
             }
             $password = Core_Model_Lib_String::generate(8);
             $user->setPassword($password)->save();
             $sender = System_Model_Config::getValueFor("support_email");
             $support_name = System_Model_Config::getValueFor("support_name");
             $layout = $this->getLayout()->loadEmail('admin', 'forgot_password');
             $subject = $this->_('Your new password');
             $layout->getPartial('content_email')->setPassword($password);
             $content = $layout->render();
             $mail = new Zend_Mail('UTF-8');
             $mail->setBodyHtml($content);
             $mail->setFrom($sender, $support_name);
             $mail->addTo($user->getEmail(), $user->getName());
             $mail->setSubject($subject);
             $mail->send();
             $data = array("success" => 1, "message" => $this->_('Your new password has been sent to the entered email address'));
         } catch (Exception $e) {
             $data = array("error" => 1, "message" => $e->getMessage());
         }
     }
     $this->_sendHtml($data);
 }
 public function checkAction()
 {
     if ($this->getRequest()->isPost()) {
         $admin_can_publish = $this->getSession()->getAdmin()->canPublishThemself();
         $errors = $this->getApplication()->isAvailableForPublishing($admin_can_publish);
         if (!empty($errors)) {
             $message = $this->_('In order to publish your application, we need:<br />- ');
             $message .= join('<br />- ', $errors);
             $html = array('message' => $message, 'message_button' => 1, 'message_loader' => 1);
         } else {
             if (Siberian_Version::TYPE == "MAE") {
                 $backoffice_email = null;
                 $system = new System_Model_Config();
                 if ($system->getValueFor("support_email")) {
                     $backoffice_email = $system->getValueFor("support_email");
                 } else {
                     $user = new Backoffice_Model_User();
                     $backoffice_user = $user->findAll(array(), "user_id ASC", array("limit" => 1))->current();
                     if ($backoffice_user) {
                         $backoffice_email = $backoffice_user->getEmail();
                     }
                 }
                 $layout = $this->getLayout()->loadEmail('application', 'publish_app');
                 $layout->getPartial('content_email')->setApp($this->getApplication())->setAdmin($this->getAdmin())->setBackofficeEmail($backoffice_email);
                 $content = $layout->render();
                 $sender = $backoffice_email;
                 $mail = new Zend_Mail('UTF-8');
                 $mail->setBodyHtml($content);
                 $mail->setFrom($sender);
                 $mail->addTo($backoffice_email);
                 $mail->setSubject($this->_('%s – Publication request', $this->getApplication()->getName()));
                 $mail->send();
                 $html = array('success_message' => $this->_("Your app will be published"), 'message_button' => 0, 'message_loader' => 0, 'message_timeout' => 3);
             } else {
                 if (Siberian_Version::TYPE == "PE") {
                     $url = $this->getUrl('subscription/application/create');
                     $html = array('url' => $url);
                 }
             }
         }
         $this->getResponse()->setBody(Zend_Json::encode($html))->sendResponse();
         die;
     }
 }
Пример #4
0
 public function getLogo()
 {
     try {
         $logo = "";
         if ($this->getCurrentWhiteLabelEditor()) {
             $logo = $this->getCurrentWhiteLabelEditor()->getLogoUrl();
         }
         if (!$logo) {
             $logo = System_Model_Config::getValueFor("logo");
         }
         if (!$logo) {
             $logo = $this->getImage("header/logo.png");
         }
     } catch (Exception $e) {
         $logo = $this->getImage("header/logo.png");
     }
     return $logo;
 }
Пример #5
0
 public function findDefaultRoleId()
 {
     return System_Model_Config::getValueFor(self::DEFAULT_ADMIN_ROLE_CODE);
 }
Пример #6
0
 protected function _initLocale()
 {
     $locale = new Zend_Locale();
     $locale_code = Core_Model_Language::DEFAULT_LOCALE;
     $is_installing = $this->getRequest()->isInstalling();
     if ($this->getRequest()->isApplication() && $this->getApplication()->getLocale()) {
         $locale_code = $this->getApplication()->getLocale();
     } else {
         if (!$is_installing) {
             $currency_code = System_Model_Config::getValueFor("system_currency");
             if ($currency_code) {
                 $currency = new Zend_Currency(null, $currency_code);
                 Core_Model_Language::setCurrentCurrency($currency);
             }
             $territory = System_Model_Config::getValueFor("system_territory");
             if ($territory) {
                 $locale_code = $locale->getLocaleToTerritory($territory);
             } else {
                 $locale_code = new Zend_Locale(Core_Model_Language::getCurrentLocale());
             }
         }
     }
     if (!$is_installing) {
         $timezone = System_Model_Config::getValueFor("system_timezone");
         if ($timezone) {
             date_default_timezone_set($timezone);
         }
     }
     $locale->setLocale($locale_code);
     Zend_Registry::set('Zend_Locale', $locale);
 }
Пример #7
0
 public function forgotpasswordAction()
 {
     if ($data = $this->getRequest()->getPost()) {
         try {
             if (empty($data['email'])) {
                 throw new Exception($this->_('Please enter your email address'));
             }
             $admin = new Admin_Model_Admin();
             $admin->findByEmail($data['email']);
             if (!$admin->getId()) {
                 throw new Exception($this->_("This email address does not exist"));
             }
             $password = Core_Model_Lib_String::generate(8);
             $admin->setPassword($password)->save();
             $sender = System_Model_Config::getValueFor("support_email");
             $support_name = System_Model_Config::getValueFor("support_name");
             $layout = $this->getLayout()->loadEmail('admin', 'forgot_password');
             $subject = $this->_('%s - Your new password', $support_name);
             $layout->getPartial('content_email')->setPassword($password);
             $content = $layout->render();
             $mail = new Zend_Mail('UTF-8');
             $mail->setBodyHtml($content);
             $mail->setFrom($sender, $support_name);
             $mail->addTo($admin->getEmail(), $admin->getName());
             $mail->setSubject($subject);
             $mail->send();
             $data = array("success" => 1);
         } catch (Exception $e) {
             $data = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
Пример #8
0
 protected function _generateApk()
 {
     $output = array();
     $alias = $this->getDevice()->getAlias();
     $store_password = $this->getDevice()->getStorePass();
     $key_password = $this->getDevice()->getKeyPass();
     $src = "var/tmp/applications/android/{$this->_folder_name}/Siberian";
     // Generates the keystore
     $keystore_base_path = Core_Model_Directory::getBasePathTo('var/apps/android/keystore/' . $this->getApplication()->getId() . '.pks');
     if (!file_exists($keystore_base_path)) {
         $organization = preg_replace('/[,\\s]+/', " ", System_Model_Config::getValueFor("company_name"));
         if (!$organization) {
             $organization = "Default";
         }
         exec('keytool -genkey -noprompt -alias ' . $alias . ' -dname "CN=' . $organization . ', O=' . $organization . '" -keystore ' . $keystore_base_path . ' -storepass ' . $store_password . ' -keypass ' . $key_password . ' -validity 36135 2>&1', $output);
     }
     // Adds the URL called at the end of the gradlew
     $gradlew_path = Core_Model_Directory::getBasePathTo("{$src}/app/gradlew");
     $gradlew_content = file_get_contents($gradlew_path);
     $url = Core_Model_Url::create("application/device/apkisgenerated", array("app_name" => $this->_folder_name));
     $gradlew_content .= 'wget "' . $url . '"';
     file_put_contents($gradlew_path, $gradlew_content);
     // Sets the Android SDK path
     $data = 'sdk.dir=' . Core_Model_Directory::getBasePathTo("var/apps/android/sdk");
     file_put_contents("{$src}/local.properties", $data);
     // Updates the build.gradle
     $content = file_get_contents("{$src}/app/build.gradle.save");
     $arraySearch = array('my_storePassword', 'my_keyAlias', 'my_keyPassword', 'my_packageName', 'my_keystore_path');
     $arrayReplace = array($store_password, $alias, $key_password, $this->_package_name, $keystore_base_path);
     $content = str_replace($arraySearch, $arrayReplace, $content);
     file_put_contents("{$src}/app/build.gradle", $content);
     // Changes the current directory
     chdir(Core_Model_Directory::getBasePathTo("{$src}/app"));
     // Creates a environment variable
     putenv('GRADLE_USER_HOME=' . Core_Model_Directory::getBasePathTo("var/tmp/applications/android/gradle"));
     // Executes gradlew
     exec('bash gradlew build 2>&1', $output);
     if (in_array('BUILD SUCCESSFUL', $output)) {
         return Core_Model_Directory::getBasePathTo("{$src}/app/build/outputs/apk/app-release.apk");
     } else {
         Zend_Registry::get("logger")->sendException(print_r($output, true), "apk_generation_", false);
         return false;
     }
 }
Пример #9
0
 private function __getFtp()
 {
     if (!$this->__ftp) {
         $host = System_Model_Config::getValueFor("ftp_host");
         if ($host) {
             $user = System_Model_Config::getValueFor("ftp_username");
             $password = System_Model_Config::getValueFor("ftp_password");
             $port = System_Model_Config::getValueFor("ftp_port");
             $path = System_Model_Config::getValueFor("ftp_path");
             $this->__ftp = new Siberian_Ftp($host, $user, $password, $port, $path);
         }
     }
     return $this->__ftp;
 }
Пример #10
0
 public function forgotpasswordpostAction()
 {
     if ($datas = $this->getRequest()->getPost() and !$this->getSession()->isLoggedIn('admin') and !$this->getSession()->isLoggedIn('pos')) {
         try {
             if (empty($datas['email'])) {
                 throw new Exception($this->_('Please enter your email address'));
             }
             $admin = new Admin_Model_Admin();
             $admin->findByEmail($datas['email']);
             if (!$admin->getId()) {
                 throw new Exception($this->_("Your email address does not exist"));
             }
             $password = Core_Model_Lib_String::generate(8);
             $admin->setPassword($password)->save();
             $sender = System_Model_Config::getValueFor("support_email");
             $support_name = System_Model_Config::getValueFor("support_name");
             $layout = $this->getLayout()->loadEmail('admin', 'forgot_password');
             $subject = $this->_('%s - Your new password', $support_name);
             $layout->getPartial('content_email')->setPassword($password);
             $content = $layout->render();
             $mail = new Zend_Mail('UTF-8');
             $mail->setBodyHtml($content);
             $mail->setFrom($sender, $support_name);
             $mail->addTo($admin->getEmail(), $admin->getName());
             $mail->setSubject($subject);
             $mail->send();
             $this->getSession()->addSuccess($this->_('Your new password has been sent to the entered email address'));
         } catch (Exception $e) {
             $this->getSession()->addError($e->getMessage());
         }
     }
     $this->_redirect('/');
     return $this;
 }
Пример #11
0
 public function checkpermissionsAction()
 {
     if ($file = $this->getRequest()->getParam("file")) {
         $data = array();
         try {
             $filename = base64_decode($file);
             $file = Core_Model_Directory::getTmpDirectory(true) . "/{$filename}";
             if (!file_exists($file)) {
                 throw new Exception($this->_("The file %s does not exist", $filename));
             }
             $parser = new Installer_Model_Installer_Module_Parser();
             $is_ok = $parser->setFile($file)->checkPermissions();
             if (!$is_ok) {
                 $ftp_host = System_Model_Config::getValueFor("ftp_host");
                 $ftp_user = System_Model_Config::getValueFor("ftp_username");
                 $ftp_password = System_Model_Config::getValueFor("ftp_password");
                 $ftp_port = System_Model_Config::getValueFor("ftp_port");
                 $ftp_path = System_Model_Config::getValueFor("ftp_path");
                 $ftp = new Siberian_Ftp($ftp_host, $ftp_user, $ftp_password, $ftp_port, $ftp_path);
                 if ($ftp->checkConnection() and $ftp->isSiberianDirectory()) {
                     $is_ok = true;
                 }
             }
             if ($is_ok) {
                 $data = array("success" => 1);
             } else {
                 $messages = $parser->getErrors();
                 $message = implode("\n", $messages);
                 throw new Exception($this->_($message));
                 //                    throw new Exception($this->_($message));
             }
         } catch (Exception $e) {
             $data = array("error" => 1, "message" => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
Пример #12
0
 public function sendCreationAccountEmail($password)
 {
     $layout = Zend_Controller_Action_HelperBroker::getStaticHelper('layout')->getLayoutInstance()->loadEmail('admin', 'create_account');
     $layout->getPartial('content_email')->setAdmin($this)->setPassword($password);
     $content = $layout->render();
     $sender = System_Model_Config::getValueFor("support_email");
     $support_name = System_Model_Config::getValueFor("support_name");
     $mail = new Zend_Mail('UTF-8');
     $mail->setBodyHtml($content);
     $mail->setFrom($sender, $support_name);
     $mail->addTo($this->getEmail());
     $mail->setSubject($this->_("Welcome!"));
     $mail->send();
     return $this;
 }