/extra.php
PHP | 145 lines | 111 code | 2 blank | 32 comment | 20 complexity | 53ceb9ee57fb56889cf74be7050db1fd MD5 | raw file
- <?php
- require_once('functions.php');
- require_once('process.functions.php');
- require_once('authentication.php');
- require_once('db.php');
- require_once('archive.php');
- require_once('maintenance.php');
- //session_start();
- include('header.php');
- ?>
- <table id=autorlist width="100%" border="0" align="center">
- <tr>
- <td>
- <?php
- $mode = $_GET["mode"];
- $u = Authenticate();
- $usersplugins = findUsersPlugins($u);
- $usersplugins_count = mysql_numrows($usersplugins);
- echo "<p> </p>";
- //if user isn't logged in or user has no plugins, use widebar (no rightside menu)
- if (($usersplugins_count > 0) && ($u != "")) echo '<div id="leftbar" align="center">';
- else echo '<div id="widebar" align="center">';
- if ($u != "") printPara ("Welcome, $u");
- echo "<h1>Stats & Tools</h1>";
- if($mode == "")
- $mode = "home";
- switch ($mode)
- {
- case "home":
- printToolHome($u);
- break;
- case "manageplugins":
- printManagePlugins($u);
- break;
- case "check":
- printCheckForProblems($u);
- break;
- }
- function printLine($line)
- {
- echo "$line<br />\n";
- }
- function printPara($para)
- {
- echo "<p>$para</p>\n";
- }
- function printH2($header)
- {
- echo "<h2>$header</h2>\n";
- }
- function printSectionTitle($title)
- {
- printH2($title);
- echo "<hr />";
- }
- function printToolHome($user)
- {
- global $ftp_repository;
- global $ftp_manual_uploads;
- printSectionTitle("OpenMAID Stats");
- //If user is not logged in, display message and link to allow user to login or register with the forum
- //Display total # of all versions of all plugins in db
- //Display total # plugins voted working
- //Display total # of unique plugins in db
- //Display # of all versions of your plugins
- //Display # of your unique plugins
- //Display author/forum id who has most versions of plugins
- //Display author/forum id who has most # of unique plugins
- $sql = "SELECT plugin_ID FROM plugins WHERE plugin_Current = true";
- $res = mysql_query($sql); $active_plugins = mysql_numrows($res);
- $sql = "SELECT plugin_ID FROM plugins WHERE plugin_ReviewFlag != true";
- $res = mysql_query($sql); $total_plugins = mysql_numrows($res);
- printLine("OpenMAID has $active_plugins active plugins ($total_plugins including previous versions).");
- $today = date("Y-m-d H:i:s");
- $year = substr($today, 0,4);
- $month = substr($today, 5, 2);
- $day = substr($today, 8, 2);
- $history_date = date("Y-m-d H:i:s", mktime(0, 0, 0, $month, $day - 30, $year));
- $sql = "SELECT plugin_ID FROM plugins WHERE plugin_Date >= '$history_date' AND plugin_ReviewFlag != 'TRUE'";
- $res = mysql_query($sql); $num_uploads_last_month = mysql_numrows($res);
- $sql = "SELECT plugin_ID FROM plugins WHERE plugin_ReviewFlag != 'TRUE' AND plugin_current = true AND plugin_Date >= '$history_date'";
- $res = mysql_query($sql); $num_unique_uploads_last_month = mysql_numrows($res);
- printLine("$num_unique_uploads_last_month plugins have been updated during the past 30 days.");
- printLine("$num_uploads_last_month plugin versions have been uploaded during the past 30 days.");
- $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";
- $res = mysql_query($sql);
- echo "<br><br><b>Top Plugin Contributors</b><br><table>";
- while (($enreg=@mysql_fetch_array($res))) {
- 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>";
- }
- echo "</table>";
- //printLine("Print various OpenMAID stats (and user stats if user is logged in):");
- //printLine("* Total plugins voted working");
- //printLine("* Total plugins downloaded by user");
- //printLine("* Total plugins uploaded by user");
- //printLine("* Author with most uploaded plugins");
- }
- function printConfirmButton($name, $DisplayName)
- {
- echo '<form method="post"><input type="hidden" name="' . $name . '" value="true" /> <input type="submit" value="' . $DisplayName . '" /></form>';
- }
- function printManagePlugins($user)
- {
- //let user manage plugin metadata
- printSectionTitle("Manage My Plugins");
- manage_myplugins("", "", $user);
- //printLine("Stay tuned... this feature will be implemented soon!<br>");
- //printLine("List plugins belonging to logged in user with list of actions:");
- //printLine("* Link to upload page");
- //printLine("* Link to edit each plugin metadata");
- //printLine("* Link to flag a plugin for deletion?");
- //printLine("* Highlight plugin red if it's voted not working");
- //printLine("* Highlight plugin yellow if it's missing some metadata");
- // printPara("Please put info here to manage database");
- }
- function printCheckForProblems($user)
- {
- //check users plugins for missing metadata
- printSectionTitle("Check for Problems");
- printLine("Checking for plugins with potentially important missing metadata.<br>");
- manage_metadata("", "", $user);
- //printLine("Stay tuned... this feature will be implemented soon!<br>");
- //printLine("Check for problems function will check the following (amongst other things):");
- //printLine("* Check for any plugins with potentially important missing metadata");
- //printLine("* Check if any of your plugins are marked as flagged for review");
- }
- //If user isn't logged in or user has no plugins, don't show side menu
- echo "<hr />";
- if (($usersplugins_count > 0) && ($u != "")){
- echo '</div><div id="rightbar" align=center>';
- echo '<a href="' . $sys_url . '">OpenMAID Home</a><br />';
- //if user has plugins, show Manage Plugins menu item
- echo '<a href="?mode=manageplugins">Manage My Plugins</a><br />';
- //if user has plugins, show Check Plugin Metadata menu item
- echo '<a href="?mode=check">Check Plugin Metadata</a><br />';
- echo '<a href="userstats.php">Your Last 10 Downloads</a><br />';
- }
- echo '</div>';
- ?>
- </td>
- </tr>
- </table>
- <?php include('footer.php'); ?>