| 1 | <?php |
| 2 | // pokus urobit neco z anketami:-))nerehocte sa moc hlasno:-)) |
| 3 | |
| 4 | function vote() { |
| 5 | global $node,$db,$error,$referer_id; |
| 6 | if (!$referer_id) $referer_id=1; |
| 7 | |
| 8 | $node_id=$node['node_id']; |
| 9 | $user_id=$_SESSION['user_id']; |
| 10 | |
| 11 | $set=$db->query("select * from node_access where node_id='$node_id' |
| 12 | and user_id='$user_id' and node_permission='ban'"); |
| 13 | if($set->getNumRows()>0) { |
| 14 | global $error; |
| 15 | $error="One vote is enough for everyone"; |
| 16 | return false; |
| 17 | } |
| 18 | |
| 19 | |
| 20 | $option=$_POST['poll_option']; |
| 21 | $option--; |
| 22 | |
| 23 | if (!is_numeric($option)) { |
| 24 | $error="incorrect poll_option. fck"; |
| 25 | } |
| 26 | |
| 27 | $poll=unserialize($node['node_content']); |
| 28 | ++$poll[$option]['number']; |
| 29 | $node_content=serialize($poll); |
| 30 | $db->query("update nodes set node_content='$node_content' |
| 31 | where node_id='$node_id'"); |
| 32 | |
| 33 | $db->query("update node_access set node_permission='ban' where |
| 34 | node_id='$node_id' and user_id='$user_id'"); |
| 35 | Header("Location: /id/".$node['node_parent']."/"); |
| 36 | } |
| 37 | |
| 38 | ?> |