Example #1
0
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;
}
// Start YOURLS
require_once dirname(__FILE__) . '/includes/load-yourls.php';
// Get request in YOURLS base (eg in 'http://site.com/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)) {
Example #2
0
/**
 * Return current admin page, or null if not an admin page
 *
 * @return mixed string if admin page, null if not an admin page
 * @since 1.6
 */
function yourls_current_admin_page()
{
    if (yourls_is_admin()) {
        $current = substr(yourls_get_request(), 6);
        if ($current === false) {
            $current = 'index.php';
        }
        // if current page is http://sho.rt/admin/ instead of http://sho.rt/admin/index.php
        return $current;
    }
    return null;
}