3 $sub = strip_tags(addslashes(trim($_POST['zxcvbnm'])));
4 $msg = strip_tags(addslashes(trim($_POST['msg'])));
6 if (strlen($msg) > 250) {
7 $echo = "Content too long";
11 $from = substr($sub, 0, 9);
12 $to = substr($sub, 9, 9);
13 $file = substr($sub, 18);
14 //echo $from."-".$to."-".$file;
17 include('../encrypt.php');
20 $msg = $reply->BeSanitize($msg);
21 $reply_receiver = $reply->FindUser($to,$id_mail_path);
23 $fdir = substr($reply_receiver, 0, 1);
24 $sdir = substr($reply_receiver, 1, 1);
25 $udir = str_replace("@", "-", $reply_receiver);
26 $file_path = MDB_PATH
."{$fdir}/{$sdir}/{$udir}/{$file}.dat";
27 $ufile_path = MDB_PATH
."{$fdir}/{$sdir}/{$udir}/u_{$file}.dat";
28 $tmp_copy_path = MDB_PATH
."{$fdir}/{$sdir}/{$udir}";
33 $sender_path = $reply->FindUser($from,$id_mail_path);
34 $fdir2 = substr($sender_path, 0, 1);
35 $sdir2 = substr($sender_path, 1, 1);
36 $udir2 = str_replace("@", "-", $sender_path);
37 $sender_file_path = MDB_PATH
."{$fdir2}/{$sdir2}/{$udir2}/{$file}.dat";
38 $usender_file_path = MDB_PATH
."{$fdir2}/{$sdir2}/{$udir2}/u_{$file}.dat";
40 $writeData = "<id>{$time}</id><from>{$from}</from><subj></subj><msg>{$msg}</msg>\n";
42 echo $file_path."<br>";
43 echo $sender_file_path;
44 if (!file_exists($file_path)) {
45 if (file_exists($sender_file_path)) {
46 if (!file_exists($tmp_copy_path)) {
47 @mkdir
(MDB_PATH
."{$fdir}");
48 @mkdir
(MDB_PATH
."{$fdir}/{$sdir}");
49 @mkdir
(MDB_PATH
."{$fdir}/{$sdir}/{$udir}");
51 $aa = file($sender_file_path);
52 $aa = implode("\n", $aa);
53 file_put_contents($file_path, $aa);
54 $handle = fopen($sender_file_path, "a+");
55 if(!fwrite($handle, $writeData)) {
63 if (trim($sender_file_path) <> trim($file_path)) {
64 $handle = fopen($file_path, "a+");
65 //var_dump($file_path);
67 if(!fwrite($handle, $writeData)) {
74 rename($file_path, $ufile_path);
75 if (trim($sender_file_path) <> trim($file_path)) {
76 rename($sender_file_path, $usender_file_path);
78 $_SESSION['msg'] = "Message succesfully sent";
79 header('Location: ../inbox.php');
82 //if (trim($sender_file_path) <> trim($file_path)) {
83 $handle = fopen($sender_file_path, "a+");
84 if(!fwrite($handle, $writeData)) {
90 if (trim($sender_file_path) <> trim($file_path)) {
91 $handle = fopen($file_path, "a+");
92 if(!fwrite($handle, $writeData)) {
98 rename($file_path, $ufile_path);
99 if (trim($sender_file_path) <> trim($file_path)) {
100 rename($sender_file_path, $usender_file_path);
102 $_SESSION['msg'] = "Message succesfully sent";
103 header('Location: ../inbox.php');