DELETE WHAT EVER YOU HAD FROM THE OLD ADDON FOR MEMBER OF THE MONTH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
DONT COME CRYING IF DONT WORK CAUSE YOU USING PARTS OF BOTH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
i take no credit for this mod, its from http://www.torrentt...er-of-the-month
and i just modified it to be useable in 2.08 and fixed alot of querys within querys.
1st database
DROP TABLE IF EXISTS `motm`;
CREATE TABLE IF NOT EXISTS `motm` (
`id` varchar(10) NOT NULL,
`points` decimal(10,1) NOT NULL DEFAULT '0.0',
`month` tinyint(2) NOT NULL,
`year` tinyint(4) NOT NULL,
`last_winner` varchar(10) NOT NULL,
`last_winner_points` varchar(10) NOT NULL,
`win_month` tinyint(2) NOT NULL,
`credit` enum('yes','no') NOT NULL DEFAULT 'no',
UNIQUE KEY `id_month_year` (`id`,`month`,`year`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
if you have my old motd db info from before 02/01/2013
then
ALTER TABLE `motm` ADD `credit` enum('yes','no') NOT NULL default 'no';
in config file add
//====motm
$site_config["maxmotm"] = 4; //max class for motm current set to uploader
New Cleanup Code 02/01/2013
in cleanup add before
//OPTIMIZE TABLES
[size=18px]UPDATED:::[/size]
to make it easier to extend to other things I have made the adding part for the motm an function
in backend/functions.php before the very last
?>
add
function motmadd($id,$v,$class,$maxmotm) {
if ($class <= $maxmotm) {
SQL_Query_exec("INSERT INTO motm (id, points, month, year) VALUES (" . sqlesc($id) . ", " . sqlesc($v) . ", " . sqlesc(date("m")) . ", " . sqlesc(date("y")) . ") ON DUPLICATE key UPDATE points = points+" . $v);
} //$class <= $maxmotm
}
in index where u want it to show
// Display Code
begin_frame("Member of the Month");
echo '<table border="0" cellspacing="0" cellpadding="0" class="forumline" align="left" width=400><tr><td>';
echo "<div align='left'><b><font color=red>Last Months Winner Was</font></b> <br /></div>";
$lastmotmget = SQL_Query_exec("SELECT motm.id, motm.last_winner_points, users.username, users.class FROM motm LEFT JOIN users ON motm.id = users.id WHERE last_winner ='1' && year = " . date("y"));
if (mysql_num_rows($lastmotmget) > 0) {
$lastmotmgot = mysql_fetch_array($lastmotmget);
$lastmotm = $lastmotmgot[0];
$usrwp = $lastmotmgot['last_winner_points'];
// $username_motm = class_user($lastmotmgot['username']); // <-- Use this if you have class_user function
// $username_motm = "<font color='" . get_class_color($lastmotmgot['class']) . "'>" . $lastmotmgot[username] . "</font>"; // Use this if have get_class_color function
$username_motm = $lastmotmgot['username']; // use this if totally stock:(
echo "<div align='left'><a href=account-details.php?id=" . $lastmotmgot[id] . ">" . $username_motm . "</a> with <font color=yellow>" . $usrwp . "</font> points.<br />and won 300 Seed points.<br /> <br /></div>"; // edit this line to reflect your bonus
} //mysql_num_rows($res) > 0
else {
echo "<div align='left'><b><font color='DarkGoldenRod'>There was no Last Months Winner</font></b> <br /></div>";
}
//////////////////////////////////
///// Member of the Month Hack by Biglad //////
/////// Show Current Top 5 ///////
echo "<b><font color=red>Top 5 for ";
echo date(F);
echo "<br /></b></font>";
$sql32 = "SELECT motm.id, motm.points, users.username, users.class FROM motm LEFT JOIN users ON motm.id = users.id WHERE points > '0' && month = " . date("m") . " && year = " . date("y") . " ORDER BY points DESC LIMIT 5";
$mysql_result_motm = SQL_Query_exec($sql32);
if (mysql_num_rows($mysql_result_motm) > 0) {
echo '<table class="ftable" border="0" cellspacing="0" cellpadding="0">';
while ($row_motm = mysql_fetch_array($mysql_result_motm)) {
$id_motm = $row_motm['id'];
$pos = $row_motm["points"];
$usrname = $row_motm['username'];
// $username_motm = class_user($usrname); // <-- Use this if you have class_user function
// $username_motm = "<font color='" . get_class_color($row_motm['class']) . "'>" . $lastmotmgot[username] . "</font>"; // Use this if have get_class_color function
$username_motm = $usrname; // use this if totally stock:(
echo "<div align='left'><tr>";
echo "<td><a href=account-details.php?id=$id_motm>" . $username_motm . "</a></td><td width='70'> - Points <font color='DarkMagenta'>" . $pos . "</font></td>";
echo "</tr></div>";
//echo "<strong><div align='left'><a href=account-details.php?id=$id_motm>".$usrname."</a> - POINTS ".$pos."</strong><br />";
} //$row_motm = mysql_fetch_array($mysql_result_motm)
echo "</table>";
} //mysql_num_rows($mysql_result_motm) > 0
echo '</td></tr></table>';
end_frame();
in torrents-details
find
//take comment add
if ($_GET["takecomment"] == 'yes'){
loggedinonly();
$commentbody = $_POST['body'];
if (!$commentbody)
show_error_msg("Error","You did not enter anything!",1);
mysql_query("UPDATE torrents SET comments = comments + 1 WHERE id = $id") or die(mysql_error());
add after
$motm_value = 3;
motmadd($CURUSER["id"],$motm_value,$CURUSER['class'],$site_config['maxmotm']);
still in torrent details
find
//take rating
if ($_GET["takerating"] == 'yes'){
$rating = (int)$_POST['rating'];
if ($rating <= 0 || $rating > 5)
show_error_msg("Rating Error", "Invalid rating",1);
add after
$motm_value = 1;
motmadd($CURUSER["id"],$motm_value,$CURUSER['class'],$site_config['maxmotm']);
open shoutbox.php
find
$query = "INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, '".$CURUSER['username']."', ".$_POST['message'].", '".get_date_time()."', '".$CURUSER['id']."')";
SQL_Query_exec($query);
after add
$motm_value = 1;
motmadd($CURUSER["id"],$motm_value,$CURUSER['class'],$site_config['maxmotm']);
comments.php
find
SQL_Query_exec("INSERT INTO comments (user, ".$type.", added, text) VALUES (".$CURUSER["id"].", ".$id.", '" .get_date_time(). "', " . sqlesc($body).")");
after add
$motm_value = 1;
motmadd($CURUSER["id"],$motm_value,$CURUSER['class'],$site_config['maxmotm']);stock 2.08 forums.php
find
SQL_Query_exec("INSERT INTO forum_topics (userid, forumid, subject) VALUES($userid, $forumid, $subject)");
$topicid = mysql_insert_id() or showerror(T_("FORUM_ERROR"),"No topic ID returned");
after add
$motm_value = 2;
motmadd($userid,$motm_value,$CURUSER['class'],$site_config['maxmotm']);
then find
SQL_Query_exec("INSERT INTO forum_posts (topicid, userid, added, body) VALUES($topicid, $userid, $added, $body)");
$postid = mysql_insert_id() or showerror(T_("FORUM_ERROR"),"Post id n/a");
after add
$motm_value = 1;
motmadd($userid,$motm_value,$CURUSER['class'],$site_config['maxmotm']);
your members get member of the month points for talking in the shoutbox , rating a torrent , commenting on a torrent, making a new forum topic (if you have stock forums), making a new forum post (again if you have stock forums)
im sure it can be implemented into other things aswell
have fun
I guess tech you could take the display part and make it into an block.. But I dont like blocks with too many querys in them.. slows down loading the whole site:(
ps: I cant find the orginal thanks.php my guess its no longer in 2.08 or was an addon, its not too hard to extend this to other pages, just post what page and I will try and help you if it have it aka its in 2.08 stock LOL..
ps: I dont know if the monthly thing works LOL!! I did not figure you wanted me waiting around to find out LOL!! before releasing it.
Edit 12/25/2012: I have added an block if people wants it, it uses an cache and should help on load issues with the querys.
FIXED: [url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6422"]motm_block.php[/url]
If you want to use the block i have attached motm_block.php just upload it to blocks then add and activate it in normal admincp.php part.
ajax-shout.. in thory this might work.. dont really know ... rofl or care about versions lower then 2.08.. this is an 2.08 addon!!!!
in sendshout.php
replace
# adds new data to the database
function addData($name,$text,$uid) {
require_once("backend/functions.php"); # getting table prefix
$now = get_date_time();
$sql = "INSERT INTO ajshoutbox (date,name,text,uid) VALUES ('".$now."','".$name."','".$text."','".$uid."')";
$conn = getDBConnection();
$results = mysql_query($sql, $conn);
if (!$results || empty($results)) {
# echo 'There was an error creating the entry';
end;
}
}
with
# adds new data to the database
function addData($name,$text,$uid) {
require_once("backend/functions.php"); # getting table prefix
global $CURUSER,$site_config;
$now = get_date_time();
$sql = "INSERT INTO ajshoutbox (date,name,text,uid) VALUES ('".$now."','".$name."','".$text."','".$uid."')";
$conn = getDBConnection();
$results = mysql_query($sql, $conn);
if (!$results || empty($results)) {
# echo 'There was an error creating the entry';
end;
}
$motm_value = 1;
motmadd$uid,$motm_value,$CURUSER['class'],$site_config['maxmotm']);
}

This part is only if your servers os or something dont support the DUPLICATE key part.. Its kind of lame LOL 3 querys to do the same thing as 1 DUPLICATE key......
This part is for the people that dont have DUPLICATE key option in there os... Its highly untested cause well I have an real os and not winblows or something.....
but in backend/functions.php before the very last
?>
replace
function motmadd($id,$v,$class,$maxmotm) {
if ($class <= $maxmotm) {
SQL_Query_exec("INSERT INTO motm (id, points, month, year) VALUES (" . sqlesc($id) . ", " . sqlesc($v) . ", " . sqlesc(date("m")) . ", " . sqlesc(date("y")) . ") ON DUPLICATE key UPDATE points = points+" . $v);
} //$class <= $maxmotm
}
with
DONT COME CRYING IF DONT WORK CAUSE YOU USING PARTS OF BOTH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
i take no credit for this mod, its from http://www.torrentt...er-of-the-month
and i just modified it to be useable in 2.08 and fixed alot of querys within querys.
1st database
DROP TABLE IF EXISTS `motm`;
CREATE TABLE IF NOT EXISTS `motm` (
`id` varchar(10) NOT NULL,
`points` decimal(10,1) NOT NULL DEFAULT '0.0',
`month` tinyint(2) NOT NULL,
`year` tinyint(4) NOT NULL,
`last_winner` varchar(10) NOT NULL,
`last_winner_points` varchar(10) NOT NULL,
`win_month` tinyint(2) NOT NULL,
`credit` enum('yes','no') NOT NULL DEFAULT 'no',
UNIQUE KEY `id_month_year` (`id`,`month`,`year`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
if you have my old motd db info from before 02/01/2013
then
ALTER TABLE `motm` ADD `credit` enum('yes','no') NOT NULL default 'no';
in config file add
//====motm
$site_config["maxmotm"] = 4; //max class for motm current set to uploader
New Cleanup Code 02/01/2013
in cleanup add before
//OPTIMIZE TABLES
//== Start member of the month
$debug = 0;
$motmdateget = SQL_Query_exec("SELECT win_month,year,credit from motm WHERE last_winner ='1'");
$motmdategot = mysql_fetch_array($motmdateget);
$motmdate = (int) $motmdategot[0];
$motmyear = $motmdategot[1];
$mdate = date("m");
$myear = date("y");
if ($motmdate == 12 && $mdate > 1)
$motmdate = 1;
if ($motmdate == 0 || $motmdate == '')
$motmdate = (date("m") - 1);
$mdate1 = (date("m") - 1);
if ($motmdate < $mdate) {
$motmdateget1 = SQL_Query_exec("SELECT win_month,year,credit from motm WHERE win_month = '$mdate'");
$motmdategot1 = mysql_fetch_array($motmdateget1);
$motcredit = $motmdategot1[2];
$sql32 = "SELECT id, points FROM motm WHERE points > '0' && year =" . $myear . " && month =" . $motmdate . " ORDER BY points DESC LIMIT 1";
$mysql_result_motm = SQL_Query_exec($sql32);
while ($row_motm = mysql_fetch_array($mysql_result_motm)) {
$nextmonth = (date(m) + 1);
$id_motm = $row_motm['id'];
$pos = $row_motm["points"];
$motmdateget3 = SQL_Query_exec("SELECT win_month from motm WHERE last_winner ='1'");
$motmdategot3 = mysql_fetch_array($motmdateget3);
$motmdate3 = $motmdategot3[0];
if ($motmdate3 == 12 && $mdate > 1)
$motmdate3 = 1;
if ($motmdate3 == 0 || $motmdate3 == '')
$motmdate3 = (date("m") - 1);
if ($motcredit != 'yes') {
SQL_Query_exec("UPDATE motm SET last_winner = '0' WHERE last_winner = '1'");
SQL_Query_exec("UPDATE motm SET win_month = '$mdate', last_winner_points = '$pos', last_winner = '1', credit='yes' WHERE id = '$id_motm' && month = $motmdate && year = " . $myear . "");
SQL_Query_exec("UPDATE users SET seedbonus = seedbonus+300 WHERE id = '$id_motm'");
// SQL_Query_exec("UPDATE motm SET points = '0' where month!='$mdate'");
SQL_Query_exec("UPDATE motm SET last_winner_points = '0' WHERE last_winner != '1'");
} //$motcredit != 'yes'
} //$row_motm = mysql_fetch_array($mysql_result_motm)
} //$motmdate < $mdate
//== End member of the month[size=18px]UPDATED:::[/size]
to make it easier to extend to other things I have made the adding part for the motm an function
in backend/functions.php before the very last
?>
add
function motmadd($id,$v,$class,$maxmotm) {
if ($class <= $maxmotm) {
SQL_Query_exec("INSERT INTO motm (id, points, month, year) VALUES (" . sqlesc($id) . ", " . sqlesc($v) . ", " . sqlesc(date("m")) . ", " . sqlesc(date("y")) . ") ON DUPLICATE key UPDATE points = points+" . $v);
} //$class <= $maxmotm
}
in index where u want it to show
// Display Code
begin_frame("Member of the Month");
echo '<table border="0" cellspacing="0" cellpadding="0" class="forumline" align="left" width=400><tr><td>';
echo "<div align='left'><b><font color=red>Last Months Winner Was</font></b> <br /></div>";
$lastmotmget = SQL_Query_exec("SELECT motm.id, motm.last_winner_points, users.username, users.class FROM motm LEFT JOIN users ON motm.id = users.id WHERE last_winner ='1' && year = " . date("y"));
if (mysql_num_rows($lastmotmget) > 0) {
$lastmotmgot = mysql_fetch_array($lastmotmget);
$lastmotm = $lastmotmgot[0];
$usrwp = $lastmotmgot['last_winner_points'];
// $username_motm = class_user($lastmotmgot['username']); // <-- Use this if you have class_user function
// $username_motm = "<font color='" . get_class_color($lastmotmgot['class']) . "'>" . $lastmotmgot[username] . "</font>"; // Use this if have get_class_color function
$username_motm = $lastmotmgot['username']; // use this if totally stock:(
echo "<div align='left'><a href=account-details.php?id=" . $lastmotmgot[id] . ">" . $username_motm . "</a> with <font color=yellow>" . $usrwp . "</font> points.<br />and won 300 Seed points.<br /> <br /></div>"; // edit this line to reflect your bonus
} //mysql_num_rows($res) > 0
else {
echo "<div align='left'><b><font color='DarkGoldenRod'>There was no Last Months Winner</font></b> <br /></div>";
}
//////////////////////////////////
///// Member of the Month Hack by Biglad //////
/////// Show Current Top 5 ///////
echo "<b><font color=red>Top 5 for ";
echo date(F);
echo "<br /></b></font>";
$sql32 = "SELECT motm.id, motm.points, users.username, users.class FROM motm LEFT JOIN users ON motm.id = users.id WHERE points > '0' && month = " . date("m") . " && year = " . date("y") . " ORDER BY points DESC LIMIT 5";
$mysql_result_motm = SQL_Query_exec($sql32);
if (mysql_num_rows($mysql_result_motm) > 0) {
echo '<table class="ftable" border="0" cellspacing="0" cellpadding="0">';
while ($row_motm = mysql_fetch_array($mysql_result_motm)) {
$id_motm = $row_motm['id'];
$pos = $row_motm["points"];
$usrname = $row_motm['username'];
// $username_motm = class_user($usrname); // <-- Use this if you have class_user function
// $username_motm = "<font color='" . get_class_color($row_motm['class']) . "'>" . $lastmotmgot[username] . "</font>"; // Use this if have get_class_color function
$username_motm = $usrname; // use this if totally stock:(
echo "<div align='left'><tr>";
echo "<td><a href=account-details.php?id=$id_motm>" . $username_motm . "</a></td><td width='70'> - Points <font color='DarkMagenta'>" . $pos . "</font></td>";
echo "</tr></div>";
//echo "<strong><div align='left'><a href=account-details.php?id=$id_motm>".$usrname."</a> - POINTS ".$pos."</strong><br />";
} //$row_motm = mysql_fetch_array($mysql_result_motm)
echo "</table>";
} //mysql_num_rows($mysql_result_motm) > 0
echo '</td></tr></table>';
end_frame();
in torrents-details
find
//take comment add
if ($_GET["takecomment"] == 'yes'){
loggedinonly();
$commentbody = $_POST['body'];
if (!$commentbody)
show_error_msg("Error","You did not enter anything!",1);
mysql_query("UPDATE torrents SET comments = comments + 1 WHERE id = $id") or die(mysql_error());
add after
$motm_value = 3;
motmadd($CURUSER["id"],$motm_value,$CURUSER['class'],$site_config['maxmotm']);
still in torrent details
find
//take rating
if ($_GET["takerating"] == 'yes'){
$rating = (int)$_POST['rating'];
if ($rating <= 0 || $rating > 5)
show_error_msg("Rating Error", "Invalid rating",1);
add after
$motm_value = 1;
motmadd($CURUSER["id"],$motm_value,$CURUSER['class'],$site_config['maxmotm']);
open shoutbox.php
find
$query = "INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, '".$CURUSER['username']."', ".$_POST['message'].", '".get_date_time()."', '".$CURUSER['id']."')";
SQL_Query_exec($query);
after add
$motm_value = 1;
motmadd($CURUSER["id"],$motm_value,$CURUSER['class'],$site_config['maxmotm']);
comments.php
find
SQL_Query_exec("INSERT INTO comments (user, ".$type.", added, text) VALUES (".$CURUSER["id"].", ".$id.", '" .get_date_time(). "', " . sqlesc($body).")");
after add
$motm_value = 1;
motmadd($CURUSER["id"],$motm_value,$CURUSER['class'],$site_config['maxmotm']);stock 2.08 forums.php
find
SQL_Query_exec("INSERT INTO forum_topics (userid, forumid, subject) VALUES($userid, $forumid, $subject)");
$topicid = mysql_insert_id() or showerror(T_("FORUM_ERROR"),"No topic ID returned");
after add
$motm_value = 2;
motmadd($userid,$motm_value,$CURUSER['class'],$site_config['maxmotm']);
then find
SQL_Query_exec("INSERT INTO forum_posts (topicid, userid, added, body) VALUES($topicid, $userid, $added, $body)");
$postid = mysql_insert_id() or showerror(T_("FORUM_ERROR"),"Post id n/a");
after add
$motm_value = 1;
motmadd($userid,$motm_value,$CURUSER['class'],$site_config['maxmotm']);
your members get member of the month points for talking in the shoutbox , rating a torrent , commenting on a torrent, making a new forum topic (if you have stock forums), making a new forum post (again if you have stock forums)
im sure it can be implemented into other things aswell
have fun
I guess tech you could take the display part and make it into an block.. But I dont like blocks with too many querys in them.. slows down loading the whole site:(
ps: I cant find the orginal thanks.php my guess its no longer in 2.08 or was an addon, its not too hard to extend this to other pages, just post what page and I will try and help you if it have it aka its in 2.08 stock LOL..
ps: I dont know if the monthly thing works LOL!! I did not figure you wanted me waiting around to find out LOL!! before releasing it.
Edit 12/25/2012: I have added an block if people wants it, it uses an cache and should help on load issues with the querys.
FIXED: [url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6422"]motm_block.php[/url]
If you want to use the block i have attached motm_block.php just upload it to blocks then add and activate it in normal admincp.php part.
ajax-shout.. in thory this might work.. dont really know ... rofl or care about versions lower then 2.08.. this is an 2.08 addon!!!!
in sendshout.php
replace
# adds new data to the database
function addData($name,$text,$uid) {
require_once("backend/functions.php"); # getting table prefix
$now = get_date_time();
$sql = "INSERT INTO ajshoutbox (date,name,text,uid) VALUES ('".$now."','".$name."','".$text."','".$uid."')";
$conn = getDBConnection();
$results = mysql_query($sql, $conn);
if (!$results || empty($results)) {
# echo 'There was an error creating the entry';
end;
}
}
with
# adds new data to the database
function addData($name,$text,$uid) {
require_once("backend/functions.php"); # getting table prefix
global $CURUSER,$site_config;
$now = get_date_time();
$sql = "INSERT INTO ajshoutbox (date,name,text,uid) VALUES ('".$now."','".$name."','".$text."','".$uid."')";
$conn = getDBConnection();
$results = mysql_query($sql, $conn);
if (!$results || empty($results)) {
# echo 'There was an error creating the entry';
end;
}
$motm_value = 1;
motmadd$uid,$motm_value,$CURUSER['class'],$site_config['maxmotm']);
}

This part is only if your servers os or something dont support the DUPLICATE key part.. Its kind of lame LOL 3 querys to do the same thing as 1 DUPLICATE key......
This part is for the people that dont have DUPLICATE key option in there os... Its highly untested cause well I have an real os and not winblows or something.....
but in backend/functions.php before the very last
?>
replace
function motmadd($id,$v,$class,$maxmotm) {
if ($class <= $maxmotm) {
SQL_Query_exec("INSERT INTO motm (id, points, month, year) VALUES (" . sqlesc($id) . ", " . sqlesc($v) . ", " . sqlesc(date("m")) . ", " . sqlesc(date("y")) . ") ON DUPLICATE key UPDATE points = points+" . $v);
} //$class <= $maxmotm
}
with
function motmadd($id,$v,$class,$maxmotm) {
if ($class < $maxmotm)
{
$query = mysql_fetch_row(SQL_Query_exec("SELECT COUNT(*) FROM `motm` WHERE `id` = '{$id}' AND month = ".sqlesc(date("m"))." AND year = ".sqlesc(date("y"))));
if ($query[0] == 0)
{
SQL_Query_exec("INSERT INTO `motm` (`id`, `month`, `year`, `points') VALUES ('" . $id . "', ".sqlesc(date("m")).", ".sqlesc(date("y")).", ".sqlesc($v).")");
} else {
SQL_Query_exec("UPDATE `motm` SET `points` = `points` + 1 WHERE `id` = '" . $CURUSER["id"] . "'' AND month = ".sqlesc(date("m"))." AND year = ".sqlesc(date("m")));
}
}
}


