Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

107 lines (92 sloc) 4.27 kb
require 'includes/';
$nav = 'applications';
$app = new Application($_GET['id']);
if(!$app->ok()) redirect('index.php');
$Error->blank($_POST['version_number'], 'Version Number');
$Error->blank($_POST['human_version'], 'Human Readable Version Number');
$Error->upload($_FILES['file'], 'file');
$v = new Version();
$v->app_id = $app->id;
$v->version_number = $_POST['version_number'];
$v->human_version = $_POST['human_version'];
$v->release_notes = $_POST['release_notes'];
$v->dt = dater();
$v->downloads = 0;
$v->filesize = filesize($_FILES['file']['tmp_name']);
$v->signature = sign_file($_FILES['file']['tmp_name'], $app->sparkle_pkey);
$object = strtolower(preg_replace('/[^a-zA-Z0-9]/', '', $app->name)) . "_" . $v->version_number . "." . substr($_FILES['file']['name'], -3);
$v->url = slash($app->s3path) . $object;
$info = parse_url($app->s3path);
$object = slash($info['path']) . $object;
chmod($_FILES['file']['tmp_name'], 0755);
// $s3 = new S3($app->s3key, $app->s3pkey);
// $s3->uploadFile($app->s3bucket, $object, $_FILES['file']['tmp_name'], true);
redirect('versions.php?id=' . $app->id);
$version_number = $_POST['version_number'];
$human_version = $_POST['human_version'];
$release_notes = $_POST['release_notes'];
$version_number = '';
$human_version = '';
$release_notes = '';
// It would be better to use PHP's native OpenSSL extension
// but it's PHP 5.3+ only. Too early to force that requirement
// upon users.
function sign_file($filename, $keydata)
$binary_hash = shell_exec('/usr/bin/openssl dgst -sha1 -binary < ' . $filename);
$hash_tmp_file = tempnam('/tmp', 'foo');
file_put_contents($hash_tmp_file, $binary_hash);
$key_tmp_file = tempnam('/tmp', 'bar');
if(strpos($keydata, '-----BEGIN DSA PRIVATE KEY-----') === false)
$keydata = "-----BEGIN DSA PRIVATE KEY-----\n" . $keydata . "\n-----END DSA PRIVATE KEY-----\n";
file_put_contents($key_tmp_file, $keydata);
$signed_data = shell_exec("/usr/bin/openssl dgst -dss1 -sign $key_tmp_file < $hash_tmp_file");
return base64_encode($signed_data);
<?PHP include('inc/'); ?>
<div id="bd">
<div id="yui-main">
<div class="yui-b"><div class="yui-g">
<div class="block tabs spaces">
<?PHP echo $Error; ?>
<div class="hd">
<li><a href="application.php?id=<?PHP echo $app->id; ?>"><?PHP echo $app->name; ?></a></li>
<li><a href="versions.php?id=<?PHP echo $app->id; ?>">Versions</a></li>
<li class="active"><a href="version-new.php?id=<?PHP echo $app->id; ?>">Release New Version</a></li>
<div class="clear"></div>
<div class="bd">
<form action="version-new.php?id=<?PHP echo $app->id; ?>" method="post" enctype="multipart/form-data">
<p><label for="version_number">Sparkle Version Number</label> <input type="text" name="version_number" id="version_number" value="<?PHP echo $version_number;?>" class="text"></p>
<p><label for="human_version">Human Readable Version Number</label> <input type="text" name="human_version" id="human_version" value="<?PHP echo $human_version;?>" class="text"></p>
<p><label for="release_notes">Release Notes</label> <textarea class="text" name="release_notes" id="release_notes"><?PHP echo $release_notes; ?></textarea></p>
<p><label for="file">Application Archive</label> <input type="file" name="file" id="file"></p>
<p><input type="submit" name="btnCreateVersion" value="Create Version" id="btnCreateVersion"></p>
<div id="sidebar" class="yui-b">
<?PHP include('inc/'); ?>
Jump to Line
Something went wrong with that request. Please try again.