1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2008 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | require_once './config.inc.php'; |
---|
8 | |
---|
9 | // エラー出力を抑制 |
---|
10 | ini_set('display_errors', false); |
---|
11 | ob_start(); |
---|
12 | |
---|
13 | // モジュール毎に決められた認証をおこなっているかどうかのチェック |
---|
14 | if (CHECK_IMG_AUTH) { |
---|
15 | require_once OPENPNE_WEBAPP_DIR . '/init.inc'; |
---|
16 | |
---|
17 | $module = ''; |
---|
18 | if (!($module = get_request_var('m'))) { |
---|
19 | // モジュール名の自動設定 |
---|
20 | if (!db_admin_user_exists()) { |
---|
21 | $module = 'setup'; |
---|
22 | } elseif (isKtaiUserAgent()) { |
---|
23 | $module = 'ktai'; |
---|
24 | } else { |
---|
25 | $module = 'pc'; |
---|
26 | } |
---|
27 | } |
---|
28 | $_SERVER['QUERY_STRING'] .= '&a=page_h_toimg'; |
---|
29 | |
---|
30 | if (!$module = _check_module($module)) { |
---|
31 | openpne_display_error('モジュールが見つかりません', true); |
---|
32 | } |
---|
33 | |
---|
34 | // disable modules |
---|
35 | if (in_array($module, (array)$GLOBALS['_OPENPNE_DISABLE_MODULES'])) { |
---|
36 | openpne_display_error('モジュールが無効になっています', true); |
---|
37 | } |
---|
38 | |
---|
39 | if (OPENPNE_UNDER_MAINTENANCE && |
---|
40 | !in_array($module, (array)$GLOBALS['_OPENPNE_MAINTENANCE_MODULES'])) { |
---|
41 | openpne_display_error(); |
---|
42 | } |
---|
43 | |
---|
44 | if ($init = openpne_ext_search("{$module}/init.inc")) { |
---|
45 | require_once $init; |
---|
46 | } |
---|
47 | |
---|
48 | // 読み込む auth.inc を決定 |
---|
49 | $auth = openpne_ext_search("{$module}/auth.inc"); |
---|
50 | if (!$auth) { |
---|
51 | $auth = OPENPNE_WEBAPP_DIR . '/lib/auth.inc'; |
---|
52 | } |
---|
53 | |
---|
54 | // ファイル名が module_ ではじまる場合、認証をおこなうかどうかのチェック |
---|
55 | list($img_prefix, $img_module) = explode('_', $_GET['filename'], 3); |
---|
56 | if ($img_prefix == 'module' && $img_module) { |
---|
57 | $module_config = util_get_module_config($img_module); |
---|
58 | if (!isset($module_config['image']['is_auth']) || $module_config['image']['is_auth']) { |
---|
59 | require_once $auth; |
---|
60 | } |
---|
61 | } else { |
---|
62 | require_once $auth; |
---|
63 | } |
---|
64 | } else { |
---|
65 | // include_path の設定 |
---|
66 | include_once OPENPNE_LIB_DIR . '/include/PHP/Compat/Constant/PATH_SEPARATOR.php'; |
---|
67 | $include_paths = array( |
---|
68 | OPENPNE_LIB_DIR . '/include', |
---|
69 | OPENPNE_WEBAPP_DIR . '/lib', |
---|
70 | ini_get('include_path') |
---|
71 | ); |
---|
72 | ini_set('include_path', implode(PATH_SEPARATOR, $include_paths)); |
---|
73 | } |
---|
74 | |
---|
75 | // 各種設定 |
---|
76 | defined('OPENPNE_IMG_JPEG_QUALITY') or define('OPENPNE_IMG_JPEG_QUALITY', 75); |
---|
77 | if (!empty($GLOBALS['_OPENPNE_DSN_LIST']['image']['dsn'])) { |
---|
78 | $dsn = $GLOBALS['_OPENPNE_DSN_LIST']['image']['dsn']; |
---|
79 | } else { |
---|
80 | $dsn = $GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']; |
---|
81 | } |
---|
82 | |
---|
83 | require_once 'OpenPNE/Img.php'; |
---|
84 | $options = array( |
---|
85 | 'dsn' => $dsn, |
---|
86 | 'cache_dir' => OPENPNE_IMG_CACHE_DIR, |
---|
87 | 'jpeg_quality' => OPENPNE_IMG_JPEG_QUALITY, |
---|
88 | ); |
---|
89 | |
---|
90 | if (defined('USE_IMAGEMAGICK')) { |
---|
91 | switch (USE_IMAGEMAGICK) { |
---|
92 | case 0: |
---|
93 | $use_IM = false; |
---|
94 | break; |
---|
95 | case 1: |
---|
96 | $pieces = explode('.', $_GET['filename']); |
---|
97 | $source_format = OpenPNE_Img::check_format(array_pop($pieces)); |
---|
98 | $use_IM = ($source_format == 'gif'); |
---|
99 | break; |
---|
100 | case 2: |
---|
101 | $use_IM = true; |
---|
102 | break; |
---|
103 | default: |
---|
104 | exit; |
---|
105 | } |
---|
106 | } else { |
---|
107 | $use_IM = false; |
---|
108 | } |
---|
109 | |
---|
110 | if ($use_IM) { |
---|
111 | require_once 'OpenPNE/Img/ImageMagick.php'; |
---|
112 | $img =& new OpenPNE_Img_ImageMagick($options); |
---|
113 | } else { |
---|
114 | $img =& new OpenPNE_Img($options); |
---|
115 | } |
---|
116 | $img->set_requests($_GET); |
---|
117 | |
---|
118 | $img->generate_img() or exit(1); |
---|
119 | while (@ob_end_clean()); |
---|
120 | |
---|
121 | $img->output_img() or exit(2); |
---|
122 | |
---|
123 | ?> |
---|