//require_once 'Exceptions/InvalidInputException.php';
session_start();
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
if (isset($_GET["action"]) && $_GET["action"] == "login") {
    if (isset($_POST["username"]) && isset($_POST["password"])) {
        unset($_SESSION["msg"]);
        unset($_SESSION["warningmsg"]);
        try {
            $userSvc = new UserService();
            $service = $userSvc->checkLogin($_POST["username"], $_POST["password"]);
            if ($service == "access granted") {
                $_SESSION[redirect_arrayName()] = redirect_par();
                $_SESSION["username"] = $_POST["username"];
                header("location:index.php");
                exit(0);
            }
        } catch (LoginException $ex) {
            $_SESSION["warningmsg"] = $ex->getMessage();
        }
    }
}
if (isset($_GET["action"]) && $_GET["action"] == "new") {
    if (isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["name"]) && isset($_POST["surname"]) && isset($_POST["email"])) {
        unset($_SESSION["msg"]);
        unset($_SESSION["warningmsg"]);
        try {
            $userSvc = new UserService();
<?php

//weighvolution.php
require_once 'Business/ChallengeService.php';
require_once 'algemenefuncties.php';
require_once 'debugger.php';
session_start();
if (!isset($_SESSION[redirect_arrayName()]) || $_SESSION[redirect_arrayName()] !== redirect_par()) {
    header("location:aanmelden.php");
    exit(0);
} else {
    $challengeSvc = new ChallengeService();
    $service = $challengeSvc->checkChallenge($_SESSION["username"]);
    if ($service) {
        $challenge = $challengeSvc->getChallegeby($_SESSION["username"]);
        $height = 500;
        $width = 1000;
        $topG = $challenge->getStartGewicht() + 5;
        $bottomG = $challenge->getEindGewicht() + 5;
        $bereik = ($challenge->getStartGewicht() + 5 - ($challenge->getEindGewicht() - 5)) * 10;
        //        var_dump($bereik);
        $gpRatio = $height / $bereik;
        $startIdeaalLijn = 0 . "," . round(($topG - $challenge->getStartGewicht()) * 10 * $gpRatio, 0, PHP_ROUND_HALF_UP);
        //        var_dump($startIdeaalLijn);
        $EindeIdeaalLijn = 1000 . "," . round(($topG - $challenge->getEindGewicht()) * 10 * $gpRatio, 0, PHP_ROUND_HALF_UP);
        //        var_dump($EindeIdeaalLijn);
        include_once 'Presentation/weighvolutionChart.php';
    } else {
        header("location:challengeAdjust.php");
        exit(0);
    }
$check = check_valid_input($string, 6);
var_dump($check);
var_dump(check_valid_input($string, 6));
$fox = $userDAO->getByUsername("foxbarrelinc");
var_dump($fox);
//        $userSvc = new UserService();
//        $service = $userSvc->checkLogin("foxbarrelinc", "adminpwd");
//        var_dump($service);
$par1 = $_SERVER['REMOTE_ADDR'];
var_dump($par1);
$par2 = gethostbyaddr($par1);
var_dump($par2);
var_dump(redirect_arrayName());
var_dump(redirect_par());
$_SESSION[redirect_arrayName()] = redirect_par();
var_dump($_SESSION[redirect_arrayName()]);
var_dump($_SERVER['HTTP_USER_AGENT']);
$hashValue = passwordEncrypt("fifafo", "schildp@d");
var_dump($hashValue);
$color = randomColor();
echo "<span style='color:" . $color . "'>" . $color . "</span>";
$cDAO = new ChallengeDAO();
$temp_var = $cDAO->getByUsername("foxbarrelinc");
var_dump($temp_var);
$challengeSvc = new ChallengeService();
$service = $challengeSvc->getChallegeby("foxbarrelinc");
var_dump($service);
$bool_temp = $challengeSvc->checkChallenge($service->getUser()->getUsername());
var_dump($bool_temp);
$wDAO = new WeighpointDAO();
$points = $wDAO->getPointsByChallengeId($service->getChallengeId());