USR);
$PASSWD = $data->PWD;
$EMAIL = $data->EMAIL;
$NAME = $data->NAME;
$lang_array = getFiles(GSLANGPATH);
# initialize these all as null
$pwd1 = $error = $success = $pwd2 = $editorchck = $prettychck = null;
# if the flush cache command was invoked
if (isset($_GET['flushcache'])) {
delete_cache();
$update = 'flushcache-success';
}
# if the undo command was invoked
if (isset($_GET['undo'])) {
# first check for csrf
if (!defined('GSNOCSRF') || (GSNOCSRF == FALSE) ) {
$nonce = $_GET['nonce'];
if(!check_nonce($nonce, "undo")) {
die("CSRF detected!");
}
}
# perform undo
undo($file, GSUSERSPATH, GSBACKUSERSPATH);
undo($wfile, GSDATAOTHERPATH, GSBACKUPSPATH.'other/');
generate_sitemap();
# redirect back to yourself to show the new restored data
redirect('settings.php?restored=true');
}
# was this page restored?
if (isset($_GET['restored'])) {
$restored = 'true';
} else {
$restored = 'false';
}
# was the form submitted?
if(isset($_POST['submitted'])) {
# first check for csrf
if (!defined('GSNOCSRF') || (GSNOCSRF == FALSE) ) {
$nonce = $_POST['nonce'];
if(!check_nonce($nonce, "save_settings")) {
die("CSRF detected!");
}
}
# website-specific fields
if(isset($_POST['sitename'])) {
$SITENAME = htmlentities($_POST['sitename'], ENT_QUOTES, 'UTF-8');
}
if(isset($_POST['siteurl'])) {
$SITEURL = tsl($_POST['siteurl']);
}
if(isset($_POST['permalink'])) {
$PERMALINK = var_out(trim($_POST['permalink']));
}
if(isset($_POST['template'])) {
$TEMPLATE = $_POST['template'];
}
if(isset($_POST['prettyurls'])) {
$PRETTYURLS = $_POST['prettyurls'];
} else {
$PRETTYURLS = '';
}
# user-specific fields
if(isset($_POST['user'])) {
$USR = strtolower($_POST['user']);
}
if(isset($_POST['name'])) {
$NAME = var_out($_POST['name']);
}
if(isset($_POST['email'])) {
$EMAIL = var_out($_POST['email'],'email');
}
if(isset($_POST['timezone'])) {
$TIMEZONE = var_out($_POST['timezone']);
}
if(isset($_POST['lang'])) {
$LANG = var_out($_POST['lang']);
}
if(isset($_POST['show_htmleditor'])) {
$HTMLEDITOR = var_out($_POST['show_htmleditor']);
} else {
$HTMLEDITOR = '';
}
# check to see if passwords are changing
if(isset($_POST['sitepwd'])) { $pwd1 = $_POST['sitepwd']; }
if(isset($_POST['sitepwd_confirm'])) { $pwd2 = $_POST['sitepwd_confirm']; }
if ($pwd1 != $pwd2) {
#passwords do not match
$error = i18n_r('PASSWORD_NO_MATCH');
} else {
# password cannot be null
if ( $pwd1 != '' ) {
$PASSWD = passhash($pwd1);
}
// check valid lang files
if(!in_array($LANG.'.php', $lang_array) and !in_array($LANG.'.PHP', $lang_array)) die();
# create user xml file
createBak($file, GSUSERSPATH, GSBACKUSERSPATH);
if (file_exists(GSUSERSPATH . _id($USR).'.xml.reset')) { unlink(GSUSERSPATH . _id($USR).'.xml.reset'); }
$xml = new SimpleXMLElement('