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

/extra.php

https://bitbucket.org/stavrossk/openmaidos
PHP | 145 lines | 111 code | 2 blank | 32 comment | 20 complexity | 53ceb9ee57fb56889cf74be7050db1fd MD5 | raw file
  1. <?php
  2. require_once('functions.php');
  3. require_once('process.functions.php');
  4. require_once('authentication.php');
  5. require_once('db.php');
  6. require_once('archive.php');
  7. require_once('maintenance.php');
  8. //session_start();
  9. include('header.php');
  10. ?>
  11. <table id=autorlist width="100%" border="0" align="center">
  12. <tr>
  13. <td>
  14. <?php
  15. $mode = $_GET["mode"];
  16. $u = Authenticate();
  17. $usersplugins = findUsersPlugins($u);
  18. $usersplugins_count = mysql_numrows($usersplugins);
  19. echo "<p>&nbsp; </p>";
  20. //if user isn't logged in or user has no plugins, use widebar (no rightside menu)
  21. if (($usersplugins_count > 0) && ($u != "")) echo '<div id="leftbar" align="center">';
  22. else echo '<div id="widebar" align="center">';
  23. if ($u != "") printPara ("Welcome, $u");
  24. echo "<h1>Stats & Tools</h1>";
  25. if($mode == "")
  26. $mode = "home";
  27. switch ($mode)
  28. {
  29. case "home":
  30. printToolHome($u);
  31. break;
  32. case "manageplugins":
  33. printManagePlugins($u);
  34. break;
  35. case "check":
  36. printCheckForProblems($u);
  37. break;
  38. }
  39. function printLine($line)
  40. {
  41. echo "$line<br />\n";
  42. }
  43. function printPara($para)
  44. {
  45. echo "<p>$para</p>\n";
  46. }
  47. function printH2($header)
  48. {
  49. echo "<h2>$header</h2>\n";
  50. }
  51. function printSectionTitle($title)
  52. {
  53. printH2($title);
  54. echo "<hr />";
  55. }
  56. function printToolHome($user)
  57. {
  58. global $ftp_repository;
  59. global $ftp_manual_uploads;
  60. printSectionTitle("OpenMAID Stats");
  61. //If user is not logged in, display message and link to allow user to login or register with the forum
  62. //Display total # of all versions of all plugins in db
  63. //Display total # plugins voted working
  64. //Display total # of unique plugins in db
  65. //Display # of all versions of your plugins
  66. //Display # of your unique plugins
  67. //Display author/forum id who has most versions of plugins
  68. //Display author/forum id who has most # of unique plugins
  69. $sql = "SELECT plugin_ID FROM plugins WHERE plugin_Current = true";
  70. $res = mysql_query($sql); $active_plugins = mysql_numrows($res);
  71. $sql = "SELECT plugin_ID FROM plugins WHERE plugin_ReviewFlag != true";
  72. $res = mysql_query($sql); $total_plugins = mysql_numrows($res);
  73. printLine("OpenMAID has $active_plugins active plugins ($total_plugins including previous versions).");
  74. $today = date("Y-m-d H:i:s");
  75. $year = substr($today, 0,4);
  76. $month = substr($today, 5, 2);
  77. $day = substr($today, 8, 2);
  78. $history_date = date("Y-m-d H:i:s", mktime(0, 0, 0, $month, $day - 30, $year));
  79. $sql = "SELECT plugin_ID FROM plugins WHERE plugin_Date >= '$history_date' AND plugin_ReviewFlag != 'TRUE'";
  80. $res = mysql_query($sql); $num_uploads_last_month = mysql_numrows($res);
  81. $sql = "SELECT plugin_ID FROM plugins WHERE plugin_ReviewFlag != 'TRUE' AND plugin_current = true AND plugin_Date >= '$history_date'";
  82. $res = mysql_query($sql); $num_unique_uploads_last_month = mysql_numrows($res);
  83. printLine("$num_unique_uploads_last_month plugins have been updated during the past 30 days.");
  84. printLine("$num_uploads_last_month plugin versions have been uploaded during the past 30 days.");
  85. $sql = "SELECT plugin_Name, plugin_Author, profil_id, plugin_ID, count(*) AS plugin_Count FROM plugins WHERE profil_id != '' AND plugin_ReviewFlag != 'TRUE' AND plugin_current = true GROUP BY profil_id ORDER BY plugin_Count DESC LIMIT 20";
  86. $res = mysql_query($sql);
  87. echo "<br><br><b>Top Plugin Contributors</b><br><table>";
  88. while (($enreg=@mysql_fetch_array($res))) {
  89. echo "<tr><td><img src=images/profile.png width='15' height='15'> [" . $enreg["plugin_Count"] . " plugins] </td><td>" . $enreg["plugin_Author"] . " (<a href=\"thelist.php?profile_id=" . urlencode($enreg["profil_id"]) . "\"><i>" . $enreg["profil_id"] . "</i></a>) </td></tr>";
  90. }
  91. echo "</table>";
  92. //printLine("Print various OpenMAID stats (and user stats if user is logged in):");
  93. //printLine("* Total plugins voted working");
  94. //printLine("* Total plugins downloaded by user");
  95. //printLine("* Total plugins uploaded by user");
  96. //printLine("* Author with most uploaded plugins");
  97. }
  98. function printConfirmButton($name, $DisplayName)
  99. {
  100. echo '<form method="post"><input type="hidden" name="' . $name . '" value="true" /> <input type="submit" value="' . $DisplayName . '" /></form>';
  101. }
  102. function printManagePlugins($user)
  103. {
  104. //let user manage plugin metadata
  105. printSectionTitle("Manage My Plugins");
  106. manage_myplugins("", "", $user);
  107. //printLine("Stay tuned... this feature will be implemented soon!<br>");
  108. //printLine("List plugins belonging to logged in user with list of actions:");
  109. //printLine("* Link to upload page");
  110. //printLine("* Link to edit each plugin metadata");
  111. //printLine("* Link to flag a plugin for deletion?");
  112. //printLine("* Highlight plugin red if it's voted not working");
  113. //printLine("* Highlight plugin yellow if it's missing some metadata");
  114. // printPara("Please put info here to manage database");
  115. }
  116. function printCheckForProblems($user)
  117. {
  118. //check users plugins for missing metadata
  119. printSectionTitle("Check for Problems");
  120. printLine("Checking for plugins with potentially important missing metadata.<br>");
  121. manage_metadata("", "", $user);
  122. //printLine("Stay tuned... this feature will be implemented soon!<br>");
  123. //printLine("Check for problems function will check the following (amongst other things):");
  124. //printLine("* Check for any plugins with potentially important missing metadata");
  125. //printLine("* Check if any of your plugins are marked as flagged for review");
  126. }
  127. //If user isn't logged in or user has no plugins, don't show side menu
  128. echo "<hr />";
  129. if (($usersplugins_count > 0) && ($u != "")){
  130. echo '</div><div id="rightbar" align=center>';
  131. echo '<a href="' . $sys_url . '">OpenMAID Home</a><br />';
  132. //if user has plugins, show Manage Plugins menu item
  133. echo '<a href="?mode=manageplugins">Manage My Plugins</a><br />';
  134. //if user has plugins, show Check Plugin Metadata menu item
  135. echo '<a href="?mode=check">Check Plugin Metadata</a><br />';
  136. echo '<a href="userstats.php">Your Last 10 Downloads</a><br />';
  137. }
  138. echo '</div>';
  139. ?>
  140. </td>
  141. </tr>
  142. </table>
  143. <?php include('footer.php'); ?>