2 define('YOURLS_GO', true);
\r
3 require_once( dirname(__FILE__).'/includes/load-yourls.php' );
\r
5 // Variables should be defined in yourls-loader.php, if not try GET request (old behavior of yourls-go.php)
\r
6 if( !isset( $keyword ) && isset( $_GET['id'] ) )
\r
7 $keyword = $_GET['id'];
\r
8 $keyword = yourls_sanitize_string( $keyword );
\r
10 // First possible exit:
\r
12 yourls_redirect( YOURLS_SITE, 301 );
\r
15 // Get URL From Database
\r
16 $url = yourls_get_keyword_longurl( $keyword );
\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
25 yourls_do_action( 'redirect_shorturl', $url );
\r
27 yourls_redirect( $url, 301 );
\r
29 // URL not found. Either reserved, or page, or doesn't exist
\r
32 // Do we have a page?
\r
33 if ( file_exists(YOURLS_PAGEDIR."/$keyword.php") ) {
\r
34 // Include YOURLS functions we've skipped, they might be of use
\r
35 require_once( YOURLS_INC.'/functions-html.php' );
\r
36 yourls_page($keyword);
\r
38 // Either reserved id, or no such id
\r
40 yourls_do_action( 'redirect_no_url', $url );
\r
42 yourls_redirect( YOURLS_SITE, 307 ); // no 404 to tell browser this might change, and also to not pollute logs
\r