]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - yourls-go.php
New const YOURLS_GO
[Github/YOURLS.git] / yourls-go.php
1 <?php\r
2 define('YOURLS_GO', true);\r
3 require_once( dirname(__FILE__).'/includes/load-yourls.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         yourls_redirect( $url, 301 );\r
12 }\r
13 \r
14 // Get URL From Database\r
15 $url = yourls_get_keyword_longurl( $keyword );\r
16 \r
17 // URL found\r
18 if( !empty($url) ) {\r
19         // Update click count in main table\r
20         $update_clicks = yourls_update_clicks( $keyword );\r
21         // Update detailed log for stats\r
22         $log_redirect = yourls_log_redirect( $keyword );\r
23 \r
24         yourls_redirect( $url, 301 );\r
25 \r
26 // URL not found. Either reserved, or page, or doesn't exist\r
27 } else {\r
28 \r
29         // Do we have a page?\r
30         if (file_exists(dirname(__FILE__)."/pages/$keyword.php")) {\r
31                 yourls_page($keyword);\r
32 \r
33         // Either reserved id, or no such id\r
34         } else {\r
35                 yourls_redirect( YOURLS_SITE, 307 ); // no 404 to tell browser this might change, and also to not pollute logs\r
36         }\r
37 }\r
38 exit();\r
39 ?>