PageRenderTime 51ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/home.php

http://n-13news.googlecode.com/
PHP | 164 lines | 135 code | 11 blank | 18 comment | 11 complexity | a607cacaca749a18160c744b4d9db09d MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1
  1. <?php
  2. /***********************************************************************
  3. N-13 News is a free news publishing system
  4. Copyright (C) 2011 Chris Watt
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program.If not, see <http://www.gnu.org/licenses/>.
  15. ***********************************************************************/
  16. if (!defined('ABSPATH')){ die(); }
  17. $totalnews = DataAccess::fetch("SELECT COUNT(id) AS totalnews FROM " . NEWS_ARTICLES);
  18. $totalnews = $totalnews['0']['totalnews'];
  19. $totalcomments = DataAccess::fetch("SELECT COUNT(id) AS totalcomments FROM " . NEWS_COMMENTS);
  20. $totalcomments = $totalcomments['0']['totalcomments'];
  21. $totalusers = DataAccess::fetch("SELECT COUNT(uid) AS totalusers FROM " . NEWS_USERS);
  22. $totalusers = $totalusers['0']['totalusers'];
  23. $totalsmilies = DataAccess::fetch("SELECT COUNT(id) AS totalsmilies FROM " . NEWS_SMILIES);
  24. $totalsmilies = $totalsmilies['0']['totalsmilies'];
  25. $totalfilters = DataAccess::fetch("SELECT COUNT(id) AS totalfilters FROM " . NEWS_FILTER);
  26. $totalfilters = $totalfilters['0']['totalfilters'];
  27. $totalcats = DataAccess::fetch("SELECT COUNT(id) AS totalcats FROM " . NEWS_CATS);
  28. $totalcats = $totalcats['0']['totalcats'];
  29. $totaltemplates = DataAccess::fetch("SELECT COUNT(id) AS totaltemplates FROM " . NEWS_TEMPLATES);
  30. $totaltemplates = $totaltemplates['0']['totaltemplates'];
  31. $numaccess = DataAccess::fetch("SELECT COUNT(uid) AS numaccess FROM " . NEWS_ACCESS);
  32. $numaccess = $numaccess['0']['numaccess'];
  33. $totalimages = DataAccess::fetch("SELECT COUNT(uid) AS numimages FROM " . NEWS_IMAGES);
  34. $totalimages = $totalimages['0']['numimages'];
  35. $totalfiles = DataAccess::fetch("SELECT COUNT(uid) AS numfiles FROM " . NEWS_FILES);
  36. $totalfiles = $totalfiles['0']['numfiles'];
  37. $totalrss = DataAccess::fetch("SELECT COUNT(feedid) AS numrss FROM " . NEWS_FEEDS);
  38. $totalrss = $totalrss['0']['numrss'];
  39. $sentto = $_SESSION['uid'];
  40. $unreadmessages = DataAccess::fetch("SELECT COUNT(uid) AS unread FROM " . NEWS_PRIVATE . " WHERE sentto = '$sentto' AND viewed = '1'");
  41. $unreadmessages = $unreadmessages['0']['unread'];
  42. $f = '';
  43. $f = $f . " (" . $unreadmessages . ")";
  44. echo ' <div id="pageLeft">
  45. <div id="pageIconHome"></div><!--icon-->
  46. <div id="titleHome">N-13 News<br />' . $version . '</div>
  47. </div><!--leftside-->';
  48. echo '<div id="pageRight">';
  49. echo "<div id=\"headerBox\">".$langmsg['home'][1]." " . $_SESSION['name'] . "</div>";
  50. if(ini_get("register_globals")){
  51. echo "<div class=\"error-warning\">";
  52. echo $langmsg['home'][3];
  53. echo "</div><br />";
  54. }
  55. //try delete install dir
  56. if(file_exists(ABSPATH . "install/index.php")){
  57. function deleteinstall(){
  58. global $langmsg;
  59. echo "<form method=\"post\" action=\"?\">";
  60. echo "<div class=\"error-warning\">";
  61. echo $langmsg['home'][4] . "<br /><br />" . $langmsg['home'][21];
  62. echo " <input type=\"submit\" value=\"".$langmsg['submitfield'][8]."\" name=\"Delete\" />
  63. </div></form><br />";
  64. }
  65. $_POST['Delete'] = (empty($_POST['Delete'])) ? '' : $_POST['Delete'];
  66. if(!$_POST['Delete']){
  67. deleteinstall();
  68. }else{
  69. if(!@unlink("install/index.php")){
  70. echo "<span class=error>";
  71. echo $langmsg['home'][5];
  72. echo "</span>";
  73. }
  74. }
  75. }
  76. echo "<div class=subheaders><span style=\"float: right; margin-right: 0px\">" . $langmsg['home'][20] . $f ."</span>".$langmsg['home'][0] . "</div>";
  77. echo "<div class=\"subheaders_body displaytable\">";
  78. echo "<table border=\"0\" cellpadding=\"0\" style=\"text-align: left; border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\">\n";
  79. echo " <tr>\n";
  80. echo " <td>\n";
  81. echo " " . $langmsg['home'][6] . "</td>\n";
  82. echo " <td>\n";
  83. echo " <div class=\"ok\">$totalnews</div></td>\n";
  84. echo " <td>\n";
  85. echo " " . $langmsg['home'][23] . "</td>\n";
  86. echo " <td>\n";
  87. echo " <div class=\"ok\">$totalimages</div></td>\n";
  88. echo " </tr>\n";
  89. echo " <tr>\n";
  90. echo " <td>\n";
  91. echo " " . $langmsg['home'][7] . "</td>\n";
  92. echo " <td>\n";
  93. echo " <div class=\"ok\">$totalcomments</div></td>\n";
  94. echo " <td>\n";
  95. echo " " . $langmsg['home'][24] . "</td>\n";
  96. echo " <td>\n";
  97. echo "<div class=ok>$totalfiles</div></td>\n";
  98. echo " </tr>\n";
  99. echo " <tr>\n";
  100. echo " <td>" . $langmsg['home'][8] . "</td>\n";
  101. echo " <td><div class=ok>$totalusers</div></td>\n";
  102. echo " <td>" . $langmsg['home'][25] . "</td>\n";
  103. echo " <td><div class=ok>$totalrss</div></td>\n";
  104. echo " </tr>\n";
  105. echo "<tr>\n";
  106. echo "<td>" . $langmsg['home'][9] . "</td>\n";
  107. echo "<td><div class=ok>$totalsmilies</div></td>\n";
  108. echo "<td>". $langmsg['home'][16] . "</td><td><span class=ok>$version</span></td>";
  109. echo "</tr>";
  110. echo "<tr>";
  111. echo "<td>" . $langmsg['home'][10] . "</td>\n";
  112. echo "<td><div class=ok>$totalfilters</div></td>\n";
  113. echo "<td>". $langmsg['home'][17] . "</td><td id=\"latestversion\">Checking for updates</td>";
  114. echo "</tr>";
  115. echo "<tr>";
  116. echo "<td>" . $langmsg['home'][11] . "</td>\n";
  117. echo "<td><div class=ok>$totalcats</div></td>\n";
  118. echo "<td colspan=\"2\" id=\"messagebox\"></td>";
  119. echo "</tr>";
  120. echo "<tr>";
  121. echo "<td>" . $langmsg['home'][12] . "</td>\n";
  122. echo "<td><div class=ok>$totaltemplates</div></td>\n";
  123. echo "</tr>";
  124. echo "<tr>";
  125. echo "<td>" . $langmsg['home'][13] . "</td>\n";
  126. echo "<td><div class=ok>$numaccess</div></td>\n";
  127. echo "<td><a href=\"?action=accesslogs\">" . $langmsg['home'][18] . "</a></td><td></td>";
  128. echo "</tr>";
  129. echo "</table>\n";
  130. echo "</div>";
  131. echo " </div><!--rightside-->
  132. </div><!--pageCont-->";
  133. $_SESSION['beenalerted'] = (empty($_SESSION['beenalerted'])) ? '' : $_SESSION['beenalerted'];
  134. if($_SESSION['beenalerted'] == false){
  135. $_SESSION['beenalerted'] = true;
  136. $alertmsg = DataAccess::fetch("SELECT alertmsg FROM " . NEWS_USERS . " WHERE user = ?", $_SESSION['name']);
  137. $alertmsg = $alertmsg['0']['alertmsg'];
  138. if($alertmsg == "1"){
  139. $uid = $_SESSION['uid'];
  140. $m = count(DataAccess::fetch("SELECT * FROM " . NEWS_PRIVATE . " WHERE sentto = ? AND viewed = ?", $uid, "1"));
  141. if($m > 0){
  142. echo "<script language=\"javascript\">";
  143. echo "if(confirm('You have $m unread message(s). Would you like to view them now?')){
  144. window.location = '?action=private&type=';
  145. }";
  146. echo "</script>";
  147. }
  148. }
  149. }
  150. ?>