home = $config['http_home_url'];} function build_map() { $map = "\n\n"; $map .= $this->get_static(); $map .= $this->get_categories(); $map .= $this->get_news(); $map .= $this->get_forum(); $map .= ""; return $map; } function build_index( $count ) { $map = "\n\n"; $lastmod = date( "Y-m-d" ); $map .= "\n{$this->home}uploads/sitemap1.xml\n{$lastmod}\n\n"; for ($i =0; $i < $count; $i++) { $t = $i+2; $map .= "\n{$this->home}uploads/sitemap{$t}.xml\n{$lastmod}\n\n"; } $map .= ""; return $map; } function build_stat() { $map = "\n\n"; $map .= $this->get_static(); $map .= $this->get_categories(); $map .= ""; return $map; } function build_map_news( $n ) { $map = "\n\n"; $map .= $this->get_news( $n ); $map .= ""; return $map; } function get_categories() { global $db, $cache; $cat_info = $cache->get( "category" ); $this->priority = $this->cat_priority; if( ! is_array( $cat_info ) ) { $cat_info = array (); $db->query( "SELECT * FROM " . PREFIX . "_category ORDER BY posi ASC" ); while ( $row = $db->get_row() ) { $cat_info[$row['id']] = array (); foreach ( $row as $key => $value ) { $cat_info[$row['id']][$key] = $value; } } $cache->set( "category", $cat_info ); $db->free(); } $xml = ""; $lastmod = date( "Y-m-d" ); foreach ( $cat_info as $cats ) { $loc = $this->home . $this->get_url( $cats[id], $cat_info ) . "/"; $xml .= $this->get_xml( $loc, $lastmod ); } return $xml; } function get_news($page = false) { global $db, $config; $xml = ""; $this->priority = $this->news_priority; if ( $page ) { $page = $page - 1; $page = $page * 40000; $this->limit = " LIMIT {$page},40000"; } else { if( $this->limit < 1 ) $this->limit = false; if( $this->limit ) { $this->limit = " LIMIT 0," . $this->limit; } else { $this->limit = ""; } } $thisdate = date( "Y-m-d H:i:s", (time() + ($config['date_adjust'] * 60)) ); if( $config['no_date'] ) $where_date = " AND date < '" . $thisdate . "'"; else $where_date = ""; $result = $db->query( "SELECT id, date, alt_name, editdate FROM " . PREFIX . "_post WHERE approve=1" . $where_date . " ORDER BY date DESC" . $this->limit ); while ( $row = $db->get_row( $result ) ) { if ( $row['editdate'] ){$row['date'] = $row['editdate']; } else {$row['date'] = strtotime($row['date']);} $loc = $this->home . $row['id'] . "-" . $row['alt_name'] . ".html"; $xml .= $this->get_xml( $loc, date( "Y-m-d", $row['date'] ) ); } return $xml; } function get_static() { global $db; $xml = ""; $lastmod = date( "Y-m-d" ); $this->priority = $this->stat_priority; $result = $db->query( "SELECT name FROM " . PREFIX . "_static" ); while ( $row = $db->get_row( $result ) ) { if( $row['name'] == "dle-rules-page" ) continue; $loc = $this->home . $row['name'] . ".html"; $xml .= $this->get_xml( $loc, $lastmod ); } return $xml; } function get_url($id, $cat_info) { if( ! $id ) return; $parent_id = $cat_info[$id]['parentid']; $url = $cat_info[$id]['alt_name']; while ( $parent_id ) { $url = $cat_info[$parent_id]['alt_name'] . "/" . $url; $parent_id = $cat_info[$parent_id]['parentid']; if( $cat_info[$parent_id]['parentid'] == $cat_info[$parent_id]['id'] ) break; } return $url; } function get_forum() { global $db; $xml = ""; $lastmod=date("Y-m-d"); $this->priority = $this->stat_priority; $result = $db->query("SELECT tid FROM " . PREFIX . "_forum_topics"); while($row = $db->get_row($result)) { $loc = $this->home."forum/topic_".$row['tid']; $xml .= $this->get_xml($loc, $lastmod); } return $xml; } function get_xml($loc, $lastmod) { $loc = htmlspecialchars( $loc ); $xml = "\t\n"; $xml .= "\t\t$loc\n"; $xml .= "\t\t$lastmod\n"; $xml .= "\t\t" . $this->priority . "\n"; $xml .= "\t\n"; return $xml; } } ?>