@@ -51,7 +51,6 @@ public function __construct() |
51 | 51 | public function downloadDat() |
52 | 52 | { |
53 | 53 | global $_conf; |
54 | | - global $uaMona, $SID2ch; // require_once P2_LIB_DIR . '/login2ch.inc.php'; |
55 | 54 |
|
56 | 55 | // まちBBS |
57 | 56 | if (P2Util::isHostMachiBbs($this->host)) { |
@@ -128,20 +127,16 @@ private function _downloadDat2ch($from_bytes) |
128 | 127 | $from_bytes = $from_bytes - 1; |
129 | 128 | } |
130 | 129 |
|
131 | | - $method = "GET"; |
132 | | - $uaMona = "Monazilla/1.00"; |
133 | | - |
134 | | - $p2ua_fmt = " (%s/%s; expack-%s)"; |
135 | | - $p2ua = $uaMona . sprintf($p2ua_fmt, $_conf['p2name'], $_conf['p2version'], $_conf['p2expack']); |
| 130 | + $method = 'GET'; |
136 | 131 |
|
137 | | - $url = 'http://' . $this->host . "/{$this->bbs}/dat/{$this->key}.dat"; |
| 132 | + $url = "http://{$this->host}/{$this->bbs}/dat/{$this->key}.dat"; |
138 | 133 | //$url="http://news2.2ch.net/test/read.cgi?bbs=newsplus&key=1038486598"; |
139 | 134 |
|
140 | 135 | $purl = parse_url($url); // URL分解 |
141 | 136 | if (isset($purl['query'])) { // クエリー |
142 | | - $purl['query'] = "?".$purl['query']; |
| 137 | + $purl['query'] = '?' . $purl['query']; |
143 | 138 | } else { |
144 | | - $purl['query'] = ""; |
| 139 | + $purl['query'] = ''; |
145 | 140 | } |
146 | 141 |
|
147 | 142 | // プロキシ |
@@ -152,20 +147,20 @@ private function _downloadDat2ch($from_bytes) |
152 | 147 | } else { |
153 | 148 | $send_host = $purl['host']; |
154 | 149 | $send_port = isset($purl['port']) ? $purl['port'] : 80; |
155 | | - $send_path = $purl['path'].$purl['query']; |
| 150 | + $send_path = $purl['path'] . $purl['query']; |
156 | 151 | } |
157 | 152 |
|
158 | 153 | if (!$send_port) { |
159 | 154 | $send_port = 80; // デフォルトを80 |
160 | 155 | } |
161 | 156 |
|
162 | | - $request = $method." ".$send_path." HTTP/1.0\r\n"; |
163 | | - $request .= "Host: ".$purl['host']."\r\n"; |
| 157 | + $request = "{$method} {$send_path} HTTP/1.0\r\n"; |
| 158 | + $request .= "Host: {$purl['host']}\r\n"; |
164 | 159 | $request .= "Accept: */*\r\n"; |
165 | 160 | //$request .= "Accept-Charset: Shift_JIS\r\n"; |
166 | 161 | //$request .= "Accept-Encoding: gzip, deflate\r\n"; |
167 | 162 | $request .= "Accept-Language: ja, en\r\n"; |
168 | | - $request .= "User-Agent: ".$p2ua."\r\n"; |
| 163 | + $request .= "User-Agent: Monazilla/1.00 ({$_conf['p2ua']})\r\n"; |
169 | 164 | if (!$zero_read) { |
170 | 165 | $request .= "Range: bytes={$from_bytes}-\r\n"; |
171 | 166 | } |
@@ -347,6 +342,7 @@ private function _downloadDat2chNotFound() |
347 | 342 | */ |
348 | 343 | private function _downloadDat2chMaru() |
349 | 344 | { |
| 345 | + // $uaMona, $SID2ch → @see lib/login2ch.inc.php |
350 | 346 | global $_conf, $uaMona, $SID2ch, $_info_msg_ht; |
351 | 347 |
|
352 | 348 | if (!($this->host && $this->bbs && $this->key && $this->keydat)) { |
@@ -356,13 +352,10 @@ private function _downloadDat2chMaru() |
356 | 352 | //unset($datgz_attayo, $start_here, $isGzip, $done_gunzip, $marudatlines, $code); |
357 | 353 |
|
358 | 354 | $method = 'GET'; |
359 | | - // $uaMona → @see login2ch.inc.php |
360 | | - $p2ua_fmt = " (%s/%s; expack-%s)"; |
361 | | - $p2ua = $uaMona . sprintf($p2ua_fmt, $_conf['p2name'], $_conf['p2version'], $_conf['p2expack']); |
362 | 355 |
|
363 | 356 | // GET /test/offlaw.cgi?bbs=板名&key=スレッド番号&sid=セッションID HTTP/1.1 |
364 | | - $SID2ch = rawurlencode($SID2ch); |
365 | | - $url = 'http://' . $this->host . "/test/offlaw.cgi/{$this->bbs}/{$this->key}/?raw=0.0&sid={$SID2ch}"; |
| 357 | + $url = "http://{$this->host}/test/offlaw.cgi/{$this->bbs}/{$this->key}/?raw=0.0&sid="; |
| 358 | + $url .= rawurlencode($SID2ch); |
366 | 359 |
|
367 | 360 | $purl = parse_url($url); // URL分解 |
368 | 361 | if (isset($purl['query'])) { // クエリー |
@@ -390,8 +383,8 @@ private function _downloadDat2chMaru() |
390 | 383 | $request .= "Host: ".$purl['host']."\r\n"; |
391 | 384 | $request .= "Accept-Encoding: gzip, deflate\r\n"; |
392 | 385 | //$request .= "Accept-Language: ja, en\r\n"; |
393 | | - $request .= "User-Agent: ".$p2ua."\r\n"; |
394 | | - //$request .= "X-2ch-UA: ".$_conf['p2name']."/".$_conf['p2version']."\r\n"; |
| 386 | + $request .= "User-Agent: {$uaMona} ({$_conf['p2ua']})\r\n"; |
| 387 | + //$request .= "X-2ch-UA: {$_conf['p2ua']}\r\n"; |
395 | 388 | //$request .= "Range: bytes={$from_bytes}-\r\n"; |
396 | 389 | $request .= "Connection: Close\r\n"; |
397 | 390 | /* |
@@ -588,9 +581,7 @@ private function _downloadDat2chKako($uri, $ext) |
588 | 581 |
|
589 | 582 | $url = $uri.$ext; |
590 | 583 |
|
591 | | - $method = "GET"; |
592 | | - $httpua_fmt = "Monazilla/1.00 (%s/%s; expack-%s)"; |
593 | | - $httpua = sprintf($httpua_fmt, $_conf['p2name'], $_conf['p2version'], $_conf['p2expack']); |
| 584 | + $method = 'GET'; |
594 | 585 |
|
595 | 586 | $purl = parse_url($url); // URL分解 |
596 | 587 | // クエリー |
@@ -615,9 +606,9 @@ private function _downloadDat2chKako($uri, $ext) |
615 | 606 | $send_port = 80; |
616 | 607 | } |
617 | 608 |
|
618 | | - $request = $method." ".$send_path." HTTP/1.0\r\n"; |
619 | | - $request .= "Host: ".$purl['host']."\r\n"; |
620 | | - $request .= "User-Agent: ".$httpua."\r\n"; |
| 609 | + $request = "{$method} {$send_path} HTTP/1.0\r\n"; |
| 610 | + $request .= "Host: {$purl['host']}\r\n"; |
| 611 | + $request .= "User-Agent: Monazilla/1.00 ({$_conf['p2ua']})\r\n"; |
621 | 612 | $request .= "Connection: Close\r\n"; |
622 | 613 | //$request .= "Accept-Encoding: gzip\r\n"; |
623 | 614 | /* |
@@ -784,7 +775,7 @@ public function get2chDatError() |
784 | 775 | $read_response_html = ""; |
785 | 776 | require_once P2_LIB_DIR . '/Wap.php'; |
786 | 777 | $wap_ua = new UserAgent(); |
787 | | - $wap_ua->setAgent($_conf['p2name']."/".$_conf['p2version']."; expack-".$_conf['p2expack']); // ここは、"Monazilla/" をつけるとNG |
| 778 | + $wap_ua->setAgent($_conf['p2ua']); // ここは、"Monazilla/" をつけるとNG |
788 | 779 | $wap_ua->setTimeout($_conf['fsockopen_time_limit']); |
789 | 780 | $wap_req = new Request(); |
790 | 781 | $wap_req->setUrl($read_url); |
@@ -912,14 +903,14 @@ public function previewOne() |
912 | 903 | // ローカルdatなければオンラインから |
913 | 904 | if (!$first_line) { |
914 | 905 |
|
915 | | - $method = "GET"; |
916 | | - $url = "http://" . $this->host . "/{$this->bbs}/dat/{$this->key}.dat"; |
| 906 | + $method = 'GET'; |
| 907 | + $url = "http://{$this->host}/{$this->bbs}/dat/{$this->key}.dat"; |
917 | 908 |
|
918 | 909 | $purl = parse_url($url); // URL分解 |
919 | 910 | if (isset($purl['query'])) { // クエリー |
920 | | - $purl['query'] = "?".$purl['query']; |
| 911 | + $purl['query'] = '?' . $purl['query']; |
921 | 912 | } else { |
922 | | - $purl['query'] = ""; |
| 913 | + $purl['query'] = ''; |
923 | 914 | } |
924 | 915 |
|
925 | 916 | // プロキシ |
@@ -930,16 +921,14 @@ public function previewOne() |
930 | 921 | } else { |
931 | 922 | $send_host = $purl['host']; |
932 | 923 | $send_port = $purl['port']; |
933 | | - $send_path = $purl['path'].$purl['query']; |
| 924 | + $send_path = $purl['path'] . $purl['query']; |
934 | 925 | } |
935 | 926 |
|
936 | 927 | if (!$send_port) {$send_port = 80;} // デフォルトを80 |
937 | 928 |
|
938 | | - $request = $method." ".$send_path." HTTP/1.0\r\n"; |
939 | | - $request .= "Host: ".$purl['host']."\r\n"; |
940 | | - $httpua_fmt = "Monazilla/1.00 (%s/%s; expack-%s)"; |
941 | | - $httpua = sprintf($httpua_fmt, $_conf['p2name'], $_conf['p2version'], $_conf['p2expack']); |
942 | | - $request .= "User-Agent: ".$httpua."\r\n"; |
| 929 | + $request = "{$method} {$send_path} HTTP/1.0\r\n"; |
| 930 | + $request .= "Host: {$purl['host']}\r\n"; |
| 931 | + $request .= "User-Agent: Monazilla/1.00 ({$_conf['p2ua']})\r\n"; |
943 | 932 | // $request .= "Range: bytes={$from_bytes}-\r\n"; |
944 | 933 |
|
945 | 934 | // Basic認証用のヘッダ |
|