define('ROOT', '../../'); header('Access-Control-Allow-Origin: *'); header('Content-type: application/json'); require_once ROOT . '../private_html/config.php'; require_once ROOT . '../private_html/includes/database.php'; require_once ROOT . '../private_html/includes/func.php'; cacheCurrentPage(array('api' => 1)); // Our json encoded response $response = array(); if (!isset($_GET['page'])) { $page = 1; } else { $page = intval($_GET['page']); } // get the total number of plugins $totalPlugins = countPlugins(PLUGIN_ORDER_POPULARITY); $response['maxPages'] = ceil($totalPlugins / PLUGIN_LIST_RESULTS_PER_PAGE); // offset is how many plugins to start after $offset = ($page - 1) * PLUGIN_LIST_RESULTS_PER_PAGE; foreach (loadPlugins(PLUGIN_ORDER_POPULARITY, PLUGIN_LIST_RESULTS_PER_PAGE, $offset) as $plugin) { if ($plugin->isHidden()) { continue; } // count the number of servers in the last 24 hours $servers24 = $plugin->getServerCount(); // add the plugin $response['plugins'][] = array('rank' => $plugin->getRank(), 'lastrank' => $plugin->getLastRank(), 'name' => htmlentities($plugin->getName()), 'authors' => htmlentities($plugin->getAuthors()), 'servers24' => number_format($servers24)); } $response['status'] = 'ok'; echo json_encode($response);
header('Content-type: text/html; charset=utf-8'); if (!isset($_GET['debug'])) { error_reporting(0); } ob_start(); define('VERSION', '2.3'); define('VERSION_DATE', '2012-02-24'); define("BASE_PATH", dirname($_SERVER["SCRIPT_FILENAME"]) . "/"); define("BASE_URL", str_replace(basename(__FILE__), "", $_SERVER['SCRIPT_URI'])); define("SYSTEM", BASE_PATH . "system/"); define("SYSTEM_URL", BASE_URL . "system/"); $mini = $_GET['mini'] == true ? true : false; define("MINI", $mini); require_once SYSTEM . "assistants/launch.php"; loadModules(); loadPlugins(); $manager->office->generateMenu(); call_anchor($manager->office->cubicle("BRANCH")); call_anchor($manager->office->cubicle("REQUEST")); call_anchor("start"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php $manager->office->pageTitle(); ?> </title> <?php $manager->office->head_tags();
function loadPlugins($dir = "", $root = true, $maxLevel = 2, $level = 0) { global $manager; static $tree; static $base_dir_length; if ($level == $maxLevel) { return; } $base = AJAX ? SYSTEM : BASE_PATH; if ($root) { $dir = $base . 'plugins/'; $tree = array(); $base_dir_length = strlen($dir) + 1; } if (is_file($dir)) { $filename = substr($dir, $base_dir_length); $extension = substr($filename, strpos($filename, '.') + 1); if ($extension == "plugin.php") { include $dir; } } elseif (is_dir($dir) && ($di = dir($dir))) { $level = !$root ? $level + 1 : $level; while (($file = $di->read()) !== false) { if ($file != "." && $file != "..") { loadPlugins("{$dir}/{$file}", false, $maxLevel, $level); } } $di->close(); } if ($root) { $theme = isset($manager) ? $manager->clerk->getSetting("site_theme", 1) : $clerk->getSetting("site_theme", 1); $themePlugin = $base . 'site/themes/' . $theme . '/functions.php'; if (file_exists($themePlugin)) { include_once $themePlugin; } return $tree; } }
} /* * Load "Check plugins"... */ $lChecks = loadPlugins($sPlugins, 'Check'); $sLastP = $sLastC = ''; $iCount = $iCheck = 0; /* * Start scanner... */ _log('Scan [' . realpath($sRoot) . '] directory with : ' . implode(', ', array_keys($lChecks)) . ' plugins.'); scan($sRoot, $lChecks); /* * Load and execute "Report plugins"... */ $lReports = loadPlugins($sReports, 'Report'); foreach ($lReports as $oO) { $oO->report($lChecks); } } else { _log('Unauthorized client request: [' . $sSecret . ']'); } define('MCS_STOP', _now()); /** * Recursive Directory Scan & file check function * * @param string $sDir Directory to scan * @param array $aPlugins Plugins to execute */ function scan($sDir, $aPlugins = array()) {
<?php define('ROOT', '../private_html/'); require_once ROOT . 'config.php'; require_once ROOT . 'includes/database.php'; require_once ROOT . 'includes/func.php'; // array of plugin objects $plugins = array(); // array of plugin server counts (1d) $counts = array(); // count servers foreach (loadPlugins(PLUGIN_ORDER_SERVERCOUNT30) as $plugin) { if ($plugin->isHidden()) { continue; } $plugins[$plugin->getID()] = $plugin; $counts[$plugin->getID()] = $plugin->getServerCount(); } // sort the plugins arsort($counts); $rank = 0; $lastChange = normalizeTime(); foreach ($counts as $pluginId => $count) { $plugin = $plugins[$pluginId]; $newRank = ++$rank; // did their rank change ? if ($newRank != $plugin->getRank()) { $plugin->setLastRankChange($lastChange); } $plugin->setLastRank($plugin->getRank()); $plugin->setRank($newRank);
<div class="row-fluid"> <div class="col-xs-12"> <h1 style="margin-bottom:10px; font-size:57px;">Glorious plugin stats!</h1> <p>MCStats / Plugin Metrics is the de facto statistical engine for Minecraft, actively used by over <b>{$pluginCount}</b> plugins.</p> <p>Across the world, over <b>{$playerCount}</b> players have been seen <b>in the last 30 minutes</b> on over <b>{$serverCount}</b> servers.</p> <p><a href="/learn-more/" class="btn btn-success"><i class="icon-white icon-star-empty"></i> Learn More</a> <a class="btn btn-primary" href="/plugin-list/"><i class="icon-white icon-th-list"></i> Plugin List</a></p> </div> </div> <div class="row-fluid" style="text-align: center;"> <h1 style="margin-bottom:30px; font-size:40px;">4 of the top 100 plugins. Do you use them?</h1> </div> END; $first = true; foreach (loadPlugins(PLUGIN_ORDER_RANDOM_TOP100, 4) as $plugin) { $name = htmlentities($plugin->getName()); $encodedName = urlencode($name); if ($first) { echo '<div class="row-fluid">'; } echo <<<END <div class="col-xs-6"> <div class="widget-box"> <div class="widget-title"> <span class="icon"> <i class="icon-signal"></i> #{$plugin->getRank()} </span> <h5><a href="/plugin/{$encodedName}">{$name}</a></h5> </div>