public function checkChallenge($username)
 {
     $challengeInProgress = false;
     $challengeDAO = new ChallengeDAO();
     $challenge = $challengeDAO->getByUsername($username);
     if (!is_null($challenge->getChallengeId())) {
         $challengeInProgress = TRUE;
     }
     return $challengeInProgress;
 }
 public function getPointsByChallengeId($challengeId)
 {
     $sql = "SELECT pointID, challangeID, date, weight FROM weighpoints WHERE challangeID = :challengeId";
     //        $sql = "select pointID, challangeID, date, weight from weighpoints";
     $dbh = new PDO(DBConfig::$DB_CONNSTRING, DBConfig::$DB_USERNAME, DBConfig::$DB_PASSWORD);
     $stmt = $dbh->prepare($sql);
     $stmt->execute(array(':challengeId' => $challengeId));
     $resultList = $stmt->fetchAll(PDO::FETCH_ASSOC);
     //        $resultSet = $dbh->query($sql);
     var_dump($resultList);
     $lijst = array();
     foreach ($resultList as $rij) {
         $challengeDAO = new ChallengeDAO();
         $challenge = $challengeDAO->getById($rij["challangeID"]);
         $weighpoint = Weighpoint::create($rij["pointID"], $challenge, $rij["weight"], $rij["date"]);
         var_dump($weighpoint);
         array_push($lijst, $weighpoint);
     }
     $dbh = null;
     return $lijst;
 }
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());
?>
    </body>
</html>
Esempio n. 4
0
<?php

$challengeDAO = new ChallengeDAO();
$app->get('/challenges/?', authorize(), function () use($challengeDAO) {
    header("Content-Type: application/json");
    echo json_encode($challengeDAO->selectAll(), JSON_NUMERIC_CHECK);
    exit;
});
$app->get('/challenges/:id/?', authorize(), function ($id) use($challengeDAO) {
    header("Content-Type: application/json");
    echo json_encode($challengeDAO->selectById($id), JSON_NUMERIC_CHECK);
    exit;
});
$app->post('/challenges/?', authorize(), function () use($app, $challengeDAO) {
    header("Content-Type: application/json");
    $post = $app->request->post();
    if (empty($post)) {
        $post = (array) json_decode($app->request()->getBody());
    }
    echo json_encode($challengeDAO->insert($post), JSON_NUMERIC_CHECK);
    exit;
});
$app->delete('/challenges/:id/?', authorize(), function () use($challengeDAO) {
    header("Content-Type: application/json");
    echo json_encode($challengeDAO->delete());
    exit;
});
$app->put('/challenges/:id/?', authorize(), function () use($app, $challengeDAO) {
    header("Content-Type: application/json");
    $post = $app->request->post();
    if (empty($post)) {