merge heihedata branch from r4060 to r4071
This commit is contained in:
parent
991a5abda3
commit
a4c02d8876
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
use Helpers\View as view;
|
||||
use Mail\Mail;
|
||||
|
||||
class AccountController extends Zend_Controller_Action
|
||||
{
|
||||
function preDispatch()
|
||||
|
@ -114,7 +117,6 @@ class AccountController extends Zend_Controller_Action
|
|||
{
|
||||
$this->view->pageID = "account-secure";
|
||||
|
||||
include_once("helper/view.php");
|
||||
include_once("Users.php");
|
||||
$usr = new Users($this->db);
|
||||
|
||||
|
@ -261,16 +263,17 @@ class AccountController extends Zend_Controller_Action
|
|||
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_template = "member-register";
|
||||
$mail_data = array(
|
||||
'name'=>$formData['username'],
|
||||
);
|
||||
|
||||
$mail = new Mail();
|
||||
|
||||
$mail->loadTemplate($mail_template,$mail_data);
|
||||
$mail->addTo($formData['email'],$formData['username']);
|
||||
$mail->send();
|
||||
|
||||
//自动登录系统
|
||||
|
@ -285,7 +288,6 @@ class AccountController extends Zend_Controller_Action
|
|||
|
||||
function loginAction()
|
||||
{
|
||||
include_once("helper/view.php");
|
||||
|
||||
$success=false;
|
||||
|
||||
|
@ -536,22 +538,21 @@ class AccountController extends Zend_Controller_Action
|
|||
$sql="update users set activation=? where email=?";
|
||||
$uid=uniqid();
|
||||
$db->query($sql,array($uid,$formData['email']));
|
||||
$mail=new WestdcMailer($this->view->config->smtp);
|
||||
$body="尊敬的西部数据中心用户:
|
||||
有人提出了针对此用户名的密码重置请求。
|
||||
|
||||
用户名:";
|
||||
$body.=$username;
|
||||
$body.="
|
||||
//发邮件
|
||||
$mail_template = "users-changepassword";
|
||||
$mail_data = array(
|
||||
'name'=>$username,
|
||||
'url' => view::getHostLink()."/account/fetchpwd/".$username."/".$uid
|
||||
);
|
||||
|
||||
若想重置您的密码请打开下面的链接,否则请忽略此邮件,一切如常。
|
||||
";
|
||||
$body.="http://westdc.westgis.ac.cn/account/fetchpwd/".$username."/".$uid;
|
||||
$mail->setBodyText($body);
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->addTo($formData['email']);
|
||||
$mail->setSubject('密码已重置');
|
||||
$mail = new Mail();
|
||||
|
||||
$mail->loadTemplate($mail_template,$mail_data);
|
||||
$mail->addTo($formData['email'],$username);
|
||||
$mail->send();
|
||||
|
||||
|
||||
$this->view->messages[]='请检查您的新邮件中的确认激活链接。';
|
||||
$this->view->form=false;//do not echo form
|
||||
} else
|
||||
|
@ -567,20 +568,20 @@ class AccountController extends Zend_Controller_Action
|
|||
{
|
||||
$sql="update users set salt='',activation='',password=md5('".$tmp_pwd."') where username=? and activation=?";
|
||||
$db->query($sql,array($login,$key));
|
||||
$mail=new WestdcMailer($this->view->config->smtp);
|
||||
$body="尊敬的西部数据中心用户:
|
||||
您的密码已修改。
|
||||
|
||||
用户名:";
|
||||
$body.=$login;
|
||||
$body.="密码:".$tmp_pwd;
|
||||
$body.="
|
||||
http://westdc.westgis.ac.cn/account/login";
|
||||
$mail->setBodyText($body);
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->addTo($urow->email);
|
||||
$mail->setSubject('您的新密码');
|
||||
//发邮件
|
||||
$mail_template = "users-changepassword";
|
||||
$mail_data = array(
|
||||
'name'=>$login,
|
||||
'tmp_pwd' => $tmp_pwd
|
||||
);
|
||||
|
||||
$mail = new Mail();
|
||||
|
||||
$mail->loadTemplate($mail_template,$mail_data);
|
||||
$mail->addTo($urow->email,$login);
|
||||
$mail->send();
|
||||
|
||||
$this->view->messages[]='请查收您新邮件中的新密码';
|
||||
$this->view->form=false;//do not echo form
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class KnowledgeController extends Zend_Controller_Action
|
|||
function datacenterAction()
|
||||
{
|
||||
$siteid="e31f5ea7-a4af-4ae3-9ac1-1a84132c4338";//site uuid from geonetowrk
|
||||
$sql="select * from mdref mr left join reference r on mr.refid=r.id where mr.uuid=? order by r.id desc";
|
||||
$sql="select * from mdref mr left join reference r on mr.refid=r.id where mr.uuid=? order by r.year desc, reference desc";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($siteid));
|
||||
$rows = $sth->fetchAll();
|
||||
|
@ -26,9 +26,9 @@ class KnowledgeController extends Zend_Controller_Action
|
|||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
}
|
||||
function userAction()
|
||||
function waterAction()
|
||||
{
|
||||
$sql="select * from reference where id in (select refid from mdref where reftype=1 and uuid in (select uuid from normalmetadata)) order by id desc";
|
||||
$sql="select * from reference where id in (select refid from mdref where uuid in (select uuid from en.normalmetadata)) order by year desc, reference desc";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute();
|
||||
$rows = $sth->fetchAll();
|
||||
|
@ -39,9 +39,24 @@ class KnowledgeController extends Zend_Controller_Action
|
|||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
}
|
||||
|
||||
function userAction()
|
||||
{
|
||||
$sql="select * from reference where id in (select refid from mdref where reftype=1 and uuid in (select uuid from normalmetadata)) order by year desc, reference desc";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute();
|
||||
$rows = $sth->fetchAll();
|
||||
$paginator = Zend_Paginator::factory($rows);
|
||||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||||
$paginator->setItemCountPerPage(10);
|
||||
$paginator->setView($this->view);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
}
|
||||
|
||||
function authorAction()
|
||||
{
|
||||
$sql="select * from reference where id in (select refid from mdref where reftype=0 and uuid in (select uuid from normalmetadata)) order by id desc";
|
||||
$sql="select * from reference where id in (select refid from mdref where reftype=0 and uuid in (select uuid from normalmetadata)) order by year desc, reference desc";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute();
|
||||
$rows = $sth->fetchAll();
|
||||
|
@ -66,14 +81,16 @@ class KnowledgeController extends Zend_Controller_Action
|
|||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
}
|
||||
|
||||
function searchAction()
|
||||
{
|
||||
$key=$this->_request->getParam('q');
|
||||
$author = (int)$this->_request->getParam('author');
|
||||
$place = (int)$this->_request->getParam('place');
|
||||
$source=$this->_request->getParam('searchsource');
|
||||
if(preg_match("/\"|'|<|>/",$key))
|
||||
{
|
||||
$data=array('<'=>'<','>'=>'>', "\'"=>'’', "\""=>'”');
|
||||
|
||||
$patterns = array();
|
||||
$replacements = array();
|
||||
foreach($data as $k=>$v)
|
||||
|
@ -86,10 +103,13 @@ class KnowledgeController extends Zend_Controller_Action
|
|||
$key=preg_replace($patterns, $replacements, $key);
|
||||
}
|
||||
|
||||
if (!empty($key) && $source=='datasource') {
|
||||
if (!empty($key)) {
|
||||
$search=new SimpleSearch($key);
|
||||
$where=$search->sql_expr(array("reference"));
|
||||
$sql="select * from reference where ".$where." order by id desc";
|
||||
$sql="select * from reference where ".$where." order by year desc, reference desc";
|
||||
} else if ($author && $place) {
|
||||
$sql="select * from reference where id in (select a1.id from ref_author a1,ref_author a2 where a1.firstname=a2.firstname and a1.lastname=a2.lastname and a2.id=$author and a2.place=$place)";
|
||||
}
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute();
|
||||
$rows = $sth->fetchAll();
|
||||
|
@ -102,25 +122,9 @@ class KnowledgeController extends Zend_Controller_Action
|
|||
$this->view->key=$key;
|
||||
$this->view->source=$source;
|
||||
$this->_helper->viewRenderer('search-data');
|
||||
|
||||
}
|
||||
else if (!empty($key) && $source=='westsource') {
|
||||
$search=new SimpleSearch($key);
|
||||
$where=$search->sql_expr(array("c.title","a.author"));
|
||||
$sql="select distinct a.author,c.title,c.publisher,c.ts_created,c.ts_issued,c.item_id,c.url from knl_article c left join knl_author a on c.item_id=a.item_id where c.url <>'' and a.place=1 and $where order by ts_created desc";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute();
|
||||
$rows = $sth->fetchAll();
|
||||
$paginator = Zend_Paginator::factory($rows);
|
||||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||||
$paginator->setItemCountPerPage(10);
|
||||
$paginator->setView($this->view);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
$this->view->key=$key;
|
||||
$this->view->source=$source;
|
||||
//$this->_helper->viewRenderer('search-data');
|
||||
}
|
||||
}
|
||||
|
||||
function paperAction()
|
||||
{
|
||||
$id = (int)$this->_request->getParam('id');
|
||||
|
|
|
@ -19,6 +19,7 @@ h3.gs_rt{font-size:110%;}
|
|||
#file-list li li:hover {background-color: #dedede;}
|
||||
#file-list li li li:hover {background-color: #eeeeee;}
|
||||
</style>
|
||||
<?= $this->render('breadcrumbs.phtml'); ?>
|
||||
<?php $md=$this->metadata;if ($md):?>
|
||||
<h3><?php echo $this->escape($md->title);
|
||||
if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
||||
|
@ -48,10 +49,11 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
|||
?> (下载引用:<a href="/service/ris/lang/cn/uuid/<?php echo $md->uuid; ?>">RIS格式</a> | <a href="/service/ris/lang/en/uuid/<?php echo $md->uuid; ?>">RIS英文格式</a> | <a href="/service/bibtex/lang/cn/uuid/<?php echo $md->uuid; ?>">Bibtex格式</a> | <a href="/service/bibtex/lang/en/uuid/<?php echo $md->uuid; ?>">Bibtex英文格式</a>)</p>
|
||||
<?php endif; endif; if ($this->ref) : ?>
|
||||
<hr />
|
||||
<h4><i class="icon-eye-open text-success"></i>建议参考文献</h4>
|
||||
<h4><i class="icon-eye-open text-success"></i>相关文献(作者推荐)</h4>
|
||||
<ol>
|
||||
<?php foreach($this->ref as $ref) :
|
||||
echo '<li>'.$ref->reference;
|
||||
echo '<a href="/knowledge/paper/id/'.$ref->id.'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (empty($ref->link))
|
||||
{
|
||||
if(!empty($ref->attid))
|
||||
|
@ -63,16 +65,40 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
|||
endforeach;
|
||||
?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->userref) : ?>
|
||||
<?php endif; if ($this->themeref) :?>
|
||||
|
||||
<hr />
|
||||
<h4>数据用户发表文献</h4>
|
||||
<h4><i class="icon-eye-open text-success"></i>专题文献</h4>
|
||||
<ol>
|
||||
<?php foreach($this->themeref as $ref) :
|
||||
echo '<li>'.$ref->reference;
|
||||
echo '<a href="/knowledge/paper/id/'.$ref->id.'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (empty($ref->link))
|
||||
{
|
||||
if(!empty($ref->attid))
|
||||
echo ' | <a href="/service/attach/id/'.$ref->attid.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}else{
|
||||
echo ' | <a href="'.$ref->link.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}
|
||||
echo "</li>";
|
||||
endforeach;
|
||||
?>
|
||||
</ol>
|
||||
<?php endif; if ($this->userref) : ?>
|
||||
<hr />
|
||||
<h4><i class="icon-eye-open text-success"></i>数据施引文献</h4>
|
||||
<ol>
|
||||
<?php foreach($this->userref as $ref) :
|
||||
echo '<li>'.$ref->reference;
|
||||
echo '<a href="/knowledge/paper/id/'.$ref->id.'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (empty($ref->link))
|
||||
echo '<li>'.$ref->reference.'</li>';
|
||||
else
|
||||
echo '<li>'.$ref->reference.' <a href="'.$ref->link.'"><i class="icon-download text-success"></i>下载</a></li>';
|
||||
{
|
||||
if(!empty($ref->attid))
|
||||
echo '<a href="/service/attach/id/'.$ref->attid.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}else{
|
||||
echo '<a href="'.$ref->link.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}
|
||||
echo "</li>";
|
||||
endforeach;
|
||||
?>
|
||||
</ol>
|
||||
|
|
|
@ -71,10 +71,11 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
|||
?> (下载引用:<a href="/service/ris/lang/cn/uuid/<?php echo $md->uuid; ?>">RIS格式</a> | <a href="/service/ris/lang/en/uuid/<?php echo $md->uuid; ?>">RIS英文格式</a> | <a href="/service/bibtex/lang/cn/uuid/<?php echo $md->uuid; ?>">Bibtex格式</a> | <a href="/service/bibtex/lang/en/uuid/<?php echo $md->uuid; ?>">Bibtex英文格式</a>)</p>
|
||||
<?php endif; endif; endif; if ($this->ref) : ?>
|
||||
<hr />
|
||||
<h4><i class="icon-eye-open text-success"></i>建议参考文献</h4>
|
||||
<h4><i class="icon-eye-open text-success"></i>相关文献(作者推荐)</h4>
|
||||
<ol>
|
||||
<?php foreach($this->ref as $ref) :
|
||||
echo '<li>'.$ref->reference;
|
||||
echo '<a href="/knowledge/paper/id/'.$ref->id.'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (empty($ref->link))
|
||||
{
|
||||
if(!empty($ref->attid))
|
||||
|
@ -86,16 +87,40 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
|||
endforeach;
|
||||
?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->userref) : ?>
|
||||
<?php endif; if ($this->themeref) :?>
|
||||
|
||||
<hr />
|
||||
<h4>数据用户发表文献</h4>
|
||||
<h4><i class="icon-eye-open text-success"></i>专题文献</h4>
|
||||
<ol>
|
||||
<?php foreach($this->themeref as $ref) :
|
||||
echo '<li>'.$ref->reference;
|
||||
echo '<a href="/knowledge/paper/id/'.$ref->id.'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (empty($ref->link))
|
||||
{
|
||||
if(!empty($ref->attid))
|
||||
echo ' | <a href="/service/attach/id/'.$ref->attid.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}else{
|
||||
echo ' | <a href="'.$ref->link.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}
|
||||
echo "</li>";
|
||||
endforeach;
|
||||
?>
|
||||
</ol>
|
||||
<?php endif; if ($this->userref) : ?>
|
||||
<hr />
|
||||
<h4><i class="icon-eye-open text-success"></i>数据施引文献</h4>
|
||||
<ol>
|
||||
<?php foreach($this->userref as $ref) :
|
||||
echo '<li>'.$ref->reference;
|
||||
echo '<a href="/knowledge/paper/id/'.$ref->id.'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (empty($ref->link))
|
||||
echo '<li>'.$ref->reference.'</li>';
|
||||
else
|
||||
echo '<li>'.$ref->reference.' <a href="'.$ref->link.'"><i class="icon-download text-success"></i>下载</a></li>';
|
||||
{
|
||||
if(!empty($ref->attid))
|
||||
echo '<a href="/service/attach/id/'.$ref->attid.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}else{
|
||||
echo '<a href="'.$ref->link.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}
|
||||
echo "</li>";
|
||||
endforeach;
|
||||
?>
|
||||
</ol>
|
||||
|
|
|
@ -69,10 +69,11 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
|||
?> (下载引用:<a href="/service/ris/lang/cn/uuid/<?php echo $md->uuid; ?>">RIS格式</a> | <a href="/service/ris/lang/en/uuid/<?php echo $md->uuid; ?>">RIS英文格式</a> | <a href="/service/bibtex/lang/cn/uuid/<?php echo $md->uuid; ?>">Bibtex格式</a> | <a href="/service/bibtex/lang/en/uuid/<?php echo $md->uuid; ?>">Bibtex英文格式</a>)</p>
|
||||
<?php endif; endif; endif; if ($this->ref) : ?>
|
||||
<hr />
|
||||
<h4><i class="icon-eye-open text-success"></i>建议参考文献</h4>
|
||||
<h4><i class="icon-eye-open text-success"></i>相关文献(作者推荐)</h4>
|
||||
<ol>
|
||||
<?php foreach($this->ref as $ref) :
|
||||
echo '<li>'.$ref->reference;
|
||||
echo '<a href="/knowledge/paper/id/'.$ref->id.'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (empty($ref->link))
|
||||
{
|
||||
if(!empty($ref->attid))
|
||||
|
@ -84,16 +85,40 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
|||
endforeach;
|
||||
?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->userref) : ?>
|
||||
<?php endif; if ($this->themeref) :?>
|
||||
|
||||
<hr />
|
||||
<h4>数据用户发表文献</h4>
|
||||
<h4><i class="icon-eye-open text-success"></i>专题文献</h4>
|
||||
<ol>
|
||||
<?php foreach($this->themeref as $ref) :
|
||||
echo '<li>'.$ref->reference;
|
||||
echo '<a href="/knowledge/paper/id/'.$ref->id.'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (empty($ref->link))
|
||||
{
|
||||
if(!empty($ref->attid))
|
||||
echo ' | <a href="/service/attach/id/'.$ref->attid.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}else{
|
||||
echo ' | <a href="'.$ref->link.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}
|
||||
echo "</li>";
|
||||
endforeach;
|
||||
?>
|
||||
</ol>
|
||||
<?php endif; if ($this->userref) : ?>
|
||||
<hr />
|
||||
<h4><i class="icon-eye-open text-success"></i>数据施引文献</h4>
|
||||
<ol>
|
||||
<?php foreach($this->userref as $ref) :
|
||||
echo '<li>'.$ref->reference;
|
||||
echo '<a href="/knowledge/paper/id/'.$ref->id.'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (empty($ref->link))
|
||||
echo '<li>'.$ref->reference.'</li>';
|
||||
else
|
||||
echo '<li>'.$ref->reference.' <a href="'.$ref->link.'"><i class="icon-download text-success"></i>下载</a></li>';
|
||||
{
|
||||
if(!empty($ref->attid))
|
||||
echo '<a href="/service/attach/id/'.$ref->attid.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}else{
|
||||
echo '<a href="'.$ref->link.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}
|
||||
echo "</li>";
|
||||
endforeach;
|
||||
?>
|
||||
</ol>
|
||||
|
|
|
@ -5,7 +5,7 @@ $this->headTitle()->setSeparator(' - ');
|
|||
$this->headLink()->appendStylesheet('/css/mdreview.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/knowledge">知识积累</a>');
|
||||
$this->breadcrumb('数据作者');
|
||||
$this->breadcrumb('作者推荐文献库');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
||||
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
||||
|
@ -16,20 +16,23 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
|
|||
</div>
|
||||
<div class="span9">
|
||||
<div id="content">
|
||||
<h2>数据作者文献库</h2>
|
||||
<h2>作者推荐文献库</h2>
|
||||
<div>
|
||||
<?php if (count($this->paginator)): ?>
|
||||
<ul>
|
||||
<ol start="<?php echo ($this->paginator->getCurrentPageNumber() - 1) * $this->paginator->getItemCountPerPage()+1; ?>">
|
||||
<?php foreach ($this->paginator as $item): ?>
|
||||
<li> <?php echo $item['reference']; ?>
|
||||
<?php if (!empty($item['link'])) :
|
||||
<li> <?php echo $item['reference'];
|
||||
echo ' <a href="/knowledge/paper/id/'.$item['id'].'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (!empty($item['link'])) :
|
||||
echo ' <a href="'.$item['link'].'">下载</a>';
|
||||
else :
|
||||
if (!empty($item['attid'])) echo ' <a href="/service/attach/id/'.$item['attid'].'"><i class="icon-download text-success"></i>下载</a>';
|
||||
endif;
|
||||
?>
|
||||
<a class="btn btn-mini btn-info" href="javascript:;" onclick="showdata('<?php echo $item['id'];?>',0)">相关数据</a>
|
||||
<a href="javascript:;" onclick="showdata('<?php echo $item['id'];?>',0)"><i class="icon-external-link text-success"></i>相关数据</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</ol>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -17,16 +17,19 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
<h2>数据中心文献库</h2>
|
||||
<div>
|
||||
<?php if (count($this->paginator)): ?>
|
||||
<ul>
|
||||
<ol start="<?php echo ($this->paginator->getCurrentPageNumber() - 1) * $this->paginator->getItemCountPerPage()+1; ?>">
|
||||
<?php foreach ($this->paginator as $item): ?>
|
||||
<li> <?php echo $item['reference']; ?>
|
||||
<?php if (!empty($item['link'])) :
|
||||
<li> <?php echo $item['reference'];
|
||||
echo ' <a href="/knowledge/paper/id/'.$item['id'].'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (!empty($item['link'])) :
|
||||
echo ' <a href="'.$item['link'].'">下载</a>';
|
||||
else :
|
||||
if (!empty($item['attid'])) echo ' <a href="/service/attach/id/'.$item['attid'].'"><i class="icon-download text-success"></i>下载</a>';
|
||||
endif;
|
||||
?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</ol>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -10,16 +10,6 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
<div class="row">
|
||||
<div class="span3">
|
||||
<?= $this->partial('knowledge/navi.phtml'); ?>
|
||||
<div class="sidebar-nav bs-review-nav">
|
||||
<ul class="nav nav-list bs-review-sidenav">
|
||||
<li> <a href="http://seekspace.resip.ac.cn/handle/2239/1" target="_blank"><i class="icon-share"></i>西部计划资源</a> </li>
|
||||
<li> <a href="http://seekspace.resip.ac.cn/handle/2239/2" target="_blank"><i class="icon-share"></i>环境与生态科学期刊资源 </a> </li>
|
||||
<li> <a href="http://seekspace.resip.ac.cn/handle/2239/12" target="_blank"><i class="icon-share"></i>环境与生态科学信息网关 </a> </li>
|
||||
<li> <a href="http://seekspace.resip.ac.cn/handle/2239/13" target="_blank"><i class="icon-share"></i>环境与生态科学开放知识资源 </a> </li>
|
||||
<li> <a href="http://seekspace.resip.ac.cn/handle/2239/2460" target="_blank"><i class="icon-share"></i>西部环境与生态科学文献库 </a> </li>
|
||||
<li> <a href="http://seekspace.resip.ac.cn/handle/2239/23662" target="_blank"><i class="icon-share"></i>黑河流域研究 </a> </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span9">
|
||||
<div id="myCarousel" class="carousel slide">
|
||||
|
@ -27,10 +17,32 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
|
||||
<li data-target="#myCarousel" data-slide-to="1"></li>
|
||||
<li data-target="#myCarousel" data-slide-to="2"></li>
|
||||
<li data-target="#myCarousel" data-slide-to="3"></li>
|
||||
</ol>
|
||||
<!-- Carousel items -->
|
||||
<div class="carousel-inner">
|
||||
<div class="active item hero-unit"><h2>西部计划文献库</h2>
|
||||
<div class="active item hero-unit">
|
||||
<h2>数据施引文献库</h2>
|
||||
<p>数据施引文献库是数据用户在使用科学数据后公开发表在科技期刊上的文献,由用户自发通知数据中心、数据作者收集和数据中心集中手机三种方式进行收集整理。</p>
|
||||
<p>从数据用户的文献库中,可以挖掘出更多的知识,了解用户是如何使用数据中心提供的科学数据。数据作者也可以从其中获取到数据相关的趋势性知识。
|
||||
数据中心也欢迎用户提供更多的公开发表成果,我们将持续更新其内容,以满足数据的深层挖掘,实现学术信息进行搜索、发现、聚集和再组织。</p>
|
||||
<p><a class="btn btn-primary" href="/knowledge/user">查看 »</a></p>
|
||||
</div>
|
||||
<div class="item hero-unit">
|
||||
<h2>作者推荐文献库</h2>
|
||||
<p>作者推荐文献库是对发布在数据中心的科学数据的作者所推荐的和其数据相关的科技文献,主要是由数据作者发表的、和其数据紧密相关的科学文献。</p>
|
||||
<p>用户可以通过数据作者的文献库中挖掘出对应的数据信息,实现从文献到数据的一个知识挖掘。将数据中心所有的数据作者文献构建一个和数据紧密相关的知识库,可以供用户更好的了解和发现数据和知识。
|
||||
支持用户对数据作者的学术信息进行搜索、发现、聚集和再组织。</p>
|
||||
<p><a class="btn btn-primary" href="/knowledge/author">查看 »</a></p>
|
||||
</div>
|
||||
<div class="item hero-unit">
|
||||
<h2>WATER文献库</h2>
|
||||
<p>WATER文献库是对由WATER项目所相关的科技文献,包括WATER项目自身发表的文献以及WATER数据用户所发表的文献。</p>
|
||||
<p>用户可以通过WATER文献库中挖掘出对应的数据信息,实现从文献到数据的一个知识挖掘。将数据中心所有的数据作者文献构建一个和数据紧密相关的知识库,可以供用户更好的了解和发现数据和知识。
|
||||
支持用户对数据作者的学术信息进行搜索、发现、聚集和再组织。</p>
|
||||
<p><a class="btn btn-primary" href="/knowledge/water">查看 »</a></p>
|
||||
</div>
|
||||
<div class="item hero-unit"><h2>西部计划文献库</h2>
|
||||
<div class="span3"><a href="http://seekspace.resip.ac.cn" target="_blank"> <img alt="中国(西部)环境与生态科学知识积累平台" src="/images/ssimg.jpg" /></a></div>
|
||||
<p>旨在发展和形成一个支持环境与生态科学领域开放学术信息的自助存档、交流和发现的领域知识平台。
|
||||
首先,实现对国家自然科学基金委组织实施的“中国西部环境与生态科学研究计划”历年来所支持的研究项目和课题所产生的有重要科研和学术价值的知识产出进行统一组织和管理,
|
||||
|
@ -38,20 +50,6 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
特别是对有重要学术影响的研究性数字知识库所涉及的环境与生态科学领域的学术信息进行搜索、发现、聚集和再组织。</p>
|
||||
<p><a class="btn btn-primary" href="/knowledge/westplan">查看 »</a> <a class="btn btn-info" href="http://seekspace.resip.ac.cn">访问seekspace »</a></p>
|
||||
</div>
|
||||
<div class="item hero-unit">
|
||||
<h2>数据作者文献库</h2>
|
||||
<p>数据作者文献库是对发布在数据中心的科学数据中相关的参考文献,主要是由数据作者发表的、和其数据紧密相关的科学文献。</p>
|
||||
<p>用户可以通过数据作者的文献库中挖掘出对应的数据信息,实现从文献到数据的一个知识挖掘。将数据中心所有的数据作者文献构建一个和数据紧密相关的知识库,可以供用户更好的了解和发现数据和知识。
|
||||
支持用户对数据作者的学术信息进行搜索、发现、聚集和再组织。</p>
|
||||
<p><a class="btn btn-primary" href="/knowledge/author">查看 »</a></p>
|
||||
</div>
|
||||
<div class="item hero-unit">
|
||||
<h2>数据用户文献库</h2>
|
||||
<p>数据用户文献库是数据用户在使用科学数据后公开发表在科技期刊上的文献,由用户自发通知数据中心、数据作者收集和数据中心集中手机三种方式进行收集整理。</p>
|
||||
<p>从数据用户的文献库中,可以挖掘出更多的知识,了解用户是如何使用数据中心提供的科学数据。数据作者也可以从其中获取到数据相关的趋势性知识。
|
||||
数据中心也欢迎用户提供更多的公开发表成果,我们将持续更新其内容,以满足数据的深层挖掘,实现学术信息进行搜索、发现、聚集和再组织。</p>
|
||||
<p><a class="btn btn-primary" href="/knowledge/user">查看 »</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Carousel nav -->
|
||||
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
|
||||
|
|
|
@ -1,25 +1,16 @@
|
|||
<div class="sidebar-nav bs-review-nav">
|
||||
<ul class="nav nav-list bs-review-sidenav">
|
||||
<li id="Nav-knowledge-index"><a href="/knowledge/"><i class="icon-chevron-right"></i>介绍</a></li>
|
||||
<li id="Nav-knowledge-westplan"><a href="/knowledge/westplan"><i class="icon-chevron-right"></i>西部计划文献库</a></li>
|
||||
<li id="Nav-knowledge-author"><a href="/knowledge/author"><i class="icon-chevron-right"></i>数据作者文献库</a></li>
|
||||
<li id="Nav-knowledge-user"><a href="/knowledge/user"><i class="icon-chevron-right"></i>数据用户文献库</a></li>
|
||||
<li id="Nav-knowledge-user"><a href="/knowledge/user"><i class="icon-chevron-right"></i>数据施引文献库</a></li>
|
||||
<li id="Nav-knowledge-author"><a href="/knowledge/author"><i class="icon-chevron-right"></i>作者推荐文献库</a></li>
|
||||
<li id="Nav-knowledge-water"><a href="/knowledge/water"><i class="icon-chevron-right"></i>WATER文献库</a></li>
|
||||
<li id="Nav-knowledge-datacenter"><a href="/knowledge/datacenter"><i class="icon-chevron-right"></i>数据中心文献库</a></li>
|
||||
<li id="Nav-knowledge-westplan"><a href="/knowledge/westplan"><i class="icon-chevron-right"></i>西部计划文献库</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<form class="form-search" id="search" enctype="application/x-www-form-urlencoded" action="/knowledge/search" method="get">
|
||||
<div class="input-append">
|
||||
<input class="span2" id="q" name="q" type="text" value="<?php echo (empty($this->key))?'':$this->key; ?>" placeholder="搜索作者和标题">
|
||||
<button type="submit" class="btn">搜索</button>
|
||||
<div class="form-actions">
|
||||
<label class="radio">
|
||||
<input type="radio" name="searchsource" id="datasource" value="datasource" <?php echo ($this->source=='datasource')?'checked':''; ?>>
|
||||
数据文献库
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="searchsource" id="westsource" value="westsource" <?php echo ($this->source=='datasource')?'':'checked'; ?>>
|
||||
西部计划文献库
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -24,7 +24,7 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
|
|||
<h4>作者</h4>
|
||||
<ul>
|
||||
<?php foreach($this->author as $a) : ?>
|
||||
<li><?php echo $a['lastname'];if (!empty($a['firstname'])) echo ', '.$a['firstname']; ?></li>
|
||||
<li><?php echo $a['lastname'];if (!empty($a['firstname'])) echo ', '.$a['firstname']; ?> 【<a href="/knowledge/search/author/<?php echo $a['id']; ?>/place/<?php echo $a['place']; ?>">所有文章</a>】</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<hr />
|
||||
|
@ -71,7 +71,7 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
|
|||
echo ' <a href="'.$item['link'].'">下载</a>';
|
||||
endif;
|
||||
?>
|
||||
<a class="btn btn-mini btn-info" href="javascript:;" onclick="showdata('<?php echo $this->paper['id'];?>',0)">相关数据(共<span id="referenceDataCount">?</span>条)</a>
|
||||
<a href="javascript:;" onclick="showdata('<?php echo $this->paper['id'];?>',0)"><i class="icon-external-link text-success"></i>相关数据(共<span id="referenceDataCount">?</span>条)</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -79,7 +79,7 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
|
|||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" >
|
||||
$('#Nav-knowledge-author').addClass('active');
|
||||
$('#Nav-knowledge-user').addClass('active');
|
||||
</script>
|
||||
<script>
|
||||
function showdata(id,page){
|
||||
|
|
|
@ -19,17 +19,20 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
|
|||
<h2>数据文献搜索</h2>
|
||||
<div>
|
||||
<?php if (count($this->paginator)): ?>
|
||||
<ul>
|
||||
<ol start="<?php echo ($this->paginator->getCurrentPageNumber() - 1) * $this->paginator->getItemCountPerPage()+1; ?>">
|
||||
<?php foreach ($this->paginator as $item): ?>
|
||||
<li> <?php echo $item['reference']; ?>
|
||||
<?php if (!empty($item['link'])) :
|
||||
echo ' <a class="btn btn-mini btn-inverse" href="'.$item['link'].'">下载</a>';
|
||||
<li> <?php echo $item['reference'];
|
||||
echo ' <a href="/knowledge/paper/id/'.$item['id'].'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (!empty($item['link'])) :
|
||||
echo ' <a href="'.$item['link'].'">下载</a>';
|
||||
else :
|
||||
if (!empty($item['attid'])) echo ' <a href="/service/attach/id/'.$item['attid'].'"><i class="icon-download text-success"></i>下载</a>';
|
||||
endif;
|
||||
?>
|
||||
<a class="btn btn-mini btn-info" href="javascript:;" onclick="showdata('<?php echo $item['id'];?>',0)">相关数据</a>
|
||||
<a href="javascript:;" onclick="showdata('<?php echo $item['id'];?>',0)"><i class="icon-external-link text-success"></i>相关数据</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</ol>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -5,7 +5,7 @@ $this->headTitle()->setSeparator(' - ');
|
|||
$this->headLink()->appendStylesheet('/css/mdreview.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/knowledge">知识积累</a>');
|
||||
$this->breadcrumb('数据用户');
|
||||
$this->breadcrumb('数据施引文献库');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
||||
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
||||
|
@ -16,20 +16,23 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
|
|||
</div>
|
||||
<div class="span9">
|
||||
<div id="content">
|
||||
<h2>数据用户文献库</h2>
|
||||
<h2>数据施引文献库</h2>
|
||||
<div>
|
||||
<?php if (count($this->paginator)): ?>
|
||||
<ul>
|
||||
<ol start="<?php echo ($this->paginator->getCurrentPageNumber() - 1) * $this->paginator->getItemCountPerPage()+1; ?>">
|
||||
<?php foreach ($this->paginator as $item): ?>
|
||||
<li> <?php echo $item['reference']; ?>
|
||||
<?php if (!empty($item['link'])) :
|
||||
<li> <?php echo $item['reference'];
|
||||
echo ' <a href="/knowledge/paper/id/'.$item['id'].'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (!empty($item['link'])) :
|
||||
echo ' <a href="'.$item['link'].'">下载</a>';
|
||||
else :
|
||||
if (!empty($item['attid'])) echo ' <a href="/service/attach/id/'.$item['attid'].'"><i class="icon-download text-success"></i>下载</a>';
|
||||
endif;
|
||||
?>
|
||||
<a class="btn btn-mini btn-info" href="javascript:;" onclick="showdata('<?php echo $item['id'];?>',0)">相关数据</a>
|
||||
<a href="javascript:;" onclick="showdata('<?php echo $item['id'];?>',0)"><i class="icon-external-link text-success"></i>相关数据</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</ol>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle('知识积累');
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headLink()->appendStylesheet('/css/mdreview.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/knowledge">知识积累</a>');
|
||||
$this->breadcrumb('WATER文献库');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
||||
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="span3">
|
||||
<?= $this->partial('knowledge/navi.phtml'); ?>
|
||||
</div>
|
||||
<div class="span9">
|
||||
<div id="content">
|
||||
<h2>WATER文献库</h2>
|
||||
<div>
|
||||
<?php if (count($this->paginator)): ?>
|
||||
<ol start="<?php echo ($this->paginator->getCurrentPageNumber() - 1) * $this->paginator->getItemCountPerPage()+1; ?>">
|
||||
<?php foreach ($this->paginator as $item): ?>
|
||||
<li> <?php echo $item['reference'];
|
||||
echo ' <a href="/knowledge/paper/id/'.$item['id'].'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (!empty($item['link'])) :
|
||||
echo ' <a href="'.$item['link'].'">下载</a>';
|
||||
else :
|
||||
if (!empty($item['attid'])) echo ' <a href="/service/attach/id/'.$item['attid'].'"><i class="icon-download text-success"></i>下载</a>';
|
||||
endif;
|
||||
?>
|
||||
<a href="javascript:;" onclick="showdata('<?php echo $item['id'];?>',0)"><i class="icon-external-link text-success"></i>相关数据</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" >
|
||||
$('#Nav-knowledge-water').addClass('active');
|
||||
</script>
|
||||
<script>
|
||||
function showdata(id,page){
|
||||
var url="/service/refdatalist/id/"+id;
|
||||
$.ajax({
|
||||
'type':"GET",
|
||||
'url':url,
|
||||
'data':'page='+page,
|
||||
'dataType':'html',
|
||||
'success':function(html){$.colorbox({'html':html,'innerHeight':230});}
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,332 @@
|
|||
<?php
|
||||
namespace Users;
|
||||
|
||||
use helpers\View as view;
|
||||
use helpers\dbh as dbh;
|
||||
use Users\Member;
|
||||
use Mail\Mail;
|
||||
|
||||
class Account extends \Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
public $memberTable = "users";
|
||||
public $FieldUsername = "username";
|
||||
public $FieldPasword = "password";
|
||||
public $FieldLastlogin = "ts_last_login";
|
||||
public $FieldEmail = "email";
|
||||
public $FieldLastloginIp = "last_login_ip";
|
||||
public $GravatarEmailField = "gravatar_email";
|
||||
|
||||
public $RoleMember = "member";
|
||||
|
||||
private $db;
|
||||
protected $events = NULL; //事件
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
if(empty($db))
|
||||
{
|
||||
$this->db = \Zend_Registry::get('db');
|
||||
}else{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
$this->config = \Zend_Registry::get('config');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function events(\Zend_EventManager_EventCollection $events = NULL)
|
||||
{
|
||||
if ($events !== NULL) {
|
||||
$this->events = $events;
|
||||
} elseif ($this->events === NULL) {
|
||||
$this->events = new \Zend_EventManager_EventManager(__CLASS__);
|
||||
}
|
||||
return $this->events;
|
||||
}
|
||||
|
||||
//获取账号信息,数组
|
||||
public function getAccountInfo($id = 0)
|
||||
{
|
||||
if($id == 0)
|
||||
{
|
||||
$id = view::User('id');
|
||||
}
|
||||
$sql = "SELECT * FROM {$this->memberTable} WHERE id=$id";
|
||||
$rs = $this->db->query($sql);
|
||||
return $rs->fetch();
|
||||
}
|
||||
|
||||
//注册
|
||||
public function register($data)
|
||||
{
|
||||
|
||||
$params = compact('data');
|
||||
$results = $this->events()->trigger('register.checkParam', $this, $params);
|
||||
$cache_data = $results->bottom();
|
||||
|
||||
if($cache_data !== true)
|
||||
{
|
||||
if(!is_array($cache_data))
|
||||
{
|
||||
return array('error'=>$cache_data);
|
||||
}else{
|
||||
return $cache_data;
|
||||
}
|
||||
}
|
||||
|
||||
$results = $this->events()->trigger('register.checkUser', $this, $params);
|
||||
$cache_data = $results->bottom();
|
||||
|
||||
if($cache_data !== true)
|
||||
{
|
||||
if(!is_array($cache_data))
|
||||
{
|
||||
return array('error'=>$cache_data);
|
||||
}else{
|
||||
return $cache_data;
|
||||
}
|
||||
}
|
||||
|
||||
$loginData = array(
|
||||
'username'=>$data['username'],
|
||||
'password'=>$data['password']
|
||||
);
|
||||
|
||||
$data['password'] = md5($data['password']);
|
||||
$data['usertype'] = "member";
|
||||
unset($data['confirm_password']);
|
||||
|
||||
$dbh = new dbh();
|
||||
|
||||
$id = $dbh->insert($this->memberTable,$data,true);
|
||||
|
||||
if(!empty($id) && is_numeric($id))
|
||||
{
|
||||
$this->storeLogin($loginData);
|
||||
$mb = new Member();
|
||||
$mb->putcookie($data[$this->FieldUsername],$data[$this->FieldPasword]); //username, md5(password)
|
||||
$params = compact('data','id');
|
||||
$results = $this->events()->trigger('register.success', $this, $params);
|
||||
return array("success" => 1);
|
||||
}else{
|
||||
if($id === false)
|
||||
{
|
||||
return array('error'=>'服务器开小差了,请稍后再试');
|
||||
}else{
|
||||
return array('error'=>'服务器处理中遇到错误,请联系管理员');
|
||||
}
|
||||
}
|
||||
|
||||
}//register
|
||||
|
||||
//登陆
|
||||
public function login($data)
|
||||
{
|
||||
$results = $this->events()->trigger('login.checkParam', $this, compact('data'));
|
||||
$cache_data = $results->bottom();
|
||||
|
||||
if($cache_data !== true)
|
||||
{
|
||||
if(!is_array($cache_data))
|
||||
{
|
||||
return array('error'=>$cache_data);
|
||||
}else{
|
||||
return $cache_data;
|
||||
}
|
||||
}
|
||||
|
||||
$state = $this->storeLogin($data);
|
||||
|
||||
$mb = new Member();
|
||||
$mb->putcookie($data[$this->FieldUsername],md5($data[$this->FieldPasword]));
|
||||
|
||||
return $state;
|
||||
}//login
|
||||
|
||||
//storeLogin
|
||||
public function storeLogin($data)
|
||||
{
|
||||
$auth = \Zend_Auth::getInstance();
|
||||
$authAdapter = new \Zend_Auth_Adapter_DbTable($this->db);
|
||||
$authAdapter->setTableName($this->memberTable)
|
||||
->setIdentityColumn($this->FieldUsername)
|
||||
->setCredentialColumn($this->FieldPasword);
|
||||
$authAdapter->setIdentity($data[$this->FieldUsername])->setCredential(md5($data[$this->FieldPasword]));
|
||||
$result = $auth->authenticate($authAdapter);
|
||||
if ($result->isValid()) {
|
||||
|
||||
$user = $authAdapter->getResultRowObject(null,$this->FieldPasword);
|
||||
$email = $user->email;
|
||||
$results = $this->events()->trigger('login.success.createAvatar', $this, compact('email'));
|
||||
$user->avatar = $results->bottom();
|
||||
$auth->getStorage()->write($user);
|
||||
|
||||
$id = $user->id;
|
||||
@$results = $this->events()->trigger('login.success.updateStatus', $this, compact('id'));
|
||||
|
||||
return array('success'=>1);
|
||||
}
|
||||
return array('error'=>'处理中发现错误,请重试');
|
||||
}
|
||||
|
||||
//注册信息参数
|
||||
public function getParam(\Zend_Controller_Request_Abstract $request)
|
||||
{
|
||||
$data = array(
|
||||
'username'=>$request->getParam('username'),
|
||||
'password'=>$request->getParam('password'),
|
||||
'confirm_password'=>$request->getParam('confirm_password'),
|
||||
'email'=>$request->getParam('email'),
|
||||
'realname'=>$request->getParam('realname')
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
|
||||
//获取用户账户修改参数
|
||||
public function getEditParam(\Zend_Controller_Request_Abstract $request)
|
||||
{
|
||||
$type = $request->getParam('type');
|
||||
|
||||
if($type == "general")
|
||||
{
|
||||
$data = array(
|
||||
'realname'=>$request->getParam('realname'),
|
||||
'signature'=>$request->getParam('signature'),
|
||||
'description'=>$request->getParam('description')
|
||||
);
|
||||
}
|
||||
|
||||
if($type == "password")
|
||||
{
|
||||
$data = array(
|
||||
'password' => $request->getParam('password'),
|
||||
'password_new'=>$request->getParam('password_new'),
|
||||
'password_confirm'=>$request->getParam('password_confirm')
|
||||
);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
//编辑
|
||||
public function edit($data,$type)
|
||||
{
|
||||
$results = $this->events()->trigger('edit.checkParam', $this, compact('data','type'));
|
||||
$cache_data = $results->bottom();
|
||||
|
||||
if($cache_data !== true)
|
||||
{
|
||||
return $cache_data;
|
||||
}
|
||||
|
||||
if($type == "general")
|
||||
{
|
||||
$data['signature'] = htmlspecialchars($data['signature']);
|
||||
$data['description'] = htmlspecialchars($data['description']);
|
||||
}else if($type == "password")
|
||||
{
|
||||
$data['password'] = md5($data['password_new']);
|
||||
unset($data['password_new']);
|
||||
unset($data['password_confirm']);
|
||||
}else{
|
||||
return "参数错误";
|
||||
}
|
||||
|
||||
$dbh = new dbh();
|
||||
$uid = view::User('id');
|
||||
if($dbh->update($this->memberTable,$data," id=$uid") === true)
|
||||
{
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//找回密码
|
||||
public function getMyPassword($email)
|
||||
{
|
||||
$results = $this->events()->trigger('pwd.forgot.checkParam', $this, compact('email'));
|
||||
$cache_data = $results->bottom();
|
||||
|
||||
if($cache_data !== true)
|
||||
{
|
||||
return $cache_data;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM {$this->memberTable} WHERE email='$email'";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
|
||||
if(!isset($row['username']) || empty($row['username']))
|
||||
{
|
||||
return array('error'=>"此邮箱并未注册",'place'=>'email');
|
||||
}
|
||||
|
||||
$salt = md5($email.'---'.$row['username']);
|
||||
|
||||
$sql = "UPDATE {$this->memberTable} SET salt='$salt' WHERE id={$row['id']}";
|
||||
$state = $this->db->exec($sql);
|
||||
|
||||
if($state<1)
|
||||
{
|
||||
return array('error'=>"处理中出现错误,请重试",'place'=>'email');
|
||||
}
|
||||
|
||||
$mail_template = "forgotpassword";
|
||||
$mail_data = array(
|
||||
'name'=>$row['realname'],
|
||||
'link'=> view::getHostLink().'/account/getpassword/salt/'.$salt
|
||||
);
|
||||
|
||||
$mail = new Mail();
|
||||
|
||||
$mail->loadTemplate($mail_template,$mail_data);
|
||||
$mail->addTo($email,$row['realname']);
|
||||
$mail->send();
|
||||
|
||||
return array("success"=>1);
|
||||
}
|
||||
|
||||
//重置密码
|
||||
public function resetPassword($data)
|
||||
{
|
||||
$results = $this->events()->trigger('pwd.reset.checkParam', $this, compact('data'));
|
||||
$cache_data = $results->bottom();
|
||||
|
||||
if($cache_data !== true)
|
||||
{
|
||||
return $cache_data;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM {$this->memberTable} WHERE salt=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($data['salt']));
|
||||
$row = $sth->fetch();
|
||||
|
||||
if(!isset($row['username']) || empty($row['username']))
|
||||
{
|
||||
return array('error'=>"您提供的校验码不正确,请重新申请重置密码",'place'=>'confirm_password');
|
||||
}
|
||||
|
||||
if($row['username'] !== $data['username'])
|
||||
{
|
||||
return array('error'=>"您提供的校验码不正确,请重新申请重置密码",'place'=>'confirm_password');
|
||||
}
|
||||
|
||||
$sql = "UPDATE {$this->memberTable} SET password='".md5($data['password'])."',salt='' WHERE id={$row['id']}";
|
||||
$this->db->exec($sql);
|
||||
|
||||
$mail_template = "getpassworded";
|
||||
$mail_data = array(
|
||||
'name'=>$row['realname'],
|
||||
);
|
||||
$mail = new Mail();
|
||||
$mail->loadTemplate($mail_template,$mail_data);
|
||||
$mail->addTo($row['email'],$row['realname']);
|
||||
$mail->send();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Users\Event;
|
||||
|
||||
interface EditEvent
|
||||
{
|
||||
|
||||
public function checkParam(\Zend_EventManager_Event $e);
|
||||
|
||||
public function editSuccess(\Zend_EventManager_Event $e);
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
namespace Users\Event;
|
||||
|
||||
interface LoginEvent
|
||||
{
|
||||
|
||||
public function checkParam(\Zend_EventManager_Event $e);
|
||||
|
||||
public function updateStatus(\Zend_EventManager_Event $e);
|
||||
|
||||
public function createAvatar(\Zend_EventManager_Event $e);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
namespace Users\Event;
|
||||
|
||||
interface PwdEvent
|
||||
{
|
||||
|
||||
public function forgotPwdCheckParam(\Zend_EventManager_Event $e);
|
||||
|
||||
public function sendGetPasswordMail(\Zend_EventManager_Event $e);
|
||||
|
||||
public function resetPwdCheckParam(\Zend_EventManager_Event $e);
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
namespace Users\Event;
|
||||
|
||||
interface RegisterEvent
|
||||
{
|
||||
|
||||
public function checkParam(\Zend_EventManager_Event $e);
|
||||
|
||||
public function checkUser(\Zend_EventManager_Event $e);
|
||||
|
||||
public function registerSuccess(\Zend_EventManager_Event $e);
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
namespace Users;
|
||||
|
||||
class Gravatar{
|
||||
|
||||
|
||||
function Get( $email, $size='' ) {
|
||||
|
||||
$default = "http://heihedata.org/static/img/gCons/agent.png";
|
||||
|
||||
if(empty($size))
|
||||
{
|
||||
$size = 40;
|
||||
}
|
||||
|
||||
$url = "http://www.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size;
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
namespace Users\Listener;
|
||||
|
||||
use Users\Operation\RegisterOperate;
|
||||
use Users\Operation\LoginOperate;
|
||||
|
||||
class AccountListener implements \Zend_EventManager_ListenerAggregate
|
||||
{
|
||||
private $event;
|
||||
private $type;
|
||||
|
||||
function __construct($type = "")
|
||||
{
|
||||
$this->event = new \Zend_EventManager_EventManager();
|
||||
|
||||
if(empty($type))
|
||||
{
|
||||
$type = "both";
|
||||
}
|
||||
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function attach(\Zend_EventManager_EventCollection $events)
|
||||
{
|
||||
if($this->type == "both")
|
||||
{
|
||||
$this->attachRegisterEvents($events);
|
||||
$this->attachLoginEvents($events);
|
||||
}
|
||||
|
||||
if($this->type == "register")
|
||||
{
|
||||
$this->attachRegisterEvents($events);
|
||||
}
|
||||
|
||||
if($this->type == "login")
|
||||
{
|
||||
$this->attachLoginEvents($events);
|
||||
}
|
||||
}
|
||||
|
||||
public function detach(\Zend_EventManager_EventCollection $events)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function attachRegisterEvents(\Zend_EventManager_EventCollection $events)
|
||||
{
|
||||
$_Events = new RegisterOperate();
|
||||
$events->attach('register.checkParam', array($_Events, 'checkParam'), 100);
|
||||
$events->attach('register.checkUser', array($_Events, 'checkUser'), 80);
|
||||
$events->attach('register.success', array($_Events, 'registerSuccess'), 50);
|
||||
}
|
||||
|
||||
private function attachLoginEvents(\Zend_EventManager_EventCollection $events)
|
||||
{
|
||||
$_Events = new LoginOperate();
|
||||
$events->attach('login.checkParam', array($_Events, 'checkParam'), 100);
|
||||
$events->attach('login.success.updateStatus', array($_Events, 'updateStatus'), 50);
|
||||
$events->attach('login.success.createAvatar', array($_Events, 'createAvatar'), 50);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
namespace Users\Listener;
|
||||
|
||||
use Users\Operation\EditOperate;
|
||||
|
||||
class EditListener implements \Zend_EventManager_ListenerAggregate
|
||||
{
|
||||
private $event;
|
||||
private $type;
|
||||
|
||||
function __construct($type = "")
|
||||
{
|
||||
$this->event = new \Zend_EventManager_EventManager();
|
||||
|
||||
if(empty($type))
|
||||
{
|
||||
$type = "both";
|
||||
}
|
||||
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function attach(\Zend_EventManager_EventCollection $events)
|
||||
{
|
||||
$_Events = new EditOperate();
|
||||
$events->attach('edit.checkParam', array($_Events, 'checkParam'), 100);
|
||||
$events->attach('edit.success', array($_Events, 'editSuccess'), 50);
|
||||
}
|
||||
|
||||
public function detach(\Zend_EventManager_EventCollection $events)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
namespace Users\Listener;
|
||||
|
||||
use Users\Operation\PwdOperate;
|
||||
|
||||
class PwdListener implements \Zend_EventManager_ListenerAggregate
|
||||
{
|
||||
private $event;
|
||||
private $type;
|
||||
|
||||
function __construct($type = "")
|
||||
{
|
||||
$this->event = new \Zend_EventManager_EventManager();
|
||||
}
|
||||
|
||||
public function attach(\Zend_EventManager_EventCollection $events)
|
||||
{
|
||||
$_Events = new PwdOperate();
|
||||
$events->attach('pwd.forgot.checkParam', array($_Events, 'forgotPwdCheckParam'), 100);
|
||||
$events->attach('pwd.forgot.sendmail', array($_Events, 'sendGetPasswordMail'), 50);
|
||||
$events->attach('pwd.reset.checkParam', array($_Events, 'resetPwdCheckParam'), 100);
|
||||
$events->attach('pwd.reset.sendmail', array($_Events, 'sendGetPasswordMail'), 50);
|
||||
}
|
||||
|
||||
public function detach(\Zend_EventManager_EventCollection $events)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
namespace Users;
|
||||
|
||||
class Member
|
||||
{
|
||||
var $ck='DCC3ER4T8L2EFX94OPDF';
|
||||
var $db; //传入PDO对象
|
||||
var $mid; //会员ID
|
||||
|
||||
public $scr; //cookie 安全码 $_COOKIE['scr']
|
||||
public $user;//cookie User $_COOKIE['user']
|
||||
|
||||
public $srpwd;//执行checkcookie后方可调用
|
||||
|
||||
public $memberTable = "users";
|
||||
public $FieldUsername = "username";
|
||||
public $FieldPasword = "password";
|
||||
public $FieldLastlogin = "ts_last_login";
|
||||
public $FieldEmail = "email";
|
||||
public $FieldLastloginIp = "last_login_ip";
|
||||
public $GravatarEmailField = "gravatar_email";
|
||||
|
||||
public $RoleMember = "member";
|
||||
|
||||
function __construct()
|
||||
{
|
||||
if(empty($db))
|
||||
{
|
||||
$this->db = \Zend_Registry::get('db');
|
||||
}else{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
$this->config = \Zend_Registry::get('config');
|
||||
|
||||
if(!empty($_COOKIE['scr']))
|
||||
{
|
||||
$this->scr = $_COOKIE['scr'];
|
||||
}
|
||||
if(!empty($_COOKIE['user']))
|
||||
{
|
||||
$this->user= $_COOKIE['user'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检测cookie
|
||||
*/
|
||||
public function checkcookie()
|
||||
{
|
||||
$uname = $this->user;
|
||||
$hash = $this->scr;
|
||||
|
||||
if(!empty($uname) && !empty($hash))
|
||||
{
|
||||
if (preg_match("/[<|>|#|$|%|^|*|(|)|{|}|'|\"|;|:]/i",$uname) || preg_match("/[<|>|#|$|%|^|*|(|)|{|}|'|\"|;|:]/i",$hash))
|
||||
{
|
||||
$this->mid=0;
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
$sql = "select {$this->FieldUsername} as userid,{$this->FieldPasword} as pwd from {$this->memberTable} where {$this->FieldUsername}='$uname'";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
$scr = $this->makescr($row['userid'],$row['pwd']);
|
||||
|
||||
if($hash == $scr)
|
||||
{
|
||||
$this->srpwd=$row['pwd'];
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}//cookie安全
|
||||
}else {
|
||||
return false;
|
||||
}//exit
|
||||
}//function checkcookie
|
||||
|
||||
/**
|
||||
* putcookie
|
||||
*
|
||||
* 登陆成功后放置cookie,包含安全码
|
||||
*
|
||||
* @param String $uname
|
||||
* @param String $pwd
|
||||
* @param Int $time
|
||||
*/
|
||||
public function putcookie($uname,$pwd,$time = 604800)
|
||||
{
|
||||
try {
|
||||
$scrString = $this->makescr($uname,$pwd);//加密验证串:防止用户密码被盗;防止伪造cookie。
|
||||
|
||||
if(!is_numeric($time))
|
||||
{
|
||||
$time = 604800;
|
||||
}
|
||||
|
||||
setcookie('user',$uname,time()+$time,'/');
|
||||
setcookie('scr',$scrString,time()+$time,'/');
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}//function putcookie
|
||||
|
||||
/**
|
||||
* 生成安全码
|
||||
*
|
||||
* @param String $u
|
||||
* @param String $p
|
||||
*/
|
||||
public function makescr($u,$p)
|
||||
{
|
||||
return substr(md5($u.$p.$this->ck),3,20);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除cookie
|
||||
*/
|
||||
static function flushcookie()
|
||||
{
|
||||
setcookie('user','',time()-99999,'/');
|
||||
setcookie('scr','',time()-99999,'/');
|
||||
}
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
$sql = "SELECT * FROM ".$this->memberTable." m ORDER BY m.id DESC";
|
||||
$rs = $this->db->query($sql);
|
||||
return $rs->fetchAll();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
namespace Users\Operation;
|
||||
|
||||
use Mail\Mail;
|
||||
use helpers\View as view;
|
||||
|
||||
class EditOperate implements \Users\Event\EditEvent
|
||||
{
|
||||
private $db; //传入PDO对象
|
||||
public $tbl_member = "users";
|
||||
public $FieldUsername = "username";
|
||||
public $FieldPasword = "password";
|
||||
public $FieldLastlogin = "ts_last_login";
|
||||
public $FieldEmail = "email";
|
||||
public $FieldLastloginIp = "last_login_ip";
|
||||
public $FieldGravatarEmail = "gravatar_email";
|
||||
private $DefaultFetchMode = \PDO::FETCH_BOTH; //默认检索模式,防止出现sdtClass错误
|
||||
private $config; //全局配置
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
if(empty($db))
|
||||
{
|
||||
$this->db = \Zend_Registry::get('db');
|
||||
}else{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
$this->config = \Zend_Registry::get('config');
|
||||
}
|
||||
|
||||
public function checkParam(\Zend_EventManager_Event $e){
|
||||
|
||||
$data = $e->getParam('data');
|
||||
$type = $e->getParam('type');
|
||||
|
||||
if($type == 'general')
|
||||
{
|
||||
|
||||
if(empty($data['realname']))
|
||||
{
|
||||
return "请输入真实姓名";
|
||||
}
|
||||
|
||||
if(mb_strlen($data['realname'],"UTF-8")>10 )
|
||||
{
|
||||
return "姓名不要超过10个字";
|
||||
}
|
||||
}
|
||||
|
||||
if($type == "password")
|
||||
{
|
||||
if(strlen($data['password'])>18 || strlen($data['password_new'])>18)
|
||||
{
|
||||
return "密码过长";
|
||||
}
|
||||
if(strlen($data['password_new'])<=6 || strlen($data['password_confirm'])<=6)
|
||||
{
|
||||
return "密码过短";
|
||||
}
|
||||
if(md5($data['password_new']) != md5($data['password_confirm']))
|
||||
{
|
||||
return "两次输入的密码不同";
|
||||
}
|
||||
|
||||
$uid = view::User('id');
|
||||
$sql = "SELECT {$this->FieldPasword} FROM {$this->tbl_member} WHERE id=$uid";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
|
||||
if(md5($data['password']) != $row[$this->FieldPasword])
|
||||
{
|
||||
return "原密码不正确";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}//checkParam
|
||||
|
||||
public function editSuccess(\Zend_EventManager_Event $e){
|
||||
|
||||
$data = $e->getParam('data');
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
namespace Users\Operation;
|
||||
|
||||
use Helpers\dbh as dbh;
|
||||
use Users\Gravatar;
|
||||
|
||||
class LoginOperate implements \Users\Event\LoginEvent
|
||||
{
|
||||
private $db; //传入PDO对象
|
||||
public $tbl_member = "users";
|
||||
public $FieldUsername = "username";
|
||||
public $FieldPasword = "password";
|
||||
public $FieldLastlogin = "ts_last_login";
|
||||
public $FieldEmail = "email";
|
||||
public $FieldLastloginIp = "last_login_ip";
|
||||
public $FieldGravatarEmail = "gravatar_email";
|
||||
private $DefaultFetchMode = \PDO::FETCH_BOTH; //默认检索模式,防止出现sdtClass错误
|
||||
private $config; //全局配置
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
if(empty($db))
|
||||
{
|
||||
$this->db = \Zend_Registry::get('db');
|
||||
}else{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
$this->config = \Zend_Registry::get('config');
|
||||
}
|
||||
|
||||
public function checkParam(\Zend_EventManager_Event $e){
|
||||
|
||||
$data = $e->getParam('data');
|
||||
|
||||
if(!is_array($data))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
|
||||
if(empty($data['username']))
|
||||
{
|
||||
return array('error'=>"请输入用户名",'place'=>'username');
|
||||
}
|
||||
|
||||
if(!empty($data['username']))
|
||||
{
|
||||
if(!preg_match("/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/",$data['username']))
|
||||
{
|
||||
return array('error'=>"用户名应当以字母开头,由字母数字和下划线组成,并且长度在5到25个字符之间",'place'=>'username');
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($data['password']))
|
||||
{
|
||||
return array('error'=>"请输入密码",'place'=>'password');
|
||||
}
|
||||
|
||||
$sql = "SELECT id,{$this->FieldPasword} FROM {$this->tbl_member} WHERE {$this->FieldUsername}=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$rs = $sth->execute(array($data[$this->FieldUsername]));
|
||||
$row = $sth->fetch();
|
||||
|
||||
if(isset($row['id']) && !empty($row['id']))
|
||||
{
|
||||
if(strlen($row[$this->FieldPasword]) !== 32)
|
||||
{
|
||||
return array('error'=>"您的密码或因安全原因或其他问题已经被重置,请先<a href='/account/forgotpassword'>重置密码</a>再登陆",'place'=>'password');
|
||||
}
|
||||
if($row[$this->FieldPasword] !== md5($data['password']))
|
||||
{
|
||||
return array('error'=>"密码错误",'place'=>'password');
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
return array('error'=>"用户不存在",'place'=>'username');
|
||||
}
|
||||
|
||||
}//checkParam
|
||||
|
||||
public function updateStatus(\Zend_EventManager_Event $e){
|
||||
|
||||
$id = (int)$e->getParam('id');
|
||||
|
||||
if(!is_numeric($id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$update = array(
|
||||
$this->FieldLastlogin => date("Y-m-d H:i:s"),
|
||||
$this->FieldLastloginIp => $_SERVER["REMOTE_ADDR"]
|
||||
);
|
||||
|
||||
$dbh = new dbh();
|
||||
@$statusUpdate = $dbh->update($this->tbl_member,$update," id=$id ");
|
||||
|
||||
return true;
|
||||
}//loginSuccess
|
||||
|
||||
public function createAvatar(\Zend_EventManager_Event $e){
|
||||
|
||||
$email = $e->getParam('email');
|
||||
$avatar = new Gravatar();
|
||||
return $avatar->Get($email);
|
||||
|
||||
}//loginSuccess
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
namespace Users\Operation;
|
||||
|
||||
use Mail\Mail;
|
||||
use Helpers\View as view;
|
||||
|
||||
class PwdOperate implements \Users\Event\PwdEvent
|
||||
{
|
||||
private $db; //传入PDO对象
|
||||
public $tbl_member = "users";
|
||||
public $FieldUsername = "username";
|
||||
public $FieldPasword = "password";
|
||||
public $FieldLastlogin = "ts_last_login";
|
||||
public $FieldEmail = "email";
|
||||
public $FieldLastloginIp = "last_login_ip";
|
||||
public $FieldGravatarEmail = "gravatar_email";
|
||||
private $DefaultFetchMode = \PDO::FETCH_BOTH; //默认检索模式,防止出现sdtClass错误
|
||||
private $config; //全局配置
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
if(empty($db))
|
||||
{
|
||||
$this->db = \Zend_Registry::get('db');
|
||||
}else{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
$this->config = \Zend_Registry::get('config');
|
||||
}
|
||||
|
||||
public function forgotPwdCheckParam(\Zend_EventManager_Event $e){
|
||||
|
||||
$email = $e->getParam('email');
|
||||
|
||||
if(empty($email))
|
||||
{
|
||||
return array('error'=>"请输入电子邮箱,作为找回密码和接受通知的联系方式",'place'=>'email');
|
||||
}
|
||||
|
||||
if (!preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',$email))
|
||||
{
|
||||
return array('error'=>"请输入正确的电子邮件",'place'=>'email');
|
||||
}
|
||||
|
||||
return true;
|
||||
}//checkParam
|
||||
|
||||
public function sendGetPasswordMail(\Zend_EventManager_Event $e){
|
||||
|
||||
$email = $e->getParam('email');
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function resetPwdCheckParam(\Zend_EventManager_Event $e)
|
||||
{
|
||||
$data = $e->getParam('data');
|
||||
|
||||
if(empty($data['username']))
|
||||
{
|
||||
return array('error'=>"请输入用户名",'place'=>'username');
|
||||
}
|
||||
|
||||
if(empty($data['password']))
|
||||
{
|
||||
return array('error'=>"请输入密码",'place'=>'password');
|
||||
}
|
||||
|
||||
if(strlen($data['password']) < 6)
|
||||
{
|
||||
return array('error'=>"密码长度太短,为了安全最少输入6位哦",'place'=>'password');
|
||||
}
|
||||
|
||||
if(strlen($data['password']) > 14)
|
||||
{
|
||||
return array('error'=>"密码太长,亲您记得住吗?不要超过14位哦",'place'=>'password');
|
||||
}
|
||||
|
||||
if(empty($data['confirm_password']))
|
||||
{
|
||||
return array('error'=>"请再次输入密码已确认输入正确",'place'=>'confirm_password');
|
||||
}
|
||||
|
||||
if(md5($data['password']) != md5($data['confirm_password']))
|
||||
{
|
||||
return array('error'=>"两次输入的密码不同,请重新输入",'place'=>'confirm_password');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
namespace Users\Operation;
|
||||
|
||||
use Mail\Mail;
|
||||
use Helpers\View as view;
|
||||
|
||||
class RegisterOperate implements \Users\Event\RegisterEvent
|
||||
{
|
||||
private $db; //传入PDO对象
|
||||
public $tbl_member = "tbl_member";
|
||||
public $FieldUsername = "username";
|
||||
public $FieldPasword = "password";
|
||||
public $FieldLastlogin = "ts_last_login";
|
||||
public $FieldEmail = "email";
|
||||
public $FieldLastloginIp = "last_login_ip";
|
||||
public $FieldGravatarEmail = "gravatar_email";
|
||||
private $DefaultFetchMode = \PDO::FETCH_BOTH; //默认检索模式,防止出现sdtClass错误
|
||||
private $config; //全局配置
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
if(empty($db))
|
||||
{
|
||||
$this->db = \Zend_Registry::get('db');
|
||||
}else{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
$this->config = \Zend_Registry::get('config');
|
||||
}
|
||||
|
||||
public function checkParam(\Zend_EventManager_Event $e){
|
||||
|
||||
$data = $e->getParam('data');
|
||||
|
||||
if(!is_array($data))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
|
||||
if(empty($data['username']))
|
||||
{
|
||||
return array('error'=>"请输入用户名",'place'=>'username');
|
||||
}
|
||||
|
||||
if(!empty($data['username']))
|
||||
{
|
||||
if(!preg_match("/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/",$data['username']))
|
||||
{
|
||||
return array('error'=>"用户名应当以字母开头,由字母数字和下划线组成,并且长度在5到16个字符之间",'place'=>'username');
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($data['password']))
|
||||
{
|
||||
return array('error'=>"请输入密码",'place'=>'password');
|
||||
}
|
||||
|
||||
if(strlen($data['password']) < 6)
|
||||
{
|
||||
return array('error'=>"密码长度太短,为了安全最少输入6位",'place'=>'password');
|
||||
}
|
||||
|
||||
if(strlen($data['password']) > 14)
|
||||
{
|
||||
return array('error'=>"密码太长,请不要超过14位",'place'=>'password');
|
||||
}
|
||||
|
||||
if(empty($data['confirm_password']))
|
||||
{
|
||||
return array('error'=>"请再次输入密码已确认输入正确",'place'=>'confirm_password');
|
||||
}
|
||||
|
||||
if(md5($data['password']) != md5($data['confirm_password']))
|
||||
{
|
||||
return array('error'=>"两次输入的密码不同,请重新输入",'place'=>'confirm_password');
|
||||
}
|
||||
|
||||
if(empty($data['email']))
|
||||
{
|
||||
return array('error'=>"请输入电子邮箱,作为找回密码和接受通知的联系方式",'place'=>'email');
|
||||
}
|
||||
|
||||
if (!preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',$data['email']))
|
||||
{
|
||||
return array('error'=>"请输入正确的电子邮件,推荐使用QQ邮箱和Gmail邮箱",'place'=>'email');
|
||||
}
|
||||
|
||||
if(empty($data['realname']))
|
||||
{
|
||||
return array('error'=>"请输入姓名",'place'=>'realname');
|
||||
}
|
||||
|
||||
if(mb_strlen($data['realname'],"UTF-8")>10 )
|
||||
{
|
||||
return array('error'=>"真实姓名请不要超过10个字",'place'=>'realname');
|
||||
}
|
||||
|
||||
return true;
|
||||
}//checkParam
|
||||
|
||||
public function checkUser(\Zend_EventManager_Event $e){
|
||||
|
||||
$data = $e->getParam('data');
|
||||
|
||||
if(!is_array($data))
|
||||
{
|
||||
return "用户信息验证失败,请重新尝试";
|
||||
}
|
||||
|
||||
$sql = "SELECT id,{$this->FieldUsername},{$this->FieldEmail} FROM ".$this->tbl_member." WHERE {$this->FieldUsername}='{$data['username']}' OR {$this->FieldEmail}='{$data['email']}'";
|
||||
|
||||
$rs = $this->db->query($sql);
|
||||
|
||||
$row = $rs->fetch();
|
||||
|
||||
if(isset($row['id']) && !empty($row['id']))
|
||||
{
|
||||
if($row[$this->FieldUsername] == $data['username'])
|
||||
{
|
||||
return array('error'=>'您的用户名已经注册过账号,您是否<a href="/account/forgotpassword">忘记了密码?</a>','place'=>'username');
|
||||
}
|
||||
|
||||
if($row[$this->FieldEmail] == $data['email'])
|
||||
{
|
||||
return array('error'=>'您的邮箱已经注册过账号,请换一个邮箱','place'=>'email');
|
||||
}
|
||||
|
||||
return array('error'=>'您的用户名或邮箱已经使用过,注册新账号请换一个用户名');
|
||||
}
|
||||
|
||||
return true;
|
||||
}//checkUser
|
||||
|
||||
public function registerSuccess(\Zend_EventManager_Event $e){
|
||||
|
||||
$data = $e->getParam('data');
|
||||
|
||||
if(!is_array($data))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$id = $e->getParam('id');
|
||||
|
||||
if(!is_numeric($id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$mail_template = "register";
|
||||
$mail_data = array(
|
||||
'name'=>$data['realname'],
|
||||
'content'=>$this->getMailContent()
|
||||
);
|
||||
|
||||
$mail = new Mail();
|
||||
|
||||
$mail->loadTemplate($mail_template,$mail_data);
|
||||
$mail->addTo($data['email'],$data['realname']);
|
||||
$mail->send();
|
||||
|
||||
return true;
|
||||
}//registerSuccess
|
||||
|
||||
//邮件内容
|
||||
public function getMailContent()
|
||||
{
|
||||
$sql = "SELECT v.id,v.title,v.thumb,v.status,v.content,m.realname,m.username FROM tbl_voice v
|
||||
LEFT JOIN tbl_member m ON v.userid = m.id
|
||||
WHERE v.status > 0
|
||||
ORDER BY v.id DESC
|
||||
LIMIT 5";
|
||||
$rs = $this->db->query($sql);
|
||||
$latest = $rs->fetchAll();
|
||||
|
||||
$content = "";
|
||||
|
||||
foreach($latest as $k=>$v)
|
||||
{
|
||||
if($v['thumb'] != '[]')
|
||||
{
|
||||
$thumb = json_decode($v['thumb'],true);
|
||||
$text = mb_strlen($v['content'],"UTF-8") > 100 ? mb_substr($v['content'],0,100,"UTF-8") : $v['content'];
|
||||
$content .= '<p style="width:100%;overflow:hidden;"><img src="http://www.msgfm.com'.$this->config->upload->urlbase.$thumb[0]['thumb'][400]['url'].'" height="100" style="float:left;margin-right:10px;" />'.$v['title']. ' / ' .$v['realname'].'<br />'.$text.'<br /><a href="http://www.msgfm.com/voice/'.$v['id'].'.html">查看播放</a></p>';
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}//getMailContent();
|
||||
|
||||
}
|
Loading…
Reference in New Issue