assign('SEP_Forum_use_usernames', true); } else { define('SEP_Forum_use_usernames', false); $smarty->assign('SEP_Forum_use_usernames', false); } // parse mod_rewrite urls and make sure, standard urls are redirecting to topic, too if($url_style == 'mod_rewrite' && !isset($_GET['c']) && $_GET['c'] != 'topic') { /* * BASE URL SUPPORT * If no images or stylesheets are loading, please uncomment * the lines below and check the base url setting in your admin panel. * * NOTE: Uncommenting the lines below may cause php session troubles though */ $_url_base = SEP_Forum_Models::get_forum_setting('url_base'); if(substr($_url_base, -1) != '/') { $_url_base .= '/'; } $url->url_base = $_url_base; unset($_url_base); // END BASE URL SUPPORT /* * Delegate Controller/Action with mod_rewrite query * * Possible routes: * * Forum Controller * /forum[/instance_id][/action][/category_id][/page] * PARAMS: instance_id, action, category_id, page * * Category Controller: * /forum[/instance_id]/category/category_id[/action][/topic_id][/page] * PARAMS: instance_id, category_id, action, topic_id, page * * Topic Controller: * /forum[/instance_id]/topic/category_id/action/topic_id[/page][#jump_to_post_id] * PARAMS: instance_id, category_id, action, topic_id, page * * Post Controller: * /forum[/instance_id]/post/category_id/action/post_id * PARAMS: instance_id, category_id, action, post_id * * Attachment Controller: * /forum[/instance_id]/attachment/category_id/post_id/attachment_id * PARAMS: instance_id, category_id, post_id, attachment_id * * SEO URL (redirects to topic controller with topic_id and page) * /forum/category/sub_category/title-topic_id-page.html * */ $category_id = null; $topic_id = null; $post_id = null; $attachment_id = null; $action = null; $controller = null; $_forum_controller_actions = array('bookmarks', 'browse', 'subindex', 'index', 'my_posts', 'search', 'settings'); $_controllers = array('category', 'topic', 'post', 'attachment'); // except for forum $requested_url = strip_tags($_SERVER['REQUEST_URI']); // fix for PHPSESSID or what ever is added at the end, after ? or & $_sign_break = strpos($requested_url, '?'); if($_sign_break !== false) { $requested_url = substr($requested_url, 0, $_sign_break); trigger_error('Forum Plugin: Client does not accept cookies. Session was killed.', E_USER_INFO); } $_sign_break = strpos($requested_url, '&'); if($_sign_break !== false) { $requested_url = substr($requested_url, 0, $_sign_break); trigger_error('Forum Plugin: Client does not accept cookies. Session was killed.', E_USER_INFO); } // subdirectory support $requested_uri = explode('/', strip_tags($requested_url)); $i=0; $_requested_uri = @array_shift($requested_uri); while($_requested_uri != 'forum') { $i++; if($i > 10) { break; } if(!empty($_requested_uri)) { $_uri_sub[] = $_requested_uri; } $_requested_uri = @array_shift($requested_uri); } unset($_requested_uri); // set prefix for subdirectories $url_sub = implode('/', $_uri_sub); // parse requested_uri... $req_uri_part = array_shift($requested_uri); if(!empty($req_uri_part)) { if(is_numeric($req_uri_part)) { $instance_id = $req_uri_part; unset($req_uri_part);$req_uri_part = @array_shift($requested_uri); } if(in_array($req_uri_part, $_forum_controller_actions)) { // forum controller $controller = 'forum'; $action = $req_uri_part; $category_id = @array_shift($requested_uri); $page_id = @array_shift($requested_uri); } elseif(in_array($req_uri_part, $_controllers)) { // other controller $controller = $req_uri_part; $category_id = @array_shift($requested_uri); $action = @array_shift($requested_uri); if($controller == 'post') { $post_id = @array_shift($requested_uri); } elseif($controller == 'attachment') { $post_id = $action; $action = 'download'; $attachment_id = @array_shift($requested_uri); } else { $topic_id = @array_shift($requested_uri); $page_id = @array_shift($requested_uri); } } if(empty($controller)) { // SEO url? // get topic_id and page_id $matches = array(); preg_match("/([0-9]*?)\-([0-9|LP]*?)\.html$/", $requested_uri[1], $matches); if(!empty($matches[1]) && !empty($matches[2])) { $topic_id = $matches[1]; $page_id = $matches[2]; // get category_id and instance_id $_post_item = $SEPFSQL->find('first', array('model' => 'Post', 'fields' => array('id', 'instance_id', 'category_id'), 'conditions' => array('Post.id=?', array($topic_id)))); if(!empty($_post_item['Post']['id'])) { $instance_id = $_post_item['Post']['instance_id']; $category_id = $_post_item['Post']['category_id']; $controller = 'topic'; $action = 'index'; } } } } if(empty($controller)) { $controller = 'forum'; } if(empty($action)) { $action = 'index'; } $params = array('params' => array('instance_id' => $instance_id, 'category_id' => $category_id, 'topic_id' => $topic_id, 'post_id' => $post_id, 'page' => $page_id, 'attachment_id' => $attachment_id, 'action' => $action, 'controller' => $controller)); // add raw requested uri to params $params['requested_uri'] = $requested_uri; } else { /* * Delegate Controller/Action with normal url query * * $controller = [category|topic|post|attachment] (becomes 'forum' if empty) * */ $instance_id = $multi_instances && !empty($_GET['iid']) ? $_GET['iid'] : $instance_id; $category_id = !empty($_GET['cid']) ? $_GET['cid'] : null; $topic_id = !empty($_GET['tid']) ? $_GET['tid'] : null; $post_id = !empty($_GET['pid']) ? $_GET['pid'] : null; $page_id = !empty($_GET['page']) ? $_GET['page'] : null; $attachment_id = !empty($_GET['aid']) ? $_GET['aid'] : null; $action = !empty($_GET['op']) ? $_GET['op'] : 'browse'; $controller = !empty($_GET['c']) ? $_GET['c'] : 'forum'; $params = array('params' => array('instance_id' => $instance_id, 'category_id' => $category_id, 'topic_id' => $topic_id, 'post_id' => $post_id, 'page' => $page_id, 'attachment_id' => $attachment_id, 'action' => $action, 'controller' => $controller)); // subdirectory support $requested_url = strip_tags($_SERVER['REQUEST_URI']); $_sub_dir = dirname($requested_url); $url_sub = null; if(!empty($_sub_dir) && $_sub_dir != '.' && $_sub_dir != '/') { $url_sub = $_sub_dir; } } // Comment out for debugging! //echo "
CONTROLLER: $controller
"; //echo "ACTION: $action
"; //echo "INSTANCE_ID: $instance_id
"; //echo "CATEGORY_ID: $category_id
"; //echo "TOPIC_ID: $topic_id
"; //echo "POST_ID: $post_id
"; //echo "PAGE: $page_id
"; //echo "ATTACHMENT_ID: $attachment_id
"; //exit; // clean controller $controller = strtolower(preg_replace('/[^a-z0-9]/i', '', $controller)); // URL Helper Init $SEPFURL->init($multi_instances, $instance_id, $url_style, $url_sub); // Prepare user object $params['user']['_object'] = $user; $params['user']['logged_in'] = !empty($user->user_info['user_id']) ? true : false; $params['user']['id'] = $user->user_info['user_id']; $params['user']['photo'] = $user->user_info['user_photo']; $params['user']['name'] = $user->user_info['user_username']; $params['user']['display_name'] = !empty($user->user_displayname) ? $user->user_displayname : $user->user_info['user_username']; $params['user']['email'] = $user->user_info['user_email']; $params['user']['level_id'] = $user->user_info['user_level_id']; $params['user']['subnet_id'] = $user->user_info['user_subnet_id']; $params['user']['profilecat_id'] = $user->user_info['user_profilecat_id']; // Assign user object $smarty->assign('sep_forum_user', $params['user']); $smarty->assign('_active_tab', ''); if($params['params']['controller'] == 'forum' && in_array($params['params']['action'], array('index', 'browse')) && empty($params['params']['instance_id'])) { $params['params']['instance_id'] = $global_instance_id; } // check if there are any instances for forum? $show_header_and_footer = true; if($SEPFSQL->find('count', array('model' => 'Instance', 'conditions' => array('mode=?', array('forum')), 'limit' => 1)) == 0) { SEP_Forum_Helper::redirect_to_error($SEPFLG->getLang('There are no forums to access.')); exit; } else { if($multi_instances) { // check if this instance is a forum or a group $_instance_info = $SEPFSQL->find('first', array('model' => 'Instance', 'fields' => array('mode'), 'conditions' => array('id=?', array($params['params']['instance_id'])))); if($_instance_info['Instance']['mode'] == 'group') { $show_header_and_footer = false; } } } $smarty->assign('show_header_and_footer', $show_header_and_footer); /* * Delegate controller/actions and pass params to action */ // whitelisting available controllers if(!in_array($controller, array('category', 'forum', 'post', 'topic', 'attachment'))) { SEP_Forum_Helper::redirect_to_error($SEPFLG->getLang('Invalid url request')); exit; } $lk=SEP_Forum_Models::get_forum_setting("license_key");if(empty($lk)){SEP_Forum_Helper::redirect_to_error($SEPFLG->getLang('The forum is not available at the moment. No license key found.'));} function sepf_dummy() {} $plugin_disabled = false; $plugin_disabled = @mysql_query("SELECT 1 FROM se_plugins WHERE plugin_type='forum' AND plugin_disabled=1 LIMIT 1") OR sepf_dummy(); $plugin_disabled = @mysql_fetch_row($plugin_disabled); if($plugin_disabled) { SEP_Forum_Helper::redirect_to_error($SEPFLG->getLang('The forum is not available at the moment')); exit; } require getcwd().'/include/forum/controllers/'.$controller.'_controller.php'; call_user_func_array(array('SEP_'.ucfirst($controller).'Controller', $action), array(&$params, &$SEPFSQL, &$SEPFLG, &$SEPFURL, &$smarty)); if(empty($params['layout'])) { $page = 'forum/'.$controller.'_'.$action; } else { $page = 'forum/'.$params['layout']; } // allow these pages/ templates only $template_whitelist = array( 'forum/category_index', 'forum/forum_bookmarks', 'forum/forum_browse', 'forum/forum_index', 'forum/forum_my_posts', 'forum/forum_profile_posts', 'forum/forum_search', 'forum/forum_settings', 'forum/forum_subindex', 'forum/topic_form', 'forum/topic_index' ); if(!in_array($page, $template_whitelist)) { SEP_Forum_Helper::redirect_to_error($SEPFLG->getLang('This page does not exist')); exit; } // Flash messages $smarty->assign('sep_flash_error', SEP_Forum_Helper::getFlash('error')); $smarty->assign('sep_flash_success', SEP_Forum_Helper::getFlash('success')); $smarty->assign('sep_flash_info', SEP_Forum_Helper::getFlash('info')); SEP_Forum_Helper::resetFlash(); include "footer.php"; ?>