| 1 |
<?php |
| 2 |
|
| 3 |
if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) { |
| 4 |
die('Forbidden'); |
| 5 |
} |
| 6 |
if(!defined('ABSPATH')) |
| 7 |
die('Forbidden'); |
| 8 |
|
| 9 |
if(!current_user_can('manage_options')) |
| 10 |
die('Forbidden'); |
| 11 |
$formId=''; |
| 12 |
|
| 13 |
if(isset($_GET['formId'])) |
| 14 |
$formId=intval($_GET["formId"]); |
| 15 |
|
| 16 |
|
| 17 |
global $wpdb; |
| 18 |
|
| 19 |
$result=$wpdb->get_results($wpdb->prepare("SELECT * FROM ".SMART_FORMS_TABLE_NAME.' where form_id=%d',$formId),"ARRAY_A"); |
| 20 |
if(count($result)==0) |
| 21 |
return; |
| 22 |
|
| 23 |
header('Content-Encoding: UTF-8'); |
| 24 |
header('Content-type: text/csv; charset=UTF-8'); |
| 25 |
header('Content-Disposition: attachment; filename='.$result[0]['form_name'].'.export'); |
| 26 |
echo json_encode($result[0]); |
| 27 |
|
| 28 |
|
| 29 |
|