Преглед изворни кода

Merge branch 'V3_WEB' into V3

Iñigo Valentin пре 9 година
родитељ
комит
62080534a9

+ 1 - 2
.gitignore

@@ -22,9 +22,8 @@ www-admin/redirect_s.php
 
 #SQL data
 sql/dbusers.sql
-sql/rows-test.sql
-sql/rows.sql
 sql/*201*
+sql/*row*.sql
 
 #Passwords file
 www/.htpasswd

+ 22 - 34
www/.htaccess

@@ -21,39 +21,27 @@ RewriteRule ^sitemap.xml$ /sitemap.php [NC]
 RewriteRule ^imgmap.xml$ /sitemap-image.php [NC]
 RewriteRule ^rss.xml$ /rss.php [NC]
 
-RewriteRule ^blog/buscar/([A-Za-z0-9]+)/([A-Za-z0-9]+)$ /blog/buscar.php?where=$1&query=$2 [NC]
-RewriteRule ^blog/buscar/([A-Za-z0-9]+)/([A-Za-z0-9]+)/$ /blog/buscar.php?where=$1&query=$2 [NC]
-RewriteRule ^blog/([A-Z\-a-z0-9]{3,}+)$ /blog/post.php?perm=$1 [NC]
-RewriteRule ^blog/([A-Z\-a-z0-9]{3,}+)/$ /blog/post.php?perm=$1 [NC]
-RewriteRule ^blog/([0-9]+)$ /blog/index.php?o=$1 [NC]
-RewriteRule ^blog/([0-9]+)/$ /blog/index.php?o=$1 [NC]
-
-RewriteRule ^lablanca/([0-9]+)$ /lablanca/index.php?year=$1 [NC]
-
-RewriteRule ^archivo/([A-Z\-a-z0-9]{3,}+)$ /archivo/index.php?file=$1 [NC]
-RewriteRule ^archivo/([A-Z\-a-z0-9]{3,}+)/$ /archivo/index.php?file=$1 [NC]
-
-RewriteRule ^actividades/search/([A-Za-z0-9]+)/([A-Za-z0-9]+)$ /actividades/buscar.php?where=$1&query=$2 [NC]
-RewriteRule ^actividades/search/([A-Za-z0-9]+)/([A-Za-z0-9]+)/$ /actividades/buscar.php?where=$1&query=$2 [NC]
-RewriteRule ^actividades/([A-Z\-a-z0-9{3,}]+)$ /actividades/actividad.php?perm=$1 [NC]
-RewriteRule ^actividades/([A-Z\-a-z0-9{3,}]+)/$ /actividades/actividad.php?perm=$1 [NC]
-RewriteRule ^actividades/([0-9]+)$ /actividades/index.php?o=$1 [NC]
-RewriteRule ^actividades/([0-9]+)/$ /actividades/index.php?o=$1 [NC]
-
-RewriteRule ^ayuda$ /ayuda/index.php [NC]
-RewriteRule ^ayuda/$ /ayuda/index.php [NC]
-
-RewriteRule ^galeria/upload$ /galeria/upload.php [NC]
-RewriteRule ^galeria/upload/$ /galeria/upload.php [NC]
-RewriteRule ^galeria/([A-Z\-a-z0-9{3,}]+)$ /galeria/album.php?perm=$1 [NC]
-RewriteRule ^galeria/([A-Z\-a-z0-9{3,}]+)/$ /galeria/album.php?perm=$1 [NC]
-RewriteRule ^galeria/([A-Z\-a-z0-9{3,}]+)/([A-Z\-a-z0-9{3,}]+)$ /galeria/photo.php?album=$2&perm=$1 [NC]
-RewriteRule ^galeria/([A-Z\-a-z0-9{3,}]+)/([A-Z\-a-z0-9{3,}]+)/$ /galeria/photo.php?album=$2&perm=$1 [NC]
-
-RewriteRule ^traducir/eu$ /traducir/index.php?l=eu [NC]
-RewriteRule ^traducir/eu/$ /traducir/index.php?l=eu [NC]
-RewriteRule ^traducir/en$ /traducir/index.php?l=en [NC]
-RewriteRule ^traducir/en/$ /traducir/index.php?l=en [NC]
+RewriteRule ^blog/buscar/([A-Za-z0-9]+)/([A-Za-z0-9]+)[\/]?$ /blog/buscar.php?where=$1&query=$2 [NC]
+RewriteRule ^blog/([A-Z\-a-z0-9]{3,}+)[\/]?$ /blog/post.php?perm=$1 [NC]
+
+RewriteRule ^lablanca/([0-9]+)[\/]?$ /lablanca/index.php?year=$1 [NC]
+RewriteRule ^lablanca/programa[\/]?$ /lablanca/programa.php?gm=1 [NC]
+RewriteRule ^lablanca/programa/([A-Za-z]+)[\/]?$ /lablanca/programa.php?gm=$1 [NC]
+RewriteRule ^lablanca/programa/([A-Za-z]+)/([0-9]+)[\/]?$ /lablanca/programa.php?gm=$1&year=$2 [NC]
+
+RewriteRule ^archivo/([A-Z\-a-z0-9]{3,}+)[\/]?$ /archivo/index.php?file=$1 [NC]
+
+RewriteRule ^actividades/search/([A-Za-z0-9]+)/([A-Za-z0-9]+)[\/]?$ /actividades/buscar.php?where=$1&query=$2 [NC]
+RewriteRule ^actividades/([A-Z\-a-z0-9{3,}]+)[\/]?$ /actividades/actividad.php?perm=$1 [NC]
+
+RewriteRule ^ayuda[\/]?$ /ayuda/index.php [NC]
+
+RewriteRule ^galeria/upload[\/]?$ /galeria/upload.php [NC]
+RewriteRule ^galeria/([A-Z\-a-z0-9{3,}]+)[\/]?$ /galeria/album.php?perm=$1 [NC]
+RewriteRule ^galeria/([A-Z\-a-z0-9{3,}]+)/([A-Z\-a-z0-9{3,}]+)[\/]?$ /galeria/photo.php?album=$2&perm=$1 [NC]
+
+RewriteRule ^traducir/eu[\/]?$ /traducir/index.php?l=eu [NC]
+RewriteRule ^traducir/en[\/]?$ /traducir/index.php?l=en [NC]
 
 #API redirections
 #TODO: This changes the url in the browser
@@ -112,5 +100,5 @@ RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
 # Limit the size of the cache to 1 Megabyte
 #MCacheSize 1024
 
-#CacheFile footer.php toolbar.php img/*/* project/*/render/* project/*/render/*/preview/* project/*/render/*/miniature/*
+#CacheFile footer.php header.php img/*/*/*.jpg 
 

+ 138 - 102
www/blog/buscar.php

@@ -1,37 +1,37 @@
 <?php
     session_start();
-    $http_host = $_SERVER['HTTP_HOST'];
+    $http_host = $_SERVER["HTTP_HOST"];
     include("../functions.php");
     $con = startdb();
     $proto = getProtocol();
+    $server = "$server";
     
     //Language
     $lang = selectLanguage();
-    include("../lang/lang_" . $lang . ".php");
+    include("../lang/lang_$lang.php");
     
-    $cur_section = $lng['section_blog'];
+    $cur_section = $lng["section_blog"];
     
     //Search terms
-    $search_field = mysqli_real_escape_string($con, $_GET['where']);
-    $search_term = strtolower(mysqli_real_escape_string($con, $_GET['query']));
-    if ($search_field == '' || $search_term == ''){
-        header("Location: $proto$http_host/blog/");
+    $search_field = mysqli_real_escape_string($con, $_GET["where"]);
+    $search_term = strtolower(mysqli_real_escape_string($con, $_GET["query"]));
+    if ($search_field == "" || $search_term == ""){
+        header("Location: $server/blog/");
         exit(-1);
     }
     
     //Get matches
     switch ($search_field){
-        case $lng['search_field_all']:
+        case $lng["search_field_all"]:
             $q = mysqli_query($con, "SELECT id, permalink, title_$lang AS title, text_$lang AS text, DATE_FORMAT(dtime, '%Y-%m-%dT%T') AS isodate, dtime, comments FROM post WHERE lower(title_es) LIKE '%$search_term%' OR lower(text_es) LIKE '%$search_term%' OR id IN (SELECT post FROM post_tag WHERE lower(tag) LIKE '%$search_term%') ORDER BY dtime DESC;");
             break;
-        case $lng['search_field_tag']:
+        case $lng["search_field_tag"]:
             $q = mysqli_query($con, "SELECT id, permalink, title_$lang AS title, text_$lang AS text, DATE_FORMAT(dtime, '%Y-%m-%dT%T') AS isodate, dtime, comments FROM post WHERE id IN (SELECT post FROM post_tag WHERE tag like '$search_term') ORDER BY dtime DESC;");
             break;
         default:
-            header("Location: $proto$http_host/blog/");
+            header("Location: $server/blog/");
             exit(-1);
     }
-    
 ?>
 <!DOCTYPE html>
 <html>
@@ -39,21 +39,21 @@
         <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
         <meta charset="utf-8"/>
         <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-        <title><?php echo $lng['blog_title'];?> - Gasteizko Margolariak</title>
-        <link rel="shortcut icon" href="<?php echo "$proto$http_host/img/logo/favicon.ico";?>">
+        <title><?=$lng["blog_title"]?> - Gasteizko Margolariak</title>
+        <link rel="shortcut icon" href="<?=$server?>/img/logo/favicon.ico">
         <!-- CSS files -->
         <style>
-            <?php 
-                include("../css/ui.css"); 
-                include("../css/blog.css");
-            ?>
+<?php 
+            include("../css/ui.css"); 
+            include("../css/blog.css");
+?>
         </style>
         <!-- CSS for mobile version -->
         <style media="(max-width : 990px)">
-            <?php 
-                include("../css/m/ui.css"); 
-                include("../css/m/blog.css");
-            ?>
+<?php 
+            include("../css/m/ui.css"); 
+            include("../css/m/blog.css");
+?>
         </style>
         <!-- Script files -->
         <script type="text/javascript">
@@ -63,100 +63,136 @@
             ?>
         </script>
         <!-- Meta tags -->
-        <link rel="canonical" href="<?php echo "$proto$http_host/blog"; ?>"/>
-        <link rel="author" href="<?php echo "$proto$http_host"; ?>"/>
-        <link rel="publisher" href="<?php echo "$proto$http_host"; ?>"/>
-        <meta name="description" content="<?php echo $lng['blog_descrption'];?>"/>
-        <meta property="og:title" content="<?php echo $lng['blog_title'];?> - Gasteizko Margolariak"/>
-        <meta property="og:url" content="<?php echo "$proto$http_host/blog"; ?>"/>
-        <meta property="og:description" content="<?php echo $lng['blog_description'];?>"/>
-        <meta property="og:image" content="<?php echo "$proto$http_host/img/logo/logo.png";?>"/>
-        <meta property="og:site_name" content="<?php echo $lng['index_title'];?>"/>
+        <link rel="canonical" href="<?=$server?>/blog"/>
+        <link rel="author" href="<?=$server?>"/>
+        <link rel="publisher" href="<?=$server?>"/>
+        <meta name="description" content="<?=$lng["blog_descrption"]?>"/>
+        <meta property="og:title" content="<?=$lng["blog_title"]?> - Gasteizko Margolariak"/>
+        <meta property="og:url" content="<?=$server?>/blog"/>
+        <meta property="og:description" content="<?=$lng["blog_description"]?>"/>
+        <meta property="og:image" content="<?=$server?>/img/logo/logo.png"/>
+        <meta property="og:site_name" content="<?=$lng["index_title"]?>"/>
         <meta property="og:type" content="website"/>
-        <meta property="og:locale" content="<?php echo $lang; ?>"/>
+        <meta property="og:locale" content="<?=$lang?>"/>
         <meta name="twitter:card" content="summary"/>
-        <meta name="twitter:title" content="<?php echo $lng['blog_title'];?> - Gasteizko Margolariak"/>
-        <meta name="twitter:description" content="<?php echo $lng['blog_description'];?>"/>
-        <meta name="twitter:image" content="<?php echo "$proto$http_host/img/logo/logo.png";?>"/>
-        <meta name="twitter:url" content="<?php echo"$proto$http_host"; ?>"/>
+        <meta name="twitter:title" content="<?=$lng["blog_title"]?> - Gasteizko Margolariak"/>
+        <meta name="twitter:description" content="<?=$lng["blog_description"]?>"/>
+        <meta name="twitter:image" content="<?=$server?>/img/logo/logo.png"/>
+        <meta name="twitter:url" content="<?=$server?>"/>
         <meta name="robots" content="no-index no-follow"/>
     </head>
     <body>
-        <?php include("../header.php"); ?>
+<?php
+        include("../header.php");
+?>
         <div id="content">
-            <?php include("common/leftpanel.php"); ?>
+<?=
+            include("common/leftpanel.php");
+?>
             <div id="middle_column">
                 <div class="section">
-                    <h3 class="section_title"><?php echo($lng['blog_search']);?></h3>
+                    <h3 class="section_title"><?=$lng["blog_search"])?></h3>
                     <div class="entry">
-                        <?php
-                            if (mysqli_num_rows($q) == 1){
-                                echo "$lng[blog_search_1]<span class='italic'>$search_term</span>&nbsp: " . strval(mysqli_num_rows($q)) . $lng['blog_search_result'];
-                            }
-                            else{
-                                echo "$lng[blog_search_1]<span class='italic'>$search_term</span>&nbsp: " . strval(mysqli_num_rows($q)) . $lng['blog_search_results'];
-                            }
-                        ?>
-                    </div>
-                    <?php
-                        while($r = mysqli_fetch_array($q)){
-                            echo "<div itemscope itemtype='http://schema.org/BlogPosting' class='entry blog_entry'>\n";
-                            echo "<meta itemprop='inLanguage' content='$lang'/>\n";
-                            echo "<meta itemprop='datePublished dateModified' content='$r[isodate]'/>\n";
-                            echo "<meta itemprop='headline name' content='$r[title]'/>\n";
-                            echo "<meta itemprop='articleBody text' content='$r[text]'/>\n";
-                            echo "<meta itemprop='mainEntityOfPage' content='$proto$http_host'/>\n";
-                            echo "<div class='hidden' itemprop='author publisher' itemscope itemtype='http://schema.org/Organization'>\n";
-                            echo "<meta itemprop='legalName' content='Asociaci&oacute;n Cultural Recreativa Gasteizko Margolariak'/>\n";
-                            echo "<meta itemprop='name' content='Gasteizko Margolariak'/>\n";
-                            echo "<meta itemprop='logo' content='$proto$http_host/img/logo/logo.png'/>\n";
-                            echo "<meta itemprop='foundingDate' content='03-02-2013'/>\n";
-                            echo "<meta itemprop='telephone' content='+34637140371'/>\n";
-                            echo "<meta itemprop='url' content='$proto$http_host'/>\n";
-                            echo "</div>\n";
-                            echo "<h3 class='entry_title post_search_title'><a itemprop='url' href='$proto$http_host/blog/$r[permalink]'>$r[title]</a></h2>\n";
-                            # Tags (if any) and date
-                            echo "<table class='post_footer post_footer_search'><tr>\n";
-                            $q_tag = mysqli_query($con, "SELECT tag FROM post_tag WHERE post= $r[id];");
-                            if (mysqli_num_rows($q_tag) > 0){
-                                $tag_string = "<span class='tags desktop'>Tags: ";
-                                $tag_raw = "";
-                                while ($r_tag = mysqli_fetch_array($q_tag)){
-                                    $tag_string = $tag_string . "<a href='$proto$http_host/blog/buscar/tag/$r_tag[tag]'>$r_tag[tag]</a>, ";
-                                    $tag_raw = $tag_raw . "$r_tag[tag],";
-                                }
-                                $tag_string = substr($tag_string, 0, strlen($tag_string) - 2);
-                                $tag_string = $tag_string . "</span>";
-                                $tag_raw = substr($tag_raw, 0, strlen($tag_raw) - 1);
-                                echo "<meta itemprop='keywords' content='$tag_raw'/>\n";
-                                echo "<td><span class='date'>" . formatDate($r['dtime'], $lang, false) . "</span>&nbsp;&nbsp;&nbsp;$tag_string</td>\n";
-                            }
-                            else{
-                                echo "<td><span class='date'></span>" . formatDate($r['dtime'], $lang) . "</span></td>\n";
-                            }
-                            echo "</tr></table><hr class='post_search_separator'/>\n";
+<?php
+                        if (mysqli_num_rows($q) == 1){
+?>
+                            <?=$lng["blog_search_1"]?>
+                            <span class='italic'><?=$search_term?></span>
+                            &nbsp: <?=strval(mysqli_num_rows($q))?> <?=$lng["blog_search_result"]?>
+<?php
+                        }
+                        else{
+?>
+                            <?=$lng["blog_search_1"]?>
+                            <span class='italic'><?=$search_term?></span>
+                            &nbsp: <?=strval(mysqli_num_rows($q))?> <?=$lng["blog_search_results"]?>
+<?php
+                        }
+?>
+                    </div> <!-- .entry -->
+<?php
+                    while($r = mysqli_fetch_array($q)){
+?>
+                        <div itemscope itemtype='http://schema.org/BlogPosting' class='entry blog_entry'>
+                            <meta itemprop='inLanguage' content='$lang'/>
+                            <meta itemprop='datePublished dateModified' content='<?=$r["isodate"]?>'/>
+                            <meta itemprop='headline name' content='<?=$r["title"]?>'/>
+                            <meta itemprop='articleBody text' content='<?=$r["text"]?>'/>
+                            <meta itemprop='mainEntityOfPage' content='<?=$server?>'/>
+                            <div class='hidden' itemprop='author publisher' itemscope itemtype='http://schema.org/Organization'>
+                                <meta itemprop='legalName' content='Asociaci&oacute;n Cultural Recreativa Gasteizko Margolariak'/>
+                                <meta itemprop='name' content='Gasteizko Margolariak'/>
+                                <meta itemprop='logo' content='<?=$server?>/img/logo/logo.png'/>
+                                <meta itemprop='foundingDate' content='03-02-2013'/>
+                                <meta itemprop='telephone' content='+34637140371'/>
+                                <meta itemprop='url' content='<?=$server?>'/>
+                            </div>
+                            <h3 class='entry_title post_search_title'>
+                                <a itemprop='url' href='<?=$server?>/blog/<?=$r["permalink"]?>'><?=$r["title"]?></a>
+                            </h3>
+                            <table class='post_footer post_footer_search'>
+                                <tr>
+<?php
+                                    # Tags (if any) and date
+                                    $q_tag = mysqli_query($con, "SELECT tag FROM post_tag WHERE post= $r[id];");
+                                    if (mysqli_num_rows($q_tag) > 0){
+                                        $tag_string = "<span class='tags desktop'>Tags: ";
+                                        $tag_raw = "";
+                                        while ($r_tag = mysqli_fetch_array($q_tag)){
+                                            $tag_string = $tag_string . "<a href='$server/blog/buscar/tag/$r_tag[tag]'>$r_tag[tag]</a>, ";
+                                            $tag_raw = $tag_raw . "$r_tag[tag],";
+                                        }
+                                        $tag_string = substr($tag_string, 0, strlen($tag_string) - 2);
+                                        $tag_string = $tag_string . "</span>";
+                                        $tag_raw = substr($tag_raw, 0, strlen($tag_raw) - 1);
+?>
+                                        <meta itemprop='keywords' content='<?=$tag_raw?>'/>
+                                        <td>
+                                            <span class='date'><?=formatDate($r["dtime"], $lang, false)?></span>
+                                            &nbsp;&nbsp;&nbsp;<?=$tag_string?>
+                                        </td>
+<?php
+                                    }
+                                    else{
+?>
+                                        <td>
+                                            <span class='date'><?=formatDate($r["dtime"], $lang)?></span>
+                                        </td>
+<?php
+                                    }
+?>
+                                </tr>
+                            </table> <!-- .post_footer_search -->
+                            <hr class='post_search_separator'/>
+<?php
                             #Image and text
                             $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $r[id] ORDER BY idx LIMIT 1;");
                             if (mysqli_num_rows($q_image) > 0){
                                 $r_image = mysqli_fetch_array($q_image);
-                                echo "<a href='$proto$http_host/blog/$r[permalink]'>\n";
-                                echo "<meta itemprop='image' content='$proto$http_host/img/blog/$r_image[image]'/>\n";
-                                echo "<img class='post_search_image alt='$r[title]' src='$proto$http_host/img/blog/preview/$r_image[image]'/>\n";
-                                echo "</a>\n";
+?>
+                                <a href='<?=$server?>/blog/<?=$r["permalink"]?>'>
+                                    <meta itemprop='image' content='<?=$server?>/img/blog/<?=$r_image["image"]?>'/>
+                                    <img class='post_search_image alt='<?=$r["title"]?>' src='<?=$server?>/img/blog/preview/<?=$r_image["image"]?>'/>
+                                </a>
+<?php
                             }
-                            echo "<p class='post_search_text'>" . cutText($r['text'], 150, $lng['blog_read_more'], "$proto$http_host/blog/$r[permalink]/") . "</p>\n";
-                            echo "<br/>\n";
-                            echo "</div>\n";
-                        }
-                    ?>
-                </div>
-            </div>
-            <?php include("common/rightpanel.php"); ?>
-        </div>
-        <?php
-            include("../footer.php");
-            $ad = ad($con, $lang, $lng); 
-            stats($ad, $ad_static, "blog", "");
-        ?>
+?>
+                            <p class='post_search_text'><?=cutText($r["text"], 150, $lng["blog_read_more"], "$server/blog/$r[permalink]/")?></p>
+                            <br/>
+                        </div> <!-- .blog_entry-->
+<?php
+                    } //  while($r = mysqli_fetch_array($q))
+?>
+                </div> <!-- .section -->
+            </div> <!-- #middle_column -->
+<?php
+            include("common/rightpanel.php");
+?>
+        </div> <!-- #content -->
+<?php
+        include("../footer.php");
+        $ad = ad($con, $lang, $lng); 
+        stats($ad, $ad_static, "blog", "");
+?>
     </body>
 </html>

+ 21 - 21
www/blog/comment.php

@@ -1,9 +1,11 @@
 <?php
-    
-    $http_host = $_SERVER['HTTP_HOST'];
+
+    $http_host = $_SERVER["HTTP_HOST"];
     include("../functions.php");
-    $con = startdb('rw');
-    
+    $con = startdb("rw");
+    $proto = getProtocol();
+    $server = "$proto$http_host";
+
     //Get post values
     $from =mysqli_real_escape_string($con, $_POST["from"]);
     $post = mysqli_real_escape_string($con, $_POST["post"]);
@@ -19,52 +21,50 @@
         http_response_code(405);
         exit(-1);
     }
-    
+
     //Check language, set fallback.
     if ($lang != 'es' && $lang != 'en' && $lang != 'eu'){
         $lang = 'es';
     }
-    
+
     //Chack for null fields
     if (strlen($user) <= 0 || strlen($text) <= 0){
         error_log("Tried to post a comment with null text or user on post. USER: '$user', TEXT: '$text'");
         http_response_code(405);
         exit(-1);
     }
-    
+
     if ($from == 'web'){
         //Format newlines in text
         $text = str_replace(["\r\n", "\r", "\n"], "<br/>", $text);
-        
+
         //Get visit
         $ip = getUserIP();
         $visit = '';
         $q = mysqli_query($con, "SELECT id FROM stat_visit WHERE ip = '$ip';");
         if (mysqli_num_rows($q) > 0){
             $r = mysqli_fetch_array($q);
-            $visit = $r['id'];
+            $visit = $r["id"];
         }
-        
+
         //Insert row
         mysqli_query($con, "INSERT INTO post_comment (post, text, username, lang, visit) VALUES ($post, '$text', '$user', '$lang', '$visit');");
-        version();
     }
     elseif ($from == 'app'){
         $code = mysqli_real_escape_string($con, $_POST["code"]);
         mysqli_query($con, "INSERT INTO post_comment (post, text, username, lang, app) VALUES ($post, '$text', '$user', '$lang', '$code');");
-        version();
     }
-    
+
     //Prepare the page to update the comment section
-    //WARNING: If changes are done here, do the same in post.php
     $q_comment = mysqli_query($con, "SELECT id, post, DATE_FORMAT(dtime, '%Y-%m-%dT%T') AS isodate, dtime, user, username, lang, text FROM post_comment WHERE post = $post AND approved = 1 ORDER BY dtime;");
     while ($r_comment = mysqli_fetch_array($q_comment)){
-        echo "<div itemprop='comment' itemscope itemtype='http://schema.org/UserComments' id='comment_$r_comment[id]' class='comment'>\n";
-        //When official users are implementes, see if there is user or username
-        echo "<span itemprop='creator' class='comment_user'>$r_comment[username]</span>\n";
-        echo "<span class='comment_date date'><meta itemprop='commentTime' content='$r_comment[isodate]'/>" . formatDate($r_comment['dtime'], $lang) . "</span>\n";
-        echo "<p itemprop='commentText' class='comment_text'>$r_comment[text]</p>";
-        echo "<hr class='comment_line'/>\n";
-        echo "</div>\n";
+?>
+        <div itemprop='comment' itemscope itemtype='http://schema.org/UserComments' id='comment_<?=$r_comment["id"]?>' class='comment'>
+            <span itemprop='creator' class='comment_user'><?=$r_comment["username"]?></span>
+            <span class='comment_date date'><meta itemprop='commentTime' content='<?=$r_comment["isodate"]?>'/><?=formatDate(<?=$r_comment["dtime"], $lang)?></span>
+            <p itemprop='commentText' class='comment_text'><?=$r_comment["text"]?></p>
+            <hr class='comment_line'/>
+        </div>
+<?php
     }
 ?>

+ 18 - 14
www/blog/common/leftpanel.php

@@ -1,27 +1,31 @@
-<div id="left_column">
-    <div id="search_panel" class="section">
-        <h3 id="search_panel_header" class="section_title search_element no_mobile"><?php echo $lng['blog_search'];?></h3>
-        <div class="entry" id="search_panel_inputs">
-            <form action="#" onSubmit="event.preventDefault();launchSearch('<?php echo $lng['search_field_all']; ?>');">
-                <input id="search_panel_input" class="search_element" type="text" name="query" placeholder="<?php echo($lng['blog_search']); ?>"/>
-                <input id="search_panel_submit" class="search_element" type="submit" value="<?php echo $lng['blog_search'];?>"/>
+<div id='left_column'>
+    <div id='search_panel' class='section'>
+        <h3 id='search_panel_header' class='section_title search_element no_mobile'><?=$lng["blog_search"]?></h3>
+        <div class='entry' id='search_panel_inputs'>
+            <form action='#' onSubmit='event.preventDefault();launchSearch("<?=$lng["search_field_all"]?>");'>
+                <input id='search_panel_input' class='search_element' type='text' name='query' placeholder='<?=$lng["blog_search"]?>'/>
+                <input id='search_panel_submit' class='search_element' type='submit' value='<?=$lng["blog_search"]?>'/>
             </form>
         </div>
     </div>
-    <div id="tag_cloud" class="section desktop">
-        <h3 class="section_title"><?php echo $lng['blog_tag_cloud'];?></h3>
-        <div class="entry">
+    <div id='tag_cloud' class='section desktop'>
+        <h3 class='section_title'><?=$lng["blog_tag_cloud"]?></h3>
+        <div class='entry'>
             <?php
                 //Get the most used tag
                 $q_max = mysqli_query($con, "SELECT max(count) AS max FROM (SELECT count(post) AS count FROM post_tag GROUP BY tag) AS t;");
                 $r_max = mysqli_fetch_array($q_max);
-                $max = $r_max['max'];
+                $max = $r_max["max"];
                 $q_tag = mysqli_query($con, "SELECT tag, count(post) AS count FROM post_tag GROUP BY tag;");
                 while($r_tag = mysqli_fetch_array($q_tag)){
-                    $size = round(60 + 100 * $r_tag['count'] / $max);    //TEST: Relativize
-                    echo "<a href='$proto$http_host/blog/buscar/tag/$r_tag[tag]'><span style='font-size: $size%'>$r_tag[tag]</span></a>\n";
+                    $size = round(60 + 100 * $r_tag['count'] / $max);
+?>
+                    <a href='<?=$server?>/blog/buscar/tag/<?=$r_tag["tag"]?>'>
+                        <span style='font-size: <?=$size?>%'><?=$r_tag["tag"]?></span>
+                    </a>
+<?php
                 }
-            ?>
+?>
         </div>
     </div>
 </div>

+ 37 - 22
www/blog/common/rightpanel.php

@@ -1,28 +1,43 @@
 <div id="right_column">
     <div id="archive" class="section desktop">
-        <h3 class="section_title"><?php echo $lng['blog_archive']; ?></h3>
+        <h3 class="section_title"><?=$lng["blog_archive"]?></h3>
         <div class='entry'>
-            <?php
-                $q_year = mysqli_query($con, "SELECT year(dtime) AS year FROM post WHERE visible = 1 GROUP BY year(dtime) ORDER BY year DESC;");
-                while($r_year = mysqli_fetch_array($q_year)){
-                    echo "<div class='year pointer' onClick=\"toggleElement('year_$r_year[year]');\">";
-                    echo ("<img class='slid' id='slid_year_$r_year[year]' src='$proto$http_host/img/misc/slid-right.png' alt=' '/><span class='fake_a'>$r_year[year]</span>");
-                    echo "</div>\n";
-                    echo "<div class='list_year pointer' id='list_year_$r_year[year]'>\n";
+<?php
+            $q_year = mysqli_query($con, "SELECT year(dtime) AS year FROM post WHERE visible = 1 GROUP BY year(dtime) ORDER BY year DESC;");
+            while($r_year = mysqli_fetch_array($q_year)){
+?>
+                <div class='year pointer' onClick='toggleElement("year_<?=$r_year["year"]?>");'>
+                    <img class='slid' id='slid_year_<?=$r_year["year"]?>' src='<?=$server?>/img/misc/slid-right.png' alt='<?=$r_year["year"]?>'/>
+                    <span class='fake_a'><?=$r_year["year"]?></span>
+                </div>
+                <div class='list_year pointer' id='list_year_<?=$r_year["year"]?>'>
+<?php
                     $q_month = mysqli_query($con, "SELECT month(dtime) AS month FROM post WHERE visible = 1 AND year(dtime) = $r_year[year] GROUP BY month(dtime) ORDER BY month DESC;");
                     while($r_month = mysqli_fetch_array($q_month)){
-                        echo "<div class='month pointer' onClick=\"toggleElement('month_$r_year[year]_$r_month[month]');\">";
-                        echo ("<img class='slid' id='slid_month_$r_year[year]_$r_month[month]' src='$proto$http_host/img/misc/slid-right.png' alt=' '/><span class='fake_a'>" . $lng['months'][$r_month['month'] - 1] . "</span>");
-                        echo "</div>\n";
-                        echo "<ul id='list_month_$r_year[year]_$r_month[month]' class='post_list'>\n";
-                        $q_title = mysqli_query($con, "SELECT id, permalink, title_$lang AS title FROM post WHERE visible = 1 AND year(dtime) = $r_year[year] AND month(dtime) = '$r_month[month]' ORDER BY dtime DESC;");
-                        while($r_title = mysqli_fetch_array($q_title))
-                            echo "<li><a href='$proto$http_host/blog/" . $r_title['permalink']  . "'>$r_title[title]</a></li>\n";
-                        echo "</ul>\n";
+?>
+                        <div class='month pointer' onClick='toggleElement("month_<?=$r_year["year"]?>_<?=$r_month["month"]?>");'>
+                            <img class='slid' id='slid_month_<?=$r_year["year"]?>_<?=$r_month["month"]?>' src='<?=$server?>?/img/misc/slid-right.png' alt='<?=$r_month["month"]?>'/>
+                            <span class='fake_a'><?=$lng["months"][$r_month["month"] - 1]?></span>
+                        </div>
+                        <ul id='list_month_<?=$r_year["year"]?>_<?=$r_month["month"]?>' class='post_list'>
+<?php
+                            $q_title = mysqli_query($con, "SELECT id, permalink, title_$lang AS title FROM post WHERE visible = 1 AND year(dtime) = $r_year[year] AND month(dtime) = '$r_month[month]' ORDER BY dtime DESC;");
+                            while($r_title = mysqli_fetch_array($q_title)){
+?>
+                                <li>
+                                    <a href='$proto$http_host/blog/<?=$r_title["permalink"]?>'><?=$r_title["title"]?></a>
+                                </li>
+<?php
+                            }
+?>
+                        </ul>
+<?php
                     }
-                    echo "</div>\n";
-                }
-            ?>
-        </div>
-    </div>
-</div>
+?>
+                </div> <!-- #list_year_<?=$r_year["year"]?> -->
+<?php
+            } //while($r_year = mysqli_fetch_array($q_year))
+?>
+        </div> <!-- .entry -->
+    </div> <!-- #archive -->
+</div> <!-- #right_column-->

+ 137 - 125
www/blog/index.php

@@ -4,12 +4,13 @@
     include("../functions.php");
     $con = startdb();
     $proto = getProtocol();
-    
+    $server = "$proto$http_host";
+
     //Language
     $lang = selectLanguage();
-    include("../lang/lang_" . $lang . ".php");
-    
-    $cur_section = $lng['section_blog'];
+    include("../lang/lang_$lang.php");
+
+    $cur_section = $lng["section_blog"];
 ?>
 <!DOCTYPE html>
 <html>
@@ -17,152 +18,163 @@
         <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
         <meta charset="utf-8"/>
         <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-        <title><?php echo $lng['blog_title'];?> - Gasteizko Margolariak</title>
-        <link rel="shortcut icon" href="<?php echo "$proto$http_host/img/logo/favicon.ico";?>">
+        <title><?=$lng["blog_title"];?> - Gasteizko Margolariak</title>
+        <link rel="shortcut icon" href="<?=$server?>/img/logo/favicon.ico">
         <!-- CSS files -->
         <style>
-            <?php 
-                include("../css/ui.css"); 
-                include("../css/blog.css");
-            ?>
+<?php
+            include("../css/ui.css");
+            include("../css/blog.css");
+?>
         </style>
         <!-- CSS for mobile version -->
         <style media="(max-width : 990px)">
-            <?php 
-                include("../css/m/ui.css"); 
-                include("../css/m/blog.css");
-            ?>
+<?php
+            include("../css/m/ui.css"); 
+            include("../css/m/blog.css");
+?>
         </style>
         <!-- Script files -->
         <script type="text/javascript">
-            <?php
+<?php
                 include("../script/ui.js");
                 include("../script/blog.js");
-            ?>
+?>
         </script>
         <!-- Meta tags -->
-        <link rel="canonical" href="<?php echo "$proto$http_host/blog"; ?>"/>
-        <link rel="author" href="<?php echo "$proto$http_host"; ?>"/>
-        <link rel="publisher" href="<?php echo "$proto$http_host"; ?>"/>
-        <meta name="description" content="<?php echo $lng['blog_descrption'];?>"/>
-        <meta property="og:title" content="<?php echo $lng['blog_title'];?> - Gasteizko Margolariak"/>
-        <meta property="og:url" content="<?php echo "$proto$http_host/blog"; ?>"/>
-        <meta property="og:description" content="<?php echo $lng['blog_description'];?>"/>
-        <meta property="og:image" content="<?php echo "$proto$http_host/img/logo/logo.png";?>"/>
-        <meta property="og:site_name" content="<?php echo $lng['index_title'];?>"/>
+        <link rel="canonical" href="<?=$server?>/blog/">
+        <link rel="author" href="<?=$server?>"/>
+        <link rel="publisher" href="<?=$server?>"/>
+        <meta name="description" content="<?=$lng["blog_descrption"]?>"/>
+        <meta property="og:title" content="<?=$lng["blog_title"]?> - Gasteizko Margolariak"/>
+        <meta property="og:url" content="<?=$server?>/blog/">
+        <meta property="og:description" content="<?=$lng["blog_description"]?>"/>
+        <meta property="og:image" content="<?=$server?>/img/logo/logo.png";?>"/>
+        <meta property="og:site_name" content="<?=$lng["index_title"]?>"/>
         <meta property="og:type" content="website"/>
         <meta property="og:locale" content="<?php echo $lang; ?>"/>
         <meta name="twitter:card" content="summary"/>
-        <meta name="twitter:title" content="<?php echo $lng['blog_title'];?> - Gasteizko Margolariak"/>
-        <meta name="twitter:description" content="<?php echo $lng['blog_description'];?>"/>
-        <meta name="twitter:image" content="<?php echo "$proto$http_host/img/logo/logo.png";?>"/>
-        <meta name="twitter:url" content="<?php echo"$proto$http_host"; ?>"/>
+        <meta name="twitter:title" content="<?=$lng["blog_title"]?> - Gasteizko Margolariak"/>
+        <meta name="twitter:description" content="<?=$lng["blog_description"]?>"/>
+        <meta name="twitter:image" content="<?=$server?>/img/logo/logo.png";?>"/>
+        <meta name="twitter:url" content="<?=$server?>"/>
         <meta name="robots" content="index follow"/>
     </head>
     <body>
-        <?php include("../header.php"); ?>
+<?php include("../header.php"); ?>
         <div id="content">
-            <?php include("common/leftpanel.php"); ?>
+<?php include("common/leftpanel.php"); ?>
             <div id="middle_column" class="section">
-                <?php
-                    echo("<h3 class='section_title'>$lng[section_blog]</h3>\n");
-                    $offset = (int) $_GET['o'];
-                    $q = mysqli_query($con, "SELECT id, permalink, title_$lang AS title, text_$lang AS text, DATE_FORMAT(dtime, '%Y-%m-%dT%T') AS isodate, dtime, comments FROM post WHERE visible = 1 ORDER BY dtime DESC LIMIT 5 OFFSET $offset;");
+                <h3 class='section_title'><?=$lng["section_blog"]?></h3>
+<?php
+                    $q = mysqli_query($con, "SELECT id, permalink, title_$lang AS title, text_$lang AS text, DATE_FORMAT(dtime, '%Y-%m-%dT%T') AS isodate, dtime, comments FROM post WHERE visible = 1 ORDER BY dtime DESC;");
                     while($r = mysqli_fetch_array($q)){
-                        echo "<div itemscope itemtype='http://schema.org/BlogPosting' class='entry blog_entry'>\n";
-                        echo "<meta itemprop='inLanguage' content='$lang'/>\n";
-                        echo "<meta itemprop='datePublished dateModified' content='$r[isodate]'/>\n";
-                        echo "<meta itemprop='headline name' content='$r[title]'/>\n";
-                        echo "<meta itemprop='articleBody text' content='$r[text]'/>\n";
-                        echo "<meta itemprop='mainEntityOfPage' content='$proto$http_host'/>\n";
-                        echo "<div class='hidden' itemprop='author publisher' itemscope itemtype='http://schema.org/Organization'>\n";
-                        echo "<meta itemprop='legalName' content='Asociaci&oacute;n Cultural Recreativa Gasteizko Margolariak'/>\n";
-                        echo "<meta itemprop='name' content='Gasteizko Margolariak'/>\n";
-                        echo "<meta itemprop='logo' content='$proto$http_host/img/logo/logo.png'/>\n";
-                        echo "<meta itemprop='foundingDate' content='03-02-2013'/>\n";
-                        echo "<meta itemprop='telephone' content='+34637140371'/>\n";
-                        echo "<meta itemprop='url' content='$proto$http_host'/>\n";
-                        echo "</div>\n";
-                        echo "<h3 class='entry_title'><a itemprop='url' href='$proto$http_host/blog/$r[permalink]'>$r[title]</a></h2>\n";
-                        $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $r[id] ORDER BY idx LIMIT 1;");
-                        if (mysqli_num_rows($q_image) > 0){
-                            $r_image = mysqli_fetch_array($q_image);
-                            echo "<div class='post_list_image_container'>\n";
-                            echo "<a href='$proto$http_host/blog/$r[permalink]'>\n";
-                            echo "<meta itemprop='image' content='$proto$http_host/img/blog/view/$r_image[image]'/>\n";
-                            echo "<img class='post_list_image alt='$r[title]' src='$proto$http_host/img/blog/miniature/$r_image[image]'/>\n";
-                            echo "</a>\n";
-                            echo "</div>\n";
-                        }
-                        echo "<p>" . cutText($r['text'], 800, $lng['blog_read_more'], "$proto$http_host/blog/$r[permalink]/") . "</p>\n";
-                        # Tags (if any), date, and comment counter
-                        echo "<hr><table class='post_footer'><tr>\n";
-                        $q_tag = mysqli_query($con, "SELECT tag FROM post_tag WHERE post= $r[id];");
-                        if (mysqli_num_rows($q_tag) > 0){
-                            $tag_string = "<span class='tags desktop'>Tags: ";
-                            $tag_raw = "";
-                            while ($r_tag = mysqli_fetch_array($q_tag)){
-                                $tag_string = $tag_string . "<a href='$proto$http_host/blog/buscar/tag/$r_tag[tag]'>$r_tag[tag]</a>, ";
-                                $tag_raw = $tag_raw . "$r_tag[tag],";
+?>
+                        <div itemscope itemtype='http://schema.org/BlogPosting' class='entry blog_entry'>
+                            <meta itemprop='inLanguage' content='<?=$lang?>'/>
+                            <meta itemprop='datePublished dateModified' content='<?=$r["isodate"]?>'/>
+                            <meta itemprop='headline name' content='$<?=r["title"]?>'/>
+                            <meta itemprop='articleBody text' content='<?=$r["text"]?>'/>
+                            <meta itemprop='mainEntityOfPage' content='<?=$server?>'/>
+                            <div class='hidden' itemprop='author publisher' itemscope itemtype='http://schema.org/Organization'>
+                                <meta itemprop='legalName' content='Asociaci&oacute;n Cultural Recreativa Gasteizko Margolariak'/>
+                                <meta itemprop='name' content='Gasteizko Margolariak'/>
+                                <meta itemprop='logo' content='<?=$server?>/img/logo/logo.png'/>
+                                <meta itemprop='foundingDate' content='03-02-2013'/>
+                                <meta itemprop='telephone' content='+34637140371'/>
+                                <meta itemprop='url' content='<?=$server?>'/>
+                            </div>
+                            <h3 class='entry_title'><a itemprop='url' href='<?=$server?>/blog/<?=$r["permalink"]?>'><?=$r["title"]?></a></h3>
+<?php
+                            $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $r[id] ORDER BY idx LIMIT 1;");
+                            if (mysqli_num_rows($q_image) > 0){
+                                $r_image = mysqli_fetch_array($q_image);
+?>
+                                <div class='post_list_image_container'>
+                                    <a href='<?=$server?>/blog/<?=$r["permalink"]?>'>
+                                        <meta itemprop='image' content='<?=$server?>/img/blog/view/<?=$r_image["image"]?>'/>
+                                        <img class='post_list_image alt='<?=$r["title"]?>' src='<?=$server?>/img/blog/miniature/<?=$r_image["image"]?>'/>
+                                    </a>
+                                </div>
+<?php
                             }
-                            $tag_string = substr($tag_string, 0, strlen($tag_string) - 2);
-                            $tag_string = $tag_string . "</span>";
-                            $tag_raw = substr($tag_raw, 0, strlen($tag_raw) - 1);
-                            echo "<meta itemprop='keywords' content='$tag_raw'/>\n";
-                            echo "<td><span class='date'>" . formatDate($r['dtime'], $lang, false) . "</span>&nbsp;&nbsp;&nbsp;$tag_string</td>\n";
-                        }
-                        else
-                            echo "<td><span class='date'>" . formatDate($r['dtime'], $lang, false) . "</span></td>\n";
-                        #Comment counter
-                        if ($r['comments'] == 1){
-                            $q_comment = mysqli_query($con, "SELECT count(id) AS count FROM post_comment WHERE post = $r[id] AND visible = 1;");
-                            $r_comment = mysqli_fetch_array($q_comment);
-                            echo "<meta itemprop='commentCount interationCount' content='$r_comment[count]'/>\n";
-                            if ($r_comment['count'] == 1)
-                                echo "<td class='r_comment'><span class='comment_counter'>1 $lng[blog_comments_1]</span>\n";
-                            else if ($r_comment['count'] == 0)
-                                echo "<td class='r_comment'><span class='comment_counter'>$lng[blog_comments_0]</span>\n";
-                            else 
-                                echo "<td class='r_comment'><span class='comment_counter'>$r_comment[count] $lng[blog_comments_multiple]</span>\n";
-                        }
-                        echo "</td>\n";
-                        echo "</tr></table>\n";
-                        echo "</div></br>\n";
-                    }
-                    #Pager
-                    $q_count = mysqli_query($con, "SELECT COUNT(id) AS count FROM post WHERE visible = 1;");
-                    $r_count = mysqli_fetch_array($q_count);
-                    $cur_page = (int) ($offset / 5) + 1;
-                    $max_page = (int) ($r_count['count'] / 5);
-                    if ($r_count['count'] % 5 != 0)
-                        $max_page ++;
-                    echo "<div id='pager'><table id='pager'><tr>\n";
-                    if ($cur_page > 4){
-                        echo "<td><div class='entry'><a href='$proto$http_host/blog/0'>1</a></div></td><td class='pager_ellipse'><div class='entry'>...</div></td>\n";
-                        for ($i = $cur_page - 2; $i < $cur_page; $i ++)
-                            echo "<td><div class='entry'><a href='$proto$http_host/blog/" . (5 * $i - 5) . "'>" . $i . "</a></div></td>\n";
-                    }
-                    else
-                        for ($i = 1; $i < $cur_page; $i ++)
-                            echo "<td><div class='entry'><a href='$proto$http_host/blog/" . (5 * $i - 5) . "'>" . $i . "</a></div></td>\n";
-                    echo "<td class='pager_current'><div class='entry'>$cur_page</div></td>\n";
-                    if ($cur_page + 4 < $max_page){
-                        for ($i = $cur_page + 1; $i < $cur_page + 3; $i ++)
-                            echo "<td><div class='entry'><a href='$proto$http_host/blog/" . (5 * $i - 5) . "'>" . $i . "</div></a></td>";
-                        echo "<td class='pager_ellipse'><div class='entry'>...</div></td><td><div class='entry'><a href='/blog/" . ($max_page * 5 - 5) . "'>$max_page</a></div></td>";
-                    }
-                    else
-                        for ($i = $cur_page + 1; $i <= $max_page; $i ++)
-                            echo "<td><div class='entry'><a href='$proto$http_host/blog/" . (5 * $i - 5) . "'>" . $i . "</a></div></td>";
-                    echo "</tr></table></div>\n";
-                ?>
-            </div>
-            <?php include("common/rightpanel.php"); ?>
+?>
+                            <p><?=cutText($r["text"], 800, $lng["blog_read_more"], "$server/blog/$r[permalink]/")?></p>
+
+                            <hr/>
+                            <table class='post_footer'>
+                                <tr>
+<?php
+                                    // Tags (if any), date, and comment counter
+                                    $q_tag = mysqli_query($con, "SELECT tag FROM post_tag WHERE post= $r[id];");
+                                    if (mysqli_num_rows($q_tag) > 0){
+                                        $tag_string = "<span class='tags desktop'>Tags: ";
+                                        $tag_raw = "";
+                                        while ($r_tag = mysqli_fetch_array($q_tag)){
+                                            $tag_string = $tag_string . "<a href='$proto$http_host/blog/buscar/tag/$r_tag[tag]'>$r_tag[tag]</a>, ";
+                                            $tag_raw = $tag_raw . "$r_tag[tag],";
+                                        }
+                                        $tag_string = substr($tag_string, 0, strlen($tag_string) - 2);
+                                        $tag_string = $tag_string . "</span>";
+                                        $tag_raw = substr($tag_raw, 0, strlen($tag_raw) - 1);
+?>
+                                        <meta itemprop='keywords' content='<?=$tag_raw?>'/>
+                                        <td>
+                                            <span class='date'><?=formatDate($r["dtime"], $lang, false)?></span>&nbsp;&nbsp;&nbsp;<?=$tag_string?>
+                                        </td>
+<?php
+                                    }
+                                    else{
+?>
+                                        <td>
+                                            <span class='date'><?=formatDate($r['dtime'], $lang, false)?></span>
+                                        </td>
+<?php
+                                    }
+                                    #Comment counter
+                                    if ($r["comments"] == 1){
+                                        $q_comment = mysqli_query($con, "SELECT count(id) AS count FROM post_comment WHERE post = $r[id] AND visible = 1;");
+                                        $r_comment = mysqli_fetch_array($q_comment);
+?>
+                                        <meta itemprop='commentCount interationCount' content='<?=$r_comment["count"]?>'/>
+                                        <td class='r_comment'>
+<?php
+                                            if ($r_comment['count'] == 1){
+?>
+                                                <span class='comment_counter'>1 <?=$lng["blog_comments_1"]?></span>
+<?php
+                                            }
+                                            else if ($r_comment['count'] == 0){
+?>
+                                                <span class='comment_counter'><?=$lng["blog_comments_0"]?></span>
+<?php
+                                            }
+                                            else{
+?>
+                                                <span class='comment_counter'>$<?=r_comment["count"]?> <?=$lng["blog_comments_multiple"]?></span>
+<?php
+                                            }
+?>
+                                        </td>
+<?php
+                                    }if ($r["comments"] == 1)
+?>
+                                </tr>
+                            </table> <!-- .post_footer -->
+                        </div> <!-- .blog_entry -->
+                        </br>
+<?php
+                    } // while($r = mysqli_fetch_array($q))
+?>
+            </div> <!-- .section -->
+<?php
+            include("common/rightpanel.php");
+?>
         </div>
-        <?php
+<?php
             include("../footer.php");
             $ad = ad($con, $lang, $lng); 
             stats($ad, $ad_static, "blog", "");
-        ?>
+?>
     </body>
 </html>

+ 205 - 148
www/blog/post.php

@@ -1,212 +1,269 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
+    $http_host = $_SERVER["HTTP_HOST"];
     include("../functions.php");
     $con = startdb();
     $proto = getProtocol();
+    $server = "$proto$http_host";
     
     //Language
     $lang = selectLanguage();
-    include("../lang/lang_" . $lang . ".php");
+    include("../lang/lang_$lang.php");
     
-    $cur_section = $lng['section_blog'];
+    $cur_section = $lng["section_blog"];
     
     // Get current post id. Redirect if inexistent or invisible
-    $perm = mysqli_real_escape_string($con, $_GET['perm']);
+    $perm = mysqli_real_escape_string($con, $_GET["perm"]);
     $q = mysqli_query($con, "SELECT id, permalink, title_$lang AS title, text_$lang AS text, DATE_FORMAT(dtime, '%Y-%m-%dT%T') AS isodate, DATE_FORMAT(dtime,'%b %d, %Y T%T') as dtime, comments FROM post WHERE permalink = '$perm' AND visible = 1;");
     if (mysqli_num_rows($q) == 0){
-        header("Location: $proto$http_host/blog/");
+        header("Location: $server/blog/");
         exit(-1);
     }
     $r = mysqli_fetch_array($q);
-    $id = $r['id'];
+    $id = $r["id"];
 ?>
 <!DOCTYPE html>
 <html>
     <head>
         <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
         <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-        <title><?php echo $r["title"] . " - Gasteizko Margolariak"; ?></title>
-        <link rel="shortcut icon" href="<?php echo "$proto$http_host/img/logo/favicon.ico";?>">
+        <title><?=$r["title"]?> - Gasteizko Margolariak</title>
+        <link rel="shortcut icon" href="<?=$server?>/img/logo/favicon.ico">
         <!-- CSS files -->
         <style>
-            <?php 
-                include("../css/ui.css"); 
-                include("../css/blog.css");
-            ?>
+<?php 
+            include("../css/ui.css"); 
+            include("../css/blog.css");
+?>
         </style>
         <!-- CSS for mobile version -->
         <style media="(max-width : 990px)">
-            <?php 
-                include("../css/m/ui.css"); 
-                include("../css/m/blog.css");
-            ?>
+<?php 
+            include("../css/m/ui.css"); 
+            include("../css/m/blog.css");
+?>
         </style>
         <!-- Script files -->
         <script type="text/javascript">
-            <?php
-                include("../script/ui.js");
-                include("../script/blog.js");
-            ?>
+<?php
+            include("../script/ui.js");
+            include("../script/blog.js");
+?>
         </script>
         <!-- Meta tags -->
-        <link rel="canonical" href="<?php echo "$proto$http_host/blog/" . $r['permalink']; ?>"/>
-        <link rel="author" href="<?php echo "$proto$http_host"; ?>"/>
-        <link rel="publisher" href="<?php echo "$proto$http_host"; ?>"/>
-        <meta name="description" content="<?php echo strip_tags($r["text"]);?>"/>
-        <meta property="og:title" content="<?php echo $r["title"] . " - Gasteizko Margolariak"; ?>"/>
-        <meta property="og:url" content="<?php echo "$proto$http_host/blog/" . $r['permalink']; ?>"/>
-        <meta property="og:description" content="<?php echo strip_tags($r["text_$lang"]);?>"/>
-        <?php
-            $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id ORDER BY idx;");
-            if (mysqli_num_rows($q_image) == 0)
-                $img = "$proto$http_host/img/logo/cover.png";
-            else{
-                $r_image = mysqli_fetch_array($q_image);
-                $img = "$proto$http_host/img/blog/preview/" . $r_image['image'];
-            }
-        ?>
-        <meta property="og:image" content="<?php echo $img;?>"/>
+        <link rel="canonical" href="<?=$server?>/blog/<?=$r["permalink"]?>"/>
+        <link rel="author" href="<?=$server?>"/>
+        <link rel="publisher" href="<?=$server?>"/>
+        <meta name="description" content="<?=strip_tags($r["text"])?>"/>
+        <meta property="og:title" content="<?=$r["title"]?> - Gasteizko Margolariak"/>
+        <meta property="og:url" content="<?=$server?>/blog/<?=$r["permalink"]?>"/>
+        <meta property="og:description" content="<?=strip_tags($r["text_$lang"])?>"/>
+<?php
+        $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id ORDER BY idx;");
+        if (mysqli_num_rows($q_image) == 0)
+            $img = "$server/img/logo/cover.png";
+        else{
+            $r_image = mysqli_fetch_array($q_image);
+            $img = "$server/img/blog/preview/" . $r_image["image"];
+        }
+?>
+        <meta property="og:image" content="<?=$img?>"/>
         <meta property="og:site_name" content="Gasteizko Margolariak"/>
         <meta property="og:type" content="article"/>
-        <meta property="og:locale" content="<?php echo $lang;?>"/>
+        <meta property="og:locale" content="<?=$lang?>"/>
         <meta property="article:section" content="Blog"/>
-        <!--     TODO: Review time format     -->
-        <meta property="article:published-time" content="<?php echo $r['time'];?>"/>
-        <meta property="article:modified-time" content="<?php echo $r['time'];?>"/>
+        <meta property="article:published-time" content="<?=$r["time"]?>"/>
+        <meta property="article:modified-time" content="<?=$r["time"]?>"/>
         <meta property="article:author" content="Gasteizko Margolariak"/>
-        <?php
-            $q_tag = mysqli_query($con, "SELECT tag FROM post_tag WHERE post = $id;");
-            $tag_string = "vitoria cuadrilla gasteizko margolariak ";
-            while ($r_tag = mysqli_fetch_array($q_tag))
-                $tag_string = $tag_string . " " . $r_tag['tag']
-        ?>
-        <meta property="article:tag" content="<?php echo $tag_string ?>"/>
+<?php
+        $q_tag = mysqli_query($con, "SELECT tag FROM post_tag WHERE post = $id;");
+        $tag_string = "vitoria cuadrilla gasteizko margolariak ";
+        while ($r_tag = mysqli_fetch_array($q_tag))
+            $tag_string = $tag_string . " " . $r_tag["tag"]
+?>
+        <meta property="article:tag" content="<?=$tag_string?>"/>
         <meta name="twitter:card" content="summary"/>
-        <meta name="twitter:title" content="<?php echo $r["title"] . " - Gasteizko Margolariak";?>"/>
-        <meta name="twitter:description" content="<?php echo strip_tags($r["text"]);?>"/>
-        <meta name="twitter:image" content="<?php echo $img;?>"/>
-        <meta name="twitter:url" content="<?php echo "$proto$http_host/blog/$r[permalink]"; ?>"/>
+        <meta name="twitter:title" content="<?=$r["title"]?> - Gasteizko Margolariak"/>
+        <meta name="twitter:description" content="<?=strip_tags($r["text_$lang"])?>"/>
+        <meta name="twitter:image" content="<?=$img?>"/>
+        <meta name="twitter:url" content="<?=$server?>/blog/<?=$r["permalink"]?>"/>
         <meta name="robots" content="index follow"/>
     </head>
     <body>
-        <?php include("../header.php"); ?>
+<?php
+        include("../header.php");
+?>
         <div id="content">
-            <?php include("common/leftpanel.php"); ?>
+<?php
+            include("common/leftpanel.php");
+?>
             <div id="middle_column">
-                <?php
-                    echo "<div itemscope itemtype='http://schema.org/BlogPosting' class='section blog_entry'>\n";
-                    echo "<meta itemprop='inLanguage' content='$lang'/>\n";
-                    echo "<meta itemprop='datePublished dateModified' content='$r[isodate]'/>\n";
-                    echo "<meta itemprop='headline name' content='$r[title]'/>\n";
-                    echo "<meta itemprop='mainEntityOfPage' content='$proto$http_host'/>\n";
-                    echo "<div class='hidden' itemprop='author publisher' itemscope itemtype='http://schema.org/Organization'>\n";
-                    echo "<meta itemprop='legalName' content='Asociaci&oacute;n Cultural Recreativa Gasteizko Margolariak'/>\n";
-                    echo "<meta itemprop='name' content='Gasteizko Margolariak'/>\n";
-                    echo "<meta itemprop='logo' content='$proto$http_host/img/logo/logo.png'/>\n";
-                    echo "<meta itemprop='foundingDate' content='03-02-2013'/>\n";
-                    echo "<meta itemprop='telephone' content='+34637140371'/>\n";
-                    echo "<meta itemprop='url' content='$proto$http_host'/>\n";
-                    echo "</div>\n";
-                    echo("<h3 class='section_title'>$r[title]</h3>\n");
-                    echo("<div class='entry'>\n");
+                <div itemscope itemtype='http://schema.org/BlogPosting' class='section blog_entry'>
+                <meta itemprop='inLanguage' content='<?=$lang?>'/>
+                <meta itemprop='datePublished dateModified' content='<?=$r["isodate"]?>'/>
+                <meta itemprop='headline name' content='<?=$r["title"]?>'/>
+                <meta itemprop='mainEntityOfPage' content='<?=$server?>'/>
+                <div class='hidden' itemprop='author publisher' itemscope itemtype='http://schema.org/Organization'>
+                    <meta itemprop='legalName' content='Asociaci&oacute;n Cultural Recreativa Gasteizko Margolariak'/>
+                    <meta itemprop='name' content='Gasteizko Margolariak'/>
+                    <meta itemprop='logo' content='<?=$server?>/img/logo/logo.png'/>
+                    <meta itemprop='foundingDate' content='03-02-2013'/>
+                    <meta itemprop='telephone' content='+34637140371'/>
+                    <meta itemprop='url' content='<?=$server?>'/>
+                </div>
+                <h3 class='section_title'><?=$r["title"]?></h3>
+                <div class='entry'>
+<?php
                     if ($r_image != null){
-                        echo "<div class='image_container'>\n";
-                        echo "<meta itemprop='image' content='$proto$http_host/img/blog/$r_image[image]'/>\n";
-                        echo "<img class='post_image post_image_large' alt='$r[title]' src='/img/blog/preview/$r_image[image]'/>\n";
-                        echo "</div>\n";
+?>
+                        <div class='image_container'>
+                            <meta itemprop='image' content='<?=$server?>/img/blog/<?=$r_image["image"]?>'/>
+                            <img class='post_image post_image_large' alt='<?=$r["title"]?>' src='/img/blog/preview/<?=$r_image["image"]?>'/>\n";
+                        </div>
+<?php
                     }
-                    echo "<p itemprop='text articleBody'>$r[text]</p>\n";
+?>
+                    <p itemprop='text articleBody'><?=$r["text"]?></p>
+<?php
                     //Other images
                     if ($r_image != null){
-                        echo "<table id='secondary_images'><tr>\n";
-                        while ($r_image = mysqli_fetch_array($q_image)){
-                            echo "<meta itemprop='image' content='$proto$http_host/img/blog/$r_image[image]'/>\n";
-                            echo "<td><img src='/img/blog/preview/$r_image[image]'/></td>\n";
-                        }
-                        echo "</tr></table>\n";
-                    }
-                    # Tags (if any) and date
-                    echo "<hr><table class='post_footer'><tr>\n";
-                    $q_tag = mysqli_query($con, "SELECT tag FROM post_tag WHERE post= $id;");
-                    if (mysqli_num_rows($q_tag) > 0){
-                        $tag_string = "<span id='tags' class='desktop'>Tags: ";
-                        $tag_raw = "";
-                        while ($r_tag = mysqli_fetch_array($q_tag)){
-                            $tag_string = $tag_string . "<a href='/blog/buscar/tag/$r_tag[tag]'>$r_tag[tag]</a>, ";
-                            $tag_raw = $tag_raw . "$r_tag[tag],";
-                        }
-                        $tag_string = substr($tag_string, 0, strlen($tag_string) - 2);
-                        $tag_string = $tag_string . "</span>";
-                        $tag_raw = substr($tag_raw, 0, strlen($tag_raw) - 1);
-                        echo "<meta itemprop='keywords' content='$tag_raw'/>\n";
-                        echo "<td><span class='date'>" . formatDate($r['dtime'], $lang) . "</span><br/><br class='mobile'/>$tag_string</td>\n";
-                    }
-                    else{
-                        echo "<td><span class='date'><span class='hidden'>" . formatDate($r['dtime'], $lang) . "</span></td>\n";
+?>
+                        <table id='secondary_images'>
+                            <tr>
+<?php
+                                while ($r_image = mysqli_fetch_array($q_image)){
+?>
+                                    <meta itemprop='image' content='<?=$server?>/img/blog/<?=$r_image["image"]?>'/>
+                                    <td>
+                                        <img src='<?=$server?>/img/blog/preview/<?=$r_image["image"]?>'/>
+                                    </td>
+<?php
+                                }
+?>
+                            </tr>
+                        </table>
+<?php
                     }
-                    #Share
-                    echo "<td class='r_share'><span class='share'><span class='desktop'>$lng[blog_share]</span>\n";
-                    $title = urlencode("$r[title] - $http_host");
-                    $url_f = htmlspecialchars("https://www.facebook.com/sharer/sharer.php?u=$proto$http_host$_SERVER[REQUEST_URI]");
-                    $url_t = htmlspecialchars("https://twitter.com/share?url=$proto$http_host$_SERVER[REQUEST_URI]&text=$title");
-                    $url_g = htmlspecialchars("https://plus.google.com/share?url=$proto$http_host$_SERVER[REQUEST_URI]");
-                    echo "<a href='$url_f' target='_blank'><img class='share_icon' alt='Facebook' src='$proto$http_host/img/social/facebook.gif'/></a>\n";
-                    echo "<a href='$url_t' target='_blank'><img class='share_icon' alt='Twitter' src='$proto$http_host/img/social/twitter.gif'/></a>\n";
-                    echo "<a href='$url_g' target='_blank'><img class='share_icon' src='$proto$http_host/img/social/googleplus.gif' alt='Google+'/></a>\n";
-                    echo "</span></td>\n";
-                    echo "</tr></table>\n";
+?>
+                    <hr>
+                    <table class='post_footer'>
+                        <tr>
+<?php
+                            # Tags (if any) and date
+                            $q_tag = mysqli_query($con, "SELECT tag FROM post_tag WHERE post= $id;");
+                            if (mysqli_num_rows($q_tag) > 0){
+                                $tag_string = "<span id='tags' class='desktop'>Tags: ";
+                                $tag_raw = "";
+                                while ($r_tag = mysqli_fetch_array($q_tag)){
+                                    $tag_string = $tag_string . "<a href='$server/blog/buscar/tag/$r_tag[tag]'>$r_tag[tag]</a>, ";
+                                    $tag_raw = $tag_raw . "$r_tag[tag],";
+                                }
+                                $tag_string = substr($tag_string, 0, strlen($tag_string) - 2);
+                                $tag_string = $tag_string . "</span>";
+                                $tag_raw = substr($tag_raw, 0, strlen($tag_raw) - 1);
+?>
+                                <meta itemprop='keywords' content='<?=$tag_raw?>'/>
+                                <td>
+                                    <span class='date'><?=formatDate($r["dtime"], $lang)?></span>
+                                    <br/><br class='mobile'/>
+                                    <?=$tag_string?>
+                                </td>
+<?php
+                            }
+                            else{
+?>
+                                <td>
+                                    <span class='date'>
+                                        <span class='hidden'><?=formatDate($r["dtime"], $lang)?>
+                                    </span>
+                                </td>
+<?php
+                            }
+                            #Share
+?>
+                            <td class='r_share'>
+                                <span class='share'>
+                                    <span class='desktop'>$lng[blog_share]</span>
+<?php
+                                    $title = urlencode("$r[title] - $http_host");
+                                    $url_f = htmlspecialchars("https://www.facebook.com/sharer/sharer.php?u=$server$_SERVER[REQUEST_URI]");
+                                    $url_t = htmlspecialchars("https://twitter.com/share?url=$server$_SERVER[REQUEST_URI]&text=$title");
+                                    $url_g = htmlspecialchars("https://plus.google.com/share?url=$server$_SERVER[REQUEST_URI]");
+?>
+                                    <a href='$url_f' target='_blank'><img class='share_icon' alt='Facebook' src='$server/img/social/facebook.gif'/></a>\n";
+                                    <a href='$url_t' target='_blank'><img class='share_icon' alt='Twitter' src='$server/img/social/twitter.gif'/></a>\n";
+                                    <a href='$url_g' target='_blank'><img class='share_icon' src='$server/img/social/googleplus.gif' alt='Google+'/></a>\n";
+                                </span>
+                            </td>
+                        </tr>
+                    </table> <!-- .post_footer -->
+<?php
                     #Comments
-                    if ($r['comments'] == 1){
-                        echo "<hr>\n";
+                    if ($r["comments"] == 1){
                         $q_comment = mysqli_query($con, "SELECT id, post, DATE_FORMAT(dtime, '%Y-%m-%dT%T') AS isodate, dtime, user, username, lang, text FROM post_comment WHERE post = $id AND approved = 1 ORDER BY dtime;");
                         $count = mysqli_num_rows($q_comment);
-                        echo "<meta itemprop='commentCount interactionCount' content='$count'/>\n";
+?>
+                        <hr/>
+                        <meta itemprop='commentCount interactionCount' content='<?=$count?>'/>
+<?php
                         switch ($count){
                             case 0:
-                                echo "<h4><meta itemprop='interactionCount' content='0'/></meta>$lng[blog_comments_0]</h4>\n";
+                                $comment_count = "<h4><meta itemprop='interactionCount' content='0'/></meta>$lng[blog_comments_0]</h4>";
                                 break;
                             case 1:
-                                echo "<h4><span itemprop='interactionCount'>1</span> $lng[blog_comments_1]</h4>\n";
+                               $comment_count = "<h4><span itemprop='interactionCount'>1</span> $lng[blog_comments_1]</h4>";
                                 break;
                             default:
-                                echo "<h4><span itemprop='interactionCount'>$count</span> $lng[blog_comments_multiple]</h4>\n";
-                        }
-                        echo "<div id='comment_list'>\n";
-                        //WARNING: If changes are done here, do the same in comment.php
-                        while ($r_comment = mysqli_fetch_array($q_comment)){
-                            echo "<div itemprop='comment' itemscope itemtype='http://schema.org/UserComments' id='comment_$r_comment[id]' class='comment'>\n";
-                            //When official users are implementes, see if there is user or username
-                            echo "<span itemprop='creator' class='comment_user'>$r_comment[username]</span>\n";
-                            echo "<span class='comment_date date'><meta itemprop='commentTime' content='$r_comment[isodate]'/>" . formatDate($r_comment['dtime'], $lang) . "</span>\n";
-                            echo "<p itemprop='commentText' class='comment_text'>$r_comment[text]</p>";
-                            echo "<hr class='comment_line'/>\n";
-                            echo "</div>\n";
+                                $comment_count = "<h4><span itemprop='interactionCount'>$count</span> $lng[blog_comments_multiple]</h4>";
                         }
-                        echo "</div>\n";
-                        #Comment form
-                        echo "<div class='comment' id='comment_new'>\n";
-                        echo "<form id='comment_form' method='post' action='/' onsubmit='event.preventDefault();postComment($id, \"$lang\");'>\n";
-                        echo "<textarea id='new_comment_text' name='text' maxlength='1800' onChange='defaultInputBorder(this);' onKeyDown='defaultInputBorder(this);' placeholder='$lng[blog_placeholder_text]'></textarea>\n";
-                        echo "<input type='hidden' name='id' value='$id'>\n";
-                        echo "<div id='identification_form'>\n";
-                        echo "<br><input id='new_comment_user' name='user' maxlength='50' type='text' placeholder='$lng[blog_placeholder_name]' onChange='defaultInputBorder(this);' onKeyDown='defaultInputBorder(this);'/>\n";
-                        echo "<input type='submit' value='$lng[blog_send]'/>\n";
-                        echo "</div>\n";
-                        echo "</form>\n";
-                        echo "</div>\n";
+?>
+                        <?=$comment_count?>
+                        <div id='comment_list'>
+<?php
+                            //WARNING: If changes are done here, do the same in comment.php
+                            while ($r_comment = mysqli_fetch_array($q_comment)){
+?>
+                                <div itemprop='comment' itemscope itemtype='http://schema.org/UserComments' id='comment_<?=$r_comment["id"]?>' class='comment'>
+                                    <span itemprop='creator' class='comment_user'><?=$r_comment["username"]?></span>
+                                    <span class='comment_date date'>
+                                        <meta itemprop='commentTime' content='<?=$r_comment["isodate"]?>'/>
+                                        <?=formatDate($r_comment["dtime"], $lang)?>
+                                    </span>
+                                    <p itemprop='commentText' class='comment_text'><?=$r_comment["text"]?></p>
+                                    <hr class='comment_line'/>
+                                </div>
+<?php
+                            }
+?>
+                        </div> <!-- #comment_list -->
+                        <div class='comment' id='comment_new'>
+                            <form id='comment_form' method='post' action='/' onsubmit='event.preventDefault();postComment(<?=$id?>, "<?=$lang?>");'>
+                                <textarea id='new_comment_text' name='text' maxlength='1800' onChange='defaultInputBorder(this);' onKeyDown='defaultInputBorder(this);' placeholder='<?=$lng["blog_placeholder_text"]?>'></textarea>
+                                <input type='hidden' name='id' value='<?=$id?>'>
+                                <div id='identification_form'>
+                                    <br>
+                                    <input id='new_comment_user' name='user' maxlength='50' type='text' placeholder='<?=$lng["blog_placeholder_name"]?>' onChange='defaultInputBorder(this);' onKeyDown='defaultInputBorder(this);'/>
+                                    <input type='submit' value='<?=$lng["blog_send"]?>'/>
+                                </div>
+                            </form>
+                        </div> <!-- .comment_new -->
+<?php
                     }
                     else{
-                        echo "<h4>$lng[blog_comments_closed]</h4>";
+?>
+                        <h4><?=$lng["blog_comments_closed"]?></h4>
+<?php
                     }
-                    echo "</div></div>\n";
-                ?>
-            </div>
-            <?php include("common/rightpanel.php"); ?>
-        </div>
-        <?php
+?>
+                </div> <!-- .entry -->
+            </div> <!-- #middle_column -->
+<?php
+            include("common/rightpanel.php");
+?>
+        </div> <!-- .content -->
+<?php
             include("../footer.php");
             $ad = ad($con, $lang, $lng); 
             stats($ad, $ad_static, "blog", "$id");
-        ?>
+?>
     </body>
 </html>

+ 39 - 6
www/css/lablanca.css

@@ -21,11 +21,11 @@ div#content_table div.content_tr div.content_td{
 }
 
 div#content_table div.content_tr div#content_td_schedule{
-    width:        60%;
+    width:        50%;
 }
 
 div#content_table div.content_tr div#content_td_prices{
-    width:        40%;
+    width:        50%;
 }
 
 div#content_table div.content_tr div#content_td_prices div#prices{
@@ -72,11 +72,22 @@ div#festivals_image_top_container div#festivals_image_container img#festivals_im
     max-height:        20em;
 }
 
+/* programa.php */
 div#schedule{
