@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | <?php $__db_h = new db_helper(); ?> |
10 | 10 | <?php $__time_h = new time_helper(); ?> |
11 | 11 | <?php |
12 | - if($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['password'] && $_POST['username']) { |
|
12 | + if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['password'] && $_POST['username']) { |
|
13 | 13 | $request = (object) [ |
14 | 14 | "username" => $_POST['username'], |
15 | 15 | "password" => $_POST['password'], |
@@ -28,19 +28,19 @@ discard block |
||
28 | 28 | $stmt->bindParam(":username", $request->username); |
29 | 29 | $stmt->execute(); |
30 | 30 | |
31 | - if(!$stmt->rowCount()){ |
|
31 | + if (!$stmt->rowCount()) { |
|
32 | 32 | { $request->error->message = "Incorrect username or password!"; $request->error->status = ""; } } |
33 | 33 | |
34 | 34 | $row = $stmt->fetch(PDO::FETCH_ASSOC); |
35 | - if(!isset($row['password'])) |
|
35 | + if (!isset($row['password'])) |
|
36 | 36 | { $request->error->message = "Incorrect username or password!"; $request->error->status = ""; } |
37 | 37 | else |
38 | 38 | { $request->returned_password = $row['password']; } |
39 | 39 | |
40 | - if(!password_verify($request->password, $request->returned_password)) |
|
40 | + if (!password_verify($request->password, $request->returned_password)) |
|
41 | 41 | { $request->error->message = "Incorrect username or password!"; $request->error->status = ""; } |
42 | 42 | |
43 | - if($request->error->status == "OK") { |
|
43 | + if ($request->error->status == "OK") { |
|
44 | 44 | $_SESSION['siteusername'] = $request->username; |
45 | 45 | header("Location: /"); |
46 | 46 | } |
@@ -33,8 +33,7 @@ |
||
33 | 33 | |
34 | 34 | $row = $stmt->fetch(PDO::FETCH_ASSOC); |
35 | 35 | if(!isset($row['password'])) |
36 | - { $request->error->message = "Incorrect username or password!"; $request->error->status = ""; } |
|
37 | - else |
|
36 | + { $request->error->message = "Incorrect username or password!"; $request->error->status = ""; } else |
|
38 | 37 | { $request->returned_password = $row['password']; } |
39 | 38 | |
40 | 39 | if(!password_verify($request->password, $request->returned_password)) |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | <?php $__db_h = new db_helper(); ?> |
10 | 10 | <?php $__time_h = new time_helper(); ?> |
11 | 11 | <?php |
12 | - if($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['password'] && $_POST['username']) { |
|
12 | + if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['password'] && $_POST['username']) { |
|
13 | 13 | $request = (object) [ |
14 | 14 | "username" => $_POST['username'], |
15 | 15 | "password" => $_POST['password'], |
@@ -23,27 +23,27 @@ discard block |
||
23 | 23 | ]; |
24 | 24 | |
25 | 25 | if (!filter_var($request->email, FILTER_VALIDATE_EMAIL)) |
26 | - { $request->error->message = "Your email is invalid!"; $request->error->status = ""; } |
|
27 | - if(strlen($request->username) > 21) |
|
26 | + { $request->error->message = "Your email is invalid!"; $request->error->status = ""; } |
|
27 | + if (strlen($request->username) > 21) |
|
28 | 28 | { $request->error->message = "Your username must be shorter than 21 characters."; $request->error->status = ""; } |
29 | - if(strlen($request->password) < 8) |
|
29 | + if (strlen($request->password) < 8) |
|
30 | 30 | { $request->error->message = "Your password must at least be 8 characters long."; $request->error->status = ""; } |
31 | - if(!preg_match('/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/', $request->password)) |
|
31 | + if (!preg_match('/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/', $request->password)) |
|
32 | 32 | { $request->error->message = "Include numbers and letters in your password!"; $request->error->status = ""; } |
33 | - if(!preg_match('/^\S+\w\S{1,}/', $request->username)) |
|
33 | + if (!preg_match('/^\S+\w\S{1,}/', $request->username)) |
|
34 | 34 | { $request->error->message = "Your username cannot contain any special characters!"; $request->error->status = ""; } |
35 | - if(empty(trim($request->username))) |
|
35 | + if (empty(trim($request->username))) |
|
36 | 36 | { $request->error->message = "Your username cannot be empty!"; $request->error->status = ""; } |
37 | 37 | |
38 | 38 | $stmt = $__db->prepare("SELECT username FROM users WHERE username = :username"); |
39 | 39 | $stmt->bindParam(":username", $username); |
40 | 40 | $stmt->execute(); |
41 | - if($stmt->rowCount()) |
|
41 | + if ($stmt->rowCount()) |
|
42 | 42 | { $request->error->message = "There's already a user with that same username!"; $request->error->status = ""; } |
43 | 43 | |
44 | 44 | echo json_encode($request->error); |
45 | 45 | |
46 | - if($request->error->status == "OK") { |
|
46 | + if ($request->error->status == "OK") { |
|
47 | 47 | $stmt = $__db->prepare("INSERT INTO users (username, email, password) VALUES (:username, :email, :password)"); |
48 | 48 | $stmt->bindParam(":username", $request->username); |
49 | 49 | $stmt->bindParam(":email", $request->email); |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | $stmt->execute(); |
36 | 36 | |
37 | 37 | |
38 | - if($_SERVER['REQUEST_METHOD'] == 'POST' && @$_FILES['pfpset']) { |
|
39 | - if(!empty($_FILES["pfpset"]["name"])) { |
|
38 | + if ($_SERVER['REQUEST_METHOD'] == 'POST' && @$_FILES['pfpset']) { |
|
39 | + if (!empty($_FILES["pfpset"]["name"])) { |
|
40 | 40 | $target_dir = "../pfp/"; |
41 | 41 | $imageFileType = strtolower(pathinfo($_FILES["pfpset"]["name"], PATHINFO_EXTENSION)); |
42 | 42 | $target_name = md5_file($_FILES["pfpset"]["tmp_name"]) . "." . $imageFileType; |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | $uploadOk = true; |
47 | 47 | $movedFile = false; |
48 | 48 | |
49 | - if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" |
|
50 | - && $imageFileType != "gif" ) { |
|
49 | + if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" |
|
50 | + && $imageFileType != "gif") { |
|
51 | 51 | $fileerror = 'unsupported file type. must be jpg, png, jpeg, or gif'; |
52 | 52 | $uploadOk = false; |
53 | 53 | goto skip; |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
73 | - } else if($_SERVER['REQUEST_METHOD'] == 'POST' && @$_FILES['backgroundbgset']) { |
|
74 | - if(!empty($_FILES["backgroundbgset"]["name"])) { |
|
73 | + } else if ($_SERVER['REQUEST_METHOD'] == 'POST' && @$_FILES['backgroundbgset']) { |
|
74 | + if (!empty($_FILES["backgroundbgset"]["name"])) { |
|
75 | 75 | $target_dir = "../banners/"; |
76 | 76 | $imageFileType = strtolower(pathinfo($_FILES["backgroundbgset"]["name"], PATHINFO_EXTENSION)); |
77 | 77 | $target_name = md5_file($_FILES["backgroundbgset"]["tmp_name"]) . "." . $imageFileType; |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | $uploadOk = true; |
82 | 82 | $movedFile = false; |
83 | 83 | |
84 | - if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" |
|
85 | - && $imageFileType != "gif" ) { |
|
84 | + if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" |
|
85 | + && $imageFileType != "gif") { |
|
86 | 86 | $fileerror = 'unsupported file type. must be jpg, png, jpeg, or gif'; |
87 | 87 | $uploadOk = false; |
88 | 88 | goto skip; |
89 | 89 | } |
90 | 90 | |
91 | - if($uploadOk) { |
|
91 | + if ($uploadOk) { |
|
92 | 92 | if (file_exists($target_file)) { |
93 | 93 | $movedFile = true; |
94 | 94 | } else { |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | - } else if($_SERVER['REQUEST_METHOD'] == 'POST' && @$_POST['bannerset']) { |
|
108 | - if(!empty($_FILES["file"]["name"])) { |
|
107 | + } else if ($_SERVER['REQUEST_METHOD'] == 'POST' && @$_POST['bannerset']) { |
|
108 | + if (!empty($_FILES["file"]["name"])) { |
|
109 | 109 | $target_dir = "../banners/"; |
110 | 110 | $imageFileType = strtolower(pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION)); |
111 | 111 | $target_name = md5_file($_FILES["file"]["tmp_name"]) . "." . $imageFileType; |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | $uploadOk = true; |
116 | 116 | $movedFile = false; |
117 | 117 | |
118 | - if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" |
|
119 | - && $imageFileType != "gif" ) { |
|
118 | + if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" |
|
119 | + && $imageFileType != "gif") { |
|
120 | 120 | $fileerror = 'unsupported file type. must be jpg, png, jpeg, or gif'; |
121 | 121 | $uploadOk = false; |
122 | 122 | goto skip; |
123 | 123 | } |
124 | 124 | |
125 | - if($uploadOk) { |
|
125 | + if ($uploadOk) { |
|
126 | 126 | if (file_exists($target_file)) { |
127 | 127 | $movedFile = true; |
128 | 128 | } else { |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | } |
139 | 139 | } |
140 | 140 | } |
141 | - } else if($_SERVER['REQUEST_METHOD'] == 'POST' && @$_FILES['videopagebanner']) { |
|
142 | - if(!empty($_FILES["videopagebanner"]["name"])) { |
|
141 | + } else if ($_SERVER['REQUEST_METHOD'] == 'POST' && @$_FILES['videopagebanner']) { |
|
142 | + if (!empty($_FILES["videopagebanner"]["name"])) { |
|
143 | 143 | $target_dir = "../subscribe/"; |
144 | 144 | $imageFileType = strtolower(pathinfo($_FILES["videopagebanner"]["name"], PATHINFO_EXTENSION)); |
145 | 145 | $target_name = md5_file($_FILES["videopagebanner"]["tmp_name"]) . "." . $imageFileType; |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | $uploadOk = true; |
150 | 150 | $movedFile = false; |
151 | 151 | |
152 | - if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" |
|
153 | - && $imageFileType != "gif" ) { |
|
152 | + if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" |
|
153 | + && $imageFileType != "gif") { |
|
154 | 154 | $fileerror = 'unsupported file type. must be jpg, png, jpeg, or gif'; |
155 | 155 | $uploadOk = false; |
156 | 156 | goto skip; |
157 | 157 | } |
158 | 158 | |
159 | - if($uploadOk) { |
|
159 | + if ($uploadOk) { |
|
160 | 160 | if (file_exists($target_file)) { |
161 | 161 | $movedFile = true; |
162 | 162 | } else { |
@@ -174,75 +174,75 @@ discard block |
||
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | - if(!empty($_POST['bio'])) { |
|
177 | + if (!empty($_POST['bio'])) { |
|
178 | 178 | $__user_u->update_row($_SESSION['siteusername'], "bio", $_POST['bio']); |
179 | 179 | } |
180 | 180 | |
181 | - if(!empty($_POST['videoid'])) { |
|
181 | + if (!empty($_POST['videoid'])) { |
|
182 | 182 | $__user_u->update_row($_SESSION['siteusername'], "featured_channels", $_POST['videoid']); |
183 | 183 | } // duplicate? |
184 | 184 | |
185 | - if(!empty($_POST['css'])) { |
|
185 | + if (!empty($_POST['css'])) { |
|
186 | 186 | $__user_u->update_row($_SESSION['siteusername'], "css", $_POST['css']); |
187 | 187 | } |
188 | 188 | |
189 | - if(!empty($_POST['videoid'])) { |
|
189 | + if (!empty($_POST['videoid'])) { |
|
190 | 190 | $__user_u->update_row($_SESSION['siteusername'], "featured", $_POST['videoid']); |
191 | 191 | } |
192 | 192 | |
193 | - if(!empty($_POST['solidcolor'])) { |
|
193 | + if (!empty($_POST['solidcolor'])) { |
|
194 | 194 | $__user_u->update_row($_SESSION['siteusername'], "primary_color", $_POST['solidcolor']); |
195 | 195 | } |
196 | 196 | |
197 | - if(!empty($_POST['transparency'])) { |
|
197 | + if (!empty($_POST['transparency'])) { |
|
198 | 198 | $__user_u->update_row($_SESSION['siteusername'], "transparency", $_POST['transparency']); |
199 | 199 | } |
200 | 200 | |
201 | - if(!empty($_POST['genre'])) { |
|
201 | + if (!empty($_POST['genre'])) { |
|
202 | 202 | $__user_u->update_row($_SESSION['siteusername'], "genre", $_POST['genre']); |
203 | 203 | } |
204 | 204 | |
205 | - if(!empty($_POST['bordercolor'])) { |
|
205 | + if (!empty($_POST['bordercolor'])) { |
|
206 | 206 | $__user_u->update_row($_SESSION['siteusername'], "border_color", $_POST['bordercolor']); |
207 | 207 | } |
208 | 208 | |
209 | - if(!empty($_POST['country'])) { |
|
209 | + if (!empty($_POST['country'])) { |
|
210 | 210 | $__user_u->update_row($_SESSION['siteusername'], "country", $_POST['country']); |
211 | 211 | } // duplicate? |
212 | 212 | |
213 | - if(!empty($_POST['header'])) { |
|
213 | + if (!empty($_POST['header'])) { |
|
214 | 214 | $__user_u->update_row($_SESSION['siteusername'], "custom_header", $_POST['header']); |
215 | 215 | } |
216 | 216 | |
217 | - if(!empty($_POST['channels'])) { |
|
217 | + if (!empty($_POST['channels'])) { |
|
218 | 218 | $__user_u->update_row($_SESSION['siteusername'], "featured_channels", $_POST['channels']); |
219 | 219 | } // duplicate? |
220 | 220 | |
221 | - if(!empty($_POST['customtext'])) { |
|
221 | + if (!empty($_POST['customtext'])) { |
|
222 | 222 | $__user_u->update_row($_SESSION['siteusername'], "custom_text", $_POST['customtext']); |
223 | 223 | } |
224 | 224 | |
225 | - if(!empty($_POST['country'])) { |
|
225 | + if (!empty($_POST['country'])) { |
|
226 | 226 | $__user_u->update_row($_SESSION['siteusername'], "custom_text", $_POST['country']); |
227 | 227 | } // duplicate? |
228 | 228 | |
229 | - if(!empty($_POST['website'])) { |
|
229 | + if (!empty($_POST['website'])) { |
|
230 | 230 | $__user_u->update_row($_SESSION['siteusername'], "website", $_POST['website']); |
231 | 231 | } |
232 | 232 | |
233 | - if(!empty($_POST['channelboxcolor'])) { |
|
233 | + if (!empty($_POST['channelboxcolor'])) { |
|
234 | 234 | $__user_u->update_row($_SESSION['siteusername'], "secondary_color", $_POST['channelboxcolor']); |
235 | 235 | } |
236 | 236 | |
237 | - if(!empty($_POST['backgroundcolor'])) { |
|
237 | + if (!empty($_POST['backgroundcolor'])) { |
|
238 | 238 | $__user_u->update_row($_SESSION['siteusername'], "third_color", $_POST['backgroundcolor']); |
239 | 239 | } |
240 | 240 | |
241 | - if(!empty($_POST['textmaincolor'])) { |
|
241 | + if (!empty($_POST['textmaincolor'])) { |
|
242 | 242 | $__user_u->update_row($_SESSION['siteusername'], "primary_color_text", $_POST['textmaincolor']); |
243 | 243 | } |
244 | 244 | |
245 | - if(!empty($_POST['bgoptionset'])) { |
|
245 | + if (!empty($_POST['bgoptionset'])) { |
|
246 | 246 | $bgoption = $_POST['bgoption']; |
247 | 247 | $bgcolor = $_POST['solidcolor']; |
248 | 248 | $default = "default.png"; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | $__user_u->update_row($_SESSION['siteusername'], "2009_bgcolor", $bgcolor); |
253 | 253 | |
254 | - if($bgoption == "solid") { |
|
254 | + if ($bgoption == "solid") { |
|
255 | 255 | $__user_u->update_row($_SESSION['siteusername'], "2009_bg", $default); |
256 | 256 | } |
257 | 257 | } |
@@ -10,9 +10,9 @@ |
||
10 | 10 | class user_insert { |
11 | 11 | public $__db; |
12 | 12 | |
13 | - public function __construct($conn){ |
|
13 | + public function __construct($conn){ |
|
14 | 14 | $this->__db = $conn; |
15 | - } |
|
15 | + } |
|
16 | 16 | |
17 | 17 | function check_view_channel($vidid, $user) { |
18 | 18 | $stmt = $this->__db->prepare("SELECT * FROM channel_views WHERE viewer = :user AND channel = :vidid"); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | class user_insert { |
11 | 11 | public $__db; |
12 | 12 | |
13 | - public function __construct($conn){ |
|
13 | + public function __construct($conn) { |
|
14 | 14 | $this->__db = $conn; |
15 | 15 | } |
16 | 16 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $stmt->bindParam(":user", $user); |
20 | 20 | $stmt->bindParam(":vidid", $vidid); |
21 | 21 | $stmt->execute(); |
22 | - if($stmt->rowCount() === 0) { |
|
22 | + if ($stmt->rowCount() === 0) { |
|
23 | 23 | $this->add_view_channel($vidid, $user); |
24 | 24 | } |
25 | 25 | } |
@@ -10,9 +10,9 @@ |
||
10 | 10 | class user_update { |
11 | 11 | public $__db; |
12 | 12 | |
13 | - public function __construct($conn){ |
|
13 | + public function __construct($conn){ |
|
14 | 14 | $this->__db = $conn; |
15 | - } |
|
15 | + } |
|
16 | 16 | |
17 | 17 | // fuck this, this can be compressed into 2 functions |
18 | 18 |
@@ -10,20 +10,20 @@ |
||
10 | 10 | class user_update { |
11 | 11 | public $__db; |
12 | 12 | |
13 | - public function __construct($conn){ |
|
13 | + public function __construct($conn) { |
|
14 | 14 | $this->__db = $conn; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // fuck this, this can be compressed into 2 functions |
18 | 18 | |
19 | 19 | function update_cooldown_time($username, $rowName) { |
20 | - $stmt = $this->__db->prepare("UPDATE users SET ".$rowName." = now() WHERE username = :username"); |
|
20 | + $stmt = $this->__db->prepare("UPDATE users SET " . $rowName . " = now() WHERE username = :username"); |
|
21 | 21 | $stmt->bindParam(":username", $username); |
22 | 22 | $stmt->execute(); |
23 | 23 | } |
24 | 24 | |
25 | 25 | function update_row($username, $rowName, $new) { |
26 | - $stmt = $this->__db->prepare("UPDATE users SET ".$rowName." = :new WHERE username = :username"); |
|
26 | + $stmt = $this->__db->prepare("UPDATE users SET " . $rowName . " = :new WHERE username = :username"); |
|
27 | 27 | $stmt->bindParam(":new", $new); |
28 | 28 | $stmt->bindParam(":username", $username); |
29 | 29 | $stmt->execute(); |
@@ -11,9 +11,9 @@ |
||
11 | 11 | class user_helper { |
12 | 12 | public $__db; |
13 | 13 | |
14 | - public function __construct($conn){ |
|
14 | + public function __construct($conn){ |
|
15 | 15 | $this->__db = $conn; |
16 | - } |
|
16 | + } |
|
17 | 17 | |
18 | 18 | function fetch_pfp($username) { |
19 | 19 | $stmt = $this->__db->prepare("SELECT pfp FROM users WHERE username = :username") |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | class user_helper { |
12 | 12 | public $__db; |
13 | 13 | |
14 | - public function __construct($conn){ |
|
14 | + public function __construct($conn) { |
|
15 | 15 | $this->__db = $conn; |
16 | 16 | } |
17 | 17 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $stmt = $this->__db->prepare("SELECT pfp FROM users WHERE username = :username") |
20 | 20 | $stmt->bindParam(":username", $username); |
21 | 21 | $stmt->execute(); |
22 | - while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
22 | + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
23 | 23 | $pfp = $row['pfp']; |
24 | 24 | } // why the while statement? just remove it (i cant be bothered to) |
25 | 25 |
@@ -24,9 +24,9 @@ |
||
24 | 24 | shell_exec($fullcmd); |
25 | 25 | } |
26 | 26 | |
27 | - public function __construct($conn){ |
|
27 | + public function __construct($conn){ |
|
28 | 28 | $this->__db = $conn; |
29 | - } |
|
29 | + } |
|
30 | 30 | |
31 | 31 | function fetch_video_views(string $id) { |
32 | 32 | $stmt = $this->__db->prepare("SELECT * FROM views WHERE videoid = :id"); |
@@ -12,19 +12,19 @@ discard block |
||
12 | 12 | |
13 | 13 | public function sh_exec(string $cmd, string $outputfile = "", string $pidfile = "", bool $mergestderror = true, bool $bg = false) { |
14 | 14 | $fullcmd = $cmd; |
15 | - if(strlen($outputfile) > 0) $fullcmd .= " >> " . $outputfile; |
|
16 | - if($mergestderror) $fullcmd .= " 2>&1"; |
|
15 | + if (strlen($outputfile) > 0) $fullcmd .= " >> " . $outputfile; |
|
16 | + if ($mergestderror) $fullcmd .= " 2>&1"; |
|
17 | 17 | |
18 | - if($bg) { |
|
18 | + if ($bg) { |
|
19 | 19 | $fullcmd = "nohup " . $fullcmd . " &"; |
20 | - if(strlen($pidfile)) $fullcmd .= " echo $! > " . $pidfile; |
|
20 | + if (strlen($pidfile)) $fullcmd .= " echo $! > " . $pidfile; |
|
21 | 21 | } else { |
22 | - if(strlen($pidfile) > 0) $fullcmd .= "; echo $$ > " . $pidfile; |
|
22 | + if (strlen($pidfile) > 0) $fullcmd .= "; echo $$ > " . $pidfile; |
|
23 | 23 | } |
24 | 24 | shell_exec($fullcmd); |
25 | 25 | } |
26 | 26 | |
27 | - public function __construct($conn){ |
|
27 | + public function __construct($conn) { |
|
28 | 28 | $this->__db = $conn; |
29 | 29 | } |
30 | 30 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | |
47 | 47 | function shorten_description(string $description, int $limit, bool $newlines = false) { |
48 | 48 | $description = trim($description); |
49 | - if(strlen($description) >= $limit) { |
|
49 | + if (strlen($description) >= $limit) { |
|
50 | 50 | $description = substr($description, 0, $limit) . "..."; |
51 | 51 | } |
52 | 52 | |
53 | 53 | $description = htmlspecialchars($description); |
54 | - if($newlines) { $description = str_replace(PHP_EOL, "<br>", $description); } |
|
54 | + if ($newlines) { $description = str_replace(PHP_EOL, "<br>", $description); } |
|
55 | 55 | return $description; |
56 | 56 | } |
57 | 57 |
@@ -12,14 +12,22 @@ |
||
12 | 12 | |
13 | 13 | public function sh_exec(string $cmd, string $outputfile = "", string $pidfile = "", bool $mergestderror = true, bool $bg = false) { |
14 | 14 | $fullcmd = $cmd; |
15 | - if(strlen($outputfile) > 0) $fullcmd .= " >> " . $outputfile; |
|
16 | - if($mergestderror) $fullcmd .= " 2>&1"; |
|
15 | + if(strlen($outputfile) > 0) { |
|
16 | + $fullcmd .= " >> " . $outputfile; |
|
17 | + } |
|
18 | + if($mergestderror) { |
|
19 | + $fullcmd .= " 2>&1"; |
|
20 | + } |
|
17 | 21 | |
18 | 22 | if($bg) { |
19 | 23 | $fullcmd = "nohup " . $fullcmd . " &"; |
20 | - if(strlen($pidfile)) $fullcmd .= " echo $! > " . $pidfile; |
|
24 | + if(strlen($pidfile)) { |
|
25 | + $fullcmd .= " echo $! > " . $pidfile; |
|
26 | + } |
|
21 | 27 | } else { |
22 | - if(strlen($pidfile) > 0) $fullcmd .= "; echo $$ > " . $pidfile; |
|
28 | + if(strlen($pidfile) > 0) { |
|
29 | + $fullcmd .= "; echo $$ > " . $pidfile; |
|
30 | + } |
|
23 | 31 | } |
24 | 32 | shell_exec($fullcmd); |
25 | 33 | } |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | "db_connected" => false, |
22 | 22 | ], |
23 | 23 | |
24 | - "video_properties" => (object) [ "status" => "unloaded" ], |
|
25 | - "user_properties" => (object) [ "status" => "unloaded" ], |
|
26 | - "group_properties" => (object) [ "status" => "unloaded" ], |
|
27 | - "forum_properties" => (object) [ "status" => "unloaded" ], |
|
24 | + "video_properties" => (object) ["status" => "unloaded"], |
|
25 | + "user_properties" => (object) ["status" => "unloaded"], |
|
26 | + "group_properties" => (object) ["status" => "unloaded"], |
|
27 | + "forum_properties" => (object) ["status" => "unloaded"], |
|
28 | 28 | ]; |
29 | 29 | |
30 | 30 | try |
31 | 31 | { |
32 | - $__db = new PDO("mysql:host=".$__server->db_properties->db_host.";dbname=".$__server->db_properties->db_database.";charset=utf8mb4", |
|
32 | + $__db = new PDO("mysql:host=" . $__server->db_properties->db_host . ";dbname=" . $__server->db_properties->db_database . ";charset=utf8mb4", |
|
33 | 33 | $__server->db_properties->db_user, |
34 | 34 | $__server->db_properties->db_password, |
35 | 35 | [ |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ); |
40 | 40 | $__server->db_properties->db_connected = true; |
41 | 41 | } |
42 | - catch(PDOException $e) |
|
42 | + catch (PDOException $e) |
|
43 | 43 | { |
44 | 44 | $__server->db_properties->db_connected = false; |
45 | 45 | // wtf is the point of this? cant you just vomit out the error? why????????????? |
@@ -38,8 +38,7 @@ |
||
38 | 38 | ] |
39 | 39 | ); |
40 | 40 | $__server->db_properties->db_connected = true; |
41 | - } |
|
42 | - catch(PDOException $e) |
|
41 | + } catch(PDOException $e) |
|
43 | 42 | { |
44 | 43 | $__server->db_properties->db_connected = false; |
45 | 44 | // wtf is the point of this? cant you just vomit out the error? why????????????? |
@@ -138,16 +138,16 @@ discard block |
||
138 | 138 | </div> |
139 | 139 | <div class="browse-item-row ytg-box"> |
140 | 140 | <?php |
141 | - $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
|
142 | - $stmt->execute(); |
|
143 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
144 | - $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
|
145 | - $video['duration'] = $__time_h->timestamp($video['duration']); |
|
146 | - $video['views'] = $__video_h->fetch_video_views($video['rid']); |
|
147 | - $video['author'] = htmlspecialchars($video['author']); |
|
148 | - $video['title'] = htmlspecialchars($video['title']); |
|
149 | - $video['description'] = $__video_h->shorten_description($video['description'], 50); |
|
150 | - ?> |
|
141 | + $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
|
142 | + $stmt->execute(); |
|
143 | + while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
144 | + $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
|
145 | + $video['duration'] = $__time_h->timestamp($video['duration']); |
|
146 | + $video['views'] = $__video_h->fetch_video_views($video['rid']); |
|
147 | + $video['author'] = htmlspecialchars($video['author']); |
|
148 | + $video['title'] = htmlspecialchars($video['title']); |
|
149 | + $video['description'] = $__video_h->shorten_description($video['description'], 50); |
|
150 | + ?> |
|
151 | 151 | <div class="browse-item yt-tile-default "> |
152 | 152 | <a href="/watch?v=<?php echo $video['rid']; ?>" class="ux-thumb-wrap yt-uix-sessionlink yt-uix-contextlink contains-addto " data-sessionlink="ei=CPjwu5ji3bICFS4RIQod9j-M-A%3D%3D&feature=b-mv"><span class="video-thumb ux-thumb yt-thumb-default-194 "><span class="yt-thumb-clip"><span class="yt-thumb-clip-inner"><img src="http://s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="Thumbnail" data-thumb="/dynamic/thumbs/<?php echo $video['thumbnail']; ?>" width="194"><span class="vertical-align"></span></span></span></span><span class="video-time"><?php echo $video['duration']; ?></span> |
153 | 153 | <button onclick=";return false;" title="Watch Later" type="button" class="addto-button video-actions addto-watch-later-button-sign-in yt-uix-button yt-uix-button-default yt-uix-button-short yt-uix-tooltip" data-button-menu-id="shared-addto-watch-later-login" data-video-ids="rLHU-_OhT8g" role="button"><span class="yt-uix-button-content"> <img src="//s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="Watch Later"> |
@@ -173,16 +173,16 @@ discard block |
||
173 | 173 | </div> |
174 | 174 | <div class="browse-item-row ytg-box"> |
175 | 175 | <?php |
176 | - $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
|
177 | - $stmt->execute(); |
|
178 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
179 | - $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
|
180 | - $video['duration'] = $__time_h->timestamp($video['duration']); |
|
181 | - $video['views'] = $__video_h->fetch_video_views($video['rid']); |
|
182 | - $video['author'] = htmlspecialchars($video['author']); |
|
183 | - $video['title'] = htmlspecialchars($video['title']); |
|
184 | - $video['description'] = $__video_h->shorten_description($video['description'], 50); |
|
185 | - ?> |
|
176 | + $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
|
177 | + $stmt->execute(); |
|
178 | + while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
179 | + $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
|
180 | + $video['duration'] = $__time_h->timestamp($video['duration']); |
|
181 | + $video['views'] = $__video_h->fetch_video_views($video['rid']); |
|
182 | + $video['author'] = htmlspecialchars($video['author']); |
|
183 | + $video['title'] = htmlspecialchars($video['title']); |
|
184 | + $video['description'] = $__video_h->shorten_description($video['description'], 50); |
|
185 | + ?> |
|
186 | 186 | <div class="browse-item yt-tile-default "> |
187 | 187 | <a href="/watch?v=<?php echo $video['rid']; ?>" class="ux-thumb-wrap yt-uix-sessionlink yt-uix-contextlink contains-addto " data-sessionlink="ei=CPjwu5ji3bICFS4RIQod9j-M-A%3D%3D&feature=b-mv"><span class="video-thumb ux-thumb yt-thumb-default-194 "><span class="yt-thumb-clip"><span class="yt-thumb-clip-inner"><img src="http://s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="Thumbnail" data-thumb="/dynamic/thumbs/<?php echo $video['thumbnail']; ?>" width="194"><span class="vertical-align"></span></span></span></span><span class="video-time"><?php echo $video['duration']; ?></span> |
188 | 188 | <button onclick=";return false;" title="Watch Later" type="button" class="addto-button video-actions addto-watch-later-button-sign-in yt-uix-button yt-uix-button-default yt-uix-button-short yt-uix-tooltip" data-button-menu-id="shared-addto-watch-later-login" data-video-ids="rLHU-_OhT8g" role="button"><span class="yt-uix-button-content"> <img src="//s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="Watch Later"> |
@@ -208,16 +208,16 @@ discard block |
||
208 | 208 | </div> |
209 | 209 | <div class="browse-item-row ytg-box"> |
210 | 210 | <?php |
211 | - $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
|
212 | - $stmt->execute(); |
|
213 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
214 | - $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
|
215 | - $video['duration'] = $__time_h->timestamp($video['duration']); |
|
216 | - $video['views'] = $__video_h->fetch_video_views($video['rid']); |
|
217 | - $video['author'] = htmlspecialchars($video['author']); |
|
218 | - $video['title'] = htmlspecialchars($video['title']); |
|
219 | - $video['description'] = $__video_h->shorten_description($video['description'], 50); |
|
220 | - ?> |
|
211 | + $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
|
212 | + $stmt->execute(); |
|
213 | + while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
214 | + $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
|
215 | + $video['duration'] = $__time_h->timestamp($video['duration']); |
|
216 | + $video['views'] = $__video_h->fetch_video_views($video['rid']); |
|
217 | + $video['author'] = htmlspecialchars($video['author']); |
|
218 | + $video['title'] = htmlspecialchars($video['title']); |
|
219 | + $video['description'] = $__video_h->shorten_description($video['description'], 50); |
|
220 | + ?> |
|
221 | 221 | <div class="browse-item yt-tile-default "> |
222 | 222 | <a href="/watch?v=<?php echo $video['rid']; ?>" class="ux-thumb-wrap yt-uix-sessionlink yt-uix-contextlink contains-addto " data-sessionlink="ei=CPjwu5ji3bICFS4RIQod9j-M-A%3D%3D&feature=b-mv"><span class="video-thumb ux-thumb yt-thumb-default-194 "><span class="yt-thumb-clip"><span class="yt-thumb-clip-inner"><img src="http://s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="Thumbnail" data-thumb="/dynamic/thumbs/<?php echo $video['thumbnail']; ?>" width="194"><span class="vertical-align"></span></span></span></span><span class="video-time"><?php echo $video['duration']; ?></span> |
223 | 223 | <button onclick=";return false;" title="Watch Later" type="button" class="addto-button video-actions addto-watch-later-button-sign-in yt-uix-button yt-uix-button-default yt-uix-button-short yt-uix-tooltip" data-button-menu-id="shared-addto-watch-later-login" data-video-ids="rLHU-_OhT8g" role="button"><span class="yt-uix-button-content"> <img src="//s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="Watch Later"> |
@@ -243,16 +243,16 @@ discard block |
||
243 | 243 | </div> |
244 | 244 | <div class="browse-item-row ytg-box"> |
245 | 245 | <?php |
246 | - $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
|
247 | - $stmt->execute(); |
|
248 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
249 | - $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
|
250 | - $video['duration'] = $__time_h->timestamp($video['duration']); |
|
251 | - $video['views'] = $__video_h->fetch_video_views($video['rid']); |
|
252 | - $video['author'] = htmlspecialchars($video['author']); |
|
253 | - $video['title'] = htmlspecialchars($video['title']); |
|
254 | - $video['description'] = $__video_h->shorten_description($video['description'], 50); |
|
255 | - ?> |
|
246 | + $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
|
247 | + $stmt->execute(); |
|
248 | + while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
249 | + $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
|
250 | + $video['duration'] = $__time_h->timestamp($video['duration']); |
|
251 | + $video['views'] = $__video_h->fetch_video_views($video['rid']); |
|
252 | + $video['author'] = htmlspecialchars($video['author']); |
|
253 | + $video['title'] = htmlspecialchars($video['title']); |
|
254 | + $video['description'] = $__video_h->shorten_description($video['description'], 50); |
|
255 | + ?> |
|
256 | 256 | <div class="browse-item yt-tile-default "> |
257 | 257 | <a href="/watch?v=<?php echo $video['rid']; ?>" class="ux-thumb-wrap yt-uix-sessionlink yt-uix-contextlink contains-addto " data-sessionlink="ei=CPjwu5ji3bICFS4RIQod9j-M-A%3D%3D&feature=b-mv"><span class="video-thumb ux-thumb yt-thumb-default-194 "><span class="yt-thumb-clip"><span class="yt-thumb-clip-inner"><img src="http://s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="Thumbnail" data-thumb="/dynamic/thumbs/<?php echo $video['thumbnail']; ?>" width="194"><span class="vertical-align"></span></span></span></span><span class="video-time"><?php echo $video['duration']; ?></span> |
258 | 258 | <button onclick=";return false;" title="Watch Later" type="button" class="addto-button video-actions addto-watch-later-button-sign-in yt-uix-button yt-uix-button-default yt-uix-button-short yt-uix-tooltip" data-button-menu-id="shared-addto-watch-later-login" data-video-ids="rLHU-_OhT8g" role="button"><span class="yt-uix-button-content"> <img src="//s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="Watch Later"> |
@@ -278,16 +278,16 @@ discard block |
||
278 | 278 | </div> |
279 | 279 | <div class="browse-item-row ytg-box"> |
280 | 280 | <?php |
281 | - $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
|
282 | - $stmt->execute(); |
|
283 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
284 | - $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
|
285 | - $video['duration'] = $__time_h->timestamp($video['duration']); |
|
286 | - $video['views'] = $__video_h->fetch_video_views($video['rid']); |
|
287 | - $video['author'] = htmlspecialchars($video['author']); |
|
288 | - $video['title'] = htmlspecialchars($video['title']); |
|
289 | - $video['description'] = $__video_h->shorten_description($video['description'], 50); |
|
290 | - ?> |
|
281 | + $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
|
282 | + $stmt->execute(); |
|
283 | + while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
284 | + $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
|
285 | + $video['duration'] = $__time_h->timestamp($video['duration']); |
|
286 | + $video['views'] = $__video_h->fetch_video_views($video['rid']); |
|
287 | + $video['author'] = htmlspecialchars($video['author']); |
|
288 | + $video['title'] = htmlspecialchars($video['title']); |
|
289 | + $video['description'] = $__video_h->shorten_description($video['description'], 50); |
|
290 | + ?> |
|
291 | 291 | <div class="browse-item yt-tile-default "> |
292 | 292 | <a href="/watch?v=<?php echo $video['rid']; ?>" class="ux-thumb-wrap yt-uix-sessionlink yt-uix-contextlink contains-addto " data-sessionlink="ei=CPjwu5ji3bICFS4RIQod9j-M-A%3D%3D&feature=b-mv"><span class="video-thumb ux-thumb yt-thumb-default-194 "><span class="yt-thumb-clip"><span class="yt-thumb-clip-inner"><img src="http://s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="Thumbnail" data-thumb="/dynamic/thumbs/<?php echo $video['thumbnail']; ?>" width="194"><span class="vertical-align"></span></span></span></span><span class="video-time"><?php echo $video['duration']; ?></span> |
293 | 293 | <button onclick=";return false;" title="Watch Later" type="button" class="addto-button video-actions addto-watch-later-button-sign-in yt-uix-button yt-uix-button-default yt-uix-button-short yt-uix-tooltip" data-button-menu-id="shared-addto-watch-later-login" data-video-ids="rLHU-_OhT8g" role="button"><span class="yt-uix-button-content"> <img src="//s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="Watch Later"> |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | <?php |
141 | 141 | $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
142 | 142 | $stmt->execute(); |
143 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
143 | + while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
144 | 144 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
145 | 145 | $video['duration'] = $__time_h->timestamp($video['duration']); |
146 | 146 | $video['views'] = $__video_h->fetch_video_views($video['rid']); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | <?php |
176 | 176 | $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
177 | 177 | $stmt->execute(); |
178 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
178 | + while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
179 | 179 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
180 | 180 | $video['duration'] = $__time_h->timestamp($video['duration']); |
181 | 181 | $video['views'] = $__video_h->fetch_video_views($video['rid']); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | <?php |
211 | 211 | $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
212 | 212 | $stmt->execute(); |
213 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
213 | + while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
214 | 214 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
215 | 215 | $video['duration'] = $__time_h->timestamp($video['duration']); |
216 | 216 | $video['views'] = $__video_h->fetch_video_views($video['rid']); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | <?php |
246 | 246 | $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
247 | 247 | $stmt->execute(); |
248 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
248 | + while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
249 | 249 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
250 | 250 | $video['duration'] = $__time_h->timestamp($video['duration']); |
251 | 251 | $video['views'] = $__video_h->fetch_video_views($video['rid']); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | <?php |
281 | 281 | $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
282 | 282 | $stmt->execute(); |
283 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
283 | + while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
284 | 284 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
285 | 285 | $video['duration'] = $__time_h->timestamp($video['duration']); |
286 | 286 | $video['views'] = $__video_h->fetch_video_views($video['rid']); |