<?php

include_once "core/fouryou-router.php";
include_once "core/fouryou-router_utils.php";

include_once "services/fouryou-mongodb.php";
include('services/MongoDBBib/vendor/autoload.php');

include_once "services/fouryou-fpdf.php";

$router = new Router();

$router->addRoute('GET', '/home', function () {
    echo "My route home is working!";
    exit;
});

$router->addRoute('GET', '/', function () {
    include('pages/home.php');
    exit;
});

$router->addRoute('GET', '/test', function () {
    echo "My route test is working!";
    exit;
});

$router->addRoute('GET', '/pdftest', function () {

    $pdfclient=new FpdfClient();
    $pdf=$pdfclient->getClient();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);
    $pdf->Cell(40,10,'Hello World!');
    $pdf->Output();
    exit;
});

//https://devlink.4you-werbeagentur.de/users/user=Peter&name=tolt&haus=gelb
$router->addRoute('GET', '/users/:getpparams', function ($getpparams) {


   
 
    $router_util=new Router_utils($getpparams);
    $get_vars=$router_util->get_getresult();



            echo "<pre>";
                    print_r($get_vars);
            echo "</pre>";

    exit;
});


$router->addRoute('GET', '/mongodb', function () {
    
    echo "My route mongo is working!";

    $uri='mongodb+srv://kmpgithub:mVgPYxKwZLEcxbs0@cluster0.a9itp.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0';
    $mongoclient=new MongoDbClient($uri);
    $client=$mongoclient->getClient();
    $collection =$client->nlsportal->nlsuser;
    $cursor = $collection->find();
    foreach ($cursor as $user) {
    
        echo '<pre>',print_r($user,1),'</pre>';
    
 
    
 
    
    }
    exit;
});




$router->matchRoute();

