session_start();
##設定値######
#本番とテスト環境で切り替えが必要な時に使用 通常は0
define('TESTMODE', '0');
#入力項目数
define('MAXCNT', '21');
#管理者メールアドレス
define('ADMIN_MAIL', 'info@ma-r.co.jp');
#CSVファイル 0:出力 それ以外出力しない
define('CSVMODE', '0');
#CSVファイル名
define('CSV_FILE', 'data/maildata.csv');
#テンプレートヘッダー内 homeで使用TOPのURLです
define('DEFHTTP', 'http://www.ma-r.co.jp/');
#------------------------------------------------------
# メールテンプレート
#------------------------------------------------------
##自動返信メールタイトル######
define('MAIL_CONTACT_TITLE', 'Thank you for contacting us.');
##管理者宛てメールタイトル######
define('MAIL_ADMIN_TITLE', 'お客様よりお問い合わせです');
##自動返信メールヘッダ######
define('MAIL_CONTACT_HEADER', '
Thank you for contacting us.
We have received your inquiry/request as listed below.
');
##自動返信メールフッタ######
define('MAIL_CONTACT_FOOTER', '
Thank you very much.
***For persons who believe this e-mail has been sent to the wrong address,
Please delete it or contact us at 03-64273156
━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━
MINAMIAOYAMA REAL ESTATE
http://www.ma-r.co.jp/
━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━
');
##自動返信メール内容######
define('MAIL_CONTACT_BODY', '
Contact Information
----------------------
Name:__p1__
E-mail:__p11__
Phone:__p8__
Zip Code:__p2__
Address:__p3__
Comments:__p18__
----------------------
');
$dberrmsg='';
$loginid='';
$hanyouflg='';
$hidden='';
$uemail='';
#宣言
#1列目:index
#2列目:
#3列目:日本語名
#4列目:必須
#5列目:チェックタイプPHP(a:文字列('消去) b:数字(少数含む) c:半角英数 d:MAIL e:URL f:tel.zip g:date h:onoff)
#6列目:長さ
#7列目:formtype(t:text s:selectbox 1:checkbox(one) r:radiobutton c:checkbox(takusan) h:hidden d:date z:zip .*.*:小数点有り)
#8列目:checkboxの時のMAX数
#9列目:
#チェックタイプ
$aryp=array("","","","","","","","","","","",
"1","corp", "Name", "1", "a", "100", "","","","",
"2","div", "Zip Code", "0", "a", "100", "","","","",
"3","post", "Address", "0", "a", "100", "","","","",
"4","name01","姓", "0", "a", "20", "","","","",
"5","name02","名", "0", "a", "20", "","","","",
"6","namek01","姓(カナ)", "0", "a", "20", "","","","",
"7","namek02","名(カナ)", "0", "a", "20", "","","","",
"8","tel", "Phone", "0", "f", "15", "","","","",
"9","fax", "FAX番号", "0", "f", "15", "","","","",
"10","site","性別" , "0", "a", "50", "r","","","",
"11","email1","E-mail", "1", "d", "50", "","","","",
"12","email2","E-mail","1", "d", "50", "","","","",
"13","zip01","郵便番号1", "0", "f", "3", "","","","",
"14","zip02","郵便番号2", "0", "f", "4", "","","","",
"15","pref","都道府県", "0", "a", "12", "","","","",
"16","addr1","市区町村番地", "0", "a", "100", "","","","",
"17","addr2","アパート・マンション", "0", "a", "100", "","","","",
"18","naiyo","Comments", "1", "a", "3000", "","","","",
"19","site","このサイトをどこで", "0", "a", "100", "c","7","","",
"20","yobi1", "追加1", "0", "a", "100", "","","","",
"21","yobi2", "追加2", "0", "a", "120", "","","","",
"");
$arryerror=array();
############# 設定 ここまで 以下は編集しない ##############
#英数字を半角に変更
function fnc_han($str){
$ret="{$str}";
$ret=mb_convert_kana($ret, "as","UTF-8");
$ret=str_replace ('"', '”', $ret);
$ret=str_replace ('<', '<', $ret);
$ret=str_replace ('>', '>', $ret);
$ret=str_replace ('&', '&', $ret);
$ret=str_replace ("'", "’" ,$ret);
return $ret;
}
#POST/GETパラメータを取得します。
function fnc_req($str){
$retval="";
$retval=fnc_post($str);
if ($retval==""){
$retval=fnc_get($str);
}
return $retval;
}
#POSTパラメータを取得します。
function fnc_post($str){
$retval="";
if (isset($_POST[$str]))$retval=$_POST[$str];
if (strlen($retval)>80000){
echo 'too largedata1';
exit;
}
return fnc_changestr($retval);
}
#GETパラメータを取得します。
function fnc_get($str){
$retval="";
if (isset($_GET[$str]))$retval=$_GET[$str];
if (strlen($retval)>800){
echo 'too largedata2';
exit;
}
if (TESTMODE=='0'){
$retval=mb_convert_encoding($retval,"UTF-8","EUC-JP");
}
return fnc_changestr($retval);
}
#危険な文字の変換
function fnc_changestr($str){
global $mobflg;
$ret=stripcslashes("{$str}");
if ($mobflg=='1'){
$ret=mb_convert_encoding( $ret, "UTF-8", "SJIS");
}
$ret=str_replace ("\0", '', $ret);
$ret=str_replace ("\t", ' ', $ret);
$ret=str_replace ('"', '”', $ret);
$ret=str_replace ('<', '<', $ret);
$ret=str_replace ('>', '>', $ret);
$ret=str_replace ('&', '&', $ret);
$ret=str_replace ("'", "’" ,$ret);
$ret = htmlspecialchars($ret, ENT_QUOTES);
return trim($ret);
}
#機種依存チェック用関数
function fnc_kisyuizon($str){
$ret=true;
$str=str_replace ('~', '', $str);
$str=str_replace ('-', '', $str);
$str=str_replace ('Ⅰ', '', $str);
$str=str_replace ('Ⅱ', '', $str);
$str=str_replace ('Ⅲ', '', $str);
$str=str_replace ('Ⅳ', '', $str);
$str=str_replace ('Ⅴ', '', $str);
$str=str_replace ('Ⅵ', '', $str);
$str=str_replace ('Ⅶ', '', $str);
$str=str_replace ('Ⅷ', '', $str);
$str=str_replace ('Ⅸ', '', $str);
$str=str_replace ('Ⅹ', '', $str);
$test=$str;
#-と~は除く
$test=mb_convert_encoding( $test, "EUC-JP", "UTF-8");
$test=mb_convert_encoding( $test, "SJIS", "EUC-JP");
$test=mb_convert_encoding( $test, "UTF-8", "SJIS");
if ($test!=$str)$ret=false;
return $ret;
}
#日付型チェック
function check_date($str){
list ($y,$m,$d) = explode("/",$str . '//');
if ($str=="" || $str=='//'){
#未入力はOK
}elseif(is_numeric($m)==false || is_numeric($y)==false || is_numeric($d)==false){
return false;
}else{
$y=$y + 0;
$m=$m + 0;
$d=$d + 0;
if ($y > 3000 || $y < 1900 || $m >12 || $m<1 || $d>31 || $d<1){
return false;
}
if ($d>30 && ($m==4 || $m==6 || $m==9 || $m==11)){
return false;
}
if ($d>29 && $m==2){
return false;
}
if ($d==29 && $m==2){
if (($y % 400)==0){
#ok
}elseif (($y % 100)==0){
return false;
}elseif(($y % 4)!=0){
return false;
}
}
}
return true;
}
#日付型チェック
function check_datetime2($str){
$str=ereg_replace(' ',"-",$str);
$str=ereg_replace('-',"/",$str);
$y=2000;
list ($m,$d,$ushiro) = explode("/",$str . '///');
if ($str=="" || $str=='//時頃'){
#未入力はOK
return true;
}elseif(is_numeric($m)==false || is_numeric($y)==false || is_numeric($d)==false){
return false;
}else{
$y=$y + 0;
$m=$m + 0;
$d=$d + 0;
if ($y > 3000 || $y < 1900 || $m >12 || $m<1 || $d>31 || $d<1){
return false;
}
if ($d>29 && $m==2){
return false;
}
if ($d==29 && $m==2){
if (($y % 400)==0){
#ok
}elseif (($y % 100)==0){
return false;
}elseif(($y % 4)!=0){
return false;
}
}
}
$ushiro=str_replace("時頃", "", $ushiro);
list ($h,$m,$s) = explode(":",$ushiro . '::');
$s=0;
$m=0;
if ($ushiro==""){
#未入力はOK
}elseif(is_numeric($h)==false || is_numeric($m)==false || is_numeric($s)==false){
return false;
}else{
$h=$h + 0;
$m=$m + 0;
$s=$s + 0;
if ($h > 23 || $h < 0 || $m >59 || $m<0 || $s>59 || $s<0){
return false;
}
}
return true;
}
#メールアドレス型チェック
function check_mail($str){
$value=$str;
if (preg_match("/^[a-zA-Z0-9\"\._\?\+\/-]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/", $value)) {
return true;
} else {
return false;
}
}
#TEL,ZIP型チェック
function check_prm_f($val){
if ($val==''){
return '';
}
if ( ereg("^[0-9\-]+$", $val) ) {
return true;
}else{
return false;
}
}
#メール送信
function fnc_sendmail($tomail,$adminmail,$mailtitle,$mailbody){
#あて先
$strTo=trim($tomail);
#送り先を取得する
$from=trim($adminmail);
#タイトル
$strSbj=$mailtitle;
#本文
$strBody=$mailbody;
$strBody=mb_convert_encoding( $strBody, "SJIS", "UTF-8");
$strSbj=mb_convert_encoding( $strSbj, "SJIS", "UTF-8");
#ヘッダ
$headers = "MIME-Version: 1.0\n" ;
$headers .= "Return-Path: <$adminmail>\n" ;
$headers .= "Reply-To: $from \n";
$headers .= "From: $adminmail\n";
$headers .= "Content-Type: text/plain;charset=ISO-2022-JP\n";
$strBody =str_replace("\r", "\n", str_replace("\r\n", "\n", $strBody));
mb_language("Japanese");
mb_language("Ja") ;
mb_internal_encoding("SJIS") ;
mb_send_mail($strTo,$strSbj,$strBody,$headers);
mb_internal_encoding("UTF-8") ;
}
function sub_check_input(){
global $aryp,$p,$mode,$hidden,$arrayerror;
$errmsg='';
for ($i=1;$i<=MAXCNT;$i++){
$arrayerror[$i]='';
}
for ($i=1;$i<=MAXCNT;$i++){
$n=$aryp[(($i*10) + 1)];
$k=$aryp[(($i*10) + 3)];
$c=$aryp[(($i*10) + 5)];
#パラメータ取得
$p[$n]=fnc_post('p'.$n);
if (is_numeric($aryp[(($i*10) + 8)]) && $p[$n]==''){
for ($ii=1;$ii<=$aryp[(($i*10) + 8)];$ii++){
$tmp=fnc_post('p'.$n.'_'.$ii);
if ($tmp!=''){
$hidden.='';
if ($p[$n]==''){
$p[$n]=$tmp;
}else{
$p[$n].=',' . $tmp;
}
}
}
}else{
if ($aryp[(($i*10) + 7)]=='1' && $p[$n]!='1'){
$p[$n]='0';
}
}
#必須チェック
if ($aryp[(($i*10) + 4)]=='1' && ($p[$n]=='' || (($c=='g' || $c=='h' || $c=='i') &&($p[$n]=='//' || $p[$n]=='//:' || $p[$n]=='/ 時頃' || $p[$n]=='/ :')))){
$errmsg.='Please enter '.$k.'
'."\n" ;
$arrayerror[$n]='The entry of '.$k.' is necessary.';
}
#機種依存文字チェックおよび半角化
if ($c=='a'){
if (fnc_kisyuizon($p[$n])==false){
$errmsg.='・「'.$k.'」に機種依存文字が含まれています。
'."\n" ;
$arrayerror[$n].='機種依存文字が含まれています';
}
}else{
$p[$n]=fnc_han($p[$n]);
}
#長さチェック
if (strlen($p[$n])>$aryp[(($i*10) + 6)]){
if (!is_numeric($p[$n])){
$errmsg.='・「'.$k.'」が長すぎます。
'."\n";
$arrayerror[$n].='長すぎます';
}
}
#型チェック(数字)
if ($c=='b' && $p[$n]!=''){
if (!is_numeric($p[$n])){
$errmsg.='Enter '.$k.'as a number.
'."\n";
$arrayerror[$n].='Must be entered as a number.';
}
}
#型チェック(半角英数)
if ($c=='c' && $p[$n]!=''){
$test=$p[$n];
$test=str_replace("-", "", $test);
if (!check_prm_c($p[$n])){
$errmsg.=' '.$k.' field only accepts half-width characters.
'."\n";
$arrayerror[$n].='Please type using half-width characters.';
}
}
#型チェック(MAIL)
if ($c=='d' && $p[$n]!=''){
$p[$n]=str_replace(" ", "", $p[$n]);
if (!check_mail($p[$n]) ){
$errmsg.='・「'.$k.'」をご確認下さい。
'."\n";
$arrayerror[$n].='アドレス書式をご確認下さい';
}
}
#型チェック(URL )
if ($c=='e' && $p[$n]!=''){
if (!ereg("^http.+$", $p[$n])){
$errmsg.='・「'.$k.'」をご確認下さい。
'."\n";
$arrayerror[$n].='URLをご確認下さい';
}
}
#型チェック(tel.zip)
if ($c=='f' && $p[$n]!=''){
if (!check_prm_f($p[$n])){
$errmsg.='Please enter numeric value in '.$k.' field.
'."\n";
$arrayerror[$n].='Please input a numerical value.';
}
}
#型チェック(date)
if ($c=='g' && $p[$n]!=''){
if (!check_date($p[$n])){
$errmsg.='・「'.$k.'」をご確認下さい。
'."\n";
$arrayerror[$n].='書式をご確認下さい';
}
}
#型チェック(カンマ区切り数字又は-)
if ($c=='h' && $p[$n]!=''){
if (!check_prm_f(str_replace(",", "", $p[$n]))){
$errmsg.='・「'.$k.'」をご確認下さい。(カンマ区切り数字又は-)
'."\n";
$arrayerror[$n].='書式をご確認下さい';
}
}
#型チェック(date)
if ($c=='i' && $p[$n]!=''){
if (!check_datetime2($p[$n])){
$errmsg.='・「'.$k.'」をご確認下さい。
'."\n";
$arrayerror[$n].='値をご確認下さい';
}
}
#型チェック(float)
if ($c=='j' && $p[$n]!=''){
if (!is_numeric($p[$n])){
$errmsg.='・「'.$k.'」をご確認下さい。
'."\n";
$arrayerror[$n].='値をご確認下さい';
}
}
}
if ($p[11]!=fnc_post('p12')){
$errmsg.='・「e-mail」が確認用と一致しません。
';
$arrayerror[12].='一致しません';
}
return $errmsg;
}
#get param
$mode=fnc_req('mode');
error_reporting(2047);
$pcol=array();
for ($i=1;$i<=MAXCNT;$i++){
$n=$aryp[(($i*10) + 1)];
$pcol[$n]=$aryp[(($i*10) + 2)];
$arrayerror[$i] ='';
}
$errmsg='';
$msg='';
$hidden='';
#送信・サンキュー画面表示
if ($mode=='reg'){
#エラーチェック・データ整形
$errmsg=sub_check_input();
if ($errmsg=='' && fnc_post('back')!='on'){
$adminmail=ADMIN_MAIL;
$tile=MAIL_ADMIN_TITLE;
$body=MAIL_CONTACT_BODY;
for ($i=1;$i<=MAXCNT;$i++){
if ($p[$i]=='')$p[$i]='(Null)';
$body=str_replace("__p".$i."__",$p[$i],$body);
}
# 管理者向けメール送信
if (TESTMODE=='0'){
fnc_sendmail($adminmail,$adminmail,$tile,$body);
}
# 自動返信メール送信
$tile=MAIL_CONTACT_TITLE;
$uname=$p[4].' '.$p[5];
$body=MAIL_CONTACT_HEADER.$body.MAIL_CONTACT_FOOTER;
$body=str_replace("__PERSON_NAME__",$uname,$body);
if (check_mail($p[11])){
fnc_sendmail($p[11],$adminmail,$tile,$body);
}
# CSVファイル出力
if (CSVMODE=='0'){
if(file_exists(CSV_FILE)){
$fp = fopen(CSV_FILE,"a");
}else{
$fp = fopen(CSV_FILE,"w");
}
$cstr='"'.date("Y/m/d H:i:s") .'"';
for ($i=1;$i<=MAXCNT;$i++){
$cstr.=',"'.$p[$i].'"';
}
$cstr=mb_convert_encoding( $cstr, "SJIS", "UTF-8");
fputs($fp,$cstr."\n");
fclose($fp);
}
# 送信完了画面表示
include ('thanks.php');
exit;
}
$mode='newconf';
#内容確認時
}elseif($mode=='newconf'){
$errmsg=sub_check_input();
if ($errmsg==''){
#hidden設定
for ($i=1;$i<=MAXCNT;$i++){
$hidden.='';
if ($p[$i]=='')$p[$i]='(Null)';
if (($i==5 || $i==6) && is_numeric($p[$i]))$p[$i]=number_format($p[$i]);
}
#HTML取得
include ('conf.php');
exit;
}
}else{
$mode='newconf';
}
?>