index.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. $http_host = $_SERVER['HTTP_HOST'];
  3. $default_host = substr($http_host, 0, strpos($http_host, ':'));
  4. include("../functions.php");
  5. $con = startdb();
  6. if (!checkSession($con)){
  7. header("Location: /index.php");
  8. exit (-1);
  9. }
  10. else{
  11. ?>
  12. <html>
  13. <head>
  14. <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
  15. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
  16. <title>Blog - Administracion</title>
  17. <!-- CSS files -->
  18. <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
  19. <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
  20. <!-- CSS for mobile version -->
  21. <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
  22. <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
  23. <!-- Script files -->
  24. <script type="text/javascript" src="script.js"></script>
  25. <script type="text/javascript" src="/script/ui.js"></script>
  26. </head>
  27. <body>
  28. <?php include('../toolbar.php'); ?>
  29. <div id='content'>
  30. <div class="section">
  31. <h3 class="section_title">Entradas del blog - <a href="/blog/add/">A&ntilde;adir nueva</a></h3>
  32. <div class="entry">
  33. <table id='blog_post_list'>
  34. <tr>
  35. <th>Titulo</th>
  36. <th>Texto</th>
  37. <th>Detalles</th>
  38. <th>Traducciones</th>
  39. <th>Accion</th>
  40. </tr>
  41. <?php
  42. $query = mysqli_query($con, "SELECT id, title_es, title_eu, title_en, text_es, text_eu, text_en, user, visible, comments, DATE_FORMAT(dtime, '%b %d, %Y %H:%i:%s') AS ptime, permalink FROM post ORDER BY id DESC;");
  43. while ($r = mysqli_fetch_array($query)){
  44. echo "<tr>\n<td class='blog_column_title'><a href='https://margolariak.com/blog/$r[permalink]'>" . cutText($r['title_es'], 35, '', '') . "</a></td>";
  45. echo "<td class='blog_column_text'>" . str_replace('<br/>', ' ', cutText($r['text_es'], 60, '', '')) . "\n";
  46. $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $r[id] ORDER BY idx;");
  47. if (mysqli_num_rows($q_image) > 0){
  48. echo "<br/>";
  49. while ($r_image = mysqli_fetch_array($q_image))
  50. echo "<img src='http://$default_host/img/blog/miniature/$r_image[image]'\>\n";
  51. }
  52. echo "</td>\n";
  53. $q_user = mysqli_query($con, "SELECT username FROM user WHERE id = $r[user];");
  54. $r_user = mysqli_fetch_array($q_user);
  55. echo "<td class='blog_column_details'>$r[ptime]<br/>Por $r_user[username]<br/>Comentarios:";
  56. if ($r['comments'] == 1){
  57. $q_comments = mysqli_query($con, "SELECT id FROM post_comment WHERE post = $r[id];");
  58. echo "Si (" . mysqli_num_rows($q_comments) . ")";
  59. }
  60. else
  61. echo "No";
  62. echo "<br/>Visible: ";
  63. if ($r['visible'] == 1)
  64. echo "Si";
  65. else
  66. echo "No";
  67. echo "</td>\n<td class='blog_column_translations'>\n"; //TODO percent
  68. $total = 2; //Title and text are mandatory
  69. $translated_en = 0;
  70. $translated_eu = 0;
  71. //Calculate field number
  72. if ($r['title_en'] != $r['title_es']){
  73. $translated_en ++;
  74. }
  75. if ($r['title_eu'] != $r['title_es']){
  76. $translated_eu ++;
  77. }
  78. if ($r['text_en'] != $r['text_es']){
  79. $translated_en ++;
  80. }
  81. if ($r['text_eu'] != $r['text_es']){
  82. $translated_eu ++;
  83. }
  84. //Calculate percents
  85. echo "Ingl&eacute;s: " . intval($translated_en * 100 / $total) . "%<br/>Euskera: " . intval($translated_eu * 100 / $total) . "%\n";
  86. echo "\n</td>\n<td class='blog_column_action'>\n<form method='get' action='http://$http_host/blog/edit/index.php'>\n<input type='submit' value='Editar / Traducir'/>\n<input type='hidden' name='p' value='$r[id]'/></form>\n";
  87. echo "<input type='button' onClick='delete_post($r[id], \"$r[title_es]\");' value='Borrar'/>";
  88. echo "<form action='/blog/moderate/moderate.php?p=$r[id]'>\n<input type='submit' value='Moderar comentarios'/>\n</form>";
  89. echo "</td>\n</tr>";
  90. }
  91. ?>
  92. </table>
  93. </div>
  94. </div>
  95. </div>
  96. </body>
  97. </html>
  98. <?php } ?>