[20090] | 1 | <?php |
---|
| 2 | if (!defined('USER_COLLEC_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | try { |
---|
[24421] | 5 | $collection = new UserCollection($_GET['col_id']); |
---|
[25678] | 6 | |
---|
[20090] | 7 | $template->assign('COL_ID', $_GET['col_id']); |
---|
| 8 | } |
---|
| 9 | catch (Exception $e) |
---|
| 10 | { |
---|
| 11 | array_push($page['errors'], $e->getMessage()); |
---|
| 12 | } |
---|
| 13 | |
---|
[20099] | 14 | // pwg_unset_session_var('uc_export_active_fields'); |
---|
| 15 | // pwg_unset_session_var('uc_export_inactive_fields'); |
---|
[20090] | 16 | |
---|
| 17 | if (isset($_POST['download'])) |
---|
| 18 | { |
---|
[20099] | 19 | pwg_set_session_var('uc_export_active_fields', $_POST['active']); |
---|
| 20 | pwg_set_session_var('uc_export_inactive_fields', $_POST['inactive']); |
---|
[25678] | 21 | |
---|
[24421] | 22 | $content = $collection->serialize($_POST['active']); |
---|
[20090] | 23 | $filename = 'collection_'.$_GET['col_id'].'_'.date('Ymd-Hi').'.csv'; |
---|
[25678] | 24 | |
---|
[20090] | 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'); |
---|
[25678] | 34 | |
---|
[20090] | 35 | echo $content; |
---|
| 36 | exit; |
---|
| 37 | } |
---|
| 38 | |
---|
[20099] | 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 | |
---|
[25678] | 57 | |
---|
[23551] | 58 | $template->set_filename('user_collections', realpath(USER_COLLEC_PATH . 'admin/template/export.tpl')); |
---|