1 | <?php |
---|
2 | /*************************************************************************** |
---|
3 | * Expresso Livre * |
---|
4 | * http://www.expressolivre.org * |
---|
5 | * -------------------------------------------- * |
---|
6 | * This program is free software; you can redistribute it and/or modify it * |
---|
7 | * under the terms of the GNU General Public License as published by the * |
---|
8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
9 | * option) any later version. * |
---|
10 | \**************************************************************************/ |
---|
11 | |
---|
12 | require_once '../../header.session.inc.php'; |
---|
13 | // This script upload an CSV file to import contacts .... |
---|
14 | if(array_key_exists('import_file', $_FILES) && $ftmp = $_FILES['import_file']['tmp_name']){ |
---|
15 | // Foi necessário modificar o caminho onde se recuperava o diretório temporário. |
---|
16 | // Esse caminho foi hardcodificado na string abaixo ( /tmp ) temporariamente, mas deve ser recuperada atraves |
---|
17 | // da configuracao do Expresso. Ver ticket #385. |
---|
18 | $fname = "/tmp/contacts_".md5(microtime()).".swp"; |
---|
19 | if(move_uploaded_file($ftmp, $fname)) |
---|
20 | $_SESSION['contactcenter']['importCSV'] = $fname; |
---|
21 | } |
---|
22 | // ... or download an CSVfile to export contacts. |
---|
23 | else if($_GET['file_name']) { |
---|
24 | $file_name = $_GET['file_name']; |
---|
25 | $file_path = $_GET['file_path']; |
---|
26 | header("Pragma: public"); |
---|
27 | header ("Content-Type: application/octet-stream"); |
---|
28 | header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
29 | header('Content-Length: ' . filesize($file_path)); |
---|
30 | header("Content-disposition: attachment; filename=".$file_name); |
---|
31 | readfile($file_path); |
---|
32 | unlink($file_path); |
---|
33 | } |
---|
34 | ?> |
---|