当前位置: 首页>>代码示例>>PHP>>正文


PHP F_db_query函数代码示例

本文整理汇总了PHP中F_db_query函数的典型用法代码示例。如果您正苦于以下问题:PHP F_db_query函数的具体用法?PHP F_db_query怎么用?PHP F_db_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了F_db_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: F_get_user_selectbox

/**
 * Returns a user select box
 * @param $label (string) Field label.
 * @param $user_id (int) selected user ID.
 * @param $fieldname (string) field name.
 * @return array containing user's groups IDs
 */
function F_get_user_selectbox($label, $user_id = 0, $fieldname = 'user_id')
{
    global $l, $db;
    require_once '../config/tce_config.php';
    $out = '';
    $out .= '<div class="row">' . K_NEWLINE;
    $out .= '<span class="label">' . K_NEWLINE;
    $out .= '<label for="' . $fieldname . '">' . $label . '</label>' . K_NEWLINE;
    $out .= '</span>' . K_NEWLINE;
    $out .= '<span class="formw">' . K_NEWLINE;
    $out .= '<select name="' . $fieldname . '" id="' . $fieldname . '" size="0">' . K_NEWLINE;
    $out .= '<option value="0"';
    if ($user_id == 0) {
        $out .= ' selected="selected"';
    }
    $out .= '></option>' . K_NEWLINE;
    $sql = 'SELECT user_id, user_lastname, user_firstname, user_name FROM ' . K_TABLE_USERS . ' WHERE (user_id>1)';
    if ($_SESSION['session_user_level'] < K_AUTH_ADMINISTRATOR) {
        // filter for level
        $sql .= ' AND ((user_level<' . $_SESSION['session_user_level'] . ') OR (user_id=' . $_SESSION['session_user_id'] . '))';
        // filter for groups
        $sql .= ' AND user_id IN (SELECT tb.usrgrp_user_id
			FROM ' . K_TABLE_USERGROUP . ' AS ta, ' . K_TABLE_USERGROUP . ' AS tb
			WHERE ta.usrgrp_group_id=tb.usrgrp_group_id
				AND ta.usrgrp_user_id=' . intval($_SESSION['session_user_id']) . '
				AND tb.usrgrp_user_id=user_id)';
    }
    $sql .= ' ORDER BY user_lastname, user_firstname, user_name';
    if ($r = F_db_query($sql, $db)) {
        $countitem = 1;
        while ($m = F_db_fetch_array($r)) {
            $out .= '<option value="' . $m['user_id'] . '"';
            if ($m['user_id'] == $user_id) {
                $out .= ' selected="selected"';
            }
            $out .= '>' . $countitem . '. ' . htmlspecialchars($m['user_lastname'] . ' ' . $m['user_firstname'] . ' - ' . $m['user_name'] . '', ENT_NOQUOTES, $l['a_meta_charset']) . '</option>' . K_NEWLINE;
            $countitem++;
        }
    } else {
        $out .= '</select></span></div>' . K_NEWLINE;
        F_display_db_error();
    }
    $out .= '</select>' . K_NEWLINE;
    $out .= '</span>' . K_NEWLINE;
    $out .= '</div>' . K_NEWLINE;
    return $out;
}
开发者ID:jayadevn,项目名称:RackMap,代码行数:54,代码来源:tce_functions_user_select.php

示例2: F_escape_sql

