Exemple #1
0
function showTypes($con)
{
    // Select all the rows in the markers table
    $query = "SELECT \n" . "  * \n" . "FROM \n" . "  gps_type gt \n" . "ORDER BY \n" . "  gt.gps_type_id;";
    $result = mysqli_query($con, $query);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    echo "<table border='1' style='width:100%' class='table'>\n";
    echo "<thead><tr>\n";
    echo "<th>id</th>\n";
    echo "<th>name</th>\n";
    echo "<th>desc</th>\n";
    echo "<th>image</th>\n";
    echo "<th>icon</th>\n";
    echo "<th>delete</th>\n";
    echo "</tr></thead>\n";
    echo "<tbody>\n";
    while ($row = @mysqli_fetch_assoc($result)) {
        echo "<td>" . $row['gps_type_id'] . "</td>\n";
        echo getTableRow($row, "gps_type_name", "gps_type", "gps_type_id", "", "");
        echo getTableRow($row, "gps_type_desc", "gps_type", "gps_type_id", "", "");
        echo getTableRow($row, "gps_type_image", "gps_type", "gps_type_id", "", "");
        echo getTableRow($row, "gps_type_icon", "gps_type", "gps_type_id", "", "");
        echo "<td><a onclick='updateDelete(\"gps_entries\", \"gps_type_id\", \"NULL\", \"gps_type\", \"gps_type_id=" . $row['gps_type_id'] . "\", true)' href='javascript:void(0);'>[X]</a></td>\n";
        echo "</tr>\n";
    }
    echo "</tbody>\n";
    echo "</table>\n";
}
Exemple #2
0
function showDevices($con)
{
    // Select all the rows in the markers table
    $query = "SELECT \n" . "  gd.*, \n" . "  gowner.gps_owner_name as gps_owner_name \n" . "FROM \n" . "  gps_device gd \n" . "  left join gps_owner gowner on gd.gps_device_id = gowner.gps_owner_id \n" . "ORDER BY \n" . "  gd.gps_device_id;";
    $result = mysqli_query($con, $query);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    echo "<table border='1' style='width:100%' class='table'>\n";
    echo "<thead><tr>\n";
    echo "<th>id</th>\n";
    echo "<th>device id</th>\n";
    echo "<th>name</th>\n";
    echo "<th>desc</th>\n";
    echo "<th>comment</th>\n";
    echo "<th>owner</th>\n";
    echo "<th>delete</th>\n";
    echo "</tr></thead>\n";
    echo "<tbody>\n";
    while ($row = @mysqli_fetch_assoc($result)) {
        $ownersSQL = "SELECT gps_owner_id, gps_owner_name from gps_owner \n" . "order by gps_owner_id";
        $ownersDropDown = buildDropDown($con, $ownersSQL, $row['gps_owner_id'], "owner", "gps_device", "gps_owner_id", "gps_owner_name", "gps_device_id", $row['gps_device_id'], true);
        echo "<td>" . $row['gps_device_id'] . "</td>\n";
        echo getTableRow($row, "gps_device_local_id", "gps_device", "gps_device_id", "", "");
        echo getTableRow($row, "gps_device_name", "gps_device", "gps_device_id", "", "");
        echo getTableRow($row, "gps_device_desc", "gps_device", "gps_device_id", "", "");
        echo getTableRow($row, "gps_device_comment", "gps_device", "gps_device_id", "", "");
        echo "<td>" . $ownersDropDown . "</td>\n";
        echo "<td><a onclick='updateDelete(\"gps_entries\", \"gps_device_id\", \"NULL\", \"gps_device\", \"gps_device_id=" . $row['gps_device_id'] . "\", true)' href='javascript:void(0);'>[X]</a></td>\n";
        echo "</tr>\n";
    }
    echo "</tbody>\n";
    echo "</table>\n";
}
Exemple #3
0
function showPaths($con)
{
    // Select all the rows in the markers table
    $query = "SELECT \n" . "  * \n" . "FROM \n" . "  gps_path gp \n" . "ORDER BY \n" . "  gp.gps_path_id;";
    $result = mysqli_query($con, $query);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    echo "<table border='1' style='width:100%' class='table'>\n";
    echo "<thead><tr>\n";
    echo "<th>id</th>\n";
    echo "<th>name</th>\n";
    echo "<th>desc</th>\n";
    //echo "<th>type</th>\n";
    echo "<th>status</th>\n";
    echo "<th>color</th>\n";
    echo "<th>delete</th>\n";
    echo "</tr></thead>\n";
    echo "<tbody>\n";
    while ($row = @mysqli_fetch_assoc($result)) {
        echo "<td>" . $row['gps_path_id'] . "</td>\n";
        echo getTableRow($row, "gps_path_name", "gps_path", "gps_path_id", "", "");
        echo getTableRow($row, "gps_path_desc", "gps_path", "gps_path_id", "", "");
        //echo "<td>" . $row['gps_type_id']    . "</td>\n";
        echo "<td>\n" . buildSetPathStatusDropDown($row['gps_path_status'], $row['gps_path_id']) . "</td>\n";
        echo getTableRow($row, "gps_path_color", "gps_path", "gps_path_id", "", "");
        echo "<td><a onclick='updateDelete(\"gps_entries\", \"gps_path_id\", \"NULL\", \"gps_path\", \"gps_path_id=" . $row['gps_path_id'] . "\", true)' href='javascript:void(0);'>[X]</a></td>\n";
        echo "</tr>\n";
    }
    echo "</tbody>\n";
    echo "</table>\n";
}
Exemple #4
0
function showGroups($con)
{
    // Select all the rows in the markers table
    $query = "SELECT \n" . "  user_type_id, \n" . "  user_type_name, \n" . "  user_type_desc \n" . "FROM \n" . "  user_types \n" . "ORDER BY \n" . "  user_type_id;";
    $result = mysqli_query($con, $query);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    echo "<table border='1' style='width:100%' class='table'>\n";
    echo "<thead><tr>\n";
    echo "<th>id</th>\n";
    echo "<th>name</th>\n";
    echo "<th>desc</th>\n";
    echo "<th>delete</th>\n";
    echo "</tr></thead>\n";
    echo "<tbody>\n";
    while ($row = @mysqli_fetch_assoc($result)) {
        echo "<td>" . $row['user_type_id'] . "</td>\n";
        echo getTableRow($row, "user_type_name", "user_types", "user_type_id", "", "");
        echo getTableRow($row, "user_type_desc", "user_types", "user_type_id", "", "");
        echo "<td><a onclick='deleteRecord(\"user_types\", \"user_type_id=" . $row['user_type_id'] . "\", true)' href='javascript:void(0);'>[X]</a></td>\n";
        echo "</tr>\n";
    }
    echo "</tbody>\n";
    echo "</table>\n";
}
Exemple #5
0
function showUsers($con)
{
    // Select all the rows in the markers table
    $query = "SELECT \n" . "  * \n" . "FROM \n" . "  users u \n" . "  left join user_types ut on u.user_type_id = ut.user_type_id \n" . "ORDER BY \n" . "  u.user_id;";
    $result = mysqli_query($con, $query);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    echo "<table border='1' style='width:100%' class='table'>\n";
    echo "<thead><tr>\n";
    echo "<th>id</th>\n";
    echo "<th>name</th>\n";
    echo "<th>type</th>\n";
    echo "<th>reset pass</th>\n";
    echo "<th>delete</th>\n";
    echo "</tr></thead>\n";
    echo "<tbody>\n";
    while ($row = @mysqli_fetch_assoc($result)) {
        $typeSQL = "SELECT user_type_id, user_type_name from user_types order by user_type_id";
        $typesDropDown = buildDropDown($con, $typeSQL, $row['user_type_id'], "type", "users", "user_type_id", "user_type_name", "user_id", $row['user_id'], false);
        echo "<td>" . $row['user_id'] . "</td>\n";
        echo getTableRow($row, "user_name", "users", "user_id", "", "");
        echo "<td>" . $typesDropDown . "</td>\n";
        echo "<td><a onclick='newPass(" . $row['user_id'] . ")' href='javascript:void(0);'>reset pass</a></td>\n";
        echo "<td><a onclick='deleteRecord(\"users\", \"user_id=" . $row['user_id'] . "\", true)' href='javascript:void(0);'>[X]</a></td>\n";
        echo "</tr>\n";
    }
    echo "</tbody>\n";
    echo "</table>\n";
}
Exemple #6
0
function showMarkers($con, $sort = "")
{
    // Select all the rows in the markers table
    $query = "SELECT \n" . "  ge.*, \n" . "  gp.gps_path_name as gps_path_name, \n" . "  gt.gps_type_name as gps_type_name \n" . "FROM \n" . "  gps_entries ge \n" . "  left join gps_path gp on ge.gps_path_id = gp.gps_path_id \n" . "  left join gps_type gt on ge.gps_type_id = gt.gps_type_id \n" . "ORDER BY \n" . $sort . "  ge.gps_date, ge.gps_entry_id;";
    $result = mysqli_query($con, $query);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    echo "<table border='1' style='width:100%' class='table'>\n";
    echo "<thead><tr>\n";
    //echo "<td>hide</td>\n";
    echo "<th>id</th>\n";
    echo "<th>date</th>\n";
    echo "<th>name</th>\n";
    echo "<th>address</th>\n";
    echo "<th>lat</th>\n";
    echo "<th>long</th>\n";
    echo "<th>status</th>\n";
    echo "<th>path</th>\n";
    echo "<th>type</th>\n";
    echo "<th>device</th>\n";
    echo "<th>delete</th>\n";
    echo "</thead></tr>\n";
    echo "<tbody>\n";
    //TODO Add marker path sequence values
    while ($row = @mysqli_fetch_assoc($result)) {
        $pathSQL = "SELECT gps_path_id, gps_path_name from gps_path \n" . "where (gps_path_status <> 'H' OR gps_path_status is null) \n" . "order by gps_path_id";
        $pathsDropDown = buildDropDown($con, $pathSQL, $row['gps_path_id'], "path", "gps_entries", "gps_path_id", "gps_path_name", "gps_entry_id", $row['gps_entry_id'], true);
        //load types drop down
        $typesSQL = "SELECT gps_type_id, gps_type_name \n" . "from gps_type \n" . "order by gps_type_id";
        $typesDropDown = buildDropDown($con, $typesSQL, $row['gps_type_id'], "type", "gps_entries", "gps_type_id", "gps_type_name", "gps_entry_id", $row['gps_entry_id'], true);
        //load device drop down
        $deviceSQL = "SELECT gps_device_id, gps_device_name from gps_device \n" . "order by gps_device_id";
        $deviceDropDown = buildDropDown($con, $deviceSQL, $row['gps_device_id'], "device", "gps_entries", "gps_device_id", "gps_device_name", "gps_entry_id", $row['gps_entry_id'], true);
        echo "<td><a href='view.php?marker_id=" . $row['gps_entry_id'] . "&zoom=15&center=" . $row['gps_latitude'] . "," . $row['gps_longitude'] . "&edit=true'>" . $row['gps_entry_id'] . "</a></td>\n";
        echo getTableRow($row, "gps_date", "gps_entries", "gps_entry_id", "", "");
        echo getTableRow($row, "gps_name", "gps_entries", "gps_entry_id", "", "");
        echo getTableRow($row, "gps_address1", "gps_entries", "gps_entry_id", "", "");
        echo getTableRow($row, "gps_latitude", "gps_entries", "gps_entry_id", "", "");
        echo getTableRow($row, "gps_longitude", "gps_entries", "gps_entry_id", "", "");
        echo "<td>\n" . buildSetStatusDropDown($row['gps_status'], $row['gps_entry_id']) . "</td>\n";
        echo "<td>" . $pathsDropDown . "</td>\n";
        echo "<td>" . $typesDropDown . "</td>\n";
        echo "<td>" . $deviceDropDown . "</td>\n";
        echo "<td><a onclick='deleteRecord(\"gps_entries\", \"gps_entry_id=" . $row['gps_entry_id'] . "\", true)' href='javascript:void(0);'>[X]</a></td>\n";
        echo "</tr>\n";
    }
    echo "</tbody>\n";
    echo "</table>\n";
}
Exemple #7
0
function showOwners($con)
{
    // Select all the rows in the markers table
    $query = "SELECT \n" . "  * \n" . "FROM \n" . "  gps_owner gowner \n" . "ORDER BY \n" . "  gowner.gps_owner_id;";
    $result = mysqli_query($con, $query);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    echo "<table border='1' style='width:100%' class='table'>\n";
    echo "<thead><tr>\n";
    echo "<th>id</th>\n";
    echo "<th>name</th>\n";
    echo "<th>desc</th>\n";
    echo "<th>email</th>\n";
    echo "<th>address</th>\n";
    echo "<th>website</th>\n";
    echo "<th>phone</th>\n";
    echo "<th>Devices</th>\n";
    echo "<th>delete</th>\n";
    echo "</tr></thead>\n";
    echo "<tbody>\n";
    while ($row = @mysqli_fetch_assoc($result)) {
        echo "<td>" . $row['gps_owner_id'] . "</td>\n";
        echo getTableRow($row, "gps_owner_name", "gps_owner", "gps_owner_id", "", "");
        echo getTableRow($row, "gps_owner_desc", "gps_owner", "gps_owner_id", "", "");
        echo getTableRow($row, "gps_owner_email", "gps_owner", "gps_owner_id", "", "");
        echo getTableRow($row, "gps_owner_address", "gps_owner", "gps_owner_id", "", "");
        echo getTableRow($row, "gps_owner_website", "gps_owner", "gps_owner_id", "", " <a href='http://" . $row['gps_owner_website'] . "'>[GO]</a>");
        echo getTableRow($row, "gps_owner_phone", "gps_owner", "gps_owner_id", "", "");
        $devices = getDeviceNamesByOwner($con, $row['gps_owner_id']);
        echo "<td>" . $devices . "</td>\n";
        echo "<td><a onclick='updateDelete(\"gps_device\", \"gps_owner_id\", \"NULL\", \"gps_owner\", \"gps_owner_id=" . $row['gps_owner_id'] . "\", true)' href='javascript:void(0);'>[X]</a></td>\n";
        echo "</tr>\n";
    }
    echo "</tbody>\n";
    echo "</table>\n";
}
Exemple #8
0
function getQuestionRow($quizId, $sectionId, $questionId)
{
    return getTableRow('quiz_questions', "`page_modulecomponentid` = '{$quizId}' AND `quiz_sectionid` = '{$sectionId}' AND `quiz_questionid` = '{$questionId}'");
}
function processGetContestResultsRequest($request)
{
    $prfx = DB_PREFIX;
    //get $is_anonymous, $contest_id, $user_contest_row, $user_contest_start_time
    if (!is_null($request->sessionID)) {
        $is_anonymous = false;
        $user_contest_row = RequestUtils::testSession($request->sessionID);
        $contest_id = RequestUtils::getRequestedContest($request->contestID, $user_contest_row['contest_id'], $user_contest_row['user_type']);
        if ($contest_id < 0) {
            throwBusinessLogicError(14);
        }
        $user_contest_start_time = DateMySQLToPHP($user_contest_row['contest_start']);
        $user_contest_finish_time = DateMySQLToPHP($user_contest_row['contest_finish']);
    } else {
        $is_anonymous = true;
        $contest_id = $request->contestID;
        $user_contest_start_time = null;
        //contest was not started for anonymous
        $user_contest_finish_time = null;
        //and was not finished
    }
    //get $serialized_contest_settings
    $need_request_for_contest_data = $is_anonymous || $user_contest_row['user_type'] === 'SuperAdmin';
    if ($need_request_for_contest_data) {
        if ($contest_id === 0) {
            throwBusinessLogicError(14);
        }
        $contest_row = Data::getRow(sprintf("SELECT *\r\n             FROM {$prfx}contest\r\n             WHERE id=%s\r\n            ", Data::quote_smart($contest_id)));
        if (!$contest_row) {
            throwBusinessLogicError(14);
        }
        $serialized_contest_settings = $contest_row['settings'];
    } else {
        $serialized_contest_settings = $user_contest_row['settings'];
    }
    //get $contest_settings
    $contest_settings = Data::_unserialize($serialized_contest_settings);
    //get $is_admin
    $is_admin = !$is_anonymous && ($user_contest_row['user_type'] === 'SuperAdmin' || $user_contest_row['user_type'] === 'ContestAdmin');
    //get $permission
    $ctime = getCurrentContestTime($contest_settings, $user_contest_start_time, $user_contest_finish_time);
    if (!$is_admin) {
        if ($ctime['interval'] === 'before') {
            throwBusinessLogicError(19);
        }
        if ($ctime['interval'] === 'contest' && !$ctime['is_ending']) {
            $permission = $contest_settings->resultsAccessPolicy->contestPermission;
        } else {
            if ($ctime['is_ending']) {
                $permission = $contest_settings->resultsAccessPolicy->contestEndingPermission;
            } else {
                if ($ctime['interval'] === 'after' && !$ctime['is_ending']) {
                    $permission = $contest_settings->resultsAccessPolicy->afterContestPermission;
                }
            }
        }
    } else {
        $permission = 'FullAccess';
    }
    //test rights
    if ($permission === 'NoAccess') {
        throwBusinessLogicError(0);
    }
    if ($is_anonymous && $permission === "OnlySelfResults") {
        throwBusinessLogicError(0);
    }
    //get problem rows
    $all_problems_rows = Data::getRows(sprintf("SELECT *\r\n                                    FROM {$prfx}problem\r\n                                    WHERE {$prfx}problem.contest_id=%s\r\n                                    ORDER BY {$prfx}problem.contest_pos ASC", Data::quote_smart($contest_id)));
    //get users rows
    if ($permission === 'FullAccess') {
        $all_users_rows = Data::getRows(sprintf("SELECT *\r\n                                     FROM {$prfx}user\r\n                                     WHERE contest_id=%s", Data::quote_smart($contest_id)));
    } else {
        /* if $permission === 'OnlySelfResults'*/
        $all_users_rows = $user_contest_row;
    }
    //create result
    $result = new GetContestResultsResponse();
    //fill columns ids
    $result->headers = array();
    $result->minorHeaders = array();
    //the first column with 'user_id' and 'login'
    if ($is_admin) {
        $result->headers[] = 'admin info';
        $result->minorHeaders[] = array('id', 'login');
    }
    //column with participant data
    $result->headers[] = 'participant';
    //get participant subcolumns
    $data_subs = array();
    $contest_user_data = $contest_settings->data;
    if ($contest_user_data) {
        foreach ($contest_settings->data as $df) {
            if ($is_admin || $df->showInResult) {
                $data_subs[] = $df->data;
            }
        }
    }
    $result->minorHeaders[] = $data_subs;
    //columns with problems
    $problem_ids = array();
    $problem_cols = array();
    while ($problem_row = Data::getNextRow($all_problems_rows)) {
        $problem_ids[] = $problem_row['id'];
        $result->headers[] = $problem_row['name'];
        $col_names = Data::_unserialize($problem_row['column_names']);
        $result->minorHeaders[] = $col_names;
        $problem_cols[] = $col_names;
    }
    //fill results table
    $result->table = array();
    if ($permission === 'OnlySelfResults') {
        $result->table[] = getTableRow($user_contest_row, $is_admin, $problem_ids, $problem_cols, $contest_settings->data);
        $result->userLine = 0;
    } else {
        $ind = 0;
        $result->userLine = -1;
        while ($user_row = Data::getNextRow($all_users_rows)) {
            $result->table[] = getTableRow($user_row, $is_admin, $problem_ids, $problem_cols, $contest_settings->data);
            if ($user_row['id'] == $user_contest_row['id']) {
                $result->userLine = $ind;
            }
            $ind++;
        }
    }
    return $result;
}