Initial commit
[2ch-be.git] / dev-test / bak / message.php
blob87b0935ae0bc85f8db6a59ab5a01ff7aaab32bc3
1 <?php
2 include('encrypt.php');
3 require 'include/header.php';
4 $inbox = new Message;
5 $uid = $inbox->GetID($_COOKIE['DMDM'],$id_mail_path);
6 $user = $inbox->FindUser($uid,$id_mail_path);
7 if ($user<>false) {
8 $d = strip_tags(addslashes(trim($_GET['d'])));
9 $messages = $inbox->specificMDB($user, $d, FALSE);
10 $senderCounter = $inbox->specificMDB($user, $d, TRUE);
11 $file = $_SESSION['sLoggedDir'].$d.".dat";
12 $value = $inbox->getContent2($_SESSION['sLoggedDir'].$d.".dat");
13 $max = max($value);
14 $ff = $inbox->within_str(max($value), "<read>", "</read>");
16 if ($uid <> trim($inbox->within_str($senderCounter, "<from>", "</from>"))) {
17 $kausap = trim($inbox->within_str($senderCounter, "<from>", "</from>"));
18 } else {
19 $kausap = trim($inbox->within_str($senderCounter, "<to>", "</to>"));
21 $checkifban = $inbox->CheckBanList($user,$kausap);
22 if ($checkifban)
23 $bansya = true;
24 else
25 $bansya = false;
26 // End of set, check for user block
28 if($ff==0){
29 if(file_exists($file)){
30 $arr = file($file);
31 $newLine = substr($max, 0, -15)."<read>1</read>";
32 $lastLine = count($value)-1;
33 unset($arr[$lastLine]);
34 $arr[$lastLine] = $newLine.PHP_EOL;
35 file_put_contents($file,implode($arr));
36 header("Location: message.php?d=$d");
37 }else{
38 header("Location: inbox.php");
42 if (isset($_POST['block'])) {
43 $block = $inbox->BlockUser($user,$kausap);
44 if ($block) {
45 echo "User Blocked! You cannot receive message from this user";
46 header('Location: '.$_SERVER['REQUEST_URI']);
47 } else {
48 echo "Error! Cannot Block User!";
51 if (isset($_POST['ublock'])) {
52 $block = $inbox->UnblockUser($user,$kausap);
53 if ($block) {
54 echo "User Unblocked! You can now receive message from this user";
55 header('Location: '.$_SERVER['REQUEST_URI']);
56 } else {
57 echo "Error! Cannot Unblock User!";
61 <div class="well well-lg">
62 <?php
63 include "include/nav.php";
64 echo "<h4>”íŽÊ‘Ì: ".urldecode($inbox->within_str($senderCounter, "<subj>", "</subj>"))."</h4>";
66 <div id="block_user" style="display:none" class="alert alert-warning">
67 <form method="post">
68 Are you sure you want to block this user?
69 <input type="submit" class="btn btn-default btn-sm" name="block" value="Yes">&nbsp;&nbsp;
70 <input type="button" class="btn btn-default btn-sm" name="cancel" onclick="document.getElementById('block_user').style.display='none';" value="Cancel">
71 </form>
72 </div>
73 <div id="ublock_user" style="display:none" class="alert alert-warning">
74 <form method="post">
75 Are you sure you want to unblock this user?
76 <input type="submit" class="btn btn-default btn-sm" name="ublock" value="Yes">&nbsp;&nbsp;
77 <input type="button" class="btn btn-default btn-sm" name="cancel" onclick="document.getElementById('ublock_user').style.display='none';" value="Cancel">
78 </form>
79 </div>
80 <?php if (!$bansya) {
82 echo "<input type=\"button\" class=\"btn btn-danger btn-xs\" name=\"block\" onclick=\"document.getElementById('block_user').style.display='block';\" value=\"Block User\"><small>";
83 } else {
84 echo "<input type=\"button\" class=\"btn btn-danger btn-xs\" name=\"ublock\" onclick=\"document.getElementById('ublock_user').style.display='block';\" value=\"Unblock User\">";
85 } ?>
86 <div class="pagination panel panel-default mdes" id="pageMessage">
87 <?php
88 // print_r($messages);
89 // die();
90 for ($i=0; $i < count($messages); $i++) {
91 $leftRightCounter = ($inbox->within_str($messages[$i], "<from>", "</from>")==$uid) ? "r mdes panel panel-default pull-left txt" : "s mdes panel panel-default pull-right txt";
92 echo "<div class=\"".$leftRightCounter."\">". urldecode($inbox->within_str($messages[$i], "<msg>", "</msg>")) . "<br><small class=\"d pull-right\">". date("Y-m-d g:i a",urldecode($inbox->within_str($messages[$i], "<id>", "</id>"))) ."</small></div>";
93 echo "<div class='clearfix'></div>";
95 if ($uid <> trim($inbox->within_str($senderCounter, "<from>", "</from>"))) {
96 $ss = "<input type=\"hidden\" name=\"zxcvbnm\" value=\"".Encrypt($uid.$inbox->within_str($senderCounter, "<from>", "</from>").$inbox->within_str($senderCounter, "<id>", "</id>"), KEY)."\">";
97 } else {
98 $ss = "<input type=\"hidden\" name=\"zxcvbnm\" value=\"".Encrypt($uid.$inbox->within_str($senderCounter, "<to>", "</to>").$inbox->within_str($senderCounter, "<id>", "</id>"), KEY)."\">";
100 echo "</div>";
101 echo "<div id=\"replyForm\" style=\"\">
102 <form method=\"post\" action=\"reply.php\">".@$ss.
103 "<textarea rows=\"5\" name=\"msg\" class=\"form-control\" required></textarea><br>
104 <button type=\"submit\">Send</button>
105 </form>
106 </div>";
107 } else {
108 // echo "Doesn't Exist!";
109 header("Location: index.php");
111 echo "</div>";
112 require 'include/footer.php';