- [= $autoindex ?>]
+ [= $autoindex ?>]
+
{reference->getAuthorByReference($item['id'],true); echo count($authors) ? join(",",$authors):'未知作者 '; ?>}
{= empty($item['title']) ? '未知标题 ':$item['title'] ?>}
{= empty($item['publisher']) ? '未知期刊 ':$item['publisher'] ?>}
{= empty($item['year']) ? '未知年份 ':$item['year'] ?>}
+
= date("Y-m-d H:i",strtotime($item['ts_created'])) ?>
From 332556997083314ec7dd67a6d0b3cb060855e50c Mon Sep 17 00:00:00 2001
From: wlx
Date: Mon, 4 Nov 2013 13:26:00 +0000
Subject: [PATCH 030/126] =?UTF-8?q?=E4=B8=8D=E8=BE=93=E5=87=BA=E5=B7=B2?=
=?UTF-8?q?=E7=BB=8F=E6=9C=89RIS=E5=86=85=E5=AE=B9=E7=9A=84=E6=96=87?=
=?UTF-8?q?=E7=8C=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Reference/RisOutput.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/module/Reference/RisOutput.php b/application/module/Reference/RisOutput.php
index 842b2ba2..0a95d24d 100644
--- a/application/module/Reference/RisOutput.php
+++ b/application/module/Reference/RisOutput.php
@@ -56,7 +56,7 @@ class RisOutput
{
if($mode == "all")
{
- $sql = "SELECT * FROM {$this->table->reference} ORDER BY year DESC,title ASC,id ASC";
+ $sql = "SELECT * FROM {$this->table->reference} where length(ris)<10 ORDER BY year DESC,title ASC,id ASC";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
From 3cd2e1676693c71b7dc349aac1ad7e4f818223b2 Mon Sep 17 00:00:00 2001
From: wlx
Date: Mon, 4 Nov 2013 13:27:32 +0000
Subject: [PATCH 031/126] =?UTF-8?q?=E4=BC=98=E5=8C=96RIS=E8=BE=93=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Reference/RisOutput.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/module/Reference/RisOutput.php b/application/module/Reference/RisOutput.php
index 0a95d24d..44b7151f 100644
--- a/application/module/Reference/RisOutput.php
+++ b/application/module/Reference/RisOutput.php
@@ -56,7 +56,7 @@ class RisOutput
{
if($mode == "all")
{
- $sql = "SELECT * FROM {$this->table->reference} where length(ris)<10 ORDER BY year DESC,title ASC,id ASC";
+ $sql = "SELECT * FROM {$this->table->reference} where length(ris)<10 or ris is null ORDER BY year DESC,title ASC,id ASC";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
From 8c3d9cf7609b45f9f6b4b29b5d7f6afcb2f9f585 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Tue, 5 Nov 2013 02:23:49 +0000
Subject: [PATCH 032/126] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E4=B8=AD=E5=BF=83=E6=96=87=E7=8C=AE=E7=9A=84=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admin/controllers/DataController.php | 21 +++++++++++--------
.../views/scripts/data/ref-mdref-form.phtml | 1 +
.../admin/views/scripts/data/ref.phtml | 4 ++++
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php
index 3ee7db2a..b7675d6d 100755
--- a/application/admin/controllers/DataController.php
+++ b/application/admin/controllers/DataController.php
@@ -1154,15 +1154,13 @@ class Admin_DataController extends Zend_Controller_Action
}
$this->view->reference = $reference;
+ $this->view->page = $this->_getParam('page');
+ $this->view->pagelimit = 12;
//文献首页
if(empty($ac))
{
- $this->view->referenceType = $reference->referenceType();
-
- $this->view->page = $this->_getParam('page');
- $this->view->pagelimit = 12;
-
+ $this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchReferences(),$this, $this->view->pagelimit);
$this->view->years = $reference->countByYear();
return true;
@@ -1170,23 +1168,25 @@ class Admin_DataController extends Zend_Controller_Action
else if ($ac == "water")
{
$this->view->referenceType = $reference->referenceType();
- view::addPaginator($reference->fetchThemeReferences('water'),$this,10);
+ view::addPaginator($reference->fetchThemeReferences('water'),$this,$this->view->pagelimit);
return true;
}
else if ($ac == "westdc")
{
$this->view->referenceType = $reference->referenceType();
- view::addPaginator($reference->fetchWestdcReferences(),$this,10);
+ view::addPaginator($reference->fetchWestdcReferences(),$this,$this->view->pagelimit);
return true;
}
else if ($ac == "todo")
{
$this->view->referenceType = $reference->referenceType();
- view::addPaginator($reference->fetchTodoReferences(),$this,10);
+ view::addPaginator($reference->fetchTodoReferences(),$this,$this->view->pagelimit);
return true;
}
unset($this->view->reference);
+ unset($this->view->page);
+ unset($this->view->pagelimit);
//添加
if($ac == "add")
@@ -1411,7 +1411,10 @@ class Admin_DataController extends Zend_Controller_Action
$risData = $risOutput->processArrayDataToRisData($preData);
$risText = $risOutput->output($risData);
- view::Dump($risText);
+
+ echo "";
+ echo $risText;
+ echo " ";
}
}//ris output
diff --git a/application/admin/views/scripts/data/ref-mdref-form.phtml b/application/admin/views/scripts/data/ref-mdref-form.phtml
index 6721ff29..5905972c 100644
--- a/application/admin/views/scripts/data/ref-mdref-form.phtml
+++ b/application/admin/views/scripts/data/ref-mdref-form.phtml
@@ -15,6 +15,7 @@
元数据UUID
diff --git a/application/admin/views/scripts/data/ref.phtml b/application/admin/views/scripts/data/ref.phtml
index f3b3afcb..9670014e 100644
--- a/application/admin/views/scripts/data/ref.phtml
+++ b/application/admin/views/scripts/data/ref.phtml
@@ -38,6 +38,10 @@ table thead tr th {background:#EBF2F6;}
= $this->msg ?>
+ ac == 'westdc'){ ?>
+
添加数据中心文献
+
+
years)) { ?>
years as $k=>$v){ ?>
= empty($v['year']) ? "未知":$v['year'] ?>(= $v['num'] ?>)
From ff2f657cb64b54a240f1cb1586fb66477e7b0537 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Tue, 5 Nov 2013 03:57:01 +0000
Subject: [PATCH 033/126] =?UTF-8?q?=E8=A7=84=E8=8C=83=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E5=90=8D=E5=92=8Cnamespace=E5=91=BD=E5=90=8D=EF=BC=8C=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=E5=B0=8F=E5=BF=83=E4=B8=BA=E5=A4=A7=E4=BA=9B=EF=BC=8C?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0Application=E7=B1=BB=E7=94=A8=E6=9D=A5?=
=?UTF-8?q?=E5=A4=84=E7=90=86=E7=94=B3=E8=AF=B7=E7=9B=B8=E5=85=B3=E4=BA=8B?=
=?UTF-8?q?=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../module/Order/Event/ApplicationEvent.php | 7 +++
.../Order/Handler/ApplicationHandler.php | 36 ++++++++++++++
.../module/Order/Manager/Application.php | 48 +++++++++++++++++++
application/module/Order/Order.php | 8 ++--
.../Order/listener/ApplicationListener.php | 25 ++++++++++
.../module/Order/listener/ManagerEvents.php | 2 +-
.../module/Order/listener/ManagerListener.php | 4 +-
.../module/Order/listener/OrderEvents.php | 2 +-
.../module/Order/listener/OrderListener.php | 8 ++--
.../module/Order/listener/PdfEvents.php | 2 +-
.../module/Order/listener/PdfFormEvents.php | 2 +-
.../module/Order/mount/ManagerOperate.php | 4 +-
.../module/Order/mount/OrderOperate.php | 8 ++--
application/module/Order/mount/PdfForm.php | 6 +--
application/module/Order/mount/PdfOperate.php | 10 ++--
15 files changed, 144 insertions(+), 28 deletions(-)
create mode 100644 application/module/Order/Event/ApplicationEvent.php
create mode 100644 application/module/Order/Handler/ApplicationHandler.php
create mode 100644 application/module/Order/Manager/Application.php
create mode 100644 application/module/Order/listener/ApplicationListener.php
diff --git a/application/module/Order/Event/ApplicationEvent.php b/application/module/Order/Event/ApplicationEvent.php
new file mode 100644
index 00000000..7865132f
--- /dev/null
+++ b/application/module/Order/Event/ApplicationEvent.php
@@ -0,0 +1,7 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+ }
+
+ public function applicationCheckParam(\Zend_EventManager_Event $e)
+ {
+ $data = $e->getParam('data');
+
+ return true;
+ }
+
+}
diff --git a/application/module/Order/Manager/Application.php b/application/module/Order/Manager/Application.php
new file mode 100644
index 00000000..cc1bf6a6
--- /dev/null
+++ b/application/module/Order/Manager/Application.php
@@ -0,0 +1,48 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+
+ $Listener = new Listener();
+ @$this->events()->attachAggregate($Listener);
+
+ $this->table = new \Helpers\Table();
+ }
+
+ 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 passed()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/application/module/Order/Order.php b/application/module/Order/Order.php
index afc15dbe..cf9ba966 100644
--- a/application/module/Order/Order.php
+++ b/application/module/Order/Order.php
@@ -1,10 +1,10 @@
event = new \Zend_EventManager_EventManager();
+ }
+
+ public function attach(\Zend_EventManager_EventCollection $events)
+ {
+ $Handler = new Handler();
+ //$events->attach('app.checkParam', array($Handler, 'appCheckParam'), 100);
+ }
+
+ public function detach(\Zend_EventManager_EventCollection $events)
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Order/listener/ManagerEvents.php b/application/module/Order/listener/ManagerEvents.php
index 2fedd65f..c3e370aa 100644
--- a/application/module/Order/listener/ManagerEvents.php
+++ b/application/module/Order/listener/ManagerEvents.php
@@ -1,5 +1,5 @@
getMessage());
+ view::Dump($e->getMessage());
}
return true;
diff --git a/application/module/Order/mount/PdfForm.php b/application/module/Order/mount/PdfForm.php
index 5c83af22..52024d4a 100644
--- a/application/module/Order/mount/PdfForm.php
+++ b/application/module/Order/mount/PdfForm.php
@@ -1,10 +1,10 @@
Date: Tue, 5 Nov 2013 03:59:35 +0000
Subject: [PATCH 034/126] =?UTF-8?q?=E5=B0=86Order/listener=E6=94=B9?=
=?UTF-8?q?=E4=B8=BAOrder/Listener?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../module/Order/{listener => Listener}/ApplicationListener.php | 0
application/module/Order/{listener => Listener}/ManagerEvents.php | 0
.../module/Order/{listener => Listener}/ManagerListener.php | 0
application/module/Order/{listener => Listener}/OrderEvents.php | 0
application/module/Order/{listener => Listener}/OrderListener.php | 0
application/module/Order/{listener => Listener}/PdfEvents.php | 0
application/module/Order/{listener => Listener}/PdfFormEvents.php | 0
7 files changed, 0 insertions(+), 0 deletions(-)
rename application/module/Order/{listener => Listener}/ApplicationListener.php (100%)
rename application/module/Order/{listener => Listener}/ManagerEvents.php (100%)
rename application/module/Order/{listener => Listener}/ManagerListener.php (100%)
rename application/module/Order/{listener => Listener}/OrderEvents.php (100%)
rename application/module/Order/{listener => Listener}/OrderListener.php (100%)
rename application/module/Order/{listener => Listener}/PdfEvents.php (100%)
rename application/module/Order/{listener => Listener}/PdfFormEvents.php (100%)
diff --git a/application/module/Order/listener/ApplicationListener.php b/application/module/Order/Listener/ApplicationListener.php
similarity index 100%
rename from application/module/Order/listener/ApplicationListener.php
rename to application/module/Order/Listener/ApplicationListener.php
diff --git a/application/module/Order/listener/ManagerEvents.php b/application/module/Order/Listener/ManagerEvents.php
similarity index 100%
rename from application/module/Order/listener/ManagerEvents.php
rename to application/module/Order/Listener/ManagerEvents.php
diff --git a/application/module/Order/listener/ManagerListener.php b/application/module/Order/Listener/ManagerListener.php
similarity index 100%
rename from application/module/Order/listener/ManagerListener.php
rename to application/module/Order/Listener/ManagerListener.php
diff --git a/application/module/Order/listener/OrderEvents.php b/application/module/Order/Listener/OrderEvents.php
similarity index 100%
rename from application/module/Order/listener/OrderEvents.php
rename to application/module/Order/Listener/OrderEvents.php
diff --git a/application/module/Order/listener/OrderListener.php b/application/module/Order/Listener/OrderListener.php
similarity index 100%
rename from application/module/Order/listener/OrderListener.php
rename to application/module/Order/Listener/OrderListener.php
diff --git a/application/module/Order/listener/PdfEvents.php b/application/module/Order/Listener/PdfEvents.php
similarity index 100%
rename from application/module/Order/listener/PdfEvents.php
rename to application/module/Order/Listener/PdfEvents.php
diff --git a/application/module/Order/listener/PdfFormEvents.php b/application/module/Order/Listener/PdfFormEvents.php
similarity index 100%
rename from application/module/Order/listener/PdfFormEvents.php
rename to application/module/Order/Listener/PdfFormEvents.php
From d007786fb1fe8363d8c2a13ce3b815eb0f8f82d7 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Tue, 5 Nov 2013 04:01:05 +0000
Subject: [PATCH 035/126] =?UTF-8?q?=E5=B0=86Order/mount=E6=94=B9=E4=B8=BAO?=
=?UTF-8?q?rder/Mount?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Order/{mount => Mount}/ManagerOperate.php | 0
application/module/Order/{mount => Mount}/OrderOperate.php | 0
application/module/Order/{mount => Mount}/PdfForm.php | 0
application/module/Order/{mount => Mount}/PdfOperate.php | 0
4 files changed, 0 insertions(+), 0 deletions(-)
rename application/module/Order/{mount => Mount}/ManagerOperate.php (100%)
rename application/module/Order/{mount => Mount}/OrderOperate.php (100%)
rename application/module/Order/{mount => Mount}/PdfForm.php (100%)
rename application/module/Order/{mount => Mount}/PdfOperate.php (100%)
diff --git a/application/module/Order/mount/ManagerOperate.php b/application/module/Order/Mount/ManagerOperate.php
similarity index 100%
rename from application/module/Order/mount/ManagerOperate.php
rename to application/module/Order/Mount/ManagerOperate.php
diff --git a/application/module/Order/mount/OrderOperate.php b/application/module/Order/Mount/OrderOperate.php
similarity index 100%
rename from application/module/Order/mount/OrderOperate.php
rename to application/module/Order/Mount/OrderOperate.php
diff --git a/application/module/Order/mount/PdfForm.php b/application/module/Order/Mount/PdfForm.php
similarity index 100%
rename from application/module/Order/mount/PdfForm.php
rename to application/module/Order/Mount/PdfForm.php
diff --git a/application/module/Order/mount/PdfOperate.php b/application/module/Order/Mount/PdfOperate.php
similarity index 100%
rename from application/module/Order/mount/PdfOperate.php
rename to application/module/Order/Mount/PdfOperate.php
From ed711d9a3b946b4c0b5437d246b965d96abdbb39 Mon Sep 17 00:00:00 2001
From: wlx
Date: Tue, 5 Nov 2013 04:09:26 +0000
Subject: [PATCH 036/126] change mount to Mount
---
application/default/controllers/DataController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php
index 205529d7..5768028c 100755
--- a/application/default/controllers/DataController.php
+++ b/application/default/controllers/DataController.php
@@ -697,7 +697,7 @@ class DataController extends Zend_Controller_Action
//检查特殊数据服务是否存在
private function checkDataService($uuid)
{
- $order = new \Order\mount\OrderOperate();
+ $order = new \Order\Mount\OrderOperate();
$service = $order->getDataService($uuid);
if(empty($service))
From 5d80b35553ddac925deacdaf850cfefcc37d481b Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Tue, 5 Nov 2013 07:57:17 +0000
Subject: [PATCH 037/126] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=B7=B2?=
=?UTF-8?q?=E9=80=9A=E8=BF=87=E7=9A=84=E6=9C=8D=E5=8A=A1=E8=AE=B0=E5=BD=95?=
=?UTF-8?q?=E7=9A=84=E6=90=9C=E7=B4=A2=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86?=
=?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=97=B6=E7=9A=84=E7=A1=AE=E8=AE=A4=E6=8C=89?=
=?UTF-8?q?=E9=92=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admin/controllers/DownController.php | 18 +++++++--------
.../admin/views/scripts/down/offline.phtml | 14 +++++++++++-
.../down/offlineapps-notreceived.phtml | 2 +-
.../module/Order/Event/ApplicationEvent.php | 2 +-
.../Order/Handler/ApplicationHandler.php | 4 ++--
.../module/Order/Manager/Application.php | 22 +++++++++++++++++--
6 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/application/admin/controllers/DownController.php b/application/admin/controllers/DownController.php
index b28592ff..f7d06304 100644
--- a/application/admin/controllers/DownController.php
+++ b/application/admin/controllers/DownController.php
@@ -4,6 +4,7 @@ use Files\Files;
use Files\Output;
use Files\Listener\FileListener;
use Order\Manager\Offlineapp;
+use Order\Manager\Application;
use data\DataService;
use Mail\Mail;
@@ -1137,16 +1138,15 @@ class Admin_DownController extends Zend_Controller_Action
->setBody($objWriter->save('php://output'));*/
}
- $select=$this->db->select();
- $select->from('offlineapp')->where('ts_approved is not null')->where('pdflink is not null')->where('status>=0')->order('ts_created desc');
- $paginator = Zend_Paginator::factory($select);
- $paginator->setCurrentPageNumber($this->_getParam('page'));
- $paginator->setItemCountPerPage($this->view->config->page->max);
- $paginator->setView($this->view);
- Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
- $this->view->paginator=$paginator;
-
$this->view->page = $this->_getParam('page');
+
+ $application = new Application();
+
+ $this->view->q = $application->keyword = $this->_getParam('q');
+ $application->filter = $this->_getParam('filter');
+ view::addPaginator($application->passed(),$this,20);
+
+ return true;
}
//在线数据下载情况,仅针对onlineapp表,自2011-9-8开始记录。
function onlineAction()
diff --git a/application/admin/views/scripts/down/offline.phtml b/application/admin/views/scripts/down/offline.phtml
index 12e44025..17bbb488 100644
--- a/application/admin/views/scripts/down/offline.phtml
+++ b/application/admin/views/scripts/down/offline.phtml
@@ -27,8 +27,20 @@
离线数据服务记录
-添加新的离线服务记录 | 下载所有离线服务记录 | 自动匹配离线下载用户与网站用户 | 下载服务用户邮箱列表
+添加新的离线服务记录 | 下载所有离线服务记录 | 自动匹配离线下载用户与网站用户 | 下载服务用户邮箱列表
| 下载上月服务记录(科技部上报)
+
+
+
paginator)): ?>
diff --git a/application/admin/views/scripts/down/offlineapps-notreceived.phtml b/application/admin/views/scripts/down/offlineapps-notreceived.phtml
index c9e8f0b2..ca1f62eb 100644
--- a/application/admin/views/scripts/down/offlineapps-notreceived.phtml
+++ b/application/admin/views/scripts/down/offlineapps-notreceived.phtml
@@ -54,7 +54,7 @@ table thead tr th {background:#EBF2F6;color:#444;}
查看详细
接收
- 退回
+ 退回
上传申请表
重置申请表
diff --git a/application/module/Order/Event/ApplicationEvent.php b/application/module/Order/Event/ApplicationEvent.php
index 7865132f..b8031621 100644
--- a/application/module/Order/Event/ApplicationEvent.php
+++ b/application/module/Order/Event/ApplicationEvent.php
@@ -1,5 +1,5 @@
db->select();
+ $select ->from('offlineapp')
+ ->where('ts_approved is not null')
+ ->where('pdflink is not null')
+ ->where('status>=0')
+ ->order('ts_created desc');
+ if(!empty($this->keyword))
+ {
+ $select ->where(" (username LIKE '%{$this->keyword}%' OR
+ unit LIKE '%{$this->keyword}%' OR
+ project_id LIKE '%{$this->keyword}%' OR
+ project_type LIKE '%{$this->keyword}%' OR
+ project_leader LIKE '%{$this->keyword}%' OR
+ project LIKE '%{$this->keyword}%' )");
+ }
+
+ return $select;
}
}
\ No newline at end of file
From 3ef2748dd11c50d1a0f9d4a9084977fd0e7729a6 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Mon, 11 Nov 2013 02:53:34 +0000
Subject: [PATCH 038/126] =?UTF-8?q?Account=20controller=E4=BF=AE=E5=A4=8D?=
=?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E6=97=A0=E6=B3=95=E7=94=9F=E6=88=90?=
=?UTF-8?q?=E7=9A=84bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/default/controllers/AccountController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php
index 78487b85..fe8aa7ba 100755
--- a/application/default/controllers/AccountController.php
+++ b/application/default/controllers/AccountController.php
@@ -344,7 +344,7 @@ class AccountController extends Zend_Controller_Action
if(empty($captchaword))
{
- $this->setCaptcha($captchaword);
+ $this->setCaptcha($captcha);
$this->view->error = "请输入验证码";
return true;
}
From 6cd975a861433402e0eb72007133a69d52cbac18 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Mon, 11 Nov 2013 08:39:55 +0000
Subject: [PATCH 039/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=94=A8?=
=?UTF-8?q?=E6=88=B7=E6=B3=A8=E5=86=8C=E7=9A=84=E9=82=AE=E4=BB=B6=E6=A8=A1?=
=?UTF-8?q?=E6=9D=BF=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86?=
=?UTF-8?q?=E7=94=A8=E6=88=B7=E6=93=8D=E4=BD=9C=E7=9A=84=E7=B1=BB=E6=96=87?=
=?UTF-8?q?=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../default/controllers/AccountController.php | 89 ++---
application/module/Users/Account.php | 332 ++++++++++++++++++
application/module/Users/Event/EditEvent.php | 11 +
application/module/Users/Event/LoginEvent.php | 12 +
application/module/Users/Event/PwdEvent.php | 13 +
.../module/Users/Event/RegisterEvent.php | 13 +
application/module/Users/Gravatar.php | 20 ++
.../module/Users/Listener/AccountListener.php | 64 ++++
.../module/Users/Listener/EditListener.php | 35 ++
.../module/Users/Listener/PwdListener.php | 30 ++
application/module/Users/Member.php | 138 ++++++++
.../module/Users/Operation/EditOperate.php | 88 +++++
.../module/Users/Operation/LoginOperate.php | 111 ++++++
.../module/Users/Operation/PwdOperate.php | 94 +++++
.../Users/Operation/RegisterOperate.php | 192 ++++++++++
15 files changed, 1198 insertions(+), 44 deletions(-)
create mode 100644 application/module/Users/Account.php
create mode 100644 application/module/Users/Event/EditEvent.php
create mode 100644 application/module/Users/Event/LoginEvent.php
create mode 100644 application/module/Users/Event/PwdEvent.php
create mode 100644 application/module/Users/Event/RegisterEvent.php
create mode 100644 application/module/Users/Gravatar.php
create mode 100644 application/module/Users/Listener/AccountListener.php
create mode 100644 application/module/Users/Listener/EditListener.php
create mode 100644 application/module/Users/Listener/PwdListener.php
create mode 100644 application/module/Users/Member.php
create mode 100644 application/module/Users/Operation/EditOperate.php
create mode 100644 application/module/Users/Operation/LoginOperate.php
create mode 100644 application/module/Users/Operation/PwdOperate.php
create mode 100644 application/module/Users/Operation/RegisterOperate.php
diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php
index fe8aa7ba..60d8a07f 100755
--- a/application/default/controllers/AccountController.php
+++ b/application/default/controllers/AccountController.php
@@ -1,4 +1,7 @@
view->pageID = "account-secure";
- include_once("helper/view.php");
include_once("Users.php");
$usr = new Users($this->db);
@@ -261,17 +263,18 @@ 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->send();
+
+ //注册邮件
+ $mail_template = "users-register";
+ $mail_data = array(
+ 'name'=>$formData['username'],
+ );
+
+ $mail = new Mail();
+
+ $mail->loadTemplate($mail_template,$mail_data);
+ $mail->addTo($formData['email'],$formData['username']);
+ $mail->send();
//自动登录系统
$this->login($formData['username'],$formData['password']);
@@ -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
+ );
+
+ $mail = new Mail();
+
+ $mail->loadTemplate($mail_template,$mail_data);
+ $mail->addTo($formData['email'],$username);
+ $mail->send();
+
- 若想重置您的密码请打开下面的链接,否则请忽略此邮件,一切如常。
-";
- $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->send();
$this->view->messages[]='请检查您的新邮件中的确认激活链接。';
$this->view->form=false;//do not echo form
} else
@@ -567,22 +568,22 @@ 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->send();
- $this->view->messages[]='请查收您新邮件中的新密码';
- $this->view->form=false;//do not echo form
+
+ //发邮件
+ $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
}
}
diff --git a/application/module/Users/Account.php b/application/module/Users/Account.php
new file mode 100644
index 00000000..e692f95c
--- /dev/null
+++ b/application/module/Users/Account.php
@@ -0,0 +1,332 @@
+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;
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Users/Event/EditEvent.php b/application/module/Users/Event/EditEvent.php
new file mode 100644
index 00000000..99488769
--- /dev/null
+++ b/application/module/Users/Event/EditEvent.php
@@ -0,0 +1,11 @@
+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);
+ }
+
+}
diff --git a/application/module/Users/Listener/EditListener.php b/application/module/Users/Listener/EditListener.php
new file mode 100644
index 00000000..bcf2ce56
--- /dev/null
+++ b/application/module/Users/Listener/EditListener.php
@@ -0,0 +1,35 @@
+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)
+ {
+
+ }
+
+}
diff --git a/application/module/Users/Listener/PwdListener.php b/application/module/Users/Listener/PwdListener.php
new file mode 100644
index 00000000..c1afb947
--- /dev/null
+++ b/application/module/Users/Listener/PwdListener.php
@@ -0,0 +1,30 @@
+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)
+ {
+
+ }
+
+}
diff --git a/application/module/Users/Member.php b/application/module/Users/Member.php
new file mode 100644
index 00000000..fcb2bce2
--- /dev/null
+++ b/application/module/Users/Member.php
@@ -0,0 +1,138 @@
+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();
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Users/Operation/EditOperate.php b/application/module/Users/Operation/EditOperate.php
new file mode 100644
index 00000000..a31a1d71
--- /dev/null
+++ b/application/module/Users/Operation/EditOperate.php
@@ -0,0 +1,88 @@
+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;
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Users/Operation/LoginOperate.php b/application/module/Users/Operation/LoginOperate.php
new file mode 100644
index 00000000..7dd145f6
--- /dev/null
+++ b/application/module/Users/Operation/LoginOperate.php
@@ -0,0 +1,111 @@
+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'=>"您的密码或因安全原因或其他问题已经被重置,请先重置密码 再登陆",'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
+
+
+
+}
\ No newline at end of file
diff --git a/application/module/Users/Operation/PwdOperate.php b/application/module/Users/Operation/PwdOperate.php
new file mode 100644
index 00000000..ae87513f
--- /dev/null
+++ b/application/module/Users/Operation/PwdOperate.php
@@ -0,0 +1,94 @@
+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;
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Users/Operation/RegisterOperate.php b/application/module/Users/Operation/RegisterOperate.php
new file mode 100644
index 00000000..8bc1f3d1
--- /dev/null
+++ b/application/module/Users/Operation/RegisterOperate.php
@@ -0,0 +1,192 @@
+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'=>'您的用户名已经注册过账号,您是否忘记了密码? ','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 .= ' '.$v['title']. ' / ' .$v['realname'].' '.$text.'查看播放
';
+ }
+ }
+
+ return $content;
+ }//getMailContent();
+
+}
\ No newline at end of file
From 747b356901f04acd944770fedb220d45c3d2ac17 Mon Sep 17 00:00:00 2001
From: wlx
Date: Mon, 11 Nov 2013 10:02:29 +0000
Subject: [PATCH 040/126] change template name
---
application/default/controllers/AccountController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php
index 60d8a07f..fe979d13 100755
--- a/application/default/controllers/AccountController.php
+++ b/application/default/controllers/AccountController.php
@@ -265,7 +265,7 @@ class AccountController extends Zend_Controller_Action
if ($u->save()) {
//注册邮件
- $mail_template = "users-register";
+ $mail_template = "member-register-en";
$mail_data = array(
'name'=>$formData['username'],
);
From 9260c03a6083aea1cd2ef2b7ca506448f51b898a Mon Sep 17 00:00:00 2001
From: wlx
Date: Mon, 11 Nov 2013 10:06:03 +0000
Subject: [PATCH 041/126] change template name
---
application/default/controllers/AccountController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php
index fe979d13..2601283e 100755
--- a/application/default/controllers/AccountController.php
+++ b/application/default/controllers/AccountController.php
@@ -265,7 +265,7 @@ class AccountController extends Zend_Controller_Action
if ($u->save()) {
//注册邮件
- $mail_template = "member-register-en";
+ $mail_template = "member-register";
$mail_data = array(
'name'=>$formData['username'],
);
From d7eec24005839ce986d5a6d7979add6cb238744c Mon Sep 17 00:00:00 2001
From: wlx
Date: Tue, 12 Nov 2013 07:02:40 +0000
Subject: [PATCH 042/126] =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=95=B4=E7=90=86?=
=?UTF-8?q?=E7=9F=A5=E8=AF=86=E7=A7=AF=E7=B4=AF=E5=B9=B3=E5=8F=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../controllers/KnowledgeController.php | 147 +++++++++---------
.../views/scripts/knowledge/author.phtml | 29 ++--
.../views/scripts/knowledge/datacenter.phtml | 15 +-
.../views/scripts/knowledge/index.phtml | 48 +++---
.../views/scripts/knowledge/navi.phtml | 17 +-
.../views/scripts/knowledge/paper.phtml | 6 +-
.../views/scripts/knowledge/search-data.phtml | 23 +--
.../views/scripts/knowledge/user.phtml | 21 +--
.../views/scripts/knowledge/water.phtml | 56 +++++++
9 files changed, 211 insertions(+), 151 deletions(-)
create mode 100644 application/default/views/scripts/knowledge/water.phtml
diff --git a/application/default/controllers/KnowledgeController.php b/application/default/controllers/KnowledgeController.php
index dd6baa2e..4ed1b760 100755
--- a/application/default/controllers/KnowledgeController.php
+++ b/application/default/controllers/KnowledgeController.php
@@ -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,56 +26,72 @@ class KnowledgeController extends Zend_Controller_Action
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
+ function waterAction()
+ {
+ $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();
+ $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 userAction()
- {
- $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";
- $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";
- $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;
- }
+ {
+ $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 westplanAction()
- {
- $sql="select distinct array_to_string(array(select author from knl_author t where t.item_id=c.item_id order by place asc),'; ') as author,c.title,c.publisher,c.ts_created,c.ts_issued,c.item_id,c.url from knl_article c where c.url <>'' 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;
- }
- function searchAction()
- {
- $key=$this->_request->getParam('q');
- $source=$this->_request->getParam('searchsource');
- if(preg_match("/\"|'|<|>/",$key))
- {
- $data=array('<'=>'<','>'=>'>', "\'"=>'’', "\""=>'”');
+ 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 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;
+ }
- $patterns = array();
- $replacements = array();
+ function westplanAction()
+ {
+ $sql="select distinct array_to_string(array(select author from knl_author t where t.item_id=c.item_id order by place asc),'; ') as author,c.title,c.publisher,c.ts_created,c.ts_issued,c.item_id,c.url from knl_article c where c.url <>'' 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;
+ }
+
+ function searchAction()
+ {
+ $key=$this->_request->getParam('q');
+ $author = (int)$this->_request->getParam('author');
+ $source=$this->_request->getParam('searchsource');
+ if(preg_match("/\"|'|<|>/",$key))
+ {
+ $data=array('<'=>'<','>'=>'>', "\'"=>'’', "\""=>'”');
+ $patterns = array();
+ $replacements = array();
foreach($data as $k=>$v)
{
$patterns[]='/'.$k.'/i';
@@ -86,12 +102,15 @@ 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) {
+ $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)";
+ }
$sth = $this->db->prepare($sql);
- $sth->execute();
+ $sth->execute();
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
@@ -102,29 +121,13 @@ 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');
- $sql="select * from reference where id=$id";
+ $id = (int)$this->_request->getParam('id');
+ $sql="select * from reference where id=$id";
$sth = $this->db->prepare($sql);
$sth->execute();
$this->view->paper = $sth->fetch();
diff --git a/application/default/views/scripts/knowledge/author.phtml b/application/default/views/scripts/knowledge/author.phtml
index 88a92cf9..2ed61408 100644
--- a/application/default/views/scripts/knowledge/author.phtml
+++ b/application/default/views/scripts/knowledge/author.phtml
@@ -5,7 +5,7 @@ $this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/mdreview.css');
$this->breadcrumb('首页 ');
$this->breadcrumb('知识积累 ');
-$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');
-
数据作者文献库
+
作者推荐文献库
- paginator)): ?>
-
- paginator as $item): ?>
-
- 下载';
- endif;
+ paginator)): ?>
+
+ paginator as $item): ?>
+ 查看';
+ if (!empty($item['link'])) :
+ echo ' 下载 ';
+ else :
+ if (!empty($item['attid'])) echo ' 下载 ';
+ endif;
?>
- 相关数据
-
-
-
+
相关数据
+
+
+
= $this->paginator; ?>
diff --git a/application/default/views/scripts/knowledge/datacenter.phtml b/application/default/views/scripts/knowledge/datacenter.phtml
index afbf6bb9..d752644a 100644
--- a/application/default/views/scripts/knowledge/datacenter.phtml
+++ b/application/default/views/scripts/knowledge/datacenter.phtml
@@ -17,16 +17,19 @@ $this->breadcrumb()->setSeparator(' > ');
数据中心文献库
paginator)): ?>
-
+
paginator as $item): ?>
-
- 下载';
- endif;
+ 查看';
+ if (!empty($item['link'])) :
+ echo ' 下载 ';
+ else :
+ if (!empty($item['attid'])) echo ' 下载 ';
+ endif;
?>
-
+
= $this->paginator; ?>
diff --git a/application/default/views/scripts/knowledge/index.phtml b/application/default/views/scripts/knowledge/index.phtml
index 66596a82..a9765cbb 100755
--- a/application/default/views/scripts/knowledge/index.phtml
+++ b/application/default/views/scripts/knowledge/index.phtml
@@ -10,16 +10,6 @@ $this->breadcrumb()->setSeparator(' > ');
= $this->partial('knowledge/navi.phtml'); ?>
-
@@ -27,10 +17,32 @@ $this->breadcrumb()->setSeparator(' > ');
+
-
西部计划文献库
+
+
数据施引文献库
+
数据施引文献库是数据用户在使用科学数据后公开发表在科技期刊上的文献,由用户自发通知数据中心、数据作者收集和数据中心集中手机三种方式进行收集整理。
+
从数据用户的文献库中,可以挖掘出更多的知识,了解用户是如何使用数据中心提供的科学数据。数据作者也可以从其中获取到数据相关的趋势性知识。
+ 数据中心也欢迎用户提供更多的公开发表成果,我们将持续更新其内容,以满足数据的深层挖掘,实现学术信息进行搜索、发现、聚集和再组织。
+
查看 »
+
+
+
作者推荐文献库
+
作者推荐文献库是对发布在数据中心的科学数据的作者所推荐的和其数据相关的科技文献,主要是由数据作者发表的、和其数据紧密相关的科学文献。
+
用户可以通过数据作者的文献库中挖掘出对应的数据信息,实现从文献到数据的一个知识挖掘。将数据中心所有的数据作者文献构建一个和数据紧密相关的知识库,可以供用户更好的了解和发现数据和知识。
+ 支持用户对数据作者的学术信息进行搜索、发现、聚集和再组织。
+
查看 »
+
+
+
WATER文献库
+
WATER文献库是对由WATER项目所相关的科技文献,包括WATER项目自身发表的文献以及WATER数据用户所发表的文献。
+
用户可以通过WATER文献库中挖掘出对应的数据信息,实现从文献到数据的一个知识挖掘。将数据中心所有的数据作者文献构建一个和数据紧密相关的知识库,可以供用户更好的了解和发现数据和知识。
+ 支持用户对数据作者的学术信息进行搜索、发现、聚集和再组织。
+
查看 »
+
+
西部计划文献库
旨在发展和形成一个支持环境与生态科学领域开放学术信息的自助存档、交流和发现的领域知识平台。
首先,实现对国家自然科学基金委组织实施的“中国西部环境与生态科学研究计划”历年来所支持的研究项目和课题所产生的有重要科研和学术价值的知识产出进行统一组织和管理,
@@ -38,20 +50,6 @@ $this->breadcrumb()->setSeparator(' > ');
特别是对有重要学术影响的研究性数字知识库所涉及的环境与生态科学领域的学术信息进行搜索、发现、聚集和再组织。
查看 » 访问seekspace »
-
-
数据作者文献库
-
数据作者文献库是对发布在数据中心的科学数据中相关的参考文献,主要是由数据作者发表的、和其数据紧密相关的科学文献。
-
用户可以通过数据作者的文献库中挖掘出对应的数据信息,实现从文献到数据的一个知识挖掘。将数据中心所有的数据作者文献构建一个和数据紧密相关的知识库,可以供用户更好的了解和发现数据和知识。
- 支持用户对数据作者的学术信息进行搜索、发现、聚集和再组织。
-
查看 »
-
-
-
数据用户文献库
-
数据用户文献库是数据用户在使用科学数据后公开发表在科技期刊上的文献,由用户自发通知数据中心、数据作者收集和数据中心集中手机三种方式进行收集整理。
-
从数据用户的文献库中,可以挖掘出更多的知识,了解用户是如何使用数据中心提供的科学数据。数据作者也可以从其中获取到数据相关的趋势性知识。
- 数据中心也欢迎用户提供更多的公开发表成果,我们将持续更新其内容,以满足数据的深层挖掘,实现学术信息进行搜索、发现、聚集和再组织。
-
查看 »
-
‹
diff --git a/application/default/views/scripts/knowledge/navi.phtml b/application/default/views/scripts/knowledge/navi.phtml
index 5ddc4339..260138ad 100644
--- a/application/default/views/scripts/knowledge/navi.phtml
+++ b/application/default/views/scripts/knowledge/navi.phtml
@@ -1,25 +1,16 @@
diff --git a/application/default/views/scripts/knowledge/paper.phtml b/application/default/views/scripts/knowledge/paper.phtml
index a0fa71e8..a2990679 100644
--- a/application/default/views/scripts/knowledge/paper.phtml
+++ b/application/default/views/scripts/knowledge/paper.phtml
@@ -24,7 +24,7 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
作者
author as $a) : ?>
-
+ 【所有文章 】
@@ -71,7 +71,7 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
echo '
下载 ';
endif;
?>
-
相关数据(共? 条)
+
相关数据(共? 条)
@@ -79,7 +79,7 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
+
\ No newline at end of file
From 98985efc84d6201d94040f80eefc77fe131d7353 Mon Sep 17 00:00:00 2001
From: wlx
Date: Tue, 12 Nov 2013 12:35:12 +0000
Subject: [PATCH 043/126] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E4=BD=9C?=
=?UTF-8?q?=E8=80=85=E6=96=87=E7=AB=A0=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/default/controllers/KnowledgeController.php | 5 +++--
application/default/views/scripts/knowledge/paper.phtml | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/application/default/controllers/KnowledgeController.php b/application/default/controllers/KnowledgeController.php
index 4ed1b760..db750d94 100755
--- a/application/default/controllers/KnowledgeController.php
+++ b/application/default/controllers/KnowledgeController.php
@@ -86,6 +86,7 @@ class KnowledgeController extends Zend_Controller_Action
{
$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))
{
@@ -106,8 +107,8 @@ class KnowledgeController extends Zend_Controller_Action
$search=new SimpleSearch($key);
$where=$search->sql_expr(array("reference"));
$sql="select * from reference where ".$where." order by year desc, reference desc";
- } else if ($author) {
- $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)";
+ } 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();
diff --git a/application/default/views/scripts/knowledge/paper.phtml b/application/default/views/scripts/knowledge/paper.phtml
index a2990679..27313bf1 100644
--- a/application/default/views/scripts/knowledge/paper.phtml
+++ b/application/default/views/scripts/knowledge/paper.phtml
@@ -24,7 +24,7 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
作者
From 7acc24754dcef78c6e2165b2d634c06cd4f34995 Mon Sep 17 00:00:00 2001
From: wlx
Date: Tue, 12 Nov 2013 13:09:02 +0000
Subject: [PATCH 044/126] change literature view
---
.../default/views/scripts/data/view.phtml | 46 +++++++++++++++----
.../default/views/scripts/heihe/view.phtml | 43 +++++++++++++----
.../default/views/scripts/hiwater/view.phtml | 43 +++++++++++++----
3 files changed, 104 insertions(+), 28 deletions(-)
diff --git a/application/default/views/scripts/data/view.phtml b/application/default/views/scripts/data/view.phtml
index 696e39ed..88c54e7c 100755
--- a/application/default/views/scripts/data/view.phtml
+++ b/application/default/views/scripts/data/view.phtml
@@ -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;}
+= $this->render('breadcrumbs.phtml'); ?>
metadata;if ($md):?>
escape($md->title);
if ($md->title_en) echo ' '.$this->escape($md->title_en);?>
@@ -48,31 +49,56 @@ if ($md->title_en) echo ' '.$this->escape($md->title_en);?>
?> (下载引用:RIS格式 | RIS英文格式 | Bibtex格式 | Bibtex英文格式 )
ref) : ?>
- 建议参考文献
+ 相关文献(作者推荐)
ref as $ref) :
- echo ''.$ref->reference;
+ echo ' '.$ref->reference;
+ echo ' 查看 ';
if (empty($ref->link))
{
- if(!empty($ref->attid))
+ if(!empty($ref->attid))
echo ' 下载 ';
+ }else{
+ echo ' 下载 ';
+ }
+ echo " ";
+ endforeach;
+ ?>
+
+ themeref) :?>
+
+
+ 专题文献
+
+ themeref as $ref) :
+ echo ''.$ref->reference;
+ echo ' 查看 ';
+ if (empty($ref->link))
+ {
+ if(!empty($ref->attid))
+ echo ' | 下载 ';
}else{
- echo ' 下载 ';
+ echo ' | 下载 ';
}
echo " ";
endforeach;
?>
-
- userref) : ?>
+ userref) : ?>
- 数据用户发表文献
+ 数据施引文献
userref as $ref) :
+ echo ''.$ref->reference;
+ echo ' 查看 ';
if (empty($ref->link))
- echo ' '.$ref->reference.' ';
- else
- echo ''.$ref->reference.' 下载 ';
+ {
+ if(!empty($ref->attid))
+ echo ' 下载 ';
+ }else{
+ echo ' 下载 ';
+ }
+ echo "";
endforeach;
?>
diff --git a/application/default/views/scripts/heihe/view.phtml b/application/default/views/scripts/heihe/view.phtml
index 23b3a51b..7e752c00 100755
--- a/application/default/views/scripts/heihe/view.phtml
+++ b/application/default/views/scripts/heihe/view.phtml
@@ -71,31 +71,56 @@ if ($md->title_en) echo ' '.$this->escape($md->title_en);?>
?> (下载引用:RIS格式 | RIS英文格式 | Bibtex格式 | Bibtex英文格式 )
ref) : ?>
- 建议参考文献
+ 相关文献(作者推荐)
ref as $ref) :
echo ''.$ref->reference;
+ echo ' 查看 ';
if (empty($ref->link))
{
- if(!empty($ref->attid))
+ if(!empty($ref->attid))
echo ' 下载 ';
+ }else{
+ echo ' 下载 ';
+ }
+ echo " ";
+ endforeach;
+ ?>
+
+ themeref) :?>
+
+
+ 专题文献
+
+ themeref as $ref) :
+ echo ''.$ref->reference;
+ echo ' 查看 ';
+ if (empty($ref->link))
+ {
+ if(!empty($ref->attid))
+ echo ' | 下载 ';
}else{
- echo ' 下载 ';
+ echo ' | 下载 ';
}
echo " ";
endforeach;
?>
-
- userref) : ?>
+ userref) : ?>
- 数据用户发表文献
+ 数据施引文献
userref as $ref) :
+ echo ''.$ref->reference;
+ echo ' 查看 ';
if (empty($ref->link))
- echo ' '.$ref->reference.' ';
- else
- echo ''.$ref->reference.' 下载 ';
+ {
+ if(!empty($ref->attid))
+ echo ' 下载 ';
+ }else{
+ echo ' 下载 ';
+ }
+ echo "";
endforeach;
?>
diff --git a/application/default/views/scripts/hiwater/view.phtml b/application/default/views/scripts/hiwater/view.phtml
index e69fd7d8..2330ecdc 100644
--- a/application/default/views/scripts/hiwater/view.phtml
+++ b/application/default/views/scripts/hiwater/view.phtml
@@ -69,31 +69,56 @@ if ($md->title_en) echo ' '.$this->escape($md->title_en);?>
?> (下载引用:RIS格式 | RIS英文格式 | Bibtex格式 | Bibtex英文格式 )
ref) : ?>
- 建议参考文献
+ 相关文献(作者推荐)
ref as $ref) :
echo ''.$ref->reference;
+ echo ' 查看 ';
if (empty($ref->link))
{
- if(!empty($ref->attid))
+ if(!empty($ref->attid))
echo ' 下载 ';
+ }else{
+ echo ' 下载 ';
+ }
+ echo " ";
+ endforeach;
+ ?>
+
+ themeref) :?>
+
+
+ 专题文献
+
+ themeref as $ref) :
+ echo ''.$ref->reference;
+ echo ' 查看 ';
+ if (empty($ref->link))
+ {
+ if(!empty($ref->attid))
+ echo ' | 下载 ';
}else{
- echo ' 下载 ';
+ echo ' | 下载 ';
}
echo " ";
endforeach;
?>
-
- userref) : ?>
+ userref) : ?>
- 数据用户发表文献
+ 数据施引文献
userref as $ref) :
+ echo ''.$ref->reference;
+ echo ' 查看 ';
if (empty($ref->link))
- echo ' '.$ref->reference.' ';
- else
- echo ''.$ref->reference.' 下载 ';
+ {
+ if(!empty($ref->attid))
+ echo ' 下载 ';
+ }else{
+ echo ' 下载 ';
+ }
+ echo "";
endforeach;
?>
From 7a36469b62ed3d65b409be1887aff623afd30feb Mon Sep 17 00:00:00 2001
From: wlx
Date: Wed, 13 Nov 2013 18:16:31 +0000
Subject: [PATCH 045/126] =?UTF-8?q?=E5=8C=BA=E5=88=86=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E4=B8=AD=E5=BF=83=E7=9A=84=E6=96=BD=E5=BC=95=E6=96=87=E7=8C=AE?=
=?UTF-8?q?=E5=B1=95=E7=A4=BA=E6=96=B9=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/default/views/scripts/knowledge/datacenter.phtml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/application/default/views/scripts/knowledge/datacenter.phtml b/application/default/views/scripts/knowledge/datacenter.phtml
index d752644a..29ec7c29 100644
--- a/application/default/views/scripts/knowledge/datacenter.phtml
+++ b/application/default/views/scripts/knowledge/datacenter.phtml
@@ -19,7 +19,9 @@ $this->breadcrumb()->setSeparator(' > ');
paginator)): ?>
paginator as $item): ?>
- 数据中心施引文献';
+ echo $item['reference'];
echo ' 查看 ';
if (!empty($item['link'])) :
echo ' 下载 ';
From 24f253c027be1118a75293e3da477e4ce63c09c6 Mon Sep 17 00:00:00 2001
From: wlx
Date: Wed, 13 Nov 2013 18:24:53 +0000
Subject: [PATCH 046/126] fix single author problem
---
application/default/views/scripts/knowledge/paper.phtml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/application/default/views/scripts/knowledge/paper.phtml b/application/default/views/scripts/knowledge/paper.phtml
index 27313bf1..354555fa 100644
--- a/application/default/views/scripts/knowledge/paper.phtml
+++ b/application/default/views/scripts/knowledge/paper.phtml
@@ -20,7 +20,7 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
paper['title']; ?>
- author) > 0) {?>
+ author) : ?>
作者
author as $a) : ?>
@@ -28,7 +28,7 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
-
+
paper['abstract']){ ?>
摘要
From 2eda7023620a0db9f015d963a998323abd8f73aa Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Thu, 14 Nov 2013 02:49:15 +0000
Subject: [PATCH 047/126] =?UTF-8?q?#563=20=E4=BF=AE=E6=94=B9=E4=BA=86?=
=?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=97=B6=E5=8D=95=E4=B8=AAauthor=E7=9A=84bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Reference/Ris.php | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/application/module/Reference/Ris.php b/application/module/Reference/Ris.php
index c9432ddd..7e30ef73 100644
--- a/application/module/Reference/Ris.php
+++ b/application/module/Reference/Ris.php
@@ -174,10 +174,8 @@ class Ris
$results = $this->events()->trigger('checkLoad', $this, compact('ref'));
$id = $results->bottom();
-
-
if ($id > 0)
- {
+ {
$this->unsetVar($ref);
$this->events()->trigger('deleteAuthor', $this, compact('id'));
$this->events()->trigger('deleteTag', $this, compact('id'));
@@ -185,8 +183,8 @@ class Ris
unset($ref['reference']);
$dbh->update($this->table->reference,$ref," id=$id ");
- } else {
- $ref['reference'] = $this->makeReferenceFlag($ref);
+ } else {
+ $ref['reference'] = $this->makeReferenceFlag($ref);
$this->unsetVar($ref);
$id = $dbh->insert($this->table->reference,$ref,true);
}
@@ -261,6 +259,11 @@ class Ris
}
return true;
}else{
+ if(is_string($author))
+ {
+ $author_splited = $this->splitAuthor($author);
+ $this->dbh->insert($this->table->reference_author,array('id'=>$id , 'lastname'=>$author_splited['lastname'] , 'firstname'=>$author_splited['firstname'] , 'place'=>0 ));
+ }
return false;
}
}
@@ -275,7 +278,7 @@ class Ris
//创建reference 字段
public function makeReferenceFlag($ref){
$str = join(', ',$ref['author']).'. ';
- $str .= $ref['title'].'. ';
+ $str .= $ref['title'].'. ';
$str .= $ref['publisher'].', ';
isset($ref['year']) ? $str .= $ref['year'].', ':"";
isset($ref['volume']) ? $str .= $ref['volume']:"";
From 1c147a88c283596ef5bf198f1d5445cf5c6110a4 Mon Sep 17 00:00:00 2001
From: wlx
Date: Thu, 14 Nov 2013 06:45:21 +0000
Subject: [PATCH 048/126] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=90=8E=E5=8F=B0?=
=?UTF-8?q?=E7=BC=96=E8=BE=91=E7=A6=BB=E7=BA=BF=E8=AE=B0=E5=BD=95=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=EF=BC=88=E8=A1=A5=E5=85=85=E9=A1=B9=E7=9B=AE=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admin/controllers/DownController.php | 11 ++++++++---
application/models/OfflinelogForm.php | 19 ++++++++++++++++++-
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/application/admin/controllers/DownController.php b/application/admin/controllers/DownController.php
index f7d06304..95da2e30 100644
--- a/application/admin/controllers/DownController.php
+++ b/application/admin/controllers/DownController.php
@@ -875,8 +875,10 @@ class Admin_DownController extends Zend_Controller_Action
if ($form->isValid($formdata)) {
$uploadedData = $form->getValues();
$pdf = basename($form->pdf->getFileName());
- $sql="insert into offlineapp (username,email,unit,phone,address,postcode,project,pdflink,datalist,ts_created,ts_approved) values(?,?,?,?,?,?,?,?,?,?,now())";
- $this->db->query($sql,array($formdata['username'],$formdata['email'],$formdata['unit'],$formdata['phone'],$formdata['address'],$formdata['postcode'],$formdata['project'],$pdf,$formdata['datalist'],$formdata['ts_approved']));
+ $sql="insert into offlineapp (username,email,unit,phone,address,postcode,project,pdflink,datalist,ts_created,ts_approved,project_id,project_title,project_type) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ $this->db->query($sql,array($formdata['username'],$formdata['email'],$formdata['unit'],$formdata['phone'],$formdata['address'],$formdata['postcode'],
+ $formdata['project'],$pdf,$formdata['datalist'],$formdata['ts_approved']),$formdata['ts_approved'],
+ $formdata['project_id'],$formdata['project_title'],$formdata['project_type']);
$this->messenger->addMessage('提示信息:您已经成功添加该离线服务记录。');
$this->_redirect('/admin/down/offline');
} else {
@@ -897,11 +899,14 @@ class Admin_DownController extends Zend_Controller_Action
$pdf = basename($form->pdf->getFileName());
$sql="update offlineapp set username=?,email=?,unit=?,phone=?,address=?,postcode=?,project=?,";
if ($form->pdf->isUploaded()) $sql.="pdflink=?,";
- $sql.="datalist=?,ts_approved=? where id=?";
+ $sql.="datalist=?,ts_approved=?,project_id=?,project_title=?,project_type=? where id=?";
$param=array($formdata['username'],$formdata['email'],$formdata['unit'],$formdata['phone'],$formdata['address'],$formdata['postcode'],$formdata['project']);
if ($form->pdf->isUploaded()) $param[]=$pdf;
$param[]=$formdata['datalist'];
$param[]=$formdata['ts_approved'];
+ $param[]=$formdata['project_id'];
+ $param[]=$formdata['project_title'];
+ $param[]=$formdata['project_type'];
$param[]=$edit;
$this->db->query($sql,$param);
$this->messenger->addMessage('提示信息:您已经编辑添加该记录。');
diff --git a/application/models/OfflinelogForm.php b/application/models/OfflinelogForm.php
index 7ef2ca87..6e9150c6 100644
--- a/application/models/OfflinelogForm.php
+++ b/application/models/OfflinelogForm.php
@@ -26,6 +26,23 @@ class OfflinelogForm extends Zend_Form
$address->setLabel('联系地址')->setRequired(true);
$project=new Zend_Form_Element_Textarea('project');
$project->setLabel('用途')->setRequired(true)->setAttrib('rows',2);
+ $project_id=new Zend_Form_Element_Text('project_id');
+ $project_id->setLabel('项目编号');
+ $project_title=new Zend_Form_Element_Text('project_title');
+ $project_title->setLabel('项目名称');
+ $project_type=new Zend_Form_Element_Select('project_type');
+ $project_type->setLabel('项目类型');
+ $project_type->addMultiOption('','请选择项目类型');
+ $project_type->addMultiOption('国家973计划项目课题','国家973计划项目课题');
+ $project_type->addMultiOption('国家863计划课题','国家863计划课题');
+ $project_type->addMultiOption('国家级科技支撑课题','国家级科技支撑课题');
+ $project_type->addMultiOption('国家级科技重大专项','国家级科技重大专项');
+ $project_type->addMultiOption('国家级国家重大工程','国家级国家重大工程');
+ $project_type->addMultiOption('国家级国家自然科学基金','国家级国家自然科学基金');
+ $project_type->addMultiOption('国际合作项目','国际合作项目');
+ $project_type->addMultiOption('省部级项目','省部级项目');
+ $project_type->addMultiOption('其他项目工程','其他项目工程');
+
$datalist=new Zend_Form_Element_Textarea('datalist');
$datalist->setLabel('数据清单')->setRequired(true)->setAttrib('rows',2);
$pdf=new Zend_Form_Element_File('pdf');
@@ -42,6 +59,6 @@ class OfflinelogForm extends Zend_Form
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton')->setLabel('添加');
$this->setAttrib('enctype', 'multipart/form-data');
- $this->addElements(array($username,$email,$phone,$unit,$address,$postcode,$pdf,$ts_approved,$project,$datalist,$id,$submit));
+ $this->addElements(array($username,$email,$phone,$unit,$address,$postcode,$pdf,$ts_approved,$project_id,$project_title,$project_type,$project,$datalist,$id,$submit));
}
}
\ No newline at end of file
From 2ca99a2de33bce520533f227b1fe08422b4237d2 Mon Sep 17 00:00:00 2001
From: wlx
Date: Fri, 15 Nov 2013 02:31:03 +0000
Subject: [PATCH 049/126] fix spell error
---
application/module/Order/Manager/Offlineapp.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/module/Order/Manager/Offlineapp.php b/application/module/Order/Manager/Offlineapp.php
index 74325e73..099692d2 100644
--- a/application/module/Order/Manager/Offlineapp.php
+++ b/application/module/Order/Manager/Offlineapp.php
@@ -3,7 +3,7 @@ namespace Order\Manager;
use Helpers\View as view;
use Helpers\dbh;
-use Order\listener\ManagerListener;
+use Order\Listener\ManagerListener;
class Offlineapp
{
From beb002b6487e9d636cf7483eae4f727621cbcabc Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Fri, 15 Nov 2013 03:44:52 +0000
Subject: [PATCH 050/126] =?UTF-8?q?=E4=B8=BACurl=E7=B1=BB=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89=E5=A4=B4=E4=BF=A1=E6=81=AF?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Helpers/Curl.php | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/application/module/Helpers/Curl.php b/application/module/Helpers/Curl.php
index bc819575..dea71661 100644
--- a/application/module/Helpers/Curl.php
+++ b/application/module/Helpers/Curl.php
@@ -16,6 +16,8 @@ class Curl
'verifyssl' => true,
), $options);
}
+
+ public $H;
/**
* Send a request to the server, receive a response
@@ -69,6 +71,11 @@ class Curl
} else {
$headers[] = 'Content-Length: 0';
}
+
+ if(!empty($this->H) && is_array($this->H) && count($this->H) > 0)
+ {
+ $headers = array_merge($headers,$this->H);
+ }
$this->debug('send '.$httpMethod.' request: '.$url);
From 1ccb1300b0262470e21d0289eac89bea8094f432 Mon Sep 17 00:00:00 2001
From: wlx
Date: Fri, 15 Nov 2013 14:41:56 +0000
Subject: [PATCH 051/126] add ris download function for literatures
---
application/default/controllers/ServiceController.php | 6 ++++++
application/default/views/scripts/knowledge/paper.phtml | 3 +++
2 files changed, 9 insertions(+)
diff --git a/application/default/controllers/ServiceController.php b/application/default/controllers/ServiceController.php
index 8d2c5af4..4654666a 100644
--- a/application/default/controllers/ServiceController.php
+++ b/application/default/controllers/ServiceController.php
@@ -1667,6 +1667,8 @@ class ServiceController extends Zend_Controller_Action
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$uuid=$this->_request->getParam('uuid');
+ //文献id
+ $id=(int)$this->_request->getParam('id');
$lang=$this->_request->getParam('lang');
$ris='';
if ($lang=='cn' && !empty($uuid))
@@ -1708,6 +1710,10 @@ class ServiceController extends Zend_Controller_Action
$ris.='M3 - doi:'.$row['doi']."\r\n";
$ris.='DO - doi:'.$row['doi']."\r\n";
$ris.='ER -'."\r\n";
+ } else if ($id) {
+ $sql="select ris from reference where id=$id";
+ $row=$this->db->fetchRow($sql);
+ $ris=$row['ris'];
}
if (!empty($ris))
{
diff --git a/application/default/views/scripts/knowledge/paper.phtml b/application/default/views/scripts/knowledge/paper.phtml
index 354555fa..d457fdb6 100644
--- a/application/default/views/scripts/knowledge/paper.phtml
+++ b/application/default/views/scripts/knowledge/paper.phtml
@@ -70,6 +70,9 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
if (!empty($item['link'])) :
echo ' 下载 ';
endif;
+ if (!empty($item['ris'])) :
+ echo ' RIS下载 ';
+ endif;
?>
相关数据(共? 条)
From 2bc695660bb3228ba3e55c816c16eb872775d28f Mon Sep 17 00:00:00 2001
From: wlx
Date: Fri, 15 Nov 2013 14:46:28 +0000
Subject: [PATCH 052/126] fix var error
---
.../default/views/scripts/knowledge/paper.phtml | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/application/default/views/scripts/knowledge/paper.phtml b/application/default/views/scripts/knowledge/paper.phtml
index d457fdb6..eabc28df 100644
--- a/application/default/views/scripts/knowledge/paper.phtml
+++ b/application/default/views/scripts/knowledge/paper.phtml
@@ -65,13 +65,9 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
}else{
echo ' PDF下载 ';
}
-
-
- if (!empty($item['link'])) :
- echo ' 下载 ';
- endif;
- if (!empty($item['ris'])) :
- echo ' RIS下载 ';
+
+ if (!empty($this->paper['ris'])) :
+ echo ' RIS下载 ';
endif;
?>
相关数据(共? 条)
From 9512051737b5eb391b28b4e62c3ee636feed7f9c Mon Sep 17 00:00:00 2001
From: wlx
Date: Fri, 15 Nov 2013 14:47:36 +0000
Subject: [PATCH 053/126] add css
---
application/default/views/scripts/knowledge/paper.phtml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/default/views/scripts/knowledge/paper.phtml b/application/default/views/scripts/knowledge/paper.phtml
index eabc28df..e629b8bd 100644
--- a/application/default/views/scripts/knowledge/paper.phtml
+++ b/application/default/views/scripts/knowledge/paper.phtml
@@ -67,7 +67,7 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
}
if (!empty($this->paper['ris'])) :
- echo ' RIS下载 ';
+ echo ' RIS下载 ';
endif;
?>
相关数据(共? 条)
From cd8fe1ca8788da0776461b1a18fcfeaf93688908 Mon Sep 17 00:00:00 2001
From: wlx
Date: Sat, 16 Nov 2013 07:43:30 +0000
Subject: [PATCH 054/126] fix single author could generate reference problem.
---
application/module/Reference/Ris.php | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/application/module/Reference/Ris.php b/application/module/Reference/Ris.php
index 7e30ef73..5b6ff16d 100644
--- a/application/module/Reference/Ris.php
+++ b/application/module/Reference/Ris.php
@@ -277,7 +277,13 @@ class Ris
//创建reference 字段
public function makeReferenceFlag($ref){
- $str = join(', ',$ref['author']).'. ';
+ $str='';
+ if(is_array($author) && count($author) > 0)
+ {
+ $str .= join(', ',$ref['author']).'. ';
+ } else if if(is_string($author)) {
+ $str .= $ref['author'].'. ';
+ }
$str .= $ref['title'].'. ';
$str .= $ref['publisher'].', ';
isset($ref['year']) ? $str .= $ref['year'].', ':"";
From 5de71572bbefe57217d4b5be61992555c65d8e38 Mon Sep 17 00:00:00 2001
From: wlx
Date: Sat, 16 Nov 2013 11:14:45 +0000
Subject: [PATCH 055/126] =?UTF-8?q?=E6=9C=89=E6=95=B0=E6=8D=AE=E4=BD=9C?=
=?UTF-8?q?=E8=80=85=E6=89=8D=E5=8F=91=E4=BF=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/admin/controllers/ReviewController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/admin/controllers/ReviewController.php b/application/admin/controllers/ReviewController.php
index 001217bf..5d43ef71 100644
--- a/application/admin/controllers/ReviewController.php
+++ b/application/admin/controllers/ReviewController.php
@@ -761,7 +761,7 @@ class Admin_ReviewController extends Zend_Controller_Action
if (is_numeric($ids))
{
$sql="select distinct u.email,m.title,m.uuid from mdstatus s left join metadata m on s.uuid=m.uuid
- left join mdauthor a on s.uuid=a.uuid left join users u on a.userid=u.id where s.id=? order by u.email";
+ right join mdauthor a on s.uuid=a.uuid left join users u on a.userid=u.id where s.id=? order by u.email";
$rs=$this->db->query($sql,array($ids));
$rows=$rs->fetchAll();
if ($rows)
From ff2c52cfebea4d51ede7d08e331489327bec6da5 Mon Sep 17 00:00:00 2001
From: wlx
Date: Sat, 16 Nov 2013 11:28:50 +0000
Subject: [PATCH 056/126] fix spell error
---
application/module/Reference/Ris.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/module/Reference/Ris.php b/application/module/Reference/Ris.php
index 5b6ff16d..cc69cf94 100644
--- a/application/module/Reference/Ris.php
+++ b/application/module/Reference/Ris.php
@@ -281,7 +281,7 @@ class Ris
if(is_array($author) && count($author) > 0)
{
$str .= join(', ',$ref['author']).'. ';
- } else if if(is_string($author)) {
+ } else if (is_string($author)) {
$str .= $ref['author'].'. ';
}
$str .= $ref['title'].'. ';
From afd7f13418730ebcb24e4bd982f04cea3f1daa6f Mon Sep 17 00:00:00 2001
From: wlx
Date: Sun, 17 Nov 2013 12:07:15 +0000
Subject: [PATCH 057/126] fix problem when generate the reference
---
application/module/Reference/Ris.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/module/Reference/Ris.php b/application/module/Reference/Ris.php
index cc69cf94..4b27adc5 100644
--- a/application/module/Reference/Ris.php
+++ b/application/module/Reference/Ris.php
@@ -278,7 +278,7 @@ class Ris
//创建reference 字段
public function makeReferenceFlag($ref){
$str='';
- if(is_array($author) && count($author) > 0)
+ if(is_array($ref['author']) && count($ref['author']) > 0)
{
$str .= join(', ',$ref['author']).'. ';
} else if (is_string($author)) {
From 69d3a94ef808f9356ef58032b0887ce9b79add35 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Tue, 19 Nov 2013 01:56:39 +0000
Subject: [PATCH 058/126] =?UTF-8?q?#566=20=E4=BF=AE=E6=94=B9=E6=9F=A5?=
=?UTF-8?q?=E9=87=8D=E6=97=B6=E7=9A=84=E5=8D=95=E5=BC=95=E5=8F=B7bug?=
=?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9Ris=E5=AF=BC=E5=85=A5=E6=97=B6?=
=?UTF-8?q?=E4=BD=9C=E8=80=85=E4=B8=BA=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=97=B6?=
=?UTF-8?q?=E5=8F=91=E7=94=9F=E9=94=99=E8=AF=AF=E7=9A=84bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Reference/Handler/RisHandler.php | 7 ++++++-
application/module/Reference/Ris.php | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/application/module/Reference/Handler/RisHandler.php b/application/module/Reference/Handler/RisHandler.php
index 9de4d5d0..8a820795 100644
--- a/application/module/Reference/Handler/RisHandler.php
+++ b/application/module/Reference/Handler/RisHandler.php
@@ -36,9 +36,14 @@ class RisHandler implements \Reference\Event\RisEvent
$wheresql = array();
+ if(preg_match("/\'/",$ref['title']))
+ {
+ $ref['title'] = preg_replace("/\'/","''",$ref['title']);
+ }
+
$wheresql[] = " lower(title)=lower('{$ref['title']}') ";
$wheresql[] = " year='{$ref['year']}' ";
-
+
//暂时不使用期刊限制
/*if(isset($ref['publisher']))
{
diff --git a/application/module/Reference/Ris.php b/application/module/Reference/Ris.php
index 4b27adc5..72da0dc3 100644
--- a/application/module/Reference/Ris.php
+++ b/application/module/Reference/Ris.php
@@ -281,7 +281,7 @@ class Ris
if(is_array($ref['author']) && count($ref['author']) > 0)
{
$str .= join(', ',$ref['author']).'. ';
- } else if (is_string($author)) {
+ } else if (is_string($ref['author'])) {
$str .= $ref['author'].'. ';
}
$str .= $ref['title'].'. ';
From 1edecd120a721c7bd202f88dfb20a3381aed2fe3 Mon Sep 17 00:00:00 2001
From: wlx
Date: Wed, 20 Nov 2013 09:50:41 +0000
Subject: [PATCH 059/126] =?UTF-8?q?fix=20#567,=20=E9=99=90=E5=AE=9A?=
=?UTF-8?q?=E6=96=BD=E5=BC=95=E6=96=87=E7=8C=AE=E7=9A=84=E6=98=BE=E7=A4=BA?=
=?UTF-8?q?=E6=95=B0=E9=87=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/default/controllers/DataController.php | 2 +-
.../default/controllers/KnowledgeController.php | 11 ++++++++++-
application/default/views/scripts/data/view.phtml | 4 ++++
application/default/views/scripts/heihe/view.phtml | 4 ++++
application/default/views/scripts/hiwater/view.phtml | 4 ++++
.../default/views/scripts/knowledge/user.phtml | 6 +++++-
application/default/views/scripts/water/view.phtml | 4 ++++
7 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php
index 5768028c..1e34826e 100755
--- a/application/default/controllers/DataController.php
+++ b/application/default/controllers/DataController.php
@@ -618,7 +618,7 @@ class DataController extends Zend_Controller_Action
$sql=$this->db->quoteInto($sql,$uuid);
$this->view->themeref=$this->db->fetchAll($sql);
//用户发表文献
- $sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=? and m.reftype=1";
+ $sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=? and m.reftype=1 order by r.language asc,r.year desc,r.ts_created desc limit 15";
$sql=$this->db->quoteInto($sql,$uuid);
$this->view->userref=$this->db->fetchAll($sql);
//多篇引用形式:hiwater
diff --git a/application/default/controllers/KnowledgeController.php b/application/default/controllers/KnowledgeController.php
index db750d94..9e76286c 100755
--- a/application/default/controllers/KnowledgeController.php
+++ b/application/default/controllers/KnowledgeController.php
@@ -42,7 +42,16 @@ class KnowledgeController extends Zend_Controller_Action
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";
+ $uuid=$this->_request->getParam('uuid');
+ if (preg_match('/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/',$uuid))
+ {
+ $sql="select uuid,title from metadata where uuid='$uuid'";
+ $sth = $this->db->prepare($sql);
+ $sth->execute();
+ $this->view->md = $sth->fetch();
+ $sql="select * from reference where id in (select refid from mdref where reftype=1 and uuid='$uuid') order by year desc, reference desc";
+ } else
+ $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();
diff --git a/application/default/views/scripts/data/view.phtml b/application/default/views/scripts/data/view.phtml
index 88c54e7c..6e60839d 100755
--- a/application/default/views/scripts/data/view.phtml
+++ b/application/default/views/scripts/data/view.phtml
@@ -100,6 +100,10 @@ if ($md->title_en) echo ' '.$this->escape($md->title_en);?>
}
echo " ";
endforeach;
+ if (count($this->userref)==15)
+ {
+ echo ' 更多施引文献 ';
+ }
?>
diff --git a/application/default/views/scripts/heihe/view.phtml b/application/default/views/scripts/heihe/view.phtml
index 7e752c00..5136e386 100755
--- a/application/default/views/scripts/heihe/view.phtml
+++ b/application/default/views/scripts/heihe/view.phtml
@@ -122,6 +122,10 @@ if ($md->title_en) echo ' '.$this->escape($md->title_en);?>
}
echo "";
endforeach;
+ if (count($this->userref)==15)
+ {
+ echo ' 更多施引文献 ';
+ }
?>
diff --git a/application/default/views/scripts/hiwater/view.phtml b/application/default/views/scripts/hiwater/view.phtml
index 2330ecdc..5a8a2783 100644
--- a/application/default/views/scripts/hiwater/view.phtml
+++ b/application/default/views/scripts/hiwater/view.phtml
@@ -120,6 +120,10 @@ if ($md->title_en) echo ' '.$this->escape($md->title_en);?>
}
echo "";
endforeach;
+ if (count($this->userref)==15)
+ {
+ echo ' 更多施引文献 ';
+ }
?>
diff --git a/application/default/views/scripts/knowledge/user.phtml b/application/default/views/scripts/knowledge/user.phtml
index 08bceb34..d30d8d99 100644
--- a/application/default/views/scripts/knowledge/user.phtml
+++ b/application/default/views/scripts/knowledge/user.phtml
@@ -16,7 +16,11 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
-
数据施引文献库
+
数据施引文献库
+ md) :
+ echo '
';
+ endif;
+ ?>
paginator)): ?>
diff --git a/application/default/views/scripts/water/view.phtml b/application/default/views/scripts/water/view.phtml
index db5ab149..a548d2bb 100755
--- a/application/default/views/scripts/water/view.phtml
+++ b/application/default/views/scripts/water/view.phtml
@@ -101,6 +101,10 @@ h3.gs_rt{font-size:110%;}
}
echo "";
endforeach;
+ if (count($this->userref)==15)
+ {
+ echo ' 更多施引文献 ';
+ }
?>
From 6d5397273e9445b9cb801626d761891d71a69534 Mon Sep 17 00:00:00 2001
From: wlx
Date: Wed, 20 Nov 2013 09:53:33 +0000
Subject: [PATCH 060/126] =?UTF-8?q?=E4=B8=8D=E9=99=90=E5=88=B6heihe?=
=?UTF-8?q?=E4=B8=8A=E7=9A=84order=E9=A1=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Order/Mount/OrderOperate.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/module/Order/Mount/OrderOperate.php b/application/module/Order/Mount/OrderOperate.php
index 31b528e1..dac905c9 100644
--- a/application/module/Order/Mount/OrderOperate.php
+++ b/application/module/Order/Mount/OrderOperate.php
@@ -11,7 +11,7 @@ class OrderOperate implements \Order\Listener\OrderEvents
//!!!!!!important!!!!!
//不同项目使用时是否要修改此项??
- public $tbl_metadata = "heihemetadata";
+ public $tbl_metadata = "normalmetadata";
public $tbl_dataorder = "dataorder";
function __construct($db = NULL)
From 1c3075584e671d6f24217dcb81de8da37ec4c2b3 Mon Sep 17 00:00:00 2001
From: wlx
Date: Wed, 20 Nov 2013 10:10:18 +0000
Subject: [PATCH 061/126] change link css
---
application/default/views/scripts/data/view.phtml | 2 +-
application/default/views/scripts/heihe/view.phtml | 2 +-
application/default/views/scripts/hiwater/view.phtml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/application/default/views/scripts/data/view.phtml b/application/default/views/scripts/data/view.phtml
index 6e60839d..99e7d8b8 100755
--- a/application/default/views/scripts/data/view.phtml
+++ b/application/default/views/scripts/data/view.phtml
@@ -102,7 +102,7 @@ if ($md->title_en) echo ' '.$this->escape($md->title_en);?>
endforeach;
if (count($this->userref)==15)
{
- echo ' 更多施引文献 ';
+ echo ' 更多施引文献 ';
}
?>
diff --git a/application/default/views/scripts/heihe/view.phtml b/application/default/views/scripts/heihe/view.phtml
index 5136e386..ba55b71c 100755
--- a/application/default/views/scripts/heihe/view.phtml
+++ b/application/default/views/scripts/heihe/view.phtml
@@ -124,7 +124,7 @@ if ($md->title_en) echo ' '.$this->escape($md->title_en);?>
endforeach;
if (count($this->userref)==15)
{
- echo ' 更多施引文献 ';
+ echo ' 更多施引文献 ';
}
?>
diff --git a/application/default/views/scripts/hiwater/view.phtml b/application/default/views/scripts/hiwater/view.phtml
index 5a8a2783..7a851a6d 100644
--- a/application/default/views/scripts/hiwater/view.phtml
+++ b/application/default/views/scripts/hiwater/view.phtml
@@ -122,7 +122,7 @@ if ($md->title_en) echo ' '.$this->escape($md->title_en);?>
endforeach;
if (count($this->userref)==15)
{
- echo ' 更多施引文献 ';
+ echo ' 更多施引文献 ';
}
?>
From 608b8f29f4e8e6aaa029b73dfdf25d6c4930ce3e Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Thu, 21 Nov 2013 02:09:45 +0000
Subject: [PATCH 062/126] =?UTF-8?q?=E6=9B=B4=E6=96=B0Users=E6=93=8D?=
=?UTF-8?q?=E4=BD=9C=E7=B1=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Users/Account.php | 49 +++++++++++--
.../module/Users/Listener/AccountListener.php | 4 +-
.../module/Users/Listener/EditListener.php | 2 +-
.../module/Users/Listener/PwdListener.php | 2 +-
application/module/Users/Member.php | 2 +-
.../module/Users/Operation/EditOperate.php | 4 +-
.../module/Users/Operation/LoginOperate.php | 6 +-
.../Users/Operation/RegisterOperate.php | 4 +-
application/module/Users/Users.php | 73 +++++++++++++++++++
9 files changed, 127 insertions(+), 19 deletions(-)
create mode 100644 application/module/Users/Users.php
diff --git a/application/module/Users/Account.php b/application/module/Users/Account.php
index e692f95c..1297d529 100644
--- a/application/module/Users/Account.php
+++ b/application/module/Users/Account.php
@@ -1,27 +1,35 @@
config = \Zend_Registry::get('config');
+ if($initializingListener === TRUE)
+ {
+ $this->loadListener();
+ }
+ }
+
+ public function loadListener()
+ {
+ //主要操作,账号注册,登录,设置session等
+ $AccountListener = new AccountListener();
+ @$this->events()->attachAggregate($AccountListener);
+ //账户编辑
+ $EditListener = new EditListener();
+ @$this->events()->attachAggregate($EditListener);
+
+ //账户安全性(找回密码)
+ $PwdListener = new PwdListener();
+ @$this->events()->attachAggregate($PwdListener);
}
public function events(\Zend_EventManager_EventCollection $events = NULL)
@@ -60,7 +86,6 @@ class Account extends \Zend_Controller_Plugin_Abstract
//注册
public function register($data)
{
-
$params = compact('data');
$results = $this->events()->trigger('register.checkParam', $this, $params);
$cache_data = $results->bottom();
@@ -145,6 +170,7 @@ class Account extends \Zend_Controller_Plugin_Abstract
}//login
//storeLogin
+ //将登录信息保存在session和cookie中
public function storeLogin($data)
{
$auth = \Zend_Auth::getInstance();
@@ -152,7 +178,16 @@ class Account extends \Zend_Controller_Plugin_Abstract
$authAdapter->setTableName($this->memberTable)
->setIdentityColumn($this->FieldUsername)
->setCredentialColumn($this->FieldPasword);
- $authAdapter->setIdentity($data[$this->FieldUsername])->setCredential(md5($data[$this->FieldPasword]));
+
+ if($data[$this->FieldPasword] == 0)
+ {
+ $password = "0";
+ }else{
+ $password = md5($data[$this->FieldPasword]);
+ }
+
+ $authAdapter->setIdentity($data[$this->FieldUsername])->setCredential($password);
+
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
diff --git a/application/module/Users/Listener/AccountListener.php b/application/module/Users/Listener/AccountListener.php
index 4eabf2c0..04d08596 100644
--- a/application/module/Users/Listener/AccountListener.php
+++ b/application/module/Users/Listener/AccountListener.php
@@ -1,8 +1,8 @@
FieldLastlogin => date("Y-m-d H:i:s"),
- $this->FieldLastloginIp => $_SERVER["REMOTE_ADDR"]
+ //$this->FieldLastloginIp => $_SERVER["REMOTE_ADDR"]
);
$dbh = new dbh();
diff --git a/application/module/Users/Operation/RegisterOperate.php b/application/module/Users/Operation/RegisterOperate.php
index 8bc1f3d1..9d3c006a 100644
--- a/application/module/Users/Operation/RegisterOperate.php
+++ b/application/module/Users/Operation/RegisterOperate.php
@@ -1,8 +1,8 @@
db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->table = new Table();
+
+ $this->config = \Zend_Registry::get('config');
+
+ if($accountClass === TRUE)
+ {
+ $this->account = new Account();
+ }
+ }
+
+ //通过email地址返回用户信息是否存在
+ public function userExists($email = NULL)
+ {
+ if(empty($email))
+ {
+ return false;
+ }
+
+ if(empty($this->account))
+ {
+ $account = new Account(FALSE);
+ }else{
+ $account = $this->account;
+ }
+
+ $sql = "SELECT * FROM {$account->memberTable} WHERE {$account->FieldEmail}=? LIMIT 1";
+ $sth = $this->db->prepare($sql);
+ $sth->execute(array($email));
+ $row = $sth->fetch();
+
+ unset($account);
+
+ if(isset($row['id']) && !empty($row['id']))
+ {
+ return $row;
+ }else{
+ return false;
+ }
+ }
+
+
+
+
+}
\ No newline at end of file
From dbe4d9d728b9c2333b6a0acbe63535fd8155d476 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Thu, 21 Nov 2013 02:14:36 +0000
Subject: [PATCH 063/126] =?UTF-8?q?=E6=9B=B4=E6=96=B0Helper\Curl=E5=92=8CH?=
=?UTF-8?q?elper\Table=E7=B1=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Helpers/Curl.php | 28 +++++++++++++++++++++-------
application/module/Helpers/Table.php | 1 +
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/application/module/Helpers/Curl.php b/application/module/Helpers/Curl.php
index dea71661..f801e43d 100644
--- a/application/module/Helpers/Curl.php
+++ b/application/module/Helpers/Curl.php
@@ -4,21 +4,25 @@ namespace Helpers;
class Curl
{
private $options;
-
+ public $port = 80;
+ public $H;
+
public function __construct($options = array())
{
- $this->options = array_merge(array(
+
+ }
+
+ public function initOptions($options = array())
+ {
+ $this->options = array_merge(array(
'debug' => false,
- 'http_port' => '80',
+ 'http_port' => $this->port,
'user_agent' => 'Westdc DataService',
'timeout' => 20,
'curlopts' => null,
'verifyssl' => true,
), $options);
- }
-
- public $H;
-
+ }
/**
* Send a request to the server, receive a response
*
@@ -88,6 +92,16 @@ class Curl
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => $options['verifyssl'],
);
+
+ if($this->port === 443)
+ {
+ /*$curlOptions += array(
+ CURLOPT_SSLVERSION => 3,
+ CURLOPT_SSLCERT => "../application/module/Open/apache.pem",
+ CURLOPT_SSLKEY => "../application/module/Open/apache.key",
+ CURLOPT_CAINFO => "../application/module/Open/apache.pem"
+ );*/
+ }
if (ini_get('open_basedir') == '' && ini_get('safe_mode') != 'On') {
$curlOptions[CURLOPT_FOLLOWLOCATION] = true;
diff --git a/application/module/Helpers/Table.php b/application/module/Helpers/Table.php
index 69256584..15bab0fb 100644
--- a/application/module/Helpers/Table.php
+++ b/application/module/Helpers/Table.php
@@ -26,5 +26,6 @@ class Table
//开放平台
public $oauth_clients = "oauth_clients";
+ public $oauth_token = "oauth_login_token";
public $oauth_access_tokens = "oauth_access_tokens";
}
\ No newline at end of file
From 580cc39411a90763adbec527616aac9055dab223 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Thu, 21 Nov 2013 03:54:26 +0000
Subject: [PATCH 064/126] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=BC=80?=
=?UTF-8?q?=E6=94=BE=E5=B9=B3=E5=8F=B0=E4=B8=ADOauth=E5=AE=A2=E6=88=B7?=
=?UTF-8?q?=E7=AB=AF=E5=92=8C=E6=9C=8D=E5=8A=A1=E5=99=A8=E7=AB=AF=E9=83=A8?=
=?UTF-8?q?=E5=88=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Open/Client.php | 172 +++++++++++++++++
application/module/Open/Event/AppEvent.php | 10 +
application/module/Open/Event/ClientEvent.php | 8 +
application/module/Open/Event/OauthEvent.php | 7 +
application/module/Open/Event/OpenEvent.php | 7 +
.../module/Open/Handler/AppHandler.php | 140 ++++++++++++++
.../module/Open/Handler/ClientHandler.php | 83 ++++++++
.../Handler/ClientTokenHandler/Escience.php | 182 ++++++++++++++++++
.../module/Open/Handler/OauthHandler.php | 46 +++++
.../module/Open/Handler/OpenHandler.php | 46 +++++
.../module/Open/Listener/AppListener.php | 28 +++
.../module/Open/Listener/ClientListener.php | 26 +++
.../module/Open/Listener/OauthListener.php | 25 +++
.../module/Open/Listener/OpenListener.php | 25 +++
application/module/Open/OAuth2.php | 31 +++
application/module/Open/OAuth2/Server.php | 76 ++++++++
application/module/Open/Source.php | 126 ++++++++++++
application/module/Open/server.php | 15 +-
18 files changed, 1039 insertions(+), 14 deletions(-)
create mode 100644 application/module/Open/Client.php
create mode 100644 application/module/Open/Event/AppEvent.php
create mode 100644 application/module/Open/Event/ClientEvent.php
create mode 100644 application/module/Open/Event/OauthEvent.php
create mode 100644 application/module/Open/Event/OpenEvent.php
create mode 100644 application/module/Open/Handler/AppHandler.php
create mode 100644 application/module/Open/Handler/ClientHandler.php
create mode 100644 application/module/Open/Handler/ClientTokenHandler/Escience.php
create mode 100644 application/module/Open/Handler/OauthHandler.php
create mode 100644 application/module/Open/Handler/OpenHandler.php
create mode 100644 application/module/Open/Listener/AppListener.php
create mode 100644 application/module/Open/Listener/ClientListener.php
create mode 100644 application/module/Open/Listener/OauthListener.php
create mode 100644 application/module/Open/Listener/OpenListener.php
create mode 100644 application/module/Open/OAuth2.php
create mode 100644 application/module/Open/OAuth2/Server.php
create mode 100644 application/module/Open/Source.php
diff --git a/application/module/Open/Client.php b/application/module/Open/Client.php
new file mode 100644
index 00000000..2bfc6ff6
--- /dev/null
+++ b/application/module/Open/Client.php
@@ -0,0 +1,172 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+
+ $this->table = new \Helpers\Table();
+
+ $this->target = $target;
+
+ $Listener = new Listener();
+ @$this->events()->attachAggregate($Listener);
+ }
+
+ 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 initSource()
+ {
+ $this->source = new Source('heihedata');
+ }
+
+ public function getSource()
+ {
+ return $this->source;
+ }
+
+ //创建获取Code的URL
+ public function makeRequestCodeUrl($target = NULL)
+ {
+ if(empty($this->source))
+ {
+ $this->initSource();
+ }
+
+ if(empty($target))
+ {
+ $target = $this->target;
+ }
+
+ $main_target = $this->source->getTarget($target);
+
+ if($main_target === false)
+ {
+ return "此登录接口可能不存在";
+ }
+
+ $source = $this->source->getSource($target);
+
+ if($source === false)
+ {
+ return "此登录接口暂不可用";
+ }
+
+ $main_url = $main_target['code'];
+
+ $param = array(
+ $source->param['id'] => $source->config['id'],
+ $source->param['secret'] => $source->config['secret'],
+ $source->param['callback'] => $source->config['callback'],
+ $source->param['code_response'] => $main_target['code_response']
+ );
+
+ if(isset($source->config['other']))
+ {
+ $param = array_merge($param,$source->config['other']);
+ }
+
+ $url = $main_url."?".http_build_query($param);
+
+ return $url;
+
+ }
+
+ //获得token
+ public function requestToken($code,$target = NULL)
+ {
+ if(empty($target))
+ {
+ $target = $this->target;
+ }
+
+ if(empty($code))
+ {
+ return "未获得您的授权码";
+ }
+
+ $main_target = $this->source->getTarget($target);
+ $client = $this->source->getSource($target);
+
+ if($client === false)
+ {
+ return "请求发生错误,登录接口不存在或者可能不再适用";
+ }
+
+ $main_url = $main_target['token'];
+ $param = array(
+ $client->param['id'] => $client->config['id'],
+ $client->param['secret'] => $client->config['secret'],
+ $client->param['grant_type'] => $main_target['grant_type'],
+ $client->param['callback'] => $client->config['callback'],
+ $client->param['code'] => $code
+ );
+
+ $curl = new Curl();
+ $curl->port = 443;
+ $curl->initOptions(array('verifyssl'=>false));
+ $data = $curl->request($main_url,$param,"POST");
+
+ $cache_data = json_decode($data['response'],true);
+
+ if(!isset($cache_data['expires_in']))
+ {
+ return "未获得授权信息,请重试链接";
+ }
+
+ return $cache_data;
+
+ }
+
+ //储存token信息
+ public function storageTokenData($type,$token)
+ {
+ if(empty($type))
+ {
+ return "接口类型错误";
+ }
+
+ if(empty($token))
+ {
+ return "登录信息有误,请重新登录";
+ }
+
+ $param = compact("type","token");
+
+ $results = $this->events()->trigger('tokenStorage', $this, $param);
+ return $cache_data = $results->bottom();
+
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/application/module/Open/Event/AppEvent.php b/application/module/Open/Event/AppEvent.php
new file mode 100644
index 00000000..9985c74d
--- /dev/null
+++ b/application/module/Open/Event/AppEvent.php
@@ -0,0 +1,10 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+ }
+
+ //检查app参数
+ public function appCheckParam(\Zend_EventManager_Event $e)
+ {
+ $data = $e->getParam('data');
+
+ if(!is_array($data))
+ {
+ return "参数错误";
+ }
+
+ if(empty($data['subject']))
+ {
+ return "请输入应用名称";
+ }
+
+ if(empty($data['client_domain']))
+ {
+ return "请填写应用使用的域名,不带www";
+ }
+
+ if(empty($data['redirect_uri']))
+ {
+ return "请输入授权成功后的回调地址";
+ }
+
+ $sql = "SELECT id FROM {$this->table->oauth_clients} WHERE subject='{$data['subject']}'";
+ $rs = $this->db->query($sql);
+ $row = $rs->fetch();
+
+ if(!empty($row['id']))
+ {
+ return "此应用名称已存在,请重新输入";
+ }
+
+ return true;
+ }
+
+ //处理app参数数据
+ public function appProcessData(\Zend_EventManager_Event $e)
+ {
+ $data = $e->getParam('data');
+ $id = $e->getParam('id');
+
+ if(empty($id))
+ {
+ $data['client_id'] = $this->create_client_guid(__CLASS__);
+ $data['client_secret'] = strtoupper(substr(md5($data['client_id'].$data['client_domain'].$data['redirect_uri'].time()),10,24));
+ }
+ $data['user_id'] = view::User('id');
+
+ return $data;
+ }
+
+ //创建App成功后
+ public function appCreated(\Zend_EventManager_Event $e)
+ {
+ $id = $e->getParam('id');
+ $data = $e->getParam('data');
+
+ return true;
+ }
+
+ //App编辑成功后
+ public function appEdited(\Zend_EventManager_Event $e)
+ {
+ $id = $e->getParam('id');
+ $data = $e->getParam('data');
+
+ return true;
+ }
+
+ public function create_client_guid($namespace = '') {
+ static $guid = '';
+ $uid = uniqid("", true);
+ $data = $namespace;
+ if(isset($_SERVER['REQUEST_TIME']))
+ $data .= $_SERVER['REQUEST_TIME'];
+
+ if(isset($_SERVER['HTTP_USER_AGENT']))
+ $data .= $_SERVER['HTTP_USER_AGENT'];
+
+ if(isset($_SERVER['LOCAL_ADDR']))
+ $data .= $_SERVER['LOCAL_ADDR'];
+
+ if(isset($_SERVER['LOCAL_PORT']))
+ $data .= $_SERVER['LOCAL_PORT'];
+
+ if(isset($_SERVER['REMOTE_ADDR']))
+ $data .= $_SERVER['REMOTE_ADDR'];
+
+ if(isset($_SERVER['REMOTE_PORT']))
+ $data .= $_SERVER['REMOTE_PORT'];
+
+ $data .= time();
+
+ $hash = strtoupper(hash('ripemd128', $uid . $guid . md5($data)));
+ $guid = '' .
+ substr($hash, 0, 8) .
+ '-' .
+ substr($hash, 8, 4) .
+ '-' .
+ substr($hash, 12, 4) .
+ '-' .
+ substr($hash, 16, 4) .
+ '-' .
+ substr($hash, 20, 12) .
+ '';
+ return $guid;
+ }
+
+}
diff --git a/application/module/Open/Handler/ClientHandler.php b/application/module/Open/Handler/ClientHandler.php
new file mode 100644
index 00000000..b3cd8a2f
--- /dev/null
+++ b/application/module/Open/Handler/ClientHandler.php
@@ -0,0 +1,83 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+ }
+
+ //获得Handler,type必须与 \Open\Source中同步,否则会出现错误
+ //
+ public function getHandler($type,$data)
+ {
+ if($type == 'escience')
+ {
+ return new \Open\Handler\ClientTokenHandler\Escience($data);
+ }
+
+ if($type == 'sina')
+ {
+ return new \Open\Handler\ClientTokenHandler\Sina($data);
+ }
+
+ return false;
+ }
+
+ //存储token信息
+ public function tokenAndDataStorage(\Zend_EventManager_Event $e)
+ {
+ $type = $e->getParam('type');
+ $data = $e->getParam('token');
+
+ $handler = $this->getHandler($type,$data);
+
+ if($status = $handler->doit() === true)
+ {
+ return true;
+ }else{
+ return $status;
+ }
+ }
+
+ //检查用户账户是否存在
+ //存在就返回用户信息,不存在返回false
+ //通用事件,通过各个 TokenHandler中内置Listener直接挂载,不需要引入整个ClientListener
+ public function userCheck(\Zend_EventManager_Event $e)
+ {
+ $email = $e->getParam('email');
+
+ $user = new Users();
+ $current = $user->userExists($email);
+
+ if($current === false)
+ {
+ return false;
+ }
+
+ return $current;
+ }
+
+}
diff --git a/application/module/Open/Handler/ClientTokenHandler/Escience.php b/application/module/Open/Handler/ClientTokenHandler/Escience.php
new file mode 100644
index 00000000..4c13a8e2
--- /dev/null
+++ b/application/module/Open/Handler/ClientTokenHandler/Escience.php
@@ -0,0 +1,182 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+
+ //预处理token信息
+ $status = $this->preProcess($token);
+ }
+
+ //考虑加一个接口,每个Token操作类中必须包含此函数
+ public function doit()
+ {
+ //makeUserStorage在先,必须的
+ $status = $this->makeUserStorage();
+
+ if($status!==true)
+ {
+ return $status;
+ }
+
+ $status = $this->makeTokenStorage();
+
+ if($status !== true)
+ {
+ return $status;
+ }
+
+ return true;
+ }
+
+ //预处理
+ public function preProcess($tokenData)
+ {
+ if(!is_array($tokenData))
+ {
+ return "参数错误";
+ }
+
+ $this->userInfo = json_decode($tokenData['userInfo'],true);
+
+ unset($tokenData['userInfo']);
+
+ $this->token = $tokenData;
+
+ return true;
+ }
+
+ //检查用户信息,如果没有用户自动注册,有用户就自动绑定。
+ public function makeUserStorage()
+ {
+ $uid = view::User('id');
+
+ if(is_numeric($uid) && $uid > 0)
+ {
+ $this->userid = $uid;
+ return "您已经登录,无需重复登录";
+ }
+
+ if(empty($this->userid))
+ {
+ $current_oauth_email = $this->userInfo['cstnetId'];
+
+ $user = new Users(TRUE);
+ $current = $user->userExists($current_oauth_email);
+
+ if($current === false)
+ //自动注册用户
+ {
+ $data = array(
+ $user->account->FieldUsername => $current_oauth_email,
+ $user->account->FieldEmail => $current_oauth_email,
+ $user->account->FieldPasword => 0,
+ $user->account->FieldRealname => $this->userInfo['truename'],
+ );
+
+ $dbh = new dbh();
+
+ $id = $dbh->insert($user->account->memberTable,$data,true);
+
+ //登录
+ $user->account->storeLogin(array(
+ $user->account->FieldUsername => $data[$user->account->FieldUsername],
+ $user->account->FieldPasword => $data[$user->account->FieldPasword]
+ ));
+
+ $this->userid = $id;
+
+ return true;
+ }
+
+ //帮用户自动登录
+ else{
+
+ $user->account->storeLogin(array(
+ $user->account->FieldUsername => $current[$user->account->FieldUsername],
+ $user->account->FieldPasword => $current[$user->account->FieldPasword]
+ ));
+
+ $this->userid = $current[$user->account->FieldIndex];
+
+ return true;
+ }
+
+ }
+
+ }
+
+ //生成写入token表的数据
+ //有token记录就更新,没有再插入
+ public function makeTokenStorage()
+ {
+ $data = array(
+ 'access_token' => $this->token['access_token'],
+ 'refresh_token' => $this->token['refresh_token'],
+ 'expires_in' => $this->token['expires_in'],
+ 'userid' => $this->userid,
+ "response_data" => json_encode($this->userInfo,JSON_NUMERIC_CHECK),
+ "source" => "escience"
+ );
+
+ //查看用户用escience登录的记录是否存在
+ $sql = "SELECT * FROM {$this->table->oauth_token} WHERE userid={$this->userid} AND source='{$data['source']}' LIMIT 1";
+ $rs = $this->db->query($sql);
+ $row = $rs->fetch();
+
+ $dbh = new dbh();
+
+ if(isset($row['id']))
+ {
+ $status = $dbh->update($this->table->oauth_token,$data," id={$row['id']} AND userid={$this->userid} ");
+ if($status)
+ {
+ return true;
+ }else{
+ return "更新授权信息时发生错误,请重新登录";
+ }
+ }else{
+ $status = $dbh->insert($this->table->oauth_token,$data);
+ if($status)
+ {
+ return true;
+ }else{
+ return "记录授权信息时发生错误,请重新登录";
+ }
+ }
+
+ return true;
+ }
+
+
+}
diff --git a/application/module/Open/Handler/OauthHandler.php b/application/module/Open/Handler/OauthHandler.php
new file mode 100644
index 00000000..5a5da972
--- /dev/null
+++ b/application/module/Open/Handler/OauthHandler.php
@@ -0,0 +1,46 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+ }
+
+ public function checkParam(\Zend_EventManager_Event $e)
+ {
+ $data = $e->getParam('data');
+
+ if(!is_array($data))
+ {
+ return "参数错误";
+ }
+
+
+
+ return true;
+ }
+
+
+
+}
diff --git a/application/module/Open/Handler/OpenHandler.php b/application/module/Open/Handler/OpenHandler.php
new file mode 100644
index 00000000..aa0dc5e0
--- /dev/null
+++ b/application/module/Open/Handler/OpenHandler.php
@@ -0,0 +1,46 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+ }
+
+ public function checkParam(\Zend_EventManager_Event $e)
+ {
+ $data = $e->getParam('data');
+
+ if(!is_array($data))
+ {
+ return "参数错误";
+ }
+
+
+
+ return true;
+ }
+
+
+
+}
diff --git a/application/module/Open/Listener/AppListener.php b/application/module/Open/Listener/AppListener.php
new file mode 100644
index 00000000..41628b18
--- /dev/null
+++ b/application/module/Open/Listener/AppListener.php
@@ -0,0 +1,28 @@
+event = new \Zend_EventManager_EventManager();
+ }
+
+ public function attach(\Zend_EventManager_EventCollection $events)
+ {
+ $Handler = new Handler();
+ $events->attach('app.checkParam', array($Handler, 'appCheckParam'), 100);
+ $events->attach('app.processData', array($Handler, 'appProcessData'), 100);
+ $events->attach('app.created', array($Handler, 'appCreated'), 100);
+ $events->attach('app.eidted', array($Handler, 'appEdited'), 100);
+ }
+
+ public function detach(\Zend_EventManager_EventCollection $events)
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Open/Listener/ClientListener.php b/application/module/Open/Listener/ClientListener.php
new file mode 100644
index 00000000..2ff2ad3e
--- /dev/null
+++ b/application/module/Open/Listener/ClientListener.php
@@ -0,0 +1,26 @@
+event = new \Zend_EventManager_EventManager();
+ }
+
+ public function attach(\Zend_EventManager_EventCollection $events)
+ {
+ $Handler = new Handler();
+ $events->attach('tokenStorage', array($Handler, 'tokenAndDataStorage'), 100);
+ $events->attach('user.check', array($Handler, 'userCheck'), 100);
+ }
+
+ public function detach(\Zend_EventManager_EventCollection $events)
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Open/Listener/OauthListener.php b/application/module/Open/Listener/OauthListener.php
new file mode 100644
index 00000000..65056b9d
--- /dev/null
+++ b/application/module/Open/Listener/OauthListener.php
@@ -0,0 +1,25 @@
+event = new \Zend_EventManager_EventManager();
+ }
+
+ public function attach(\Zend_EventManager_EventCollection $events)
+ {
+ $Handler = new OauthHandler();
+ $events->attach('submit.checkParam', array($Handler, 'checkParam'), 100);
+ }
+
+ public function detach(\Zend_EventManager_EventCollection $events)
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Open/Listener/OpenListener.php b/application/module/Open/Listener/OpenListener.php
new file mode 100644
index 00000000..64a06730
--- /dev/null
+++ b/application/module/Open/Listener/OpenListener.php
@@ -0,0 +1,25 @@
+event = new \Zend_EventManager_EventManager();
+ }
+
+ public function attach(\Zend_EventManager_EventCollection $events)
+ {
+ $Handler = new Handler();
+ $events->attach('submit.checkParam', array($Handler, 'checkParam'), 100);
+ }
+
+ public function detach(\Zend_EventManager_EventCollection $events)
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Open/OAuth2.php b/application/module/Open/OAuth2.php
new file mode 100644
index 00000000..f31d6f37
--- /dev/null
+++ b/application/module/Open/OAuth2.php
@@ -0,0 +1,31 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+
+ }
+
+ //用户使用谷歌账号登陆
+ public function googleClient()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/application/module/Open/OAuth2/Server.php b/application/module/Open/OAuth2/Server.php
new file mode 100644
index 00000000..05508c18
--- /dev/null
+++ b/application/module/Open/OAuth2/Server.php
@@ -0,0 +1,76 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+ }
+
+ //根据ID或者Client_id获得app的信息
+ public function getClientInfo($id)
+ {
+ if(empty($id))
+ {
+ return "无效参数";
+ }
+
+ if(is_numeric($id))
+ {
+ $field = "id";
+ }else{
+ $field = "client_id";
+ }
+
+ $sql = "SELECT * FROM {$this->table->oauth_clients} WHERE $field=? LIMIT 1";
+ $sth = $this->db->prepare($sql);
+ $sth->execute(array($id));
+ $row = $sth->fetch();
+
+ return $row;
+ }
+
+ //验证App
+ public function clientCredentials($client_id,$client_secret)
+ {
+
+ $client = $this->getClientInfo($client_id);
+
+ if(empty($client['id']))
+ {
+ return "此应用ID未被证实";
+ }
+
+ if($client['status'] == -1)
+ {
+ return "此应用已关闭";
+ }
+
+ if($client['client_secret'] !== $client_secret)
+ {
+ return "Invalid client secret";
+ }
+
+ return true;
+ }
+
+
+}
\ No newline at end of file
diff --git a/application/module/Open/Source.php b/application/module/Open/Source.php
new file mode 100644
index 00000000..51e82760
--- /dev/null
+++ b/application/module/Open/Source.php
@@ -0,0 +1,126 @@
+source = new stdClass();
+ $this->target = new stdClass();
+
+ $this->website = $website;
+
+ $this->initSourceConfig();
+ $this->initTarget();
+ }
+
+ //获得当前绑定的站点
+ public function getCurrentSite(){
+ return $this->website;
+ }
+
+ //设置绑定的站点
+ public function setCurrentSite($website){
+ $this->website = $website;
+ $this->initSourceConfig();
+ }
+
+ private function initSourceConfig()
+ {
+ if(!in_array($this->website,$this->sourceType))
+ {
+ return false;
+ }
+
+ // Escience
+ // passport.escience.cn
+ $this->source->escience = new stdClass();
+ $this->source->escience->param = array(
+ "id" => "client_id",
+ "secret" => "client_secret",
+ "code_response" => "response_type",
+ "grant_type" => "grant_type",
+ "callback" => "redirect_uri",
+ "code"=>"code"
+ );
+
+ if($this->website == 'westdc'){
+
+ $this->source->escience->config = array(
+ 'id' => '71852',
+ 'secret' => 'ad7gd3jZgbzhQM6vIh9vPnQFZQoTGHZI',
+ 'index' => 'http://westdc.westgis.ac.cn',
+ 'callback' => 'http://westdc.westgis.ac.cn/account/callback/type/escience',
+ 'other' => array(
+ 'theme'=>'full'
+ )
+ );
+
+ }
+
+ if($this->website == 'heihedata'){
+
+ $this->source->escience->config = array(
+ 'id' => '78969',
+ 'secret' => 'iTGKdCkUPakA2hza2TJ4XZ4cnwlh8Hqz',
+ 'index' => 'http://www.heihedata.org',
+ 'callback' => 'http://www.heihedata.org/account/callback/type/escience',
+ 'other' => array(
+ 'theme'=>'full'
+ )
+ );
+
+ }
+
+ }
+
+ //获得一个源
+ public function getSource($type = "")
+ {
+ if(empty($type))
+ {
+ return $this->source;
+ }else{
+ if(isset($this->source->$type))
+ {
+ return $this->source->$type;
+ }else{
+ return false;
+ }
+ }
+ }
+
+ //Oauth2登录目标
+ private function initTarget(){
+ $this->target->escience = array(
+ 'name' => '中国科技网通行证',
+ 'code' => 'http://passport.escience.cn/oauth2/authorize',
+ 'token' => 'https://passport.escience.cn/oauth2/token',
+ 'code_response' => 'code',
+ 'grant_type' => 'authorization_code',
+ );
+ }
+
+ //获得Oauth2登录模板
+ public function getTarget($type = "")
+ {
+ if(empty($type))
+ {
+ return $this->target;
+ }else{
+ if(isset($this->target->$type))
+ {
+ return $this->target->$type;
+ }else{
+ return false;
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Open/server.php b/application/module/Open/server.php
index ee0b7408..3406b448 100644
--- a/application/module/Open/server.php
+++ b/application/module/Open/server.php
@@ -29,22 +29,9 @@ class Server extends \Zend_Controller_Plugin_Abstract
}
}
- public function bootstrap()
+ public function getCode()
{
- $dsn = "pgsql:dbname={$this->config->db->params->dbname};host={$this->config->db->params->host}";
- $storage = new \OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $this->config->db->params->username, 'password' => $this->config->db->params->password));
-
- $server = new \OAuth2\Server($storage);
-
- $server->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage));
-
- $server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage));
-
- //应用授权
- //$server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
-
- return $server;
}
}
\ No newline at end of file
From 0e11fd37d797d6e968444c9c7256e01611df36a3 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Thu, 21 Nov 2013 03:56:00 +0000
Subject: [PATCH 065/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20\Open\server=20?=
=?UTF-8?q?=E4=B8=BA=20\Open\Server?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Open/{server.php => Server.php} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename application/module/Open/{server.php => Server.php} (100%)
diff --git a/application/module/Open/server.php b/application/module/Open/Server.php
similarity index 100%
rename from application/module/Open/server.php
rename to application/module/Open/Server.php
From 6ab8c24f949f22bd7066a6306415bc0dc146816b Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Thu, 21 Nov 2013 06:21:22 +0000
Subject: [PATCH 066/126] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86OpenControll?=
=?UTF-8?q?er=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86accountController?=
=?UTF-8?q?=E4=B8=AD=E5=85=B3=E4=BA=8EOauth=E4=BA=A4=E4=BA=92=E7=99=BB?=
=?UTF-8?q?=E5=BD=95=E7=9A=84=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../default/controllers/AccountController.php | 47 +++++
.../default/controllers/OpenController.php | 165 ++++++++++++++++++
.../scripts/account/application-add.phtml | 43 +++++
.../views/scripts/account/application.phtml | 25 +++
.../views/scripts/account/callback.phtml | 46 +++++
.../default/views/scripts/account/left.phtml | 1 +
.../default/views/scripts/account/login.phtml | 3 +
7 files changed, 330 insertions(+)
create mode 100644 application/default/controllers/OpenController.php
create mode 100644 application/default/views/scripts/account/application-add.phtml
create mode 100644 application/default/views/scripts/account/application.phtml
create mode 100644 application/default/views/scripts/account/callback.phtml
diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php
index 2601283e..cfec11f1 100755
--- a/application/default/controllers/AccountController.php
+++ b/application/default/controllers/AccountController.php
@@ -1,6 +1,7 @@
_getParam('type');
+ $client = new Client();
+ $url = $client->makeRequestCodeUrl($type);
+
+ view::Post($this,"为您转入科技网登录入口",$url);
+ }
+
+ //oauth2登录回调地址
+ public function callbackAction()
+ {
+ $type = $this->_getParam('type');
+ $code = $this->_getParam('code');
+
+ $client = new Client($type);
+
+ $client->initSource();
+ $target = $client->getSource()->getTarget($type);
+ $this->view->target_name = $target['name'];
+
+ //$token = $client->requestToken($code);
+
+ $token = array(
+ "expires_in"=>(int)432000,
+ "refresh_token"=>(string)"eb40e792e05a21e779aa89d71066fa61",
+ "userInfo"=>(string)'{"passwordType":"password_umt","securityEmail":"liujin834@live.com","cstnetIdStatus":"active","umtId":"10247308","truename":"李建轩","cstnetId":"liujin834@live.com","type":"umt"}',
+ "access_token"=>(string)"48415c56215f5cd26baabe403864aaf7"
+ );
+
+ if(is_string($token))
+ {
+ view::Post($this,$token,'/account/login');
+ }
+
+ $status = $client->storageTokenData($type,$token);
+
+ if($status === true)
+ {
+ echo "";
+ }else{
+ echo $status;
+ }
+ }
}
diff --git a/application/default/controllers/OpenController.php b/application/default/controllers/OpenController.php
new file mode 100644
index 00000000..65805abe
--- /dev/null
+++ b/application/default/controllers/OpenController.php
@@ -0,0 +1,165 @@
+view->config = $this->config = \Zend_Registry::get('config');
+ $this->db = \Zend_Registry::get('db');
+ $this->view->theme = new Theme();
+ $this->_helper->layout->setLayout('layout-open');
+ }
+
+ function indexAction()
+ {
+ $this->view->pageID = "open-index";
+ }
+
+ //我的应用
+ function myappAction()
+ {
+ $this->view->pageID = "open-myapp";
+
+ $app = new App();
+
+ $user_state = $app->checkinfo();
+ if( $user_state !== true)
+ {
+ view::post($this,$user_state,"/account/edit");
+ }
+
+ $ac = $this->_getParam('ac');
+ $id = $this->_getParam('id');
+ $submit = $this->_getParam('submit');
+
+ if(empty($ac))
+ {
+ $this->view->myapp = $app->getUserApp();
+ return true;
+ }
+
+ if($ac == "create")
+ {
+ $this->_helper->viewRenderer('myapp-create');
+
+ $this->view->appStatus = $app->appStatus();
+
+ if(!empty($id))
+ {
+ $this->view->info = $app->getAppInfo($id);
+ }
+
+ if(!empty($submit))
+ {
+ if(empty($id))
+ {
+ $status = $app->appCreate();
+ }else{
+ $this->view->info = $app->getAppCreateParam();
+ $status = $app->appCreate($id);
+ }
+
+ if($status !== true && !is_numeric($status))
+ {
+ $this->view->error = view::Error($status);
+ }else{
+ if(!empty($id))
+ view::Post($this,"修改成功!",'/open/myapp/ac/view/id/'.$id);
+ else
+ view::Post($this,"添加成功!","/open/myapp/ac/view/id/".$status);
+ }
+
+ }
+ return true;
+ }
+
+ if($ac == "delete")
+ {
+ $status = $app->delete($id);
+ if($status !== true)
+ {
+ view::Post($this,$status,"/open/myapp");
+ }else{
+ view::Post($this,'删除成功',"/open/myapp");
+ }
+ return false;
+ }
+
+ if($ac == "view")
+ {
+ $this->_helper->viewRenderer('myapp-view');
+ $this->view->data = $app->getAppInfo($id);
+ $this->view->appStatus = $app->appStatus();
+ return true;
+ }
+
+ }
+
+ function authenticateAction()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $data = array(
+ 'client_id' => $this->_getParam('client_id'),
+ 'redirect_uri' => $this->_getParam('redirect_uri'),
+ 'client_secret' => $this->_getParam('client_secret'),
+ 'host' => $_SERVER['HTTP_HOST'],
+ 'ip' => $_SERVER['REMOTE_ADDR']
+ );
+
+ $server = new Server();
+
+ $status = $server->clientCredentials($data['client_id'],$data['client_secret']);
+
+ if($status !== true)
+ {
+ echo $status;
+ }else{
+
+ }
+
+ }
+
+ function authorizeAction()
+ {
+ $submit = $this->_getParam('submit');
+
+ if(empty($submit))
+ {
+ return true;
+ }
+
+ $sv = new open\server();
+ $server = $sv->bootstrap();
+
+ $request = OAuth2\Request::createFromGlobals();
+ $response = new OAuth2\Response();
+
+ // validate the authorize request
+ if (!$server->validateAuthorizeRequest($request, $response)) {
+ $response->send();
+ die;
+ }
+
+ // print the authorization code if the user has authorized your client
+ $is_authorized = ($_POST['authorized'] === 'yes');
+ $server->handleAuthorizeRequest($request, $response, $is_authorized);
+ if ($is_authorized) {
+ // this is only here so that you get to see your code in the cURL request. Otherwise, we'd redirect back to the client
+ $code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=')+5, 40);
+ exit("SUCCESS! Authorization Code: $code");
+ }
+ $response->send();
+ }
+
+}
+
diff --git a/application/default/views/scripts/account/application-add.phtml b/application/default/views/scripts/account/application-add.phtml
new file mode 100644
index 00000000..192d78b2
--- /dev/null
+++ b/application/default/views/scripts/account/application-add.phtml
@@ -0,0 +1,43 @@
+headTitle($this->config->title->site);
+ $this->headTitle('网站接入');
+ $this->headTitle()->setSeparator(' - ');
+?>
+
+
+
+
+
+
应用接入
+
+ msg)) { ?>
+ = $this->msg ?>
+
+ error)) { ?>
+ = $this->error ?>
+
+
+
+
+
diff --git a/application/default/views/scripts/account/application.phtml b/application/default/views/scripts/account/application.phtml
new file mode 100644
index 00000000..699fad4d
--- /dev/null
+++ b/application/default/views/scripts/account/application.phtml
@@ -0,0 +1,25 @@
+headTitle($this->config->title->site);
+ $this->headTitle('我的账户');
+ $this->headTitle()->setSeparator(' - ');
+?>
+
+
+
+
+
+
应用接入
+
应用管理
+
+ msg)) { ?>
+ = $this->msg ?>
+
+ error)) { ?>
+ = $this->error ?>
+
+
+
+
+
diff --git a/application/default/views/scripts/account/callback.phtml b/application/default/views/scripts/account/callback.phtml
new file mode 100644
index 00000000..2c476ed5
--- /dev/null
+++ b/application/default/views/scripts/account/callback.phtml
@@ -0,0 +1,46 @@
+headTitle($this->config->title->site);
+ $this->headTitle('用户登录');
+ $this->headTitle()->setSeparator(' - ');
+ $this->breadcrumb('首页 ');
+ $this->breadcrumb('用户登录 ');
+ $this->breadcrumb()->setSeparator(' > ');
+?>
+
+
+
+ = empty($this->target_name) ? "":"您已经使用 ".$this->target_name." 账号登录
" ?>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/default/views/scripts/account/left.phtml b/application/default/views/scripts/account/left.phtml
index 8608f255..c219e4d7 100644
--- a/application/default/views/scripts/account/left.phtml
+++ b/application/default/views/scripts/account/left.phtml
@@ -2,6 +2,7 @@
数据篮
+
账户信息
安全性
diff --git a/application/default/views/scripts/account/login.phtml b/application/default/views/scripts/account/login.phtml
index e53bd83d..a362a769 100755
--- a/application/default/views/scripts/account/login.phtml
+++ b/application/default/views/scripts/account/login.phtml
@@ -64,6 +64,9 @@
+
+
其它账号登录
+
中国科技网通行证
";
- }else{
- echo $status;
- }
- }
-
-}
-
+view->config = Zend_Registry::get('config');
+ $this->_request->setParam('return', $this->_request->getServer('REQUEST_URI'));
+ $this->db = Zend_Registry::get('db');
+ $this->view->messages = $this->messenger->getMessages();
+ $this->view->theme = new Theme();
+ }
+
+ function indexAction()
+ {
+ $this->view->pageID = "account-index";
+
+ include_once("Users.php");
+ $usr = new Users($this->db);
+
+ $auth = Zend_Auth::getInstance();
+ if($auth->hasIdentity())
+ {
+ $user = $auth->getIdentity();
+ $uid = $user->id;
+ }
+
+ include_once("Avatar.php");
+ $avatar = new Avatar();
+ $this->view->avatar = $avatar->Get($user->email,140);
+
+ $this->view->info = $usr->getUserInfo($uid);
+ }
+
+ function editAction()
+ {
+ $this->view->pageID = "account-edit";
+
+ include_once("Users.php");
+ $usr = new Users($this->db);
+
+ $auth = Zend_Auth::getInstance();
+ if($auth->hasIdentity())
+ {
+ $user = $auth->getIdentity();
+ $uid = $user->id;
+ }
+
+ include_once("Avatar.php");
+ $avatar = new Avatar();
+ $this->view->avatar = $avatar->Get($user->email,140);
+
+ $this->view->projectType = array(
+ "无" => '',
+ "国家973计划项目课题" => "国家973计划项目课题",
+ "国家863计划课题"=>"国家863计划课题",
+ "国家级科技支撑课题" => "国家级科技支撑课题",
+ "国家级科技重大专项" => "国家级科技重大专项",
+ "国家级国家重大工程" => "国家级国家重大工程",
+ "国家级国家自然科学基金" => "国家级国家自然科学基金",
+ "国际合作项目"=>"国际合作项目",
+ "省部级项目" => "省部级项目",
+ "其他项目工程" => "其他项目工程"
+ );
+
+ $submit = $this->_getParam('submit');
+
+ if(!empty($submit))
+ {
+ $data = $this->AccountEditParamFilter();
+
+ if($this->db->update("users",$data,"id=$uid"))
+ {
+ $this->view->AlertType = "alert-success";
+ $this->view->msg = "修改成功!";
+ $this->view->jump_url = "/account/edit";
+ return true;
+ }else{
+ $this->view->AlertType = "alert-error";
+ $this->view->error = "修改失败,请重试";
+ $this->view->info = $data;
+ return true;
+ }
+ }else{
+ $this->view->info = $usr->getUserInfo($uid);
+ }
+ }
+
+ function AccountEditParamFilter(){
+ $data = array();
+ $data['realname'] = substr(trim($this->_getParam('realname')),0,40);
+ $data['unit'] = substr(trim($this->_getParam('unit')),0,100);
+ $data['address'] = substr(trim($this->_getParam('address')),0,100);
+ $data['phone'] = substr(trim($this->_getParam('phone')),0,15);
+ $data['postcode'] = substr(trim($this->_getParam('postcode')),0,15);
+ $data['project_type'] = substr(trim($this->_getParam('project_type')),0,100);
+ $data['project_id'] = substr(trim($this->_getParam('project_id')),0,40);
+ $data['project_title'] = substr(trim($this->_getParam('project_title')),0,100);
+ $data['project'] = substr(trim($this->_getParam('project')),0,600);
+
+ foreach($data as $k=>$v)
+ {
+ $data[$k] = $this->StringFilter($v);
+ }
+
+ return $data;
+ }
+
+ function StringFilter($string){
+ $string = preg_replace ('/<[^>]*>/', ' ', $string);
+ return $string;
+ }
+
+ function secureAction()
+ {
+ $this->view->pageID = "account-secure";
+
+ include_once("Users.php");
+ $usr = new Users($this->db);
+
+ $auth = Zend_Auth::getInstance();
+ if($auth->hasIdentity())
+ {
+ $user = $auth->getIdentity();
+ $uid = $user->id;
+ }
+
+ $opt = $this->_getParam('opt');
+ $submit = $this->_getParam('submit');
+
+ if(empty($opt))
+ {
+ $this->view->section = "password";
+ if(!empty($submit))
+ {
+ $data = $this->AccountSecureParamFilter();
+
+ $this->view->AlertType = "alert-error";
+ if(strlen($data['password'])>18 || strlen($data['new_password'])>18)
+ {
+ $this->view->error = view::Error("密码过长");
+ return true;
+ }
+ if(strlen($data['new_password'])<=6 || strlen($data['new_password_confrim'])<=6)
+ {
+ $this->view->error = view::Error("密码过短,请输入大于6位的密码");
+ return true;
+ }
+ if(md5($data['new_password']) != md5($data['new_password_confrim']))
+ {
+ $this->view->error = view::Error("两次输入的密码不相同");
+ return true;
+ }
+
+ $sql = "SELECT password FROM users WHERE id=$uid";
+ $rs = $this->db->query($sql);
+ $row = $rs->fetch();
+
+ if(md5($data['password']) != $row['password'])
+ {
+ $this->view->error = view::Error("原密码不正确");
+ return true;
+ }
+
+ $data['password'] = md5($data['new_password']);
+
+ unset($data['new_password']);
+ unset($data['new_password_confrim']);
+
+ if($this->db->update("users",$data,"id=$uid"))
+ {
+ view::Post($this,array("content"=>'修改成功!','url'=>'/account/secure'));
+ return true;
+ }else{
+ $this->view->error = view::Error("修改失败");
+ return true;
+ }
+ }else{
+ $this->view->info = $usr->getUserInfo($uid);
+ }
+ }//password
+
+ if($opt == "email")
+ {
+ $this->view->section = "email";
+ if(!empty($submit))
+ {
+ $email = $this->_getParam('email');
+ $password = $this->_getParam('password');
+
+ if(!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/i",$email))
+ {
+ $this->view->error = view::Error("错误的邮箱格式");
+ return true;
+ }
+
+ $sql = "SELECT password FROM users WHERE id=$uid";
+ $rs = $this->db->query($sql);
+ $row = $rs->fetch();
+
+ if(md5($password) != $row['password'])
+ {
+ $this->view->error = view::Error("原密码错误");
+ return true;
+ }
+
+ $data['email'] = $email;
+
+ if($this->db->update("users",$data,"id=$uid"))
+ {
+ view::Post($this,array("content"=>'修改成功!','url'=>'/account/secure'));
+ return true;
+ }else{
+ $this->view->error = view::Error("修改失败");
+ return true;
+ }
+ }else{
+ $this->view->info = $usr->getUserInfo($uid);
+ }
+ }//email
+ }
+
+ function AccountSecureParamFilter(){
+ $data = array();
+ $data['password'] = trim($this->_getParam('password'));
+ $data['new_password'] = trim($this->_getParam('new_password'));
+ $data['new_password_confrim'] = trim($this->_getParam('new_password_confrim'));
+ foreach($data as $k=>$v)
+ {
+ $data[$k] = $this->StringFilter($v);
+ }
+ return $data;
+ }
+
+ function init()
+ {
+ $this->messenger=$this->_helper->getHelper('FlashMessenger');
+ }
+
+ function postDispatch()
+ {
+ //$this->view->messages = $this->messenger->getMessages();
+ }
+
+ function registerAction()
+ {
+ $form = new RegisterForm();
+ $this->view->form = $form;
+
+ if ($this->_request->isPost()) {
+ $formData = $this->_request->getPost();
+ 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_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();
+
+ //自动登录系统
+ $this->login($formData['username'],$formData['password']);
+ $this->_redirect('/');
+ }
+ } else {
+ $form->populate($formData);
+ }
+ }
+ }
+
+ function loginAction()
+ {
+
+ $success=false;
+
+ $options = array(
+ 'module' => $this->_request->getModuleName(),
+ 'controller' => $this->_request->getControllerName(),
+ 'action' => $this->_request->getActionName(),
+ );
+
+ $auth = Zend_Auth::getInstance();
+ if ($auth->hasIdentity())
+ {
+ view::Post($this,"您已经登录,无需重复登录",-1);
+ return true;
+ }
+
+ $tohref = $this->_request->getParam('href');
+
+ if(($options['module']=="default" && $options['controller'] == "account" && $options['action'] == "login"))
+ {
+ $this->view->href = $_SERVER['REQUEST_URI'];
+ }
+
+ if($tohref == "/account/login")
+ {
+ $this->view->href = $tohref = "/";
+ }
+
+ if(!empty($tohref))
+ {
+ $this->view->href = $tohref;
+ }
+
+ $captcha = $this->loadCaptcha();
+
+ $submit = $this->_getParam("submit");
+ if(!empty($submit))
+ {
+ $username = trim($this->_request->getParam('username'));
+ $password = trim($this->_request->getParam('password'));
+ $captchaword = trim($this->_request->getParam('captcha'));
+
+ if(empty($username))
+ {
+ $this->setCaptcha($captcha);
+ $this->view->error = "请输入用户名";
+ return true;
+ }
+
+ if(empty($password))
+ {
+ $this->setCaptcha($captcha);
+ $this->view->error = "请输入密码";
+ return true;
+ }
+
+ if(empty($captchaword))
+ {
+ $this->setCaptcha($captcha);
+ $this->view->error = "请输入验证码";
+ return true;
+ }
+
+ if(!isset($_SESSION['captcha']))
+ {
+ $_SESSION['captcha'] = md5(time());
+ }
+
+ if ($captchaword != $_SESSION['captcha']) {
+ $this->setCaptcha($captcha);
+ $this->view->error = "验证码错误";
+ return true;
+ }
+
+ if (!$this->login($username,$password))
+ {
+ $this->setCaptcha($captcha);
+ $this->view->error = "用户名或密码错误";
+ $this->view->userid = $username;
+ return true;
+ }
+ else
+ {
+ if(!empty($tohref))
+ {
+ view::Post($this,"登录成功,正在跳转",$tohref);
+ return true;
+ }
+ }
+ }else{
+ $this->setCaptcha($captcha);
+ }
+
+ }
+
+ function loadCaptcha()
+ {
+ $captcha = new Zend_Captcha_Image(array(
+ 'captcha' => 'Image',
+ 'wordLen' => 4,
+ 'fontsize'=>16,
+ 'width' => 100,
+ 'height' => 38,
+ 'dotNoiseLevel'=>2,
+ 'lineNoiseLevel'=>1,
+ 'timeout' => 300,
+ 'font' => '../data/fonts/ggbi.ttf',
+ 'imgDir' => 'vdimg/',
+ 'imgUrl' => '/vdimg',
+ ));
+ return $captcha;
+ }
+
+ function setCaptcha(Zend_Captcha_Image $captcha,$ajax = false){
+ $captcha->generate();
+ $_SESSION['captcha'] = $captcha->getWord();
+ $url = $captcha->getImgUrl()
+ .$captcha->getId()
+ .$captcha->getSuffix();
+ if(!$ajax)
+ {
+ $this->view->captcha = $url;
+ }else{
+ return $url;
+ }
+ }
+
+ function captchaAction()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $captcha = $this->loadCaptcha();
+ $url = $this->setCaptcha($captcha,true);
+
+ echo $url;
+ return true;
+ }
+
+ function logoutAction()
+ {
+ $auth = Zend_Auth::getInstance();
+ $auth->clearIdentity();
+ require_once 'member.php';
+ $mb=new member();
+ member::flushcookie();
+ $this->_redirect('/');
+ }
+
+ private function default_login($u,$p)
+ {
+ $auth = Zend_Auth::getInstance();
+ $db=Zend_Registry::get('db');
+
+ $authAdapter = new Zend_Auth_Adapter_DbTable($db);
+ $authAdapter->setTableName('users')
+ ->setIdentityColumn('username')
+ ->setCredentialColumn('password');
+ $authAdapter->setIdentity($u)->setCredential(md5($p));
+ $result = $auth->authenticate($authAdapter);
+ if ($result->isValid()) {
+ // success: store database row to auth's storage
+ $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($db);
+ $data->gid = $usr->getGroup($data->id);
+
+ $auth->getStorage()->write($data);
+ $db->query("update users set ts_last_login=now() where username=?",array($u));
+
+ if ($this->_request->getParam('remember')) {
+ $sql="select usertype from users where username='$u'";
+ $rs=$db->query($sql);
+ $row=$rs->fetch();
+ //if($row['usertype']!='administrator')
+ {
+ require_once 'member.php';
+ $mb = new member();
+ $mb -> putcookie($u,md5($p));
+ }
+ }
+
+ return true;
+ }else
+ {
+ return false;
+ }
+ return false;
+ }
+ private function aspnet_login($p,$salt,$password)
+ {
+ $p1=implode("\x00",str_split($p))."\x00";
+ $ball=base64_decode($salt).$p1;
+ return trim($password)==base64_encode(sha1($ball,true));
+ }
+ // 首先判断是否存在salt
+ // 若有salt,则按照aspnet membership加密算法进行判断
+ function login($u,$p)
+ {
+ $ut= new UsersTable();
+ $db=$ut->getAdapter();
+ $sql="select password,salt from users where username=?";
+ $uq=$db->query($sql,array($u));
+ if ($urow=$uq->fetchObject())
+ {
+ if (empty($urow->salt))
+ return $this->default_login($u,$p);
+ else {
+ //进行判断并进行转换到默认
+ if ($this->aspnet_login($p,$urow->salt,$urow->password))
+ {
+ $sql="update users set password=md5(?),salt='' where username=?";
+ $db->query($sql,array($p,$u));
+ return $this->default_login($u,$p);
+ } else
+ return false;
+ }
+ } else {
+ //没有对应的用户,登录失败
+ return false;
+ }
+ }
+ function fetchpwdAction()
+ {
+ $ut= new UsersTable();
+ $db=$ut->getAdapter();
+ $form = new LostpwdForm();
+ $key=$this->_request->getParam('key');
+ $login=$this->_request->getParam('login');
+ if (empty($key) && empty($login)) {
+ $this->view->form = $form;
+ if ($this->_request->isPost()) {
+ $formData = $this->_request->getPost();
+ if ($form->isValid($formData)) {
+ $sql="select * from users where email=?";
+ $uq=$db->query($sql,array($formData['email']));
+ if ($urow=$uq->fetchObject())
+ {
+ //email the url to user
+ $username=$urow->username;
+ $sql="update users set activation=? where email=?";
+ $uid=uniqid();
+ $db->query($sql,array($uid,$formData['email']));
+
+ //发邮件
+ $mail_template = "users-changepassword";
+ $mail_data = array(
+ 'name'=>$username,
+ 'url' => view::getHostLink()."/account/fetchpwd/".$username."/".$uid
+ );
+
+ $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
+ $this->messenger->addMessage('对不起,没有找到对应的电子邮件地址。');
+ }
+ } else
+ $this->view->messages[]='请输入您的电子邮件地址。您将通过电子邮件收到新密码。';
+ } else {
+ $sql="select * from users where username=? and activation=?";
+ $uq=$db->query($sql,array($login,$key));
+ $tmp_pwd=uniqid();
+ if ($urow=$uq->fetchObject())
+ {
+ $sql="update users set salt='',activation='',password=md5('".$tmp_pwd."') where username=? and activation=?";
+ $db->query($sql,array($login,$key));
+
+ //发邮件
+ $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
+
+ }
+ }
+
+ } //找回密码
+
+ //OAuth2登录跳转页面
+ public function oauth2loginAction()
+ {
+ $type = $this->_getParam('type');
+ $client = new Client();
+ $url = $client->makeRequestCodeUrl($type);
+
+ view::Post($this,"为您转入科技网登录入口",$url);
+ }
+
+ //oauth2登录回调地址
+ public function callbackAction()
+ {
+ $type = $this->_getParam('type');
+ $code = $this->_getParam('code');
+
+ $client = new Client($type);
+
+ $client->initSource();
+ $target = $client->getSource()->getTarget($type);
+ $this->view->target_name = $target['name'];
+
+ $token = $client->requestToken($code);
+
+ if(is_string($token))
+ {
+ view::Post($this,$token,'/account/login');
+ }
+
+ $status = $client->storageTokenData($type,$token);
+
+ if($status === true)
+ {
+ echo "";
+ }else{
+ echo $status;
+ }
+ }
+
+}
+
From 580e97cc9d13198e61bce2a8813cb5758162c32f Mon Sep 17 00:00:00 2001
From: wlx
Date: Fri, 22 Nov 2013 03:16:53 +0000
Subject: [PATCH 068/126] change acl
---
application/models/CustomControllerAclManager.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/models/CustomControllerAclManager.php b/application/models/CustomControllerAclManager.php
index 7e275887..60330350 100755
--- a/application/models/CustomControllerAclManager.php
+++ b/application/models/CustomControllerAclManager.php
@@ -32,7 +32,7 @@
$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',
+ $this->acl->allow('guest', 'account', array('login','oauth2login','callback',
'logout',
'captcha',
'fetchpwd',
From 74a5e3f5fc02dfeabb8b6fefb982975712184c76 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Fri, 22 Nov 2013 03:29:30 +0000
Subject: [PATCH 069/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86Oauth?=
=?UTF-8?q?=E7=99=BB=E5=BD=95=E6=97=B6=E5=AF=86=E7=A0=81=E9=87=8D=E5=A4=8D?=
=?UTF-8?q?md5=E7=9A=84bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Handler/ClientTokenHandler/Escience.php | 364 ++++-----
application/module/Users/Account.php | 737 +++++++++---------
2 files changed, 553 insertions(+), 548 deletions(-)
diff --git a/application/module/Open/Handler/ClientTokenHandler/Escience.php b/application/module/Open/Handler/ClientTokenHandler/Escience.php
index 4c13a8e2..68759322 100644
--- a/application/module/Open/Handler/ClientTokenHandler/Escience.php
+++ b/application/module/Open/Handler/ClientTokenHandler/Escience.php
@@ -1,182 +1,182 @@
-db = \Zend_Registry::get('db');
- }else{
- $this->db = $db;
- }
-
- $this->config = \Zend_Registry::get('config');
- $this->table = new Table();
-
- //预处理token信息
- $status = $this->preProcess($token);
- }
-
- //考虑加一个接口,每个Token操作类中必须包含此函数
- public function doit()
- {
- //makeUserStorage在先,必须的
- $status = $this->makeUserStorage();
-
- if($status!==true)
- {
- return $status;
- }
-
- $status = $this->makeTokenStorage();
-
- if($status !== true)
- {
- return $status;
- }
-
- return true;
- }
-
- //预处理
- public function preProcess($tokenData)
- {
- if(!is_array($tokenData))
- {
- return "参数错误";
- }
-
- $this->userInfo = json_decode($tokenData['userInfo'],true);
-
- unset($tokenData['userInfo']);
-
- $this->token = $tokenData;
-
- return true;
- }
-
- //检查用户信息,如果没有用户自动注册,有用户就自动绑定。
- public function makeUserStorage()
- {
- $uid = view::User('id');
-
- if(is_numeric($uid) && $uid > 0)
- {
- $this->userid = $uid;
- return "您已经登录,无需重复登录";
- }
-
- if(empty($this->userid))
- {
- $current_oauth_email = $this->userInfo['cstnetId'];
-
- $user = new Users(TRUE);
- $current = $user->userExists($current_oauth_email);
-
- if($current === false)
- //自动注册用户
- {
- $data = array(
- $user->account->FieldUsername => $current_oauth_email,
- $user->account->FieldEmail => $current_oauth_email,
- $user->account->FieldPasword => 0,
- $user->account->FieldRealname => $this->userInfo['truename'],
- );
-
- $dbh = new dbh();
-
- $id = $dbh->insert($user->account->memberTable,$data,true);
-
- //登录
- $user->account->storeLogin(array(
- $user->account->FieldUsername => $data[$user->account->FieldUsername],
- $user->account->FieldPasword => $data[$user->account->FieldPasword]
- ));
-
- $this->userid = $id;
-
- return true;
- }
-
- //帮用户自动登录
- else{
-
- $user->account->storeLogin(array(
- $user->account->FieldUsername => $current[$user->account->FieldUsername],
- $user->account->FieldPasword => $current[$user->account->FieldPasword]
- ));
-
- $this->userid = $current[$user->account->FieldIndex];
-
- return true;
- }
-
- }
-
- }
-
- //生成写入token表的数据
- //有token记录就更新,没有再插入
- public function makeTokenStorage()
- {
- $data = array(
- 'access_token' => $this->token['access_token'],
- 'refresh_token' => $this->token['refresh_token'],
- 'expires_in' => $this->token['expires_in'],
- 'userid' => $this->userid,
- "response_data" => json_encode($this->userInfo,JSON_NUMERIC_CHECK),
- "source" => "escience"
- );
-
- //查看用户用escience登录的记录是否存在
- $sql = "SELECT * FROM {$this->table->oauth_token} WHERE userid={$this->userid} AND source='{$data['source']}' LIMIT 1";
- $rs = $this->db->query($sql);
- $row = $rs->fetch();
-
- $dbh = new dbh();
-
- if(isset($row['id']))
- {
- $status = $dbh->update($this->table->oauth_token,$data," id={$row['id']} AND userid={$this->userid} ");
- if($status)
- {
- return true;
- }else{
- return "更新授权信息时发生错误,请重新登录";
- }
- }else{
- $status = $dbh->insert($this->table->oauth_token,$data);
- if($status)
- {
- return true;
- }else{
- return "记录授权信息时发生错误,请重新登录";
- }
- }
-
- return true;
- }
-
-
-}
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+
+ //预处理token信息
+ $status = $this->preProcess($token);
+ }
+
+ //考虑加一个接口,每个Token操作类中必须包含此函数
+ public function doit()
+ {
+ //makeUserStorage在先,必须的
+ $status = $this->makeUserStorage();
+
+ if($status!==true)
+ {
+ return $status;
+ }
+
+ $status = $this->makeTokenStorage();
+
+ if($status !== true)
+ {
+ return $status;
+ }
+
+ return true;
+ }
+
+ //预处理
+ public function preProcess($tokenData)
+ {
+ if(!is_array($tokenData))
+ {
+ return "参数错误";
+ }
+
+ $this->userInfo = json_decode($tokenData['userInfo'],true);
+
+ unset($tokenData['userInfo']);
+
+ $this->token = $tokenData;
+
+ return true;
+ }
+
+ //检查用户信息,如果没有用户自动注册,有用户就自动绑定。
+ public function makeUserStorage()
+ {
+ $uid = view::User('id');
+
+ if(is_numeric($uid) && $uid > 0)
+ {
+ $this->userid = $uid;
+ return "您已经登录,无需重复登录";
+ }
+
+ if(empty($this->userid))
+ {
+ $current_oauth_email = $this->userInfo['cstnetId'];
+
+ $user = new Users(TRUE);
+ $current = $user->userExists($current_oauth_email);
+
+ if($current === false)
+ //自动注册用户
+ {
+ $data = array(
+ $user->account->FieldUsername => $current_oauth_email,
+ $user->account->FieldEmail => $current_oauth_email,
+ $user->account->FieldPasword => 0,
+ $user->account->FieldRealname => $this->userInfo['truename'],
+ );
+
+ $dbh = new dbh();
+
+ $id = $dbh->insert($user->account->memberTable,$data,true);
+
+ //登录
+ $user->account->storeLogin(array(
+ $user->account->FieldUsername => $data[$user->account->FieldUsername],
+ $user->account->FieldPasword => $data[$user->account->FieldPasword]
+ ));
+
+ $this->userid = $id;
+
+ return true;
+ }
+
+ //帮用户自动登录
+ else{
+
+ $user->account->storeLogin(array(
+ $user->account->FieldUsername => $current[$user->account->FieldUsername],
+ $user->account->FieldPasword => $current[$user->account->FieldPasword]
+ ),false);
+
+ $this->userid = $current[$user->account->FieldIndex];
+
+ return true;
+ }
+
+ }
+
+ }
+
+ //生成写入token表的数据
+ //有token记录就更新,没有再插入
+ public function makeTokenStorage()
+ {
+ $data = array(
+ 'access_token' => $this->token['access_token'],
+ 'refresh_token' => $this->token['refresh_token'],
+ 'expires_in' => $this->token['expires_in'],
+ 'userid' => $this->userid,
+ "response_data" => json_encode($this->userInfo,JSON_NUMERIC_CHECK),
+ "source" => "escience"
+ );
+
+ //查看用户用escience登录的记录是否存在
+ $sql = "SELECT * FROM {$this->table->oauth_token} WHERE userid={$this->userid} AND source='{$data['source']}' LIMIT 1";
+ $rs = $this->db->query($sql);
+ $row = $rs->fetch();
+
+ $dbh = new dbh();
+
+ if(isset($row['id']))
+ {
+ $status = $dbh->update($this->table->oauth_token,$data," id={$row['id']} AND userid={$this->userid} ");
+ if($status)
+ {
+ return true;
+ }else{
+ return "更新授权信息时发生错误,请重新登录";
+ }
+ }else{
+ $status = $dbh->insert($this->table->oauth_token,$data);
+ if($status)
+ {
+ return true;
+ }else{
+ return "记录授权信息时发生错误,请重新登录";
+ }
+ }
+
+ return true;
+ }
+
+
+}
diff --git a/application/module/Users/Account.php b/application/module/Users/Account.php
index 1297d529..717a34d6 100644
--- a/application/module/Users/Account.php
+++ b/application/module/Users/Account.php
@@ -1,367 +1,372 @@
-db = \Zend_Registry::get('db');
- }else{
- $this->db = $db;
- }
-
- $this->config = \Zend_Registry::get('config');
-
- if($initializingListener === TRUE)
- {
- $this->loadListener();
- }
- }
-
- public function loadListener()
- {
- //主要操作,账号注册,登录,设置session等
- $AccountListener = new AccountListener();
- @$this->events()->attachAggregate($AccountListener);
-
- //账户编辑
- $EditListener = new EditListener();
- @$this->events()->attachAggregate($EditListener);
-
- //账户安全性(找回密码)
- $PwdListener = new PwdListener();
- @$this->events()->attachAggregate($PwdListener);
- }
-
- 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
- //将登录信息保存在session和cookie中
- 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);
-
- if($data[$this->FieldPasword] == 0)
- {
- $password = "0";
- }else{
- $password = md5($data[$this->FieldPasword]);
- }
-
- $authAdapter->setIdentity($data[$this->FieldUsername])->setCredential($password);
-
- $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;
-
- }
-
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+
+ if($initializingListener === TRUE)
+ {
+ $this->loadListener();
+ }
+ }
+
+ public function loadListener()
+ {
+ //主要操作,账号注册,登录,设置session等
+ $AccountListener = new AccountListener();
+ @$this->events()->attachAggregate($AccountListener);
+
+ //账户编辑
+ $EditListener = new EditListener();
+ @$this->events()->attachAggregate($EditListener);
+
+ //账户安全性(找回密码)
+ $PwdListener = new PwdListener();
+ @$this->events()->attachAggregate($PwdListener);
+ }
+
+ 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
+ //将登录信息保存在session和cookie中
+ public function storeLogin($data,$md5verify = true)
+ {
+ $auth = \Zend_Auth::getInstance();
+ $authAdapter = new \Zend_Auth_Adapter_DbTable($this->db);
+ $authAdapter->setTableName($this->memberTable)
+ ->setIdentityColumn($this->FieldUsername)
+ ->setCredentialColumn($this->FieldPasword);
+
+ if($data[$this->FieldPasword] == 0)
+ {
+ $password = "0";
+ }else{
+ if($md5verify === false)
+ {
+ $password = $data[$this->FieldPasword];
+ }else{
+ $password = md5($data[$this->FieldPasword]);
+ }
+ }
+
+ $authAdapter->setIdentity($data[$this->FieldUsername])->setCredential($password);
+
+ $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;
+
+ }
+
}
\ No newline at end of file
From eb98d79dfc747c35f9fc32db40cb2a1fdfaa7661 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Tue, 26 Nov 2013 09:40:33 +0000
Subject: [PATCH 070/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E9=87=8D?=
=?UTF-8?q?=E7=BD=AE=E7=94=B3=E8=AF=B7=E8=A1=A8=E7=9A=84=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=BF=AE=E6=94=B9=E7=8A=B6?=
=?UTF-8?q?=E6=80=81=E4=BB=A3=E7=A0=81=E7=9A=84=E9=83=A8=E5=88=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../module/Order/Manager/Offlineapp.php | 20 +++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/application/module/Order/Manager/Offlineapp.php b/application/module/Order/Manager/Offlineapp.php
index 099692d2..15a15168 100644
--- a/application/module/Order/Manager/Offlineapp.php
+++ b/application/module/Order/Manager/Offlineapp.php
@@ -75,15 +75,15 @@ class Offlineapp
";
$rs = $this->db->query($sql);
return $rs->fetchAll();
- }//
-
- //判断是否存在wsn数据申请
- public function hasWsnData($id)
- {
- $sql="select count(d.id) as wsn from dataorder d left join dataservice s on d.uuid=s.uuid where d.offlineappid=$id and s.service_type in (1,2) and position('waterwsn' in s.service_url)>0 and d.selection is not null";
- $rs=$this->db->query($sql);
- $row=$rs->fetch();
- return $row['wsn'];
+ }//
+
+ //判断是否存在wsn数据申请
+ public function hasWsnData($id)
+ {
+ $sql="select count(d.id) as wsn from dataorder d left join dataservice s on d.uuid=s.uuid where d.offlineappid=$id and s.service_type in (1,2) and position('waterwsn' in s.service_url)>0 and d.selection is not null";
+ $rs=$this->db->query($sql);
+ $row=$rs->fetch();
+ return $row['wsn'];
}
//重置申请表
@@ -100,7 +100,7 @@ class Offlineapp
@unlink($row['applicationform']);
}
- if($this->db->exec("UPDATE offlineapp SET applicationform=NULL WHERE id=$id")>0)
+ if($this->db->exec("UPDATE offlineapp SET applicationform=NULL,status=2 WHERE id=$id")>0 && $this->db->exec("UPDATE dataorder SET status=2 WHERE offlineappid=$id"))
{
@$this->events()->trigger('offlineapp.AppFormReseted', $this, compact('id'));
return true;
From 35c08833553790713ef87d4cd206a41414589a07 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Tue, 26 Nov 2013 10:04:02 +0000
Subject: [PATCH 071/126] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86card.westgis?=
=?UTF-8?q?.ac.cn=E7=9A=84=E7=A7=91=E6=8A=80=E7=BD=91=E9=80=9A=E8=A1=8C?=
=?UTF-8?q?=E8=AF=81Appkey=E5=92=8CAppsecret?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Open/Source.php | 61 ++++++++++++++++++++++--------
1 file changed, 46 insertions(+), 15 deletions(-)
diff --git a/application/module/Open/Source.php b/application/module/Open/Source.php
index 51e82760..49730998 100644
--- a/application/module/Open/Source.php
+++ b/application/module/Open/Source.php
@@ -50,8 +50,13 @@ class Source
"code"=>"code"
);
- if($this->website == 'westdc'){
+ //新浪微博(新浪通行证)
+ $this->source->sina = new stdClass();
+ $this->source->sina->param = array(
+ );
+
+ if($this->website == 'westdc'){
$this->source->escience->config = array(
'id' => '71852',
'secret' => 'ad7gd3jZgbzhQM6vIh9vPnQFZQoTGHZI',
@@ -61,11 +66,9 @@ class Source
'theme'=>'full'
)
);
-
}
if($this->website == 'heihedata'){
-
$this->source->escience->config = array(
'id' => '78969',
'secret' => 'iTGKdCkUPakA2hza2TJ4XZ4cnwlh8Hqz',
@@ -75,9 +78,48 @@ class Source
'theme'=>'full'
)
);
-
}
+ if($this->website == 'card'){
+ $this->source->escience->config = array(
+ 'id' => '58176',
+ 'secret' => 'ZM5dEFX5GpJC62IcJ3iajx51T9hzhJkQ',
+ 'index' => 'http://card.westgis.ac.cn/',
+ 'callback' => 'http://card.westgis.ac.cn/account/callback/type/escience',
+ 'other' => array(
+ 'theme'=>'full'
+ )
+ );
+ }
+
+ }
+
+ //Oauth2登录目标
+ /*
+ name : 名称
+ code : 获取code的url
+ token : 获取 token的url
+ code_response : 获取token时使用的参数值(配合$this->source->OBJECTIVE->param中的code_response使用
+ grant_type : 获得token的认证方式,按照oauth2标准,应该是authorization_code
+ */
+ private function initTarget(){
+ //中国科技网通行证
+ $this->target->escience = array(
+ 'name' => '中国科技网通行证',
+ 'code' => 'http://passport.escience.cn/oauth2/authorize',
+ 'token' => 'https://passport.escience.cn/oauth2/token',
+ 'code_response' => 'code',
+ 'grant_type' => 'authorization_code',
+ );
+
+ //新浪
+ $this->target->sina = array(
+ 'name' => '新浪微博',
+ 'code' => 'https://api.weibo.com/oauth2/authorize',
+ 'token' => '',
+ 'code_response' => 'code',
+ 'grant_type' => 'authorization_code'
+ );
}
//获得一个源
@@ -96,17 +138,6 @@ class Source
}
}
- //Oauth2登录目标
- private function initTarget(){
- $this->target->escience = array(
- 'name' => '中国科技网通行证',
- 'code' => 'http://passport.escience.cn/oauth2/authorize',
- 'token' => 'https://passport.escience.cn/oauth2/token',
- 'code_response' => 'code',
- 'grant_type' => 'authorization_code',
- );
- }
-
//获得Oauth2登录模板
public function getTarget($type = "")
{
From 5ae05fb85d4581b3843595e329ab3418a4df3ace Mon Sep 17 00:00:00 2001
From: wlx
Date: Fri, 29 Nov 2013 01:47:32 +0000
Subject: [PATCH 072/126] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=88=90=E6=9E=9C?=
=?UTF-8?q?=E5=B1=95=E7=A4=BA=E4=B8=AD=E7=9A=84=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/default/controllers/AboutController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/default/controllers/AboutController.php b/application/default/controllers/AboutController.php
index 27f44c3a..647115d9 100755
--- a/application/default/controllers/AboutController.php
+++ b/application/default/controllers/AboutController.php
@@ -86,7 +86,7 @@ class AboutController extends Zend_Controller_Action
$siteid="e31f5ea7-a4af-4ae3-9ac1-1a84132c4338";//site uuid from geonetowrk
if(empty($ac))
{
- $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=? and mr.reftype=0 order by r.year desc,r.title asc";
$sth = $this->db->prepare($sql);
$sth->execute(array($siteid));
$rows = $sth->fetchAll();
From 8f208ef7c5b96ba023ad61ca8465c4c6b959cc9f Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Fri, 29 Nov 2013 02:26:06 +0000
Subject: [PATCH 073/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9curl=E4=B8=AD?=
=?UTF-8?q?=E4=B8=8D=E8=83=BD=E5=88=9D=E5=A7=8B=E5=8C=96=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E7=9A=84bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Helpers/Curl.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/module/Helpers/Curl.php b/application/module/Helpers/Curl.php
index f801e43d..b36ad768 100644
--- a/application/module/Helpers/Curl.php
+++ b/application/module/Helpers/Curl.php
@@ -9,7 +9,7 @@ class Curl
public function __construct($options = array())
{
-
+ $this->initOptions($options);
}
public function initOptions($options = array())
From 88e29d711e7239f1d240da627bce022da24396f9 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Wed, 18 Dec 2013 02:43:10 +0000
Subject: [PATCH 074/126] =?UTF-8?q?=E5=9C=A8hiwater=E4=B8=AD=E7=9A=84?=
=?UTF-8?q?=E5=A4=9A=E7=AF=87=E6=96=87=E7=8C=AE=E5=BC=95=E7=94=A8=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E4=B8=AD=E5=8A=A0=E5=85=A5=E4=BA=86=E6=9F=A5=E7=9C=8B?=
=?UTF-8?q?=E5=92=8C=E4=B8=8B=E8=BD=BD=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/default/views/scripts/hiwater/view.phtml | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/application/default/views/scripts/hiwater/view.phtml b/application/default/views/scripts/hiwater/view.phtml
index 7a851a6d..1cf65878 100644
--- a/application/default/views/scripts/hiwater/view.phtml
+++ b/application/default/views/scripts/hiwater/view.phtml
@@ -46,9 +46,16 @@ if ($md->title_en) echo ' '.$this->escape($md->title_en);?>
mcitation as $ref) :
if (empty($ref->link))
- echo ''.$ref->reference.' ';
+ {
+ echo ''.$ref->reference;
+ echo ' 查看 ';
+ if(!empty($ref->attid)) {
+ echo ' 下载 ';
+ }
+ echo " ";
+ }
else
- echo ''.$ref->reference.' 下载 ';
+ echo ''.$ref->reference.' 查看 下载 ';
endforeach;
?>
From 548369039585adb170331a2a6662957ebacc11a5 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Tue, 24 Dec 2013 09:39:34 +0000
Subject: [PATCH 075/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9form=E5=AE=BD?=
=?UTF-8?q?=E5=BA=A6=E8=B6=85=E5=87=BA=E9=A1=B5=E9=9D=A2=E7=9A=84bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/default/views/scripts/account/edit.phtml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/application/default/views/scripts/account/edit.phtml b/application/default/views/scripts/account/edit.phtml
index c37d8411..db4eff44 100755
--- a/application/default/views/scripts/account/edit.phtml
+++ b/application/default/views/scripts/account/edit.phtml
@@ -53,13 +53,13 @@
@@ -107,13 +107,13 @@
}else{ ?>
- = $this->error ?>
+ = $this->error['error'] ?>
diff --git a/application/module/Helpers/Captcha.php b/application/module/Helpers/Captcha.php
new file mode 100644
index 00000000..dc61b759
--- /dev/null
+++ b/application/module/Helpers/Captcha.php
@@ -0,0 +1,52 @@
+loadCaptcha();
+ }
+
+ public function loadCaptcha()
+ {
+ $this->captcha = new \Zend_Captcha_Image(array(
+ 'captcha' => 'Image',
+ 'wordLen' => 4,
+ 'fontsize'=>16,
+ 'width' => 100,
+ 'height' => 38,
+ 'dotNoiseLevel'=>2,
+ 'lineNoiseLevel'=>1,
+ 'timeout' => 300,
+ 'font' => '../data/fonts/ggbi.ttf',
+ 'imgDir' => 'vdimg/',
+ 'imgUrl' => '/vdimg',
+ ));
+ }
+
+ public function setCaptcha(){
+ $this->captcha->generate();
+ $_SESSION[$this->sessionName] = $this->captcha->getWord();
+ $url = $this->captcha->getImgUrl()
+ .$this->captcha->getId()
+ .$this->captcha->getSuffix();
+
+ return $url;
+ }
+
+ public function isValid($captchaword)
+ {
+ if($captchaword == $_SESSION[$this->sessionName])
+ {
+ return true;
+ }else{
+ return false;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Users/Account.php b/application/module/Users/Account.php
index 717a34d6..1e35480b 100644
--- a/application/module/Users/Account.php
+++ b/application/module/Users/Account.php
@@ -1,372 +1,374 @@
-db = \Zend_Registry::get('db');
- }else{
- $this->db = $db;
- }
-
- $this->config = \Zend_Registry::get('config');
-
- if($initializingListener === TRUE)
- {
- $this->loadListener();
- }
- }
-
- public function loadListener()
- {
- //主要操作,账号注册,登录,设置session等
- $AccountListener = new AccountListener();
- @$this->events()->attachAggregate($AccountListener);
-
- //账户编辑
- $EditListener = new EditListener();
- @$this->events()->attachAggregate($EditListener);
-
- //账户安全性(找回密码)
- $PwdListener = new PwdListener();
- @$this->events()->attachAggregate($PwdListener);
- }
-
- 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
- //将登录信息保存在session和cookie中
- public function storeLogin($data,$md5verify = true)
- {
- $auth = \Zend_Auth::getInstance();
- $authAdapter = new \Zend_Auth_Adapter_DbTable($this->db);
- $authAdapter->setTableName($this->memberTable)
- ->setIdentityColumn($this->FieldUsername)
- ->setCredentialColumn($this->FieldPasword);
-
- if($data[$this->FieldPasword] == 0)
- {
- $password = "0";
- }else{
- if($md5verify === false)
- {
- $password = $data[$this->FieldPasword];
- }else{
- $password = md5($data[$this->FieldPasword]);
- }
- }
-
- $authAdapter->setIdentity($data[$this->FieldUsername])->setCredential($password);
-
- $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;
-
- }
-
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+
+ if($initializingListener === TRUE)
+ {
+ $this->loadListener();
+ }
+ }
+
+ public function loadListener()
+ {
+ //主要操作,账号注册,登录,设置session等
+ $AccountListener = new AccountListener();
+ @$this->events()->attachAggregate($AccountListener);
+
+ //账户编辑
+ $EditListener = new EditListener();
+ @$this->events()->attachAggregate($EditListener);
+
+ //账户安全性(找回密码)
+ $PwdListener = new PwdListener();
+ @$this->events()->attachAggregate($PwdListener);
+ }
+
+ 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
+ //将登录信息保存在session和cookie中
+ public function storeLogin($data,$md5verify = true)
+ {
+ $auth = \Zend_Auth::getInstance();
+ $authAdapter = new \Zend_Auth_Adapter_DbTable($this->db);
+ $authAdapter->setTableName($this->memberTable)
+ ->setIdentityColumn($this->FieldUsername)
+ ->setCredentialColumn($this->FieldPasword);
+
+ if($data[$this->FieldPasword] === 0)
+ {
+ $password = "0";
+ }else{
+ if($md5verify == false)
+ {
+ $password = $data[$this->FieldPasword];
+ }else{
+ $password = md5($data[$this->FieldPasword]);
+ }
+ }
+
+ $authAdapter->setIdentity($data[$this->FieldUsername])->setCredential($password);
+ $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);
+ }else{
+ return array("error"=>"用户信息验证失败,请重新登录");
+ }
+ 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;
+
+ }
+
}
\ No newline at end of file
diff --git a/application/module/Users/Member.php b/application/module/Users/Member.php
index 9854e6f1..fcb2bce2 100644
--- a/application/module/Users/Member.php
+++ b/application/module/Users/Member.php
@@ -1,5 +1,5 @@
"用户名应当以字母开头,由字母数字和下划线组成,并且长度在5到25个字符之间",'place'=>'username');
+ return array('error'=>"用户名应当以字母开头,由字母数字和下划线组成,并且长度在3到25个字符之间",'place'=>'username');
}
}
@@ -106,6 +106,10 @@ class LoginOperate implements \Users\Event\LoginEvent
}//loginSuccess
-
+ //检查token表记录
+ public function checkOAuthToken()
+ {
+
+ }
}
\ No newline at end of file
From e8aba81d7d85d94a1a0f08dcf89303ee5cacb26f Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Thu, 26 Dec 2013 07:12:59 +0000
Subject: [PATCH 078/126] =?UTF-8?q?=E4=B8=BA=E9=82=AE=E4=BB=B6=E6=A8=A1?=
=?UTF-8?q?=E6=9D=BF=E5=8A=9F=E8=83=BD=E6=B7=BB=E5=8A=A0=E5=86=97=E9=94=99?=
=?UTF-8?q?=E5=88=A4=E6=96=AD=EF=BC=8C=E4=BD=BF=E7=94=A8=E6=A8=A1=E5=9D=97?=
=?UTF-8?q?=E5=8C=96=E5=B0=81=E8=A3=85=E7=9A=84=E6=89=BE=E5=9B=9E=E5=AF=86?=
=?UTF-8?q?=E7=A0=81=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../default/controllers/AccountController.php | 254 +++++-------------
.../account/account-resetpassword.phtml | 41 +++
.../views/scripts/account/fetchpwd.phtml | 79 ++++--
application/module/Mail/Mail.php | 7 +-
application/module/Users/Account.php | 17 +-
.../module/Users/Operation/PwdOperate.php | 9 +-
6 files changed, 187 insertions(+), 220 deletions(-)
create mode 100644 application/default/views/scripts/account/account-resetpassword.phtml
diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php
index 37691bc2..fc35b8bb 100755
--- a/application/default/controllers/AccountController.php
+++ b/application/default/controllers/AccountController.php
@@ -2,6 +2,7 @@
use Mail\Mail;
use Open\Client;
use Users\Account;
+use Users\Member;
use Helpers\Captcha;
use Helpers\View as view;
@@ -357,211 +358,92 @@ class AccountController extends Zend_Controller_Action
$this->view->captcha = $captcha->setCaptcha();
}
- function loadCaptcha()
+ public function captchaAction()
{
- $captcha = new Zend_Captcha_Image(array(
- 'captcha' => 'Image',
- 'wordLen' => 4,
- 'fontsize'=>16,
- 'width' => 100,
- 'height' => 38,
- 'dotNoiseLevel'=>2,
- 'lineNoiseLevel'=>1,
- 'timeout' => 300,
- 'font' => '../data/fonts/ggbi.ttf',
- 'imgDir' => 'vdimg/',
- 'imgUrl' => '/vdimg',
- ));
- return $captcha;
- }
-
- function setCaptcha(Zend_Captcha_Image $captcha,$ajax = false){
- $captcha->generate();
- $_SESSION['captcha'] = $captcha->getWord();
- $url = $captcha->getImgUrl()
- .$captcha->getId()
- .$captcha->getSuffix();
- if(!$ajax)
+ if(view::isXmlHttpRequest($this))
{
- $this->view->captcha = $url;
+ $captcha = new Captcha();
+ $url = $captcha->setCaptcha();
+ echo $url;
+ return true;
}else{
- return $url;
+ echo "bad request!";
+ exit();
}
}
-
- function captchaAction()
- {
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
-
- $captcha = $this->loadCaptcha();
- $url = $this->setCaptcha($captcha,true);
-
- echo $url;
- return true;
- }
- function logoutAction()
+ public function logoutAction()
{
$auth = Zend_Auth::getInstance();
$auth->clearIdentity();
- require_once 'member.php';
- $mb=new member();
- member::flushcookie();
+ Member::flushcookie();
$this->_redirect('/');
- }
-
- private function default_login($u,$p)
- {
- $auth = Zend_Auth::getInstance();
- $db=Zend_Registry::get('db');
-
- $authAdapter = new Zend_Auth_Adapter_DbTable($db);
- $authAdapter->setTableName('users')
- ->setIdentityColumn('username')
- ->setCredentialColumn('password');
- $authAdapter->setIdentity($u)->setCredential(md5($p));
- $result = $auth->authenticate($authAdapter);
- if ($result->isValid()) {
- // success: store database row to auth's storage
- $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($db);
- $data->gid = $usr->getGroup($data->id);
-
- $auth->getStorage()->write($data);
- $db->query("update users set ts_last_login=now() where username=?",array($u));
-
- if ($this->_request->getParam('remember')) {
- $sql="select usertype from users where username='$u'";
- $rs=$db->query($sql);
- $row=$rs->fetch();
- //if($row['usertype']!='administrator')
- {
- require_once 'member.php';
- $mb = new member();
- $mb -> putcookie($u,md5($p));
- }
- }
-
- return true;
- }else
- {
- return false;
- }
- return false;
- }
- private function aspnet_login($p,$salt,$password)
- {
- $p1=implode("\x00",str_split($p))."\x00";
- $ball=base64_decode($salt).$p1;
- return trim($password)==base64_encode(sha1($ball,true));
- }
- // 首先判断是否存在salt
- // 若有salt,则按照aspnet membership加密算法进行判断
- function login($u,$p)
- {
- $ut= new UsersTable();
- $db=$ut->getAdapter();
- $sql="select password,salt from users where username=?";
- $uq=$db->query($sql,array($u));
- if ($urow=$uq->fetchObject())
- {
- if (empty($urow->salt))
- return $this->default_login($u,$p);
- else {
- //进行判断并进行转换到默认
- if ($this->aspnet_login($p,$urow->salt,$urow->password))
- {
- $sql="update users set password=md5(?),salt='' where username=?";
- $db->query($sql,array($p,$u));
- return $this->default_login($u,$p);
- } else
- return false;
- }
- } else {
- //没有对应的用户,登录失败
- return false;
- }
}
- function fetchpwdAction()
+
+ public function fetchpwdAction()
{
- $ut= new UsersTable();
- $db=$ut->getAdapter();
- $form = new LostpwdForm();
- $key=$this->_request->getParam('key');
- $login=$this->_request->getParam('login');
- if (empty($key) && empty($login)) {
- $this->view->form = $form;
- if ($this->_request->isPost()) {
- $formData = $this->_request->getPost();
- if ($form->isValid($formData)) {
- $sql="select * from users where email=?";
- $uq=$db->query($sql,array($formData['email']));
- if ($urow=$uq->fetchObject())
- {
- //email the url to user
- $username=$urow->username;
- $sql="update users set activation=? where email=?";
- $uid=uniqid();
- $db->query($sql,array($uid,$formData['email']));
-
- //发邮件
- $mail_template = "users-changepassword";
- $mail_data = array(
- 'name'=>$username,
- 'url' => view::getHostLink()."/account/fetchpwd/".$username."/".$uid
- );
-
- $mail = new Mail();
-
- $mail->loadTemplate($mail_template,$mail_data);
- $mail->addTo($formData['email'],$username);
- $mail->send();
-
+ $salt = trim($this->_getParam('salt'));
- $this->view->messages[]='请检查您的新邮件中的确认激活链接。';
- $this->view->form=false;//do not echo form
- } else
- $this->messenger->addMessage('对不起,没有找到对应的电子邮件地址。');
- }
- } else
- $this->view->messages[]='请输入您的电子邮件地址。您将通过电子邮件收到新密码。';
- } else {
- $sql="select * from users where username=? and activation=?";
- $uq=$db->query($sql,array($login,$key));
- $tmp_pwd=uniqid();
- if ($urow=$uq->fetchObject())
+ if(empty($salt))
+ {
+ $captcha = new Captcha();
+ if(!empty($this->_getParam('submit')))
{
- $sql="update users set salt='',activation='',password=md5('".$tmp_pwd."') where username=? and activation=?";
- $db->query($sql,array($login,$key));
+ $email = trim($this->_request->getParam('email'));
+ $captchaword = trim($this->_request->getParam('captcha'));
- //发邮件
- $mail_template = "users-changepassword";
- $mail_data = array(
- 'name'=>$login,
- 'tmp_pwd' => $tmp_pwd
- );
+ if(!$captcha->isValid($captchaword))
+ {
+ $this->view->error = view::Error("验证码错误");
+ $this->view->captcha = $captcha->setCaptcha();
+ return true;
+ }
- $mail = new Mail();
+ $account = new Account();
+ $status = $account->getMyPassword($email);
- $mail->loadTemplate($mail_template,$mail_data);
- $mail->addTo($urow->email,$login);
- $mail->send();
+ if(isset($status['error']))
+ {
+ $this->view->error = view::Error($status['error']);
+ $this->view->captcha = $captcha->setCaptcha();
+ return true;
+ }
- $this->view->messages[]='请查收您新邮件中的新密码';
- $this->view->form=false;//do not echo form
-
- }
+ view::Post($this,"您的密码重置申请已提交,请在邮箱中查看");
+ return true;
+ }else{
+ $this->view->captcha = $captcha->setCaptcha();
+ }//提交密码重置申请
}
-
+
+ else{
+ $this->_helper->viewRenderer('account-resetpassword');
+ $this->view->salt = $salt;
+ if(!empty($this->_getParam('submit')))
+ {
+ $username = trim($this->_request->getParam('username'));
+ $password = trim($this->_request->getParam('password'));
+ $confirm_password = trim($this->_request->getParam('confirm_password'));
+
+ $account = new Account();
+ $status = $account->resetPassword(array(
+ 'username' => $username,
+ 'password' => $password,
+ 'confirm_password' => $confirm_password,
+ 'salt' => $salt
+ ));
+
+ if(isset($status['error']))
+ {
+ $this->view->error = view::Error($status['error']);
+ return true;
+ }
+
+ view::Post($this,"您的密码修改成功!请使用新密码登录","/account/login");
+ return true;
+ }
+ }//修改密码
+
} //找回密码
//OAuth2登录跳转页面
diff --git a/application/default/views/scripts/account/account-resetpassword.phtml b/application/default/views/scripts/account/account-resetpassword.phtml
new file mode 100644
index 00000000..34e6b0e0
--- /dev/null
+++ b/application/default/views/scripts/account/account-resetpassword.phtml
@@ -0,0 +1,41 @@
+headTitle($this->config->title->site);
+ $this->headTitle('用户登录');
+ $this->headTitle()->setSeparator(' - ');
+ $this->breadcrumb('首页 ');
+ $this->breadcrumb('用户登录 ');
+ $this->breadcrumb()->setSeparator(' > ');
+?>
+
+ error)) { ?>
+ = $this->error ?>
+
+
+
\ No newline at end of file
diff --git a/application/default/views/scripts/account/fetchpwd.phtml b/application/default/views/scripts/account/fetchpwd.phtml
index fcea22a9..ac41ca95 100644
--- a/application/default/views/scripts/account/fetchpwd.phtml
+++ b/application/default/views/scripts/account/fetchpwd.phtml
@@ -1,24 +1,55 @@
-headTitle($this->config->title->site);
- $this->headTitle('用户登录');
- $this->headTitle()->setSeparator(' - ');
- $this->headLink()->appendStylesheet('/css/register.css');
- $this->breadcrumb('首页 ');
- $this->breadcrumb('找回密码 ');
- $this->breadcrumb()->setSeparator(' > ');
-?>
-messages)) : ?>
-
-messages as $info)echo $info;
- ?>
-
-
-form) : ?>
-
-form;?>
-
-
-
+headTitle($this->config->title->site);
+ $this->headTitle('用户登录');
+ $this->headTitle()->setSeparator(' - ');
+ $this->headLink()->appendStylesheet('/css/register.css');
+ $this->breadcrumb('首页 ');
+ $this->breadcrumb('找回密码 ');
+ $this->breadcrumb()->setSeparator(' > ');
+?>
+
+ error)) { ?>
+ = $this->error ?>
+
+
+
+
\ No newline at end of file
diff --git a/application/module/Mail/Mail.php b/application/module/Mail/Mail.php
index 8736bffb..06288646 100644
--- a/application/module/Mail/Mail.php
+++ b/application/module/Mail/Mail.php
@@ -121,7 +121,12 @@ class Mail
$this->subject = $subject;
$this->body = $body;
- $this->type = $row['type'];
+ if(isset($row['type']))
+ {
+ $this->type = $row['type'];
+ }else{
+ $this->type = "text";
+ }
}//加载模板
diff --git a/application/module/Users/Account.php b/application/module/Users/Account.php
index 1e35480b..e5679992 100644
--- a/application/module/Users/Account.php
+++ b/application/module/Users/Account.php
@@ -22,9 +22,12 @@ class Account extends \Zend_Controller_Plugin_Abstract
public $FieldRealname = "realname";
public $RoleMember = "member";
+ public $getPwdEmailTemplate = "users-changepassword"; //找回密码的邮件模板名称
+ public $PwdChangedEmailTemplate = "users-password-changed"; //密码修改后的邮件模板
private $db;
protected $events = NULL; //事件
+ private $config;
/*
需要挂载的事件分别放在不同的listener中,将各种操作进行模块化细分
@@ -304,7 +307,7 @@ class Account extends \Zend_Controller_Plugin_Abstract
return array('error'=>"此邮箱并未注册",'place'=>'email');
}
- $salt = md5($email.'---'.$row['username']);
+ $salt = md5($email.'--'.time().'--'.$row['username']);
$sql = "UPDATE {$this->memberTable} SET salt='$salt' WHERE id={$row['id']}";
$state = $this->db->exec($sql);
@@ -314,15 +317,15 @@ class Account extends \Zend_Controller_Plugin_Abstract
return array('error'=>"处理中出现错误,请重试",'place'=>'email');
}
- $mail_template = "forgotpassword";
$mail_data = array(
'name'=>$row['realname'],
- 'link'=> view::getHostLink().'/account/getpassword/salt/'.$salt
+ 'link'=> view::getHostLink().'/account/fetchpwd/?salt='.$salt,
+ 'site' => $this->config->title->site
);
$mail = new Mail();
- $mail->loadTemplate($mail_template,$mail_data);
+ $mail->loadTemplate($this->getPwdEmailTemplate,$mail_data);
$mail->addTo($email,$row['realname']);
$mail->send();
@@ -358,12 +361,12 @@ class Account extends \Zend_Controller_Plugin_Abstract
$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'],
+ 'name' => $row['realname'],
+ 'site' => $this->config->title->site
);
$mail = new Mail();
- $mail->loadTemplate($mail_template,$mail_data);
+ $mail->loadTemplate($this->PwdChangedEmailTemplate,$mail_data);
$mail->addTo($row['email'],$row['realname']);
$mail->send();
diff --git a/application/module/Users/Operation/PwdOperate.php b/application/module/Users/Operation/PwdOperate.php
index ae87513f..27d54184 100644
--- a/application/module/Users/Operation/PwdOperate.php
+++ b/application/module/Users/Operation/PwdOperate.php
@@ -58,6 +58,11 @@ class PwdOperate implements \Users\Event\PwdEvent
{
$data = $e->getParam('data');
+ if(empty($data['salt']))
+ {
+ return array('error'=>"密钥不正确,请重新申请","place"=>'salt');
+ }
+
if(empty($data['username']))
{
return array('error'=>"请输入用户名",'place'=>'username');
@@ -70,12 +75,12 @@ class PwdOperate implements \Users\Event\PwdEvent
if(strlen($data['password']) < 6)
{
- return array('error'=>"密码长度太短,为了安全最少输入6位哦",'place'=>'password');
+ return array('error'=>"密码长度太短,为了安全最少输入6位",'place'=>'password');
}
if(strlen($data['password']) > 14)
{
- return array('error'=>"密码太长,亲您记得住吗?不要超过14位哦",'place'=>'password');
+ return array('error'=>"密码太长,请不要超过14位",'place'=>'password');
}
if(empty($data['confirm_password']))
From b54c72b565b7de776d3a0e70310e5123057a46fa Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Thu, 26 Dec 2013 07:27:27 +0000
Subject: [PATCH 079/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=87=BD=E6=95=B0?=
=?UTF-8?q?=E5=86=99=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/default/controllers/AccountController.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php
index fc35b8bb..264f86ab 100755
--- a/application/default/controllers/AccountController.php
+++ b/application/default/controllers/AccountController.php
@@ -383,11 +383,12 @@ class AccountController extends Zend_Controller_Action
public function fetchpwdAction()
{
$salt = trim($this->_getParam('salt'));
-
+ $submit = $this->_getParam('submit');
if(empty($salt))
{
$captcha = new Captcha();
- if(!empty($this->_getParam('submit')))
+
+ if(!empty($submit))
{
$email = trim($this->_request->getParam('email'));
$captchaword = trim($this->_request->getParam('captcha'));
From 9a78f04113f660b27ee4e17167dada6d51834155 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Thu, 26 Dec 2013 07:28:27 +0000
Subject: [PATCH 080/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=87=BD=E6=95=B0?=
=?UTF-8?q?=E5=86=99=E6=B3=95=E5=85=BC=E5=AE=B9php5.3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/default/controllers/AccountController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php
index 264f86ab..72e52f23 100755
--- a/application/default/controllers/AccountController.php
+++ b/application/default/controllers/AccountController.php
@@ -420,7 +420,7 @@ class AccountController extends Zend_Controller_Action
else{
$this->_helper->viewRenderer('account-resetpassword');
$this->view->salt = $salt;
- if(!empty($this->_getParam('submit')))
+ if(!empty($submit))
{
$username = trim($this->_request->getParam('username'));
$password = trim($this->_request->getParam('password'));
From 1c6a36d63878c2ac15b0c2abef859ce7b58c8689 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Thu, 26 Dec 2013 07:59:00 +0000
Subject: [PATCH 081/126] =?UTF-8?q?=E5=8F=96=E6=B6=88=E9=BB=91=E6=B2=B3?=
=?UTF-8?q?=E4=B8=93=E9=A2=98jiathis=E7=9A=84=E6=B3=A8=E9=87=8A=EF=BC=8C?=
=?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=87=8D=E5=A4=8D=E8=AE=BF=E9=97=AE=E7=99=BB?=
=?UTF-8?q?=E5=BD=95=E9=A1=B5=E9=9D=A2=E6=97=B6=E7=9A=84=E6=AD=BB=E5=BE=AA?=
=?UTF-8?q?=E7=8E=AF=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BF=AE=E6=94=B9=E9=AA=8C?=
=?UTF-8?q?=E8=AF=81=E7=A0=81=E5=9B=BE=E7=89=87=E5=AD=98=E6=94=BE=E8=B7=AF?=
=?UTF-8?q?=E5=BE=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../default/controllers/AccountController.php | 11 ++++-------
application/default/views/scripts/heihe/view.phtml | 4 ++--
application/module/Helpers/Captcha.php | 12 +++++++++---
3 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php
index 72e52f23..762f3597 100755
--- a/application/default/controllers/AccountController.php
+++ b/application/default/controllers/AccountController.php
@@ -301,20 +301,17 @@ class AccountController extends Zend_Controller_Action
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity())
{
- view::Post($this,"您已经登录,无需重复登录",-1);
+ view::Post($this,"您已经登录,无需重复登录","/index");
return true;
}
$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'];
- }
-
- if($tohref == "/account/login")
- {
- $this->view->href = $tohref = "/";
+ }else{
+ $this->view->href = "/";
}
if(!empty($tohref))
diff --git a/application/default/views/scripts/heihe/view.phtml b/application/default/views/scripts/heihe/view.phtml
index ba55b71c..f5a5b84a 100755
--- a/application/default/views/scripts/heihe/view.phtml
+++ b/application/default/views/scripts/heihe/view.phtml
@@ -479,7 +479,7 @@ endforeach;
-
+
@@ -554,4 +554,4 @@ var bound = {
没有找到对应的元数据。
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/application/module/Helpers/Captcha.php b/application/module/Helpers/Captcha.php
index dc61b759..43a835b3 100644
--- a/application/module/Helpers/Captcha.php
+++ b/application/module/Helpers/Captcha.php
@@ -6,6 +6,7 @@ class Captcha extends \Zend_Controller_Plugin_Abstract
public $captcha;
private $sessionName = "captcha";
+ private $imgDir = "images/captcha";
function __construct($db = NULL)
{
@@ -23,13 +24,18 @@ class Captcha extends \Zend_Controller_Plugin_Abstract
'dotNoiseLevel'=>2,
'lineNoiseLevel'=>1,
'timeout' => 300,
- 'font' => '../data/fonts/ggbi.ttf',
- 'imgDir' => 'vdimg/',
- 'imgUrl' => '/vdimg',
+ 'font' => '../data/fonts/ggbi.ttf',
+ 'imgDir' => $this->imgDir,
+ 'imgUrl' => '/images/captcha',
));
}
public function setCaptcha(){
+ if(!is_dir($this->imgDir))
+ {
+ mkdir($this->imgDir);
+ }
+
$this->captcha->generate();
$_SESSION[$this->sessionName] = $this->captcha->getWord();
$url = $this->captcha->getImgUrl()
From a1f43ad5749f6e3f2873fa80aa7184e60bc1245d Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Fri, 27 Dec 2013 02:06:40 +0000
Subject: [PATCH 082/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=94=A8?=
=?UTF-8?q?=E6=88=B7=E5=90=8D=E5=88=A4=E6=96=AD=E7=9A=84=E6=9D=A1=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Users/Operation/LoginOperate.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/application/module/Users/Operation/LoginOperate.php b/application/module/Users/Operation/LoginOperate.php
index a61833f7..336f38f8 100644
--- a/application/module/Users/Operation/LoginOperate.php
+++ b/application/module/Users/Operation/LoginOperate.php
@@ -45,9 +45,9 @@ class LoginOperate implements \Users\Event\LoginEvent
if(!empty($data['username']))
{
- if(!preg_match("/^[a-zA-Z][a-zA-Z0-9_]{2,15}$/",$data['username']))
+ if(mb_strlen($data['username'])<2)
{
- return array('error'=>"用户名应当以字母开头,由字母数字和下划线组成,并且长度在3到25个字符之间",'place'=>'username');
+ return array('error'=>"用户名长度应该大于两个字符",'place'=>'username');
}
}
From 0288b30ab6c740e09aa363b4af7700658b74d0d4 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Fri, 27 Dec 2013 02:39:18 +0000
Subject: [PATCH 083/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9AccountController?=
=?UTF-8?q?=E4=B8=AD=E8=BF=94=E5=9B=9E=E6=B6=88=E6=81=AF=E7=9A=84bug?=
=?UTF-8?q?=EF=BC=8C=E6=8F=90=E4=BA=A4AclManager=E4=B8=AD=E6=9C=89?=
=?UTF-8?q?=E5=85=B3=E8=87=AA=E5=8A=A8=E7=99=BB=E5=BD=95=E7=9A=84=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81=EF=BC=8C=E4=BF=AE=E6=94=B9member=E7=B1=BB=E4=B8=AD?=
=?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=E6=94=AF=E6=8C=81php5.5+?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../default/controllers/AccountController.php | 4 +-
.../default/views/scripts/account/login.phtml | 17 +------
.../models/CustomControllerAclManager.php | 44 +++++++++----------
application/module/Users/Member.php | 6 +--
4 files changed, 27 insertions(+), 44 deletions(-)
diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php
index 762f3597..d5cf52af 100755
--- a/application/default/controllers/AccountController.php
+++ b/application/default/controllers/AccountController.php
@@ -350,9 +350,11 @@ class AccountController extends Zend_Controller_Action
view::Post($this,"登录成功,正在跳转",$tohref);
return true;
+ }else{
+ $this->view->captcha = $captcha->setCaptcha();
}
- $this->view->captcha = $captcha->setCaptcha();
+
}
public function captchaAction()
diff --git a/application/default/views/scripts/account/login.phtml b/application/default/views/scripts/account/login.phtml
index 42874937..ac421001 100755
--- a/application/default/views/scripts/account/login.phtml
+++ b/application/default/views/scripts/account/login.phtml
@@ -6,21 +6,6 @@
$this->breadcrumb('用户登录 ');
$this->breadcrumb()->setSeparator(' > ');
?>
-
}else{ ?>
- = $this->error['error'] ?>
+ = isset($this->error['error'])? $this->error['error'] : $this->error ?>
diff --git a/application/models/CustomControllerAclManager.php b/application/models/CustomControllerAclManager.php
index 60330350..0bee8403 100755
--- a/application/models/CustomControllerAclManager.php
+++ b/application/models/CustomControllerAclManager.php
@@ -1,4 +1,8 @@
auth->hasIdentity())
{
- $mb = new member();
- $mb->db=$this->db;
- if($mb->checkcookie())
+ $member = new Member();
+
+ if($member->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));
+ $data = array(
+ 'username' => $member->user,
+ 'password' => $member->srpwd
+ );
+
+ $account = new Account();
+ $status = $account->storeLogin($data,false);
+
+ if(isset($status['error']))
+ {
+ $auth = Zend_Auth::getInstance();
+ $auth->clearIdentity();
+ Member::flushcookie();
}
}
}
diff --git a/application/module/Users/Member.php b/application/module/Users/Member.php
index fcb2bce2..c7ad012c 100644
--- a/application/module/Users/Member.php
+++ b/application/module/Users/Member.php
@@ -3,9 +3,9 @@ namespace Users;
class Member
{
- var $ck='DCC3ER4T8L2EFX94OPDF';
- var $db; //传入PDO对象
- var $mid; //会员ID
+ public $ck='DCC3ER4T8L2EFX94OPDF';
+ public $db; //传入PDO对象
+ public $mid; //会员ID
public $scr; //cookie 安全码 $_COOKIE['scr']
public $user;//cookie User $_COOKIE['user']
From 1822a361cfe9e69f8795fe5629478a45a4a3cf5b Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Fri, 27 Dec 2013 04:14:03 +0000
Subject: [PATCH 084/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=95=8C=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../default/controllers/AccountController.php | 79 ++++-----
.../views/scripts/account/register.phtml | 162 ++++++++++++++++--
application/module/Users/Account.php | 25 ++-
.../Users/Operation/RegisterOperate.php | 41 ++---
4 files changed, 207 insertions(+), 100 deletions(-)
diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php
index d5cf52af..a2fb8f50 100755
--- a/application/default/controllers/AccountController.php
+++ b/application/default/controllers/AccountController.php
@@ -66,7 +66,7 @@ class AccountController extends Zend_Controller_Action
"国家级国家自然科学基金" => "国家级国家自然科学基金",
"国际合作项目"=>"国际合作项目",
"省部级项目" => "省部级项目",
- "其他项目工程" => "其他项目工程"
+ "其他项目工程" => "其他项目工程",
);
$submit = $this->_getParam('submit');
@@ -250,44 +250,31 @@ class AccountController extends Zend_Controller_Action
function registerAction()
{
- $form = new RegisterForm();
- $this->view->form = $form;
-
- if ($this->_request->isPost()) {
- $formData = $this->_request->getPost();
- 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_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();
-
- //自动登录系统
- $this->login($formData['username'],$formData['password']);
- $this->_redirect('/');
- }
- } else {
- $form->populate($formData);
- }
- }
+ $order = new \Order\Order();
+
+ $this->view->projectType = array_merge(array("无"=>""),$order->projectType);
+
+ $submit = $this->_getParam("submit");
+
+ if(!empty($submit))
+ {
+ $account = new Account();
+ $this->view->data = $data = $account->getRegisterParam();
+ $status = $account->register($data);
+
+ if(isset($status['error']))
+ {
+ $this->view->error = $status['error'];
+ if(isset($status['place']))
+ {
+ $this->view->place = $status['place'];
+ }
+ }else{
+ view::Post($this,"注册成功!","/");
+ return true;
+ }
+ }
+
}
function loginAction()
@@ -328,6 +315,13 @@ class AccountController extends Zend_Controller_Action
$password = trim($this->_request->getParam('password'));
$captchaword = trim($this->_request->getParam('captcha'));
+ if($captcha->isValid($captchaword) !== true)
+ {
+ $this->view->error = "验证码错误";
+ $this->view->captcha = $captcha->setCaptcha();
+ return true;
+ }
+
$account = new Account();
$status = $account->login(array(
'username' => $username,
@@ -341,13 +335,6 @@ class AccountController extends Zend_Controller_Action
return true;
}
- if(!$captcha->isValid($captchaword))
- {
- $this->view->error = "验证码错误";
- $this->view->captcha = $captcha->setCaptcha();
- return true;
- }
-
view::Post($this,"登录成功,正在跳转",$tohref);
return true;
}else{
diff --git a/application/default/views/scripts/account/register.phtml b/application/default/views/scripts/account/register.phtml
index cf161a9b..7d6bded9 100755
--- a/application/default/views/scripts/account/register.phtml
+++ b/application/default/views/scripts/account/register.phtml
@@ -1,19 +1,143 @@
-headTitle($this->config->title->site);
- $this->headTitle('用户注册');
- $this->headTitle()->setSeparator(' - ');
- $this->headLink()->appendStylesheet('/css/register.css');
- $this->breadcrumb('首页 ');
- $this->breadcrumb('用户注册 ');
- $this->breadcrumb()->setSeparator(' > ');
-?>
-
-
-
确认服务条款
-
-
填写基本信息
-
-
注册完成
- form;?>
-
-
\ No newline at end of file
+headTitle($this->config->title->site);
+ $this->headTitle('用户注册');
+ $this->headTitle()->setSeparator(' - ');
+ $this->headLink()->appendStylesheet('/css/register.css');
+ $this->breadcrumb('首页 ');
+ $this->breadcrumb('用户注册 ');
+ $this->breadcrumb()->setSeparator(' > ');
+?>
+
+place)){ ?>
+
+
\ No newline at end of file
diff --git a/application/module/Users/Account.php b/application/module/Users/Account.php
index e5679992..0f94658e 100644
--- a/application/module/Users/Account.php
+++ b/application/module/Users/Account.php
@@ -216,14 +216,27 @@ class Account extends \Zend_Controller_Plugin_Abstract
}
//注册信息参数
- public function getParam(\Zend_Controller_Request_Abstract $request)
+ public function getRegisterParam(\Zend_Controller_Request_Abstract $request = NULL)
{
+ if(empty($request))
+ {
+ $request = new \Zend_Controller_Request_Http();
+ }
$data = array(
- 'username'=>$request->getParam('username'),
- 'password'=>$request->getParam('password'),
- 'confirm_password'=>$request->getParam('confirm_password'),
- 'email'=>$request->getParam('email'),
- 'realname'=>$request->getParam('realname')
+ 'username'=>trim($request->getParam('username')),
+ 'password'=>trim($request->getParam('password')),
+ 'confirm_password'=>trim($request->getParam('confirm_password')),
+ 'email' => trim($request->getParam('email')),
+ 'realname' => trim($request->getParam('realname')),
+ 'phone' => trim($request->getParam('phone')),
+ 'unit' => trim($request->getParam('unit')),
+ 'address' => trim($request->getParam('address')),
+ 'project' => trim($request->getParam('project')),
+ 'project_id' => trim($request->getParam('project_id')),
+ 'project_type' => trim($request->getParam('project_type')),
+ 'project_title' => trim($request->getParam('project_title')),
+ 'project_leader'=> trim($request->getParam('project_leader')),
+ 'postcode' => trim($request->getParam('postcode')),
);
return $data;
}
diff --git a/application/module/Users/Operation/RegisterOperate.php b/application/module/Users/Operation/RegisterOperate.php
index 9d3c006a..8c98724a 100644
--- a/application/module/Users/Operation/RegisterOperate.php
+++ b/application/module/Users/Operation/RegisterOperate.php
@@ -7,7 +7,7 @@ use \Helpers\View as view;
class RegisterOperate implements \Users\Event\RegisterEvent
{
private $db; //传入PDO对象
- public $tbl_member = "tbl_member";
+ public $tbl_member = "users";
public $FieldUsername = "username";
public $FieldPasword = "password";
public $FieldLastlogin = "ts_last_login";
@@ -45,9 +45,9 @@ class RegisterOperate implements \Users\Event\RegisterEvent
if(!empty($data['username']))
{
- if(!preg_match("/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/",$data['username']))
+ if(!preg_match("/^[a-zA-Z\xa0-\xff_][0-9a-zA-Z\xa0-\xff_]{2,25}$/",$data['username']))
{
- return array('error'=>"用户名应当以字母开头,由字母数字和下划线组成,并且长度在5到16个字符之间",'place'=>'username');
+ return array('error'=>"用户名只能包含字母汉字数字和下划线,并且长度在2到26个字符之间",'place'=>'username');
}
}
@@ -86,14 +86,12 @@ class RegisterOperate implements \Users\Event\RegisterEvent
return array('error'=>"请输入正确的电子邮件,推荐使用QQ邮箱和Gmail邮箱",'place'=>'email');
}
- if(empty($data['realname']))
+ if(!empty($data['realname']))
{
- return array('error'=>"请输入姓名",'place'=>'realname');
- }
-
- if(mb_strlen($data['realname'],"UTF-8")>10 )
- {
- return array('error'=>"真实姓名请不要超过10个字",'place'=>'realname');
+ if(mb_strlen($data['realname'],"UTF-8")>10 )
+ {
+ return array('error'=>"真实姓名请不要超过10个字",'place'=>'realname');
+ }
}
return true;
@@ -118,7 +116,7 @@ class RegisterOperate implements \Users\Event\RegisterEvent
{
if($row[$this->FieldUsername] == $data['username'])
{
- return array('error'=>'您的用户名已经注册过账号,您是否忘记了密码? ','place'=>'username');
+ return array('error'=>'您的用户名已经注册过账号,您是否忘记了密码? ','place'=>'username');
}
if($row[$this->FieldEmail] == $data['email'])
@@ -148,10 +146,9 @@ class RegisterOperate implements \Users\Event\RegisterEvent
return false;
}
- $mail_template = "register";
+ $mail_template = "member-register";
$mail_data = array(
'name'=>$data['realname'],
- 'content'=>$this->getMailContent()
);
$mail = new Mail();
@@ -166,25 +163,11 @@ class RegisterOperate implements \Users\Event\RegisterEvent
//邮件内容
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 .= ' '.$v['title']. ' / ' .$v['realname'].' '.$text.'查看播放
';
- }
- }
+
return $content;
}//getMailContent();
From dd22a0fe70eaafbdef594c7f8a864fe85c2ddaae Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Fri, 27 Dec 2013 05:54:27 +0000
Subject: [PATCH 085/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?=
=?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=96=B9=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/default/controllers/AccountController.php | 6 +++---
application/default/views/scripts/account/login.phtml | 4 +---
application/default/views/scripts/account/register.phtml | 4 +---
application/module/Helpers/View.php | 2 +-
application/module/Users/Operation/RegisterOperate.php | 2 +-
5 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php
index a2fb8f50..10864530 100755
--- a/application/default/controllers/AccountController.php
+++ b/application/default/controllers/AccountController.php
@@ -264,7 +264,7 @@ class AccountController extends Zend_Controller_Action
if(isset($status['error']))
{
- $this->view->error = $status['error'];
+ $this->view->error = view::Error($status['error']);
if(isset($status['place']))
{
$this->view->place = $status['place'];
@@ -317,7 +317,7 @@ class AccountController extends Zend_Controller_Action
if($captcha->isValid($captchaword) !== true)
{
- $this->view->error = "验证码错误";
+ $this->view->error = view::Error("验证码错误");
$this->view->captcha = $captcha->setCaptcha();
return true;
}
@@ -330,7 +330,7 @@ class AccountController extends Zend_Controller_Action
if(isset($status['error']))
{
- $this->view->error = $status;
+ $this->view->error = view::Error($status['error']);
$this->view->captcha = $captcha->setCaptcha();
return true;
}
diff --git a/application/default/views/scripts/account/login.phtml b/application/default/views/scripts/account/login.phtml
index ac421001..c4e9aa6f 100755
--- a/application/default/views/scripts/account/login.phtml
+++ b/application/default/views/scripts/account/login.phtml
@@ -13,9 +13,7 @@
请输入用户名和密码登录
}else{ ?>
-
- = isset($this->error['error'])? $this->error['error'] : $this->error ?>
-
+ = $this->error ?>
用户名
diff --git a/application/default/views/scripts/account/register.phtml b/application/default/views/scripts/account/register.phtml
index 7d6bded9..10c57682 100755
--- a/application/default/views/scripts/account/register.phtml
+++ b/application/default/views/scripts/account/register.phtml
@@ -14,9 +14,7 @@
请输入您的基本信息进行注册
}else{ ?>
-
- = isset($this->error['error'])? $this->error['error'] : $this->error ?>
-
+ = $this->error ?>
用户名
diff --git a/application/module/Helpers/View.php b/application/module/Helpers/View.php
index 783ba487..732468cb 100644
--- a/application/module/Helpers/View.php
+++ b/application/module/Helpers/View.php
@@ -55,7 +55,7 @@ class View extends \Zend_Controller_Plugin_Abstract
$html = '
'."\r\n";
$html.= '
× '."\r\n";
if(!is_array($content)) {
- $html.= '
'.$content.' '."\r\n";
+ $html.= ''.$content.''."\r\n";
}else{
$html.= '
'."\r\n";
foreach($content as $v) {
diff --git a/application/module/Users/Operation/RegisterOperate.php b/application/module/Users/Operation/RegisterOperate.php
index 8c98724a..b9985674 100644
--- a/application/module/Users/Operation/RegisterOperate.php
+++ b/application/module/Users/Operation/RegisterOperate.php
@@ -83,7 +83,7 @@ class RegisterOperate implements \Users\Event\RegisterEvent
if (!preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',$data['email']))
{
- return array('error'=>"请输入正确的电子邮件,推荐使用QQ邮箱和Gmail邮箱",'place'=>'email');
+ return array('error'=>"请输入正确的电子邮件地址",'place'=>'email');
}
if(!empty($data['realname']))
From f6b1acc2730fcdbc08336bf70b10b4fd785f02dd Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Fri, 27 Dec 2013 06:21:12 +0000
Subject: [PATCH 086/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E5=90=8D=E9=95=BF=E5=BA=A6=E5=92=8C=E8=A7=84=E5=88=99=E5=88=A4?=
=?UTF-8?q?=E6=96=AD=E7=9A=84=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Users/Operation/RegisterOperate.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/application/module/Users/Operation/RegisterOperate.php b/application/module/Users/Operation/RegisterOperate.php
index b9985674..0c02b560 100644
--- a/application/module/Users/Operation/RegisterOperate.php
+++ b/application/module/Users/Operation/RegisterOperate.php
@@ -45,7 +45,7 @@ class RegisterOperate implements \Users\Event\RegisterEvent
if(!empty($data['username']))
{
- if(!preg_match("/^[a-zA-Z\xa0-\xff_][0-9a-zA-Z\xa0-\xff_]{2,25}$/",$data['username']))
+ if(!preg_match("/[0-9a-zA-Z\xa0-\xff_]{2,25}/",$data['username']))
{
return array('error'=>"用户名只能包含字母汉字数字和下划线,并且长度在2到26个字符之间",'place'=>'username');
}
From e2f2b2ae71eae75f5ac47b4e36b360ec153fe9b3 Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Fri, 3 Jan 2014 02:22:45 +0000
Subject: [PATCH 087/126] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E8=A3=81?=
=?UTF-8?q?=E5=9B=BE=E5=B7=A5=E5=85=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/module/Files/Thumbnail.php | 363 +++++++++++++++----------
1 file changed, 217 insertions(+), 146 deletions(-)
diff --git a/application/module/Files/Thumbnail.php b/application/module/Files/Thumbnail.php
index 6d63fa79..9a98fae7 100644
--- a/application/module/Files/Thumbnail.php
+++ b/application/module/Files/Thumbnail.php
@@ -9,153 +9,224 @@ namespace Files;
*/
class Thumbnail {
- private $maxWidth;
- private $maxHeight;
- private $scale;
- private $inflate;
- private $types;
- private $imgLoaders;
- private $imgCreators;
- private $source;
- private $sourceWidth;
- private $sourceHeight;
- private $sourceMime;
- private $thumb;
- private $thumbWidth;
- private $thumbHeight;
-
- public function __construct($maxWidth, $maxHeight, $scale = true, $inflate = false) {
- $this->maxWidth = $maxWidth;
- $this->maxHeight = $maxHeight;
- $this->scale = $scale;
- $this->inflate = $inflate;
- $this->types = array(
- 'image/jpeg',
- 'image/png',
- 'image/gif'
- );
- //加载MIME类型图像的函数名称
- $this->imgLoaders = array(
- 'image/jpeg' => 'imagecreatefromjpeg',
- 'image/png' => 'imagecreatefrompng',
- 'image/gif' => 'imagecreatefromgif'
- );
- //储存创建MIME类型图片的函数名称
- $this->imgCreators = array(
- 'image/jpeg' => 'imagejpeg',
- 'image/png' => 'imagepng',
- 'image/gif' => 'imagegif'
- );
- }
- /**
- * 文件方式加载图片
- * @param string $image 源图片
- * @return bool
- */
- public function loadFile($image){
- if(!$dims = @getimagesize($image)){
- trigger_error("源图片不存在");
- }
- if(in_array($dims['mime'], $this->types)){
- $loader = $this->imgLoaders[$dims['mime']];
- $this->source = $loader($image);
- if($dims['mime'] == 'image/png' || $dims['mime'] == 'image/gif'){
- imagesavealpha($this->source, true);
- }
- $this->sourceWidth = $dims[0];
- $this->sourceHeight = $dims[1];
- $this->sourceMime = $dims['mime'];
- $this->initThumb();
- return TRUE;
- }else{
- trigger_error('不支持'.$dims['mime']."图片类型");
- }
- }
- /**
- * 字符串方式加载图片
- * @param string $image 字符串
- * @param string $mime 图片类型
- * @return type
- */
- public function loadData($image,$mime){
- if(in_array($mime, $this->types)){
- if($this->source = @imagecreatefromstring($image)){
- $this->sourceWidth = imagesx($this->source);
- $this->sourceHeight = imagesy($this->source);
- $this->sourceMime = $mime;
- $this->initThumb();
- return TRUE;
- }else{
- trigger_error("不能从字符串加载图片");
- }
- }else{
- trigger_error("不支持".$mime."图片格式");
- }
- }
- /**
- * 生成缩略图
- * @param string $file 文件名。如果不为空则储存为文件,否则直接输出到浏览器
- */
- public function buildThumb($file = NULL){
- $creator = $this->imgCreators[$this->sourceMime];
- if(isset($file) && $this->thumb !== NULL){
- return $creator($this->thumb,$file);
- }else{
- return false;
- }
- }
- /**
- * 处理缩放
- */
- public function initThumb(){
- if($this->scale){
- if($this->sourceWidth > $this->sourceHeight){
- $this->thumbWidth = $this->maxWidth;
- $this->thumbHeight = floor($this->sourceHeight*($this->maxWidth/$this->sourceWidth));
- }elseif($this->sourceWidth < $this->sourceHeight){
- $this->thumbHeight = $this->maxHeight;
- $this->thumbWidth = floor($this->sourceWidth*($this->maxHeight/$this->sourceHeight));
- }else{
- $this->thumbWidth = $this->maxWidth;
- $this->thumbHeight = $this->maxHeight;
- }
- }
-
- if($this->sourceWidth <= $this->maxWidth && $this->sourceHeight <= $this->maxHeight && $this->inflate == FALSE){
- $this->thumb = NULL;
- }else{
- $this->thumb = imagecreatetruecolor($this->thumbWidth, $this->thumbHeight);
- if($this->sourceMime == 'image/png' || $this->sourceMime == 'image/gif')
- {
-
- imagealphablending($this->thumb, true);
- imagesavealpha($this->thumb, true);
- if($this->sourceMime == 'image/gif')
- {
- $bgcolor=imagecolorallocate($this->thumb,0,0,0);
- $transparent = imagecolortransparent($this->thumb,$bgcolor) ;
- }
- if($this->sourceMime == 'image/png')
- {
- $transparent = imagecolorallocatealpha($this->thumb, 0, 0, 0, 127);
- }
- imagefill($this->thumb, 0, 0, $transparent);
+ private $maxWidth;
+ private $maxHeight;
+ private $scale;
+ private $inflate;
+ private $types;
+ private $imgLoaders;
+ private $imgCreators;
+ private $source;
+ private $sourceWidth;
+ private $sourceHeight;
+ private $sourceMime;
+ private $thumb;
+ private $thumbWidth;
+ private $thumbHeight;
+
+ public function __construct($maxWidth, $maxHeight, $scale = true, $inflate = false) {
+ $this->maxWidth = $maxWidth;
+ $this->maxHeight = $maxHeight;
+ $this->scale = $scale;
+ $this->inflate = $inflate;
+ $this->types = array(
+ 'image/jpeg',
+ 'image/png',
+ 'image/gif'
+ );
+ //加载MIME类型图像的函数名称
+ $this->imgLoaders = array(
+ 'image/jpeg' => 'imagecreatefromjpeg',
+ 'image/png' => 'imagecreatefrompng',
+ 'image/gif' => 'imagecreatefromgif'
+ );
+ //储存创建MIME类型图片的函数名称
+ $this->imgCreators = array(
+ 'image/jpeg' => 'imagejpeg',
+ 'image/png' => 'imagepng',
+ 'image/gif' => 'imagegif'
+ );
+ }
+
+ /**
+ * 文件方式加载图片
+ * @param string $image 源图片
+ * @return bool
+ */
+ public function loadFile($image){
+ if(!$dims = @getimagesize($image)){
+ trigger_error("源图片不存在");
+ }
+ if(in_array($dims['mime'], $this->types)){
+ $loader = $this->imgLoaders[$dims['mime']];
+ $this->source = $loader($image);
+ if($dims['mime'] == 'image/png' || $dims['mime'] == 'image/gif'){
+ imagesavealpha($this->source, true);
}
- imagecopyresampled($this->thumb, $this->source, 0, 0, 0, 0, $this->thumbWidth, $this->thumbHeight, $this->sourceWidth, $this->sourceHeight);
- }
- }
-
- public function getMine(){
- return $this->sourceMime;
- }
-
- public function getThumbWidth(){
- return $this->thumbWidth;
- }
-
- public function getThumbHeight(){
- return $this->thumbHeight;
- }
+ $this->sourceWidth = $dims[0];
+ $this->sourceHeight = $dims[1];
+ $this->sourceMime = $dims['mime'];
+ $this->initThumb();
+ return TRUE;
+ }else{
+ trigger_error('不支持'.$dims['mime']."图片类型");
+ }
+ }
+
+ /**
+ * 字符串方式加载图片
+ * @param string $image 字符串
+ * @param string $mime 图片类型
+ * @return type
+ */
+ public function loadData($image,$mime){
+ if(in_array($mime, $this->types)){
+ if($this->source = @imagecreatefromstring($image)){
+ $this->sourceWidth = imagesx($this->source);
+ $this->sourceHeight = imagesy($this->source);
+ $this->sourceMime = $mime;
+ $this->initThumb();
+ return TRUE;
+ }else{
+ trigger_error("不能从字符串加载图片");
+ }
+ }else{
+ trigger_error("不支持".$mime."图片格式");
+ }
+ }
+
+ /**
+ * 生成缩略图
+ * @param string $file 文件名。如果不为空则储存为文件,否则直接输出到浏览器
+ */
+ public function buildThumb($file = NULL){
+ $creator = $this->imgCreators[$this->sourceMime];
+ if(isset($file) && $this->thumb !== NULL){
+ return $creator($this->thumb,$file);
+ }else{
+ return false;
+ }
+ }
+
+ /**
+ * 处理缩放
+ */
+ public function initThumb(){
+ if($this->scale){
+ if($this->sourceWidth > $this->sourceHeight){
+ $this->thumbWidth = $this->maxWidth;
+ $this->thumbHeight = floor($this->sourceHeight*($this->maxWidth/$this->sourceWidth));
+ }elseif($this->sourceWidth < $this->sourceHeight){
+ $this->thumbHeight = $this->maxHeight;
+ $this->thumbWidth = floor($this->sourceWidth*($this->maxHeight/$this->sourceHeight));
+ }else{
+ $this->thumbWidth = $this->maxWidth;
+ $this->thumbHeight = $this->maxHeight;
+ }
+ }
+
+ if($this->sourceWidth <= $this->maxWidth && $this->sourceHeight <= $this->maxHeight && $this->inflate == FALSE){
+ $this->thumb = NULL;
+ }else{
+ $this->thumb = imagecreatetruecolor($this->thumbWidth, $this->thumbHeight);
+ if($this->sourceMime == 'image/png' || $this->sourceMime == 'image/gif')
+ {
+
+ imagealphablending($this->thumb, true);
+ imagesavealpha($this->thumb, true);
+ if($this->sourceMime == 'image/gif')
+ {
+ $bgcolor=imagecolorallocate($this->thumb,0,0,0);
+ $transparent = imagecolortransparent($this->thumb,$bgcolor) ;
+ }
+ if($this->sourceMime == 'image/png')
+ {
+ $transparent = imagecolorallocatealpha($this->thumb, 0, 0, 0, 127);
+ }
+ imagefill($this->thumb, 0, 0, $transparent);
+ }
+ imagecopyresampled($this->thumb, $this->source, 0, 0, 0, 0, $this->thumbWidth, $this->thumbHeight, $this->sourceWidth, $this->sourceHeight);
+ }
+ }
+
+ public function getMine(){
+ return $this->sourceMime;
+ }
+
+ public function getThumbWidth(){
+ return $this->thumbWidth;
+ }
+
+ public function getThumbHeight(){
+ return $this->thumbHeight;
+ }
+
+ static function cut($source_path, $target_width, $target_height){
+ $source_info = getimagesize($source_path);
+ $source_width = $source_info[0];
+ $source_height = $source_info[1];
+ $source_mime = $source_info['mime'];
+ $source_ratio = $source_height / $source_width;
+ $target_ratio = $target_height / $target_width;
+
+ // 源图过高
+ if ($source_ratio > $target_ratio)
+ {
+ $cropped_width = $source_width;
+ $cropped_height = $source_width * $target_ratio;
+ $source_x = 0;
+ $source_y = ($source_height - $cropped_height) / 2;
+ }
+ // 源图过宽
+ elseif ($source_ratio < $target_ratio)
+ {
+ $cropped_width = $source_height / $target_ratio;
+ $cropped_height = $source_height;
+ $source_x = ($source_width - $cropped_width) / 2;
+ $source_y = 0;
+ }
+ // 源图适中
+ else
+ {
+ $cropped_width = $source_width;
+ $cropped_height = $source_height;
+ $source_x = 0;
+ $source_y = 0;
+ }
+
+ switch ($source_mime)
+ {
+ case 'image/gif':
+ $source_image = imagecreatefromgif($source_path);
+ break;
+
+ case 'image/jpeg':
+ $source_image = imagecreatefromjpeg($source_path);
+ break;
+
+ case 'image/png':
+ $source_image = imagecreatefrompng($source_path);
+ break;
+
+ default:
+ return false;
+ break;
+ }
+
+ $target_image = imagecreatetruecolor($target_width, $target_height);
+ $cropped_image = imagecreatetruecolor($cropped_width, $cropped_height);
+
+ // 裁剪
+ imagecopy($cropped_image, $source_image, 0, 0, $source_x, $source_y, $cropped_width, $cropped_height);
+ // 缩放
+ imagecopyresampled($target_image, $cropped_image, 0, 0, 0, 0, $target_width, $target_height, $cropped_width, $cropped_height);
+
+ header('Content-Type: image/jpeg');
+ imagejpeg($target_image);
+ imagedestroy($source_image);
+ imagedestroy($target_image);
+ imagedestroy($cropped_image);
+ }//cute
}
From a6efab68c93e246c93d30d83b3207fb5bafeae6f Mon Sep 17 00:00:00 2001
From: Li Jianxuan
Date: Fri, 3 Jan 2014 06:19:04 +0000
Subject: [PATCH 088/126] =?UTF-8?q?=E4=B8=BAwsn=E6=95=B0=E6=8D=AE=E9=80=89?=
=?UTF-8?q?=E6=8B=A9=E6=97=B6=E9=97=B4=E8=8C=83=E5=9B=B4=E7=9A=84=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E4=BA=86=E5=A6=82=E6=9E=9C=E6=98=AF=E5=A4=9A=E4=B8=AA?=
=?UTF-8?q?=E7=82=B9=E7=9A=84=E8=AF=9D=E5=8F=AF=E4=BB=A5=E8=AE=BE=E7=BD=AE?=
=?UTF-8?q?=E6=89=80=E6=9C=89=E5=8F=98=E9=87=8F=E7=9A=84=E6=97=B6=E9=97=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
htdocs/js/lib/custom/models/dataservice.js | 65 +++++++++++++++++++---
1 file changed, 56 insertions(+), 9 deletions(-)
diff --git a/htdocs/js/lib/custom/models/dataservice.js b/htdocs/js/lib/custom/models/dataservice.js
index e7443602..3055af00 100644
--- a/htdocs/js/lib/custom/models/dataservice.js
+++ b/htdocs/js/lib/custom/models/dataservice.js
@@ -168,6 +168,8 @@ westdc.dataservice.wsn = {
this.selects = "";
this.uls = new Array();
+ this.count = 0;
+ this.first = 0;
for(i in data.data)
{
this.input = new Array();
@@ -185,12 +187,32 @@ westdc.dataservice.wsn = {
+ ' '
+ ' ';
this.uls.push('
观测点:'+data.data[i].name+' 可下载的变量: '+ this.input.join("") + this.timemap + '');
+
+ this.count++;
+ if(this.count == 1)
+ {
+ this.first = i;
+ }
+
}
this.selects = this.uls.join("");
+ if(this.count > 1)
+ {
+ this.allcontrol = '
';
+ }else{
+ this.allcontrol = "";
+ }
+
this.HTML = '