/**
 * Display user selection XHTML table.
 * @author Nicola Asuni
 * @since 2001-09-13
 * @param $order_field (string) Order by column name.
 * @param $orderdir (int) Order direction.
 * @param $firstrow (int) Number of first row to display.
 * @param $rowsperpage (int) Number of rows per page.
 * @param $group_id (int) ID of the group (default = 0 = no specific group selected).
 * @param $andwhere (string) Additional SQL WHERE query conditions.
 * @param $searchterms (string) Search terms.
 * @return false in case of empty database, true otherwise
 */
function F_show_select_user($order_field, $orderdir, $firstrow, $rowsperpage, $group_id = 0, $andwhere = '', $searchterms = '')
{
    global $l, $db;
    require_once '../config/tce_config.php';
    require_once '../../shared/code/tce_functions_page.php';
    require_once '../../shared/code/tce_functions_form.php';
    $filter = '';
    if ($l['a_meta_dir'] == 'rtl') {
        $txtalign = 'right';
        $numalign = 'left';
    } else {
        $txtalign = 'left';
        $numalign = 'right';
    }
    $order_field = F_escape_sql($db, $order_field);
    $orderdir = intval($orderdir);
    $firstrow = intval($firstrow);
    $rowsperpage = intval($rowsperpage);
    $group_id = intval($group_id);
    if (empty($order_field) or !in_array($order_field, array('user_id', 'user_name', 'user_password', 'user_email', 'user_regdate', 'user_ip', 'user_firstname', 'user_lastname', 'user_birthdate', 'user_birthplace', 'user_regnumber', 'user_ssn', 'user_level', 'user_verifycode'))) {
        $order_field = 'user_lastname,user_firstname';
    }
    if ($orderdir == 0) {
        $nextorderdir = 1;
        $full_order_field = $order_field;
    } else {
        $nextorderdir = 0;
        $full_order_field = $order_field . ' DESC';
    }
    if (!F_count_rows(K_TABLE_USERS)) {
        // if the table is void (no items) display message
        F_print_error('MESSAGE', $l['m_databasempty']);
        return FALSE;
    }
    $wherequery = '';
    if ($group_id > 0) {
        $wherequery = ', ' . K_TABLE_USERGROUP . ' WHERE user_id=usrgrp_user_id	AND usrgrp_group_id=' . $group_id . '';
        $filter .= '&group_id=' . $group_id . '';
    }
    if (empty($wherequery)) {
        $wherequery = ' WHERE';
    } else {
        $wherequery .= ' AND';
    }
    $wherequery .= ' (user_id>1)';
    if ($_SESSION['session_user_level'] < K_AUTH_ADMINISTRATOR) {
        // filter for level
        $wherequery .= ' AND ((user_level<' . $_SESSION['session_user_level'] . ') OR (user_id=' . $_SESSION['session_user_id'] . '))';
        // filter for groups
        $wherequery .= ' 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)';
    }
    if (!empty($andwhere)) {
        $wherequery .= ' AND (' . $andwhere . ')';
    }
    $sql = 'SELECT * FROM ' . K_TABLE_USERS . $wherequery . ' ORDER BY ' . $full_order_field;
    if (K_DATABASE_TYPE == 'ORACLE') {
        $sql = 'SELECT * FROM (' . $sql . ') WHERE rownum BETWEEN ' . $firstrow . ' AND ' . ($firstrow + $rowsperpage) . '';
    } else {
        $sql .= ' LIMIT ' . $rowsperpage . ' OFFSET ' . $firstrow . '';
    }
    if ($r = F_db_query($sql, $db)) {
        if ($m = F_db_fetch_array($r)) {
            // -- Table structure with links:
            echo '<div class="container">';
            echo '<table class="userselect">' . K_NEWLINE;
            // table header
            echo '<tr>' . K_NEWLINE;
            echo '<th>&nbsp;</th>' . K_NEWLINE;
            if (strlen($searchterms) > 0) {
                $filter .= '&amp;searchterms=' . urlencode($searchterms);
            }
            echo F_select_table_header_element('user_name', $nextorderdir, $l['h_login_name'], $l['w_user'], $order_field, $filter);
            echo F_select_table_header_element('user_lastname', $nextorderdir, $l['h_lastname'], $l['w_lastname'], $order_field, $filter);
            echo F_select_table_header_element('user_firstname', $nextorderdir, $l['h_firstname'], $l['w_firstname'], $order_field, $filter);
            echo F_select_table_header_element('user_regnumber', $nextorderdir, $l['h_regcode'], $l['w_regcode'], $order_field, $filter);
            echo F_select_table_header_element('user_level', $nextorderdir, $l['h_level'], $l['w_level'], $order_field, $filter);
            echo F_select_table_header_element('user_regdate', $nextorderdir, $l['h_regdate'], $l['w_regdate'], $order_field, $filter);
            echo '<th title="' . $l['h_group_name'] . '">' . $l['w_groups'] . '</th>' . K_NEWLINE;
            echo '<th title="' . $l['t_all_results_user'] . '">' . $l['w_tests'] . '</th>' . K_NEWLINE;
            echo '</tr>' . K_NEWLINE;
            $itemcount = 0;
            do {
                $itemcount++;
                echo '<tr>' . K_NEWLINE;
                echo '<td>';
                echo '<input type="checkbox" name="userid' . $itemcount . '" id="userid' . $itemcount . '" value="' . $m['user_id'] . '" title="' . $l['w_select'] . '"';
                if (isset($_REQUEST['checkall']) and $_REQUEST['checkall'] == 1) {
                    echo ' checked="checked"';
                }
                echo ' />';
                echo '</td>' . K_NEWLINE;
                echo '<td style="text-align:' . $txtalign . ';">&nbsp;<a href="tce_edit_user.php?user_id=' . $m['user_id'] . '" title="' . $l['w_edit'] . '">' . htmlspecialchars($m['user_name'], ENT_NOQUOTES, $l['a_meta_charset']) . '</a></td>' . K_NEWLINE;
                echo '<td style="text-align:' . $txtalign . ';">&nbsp;' . htmlspecialchars($m['user_lastname'], ENT_NOQUOTES, $l['a_meta_charset']) . '</td>' . K_NEWLINE;
                echo '<td style="text-align:' . $txtalign . ';">&nbsp;' . htmlspecialchars($m['user_firstname'], ENT_NOQUOTES, $l['a_meta_charset']) . '</td>' . K_NEWLINE;
                echo '<td style="text-align:' . $txtalign . ';">&nbsp;' . htmlspecialchars($m['user_regnumber'], ENT_NOQUOTES, $l['a_meta_charset']) . '</td>' . K_NEWLINE;
                echo '<td>&nbsp;' . $m['user_level'] . '</td>' . K_NEWLINE;
                echo '<td>&nbsp;' . htmlspecialchars($m['user_regdate'], ENT_NOQUOTES, $l['a_meta_charset']) . '</td>' . K_NEWLINE;
                // comma separated list of user's groups
                $grp = '';
                $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();
                }
                echo '<td style="text-align:' . $txtalign . ';">&nbsp;' . htmlspecialchars(substr($grp, 0, -2), ENT_NOQUOTES, $l['a_meta_charset']) . '</td>' . K_NEWLINE;
                echo '<td><a href="tce_show_result_allusers.php?user_id=' . $m['user_id'] . '" class="xmlbutton" title="' . $l['t_all_results_user'] . '">...</a></td>' . K_NEWLINE;
                echo '</tr>' . K_NEWLINE;
            } while ($m = F_db_fetch_array($r));
            echo '</table>' . K_NEWLINE;
            echo '<br />' . K_NEWLINE;
            echo '<input type="hidden" name="order_field" id="order_field" value="' . $order_field . '" />' . K_NEWLINE;
            echo '<input type="hidden" name="orderdir" id="orderdir" value="' . $orderdir . '" />' . K_NEWLINE;
            echo '<input type="hidden" name="firstrow" id="firstrow" value="' . $firstrow . '" />' . K_NEWLINE;
            echo '<input type="hidden" name="rowsperpage" id="rowsperpage" value="' . $rowsperpage . '" />' . K_NEWLINE;
            // check/uncheck all options
            echo '<span dir="' . $l['a_meta_dir'] . '">';
            echo '<input type="radio" name="checkall" id="checkall1" value="1" onclick="document.getElementById(\'form_userselect\').submit()" />';
            echo '<label for="checkall1">' . $l['w_check_all'] . '</label> ';
            echo '<input type="radio" name="checkall" id="checkall0" value="0" onclick="document.getElementById(\'form_userselect\').submit()" />';
            echo '<label for="checkall0">' . $l['w_uncheck_all'] . '</label>';
            echo '</span>' . K_NEWLINE;
            echo '<br />' . K_NEWLINE;
            echo '<strong style="margin:5px">' . $l['m_with_selected'] . '</strong>' . K_NEWLINE;
            echo '<ul style="margin:0">';
            if ($_SESSION['session_user_level'] >= K_AUTH_DELETE_USERS) {
                // delete user
                echo '<li>';
                F_submit_button('delete', $l['w_delete'], $l['h_delete']);
                echo '</li>' . K_NEWLINE;
            }
            if ($_SESSION['session_user_level'] >= K_AUTH_ADMIN_GROUPS) {
                echo '<li>';
                // add/delete group
                echo F_user_group_select('new_group_id');
                F_submit_button('addgroup', $l['w_add'], $l['w_add']);
                if ($_SESSION['session_user_level'] >= K_AUTH_DELETE_GROUPS) {
                    F_submit_button('delgroup', $l['w_delete'], $l['h_delete']);
                }
                echo '</li>' . K_NEWLINE;
                if ($_SESSION['session_user_level'] >= K_AUTH_MOVE_GROUPS) {
                    // move group
                    echo '<li>';
                    if ($l['a_meta_dir'] == 'rtl') {
                        $arr = '&larr;';
                    } else {
                        $arr = '&rarr;';
                    }
                    echo F_user_group_select('from_group_id');
                    echo $arr;
                    echo F_user_group_select('to_group_id');
                    F_submit_button('move', $l['w_move'], $l['w_move']);
                    echo '</li>' . K_NEWLINE;
                }
            }
            echo '</ul>' . K_NEWLINE;
            echo '<div class="row"><hr /></div>' . K_NEWLINE;
            // ---------------------------------------------------------------
            // -- page jumper (menu for successive pages)
            if ($rowsperpage > 0) {
                $sql = 'SELECT count(*) AS total FROM ' . K_TABLE_USERS . '' . $wherequery . '';
                if (!empty($order_field)) {
                    $param_array = '&amp;order_field=' . urlencode($order_field) . '';
                }
                if (!empty($orderdir)) {
                    $param_array .= '&amp;orderdir=' . $orderdir . '';
                }
                if (!empty($group_id)) {
                    $param_array .= '&amp;group_id=' . $group_id . '';
                }
                if (!empty($searchterms)) {
                    $param_array .= '&amp;searchterms=' . urlencode($searchterms) . '';
                }
                $param_array .= '&amp;submitted=1';
                F_show_page_navigator($_SERVER['SCRIPT_NAME'], $sql, $firstrow, $rowsperpage, $param_array);
            }
            echo '<div class="row">' . K_NEWLINE;
            echo '<br />';
            echo '<a href="tce_xml_users.php" class="xmlbutton" title="' . $l['h_xml_export'] . '">XML</a> ';
            echo '<a href="tce_xml_users.php?format=JSON" class="xmlbutton" title="JSON">JSON</a> ';
            echo '<a href="tce_tsv_users.php" class="xmlbutton" title="' . $l['h_tsv_export'] . '">TSV</a>';
            echo '</div>' . K_NEWLINE;
            echo '<div class="pagehelp">' . $l['hp_select_users'] . '</div>' . K_NEWLINE;
            echo '</div>' . K_NEWLINE;
        } else {
            F_print_error('MESSAGE', $l['m_search_void']);
        }
    } else {
        F_display_db_error();
    }
    return TRUE;
}
                echo '<strong><a href="index.php" title="' . $l['h_index'] . '">' . $l['h_index'] . ' &gt;</a></strong>' . K_NEWLINE;
                echo '</div>' . K_NEWLINE;
                require_once 'tce_page_footer.php';
                exit;
            }
        }
        break;
    default:
        break;
}
//end of switch
echo '<div class="container">' . K_NEWLINE;
echo '<div class="tceformbox">' . K_NEWLINE;
echo '<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post" enctype="multipart/form-data" id="form_editor">' . K_NEWLINE;
echo getFormRowTextInput('user_email', $l['w_new_email'], $l['h_email'], '', '', '^([a-zA-Z0-9_\\.\\-]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$', 255, false, false, false, '');
echo getFormRowTextInput('user_email_repeat', $l['w_new_email'], $l['h_email'], ' (' . $l['w_repeat'] . ')', '', '', 255, false, false, false, '');
echo getFormRowTextInput('currentpassword', $l['w_password'], $l['h_password'], '', '', '', 255, false, false, true, '');
echo '<div class="row">' . K_NEWLINE;
F_submit_button('update', $l['w_update'], $l['h_update']);
// comma separated list of required fields
echo '<input type="hidden" name="ff_required" id="ff_required" value="user_email,user_email_repeat" />' . K_NEWLINE;
echo '<input type="hidden" name="ff_required_labels" id="ff_required_labels" value="' . htmlspecialchars($l['w_email'] . ',' . $l['w_email'], ENT_COMPAT, $l['a_meta_charset']) . '" />' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '</form>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="pagehelp">' . $l['hp_user_change_email'] . '</div>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
require_once dirname(__FILE__) . '/tce_page_footer.php';
//============================================================+
// END OF FILE
//============================================================+
</span>
<span class="formw">
<input type="hidden" name="MAX_FILE_SIZE" value="<?php 
echo K_MAX_UPLOAD_SIZE;
?>
" />
<input type="file" name="userfile" id="userfile" size="20" title="<?php 
echo $l['h_upload_file'];
?>
" />
</span>
&nbsp;
</div>

