예제 #1
0
 public static function loadBasicDummyData()
 {
     TestManager::clearDatabase();
     $database = new DatabaseManager();
     UserManager::verifyTable($database);
     AddonManager::verifyTable($database);
     BoardManager::verifyTable($database);
     TagManager::verifyTable($database);
     GroupManager::verifyTable($database);
     DependencyManager::verifyTable($database);
     CommentManager::verifyTable($database);
     RatingManager::verifyTable($database);
     BuildManager::verifyTable($database);
     StatManager::verifyTable($database);
     ScreenshotManager::verifyTable($database);
     if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('General Content', 'general_content_bg', 'Bricks, Events, Sounds, Prints, Environments, and much more!')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('Minigames', 'minigames_bg', 'Weapons, Vehicles, Gamemodes, and all your gaming needs!')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('Client Mods', 'client_mods_bg', 'Mods that run on your client.')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('Bargain Bin', 'bargain_bin_bg', 'A home for \\'special\\' content.')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `users` (username, blid, password, email, salt, verified) VALUES ('testuser', '4833', '1d8436e97ef95a7a6151f47b909167c77cfe1985ee5500efa8d46cfe825abc59', '*****@*****.**', '273eb4', '1')")) {
         throw new Exception("Database error: " . $database->error());
     }
     //the default json types likely need to be reworked
     if (!$database->query("INSERT INTO `addon_addons` (board, blid, name, filename, description, approved, versionInfo, authorInfo, reviewInfo) VALUES ('1', '4833', 'crapy adon', 'sciprt_hax.zip', 'bad addone pls delete', '1', '{}', '[]', '[]')")) {
         throw new Exception("Database error: " . $database->error());
     }
     StatManager::addStatsToAddon(1);
     if (!$database->query("INSERT INTO `addon_tags` (name, base_color, icon) VALUES ('dum tag', 'ff6600', 'brokenimage')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_tagmap` (aid, tid) VALUES ('1', '1')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `group_groups` (leader, name, description, color, icon) VALUES ('4833', 'legion of dumies', 'a group for people who just want to be in a group', '00ff00', 'brokenimage')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `group_usermap` (gid, blid, administrator) VALUES ('1', '4833', '1')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_comments` (blid, aid, comment) VALUES ('4833', '1', 'glorious addon comrade')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_ratings` (blid, aid, rating) VALUES ('4833', '1', '1')")) {
         throw new Exception("Database error: " . $database->error());
     }
 }
예제 #2
0
<?php

if (!isset($_GET['id'])) {
    $response = ["redirect" => "/builds/index.php"];
    return $response;
}
require_once realpath(dirname(__DIR__) . "/class/BuildManager.php");
require_once realpath(dirname(__DIR__) . "/class/UserManager.php");
require_once realpath(dirname(__DIR__) . "/class/ScreenshotManager.php");
//	require_once(realpath(dirname(__DIR__) . "/class/TagManager.php"));
//	require_once(realpath(dirname(__DIR__) . "/class/DependencyManager.php"));
$build = BuildManager::getFromID($_GET['id'] + 0);
if ($build === false) {
    $response = ["redirect" => "/builds/index.php"];
    return $response;
}
$user = UserManager::getFromBLID($build->blid);
//	$tagIDs = $build->getTags();
//	$dependencyIDs = $build->getDependencies();
//	$tags = [];
//	$dependencies = [];
//
//	foreach($tagIDS as $tid) {
//		$tags[] = TagManager::getFromID($tid);
//	}
//
//	foreach($dependencyIDs as $did) {
//		$dependencies[] = DependencyManager::getFromID($did);
//	}
$screenshotIDs = ScreenshotManager::getScreenshotsFromBuild($build->id);
$primaryScreenshotID = ScreenshotManager::getBuildPrimaryScreenshot($build->id);
예제 #3
0
<?php

