Jump to content
MakeWebGames

Rating Mod Needed


Jigsaw

Recommended Posts

  • 1 month later...

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 by SolarBacon
Fixed typo.
Link to comment
Share on other sites

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?)

Link to comment
Share on other sites

<?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 by rockwood
writing error
Link to comment
Share on other sites

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 by SolarBacon
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by KyleMassacre
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...