<?php
   session_start();
    if (!isset($_SESSION['initiated']))
    { 
        session_regenerate_id(true); 
        $_SESSION['initiated'] = true;
//        echo "regene" . session_id();
    }
    $_SESSION['debug'] = 0; 
    $_SESSION['time_start'] = microtime();
?> 

<!DOCTYPE html> 
<html lang="en"> 
<head>
<?php 
include_once $_SERVER['DOCUMENT_ROOT'] . '/vgd_shared.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/language.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/cache.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/payment/payment_shared.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/editor/editor_shared.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/vgd_logic.php';

//StartDebugTime();
EndDebugTime();
PrintDebugTime("Alku");
PutCookie();


$header = AddHeader(xxxHOMETITLExxx, false, '/header2.html'); 
echo $header;

AddGoogleTag('home');

if ($_SESSION['user_id'] == "")
{
/*    echo "<script language=\"javascript\" type=\"text/javascript\">";
    echo "window.location=\"register.php\";";
    echo "</script>";    */
//    CacheCoursesTable();
} 

$course_id = test_input($_GET['course']);
SetCurrentCourse($course_id);
if ($course_id == "")
{
    echo "<script language=\"javascript\" type=\"text/javascript\">";
    echo "window.location=\"index.php#courses\";";
    echo "</script>";
    
}
PrintDebugTime("Alku 2");

//echo "access ";
$course = GetCourse($course_id);
if ($course != "") 
{
    if ($_SESSION["course_id"] != $course_id)
        CreateCache();

    $_SESSION["course_id"] = $course_id;
}
$enrol = test_input($_GET['enrol']);
if ($enrol == '1')
{
        if ($_SESSION['user_country'] == 'FI')
        {
            $conn = CreateConnection("vgd");
            PrintDebugTime("CreateEnrolment");
            $str = CreateEnrolment($conn, $course_id, $_SESSION['user_id'], $_SESSION['school'], false);
            ShowResultBanner(COLOR_SUCCESS, $str);
            CacheAccess($conn);
            CloseConnection($conn);
        }
//        else
}
$access = SetandGetAccess($course_id);

HandleEdugaMenu2($_SESSION['loginname'], $_SERVER['DOCUMENT_ROOT'] . '/menu_edugametion_2025.html', "megamenu", "", '');
//HandleMenu($_SESSION['loginname'], 'menu2_new.html', "xp_megamenu" );

SaveStats($_SESSION['user_id'], "home", "open", $_SERVER['HTTP_REFERER']);
//echo HandleXPBar("", 'menu2_xp.html');
//include_once "vgd_logic.php";
//    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
//F2F2F2
?>
</head>
<body class="index-page">

<?php
//==========================
//TOP
//==========================
$path_id = test_input($_GET['path']);
$firsttime = test_input($_GET['firsttime']);
$name = test_input($_GET['name']);
$hid = test_input($_GET['hid']);

function AddCountryIcon($countrycode)
{
    echo "<a href='/home.php?cnt=" . $countrycode . "'>";
    echo "<img src='../img/flags/" . strtolower($countrycode) . ".svg' alt='" . $country . "' width='16' height='12' >";
    echo "</a>";
}


$cnt = test_input($_GET["cnt"]);
if ($_SESSION['user_id'] == 2) 
{
    if ($cnt != '')
        SetCountry($cnt); 
    echo "For Juha only: " . $_SESSION['user_id'] . ":" . $_SESSION['user_country']  . $_SESSION['CURRENCY_NAME'];
    AddCountryIcon('FI');
    AddCountryIcon('IN');
    AddCountryIcon('US');
    AddCountryIcon('GB');
    AddCountryIcon('ID');
    AddCountryIcon('VN');
    AddCountryIcon('MY');
    AddCountryIcon('PH');
    AddCountryIcon('DE');
    AddCountryIcon('SE');
    AddCountryIcon('CA');
    AddCountryIcon('SA');
}

if (! empty($path_id))
{
    $_SESSION['path'] = $path_id;
    if ($_SESSION['user_id'] == "")
        if ($_SESSION['caching_done'] != 1)
        {
            echo "create cache";
            CreateCache();
        } 
}
//echo "editor image cache";
//if ($_SESSION['course_id'] != 'gdg')
//if (! $_SESSION['editor_image_cache_created'])
//    CreateEditorImageCache();