require_once dirname(__DIR__) . "/../../../private/class/BuildManager.php";
require_once dirname(__DIR__) . "/../../../private/class/ScreenshotManager.php";
$bid = $_REQUEST['id'];
$buldObject = BuildManager::getFromID($bid);
//$screens = ScreenshotManager::getScreenshotsFromAddon($aid); //I dont think this is done
$ret = new stdClass();
$ret->bid = $bid;
$ret->filename = $info = (new SplFileInfo($buldObject->getFilename()))->getFilename();
$ret->name = $buldObject->getName();
$ret->description = htmlspecialchars_decode($buldObject->getDescription());
$ret->screenshots = array();
/*foreach($screens as $screen) {
  $screenshot = new stdClass();
  $screenshot->id = $screen->getId();
  $screenshot->url = "http://api.blocklandglass.com/files/screenshots/" . $addonObject->getId() . "/" . $i . ".png";
  $screenshot->thumbnail = "http://api.blocklandglass.com/files/screenshots/" . $addonObject->getId() . "/" . $i . "_thumb.png";
  list($width, $height) = getimagesize(dirname(__DIR__) . "/files/screenshots/" . $addonObject->getId() . "/" . $i . ".png");
  $screenshot->extent = $width . " " . $height;
  $ret->screenshots[] = $screenshot;
}*/
$author = new stdClass();
//$author->blid = $addonObject->getAuthor()->getBlid();
//$author->name = $addonObject->getAuthor()->getName();
$ret->authors = $author;
echo json_encode($ret, JSON_PRETTY_PRINT);
예제 #4
0
    if ($check === false) {
        $response = ["message" => "Invalid image uploaded", "build" => $build, "user" => $user];
        return $response;
    }
    $uploadExt = pathinfo($_FILES['screenshots']['name'], PATHINFO_EXTENSION);
    if ($uploadExt != "png" && $uploadExt != "jpg") {
        $response = ["message" => "Only .png and .jpg screenshots are allowed", "build" => $build, "user" => $user];
        return $response;
    }
    require_once realpath(dirname(__DIR__) . "/class/ScreenshotManager.php");
    if ($_FILES['screenshots']['size'] > ScreenshotManager::$maxFileSize) {
        $response = ["message" => "File too large - The maximum Screenshot file size is 3 MB", "build" => $build, "user" => $user];
        return $response;
    }
    require_once realpath(dirname(__DIR__) . "/class/ScreenshotManager.php");
    ScreenshotManager::uploadScreenshotForBuild($build, $uploadExt, $tempPath);
    $changed = true;
}
$subResponse = BuildManager::updateBuild($build, $_POST['buildname'], $_POST['description']);
if ($subResponse['message'] !== "") {
    $response = ["message" => $subResponse['message'], "build" => $build, "user" => $user];
    return $response;
} else {
    if ($changed) {
        $response = ["message" => "Screenshots Updated", "build" => $build, "user" => $user];
        return $response;
    } else {
        $response = ["message" => "No changes were made", "build" => $build, "user" => $user];
        return $response;
    }
}
 function collectHourStat($store = false)
 {
     $stats = new stdClass();
     $stats->time = gmdate("Y-m-d H:00:00", time());
     $stats->duration = "hour";
     $database = new DatabaseManager();
     //Addons!
     $addons = new stdClass();
     $addonArray = AddonManager::getAll();
     $addons->count = sizeof($addonArray);
     $addons->cumulative_downloads = array();
     $addons->usage = array();
     $addons->usage_total = array();
     foreach ($addonArray as $addon) {
         $downloadData = new stdClass();
         // TODO we need to go back. I dont want total downloads, I want individual
         //$downloadData->web =
         //$downloadData->ingame =
         //$downloadData->update =
         $addons->cumulative_downloads[$addon->getId()] = $downloadData;
         $res = $database->query("SELECT `version` FROM `stats_usage` WHERE `aid`='" . $addon->getId() . "' AND `reported` > now() - INTERVAL 1 HOUR");
         $ret = $res->fetch_object();
         $usage = array();
         $total = 0;
         while ($obj = $res->fetch_object()) {
             $total++;
             if (!isset($usage[$obj->version])) {
                 $usage[$obj->version] = 1;
             } else {
                 $usage[$obj->version]++;
             }
         }
         $addons->usage[$addon->getId()] = $usage;
         $addons->usage_total[$addon->getId()] = $total;
     }
     $stats->addons = $addons;
     //Builds
     $builds = new stdClass();
     $buildArray = BuildManager::getAll();
     $builds->count = sizeof($buildArray);
     $builds->cumulative_downloads = array();
     foreach ($buildArray as $build) {
         // TODO this isn't done either...
         //$builds->cumulative_downloads[$build->getId()] = $build->getDownloads();
     }
     $stats->builds = $builds;
     //Master Server
     $stats->master = new stdClass();
     $master = CronStatManager::getMasterServerStats();
     $stats->master->users = $master[0];
     $stats->master->servers = $master[1];
     if ($store) {
         CronStatManager::verifyTable($database);
         $database->query("INSERT INTO `cron_statistics`  (`time` , `duration` , `data`) VALUES ('" . $stats->time . "',  'hour',  '" . $database->sanitize(json_encode($stats)) . "')");
     }
     return $stats;
 }
