-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.php
More file actions
44 lines (44 loc) · 1.03 KB
/
user.php
File metadata and controls
44 lines (44 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
include './lib/mysql_contral.php';
include './lib/class_other.php';
include './lib/session_mem.php';
include './lib/excel_io.php';
$db=new db_contral();
$db->connect_db();
if(isset($_SESSION['uid'])){
switch($_GET['action']){
case 'del':
$db->del_data('acc',array('uid'),array('='), array($_GET['uid']), array());
break;
case 'add':
if($_POST['pwd']!=''&&$_POST['usr']!=''){
$r=$db->db_query_n1('acc', 'usr', $_POST['usr']);
if(!count($r)){
$o=new other_func();
$salt=$o->random(8, 0);
$pwd=md5($_POST['pwd'].$salt);
$db->ins_data('acc',array('usr','pwd','salt'), array($_POST['usr'],$pwd,$salt));
}
else{
$err[0]['error']=2;
echo json_encode($err);
}
}
else{
$err[0]['error']=1;
echo json_encode($err);
}
break;
case 'change_pwd':
$r=$db->db_query_n1('acc', 'uid', $_GET['uid']);
$salt=$r[0]['salt'];
$pwd=md5($_POST['pwd'].$salt);
$db->update_data_basic('acc', array('pwd'), array($pwd), 'uid', '=', $_GET['uid']);
break;
}
}
else{
$err[0]['error']=1;
echo json_encode($err);
}
?>