if ((isset($hid)) && ($hid != "")) //login info is in the link sent in the email 
{
//echo "<br><br><br>HID " . $hid;
    //die("Died HEre:" . $user_id . " HID:" . $hid . ":". $completed . $uncompleted . "<br><br><br><br><br><br><br>");
    //die ("USer found...". $_SESSION['user_id'] . $_SESSION['user'] ." - ". $_SESSION['cookies']);
    $conn = CreateConnection("vgd");
    $result = DoHIDLogin($conn, $hid);
    echo "<script language=\"javascript\" type=\"text/javascript\">";
    echo "window.location=\"home.php?course=" . $_SESSION["course_id"] . "\";";
    echo "</script>";
    CloseConnection($conn);
}
//if ($_SESSION['user_id'] == "")
//check this or will cause problems otherwise
if (($_SESSION['user_id'] == "") && ($firsttime == 1))
    $firsttime = 0;

if (($_SESSION['user_id'] == "") && ($firsttime != 1))
{
        if ($_SESSION['caching_done'] != 1) 
            CreateCache();
/*        if ($_SESSION['course_id'] != 'gdg' && $_SESSION['course_id'] != 'gdg1' &&$_SESSION['course_id'] != 'gdg2' )
            if (! $_SESSION['editor_image_cache_created'])
                CreateEditorImageCache();            */
}
else
{
}
PrintDebugTime("Home 1");

