|
|
|
One vote per user 3 Years ago
|
Karma: 0
|
|
Hi,
Great job !!!
Is there a way to limit the votes to only one vote per user ?
I noticed in phpmyadmin, that only the last ip is recorded, so it's possible to vote again after somebody.
In the demo (v1.5), it's not possible to vote twice, so i'm looking for the solution ...
Thanks,
Benjiz
|
|
|
|
Logged
|
|
|
The topic has been locked.
|
|
|
|
Re:One vote per user 3 Years ago
|
Karma: 7
|
|
Our demo VOTItaly version works exactly as you say... however we have planned to include this feature... but we have actually no dates...
|
|
|
|
Logged
|
|
|
Last Edit: 2009/01/19 17:05 By silzenna.
|
|
|
|
|
|
The topic has been locked.
|
|
|
|
Re:One vote per user 3 Years ago
|
Karma: 0
|
|
Hi!
This would be a nice feature. If that helps, check the code of pollxt component. It has a similar feature for polls: enable Cookies, enable IP-check, enable Username-check.
|
|
|
|
Logged
|
|
|
The topic has been locked.
|
|
|
|
Re:One vote per user 2 Years, 9 Months ago
|
Karma: 0
|
Firstly welcome to all and I apologize for my language (use translator).
I had a big problem that users realized the trick of the last IP, and a vote was made after another, consecutively.
Finally I typed a few lines of code in the module "ajax.php" and I think for now I have saved the situation to get a single vote per user.
First I created an additional table:
--
-- Estructura de tabla para la tabla `log_rating`
--
CREATE TABLE IF NOT EXISTS `log_rating` (
`content_id` int(11) NOT NULL default '0',
`ip` varchar(150) NOT NULL,
PRIMARY KEY (`content_id`,`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Tabla de votaciones';
Finally touch the code from this:
| Code: |
<?php
/*
// "VOTItaly" Plugin for Joomla! 1.5.x - Version 1.0
// License: http://www.gnu.org/copyleft/gpl.html
// Authors: Luca Scarpa & Silvio Zennaro
// Copyright (c) 2006 - 2008 Siloos snc - http://www.siloos.it
// Project page at http://www.joomitaly.com - Demos at http://demo.joomitaly.com
// ***Last update: Jul 01th, 2008***
*/
// Set flag that this is a parent file
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) . '/../../..' );
define('JPATH_CORE', JPATH_BASE . '/../../..');
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$cfg =& JFactory::getConfig();
$db =& JFactory::getDBO();
$rate = (int) JRequest::getVar( 'rating', false );
$cid = (int) JRequest::getVar( 'cid', false );
$status_code = storeVote($cid, $rate);
function storeVote($content_id, $user_rating) {
global $db;
$query = 'SELECT *' .
' FROM #__content_rating' .
' WHERE content_id = '.(int) $content_id;
$db->setQuery($query);
$rating = $db->loadObject();
if (!$rating) {
$prev_rating_count = 0;
$prev_rating_sum = 0;
} else {
$prev_rating_count = $rating->rating_count;
$prev_rating_sum = $rating->rating_sum;
}
$error = 0;
$message = '';
if ( $user_rating >= 1 && $user_rating <= 5) {
$userIP = $_SERVER['REMOTE_ADDR'];
if (!$rating) {
// There are no ratings yet, so lets insert our rating
$query = 'INSERT INTO #__content_rating ( content_id, lastip, rating_sum, rating_count )' .
' VALUES ( '.(int) $content_id.', '.$db->Quote($userIP).', '.(int) $user_rating.', 1 )';
$db->setQuery($query);
if (!$db->query()) {
$error = 1;
$message = $db->stderr();
} else {
$rating_count = 1;
$rating_sum = $user_rating;
}
// By ArdiIIa
$query = 'INSERT INTO log_rating (IP, content_id )' .
'VALUES (' . $db->Quote($userIP) . ',' . (int) $content_id . ')';
$db->setQuery($query);
$db->query();
} else {
//By ArdiIIa
$query = 'SELECT * FROM log_rating WHERE IP = ' . $db->Quote($userIP) . ' and content_id = ' . (int)$content_id;
$db->setQuery($query);
$row = $db->loadObject();
if ( ! $row ) {
$query = 'INSERT INTO log_rating (IP, content_id )' .
'VALUES (' . $db->Quote($userIP) . ',' . (int) $content_id . ')';
$db->setQuery($query);
if (!$db->query()) {
$error = 2;
$message = $db->stderr();
}
}
if (!$row and $rating)
{ // End code ArdiIIa
// We weren't the last voter so lets add our vote to the ratings totals for the article
$query = 'UPDATE #__content_rating' .
' SET rating_count = rating_count + 1, rating_sum = rating_sum + '.(int) $user_rating.', lastip = '.$db->Quote($userIP) .
' WHERE content_id = '.(int) $content_id;
$db->setQuery($query);
if (!$db->query()) {
$error = 2;
$message = $db->stderr();
} else {
$rating_count = $prev_rating_count + 1;
$rating_sum = $prev_rating_sum + $user_rating;
}
} else {
$error = 2; // giĆ votato!
}
}
} else $error = 3;
if (!$error) {
$average = number_format(intval($rating_sum) / intval( $rating_count ),2);
$width = $average * 20;
} else {
$average = ($prev_rating_count ? number_format(intval($prev_rating_sum) / intval( $prev_rating_count ),2) : 0 );
$width = $average * 20;
}
?>
{
success: <?php echo ( $error ? 'false' : 'true' ); ?>,
return_code: <?php echo $error; ?>,
message: "<?php echo $message; ?>",
width: <?php echo ( false ? '""' : '"'.$width.'%"' ); ?>,
num_votes: <?php echo ( $error ? $prev_rating_count : $rating_count ); ?>,
average: <?php echo ( false ? '""' : $average ); ?>,
out_of: 5
}
<?php
}
|
I have done this evening and apparently it works.
If you want to see it in operation can visit my site:
www.senderismosermar.com/index.php/votacion
And results:
www.senderismosermar.com/index.php/resultados-vptaciion
Thank you very much for this component. 
|
|
|
|
Logged
|
|
|
Last Edit: 2009/04/28 07:16 By ArdiIIa.
|
|
|
The topic has been locked.
|
|
|
|
Re:One vote per user 2 Years, 7 Months ago
|
Karma: 0
|
|
Note;
It's voting system was deactivated by the deadline for voting (sorry)
|
|
|
|
Logged
|
|
|
The topic has been locked.
|
strgg
Fresh Boarder
Posts: 2
|
|
Re:One vote per user 2 Years, 7 Months ago
|
Karma: 0
|
Please, Please, Please Admin tell us what's going on there
A fix to store more ip's and to prevent abuse would be a relief.
Please, it would be sooo nice
@ardilla
does your fix work and why I could not find any article rating at your website?
thx for a helping answer admin, ardilla or phpgod
@admins
It doesnt matter if the solution is a hack or integrated in the backend! A working hack
is sufficient.
|
|
|
|
Logged
|
|
|
Last Edit: 2009/06/26 22:02 By strgg.
|
|
|
The topic has been locked.
|
|
|
|
Re:One vote per user 2 Years, 7 Months ago
|
Karma: 0
|
You have here an example of how the code applies above.
tinyurl.com/lxvv29
|
|
|
|
Logged
|
|
|
The topic has been locked.
|
strgg
Fresh Boarder
Posts: 2
|
|
Re:One vote per user 2 Years, 7 Months ago
|
Karma: 0
|
hi ardilla,
thank you very much for this share.
it seems to be working  the ip's are stored in the database.
@ardila
i was used to use this extension for rating
extensions.joomla.org/extensions/5483/details
the advantages are: 1. it allows option that voting is only for logged-in users, 2. you can include starrating into content which is awesome I wish there were a hack for this extension which does the same as your hack for votitaly.
thank you ardilla and have a good life 
|
|
|
|
Logged
|
|
|
Last Edit: 2009/07/03 13:18 By strgg.
|
|
|
The topic has been locked.
|
|