Example #1
0
$mailbox = new PhpImap\Mailbox('{10.0.5.3/imap/ssl/novalidate-cert}INBOX', 'test', 'test');
// change this, example: $mailbox = new PhpImap\Mailbox('{mail.server.com:993/imap/ssl}INBOX', 'user123', 'myp4ssw0rd');
date_default_timezone_set('Europe/Paris');
# enable in development mode:
#error_reporting(E_ALL);
# get hostname from request if possible - or define your own
$serverName = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
define('DOMAIN', str_replace('www.', '', $serverName));
// URI-Redirector Prefix (leave empty for direct links)
define('URI_REDIRECT_PREFIX', "http://www.redirect.am/?");
// --- end of CONFIG
// setup slim & twig
$app = new \Slim\Slim(array('view' => new \Slim\Views\Twig(), 'templates.path' => 'app/templates', 'slim.url_scheme' => 'https'));
$app->error(function (\Exception $e) use($app) {
    error_log($e->getMessage());
    $app->callErrorHandler($e);
});
$app->view()->parserOptions = array('cache' => __DIR__ . '/cache');
$app->view()->parserExtensions = array(new \Slim\Views\TwigExtension(), new DisposableEmail\AutoLinkTwigExtension());
// add html2Text filter
$app->view()->getInstance()->addFilter(new Twig_SimpleFilter('html2Text', function ($string) {
    $convert = new \Html2Text\Html2Text($string);
    return $convert->get_text();
}));
// redirect to random address
$app->get('/', function () use($app) {
    $wordLength = rand(3, 8);
    $container = new PronounceableWord_DependencyInjectionContainer();
    $generator = $container->getGenerator();
    $word = $generator->generateWordOfGivenLength($wordLength);
    $nr = rand(51, 91);