Hi
Se hack comes from serf in 2015 from a super nice poll of tt and even nowadays
SQL:
No
Author:
[USER=1398]serph[/USER]
Update By:
SPIRITBLUE
Post:
Here
I brought the configuration for v3 and I redid the images to give them a more degraded side and more brilliant colors ?
Open[color=rgb(251, 160, 38)] backend / functions.php[/color] and search :
function stdfoot() {
global $site_config, $CURUSER, $THEME, $LANGUAGE;
require_once("themes/" . $THEME . "/footer.php");
mysqli_close($GLOBALS["DBconnector"]);
}
Add after :
// Poll - @TTv3 2020
function get_poolsleft($i){
global $site_config, $THEME; if ($i == 0 || $i == 5 || $i == 10 || $i == 15) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar1-l.png border=0>";
if ($i == 1 || $i == 6 || $i == 11 || $i == 16) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar2-l.png border=0>";
if ($i == 2 || $i == 7 || $i == 12 || $i == 17) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar3-l.png border=0>";
if ($i == 3 || $i == 8 || $i == 13 || $i == 18) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar4-l.png border=0>";
if ($i == 4 || $i == 9 || $i == 14 || $i == 19) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar5-l.png border=0>";
return "";
}
function get_poolsmiddle($i){
global $site_config, $THEME;
if ($i == 0 || $i == 5 || $i == 10 || $i == 15) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar1.png border=0";
if ($i == 1 || $i == 6 || $i == 11 || $i == 16) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar2.png border=0";
if ($i == 2 || $i == 7 || $i == 12 || $i == 17) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar3.png border=0";
if ($i == 3 || $i == 8 || $i == 13 || $i == 18) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar4.png border=0";
if ($i == 4 || $i == 9 || $i == 14 || $i == 19) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar5.png border=0";
return "";
}
function get_poolsright($i) {
global $site_config, $THEME;
if ($i == 0 || $i == 5 || $i == 10 || $i == 15) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar1-r.png border=0>";
if ($i == 1 || $i == 6 || $i == 11 || $i == 16) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar2-r.png border=0>";
if ($i == 2 || $i == 7 || $i == 12 || $i == 17) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar3-r.png border=0>";
if ($i == 3 || $i == 8 || $i == 13 || $i == 18) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar4-r.png border=0>";
if ($i == 4 || $i == 9 || $i == 14 || $i == 19) return "<img src=".$site_config['SITEURL']."/themes/" . $THEME . "/images/polls/bar5-r.png border=0>";
return "";
}
// End Poll
~
Add the [color=rgb(247, 218, 100)]polls [/color]name folder in the [color=rgb(247, 218, 100)]images[/color] folder of your default themes
~ Copy your block from the name polls block or download the lowest.
Block poll,,,:
<?php
begin_block(T_("POLL"));
require_once("backend/functions.php");
dbconn(false);
if (!function_exists("srt")) {
function srt($a,$b){
if ($a[0] > $b[0]) return -1;
if ($a[0] < $b[0]) return 1;
return 0;
}
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && $CURUSER && $_POST["act"] == "takepoll"){
$choice = $_POST["choice"];
if ($choice != "" && $choice < 256 && $choice == floor($choice)){
$res = SQL_Query_exec("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or mysqlierr($GLOBALS["DBconnector"]);
$arr = mysqli_fetch_assoc($res) or block_error_msg("Error", "No Poll",1);
$pollid = $arr["id"];
$userid = $CURUSER["id"];
$res = SQL_Query_exec("SELECT * FROM pollanswers WHERE pollid=$pollid && userid=$userid") or mysqlierr($GLOBALS["DBconnector"]);
$arr = mysqli_fetch_assoc($res);
if ($arr){
block_error_msg("Error", "You have already voted!", 0);
}else{
SQL_Query_exec("INSERT INTO pollanswers VALUES(0, $pollid, $userid, $choice)") or mysqlierr($GLOBALS["DBconnector"]);
if (mysqli_affected_rows() != 1)
block_error_msg("Error", "An error has occurred. Your vote has not been counted.", 0);
}
}else{
block_error_msg("Error", "Please select one option.", 0);
}
}
// Get current poll
if ($CURUSER){
$res = SQL_Query_exec("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or mysqlierr($GLOBALS["DBconnector"]);
if($pollok=(mysqli_num_rows($res))) {
$arr = mysqli_fetch_assoc($res);
$pollid = $arr["id"];
$userid = $CURUSER["id"];
$question = $arr["question"];
$o = array($arr["option0"], $arr["option1"], $arr["option2"], $arr["option3"], $arr["option4"],
$arr["option5"], $arr["option6"], $arr["option7"], $arr["option8"], $arr["option9"],
$arr["option10"], $arr["option11"], $arr["option12"], $arr["option13"], $arr["option14"],
$arr["option15"], $arr["option16"], $arr["option17"], $arr["option18"], $arr["option19"]);
// Check if user has already voted
$res = SQL_Query_exec("SELECT * FROM pollanswers WHERE pollid=$pollid AND userid=$userid") or mysqlierr($GLOBALS["DBconnector"]);
$arr2 = mysqli_fetch_assoc($res);
}
//Display Current Poll
if($pollok) {
print("<div align=center><b>$question</b></div>\n");
$voted = $arr2;
// If member has voted already show results
if ($voted) {
if ($arr["selection"])
$uservote = $arr["selection"];
else
$uservote = -1;
// we reserve 255 for blank vote.
$res = SQL_Query_exec("SELECT selection FROM pollanswers WHERE pollid=$pollid AND selection < 20") or mysqlierr($GLOBALS["DBconnector"]);
$tvotes = mysqli_num_rows($res);
$vs = array(); // array of
$os = array();
// Count votes
while ($arr2 = mysqli_fetch_row($res))
$vs[$arr2[0]] += 1;
reset($o);
for ($i = 0; $i < count($o); ++$i)
if ($o[$i])
$os[$i] = array($vs[$i], $o[$i]);
// now os is an array like this: array(array(123, "Option 1"), array(45, "Option 2"))
if ($arr["sort"] == "yes")
usort($os, srt);
print("<table width=100% border=0 cellspacing=0 cellpadding=0>\n");
$i = 0;
while ($a = $os[$i]){
if ($i == $uservote)
$a[1] .= " *";
if ($tvotes == 0)
$p = 0;
else
$p = round($a[0] / $tvotes * 100);
print("<tr><td class=table_head align=center width=100%>" . format_comment($a[1]) . "</td></tr><tr><td align=left width=100% class=pollspercent>".get_poolsleft($i)."".get_poolsmiddle($i)." height=12 width=" . ($p) . ">".get_poolsright($i)." $p%</td></tr><tr><td><br></td></tr>\n");
++$i;
}
print("</table>\n");
$tvotes = number_format($tvotes);
print("<div align=center>Votes: $tvotes</div>\n");
}else{//User has not voted, show options
print("<form method=post action='?$_SERVER[QUERY_STRING]'>\n");
print("<input type=hidden name=act value='takepoll'>");
$i = 0;
while ($a = $o[$i]){
print("<input type=radio name=choice value=$i>".format_comment($a)."<br/>\n");
++$i;
}
print("<br/>");
print("<input type=radio name=choice value=255>Blank Vote (View Results)<br/>\n");
print("<p align=center><input type=submit value='Vote!'></p></form>");
}
} else {
echo"<br/><br/><center><i>..No active survey! </i></center><br/><br/>\n";
}
} else {
echo"br/><br/>center>You must be logged in to view polls .</centrer><br/><br/>\n";
}
end_block();
?>
Add themes / theme by default / theme.css at the end of the page:
/* Poll */
.pollsanswer {
color:#000;
border: 0px solid #486386;
}
.pollspercent {
background: none;
color: #F0F8FF;
border-bottom: 0px solid #486386;
border-left: 0px solid #486386;
border-right: 0px solid #486386;
}
[color=rgb(97, 189, 109)]([/color]
[color=rgb(251, 160, 38)]Make changes to the css lines to adapt it to your theme[/color] [color=rgb(65, 168, 95)]) [/color]
Example on my site:
[ATTACH type="full" width="161px" alt="5331"]5331[/ATTACH]
[ATTACH type="full" width="159px" alt="5328"]5328[/ATTACH]