From 9cb1fcba82027daa21eb457f1b2912ee02e5c7eb Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sun, 14 Dec 2008 09:39:10 -0500 Subject: Major design and code overhaul I don't know, a lot of stuffses happened that I don't quite remember anymore. Goodness, that's not good. --- pages/poll.php | 60 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 9 deletions(-) (limited to 'pages/poll.php') 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'; if (isset($_GET['submit'])) { - $setip = "INSERT INTO didpollalready SET ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; - $setip2 = mysql_query($setip); - $getpoll = "SELECT * FROM polloftheweek ORDER BY id DESC LIMIT 0,1"; - $getpoll2 = mysql_query($getpoll); - $getpoll3 = mysql_fetch_array($getpoll2); - $setpoll = "UPDATE polloftheweek SET clicks" . $_POST['options'] . " = " . ($getpoll3['clicks' . $_POST['options']]+1) . " WHERE id = " . $getpoll3['id']; + $setip = "INSERT INTO didpollalready SET ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; + $setip2 = mysql_query($setip); + $getpoll = "SELECT * FROM polloftheweek ORDER BY id DESC LIMIT 0,1"; + $getpoll2 = mysql_query($getpoll); + $getpoll3 = mysql_fetch_array($getpoll2); + $setpoll = "UPDATE polloftheweek SET clicks" . $_POST['options'] . " = " . ($getpoll3['clicks' . $_POST['options']]+1) . " WHERE id = " . $getpoll3['id']; $setpoll2 = mysql_query($setpoll); $template = new FITemplate('msg'); @@ -43,17 +43,57 @@ if (isset($_GET['submit'])) { $template = new FITemplate('pollIndex'); - $getpolls = "SELECT * FROM polloftheweek ORDER BY id DESC"; + if (isset($_GET['start'])) + { + $start = $_GET['start'] * 10; + } else { + $start = 0; + } + + $getpolls = "SELECT * FROM polloftheweek ORDER BY id DESC LIMIT " . $start . ",10"; $getpolls2 = mysql_query($getpolls); $i=0; while ($getpolls3[$i] = mysql_fetch_array($getpolls2)) { + $question = strip_tags($getpolls3[$i]['question']); + if (strlen($question) > 50) + { + $question = substr($question, 0, 50); + while (substr($question, strlen($question)-1) != ' ') + { + $question = substr($question, 0, strlen($question)-1); + } + + $question = substr($question, 0, strlen($question)-1); + $question .= '....'; + } $template->adds_block('POLL', array( 'ID' => $getpolls3[$i]['id'], - 'QUESTION' => $getpolls3[$i]['question'], - 'WEEK' => date('F jS Y', strtotime($getpolls3[$i]['week'])))); + 'QUESTION' => $question, + 'WEEK' => date('F jS Y', strtotime($getpolls3[$i]['week'])), + 'EVEN' => (($i % 2 == 1) ? ' CLASS="even"' : ''))); $i++; } + if ($i==0) + { + generateError('404'); + exit; + } + + $start /= 10; + if ($start > 0) + { + $template->adds_block('PREVIOUS', array('ID' => ($start-1))); + } + + $cntpolls = "SELECT COUNT(*) FROM polloftheweek"; + $cntpolls2 = mysql_query($cntpolls); + $cntpolls3 = mysql_fetch_array($cntpolls2); + if ($start < floor($cntpolls3['COUNT(*)'] / 10)) + { + $template->adds_block('NEXT', array('ID' => ($start+1))); + } + include('pages/polloftheweek.php'); $template->display(); @@ -95,6 +135,8 @@ if (isset($_GET['submit'])) $page_id = 'polloftheweek-' . $getpoll3['id']; include('includes/comments.php'); + + displayRelated($getpoll3['question']); } ?> -- cgit 1.4.1