使用方法
在版面的目录内建立.boardquota文件,里面写上配额的大小(单位字节)
0或者没有该文件表示没有限额
限额最大为2G左右
修改地方
bbs.c
在static int choose_tmpl(char *title, char *fname);下加入两句话
long GetBSize(char* dirname);
long GetBQuota(char* boardname);
在post_article函数中
} else if (ans[0] == 'U') {
一行下加入下面几句话:
long quota=GetBQuota(currboard->filename);
if( (quota==0) || (GetBSize(currboard->filename) < quota )){
在 if (b->flag & BOARD_ATTACH && use_tmpl <= 0) {} 整个判断体,即
// use_tmpl = -1;
}
之后,加入下面几句话
}
else{
clear();
move(2,0);
prints(" 本版附件达到上限,不能添加附件。 \n");
pressreturn();
clear();
show_board_notes(currboard->filename);
}
最后在bbs.c最后加上下面两个函数
/*combe getbsize*/
long GetBSize(char* dirname){
DIR* dirp=NULL;
struct dirent* direntp=NULL;
struct stat statbuf;
long size=0;
chdir("boards");
dirp=opendir(dirname);
if(dirp!=NULL){
chdir(dirname);
while((direntp=readdir(dirp))!=NULL){
stat(direntp->d_name,&statbuf);
if( ( S_ISDIR(statbuf.st_mode) && (strcmp(direntp->d_name,".")!=0) && (strcmp(direntp->d_name,"..")!=0) )){
size+=GetBSize(direntp->d_name);
}
else{
if(!S_ISDIR(statbuf.st_mode)){
size+=statbuf.st_size;
}
}
}
chdir("..");
}
chdir("..");
return(size);
}
/* combe getbquota */
long GetBQuota(char* boardname){
long num;
chdir("boards");
chdir(boardname);
FILE* fp=fopen(".boardquota","r");
if(fp==NULL){
chdir("../..");
return(0);
}
else{
fscanf(fp,"%ld",&num);
fclose(fp);
chdir("../..");
return(num);
}
return(0);
}
bbsupload.php中修改:
在开头的注释下加入以下几行
function GetBSize($dirname){
$currdir=getcwd();
$size=0;
$handle=opendir($dirname);
chdir($dirname);
while($filename=readdir($handle)){
if( ( is_dir($filename) && (strcmp($filename,".")!=0) && (strcmp($filename,"..")!=0) )){
$size=$size+GetBSize($filename);
}
else{
if(!is_dir($filename)){
$size=$size+filesize($filename);
}
}
}
chdir($currdir);
return($size);
}
function GetBQuota($boardname){
$currdir=getcwd();
chdir($boardname);
if(!file_exists(".boardquota")){
chdir($currdir);
return(0);
}
$fp=fopen(".boardquota","r");
$num=fgets($fp,filesize(".boardquota"));
fclose($fp);
chdir($currdir);
return($num);
}
require("funcs.php");
require("boards.php");
if (isset($_GET["board"]))
$board = $_GET["board"];
else{
echo $board;
html_error_quit("错误的讨论区");
}
$currdir=getcwd();
chdir("boards");
$quota=GetBQuota($board);
if($quota!=0 && (GetBSize($board)>$quota) ){
html_error_quit("本版附件达到上限,不能增加附件\n");
}
chdir($currdir);
/* combe> */
把
alert('您还没选择上传的附件');
return false;
} else {
后的一行改为
e2="bbsupload.php?act=add&board=<?php echo $board;?>";
把函数function deletesubmit() 中的e2改为
e2="bbsupload.php?act=delete&attachname="+document.forms[1].elements["removefile"].value&board=<?php echo $board;?>;
在bbspst.php中function GoAttachWindow()
将
var hWnd的值改成
var hWnd = window.open("bbsupload.php?board=<?php echo $board;?>","_blank","width=600,height=300,scrollbars=yes");
修改完成
--
FROM 218.1.192.*