1 | <?php |
---|
2 | if (!defined('USER_COLLEC_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | try { |
---|
5 | $UserCollection = new UserCollection($_GET['col_id']); |
---|
6 | |
---|
7 | $template->assign('COL_ID', $_GET['col_id']); |
---|
8 | } |
---|
9 | catch (Exception $e) |
---|
10 | { |
---|
11 | array_push($page['errors'], $e->getMessage()); |
---|
12 | } |
---|
13 | |
---|
14 | // pwg_unset_session_var('uc_export_active_fields'); |
---|
15 | // pwg_unset_session_var('uc_export_inactive_fields'); |
---|
16 | |
---|
17 | if (isset($_POST['download'])) |
---|
18 | { |
---|
19 | pwg_set_session_var('uc_export_active_fields', $_POST['active']); |
---|
20 | pwg_set_session_var('uc_export_inactive_fields', $_POST['inactive']); |
---|
21 | |
---|
22 | $content = $UserCollection->serialize($_POST['active']); |
---|
23 | $filename = 'collection_'.$_GET['col_id'].'_'.date('Ymd-Hi').'.csv'; |
---|
24 | |
---|
25 | header('Content-Type: application/force-download; name="'.$filename.'"'); |
---|
26 | header('Content-Disposition: attachment; filename="'.$filename.'"'); |
---|
27 | header('Content-Description: File Transfer'); |
---|
28 | header('Content-Transfer-Encoding: binary'); |
---|
29 | header('Content-Length: '.strlen($content).''); |
---|
30 | |
---|
31 | header('Cache-Control: no-cache, must-revalidate'); |
---|
32 | header('Pragma: no-cache'); |
---|
33 | header('Expires: 0'); |
---|
34 | |
---|
35 | echo $content; |
---|
36 | exit; |
---|
37 | } |
---|
38 | |
---|
39 | $default_active_fields = array( |
---|
40 | 'id', |
---|
41 | 'name', |
---|
42 | 'path', |
---|
43 | ); |
---|
44 | $default_inactive_fields = array( |
---|
45 | 'file', |
---|
46 | 'url', |
---|
47 | 'date_creation', |
---|
48 | 'collection_add_date', |
---|
49 | 'filesize', |
---|
50 | 'width', |
---|
51 | 'height', |
---|
52 | ); |
---|
53 | |
---|
54 | $template->assign('active_fields', pwg_get_session_var('uc_export_active_fields', $default_active_fields)); |
---|
55 | $template->assign('inactive_fields', pwg_get_session_var('uc_export_inactive_fields', $default_inactive_fields)); |
---|
56 | |
---|
57 | $template->set_filename('user_collections', dirname(__FILE__) . '/template/export.tpl'); |
---|
58 | |
---|
59 | ?> |
---|