index.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. session_start();
  3. $http_host = $_SERVER["HTTP_HOST"];
  4. $doc_root = $_SERVER["DOCUMENT_ROOT"] . "/";
  5. include $doc_root . "functions.php";
  6. $proto = get_protocol();
  7. $con = start_db();
  8. $server = $proto . $http_host;
  9. $pserver = substr($server, 0, strpos($http_host, ':')); // public server
  10. $lang = "en";
  11. if (!check_session($con)){
  12. header("Location: /authentication.php");
  13. exit(-1);
  14. }
  15. else{
  16. ?>
  17. <html>
  18. <head>
  19. <meta content='text/html; charset=windows-1252' http-equiv='content-type'/>
  20. <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'>
  21. <link rel='shortcut icon' href='<?=$pserver?>/img/logo/x2/favicon.ico'/>
  22. <title>Blog - I&ntilde;igo Valentin - Administration Panel</title>
  23. <style>
  24. <?php
  25. include $doc_root . "css/ui.css";
  26. include $doc_root . "css/blog.css";
  27. ?>
  28. </style>
  29. <!-- CSS for mobile version -->
  30. <style media='(max-width : 990px)'>
  31. <?php
  32. include $doc_root . "css/m/ui.css";
  33. include $doc_root . "css/m/blog.css";
  34. ?>
  35. </style>
  36. <!-- Script files -->
  37. <script type='text/javascript'>
  38. <?php
  39. include $doc_root . "script/ui.js";
  40. include $doc_root . "script/blog.js";
  41. ?>
  42. </script>
  43. </head>
  44. <body>
  45. <?php
  46. include $doc_root . "header.php";
  47. ?>
  48. <div id='content'>
  49. <div class='section'>
  50. <h3 class='section_title'>Post list</h3>
  51. <div class='entry'>
  52. <table id='post_list'>
  53. <tr>
  54. <th>Post</th>
  55. <th>Detalles</th>
  56. <th>Acciones</th>
  57. </tr>
  58. <?php
  59. $q_post = mysqli_query($con, "SELECT post.id AS id, permalink, title, text, dtime, comments, (SELECT count(id) FROM post_comment WHERE post = post.id) AS comment_count, concat(fname, concat(' ', lname)) AS user, visible, comments, (SELECT image FROM post_image WHERE post = post.id ORDER BY idx LIMIT 1) AS image, (SELECT count(image) FROM post_image WHERE post = post.id) AS image_count FROM post, user WHERE user = user.id");
  60. while ($r_post = mysqli_fetch_array($q_post)){
  61. $title = text($con, $r_post["title"], $lang);
  62. ?>
  63. <tr>
  64. <td class='td_post'>
  65. <h4>
  66. <a title='View <?=$title?> on a new tab' target='_blank' href='<?=$pserver?>/blog/<?=$r_post["permalink"]?>'>
  67. <?=$title?>
  68. </a>
  69. </h4>
  70. <p><?=cut_text(text($con, $r_post["text"], $lang), 200)?></p>
  71. <?php
  72. if ($r_post["image_count"] > 0){
  73. ?>
  74. <img class='post_image' alt='<?=$title?>' title='<?=$title?>' src='<?=$pserver?>/img/blog/x2/<?=$r_post["image"]?>' />
  75. <?php
  76. if ($r_post["image_count"] == 2){
  77. ?>
  78. + other image.
  79. <?php
  80. }
  81. elseif ($r_post["image_count"] > 2){
  82. $pl = $r_post["image_count"] - 1;
  83. ?>
  84. + <?=$pl?> other images.
  85. <?php
  86. }
  87. }
  88. ?>
  89. </td>
  90. <td class='td_details'>
  91. By <?=$r_post["user"]?>.<br/>
  92. Posted <?=format_date($r_post["dtime"], $lang, true)?>.<br/>
  93. Visible:
  94. <?php
  95. if ($r_post["visible"] == 1){
  96. ?>
  97. Yes
  98. <?php
  99. }
  100. else{
  101. ?>
  102. No
  103. <?php
  104. }
  105. ?>
  106. <br/>Comments: <?=$r_post["comment_count"]?><br/>
  107. Comments allowed:
  108. <?php
  109. if ($r_post["comments"] == 1){
  110. ?>
  111. Yes
  112. <?php
  113. }
  114. else{
  115. ?>
  116. No
  117. <?php
  118. }
  119. ?>
  120. </td>
  121. <td class='td_actions'>
  122. <input type='button' onclick='managePost(<?=$r_post["id"]?>);' value='Manage / Translate'/>
  123. <input type='button' onclick='deletePost(<?=$r_post["id"]?>, "<?=$title?>");' value='Delete'/>
  124. <?php
  125. if ($r_post["visible"] == 1){
  126. ?>
  127. <input type='button' onclick='visiblePost(<?=$r_post["id"]?>, "<?=$title?>", 0);' value='Unpublish'/>
  128. <?php
  129. }
  130. else{
  131. ?>
  132. <input type='button' onclick='visiblePost(<?=$r_post["id"]?>, "<?=$title?>", 1);' value='Publish'/>
  133. <?php
  134. }
  135. ?>
  136. </td>
  137. </tr>
  138. <?php
  139. }
  140. ?>
  141. </table>
  142. </div> <!-- .entry -->
  143. </div> <!-- .section -->
  144. </div> <!-- #content -->
  145. </body>
  146. </html>
  147. <?php
  148. }
  149. ?>