09 Ezeros Freeleech Contribution System

Started by Mindless, July 21, 2012, 07:54:02 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Kustff

Is there only events.php and only this freleech mod in somehwere?

denede

#3
thx for the mod :)

Mindless

Ok so the contribution wouldnt allow you to donate just one point and that was no use so after spending some time altering the checks and thinking i found a working solution - Only requires a few changes and wont affect your bonus system at all - First add this new sql

Code (sql) Select
ALTER TABLE bonus ADD `minpoints` int(1) NOT NULL;

Once you add that sql its very important that you add your minpoints value for every bonus option you have that uses points for exchange because to allow the minpoint of 1 i had to change the checking around a little. So if buy 1 gig is 275 points then minpoints for 1 gig will be 275 so do that for all your options except Freelech contribution, Doubleupload contribution and Halfdownload contribution because they will all be 1 :)

@File mybonus.php find :

Code (php) Select
if($bonus < $points)
stderr("Sorry", "you do not have enough Karma points!");


Change to

Code (php) Select
if($bonus < $minpoints)
stderr("Sorry", "you do not have enough Karma points!");


Find :

Code (php) Select
case ($gets['id'] == 11):
  $HTMLOUT .="<tr><td align='left' class='".$class."'><form action='{$TBDEV['baseurl']}/mybonus.php?exchange=1' method='post'><input type='hidden' name='option' value='".$gets['id']."' /> <input type='hidden' name='art' value='".$gets['art']."' /><h1><font color=\"#CECFF3\">".$gets["bonusname"]."</font></h1>".$gets['description']."<br /><h4>Top 10 Contributors </h4> <ol>".$top_donators." </ol> <br />Enter the <b>amount to contribute</b><input type='text' name='donate' size='10' maxlength='10' /></td><td align='center' class='".$class."'>" .$gets['points'] ." <br /></td>";
break;
case ($gets['id'] == 12):
  $HTMLOUT .="<tr><td align='left' class='".$class."'><form action='{$TBDEV['baseurl']}/mybonus.php?exchange=1' method='post'><input type='hidden' name='option' value='".$gets['id']."' /> <input type='hidden' name='art' value='".$gets['art']."' /><h1><font color=\"#CECFF3\">".$gets["bonusname"]."</font></h1>".$gets['description']."<br /><h4>Top 10 Contributors </h4> <ol>".$top_donators2." </ol> <br />Enter the <b>amount to contribute</b><input type='text' name='donate' size='10' maxlength='10' /></td><td align='center' class='".$class."'>" .$gets['points'] ." <br /></td>";
break;
case ($gets['id'] == 13):
  $HTMLOUT .="<tr><td align='left' class='".$class."'><form action='{$TBDEV['baseurl']}/mybonus.php?exchange=1' method='post'><input type='hidden' name='option' value='".$gets['id']."' /> <input type='hidden' name='art' value='".$gets['art']."' /><h1><font color=\"#CECFF3\">".$gets["bonusname"]."</font></h1>".$gets['description']."<br /><h4>Top 10 Contributors </h4> <ol>".$top_donators3." </ol> <br />Enter the <b>amount to contribute</b><input type='text' name='donate' size='10' maxlength='10' /></td><td align='center' class='".$class."'>" .$gets['points'] ." <br /></td>";
break;


Change them to

Code (php) Select
case ($gets['id'] == 11):
  $HTMLOUT .="<tr><td align='left' class='".$class."'><form action='{$TBDEV['baseurl']}/mybonus.php?exchange=1' method='post'><input type='hidden' name='option' value='".$gets['id']."' /> <input type='hidden' name='art' value='".$gets['art']."' /><h1><font color=\"#CECFF3\">".$gets["bonusname"]."</font></h1>".$gets['description']."<br /><h4>Top 10 Contributors </h4> <ol>".$top_donators." </ol> <br />Enter the <b>amount to contribute</b><input type='text' name='donate' size='10' maxlength='10' /></td><td align='center' class='".$class."'>" .$gets['minpoints'] ." <br /></td>";
break;
case ($gets['id'] == 12):
  $HTMLOUT .="<tr><td align='left' class='".$class."'><form action='{$TBDEV['baseurl']}/mybonus.php?exchange=1' method='post'><input type='hidden' name='option' value='".$gets['id']."' /> <input type='hidden' name='art' value='".$gets['art']."' /><h1><font color=\"#CECFF3\">".$gets["bonusname"]."</font></h1>".$gets['description']."<br /><h4>Top 10 Contributors </h4> <ol>".$top_donators2." </ol> <br />Enter the <b>amount to contribute</b><input type='text' name='donate' size='10' maxlength='10' /></td><td align='center' class='".$class."'>" .$gets['minpoints'] ." <br /></td>";
break;
case ($gets['id'] == 13):
  $HTMLOUT .="<tr><td align='left' class='".$class."'><form action='{$TBDEV['baseurl']}/mybonus.php?exchange=1' method='post'><input type='hidden' name='option' value='".$gets['id']."' /> <input type='hidden' name='art' value='".$gets['art']."' /><h1><font color=\"#CECFF3\">".$gets["bonusname"]."</font></h1>".$gets['description']."<br /><h4>Top 10 Contributors </h4> <ol>".$top_donators3." </ol> <br />Enter the <b>amount to contribute</b><input type='text' name='donate' size='10' maxlength='10' /></td><td align='center' class='".$class."'>" .$gets['minpoints'] ." <br /></td>";
break;


$gets['points'] was changed to $gets['minpoints'] on all three

Next find :

Code (php) Select
if($bonus >= $gets['points']) {

Change that to :

Code (php) Select
if($bonus >= $gets['points'] OR $bonus >= $gets['minpoints']) {

And that should be it - all other options have minpoint values so there safe and i dont see any issue here or any other way i could do it.

Mindless

Credits to Ezero
Heres the full modification to work soley with sir_snugglebunnys mybonus.php 09 version - Remember to back up your script before attempting this :)

Sql

Code (sql) Select
ALTER TABLE bonus ADD `pointspool` decimal(10,1) NOT NULL default '1.0';
ALTER TABLE bonus ADD `enabled` enum('yes','no') NOT NULL default 'yes' COMMENT 'This will determined a switch if the bonus is enabled or not! enabled by default';


Code (sql) Select
INSERT INTO `bonus` VALUES (11, 'FreeLeech', 30000.0, 'The Ultimate exchange if you have over 100000 Points - Make the tracker freeleech for everyone for 3 days: Upload will count but no download.\r\nIf you don''t have enough points you can donate certain amount of your points until it accumulates. Everybody''s karma counts!', 'freeleech', 1.0, 'yes');
INSERT INTO `bonus` VALUES (12, 'Doubleupload', 30000.0, 'The ultimate exchange if you have over 100000 points - Make the tracker double upload for everyone for 3 days: Upload will count double.\r\nIf you don''t have enough points you can donate certain amount of your points until it accumulates. Everybody''s karma counts!', 'doubleup', 1.0, 'yes');
INSERT INTO `bonus` VALUES (13, 'Halfdownload', 30000.0, 'The ultimate exchange if you have over 100000 points - Make the tracker Half Download for everyone for 3 days: Download will count only half.\r\nIf you don''t have enough points you can donate certain amount of your points until it accumulates. Everybody''s karma counts!', 'halfdown', 1.0, 'yes');


Now to insert the actual bonus sql you need to follow on from your last entry, so if you have 10 options already then those ^ above will be 11,12,13 - That will vary for every member so i used X - Y - Z - change them accordinally around your bonus table entrys.

Next the bonus log sql to display the top ten contributors on mybonus.php :

Code (sql) Select
CREATE TABLE `bonuslog` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `donation` decimal(10,1) NOT NULL,
  `type` varchar(44) NOT NULL,
  `added_at` datetime NOT NULL,
  KEY `id` (`id`),
  KEY `added_at` (`added_at`),
  FULLTEXT KEY `type` (`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='log of contributors towards freeleech etc...';


The actual events table :

Code (sql) Select
CREATE TABLE `events` (
  `id` int(11) NOT NULL auto_increment,
  `userid` int(11) NOT NULL,
  `startTime` int(11) NOT NULL,
  `endTime` int(11) NOT NULL,
  `overlayText` text NOT NULL,
  `displayDates` tinyint(1) NOT NULL,
  `freeleechEnabled` tinyint(1) NOT NULL,
  `duploadEnabled` tinyint(1) NOT NULL,
  `hdownEnabled` tinyint(1) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `startTime` (`startTime`,`endTime`),
  FULLTEXT KEY `overlayText` (`overlayText`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


Ok thats the sql over with next the modifications to mybonus.php

At the top of mybonus.php right under this

Code (php) Select
$bonus = htmlspecialchars($CURUSER['seedbonus'], 1);

Add this :

Code (php) Select
/////////freeleech
if (isset($_GET["freeleech_success"]) && $_GET["freeleech_success"]){
$freeleech_success = 0 + $_GET["freeleech_success"];
if($freeleech_success != '1' && $freeleech_success != '2')
stderr("Error", "I smell a rat on freeleech!");
if($freeleech_success == '1'){

if ($_GET["norefund"] != '0') {
$HTMLOUT .="<table width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>Success!</h1></td></tr><tr>".
"<td align='left' class='clearalt6'><img src='{$TBDEV['pic_base_url']}/smilies/karma.gif' alt='good_karma' title='Good Karma' /></td><td align='left' class='clearalt6'><b>Congratulations! </b>
$CURUSER[username] you have set the tracker <b>Free Leech !</b> <img src='{$TBDEV['pic_base_url']}/smilies/w00t.gif' alt='w00t' title='W00t' /><br /><br />Remaining ".htmlspecialchars($_GET['norefund'])." points have been contributed towards the next freeleech period automatically!".
"<br /> click to go back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page.<br /><br />".
"</td></tr></table>";
print stdhead('Karma Bonus') . $HTMLOUT . stdfoot();
} else {
$HTMLOUT .="<table width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>Success!</h1></td></tr><tr>".
"<td align='left' class='clearalt6'><img src='{$TBDEV['pic_base_url']}/smilies/karma.gif' alt='good_karma' title='Good Karma' /></td><td align='left' class='clearalt6'><b>Congratulations! </b>
$CURUSER[username] you have set the tracker <b>Free Leech !</b> <img src='{$TBDEV['pic_base_url']}/smilies/w00t.gif' alt='w00t' title='W00t' /><br />".
"<br /> click to go back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page.<br /><br />".
"</td></tr></table>";
print stdhead('Karma Bonus') . $HTMLOUT . stdfoot();
}

die;
}
if($freeleech_success == '2'){
$HTMLOUT .="<table width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>Success!</h1></td></tr><tr>".
"<td align='left' class='clearalt6'><img src='{$TBDEV['pic_base_url']}/smilies/karma.gif' alt='good_karma' title='Good Karma' /></td><td align='left' class='clearalt6'><b>Congratulations! </b>".
"$CURUSER[username] you have contributed towards making the tracker Free Leech ! <img src='{$TBDEV['pic_base_url']}/smilies/w00t.gif' alt='w00t' title='W00t' /><br />".
"<br /> click to go back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page.<br /><br />".
"</td></tr></table>";
print stdhead('Karma Bonus') . $HTMLOUT . stdfoot();
die;
}
}
////////doubleup
if (isset($_GET["doubleup_success"]) && $_GET["doubleup_success"]){
$doubleup_success = 0 + $_GET["doubleup_success"];
if($doubleup_success != '1' && $doubleup_success != '2')
stderr("Error", "I smell a rat on freeleech!");
if($doubleup_success == '1'){

if ($_GET["norefund"] != '0') {
$HTMLOUT .="<table width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>Success!</h1></td></tr><tr>".
"<td align='left' class='clearalt6'><img src='{$TBDEV['pic_base_url']}/smilies/karma.gif' alt='good_karma' title='Good Karma' /></td><td align='left' class='clearalt6'><b>Congratulations! </b>
$CURUSER[username] you have set the tracker <b>Double Up !</b> <img src='{$TBDEV['pic_base_url']}/smilies/w00t.gif' alt='w00t' title='W00t' /><br /><br />Remaining ".htmlspecialchars($_GET['norefund'])." points have been contributed towards the next Double upload period automatically!".
"<br /> click to go back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page.<br /><br />".
"</td></tr></table>";
print stdhead('Karma Bonus') . $HTMLOUT . stdfoot();
} else {
$HTMLOUT .="<table width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>Success!</h1></td></tr><tr>".
"<td align='left' class='clearalt6'><img src='{$TBDEV['pic_base_url']}/smilies/karma.gif' alt='good_karma' title='Good Karma' /></td><td align='left' class='clearalt6'><b>Congratulations! </b>
$CURUSER[username] you have set the tracker <b>Double Up !</b> <img src={$TBDEV['pic_base_url']}/smilies/w00t.gif alt='w00t' title='W00t' /><br />".
"<b /r> click to go back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page.<br /><br />".
"</td></tr></table>";
print stdhead('Karma Bonus') . $HTMLOUT . stdfoot();
}

die;
}
if($doubleup_success == '2'){
$HTMLOUT .="<table width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>Success!</h1></td></tr><tr>".
"<td align='left' class='clearalt6'><img src='{$TBDEV['pic_base_url']}/smilies/karma.gif' alt='good_karma' title='Good Karma' /></td><td align='left' class='clearalt6'><b>Congratulations! </b>".
"$CURUSER[username] you have contributed towards making the tracker Double Upload ! <img src='{$TBDEV['pic_base_url']}/smilies/w00t.gif' alt='w00t' title='W00t' /><br />".
"<br /> click to go back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page.<br /><br />".
"</td></tr></table>";
print stdhead('Karma Bonus') . $HTMLOUT . stdfoot();
die;
}
}
/////////Halfdownload
if (isset($_GET["halfdown_success"]) && $_GET["halfdown_success"]){
$halfdown_success = 0 + $_GET["halfdown_success"];
if($halfdown_success != '1' && $halfdown_success != '2')
stderr("Error", "I smell a rat on halfdownload!");
if($halfdown_success == '1'){

if ($_GET["norefund"] != '0') {
$HTMLOUT .="<table width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>Success!</h1></td></tr><tr>".
"<td align='left' class='clearalt6'><img src='{$TBDEV['pic_base_url']}/smilies/karma.gif' alt='good_karma' title='Good Karma' /></td><td align='left' class='clearalt6'><b>Congratulations! </b>
$CURUSER[username] you have set the tracker <b>Half Download !</b> <img src='{$TBDEV['pic_base_url']}/smilies/w00t.gif' alt='w00t' title='W00t' /><br /><br />Remaining ".htmlspecialchars($_GET['norefund'])." points have been contributed towards the next Half download period automatically!".
"<br /> click to go back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page.<br /><br />".
"</td></tr></table>";
print stdhead('Karma Bonus') . $HTMLOUT . stdfoot();
} else {
$HTMLOUT .="<table width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>Success!</h1></td></tr><tr>".
"<td align='left' class='clearalt6'><img src='{$TBDEV['pic_base_url']}/smilies/karma.gif' alt='good_karma' title='Good Karma' /></td><td align=left class=clearalt6><b>Congratulations! </b>
$CURUSER[username] you have set the tracker <b>Half Download !</b> <img src='{$TBDEV['pic_base_url']}/smilies/w00t.gif' alt='w00t' title='W00t' /><br />".
"<br /> click to go back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page.<br /><br />".
"</td></tr></table>";
print stdhead('Karma Bonus') . $HTMLOUT . stdfoot();
}

die;
}
if($halfdown_success == '2'){
$HTMLOUT .="<table width='80%'><tr><td class='colhead' align='left' colspan='2'><h1>Success!</h1></td></tr><tr>".
"<td align='left' class='clearalt6'><img src='{$TBDEV['pic_base_url']}/smilies/karma.gif' alt='good_karma' title='Good Karma' /></td><td align='left' class='clearalt6'><b>Congratulations! </b>".
"$CURUSER[username] you have contributed towards making the tracker Half Download ! <img src='{$TBDEV['pic_base_url']}/smilies/w00t.gif' alt='w00t' title='W00t' /><br />".
"<br /> click to go back to your <a class='altlink' href='{$TBDEV['baseurl']}/mybonus.php'>Karma Bonus Point</a> page.<br /><br />".
"</td></tr></table>";
print stdhead('Karma Bonus') . $HTMLOUT . stdfoot();
die;
}
}
//////////


Under this block :

Code (php) Select
case 'traffic':
//=== trade for one upload credit
$up = $upload + $arr_points['menge'];
$bonuscomment = get_date( time(), 'DATE', 1 ) . " - " .$points. " Points for upload bonus.\n " .$bonuscomment;
mysql_query("UPDATE users SET uploaded = $upload + $arr_points[menge], seedbonus = '$seedbonus', bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
header("Refresh: 0; url=$BASEURL/mybonus.php?up_success=1&amt=$points");
die;


Add this :

Code (php) Select
//--- Freeleech
case 'freeleech':
$points2 = 59999;
$pointspool = $arr_points['pointspool'];
$points= htmlspecialchars($points,1);
$donation = 0 + $_POST['donate'];
$seedbonus = ($bonus - $donation);
if($bonus < $donation || $donation <= 0 ||$donation > $points2){
stderr("Error", " <br />Points: ".htmlspecialchars($donation)." <br /> Bonus: ".htmlspecialchars($bonus)." <br /> Donation: ".htmlspecialchars($donation)." <br />Time shall unfold what plighted cunning hides\n\nWho cover faults, at last shame them derides.<br /> Click to go back to your <a class='altlink' href='./mybonus.php'>Karma Bonus Point</a> page.<br />");
die;
}
if(($pointspool+$donation) >= $arr_points["points"] ){
$now = time();
$end = (86400 * 3 + time());
$message = "FreeLeech [ON]";
$sql = "INSERT INTO `events`(`userid`,`overlayText`, `startTime`, `endTime`, `displayDates`, `freeleechEnabled`) VALUES ('$userid', '$message', '$now', '$end', '1', '1');";
$norefund = ($donation + $pointspool) % $points;
mysql_query($sql)or sqlerr(__FILE__, __LINE__);
$bonuscomment = get_date( time(), 'DATE', 1 ) . " - " .$points. " Points contributed for freeleech.\n " .$bonuscomment;
mysql_query("UPDATE users SET seedbonus = '$seedbonus',  bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
$sql2 = "UPDATE bonus SET pointspool = '$norefund' WHERE id = '11' LIMIT 1";
mysql_query($sql2)or sqlerr(__FILE__, __LINE__);
write_bonus_log($CURUSER["id"], $donation, $type = "freeleech");
header("Refresh: 0; url={$TBDEV['baseurl']}//mybonus.php?freeleech_success=1&norefund=$norefund");
die;
} else {
// add to the pool
$sql = "UPDATE bonus SET pointspool = pointspool + '$donation' WHERE id = '11' LIMIT 1";
mysql_query($sql)or sqlerr(__FILE__, __LINE__);
$bonuscomment = get_date( time(), 'DATE', 1 ) . " - " .$points. " Points contributed for freeleech.\n " .$bonuscomment;
mysql_query("UPDATE users SET seedbonus = '$seedbonus', bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
write_bonus_log($CURUSER["id"], $donation, $type = "freeleech");
header("Refresh: 0; url={$TBDEV['baseurl']}/mybonus.php?freeleech_success=2");
die;
}
die;
break;
//--- doubleupload
case 'doubleup':
$points2 = 59999;
$pointspool = $arr_points['pointspool'];
$points= htmlspecialchars($points,1);
$donation = 0 + $_POST['donate'];
$seedbonus = ($bonus - $donation);
if($bonus < $donation || $donation <= 0 ||$donation > $points2){
stderr("Error", " <br />Points: ".htmlspecialchars($donation)." <br /> Bonus: ".htmlspecialchars($bonus)." <br /> Donation: ".htmlspecialchars($donation)." <br />Time shall unfold what plighted cunning hides\n\nWho cover faults, at last shame them derides.<br /> Click to go back to your <a class='altlink' href='./mybonus.php'>Karma Bonus Point</a> page.<br />");
die;
}
if(($pointspool+$donation) >= $arr_points["points"] ){
$now = time();
$end = (86400 * 3 + time());
$message = "DoubleUpload [ON]";
$sql = "INSERT INTO `events`(`userid`,`overlayText`, `startTime`, `endTime`, `displayDates`, `duploadEnabled`) VALUES ('$userid', '$message', '$now', '$end', '1', '1');";
$norefund = ($donation + $pointspool) % $points;
mysql_query($sql)or sqlerr(__FILE__, __LINE__);
$bonuscomment = get_date( time(), 'DATE', 1 ) . " - " .$points. " Points contributed for doubleupload.\n " .$bonuscomment;
mysql_query("UPDATE users SET seedbonus = '$seedbonus',  bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
$sql2 = "UPDATE bonus SET pointspool = '$norefund' WHERE id = '12' LIMIT 1";
mysql_query($sql2)or sqlerr(__FILE__, __LINE__);
write_bonus_log($CURUSER["id"], $donation, $type = "doubleupload");
header("Refresh: 0; url={$TBDEV['baseurl']}/mybonus.php?doubleup_success=1&norefund=$norefund");
die;
} else {
// add to the pool
$sql = "UPDATE bonus SET pointspool = pointspool + '$donation' WHERE id = '12' LIMIT 1";
mysql_query($sql)or sqlerr(__FILE__, __LINE__);
$bonuscomment = get_date( time(), 'DATE', 1 ) . " - " .$points. " Points contributed for doubleupload.\n " .$bonuscomment;
mysql_query("UPDATE users SET seedbonus = '$seedbonus', bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
write_bonus_log($CURUSER["id"], $donation, $type = "doubleupload");
header("Refresh: 0; url={$TBDEV['baseurl']}/mybonus.php?doubleup_success=2");
die;
}
die;
break;
//---Halfdownload
case 'halfdown':
$points2 = 59999;
$pointspool = $arr_points['pointspool'];
$points= htmlspecialchars($points,1);
$donation = 0 + $_POST['donate'];
$seedbonus = ($bonus - $donation);
if($bonus < $donation || $donation <= 0 ||$donation > $points2){
stderr("Error", " <br />Points: ".htmlspecialchars($donation)." <br /> Bonus: ".htmlspecialchars($bonus)." <br /> Donation: ".htmlspecialchars($donation)." <br />Time shall unfold what plighted cunning hides\n\nWho cover faults, at last shame them derides.<br /> Click to go back to your <a class='altlink' href='./mybonus.php'>Karma Bonus Point</a> page.<br />");
die;
}
if(($pointspool+$donation) >= $arr_points["points"] ){
$now = time();
$end = (86400 * 3 + time());
$message = "HalfDownload [ON]";
$sql = "INSERT INTO `events`(`userid`,`overlayText`, `startTime`, `endTime`, `displayDates`, `hdownEnabled`) VALUES ('$userid', '$message', '$now', '$end', '1', '1');";
$norefund = ($donation + $pointspool) % $points;
mysql_query($sql)or sqlerr(__FILE__, __LINE__);
$bonuscomment = get_date( time(), 'DATE', 1 ) . " - " .$points. " Points contributed for Halfdownload.\n " .$bonuscomment;
mysql_query("UPDATE users SET seedbonus = '$seedbonus',  bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
$sql2 = "UPDATE bonus SET pointspool = '$norefund' WHERE id = '13' LIMIT 1";
mysql_query($sql2)or sqlerr(__FILE__, __LINE__);
write_bonus_log($CURUSER["id"], $donation, $type = "halfdownload");
header("Refresh: 0; url={$TBDEV['baseurl']}/mybonus.php?halfdown_success=1&norefund=$norefund");
die;
} else {
// add to the pool
$sql = "UPDATE bonus SET pointspool = pointspool + '$donation' WHERE id = '13' LIMIT 1";
mysql_query($sql)or sqlerr(__FILE__, __LINE__);
$bonuscomment = get_date( time(), 'DATE', 1 ) . " - " .$points. " Points contributed for halfdownload.\n " .$bonuscomment;
mysql_query("UPDATE users SET seedbonus = '$seedbonus', bonuscomment = '$bonuscomment' WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
write_bonus_log($CURUSER["id"], $donation, $type = "halfdownload");
header("Refresh: 0; url={$TBDEV['baseurl']}/mybonus.php?halfdown_success=2");
die;
}
die;
break;


6 occurences in the query's above you may need to alter as i stated at the top using your bonus numbers - ie 10 for freeleech - 11 for doubleupload - 12 for halfdownload is from default... you get what i mean :)

next change this

Code (php) Select
if ($points == 0)
stderr("Error", "I smell a rat!");


to this

Code (php) Select
if ($points <= 0)
stderr("Error", "I smell a rat!");


then under this

Code (php) Select
stdhead($CURUSER['username'] . "'s Karma Bonus Page");

add this

Code (php) Select
//==09 Ezeros freeleech contribution - pdq.Bigjoos.Ezero
$sql = "SELECT bonuslog.id, SUM(bonuslog.donation) as total, users.username FROM bonuslog left join users ON bonuslog.id=users.id WHERE bonuslog.type = 'freeleech' GROUP BY bonuslog.id ORDER BY total DESC LIMIT 10;";
$res2 = sql_query($sql);
while($row = mysql_fetch_assoc($res2)){
$top_donators_id = $row["id"];
$damount_donated = $row["total"];
$top_donators_username = $row['username'];
$top_donators .= "<li><a href='{$TBDEV['baseurl']}/userdetails.php?id=$top_donators_id'>" . $top_donators_username . "</a> ( $damount_donated )</li>";
}

$sql = "SELECT bonuslog.id, SUM(bonuslog.donation) as total, users.username FROM bonuslog left join users ON bonuslog.id=users.id WHERE bonuslog.type = 'doubleupload' GROUP BY bonuslog.id ORDER BY total DESC LIMIT 10;";
$res2 = sql_query($sql);
while($row = mysql_fetch_assoc($res2)){
$top_donators_id = $row["id"];
$damount_donated = $row["total"];
$top_donators_username = $row['username'];
$top_donators2 .= "<li><a href='{$TBDEV['baseurl']}/userdetails.php?id=$top_donators_id'>" . $top_donators_username . "</a> ( $damount_donated )</li>";
}

$sql = "SELECT bonuslog.id, SUM(bonuslog.donation) as total, users.username FROM bonuslog left join users ON bonuslog.id=users.id WHERE bonuslog.type = 'halfdownload' GROUP BY bonuslog.id ORDER BY total DESC LIMIT 10;";
$res2 = sql_query($sql);
while($row = mysql_fetch_assoc($res2)){
$top_donators_id = $row["id"];
$damount_donated = $row["total"];
$top_donators_username = $row['username'];
$top_donators3 .= "<li><a href='{$TBDEV['baseurl']}/userdetails.php?id=$top_donators_id'>" . $top_donators_username . "</a> ( $damount_donated )</li>";
}
$fpoints ="";
$dpoints ="";
$hpoints ="";
$freeleech_enabled ="";
$double_upload_enabled ="";
$half_down_enabled ="";
$top_donators ="";
$top_donators2 ="";
$top_donators3 ="";
// eZER0's mod for bonus contribution
// Limited this to 3 because of performance reasons and i wanted to go through last 3 events anyway the most we can have
// is that halfdownload is enabled, double upload is enabled as well as freeleech enabled! x  3 eZER0
function mysql_fetch_all($query, $default_value = Array())
{
    $r = @mysql_query($query);
    $result = Array();
    if ($err = mysql_error())return $err;
    if (@mysql_num_rows($r))
        while ($row = mysql_fetch_array($r))$result[] = $row;
    if (count($result) == 0)
        return $default_value;
    return $result;
}

function write_bonus_log($userid, $amount, $type){
  $added = time();
  $donation_type = $type;
  sql_query("INSERT INTO bonuslog (id, donation, type, added_at) VALUES('$userid', '$amount', '$donation_type', $added)") or sqlerr(__FILE__, __LINE__);
}
   
    $scheduled_events = mysql_fetch_all("SELECT * from `events` ORDER BY `startTime` DESC LIMIT 3;", array());
    if (is_array($scheduled_events)){
        foreach ($scheduled_events as $scheduled_event) {
            if (is_array($scheduled_event) && array_key_exists('startTime', $scheduled_event) &&
                array_key_exists('endTime', $scheduled_event)){
                $startTime = 0;
                $endTime = 0;
                $startTime = $scheduled_event['startTime'];
                $endTime = $scheduled_event['endTime'];
                if (time() < $endTime && time() > $startTime){
                    if (array_key_exists('freeleechEnabled', $scheduled_event)) {
                        $freeleechEnabled = $scheduled_event['freeleechEnabled'];
                        if ($scheduled_event['freeleechEnabled']){
                            $freeleech_start_time = $scheduled_event['startTime'];
                            $freeleech_end_time = $scheduled_event['endTime'];
                            $freeleech_enabled = true;
                        }
                    }
                    if (array_key_exists('duploadEnabled', $scheduled_event)){
                        $duploadEnabled = $scheduled_event['duploadEnabled'];
                        if ($scheduled_event['duploadEnabled']){
                            $double_upload_start_time = $scheduled_event['startTime'];
                            $double_upload_end_time = $scheduled_event['endTime'];
                            $double_upload_enabled = true;
                        }
                    }
                    if (array_key_exists('hdownEnabled', $scheduled_event)) {
                        $hdownEnabled = $scheduled_event['hdownEnabled'];   
                        if ($scheduled_event['hdownEnabled']){
                            $half_down_start_time = $scheduled_event['startTime'];
                            $half_down_end_time = $scheduled_event['endTime'];
                            $half_down_enabled = true;
                        }
                        }
                        }
                        }
                        }
                        }

    $sql = "SELECT `pointspool`, `points` FROM `bonus` WHERE `art` = 'freeleech' OR `art` = 'doubleup' OR `art` = 'halfdown'";
    $res = sql_query($sql)  or print (mysql_error());
    $row = mysql_fetch_assoc($res);
    $row2 = mysql_fetch_assoc($res);
    $row3 = mysql_fetch_assoc($res);
    $fpointspool = $row["pointspool"];
    $dpointspool = $row2["pointspool"];
    $hpointspool = $row3["pointspool"];
    if($fpoints == 0) $fpoints = 1;
    if($dpoints == 0) $dpoints = 1;
    if($hpoints == 0) $hpoints = 1;
    $free_leech_percentage = round(($fpointspool / $fpoints) / 1000, 0);
    $double_upload_percentage = round(($dpointspool / $dpoints) / 1000, 0);   
    $half_down_open_percentage = round(($hpointspool / $hpoints) / 1000, 0); 
        // make this code more DRY! put it in a function somewhere and then call it for each of the percentages
        if($free_leech_percentage <= 25){
            $fcolor = "red";   
        } elseif($free_leech_percentage <= 50) {
            $fcolor = "#da00e0";
        } else {
            $fcolor = "darkgreen";
        }
        if($double_upload_percentage <= 25){
            $dcolor = "red";   
        } elseif($double_upload_percentage <= 50) {
            $dcolor = "#da00e0";
        } else {
            $dcolor = "darkgreen";
        }
        if($half_down_open_percentage <= 25){
            $hcolor = "red";   
        } elseif($half_down_open_percentage <= 50) {
            $hcolor = "#da00e0";
        } else {
            $hcolor = "darkgreen";
        }
    if($freeleech_enabled){
        $fstatus = "<strong><font color=\"yellow\">&nbsp;ON&nbsp;</font></strong>";
    } else {
        $fstatus = $free_leech_percentage ."&nbsp;%";
    }
    if($double_upload_enabled){
        $dstatus = "<strong><font color=\"yellow\">&nbsp;ON&nbsp;</font></strong>";
    } else {
        $dstatus = $double_upload_percentage ."&nbsp;%";
    }
    if($half_down_enabled){
        $hstatus = "<strong><font color=\"yellow\">&nbsp;ON&nbsp;</font></strong>";
    } else {
        $hstatus = $half_down_open_percentage ."&nbsp;%";
    }
$HTMLOUT .="
            <div align='center' style='background:#890537;height:25px;'>&nbsp;FreeLeech&nbsp;[&nbsp;";
            if($freeleech_enabled){
            $HTMLOUT .="<font color=\"yellow\"><strong>&nbsp;ON</strong></font>&nbsp;".get_date($freeleech_start_time, 'DATE') . "&nbsp;-&nbsp;" .get_date($freeleech_end_time, 'DATE');
            } else {
            $HTMLOUT .="<font color=\"" . $fcolor . "\"><strong>" . $fstatus . "</strong></font>";
            }
            $HTMLOUT .="&nbsp;]";
   
            $HTMLOUT .="&nbsp;DoubleUpload&nbsp;[&nbsp;";
            if($double_upload_enabled){
            $HTMLOUT .="<font color=\"yellow\"><strong>&nbsp;ON</strong></font>&nbsp;".get_date($double_upload_start_time, 'DATE') . "&nbsp;-&nbsp;" .get_date($double_upload_end_time, 'DATE');
            } else {
            $HTMLOUT .="<font color=\"" . $dcolor . "\"><strong>" . $dstatus . "</strong></font>";
            }
            $HTMLOUT .="&nbsp;]";
           
            $HTMLOUT .="&nbsp;Half Download&nbsp;[&nbsp;";
            if($half_down_enabled){
            $HTMLOUT .="<font color=\"yellow\"><strong>&nbsp;ON</strong></font>&nbsp;".get_date($half_down_start_time, 'DATE') . "&nbsp;-&nbsp;" .get_date($half_down_end_time, 'DATE');
            } else {
            $HTMLOUT .="<font color=\"" . $hcolor . "\"><strong>" . $hstatus . "</strong></font>";
            }
            $HTMLOUT .="&nbsp;]</div>";
//==End


under this

Code (php) Select
$otheroption_title = "<input type='text' name='title' size='30' maxlength='30' />";

add this

Code (php) Select
$otheroption_donate = "<input type='text' name='donate' size='10' maxlength='10' />";

under this or similiar depending on your mybonus

Code (php) Select
case ($gets['id'] == 10):
  $HTMLOUT .="<tr><td align='left' class='".$class."'><h1><font color='#CECFF3'>".$gets['bonusname']."</font></h1>".$gets['description']."<br /><br />Enter the <b>ID number of the Torrent:</b> <input type='text' name='torrent_id' size='4' maxlength='8' /> you would like to buy a 1 to 1 ratio on.</td><td align='center' class='".$class."'>min.<br />".$gets['points']."</td>";
break;


add these again theres 3 numbers to be added to match your bonus table and the above querys

Code (php) Select
case ($gets['id'] == 11):
  $HTMLOUT .="<tr><td align='left' class='".$class."'><h1><font color=\"#CECFF3\">".$gets["bonusname"]."</font></h1>".$gets['description']."<br /><h4>Top 10 Contributors </h4> <ol>".$top_donators." </ol> <br />Enter the <b>amount to contribute</b> ".$otheroption_donate."</td><td align='center' class='".$class."'>" .$gets['points'] ." <br /> </td>";
break;
case ($gets['id'] == 12):
  $HTMLOUT .="<tr><td align='left' class='".$class."'><h1><font color=\"#CECFF3\">".$gets["bonusname"]."</font></h1>".$gets['description']."<br /><h4>Top 10 Contributors </h4> <ol>".$top_donators2." </ol> <br />Enter the <b>amount to contribute</b> ".$otheroption_donate."</td><td align='center' class='".$class."'>" .$gets['points'] ." <br /> </td>";
break;
case ($gets['id'] == 13):
  $HTMLOUT .="<tr><td align='left' class='".$class."'><h1><font color=\"#CECFF3\">".$gets["bonusname"]."</font></h1>".$gets['description']."<br /><h4>Top 10 Contributors </h4> <ol>".$top_donators3." </ol> <br />Enter the <b>amount to contribute</b> ".$otheroption_donate."</td><td align='center' class='".$class."'>" .$gets['points'] ." <br /> </td>";
break;


then under this or similiar whatevers last :)

Code (php) Select
case ($gets['id'] == 7):
$HTMLOUT .="<td class='".$class."'><input class='button' type='submit' name='submit' value='Karma Gift!' /></td></form>";
break;


add these again changing  to your numbers if required :)

Code (php) Select
case ($gets['id'] == 11 ):
$HTMLOUT .="<td align='center' class='".$class."'>". ($gets['points'] - $gets['pointspool']) . " <br />Points needed! <br /><input class='button' type='submit' name='submit' value='Contribute!' /></td></form>";
break;
case ($gets['id'] == 12 ):
$HTMLOUT .="<td align='center' class='".$class."'>". ($gets['points'] - $gets['pointspool']) . " <br />Points needed! <br /><input class='button' type='submit' name='submit' value='Contribute!' /></td></form>";
break;
case ($gets['id'] == 13 ):
$HTMLOUT .="<td align='center' class='".$class."'>". ($gets['points'] - $gets['pointspool']) . " <br />Points needed! <br /><input class='button' type='submit' name='submit' value='Contribute!' /></td></form>";
break;


last part is html to be added to the list of what costs karma

Code (php) Select
<li>Freeleech contribution - Max 59999 points - button can be seen if you have over 30000 points.</li>
<li>Double Upload contribution - Max 59999 points - button can be seen if you have over 30000 points.</li>
<li>Half Download contribution - Max 59999 points - button can be seen if you have over 30000 points.</li>


next events.php - upload to root

Code (php) Select
<?php
require_once("include/bittorrent.php");
require_once (
"include/user_functions.php");
require_once (
"include/bbcode_functions.php");
require_once (
"include/html_functions.php");
dbconn();
loggedinorreturn();

$lang array_mergeload_language('global'));

$HTMLOUT="";

if (
$CURUSER['class'] < UC_MODERATOR)
    
stderr("Events", - "Nosey Cunt !");

function 
mysql_fetch_all($query$default_value = Array())
{
    
$r = @mysql_query($query);
    
$result = Array();
    if (
$err mysql_error())return $err;
    if (@
mysql_num_rows($r))
        while (
$row mysql_fetch_array($r))$result[] = $row;
    if (
count($result) == 0)
        return 
$default_value;
    return 
$result;
}

function 
get_user_name($userid){

  
$res mysql_query("SELECT `username` FROM `users` WHERE `id` = $userid LIMIT 1")  or sqlerr(__FILE____LINE__);
  
$username mysql_fetch_assoc($res);
  
  return 
$username;
}

$scheduled_events mysql_fetch_all("SELECT * from `events` ORDER BY `startTime` DESC LIMIT 10;", array());

if (
is_array($scheduled_events)){
foreach (
$scheduled_events as $scheduled_event)
{
if (
is_array($scheduled_event) && array_key_exists('startTime'$scheduled_event) &&
array_key_exists('endTime'$scheduled_event))
{
$startTime 0;
$endTime 0;
$overlayText "";
$displayDates true;

$startTime $scheduled_event['startTime'];

$endTime $scheduled_event['endTime'];

if (
time() < $endTime && time() > $startTime)
{

if (
array_key_exists('overlayText'$scheduled_event))
$overlayText $scheduled_event['overlayText'];
if (!
is_string($overlayText))
$overlayText "";

if (
array_key_exists('displayDates'$scheduled_event))
$displayDates = (bool)(int)$scheduled_event['displayDates'];
if (!
is_bool($displayDates))
$displayDates false;

if (
array_key_exists('freeleechEnabled'$scheduled_event)) {
$freeleechEnabled $scheduled_event['freeleechEnabled'];
}
if (!
is_bool($freeleechEnabled)){
$freeleechEnabled false;
}


if (
array_key_exists('duploadEnabled'$scheduled_event)){
$duploadEnabled $scheduled_event['duploadEnabled'];
}
if (!
is_bool($duploadEnabled)) {
$duploadEnabled false;
}

if (
array_key_exists('hdownEnabled'$scheduled_event)) {
$hdownEnabled $scheduled_event['hdownEnabled'];
}
if (!
is_bool($hdownEnabled)) {
$hdownEnabled false;
}

if (
$freeleechEnabled){
$freeleechEnabled true;
}
if (
$duploadEnabled){
$duploadEnabled true;
}
if (
$hdownEnabled){
$hdownEnabled true;
}

if (
$displayDates) {
$overlay_text "<span style=\"font-size: 90%\">$overlayText</span><br/><span style=\"font-size: 60%\">" .
get_date($startTime'DATE') . " - " get_date($endTime'DATE') . "</span>\n";
} else {
$overlay_text "<span style=\"font-size: 90%\">$overlayText</span>\n";
}
}
}
}
}

$HTMLOUT .="
<script type='text/javascript'>
function checkAllGood(event){
var result = confirm(\"Are you sure you want to remove '\" + event + \"' Event ?\");
if(result)
return true;
else
return false;
}
</script>"
;

if(!
is_array($scheduled_events)){
$_POST = (isset($_POST) ? $_POST '');
$HTMLOUT .="Error: Events not loaded.";
}else{
foreach(
$_POST as $key => $value){
if(
gettype($pos strpos($key"_"))!= 'boolean'){
$id = (int)substr($key$pos 1);
if(
gettype(strpos($key"removeEvent_"))!= 'boolean'){
$sql "DELETE FROM `events` WHERE `id` = $id LIMIT 1;";
$res mysql_query($sql);
if(
mysql_error()!=0)
$HTMLOUT .="<p>Error Deleting Event: " mysql_error() . "<br /> Click <a class='altlink' href='{$TBDEV['baseurl']}/events.php'>Here</a> to go back.<br /></p>\n";
else{
if(
mysql_affected_rows()==0)
$HTMLOUT .="<p>Error Deleting Event: " mysql_error() . "<br /> Click <a class='altlink' href='{$TBDEV['baseurl']}/events.php'>Here</a> to go back.<br /></p>\n";
else{
$HTMLOUT .="<p>Deleted.</p>\n";
header("Refresh: 2; url=".$_SERVER["PHP_SELF"]);
}
}
}
elseif(
gettype(strpos($key"saveEvent_"))!= 'boolean'){
$text "";
$start 0;
$end 0;
$showDates 0;


if(
array_key_exists('userid'$_POST))
$userid $_POST['userid'];
if(
array_key_exists('editText'$_POST))
$text $_POST['editText'];
if(
array_key_exists('editStartTime'$_POST))
$start strtotime(trim($_POST['editStartTime']));
if(
array_key_exists('editEndTime'$_POST))
$end strtotime(trim($_POST['editEndTime']));
 
    if(isset(
$_POST["editFreeleech"])){
  $freeleech 1;
  }
if(isset($_POST['editFreeleech']) == ''){
$freeleech 0;
}

  if(isset($_POST["editDoubleupload"])){
  $doubleupload 1;
  }
if(isset($_POST['editDoubleupload']) == ''){
$doubleupload 0;
}
 
    if(isset(
$_POST["editHalfdownload"])){
  $halfdownload 1;
  }
if(isset($_POST['editHalfdownload']) == ''){
$halfdownload 0;
}
 

if (
array_key_exists('editShowDates'$_POST))
$showDates 1;
if(
$id==-1)
$sql "INSERT INTO `events`(`overlayText`, `startTime`, `endTime`, `displayDates`, `freeleechEnabled`, `duploadEnabled`, `hdownEnabled`, `userid`) VALUES ('$text', $start$end$showDates$freeleech$doubleupload$halfdownload$userid);";
else
$sql "UPDATE `events` SET `overlayText` = '$text',`startTime` = $start, `endTime` = $end, `displayDates` = $showDates, `freeleechEnabled` = $freeleech, `duploadEnabled` = $doubleupload, `hdownEnabled` = $halfdownload, `userid` = $userid  WHERE `id` = $id;";

$res mysql_query($sql);
if(
mysql_error()!=0)
$HTMLOUT .="<p>Error Saving Event: " mysql_error() . "<br /> Click <a class='altlink' href='{$TBDEV['baseurl']}/events.php'>Here</a> to go back.<br /></p>\n";
else{
if(
mysql_affected_rows()==0)
$HTMLOUT .="<p>Possible Error Saving (No Changes)<br /> Click <a class='altlink' href='{$TBDEV['baseurl']}/events.php'>Here</a> to go back.<br /></p>\n";
else{
$HTMLOUT .="<p>Saved.</p>\n";
header("Refresh: 2; url=".$_SERVER["PHP_SELF"]);
}
}
}
}
}

$HTMLOUT .="<p><strong> Events Schedular </strong> (eZERO) - <strong> <font color='red'>BETA - Reworked For 09</font> </strong> </p>
<form action='' method='post'>
<table width='80%' cellpadding='6'>
<tr><th>User</th><th>Text</th><th>Start</th><th>End</th><th>Freeleech?</th><th>DUpload?</th><th>halfdownload?</th><th>Show Dates?</th><th>&nbsp;</th></tr>"
;

foreach(
$scheduled_events as $scheduled_event){
$id $scheduled_event['id'];
$username get_user_name($scheduled_event['userid']);
$text $scheduled_event['overlayText'];
$start get_date((int)$scheduled_event['startTime'], 'DATE');
$end get_date((int)$scheduled_event['endTime'], 'DATE');
$freeleech = (bool)(int)$scheduled_event['freeleechEnabled'];
$doubleUpload = (bool)(int)$scheduled_event['duploadEnabled'];
$halfdownload = (bool)(int)$scheduled_event['hdownEnabled'];

if(
$freeleech){
$freeleech "<img src=\"{$TBDEV['pic_base_url']}on.gif\" alt=\"Freeleech Enabled\" title=\"Enabled\" />";
}else{
$freeleech "<img src=\"{$TBDEV['pic_base_url']}off.gif\" alt=\"Freeleech Disabled\" title=\"Disabled\" />";
}
if(
$doubleUpload){
$doubleUpload "<img src=\"{$TBDEV['pic_base_url']}on.gif\" alt=\"Double Upload Enabled\" title=\"Enabled\" />";
}else{
$doubleUpload "<img src=\"{$TBDEV['pic_base_url']}off.gif\" alt=\"Double Upload Disabled\" title=\"Disabled\" />";
}

if(
$halfdownload){
$halfdownload "<img src=\"{$TBDEV['pic_base_url']}on.gif\" alt=\"Halfdownload Enabled\" title=\"Enabled\" />";
}else{
$halfdownload "<img src=\"{$TBDEV['pic_base_url']}off.gif\" alt=\"Halfdownload Disabled\" title=\"Disabled\" />";
}
$showdates = (bool)(int)$scheduled_event['displayDates'];
if(
$showdates){
$showdates "<img src=\"{$TBDEV['pic_base_url']}on.gif\" alt=\"Showing of Dates Enabled\" title=\"Enabled\" />";
}else{
$showdates "<img src=\"{$TBDEV['pic_base_url']}off.gif\" alt=\"Showing of Dates Disabled\" title=\"Disabled\" />";
}
$HTMLOUT .="<tr><td align=\"center\">$username[username]</td><td align=\"center\">{$text}</td><td align=\"center\">{$start}</td><td align=\"center\">{$end}</td><td align=\"center\">{$freeleech}</td><td align=\"center\">{$doubleUpload}</td><td align=\"center\">{$halfdownload}</td><td align=\"center\">{$showdates}</td><td align=\"center\"><input type=\"submit\" name=\"editEvent_$id\" value=\"Edit\" /> <input type=\"submit\" onclick=\"return checkAllGood('$text')\" name=\"removeEvent_$id\" value=\"Remove\" /></td></tr>";
}
$HTMLOUT .="<tr><td colspan='9' align='right'><input type='submit' name='editEvent_-1' value='Add Event' /></td></tr></table>";

foreach(
$_POST as $key => $value){
if(
gettype($pos strpos($key"_"))!= 'boolean'){
$id = (int)substr($key$pos 1);
if(
gettype(strpos($key"editEvent_"))!= 'boolean'){
if(
$id==-1){
$HTMLOUT .="<table>
<tr><th align='right'>Userid</th><td><input type='text' name='userid' value='
{$CURUSER["id"]}' /></td></tr>
<tr><th align='right'>Text</th><td><input type='text' name='editText' /></td></tr>
<tr><th align='right'>Start Time</th><td><input type='text' name='editStartTime' /></td></tr>
<tr><th align='right'>End Time</th><td><input type='text' name='editEndTime' /></td></tr>
<tr><th align='right'>Freeleech</th><td><input type='checkbox' name='editFreeleech' /></td></tr>
<tr><th align='right'>DoubleUpload</th><td><input type='checkbox' name='editDoubleupload' /></td></tr>
<tr><th align='right'>halfdownload</th><td><input type='checkbox' name='editHalfdownload' /></td></tr>
<tr><th align='right'>Show Dates</th><td><input type='checkbox' name='editShowDates' /></td></tr>
<tr><td colspan='2' align='center'><input type='submit' name='saveEvent_-1' value='Save Changes' /></td></tr>
</table>"
;
}
else
foreach(
$scheduled_events as $scheduled_event){
if(
$id == $scheduled_event['id']){
$text $scheduled_event['overlayText'];
$start get_date((int)$scheduled_event['startTime'], 'DATE');
$end get_date((int)$scheduled_event['endTime'], 'DATE');
$freeleech = (bool)(int)$scheduled_event['freeleechEnabled'];
if(
$freeleech){
$freeleech "checked=\"checked\"";
}else{
$freeleech "";
}

$doubleupload = (bool)(int)$scheduled_event['duploadEnabled'];
if(
$doubleupload){
$doubleupload "checked=\"checked\"";
}else{
$doubleupload "";
}

$halfdownload = (bool)(int)$scheduled_event['hdownEnabled'];
if(
$halfdownload){
$halfdownload "checked=\"checked\"";
}else{
$halfdownload "";
}

$showdates = (bool)(int)$scheduled_event['displayDates'];
if(
$showdates){
$showdates "checked=\"checked\"";
}else{
$showdates "";
}

$HTMLOUT .="<table>
<tr><th align='right'>Userid</th><td><input type='text' name='userid' value='
{$CURUSER["id"]}' /></td></tr>
<tr><th align='right'>Text</th><td><input type='text' name='editText' value='
{$text}' /></td></tr>
<tr><th align='right'>Start Time</th><td><input type='text' name='editStartTime' value='
{$start}' /></td></tr>
<tr><th align='right'>End Time</th><td><input type='text' name='editEndTime' value='
{$end}' /></td></tr>
<tr><th align='right'>Freeleech</th><td><input type='checkbox' name='editFreeleech' value='
{$freeleech}' /></td></tr>
<tr><th align='right'>DoubleUpload</th><td><input type='checkbox' name='editDoubleupload' value='
{$doubleUpload}' /></td></tr>
<tr><th align='right'>halfdownload</th><td><input type='checkbox' name='editHalfdownload' value='
{$halfdownload}' /></td></tr>
<tr><th align='right'>Show Dates</th><td><input type='checkbox' name='editShowDates' value='
{$showdates}' /></td></tr>
<tr><td colspan='2' align='center'><input type='submit' name='saveEvent_
{$id}' value='Save Changes' /></td></tr>
</table>"
;
break;
}
}
}
}
}
$HTMLOUT .="</form>";
}
print 
stdhead('Events') . $HTMLOUT stdfoot();
die;
?>
[code]

Lastly announce.php above this :

[code=php]if ( $upthis > 0 || $downthis > 0 )
{


Add this :

Code (php) Select
//==freeleech/doubleupload/ system by ezero - recoded block by putyn
$q = mysql_query("SELECT * FROM events ORDER BY startTime DESC LIMIT 1") or print (mysql_error());
  $a = mysql_fetch_assoc($q);
  if($a["startTime"] < time() && $a["endTime"] >time())
  {
if($a['freeleechEnabled'] == 1)
$downthis = 0;
if($a['duploadEnabled'] == 1){
$upthis *=2;
$downthis = 0;
}
if($a['hdownEnabled'] == 1){
$downthis = $downthis / 2;
  }
  }


And thats it simply add a link on your admin panel for events.php - Ensure you check the scripts over and the code so you happy its secure as its been worked on in a test environment - i have it working fine on all three options - Now the only issue i have here is the case/switch like i explained before - You need over 30000 points to have the button enabled to contribute so that needs changed so you can have the button show even if you only have 1 bonus point - If anyone can see what i cant or point me in the right direction then that would be perfect because i know the area that controls that side but so far testing hasnt offer