File: redirect.php

package info (click to toggle)
nanourl 0.1-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 88 kB
  • ctags: 20
  • sloc: sh: 93; php: 50; makefile: 39; sql: 6
file content (33 lines) | stat: -rw-r--r-- 768 bytes parent folder | download | duplicates (2)
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('nanourl.conf');
    $hash= $_GET['num'];

    
    if(! ($connection = @ mysql_connect($nanourlHost, $nanourlUser, $nanourlPassword)) ) {
            die("could not connect");
    }
    
    if(! (mysql_select_db($nanourlDB, $connection))) {
            die("cannot select DB");
    }
    
    $result = mysql_query("SELECT url FROM urls WHERE hash = '$hash'");
    if(! ($result)) {
	    die(mysql_error());
    }
    
    if(($row = mysql_fetch_array($result))) {
       mysql_free_result($result);
       header('Location: ' . $row["url"]);
    }

    mysql_free_result($result);
?>

<html lang="en">
<head>
<title>NanoURL - Create a shorter link</title>
</head>
<h1>Hash &quot; <?php echo $hash; ?> &quot; was not in found!</h1>
</body>
</html>