Example #1
0
 public function extract()
 {
     $tmp_dir = Core_Model_Directory::getTmpDirectory(true) . '/';
     if (!is_writable($tmp_dir)) {
         throw new Exception($this->_("The folder %s is not writable. Please fix this issue and try again.", $tmp_dir));
     } else {
         if (is_dir($this->_tmp_directory)) {
             Core_Model_Directory::delete($this->_tmp_directory);
         }
         mkdir($this->_tmp_directory, 0777);
         exec('unzip "' . $this->_tmp_file . '" -d "' . $this->_tmp_directory . '" 2>&1', $output);
         if (!count(glob($this->_tmp_directory))) {
             throw new Exception($this->_("Unable to extract the archive. Please make sure that the 'zip' extension is installed."));
         }
         exec('unzip "' . $this->_tmp_file . '" -d "' . $this->_tmp_directory . '" 2>&1', $output);
         $base_path = $this->_tmp_directory . "/app/modules/Template/db";
         if (file_exists("{$base_path}/database.template.php")) {
             $template = new Installer_Model_Installer_Module();
             $template->find("Template", "name");
             $tmp_new_version = explode(".", $template->getVersion());
             if (count($tmp_new_version) > 3) {
                 $version = "{$tmp_new_version[0]}.{$tmp_new_version[1]}.{$tmp_new_version[2]}." . ($tmp_new_version[3] + 1);
             } else {
                 $version = "{$template->getVersion()}.1";
             }
             $file = "database.{$version}.php";
             rename("{$base_path}/database.template.php", "{$base_path}/{$file}");
         }
         return $this->_tmp_directory;
     }
     /*
             $zip = new ZipArchive();
             if($zip->open($this->_tmp_file)) {
                 $tmp_dir = Core_Model_Directory::getTmpDirectory(true).'/';
                 if(!is_writable($tmp_dir)) {
                     throw new Exception($this->_("The folder %s is not writable. Please fix this issue and try again.", $tmp_dir));
                 } else {
     
                     if(is_dir($this->_tmp_directory)) {
                         Core_Model_Directory::delete($this->_tmp_directory);
                     }
                     mkdir($this->_tmp_directory, 0777);
     
                     if($zip->extractTo($this->_tmp_directory)) {
                         $zip->close();
                         return $this->_tmp_directory;
                     } else {
                         throw new Exception($this->_("Unable to open the file. Please, make sure that you sent a valid archive."));
                     }
                 }
     
             } else {
                 throw new Exception($this->_("Unable to open the archive."));
             }
     */
 }
 public function installAction()
 {
     $module_names = Zend_Controller_Front::getInstance()->getDispatcher()->getSortedModuleDirectories();
     $modules = array();
     foreach ($module_names as $module_name) {
         $module = new Installer_Model_Installer_Module();
         $module->prepare($module_name);
         if ($module->canUpdate()) {
             $modules[] = $module->getName();
         }
     }
     $this->loadPartials();
     $this->getLayout()->getPartial('content')->setModules($modules);
 }
Example #3
0
 public function install()
 {
     $module = new Installer_Model_Installer_Module();
     $module->prepare($this->getModuleName())->install();
     return $this;
 }
Example #4
0
 protected function _initModules()
 {
     if (!$this->_request->isInstalling()) {
         $front = $this->_front_controller;
         $module_names = $front->getDispatcher()->getSortedModuleDirectories();
         if (APPLICATION_ENV == "development") {
             foreach ($module_names as $module_name) {
                 $module = new Installer_Model_Installer_Module();
                 $module->prepare($module_name);
                 if ($module->canUpdate()) {
                     $module->install();
                 }
             }
         }
     }
 }
 public function installAction()
 {
     $data = array();
     try {
         $cache = Zend_Registry::isRegistered('cache') ? Zend_Registry::get('cache') : null;
         if ($cache) {
             $cache->clean("all");
         }
         $cache_ids = array('js_mobile.js', 'js_desktop.js', 'css_mobile.css', 'css_desktop.css');
         foreach ($cache_ids as $cache_id) {
             if (file_exists(Core_Model_Directory::getCacheDirectory(true) . "/{$cache_id}")) {
                 @unlink(Core_Model_Directory::getCacheDirectory(true) . "/{$cache_id}");
             }
         }
         $module_names = Zend_Controller_Front::getInstance()->getDispatcher()->getSortedModuleDirectories();
         $modules = array();
         foreach ($module_names as $module_name) {
             $module = new Installer_Model_Installer_Module();
             $module->prepare($module_name);
             if ($module->canUpdate()) {
                 $modules[] = $module->getName();
             }
         }
         foreach ($modules as $module) {
             $installer = new Installer_Model_Installer();
             $installer->setModuleName($module)->install();
         }
         $host = $this->getRequest()->getHeader("host");
         if ($host and $host == base64_decode("YXBwcy5tb2JpdXNjcy5jb20=")) {
             $email = base64_decode("Y29udGFjdEBzaWJlcmlhbmNtcy5jb20=");
             $object = "{$host} - Siberian Update";
             $message = "Siberian " . Siberian_Version::NAME . " " . Siberian_Version::VERSION;
             @mail($email, $object, $message);
         }
         $data = array("success" => 1, "message" => $this->_("Module successfully installed"));
     } catch (Exception $e) {
         $data = array("error" => 1, "message" => $e->getMessage());
     }
     $this->_sendHtml($data);
 }