Exemple #1
0
function upload_identity_doc($num, $uid)
{
    $file = "file{$num}";
    if (!isset($_FILES[$file])) {
        return 0;
    }
    $info = $_FILES[$file];
    $error = $info['error'];
    if ($error) {
        if ($error == UPLOAD_ERR_INI_SIZE) {
            echo "<p>" . sprintf(_("File '%s' is bigger than the per-file limit of %s."), $info['name'], ini_get('upload_max_filesize')) . "</p>\n";
        } else {
            if ($error == UPLOAD_ERR_PARTIAL) {
                echo "<p>" . sprintf(_("File '%s' is was only partially uploaded."), $info['name']) . "</p>\n";
            } else {
                if ($error != UPLOAD_ERR_NO_FILE) {
                    echo "<p>" . sprintf(_("An error (code %s) occurred uploading file '%s'."), $error, $info['name']) . "</p>\n";
                }
            }
        }
        return 0;
    }
    $description = post("description{$num}");
    $filename = cleanup_string(basename($info['name']));
    $type = $info['type'];
    $source = $info['tmp_name'];
    $size = $info['size'];
    $dir = DOCDIR . "/{$uid}";
    @mkdir($dir, 0755);
    $base = "{$filename}";
    $index = $dir . "/00-README.txt";
    $dest = $base;
    $count = 1;
    while (file_exists($dir . "/{$dest}") || file_exists($dir . "/{$dest}.gpg")) {
        $count++;
        $dest = sprintf("upload-%d-of-%s", $count, $base);
    }
    if (!($fp = fopen("{$index}", 'a'))) {
        throw new Error("file permission error", "can't upload user identification documents");
    }
    fprintf($fp, "%s\n  %s\n    %s\n\n", date('r'), "{$dest}.gpg", $description);
    fclose($fp);
    $dest = $dir . "/{$dest}";
    rename($source, $dest);
    encrypt_file($dest, array('*****@*****.**', '*****@*****.**'));
    @unlink($dest);
    echo "<p>File '{$filename}' was uploaded and encrypted successfully.</p>\n";
    return 1;
}
Exemple #2
0
function get($key, $extra = '')
{
    if (!isset($_GET[$key])) {
        throw new Error('Ooops!', "Missing get value {$key}!");
    }
    $value = cleanup_string($_GET[$key], $extra);
    addlog(LOG_PARAMS, "  get '{$key}' = '{$value}'");
    return $value;
}
Exemple #3
0
function do_change_preferences($currentuser)
{
    global $HTTP_POST_VARS, $glob_userdata;
    foreach ($currentuser as $key => $value) {
        $currentuser[$key] = cleanup_string($value);
    }
    foreach ($HTTP_POST_VARS as $key => $value) {
        $HTTP_POST_VARS[$key] = cleanup_string($value);
    }
    $currentuser['PopupPos'] = $HTTP_POST_VARS['field_popup_pos'];
    $currentuser['PopupPos'] = $HTTP_POST_VARS['field_popup_pos'];
    $currentuser['NS6Sidebar'] = isset($HTTP_POST_VARS['field_nsside']) ? true : false;
    $currentuser['ResPerPage'] = $HTTP_POST_VARS['field_count_search_results'];
    $currentuser['HighlightSearch'] = isset($HTTP_POST_VARS['field_highlight_results']) ? true : false;
    $currentuser['MypageAfterLogon'] = isset($HTTP_POST_VARS['field_mypage_after_login']) ? true : false;
    $currentuser['NewWindow'] = isset($HTTP_POST_VARS['field_newwindow']) ? true : false;
    $currentuser['NotificationStyle'] = $HTTP_POST_VARS['field_notification_method'];
    $currentuser['Vacation'] = isset($HTTP_POST_VARS['field_vacation_mode']) ? true : false;
    set_user_at_name($currentuser['Username'], $currentuser);
    $glob_userdata = $currentuser;
}
<?php

require_once '../util.php';
if (count($argv) < 2) {
    echo "need account name to synchronise\n";
    exit(-1);
}
$uid = cleanup_string($argv[1]);
# check they actually exist
$query = "SELECT 1 FROM users WHERE uid='{$uid}'";
$result = do_query($query);
if (has_results($result)) {
    sync_to_bitcoin($uid);
    echo "Done.\n";
} else {
    echo "User {$uid} doesn't exist.\n";
}
Exemple #5
0
function redeem_mtgox_fiat_voucher($code)
{
    global $is_logged_in;
    if (!ENABLE_MTGOX_VOUCHERS) {
        throw Error('MtGox vouchers are not enabled on this site', 'Redeeming MtGox voucher codes is disabled.');
    }
    $mtgox = new MtGox_API(MTGOX_KEY, MTGOX_SECRET);
    $result = $mtgox->deposit_coupon($code);
    // echo "result: <pre>" . var_dump($result) . "</pre><br/>\n";
    // successful coupon deposit:
    //
    // array(4) {
    //   ["amount"]=>  float(0.01)
    //   ["currency"]=>  string(3) "BTC"
    //   ["reference"]=>  string(36) "beabf9ce-07b6-4852-ae71-4cfc671ff35d"
    //   ["status"]=>     string(49) "Your account has been credited by 0.01000000 BTC"
    // }
    // trying to redeem an already-spent code - note no 'status':
    //
    // array(1) {
    //   ["error"]=>  string(59) "This code cannot be redeemed (non existing or already used)"
    // }
    if (isset($result['error'])) {
        throw new Exception($result['error']);
    }
    $amount = numstr_to_internal(cleanup_string($result['amount']));
    $curr_type = cleanup_string($result['currency']);
    // $reference = cleanup_string($result['reference'], '-');
    $status = cleanup_string($result['status']);
    // echo "<p>When we tried to redeem that voucher into our account, MtGox said: <strong>$status</strong></p>\n";
    $commission = commission_on_deposit_mtgox_fiat_voucher($amount);
    $amount = gmp_strval(gmp_sub($amount, $commission));
    $query = "\n        INSERT INTO requests (req_type, uid, amount, commission, curr_type, status)\n        VALUES ('DEPOS', '{$is_logged_in}', '{$amount}', '{$commission}', '{$curr_type}', 'FINAL');\n    ";
    do_query($query);
    add_funds(1, $commission, $curr_type);
    add_funds($is_logged_in, $amount, $curr_type);
    return array($curr_type, $amount);
}