diff options
| author | s1n <[email protected]> | 2020-03-28 10:36:41 -0700 |
|---|---|---|
| committer | s1n <[email protected]> | 2020-03-28 10:36:41 -0700 |
| commit | 25b7d2aab61ae6421398d3abae5da6ffe590333d (patch) | |
| tree | 611985ec78bb2d94099c9fd5dd687f5c9cee6f3e /yourls-loader.php | |
| parent | Initial commit (diff) | |
| download | crack.cf-backup-25b7d2aab61ae6421398d3abae5da6ffe590333d.tar.xz crack.cf-backup-25b7d2aab61ae6421398d3abae5da6ffe590333d.zip | |
Diffstat (limited to 'yourls-loader.php')
| -rw-r--r-- | yourls-loader.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/yourls-loader.php b/yourls-loader.php new file mode 100644 index 0000000..b880ce0 --- /dev/null +++ b/yourls-loader.php @@ -0,0 +1,66 @@ +<?php +// Handle inexistent root favicon requests and exit +if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) { + header( 'Content-Type: image/gif' ); + echo base64_decode( "R0lGODlhEAAQAJECAAAAzFZWzP///wAAACH5BAEAAAIALAAAAAAQABAAAAIplI+py+0PUQAgSGoNQFt0LWTVOE6GuX1H6onTVHaW2tEHnJ1YxPc+UwAAOw==" ); + exit; +} + +// Handle inexistent root robots.txt requests and exit +if ( '/robots.txt' == $_SERVER['REQUEST_URI'] ) { + header( 'Content-Type: text/plain; charset=utf-8' ); + echo "User-agent: *\n"; + echo "Disallow:\n"; + exit; +} + +// Load YOURLS +require_once __DIR__ . '/includes/load-yourls.php'; + +// Get request in YOURLS base (eg in 'http://sho.rt/yourls/abcd' get 'abdc') +$request = yourls_get_request(); + +// Make valid regexp pattern from authorized charset in keywords +$pattern = yourls_make_regexp_pattern( yourls_get_shorturl_charset() ); + +// Now load required template and exit + +yourls_do_action( 'pre_load_template', $request ); + +// At this point, $request is not sanitized. Sanitize in loaded template. + +// Redirection: +if( preg_match( "@^([$pattern]+)/?$@", $request, $matches ) ) { + $keyword = isset( $matches[1] ) ? $matches[1] : ''; + $keyword = yourls_sanitize_keyword( $keyword ); + yourls_do_action( 'load_template_go', $keyword ); + require_once( YOURLS_ABSPATH.'/yourls-go.php' ); + exit; +} + +// Stats: +if( preg_match( "@^([$pattern]+)\+(all)?/?$@", $request, $matches ) ) { + $keyword = isset( $matches[1] ) ? $matches[1] : ''; + $keyword = yourls_sanitize_keyword( $keyword ); + $aggregate = isset( $matches[2] ) ? (bool)$matches[2] && yourls_allow_duplicate_longurls() : false; + yourls_do_action( 'load_template_infos', $keyword ); + require_once( YOURLS_ABSPATH.'/yourls-infos.php' ); + exit; +} + +// Prefix-n-Shorten sends to bookmarklet (doesn't work on Windows) +if( preg_match( "@^[a-zA-Z]+://.+@", $request, $matches ) ) { + $url = yourls_sanitize_url( $matches[0] ); + if( $parse = yourls_get_protocol_slashes_and_rest( $url, array( 'up', 'us', 'ur' ) ) ) { + yourls_do_action( 'load_template_redirect_admin', $url ); + $parse = array_map( 'rawurlencode', $parse ); + // Redirect to /admin/index.php?up=<url protocol>&us=<url slashes>&ur=<url rest> + yourls_redirect( yourls_add_query_arg( $parse , yourls_admin_url( 'index.php' ) ), 302 ); + exit; + } +} + +// Past this point this is a request the loader could not understand +yourls_do_action( 'loader_failed', $request ); +yourls_redirect( YOURLS_SITE, 302 ); +exit; |