1 |
<?php |
2 |
|
3 |
$dbhost = "localhost"; // Хост, на котором расположен сервер MySQL |
4 |
$dbuser = "root"; // Имя пользователя MySQL |
5 |
/***** ЗДЕСЬ ВБИТЬ ПАРОЛЬ root'а: *****/ |
6 |
$dbpwd = "ibpjahtybr"; // Пароль пользователя MySQL |
7 |
|
8 |
/***** НЕ ТРОГАЕМ: *****/ |
9 |
$db = "vpntest"; // Имя базы данных |
10 |
$UsersTable = "users"; |
11 |
$QuestionsTable = "questions"; |
12 |
$ResultsTable = "results"; |
13 |
$SnapshotsTable = "snapshots"; // => будут и таблицы snapshots_users, snapshots_results, snapshots_questions |
14 |
|
15 |
$VLoginSession = "vmxlsess"; |
16 |
|
17 |
/***** ВБИТЬ ДРУГОЕ ИМЯ ДОМЕНА, ЕСЛИ УСТАНОВЛЕНО ДРУГОЕ *****/ |
18 |
$Domain = "vpntest.ru"; |
19 |
|
20 |
/***** ПАРАМЕТРЫ ПРОЦЕССА ТЕСТИРОВАНИЯ - МОЖНО МЕНЯТЬ БЕЗБОЛЕЗНЕННО *****/ |
21 |
$MatrixWidth = 10; // ширина матрицы с номерами вопросов |
22 |
$TriesCount = 3; // количество возможных попыток ответить на один вопрос |
23 |
$TimeLimit = 60*90; // временной лимит теста в секундах - чтобы отключить, |
24 |
// закомментируйте эту строку полностью или установите его меньшим нуля |
25 |
|
26 |
/***** ПАРАМЕТРЫ СТРАНИЦ АДМИНИСТРИРОВАНИЯ И АРХИВА - МОЖНО МЕНЯТЬ *****/ |
27 |
$ElementsPerPage = 20; // количество записей на одной странице при постраничном просмотре |
28 |
|
29 |
/***** ДАЛЕЕ - НЕ ТРОГАЕМ *****/ |
30 |
|
31 |
$cfgLastErr = ''; // последняя ошибка |
32 |
$link = false; // MySQL-соединение |
33 |
|
34 |
/* Несколько стандартных функций */ |
35 |
|
36 |
function amysql_query ($q) |
37 |
{ |
38 |
global $amy_query_count; |
39 |
if (!isset ($amy_query_count)) |
40 |
$amy_query_count = 0; |
41 |
$amy_query_count++; |
42 |
return mysql_query ($q); |
43 |
} |
44 |
|
45 |
function str_starts_with ($str, $sub) |
46 |
{ |
47 |
if (strcmp (substr ($str, 0, strlen ($sub)), $sub) == 0) |
48 |
return true; |
49 |
return false; |
50 |
} |
51 |
|
52 |
function html_pbr ($str) |
53 |
{ |
54 |
return str_replace ("\n", "<br>", htmlspecialchars($str)); |
55 |
} |
56 |
|
57 |
function query_str_replace ($str, $from, $to) |
58 |
{ |
59 |
$a = explode ('&', $str); |
60 |
for ($i = 0; $i < count ($a); $i++) |
61 |
if (strcmp ($a [$i], $from) == 0) |
62 |
$a [$i] = $to; |
63 |
delnull ($a); |
64 |
return implode ('&', $a); |
65 |
} |
66 |
|
67 |
function query_str_add ($str, $what) |
68 |
{ |
69 |
$a = explode ('&', $str); |
70 |
for ($i = 0; $i < count ($a); $i++) |
71 |
if (strcmp ($a [$i], $what) == 0) |
72 |
break; |
73 |
if ($i >= count($a)) |
74 |
$a [count($a)] = $what; |
75 |
delnull ($a); |
76 |
return implode ('&', $a); |
77 |
} |
78 |
|
79 |
function mysql_start ($donotexit = false) |
80 |
{ |
81 |
global $cfgLastErr, $link, $dbhost, $dbuser, $dbpwd, $db; |
82 |
if ($link) // уже соединено |
83 |
return true; |
84 |
// Соединяемся с MySQL |
85 |
$link = mysql_connect ($dbhost, $dbuser, $dbpwd); |
86 |
if (!$link) |
87 |
{ |
88 |
$cfgLastErr = 'Could not connect to the database: ' . mysql_errno() . ": " . mysql_error(); |
89 |
if (!$donotexit) |
90 |
exit; |
91 |
return false; |
92 |
} |
93 |
mysql_select_db($db); // даже если её нет - всё равно скажем что всё ок. init создаст |
94 |
return true; |
95 |
} |
96 |
|
97 |
function mysql_finish () |
98 |
{ |
99 |
global $result, $link; |
100 |
// Очищаем MySQL-соединение |
101 |
@mysql_free_result($result); |
102 |
if (isset ($link) && $link !== false) |
103 |
mysql_close($link); |
104 |
$link = false; |
105 |
} |
106 |
|
107 |
?> |