$errors[] = lang("CONFIG_TEMPLATE_INVALID", array($newTemplate)); } else { if (count($errors) == 0) { $cfgId[] = 7; $cfgValue[7] = $newTemplate; $template = $newTemplate; } } } //Update configuration table with new settings if (count($errors) == 0 and count($cfgId) > 0) { updateConfig($cfgId, $cfgValue); $successes[] = lang("CONFIG_UPDATE_SUCCESSFUL"); } } $languages = getLanguageFiles(); //Retrieve list of language files $templates = getTemplateFiles(); //Retrieve list of template files $permissionData = fetchAllPermissions(); //Retrieve list of all permission levels require_once "models/header.php"; echo "\n<body>\n<div id='wrapper'>\n<div id='top'><div id='logo'></div></div>\n<div id='content'>\n<h1>UserCake</h1>\n<h2>Admin Configuration</h2>\n<div id='left-nav'>"; include "left-nav.php"; echo "\n</div>\n<div id='main'>"; echo resultBlock($errors, $successes); echo "\n<div id='regbox'>\n<form name='adminConfiguration' action='" . $_SERVER['PHP_SELF'] . "' method='post'>\n<p>\n<label>Website Name:</label>\n<input type='text' name='settings[" . $settings['website_name']['id'] . "]' value='" . $websiteName . "' />\n</p>\n<p>\n<label>Website URL:</label>\n<input type='text' name='settings[" . $settings['website_url']['id'] . "]' value='" . $websiteUrl . "' />\n</p>\n<p>\n<label>Email:</label>\n<input type='text' name='settings[" . $settings['email']['id'] . "]' value='" . $emailAddress . "' />\n</p>\n<p>\n<label>Activation Threshold:</label>\n<input type='text' name='settings[" . $settings['resend_activation_threshold']['id'] . "]' value='" . $resend_activation_threshold . "' />\n</p>\n<p>\n<label>Language:</label>\n<select name='settings[" . $settings['language']['id'] . "]'>"; //Display language options foreach ($languages as $optLang) { if ($optLang == $language) { echo "<option value='" . $optLang . "' selected>{$optLang}</option>";
public function index() { /* UserCake (Via CupCake) Version: 2.0.2 http://usercake.com */ global $baseURL; $baseURL = getcwd(); require_once "{$baseURL}/application/third_party/user_cake/models/config.php"; if (!securePage($_SERVER['PHP_SELF'])) { die; } //Forms posted if (!empty($_POST)) { $cfgId = array(); $newSettings = $_POST['settings']; //Validate new site name if ($newSettings[1] != $websiteName) { $newWebsiteName = $newSettings[1]; if (minMaxRange(1, 150, $newWebsiteName)) { $errors[] = lang("CONFIG_NAME_CHAR_LIMIT", array(1, 150)); } else { if (count($errors) == 0) { $cfgId[] = 1; $cfgValue[1] = $newWebsiteName; $websiteName = $newWebsiteName; } } } //Validate new URL if ($newSettings[2] != $websiteUrl) { $newWebsiteUrl = $newSettings[2]; if (minMaxRange(1, 150, $newWebsiteUrl)) { $errors[] = lang("CONFIG_URL_CHAR_LIMIT", array(1, 150)); } else { if (substr($newWebsiteUrl, -1) != "/") { $errors[] = lang("CONFIG_INVALID_URL_END"); } else { if (count($errors) == 0) { $cfgId[] = 2; $cfgValue[2] = $newWebsiteUrl; $websiteUrl = $newWebsiteUrl; } } } } //Validate new site email address if ($newSettings[3] != $emailAddress) { $newEmail = $newSettings[3]; if (minMaxRange(1, 150, $newEmail)) { $errors[] = lang("CONFIG_EMAIL_CHAR_LIMIT", array(1, 150)); } elseif (!isValidEmail($newEmail)) { $errors[] = lang("CONFIG_EMAIL_INVALID"); } else { if (count($errors) == 0) { $cfgId[] = 3; $cfgValue[3] = $newEmail; $emailAddress = $newEmail; } } } //Validate email activation selection if ($newSettings[4] != $emailActivation) { $newActivation = $newSettings[4]; if ($newActivation != "true" and $newActivation != "false") { $errors[] = lang("CONFIG_ACTIVATION_TRUE_FALSE"); } else { if (count($errors) == 0) { $cfgId[] = 4; $cfgValue[4] = $newActivation; $emailActivation = $newActivation; } } } //Validate new email activation resend threshold if ($newSettings[5] != $resend_activation_threshold) { $newResend_activation_threshold = $newSettings[5]; if ($newResend_activation_threshold > 72 or $newResend_activation_threshold < 0) { $errors[] = lang("CONFIG_ACTIVATION_RESEND_RANGE", array(0, 72)); } else { if (count($errors) == 0) { $cfgId[] = 5; $cfgValue[5] = $newResend_activation_threshold; $resend_activation_threshold = $newResend_activation_threshold; } } } //Validate new language selection if ($newSettings[6] != $language) { $newLanguage = $newSettings[6]; if (minMaxRange(1, 150, $language)) { $errors[] = lang("CONFIG_LANGUAGE_CHAR_LIMIT", array(1, 150)); } elseif (!file_exists($baseURL . $newLanguage)) { $errors[] = lang("CONFIG_LANGUAGE_INVALID", array($newLanguage)); } else { if (count($errors) == 0) { $cfgId[] = 6; $cfgValue[6] = $newLanguage; $language = $newLanguage; } } } //Validate new template selection if ($newSettings[7] != $template) { $newTemplate = $newSettings[7]; if (minMaxRange(1, 150, $template)) { $errors[] = lang("CONFIG_TEMPLATE_CHAR_LIMIT", array(1, 150)); } elseif (!file_exists($baseURL . $newTemplate)) { $errors[] = lang("CONFIG_TEMPLATE_INVALID", array($newTemplate)); } else { if (count($errors) == 0) { $cfgId[] = 7; $cfgValue[7] = $newTemplate; $template = $newTemplate; } } } //Update configuration table with new settings if (count($errors) == 0 and count($cfgId) > 0) { updateConfig($cfgId, $cfgValue); $successes[] = lang("CONFIG_UPDATE_SUCCESSFUL"); } } $languages = getLanguageFiles(); //Retrieve list of language files $templates = getTemplateFiles(); //Retrieve list of template files $permissionData = fetchAllPermissions(); //Retrieve list of all permission levels require_once "{$baseURL}/application/third_party/user_cake/models/header.php"; echo "\r\n<body>\r\n<div id='wrapper'>\r\n<div id='top'><div id='logo'></div></div>\r\n<div id='content'>\r\n<h1>UserCake (Via CupCake)</h1>\r\n<h2>Admin Configuration</h2>\r\n<div id='left-nav'>"; include "{$baseURL}/application/third_party/user_cake/left-nav.php"; echo "\r\n</div>\r\n<div id='main'>"; echo resultBlock($errors, $successes); echo "\r\n<div id='regbox'>\r\n<form name='adminConfiguration' action='" . $_SERVER['PHP_SELF'] . "' method='post'>\r\n<p>\r\n<label>Website Name:</label>\r\n<input type='text' name='settings[" . $settings['website_name']['id'] . "]' value='" . $websiteName . "' />\r\n</p>\r\n<p>\r\n<label>Website URL:</label>\r\n<input type='text' name='settings[" . $settings['website_url']['id'] . "]' value='" . $websiteUrl . "' />\r\n</p>\r\n<p>\r\n<label>Email:</label>\r\n<input type='text' name='settings[" . $settings['email']['id'] . "]' value='" . $emailAddress . "' />\r\n</p>\r\n<p>\r\n<label>Activation Threshold:</label>\r\n<input type='text' name='settings[" . $settings['resend_activation_threshold']['id'] . "]' value='" . $resend_activation_threshold . "' />\r\n</p>\r\n<p>\r\n<label>Language:</label>\r\n<select name='settings[" . $settings['language']['id'] . "]'>"; //Display language options foreach ($languages as $optLang) { if ($optLang == $language) { echo "<option value='" . $optLang . "' selected>{$optLang}</option>"; } else { echo "<option value='" . $optLang . "'>{$optLang}</option>"; } } echo "\r\n</select>\r\n</p>\r\n<p>\r\n<label>Email Activation:</label>\r\n<select name='settings[" . $settings['activation']['id'] . "]'>"; //Display email activation options if ($emailActivation == "true") { echo "\r\n\t<option value='true' selected>True</option>\r\n\t<option value='false'>False</option>\r\n\t</select>"; } else { echo "\r\n\t<option value='true'>True</option>\r\n\t<option value='false' selected>False</option>\r\n\t</select>"; } echo "</p>\r\n<p>\r\n<label>Template:</label>\r\n<select name='settings[" . $settings['template']['id'] . "]'>"; //Display template options foreach ($templates as $temp) { if ($temp == $template) { echo "<option value='" . $temp . "' selected>{$temp}</option>"; } else { echo "<option value='" . $temp . "'>{$temp}</option>"; } } echo "\r\n</select>\r\n</p>\r\n<input type='submit' name='Submit' value='Submit' />\r\n</form>\r\n</div>\r\n</div>\r\n<div id='bottom'></div>\r\n</div>\r\n</body>\r\n</html>"; }