<?php
include '../db.config.php';
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$sql = "SELECT * FROM posts ORDER BY created DESC";
$file = '../../../sitemap.xml';
$private = "2";
ob_start();
if ($result = mysqli_query($link, $sql))
{
if (mysqli_num_rows($result) > 0)
{
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?>";
echo "<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'>";
echo "<url><loc>https://watcha.movie/</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>1.00</priority></url>";
echo "<url><loc>https://watcha.movie/register</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.80</priority></url>";
echo "<url><loc>https://watcha.movie/login</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.80</priority></url>";
echo "<url><loc>https://watcha.movie/discovery</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.80</priority></url>";
echo "<url><loc>https://watcha.movie/movies</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.80</priority></url>";
echo "<url><loc>https://watcha.movie/categories</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.80</priority></url>";
echo "<url><loc>https://watcha.movie/page/about</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.80</priority></url>";
echo "<url><loc>https://watcha.movie/page/terms-and-conditions</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.80</priority></url>";
echo "<url><loc>https://watcha.movie/page/privacy-policy</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.80</priority></url>";
echo "<url><loc>https://watcha.movie/page/create-a-mirror</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.80</priority></url>";
echo "<url><loc>https://watcha.movie/page/affiliates</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.80</priority></url>";
echo "<url><loc>https://watcha.movie/page/dmca</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.80</priority></url>";
echo "<url><loc>https://watcha.movie/page/rss-feeds</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.80</priority></url>";
echo "<url><loc>https://watcha.movie/forgot-password</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/action</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/adventure</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/animation</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/comedy</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/crime</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/documentary</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/drama</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/family</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/fantasy</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/history</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/horror</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/music</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/mystery</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/romance</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/science-fiction</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/thriller</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/tv-movie</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/war</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
echo "<url><loc>https://watcha.movie/category/western</loc><lastmod>2021-05-06T23:23:07+00:00</lastmod><priority>0.64</priority></url>";
while ($row = mysqli_fetch_array($result))
{
if ($row['private'] == $private)
{
if(preg_match('/&/',$row['title'])){
}
else {
echo "<url>";
echo "<loc>https://watcha.movie/" . $row['type'] . "/" . $row['self'] . "-" . $row['id'] . "</loc>";
echo "<priority>0.51</priority>";
echo "</url>";
}
}
}
echo "</urlset>";
mysqli_free_result($result);
}
else
{
echo "No records matching your query were found.";
}
}
else
{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
$htmlStr = ob_get_contents();
ob_end_clean();
file_put_contents($file, $htmlStr);
mysqli_close($link);
?>