<?php

ini_set("display_errors", 1);

// Define path to application directory
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment development | production
define('APPLICATION_ENV', 'production');


// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library')
)));

/** Zend_Application */
require_once 'Zend/Application.php';

$application = new Zend_Application(APPLICATION_ENV);
$application->setBootstrap(APPLICATION_PATH.'/Bootstrap.php','Bootstrap');

$application->bootstrap()->run();
/*
ob_start();

$application->bootstrap()->run();

$response = ob_get_contents();
ob_end_clean();

function sanitize_output($buffer) {

    $search = array(
        '/\>[^\S ]+/s',     // strip whitespaces after tags, except space
        '/[^\S ]+\</s',     // strip whitespaces before tags, except space
        '/(\s)+/s',         // shorten multiple whitespace sequences
        '/<!--(.|\s)*?-->/' // Remove HTML comments
    );

    $replace = array(
        '>',
        '<',
        '\\1',
        ''
    );

    $buffer = preg_replace($search, $replace, $buffer);

    return $buffer;
}

echo sanitize_output($response);