예제 #6
0
 public static function verifyTable($database)
 {
     if ($database->debug()) {
         UserManager::verifyTable($database);
         AddonManager::verifyTable($database);
         TagManager::verifyTable($database);
         BuildManager::verifyTable($database);
         GroupManager::verifyTable($database);
         if (!$database->query("CREATE TABLE IF NOT EXISTS `addon_stats` (\n\t\t\t\t`aid` INT NOT NULL,\n\t\t\t\t`rating` FLOAT,\n\t\t\t\t`totalDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`iterationDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`webDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`ingameDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`updateDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\tKEY (`totalDownloads`),\n\t\t\t\tKEY (`iterationDownloads`),\n\t\t\t\tFOREIGN KEY (`aid`)\n\t\t\t\t\tREFERENCES addon_addons(`id`)\n\t\t\t\t\tON UPDATE CASCADE\n\t\t\t\t\tON DELETE CASCADE)")) {
             throw new Exception("Failed to create addon stats table: " . $database->error());
         }
         if (!$database->query("CREATE TABLE IF NOT EXISTS `build_stats` (\n\t\t\t\t`bid` INT NOT NULL,\n\t\t\t\t`rating` FLOAT,\n\t\t\t\t`totalDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`iterationDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\tKEY (`totalDownloads`),\n\t\t\t\tKEY (`iterationDownloads`),\n\t\t\t\tFOREIGN KEY (`bid`)\n\t\t\t\t\tREFERENCES build_builds(`id`)\n\t\t\t\t\tON UPDATE CASCADE\n\t\t\t\t\tON DELETE CASCADE)")) {
             throw new Exception("Failed to create build stats table: " . $database->error());
         }
         if (!$database->query("CREATE TABLE IF NOT EXISTS `tag_stats` (\n\t\t\t\t`tid` INT NOT NULL,\n\t\t\t\t`totalDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`iterationDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\tKEY (`totalDownloads`),\n\t\t\t\tKEY (`iterationDownloads`),\n\t\t\t\tFOREIGN KEY (`tid`)\n\t\t\t\t\tREFERENCES addon_tags(`id`)\n\t\t\t\t\tON UPDATE CASCADE\n\t\t\t\t\tON DELETE CASCADE)")) {
             throw new Exception("Failed to create tag stats table: " . $database->error());
         }
         //includes a lot of foreign keys, not sure if it is a good idea to include them all
         if (!$database->query("CREATE TABLE IF NOT EXISTS `statistics` (\n\t\t\t\t`id` INT NOT NULL AUTO_INCREMENT,\n\t\t\t\t`date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t\t`users` INT NOT NULL DEFAULT 0,\n\t\t\t\t`addons` INT NOT NULL DEFAULT 0,\n\t\t\t\t`downloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`groups` INT NOT NULL DEFAULT 0,\n\t\t\t\t`comments` INT NOT NULL DEFAULT 0,\n\t\t\t\t`builds` INT NOT NULL DEFAULT 0,\n\t\t\t\t`tags` INT NOT NULL DEFAULT 0,\n\t\t\t\t`addon0` INT NOT NULL,\n\t\t\t\t`addon1` INT NOT NULL,\n\t\t\t\t`addon2` INT NOT NULL,\n\t\t\t\t`addon3` INT NOT NULL,\n\t\t\t\t`addon4` INT NOT NULL,\n\t\t\t\t`addon5` INT NOT NULL,\n\t\t\t\t`addon6` INT NOT NULL,\n\t\t\t\t`addon7` INT NOT NULL,\n\t\t\t\t`addon8` INT NOT NULL,\n\t\t\t\t`addon9` INT NOT NULL,\n\t\t\t\t`addonDownloads0` INT NOT NULL,\n\t\t\t\t`addonDownloads1` INT NOT NULL,\n\t\t\t\t`addonDownloads2` INT NOT NULL,\n\t\t\t\t`addonDownloads3` INT NOT NULL,\n\t\t\t\t`addonDownloads4` INT NOT NULL,\n\t\t\t\t`addonDownloads5` INT NOT NULL,\n\t\t\t\t`addonDownloads6` INT NOT NULL,\n\t\t\t\t`addonDownloads7` INT NOT NULL,\n\t\t\t\t`addonDownloads8` INT NOT NULL,\n\t\t\t\t`addonDownloads9` INT NOT NULL,\n\t\t\t\t`tag0` INT NOT NULL,\n\t\t\t\t`tag1` INT NOT NULL,\n\t\t\t\t`tag2` INT NOT NULL,\n\t\t\t\t`tag3` INT NOT NULL,\n\t\t\t\t`tag4` INT NOT NULL,\n\t\t\t\t`tagDownloads0` INT NOT NULL,\n\t\t\t\t`tagDownloads1` INT NOT NULL,\n\t\t\t\t`tagDownloads2` INT NOT NULL,\n\t\t\t\t`tagDownloads3` INT NOT NULL,\n\t\t\t\t`tagDownloads4` INT NOT NULL,\n\t\t\t\t`build0` INT NOT NULL,\n\t\t\t\t`build1` INT NOT NULL,\n\t\t\t\t`build2` INT NOT NULL,\n\t\t\t\t`buildDownloads0` INT NOT NULL,\n\t\t\t\t`buildDownloads1` INT NOT NULL,\n\t\t\t\t`buildDownloads2` INT NOT NULL,\n\t\t\t\tKEY (`date`),\n\t\t\t\tPRIMARY KEY (`id`))")) {
             throw new Exception("Failed to create stat history table: " . $database->error());
         }
     }
 }
