global = new skin_global; if ( URL_TYPE == 3 ) $skin = str_replace( "./", $_SERVER['DOCUMENT_ROOT'] ."/", $skin ); $this->skinDir = ( IN_SITE == 2 ) ? "../admin/skin/" : $skin; if ( IN_SITE != 3 ) { $this->loadSkin( "all" ); if ( !file_exists( RP ."lang/". $bin->conf['language'] .".php" ) ) return 1; require_once RP ."lang/". $bin->conf['language'] .".php"; $bin->lang = array_merge_recursive( $bin->lang, ( IN_SITE == 2 ) ? $lang_adm : $lang ); } $this->output['page'] = ""; $this->output['top'] = ""; $this->output['left'] = ""; $this->output['content'] = ""; $this->output['right'] = ""; $this->output['debug'] = ""; } function loadSkin( $skins ) { global $bin, $db; $type = ( IN_SITE == 2 ) ? "admin" : "site"; $skins = explode( ",", $skins ); if ( !is_array( $skins ) ) $skins = array( $skins ); foreach ( $skins as $id => $name ) { if ( empty( $name ) ) continue; $file = $this->skinDir . $type ."_". $name .".". SKIN_FILE_TYPE; if ( file_exists( $file ) ) { if ( SKIN_FILE_TYPE == "xml" ) { $db->xml->open( "name,vars,globals,precode,display", "section", $file ); $skinxml = $db->xml->data; $skindata = "class ". $skinxml->items['ATTRS']['type'] ."_". $skinxml->items['ATTRS']['name'] ."\n{\n"; for ( $i = 0; $i < count( $skinxml->items )-1; $i++ ) { if ( strstr( $skinxml->items[$i]['globals'], "$" ) ) $skinxml->items[$i]['globals'] = "\nglobal ". $skinxml->items[$i]['globals'].";"; $skindata .= "\nfunction ".$skinxml->items[$i]['name']."(".$skinxml->items[$i]['vars'].")\n{\n".$skinxml->items[$i]['globals']."\n\n".$skinxml->items[$i]['precode']."\nreturn <<items[$i]['display']."\nHTML;\n }\n"; } $skindata .= "\n}"; $skindata = str_replace( "<", "<", str_replace( ">", ">", $skindata ) ); $name = $skinxml->items['ATTRS']['name']; $class = $skinxml->items['ATTRS']['type']. "_". $skinxml->items['ATTRS']['name']; eval( $skindata ); if ( !empty( $name ) ) ( $type == "admin" ) ? $bin->skin->admin->$name = new $class : $bin->skin->$name = new $class; $skindata = ""; } else { require_once $file; $name = $name; $class = $type ."_". $name; if ( !empty( $name ) ) { $bin->skin->$name = new $class; } } } else $bin->kill( $bin->lang['core']['noSkinFile'] ." (". $file .")" ); } } function formatPage( &$html ) { global $bin, $db; $execution = ""; ####################################### # Please leave this alone. I spend my # # free time developing this program # # and I'd like to be credited for it. # ####################################### $html = str_replace( $execution, "Powered By: {!program!} v{!version!}
\n© Seigousei.net 2006
\n". $execution, $html ); $html = str_replace( "{!program!}", $bin->program, $html ); $html = str_replace( "{!version!}", $bin->version, $html ); $skinDir = ( URL_TYPE == 3 ) ? str_replace( "./", "/", SKINDIR ) : $this->skinDir; $html = str_replace( "{!images!}", $skinDir ."images/", $html ); $html = str_replace( "{!ip!}", $_SERVER['REMOTE_ADDR'], $html ); $html = str_replace( "{!LoadTime!}", $bin->loadtime, $html ); $html = str_replace( "{!info!}", $this->assembleInfo(), $html ); $queries = 0; if ( IN_SITE != 3 && $bin->conf['uses_database'] ) foreach ( $db as $driver ) if ( method_exists( $driver, "show_cache" ) ) $queries += $driver->count; $html = str_replace( "{!DBQueries!}", $queries, $html ); return $html; } function showPage( $offline ) { global $bin, $timer, $db; if ( $offline == 1 ) $this->raw = $this->global->offline( $bin->conf['offline_message'] ); elseif ( $offline == 2 ) $this->raw = $this->global->offline( $bin->conf['dev_message'] ); elseif ( $offline != 0 ) $this->raw = ""; else { if ( IN_SITE == 1 ) $this->assemble(); elseif ( IN_SITE == 2 ) $this->assemble_admin(); elseif ( IN_SITE == 3 ) $this->raw = $this->output['content']; } $this->raw = $bin->func->stripslashes( $this->raw ); $bin->loadtime = $timer->stop(); $this->formatPage( $this->raw ); print( $this->raw ); } function getCSS( $file ) { global $bin; header( "Content-type: text/css" ); if ( preg_match( "#^(.+?)\.php$#i", $file ) ) { require_once( $this->skinDir ."images/". $file ); } else { $css = file_get_contents( $this->skinDir ."images/". $file ); $css = str_replace( "{!images!}", $this->skinDir ."images/", $css ); print $css; } } function getJS( $file ) { global $bin; header( "Content-type: text/javascript" ); if ( preg_match( "#^(.+?)\.php$#i", $file ) ) { require_once( $this->skinDir ."images/". $file ); } else { $js = file_get_contents( $this->skinDir ."images/". $file ); $js = str_replace( "{!images!}", $this->skinDir ."images/", $js ); print $js; } } function assemble() { global $bin; $title = $this->title; if ( !empty( $title ) ) $title = " - ".$this->title; if ( $bin->conf['offline'] ) $title .= " - OFFLINE"; $this->output['content'] = $bin->skin->all->page_content( $this->output['content'] ); if ( $this->showNav == 1 ) $navlist = $this->assembleNav( $bin->skin->all->navigation() ); elseif ( $this->showNav == 2 ) $navlist = $this->assembleNav( $this->customNav ); else $navlist = ""; $content = $this->output['content']; if ( ADMIN ) $content .= $bin->skin->all->admin(); if ( defined( "JUST_CONTENT" ) ) $this->raw = $bin->skin->all->justContent( $content ); else $this->raw = $bin->skin->all->page( $title, $this->onload, $navlist, $content, ( IN_DEV && !empty( $this->output['debug'] ) ) ? $bin->skin->all->debug($this->output['debug']) : "" ); } function assemble_admin() { global $bin, $db; $title = $this->title; if ( !empty( $title ) ) $title = " - ".$this->title; if ( $bin->conf['offline'] ) $title .= " - OFFLINE"; $this->output['content'] = $bin->skin->all->page_content( $this->output['content'] ); $content = $this->output['content']; if ( ADMIN ) $content .= $bin->skin->all->admin(); $this->raw .= $bin->skin->all->page( $title, $this->onload, $content, ( IN_DEV && !empty($this->output['debug']) ) ? $bin->skin->all->debug($this->output['debug']) : "" ); } function assembleNav( $theNav ) { global $bin; $theNav = explode( "\n", trim( $theNav ) ); $nav = ""; foreach ( $theNav as $k => $v ) { $thisnav = explode( "|~|", $v ); if ( count( $thisnav ) == 2 ) if ( isset( $bin->URL[0] ) && $thisnav[0] == $bin->URL[0] ) $nav .= trim( $bin->skin->all->nav_linkcurrent( array( $bin->func->formatURL( $thisnav[0] ), $thisnav[1] ) ) ); else $nav .= trim( $bin->skin->all->nav_link( array( $bin->func->formatURL( $thisnav[0] ), $thisnav[1] ) ) ); } $navlist = trim( $bin->skin->all->nav( $nav ) ); return $navlist; } function assembleInfo() { global $bin; if ( !isset( $bin->conf['validInfo'] ) || empty( $bin->conf['validInfo'] ) || !method_exists( $bin->skin->all, "info" ) ) return ""; $info = explode( ":||:", $bin->conf['validInfo'] ); $img = ""; $txt = ""; foreach ( $info as $k => $data ) { $data = explode( "|", $data ); if ( count( $data ) == 2 ) $txt .= $bin->skin->all->info( false, $data ); elseif ( count( $data ) == 3 ) { if ( file_exists( "./images/" ) ) { $imgData = @getimagesize( "./images/". $data[1] ); $data[3] = $imgData[3]; $img .= $bin->skin->all->info( true, $data ); } } } return $txt . $img; } } ?>