$q->execute(array($title, user_id(), $id));
        $messages[] = t("Updated :title title.", array(':title' => htmlspecialchars($account_data['title'])));
        // redirect to GET
        set_temporary_messages($messages);
        redirect(url_for("wizard_accounts_addresses#wizard_" . $currency));
    }
}
// process add
if (require_post("add", false) && require_post("address", false)) {
    $address = trim(require_post("address"));
    $title = trim(require_post("title", false));
    $callback = $account_data['callback'];
    if (!$callback($address)) {
        $errors[] = t("':address' is not a valid :title.", array(':address' => htmlspecialchars($address), ':title' => htmlspecialchars($account_data['title'])));
    } else {
        if (!is_valid_title($title)) {
            $errors[] = t("':value' is not a valid :title title.", array(':value' => htmlspecialchars($title), ':title' => htmlspecialchars($account_data['title'])));
        } else {
            if (!can_user_add($user, $account_data['premium_group'])) {
                $errors[] = t("Cannot add address: too many existing addresses.") . ($user['is_premium'] ? "" : " " . t("To add more addresses, upgrade to a :premium_account.", array(':premium_account' => link_to(url_for('premium'), t('premium account')))));
            } else {
                // we don't care if the address already exists
                $q = db()->prepare("INSERT INTO " . $account_data['table'] . " SET user_id=?, address=?, currency=?, title=?");
                $q->execute(array(user_id(), $address, $account_data['currency'], $title));
                $messages[] = t("Added new address :address. Balances from this address will be retrieved shortly.", array(':address' => crypto_address($account_data['currency'], $address), ':title' => htmlspecialchars($account_data['title'])));
                // update has_added_account
                $q = db()->prepare("UPDATE user_properties SET has_added_account=1,last_account_change=NOW() WHERE id=?");
                $q->execute(array(user_id()));
                // redirect to GET
                set_temporary_messages($messages);
                redirect(url_for("wizard_accounts_addresses#wizard_" . $currency));
Пример #2
0
             $errors[] = t("That is not a valid :title :label.", array(':title' => htmlspecialchars($account_data['title']), ':label' => htmlspecialchars($data['title'])));
         }
         break;
     } else {
         $query .= ", {$key}=?";
         $args[] = $value;
     }
 }
 foreach ($account_data['fixed_inputs'] as $key => $data) {
     $query .= ", {$key}=?";
     $args[] = $data;
 }
 if ($account_data['disabled']) {
     $errors[] = t("Cannot add a new account; that account type is disabled.");
 }
 if (!is_valid_title(require_post("title", false))) {
     $errors[] = t("That is not a valid title.");
 }
 if (!can_user_add($user, $account_data['exchange'])) {
     $errors[] = t("Cannot add :title: too many existing accounts.", array(':title' => $account_data['title'])) . ($user['is_premium'] ? "" : " " . t("To add more accounts, upgrade to a :premium_account.", array(':premium_account' => link_to(url_for('premium'), t('premium account')))));
 }
 if (!$errors) {
     $title = htmlspecialchars(require_post("title", ""));
     // we don't care if the address already exists
     $q = db()->prepare("INSERT INTO " . $account_data['table'] . " SET user_id=?, title=? {$query}");
     $full_args = array_join(array(user_id(), require_post("title", false)), $args);
     $q->execute($full_args);
     $id = db()->lastInsertId();
     if (!$title) {
         $title = t("(untitled)");
     }