diff options
Diffstat (limited to 'pages/poll.php')
-rwxr-xr-x | pages/poll.php | 60 |
1 files changed, 51 insertions, 9 deletions
diff --git a/pages/poll.php b/pages/poll.php index d871a7d..2dee559 100755 --- a/pages/poll.php +++ b/pages/poll.php | |||
@@ -26,12 +26,12 @@ $pageCategory = 'poll'; | |||
26 | 26 | ||
27 | if (isset($_GET['submit'])) | 27 | if (isset($_GET['submit'])) |
28 | { | 28 | { |
29 | $setip = "INSERT INTO didpollalready SET ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; | 29 | $setip = "INSERT INTO didpollalready SET ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; |
30 | $setip2 = mysql_query($setip); | 30 | $setip2 = mysql_query($setip); |
31 | $getpoll = "SELECT * FROM polloftheweek ORDER BY id DESC LIMIT 0,1"; | 31 | $getpoll = "SELECT * FROM polloftheweek ORDER BY id DESC LIMIT 0,1"; |
32 | $getpoll2 = mysql_query($getpoll); | 32 | $getpoll2 = mysql_query($getpoll); |
33 | $getpoll3 = mysql_fetch_array($getpoll2); | 33 | $getpoll3 = mysql_fetch_array($getpoll2); |
34 | $setpoll = "UPDATE polloftheweek SET clicks" . $_POST['options'] . " = " . ($getpoll3['clicks' . $_POST['options']]+1) . " WHERE id = " . $getpoll3['id']; | 34 | $setpoll = "UPDATE polloftheweek SET clicks" . $_POST['options'] . " = " . ($getpoll3['clicks' . $_POST['options']]+1) . " WHERE id = " . $getpoll3['id']; |
35 | $setpoll2 = mysql_query($setpoll); | 35 | $setpoll2 = mysql_query($setpoll); |
36 | 36 | ||
37 | $template = new FITemplate('msg'); | 37 | $template = new FITemplate('msg'); |
@@ -43,17 +43,57 @@ if (isset($_GET['submit'])) | |||
43 | { | 43 | { |
44 | $template = new FITemplate('pollIndex'); | 44 | $template = new FITemplate('pollIndex'); |
45 | 45 | ||
46 | $getpolls = "SELECT * FROM polloftheweek ORDER BY id DESC"; | 46 | if (isset($_GET['start'])) |
47 | { | ||
48 | $start = $_GET['start'] * 10; | ||
49 | } else { | ||
50 | $start = 0; | ||
51 | } | ||
52 | |||
53 | $getpolls = "SELECT * FROM polloftheweek ORDER BY id DESC LIMIT " . $start . ",10"; | ||
47 | $getpolls2 = mysql_query($getpolls); | 54 | $getpolls2 = mysql_query($getpolls); |
48 | $i=0; | 55 | $i=0; |
49 | while ($getpolls3[$i] = mysql_fetch_array($getpolls2)) | 56 | while ($getpolls3[$i] = mysql_fetch_array($getpolls2)) |
50 | { | 57 | { |
58 | $question = strip_tags($getpolls3[$i]['question']); | ||
59 | if (strlen($question) > 50) | ||
60 | { | ||
61 | $question = substr($question, 0, 50); | ||
62 | while (substr($question, strlen($question)-1) != ' ') | ||
63 | { | ||
64 | $question = substr($question, 0, strlen($question)-1); | ||
65 | } | ||
66 | |||
67 | $question = substr($question, 0, strlen($question)-1); | ||
68 | $question .= '....'; | ||
69 | } | ||
51 | $template->adds_block('POLL', array( 'ID' => $getpolls3[$i]['id'], | 70 | $template->adds_block('POLL', array( 'ID' => $getpolls3[$i]['id'], |
52 | 'QUESTION' => $getpolls3[$i]['question'], | 71 | 'QUESTION' => $question, |
53 | 'WEEK' => date('F jS Y', strtotime($getpolls3[$i]['week'])))); | 72 | 'WEEK' => date('F jS Y', strtotime($getpolls3[$i]['week'])), |
73 | 'EVEN' => (($i % 2 == 1) ? ' CLASS="even"' : ''))); | ||
54 | $i++; | 74 | $i++; |
55 | } | 75 | } |
56 | 76 | ||
77 | if ($i==0) | ||
78 | { | ||
79 | generateError('404'); | ||
80 | exit; | ||
81 | } | ||
82 | |||
83 | $start /= 10; | ||
84 | if ($start > 0) | ||
85 | { | ||
86 | $template->adds_block('PREVIOUS', array('ID' => ($start-1))); | ||
87 | } | ||
88 | |||
89 | $cntpolls = "SELECT COUNT(*) FROM polloftheweek"; | ||
90 | $cntpolls2 = mysql_query($cntpolls); | ||
91 | $cntpolls3 = mysql_fetch_array($cntpolls2); | ||
92 | if ($start < floor($cntpolls3['COUNT(*)'] / 10)) | ||
93 | { | ||
94 | $template->adds_block('NEXT', array('ID' => ($start+1))); | ||
95 | } | ||
96 | |||
57 | include('pages/polloftheweek.php'); | 97 | include('pages/polloftheweek.php'); |
58 | 98 | ||
59 | $template->display(); | 99 | $template->display(); |
@@ -95,6 +135,8 @@ if (isset($_GET['submit'])) | |||
95 | 135 | ||
96 | $page_id = 'polloftheweek-' . $getpoll3['id']; | 136 | $page_id = 'polloftheweek-' . $getpoll3['id']; |
97 | include('includes/comments.php'); | 137 | include('includes/comments.php'); |
138 | |||
139 | displayRelated($getpoll3['question']); | ||
98 | } | 140 | } |
99 | 141 | ||
100 | ?> | 142 | ?> |