Beispiel #1
0
function Insert($userPwd, $account, $userName, $idNum, $authority)
{
    include_once '../DAL/userDal.php';
    $result = InsertUser($userPwd, $account, $userName, $idNum, $authority);
    if ($result > 0) {
        return true;
    }
    return false;
}
function CreateUserPage_CreateUser($databaseConnection)
{
    $username = trim($_POST["username"]);
    $password = trim($_POST["password"]);
    $repeatPassword = trim($_POST["repeatPassword"]);
    $email = trim($_POST["email"]);
    if (empty($username)) {
        throw new Exception("You must enter an username.");
    }
    if (empty($password)) {
        throw new Exception("You must enter a password.");
    }
    if ($password !== $repeatPassword) {
        throw new Exception("Repeated password doesn't match with entered password.");
    }
    if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
        throw new Exception("You must enter a valid e-mail address.");
    }
    $salt = GenerateRandomSha224();
    $saltedPassword = $password . $salt;
    $hashedPassword = hash("sha224", $saltedPassword);
    InsertUser($databaseConnection, $username, $hashedPassword, $salt, $email);
}
Beispiel #3
0
require_once 'DisplayFunctions.php';
if (isset($_SESSION["idLogged"])) {
    echo $_SESSION["idLogged"];
}
$message = null;
$nom = "";
$prenom = "";
$dateNaissance = "";
$description = "";
$email = "";
$pseudo = "";
$flagModification = 0;
if (isset($_POST['valider'])) {
    if ($_POST['flagModification'] == 0) {
        if ($_POST['nom'] != null && $_POST['prenom'] != null && $_POST['dateNaissance'] != null && $_POST['description'] != null && $_POST['email'] != null && $_POST['pseudo'] != null && $_POST['pwd'] != null) {
            InsertUser($_POST['nom'], $_POST['prenom'], $_POST['dateNaissance'], $_POST['description'], $_POST['email'], $_POST['pseudo'], $_POST['pwd']);
            $message = "Formulaire envoyé !";
        } else {
            $message = 'Veuillez renseigner tous les champs !';
        }
    } else {
        if ($_POST['flagModification'] == 1) {
            if ($_POST['nom'] != null && $_POST['prenom'] != null && $_POST['dateNaissance'] != null && $_POST['description'] != null && $_POST['email'] != null && $_POST['pseudo'] != null) {
                UpdateUser($_POST['nom'], $_POST['prenom'], $_POST['dateNaissance'], $_POST['description'], $_POST['email'], $_POST['pseudo'], $_POST['pwd'], $_GET['id']);
                $message = 'Informations mises à jour !';
            } else {
                $message = 'Veuillez renseigner tous les champs obligatoires !';
            }
        }
    }
}
Beispiel #4
0
             foreach ($rows as $val) {
                 $keys[] = $val['iduser'];
             }
             $content = RenderView($router, array('rows' => $rows, 'ids' => $keys));
             break;
         case 'Txt':
             $content = RenderView($router, array('rows' => $rows, 'ids' => array_keys($rows)));
             break;
     }
     break;
 case 'insert':
     if ($_POST) {
         $data = filterData($_POST, $formdef);
         $validate = validateData($data, $formdef);
         if ($validate['result'] === true) {
             InsertUser($config, $_POST, $userfilename);
             // saltar a tabla
             header("Location: /user/select");
         } else {
             $content = RenderView($router, array('data' => $_POST, 'config' => $config, 'validation' => $validate));
         }
     } else {
         $rows = GetUsers($config);
         $content = RenderView($router, array('rows' => $rows, 'config' => $config));
     }
     break;
 case 'update':
     if ($_POST) {
         //             print_r($_POST);
         //             $_POST['photo']=$_FILES['photo']['name'];
         include "../modules/Application/src/Application/Model/Txt/Update.php";
if (isset($_POST['command'])) {
    $command = $_POST['command'];
}
//Set variables per module
setReportVariables();
setUserInsertVariables();
$cons = mysql_connect("localhost", "root", "mark");
//field input
mysql_select_db("ireportdb", $cons);
//declaration of $cons and connection to the database itself
switch ($command) {
    case 'insertReport':
        InsertReport();
        break;
    case 'insertUser':
        InsertUser();
        break;
    case 'getAccountData':
        GetAccountData();
        break;
    case 'viewStatus':
        viewStatus();
        break;
    case 'testConnection':
        testConnection();
        break;
    default:
        echo "Unknown Command";
        break;
}
function setReportVariables()
Beispiel #6
0
/// set the content charset to utf-8 for php
error_reporting(E_ALL);
ini_set('display_errors', '1');
session_start();
$temp = $_POST["param"];
$temp = str_replace("[", "", $temp);
$temp = str_replace("]", "", $temp);
//echo $temp;
$param = json_decode($temp);
$ordr = (int) $param->order;
switch ($ordr) {
    case 1:
        GetUsers();
        break;
    case 2:
        InsertUser($param);
        break;
    case 3:
        UpdateUser($param);
        break;
    case 4:
        GetUserInfo($param);
        break;
    case 5:
        DelUser($param);
        break;
}
function GetUsers()
{
    $sql = "SELECT `user_name` FROM `keys` WHERE 1";
    $rr = array();