Welcome, Guest. Please login or register.
March 17, 2010, 12:56:18 AM

Login with username, password and session length
Search:     Advanced search
WB 2.8.1 veröffentlicht!
Download und weitere Informationen gibt es hier .
110166 Posts in 15912 Topics by 9281 Members
Latest Member: s-pax
* Home Help Search Login Register
+  WebsiteBaker Community Forum
|-+  English
| |-+  Modules (Moderators: Argos, BerndJM)
| | |-+  POLL Module
Pages: [1] 2 3 4 Go Down Print
Author Topic: POLL Module  (Read 26424 times)
pcwacht
Guest
« on: July 27, 2005, 03:36:57 PM »

Allmost ready with my POLL module

Current features :
Unlimited polls, one per section
Unlimited questions
Scores editable
IP logged for one vote per ip

Only need to implement time out for iplogging
once per vote, once per week, day, 12 hour, 1 hour

What other features are required, so I can implement them in the first release.

John
Logged
pcwacht
Guest
« Reply #1 on: July 27, 2005, 07:33:10 PM »

Time has been added, you can give the amount of hours the voter's  ip will be checked against.
ie:
24 = one day
168 = one week
720 = one month
99999999 = a very long time Wink

Best place for this module is in a side block.
See this post for the poll module : http://forum.websitebaker.org/index.php/topic,1256.msg11290.html#msg11290

Have fun!
John
« Last Edit: December 03, 2005, 05:28:51 PM by pcwacht » Logged
pcwacht
Guest
« Reply #2 on: July 27, 2005, 08:24:30 PM »

and here is the snippet wich can be used with the poll-module
you need to change the poll_id to the one you want!

Code:
$poll_id=1;   // **** change this *****

// the rest shouldn't be altered..

$show_poll=$_REQUEST['show'];
$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_polls WHERE poll_id = '$poll_id'");
$poll_data = $query_content->fetchRow();
$txt_vote = $poll_data['txt_vote'];
$txt_voted = $poll_data['txt_voted'];
$txt_picture = WB_URL."/modules/polls/".$poll_data['txt_picture'];
$txt_nopolls = $poll_data['txt_nopolls'];
$txt_results = $poll_data['txt_results'];
$poll_id = $poll_data['poll_id'];
if($query_content->numRows() > 0) {                            # If there is a poll
$fetch_content = $query_content->fetchRow();
$ip = $_SERVER['REMOTE_ADDR'];                             # Check for voted allready
$data = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_polls_votes  WHERE `vote_ip` = '" . $ip . "' AND `poll_id` = '" . $poll_id . "' AND `vote_datum` > '" . time() . "'" );
$datapoll = $data->fetchRow();

    if ((!$_POST['vote']) && (!$datapoll) && (!$show_poll)) {  # Check if form submitted and not voted yet and no request to show results!
$options = explode(",", $poll_data['poll_keuzes']);    # Split options and count them in loop
    $aant = count($options)-1;
    $poll .= "<center>".$poll_data['poll_stelling']."</center><br />" ;
    $poll .= "<form method=\"POST\" action=\"" . $_SERVER['PHP_SELF'] . "\">";
    for($i = 0; $i <= $aant; $i++) {                       # Loop and make input radios  
    $j = $i+1;
       $poll .= "<input type=\"radio\" value=\"" . $j . "\" name=\"poll\" />" . $options[$i] . "<br />";
    }
    $poll .= "<br /><center><input type=\"submit\" class=\"button\" name=\"vote\" value=\"$txt_vote\" /></center></form>";
    $poll .= "<center><a href=\"".$_SERVER[PHP_SELF]."?show=1\">".$txt_results."</a></center>";
    echo $poll;
} else {                                                   # Add data to database and check for a value
        if($_POST['poll']) {                                   # Option selected - Update votes
           $vote=$_POST['poll'];
           $stemmen = explode(",", $poll_data['poll_scores']);# Split the vote scores
            $vote--;                                      
           (int) $stemmen[$vote]++;                           # add one to the selected option  
           $stem = implode(",", $stemmen);                    # Remake the data and add to database
           $poll_data['poll_scores']=$stem;
           $database->query("UPDATE ".TABLE_PREFIX."mod_polls SET `poll_scores` = '" . $stem . "' WHERE `poll_id` = '" . $poll_data['poll_id'] . "'");
$date_time = time()+($poll_data['poll_ttl']*60*60);
$database->query("INSERT INTO ".TABLE_PREFIX."mod_polls_votes SET `vote_ip` = '" . $ip . "',`poll_id` = '" . $poll_data['poll_id'] . "', `vote_datum` = '" . $date_time . "'");
            # Make sure to show poll
            $datapoll="1" ;
       }
    }
if(($datapoll) || ($show_poll)) {                          # If allready voted or requested show results
$options = explode(",", $poll_data['poll_keuzes']);    # Split options and scores
   $scores = explode(",", $poll_data['poll_scores']);
    $option = count($options)-1;
   $votes = array_sum($scores);                           # Count the votes and show them
   $results .= "<center>".$poll_data['poll_stelling']."</center><br />";
    $results .= "<p>";
   for($i = 0;$i <= $option; $i++) {                      # Loop through results
    $results .= $options[$i] . "<br />";
        if ($votes>0) {
        $num = (int) ($scores[$i] / ($votes/100)) ;
        } else {
        $num=0;
        }
    $results .= "<img src=\"".$txt_picture."\" width=\"" . $num/2 . "\" height=\"10\" /> " . $num . "%";
       $results .= "<br />";
    }
   $results .= "</p>";
   $results .= $txt_voted . $votes . "<br />";
    echo $results;            
}
} else {                                                       # No polls!
echo $txt_nopolls;
}

