2 define('YOURLS_GO', true);
\r
3 require_once( dirname(__FILE__).'/includes/load-yourls.php' );
\r
6 $id = ( isset( $_GET['id'] ) ? $_GET['id'] : '' );
\r
7 $keyword = yourls_sanitize_string( $id );
\r
9 // First possible exit:
\r
11 yourls_redirect( YOURLS_SITE, 301 );
\r
14 // Get URL From Database
\r
15 $url = yourls_get_keyword_longurl( $keyword );
\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
24 yourls_do_action( 'redirect_shorturl', $url );
\r
26 yourls_redirect( $url, 301 );
\r
28 // URL not found. Either reserved, or page, or doesn't exist
\r
31 // Do we have a page?
\r
32 if ( file_exists(YOURLS_PAGEDIR."/$keyword.php") ) {
\r
33 // Include YOURLS functions we've skipped, they might be of use
\r
34 require_once( YOURLS_INC.'/functions-html.php' );
\r
35 yourls_page($keyword);
\r
37 // Either reserved id, or no such id
\r
39 yourls_redirect( YOURLS_SITE, 307 ); // no 404 to tell browser this might change, and also to not pollute logs
\r