Пример #1
0
 /**
  * IMPORT: Loads a ZIP file, parses and adds contents to the database.
  */
 public function import($paperID = 0)
 {
     if ($paperID != 0) {
         $this->properties = PaperProperties::get_paper_properties_by_id($paperID, $this->db, $this->string);
     }
     $this->logger = new Logger($this->db);
     $this->status_array = QuestionStatus::get_all_statuses_by_name($this->db, $this->string);
     $this->get_keyword_ids();
     $this->zip_filename = $this->userID . '_raf.zip';
     $tmp_path = $this->configObj->get('cfg_tmpdir');
     if (!move_uploaded_file($_FILES['raffile']['tmp_name'], $tmp_path . $this->zip_filename)) {
         echo uploadError($_FILES['raffile']['error']);
         exit;
     }
     $dest_dir = $tmp_path . $this->userID;
     if (!file_exists($dest_dir)) {
         mkdir($dest_dir, 0700);
     }
     $zip = new ZipArchive();
     if ($zip->open($tmp_path . $this->zip_filename) === TRUE) {
         $zip->extractTo($dest_dir);
         if (file_exists($dest_dir . '/raf.json')) {
             $this->data = file_get_contents($dest_dir . '/raf.json');
         } else {
             $zip->close();
             $msg = sprintf($this->string['furtherassistance'], $this->configObj->get('support_email'), $this->configObj->get('support_email'));
             $this->notice->display_notice_and_exit($this->db, $this->string['invalidraf'], $msg, $this->string['invalidraf'], '../artwork/exclamation_48.png', '#C00000', true, true);
         }
         $this->copy_images($dest_dir, $tmp_path);
         $this->load_raf_data();
         unlink($dest_dir . '/raf.json');
         $zip->close();
     } else {
         $msg = sprintf($this->string['furtherassistance'], $this->configObj->get('support_email'), $this->configObj->get('support_email'));
         $this->notice->display_notice_and_exit($this->db, $this->string['invalidzip'], $msg, $this->string['invalidzip'], '../artwork/exclamation_48.png', '#C00000', true, true);
     }
 }