function nvweb_route_parse($route = "") { global $website; global $DB; global $current; global $session; global $theme; global $events; global $dictionary; // node route types if (substr($route, 0, 5) == 'node/') { $node = substr($route, 5); $route = 'node'; } switch ($route) { case 'object': nvweb_object(); nvweb_clean_exit(); break; case 'nvajax': nvweb_ajax(); nvweb_clean_exit(); break; case 'nvtags': case 'nvsearch': $current['template'] = 'search'; break; case 'nv.webuser/verify': $hash = $_REQUEST['hash']; $email = filter_var($_REQUEST['email'], FILTER_VALIDATE_EMAIL); if (!empty($hash) && !empty($email)) { $ok = webuser::email_verification($email, $hash); if ($ok) { $session['nv.webuser/verify:email_confirmed'] = time(); } } nvweb_clean_exit(NVWEB_ABSOLUTE . $website->homepage()); break; case 'node': if ($node > 0) { $current['id'] = $node; $DB->query('SELECT * FROM nv_items WHERE id = ' . protect($current['id']) . ' AND website = ' . $website->id); $current['object'] = $DB->first(); // let's count a hit (except admin) if ($current['navigate_session'] != 1 && !nvweb_is_bot()) { $DB->execute(' UPDATE nv_items SET views = views + 1 WHERE id = ' . $current['id'] . ' AND website = ' . $website->id); } $current['type'] = 'item'; $current['template'] = $current['object']->template; if ($current['navigate_session'] == 1 && !empty($_REQUEST['template'])) { $current['template'] = $_REQUEST['template']; } } break; case 'sitemap.xml': nvweb_webget_load('sitemap'); echo nvweb_sitemap(array('mode' => 'xml')); nvweb_clean_exit(); break; // redirect to home page of the current website // redirect to home page of the current website case 'nvweb.home': case 'nv.home': header('location: ' . NVWEB_ABSOLUTE . $website->homepage()); nvweb_clean_exit(); break; // webservice endpoint via XML-RPC calls // webservice endpoint via XML-RPC calls case 'xmlrpc': $events->trigger('nvweb', 'xmlrpc', array('route' => '/' . $route)); // if no extension processes the call, use the integrated XML-RPC parser nvweb_xmlrpc(); nvweb_clean_exit(); break; // empty path // empty path case '': case '/': case 'nv.empty': if ($website->empty_path_action == 'homepage_noredirect') { $route = $website->homepage(); if (strpos($route, '/') === 0) { $route = substr($route, 1); } } else { $route = ""; $website->wrong_path_action = $website->empty_path_action; } // do NOT break this case, continue processing as wrong_path action // no special route (or already processed), look for the path on navigate routing table // do NOT break this case, continue processing as wrong_path action // no special route (or already processed), look for the path on navigate routing table default: $DB->query('SELECT * FROM nv_paths WHERE path = ' . protect('/' . $route) . ' AND website = ' . $website->id . ' ORDER BY id DESC'); $rs = $DB->result(); if (empty($rs)) { // no valid route found switch ($website->wrong_path_action) { case 'homepage': case 'homepage_redirect': header('location: ' . NVWEB_ABSOLUTE . $website->homepage()); nvweb_clean_exit(); break; case 'http_404': header("HTTP/1.0 404 Not Found"); nvweb_clean_exit(); break; case 'theme_404': $current['template'] = 'not_found'; $current['type'] = 'structure'; $current['id'] = 0; $current['object'] = new structure(); return; break; case 'website_path': $redirect_url = nvweb_template_convert_nv_paths($website->wrong_path_redirect); header('location: ' . $redirect_url); nvweb_clean_exit(); break; case 'blank': default: nvweb_clean_exit(); break; } } else { // route found! // let's count a hit (except admin) if ($current['navigate_session'] != 1 && !nvweb_is_bot()) { $DB->execute(' UPDATE nv_paths SET views = views + 1 WHERE id = ' . $rs[0]->id . ' AND website = ' . $website->id); } // set the properties found // set the default language for this route if (!isset($_REQUEST['lang'])) { $current['lang'] = $rs[0]->lang; $session['lang'] = $rs[0]->lang; // force reloading the dictionary $dictionary = nvweb_dictionary_load(); } $current['type'] = $rs[0]->type; $current['id'] = $rs[0]->object_id; // look for the template associated with this item if ($current['type'] == 'structure') { $obj = new structure(); $obj->load($current['id']); // check if it is a direct access to a "jump to another branch" path if ($obj->dictionary[$current['lang']]['action-type'] == 'jump-branch') { $current['id'] = $obj->dictionary[$current['lang']]['action-jump-branch']; $obj = new structure(); $obj->load($current['id']); header('location: ' . NVWEB_ABSOLUTE . $obj->paths[$current['lang']]); nvweb_clean_exit(); } else { if ($obj->dictionary[$current['lang']]['action-type'] == 'jump-item') { $current['id'] = $obj->dictionary[$current['lang']]['action-jump-item']; $obj = new item(); $obj->load($current['id']); header('location: ' . NVWEB_ABSOLUTE . $obj->paths[$current['lang']]); nvweb_clean_exit(); } } $current['object'] = $obj; $current['category'] = $current['id']; if ($current['navigate_session'] != 1 && !nvweb_is_bot()) { $DB->execute(' UPDATE nv_structure SET views = views + 1 WHERE id = ' . protect($current['id']) . ' AND website = ' . $website->id); } } else { if ($current['type'] == 'item') { $DB->query('SELECT * FROM nv_items WHERE id = ' . protect($current['id']) . ' AND website = ' . $website->id); $current['object'] = $DB->first(); // let's count a hit (except admin) if ($current['navigate_session'] != 1 && !nvweb_is_bot()) { $DB->execute(' UPDATE nv_items SET views = views + 1 WHERE id = ' . $current['id'] . ' AND website = ' . $website->id); } } else { if ($current['type'] == 'feed') { $out = feed::generate_feed($current['id']); if ($current['navigate_session'] != 1 && !nvweb_is_bot()) { $DB->execute(' UPDATE nv_feeds SET views = views + 1 WHERE id = ' . $current['id'] . ' AND website = ' . $website->id); } echo $out; nvweb_clean_exit(); } else { // path exists, but the object type is unknown // maybe the path belongs to an extension? $events->trigger('nvweb', 'routes', array('path' => $rs[0])); } } } $current['template'] = $current['object']->template; } break; } }
$id = $_REQUEST['id']; if (!empty($_REQUEST['id'])) { if (is_int($id)) { $item->load($id); } else { $item->load($_REQUEST['id']); } } if (!$item->id) { echo 'Error: no item found with id ' . $_REQUEST['id'] . '.'; session_write_close(); $DB->disconnect(); // we don't need the database anymore (we'll see) exit; } $website = new Website(); if (!empty($_GET['wid'])) { $website->load(intval($_GET['wid'])); } else { if ($item->website > 0) { $website->load($item->website); } else { $website->load(); } } $path = NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $item->id; // pass control to usual website download (ignoring enabled check) $_REQUEST['type'] = $item->type; $_REQUEST['force_resize'] = 'true'; nvweb_object(true, true); // ignore all permissions