📄 user_ac.php
字号:
<?php
global $action,$cate,$superName;
switch($cate){
case "save":
$currentID=p('id');
$ONE["mName"]=p("mailName");
$ONE["mPhone"]=p("mailPhone");
$ONE["mAddress"]=p("mailAddress");
$ONE["mDetails"]=p("mailDetails");
$ONE["mMail"]=p("mail");
$ONE["mPass"]=p("pass");
//if(!$ONE['mName']) $msg='Name can not be empty.';
//if(!$ONE['mMail']) $msg='Email can not be empty.';
if($currentID!=0){
$sql="update members set mName='".$ONE['mName']."',mPhone='".$ONE['mPhone']."',mAddress='".$ONE['mAddress']."',mMail='".$ONE['mMail']."',mDetails='".$ONE['mDetails']."',mPass='".md5($ONE['mPass'])."',mRealPass='".$ONE['mPass']."' where ID=$currentID";
$title='User updated!';
$msg[]='User updated successfully.';
$msg[]='<a href="index.php?action=user">Back to view users</a>';
}
else{
$sql="insert into members(mName,mPhone,mAddress,mMail,mDetails,mCreated,mPass,mRealPass) values('".$ONE['mName']."','".$ONE['mPhone']."','".$ONE['mAddress']."','".$ONE['mMail']."','".$ONE['mDetails']."',".time().",'".md5($ONE['mPass'])."','".$ONE['mPass']."')";
$title='New user added!';
$msg[]='New user added successfully.';
$msg[]='<a href="index.php?action=user">Back to view users</a>';
}
if(isset($sql)){
$this->db->query($sql,'U_B');
}else{$title='Warning!';}
$this->set('finalTitle',$title);
$this->set('msg',$msg);
$this->set('final','warning');
break;
case "add":
$currentID=g('id');
$title='Add New User';
$ONE=array('ID'=>0,'mName'=>'','mPhone'=>'','mAddress'=>'','mDetails'=>'','mMail'=>'','mPass'=>'');
if($currentID){
$title='Edit User';
if($result=$this->db->get_one('select * from members where id='.$currentID)){
$ONE['ID'] =$currentID;
$ONE['mName'] =$result['mName'];
$ONE['mPhone'] =$result['mPhone'];
$ONE['mAddress'] =$result['mAddress'];
$ONE['mDetails'] =$result['mDetails'];
$ONE['mMail'] =$result['mMail'];
$ONE['mPass'] =$result['mRealPass'];
}
else{
$msg[]='User No. not found.';
$msg[]='<a href="index.php?action=user">Back to view users</a>';
}
}
if(isset($msg)){
$this->set('finalTitle','Warning!');
$this->set('msg',$msg);
$this->set('final','warning');
}
else{
$this->set('finalTitle',$title);
$this->set('ONE',$ONE);
$this->set('final','user_edit');
}
break;
case "send":
$pid=g('ids')?g('ids'):(p('ids')?join(p('ids'),','):false);
if($pid){
global $_SITEINFO;
$scount=0;
$title=$_POST["title"];
$message=$_POST["message"];
$header="From:".$_SITEINFO['EMAIL']."\r\nContent-Type:text/html;charset=\"utf-8\"";
$sql="select * from members where id in($pid)";
$result=$this->db->query($sql);
while($row=$db->fetch_array($result)){
mail($row['mMail'],$title,$message,$header);
$scount++;
}
$msg[]="You've send $scount email(s).";
$msg[]='<a href="index.php?action=user">Back to view users</a> <a href="index.php?action=user&cate=sendMessage">Send another one</a>';
$this->set('finalTitle','Emails sent!');
$this->set('msg',$msg);
$this->set('final','warning');
}
else{
$msg[]='No user selected';
$msg[]='<a href="index.php?action=user">Back to users</a> <a href="index.php?action=user&cate=sendMessage">Back to choose</a>';
$this->set('finalTitle','Warning!');
$this->set('msg',$msg);
$this->set('final','warning');
}
break;
case "sendMessage":
$sql = "select id,mName,mMail from members";
$result=$this->db->query($sql);
while($row=$this->db->fetch_array($result)){
$id=$row['id'];
$mName=$row['mName'];
$mMail=$row['mMail'];
$users[]=array($id,$mName,$mMail);
}
if(isset($users)) $this->set('users',$users);
$this->set('html',create_html_editor('html',350));
$this->set('finalTitle','Send Message');
$this->set('final','user_message');
break;
case "delete":
$pid=g('id')?g('id'):(p('id')?join(p('id'),','):false);
if($pid){
$sql="delete from members where id in($pid)";
$this->db->query($sql,'U_B');
$msg[]='User deleted successfully.';
$msg[]='<a href="index.php?action=user">Back to view users</a>';
$this->set('finalTitle','User deleted!');
$this->set('msg',$msg);
$this->set('final','warning');
}
else{
$msg[]='User deleted unsuccessfully';
$msg[]='<a href="index.php?action=user">Back to users</a>';
$this->set('finalTitle','Warning!');
$this->set('msg',$msg);
$this->set('final','warning');
}
break;
default:
$page[]=25;
if(g('page')){$page[]=intval(g('page'));}else{$page[]=1;}
$sql = "select count(id) as amount from members";
$result=$this->db->query($sql);
$row=$this->db->fetch_array($result);
$amount = $row['amount'];
if($amount){
if($amount % $page[0]){$page[]=(int)($amount/$page[0])+1;}else{$page[]=$amount/$page[0];}
$page[]=$amount;
}
else{$page[]=0;$page[]=0;}
$sql = "select id,mName,mMail from members limit ".($page[1]-1)*$page[0].",".$page[0];
$result=$this->db->query($sql);
while($row=$this->db->fetch_array($result)){
$id=$row['id'];
$mName=$row['mName'];
$mMail=$row['mMail'];
$users[]=array($id,$mName,$mMail);
}
if(isset($users)) $this->set('users',$users);
$this->set('page',$page);
$this->set('finalTitle','View Users');
$this->set('final','user');
break;
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -