druglab.php
<?php
/*
This Mod was Designed Free of Charge For the Members of
Makewebgames.com
Cronwerks.com
MasterMccodes.com
Dev-Forum.net
Mcaddons.com
This mod was solely designed and Developed by Immortal Thug.
Modifications, Plug-ins, add-ons are Welcomed, But please keep the original Copyright Notice.
Thanks to Zeddicus for baring with me on a few areas I got stuck on.
Thanks to CrimeGame for a few security functions you will find below.
Thanks to the members of Makewebgames.com for Throwing new Ideas my direction to add-on to this script.
If you like this mod and would like to see more like it Please contact me at
joshuawdams@hotmail.com
Thanks, and Enjoy.
*/
require_once("globals.php");
// All Posts and Gets are Secured below. I find this easier than Securing them in each individual Query and I have tested to make sure they are secured.
$_GET['action'] = isset($_GET['action']) && is_string($_GET['action']) ? strtolower(trim($_GET['action'])) : false;
$_POST['amount'] = ( isset($_POST['amount']) AND ctype_digit($_POST['amount']) ) ? $_POST['amount'] : '' ;
$_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs((int) $_GET['ID']) : false;
$_POST['drug'] = ( isset($_POST['drug']) AND ctype_digit($_POST['drug']) ) ? $_POST['drug'] : '' ;
$_POST['damount'] = ( isset($_POST['damount']) AND ctype_digit($_POST['damount']) ) ? $_POST['damount'] : '' ;
$_POST['qty'] = ( isset($_POST['qty']) AND ctype_digit($_POST['qty']) ) ? $_POST['qty'] : '' ;
$_POST['price'] = ( isset($_POST['price']) AND ctype_digit($_POST['price']) ) ? $_POST['price'] : '' ;
$_POST['user'] = ( isset($_POST['user']) AND ctype_digit($_POST['user']) ) ? $_POST['user'] : '' ;
// End $_POST/$_GET security
$itusers = $db->query("SELECT
`userid`,`username`,`location`,`money`
FROM `users`
WHERE `userid`=".$_SESSION['userid']."");
if(!$db->num_rows($itusers))
{
echo "You have encountered an error which should be reported to staff immediately!";
$h->endpage();
exit;
}
$it = $db->fetch_row($itusers);
switch($_GET['action'])
{
case "index":index();break;
case "druglist":druglist();break;
case 'buydrug': buydrug(); break;
case 'druggrow': druggrow(); break;
case 'druggrow2': druggrow2(); break;
case 'upkeep': upkeep(); break;
case 'fertilize': fertilize(); break;
case 'confirm': confirm(); break;
case 'harvest': harvest(); break;
case 'druguse': druguse(); break;
case 'druguse2': druguse2(); break;
case 'market': market(); break;
case 'usersend': usersend(); break;
default:index();break;
}
function index()
{
global $db;
echo "<center><h2>Drug Lab Center</h2></center><br />
<table width=80% class=ttable><tr><td><a href='druglab.php?action=druglist'>Purchase Drugs</a>
</td><td><a href='druglab.php?action=druggrow'>Grow Drugs</a></td></tr>
<tr><td><a href='druglab.php?action=druguse'>Drugs Owned</a></td>
<td><a href='druglab.php?action=upkeep'>Maintain Drugs</a></td></tr>";
}
function druglist()
{
global $db,$it;
$itdrugs = $db->query("SELECT
`dID`,`drugTYPE`,`materialPRICE`,`drugCITY`
FROM `drugs`
WHERE `drugCITY`=".$it['location']."");
echo 'Welcome to the Drug Lab.<br />
<table width="95%" class="ttable">
<tr><th>Drug Type</th>
<th>Material Cost</th>
<th>Purchase</th></tr>';
while($itd=$db->fetch_row($itdrugs))
{
echo '<tr><td>'.stripslashes(htmlentities($itd['drugTYPE'])).'</td><td>'.number_format($itd['materialPRICE']).'</td>
<td><a href="druglab.php?action=buydrug&ID='.abs((int) $itd['dID']).'">Purchase</a></td></tr>';
}
echo '</table>';
echo '<br /><a href="druglab.php"><strong>Back</strong></a>';
}
function buydrug()
{
global $db,$h,$it;
$itdrugbuy = $db->query("SELECT `dID`,`drugTYPE`,`materialPRICE`,`drugCITY` FROM `drugs` WHERE `dID`=".$_GET['ID']."");
if(!$db->num_rows($itdrugbuy))
{
echo 'This drug is not available.';
$h->endpage();
exit;
}
$cct = $db->fetch_row($itdrugbuy);
if($_POST['amount'])
{
$xamount = $_POST['amount']*$cct['materialPRICE'];
if($xamount > $it['money'])
{
echo 'You cannot afford this quantity.<br /><a href="druglab.php"><strong>Back</strong></a>';
$h->endpage();
exit;
}
else
{
$exists = $db->query("SELECT `type`,`usrID` FROM `materialsowned` WHERE `type`=".$cct['dID']."");
if($db->num_rows($exists))
{
$db->query(sprintf("UPDATE `materialsowned` SET `qty`=`qty`+%u WHERE `usrID`=%d AND `type`=%u", abs((int) $_POST['amount']), $it['userid'], $cct['dID']));
$db->query(sprintf("UPDATE `users` SET `money`=`money`-%u WHERE `userid`=%d", abs((int) $xamount), $it['userid']));
echo "You have purchased ".number_format($_POST['amount'])." gram of ".stripslashes(htmlentities($cct['drugTYPE']))." supplies, at the price of ".abs((int) $xamount).".<br /><a href='druglab.php'><strong>Back</strong></a>";
}
else
{
$db->query(sprintf("INSERT INTO `materialsowned` VALUES('',%u,'%s',%u,%d)", abs((int) $cct['dID']), mysql_real_escape_string($cct['drugTYPE']), $_POST['amount'], $it['userid']));
$db->query(sprintf("UPDATE `users` SET `money`=`money`-%u WHERE `userid`=%d", abs((int) $xamount), $it['userid']));
echo "You have purchased ".number_format($_POST['amount'])." gram of ".stripslashes(htmlentities($cct['drugTYPE']))." supplies, at the price of ".abs((int) $xamount).".<br /><a href='druglab.php'><strong>Back</strong></a>";
}
}
}
else
{
echo "Current Price per Material: ".number_format($cct['materialPRICE'])." dollars cash.<br />
<form action='druglab.php?action=buydrug&ID=".$_GET['ID']."' method='post'>
Enter Quantity: <input type='text' name='amount' />
<input type='submit' />
</form>";
}
}
function druggrow()
{
global $db,$h,$it;
$drugsowned = $db->query("SELECT `type`,`typeNAME`,`qty`,`usrID` FROM `materialsowned` WHERE `usrID`=".$_SESSION['userid']."");
if(!$db->num_rows($drugsowned))
{
echo "You do not own any drug materials. Please return to the lab to purchase the necessary items you would require.<br /><strong><a href='druglab.php'>Back</a></strong>";
$h->endpage();
exit;
}
$dx = $db->fetch_row($drugsowned);
if(isset($_POST['drug']) AND abs((int) $_POST['drug']))
{
$drugsowned = $db->query("SELECT `type`,`typeNAME`,`qty`,`usrID` FROM `materialsowned` WHERE `usrID`=".$_SESSION['userid']." AND `type`=".$_POST['drug']."");
$bleh = $db->fetch_row($drugsowned);
echo "Enter an Amount of the selected drug to send to the lab.<br />
You currently have ".number_format($bleh['qty'])." units of ".stripslashes(htmlentities($bleh['typeNAME']))." to farm.
<form action='druglab.php?action=druggrow2&ID=".$_POST['drug']."' method='post'>
Amount: <input type='text' name='damount' />
<input type='submit' />
</form>";
}
else
{
echo '<center>Here you must select which drug you wish to grow for redistribution.<br /></center.
Various drugs will grow differantly in various cities.<br />
Please Select your type from the drop down menu to continue to the next step.<br />
<form action="druglab.php?action=druggrow" method="post">
<select name="drug" type="dropdown">';
$fetch = $db->query("SELECT
d.`dID`,d.`drugTYPE`,m.`qty`
FROM `drugs` d
LEFT JOIN `materialsowned` m
ON d.`dID`=m.`type`
WHERE `usrID`=".$_SESSION['userid']."
AND m.`qty`>0");
while($cc = $db->fetch_row($fetch))
{
echo '<option value="'.abs((int) $cc['dID']).'">'.stripslashes(htmlentities($cc['drugTYPE'])).'</option>';
} echo '</select><br>
<input type="submit" value="Select Drug"></form>';
}
}
function druggrow2()
{
global $db,$h;
$itresult = $db->query("SELECT `type`,`typeNAME`,`qty` FROM `materialsowned` WHERE `usrID`=".$_SESSION['userid']." AND `type`=".$_GET['ID']."");
if(!$db->num_rows($itresult))
{
echo "You do not have any seeds to plant here, please return to the drug lab and purchase some!<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$dait = $db->fetch_row($itresult);
if($dait['type'] != $_GET['ID'])
{
echo "blah";
$h->endpage();
exit;
}
if($_POST['damount'] > $dait['qty'])
{
echo "You do not have this much to send to your lab, please select a differant amount.<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
if(!$_POST['damount'] || $_POST['damount'] != abs((int) $_POST['damount']))
{
echo "You did not select a quantity please return to the lab and try again.<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
else
{
echo "You opted to send ".number_format($_POST['damount'])." unit(s) of ".stripslashes(htmlentities($dait['typeNAME']))." material to the lab to grow.<br />
<strong><a href='druglab.php'><strong>Return</strong></a>";
$db->query(sprintf("INSERT INTO `userfarm` VALUES('',0,%u,%u,1,1,%u)", $_POST['damount'], $_SESSION['userid'], $dait['type']));
$db->query(sprintf("UPDATE `materialsowned` SET `qty`=`qty`-%u WHERE `type`=%u AND `usrID`=%u AND `qty`>0", $_POST['damount'], $_GET['ID'], $_SESSION['userid']));
$db->query("DELETE FROM `materialsowned` WHERE `qty`=0");
$h->endpage();
exit;
}
}
function upkeep()
{
global $db,$h;
$growing = $db->query("SELECT
uf.`fID`,uf.`age`,uf.`fQTY`,uf.`fuserid`,uf.`fquality`,uf.`ffertilized`,uf.`fTYPE`,d.`drugTYPE`
FROM `userfarm` uf
LEFT JOIN `drugs` d
ON d.`dID`=uf.`fTYPE`
WHERE `fuserid`=".$_SESSION['userid']."");
if(!$db->num_rows($growing))
{
echo "You currently have no drugs growing in the lab. Please return to the materials depot to purchase the required items.<br /><a href='druglab.php'><strong>Lab</strong></a>";
$h->endpage();
exit;
}
echo "Below is a list of all drugs you currently have growing in the lab.<br />
Drug growing requires careful upkeep and proper fertilization.<br />
Please make sure your drugs are kept fertilized or they may turn out of poor quality<br />
Crops Take exactly 7 days to Harvest. Once harvested you have exactly One day to crop them or you will lose them.<br />
<table width=100% class=ttable>
<tr>
<th>Drug Name</th>
<th>Amount Growing</th>
<th>Quality</th>
<th>Days Old</th>
<th>Fertilize</th>
<th>Harvest</th></tr>";
while($mm=$db->fetch_row($growing))
{
echo "<tr>
<td>".stripslashes(htmlentities($mm['drugTYPE']))."</td>
<td>".number_format($mm['fQTY'])."</td>
<td>".number_format($mm['fquality'])."</td>
<td>".number_format($mm['age'])."</td>";
if($mm['ffertilized'] > 0)
{
echo "<td><font color=green>Doing Well</font></td>";
}
else
{
echo "<td><a href='druglab.php?action=fertilize&ID=".$mm['fID']."'><u>Fertilize</u></a></td>";
}
if($mm['age'] > 6)
{
echo "<td><a href='druglab.php?action=harvest&ID=".$mm['fID']."'><u>Harvest</u></a></td></tr>";
}
else
{
echo "<td>Not Full Grown</td></tr>";
}
}
echo "</table><br />
<a href='druglab.php'><strong>Return to Lab</strong></a>";
}
function fertilize()
{
global $db,$h;
if(!$_GET['ID'] || $_GET['ID'] != abs((int) $_GET['ID']))
{
echo "You did not select a valid Drug from the list.<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$check = $db->query("SELECT
uf.`fID`,uf.`fQTY`,uf.`fTYPE`,d.`drugTYPE`
FROM `userfarm` uf
LEFT JOIN `drugs` d
ON d.`dID`=uf.`fTYPE`
WHERE `fID`=".$_GET['ID']."
AND (`fuserid`=".$_SESSION['userid'].")");
$itd = $db->fetch_row($check);
if(!$db->num_rows($check))
{
echo "Please select a drug that you own and wish to fertilize.<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$drugcost = $db->query("SELECT `fertilcost` FROM `drugs` WHERE `dID`=".$itd['fTYPE']."");
$costof = $db->fetch_row($drugcost);
$costy = $costof['fertilcost']*$itd['fQTY'];
echo "You have selected to fertilize this section of your ".stripslashes(htmlentities($itd['drugTYPE']))." at a cost of ".number_format($costy).". If this information is correct, Please select the confirmation link below to confirm your purchase.<br />
<center><a href='druglab.php?action=confirm&ID=".$_GET['ID']."'><u><strong>I hereby confirm purchase.</strong></u></a> ";
$h->endpage();
exit;
}
function confirm()
{
global $db,$h,$it;
if(!$_GET['ID'] || $_GET['ID'] != abs((int) $_GET['ID']))
{
echo "You did not select a valid Drug from the list.<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$check = $db->query("SELECT
uf.`fID`,uf.`fQTY`,uf.`fTYPE`,uf.`ffertilized`,d.`drugTYPE`
FROM `userfarm` uf
LEFT JOIN `drugs` d
ON d.`dID`=uf.`fTYPE`
WHERE `fID`=".$_GET['ID']."
AND (`fuserid`=".$_SESSION['userid'].")");
$itd = $db->fetch_row($check);
if(!$db->num_rows($check))
{
echo "Please select a drug that you own and wish to fertilize.<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
if($itd['ffertilized'] > 0)
{
echo "You have alreay fertilized this batch today. You do not want to over kill it! <br />
Please come back tomorrow and try again.<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$drugcost = $db->query("SELECT `fertilcost` FROM `drugs` WHERE `dID`=".abs((int) $itd['fTYPE'])."");
$costof = $db->fetch_row($drugcost);
$costy = abs((int) $costof['fertilcost'])*abs((int) $itd['fQTY']);
if($it['money'] < $costy)
{
echo "You cannot afford to co fertilize this batch of drugs. Please select another batch or save up to fertilize this one! You will need ".number_format($costy)." In order to carry out the transaction for this batch.<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
else
{
echo "You have successfully fertilized this batch of drugs! Click below to return to your management center.<br /><a href='druglab.php'><strong>Back</strong></a>";
$db->query("UPDATE `userfarm` SET `fquality`=`fquality`+1, `ffertilized`=1 WHERE `fID`=".abs((int) $itd['fID'])." AND `fquality`<7");
$db->query("UPDATE `users` SET `money`=`money`-".abs((int) $costy)." WHERE `userid`=".$_SESSION['userid']."");
}
}
function harvest()
{
global $db,$h;
if(!$_GET['ID'] || $_GET['ID'] != abs((int) $_GET['ID']))
{
echo "You did not select a Drug Id, please return and try again.<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$exists = $db->query("SELECT
uf.`fID`,uf.`age`,uf.`fQTY`,uf.`fuserid`,uf.`fquality`,uf.`fTYPE`,d.`drugTYPE`
FROM `userfarm` uf
LEFT JOIN `drugs` d
ON d.`dID`=uf.`fTYPE`
WHERE uf.`age` > 6
AND uf.`fuserid`=".$_SESSION['userid']."
AND (uf.`fID`=".$_GET['ID'].")");
if(!$db->num_rows($exists))
{
echo "The drugs you have selected are not currently ready to be harvested or do not exist. Please try when they reach 7 days old!<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$iqr = $db->fetch_row($exists);
if($iqr['fTYPE'] == 1)
{
$stat = 'guard';
}
elseif($iqr['fTYPE'] == 2)
{
$stat = 'agility';
}
else
{
$stat = 'strength';
}
echo "You have successfully harvested your crop! You can now manage or use your drugs in the Drugs Owned section.<br /><a href='druglab.php'><strong>Back</strong></a>";
$db->query("INSERT INTO `drugsowned` VALUES('',".$iqr['fTYPE'].",".$_SESSION['userid'].",".$iqr['fquality'].",'$stat','".$iqr['drugTYPE']."',".$iqr['fQTY'].")");
$db->query("DELETE FROM `userfarm` WHERE `fID`=".$_GET['ID']."");
}
function druguse()
{
global $it,$db,$h;
$find = $db->query("SELECT `oID`,`oTYPE`,`oUSER`,`oQUALITY`,`oSTAT`,`oNAME`,`oQTY` FROM `drugsowned` WHERE `oUSER`=".$_SESSION['userid']."");
if(!$db->num_rows($find))
{
echo "You do not currently hold any drugs that you can use. Please either purchase some or farm your own!<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
echo "<center><h2>Your Drugs</h2></center><br /><strong><a href='druglab.php'>Back</a></strong>
<table width=100% class=ttable>
<tr><th>Drug Name</th>
<th>Drug Quantity</th>
<th>Drug Quality</th>
<th>Drug Stat</th>
<th>Use</th>
<th>Market Drug</th>
<th>Send Drugs</th></tr>";
while($x=$db->fetch_row($find))
{
echo "<tr><td>".stripslashes(htmlentities($x['oNAME']))."</td>
<td>".number_format($x['oQTY'])."</td>
<td>".number_format($x['oQUALITY'])."</td>
<td>".stripslashes(htmlentities($x['oSTAT']))."</td>
<td><a href='druglab.php?action=druguse2&ID=".$x['oID']."'><u>Use Drug</u></a></td>
<td><a href='druglab.php?action=market&ID=".$x['oID']."'><u>Add to Market</u></a></td>
<td><a href='druglab.php?action=usersend&ID=".$x['oID']."'><u>Send To User</u></a></td></tr>";
}
echo "</table>";
}
function druguse2()
{
global $db,$it,$h;
$find = $db->query("SELECT `oID`,`oTYPE`,`oUSER`,`oQUALITY`,`oSTAT`,`oNAME`,`oQTY` FROM `drugsowned` WHERE `oUSER`=".$_SESSION['userid']." AND `oID`=".$_GET['ID']."");
if(!$db->num_rows($find))
{
echo "You do not currently hold any drugs that you can use. Please either purchase some or farm your own!<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$itd = $db->fetch_row($find);
if(isset($_POST['submit']) && is_string($_POST['submit']))
{
$userstats = $db->query("SELECT `strength`,`agility`,`guard` FROM `userstats` WHERE `userid`=".$_SESSION['userid']."");
if(!$db->num_rows($userstats))
{
echo "An error has occured, please report this to administrator naming the location and what you were doing.<br /><a href='index.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$itu = $db->fetch_row($userstats);
$alreadyhigh = $db->query("SELECT `userid` FROM `oldstats` WHERE `userid`=".$_SESSION['userid']."");
if($db->num_rows($alreadyhigh))
{
echo "You are already on a drug at this moment. Please wait for the effects of that drug to expire before attempting to use another one.<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$db->query("INSERT INTO `oldstats` VALUES(".$_SESSION['userid'].",".$itu['strength'].",".$itu['agility'].",".$itu['guard'].")");
$updatecalc = $db->query("SELECT ".$itd['oSTAT']." FROM `userstats` WHERE `userid`=".$_SESSION['userid']."");
$sta=$db->fetch_row($updatecalc);
$increase = ($sta[$itd['oSTAT']]/8)*$itd['oQUALITY'];
$expires = $itd['oQUALITY']*5;
$db->query("UPDATE `userstats` SET ".$itd['oSTAT']."=".$itd['oSTAT']."+$increase WHERE `userid`=".$_SESSION['userid']."");
$db->query("UPDATE `users` SET `expire`=$expires WHERE `userid`=".$_SESSION['userid']."");
$db->query("UPDATE `drugsowned` SET `oQTY`=`oQTY`-1 WHERE `oID`=".$_GET['ID']."");
$db->query("DELETE FROM `drugsowned` WHERE `oQTY`=0");
echo "After using ".stripslashes(htmlentities($itd['oNAME']))." You feel a high like you've never felt before and gain ".$increase." points to your ".stripslashes(htmlentities($itd['oSTAT']))." stat. This is only temporary so make use of it!";
}
else
{
echo "You are about to use some ".stripslashes(htmlentities($itd['oNAME']))." which will give you a temporary bonus to your ".stripslashes(htmlentities($itd['oSTAT'])).".<br />
If you wish to continue, simply confirm below and enjoy, you will be notified when your high wears off.<br />
<form action = 'druglab.php?action=druguse2&ID=".abs((int) $_GET['ID'])."' method = 'post'>
<input type = 'submit' value = 'Confirm' name = 'submit'>
</form>";
}
}
function market()
{
global $db,$it,$h;
if(!$_GET['ID'])
{
echo "You did not select a valid Drug ID.<a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$find = $db->query("SELECT `oID`,`oTYPE`,`oUSER`,`oQUALITY`,`oSTAT`,`oNAME`,`oQTY` FROM `drugsowned` WHERE `oUSER`=".$_SESSION['userid']." AND `oID`=".$_GET['ID']."");
if(!$db->num_rows($find))
{
echo "Invalid Selection. Either this drug does not exist or it does not belong to you!<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$mydrug = $db->fetch_row($find);
if($_POST['qty'] && $_POST['price'])
{
if($_POST['qty'] > $mydrug['oQTY'])
{
echo "You have attempted to place more on the market than you own. Please return and select a differant amount.<a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
echo "You have successfully added ".number_format($_POST['qty'])." units of ".stripslashes(htmlentities($mydrug['oNAME']))." to the market!
<a href='drugmarket.php'><strong>View</strong></a>";
$db->query("INSERT INTO `drugmarket` VALUES('',".$_POST['qty'].",".$_SESSION['userid'].",".$_POST['price'].",".$mydrug['oQUALITY'].",'".$mydrug['oNAME']."',".$mydrug['oTYPE'].",'".$mydrug['oSTAT']."')");
$db->query("UPDATE `drugsowned` SET `oQTY`=`oQTY`-".$_POST['qty']." WHERE `oID`=".$_GET['ID']."");
$db->query("DELETE FROM `drugsowned` WHERE `oQTY`=0");
}
else
{
echo "You have selected to add some of your ".stripslashes(htmlentities($mydrug['oNAME']))." to the market. Please select a Quantity to add.<br />
<form action='druglab.php?action=market&ID=".$_GET['ID']."' method='post'>
Amount to Add: <input type='text' name='qty' />
Price Requested: <input type='text' name='price'] />
<input type='submit' />
</form>";
}
}
function usersend()
{
global $db,$h,$it,$c;
if(!$_GET['ID'] || $_GET['ID'] != abs((int) $_GET['ID']))
{
echo "You did not select a valid drug ID.<strong><a href='druglab.php'>Back</a></strong>";
$h->endpage();
exit;
}
$find = $db->query("SELECT `oID`,`oTYPE`,`oUSER`,`oQUALITY`,`oSTAT`,`oNAME`,`oQTY` FROM `drugsowned` WHERE `oUSER`=".$_SESSION['userid']." AND `oID`=".$_GET['ID']."");
if(!$db->num_rows($find))
{
echo "You do not currently hold any drugs that you can send to other users. Please either purchase some or farm your own!<br /><a href='druglab.php'><strong>Back</strong></a>";
$h->endpage();
exit;
}
$dit = $db->fetch_row($find);
if($_POST['user'] AND $_POST['amount'])
{
if($_POST['amount'] > $dit['oQTY'])
{
echo "You are trying to send more than you have.<strong><a href='druglab.php'>Back</a></strong>";
$h->endpage();
exit;
}
echo "You successfully sent ".number_format($_POST['amount'])." units of ".stripslashes(htmlentities($dit['oNAME']))." to User ID ".abs((int) $_POST['user'])."
<a href='druglab.php'><strong>Back</strong></a>";
$db->query("INSERT INTO `drugsowned` VALUES('',".abs((int) $dit['oTYPE']).",".abs((int) $_POST['user']).",".abs((int) $dit['oQUALITY']).",'".mysql_real_escape_string($dit['oSTAT'])."','".mysql_real_escape_string($dit['oNAME'])."',".abs((int) $_POST['amount']).")");
$db->query("UPDATE `drugsowned` SET `oQTY`=`oQTY`-".abs((int) $_POST['amount'])." WHERE (`oUSER`=".$_SESSION['userid'].")");
$db->query("DELETE FROM `drugsowned` WHERE (`oQTY` < 0)");
}
else
{
echo "<form action='druglab.php?action=usersend&ID=".$_GET['ID']."' method='post'>
User: ".user_dropdown($c,'user')."<br />
Amount: <input type='text' name='amount' value='0' /><br />
<input type='submit' value='send drugs' /></form>
Or Enter the users ID you wish to send to.
<form action='druglab.php?action=usersend&ID=".$_GET['ID']."' method='post'>
User: <input type='text' name='user' value='0' /><br />
Amount: <input type='text' name='amount' value='0' /><br />
<input type='submit' value='Send Drug' /></form>";
}
}
/*
This Mod was Designed Free of Charge For the Members of
Makewebgames.com
Cronwerks.com
MasterMccodes.com
Dev-Forum.net
Mcaddons.com
This mod was solely designed and Developed by Immortal Thug.
Modifications, Plug-ins, add-ons are Welcomed, But please keep the original Copyright Notice.
Thanks to Zeddicus for baring with me on a few areas I got stuck on.
Thanks to CrimeGame for a few security functions you will find below.
Thanks to the members of Makewebgames.com for Throwing new Ideas my direction to add-on to this script.
If you like this mod and would like to see more like it Please contact me at
joshuawdams@hotmail.com
Thanks, and Enjoy.
*/
?>