]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - yourls-loader.php
First attempt at making a unified loader to replace the .htaccess based system
[Github/YOURLS.git] / yourls-loader.php
1 <?php\r
2 // Handle inexistant favicon requests\r
3 if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) {\r
4         header('Content-Type: image/gif');\r
5         echo base64_decode("R0lGODlhEAAQAJECAAAAzFZWzP///wAAACH5BAEAAAIALAAAAAAQABAAAAIplI+py+0PUQAgSGoNQFt0LWTVOE6GuX1H6onTVHaW2tEHnJ1YxPc+UwAAOw==");\r
6         exit;\r
7 }\r
8 \r
9 echo "<pre>";\r
10 \r
11 // Start YOURLS\r
12 require_once( dirname(__FILE__).'/includes/load-yourls.php' );\r
13 \r
14 // Load required template\r
15 \r
16 // Get request in YOURLS base\r
17 $scheme = ( isset($_SERVER["HTTPS"]) ? 'https' : 'http' );\r
18 $request = str_replace( YOURLS_SITE.'/', '', $scheme . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );\r
19 \r
20 // Make valid regexp pattern from authorized charset in keywords\r
21 $pattern = yourls_make_regexp_pattern( yourls_get_shorturl_charset() );\r
22 \r
23 // Test server request and redirect accordingly\r
24 if( preg_match( "/^([$pattern]+)\/?$/", $request, $matches ) ) {\r
25         // yourls-go.php?id=$1\r
26 }\r
27 \r
28 if( preg_match( "/^([$pattern]+)\+\/?$/", $request, $matches ) ) {\r
29         // yourls-infos.php?id=$1\r
30 }\r
31 \r
32 if( preg_match( "/^([$pattern]+)\+all\/?$/", $request, $matches ) ) {\r
33         // yourls-infos.php?id=$1&all=1\r
34 }\r