Initial commit
[2ch-be.git] / dev-test / old_dev / replybackw.php
blob6b9f44220abd894d42a5b02ec363f0dc6d303a53
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="Shift_JIS">
5 </head>
6 <body>
7 <?php
8 if (!isset($_COOKIE['DMDM']) && !isset($_COOKIE['MDMD'])) {
9 header('location:index.php');
10 exit;
12 session_start();
13 include('encrypt.php');
15 //$sub = addslashes(trim($_POST['zxcvbnm']));
16 $sub = Decrypt(addslashes(trim($_POST['zxcvbnm'])), KEY);
17 $msg = trim($_POST['msg']);
18 $sbj = trim($_POST['sbj']);
20 if (strlen($msg) > 250) {
21 $_SESSION['msg'] = "<div class=\"alert alert-danger\">’·‚·‚¬‚éƒRƒ“ƒeƒ“ƒc</div>";
22 header('Location:message.php?d='.$file);
23 exit;
26 $from = substr($sub, 0, 9);
27 $to = substr($sub, 9, 9);
28 $file = substr($sub, 18);
30 $reply = new Message;
31 if($reply->CheckBanMessaging()) {
32 $_SESSION['msg'] = "<div class=\"alert alert-danger\">BEƒ|ƒCƒ“ƒg‚ª‘«‚è‚È‚¢‚Ì‚Å�Aƒ�ƒbƒZ�[ƒW‚ð‘—�M‚·‚邱‚Æ‚ª‚Å‚«‚Ü‚¹‚ñ�B</div>";
33 header('Location:message.php?d='.$file);
34 exit;
37 $msg = $reply->BeSanitize($msg);
38 $reply_receiver = $reply->FindUser($to,$id_mail_path);
40 $fdir = substr($reply_receiver, 0, 1);
41 $sdir = substr($reply_receiver, 1, 1);
42 $udir = str_replace("@", "-", $reply_receiver);
43 $file_path = MDB_PATH."{$fdir}/{$sdir}/{$udir}/{$file}.dat";
44 $file_del_path = MDB_PATH."{$fdir}/{$sdir}/{$udir}/del/{$file}.dat";
45 //$ufile_path = MDB_PATH."{$fdir}/{$sdir}/{$udir}/u_{$file}.dat";
46 $tmp_copy_path = MDB_PATH."{$fdir}/{$sdir}/{$udir}";
48 if (file_exists($tmp_copy_path."/ban.txt")) {
49 $banlist = file($tmp_copy_path."/ban.txt");
50 foreach ($banlist as $key => $value) {
51 if (trim($from) == trim($value)) {
52 //echo "Message sending failed, You have been blocked by the user";
53 $_SESSION['msg'] = "<div class=\"alert alert-danger\"> ƒ�ƒbƒZ�[ƒW‘—�M‚ªŽ¸”s‚µ�Aƒ†�[ƒU�[‚É‚æ‚Á‚ăuƒ�ƒbƒN‚³‚ê‚Ä‚¢‚Ü‚· </div>";
54 header('Location:message.php?d='.$file);
55 exit;
60 $sender_path = $reply->FindUser($from,$id_mail_path);
61 if ($sender_path == false) {
62 echo "NG";
63 exit;
66 $allow_post = $reply->CheckPostLimit($from,$plimit_path,TRUE);
67 if (($allow_post >= 60) && ($allow_post != false)) {
68 $_SESSION['msg'] = "<div class=\"alert alert-danger\">“ž’B‚µ‚½Œã‚Ì�§ŒÀ‚Í�AŽŸ‚Ì•ª‚¨‘Ò‚¿‚­‚¾‚³‚¢</div>";
69 header('Location:message.php?d='.$file);
70 exit;
73 $allow_post = $reply->CheckPostLimit($from,$plimit_hpath,FALSE);
74 if (($allow_post >= 600) && ($allow_post != false)) {
75 $_SESSION['msg'] = "<div class=\"alert alert-danger\">“ž’B‚µ‚½Œã‚Ì�§ŒÀ‚Í�AŽŸ‚Ì1ŽžŠÔ‚¨‘Ò‚¿‚­‚¾‚³‚¢</div>";
76 header('Location:message.php?d='.$file);
77 exit;
80 $fdir2 = substr($sender_path, 0, 1);
81 $sdir2 = substr($sender_path, 1, 1);
82 $udir2 = str_replace("@", "-", $sender_path);
83 $sender_file_path = MDB_PATH."{$fdir2}/{$sdir2}/{$udir2}/{$file}.dat";
84 //$usender_file_path = MDB_PATH."{$fdir2}/{$sdir2}/{$udir2}/u_{$file}.dat";
85 date_default_timezone_set("Asia/Tokyo");
86 $time = time();
88 $writeData = "<id>{$time}</id><from>{$from}</from><to>{$to}</to><subj>{$sbj}</subj><msg>{$msg}</msg><read>0</read>\n";
89 $writeDataSender = "<id>{$time}</id><from>{$from}</from><to>{$to}</to><subj>{$sbj}</subj><msg>{$msg}</msg><read>1</read>\n";
91 if (file_exists($file_del_path)) {
92 file_put_contents($file_path, "");
93 rename($file_del_path, $file_del_path."_".$from);
94 //unlink($file_del_path);
97 //echo $file_path."<br>";
98 //echo $sender_file_path;
99 if (!file_exists($file_path)) {
100 //echo "--una--";
101 if (file_exists($sender_file_path)) {
102 if (!file_exists($tmp_copy_path)) {
103 @mkdir(MDB_PATH."{$fdir}");
104 @mkdir(MDB_PATH."{$fdir}/{$sdir}");
105 @mkdir(MDB_PATH."{$fdir}/{$sdir}/{$udir}");
107 $aa = file($sender_file_path);
108 $aa = implode("\n", $aa);
109 $aa = str_replace("\n\n", "\n", $aa); // A pain before I found this bug!
110 file_put_contents($file_path, $aa);
111 $handle = fopen($sender_file_path, "a");
112 //if(!fwrite($handle, $writeData)) {
113 if(!fwrite($handle, $writeDataSender)) {
114 echo "Error 1!";
115 exit;
117 fclose($handle);
118 } else {
119 echo "Error 2!";
121 if (trim($sender_file_path) <> trim($file_path)) {
122 $handle = fopen($file_path, "a");
123 if(!fwrite($handle, $writeData)) {
124 echo "Error 3!";
125 exit;
127 fclose($handle);
130 $add_post = $reply->AddPostLimit($from,$plimit_path,TRUE);
131 $add_post = $reply->AddPostLimit($from,$plimit_hpath,FALSE);
133 # $_SESSION['msg'] = "<div class=\"alert alert-success\">�³�í‚É‘—�M‚³‚ꂽƒ�ƒbƒZ�[ƒW</div>";
134 $_SESSION['msg'] = "<div class=\"alert alert-success\">�³�í‚É‘—�M‚³‚ꂽƒ�ƒbƒZ�[ƒW</div>";
135 header('Location:message.php?d='.$file);
136 // header('Location:inbox.php');
138 } else {
139 //echo "--pangalawa--";
140 $handle = fopen($sender_file_path, "a");
141 //if(!fwrite($handle, $writeData)) {
142 if(!fwrite($handle, $writeDataSender)) {
143 echo "Error 4";
144 exit;
146 fclose($handle);
147 if (trim($sender_file_path) <> trim($file_path)) {
148 $handle = fopen($file_path, "a");
149 if(!fwrite($handle, $writeData)) {
150 echo "Error 5";
151 exit;
153 fclose($handle);
156 $add_post = $reply->AddPostLimit($from,$plimit_path,TRUE);
157 $add_post = $reply->AddPostLimit($from,$plimit_hpath,FALSE);
158 # $_SESSION['msg'] = "<div class=\"alert alert-success\">�³�í‚É‘—�M‚³‚ꂽƒ�ƒbƒZ�[ƒW</div>";
159 $_SESSION['msg'] = "<div class=\"alert alert-success\">�³�í‚É‘—�M‚³‚ꂽƒ�ƒbƒZ�[ƒW</div>";
160 // header('Location:inbox.php');
161 header('Location:message.php?d='.$file);
165 </body>
166 </html>