-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathveral_cache.php
More file actions
90 lines (68 loc) · 2.55 KB
/
veral_cache.php
File metadata and controls
90 lines (68 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
ini_set('display_errors', true);
session_start();
mysql_connect('localhost','root','aidos123') or die("Not connect to MySQL");
mysql_select_db('test') or die("Not connect to DB");
mysql_set_charset('utf8');
/**
* Simle SQL execute
*@author=Aidos Kakimzhanov
*@version=1.0
*/
class SQL {
public function getOne($sql){
$res = mysql_query($sql);
$row = mysql_fetch_assoc($res);
return $row;
}
public function execute($sql){
$sql = mysql_query($sql);
while ($row = mysql_fetch_assoc($sql)) {
$data[] = $row;
}
return $data;
}
}
$SQL = new SQL();
$test = $SQL->execute('SELECT answers.answer, tests.* FROM tests
JOIN answers ON tests.number=answers.number and tests.name=answers.name ;');
header('Content-Type: text/plain; charset=utf-8');
ECHO<<<END
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE test SYSTEM "XTF_v1p1.dtd">
<test>
<questions>
END;
foreach ($test as $e) {
?>
<single random="y" format="custom">
<p align="left"><font face="Times New Roman" size="3"><?=$e['number']?>.<?=$e['question']?></font></p>
<?php if ($e['А']): ?>
<answer rating="<?=($e['answer']=='А')?'1':'0'?>"><p align="left"><font face="Arial" size="3"/><font face="Times New Roman" size="3"><?=$e['А']?></font></p></answer>
<?php endif ?>
<?php if ($e['Б']): ?>
<answer rating="<?=($e['answer']=='Б')?'1':'0'?>"><p align="left"><font face="Arial" size="3"/><font face="Times New Roman" size="3"><?=$e['Б']?></font></p></answer>
<?php endif ?>
<?php if ($e['В']): ?>
<answer rating="<?=($e['answer']=='В')?'1':'0'?>"><p align="left"><font face="Arial" size="3"/><font face="Times New Roman" size="3"><?=$e['В']?></font></p></answer>
<?php endif ?>
<?php if ($e['Г']): ?>
<answer rating="<?=($e['answer']=='Г')?'1':'0'?>"><p align="left"><font face="Arial" size="3"/><font face="Times New Roman" size="3"><?=$e['Г']?></font></p></answer>
<?php endif ?>
<?php if ($e['Д']): ?>
<answer rating="<?=($e['answer']=='Д')?'1':'0'?>"><p align="left"><font face="Arial" size="3"/><font face="Times New Roman" size="3"><?=$e['Д']?></font></p></answer>
<?php endif ?>
<?php if ($e['Е']): ?>
<answer rating="<?=($e['answer']=='Е')?'1':'0'?>"><p align="left"><font face="Arial" size="3"/><font face="Times New Roman" size="3"><?=$e['Е']?></font></p></answer>
<?php endif ?>
<?php if ($e['Ж']): ?>
<answer rating="<?=($e['answer']=='Ж')?'1':'0'?>"><p align="left"><font face="Arial" size="3"/><font face="Times New Roman" size="3"><?=$e['Ж']?></font></p></answer>
<?php endif ?>
</single>
<?php
}
?>
ECHO<<<END
</questions>
</test>
END;