2 // Handle inexistent root favicon requests and exit
3 if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) {
4 header( 'Content-Type: image/gif' );
5 echo base64_decode( "R0lGODlhEAAQAJECAAAAzFZWzP///wAAACH5BAEAAAIALAAAAAAQABAAAAIplI+py+0PUQAgSGoNQFt0LWTVOE6GuX1H6onTVHaW2tEHnJ1YxPc+UwAAOw==" );
9 // Handle inexistent root robots.txt requests and exit
10 if ( '/robots.txt' == $_SERVER['REQUEST_URI'] ) {
11 header( 'Content-Type: text/plain; charset=utf-8' );
12 echo "User-agent: *\n";
18 require_once( dirname( __FILE__ ) . '/includes/load-yourls.php' );
20 // Get request in YOURLS base (eg in 'http://site.com/yourls/abcd' get 'abdc')
21 $request = yourls_get_request();
23 // Make valid regexp pattern from authorized charset in keywords
24 $pattern = yourls_make_regexp_pattern( yourls_get_shorturl_charset() );
26 // Now load required template and exit
28 yourls_do_action( 'pre_load_template', $request );
30 // At this point, $request is not sanitized. Sanitize in loaded template.
33 if( preg_match( "@^([$pattern]+)/?$@", $request, $matches ) ) {
34 $keyword = isset( $matches[1] ) ? $matches[1] : '';
35 $keyword = yourls_sanitize_keyword( $keyword );
36 yourls_do_action( 'load_template_go', $keyword );
37 require_once( YOURLS_ABSPATH.'/yourls-go.php' );
42 if( preg_match( "@^([$pattern]+)\+(all)?/?$@", $request, $matches ) ) {
43 $keyword = isset( $matches[1] ) ? $matches[1] : '';
44 $keyword = yourls_sanitize_keyword( $keyword );
45 $aggregate = isset( $matches[2] ) ? (bool)$matches[2] && yourls_allow_duplicate_longurls() : false;
46 yourls_do_action( 'load_template_infos', $keyword );
47 require_once( YOURLS_ABSPATH.'/yourls-infos.php' );
51 // Prefix-n-Shorten sends to bookmarklet (doesn't work on Windows)
52 if( preg_match( "@^[a-zA-Z]+://.+@", $request, $matches ) ) {
53 $url = yourls_sanitize_url( $matches[0] );
54 yourls_do_action( 'load_template_redirect_admin', $url );
55 yourls_redirect( yourls_admin_url('index.php').'?u='.rawurlencode( $url ), 302 );
59 // Past this point this is a request the loader could not understand
60 yourls_do_action( 'loader_failed', $request );
61 yourls_redirect( YOURLS_SITE, 302 );