-    display:        inline-block;
-    vertical-align:    top;
-    margin-top:        2em;
-    margin-right:    1em;
+    display: inline-block;
+    vertical-align: top;
+    margin-top: 2em;
+    margin-right: 1em;
+    text-align: center
+    width: 100%;
+}
+
+div#schedule div.button{
+    margin: 1em 0.5em 1em 0.5em;
+    padding: 0.5em;
+    display: inline-block;
+    vertical-align: top;
+    width: 40%;
 }
 
 div.day_title h4{
@@ -152,6 +163,28 @@ table.schedule div.location span.address{
     font-style:    italic;
 }
 
+div#map_container{
+    display: none;
+    opacity: 0;
+    position: fixed;
+    top:0;
+    bottom:0;
+    left:0;
+    right:0;
+    width: 100%;
+    height: 100%;
+    background-color: #33333333;    
+}
+
+div#map_container div#map{
+   background-color: #ffffff;
+   width: 70%;
+   height: 50%;
+   margin: 15% 15% 25% 15%;
+}
+
+
+/* fiestas.php */
 div#prices{
     display:        inline-block;
     vertical-align:    top;

+ 21 - 7
www/css/ui.css

@@ -374,14 +374,28 @@ div#cookie_popup{
     transition:                    bottom .5s ease-in-out;
 }
 
