-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.php
36 lines (29 loc) · 979 Bytes
/
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
<?php
/**
* $Header$
*
* Copyright (c) 2013 bitweaver.org
* All Rights Reserved. See below for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
*
* @package meta
*/
require_once( '../kernel/includes/setup_inc.php' );
// Is package installed and enabled
$gBitSystem->verifyPackage( 'meta' );
// Now check permissions to access this page
$gBitSystem->verifyPermission( 'p_view_meta' );
require_once META_PKG_INCLUDE_PATH.'meta_lib.php';
$data = data_metatable( '', $_REQUEST, 'csv' );
$file = tempnam( sys_get_temp_dir(), 'users' );
$fp = fopen($file, 'w');
foreach( $data as &$row ) {
fputcsv( $fp, $row );
}
fclose( $fp );
header( "Content-Type: text/csv" );
header('Content-disposition: attachment;filename='.$gBitSystem->getConfig('site_title', 'Site').'-'.META_PKG_DIR.'-export-'.date('Y-m-d_Hi').'.csv');
readfile( $file );
flush();
unlink( $file );
exit;