public function uploadAction() { if (!empty($_FILES)) { try { $path = '/var/apps/iphone/'; $base_path = Core_Model_Directory::getBasePathTo($path); $filename = uniqid() . '.pem'; if (!is_dir($base_path)) { mkdir($base_path, 0775, true); } $adapter = new Zend_File_Transfer_Adapter_Http(); $adapter->setDestination($base_path); $adapter->setValidators(array('Extension' => array('pem', 'case' => false))); $adapter->getValidator('Extension')->setMessages(array('fileExtensionFalse' => $this->_("Extension not allowed, \\'%s\\' only", '%extension%'))); $files = $adapter->getFileInfo(); foreach ($files as $file => $info) { if (!$adapter->isUploaded($file)) { throw new Exception($this->_('An error occurred during process. Please try again later.')); } else { if (!$adapter->isValid($file)) { if (count($adapter->getMessages()) == 1) { $erreur_message = $this->_('Error : <br/>'); } else { $erreur_message = $this->_('Errors : <br/>'); } foreach ($adapter->getMessages() as $message) { $erreur_message .= '- ' . $message . '<br/>'; } throw new Exception($erreur_message); } else { $adapter->addFilter(new Zend_Filter_File_Rename(array('target' => $base_path . $filename, 'overwrite' => true))); $adapter->receive($file); } } } $certificat = new Push_Model_Certificat(); $certificat->find('ios', 'type'); if (!$certificat->getId()) { $certificat->setType('ios'); } $certificat->setPath($path . $filename)->save(); $datas = array('success' => 1, 'files' => 'eeeee', 'message_success' => $this->_('Infos successfully saved'), 'message_button' => 0, 'message_timeout' => 2); } catch (Exception $e) { $datas = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($datas)); } }
protected function _prepareFiles() { $links = glob($this->_dst . '/src/com/' . $this->_formatted_bundle_name . '/' . $this->_formatted_name . '/*'); $url = $this->getUrl(); if (!$links) { return $this; } $links = array_merge(array($this->_dst . '/AndroidManifest.xml'), $links); foreach ($links as $link) { if (!is_dir($link)) { $this->__replace(array('siberian.app' => $this->_formatted_bundle_name . '.' . $this->_formatted_name), $link); if (strpos($link, 'CommonUtilities.java') !== false) { $this->__replace(array('String SENDER_ID = ""' => 'String SENDER_ID = "' . Push_Model_Certificat::getAndroidSenderId() . '"', 'SERVEUR_URL = "http://www.siberiancms.com/";' => 'SERVEUR_URL = "' . $this->getUrl() . '";'), $link); } } } $name = str_replace(array('&', '/'), 'AND', $this->getApplication()->getName()); $this->__replace(array('<name>Siberian</name>' => '<name>' . $name . '</name>'), $this->_dst . '/.project'); $replacements = array('http://app.siberiancms.com' => $this->getApplication()->getUrl(null, array(), false, 'en'), '<string name="app_name">Siberian</string>' => '<string name="app_name">' . $name . '</string>'); $this->__replace($replacements, $this->_dst . '/res/values/strings.xml'); foreach (Core_Model_Language::getLanguageCodes() as $lang) { if ($lang != 'en') { $replacements = array('http://app.siberiancms.com' => $this->getApplication()->getUrl(null, array(), false, $lang), '<string name="app_name">Siberian</string>' => '<string name="app_name">' . $name . '</string>'); $this->__replace($replacements, $this->_dst . '/res/values-' . $lang . '/strings.xml'); } } return $this; }
public static function getAndroidSenderId() { if (is_null(self::$_android_sender_id)) { $certificat = new self(); $certificat->find('android_sender_id', 'type'); self::$_android_sender_id = $certificat->getPath(); } return self::$_android_sender_id; }
/** * Constructor. * * @param array $params * @access public */ function __construct($params = array()) { parent::__construct($params); $this->__key = Push_Model_Certificat::getAndroidKey(); }
public function __construct($datas = array()) { parent::__construct($datas); $this->__certificate = Core_Model_Directory::getBasePathTo(Push_Model_Certificat::getiOSCertificat()); }