Improving Polls, replacing session to cookie

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
Rkz
Forum Members
Forum Members
Posts: 36
Joined: Tue Feb 12, 2008 8:30 pm

Improving Polls, replacing session to cookie

Post by Rkz »

Hi,
Its time to improve our polls system.

So I guess everyting what we need is in Polls.module.php file.

Im not stong programmer of cmsms, but I think It would be much easier when we have the code.

Make them eat the cookie:  line 274:

Code: Select all

		if (session_id()=="") session_start();

		$q="INSERT INTO ".cms_db_prefix()."module_pollblocked (sessionid,votetime,pollid) VALUES (?,?,?)";
here we have to set cookie:
it could be sth like this:

Code: Select all

setcookie ($this->GetPollName($pollid), "", time() + 60*60*24*30); // cookie with pool name and time to live
also we have to change this function line 107:

Code: Select all

function UserAlreadyVoted($pollid) {
		$db=&$this->GetDb();
		$q="SELECT * FROM ".cms_db_prefix()."module_pollblocked WHERE pollid=? AND sessionid=?";
		$p=array($pollid,session_id());
		$result=$db->Execute($q,$p);
		if (!$result || $result->RecordCount()<1) {
			return false;
		} else {
			return true;
		}
	}
to this:

Code: Select all

	function UserAlreadyVoted($pollid) {
if (isset($_COOKIE['$this->GetPollName($pollid)'])
 {
return true;
} 
else {
	return false;
	}
Is it OK? Please let me know what do you think about that idea




   
Last edited by Rkz on Thu Feb 25, 2010 12:12 pm, edited 1 time in total.
Post Reply

Return to “Developers Discussion”