Fixed problems with bitbanged Dshot and lazily allocated timers.
[betaflight.git] / support / buildserver / upload.php
blobef9fd306abd2e75e34ea27cac9df341482ba6da9
1 <?php
2 // see docs/Travis.md, .travis.sh
4 $baseDir = "/var/www/builds/";
6 $firmwareFile = $_FILES["file"];
7 $manualFile = $_FILES["manual"];
9 $recentCommits = $_POST["recent_commits"];
10 $travisJobId = sanitize($_POST["travis_build_number"]);
11 $lastCommitDate = sanitize($_POST["last_commit_date"]);
12 $revision = sanitize($_POST["revision"]);
13 $branch = sanitize($_POST["branch"]);
15 $github_repo = sanitize($_POST["github_repo"]);
16 $build_name = sanitize($_POST["build_name"]);
18 $uploadDir = $baseDir . "/" . $github_repo . "/" . $lastCommitDate . "/";
19 $prefix = $uploadDir . $travisJobId . "_" . $revision . "_" . $build_name;
21 if(!file_exists($uploadDir)) mkdir($uploadDir, 0770, true);
23 if($firmwareFile) {
24 $uploadfile = $prefix . "_" . (basename($firmwareFile['name']));
25 if(move_uploaded_file($firmwareFile['tmp_name'], $uploadfile)) {
26 echo "upload succeeded.\n";
28 else {
29 echo "upload failed $uploadfile\n";
33 if($manualFile) {
34 $uploadfile = $prefix . "_" . (basename($manualFile['name']));
35 if(move_uploaded_file($manualFile['tmp_name'], $uploadfile)) {
36 echo "upload succeeded.\n";
38 else {
39 echo "upload failed $uploadfile\n";
43 if($revision && $lastCommitDate && $recentCommits) {
44 $changelog = fopen($prefix . "_changes.txt", "w") or die ("unable to open changelog file for writing");
45 fwrite($changelog, $recentCommits);
46 fclose($changelog);
49 print_r($_FILES);
50 print_r($_POST);
51 print_r($_GET);
53 function sanitize($str) {
54 return (preg_replace('/[^A-Za-z0-9_\-]/', '_', ($str)));