| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/stradivariwettbewerb/ |
Upload File : |
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer-6.0.7/src/Exception.php';
require 'PHPMailer-6.0.7/src/PHPMailer.php';
require 'PHPMailer-6.0.7/src/SMTP.php';
// error_reporting(0);
// ini_set('display_errors', 0);
if ( ! function_exists('_h')) {
function _h($str)
{
return htmlspecialchars($str);
}
}
if (empty($_POST)) {
exit('No data');
}
$attachment = '';
if(isset($_FILES['attachment'])){
$errors= array();
$file_name = $_FILES['attachment']['name'];
$file_size =$_FILES['attachment']['size'];
$file_tmp =$_FILES['attachment']['tmp_name'];
$file_type=$_FILES['attachment']['type'];
$file_ext=strtolower(end(explode('.',$file_name)));
$extensions= array("jpeg","jpg","png","pdf");
if(in_array($file_ext,$extensions)=== false){
$errors[]="extension not allowed, please choose a JPEG , PDF or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be less than 2 MB';
}
if(empty($errors)){
move_uploaded_file($file_tmp,"file/".$file_name);
$attachment = "file/".$file_name;
}else{
print_r($errors);
}
}
if(!filter_var($_POST['mail'],FILTER_VALIDATE_EMAIL)){
exit("Invalid email");
}
$from = _h($_POST['mail']);
try {
$mail = new PHPMailer;
// $mail->isSendmail();
// $mail->Host = 'localhost';
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP();
$mail->Host = 'localhost'; // Set mailer to use SMTP
// $mail->Host = 'mail.stradivariwettbewerb.com'; // Specify main and backup SMTP servers
// $mail->SMTPAuth = TRUE; // Enable SMTP authentication
// $mail->Username = 'admin@stradivariwettbewerb.com'; // SMTP username
// $mail->Password = '2Tv@#230'; // SMTP password
// $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
// $mail->Port = 25; // TCP port to connect to
//Recipients
$mail->setFrom($from);
// $mail->addAddress('nickcheung@onesolution.com.hk');
$mail->addAddress('monicalelehk@gmail.com'); // Add a recipient
$mail->addBCC('manfok@onesolution.com.hk');
if ( ! empty($attachment)) {
$mail->addAttachment($attachment); // Add attachments
}
// Content
$mail->isHTML(TRUE); // Set email format to HTML
$mail->Subject = '小手牽大手音樂夏令營報名表';
ob_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>小手牽大手音樂夏令營報名表</title>
</head>
<body>
<table width="100%">
<tr>
<th>姓名</th>
<td><?= _h($_POST['name']) ?></td>
</tr>
<tr>
<th>性別</th>
<td><?= $_POST['gender'] == 'male' ? '男' : '女' ?></td>
</tr>
<tr>
<th>出生日期</th>
<td><?= date('Y-m-d', strtotime($_POST['dob'])) ?></td>
</tr>
<tr>
<th>手機號</th>
<td><?= _h($_POST['mobile']) ?></td>
</tr>
<tr>
<th>微信號</th>
<td><?= _h($_POST['wechatno']) ?></td>
</tr>
<tr>
<th>Email</th>
<td><?= _h($_POST['mail']) ?></td>
</tr>
<tr>
<th>學校或工作單位</th>
<td><?= _h($_POST['organization']) ?></td>
</tr>
<tr>
<th>家庭/通訊地址</th>
<td><?= _h($_POST['address']) ?></td>
</tr>
<tr>
<th>護照號</th>
<td><?= _h($_POST['passportno']) ?></td>
</tr>
<tr>
<th>護照有效期</th>
<td><?= _h($_POST['passportValid']) ?></td>
</tr>
<tr>
<th>護照複印件</th>
<td>附件</td>
</tr>
<tr>
<th>付款日期</th>
<td><?= _h($_POST['paymentDate']) ?></td>
</tr>
<tr>
<th>付款憑證</th>
<td><?= _h($_POST['paymentCode']) ?></td>
</tr>
<tr>
<th>付款人姓名</th>
<td><?= _h($_POST['payer']) ?></td>
</tr>
<tr>
<th>專業選項</th>
<td><?php switch ($_POST['profession']) {
case 'piano':
echo '鋼琴';
break;
case 'string':
echo '弦樂器';
break;
case 'vocal':
echo '聲樂組';
break;
case 'chamber':
echo '室内樂';
break;
} ?></td>
</tr>
<tr>
<th>專業水平</th>
<td><?= _h($_POST['professionLV']) ?></td>
</tr>
<tr>
<th>到達瑞士日期</th>
<td><?= date('Y-m-d', strtotime($_POST['arrivalDate'])) ?></td>
</tr>
<tr>
<th>到達航班</th>
<td><?= _h($_POST['arrivalFlight']) ?></td>
</tr>
<tr>
<th>離開瑞士日期</th>
<td><?= date('Y-m-d', strtotime($_POST['leaveDate'])) ?></td>
</tr>
<tr>
<th>離開航班</th>
<td><?= _h($_POST['departureFlight']) ?></td>
</tr>
</table>
</body>
</html>
<?php
$body = ob_get_clean();
$mail->CharSet = 'UTF-8';
$mail->Body = $body;
if($mail->send()) {
echo '<script>alert("報名表已發送");window.location.href="index.php";</script>';
}else{
exit("發送失敗");
}
// echo 'Message has been sent';
} catch (Exception $e) {
echo '<script>alert("發送失敗: '.$mail->ErrorInfo.'");history.back()</script>';
// echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}