download.php 1.08 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
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");

25
$error = '';
Carsten  Rose's avatar
Carsten Rose committed
26
27

try {
Carsten  Rose's avatar
Carsten Rose committed
28
    try {
29
        $download = new Download();
Carsten  Rose's avatar
Carsten Rose committed
30

31
32
        // If all is fine: process() will output file via print() !!
        $error = $download->process(STORE_SIP, OUTPUT_MODE_DIRECT);
33

Carsten  Rose's avatar
Carsten Rose committed
34
    } catch (qfq\CodeException $e) {
35
        $error = $e->formatMessage();
Carsten  Rose's avatar
Carsten Rose committed
36
    } catch (qfq\DbException $e) {
37
        $error = $e->formatMessage();
Carsten  Rose's avatar
Carsten Rose committed
38
    } catch (qfq\DownloadException $e) {
39
        $error = $e->formatMessage();
Carsten  Rose's avatar
Carsten Rose committed
40
    }
Carsten  Rose's avatar
Carsten Rose committed
41
} catch (\Exception $e) {
42
    $error = "Exception: " . $e->getMessage();
Carsten  Rose's avatar
Carsten Rose committed
43
44
}

45
echo $error;