Example #1
0
function create_secret()
{
    global $repo_directory, $secret_name;
    $now = floor(time() / 60 / 60);
    // number of hours since 1970
    $secret = "";
    create_secrets_directory();
    do {
        $secret = create_random_message(9);
    } while (file_exists($repo_directory . $secret_name . $secret));
    $file = fopen($repo_directory . $secret_name . $secret, "w");
    fwrite($file, "{$now}");
    fclose($file);
    return $secret;
}
Example #2
0
function save_bundle()
{
    global $repo_directory, $bundle_name, $emailaddress;
    $repo = $_GET['p'];
    $dname = "{$repo_directory}{$bundle_name}{$repo}/";
    create_bundles_directory();
    if ($_FILES['bundle_file']['error'] != UPLOAD_ERR_OK) {
        return false;
    }
    $fname = "";
    do {
        $fname = create_random_message(9);
    } while (is_file("{$dname}{$fname}"));
    $fullpath = "{$dname}{$fname}";
    if (false == move_uploaded_file($_FILES['bundle_file']['tmp_name'], $fullpath)) {
        return false;
    }
    chmod($fullpath, 0666);
    $file = fopen("{$fullpath}.txt", "w");
    fwrite($file, $_POST['commiter_name'], 40);
    fclose($file);
    chmod("{$fullpath}.txt", 0666);
    // send e-mail message about the commitment
    $message = "{$_POST['commiter_name']}\n {$fullpath}\n";
    $headers = "From: {$emailaddress}\r\n" . "Reply-To: {$emailaddress}\r\n" . 'X-Mailer: PHP/' . phpversion();
    $ok = mail($emailaddress, "Bundle sent to {$repo}", $message, $headers);
    if (!$ok) {
        echo "Error sending email message\n";
    }
    return true;
}