<div class="row">
<?php 
// show buttons by case
F_submit_button("upload", $l['w_upload'], $l['h_submit_file']);
?>
</div>

</form>

</div>
<?php 
echo '<div class="pagehelp">' . $l['hp_import_dhcp'] . '</div>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
require_once '../code/tce_page_footer.php';
//============================================================+
// END OF FILE
//============================================================+
/**
 * Display test selection XHTML table.
 * @author Nicola Asuni
 * @param $order_field (string) Order by column name.
 * @param $orderdir (int) Order direction.
 * @param $firstrow (int) Number of first row to display.
 * @param $rowsperpage (int) Number of rows per page.
 * @param $andwhere (string) Additional SQL WHERE query conditions.
 * @param $searchterms (string) Search terms.
 * @return false in case of empty database, true otherwise
 */
function F_show_select_test($order_field, $orderdir, $firstrow, $rowsperpage, $andwhere = '', $searchterms = '')
{
    global $l, $db;
    require_once '../config/tce_config.php';
    require_once '../../shared/code/tce_functions_page.php';
    require_once '../../shared/code/tce_functions_form.php';
    $filter = '';
    if ($l['a_meta_dir'] == 'rtl') {
        $txtalign = 'right';
        $numalign = 'left';
    } else {
        $txtalign = 'left';
        $numalign = 'right';
    }
    $order_field = F_escape_sql($db, $order_field);
    $orderdir = intval($orderdir);
    $firstrow = intval($firstrow);
    $rowsperpage = intval($rowsperpage);
    if (empty($order_field) or !in_array($order_field, array('test_name', 'test_description', 'test_begin_time', 'test_end_time', 'test_duration_time', 'test_ip_range', 'test_results_to_users', 'test_report_to_users', 'test_score_right', 'test_score_wrong', 'test_score_unanswered', 'test_max_score', 'test_user_id', 'test_score_threshold', 'test_random_questions_select', 'test_random_questions_order', 'test_questions_order_mode', 'test_random_answers_select', 'test_random_answers_order', 'test_answers_order_mode', 'test_comment_enabled', 'test_menu_enabled', 'test_noanswer_enabled', 'test_mcma_radio', 'test_repeatable', 'test_mcma_partial_score', 'test_logout_on_timeout'))) {
        $order_field = 'test_begin_time DESC,test_name';
    }
    if ($orderdir == 0) {
        $nextorderdir = 1;
        $full_order_field = $order_field;
    } else {
        $nextorderdir = 0;
        $full_order_field = $order_field . ' DESC';
    }
    if (!F_count_rows(K_TABLE_TESTS)) {
        // if the table is void (no items) display message
        F_print_error('MESSAGE', $l['m_databasempty']);
        return FALSE;
    }
    $wherequery = '';
    if (empty($wherequery)) {
        $wherequery = ' WHERE';
    } else {
        $wherequery .= ' AND';
    }
    $wherequery .= ' (test_id>0)';
    if ($_SESSION['session_user_level'] < K_AUTH_ADMINISTRATOR) {
        $wherequery .= ' AND test_user_id IN (' . F_getAuthorizedUsers($_SESSION['session_user_id']) . ')';
    }
    if (!empty($andwhere)) {
        $wherequery .= ' AND (' . $andwhere . ')';
    }
    $sql = 'SELECT * FROM ' . K_TABLE_TESTS . $wherequery . ' ORDER BY ' . $full_order_field;
    if (K_DATABASE_TYPE == 'ORACLE') {
        $sql = 'SELECT * FROM (' . $sql . ') WHERE rownum BETWEEN ' . $firstrow . ' AND ' . ($firstrow + $rowsperpage) . '';
    } else {
        $sql .= ' LIMIT ' . $rowsperpage . ' OFFSET ' . $firstrow . '';
    }
    if ($r = F_db_query($sql, $db)) {
        if ($m = F_db_fetch_array($r)) {
            // -- Table structure with links:
            echo '<div class="container">';
            echo '<table class="userselect">' . K_NEWLINE;
            // table header
            echo '<tr>' . K_NEWLINE;
            echo '<th>&nbsp;</th>' . K_NEWLINE;
            if (strlen($searchterms) > 0) {
                $filter .= '&amp;searchterms=' . urlencode($searchterms);
            }
            echo F_select_table_header_element('test_begin_time', $nextorderdir, $l['w_time_begin'] . ' ' . $l['w_datetime_format'], $l['w_time_begin'], $order_field, $filter);
            echo F_select_table_header_element('test_end_time', $nextorderdir, $l['w_time_end'] . ' ' . $l['w_datetime_format'], $l['w_time_end'], $order_field, $filter);
            echo F_select_table_header_element('test_name', $nextorderdir, $l['h_test_name'], $l['w_name'], $order_field, $filter);
            echo F_select_table_header_element('test_description', $nextorderdir, $l['h_test_description'], $l['w_description'], $order_field, $filter);
            echo '</tr>' . K_NEWLINE;
            $itemcount = 0;
            do {
                $itemcount++;
                echo '<tr>' . K_NEWLINE;
                echo '<td>';
                echo '<input type="checkbox" name="testid' . $itemcount . '" id="testid' . $itemcount . '" value="' . $m['test_id'] . '" title="' . $l['w_select'] . '"';
                if (isset($_REQUEST['checkall']) and $_REQUEST['checkall'] == 1) {
                    echo ' checked="checked"';
                }
                echo ' />';
                echo '</td>' . K_NEWLINE;
                echo '<td style="text-align:' . $txtalign . ';">&nbsp;' . htmlspecialchars($m['test_begin_time'], ENT_NOQUOTES, $l['a_meta_charset']) . '</td>' . K_NEWLINE;
                echo '<td style="text-align:' . $txtalign . ';">&nbsp;' . htmlspecialchars($m['test_end_time'], ENT_NOQUOTES, $l['a_meta_charset']) . '</td>' . K_NEWLINE;
                echo '<td style="text-align:' . $txtalign . ';">&nbsp;<a href="tce_edit_test.php?test_id=' . $m['test_id'] . '" title="' . $l['w_edit'] . '">' . htmlspecialchars($m['test_name'], ENT_NOQUOTES, $l['a_meta_charset']) . '</a></td>' . K_NEWLINE;
                echo '<td style="text-align:' . $txtalign . ';">&nbsp;' . htmlspecialchars($m['test_description'], ENT_NOQUOTES, $l['a_meta_charset']) . '</td>' . K_NEWLINE;
                echo '</tr>' . K_NEWLINE;
            } while ($m = F_db_fetch_array($r));
            echo '</table>' . K_NEWLINE;
            echo '<br />' . K_NEWLINE;
            echo '<input type="hidden" name="order_field" id="order_field" value="' . $order_field . '" />' . K_NEWLINE;
            echo '<input type="hidden" name="orderdir" id="orderdir" value="' . $orderdir . '" />' . K_NEWLINE;
            echo '<input type="hidden" name="firstrow" id="firstrow" value="' . $firstrow . '" />' . K_NEWLINE;
            echo '<input type="hidden" name="rowsperpage" id="rowsperpage" value="' . $rowsperpage . '" />' . K_NEWLINE;
            // check/uncheck all options
            echo '<span dir="' . $l['a_meta_dir'] . '">';
            echo '<input type="radio" name="checkall" id="checkall1" value="1" onclick="document.getElementById(\'form_testselect\').submit()" />';
            echo '<label for="checkall1">' . $l['w_check_all'] . '</label> ';
            echo '<input type="radio" name="checkall" id="checkall0" value="0" onclick="document.getElementById(\'form_testselect\').submit()" />';
            echo '<label for="checkall0">' . $l['w_uncheck_all'] . '</label>';
            echo '</span>' . K_NEWLINE;
            echo '<br />' . K_NEWLINE;
            echo '<strong style="margin:5px">' . $l['m_with_selected'] . '</strong>' . K_NEWLINE;
            // delete user
            echo '<div>';
            F_submit_button('delete', $l['w_delete'], $l['h_delete']);
            F_submit_button('lock', $l['w_lock'], $l['w_lock']);
            F_submit_button('unlock', $l['w_unlock'], $l['w_unlock']);
            echo '</div>' . K_NEWLINE;
            echo '<div class="row"><hr /></div>' . K_NEWLINE;
            // ---------------------------------------------------------------
            // -- page jumper (menu for successive pages)
            if ($rowsperpage > 0) {
                $sql = 'SELECT count(*) AS total FROM ' . K_TABLE_TESTS . '' . $wherequery . '';
                if (!empty($order_field)) {
                    $param_array = '&amp;order_field=' . urlencode($order_field) . '';
                }
                if (!empty($orderdir)) {
                    $param_array .= '&amp;orderdir=' . $orderdir . '';
                }
                if (!empty($searchterms)) {
                    $param_array .= '&amp;searchterms=' . urlencode($searchterms) . '';
                }
                $param_array .= '&amp;submitted=1';
                F_show_page_navigator($_SERVER['SCRIPT_NAME'], $sql, $firstrow, $rowsperpage, $param_array);
            }
            echo '<div class="row">' . K_NEWLINE;
            echo '</div>' . K_NEWLINE;
            echo '<div class="pagehelp">' . $l['hp_select_tests'] . '</div>' . K_NEWLINE;
            echo '</div>' . K_NEWLINE;
        } else {
            F_print_error('MESSAGE', $l['m_search_void']);
        }
    } else {
        F_display_db_error();
    }
    return TRUE;
}
        echo '<option value="' . $m['tmp_id'] . '"';
        if ($m['tmp_id'] == $footer_tmp_id) {
            echo ' selected="selected"';
        }
        echo '>' . htmlspecialchars($m['tmp_name'], ENT_NOQUOTES, $l['a_meta_charset']) . '</option>' . K_NEWLINE;
    }
} else {
    echo '</select></span></div>' . K_NEWLINE;
    F_display_db_error();
}
echo '</select>' . K_NEWLINE;
echo '</span>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
// generate button
echo '<div class="row">' . K_NEWLINE;
F_submit_button('generate', $l['w_generate'], $l['h_generate_script']);
echo '</div>' . K_NEWLINE;
echo '<div class="row">' . K_NEWLINE;
echo '&nbsp;' . K_NEWLINE;
// comma separated list of required fields
echo '<input type="hidden" name="ff_required" id="ff_required" value="" />' . K_NEWLINE;
echo '<input type="hidden" name="ff_required_labels" id="ff_required_labels" value="" />' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '</form>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="pagehelp">' . $l['hp_script_generator'] . '</div>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
require_once '../code/tce_page_footer.php';
//============================================================+
// END OF FILE
//============================================================+
Exemple #6
0
echo '<span class="label">&nbsp;</span>' . K_NEWLINE;
echo '<span class="formw">' . K_NEWLINE;
echo '<input type="radio" name="default_score" id="default_score_unanswered" value="0" onclick="document.getElementById(\'form_ratingeditor\').testlog_score.value=\'' . $test_score_unanswered . '\'" title="' . $l['h_score_unanswered'] . '" /><label for="default_score_unanswered">' . $l['w_score_unanswered'] . ' [' . $test_score_unanswered . ']</label>' . K_NEWLINE;
echo '</span>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="row">' . K_NEWLINE;
echo '<br />' . K_NEWLINE;
echo '<span class="label">' . K_NEWLINE;
echo '<label for="testlog_comment">' . $l['w_comment'] . '</label>' . K_NEWLINE;
echo '</span>' . K_NEWLINE;
echo '<span class="formw">' . K_NEWLINE;
echo '<textarea cols="50" rows="5" name="testlog_comment" id="testlog_comment" style="color:#FF0000" title="' . $l['w_comment'] . '">' . htmlspecialchars($testlog_comment, ENT_NOQUOTES, $l['a_meta_charset']) . '</textarea>' . K_NEWLINE;
echo '</span>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="row">' . K_NEWLINE;
// show buttons by case
if (isset($testlog_id) and $testlog_id > 0) {
    F_submit_button("update", $l['w_update'], $l['h_update']);
}
// comma separated list of required fields
echo '<input type="hidden" name="ff_required" id="ff_required" value="testlog_score" />' . K_NEWLINE;
echo '<input type="hidden" name="ff_required_labels" id="ff_required_labels" value="' . $l['w_score'] . '" />' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '</form>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="pagehelp">' . $l['hp_edit_rating'] . '</div>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
require_once '../code/tce_page_footer.php';
//============================================================+
// END OF FILE
//============================================================+
    echo F_object_selector($cab_b_obj_id, 'cab_b_obj_id', $l['w_object'] . ' (B)', false, false);
    echo F_select_connection_type($cab_cbt_id);
}
echo F_select_color($cab_color, 'cab_color', $l['w_color'], $l['h_cable_color']);
echo '<div class="row">' . K_NEWLINE;
// show buttons by case
if (isset($cab_ids) and !empty($cab_ids)) {
    echo '<span style="background-color:#999999;">';
    echo '<input type="checkbox" name="confirmupdate" id="confirmupdate" value="1" title="confirm &rarr; update" />';
    F_submit_button('update', $l['w_update'], $l['h_update']);
    echo '</span>';
    F_submit_button('delete', $l['w_delete'], $l['h_delete']);
} else {
    F_submit_button('add', $l['w_add'], $l['h_add']);
}
F_submit_button('clear', $l['w_clear'], $l['h_clear']);
echo '</div>' . K_NEWLINE;
echo '<div class="row">' . K_NEWLINE;
echo '&nbsp;' . K_NEWLINE;
// comma separated list of required fields
echo '<input type="hidden" name="ff_required" id="ff_required" value="cab_color" />' . K_NEWLINE;
echo '<input type="hidden" name="ff_required_labels" id="ff_required_labels" value="' . htmlspecialchars($l['w_color'], ENT_COMPAT, $l['a_meta_charset']) . '" />' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '</form>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="pagehelp">' . $l['hp_connection_editor'] . '</div>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
require_once '../code/tce_page_footer.php';
//============================================================+
// END OF FILE
//============================================================+
        F_display_db_error();
    }
    echo '</select>' . K_NEWLINE;
    echo '</span>' . K_NEWLINE;
    echo '</div>' . K_NEWLINE;
}
if ($regfields['user_agreement'] > 0) {
    echo '<div class="row">' . K_NEWLINE;
    echo '<span class="label">&nbsp;</span>' . K_NEWLINE;
    echo '<span class="formw">' . K_NEWLINE;
    echo '<input type="checkbox" name="user_agreement" id="user_agreement" value="1" title="..." />' . K_NEWLINE;
    echo '<label for="user_agreement"><a href="' . K_USRREG_AGREEMENT . '" title="' . $l['m_new_window_link'] . '">' . $l['w_i_agree'] . '</a></label></span>' . K_NEWLINE;
    echo '</div>' . K_NEWLINE;
}
echo '<div class="row">' . K_NEWLINE;
F_submit_button("add", $l['w_add'], $l['h_add']);
// set fields descriptions for error messages
$fielddesc = array('user_name' => $l['w_name'], 'newpassword' => $l['w_password'], 'newpassword_repeat' => $l['w_password'], 'user_email' => $l['w_email'], 'user_regnumber' => $l['w_regcode'], 'user_firstname' => $l['w_firstname'], 'user_lastname' => $l['w_lastname'], 'user_sshkey' => $l['w_sshkey'], 'user_groups' => $l['w_groups'], 'user_agreement' => $l['w_i_agree']);
$reqfields = '';
$reqdesc = '';
foreach ($regfields as $field => $required) {
    if ($required == 2) {
        $reqfields .= ',' . $field;
        $reqdesc .= ',' . htmlspecialchars($fielddesc[$field], ENT_COMPAT, $l['a_meta_charset']);
    }
}
$reqfields = substr($reqfields, 1);
$reqdesc = substr($reqdesc, 1);
// comma separated list of required fields
echo '<input type="hidden" name="ff_required" id="ff_required" value="' . $reqfields . '" />' . K_NEWLINE;
echo '<input type="hidden" name="ff_required_labels" id="ff_required_labels" value="' . $reqdesc . '" />' . K_NEWLINE;
Exemple #9
0
    echo '<select name="tsubset_difficulty" id="tsubset_difficulty" size="0" title="' . $l['h_question_difficulty'] . '">' . K_NEWLINE;
    for ($i = 0; $i <= K_QUESTION_DIFFICULTY_LEVELS; ++$i) {
        echo '<option value="' . $i . '"';
        if ($i == $tsubset_difficulty) {
            echo ' selected="selected"';
        }
        echo '>' . $i . '</option>' . K_NEWLINE;
    }
    echo '</select>' . K_NEWLINE;
    echo '</span>' . K_NEWLINE;
    echo '</div>' . K_NEWLINE;
    echo getFormRowTextInput('tsubset_answers', $l['w_num_answers'], $l['h_num_answers'], '', $tsubset_answers, '^([0-9]*)$', 20, false, false, false);
    echo '<div class="row">' . K_NEWLINE;
    echo '<span class="label">&nbsp;</span>' . K_NEWLINE;
    echo '<span class="formw">' . K_NEWLINE;
    F_submit_button("addquestion", $l['w_add_questions'], $l['h_add_questions']);
    echo '</span>' . K_NEWLINE;
    echo '</div>' . K_NEWLINE;
    echo '<div class="rowl" title="' . $l['h_subjects'] . '">' . K_NEWLINE;
    echo '<br />' . K_NEWLINE;
    echo '<div class="preview">' . K_NEWLINE;
    $subjlist = '';
    $sql = 'SELECT * FROM ' . K_TABLE_TEST_SUBJSET . '
		WHERE tsubset_test_id=\'' . $test_id . '\'
		ORDER BY tsubset_id';
    if ($r = F_db_query($sql, $db)) {
        while ($m = F_db_fetch_array($r)) {
            $subjlist .= '<li>';
            $subjects_list = '';
            $sqls = 'SELECT subject_id,subject_name
				FROM ' . K_TABLE_SUBJECTS . ', ' . K_TABLE_SUBJECT_SET . '
Exemple #10
0
            F_send_user_reg_email($user_id, $user_email, $user_verifycode);
            F_print_error('MESSAGE', $user_email . ': ' . $l['m_user_verification_sent']);
            echo '<div class="container">' . K_NEWLINE;
            echo '<strong><a href="index.php" title="' . $l['h_index'] . '">' . $l['h_index'] . ' &gt;</a></strong>' . K_NEWLINE;
            echo '</div>' . K_NEWLINE;
            require_once '../code/tce_page_footer.php';
            exit;
        } else {
            F_print_error('ERROR', $l['w_unknown_email']);
        }
    }
}
//end of add
echo '<div class="container">' . K_NEWLINE;
echo '<div class="tceformbox">' . K_NEWLINE;
echo '<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post" enctype="multipart/form-data" id="form_usereditor">' . K_NEWLINE;
echo '<p>' . $l['d_reset_password'] . '</p>' . K_NEWLINE;
echo getFormRowTextInput('user_email', $l['w_email'], $l['h_usered_email'], '', '', '^([a-zA-Z0-9_\\.\\-]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$', 255, false, false, false, '');
echo '<div class="row">' . K_NEWLINE;
F_submit_button('resetpassword', $l['w_submit'], $l['h_submit']);
// comma separated list of required fields
echo '<input type="hidden" name="ff_required" id="ff_required" value="user_email" />' . K_NEWLINE;
echo '<input type="hidden" name="ff_required_labels" id="ff_required_labels" value="' . $l['w_email'] . '" />' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '</form>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
require_once '../code/tce_page_footer.php';
//============================================================+
// END OF FILE
//============================================================+
        echo '</ul>';
        echo '</li>' . K_NEWLINE;
    }
    echo '</ul>';
    echo '<hr />' . K_NEWLINE;
    echo '</div>' . K_NEWLINE;
    echo '<div class="row">' . K_NEWLINE;
    // show buttons by case
    if (isset($test_id) and $test_id > 0 and isset($user_id) and $user_id > 0) {
        F_submit_button('delete', $l['w_delete'], $l['h_delete']);
        if ($testuser_status < 4) {
            // lock test button
            F_submit_button('lock', $l['w_lock'], $l['w_lock']);
        } else {
            // unlock test button
            F_submit_button('unlock', $l['w_unlock'], $l['w_unlock']);
        }
        echo '<br /><br />';
        echo '<a href="' . pdfLink(3, $test_id, 0, $user_id, '', 0) . '" class="xmlbutton" title="' . $l['h_pdf'] . '">' . $l['w_pdf'] . '</a> ';
        echo '<a href="tce_email_results.php?testid=' . $test_id . '&amp;userid=' . $user_id . '&amp;mode=1" class="xmlbutton" title="' . $l['h_email_result'] . '">' . $l['w_email_result'] . '</a> ';
        echo '<a href="tce_email_results.php?testid=' . $test_id . '&amp;userid=' . $user_id . '&amp;mode=0" class="xmlbutton" title="' . $l['h_email_result'] . ' + PDF">' . $l['w_email_result'] . ' + PDF</a> ';
    }
    // comma separated list of required fields
    echo '<input type="hidden" name="ff_required" id="ff_required" value="" />' . K_NEWLINE;
    echo '<input type="hidden" name="ff_required_labels" id="ff_required_labels" value="" />' . K_NEWLINE;
    echo '</div>' . K_NEWLINE;
}
// end "if (isset($usrtestdata))"
echo '</form>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="pagehelp">' . $l['hp_result_user'] . '</div>' . K_NEWLINE;
if ($filtered === true) {
    echo F_getSelectedObject($dcn_id, $sts_id, $rck_id, $obt_id, $obj_owner_id, $obj_tenant_id, $keywords);
    // *** user groups ***
    // -----------------------------------------------------------------------------
    // group permissions
    echo '<fieldset class="subset" style="text-align:left;">' . K_NEWLINE;
    echo '<legend>' . $l['t_permissions'] . '</legend>' . K_NEWLINE;
    echo F_groupsPermsSelector($perms, true);
    echo '</fieldset>' . K_NEWLINE;
    // -----------------------------------------------------------------------------
    echo getFormRowCheckBox('sshkey_overwrite', $l['w_overwrite'], $l['h_sshkey_overwrite'], '', '1', $sshkey_overwrite, false, '');
    // generate button
    echo '<div class="row">' . K_NEWLINE;
    F_submit_button('update', $l['w_update'], $l['h_update']);
    if ($userlevel >= K_AUTH_ADMINISTRATOR) {
        F_submit_button('updatessh', $l['w_update_ssh'], $l['h_update_ssh']);
    }
    echo '</div>' . K_NEWLINE;
}
echo '<div class="row">' . K_NEWLINE;
echo '&nbsp;' . K_NEWLINE;
// comma separated list of required fields
echo '<input type="hidden" name="ff_required" id="ff_required" value="" />' . K_NEWLINE;
echo '<input type="hidden" name="ff_required_labels" id="ff_required_labels" value="" />' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '</form>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="pagehelp">' . $l['hp_bulk_access_groups'] . '</div>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
require_once '../code/tce_page_footer.php';
//============================================================+
            F_print_error('MESSAGE', $l['m_file_saved'] . ': <a href="' . K_PATH_URL_CONFIG_SCRIPTS . $outfile . '" title="' . $l['w_download'] . '" onclick="pdfWindow=window.open(\'' . K_PATH_URL_CONFIG_SCRIPTS . $outfile . '\',\'expWindow\',\'dependent,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes\'); return false;">' . $outfile . '</a>');
        } else {
            F_print_error('ERROR', $l['m_file_save_error'] . ': ' . $outfile);
        }
        break;
    default:
        break;
}
//end of switch
// -----------------------------------------------------------------------------
echo '<div class="container">' . K_NEWLINE;
echo '<div class="tceformbox">' . K_NEWLINE;
echo '<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post" enctype="multipart/form-data" id="form_editor">' . K_NEWLINE;
// export button
echo '<div class="row">' . K_NEWLINE;
F_submit_button('generate', $l['w_export'], $l['w_export_data']);
echo '</div>' . K_NEWLINE;
echo '<div class="row">' . K_NEWLINE;
echo '&nbsp;' . K_NEWLINE;
// comma separated list of required fields
echo '<input type="hidden" name="ff_required" id="ff_required" value="" />' . K_NEWLINE;
echo '<input type="hidden" name="ff_required_labels" id="ff_required_labels" value="" />' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '</form>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="pagehelp">' . $l['hp_export_objects_csv'] . '</div>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
require_once '../code/tce_page_footer.php';
//============================================================+
// END OF FILE
//============================================================+
        echo '<option value="' . $m['tmp_id'] . '"';
        if ($m['tmp_id'] == $footer_tmp_id) {
            echo ' selected="selected"';
        }
        echo '>' . htmlspecialchars($m['tmp_name'], ENT_NOQUOTES, $l['a_meta_charset']) . '</option>' . K_NEWLINE;
    }
} else {
    echo '</select></span></div>' . K_NEWLINE;
    F_display_db_error();
}
echo '</select>' . K_NEWLINE;
echo '</span>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
// generate button
echo '<div class="row">' . K_NEWLINE;
F_submit_button('generate', $l['w_generate'], $l['h_generate_ssh_commands']);
echo '</div>' . K_NEWLINE;
echo '<div class="row">' . K_NEWLINE;
echo '&nbsp;' . K_NEWLINE;
// comma separated list of required fields
echo '<input type="hidden" name="ff_required" id="ff_required" value="" />' . K_NEWLINE;
echo '<input type="hidden" name="ff_required_labels" id="ff_required_labels" value="" />' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '</form>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="pagehelp">' . $l['hp_ssh_commander'] . '</div>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
require_once '../code/tce_page_footer.php';
//============================================================+
// END OF FILE
//============================================================+
Exemple #15
0
     // display questions + navigation menu
     echo F_questionForm($test_id, $testlog_id, $formname);
     // the $finish variable is used to check if the form has been automatically submitted
     // at the end of the time.
     if (isset($_REQUEST['finish']) and $_REQUEST['finish'] > 0) {
         $finish = 1;
     } else {
         $finish = 0;
     }
     echo '<input type="hidden" name="finish" id="finish" value="' . $finish . '" />' . K_NEWLINE;
     echo '<input type="hidden" name="display_time" id="display_time" value="" />' . K_NEWLINE;
     echo '<input type="hidden" name="reaction_time" id="reaction_time" value="" />' . K_NEWLINE;
     // textarea field for user's comment
     echo '<span class="testcomment">' . F_testComment($test_id) . '</span>' . K_NEWLINE;
     // test termination button
     F_submit_button('terminatetest', $l['w_terminate_exam'], $l['w_terminate_exam']);
     echo K_NEWLINE;
     echo '</div>' . K_NEWLINE;
     echo '</form>' . K_NEWLINE;
 }
 // start the countdown if disabled
 if (isset($examtime)) {
     if (isset($timeout_logout) and $timeout_logout) {
         $timeout_logout = 'true';
     } else {
         $timeout_logout = 'false';
     }
     echo '<script type="text/javascript">' . K_NEWLINE;
     echo '//<![CDATA[' . K_NEWLINE;
     echo 'if(!enable_countdown) {' . K_NEWLINE;
     echo '	FJ_start_timer(\'true\', ' . (time() - $examtime) . ', \'' . addslashes($l['m_exam_end_time']) . '\', ' . $timeout_logout . ');' . K_NEWLINE;
echo '<td colspan="7">&nbsp;</td>';
echo '</tr>';
echo '</table>' . K_NEWLINE;
if ($itemcount > 0) {
    // check/uncheck all options
    echo '<span dir="ltr">';
    echo '<input type="radio" name="checkall" id="checkall1" value="1" onclick="document.getElementById(\'form_resultallusers\').submit()" />';
    echo '<label for="checkall1">' . $l['w_check_all'] . '</label> ';
    echo '<input type="radio" name="checkall" id="checkall0" value="0" onclick="document.getElementById(\'form_resultallusers\').submit()" />';
    echo '<label for="checkall0">' . $l['w_uncheck_all'] . '</label>';
    echo '</span>' . K_NEWLINE;
    echo '<br /><strong style="margin:5px">' . $l['m_with_selected'] . '</strong><br />' . K_NEWLINE;
    F_submit_button('delete', $l['w_delete'], $l['h_delete']);
    F_submit_button('lock', $l['w_lock'], $l['w_lock']);
    F_submit_button('unlock', $l['w_unlock'], $l['w_unlock']);
    F_submit_button('extendtime', '+' . K_EXTEND_TIME_MINUTES . ' min', $l['h_add_five_minutes']);
    echo '<br /><br />' . K_NEWLINE;
    // calculate statistics
    $stats = F_getArrayStatistics($statsdata);
    $excludestat = array('sum', 'variance');
    $calcpercent = array('mean', 'median', 'mode', 'minimum', 'maximum', 'range', 'standard_deviation');
    echo '<table class="userselect">' . K_NEWLINE;
    echo '<tr><td colspan="13" style="background-color:#DDDDDD;"><strong>' . $l['w_statistics'] . '</strong></td></tr>' . K_NEWLINE;
    // print statistics (one line for each statistic data).
    if ($usrtestdata['score_threshold'] > 0 and $stats['number']['score'] > 0) {
        echo '<tr><td style="text-align:' . $tdalignr . ';">' . $l['w_passed'] . '</td><td class="numeric">' . $passed . ' ' . F_formatPercentage($passed / $stats['number']['score']) . '</td><td colspan="5">&nbsp;</td></tr>' . K_NEWLINE;
    }
    echo '<tr>' . K_NEWLINE;
    echo '<th>&nbsp;</th>' . K_NEWLINE;
    echo '<th title="' . $l['h_score'] . '">' . $l['w_score'] . '</th>' . K_NEWLINE;
    echo '<th title="' . $l['h_answers_right'] . '">' . $l['w_answers_right'] . '</th>' . K_NEWLINE;
        F_display_db_error();
    }
    echo '</select>' . K_NEWLINE;
    echo '</span>' . K_NEWLINE;
    echo '</div>' . K_NEWLINE;
}
if ($regfields['user_agreement'] > 0) {
    echo '<div class="row">' . K_NEWLINE;
    echo '<span class="label">&nbsp;</span>' . K_NEWLINE;
    echo '<span class="formw">' . K_NEWLINE;
    echo '<input type="checkbox" name="user_agreement" id="user_agreement" value="1" title="..." />' . K_NEWLINE;
    echo '<label for="user_agreement"><a href="' . K_USRREG_AGREEMENT . '" title="' . $l['m_new_window_link'] . '">' . $l['w_i_agree'] . '</a></label></span>' . K_NEWLINE;
    echo '</div>' . K_NEWLINE;
}
echo '<div class="row">' . K_NEWLINE;
F_submit_button('add', $l['w_add'], $l['h_add']);
// set fields descriptions for error messages
$fielddesc = array('user_name' => $l['w_name'], 'newpassword' => $l['w_password'], 'newpassword_repeat' => $l['w_password'], 'user_email' => $l['w_email'], 'user_regnumber' => $l['w_regcode'], 'user_firstname' => $l['w_firstname'], 'user_lastname' => $l['w_lastname'], 'user_birthdate' => $l['w_birth_date'], 'user_birthplace' => $l['w_birth_place'], 'user_ssn' => $l['w_fiscal_code'], 'user_groups' => $l['w_groups'], 'user_agreement' => $l['w_i_agree']);
$reqfields = '';
$reqdesc = '';
foreach ($regfields as $field => $required) {
    if ($required == 2) {
        $reqfields .= ',' . $field;
        $reqdesc .= ',' . htmlspecialchars($fielddesc[$field], ENT_COMPAT, $l['a_meta_charset']);
    }
}
$reqfields = substr($reqfields, 1);
$reqdesc = substr($reqdesc, 1);
// comma separated list of required fields
echo '<input type="hidden" name="ff_required" id="ff_required" value="' . $reqfields . '" />' . K_NEWLINE;
echo '<input type="hidden" name="ff_required_labels" id="ff_required_labels" value="' . $reqdesc . '" />' . K_NEWLINE;
    F_submit_button('viewmodev', $l['w_visual'], $l['w_mode']);
} else {
    // visual mode
    echo '<label for="viewmodet">' . $l['w_mode'] . ': </label>';
    F_submit_button('viewmodet', $l['w_table'], $l['w_mode']);
}
echo '</div>' . K_NEWLINE;
// directory link path
echo '<br />' . K_NEWLINE;
echo '<strong>' . $l['w_position'] . ': ' . F_getMediaDirPathLink($dir, $viewmode) . '</strong>';
if ($_SESSION['session_user_level'] >= K_AUTH_ADMIN_DIRS) {
    // directory mode
    echo ' <input type="text" name="newdirname" id="newdirname" value="" size="15" maxlength="255" title="' . $l['w_new_directory'] . '" />' . K_NEWLINE;
    F_submit_button('newdir', $l['w_create_directory'], $l['w_new_directory']);
    if (count(scandir($dir)) <= 2) {
        F_submit_button('deldir', $l['w_delete'], $l['w_delete']);
    }
}
echo '<br />' . K_NEWLINE;
// list files
if ($viewmode) {
    // table mode
    echo F_getDirTable($dir, basename($file), $params, $root_dir, $authdirs);
} else {
    // visual mode
    echo F_getDirVisualTable($dir, basename($file), $params, $root_dir, $authdirs);
}
echo '</div>' . K_NEWLINE;
echo '</form>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="pagehelp">' . $l['hp_select_media_file'] . '</div>' . K_NEWLINE;
if (!isset($orderdir)) {
    $orderdir = 0;
}
if (!isset($searchterms)) {
    $searchterms = '';
}
if (!isset($cid)) {
    $cid = '';
}
// ID of the calling form field
echo '<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post" enctype="multipart/form-data" id="form_select">' . K_NEWLINE;
echo '<input type="hidden" name="cid" id="cid" value="' . $cid . '" />' . K_NEWLINE;
//echo '<div style="text-align:left;">';
echo '<div class="row">';
echo '<input type="text" name="searchterms" id="searchterms" value="' . htmlspecialchars($searchterms, ENT_COMPAT, $l['a_meta_charset']) . '" size="20" maxlength="255" title="' . $l['w_search_keywords'] . '" />';
F_submit_button('search', $l['w_search'], $l['w_search']);
echo '</div>' . K_NEWLINE;
// build a search query
if (strlen($searchterms) > 0) {
    $searchterms = trim($searchterms);
    if (preg_match("/^([0-9A-F]{2})[\\:\\-]([0-9A-F]{2})[\\:\\-]([0-9A-F]{2})/i", $searchterms, $matches) > 0) {
        // MAC address
        $mac = strtoupper($matches[1] . $matches[2] . $matches[3]);
        $sql = 'SELECT mnf_id, mnf_name FROM ' . K_TABLE_MANUFACTURES . ', ' . K_TABLE_MANUFACTURES_MAC . ' WHERE mnf_id=mac_mnf_id AND mac_mac=\'' . $mac . '\' ORDER BY mnf_name ASC';
    } else {
        $wherequery = '';
        $terms = preg_split("/[\\s]+/i", $searchterms);
        // Get all the words into an array
        foreach ($terms as $word) {
            $word = F_escape_sql($word);
            $wherequery .= ' AND (mnf_name LIKE \'%' . $word . '%\')';
Exemple #20
0
    if (is_file(K_PATH_BACKUP . $file)) {
        $files_list[] = $file;
    }
}
closedir($handle);
// sort alphabetically
sort($files_list);
$files_list = array_reverse($files_list);
foreach ($files_list as $file) {
    echo '<option value="' . $file . '">' . $file . '</option>' . K_NEWLINE;
}
echo '</select>' . K_NEWLINE;
echo '</span>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo getFormNoscriptSelect('selectrecord');
echo '<div class="row"><hr /></div>' . K_NEWLINE;
echo '<div class="row">' . K_NEWLINE;
F_submit_button('backup', $l['w_backup'], $l['h_backup']);
F_submit_button('restore', $l['w_restore'], $l['h_restore']);
if (K_DOWNLOAD_BACKUPS) {
    F_submit_button('download', $l['w_download'], $l['h_download']);
}
echo '</div>' . K_NEWLINE;
echo '</form>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="pagehelp">' . $l['hp_edit_backups'] . '</div>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
require_once '../code/tce_page_footer.php';
//============================================================+
// END OF FILE
//============================================================+
    echo '<fieldset class="noborder">' . K_NEWLINE;
    echo '<legend title="' . $l['w_type'] . '">' . $l['w_type'] . '</legend>' . K_NEWLINE;
    echo '<input type="radio" name="type" id="type_tcexam" value="1" title="TCExam XML Format"';
    if ($type == 1) {
        echo ' checked="checked"';
    }
    echo ' />';
    echo '<label for="type_tcexam">TCExam XML</label><br />' . K_NEWLINE;
    echo '<input type="radio" name="type" id="type_custom" value="2" title="' . $custom_import . '"' . K_NEWLINE;
    if ($type == 2) {
        echo ' checked="checked"';
    }
    echo ' />';
    echo '<label for="type_custom">' . $custom_import . '</label>' . K_NEWLINE;
    echo '</fieldset>' . K_NEWLINE;
    echo '</div>' . K_NEWLINE;
    echo '</div>' . K_NEWLINE;
}
echo '<div class="row">' . K_NEWLINE;
echo '<br />' . K_NEWLINE;
// show upload button
F_submit_button('upload', $l['w_upload'], $l['h_submit_file']);
echo '</div>' . K_NEWLINE;
echo '</form>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
echo '<div class="pagehelp">' . $l['hp_import_xml_questions'] . '</div>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
require_once '../code/tce_page_footer.php';
//============================================================+
// END OF FILE
//============================================================+
/**
 * Display a list of selected questions.
 * @author Nicola Asuni
 * @since 2005-07-06
 * @param $wherequery (string) question selection query
 * @param $subject_module_id (string) module ID
 * @param $subject_id (string) topic ID
 * @param $order_field (string) order by column name
 * @param $orderdir (int) oreder direction
 * @param $firstrow (int) number of first row to display
 * @param $rowsperpage (int) number of rows per page
 * @param $hide_answers (boolean) if true hide answers
 * @return false in case of empty database, true otherwise
 */
function F_show_select_questions($wherequery, $subject_module_id, $subject_id, $order_field, $orderdir, $firstrow, $rowsperpage, $hide_answers = false)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    require_once '../../shared/code/tce_functions_page.php';
    $subject_module_id = intval($subject_module_id);
    $subject_id = intval($subject_id);
    $orderdir = intval($orderdir);
    $firstrow = intval($firstrow);
    $rowsperpage = intval($rowsperpage);
    if (empty($order_field) or !in_array($order_field, array('question_id', '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', 'question_enabled DESC, question_position, CAST(question_description as varchar2(100))', 'question_enabled DESC, question_position, question_description'))) {
        $order_field = 'question_description';
    }
    if ($orderdir == 0) {
        $nextorderdir = 1;
        $full_order_field = $order_field;
    } else {
        $nextorderdir = 0;
        $full_order_field = $order_field . ' DESC';
    }
    if (!F_count_rows(K_TABLE_QUESTIONS)) {
        //if the table is void (no items) display message
        F_print_error('MESSAGE', $l['m_databasempty']);
        return FALSE;
    }
    if (empty($wherequery)) {
        $wherequery = 'WHERE question_subject_id=' . $subject_id . '';
    } else {
        $wherequery = F_escape_sql($db, $wherequery);
        $wherequery .= ' AND question_subject_id=' . $subject_id . '';
    }
    $sql = 'SELECT *
		FROM ' . K_TABLE_QUESTIONS . '
		' . $wherequery . '
		ORDER BY ' . $full_order_field;
    if (K_DATABASE_TYPE == 'ORACLE') {
        $sql = 'SELECT * FROM (' . $sql . ') WHERE rownum BETWEEN ' . $firstrow . ' AND ' . ($firstrow + $rowsperpage) . '';
    } else {
        $sql .= ' LIMIT ' . $rowsperpage . ' OFFSET ' . $firstrow . '';
    }
    if ($r = F_db_query($sql, $db)) {
        $questlist = '';
        $itemcount = $firstrow;
        while ($m = F_db_fetch_array($r)) {
            $itemcount++;
            $questlist .= '<li>' . K_NEWLINE;
            $questlist .= '<strong>' . $itemcount . '.</strong> ';
            $questlist .= '<input type="checkbox" name="questionid' . $itemcount . '" id="questionid' . $itemcount . '" value="' . $m['question_id'] . '" title="' . $l['w_select'] . '"';
            if (isset($_REQUEST['checkall']) and $_REQUEST['checkall'] == 1) {
                $questlist .= ' checked="checked"';
            }
            $questlist .= ' />';
            // display question description
            if (F_getBoolean($m['question_enabled'])) {
                $questlist .= '<acronym class="onbox" title="' . $l['w_enabled'] . '">+</acronym>';
            } else {
                $questlist .= '<acronym class="offbox" title="' . $l['w_disabled'] . '">-</acronym>';
            }
            switch ($m['question_type']) {
                case 1:
                    $questlist .= ' <acronym class="offbox" title="' . $l['w_single_answer'] . '">S</acronym>';
                    break;
                case 2:
                    $questlist .= ' <acronym class="offbox" title="' . $l['w_multiple_answers'] . '">M</acronym>';
                    break;
                case 3:
                    $questlist .= ' <acronym class="offbox" title="' . $l['w_free_answer'] . '">T</acronym>';
                    break;
                case 4:
                    $questlist .= ' <acronym class="offbox" title="' . $l['w_ordering_answer'] . '">O</acronym>';
                    break;
            }
            $questlist .= ' <acronym class="offbox" title="' . $l['h_question_difficulty'] . '">' . $m['question_difficulty'] . '</acronym>';
            if ($m['question_position'] > 0) {
                $questlist .= ' <acronym class="onbox" title="' . $l['h_position'] . '">' . intval($m['question_position']) . '</acronym>';
            } else {
                $questlist .= ' <acronym class="offbox" title="' . $l['h_position'] . '">&nbsp;</acronym>';
            }
            if (F_getBoolean($m['question_fullscreen'])) {
                $questlist .= ' <acronym class="onbox" title="' . $l['w_fullscreen'] . ': ' . $l['w_enabled'] . '">F</acronym>';
            } else {
                $questlist .= ' <acronym class="offbox" title="' . $l['w_fullscreen'] . ': ' . $l['w_disabled'] . '">&nbsp;</acronym>';
            }
            if (F_getBoolean($m['question_inline_answers'])) {
                $questlist .= ' <acronym class="onbox" title="' . $l['w_inline_answers'] . ': ' . $l['w_enabled'] . '">I</acronym>';
            } else {
                $questlist .= ' <acronym class="offbox" title="' . $l['w_inline_answers'] . ': ' . $l['w_disabled'] . '">&nbsp;</acronym>';
            }
            if (F_getBoolean($m['question_auto_next'])) {
                $questlist .= ' <acronym class="onbox" title="' . $l['w_auto_next'] . ': ' . $l['w_enabled'] . '">A</acronym>';
            } else {
                $questlist .= ' <acronym class="offbox" title="' . $l['w_auto_next'] . ': ' . $l['w_disabled'] . '">&nbsp;</acronym>';
            }
            if ($m['question_timer'] > 0) {
                $questlist .= ' <acronym class="onbox" title="' . $l['h_question_timer'] . '">' . intval($m['question_timer']) . '</acronym>';
            } else {
                $questlist .= ' <acronym class="offbox" title="' . $l['h_question_timer'] . '">&nbsp;</acronym>';
            }
            $questlist .= ' <a href="tce_edit_question.php?subject_module_id=' . $subject_module_id . '&amp;question_subject_id=' . $subject_id . '&amp;question_id=' . $m['question_id'] . '" title="' . $l['t_questions_editor'] . ' [ID = ' . $m['question_id'] . ']" class="xmlbutton">' . $l['w_edit'] . '</a>';
            $questlist .= '<br /><br />' . K_NEWLINE;
            $questlist .= '<div class="paddingleft">' . F_decode_tcecode($m['question_description']) . '</div>' . K_NEWLINE;
            if (K_ENABLE_QUESTION_EXPLANATION and !empty($m['question_explanation'])) {
                $questlist .= '<div class="paddingleft"><br /><span class="explanation">' . $l['w_explanation'] . ':</span><br />' . F_decode_tcecode($m['question_explanation']) . '</div>' . K_NEWLINE;
            }
            if (!$hide_answers) {
                // display alternative answers
                $sqla = 'SELECT *
					FROM ' . K_TABLE_ANSWERS . '
					WHERE answer_question_id=\'' . $m['question_id'] . '\'
					ORDER BY answer_enabled DESC,answer_position,answer_isright DESC';
                if ($ra = F_db_query($sqla, $db)) {
                    $answlist = '';
                    while ($ma = F_db_fetch_array($ra)) {
                        $answlist .= '<li>';
                        if (F_getBoolean($ma['answer_enabled'])) {
                            $answlist .= '<acronym class="onbox" title="' . $l['w_enabled'] . '">+</acronym>';
                        } else {
                            $answlist .= '<acronym class="offbox" title="' . $l['w_disabled'] . '">-</acronym>';
                        }
                        if ($m['question_type'] != 4) {
                            if (F_getBoolean($ma['answer_isright'])) {
                                $answlist .= ' <acronym class="okbox" title="' . $l['h_answer_right'] . '">T</acronym>';
                            } else {
                                $answlist .= ' <acronym class="nobox" title="' . $l['h_answer_wrong'] . '">F</acronym>';
                            }
                        }
                        if ($ma['answer_position'] > 0) {
                            $answlist .= ' <acronym class="onbox" title="' . $l['h_position'] . '">' . intval($ma['answer_position']) . '</acronym>';
                        } else {
                            $answlist .= ' <acronym class="offbox" title="' . $l['h_position'] . '">&nbsp;</acronym>';
                        }
                        if ($ma['answer_keyboard_key'] > 0) {
                            $answlist .= ' <acronym class="onbox" title="' . $l['h_answer_keyboard_key'] . '">' . F_text_to_xml(chr($ma['answer_keyboard_key'])) . '</acronym>';
                        } else {
                            $answlist .= ' <acronym class="offbox" title="' . $l['h_answer_keyboard_key'] . '">&nbsp;</acronym>';
                        }
                        $answlist .= ' <a href="tce_edit_answer.php?subject_module_id=' . $subject_module_id . '&amp;question_subject_id=' . $subject_id . '&amp;answer_question_id=' . $m['question_id'] . '&amp;answer_id=' . $ma['answer_id'] . '" title="' . $l['t_answers_editor'] . ' [ID = ' . $ma['answer_id'] . ']" class="xmlbutton">' . $l['w_edit'] . '</a>';
                        //$answlist .= " ";
                        //$answlist .= "".F_decode_tcecode($ma['answer_description'])."";
                        $answlist .= '<br /><br />' . K_NEWLINE;
                        $answlist .= '<div class="paddingleft">' . F_decode_tcecode($ma['answer_description']) . '</div>' . K_NEWLINE;
                        if (K_ENABLE_ANSWER_EXPLANATION and !empty($ma['answer_explanation'])) {
                            $answlist .= '<div class="paddingleft"><br /><span class="explanation">' . $l['w_explanation'] . ':</span><br />' . F_decode_tcecode($ma['answer_explanation']) . '</div>' . K_NEWLINE;
                        }
                        $answlist .= '</li>' . K_NEWLINE;
                    }
                    if (strlen($answlist) > 0) {
                        $questlist .= "<ol class=\"answer\">\n" . $answlist . "</ol><br /><br />\n";
                    }
                } else {
                    F_display_db_error();
                }
            }
            // end if hide_answers
            $questlist .= '</li>' . K_NEWLINE;
        }
        if (strlen($questlist) > 0) {
            // display the list
            echo '<ul class="question">' . K_NEWLINE;
            echo $questlist;
            echo '</ul>' . K_NEWLINE;
            echo '<div class="row"><hr /></div>' . K_NEWLINE;
            // check/uncheck all options
            echo '<span dir="' . $l['a_meta_dir'] . '">';
            echo '<input type="radio" name="checkall" id="checkall1" value="1" onclick="document.getElementById(\'form_selectquestions\').submit()" />';
            echo '<label for="checkall1">' . $l['w_check_all'] . '</label> ';
            echo '<input type="radio" name="checkall" id="checkall0" value="0" onclick="document.getElementById(\'form_selectquestions\').submit()" />';
            echo '<label for="checkall0">' . $l['w_uncheck_all'] . '</label>';
            echo '</span>' . K_NEWLINE;
            echo '&nbsp;';
            if ($l['a_meta_dir'] == 'rtl') {
                $arr = '&larr;';
            } else {
                $arr = '&rarr;';
            }
            // action options
            echo '<select name="menu_action" id="menu_action" size="0">' . K_NEWLINE;
            echo '<option value="0" style="color:gray">' . $l['m_with_selected'] . '</option>' . K_NEWLINE;
            echo '<option value="enable">' . $l['w_enable'] . '</option>' . K_NEWLINE;
            echo '<option value="disable">' . $l['w_disable'] . '</option>' . K_NEWLINE;
            echo '<option value="delete">' . $l['w_delete'] . '</option>' . K_NEWLINE;
            echo '<option value="copy">' . $l['w_copy'] . ' ' . $arr . '</option>' . K_NEWLINE;
            echo '<option value="move">' . $l['w_move'] . ' ' . $arr . '</option>' . K_NEWLINE;
            echo '</select>' . K_NEWLINE;
            // select new topic (for copy or move action)
            echo '<select name="new_subject_id" id="new_subject_id" size="0" title="' . $l['h_subject'] . '">' . K_NEWLINE;
            $sql = F_select_module_subjects_sql('module_enabled=\'1\' AND subject_enabled=\'1\'');
            if ($r = F_db_query($sql, $db)) {
                echo '<option value="0" style="color:gray">' . $l['w_subject'] . '</option>' . K_NEWLINE;
                $prev_module_id = 0;
                while ($m = F_db_fetch_array($r)) {
                    if ($m['module_id'] != $prev_module_id) {
                        $prev_module_id = $m['module_id'];
                        echo '<option value="0" style="color:gray;font-weight:bold;" disabled="disabled">* ' . htmlspecialchars($m['module_name'], ENT_NOQUOTES, $l['a_meta_charset']) . '</option>' . K_NEWLINE;
                    }
                    echo '<option value="' . $m['subject_id'] . '">&nbsp;&nbsp;&nbsp;&nbsp;' . htmlspecialchars($m['subject_name'], ENT_NOQUOTES, $l['a_meta_charset']) . '</option>' . K_NEWLINE;
                }
            } else {
                echo '</select>' . K_NEWLINE;
                F_display_db_error();
            }
            echo '</select>' . K_NEWLINE;
            // submit button
            F_submit_button("update", $l['w_update'], $l['h_update']);
        }
        // ---------------------------------------------------------------
        // -- page jumper (menu for successive pages)
        if ($rowsperpage > 0) {
            $sql = 'SELECT count(*) AS total FROM ' . K_TABLE_QUESTIONS . ' ' . $wherequery . '';
            if (!empty($order_field)) {
                $param_array = '&amp;order_field=' . urlencode($order_field) . '';
            }
            if (!empty($orderdir)) {
                $param_array .= '&amp;orderdir=' . $orderdir . '';
            }
            if (!empty($hide_answers)) {
                $param_array .= '&amp;hide_answers=' . intval($hide_answers) . '';
            }
            $param_array .= '&amp;subject_module_id=' . $subject_module_id . '';
            $param_array .= '&amp;subject_id=' . $subject_id . '';
            $param_array .= '&amp;submitted=1';
            F_show_page_navigator($_SERVER['SCRIPT_NAME'], $sql, $firstrow, $rowsperpage, $param_array);
        }
    } else {
        F_display_db_error();
    }
    return TRUE;
}