i have a mod called hitman agency but dont have the sql and am bad at them stuff so can some one help me witht the sql
<?php
session_start();
require "globals.php";
if($ir['hospital'])
{
die("<font color=red><h3>This page has been blocked.</br /></h3><h4>You are currently in hospital for another {$ir['hospital']} minutes!</h4></font> ");
}
if($ir['jail'])
{
die("<font color=red><h3>This page has been blocked.</br /></h3><h4>You are currently in jail for another {$ir['jail']} minutes!</h4></font>");
}
//-- We print the hitman agency
print "<center><h3>Hitman Agency</h3>
<a href='hitmanagency.php?action=add'>Add Contract</a> | <a href='hitmanagency.php?action=about'>About</a> | <a href='hitmanagency.php?action=completedlist'>Hitman Missions Completed</a> | <a href='hitmanagency.php'>Available Missions</a> | <a href='hitmanagency.php?action=signup'>Become a Hitman</a><br /><br />";
switch($_GET['action'])
{
case "completedlist":
hitman_completedlist();
break;
case "about":
hitman_about();
break;
case "signup":
hitman_signup();
break;
case "add":
hitman_add();
break;
default:
hitman_index();
break;
}
function hitman_index()
{
global $db,$ir,$c,$userid,$h;
$q=$db->query("SELECT * FROM hitman_agency WHERE h_done=0 ORDER BY h_added ASC",$c);
if($db->num_rows($q) == 0)
{
print "There is no available hitman missions available";
} else {
print "<table width=80% border=0><tr><th>Payer</th><th>Target</th><th>Days Remaining</th><th>Payment</th><th>Fails</th><th>Take Job</th></tr>";
while($r=$db->num_rows($q))
{
$user1=$db->fetch_row($db->query("SELECT * FROM users WHERE userid={$r['h_from']}",$c));
$user2=$db->fetch_row($db->query("SELECT * FROM users WHERE userid={$r['h_to']}",$c));
if($r['h_daysleft'] == 0) { $d_text="Today"; } elseif($r['h_daysleft'] == 1) { $d_text="Tommorrow"; } elseif($r['h_daysleft'] == 7) { $d_text="One Week"; } elseif($r['h_daysleft'] == 31) { $d_text="One Month"; } else { $d_text=$r['h_daysleft']." days left"; }
print "<tr><td>{$user1['username']} [{$user1['userid']}]</td><td>{$user2['username']} [{$user2['userid']}]</td><td>$d_text</td><td><font color=green>\$".number_format($r['h_price'])."</font><br />";
if($r['h_crystals'] > 0)
{
print "<font color=maroon>and ".$r['h_crystals']." crystals</font>";
}
print "</td><td>".$r['h_fails']."</td><td>";
if($ir['hitman_user'] == 0)
{
print "<b>You need to be a hitman</b>";
} else {
print "<a href='attack.php?ID={$r['h_to']}'>Take Job</a>";
}
print "</td></tr>";
}
print "</table>";
}
}
function hitman_completedlist()
{
global $db,$ir,$c,$userid,$h;
print "Completed List.<br />";
$q=$db->query("SELECT h.*,u.* FROM hitman_agency h LEFT JOIN users u ON h.h_to=u.userid WHERE h.h_done=$userid",$c);
if($db->num_rows($q) == 0)
{
print "<B>You haven't completed any missions so far</b>";
} else {
$tc = 0;
$tcc = 0;
$targets = "These are your targets you have hit<br />
<table width=50% border=1><tr><th><b>Payer</b></th><th><b>Target</b></th></tr>";
while($r=$db->num_rows($q))
{
$tc+=$r['h_price'];
$tcc+=$r['h_crystals'];
$tr=mysql_fetch_array($db->query("SELECT * FROM users WHERE userid={$r['h_from']}",$c));
$targets .= "<tr><td><a href='viewuser.php?u={$tr['userid']}'>{$tr['username']}</a> [{$tr['userid']}]</td><td><a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> [{$r['userid']}]</td></tr>";
}
$targets .= "</table>";
print "<b>Missions Completed</b>: ".$db->num_rows($q)."<br />
<b>Total Payment (Game Money)</b>: \$$tc<br />
<b>Total Payment (Crystals)</b>: $tcc crystals<br />
<br />
".$targets;
}
}
function hitman_about()
{
global $db,$ir,$c,$userid,$h;
print "About/How to use Hitman Agency.<br />
<li>If you cannot defeat someone or you want to make a hidden attack, You can open a hitman contract against a user for a following price in which a hitman who has signed up will be available to take that contract
and upon winning, they will get paid the amount chosen and your enemy/contracted user will be attacked.</li>
<li>Hitman Missions are completely dependant, We dont guarantee attacks in a certain amount of time. You can only put a hitman mission up for upto 7 days, After 7 days it will be removed.</li>
<li>To become a hitman, a \$50,000 a day will occur. And signing up as a hitman allows you to take these missions and earn a bundle of cash and vouchers.</li>
<li>If you fail a mission, it will occur on the system as 1 fail. If the hitman has recieved over 10 fails, The contract will be removed.</li>
<li>Hitman Missions cannot be hit against owners or NPCs.</li>";
}
function hitman_signup()
{
global $db,$ir,$c,$userid,$h;
if($ir['level'] <= 3)
{
print "<b>You must be over level 3 to become a hitman.</b>";
} elseif($ir['money'] < 50000)
{
print "<b>You dont have enough money to renew/become your hitman status</b>";
} elseif($ir['daysold'] <= 10)
{
print "<b>You need to be at least over 10 days to have a hitman status</b>";
} else {
if($_POST['days'])
{
$req=(int) $_POST['days']*50000;
if($ir['money'] < $req)
{
print "You dont have enough funds to purchase this amount of days.";
$h->endpage();
exit();
}
if($ir['hitman_user'] > 0)
{
print "You have successfully renewed your hitman status!<br />";
} else {
print "You have successfully become a hitman!<br />";
}
$ir['hitman_user']+=(int) $_POST['days'];
print "<b>Upon this date, you now have {$ir['hitman_user']} days as a hitman</b><br />
<a href='hitmanagency.php'>Back</a><br />";
$db->query("UPDATE users SET hitman_user={$ir['hitman_user']},money=money-$req WHERE userid=$userid",$c);
} else {
print "Sign up as a hitman.<br />
Each day as a hitman costs <b>\$50,000</b> a day<br />";
if($ir['hitman_user'] > 0) {
print "You currently have <b>{$ir['hitman_user']}</b> days left as a hitman<br />"; }
print "<form action='hitmanagency.php?action=signup' method='post'>
Days: <input type='text' name='days' value=''><br />
<input type='submit' value='Submit'></form>";
}
}
}
function hitman_add()
{
global $db,$ir,$c,$userid,$h;
if($ir['level'] <= 5)
{
print "<b>You must be over level 5 to start a hitman contract.</b>";
} elseif($ir['daysold'] <= 10)
{
print "<b>You need to be at least over 10 days old to set a hitman contract.</b>";
} else {
if($_POST['user'] and $_POST['amount'] and $_POST['days'])
{
$q=$db->query("SELECT * FROM users WHERE userid={$_POST['user']}",$c);
$r=$db->num_rows($q);
if($db->num_rows($q) == 0)
{
print "<b>You can only put a hitman mission on a user that actually exists!</b>";
} elseif($_POST['user'] == $userid)
{
print "<b>Haha, Trying to make hitman contracts on yourself?</b>";
} elseif($r['lastip'] == $ir['lastip'])
{
print "<b>Haha, Trying to make hitman contracts on your own IP mate?</b>";
} elseif($_POST['amount'] > $ir['money'] || $_POST['crystals'] > $ir['crystals'])
{
print "<b>You dont have the right funds to do these vast amounts.</b>";
} elseif($_POST['amount'] <= 0 || $_POST['crystals'] < 0)
{
print "<b>You either have posted no money or your trying to cheat.</b>";
} elseif($_POST['days'] < 0 or ($ir['donatordays'] == 0 and $_POST['days'] > 3))
{
print "<b>Your not a donator so put your days to 1-3 days.</b>";
} elseif($ir['donatordays'] > 0 and $_POST['days'] > 7)
{
print "<b>You are a donator but you cant list a hitman contract for over 7 days.</b>";
} else {
$time=time();
$db->query("INSERT INTO hitman_agency (h_id,h_from,h_to,h_daysleft,h_price,h_crystals,h_done,h_fails,h_added) VALUES ('NULL', '{$userid}', '{$_POST['user']}', '{$_POST['days']}', '{$_POST['amount']}', '{$_POST['crystals']}', '0', '0', '{$time}');",$c) or die($db->error());
$db->query("UPDATE users SET money=money-{$_POST['amount']} WHERE userid=$userid",$c);
if($_POST['crystals'] > 0)
{
$db->query("UPDATE users SET crystals=crystals-{$_POST['crystals']} WHERE userid=$userid",$c);
}
print "<B>Hitman Mission Added</B><br />
You will have a remaining <b>$_POST[days]</b> days for it to be took<br />
If the mission has been failed more than 9 times, it will be removed<br />
<a href='hitmanagency.php'>Back</a><br />";
}
} else {
print "Adding a hitman contract.<br />
<script language='JavaScript'>
function checkError()
{
var id=document.getElementById('cash').value;
var money=document.getElementById('mycash').value;
var days=document.getElementById('days').value;
var donator=document.getElementById('donator').value;
if(!id || !money || !days)
{
alert('Please go back and fill in all fields.');
return false;
exit;
}
if(id < 0)
{
alert('Trying to cheat, eh?');
return false;
exit;
} elseif(id > money)
{
alert('You dont that much money.');
return false;
exit;
} elseif(days < 0 || days>7)
{
alert('Your days cannot be over 7 or under 0.');
return false;
exit;
} elseif(donator == 0 && days>3)
{
alert('Your days cannot be over 3 because your not a donator.');
return false;
exit;
}
}
</script>
<b>If your not a donator, you can only put your maximum days as 3.</b><br />
<form action='hitmanagency.php?action=add' method='post'>
User ID: <input type='text' name='user' value=''><br />
<input type='hidden' id='mycash' value='{$ir['money']}'><br />
Cash: <input type='text' name='amount' value='' id='cash'><br />
Crystals: <input type='text' name='crystals' value=''><br />
<input type='hidden' id='donator' value='{$ir['donatordays']}'>
Days to show up: <input type='text' name='days' value='' maxlength='1' id='days'><br />
<input type='submit' value='Submit' onclick='checkError()'></form>";
}
}
}
print '</center>';
$h->endpage();
?>