Example #1
0
<?php

require 'vendor/autoload.php';
Epi::init('template', 'route');
Epi::setPath('view', 'templates');
getRoute()->get('/', array('DomainChecker', 'Run'));
getRoute()->run();
class DomainChecker
{
    public static function Run()
    {
        if (file_exists("cache.json")) {
            $cache = json_decode(file_get_contents("cache.json"), true);
        } else {
            $cache = array();
        }
        $tlds = explode(",", isset($_GET['tlds']) ? $_GET['tlds'] : "com,co.uk,net,org");
        $domains = explode(",", isset($_GET['domains']) ? $_GET['domains'] : "");
        $whois = new Whois();
        $rows = array();
        foreach ($domains as $domain) {
            if (strlen($domain) == 0) {
                continue;
            }
            $results = array();
            $domain = trim($domain);
            $alltaken = true;
            foreach ($tlds as $tld) {
                if (array_key_exists($domain . "." . $tld, $cache) && $cache[$domain . "." . $tld]['time'] > time() - 60 * 60 * 24) {
                    $info = $cache[$domain . "." . $tld]['data'];
                } else {
Example #2
0
<?php

chdir('..');
include_once '../src/Epi.php';
Epi::setPath('base', '../src');
Epi::init('route');
/*
 * This file is an example of using regular expressions in a route.
 * You can use subpatterns which are passed to the function as parameters.
 */
getRoute()->get('/', 'home');
getRoute()->get('/(\\w+)/(\\w+)', 'greeting');
getRoute()->run();
/*
 * ******************************************************************************************
 * Define functions and classes which are executed by EpiRoute
 * ******************************************************************************************
 */
function home()
{
    echo '<h1>Home page. <a href="jaisen/mathai">Click for greeting</a></h1>';
}
function greeting($firstName, $lastName)
{
    echo "<h1>Welcome, {$firstName} {$lastName}</h1>";
}
Example #3
0
<?php

date_default_timezone_set('America/Los_Angeles');
$basePath = dirname(dirname(__FILE__));
$libraryPath = sprintf('%s/libraries', $basePath);
$epiPath = sprintf('%s/epi', $libraryPath);
require sprintf('%s/Epi.php', $epiPath);
Epi::setPath('base', $epiPath);
Epi::setPath('view', sprintf('%s/templates', $basePath));
Epi::setSetting('exceptions', true);
Epi::init('api', 'cache', 'config', 'logger', 'route', 'session', 'template', 'database');
EpiSession::employ(EpiSession::PHP);
require sprintf('%s/initialize.php', $libraryPath);
getRoute()->run();
Example #4
0
<?php

chdir('..');
include_once '../src/Epi.php';
Epi::setPath('base', '../src');
Epi::init('route', 'database');
EpiDatabase::employ('mysql', 'mysql', 'localhost', 'root', '');
// type = mysql, database = mysql, host = localhost, user = root, password = [empty]
// Epi::init('base','cache','session');
// Epi::init('base','cache-apc','session-apc');
// Epi::init('base','cache-memcached','session-apc');
/*
 * This is a sample page whch uses EpiCode.
 * There is a .htaccess file which uses mod_rewrite to redirect all requests to index.php while preserving GET parameters.
 * The $_['routes'] array defines all uris which are handled by EpiCode.
 * EpiCode traverses back along the path until it finds a matching page.
 *  i.e. If the uri is /foo/bar and only 'foo' is defined then it will execute that route's action.
 * It is highly recommended to define a default route of '' for the home page or root of the site (yoursite.com/).
 */
getRoute()->get('/', 'dbhandler');
getRoute()->run();
/*
 * ******************************************************************************************
 * Define functions and classes which are executed by EpiCode based on the $_['routes'] array
 * ******************************************************************************************
 */
function dbhandler()
{
    $users = getDatabase()->all('SELECT * FROM user');
    echo "<h2>All users</h2><ol>";
    foreach ($users as $key => $user) {
Example #5
0
<?php

chdir('..');
include_once '../src/Epi.php';
Epi::setPath('base', '../src');
Epi::init('api');
/*
 * We create 3 normal routes (think of these are user viewable pages).
 * We also create 2 api routes (this of these as data methods).
 *  The beauty of the api routes are they can be accessed natively from PHP
 *    or remotely via HTTP.
 *  When accessed over HTTP the response is json.
 *  When accessed natively it's a php array/string/boolean/etc.
 */
getRoute()->get('/', 'showEndpoints');
getRoute()->get('/version', 'showVersion');
getRoute()->get('/users', 'showUsers');
getRoute()->get('/users/javascript', 'showUsersJavaScript');
getRoute()->get('/params', 'showParams');
getApi()->get('/version.json', 'apiVersion', EpiApi::external);
getApi()->get('/users.json', 'apiUsers', EpiApi::external);
getApi()->get('/params.json', 'apiParams', EpiApi::external);
getApi()->get('/params-internal.json', 'apiParams', EpiApi::internal);
getApi()->get('/params-internal-from-external.json', 'apiParamsFromExternal', EpiApi::external);
getRoute()->run();
/*
 * ******************************************************************************************
 * Define functions and classes which are executed by EpiCode based on the $_['routes'] array
 * ******************************************************************************************
 */
function showEndpoints()
Example #6
0
<?php

chdir('..');
include_once '../src/Epi.php';
Epi::setPath('base', '../src');
Epi::init('route', 'cache-apc');
// If you'd like to use Memcached for cache then init the 'cache' or 'cache-memcached' module and call EpiCache::employ()
// EpiCache::employ(EpiCache::MEMCACHED);
/*
 * This is a sample page which uses native php sessions
 * It's easy to switch the session backend by passing a different value to getInstance.
 *  For example, EpiSession::getInstance(EpiSession::Memcached);
 */
getRoute()->get('/', array('MyClass', 'MyMethod'));
getRoute()->run();
/*
 * ******************************************************************************************
 * Define functions and classes which are executed by EpiRoute
 * ******************************************************************************************
 */
class MyClass
{
    public static function MyMethod()
    {
        if (isset($_GET['name'])) {
            getCache()->set('name', $_GET['name']);
        }
        $name = getCache()->get('name');
        if (empty($name)) {
            $name = '[Enter your name]';
        }
Example #7
0
File: router.php Project: Hulth/API
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
//max: set timezone
//
date_default_timezone_set('Europe/Stockholm');
try {
    // Start EPI
    include 'src/Epi.php';
    Epi::init('api', 'database');
    //include('config.php');
} catch (Exception $err) {
    // Make sure we always change the respose code to something else than 200
    http_response_code(500);
    $err = array('error' => $err->getMessage(), 'file' => $err->getFile(), 'line' => $err->getLine());
    response($err);
}
function p($data)
{
    echo "<pre>" . print_r($data, true) . "</pre>";
}
getRoute()->get('/', 'home', 'insecure');
//user
getApi()->get('/users', array('users', 'getAll'), 'secure', EpiApi::external);
getApi()->get('/users/self', array('users', 'getSelf'), 'secure', EpiApi::external);
getApi()->get('/users/(\\d+)', array('users', 'get'), 'secure', EpiApi::external);
getApi()->get('/users/relations', array('users', 'relations'), 'secure', EpiApi::external);
getApi()->get('/users/relationsng', array('users', 'relationsng'), 'secure', EpiApi::external);
getApi()->get('/users/phone/(\\w+)', array('users', 'phonenumber'), 'secure', EpiApi::external);
//group
Example #8
0
<?php

chdir('..');
include_once '../src/Epi.php';
Epi::setPath('base', '../src');
Epi::init('route', 'session-php');
// If you'd like to use Memcached for sessions then init the 'session' or 'session-memcached' module and call EpiSession::employ()
// EpiSession::employ(EpiSession::MEMCACHED);
/*
 * This is a sample page which uses native php sessions
 * It's easy to switch the session backend by passing a different value to getInstance.
 *  For example, EpiSession::getInstance(EpiSession::Memcached);
 */
getRoute()->get('/', array('MyClass', 'MyMethod'));
getRoute()->run();
/*
 * ******************************************************************************************
 * Define functions and classes which are executed by EpiRoute
 * ******************************************************************************************
 */
class MyClass
{
    public static function MyMethod()
    {
        $counter = (int) getSession()->get('counter');
        $counter++;
        getSession()->set('counter', $counter);
        echo '<h1>You have clicked ' . getSession()->get('counter') . ' times <a href="">Reload</a></h1>';
    }
}
Example #9
0
<?php

include_once '../epiphany/src/Epi.php';
include_once 'controllers/home.class.php';
include_once 'controllers/login.class.php';
include_once 'controllers/dashboard.class.php';
include_once 'controllers/logout.class.php';
include_once 'lib/constants.class.php';
Epi::setSetting('exceptions', true);
Epi::setPath('base', '../epiphany/src');
Epi::setPath('view', './views');
Epi::init('route', 'template', 'session');
getRoute()->get('/', array('HomeController', 'display'));
getRoute()->get('/login', array('LoginController', 'display'));
getRoute()->post('/login', array('LoginController', 'processLogin'));
getRoute()->get('/dashboard', array('DashboardController', 'display'));
getRoute()->get('/logout', array('LogoutController', 'processLogout'));
getRoute()->run();
Example #10
0
<?php

chdir('..');
include_once '../src/Epi.php';
Epi::setPath('base', '../src');
Epi::setSetting('debug', true);
Epi::init('route', 'debug');
getRoute()->get('/', array('MyClass', 'MyMethod'));
getRoute()->get('/sample', array('MyClass', 'MyOtherMethod'));
getRoute()->get('/somepath/source', array('MyClass', 'ViewSource'));
getRoute()->run();
echo '<pre>';
echo getDebug()->renderAscii();
echo '</pre>';
/*
 * ******************************************************************************************
 * Define functions and classes which are executed by EpiCode based on the $_['routes'] array
 * ******************************************************************************************
 */
class MyClass
{
    public static function MyMethod()
    {
        echo '<h1>You are looking at the output from MyClass::MyMethod</h1>
          <ul>
            <li><a href="/debug">Call MyClass::MyMethod</a></li>
            <li><a href="/debug/sample">Call MyClass::MyOtherMethod</a></li>
            <li><a href="/debug/somepath/source">View the source of this page</a></li>
            </ul>
            <p><img src="https://github.com/images/modules/header/logov3-hover.png"></p>';
    }