server()) {
metaRefresh("../login.php");
exit;
}
// copy type and profile name from POST to GET
if (isset($_POST['profname'])) $_GET['edit'] = $_POST['profname'];
if (isset($_POST['accounttype'])) $_GET['type'] = $_POST['accounttype'];
// abort button was pressed
// back to profile editor
if (isset($_POST['abort'])) {
metaRefresh("profilemain.php");
exit;
}
// print header
echo $_SESSION['header'];
echo "
Profile editor\n\n";
echo "\n\n";
echo " \n";
// save button was presed
if (isset($_POST['save'])) {
// create option array to check and save
$options = array();
$opt_keys = array_keys($_SESSION['profile_types']);
foreach ($opt_keys as $element) {
// text fields
if ($_SESSION['profile_types'][$element] == "text") {
$options[$element] = array($_POST[$element]);
}
// checkboxes
elseif ($_SESSION['profile_types'][$element] == "checkbox") {
if (isset($_POST[$element]) && ($_POST[$element] == "on")) $options[$element] = array('true');
else $options[$element] = array('false');
}
// dropdownbox
elseif ($_SESSION['profile_types'][$element] == "select") {
$options[$element] = array($_POST[$element]);
}
// multiselect
elseif ($_SESSION['profile_types'][$element] == "multiselect") {
if (isset($_POST[$element])) $options[$element] = $_POST[$element]; // value is already an array
else $options[$element] = array();
}
}
// remove double slashes if magic quotes are on
if (get_magic_quotes_gpc() == 1) {
foreach ($opt_keys as $element) {
if (isset($options[$element][0]) && is_string($options[$element][0])) $options[$element][0] = stripslashes($options[$element][0]);
}
}
// check options
$errors = checkProfileOptions($_POST['accounttype'], $options);
// print error messages if any
if (sizeof($errors) > 0) {
for ($i = 0; $i < sizeof($errors); $i++) {
if (sizeof($errors[$i]) > 3) { // messages with additional variables
StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2], $errors[$i][3]);
}
else {
StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2]);
}
}
echo " \n";
}
else { // input data is valid, save profile
// save profile
if (saveAccountProfile($options, $_POST['profname'], $_POST['accounttype'])) {
echo StatusMessage("INFO", _("Profile was saved."), $_POST['profname']);
echo ("