예제 #7
0
 public static function updateBuild($build, $buildname, $description)
 {
     //to do: apc_delete and update existing object
     $changed = false;
     if ($buildname !== $build->name) {
         //validate build name
         //match 1-60 of any character except newlines
         //this should probably be a method instead of copy pasted from above
         if (!preg_match("/^.{1,60}\$/", $buildName)) {
             $response = ["changed" => $changed, "message" => "Your Build Title can only contain up to 60 characters and cannot contain line breaks"];
             return $response;
         }
         $database = new DatabaseManager();
         BuildManager::verifyTable($database);
         if (!$database->query("UPDATE `build_builds` SET `name` = '" . $database->sanitize($buildname) . "'")) {
             throw new Exception("Database error: " . $database->error());
         }
         $build->name = $buildname;
         apc_store('buildObject_' . $build->id, $build, BuildManager::$objectCacheTime);
         $changed = true;
     }
     //if($filename !== $build->filename) {
     //	//allows letters, numbers, '-', '_', '\'', '!', and ' '
     //	if(!preg_match("/^[a-zA-Z0-9\-\_\ \'\!]{1,56}\.bls$/", $filename)) {
     //		$response = [
     //			"ok" => $changed,
     //			"message" => "Invalid File Name - You may use up to 56 characters followed by '.bls' and include letters, numbers, spaces, and the following symbols: -, ', _, and !"
     //		];
     //		return $response;
     //	}
     //	$other = BuildManager::getIDFromFileName($filename);
     //
     //	if($other !== false) {
     //		$response = [
     //			"changed" => $changed,
     //			"message" => "A Build with that File Name already exists - ID " . $other
     //		];
     //		return $response;
     //	}
     //	$database = new DatabaseManager();
     //	BuildManager::verifyTable($database);
     //
     //	if(!$database->query("UPDATE `build_builds` SET `filename` = '" .
     //		$database->sanitize($filename) . "'")) {
     //		throw new Exception("Database error: " . $database->error());
     //	}
     //	$build->filename = $filename;
     //	apc_store('buildObject_' . $build->id, $build, BuildManager::$objectCacheTime);
     //	$changed = true;
     //}
     if ($description !== $build->description) {
         $database = new DatabaseManager();
         BuildManager::verifyTable($database);
         if (!$database->query("UPDATE `build_builds` SET `description` = '" . $database->sanitize($description) . "'")) {
             throw new Exception("Database error: " . $database->error());
         }
         $build->description = $description;
         apc_store('buildObject_' . $build->id, $build, BuildManager::$objectCacheTime);
         $changed = true;
     }
     if ($changed) {
         $response = ["changed" => true, "message" => "Build Updated"];
         return $response;
     } else {
         $response = ["changed" => false, "message" => ""];
         return $response;
     }
 }
