'.print_r($_POST,1).''.N; use function mysqli_real_escape_string as myesc; // praticamente una macro function hspech($str) { return(htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8')); } function inputerr(&$account) { muoribene(t('
Errori di input.
Stavi cercando di editare il tuo account?
Input errors.
Where you trying to edit your account?
You can edit your account only.
'.N,true); if ($id!=0) { $res=mysqli_query($link,'SELECT * FROM Admins WHERE ID='.$id) or muoribene(__LINE__.': '.mysqli_error($link),true); if (mysqli_num_rows($res)==0) muoribene('Non esiste alcun account con ID='.$id.'
Se vuoi puoi editare il tuo account.
Come admin di livello “normale” puoi editare solo il tuo account e gli account di livello “guest”.
',true); if ($id==0) $atit=t('Nuovo account','New account'); elseif ($ownacc) $atit=t('Il tuo account','Your account'); else $atit='Account «'.hspech($acc['Email']).'»'; /* [id] => 3 [Username] => bida [Email] => mastodon@bida.im [Password] => [CPassword] => [Level] => guest [MaxLocalities] => 1 [MaxLanguages] => 0 [MaxFinancing] => 5 [MaxPolicies] => 3 [MaxTags] => 3 [Enabled] => 1 */ function ckmax($key) { global $fields; if (preg_match('/^[0-9]+$/',$_POST[$key])==1 && $_POST[$key]+0>=$fields[$key]['min'] && $_POST[$key]+0<=$fields[$key]['max']) return(true); else return(false); } if ($post) { $quea=array(); $quea[]='Username="'.myesc($link,$_POST['Username']).'"'; $quea[]='Email="'.myesc($link,$_POST['Email']).'"'; if ($_POST['Password']!='' || $_POST['CPassword']!='') { if ($_POST['Password']!=$_POST['CPassword']) inputerr($account); $quea[]='Password="'.myesc($link,password_hash($_POST['Password'],PASSWORD_DEFAULT)).'"'; } $ok=true; if (array_key_exists('Level',$_POST)) { if (!in_array($_POST['Level'],array('guest','normal','super'))) $ok=false; if ($account['Level']=='normal' && !$ownacc && !in_array($_POST['Level'],array('guest','normal'))) $ok=false; if ($account['Level']=='normal' && $ownacc) $ok=false; if ($account['Level']=='guest') $ok=false; if (!$ok) inputerr($account); $quea[]='Level="'.$_POST['Level'].'"'; } if (count(ckkeys(array('MaxLocalities','MaxLanguages','MaxFinancing','MaxPolicies','MaxTags'),$_POST))==0) { if ($account['Level']=='guest') $ok=false; if ($account['Level']=='normal' && $ownacc) $ok=false; if ($ok && ckmax('MaxLocalities') && ckmax('MaxLanguages') && ckmax('MaxFinancing') && ckmax('MaxPolicies') && ckmax('MaxTags')) { $quea[]='MaxLocalities='.$_POST['MaxLocalities']; $quea[]='MaxLanguages='.$_POST['MaxLanguages']; $quea[]='MaxFinancing='.$_POST['MaxFinancing']; $quea[]='MaxPolicies='.$_POST['MaxPolicies']; $quea[]='MaxTags='.$_POST['MaxTags']; } else { inputerr($account); } } if (array_key_exists('Enabled',$_POST)) { if (!in_array($_POST['Enabled'],array('0','1'))) inputerr($account); ($ownacc && $_POST['Enabled']=='0') ? $logout=true : $logout=false; $quea[]='Enabled='.$_POST['Enabled']; } if ($id!=0) $que='UPDATE Admins SET '.implode(', ',$quea).' WHERE ID='.$id; else $que='INSERT INTO Admins SET '.implode(', ',$quea); $dbg.='QUERONA: '.hspech($que); mysqli_query($link,$que) or muoribene(__LINE__.': '.mysqli_error($link),true); if ($logout) { $_SESSION=array(); session_destroy(); muoribene(''.t('Il tuo account è stato disattivato correttamente. Ciao! :-)','Your account has been correctly disabled. Bye! :-)').'
'.N,true); } $out=' '.N; } else { $out=''.N; } mysqli_close($link); ?>