hi im looking for some way in php only to allow numbers in a text box say like in this part of a code here there is a way they can add certain marks in the reserve box that will give them more of what they sould get so need to beable to block all letters and signs and only allow 4 for the max length
PHP Code:
<?
include("html.php");
$x = array('#','-','+','&','a','n','d','w','h','e','r','"','$','%','&','^');
$y = array('','','','','','','','','','','','','','','','');
$reserves = str_replace($x, $y, trim($_POST['reserves']));
function check_reserves($reserves) {
$i = '0';
$numz = array(1,2,3,4,5,6,7,8,9,0);
$reserves_check = preg_split('//', $reserves, -1, PREG_SPLIT_NO_EMPTY);
foreach($reserves_check as $rc) {
if(!in_array($rc, $numz)) $i++;
}
if($i != '0') return 'bad';
else return 'OK';
}
$pimp = mysql_fetch_array(mysql_query("SELECT code,status,alert FROM $tab[pimp] WHERE id='$id';"));
$res = mysql_fetch_array(mysql_query("SELECT res FROM $tab[pimp] WHERE id='$id';"));
if (isset($_POST["alert"])) $alert=$_POST["alert"]; else $alert=0;
if(($alert) && ($pmp["31"] == admin)){ mysql_query("UPDATE $tab[pimp] SET alert='$alert' WHERE id>0 "); }
if(($reserves > 0) && (!preg_match ('[0-9]', $reserves)) && (!strstr($reserves,"+")) && (!strstr($reserves,"-")) && (!strstr($reserves,".")) && (!strstr($reserves,"/")) && (!strstr($reserves,"<")) && (!strstr($reserves,">")) && (!strstr($reserves,")")) && (!strstr($reserves,"(")) && (!strstr($reserves,"&")) && (!strstr($reserves,"@")) && (!strstr($reserves,"=")) && (!strstr($reserves,"*")) && ($reserves <= $res[0]))
//if(($reserves) != bad) && ($reserves > 0) && (!preg_match ('[0-9]', $reserves)) && (!strstr($reserves,"+")) && (!strstr($reserves,"-")) && (!strstr($reserves,".")) && (!strstr($reserves,"/")) && (!strstr($reserves,"<")) && (!strstr($reserves,">")) && (!strstr($reserves,")")) && (!strstr($reserves,"&")) && (!strstr($reserves,"@")) && (!strstr($reserves,"=")) && (!strstr($reserves,"*")) && ($reserves <= $res[0]))
{
$reserves = substr($reserves, 0, 4);
mysql_query("UPDATE $tab[pimp] SET trn=trn+$reserves, res=res-$reserves WHERE id='$id'");
}
$pmp = mysql_fetch_array(mysql_query("SELECT pimp,rank,nrank,city,networth,money,trn,res,condom,medicine,crack,weed,glock,shotgun,uzi,ak47,whore,thug,whappy,thappy,payout,crew,msg,atk,ivt,lowrider,attin,attout,lastattackby,lastattack,cmsg,rlauncher,hummer FROM $tab[pimp] WHERE id='$id'"));
$crw = mysql_fetch_array(mysql_query("SELECT name,founder,icon FROM $tab[crew] WHERE id='$pmp[21]';"));
$cty = mysql_fetch_array(mysql_query("SELECT name FROM $tab[city] WHERE id='$pmp[3]';"));
//31 = rocket launcher - hummer = 32
// turn info
$turnupdate = mysql_fetch_array(mysql_query("SELECT lastran FROM $tab[cron] WHERE cronjob='turns'"));
$game = mysql_fetch_array(mysql_query("SELECT speed,maxbuild FROM $tab[game] WHERE round='$gp'"));
function sounds(){
global $id, $tab, $site;
$sound = mysql_fetch_array(mysql_query("SELECT sounds,msg,atk FROM $tab[pimp] WHERE id='$id';"));
if($sound[0] != disabled)
{
if($sound[2] >= 1){?>
<body bgcolor="#FFFFFF">
<embed src="<?=$site[img]?>attack.swf" quality="high" width="1" height="1" menu="false" type="application/x-shockwave-flash" pluginpage="http://www.macromedia.com/go/getflashplayer"></embed>
<?}
elseif($sound[1] >= 1){?>
<embed src="<?=$site[img]?>message.swf" quality="high" width="1" height="1" menu="false" type="application/x-shockwave-flash" pluginpage="http://www.macromedia.com/go/getflashplayer"></embed>
<?}
}
}
$tw=$pmp[12]+$pmp[13]+$pmp[14]+$pmp[15]+$pmp[31];
$figure=$time - $pmp[28];
$count=round($figure / (60*60*24));
if(($alert) && ($pmp[0] == admin || mod)){ mysql_query("UPDATE $tab[pimp] SET alert='$alert', newalert='1' WHERE id>0;"); }
$tillmax=number_format(((($game[1] - $pmp[6])/($game[0] * 6))*60)*60,0);
$tillmax = strtotime("+".str_replace(' ','',str_replace(',','',$tillmax))." seconds", $turnupdate[0]);
GAMEHEADER("Play the game");
?>
<table width="100%" align="center" cellspacing="0" cellpadding="12" border="0">
<tr>
<td align="center" valign="top"><table width="100%">
<tr>
<td valign="bottom"><table cellspacing="0" cellpadding="0">
<tr>
<?if($crw[2]){?>
<td height="32" valign="bottom"><a href="gang.php?cid=<?=$pmp[21]?>&gp=<?=$gp?>"><img src="<?=$crw[2]?>" border="0" width="32" height="32"></a> </td>
<?}?>
<td><font color="7777CC">ranked</font>
<?=$pmp[1]?>
<font color="7777CC">in
<?=$cty[0]?>
,</font>
<?=$pmp[2]?>
<font color="7777CC">national<br>
currently worth</font> $
<?=commas($pmp[4])?>
<?if($pmp[21] > 0){?>
<br>
<?if($pmp[0] == $crw[1]){?>
founder of
<?}else{?>
member of
<?}?>
<a href="gang.php?cid=<?=$pmp[21]?>&gp=<?=$gp?>">
<?=$crw[0]?>
</a>.
<?}?>
</small></td>
</tr>
</table></td>
<td align="right" valign="bottom"><a href="mailbox.php?gp=<?=$gp?>">Open Mailbox</a><br>
<?if($pmp[22] == 1){?>
<font color="#66CCFF">you have 1 new message</font>
<?}elseif($pmp[22] > 1){?>
<font color="#66CCFF">you have
<?=$pmp[22]?>
new messages</font>
<?}else{?>
you have no new messages
<?}?>
<?if($pmp[23] == 1){?>
<br>
<font color="#7777CC">you have been attacked!</font>
<?}elseif($pmp[23] > 1){?>
<br>
<font color="#7777CC">you have been attacked
<?=$pmp[23]?>
times!</font>
<?}?>
<?if($pmp[24] == 1){?>
<br>
<font color="#0066CC">you have a invitation!</font>
<?}elseif($pmp[24] > 1){?>
<br>
<font color="#0066CC">you have
<?=$pmp[24]?>
new invitations!</font>
<?}elseif($pmp[30] > 0){?>
<br>
<a href="cboard.php?cid=<?=$pmp[21]?>&gp=<?=$gp?>">
<?=$pmp[30]?>
new crew message</a>
<?}?></td>
</tr>
</table>
<?if($bigman){?>
<font color="#7777CC" size="3">
<?=$bigman?>
</font><br>
<?}?>
<br>
<font size="+1"><font color="3366FF">
<?=commas($pmp[6])?>
turns</font> and <font color="3366FF">$
<?=commas($pmp[5])?>
cash</font> on hand.</font> <br>
Max turns in
<?=countup($tillmax);?>
<?if($takeout == reserves){?>
<br>
<form method="post" action="index.php?gp=<?=$gp?>">
how many turns would you like to add?
<input type="text" class="text" maxlength="4" size="7" name="reserves">
<input type="submit" class="button" value="apply">
</form>
<?}else{?>
<?if($pmp[7] != 0){?>
<br>
<a href="?takeout=reserves&gp=<?=$gp?>"><font color="#FFFFFF">you also have</font>
<?=commas($pmp[7])?>
<font color="#FFFFFF">reserve turns</font></a></small>
<?}?>
<?}?>
<br>
<br>
<table>
<tr>
<td><table>
<tr>
<td align="right"><font color="7777CC">glocks:</font></td>
<td><?=commas($pmp[12])?></td>
</tr>
<tr>
<td align="right"><font color="7777CC">shotguns:</font></td>
<td><?=commas($pmp[13])?></td>
</tr>
<tr>
<td align="right"><font color="7777CC">uzi's:</font></td>
<td><?=commas($pmp[14])?></td>
</tr>
<tr>
<td align="right"><font color="7777CC">AK-47's:</font></td>
<td><?=commas($pmp[15])?></td>
</tr>
<tr>
<td align="right"><font color="7777CC">rocketlaunchers:</font></td>
<td><?=commas($pmp[31])?></td>
</tr>
<tr>
<td align="right"><font color="7777CC">cigs:</font></td>
<td><?=commas($pmp[8])?></td>
</tr>
<tr>
<td align="right"><font color="7777CC">meds:</font></td>
<td><?=commas($pmp[9])?></td>
</tr>
<tr>
<td align="right"><font color="7777CC">moonshine:</font></td>
<td><?=commas($pmp[10])?></td>
</tr>
<tr>
<td align="right"><font color="7777CC">beer:</font></td>
<td><?=commas($pmp[11])?></td>
</tr>
<?if($pmp[25] > 0){?>
<tr>
<td align="right"><font color="7777CC">truck:</font></td>
<td><?=commas($pmp[25])?></td>
</tr>
<tr>
<td align="right"><font color="#7777CC">rigs</font></td>
<td><?=commas($pmp[32])?></td>
</tr>
<?}?>
</table></td>
<td width="50"></td>
<td><table>
<tr>
<td><nobr>
<?=commas($pmp[17])?>
hustlers<br>
<font color="3366FF">
<?=$pmp[19]?>
%</font> <font color="7777CC">happy, with <br>
<?=commas($tw)?>
weapons total </nobr> </td>
</tr>
</table>
<br>
<table>
<form method="post" action="set.php?gp=<?=$gp?>">
<tr>
<td><nobr>
<?=commas($pmp[16])?>
bootleggers<br>
<font color="3366FF">
<?=$pmp[18]?>
%</font> <font color="7777CC">happy, at <br>
<input type="text" class="text" name="pay" size="3" value="<?=$pmp[20]?>">
% payout.
<input type="submit" class="button" name="setpay" value="set">
</nobr> </td>
</tr>
</form>
</table></td>
</tr>
</table>
<p><br>
<font color="#7777CC">attacks in:</font>
<?=$pmp[26]?>
<font color="#7777CC">out:</font>
<?=$pmp[27]?>
<br>
<br>
<?if($turnupdate[0]){?>
you will receive <font color="#7777CC">
<?=$game[0]?>
</font> <font color="#7777CC">turns</font> in:
<?=countup($turnupdate[0]+600)?>
<br>
<small>you can hold up to <font color="#7777CC">
<?=commas($game[1])?>
</font> <font color="#7777CC">turns</font>.
<?}else{?>
<i><b>Turns will start processing in less then 10 minutes...</b></i>
<?}?>
<?=sounds()?>
</p>
<? if($pmp[31] == admin){?>
<form method="post" action="index.php?rid=<?=$rid?>">
<b>admin panel:</b> alert all pimps:
<input type="text" class="text" name="alert" size="20">
<input type="submit" name="alertpimp" value="alert!">
</form>
<br>
<?}?>
</tr>
</table>
<?
GAMEFOOTER();
?>