예제 #8
0
 public static function verifyTable($database)
 {
     if ($database->debug()) {
         require_once realpath(dirname(__FILE__) . '/UserManager.php');
         require_once realpath(dirname(__FILE__) . '/AddonManager.php');
         require_once realpath(dirname(__FILE__) . '/BuildManager.php');
         UserManager::verifyTable($database);
         //we need users table to exist before we can create this one
         AddonManager::verifyTable($database);
         BuildManager::verifyTable($database);
         //we need to be able to build a url out of this data too
         //	UNIQUE KEY (`filename`),
         if (!$database->query("CREATE TABLE IF NOT EXISTS `screenshots` (\n\t\t\t\t`id` INT NOT NULL AUTO_INCREMENT,\n\t\t\t\t`blid` INT NOT NULL,\n\t\t\t\t`name` VARCHAR(60),\n\t\t\t\t`filename` VARCHAR(60),\n\t\t\t\t`description` TEXT,\n\t\t\t\tFOREIGN KEY (`blid`)\n\t\t\t\t\tREFERENCES users(`blid`)\n\t\t\t\t\tON UPDATE CASCADE\n\t\t\t\t\tON DELETE CASCADE,\n\t\t\t\tKEY (`name`),\n\t\t\t\tPRIMARY KEY (`id`))")) {
             throw new Exception("Error creating screenshots table: " . $database->error());
         }
         if (!$database->query("CREATE TABLE IF NOT EXISTS `build_screenshotmap` (\n\t\t\t\t`id` INT NOT NULL AUTO_INCREMENT,\n\t\t\t\t`sid` INT NOT NULL,\n\t\t\t\t`bid` INT NOT NULL,\n\t\t\t\t`primary` TINYINT NOT NULL DEFAULT 0,\n\t\t\t\tFOREIGN KEY (`sid`)\n\t\t\t\t\tREFERENCES screenshots(`id`)\n\t\t\t\t\tON UPDATE CASCADE\n\t\t\t\t\tON DELETE CASCADE,\n\t\t\t\tFOREIGN KEY (`bid`)\n\t\t\t\t\tREFERENCES build_builds(`id`)\n\t\t\t\t\tON UPDATE CASCADE\n\t\t\t\t\tON DELETE CASCADE,\n\t\t\t\tPRIMARY KEY (`id`))")) {
             throw new Exception("Error creating build_screenshotmap table: " . $database->error());
         }
         if (!$database->query("CREATE TABLE IF NOT EXISTS `addon_screenshotmap` (\n\t\t\t\t`id` INT NOT NULL AUTO_INCREMENT,\n\t\t\t\t`sid` INT NOT NULL,\n\t\t\t\t`aid` INT NOT NULL,\n\t\t\t\tFOREIGN KEY (`sid`)\n\t\t\t\t\tREFERENCES screenshots(`id`)\n\t\t\t\t\tON UPDATE CASCADE\n\t\t\t\t\tON DELETE CASCADE,\n\t\t\t\tFOREIGN KEY (`aid`)\n\t\t\t\t\tREFERENCES addon_addons(`id`)\n\t\t\t\t\tON UPDATE CASCADE\n\t\t\t\t\tON DELETE CASCADE,\n\t\t\t\tPRIMARY KEY (`id`))")) {
             throw new Exception("Error creating addon_screenshotmap table: " . $database->error());
         }
     }
 }
