示例#1
0
            return;
        } else {
            // Valid login. Cache access for 1hr for this user.
            //echo 'settrans';
            //set_transient( 'pb_backupbuddy_stashallfiles_' . $current_user->user_login, $itxapi_password, $stash_allfiles_access_timelimit );
            $stash_hash = $itxapi_password;
        }
    }
}
echo '<span id="pb_backupbuddy_stashhash" rel="' . $itxapi_password . '" style="display: none;"></span>';
// Talk with the Stash API to get access to do things.
$stash = new ITXAPI_Helper(pb_backupbuddy_destination_stash::ITXAPI_KEY, pb_backupbuddy_destination_stash::ITXAPI_URL, $itxapi_username, $itxapi_password);
// Re-authenticating to Stash.
if ('1' == pb_backupbuddy::_POST('stash_reauth')) {
    $itxapi_username = strtolower(pb_backupbuddy::_POST('itxapi_username'));
    $itxapi_password = ITXAPI_Helper::get_password_hash($itxapi_username, pb_backupbuddy::_POST('itxapi_password_raw'));
    // Generates hash for use as password for API.
    $account_info = pb_backupbuddy_destination_stash::get_quota(array('itxapi_username' => $itxapi_username, 'itxapi_password' => $itxapi_password), true);
    if (false !== $account_info) {
        // New credentials are good. Update destination settings.
        $settings['itxapi_username'] = $itxapi_username;
        $settings['itxapi_password'] = $itxapi_password;
        pb_backupbuddy::save();
        // $settings is a reference so this will save the propr destination settings.
        pb_backupbuddy::alert(__('Success re-authenticating to your Stash account.', 'it-l10n-backupbuddy'));
        echo '<br>';
    }
}
// Validate authentication with Stash.
$manage_data = pb_backupbuddy_destination_stash::get_manage_data($settings, $suppressAuthAlert = true);
if (!is_array($manage_data['credentials']) || '1' == pb_backupbuddy::_GET('force_stash_reauth')) {
示例#2
0
        return;
    } else {
        // Form submitted.
        if (count($settings_result['errors']) > 0) {
            // Form errors.
            echo $login_welcome;
            pb_backupbuddy::alert(implode('<br>', $settings_result['errors']));
            $credentials_form->display_settings('Submit');
            $pb_hide_test = true;
            $pb_hide_save = true;
            return;
        } else {
            // No form errors; process!
            require_once dirname(__FILE__) . '/lib/class.itx_helper.php';
            $itxapi_username = strtolower($settings_result['data']['itxapi_username']);
            $itxapi_password = ITXAPI_Helper::get_password_hash($itxapi_username, $settings_result['data']['itxapi_password_raw']);
            // Generates hash for use as password for API.
            $account_info = pb_backupbuddy_destination_stash::get_quota(array('itxapi_username' => $itxapi_username, 'itxapi_password' => $itxapi_password), true);
            if ($account_info === false) {
                $credentials_form->display_settings('Submit');
            }
        }
    }
    // end form submitted.
} elseif ($mode == 'edit') {
    // EDIT MODE.
    //echo 'editmode?';
    $account_info = pb_backupbuddy_destination_stash::get_quota(array('itxapi_username' => $destination_settings['itxapi_username'], 'itxapi_password' => $destination_settings['itxapi_password']));
    $itxapi_username = $destination_settings['itxapi_username'];
}
if ($mode == 'save' || $mode == 'edit' || $itxapi_username != '') {
示例#3
0
    /*
    $stash_password = get_transient( 'pb_backupbuddy_stashallfiles_' . $current_user->user_login );
    echo 'pass: '******'';
    if (pb_backupbuddy::_POST('stash_password') != '') {
        $stash_password = pb_backupbuddy::_POST('stash_password');
    }
    if ($stash_password == '' && pb_backupbuddy::_GET('stashhash') == '') {
        pb_backupbuddy_stash_pass_form();
        return;
    } else {
        if (pb_backupbuddy::_GET('stashhash') != '') {
            $itxapi_password = pb_backupbuddy::_GET('stashhash');
        } else {
            $itxapi_password = ITXAPI_Helper::get_password_hash($itxapi_username, $stash_password);
            // Generates hash for use as password for API.
        }
        $account_info = pb_backupbuddy_destination_stash::get_quota(array('itxapi_username' => $itxapi_username, 'itxapi_password' => $itxapi_password), true);
        if ($account_info === false) {
            pb_backupbuddy_stash_pass_form();
            delete_transient('pb_backupbuddy_stashallfiles_' . $current_user->user_login);
            return;
        } else {
            // Valid login. Cache access for 1hr for this user.
            //echo 'settrans';
            //set_transient( 'pb_backupbuddy_stashallfiles_' . $current_user->user_login, $itxapi_password, $stash_allfiles_access_timelimit );
            $stash_hash = $itxapi_password;
        }
    }
}