summaryrefslogtreecommitdiffstats
path: root/apis/download.inc.php
blob: 9ba0f0085034be5be3929fc05a764f00647a9e4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

User::load();

if (!User::hasPermission('superadmin')) die('No permission');
if (!isset($_REQUEST['type'])) die('No type');
if (!isset($_REQUEST['file'])) die('No file');
if (!isset($_REQUEST['id'])) die('No id');

require_once('inc/render.inc.php');

$type = $_REQUEST['type'];
$file = preg_replace('/[^a-z0-9\.\-_]/is', '', $_REQUEST['file']);
$id = $_REQUEST['id'];

switch ($type) {
case 'tgz':
	$remote = CONFIG_REMOTE_TGZ;
	$local = CONFIG_TGZ_LIST_DIR;
	break;
default:
	die('Invalid download type');
}

if (file_exists($local . '/' . $file) && !isset($_REQUEST['exec'])) {
	echo 'FILE EXISTS LOCALLY I SHOULD ASK FOR OVERWRITE NOW';
	exit(0);
}

sleep(2);

// No execution - just return dialog
echo Render::parse('download-complete', array('file' => $file));