-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgoto.php
More file actions
33 lines (24 loc) · 711 Bytes
/
Copy pathgoto.php
File metadata and controls
33 lines (24 loc) · 711 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
33
<?php
/** include header **/
include("header.php");
/** reset error vars **/
$error = 0;
/** get url id **/
$id = isset($_GET['id']) ? $_GET['id'] : '';
/** run query **/
$query = @mysql_query("SELECT * FROM short_urls WHERE url_id = '".$id."' LIMIT 1");
$num = @mysql_num_rows($query);
$row = @mysql_fetch_array($query);
/** if url does not exist throw to home page **/
if($num == 0){ redirect($url->url_base); exit; }else
/** if url exists go to it **/
if($num != 0)
{
/** update hits **/
@mysql_query("UPDATE short_urls SET url_hits = url_hits+1 WHERE url_id = '".$id."'");
/** redirect to long url **/
redirect($row['long_url']);
/** exit **/
exit;
}
?>