Initial commit
[2ch-be.git] / dev-test / bak / reply4.php
blob6356c3145969721f997d26b029bf8d46bf0659a2
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 = Decrypt(addslashes(trim($_POST['zxcvbnm'])), KEY);
16 //$sub = addslashes(trim($_POST['zxcvbnm']));
17 $msg = trim($_POST['msg']);
19 if (strlen($msg) > 250) {
20 echo "’·‚·‚¬‚éƒRƒ“ƒeƒ“ƒc";
21 exit;
24 $from = substr($sub, 0, 9);
25 $to = substr($sub, 9, 9);
26 $file = substr($sub, 18);
28 $reply = new Message;
29 if($reply->CheckBanMessaging()) {
30 echo "ƒ�ƒbƒZ�[ƒW‚ð‘—�M‚·‚邱‚Æ‚Í‚Å‚«‚Ü‚¹‚ñ�A’á‚·‚¬‚é‚Ì“_BE";
31 exit;
34 $msg = $reply->BeSanitize($msg);
35 $reply_receiver = $reply->FindUser($to,$id_mail_path);
37 $fdir = substr($reply_receiver, 0, 1);
38 $sdir = substr($reply_receiver, 1, 1);
39 $udir = str_replace("@", "-", $reply_receiver);
40 $file_path = MDB_PATH."{$fdir}/{$sdir}/{$udir}/{$file}.dat";
41 //$ufile_path = MDB_PATH."{$fdir}/{$sdir}/{$udir}/u_{$file}.dat";
42 $tmp_copy_path = MDB_PATH."{$fdir}/{$sdir}/{$udir}";
44 $sender_path = $reply->FindUser($from,$id_mail_path);
45 if ($sender_path == false) {
46 echo "NG";
47 exit;
50 $allow_post = $reply->CheckPostLimit($from,$plimit_path,TRUE);
51 if (($allow_post >= 60) && ($allow_post != false)) {
52 echo "“ž’B‚µ‚½Œã‚Ì�§ŒÀ‚Í�AŽŸ‚Ì•ª‚¨‘Ò‚¿‚­‚¾‚³‚¢";
53 exit;
56 $allow_post = $reply->CheckPostLimit($from,$plimit_hpath,FALSE);
57 if (($allow_post >= 600) && ($allow_post != false)) {
58 echo "“ž’B‚µ‚½Œã‚Ì�§ŒÀ‚Í�AŽŸ‚Ì1ŽžŠÔ‚¨‘Ò‚¿‚­‚¾‚³‚¢";
59 exit;
62 $fdir2 = substr($sender_path, 0, 1);
63 $sdir2 = substr($sender_path, 1, 1);
64 $udir2 = str_replace("@", "-", $sender_path);
65 $sender_file_path = MDB_PATH."{$fdir2}/{$sdir2}/{$udir2}/{$file}.dat";
66 //$usender_file_path = MDB_PATH."{$fdir2}/{$sdir2}/{$udir2}/u_{$file}.dat";
67 date_default_timezone_set("Asia/Tokyo");
68 $time = time();
69 $writeData = "<id>{$time}</id><from>{$from}</from><subj></subj><msg>{$msg}</msg><read>0</read>\n";
70 $writeDataSender = "<id>{$time}</id><from>{$from}</from><subj></subj><msg>{$msg}</msg><read>1</read>\n";
72 //echo $file_path."<br>";
73 //echo $sender_file_path;
74 if (!file_exists($file_path)) {
75 //echo "--una--";
76 if (file_exists($sender_file_path)) {
77 if (!file_exists($tmp_copy_path)) {
78 @mkdir(MDB_PATH."{$fdir}");
79 @mkdir(MDB_PATH."{$fdir}/{$sdir}");
80 @mkdir(MDB_PATH."{$fdir}/{$sdir}/{$udir}");
82 if (file_exists($tmp_copy_path."/ban.txt")) {
83 $banlist = file($tmp_copy_path."/ban.txt");
84 foreach ($banlist as $key => $value) {
85 if (trim($from) == trim($value)) {
86 //echo "Message sending failed, You have been blocked by the user";
87 $_SESSION['msg'] = "<div class=\"alert alert-danger\">ƒ�ƒbƒZ�[ƒW‘—�M‚ªŽ¸”s‚µ�Aƒ†�[ƒU�[‚É‚æ‚Á‚ăuƒ�ƒbƒN‚³‚ꂽ</div>";
88 header('Location:message.php?d='.$file);
89 // header('Location:inbox.php');
90 exit;
94 $aa = file($sender_file_path);
95 $aa = implode("\n", $aa);
96 $aa = str_replace("\n\n", "\n", $aa); // A pain before I found this bug!
97 file_put_contents($file_path, $aa);
98 $handle = fopen($sender_file_path, "a");
99 //if(!fwrite($handle, $writeData)) {
100 if(!fwrite($handle, $writeDataSender)) {
101 echo "Error 1!";
102 exit;
104 fclose($handle);
105 } else {
106 echo "Error 2!";
108 if (trim($sender_file_path) <> trim($file_path)) {
109 $handle = fopen($file_path, "a");
110 if(!fwrite($handle, $writeData)) {
111 echo "Error 3!";
112 exit;
114 fclose($handle);
117 $add_post = $reply->AddPostLimit($from,$plimit_path,TRUE);
118 $add_post = $reply->AddPostLimit($from,$plimit_hpath,FALSE);
120 $_SESSION['msg'] = "<div class=\"alert alert-success\">�³�í‚É‘—�M‚³‚ꂽƒ�ƒbƒZ�[ƒW</div>";
121 header('Location:message.php?d='.$file);
122 // header('Location:inbox.php');
124 } else {
125 if (file_exists($tmp_copy_path."/ban.txt")) {
126 $banlist = file($tmp_copy_path."/ban.txt");
127 foreach ($banlist as $key => $value) {
128 if (trim($from) == trim($value)) {
129 //echo "Message sending failed, You have been blocked by the user";
130 $_SESSION['msg'] = "<div class=\"alert alert-danger\">ƒ�ƒbƒZ�[ƒW‘—�M‚ªŽ¸”s‚µ�Aƒ†�[ƒU�[‚É‚æ‚Á‚ăuƒ�ƒbƒN‚³‚ꂽ</div>";
131 header('Location:message.php?d='.$file);
132 // header('Location:inbox.php');
133 exit;
137 //echo "--pangalawa--";
138 $handle = fopen($sender_file_path, "a");
139 //if(!fwrite($handle, $writeData)) {
140 if(!fwrite($handle, $writeDataSender)) {
141 echo "Error 4";
142 exit;
144 fclose($handle);
145 if (trim($sender_file_path) <> trim($file_path)) {
146 $handle = fopen($file_path, "a");
147 if(!fwrite($handle, $writeData)) {
148 echo "Error 5";
149 exit;
151 fclose($handle);
154 $add_post = $reply->AddPostLimit($from,$plimit_path,TRUE);
155 $add_post = $reply->AddPostLimit($from,$plimit_hpath,FALSE);
156 $_SESSION['msg'] = "<div class=\"alert alert-success\">�³�í‚É‘—�M‚³‚ꂽƒ�ƒbƒZ�[ƒW</div>";
157 // header('Location:inbox.php');
158 header('Location:message.php?d='.$file);
162 </body>
163 </html>