Initial commit
[2ch-be.git] / dev-test / simulation.php
blob38ca4f722380ec2b6f4521b55c9dc49d66ee53d5
1 <?php
2 include('encrypt.php');
3 setlocale(LC_ALL, 'ja_JP.EUC-JP');
4 $inbox = new Message;
5 $uid = $inbox->GetID($_COOKIE['DMDM'],$id_mail_path);
7 $user = $inbox->FindUser($uid,$id_mail_path);
8 $d = $_GET['d'];
9 $l = $_GET['load'];
10 $start = $_GET['start'];
11 $total = $_GET['total'];
12 function specificMDB($user, $dat, $turn) {
13 // Turn is yung incrementation.
14 // Ignore this
15 $fdir = substr($user, 0, 1);
16 $sdir = substr($user, 1, 1);
17 $udir = str_replace("@", "-", $user);
18 $path = MDB_PATH."{$fdir}/{$sdir}/{$udir}";
19 // Ignore this
21 $messages = array();
22 // Checking Path
23 if(file_exists($path."/{$dat}.dat")){
24 $i = 0;
25 $messages = file("{$path}/{$dat}.dat");
26 $count = sizeof($messages);
27 $total = $count-$turn;
28 $start = $total-$turn;
29 $start = abs($start);
30 if($start >= $total){
31 return array($messages, TRUE, $total, 0);
32 }else{
33 return array($messages, FALSE, $total, $start);
36 }else{
37 return false;
40 $d = strip_tags(addslashes(trim($d)));
41 $messages = specificMDB($user, $d, $l);
43 $returnValues['breaker'] = $messages[1];
44 $returnValues["total"] = abs($messages[2]);
45 $returnValues['start'] = abs($messages[3]);
48 for ($i=$start; $i < $total; $i++) {
50 $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";
51 $returnValues["array"][] =
53 "<div class=\"".$leftRightCounter."\">". mb_convert_encoding(urldecode($inbox->within_str($messages[0][$i], "<msg>", "</msg>")), "UTF-8", "SHIFT-JIS").
54 "<br><small class=\"d pull-right\">".
55 date("Y-m-d g:i a",urldecode($inbox->within_str($messages[0][$i], "<id>", "</id>"))) ."</small></div> <div class='clearfix'></div>";
56 // echo "<div class=\"".$leftRightCounter."\">". urldecode($inbox->within_str($messages[0][$i], "<msg>", "</msg>")) . "<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>";
58 // utf8_encode($returnValues);
59 // echo "<pre>";
60 // print_r($returnValues);
61 // echo "</pre>";
62 // dont
63 // if(isset($returnValues["array"])){
64 echo json_encode($returnValues)."<br />xxx";
65 // echo json_last_error();
66 // echo json_encode("ƒXƒe[ƒ^ƒX
68 // ŒöŠJƒvƒƒtƒB[ƒ‹
70 // ŽóMƒgƒŒƒC
72 // ƒ[ƒ‹‚ðƒ`ƒFƒbƒN");
73 // }