if themes type if themes us us id us level level query core dbs query

 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
if ($themes['type']==1) {
if ($themes['us']==$us['id'] || $us['level']>$a['level']) {
$query = core :: $dbs -> query ("SELECT * FROM `forum_opr` WHERE (`id_themes`='" . $themes['id'] . "')");
if ($query -> rowCount () == 0) {
echo ' | <a href="/forum.php?mod=opr_add&amp;thema=' . $themes['id'] . '">Добавить опрос</a>';
} } }
echo '</small>';
echo '</div>';
$query = core :: $dbs -> query ("SELECT * FROM `forum_opr` WHERE (`id_themes`='" . $themes['id'] . "')");
if ($query -> rowCount () != 0) {
$opr = $query -> fetch ();
echo '<div class="block">';
echo 'Вопрос: ' . $opr['vopros'] . ' (' . ($opr['type']==1?'открытое':'закрытое') . ' голосование)<br/>';
if (core :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_opr_votes` WHERE (`id_opr`='" . $opr['id'] . "') AND (`us`='" . $us['id'] . "')")==0) {
if (isset ($_GET['opr_votes'])) {
$_POST['otv'] = (int) $_POST['otv'];
if (core :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_opr_otv` WHERE (`id_opr`='" . $opr['id'] . "') AND (`id`=?)", array ($_POST['otv'])) == 0) {
header ('location: /forum/thema' . $themes['id'] . '/page' . $page);
exit;
}
core :: $dbs -> query ("INSERT INTO `forum_opr_votes` (`id_razd`,`id_podrazd`,`id_themes`,`id_opr`,`id_otv`,`us`,`t`) VALUES ('" . $razd['id'] . "', '" . $podrazd['id'] . "', '" . $themes['id'] . "', '" . $opr['id'] . "',?,'" . $us['id'] . "','" . time () . "')", array ($_POST['otv']));
header ('location: /forum/thema' . $themes['id'] . '/page' . $page);
}
echo '<form action="/forum/thema' . $themes['id'] . '/page' . $page . '?opr_vote" method="post">';
echo '<select name="otv">';
$query = core :: $dbs -> query ("SELECT * FROM `forum_opr_otv` WHERE (`id_opr`='" . $opr['id'] . "')");
while ($otv = $query -> fetch ()) {
echo '<option value="' . $otv['id'] . '">' . $otv['text'] . '</option>';
}
echo '</select><br/>';
echo '<input type="submit" value="Проголосовать"/>';
echo '</form>';
}
else {
$query = core :: $dbs -> query ("SELECT * FROM `forum_opr_otv` WHERE (`id_opr`='" . $opr['id'] . "')");
while ($otv = $query -> fetch ()) {
echo '<b>' . $otv['text'] . '</b> (голосов: ' . core :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_opr_votes` WHERE (`id_opr`='" . $opr['id'] . "') AND (`id_otv`='" . $otv['id'] . "')") . ')<br/>';
}
if ($opr['type']==1) {
echo '- <a href="/forums/opros.php?id=' . $themes['id'] . '">Список проголосовавших</a><br/>';
}
}
if ($a['id']==$us['id'] || $a['level']<$us['level']) {
//
if (isset ($_GET['delo'])) {
core :: $dbs -> query ("DELETE FROM `forum_opr` WHERE (`id_themes`='" . $themes['id'] . "')");
core :: $dbs -> query ("DELETE FROM `forum_opr_otv` WHERE (`id_themes`='" . $themes['id'] . "')");
core :: $dbs -> query ("DELETE FROM `forum_opr_votes` WHERE (`id_themes`='" . $themes['id'] . "')");
header ('location: /forum/thema' . $themes['id'] . '/page' . $page);
}
echo '- <a href="/forum.php?mod=vop_add&thema=' . $themes['id'] . '&amp;opr=' . $opr['id'] . '">Добавить</a> | <a href="/forum.php?mod=redop&thema=' . $themes['id'] . '&amp;op=' . $opr['id'] . '">удалить</a> варианты<br/>';
echo '- <a href="/forum.php?mod=thema&id=' . $themes['id'] . '&amp;delo">Удалить опрос</a>';
}
echo '</div>';
}