-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget.php
More file actions
51 lines (51 loc) · 2.04 KB
/
get.php
File metadata and controls
51 lines (51 loc) · 2.04 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
<?php
include ("config.php");
$db=new SQLite3($db_file);
if (isset($_GET['file'])) {
$result=$db->query("select link, downloads from links where hidden=0 and file='".SQLite3::escapeString($_GET['file'])."'");
if ($row = $result->fetchArray(SQLITE3_NUM)){
$downloads=intval($row[1])+1;
$db->exec("update links set downloads=".strval($downloads)." where file='".SQLite3::escapeString($_GET['file'])."'");
header('Location:'.$row[0]);
}else{
die("Link not found.");
}
$result->finalize();
} else If (isset($_GET['addonslist'])) {
$addons=array();
$result=$db->query("select * from addons where hidden=0");
while ($row=$result->fetchArray(SQLITE3_ASSOC)){
$row["links"]=array();
// If you run into problems with the line below, try opening the database file and running: "alter table links add modified text;"
$result2=$db->query("select file, version, channel, minimum, lasttested, link, downloads, modified from links where id=".$row['id']);
while ($link=$result2->fetchArray(SQLITE3_ASSOC)){
$row['links'][]=$link;
}
$result2->finalize();
$addons[]=$row;
}
$result->finalize();
echo json_encode($addons);
}else{
session_name($session_name);
session_start();
include("header.php");
set_title("List of download links");
?>
<p>This page displays download links for all the add-ons registered on the system, so you can easily copy and share them.</p>
<?php
$result=$db->query("select id, summary from addons where hidden=0 order by id desc");
while ($row=$result->fetchArray(SQLITE3_ASSOC)){
echo "<h2>".$row['summary']."</h2>";
$result2=$db->query("select file, version, channel, downloads from links where id=".$row['id']);
while ($link=$result2->fetchArray(SQLITE3_ASSOC)){
echo "<h3>Channel ".$link['channel'].", version ".$link['version'].", downloaded ".$link['downloads']." times</h3>";
echo "<p><a href='get.php?file=".$link['file']."'>".$baseURL."get.php?file=".$link['file']."</a></p>";
}
$result2->finalize();
}
$result->finalize();
include("footer.php");
}
$db->close();
?>