All pastes #436837 Raw Edit

Stuff

public text v1 · immutable
·published 2007-04-12 19:18 UTC
rendered paste body
<?
include "vsys.php";
if ($cgi['buy_merc']){
	$merc=getCommonInfo();
	
	if ($cgi['mercs_attack']){
		$cgi['mercs_attack'] = max(0, intval($cgi['mercs_attack']));
		if ($cgi['mercs_attack']>$merc->attackSpecCount)$cgi['mercs_attack']=$merc->attackSpecCount;
		$gold=$cgi['mercs_attack']*$conf["mercenaries"]["atack"]["prise"];
		$user=getUserDetails($_SESSION['isLogined']," gold ");
		if ($user->gold>$gold){
			updateMercenary(" attackSpecCount=attackSpecCount-{$cgi['mercs_attack']} ");
			updateUser($_SESSION['isLogined'], " trainedAttackMerc=trainedAttackMerc+{$cgi['mercs_attack']} , gold=gold-$gold ");
		}else{
			$strErr="You do not have enough money";
		}
	}
	if ($cgi['mercs_defend']){
		$cgi['mercs_defend'] = max(0, intval($cgi['mercs_defend']));
		if ($cgi['mercs_defend']>$merc->defSpecCount)$cgi['mercs_defend']=$merc->defSpecCount;
		$gold=$cgi['mercs_defend']*$conf["mercenaries"]["defence"]["prise"];
		$user=getUserDetails($_SESSION['isLogined']," gold ");
		if ($user->gold>$gold){
			updateMercenary(" defSpecCount =defSpecCount -{$cgi['mercs_defend']} ");
			updateUser($_SESSION['isLogined'], " trainedDefMerc=trainedDefMerc+{$cgi['mercs_defend']}  , gold=gold-$gold ");
		}else{
			$strErr="You do not have enough money";
		}
	}
	if ($cgi['mercs_general']){
		$cgi['mercs_general'] = max(0, intval($cgi['mercs_general']));
		if ($cgi['mercs_general']>$merc->untrainedCount)$cgi['mercs_general']=$merc->untrainedCount;
		$gold=$cgi['mercs_general']*$conf["mercenaries"]["untrained"]["prise"];
		$user=getUserDetails($_SESSION['isLogined']," gold ");
		if ($user->gold>$gold){
			updateMercenary(" untrainedCount =untrainedCount -{$cgi['mercs_general']} ");
			updateUser($_SESSION['isLogined'], " untrainedMerc=untrainedMerc+{$cgi['mercs_general']} , gold=gold-$gold ");
		}else{
			$strErr="You do not have enough money";
		}
	}
	header("Location: mercs.php?strErr=$strErr");
}
?>