Welcome, Guest. Please login or register.
August 20, 2008, 05:27:14 PM

Login with username, password and session length
Search:     Advanced search
Website Baker 2.7.0 (stable) veröffentlicht!
Nähere Informationen findet ihr hier.
Das Diskussionsboard findet ihr hier.
60556 Posts in 9791 Topics by 5824 Members
Latest Member: blubb
* Home Help Search Login Register
+  Website Baker Community Forum
|-+  English
| |-+  Modules
| | |-+  POLL Module
Pages: [1] 2 3 Go Down Print
Author Topic: POLL Module  (Read 14510 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
Semi-Master Baker
*****
Offline Offline

Posts: 215


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
Almost Master Baker
*****
Offline Offline

Posts: 232


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

it looks great... and i will use it soon grin
Logged
babsy
Almost Master Baker
*****
Offline Offline

Posts: 232


Email
« 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
Almost Master Baker
*****
Offline Offline

Posts: 232


Email
« 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
Pending Apprentice Baker
**
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
"All I Do Is Bake" Baker
*****
Offline Offline

Posts: 503


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.nl.
pcwacht
Guest
« Reply #10 on: November 25, 2005, 10:59:47 AM »

here you go:
Logged
babsy
Almost Master Baker
*****
Offline Offline

Posts: 232


Email
« 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
Pending Apprentice Baker
**
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
Master Baker
*****
Offline Offline

Posts: 358


Email
« 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
Pending Apprentice Baker
**
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
Pending Apprentice Baker
**
Offline Offline

Posts: 4


Email
« 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
Pending Apprentice Baker
**
Offline Offline

Posts: 4


Email
« 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
Pages: [1] 2 3 Go Up Print 
Jump to:  

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