+div.button{
+    border: 0.2em solid #133442;
+    border-radius: 0.2em;
+    background-color: #124567;
+    text-align: center;
+}
+
+div.button a{
+    padding: 0.2em;
+    color: #dddddd;
+    font-weight: bold;
+    font-size: 100%;
+}
+
 span.button a{
-    font-weight:    bold;
-    font-size:        100%;
-    border:            0.2em solid #133442;
-    border-radius:    0.2em;
-    padding:        0.2em;
-    color:            #dddddd;
-	background-color:    #124567;
+    font-weight: bold;
+    font-size: 100%;
+    border: 0.2em solid #133442;
+    border-radius: 0.2em;
+    padding: 0.2em;
+    color: #dddddd;
+    background-color: #124567;
 }
 
 span#button_ok a{

+ 65 - 51
www/footer.php

@@ -2,67 +2,81 @@
     <div id="footer_table">
         <div class="tr">
             <div class="td" id="footer_left">
-                <span id="footer_follow" class="desktop"><?php echo $lng['footer_follow']?></span><br/>
-                <a title="Facebook" target="_blank" href="https://www.facebook.com/gmargolariak"><img class="footer_social_icon" src="<?php echo $proto . $_SERVER['HTTP_HOST']; ?>/img/social/facebook.gif" alt="Facebook"/></a>
-                <a title="Twitter" target="_blank" href="https://twitter.com/gmargolariak"><img class="footer_social_icon" src="<?php echo $proto . $_SERVER['HTTP_HOST']; ?>/img/social/twitter.gif" alt="Twitter"/></a>
-                <a title="Google+" target="_blank" href="https://plus.google.com/106661466029005469492"><img class="footer_social_icon" src="<?php echo $proto . $_SERVER['HTTP_HOST']; ?>/img/social/googleplus.gif" alt="Google+"/></a>
+                <span id="footer_follow" class="desktop"><?=$lng["footer_follow"]?></span>
+                <br/>
+                <a title="Facebook" target="_blank" href="https://www.facebook.com/gmargolariak">
+                    <img class="footer_social_icon" src="<?=$server?>/img/social/facebook.gif" alt="Facebook"/>
+                </a>
+                <a title="Twitter" target="_blank" href="https://twitter.com/gmargolariak">
+                    <img class="footer_social_icon" src="<?=$server?>/img/social/twitter.gif" alt="Twitter"/>
+                </a>
+                <a title="Google+" target="_blank" href="https://plus.google.com/106661466029005469492">
+                    <img class="footer_social_icon" src="<?=$server?>/img/social/googleplus.gif" alt="Google+"/>
+                </a>
                 <br class="desktop"/>
