//////////////////////////////////////////////////////////////////////////////
$ck = "gomiyasikisyslogin"; //システム共有クッキー名
$title='VRC-ランダムトップ絵投稿フォーム';////タイトル
$dir = "./cov/"; //画像用ディレクトリ
////////////////////////////////////////////////////////////////////////////////
$pw = file_get_contents("../spw.dat");
$p = $_GET['p'];
$send = $_POST['send'];
$cpw = $_COOKIE[$ck];
include("covlist.php");
if($send){
if(($send==="app")&&($_POST['covauadd']==="")) exit("名前を入力してください");
$file = $_FILES['upfile']['name'];
if(!empty($_POST['covajp']))$covajp = $_POST['covajp'];
if(!empty($_POST['covaen']))$covaen = $_POST['covaen'];
if(!empty($_POST['sel'])){
$sel = $_POST['sel'];
if($send==="scr"){
foreach ($sel as $key => $value) {
if($value==="ok"){
if(!empty($_POST['covaux']))$covaux = $_POST['covaux'];
if(!empty($_POST['covauxen']))$covauxen = $_POST['covauxen'];
$a = count($covf);$b = "rt".$a.".jpg";
$covajp[$a] = $covaux[$key];$covauen[$a] = $covauxen[$key];
if(is_array($covaux))unset($covaux[$key],$covauxen[$key]);
rename($dir.$key,$dir.$b);
}elseif($value==="no"){
if(is_array($covaux))unset($covaux[$key],$covauxen[$key]);
if(is_file($dir.$key))unlink($dir.$key);
}
}
$info="申請の処理をしました
";
if($i==count($covaux))$covaux="";
}elseif($send==="up"){
foreach ($sel as $key => $value) {
if($value==="del"){echo $key.'=del';
unset($covf[$key],$covajp[$key],$covaen[$key]);
if(is_file($dir.$key))unlink($dir.$key);
}
}
$info="削除しました
";
}
}
if (!empty($file)){
$tmp = $_FILES['upfile']['tmp_name'];
$dat = pathinfo($file);$ext=$dat['extension'];if($ext==="jpeg")$ext="jpg";
$file = "rt".(count($covf)+1);if ($send==="app")$file = "_rt".count($covaux);
$filed = $file.".".$ext;
if (!file_exists($tmp)) exit("ファイルが選択されていません");
if (preg_match('/<\\?php./i', $image)) die("危険性のあるファイルです");
if (move_uploaded_file($tmp, $dir.$filed) == FALSE){
exit("投稿に失敗しました");
}else{
$base_image = $dir.$filed;
if($ext==="jpg"){$baseimg = ImageCreateFromJpeg($base_image);}
elseif($ext==="png"){$baseimg = ImageCreateFrompng($base_image);}
else{exit($ext."は対応していないファイル形式です");}
//画像の幅・高さ取得
$i_W = imagesx($baseimg);
$i_H = imagesy($baseimg);
$tpW = "360"; //top絵横サイズ
$tpH = "480"; //top絵縦サイズ
if((($i_W>$tpW)||($i_H!=$tpH))||($ext!=="jpg")){
//resize
$W = $i_W/$tpW; $H = $i_H/$tpH;
if($W>$H){
$r_W=$i_W/$H; $r_H=$i_H/$H;
if($r_W>$tpW){$r_W=$i_W/$W; $r_H=$i_H/$W;}
}
else{
$r_W=$i_W/$W; $r_H=$i_H/$W;
if($r_H>$tpH){$r_W=$i_W/$H; $r_H=$i_H/$H;}
}
$posX=($tpW-$r_W)/2;
$posY=($tpH-$r_H)/2;
$result_file = $dir.$file.".jpg";
$result_image = imagecreatetruecolor($tpW,$tpH);
$bgimg = ImageCreateFrompng("covbg.png");
imagecopy($result_image, $bgimg, 0, 0, 0, 0, $tpW, $tpH);
imagecopyresampled($result_image, $baseimg, $posX, $posY, 0, 0, $r_W, $r_H, $i_W, $i_H);
imagejpeg($result_image, $result_file);
if(($ext!=="jpg")&&(is_file($base_image)))unlink($base_image);
}
$key=$file.".jpg";
if($send==="app"){
$covaux[$key] = $_POST['covauadd'];
$covauxen[$key] = $_POST['covauadden'];
$info="申請しました
";mail('mdm2vip@gmail.com', 'VRC Rnd Cover Now!', '.. http://moe.but.jp/vrc/covset.php');
}else{
$covau[$key] = $_POST['covauadd'];
$covauen[$key] = $_POST['covauadden'];
$info="追加しました
";
}
}
}
$newf="";
ksort($covau);ksort($covauen);
$dat="\n";
if(is_Array($covaux)){//未登録ファイル
$dat.='$covaux = ';
$dat.=var_export($covaux,true);
$dat.=';
$covauxen = ';
$dat.=var_export($covauxen,true);
$dat.=";\n";
}//未登録ファイルend
$dat.='$covau = ';
$dat.=var_export($covau,true);
$dat.=';
$covauen = ';
$dat.=var_export($covauen,true);
$dat.=';
$covf = ';
$dat.=var_export($covf,true);
$dat.=';
$covajp = ';
$dat.=var_export($covajp,true);
$dat.=';
$covaen = ';
$dat.=var_export($covaen,true);
$dat.=';';
$htm='
include("covlist.php");
foreach ($covf as $key => $value) {$ar[]=$key;}
shuffle($ar);
foreach ($ar as $value) {
echo \'