<?php /* This is a demo for [bd] API add-on for XenForo. It includes a simple OAuth 2 authorization flow which has 3 actors (XenForo, User and Demo App): 1. Demo App sends User to an authorization page on XenForo website 2. User verifies the information and grant access 3. XenForo sends User back to a callback page on Demo App website 4. Demo App obtains an access token from XenForo server 5. Demo App can now make request on behalf of User */ require_once 'functions.php'; $config = loadConfiguration(); if (empty($config['api_root'])) { displaySetup(); } $message = ''; $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; $accessToken = !empty($_REQUEST['access_token']) ? $_REQUEST['access_token'] : ''; switch ($action) { case 'callback': // step 3 if (empty($_REQUEST['code'])) { $message = 'Callback request must have `code` query parameter!'; break; } $tokenUrl = sprintf('%s/index.php?oauth/token', $config['api_root']); $postFields = array('grant_type' => 'authorization_code', 'client_id' => $config['api_key'], 'client_secret' => $config['api_secret'], 'code' => $_REQUEST['code'], 'redirect_uri' => getCallbackUrl()); if (isLocal($config['api_root']) && !isLocal(getBaseUrl())) { $message = renderMessageForPostRequest($tokenUrl, $postFields); $message .= '<br />Afterwards, you can test JavaScript by clicking the link below.';
/** * Processes installation. * * @since 1.0 * @package facileManager * @subpackage Installer */ function processSetup() { extract($_POST); $link = @mysql_connect($dbhost, $dbuser, $dbpass); if (!$link) { exit(displaySetup(_('Could not connect to MySQL.<br />Please check your credentials.'))); } else { $db_selected = @mysql_select_db($dbname, $link); if (mysql_error() && strpos(mysql_error(), 'Unknown database') === false) { exit(displaySetup(mysql_error())); } if ($db_selected) { $tables = @mysql_query(sanitize('SHOW TABLES FROM ' . $dbname . ';'), $link); @mysql_close($link); if (@mysql_num_rows($tables)) { exit(displaySetup(_('Database already exists and contains one or more tables.<br />Please choose a different name.'))); } } } require_once ABSPATH . 'fm-modules/facileManager/install.php'; createConfig(); }