type = 'i'; $this->name = __('Flat file import'); $this->description = __('Imports a blog or a full Dotclear installation from flat file.'); } public function process($do) { if ($do == 'single' || $do == 'full') { $this->status = $do; return; } $to_unlink = false; # Single blog import $files = $this->getPublicFiles(); $single_upl = null; if (!empty($_POST['public_single_file']) && in_array($_POST['public_single_file'],$files)) { $single_upl = false; } elseif (!empty($_FILES['up_single_file'])) { $single_upl = true; } if ($single_upl !== null) { if ($single_upl) { files::uploadStatus($_FILES['up_single_file']); $file = DC_TPL_CACHE.'/'.md5(uniqid()); if (!move_uploaded_file($_FILES['up_single_file']['tmp_name'],$file)) { throw new Exception(__('Unable to move uploaded file.')); } $to_unlink = true; } else { $file = $_POST['public_single_file']; } try { $bk = new dcImport($this->core,$file); $bk->importSingle(); } catch (Exception $e) { if ($to_unlink) { @unlink($file); } throw $e; } if ($to_unlink) { @unlink($file); } http::redirect($this->getURL().'&do=single'); } # Full import $full_upl = null; if (!empty($_POST['public_full_file']) && in_array($_POST['public_full_file'],$files)) { $full_upl = false; } elseif (!empty($_FILES['up_full_file'])) { $full_upl = true; } if ($full_upl !== null && $this->core->auth->isSuperAdmin()) { if (empty($_POST['your_pwd']) || !$this->core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY,$_POST['your_pwd']))) { throw new Exception(__('Password verification failed')); } if ($full_upl) { files::uploadStatus($_FILES['up_full_file']); $file = DC_TPL_CACHE.'/'.md5(uniqid()); if (!move_uploaded_file($_FILES['up_full_file']['tmp_name'],$file)) { throw new Exception(__('Unable to move uploaded file.')); } $to_unlink = true; } else { $file = $_POST['public_full_file']; } try { $bk = new dcImport($this->core,$file); $bk->importFull(); } catch (Exception $e) { if ($to_unlink) { @unlink($file); } throw $e; } if ($to_unlink) { @unlink($file); } http::redirect($this->getURL().'&do=full'); } header('content-type:text/plain'); var_dump($_POST); exit; $this->status = true; } public function gui() { if ($this->status == 'single') { echo '
'; return; } if ($this->status == 'full') { echo ' '; return; } echo '\n"; echo ''.sprintf(__('This will import a single blog backup as new content in the current blog: %s.'), ''.html::escapeHTML($this->core->blog->name).'').'
'. ''; if ($this->core->auth->isSuperAdmin()) { echo '