#!/usr/bin/perl
require 'setup.cgi';
# メイン処理_________________________________________________________
&decode;
$pass = $in{"pass"};
$mode = $in{"mode"};
$number = $in{"number"};
if ( !$mode ) { &admin; }
if ( $mode eq "admin" ) { &admin; }
if ( $mode eq "regist" ) { ®ist; }
if ( $mode eq "ctrl_view" ) { &ctrl_view; }
if ( $mode eq "ctrl_save" ) { &ctrl_regist; }
if ( $mode eq "sort1" ) { &sort1; }
if ( $mode eq "sort2" ) { &sort2; }
if ( $mode eq "edit" ) { &edit_db; }
if ( $mode eq "edit_regist" ) { &edit_regist; }
if ( $mode eq "user" && $usr_input ) { &form2; }
&form;
exit;
# 一般メニュー表示___________________________________________________
sub def_vew{
&ctrl_read;
$title = "管理メニュー";
&head;
}
# 管理メニュー表示___________________________________________________
sub admin {
&ctrl_read;
$title = "管理メニュー";
&head;
print "
";
print '
管理メニュー |
項目編集モード |
[ 戻る ]
"; © exit; } # 項目データー登録___________________________________________________ sub ctrl_regist { if ( $pass ne $master_pass ) { &error("パスワードが異なります。"); } @NEW = (); foreach ( 1 .. 30 ) { $name = $in{"label_name$_"}; if ( $in{"label_input$_"} eq "on" ) { $input = "*"; } else { $input = ""; } if ( $in{"label_tag$_"} eq "on" ) { $tag = "*"; } else { $tag = ""; } if ( $in{"label_need$_"} eq "on" ) { $need = "*"; } else { $need = ""; } $value = $in{"label_value$_"}; $list = $in{"label_list$_"}; $new = "$name<>$input<>$value<>$tag<>$list<>$need<>\n"; @NEW="@NEW$new"; } @NEW = "番号<><><>\n@NEW"; &ctrl_save; $move_to = "system.cgi?mode=admin"; &move_to; } # データーベース新規登録_____________________________________________ sub form { if ( $pass ne $master_pass ) { &error("パスワードが異なります。"); } &ctrl_read; $title = "新規登録"; &head; print '新規登録モード |
[ 戻る ]
データー並び替え |
並び替えの基準にしたい項目を指定し、並び替え方法を選択して実行ボタンを押してください(項目名が未記入のものはこの一覧には\表\示されません)。並び替え前のデーターは自動的にバックアップファイル($back_file)に保存されます。 |
[ 戻る ]
"; © exit; } sub sort2 { if ( $pass ne $master_pass ) { &error("パスワードが異なります。"); } &db_read; @DAMMY = @DBlines; $backup = 1; &db_backup; @DBlines = @DAMMY; $op = $in{"op"}; $op1 = $in{"op1"}; $op2 = $in{"op2"}; if ( $op2 eq "1" ) { if ( $op1 eq "1" ) { @DBlines = sort{(split(/<>/,$a))[$op] <=> (split(/<>/,$b))[$op]}@DBlines; } else { @DBlines = sort{(split(/<>/,$b))[$op] <=> (split(/<>/,$a))[$op]}@DBlines; } } else { if ( $op1 eq "1" ) { @DBlines = sort{(split(/<>/,$a))[$op] cmp (split(/<>/,$b))[$op]}@DBlines; } else { @DBlines = sort{(split(/<>/,$b))[$op] cmp (split(/<>/,$a))[$op]}@DBlines; } } &db_save; &admin; } # バックアップ処理___________________________________________________ sub db_backup { &back_read; $nowtime = time; chop($backup[0]); if ( ( $nowtime - $backup[0] ) > 60*60*$back_time || $backup ) { unshift (@DBlines,"$nowtime\n"); open(LOCK,">$tmp_dir/back_lock.dat"); eval { flock(LOCK,2); }; open(TMP,">back_tmp.dat") || &error("バックアップ一時ファイルに書き込めません。"); print TMP @DBlines; close(TMP); rename("back_tmp.dat","$back_file") || &error("バックアップファイルに書き込めません。"); unlink("$tmp_dir/back_lock.dat"); eval { flock(LOCK,8); }; close(LOCK); } } # 画像ファイル保存処理_______________________________________________ sub UpFile { $macbin=0; foreach (@in) { if ($_ =~ /(.*)Content-type:(.*)/i) { $tail=$2; } if ($_ =~ /(.*)filename=(.*)/i) { $fname=$2; } if ($_ =~ /application\/x-macbinary/i) { $macbin=1; } } $tail =~ s/\r//g; $tail =~ s/\n//g; # $fname =~ s/\"//g; $fname =~ tr/\"\x0D\x0A//d; $flag=0; if ($tail =~ /image\/gif/i && $gif) { $tail=".gif"; $flag=1; } if ($tail =~ /image\/jpeg/i && $jpeg) { $tail=".jpg"; $flag=1; } if ($tail =~ /image\/x-png/i && $png) { $tail=".png"; $flag=1; } if (!$flag) { if ($fname =~ /\.gif$/i && $gif) { $tail=".gif"; $flag=1; } if (($fname =~ /\.jpe?g$/i && $jpeg)) { $tail=".jpg"; $flag=1; } if ($fname =~ /\.png$/i && $png) { $tail=".png"; $flag=1; } } foreach $confirm_type (@confirm_type) { if ( $fname =~ /\.$confirm_type$/i ) { $tail=".$confirm_type"; $flag=2; $org_width="file"; last; } } if (!$flag) { return; } elsif (!$flag) { &error("アップロードできないファイル形式です","lock"); } $upfile = $in{'upfile'}; if ($macbin) { $length = substr($upfile,83,4); $length = unpack("%N",$length); $upfile = substr($upfile,128,$length); } $ImgFile = "$ImgUrl$number$tail"; open(OUT,"> $ImgFile") || &error("画像のアップロードに失敗しました","lock"); binmode(OUT); binmode(STDOUT); print OUT $upfile; close(OUT); chmod (0666,$ImgFile); if ($tail eq ".jpg") { ($W, $H) = &JpegSize($ImgFile); } elsif ($tail eq ".gif") { ($W, $H) = &GifSize($ImgFile); } elsif ($tail eq ".png") { ($W, $H) = &PngSize($ImgFile); } elsif ( $flag eq "2" ) { $W = $down_ix; $H = $down_iy; } if ($W > $MaxW || $H > $MaxH) { $orw = $W; $orh = $H; $W2 = $MaxW / $W; $H2 = $MaxH / $H; if ($W2 < $H2) { $key = $W2; } else { $key = $H2; } $W = int ($W * $key) || 1; $H = int ($H * $key) || 1; } } sub JpegSize { local($jpeg) = @_; local($t, $m, $c, $l, $W, $H); open(JPEG, "$jpeg") || return (0,0); binmode JPEG; read(JPEG, $t, 2); while (1) { read(JPEG, $t, 4); ($m, $c, $l) = unpack("a a n", $t); if ($m ne "\xFF") { $W = $H = 0; last; } elsif ((ord($c) >= 0xC0) && (ord($c) <= 0xC3)) { read(JPEG, $t, 5); ($H, $W) = unpack("xnn", $t); last; } else { read(JPEG, $t, ($l - 2)); } } close(JPEG); return ($W, $H); } sub GifSize { local($gif) = @_; local($data); open(GIF,"$gif") || return (0,0); binmode(GIF); sysread(GIF,$data,10); close(GIF); if ($data =~ /^GIF/) { $data = substr($data,-4); } $W = unpack("v",substr($data,0,2)); $H = unpack("v",substr($data,2,2)); return ($W, $H); } sub PngSize { local($png) = @_; local($data); open(PNG, "$png") || return (0,0); binmode(PNG); read(PNG, $data, 24); close(PNG); $W = unpack("N", substr($data, 16, 20)); $H = unpack("N", substr($data, 20, 24)); return ($W, $H); } sub del_img { opendir(DIR, $ImgUrl) or die; @file = sort grep { /^$number\./i && -f "$ImgUrl/$_"} readdir(DIR); closedir(DIR); unlink "$ImgUrl/$file[0]"; } exit;