OSDN Git Service

r23 コミット漏れ
[trpgtools-onweb/AjaxChat.git] / lib / trpgchat.php
1 <?php
2 /*
3  * Ajax Chat for TRPG ver.1.3
4  * (c)2007 Cake All rights reserved.
5  * Mail : cake_67@users.sourceforge.jp
6  * Home : http://trpgtools-onweb.sourceforge.jp/
7  */
8
9 /*****************
10  *  PHPライブラリ:共通
11  *****************/
12
13 /* リクエストを取得 */
14 function request() {
15     if (!strcasecmp(METHOD, 'GET')) {
16         $request = $_GET;
17     } elseif (!strcasecmp(METHOD, 'POST')) {
18         $request = $_POST;
19     }
20     return $request;
21 }
22
23 /* 色選択出力 */
24 function colorbox($color_code, $id, $select=''){
25     $color_list = array();
26     foreach ($color_code as $k1 => $v1) {
27         foreach ($color_code as $v2) {
28             foreach ($color_code as $v3) {
29                 $color_list[] = $v1.$v2.$v3;
30             }
31         }
32     }
33     array_unique($color_list);
34     sort($color_list);
35
36     foreach ($color_list as $k => $v) {
37         print'<option value="'.$v.'" style="color: #'.$v.'; font-weight:bold;" id="'.$id.'_'.$v.'"';
38         if ($select == $v) { print ' selected';}
39         print ' >#'.$v.'</option>'."\n";
40     }
41 }
42
43 /* ヘッター */
44 function html_header($title, $window = false, $js = true, $no_cache = true) {
45     $header = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
46     $header .= '<html>'."\n";
47     $header .= '<head>'."\n";
48     $header .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'."\n";
49     $header .= '<meta http-equiv="Content-Style-Type" content="text/css" />'."\n";
50     if ($js) {
51         $header .= '<meta http-equiv="Content-Script-Type" content="text/javascript" />'."\n";
52     }
53     if ($no_cache) {
54         $header .= '<meta http-equiv="Pragma" content="no-cache">'."\n";
55         $header .= '<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate">'."\n";
56         $header .= '<meta http-equiv="Expires" content="Thu, 01 Feb 2007 00:00:00 GMT">'."\n";
57     }
58     if ($window == 'pastlog') {
59         $header .= '<link rel="stylesheet" type="text/css" href="../css/trpgchat.css">'."\n";
60     } else {
61         $header .= '<link rel="stylesheet" type="text/css" href="./css/trpgchat.css">'."\n";
62     }
63     if ($window == 'index') {
64         $header .= '<link rel="stylesheet" type="text/css" href="./css/index.css">'."\n";
65     } elseif ($window == 'main') {
66         $header .= '<link rel="stylesheet" type="text/css" href="./css/main.css">'."\n";
67     } elseif ($window == 'pastlog') {
68         $header .= '<link rel="stylesheet" type="text/css" href="../css/main.css">'."\n";
69     }
70     $header .= '<title>'.$title.'</title>'."\n";
71     if ($js) {
72         $header .= '<script type="text/javascript" src="./lib/js/jquery.js"></script>'."\n";
73     }
74
75     return $header;
76 }
77
78 /* フッター */
79 function html_footer($copyright = 'true') {
80     if ($copyright) $footer = '<p class="copyright">'.COPYRIGHT.'</p>'."\n";
81     $footer .= '</body>'."\n";
82     $footer .= '</html>'."\n";
83
84     return $footer;
85 }
86
87 /* エラー表示 */
88 function error($msg) {
89     print html_header('エラー', false, false, false);
90     print "</head>\n";
91     print "<body>\n";
92     print '<font color="red">エラー</font><br>'."\n";
93     print $msg."\n";
94     print  html_footer('');
95     exit;
96 }
97
98 /* トリップ生成 */
99 function create_hash($name,$pwd) {
100     //パスワードがなければ中止
101     if (!$pwd) {
102         return false;
103     }
104     $key = substr(substr($pwd,1,2)."dummy",0,2);
105     $key = strtr($key,':;<=>?@[\]^_`','ABCDEFGabcdef');
106     $pwd = substr(crypt($name, $key), -10);
107
108     return $pwd;
109 }
110 ?>