Title: Sent Message and CSV Export
Last modified: August 31, 2016

---

# Sent Message and CSV Export

 *  Resolved [nailujinacab](https://wordpress.org/support/users/nailujinacab/)
 * (@nailujinacab)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/sent-message-and-csv-export/)
 * Hi,
 * Is it possible to change the message after the downloader click the submit button?
   Currently the message is fixed to ” Thank you for your request. Your download
   has been sent”.
 * And also, I added new field in the form. The new field is a “country list”.
    
   When I exported the CSV, I can’t seem to find a column that shows the country
   of the sender.
 * I am willing to pay for support if these concerns can be solve 🙂
 * Thank you!
 * [https://wordpress.org/plugins/email-before-download/](https://wordpress.org/plugins/email-before-download/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [dtynan](https://wordpress.org/support/users/dtynan/)
 * (@dtynan)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/sent-message-and-csv-export/#post-7443465)
 * You have to edit email-before-download.php in order to change that message (I
   believe it is in two places so you’d probably want to change both). Note that
   if a new version of Email Before Download comes out at some point and you upgrade
   then it will overwrite your changed version and you’ll need to make that change
   again.
 * On the csv export, the fields are all hardcoded into the export.php file. So,
   you can add new fields to the CF7 form, but they won’t show up as their own column
   in the csv. However, one column in the csv file is called posted_data or something
   like that and it contains all the fields that were sent up when the user pressed
   submit on the form. That will have any extra fields and their values. Obviously
   it’s just one column in the csv so in order to get all the data into that one
   column they make it xml. So, to get the data back out you’d have to have some
   sort of script or program or something like that to parse the xml in that field
   and pull out that extra piece of data. Alternatively, you could make a bunch 
   of modifications to email-before-download.php and export.php to add that extra
   field to the database tables and then support it in the code & in the export 
   code. That would be some work.
 *  Thread Starter [nailujinacab](https://wordpress.org/support/users/nailujinacab/)
 * (@nailujinacab)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/sent-message-and-csv-export/#post-7443469)
 * Thanks for taking the time to reply. Appreciate it!
 * Unfortunately, I don’t know what to edit in the email-before-download.php. If
   this wouldn’t bother you, I would appreaciate if you take time to find the code
   that needs to be change. I will paste the code here from email-before-download.
   php.
 * Thanks!
 *     ```
       <?php
          $wp_root = dirname(__FILE__) .'/../../../';
          if(file_exists($wp_root . 'wp-load.php')) {
       	require_once($wp_root . "wp-load.php");
          } else if(file_exists($wp_root . 'wp-config.php')) {
       	require_once($wp_root . "wp-config.php");
         } else {
       	exit;
         }	
   
         //get file id
         $dId = $_REQUEST['dl'];
   
        //
         global $wpdb;
         $table_item = $wpdb->prefix . "ebd_item";
         $table_link = $wpdb->prefix . "ebd_link";
         $ebd_link = $wpdb->get_row( "SELECT * FROM $table_link  WHERE uid = '".esc_sql($dId)."';" );
   
         $dld = null;
          $is_new_dm = false;
           $old_rep = error_reporting(E_ERROR | E_PARSE);;
   
           $pd =  &get_file_data(  WP_PLUGIN_DIR . "/download-monitor/download-monitor.php", array("Version"=>"Version"), 'plugin');
           if(!($pd['Version'])) {
           }
           else $is_new_dm = true;
   
           $new = error_reporting($old_rep);
   
         if($ebd_link->expire_time != NULL && $ebd_link->expire_time != 0 && $ebd_link->expire_time < time()){
           @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
           wp_die( sprintf(__('The link you are trying to access is expired. <br/><br/><a href="%1$s"><strong>← Back to %2$s</strong></a>', "email-before-download"), get_bloginfo('url'), get_bloginfo('name')), __('The link you are trying to access is expired.',"email-before-download"));
         }
         $is_force_download = $ebd_link->is_force_download == 'yes' || $ebd_link->is_force_download == 'true';
         if($ebd_link->selected_id != NULL && $ebd_link->selected_id != 0){
           $dl = $wpdb->get_row( "SELECT * FROM $wp_dlm_db  WHERE id = ".esc_sql($ebd_link->selected_id).";" );
           $file = '';
           if(!$is_new_dm){
             $downloads = get_downloads('include='.$ebd_link->selected_id.'');
             $file = $downloads[0]->url;
           }
           else $file = do_shortcode('[download_data id="'.$ebd_link->selected_id.'" data="download_link"]');
   
           $wpdb->update( $table_link, array("is_downloaded"=>1), array("uid"=>esc_sql($dId)) );
           header("Location: $file");
           exit(0);
         }
         $ebd_item = $wpdb->get_row( "SELECT * FROM $table_item  WHERE id = '".esc_sql($ebd_link->item_id)."';" );
   
         $is_masked = get_option('email_before_download_hide');
         //is the "hide" option overriden for the individual download
         if($ebd_link->is_masked != NULL)
           $is_masked = $ebd_link->is_masked == 'yes' || $ebd_link->is_masked == 'true';
   
         if($is_force_download){
           $is_masked = true;
         }
         $file = '';
         if($ebd_item->file){
          $file = $ebd_item->file;
         }
         if($ebd_item->download_id){
           if(!$is_new_dm){
             $dl = $wpdb->get_row( "SELECT * FROM $wp_dlm_db  WHERE id = '".esc_sql($ebd_item->download_id)."';" );
   
             //another way of getting downloads from download monitor
             $downloads = get_downloads('include='.$ebd_item->download_id.'');
   
             $d = new downloadable_file($dl);
             $file = $downloads[0]->url;
   
             //if the link is masked use the real path of the DM file
             if ($is_masked && function_exists('curl_init')) $file = $d->filename;
           }
           else{
             //$file = do_shortcode('[download_data id="'.$ebd_item->download_id.'" data="download_link"]');
             if ($is_masked && function_exists('curl_init')) {
                $dld = new DLM_Download($ebd_item->download_id);
   
                $file  = $dld->get_file_version()->url;
                if(!isset($_SERVER['HTTP_RANGE'])){
                  $dld->get_file_version()->increase_download_count();
                }
             }
             else $file = do_shortcode('[download_data id="'.$ebd_item->download_id.'" data="download_link"]');
            }
         }
         $wpdb->update( $table_link, array("is_downloaded"=>1), array("uid"=>esc_sql($dId)) );
   
       //Check if the cUrl functions are available and the url hide option is enabled.
       //If not, just rederect to real file url.
   
       if ($is_masked && function_exists('curl_init')) {
       $filesize = 0;
       if($dld == null){
          $curl = curl_init();
          $url = $file;
          $options = array
          (
            CURLOPT_URL=>$url,
            CURLOPT_HEADER=>true,
            CURLOPT_RETURNTRANSFER=>true,
            CURLOPT_NOBODY=>TRUE,
          );
         curl_setopt_array($curl,$options);
         $r = curl_exec ($curl);
         $header_size = curl_getinfo($curl,CURLINFO_HEADER_SIZE);
         $header = substr($r, 0, $header_size);
         $body = substr( $r, $header_size );
   
         curl_close ($curl);
   
         $my_headers = ebd_parse_headers ( $header );
   
         $regex = '/Content-Length:\s([0-9].+?)\s/';
         $count = preg_match($regex, $header, $matches);
   
         $filesize =   isset($matches[1]) ? $matches[1] : "";
   
       $dirs = wp_upload_dir();
        $uploadpath = trailingslashit( $dirs['baseurl'] );
        $absuploadpath = trailingslashit( $dirs['basedir'] );
   
        if ( $uploadpath && ( strstr ( $file, $uploadpath ) || strstr ( $file, $absuploadpath )) ) {
          $file = str_replace( $uploadpath , "" , $file);
          if(is_file($absuploadpath.$file)){
            $file = $absuploadpath.$file;
          }
          else {
          //
            @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
            wp_die( sprintf(__('The file you are trying to download is not available. <br/><br/><a href="%1$s"><strong>← Back to %2$s</strong></a>', "email-before-download"), get_bloginfo('url'), get_bloginfo('name')), __('The link you are trying to access is expired.',"email-before-download"));
          }
        }
   
       foreach($my_headers as $key=>$value){
         if($key == 'Location') continue;
         header("$key: $value");  
   
       }
       }
       else{
         $filesize = $dld->get_file_version()->filesize;
         $mimetypes =  get_allowed_mime_types();
   
         $mime_type = 'application/force-download';
         foreach(get_allowed_mime_types() as $mime => $type) {
       			$mimes = explode( '|', $mime );
       			if (strpos($mime, $dld->get_file_version()->filetype) !== false) {
       				$mime_type = $type;
       				break;
       			}
       	}
   
       $dirs = wp_upload_dir();
        $uploadpath = trailingslashit( $dirs['baseurl'] );
        $absuploadpath = trailingslashit( $dirs['basedir'] );
   
        if ( $uploadpath && ( strstr ( $file, $uploadpath ) || strstr ( $file, $absuploadpath )) ) {
          $file = str_replace( $uploadpath , "" , $file);
          if(is_file($absuploadpath.$file)){
            $file = $absuploadpath.$file;
          }
          else {
          //
            @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
            wp_die( sprintf(__('The file you are trying to download is not available. <br/><br/><a href="%1$s"><strong>← Back to %2$s</strong></a>', "email-before-download"), get_bloginfo('url'), get_bloginfo('name')), __('The link you are trying to access is expired.',"email-before-download"));
          }
        }
   
       	header( "Robots: none" );
       	header( "Content-Type: " . $mime_type );
       	header( "Content-Description: File Transfer" );
   
       }
       //
       //HTTPRange support
         $size =$filesize;
         $begin=0;
         $end=$size;
   
         if(isset($_SERVER['HTTP_RANGE']))
         { if(preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches))
           { $begin=intval($matches[0]);
             if(!empty($matches[1]))
               $end=intval($matches[1]);
           }
         }
   
         if($begin>0||$end<$size)
           header('HTTP/1.0 206 Partial Content');
         else
           header('HTTP/1.0 200 OK');  
   
       header('Accept-Ranges: bytes');
   
       header("Content-Range: bytes $begin-$end/$size"); 
   
       $base_file_name = basename($file);
       if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") != false) {
         $base_file_name = urlencode(basename($file));
         $is_force_download = TRUE;
       }
       if($is_force_download)
         header("Content-Disposition: attachment; filename=\"" . $base_file_name . "\"");
       else header("Content-Disposition: filename=\"" . $base_file_name . "\"");
   
       header('Content-Length:'.($end-$begin));
   
       $chunksize = 1 * (1024 * 1024); // how many bytes per chunk
       if ($filesize > $chunksize) {
         $handle = fopen($file, 'rb');
         $buffer = '';
         // If it's a large file we don't want the script to timeout, so:
         @set_time_limit(0);
         fseek($handle,$begin,0);
         while (!feof($handle)) {
   
           $buffer = fread($handle, $chunksize);
           echo $buffer;
           ob_flush();
           flush();
         }
         fclose($handle);
       } else {
         readfile($file);
       } 
   
         exit(0);
   
       }
       else {
          header("Location: $file");
       }
   
           function ebd_parse_headers( $header )
           {
               $retVal = array();
               $fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header));
               foreach( $fields as $field ) {
                   if( preg_match('/([^:]+): (.+)/m', $field, $match) ) {
                       $match[1] = preg_replace('/(?<=^|[\x09\x20\x2D])./e', 'strtoupper("")', strtolower(trim($match[1])));
                       if( isset($retVal[$match[1]]) ) {
                           $retVal[$match[1]] = array($retVal[$match[1]], $match[2]);
                       } else {
                           $retVal[$match[1]] = trim($match[2]);
                       }
                   }
               }
               return $retVal;
           }
   
       ?>
       ```
   
 *  [dtynan](https://wordpress.org/support/users/dtynan/)
 * (@dtynan)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/sent-message-and-csv-export/#post-7443470)
 * The file you included there was download.php, not email-before-download.php. 
   However, that may not matter as I just realized that message text you are seeing
   is not in either file.
 * Hmm. Unfortunately, my installation has been modified a whole bunch, so I’m not
   sure exactly where that would be coming from. You can check the EBD settings 
   page in your wordpress menu. There are 15 or so settings in there – maybe that
   message is in one of those boxes.
 * Also, go check the CF7 form you made. Edit it and then one of the tabs is “Messages”.
   Click on that and then scroll down and look at each of the messages and see if
   it’s in there. I wouldn’t expect it to be since it specifically mentions a “download”,
   but check just to be sure.
 * If you don’t find it in either of those places then it has to be in email-before-
   download.php .. maybe you have an older version than the latest or something?
   not sure….
 *  Thread Starter [nailujinacab](https://wordpress.org/support/users/nailujinacab/)
 * (@nailujinacab)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/sent-message-and-csv-export/#post-7443475)
 *  Thread Starter [nailujinacab](https://wordpress.org/support/users/nailujinacab/)
 * (@nailujinacab)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/sent-message-and-csv-export/#post-7443476)
 * Yay! I found it 😀 😀 😀
 * It’s in the first box of Message tab of CF7. Thanks so much for your help!!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Sent Message and CSV Export’ is closed to new replies.

 * ![](https://ps.w.org/email-before-download/assets/icon-256x256.jpg?rev=1813522)
 * [Email Before Download](https://wordpress.org/plugins/email-before-download/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/email-before-download/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/email-before-download/)
 * [Active Topics](https://wordpress.org/support/plugin/email-before-download/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/email-before-download/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/email-before-download/reviews/)

## Tags

 * [csv](https://wordpress.org/support/topic-tag/csv/)
 * [export](https://wordpress.org/support/topic-tag/export/)
 * [sent](https://wordpress.org/support/topic-tag/sent/)

 * 5 replies
 * 2 participants
 * Last reply from: [nailujinacab](https://wordpress.org/support/users/nailujinacab/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/sent-message-and-csv-export/#post-7443476)
 * Status: resolved