OSDN Git Service

c3d23807edbf93882f08d36c0fbc9f7425555bc1
[trpgtools-onweb/AjaxChat.git] / lib / log.php
1 <?php
2 /*
3  Ajax Chat for TRPG ver.2.6
4  (c)2007-2009 Cake All Rights Reserved.
5  Mail : cake_67@users.sourceforge.jp
6  Home : http://trpgtools-onweb.sourceforge.jp/
7  */
8
9 /*****************
10  *  PHPライブラリ:ログのPHP読み込み用
11  *****************/
12
13 /*
14  * ログ基本整形
15  */
16 function format_log($line, $hash='', $d=true, $is_mobile=false)
17 {
18     $unit = explode("<>", $line);
19     $num = $unit[0];
20     $name = $unit[1];
21     $pc = $unit[2];
22     $color = $unit[3];
23     if (!$color) {
24         $color = MAIN_TEXTCOLOR;
25     }
26     $com = $unit[4];
27     if ($d) {
28         $date_format = 'm/d H:i';
29         if (SHOW_DATETIME_YEAR && !$is_mobile) {
30 $date_format = 'Y/'.$date_format;
31         }
32         if (SHOW_DATETIME_SECOND && !$is_mobile) {
33 $date_format .= ":s";
34         }
35         $datetime = date($date_format, $unit[5]);
36     }
37     if (!$is_mobile) {
38         $host = (MASTERPASS && $hash == MASTERPASS) ? '<!--' : NULL ;
39         $host .= (MASTERPASS && $hash == MASTERPASS && $unit[6]) ? $unit[6].'<>' : NULL ;
40         $host .= (MASTERPASS && $hash == MASTERPASS) ? $unit[7].' -->' : NULL ;
41         $whisper_from_pass = $unit[8];
42         $whisper_to_name = $unit[9];
43         $whisper_to_pass = $unit[10];
44
45         $w = 'n';
46         if ($unit[9] || $unit[10]) {
47             $w = 'y';
48             if ($hash == MASTERPASS) {
49                 $w = 'to';
50             } elseif ($hash == $unit[8]) {
51                 $w = 'to';
52             } elseif ($hash == $unit[10]) {
53                 $w = 'from';
54             }
55         }
56     }
57     $status = "";
58     if ($unit[11] == '1' && $unit[12]) {
59         $status = $unit[12];
60     }
61     $isMobile = $unit[13];
62
63     return array($num, $name, $pc, $color, $com, $datetime, $host, $whisper_from_pass, $whisper_to_name, $whisper_to_pass, $w, $status, $isMobile);
64 }
65
66 /*
67  * 難読化デコード
68  */
69 function decode_obf_log($pc, $com, $name, $whisper_to_name, $status)
70 {
71     $pc = de_obf_xor($pc);
72     $com = de_obf_xor($com);
73     $name = de_obf_xor($name);
74     if ($whisper_to_name) $whisper_to_name = de_obf_xor($whisper_to_name);
75     if ($status) $status = de_obf_xor($status);
76
77     return array($pc, $com, $name, $whisper_to_name, $status);
78 }
79
80
81 ?>