source: quests/action.php@ 276

Last change on this file since 276 was 263, checked in by maron, 17 years ago

Páru oprav

File size: 2.9 KB
Line 
1<?php
2
3 include('includes/global.php');
4
5 if (array_key_exists('delete', $_GET) and Licence(1)) {
6 $QuestID = $_GET['ID'];
7 $Database->SQLCommand("DELETE FROM quests WHERE ID = '$QuestID' AND Language <> '0'");
8 echo 'Quest byl smazán!';
9 WriteLog('Quest smazán! <a href="form.php?ID='.$QuestID.'">'.$QuestID.'</a>', 4);
10 }
11
12 if (array_key_exists('NotComplete', $_GET) and Licence(1)) {
13 $QuestID = $_GET['ID'];
14 $Database->SQLCommand("UPDATE quests SET Complete = '0' WHERE ID = '$QuestID'");
15 echo 'Quest byl vrázen k opravì!';
16 WriteLog('Quest Byl brácen k opravì <a href="form.php?ID='.$QuestID.'">'.$QuestID.'</a>', 4);
17 }
18
19 if (array_key_exists('shoutbox', $_GET)) {
20 $shoutbox = $_GET['shoutbox'];
21 if ($shoutbox == '') {
22 echo '<form action="action.php?shoutbox=1" method="post">
23 Uµivatel: ';
24 if (Licence(0)) echo '<b>'.$_SESSION['User'].'</b><br />'; else echo '<input type="text" name="user"><br />';
25 echo 'Text zprávy: <input type="text" name="text" size="50">
26 <input type="submit" value="Uloµit"><br />
27 </form>';
28 } else {
29 if (Licence(0)) $user = $_SESSION['User']; else {
30 $user = $_POST['user'];
31 $Line = mysql_fetch_array($Database->SQLCommand("SELECT * FROM user WHERE user = '$user'"));
32 if ((!$Line) or ($user == '')) {} else die('Toto jméno je registrováno nemùµete psát za nìj. Pokud jste '.$user.' pak se pøihlaste.');
33 }
34 $text = $_POST['text'];
35 $Database->SQLCommand("INSERT INTO `shoutbox` ( `user` , `text` , `date` , `IP` )
36 VALUES ( '$user', '$text', now(), '".$_SERVER['REMOTE_ADDR']."');");
37 echo 'Zpráva vloµena!';
38 }
39 }
40
41 if (array_key_exists('vote', $_GET)) {
42 $questID = $_GET['ID'];
43 $vote = $_GET['vote'];
44 $IDuser = $_SESSION['UserID'];
45
46 if (($vote > 5) OR ($vote < 1)) die ('Spadná známka');
47
48
49 $Line = mysql_fetch_row($Database->SQLCommand("SELECT * FROM quests_vote WHERE IDuser = '$IDuser' AND IDquest = '$questID'"));
50 if ((!$Line) and (Licence(0))) {
51 $Line = mysql_fetch_array($Database->SQLCommand("SELECT Vote,CountVote FROM quests WHERE ID = '$questID'"));
52 $CountVote = $Line['CountVote']+1;
53 $OldVote = $Line['Vote']*$Line['CountVote'];
54 $NewVote = ($OldVote+$vote)/$CountVote;
55
56 $Database->SQLCommand("UPDATE quests SET Vote = '$NewVote', CountVote = '$CountVote' WHERE ID = '$questID'");
57
58 $Database->SQLCommand("INSERT INTO `quests_vote` ( `IDquest` , `IDuser` , `vote` ) VALUES ( '$questID', '$IDuser', '$vote');");
59 echo 'Hlas byl ulo¾en! Hlasoval jste: '.$vote.'<br /> Nyní je známka questu '.$NewVote;
60
61 WriteLog('U¾ivatel hlasoval: '.$vote.'! Nyní je známka questu (<a href="form.php?ID='.$questID.'">'.$questID.'</a>): '.$NewVote, 5);
62 } else echo 'Ji¾ jste hlasoval!, nebo nem¾e¹ hlasovat';
63 }
64
65 ShowFooter();
66?>
67
Note: See TracBrowser for help on using the repository browser.