?? outbox.php
字號:
<?php
session_start();
if (!empty($downfile)) {
if (!@file_exists($downfile)) {
echo "<script>alert('你要下的文件不存在!')</script>";
//echo "下載出錯";
} else {
$filename = basename($downfile);
$filename_info = explode('.', $filename);
$fileext = $filename_info[count($filename_info)-1];
header('Content-type: application/x-'.$fileext);
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Description: PHP Generated Data');
header('Content-Length: '.filesize($downfile));
@readfile($downfile);
exit;
}
}
include "middle.php";
require_once "../MessageBox.php";
$Message = new MessageBox;
?>
<link href="../css/a1.css" rel="stylesheet" type="text/css">
<body leftmargin="0" topmargin="0">
<table width="789" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><img src="../images/home_12.jpg" width="789" height="12"></td>
</tr>
<tr>
<td width="776" valign="top">
<?php
if ( !empty($_SESSION["userid"]) ) {
include "../datasource.inc.php";
$page = $_REQUEST['page'];
$id = $_REQUEST['id'];
$action = $_REQUEST['action'];
$date = Date("Y-m-d");
if ($action == 'add') {
$addressee = $_REQUEST['addressee'];
$content = $_REQUEST['content'];
$addresser = $_SESSION['realname'];
$department = $_SESSION['department'];
$title = $_REQUEST['title'];
$file_name01 = $_FILES['job_path']['name'];
mt_srand((double)microtime()*1000000);
$shpid = uniqid(mt_rand());
$shpid = substr($shpid,0,8);
$file_name1 = $shpid.$file_name01;
$picpath1 = $path.$file_name1;
copy($HTTP_POST_FILES['job_path']['tmp_name'],$picpath1);
$shpidfilename = $shpid.".".substr($file_name01,-3);
@rename("$path/$file_name1","$path/$shpidfilename");
$sql = "insert into outbox (id,addressee,content,addresser,time,department,job_path,title) values ('','$addressee','$content','$addresser','$date','$department','$shpidfilename','$title');";
$result = mysql_query($sql);
$sql1 = "insert into inbox values ('','$addresser','$content','$addressee','0','$date','$shpidfilename','$title')";
$result1 = mysql_query($sql1);
$Message->setMessage("發送成功!","outbox.php");
$Message->showMessage();
}
?>
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr>
<TD vAlign=top><FONT color=#565656> <IMG height=14
src="../images/closedfold.gif" width=14> 您當前的位置<BR> <IMG
height=15 src="../images/bar.gif" width=15> <IMG height=14
src="../images/openfold.gif" width=14> 我的發件箱</FONT></TD>
</tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=766 align="right">
<tr><td width=766 height=1 bgcolor=#3494d4></td>
</tr>
</table><br>
<script language=javascript>
function check_input()
{
if (document.form.addressee.value=='') {
alert("請輸入收件人名稱!");
return false;
}
if (document.form.content.value=='') {
alert("請輸入內容!");
return false;
}
}
function OpenWin(URL){
newwindow=window.open(URL ,'日期選擇','width=200,height=230,scrollbars=1,resizable=1');
newwindow.focus();
}
</script>
<?
//echo "<div align=right><a href=outbox.php>瀏覽發件箱</a>  <a href=outbox.php?page=add>編寫新信件</a></div><br>";
switch($page){
case "add":
?>
<center>
<form enctype="multipart/form-data" name=form method="post" action="outbox.php" onsubmit="return check_input()">
<table border=0 cellpadding=0 cellspacing=0 bgcolor=#3494D4 width=776>
<tr>
<td width=10 bgcolor=#ffffff> </td>
<td>
<table border=0 cellpadding=0 cellspacing=1 bgcolor=#3494D4 width=766>
<!-- <tr>
<td width="15%" align=center bgColor=#ffffff>發信時間</td>
<td width="85%" bgcolor=ffffff> <?php
echo "<input type=text size=30 name=time maxlength=8 height=24 value=$date>";
?> <font color=red>*</font> 號為必填項
</td>
</tr> -->
<tr>
<td width="15%" align="center" bgcolor=#ffffff>主 旨</td>
<td width="85%" bgcolor=#ffffff> <input type="text" size="30" name="title" maxlength="20" height=24></td>
</tr>
<tr>
<td width="15%" align=center bgColor=#ffffff>收件人</td>
<td width="85%" bgcolor=ffffff> <input type="text" size="30" name="addressee" maxlength="20" height=24>
<a href="JavaScript:OpenWin('PickUser.php?chanField=form.addressee');">選擇收件人</a>
<font color=red>*</font>
</td>
</tr>
<tr>
<td width="15%" bgColor=#ffffff align=center>發送文件</td>
<td width="85%" bgcolor=ffffff>
<input type="file" size="20" name="job_path">
</td>
</tr>
<tr>
<td width="15%" align=center bgColor=#ffffff>內 容</td>
<td width="85%" bgColor=#ffffff> <textarea name="content" cols="65" rows="10"></textarea> <font color=red>*</font></td>
</tr>
</table>
</td>
</tr>
</table><br>
<input type="hidden" value="add" name="action">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<input type="hidden" name="addresser" value="<? $_SESSION["realname"] ?>">
<input type="hidden" name="department" value="<? $_SESSION["department"] ?>">
<input type="submit" name="submit" value=" 確 定 "> <input type="reset" name="submit1" value=" 重 置 ">
</form>
</center>
<?
break;
case "delete":
$query = "delete from outbox where id='$id';";
mysql_query($query);
$Message->setMessage("刪除成功!","outbox.php");
$Message->showMessage();
break;
case "text":
$sql = "select * from outbox where id='$id';";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$content = str_replace("<BR>", "\n", $row['content']);
?>
<center>
<table border=0 cellpadding=0 cellspacing=0 width=776>
<tr><td width=10 bgcolor=#ffffff> </td>
<td><table border=0 cellpadding=0 cellspacing=1 bgcolor=#3494d4 width=766 >
<tr height=24>
<td width="15%" bgColor=#ffffff align=center>發件時間</td>
<td width="85%" bgcolor=ffffff>
<?php echo $row['time']; ?>
</td>
</tr>
<tr height=24>
<td width="15%" bgColor=#ffffff align=center >收件人</td>
<td width="85%" bgcolor=ffffff>
<?php echo $row['addressee']; ?>
</td>
</tr>
<?
if ($row['job_path']) {
?>
<tr>
<td width="15%" bgColor=#ffffff align=center height=24>發送文件</td>
<td width="85%" bgcolor=ffffff>
<?php
$path0 = "../upload-files";
$path1 = $row['job_path'];
$filepath = "$path0/$path1";
echo "<a href=\"?downfile=".urlencode($filepath)."\">下載</a>";
?>
</td>
</tr>
<?
}
?>
<tr>
<td width="15%" bgColor=#ffffff align=center >內 容</td>
<td bgColor=#ffffff>
<?php
echo "<textarea cols=60 rows=10>$content</textarea>";
?>
</td>
</tr>
</table></td></tr></table>
<?
break;
default :
$sql = "select * from outbox where addresser='$_SESSION[realname]' order by id desc";
$result = mysql_query($sql);
$num = mysql_num_rows($result);
if ( $num>0 ){
$last = intval(($num-1)/40)+1;
if ( $page < 1 ) $page=1;
if ( $page > $last ) $page=$last;
mysql_data_seek($result,($page-1)*40);
echo "<table border=0 cellpadding=0 cellspacing=0 width=776>";
echo "<tr><td width=10 bgcolor=#ffffff> </td>";
echo "<td><table border=0 cellpadding=0 cellspacing=1 bgcolor=#3494d4 width=766>";
echo "<tr height=24>";
echo "<td width=170 bgColor=#3494d4><div align=center><font color=#ffffff><b>發件時間</b></font></div></td>";
echo "<td width=100 bgColor=#3494d4><div align=center><font color=#ffffff><b>收件人</b></font></div></td>";
echo "<td width=246 bgColor=#3494d4><div align=center><font color=#ffffff><b>內容</b></font></div></td>";
echo "<td width=150 bgColor=#3494d4><div align=center><font color=#ffffff><b>查看</b></font></div></td>";
echo "<td width=100 bgColor=#3494d4><div align=center><font color=#ffffff><b>刪除</b></font></div></td>";
echo "</tr>";
for ( $i=0;$i<40;$i++ ) {
$row = mysql_fetch_array($result);
$id = $row['id'];
$content = substr($row['content'],0,30);
if ( $id ) {
echo "<tr bgColor=#ffffff height=20>";
echo "<td width=170 bgColor=#ffffff><div align=center>$row[time]</div></td>";
echo "<td width=100 bgColor=#ffffff><div align=center>$row[addressee]</div></td>";
echo "<td width=246 bgColor=#ffffff><div align=center>$row[content]</div></td>";
echo "<td width=150 bgColor=#ffffff><div align=center><a href=# onClick=\"window.open('outbox_show.php?id=$row[id]',1,'top=50,left=50,height=450,width=450,scrollbars=yes')\">查看</a></div></td>";
echo "<td width=100 bgColor=#ffffff><div align=center><a title=點擊刪除本條記錄 href=outbox.php?page=delete&id=$row[id] onclick=\"return confirm('確定要刪除嗎?')\"><img src=../images/clearicon.gif border=0></a></div></td>";
echo "</tr>";
}
}
echo "</table></td></table><br>";
echo "<table width=500 border=0 cellspacing=0 cellpadding=0 height=24 align=center>";
echo "<tbody>";
echo "<tr><td><center>";
echo "總共找到<font color=red>$num</font>條記錄,第<font color=red>$page</font>頁,共<font color=red>$last</font>頁。";
echo "</center></td></tr><tr>";
if ( $page <> 1 ) {
echo "<td align=center> <a href=inbox.php?page=1>第一頁</a></td>";
echo "<td align=center><a href=inbox.php?page=".($page-1).">上一頁</a></td>";
}
if ( $page <> $last ) {
echo "<td align=center><a href=inbox.php?page=".($page+1).">下一頁</a></td>";
echo "<td align=center><a href=inbox.php?page=$last>最后一頁</a></td>";
}
echo "</tbody>";
echo "</tr>";
echo "</table><br>";
echo "</center>";
} else {
echo "<center>對不起,找不到符合條件的記錄!<a href=outbox.php?page=add>我要寫信</a></center>";
}
break;
}
} else {
$Message->setMessage("對不起,您沒有權限進入后臺管理!","index.php");
$Message->showMessage();
}
?>
</td>
<td width="13" align="right" background="../images/home_16.jpg" height=457> </td>
</tr>
<tr>
<td height="8" colspan="2" valign="top"><img src="../images/home_24.jpg" width="789" height="8"></td>
</tr>
</table>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -