{$language_block['Poll title']}"; elseif($_SESSION["$random_code"] == "off") $links = " {$language_block['Poll title']}"; $template_block = implode("", file("templates/$template/block.php")); $template_block = str_replace("{template}", $template, $template_block); $template_block = str_replace("{links}", $links, $template_block); if(!isset($_SESSION["$random_code"]) || $_SESSION["$random_code"] == "on") { $poll = $db->getLine("SELECT * FROM poll ORDER BY id DESC LIMIT 1"); $Total_poll_votes = $poll['votes1'] + $poll['votes2'] + $poll['votes3'] + $poll['votes4'] + $poll['votes5'] + $poll['votes6'] + $poll['votes7'] + $poll['votes8'] + $poll['votes9'] + $poll['votes10']; if($poll != FALSE) { if($l == "save_poll") { if(@$_SESSION["jcmpoll_{$poll['id']}"] == "{$poll['id']}" || @$_COOKIE["jcmpoll_{$poll['id']}"] == "{$poll['id']}"){ header("location: $PHP_SELF?l=results_poll"); exit;} if(!$_POST['answer']){ header("location: $PHP_SELF?&i=77"); exit;} $tmp["votes{$_POST['answer']}"] = $poll["votes{$_POST['answer']}"] + 1; $db->updateRow("poll",$tmp,"id={$poll['id']}"); $_SESSION["jcmpoll_{$poll['id']}"] = $poll['id']; setcookie("jcmpoll_{$poll['id']}", $poll['id'], time() + 86400); $query_string = "?{$_SERVER['QUERY_STRING']}"; if($query_string == "?") $query_code = "?l=results_poll"; else $query_code = "$query_string&l=results_poll"; header("location: $PHP_SELF$query_code"); } elseif(@$_SESSION["jcmpoll_{$poll['id']}"] == "{$poll['id']}" || @$_COOKIE["jcmpoll_{$poll['id']}"] == "{$poll['id']}" || $l == "results_poll") { $content .= "{$poll['question']}"; for($i = 1; $i <= 10; $i++) { if($Total_poll_votes != "0") $poll_percent = round(($poll["votes$i"] * 100 / $Total_poll_votes), 1); else $poll_percent = 0; if($poll["option$i"] != NULL) $content .= "
{$poll["option$i"]} [{$poll["votes$i"]} v.]$poll_percent%
"; } $content .= "{$language_block['Poll votes']} $Total_poll_votes"; } else { $query_string = "?{$_SERVER['QUERY_STRING']}"; if($query_string == "?") $query_code = "?l=results_poll"; else $query_code = "$query_string&l=results_poll"; $content .= "
{$poll['question']}"; for($i = 1; $i <= 10; $i++) if($poll["option$i"] != NULL) $content .= "{$poll["option$i"]}"; $content .= " {$language_block['Poll results']}"; $content .= "
"; } } else { $content .= " {$language_block['Poll blank']} "; } } $template_block = str_replace("{content}", $content, $template_block); $output = $template_block; return $output; } ?>