/**
  * Select attachment file type and return result
  *
  * @param array $mailvars
  * @param int $type
  * @return mixed attachment content
  */
 public static function get_content($config)
 {
     // Remove control fields
     $mailvars = attach_mail_variables::remove_control_fields($config['mailvars'], $config['control']);
     // Create VCard
     if ($config['type'] == G10E_ATTACH_TYPE_VCARD) {
         if ($res = attach_mail_variables::vcard($mailvars)) {
             return $res;
         }
     }
     // Create CSV
     if ($config['type'] == G10E_ATTACH_TYPE_CSV) {
         if ($res = attach_mail_variables::csv($mailvars, $config)) {
             return $res;
         }
     }
 }
Example #2
0
 /**
  * Write csv file
  */
 function write_csv_file($post_data)
 {
     global $log_messages, $txt, $filepath;
     if ($log_messages == 'yes') {
         unset($post_data['fs']);
         unset($post_data['fn']);
         $config = array('mailvars' => $post_data, 'type' => G10E_ATTACH_TYPE_CSV, 'control' => $this->control_fields, 'csv_head' => false);
         if ($res = attach_mail_variables::get_content($config)) {
             if ($logfile = @fopen($filepath['logfile'] . 'formdata.csv', 'a')) {
                 @flock($logfile, 2) or debug_mode($txt['txt_cannot_lock_file'] . $filepath['logfile'] . 'formdata.csv');
                 $line = date('Y-m-d');
                 $line .= G10E_ATTACH_TYPE_CSV_DELIMITER . date('H:i:s');
                 $line .= G10E_ATTACH_TYPE_CSV_DELIMITER . $res;
                 $line = str_replace("\n", ' ', str_replace("\r", ' ', $line));
                 @fputs($logfile, $line . "\n");
                 @fclose($logfile);
             } else {
                 debug_mode($filepath['logfile'] . 'formdata.csv', $txt['txt_cannot_open_file']);
             }
         }
     }
 }