View Single Post
Old 25.04.2005, 22:46   #13
astranger
Архивный участник
 
Join Date: Mar 2005
Posts: 41
Default

Here is the php script for adding adena to a character

Code:
<?
/* PHP script with HTML code
   for adding adena to a character 
   2005 - DiAvOl
*/

session_start();

/* Replace xxx.xxx.xxx.xxx with your mssql host
   Replace sql_user with your mysql username and
   password with your mssql password
*/

$mssql_host = 'xxx.xxx.xxx.xx';
$mssql_user = 'sql_user';
$mssql_pass = 'password';

/* Add here a description and an IP of a host which you allow 
   to use this page and add adena to a character
   Example: 'home'=>"1xx.xx.2.143", 'work'=>"2xx.xx1.xx.xx" etc
*/ 

$store_cashier = array('local'=>"127.0.0.1", 'pc2'=>"xxx.xxx.xxx.xxx");

$store = "";

foreach ($store_cashier as $key=>$value) {
	$rip = $_SERVER['REMOTE_ADDR'];
	if ($rip == $value) { $store = $key; } 
}

if ($store != "") {
	$_SESSION['store'] = $store;
} else {
	die("You are not permitted to view this page, actually who gave you this url?");
}

function antiinjection($str) {
	$banwords = array ("'", ",", ";", "--");
	if ( eregi ( "[a-zA-Z0-9]+", $str ) ) {
		$str = str_replace ( $banwords, '', strtolower ( $str ) );
	} else {
		$str = NULL;
	}
	return $str;
}
?>
<html>
<head>
<title>Lineage II Adena Managment</title>
<style>
.style1 {
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-size:14px;
}
.formPaneGeneral {
	font: normal 12pt/10px Verdana, sans-serif;
	background:#F2FDFF;
	border: 1px groove #6600FF;
	vertical-align: middle;
}
.formButtonGeneral {

	font: 9pt/10pt Verdana, sans-serif;
	color:#333333;
	background:#F2FDFF;
	border: 1px solid #666666;
}

.border {
	border: 1px groove #000000;
}
</style>
</head>
<body topmargin="150" leftmargin="0" rightmargin="0" bottommargin="0" bgcolor="#CCCCCC">
<div align="center">
<table cellpadding="0" cellspacing="0" border="1" bgcolor="#FFCC33">
	<tr>
		<td align="center" bgcolor="#000000">
		<font face="Geneva, Arial, Helvetica, sans-serif" size="+1" color="#FFFFFF">ADENA MANAGMENT</font>		
		</td>
	</tr>
	<tr>
		<td>
<form name="addadena" method="post" action="addadena.php">
<table cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td align="center" colspan="2" bgcolor="#FFCC99" class="border">
<?
	$error = 0;
	$noname = FALSE;
	$noamount = FALSE;
	
	if ($_POST['action']) {
	
	if ($_POST['charname']) { $character_name = antiinjection($_POST['charname']); }
	else { echo "<font face=\"Times New Roman, Times, serif\" color=\"#FF0000\">- Please insert a character name</font>
"; $error=1; $noname = TRUE; }
	
	if ($_POST['amount']) { $amount = antiinjection($_POST['amount']); }
	else { echo "<font face=\"Times New Roman, Times, serif\" color=\"#FF0000\">- Please insert adena amount</font>
"; $error=2; $noamount = TRUE; }
	}
	
	if (($error == 0) && $_POST['action']) {
	
	$connection = mssql_connect($mssql_host,$mssql_user,$mssql_pass);
	if ($connection) {
		mssql_select_db('lin2world',$connection); 
		$query = mssql_query("EXEC lin_GetIdSetAmmount '$character_name', $amount");
		$arr = mssql_fetch_array($query);
		$last_msg = mssql_get_last_message();
		if (empty($last_msg) && empty($arr['amount'])) {
			echo "<font face=\"Times New Roman, Times, serif\" color=\"#FF0000\">Account does not exists</font>";
			mssql_close($connection);
		} else if(empty($arr['amount'])) {
			echo "<font face=\"Times New Roman, Times, serif\" color=\"#FF0000\">-$last_msg</font>";
			mssql_close($connection);
		} else {
		echo "<font face=\"Times New Roman, Times, serif\" color=\"#0000FF\">{$amount} adena added to $character_name
Total: {$arr['amount']} adena</font>"; }
		mssql_close($connection);
	} else { 
		echo "Can't connect to the database"; }
	}

?>
		</td>
	</tr>
	<tr>
		<td align="right" height="30">
		<span class="style1"> <? echo ($noname?"<font color=\"#FF0000\">Character Name</font>" : "Character Name"); ?></span>
		</td>
		<td align="left" width="150">
		<input type="text" name="charname" size="15" maxlength="15" class="formPaneGeneral" value=<? echo ($_POST['charname'] ? $_POST['charname'] : "" ); ?> >
		</td>
	</tr>
	<tr>
		<td height="5">
		</td>
	</tr>
	<tr>
		<td align="right">
		<span class="style1"><? echo ($noamount?"<font color=\"#FF0000\">Adena amount</font>" : "Adena amount"); ?></span>
		</td>
		<td align="left">
		<input type="text" name="amount" size="15" maxlength="15" class="formPaneGeneral" value=<? echo ($_POST['amount'] ? $_POST['amount'] : "" ); ?>>
		</td>
	</tr>
	<tr>
		<td>
		
		</td>
		<td align="left" height="30">
		<input type="submit" name="submit" value="Add Adena" class="formButtonGeneral">
		<input type="hidden" name="action" value="action">
		</td>
	</tr>
</table>
		</td>
	</tr>
	<tr>
		<td height="15" bgcolor="#000000">
		</td>
	</tr>
</table>
</form>
</div>
</body>
</html>
astranger is offline