293691
lubdub
Re: I'd like smarter polls
  • 2002/10/15 18:15

  • lubdub

  • Just popping in

  • Posts: 64

  • Since: 2002/2/28


Quote:

I think the polls are based on username, if the voter is logged in. For anonymous users, we use IP.

IMHO, nope... I think there is some logic to correct, here:
here is the code from XoopsPollLog:
$sql "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".$poll_id." AND (ip='".$ip."'";
        if ( !empty(
$user_id) ) {
            
$sql .= " OR user_id=".$user_id."";
        }
        
$sql .= ")";
        list(
$count) = $db->fetchRow($db->query($sql));
        if ( 
$count ) {
            return 
true;

The request is thus, for a logged user:
AND ( IP = ... OR UID = ... ) ==> has voted
in other words, when I have 2 users behind the same firewall, the first is able to vote, but for the second, the IP is the same, the OR condition is true and thus he can't vote.

The correct logic should be:
UID not null ==> use it whatever the ip is.
UID null ==> use the ip whichever it is (this will prevent two anonymous from behind the same firewall, but prevents also a logged user from logging out and voting again)

The corrected code should looks like:
$sql "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".$poll_id." AND ";
        if ( !empty(
$user_id) ) {
            
$sql .= " user_id=".$user_id;
        } else {
            
$sql .= "ip='".$ip."'";
        }


Quote:

Yes, sounds like some nice ideas.

thanks



293692
onokazu
Re: I'd like smarter polls
  • 2002/10/15 17:34

  • onokazu

  • XOOPS Founder

  • Posts: 617

  • Since: 2001/12/13


Quote:

lubdub wrote:
Missing features I'd really would appreciate (of course, I could code them myself... but... not time for now )
- choose the way to record votes (for now, I think it's based on ip, but I have several users behind the same firewall, so it should be allowed to be based on username)


I think the polls are based on username, if the voter is logged in. For anonymous users, we use IP.

Quote:

- allow/prevent anonymous users to vote
- show the list of voting users with their vote (at least for admin, but some polls could be completely public)


Yes, sounds like some nice ideas.



293693
lubdub
I'd like smarter polls
  • 2002/10/15 11:16

  • lubdub

  • Just popping in

  • Posts: 64

  • Since: 2002/2/28


Missing features I'd really would appreciate (of course, I could code them myself... but... not time for now )
- choose the way to record votes (for now, I think it's based on ip, but I have several users behind the same firewall, so it should be allowed to be based on username)
- allow/prevent anonymous users to vote
- show the list of voting users with their vote (at least for admin, but some polls could be completely public)



293694
Akshara
Re: new page to my site ??.
  • 2002/10/14 20:01

  • Akshara

  • Just popping in

  • Posts: 5

  • Since: 2002/8/9 4


Wow... this is one of the clearest and most informative posts I have ever come across. I would like to vote that this suggestion be placed in the "Module Docs" section here. Thank you swisslyons... Excellent.



293695
pauleley
Re: new page to my site ??.
  • 2002/10/14 18:33

  • pauleley

  • Just popping in

  • Posts: 13

  • Since: 2002/10/10


Thanks swisslyons
This works grate.



293696
freeop
Re: new page to my site ??.
  • 2002/10/13 23:13

  • freeop

  • Just popping in

  • Posts: 25

  • Since: 2002/4/12


Nice.. Thx I can use this.. I created a little script using the filename as a variable so I didn't have to add the code to each page :

ie : wrap.php?file=mypage.html
ie : wrap.php?file=MyDir/mypage.html
--------------------------------------
<?php
include("mainfile.php");
include(XOOPS_ROOT_PATH."/header.php");
OpenTable();
include($file);
CloseTable();
include(XOOPS_ROOT_PATH."/footer.php");
?>
----------------------------------------


EDITED :
This works ok.. If you put this code into the root call it wrap.php.. Usinghttp://your site/wrap.php?file=your.html or ?file=mydir/your.html as the link, it will show your html or php script in XOOPS display.. However the problem I had was any links from the page your calling had to be the same : mypage.html had to be changed tohttp://yoursite/wrap.php?file=

That is what the problem was, it doesn't read file and rewrite output changing links... But if you just want to show pages without editing each one it works great.. ( guess you can't really call it a wrapper )



293697
swisslyons
Re: new page to my site ??.
  • 2002/10/13 23:11

  • swisslyons

  • Just popping in

  • Posts: 43

  • Since: 2002/6/23


Sure! no problem Paul and if you have any questions /problems just ask!

Regards,
john



293698
pauleley
Re: new page to my site ??.
  • 2002/10/13 23:09

  • pauleley

  • Just popping in

  • Posts: 13

  • Since: 2002/10/10


Thanks for the Info & all you Help.
I will give it a go and let you no how i get on.
Kind Regerdes
Paul



293699
swisslyons
how to make a module
  • 2002/10/13 22:54

  • swisslyons

  • Just popping in

  • Posts: 43

  • Since: 2002/6/23


The way i usually do this is to make my own module for each page I want to display in the middle of Xoops. To make your own custom module, you only need to create 2 files: index.php and xoops_version.php in a new folder. Lets call this folder 'myModule' for example.

Then, in the index.php,

should copy/paste this code:
*****************************

<?php

include("../../mainfile.php");
include("../../header.php");
include("header.php");
OpenTable();

?>

your HTML content goes here, between these php tags ;) This also works for Flash content, just copy/paste from your flash.htnl file and place it here

<?
CloseTable();
include ("../../footer.php");
?>

**********************************
Here is a second possibility for creating your index.php, using an include(); instead of hardcoding the HTML in the php page. This helps make the code a bit more modular and easier to handle.
Create your html in Dreamweaver or whatever editor, then upload all files to this same module directory (myModule) for example)...and use this code to include it:

**********************************

<?php

include("../../mainfile.php");
include("../../header.php");
include("header.php");
OpenTable();

include("nameOfYourPage.html");


CloseTable();
include ("../../footer.php");
?>

**********************************

OK, then in xoops_version.php

copy/paste this code:
**********************************

<?php
$modversion['name'] = "title that you want to display in main menu";
$modversion['version'] = "alpha testing only";
$modversion['description'] = "description here";
$modversion['credits'] = "The XOOPS Project <BR /> Thanks to blah blah blah....";
$modversion['author'] = "John Lyons (http://www.flashbuilder.ch/)";
$modversion['help'] = "";
$modversion['license'] = "GPL see LICENSE";
$modversion['official'] = 0;
$modversion['image'] = "logo.gif";
$modversion['dirname'] = "myModule";

// Menu
$modversion['hasMain'] = 1;



?>

Then upload this new folder to your modules directory. Log into your site as admin, go to Modules, and add this module. Don't forget to give group rights to access this module.

That should do it, I hope its all ok becuase its late here and I am tired.

P.S. --> if you are trying to include content that is on another URL and you cant copy/paste the code, try using the
framebrowser script



293700
pauleley
Re: new page to my site ??.
  • 2002/10/13 22:41

  • pauleley

  • Just popping in

  • Posts: 13

  • Since: 2002/10/10


Hi Thanks for the info i have downloaded FreeContent & installed it but when i try to it i get: Sorry, we were unable to find this Link-ID in our Database
Dos any one no my problem.
Thanks
Paul Eley







Login

Who's Online

259 user(s) are online (166 user(s) are browsing Support Forums)


Members: 0


Guests: 259


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits