sitemap.php 8.4 KB

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