<?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 {
<?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>"; }
<?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();
<?php // TODO, remove these date_default_timezone_set('America/Los_Angeles'); if (isset($_GET['__route__']) && strstr($_GET['__route__'], '.json')) { header('Content-type: application/json'); } $basePath = dirname(dirname(__FILE__)); $epiPath = "{$basePath}/libraries/external/epi"; require "{$epiPath}/Epi.php"; require "{$basePath}/libraries/compatability.php"; require "{$basePath}/libraries/models/UserConfig.php"; Epi::setSetting('exceptions', true); Epi::setPath('base', $epiPath); Epi::setPath('config', "{$basePath}/configs"); Epi::setPath('view', ''); Epi::init('api', 'cache', 'config', 'curl', 'form', 'logger', 'route', 'session', 'template', 'database'); $routeObj = getRoute(); $apiObj = getApi(); // loads configs and dependencies $userConfigObj = new UserConfig(); $hasConfig = $userConfigObj->load(); $configObj = getConfig(); EpiCache::employ($configObj->get('epi')->cache); $sessionParams = array($configObj->get('epi')->session); if ($configObj->get('epiSessionParams')) { $sessionParams = array_merge($sessionParams, (array) $configObj->get('epiSessionParams')); // for TLDs we need to override the cookie domain if specified if (isset($sessionParams['domain']) && stristr($_SERVER['HTTP_HOST'], $sessionParams['domain']) === false) { $sessionParams['domain'] = $_SERVER['HTTP_HOST']; }
<?php chdir('..'); include_once '../src/Epi.php'; Epi::setPath('base', '../src'); Epi::setPath('view', 'site-with-templates'); Epi::init('route', 'template'); /* * 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('/', array('MyClass', 'MyMethod')); getRoute()->run(); /* * ****************************************************************************************** * Define functions and classes which are executed by EpiCode based on the $_['routes'] array * ****************************************************************************************** */ class MyClass { public static function MyMethod() { $template = new EpiTemplate(); $params = array(); $params['heading'] = 'This is a heading'; $params['imageSrc'] = 'https://github.com/images/modules/header/logov3-hover.png'; $params['content'] = str_repeat('Lorem ipsum ', 100);
<?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();
<?php chdir('..'); include_once '../src/Epi.php'; Epi::setPath('base', '../src'); Epi::setPath('config', dirname(__FILE__)); Epi::init('route'); /* * ****************************************************************************************** * Load the routes from routes.ini then call run() * ****************************************************************************************** */ getRoute()->load('routes.ini'); getRoute()->run(); /* * ****************************************************************************************** * 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="/routes-in-ini-file">Call MyClass::MyMethod</a></li> <li><a href="/routes-in-ini-file/anotherpage">Call MyClass::MyOtherMethod</a></li> </ul> <p><img src="https://github.com/images/modules/header/logov3-hover.png"></p>'; } public static function MyOtherMethod()
<?php //Include Epiphany library include_once './lib/epiphany/src/Epi.php'; Epi::setPath('base', './lib/epiphany/src'); Epi::init('template'); Epi::init('config'); Epi::init('api'); //Epi::setSetting('exceptions', true); //Include Application classes and configuration include_once './controlers/api.class.php'; include_once './controlers/site.class.php'; Epi::setPath('view', './views'); Epi::setPath('config', './conf'); getConfig()->load('config.ini'); //Include plugin classes and configuration $dir = new DirectoryIterator(dirname(__FILE__) . '/plugins'); foreach ($dir as $fileinfo) { if (!$fileinfo->isDot() && $fileinfo->isDir()) { $file = $fileinfo->getFilename(); include_once './plugins/' . $file . '/index.php'; } } /* * We create 1 normal route (think of these are user viewable pages). * We also create 7 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. */