-                <a title="Youtube" target="_blank" href="https://www.youtube.com/user/GasteizkoMargolariak"><img class="footer_social_icon" src="<?php echo $proto . $_SERVER['HTTP_HOST']; ?>/img/social/youtube.gif" alt="Youtube"/></a>
-                <a title="Instagram" target="_blank" href="https://instagram.com/gmargolariak/"><img class="footer_social_icon" src="<?php echo $proto . $_SERVER['HTTP_HOST']; ?>/img/social/instagram.gif" alt="nstagram"/></a>
-<!--                  <a title="RSS" href="<?php echo $proto.$_SERVER['HTTP_HOST']; ?>/rss.xml"><img class="footer_social_icon" src="<?php echo $proto . $_SERVER['HTTP_HOST']; ?>/img/social/rss.gif" alt="RSS"/></a> -->
-                <br/><span id="footer_info" class='desktop'><?php echo($lng['footer_info']); ?></span>
-            </div>
+                <a title="Youtube" target="_blank" href="https://www.youtube.com/user/GasteizkoMargolariak">
+                    <img class="footer_social_icon" src="<?=$server?>/img/social/youtube.gif" alt="Youtube"/>
+                </a>
+                <a title="Instagram" target="_blank" href="https://instagram.com/gmargolariak/">
+                    <img class="footer_social_icon" src="<?=$server?>/img/social/instagram.gif" alt="Instagram"/>
+                </a>
+                <br/>
+                <span id="footer_info" class='desktop'><?=$lng["footer_info"]?></span>
+            </div> <!-- #footer_left-->
             <div class="td" id="footer_center">
                 <br class="mobile"/><br class="mobile"/>
