-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage.php
166 lines (134 loc) · 6.14 KB
/
page.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
require_once("./php/htmlHelper.php");
require_once("./php/generalHelper.php");
require_once("./php/sql.php");
$pdo = getpdo();
$ID = $_GET["id"];
$req = $pdo->prepare("SELECT * FROM ultraverse.pages where id = :id;");
$req->execute([":id" => $ID]);
$Page = $req->fetch();
if (!$Page) {
http_response_code(404);
echo render_php('404.php');
die();
}
if($_SERVER["REQUEST_METHOD"] == "POST") {
$req = $pdo->prepare("SELECT UID FROM ultraverse.user_pages where PID = :id AND UID = :uid;");
$req->execute([":id" => $ID, ":uid" => GetID()]);
var_dump($req->rowCount());
if ($req->rowCount() < 1) {
http_response_code(403);
die();
}
switch ($_GET["type"]) {
case "avatar":
$uploaddir = $_SERVER['DOCUMENT_ROOT']."/pageAvatars/".$ID.".png";
break;
case "banner":
$uploaddir = $_SERVER['DOCUMENT_ROOT']."/pageBanners/".$ID.".png";
break;
default:
http_response_code(400);
var_dump($_GET);
die();
break;
}
if(file_exists($uploaddir)) {
unlink($uploaddir);
}
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir)) {
http_response_code(302);
header("Refresh:0");
}
die();
}
GenerateHeader("../../pbanners/".$ID, "Page", 200);
?>
<div class="ui container">
<div class="profile-bg" style="background-image: url('/pbanners/<?= $ID ?>');">
<div class="overlay"></div>
<div class="profile">
<div class="profile-data">
<div class="cat">
<div class="rank">
</div>
<div class="stats">
<h1 class="username"><?= $Page["name"] ?></h1>
<h1 style="margin: 0;color: #ffc700;text-shadow: 0 0 6px black;">Ultraverse Page</h1>
<h3 style="margin: 0;color: #fff;text-shadow: 0 0 6px black;"> <?= $Page["description"] ?></h1>
</div>
</div>
</div>
<div class="p-avatar">
<img height="256" alt="avatar" src="/pavatars/<?= $ID ?>">
</div>
</div>
</div>
<div class="profile-segment">
<div class="left-panel">
</div>
<div class="right-panel">
<div class="ui raised segment">
<?php
$req = $pdo->prepare("SELECT UID FROM ultraverse.user_pages where PID = :id;");
$req->execute([":id" => $ID]);
$ids = $req->fetchAll();
foreach ($ids as $id) {
?>
<a href="/users/<?= $id["UID"] ?>">
<div class="hoverable tab">
<div class="label" style="box-shadow: 0 0 5px 1px #6500ff;background: #6500ff;position: relative;">
<h3><img src="/avatars/<?= $id["UID"] ?>"><?= GetUserData($id["UID"])['username'] ?></h3>
</div>
</div>
</a>
<?php } ?>
<a href="#" onclick="AddAdmin()">
<form id="userAdd" method="post" style="display:none" action="/pages/<?= $ID ?>?type=user" enctype="multipart/form-data" >
<input type="text" id="addUser" required name="newUser">
</form>
<label style="display:block" class="hoverable tab">
<div class="label" style="box-shadow: 0 0 5px 1px #6500ff;background: #6500ff;position: relative;">
<h3><i class="circular plus icon"></i>Add User</h3>
</div>
</label>
</a>
<div class="ui divider"></div>
<?php
$req = $pdo->prepare("SELECT UID FROM ultraverse.user_pages where PID = :id AND UID = :uid;");
$req->execute([":id" => $ID, ":uid" => GetID()]);
if ($req->rowCount() == 1) {
?>
<a href="#" onclick="$('#file-avatar').trigger('click')">
<form id="avatar-change" method="post" style="display:none" action="/pages/<?= $ID ?>?type=avatar" enctype="multipart/form-data" >
<input type="file" id="file-avatar" required accept="image/*" name="file" onchange="$('#avatar-change').submit()">
</form>
<label style="display:block" for="file-avatar" class="hoverable tab">
<div class="label" style="box-shadow: 0 0 5px 1px #6500ff;background: #6500ff;position: relative;">
<h3><i class="circular image icon"></i>Change Avatar</h3>
</div>
</label>
</a>
<a href="#" onclick="$('#file-banner').trigger('click')">
<form id="banner-change" method="post" style="display:none" action="/pages/<?= $ID ?>?type=banner" enctype="multipart/form-data" >
<input type="file" id="file-banner" required accept="image/*" name="file" onchange="$('#banner-change').submit()">
</form>
<label style="display:block" for="file-banner" class="hoverable tab">
<div class="label" style="box-shadow: 0 0 5px 1px #6500ff;background: #6500ff;position: relative;">
<h3><i class="circular image icon"></i>Change Banner</h3>
</div>
</label>
</a>
<?php } ?>
</div>
</div>
</div>
<script>
function AddAdmin() {
$username = prompt("Input");
if ($username != null) {
$("addUser")
}
}
</script>
<?php GenerateFooter(); ?>