-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathredirect.php
More file actions
32 lines (26 loc) · 818 Bytes
/
Copy pathredirect.php
File metadata and controls
32 lines (26 loc) · 818 Bytes
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
<?php
require_once 'config/config.php';
$db = new Framework\Database();
$shortener = new Framework\Shortener($db);
$utils = new Framework\Utils();
try {
$shortCode = rtrim($utils->sanitize($_GET["c"]), "/");
if ($shortener->is_protected($shortCode)) {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($shortener->checkPassword($shortCode, $utils->sanitize($_POST['password']))) {
$utils->redirect(
$shortener->shortCodeToUrl($shortCode)
);
} else {
$msg = "Incorrect Password";
}
}
include_once 'password_form.php';
} else {
$utils->redirect(
$shortener->shortCodeToUrl($shortCode)
);
}
} catch (Exception $e) {
echo $e->getMessage();
}