Esempio n. 1
0
/**
 * [wo_create_client description]
 * @param  [type] $user [description]
 * @return [type]       [description]
 *
 * @todo Add role and permissions check
 */
function wo_create_client($user = null)
{
    do_action('wo_before_create_client', array($user));
    if (!current_user_can('manage_options')) {
        return false;
    }
    $new_client_id = wo_gen_key();
    $new_client_secret = wo_gen_key();
    // Insert the user into the system
    global $wpdb;
    return $wpdb->insert("{$wpdb->prefix}oauth_clients", array('client_id' => $new_client_id, 'client_secret' => $new_client_secret, 'redirect_uri' => empty($user['client-redirect-uri']) ? '' : $user['client-redirect-uri'], 'name' => empty($user['client-name']) ? 'No Name' : $user['client-name'], 'description' => empty($user['client-description']) ? '' : $user['client-description']));
}
 * is secure, we need to start tweaking the file to be more WP compliant. Quality Matters!
 *
 * @todo Add an additional check to ensure that the form is being loaded by WordPress.
 * @todo Load WP core JS and styles for the plugin. It will be more cleaner and not rely on external JS libs.
 */
/** Find wp-load and load it into scope */
$parse_uri = explode('wp-content', $_SERVER['SCRIPT_FILENAME']);
require_once $parse_uri[0] . 'wp-load.php';
/** should stop 99% exploits */
if (!current_user_can('manage_options')) {
    exit('Unauthorized Access');
}
/** listen for post back */
if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'add-new-client')) {
    $new_client_id = wo_gen_key();
    $new_client_secret = wo_gen_key();
    global $wpdb;
    $add_new = $wpdb->insert("{$wpdb->prefix}oauth_clients", array('client_id' => $new_client_id, 'client_secret' => $new_client_secret, 'redirect_uri' => $_POST['client-redirect-uri'], 'name' => $_POST['client-name'], 'description' => $_POST['client-description']));
    print 'Reloading...<script>window.parent.location.reload();</script>';
    exit;
}
$options = get_option('wo_options');
?>
<style>
body {
	background: #f1f1f1;
	font-family: Arial, Helvetica, sans-serif;
}
h2 {
	font-size: 23px;
	font-weight: 400;