-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathadvanced-example.php
82 lines (65 loc) · 2.86 KB
/
advanced-example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!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'));
$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");
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("yahooAppId");
// shows each search engine submitting status
echo "<pre>";
print_r($result);
echo "</pre>";
}
catch (Exception $exc) {
echo $exc->getTraceAsString();
}
echo "Memory peak usage: ".number_format(memory_get_peak_usage()/(1024*1024),2)."MB";
$time2 = explode(" ",microtime());
$time2 = $time2[1];
echo "<br>Execution time: ".number_format($time2-$time)."s";
?>
</body>
</html>