function eventOnQueryTestStatus($i_parameters = array())
{
    global $g_db, $G_SESSION, $lngstr, $srv_settings, $g_vars, $i_rSet1;
    $i_testno = $i_parameters['testno'];
    $i_testid = $i_parameters['testid'];
    $i_result = $i_parameters['status'];
    if ($i_rSet1->fields['test_prevtestid'] > 0 && getRecordCount($srv_settings['table_prefix'] . 'results', 'testid=' . $i_rSet1->fields['test_prevtestid'] . ' AND id=' . $G_SESSION['id'] . ' AND gscale_gradeid > 0') <= 0) {
        $g_vars['page']['test'][$i_testno]['visible'] = false;
        $i_result = IGT_TEST_STATUS_UNAVAILABLE;
    }
    return $i_result;
}
<?php

$f_testid = (int) readGetVar('testid');
$f_test_questionid = (int) readGetVar('test_questionid');
$i_questioncount = getRecordCount($srv_settings['table_prefix'] . 'tests_questions', "testid=" . $f_testid);
if ($f_test_questionid < $i_questioncount) {
    $g_db->Execute("LOCK TABLES " . $srv_settings['table_prefix'] . "tests_questions WRITE");
    $g_db->Execute("UPDATE " . $srv_settings['table_prefix'] . "tests_questions SET test_questionid=0 WHERE test_questionid=" . ($f_test_questionid + 1) . " AND testid=" . $f_testid);
    $g_db->Execute("UPDATE " . $srv_settings['table_prefix'] . "tests_questions SET test_questionid=test_questionid+1 WHERE test_questionid=" . $f_test_questionid . " AND testid=" . $f_testid);
    $g_db->Execute("UPDATE " . $srv_settings['table_prefix'] . "tests_questions SET test_questionid=" . $f_test_questionid . " WHERE test_questionid=0 AND testid=" . $f_testid);
    $g_db->Execute("UNLOCK TABLES");
}
gotoLocation('test-manager.php' . getURLAddon('?action=editt', array('action')));
function createGrade($i_gscaleid)
{
    global $g_db, $srv_settings;
    $i_gradecount = 0;
    $i_gradecount = getRecordCount($srv_settings['table_prefix'] . 'gscales_grades', 'gscaleid=' . $i_gscaleid);
    $i_gradecount++;
    if ($g_db->Execute("INSERT INTO " . $srv_settings['table_prefix'] . "gscales_grades (gscale_gradeid, gscaleid, grade_feedback) VALUES(" . $i_gradecount . ", " . $i_gscaleid . ", '')") === false) {
        showDBError(__FILE__, 2);
    }
    return $i_gradecount;
}
$i_order_no = isset($_GET["order"]) ? (int) $_GET["order"] : 0;
if ($i_order_no >= count($i_tablefields)) {
    $i_order_no = -1;
}
if ($i_order_no >= 0) {
    $i_direction = isset($_GET["direction"]) && $_GET["direction"] ? "DESC" : "";
    $i_order_addon = "&order=" . $i_order_no . "&direction=" . $i_direction;
    $i_sql_order_addon = " ORDER BY " . $i_tablefields[$i_order_no][2] . " " . $i_direction;
}
$i_url_limitto_addon = "";
$i_url_pageno_addon = "";
$i_url_limit_addon = "";
$i_pageno = 0;
$i_limitcount = isset($_GET["limitto"]) ? (int) $_GET["limitto"] : $G_SESSION['config_itemsperpage'];
if ($i_limitcount > 0) {
    $i_recordcount = getRecordCount($srv_settings['table_prefix'] . 'tests', $i_sql_where_addon . "1=1");
    $i_pageno = isset($_GET["pageno"]) ? (int) $_GET["pageno"] : 1;
    if ($i_pageno < 1) {
        $i_pageno = 1;
    }
    $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    $i_pageno_count = floor(($i_recordcount - 1) / $i_limitcount) + 1;
    if ($i_limitfrom > $i_recordcount) {
        $i_pageno = $i_pageno_count;
        $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    }
    $i_url_limitto_addon .= "&limitto=" . $i_limitcount;
    $i_url_pageno_addon .= "&pageno=" . $i_pageno;
    $i_url_limit_addon .= $i_url_limitto_addon . $i_url_pageno_addon;
} else {
    $i_url_limitto_addon = "&limitto=";
$i_order_no = isset($_GET["order"]) ? (int) $_GET["order"] : 0;
if ($i_order_no >= count($i_tablefields)) {
    $i_order_no = -1;
}
if ($i_order_no >= 0) {
    $i_direction = isset($_GET["direction"]) && $_GET["direction"] ? "DESC" : "";
    $i_order_addon = "&order=" . $i_order_no . "&direction=" . $i_direction;
    $i_sql_order_addon = " ORDER BY " . $i_tablefields[$i_order_no][2] . " " . $i_direction;
}
$i_url_limitto_addon = "";
$i_url_pageno_addon = "";
$i_url_limit_addon = "";
$i_pageno = 0;
$i_limitcount = isset($_GET["limitto"]) ? (int) $_GET["limitto"] : $G_SESSION['config_itemsperpage'];
if ($i_limitcount > 0) {
    $i_recordcount = getRecordCount($srv_settings['table_prefix'] . 'sections', "testid=" . $f_testid);
    $i_pageno = isset($_GET["pageno"]) ? (int) $_GET["pageno"] : 1;
    if ($i_pageno < 1) {
        $i_pageno = 1;
    }
    $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    $i_pageno_count = floor(($i_recordcount - 1) / $i_limitcount) + 1;
    if ($i_limitfrom > $i_recordcount) {
        $i_pageno = $i_pageno_count;
        $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    }
    $i_url_limitto_addon .= "&limitto=" . $i_limitcount;
    $i_url_pageno_addon .= "&pageno=" . $i_pageno;
    $i_url_limit_addon .= $i_url_limitto_addon . $i_url_pageno_addon;
} else {
    $i_url_limitto_addon = "&limitto=";
function initATest($testid, $existing_resultid = 0, $existing_answered_questionids = array())
{
    global $g_db, $G_SESSION, $lngstr, $srv_settings, $g_vars;
    $i_now = time();
    $i_rSet1 = $g_db->SelectLimit("SELECT * FROM " . $srv_settings['table_prefix'] . "tests WHERE testid=" . $testid . " AND test_enabled=1 AND test_datestart<=" . $i_now . " AND test_dateend>" . $i_now, 1);
    if (!$i_rSet1) {
        showDBError(__FILE__, 1);
    } else {
        if (!$i_rSet1->EOF) {
            $i_isallowed = $i_rSet1->fields['test_forall'];
            if (!$i_isallowed) {
                //9917//9917
                $i_isallowed = getRecordCount($srv_settings['table_prefix'] . 'groups_users, ' . $srv_settings['table_prefix'] . 'groups_tests', "(" . $srv_settings['table_prefix'] . "groups_tests.testid=" . $i_rSet1->fields['testid'] . " AND " . $srv_settings['table_prefix'] . "groups_tests.groupid=" . $srv_settings['table_prefix'] . "groups_users.groupid AND " . $srv_settings['table_prefix'] . "groups_users.id=" . $G_SESSION['id'] . ")") > 0;
            }
            if ($i_isallowed) {
                $i_isallowed = $i_rSet1->fields['test_price'] <= 0 || getRecordCount($srv_settings['table_prefix'] . 'tests_own', 'testid=' . $testid . ' AND id=' . $G_SESSION['id']) > 0;
            }
            if ($i_isallowed) {
                $yt_questionids = array();
                $i_rSet2 = $g_db->Execute("SELECT " . $srv_settings['table_prefix'] . "tests_questions.questionid, " . $srv_settings['table_prefix'] . "tests_questions.test_sectionid, " . $srv_settings['table_prefix'] . "questions.subjectid, " . $srv_settings['table_prefix'] . "questions.question_points, " . $srv_settings['table_prefix'] . "questions.question_type FROM " . $srv_settings['table_prefix'] . "tests_questions, " . $srv_settings['table_prefix'] . "questions WHERE testid=" . $testid . " AND " . $srv_settings['table_prefix'] . "tests_questions.questionid=" . $srv_settings['table_prefix'] . "questions.questionid ORDER BY " . $srv_settings['table_prefix'] . "tests_questions.test_questionid");
                if (!$i_rSet2) {
                    showDBError(__FILE__, 2);
                } else {
                    $i_questioncounter = 0;
                    $yt_pointsmax = 0;
                    while (!$i_rSet2->EOF) {
                        if ($i_rSet2->fields['question_type'] != QUESTION_TYPE_RANDOM) {
                            $yt_questionids[$i_questioncounter + 1] = $i_rSet2->fields['questionid'];
                            $yt_pointsmax += $i_rSet2->fields['question_points'];
                            $i_questioncounter++;
                        } else {
                            $i_questioncount_by_subjectid = getRecordCount($srv_settings['table_prefix'] . 'questions', "subjectid=" . $i_rSet2->fields['subjectid'] . " AND question_type NOT IN (" . QUESTION_TYPE_RANDOM . ")" . ($yt_questionids ? " AND questionid NOT IN (" . implode(',', $yt_questionids) . ")" : ""));
                            if ($i_questioncount_by_subjectid > 0) {
                                srand((double) microtime() * 10000000);
                                $i_rSet3 = $g_db->SelectLimit("SELECT questionid, question_points FROM " . $srv_settings['table_prefix'] . "questions WHERE subjectid=" . $i_rSet2->fields['subjectid'] . " AND question_type NOT IN (" . QUESTION_TYPE_RANDOM . ")" . ($yt_questionids ? " AND questionid NOT IN (" . implode(',', $yt_questionids) . ")" : ""), 1, rand(0, $i_questioncount_by_subjectid - 1));
                                if (!$i_rSet3) {
                                    showDBError(__FILE__, 3);
                                } else {
                                    if (!$i_rSet3->EOF) {
                                        $yt_questionids[$i_questioncounter + 1] = $i_rSet3->fields['questionid'];
                                        $yt_pointsmax += $i_rSet3->fields['question_points'];
                                        $i_questioncounter++;
                                    }
                                    $i_rSet3->Close();
                                }
                            } else {
                                showError(__FILE__, $lngstr['err_no_questions_left_in_bank']);
                            }
                        }
                        $i_rSet2->MoveNext();
                    }
                    $i_rSet2->Close();
                }
                $yt_questioncount = $i_questioncounter;
                if ($yt_questioncount > 0) {
                    for ($i = 0; $i < $yt_questioncount; $i++) {
                        $yt_questions[$i] = $i + 1;
                    }
                    if ($i_rSet1->fields['test_shuffleq']) {
                        $yt_questions_2 = array();
                        if (!empty($existing_answered_questionids)) {
                            foreach ($existing_answered_questionids as $key => $val) {
                                foreach ($yt_questionids as $key2 => $val2) {
                                    if ($val2 == $val) {
                                        $i_questionno = $key2;
                                        break;
                                    }
                                }
                                $yt_questions_2[$key] = $i_questionno;
                                unset($yt_questions[$i_questionno - 1]);
                            }
                        }
                        $yt_questions = array_merge($yt_questions_2, getShuffledArray($yt_questions));
                    }
                    $yt_shufflea = (bool) $i_rSet1->fields['test_shufflea'];
                    $i_testtime = (int) $i_rSet1->fields['test_time'];
                    $yt_test_timeforceout = (bool) $i_rSet1->fields['test_timeforceout'];
                    if ($i_testtime < 0) {
                        $i_testtime = 0;
                    }
                    $G_SESSION['testid'] = $testid;
                    if ($existing_resultid > 0) {
                        $G_SESSION['resultid'] = $existing_resultid;
                    } else {
                        if ($g_db->Execute("INSERT INTO " . $srv_settings['table_prefix'] . "results (testid,id,result_datestart) VALUES (" . $testid . "," . $G_SESSION['id'] . "," . $i_now . ")") === false) {
                            showDBError(__FILE__, 5);
                        }
                        $G_SESSION['resultid'] = $g_db->Insert_ID($srv_settings['table_prefix'] . 'results', 'resultid');
                    }
                    $G_SESSION['yt_name'] = $i_rSet1->fields['test_name'];
                    $G_SESSION['yt_result_etemplateid'] = $i_rSet1->fields['result_etemplateid'];
                    if ($i_rSet1->fields['result_etemplateid'] > 0) {
                        $G_SESSION['yt_result_email'] = trim($i_rSet1->fields['test_result_email']);
                        $G_SESSION['yt_result_emailtouser'] = $i_rSet1->fields['test_result_emailtouser'];
                    }
                    $G_SESSION['yt_teststart'] = $i_now;
                    $G_SESSION['yt_testtime'] = $i_testtime;
                    $G_SESSION['yt_timeforceout'] = $yt_test_timeforceout;
                    $G_SESSION['yt_attempts'] = $i_rSet1->fields['test_attempts'];
                    $G_SESSION['yt_pointsmax'] = $yt_pointsmax;
                    $G_SESSION['yt_questioncount'] = $yt_questioncount;
                    $G_SESSION['yt_questions'] = $yt_questions;
                    $G_SESSION['yt_questionids'] = $yt_questionids;
                    $G_SESSION['yt_answers'] = array();
                    $G_SESSION['yt_shufflea'] = $yt_shufflea;
                    $G_SESSION['yt_test_qsperpage'] = $i_rSet1->fields['test_qsperpage'];
                    $G_SESSION['yt_test_showqfeedback'] = (bool) $i_rSet1->fields['test_showqfeedback'];
                    $G_SESSION['yt_result_showanswers'] = (bool) $i_rSet1->fields['test_result_showanswers'];
                    $G_SESSION['yt_result_showpoints'] = (bool) $i_rSet1->fields['test_result_showpoints'];
                    $G_SESSION['yt_result_showgrade'] = (bool) $i_rSet1->fields['test_result_showgrade'];
                    $G_SESSION['yt_result_showgradefeedback'] = (bool) $i_rSet1->fields['test_result_showgradefeedback'];
                    $G_SESSION['yt_result_showhtml'] = (bool) $i_rSet1->fields['test_result_showhtml'] && $i_rSet1->fields['rtemplateid'] > 0;
                    $G_SESSION['yt_result_showpdf'] = (bool) $i_rSet1->fields['test_result_showpdf'] && $i_rSet1->fields['rtemplateid'] > 0;
                    $G_SESSION['yt_result_rtemplateid'] = $i_rSet1->fields['test_result_rtemplateid'];
                    $G_SESSION['yt_reportgradecondition'] = $i_rSet1->fields['test_reportgradecondition'];
                    $G_SESSION['yt_gscaleid'] = (int) $i_rSet1->fields['gscaleid'];
                    $G_SESSION['yt_prevtestid'] = (int) $i_rSet1->fields['test_prevtestid'];
                    $G_SESSION['yt_nexttestid'] = (int) $i_rSet1->fields['test_nexttestid'];
                    $G_SESSION['yt_other_repeatuntilcorrect'] = (bool) $i_rSet1->fields['test_other_repeatuntilcorrect'];
                    $G_SESSION['yt_contentprotection'] = (int) $i_rSet1->fields['test_contentprotection'];
                    $G_SESSION['yt_canreview'] = (int) $i_rSet1->fields['test_canreview'];
                    $G_SESSION['yt_subjects'] = array();
                    $G_SESSION['yt_questionno'] = 1;
                    $G_SESSION['yt_got_answers'] = 0;
                    $G_SESSION['yt_got_points'] = 0;
                    $G_SESSION['yt_points_pending'] = 0;
                    if (!empty($i_rSet1->fields['test_instructions'])) {
                        $G_SESSION['yt_state'] = TEST_STATE_TESTINTRO;
                    } else {
                        $G_SESSION['yt_state'] = TEST_STATE_QSHOW;
                    }
                    eventOnBeforeTestStart();
                    return true;
                } else {
                    $g_vars['page']['errors'] = $lngstr['err_no_questions'];
                    return false;
                }
            } else {
                $g_vars['page']['notifications'] = $lngstr['inf_cant_passtest'];
                return false;
            }
        } else {
            $g_vars['page']['errors'] = $lngstr['err_no_tests'];
            return false;
        }
        $i_rSet1->Close();
    }
}
function writeResultStats($i_resultid)
{
    global $g_db, $lngstr, $srv_settings, $g_vars;
    $g_vars['page']['resultid'] = $i_resultid;
    $i_testid = 0;
    $i_rSet6 = $g_db->SelectLimit("SELECT * FROM " . $srv_settings['table_prefix'] . "results WHERE resultid=" . $i_resultid, 1);
    if (!$i_rSet6) {
        showDBError(__FILE__, 6);
    } else {
        if (!$i_rSet6->EOF) {
            $i_testid = $i_rSet6->fields['testid'];
            $g_vars['page']['result_date'] = getDateLocal($lngstr['language']['date_format_full'], $i_rSet6->fields['result_datestart']);
            $g_vars['page']['time_spent'] = getTimeFormatted($i_rSet6->fields['result_timespent']);
            $g_vars['page']['got_points'] = $i_rSet6->fields['result_points'];
            $g_vars['page']['points_max'] = $i_rSet6->fields['result_pointsmax'];
            $g_vars['page']['score'] = $g_vars['page']['points_max'] != 0 ? round($g_vars['page']['got_points'] * 100 / $g_vars['page']['points_max']) : 100;
            $g_vars['page']['grade'] = getGradeData($i_rSet6->fields['gscaleid'], $i_rSet6->fields['gscale_gradeid']);
            $i_id = $i_rSet6->fields['id'];
            $i_rSet7 = $g_db->SelectLimit("SELECT * FROM " . $srv_settings['table_prefix'] . "users WHERE id=" . $i_id, 1);
            if (!$i_rSet7) {
                showDBError(__FILE__, 7);
            } else {
                if (!$i_rSet7->EOF) {
                    $g_vars['page']['username'] = $i_rSet7->fields['user_firstname'] . ' ' . $i_rSet7->fields['user_lastname'];
                }
                $i_rSet7->Close();
            }
        }
        $i_rSet6->Close();
    }
    $g_vars['page']['test_name'] = '';
    $i_gscaleid = 0;
    $i_rSet1 = $g_db->SelectLimit("SELECT * FROM " . $srv_settings['table_prefix'] . "tests WHERE testid=" . $i_testid, 1);
    if (!$i_rSet1) {
        showDBError(__FILE__, 1);
    } else {
        if (!$i_rSet1->EOF) {
            $g_vars['page']['test_name'] = $i_rSet1->fields['test_name'];
            $i_gscaleid = $i_rSet1->fields['gscaleid'];
        }
        $i_rSet1->Close();
    }
    $g_vars['page']['grades_times_total'] = 0;
    $i_rSet2 = $g_db->Execute("SELECT * FROM " . $srv_settings['table_prefix'] . "gscales_grades WHERE gscaleid=" . $i_gscaleid . " ORDER BY gscale_gradeid");
    if (!$i_rSet2) {
        showDBError(__FILE__, 2);
    } else {
        while (!$i_rSet2->EOF) {
            $i_gradeid = $i_rSet2->fields['gscale_gradeid'];
            $g_vars['page']['grades'][$i_gradeid]['name'] = $i_rSet2->fields['grade_name'];
            $g_vars['page']['grades'][$i_gradeid]['times'] = getRecordCount($srv_settings['table_prefix'] . 'results', 'testid=' . $i_testid . ' AND gscaleid=' . $i_gscaleid . ' AND gscale_gradeid=' . $i_gradeid);
            $g_vars['page']['grades_times_total'] += $g_vars['page']['grades'][$i_gradeid]['times'];
            $i_rSet2->MoveNext();
        }
        $i_rSet2->Close();
    }
    foreach ($g_vars['page']['grades'] as $i_gradeid => $i_grade) {
        $g_vars['page']['grades'][$i_gradeid]['times_percents'] = $g_vars['page']['grades_times_total'] != 0 ? $g_vars['page']['grades'][$i_gradeid]['times'] * 100 / $g_vars['page']['grades_times_total'] : 0;
    }
    $g_vars['page']['test']['participant_count'] = 0;
    $i_points_all = array();
    $g_vars['page']['test']['points_max'] = 0;
    $g_vars['page']['test']['points_low'] = IGT_MAX_FLOAT;
    $g_vars['page']['test']['points_high'] = 0;
    $i_points_total = 0;
    $g_vars['page']['test']['points_total_max'] = 0;
    $i_rSet3 = $g_db->Execute("SELECT * FROM " . $srv_settings['table_prefix'] . "results WHERE testid=" . $i_testid . " AND gscale_gradeid > 0");
    if (!$i_rSet3) {
        showDBError(__FILE__, 3);
    } else {
        while (!$i_rSet3->EOF) {
            $g_vars['page']['test']['participant_count']++;
            $i_points = $i_rSet3->fields['result_points'];
            array_push($i_points_all, $i_points);
            $g_vars['page']['test']['points_max'] = $i_rSet3->fields['result_pointsmax'];
            if ($i_points > $g_vars['page']['test']['points_high']) {
                $g_vars['page']['test']['points_high'] = $i_points;
            }
            if ($i_points < $g_vars['page']['test']['points_low']) {
                $g_vars['page']['test']['points_low'] = $i_points;
            }
            $i_points_total += $i_points;
            $g_vars['page']['test']['points_total_max'] += $g_vars['page']['test']['points_max'];
            $i_rSet3->MoveNext();
        }
        $i_rSet3->Close();
    }
    $g_vars['page']['test']['points_average'] = $i_points_total / $g_vars['page']['test']['participant_count'];
    $g_vars['page']['test']['points_average_percents'] = $i_points_total * 100 / $g_vars['page']['test']['points_total_max'];
    $g_vars['page']['test']['points_high_percents'] = $g_vars['page']['test']['points_high'] * 100 / $g_vars['page']['test']['points_max'];
    $g_vars['page']['test']['points_low_percents'] = $g_vars['page']['test']['points_low'] * 100 / $g_vars['page']['test']['points_max'];
    $g_vars['page']['test']['variance'] = 0;
    if ($g_vars['page']['test']['participant_count'] > 1) {
        foreach ($i_points_all as $i_points) {
            $g_vars['page']['test']['variance'] += ($i_points - $g_vars['page']['test']['points_average']) * ($i_points - $g_vars['page']['test']['points_average']);
        }
        $g_vars['page']['test']['variance'] = $g_vars['page']['test']['variance'] / ($g_vars['page']['test']['participant_count'] - 1);
    }
    $g_vars['page']['test']['std_deviation'] = sqrt($g_vars['page']['test']['variance']);
    $g_vars['page']['questions'] = array();
    $i_rSet4 = $g_db->Execute("SELECT questionid, result_answer_iscorrect FROM " . $srv_settings['table_prefix'] . "results_answers WHERE resultid=" . $i_resultid);
    if (!$i_rSet4) {
        showDBError(__FILE__, 4);
    } else {
        while (!$i_rSet4->EOF) {
            $i_questionid = $i_rSet4->fields['questionid'];
            $g_vars['page']['questions'][$i_questionid]['iscorrect'] = $i_rSet4->fields['result_answer_iscorrect'];
            $i_rSet4->MoveNext();
        }
        $i_rSet4->Close();
    }
    $g_vars['page']['subjects'] = array();
    foreach ($g_vars['page']['questions'] as $i_questionid => $i_question) {
        $i_rSet5 = $g_db->SelectLimit("SELECT " . $srv_settings['table_prefix'] . "subjects.subjectid, " . $srv_settings['table_prefix'] . "subjects.subject_name FROM " . $srv_settings['table_prefix'] . "questions, " . $srv_settings['table_prefix'] . "subjects WHERE questionid=" . $i_questionid . " AND " . $srv_settings['table_prefix'] . "questions.subjectid=" . $srv_settings['table_prefix'] . "subjects.subjectid", 1);
        if (!$i_rSet5) {
            showDBError(__FILE__, 5);
        } else {
            if (!$i_rSet5->EOF) {
                $i_subjectid = $i_rSet5->fields['subjectid'];
                $g_vars['page']['subjects'][$i_subjectid]['question_count'] = getRecordCount($srv_settings['table_prefix'] . 'questions', 'subjectid=' . $i_subjectid);
                if (!isset($g_vars['page']['subjects'][$i_subjectid]['question_got'])) {
                    $g_vars['page']['subjects'][$i_subjectid]['name'] = $i_rSet5->fields['subject_name'];
                    $g_vars['page']['subjects'][$i_subjectid]['question_got'] = 0;
                    $g_vars['page']['subjects'][$i_subjectid]['question_correct'] = 0;
                }
                $g_vars['page']['subjects'][$i_subjectid]['question_got']++;
                if ($i_question['iscorrect'] == IGT_ANSWER_IS_CORRECT) {
                    $g_vars['page']['subjects'][$i_subjectid]['question_correct']++;
                }
            }
            $i_rSet5->Close();
        }
    }
    foreach ($g_vars['page']['subjects'] as $i_subjectid => $i_grade) {
        $g_vars['page']['subjects'][$i_subjectid]['question_correct_percents'] = $g_vars['page']['subjects'][$i_subjectid]['question_correct'] * 100 / $g_vars['page']['subjects'][$i_subjectid]['question_got'];
    }
}
    }
}
if (getConfigItem(CONFIG_reg_userfield9) > CONFIG_CONST_donotshow) {
    if (isset($_POST['user_ufield9'])) {
        $arrValuesToUpdate['user_ufield9'] = readPostVar('user_ufield9');
    }
}
if (getConfigItem(CONFIG_reg_userfield10) > CONFIG_CONST_donotshow) {
    if (isset($_POST['user_ufield10'])) {
        $arrValuesToUpdate['user_ufield10'] = readPostVar('user_ufield10');
    }
}
if (isset($_POST['user_notes'])) {
    $arrValuesToUpdate['user_notes'] = readPostVar('user_notes');
}
$bIsUserNameDuplicated = getRecordCount($srv_settings['table_prefix'] . 'users', 'username='******'username'] . (!$bIsNewUser ? ' AND id<>' . $arrValuesToUpdate['id'] : '')) > 0;
if ($bIsUserNameDuplicated) {
    $g_vars['page']['errors'] .= $lngstr['err_username_duplicate'];
}
if ($g_vars['page']['errors']) {
    include_once $DOCUMENT_PAGES . "manageusers-2.inc.php";
} else {
    if ($bIsNewUser) {
        $f_id = addNewUser($arrValuesToUpdate, array(), true);
    } else {
        updateUser($arrValuesToUpdate);
    }
    if (isset($_POST['group']) && !empty($_POST['group'][0])) {
        $arrGroupIDsNew = readPostVar('group');
        unset($arrGroupIDsNew[0]);
        $arrGroupIDsToAdd = array();
 $i_isallowed = $i_rSet1->fields['test_forall'];
 if (!$i_isallowed) {
     //9917//9917
     $i_isallowed = getRecordCount($srv_settings['table_prefix'] . 'groups_users, ' . $srv_settings['table_prefix'] . 'groups_tests', "(" . $srv_settings['table_prefix'] . "groups_tests.testid=" . $i_rSet1->fields['testid'] . " AND " . $srv_settings['table_prefix'] . "groups_tests.groupid=" . $srv_settings['table_prefix'] . "groups_users.groupid AND " . $srv_settings['table_prefix'] . "groups_users.id=" . $G_SESSION['id'] . ")") > 0;
 }
 if ($i_isallowed) {
     $i_test_count++;
     $g_vars['page']['test'][$i_test_count]['testid'] = $i_rSet1->fields['testid'];
     $g_vars['page']['test'][$i_test_count]['name'] = $i_rSet1->fields['test_name'] ? convertTextValue($i_rSet1->fields['test_name']) : $lngstr['label_noname'];
     $g_vars['page']['test'][$i_test_count]['code'] = $i_rSet1->fields['test_code'];
     $g_vars['page']['test'][$i_test_count]['description'] = convertTextValue($i_rSet1->fields['test_description']);
     $g_vars['page']['test'][$i_test_count]['startdate'] = $i_rSet1->fields['test_datestart'];
     $g_vars['page']['test'][$i_test_count]['attempts'] = getTestAttemptsUsed($i_rSet1->fields['testid'], $G_SESSION['id']);
     $g_vars['page']['test'][$i_test_count]['attempts_total'] = $i_rSet1->fields['test_attempts'];
     $g_vars['page']['test'][$i_test_count]['test_price'] = $i_rSet1->fields['test_price'] / 100;
     $g_vars['page']['test'][$i_test_count]['test_purchased'] = $i_rSet1->fields['test_price'] <= 0 || getRecordCount($srv_settings['table_prefix'] . 'tests_own', 'testid=' . $i_rSet1->fields['testid'] . ' AND id=' . $G_SESSION['id']) > 0;
     $g_vars['page']['test'][$i_test_count]['content_protection'] = $i_rSet1->fields['test_contentprotection'];
     $g_vars['page']['test'][$i_test_count]['status'] = IGT_TEST_STATUS_UNAVAILABLE;
     $g_vars['page']['test'][$i_test_count]['visible'] = true;
     if ($i_rSet1->fields['test_datestart'] > $now) {
         $g_vars['page']['test'][$i_test_count]['status_label'] = sprintf($lngstr['page_panel_status_will_be_available_on'], getDateLocal($lngstr['language']['date_format'], $i_rSet1->fields['test_datestart']));
     } else {
         if ($g_vars['page']['test'][$i_test_count]['attempts_total'] > 0) {
             if ($g_vars['page']['test'][$i_test_count]['attempts'] >= $g_vars['page']['test'][$i_test_count]['attempts_total']) {
                 $g_vars['page']['test'][$i_test_count]['status_label'] = $lngstr['page-takeatest']['attempts_limit_reached'];
             } else {
                 $g_vars['page']['test'][$i_test_count]['status_label'] = sprintf($lngstr['page-takeatest']['attempts_left'], $g_vars['page']['test'][$i_test_count]['attempts_total'] - $g_vars['page']['test'][$i_test_count]['attempts']);
                 $g_vars['page']['test'][$i_test_count]['status'] = IGT_TEST_STATUS_AVAILABLE;
             }
         } else {
             $g_vars['page']['test'][$i_test_count]['status_label'] = $lngstr['page_panel_status_available'];
        echo '<td width=32><img src="images/button-last-big-inactive.gif" border=0 title="' . $lngstr['button_last_page'] . '"></td>';
    }
}
echo '<td width=2><img src="images/toolbar-right.gif" width=2 height=32></td></tr></table>';
echo '</td></tr><tr><td>';
echo '<table class=rowtable2 cellpadding=5 cellspacing=1 border=0 width="100%">';
echo '<tr vAlign=top><td class=rowhdr1 title="' . $lngstr['label_hdr_select_hint'] . '" width=22><input type=checkbox name=toggleAll onclick="toggleCBs(this);"></td>';
writeQryTableHeaders('test-manager.php?action=groups' . $i_testids_addon . $i_order_addon . $i_2_url_limit_addon, $i_2_tablefields, $i_2_order_no, $i_2_direction, '2');
echo '<td class=rowhdr1 title="' . $lngstr['page_assignto_hdr_assignto_hint'] . '" vAlign=top>' . $lngstr['page_assignto_hdr_assignto'] . '</td>';
echo '<td class=rowhdr1 colspan=2>' . $lngstr['label_hdr_action'] . '</td></tr>';
//9917
$i_rSet3 = $g_db->SelectLimit("SELECT * FROM " . $srv_settings['table_prefix'] . "groups" . $i_2_sql_order_addon, $i_2_limitcount, $i_2_limitfrom);
if (!$i_rSet3) {
    showDBError(__FILE__, 3);
} else {
    $i_counter = 0;
    while (!$i_rSet3->EOF) {
        //9917
        $i_member_count = getRecordCount($srv_settings['table_prefix'] . 'groups_tests', $i_sql_where_addon . "groupid=" . $i_rSet3->fields["groupid"]);
        $rowname = $i_counter % 2 ? "rowone" : "rowtwo";
        echo '<tr id=tr_' . $i_pagewide_id . ' class=' . $rowname . ' onmouseover="rollTR(' . $i_pagewide_id . ',1);" onmouseout="rollTR(' . $i_pagewide_id . ',0);"><td align=center width=22' . ($i_rSet3->fields["groupid"] > SYSTEM_GROUP_MAX_INDEX ? '' : ' class=system') . '><input id=cb_' . $i_pagewide_id . ' type=checkbox name=box_groups[] value="' . $i_rSet3->fields["groupid"] . '" onclick="toggleCB(this);"></td><td align=right>' . $i_rSet3->fields["groupid"] . '</td><td>' . getTruncatedHTML($i_rSet3->fields["group_name"]) . '</td><td>' . $i_rSet3->fields["group_description"] . '</td><td align=center><a href="test-manager.php?action=assignto&groupid=' . $i_rSet3->fields["groupid"] . $i_order_addon . $i_testids_addon . $i_2_url_limit_addon . '&set=' . ($i_member_count >= sizeof($f_testids) ? '0"><img src="images/button-checkbox-2.gif" width=13 height=13 border=0 title="' . $lngstr['label_yes'] . '">' : ($i_member_count > 0 ? '1"><img src="images/button-checkbox-1.gif" width=13 height=13 border=0 title="' . $lngstr['label_partially'] . '">' : '1"><img src="images/button-checkbox-0.gif" width=13 height=13 border=0 title="' . $lngstr['label_no'] . '">')) . '</a></td>';
        echo '<td align=center width=22><a href="groups.php?groupid=' . $i_rSet3->fields["groupid"] . '&action=edit"><img width=20 height=20 border=0 src="images/button-edit.gif" title="' . $lngstr['label_action_group_edit'] . '"></a></td><td align=center width=22>' . ($i_rSet3->fields["groupid"] > SYSTEM_GROUP_MAX_INDEX ? '<a href="groups.php?groupid=' . $i_rSet3->fields["groupid"] . '&action=delete" onclick="return confirmMessage(this, \'' . $lngstr['qst_delete_group'] . '\')"><img width=20 height=20 border=0 src="images/button-cross.gif" title="' . $lngstr['label_action_group_delete'] . '"></a>' : '<img width=20 height=20 border=0 src="images/button-cross-inactive.gif">') . '</td></tr>';
        $i_counter++;
        $i_pagewide_id++;
        $i_rSet3->MoveNext();
    }
    $i_rSet3->Close();
}
echo '</table>';
echo '</td></tr></table></form>';
displayTemplate('_footer');
$i_order_no = isset($_GET['order']) ? (int) $_GET['order'] : 0;
if ($i_order_no >= count($g_vars['page']['tables'][1]['columns'])) {
    $i_order_no = -1;
}
if ($i_order_no >= 0) {
    $i_direction = isset($_GET['direction']) && $_GET['direction'] ? 'DESC' : '';
    $i_order_addon = '&order=' . $i_order_no . '&direction=' . $i_direction;
    $i_sql_order_addon = ' ORDER BY ' . $g_vars['page']['tables'][1]['columns'][$i_order_no][2] . ' ' . $i_direction;
}
$i_url_limitto_addon = '';
$i_url_pageno_addon = '';
$i_url_limit_addon = '';
$i_pageno = 0;
$i_limitcount = isset($_GET['limitto']) ? (int) $_GET['limitto'] : $G_SESSION['config_itemsperpage'];
if ($i_limitcount > 0) {
    $i_recordcount = getRecordCount($srv_settings['table_prefix'] . 'results, ' . $srv_settings['table_prefix'] . 'users, ' . $srv_settings['table_prefix'] . 'tests, ' . $srv_settings['table_prefix'] . 'gscales_grades', $i_sql_where_addon);
    $i_pageno = isset($_GET['pageno']) ? (int) $_GET['pageno'] : 1;
    if ($i_pageno < 1) {
        $i_pageno = 1;
    }
    $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    $i_pageno_count = floor(($i_recordcount - 1) / $i_limitcount) + 1;
    if ($i_limitfrom > $i_recordcount) {
        $i_pageno = $i_pageno_count;
        $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    }
    $i_url_limitto_addon .= '&limitto=' . $i_limitcount;
    $i_url_pageno_addon .= '&pageno=' . $i_pageno;
    $i_url_limit_addon .= $i_url_limitto_addon . $i_url_pageno_addon;
} else {
    $i_url_limitto_addon = '&limitto=';
<?php

defined('IGT_VALID_ENVIRONMENT') or exit('Restricted access');
$g_vars['page']['hide_cpanel'] = true;
$f_username = readPostVar('username');
$g_vars['page']['username'] = convertTextValue($f_username);
$g_vars['page']['gotourl'] = @htmlspecialchars($_SERVER['REQUEST_URI']);
$g_vars['page']['cansigninasguest'] = getRecordCount($srv_settings['table_prefix'] . 'users', 'id=' . SYSTEM_GROUP_GUEST_id . ' AND user_enabled=1') > 0;
$g_vars['page']['test_code'] = isset($G_SESSION['test_code']) ? $G_SESSION['test_code'] : '';
$g_vars['page']['can_register'] = getConfigItem(CONFIG_can_register);
eventOnBeforePageGeneration(array('page_name' => 'signin'));
$g_smarty->assign('g_vars', $g_vars);
displayTemplate('signin');
<?php

$f_id = (int) readGetVar('id');
$f_checkword = readGetVar('checkword');
$f_checkword = $g_db->qstr($f_checkword, get_magic_quotes_gpc());
$i_isok = getRecordCount($srv_settings['table_prefix'] . 'users', 'id=' . $f_id . ' AND user_checkword=' . $f_checkword) > 0;
if ($i_isok) {
    activateUserByID($f_id, true);
    $i_isok = $i_isok && ($i_rSet1 = $g_db->SelectLimit("SELECT * FROM " . $srv_settings['table_prefix'] . "users WHERE id=" . $f_id, 1));
    if ($i_isok) {
        $i_isok = $i_isok && !$i_rSet1->EOF;
    }
    if ($i_isok) {
        sendEmailTemplate(array('etemplateid' => SYSTEM_ETEMPLATES_ACTIVATED_INDEX, 'emailto' => array($i_rSet1->fields['email']), 'id' => $f_id, 'username' => $i_rSet1->fields['username'], 'email' => $i_rSet1->fields['email'], 'title' => $i_rSet1->fields['user_title'], 'firstname' => $i_rSet1->fields['user_firstname'], 'lastname' => $i_rSet1->fields['user_lastname'], 'middlename' => $i_rSet1->fields['user_middlename'], 'address' => $i_rSet1->fields['user_address'], 'city' => $i_rSet1->fields['user_city'], 'state' => $i_rSet1->fields['user_state'], 'zip' => $i_rSet1->fields['user_zip'], 'country' => $i_rSet1->fields['user_country'], 'phone' => $i_rSet1->fields['user_phone'], 'fax' => $i_rSet1->fields['user_fax'], 'mobile' => $i_rSet1->fields['user_mobile'], 'pager' => $i_rSet1->fields['user_pager'], 'ipphone' => $i_rSet1->fields['user_ipphone'], 'webpage' => $i_rSet1->fields['user_webpage'], 'icq' => $i_rSet1->fields['user_icq'], 'msn' => $i_rSet1->fields['user_msn'], 'aol' => $i_rSet1->fields['user_aol'], 'gender' => $i_rSet1->fields['user_gender'], 'birthday' => $i_rSet1->fields['user_birthday'], 'husbandwife' => $i_rSet1->fields['user_husbandwife'], 'children' => $i_rSet1->fields['user_children'], 'trainer' => $i_rSet1->fields['user_trainer'], 'photo' => $i_rSet1->fields['user_photo'], 'company' => $i_rSet1->fields['user_company'], 'cposition' => $i_rSet1->fields['user_cposition'], 'department' => $i_rSet1->fields['user_department'], 'coffice' => $i_rSet1->fields['user_coffice'], 'caddress' => $i_rSet1->fields['user_caddress'], 'ccity' => $i_rSet1->fields['user_ccity'], 'cstate' => $i_rSet1->fields['user_cstate'], 'czip' => $i_rSet1->fields['user_czip'], 'ccountry' => $i_rSet1->fields['user_ccountry'], 'cphone' => $i_rSet1->fields['user_cphone'], 'cfax' => $i_rSet1->fields['user_cfax'], 'cmobile' => $i_rSet1->fields['user_cmobile'], 'cpager' => $i_rSet1->fields['user_cpager'], 'cipphone' => $i_rSet1->fields['user_cipphone'], 'cwebpage' => $i_rSet1->fields['user_cwebpage'], 'cphoto' => $i_rSet1->fields['user_cphoto'], 'ufield1' => $i_rSet1->fields['user_ufield1'], 'ufield2' => $i_rSet1->fields['user_ufield2'], 'ufield3' => $i_rSet1->fields['user_ufield3'], 'ufield4' => $i_rSet1->fields['user_ufield4'], 'ufield5' => $i_rSet1->fields['user_ufield5'], 'ufield6' => $i_rSet1->fields['user_ufield6'], 'ufield7' => $i_rSet1->fields['user_ufield7'], 'ufield8' => $i_rSet1->fields['user_ufield8'], 'ufield9' => $i_rSet1->fields['user_ufield9'], 'ufield10' => $i_rSet1->fields['user_ufield10'], 'checkword' => $f_checkword));
    }
    if ($i_rSet1) {
        $i_rSet1->Close();
    }
    $g_vars['page']['title'] = $lngstr['page_title_register'];
    $g_vars['page']['notifications'] = $lngstr['page-register']['account_activated'];
    include_once $DOCUMENT_PAGES . "signin-1.inc.php";
} else {
}
$i_order_no = isset($_GET['order']) ? (int) $_GET['order'] : 0;
if ($i_order_no >= count($i_tablefields)) {
    $i_order_no = -1;
}
if ($i_order_no >= 0) {
    $i_direction = isset($_GET['direction']) && $_GET['direction'] ? 'DESC' : '';
    $i_order_addon = '&order=' . $i_order_no . '&direction=' . $i_direction;
    $i_sql_order_addon = ' ORDER BY ' . $i_tablefields[$i_order_no][2] . ' ' . $i_direction;
}
$i_url_limitto_addon = '';
$i_url_pageno_addon = '';
$i_url_limit_addon = '';
$i_pageno = 0;
$i_limitcount = isset($_GET['limitto']) ? (int) $_GET['limitto'] : $G_SESSION['config_itemsperpage'];
if ($i_limitcount > 0) {
    $i_recordcount = getRecordCount($srv_settings['table_prefix'] . 'users', $i_sql_where_addon);
    $i_pageno = isset($_GET['pageno']) ? (int) $_GET['pageno'] : 1;
    if ($i_pageno < 1) {
        $i_pageno = 1;
    }
    $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    $i_pageno_count = floor(($i_recordcount - 1) / $i_limitcount) + 1;
    if ($i_limitfrom > $i_recordcount) {
        $i_pageno = $i_pageno_count;
        $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    }
    $i_url_limitto_addon .= '&limitto=' . $i_limitcount;
    $i_url_pageno_addon .= '&pageno=' . $i_pageno;
    $i_url_limit_addon .= $i_url_limitto_addon . $i_url_pageno_addon;
} else {
    $i_url_limitto_addon = '&limitto=';
if ($i_2_order_no >= count($i_2_tablefields)) {
    $i_2_order_no = -1;
}
if ($i_2_order_no >= 0) {
    $i_2_direction = isset($_GET['direction2']) && $_GET['direction2'] ? 'DESC' : '';
    $i_2_order_addon = '&order2=' . $i_2_order_no . '&direction2=' . $i_2_direction;
    $i_2_sql_order_addon = ' ORDER BY ' . $i_2_tablefields[$i_2_order_no][2] . ' ' . $i_2_direction;
}
$i_2_url_limitto_addon = '';
$i_2_url_pageno_addon = '';
$i_2_url_limit_addon = '';
$i_2_pageno = 0;
$i_2_limitcount = isset($_GET['limitto2']) ? (int) $_GET['limitto2'] : $G_SESSION['config_itemsperpage'];
if ($i_2_limitcount > 0) {
    $i_2_recordcount = 0;
    $i_2_recordcount = getRecordCount($srv_settings['table_prefix'] . 'questions', $i_2_sql_where_addon . '1=1');
    $i_2_pageno = isset($_GET['pageno2']) ? (int) $_GET['pageno2'] : 1;
    if ($i_2_pageno < 1) {
        $i_2_pageno = 1;
    }
    $i_2_limitfrom = ($i_2_pageno - 1) * $i_2_limitcount;
    $i_2_pageno_count = floor(($i_2_recordcount - 1) / $i_2_limitcount) + 1;
    if ($i_2_limitfrom > $i_2_recordcount) {
        $i_2_pageno = $i_2_pageno_count;
        $i_2_limitfrom = ($i_2_pageno - 1) * $i_2_limitcount;
    }
    $i_2_url_limitto_addon .= '&limitto2=' . $i_2_limitcount;
    $i_2_url_pageno_addon .= '&pageno2=' . $i_2_pageno;
    $i_2_url_limit_addon .= $i_2_url_limitto_addon . $i_2_url_pageno_addon;
} else {
    $i_2_url_limitto_addon = '&limitto2=';
<?php

$f_gscaleid = (int) readGetVar('gscaleid');
$f_gscale_gradeid = (int) readGetVar('gscale_gradeid');
$i_gradecount = getRecordCount($srv_settings['table_prefix'] . 'gscales_grades', "gscaleid=" . $f_gscaleid);
if ($f_gscale_gradeid < $i_gradecount) {
    $g_db->Execute("LOCK TABLES " . $srv_settings['table_prefix'] . "gscales_grades WRITE");
    $g_db->Execute("UPDATE " . $srv_settings['table_prefix'] . "gscales_grades SET gscale_gradeid=0 WHERE gscale_gradeid=" . ($f_gscale_gradeid + 1) . " AND gscaleid=" . $f_gscaleid);
    $g_db->Execute("UPDATE " . $srv_settings['table_prefix'] . "gscales_grades SET gscale_gradeid=gscale_gradeid+1 WHERE gscale_gradeid=" . $f_gscale_gradeid . " AND gscaleid=" . $f_gscaleid);
    $g_db->Execute("UPDATE " . $srv_settings['table_prefix'] . "gscales_grades SET gscale_gradeid=" . $f_gscale_gradeid . " WHERE gscale_gradeid=0 AND gscaleid=" . $f_gscaleid);
    $g_db->Execute("UNLOCK TABLES");
}
gotoLocation('grades.php' . getURLAddon('?action=edit', array('action')));
示例#17
0
function makeAllHtml($columnType, $columnName, $columnId)
{
    $action = '';
    $s = '';
    $i = '';
    $nPageSize = '';
    $nCountSize = '';
    $nPage = '';
    $addSql = '';
    $url = '';
    $articleSql = '';
    handlePower('生成全部HTML页面');
    //管理权限处理
    writeSystemLog('', '生成全部HTML页面');
    //系统日志
    $GLOBALS['isMakeHtml'] = true;
    //栏目
    aspEcho('栏目', '');
    if ($columnType != '') {
        $addSql = 'where columnType=\'' . $columnType . '\'';
    }
    if ($columnName != '') {
        $addSql = getWhereAnd($addSql, 'where columnName=\'' . $columnName . '\'');
    }
    if ($columnId != '') {
        $addSql = getWhereAnd($addSql, 'where id in(' . $columnId . ')');
    }
    $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'webcolumn ' . $addSql . ' order by sortrank asc');
    while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) {
        $GLOBALS['glb_columnName'] = '';
        //开启生成html
        if ($rss['isonhtml'] == true) {
            if (inStr('|产品|新闻|视频|下载|案例|留言|反馈|招聘|订单|', '|' . $rss['columntype'] . '|') > 0) {
                if ($rss['columntype'] == '留言') {
                    $nCountSize = getRecordCount($GLOBALS['db_PREFIX'] . 'guestbook', '');
                    //记录数
                } else {
                    $nCountSize = getRecordCount($GLOBALS['db_PREFIX'] . 'articledetail', ' where parentid=' . $rss['id']);
                    //记录数
                }
                $nPageSize = $rss['npagesize'];
                $nPage = getPageNumb(CInt($nCountSize), CInt($nPageSize));
                if ($nPage <= 0) {
                    $nPage = 1;
                }
                for ($i = 1; $i <= $nPage; $i++) {
                    $url = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/nav' . $rss['id']);
                    $GLOBALS['glb_filePath'] = replace($url, $GLOBALS['cfg_webSiteUrl'], '');
                    if (right($GLOBALS['glb_filePath'], 1) == '/' || $GLOBALS['glb_filePath'] == '') {
                        $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html';
                    }
                    //call echo("glb_filePath",glb_filePath)
                    $action = ' action actionType=\'nav\' columnName=\'' . $rss['columnname'] . '\' npage=\'' . $i . '\' listfilename=\'' . $GLOBALS['glb_filePath'] . '\' ';
                    //call echo("action",action)
                    makeWebHtml($action);
                    if ($i > 1) {
                        $GLOBALS['glb_filePath'] = mid($GLOBALS['glb_filePath'], 1, len($GLOBALS['glb_filePath']) - 5) . $i . '.html';
                    }
                    $s = '<a href="' . $GLOBALS['glb_filePath'] . '" target=\'_blank\'>' . $GLOBALS['glb_filePath'] . '</a>(' . $rss['isonhtml'] . ')';
                    aspEcho($action, $s);
                    if ($GLOBALS['glb_filePath'] != '') {
                        CreateDirFolder(getFileAttr($GLOBALS['glb_filePath'], '1'));
                        createFileGBK($GLOBALS['glb_filePath'], $GLOBALS['code']);
                    }
                    doEvents();
                    $GLOBALS['templateName'] = '';
                    //清空模板文件名称
                }
            } else {
                $action = ' action actionType=\'nav\' columnName=\'' . $rss['columnname'] . '\'';
                makeWebHtml($action);
                $GLOBALS['glb_filePath'] = replace(getColumnUrl($rss['columnname'], 'name'), $GLOBALS['cfg_webSiteUrl'], '');
                if (right($GLOBALS['glb_filePath'], 1) == '/' || $GLOBALS['glb_filePath'] == '') {
                    $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html';
                }
                $s = '<a href="' . $GLOBALS['glb_filePath'] . '" target=\'_blank\'>' . $GLOBALS['glb_filePath'] . '</a>(' . $rss['isonhtml'] . ')';
                aspEcho($action, $s);
                if ($GLOBALS['glb_filePath'] != '') {
                    CreateDirFolder(getFileAttr($GLOBALS['glb_filePath'], '1'));
                    createFileGBK($GLOBALS['glb_filePath'], $GLOBALS['code']);
                }
                doEvents();
                $GLOBALS['templateName'] = '';
            }
            connexecute('update ' . $GLOBALS['db_PREFIX'] . 'WebColumn set ishtml=true where id=' . $rss['id']);
            //更新导航为生成状态
        }
    }
    //单独处理指定栏目对应文章
    if ($columnId != '') {
        $articleSql = 'select * from ' . $GLOBALS['db_PREFIX'] . 'articledetail where parentid=' . $columnId . ' order by sortrank asc';
        //批量处理文章
    } else {
        if ($addSql == '') {
            $articleSql = 'select * from ' . $GLOBALS['db_PREFIX'] . 'articledetail order by sortrank asc';
        }
    }
    if ($articleSql != '') {
        //文章
        aspEcho('文章', '');
        $rssObj = $GLOBALS['conn']->query($articleSql);
        while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) {
            $GLOBALS['glb_columnName'] = '';
            $action = ' action actionType=\'detail\' columnName=\'' . $rss['parentid'] . '\' id=\'' . $rss['id'] . '\'';
            //call echo("action",action)
            makeWebHtml($action);
            $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'], '');
            if (right($GLOBALS['glb_filePath'], 1) == '/') {
                $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html';
            }
            $s = '<a href="' . $GLOBALS['glb_filePath'] . '" target=\'_blank\'>' . $GLOBALS['glb_filePath'] . '</a>(' . $rss['isonhtml'] . ')';
            aspEcho($action, $s);
            //文件不为空  并且开启生成html
            if ($GLOBALS['glb_filePath'] != '' && $rss['isonhtml'] == true) {
                CreateDirFolder(getFileAttr($GLOBALS['glb_filePath'], '1'));
                createFileGBK($GLOBALS['glb_filePath'], $GLOBALS['code']);
                connexecute('update ' . $GLOBALS['db_PREFIX'] . 'ArticleDetail set ishtml=true where id=' . $rss['id']);
                //更新文章为生成状态
            }
            $GLOBALS['templateName'] = '';
            //清空模板文件名称
        }
    }
    if ($addSql == '') {
        //单页
        aspEcho('单页', '');
        $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'onepage order by sortrank asc');
        while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) {
            $GLOBALS['glb_columnName'] = '';
            $action = ' action actionType=\'onepage\' id=\'' . $rss['id'] . '\'';
            //call echo("action",action)
            makeWebHtml($action);
            $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'], '');
            if (right($GLOBALS['glb_filePath'], 1) == '/') {
                $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html';
            }
            $s = '<a href="' . $GLOBALS['glb_filePath'] . '" target=\'_blank\'>' . $GLOBALS['glb_filePath'] . '</a>(' . $rss['isonhtml'] . ')';
            aspEcho($action, $s);
            //文件不为空  并且开启生成html
            if ($GLOBALS['glb_filePath'] != '' && $rss['isonhtml'] == true) {
                CreateDirFolder(getFileAttr($GLOBALS['glb_filePath'], '1'));
                createFileGBK($GLOBALS['glb_filePath'], $GLOBALS['code']);
                connexecute('update ' . $GLOBALS['db_PREFIX'] . 'onepage set ishtml=true where id=' . $rss['id']);
                //更新单页为生成状态
            }
            $GLOBALS['templateName'] = '';
            //清空模板文件名称
        }
    }
}
示例#18
0
<?php

require_once "inc/init.inc.php";
if (isset($G_SESSION['id'])) {
    $i_can_access = false;
    if (isset($_GET['resultid'])) {
        $f_resultid = (int) readGetVar('resultid');
        if ($G_SESSION['access_reportsmanager'] > 1) {
            $i_can_access = true;
        } else {
            $i_can_access = getRecordCount($srv_settings['table_prefix'] . 'results', 'id=' . $G_SESSION['id'] . ' AND resultid=' . $f_resultid) > 0;
        }
    }
    switch (readGetVar('action')) {
        case 'tpdf':
            if ($i_can_access) {
                if (isset($_GET['resultid'])) {
                    include_once $DOCUMENT_PAGES . "getfile-1.inc.php";
                }
            }
            break;
        case 'thtml':
            if ($i_can_access) {
                if (isset($_GET['resultid'])) {
                    include_once $DOCUMENT_PAGES . "getfile-template-html.inc.php";
                }
            }
            break;
        case 'cpdf':
            include_once $DOCUMENT_PAGES . "getfile-custompdf.inc.php";
            break;
示例#19
0
function isOpenTemplate()
{
    $templatePath = '';
    $templateName = '';
    $editValueStr = '';
    $url = '';
    handlePower('启用模板');
    //管理权限处理
    $templatePath = @$_REQUEST['templatepath'];
    $templateName = @$_REQUEST['templatename'];
    if (getRecordCount($GLOBALS['db_PREFIX'] . 'website', '') == 0) {
        connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'website(webtitle) values(\'测试\')');
    }
    $editValueStr = 'webtemplate=\'' . $templatePath . '\',webimages=\'' . $templatePath . 'Images/\'';
    $editValueStr = $editValueStr . ',webcss=\'' . $templatePath . 'css/\',webjs=\'' . $templatePath . 'Js/\'';
    connexecute('update ' . $GLOBALS['db_PREFIX'] . 'website set ' . $editValueStr);
    $url = '?act=displayLayout&templateFile=layout_manageTemplates.html&lableTitle=模板';
    Rw(getMsg1('启用模板成功,正在进入模板界面...', $url));
    writeSystemLog('', '应用模板' . $templatePath);
    //系统日志
}
示例#20
0
function resetAccessData_temp()
{
    handlePower('恢复模板数据');
    //管理权限处理
    $GLOBALS['conn='] = OpenConn();
    $splStr = '';
    $i = '';
    $s = '';
    $columnname = '';
    $title = '';
    $nCount = '';
    $webdataDir = '';
    $webdataDir = @$_REQUEST['webdataDir'];
    if ($webdataDir != '') {
        if (checkFolder($webdataDir) == false) {
            eerr('网站数据目录不存在,恢复默认数据未成功', $webdataDir);
        }
    } else {
        $webdataDir = '/Data/WebData/';
    }
    aspEcho('提示', '恢复数据完成');
    rw('<hr><a href=\'../index.php\' target=\'_blank\'>进入首页</a> | <a href="?" target=\'_blank\'>进入后台</a>');
    $content = '';
    $filePath = '';
    $parentid = '';
    $author = '';
    $adddatetime = '';
    $fileName = '';
    $bodycontent = '';
    $webtitle = '';
    $webkeywords = '';
    $webdescription = '';
    $sortrank = '';
    $labletitle = '';
    $target = '';
    $websitebottom = '';
    $webTemplate = '';
    $webimages = '';
    $webcss = '';
    $webjs = '';
    $flags = '';
    $websiteurl = '';
    $splxx = '';
    $columntype = '';
    $relatedtags = '';
    $npagesize = '';
    $customaurl = '';
    $nofollow = '';
    $templatepath = '';
    $isthrough = '';
    $titlecolor = '';
    $showreason = '';
    $ncomputersearch = '';
    $nmobliesearch = '';
    $ncountsearch = '';
    $ndegree = '';
    //竞价表
    $displaytitle = '';
    $aboutcontent = '';
    $isonhtml = '';
    //单页表
    $columnenname = '';
    //导航表
    $smallimage = '';
    $bigImage = '';
    $bannerimage = '';
    //文章表
    $httpurl = '';
    $price = '';
    $morepageurl = '';
    $charset = '';
    $thispage = '';
    $countpage = '';
    $bigClassName = '';
    $startStr = '';
    $endStr = '';
    $startaddstr = '';
    $endaddstr = '';
    $sType = '';
    $saction = '';
    $fieldName = '';
    $fieldcheck = '';
    //网站配置
    $content = GetFText($webdataDir . '/website.txt');
    //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
    if (inStr($content, vbCrlf()) == false) {
        $content = replace($content, chr(10), vbCrlf());
    }
    if ($content != '') {
        $webtitle = newGetStrCut($content, 'webtitle');
        $webkeywords = newGetStrCut($content, 'webkeywords');
        $webdescription = newGetStrCut($content, 'webdescription');
        $websitebottom = newGetStrCut($content, 'websitebottom');
        $webTemplate = newGetStrCut($content, 'webtemplate');
        $webimages = newGetStrCut($content, 'webimages');
        $webcss = newGetStrCut($content, 'webcss');
        $webjs = newGetStrCut($content, 'webjs');
        $flags = newGetStrCut($content, 'flags');
        $websiteurl = newGetStrCut($content, 'websiteurl');
        if (getRecordCount($GLOBALS['db_PREFIX'] . 'website', '') == 0) {
            connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'website(webtitle) values(\'测试\')');
        }
        connexecute('update ' . $GLOBALS['db_PREFIX'] . 'website  set webtitle=\'' . $webtitle . '\',webkeywords=\'' . $webkeywords . '\',webdescription=\'' . $webdescription . '\',websitebottom=\'' . $websitebottom . '\',webtemplate=\'' . $webTemplate . '\',webimages=\'' . $webimages . '\',webcss=\'' . $webcss . '\',webjs=\'' . $webjs . '\',flags=\'' . $flags . '\',websiteurl=\'' . $websiteurl . '\'');
    }
    //导航
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'webcolumn');
    $content = getDirTxtList($webdataDir . '/webcolumn/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('导航', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【webtitle】') > 0) {
                    $s = $s . vbCrlf();
                    $webtitle = newGetStrCut($s, 'webtitle');
                    $webkeywords = newGetStrCut($s, 'webkeywords');
                    $webdescription = newGetStrCut($s, 'webdescription');
                    $customaurl = newGetStrCut($s, 'customaurl');
                    $sortrank = newGetStrCut($s, 'sortrank');
                    if ($sortrank == '') {
                        $sortrank = 0;
                    }
                    $fileName = newGetStrCut($s, 'filename');
                    $columnname = newGetStrCut($s, 'columnname');
                    $columnenname = newGetStrCut($s, 'columnenname');
                    $columntype = newGetStrCut($s, 'columntype');
                    $flags = newGetStrCut($s, 'flags');
                    $parentid = newGetStrCut($s, 'parentid');
                    $parentid = phpTrim(getColumnId($parentid));
                    //可根据栏目名称找到对应ID   不存在为-1
                    //call echo("parentid",parentid)
                    $labletitle = newGetStrCut($s, 'labletitle');
                    //每页显示条数
                    $npagesize = newGetStrCut($s, 'npagesize');
                    if ($npagesize == '') {
                        $npagesize = 10;
                    }
                    //默认分页数为10条
                    $target = newGetStrCut($s, 'target');
                    $smallimage = newGetStrCut($s, 'smallimage');
                    $bigImage = newGetStrCut($s, 'bigImage');
                    $bannerimage = newGetStrCut($s, 'bannerimage');
                    $templatepath = newGetStrCut($s, 'templatepath');
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $bodycontent = contentTranscoding($bodycontent);
                    //是否启用生成html
                    $isonhtml = newGetStrCut($s, 'isonhtml');
                    if ($isonhtml == '0' || lCase($isonhtml) == 'false') {
                        $isonhtml = 0;
                    } else {
                        $isonhtml = 1;
                    }
                    //是否为nofollow
                    $nofollow = newGetStrCut($s, 'nofollow');
                    if ($nofollow == '1' || lCase($nofollow) == 'true') {
                        $nofollow = 1;
                    } else {
                        $nofollow = 0;
                    }
                    //call echo(columnname,nofollow)
                    $aboutcontent = newGetStrCut($s, 'aboutcontent');
                    $aboutcontent = contentTranscoding($aboutcontent);
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $bodycontent = contentTranscoding($bodycontent);
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'webcolumn (webtitle,webkeywords,webdescription,columnname,columnenname,columntype,sortrank,filename,customaurl,flags,parentid,labletitle,aboutcontent,bodycontent,npagesize,isonhtml,nofollow,target,smallimage,bigImage,bannerimage,templatepath) values(\'' . $webtitle . '\',\'' . $webkeywords . '\',\'' . $webdescription . '\',\'' . $columnname . '\',\'' . $columnenname . '\',\'' . $columntype . '\',' . $sortrank . ',\'' . $fileName . '\',\'' . $customaurl . '\',\'' . $flags . '\',' . $parentid . ',\'' . $labletitle . '\',\'' . $aboutcontent . '\',\'' . $bodycontent . '\',' . $npagesize . ',' . $isonhtml . ',' . $nofollow . ',\'' . $target . '\',\'' . $smallimage . '\',\'' . $bigImage . '\',\'' . $bannerimage . '\',\'' . $templatepath . '\')');
                }
            }
        }
    }
    //文章
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'articledetail');
    $content = getDirAllFileList($webdataDir . '/articledetail/', 'txt');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('文章', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【title】') > 0) {
                    $s = $s . vbCrlf();
                    $parentid = newGetStrCut($s, 'parentid');
                    $parentid = getColumnId($parentid);
                    $title = newGetStrCut($s, 'title');
                    $titlecolor = newGetStrCut($s, 'titlecolor');
                    $webtitle = newGetStrCut($s, 'webtitle');
                    $webkeywords = newGetStrCut($s, 'webkeywords');
                    $webdescription = newGetStrCut($s, 'webdescription');
                    $author = newGetStrCut($s, 'author');
                    $sortrank = newGetStrCut($s, 'sortrank');
                    if ($sortrank == '') {
                        $sortrank = 0;
                    }
                    $adddatetime = newGetStrCut($s, 'adddatetime');
                    $fileName = newGetStrCut($s, 'filename');
                    $templatepath = newGetStrCut($s, 'templatepath');
                    $flags = newGetStrCut($s, 'flags');
                    $relatedtags = newGetStrCut($s, 'relatedtags');
                    $customaurl = newGetStrCut($s, 'customaurl');
                    $target = newGetStrCut($s, 'target');
                    $smallimage = newGetStrCut($s, 'smallimage');
                    $bigImage = newGetStrCut($s, 'bigImage');
                    $bannerimage = newGetStrCut($s, 'bannerimage');
                    $labletitle = newGetStrCut($s, 'labletitle');
                    $aboutcontent = newGetStrCut($s, 'aboutcontent');
                    $aboutcontent = contentTranscoding($aboutcontent);
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $bodycontent = contentTranscoding($bodycontent);
                    //是否启用生成html
                    $isonhtml = newGetStrCut($s, 'isonhtml');
                    if ($isonhtml == '0' || lCase($isonhtml) == 'false') {
                        $isonhtml = 0;
                    } else {
                        $isonhtml = 1;
                    }
                    //是否为nofollow
                    $nofollow = newGetStrCut($s, 'nofollow');
                    if ($nofollow == '1' || lCase($nofollow) == 'true') {
                        $nofollow = 1;
                    } else {
                        $nofollow = 0;
                    }
                    //价格
                    $price = getDianNumb(newGetStrCut($s, 'price'));
                    if ($price == '') {
                        $price = 0;
                    }
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'articledetail (parentid,title,titlecolor,webtitle,webkeywords,webdescription,author,sortrank,adddatetime,filename,flags,relatedtags,aboutcontent,bodycontent,updatetime,isonhtml,customaurl,nofollow,target,smallimage,bigImage,bannerimage,templatepath,labletitle,price) values(' . $parentid . ',\'' . $title . '\',\'' . $titlecolor . '\',\'' . $webtitle . '\',\'' . $webkeywords . '\',\'' . $webdescription . '\',\'' . $author . '\',' . $sortrank . ',\'' . $adddatetime . '\',\'' . $fileName . '\',\'' . $flags . '\',\'' . $relatedtags . '\',\'' . $aboutcontent . '\',\'' . $bodycontent . '\',\'' . now() . '\',' . $isonhtml . ',\'' . $customaurl . '\',' . $nofollow . ',\'' . $target . '\',\'' . $smallimage . '\',\'' . $bigImage . '\',\'' . $bannerimage . '\',\'' . $templatepath . '\',\'' . $labletitle . '\',' . $price . ')');
                }
            }
        }
    }
    //单页
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'OnePage');
    $content = getDirTxtList($webdataDir . '/OnePage/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('单页', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【webkeywords】') > 0) {
                    $s = $s . vbCrlf();
                    $title = newGetStrCut($s, 'title');
                    $displaytitle = newGetStrCut($s, 'displaytitle');
                    $webtitle = newGetStrCut($s, 'webtitle');
                    $webkeywords = newGetStrCut($s, 'webkeywords');
                    $webdescription = newGetStrCut($s, 'webdescription');
                    $adddatetime = newGetStrCut($s, 'adddatetime');
                    $fileName = newGetStrCut($s, 'filename');
                    $aboutcontent = newGetStrCut($s, 'aboutcontent');
                    $aboutcontent = contentTranscoding($aboutcontent);
                    $target = newGetStrCut($s, 'target');
                    $templatepath = newGetStrCut($s, 'templatepath');
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $bodycontent = contentTranscoding($bodycontent);
                    //是否启用生成html
                    $isonhtml = newGetStrCut($s, 'isonhtml');
                    if ($isonhtml == '0' || lCase($isonhtml) == 'false') {
                        $isonhtml = 0;
                    } else {
                        $isonhtml = 1;
                    }
                    //是否为nofollow
                    $nofollow = newGetStrCut($s, 'nofollow');
                    if ($nofollow == '1' || lCase($nofollow) == 'true') {
                        $nofollow = 1;
                    } else {
                        $nofollow = 0;
                    }
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'onepage (title,displaytitle,webtitle,webkeywords,webdescription,adddatetime,filename,isonhtml,aboutcontent,bodycontent,nofollow,target,templatepath) values(\'' . $title . '\',\'' . $displaytitle . '\',\'' . $webtitle . '\',\'' . $webkeywords . '\',\'' . $webdescription . '\',\'' . $adddatetime . '\',\'' . $fileName . '\',' . $isonhtml . ',\'' . $aboutcontent . '\',\'' . $bodycontent . '\',' . $nofollow . ',\'' . $target . '\',\'' . $templatepath . '\')');
                }
            }
        }
    }
    //竞价
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'Bidding');
    $content = getDirTxtList($webdataDir . '/Bidding/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('竞价', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【webkeywords】') > 0) {
                    $s = $s . vbCrlf();
                    $webkeywords = newGetStrCut($s, 'webkeywords');
                    $showreason = newGetStrCut($s, 'showreason');
                    $ncomputersearch = newGetStrCut($s, 'ncomputersearch');
                    $nmobliesearch = newGetStrCut($s, 'nmobliesearch');
                    $ncountsearch = newGetStrCut($s, 'ncountsearch');
                    $ndegree = newGetStrCut($s, 'ndegree');
                    $ndegree = getNumber($ndegree);
                    if ($ndegree == '') {
                        $ndegree = 0;
                    }
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'Bidding (webkeywords,showreason,ncomputersearch,nmobliesearch,ndegree) values(\'' . $webkeywords . '\',\'' . $showreason . '\',' . $ncomputersearch . ',' . $nmobliesearch . ',' . $ndegree . ')');
                }
            }
        }
    }
    //搜索统计
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'SearchStat');
    $content = getDirTxtList($webdataDir . '/SearchStat/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('搜索统计', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【title】') > 0) {
                    $s = $s . vbCrlf();
                    $title = newGetStrCut($s, 'title');
                    $webtitle = newGetStrCut($s, 'webtitle');
                    $webkeywords = newGetStrCut($s, 'webkeywords');
                    $webdescription = newGetStrCut($s, 'webdescription');
                    $customaurl = newGetStrCut($s, 'customaurl');
                    $target = newGetStrCut($s, 'target');
                    $isthrough = newGetStrCut($s, 'isthrough');
                    if ($isthrough == '0' || lCase($isthrough) == 'false') {
                        $isthrough = 0;
                    } else {
                        $isthrough = 1;
                    }
                    $sortrank = newGetStrCut($s, 'sortrank');
                    if ($sortrank == '') {
                        $sortrank = 0;
                    }
                    //是否启用生成html
                    $isonhtml = newGetStrCut($s, 'isonhtml');
                    if ($isonhtml == '0' || lCase($isonhtml) == 'false') {
                        $isonhtml = 0;
                    } else {
                        $isonhtml = 1;
                    }
                    //是否为nofollow
                    $nofollow = newGetStrCut($s, 'nofollow');
                    if ($nofollow == '1' || lCase($nofollow) == 'true') {
                        $nofollow = 1;
                    } else {
                        $nofollow = 0;
                    }
                    //call echo("title",title)
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'SearchStat (title,webtitle,webkeywords,webdescription,customaurl,target,isthrough,sortrank,isonhtml,nofollow) values(\'' . $title . '\',\'' . $webtitle . '\',\'' . $webkeywords . '\',\'' . $webdescription . '\',\'' . $customaurl . '\',\'' . $target . '\',' . $isthrough . ',' . $sortrank . ',' . $isonhtml . ',' . $nofollow . ')');
                }
            }
        }
    }
    $itemid = '';
    $userName = '';
    $ip = '';
    $reply = '';
    $tableName = '';
    //评论
    //评论
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'TableComment');
    $content = getDirTxtList($webdataDir . '/TableComment/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('评论', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【title】') > 0) {
                    $s = $s . vbCrlf();
                    $tableName = newGetStrCut($s, 'tablename');
                    $title = newGetStrCut($s, 'title');
                    $itemid = getArticleId(newGetStrCut($s, 'itemid'));
                    if ($itemid == '') {
                        $itemid = 0;
                    }
                    //call echo("itemID",itemID)
                    $adddatetime = newGetStrCut($s, 'adddatetime');
                    $userName = newGetStrCut($s, 'username');
                    $ip = newGetStrCut($s, 'ip');
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $reply = newGetStrCut($s, 'reply');
                    $isthrough = newGetStrCut($s, 'isthrough');
                    if ($isthrough == '0' || lCase($isthrough) == 'false') {
                        $isthrough = 0;
                    } else {
                        $isthrough = 1;
                    }
                    //call echo("title",title)
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'TableComment (tablename,title,itemid,adddatetime,username,ip,bodycontent,reply,isthrough) values(\'' . $tableName . '\',\'' . $title . '\',' . $itemid . ',\'' . $adddatetime . '\',\'' . $userName . '\',\'' . $ip . '\',\'' . $bodycontent . '\',\'' . $reply . '\',' . $isthrough . ')');
                }
            }
        }
    }
    //友情链接
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'FriendLink');
    $content = getDirTxtList($webdataDir . '/FriendLink/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('评论', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【title】') > 0) {
                    $s = $s . vbCrlf();
                    $title = newGetStrCut($s, 'title');
                    $httpurl = newGetStrCut($s, 'httpurl');
                    $smallimage = newGetStrCut($s, 'smallimage');
                    $flags = newGetStrCut($s, 'flags');
                    $target = newGetStrCut($s, 'target');
                    $sortrank = newGetStrCut($s, 'sortrank');
                    if ($sortrank == '0' || lCase($sortrank) == 'false') {
                        $sortrank = 0;
                    } else {
                        $sortrank = 1;
                    }
                    $isthrough = newGetStrCut($s, 'isthrough');
                    if ($isthrough == '0' || lCase($isthrough) == 'false') {
                        $isthrough = 0;
                    } else {
                        $isthrough = 1;
                    }
                    //call echo("title",title)
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'FriendLink (title,httpurl,smallimage,flags,sortrank,isthrough,target) values(\'' . $title . '\',\'' . $httpurl . '\',\'' . $smallimage . '\',\'' . $flags . '\',' . $sortrank . ',' . $isthrough . ',\'' . $target . '\')');
                }
            }
        }
    }
    //留言
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'GuestBook');
    $content = getDirTxtList($webdataDir . '/GuestBook/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('留言', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【adddatetime】') > 0) {
                    $s = $s . vbCrlf();
                    $adddatetime = newGetStrCut($s, 'adddatetime');
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $reply = newGetStrCut($s, 'reply');
                    $isthrough = newGetStrCut($s, 'isthrough');
                    if ($isthrough == '0' || lCase($isthrough) == 'false') {
                        $isthrough = 0;
                    } else {
                        $isthrough = 1;
                    }
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'GuestBook (adddatetime,bodycontent,reply,isthrough) values(\'' . $adddatetime . '\',\'' . $bodycontent . '\',\'' . $reply . '\',' . $isthrough . ')');
                }
            }
        }
    }
    //采集网站
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'CaiWeb');
    $content = getDirTxtList($webdataDir . '/CaiWeb/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('采集网站', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【bigclassname】') > 0) {
                    $s = $s . vbCrlf();
                    $bigClassName = newGetStrCut($s, 'bigclassname');
                    $httpurl = newGetStrCut($s, 'httpurl');
                    $morepageurl = newGetStrCut($s, 'morepageurl');
                    $charset = newGetStrCut($s, 'charset');
                    $adddatetime = newGetStrCut($s, 'adddatetime');
                    $bodycontent = newGetStrCut($s, 'bodycontent');
                    $sortrank = newGetStrCut($s, 'sortrank');
                    if ($sortrank == '') {
                        $sortrank = 0;
                    }
                    $thispage = newGetStrCut($s, 'thispage');
                    if ($thispage == '') {
                        $thispage = 0;
                    }
                    $countpage = newGetStrCut($s, 'countpage');
                    if ($countpage == '') {
                        $thispage = 0;
                    }
                    $columnname = newGetStrCut($s, 'columnname');
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'CaiWeb (adddatetime,bodycontent,httpurl,morepageurl,charset,sortrank,thispage,countpage,bigclassname,columnname) values(\'' . $adddatetime . '\',\'' . $bodycontent . '\',\'' . $httpurl . '\',\'' . $morepageurl . '\',\'' . $charset . '\',' . $sortrank . ',' . $thispage . ',' . $countpage . ',\'' . $bigClassName . '\',\'' . $columnname . '\')');
                }
            }
        }
    }
    //采集配置
    connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'CaiConfig');
    $content = getDirTxtList($webdataDir . '/CaiConfig/');
    $content = contentNameSort($content, '');
    $splStr = aspSplit($content, vbCrlf());
    HR();
    foreach ($splStr as $key => $filePath) {
        $fileName = getFileName($filePath);
        if ($filePath != '' && inStr('_#', left($fileName, 1)) == false) {
            aspEcho('采集配置', $filePath);
            $content = GetFText($filePath);
            //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
            if (inStr($content, vbCrlf()) == false) {
                $content = replace($content, chr(10), vbCrlf());
            }
            $splxx = aspSplit($content, vbCrlf() . '-------------------------------');
            foreach ($splxx as $key => $s) {
                if (inStr($s, '【bigclassname】') > 0) {
                    $s = $s . vbCrlf();
                    $bigClassName = newGetStrCut($s, 'bigclassname');
                    $sType = newGetStrCut($s, 'stype');
                    $startStr = newGetStrCut($s, 'startstr');
                    $endStr = newGetStrCut($s, 'endstr');
                    $startaddstr = newGetStrCut($s, 'startaddstr');
                    $endaddstr = newGetStrCut($s, 'endaddstr');
                    $adddatetime = newGetStrCut($s, 'adddatetime');
                    $sortrank = newGetStrCut($s, 'sortrank');
                    if ($sortrank == '') {
                        $sortrank = 0;
                    }
                    $saction = newGetStrCut($s, 'saction');
                    $isthrough = newGetStrCut($s, 'isthrough');
                    $isthrough = IIF($isthrough == '0' || lCase($isthrough) == 'false', 0, 1);
                    $fieldName = newGetStrCut($s, 'fieldname');
                    $fieldcheck = newGetStrCut($s, 'fieldcheck');
                    if ($fieldcheck == '') {
                        $fieldcheck = 0;
                    }
                    connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'CaiConfig (adddatetime,sortrank,bigclassname,stype,startstr,endstr,startaddstr,endaddstr,saction,isthrough,fieldname,fieldcheck) values(\'' . $adddatetime . '\',' . $sortrank . ',\'' . $bigClassName . '\',\'' . $sType . '\',\'' . $startStr . '\',\'' . $endStr . '\',\'' . $startaddstr . '\',\'' . $endaddstr . '\',\'' . $saction . '\',' . $isthrough . ',\'' . $fieldName . '\',' . $fieldcheck . ')');
                }
            }
        }
    }
    writeSystemLog('', '恢复默认数据' . $GLOBALS['db_PREFIX']);
    //系统日志
}
示例#21
0
							<div class="list-group text-success">
								<div class="list-group-item">[UID]代表指定某个用户能解析此域名,[UID:0]代表所有有均可以解析此域名!</div>
								<div class="list-group-item"><form method="post" class="form-inline"><input type="hidden" name="action" value="zd"><div class="form-group"><label>&nbsp;指定域名&nbsp;&nbsp;&nbsp;</label><select name="domain_id" class="form-control">
								<?php 
