<?php

if( $_SERVER['HTTP_HOST'] == 'homlokzatihoszigeteles.hu' && $_SERVER['REQUEST_URI'] == '/hoszigetelo-rendszer-kiegeszitok/uvegszovet-halo-premium' ) {
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: https://www.homlokzatihoszigeteles.hu/hoszigetelo-rendszer-kiegeszitok/uvegszovet-halo-premium");
    exit();
}

if( isset($_SERVER['HTTP_SEC_FETCH_DEST']) && $_SERVER['HTTP_SEC_FETCH_DEST'] == 'iframe' ) {
    define('IN_IFRAME', true);
} else {
    define('IN_IFRAME', false);
}

$ruri = $_SERVER['REQUEST_URI'];

if( strpos($ruri, 'dryvit') !== false ) {
    $new_ruri = str_replace('dryvit', 'polisztirol', $ruri);

    header("HTTP/1.1 301 Moved Permanently");
    header("Location: " . $new_ruri);
    exit();
}

$delimiter = strpos($ruri, '?');
if( $delimiter !== false ) {
    $ruri = substr($ruri, 0, $delimiter);
}

$ends = substr($ruri, -5);
if( $ends === '.html' ) {
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: /");
    exit();
}

$starts = substr($ruri, 0, 6);
if( $starts === '/site/' ) {
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: /");
    exit();
}

if( ( $_SERVER['HTTP_HOST'] === 'www.hoszigeteles.info' || $_SERVER['HTTP_HOST'] === 'hoszigeteles.info' ) && $ruri === '/' ) {
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: /webaruhaz");
    exit();
}

ini_set("display_errors", 0);

// 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 */
if (PHP_VERSION_ID < 70000) {
    require_once 'Zend/Application.php';
} else {
    require_once __DIR__ . '/../vendor/autoload.php';
}

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

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