try {  
/*        if (( $_SESSION['member'] < 1))// && ($page['public'] == 0))
            
        {
            if (!IsSuperOfferCountry())
               AddNowOnly();
//           AddPricing();
        }  */
        
//            echo "SUBMITTED val: " . $_SESSION["submitted"];
        if ($_SESSION['user_id'] != "")
            AddBanner();
        
        $course = GetCourse($_SESSION["course_id"]);
        $access = $_SESSION["access"][$_SESSION['course_id']];
        $completed_pages = GetPagesCompleted();
        $course = GetCourse($_SESSION["course_id"]);
        $pages_required = $course["pages_required"];//PAGES_REQUIRED_FOR_COMPLETION;        
        $color = GetCourseGroupColor($course['group_id']);
        $group_name = GetCourseGroupName($course['group_id']);
        
        
        $file = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/home_details.html'); 
        $file = str_replace_first('xxxCOURSETITLExxx', $course["course_name"], $file); 
        $file = str_replace_first('xxxCOURSESHORTxxx', $course["short"], $file); 
        if ($_SESSION['certificate_number'] > 0)
            $file = str_replace_first('xxxCURRICULUMIMAGExxx', "<img src='" . CDN . "img/certificate-Edugametion-white.jpg' style='width:30%'>", $file);
        else
        {
            if (($course['intro_video'] != '') && ($_SESSION['loginname'] == ''))
            {
                $file = str_replace_first('xxxCURRICULUMIMAGExxx', "<h3>Preview to the course</h3>" . "<iframe src='https://player.vimeo.com/video/" . $course['intro_video'] . "' width='100%' height='320' style='position:relative;top:0px;' frameborder='0' allow='autoplay; fullscreen' allowfullscreen></iframe>", $file); 
                //$file = str_replace_first('xxxPREVIEWxxx', "<h3>Preview to the course</h3>" . "<iframe src='https://player.vimeo.com/video/" . $course['intro_video'] . "' width='100%' height='320' style='position:relative;top:0px;' frameborder='0' allow='autoplay; fullscreen' allowfullscreen></iframe>", $file); 
                $file = str_replace_first('xxxPREVIEWxxx', "", $file); 
            }
            else
                $file = str_replace_first('xxxCURRICULUMIMAGExxx', "<img  src='" . CDN . "img/" . $_SESSION['course_id'] . "/" . $course['image'] . "' height=320 width=100% style='object-fit: cover;'>", $file); 
                //$file = str_replace_first('xxxPREVIEWxxx', "<h3>Preview to the course</h3>" . "<iframe src='https://player.vimeo.com/video/" . $course['intro_video'] . "' width='100%' height='320' style='position:relative;top:0px;' frameborder='0' allow='autoplay; fullscreen' allowfullscreen></iframe>", $file); 
                $file = str_replace_first('xxxPREVIEWxxx', "", $file); 
            }
        
        $file = str_replace_first('xxxDESCRIPTIONxxx', $course['description'], $file);   
        $file = str_replace_first('xxxREQUIREMENTSxxx', $course['requirements'], $file);   
        $file = str_replace_first('xxxOUTCOMExxx', $course['outcome'], $file);   
        
        $file = str_replace('xxxEDUCATORIDxxx', $course["educator_id"], $file);   
        $educator = $_SESSION['educators'][$course['educator_id']];
        $file = str_replace('xxxEDUCATORxxx', $educator['fname'] . " " . $educator['lname'], $file);   
        $file = str_replace_first('xxxREQUIREMENTSxxx', $course["requirements"], $file);  
        $file = str_replace_first('xxxLEVELxxx', $course['level'], $file); 
        if ($_SESSION['user_country'] == 'FI') 
        { 
            $file = str_replace_first('xxxHOURSxxx',  'One month of studies.<br>Upon completion ' . $row['ects_amount'] . " ECTS credits.<br><a href='/promo/ECTSinfo.php'>More info</a>", $file);
        }
        else
        { 
            $file = str_replace_first('xxxHOURSxxx',  "One month of studies.", $file);
        }
 
//        $file = str_replace_first('xxxCURRICULUMROWSxxx', HandleCurriculumMenu("curriculum2025"), $file); 
        $file = str_replace_first('xxxCURRICULUMCARDSxxx', CreateCurriculumCards($_SESSION["course_id"]), $file); 
        
        
        $home_str = "";
        $status_str = "";
        $btn_str = "";
        $guide_str = "";
        $progress_str = "";
        $feedback_str = "";
        if ($_SESSION['debug'] == 1) echo "<br>ACC1:" . (isset($access));
        if ($_SESSION['debug'] == 1) echo "<br>ACC1:" . ($access != "");
        if ($_SESSION['debug'] == 1) echo "<br>Plan:" . ($_SESSION['plan']);
        
/*        $style_str = "<script>";
        $style_str = $style_str . " var element = document.querySelector(',btn-primary');";
        $style_str = $style_str . " element.style.setProperty('--bs-btn-color', 'red');";
//        $style_str = $style_str .  "function test() {";
//        $style_str = $style_str . " var r = document.querySelector(':root');";
        //$style_str = $style_str . " var rs = getComputedStyle(r);";
//        $style_str = $style_str . " r.style.setProperty('--bs-btn-color', 'red');";

        //$style_str = $style_str . " r.querySelector('btn-primary').style.setProperty('--bs-btn-color','" . $color . "');";
//        $style_str = $style_str . "}";
        $style_str = $style_str . "</script>";
        echo $style_str;*/
        $style_str = "";// style='background-color:". $color . ";border-color:white;hover-color:white !important;'";
        
        if (! CheckHasCourseAccess($course_id)) //(! isset($access)) || ($access == ""))
        {
            if ($course['purchase_only'])   
            { 
                if (IsPaymentAvailableCountry())
                    $btn_str = $btn_str . "<a class = 'btn btn-primary w-75' id='start-btn' href='/payment/pricing.php?hndl=" . $course_id . "&return=home.php&button=home' " . $style_str . " >Start</a>";                            
                else
                    $btn_str = $btn_str . "<a class = 'btn btn-primary w-75' id='start-btn' href='/contactus.php' " . $style_str . " >Enquire Availabity</a>";                            
                if ($_SESSION['user_country'] == 'FI')
                    $status_str = $status_str . "This course is only available for purchase.";
            }                    
            else 
            if (($course['available'] != ""))   
            {
                if (isset($access))//has enrolled but no approved
                    $btn_str = $btn_str . "<h4>Pending course to be available!</h4>";                 
                else
                    $btn_str = $btn_str . "<a class = 'btn btn-primary w-75' id='start-btn' href='/home.php?course=" . $course_id . "&enrol=1'  " . $style_str . " >Enrol already</a>";                
                $status_str = $status_str . "<h3>COMING: " . $course['available'] . "</h3>";
            }
            else  
            {
//                $btn_str = $btn_str . "<a class = 'btn primary-btn w-50' href='home.php?enrol=" . $course_id . "'><h4>Enrol</h4></a>";                
                //echo "<br><br><br>School: " . $_SESSION['school'];
                if (($_SESSION['user_country'] == 'FI') || ($_SESSION['school'] != ''))
                {
                    if (isset($access))//has enrolled but no approved
                    { 
                        $btn_str = $btn_str . "<div class = 'btn btn-primary w-75' id='start-btn' href='/home.php?course=" . $course_id . "&enrol=1'  " . $style_str . " >Pending approval</div>";                            
                        $btn_str = $btn_str . "<br>Remember to enrol at Metropolia too";                            
                    }   
                    else 
                        $btn_str = $btn_str . "<a class = 'btn btn-primary w-75' id='start-btn' href='/home.php?course=" . $course_id . "&enrol=1'  " . $style_str . " >Enrol</a>";                            
                }  
                else
                if (IsPaymentAvailableCountry())
                {
                    if ($_SESSION['pages'][0]['public'] == 1)
                    { 
                        $page = $_SESSION['pages'][0];
                        //$btn_str = $btn_str . "<a class = 'btn btn-primary w-50' href='/page.php?page=" . $page['page_name'] ."' >Start this course</a>";                            
                        $btn_str = $btn_str . "<a class = 'btn btn-primary w-75' id='start-btn' href='/page.php?page=" . $page['page_name'] ."'  " . $style_str . " >Start this course</a>";                            
                    }
                    else
                    {
                        $sub = GetSubForSubscription();
                        $btn_str = $btn_str . "<a class = 'btn btn-primary w-75' id='start-btn' href='/payment/pricing.php?onecourse=" . $course_id . "&button=homesub&plan=3'  " . $style_str . " >Start this course</a>";                            
                        //$btn_str = $btn_str . "<a class = 'btn btn-primary w-75' id='start-btn' href='/payment/subscription_handler.php?onecourse=" . $course_id . "&&button=homesub&plan=3'  " . $style_str . " >Start this course</a>";                            
                    }
                }
                else
                    $btn_str = $btn_str . "<a class = 'btn btn-primary w-75' id='start-btn' href='/contactus.php'  " . $style_str . " >Enquire Availabity</a>";                            
            }
            
        }
        else
        {
            if ($firsttime == 1)
            {
                if (! empty($name))
                { //jos rekisteröinyt niin nimi puuttuu muuten
                    //wechat payment päivittää nimen kantaan, jos täällä tuota parametria voi käyttää kuka vaan miten vaan
                    $pos = strpos($name, " ");
                    $_SESSION['fname'] = substr($name, 0, $pos);
                    $_SESSION['lname']  = substr($name, $pos+1, 100);
                }
                $home_str = xxxFIRSTTIMEWELCOMExxx;
                $home_str = str_replace_first("xxxSITENAMExxx", SITENAME, $home_str);             
                $btn_str = "<a href='page.php?page=" . $latest . "&course=" . $course_id . "' class='btn btn-primary w-75' id='start-btn' role='button' aria-pressed='true'  " . $style_str . " >" . "Start" . "</a>";
            }
            else
            {            
                //echo "COURSE id " . $course_id . "ACCESS for " . var_dump($access) . " MEMBER " . $_SESSION['member'] . "<br>";
                if (($course['available'] != "") && (! $course['purchase_only']))
                {
                    $status_str = $status_str . "<h3>COMING: " . $course['available'] . "</h3>";
                    $btn_str = $btn_str . "<h4>Waiting for course availability!</a>";
                }     
                else 
                {
                        $home_str = xxxHOMETEXTxxx;
                        if ($_SESSION['certificate_number'] > 0)
                        {
                            $status_str = "<h2>" . xxxCERTIFICATEAVAIL1xxx . "</h2>" ;

                            $progress_str = xxxCERTIFICATEAVAIL2xxx;
                            //$guide_str = xxxGENERATExxx;
                            $btn_str = "<br><a class='btn btn-primary black-background white w-75' id='start-btn' href='validate.php' >" . xxxGENERATExxx . "</a>";
                            $feedback_str = "<a  href='https://forms.gle/J5vXAme4cxYDprsK6' style='color:white'>" . xxxSUBMITFEEDBACK2xxx . "</a><br><br>";

                        }
                        else
                        if ($completed_pages >= $pages_required)
                        {
                            //$fireworks = CreateFireworks();
                            //$file = str_replace_first('xxxWORKSxxx', $fireworks, $file);             
                            $home_str = xxxSUBMITHEADERxxx . " " . $_SESSION["fname"] . "!";      
                            $status_str = "YOU HAVE COMPLETED THE COURSE!";      
                            $guide_str = "<br>" . xxxSUBMITDELIVEREDxxx . "<br>" . xxxSUBMITGETCERTIFICATExxx . "<br>" . xxxSUBMITTHANKYOUxxx;
                            $btn_str = "<a class='btn btn-primary black-background white w-50' href='https://forms.gle/J5vXAme4cxYDprsK6'  " . $style_str . " >" . xxxSUBMITFEEDBACK2xxx . "</a>";
                        }          
                        else
                        {

                            if ($completed_pages == 0)
                            {
                                $status_str = xxxSTARTHERExxx;
                            }
                            else
                            {
                                //$level = GetPlayerLevel();
//                                $file = str_replace_first('xxxRANKINGxxx', xxxRANKINGxxx . "<br>" . $rankings[$level], $file); 

                                $total_persentage = round(100 * $completed_pages / $pages_required);//TOTAL_PAGES);
                                $progress_str = CreateProgressBar($total_persentage, $total_persentage . "%");

                                //$next_level = $level + 1;
                                //$needed_pages = GetPagesRequired($next_level);//layerLevel($level + 1;
                                //$status_str = "<h3>" . xxxRANKINGxxx . $rankings[$level];
                                //$status_str = $status_str . $level . " - " . $_SESSION['rankings'][$level] .  "</h3>";
                                //$status_str = $status_str . "Complete " . $needed_pages . " pages for " . $rankings[$next_level];
                                $progress_str = $progress_str . $completed_pages . " pages of " . $pages_required . " completed. ";
                                $progress_str = $progress_str . xxxGUIDE5xxx;// . "<br>" . xxxGUIDE2xxx;
                                $progress_str = $progress_str . "<br>";
                                $progress_str = $progress_str . xxxWHENCERTIFICATExxx;
                                $progress_str = $progress_str . "<br>";
                                //$status_str = $status_str . xxxCOMPLETEREQUIREDPAGESxxx . " " . $pages_required . " " . xxxREQUIREDPAGESxxx;;

                                //check for missed pages
                                $pages = $_SESSION['pages'];    
                                $str = "";
                                if (($completed_pages < $pages_required) && ($course['available'] == "")) 
                                foreach ($pages as $p)
                                {
                                    if (GetPageStatus($p["page_name"]) == PAGE_HALF)
                                    {
                                        foreach($_SESSION['sections'] as $row)
                                        {
                                            if (($row['type'] == 'exercise') && ($row['page_name'] == $p["page_name"]) && ($row['active'] == 1))
                                            if (! GetAnswer($row['header']))
                                            {
                                                $e = GetExercise($row['header']);
                                                if ($str == "")
                                                    $str = $str . "<br><br>You might have missed these Exercises:<br>";
                                                $str = $str . "<a href=page.php?page=" . $p['page_name'] . "#" . $row['header'] . " style='color:#ed8d1c'>" . $p['title'] . ": " . $e['title'] . "</a><br>"; 
                                            }
                                        }
                                    }
                                }
                                $guide_str = $guide_str . $str;
                            }
                            if (! empty($access['latest']))
                                $latest = $access['latest'];
                            else
                                $latest = $_SESSION['pages'][0]['page_name'];
                            if ($total_persentage == 0)
                                $btn_str = "<a href='page.php?page=" . $latest . "&course=" . $course_id . "' class='btn btn-primary w-75' id='start-btn' role='button' aria-pressed='true'  " . $style_str . " >" . "Start Course" . "</a>";
                            else
                                $btn_str = "<a href='page.php?page=" . $latest . "&course=" . $course_id . "' class='btn btn-primary w-75' id='start-btn' role='button' aria-pressed='true'  " . $style_str . " >" . lan_continue . "</a>";
                        }
                }
            }
        }
        $style_str = "<script>";
        $style_str = $style_str . " var element =  document.querySelector('start-btn');";
        //$style_str = $style_str . " var element = document.querySelector(',btn-primary');";
        $style_str = $style_str . " element.style.setProperty('--bs-btn-color', 'red');";
//        $style_str = $style_str .  "function test() {";
//        $style_str = $style_str . " var r = document.querySelector(':root');";
        //$style_str = $style_str . " var rs = getComputedStyle(r);";
//        $style_str = $style_str . " r.style.setProperty('--bs-btn-color', 'red');";

        //$style_str = $style_str . " r.querySelector('btn-primary').style.setProperty('--bs-btn-color','" . $color . "');";
//        $style_str = $style_str . "}";
        $style_str = $style_str . "</script>";
        echo $style_str;

        $file = str_replace_first('xxxHOMETEXTxxx', $home_str, $file); 
        $file = str_replace_first('xxxSTATUSxxx',   $status_str, $file); 
        $file = str_replace_first('xxxPROGRESSxxx', $progress_str, $file); 
        $file = str_replace_first('xxxGUIDETEXTxxx',$guide_str, $file); 
        $file = str_replace('xxxCTABUTTONxxx',$btn_str, $file); 
        $file = str_replace_first('xxxFEEDBACKxxx', $feedback_str, $file); 
        $file = str_replace_first('xxxCANVASxxx', "", $file); 
        $file = str_replace_first('xxxFEATUREGAMExxx', "", $file); 

        
        
        

        $presentage = GetCourseStatus() ;//GetCertificateCompletion();
        $file = str_replace('xxxCERTIFICATEPERCENTAGExxx', strval($presentage) . "%", $file);
        if ($presentage < 10)
            $file = str_replace('xxxTOTALCOLORxxx', "black", $file);
        else
            $file = str_replace('xxxTOTALCOLORxxx', "white", $file);
        $file = str_replace_first('xxxCERTIFICATECOMPLETIONxxx', xxxCERTIFICATECOMPLETIONxxx, $file);
            
        $file = str_replace_first('xxxHOMETEXTxxx', $home_str, $file); 
        $file = str_replace_first('xxxSTATUSxxx',   $status_str, $file); 
        $file = str_replace_first('xxxPROGRESSxxx', $progress_str, $file); 
        $file = str_replace_first('xxxGUIDETEXTxxx',$guide_str, $file); 
        $file = str_replace('xxxCTABUTTONxxx',$btn_str, $file); 
        $file = str_replace_first('xxxFEEDBACKxxx', $feedback_str, $file); 
        $file = str_replace_first('xxxCANVASxxx', "", $file); 
        $file = str_replace_first('xxxFEATUREGAMExxx', "", $file); 
                                            
            
PrintDebugTime("Home 5");


        
        echo $file;

/*//            if (IsSite('BIZSITE'))
        echo "<div class='container' style='max-width:100%;color:white;background-image: linear-gradient(" . COLOR_GRADIENTDARK . "," . COLOR_GRADIENTDARKER . ");border-radius:0px;padding:0px;'>";
//            else 
//                echo "<div class='container shadow'>";
                if ($_SESSION['user_country'] == 'FI')
                    CreateCourseGrid2("home.php", false, false);
                else
                    CreateCourseGrid2("home.php", true, true);
//        CreateCourseGrid2("home.php?course=". $course_id);
        
        echo "</div>";
*/        
        
        AddChat();    
        HandleCookies("home.php#portfolio");//has to be before any headers

        
} catch ( Exception $e ) {
     
        SaveStats($_SESSION['user_id'], "error", "home", $_SERVER['HTTP_REFERER']);
        echo "<br><br>" . lan_loginerror ;// . $e->getMessage();
        if ($_POST['email'] == "juha@hisome.co") 
        	echo "<br>". $e->getMessage();
         
    }

//  <a href="#" id="scroll-top" class="scroll-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
?> 

</body>
					
<?php
//    echo "<br>";
    $footer = CreateFooter("home.php", $_SERVER["DOCUMENT_ROOT"] . "/footer2.html");
    echo $footer;

PrintDebugTime("Home done");
?>

</html>