예제 #1
0
 if (empty($email) or empty($frage) or empty($rAntwort) or empty($bAntwort) or empty($cAntwort) or empty($dAntwort)) {
     $array = loadTopics();
     return $app['templating']->render('service.html.php', array("files" => $array, "error" => true, "neuFalse" => false));
 }
 if (strcmp($thema, '*neu*') == 0) {
     $dateiname = changeChar($neu);
     if (ctype_alnum($dateiname) == false) {
         $array = loadTopics();
         return $app['templating']->render('service.html.php', array("files" => $array, "error" => false, "neuFalse" => true));
     }
     $json = new stdClass();
     $json->topic = $neu;
     $json->description = "";
     $json->questions = array();
 } else {
     $dateiname = changeChar($thema);
     $file = file_get_contents('questions/' . $dateiname . '.json', FILE_USE_INCLUDE_PATH);
     $json = json_decode($file);
 }
 $frageObj = new stdClass();
 $frageObj->Kategorie = "Multiple Choice";
 $frageObj->Frage = $frage;
 $frageObj->{'Antwort A'} = $rAntwort;
 $frageObj->{'Antwort B'} = $bAntwort;
 $frageObj->{'Antwort C'} = $cAntwort;
 $frageObj->{'Antwort D'} = $dAntwort;
 $frageObj->Schwierigkeit = $schwer;
 $frageObj->Quelle = "Portal";
 $frageObj->Überprüft = "Nein";
 $frageObj->{'Richtige Antwort'} = $rAntwort;
 $frageObj->Ersteller = $email;
<?php

ob_start();
include "dbUtilities.php";
session_start();
// Special characters.
$username = changeChar($_POST['username']);
$password = $_POST['password'];
// Se il controllo va bene si effettua il login e si ritorna una stringa OK, altrimenti errore.
$id = checkCredential($username, $password);
if ($id != false) {
    echo "OK";
    $_SESSION['login'] = true;
    $_SESSION['id'] = $id;
    $_SESSION['username'] = $username;
} else {
    echo "Error. Wrong username and/or <a onClick='pong()'>password</a>.";
}
예제 #3
0
<?php

include "dbUtilities.php";
$session_expiration = time() + 3600 * 24 * 2;
// +2 days
session_set_cookie_params($session_expiration);
session_start();
$username = htmlentities(changeChar($_POST['username']));
$email = htmlentities($_POST['email']);
$password = htmlentities($_POST['password']);
$expertise = htmlentities($_POST['expertise']);
if ($username == "") {
    header("Location: index.php");
} else {
    if (checkUserInDB($username) == true) {
        echo "This username already exists.";
    } else {
        if (checkEMailInDB(strtolower($email)) == true) {
            echo "This e-mail already exists.";
        } else {
            $id = insertUser($username, $email, $password, $expertise);
            // Una volta effettuata la registrazione la sessione viene avviata.
            $_SESSION['id'] = $id;
            $_SESSION['login'] = true;
            $_SESSION["username"] = $username;
            echo "Utente " . $username . " aggiunto con successo.";
        }
    }
}
//sostituisco le lettere accentate con le relativa entità html