?? job_download_info.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;
if ( !empty($_SESSION["userid"]) ) {
include "../datasource.inc.php";
$page = $_REQUEST['page'];
$id = $_REQUEST['id'];
$action = $_REQUEST['action'];
$job_body = str_replace("\n", "<BR>", $_REQUEST['job_body']);
$date = Date("Y-m-j H:i:s");
if ($action == 'add' and $_SESSION["userjs"]=='0' ) {
$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 job_download (id,job_name,job_path,job_fl,job_body) values ('','$_REQUEST[job_name]','$shpidfilename','$_REQUEST[job_fl]','$job_body');";
$result = mysql_query($sql);
$Message->setMessage("添加成功!","job_download_info.php");
$Message->showMessage();
}
if ($_REQUEST['action'] == 'update' and $_SESSION["userjs"]=='0') {
$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;
if (!empty($file_name01)) {
copy($HTTP_POST_FILES['job_path']['tmp_name'],$picpath1);
$shpidfilename = $shpid.".".substr($file_name01,-3);
@rename("$path/$file_name1","$path/$shpidfilename");
$sql = "update job_download set job_name='$_REQUEST[job_name]',job_path='$shpidfilename',job_fl='$_REQUEST[job_fl]',job_body='$job_body' where id='$_REQUEST[id]';";
} else {
$sql = "update job_download set job_name='$_REQUEST[job_name]',job_fl='$_REQUEST[job_fl]',job_body='$job_body' where id='$_REQUEST[id]';";
}
$result = mysql_query($sql);
$Message->setMessage("編輯成功!","job_download_info.php");
$Message->showMessage();
}?>
<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">
<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 width=766 border="0" cellpadding=0 cellspacing=0 align="right">
<tr><td width=766 height=1 bgcolor=#3494d4></td>
</tr>
</table>
<script language=javascript>
function check_input()
{
if (document.form.job_name.value=='') {
alert("請輸入文檔名稱!");
return false;
}
if (document.form.job_body.value=='') {
alert("請輸入文檔內容!");
return false;
}
return true;
}
</script>
<br>
<?php
if ($_SESSION['userjs']=="0") {
echo "<div align=right><a href=job_download_info.php?page=add>添加文檔</a> <a href=job_download_info.php>瀏覽文檔</a> <a href=job_fl.php?page=add>添加分類</a> <a href=job_fl.php>分類管理</a></div>";
}
switch ($page){
case "add":
?>
<center>
<form enctype="multipart/form-data" name=form method="post" action="job_download_info.php" onsubmit="return check_input()">
<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 align="right">
<tr>
<td width="15%" bgColor=#ffffff align=center>文檔名稱</td>
<td width="85%" bgcolor=ffffff>
<input type="text" size="30" name="job_name" maxlength="40">
</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%" bgColor=#ffffff align=center>所屬分類</td>
<td width="85%" bgcolor=ffffff>
<?php
$sql = "select * from job_fl order by id desc;";
$result = mysql_query($sql);
echo " <select name=\"job_fl\">";
while ($row = mysql_fetch_array($result) ) {
echo "<option value=\"$row[fl]\">$row[fl]</option>";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td width="15%" bgColor=#ffffff align=center>文檔內容</td>
<td width="85%" bgColor=#ffffff><textarea name="job_body" cols="80" rows="15"></textarea></td>
</tr>
</table></td></table><br>
<input type="hidden" value="add" name="action">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<input type="submit" name="submit" value=" 確 定 "> <input type="reset" name="submit1" value=" 重 置 ">
</form>
</center>
<?
//}
break;
case "delete":
/*$sql = "select * from job_download where id='$id';";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$dele = `rm $row['job_pic1']`;
$dele = `rm $row['job_pic2']`;
$dele = `rm $row['job_pic3']`;
$dele = `rm $row['job_pic4']`;
*/
if ($_SESSION["userjs"]=='0') {
$query = "delete from job_download where id='$id';";
mysql_query($query);
$Message->setMessage("刪除成功!","job_download_info.php");
$Message->showMessage();
}
break;
case "update":
$sql = "select * from job_download where id='$id';";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$id = $row['id'];
$job_name = $row['job_name'];
$job_body = str_replace("<BR>", "\n", $row['job_body']);
?>
<form enctype="multipart/form-data" name=form method="post" action="job_download_info.php" onsubmit="return check_input()">
<center>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td width=10 bgcolor=#ffffff> </td>
<td><table border=0 cellpadding=0 cellspacing=1 bgcolor=#3494d4 width=776>
<tr>
<td width="15%" bgColor=#ffffff align=center>文檔名稱</td>
<td width="85%" bgcolor=ffffff>
<?php echo "<input type=text size=30 name=job_name maxlength=40 value=\"$row[job_name]\">" ?>
</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%" bgColor=#ffffff align=center>所屬分類</td>
<td width="85%" bgcolor=ffffff>
<?php
$sql1 = "select * from job_fl order by id desc;";
$result1 = mysql_query($sql1);
echo " <select name=\"job_fl\">";
echo "<option value=$row[job_fl]>$row[job_fl]</option>";
while ($row1 = mysql_fetch_array($result1) ) {
echo "<option value=\"$row1[fl]\">$row1[fl]</option>";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td width="15%" bgColor=#ffffff align=center>文檔內容</td>
<td width="85%" bgColor=#ffffff>
<?php echo "<textarea name=job_body cols=80 rows=15>$job_body</textarea>";?>
</td>
</tr>
</table></td></tr></table>
<br>
<input type="hidden" value="update" name="action">
<?php echo "<input type=hidden name=id value=$id>"; ?>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<input type="submit" name="submit" value=" 確 定 "> <input type="reset" name="submit1" value=" 重 置 ">
</form>
</center>
<?php
break;
case "text":
$sql = "select * from job_download where id='$id';";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$job_body = str_replace("<BR>", "\n", $row['job_body']);
?>
<br>
<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 height=400>
<tr>
<td width="15%" bgColor=#ffffff align=center height=24>所屬分類</td>
<td width="85%" bgcolor=ffffff>
<?php echo $row['job_fl']; ?>
</td>
</tr>
<tr>
<td width="15%" bgColor=#ffffff align=center height=24>文檔名稱</td>
<td width="85%" bgcolor=ffffff>
<?php echo $row['job_name']; ?>
</td>
</tr>
<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 colspan=2 bgColor=#ffffff>
<?php
echo "<textarea cols=106 rows=25>$job_body</textarea>";
?>
</td>
</td>
</tr>
</table></td></table>
<br><a href="javascript:history.go(-1)">返回</a>
</center>
<?php
break;
default:
// echo "<center>";
//echo "<form action=job_download_info.php method=post>";
// echo "<table border=0 width=680>";
// echo "<tr>";
// echo "<td width=40% bgColor=#ffffff>";
//echo "按文檔名查詢:<input type=text size=20 name=search maxlength=20>";
//echo " <input type=submit value=搜索>";
//echo "</td>";
//echo "</tr>";
// echo "</table>";
// echo "</form>";
//if ($_REQUEST['search']){
// $sql = "select * from job_download where job_name like '%$_REQUEST[search]%' order by id desc;";
//} else {
// $sql = "select * from job_download order by id desc;";
//}
$sql = "select * from job_fl order by id asc;";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result) ) {
echo "<div align=right><table border=0 cellpadding=0 cellspacing=1 bgcolor=#3494d4 width=766 >";
echo "<tr height=24>";
echo "<td colspan=5 bgColor=#3494d4><b><font color=#ffffff>$row[fl]</font></b></td>";
echo "</tr><br>";
$sql1 = "select * from job_download where job_fl='$row[fl]' order by id asc;";
$result1 = mysql_query($sql1);
$num1 = mysql_num_rows($result1);
if ($num1>0) {
while ($row1 = mysql_fetch_array($result1) ) {
echo "<tr bgcolor=ffffff height=22>";
echo "<td width=350>$row1[job_name]</td>";
echo "<td width=104 align=center><a href=# onClick=\"window.open('job_download_show.php?id=$row1[id]',1,'top=50,left=50,height=450,width=450,scrollbars=yes')\">查看</td>";
$path0 = "../upload-files";
$path1 = $row1['job_path'];
$filepath = "$path0/$path1";
echo "<td width=104 align=center><a href=\"?downfile=".urlencode($filepath)."\">下載</a></td>";
if ($_SESSION["userjs"] == "0"){
echo "<td width=104 align=center><a href=job_download_info.php?page=update&id=$row1[id]><img src=../images/editicon.gif border=0></td>";
echo "<td width=104 align=center><a href=job_download_info.php?page=delete&id=$row1[id] onclick=\"return confirm('是否確定刪除此記錄')\"><img src=../images/clearicon.gif border=0></td>";
}
echo "</tr>";
}
}
}
echo "</table></div><br>";
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"></td>
</tr>
</table>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -