Skip to content

Instantly share code, notes, and snippets.

@sofadesign
Created July 14, 2011 15:08
Show Gist options
  • Save sofadesign/1082633 to your computer and use it in GitHub Desktop.
Save sofadesign/1082633 to your computer and use it in GitHub Desktop.
<?php
function before($route)
{
$uri = request_uri();
$is_admin = preg_match('%^/admin(/.+)?$%', $uri);
# Authentication if required
$auth_required = $is_admin && $uri != "/admin/login" && $uri != "/admin/logout";
if($auth_required) authentication_is_required();
# other ui options
if($is_admin)
{
# Set view dir
option('views_dir', option('root_dir').'/views/admin/');
# execute more things if necessary
before_admin();
}
else
{
# something else if you want
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment