This repository has been archived by the owner on Feb 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
update_url.php
54 lines (54 loc) · 2.03 KB
/
update_url.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
<?php
if (isset($_POST['form']) && $_POST['form'] == "expire_date") {
require_once "includes/config.php";
require_once "includes/functions.php";
error_reporting(0);
db_connect();
$alias = mysql_real_escape_string(trim($_POST['alias']));
$_SELF = get_phurl_option('site_url')."/".$alias."-";
$result = mysql_query("SELECT * from ".DB_PREFIX."urls WHERE BINARY code='$alias'");
$num_rows = mysql_num_rows($result);
if ($num_rows < 1) {
header('Location: '.$_SELF);
die();
}
$db_row = mysql_fetch_assoc($result);
$apiKey = $db_row['api'];
$expire_date = $db_row['expire_date'];
if (is_login() && $apiKey = $_USER['apiKey']) {
if (isset($_POST['form']) && isset($_POST['expire_date']) && $_POST['form'] == "expire_date") {
$new_expire_date = mysql_real_escape_string(trim(urldecode($_POST['expire_date'])));
mysql_query("UPDATE ".DB_PREFIX."urls SET expire_date='$new_expire_date' WHERE code='$alias'") or die(mysql_error());
header('Location: '.$_SELF);
die();
}
}
} elseif (isset($_POST['form']) && $_POST['form'] == "url_password") {
require_once "includes/config.php";
require_once "includes/functions.php";
error_reporting(0);
db_connect();
$alias = mysql_real_escape_string(trim($_POST['alias']));
$_SELF = get_phurl_option('site_url')."/".$alias."-";
$result = mysql_query("SELECT * from ".DB_PREFIX."urls WHERE BINARY code='$alias'");
$num_rows = mysql_num_rows($result);
if ($num_rows < 1) {
header('Location: '.$_SELF);
die();
}
$db_row = mysql_fetch_assoc($result);
$apiKey = $db_row['api'];
$url = $db_row['url'];
$newPassword = hashPassword($_POST['password'], hash('sha1', $url));
$oldPass = $db_row['password'];
if (is_login() && $apiKey = $_USER['apiKey']) {
if (isset($_POST['form']) && isset($_POST['password']) && $_POST['form'] == "url_password") {
mysql_query("UPDATE ".DB_PREFIX."urls SET password='$newPassword' WHERE code='$alias'") or die(mysql_error());
header('Location: '.$_SELF);
die();
}
}
}
header('Location: '.$_SELF);
die();
?>