当前位置: 首页 > 图文教程 > 网络编程 > PHP > 不用数据库的多用户文件自由上传投票系统(1)

PHP
PHP 开发环境的选择、建立及使用(5)
PHP 开发环境的选择、建立及使用(6)
PHP 开发环境的选择、建立及使用(7)
PHP 开发环境的选择、建立及使用(8)
PHP 开发环境的选择、建立及使用(9)
Win2003下APACHE PHP5 MYSQL4 PHPMYADMIN 的简易安装配置
PHP新手上路(八) 文件上传
PHP新手上路(九) 投票系统
PHP新手上路(十) 简易banner动态更替
PHP新手上路(十一) 数据库链接
PHP新手上路(十二)使用PHP来操作Oracle数据库
PHP新手上路(十三)PHP资源
PHP新手上路(十四) 其他杂项
session全教程(一)
session全教程(二)
session全教程(三)
PHP编码规范
第十五节--Zend引擎的发展 -- Classes and Objects in PHP5 [15]
第十四节--命名空间 -- Classes and Objects in PHP5 [14]
第十二节--类的自动加载 -- Classes and Objects in PHP5 [12]

PHP 中的 不用数据库的多用户文件自由上传投票系统(1)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 365 ::
收藏到网摘: n/a

这是我近来开发的一套上传投票一体化的系统,共由4个php和若干记录文件组成,这是第一个view.php,主要负责显示文件列表和上传的文件表单和文件名的检验.其中的地址均为真实地址,请使用时作相应修改,我将在最后1篇提供具体的使用方法。
<html>
<head>
<link rel="stylesheet" href="../css/eccct.css">
</head>
<body>
<center>
<script src=http://home.classover.com/~vampirehunter/js/menu.js></script>
<script>

function opennewwin(url){
window.open(url,null,"height=200,width=200,status=no,toolbar=no,menubar=no,location=no");
}

function check(theform){
var tempstr=theform.upfile.value.split("\");
var files=tempstr[tempstr.length-1].split(".");
if(theform.writer.value=="" || theform.upfile.value=="" ){alert("作者与文件名不能为空");event.returnValue= false; }
if(escape(tempstr[tempstr.length-1]).indexOf("%u")!=-1){
alert("文件名不能为中文");
event.returnValue= false;

}

if(files.length<2 || (files[1]!="rar" && files[1]!="zip")){
alert("文件名必须以小写zip或rar结尾");
event.returnValue= false;
}
}
</script>
</head>
<body>

<?php
//col为栏目,当存在$uploadto/$col.if(纪录title),$col.ip,$col.ipd,$col.lst时合法
//
//page为第几页1-n
//rowperpage为每页几行

if(!$page) $page=0;
$rowperpage=5;
if(!$col) die("系统出错");
$cgiroot="http://eccct.51.net/cgi-bin/";//此php所在位置
$uploadto="../uploadfile/".$col."/";

$fp=@fopen($uploadto.$col.".if","r") or die("系统出错");
$title=fread($fp,filesize($uploadto.$col.".if"));
fclose($fp);//$title为本上传的名称

$recfile=$uploadto.$col.".lst";
$fp=@fopen($recfile,"r") or die("系统出错");
$info=explode(">",fread($fp,filesize($recfile)));
fclose($fp);
$maxpage=ceil((sizeof($info)-1)/$rowperpage);
if(!$maxpage) $maxpage=1;
if($page>$maxpage||$page<1)$page=1;
echo "<table class=tb cellspacing=0 cellpadding=0 ><tr><td colspan=10><br><br><center><h2>".$title."<hr></h2></center></td></tr><tr>";
echo "<td width=25%>共".(sizeof($info)-1)."个作品</td>";
echo "<td width=25%>第".$page."/".$maxpage."页</td>";
echo "<td width=25%>";
if($page+1<=$maxpage)
echo "<a href='view.php?col=".$col."&page=".($page+1)."'>下一页</a>";
echo "</td>";
echo "<td width=25%>";
if($page-1>0)
echo "<a href='view.php?col=".$col."&page=".($page-1)."'>上一页</a>";
echo "</td>";
echo "</tr></table><br><br>";
$startrec=($page-1)*$rowperpage;
$endrec=$startrec+$rowperpage;
for($i=$startrec;$i<$endrec&&$info[$i]!="";$i++){
$items=explode("<",$info[$i]);
if(!trim($items[0])) continue;
echo "<table class='tb' border=1 cellspacing=0 cellpadding=0>";
echo "<tr><td width=16.5% class=items>编号</td>";
echo "<td width=16.5% class=values>".$items[0]."</td>";
if(!trim($items[1]))$items[1]="打死我也不说";
echo "<td width=16.5% class=items>作者</td><td width=16.5% class=values>".$items[1]."</td>";
$temp=sprintf("%d",trim($items[5])/1024);
echo "<td width=16.5% class=items>文件名</td><td class=values>".trim($items[2])."(".$temp."KB)</td>";
echo "</tr><tr>";

echo "<td class=items>得票数</td><td class=values >".$items[3]."</td>";
echo "<td class=items>下载次数</td><td class=values width=13%>".$items[6]."</td>";
$click="opennewwin("download.php?num=".$items[0]."&col=".$col."");return false;";

$ev="<td class=values><input type='button' value=下载 onclick='".$click."'></td>";
echo $ev;

echo "<td class=values><a href='vote2.php?col=".$col."&option=".$items[0]."' >我要投票</a></td></tr>";

if(!trim($items[4]))$items[4]="保密";
echo "<tr><td class=items>简介</td><td class=values colspan=10>".$items[4]."</td></tr>";
echo "</table><br><br>";
}
?>
<form method="post" action="upload.php" enctype="multipart/form-data" onsubmit="check(this);">

<table class=tb border=1>
<tr><td><center><h2>我要投稿</h2></center></td></tr>
<tr><td>
作者:<input type="text" name="writer"></td></tr>
<tr><td>简介:<TEXTAREA name="intro" STYLE="width:600;overflow:hidden" >
</TEXTAREA>
</td></tr>
<tr><td> <input type=hidden name=col value="<? echo $col?>">
文件:<input type="file" name="upfile">(文件名请不要包含中文,文件小于1MB,以zip,rar结尾)</td></tr>
<tr><td align="center"> <input type="submit" name="Submit" value="提交">

</td></tr>
</table>
</form>
</center>
</body>
</html>