/** * Function to save the identities array * * @param array $identities Array of identities */ function save_identities($identities) { global $username, $data_dir, $domain; if (empty($identities) || !is_array($identities)) { return; } $num_cur = getPref($data_dir, $username, 'identities'); $cnt = count($identities); // Remove any additional identities in prefs // for ($i = $cnt; $i <= $num_cur; $i++) { removePref($data_dir, $username, 'full_name' . $i); removePref($data_dir, $username, 'email_address' . $i); removePref($data_dir, $username, 'reply_to' . $i); setSig($data_dir, $username, $i, ''); } foreach ($identities as $id => $ident) { $key = $id ? $id : ''; setPref($data_dir, $username, 'full_name' . $key, $ident['full_name']); setPref($data_dir, $username, 'email_address' . $key, $ident['email_address']); setPref($data_dir, $username, 'reply_to' . $key, $ident['reply_to']); if ($id === 0) { setSig($data_dir, $username, 'g', $ident['signature']); } else { setSig($data_dir, $username, $key, $ident['signature']); } } setPref($data_dir, $username, 'identities', $cnt); }
} if ($method == 'up' && $num > 1) { $prev = $num - 1; $tmp = $index_order[$prev]; $index_order[$prev] = $index_order[$num]; $index_order[$num] = $tmp; } else { if ($method == 'down' && $num < count($index_order)) { $next = $num++; $tmp = $index_order[$next]; $index_order[$next] = $index_order[$num]; $index_order[$num] = $tmp; } else { if ($method == 'remove' && $num) { for ($i = 1; $i < 8; $i++) { removePref($data_dir, $username, "order{$i}"); } for ($j = 1, $i = 1; $i <= count($index_order); $i++) { if ($i != $num) { $new_ary[$j] = $index_order[$i]; $j++; } } $index_order = array(); $index_order = $new_ary; if (count($index_order) < 1) { include_once '../src/load_prefs.php'; } } else { if ($method == 'add' && $add) { /* User should not be able to insert PHP-code here */
/** * FIXME: Undocumented function * @access private */ function remove_filter($id) { global $data_dir, $username; while ($nextFilter = getPref($data_dir, $username, 'filter' . ($id + 1))) { setPref($data_dir, $username, 'filter' . $id, $nextFilter); $id++; } removePref($data_dir, $username, 'filter' . $id); }
/** * Deletes user's dictionary * Function was modified in 1.5.1 (sqspell 0.5). Older function is suffixed * with '_old' * @param string $lang dictionary */ function sqspell_deleteWords($lang) { global $data_dir, $username; removePref($data_dir, $username, 'sqspell_dict_' . $lang); }
/* Load up the Signature file */ $signature_abs = $signature = getSig($data_dir, $username, 'g'); /* Message Highlighting Rules */ $message_highlight_list = array(); /* use new way of storing highlighting rules */ if ($ser = getPref($data_dir, $username, 'hililist')) { $message_highlight_list = unserialize($ser); } else { /* use old way */ for ($i = 0; $hlt = getPref($data_dir, $username, "highlight{$i}"); ++$i) { $highlight_array = explode(',', $hlt); $message_highlight_list[$i]['name'] = $highlight_array[0]; $message_highlight_list[$i]['color'] = $highlight_array[1]; $message_highlight_list[$i]['value'] = $highlight_array[2]; $message_highlight_list[$i]['match_type'] = $highlight_array[3]; removePref($data_dir, $username, "highlight{$i}"); } // NB: The fact that this preference is always set here means that some plugins rely on testing it to know if a user has logged in before - the "old way" above is probably long since obsolete and unneeded, but the setPref() below should not be removed /* store in new format for the next time */ setPref($data_dir, $username, 'hililist', serialize($message_highlight_list)); } /* Index order lets you change the order of the message index */ $order = getPref($data_dir, $username, 'order1'); for ($i = 1; $order; ++$i) { $index_order[$i] = $order; $order = getPref($data_dir, $username, 'order' . ($i + 1)); } if (!isset($index_order)) { $index_order[1] = 1; $index_order[2] = 2; $index_order[3] = 3;
/** * @param string $key the pref key * @param integer $index the pref key index * @return bool status */ function asearch_removePref(&$key, $index) { global $data_dir, $username, $search_advanced; return removePref($data_dir, $username, $key . ($index + !$search_advanced)); }
/** * Sets the desired preference setting ($pref_name) to whatever is in $value * @ignore */ function setPref($data_dir, $username, $pref_name, $value) { global $prefs_cache; if (isset($prefs_cache[$pref_name]) && $prefs_cache[$pref_name] == $value) { return; } if ($value === '') { removePref($data_dir, $username, $pref_name); return; } $db = new dbPrefs(); if (isset($db->error)) { $db->failQuery(); } $db->setKey($username, $pref_name, $value); $prefs_cache[$pref_name] = $value; assert_options(ASSERT_ACTIVE, 1); assert_options(ASSERT_BAIL, 1); assert('$value == $prefs_cache[$pref_name]'); sqsession_register($prefs_cache, 'prefs_cache'); return; }
/** * Set a there preference $string to $value. */ function setPref($data_dir, $username, $string, $value) { global $prefs_cache; cachePrefValues($data_dir, $username); if (isset($prefs_cache[$string]) && $prefs_cache[$string] == $value) { return; } if ($value === '') { removePref($data_dir, $username, $string); return; } $prefs_cache[$string] = $value; savePrefValues($data_dir, $username); }
function SaveUpdateFunction() { global $username, $data_dir, $full_name, $email_address, $reply_to, $signature; $i = 1; $fakeI = 1; $name = 'form_for_' . $i; global ${$name}; while (isset(${$name})) { $name = 'delete_' . $i; global ${$name}; if (isset(${$name})) { $fakeI--; } else { do_hook('options_identities_renumber', $i, $fakeI); $filled = 0; $name = 'full_name' . $i; global ${$name}; if (${$name} != '') { $filled++; } setPref($data_dir, $username, 'full_name' . $fakeI, ${$name}); $name = 'email_address' . $i; global ${$name}; if (${$name} != '') { $filled++; } setPref($data_dir, $username, 'email_address' . $fakeI, ${$name}); $name = 'reply_to' . $i; global ${$name}; if (${$name} != '') { $filled++; } setPref($data_dir, $username, 'reply_to' . $fakeI, ${$name}); $name = 'signature' . $i; global ${$name}; if (${$name} != '') { $filled++; } setSig($data_dir, $username, $fakeI, ${$name}); if ($filled == 0) { $fakeI--; } } $fakeI++; $i++; $name = 'form_for_' . $i; global ${$name}; } setPref($data_dir, $username, 'identities', $fakeI); while ($fakeI != $i) { removePref($data_dir, $username, 'full_name' . $fakeI); removePref($data_dir, $username, 'email_address' . $fakeI); removePref($data_dir, $username, 'reply_to' . $fakeI); setSig($data_dir, $username, $fakeI, ""); $fakeI++; } setPref($data_dir, $username, 'full_name', $full_name); setPref($data_dir, $username, 'email_address', $email_address); setPref($data_dir, $username, 'reply_to', $reply_to); setSig($data_dir, $username, "g", $signature); }
/** * Renames a mailbox. */ function sqimap_mailbox_rename($imap_stream, $old_name, $new_name) { if ($old_name != $new_name) { global $delimiter, $imap_server_type, $data_dir, $username; if (substr($old_name, -1) == $delimiter) { $old_name = substr($old_name, 0, strlen($old_name) - 1); $new_name = substr($new_name, 0, strlen($new_name) - 1); $postfix = $delimiter; } else { $postfix = ''; } $boxesall = sqimap_mailbox_list_all($imap_stream); $cmd = 'RENAME "' . $old_name . '" "' . $new_name . '"'; $data = sqimap_run_command($imap_stream, $cmd, true, $response, $message); sqimap_unsubscribe($imap_stream, $old_name . $postfix); $oldpref_thread = getPref($data_dir, $username, 'thread_' . $old_name . $postfix); $oldpref_collapse = getPref($data_dir, $username, 'collapse_folder_' . $old_name . $postfix); removePref($data_dir, $username, 'thread_' . $old_name . $postfix); removePref($data_dir, $username, 'collapse_folder_' . $old_name . $postfix); sqimap_subscribe($imap_stream, $new_name . $postfix); setPref($data_dir, $username, 'thread_' . $new_name . $postfix, $oldpref_thread); setPref($data_dir, $username, 'collapse_folder_' . $new_name . $postfix, $oldpref_collapse); do_hook_function('rename_or_delete_folder', $args = array($old_name, 'rename', $new_name)); $l = strlen($old_name) + 1; $p = 'unformatted'; foreach ($boxesall as $box) { if (substr($box[$p], 0, $l) == $old_name . $delimiter) { $new_sub = $new_name . $delimiter . substr($box[$p], $l); /* With Cyrus IMAPd >= 2.0 rename is recursive, so don't check for errors here */ if ($imap_server_type == 'cyrus') { $cmd = 'RENAME "' . $box[$p] . '" "' . $new_sub . '"'; $data = sqimap_run_command($imap_stream, $cmd, false, $response, $message); } $was_subscribed = sqimap_mailbox_is_subscribed($imap_stream, $box[$p]); if ($was_subscribed) { sqimap_unsubscribe($imap_stream, $box[$p]); } $oldpref_thread = getPref($data_dir, $username, 'thread_' . $box[$p]); $oldpref_collapse = getPref($data_dir, $username, 'collapse_folder_' . $box[$p]); removePref($data_dir, $username, 'thread_' . $box[$p]); removePref($data_dir, $username, 'collapse_folder_' . $box[$p]); if ($was_subscribed) { sqimap_subscribe($imap_stream, $new_sub); } setPref($data_dir, $username, 'thread_' . $new_sub, $oldpref_thread); setPref($data_dir, $username, 'collapse_folder_' . $new_sub, $oldpref_collapse); do_hook_function('rename_or_delete_folder', $args = array($box[$p], 'rename', $new_sub)); } } } }
if ($_SESSION['login'] == true) { switch ($_POST["action"]) { case "getRandomDrink": getRandomDrink(); break; case "getBestDrink": getBestDrink(); break; case "getSortedDrinks": getSortedDrinks(); break; case "addPref": addPref(); break; case "removePref": removePref(); break; case "getAllDrinks": getAllDrinks(); break; case "getPreferences": getPreferences(); break; case "getDrinkTraits": getDrinkTraits(); break; case "getDrinkInfo": getDrinkInfo(); break; case "getRandomBestDrink": getRandomBestDrink();
} // NB: The fact that this preference is always set here means that some plugins rely on testing it to know if a user has logged in before - the "old way" above is probably long since obsolete and unneeded, but the setPref() below should not be removed /* store in new format for the next time */ setPref($data_dir, $username, 'hililist', serialize($message_highlight_list)); } /* use the internal date of the message for sorting instead of the supplied header date */ /* OBSOLETE */ $internal_date_sort = getPref($data_dir, $username, 'internal_date_sort', SMPREF_ON); /* Index order lets you change the order of the message index */ $order = getPref($data_dir, $username, 'order1'); if (isset($order1)) { removePref($data_dir, $username, 'order1'); for ($i = 1; $order; ++$i) { $index_order[$i - 1] = $order - 1; $order = getPref($data_dir, $username, 'order' . ($i + 1)); removePref($data_dir, $username, 'order' . ($i + 1)); } if (isset($internal_date_sort) && $internal_date_sort) { if (in_array(SQM_COL_DATE, $index_order)) { $k = array_search(SQM_COL_DATE, $index_order, true); $index_order[$k] = SQM_COL_INT_DATE; } } setPref($data_dir, $username, 'index_order', serialize($index_order)); } $index_order = getPref($data_dir, $username, 'index_order'); if (is_string($index_order)) { $index_order = unserialize($index_order); } // new Index order handling //$default_mailbox_pref = unserialize(getPref($data_dir, $username, 'default_mailbox_pref'));
function delete_saved($delete_index, $username, $data_dir) { $types = array('saved_what', 'saved_where', 'saved_folder'); $attributes = get_saved($username, $data_dir); foreach ($types as $key) { array_splice($attributes[$key], $delete_index, 1); } reset($types); $n = 0; $saved_count = count($attributes['saved_what']); $last_element = $saved_count + 1; for ($i = 1; $i <= $saved_count; $i++) { reset($types); foreach ($types as $key) { setPref($data_dir, $username, $key . $i, $attributes[$key][$n]); } $n++; } reset($types); foreach ($types as $key) { removePref($data_dir, $username, $key . $last_element); } }
function sqimap_mailbox_rename($imap_stream, $old_name, $new_name) { if ($old_name != $new_name) { global $delimiter, $imap_server_type, $data_dir, $username; if (substr($old_name, -1) == $delimiter) { $old_name = substr($old_name, 0, strlen($old_name) - 1); $new_name = substr($new_name, 0, strlen($new_name) - 1); $postfix = $delimiter; } else { $postfix = ''; } $boxesall = sqimap_mailbox_list($imap_stream); $cmd = 'RENAME "' . $old_name . '" "' . $new_name . '"'; $data = sqimap_run_command($imap_stream, $cmd, true, $response, $message); sqimap_unsubscribe($imap_stream, $old_name . $postfix); $oldpref = getPref($data_dir, $username, 'thread_' . $old_name . $postfix); removePref($data_dir, $username, 'thread_' . $old_name . $postfix); sqimap_subscribe($imap_stream, $new_name . $postfix); setPref($data_dir, $username, 'thread_' . $new_name . $postfix, $oldpref); do_hook_function('rename_or_delete_folder', $args = array($old_name, 'rename', $new_name)); $l = strlen($old_name) + 1; $p = 'unformatted'; foreach ($boxesall as $box) { if (substr($box[$p], 0, $l) == $old_name . $delimiter) { $new_sub = $new_name . $delimiter . substr($box[$p], $l); if ($imap_server_type == 'cyrus') { $cmd = 'RENAME "' . $box[$p] . '" "' . $new_sub . '"'; $data = sqimap_run_command($imap_stream, $cmd, true, $response, $message); } sqimap_unsubscribe($imap_stream, $box[$p]); $oldpref = getPref($data_dir, $username, 'thread_' . $box[$p]); removePref($data_dir, $username, 'thread_' . $box[$p]); sqimap_subscribe($imap_stream, $new_sub); setPref($data_dir, $username, 'thread_' . $new_sub, $oldpref); do_hook_function('rename_or_delete_folder', $args = array($box[$p], 'rename', $new_sub)); } } } }
/** * Save newmail plugin settings */ function newmail_sav_function() { global $data_dir, $username, $_FILES, $newmail_uploadsounds; if (sqgetGlobalVar('submit_newmail', $submit, SQ_POST)) { $media_enable = ''; $media_popup = ''; $media_recent = ''; $media_changetitle = ''; $media_sel = ''; $popup_width = ''; $popup_height = ''; sqgetGlobalVar('media_enable', $media_enable, SQ_POST); sqgetGlobalVar('media_popup', $media_popup, SQ_POST); sqgetGlobalVar('media_recent', $media_recent, SQ_POST); sqgetGlobalVar('media_changetitle', $media_changetitle, SQ_POST); sqgetGlobalVar('popup_width', $popup_width, SQ_POST); sqgetGlobalVar('popup_height', $popup_height, SQ_POST); // sanitize height and width $popup_width = (int) $popup_width; if ($popup_width <= 0) { $popup_width = 200; } $popup_height = (int) $popup_height; if ($popup_height <= 0) { $popup_height = 130; } setPref($data_dir, $username, 'newmail_enable', $media_enable); setPref($data_dir, $username, 'newmail_popup', $media_popup); setPref($data_dir, $username, 'newmail_recent', $media_recent); setPref($data_dir, $username, 'newmail_changetitle', $media_changetitle); setPref($data_dir, $username, 'newmail_popup_width', $popup_width); setPref($data_dir, $username, 'newmail_popup_height', $popup_height); if (sqgetGlobalVar('newmail_unseen_notify', $newmail_unseen_notify, SQ_POST)) { $newmail_unseen_notify = (int) $newmail_unseen_notify; setPref($data_dir, $username, 'newmail_unseen_notify', $newmail_unseen_notify); } if (sqgetGlobalVar('media_sel', $media_sel, SQ_POST) && $media_sel == '(none)') { removePref($data_dir, $username, 'newmail_media'); } else { setPref($data_dir, $username, 'newmail_media', $media_sel); } // process uploaded file if ($newmail_uploadsounds && isset($_FILES['media_file']['tmp_name']) && $_FILES['media_file']['tmp_name'] != '') { // set temp file and get media file name $newmail_tempmedia = getHashedDir($username, $data_dir) . "/{$username}.tempsound"; $newmail_mediafile = getHashedFile($username, $data_dir, $username . '.sound'); if (move_uploaded_file($_FILES['media_file']['tmp_name'], $newmail_tempmedia)) { // new media file is in $newmail_tempmedia if (file_exists($newmail_mediafile)) { unlink($newmail_mediafile); } if (!rename($newmail_tempmedia, $newmail_mediafile)) { // remove (userfile), if file rename fails removePref($data_dir, $username, 'newmail_media'); } else { // store media type if (isset($_FILES['media_file']['type']) && isset($_FILES['media_file']['name'])) { setPref($data_dir, $username, 'newmail_userfile_type', newmail_get_mediatype($_FILES['media_file']['type'], $_FILES['media_file']['name'])); } else { removePref($data_dir, $username, 'newmail_userfile_type'); } // store file name if (isset($_FILES['media_file']['name'])) { setPref($data_dir, $username, 'newmail_userfile_name', basename($_FILES['media_file']['name'])); } else { setPref($data_dir, $username, 'newmail_userfile_name', 'mediafile.unknown'); } } } } } }
function setPref($data_dir, $username, $string, $set_to) { global $prefs_cache; if (isset($prefs_cache[$string]) && $prefs_cache[$string] == $set_to) { return; } if ($set_to === '') { removePref($data_dir, $username, $string); return; } $db = new dbPrefs(); if (isset($db->error)) { $db->failQuery(); } $db->setKey($username, $string, $set_to); $prefs_cache[$string] = $set_to; assert_options(ASSERT_ACTIVE, 1); assert_options(ASSERT_BAIL, 1); assert('$set_to == $prefs_cache[$string]'); sqsession_register($prefs_cache, 'prefs_cache'); return; }
} else { echo _("You must select a spam folder."); } // setting scan type sqgetGlobalVar('filters_spam_scan_set', $filters_spam_scan_set, SQ_POST); if (isset($filters_spam_scan_set)) { setPref($data_dir, $username, 'filters_spam_scan', $filters_spam_scan_set); } else { echo _("You must select a scan type."); } foreach ($spam_filters as $Key => $Value) { $input = $spam_filters[$Key]['prefname'] . '_set'; if (sqgetGlobalVar($input, $input_key, SQ_POST)) { setPref($data_dir, $username, $spam_filters[$Key]['prefname'], $input_key); } else { removePref($data_dir, $username, $spam_filters[$Key]['prefname']); } } } $filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder'); $filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan'); $filters = load_filters(); echo html_tag('table', html_tag('tr', html_tag('th', _("Spam Filtering"), 'center')), 'center', $color[0], 'width="95%" border="0" cellpadding="2" cellspacing="0"'); if ($SpamFilters_YourHop == ' ') { echo '<br />' . html_tag('div', '<b>' . sprintf(_("WARNING! Tell the administrator to set the %s variable."), '"SpamFilters_YourHop"') . '</b>', 'center') . '<br />'; } if (isset($action) && $action == 'spam') { $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imapConnection); sqimap_logout($imapConnection); $numboxes = count($boxes);
} setPref($GLOBALS['data_dir'], $GLOBALS['username'], 'bayesspam_scan_size', (int) $_REQUEST['scan_size']); } elseif ($_REQUEST['action'] == 'ignore_add' && isset($_REQUEST['ignore_add'])) { $GLOBALS['bayesspam_ignore_folders'][] = $_REQUEST['ignore_add']; array_unique($GLOBALS['bayesspam_ignore_folders']); $temp = array(); foreach ($GLOBALS['bayesspam_ignore_folders'] as $value) { $temp[] = $value; } $GLOBALS['bayesspam_ignore_folders'] = $temp; for ($i = 0; $i < count($GLOBALS['bayesspam_ignore_folders']); $i++) { setPref($GLOBALS['data_dir'], $GLOBALS['username'], 'bayesspam_ignore_folders_' . $i, $GLOBALS['bayesspam_ignore_folders'][$i]); } } elseif ($_REQUEST['action'] == 'ignore_rem' && isset($_REQUEST['ignore_rem'])) { for ($i = 0; $i <= count($GLOBALS['bayesspam_ignore_folders']); $i++) { removePref($GLOBALS['data_dir'], $GLOBALS['username'], 'bayesspam_ignore_folders_' . $i); } $GLOBALS['bayesspam_ignore_folders'] = array_diff($GLOBALS['bayesspam_ignore_folders'], array($_REQUEST['ignore_rem'])); $temp = array(); foreach ($GLOBALS['bayesspam_ignore_folders'] as $value) { $temp[] = $value; } $GLOBALS['bayesspam_ignore_folders'] = $temp; array_merge($GLOBALS['bayesspam_ignore_folders'], array()); for ($i = 0; $i < count($GLOBALS['bayesspam_ignore_folders']); $i++) { setPref($GLOBALS['data_dir'], $GLOBALS['username'], 'bayesspam_ignore_folders_' . $i, $GLOBALS['bayesspam_ignore_folders'][$i]); } } elseif ($_REQUEST['action'] == 'rebuild') { bayesspam_rebuild_corpus(); } elseif ($_REQUEST['action'] == 'empty') { bayesspam_nuke_db();
function newmail_sav() { global $data_dir, $username; if (sqgetGlobalVar('submit_newmail', $submit, SQ_POST)) { $media_enable = ''; $media_popup = ''; $media_allbox = ''; $media_recent = ''; $media_changetitle = ''; $media_sel = ''; sqgetGlobalVar('media_enable', $media_enable, SQ_POST); sqgetGlobalVar('media_popup', $media_popup, SQ_POST); sqgetGlobalVar('media_allbox', $media_allbox, SQ_POST); sqgetGlobalVar('media_recent', $media_recent, SQ_POST); sqgetGlobalVar('media_changetitle', $media_changetitle, SQ_POST); sqgetGlobalVar('popup_height', $newmail_popup_height, SQ_POST); sqgetGlobalVar('popup_width', $newmail_popup_width, SQ_POST); setPref($data_dir, $username, 'newmail_enable', $media_enable); setPref($data_dir, $username, 'newmail_popup', $media_popup); setPref($data_dir, $username, 'newmail_allbox', $media_allbox); setPref($data_dir, $username, 'newmail_recent', $media_recent); setPref($data_dir, $username, 'newmail_popup_height', $newmail_popup_height); setPref($data_dir, $username, 'newmail_popup_width', $newmail_popup_width); setPref($data_dir, $username, 'newmail_changetitle', $media_changetitle); if (sqgetGlobalVar('media_sel', $media_sel, SQ_POST) && ($media_sel == '(none)' || $media_sel == '(local media)')) { removePref($data_dir, $username, 'newmail_media'); } else { setPref($data_dir, $username, 'newmail_media', $media_sel); } } }
/** * Main function attached to options_identities_process hook. * * Hook is not available in 1.4.5. */ function demo_options_identities_process_do(&$args) { global $demo_id, $data_dir, $username; // sm_print_r($args); if (count($args) == 3) { // SquirrelMail 1.4.6+ and 1.5.1+ if ($args[1] == 'demo_submit') { $demo_id = (int) $args[2]; setPref($data_dir, $username, 'demo_id', $demo_id); // FIXME: count number of hook calls. } elseif ($args[1] == 'save' && sqGetGlobalVar('demo_id_select', $demo_id_number, SQ_POST)) { // FIXME: count number of hook calls. $demo_id = (int) $demo_id_number; setPref($data_dir, $username, 'demo_id', $demo_id); } elseif ($args[1] == 'delete') { $deleted_id = (int) $args[2]; if ($demo_id == $deleted_id) { // demo id is deleted $demo_id = SMPREF_NONE; removePref($data_dir, $username, 'demo_id'); } elseif ($demo_id > $deleted_id) { // demo id is renumbered (-1) $demo_id = $demo_id - 1; setPref($data_dir, $username, 'demo_id', $demo_id); } } } elseif (sqgetGlobalVar('smaction', $smaction, SQ_POST) && is_array($smaction) && isset($smaction['demo_submit'])) { // process own buttons in form submission (1.4.4 or older and 1.5.0) $demo_id = (int) key($smaction['demo_submit']); setPref($data_dir, $username, 'demo_id', $demo_id); } elseif (sqgetGlobalVar('update', $tmp, SQ_POST) && sqGetGlobalVar('demo_id_select', $demo_id_number, SQ_POST)) { // check if form action is 'save/update', extract selected value of demo id radio box and save it $demo_id = (int) $demo_id_number; setPref($data_dir, $username, 'demo_id', $demo_id); } }