PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/index.php

https://github.com/myiek/swopr.ca
PHP | 205 lines | 160 code | 33 blank | 12 comment | 5 complexity | 6b559a2b4558b16b5f3824ca75303b64 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?
  2. require_once("../PeoplePods.php");
  3. $POD = new PeoplePod(array('debug'=>0,'lockdown'=>'adminUser','authSecret'=>@$_COOKIE['pp_auth']));
  4. $POD->changeTheme('admin');
  5. if (!$POD->success()) {
  6. error_log($POD->error());
  7. }
  8. if (isset($_GET['flushcache'])) {
  9. $POD->cacheflush();
  10. $message = "Cache Flushed!";
  11. }
  12. $POD->header();
  13. // lets generate some stats!
  14. $today = date("Y-m-d");
  15. /*
  16. $totalMembers = $POD->getPeople(array('memberSince:lte'=>$today));
  17. $membersToday = $POD->getPeople(array('lastVisit:gt'=>$today),'lastVisit desc',10);
  18. $membersJoined = $POD->getPeople(array('memberSince:gt'=>$today));
  19. $docsCreated = $POD->getContents(array('date:gt'=>$today));
  20. $newComments = $POD->getComments(array('date:gt'=>$today),'date desc',5);
  21. $total = $membersJoined->totalCount() + $totalMembers->totalCount();
  22. */
  23. $this_database_update = 0.81;
  24. $last_version = $POD->libOptions('last_database_update');
  25. if (!$last_version) { $last_version = 0; }
  26. // load each type of thing
  27. // get total, total for today, total for the last week
  28. // members, content, comments, files, groups
  29. $members = $POD->getPeople(array('memberSince:gte'=>date('Y-m-d') . ' 00:00:00'));
  30. $stats['members_today'] = $members->totalCount();
  31. $members = $POD->getPeople(array('memberSince:gte'=>date('Y-m-d',strtotime('-7 days'))));
  32. $stats['members_week'] = $members->totalCount();
  33. $members = $POD->getPeople(array(),'memberSince DESC',10);
  34. $stats['members_total'] = $members->totalCount();
  35. $visitors = $POD->getPeople(array('lastVisit:gte'=>date('Y-m-d') . ' 00:00:00'));
  36. $stats['visits_today'] = $visitors->totalCount();
  37. $visitors = $POD->getPeople(array('lastVisit:gte'=>date('Y-m-d',strtotime('-7 days'))));
  38. $stats['visits_week'] = $visitors->totalCount();
  39. $visitors = $POD->getPeople(array('lastVisit:gte'=>date('Y-m-d',strtotime('-30 days'))),'lastVisit DESC',10);
  40. $stats['visits_total'] = $visitors->totalCount();
  41. $content = $POD->getContents(array('date:gte'=>date('Y-m-d') . ' 00:00:00'));
  42. $stats['content_today'] = $content->totalCount();
  43. $content = $POD->getContents(array('date:gte'=>date('Y-m-d',strtotime('-7 days'))));
  44. $stats['content_week'] = $content->totalCount();
  45. $content = $POD->getContents(array(),'date desc',10);
  46. $stats['content_total'] = $content->totalCount();
  47. $active_content = $POD->getContents(array(),'commentDate DESC',10);
  48. $comments = $POD->getComments(array('date:gte'=>date('Y-m-d') . ' 00:00:00'));
  49. $stats['comments_today'] = $comments->totalCount();
  50. $comments = $POD->getComments(array('date:gte'=>date('Y-m-d',strtotime('-7 days'))));
  51. $stats['comments_week'] = $comments->totalCount();
  52. $comments = $POD->getComments(array(),'date desc',10);
  53. $stats['comments_total'] = $comments->totalCount();
  54. $files = $POD->getFiles(array('date:gte'=>date('Y-m-d') . ' 00:00:00'));
  55. $stats['files_today'] = $files->totalCount();
  56. $files = $POD->getFiles(array('date:gte'=>date('Y-m-d',strtotime('-7 days'))));
  57. $stats['files_week'] = $files->totalCount();
  58. $files = $POD->getFiles(array(),'date desc',10);
  59. $stats['files_total'] = $files->totalCount();
  60. $groups = $POD->getGroups(array('date:gte'=>date('Y-m-d') . ' 00:00:00'));
  61. $stats['groups_today'] = $groups->totalCount();
  62. $groups = $POD->getGroups(array('date:gte'=>date('Y-m-d',strtotime('-7 days'))));
  63. $stats['groups_week'] = $groups->totalCount();
  64. $groups = $POD->getGroups(array(),'date desc',10);
  65. $stats['groups_total'] = $groups->totalCount();
  66. ?>
  67. <script type="text/javascript">
  68. function doSearch() {
  69. window.location="<? $POD->podRoot(); ?>/admin/" + $('#search_type').val()+ "/search.php?q=" + escape($('#search_q').val());
  70. return false;
  71. }
  72. </script>
  73. <div id="tools">
  74. <ul>
  75. <li id="section_name">Command Center</li><li><a href="content/" title="Create new content...">Add Content</a></li><li><a href="people/" title="Create a new member...">Add Person</a></li><li><a href="groups/" title="Create a new group...">Add Group</a></li><li class="last">
  76. <form method="get" onsubmit="return doSearch();">
  77. <input name="q" id="search_q" default="Search" class="repairField" size="15" />
  78. <select name="type" id="search_type">
  79. <option value="people">People</option>
  80. <option value="content">Content</option>
  81. </select>
  82. </form>
  83. </li>
  84. </ul>
  85. </div>
  86. <div class="list_panel">
  87. <div id="update_check">
  88. <script type="text/javascript" src="http://peoplepods.net/versioncheck/<? echo $POD->libOptions('peoplepods_api'); ?>?version=<?= $POD->VERSION; ?>"></script>
  89. </div>
  90. <h1 style="margin:0px"><? $POD->siteName(); ?></h1>
  91. </div>
  92. <? if (isset($message)) { ?>
  93. <div class="info"><?= $message; ?></div>
  94. <? } ?>
  95. <? if ($last_version < $this_database_update) { ?>
  96. <div class="info">
  97. Updates to the database schema are required! <a href="options/upgrade.php">Click to upgrade.</a>
  98. </div>
  99. <? } ?>
  100. <div id="options">
  101. <div class="stats option_set">
  102. <div class="stat">
  103. <a href="<? $POD->podRoot(); ?>/admin/people/search.php?mode=newest"><?= $POD->pluralize($stats['members_total'],'<span class="number">@number</span> member','<span class="number">@number</span> members'); ?></a>
  104. <?= $stats['members_today']; ?> joined today<br />
  105. <?= $stats['members_week']; ?> over the last week
  106. </div>
  107. <div class="stat">
  108. <a href="<? $POD->podRoot(); ?>/admin/people/search.php?mode=last" title="Members active during the last 30 days"><?= $POD->pluralize($stats['visits_total'],'<span class="number">@number active</span>','<span class="number">@number active</span>'); ?></a>
  109. <?= $stats['visits_today']; ?> visited today<br />
  110. <?= $stats['visits_week']; ?> over the last week
  111. </div>
  112. <div class="stat">
  113. <a href="<? $POD->podRoot(); ?>/admin/content/search.php"><?= $POD->pluralize($stats['content_total'],'<span class="number">@number</span> post','<span class="number">@number</span> posts'); ?></a>
  114. <?= $stats['content_today']; ?> created today<br />
  115. <?= $stats['content_week']; ?> over the last week
  116. </div>
  117. <div class="stat">
  118. <a href="<? $POD->podRoot(); ?>/admin/comments/"><?= $POD->pluralize($stats['comments_total'],'<span class="number">@number</span> comment','<span class="number">@number</span> comments'); ?></a>
  119. <?= $stats['comments_today']; ?> posted today<br />
  120. <?= $stats['comments_week']; ?> over the last week
  121. </div>
  122. <div class="stat">
  123. <a href="<? $POD->podRoot(); ?>/admin/files/"><?= $POD->pluralize($stats['files_total'],'<span class="number">@number</span> file','<span class="number">@number</span> files'); ?></a>
  124. <?= $stats['files_today']; ?> uploaded today<br />
  125. <?= $stats['files_week']; ?> over the last week
  126. </div>
  127. <div class="stat">
  128. <a href="<? $POD->podRoot(); ?>/admin/groups/search.php"><?= $POD->pluralize($stats['groups_total'],'<span class="number">@number</span> group','<span class="number">@number</span> groups'); ?></a>
  129. <?= $stats['groups_today']; ?> created today<br />
  130. <?= $stats['groups_week']; ?> over the last week
  131. </div>
  132. </div>
  133. <div class="option_set">
  134. <? $POD->cachestatus(); ?>
  135. <a href="?flushcache=now">Flush Cache</a>
  136. </div>
  137. <div class="option_set">
  138. <h3>Documentation</h3>
  139. <ul>
  140. <li><a href="http://peoplepods.net/readme">README</a></li>
  141. <li><a href="http://peoplepods.net/readme/sdk">SDK</a></li>
  142. <li><a href="http://peoplepods.net/readme/themes">Themes</a></li>
  143. <li><a href="http://peoplepods.net/readme/object-definitions">Object Definitions</a></li>
  144. <li><a href="http://peoplepods.net/readme/admin-tools">Admin Tools</a></li>
  145. </ul>
  146. </div>
  147. </div>
  148. <div class="list_panel panel_with_options">
  149. <h1>Recent Activity</h1>
  150. <div class="quick_view" id="quick_people" >
  151. <h2>People</h2>
  152. <h3>New Signups</h3>
  153. <? $members->output('list_item','list_header','list_footer'); ?>
  154. <h3>Recent Visitors</h3>
  155. <? $visitors->output('list_item','list_header','list_footer'); ?>
  156. </div>
  157. <div class="quick_view" id="quick_content">
  158. <h2>Content</h2>
  159. <h3>Recently Added Content</h3>
  160. <? $content->output('list_item','list_header','list_footer'); ?>
  161. <h3>Recently Active Content</h3>
  162. <? $active_content->output('list_item','list_header','list_footer'); ?>
  163. </div>
  164. <div class="quick_view" id="quick_comments">
  165. <h2>Comments</h2>
  166. <? $comments->output('comment.preview'); ?>
  167. </div>
  168. <br clear="left" />
  169. </div>
  170. <?
  171. $POD->footer();
  172. ?>