/** * openpne_forward * * @param string $module a requested module name. * @param string $type request type. 'page' or 'do' * @param string $action requested page/command name. * @param array $errors error message strings. */ function openpne_forward($module, $type = '', $action = '', $errors = array()) { /// module /// if (!($module = _check_module($module))) { openpne_display_error('モジュールが見つかりません', true); } $GLOBALS['__Framework']['current_module'] = $module; // disable modules if (in_array($module, (array) $GLOBALS['_OPENPNE_DISABLE_MODULES'])) { openpne_display_error('モジュールが無効になっています', true); } // init if ($init = openpne_ext_search("{$module}/init.inc")) { require_once $init; } /// type /// if (!$type) { $type = $GLOBALS['__Framework']['default_type']; } if (!_check_type($type)) { openpne_display_error('リクエストの種類が正しくありません', true); } $GLOBALS['__Framework']['current_type'] = $type; /// action /// if (!($action = _check_action($action))) { openpne_display_error('アクションの指定が正しくありません', true); } if (!($file = openpne_ext_search("{$module}/{$type}/{$action}.php"))) { openpne_display_error('アクションファイルが見つかりません', true); } require_once $file; $class_name = "{$module}_{$type}_{$action}"; if (!class_exists($class_name)) { openpne_display_error('アクションが見つかりません', true); } $action_obj = new $class_name(); $GLOBALS['__Framework']['current_action'] = $action; // maintenace mode if (OPENPNE_UNDER_MAINTENANCE) { if (!in_array($module, (array) $GLOBALS['_OPENPNE_MAINTENANCE_MODULES']) || in_array($type . '_' . $action, (array) $GLOBALS['_OPENPNE_MAINTENANCE_EXCLUDED_ACTION'][$module])) { openpne_display_error(); } } // auth if ($GLOBALS['__Framework']['is_secure'] = $action_obj->isSecure()) { if ($auth = openpne_ext_search("{$module}/auth.inc")) { require_once $auth; } else { require_once 'auth.inc'; } } // ---------- リクエストバリデーション ---------- require_once 'OpenPNE/Validator.php'; require_once 'OpenPNE/Validator/Common.php'; $validator = new OpenPNE_Validator_Common(); $files = array(); if ($ini = openpne_ext_search("{$module}/validate/{$type}/{$action}.ini")) { $files[] = $ini; } list($result, $requests) = $validator->common_validate($files); $action_obj->requests = $requests; if ($result === false) { $errors = $validator->getErrors(); $action_obj->handleError($errors); } // ---------------------------------------------- switch ($type) { case 'page': $smarty = new OpenPNE_Smarty($GLOBALS['SMARTY']); $smarty->templates_dir = $module . '/templates'; $smarty->assign('requests', $requests); $smarty->assign('msg', $requests['msg']); $smarty->assign('msg1', $requests['msg1']); $smarty->assign('msg2', $requests['msg2']); $smarty->assign('msg3', $requests['msg3']); if ($errors) { $smarty->assign('errors', $errors); } if (OPENPNE_USE_PARTIAL_SSL) { $a = "{$type}_{$action}"; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $p = $_POST; } else { $p = $_GET; } switch (openpne_ssl_type($module, $a)) { case 'SSL_REQUIRED': if (!is_ssl()) { openpne_redirect($module, $a, $p); } break; case 'SSL_DISABLED': if (is_ssl()) { openpne_redirect($module, $a, $p); } break; case 'SSL_SELECTABLE': if ($https = is_ssl()) { $url = openpne_gen_url($module, $a, $p, true, 'nonssl'); } else { $url = openpne_gen_url($module, $a, $p, true, 'ssl'); } $smarty->assign('HTTPS', $https); $smarty->assign('SSL_SELECT_URL', $url); break; } } $action_obj->view =& $smarty; break; } // init function $init_func = "init_{$module}_{$type}"; if (function_exists($init_func)) { if (isset($smarty)) { $init_func($smarty); } else { $init_func(); } } $result = $action_obj->execute($requests); if ($result == 'success') { send_nocache_headers(); if ($smarty->ext_search($smarty->templates_dir . '/common/layout.tpl', $place)) { $smarty->assign('op_content', $smarty->ext_fetch("{$action}.tpl")); $smarty->ext_display('common/layout.tpl'); } else { $smarty->ext_display("{$action}.tpl"); } } // ---------------------------------------------- // c_access_log if (LOG_C_ACCESS_LOG) { if ($GLOBALS['__Framework']['is_secure'] && $type == 'page') { if ($module == 'pc') { p_access_log($GLOBALS['AUTH']->uid(), $action); } elseif ($module == 'ktai') { p_access_log($GLOBALS['KTAI_C_MEMBER_ID'], $action, 1); } } } // カスタムログ用関数の呼び出し if (OPENPNE_LOG_FUNCTION && is_callable(OPENPNE_LOG_FUNCTION)) { // c_member_id を取得 $c_member_id = 0; if ($GLOBALS['__Framework']['is_secure']) { if ($module == 'pc') { $c_member_id = $GLOBALS['AUTH']->uid(); } else { if ($module == 'ktai') { $c_member_id = $GLOBALS['KTAI_C_MEMBER_ID']; } } } $params = array('module' => $module, 'type' => $type, 'action' => $action, 'c_member_id' => $c_member_id, 'is_secure' => $GLOBALS['__Framework']['is_secure']); call_user_func(OPENPNE_LOG_FUNCTION, $params); } return true; }
if (!db_admin_user_exists()) { $module = 'setup'; } elseif (isKtaiUserAgent()) { $module = 'ktai'; } else { $module = 'pc'; } } $params = '&a=page_h_toimg'; if (isKtaiUserAgent()) { $params .= '&m=ktai'; } else { $params .= '&m=pc'; } $_SERVER['QUERY_STRING'] .= $params; if (!($module = _check_module($module))) { openpne_display_error('モジュールが見つかりません', true); } // disable modules if (in_array($module, (array) $GLOBALS['_OPENPNE_DISABLE_MODULES'])) { openpne_display_error('モジュールが無効になっています', true); } if (OPENPNE_UNDER_MAINTENANCE && !in_array($module, (array) $GLOBALS['_OPENPNE_MAINTENANCE_MODULES'])) { openpne_display_error(); } if ($init = openpne_ext_search("{$module}/init.inc")) { require_once $init; } // 読み込む auth.inc を決定 $auth = openpne_ext_search("{$module}/auth.inc"); if (!$auth) {