forked from wp-sms/wp-sms
-
Notifications
You must be signed in to change notification settings - Fork 1
/
export.php
53 lines (37 loc) · 1.13 KB
/
export.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
require('../../../wp-load.php');
if (!is_super_admin())
wp_die(__('Access denied!', 'wp-sms'));
$type = $_POST['export-file-type'];
if ($type) {
global $wpdb, $table_prefix;
require('includes/classes/php-export-data.class.php');
$file_name = date('Y-m-d_H-i');
$result = $wpdb->get_results("SELECT `ID`,`date`,`name`,`mobile`,`status`,`group_ID` FROM {$table_prefix}sms_subscribes");
switch ($type) {
case 'excel':
$exporter = new ExportDataExcel('browser', "{$file_name}.xls");
break;
case 'xml':
$exporter = new ExportDataExcel('browser', "{$file_name}.xml");
break;
case 'csv':
$exporter = new ExportDataCSV('browser', "{$file_name}.csv");
break;
case 'tsv':
$exporter = new ExportDataTSV('browser', "{$file_name}.tsv");
break;
}
$exporter->initialize();
foreach ($result[0] as $key => $col) {
$columns[] = $key;
}
$exporter->addRow($columns);
foreach ($result as $row) {
$exporter->addRow($row);
}
$exporter->finalize();
} else {
wp_die(__('Please select the desired items.', 'wp-sms'), false, array('back_link' => true));
}
?>