コード例 #1
0
 /**
  * @return bool
  */
 public function save()
 {
     $search = esc_url_raw(filter_input(INPUT_POST, 'search'));
     $replace = esc_url_raw(filter_input(INPUT_POST, 'replace'));
     $new_db_prefix = esc_attr(filter_input(INPUT_POST, 'new_db_prefix'));
     //search field should not be empty
     if ('' === $replace) {
         $this->add_error(esc_html__('Replace Field should not be empty.', 'search-and-replace'));
         return FALSE;
     }
     $report = $this->dbe->db_backup($search, $replace, array(), TRUE, $new_db_prefix);
     $this->downloader->show_modal($report);
     return TRUE;
 }
コード例 #2
0
 /**
  * calls the file delivery in Class DatabaseExporter
  *
  * @wp-hook init
  */
 public function deliver_backup_file()
 {
     if (!$_SERVER['REQUEST_METHOD'] === 'POST') {
         return;
     }
     if (!isset($_POST['insr_nonce']) || !wp_verify_nonce($_POST['insr_nonce'], 'download_sql')) {
         return;
     }
     if (isset($_POST['action']) && 'download_file' === $_POST['action']) {
         $sql_file = '';
         if (isset($_POST['sql_file'])) {
             $sql_file = $_POST['sql_file'];
         }
         $compress = FALSE;
         if (isset($_POST['compress'])) {
             $compress = $_POST['compress'];
         }
         // If file name contains path or does not end with '.sql' exit.
         $ext = strrchr($sql_file, '.');
         if (FALSE !== strpos($sql_file, '/') || '.sql' !== $ext) {
             die;
         }
         $this->dbe->deliver_backup($sql_file, $compress);
     }
 }
コード例 #3
0
 /**
  * event handler for click on export sql button
  */
 public function save()
 {
     $report = $this->dbe->db_backup();
     $this->downloader->show_modal($report);
     return TRUE;
 }