$thispage_description = '';
require_once '../code/tce_page_header.php';
$sql = 'SELECT *
	FROM ' . K_TABLE_USERS . '
	WHERE (user_verifycode=\'' . F_escape_sql($verifycode) . '\'
		AND user_id=\'' . $userid . '\'
		AND user_email=\'' . F_escape_sql($email) . '\')
		LIMIT 1';
if ($r = F_db_query($sql, $db)) {
    if ($m = F_db_fetch_array($r)) {
        // update user level
        $sqlu = 'UPDATE ' . K_TABLE_USERS . ' SET
				user_level=\'1\',
				user_verifycode=NULL
				WHERE user_id=' . $userid . '';
        if (!($ru = F_db_query($sqlu, $db))) {
            F_display_db_error(false);
        } else {
            F_print_error('MESSAGE', $l['m_user_registration_ok']);
            echo K_NEWLINE;
            echo '<div class="container">' . K_NEWLINE;
            if (K_OTP_LOGIN) {
                require_once '../../shared/tcpdf/tcpdf_barcodes_2d.php';
                $host = preg_replace('/[h][t][t][p][s]?[:][\\/][\\/]/', '', K_PATH_HOST);
                $qrcode = new TCPDF2DBarcode('otpauth://totp/' . $m['user_name'] . '@' . $host . '?secret=' . $m['user_otpkey'], 'QRCODE,H');
                echo '<p>' . $l['m_otp_qrcode'] . '</p>' . K_NEWLINE;
                echo '<h2>' . $m['user_otpkey'] . '</h2>' . K_NEWLINE;
                echo '<div style="margin:40px 40px 40px 40px;">' . K_NEWLINE;
                echo $qrcode->getBarcodeHTML(6, 6, 'black');
                echo '</div>' . K_NEWLINE;
            }
开发者ID:jayadevn,项目名称:RackMap,代码行数:31,代码来源:tce_user_verification.php

示例3: F_csv_export_users

/**
 * Export all users to CSV grouped by users' groups.
 * @author Nicola Asuni
 * @since 2006-03-30
 * @return CSV data
 */
function F_csv_export_users()
{
    global $l, $db;
    require_once '../config/tce_config.php';
    $csv = '';
    // CSV data to be returned
    // print column names
    $csv .= 'user_id';
    $csv .= K_TAB . 'user_name';
    $csv .= K_TAB . 'user_password';
    $csv .= K_TAB . 'user_email';
    $csv .= K_TAB . 'user_regdate';
    $csv .= K_TAB . 'user_ip';
    $csv .= K_TAB . 'user_firstname';
    $csv .= K_TAB . 'user_lastname';
    $csv .= K_TAB . 'user_birthdate';
    $csv .= K_TAB . 'user_birthplace';
    $csv .= K_TAB . 'user_regnumber';
    $csv .= K_TAB . 'user_ssn';
    $csv .= K_TAB . 'user_level';
    $csv .= K_TAB . 'user_verifycode';
    $csv .= K_TAB . 'user_groups';
    $sql = 'SELECT * FROM ' . K_TABLE_USERS . ' WHERE (user_id>1)';
    if ($_SESSION['session_user_level'] < K_AUTH_ADMINISTRATOR) {
        // filter for level
        $sql .= ' AND ((user_level<' . $_SESSION['session_user_level'] . ') OR (user_id=' . $_SESSION['session_user_id'] . '))';
        // filter for groups
        $sql .= ' AND user_id IN (SELECT tb.usrgrp_user_id
			FROM ' . K_TABLE_USERGROUP . ' AS ta, ' . K_TABLE_USERGROUP . ' AS tb
			WHERE ta.usrgrp_group_id=tb.usrgrp_group_id
				AND ta.usrgrp_user_id=' . intval($_SESSION['session_user_id']) . '
				AND tb.usrgrp_user_id=user_id)';
    }
    $sql .= ' ORDER BY user_lastname,user_firstname,user_name';
    if ($r = F_db_query($sql, $db)) {
        while ($m = F_db_fetch_array($r)) {
            $csv .= K_NEWLINE . $m['user_id'];
            $csv .= K_TAB . $m['user_name'];
            $csv .= K_TAB;
            // password cannot be exported because is encrypted
            $csv .= K_TAB . $m['user_email'];
            $csv .= K_TAB . $m['user_regdate'];
            $csv .= K_TAB . $m['user_ip'];
            $csv .= K_TAB . $m['user_firstname'];
            $csv .= K_TAB . $m['user_lastname'];
            $csv .= K_TAB . substr($m['user_birthdate'], 0, 10);
            $csv .= K_TAB . $m['user_birthplace'];
            $csv .= K_TAB . $m['user_regnumber'];
            $csv .= K_TAB . $m['user_ssn'];
            $csv .= K_TAB . $m['user_level'];
            $csv .= K_TAB . $m['user_verifycode'];
            $csv .= K_TAB;
            $grp = '';
            // comma separated list of user's groups
            $sqlg = 'SELECT *
				FROM ' . K_TABLE_GROUPS . ', ' . K_TABLE_USERGROUP . '
				WHERE usrgrp_group_id=group_id
					AND usrgrp_user_id=' . $m['user_id'] . '
				ORDER BY group_name';
            if ($rg = F_db_query($sqlg, $db)) {
                while ($mg = F_db_fetch_array($rg)) {
                    $grp .= $mg['group_name'] . ',';
                }
            } else {
                F_display_db_error();
            }
            if (!empty($grp)) {
                // add user's groups removing last comma
                $csv .= substr($grp, 0, -1);
            }
        }
    } else {
        F_display_db_error();
    }
    return $csv;
}
开发者ID:BGCX261,项目名称:zjxt-svn-to-git,代码行数:82,代码来源:tce_csv_users.php

示例4: F_getUserTestStat

/**
 * Returns test data structure for selected user:
 * <ul>
 * <li>$data['all'] = total number of questions</li>
 * <li>$data['right'] = number of right answers for multiple-choice questions (score &gt; 50% max points)</li>
 * <li>$data['wrong'] = number of wrong answers for multiple-choice questions (score &lt;= 50% max points)</li>
 * <li>$data['textright'] = number of right answers for free-text questions (score &gt; 50% max points)</li>
 * <li>$data['textwrong'] = number of wrong answers for free-text questions (score &lt;= 50% max points)</li>
 * <li>$data['unanswered'] = total number of unanswered questions</li>
 * <li>$data['undisplayed'] = total number of undisplayed questions</li>
 * <li>$data['basic_score'] = basic points for each difficulty level of questions</li>
 * <li>$data['max_score'] = maximum test score</li>
 * <li>$data['score'] = user's score</li>
 * <li>$data['comment'] = user's test comment</li>
 * <li>$data['time'] = user's test start time</li>
 * </ul>
 * @param $test_id (int) test ID
 * @param $user_id (int) user's test ID
 * return array $data
 */
function F_getUserTestStat($test_id, $user_id)
{
    require_once '../config/tce_config.php';
    global $db, $l;
    $test_id = intval($test_id);
    $user_id = intval($user_id);
    $data = array();
    // get test default scores
    $sql = 'SELECT test_score_right, test_max_score, test_score_threshold
		FROM ' . K_TABLE_TESTS . '
		WHERE test_id=' . $test_id . '';
    if ($r = F_db_query($sql, $db)) {
        if ($m = F_db_fetch_array($r)) {
            $data['basic_score'] = $m['test_score_right'];
            $data['max_score'] = $m['test_max_score'];
            $data['score_threshold'] = $m['test_score_threshold'];
        }
    } else {
        F_display_db_error();
    }
    // total number of questions
    $data['all'] = F_count_rows(K_TABLE_TESTS_LOGS . ', ' . K_TABLE_TEST_USER . ', ' . K_TABLE_QUESTIONS, 'WHERE testlog_testuser_id=testuser_id AND testlog_question_id=question_id AND testuser_test_id=' . $test_id . ' AND testuser_user_id=' . $user_id . '');
    // number of right answers
    $data['right'] = F_count_rows(K_TABLE_TESTS_LOGS . ', ' . K_TABLE_TEST_USER . ', ' . K_TABLE_QUESTIONS, 'WHERE testlog_testuser_id=testuser_id AND testlog_question_id=question_id AND testuser_test_id=' . $test_id . ' AND testuser_user_id=' . $user_id . ' AND testlog_score>((question_difficulty*' . $data['basic_score'] . ')/2)');
    // number of wrong answers
    $data['wrong'] = F_count_rows(K_TABLE_TESTS_LOGS . ', ' . K_TABLE_TEST_USER . ', ' . K_TABLE_QUESTIONS, 'WHERE testlog_testuser_id=testuser_id AND testlog_question_id=question_id AND testuser_test_id=' . $test_id . ' AND testuser_user_id=' . $user_id . ' AND testlog_score<=((question_difficulty*' . $data['basic_score'] . ')/2)');
    // total number of unanswered questions
    $data['unanswered'] = F_count_rows(K_TABLE_TESTS_LOGS . ', ' . K_TABLE_TEST_USER, 'WHERE testlog_testuser_id=testuser_id AND testuser_test_id=' . $test_id . ' AND testuser_user_id=' . $user_id . ' AND testlog_change_time IS NULL');
    // total number of undisplayed questions
    $data['undisplayed'] = F_count_rows(K_TABLE_TESTS_LOGS . ', ' . K_TABLE_TEST_USER, 'WHERE testlog_testuser_id=testuser_id AND testuser_test_id=' . $test_id . ' AND testuser_user_id=' . $user_id . ' AND testlog_display_time IS NULL');
    // number of free-text unrated questions
    $data['unrated'] = F_count_rows(K_TABLE_TESTS_LOGS . ', ' . K_TABLE_TEST_USER, 'WHERE testlog_testuser_id=testuser_id AND  testuser_test_id=' . $test_id . ' AND testuser_user_id=' . $user_id . ' AND testlog_score IS NULL');
    // get user's score
    $sql = 'SELECT SUM(testlog_score) AS total_score
		FROM ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_TEST_USER . '
		WHERE testlog_testuser_id=testuser_id
			AND testuser_user_id=' . $user_id . '
			AND testuser_test_id=' . $test_id . '
		GROUP BY testuser_id';
    if ($r = F_db_query($sql, $db)) {
        if ($m = F_db_fetch_array($r)) {
            $data['score'] = $m['total_score'];
        }
    } else {
        F_display_db_error();
    }
    // get user's test comment
    $data['comment'] = '';
    $sql = 'SELECT testuser_comment, testuser_creation_time
	FROM ' . K_TABLE_TEST_USER . '
	WHERE testuser_user_id=' . $user_id . '
		AND testuser_test_id=' . $test_id . '
	LIMIT 1';
    if ($r = F_db_query($sql, $db)) {
        if ($m = F_db_fetch_array($r)) {
            $data['comment'] = $m['testuser_comment'];
            $data['time'] = $m['testuser_creation_time'];
        }
    } else {
        F_display_db_error();
    }
    $sql = 'SELECT testuser_id, testuser_creation_time, testuser_status, MAX(testlog_change_time) AS test_end_time
		FROM ' . K_TABLE_TEST_USER . ', ' . K_TABLE_TESTS_LOGS . '
		WHERE testlog_testuser_id=testuser_id
			AND testuser_test_id=' . $test_id . '
			AND testuser_user_id=' . $user_id . '
			AND testuser_status>0
		GROUP BY testuser_id, testuser_creation_time, testuser_status
		LIMIT 1';
    if ($r = F_db_query($sql, $db)) {
        if ($m = F_db_fetch_array($r)) {
            $data['test_start_time'] = $m['testuser_creation_time'];
            $data['test_end_time'] = $m['test_end_time'];
            $data['testuser_id'] = $m['testuser_id'];
            $data['testuser_status'] = $m['testuser_status'];
        }
    } else {
        F_display_db_error();
    }
    return $data;
//.........这里部分代码省略.........
开发者ID:BGCX261,项目名称:zjxt-svn-to-git,代码行数:101,代码来源:tce_functions_test_stats.php

示例5: F_decode_tcecode

                        $pdf->Ln();
                        $pdf->writeHTMLCell(0, $data_cell_height, PDF_MARGIN_LEFT + $data_cell_width_third, $pdf->GetY(), F_decode_tcecode($mq['question_description']), 1, 1, '', '');
                        if (K_ENABLE_QUESTION_EXPLANATION and !empty($mq['question_explanation'])) {
                            $pdf->Cell($data_cell_width_third, $data_cell_height, '', 0, 0, 'C', 0);
                            $pdf->SetFont('', 'BIU');
                            $pdf->Cell(0, $data_cell_height, $l['w_explanation'], 'LTR', 1, '', 0, '', 0);
                            $pdf->SetFont('', '');
                            $pdf->writeHTMLCell(0, $data_cell_height, PDF_MARGIN_LEFT + $data_cell_width_third, $pdf->GetY(), F_decode_tcecode($mq['question_explanation']), 'LRB', 1, '', '');
                        }
                        if ($show_answers) {
                            // display alternative answers
                            $sqla = 'SELECT *
								FROM ' . K_TABLE_ANSWERS . '
								WHERE answer_question_id=\'' . $mq['question_id'] . '\'
								ORDER BY answer_position,answer_isright DESC';
                            if ($ra = F_db_query($sqla, $db)) {
                                $idx = 0;
                                // count items
                                while ($ma = F_db_fetch_array($ra)) {
                                    $idx++;
                                    $answer_disabled = intval(!F_getBoolean($ma['answer_enabled']));
                                    $answer_isright = intval(F_getBoolean($ma['answer_isright']));
                                    $pdf->Cell($data_cell_width_third, $data_cell_height, '', 0, 0, 'C', 0);
                                    $pdf->Cell($data_cell_width_third, $data_cell_height, $idx, 1, 0, 'C', $answer_disabled);
                                    if ($mq['question_type'] != 4) {
                                        $pdf->Cell($data_cell_width_third / 2, $data_cell_height, $qright[$answer_isright], 1, 0, 'C', $answer_disabled);
                                    } else {
                                        $pdf->Cell($data_cell_width_third / 2, $data_cell_height, '', 1, 0, 'C', $answer_disabled);
                                    }
                                    if ($ma['answer_position'] > 0) {
                                        $pdf->Cell($data_cell_width_third, $data_cell_height, $ma['answer_position'], 1, 0, 'C', $answer_disabled);
开发者ID:BGCX261,项目名称:zjxt-svn-to-git,代码行数:31,代码来源:tce_pdf_all_questions.php

示例6: F_isUsedMediaFile

/**
 * Return true if the file is used on question or answer descriptions
 * @author Nicola Asuni
 * @param $file (string) the fiel to search
 * @return true if the file is used, false otherwise
 */
function F_isUsedMediaFile($file)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    // remove cache root from file path
    $file = substr($file, strlen(K_PATH_CACHE));
    // search on questions
    $sql = 'SELECT question_id FROM ' . K_TABLE_QUESTIONS . ' WHERE question_description LIKE \'%' . $file . '[/object%\' OR question_explanation LIKE \'%' . $file . '[/object%\' LIMIT 1';
    if ($r = F_db_query($sql, $db)) {
        if ($m = F_db_fetch_array($r)) {
            return true;
        }
    } else {
        F_display_db_error();
    }
    // search on answers
    $sql = 'SELECT answer_id FROM ' . K_TABLE_ANSWERS . ' WHERE answer_description LIKE \'%' . $file . '[/object%\' OR answer_explanation LIKE \'%' . $file . '[/object%\' LIMIT 1';
    if ($r = F_db_query($sql, $db)) {
        if ($m = F_db_fetch_array($r)) {
            return true;
        }
    } else {
        F_display_db_error();
    }
    return false;
}
开发者ID:jayadevn,项目名称:RackMap,代码行数:32,代码来源:tce_functions_filemanager.php

示例7: VALUES

                    if (isset($_POST['xuser_otpcode']) and !empty($_POST['xuser_otpcode']) and ($_POST['xuser_otpcode'] == F_getOTP($m['user_otpkey'], $mtime) or $_POST['xuser_otpcode'] == F_getOTP($m['user_otpkey'], $mtime - 30) or $_POST['xuser_otpcode'] == F_getOTP($m['user_otpkey'], $mtime + 30))) {
                        // check if this OTP token has been alredy used
                        $sqlt = 'SELECT cpsession_id FROM ' . K_TABLE_SESSIONS . ' WHERE cpsession_id=\'' . $_POST['xuser_otpcode'] . '\' LIMIT 1';
                        if ($rt = F_db_query($sqlt, $db)) {
                            if (!F_db_fetch_array($rt)) {
                                // Store this token on the session table to mark it as invalid for 5 minute (300 seconds)
                                $sqltu = 'INSERT INTO ' . K_TABLE_SESSIONS . ' (
									cpsession_id,
									cpsession_expiry,
									cpsession_data
									) VALUES (
									\'' . $_POST['xuser_otpcode'] . '\',
									\'' . date(K_TIMESTAMP_FORMAT, time() + 300) . '\',
									\'300\'
									)';
                                if (!F_db_query($sqltu, $db)) {
                                    F_display_db_error();
                                }
                                $otp = true;
                            }
                        }
                    }
                }
                if (!K_OTP_LOGIN or $otp) {
                    // sets some user's session data
                    $_SESSION['session_user_id'] = $m['user_id'];
                    $_SESSION['session_user_name'] = $m['user_name'];
                    $_SESSION['session_user_ip'] = getNormalizedIP($_SERVER['REMOTE_ADDR']);
                    $_SESSION['session_user_level'] = $m['user_level'];
                    $_SESSION['session_user_firstname'] = urlencode($m['user_firstname']);
                    $_SESSION['session_user_lastname'] = urlencode($m['user_lastname']);
开发者ID:jayadevn,项目名称:RackMap,代码行数:31,代码来源:tce_authorization.php

示例8: F_clone_child_objects

/**
 * Clone the specified object, including child objects
 * @param $source_obj_id (int) Source parent object ID.
 * @param $target_obj_id (int) Target parent object ID.
 */
function F_clone_child_objects($source_obj_id, $target_obj_id)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    $sql = 'SELECT * FROM ' . K_TABLE_OBJECTS . ', ' . K_TABLE_OBJECTS_MAP . ' WHERE omp_child_obj_id=obj_id AND omp_parent_obj_id=' . $source_obj_id . '';
    if ($r = F_db_query($sql, $db)) {
        while ($m = F_db_fetch_array($r)) {
            // create new object
            $sqli = 'INSERT INTO ' . K_TABLE_OBJECTS . ' (
				obj_obt_id,
				obj_name,
				obj_description,
				obj_label,
				obj_tag,
				obj_mnf_id,
				obj_owner_id,
				obj_tenant_id
				) VALUES (
				' . $m['obj_obt_id'] . ',
				\'' . $m['obj_name'] . '\',
				' . F_empty_to_null($m['obj_description']) . ',
				' . F_empty_to_null($m['obj_label']) . ',
				' . F_empty_to_null($m['obj_tag']) . ',
				' . F_empty_to_null($m['obj_mnf_id']) . ',
				' . F_empty_to_null($m['obj_owner_id']) . ',
				' . F_empty_to_null($m['obj_tenant_id']) . '
				)';
            if (!($ri = F_db_query($sqli, $db))) {
                F_display_db_error(false);
            } else {
                $child_obj_id = F_db_insert_id($db, K_TABLE_OBJECTS, 'obj_id');
                // add new object as child
                $sqli = 'INSERT INTO ' . K_TABLE_OBJECTS_MAP . ' (
					omp_parent_obj_id,
					omp_child_obj_id
					) VALUES (
					' . $target_obj_id . ',
					' . $child_obj_id . '
					)';
                if (!($ri = F_db_query($sqli, $db))) {
                    F_display_db_error(false);
                }
                F_clone_child_objects($m['obj_id'], $child_obj_id);
            }
        }
    } else {
        F_display_db_error();
    }
}
开发者ID:jayadevn,项目名称:RackMap,代码行数:54,代码来源:tce_functions_objects.php

示例9:

         } else {
             // all question types
             $subjlist .= '*';
         }
         $subjlist .= '</acronym> ';
         $subjlist .= '<acronym class="offbox" title="' . $l['h_question_difficulty'] . '">' . $m['tsubset_difficulty'] . '</acronym> ';
         $subjlist .= '<acronym class="offbox" title="' . $l['h_num_answers'] . '">' . $m['tsubset_answers'] . '</acronym> ';
         $subjlist .= ' <a href="' . $_SERVER['SCRIPT_NAME'] . '?menu_mode=deletesubject&amp;test_id=' . $test_id . '&amp;tsubset_id=' . $m['tsubset_id'] . '" title="' . $l['h_delete'] . '" class="deletebutton">' . $l['w_delete'] . '</a>';
         $subjlist .= '</li>' . K_NEWLINE;
         // update test_max_score
         $test_max_score_new += $test_score_right * $m['tsubset_difficulty'] * $m['tsubset_quantity'];
         if (isset($test_max_score) and $test_max_score_new != $test_max_score) {
             $test_max_score = $test_max_score_new;
             // update max score on test table
             $sqlup = 'UPDATE ' . K_TABLE_TESTS . ' SET test_max_score=' . $test_max_score . ' WHERE test_id=' . $test_id . '';
             if (!($rup = F_db_query($sqlup, $db))) {
                 F_display_db_error(false);
             }
         }
     }
     if (strlen($subjlist) > 0) {
         echo '<ul>' . K_NEWLINE . $subjlist . '</ul>' . K_NEWLINE;
     }
 } else {
     F_display_db_error();
 }
 echo '&nbsp;' . K_NEWLINE;
 echo $l['w_max_score'] . ': ' . $test_max_score_new;
 echo '<input type="hidden" name="test_max_score" id="test_max_score" value="' . $test_max_score_new . '" />';
 echo '</div>' . K_NEWLINE;
 echo '<br /><br />' . K_NEWLINE;
