-
Notifications
You must be signed in to change notification settings - Fork 1
/
sitemap.php
136 lines (106 loc) · 3.95 KB
/
sitemap.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?
$type = read($_GET,'type','');
$timeout = 3600;
$timeout = 1;
//print "Running sitemap($type) timeout($timeout)<br>\n";
if(!$type){
$content = new HTMLPlaceholder();
$content->load($page->getGUID(), 'content');
$content->setMode($page->getMode());
$content->setHeight('500px');
$referer = urldecode(read($_REQUEST,'referer','/treeline/'));
$mode = read($_REQUEST,'mode','');
$tags = new Tags($site->id, 1);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$referer.=(strpos($referer, "?")?"&":"?");
$action = read($_POST,'treeline','');
if (read($_POST,'treeline','') == 'Save changes') {
$content->save();
$page->save();
$referer .= 'message='.urlencode("Changes saved to page '<strong>".$page->getTitle()."</strong>' in section <strong>". $page->drawTitleByGUID($page->getSectionByPageGUID($page->getGUID()))."</strong>");
$referer .= '&action=edit';
redirect ($referer);
}
else if (read($_POST,'treeline','') == 'Discard changes') {
$referer .= 'message='.urlencode("Changes discarded");
$referer .= '&action=edit';
redirect ($referer);
}
}
// Page specific options
$pageClass = 'sitemap'; // used for CSS usually
$css = array('forms'); // all attached stylesheets
if($page->style) $css[] = $page->style;
// extra page specific CSS
$extraCSS = '';
$js = array(); // all atatched JS behaviours
$extraJS = ''; // etxra page specific JS behaviours
$pagetitle = "Sitemap";
include($_SERVER['DOCUMENT_ROOT'].'/includes/templates/header.inc.php');
include($_SERVER['DOCUMENT_ROOT'].'/includes/snippets/pagetitle.inc.php');
?>
<div class="main-content">
<div class="container">
<div class="col-lg-12" id="primarycontent">
<!-- <p><?= $page->getMetaDescription() ?></p> -->
<?php
if( $siteID==1 ) $filename = 'sitemap.inc';
else $filename = 'sitemap_'. $site->id .'.inc';
//print "look for map ".$_SERVER['DOCUMENT_ROOT'].'/cache/'.$filename."<br>";
if(validCache($_SERVER['DOCUMENT_ROOT'].'/cache/'.$filename)){
//print "cache still valid<br>\n";
include($_SERVER['DOCUMENT_ROOT'].'/cache/'.$filename);
}
else{
//print "drawSiteMap(0, ".$site->id.")<br>";
$contents = $menu->drawSiteMapByParent(0, $site->id);
createCache($filename, $contents);
}
?>
</div>
<!-- end content div (id="content") -->
</div>
</div>
<?php
include($_SERVER['DOCUMENT_ROOT'].'/includes/templates/footer.inc.php');
?>
<?php
}
else if($type == 'xml' || $type=="xmlnews"){
// mime-type
header("HTTP/1.0 200 OK", true);
header("Content-type: text/xml; charset: UTF-8");
//$timeout = 1;
//echo $menu->drawXMLSiteMapByParent();
$filename = 'sitemap'.$site->id.($type=="xmlnews"?"news":"").'.xml';
$xmlfile = $_SERVER['DOCUMENT_ROOT'].'/cache/'.$filename;
if(!validCache($xmlfile, $timeout)){
//file doesn't exists, do create it and include it
//print "create file($xmlfile)<br>\n";
$contents = $menu->drawXMLSiteMapByParent($site->id, 0, $type=="xmlnews");
//print "content($contents)<br>\n";
createCache($filename, $contents, false);
$menu->drawSiteMapIndex();
}
if (file_exists($xmlfile)) {
readfile($xmlfile);
}
}
else if($type == 'xmlmap') {
$xmlsitemap = $_SERVER['DOCUMENT_ROOT']."/includes/snippets/sitemapindex.".($site->id+0).".xml";
header("Content-type: text/xml; charset: UTF-8");
if (file_exists($xmlsitemap)) {
echo file_get_contents($xmlsitemap);
}
else {
echo "<";
?>?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>http://<?=$_SERVER['HTTP_HOST']?>/sitemap.xml</loc>
<lastmod>2011-06-17T12:53:29+00:00</lastmod>
</sitemap>
</sitemapindex><?php
}
}
?>