Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
[HACK] New survey (poll) TTv3
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2020-01-19 16:12:19
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] .= "&nbsp;*";
                 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)."&nbsp;$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]
Capture.JPG
Capture.JPG
Ca3pture.JPG
Ca3pture.JPG
Img polls.rar
Download
polls_block.rar
Download

2020-01-19 16:23:50
Corrects a repeated validation error, I recommend it to you, [url='https://www.torrenttrader.xyz/index.php?threads/error-corrections-on-poll.9813/'][color=rgb(226, 80, 65)]click here[/color][/url]
2025-01-14 12:55:33
Hello friends, how can I make different colors of the bars for different answers in the polls?
As shown in the first picture.

Thankyou spiritblue
Thanks and Regards
Last edited by coco on 2025-01-14 12:56:35
2025-01-15 15:54:18
@coco
If you use usual poll block you must make few changes on bootstrap and block file self...



MckCIplSS16YJOfZMRY4yQ[1].png
MckCIplSS16YJOfZMRY4yQ[1].png



www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
Last edited by Botanicar on 2025-01-15 23:14:19
2025-01-16 13:07:52
Look amazing mate
2025-01-16 15:05:31
Poll block with 7 different colors for each vote option:
1. Before you install this mode backup your files and database
2. Add or replace poll_block.php in your blocks folder
3. Add lines from poll-bar.css to your theme style.css
3. a. Or add line from header.txt to your themes header
4. Import poll table to your sql database

PS
If you use bootstrap on you theme, just add lines from poll-bar.css to bootstrap.mini.css
If you don't use bootstrap on you theme use link from header.txt to import latest bootstrap.mini css
For all other questions, please, leave comment here

Poll block and different stripes colors.zip
Download
qPLzf4R1TKKiLBBLkK7QBw[1].png
qPLzf4R1TKKiLBBLkK7QBw[1].png



www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
Last edited by Botanicar on 2025-01-16 15:06:41
2025-01-16 22:37:34
Nice.  I have my test site set using strict mode with errors turned on, and a while back The polls_block had an undefined constant warning. If you want to fix it in case its an issue, here is the line
    		// now os is an array like this: array(array(123, "Option 1"), array(45, "Option 2"))
if ($arr["sort"] == "yes") {
usort($os, "srt");
}
needs to be called as a string, not a constant it seems. Just wrap srt in quotes. It only sets a warning, not the end of the world, but if you wanna make it correct, this is it. I been slowly in my free time trying to get this script fully working on php 8+, so I been fixing these errors along the way best I can lol
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Last edited by MicroMonkey on 2025-01-16 22:47:50
2025-01-16 23:11:11
In my case I view only 4 different colors. I have 5 voters


2025-01-16 23:21:05
@MicroMonkey thanks

@coco... add content from poll-bar.css to your style.css and try it again; remove line to call external bootstrap.mini.css


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2025-01-18 02:50:33
Wow, what a great development this mode has been, thanks everyone! 👍 ♫
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728