public function actionIndex() { $domain = 'http://' . $_SERVER['SERVER_NAME']; $time = explode(" ", microtime()); $time = $time[1]; // create object $sitemap = new SitemapGenerator($domain . '/', ROOT_PATH); // will create also compressed (gzipped) sitemap $sitemap->createGZipFile = true; $urls = array(); $urls[] = array($domain, date('c'), 'daily', '1'); $urls[] = array($this->createAbsoluteUrl('video/index'), date('c'), 'daily', '1'); //danh muc $query = "SELECT id, alias FROM tbl_category"; $result = $this->db->createCommand($query)->queryAll(); foreach ($result as $item) { $url = $this->createAbsoluteUrl('category/index', array('alias' => $item['alias'])); if ($item['id'] == 20) { $url = $domain . '/reviews.html'; } $urls[] = array($url, date('c'), 'daily', '0.9'); } //topic tag $query = "SELECT id, alias FROM tbl_tags"; $result = $this->db->createCommand($query)->queryAll(); foreach ($result as $item) { $url = $this->createAbsoluteUrl('tag/index', array('alias' => $item['alias'])); $urls[] = array($url, date('c'), 'daily', '0.7'); } //danh sach bai viet $query = "SELECT id, alias, cate_id FROM tbl_archive ORDER BY id DESC"; $result = $this->db->createCommand($query)->queryAll(); foreach ($result as $item) { $url = $this->createAbsoluteUrl('detail/index', $item); $urls[] = array($url); } //danh sach bai viet $query = "SELECT id, alias FROM tbl_youtube ORDER BY id DESC"; $result = $this->db->createCommand($query)->queryAll(); foreach ($result as $item) { $url = $this->createAbsoluteUrl('video/detail', array('alias' => $item['alias'])); $urls[] = array($url); } if ($_GET['test'] == 1) { echo count($urls); die; } header('Content-type: application/xml'); // add many URLs at one time $sitemap->addUrls($urls); try { // create sitemap $sitemap->createSitemap(); // write sitemap as file $sitemap->writeSitemap(); } catch (Exception $exc) { echo $exc->getTraceAsString(); } }
function __construct() { self::$website = GetConfig('ShopPath'); $this->Last_modification = date("Y-m-d"); //date("Y-m-d\TH:i:s").substr(date("O"),0,3).":".substr(date("O"),3); if (!is_dir(self::$sitemap_folder)) { mkdir(self::$sitemap_folder); chmod(self::$sitemap_folder, 0777); } $filename = self::$sitemap_index . '.xml'; if (!file_exists($filename)) { file_put_contents($filename, ''); /* $fp=fopen($filename, "w+"); if(!is_writable($filename) ){ } fclose($fp);*/ chmod($filename, 0777); } }
} } return $p; } public function compressToGZ($srcName, $dstName) { $fp = fopen($srcName, "r"); $data = fread($fp, filesize($srcName)); fclose($fp); $zp = gzopen($dstName, "w9"); gzwrite($zp, $data); gzclose($zp); } } if (!isset($SitemapGenerator) || empty($SitemapGenerator)) { $SitemapGenerator = new SitemapGenerator(); } $dir = null; require_once $relpa . 'inc/dir.inc'; sort($dir, 0); reset($dir); /** * update sitemap.xml */ $sitemap_xml = 'sitemap.xml'; $sitemap_xml_gz = 'sitemap.xml.gz'; $sitemap_changefreq = 'monthly'; $sitemap_priority = '0.2'; $s = ''; for ($i = 0; $i < count($dir); $i++) { if (!empty($dir[$i][0])) {
foreach ($names as $name => $value) { if (in_array($name, $_POST['names'])) { $config[$name]['changefreq'] = $_POST['changefreq'][$name]; $config[$name]['priority'] = $_POST['priority'][$name]; } } if (write_ini_file($config, CONFIG_PATH . 'sitemap.ini', true)) { rcms_showAdminMessage(__('Configuration updated')); } } $config = @parse_ini_file(CONFIG_PATH . 'sitemap.ini', true); /////////////////////////////////////Initialization///////////////////////////////////////// if (!empty($_POST['create']) && !empty($_POST['filename'])) { $frm = new InputForm('', 'post', '<<< ' . __('Back')); $frm->show(); $sitemap = new SitemapGenerator($directory); $time = explode(" ", microtime()); $time = $time[1]; if (isset($_POST['sitemap_dat'])) { file_write_contents(DF_PATH . 'sitemap.dat', $_POST['sitemap_dat']); } //save new urls if (!empty($_POST['names']) && is_array($_POST['names'])) { $modules = $_POST['names']; } else { rcms_showAdminMessage('Sitemap' . __(' is empty')); return; } ////////////////////////////////////////Start build////////////////////////////////////// foreach ($modules as $module) { if ($module != 'module' and $module != 'sitemap') {
/** * Gets the sitemap index. */ private function get_sitemap_index() { $generator = new SitemapGenerator(); return $generator->generate_sitemap_index($this->sitemap); }
/** * Renders sitemap file * @param array $config */ private function renderNormal($config) { $map = new SitemapGenerator($config['aliases']); $map->setDefaults($config); echo $map->getAsXml(); }
/** * * generate sitemap */ public static function generate($force = FALSE) { //start time $start_time = microtime(TRUE); $site_url = Core::config('general.base_url'); // include class require Kohana::find_file('vendor/sitemap', 'SitemapGenerator'); // create object $sitemap = new SitemapGenerator($site_url, DOCROOT); // will create also compressed (gzipped) sitemap $sitemap->createGZipFile = TRUE; // determine how many urls should be put into one file $sitemap->maxURLsPerSitemap = 10000; // sitemap file name $sitemap->sitemapFileName = 'sitemap.xml'; // sitemap index file name $sitemap->sitemapIndexFileName = 'sitemap-index.xml'; // robots file name //$sitemap->robotsFileName = 'robots.txt'; //users $users = new Model_User(); $users = $users->select('seoname')->select('created')->where('status', '=', Model_User::STATUS_ACTIVE)->find_all(); foreach ($users as $user) { $url = Route::url('profile', array('seoname' => $user->seoname)); $sitemap->addUrl($url, date('c', Date::mysql2unix($user->created)), 'monthly', '0.5'); } //pages CMS $pages = new Model_Content(); $pages = $pages->select('seotitle')->where('type', '=', 'page')->where('status', '=', '1')->find_all(); foreach ($pages as $page) { $url = Route::url('page', array('seotitle' => $page->seotitle)); $sitemap->addUrl($url, date('c', Date::mysql2unix($page->created)), 'monthly', '0.5'); } //FAQ CMS if (core::config('general.faq') == 1) { $pages = new Model_Content(); $pages = $pages->select('seotitle')->where('type', '=', 'help')->where('status', '=', '1')->find_all(); $sitemap->addUrl(Route::url('faq'), date('c'), 'monthly', '0.5'); foreach ($pages as $page) { $url = Route::url('faq', array('seotitle' => $page->seotitle)); $sitemap->addUrl($url, date('c', Date::mysql2unix($page->created)), 'monthly', '0.5'); } } //locations $locs = new Model_Location(); $locs = $locs->select('seoname')->where('id_location', '!=', 1)->find_all(); //categories $cats = new Model_Category(); $cats = $cats->select('seoname')->where('id_category', '!=', 1)->find_all(); foreach ($cats as $cat) { $url = Route::url('list', array('category' => $cat->seoname)); $sitemap->addUrl($url, date('c'), 'daily', '0.7'); //adding the categories->locations foreach ($locs as $loc) { $url = Route::url('list', array('category' => $cat->seoname, 'location' => $loc->seoname)); $sitemap->addUrl($url, date('c'), 'weekly', '0.5'); } } //all the ads $ads = DB::select('a.seotitle')->select(array('c.seoname', 'category'))->from(array('ads', 'a'))->join(array('categories', 'c'), 'INNER')->on('a.id_category', '=', 'c.id_category')->where('a.status', '=', Model_Ad::STATUS_PUBLISHED)->as_object()->execute(); foreach ($ads as $a) { $url = Route::url('ad', array('category' => $a->category, 'seotitle' => $a->seotitle)); $sitemap->addUrl($url, date('c'), 'monthly', '0.5'); } //all the blog posts if (core::config('general.blog') == 1) { $sitemap->addUrl(Route::url('blog'), date('c'), 'daily', '0.7'); $posts = new Model_Post(); $posts = $posts->where('status', '=', 1)->where('id_forum', 'IS', NULL)->order_by('created', 'desc')->find_all(); foreach ($posts as $post) { $url = Route::url('blog', array('seotitle' => $post->seotitle)); $sitemap->addUrl($url, date('c'), 'monthly', '0.5'); } } //all the forums and topics if (core::config('general.forums') == 1) { $sitemap->addUrl(Route::url('forum-home'), date('c'), 'monthly', '0.5'); $forums = new Model_Forum(); $forums = $forums->select('seoname')->find_all(); foreach ($forums as $forum) { $url = Route::url('forum-list', array('forum' => $forum->seoname)); $sitemap->addUrl($url, date('c'), 'daily', '0.7'); } //all the topics $posts = new Model_Post(); $posts = $posts->where('status', '=', Model_Post::STATUS_ACTIVE)->where('id_forum', 'IS NOT', NULL)->where('id_post_parent', 'IS', NULL)->order_by('created', 'desc')->find_all(); foreach ($posts as $post) { $url = Route::url('forum-topic', array('seotitle' => $post->seotitle, 'forum' => $post->forum->seoname)); $sitemap->addUrl($url, date('c'), 'daily', '0.7'); } } try { // create sitemap $sitemap->createSitemap(); // write sitemap as file $sitemap->writeSitemap(); // update robots.txt file //$sitemap->updateRobots(); // submit sitemaps to search engines $result = $sitemap->submitSitemap(); // shows each search engine submitting status // echo '<pre>'.print_r($result,1).'</pre>'; } catch (Exception $exc) { echo $exc->getTraceAsString(); } $ret = 'Memory peak ' . round(memory_get_peak_usage() / (1024 * 1024), 2) . ' MB -'; return $ret . ' Time: ' . round(microtime(TRUE) - $start_time, 2) . 's'; }
<?php require_once 'common/header.php'; $sg = new SitemapGenerator(); $lat = $long = ''; if (isset($_POST['submit'])) { $key = "AIzaSyBtdwakOHGgJ8p9llMUHIdYCxvX2QWoZos"; $lat = $_POST['lat']; $long = $_POST['long']; $url = "https://maps.googleapis.com/maps/api/geocode/json?latlng={$lat},{$long}&key={$key}"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HEADER, 0); //Change this to a 1 to return headers curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); $data = json_decode($data, true); $sg->save_db_sitemap($data); if (isset($data['results'][0])) { $address = $data['results'][0]['formatted_address']; } else { $address = ''; } } ?> <h1>Reverse Geo Location</h1> <div class="pull-right"> <a href="index.html">Home </a> </div>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <?php $time = explode(" ", microtime()); $time = $time[1]; // include class include 'SitemapGenerator.php'; // create object $sitemap = new SitemapGenerator("http://your.app.com/", "../"); // will create also compressed (gzipped) sitemap $sitemap->createGZipFile = true; // determine how many urls should be put into one file $sitemap->maxURLsPerSitemap = 10000; // sitemap file name $sitemap->sitemapFileName = "sitemap.xml"; // sitemap index file name $sitemap->sitemapIndexFileName = "sitemap-index.xml"; // robots file name $sitemap->robotsFileName = "robots.txt"; $urls = array(array("http://your.app.com", date('c'), 'daily', '1'), array("http://your.app.com/mainpage1", date('c'), 'daily', '0.5'), array("http://your.app.com/mainpage2", date('c'), 'daily'), array("http://your.app.com/mainpage3", date('c')), array("http://your.app.com/mainpage4")); // add many URLs at one time $sitemap->addUrls($urls); // add urls one by one $sitemap->addUrl("http://your.app.com/page1", date('c'), 'daily', '0.5'); $sitemap->addUrl("http://your.app.com/page2", date('c'), 'daily'); $sitemap->addUrl("http://your.app.com/page3", date('c'));
include_once ENGINE_PATH . 'class/classConstData.php'; include_once ENGINE_PATH . 'class/classSitemapGenerator.php'; Error::initialize(); Error::setMailing(TRUE); Error::$pathToFile = LOCAL_PATH . 'logs/sitemap.log'; Error::setFileLogging(TRUE); DB::initialize('mysql', 'localhost', NULL, 'venginse_admin', 'venginse', 'YqPffTfB'); DB::executeQuery('SET NAMES utf8', 'cp_utf8'); $q = 'SELECT s_hostname, s_dbname, s_path, s_gziped FROM sites WHERE s_indexed = 1'; DB::executeQuery($q, 'sites'); $rows = DB::fetchResults('sites'); if (!empty($rows)) { $tsize = sizeof($rows); $Sitemap = new SitemapGenerator('venginse_all'); for ($i = 0; $i < $tsize; $i++) { $q = 'SELECT c_value FROM ' . $rows[$i]['s_dbname'] . '.const WHERE c_name = "siteClosed" LIMIT 1'; DB::executeQuery($q, 'close'); $row = DB::fetchOne('close'); if ($row == '0') { $Sitemap->setParams($rows[$i]); if ($Sitemap->buildSitemap()) { $Sitemap->writeSitemap(); $Sitemap->submitSitemap(); } sleep(100); } }
public function completeSitemap() { parent::completeSitemap(); fclose($this->file); echo 'Done'; }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <?php // include class include 'SitemapGenerator.php'; // create object $sitemap = new SitemapGenerator("http://your.app.com/"); // add urls $sitemap->addUrl("http://your.app.com", date('c'), 'daily', '1'); $sitemap->addUrl("http://your.app.com/page1", date('c'), 'daily', '0.5'); $sitemap->addUrl("http://your.app.com/page2", date('c'), 'daily'); $sitemap->addUrl("http://your.app.com/page3", date('c')); $sitemap->addUrl("http://your.app.com/page4"); $sitemap->addUrl("http://your.app.com/page/subpage1", date('c'), 'daily', '0.4'); $sitemap->addUrl("http://your.app.com/page/subpage2", date('c'), 'daily'); $sitemap->addUrl("http://your.app.com/page/subpage3", date('c')); $sitemap->addUrl("http://your.app.com/page/subpage4"); // create sitemap $sitemap->createSitemap(); // write sitemap as file $sitemap->writeSitemap(); // update robots.txt file $sitemap->updateRobots(); // submit sitemaps to search engines $sitemap->submitSitemap(); ?>
public function generate_all_sitemaps() { $generator = new SitemapGenerator(); $generator->set_custom_links($this->config->get('custom')); $generator->set_entity_types($this->config->get('entity_types')); foreach (\Drupal::languageManager()->getLanguages() as $language) { $generator->set_sitemap_lang($language); $this->language = $language; $this->sitemap = $generator->generate_sitemap(); $this->save_sitemap(); } }