Skip to content

Commit

Permalink
Web|Builder: Fixed issues with file data stored in the database
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 28, 2017
1 parent 537d284 commit 8efb9cc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
23 changes: 15 additions & 8 deletions webapi/1/admin/bdb.php
Expand Up @@ -63,29 +63,35 @@ function add_file($json_args)
{
$args = json_decode($json_args);
if ($args == NULL) return; // JSON parse error.

$db = db_open();

$build = (int) $args->build;
$plat_id = get_platform_id($db, $args->platform);
$type = ($args->type == 'binary'? FT_BINARY :
($args->type == 'log'? FT_LOG : FT_NONE));
$name = $db->real_escape_string($args->name);
$size = (int) $args->size;

$header = 'build, plat_id, type, name';
$values = "$build, $plat_id, $type, '$name'";
$header = 'build, plat_id, type, name, size';
$values = "$build, $plat_id, $type, '$name', $size";

if (property_exists($args, 'md5')) {
$md5 = $db->real_escape_string($args->md5);
$header .= ', md5';
$values .= ", '$md5'";
}
if (property_exists($args, 'signature')) {
$sigature = $db->real_escape_string($args->signature);
$signature = $db->real_escape_string($args->signature);
$header .= ', signature';
$values .= ", '$signature'";
}

if (property_exists($args, 'timestamp')) {
$ts = (int) $args->timestamp;
$header .= ', timestamp';
$values .= ", FROM_UNIXTIME($ts)";
}

db_query($db, "INSERT INTO ".DB_TABLE_FILES." ($header) VALUES ($values)");
$db->close();
}
Expand Down Expand Up @@ -164,10 +170,11 @@ function purge_old_builds()

// Set up the known platforms.
db_query($db, "INSERT INTO $table (ord, platform, name, os, cpu_arch, cpu_bits) VALUES "
. "(100, 'win-x64', 'Windows 7 (64-bit)', 'windows', 'x64', 64), "
. "(200, 'win-x86', 'Windows 7 (32-bit)', 'windows', 'x86', 32), "
. "(100, 'win-x64', 'Windows 7', 'windows', 'x64', 64), "
. "(200, 'win-x86', 'Windows 7', 'windows', 'x86', 32), "
. "(300, 'mac10_8-x86_64', 'macOS 10.8', 'macx', 'x86_64', 64), "
. "(400, 'ubuntu-x86_64', 'Ubuntu 16.04 LTS', 'linux', 'amd64', 64), "
. "(400, 'ubuntu-x86_64', 'Ubuntu 16.04', 'linux', 'amd64', 64), "
. "(450, 'ubuntu-x86', 'Ubuntu 14.04', 'linux', 'i386', 32), "
. "(500, 'fedora-x86_64', 'Fedora 23', 'linux', 'x86_64', 64), "
. "(600, 'source', 'Source', 'any', 'any', 0);");

Expand Down
2 changes: 1 addition & 1 deletion webapi/1/builds.inc.php
Expand Up @@ -68,7 +68,7 @@ function cmp_name($a, $b)
function sfnet_link($build_data, $name)
{
$sfnet_url = 'http://sourceforge.net/projects/deng/files/Doomsday%20Engine/';
if ($build_info['type'] == BT_STABLE) {
if ($build_data['type'] == BT_STABLE) {
$sfnet_url .= "$build_data[version]/";
}
else {
Expand Down
12 changes: 8 additions & 4 deletions webapi/1/builds.php
Expand Up @@ -74,12 +74,16 @@ function generate_build_page($number)
echo("<div class='filename'>$bin[name] ($mb_size MB)</div>"
."<div class='hash'>MD5: <span class='digits'>$bin[md5]</span></div>");
if (!empty($bin['signature'])) {
echo("<a class='signature' href='".DENG_API_URL."/builds?signature=$bin[name]'>PGP Signature</a>");
echo("<a class='signature' href='".DENG_API_URL."/builds?signature=$bin[name]'>PGP Signature &#x21E3;</a>");
}
$mirror_url = sfnet_link($build_info, $bin['name']);
$fext = strtoupper(pathinfo($bin['name'], PATHINFO_EXTENSION));
echo("</td><td><a class='download' href='".DENG_ARCHIVE_URL."/$bin[name]'>$fext <span class='downarrow'>&#x21E3;</span></a>");
echo("</td><td><a class='mirror' href='$mirror_url'>$fext <span class='downarrow'>&#x21E3;</span></a>");
$fext = "<span class='fext'>".strtoupper(pathinfo($bin['name'], PATHINFO_EXTENSION))."</span>";
unset($bits);
if ($plat['cpu_bits'] > 0) {
$bits = ' '.$plat['cpu_bits'].'-bit ';
}
echo("</td><td><a class='download' href='".DENG_ARCHIVE_URL."/$bin[name]'>$fext$bits<span class='downarrow'>&#x21E3;</span></a>");
echo("</td><td><a class='mirror' href='$mirror_url'>$fext$bits<span class='downarrow'>&#x21E3;</span></a>");
echo("</td></tr>\n");
}
}
Expand Down

0 comments on commit 8efb9cc

Please sign in to comment.