have fun!
Logged
Bennie_wijs

Offline Offline

Posts: 230


I believe what I want to Believe.


WWW
« Reply #3 on: July 28, 2005, 09:01:12 AM »

Looks good.

As soon as a need a poll, I will download yours  wink
Logged

I believe what I want to Believe
babsy

Offline Offline

Posts: 299


« Reply #4 on: September 27, 2005, 10:54:32 AM »

it looks great... and i will use it soon grin
Logged
babsy

Offline Offline

Posts: 299


« Reply #5 on: October 24, 2005, 11:08:15 AM »

HI...

now i need this poll, but, im not sure how to insert it....

i have downloaded the module (but where exacly should i copy the code, - i tryed copying it on to the template itself, but it only appeared as text...?

 huh
Logged
pcwacht
Guest
« Reply #6 on: October 24, 2005, 11:45:26 AM »

put the text between
<?php and ?> so the webserver will know it is php.

You don't need the <?php and ?> when inserting the text in a code section!

John
Logged
babsy

Offline Offline

Posts: 299


« Reply #7 on: October 26, 2005, 02:20:37 PM »

Hi again...

and thanks alot... works like a charm...
now i only have to play with it, to make it look like i want to  grin

thanks!

its is on www.kjolurin.com
Logged
remob

Offline Offline

Posts: 13


« Reply #8 on: November 25, 2005, 01:14:21 AM »

@ phil

where one can I download your fantastic polling module? the download links mentioned above unfortunately does not work any more

thanks
Logged
i2Paq

Offline Offline

Posts: 500


Tempelier, on bare feet!


WWW
« Reply #9 on: November 25, 2005, 08:02:19 AM »

@ phil John

where one can I download your fantastic polling module? the download links mentioned above unfortunately does not work any more

thanks

Maybe babsy or John can put up a new link (or we can have it in the modules section if it's finished  wink)
Logged

Opensource is my life,  osCommerce and PrestaShop..
pcwacht
Guest
« Reply #10 on: November 25, 2005, 10:59:47 AM »

here you go:
Logged
babsy

Offline Offline

Posts: 299


« Reply #11 on: December 06, 2005, 03:18:23 PM »

Hi again.... this is probably a very very stupid question!

but how can i make a new poll... I just want a new question with new votes! to i have to install it again??

i tryed just to change the question, but that did´nt to it?? huh
Logged
pcwacht
Guest
« Reply #12 on: December 06, 2005, 03:48:24 PM »

If you have a poll running and you want other questions, just overtype them
If you want another poll with diff questions, make a new section

If you use the snippet to include the poll in your template make sure to adjust the poll_id!


John
Logged
remob

Offline Offline

Posts: 13


« Reply #13 on: December 13, 2005, 11:31:59 PM »

if you want to run the poll module with webseitebaker 2.6.0 you have to change the info.php

add the new variable $module_function to the file

Code:
$module_function = 'page';

and the module works perfect
Logged
pcwacht
Guest
« Reply #14 on: December 14, 2005, 12:04:45 AM »

k, it needs to be updated.
Will do so soon.

John
Logged
Hans

Offline Offline

Posts: 498


« Reply #15 on: December 25, 2005, 10:11:26 PM »

In 2.6.1 I can't get the poll module working in a block  cry
Hans
[Edit] Sorry, I put the code in a code-block, now it works great.
« Last Edit: December 25, 2005, 10:22:46 PM by Hans » Logged

Hans - Nijmegen - The Netherlands
mufti

Offline Offline

Posts: 8


« Reply #16 on: February 20, 2006, 02:31:02 PM »

Hi.. nice Module. Thx to the author!

Question:

i want the module to run under the menue. (is use the ROUND Template). The Menu is on the left side.
Is that possible? If yes - what have i to do exacktly? Thanx for your help!

my site: www.musichall-oppau.de

Greetz,
André
Logged
Liakoni

Offline Offline

Posts: 4


« Reply #17 on: February 22, 2006, 10:43:35 PM »

In 2.6.1 i get " Table 'wb._wbmod_polls' doesn't exist "
I changed the  file info.php $module_function= 'page'; but it didn't worked .
Logged
pcwacht
Guest
« Reply #18 on: February 22, 2006, 11:00:16 PM »

When you get the error : Table 'wb._wbmod_polls' doesn't exist "

there went something wrong during installation

Did you install the mod through admin-addons-modules-install?

What you can try, reload modules (admin->settings-show advanced-bottom of page)

Think this will work.

John
Logged
Liakoni

Offline Offline

Posts: 4


« Reply #19 on: February 23, 2006, 12:20:05 AM »

When you get the error : Table 'wb._wbmod_polls' doesn't exist "

there went something wrong during installation

Did you install the mod through admin-addons-modules-install?

What you can try, reload modules (admin->settings-show advanced-bottom of page)

Think this will work.

John


I didn't install it correct.
But what file should i select to make install through  admin-addons-modules-install ?

My mistake. I install it correct this time.

Thanks!!!
« Last Edit: February 23, 2006, 12:23:01 AM by Liakoni » Logged
pcwacht
Guest
« Reply #20 on: February 23, 2006, 01:28:58 AM »

the poll.zip
Logged
dhdesign

Offline Offline

Posts: 35


« Reply #21 on: February 23, 2006, 01:48:02 AM »

I've installed the poll module and set up a test poll.  I voted once, and have been making adjustments to the layout of the poll. Using Firefox 1.5.0.1, each time I refresh the page, there is another vote added to the total.  In IE6, this does not happen.

With the IP block, it is supposed to stop people from voting more than once in the period specified.  How do I stop the vote count from going up when Firefox users refresh the page (which defeats the purpose of the IP block)? 
« Last Edit: February 23, 2006, 01:59:58 AM by dhdesign » Logged
grimwalker

Offline Offline

Posts: 1


« Reply #22 on: February 26, 2006, 02:35:45 PM »

Well, on Opera I can vote as much times as i want too Sad
Logged
pcwacht
Guest
« Reply #23 on: February 26, 2006, 06:19:11 PM »

Here is a new version wich checks the vote to see if it was voted allready or not, allso with refreshes.

Changed version number to 1.0 cause it is stable
changed info.php so it wokrs with 26x

To update, overwrite the files.


Have fun,
John
Logged
wwwMARKLEYcouk

Offline Offline

Posts: 287



WWW
« Reply #24 on: March 02, 2006, 04:52:50 PM »

im test this now and seems to be working nice Smiley however, i tried adding more than one poll to a page and you cant do it without it saving and duplicating the first poll that is already present Sad

is tehre going to be a feature in the future for this to view old polls? as at present the only way i can see is to delete the old poll and make a new one in its place when i want to change Sad
Logged

http://www.markley.co.uk
webhosting packages available
Pages: [1] 2 3 4 Go Up Print 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!