开发者ID:dungvu,项目名称:tcexam,代码行数:31,代码来源:tce_edit_test.php

示例10: F_syncUserGroups

/**
 * Sync user groups with the ones specified on the configuration file for alternate authentication.
 * @param $usrid (int) ID of the user to update.
 * @param $grpids (mixed) Group ID or comma separated list of group IDs (0=all available groups).
 * @author Nicola Asuni
 * @since 2012-09-11
 */
function F_syncUserGroups($usrid, $grpids)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    $usrid = intval($usrid);
    // select new group IDs
    $newgrps = array();
    if (is_string($grpids)) {
        // comma separated list of group IDs
        $newgrps = explode(',', $grpids);
        array_walk($newgrps, 'intval');
        $newgrps = array_unique($newgrps, SORT_NUMERIC);
    } elseif ($grpids == 0) {
        // all available groups
        $sqlg = 'SELECT group_id FROM ' . K_TABLE_GROUPS . '';
        if ($rg = F_db_query($sqlg, $db)) {
            while ($mg = F_db_fetch_array($rg)) {
                $newgrps[] = $mg['group_id'];
            }
        } else {
            F_display_db_error();
        }
    } elseif ($grpids > 0) {
        // single default group
        $newgrps[] = intval($grpids);
    }
    if (empty($newgrps)) {
        return;
    }
    // select existing group IDs
    $usrgrps = array();
    $sqlu = 'SELECT usrgrp_group_id FROM ' . K_TABLE_USERGROUP . ' WHERE usrgrp_user_id=' . $usrid . '';
    if ($ru = F_db_query($sqlu, $db)) {
        while ($mu = F_db_fetch_array($ru)) {
            $usrgrps[] = $mu['usrgrp_group_id'];
        }
    } else {
        F_display_db_error();
    }
    // extract missing groups
    $diffgrps = array_values(array_diff($newgrps, $usrgrps));
    // add missing groups
    foreach ($diffgrps as $grpid) {
        if ($grpid > 0) {
            // add user to default user groups
            $sql = 'INSERT INTO ' . K_TABLE_USERGROUP . ' (
				usrgrp_user_id,
				usrgrp_group_id
				) VALUES (
				\'' . $usrid . '\',
				\'' . $grpid . '\'
				)';
            if (!($r = F_db_query($sql, $db))) {
                F_display_db_error();
            }
        }
    }
}
开发者ID:dungvu,项目名称:tcexam,代码行数:65,代码来源:tce_functions_authorization.php

