-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_app_version.php
58 lines (49 loc) · 1.4 KB
/
add_app_version.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
// remotely add an app version
//
require_once("../inc/util.inc");
require_once("../inc/bootstrap.inc");
function form() {
page_head("Add app version");
form_start("add_app_version.php", 'post', 'ENCTYPE="multipart/form-data"');
form_input_hidden("action", "add");
form_general("Zip file", "<input name=zipfile type=file>");
form_submit("OK");
form_end();
page_tail();
}
function get_upload_file($name, $dest_name) {
if ($_FILES[$name]['error'] != UPLOAD_ERR_OK) return -1;
$tmp_name = $_FILES[$name]['tmp_name'];
if (!move_uploaded_file($tmp_name, $dest_name)) return -1;
return 0;
}
function action() {
if (get_upload_file('zipfile', 'aav.zip')) {
error_page("can't upload zip file");
}
$cmd = "unzip -u aav.zip -d ../../apps > /dev/null";
passthru($cmd, $ret);
if ($ret) error_page("unzip failed: $cmd");
page_head("Adding app version");
echo "<pre>";
$cmd = "cd ../..; bin/update_versions --noconfirm";
passthru($cmd, $ret);
echo "</pre>";
if ($ret) echo "update_versions failed: $cmd returned $ret";
page_tail();
}
$user = get_logged_in_user();
$uids = parse_config(get_config(), "<add_av_userids>");
if (!$uids) die('no uids');
$uids = explode(',', $uids);
if (!in_array($user->id, $uids)) {
die('bad uid');
}
$action = post_str("action", true);
if ($action == "add") {
action();
} else {
form();
}
?>