<?php

require_once 'config.php';
require_once 'model/faform-model.php';
require_once 'view/faform-view.php';
require_once 'controller/faform-controller.php';
// Define application version nuuber
define('VERSION_NUMBER', '1.3');
/*
	Check if all config variables have values
*/
if (!check_configuration()) {
    die("One or more of Config variables are not set.");
}
$request_host = $_SERVER['HTTP_HOST'];
$request_uri = $_SERVER['REQUEST_URI'];
$base_uri = rtrim($GLOBALS['BASE_URI'], '/') . '/';
//echo "\n base uri :".$base_uri;
// Check to make sure we are hosted out of the correct directory.
if ($base_uri !== substr($request_uri, 0, strlen($base_uri))) {
    $error_message = 'The BASE_URI constant does not match the requested ' . 'URI. Please review the config.php file and set BASE_URI to ' . 'the appropriate path';
    throw new Exception($error_message);
}
// Redirect to HTTPS if the request is made over HTTP.
if (!isset($_SERVER['HTTPS'])) {
    $url = 'https://' . $request_host . $request_uri;
    header($_SERVER['SERVER_PROTOCOL'] . ' Moved Permanently');
    header('Location: ' . $url);
    exit;
}
// Initialize username
/**
 * TODO documentation
 * @param string $type
 * @param string $pattern
 * @param string $id
 * @param array() $configurations
 */
function init_ui_sintax($type, $pattern, $id, $configurations = array())
{
    $listenerConfiguration['listener'] = array('selector' => $id, 'event' => 'ready');
    $configurations = check_configuration($configurations, $listenerConfiguration);
    echo return_jquery($configurations, jquery_support($id, $type, $pattern));
}
        die hinterlegten Werte, sondern probiert diese Werte durch:<dl>
            <dt>Ports</dt><dd><?php 
echo implode(",", $ports);
?>
</dd>
            <dt>Security</dt><dd><?php 
echo implode(",", $secures);
?>
</dd>
        </dl>

        <?php 
foreach ($ports as $port) {
    foreach ($secures as $sec) {
        echo "<h3>Prüfe die Konfiguration mit Port " . $port . " und Security '" . $sec . "'</h3>";
        if (check_configuration($port, $sec)) {
            exit(0);
        }
    }
}
?>
        </div>
    </body>
</html>
<?php 
function check_configuration($port, $security)
{
    flush();
    try {
        $mail = Newsletter::initMailer($port, $security);
        $mail->Timeout = 3;