global $template; global $mediaPath; global $defaultMaxCols; global $defaultMaxRows; global $defaultTemplate; global $defaultMediaPath; $maxCols = safeGetConfig("maxCols", $defaultMaxCols); $maxRows = safeGetConfig("maxRows", $defaultMaxRows); $template = safeGetConfig("template", $defaultTemplate); $mediaPath = safeGetConfig("mediaPath", $defaultMediaPath); } function safeGetConfig($name, $defaultValue) { $config = sql_query("select value from xlsimport_config WHERE name='" . escapeString($name) . "'", true); if (count($config) == 0) { sql_query("insert into xlsimport_config set name='" . escapeString($name) . "', value='" . escapeString($defaultValue) . "'"); return $defaultValue; } return $config[0]["value"]; } function putConfig($name, $value) { $config = sql_query("select value from xlsimport_config WHERE name='" . escapeString($name) . "'", true); if (count($config) == 0) { sql_query("insert into xlsimport_config set name='" . escapeString($name) . "', value='" . escapeString($value) . "'"); } else { sql_query("update xlsimport_config set value='" . escapeString($value) . "' where name='" . escapeString($name) . "'"); } } loadConfiguration();
<?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.';
<?php global $CONFIG_FILE, $options; $options = getopt("", ["det:", "build-version:", "common-ui:", "pdi-host:", "pdi-port:", "mock-data:", "mock-data-dir:"]); if ($options) { saveConfiguration($options); exit; } else { $options = loadConfiguration(); } if (empty($options["det"])) { $options["det"] = getcwd(); } else { ensureTrailingSlash($options["det"]); } if (empty($options["build-version"])) { $options["build-version"] = '7.0-SNAPSHOT'; } if (!empty($options["common-ui"])) { ensureTrailingSlash($options["common-ui"]); } if (empty($options["pdi-host"])) { $options["pdi-host"] = "localhost"; } if (empty($options["pdi-port"])) { $options["pdi-port"] = 9050; } $options["mock-data"] = empty($options["mock-data"]) || filter_var($options["mock-data"], FILTER_VALIDATE_BOOLEAN); if (empty($options["mock-data-dir"])) { $options["mock-data-dir"] = $tool_root . '/mock_data'; } else {