Skip to content

Instantly share code, notes, and snippets.

@lukemorton
Created November 30, 2010 16:23
Show Gist options
  • Save lukemorton/721913 to your computer and use it in GitHub Desktop.
Save lukemorton/721913 to your computer and use it in GitHub Desktop.
<?php
require_once('srv.php');
/**
* Set root URL
*/
Srv::config(array('root' => '/myfreeola-control-panel/e-mail/'));
/**
* GET /myfreeola-control-panel/e-mail/
*/
Srv::root(function ()
{
require('index.php');
});
/**
* GET /myfreeola-control-panel/e-mail/luke@freeola-test.net
* GET /myfreeola-control-panel/e-mail/luke@freeola-test.net/security
* POST /myfreeola-control-panel/e-mail/luke@freeola-test.net
* POST /myfreeola-control-panel/e-mail/luke@freeola-test.net/security
*/
Srv::route(':email(/:action)', array('email' => 'emailregex', 'action' => '(security|forwarding|protocol)'))
->methods(array('GET', 'POST'))
->response(function ($req)
{
// Set e-mail object
$email = MyFreeola::instance()->email($req->param('email'));
// Action
$action = $req->param('action');
// Manage or process
if ($req->method() === 'POST')
{
$file = 'process';
}
else
{
$file = 'manage';
}
// If action set, load it's own manage|process page
if ($action !== NULL)
{
require($action.'/'.$file.'.php');
}
// Default include manage|process page
else
{
require($file.'.php');
}
});
// Serve it
Srv::serve();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment