修改子平台用户登录及管理的相关功能
This commit is contained in:
parent
4d8c3abbce
commit
71fac4e412
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
use Helpers\View as view;
|
use Helpers\View as view;
|
||||||
use \Users\Local;
|
use Helpers\PDO;
|
||||||
use Helpers\dbh;
|
use Users\Users;
|
||||||
|
|
||||||
class Admin_UserController extends Zend_Controller_Action
|
class Admin_UserController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
function preDispatch()
|
function preDispatch()
|
||||||
|
@ -34,57 +35,21 @@ class Admin_UserController extends Zend_Controller_Action
|
||||||
|
|
||||||
function listAction()
|
function listAction()
|
||||||
{
|
{
|
||||||
|
|
||||||
$select=$this->db->select();
|
$select=$this->db->select();
|
||||||
|
|
||||||
|
|
||||||
$select->from('users')
|
$select->from('users')
|
||||||
->where('usertype = ?', 'member')
|
->where('usertype = ?', 'member')
|
||||||
->order('users.id desc');
|
->order('users.id desc');
|
||||||
|
|
||||||
view::addPaginator($select,$this,20);
|
|
||||||
}//listAction
|
|
||||||
|
|
||||||
#添加本地用户
|
$paginator = Zend_Paginator::factory($select);
|
||||||
function localAction()
|
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||||||
{
|
$paginator->setItemCountPerPage(30);
|
||||||
$this->view->ac = $ac = $this->_getParam('ac');
|
$paginator->setView($this->view);
|
||||||
$submit = $this->_getParam('submit');
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
|
||||||
$local = new Local();
|
$this->view->paginator=$paginator;
|
||||||
|
|
||||||
if(empty($ac))
|
|
||||||
{
|
|
||||||
$select=$this->db->select();
|
|
||||||
|
|
||||||
$select->from(array('u'=>'users','l'=>'users_local'))
|
|
||||||
->join(array('l'=>'users_local'),'u.id=l.uid')
|
|
||||||
->order('u.id desc');
|
|
||||||
|
|
||||||
view::addPaginator($select,$this,20);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($ac=='addLocal')
|
|
||||||
{
|
|
||||||
if(view::isXmlHttpRequest($this))
|
|
||||||
{
|
|
||||||
$status = $local->addLocalUser();
|
|
||||||
if($status !== true)
|
|
||||||
{
|
|
||||||
$this->jsonexit(array('error'=>$status));
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
$this->jsonexit(array('success'=>1));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($ac == 'delete')
|
|
||||||
{
|
|
||||||
view::Post($this,$local->deleteUser($this->_getParam('id')),-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}//listAction
|
}//listAction
|
||||||
|
|
||||||
function searchAction()
|
function searchAction()
|
||||||
|
@ -204,10 +169,10 @@ class Admin_UserController extends Zend_Controller_Action
|
||||||
if (isset($id))
|
if (isset($id))
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$sql="select * from users where id=?";
|
$user = new \Users\Users;
|
||||||
$result=$this->db->query($sql,$id);
|
$this->view->infos=$user->getUser($id);
|
||||||
$rows = $result->fetch();
|
$this->view->usertypes = $user->getUserType();
|
||||||
$this->view->infos=$rows;
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->messenger->addMessage($e->getMessage());
|
$this->messenger->addMessage($e->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -276,6 +241,7 @@ class Admin_UserController extends Zend_Controller_Action
|
||||||
$updates=array();
|
$updates=array();
|
||||||
if (isset($id))
|
if (isset($id))
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!empty($newpwd)&&!empty($cfnewpwd))
|
if(!empty($newpwd)&&!empty($cfnewpwd))
|
||||||
{
|
{
|
||||||
if($newpwd==$cfnewpwd)
|
if($newpwd==$cfnewpwd)
|
||||||
|
@ -303,6 +269,7 @@ class Admin_UserController extends Zend_Controller_Action
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->messenger->addMessage($e->getMessage());
|
$this->messenger->addMessage($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_redirect("/admin/user/show/id/$id");
|
$this->_redirect("/admin/user/show/id/$id");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -2,32 +2,28 @@
|
||||||
$this->headTitle($this->config->title->site);
|
$this->headTitle($this->config->title->site);
|
||||||
$this->headTitle('后台管理');
|
$this->headTitle('后台管理');
|
||||||
$this->headTitle()->setSeparator(' - ');
|
$this->headTitle()->setSeparator(' - ');
|
||||||
# $this->headLink()->appendStylesheet('/css/admin.css');
|
$this->headLink()->appendStylesheet('/css/admin.css');
|
||||||
$this->breadcrumb('<a href="/">首页</a>');
|
$this->breadcrumb('<a href="/">首页</a>');
|
||||||
$this->breadcrumb('<a href="/admin/">后台首页</a>');
|
$this->breadcrumb('<a href="/admin/">后台首页</a>');
|
||||||
$this->breadcrumb('<a href="/admin/user">用户管理</a>');
|
$this->breadcrumb('<a href="/admin/user">用户管理</a>');
|
||||||
$this->breadcrumb()->setSeparator(' > ');
|
$this->breadcrumb()->setSeparator(' > ');
|
||||||
?>
|
?>
|
||||||
|
<div id="leftPanel">
|
||||||
|
<?= $this->partial('user/left.phtml'); ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
<style>
|
<div id="rightPanel">
|
||||||
table thead tr th {background:#EBF2F6;color:#444;}
|
<div class="title">管理员列表</div>
|
||||||
.high{background:#444;color:#FFF;}
|
<div class=""><a href="/admin/user/adminlist/ac/sync">同步管理员到geonetwork</a></div>
|
||||||
</style>
|
<table>
|
||||||
<div class="row-fluid">
|
|
||||||
<div class="span3"><?= $this->partial('user/left.phtml'); ?></div>
|
|
||||||
|
|
||||||
<div class="span9">
|
|
||||||
<h3>管理员列表</h3>
|
|
||||||
<hr />
|
|
||||||
<table class="table table-bordered table-hover table-condensed"><thead>
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>用户名</th>
|
<td width='150'>用户名</td>
|
||||||
<th>电子邮箱</th>
|
<td width='250'>电子邮箱</td>
|
||||||
<th>用户类型</th>
|
<td width='100'>用户类型</td>
|
||||||
<th>真实姓名</th>
|
<td width='150'>真实姓名</td>
|
||||||
<th>电话</th>
|
<td width='150'>电话</td>
|
||||||
<th>操作</th>
|
<td width='150'>操作</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<?php if (count($this->paginator)): ?>
|
<?php if (count($this->paginator)): ?>
|
||||||
|
@ -49,4 +45,3 @@ table thead tr th {background:#EBF2F6;color:#444;}
|
||||||
</table>
|
</table>
|
||||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
|
@ -2,26 +2,42 @@
|
||||||
$this->headTitle($this->config->title->site);
|
$this->headTitle($this->config->title->site);
|
||||||
$this->headTitle('后台管理');
|
$this->headTitle('后台管理');
|
||||||
$this->headTitle()->setSeparator(' - ');
|
$this->headTitle()->setSeparator(' - ');
|
||||||
$this->headLink()->appendStylesheet('/css/admin.css');
|
|
||||||
$this->breadcrumb('<a href="/">首页</a>');
|
$this->breadcrumb('<a href="/">首页</a>');
|
||||||
$this->breadcrumb('后台管理首页');
|
$this->breadcrumb('后台管理首页');
|
||||||
$this->breadcrumb()->setSeparator(' > ');
|
$this->breadcrumb()->setSeparator(' > ');
|
||||||
?>
|
?>
|
||||||
<div id="leftPanel">
|
<div class="row-fluid">
|
||||||
|
<div class="span3">
|
||||||
<?= $this->partial('user/left.phtml'); ?>
|
<?= $this->partial('user/left.phtml'); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="rightPanel">
|
<div class="span9">
|
||||||
<div><h4>用户总数: <?php echo $this->su['total'];?>,其中管理员: <?php echo $this->suadmin['total'];?></h4></div>
|
<h3>用户总数: <?php echo $this->su['total'];?>,其中管理员: <?php echo $this->suadmin['total'];?></h3>
|
||||||
<hr />
|
<hr />
|
||||||
<div>
|
|
||||||
<h4>搜索用户</h4>
|
|
||||||
<form action="/admin/user/search/" method="get">
|
<form action="/admin/user/search/" method="get">
|
||||||
<input type="hidden" name="search" value='1' />
|
<div class="control-group">
|
||||||
<div>姓名 <input type="text" name="realname" /></div>
|
<label class="control-label" for="inputName">姓名/用户名</label>
|
||||||
<div>单位 <input type="text" name="unit" /></div>
|
<div class="controls">
|
||||||
<div>项目 <input type="text" name="project" /></div>
|
<input type="text" id="inputName" placeholder="Name or Username" name="realname" class="input-xxlarge">
|
||||||
<div><input type="submit" class="btn btn-success" value="搜索" /></div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="inputUnit">单位</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="inputUnit" placeholder="Unit" name="unit" class="input-xxlarge">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="inputProject">项目</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="inputProject" placeholder="Project" name="project" class="input-xxlarge">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<input type="hidden" name="search" value="1" />
|
||||||
|
<button type="submit" class="btn">搜索</button>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -1,7 +1,6 @@
|
||||||
<ul class="nav nav-pills nav-stacked well">
|
<ul class="nav nav-pills nav-stacked well">
|
||||||
<span class="label"><h4>用户管理</h4></span>
|
<span class="label"><h4>用户管理</h4></span>
|
||||||
<li><a href="/admin/user/">用户管理首页</a></li>
|
<li><a href="/admin/user/">用户管理首页</a></li>
|
||||||
<li><a href="/admin/user/local">本地账户</a></li>
|
|
||||||
<li><a href="/admin/user/adminlist">管理员列表</a></li>
|
<li><a href="/admin/user/adminlist">管理员列表</a></li>
|
||||||
<li><a href="/admin/user/list">查看所有账户</a></li>
|
<li><a href="/admin/user/list">查看所有账户</a></li>
|
||||||
<li><a href="/admin/user/group">用户组管理</a></li>
|
<li><a href="/admin/user/group">用户组管理</a></li>
|
||||||
|
|
|
@ -7,57 +7,54 @@
|
||||||
$this->breadcrumb('<a href="/admin/user">用户管理</a>');
|
$this->breadcrumb('<a href="/admin/user">用户管理</a>');
|
||||||
$this->breadcrumb()->setSeparator(' > ');
|
$this->breadcrumb()->setSeparator(' > ');
|
||||||
?>
|
?>
|
||||||
<style>
|
|
||||||
table thead tr th {background:#EBF2F6;color:#444;}
|
|
||||||
.high{background:#444;color:#FFF;}
|
|
||||||
</style>
|
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span3">
|
<div class="span3">
|
||||||
<div id="leftPanel"><?= $this->partial('user/left.phtml'); ?></div>
|
<?= $this->partial('user/left.phtml'); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="span9">
|
<div class="span9">
|
||||||
|
<h3>用户列表</h3>
|
||||||
|
<hr />
|
||||||
<?php if ($this->msg or $this->messages) :?>
|
<?php if ($this->msg or $this->messages) :?>
|
||||||
<div id="message">
|
<div class="alert alert-success">
|
||||||
|
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||||
<?php if ($this->msg) : ?>
|
<?php if ($this->msg) : ?>
|
||||||
<p><?php echo $this->msg; ?></p>
|
<?php echo $this->msg; ?>
|
||||||
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
|
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
|
||||||
<p><?php echo $msg; ?></p>
|
<?php echo $msg; ?>
|
||||||
<?php endforeach;endif; ?>
|
<?php endforeach;endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="search form-inline">
|
||||||
<div id="rightPanel">
|
<form action="/admin/user/search/" method="get">
|
||||||
<h3>用户列表</h3>
|
|
||||||
<hr />
|
|
||||||
<div class="search">
|
|
||||||
<form action="/admin/user/search/" method="get" class="search input-append">
|
|
||||||
<input type="hidden" name="search" value='1' />
|
<input type="hidden" name="search" value='1' />
|
||||||
<ul class="inline">
|
|
||||||
<li><label>姓名</label><input type="text" name="realname" value="<?php echo $this->realname; ?>" class="search-query"/></li>
|
<label>姓名</label><input type="text" name="realname" value="<?php echo $this->realname; ?>" />
|
||||||
<li><label>单位</label><input type="text" name="unit" value="<?php echo $this->unit; ?>" class="search-query"/></li>
|
<label>单位</label><input type="text" name="unit" value="<?php echo $this->unit; ?>" />
|
||||||
<li><label>项目</label><input type="text" name="project" value="<?php echo $this->project; ?>" class="search-query"/></li>
|
<label>项目</label><input type="text" name="project" value="<?php echo $this->project; ?>" />
|
||||||
<li><input type="submit" class="btn" value="搜索" /></li>
|
<button type="submit" value="搜索" class="btn btn-success">搜索</button>
|
||||||
</ul>
|
|
||||||
</form>
|
</form>
|
||||||
</div><!-- search DIV -->
|
</div><!-- search DIV -->
|
||||||
<table class="table table-bordered table-hover table-condensed"><thead>
|
|
||||||
|
<hr />
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>用户名</th>
|
<td width='150'>用户名</td>
|
||||||
<th>电子邮箱</th>
|
<td width='250'>电子邮箱</td>
|
||||||
<th>用户类型</th>
|
<td width='100'>用户组</td>
|
||||||
<th>单位</th>
|
<td width='200'>单位</td>
|
||||||
<th>真实姓名</th>
|
<td width='100'>真实姓名</td>
|
||||||
<th>操作</th>
|
<td width='150'>操作</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead><!-- table's head -->
|
</thead><!-- table's head -->
|
||||||
<?php if (count($this->paginator)): ?>
|
<?php if (count($this->paginator)): ?>
|
||||||
<?php $autoindex=0;?>
|
<?php $autoindex=0;?>
|
||||||
<?php foreach ($this->paginator as $item): ?>
|
<?php foreach ($this->paginator as $item): ?>
|
||||||
<?php $autoindex++;?>
|
<?php $autoindex++;?>
|
||||||
<tr>
|
<tr class="<?php if($autoindex%2 == 0) echo 'even'; else echo 'odd'; ?>">
|
||||||
<td><?= $item['username']?></td>
|
<td><?= $item['username']?></td>
|
||||||
<td><?= $item['email']; ?></td>
|
<td><?= $item['email']; ?></td>
|
||||||
<td><?= $item['usertype']; ?></td>
|
<td><?= $item['usertype']; ?></td>
|
||||||
|
@ -75,8 +72,5 @@ table thead tr th {background:#EBF2F6;color:#444;}
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</table>
|
</table>
|
||||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||||
|
</div><!-- span9 -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,29 +2,19 @@
|
||||||
$this->headTitle($this->config->title->site);
|
$this->headTitle($this->config->title->site);
|
||||||
$this->headTitle('后台管理');
|
$this->headTitle('后台管理');
|
||||||
$this->headTitle()->setSeparator(' - ');
|
$this->headTitle()->setSeparator(' - ');
|
||||||
$this->headLink()->appendStylesheet('/css/admin.css');
|
|
||||||
$this->breadcrumb('<a href="/">首页</a>');
|
$this->breadcrumb('<a href="/">首页</a>');
|
||||||
$this->breadcrumb('<a href="/admin/">后台首页</a>');
|
$this->breadcrumb('<a href="/admin/">后台首页</a>');
|
||||||
$this->breadcrumb('<a href="/admin/user">用户管理</a>');
|
$this->breadcrumb('<a href="/admin/user">用户管理</a>');
|
||||||
$this->breadcrumb()->setSeparator(' > ');
|
$this->breadcrumb()->setSeparator(' > ');
|
||||||
?>
|
?>
|
||||||
<div id="leftPanel">
|
<div class="row-fluid">
|
||||||
|
<div class="span3">
|
||||||
<?= $this->partial('user/left.phtml'); ?>
|
<?= $this->partial('user/left.phtml'); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if ($this->msg or $this->messages) :?>
|
<div class="span9">
|
||||||
<div id="message">
|
|
||||||
<?php if ($this->msg) : ?>
|
|
||||||
<p><?php echo $this->msg; ?></p>
|
|
||||||
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
|
|
||||||
<p><?php echo $msg; ?></p>
|
|
||||||
<?php endforeach;endif; ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<div id="rightPanel">
|
|
||||||
<form name="form1" method="post" action="/admin/user/edit">
|
<form name="form1" method="post" action="/admin/user/edit">
|
||||||
<table>
|
<table class="table">
|
||||||
<tr><td width="100">ID</td><td width="600"><?= $this->infos['id'];?></td></tr>
|
<tr><td width="100">ID</td><td width="600"><?= $this->infos['id'];?></td></tr>
|
||||||
<tr><td>用户名</td><td><?= $this->infos['username'];?></td></tr>
|
<tr><td>用户名</td><td><?= $this->infos['username'];?></td></tr>
|
||||||
<tr><td>真实姓名</td><td><?= $this->infos['realname'];?></td></tr>
|
<tr><td>真实姓名</td><td><?= $this->infos['realname'];?></td></tr>
|
||||||
|
@ -35,39 +25,29 @@
|
||||||
<tr><td>地址</td><td><?= $this->infos['address'];?></td></tr>
|
<tr><td>地址</td><td><?= $this->infos['address'];?></td></tr>
|
||||||
<tr><td>电话</td><td><?= $this->infos['phone'];?></td></tr>
|
<tr><td>电话</td><td><?= $this->infos['phone'];?></td></tr>
|
||||||
<tr><td>项目</td><td><?= $this->infos['project'];?></td></tr>
|
<tr><td>项目</td><td><?= $this->infos['project'];?></td></tr>
|
||||||
<tr><td>用户权限</td><td>
|
<tr><td>用户组</td><td>
|
||||||
<select name="usertype">
|
<select name="usertype">
|
||||||
<?php
|
<?php foreach($this->usertypes as $k=>$v){ ?>
|
||||||
|
<option value="<?= $v ?>" <?= $this->infos['usertype'] == $v ? 'selected="selected"':"" ?>><?= $k ?></option>
|
||||||
if ($this->infos['usertype']=='member')
|
<?php } ?>
|
||||||
|
|
||||||
{ echo "
|
|
||||||
<option value='member' selected='selected'>普通会员</option>
|
|
||||||
<option value='administrator'>系统管理员</option>
|
|
||||||
";}
|
|
||||||
|
|
||||||
else if($this->infos['usertype']=='administrator')
|
|
||||||
|
|
||||||
{ echo "<option value='administrator' selected='selected'>系统管理员</option>
|
|
||||||
<option value='member'>普通会员</option>
|
|
||||||
";}
|
|
||||||
?>
|
|
||||||
</select>
|
</select>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td>用户密码</td><td><input type='password' name="newpwd" /></td></tr>
|
<tr><td>用户密码</td><td><input type='password' name="newpwd" /></td></tr>
|
||||||
<tr><td>确认用户密码</td><td><input type='password' name="cfnewpwd" /></td></tr>
|
<tr><td>确认用户密码</td><td><input type='password' name="cfnewpwd" /></td></tr>
|
||||||
</table>
|
</table>
|
||||||
<input type='hidden' value="<?php echo $this->infos['id'];?>" name='id' />
|
<input type='hidden' value="<?php echo $this->infos['id'];?>" name='id' />
|
||||||
<input type="submit" value="提交" />
|
<input type="submit" value="提交" class="btn btn-primary" />
|
||||||
</form>
|
</form>
|
||||||
<form name="lostpwd" action="/admin/user/fetchpwd">
|
<form name="lostpwd" action="/admin/user/fetchpwd">
|
||||||
<input type="hidden" name="id" value="<?= $this->infos['id'];?>" />
|
<input type="hidden" name="id" value="<?= $this->infos['id'];?>" />
|
||||||
<input type="hidden" name="email" value="<?= $this->infos['email'];?>" />
|
<input type="hidden" name="email" value="<?= $this->infos['email'];?>" />
|
||||||
<input type="submit" value="为他执行Eamil重置密码"/>
|
<input type="submit" value="为他执行Eamil重置密码" class="btn btn-default" />
|
||||||
</form>
|
</form>
|
||||||
<form name="lostpwd" action="/admin/user/delete">
|
<form name="lostpwd" action="/admin/user/delete">
|
||||||
<input type="hidden" name="id" value="<?= $this->infos['id'];?>" />
|
<input type="hidden" name="id" value="<?= $this->infos['id'];?>" />
|
||||||
<input type="hidden" name="uname" value="<?= $this->infos['username'];?>" />
|
<input type="hidden" name="uname" value="<?= $this->infos['username'];?>" />
|
||||||
<input type="submit" value="删除该用户"/>
|
<input type="submit" value="删除该用户" class="btn btn-default" />
|
||||||
</form>
|
</form>
|
||||||
<a href="/admin/user/userauth/uid/<?= $this->infos['id'];?>">编辑权限</a>
|
<a href="/admin/user/userauth/uid/<?= $this->infos['id'];?>">编辑权限</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -251,47 +251,74 @@ class AccountController extends Zend_Controller_Action
|
||||||
|
|
||||||
function registerAction()
|
function registerAction()
|
||||||
{
|
{
|
||||||
$form = new RegisterForm();
|
$request = new \Zend_Controller_Request_Http();
|
||||||
$this->view->form = $form;
|
if($request->isXmlHttpRequest())
|
||||||
|
{
|
||||||
|
$this->_helper->layout->disableLayout();
|
||||||
|
$this->_helper->viewRenderer->setNoRender();
|
||||||
|
|
||||||
if ($this->_request->isPost()) {
|
$account = new Account();
|
||||||
$formData = $this->_request->getPost();
|
$data = $account->getParam($this->_request);
|
||||||
if ($form->isValid($formData)) {
|
|
||||||
$ut = new UsersTable();
|
|
||||||
$u = $ut->createRow();
|
|
||||||
$u->username = $form->getValue('username');
|
|
||||||
$u->password = $form->getValue('password');
|
|
||||||
$u->email=$form->getValue('email');
|
|
||||||
if ($form->getValue('realname')) $u->realname=$form->getValue('realname');
|
|
||||||
if ($form->getValue('phone')) $u->phone=$form->getValue('phone');
|
|
||||||
if ($form->getValue('address')) $u->address=$form->getValue('address');
|
|
||||||
if ($form->getValue('unit')) $u->unit=$form->getValue('unit');
|
|
||||||
if ($form->getValue('project')) $u->project=$form->getValue('project');
|
|
||||||
if ($u->save()) {
|
|
||||||
//发送欢迎邮件
|
|
||||||
$mail=new WestdcMailer($this->view->config->smtp);
|
|
||||||
$body=file_get_contents($this->view->config->register->email->template);
|
|
||||||
$body=str_replace("[username]",$formData['username'],$body);
|
|
||||||
$mail->setBodyText($body);
|
|
||||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
|
||||||
$mail->addTo($formData['email']);
|
|
||||||
//中文标题有乱码,在1.5版本中尚未解决
|
|
||||||
//ref: http://framework.zend.com/issues/browse/ZF-2532
|
|
||||||
$mail->setSubject('欢迎使用中国西部环境与生态数据中心');
|
|
||||||
$mail->send();
|
|
||||||
|
|
||||||
//自动登录系统
|
$result = $account->register($data);
|
||||||
$this->login($formData['username'],$formData['password']);
|
|
||||||
|
if(!empty($result))
|
||||||
|
{
|
||||||
|
$this->jsonexit($result);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->jsonexit(array('error'=>'|o| 服务器掉链子了,请重试'));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
//$this->_helper->layout->disableLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$success=false;
|
||||||
|
|
||||||
|
$auth = Zend_Auth::getInstance();
|
||||||
|
if ($auth->hasIdentity())
|
||||||
$this->_redirect('/');
|
$this->_redirect('/');
|
||||||
|
|
||||||
|
$submit = $this->_getParam('submit');
|
||||||
|
if(!empty($submit))
|
||||||
|
{
|
||||||
|
$account = new Account();
|
||||||
|
$this->view->data = $data = $account->getParam($this->_request);
|
||||||
|
$result = $account->register($data);
|
||||||
|
|
||||||
|
if(!empty($result))
|
||||||
|
{
|
||||||
|
if(isset($result['error']))
|
||||||
|
{
|
||||||
|
$this->view->place = $result['place'];
|
||||||
|
$this->view->error = $result['error'];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(isset($result['success']))
|
||||||
|
{
|
||||||
|
$this->_redirect('/');
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$form->populate($formData);
|
$this->view->error = "处理中出现问题";
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}//用户注册
|
||||||
|
|
||||||
function loginAction()
|
function loginAction()
|
||||||
{
|
{
|
||||||
|
$request = new \Zend_Controller_Request_Http();
|
||||||
|
if($request->isXmlHttpRequest())
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$captcha = new Captcha();
|
||||||
|
|
||||||
$success=false;
|
$success=false;
|
||||||
|
|
||||||
$options = array(
|
$options = array(
|
||||||
|
@ -303,152 +330,62 @@ class AccountController extends Zend_Controller_Action
|
||||||
$auth = Zend_Auth::getInstance();
|
$auth = Zend_Auth::getInstance();
|
||||||
if ($auth->hasIdentity())
|
if ($auth->hasIdentity())
|
||||||
{
|
{
|
||||||
view::Post($this,"您已经登录,无需重复登录",-1);
|
if($options['module']=="default" && $options['controller'] == "account" && $options['action'] == "login")
|
||||||
return true;
|
{
|
||||||
|
$this->_redirect("/");
|
||||||
|
}else{
|
||||||
|
$this->_redirect($_SERVER['REQUEST_URI']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$tohref = $this->_request->getParam('href');
|
$tohref = $this->_request->getParam('href');
|
||||||
|
|
||||||
if(($options['module']=="default" && $options['controller'] == "account" && $options['action'] == "login"))
|
if($_SERVER['REQUEST_URI'] !== "/account/login")
|
||||||
{
|
{
|
||||||
$this->view->href = $_SERVER['REQUEST_URI'];
|
$this->view->href = $_SERVER['REQUEST_URI'];
|
||||||
}
|
}else{
|
||||||
|
$this->view->href = "/";
|
||||||
if($tohref == "/account/login")
|
|
||||||
{
|
|
||||||
$this->view->href = $tohref = "/";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($tohref))
|
if(!empty($tohref))
|
||||||
{
|
{
|
||||||
$this->view->href = $tohref;
|
$this->view->href = $tohref;
|
||||||
}
|
}
|
||||||
$captcha = new Captcha();
|
|
||||||
|
|
||||||
//登录表单提交
|
$submit = $this->_getParam("submit");
|
||||||
|
|
||||||
if(!$this->_getParam('submit'))
|
if(!empty($submit))
|
||||||
{
|
{
|
||||||
$this->view->captcha = $captcha->setCaptcha();
|
$data = array(
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = "http://sanjiangyuan/account/login";
|
|
||||||
|
|
||||||
$param = array(
|
|
||||||
'username' => $this->_getParam('username'),
|
'username' => $this->_getParam('username'),
|
||||||
'password' => $this->_getParam('password'),
|
'password' => $this->_getParam('password')
|
||||||
'captchaword' => trim($this->_request->getParam('captcha'))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$captchaword = $param['captchaword'];
|
$account = new Account();
|
||||||
|
$result = $account->login($data);
|
||||||
|
|
||||||
#用户名校验
|
if(!empty($result))
|
||||||
if(strlen($param['username'])<6)
|
|
||||||
{
|
{
|
||||||
$this->view->error = '用户名不能少于6个字符';
|
if(isset($result['error']))
|
||||||
|
{
|
||||||
|
$this->view->error = $result['error'];
|
||||||
$this->view->captcha = $captcha->setCaptcha();
|
$this->view->captcha = $captcha->setCaptcha();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if(isset($result['success']))
|
||||||
if(strlen($param['username'])>20)
|
|
||||||
{
|
{
|
||||||
|
$this->_redirect($this->view->href);
|
||||||
$this->view->error = '用户名不能超过20个字符';
|
|
||||||
$this->view->captcha = $captcha->setCaptcha();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!preg_match("/^[a-zA-Z][a-zA-Z0-9_]{4,19}$/",$param['username']))
|
|
||||||
{
|
|
||||||
$this->view->error = '用户名只能包含英文字母及数字';
|
|
||||||
$this->view->captcha = $captcha->setCaptcha();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#密码校验
|
|
||||||
$match = "/[\"|'|\\\]/i";
|
|
||||||
|
|
||||||
if(preg_match($match,$param['password']) )
|
|
||||||
{
|
|
||||||
$this->view->error = '密码中包含非法字符,请重新输入';
|
|
||||||
$this->view->captcha = $captcha->setCaptcha();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(empty($param['password']))
|
|
||||||
{
|
|
||||||
$this->view->error = '请输入密码';
|
|
||||||
$this->view->captcha = $captcha->setCaptcha();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(strlen($param['password'])<6)
|
|
||||||
{
|
|
||||||
$this->view->error ='密码太短';
|
|
||||||
$this->view->captcha = $captcha->setCaptcha();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(strlen($param['password'])>20)
|
|
||||||
{
|
|
||||||
$this->view->error ="密码长度不能超过20个字符";
|
|
||||||
$this->view->captcha = $captcha->setCaptcha();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#验证码校验
|
|
||||||
|
|
||||||
if(empty($captchaword))
|
|
||||||
{
|
|
||||||
$this->view->error = "请输入验证码";
|
|
||||||
$this->view->captcha = $captcha->setCaptcha();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isset($_SESSION['captcha']))
|
|
||||||
{
|
|
||||||
$_SESSION['captcha'] = md5(time());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($captchaword != $_SESSION['captcha']) {
|
|
||||||
$this->view->captcha = $captcha->setCaptcha();
|
|
||||||
$this->view->error = "验证码错误";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$encoded_param = json_encode($param,JSON_NUMERIC_CHECK);
|
|
||||||
$encoded_param = \Helpers\MCrypt::encrypt($encoded_param,"DY7567");
|
|
||||||
|
|
||||||
$curl = new Curl();
|
|
||||||
$curl->port = 80;
|
|
||||||
$curl->initOptions(array('verifyssl'=>false));
|
|
||||||
$curl->H = array(
|
|
||||||
'X-Requested-With: XMLHttpRequest'
|
|
||||||
);
|
|
||||||
$data = $curl->request($url,array('data'=>$encoded_param),"POST");
|
|
||||||
|
|
||||||
$KEY = \Helpers\MCrypt::decrypt($data['response'],"CH6668");
|
|
||||||
$cache_data = json_decode($KEY);
|
|
||||||
if (isset($cache_data -> error))
|
|
||||||
{
|
|
||||||
$this->view->error =$cache_data -> error;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$Users = new Users();
|
|
||||||
if(!$Users -> storeNewAuthCredential($cache_data))
|
|
||||||
{
|
|
||||||
$this-> view->error ="登录失败,请重新登录。";
|
|
||||||
return;
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
view::Post($this,"登录成功!",$tohref);
|
|
||||||
}
|
|
||||||
$this->view->captcha = $captcha->setCaptcha();
|
$this->view->captcha = $captcha->setCaptcha();
|
||||||
|
$this->view->error = "处理中出现问题";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->view->captcha = $captcha->setCaptcha();
|
||||||
|
}//登陆
|
||||||
|
|
||||||
|
|
||||||
function captchaAction()
|
function captchaAction()
|
||||||
|
|
|
@ -0,0 +1,144 @@
|
||||||
|
<?php
|
||||||
|
namespace Users;
|
||||||
|
|
||||||
|
use Zend_Acl;
|
||||||
|
use Zend_Acl_Role;
|
||||||
|
use Zend_Acl_Resource;
|
||||||
|
|
||||||
|
|
||||||
|
class AclManager extends \Zend_Controller_Plugin_Abstract
|
||||||
|
{
|
||||||
|
// default user role if not logged or (or invalid role found)
|
||||||
|
private $_defaultRole = 'guest';
|
||||||
|
// the action to dispatch if a user doesn't have sufficient privileges
|
||||||
|
private $_authController = array(
|
||||||
|
'module'=>'',
|
||||||
|
'controller' => 'account',
|
||||||
|
'action' => 'login'
|
||||||
|
);
|
||||||
|
|
||||||
|
private $_adminRole;
|
||||||
|
|
||||||
|
public function __construct(\Zend_Auth $auth)
|
||||||
|
{
|
||||||
|
$config = \Zend_Registry::get('config');
|
||||||
|
$this->_adminRole = $config->auth->identifier;
|
||||||
|
|
||||||
|
$this->db=\Zend_Registry::get('db');
|
||||||
|
$this->auth = $auth;
|
||||||
|
$this->acl = new Zend_Acl();
|
||||||
|
// add the different user roles
|
||||||
|
$this->acl->addRole(new Zend_Acl_Role($this->_defaultRole));
|
||||||
|
$this->acl->addRole(new Zend_Acl_Role('member'));
|
||||||
|
$this->acl->addRole(new Zend_Acl_Role($this->_adminRole), 'member');
|
||||||
|
|
||||||
|
// add the resources we want to have control over
|
||||||
|
$this->acl->add(new Zend_Acl_Resource('account'));
|
||||||
|
$this->acl->add(new Zend_Acl_Resource('data'));
|
||||||
|
$this->acl->add(new Zend_Acl_Resource('water'));
|
||||||
|
$this->acl->add(new Zend_Acl_Resource('admin'));
|
||||||
|
$this->acl->add(new Zend_Acl_Resource('upload'));
|
||||||
|
$this->acl->add(new Zend_Acl_Resource('author'));
|
||||||
|
$this->acl->add(new Zend_Acl_Resource('heihe'));
|
||||||
|
// allow access to everything for all users by default
|
||||||
|
// except for the account management and administration areas
|
||||||
|
$this->acl->allow();
|
||||||
|
$this->acl->deny(null, 'account');
|
||||||
|
$this->acl->deny(null, 'admin');
|
||||||
|
$this->acl->deny(null, 'author');
|
||||||
|
// add an exception so guests can log in or register
|
||||||
|
// in order to gain privilege
|
||||||
|
$this->acl->allow('guest', 'account', array('login',
|
||||||
|
'logout',
|
||||||
|
'captcha',
|
||||||
|
'fetchpwd',
|
||||||
|
'register',
|
||||||
|
'registercomplete'));
|
||||||
|
$this->acl->deny('guest','data',array('download','order'));
|
||||||
|
$this->acl->deny('guest','water',array('download','order'));
|
||||||
|
$this->acl->deny('guest','heihe',array('submit'));
|
||||||
|
// allow members access to the account management area
|
||||||
|
$this->acl->allow('guest','author',array('index'));
|
||||||
|
$this->acl->allow('member', 'account');
|
||||||
|
$this->acl->allow('member', 'author');
|
||||||
|
|
||||||
|
// allows administrators access to the admin area
|
||||||
|
$this->acl->allow($this->_adminRole, 'admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* preDispatch
|
||||||
|
*
|
||||||
|
* Before an action is dispatched, check if the current user
|
||||||
|
* has sufficient privileges. If not, dispatch the default
|
||||||
|
* action instead
|
||||||
|
*
|
||||||
|
* @param Zend_Controller_Request_Abstract $request
|
||||||
|
*/
|
||||||
|
public function preDispatch(\Zend_Controller_Request_Abstract $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$phpSessId = $request->getParam('PHPSESSID');
|
||||||
|
|
||||||
|
if (!empty($phpSessId) && session_id() != $phpSessId) {
|
||||||
|
session_destroy();
|
||||||
|
session_id($phpSessId);
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
// check if a user is logged in and has a valid role,
|
||||||
|
// otherwise, assign them the default role (guest)
|
||||||
|
|
||||||
|
if(!$this->auth->hasIdentity())
|
||||||
|
{
|
||||||
|
$mb = new \member();
|
||||||
|
$mb->db=$this->db;
|
||||||
|
if($mb->checkcookie())
|
||||||
|
{
|
||||||
|
$auth = Zend_Auth::getInstance();
|
||||||
|
$authAdapter = new Zend_Auth_Adapter_DbTable($this->db);
|
||||||
|
$authAdapter->setTableName('users')
|
||||||
|
->setIdentityColumn('username')
|
||||||
|
->setCredentialColumn('password');
|
||||||
|
$authAdapter->setIdentity($mb->user)->setCredential($mb->srpwd);
|
||||||
|
$result = $auth->authenticate($authAdapter);
|
||||||
|
if ($result->isValid()) {
|
||||||
|
$data = $authAdapter->getResultRowObject(null,'password');
|
||||||
|
//头像
|
||||||
|
include_once("Avatar.php");
|
||||||
|
$avatar = new Avatar();
|
||||||
|
$data->avatar = $avatar->Get($data->email,40);
|
||||||
|
|
||||||
|
//组ID
|
||||||
|
include_once("Users.php");
|
||||||
|
$usr = new Users($this->db);
|
||||||
|
$data->gid = $usr->getGroup($data->id);
|
||||||
|
|
||||||
|
$auth->getStorage()->write($data);
|
||||||
|
$this->db->query("update users set ts_last_login=now() where username=?",array($mb->user));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->auth->hasIdentity())
|
||||||
|
$role = $this->auth->getIdentity()->usertype;
|
||||||
|
else
|
||||||
|
$role = $this->_defaultRole;
|
||||||
|
if (!$this->acl->hasRole($role))
|
||||||
|
$role = $this->_defaultRole;
|
||||||
|
// the ACL resource is the requested controller name
|
||||||
|
$resource = $request->controller;
|
||||||
|
if ($request->module<>"default") $resource=$request->module;
|
||||||
|
// the ACL privilege is the requested action name
|
||||||
|
$privilege = $request->action;
|
||||||
|
if ($request->module<>"default") $privilege = $request->controller;
|
||||||
|
// if we haven't explicitly added the resource, check
|
||||||
|
// the default global permissions
|
||||||
|
if (!$this->acl->has($resource))
|
||||||
|
$resource = null;
|
||||||
|
// access denied - reroute the request to the default action handler
|
||||||
|
if (!$this->acl->isAllowed($role, $resource, $privilege)) {
|
||||||
|
$request->setModuleName($this->_authController['module']);
|
||||||
|
$request->setControllerName($this->_authController['controller']);
|
||||||
|
$request->setActionName($this->_authController['action']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ class Local extends \Zend_Controller_Plugin_Abstract
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->config = \Zend_Registry::get('6config');
|
$this->config = \Zend_Registry::get('config');
|
||||||
|
|
||||||
|
|
||||||
$this->table = new \Helpers\Table();
|
$this->table = new \Helpers\Table();
|
||||||
|
|
|
@ -37,6 +37,37 @@ class Users extends \Zend_Controller_Plugin_Abstract
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//初始化用户类型
|
||||||
|
public function initUserType()
|
||||||
|
{
|
||||||
|
$this->usertype = array(
|
||||||
|
'普通会员' => 'member',
|
||||||
|
$this->config->auth->groupname => $this->config->auth->indentifier
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取用户类型
|
||||||
|
public function getUserType()
|
||||||
|
{
|
||||||
|
$this->initUserType();
|
||||||
|
return $this->usertype;
|
||||||
|
}
|
||||||
|
|
||||||
|
//通过ID获取User信息
|
||||||
|
public function getUser($id)
|
||||||
|
{
|
||||||
|
$sql="select * from users where id=?";
|
||||||
|
$result=$this->db->query($sql,$id);
|
||||||
|
$rows = $result->fetch();
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserInfo($id)
|
||||||
|
{
|
||||||
|
return $this->getUser($id);
|
||||||
|
}
|
||||||
|
|
||||||
//通过email地址返回用户信息是否存在
|
//通过email地址返回用户信息是否存在
|
||||||
public function userExists($email = NULL)
|
public function userExists($email = NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@ ini_set('display_errors', 1);
|
||||||
date_default_timezone_set('Asia/Shanghai');
|
date_default_timezone_set('Asia/Shanghai');
|
||||||
|
|
||||||
// directory setup and class loading
|
// directory setup and class loading
|
||||||
set_include_path('.' . PATH_SEPARATOR . '../include/'
|
set_include_path('.' . PATH_SEPARATOR . 'F:/library/zf1/library'
|
||||||
. PATH_SEPARATOR . 'D:/library/zf1'
|
. PATH_SEPARATOR . 'D:/library/zf1'
|
||||||
. PATH_SEPARATOR . '../application/models'
|
. PATH_SEPARATOR . '../application/models'
|
||||||
. PATH_SEPARATOR . '../application/module'
|
. PATH_SEPARATOR . '../application/module'
|
||||||
|
@ -40,7 +40,7 @@ $frontController->setControllerDirectory(array(
|
||||||
'default' => '../application/default/controllers',
|
'default' => '../application/default/controllers',
|
||||||
'admin' => '../application/admin/controllers'));
|
'admin' => '../application/admin/controllers'));
|
||||||
|
|
||||||
$frontController->registerPlugin(new CustomControllerAclManager($auth));
|
$frontController->registerPlugin(new \Users\AclManager($auth));
|
||||||
Zend_Layout::startMvc(array('layoutPath'=>'../application/layouts'));
|
Zend_Layout::startMvc(array('layoutPath'=>'../application/layouts'));
|
||||||
$router = new Zend_Controller_Router_Rewrite();
|
$router = new Zend_Controller_Router_Rewrite();
|
||||||
$router->addConfig($config, 'routes');
|
$router->addConfig($config, 'routes');
|
||||||
|
|
Loading…
Reference in New Issue