Esempio n. 1
0
/**
 * Initializing queries utilities
 */
$QUERIES = new Queries();
switch ($_REQUEST['action']) {
    /**
     * Checking user permission and data validity. Check fram number
     * camera id validity
     * 
     * @return boolean : true if user can proceed
     */
    case "check-gt-login":
        $to_return = true;
        if (!isset($_SESSION["user"])) {
            if ($_REQUEST["user"] != "" && $_REQUEST["camera_id"] != "" && $_REQUEST["password"] != "" && ($_REQUEST["frame_id"] != "number" || $_REQUEST["frame_number"] != "")) {
                $sql = $QUERIES->getUserIdFromName($_REQUEST['user'], $_REQUEST["password"]);
                $result = mysql_query($sql) or $to_return = false;
                if (mysql_num_rows($result) == 0) {
                    $to_return = false;
                } else {
                    while ($row = mysql_fetch_array($result)) {
                        $_SESSION["user"] = $row["userid"];
                        $_SESSION["camera_id"] = $_REQUEST["camera_id"];
                        $sql = $QUERIES->countNoGroupsByUserName($_REQUEST['user']);
                        $result_zero = mysql_query($sql) or $to_return = false;
                        if (mysql_num_rows($result_zero) == 0) {
                            $sql_1 = $QUERIES->getUserIdFromName($_REQUEST['user']);
                            $result_1 = mysql_query($sql_1) or $to_return = false;
                            while ($returned_id = mysql_fetch_array($result_1)) {
                                $sql_2 = $QUERIES->insertGroup(0, 'No group', 0, $returned_id["userid"]);
                                $final_result = mysql_query($sql_2) or $to_return = false;