WebsiteBaker 2.13.8 is now available!
R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WBhttps://forum.websitebaker.org/index.php/topic,32355.0.html
require("config.php"); // i need db connectiondefine('ERROR_PAGE' , '/error404'); //Change this to point to your existing 404 page is in admin/pages menu.if (isset($_GET['_wb'])) { $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI']; $_SERVER['SCRIPT_NAME'] = $_SERVER['REQUEST_URI']; $page_link1 = trim($_GET['_wb'],'/'); $page_link = '/'.$page_link1; $link_chunks = explode("/",$page_link1); $links_array = Array(); for ($i = 0; $i < count($link_chunks); ++$i) { $sublink = ''; for ($j = 0; $j < $i; $j++) { $sublink .= '/'.$link_chunks[$j]; } $links_array[] = $sublink.'/'.$link_chunks[$i]; } $links_array = array_reverse($links_array,false); // reverse order for best possible match $count_chunks = count($links_array); $matches = 0; $k = 0; while( $k < $count_chunks AND $matches < 1) { $qpages = $database->query("SELECT page_id FROM `".TABLE_PREFIX."pages` WHERE `link` = '$links_array[$k]'"); if (!$qpages OR $qpages->numRows() == 0) { $matches = 0; $matched_link = ''; } else { $matches = 1; $matched_link = $links_array[$k]; $page_row = $qpages->fetchRow(); $matched_page_id = $page_row['page_id']; } $k++; } if ($matches == 0) { header('Location: '.WB_URL.ERROR_PAGE); } // List modules who needs more parameters than just page_id $module['bakery'] = array('item_id'); $module['news'] = array('section_id', 'post_id');// ... here put more modules.. // We move on with page_id if(isset($matched_page_id)) { $sections_query = $database->query("SELECT module FROM ".TABLE_PREFIX."sections WHERE page_id = '$matched_page_id' ORDER BY section_id ASC "); while( $section = $sections_query->fetchRow() ) { // Check if the module is added to the module list $module_name = $section['module']; if(array_key_exists($module_name, $module)) { switch ($module_name) { case 'bakery': $id_name = $module[$module_name][0]; //Search for item_id from url $k = 0; while( $k < $count_chunks AND $bakerymatches < 1) { $qpages = $database->query("SELECT $id_name FROM ".TABLE_PREFIX."mod_bakery_items WHERE link = '$links_array[$k]'"); if (!$qpages OR $qpages->numRows() == 0) { $bakerymatches = 0; } else { $bakerymatches = 1; $matched_link = $links_array[$k]; $page_row = $qpages->fetchRow(); $item_id = $page_row[$id_name]; define("ITEM_ID", $item_id); } $k++; } break; case 'news': $section_id_name = $module[$module_name][0]; $post_id_name = $module[$module_name][1]; // search for post_id $qpages = $database->query("SELECT $section_id_name, $post_id_name FROM ".TABLE_PREFIX."mod_news_posts WHERE link = '$page_link'"); if ($qpages->numRows() > 0) { $page_row = $qpages->fetchRow(); // populate required variables for specific post $iPageId = $matched_page_id; $section_id = $page_row[$section_id_name]; $post_id = $page_row[$post_id_name]; $post_section = $page_row[$section_id_name]; } break; default : $page_id = $matched_page_id; break; } } } $page_id = $matched_page_id; } } else { header('Location: '.WB_URL.ERROR_PAGE);}require('index.php');
line: 63 $newLink = '/posts/'.$sNewFile;insert://///// More code // Create nice URLs => /posts/' replaced with: /group_name/ $query_groups = $database->query("SELECT title FROM `".TABLE_PREFIX."mod_news_groups` WHERE group_id = '$group_id'"); if($query_groups->numRows() > 0) { $row = $query_groups->fetchRow(); $category_name = '/'.page_filename($admin->add_slashes($row['title'])); } else { // For no category, put under /posts/ $category_name = '/posts'; } // Get page link URL $query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"); $page = $query_page->fetchRow(); $page_link = $page['link']; // finaly, create nice urls - /page/group/post_title $post_link = $page_link.$category_name.'/'.page_filename($title).PAGE_SPACER.$post_id; $newLink = $post_link;/////find line switch($sDoWhat)and dissable entire switch with comments / * switch($sDoWhat)...... }*/to stop to create access files.you will be able to create and view posts and news page , there is only one glitch when you submit comment (I need to fix returning path after submitting, but it can be done in 3 lines of code :D )
$page_id = 2;require("config.php");require(WB_PATH."/index.php");