function Authenticate() { global $password, $mypassword; if($password != $mypassword) { echo '<p style="color: #FF0000;">Authentication failed</p>'; ShowAuthenticationForm(); } else { $_SESSION['authenticated'] = true; BackupSite(); } }
$from = '*****@*****.**'; $to = '*****@*****.**'; $file = $archname; $boundary = uniqid(""); $headers = "From:{$from}\r\n"; $headers .= "Content-type:multipart/mixed; boundary= {$boundary}\r\n"; $mimeType = "application/x-bzip2"; $fileName = $backupfile; $fp = fopen($file, "r"); $read = fread($fp, filesize($file)); $read = base64_encode($read); $read = chunk_split($read); $body = "--{$boundary}\nContent-type:text/plain; charset=utf-8\nContent-transfer-encoding: 8bit\n{$text}\n文件:{$backupfile}\n备份日期:{$curtime}\n--{$boundary}\nContent-type: {$mimeType}; name={$fileName}\nContent-disposition: attachment; filename={$fileName}\nContent-transfer-encoding: base64\n{$read}\n--{$boundary}--"; if (mail($to, $subject, $body, $headers)) { print "OK! Now the mail from {$from} ---to--- {$to} has been send<br>"; } else { print "fail to send mail <br>"; } } ?> <?php BackupSite(); sendmail(); ?> <p>© <a href="http://www.suifeng.me">且听风吟</a></p> </div> </body> </html>