-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.php
148 lines (146 loc) · 3.36 KB
/
generator.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
145
146
147
148
<?php
include('inc.php');
$total=0;
$samplestart='<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<!-- generated by self hosted script -->
<url>
<loc>'.$urlhead.'</loc>
</url>';
$sampleend='
</urlset>';
$sindex='<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
//for playlists
$apath="a/";
$c=1;$t=1;
$data=$samplestart;
$result=$conn->query('select pid from playlists');
while ($row = $result->fetch_assoc()) {
$list[] = $row['pid'];
}
$total+= count($list);
foreach($list as $link){
$data.='
<url>
<loc>'.$urlhead.'playlist/'.$link.'</loc>
</url>';
$c++;
if($c==300)
{
$data.=$sampleend;
$fp = fopen('maps/playlist'.$t.'.xml', 'w');
fwrite($fp, $data);
fclose($fp);
$sindex.='
<sitemap>
<loc>'.$urlhead.'maps/playlist'.$t.'.xml</loc>
<lastmod>'.date('Y-m-d\TH:i:sP').'</lastmod>
</sitemap>';
$t++;
$c=1;
$data=$samplestart;
}
}
$data.=$sampleend;
$fp = fopen('maps/playlist'.$t.'.xml', 'w');
fwrite($fp, $data);
fclose($fp);
$sindex.='
<sitemap>
<loc>'.$urlhead.'maps/playlist'.$t.'.xml</loc>
<lastmod>'.date('Y-m-d\TH:i:sP').'</lastmod>
</sitemap>';
//for albums
$apath="a/";
$c=1;$t=1;
$data=$samplestart;
$result=$conn->query('select aid from albums');
while ($row = $result->fetch_assoc()) {
$list[] = $row['aid'];
}
$total+= count($list);
foreach($list as $link){
$data.='
<url>
<loc>'.$urlhead.'album/'.$link.'</loc>
</url>';
$c++;
if($c==300)
{
$data.=$sampleend;
$fp = fopen('maps/album'.$t.'.xml', 'w');
fwrite($fp, $data);
fclose($fp);
$sindex.='
<sitemap>
<loc>'.$urlhead.'maps/album'.$t.'.xml</loc>
<lastmod>'.date('Y-m-d\TH:i:sP').'</lastmod>
</sitemap>';
$t++;
$c=1;
$data=$samplestart;
}
}
$data.=$sampleend;
$fp = fopen('maps/album'.$t.'.xml', 'w');
fwrite($fp, $data);
fclose($fp);
$sindex.='
<sitemap>
<loc>'.$urlhead.'maps/album'.$t.'.xml</loc>
<lastmod>'.date('Y-m-d\TH:i:sP').'</lastmod>
</sitemap>';
//for songs
$apath="s/";
$c=1;$t=1;
$list=array();
$data=$samplestart;
$result=$conn->query('select sid from songs');
while ($row = $result->fetch_assoc()) {
$list[] = $row['sid'];
}
$total+= count($list);
foreach($list as $link)
{
$data.='
<url>
<loc>'.$urlhead.'song/'.$link.'</loc>
</url>';
$c++;
if($c==300)
{
$data.=$sampleend;
$fp = fopen('maps/song'.$t.'.xml', 'w');
fwrite($fp, $data);
fclose($fp);
$sindex.='
<sitemap>
<loc>'.$urlhead.'maps/song'.$t.'.xml</loc>
<lastmod>'.date('Y-m-d\TH:i:sP').'</lastmod>
</sitemap>';
$t++;
$c=1;
$data=$samplestart;
}
}
$data.=$sampleend;
$fp = fopen('maps/song'.$t.'.xml', 'w');
fwrite($fp, $data);
fclose($fp);
$sindex.='
<sitemap>
<loc>'.$urlhead.'maps/song'.$t.'.xml</loc>
<lastmod>'.date('Y-m-d\TH:i:sP').'</lastmod>
</sitemap>';
$sindex.='
</sitemapindex>';
$fp = fopen('sitemap.xml', 'w');
fwrite($fp, $sindex);
fclose($fp);
echo $total.' sitemaps generated';
?>