예제 #9
0
    $response = ["message" => "Only .bls files are allowed"];
    return $response;
}
require_once realpath(dirname(__DIR__) . "/class/BuildManager.php");
if ($_FILES['uploadfile']['size'] > BuildManager::$maxFileSize) {
    $response = ["message" => "File too large - The maximum build file size is 10 MB"];
    return $response;
}
$uploadContents = file($_FILES['uploadfile']['tmp_name']);
$tempPath = $_FILES['uploadfile']['tmp_name'];
$uploadBuildName = basename($_FILES['uploadfile']['name'], ".bls");
$uploadFileName = basename($_FILES['uploadfile']['name'], ".bls");
if (isset($_POST['buildname']) && $_POST['buildname'] != "") {
    //trim .bls from end of file name if it exists
    //$uploadBuildName = preg_replace("/\\.bls$/", "", $_POST['buildname']);
    $uploadBuildName = $_POST['buildname'];
}
if (isset($_POST['filename']) && $_POST['filename'] != "") {
    //trim .bls from end of file name if it exists
    $uploadFileName = $_POST['filename'];
}
if (!preg_match("/\\.bls\$/", $uploadFileName)) {
    $uploadFileName .= ".bls";
}
if (!isset($_POST['description']) && $_POST['description'] != "") {
    $uploadDescription = $_POST['description'];
    $response = BuildManager::uploadBuild($user->getBLID(), $uploadBuildName, $uploadFileName, $uploadContents, $tempPath, $uploadDescription);
} else {
    $response = BuildManager::uploadBuild($user->getBLID(), $uploadBuildName, $uploadFileName, $uploadContents, $tempPath);
}
return $response;
예제 #10
0
								<br />
								<span style="font-size: 0.8em;">
									<a href="#">Update</a> | <a href="#">Edit</a> | <a href="#">Repository</a> | <a href="#">Delete</a>
								</span>
							</div>
							<?php 
}
?>
						<div class="useraddon" style="text-align:center; background-color: #ccffcc">
							<img style="width: 1.2em;" src="http://blocklandglass.com/icon/icons32/add.png" alt="New"/> <a href="/addons/upload.php">Upload a new Add-on...</a>
						</div>
						<?php 
echo "<hr>";
$builds = BuildManager::getBuildsFromBLID($userObject->getBLID());
foreach ($builds as $bid) {
    $bo = BuildManager::getFromId($bid);
    ?>
							<div class="useraddon">
								<a href="/builds/"><img style="width: 1.2em;" src="http://blocklandglass.com/icon/icons32/bricks.png" /> <span style="font-size: 1.2em; font-weight:bold;"><?php 
    echo $bo->getName();
    ?>
</span></a>
								<br />
								<span style="font-size: 0.8em;">
									<a href="/builds/manage.php?id=<?php 
    echo $bo->getId();
    ?>
">Manage</a> | <a href="#">Delete</a>
								</span>
							</div>
							<?php 
예제 #11
0
 function collectHourStat($store = false)
 {
     $stats = new stdClass();
     $stats->time = gmdate("Y-m-d H:00:00", time());
     $stats->duration = "hour";
     //Addons!
     $addons = new stdClass();
     $addonArray = AddonManager::getAll();
     $addons->count = sizeof($addonArray);
     $addons->cumulative_downloads = array();
     foreach ($addonArray as $addon) {
         $downloadData = new stdClass();
         // TODO we need to go back. I dont want total downloads, I want individual
         //$downloadData->web =
         //$downloadData->ingame =
         //$downloadData->update =
         $addons->cumulative_downloads[$addon->getId()] = $downloadData;
     }
     $stats->addons = $addons;
     //Builds
     $builds = new stdClass();
     $buildArray = BuildManager::getAll();
     $builds->count = sizeof($buildArray);
     $builds->cumulative_downloads = array();
     foreach ($buildArray as $build) {
         // TODO this isn't done either...
         //$builds->cumulative_downloads[$build->getId()] = $build->getDownloads();
     }
     $stats->builds = $builds;
     //Master Server
     $stats->master = new stdClass();
     $master = CronStatManager::getMasterServerStats();
     $stats->master->users = $master[0];
     $stats->master->servers = $master[1];
     if ($store) {
         $database = new DatabaseManager();
         CronStatManager::verifyTable($database);
         $database->query("INSERT INTO `cron_statistics`  (`time` , `duration` , `data`) VALUES ('" . $stats->time . "',  'hour',  '" . $database->sanitize(json_encode($stats)) . "')");
     }
     return $stats;
 }