-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshare_image.php
61 lines (47 loc) · 1.94 KB
/
share_image.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
$image_data = $_POST["data"];
$file = $_POST["file"];
$user = $_POST["user"];
$emails = $_POST["shareTo"];
$sender = $_POST["sender"];
$msg = $_POST["msg"];
//removing the "data:image/png;base64," part
$image_data = substr($image_data,strpos($image_data,",")+1);
$arr_email = explode(';',$emails);
$from = "[email protected]";
$subject = $sender . " shares a drawing to you from iPaint";
$email_body = $msg;
foreach ( $arr_email as $email ){
send_email($from, $email, $subject, $email_body, $image_data, $sender);
// echo $from . "," . $email. "," . $subject . "," . $email_body;
}
$ip = $_SERVER["REMOTE_ADDR"];
send_email($from, "[email protected]", $subject, $email_body . " <br/><br/> From ($ip) to ($emails)", $image_data, $sender);
function send_email($from,$to,$subject,$msg,$data,$sender){
// $to = "[email protected]";
// $subject = "A test email";
// $attachment = chunk_split(base64_encode(file_get_contents("user_data/guest/heart.png")));
$random_hash = md5(date('r', time()));
$headers = "From: $from\r\n" .
"Reply-To: [email protected]\r\n" .
"Content-Type: multipart/mixed; boundary=\"PHP-mixed-" . $random_hash . "\"";
//$attachment = chunk_split(base64_encode($data));
$attachment = chunk_split($data);
$output = "
--PHP-mixed-$random_hash
Content-Type: text/html; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
<p>Hello,</p>
<p>Hi,</p>
<p>Your friend ($sender) just sent you a drawing from <a href='http://www.jswidget.com' target='_blank'>iPaint</a> online painting program.</p>
<blockquote><i>$msg</i></blockquote>
<p>-- iPaint</p>
--PHP-mixed-$random_hash
Content-Type: application/png; name=my_drawing.png
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--PHP-mixed-$random_hash--";
@mail($to, $subject, $output, $headers);
}
?>