]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - yourls-go.php
1.4-alpha massive commit:
[Github/YOURLS.git] / yourls-go.php
1 <?php\r
2 // Require Files\r
3 require_once( dirname(__FILE__).'/includes/config.php' );\r
4 \r
5 // Variables\r
6 $id = ( isset( $_GET['id'] ) ? $_GET['id'] : '' );\r
7 $keyword = yourls_sanitize_string( $id );\r
8 \r
9 // First possible exit:\r
10 if ( !$keyword ) {\r
11         header ('Location: '. YOURLS_SITE);\r
12         exit();\r
13 }\r
14 \r
15 // Get URL From Database\r
16 $url = yourls_get_longurl( $keyword );\r
17 \r
18 // URL found\r
19 if( !empty($url) ) {\r
20         // Update click count in main table\r
21         $update_clicks = yourls_update_clicks( $keyword );\r
22         // Update detailed log for stats\r
23         $log_redirect = yourls_log_redirect( $keyword );\r
24 \r
25         yourls_redirect( $url, 301 );\r
26 \r
27 // URL not found. Either reserved, or page, or doesn't exist\r
28 } else {\r
29 \r
30         // Do we have a page?\r
31         if (file_exists(dirname(__FILE__)."/pages/$keyword.php")) {\r
32                 yourls_page($keyword);\r
33 \r
34         // Either reserved id, or no such id\r
35         } else {\r
36                 yourls_redirect( YOURLS_SITE, 307 ); // no 404 to tell browser this might change, and also to not pollute logs\r
37         }\r
38 }\r
39 exit();\r
40 ?>