forked from MIKEINTOSHSYSTEMS/Ayay_Media_Games
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sitemap.php
65 lines (61 loc) · 1.5 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
<?php
session_start();
$username = isset( $_SESSION['username'] ) ? $_SESSION['username'] : "";
if ( !$username ) {
exit('logout');
}
include 'config.php';
include 'init.php';
if ( ADMIN_DEMO ) {
exit('ADMIN DEMO');
}
if ( !USER_ADMIN ) {
exit('access forbidden!');
}
$str = '<?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 CloudArcade -->';
//domain
$str = $str.'
<url>
<loc>'.DOMAIN.'</loc>
<priority>1.00</priority>
</url>';
//categories
$cats = get_all_categories();
foreach ($cats as $cat) {
if (strpos($cat->slug, '&') == false) {
$str = $str.'
<url>
<loc>'.get_permalink('category', $cat->slug).'</loc>
<changefreq>weekly</changefreq>
</url>';
}
}
//games
$conn = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT slug FROM games";
$st = $conn->prepare($sql);
$st->execute();
$games = $st -> fetchAll();
$conn = null;
foreach ($games as $game) {
if (strpos($game['slug'], '&') == false) {
$str = $str.'
<url>
<loc>'.get_permalink('game', $game['slug']).'</loc>
</url>';
}
}
$str = $str.'</urlset>';
$sitemap = fopen("sitemap.xml", "w") or die("Unable to open file!");
$content = $str;
fwrite($sitemap, $content);
fclose($sitemap);
header('Location: sitemap.xml');
?>