query( "SELECT * FROM `languages`" ); $i = 0; while ($db->next_record()) { $lang_urls[] = "/" . $db->f( "lang" ) . "/" . $db->f( "default_site" ) . "/"; $lang_names[] = $db->f( "name" ); $lang_imgs[] = $db->f( "src_img" ); $lang_shorts[] = $db->f( "lang" ); $lang_defaults[] = $db->f( "default_site" ); if( $lang == $db->f( "lang" )) { $lang_selected = $i; $default_site = $db->f( "default_site" ); require( "lang_" . $lang . ".php" ); } $i++; } if( !isset( $lang_selected )) { $lang = getSetting( "default_language" ); require( "lang_" . $lang . ".php" ); } /* parse path and site name */ $site_path = implode( "/", array_slice( $p, 1, count( $p ) - 3 )) . "/"; if( $p[1] != "" ) { $site_name = $p[ count( $p ) - 2 ]; } else { $site_name = $default_site; } /* Build Menu */ $db->query( "SELECT `href`, `name` FROM `menu` " . "WHERE `lang` = '" . $lang . "' ". "ORDER BY `id`;" ); $i = 0; while ($db->next_record()) { if( substr( $db->f( "href" ), 0, 4 ) == "http" ) { $menu_urls[] = $db->f( "href" ); } else { $menu_urls[] = "/" . $lang . "/" . replaceWhitespace( $db->f( "href" )) . "/"; } $menu_names[] = $db->f( "name" ); if( $site == $db->f( "name" )) { $menu_selected = $i; } $i++; } /* Load Module */ if( file_exists( "mod_" . $p[1] . ".php" )) { require( "mod_" . $p[1] . ".php" ); $content = call_user_func( "mod_" . $p[1], $p ); } else { /* Get Site */ $db->query( "SELECT `id`, `content` FROM `sites` " . "WHERE `name` = '" . $site_name . "' ". "AND `path` = '" . $site_path . "' " . "AND `language` = '" . $lang . "';" ); if( $db->next_record( )) { $db->query( "UPDATE `sites` SET `count`=`count`+1 " . "WHERE `path` = '" . $site_path . "'" . "AND `name` = '" . $site_name . "'" . "AND `language` = '" . $lang . "';"); $content = $db->f( "content" ); $ctemplate = new mySmarty; $ctemplate->assign( "content", $content ); $ctemplate->assign( "pagetitle", $site_name); $content = $ctemplate->fetch( "content.tpl" ); } else { if( !$xerr ) $xerr = $itext[ "site_not_found" ]; } } if( $xerr ) { getSmarty( ); $smarty->assign( "error", $xerr ); $content = $smarty->fetch( "error.tpl" ); } /* highlighing */ initVar( "highlight", 0 ); if( $highlight ) { preg_match_all( "/(<[^>][^<]*>)([^<]*)/", $content, $tmp_match, PREG_PATTERN_ORDER ); $content = ""; for( $h_num = 0; $h_num < count( $tmp_match[1] ); $h_num++ ) { $content .= $tmp_match[1][ $h_num ]; $content .= str_replace( $highlight, "" . $highlight . "", $tmp_match[2][ $h_num ] ); } } getSmarty( ); $smarty->assign( "pagetitle", $site_name ); $smarty->assign( "lang", $lang ); $smarty->assign( "lang_urls", $lang_urls ); $smarty->assign( "lang_names", $lang_names ); $smarty->assign( "lang_imgs", $lang_imgs ); $smarty->assign( "lang_selected", $lang_selected ); $smarty->assign( "menu_urls", $menu_urls ); $smarty->assign( "menu_names", $menu_names ); $smarty->assign( "menu_selected", $menu_selected ); $smarty->assign( "content", $content ); $smarty->display( "main.tpl" ); ?>