Initial commit
[2ch-be.git] / dev-test / loadM.php
blobf5b932b1c15b40523593aca6274d0663e5c08550
1 <?php
2 if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH']!='XMLHttpRequest' )){
3 header('location: index.php');
5 header('Content-Type: application/json', true);
6 include('encrypt.php');
7 $inbox = new Message;
8 $uid = $inbox->GetID($_COOKIE['DMDM'],$id_mail_path);
9 $user = $inbox->FindUser($uid,$id_mail_path);
12 // function Smilify($subject, $livesitePath){
13 // $smilies = array(
14 // ':|' => 'mellow',
15 // ':-|' => 'mellow',
16 // '&gt;:P' => 'mad',
17 // ':-o' => 'surprised',
18 // ':-O' => 'surprised',
19 // ':o' => 'surprised',
20 // ':O' => 'surprised',
21 // ';)' => 'wink',
22 // ';-)' => 'wink',
23 // // ':p' => 'tongue',
24 // // ':-p' => 'tongue',
25 // // ':P' => 'tongue',
26 // // ':-P' => 'tongue',
27 // ':D' => 'grin',
28 // ':-D' => 'grin',
29 // '8)' => 'cool',
30 // '8-)' => 'cool',
31 // ':)' => 'smile',
32 // ':-)' => 'smile',
33 // ':(' => 'sad',
34 // ':-(' => 'sad',
35 // );
37 // $sizes = array(
38 // 'grin' => 15,
39 // 'cool' => 15,
40 // // 'haha' => 15,
41 // 'mellow' => 15,
42 // 'surprised' => 15,
43 // 'sad' => 15,
44 // 'smile' => 15,
45 // 'mad' => 15,
46 // // 'tongue' => 15,
47 // 'wink' => 15,
48 // );
50 // $replace = array();
51 // foreach ($smilies as $smiley => $imgName)
52 // {
53 // $size = $sizes[$imgName];
54 // array_push($replace, '<img src="'.$livesitePath.'imagess/'.$imgName.'.png" alt="'.$smiley.'" style="width:'.$size.'px;"/>');
55 // }
56 // $subject = str_replace(array_keys($smilies), $replace, $subject);
57 // return $subject;
58 // }
59 function specificMDB($user, $dat, $turn) {
60 // Turn is yung incrementation.
61 // Ignore this
62 $fdir = substr($user, 0, 1);
63 $sdir = substr($user, 1, 1);
64 $udir = str_replace("@", "-", $user);
65 $path = MDB_PATH."{$fdir}/{$sdir}/{$udir}";
66 // Ignore this
68 $messages = array();
69 // Checking Path
70 if(file_exists($path."/{$dat}.dat")){
71 $i = 0;
72 $messages = file("{$path}/{$dat}.dat");
73 $count = sizeof($messages);
74 $total = $count-$turn;
75 $start = $total-$turn;
76 $start = abs($start);
77 if($start >= $total){
78 return array($messages, TRUE, $total, 0);
79 }else{
80 return array($messages, FALSE, $total, $start);
83 }else{
84 return false;
87 $d = strip_tags(addslashes(trim($_POST['data'])));
88 $messages = specificMDB($user, $d, $_POST['load']);
89 $senderCounter = $inbox->specificMDB($user, $d, TRUE);
91 $returnValues['breaker'] = $messages[1];
92 $returnValues["total"] = abs($messages[2]);
93 $returnValues['start'] = abs($messages[3]);
95 if ($uid <> trim($inbox->within_str($senderCounter, "<from>", "</from>"))) {
97 for ($i=$returnValues['start']; $i < $returnValues['total']; $i++) {
99 // $getid = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? ($inbox->within_str($senderCounter, "<from>", "</from>")) : ($inbox->within_str($senderCounter, "<to>", "</to>"));
100 // $getid = $inbox->FindUser($getid,$id_mail_path);
101 // $getid = trim($inbox->GetImgTrip($getid));
102 // $getid = explode("\n", $getid);
103 // $uimg = trim($getid[5]);
104 // $lr = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? "pull-left" : "pull-right";
106 // $leftRightCounter = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? "r mdes panel panel-default pull-left txt" : "s mdes panel panel-default pull-right txt";
107 if ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) {
108 $leftRightCounter = "r mdes panel panel-default pull-left txt";
109 $getid = $inbox->within_str($senderCounter, "<to>", "</to>");
110 } else {
111 $leftRightCounter = "s mdes panel panel-default pull-right txt";
112 $getid = $inbox->within_str($senderCounter, "<from>", "</from>");
115 $getid = $inbox->FindUser($getid,$id_mail_path);
116 $getid = trim($inbox->GetImgTrip($getid));
117 $getid = explode("\n", $getid);
118 $uimg = trim($getid[5]);
119 if (strpos($uimg, "-PREM")) {
120 $ico = explode("-PREM", $uimg);
121 $uimg = "<img src=\"".$livesitePath2."/premium/".$ico[0]."\" class='pic2'/>";
122 } else {
123 $uimg = "<img src=\"".$livesitePath2."/ico/".$uimg."\" class='pic2'/>";
126 $lr = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? "pull-left" : "pull-right";
127 $tripcode = trim($getid[7]);
128 $tripcode = (empty($tripcode)) ? $getid[0] : $getid[7];
130 $returnValues["array"][] = "<div class=\"panel panel-default ic4 {$lr}\"><a href=\"".$livesitePath."test/p.php?i=".$getid[0]."\" target=\"_blank\">{$uimg}</a></div><div class=\"".$leftRightCounter."\">".
131 Smilify(mb_convert_encoding(urldecode($inbox->within_str($messages[0][$i], "<msg>", "</msg>")), "UTF-8", "SHIFT-JIS"),$livesitePath). "<br><small class=\"d pull-left\">".$tripcode."</small><small class=\"d pull-right\">". date("Y-m-d g:i a",urldecode($inbox->within_str($messages[0][$i], "<id>", "</id>"))) ."</small></div> <div class='clearfix'></div>";
134 }else{
135 for ($i=$returnValues['start']; $i < $returnValues['total']; $i++) {
137 // $getid = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? ($inbox->within_str($senderCounter, "<from>", "</from>")) : ($inbox->within_str($senderCounter, "<to>", "</to>"));
138 // $getid = $inbox->FindUser($getid,$id_mail_path);
139 // $getid = trim($inbox->GetImgTrip($getid));
140 // $getid = explode("\n", $getid);
141 // $uimg = trim($getid[5]);
142 // $lr = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? "pull-left" : "pull-right";
144 // $leftRightCounter = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? "r mdes panel panel-default pull-left txt" : "s mdes panel panel-default pull-right txt";
145 if ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) {
146 $leftRightCounter = "r mdes panel panel-default pull-left txt";
147 $getid = $inbox->within_str($senderCounter, "<from>", "</from>");
148 } else {
149 $leftRightCounter = "s mdes panel panel-default pull-right txt";
150 $getid = $inbox->within_str($senderCounter, "<to>", "</to>");
154 $getid = $inbox->FindUser($getid,$id_mail_path);
155 $getid = trim($inbox->GetImgTrip($getid));
156 $getid = explode("\n", $getid);
157 $uimg = trim($getid[5]);
158 if (strpos($uimg, "-PREM")) {
159 $ico = explode("-PREM", $uimg);
160 $uimg = "<img src=\"".$livesitePath2."/premium/".$ico[0]."\" class='pic2'/>";
161 } else {
162 $uimg = "<img src=\"".$livesitePath2."/ico/".$uimg."\" class='pic2'/>";
164 $lr = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? "pull-left" : "pull-right";
165 $tripcode = trim($getid[7]);
166 $tripcode = (empty($tripcode)) ? $getid[0] : $getid[7];
168 $returnValues["array"][] = "<div class=\"panel panel-default ic4 {$lr}\"><a href=\"".$livesitePath."test/p.php?i=".$getid[0]."\" target=\"_blank\">{$uimg}</a></div><div class=\"".$leftRightCounter."\">".
170 Smilify(mb_convert_encoding(urldecode($inbox->within_str($messages[0][$i], "<msg>", "</msg>")), "UTF-8", "SHIFT-JIS"),$livesitePath). "<br><small class=\"d pull-left\">".$tripcode."</small><small class=\"d pull-right\">". date("Y-m-d g:i a",urldecode($inbox->within_str($messages[0][$i], "<id>", "</id>"))) ."</small></div> <div class='clearfix'></div>";
174 // for ($i=$returnValues['start']; $i < $returnValues['total']; $i++) {
176 // $getid = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? ($inbox->within_str($senderCounter, "<from>", "</from>")) : ($inbox->within_str($senderCounter, "<to>", "</to>"));
177 // $getid = $inbox->FindUser($getid,$id_mail_path);
178 // $getid = trim($inbox->GetImgTrip($getid));
179 // $getid = explode("\n", $getid);
180 // $uimg = trim($getid[5]);
181 // $lr = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? "pull-left" : "pull-right";
183 // $leftRightCounter = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? "r mdes panel panel-default pull-left txt" : "s mdes panel panel-default pull-right txt";
184 // $returnValues["array"][] = "<div class=\"panel panel-default ic4 {$lr}\"><img src=\"".$livesitePath2."/ico/{$uimg}\" class=\"pic2\" ></div><div class=\"".$leftRightCounter."\">".
185 // mb_convert_encoding(urldecode($inbox->within_str($messages[0][$i], "<msg>", "</msg>")), "UTF-8", "SHIFT-JIS"). "<br><small class=\"d pull-right\">". date("Y-m-d g:i a",urldecode($inbox->within_str($messages[0][$i], "<id>", "</id>"))) ."</small></div> <div class='clearfix'></div>";
187 // }
188 // dont
189 if(isset($returnValues["array"])){
190 echo json_encode($returnValues);