-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
67 lines (65 loc) · 1.83 KB
/
index.php
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
<?php
require_once "config.php";
$con=mysqli_connect($sql_server, $sql_user, $sql_pass, $sql_database);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM packages");
$path = "http://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER["SCRIPT_NAME"]);
if ($_GET["op"]=="json")
{
$counter = 0;
$outer = array();
while($row = mysqli_fetch_assoc($result))
{
if (count(glob($row["name"].".*")) > 0)
{
$entry = array();
$entry["name"] = $row["name"];
$entry["version"] = $row["version"];
$entry["description"] = $row["description"];
$entry["author"] = $row["author"];
$fileName = glob($row["name"] . ".dat");
$entry["url"] = $path . "/" . $fileName[0];
$entry["extension"] = $row["extension"];
$outer[$counter] = $entry;
$counter++;
}
}
echo json_encode($outer);
}else{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Mudlet repository listing</title>
</head>
<body>
To upload new packages or manage your packages, please <a href="<?php echo $path."/login.php"; ?>">log in</a> or <a href="register.php">register</a><br/>
<br/>
<table>
<tr><td>Package name</td><td>Version</td><td>Description</td><td>Author</td></tr>
<?php
while($row = mysqli_fetch_array($result))
{
?>
<tr>
<?php
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['version'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['author'] . "</td>";
?>
</tr>
<?php
}
?>
</table>
</body>
</html>
<?php
}
?>