foreach ($domainList as $value) {
    echo '<option value="' . $value['domain_id'] . '">' . $value['name'] . '</option>';
}
?>
								</select></div><div class="form-group"><label>&nbsp;&nbsp;&nbsp;所属权归&nbsp;&nbsp;&nbsp;</label><input type="number" name="uid" size=4 class="form-control" placeholder="输入用户UID">&nbsp;&nbsp;&nbsp;使用!</div><button type="submit" class="btn btn-success">确定</button></form></div>
								<?php 
$img['dnspod'] = '<img src="/assets/images/dnspod.jpg" width=50 height=18>&nbsp;&nbsp;';
$img['aliyun'] = '<img src="/assets/images/aliyun.jpg" width=50 height=18>&nbsp;&nbsp;';
$img['cloudxns'] = '<img src="/assets/images/cloudxns.jpg" width=50 height=18>&nbsp;&nbsp;';
if (!empty($domainList)) {
    foreach ($domainList as $value) {
        echo '<a href="recordList.php?domain_id=' . $value['domain_id'] . '" class="list-group-item">' . $img[$value['dns']] . $value['name'] . '-[UID:' . $value['allow_uid'] . '] <span class="badge">' . getRecordCount($value['domain_id']) . '</span></a>';
    }
}
?>
								
							</div>

						</div>
						<div class="panel-body">
							<div class="list-group text-center">
								<a href="addDomain.php" class="list-group-item">添加域名</a>
							</div>

						</div>
					</div>
				</div>
        echo '<td width=32><img src="images/button-last-big-inactive.gif" border=0 title="' . $lngstr['button_last_page'] . '"></td>';
    }
}
echo '<td width=2><img src="images/toolbar-right.gif" width=2 height=32></td></tr></table>';
echo '</td></tr><tr><td>';
echo '<table class=rowtable2 cellpadding=5 cellspacing=1 border=0 width="100%">';
echo '<tr vAlign=top><td class=rowhdr1 title="' . $lngstr['label_hdr_select_hint'] . '" width=22><input type=checkbox name=toggleAll onclick="toggleCBs(this);"></td>';
writeQryTableHeaders('users.php?action=groups' . $i_ids_addon . $i_order_addon . $i_2_url_limit_addon, $i_2_tablefields, $i_2_order_no, $i_2_direction, '2');
echo '<td class=rowhdr1 title="' . $lngstr['label_managegroups_hdr_member_of_hint'] . '" vAlign=top>' . $lngstr['label_managegroups_hdr_member_of'] . '</td>';
echo '<td class=rowhdr1 colspan=2>' . $lngstr['label_hdr_action'] . '</td></tr>';
//9917
$i_rSet2 = $g_db->SelectLimit("SELECT * FROM " . $srv_settings['table_prefix'] . "groups" . $i_2_sql_order_addon, $i_2_limitcount, $i_2_limitfrom);
if (!$i_rSet2) {
    showDBError(__FILE__, 2);
} else {
    $i_counter = 0;
    while (!$i_rSet2->EOF) {
        //9917//9917
        $i_member_count = getRecordCount($srv_settings['table_prefix'] . 'groups_users', ($f_ids ? "id IN (" . implode(',', $f_ids) . ") AND " : "") . "groupid=" . $i_rSet2->fields["groupid"]);
        $rowname = $i_counter % 2 ? "rowone" : "rowtwo";
        echo '<tr id=tr_' . $i_pagewide_id . ' class=' . $rowname . ' onmouseover="rollTR(' . $i_pagewide_id . ',1);" onmouseout="rollTR(' . $i_pagewide_id . ',0);"><td align=center width=22' . ($i_rSet2->fields["groupid"] > SYSTEM_GROUP_MAX_INDEX ? '' : ' class=system') . '><input id=cb_' . $i_pagewide_id . ' type=checkbox name=box_groups[] value="' . $i_rSet2->fields["groupid"] . '" onclick="toggleCB(this);"></td><td align=right>' . $i_rSet2->fields["groupid"] . '</td><td>' . getTruncatedHTML($i_rSet2->fields["group_name"]) . '</td><td>' . $i_rSet2->fields["group_description"] . '</td><td align=center><a href="users.php?action=memberof&groupid=' . $i_rSet2->fields["groupid"] . $i_order_addon . $i_ids_addon . $i_2_order_addon . $i_2_url_limit_addon . '&set=' . ($i_member_count >= sizeof($f_ids) ? '0"><img src="images/button-checkbox-2.gif" width=13 height=13 border=0 title="' . $lngstr['label_yes'] . '">' : ($i_member_count > 0 ? '1"><img src="images/button-checkbox-1.gif" width=13 height=13 border=0 title="' . $lngstr['label_partially'] . '">' : '1"><img src="images/button-checkbox-0.gif" width=13 height=13 border=0 title="' . $lngstr['label_no'] . '">')) . '</a></td>';
        echo '<td align=center width=22><a href="groups.php?groupid=' . $i_rSet2->fields["groupid"] . '&action=edit"><img width=20 height=20 border=0 src="images/button-edit.gif" title="' . $lngstr['label_action_group_edit'] . '"></a></td><td align=center width=22>' . ($i_rSet2->fields["groupid"] > SYSTEM_GROUP_MAX_INDEX ? '<a href="groups.php?groupid=' . $i_rSet2->fields["groupid"] . '&action=delete" onclick="return confirmMessage(this, \'' . $lngstr['qst_delete_group'] . '\')"><img width=20 height=20 border=0 src="images/button-cross.gif" title="' . $lngstr['label_action_group_delete'] . '"></a>' : '<img width=20 height=20 border=0 src="images/button-cross-inactive.gif">') . '</td></tr>';
        $i_counter++;
        $i_pagewide_id++;
        $i_rSet2->MoveNext();
    }
    $i_rSet2->Close();
}
echo '</table>';
echo '</td></tr></table></form>';
displayTemplate('_footer');
$i_order_no = isset($_GET["order"]) ? (int) $_GET["order"] : 0;
if ($i_order_no >= count($i_tablefields)) {
    $i_order_no = -1;
}
if ($i_order_no >= 0) {
    $i_direction = isset($_GET["direction"]) && $_GET["direction"] ? "DESC" : "";
    $i_order_addon = "&order=" . $i_order_no . "&direction=" . $i_direction;
    $i_sql_order_addon = " ORDER BY " . $i_tablefields[$i_order_no][2] . " " . $i_direction;
}
$i_url_limitto_addon = "";
$i_url_pageno_addon = "";
$i_url_limit_addon = "";
$i_pageno = 0;
$i_limitcount = isset($_GET["limitto"]) ? (int) $_GET["limitto"] : $G_SESSION['config_itemsperpage'];
if ($i_limitcount > 0) {
    $i_recordcount = getRecordCount($srv_settings['table_prefix'] . 'rtemplates');
    $i_pageno = isset($_GET["pageno"]) ? (int) $_GET["pageno"] : 1;
    if ($i_pageno < 1) {
        $i_pageno = 1;
    }
    $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    $i_pageno_count = floor(($i_recordcount - 1) / $i_limitcount) + 1;
    if ($i_limitfrom > $i_recordcount) {
        $i_pageno = $i_pageno_count;
        $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    }
    $i_url_limitto_addon .= "&limitto=" . $i_limitcount;
    $i_url_pageno_addon .= "&pageno=" . $i_pageno;
    $i_url_limit_addon .= $i_url_limitto_addon . $i_url_pageno_addon;
} else {
    $i_url_limitto_addon = "&limitto=";
$i_order_no = isset($_GET["order"]) ? (int) $_GET["order"] : 0;
if ($i_order_no >= count($i_tablefields)) {
    $i_order_no = -1;
}
if ($i_order_no >= 0) {
    $i_direction = isset($_GET["direction"]) && $_GET["direction"] ? "DESC" : "";
    $i_order_addon = "&order=" . $i_order_no . "&direction=" . $i_direction;
    $i_sql_order_addon = " ORDER BY " . $i_tablefields[$i_order_no][2] . " " . $i_direction;
}
$i_url_limitto_addon = "";
$i_url_pageno_addon = "";
$i_url_limit_addon = "";
$i_pageno = 0;
$i_limitcount = isset($_GET["limitto"]) ? (int) $_GET["limitto"] : $G_SESSION['config_itemsperpage'];
if ($i_limitcount > 0) {
    $i_recordcount = getRecordCount($srv_settings['table_prefix'] . 'visitors');
    $i_pageno = isset($_GET["pageno"]) ? (int) $_GET["pageno"] : 1;
    if ($i_pageno < 1) {
        $i_pageno = 1;
    }
    $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    $i_pageno_count = floor(($i_recordcount - 1) / $i_limitcount) + 1;
    if ($i_limitfrom > $i_recordcount) {
        $i_pageno = $i_pageno_count;
        $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    }
    $i_url_limitto_addon .= "&limitto=" . $i_limitcount;
    $i_url_pageno_addon .= "&pageno=" . $i_pageno;
    $i_url_limit_addon .= $i_url_limitto_addon . $i_url_pageno_addon;
} else {
    $i_url_limitto_addon = "&limitto=";
$i_order_no = isset($_GET["order"]) ? (int) $_GET["order"] : 0;
if ($i_order_no >= count($i_tablefields)) {
    $i_order_no = -1;
}
if ($i_order_no >= 0) {
    $i_direction = isset($_GET["direction"]) && $_GET["direction"] ? "DESC" : "";
    $i_order_addon = "&order=" . $i_order_no . "&direction=" . $i_direction;
    $i_sql_order_addon = " ORDER BY " . $i_tablefields[$i_order_no][2] . " " . $i_direction;
}
$i_url_limitto_addon = "";
$i_url_pageno_addon = "";
$i_url_limit_addon = "";
$i_pageno = 0;
$i_limitcount = isset($_GET["limitto"]) ? (int) $_GET["limitto"] : $G_SESSION['config_itemsperpage'];
if ($i_limitcount > 0) {
    $i_recordcount = getRecordCount($srv_settings['table_prefix'] . 'subjects');
    $i_pageno = isset($_GET["pageno"]) ? (int) $_GET["pageno"] : 1;
    if ($i_pageno < 1) {
        $i_pageno = 1;
    }
    $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    $i_pageno_count = floor(($i_recordcount - 1) / $i_limitcount) + 1;
    if ($i_limitfrom > $i_recordcount) {
        $i_pageno = $i_pageno_count;
        $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    }
    $i_url_limitto_addon .= "&limitto=" . $i_limitcount;
    $i_url_pageno_addon .= "&pageno=" . $i_pageno;
    $i_url_limit_addon .= $i_url_limitto_addon . $i_url_pageno_addon;
} else {
    $i_url_limitto_addon = "&limitto=";
function writeTestStats($i_testid)
{
    global $g_db, $lngstr, $srv_settings;
    $i_testid = (int) $i_testid;
    $i_test_name = '';
    $i_gscaleid = 0;
    $i_rSet1 = $g_db->SelectLimit("SELECT * FROM " . $srv_settings['table_prefix'] . "tests WHERE testid=" . $i_testid, 1);
    if (!$i_rSet1) {
        showDBError(__FILE__, 1);
    } else {
        if (!$i_rSet1->EOF) {
            $i_test_name = $i_rSet1->fields['test_name'];
            $i_gscaleid = $i_rSet1->fields['gscaleid'];
        }
        $i_rSet1->Close();
    }
    $i_gradecount = 0;
    $i_grades_times_total = 0;
    $i_rSet2 = $g_db->Execute("SELECT * FROM " . $srv_settings['table_prefix'] . "gscales_grades WHERE gscaleid=" . $i_gscaleid . " ORDER BY gscale_gradeid");
    if (!$i_rSet2) {
        showDBError(__FILE__, 2);
    } else {
        while (!$i_rSet2->EOF) {
            $i_gradecount++;
            $i_gradeid = $i_rSet2->fields['gscale_gradeid'];
            $i_grades_names[$i_gradeid] = $i_rSet2->fields['grade_name'];
            $i_grades_times[$i_gradeid] = getRecordCount($srv_settings['table_prefix'] . 'results', 'testid=' . $i_testid . ' AND gscaleid=' . $i_gscaleid . ' AND gscale_gradeid=' . $i_gradeid);
            $i_grades_times_total += $i_grades_times[$i_gradeid];
            $i_rSet2->MoveNext();
        }
        $i_rSet2->Close();
    }
    $i_resultcount = 0;
    $i_points_max = 0;
    $i_points_low = IGT_MAX_FLOAT;
    $i_points_high = 0;
    $i_points_total = 0;
    $i_points_total_max = 0;
    $i_rSet3 = $g_db->Execute("SELECT * FROM " . $srv_settings['table_prefix'] . "results WHERE testid=" . $i_testid . " AND gscale_gradeid > 0");
    if (!$i_rSet3) {
        showDBError(__FILE__, 3);
    } else {
        while (!$i_rSet3->EOF) {
            $i_resultcount++;
            $i_points = $i_rSet3->fields['result_points'];
            $i_points_max = $i_rSet3->fields['result_pointsmax'];
            if ($i_points > $i_points_high) {
                $i_points_high = $i_points;
            }
            if ($i_points < $i_points_low) {
                $i_points_low = $i_points;
            }
            $i_points_total += $i_points;
            $i_points_total_max += $i_points_max;
            $i_rSet3->MoveNext();
        }
        $i_rSet3->Close();
    }
    echo '<tr class=rowone>';
    echo '<td rowspan=' . ($i_gradecount + 8) . ' align=right>' . $i_testid . '</td>';
    echo '<td colspan=4><b>' . $i_test_name . '</b></td>';
    echo '</tr>';
    echo '<tr class=rowone><td colspan=4><img src="images/1x1.gif" width=1 height=5></td></tr>';
    echo '<tr class=rowone>';
    echo '<td>' . $lngstr['page_testmanager_stats']['test_average_score'] . '</td>';
    if ($i_points_total_max > 0 && $i_resultcount > 0) {
        $i_points_average = $i_points_total / $i_resultcount;
        $i_points_average_percentage = $i_points_total * 100 / $i_points_total_max;
        echo '<td>' . getGauge($i_points_average_percentage, 'yellow') . '</td>';
        echo '<td align=right>' . sprintf("%.0f", $i_points_average) . '</td>';
        echo '<td align=right>' . sprintf("%.2f", $i_points_average_percentage) . '%</td>';
    } else {
        echo '<td colspan=3 align=center class=gray>' . $lngstr['label_notapplicable'] . '</td>';
    }
    echo '</tr>';
    echo '<tr class=rowone>';
    echo '<td>' . $lngstr['page_testmanager_stats']['test_high_score'] . '</td>';
    if ($i_points_max > 0) {
        $i_points_high_percentage = $i_points_high * 100 / $i_points_max;
        echo '<td>' . getGauge($i_points_high_percentage, 'green') . '</td>';
        echo '<td align=right>' . $i_points_high . '</td>';
        echo '<td align=right>' . sprintf("%.2f", $i_points_high_percentage) . '%</td>';
    } else {
        echo '<td colspan=3 align=center class=gray>' . $lngstr['label_notapplicable'] . '</td>';
    }
    echo '</tr>';
    echo '<tr class=rowone>';
    echo '<td>' . $lngstr['page_testmanager_stats']['test_low_score'] . '</td>';
    if ($i_points_max > 0) {
        $i_points_low_percentage = $i_points_low * 100 / $i_points_max;
        echo '<td>' . getGauge($i_points_low_percentage, 'red') . '</td>';
        echo '<td align=right>' . $i_points_low . '</td>';
        echo '<td align=right>' . sprintf("%.2f", $i_points_low_percentage) . '%</td>';
    } else {
        echo '<td colspan=3 align=center class=gray>' . $lngstr['label_notapplicable'] . '</td>';
    }
    echo '</tr>';
    echo '<tr class=rowone><td colspan=4><img src="images/1x1.gif" width=1 height=5></td></tr>';
    echo '<tr class=rowone><td colspan=2 class=rowhdr1 title="' . $lngstr['page_testmanager_stats']['hdr_grade_data_hint'] . '">' . $lngstr['page_testmanager_stats']['hdr_grade_data'] . '</td><td class=rowhdr1 title="' . $lngstr['page_testmanager_stats']['hdr_grade_responses_hint'] . '">' . $lngstr['page_testmanager_stats']['hdr_grade_responses_hint'] . '</td><td class=rowhdr1 title="' . $lngstr['page_testmanager_stats']['hdr_percents_hint'] . '">' . $lngstr['page_testmanager_stats']['hdr_percents'] . '</td></tr>';
    foreach ($i_grades_names as $i_gradeid => $i_grade_name) {
        echo '<tr class=rowone>';
        echo '<td>' . $i_grade_name . '</td>';
        if ($i_grades_times_total > 0) {
            $i_grade_times_percentage = $i_grades_times[$i_gradeid] * 100 / $i_grades_times_total;
            echo '<td>' . getGauge($i_grade_times_percentage) . '</td>';
            echo '<td align=right>' . $i_grades_times[$i_gradeid] . '</td>';
            echo '<td align=right>' . sprintf("%.2f", $i_grade_times_percentage) . '%</td>';
        } else {
            echo '<td colspan=3 align=center class=gray>' . $lngstr['label_notapplicable'] . '</td>';
        }
        echo '</tr>';
    }
    echo '<tr class=rowone>';
    echo '<td>' . $lngstr['page_testmanager_stats']['total_responses'] . '</td>';
    echo '<td></td>';
    echo '<td align=right>' . $i_resultcount . '</td>';
    echo '<td align=right></td>';
    echo '</tr>';
}
if ($i_order_no >= count($i_tablefields)) {
    $i_order_no = -1;
}
if ($i_order_no >= 0) {
    $i_direction = isset($_GET['direction']) && $_GET['direction'] ? 'DESC' : '';
    $i_order_addon = '&order=' . $i_order_no . '&direction=' . $i_direction;
    $i_sql_order_addon = ' ORDER BY ' . $i_tablefields[$i_order_no][2] . ' ' . $i_direction;
}
$i_url_limitto_addon = '';
$i_url_pageno_addon = '';
$i_url_limit_addon = '';
$i_pageno = 0;
$i_limitcount = isset($_GET['limitto']) ? (int) $_GET['limitto'] : $G_SESSION['config_itemsperpage'];
if ($i_limitcount > 0) {
    //9917
    $i_recordcount = getRecordCount($srv_settings['table_prefix'] . 'groups');
    $i_pageno = isset($_GET['pageno']) ? (int) $_GET['pageno'] : 1;
    if ($i_pageno < 1) {
        $i_pageno = 1;
    }
    $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    $i_pageno_count = floor(($i_recordcount - 1) / $i_limitcount) + 1;
    if ($i_limitfrom > $i_recordcount) {
        $i_pageno = $i_pageno_count;
        $i_limitfrom = ($i_pageno - 1) * $i_limitcount;
    }
    $i_url_limitto_addon .= '&limitto=' . $i_limitcount;
    $i_url_pageno_addon .= '&pageno=' . $i_pageno;
    $i_url_limit_addon .= $i_url_limitto_addon . $i_url_pageno_addon;
} else {
    $i_url_limitto_addon = '&limitto=';
{
    global $g_vars, $srv_settings, $lngstr;
    if ($i_required && !$i_value) {
        $g_vars['page']['errors'] .= $lngstr['page_register']['no_' . $i_name];
    }
}
if ($g_vars['page']['errors']) {
    include_once $DOCUMENT_PAGES . "register-1.inc.php";
} else {
    $i_id = api_addNewUser($f_username, $f_password, array('email' => $f_email, 'title' => $f_title, 'firstname' => $f_firstname, 'lastname' => $f_lastname, 'middlename' => $f_middlename, 'address' => $f_address, 'city' => $f_city, 'state' => $f_state, 'zip' => $f_zip, 'country' => $f_country, 'phone' => $f_phone, 'fax' => $f_fax, 'mobile' => $f_mobile, 'pager' => $f_pager, 'ipphone' => $f_ipphone, 'webpage' => $f_webpage, 'icq' => $f_icq, 'msn' => $f_msn, 'aol' => $f_aol, 'gender' => $f_gender, 'birthday' => $f_birthday, 'husbandwife' => $f_husbandwife, 'children' => $f_children, 'trainer' => $f_trainer, 'photo' => $f_photo, 'company' => $f_company, 'cposition' => $f_cposition, 'department' => $f_department, 'coffice' => $f_coffice, 'caddress' => $f_caddress, 'ccity' => $f_ccity, 'cstate' => $f_cstate, 'czip' => $f_czip, 'ccountry' => $f_ccountry, 'cphone' => $f_cphone, 'cfax' => $f_cfax, 'cmobile' => $f_cmobile, 'cpager' => $f_cpager, 'cipphone' => $f_cipphone, 'cwebpage' => $f_cwebpage, 'cphoto' => $f_cphoto, 'ufield1' => $f_userfield1, 'ufield2' => $f_userfield2, 'ufield3' => $f_userfield3, 'ufield4' => $f_userfield4, 'ufield5' => $f_userfield5, 'ufield6' => $f_userfield6, 'ufield7' => $f_userfield7, 'ufield8' => $f_userfield8, 'ufield9' => $f_userfield9, 'ufield10' => $f_userfield10, 'checkword' => $i_checkword, 'active' => false), array($f_groupid));
    if ($i_id == false) {
        $g_vars['page']['errors'] .= $lngstr['err_username_duplicate'];
        unset($f_username);
        include_once $DOCUMENT_PAGES . "register-1.inc.php";
    } else {
        if ($i_CONFIG_reg_username == CONFIG_CONST_donotshow_autogenerate || $i_CONFIG_reg_username == CONFIG_CONST_show_autogenerate && getRecordCount($srv_settings['table_prefix'] . 'users', "username="******"UPDATE " . $srv_settings['table_prefix'] . "users SET username="******" WHERE id=" . $i_id);
            $_POST['username'] = $f_username;
        }
        sendEmailTemplate(array('etemplateid' => SYSTEM_ETEMPLATES_REGISTRATION_INDEX, 'emailto' => array($f_email), 'id' => $i_id, 'username' => $f_username, 'password' => $f_password, 'email' => $f_email, 'title' => $f_title, 'firstname' => $f_firstname, 'lastname' => $f_lastname, 'middlename' => $f_middlename, 'address' => $f_address, 'city' => $f_city, 'state' => $f_state, 'zip' => $f_zip, 'country' => $f_country, 'phone' => $f_phone, 'fax' => $f_fax, 'mobile' => $f_mobile, 'pager' => $f_pager, 'ipphone' => $f_ipphone, 'webpage' => $f_webpage, 'icq' => $f_icq, 'msn' => $f_msn, 'aol' => $f_aol, 'gender' => $f_gender, 'birthday' => $f_birthday, 'husbandwife' => $f_husbandwife, 'children' => $f_children, 'trainer' => $f_trainer, 'photo' => $f_photo, 'company' => $f_company, 'cposition' => $f_cposition, 'department' => $f_department, 'coffice' => $f_coffice, 'caddress' => $f_caddress, 'ccity' => $f_ccity, 'cstate' => $f_cstate, 'czip' => $f_czip, 'ccountry' => $f_ccountry, 'cphone' => $f_cphone, 'cfax' => $f_cfax, 'cmobile' => $f_cmobile, 'cpager' => $f_cpager, 'cipphone' => $f_cipphone, 'cwebpage' => $f_cwebpage, 'cphoto' => $f_cphoto, 'ufield1' => $f_userfield1, 'ufield2' => $f_userfield2, 'ufield3' => $f_userfield3, 'ufield4' => $f_userfield4, 'ufield5' => $f_userfield5, 'ufield6' => $f_userfield6, 'ufield7' => $f_userfield7, 'ufield8' => $f_userfield8, 'ufield9' => $f_userfield9, 'ufield10' => $f_userfield10, 'checkword' => $i_checkword));
        $i_admin_emails = getRecordItem($srv_settings['table_prefix'] . 'etemplates', 'etemplate_from', 'etemplateid=' . SYSTEM_ETEMPLATES_ACTIVATE_INDEX);
        $i_admin_emails = explode(SYSTEM_ARRAY_ITEM_SEPARATOR, $i_admin_emails);
        sendEmailTemplate(array('etemplateid' => SYSTEM_ETEMPLATES_REGISTRATION_INDEX_FOR_ADMIN, 'emailto' => $i_admin_emails, 'id' => $i_id, 'username' => $f_username, 'password' => $f_password, 'email' => $f_email, 'title' => $f_title, 'firstname' => $f_firstname, 'lastname' => $f_lastname, 'middlename' => $f_middlename, 'address' => $f_address, 'city' => $f_city, 'state' => $f_state, 'zip' => $f_zip, 'country' => $f_country, 'phone' => $f_phone, 'fax' => $f_fax, 'mobile' => $f_mobile, 'pager' => $f_pager, 'ipphone' => $f_ipphone, 'webpage' => $f_webpage, 'icq' => $f_icq, 'msn' => $f_msn, 'aol' => $f_aol, 'gender' => $f_gender, 'birthday' => $f_birthday, 'husbandwife' => $f_husbandwife, 'children' => $f_children, 'trainer' => $f_trainer, 'photo' => $f_photo, 'company' => $f_company, 'cposition' => $f_cposition, 'department' => $f_department, 'coffice' => $f_coffice, 'caddress' => $f_caddress, 'ccity' => $f_ccity, 'cstate' => $f_cstate, 'czip' => $f_czip, 'ccountry' => $f_ccountry, 'cphone' => $f_cphone, 'cfax' => $f_cfax, 'cmobile' => $f_cmobile, 'cpager' => $f_cpager, 'cipphone' => $f_cipphone, 'cwebpage' => $f_cwebpage, 'cphoto' => $f_cphoto, 'ufield1' => $f_userfield1, 'ufield2' => $f_userfield2, 'ufield3' => $f_userfield3, 'ufield4' => $f_userfield4, 'ufield5' => $f_userfield5, 'ufield6' => $f_userfield6, 'ufield7' => $f_userfield7, 'ufield8' => $f_userfield8, 'ufield9' => $f_userfield9, 'ufield10' => $f_userfield10, 'checkword' => $i_checkword));
        switch (getConfigItem(CONFIG_upon_registration)) {
            case CONFIG_CONST_upon_registration_signinautomatically:
                activateUserByID($i_id, true);
                signinUser($f_username, $f_password, false);
                if ($f_testid > 0) {
                    gotoLocation('test.php?testid=' . $f_testid);
                } else {