assignInclude( "header", "./$skindir/header.tpl" ); $tpl->assignInclude( "footer", "./$skindir/footer.tpl" ); //let TemplatePower do its thing, parsing etc. $tpl->prepare(); include("../../includes/pagesetup.php"); $poll = !empty($_GET['poll']) && isNumber($_GET['poll']) ? $_GET['poll'] : false; if($poll) { $pollquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_poll WHERE poll_id = '$poll' ORDER BY poll_id DESC LIMIT 1"); $currentpoll = dbassoc($pollquery); $opts = explode("|#|", $currentpoll['poll_opts']); $votes = explode("#", $currentpoll['poll_results']); $output .= "
"._POLLARCHIVE.": ".$currentpoll['poll_question']."

"; if(isset($blocks['poll']['bar']) && file_exists($blocks['poll']['bar'])) $bar = $blocks['poll']['bar']; else $bar = _BASEDIR."blocks/poll/bar.jpg"; $totalvotes = 0; $results = array( ); foreach($votes as $opt => $count) { $results[$opt] = $count; $totalvotes = $count ? $count + $totalvotes : $totalvotes; } $output .= "
"; foreach($opts as $num => $opt) { unset($percent); if(!empty($results[$num]) && $results[$num] > 0) $percent = floor(($results[$num] / $totalvotes) * 100); else $percent = 0; $output .= "
$opt
".strip_tags($opt)." $percent%
"; } $output .= "
"; } else { $output .= "
"._POLLARCHIVE."
"; $listquery = dbquery("SELECT poll_id, poll_question, poll_start as start, poll_end as end FROM ".TABLEPREFIX."fanfiction_poll WHERE poll_end IS NOT NULL OR poll_end != 0 ORDER BY poll_id DESC"); if(dbnumrows($listquery) > 0) { $output .= ""; while($poll = dbassoc($listquery)) { $output .= ""; } $output .= "
"._POLLARCHQUESTION.""._START.""._END."
".$poll['poll_question']."".date("$dateformat", $poll['start'])."".date("$dateformat", $poll['end'])."
"; } } $tpl->assign("output", $output); $tpl->printToScreen(); ?>