Initial commit
[2ch-be.git] / dev-test / reply.php
bloba329f3b7aefbcf8305f911bfb3339c4a36d4ef67
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 $from = substr($sub, 0, 9);
21 $to = substr($sub, 9, 9);
22 $file = substr($sub, 18);
24 $chkspc = trim(str_replace("&nbsp;", " ", $msg));
26 if (strlen($msg) < 1 || strlen($chkspc) < 1) {
27 $_SESSION['msg'] = "<div class=\"alert alert-danger\">‹–‰Â‚³‚ê‚Ä‚¢‚È‚¢</div>";
28 header('Location:message.php?d='.$file);
29 exit;
32 if (strlen($msg) > 250) {
33 $_SESSION['msg'] = "<div class=\"alert alert-danger\">’·‚·‚¬‚éƒRƒ“ƒeƒ“ƒc</div>";
34 header('Location:message.php?d='.$file);
35 exit;
38 $reply = new Message;
39 if($reply->CheckBanMessaging()) {
40 $_SESSION['msg'] = "<div class=\"alert alert-danger\">BEƒ|ƒCƒ“ƒg‚ª‘«‚è‚È‚¢‚Ì‚Å�Aƒ�ƒbƒZ�[ƒW‚ð‘—�M‚·‚邱‚Æ‚ª‚Å‚«‚Ü‚¹‚ñ�B</div>";
41 header('Location:message.php?d='.$file);
42 exit;
45 $msg = $reply->BeSanitize($msg);
46 $reply_receiver = $reply->FindUser($to,$id_mail_path);
48 $fdir = substr($reply_receiver, 0, 1);
49 $sdir = substr($reply_receiver, 1, 1);
50 $udir = str_replace("@", "-", $reply_receiver);
51 $file_path = MDB_PATH."{$fdir}/{$sdir}/{$udir}/{$file}.dat";
52 $file_del_path = MDB_PATH."{$fdir}/{$sdir}/{$udir}/del/{$file}.dat";
53 //$ufile_path = MDB_PATH."{$fdir}/{$sdir}/{$udir}/u_{$file}.dat";
54 $tmp_copy_path = MDB_PATH."{$fdir}/{$sdir}/{$udir}";
56 if (file_exists($tmp_copy_path."/ban.txt")) {
57 $banlist = file($tmp_copy_path."/ban.txt");
58 foreach ($banlist as $key => $value) {
59 if (trim($from) == trim($value)) {
60 //echo "Message sending failed, You have been blocked by the user";
61 $_SESSION['msg'] = "<div class=\"alert alert-danger\"> ƒ�ƒbƒZ�[ƒW‘—�M‚ªŽ¸”s‚µ�Aƒ†�[ƒU�[‚É‚æ‚Á‚ăuƒ�ƒbƒN‚³‚ê‚Ä‚¢‚Ü‚· </div>";
62 header('Location:message.php?d='.$file);
63 exit;
68 $sender_path = $reply->FindUser($from,$id_mail_path);
69 if ($sender_path == false) {
70 echo "NG";
71 exit;
74 $allow_post = $reply->CheckPostLimit($from,$plimit_path,TRUE);
75 if (($allow_post >= 60) && ($allow_post != false)) {
76 $_SESSION['msg'] = "<div class=\"alert alert-danger\">“ž’B‚µ‚½Œã‚Ì�§ŒÀ‚Í�AŽŸ‚Ì•ª‚¨‘Ò‚¿‚­‚¾‚³‚¢</div>";
77 header('Location:message.php?d='.$file);
78 exit;
81 $allow_post = $reply->CheckPostLimit($from,$plimit_hpath,FALSE);
82 if (($allow_post >= 600) && ($allow_post != false)) {
83 $_SESSION['msg'] = "<div class=\"alert alert-danger\">“ž’B‚µ‚½Œã‚Ì�§ŒÀ‚Í�AŽŸ‚Ì1ŽžŠÔ‚¨‘Ò‚¿‚­‚¾‚³‚¢</div>";
84 header('Location:message.php?d='.$file);
85 exit;
88 $fdir2 = substr($sender_path, 0, 1);
89 $sdir2 = substr($sender_path, 1, 1);
90 $udir2 = str_replace("@", "-", $sender_path);
91 $sender_file_path = MDB_PATH."{$fdir2}/{$sdir2}/{$udir2}/{$file}.dat";
92 //$usender_file_path = MDB_PATH."{$fdir2}/{$sdir2}/{$udir2}/u_{$file}.dat";
93 date_default_timezone_set("Asia/Tokyo");
94 $time = time();
96 $writeData = "<id>{$time}</id><from>{$from}</from><to>{$to}</to><subj>{$sbj}</subj><msg>{$msg}</msg><read>0</read>\n";
97 $writeDataSender = "<id>{$time}</id><from>{$from}</from><to>{$to}</to><subj>{$sbj}</subj><msg>{$msg}</msg><read>1</read>\n";
99 if (file_exists($file_del_path)) {
100 file_put_contents($file_path, "");
101 unlink($file_del_path);
104 //echo $file_path."<br>";
105 //echo $sender_file_path;
106 if (!file_exists($file_path)) {
107 //echo "--una--";
108 if (file_exists($sender_file_path)) {
109 if (!file_exists($tmp_copy_path)) {
110 @mkdir(MDB_PATH."{$fdir}");
111 @mkdir(MDB_PATH."{$fdir}/{$sdir}");
112 @mkdir(MDB_PATH."{$fdir}/{$sdir}/{$udir}");
114 $aa = file($sender_file_path);
115 $aa = implode("\n", $aa);
116 $aa = str_replace("\n\n", "\n", $aa); // A pain before I found this bug!
117 file_put_contents($file_path, $aa);
118 $handle = fopen($sender_file_path, "a");
119 //if(!fwrite($handle, $writeData)) {
120 if(!fwrite($handle, $writeDataSender)) {
121 echo "Error 1!";
122 exit;
124 fclose($handle);
125 } else {
126 echo "Error 2!";
128 if (trim($sender_file_path) <> trim($file_path)) {
129 $handle = fopen($file_path, "a");
130 if(!fwrite($handle, $writeData)) {
131 echo "Error 3!";
132 exit;
134 fclose($handle);
137 $add_post = $reply->AddPostLimit($from,$plimit_path,TRUE);
138 $add_post = $reply->AddPostLimit($from,$plimit_hpath,FALSE);
140 # $_SESSION['msg'] = "<div class=\"alert alert-success\">�³�í‚É‘—�M‚³‚ꂽƒ�ƒbƒZ�[ƒW</div>";
141 $_SESSION['msg'] = "<div class=\"alert alert-success\">�³�í‚É‘—�M‚³‚ꂽƒ�ƒbƒZ�[ƒW</div>";
142 header('Location:message.php?d='.$file);
143 // header('Location:inbox.php');
145 } else {
146 //echo "--pangalawa--";
147 $handle = fopen($sender_file_path, "a");
148 //if(!fwrite($handle, $writeData)) {
149 if(!fwrite($handle, $writeDataSender)) {
150 echo "Error 4";
151 exit;
153 fclose($handle);
154 if (trim($sender_file_path) <> trim($file_path)) {
155 $handle = fopen($file_path, "a");
156 if(!fwrite($handle, $writeData)) {
157 echo "Error 5";
158 exit;
160 fclose($handle);
163 $add_post = $reply->AddPostLimit($from,$plimit_path,TRUE);
164 $add_post = $reply->AddPostLimit($from,$plimit_hpath,FALSE);
165 # $_SESSION['msg'] = "<div class=\"alert alert-success\">�³�í‚É‘—�M‚³‚ꂽƒ�ƒbƒZ�[ƒW</div>";
166 $_SESSION['msg'] = "<div class=\"alert alert-success\">�³�í‚É‘—�M‚³‚ꂽƒ�ƒbƒZ�[ƒW</div>";
167 // header('Location:inbox.php');
168 header('Location:message.php?d='.$file);
172 </body>
173 </html>