post.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <?php
  2. $http_host = $_SERVER['HTTP_HOST'];
  3. include("../functions.php");
  4. $con = startdb();
  5. $proto = getProtocol();
  6. //Language
  7. $lang = selectLanguage();
  8. include("../lang/lang_" . $lang . ".php");
  9. $cur_section = $lng['section_blog'];
  10. // Get current post id. Redirect if inexistent or invisible
  11. $perm = mysqli_real_escape_string($con, $_GET['perm']);
  12. $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;");
  13. if (mysqli_num_rows($q) == 0){
  14. header("Location: $proto$http_host/blog/");
  15. exit(-1);
  16. }
  17. $r = mysqli_fetch_array($q);
  18. $id = $r['id'];
  19. ?>
  20. <!DOCTYPE html>
  21. <html>
  22. <head>
  23. <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
  24. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
  25. <title><?php echo $r["title"] . " - Gasteizko Margolariak"; ?></title>
  26. <link rel="shortcut icon" href="<?php echo "$proto$http_host/img/logo/favicon.ico";?>">
  27. <!-- CSS files -->
  28. <style>
  29. <?php
  30. include("../css/ui.css");
  31. include("../css/blog.css");
  32. ?>
  33. </style>
  34. <!-- CSS for mobile version -->
  35. <style media="(max-width : 990px)">
  36. <?php
  37. include("../css/m/ui.css");
  38. include("../css/m/blog.css");
  39. ?>
  40. </style>
  41. <!-- Script files -->
  42. <script type="text/javascript">
  43. <?php
  44. include("../script/ui.js");
  45. include("../script/blog.js");
  46. ?>
  47. </script>
  48. <!-- Meta tags -->
  49. <link rel="canonical" href="<?php echo "$proto$http_host/blog/" . $r['permalink']; ?>"/>
  50. <link rel="author" href="<?php echo "$proto$http_host"; ?>"/>
  51. <link rel="publisher" href="<?php echo "$proto$http_host"; ?>"/>
  52. <meta name="description" content="<?php echo strip_tags($r["text"]);?>"/>
  53. <meta property="og:title" content="<?php echo $r["title"] . " - Gasteizko Margolariak"; ?>"/>
  54. <meta property="og:url" content="<?php echo "$proto$http_host/blog/" . $r['permalink']; ?>"/>
  55. <meta property="og:description" content="<?php echo strip_tags($r["text_$lang"]);?>"/>
  56. <?php
  57. $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id ORDER BY idx;");
  58. if (mysqli_num_rows($q_image) == 0)
  59. $img = "$proto$http_host/img/logo/cover.png";
  60. else{
  61. $r_image = mysqli_fetch_array($q_image);
  62. $img = "$proto$http_host/img/blog/preview/" . $r_image['image'];
  63. }
  64. ?>
  65. <meta property="og:image" content="<?php echo $img;?>"/>
  66. <meta property="og:site_name" content="Gasteizko Margolariak"/>
  67. <meta property="og:type" content="article"/>
  68. <meta property="og:locale" content="<?php echo $lang;?>"/>
  69. <meta property="article:section" content="Blog"/>
  70. <!-- TODO: Review time format -->
  71. <meta property="article:published-time" content="<?php echo $r['time'];?>"/>
  72. <meta property="article:modified-time" content="<?php echo $r['time'];?>"/>
  73. <meta property="article:author" content="Gasteizko Margolariak"/>
  74. <?php
  75. $q_tag = mysqli_query($con, "SELECT tag FROM post_tag WHERE post = $id;");
  76. $tag_string = "vitoria cuadrilla gasteizko margolariak ";
  77. while ($r_tag = mysqli_fetch_array($q_tag))
  78. $tag_string = $tag_string . " " . $r_tag['tag']
  79. ?>
  80. <meta property="article:tag" content="<?php echo $tag_string ?>"/>
  81. <meta name="twitter:card" content="summary"/>
  82. <meta name="twitter:title" content="<?php echo $r["title"] . " - Gasteizko Margolariak";?>"/>
  83. <meta name="twitter:description" content="<?php echo strip_tags($r["text"]);?>"/>
  84. <meta name="twitter:image" content="<?php echo $img;?>"/>
  85. <meta name="twitter:url" content="<?php echo "$proto$http_host/blog/$r[permalink]"; ?>"/>
  86. <meta name="robots" content="index follow"/>
  87. </head>
  88. <body>
  89. <?php include("../header.php"); ?>
  90. <div id="content">
  91. <?php include("common/leftpanel.php"); ?>
  92. <div id="middle_column">
  93. <?php
  94. echo "<div itemscope itemtype='http://schema.org/BlogPosting' class='section blog_entry'>\n";
  95. echo "<meta itemprop='inLanguage' content='$lang'/>\n";
  96. echo "<meta itemprop='datePublished dateModified' content='$r[isodate]'/>\n";
  97. echo "<meta itemprop='headline name' content='$r[title]'/>\n";
  98. echo "<meta itemprop='mainEntityOfPage' content='$proto$http_host'/>\n";
  99. echo "<div class='hidden' itemprop='author publisher' itemscope itemtype='http://schema.org/Organization'>\n";
  100. echo "<meta itemprop='legalName' content='Asociaci&oacute;n Cultural Recreativa Gasteizko Margolariak'/>\n";
  101. echo "<meta itemprop='name' content='Gasteizko Margolariak'/>\n";
  102. echo "<meta itemprop='logo' content='$proto$http_host/img/logo/logo.png'/>\n";
  103. echo "<meta itemprop='foundingDate' content='03-02-2013'/>\n";
  104. echo "<meta itemprop='telephone' content='+34637140371'/>\n";
  105. echo "<meta itemprop='url' content='$proto$http_host'/>\n";
  106. echo "</div>\n";
  107. echo("<h3 class='section_title'>$r[title]</h3>\n");
  108. echo("<div class='entry'>\n");
  109. if ($r_image != null){
  110. echo "<div class='image_container'>\n";
  111. echo "<meta itemprop='image' content='$proto$http_host/img/blog/$r_image[image]'/>\n";
  112. echo "<img class='post_image post_image_large' alt='$r[title]' src='/img/blog/preview/$r_image[image]'/>\n";
  113. echo "</div>\n";
  114. }
  115. echo "<p itemprop='text articleBody'>$r[text]</p>\n";
  116. //Other images
  117. if ($r_image != null){
  118. echo "<table id='secondary_images'><tr>\n";
  119. while ($r_image = mysqli_fetch_array($q_image)){
  120. echo "<meta itemprop='image' content='$proto$http_host/img/blog/$r_image[image]'/>\n";
  121. echo "<td><img src='/img/blog/preview/$r_image[image]'/></td>\n";
  122. }
  123. echo "</tr></table>\n";
  124. }
  125. # Tags (if any) and date
  126. echo "<hr><table class='post_footer'><tr>\n";
  127. $q_tag = mysqli_query($con, "SELECT tag FROM post_tag WHERE post= $id;");
  128. if (mysqli_num_rows($q_tag) > 0){
  129. $tag_string = "<span id='tags' class='desktop'>Tags: ";
  130. $tag_raw = "";
  131. while ($r_tag = mysqli_fetch_array($q_tag)){
  132. $tag_string = $tag_string . "<a href='/blog/buscar/tag/$r_tag[tag]'>$r_tag[tag]</a>, ";
  133. $tag_raw = $tag_raw . "$r_tag[tag],";
  134. }
  135. $tag_string = substr($tag_string, 0, strlen($tag_string) - 2);
  136. $tag_string = $tag_string . "</span>";
  137. $tag_raw = substr($tag_raw, 0, strlen($tag_raw) - 1);
  138. echo "<meta itemprop='keywords' content='$tag_raw'/>\n";
  139. echo "<td><span class='date'>" . formatDate($r['dtime'], $lang) . "</span><br/><br class='mobile'/>$tag_string</td>\n";
  140. }
  141. else{
  142. echo "<td><span class='date'><span class='hidden'>" . formatDate($r['dtime'], $lang) . "</span></td>\n";
  143. }
  144. #Share
  145. echo "<td class='r_share'><span class='share'><span class='desktop'>$lng[blog_share]</span>\n";
  146. $title = urlencode("$r[title] - $http_host");
  147. $url_f = htmlspecialchars("https://www.facebook.com/sharer/sharer.php?u=$proto$http_host$_SERVER[REQUEST_URI]");
  148. $url_t = htmlspecialchars("https://twitter.com/share?url=$proto$http_host$_SERVER[REQUEST_URI]&text=$title");
  149. $url_g = htmlspecialchars("https://plus.google.com/share?url=$proto$http_host$_SERVER[REQUEST_URI]");
  150. echo "<a href='$url_f' target='_blank'><img class='share_icon' alt='Facebook' src='$proto$http_host/img/social/facebook.gif'/></a>\n";
  151. echo "<a href='$url_t' target='_blank'><img class='share_icon' alt='Twitter' src='$proto$http_host/img/social/twitter.gif'/></a>\n";
  152. echo "<a href='$url_g' target='_blank'><img class='share_icon' src='$proto$http_host/img/social/googleplus.gif' alt='Google+'/></a>\n";
  153. echo "</span></td>\n";
  154. echo "</tr></table>\n";
  155. #Comments
  156. if ($r['comments'] == 1){
  157. echo "<hr>\n";
  158. $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;");
  159. $count = mysqli_num_rows($q_comment);
  160. echo "<meta itemprop='commentCount interactionCount' content='$count'/>\n";
  161. switch ($count){
  162. case 0:
  163. echo "<h4><meta itemprop='interactionCount' content='0'/></meta>$lng[blog_comments_0]</h4>\n";
  164. break;
  165. case 1:
  166. echo "<h4><span itemprop='interactionCount'>1</span> $lng[blog_comments_1]</h4>\n";
  167. break;
  168. default:
  169. echo "<h4><span itemprop='interactionCount'>$count</span> $lng[blog_comments_multiple]</h4>\n";
  170. }
  171. echo "<div id='comment_list'>\n";
  172. //WARNING: If changes are done here, do the same in comment.php
  173. while ($r_comment = mysqli_fetch_array($q_comment)){
  174. echo "<div itemprop='comment' itemscope itemtype='http://schema.org/UserComments' id='comment_$r_comment[id]' class='comment'>\n";
  175. //When official users are implementes, see if there is user or username
  176. echo "<span itemprop='creator' class='comment_user'>$r_comment[username]</span>\n";
  177. echo "<span class='comment_date date'><meta itemprop='commentTime' content='$r_comment[isodate]'/>" . formatDate($r_comment['dtime'], $lang) . "</span>\n";
  178. echo "<p itemprop='commentText' class='comment_text'>$r_comment[text]</p>";
  179. echo "<hr class='comment_line'/>\n";
  180. echo "</div>\n";
  181. }
  182. echo "</div>\n";
  183. #Comment form
  184. echo "<div class='comment' id='comment_new'>\n";
  185. echo "<form id='comment_form' method='post' action='/' onsubmit='event.preventDefault();postComment($id, \"$lang\");'>\n";
  186. echo "<textarea id='new_comment_text' name='text' maxlength='1800' onChange='defaultInputBorder(this);' onKeyDown='defaultInputBorder(this);' placeholder='$lng[blog_placeholder_text]'></textarea>\n";
  187. echo "<input type='hidden' name='id' value='$id'>\n";
  188. echo "<div id='identification_form'>\n";
  189. 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";
  190. echo "<input type='submit' value='$lng[blog_send]'/>\n";
  191. echo "</div>\n";
  192. echo "</form>\n";
  193. echo "</div>\n";
  194. }
  195. else{
  196. echo "<h4>$lng[blog_comments_closed]</h4>";
  197. }
  198. echo "</div></div>\n";
  199. ?>
  200. </div>
  201. <?php include("common/rightpanel.php"); ?>
  202. </div>
  203. <?php
  204. include("../footer.php");
  205. $ad = ad($con, $lang, $lng);
  206. stats($ad, $ad_static, "blog", "$id");
  207. ?>
  208. </body>
  209. </html>