示例11: F_question_copy

/**
 * Copy selected question to another topic
 * @author Nicola Asuni
 * @since 2008-11-26
 * @param $question_id (int) question ID
 * @param $new_subject_id (int) new subject ID
 */
function F_question_copy($question_id, $new_subject_id)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    $question_id = intval($question_id);
    $new_subject_id = intval($new_subject_id);
    // check authorization
    $sql = 'SELECT subject_module_id FROM ' . K_TABLE_SUBJECTS . ' WHERE subject_id=' . $new_subject_id . ' LIMIT 1';
    if ($r = F_db_query($sql, $db)) {
        if ($m = F_db_fetch_array($r)) {
            $subject_module_id = $m['subject_module_id'];
            // check user's authorization for parent module
            if (!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $subject_module_id, 'module_user_id')) {
                return;
            }
        }
    } else {
        F_display_db_error();
        return;
    }
    $q = F_question_get_data($question_id);
    if ($q !== false) {
        if (K_DATABASE_TYPE == 'ORACLE') {
            $chksql = 'dbms_lob.instr(question_description,\'' . F_escape_sql($db, $q['question_description']) . '\',1,1)>0';
        } elseif (K_DATABASE_TYPE == 'MYSQL' and defined('K_MYSQL_QA_BIN_UNIQUITY') and K_MYSQL_QA_BIN_UNIQUITY) {
            $chksql = 'question_description=\'' . F_escape_sql($db, $q['question_description']) . '\' COLLATE utf8_bin';
        } else {
            $chksql = 'question_description=\'' . F_escape_sql($db, $q['question_description']) . '\'';
        }
        if (F_check_unique(K_TABLE_QUESTIONS, $chksql . ' AND question_subject_id=' . $new_subject_id . '')) {
            $sql = 'START TRANSACTION';
            if (!($r = F_db_query($sql, $db))) {
                F_display_db_error(false);
                break;
            }
            // adjust questions ordering
            if ($q['question_position'] > 0) {
                $sql = 'UPDATE ' . K_TABLE_QUESTIONS . ' SET
					question_position=question_position+1
					WHERE question_subject_id=' . $new_subject_id . '
						AND question_position>=' . $q['question_position'] . '';
                if (!($r = F_db_query($sql, $db))) {
                    F_display_db_error(false);
                    F_db_query('ROLLBACK', $db);
                    // rollback transaction
                }
            }
            $sql = 'INSERT INTO ' . K_TABLE_QUESTIONS . ' (
				question_subject_id,
				question_description,
				question_explanation,
				question_type,
				question_difficulty,
				question_enabled,
				question_position,
				question_timer,
				question_fullscreen,
				question_inline_answers,
				question_auto_next
				) VALUES (
				' . $new_subject_id . ',
				\'' . F_escape_sql($db, $q['question_description']) . '\',
				\'' . F_escape_sql($db, $q['question_explanation']) . '\',
				\'' . $q['question_type'] . '\',
				\'' . $q['question_difficulty'] . '\',
				\'' . $q['question_enabled'] . '\',
				' . F_zero_to_null($q['question_position']) . ',
				\'' . $q['question_timer'] . '\',
				\'' . $q['question_fullscreen'] . '\',
				\'' . $q['question_inline_answers'] . '\',
				\'' . $q['question_auto_next'] . '\'
				)';
            if (!($r = F_db_query($sql, $db))) {
                F_display_db_error(false);
            } else {
                $new_question_id = F_db_insert_id($db, K_TABLE_QUESTIONS, 'question_id');
            }
            // copy associated answers
            $sql = 'SELECT *
				FROM ' . K_TABLE_ANSWERS . '
				WHERE answer_question_id=' . $question_id . '';
            if ($r = F_db_query($sql, $db)) {
                while ($m = F_db_fetch_array($r)) {
                    $sqli = 'INSERT INTO ' . K_TABLE_ANSWERS . ' (
						answer_question_id,
						answer_description,
						answer_explanation,
						answer_isright,
						answer_enabled,
						answer_position,
						answer_keyboard_key
						) VALUES (
						' . $new_question_id . ',
//.........这里部分代码省略.........
开发者ID:dungvu,项目名称:tcexam,代码行数:101,代码来源:tce_functions_questions.php

示例12: F_session_gc

/**
 * Garbage collector.<br>
 * Deletes expired sessions.<br>
 * NOTE: while time() function returns a 32 bit integer, it works fine until year 2038.
 * @return int number of deleted sessions.
 */
function F_session_gc()
{
    global $db;
    $expiry_time = date(K_TIMESTAMP_FORMAT);
    $sql = 'DELETE FROM ' . K_TABLE_SESSIONS . ' WHERE cpsession_expiry<=\'' . $expiry_time . '\'';
    if (!($r = F_db_query($sql, $db))) {
        return FALSE;
    }
    return F_db_affected_rows($db, $r);
}
开发者ID:jayadevn,项目名称:RackMap,代码行数:16,代码来源:tce_functions_session.php

示例13: F_importOMRTestData

/**
 * Import user's test data from OMR.
 * @param $user_id (int) user ID.
 * @param $date (string) date-time field.
 * @param $omr_testdata (array) Array containing test data.
 * @param $omr_answers (array) Array containing test answers (from OMR).
 * @return boolean TRUE in case of success, FALSE otherwise.
 */
function F_importOMRTestData($user_id, $date, $omr_testdata, $omr_answers)
{
    require_once '../config/tce_config.php';
    require_once '../../shared/code/tce_functions_test.php';
    global $db, $l;
    // check arrays
    if (count($omr_testdata) > count($omr_answers) + 1) {
        // arrays must contain the same amount of questions
        return false;
    }
    $test_id = intval($omr_testdata[0]);
    $user_id = intval($user_id);
    $time = strtotime($date);
    $date = date(K_TIMESTAMP_FORMAT, $time);
    $dateanswers = date(K_TIMESTAMP_FORMAT, $time + 1);
    // check user's group
    if (F_count_rows(K_TABLE_USERGROUP . ', ' . K_TABLE_TEST_GROUPS . ' WHERE usrgrp_group_id=tstgrp_group_id AND tstgrp_test_id=' . $test_id . ' AND usrgrp_user_id=' . $user_id . ' LIMIT 1') == 0) {
        return false;
    }
    // get test data
    $testdata = F_getTestData($test_id);
    // 1. delete previous test data
    $sqld = 'DELETE FROM ' . K_TABLE_TEST_USER . ' WHERE testuser_test_id=' . $test_id . ' AND testuser_user_id=' . $user_id . '';
    if (!($rd = F_db_query($sqld, $db))) {
        F_display_db_error();
    }
    // 2. create new user's test entry
    // ------------------------------
    $sql = 'INSERT INTO ' . K_TABLE_TEST_USER . ' (
		testuser_test_id,
		testuser_user_id,
		testuser_status,
		testuser_creation_time,
		testuser_comment
		) VALUES (
		' . $test_id . ',
		' . $user_id . ',
		4,
		\'' . $date . '\',
		\'OMR\'
		)';
    if (!($r = F_db_query($sql, $db))) {
        F_display_db_error(false);
        return false;
    } else {
        // get inserted ID
        $testuser_id = F_db_insert_id($db, K_TABLE_TEST_USER, 'testuser_id');
    }
    // 3. create test log entries
    $num_questions = count($omr_testdata) - 1;
    // for each question on array
    for ($q = 1; $q <= $num_questions; ++$q) {
        $question_id = intval($omr_testdata[$q][0]);
        $num_answers = count($omr_testdata[$q][1]);
        // get question data
        $sqlq = 'SELECT question_type, question_difficulty FROM ' . K_TABLE_QUESTIONS . ' WHERE question_id=' . $question_id . ' LIMIT 1';
        if ($rq = F_db_query($sqlq, $db)) {
            if ($mq = F_db_fetch_array($rq)) {
                // question scores
                $question_right_score = $testdata['test_score_right'] * $mq['question_difficulty'];
                $question_wrong_score = $testdata['test_score_wrong'] * $mq['question_difficulty'];
                $question_unanswered_score = $testdata['test_score_unanswered'] * $mq['question_difficulty'];
                // add question
                $sqll = 'INSERT INTO ' . K_TABLE_TESTS_LOGS . ' (
					testlog_testuser_id,
					testlog_question_id,
					testlog_score,
					testlog_creation_time,
					testlog_display_time,
					testlog_reaction_time,
					testlog_order,
					testlog_num_answers
					) VALUES (
					' . $testuser_id . ',
					' . $question_id . ',
					' . $question_unanswered_score . ',
					\'' . $date . '\',
					\'' . $date . '\',
					1,
					' . $q . ',
					' . $num_answers . '
					)';
                if (!($rl = F_db_query($sqll, $db))) {
                    F_display_db_error(false);
                    return false;
                }
                $testlog_id = F_db_insert_id($db, K_TABLE_TESTS_LOGS, 'testlog_id');
                // set initial question score
                if ($mq['question_type'] == 1) {
                    // MCSA
                    $qscore = $question_unanswered_score;
                } else {
//.........这里部分代码省略.........
开发者ID:BGCX261,项目名称:zjxt-svn-to-git,代码行数:101,代码来源:tce_functions_omr.php

示例14: header

} else {
    header('Location: index.php');
    //redirect browser to public main page
    exit;
}
if (isset($_REQUEST['test_id']) and $_REQUEST['test_id'] > 0) {
    $test_id = intval($_REQUEST['test_id']);
} else {
    header('Location: index.php');
    //redirect browser to public main page
    exit;
}
// security check
$checkid = 0;
$sqlt = 'SELECT testuser_user_id FROM ' . K_TABLE_TEST_USER . ' WHERE testuser_test_id=' . $test_id . ' AND testuser_id=' . $testuser_id . '';
if ($rt = F_db_query($sqlt, $db)) {
    if ($mt = F_db_fetch_assoc($rt)) {
        $checkid = $mt['testuser_user_id'];
    }
} else {
    F_display_db_error();
}
if ($user_id != $checkid) {
    header('Location: index.php');
    //redirect browser to public main page
    exit;
}
// get user's test stats
$userdata = F_getUserData($user_id);
$teststat = F_getTestStat($test_id, 0, $user_id, 0, 0, $testuser_id);
$teststat['testinfo'] = F_getUserTestStat($test_id, $user_id, $testuser_id);
开发者ID:dungvu,项目名称:tcexam,代码行数:31,代码来源:tce_show_result_user.php

示例15: F_updateTestComment

/**
 * Updates user's test comment.<br>
 * @param $test_id (int) test ID
 * @param $testcomment (string) user comment.
 * @return string XHTML code
 * @since 4.0.000 (2006-10-01)
 */
function F_updateTestComment($test_id, $testcomment)
{
    require_once '../config/tce_config.php';
    global $db, $l;
    $test_id = intval($test_id);
    $testcomment = F_escape_sql($testcomment);
    $user_id = intval($_SESSION['session_user_id']);
    $sql = 'UPDATE ' . K_TABLE_TEST_USER . '
		SET testuser_comment=\'' . $testcomment . '\'
		WHERE testuser_test_id=' . $test_id . '
			AND testuser_user_id=' . $user_id . '';
    if (!($r = F_db_query($sql, $db))) {
        F_display_db_error();
    }
}
开发者ID:BGCX261,项目名称:zjxt-svn-to-git,代码行数:22,代码来源:tce_functions_test.php


注:本文中的F_db_query函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。