-
Notifications
You must be signed in to change notification settings - Fork 45
/
index.php
180 lines (157 loc) · 4.98 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
/**
* rep2 - インデックスページ
*/
define('P2_SESSION_CLOSE_AFTER_AUTHENTICATION', 0);
if (array_key_exists('b', $_GET) && in_array($_GET['b'], array('h2', 'v2', 'v3'))) {
$_GET['panes'] = $_GET['b'];
$_GET['b'] = 'pc';
}
require_once './conf/conf.inc.php';
$_login->authorize(); //ユーザ認証
//=============================================================
// 前処理
//=============================================================
// アクセス拒否用の.htaccessをデータディレクトリに作成する
$secret_dirs = array_unique(array(
$_conf['pref_dir'],
$_conf['dat_dir'],
$_conf['idx_dir'],
$_conf['db_dir'],
$_conf['admin_dir'],
$_conf['cache_dir'],
$_conf['cookie_dir'],
$_conf['compile_dir'],
$_conf['session_dir'],
$_conf['tmp_dir'],
));
foreach ($secret_dirs as $dir) {
makeDenyHtaccess($dir);
}
//=============================================================
$me_url = P2Util::getMyUrl();
$me_dir_url = dirname($me_url);
$me_url_b = htmlspecialchars(rtrim($me_dir_url, '/') . '/?b=', ENT_QUOTES);
if ($_conf['ktai']) {
//=========================================================
// 携帯用 インデックス
//=========================================================
// url指定があれば、そのままスレッド読みへ飛ばす
if (!empty($_GET['url']) || !empty($_GET['nama_url'])) {
header('Location: '.$me_dir_url . '/read.php?' . $_SERVER['QUERY_STRING']);
exit;
}
if ($_conf['iphone']) {
include P2_BASE_DIR . '/menu_i.php';
exit;
}
require_once P2_LIB_DIR . '/index_print_k.inc.php';
index_print_k();
} else {
//=========================================
// PC用 変数
//=========================================
$title_page = "title.php";
if (!empty($_GET['url']) || !empty($_GET['nama_url'])) {
$htm['read_page'] = 'read.php?' . $_SERVER['QUERY_STRING'];
} else {
if (!empty($_conf['first_page'])) {
$htm['read_page'] = $_conf['first_page'];
} else {
$htm['read_page'] = 'first_cont.php';
}
}
// デフォルトのペイン分割
$panes = 'default';
$direction = 'rows';
$_SESSION['use_narrow_toolbars'] = false;
// index.php?panes={v3,v2,h2} or index.php?sidebar=1 でペイン指定
if (array_key_exists('panes', $_GET) && is_string($_GET['panes'])) {
switch ($_GET['panes']) {
case 'v3':
case 'v2':
$panes = $_GET['panes'];
$direction = 'cols';
$_SESSION['use_narrow_toolbars'] = true;
break;
case 'h2':
$panes = 'h2';
break;
}
} elseif (!empty($_GET['sidebar'])) {
$panes = 'h2';
}
$ptitle = "rep2";
//======================================================
// PC用 HTMLプリント
//======================================================
//P2Util::header_nocache();
if ($_conf['doctype']) {
echo str_replace(array('Transitional', 'loose.dtd'),
array('Frameset', 'frameset.dtd'),
$_conf['doctype']);
}
echo <<<EOHEADER
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
{$_conf['extra_headers_ht']}
<title>{$ptitle}</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
</head>\n
EOHEADER;
if ($panes === 'default' || $panes === 'v3') {
echo <<<EOMENUFRAME
<frameset id="menuframe" cols="{$_conf['frame_menu_width']},*" border="1">
<frame src="menu.php" id="menu" name="menu" scrolling="auto" frameborder="1">\n
EOMENUFRAME;
}
echo <<<EOMAINFRAME
<frameset id="mainframe" {$direction}="{$_conf['frame_subject_width']},{$_conf['frame_read_width']}" border="2">
<frame src="{$title_page}" id="subject" name="subject" scrolling="auto" frameborder="1">
<frame src="{$htm['read_page']}" id="read" name="read" scrolling="auto" frameborder="1">
</frameset>\n
EOMAINFRAME;
if ($panes === 'default' || $panes === 'v3') {
echo "</frameset>\n";
}
echo <<<EONOFRAMES
<noframes>
<body>
<h1>{$ptitle}</h1>
<ul>
<li> 携帯用URL: <a href="{$me_url_b}k">{$me_url_b}k</a></li>
<li>iPhone用URL: <a href="{$me_url_b}i">{$me_url_b}i</a></li>
</ul>
</body>
</noframes>\n
EONOFRAMES;
echo '</html>';
}
// {{{ makeDenyHtaccess()
/**
* ディレクトリに(アクセス拒否のための) .htaccess がなければ、自動で生成する
*/
function makeDenyHtaccess($dir)
{
$hta = $dir . '/.htaccess';
if (!file_exists($hta)) {
if (!is_dir($dir)) {
FileCtl::mkdirFor($hta);
}
$data = 'Order allow,deny'."\n".'Deny from all'."\n";
FileCtl::file_write_contents($hta, $data);
}
}
// }}}
/*
* Local Variables:
* mode: php
* coding: cp932
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/
// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker: