download.php 1.12 KB
Newer Older
Carsten  Rose's avatar
Carsten Rose committed
1
2
3
4
5
6
<?php
/**
 * Created by PhpStorm.
 * User: crose
 * Date: 4/17/17
 * Time: 5:51 PM
Carsten  Rose's avatar
Carsten Rose committed
7
8
 *
 * Check: CODING.md > Download
Carsten  Rose's avatar
Carsten Rose committed
9
10
11
12
13
14
15
16
 */

namespace qfq;

use qfq;

require_once(__DIR__ . '/../qfq/report/Download.php');
require_once(__DIR__ . '/../qfq/Constants.php');
Carsten  Rose's avatar
Carsten Rose committed
17
18
19
20
21
22
23
24
25
require_once(__DIR__ . '/../qfq/exceptions/DownloadException.php');
require_once(__DIR__ . '/../qfq/exceptions/CodeException.php');
require_once(__DIR__ . '/../qfq/exceptions/DbException.php');
require_once(__DIR__ . '/../qfq/exceptions/ErrorHandler.php');


set_error_handler("\\qfq\\ErrorHandler::exception_error_handler");

$data = '';
Carsten  Rose's avatar
Carsten Rose committed
26
27

try {
Carsten  Rose's avatar
Carsten Rose committed
28
29
30
31
32
33
34
35
36
37
38
39
40
    try {
        $download = new \qfq\Download();

        // If all is fine - 'process()' never returns! The output file is delivered and PHP is stopped after that.
        $data = $download->process(STORE_SIP, OUTPUT_MODE_DIRECT);

    } catch (qfq\CodeException $e) {
        $data = $e->formatMessage();
    } catch (qfq\DbException $e) {
        $data = $e->formatMessage();
    } catch (qfq\DownloadException $e) {
        $data = $e->formatMessage();
    }
Carsten  Rose's avatar
Carsten Rose committed
41
42
43
44
45
} catch (\Exception $e) {
    $data = "Exception: " . $e->getMessage();
}

echo $data;