Initial commit
[2ch-be.git] / dev-test / rewrite / loadM.php
blobd0afd7eabf12db549f448f777cee26b00bb31a9a
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('include/config.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 $lr = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? "pull-left" : "pull-right";
120 $tripcode = trim($getid[7]);
121 $tripcode = (empty($tripcode)) ? $getid[0] : $getid[7];
123 $returnValues["array"][] = "<div class=\"panel panel-default ic4 {$lr}\"><a href=\"".$livesitePath."test/p.php?i=".$getid[0]."\" target=\"_blank\"><img src=\"".$livesitePath2."/ico/{$uimg}\" class=\"pic2\" ></a></div><div class=\"".$leftRightCounter."\">".
124 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>";
127 }else{
128 for ($i=$returnValues['start']; $i < $returnValues['total']; $i++) {
130 // $getid = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? ($inbox->within_str($senderCounter, "<from>", "</from>")) : ($inbox->within_str($senderCounter, "<to>", "</to>"));
131 // $getid = $inbox->FindUser($getid,$id_mail_path);
132 // $getid = trim($inbox->GetImgTrip($getid));
133 // $getid = explode("\n", $getid);
134 // $uimg = trim($getid[5]);
135 // $lr = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? "pull-left" : "pull-right";
137 // $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";
138 if ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) {
139 $leftRightCounter = "r mdes panel panel-default pull-left txt";
140 $getid = $inbox->within_str($senderCounter, "<from>", "</from>");
141 } else {
142 $leftRightCounter = "s mdes panel panel-default pull-right txt";
143 $getid = $inbox->within_str($senderCounter, "<to>", "</to>");
147 $getid = $inbox->FindUser($getid,$id_mail_path);
148 $getid = trim($inbox->GetImgTrip($getid));
149 $getid = explode("\n", $getid);
150 $uimg = trim($getid[5]);
151 $lr = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? "pull-left" : "pull-right";
152 $tripcode = trim($getid[7]);
153 $tripcode = (empty($tripcode)) ? $getid[0] : $getid[7];
155 $returnValues["array"][] = "<div class=\"panel panel-default ic4 {$lr}\"><a href=\"".$livesitePath."test/p.php?i=".$getid[0]."\" target=\"_blank\"><img src=\"".$livesitePath2."/ico/{$uimg}\" class=\"pic2\" ></a></div><div class=\"".$leftRightCounter."\">".
157 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>";
161 // for ($i=$returnValues['start']; $i < $returnValues['total']; $i++) {
163 // $getid = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? ($inbox->within_str($senderCounter, "<from>", "</from>")) : ($inbox->within_str($senderCounter, "<to>", "</to>"));
164 // $getid = $inbox->FindUser($getid,$id_mail_path);
165 // $getid = trim($inbox->GetImgTrip($getid));
166 // $getid = explode("\n", $getid);
167 // $uimg = trim($getid[5]);
168 // $lr = ($inbox->within_str($messages[0][$i], "<from>", "</from>")==$uid) ? "pull-left" : "pull-right";
170 // $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";
171 // $returnValues["array"][] = "<div class=\"panel panel-default ic4 {$lr}\"><img src=\"".$livesitePath2."/ico/{$uimg}\" class=\"pic2\" ></div><div class=\"".$leftRightCounter."\">".
172 // 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>";
174 // }
175 // dont
176 if(isset($returnValues["array"])){
177 echo json_encode($returnValues);