Ejemplo n.º 1
0
 public function download()
 {
     $nonce = !empty($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : '';
     if (!wp_verify_nonce($nonce, '_wpnonce-download_feed')) {
         die(__('Security check', 'wp_all_export_plugin'));
     } else {
         $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
         $id = $this->input->get('id');
         $export = new PMXE_Export_Record();
         $filepath = '';
         if (!$export->getById($id)->isEmpty()) {
             if (!$is_secure_import) {
                 $filepath = get_attached_file($export->attch_id);
             } else {
                 $filepath = wp_all_export_get_absolute_path($export->options['filepath']);
             }
             if (@file_exists($filepath)) {
                 switch ($export['options']['export_to']) {
                     case 'xml':
                         PMXE_download::xml($filepath);
                         break;
                     case 'csv':
                         PMXE_download::csv($filepath);
                         break;
                     default:
                         break;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function get_file()
 {
     $nonce = !empty($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : '';
     if (!wp_verify_nonce($nonce, '_wpnonce-download_feed')) {
         die(__('Security check', 'wp_all_export_plugin'));
     } else {
         $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
         $id = $this->input->get('id');
         $export = new PMXE_Export_Record();
         $filepath = '';
         if (!$export->getById($id)->isEmpty()) {
             if (!$is_secure_import) {
                 $filepath = get_attached_file($export->attch_id);
             } else {
                 $filepath = wp_all_export_get_absolute_path($export->options['filepath']);
             }
             if (@file_exists($filepath)) {
                 switch ($export->options['export_to']) {
                     case 'xml':
                         PMXE_download::xml($filepath);
                         break;
                     case 'csv':
                         PMXE_download::csv($filepath);
                         break;
                     default:
                         wp_redirect(add_query_arg('pmxe_nt', urlencode(__('File format not supported', 'pmxe_plugin')), $this->baseUrl));
                         die;
                         break;
                 }
             } else {
                 wp_redirect(add_query_arg('pmxe_nt', urlencode(__('The exported file is missing and can\'t be downloaded. Please re-run your export to re-generate it.', 'pmxe_plugin')), $this->baseUrl));
                 die;
             }
         } else {
             wp_redirect(add_query_arg('pmxe_nt', urlencode(__('The exported file is missing and can\'t be downloaded. Please re-run your export to re-generate it.', 'pmxe_plugin')), $this->baseUrl));
             die;
         }
     }
 }
Ejemplo n.º 3
0
 public function download()
 {
     $nonce = !empty($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : '';
     if (!wp_verify_nonce($nonce, '_wpnonce-download_feed')) {
         die(__('Security check', 'wp_all_export_plugin'));
     } else {
         $attch_url = PMXE_Plugin::$session->file;
         $export_type = PMXE_Plugin::$session->export_to;
         // clear import session
         PMXE_Plugin::$session->clean_session();
         // clear session data (prevent from reimporting the same data on page refresh)
         switch ($export_type) {
             case 'xml':
                 PMXE_download::xml($attch_url);
                 break;
             case 'csv':
                 PMXE_download::csv($attch_url);
                 break;
             default:
                 # code...
                 break;
         }
     }
 }