-                <?php
-                    $q = mysqli_query($con, "SELECT id, name_$lang AS name, image, link FROM sponsor WHERE image != '' ORDER BY ammount DESC;");
-                    $ad_static = Array();
-                    if (mysqli_num_rows($q) > 0){
-                        echo("<span class='desktop'>$lng[footer_sponsors]</span></br class='desktop'>\n");
-                        //$idx = 0;
-                        while ($r = mysqli_fetch_array($q)){
-                            
-                            array_push($ad_static, $r['id']);
-                        
-                            //if ($idx == 0){
-                            //    echo("<a target='_blank' href='$r[link]'><span class='desktop'>$r[name]</span><img src='/img/spo/miniature/$r[image]'/></a>");
-                            //}
-                            //elseif ($idx == 1){
-                            //    echo("&nbsp;&nbsp;&nbsp;<a target='_blank' href='$r[link]'><img src='/img/spo/thumb/$r[image]'/><span class='desktop'>$r[name]</span></a></br class='desktop'>");
-                            //}
-                            //else{
-                                echo("<a target='_blank' href='$r[link]'><img src='/img/spo/thumb/$r[image]'/></a>");
-                            //}
-                            //$idx ++;
-                        }
-                        
+<?php
+                $q = mysqli_query($con, "SELECT id, name_$lang AS name, image, link FROM sponsor WHERE image != '' ORDER BY ammount DESC;");
+                $ad_static = Array();
+                if (mysqli_num_rows($q) > 0){
+?>
+                    <span class='desktop'><?=$lng["footer_sponsors"]?></span>
+                    </br class='desktop'>
+<?php
+                    while ($r = mysqli_fetch_array($q)){
+                        array_push($ad_static, $r["id"]);
+?>
+                        <a target='_blank' href='<?=$r["link"]?>'>
+                            <img src='<?=$server?>/img/spo/thumb/<?=$r["image"]?>'/>
+                        </a>
+<?php
                     }
-                ?>
+                }
+?>
                 <br class="mobile"/><br class="mobile"/><br class="mobile"/>
-            </div>
+            </div> <!-- #footer_center -->
             <div  class="td" id="footer_right" class="desktop">
-                <a href="<?php echo "$proto$_SERVER[HTTP_HOST]/ayuda/";?>"><?php echo $lng['footer_help']; ?></a>&nbsp;&nbsp;&nbsp;<a href="<?php echo "$proto$_SERVER[HTTP_HOST]/ayuda/#section_privacy";?>"><?php echo $lng['footer_privacy'];?></a>
+                <a href="<?=$server?>/ayuda/"><?=$lng["footer_help"]?></a>&nbsp;&nbsp;&nbsp;
+                <a href="<?=$server?>/ayuda/#section_privacy"><?=$lng["footer_privacy"]?></a>
                 <br/><br class='mobile'/>
-                <img class='lang' alt='Espanol' src='/img/lang/es.gif' onClick='changeLanguage("es", "<?php echo $http_host; ?>");'/>
-                <img class='lang' alt='English' src='/img/lang/en.gif' onClick='changeLanguage("en", "<?php echo $http_host; ?>");'/>
-                <img class='lang' alt='Euskara' src='/img/lang/eu.gif' onClick='changeLanguage("eu", "<?php echo $http_host; ?>");'/>
+                <img class='lang' alt='Espa&ntilde;ol' src='/img/lang/es.gif' onClick='changeLanguage("es", "<?=$server?>");'/>
+                <img class='lang' alt='English' src='/img/lang/en.gif' onClick='changeLanguage("en", "<?=$server?>");'/>
+                <img class='lang' alt='Euskara' src='/img/lang/eu.gif' onClick='changeLanguage("eu", "<?=$server?>");'/>
                 <br class='desktop'/>
-                <a title="Google Play" href="https://play.google.com/store/apps/details?id=com.ivalentin.margolariak"><img class='app' alt="<?php echo $lng['footer_app_google']; ?>" src='/img/app/android.gif' /></a>
-								<br class='desktop'/>
-                <a title="App Store" href="https://itunes.apple.com/us/app/gasteizko-margolariak/id1227846624"><img class='app' alt="<?php echo $lng['footer_app_apple']; ?>" src='/img/app/ios.gif' /></a>
-            </div>
-        </div>
-    </div>
-</div>
+                <a title="Google Play" href="https://play.google.com/store/apps/details?id=com.ivalentin.margolariak">
+                    <img class='app' alt="<?=$lng["footer_app_google"]?>" src='/img/app/android.gif'/>
+                </a>
+                <br class='desktop'/>
+                <a title="App Store" href="https://itunes.apple.com/us/app/gasteizko-margolariak/id1227846624">
+                    <img class='app' alt="<?=$lng["footer_app_apple"]?>" src='/img/app/ios.gif'/>
+                </a>
+            </div> <!-- #footer_right -->
+        </div> <!-- .tr -->
+    </div> <!-- #footer_table -->
+</div> <!-- footer -->
 <?php
-    //header('Cache-control: private');
-    if (isSet($_COOKIE['cookie']) == false){
+
+if (isSet($_COOKIE["cookie"]) == false){
 ?>
-<div id='cookie_popup'>
-    <span id='message'><?php echo $lng['cookie_message']; ?></span><br/><br/>
-    <span class='button pointer' style="cursor:pointer" id='button_ok'><a onClick="dismissCookiePopUp('<?php echo $http_host; ?>', false);" ><?php echo $lng['cookie_ok']; ?></a></span>
-    <span class='button pointer' style="cursor:pointer" id='button_more'><a onClick="dismissCookiePopUp('<?php echo $http_host; ?>', true);" ><?php echo $lng['cookie_more']; ?></a></span>
-</div>
+    <div id='cookie_popup'>
+        <span id='message'><?=$lng["cookie_message"]?></span><br/><br/>
+        <span class='button pointer' style="cursor:pointer" id='button_ok'>
+            <a onClick="dismissCookiePopUp('<?=$server?>', false);" ><?=$lng["cookie_ok"]?></a>
+        </span>
+        <span class='button pointer' style="cursor:pointer" id='button_more'>
+            <a onClick="dismissCookiePopUp('<?=$server?>', true);" ><?=$lng["cookie_more"]?></a>
+        </span>
+    </div>
 <?php
 }
 ?>

+ 332 - 273
www/functions.php

@@ -1,126 +1,139 @@
 <?php
 
-    /****************************************************
-    * This function is called from almost everywhere at *
-    * the beggining of the page. It initializes the     *
-    * session variables, connect to the db, enabling    *
-    * the variable $con for futher use everywhere in    *
-    * the php code, and populates the arrays $user      *
-    * and $permission, with info about the user.        *
-    * @params:                                          *
-    *    mode: (string) Indicates required permissions  *
-    *          on database. 'ro' gives read             *
-    *          permissions, and 'rw' read and write     *
-    *          permissions. Other values will result in *
-    *          errors.                                  *
-    * @return: (db connection): The connection handler. *
-    ****************************************************/
-    function startdb($mode = 'ro'){
+
+    /*****************************************************
+     * This function is called from almost everywhere at *
+     * the beggining of the page. It initializes the     *
+     * session variables, connect to the db, enabling    *
+     * the variable $con for futher use everywhere in    *
+     * the php code, and populates the arrays $user      *
+     * and $permission, with info about the user.        *
+     * @params:                                          *
+     *    mode: (string) Indicates required permissions  *
+     *          on database. "ro" gives read             *
+     *          permissions, and "rw" read and write     *
+     *          permissions. Other values will result in *
+     *          errors.                                  *
+     * @return: (db connection): The connection handler. *
+     *****************************************************/
+    function startdb($mode = "ro"){
         //Include the db configuration file. It's somehow like this
         /*
         <?php
-            $host = 'XXXX';
-            $db_name = 'XXXX';
-            $username_ro = 'XXXX';
-            $username_rw = 'XXXX';
-            $pass_ro = 'XXXX';
-            $pass_rw = 'XXXX';
+            $host = "XXXX";
+            $db_name = "XXXX";
+            $username_ro = "XXXX";
+            $username_rw = "XXXX";
+            $pass_ro = "XXXX";
+            $pass_rw = "XXXX";
         ?>
         */
-        include('.htpasswd');
-        
+        include(".htpasswd");
+
         //Connect to to database
-        if ($mode == 'ro')
+        if ($mode == "ro"){
             $con = mysqli_connect($host, $username_ro, $pass_ro, $db_name);
-        else if ($mode == 'rw'){
+        }
+        else if ($mode == "rw"){
             $con = mysqli_connect($host, $username_rw, $pass_rw, $db_name);
         }
-            
+        else{
+            $con = mysqli_connect("error", "error", "error", "error");
+        }
+
         // Check connection
         if (mysqli_connect_errno()){
             error_log("Failed to connect to database: " . mysqli_connect_error());
             return -1;
         }
-        
+
         //Set encoding options
-        mysqli_set_charset($con, 'utf-8');
-        header('Content-Type: text/html; charset=utf8');
-        mysqli_query($con, 'SET NAMES utf8;');
-        
+        mysqli_set_charset($con, "utf-8");
+        header("Content-Type: text/html; charset=utf8");
+        mysqli_query($con, "SET NAMES utf8;");
+
         //Return the db connection
         return $con;
     }
+
+
+    /*****************************************************
+     * Finds out the protocol the user is connecting to  *
+     * the site with (http or https)                     *
+     * @return: (string): "http://" or "https://".       *
+     ****************************************************/
     function getProtocol(){
-        if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
-            $protocol = 'https://';
+        if (isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on" || $_SERVER["HTTPS"] == 1) || isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && $_SERVER["HTTP_X_FORWARDED_PROTO"] == "https") {
+            $protocol = "https://";
         }
         else {
-            $protocol = 'http://';
+            $protocol = "http://";
         }
         return $protocol;
     }
 
-    
-    /****************************************************
-    * This function selects the language the page will  *
-    * be displayed inf the page. Several methods are    *
-    * used: cookie detection, and browser language      *
-    * preferences.                                      *
-    * @return: (string): Language code.                 *
-    ****************************************************/
+
+    /*****************************************************
+     * This function selects the language the page will  *
+     * be displayed inf the page. Several methods are    *
+     * used: cookie detection, and browser language      *
+     * preferences.                                      *
+     * @return: (string): Language code.                 *
+     *****************************************************/
     function selectLanguage(){
         //Try to read cookie.
-        header('Cache-control: private');
-        if (isSet($_COOKIE['lang'])){
-            $lang = $_COOKIE['lang'];
-            if ($lang == 'es' || $lang == 'en' || $lang == 'eu'){
+        header("Cache-control: private");
+        if (isSet($_COOKIE["lang"])){
+            $lang = $_COOKIE["lang"];
+            if ($lang == "es" || $lang == "en" || $lang == "eu"){
                 return $lang;
             }
             else{
-                return 'es';
+                return "es";
             }
         }
-        
+
         //If no cookie, select from client browser preferences.
         else{
             $available_languages = array("en", "eu", "es");
             $langs = prefered_language($available_languages, $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
             $lang = $langs[0];
-            if ($lang != 'es' && $lang != 'en' && $lang != 'eu'){
-                return 'es';
+            if ($lang != "es" && $lang != "en" && $lang != "eu"){
+                return "es";
             }
             else{
-                return $langs[0]; //TODO test this
+                return $langs[0];
             }
         }
     }
-    
-    /****************************************************
-    * This function parses the language prefrences of   *
-    * the client broser, comparing them to th languages *
-    * offered by the site.                              *
-    * the variable $con for futher use everywhere in    *
-    * the php code, and populates the arrays $user      *
-    * and $permission, with info about the user.        *
-    * @params:                                          *
-    *    available_languages: (string array) Contains   *
-    *                         a list of strins offered  *
-    *                         by the site.              *
-    *    http_accept_language: (string) Raw header with *
-    *                          info about client        *
-    *                          language preferences.    *
-    * @return: (string array) List of the languages     *
-    *          offered, sorted by prefference.          *
-    ****************************************************/
+
+
+    /*****************************************************
+     * This function parses the language prefrences of   *
+     * the client broser, comparing them to th languages *
+     * offered by the site.                              *
+     * the variable $con for futher use everywhere in    *
+     * the php code, and populates the arrays $user      *
+     * and $permission, with info about the user.        *
+     * @params:                                          *
+     *    available_languages: (string array) Contains   *
+     *                         a list of strins offered  *
+     *                         by the site.              *
+     *    http_accept_language: (string) Raw header with *
+     *                          info about client        *
+     *                          language preferences.    *
+     * @return: (string array) List of the languages     *
+     *          offered, sorted by prefference.          *
+     *****************************************************/
     function prefered_language(array $available_languages, $http_accept_language) {
 
         $available_languages = array_flip($available_languages);
 
         $langs;
-        preg_match_all('~([\w-]+)(?:[^,\d]+([\d.]+))?~', strtolower($http_accept_language), $matches, PREG_SET_ORDER);
+        preg_match_all("~([\w-]+)(?:[^,\d]+([\d.]+))?~", strtolower($http_accept_language), $matches, PREG_SET_ORDER);
         foreach($matches as $match) {
 
-            list($a, $b) = explode('-', $match[1]) + array('', '');
+            list($a, $b) = explode("-", $match[1]) + array("", "");
             $value = isset($match[2]) ? (float) $match[2] : 1.0;
 
             if(isset($available_languages[$match[1]])) {
@@ -138,34 +151,35 @@
         return $langs;
     }
 
-    /****************************************************
-    * This function turns a date string into a human    *
-    * readable string, deppending o the specified       * 
-    * language.                                         *
-    * @params:                                          *
-    *    strdate: (string): Date string.                *
-    *    lang: (string): Language code (es, en, eu).    *
-    *    http_accept_language: (string) Raw header with *
-    *                          info about client        *
-    *                          language preferences.    *
-    *    time: (boolean): Append the time at the end.   *
-    * @return: (string array) List of the languages     *
-    *          offered, sorted by prefference.          *
-    ****************************************************/    
+
+    /*****************************************************
+     * This function turns a date string into a human    *
+     * readable string, deppending o the specified       *
+     * language.                                         *
+     * @params:                                          *
+     *    strdate: (string): Date string.                *
+     *    lang: (string): Language code (es, en, eu).    *
+     *    http_accept_language: (string) Raw header with *
+     *                          info about client        *
+     *                          language preferences.    *
+     *    time: (boolean): Append the time at the end.   *
+     * @return: (string array) List of the languages     *
+     *          offered, sorted by prefference.          *
+     *****************************************************/
     function formatDate($strdate, $lang, $time = true){
         $date = strtotime($strdate);
-        $year = date('o', $date);
-        $month = date('n', $date);
+        $year = date("o", $date);
+        $month = date("n", $date);
         $month --;
-        $day = date('j', $date);
-        $wday = date('N', $date);
+        $day = date("j", $date);
+        $wday = date("N", $date);
         $wday --;
-        $hour = date('H', $date);
-        $minute = date('i', $date);
+        $hour = date("H", $date);
+        $minute = date("i", $date);
         switch ($lang){
-            case 'en':
-                $week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
-                $months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
+            case "en":
+                $week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
+                $months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
                 if ($time){
                     $str = "$week[$wday], $months[$month] $day, $year at $hour:$minute";
                 }
@@ -173,9 +187,9 @@
                     $str = "$week[$wday], $months[$month] $day, $year";
                 }
                 break;
-            case 'eu':
-                $week = ['astelehena', 'asteartea', 'asteazkena', 'osteguna', 'ostirala', 'larumbata', 'igandea'];
-                $months = ['urtarrilaren', 'otsailaren', 'martxoaren', 'apirilaren', 'maiatzaren', 'ekainaren', 'uztailaren', 'abuztuaren', 'irailaren', 'urriaren', 'azaroaren', 'abenduaren'];
+            case "eu":
+                $week = ["astelehena", "asteartea", "asteazkena", "osteguna", "ostirala", "larumbata", "igandea"];
+                $months = ["urtarrilaren", "otsailaren", "martxoaren", "apirilaren", "maiatzaren", "ekainaren", "uztailaren", "abuztuaren", "irailaren", "urriaren", "azaroaren", "abenduaren"];
                 if ($time){
                     $str = $year . "ko $months[$month] $day" . "an, $week[$wday], $hour:$minute";
                 }
@@ -184,8 +198,8 @@
                 }
                 break;
             default:
-                $week = ['Lunes', 'Martes', 'Mi&eacute;rcoles', 'Jueves', 'Viernes', 'S&aacute;bado', 'Domingo'];
-                $months = ['enero', ' febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];
+                $week = ["Lunes", "Martes", "Mi&eacute;rcoles", "Jueves", "Viernes", "S&aacute;bado", "Domingo"];
+                $months = ["enero", " febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"];
                 if ($time){
                     $str = "$week[$wday] $day de $months[$month] de $year a las $hour:$minute";
                 }
@@ -195,72 +209,76 @@
         }
         return $str;
     }
-    
-    /****************************************************
-    * This function turns a date string into a human    *
-    * readable string, deppending o the specified       * 
-    * language. It is designed to be used for festival  *
-    * days only, since it doesnt return the weekday.    *
-    * @params:                                          *
-    *    strdate: (string): Date string.                *
-    *    lang: (string): Language code (es, en, eu).    *
-    *    http_accept_language: (string) Raw header with *
-    *                          info about client        *
-    *                          language preferences.    *
-    * @return: (string array) List of the languages     *
-    *          offered, sorted by prefference.          *
-    ****************************************************/    
+
+
+    /*****************************************************
+     * This function turns a date string into a human    *
+     * readable string, deppending o the specified       *
+     * language. It is designed to be used for festival  *
+     * days only, since it doesnt return the weekday.    *
+     * @params:                                          *
+     *    strdate: (string): Date string.                *
+     *    lang: (string): Language code (es, en, eu).    *
+     *    http_accept_language: (string) Raw header with *
+     *                          info about client        *
+     *                          language preferences.    *
+     * @return: (string array) List of the languages     *
+     *          offered, sorted by prefference.          *
+     *****************************************************/
     function formatFestivalDate($strdate, $lang){
         $date = strtotime($strdate);
-        $month = date('n', $date);
+        $month = date("n", $date);
         $month --;
-        $day = date('j', $date);
+        $day = date("j", $date);
         switch ($lang){
-            case 'en':
-                $months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
+            case "en":
+                $months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
                 $str = "$months[$month] $day";
                 break;
-            case 'eu':
-                $months = ['urtarrilaren', 'otsailaren', 'martxoaren', 'apirilaren', 'maiatzaren', 'ekainaren', 'uztailaren', 'abuztuaren', 'irailaren', 'urriaren', 'azaroaren', 'abenduaren'];
+            case "eu":
+                $months = ["urtarrilaren", "otsailaren", "martxoaren", "apirilaren", "maiatzaren", "ekainaren", "uztailaren", "abuztuaren", "irailaren", "urriaren", "azaroaren", "abenduaren"];
                 $str = "$months[$month] $day";
                 break;
             default:
-                $months = ['enero', ' febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];
+                $months = ["enero", " febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"];
                 $str = "$day de $months[$month]";
         }
         return $str;
     }
-    
-    /****************************************************
-    * Generates a URL-valid string from a regular one.  *
-    *                                                   *
-    * @params:                                          *
-    *    text: (string): Original string.               *
-    * @return: (string): URL-valid string.              *
-    ****************************************************/
+
+
+    /*****************************************************
+     * Generates a URL-valid string from a regular one.  *
+     *                                                   *
+     * @params:                                          *
+     *    text: (string): Original string.               *
+     * @return: (string): URL-valid string.              *
+     *****************************************************/
     function permalink($text){
-        $unwanted_array = array('Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
-                            'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
-                            'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
-                            'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
-                            'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y' );
+        $unwanted_array = array("Š"=>"S", "š"=>"s", "Ž"=>"Z", "ž"=>"z", "À"=>"A", "Á"=>"A", "Â"=>"A", "Ã"=>"A", "Ä"=>"A", "Å"=>"A", "Æ"=>"A", "Ç"=>"C", "È"=>"E", "É"=>"E",
+                            "Ê"=>"E", "Ë"=>"E", "Ì"=>"I", "Í"=>"I", "Î"=>"I", "Ï"=>"I", "Ñ"=>"N", "Ò"=>"O", "Ó"=>"O", "Ô"=>"O", "Õ"=>"O", "Ö"=>"O", "Ø"=>"O", "Ù"=>"U",
+                            "Ú"=>"U", "Û"=>"U", "Ü"=>"U", "Ý"=>"Y", "Þ"=>"B", "ß"=>"Ss", "à"=>"a", "á"=>"a", "â"=>"a", "ã"=>"a", "ä"=>"a", "å"=>"a", "æ"=>"a", "ç"=>"c",
+                            "è"=>"e", "é"=>"e", "ê"=>"e", "ë"=>"e", "ì"=>"i", "í"=>"i", "î"=>"i", "ï"=>"i", "ð"=>"o", "ñ"=>"n", "ò"=>"o", "ó"=>"o", "ô"=>"o", "õ"=>"o",
+                            "ö"=>"o", "ø"=>"o", "ù"=>"u", "ú"=>"u", "û"=>"u", "ý"=>"y", "þ"=>"b", "ÿ"=>"y" );
         $str = strtr( $text, $unwanted_array );
-        $str = preg_replace('/[^\da-zA-Z ]/i', '', $str);
-        $str = str_replace(' ', '-', $str);
+        $str = preg_replace("/[^\da-zA-Z ]/i", "", $str);
+        $str = str_replace(" ", "-", $str);
         return $str;
     }
-    
-    /****************************************************
-    * This function closes all the opened HTML tags in  *
-    * a given string.                                   * 
-    *                                                   *
-    * @params:                                          *
-    *    html: (string): The string with HTML tags      *
-     ****************************************************/
+
+
+    /*****************************************************
+     * This function closes all the opened HTML tags in  *
+     * a given string.                                   *
+     *                                                   *
+     * @params:                                          *
+     *    html: (string): The string with HTML tags.      *
+     * @return: (string): HTML with closed tags.         *
+     *****************************************************/
     function closeTags($html) {
-        preg_match_all('#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);
+        preg_match_all("#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?<![/|/ ])>#iU", $html, $result);
         $openedtags = $result[1];
-        preg_match_all('#</([a-z]+)>#iU', $html, $result);
+        preg_match_all("#</([a-z]+)>#iU", $html, $result);
         $closedtags = $result[1];
         $len_opened = count($openedtags);
         if (count($closedtags) == $len_opened) {
@@ -269,26 +287,28 @@
         $openedtags = array_reverse($openedtags);
         for ($i=0; $i < $len_opened; $i++) {
             if (!in_array($openedtags[$i], $closedtags)) {
-                $html .= '</'.$openedtags[$i].'>';
+                $html .= "</".$openedtags[$i].">";
             } else {
                 unset($closedtags[array_search($openedtags[$i], $closedtags)]);
             }
         }
         return $html;
     }
-    
-    /****************************************************
-    * Text shortener. Given a string, it trims in the   *
-    * proximity of the desired string, ut to the next   * 
-    * white character. If indicated, it will append a   *
-    * link to the full text.                            *
-    *                                                   *
-    * @params:                                          *
-    *    text: (string): The text to shorten.           *
-    *    length: (int): The desired length.             *
-    *    linktext: (string): Text fot the link.         *
-    *    link: (string): URI of the full text.          *
-     ****************************************************/
+
+
+    /*****************************************************
+     * Text shortener. Given a string, it trims in the   *
+     * proximity of the desired string, ut to the next   *
+     * white character. If indicated, it will append a   *
+     * link to the full text.                            *
+     *                                                   *
+     * @params:                                          *
+     *    text: (string): The text to shorten.           *
+     *    length: (int): The desired length.             *
+     *    linktext: (string): Text fot the link.         *
+     *    link: (string): URI of the full text.          *
+     * @return: (string): Cutted text.                   *
+     *****************************************************/
      function cutText($text, $length, $linktext, $link){
         if (strlen($text) < $length){
             return $text;
@@ -303,29 +323,26 @@
         }
         return $cut;
     }
-    
-    /****************************************************
-    * Increases version value in table settings by one. *
-    * Helpfull for the app to know when to perform a    * 
-    * full sync. Must be called after every INSERT,     *
-    * UPDATE or DELETE query to the database.           *
-     ****************************************************/
-    function version(){
-        $con = startdb('rw');
-        mysqli_query($con, 'UPDATE settings SET value = value + 1 WHERE name = "version";');
-    }
-    
-    /****************************************************
-        * Shows an ad at random. It does that one in three  *
-        * times, and only one per session (inserts a cookie *
-        * to know if the ad has been shown. A sponsor has   *
-        * more chances of having his ad popping the more it *
-    * contributes with Gasteizko Margolariak.           *
-        ****************************************************/
+
+
+    /*****************************************************
+     * Shows an ad at random. It does that one in three  *
+     * times, and only one per session (inserts a cookie *
+     * to know if the ad has been shown. A sponsor has   *
+     * more chances of having his ad popping the more it *
+     * contributes with Gasteizko Margolariak.           *
+     * @params:                                          *
+     *    con: (Mysql connectrion): DB connection.       *
+     *    lang: (string): Two-letter language code.      *
+     *    lng: (string array): Literal array for the     *
+     *         user language.                            *
+     * @return: (int) Id of the shown sponsor, null if   *
+     *          none was shown.                          *
+     *****************************************************/
     function ad($con, $lang, $lng){
         $id = -1;
-        //If the user hasn't still see an add on this session
-        if (isset($_SESSION['ad']) == false){
+        //If the user hasn"t still see an add on this session
+        if (isset($_SESSION["ad"]) == false){
             //25% chance of seeing an add
             if (rand (0, 3) == 0){
                 //Create an array with weighted values
@@ -336,57 +353,77 @@
                 $total = 0;
                 $sponsors = array();
                 while ($r = mysqli_fetch_array($q)){
-                    $times = $r['value'];
-                    $id = $r['id'];
+                    $times = $r["value"];
+                    $id = $r["id"];
                     for ($i = 0; $i < $times; $i ++) {
                         array_push($sponsors, $id);
                         $total ++;
                     }
                 }
-                
+
                 //Get a random id from the array
                 $id = $sponsors[rand (0, $total - 1)];
-                
+
                 //Get sponsor data
-                $q = mysqli_query($con, "SELECT name_$lang AS name, text_$lang AS text, image, address_$lang AS address, link, lat, lon FROM sponsor WHERE id = $id;");
+                $q = mysqli_query($con, "SELECT name_$lang AS name, text_$lang AS text, image, local, address_$lang AS address, link, lat, lon FROM sponsor WHERE id = $id;");
                 $r = mysqli_fetch_array($q);
-                echo("<div id='ad' class='section'>\n");
-                echo("<h3 class='section_title'><a target='_blank' href='$r[link]'>$r[name]</a></h3>\n");
-                echo("<div class='entry'>\n");
-                echo("<div id='ad_details'>\n");
-                echo($lng['ad_title']);
-                echo("<img class='pointer' src='/img/misc/slid-close.png' onClick='closeAd();' />\n");
-                echo("</div>\n");
-                if (strlen($r['image']) > 0){
-                    echo("<div id='ad_image_container'>\n");
-                    echo("<img src='/img/spo/miniature/$r[image]'/>\n");
-                    echo("</div>\n");
-                }
-                echo($r['text']);
-                if(strlen($r["address"]) > 0){
-                    echo("<br/><br/><a target='_blank' href='https://www.google.es/maps/@$r[lat],$r[lon],14z'><img id='ad_pinpoint' src='/img/misc/pinpoint.png'\>$r[address]</a>\n");
-                }
-                echo("<br/><br/><br class='mobile'/><br class='mobile'/>");
-                echo("<div id='ad_policy'>\n");
-                echo("<a target='_blank' href='$proto$http_host/ayuda/#section_ads'>" . $lng['help_ad_title'] . "</a>\n");
-                echo("</div>\n");
-                echo("</div>\n");
-                echo("</div>\n");
-                echo("<script type='text/javascript'>showAd();</script>\n");
-                
+?>
+                <div id='ad' class='section'>
+                    <h3 class='section_title'>
+                        <a target='_blank' href='<?=$r["link"]?>'><?=$r["name"]?></a>
+                    </h3>
+                    <div class='entry'>
+                        <div id='ad_details'>
+                            <?=$lng["ad_title"]?>
+                            <img class='pointer' src='/img/misc/slid-close.png' onClick='closeAd();' />
+                        </div>
+<?php
+                        if (strlen($r["image"]) > 0){
+?>
+                            <div id='ad_image_container'>
+                                <img src='/img/spo/miniature/<?=$r["image"]?>'/>
+                            </div>
+<?php
+                        }
+?>
+                        <?=$r["text"]?>
+<?php
+                        if($r["local"] == 1 && strlen($r["address"]) > 0){
+?>
+                            <br/><br/>
+                            <a target='_blank' href='https://www.google.es/maps/@<?=$r["lat"]?>,<?=$r["lon"]?>,14z'>
+                                <img id='ad_pinpoint' src='/img/misc/pinpoint.png'\>
+                                <?=$r["address"]?>
+                            </a>
+<?php
+                        }
+?>
+                        <br/><br/><br class='mobile'/><br class='mobile'/>
+                        <div id='ad_policy'>
+                            <a target='_blank' href='/ayuda/#section_ads'><?=$lng["help_ad_title"]?></a>
+                        </div>
+                    </div> <!-- .entry -->
+                </div> <!-- .section -->
+                <script type='text/javascript'>showAd();</script>
+<?php
                 //Set ad as seen
-                $_SESSION['ad'] = 1;
-            }
-            
-        }
+                $_SESSION["ad"] = 1;
+            } // if (rand (0, 3) == 0)
+
+        } // if (isset($_SESSION["ad"]) == false)
         return $id;
     }
-    
-    // Function to get visitor ip
+
+
+    /*****************************************************
+     * Finds out the IP address of the client.           *
+     *                                                   *
+     * @return: (String): Client IP address.             *
+     *****************************************************/
     function getUserIP(){
-        $client  = @$_SERVER['HTTP_CLIENT_IP'];
-        $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
-        $remote  = $_SERVER['REMOTE_ADDR'];
+        $client  = @$_SERVER["HTTP_CLIENT_IP"];
+        $forward = @$_SERVER["HTTP_X_FORWARDED_FOR"];
+        $remote  = $_SERVER["REMOTE_ADDR"];
         if(filter_var($client, FILTER_VALIDATE_IP)){
             $ip = $client;
         }
@@ -398,58 +435,72 @@
         }
         return $ip;
     }
-    
+
+
+    /*****************************************************
+     * Registers the page viewed by the user. If it is   *
+     * first page shown in his visit, it also registers  *
+     * the visit. It will also increase the ad views     *
+     * count (if any was shown).                         *
+     *                                                   *
+     * @params:                                          *
+     *    ad: (int): ID of the shown sponsor, or null.   *
+     *    ad_static: (int array): List of the IDs of the *
+     *               sponsors with statis ads.           *
+     *    section: (string): Site section being visited. *
+     *    id: (int): ID of the entri being visited       *
+     *****************************************************/
     function stats($ad, $ad_static, $section, $id){
-        
+
         // Get client data
         $ip = getUserIP();
         $browser_data = get_browser(null, true);
-        $os = $browser_data['platform'];
-        $browser = $browser_data['browser'];
-        $uagent = $browser_data['browser_name_pattern'];
+        $os = $browser_data["platform"];
+        $browser = $browser_data["browser"];
+        $uagent = $browser_data["browser_name_pattern"];
         //If bot, do nothing
         $bot_kw = Array();
-        $bot_kw[0] = 'bot';
-        $bot_kw[1] = 'spider';
-        $bot_kw[2] = 'crawl';
-        $bot_kw[3] = '.com';
-        $bot_kw[4] = '.ru';
-        $bot_kw[5] = 'baidu';
-        $bot_kw[6] = 'survey';
-        $bot_kw[7] = 'scan';
-        $bot_kw[8] = 'feed';
-        $bot_kw[9] = 'bing';
-        $bot_kw[10] = 'yahoo';
-        $bot_kw[11] = 'engine';
-        $bot_kw[12] = 'preview';
-        $bot_kw[13] = 'checker';
-        $bot_kw[14] = 'catalog';
-        $bot_kw[15] = 'accelerator';
-        $bot_kw[16] = 'python';
-        $bot_kw[14] = 'qt';
-        $bot_kw[15] = 'webdav';
-        $bot_kw[16] = 'http';
-        $bot_kw[17] = 'url';
-        $bot_kw[18] = 'fake';
-        $bot_kw[19] = 'library';
-        $bot_kw[20] = 'commerce';
-        $bot_kw[21] = 'htmlbot';
-        $bot_kw[22] = 'fetch';
-        $bot_kw[23] = 'googleb';
-        $bot_kw[24] = 'facebook';
-        $bot_kw[25] = 'whatsapp';
-        $bot_kw[26] = 'pinterest';
-        $bot_kw[27] = 'scrapy';
-        $bot_kw[28] = 'libwww';
-        $bot_kw[29] = 'java standard library';
-        $bot_kw[30] = 'default browser';
-        $bot_kw[31] = 'twingly recon';
-        $bot_kw[32] = 'siteexplorer';
-        $bot_kw[33] = 'yandex';
-        $bot_kw[34] = 'wotbox';
-        $bot_kw[35] = 'apache synapse';
-        $bot_kw[36] = 'catexplorador';
-        $bot_kw[37] = 'internet archive';
+        $bot_kw[0] = "bot";
+        $bot_kw[1] = "spider";
+        $bot_kw[2] = "crawl";
+        $bot_kw[3] = ".com";
+        $bot_kw[4] = ".ru";
+        $bot_kw[5] = "baidu";
+        $bot_kw[6] = "survey";
+        $bot_kw[7] = "scan";
+        $bot_kw[8] = "feed";
+        $bot_kw[9] = "bing";
+        $bot_kw[10] = "yahoo";
+        $bot_kw[11] = "engine";
+        $bot_kw[12] = "preview";
+        $bot_kw[13] = "checker";
+        $bot_kw[14] = "catalog";
+        $bot_kw[15] = "accelerator";
+        $bot_kw[16] = "python";
+        $bot_kw[14] = "qt";
+        $bot_kw[15] = "webdav";
+        $bot_kw[16] = "http";
+        $bot_kw[17] = "url";
+        $bot_kw[18] = "fake";
+        $bot_kw[19] = "library";
+        $bot_kw[20] = "commerce";
+        $bot_kw[21] = "htmlbot";
+        $bot_kw[22] = "fetch";
+        $bot_kw[23] = "googleb";
+        $bot_kw[24] = "facebook";
+        $bot_kw[25] = "whatsapp";
+        $bot_kw[26] = "pinterest";
+        $bot_kw[27] = "scrapy";
+        $bot_kw[28] = "libwww";
+        $bot_kw[29] = "java standard library";
+        $bot_kw[30] = "default browser";
+        $bot_kw[31] = "twingly recon";
+        $bot_kw[32] = "siteexplorer";
+        $bot_kw[33] = "yandex";
+        $bot_kw[34] = "wotbox";
+        $bot_kw[35] = "apache synapse";
+        $bot_kw[36] = "catexplorador";
+        $bot_kw[37] = "internet archive";
 
         $i = 0;
         while ($i < sizeof($bot_kw)) {
@@ -463,9 +514,9 @@
             mysqli_close($con);
             return;
         }
-        
+
         //Look for a visit with the same IP in the last 30 mins.
-        $con = startdb('rw');
+        $con = startdb("rw");
         $q = mysqli_query($con, "SELECT stat_visit.id AS visitid FROM stat_view, stat_visit WHERE visit = stat_visit.id AND dtime > DATE_SUB(now(), INTERVAL 30 MINUTE) AND ip = '$ip' AND uagent = '$uagent';");
         if (mysqli_num_rows($q) == 0){
             mysqli_query($con, "INSERT INTO stat_visit (ip, uagent, os, browser) VALUES ('$ip', '$uagent', '$os', '$browser');");
@@ -474,12 +525,12 @@
         $r = mysqli_fetch_array($q);
         $visit = $r['visitid'];
         mysqli_query($con, "INSERT INTO stat_view (visit, section, entry) VALUES ($visit, '$section', '$id');");
-        
+
         //Increase pop ad advertiser count
         if ($ad > 0){
             mysqli_query($con, "UPDATE sponsor SET print = print + 1 WHERE id = $ad;");
         }
-        
+
         if (is_array($ad_static)){
             foreach ($ad_static as $sponsor) {
                 mysqli_query($con, "UPDATE sponsor SET print_static = print_static + 1 WHERE id = $sponsor;");
@@ -487,8 +538,16 @@
         }
     }
 
+
+    /*****************************************************
+     * Recalculates the global count of statistics.      *
+     *                                                   *
+     * @params:                                          *
+     *    day: (data): Do it for the specified day, or   *
+     *         all the stats if it is null.              *
+     *****************************************************/
     function recalculateStats($day = null){
-        $con = startdb('rw');
+        $con = startdb("rw");
 
         // Visit count
         $s = "SELECT date(dtime) AS day, count(stat_visit.id) AS visit FROM stat_view, stat_visit where stat_visit.id = stat_view.visit";
@@ -527,7 +586,7 @@
                 mysqli_query($con, "INSERT INTO stat_daily_visit_browser (day, os, browser, visit) VALUES (str_to_date('$day', '%Y-%m-%d'), $r[os], $[browser], $r[visit])");
             }
         }
-        
+
     }
 ?>
-    
+

+ 24 - 20
www/header.php

@@ -1,18 +1,15 @@
-<?php $http_host = $_SERVER['HTTP_HOST']; ?>
 <div id="header" class="desktop">
     <div id="header_content">
         <img src="/img/logo/logo.png"/>
         <div id="header_menu">
             <table>
                 <tr>
-                    <td><a href="<?php echo $proto . $http_host; ?>/"><?php echo $lng['header_home'];?></a></td>
-                    <td><a href="<?php echo $proto . $http_host; ?>/lablanca/"><?php echo $lng['header_lablanca'];?></a></td>
-                    <td><a href="<?php echo $proto . $http_host; ?>/actividades/"><?php echo $lng['header_activities'];?></a></td>
-                    <td><a href="<?php echo $proto . $http_host; ?>/blog/"><?php echo $lng['header_blog'];?></a></td>
-                    <td><a href="<?php echo $proto . $http_host; ?>/nosotros/"><?php echo $lng['header_whoarewe'];?></a></td>
-                    <td><a href="<?php echo $proto . $http_host; ?>/galeria/"><?php echo $lng['header_gallery'];?></a></td>
-    <!--                 <td><a href="<?php echo $proto . $http_host; ?>/prensa/"><?php echo $lng['header_press'];?></a></td> -->
-<!--                     <td><a href="<?php echo $proto . $http_host; ?>/unete/"><?php echo $lng['header_join'];?></a></td> -->
+                    <td><a href="<?=$server?>/"><?=$lng["header_home"]?></a></td>
+                    <td><a href="<?=$server?>/lablanca/"><?=$lng["header_lablanca"]?></a></td>
+                    <td><a href="<?=$server?>/actividades/"><?=$lng["header_activities"]?></a></td>
+                    <td><a href="<?=$server?>/blog/"><?=$lng["header_blog"]?></a></td>
+                    <td><a href="<?=$server?>/nosotros/"><?=$lng["header_whoarewe"]?></a></td>
+                    <td><a href="<?=$server?>/galeria/"><?=$lng["header_gallery"]?></a></td>
                 </tr>
             </table>
         </div>
@@ -21,16 +18,23 @@
 <div id="header_m" class="mobile">
     <img src="/img/logo/logo.png" onClick='toggleMobileMenu();' id='mobile_logo'/>
     <div id="header_menu_m">
-        <div id='header_m_title' onClick='openMobileMenu();' class='pointer'><span><img src='<?php echo $proto . $http_host; ?>/img/misc/slid-menu.png'/>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $cur_section; ?></span></div>
-        <div class='header_m_link'><a href="<?php echo($proto . $http_host); ?>/"><?php echo $lng['header_home'];?></a></div>
-        <div class='header_m_link'><a href="<?php echo($proto . $http_host); ?>/lablanca/"><?php echo $lng['header_lablanca'];?></a></div>
-        <div class='header_m_link'><a href="<?php echo($proto . $http_host); ?>/actividades/"><?php echo $lng['header_activities'];?></a></div>
-        <div class='header_m_link'><a href="<?php echo($proto . $http_host); ?>/blog/"><?php echo $lng['header_blog'];?></a></div>
-        <div class='header_m_link'><a href="<?php echo($proto . $http_host); ?>/nosotros/"><?php echo $lng['header_whoarewe'];?></a></div>
-        <div class='header_m_link'><a href="<?php echo($proto . $http_host); ?>/galeria/"><?php echo $lng['header_gallery'];?></a></div>
-<!--         <div class='header_m_link'><a href="<?php echo($proto . $http_host); ?>/prensa/"><?php echo $lng['header_press'];?></a></div> -->
-<!--         <div class='header_m_link'><a href="<?php echo($proto . $http_host); ?>/unete/"><?php echo $lng['header_join'];?></a></div> -->
-        <div id='header_m_slider' onClick='closeMobileMenu();' class='pointer'><span><img src='<?php echo($proto . $http_host); ?>/img/misc/slid-top.png'/></span></div>
-    </div><br/><br/>
+        <div id='header_m_title' onClick='openMobileMenu();' class='pointer'>
+            <span>
+                <img src='<?=$server?>/img/misc/slid-menu.png'/>&nbsp;&nbsp;&nbsp;&nbsp;<?=$cur_section?>
+            </span>
+        </div>
+        <div class='header_m_link'><a href="<?=$server?>/"><?=$lng["header_home"]?></a></div>
+        <div class='header_m_link'><a href="<?=$server?>/lablanca/"><?=$lng["header_lablanca"]?></a></div>
+        <div class='header_m_link'><a href="<?=$server?>/actividades/"><?=$lng["header_activities"]?></a></div>
+        <div class='header_m_link'><a href="<?=$server?>/blog/"><?=$lng["header_blog"]?></a></div>
+        <div class='header_m_link'><a href="<?=$server?>/nosotros/"><?=$lng["header_whoarewe"]?></a></div>
+        <div class='header_m_link'><a href="<?=$server?>/galeria/"><?=$lng["header_gallery"]?></a></div>
+        <div id='header_m_slider' onClick='closeMobileMenu();' class='pointer'>
+            <span>
+                <img src='<?=$server?>/img/misc/slid-top.png'/>
+            </span>
+        </div>
+    </div>
+    <br/><br/>
 </div>
 

+ 5 - 5
www/index.php

@@ -388,7 +388,7 @@
                                 </div> <!-- festivals_schedule_cell -->
                             </div> <!-- festivals_schedule_row -->
                         </div> <!-- festivals_schedule_table -->
-                        <a class='go_to_section' href='<?=server?>/lablanca/'><?=$lng['index_festivals_link']?></a>
+                        <a class='go_to_section' href='<?=$server?>/lablanca/'><?=$lng["index_festivals_link"]?></a>
                         <br/>
                     </div> <!-- festivals - section-->
 <?php
@@ -552,9 +552,9 @@
 ?>
                                         <div class='entry post' itemscope itemtype='http://schema.org/BlogPosting'>
                                             <meta itemprop='inLanguage' content='<?=$lang?>'/>
-                                            <meta itemprop='datePublished dateModified' content='<?=$r_post['isodate']?>'/>
-                                            <meta itemprop='headline name' content='<?=$r_post['title']?>'/>
-                                            <meta itemprop='articleBody text' content='<?=$r_post[text]?>'/>
+                                            <meta itemprop='datePublished dateModified' content='<?=$r_post["isodate"]?>'/>
+                                            <meta itemprop='headline name' content='<?=$r_post["title"]?>'/>
+                                            <meta itemprop='articleBody text' content='<?=$r_post["text"]?>'/>
                                             <meta itemprop='mainEntityOfPage' content='<?=$server?>'/>
                                             <div class='hidden' itemprop='author publisher' itemscope itemtype='http://schema.org/Organization'>
                                                 <meta itemprop='legalName' content='Asociaci&oacute;n Cultural Recreativa Gasteizko Margolariak'/>
@@ -617,7 +617,7 @@
                                                     <td itemscope itemtype='http://schema.org/Photograph'>
                                                         <meta itemprop='datePublished' content='<?=$r_photos['isodate']?>'/>
                                                         <a href='$server/galeria/<?=$r_album['permalink']?>'>
-                                                            <meta itemprop='image' content='<?=$serve?>/img/galeria/<?=$r_photos['file']?>'/>
+                                                            <meta itemprop='image' content='<?=$server?>/img/galeria/<?=$r_photos["file"]?>'/>
                                                             <img src='<?=$server?>/img/galeria/miniature/<?=$r_photos['file']?>' alt='<?=$r_photos['title']?>' />
                                                         </a>
                                                     </td>

+ 8 - 71
www/lablanca/fiestas.php

@@ -18,78 +18,15 @@
     <div class='content_tr'>
         <div class='content_td' id='content_td_schedule'>
             <div class='section' id='schedule'>
-                <h3 class='section_title'><?=$lng['lablanca_schedule']?></h3>
-<?php
-                $q_days = mysqli_query($con, "SELECT DISTINCT date(DATE_SUB(start, INTERVAL 6 HOUR)) AS date, DATE_FORMAT(DATE_SUB(start, INTERVAL 6 HOUR), '%Y-%m-%d') AS isodate, (SELECT name_$lang from festival_day WHERE date = date(DATE_SUB(start, INTERVAL 6 HOUR))) AS name FROM festival_event WHERE year(start) = 2017 AND gm = 1 ORDER BY date");
-                $i=0;
-                while ($r_days = mysqli_fetch_array($q_days)){
-?>
-                    <div class='entry'>
-                        <div onClick='expandDay(<?=$i?>);' class='day_title pointer'>
-                            <h4>
-                                <img class='slid' src='<?=$server?>/img/misc/slid-right.png' id='slid_day_<?=$i?>'/>
-<?php
-                                if($r_days['name'] != null){
-?>
-                                    <?=formatFestivalDate($r_days['date'])?> - <?=$r_days['name']?>
-<?php
-                                }
-                                else{
-?>
-                                    <?=formatFestivalDate($r_days['date'])?>
-<?php
-                                }
-?>
-                            </h4>
-                        </div>
-                        <div class='day_schedule' id='day_schedule_<?=$i?>'>
-<?php
-                            $q_sch = mysqli_query($con, "SELECT festival_event.id AS id, gm, title_$lang AS title, description_$lang AS description, host, place, date_format(start, '%H:%i') AS st, date_format(end, '%H:%i') AS end, place.name_$lang AS place, address_$lang AS address, lat, lon FROM festival_event, place WHERE place.id = festival_event.place AND gm = 1 AND date(DATE_SUB(start, INTERVAL 6 HOUR)) = str_to_date('$r_days[date]', '%Y-%m-%d') ORDER BY start");
-                            if (mysqli_num_rows($q_sch) > 0){
-                                echo("<table class='schedule'>\n");
-                                while ($r_sch = mysqli_fetch_array($q_sch)){
-?>
-                                    <tr>
-                                        <td>
-                                            <span class='time'><?=$r_sch['st']?></span>
-                                        </td>
-                                        <td class='timeline'>
-                                            <img class='timeline_dot' alt=' ' src='<?=$server?>/img/misc/schedule-point.png'/>
-                                        </td>
-                                        <td>
-                                            <span class='title'><?=$r_sch['title']?></span>
-<?php
-                                            if (strlen($r_sch["description"]) > 0 && $r_sch["description"] != $r_sch["title"]){
-                                                echo("<br/><div class='description'>$r_sch[description]</div>\n");
-                                            }
-?>
-                                            <div class='location'>
-                                                <a target='_blank' href='http://maps.google.com/maps?q=<?=$r_sch['lat']?>,<?=$r_sch['lon']?>+(My+Point)&z=14&ll=<?=$r_sch['lat']?>,<?=$r_sch['lon']?>'>
-                                                    <img alt=' ' src='<?=$server?>/img/misc/pinpoint.png'/>
-<?php
-                                                    //If name and address are the same, show only name
-                                                    if ($r_sch['place'] == $r_sch['address']){
-                                                        echo("$r_sch[place]\n");
-                                                    }
-                                                    else{
-                                                        echo("$r_sch[place] <span class='address'>- $r_sch[address]</span>\n");
-                                                    }
-?>
-                                                </a>
-                                            </div>
-                                        </td>
-                                    </tr>
-<?php
-                                }
-                                echo "</table>\n";
-                            }
-?>
-                        </div>
+                <h3 class='section_title'><?=$lng['lablanca_schedules']?></h3>
+                <div class='entry'>
+                    <div class='button'>
+                        <a href='<?=$server?>/lablanca/programa/margolariak/<?=$year?>'><?=str_replace('#', $year, $lng["lablanca_schedule_year_gm"])?></a>
                     </div>
-<?php
-                    $i ++;
-                } // while ($r_days = mysqli_fetch_array($q_days))
-?>
+                    <div class='button'>
+                        <a href='<?=$server?>/lablanca/programa/ciudad/<?=$year?>'><?=str_replace('#', $year, $lng["lablanca_schedule_year_city"])?></a>
+                    </div>
+                </div> <!-- .entry -->
             </div>
         </div>
         <div class='content_td' id='content_td_prices'>

+ 189 - 0
www/lablanca/programa.php

@@ -0,0 +1,189 @@
+<?php
+    session_start();
+    include("../functions.php");
+    $con = startdb();
+    $proto = getProtocol();
+    $http_host = $_SERVER['HTTP_HOST'];
+    $server = "$proto" . "$http_host";
+    $gm = $_GET["gm"];
+
+    if (isset($_GET["y"]) && intval($_GET["y"]) > 2013 && intval($_GET["y"]) <= date("Y")){
+        $year = $_GET["y"];
+    }
+    else{
+        $year = date("Y");
+    }
+
+    if ($gm == 1 || $gm == "margolari" || $gm == "margolariak"){
+        $gm = 1;
+        $schi = "gm";
+        $url = "margolariak";
+    }
+    elseif ($gm == 0 || $gm == "municipal" || $gm == "ciudad"){
+        $gm = 0;
+        $schi = "city";
+        $url = "municipal";
+    }
+    else{
+        header("Location: $server/lablanca/programa/margolariak/$year");
+    }
+
+    //Language
+    $lang = selectLanguage();
+    include("../lang/lang_" . $lang . ".php");
+
+    $cur_section = $lng['section_lablanca'];
+
+?>
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
+        <meta charset="utf-8"/>
+        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <title>
+            <?=str_replace('#', $year, $lng["lablanca_schedule_year_" . $schi])?> - Gasteizko Margolariak
+        </title>
+        <link rel="shortcut icon" href="<?=$server?>/img/logo/favicon.ico">
+        <!-- CSS files -->
+        <style>
+<?php
+            include("../css/ui.css");
+            include("../css/lablanca.css");
+?>
+        </style>
+        <!-- CSS for mobile version -->
+        <style media="(max-width : 990px)">
+<?php
+            include("../css/m/ui.css");
+            include("../css/m/lablanca.css");
+?>
+        </style>
+        <!-- Script files -->
+        <script type="text/javascript">
+<?php
+            include("../script/ui.js");
+            include("../script/lablanca.js");
+?>
+        </script>
+        <!-- Meta tags -->
+        <link rel="canonical" href="<?=$server?>/lablanca/programa/<?=$url?>/<?=$year?>"/>
+        <link rel="author" href="<?=$server?>"/>
+        <link rel="publisher" href="<?=$server?>"/>
+        <meta name="description" content="<?=str_replace('#', $year, $lng["lablanca_schedule_year_" . $schi . "_description"])?>"/>
+        <meta property="og:title" content="<?=str_replace('#', $year, $lng["lablanca_schedule_year_" . $schi])?> - Gasteizko Margolariak"/>
+        <meta property="og:url" content="<?=$server?>/lablanca/programa/<?=$url?>/<?=$year?>"/>
+        <meta property="og:description" content="<?=str_replace('#', $year, $lng["lablanca_schedule_year_" . $schi . "_description"])?>"/>
+        <meta property="og:image" content="<?=$server?>/img/logo/logo.png"/>
+        <meta property="og:site_name" content="Gasteizko Margolariak"/>
+        <meta property="og:type" content="website"/>
+        <meta property="og:locale" content="<?=$lang?>"/>
+        <meta name="twitter:card" content="summary"/>
+        <meta name="twitter:title" content="<?=str_replace('#', $year, $lng["lablanca_schedule_year_" . $schi])?> - Gasteizko Margolariak"/>
+        <meta name="twitter:description" content="<?=str_replace('#', $year, $lng["lablanca_schedule_year_" . $schi . "_description"])?>"/>
+        <meta name="twitter:image" content="<?=$server?>/img/logo/logo.png"/>
+        <meta name="twitter:url" content="<?=$server?>/lablanca/programa/<?=$url?>/<?=$year?>"/>
+        <meta name="robots" content="index follow"/>
+    </head>
+    <body>
+        <?php include("../header.php"); ?>
+        <div id="content">
+            <div class='section' id='schedule'>
+                <h3 class='section_title'><?=str_replace('#', $year, $lng["lablanca_schedule_year_" . $schi])?></h3>
+<?php
+                $q_days = mysqli_query($con, "SELECT DISTINCT date(DATE_SUB(start, INTERVAL 6 HOUR)) AS date, DATE_FORMAT(DATE_SUB(start, INTERVAL 6 HOUR), '%Y-%m-%d') AS isodate, (SELECT name_$lang FROM festival_day WHERE date = date(DATE_SUB(start, INTERVAL 6 HOUR))) AS name FROM festival_event_$schi WHERE year(start) = 2017 ORDER BY date");
+                $i=0;
+                while ($r_days = mysqli_fetch_array($q_days)){
+?>
+                    <div class='entry'>
+                        <div onClick='expandDay(<?=$i?>);' class='day_title pointer'>
+                            <h4>
+                                <img class='slid' src='<?=$server?>/img/misc/slid-right.png' id='slid_day_<?=$i?>'/>
+<?php
+                                if($gm == 1 && $r_days['name'] != null){
+?>
+                                    <?=formatFestivalDate($r_days['date'])?> - <?=$r_days['name']?>
+<?php
+                                }
+                                else{
+?>
+                                    <?=formatFestivalDate($r_days['date'])?>
+<?php
+                                }
+?>
+                            </h4>
+                        </div>
+                        <div class='day_schedule' id='day_schedule_<?=$i?>'>
+<?php
+                            $q_sch = mysqli_query($con, "SELECT festival_event_$schi.id AS id, title_$lang AS title, description_$lang AS description, host, place, date_format(start, '%H:%i') AS st, date_format(end, '%H:%i') AS end, place.name_$lang AS place, address_$lang AS address, lat, lon FROM festival_event_$schi, place WHERE place.id = festival_event_$schi.place AND date(DATE_SUB(start, INTERVAL 6 HOUR)) = str_to_date('$r_days[date]', '%Y-%m-%d') ORDER BY start");
+                            if (mysqli_num_rows($q_sch) > 0){
+                                echo("<table class='schedule'>\n");
+                                while ($r_sch = mysqli_fetch_array($q_sch)){
+?>
+                                    <tr>
+                                        <td>
+                                            <span class='time'><?=$r_sch['st']?></span>
+                                        </td>
+                                        <td class='timeline'>
+                                            <img class='timeline_dot' alt=' ' src='<?=$server?>/img/misc/schedule-point.png'/>
+                                        </td>
+                                        <td>
+                                            <span class='title'><?=$r_sch['title']?></span>
+<?php
+                                            if (strlen($r_sch["description"]) > 0 && $r_sch["description"] != $r_sch["title"]){
+?>
+                                                <br/>
+                                                <div class='description'><?=$r_sch["description"]?></div>
+<?php
+                                            }
+?>
+                                            <div class='location'>
+                                                <!--<a target='_blank' href='http://maps.google.com/maps?q=<?=$r_sch['lat']?>,<?=$r_sch['lon']?>+(My+Point)&z=14&ll=<?=$r_sch['lat']?>,<?=$r_sch['lon']?>'>-->
+                                                <!-- TODO Routes -->
+                                                <span class='fake_a pointer' onClick='showMapPoint(<?=$r_sch['lat']?>,<?=$r_sch['lon']?>);'>
+                                                    <img alt=' ' src='<?=$server?>/img/misc/pinpoint.png'/>
+<?php
+                                                    //If name and address are the same, show only name
+                                                    if ($r_sch["place"] == $r_sch["address"]){
+?>
+                                                        <?=$r_sch["place"]?>
+<?php
+                                                    }
+                                                    else{
+?>
+                                                        <?=$r_sch["place"]?>
+                                                        <span class='address'> - <?=$r_sch["address"]?></span>
+<?php
+                                                    }
+?>
+                                                </span>
+                                            </div>
+                                        </td>
+                                    </tr>
+<?php
+                                }
+?>
+                                </table>
+<?php
+                            }
+?>
+                        </div>
+                    </div>
+<?php
+                    $i ++;
+                } // while ($r_days = mysqli_fetch_array($q_days))
+?>
+            </div>
+            <div id='map_container'>
+                <div id='map'>
+                    <!-- TODO: OSM -->
+                </div> <!-- map -->
+            </div> <!-- .map_container -->
+        </div> <!-- #content -->
+<?php
+            include("../footer.php");
+            $ad = ad($con, $lang, $lng);
+            stats($ad, $ad_static, "fiestas", "");
+?>
+    </body>
+</html>

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
www/lang/lang_en.php


Разлика између датотеке није приказан због своје велике величине
+ 7 - 7
www/lang/lang_es.php


Разлика између датотеке није приказан због своје велике величине
+ 2 - 2
www/lang/lang_eu.php


+ 25 - 5
www/script/lablanca.js

@@ -3,15 +3,35 @@ function expand(year){
 }
 
 function expandDay(id){
-    if (document.getElementById('day_schedule_' + id).style.maxHeight == '120em'){
+    if (document.getElementById('day_schedule_' + id).style.maxHeight != '' && document.getElementById('day_schedule_' + id).style.maxHeight != '0em'){
         document.getElementById('day_schedule_' + id).style.maxHeight = '0em';
         setTimeout(function(){document.getElementById('slid_day_' + id).src = '/img/misc/slid-right.png';}, 500);
     }
     else{
-        document.getElementById('day_schedule_' + id).style.maxHeight = '120em';
+        document.getElementById('day_schedule_' + id).style.maxHeight = 'initial';
         setTimeout(function(){document.getElementById('slid_day_' + id).src = '/img/misc/slid-down.png';}, 500);
     }
     document.getElementById('slid_day_' + id).style.opacity = '0';
-    setTimeout(function(){document.getElementById('slid_day_' + id).style.opacity = '1';}, 500);
-    
-}
+    setTimeout(function(){document.getElementById('slid_day_' + id).style.opacity = '1';}, 500); 
+}
+
+function hideMap(){
+    document.getElementById('map_container').style.opacity = 0;
+    document.getElementById('map_container').style.display = 'none';
+}
+
+function showMap(){
+    document.getElementById('map_container').style.display = 'block';
+    document.getElementById('map_container').style.opacity = 1;
+    return document.getElementById('map');
+}
+
+function showMapRoute(route){
+    map = showMap();
+    //TODO: OSM
+}
+
+function showMapPoint(lat, lon){
+    map = showMap();
+    //TODO: OSM
+}

+ 192 - 117
www/sitemap.php

@@ -4,178 +4,253 @@
     include("functions.php");
     $con = startdb();
     $proto = getProtocol();
-    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+    $server = "$proto$http_host";
 ?>
+<?xml version="1.0" encoding="UTF-8"?>
 <urlset
     xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
     xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
     <url>
-        <loc><?php echo $proto$http_host; ?>/</loc>
-        <?php
-            $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;");
-            $row_date = mysqli_fetch_array($res_date);
-        ?><lastmod><?php echo $row_date['cdate']; ?></lastmod>
+        <loc><?=$server?>/</loc>
+<?php
+        $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;");
+        $row_date = mysqli_fetch_array($res_date);
+?>
+        <lastmod><?=$row_date["cdate"]?></lastmod>
         <changefreq>weekly</changefreq>
         <priority>0.8</priority>
         <image:image>
-            <image:loc><?php echo $proto$http_host; ?>/img/logo/GasteizkoMargolariak.png</image:loc>
+            <image:loc><?=$server?>/img/logo/GasteizkoMargolariak.png</image:loc>
             <image:caption>Gasteizko Margolariak</image:caption>
             <image:title>Gasteizko Margolariak</image:title>
         </image:image>
         <image:image>
-            <image:loc><?php echo $proto$http_host; ?>/img/logo/GasteizkoMargolariak-0.png</image:loc>
+            <image:loc><?=$server?>/img/logo/GasteizkoMargolariak-0.png</image:loc>
             <image:caption>Gasteizko Margolariak Original</image:caption>
             <image:title>Gasteizko Margolariak Original</image:title>
         </image:image>
     </url>
     <url>
-        <loc><?php echo $proto$http_host; ?>/ayuda/</loc>
+        <loc><?=$server?>/ayuda/</loc>
         <changefreq>monthly</changefreq>
         <priority>0.5</priority>
     </url>
     <url>
-        <loc><?php echo $proto$http_host; ?>/nosotros/</loc>
+        <loc><?=$server?>/nosotros/</loc>
         <changefreq>monthly</changefreq>
         <priority>0.6</priority>
     </url>
     <url>
-        <loc><?php echo $proto$http_host; ?>/blog/</loc>
-        <?php
-            $res_date = mysqli_query($con, "SELECT DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM post ORDER BY cdate DESC LIMIT 1;");
-            $row_date = mysqli_fetch_array($res_date);
-        ?><lastmod><?php echo $row_date['cdate']; ?></lastmod>
+        <loc><?=$server?>/blog/</loc>
+<?php
+        $res_date = mysqli_query($con, "SELECT DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM post ORDER BY cdate DESC LIMIT 1;");
+        $row_date = mysqli_fetch_array($res_date);
+?>
+        <lastmod><?=$row_date["cdate"]?></lastmod>
         <changefreq>weekly</changefreq>
         <priority>0.8</priority>
     </url>
-    <?php
-        $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;");
-        $priority = 0.75;
-        while ($row_post = mysqli_fetch_array($res_post)){
-            echo "\t<url>\n";
-            echo "\t\t<loc>$proto$http_host/blog/$row_post[permalink]</loc>\n";
-            echo "\t\t<lastmod>$row_post[cdate]</lastmod>\n";
-            echo "\t\t<changefreq>weekly</changefreq>\n";
-            echo "\t\t<priority>$priority</priority>\n";
+<?php
+    $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;");
+    $priority = 0.75;
+    while ($row_post = mysqli_fetch_array($res_post)){
+?>
+        <url>
+            <loc><?=$server?>/blog/<?=$row_post["permalink"]?></loc>
+            <lastmod><?=$row_post["cdate"]?></lastmod>
+            <changefreq>weekly</changefreq>
+            <priority><?=$priority?></priority>
+<?php
             $q_i = mysqli_query($con, "SELECT image FROM post_image WHERE post = $row_post[id] ORDER BY idx;");
             while ($r_i = mysqli_fetch_array($q_i)){
-                echo("\t\t<image:image>\n");
-                echo("\t\t\t<image:loc>$proto$http_host/img/blog/view/$r_i[image]</image:loc>\n");
-                echo("\t\t\t<image:title>$row_post[title_es]</image:title>\n");
-                echo("\t\t</image:image>\n");
-            } 
-            echo "\t</url>\n";
-            $priority = $priority - 0.05;
-            if ($priority < 0.45)
-                $priority = 0.45;
+?>
+                <image:image>
+                    <image:loc><?=$server?>/img/blog/view/<?=$r_i["image"]?></image:loc>
+                    <image:title><?=$row_post["title_es"]?></image:title>
+                </image:image>
+<?php
+            }
+?>
+        </url>
+<?php
+        $priority = $priority - 0.05;
+        if ($priority < 0.45){
+            $priority = 0.45;
         }
-    ?>
+    }
+?>
     <url>
-        <loc><?php echo $proto$http_host; ?>/actividades/</loc>
-        <?php
-            $res_date = mysqli_query($con, "SELECT DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM activity ORDER BY cdate DESC LIMIT 1;");
-            $row_date = mysqli_fetch_array($res_date);
-        ?><lastmod><?php echo $row_date['cdate']; ?></lastmod>
+        <loc><?=$server?>/actividades/</loc>
+<?php
+        $res_date = mysqli_query($con, "SELECT DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM activity ORDER BY cdate DESC LIMIT 1;");
+        $row_date = mysqli_fetch_array($res_date);
+?>
+        <lastmod><?=$row_date["cdate"]?></lastmod>
         <changefreq>weekly</changefreq>
         <priority>1</priority>
     </url>
-    <?php
-        $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;");
-        $priority = 0.95;
-        while ($row = mysqli_fetch_array($res)){
-            echo "\t<url>\n";
-            echo "\t\t<loc>$proto$http_host/actividades/$row[permalink]</loc>\n";
-            echo "\t\t<lastmod>$row[cdate]</lastmod>\n";
-            echo "\t\t<changefreq>weekly</changefreq>\n";
-            echo "\t\t<priority>$priority</priority>\n";
+<?php
+    $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;");
+    $priority = 0.95;
+    while ($row = mysqli_fetch_array($res)){
+?>
+        <url>
+            <loc><?=$server?>/actividades/<?=$row["permalink"]?></loc>
+            <lastmod><?=$row["cdate"]?></lastmod>
+            <changefreq>weekly</changefreq>
+            <priority><?=$priority?></priority>
+<?php
             $q_i = mysqli_query($con, "SELECT image FROM activity_image WHERE activity = $row[id] ORDER BY idx;");
             while ($r_i = mysqli_fetch_array($q_i)){
-                echo("\t\t<image:image>\n");
-                echo("\t\t\t<image:loc>$proto$http_host/img/actividades/view/$r_i[image]</image:loc>\n");
-                echo("\t\t\t<image:title>$row[title_es]</image:title>\n");
-                echo("\t\t</image:image>\n");
-            } 
-            echo "\t</url>\n";
-            $priority = $priority - 0.05;
-            if ($priority < 0.65)
-                $priority = 0.65;
+?>
+                <image:image>
+                    <image:loc><?=$server?>/img/actividades/view/<?=$r_i["image"]?></image:loc>
+                    <image:title><?=$row_post["title_es"]?></image:title>
+                </image:image>
+<?php
+            }
+?>
+        </url>
+<?php
+        $priority = $priority - 0.05;
+        if ($priority < 0.65){
+            $priority = 0.65;
         }
-    ?>
+    }
+?>
     <url>
-        <loc><?php echo $proto$http_host; ?>/galeria/</loc>
-        <?php
-            $res_date = mysqli_query($con, "SELECT DATE_FORMAT(uploaded, '%Y-%m-%d') AS cdate FROM photo ORDER BY cdate DESC LIMIT 1;");
-            $row_date = mysqli_fetch_array($res_date);
-        ?><lastmod><?php echo $row_date['cdate']; ?></lastmod>
+        <loc><?=$server?>/galeria/</loc>
+<?php
+        $res_date = mysqli_query($con, "SELECT DATE_FORMAT(uploaded, '%Y-%m-%d') AS cdate FROM photo ORDER BY cdate DESC LIMIT 1;");
+        $row_date = mysqli_fetch_array($res_date);
+?>
+        <lastmod><?=$row_date["cdate"]?></lastmod>
         <changefreq>weekly</changefreq>
         <priority>0.8</priority>
     </url>
-    <?php
-        $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;");
-        $priority = 0.75;
-        while ($row = mysqli_fetch_array($res)){
-            echo "\t<url>\n";
-            echo "\t\t<loc>$proto$http_host/galeria/$row[permalink]</loc>\n";
-            echo "\t\t<lastmod>$row[cdate]</lastmod>\n";
-            echo "\t\t<changefreq>weekly</changefreq>\n";
-            echo "\t\t<priority>$priority</priority>\n";
+<?php
+    $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;");
+    $priority = 0.75;
+    while ($row = mysqli_fetch_array($res)){
+?>
+        <url>
+            <loc><?=$server?>/galeria/<?=$row["permalink"]?></loc>
+            <lastmod><?=$row["cdate"]?></lastmod>
+            <changefreq>weekly</changefreq>
+            <priority><?=$priority?></priority>
+<?php
             $q_i = mysqli_query($con, "SELECT file, title_es FROM photo, photo_album WHERE id = photo AND album = $row[albumid];");
             while ($r_i = mysqli_fetch_array($q_i)){
-                echo("\t\t<image:image>\n");
-                echo("\t\t\t<image:loc>$proto$http_host/img/galeria/view/$r_i[file]</image:loc>\n");
-                if (strlen($r_i['title_es']) > 0){
-                    echo("\t\t\t<image:title>$r_i[title_es]</image:title>\n");
-                }
-                else{
-                    echo("\t\t\t<image:title>$row[title]</image:title>\n");
-                }
-                echo("\t\t</image:image>\n");
-            } 
-            echo "\t</url>\n";
-            $priority = $priority - 0.05;
-            if ($priority < 0.45)
-                $priority = 0.45;
+?>
+                <image:image>
+                <image:loc><?=$server?>/img/galeria/view/<?=$r_i["file"]?></image:loc>
+<?php
+                    if (strlen($r_i['title_es']) > 0){
+?>
+                        <image:title><?=$r_i["title_es"]?></image:title>
+<?php
+                    }
+                    else{
+?>
+                        <image:title><?=$row["title"]?></image:title>
+<?php
+                    }
+?>
+                </image:image>
+<?php
+            }
+?>
+        </url>
+<?php
+        $priority = $priority - 0.05;
+        if ($priority < 0.45){
+            $priority = 0.45;
         }
-    ?>
+    }
+?>
     <url>
-        <loc><?php echo $proto$http_host; ?>/lablanca/</loc>
-        <?php
-            $res_lb = mysqli_query($con, 'SELECT value FROM settings WHERE name= "festivals";');
-            if (mysqli_num_rows($res_lb) > 0){
-                $r_lb = mysqli_fetch_array($res_lb);
-                if ($r_lb['value'] == 1){
-                    echo "<changefreq>daily</changefreq>\n";
-                    echo "\t\t<priority>1</priority>\n";
-                }
-                else{
-                    echo "<changefreq>monthly</changefreq>\n";
-                    echo "\t\t<priority>0.5</priority>\n";
-                }
+        <loc><?=$server?>/lablanca/</loc>
+<?php
+        $res_lb = mysqli_query($con, 'SELECT value FROM settings WHERE name= "festivals";');
+        if (mysqli_num_rows($res_lb) > 0){
+            $r_lb = mysqli_fetch_array($res_lb);
+            if ($r_lb["value"] == 1){
+?>
+                <changefreq>daily</changefreq>
+                <priority>1</priority>
+<?php
             }
             else{
-                echo "<changefreq>monthly</changefreq>\n";
-                echo "\t\t<priority>0.5</priority>\n";
+?>
+                <changefreq>monthly</changefreq>
+                <priority>0.5</priority>
+<?php
             }
-        ?>
+        }
+        else{
+?>
+            <changefreq>monthly</changefreq>
+            <priority>0.5</priority>
+<?php
+        }
+?>
     </url>
-    <?php
+<?php
         $year = date("Y");
         $res_years = mysqli_query($con, "SELECT img, year FROM festival ORDER BY year DESC;");
         $priority = 0.55;
         while ($row_years = mysqli_fetch_array($res_years)){
-            echo "\t<url>\n";
-            echo "\t\t<loc>$proto$http_host/lablanca/$row_years[year]</loc>\n";
-            echo "\t\t<changefreq>yearly</changefreq>\n";
-            echo "\t\t<priority>$priority</priority>\n";
-            if (strlen($row_years['img']) > 0){
-                echo("\t\t<image:image>\n");
-                echo("\t\t\t<image:loc>$proto$http_host/img/fiestas/view/$row_years[img]</image:loc>\n");
-                echo("\t\t\t<image:title>La Blanca $row_years[year]</image:title>\n");
-                echo("\t\t</image:image>\n");
+?>
+            <url>
+                <loc><?=$server?>/lablanca/<?=$row_years["year"]?></loc>
+                <changefreq>yearly</changefreq>
+                <priority><?=$priority?></priority>
+<?php
+                if (strlen($row_years["img"]) > 0){
+?>
+                    <image:image>
+                        <image:loc><?=$server?>/img/fiestas/view/<?$row_years["img"]?></image:loc>
+                        <image:title>La Blanca <?=$row_years["year"]?></image:title>
+                    </image:image>
+<?php
+            }
+?>
+            </url>
+            <url>
+                <loc><?=$server?>/lablanca/programa/margolariak/<?=$row_years["year"]?></loc>
+                <changefreq>yearly</changefreq>
+                <priority><?=($priority + 0.3)?></priority>
+<?php
+                if (strlen($row_years["img"]) > 0){
+?>
+                    <image:image>
+                        <image:loc><?=$server?>/img/fiestas/view/<?=$row_years["img"]?></image:loc>
+                        <image:title>La Blanca <?=$row_years["year"]?></image:title>
+                    </image:image>
+<?php
+            }
+?>
+            </url>
+            <url>
+                <loc><?=$server?>/lablanca/programa/municipal/<?=$row_years["year"]?></loc>
+                <changefreq>yearly</changefreq>
+                <priority><?=($priority + 0.1)?></priority>
+<?php
+                if (strlen($row_years["img"]) > 0){
+?>
+                    <image:image>
+                        <image:loc><?=$server?>/img/fiestas/view/<?=$row_years["img"]?></image:loc>
+                        <image:title>La Blanca <?=$row_years["year"]?></image:title>
+                    </image:image>
+<?php
             }
-            echo "\t</url>\n";
+?>
+            </url>
+<?php
             $priority = $priority - 0.05;
-            if ($priority < 0.40)
+            if ($priority < 0.40){
                 $priority = 0.40;
-        }
-    ?>
+            }
+        } // while ($row_years = mysqli_fetch_array($res_years))
+?>
 </urlset>

Неке датотеке нису приказане због велике количине промена