sitemap.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. header('Content-type: application/xml');
  3. $http_host = $_SERVER['HTTP_HOST'];
  4. include("functions.php");
  5. $con = startdb();
  6. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  7. ?>
  8. <urlset
  9. xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  10. xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
  11. <url>
  12. <loc>http://<?php echo $http_host; ?>/</loc>
  13. <?php
  14. $res_date = mysqli_query($con, "(SELECT DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM post) UNION (SELECT DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM activity) UNION (SELECT DATE_FORMAT(uploaded, '%Y-%m-%d') AS cdate FROM photo) ORDER BY cdate DESC LIMIT 1;");
  15. $row_date = mysqli_fetch_array($res_date);
  16. ?><lastmod><?php echo $row_date['cdate']; ?></lastmod>
  17. <changefreq>weekly</changefreq>
  18. <priority>0.8</priority>
  19. <image:image>
  20. <image:loc>http://<?php echo $http_host; ?>/img/logo/GasteizkoMargolariak.png</image:loc>
  21. <image:caption>Gasteizko Margolariak</image:caption>
  22. <image:title>Gasteizko Margolariak</image:title>
  23. </image:image>
  24. <image:image>
  25. <image:loc>http://<?php echo $http_host; ?>/img/logo/GasteizkoMargolariak-0.png</image:loc>
  26. <image:caption>Gasteizko Margolariak Original</image:caption>
  27. <image:title>Gasteizko Margolariak Original</image:title>
  28. </image:image>
  29. </url>
  30. <url>
  31. <loc>http://<?php echo $http_host; ?>/help/</loc>
  32. <changefreq>monthly</changefreq>
  33. <priority>0.5</priority>
  34. </url>
  35. <url>
  36. <loc>http://<?php echo $http_host; ?>/nosotros/</loc>
  37. <changefreq>monthly</changefreq>
  38. <priority>0.6</priority>
  39. </url>
  40. <url>
  41. <loc>http://<?php echo $http_host; ?>/blog/</loc>
  42. <?php
  43. $res_date = mysqli_query($con, "SELECT DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM post ORDER BY cdate DESC LIMIT 1;");
  44. $row_date = mysqli_fetch_array($res_date);
  45. ?><lastmod><?php echo $row_date['cdate']; ?></lastmod>
  46. <changefreq>weekly</changefreq>
  47. <priority>0.8</priority>
  48. </url>
  49. <?php
  50. $res_post = mysqli_query($con, "SELECT id, title_es, permalink, DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM post WHERE visible = 1 ORDER BY cdate DESC;");
  51. $priority = 0.75;
  52. while ($row_post = mysqli_fetch_array($res_post)){
  53. echo "\t<url>\n";
  54. echo "\t\t<loc>http://$http_host/blog/$row_post[permalink]</loc>\n";
  55. echo "\t\t<lastmod>$row_post[cdate]</lastmod>\n";
  56. echo "\t\t<changefreq>weekly</changefreq>\n";
  57. echo "\t\t<priority>$priority</priority>\n";
  58. $q_i = mysqli_query($con, "SELECT image FROM post_image WHERE post = $row_post[id] ORDER BY idx;");
  59. while ($r_i = mysqli_fetch_array($q_i)){
  60. echo("\t\t<image:image>\n");
  61. echo("\t\t\t<image:loc>http://$http_host/img/blog/view/$r_i[image]</image:loc>\n");
  62. echo("\t\t\t<image:title>$row_post[title_es]</image:title>\n");
  63. echo("\t\t</image:image>\n");
  64. }
  65. echo "\t</url>\n";
  66. $priority = $priority - 0.05;
  67. if ($priority < 0.45)
  68. $priority = 0.45;
  69. }
  70. ?>
  71. <url>
  72. <loc>http://<?php echo $http_host; ?>/actividades/</loc>
  73. <?php
  74. $res_date = mysqli_query($con, "SELECT DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM activity ORDER BY cdate DESC LIMIT 1;");
  75. $row_date = mysqli_fetch_array($res_date);
  76. ?><lastmod><?php echo $row_date['cdate']; ?></lastmod>
  77. <changefreq>weekly</changefreq>
  78. <priority>1</priority>
  79. </url>
  80. <?php
  81. $res = mysqli_query($con, "SELECT title_es, id, permalink, DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM activity WHERE visible = 1 ORDER BY cdate DESC;");
  82. $priority = 0.95;
  83. while ($row = mysqli_fetch_array($res)){
  84. echo "\t<url>\n";
  85. echo "\t\t<loc>http://$http_host/actividades/$row[permalink]</loc>\n";
  86. echo "\t\t<lastmod>$row[cdate]</lastmod>\n";
  87. echo "\t\t<changefreq>weekly</changefreq>\n";
  88. echo "\t\t<priority>$priority</priority>\n";
  89. $q_i = mysqli_query($con, "SELECT image FROM activity_image WHERE activity = $row[id] ORDER BY idx;");
  90. while ($r_i = mysqli_fetch_array($q_i)){
  91. echo("\t\t<image:image>\n");
  92. echo("\t\t\t<image:loc>http://$http_host/img/actividades/view/$r_i[image]</image:loc>\n");
  93. echo("\t\t\t<image:title>$row[title_es]</image:title>\n");
  94. echo("\t\t</image:image>\n");
  95. }
  96. echo "\t</url>\n";
  97. $priority = $priority - 0.05;
  98. if ($priority < 0.65)
  99. $priority = 0.65;
  100. }
  101. ?>
  102. <url>
  103. <loc>http://<?php echo $http_host; ?>/galeria/</loc>
  104. <?php
  105. $res_date = mysqli_query($con, "SELECT DATE_FORMAT(uploaded, '%Y-%m-%d') AS cdate FROM photo ORDER BY cdate DESC LIMIT 1;");
  106. $row_date = mysqli_fetch_array($res_date);
  107. ?><lastmod><?php echo $row_date['cdate']; ?></lastmod>
  108. <changefreq>weekly</changefreq>
  109. <priority>0.8</priority>
  110. </url>
  111. <?php
  112. $res = mysqli_query($con, "SELECT DISTINCT album.id AS albumid, album.title_es AS title, album.permalink AS permalink, DATE_FORMAT(uploaded, '%Y-%m-%d') AS cdate FROM photo, album, photo_album WHERE photo = photo.id AND album = album.id ORDER BY cdate DESC;");
  113. $priority = 0.75;
  114. while ($row = mysqli_fetch_array($res)){
  115. echo "\t<url>\n";
  116. echo "\t\t<loc>http://$http_host/galeria/$row[permalink]</loc>\n";
  117. echo "\t\t<lastmod>$row[cdate]</lastmod>\n";
  118. echo "\t\t<changefreq>weekly</changefreq>\n";
  119. echo "\t\t<priority>$priority</priority>\n";
  120. $q_i = mysqli_query($con, "SELECT file, title_es FROM photo, photo_album WHERE id = photo AND album = $row[albumid];");
  121. while ($r_i = mysqli_fetch_array($q_i)){
  122. echo("\t\t<image:image>\n");
  123. echo("\t\t\t<image:loc>http://$http_host/img/galeria/view/$r_i[file]</image:loc>\n");
  124. if (strlen($r_i['title_es']) > 0){
  125. echo("\t\t\t<image:title>$r_i[title_es]</image:title>\n");
  126. }
  127. else{
  128. echo("\t\t\t<image:title>$row[title]</image:title>\n");
  129. }
  130. echo("\t\t</image:image>\n");
  131. }
  132. echo "\t</url>\n";
  133. $priority = $priority - 0.05;
  134. if ($priority < 0.45)
  135. $priority = 0.45;
  136. }
  137. ?>
  138. <url>
  139. <loc>http://<?php echo $http_host; ?>/lablanca/</loc>
  140. <?php
  141. $res_lb = mysqli_query($con, 'SELECT value FROM settings WHERE name= "festivals";');
  142. if (mysqli_num_rows($res_lb) > 0){
  143. $r_lb = mysqli_fetch_array($res_lb);
  144. if ($r_lb['value'] == 1){
  145. echo "<changefreq>daily</changefreq>\n";
  146. echo "\t\t<priority>1</priority>\n";
  147. }
  148. else{
  149. echo "<changefreq>monthly</changefreq>\n";
  150. echo "\t\t<priority>0.5</priority>\n";
  151. }
  152. }
  153. else{
  154. echo "<changefreq>monthly</changefreq>\n";
  155. echo "\t\t<priority>0.5</priority>\n";
  156. }
  157. ?>
  158. </url>
  159. <?php
  160. $year = date("Y");
  161. $res_years = mysqli_query($con, "SELECT img, year FROM festival ORDER BY year DESC;");
  162. $priority = 0.55;
  163. while ($row_years = mysqli_fetch_array($res_years)){
  164. echo "\t<url>\n";
  165. echo "\t\t<loc>http://$http_host/lablanca/$row_years[year]</loc>\n";
  166. echo "\t\t<changefreq>yearly</changefreq>\n";
  167. echo "\t\t<priority>$priority</priority>\n";
  168. if (strlen($row_years['img']) > 0){
  169. echo("\t\t<image:image>\n");
  170. echo("\t\t\t<image:loc>http://$http_host/img/fiestas/view/$row_years[img]</image:loc>\n");
  171. echo("\t\t\t<image:title>La Blanca $row_years[year]</image:title>\n");
  172. echo("\t\t</image:image>\n");
  173. }
  174. echo "\t</url>\n";
  175. $priority = $priority - 0.05;
  176. if ($priority < 0.40)
  177. $priority = 0.40;
  178. }
  179. ?>
  180. </urlset>