forked from saggim/Tiny-Tiny-IRC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
url.php
30 lines (22 loc) · 756 Bytes
/
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
<?php
set_include_path(get_include_path() . PATH_SEPARATOR .
dirname(__FILE__) ."/include");
require_once "functions.php";
require_once "sessions.php";
require_once "sanity_check.php";
require_once "version.php";
require_once "config.php";
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$key = $_REQUEST['id'];
if (strpos($key, ".") !== FALSE)
$key = substr($key, 0, strpos($key, "."));
$id = db_escape_string(shorten_key_to_id($key));
$result = db_query($link, "SELECT url FROM ttirc_shorturls
WHERE id = '$id'");
if (db_num_rows($result) != 0) {
$url = db_fetch_result($result, 0, "url");
header("Location: $url");
}
db_query($link, "DELETE FROM ttirc_shorturls WHERE
created < NOW() - INTERVAL '30 days'");
?>