bachcotsau
06-04-09, 08:32 AM
Hiện chức năng Nạp thẻ chờ Admin xác nhận đã làm xong, muốn lấy thì phân tích các code sau của mình rồi add vào nhé.
mail.php
<?
if (eregi("mail.php", $_SERVER['SCRIPT_NAME'])) { die ("<META <b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b> content=0;URL=<b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b>>"); }
require('ketnoi_db.php');
?><br>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<?
include("$thumuc/XuLy_TK.php");
if (isset($_POST["delete_msg_inbox"])){
option::delete_mail();}
if (isset($_GET['id']) && isset($_SESSION['user'])){
$news_id = $_GET['id'];
option::doc_mail();
$xem_mail = $db->Execute("select tu,tieu_de,loi_nhan,tinh_trang,vao_luc,id from Tin_nhan where id=? order by id desc",array($news_id));
$row2 = $xem_mail->fetchrow();
echo('
<table class="sort-table" id="table-1" border="0" cellpadding="0" cellspacing="0"><tbody>
<thead><tr><td align="center"><b>'.$row2[1].'</b></td></tr></thead>
<tr><td align="center" width="100%">
<table width="510" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="40%" scope="row"><div align="right">Từ :</div></td>
<td width="60%" colspan="2" scope="row">
<div align="left">'.$row2[0].'</div></td>
</tr>
<tr>
<td scope="row" align="right">Vào lúc :</td>
<td colspan="2" scope="row"><div align="left">'.$row2[4].'</div></td>
</tr>
<tr>
<td colspan="3" valign="top" scope="row">
<fieldset><legend align="center"><b>Tin nhắn</b></legend><div align="left">'.$row2[2].'</div></td></fieldset>
</tr>
</table>
</td></tr></table>
');}
?>
</div></td>
</tr>
</table>
<fieldset><legend align="center"><b>Danh sách tin nhận</b></legend>
<table border="0" cellpadding="0" cellspacing="0" width="505">
<tr><td align="center" width="505">
<?
$account_id = stripslashes($_SESSION['user']);
$tim_mail = $db->Execute("SELECT tu,toi_acc,tieu_de,loi_nhan,tinh_trang,vao_luc,xem _luc,id from Tin_nhan where toi_acc='".secure($account_id)."' order by id desc");
echo '<table class="sort-table" id="table-1" border="0" cellpadding="0" cellspacing="0" width="100%">
<thead><tr align="center">
<td width="10">#</td>
<td width="200" class=text_statistics><b>Tiêu đề</b></td>
<td width="10" class=text_statistics><b>Xóa</b></td>
<td width="80" class=text_statistics><b>Đã xem</b></td>
</tr></thead>';
for($i=0;$i < $tim_mail->numrows();++$i)
{
$msg = $tim_mail->fetchrow();
$rank = $i+1;
if($msg[4] == '0'){$msg[4] ='Chưa xem';}
if($msg[4] == '1'){$msg[4] =''.$msg[6].'';}
$msg_table_delete ="<table border='0' cellpadding='0' cellspacing='0'>
<tr>
<td><form action='' method='post' name='delete_msg_inbox' id='delete_msg_inbox'>
<input onclick='return confirm(\"Bạn chắc chắn muốn xóa tin nhắn này ?\");' name='Delete' type='submit' id='Delete' value='Xóa' class='button'>
<input name='idm' type='hidden' id='idm' value=$msg[7]>
<input name=delete_msg_inbox type=hidden id=delete_msg_inbox value=delete_msg_inbox>
</form></td>
</tr></table>";
$msg[2]= substr($msg[2],0,70);
echo "<tbody><tr align='center'>
<td class=text_statistics>$rank</td>
<td class=link_content align=left><a href='BachCot-ThongTin-mail-$msg[7].ClbMuVn'>$msg[2]...</a></td>
<td>$msg_table_delete</td>
<td class=text_statistics>".$msg[4]."</td>
</tr></tbody>";
}
?>
</TABLE>
</td>
</tr>
</table>
</fieldset>
XuLy_TK.php
function napthe_dt()
{
require("ketnoi_db.php");
$account_id = stripslashes($_SESSION['user']);
$td = stripslashes($_POST['loaithe']);
$menhgia = stripslashes($_POST['menhgia']);
$macao = stripslashes($_POST['macao']);
$serial = stripslashes($_POST['seri']);
$date=date("d-m-Y G:i");
$full_the = "Loại thẻ: $td<br>Mệnh Giá: $menhgia<br>Mã Cào: $macao<br>Serial: $serial";
if (empty($td) || empty($menhgia) || empty($macao) || empty($serial)){
echo "$warning_start Bạn phải điền đủ thông tin! $warning_end";}
else{
$execute_sql_script = $db->Execute("INSERT INTO Tin_nhan (tu,toi_acc,tieu_de,loi_nhan,vao_luc) VALUES (N'".secure($account_id)."','Admin',N'".secure($td)."',N'".secure($full_the)."',N'$date')
");
echo "$ok_start Quá trình nạp thẻ hoàn tất,thời gian chờ kiểm tra trong 24 Tiếng. $ok_end";
}
}
function gui_mail()
{
require("ketnoi_db.php");
$account_id = stripslashes($_COOKIE['administrator']);
$td = stripslashes($_POST['tieude']);
$to_acc = stripslashes($_POST['toi_acc']);
$mail = fixnew($_POST['new_msg']);
$date=date("d-m-Y G:i");
$check_tk = $db->Execute("SELECT memb___id FROM MEMB_INFO WHERE memb___id=?",array(secure($to_acc)));
$check = $check_tk->numrows();
if (
empty($account_id) ||
empty($td) ||
empty($to_acc) ||
empty($mail)){
echo "$error_1 Bạn phải điền đủ thông tin! $error_2";}
else if ($check<=0){
echo "$error_1 Tài khoản gửi đi không có! $error_2";}
else{
$execute_sql_script = $db->Execute("INSERT INTO Tin_nhan (tu,toi_acc,tieu_de,loi_nhan,tinh_trang,vao_luc) VALUES ('Admin',N'".secure($to_acc)."',N'".secure($td)."',N'".secure($mail)."','0','$date')
");
echo "$ok_1 Tin nhắn đã được gửi tới $to_acc ! $ok_2";
}
}
function doc_mail_admin()
{
require("ketnoi_db.php");
$account_id = stripslashes($_COOKIE['administrator']);
$id = stripslashes($_POST['idm']);
$date2=date("d-m-Y G:i");
$check_mail = $db->Execute("select xem_luc from Tin_nhan where id='".$id."'");
$tinhtrang = $check_mail->fetchrow();
if (
empty($id)){
echo "$error_1 Bạn phải điền đủ thông tin! $error_2";}
else{
if ($tinhtrang[0]==NULL){
$execute_sql_script = $db->Execute("Update Tin_nhan set tinh_trang='1',xem_luc='$date2' where id='".secure($id)."'
");}
}
}
function doc_mail()
{
require("ketnoi_db.php");
$id = stripslashes($_GET['id']);
$date2=date("d-m-Y G:i");
$check_mail = $db->Execute("select xem_luc from Tin_nhan where id='".$id."'");
$tinhtrang = $check_mail->fetchrow();
if (
empty($id)){
echo "$error_1 Bạn phải điền đủ thông tin! $error_2";}
else{
if ($tinhtrang[0]==NULL){
$execute_sql_script = $db->Execute("Update Tin_nhan set tinh_trang='1',xem_luc='$date2' where id='".secure($id)."'
");}
}
}
function delete_mail()
{
require("ketnoi_db.php");
$account_id = stripslashes($_COOKIE['administrator']);
$id = stripslashes($_POST['idm']);
if (
empty($id)){
echo "$error_1 Bạn phải điền đủ thông tin! $error_2";}
else{
$execute_sql_script = $db->Execute("
Delete from Tin_nhan where id='".secure($id)."'
");
echo "$error_1 Tin nhắn đã được xóa ! $error_2";
}
}
mail.php(của Admin)
<?
if (eregi("mail.php", $_SERVER['SCRIPT_NAME'])) { die ("<META <b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b> content=0;URL=<b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b>>"); }
require('ketnoi_db.php');
$account_id = stripslashes($_COOKIE['administrator']);
?><br>
<table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<?
$news_id = $_POST['idm'];
$xem_mail = $db->Execute("select tu,tieu_de,loi_nhan,tinh_trang,vao_luc,id from Tin_nhan where id=? order by id desc",array($news_id));
$row2 = $xem_mail->fetchrow();
include("$thumuc/XuLy_TK.php");
if (isset($_POST["new_mail"])){
option::gui_mail();}
if (isset($_POST["delete_msg_inbox"])){
option::delete_mail();}
if (isset($_POST["delete_msg_sent"])){
option::delete_mail();}
if (isset($_POST["view_msg_inbox"])){
option::doc_mail_admin();
echo('
<table class="sort-table" id="table-1" cellpadding="3" cellspacing="0" width="690"><tbody>
<thead><tr><td align="center" bgcolor="#DEE7FF"><b>'.$row2[1].'</b></td></tr></thead>
<tr><td align="center" width="100%">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="4">
<tr>
<td width="40%" scope="row"><div align="right">Từ :</div></td>
<td width="60%" colspan="2" scope="row"><div align="left">'.$row2[0].'
</div></td>
</tr>
<tr>
<td scope="row"><div align="right">Tiêu đề :</div></td>
<td colspan="2" scope="row"><div align="left">'.$row2[1].'</div></td>
</tr>
<tr>
<td scope="row"><div align="right">Ngày :</div></td>
<td colspan="2" scope="row"><div align="left">'.$row2[4].'</div></td>
</tr>
<tr>
<td colspan="2" rowspan="3" valign="top" scope="row">
<fieldset><legend align="center"><b>Tin nhắn</b></legend><div align="left">'.$row2[2].'</div></td></fieldset>
</tr>
</table>
</td></tr></table>
');}
if (isset($_POST["view_msg_sent"])){
echo('
<table class="sort-table" id="table-1" cellpadding="3" cellspacing="0" width="690"><tbody>
<thead><tr><td align="center" bgcolor="#DEE7FF"><b>'.$row2[1].'</b></td></tr></thead>
<tr><td align="center" width="100%">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="4">
<tr>
<td width="40%" scope="row"><div align="right">Từ :</div></td>
<td width="60%" colspan="2" scope="row"><div align="left">'.$row2[0].'
</div></td>
</tr>
<tr>
<td scope="row"><div align="right">Tiêu đề :</div></td>
<td colspan="2" scope="row"><div align="left">'.$row2[1].'</div></td>
</tr>
<tr>
<td scope="row"><div align="right">Ngày :</div></td>
<td colspan="2" scope="row"><div align="left">'.$row2[4].'</div></td>
</tr>
<tr>
<td colspan="2" rowspan="3" valign="top" scope="row">
<fieldset><legend align="center"><b>Tin nhắn</b></legend><div align="left">'.$row2[2].'</div></td></fieldset>
</tr>
</table>
</td></tr></table>
');}
?>
</div></td>
</tr>
</table>
<fieldset>
<legend align="center"><b>Gửi tin nhắn</b></legend>
<table border="0" cellpadding="3" cellspacing="0" width="650">
<tr><td align="center" width="650"><div align="center">
<form action="" method="post" name="new_mail" id="new_mail">
<table width="600" border="0" cellpadding="1" cellspacing="4">
<tr>
<td width="200" scope="row"><div align="right" class="text_administrator">Tiêu đề:</div></td>
<td width="400" scope="row"><input name="tieude" type="text" id="tieude" size="80" maxlength="100"></td>
</tr>
<tr>
<td width="200" scope="row"><div align="right" class="text_administrator">Tới acc:</div></td>
<td scope="row"><input name="toi_acc" type="text" id="toi_acc" size="15" maxlength="10"></td>
</tr>
<tr>
<td width="200" scope="row"><div align="right" class="text_administrator">Người gửi:</div></td>
<td scope="row">
<input name="from" type="text" id="from" size="15" maxlength="20" value="Admin" disabled="disabled"></td>
</tr>
</table>
<table width="400" border="1" align="center" cellpadding="4" cellspacing="4">
<tr>
<td colspan="2" rowspan="3" scope="row"><div align="left">
<? $oFCKeditor = new FCKeditor('new_msg');
$oFCKeditor->BasePath = 'includes/news/';
$oFCKeditor->Config['AutoDetectLanguage'] = false ;
$oFCKeditor->Config['DefaultLanguage'] = 'vi' ;
$oFCKeditor->Value = '';
$oFCKeditor->Width = '600';
$oFCKeditor->Height = '500';
$oFCKeditor->Create(); ?>
</div>
<div align="center">
<input name="new_mail" type="hidden" id="new_mail" value="new_mail">
<input type="submit" name="Submit" value="Gửi tin nhắn" class="button">
</div>
</tr>
</table>
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<th scope="row"></th>
</tr>
</table>
</form>
</div></td>
</tr>
</table>
</fieldset>
<fieldset><legend align="center"><b>Danh sách tin nhận</b></legend>
<table border="0" cellpadding="3" cellspacing="0" width="670">
<tr><td align="center" width="650">
<? include_once("mail_nhan.php"); ?>
</td>
</tr>
</table>
</fieldset>
<fieldset><legend align="center"><b>Danh sách tin gửi đi</b></legend>
<table border="0" cellpadding="3" cellspacing="0" width="670">
<tr><td align="center" width="650">
<? include_once("mail_gui.php"); ?>
</td>
</tr>
</table>
</fieldset>
mail_nhan.php
<?PHP
if (eregi("mail_nhan.php", $_SERVER['SCRIPT_NAME'])) { die ("<META <b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b> content=0;URL=<b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b>>"); }
require_once('ketnoi_db.php');
$account_id = $_COOKIE['administrator'];
$tim_mail = $db->Execute("SELECT tu,toi_acc,tieu_de,loi_nhan,tinh_trang,vao_luc,xem _luc,id from Tin_nhan where toi_acc='Admin' order by id desc");
echo '<table class="sort-table" id="table-1" height=0 border="0" cellpadding="0" cellspacing="0" width="100%">
<thead><tr align="center">
<td width=10>#</td>
<td width=20 class=text_statistics><b>Từ</b></td>
<td width=180 class=text_statistics><b>Tiêu đề</b></td>
<td width=130 class=text_statistics><b>Ngày</b></td>
<td width=10 class=text_statistics><b>Xem</b></td>
<td width=10 class=text_statistics><b>Xóa</b></td>
<td width=130 class=text_statistics><b>Đã xem</b></td>
</tr></thead>';
for($i=0;$i < $tim_mail->numrows();++$i)
{
$msg = $tim_mail->fetchrow();
$rank = $i+1;
if($msg[4] == '0'){$msg[4] ='Chưa xem';}
if($msg[4] == '1'){$msg[4] =''.$msg[6].'';}
$msg_table_delete ="
<table width='40' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='85'><form action='' method='post' name='delete_msg_inbox' id='delete_msg_inbox'>
<input name='Delete' type='submit' id='Delete' value='Xóa' class='button'>
<input name='idm' type='hidden' id='idm' value=$msg[7]>
<input name=delete_msg_inbox type=hidden id=delete_msg_inbox value=delete_msg_inbox>
</form></td>
</tr></table>";
$msg_table_view ="<table width='40' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='85'><form action='' method='post' name='view_msg_inbox' id='view_msg_inbox'>
<input name='View' type='submit' id='View' value='Xem' class='button'>
<input name='idm' type='hidden' id='idm' value=$msg[7]>
<input name='view_msg_inbox' type='hidden' id='view_msg_inbox' value='view_msg_inbox'>
</form></td>
</tr></table>";
$msg[3]= substr($msg[3],0,25);
echo "<tbody><tr align='center'>
<td class=text_statistics>$rank</td>
<td class=text_statistics>$msg[0]</td>
<td class=text_statistics align=left>$msg[2].....</td>
<td class=text_statistics>$msg[5]</td>
<td>$msg_table_view</td>
<td>$msg_table_delete</td>
<td class=text_statistics>".$msg[4]."</td>
</tr></tbody>";
}
?>
</TABLE>
mail_gui.php
<?PHP
if (eregi("mail_gui.php", $_SERVER['SCRIPT_NAME'])) { die ("<META <b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b> content=0;URL=<b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b>>"); }
require('ketnoi_db.php');
$account_id = $_COOKIE['administrator'];
$tim_mail = $db->Execute("SELECT tu,toi_acc,tieu_de,loi_nhan,tinh_trang,vao_luc,xem _luc,id from Tin_nhan where tu='Admin' order by id desc");
echo '<table class="sort-table" id="table-1" height=0 border="0" cellpadding="0" cellspacing="0" width="100%">
<thead><tr align="center">
<td width=10>#</td>
<td width=20 class=text_statistics><b>Tới</b></td>
<td width=180 class=text_statistics><b>Tiêu đề</b></td>
<td width=130 class=text_statistics><b>Ngày</b></td>
<td width=10 class=text_statistics><b>Xem</b></td>
<td width=10 class=text_statistics><b>Xóa</b></td>
<td width=135 class=text_statistics><b>Đã xem</b></td>
</tr></thead>';
for($i=0;$i < $tim_mail->numrows();++$i)
{
$msg = $tim_mail->fetchrow();
$rank = $i+1;
if($msg[6] == NULL){$msg[6] ='Chưa xem';}
$msg_table_delete ="
<table width='40' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='85'><form action='' method='post' name='delete_msg_sent' id='delete_msg_sent'>
<input name='Delete' type='submit' id='Delete' value='Xóa' class='button'>
<input name=idm type=hidden id=idm value=\"$msg[7]\">
<input name=delete_msg_sent type=hidden id=delete_msg_sent value=delete_msg_sent>
</form></td>
</tr></table>";
$msg_table_view ="<table width='40' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='85'><form action='' method='post' name='view_msg' id='view_msg'>
<input name='View' type='submit' id='View' value='Xem' class='button'>
<input name=to type=hidden id=to value=\"$msg[1]\">
<input name=subject type=hidden id=subject value=\"$msg[2]\">
<input name=date type=hidden id=date value=\"$msg[6]\">
<input name=msg type=hidden id=msg value=\"".anti_sql($msg[3])."\">
<input name=idm type=hidden id=idm value=\"$msg[7]\">
<input name=view_msg_sent type=hidden id=view_msg_sent value=view_msg_sent>
</form></td>
</tr></table>";
$msg[2]= substr($msg[2],0,25);
echo "<tbody><tr align='center'>
<td class=text_statistics>$rank</td>
<td class=text_statistics>$msg[1]</td>
<td class=text_statistics align=left>$msg[2].....</td>
<td class=text_statistics>$msg[5]</td>
<td>$msg_table_view</td>
<td>$msg_table_delete</td>
<td class=text_statistics>$msg[6]</td>
</tr></tbody>";
}
?>
</TABLE>
Querry
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Tin_nhan]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Tin_nhan]
CREATE TABLE [dbo].[Tin_nhan] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[tu] [nvarchar] (20) NULL ,
[toi_acc] [nvarchar] (10) NULL ,
[tieu_de] [ntext] NULL ,
[loi_nhan] [ntext] NULL ,
[tinh_trang] [nvarchar] NOT NULL default 0,
[vao_luc] [nvarchar] (50) NULL ,
[xem_luc] [nvarchar] (50) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
mail.php
<?
if (eregi("mail.php", $_SERVER['SCRIPT_NAME'])) { die ("<META <b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b> content=0;URL=<b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b>>"); }
require('ketnoi_db.php');
?><br>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<?
include("$thumuc/XuLy_TK.php");
if (isset($_POST["delete_msg_inbox"])){
option::delete_mail();}
if (isset($_GET['id']) && isset($_SESSION['user'])){
$news_id = $_GET['id'];
option::doc_mail();
$xem_mail = $db->Execute("select tu,tieu_de,loi_nhan,tinh_trang,vao_luc,id from Tin_nhan where id=? order by id desc",array($news_id));
$row2 = $xem_mail->fetchrow();
echo('
<table class="sort-table" id="table-1" border="0" cellpadding="0" cellspacing="0"><tbody>
<thead><tr><td align="center"><b>'.$row2[1].'</b></td></tr></thead>
<tr><td align="center" width="100%">
<table width="510" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="40%" scope="row"><div align="right">Từ :</div></td>
<td width="60%" colspan="2" scope="row">
<div align="left">'.$row2[0].'</div></td>
</tr>
<tr>
<td scope="row" align="right">Vào lúc :</td>
<td colspan="2" scope="row"><div align="left">'.$row2[4].'</div></td>
</tr>
<tr>
<td colspan="3" valign="top" scope="row">
<fieldset><legend align="center"><b>Tin nhắn</b></legend><div align="left">'.$row2[2].'</div></td></fieldset>
</tr>
</table>
</td></tr></table>
');}
?>
</div></td>
</tr>
</table>
<fieldset><legend align="center"><b>Danh sách tin nhận</b></legend>
<table border="0" cellpadding="0" cellspacing="0" width="505">
<tr><td align="center" width="505">
<?
$account_id = stripslashes($_SESSION['user']);
$tim_mail = $db->Execute("SELECT tu,toi_acc,tieu_de,loi_nhan,tinh_trang,vao_luc,xem _luc,id from Tin_nhan where toi_acc='".secure($account_id)."' order by id desc");
echo '<table class="sort-table" id="table-1" border="0" cellpadding="0" cellspacing="0" width="100%">
<thead><tr align="center">
<td width="10">#</td>
<td width="200" class=text_statistics><b>Tiêu đề</b></td>
<td width="10" class=text_statistics><b>Xóa</b></td>
<td width="80" class=text_statistics><b>Đã xem</b></td>
</tr></thead>';
for($i=0;$i < $tim_mail->numrows();++$i)
{
$msg = $tim_mail->fetchrow();
$rank = $i+1;
if($msg[4] == '0'){$msg[4] ='Chưa xem';}
if($msg[4] == '1'){$msg[4] =''.$msg[6].'';}
$msg_table_delete ="<table border='0' cellpadding='0' cellspacing='0'>
<tr>
<td><form action='' method='post' name='delete_msg_inbox' id='delete_msg_inbox'>
<input onclick='return confirm(\"Bạn chắc chắn muốn xóa tin nhắn này ?\");' name='Delete' type='submit' id='Delete' value='Xóa' class='button'>
<input name='idm' type='hidden' id='idm' value=$msg[7]>
<input name=delete_msg_inbox type=hidden id=delete_msg_inbox value=delete_msg_inbox>
</form></td>
</tr></table>";
$msg[2]= substr($msg[2],0,70);
echo "<tbody><tr align='center'>
<td class=text_statistics>$rank</td>
<td class=link_content align=left><a href='BachCot-ThongTin-mail-$msg[7].ClbMuVn'>$msg[2]...</a></td>
<td>$msg_table_delete</td>
<td class=text_statistics>".$msg[4]."</td>
</tr></tbody>";
}
?>
</TABLE>
</td>
</tr>
</table>
</fieldset>
XuLy_TK.php
function napthe_dt()
{
require("ketnoi_db.php");
$account_id = stripslashes($_SESSION['user']);
$td = stripslashes($_POST['loaithe']);
$menhgia = stripslashes($_POST['menhgia']);
$macao = stripslashes($_POST['macao']);
$serial = stripslashes($_POST['seri']);
$date=date("d-m-Y G:i");
$full_the = "Loại thẻ: $td<br>Mệnh Giá: $menhgia<br>Mã Cào: $macao<br>Serial: $serial";
if (empty($td) || empty($menhgia) || empty($macao) || empty($serial)){
echo "$warning_start Bạn phải điền đủ thông tin! $warning_end";}
else{
$execute_sql_script = $db->Execute("INSERT INTO Tin_nhan (tu,toi_acc,tieu_de,loi_nhan,vao_luc) VALUES (N'".secure($account_id)."','Admin',N'".secure($td)."',N'".secure($full_the)."',N'$date')
");
echo "$ok_start Quá trình nạp thẻ hoàn tất,thời gian chờ kiểm tra trong 24 Tiếng. $ok_end";
}
}
function gui_mail()
{
require("ketnoi_db.php");
$account_id = stripslashes($_COOKIE['administrator']);
$td = stripslashes($_POST['tieude']);
$to_acc = stripslashes($_POST['toi_acc']);
$mail = fixnew($_POST['new_msg']);
$date=date("d-m-Y G:i");
$check_tk = $db->Execute("SELECT memb___id FROM MEMB_INFO WHERE memb___id=?",array(secure($to_acc)));
$check = $check_tk->numrows();
if (
empty($account_id) ||
empty($td) ||
empty($to_acc) ||
empty($mail)){
echo "$error_1 Bạn phải điền đủ thông tin! $error_2";}
else if ($check<=0){
echo "$error_1 Tài khoản gửi đi không có! $error_2";}
else{
$execute_sql_script = $db->Execute("INSERT INTO Tin_nhan (tu,toi_acc,tieu_de,loi_nhan,tinh_trang,vao_luc) VALUES ('Admin',N'".secure($to_acc)."',N'".secure($td)."',N'".secure($mail)."','0','$date')
");
echo "$ok_1 Tin nhắn đã được gửi tới $to_acc ! $ok_2";
}
}
function doc_mail_admin()
{
require("ketnoi_db.php");
$account_id = stripslashes($_COOKIE['administrator']);
$id = stripslashes($_POST['idm']);
$date2=date("d-m-Y G:i");
$check_mail = $db->Execute("select xem_luc from Tin_nhan where id='".$id."'");
$tinhtrang = $check_mail->fetchrow();
if (
empty($id)){
echo "$error_1 Bạn phải điền đủ thông tin! $error_2";}
else{
if ($tinhtrang[0]==NULL){
$execute_sql_script = $db->Execute("Update Tin_nhan set tinh_trang='1',xem_luc='$date2' where id='".secure($id)."'
");}
}
}
function doc_mail()
{
require("ketnoi_db.php");
$id = stripslashes($_GET['id']);
$date2=date("d-m-Y G:i");
$check_mail = $db->Execute("select xem_luc from Tin_nhan where id='".$id."'");
$tinhtrang = $check_mail->fetchrow();
if (
empty($id)){
echo "$error_1 Bạn phải điền đủ thông tin! $error_2";}
else{
if ($tinhtrang[0]==NULL){
$execute_sql_script = $db->Execute("Update Tin_nhan set tinh_trang='1',xem_luc='$date2' where id='".secure($id)."'
");}
}
}
function delete_mail()
{
require("ketnoi_db.php");
$account_id = stripslashes($_COOKIE['administrator']);
$id = stripslashes($_POST['idm']);
if (
empty($id)){
echo "$error_1 Bạn phải điền đủ thông tin! $error_2";}
else{
$execute_sql_script = $db->Execute("
Delete from Tin_nhan where id='".secure($id)."'
");
echo "$error_1 Tin nhắn đã được xóa ! $error_2";
}
}
mail.php(của Admin)
<?
if (eregi("mail.php", $_SERVER['SCRIPT_NAME'])) { die ("<META <b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b> content=0;URL=<b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b>>"); }
require('ketnoi_db.php');
$account_id = stripslashes($_COOKIE['administrator']);
?><br>
<table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<?
$news_id = $_POST['idm'];
$xem_mail = $db->Execute("select tu,tieu_de,loi_nhan,tinh_trang,vao_luc,id from Tin_nhan where id=? order by id desc",array($news_id));
$row2 = $xem_mail->fetchrow();
include("$thumuc/XuLy_TK.php");
if (isset($_POST["new_mail"])){
option::gui_mail();}
if (isset($_POST["delete_msg_inbox"])){
option::delete_mail();}
if (isset($_POST["delete_msg_sent"])){
option::delete_mail();}
if (isset($_POST["view_msg_inbox"])){
option::doc_mail_admin();
echo('
<table class="sort-table" id="table-1" cellpadding="3" cellspacing="0" width="690"><tbody>
<thead><tr><td align="center" bgcolor="#DEE7FF"><b>'.$row2[1].'</b></td></tr></thead>
<tr><td align="center" width="100%">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="4">
<tr>
<td width="40%" scope="row"><div align="right">Từ :</div></td>
<td width="60%" colspan="2" scope="row"><div align="left">'.$row2[0].'
</div></td>
</tr>
<tr>
<td scope="row"><div align="right">Tiêu đề :</div></td>
<td colspan="2" scope="row"><div align="left">'.$row2[1].'</div></td>
</tr>
<tr>
<td scope="row"><div align="right">Ngày :</div></td>
<td colspan="2" scope="row"><div align="left">'.$row2[4].'</div></td>
</tr>
<tr>
<td colspan="2" rowspan="3" valign="top" scope="row">
<fieldset><legend align="center"><b>Tin nhắn</b></legend><div align="left">'.$row2[2].'</div></td></fieldset>
</tr>
</table>
</td></tr></table>
');}
if (isset($_POST["view_msg_sent"])){
echo('
<table class="sort-table" id="table-1" cellpadding="3" cellspacing="0" width="690"><tbody>
<thead><tr><td align="center" bgcolor="#DEE7FF"><b>'.$row2[1].'</b></td></tr></thead>
<tr><td align="center" width="100%">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="4">
<tr>
<td width="40%" scope="row"><div align="right">Từ :</div></td>
<td width="60%" colspan="2" scope="row"><div align="left">'.$row2[0].'
</div></td>
</tr>
<tr>
<td scope="row"><div align="right">Tiêu đề :</div></td>
<td colspan="2" scope="row"><div align="left">'.$row2[1].'</div></td>
</tr>
<tr>
<td scope="row"><div align="right">Ngày :</div></td>
<td colspan="2" scope="row"><div align="left">'.$row2[4].'</div></td>
</tr>
<tr>
<td colspan="2" rowspan="3" valign="top" scope="row">
<fieldset><legend align="center"><b>Tin nhắn</b></legend><div align="left">'.$row2[2].'</div></td></fieldset>
</tr>
</table>
</td></tr></table>
');}
?>
</div></td>
</tr>
</table>
<fieldset>
<legend align="center"><b>Gửi tin nhắn</b></legend>
<table border="0" cellpadding="3" cellspacing="0" width="650">
<tr><td align="center" width="650"><div align="center">
<form action="" method="post" name="new_mail" id="new_mail">
<table width="600" border="0" cellpadding="1" cellspacing="4">
<tr>
<td width="200" scope="row"><div align="right" class="text_administrator">Tiêu đề:</div></td>
<td width="400" scope="row"><input name="tieude" type="text" id="tieude" size="80" maxlength="100"></td>
</tr>
<tr>
<td width="200" scope="row"><div align="right" class="text_administrator">Tới acc:</div></td>
<td scope="row"><input name="toi_acc" type="text" id="toi_acc" size="15" maxlength="10"></td>
</tr>
<tr>
<td width="200" scope="row"><div align="right" class="text_administrator">Người gửi:</div></td>
<td scope="row">
<input name="from" type="text" id="from" size="15" maxlength="20" value="Admin" disabled="disabled"></td>
</tr>
</table>
<table width="400" border="1" align="center" cellpadding="4" cellspacing="4">
<tr>
<td colspan="2" rowspan="3" scope="row"><div align="left">
<? $oFCKeditor = new FCKeditor('new_msg');
$oFCKeditor->BasePath = 'includes/news/';
$oFCKeditor->Config['AutoDetectLanguage'] = false ;
$oFCKeditor->Config['DefaultLanguage'] = 'vi' ;
$oFCKeditor->Value = '';
$oFCKeditor->Width = '600';
$oFCKeditor->Height = '500';
$oFCKeditor->Create(); ?>
</div>
<div align="center">
<input name="new_mail" type="hidden" id="new_mail" value="new_mail">
<input type="submit" name="Submit" value="Gửi tin nhắn" class="button">
</div>
</tr>
</table>
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<th scope="row"></th>
</tr>
</table>
</form>
</div></td>
</tr>
</table>
</fieldset>
<fieldset><legend align="center"><b>Danh sách tin nhận</b></legend>
<table border="0" cellpadding="3" cellspacing="0" width="670">
<tr><td align="center" width="650">
<? include_once("mail_nhan.php"); ?>
</td>
</tr>
</table>
</fieldset>
<fieldset><legend align="center"><b>Danh sách tin gửi đi</b></legend>
<table border="0" cellpadding="3" cellspacing="0" width="670">
<tr><td align="center" width="650">
<? include_once("mail_gui.php"); ?>
</td>
</tr>
</table>
</fieldset>
mail_nhan.php
<?PHP
if (eregi("mail_nhan.php", $_SERVER['SCRIPT_NAME'])) { die ("<META <b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b> content=0;URL=<b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b>>"); }
require_once('ketnoi_db.php');
$account_id = $_COOKIE['administrator'];
$tim_mail = $db->Execute("SELECT tu,toi_acc,tieu_de,loi_nhan,tinh_trang,vao_luc,xem _luc,id from Tin_nhan where toi_acc='Admin' order by id desc");
echo '<table class="sort-table" id="table-1" height=0 border="0" cellpadding="0" cellspacing="0" width="100%">
<thead><tr align="center">
<td width=10>#</td>
<td width=20 class=text_statistics><b>Từ</b></td>
<td width=180 class=text_statistics><b>Tiêu đề</b></td>
<td width=130 class=text_statistics><b>Ngày</b></td>
<td width=10 class=text_statistics><b>Xem</b></td>
<td width=10 class=text_statistics><b>Xóa</b></td>
<td width=130 class=text_statistics><b>Đã xem</b></td>
</tr></thead>';
for($i=0;$i < $tim_mail->numrows();++$i)
{
$msg = $tim_mail->fetchrow();
$rank = $i+1;
if($msg[4] == '0'){$msg[4] ='Chưa xem';}
if($msg[4] == '1'){$msg[4] =''.$msg[6].'';}
$msg_table_delete ="
<table width='40' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='85'><form action='' method='post' name='delete_msg_inbox' id='delete_msg_inbox'>
<input name='Delete' type='submit' id='Delete' value='Xóa' class='button'>
<input name='idm' type='hidden' id='idm' value=$msg[7]>
<input name=delete_msg_inbox type=hidden id=delete_msg_inbox value=delete_msg_inbox>
</form></td>
</tr></table>";
$msg_table_view ="<table width='40' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='85'><form action='' method='post' name='view_msg_inbox' id='view_msg_inbox'>
<input name='View' type='submit' id='View' value='Xem' class='button'>
<input name='idm' type='hidden' id='idm' value=$msg[7]>
<input name='view_msg_inbox' type='hidden' id='view_msg_inbox' value='view_msg_inbox'>
</form></td>
</tr></table>";
$msg[3]= substr($msg[3],0,25);
echo "<tbody><tr align='center'>
<td class=text_statistics>$rank</td>
<td class=text_statistics>$msg[0]</td>
<td class=text_statistics align=left>$msg[2].....</td>
<td class=text_statistics>$msg[5]</td>
<td>$msg_table_view</td>
<td>$msg_table_delete</td>
<td class=text_statistics>".$msg[4]."</td>
</tr></tbody>";
}
?>
</TABLE>
mail_gui.php
<?PHP
if (eregi("mail_gui.php", $_SERVER['SCRIPT_NAME'])) { die ("<META <b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b> content=0;URL=<b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b>>"); }
require('ketnoi_db.php');
$account_id = $_COOKIE['administrator'];
$tim_mail = $db->Execute("SELECT tu,toi_acc,tieu_de,loi_nhan,tinh_trang,vao_luc,xem _luc,id from Tin_nhan where tu='Admin' order by id desc");
echo '<table class="sort-table" id="table-1" height=0 border="0" cellpadding="0" cellspacing="0" width="100%">
<thead><tr align="center">
<td width=10>#</td>
<td width=20 class=text_statistics><b>Tới</b></td>
<td width=180 class=text_statistics><b>Tiêu đề</b></td>
<td width=130 class=text_statistics><b>Ngày</b></td>
<td width=10 class=text_statistics><b>Xem</b></td>
<td width=10 class=text_statistics><b>Xóa</b></td>
<td width=135 class=text_statistics><b>Đã xem</b></td>
</tr></thead>';
for($i=0;$i < $tim_mail->numrows();++$i)
{
$msg = $tim_mail->fetchrow();
$rank = $i+1;
if($msg[6] == NULL){$msg[6] ='Chưa xem';}
$msg_table_delete ="
<table width='40' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='85'><form action='' method='post' name='delete_msg_sent' id='delete_msg_sent'>
<input name='Delete' type='submit' id='Delete' value='Xóa' class='button'>
<input name=idm type=hidden id=idm value=\"$msg[7]\">
<input name=delete_msg_sent type=hidden id=delete_msg_sent value=delete_msg_sent>
</form></td>
</tr></table>";
$msg_table_view ="<table width='40' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='85'><form action='' method='post' name='view_msg' id='view_msg'>
<input name='View' type='submit' id='View' value='Xem' class='button'>
<input name=to type=hidden id=to value=\"$msg[1]\">
<input name=subject type=hidden id=subject value=\"$msg[2]\">
<input name=date type=hidden id=date value=\"$msg[6]\">
<input name=msg type=hidden id=msg value=\"".anti_sql($msg[3])."\">
<input name=idm type=hidden id=idm value=\"$msg[7]\">
<input name=view_msg_sent type=hidden id=view_msg_sent value=view_msg_sent>
</form></td>
</tr></table>";
$msg[2]= substr($msg[2],0,25);
echo "<tbody><tr align='center'>
<td class=text_statistics>$rank</td>
<td class=text_statistics>$msg[1]</td>
<td class=text_statistics align=left>$msg[2].....</td>
<td class=text_statistics>$msg[5]</td>
<td>$msg_table_view</td>
<td>$msg_table_delete</td>
<td class=text_statistics>$msg[6]</td>
</tr></tbody>";
}
?>
</TABLE>
Querry
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Tin_nhan]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Tin_nhan]
CREATE TABLE [dbo].[Tin_nhan] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[tu] [nvarchar] (20) NULL ,
[toi_acc] [nvarchar] (10) NULL ,
[tieu_de] [ntext] NULL ,
[loi_nhan] [ntext] NULL ,
[tinh_trang] [nvarchar] NOT NULL default 0,
[vao_luc] [nvarchar] (50) NULL ,
[xem_luc] [nvarchar] (50) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]