Home Private Messages Search
CPG Dragonfly™ CMS stopsoftwarepatents.eu petition banner
Toggle Content
 
Forums ⇒ CMS (All) ⇒ Requests :: Archives ⇒ [approved] Add my survey module changes to cvs :: Archived


[approved] Add my survey module changes to cvs :: Archived
Requests for core changes must be submitted through the Projects Features section.
Go to page 1, 2  Next
This forum is locked: you cannot post, reply to, or edit topics.    This topic is locked: you cannot edit posts or make replies.    Printer Friendly Page     Forum Index ⇒  Requests

Topic Archived View previous topic :: View next topic  
Author Message
Mammlouk
Nice poster
Nice poster

Offline Offline
Joined: Apr 13, 2007
Posts: 128
Location: Colorado
PostPosted: Thu May 17, 2007 4:08 pm
Post subject: [approved] Add my survey module changes to cvs

I was just curious what your rules/procedures are for getting changes committed to CVS. I made a modified version of the survey module that changes allowances from 1 vote per ip, to 1 vote per username. I am working on changing it to support both and give you the option of which you prefer. It seems unnecessary to have it as a separate module instead of just merging with the core survey module. Please let me know how to proceed.

Thanks,
-Jeremy


Mammlouk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Thu May 17, 2007 6:17 pm
Post subject: Re: CVS Commits

Show us the code and we will look into it.

A vote system based on username is nice, but what about anonymous votes?


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
Mammlouk
Nice poster
Nice poster

Offline Offline
Joined: Apr 13, 2007
Posts: 128
Location: Colorado
PostPosted: Thu May 17, 2007 7:44 pm
Post subject: Re: CVS Commits

I can just throw in a check for anonymous and then base it on the users IP. Although I think anonymous voting kinda defeats the purpose :). Shouldn't be too hard to make an option to allow or disallow anonymous users either. I should have some good free time on Saturday and Sunday, so I will try to come up with a more comprehensive solution and then upload it for you here.


Mammlouk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Thu May 17, 2007 8:14 pm
Post subject: Re: CVS Commits

Great Mammlouk, we'll look forward to it.


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
Mammlouk
Nice poster
Nice poster

Offline Offline
Joined: Apr 13, 2007
Posts: 128
Location: Colorado
PostPosted: Sat May 19, 2007 7:20 pm
Post subject: Re: CVS Commits

I've got it almost completed, but I am having a little trouble with the main index page. I've got the code setup to check voting status based on user, or ip depending on the survey options. It works perfectly in the Survey Block, showing the results if you've already voted, but I can't seem to figure out the redirect in index.php and get it working the same. Instead it always gives you the option to vote... I've got code in so that it won't actually submit to the database if you've already voted, but that's not what we're really looking for.

If you have any tips let me know, I will keep working at it and post back if I get it fixed.


Mammlouk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
Mammlouk
Nice poster
Nice poster

Offline Offline
Joined: Apr 13, 2007
Posts: 128
Location: Colorado
PostPosted: Sat May 19, 2007 8:49 pm
Post subject: Re: Add my survey module changes to cvs

O.k. I figured it out, not sure if it's the best way to do it, but it works. Please take a look and let me know what you think. My changes are in the following areas:

index.php:
lines 67-78, 137-152, and 159-174

cpg-inst.php:
lines 42 and 58

admin/index.inc:
lines 28, and 117-121

block-survey.php:
lines 38 -48

That may not be exactly complete, but it's pretty much everything I added.


Mammlouk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)


Last edited by Mammlouk on Sun May 20, 2007 3:27 pm; edited 1 time in total
Back to top
View user's profile Visit poster's website
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Sun May 20, 2007 11:52 am
Post subject: Re: Add my survey module changes to cvs

block-survey:
Code::
    $result3 = $db->sql_query("SELECT anonymous FROM ".$prefix."_poll_desc WHERE poll_id='$poll_id'");
    while ($row = $db->sql_fetchrow($result3, SQL_ASSOC)) {
        if(($row['anonymous'] == "0") && ($userinfo['username'] == "Anonymous")) { //if you are anonymous and no anonymous votes allowed, you can't vote
            $voted = "1";
        }elseif(($row['anonymous'] == "1") && ($userinfo['username'] == "Anonymous")) { //if limited by username, but anonymous is allowed, don't disallow multiple anonymous entries
            $voted = $db->sql_count($prefix.'_poll_check', "user='".$userinfo['username']."' AND ip='".$userinfo['user_ip']."' AND poll_id='$poll_id'");//only one anonymous per ip
        }else{
            $voted = $db->sql_count($prefix.'_poll_check', "user='".$userinfo['username']."' AND poll_id='$poll_id'");
        }
    }
    $db->sql_freeresult($result3);

This is not really fast because the while loop is useless since there can't be duplicate poll_id's

Replace
PHP:
$result = $db->sql_query("SELECT poll_id, poll_title, voters FROM ".$prefix."_poll_desc WHERE artid=0 $querylang ORDER BY poll_id DESC LIMIT 0,1");
/*...*/
list($poll_id, $poll_title, $voters) = $db->sql_fetchrow($result);
with
PHP:
$result = $db->sql_query("SELECT poll_id, poll_title, voters, anonymous FROM ".$prefix."_poll_desc WHERE artid=0 $querylang ORDER BY poll_id DESC LIMIT 0,1");
/*...*/
list($poll_id, $poll_title, $voters, $anonymous) = $db->sql_fetchrow($result);

Then replace the first code with
Code::
    if ($anonymous == "0" && $userinfo['username'] == "Anonymous") { //if you are anonymous and no anonymous votes allowed, you can't vote
        $voted = 1;
    } elseif (anonymous == "1" && $userinfo['username'] == "Anonymous") { //if limited by username, but anonymous is allowed, don't disallow multiple anonymous entries
        $voted = $db->sql_count($prefix.'_poll_check', "user='".$userinfo['username']."' AND ip='".$userinfo['user_ip']."' AND poll_id='$poll_id'");//only one anonymous per ip
    }else{
        $voted = $db->sql_count($prefix.'_poll_check', "user='".$userinfo['username']."' AND poll_id='$poll_id'");
    }

Secondly: don't use $userinfo['username'], use the $userinfo['user_id'] instead.
This because searching on text is damn slow compared to an integer, and usernames are unreliable.

Look around in your code and find the other anomalies.


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
Mammlouk
Nice poster
Nice poster

Offline Offline
Joined: Apr 13, 2007
Posts: 128
Location: Colorado
PostPosted: Sun May 20, 2007 12:00 pm
Post subject: Re: Add my survey module changes to cvs

I actually looked at that first, but being unfamiliar with the list function, went the way I did. Big grin I will take care of fixing it today and re-upload. In your last code tag after "Then replace the first code with", I don't see any code... Is that just me? Anyway, I will do some googling and try to fix it all adequately. Thanks for the pointer.


Mammlouk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Sun May 20, 2007 12:01 pm
Post subject: Re: Add my survey module changes to cvs

fixed the bbcode


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
Mammlouk
Nice poster
Nice poster

Offline Offline
Joined: Apr 13, 2007
Posts: 128
Location: Colorado
PostPosted: Sun May 20, 2007 12:57 pm
Post subject: Re: Add my survey module changes to cvs

Thanks. That's about what I figured it said, but i wanted to check. I will fix the code as soon as I have another free minute and let you know.


Mammlouk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
Mammlouk
Nice poster
Nice poster

Offline Offline
Joined: Apr 13, 2007
Posts: 128
Location: Colorado
PostPosted: Sun May 20, 2007 3:34 pm
Post subject: Re: Add my survey module changes to cvs

O.k. I updated it with the changes you mentioned. I just updated the file attached to the previous post.

In addition, I also made the following changes:
I changed most statements like this
Code::
if($anonymous == "0" && $userinfo['username'] == "Anonymous")
to this
Code::
if(!$anonymous && !is_user())
I figured it is probably better to just use the built in function than to re-evaluate my own way. If you disagree due to speed or anything please let me know.

I also update index.php so that there is a pollVoted function that takes the poll_id as input and returns the correct $voted string/query. Since it is being called 3 times it seemed like a better idea than having repeat code.

Thanks for the help and please let me know if you have any other comments or recommendations!


Mammlouk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
Mammlouk
Nice poster
Nice poster

Offline Offline
Joined: Apr 13, 2007
Posts: 128
Location: Colorado
PostPosted: Sat Jun 02, 2007 5:41 am
Post subject: Re: Add my survey module changes to cvs

DJ Maze,
Just wanted to check and see if the code was satisfactory.


Mammlouk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
Mammlouk
Nice poster
Nice poster

Offline Offline
Joined: Apr 13, 2007
Posts: 128
Location: Colorado
PostPosted: Sat Aug 18, 2007 8:54 pm
Post subject: Re: Add my survey module changes to cvs

DJ - It's been awhile and I thought that since I haven't heard anything, I would check back in and see if you had any input for me on this. Do I need to make more changes to my code? Is it sloppy?

Thanks,
-Jeremy


Mammlouk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Sat Aug 25, 2007 8:59 pm
Post subject: Re: Add my survey module changes to cvs

I was on holiday, it's summer ya know Smile


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Sat Aug 25, 2007 9:15 pm
Post subject: Re: Add my survey module changes to cvs

Added to CVS


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.    This topic is locked: you cannot edit posts or make replies.    Printer Friendly Page    Forum Index ⇒  Requests
Page 1 of 2
All times are GMT
Go to page 1, 2  Next

 
   Toggle Content User Info

Welcome Anonymous

Nickname
Password
(Register)

   Toggle Content Last CVS commits
· Fixed .ico Expires header.
· Removed domain name from cookies so subdomains wont access them anymore.
· CSS and JS, case insensitives.
· CSS and JS, send correct HTTP 1.1 headers and fixed issues where themes and...
· Further security class improvements.
· 301 redirects on LEO changes
· Option to force 3xx http status codes
· Validate googlebot.com and google.com crawlers.
· CCBot
· Rss with etag and atom.

read more...

   Toggle Content Community

Support for DragonflyCMS in a other languages:

Deutsch
Español

   Toggle Content X-links
UltraEdit Browse Happy logo Firefox MySQL PostgreSQL Valid CSS! Valid XHTML 1.0! Unicode Encoded Badge NukeBiz Resources Raven DragonflyCMS Dedicated Now InsideSupport Lampe Berger

You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
Interactive software released under GNU GPL, Code Credits, Privacy Policy