Jigsaw Posted June 30, 2013 Posted June 30, 2013 I'm in need of a User Rating mod, that allows users to rate a person once a day, I believe Cronus had one, but I can't seem to find a copy, if anyone could lend me one, if would be appreciated! Thanks in advance. Quote
Guest Posted June 30, 2013 Posted June 30, 2013 Totally wrong section as I assume this is for MCCodes. Try posting over here http://makewebgames.io/forumdisplay.php/301-Requests-amp-In-Production I will put it in my todo list if no one else is doing it. Quote
SolarBacon Posted August 6, 2013 Posted August 6, 2013 (edited) I threw this together in literally 5 minutes, you should read through the .php files you can learn a lot... Run this in PhpMyAdmin ALTER TABLE `users` Add `DailyVote` varchar(255) NOT NULL default 'False', Add `upvotes` int(11) NOT NULL default '0', Add `downvotes` int(11) NOT NULL default '0'; Put this in Viewuser.php print "<tr> <td>Votes: <br> Up: {$r['upvotes']}'> <br>Down: {$r['downvotes']}'</td>" print "<tr> <td><a href='upvote.php?u={$r['userid']}'>Give a up vote!</a></td>" print "<tr> <td><a href='downvote.php?u={$r['userid']}'>Give a down vote!</a></td>" upvote.php <?php include "globals.php"; $_GET['u'] = abs((int) $_GET['u']); if(!$_GET['u']) { print "Invalid use of file"; } else { $_GET['u'] = mysql_real_escape_string($_GET['u'], $link) $q=$db->query("SELECT u.*,us.*,c.*,h.*,g.*,f.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN cities c ON u.location=c.cityid LEFT JOIN houses h ON u.maxwill=h.hWILL LEFT JOIN gangs g ON g.gangID=u.gang LEFT JOIN fedjail f ON f.fed_userid=u.userid WHERE u.userid={$_GET['u']}"); if($db->num_rows($q) == 0) { print "Sorry, we could not find a user with that ID, check your source."; } if($ir['DailyVote'] == 'False') { $db->query("UPDATE `users` SET DailyVote = 'True' WHERE `userid` == &ir"); $db->query("UPDATE `users` SET upvotes=upvotes+1 WHERE `userid` == $r"); print "You have up voted the player!"; } else { print "You may only vote once per day."; } $h->endpage(); ?> downvote.php <?php include "globals.php"; $_GET['u'] = abs((int) $_GET['u']); if(!$_GET['u']) { print "Invalid use of file"; } else { $_GET['u'] = mysql_real_escape_string($_GET['u'], $link) $q=$db->query("SELECT u.*,us.*,c.*,h.*,g.*,f.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN cities c ON u.location=c.cityid LEFT JOIN houses h ON u.maxwill=h.hWILL LEFT JOIN gangs g ON g.gangID=u.gang LEFT JOIN fedjail f ON f.fed_userid=u.userid WHERE u.userid={$_GET['u']}"); if($db->num_rows($q) == 0) { print "Sorry, we could not find a user with that ID, check your source."; } if($ir['DailyVote'] == 'False') { $db->query("UPDATE `users` SET DailyVote = 'True' WHERE `userid` == &ir"); $db->query("UPDATE `users` SET downvotes=downvotes+1 WHERE `userid` == $r"); print "You have up voted the player!"; } else { print "You may only vote once per day."; } $h->endpage(); ?> Add this into cron_day.php UPDATE users SET DailyVote = 'False' Sure it could use some formatting improvements, maybe add an image or colours to show up and down votes, but from what I can tell this is the sort of thing you're looking for. :) Edited August 6, 2013 by SolarBacon Fixed typo. Quote
sniko Posted August 6, 2013 Posted August 6, 2013 I threw this together in literally 5 minutes, you should read through the .php files you can learn a lot... Run this in PhpMyAdmin INSERT INTO users `DailyVote` enum('True,'False') NOT NULL default 'False', `upvotes` int(11) NOT NULL default '0', `downvotes` int(11) NOT NULL default '0' Put this in Viewuser.php print "<tr> <td>Votes: <br> Up: {$r['upvotes']}'> <br>Down: {$r['downvotes']}'</td>" print "<tr> <td><a href='upvote.php?u={$r['userid']}'>Give a up vote!</a></td>" print "<tr> <td><a href='downvote.php?u={$r['userid']}'>Give a down vote!</a></td>" upvote.php <?php include "globals.php"; $_GET['u'] = abs((int) $_GET['u']); if(!$_GET['u']) { print "Invalid use of file"; } else { $q=$db->query("SELECT u.*,us.*,c.*,h.*,g.*,f.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN cities c ON u.location=c.cityid LEFT JOIN houses h ON u.maxwill=h.hWILL LEFT JOIN gangs g ON g.gangID=u.gang LEFT JOIN fedjail f ON f.fed_userid=u.userid WHERE u.userid={$_GET['u']}"); if($db->num_rows($q) == 0) { print "Sorry, we could not find a user with that ID, check your source."; } if($ir['DailyVote'] == False) { $db->query("UPDATE `users` SET DailyVote = 'True' WHERE `userid` == &ir"); $db->query("UPDATE `users` SET upvotes=upvotes+1 WHERE `userid` == $r"); print "You have up voted the player!"; } else { print "You may only vote once per day."; } $h->endpage(); ?> downvote.php <?php include "globals.php"; $_GET['u'] = abs((int) $_GET['u']); if(!$_GET['u']) { print "Invalid use of file"; } else { $q=$db->query("SELECT u.*,us.*,c.*,h.*,g.*,f.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN cities c ON u.location=c.cityid LEFT JOIN houses h ON u.maxwill=h.hWILL LEFT JOIN gangs g ON g.gangID=u.gang LEFT JOIN fedjail f ON f.fed_userid=u.userid WHERE u.userid={$_GET['u']}"); if($db->num_rows($q) == 0) { print "Sorry, we could not find a user with that ID, check your source."; } if($ir['DailyVote'] == False) { $db->query("UPDATE `users` SET DailyVote = 'True' WHERE `userid` == &ir"); $db->query("UPDATE `users` SET downvotes=downvotes+1 WHERE `userid` == $r"); print "You have up voted the player!"; } else { print "You may only vote once per day."; } $h->endpage(); ?> Add this into cron_day.php UPDATE users SET DailyVote = 'False' Sure it could use some formatting improvements, maybe add an image or colours to show up and down votes, but from what I can tell this is the sort of thing you're looking for. :) Did you actually test this? Because it will fail. (It could be the forum software messing the script up, can you create a mirror?) Quote
rockwood Posted August 6, 2013 Posted August 6, 2013 (edited) <?php include "globals.php"; $_GET['u'] = abs((int) $_GET['u']); if(!$_GET['u']) { print "Invalid use of file"; } else { // suggestion :- you can remove userstats ,cities, fed and gang from the query bcz you are not using em $_GET['u'] = mysql_real_escape_string($_GET['u'], $link) $q=$db->query("SELECT u.*,us.*,c.*,h.*,g.*,f.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN cities c ON u.location=c.cityid LEFT JOIN houses h ON u.maxwill=h.hWILL LEFT JOIN gangs g ON g.gangID=u.gang LEFT JOIN fedjail f ON f.fed_userid=u.userid WHERE u.userid={$_GET['u']}"); if($db->num_rows($q) == 0) { print "Sorry, we could not find a user with that ID, check your source."; } else { if($ir['DailyVote'] == False) { $r = mysql_fetch_array($q); $db->query("UPDATE `users` SET DailyVote = 'True' WHERE `userid` = &ir['userid']"); $db->query("UPDATE `users` SET upvotes=upvotes+1 WHERE `userid` = &r['userid']"); print "You have up voted the player!"; } else { print "You may only vote once per day."; } } } $h->endpage(); ?> hope it will help you Edited August 6, 2013 by rockwood writing error Quote
SolarBacon Posted August 6, 2013 Posted August 6, 2013 (edited) Yeah I know the things could be removed, but thanks for the suggestion :) Also, my SQL was terrible, sorry about that. Should be fixed now. :) Edit: Rockwood is the $_GET['u'] = mysql_real_escape_string($_GET['u'], $link) necessary? Edited August 6, 2013 by SolarBacon Quote
rockwood Posted August 6, 2013 Posted August 6, 2013 more better is possible by payment lol - - - Updated - - - Yeah I know the things could be removed, but thanks for the suggestion :) Also, my SQL was terrible, sorry about that. Should be fixed now. :) Edit: Rockwood is the $_GET['u'] = mysql_real_escape_string($_GET['u'], $link) necessary? yes my friend Escapes special characters in the unescaped_string , taking into account the current character set of the connection so that it is safe to place it in a mysql_query(). If binary data is to be inserted, this function must be used. Quote
SolarBacon Posted August 6, 2013 Posted August 6, 2013 more better is possible by payment lol - - - Updated - - - yes my friend Ahh, it's to prevent SQL injections right? :) I'll add it into my original post, I'm not great with SQL. In fact this is the first time I've attempted any sort of McCodes modification; haven't even used it for a good few years. :p Quote
rockwood Posted August 6, 2013 Posted August 6, 2013 hint:- bcz you are interacting $_GET directly with query Quote
KyleMassacre Posted August 6, 2013 Posted August 6, 2013 (edited) I threw this together in literally 5 minutes, you should read through the .php files you can learn a lot... Run this in PhpMyAdmin ALTER TABLE `users` Add `DailyVote` varchar(255) NOT NULL default 'False', Add `upvotes` int(11) NOT NULL default '0', Add `downvotes` int(11) NOT NULL default '0'; Put this in Viewuser.php print "<tr> <td>Votes: <br> Up: {$r['upvotes']}'> <br>Down: {$r['downvotes']}'</td>" print "<tr> <td><a href='upvote.php?u={$r['userid']}'>Give a up vote!</a></td>" print "<tr> <td><a href='downvote.php?u={$r['userid']}'>Give a down vote!</a></td>" upvote.php <?php include "globals.php"; $_GET['u'] = abs((int) $_GET['u']); if(!$_GET['u']) { print "Invalid use of file"; } else { $_GET['u'] = mysql_real_escape_string($_GET['u'], $link) $q=$db->query("SELECT u.*,us.*,c.*,h.*,g.*,f.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN cities c ON u.location=c.cityid LEFT JOIN houses h ON u.maxwill=h.hWILL LEFT JOIN gangs g ON g.gangID=u.gang LEFT JOIN fedjail f ON f.fed_userid=u.userid WHERE u.userid={$_GET['u']}"); if($db->num_rows($q) == 0) { print "Sorry, we could not find a user with that ID, check your source."; } if($ir['DailyVote'] == 'False') { $db->query("UPDATE `users` SET DailyVote = 'True' WHERE `userid` == &ir"); $db->query("UPDATE `users` SET upvotes=upvotes+1 WHERE `userid` == $r"); print "You have up voted the player!"; } else { print "You may only vote once per day."; } $h->endpage(); ?> downvote.php <?php include "globals.php"; $_GET['u'] = abs((int) $_GET['u']); if(!$_GET['u']) { print "Invalid use of file"; } else { $_GET['u'] = mysql_real_escape_string($_GET['u'], $link) $q=$db->query("SELECT u.*,us.*,c.*,h.*,g.*,f.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN cities c ON u.location=c.cityid LEFT JOIN houses h ON u.maxwill=h.hWILL LEFT JOIN gangs g ON g.gangID=u.gang LEFT JOIN fedjail f ON f.fed_userid=u.userid WHERE u.userid={$_GET['u']}"); if($db->num_rows($q) == 0) { print "Sorry, we could not find a user with that ID, check your source."; } if($ir['DailyVote'] == 'False') { $db->query("UPDATE `users` SET DailyVote = 'True' WHERE `userid` == &ir"); $db->query("UPDATE `users` SET downvotes=downvotes+1 WHERE `userid` == $r"); print "You have up voted the player!"; } else { print "You may only vote once per day."; } $h->endpage(); ?> Add this into cron_day.php UPDATE users SET DailyVote = 'False' Sure it could use some formatting improvements, maybe add an image or colours to show up and down votes, but from what I can tell this is the sort of thing you're looking for. :) Yeah we can tell it took only 5 minutes. Not only can It use formatting but also some optimization. Feel free to download this one, its only like 1 file, doesn't work off a cron, comes with a small visual, and sends an event. I would post it here but I'm on my phone so its some drama **edit** http://forums.mccodemods.com/files/file/9-player-rating/ forgot to add the link Edited August 6, 2013 by KyleMassacre Quote
SRB Posted August 6, 2013 Posted August 6, 2013 I'll write one and add it within a couple hours. The ones here... well, LOL! Quote
sniko Posted August 6, 2013 Posted August 6, 2013 I'll write one and add it within a couple hours. The ones here... well, LOL! I look forward to seeing this creation, Guest ;) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.