This repository was archived by the owner on Jan 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
71 lines (53 loc) · 1.69 KB
/
Copy pathindex.php
File metadata and controls
71 lines (53 loc) · 1.69 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
require 'Slim/Slim.php';
require 'lib/phpQuery.php';
require 'utils.php';
$app = new Slim(array(
'mode' => 'development',
));
error_reporting(E_ALL & ~E_NOTICE);
function g1() {
Slim::getInstance()->render('index.php', array(
'increase' => "1",
'start' => "1",
'limit' => "0",
'format' => "",
'selector' => "",
'minEntryLength' => "0",
));
}
$app->get('/', "g1");
function p1() {
$format = $_POST['format'];
$selector = $_POST['selector'];
$increase = $_POST['increase'];
$start = $_POST['start'];
$limit = $_POST['limit'];
$minEntryLength = $_POST['min_entry_length'];
$entries = fetchEntries($format, $selector, $increase, $start, $limit, $minEntryLength);
$templateData = array(
'entries' => $entries,
'increase' => $increase,
'start' => $start,
'limit' => $limit,
'format' => htmlentities($format),
'selector' => htmlentities($selector),
'minEntryLength' => $minEntryLength,
);
if ($_POST['output'] == "sqlite") {
$tmpFile = saveEntriesToSqlite($entries);
$templateData['downloadId'] = substr(basename($tmpFile), strlen(SCRAPPR_PREFIX));
}
Slim::getInstance()->render('index.php', $templateData);
}
$app->post('/', "p1");
function p2($id) {
$path = 'tmp/' . SCRAPPR_PREFIX . $id;
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".SCRAPPR_PREFIX.date("YmdHi").".db");
header("Content-Length: " . filesize($path));
readfile($path);
//unlink($path); //FIXME unlink won't work, because readfile keeps file handle
}
$app->get('/download/:id', 'p2');
$app->run();