- Joined
- Nov 23, 2008
- Messages
- 644
- Reaction score
- 572
Така имах rq да направя web bank в която може да си складирате zen-а.
Файловете са 5 (+1 Query) и скрипта работи с muweb 0.8
1 файл bankgo.php слага се в modules/
addzen.php пак в modules/
get.php
bank.php той също се слага там.
conreal.php в главната директория!
IMG:
ИМА ЛИМИТ! Той е 9223372036854775807
Файловете са 5 (+1 Query) и скрипта работи с muweb 0.8
1 файл bankgo.php слага се в modules/
PHP:
<center>
<center>
<?php
include "conreal.php";
if (htmlspecialchars(trim($_POST['char'])))
{
$charc=htmlspecialchars(trim($_POST['char']));
$_SESSION['charses']=$charc;
$selitems=mssql_fetch_array(mssql_query("SELECT * from Character where Name='".$_SESSION['charses']."'"));
$zen=$selitems['Money'];
echo "Имаш $zen zen. Можеш да го сложиш в web bank-а.";
echo "<br>
<form action='index.php?op=addzen' method='post'>
<input type='hidden' value='".$_SESSION['charses']."' name='usr'>
<input type='text' value='$zen' name='zen'>
<input type='submit' value='Добави'>
</form>
";
}
?>
<br><br>
<?php
$accbalance=mssql_fetch_array(mssql_query("SELECT * from webbank where acc='".$_SESSION['user']."'"));
$accbzen=$accbalance['zen'];
echo "Баланс на акаунта $accbzen zen<br><br>";
?>
<form action='index.php?op=get' method='post'>
<input type='hidden' value='<?php echo "".$_SESSION['charses']."" ?>' name='usr'>
<input type='text' value='<?php echo "$accbzen"; ?>' name='zen'>
<input type='submit' value='Вземи'>
</form>
</center>
addzen.php пак в modules/
PHP:
<?php
include "conreal.php";
if (htmlspecialchars(trim($_POST['zen'])) and htmlspecialchars(trim($_POST['usr'])))
{
$usr=htmlspecialchars(trim($_POST['usr']));
$zen=htmlspecialchars(trim($_POST['zen']));
$zencheck=mssql_fetch_array(mssql_query("SELECT * from Character where Name='$usr'")) or die(mssql_get_last_message());
$mm=$zencheck['Money'];
if ($mm>=$zen)
{
$ifex=mssql_num_rows(mssql_query("SELECT * from webbank where acc='".$_SESSION['user']."'"));
if ($ifex=="1")
{
$upd=mssql_query("UPDATE webbank set zen=zen+$zen where acc='".$_SESSION['user']."'") or die(mssql_get_last_message());
}
else
{
$upd=mssql_query("INSERT INTO webbank (zen, acc) VALUES('$zen', '".$_SESSION['user']."')") or die(mssql_get_last_message());
}
$upd1=mssql_query("UPDATE Character set Money=Money-$zen where Name='$usr'");
echo "Вие успешно добавихте $zen в webbank-а.";
}
else
{
echo "Нямаш достатъчно zen.";
}
}
?>
get.php
PHP:
<?php
include "conreal.php";
if (htmlspecialchars(trim($_POST['zen'])) and htmlspecialchars(trim($_POST['usr'])))
{
$usr=htmlspecialchars(trim($_POST['usr']));
$zen=htmlspecialchars(trim($_POST['zen']));
$cs=mssql_fetch_array(mssql_query("SELECT * from Character where name='$usr'")) or die(mssql_get_last_message());
$mc=$cs['Money'];
$zencheck=mssql_fetch_array(mssql_query("SELECT * from webbank where acc='".$_SESSION['user']."'")) or die(mssql_get_last_message());
$mm=$zencheck['zen'];
if ($mc+$zen>"2000000000")
{
echo "Zena в героя надвишава 2 000 000 000 zen";
}
else
{
if ($mm>=$zen)
{
$upd1=mssql_query("UPDATE webbank set zen=zen-$zen where acc='".$_SESSION['user']."'");
$upd3=mssql_query("UPDATE Character set Money=Money+$zen where Name='$usr'");
echo "Вие успешно добавихте $zen в героя $usr.";
}
else
{
echo "Нямаш достатъчно zen.";
}
}
}
?>
bank.php той също се слага там.
PHP:
<?php
include "conreal.php";
?>
<center>
<?php
if ($_SESSION['user']==TRUE)
{
$acc=$_SESSION['user'];
?>
<?php
$accbalance=mssql_fetch_array(mssql_query("SELECT * from webbank where acc='".$_SESSION['user']."'"));
$accbzen=$accbalance['zen'];
echo "Баланс на акаунта $accbzen zen<br><br>";
?>
Character
<form action="index.php?op=bankgo" method="post">
<select name="char">
<?php
$s=mssql_query("SELECT * from character where AccountID='$acc'");
while($r=mssql_fetch_array($s))
{
$nm=$r['Name'];
echo "<option value='$nm'>$nm</option>";
}
?>
</select>
<br><br>
<input type="submit" value="Напред" name="sf">
</form>
<?php
}
?>
</center>
conreal.php в главната директория!
PHP:
<?php
$conn=mssql_connect('localhost','sa','Паролата');
$selected=mssql_select_db('MuOnline', $conn);
?>
SQL > Добавя се от Query Analizer-a в DB MuOnline
Code:
CREATE TABLE [webbank] (
[zen] [bigint] NULL ,
[acc] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
IMG:
Last edited: