MAX_FILE){error("でかい。");} $dest = SRC_DIR.$tim.'.tmp'; move_uploaded_file($up, $dest); if(!$pass){$pass='dummy';} $pass = md5($pass); $youbi = array('日','月','火','水','木','金','土'); $now = date("y/m/d(",$time).(string)$youbi[date("w",$time)].date(")H:i",$time); $ext = ereg_replace("^.*\\.",".",$name); $ext = substr(strtolower($ext),0,5); $flag=FALSE; foreach($allowext as $value){ if('.'.$value==$ext){$flag=TRUE;} } if(!$flag){$ext='.xxx';} $size=(int)($size/1000); $fp = fopen(LOGFILE,"r+"); flock($fp,2); rewind($fp); $buf=fread($fp,90000); $line = explode("\n",$buf); $countline=count($line); for($i = 0; $i < $countline; $i++){ if($line[$i]){$line[$i].="\n";} } if($countline >= MAX_LOG){ for($d=$countline-1;$d>=MAX_LOG-1;$d--){ list($dno,$dname,)=explode("\t",$line[$d]); if(is_file(SRC_DIR.$dname)){unlink(SRC_DIR.$dname);} $line[$d]=''; } } list($lastno,) = explode("\t", $line[0]); $no=sprintf("%04d",++$lastno); $name=PREFIX.$no.$ext; $newline = "$no\t$name\t$now\t$pass\t$com\t$mime\t$size\t\n"; $newline.= implode('', $line); ftruncate($fp,0); set_file_buffer($fp, 0); rewind($fp); fputs($fp, $newline); fclose($fp); rename($dest,SRC_DIR.$name); chmod(SRC_DIR.$name,0666); } } function usrdel($no,$pass){ if($pass){ $pass = md5($pass); $fp = fopen(LOGFILE, "r+"); flock($fp, 2); rewind($fp); $buf=fread($fp,90000); $line = explode("\n",$buf); $countline=count($line); for($i = 0; $i < $countline; $i++){ if($line[$i]){$line[$i].="\n";} list($dno,$dname,,$dpass,)=explode("\t",$line[$i]); if($dno==$no){ if($dpass==$pass){ if(is_file(SRC_DIR.$dname)){unlink(SRC_DIR.$dname);} $line[$i]=''; }else{error("パス違う。");} } } $newline= implode('', $line); ftruncate($fp,0); set_file_buffer($fp, 0); rewind($fp); fputs($fp, $newline); fclose($fp); }else{ head($buf); $buf.='

記事'.$no.'番を削除します

パスワード入力:
'; echo $buf; exit; } } function Escstr($str){ $str = htmlspecialchars($str); if(get_magic_quotes_gpc()){$str=stripslashes($str);} return ereg_replace("[\r\n\x09]", "", $str); } function head(&$buf){ $buf='
あぷ@ふたば

phpテスト中…。
'; } function updatelog(){ head($buf); $buf.='
アプするファイル('.(MAX_FILE/1000).'Kまで)

コメント

del pass:

'; $line=file(LOGFILE); $countline = count($line); $buf.="\n"; for($i=0;$i<$countline;$i++){ list($no,$name,$now,,$com,$mime,$size,) = explode("\t", $line[$i]); $href=SRC_DIR.$name; $buf.="". "". "". "\n"; } $buf.='
ACTNAMECOMENTSIZE(KB)MIMEDATE
D[$name]$com$size$mime$now

'; $fp = fopen(PHP_SELF2, "w"); set_file_buffer($fp, 0); fputs($fp,$buf); fclose($fp); } function error($mes,$dest=''){ if($dest&&is_file($dest)) unlink($dest); head($dat); echo $dat."




". "
$mes

リロード
". "


"; exit; } if($_GET["del"]){ usrdel($_GET["del"],''); } switch($mode){ case 'del': if(!$pass){$pass='dummy';} usrdel($delno,$pass); case 'reg': regist($com,$up,$name,$mime,$pass); default: updatelog(); echo ""; } ?>