include("inc/db.php");
include("inc/makethumb.php");
if($_POST['lang']=="1"){
$ruc=& $_POST;
session_start();
$code = $_POST["authcode"];
if( $code == "" || $code != $HTTP_SESSION_VARS["authcode_session"])
{
echo "";
echo "";
exit();
}
while (list($key, $value) = each($ruc)) {
$ruc[$key]=trim($value);
}
$ruc['identity']=intval($ruc['identity']);
$ruc['issueyear']=intval($ruc['issueyear']);
$ruc['issuemonth']=intval($ruc['issuemonth']);
$ruc['issuedate']=intval($ruc['issuedate']);
$ruc['contactway1']=intval($ruc['contactway1']);
$ruc['contactway2']=intval($ruc['contactway2']);
$ruc['contactway3']=intval($ruc['contactway3']);
$ruc['lang']=intval($ruc['lang']);
$sql_check="select * from ruc order by id desc limit 1";
$query_check=mysql_query($sql_check,$conn) or die("error".mysql_error());
$num_check=mysql_num_rows($query_check);
$result_check=mysql_fetch_assoc($query_check);
$check_flag=0;
if($num_check==0){
$check_flag=1;
}else{
foreach($result_check as $key=>$value){
if(addslashes($result_check[$key])!=$ruc[$key]&&$key!='id'&&$key!='regdate'&&$key!='insdate'){
$check_flag=1;
break;
}
}
}
if($check_flag==0){
echo "";
echo "";
exit();
}else{
$filenum=1;
$fileflag=0;
for($i=1;$i<=$filenum&&$fileflag==0;$i++){
$filename[$i]="";
if($_FILES['documentrequire'.$i]['name']!=""){
$pt=split('\.',$_FILES['documentrequire'.$i]['name']);
$ptcount=sizeof($pt)-1;
//echo($pt[0]);
$pt[$ptcount]=strtolower($pt[$ptcount]);
if($pt[$ptcount]!='jpg'&&$pt[$ptcount]!='jpeg'&&$pt[$ptcount]!='gif'&&$pt[$ptcount]!='doc'&&$pt[$ptcount]!='pdf'&&$pt[$ptcount]!='txt'){
$fileflag=1;
echo "";
echo "";
break;
}
$pt2=split('/',$_FILES['documentrequire'.$i]['type']);
//echo($pt[0]);
if($pt2[0]==''){
$fileflag=1;
echo "";
echo "";
break;
}else{
$filename[$i]=date('YmdHis')."_".$i.'.'.$pt[$ptcount];
copy($_FILES['documentrequire'.$i]['tmp_name'],"admin/file/ruc".$filename[$i]);
if($pt[$ptcount]=='jpg'||$pt[$ptcount]=='jpeg'||$pt[$ptcount]=='gif'){
$src_image="admin/file/ruc".$filename[$i];
$dst_image="admin/file/ruc".$filename[$i];
makethumb($src_image,$dst_image,'620');
}
}
}
}
if($fileflag==0){
$sql_add = "insert into ruc (name,title,identity,identityno,issueplace,issueyear,issuemonth,issuedate,companyname_c,companyname_e,companyname_p,companyname_o,businessnature,companyaddress,bareacode,bnumber,mareacode,mnumber,fareacode,fnumber,email,contactway1,contactway2,contactway3,documentrequire1,following,lang,regdate) values('{$ruc['name']}','{$ruc['title']}',{$ruc['identity']},'{$ruc['identityno']}','{$ruc['issueplace']}',{$ruc['issueyear']},{$ruc['issuemonth']},{$ruc['issuedate']},'{$ruc['companyname_c']}','{$ruc['companyname_e']}','{$ruc['companyname_p']}','{$ruc['companyname_o']}','{$ruc['businessnature']}','{$ruc['companyaddress']}','{$ruc['bareacode']}','{$ruc['bnumber']}','{$ruc['mareacode']}','{$ruc['mnumber']}','{$ruc['fareacode']}','{$ruc['fnumber']}','{$ruc['email']}',{$ruc['contactway1']},{$ruc['contactway2']},{$ruc['contactway3']},'{$filename[1]}',0,{$ruc['lang']},now())";
$query_add=mysql_query($sql_add,$conn) or die("error2".mysql_error());
$sql_log = "insert into formlog (formbel) values(1)";
$query_log=mysql_query($sql_log,$conn) or die("error".mysql_error());
ini_set("SMTP","smtp.macau.ctm.net");
$send_email = $ruc['email'];
$send_subject = "=?utf-8?B?".base64_encode('Form application alert')."?=";
$send_headers = "MIME-Version: 1.0\r\n";
$send_headers .= "Content-type: text/html; charset=utf-8\r\n";
$send_headers .= "From: ".$send_email;
//$send_to="lei@microchina.com";
$send_to="mbsc@ipim.gov.mo,fmak@ipim.gov.mo,chan@ipim.gov.mo,twh@ipim.gov.mo";
$send_html="Note:
There is a new application form( Registered User Information - Chinese ) has been submitted, please check it in time!
".date("Y-m-d H:i");
if(mail($send_to, $send_subject, $send_html, $send_headers))
{ }
else {
echo "Email Error1!";
}
ini_restore("SMTP");
ini_set("SMTP","smtp.macau.ctm.net");
$send_email2 = "mbsc@ipim.gov.mo";
$send_subject2 = "=?utf-8?B?".base64_encode('MBSC Auto-reply')."?=";
$send_headers2 = "MIME-Version: 1.0\r\n";
$send_headers2 .= "Content-type: text/html; charset=utf-8\r\n";
$send_headers2 .= "From: ".$send_email2;
//$send_to2="lei@microchina.com";
$send_to2=$ruc['email'];
$send_html2=$ruc['name']."
先生/小姐 台啟
多謝使用澳門商務促進中心為您提供之服務。本中心已收到閣下於".date("Y年m月d日H時i分")."遞交之申請 (用戶登記表格),並將會跟進處理。
如有任何查詢,煩請聯絡本中心﹙電話﹕+853 28728212、傳真﹕+853 28727123 或電郵﹕mbsc@ipim.gov.mo﹚。
";
if(mail($send_to2, $send_subject2, $send_html2, $send_headers2))
{ }
else {
echo "Email Error2!";
}
ini_restore("SMTP");
echo "
登記成功!";
echo "返回