]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - yourls-go.php
- Moved to /admin/ folder
[Github/YOURLS.git] / yourls-go.php
1 <?php\r
2 ### Require Files\r
3 require_once 'includes/config.php';\r
4 \r
5 ### Connect To Database\r
6 $db = yourls_db_connect();\r
7 \r
8 ### Variables\r
9 $keyword = yourls_sanitize_string($_GET['id']);\r
10 $id = yourls_sanitize_int( yourls_string2int($keyword) );\r
11 \r
12 ### Get URL From Database\r
13 $table = YOURLS_DB_TABLE_URL;\r
14 $url = stripslashes($db->get_var("SELECT `url` FROM `$table` WHERE id = $id"));\r
15 \r
16 // URL found\r
17 if(!empty($url)) {\r
18         $update_clicks = $db->query("UPDATE `$table` SET `clicks` = clicks + 1 WHERE `id` = $id");\r
19         header ('HTTP/1.1 301 Moved Permanently');\r
20         header ('Location: '. $url);\r
21 \r
22 // URL not found. Either reserved, or page, or doesn't exist\r
23 } else {\r
24 \r
25         // Do we have a page?\r
26         if (file_exists(dirname(__FILE__)."/pages/$keyword.php")) {\r
27                 yourls_page($keyword);\r
28 \r
29         // Either reserved id, or no such id\r
30         } else {\r
31                 header ('HTTP/1.1 307 Temporary Redirect'); // no 404 to tell browser this might change, and also to not pollute logs\r
32                 header ('Location: '. yourls_SITE);\r
33         }\r
34 }\r
35 exit();\r
36 ?>