-
Notifications
You must be signed in to change notification settings - Fork 24
/
generateSiteMap.php
144 lines (111 loc) · 3.7 KB
/
generateSiteMap.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
137
138
139
140
141
142
143
144
<?php
/**
* This is meant to be called from cron.
* It will send off the ealerts.
*/
require_once("bootstrap.php");
$filename = EXP_PATH . 'sitemap.xml';
$content="<?xml version='1.0' encoding='UTF-8'?>".chr(13).chr(10);
$content.="<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>".chr(13).chr(10);
if (is_writable($filename))
{
if (!$handle = fopen($filename, 'w')) {
echo "Cannot open file ($filename)";
exit;
}
// Write$somecontent to our opened file.
if (fwrite($handle, $content) == FALSE) {
$action_msg = "ER";
}
}
else
{
echo "$filename is not writeable.";
}
$count=0;
$columns = '';
//$ps = new product();
//$prodCount = $ps->find('count','parent_id=0 AND (availability_type=0 OR availability_type=1)');
//print "\n" . $prodCount . "\n";
//print "\n";
$sections = $db->selectObjectsBySql('SELECT sef_name FROM exponent_section WHERE public = 1 and active = 1');
//Sections
foreach ($sections as $item) {
$columns = '<url>'.chr(13).chr(10);
$columns.='<loc>';
$columns.="http://www.militaryuniformsupply.com/".$item->sef_name;
$columns.='</loc>'.chr(13).chr(10);
$columns.='<lastmod>';
$columns.= date('Y-m-d');
$columns.='</lastmod>'.chr(13).chr(10);
$columns.='<changefreq>';
$columns.= "weekly";
$columns.='</changefreq>'.chr(13).chr(10);
$columns.='<priority>';
$columns.= "0.5";
$columns.='</priority>'.chr(13).chr(10);
$columns.='</url>'.chr(13).chr(10);
$count++;
//size
// Write$somecontent to our opened file.
if (fwrite($handle, $columns.chr(13).chr(10)) == FALSE) {
$action_msg = "ER";
}
}
//Categories
$categories = $db->selectObjectsBySql('SELECT sef_url FROM exponent_storeCategories WHERE is_active = 1');
foreach ($categories as $item) {
$columns = '<url>'.chr(13).chr(10);
$columns.='<loc>';
$columns.="http://www.militaryuniformsupply.com/".$item->sef_url;
$columns.='</loc>'.chr(13).chr(10);
$columns.='<lastmod>';
$columns.= date('Y-m-d');
$columns.='</lastmod>'.chr(13).chr(10);
$columns.='<changefreq>';
$columns.= "weekly";
$columns.='</changefreq>'.chr(13).chr(10);
$columns.='<priority>';
$columns.= "0.5";
$columns.='</priority>'.chr(13).chr(10);
$columns.='</url>'.chr(13).chr(10);
$count++;
//size
// Write$somecontent to our opened file.
if (fwrite($handle, $columns.chr(13).chr(10)) == FALSE) {
$action_msg = "ER";
}
}
//Products
$products = $db->selectObjectsBySql("SELECT sef_url FROM exponent_product WHERE (active_type = 0 or active_type = 1) and parent_id = 0");
foreach ($products as $item) {
$columns = '<url>'.chr(13).chr(10);
$columns.='<loc>';
$columns.="http://www.militaryuniformsupply.com/".$item->sef_url;
$columns.='</loc>'.chr(13).chr(10);
$columns.='<lastmod>';
$columns.= date('Y-m-d');
$columns.='</lastmod>'.chr(13).chr(10);
$columns.='<changefreq>';
$columns.= "weekly";
$columns.='</changefreq>'.chr(13).chr(10);
$columns.='<priority>';
$columns.= "0.5";
$columns.='</priority>'.chr(13).chr(10);
$columns.='</url>'.chr(13).chr(10);
$count++;
//size
// Write$somecontent to our opened file.
if (fwrite($handle, $columns.chr(13).chr(10)) == FALSE) {
$action_msg = "ER";
}
}
$content='</urlset>'.chr(13).chr(10);
// Write$somecontent to our opened file.
if (fwrite($handle, $content) == FALSE) {
$action_msg = "ER";
}
$action_msg = "SC";
fclose($handle);
echo "\r\nGenerated $count products in the feed.\r\n";
?>