Пример #1
0
 public function tearDown()
 {
     if (is_dir($this->oc_controller_dir)) {
         $this->fsh->rmdir($this->oc_controller_dir);
     }
     $this->installer->removeDatabase($this->options);
     $this->installer->removeConfigFiles();
 }
Пример #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (parent::execute($input, $output)) {
         $file_system_helper = new FileSystem();
         $this->loadOCConfig();
         $this->backup_folder = $this->getOCDirectory() . DIRECTORY_SEPARATOR . ".backup_tmp/";
         $za = new \ZipArchive();
         if ($za->open("ocok_backup_" . date("Y_m_d_H_i") . ".zip", \ZipArchive::OVERWRITE)) {
             if (is_dir($this->backup_folder)) {
                 $file_system_helper->rmdir($this->backup_folder);
             }
             mkdir($this->backup_folder);
             $image_path = DIR_IMAGE;
             if ($this->isVersion('2')) {
                 $image_path .= 'catalog/';
             } elseif ($this->isVersion('1')) {
                 $image_path .= 'data/';
             }
             if ($input->getOption("images")) {
                 $files = $file_system_helper->getFilesRecursively($image_path);
                 foreach ($files as $file) {
                     if ($file->isFile() && $file->isReadable() && $file_system_helper->isImage($file->getPathname())) {
                         // remove basefolder prefix from path
                         if (substr($file->getPathname(), 0, strlen($this->getOCDirectory())) == $this->getOCDirectory()) {
                             $path = substr($file->getPathname(), strlen($this->getOCDirectory()));
                         }
                         $za->addFile($file->getPathname(), substr($path, 1));
                     }
                 }
             }
             if ($input->getOption("database")) {
                 $dumper = new Mysqldump(DB_DATABASE, DB_USERNAME, DB_PASSWORD, DB_HOSTNAME, 'mysql', array('add-drop-table' => true, 'add-drop-database' => true, 'databases' => true));
                 $dumper->start($this->backup_folder . $this->backup_db);
                 $za->addFile($this->backup_folder . $this->backup_db, $this->backup_db);
             }
             $za->close();
             $file_system_helper->rmdir($this->backup_folder);
         }
     }
 }
Пример #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fsh = new FileSystem();
     $dir = getcwd();
     $installer = new Installer($dir . DIRECTORY_SEPARATOR);
     $options = array();
     $options['db_driver'] = $input->getOption("db_driver");
     $options['db_hostname'] = $input->getOption("db_hostname");
     $options['db_username'] = $input->getOption("db_username");
     $options['db_password'] = $input->getOption("db_password");
     $options['db_database'] = $input->getOption("db_database");
     $options['db_prefix'] = $input->getOption("db_prefix");
     $options['username'] = $input->getOption("username");
     $options['password'] = $input->getOption("password");
     $options['email'] = $input->getOption("email");
     $options['http_server'] = $input->getOption("http_server");
     if (!$options['db_username']) {
         $output->writeln("<error>Database Username option is missing!</error>");
         return;
     }
     if (!$options['db_password']) {
         $output->writeln("<error>Database Password option is missing!</error>");
         return;
     }
     if (!$options['username']) {
         $output->writeln("<error>Username option is missing!</error>");
         return;
     }
     if (!$options['password']) {
         $output->writeln("<error>Password option is missing!</error>");
         return;
     }
     if (!$options['email']) {
         $output->writeln("<error>Email option is missing!</error>");
         return;
     }
     if ($fsh->isEmptyDirectory($dir)) {
         $version = "2.0.1.1";
         if ($input->getOption("version")) {
             $version = $input->getOption("version");
         }
         $downloader = new Downloader($dir);
         $downloader->process($version);
         $output->writeln("<info>OpenCart Version {$version} downloaded.</info>");
     } else {
         if ($this->checkUninstalledOC()) {
             // OC present
             $version = $this->getVersion();
             $output->writeln("<info>OpenCart Version {$version} found.</info>");
         } else {
             $output->writeln("<error>No Empty and no OC Directory found here</error>");
             return;
         }
     }
     try {
         $installer->install($options);
         $installer->removeInstallationFiles();
     } catch (\Exception $e) {
         $output->writeln("<error>Error: " . $e->getMessage() . "</error>");
         return;
     }
     $output->writeln("<info>OpenCart was successfully installed!</info>");
 }