Esempio n. 1
0
function db_getUserEmail($id, $username)
{
    $ret = db_getUserDataRaw($id, $username);
    if (empty($ret)) {
        return FALSE;
    }
    return $ret['email'];
}
Esempio n. 2
0
<?php

$active = "profile";
$color = "magenta";
include_once 'includes/config.php';
//session_start();
if (!isset($_SESSION["is_auth"])) {
    header('location: login.php?msg=1');
    exit;
}
$userId = $_SESSION['userId'];
$timeWindowName = $_SESSION['timeWindowName'];
$ret = db_getUserDataRaw($userId, null, null, null);
$userLastName = $ret['vez_nev'];
$userFirstName = $ret['ker_nev'];
$userElonev = $ret['elonev'];
$userEmail = $ret['email'];
$telefon = $ret['telefon'];
$comp = db_getCompanyDataForUser($userId, null, null, null);
$vallNev = $comp['nev'];
$thely = $comp['thely'];
$varos = $ret['lakhely_varos'];
$varosresz = $ret['lakhely_varosresz'];
$userCard = $ret['kartyaId'];
$userName = $ret['felh_nev'];
$msgColor = "darkred";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (isset($_POST['user-submit'])) {
        if (!empty($_POST['e-mail']) && !empty($_POST['lakhely_varos']) && !empty($_POST['user_n']) && !empty($_POST['passw'])) {
            $userEmail_uj = test_input($_POST['e-mail']);
            $varos_uj = test_input($_POST['lakhely_varos']);
Esempio n. 3
0
/**
 * Returns a percentage of user's status in the current lecke.
 * @param $userId
 * @param $timeWindowName
 * @return int (percentage) on success or FALSE on failure.
 */
function db_getStatusInLecke($userId = -1, $timeWindowName = "-1")
{
    $ret = db_getUserDataRaw($userId, null, null, null);
    if (empty($ret)) {
        return FALSE;
    } else {
        $userName = $ret['felh_nev'];
    }
    $tid = db_getTimeWindowIdFromName($timeWindowName);
    global $conn;
    $stmt = $conn->prepare("SELECT SUM(suly)\n                            FROM aktivitas\n                            WHERE idoablakId = :twid");
    $stmt->bindParam(':twid', $tid);
    $stmt->execute();
    $egesz = $stmt->fetchColumn();
    $stmt = $conn->prepare("SELECT SUM(suly)\n                            FROM aktivitas, aktivitas_ertekek\n                            WHERE aktivitas.id = aktivitas_ertekek.aktivitasId AND felhNev = :usern AND idoablakId = :twid");
    $stmt->bindParam(':usern', $userName);
    $stmt->bindParam(':twid', $tid);
    $stmt->execute();
    $resz = $stmt->fetchColumn();
    return round($resz * (100 / $egesz));
}
Esempio n. 4
0
/**
 * Returns the three column data for the corresponding lecke (test type: lecke start test).
 * @param $userId
 * @param $numberOfLecke
 * @return array 1D associative array containing the graph dara, or FALSE if the user cannot be found.
 */
function db_getGraphDataForLeckeStartTest($userId = -1, $numberOfLecke = -1)
{
    $graphData = array();
    $leckeName = "lecke" . $numberOfLecke . "kezdo";
    $ret = db_getUserDataRaw($userId, null, null, null);
    if (empty($ret)) {
        return FALSE;
    } else {
        $userName = $ret['felh_nev'];
    }
    /* first column for the graph */
    global $conn;
    $stmt = $conn->prepare("SELECT szazalek\n                            FROM kitolt\n                            WHERE felhNev = :uname AND tesztId = (SELECT id\n                                                                  FROM teszt\n                                                                  WHERE nev = :lname)");
    $stmt->bindParam(':uname', $userName);
    $stmt->bindParam(':lname', $leckeName);
    $stmt->execute();
    $row_count = $stmt->rowCount();
    if ($row_count == 0) {
        array_push($graphData, 0);
    } else {
        array_push($graphData, round($stmt->fetchColumn() * 100));
    }
    /* second column for the graph */
    array_push($graphData, round(0.25 * 100));
    /* third column for the graph */
    $ret = db_getUserDataRaw($userId, null, null, null);
    $cardId = $ret['kartyaId'];
    $stmt = $conn->prepare("SELECT cegId\n                            FROM kartya\n                            WHERE kartya_id = :kartya");
    $stmt->bindParam(':kartya', $cardId);
    $stmt->execute();
    $companyId = $stmt->fetchColumn();
    $stmt = $conn->prepare("SELECT AVG(szazalek)\n                            FROM kitolt\n                            WHERE felhNev IN (SELECT felh_nev\n                                              FROM felhasznalo\n                                              WHERE kartyaId IN (SELECT kartya_id\n                                                                 FROM kartya\n                                                                 WHERE cegId = :compId)) AND tesztId = (SELECT id\n                                                                                                        FROM teszt\n                                                                                                        WHERE nev = :lname)");
    $stmt->bindParam(':compId', $companyId);
    $stmt->bindParam(':lname', $leckeName);
    $stmt->execute();
    if ($row_count == 0) {
        array_push($graphData, 0);
    } else {
        array_push($graphData, round($stmt->fetchColumn() * 100));
    }
    return $graphData;
}
Esempio n. 5
0
/**
 * Adds a new record in table lzaro_kitolt into the database.
 * @param $userId
 * @param $timeWindowName
 * @param $testName
 * @param $time
 * @return integer containing the last inserted id, or FALSE on failure.
 */
function db_addNewRecordInTableLzaro_kitolt($userId, $timeWindowName, $testName, $time)
{
    $ret = db_getUserDataRaw($userId, null, null, null);
    if (empty($ret)) {
        return FALSE;
    } else {
        $userName = $ret['felh_nev'];
    }
    $tid = db_getTimeWindowIdFromName($timeWindowName);
    $ret = db_getTestId($testName);
    if (empty($ret)) {
        return FALSE;
    } else {
        $testId = $ret;
    }
    global $conn;
    $stmt = $conn->prepare("INSERT INTO lzaro_kitolt\n                            VALUES (NULL, :uname, :tid, :testId, :secs, NOW())");
    $stmt->bindParam(':uname', $userName);
    $stmt->bindParam(':tid', $tid);
    $stmt->bindParam(':testId', $testId);
    $stmt->bindParam(':secs', $time);
    $stmt->execute();
    return $conn->lastInsertId();
}