From 13ed7f0b1362a93fca869555e9d5cd21257a9181 Mon Sep 17 00:00:00 2001 From: ozhozh Date: Fri, 11 Jun 2010 16:55:03 +0000 Subject: [PATCH] First attempt at making a unified loader to replace the .htaccess based system git-svn-id: http://yourls.googlecode.com/svn/trunk@391 12232710-3e20-11de-b438-597f59cd7555 --- yourls-loader.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 yourls-loader.php diff --git a/yourls-loader.php b/yourls-loader.php new file mode 100644 index 0000000..8b340ba --- /dev/null +++ b/yourls-loader.php @@ -0,0 +1,34 @@ +"; + +// Start YOURLS +require_once( dirname(__FILE__).'/includes/load-yourls.php' ); + +// Load required template + +// Get request in YOURLS base +$scheme = ( isset($_SERVER["HTTPS"]) ? 'https' : 'http' ); +$request = str_replace( YOURLS_SITE.'/', '', $scheme . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); + +// Make valid regexp pattern from authorized charset in keywords +$pattern = yourls_make_regexp_pattern( yourls_get_shorturl_charset() ); + +// Test server request and redirect accordingly +if( preg_match( "/^([$pattern]+)\/?$/", $request, $matches ) ) { + // yourls-go.php?id=$1 +} + +if( preg_match( "/^([$pattern]+)\+\/?$/", $request, $matches ) ) { + // yourls-infos.php?id=$1 +} + +if( preg_match( "/^([$pattern]+)\+all\/?$/", $request, $matches ) ) { + // yourls-infos.php?id=$1&all=1 +} -- 2.45.0