【directory.plの編集】
設定
改名
履歴
G-System
/
cgi-bin
/
lib
/ directory.pl
※このキーワードは元キーワードの作成者のみ作成・編集が可能です。
■キーワード内容
################################################################### #▼ディレクトリ一覧配列作成 #(引数:処理区分) #(返却値:ディレクトリ名配列) ################################################################### sub Directory{ my(@Directory,$Case,$Kubun,$BaseDir); $Case = $_[0]; $BaseDir = "$AbsoDir/cgi-files"; #□ディレクトリパスを配列に格納 if($Case eq 'Base'){ push(@Directory, "$BaseDir"); push(@Directory, "$BaseDir/bbs"); push(@Directory, "$BaseDir/user"); push(@Directory, "$BaseDir/backup"); push(@Directory, "$BaseDir/csystem"); push(@Directory, "$BaseDir/toukou"); push(@Directory, "$BaseDir/ranking"); push(@Directory, "$BaseDir/ranking/csystem"); push(@Directory, "$BaseDir/uploader"); push(@Directory, "$BaseDir/log"); } if($Case eq 'Delete'){ foreach $Program ('n','m','s','t','o','k'){ foreach $w ('smd','mmf','ma3','ma5'){ push(@Directory,"$BaseDir/csystem/dat_${Program}_${w}"); } } push(@Directory, "$BaseDir/csystem/temp"); } if($Case eq 'htaccess'){ #push(@Directory, "$BaseDir/uploader/file_gif"); #push(@Directory, "$BaseDir/uploader/file_jpg"); push(@Directory, "$BaseDir/uploader/file_mmf"); push(@Directory, "$BaseDir/uploader/file_mld"); push(@Directory, "$BaseDir/uploader/file_3gp"); } if($Case eq 'htaccessPlus'){ push(@Directory, "cgi-bin/lib"); push(@Directory, "$BaseDir/backup"); push(@Directory, "$BaseDir/log"); } if($Case eq 'Backup_htaccessPlus'){ push(@Directory,&Directory('DownloadLog')); push(@Directory,&Directory('MessageBox')); push(@Directory,&Directory('Other')); } if($Case eq 'DownloadLog'){ foreach $Program ('c','n','s','t'){ foreach $w ('smd','mmf','ma3','ma5'){ foreach $MType ('free','toll'){ if($w eq 'smd' && $MType eq 'toll'){ next; } push(@Directory,"$BaseDir/csystem/log_${Program}_${w}_${MType}"); } } } } if($Case eq 'MessageBox'){ push(@Directory, $USRMBX); } if($Case eq 'Other'){ push(@Directory, $BBSINF); push(@Directory, $BBSORD); push(@Directory, $USRCNT); push(@Directory, "$USRCNT/access"); push(@Directory, "$USRCNT/dlpoint"); push(@Directory, $USRFAV); push(@Directory, $USRFBX); push(@Directory, "$BaseDir/user/dat_favorite/okiniiri"); push(@Directory, "$BaseDir/user/dat_favorite/okiniirare"); push(@Directory, $USRMAS); push(@Directory, $USRMBI); push(@Directory, $USRTMP); push(@Directory, $USRINF); push(@Directory, $USRMSG); push(@Directory, $USRPRO); push(@Directory, $USRDLH); push(@Directory, $USRREG); push(@Directory, $USRGID); push(@Directory, $USRGNO); push(@Directory, "$BaseDir/user/log_checkgid"); push(@Directory, $UPLCNT); push(@Directory, $UPLFIN); push(@Directory, $UPLMSG); } if($Case eq 'html'){ foreach $Program ('d'){ push(@Directory,"$BaseDir/csystem/html_${Program}"); } foreach $Program ('m','s','t','o','k'){ foreach $w ('smd','mmf','ma3','ma5'){ if($Program eq 'k' && $w eq 'smd'){ next; } push(@Directory,"$BaseDir/csystem/html_${Program}_${w}"); } } foreach $Program ('n'){ foreach $w ('smd','mmf','ma3','ma5'){ foreach $MType ('free','toll'){ foreach $Browser ('j2','j3','j4','j5','i','ez','pc'){ if($w eq 'smd' && $MType eq 'toll'){ next; } if($w eq 'smd' && $Browser eq 'ez'){ next; } if($w ne 'smd' && $Browser eq 'j2'){ next; } if($MType eq 'toll' && $Browser eq 'i'){ next; } push(@Directory,"$BaseDir/csystem/html_${Program}_${w}_${MType}_${Browser}"); } } } } foreach $Program ('c','s','t'){ foreach $w ('smd','mmf','ma3','ma5'){ foreach $MType ('free','toll'){ if($w eq 'smd' && $MType eq 'toll'){ next; } push(@Directory,"$BaseDir/ranking/csystem/log_${Program}_${w}_${MType}"); push(@Directory,"$BaseDir/ranking/csystem/html_${Program}_${w}_${MType}"); } } } } return @Directory; } ################################################################### #▼.htaccess作成(携帯以外からのアクセス制限) #(引数:ディレクトリパス) #(返却値:なし) ################################################################### sub htaccess{ my($Directory,$htaccess); ($Directory) = @_; if(open(OUT, "> $Directory/.htaccess")){ $htaccess .= "DirectoryIndex index.cgi\n"; $htaccess .= "AddType application/x-smaf mmf\n"; $htaccess .= "\n"; $htaccess .= "order deny,allow\n"; $htaccess .= "deny from all\n"; $htaccess .= "allow from .jp-t.ne.jp\n"; $htaccess .= "allow from .jp-d.ne.jp\n"; $htaccess .= "allow from .jp-h.ne.jp\n"; $htaccess .= "allow from .jp-c.ne.jp\n"; $htaccess .= "allow from .jp-k.ne.jp\n"; $htaccess .= "allow from .jp-r.ne.jp\n"; $htaccess .= "allow from .jp-n.ne.jp\n"; $htaccess .= "allow from .jp-s.ne.jp\n"; $htaccess .= "allow from .jp-q.ne.jp\n"; $htaccess .= "allow from .vodafone.ne.jp\n"; $htaccess .= "allow from .t.vodafone.ne.jp\n"; $htaccess .= "allow from .d.vodafone.ne.jp\n"; $htaccess .= "allow from .h.vodafone.ne.jp\n"; $htaccess .= "allow from .c.vodafone.ne.jp\n"; $htaccess .= "allow from .k.vodafone.ne.jp\n"; $htaccess .= "allow from .r.vodafone.ne.jp\n"; $htaccess .= "allow from .n.vodafone.ne.jp\n"; $htaccess .= "allow from .s.vodafone.ne.jp\n"; $htaccess .= "allow from .q.vodafone.ne.jp\n"; $htaccess .= "allow from .docomo.ne.jp\n"; $htaccess .= "allow from .ezweb.ne.jp\n"; print OUT $htaccess; close(OUT); }else{ print "$Directory/.htaccessを作成できませんでした"; exit; } } ################################################################### #▼.htaccess作成(完全アクセス制限) #(引数:ディレクトリパス) #(返却値:なし) ################################################################### sub htaccessPlus{ my($Directory,$htaccess); ($Directory) = @_; if(open(OUT, "> $Directory/.htaccess")){ $htaccess .= "order deny,allow\n"; $htaccess .= "deny from all\n"; print OUT $htaccess; close(OUT); }else{ print "$Directory/.htaccessを作成できませんでした"; exit; } } ################################################################### #▼ディレクトリ内の全ファイルパス取得 #(引数:ディレクトリ名) #(返却値:全ファイルパスの配列) ################################################################### sub getDirectoryFilePass{ my(@Return,$Directory,@FileName,$FileName); ($Directory) = @_; opendir(DIR,$Directory) || &Error("$Directoryを開けません(&getDirectoryFilePass)"); @FileName = readdir(DIR); closedir(DIR); foreach $FileName (@FileName){ if($FileName =~ m/(\.{1}[a-zA-Z]{3,4})$/g){ push(@Return,"$Directory/$FileName"); } } return @Return; } ################################################################### #▼ディレクトリ内の全ファイルを更新順整列した配列を取得 #(引数:ディレクトリ名) #(返却値:ファイルパス配列) ################################################################### sub getDirectorySortUpdateTime{ my($Directory); ($Directory) = @_; @FilePass = &getDirectoryFilePass($Directory); foreach $FilePass (@FilePass){ $UpdateTime = &getFileLastUpdate($FilePass); push(@Record,"$FilePass\t$UpdateTime"); } @Record = &getReverseSort(@Record); foreach $Record (@Record){ ($FilePass,$UpdateTime) = split(/\t/,$Record); push(@Return,$FilePass); } return @Return; } ################################################################### #▼ディレクトリ内の全ファイル内容取得 #(引数:ディレクトリ名) #(返却値:ファイルパス,ファイル内容の配列) ################################################################### sub getDirectoryContents{ my(@Return,@Record,$Record,@FilePass,$FilePass,@Directory,$Directory,$Count); ($Directory) = @_; @Directory = &getDirectoryFilePass($Directory); foreach $Directory (@Directory){ @Record = &fread($Directory); $FilePass = &removeAbsoDir($Directory); $Count = 0; foreach $Record (@Record){ push(@Return,"$FilePass□区切□\t$Record\n"); $Count++; } if($Count == 0){ push(@Return,"\n"); } } return @Return; } ################################################################### #▼降順に整列した配列を取得(数値比較) #(引数:配列) #(返却値:整列済み配列) ################################################################### sub getReverseSort{ my(@Matrix,@Return); @Matrix = @_; @Return = reverse sort { ( split(/\t/,$a) )[1] <=> ( split(/\t/,$b) )[1] } @Matrix; return @Return; } ################################################################### #▼ディレクトリ内の全ファイル内容保存(xxx-xxx-xx.dat) #(引数:ディレクトリ名) #(返却値:なし) ################################################################### sub backupDirectoryContents{ my($Directory,@Record,$FilePass,$SaveDir); ($Directory) = @_; @Record = &getDirectoryContents($Directory); $SaveDir = "$AbsoDir/cgi-files/backup/".substr(&getLocalTime(),0,8); if(!(-d $SaveDir)){ mkdir($SaveDir,0777) || &Error("$SaveDirを作成できません(&backupDirectoryContents)"); &htaccessPlus($SaveDir); } $Directory = &removeAbsoDir($Directory); $Directory =~ s/[\/\\]/\-/g; $FilePass = $SaveDir.'/'.$Directory.'.dat'; #$FilePass = substr(&getLocalTime(),0,8).'-'.$Directory.'.dat'; &fwrite($FilePass,@Record); return 1; } ################################################################### #▼ディレクトリ内の全ファイル内容復元(xxx-xxx-xx.dat) #(引数:ディレクトリ名) #(返却値:なし) ################################################################### sub restoreDirectoryContents{ my($Directory,@Record,$Record,$FilePass); ($Directory) = @_; $FilePass = &removeAbsoDir($Directory).'.dat'; $FilePass =~ s/[\/\\]/\-/g; @Record = &fread($FilePass); foreach $Record (@Record){ ($FilePass,$Record) = split(/□区切□\t/,$Record); if($FilePass ne ''){ open(OUT, ">> $FilePass") || &Error("$FilePassを作成できません(&restoreDirectoryContents)"); print OUT "$Record\n"; close(OUT); } } return 1; } ################################################################### #▼ディレクトリ名から絶対パスを取り除く(xxx-xxx-xx.dat) #(引数:ディレクトリ名) #(返却値:絶対パス無しディレクトリ名) ################################################################### sub removeAbsoDir{ my($Directory) = @_; if(substr($Directory,0,length($AbsoDir)) eq $AbsoDir){ $Directory = substr($Directory,length($AbsoDir) + 1); } return $Directory; } return 1;
■G-ID
■添付ファイルアップロード
KeyWiki
Ver 0.6.9
(c) 2004
Ryota