|
1 | 1 | <?php |
2 | | -/* vim: set fileencoding=cp932 ai et ts=4 sw=4 sts=4 fdm=marker: */ |
3 | | -/* mi: charset=Shift_JIS */ |
4 | 2 | /** |
5 | 3 | * Ascii Art Scope for rep2 |
6 | 4 | * |
|
37 | 35 |
|
38 | 36 | // {{{ p2基本設定読み込み&認証 |
39 | 37 |
|
40 | | -require_once 'conf/conf.inc.php'; |
| 38 | +require_once './conf/conf.inc.php'; |
41 | 39 |
|
42 | 40 | $_login->authorize(); |
43 | 41 |
|
44 | 42 | if (!$_conf['expack.aas.enabled']) { |
45 | | - exit('<html><body><p>AASは無効です。<br>conf/conf_admin_ex.inc.php の設定を変えてください。</p></body></html>'); |
| 43 | + p2die('AASは無効です。', 'conf/conf_admin_ex.inc.php の設定を変えてください。'); |
46 | 44 | } |
47 | 45 |
|
48 | 46 | // }}} |
49 | 47 | // {{{ 設定 |
50 | 48 |
|
51 | 49 | // このファイルの文字コード |
52 | | -define('AAS_SCRIPT_CHARSET', 'SJIS-win'); |
| 50 | +define('AAS_SCRIPT_CHARSET', 'CP932'); |
53 | 51 |
|
54 | 52 | // HTML→プレーンテキスト変換処理の文字コード |
55 | 53 | define('AAS_INTERNAL_CHARSET', 'UTF-8'); |
|
218 | 216 |
|
219 | 217 | // レス読み込み |
220 | 218 | if (empty($errors) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
221 | | - require_once P2_LIB_DIR . '/threadread.class.php'; |
222 | | - $aThread = &new ThreadRead; |
| 219 | + require_once P2_LIB_DIR . '/ThreadRead.php'; |
| 220 | + $aThread = new ThreadRead; |
223 | 221 | $aThread->setThreadPathInfo($host, $bbs, $key); |
224 | 222 | if (!$aThread->readDat()) { |
225 | 223 | $errors[] = 'datが読み込めませんでした。'; |
|
257 | 255 | // {{{ メイン処理 |
258 | 256 |
|
259 | 257 | // 文字コード変換 |
260 | | -$text = mb_convert_encoding($text, AAS_INTERNAL_CHARSET, 'SJIS-win'); |
| 258 | +$text = mb_convert_encoding($text, AAS_INTERNAL_CHARSET, 'CP932'); |
261 | 259 |
|
262 | 260 | // 制御文字以外をすべて数値文字参照に変換 |
263 | 261 | $regex = '/&(\\w+|#x([[:xdigit:]]{1,4}))(;|\\b)/'; |
|
276 | 274 | $text = mb_convert_encoding($text, $_conf['expack.aas.output_charset'], AAS_INTERNAL_CHARSET); |
277 | 275 | */ |
278 | 276 | // エラーハンドラを設定 |
279 | | -/*if (version_compare(phpversion(), '5.0.0', '>')) { |
280 | | - set_error_handler('aas_ttfErrorHandler', E_WARNING); |
281 | | -} else { |
282 | | - set_error_handler('aas_ttfErrorHandler'); |
283 | | -}*/ |
| 277 | +//set_error_handler('aas_ttfErrorHandler', E_WARNING); |
284 | 278 |
|
285 | 279 | // 元のテキストの文字数が多いとエラーになるので |
286 | 280 | // テキストボックスの大きさ判定用の文字列を作成 |
|
391 | 385 | // Bug #24155 (gdImageRotate270 rotation problem). |
392 | 386 | //$new_image = imagerotate(imagerotate($image, 180, $bgcolor), 90, $bgcolor); |
393 | 387 | imagedestroy($image); |
394 | | - unset($image); |
395 | | - $image = &$new_image; |
| 388 | + $image = $new_image; |
396 | 389 | } |
397 | 390 |
|
398 | 391 | // エラーハンドラを戻す |
|
420 | 413 |
|
421 | 414 | // }}} |
422 | 415 | // {{{ 関数 |
| 416 | +// {{{ aas_toNumericEntity() |
423 | 417 |
|
424 | 418 | /** |
425 | 419 | * 実体参照・と16進数の数値参照を10真数の数値参照に変換する |
@@ -458,6 +452,9 @@ function aas_toNumericEntity($e) |
458 | 452 | return $_conf['expack.aas.unknown_char']; |
459 | 453 | } |
460 | 454 |
|
| 455 | +// }}} |
| 456 | +// {{{ aas_decodeHTMLEntity() |
| 457 | + |
461 | 458 | /** |
462 | 459 | * 実体参照・数値参照をデコードする |
463 | 460 | * |
@@ -503,6 +500,9 @@ function aas_decodeHTMLEntity($e) |
503 | 500 | return $_conf['expack.aas.unknown_char']; |
504 | 501 | } |
505 | 502 |
|
| 503 | +// }}} |
| 504 | +// {{{ aas_getTextBoxSize() |
| 505 | + |
506 | 506 | /** |
507 | 507 | * テキストボックスの大きさを計算する |
508 | 508 | */ |
@@ -516,6 +516,9 @@ function aas_getTextBoxSize($size, $font, $hint, $lines) |
516 | 516 | return array($box_width, $box_height); |
517 | 517 | } |
518 | 518 |
|
| 519 | +// }}} |
| 520 | +// {{{ aas_isTextInPicture() |
| 521 | + |
519 | 522 | /** |
520 | 523 | * テキストが画像に収まり切るかチェックする |
521 | 524 | */ |
@@ -528,28 +531,35 @@ function aas_isTextInPicture($size, $font, $hint, $lines, $max_width, $max_heigh |
528 | 531 | return true; |
529 | 532 | } |
530 | 533 |
|
| 534 | +// }}} |
| 535 | +// {{{ aas_parseColor() |
| 536 | + |
531 | 537 | /** |
532 | 538 | * 3桁または6桁の16進数表記の色指定を array(int, int, int) に変換して返す |
533 | 539 | */ |
534 | 540 | function aas_parseColor($hex) |
535 | 541 | { |
536 | | - if (!preg_match('/^#?([[:xdigit:]]{3}|[[:xdigit:]]{6})$/', $hex)) { |
| 542 | + if (!preg_match('/^#?(?:[[:xdigit:]]{3}|[[:xdigit:]]{6})$/', $hex)) { |
537 | 543 | return false; |
538 | 544 | } |
539 | | - if ($hex{0} == '#') { |
540 | | - $hex = substr($hex, 1); |
| 545 | + if ($hex[0] == '#') { |
| 546 | + $dec = hexdec(substr($hex, 1)); |
| 547 | + } else { |
| 548 | + $dec = hexdec($hex); |
541 | 549 | } |
542 | | - if (strlen($hex) == 3) { |
543 | | - $r = hexdec($hex{0}); |
544 | | - $g = hexdec($hex{1}); |
545 | | - $b = hexdec($hex{2}); |
546 | | - return array($r * 16 + $r, $g * 16 + $g, $b * 16 + $b); |
| 550 | + if (strlen($hex) < 6) { |
| 551 | + $r = ($dec & 0xf00) >> 8; |
| 552 | + $g = ($dec & 0xf0) >> 4; |
| 553 | + $b = $dec & 0xf; |
| 554 | + return array(($r << 4) | $r, ($g << 4) | $g, ($b << 4) | $b); |
| 555 | + } else { |
| 556 | + return array(($dec & 0xff0000) >> 16, ($dec & 0xff00) >> 8, $dec & 0xff); |
547 | 557 | } |
548 | | - preg_match('/(..)(..)(..)/', $hex, $colors); |
549 | | - array_shift($colors); |
550 | | - return array_map('hexdec', $colors); |
551 | 558 | } |
552 | 559 |
|
| 560 | +// }}} |
| 561 | +// {{{ aas_ttfErrorHandler() |
| 562 | + |
553 | 563 | /** |
554 | 564 | * imagettftext(), imagettfbbox() の入力文字列が大きすぎたときのエラー処理 |
555 | 565 | */ |
@@ -569,3 +579,15 @@ function aas_ttfErrorHandler($errno, $errstr, $errfile, $errline) |
569 | 579 | } |
570 | 580 |
|
571 | 581 | // }}} |
| 582 | +// }}} |
| 583 | + |
| 584 | +/* |
| 585 | + * Local Variables: |
| 586 | + * mode: php |
| 587 | + * coding: cp932 |
| 588 | + * tab-width: 4 |
| 589 | + * c-basic-offset: 4 |
| 590 | + * indent-tabs-mode: nil |
| 591 | + * End: |
| 592 | + */ |
| 593 | +// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker: |