<?php
require_once('config.php');
$uid=$_SESSION['user'];
$userFile=ABSPATH.'data/users/'.preg_replace('/[^a-zA-Z0-9_-]/','',$uid).'.meta';
$uData=file_exists($userFile)?loadMeta($userFile):[];
$uPrefs=$uData['prefs']??[];
$PER_PAGE_DESKTOP=(int)($uPrefs['PER_PAGE_DESKTOP']??$PER_PAGE_DESKTOP);
$PER_PAGE_MOBILE=(int)($uPrefs['PER_PAGE_MOBILE']??$PER_PAGE_MOBILE);
if(!isset($_SESSION['user'])){header("Location:login.php");exit;}
$settingsFile=ABSPATH.'data/users/settings.meta';
$usersFile=ABSPATH.'data/users/users.meta';
$userSettingsDir=ABSPATH.'data/users/';
$USERS=file_exists($usersFile)?loadMeta($usersFile):[];
$search=trim($_GET['q']??'');
$searchMemo=isset($_GET['sm'])&&$_GET['sm']==='1';
$filteredUsers=[];
foreach($USERS as $user=>$info){
if($search==='')$filteredUsers[$user]=$info;
else{
$found=stripos($user,$search)!==false||stripos($info['name']??'',$search)!==false;
if(!$found&&$searchMemo&&!empty($info['memo']))$found=stripos($info['memo'],$search)!==false;
if($found)$filteredUsers[$user]=$info;
}}
uksort($filteredUsers,function($a,$b)use($filteredUsers){
$priority=['admin'=>1,'user'=>2,'view'=>3];
$cmp=($priority[$filteredUsers[$a]['role']??'user']??2)<=>($priority[$filteredUsers[$b]['role']??'user']??2);
return $cmp!==0?$cmp:strcasecmp($a,$b);
});
$isMobile=preg_match('/Mobile|Android|iPhone|iPad/i',$_SERVER['HTTP_USER_AGENT']);
$perPage=$isMobile?$PER_PAGE_MOBILE:$PER_PAGE_DESKTOP;
$totalItems=count($filteredUsers);
$totalPages=max(1,ceil($totalItems/$perPage));
$page=max(1,min($totalPages,(int)($_GET['page']??1)));
$displayUsers=array_slice($filteredUsers,($page-1)*$perPage,$perPage,true);
if(!is_dir($userSettingsDir))mkdir($userSettingsDir,0755,true);
$conf=file_exists($settingsFile)?loadMeta($settingsFile):[];
$USERS=file_exists($usersFile)?loadMeta($usersFile):[];
function getUserSettingsFile($username){
global $userSettingsDir;
$safeName=preg_replace('/[^a-zA-Z0-9_-]/','',$username);
if(empty($safeName))die("Invalid Username");
return $userSettingsDir.$safeName.'.meta';
}
function loadUserSettings($username){$file=getUserSettingsFile($username);return file_exists($file)?loadMeta($file):[];}
function saveUserSettings($username,$data){$file=getUserSettingsFile($username);return saveMeta($file,$data);}
if($_SERVER['REQUEST_METHOD']==='POST'&&hash_equals($_SESSION['csrf'],$_POST['csrf'])){
$mode=$_POST['mode'];
$redirectTab=$mode;
if($mode==='system'&&is_admin()){
$conf['general']=$_POST['gen'];
$numKeys=['MAX_LOGIN_ATTEMPTS','BLOCK_TIME_SECONDS','scan_limit','recent_limit','PER_PAGE_DESKTOP','PER_PAGE_MOBILE','fax_retry','fax_error_timer'];
foreach($numKeys as $nk){if(isset($conf['general'][$nk]))$conf['general'][$nk]=(int)$conf['general'][$nk];}
saveMeta($settingsFile,$conf);
}elseif($mode==='permissions'&&is_admin()){
$conf['permissions']=$_POST['perm'];
foreach($conf['permissions'] as $key=>&$roles){$roles['admin']='on';}
saveMeta($settingsFile,$conf);
}elseif($mode==='account'&&is_admin()){
$uname=preg_replace('/[^a-zA-Z0-9_-]/','',$_POST['username']);
$action=$_POST['user_action'];
if($action==='delete'){
if($uname!==$_SESSION['user']&&isset($USERS[$uname])){
unset($USERS[$uname]);
$uFile=getUserSettingsFile($uname);
if(file_exists($uFile))unlink($uFile);
$cFile=ABSPATH.'data/contacts/'.$uname.'.meta';
if(file_exists($cFile))@unlink($cFile);
}
}else{
if(empty($uname))die("Invalid Username");
if(!isset($USERS[$uname]))$USERS[$uname]=[];
if(!empty($_POST['password'])){$USERS[$uname]['pass']=password_hash($_POST['password'],PASSWORD_BCRYPT,['cost'=>12]);}
$USERS[$uname]['role']=$_POST['role'];
$USERS[$uname]['name']=$_POST['name']??'';
$USERS[$uname]['memo']=$_POST['memo']??'';
}
saveMeta($usersFile,$USERS);
}elseif($mode==='my_profile'){
$uid=$_SESSION['user'];
$userSettings=loadUserSettings($uid);
$userSettings['prefs']=$_POST['my'];
saveUserSettings($uid,$userSettings);
$redirectTab='profile';
}
header("Location:fax_settings.php?view=".urlencode($redirectTab));exit;
}
$viewMode=$_GET['view']??'profile';
if(isset($_GET['q'])&&is_admin())$viewMode='account';
if(!is_admin()&&in_array($viewMode,['system','permissions','account']))$viewMode='profile';
$langDir=WP_LANG_DIR;
$availableLangs=[];
if(is_dir($langDir)){foreach(scandir($langDir)as $file){if(pathinfo($file,PATHINFO_EXTENSION)==='mo')$availableLangs[]=basename($file,'.mo');}}
if(!in_array('en_EN',$availableLangs))$availableLangs[]='en_EN';
sort($availableLangs);
$currentLang=$conf['general']['WPLANG']??'en_EN';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title><?=ns(APP_NAME)?> - <?php _nsl('Settings');?></title>
<link rel="stylesheet" href="include/css/style.css">
<?php include('include/web/header.php');?>
<script>
window.FAX_LANG={
id:"<?=ns(__('ID'))?>",
password:"<?=ns(__('PASSWORD'))?>",
name:"<?=ns(__('Name'))?>",
leaveBlankToKeep:"<?=ns(__('leaveBlankToKeep'))?>",
alert:"<?=ns(__('Alert'))?>",
ok:"<?=ns(__('Ok'))?>",
save:"<?=ns(__('Save'))?>",
cancel:"<?=ns(__('Cancel'))?>",
delete:"<?=ns(__('Delete'))?>",
section:"<?=ns(__('Section'))?>",
Settings:"<?=ns(__('Settings'))?>",
Profile:"<?=ns(__('User Profile'))?>",
System:"<?=ns(__('System Settings'))?>",
Permissions:"<?=ns(__('Group Permissions'))?>",
Account:"<?=ns(__('Account Management'))?>",
search:"<?=ns(__('Search'))?>",
keyword:"<?=ns(__('Enter keyword'))?>",
withMemo:"<?=ns(__('Include memo content'))?>",
Admin:"<?=ns(__('Admin'))?>",
Users:"<?=ns(__('Users'))?>",
View:"<?=ns(__('View'))?>",
Group:"<?=ns(__('Group'))?>",
addAccount:"<?=ns(__('Add Account'))?>",
editAccount:"<?=ns(__('Edit Account'))?>",
memo:"<?=ns(__('Enter memo (optional)'))?>",
alert:"<?=ns(__('Alert'))?>",
pushTitle:"<?=ns(__('Push Notification'))?>",
pushDesc:"<?=ns(__('You can register or test push notifications'))?>",
pushRegister:"<?=ns(__('Subscribe'))?>",
pushTest:"<?=ns(__('Test'))?>",
pushNotSupported:"<?=ns(__('Push is not supported in this browser'))?>",
pushNeedPermission:"<?=ns(__('Notification permission is required'))?>",
pushAlready:"<?=ns(__('Already subscribed'))?>",
pushSuccess:"<?=ns(__('Push subscription completed'))?>",
pushTestSuccess:"<?=ns(__('Test notification sent'))?>",
pushTestFail:"<?=ns(__('Test failed'))?>",
help:"<?=ns(__('Help'))?>",
help1:"<?=ns(__('Select the language used in the application interface'))?>",
help2:"<?=ns(__('Set how many fax items are displayed per page on desktop'))?>",
help3:"<?=ns(__('Set how many fax items are displayed per page on mobile devices'))?>",
help4:"<?=ns(__('Select the criteria used to sort the list'))?>",
help5:"<?=ns(__('Set the sorting order for folders'))?>",
help6:"<?=ns(__('Set the sorting order for files'))?>",
help7:"<?=ns(__('Choose how contacts are grouped in the list. Public contacts can be shown first or mixed with others'))?>",
help8:"<?=ns(__('Set the full name of the application displayed in the interface'))?>",
help9:"<?=ns(__('Set a short name used where space is limited'))?>",
help10:"<?=ns(__('Set the maximum number of login attempts before blocking access'))?>",
help11:"<?=ns(__('Set how long login is blocked after reaching the maximum attempts (in seconds)'))?>",
help12:"<?=ns(__('Set how many times the system retries sending a fax after failure'))?>",
help13:"<?=ns(__('Set the time before a fax is marked as failed (in seconds)'))?>",
help14:"<?=ns(__('Set the maximum number of files to scan when building the list'))?>",
help15:"<?=ns(__('Set how many recent items are shown in the list'))?>",
accountMemo:"<?=ns(__('Account Memo'))?>",
deleteAccount:"<?=ns(__('Delete Account'))?>",
deleteConfirm:"<?=ns(__('The selected account will be deleted. This action cannot be undone. Are you sure you want to proceed?'))?>",
deleteConfirmMsg:"<?=ns(__('You cannot delete your own account'))?>"
};
window.PUSH_CONFIG={publicKey:"<?=PUSH_PUBLIC_KEY?>"};
const IS_ADMIN=<?=is_admin()?'true':'false'?>;
const VIEW_MODE="<?=ns($viewMode)?>";
window.FAX_ENV={currentUser:"<?=ns($_SESSION['user'])?>",search:"<?=ns($search)?>",withMemo:<?=($searchMemo?1:0)?>};
function openCategoryDialog(){window.openSettingsCategoryDialog(VIEW_MODE);}
function showUserMemo(memo) {if(!memo) return;modalAlert(memo);}
</script>
<script src="include/js/base.js" defer></script>
<script src="include/js/modal.js" defer></script>
</head>
<body>
<div id="menuToggle">≡ <?php _nsl('Menu');?></div>
<div id="container">
<?php include('menu.php');?>
<div id="main">
<h2><?php _nsl('Settings');?></h2>
<div class="table-wrapper">
<table>
<thead>
<tr>
<th class="faxlist-top" colspan="3">
<div class="faxlist-header">
<div class="faxlist-path">
<strong>
<?php if($viewMode=='system')_nsl('System Settings');
elseif($viewMode=='permissions')_nsl('Group Permissions');
elseif($viewMode=='account'){echo '<a class="menulink" href="fax_settings.php?view=account">';_nsl('Account List');echo'</a>';}
else _nsl('User Profile');?>
</strong>
</div>
<div class="faxlist-actions">
<?php if(is_admin()):?>
<?php if($viewMode=='account'):?>
<button class="add-btn" onclick="openUserModal('add', '<?=ns($_SESSION['csrf'])?>')"><?php _nsl('Add');?></button>
<button class="faxlist-btn" onclick="openSearchDialog()"><?php _nsl('Search');?></button>
<?php endif;?>
<button class="faxlist-btn" onclick="openSettingsDialog()"><?php _nsl('Section');?></button>
<?php endif;?>
</div></div>
</th>
</tr>
</thead>
<?php if($viewMode=='system'&&is_admin()):?>
<form method="POST">
<input type="hidden" name="csrf" value="<?=ns($_SESSION['csrf'])?>">
<input type="hidden" name="mode" value="system">
<table class="fax-table">
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help8"><?php _nsl('Full Name');?></span></td><td class="s-field"><div class="input-group"><input type="text" name="gen[APP_NAME]" value="<?=ns($conf['general']['APP_NAME']??'NSFAX')?>"></div></td></tr>
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help9"><?php _nsl('Short Name');?></span></td><td class="s-field"><div class="input-group"><input type="text" name="gen[APP_SHORT_NAME]" value="<?=ns($conf['general']['APP_SHORT_NAME']??'NSFAX')?>"></div></td></tr>
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help1"><?php _nsl('Language');?></span></td><td class="s-field"><div class="input-group"><select name="gen[WPLANG]" class="setting-input"><?php foreach($availableLangs as $lang):?><option value="<?=ns($lang)?>"<?=$lang===$currentLang?'selected':''?>><?=ns($lang)?></option><?php endforeach;?></select></div></td></tr>
</table></table></div>
<div class="set-table-wrapper">
<table>
<thead><tr><th class="setlist-top"><?php _nsl('Login Security');?></th></tr></thead>
<table class="fax-table">
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help10"><?php _nsl('Max Attempts');?></span></td><td class="s-field"><div class="input-group"><input type="number" name="gen[MAX_LOGIN_ATTEMPTS]" value="<?=$conf['general']['MAX_LOGIN_ATTEMPTS']??3?>"></div></td></tr>
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help11"><?php _nsl('Block Time');?></span></td><td class="s-field"><div class="input-group"><input type="number" name="gen[BLOCK_TIME_SECONDS]" value="<?=$conf['general']['BLOCK_TIME_SECONDS']??1200?>"></div></td></tr>
</table></table></div>
<div class="set-table-wrapper">
<table>
<thead><tr><th class="setlist-top"><?php _nsl('Fax Transmission');?></th></tr></thead>
<table class="fax-table">
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help12"><?php _nsl('Retry Attempts');?></span></td><td class="s-field"><div class="input-group"><input type="number" name="gen[fax_retry]" value="<?=$conf['general']['fax_retry']??1?>"></div></td></tr>
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help13"><?php _nsl('Error Fall Time');?></span></td><td class="s-field"><div class="input-group"><input type="number" name="gen[fax_error_timer]" value="<?=$conf['general']['fax_error_timer']??600?>"></div></td></tr>
</table></table></div>
<div class="set-table-wrapper">
<table>
<thead><tr><th class="setlist-top"><?php _nsl('Index List');?></th></tr></thead>
<table class="fax-table">
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help14"><?php _nsl('Maximum Files to Scan');?></td><td class="s-field"><div class="input-group"><input type="number" name="gen[scan_limit]" value="<?=$conf['general']['scan_limit']??50?>"></div></td></tr>
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help15"><?php _nsl('Recent Items Limit');?></td><td class="s-field"><div class="input-group"><input type="number" name="gen[recent_limit]" value="<?=$conf['general']['recent_limit']??5?>"></div></td></tr>
<tr><th colspan="2"><button type="submit" class="send-btn"><?php _nsl('Save');?></button></th></tr>
</table></table>
</form>
<?php elseif($viewMode=='permissions'&&is_admin()):?>
<form method="POST">
<input type="hidden" name="csrf" value="<?=ns($_SESSION['csrf'])?>">
<input type="hidden" name="mode" value="permissions">
<table class="fax-table" style="text-align:center;">
<thead
<tr>
<th><?php _nsl('Module Name');?></th>
<th style="text-align:center;"><?php _nsl('Users');?></th><th style="text-align:center;"><?php _nsl('View');?></th>
</tr>
</thead>
<?php $rowClass='row-classic';foreach($permissions as $key=>$roles):$rowClass=($rowClass=='row-classic')?'row-alternate':'row-classic';?>
<tr class="<?=$rowClass?>">
<td style="text-align:left;"><?php _nsl($key);?></td>
<?php foreach(['user','view'] as $r):?>
<td>
<input type="hidden" name="perm[<?=$key?>][<?=$r?>]" value="off">
<input type="checkbox" name="perm[<?=$key?>][<?=$r?>]" value="on" style="transform:scale(1.3);" <?=isset($roles[$r])&&$roles[$r]==='on'?'checked':''?>>
</td>
<?php endforeach;?>
</tr>
<?php endforeach;?>
<tr><th colspan="4"><button type="submit" class="send-btn"><?php _nsl('Save');?></button></th></tr>
</table>
</form>
<?php elseif($viewMode=='account'&&is_admin()):?>
<table class="fax-table">
<tbody>
<?php $rowClass='row-classic';if(empty($displayUsers)){echo"<tr><td colspan='3' class='web-msg'>".ns($search!==''?__('No accounts found matching your search'):__('No accounts found'))."</td></tr>";}
foreach($displayUsers as $user=>$info):
$rowClass=($rowClass=='row-classic')?'row-alternate':'row-classic';
$roleClass='badge-'.($info['role']??'user');
?>
<tr class="<?=$rowClass?>">
<td>
<span class="badge <?=$roleClass?>"><?php if(($info['role']??'')=='admin')_nsl('Admin');elseif(($info['role']??'')=='view')_nsl('View');else _nsl('Users');?></span>
<strong><?=ns($user)?></strong><?php if(!empty($info['name'])):?>(<?=ns($info['name'])?>)<?php endif;?>
<?php if(!empty($info['memo'])):?> <span class="memo-icon" data-memo="<?=ns($info['memo'])?>" onclick="openSMemoAlert(this)"><span class="fax-memo">M</span></span><?php endif;?>
</td>
<td class='icon'><a href="#" onclick='openUserModal("edit","<?=ns($_SESSION['csrf'])?>",<?=json_encode(["username"=>$user,"name"=>$info['name']??"","role"=>$info['role']??"","memo"=>$info['memo']??""])?>);return false;'><img src="img/box_submenu.png"></a></td>
<td class='icon'><?php if($user!==$_SESSION['user']):?><a href="#" onclick="openUserDeleteDialog('<?=ns($user)?>','<?=ns($_SESSION['csrf'])?>');return false;"><img src="img/box_remove.png"></a><?php else:?><a href="#" onclick="modalAlert(window.FAX_LANG.deleteConfirmMsg);return false;"><img src="img/box_remove.png" style="opacity:0.4;filter:grayscale(100%);"></a><?php endif;?></td>
</tr>
<?php endforeach;?>
<?php if($totalPages>1):?>
<tr><th colspan="3"><div class="pagination">
<?php $q="view=account&q=".urlencode($search);
if($page>1):?>
<input type="button" class="page-btn" value="«" onclick="location.href='?<?=$q?>&page=1'">
<input type="button" class="page-btn" value="‹" onclick="location.href='?<?=$q?>&page=<?=($page-1)?>'">
<?php endif;
for($p=max(1,$page-2);$p<=min($totalPages,$page+2);$p++):
$active=($p==$page)?'current':'';?>
<input type="button" class="page-btn <?=$active?>" value="<?=$p?>" onclick="location.href='?<?=$q?>&page=<?=$p?>'">
<?php endfor;
if($page<$totalPages):?>
<input type="button" class="page-btn" value="›" onclick="location.href='?<?=$q?>&page=<?=($page+1)?>'">
<input type="button" class="page-btn" value="»" onclick="location.href='?<?=$q?>&page=<?=$totalPages?>'">
<?php endif;?>
</div></th></tr>
<?php endif;?>
</tbody>
</table>
</div>
<?php else:?>
<?php 
$uid=$_SESSION['user'];
$userSettings=loadUserSettings($uid);
$prefs=$userSettings['prefs']??[];
?>
<form method="POST">
<input type="hidden" name="csrf" value="<?=ns($_SESSION['csrf'])?>">
<input type="hidden" name="mode" value="my_profile">
<table class="fax-table">
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help1"><?php _nsl('Language');?></span></td><td class="s-field"><div class="input-group"><select name="my[WPLANG]" class="setting-input"><?php foreach($availableLangs as $lang):?><option value="<?=ns($lang)?>"<?=($prefs['WPLANG']??$currentLang)===$lang?'selected':''?>><?=ns($lang)?></option><?php endforeach; ?></select></div></td></tr>
</table></table></div>
<div class="set-table-wrapper">
<table>
<thead><tr><th class="setlist-top"><?php _nsl('Fax List');?></th></tr></thead>
<table class="fax-table">
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help2"><?php _nsl('Item (PC)');?></span></td><td class="s-field"><div class="input-group"><input type="number" name="my[PER_PAGE_DESKTOP]" value="<?=$prefs['PER_PAGE_DESKTOP']??$PER_PAGE_DESKTOP?>"></div></td></tr>
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help3"><?php _nsl('Item (Mobile)');?></span></td><td class="s-field"><div class="input-group"><input type="number" name="my[PER_PAGE_MOBILE]" value="<?=$prefs['PER_PAGE_MOBILE']??$PER_PAGE_MOBILE?>"></div></td></tr>
</table></table></div>
<?php if(has_permission('inboxmenu')):?>
<div class="set-table-wrapper">
<table>
<thead><tr><th class="setlist-top"><?php _nsl('Fax Inbox');?></th></tr></thead>
<table class="fax-table">
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help4"><?php _nsl('Sort by');?></span></td><td class="s-field"><div class="input-group"><select name="my[inboxsortMode]"><option value="folder"<?=($prefs['inboxsortMode']??'folder')=='folder'?'selected':''?>><?php _nsl('Folder priority');?></option><option value="file"<?=($prefs['inboxsortMode']??'folder')=='file'?'selected':''?>><?php _nsl('File priority');?></option></select></div></td></tr>
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help5"><?php _nsl('Folder Order');?></span></td><td class="s-field"><div class="input-group"><select name="my[inboxfoldersortMode]"><option value="on"<?=($prefs['inboxfoldersortMode']??'off')=='on'?'selected':''?>><?php _nsl('Descending (Z-A)');?></option><option value="off"<?=($prefs['inboxfoldersortMode']??'off')=='off'?'selected':''?>><?php _nsl('Ascending (A-Z)');?></option></select></div></td></tr>
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help6"><?php _nsl('File Order');?></span></td><td class="s-field"><div class="input-group"><select name="my[inboxfilesortMode]"><option value="on"<?=($prefs['inboxfilesortMode']??'on')=='on'?'selected':''?>><?php _nsl('Newest first');?></option><option value="off"<?=($prefs['inboxfilesortMode']??'on')=='off'?'selected':''?>><?php _nsl('Oldest first');?></option></select></div></td></tr>
<?php endif;?>
<?php if(has_permission('outboxmenu')):?>
</table></table></div>
<div class="set-table-wrapper">
<table>
<thead><tr><th class="setlist-top"><?php _nsl('Fax Outbox');?></th></tr></thead>
<table class="fax-table">
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help4"><?php _nsl('Sort by');?></span></td><td class="s-field"><div class="input-group"><select name="my[outboxsortMode]"><option value="folder"<?=($prefs['outboxsortMode']??'folder')=='folder'?'selected':''?>><?php _nsl('Folder priority');?></option><option value="file"<?=($prefs['outboxsortMode']??'folder')=='file'?'selected':''?>><?php _nsl('File priority');?></option></select></div></td></tr>
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help5"><?php _nsl('Folder Order');?></span></td><td class="s-field"><div class="input-group"><select name="my[outboxfoldersortMode]"><option value="on"<?=($prefs['outboxfoldersortMode']??'off')=='on'?'selected':''?>><?php _nsl('Descending (Z-A)');?></option><option value="off"<?=($prefs['outboxfoldersortMode']??'off')=='off'?'selected':''?>><?php _nsl('Ascending (A-Z)');?></option></select></div></td></tr>
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help6"><?php _nsl('File Order');?></span></td><td class="s-field"><div class="input-group"><select name="my[outboxfilesortMode]"><option value="on"<?=($prefs['outboxfilesortMode']??'on')=='on'?'selected':''?>><?php _nsl('Newest first');?></option><option value="off"<?=($prefs['inboxfilesortMode']??'on')=='off'?'selected':''?>><?php _nsl('Oldest first');?></option></select></div></td></tr>
<?php endif;?>
<?php if(has_permission('faxcontacts')):?>
</table></table></div>
<div class="set-table-wrapper">
<table>
<thead><tr><th class="setlist-top"><?php _nsl('Contacts');?></th></tr></thead>
<table class="fax-table">
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help4"><?php _nsl('Sort by');?></span></td><td class="s-field"><div class="input-group"><select name="my[contactNameSortMode]"><option value="on"<?=($prefs['contactNameSortMode']??'off')=='on'?'selected':''?>><?php _nsl('Descending (Z-A)');?></option><option value="off"<?=($prefs['contactNameSortMode']??'off')=='off'?'selected':''?>><?php _nsl('Ascending (A-Z)');?></option></select></div></td></tr>
<tr class="setbg"><td class="s-label"><span class="help-text" data-help="help7"><?php _nsl('Group Order');?></span></td><td class="s-field"><div class="input-group"><select name="my[contactSortMode]"><option value="public"<?=($prefs['contactSortMode']??'public')=='public'?'selected':''?>><?php _nsl('Public Contacts First');?></option><option value="mix"<?=($prefs['contactSortMode']??'public')!='public'?'selected':''?>><?php _nsl('All Contacts');?></option></select></div></td></tr>
<?php endif;?>
<tr><th colspan="2"><button type="submit" class="send-btn"><?php _nsl('Save');?></button></th></tr>
</table></table></div>
</form>
<?php endif;?>
</div>
</div>
</div>
<?php include('include/web/modal.php');?>
<?php include('include/web/footer.php');?>
</body>
</html>
