-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathallFiles.php
executable file
·126 lines (126 loc) · 4.28 KB
/
allFiles.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
session_start();
require_once 'Mobile_Detect.php';
include './usergroups.php';
$detect = new Mobile_Detect;
if (empty($_SESSION[$RootSession])) {
$_SESSION[$RootSession] = false;
}
$session = $_SESSION[$RootSession];
if ($session === true) {
$availableIdentifiers = array();
// Get identifiers
if (is_dir("all_packages"))
{
if (file_exists("all_packages/info.txt")) {
unlink("all_packages/info.txt");
}
if ($handle = opendir("all_packages"))
{
//Notice the parentheses I added:
while(($file = readdir($handle)) !== FALSE)
{
$temp = explode( '.', $file );
$ext = array_pop( $temp );
$name = implode( '.', $temp );
// Remove .json
$availableIdentifiers[] = $name;
}
closedir($handle);
}
}
if (!isset($_POST['submitted'])) {
// Alphabetically sort the identifiers
sort($availableIdentifiers);
// remove first useless values (. and ..)
unset($availableIdentifiers[0]);
unset($availableIdentifiers[1]);
$form = "<form action='' method='post'>
<input type='hidden' name='submitted'>
Identifier: <input type='text' name='identifier'><br>
<input type='submit' value='Search'>";
if( $detect->isiOS() ){ ?>
<!DOCTYPE html>
<html>
<head>
<link href="ios7css.css" rel="stylesheet">
<meta content="width=device-width, user-scalable=no" name="viewport">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"><title>All Packages</title></head><body>
<!-- <ul><li><p>Hello, <?php // echo $_SERVER["HTTP_X_MACHINE"]; ?>!</p></li></ul> -->
<header><h1>All Packages</h1></header>
<h2>What already exists</h2>
<ul><li><p><?php
echo "<ul>";
foreach ($availableIdentifiers as $ident) {
echo "<li>".$ident."</li>";
}
echo "</ul>";
?></li></p></ul><br><br>
<h2>Search for one</h2>
<ul><li><p><form action='' method='post'>
<input type='hidden' name='submitted'>
Identifier: <input type='text' name='identifier' autocapitalize="off"><br>
<input type='submit' value='Search'>
</form></p></li></ul>
</body>
</html>
<?php } else {
echo "<ul>";
foreach ($availableIdentifiers as $ident) {
echo "<li>".$ident."</li>";
}
echo "</ul>"; ?>
<br><br>
<form action='' method='post'>
<input type='hidden' name='submitted'>
Identifier: <input type='text' name='identifier'><br>
<input type='submit' value='Search'>
<?php }
} else {
$identifier = $_POST['identifier'];
if (in_array($identifier,$availableIdentifiers)) {
$link1 = $CurrentDirectory . "ChangeFile.php?identifier=";
$finallink2 = $link1 . $identifier;
if( $detect->isiOS() ){ ?>
<!DOCTYPE html>
<html>
<head>
<link href="ios7css.css" rel="stylesheet">
<meta content="width=device-width, user-scalable=no" name="viewport">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"><title>All Packages</title></head><body>
<!-- <ul><li><p>Hello, <?php // echo $_SERVER["HTTP_X_MACHINE"]; ?>!</p></li></ul> -->
<header><h1>All Packages</h1></header>
<h2>Package Search Result</h2>
<ul><li><p><?php echo "Visit </p><a href='$finallink2'>$finallink2</a><p> to see everything about this package and be able to make changes to it.<br><br>";
echo "</p><a href='javascript:window.history.back()'>Go back</a>"; ?></ul><br><br>
</body>
</html>
<?php } else {
echo "Visit <a href='$finallink2'>$finallink2</a> to see everything about this package and be able to make changes to it.<br><br>";
echo "<a href='javascript:window.history.back()'>Go back</a>";
}
} else {
if( $detect->isiOS() ){ ?>
<!DOCTYPE html>
<html>
<head>
<link href="ios7css.css" rel="stylesheet">
<meta content="width=device-width, user-scalable=no" name="viewport">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"><title>All Packages</title></head><body>
<!-- <ul><li><p>Hello, <?php // echo $_SERVER["HTTP_X_MACHINE"]; ?>!</p></li></ul> -->
<header><h1>All Packages</h1></header>
<h2>Package Search Result</h2>
<ul><li><p><?php echo "Could not find identifier!<br>";
echo "</p><a href='javascript:window.history.back()'>Go back</a>"; ?></ul><br><br>
</body>
</html>
<?php } else {
echo "Could not find identifier!<br>";
echo "<a href='javascript:window.history.back()'>Go back</a>";
}
}
}
} else {
$authurl = $CurrentDirectory . "auth.php";
header("Location: $authurl");
} ?>