-
Notifications
You must be signed in to change notification settings - Fork 45
/
read_copy_k.php
193 lines (177 loc) · 6.34 KB
/
read_copy_k.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
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
/**
* rep2 - 携帯版レスコピー
*/
require_once './conf/conf.inc.php';
$_login->authorize(); // ユーザ認証
$name_txt = '';
$mail_txt = '';
$date_txt = '';
$id_txt = '';
$msg_txt = '';
$url_k_ht = '';
$id_ht = '';
$back_link = '';
$post_link = '';
$moto_link = '';
//=====================================================
// スレッド情報
//=====================================================
$host = $_GET['host'];
$bbs = $_GET['bbs'];
$key = $_GET['key'];
$resid = $_GET['copy'];
$quote = !empty($_GET['inyou']);
if (isset($_SERVER['HTTP_REFERER'])) {
$back_link = '<a href="' . htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES) . '" title="戻る">戻る</a> ';
}
//=================================================
// レス読み込み
//=================================================
$aThread = new ThreadRead;
$aThread->setThreadPathInfo($host, $bbs, $key);
if (file_exists($aThread->keydat)) {
// スレッド情報
$aThread->readDat($aThread->keydat);
$one = $aThread->explodeDatLine($aThread->datlines[0]);
$ttitle = trim($one[4]);
$ttitle_en = UrlSafeBase64::encode($ttitle);
$ttitle_ht = htmlspecialchars($ttitle, ENT_QUOTES);
$url_txt = $aThread->getMotoThread(true);
$url_k_txt = $aThread->getMotoThread();
if ($quote) {
$url_txt .= $resid;
$url_k_txt .= $resid;
}
if ($url_txt != $url_k_txt) {
$url_k_ht = "<input type=\"text\" name=\"url_k_txt\" value=\"{$url_k_txt}\"><br>";
}
// 投稿フォームへのリンク
$post_url = "post_form.php?host={$host}&bbs={$bbs}&key={$key}";
$post_url .= "&rescount={$aThread->rescount}&ttitle_en={$ttitle_en}&b=k";
$post_link = "<a href=\"{$post_url}\">レス</a> ";
// 元スレへのリンク
$moto_link = '<a href="' . P2Util::throughIme($url_k_txt) . '">元スレ</a> ';
// 指定番号のレスをパース
$p = $resid - 1;
if (isset($aThread->datlines[$p])) {
$resar = $aThread->explodeDatLine($aThread->datlines[$p]);
$name_txt = trim(strip_tags($resar[0]));
$mail_txt = trim(strip_tags($resar[1]));
if (strpos($resar[2], 'ID:') !== false) {
$date_txt = preg_replace('/ ?ID: ?([0-9A-Za-z\/.+?]+)([.,]|†)?.*$/', '', $resar[2]);
$id_txt = preg_replace('/^.*ID: ?([0-9A-Za-z\/.+?]+)([.,]|†)?.*$/', 'ID:$1', $resar[2]);
$id_ht = "<input type=\"text\" name=\"id_txt\" value=\"{$id_txt}\"><br>";
} else {
$date_txt = $resar[2];
}
$msg_txt = trim(strip_tags($resar[3], '<br>'));
if ($quote) {
$msg_txt = ">>{$resid}\r\n> " . preg_replace('/ *<br[^>]*> */i', "\n> ", $msg_txt);
} else {
$msg_txt = preg_replace('/ *<br[^>]*> */i', "\n", $msg_txt);
}
} else {
P2Util::pushInfoHtml('<p>p2 error: レス番号の指定が変です。</p>');
}
} else {
P2Util::pushInfoHtml('<p>p2 error: スレッドの指定が変です。</p>');
}
$msg_len = mb_strlen($msg_txt);
$len = $GLOBALS['_conf']['mobile.copy_divide_len'] ? $GLOBALS['_conf']['mobile.copy_divide_len'] : 10000;
$msg_txts = array();
for ($i = 0; $i < $msg_len; $i += $len) {
$msg_txts[] = mb_substr($msg_txt, $i, $len);
}
//=====================================================
// コピー用フォームを表示
//=====================================================
$action_ht = htmlspecialchars($_SERVER['SCRIPT_NAME'] . '?host=' . $_GET['host'] . '&bbs=' . $_GET['bbs'] . '&key=' . $_GET['key'] . '©=' . $_GET['copy'], ENT_QUOTES);
// willcom はtextareaのサイズが小さいと使いにくいらしい
/*
JavaScriptにしてしまった方がいいかも?
javascript:(function(){for (var j=0;j<document.forms.length;j++){for (var i=0;i<document.forms[j].elements.length;i++) {k=document.forms[j].elements[i];if(k.type=="textarea"){k.rows=10;k.cols=34;}}}})();
*/
$kyopon_size = '';
$mobile = Net_UserAgent_Mobile::singleton();
if ($mobile->isAirHPhone()) {
$kyopon_size = ' rows="10" cols="34"';
}
P2Util::header_nocache();
echo $_conf['doctype'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<?php echo $_conf['extra_headers_ht']; ?>
<?php if ($_conf['iphone']) {
echo <<<EOS
<script type="text/javascript">
// <![CDATA[
window.addEventListener('load', function(event) {
var read_copy_adjsut_text_width
window.removeEventListener(event.type, arguments.callee, false);
read_copy_adjsut_text_width = function() {
var texts, i, l, node, width;
texts = document.evaluate('.//input[@type="text"]',
document.body,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null);
l = texts.snapshotLength;
for (i = 0; i < l; i++) {
node = texts.snapshotItem(i);
width = node.parentNode.clientWidth;
if (width > 100) {
width -= 18; // 適当
if (width > 480) {
width = 480; // maxWidth
}
node.style.width = width + 'px';
}
}
};
read_copy_adjsut_text_width();
document.body.addEventListener('orientationchange', read_copy_adjsut_text_width, false);
}, false);
// ]]>
</script>\n
EOS;
} ?>
<title><?php echo $ttitle_ht; ?>/<?php echo $resid; ?></title>
</head>
<body<?php echo $k_color_settings; ?>>
<?php P2Util::printInfoHtml(); ?>
<form action="<?php echo $action_ht; ?>" method="post">
スレ:<br>
<input type="text" name="ttitle_txt" value="<?php echo $ttitle_ht; ?>"><br>
<input type="text" name="url_txt" value="<?php echo $url_txt; ?>"><br>
<?php echo $url_k_ht; ?>
<?php echo $resid; ?>:<br>
<input type="text" name="name_txt" value="<?php echo $name_txt; ?>"><br>
<input type="text" name="mail_txt" value="<?php echo $mail_txt; ?>"><br>
<input type="text" name="date_txt" value="<?php echo $date_txt; ?>"><br>
<?php echo $id_ht; ?>
<?php foreach ($msg_txts as $msg_txt) { ?>
<textarea<?php echo $kyopon_size; ?>><?php echo $msg_txt; ?></textarea><br>
<?php } ?>
フリー:<br>
<textarea name="free" rows="2"></textarea>
</form>
<div class="center navi">
<?php echo $back_link, $post_link, $moto_link; ?>
</div>
</body>
</html>
<?php
/*
* 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: