ADD_DESCR("admin", basename(__FILE__));
if (isset($_POST['ok'])) {
- // Save settings
- ADMIN_SAVE_SETTINGS($_POST, "_config", "config='0'");
+ // First merge temporary the new API data into config
+ $CONFIG = array_merge($CONFIG, $_POST);
+
+ // Let's test the API first (hold your horses here, cowboy! Thanks. :) )
+ if (WERNIS_TEST_API()) {
+ // Save settings
+ ADMIN_SAVE_SETTINGS($_POST, "_config", "config='0'");
+ } else {
+ // Failed to test the API!
+ LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_ERROR_MESSAGE());
+ }
} else {
// Prepare data for template output
$content = array(
'min_amount' => $CONFIG['wernis_min_amount'],
'api_id' => $CONFIG['wernis_api_id'],
- 'api_md5' => $CONFIG['wernis_api_md5']
+ 'api_md5' => $CONFIG['wernis_api_md5'],
+ 'api_url' => $CONFIG['wernis_api_url']
);
// Load template