You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
3.3 KiB
124 lines
3.3 KiB
<?php
|
|
require_once('../ajax_asm.php');
|
|
if( $CUser->Data['id'] > 1 ){
|
|
$DATA = array();
|
|
$DATA['success'] = false;
|
|
if( $CUser->Data['access'] > 4 ){
|
|
$COP = intval( $_POST['OP'] );
|
|
switch( $COP ){
|
|
case 0:{
|
|
//add new
|
|
$NLO = $DATABASE->escape( $_POST['NLO'] );
|
|
$PWD = $_POST['PW1'];
|
|
$RWD = $_POST['PW2'];
|
|
$ACC = intval($_POST['ACC']);
|
|
if( $PWD == '' ){
|
|
$DATA['msg'] = 'No Password defined!';
|
|
} else {
|
|
if( $_POST['NLO'] == '' ){
|
|
$DATA['msg'] = 'No Login defined!';
|
|
} else {
|
|
if( $PWD == $RWD ){
|
|
$M5 = md5( $PWD );
|
|
$CTS = time();
|
|
$QS="INSERT INTO `users`(`create_ts`,`login_id`,`pwd_hash`,`status`,`access`) VALUES ( {$CTS},'{$NLO}','{$M5}','A',{$ACC})";
|
|
$DATABASE->Query( $QS );
|
|
$DATA['success'] = true;
|
|
} else {
|
|
$DATA['msg'] = 'Passwords does not match!';
|
|
};
|
|
};
|
|
};
|
|
break;
|
|
};
|
|
case 1:{
|
|
//change old
|
|
$UID = intval($_POST['SUID']);
|
|
if( $UID ){
|
|
$OLO = $DATABASE->escape( $_POST['OLO'] );
|
|
$NLO = $DATABASE->escape( $_POST['NLO'] );
|
|
$PWD = $_POST['PW1'];
|
|
$RWD = $_POST['PW2'];
|
|
$ACC = intval($_POST['ACC']);
|
|
if( $PWD == '' ){
|
|
$QS="UPDATE `users` SET `login_id`='{$NLO}', `access`={$ACC} WHERE id={$UID}";
|
|
$DATABASE->Query( $QS );
|
|
$DATA['success'] = true;
|
|
} else {
|
|
if( $PWD == $RWD ){
|
|
$M5 = md5( $PWD );
|
|
$QS="UPDATE `users` SET `login_id`='{$NLO}', `pwdMD5`='{$M5}', `access`={$ACC} WHERE id={$UID}";
|
|
$DATABASE->Query( $QS );
|
|
$DATA['success'] = true;
|
|
} else {
|
|
$DATA['msg'] = 'Passwords does not match!';
|
|
};
|
|
};
|
|
} else {
|
|
$DATA['msg'] = 'Wrong User ID!';
|
|
};
|
|
break;
|
|
};
|
|
case 2:{
|
|
$UID = intval($_POST['SUID']);
|
|
if( $UID ){
|
|
if( $UID != $CUser->Data['id'] ){
|
|
if( $UID > 1 ){
|
|
$QS="UPDATE `users` SET `status`='D' WHERE id={$UID}";
|
|
$DATABASE->Query( $QS );
|
|
$DATA['success'] = true;
|
|
} else {
|
|
$DATA['msg'] = 'You Can not change Guest account!';
|
|
};
|
|
} else {
|
|
$DATA['msg'] = 'You Can not block yoreself account!';
|
|
};
|
|
} else {
|
|
$DATA['msg'] = 'Wrong User ID!';
|
|
};
|
|
break;
|
|
};
|
|
case 3:{
|
|
$UID = intval($_POST['SUID']);
|
|
if( $UID ){
|
|
if( $UID > 1 ){
|
|
$QS="UPDATE `users` SET `status`='A' WHERE id={$UID}";
|
|
$DATABASE->Query( $QS );
|
|
$DATA['success'] = true;
|
|
} else {
|
|
$DATA['msg'] = 'You Can not change Guest account!';
|
|
};
|
|
} else {
|
|
$DATA['msg'] = 'Wrong User ID!';
|
|
};
|
|
break;
|
|
};
|
|
case 4:{
|
|
$UID = intval($_POST['SUID']);
|
|
if( $UID ){
|
|
if( $UID != $CUser->Data['id'] ){
|
|
if( $UID > 1 ){
|
|
$QS="DELETE FROM `users` WHERE id={$UID}";
|
|
$DATABASE->Query( $QS );
|
|
$DATA['success'] = true;
|
|
} else {
|
|
$DATA['msg'] = 'You Can not remove Guest account!';
|
|
};
|
|
} else {
|
|
$DATA['msg'] = 'You Can not remove yoreself account!';
|
|
};
|
|
} else {
|
|
$DATA['msg'] = 'Wrong User ID!';
|
|
};
|
|
break;
|
|
};
|
|
default: $DATA['msg'] = 'Wrong Operation!'; break;
|
|
};
|
|
} else {
|
|
$DATA['msg'] = 'Access Permition Denied!';
|
|
};
|
|
echo json_encode( $DATA );
|
|
exit();
|
|
};
|
|
header('location: /');
|
|
?>
|