Ejemplo n.º 1
0
 public function split_bundle()
 {
     $nonce = !empty($_REQUEST['_wpnonce']) ? $_REQUEST['_wpnonce'] : '';
     if (!wp_verify_nonce($nonce, '_wpnonce-download_split_bundle')) {
         die(__('Security check', 'wp_all_export_plugin'));
     } else {
         $uploads = wp_upload_dir();
         $id = PMXE_Plugin::$session->update_previous;
         if (empty($id)) {
             $id = $this->input->get('id');
         }
         $export = new PMXE_Export_Record();
         if (!$export->getById($id)->isEmpty()) {
             if (!empty($export->options['split_files_list'])) {
                 $tmp_dir = $uploads['basedir'] . DIRECTORY_SEPARATOR . PMXE_Plugin::TEMP_DIRECTORY . DIRECTORY_SEPARATOR . md5($export->id) . DIRECTORY_SEPARATOR;
                 $bundle_dir = $tmp_dir . 'split_files' . DIRECTORY_SEPARATOR;
                 wp_all_export_rrmdir($tmp_dir);
                 @mkdir($tmp_dir);
                 @mkdir($bundle_dir);
                 foreach ($export->options['split_files_list'] as $file) {
                     @copy($file, $bundle_dir . basename($file));
                 }
                 $friendly_name = sanitize_file_name($export->friendly_name);
                 $bundle_path = $tmp_dir . $friendly_name . '-split-files.zip';
                 PMXE_Zip::zipDir($bundle_dir, $bundle_path);
                 if (file_exists($bundle_path)) {
                     $bundle_url = $uploads['baseurl'] . str_replace($uploads['basedir'], '', $bundle_path);
                     PMXE_download::zip($bundle_path);
                 }
             }
         }
     }
 }