From c30f1c68267316b1acc94244636e4efffe23f265 Mon Sep 17 00:00:00 2001 From: wlx Date: Tue, 15 Oct 2013 10:04:41 +0000 Subject: [PATCH 001/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E7=8C=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=9A=84=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/module/Reference/Handler/ReferenceHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/module/Reference/Handler/ReferenceHandler.php b/application/module/Reference/Handler/ReferenceHandler.php index 77300d78..d92b3a27 100644 --- a/application/module/Reference/Handler/ReferenceHandler.php +++ b/application/module/Reference/Handler/ReferenceHandler.php @@ -110,7 +110,7 @@ class ReferenceHandler implements \Reference\Event\ReferenceEvent return "UUID格式不正确"; } - if(empty($data['reftype'])) + if(($data['reftype']=='')) { return "请选择文献类型"; } From 29557c14c19a47a3f48479716e6baa75e1dfdd77 Mon Sep 17 00:00:00 2001 From: wlx Date: Tue, 15 Oct 2013 10:06:42 +0000 Subject: [PATCH 002/126] fix condition judgement --- application/module/Reference/Handler/ReferenceHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/module/Reference/Handler/ReferenceHandler.php b/application/module/Reference/Handler/ReferenceHandler.php index d92b3a27..efb6732b 100644 --- a/application/module/Reference/Handler/ReferenceHandler.php +++ b/application/module/Reference/Handler/ReferenceHandler.php @@ -110,7 +110,7 @@ class ReferenceHandler implements \Reference\Event\ReferenceEvent return "UUID格式不正确"; } - if(($data['reftype']=='')) + if(($data['reftype']==='')) { return "请选择文献类型"; } @@ -135,4 +135,4 @@ class ReferenceHandler implements \Reference\Event\ReferenceEvent return $data; } -} \ No newline at end of file +} From 3acef46848e8fe697e5ee27f659e82ef33d8b677 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Wed, 16 Oct 2013 08:07:54 +0000 Subject: [PATCH 003/126] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E9=99=84?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E4=B8=AD=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/DataController.php | 16 +-- .../views/scripts/data/attachmentsadd.phtml | 134 ++++++++++-------- 2 files changed, 78 insertions(+), 72 deletions(-) diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index ed125cf4..27584057 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -1788,8 +1788,8 @@ class Admin_DataController extends Zend_Controller_Action $id = $this->_getParam('attupdate'); - $files=new files(); - $msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],empty($uuid)?'file':'md'); + $files=new Files(); + $msg = $files -> upload($_FILES['Filedata'],empty($uuid)?'file/':'md/',true); if(empty($msg['error'])) { @@ -1797,7 +1797,7 @@ class Admin_DataController extends Zend_Controller_Action $filename = $msg['db_path']; $filesize = $msg['file_size']; $filedesc = $this->_request->getParam('filedesc'); - $filetype = $msg['file_type']; + $filetype = 'md'; $realname = $msg['realname']; @@ -2116,8 +2116,8 @@ class Admin_DataController extends Zend_Controller_Action exit(); } - $files=new files(); - $msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],empty($uuid)?'file':'md'); + $files=new Files(); + $msg = $files -> upload($_FILES['Filedata'],empty($uuid)?'file/':'md/',true); if(empty($msg['error'])) { @@ -2125,7 +2125,7 @@ class Admin_DataController extends Zend_Controller_Action $filename = $msg['db_path']; $filesize = $msg['file_size']; $filedesc = $this->_request->getParam('filedesc'); - $filetype = $msg['file_type']; + $filetype = 'md'; $realname = $msg['realname']; @@ -2184,10 +2184,6 @@ class Admin_DataController extends Zend_Controller_Action $rs = $this->db->query($sql); $atts = $rs->fetchAll(); - foreach($atts as $k=>$v) - { - $atts[$k]['html']= $v['realname'].'['. round($v['filesize']/1024,2) .' kb]
'; - } echo Zend_Json::encode($atts); exit(); }else diff --git a/application/admin/views/scripts/data/attachmentsadd.phtml b/application/admin/views/scripts/data/attachmentsadd.phtml index c6a37c0a..5660ef70 100644 --- a/application/admin/views/scripts/data/attachmentsadd.phtml +++ b/application/admin/views/scripts/data/attachmentsadd.phtml @@ -7,12 +7,7 @@ $this->breadcrumb('后台首页'); $this->breadcrumb('数据管理'); $this->breadcrumb()->setSeparator(' > '); - $this->headLink()->appendStylesheet('/static/js/uploadify/uploadify.css'); - $this->headScript()->appendFile('/static/js/jquery-1.7.2.min.js'); - $this->headScript()->appendFile('/js/jquery.colorbox-min.js'); - $this->headLink()->appendStylesheet('/css/colorbox.css'); - $this->headScript()->appendFile('/static/js/uploadify/swfobject.js'); - $this->headScript()->appendFile('/static/js/uploadify/jquery.uploadify.v2.1.4.min.js'); + $this->theme->AppendPlus($this,"uploadify"); ?>
partial('data/left.phtml'); ?> @@ -21,7 +16,7 @@ @@ -30,7 +25,8 @@

注:可选择多个文件
-

    +
    +

    @@ -38,65 +34,79 @@
    + \ No newline at end of file diff --git a/application/default/views/scripts/water/view.phtml b/application/default/views/scripts/water/view.phtml index 217c6742..3d4a58e9 100755 --- a/application/default/views/scripts/water/view.phtml +++ b/application/default/views/scripts/water/view.phtml @@ -46,33 +46,59 @@ if ($md->title_en) echo '
    '.$this->escape($md->title_en);?> echo substr($md->authors,1,-1).'. '.$md->title.'. '.$md->publisher.', '.$md->publish_year.'. doi:'.$md->doi; echo ' ['.substr($md->author_en,1,-1).'. '.$md->title_en.'. '.$md->publisher_en.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi.']'; ?> (下载引用:RIS格式 | RIS英文格式 | Bibtex格式 | Bibtex英文格式)

    - ref) : ?> + + ref) : ?>
    -

    建议参考文献

    +

    相关文献(作者推荐)

      ref as $ref) : echo '
    1. '.$ref->reference; + echo '查看'; if (empty($ref->link)) { - if(!empty($ref->attid)) + if(!empty($ref->attid)) echo '下载'; + }else{ + echo '下载'; + } + echo "
    2. "; + endforeach; + ?> +
    + themeref) :?> + +
    +

    专题文献

    +
      + themeref as $ref) : + echo '
    1. '.$ref->reference; + echo '查看'; + if (empty($ref->link)) + { + if(!empty($ref->attid)) + echo ' | 下载'; }else{ - echo '下载'; + echo ' | 下载'; } echo "
    2. "; endforeach; ?>
    - userref) : ?>
    -

    数据用户发表文献

    +

    数据施引文献

      userref as $ref) : + echo '
    1. '.$ref->reference; + echo '查看'; if (empty($ref->link)) - echo '
    2. '.$ref->reference.'
    3. '; - else - echo '
    4. '.$ref->reference.' 下载
    5. '; + { + if(!empty($ref->attid)) + echo '下载'; + }else{ + echo '下载'; + } + echo ""; endforeach; ?>
    From c1f5c7de566b5d4dd7006d5685dbe8ec07255330 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Mon, 28 Oct 2013 09:45:48 +0000 Subject: [PATCH 022/126] =?UTF-8?q?#558=20=E5=A2=9E=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E4=BB=8E=E8=A1=A8=E4=B8=AD=E8=AF=BB=E5=8F=96=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/KnowledgeController.php | 120 +++++++++--------- .../default/controllers/ServiceController.php | 18 +++ .../views/scripts/knowledge/paper.phtml | 114 +++++++++++------ 3 files changed, 152 insertions(+), 100 deletions(-) diff --git a/application/default/controllers/KnowledgeController.php b/application/default/controllers/KnowledgeController.php index 3ad91082..dd6baa2e 100755 --- a/application/default/controllers/KnowledgeController.php +++ b/application/default/controllers/KnowledgeController.php @@ -1,17 +1,17 @@ -db=Zend_Registry::get('db'); - $this->view->config = Zend_Registry::get('config'); - $this->messenger=$this->_helper->getHelper('FlashMessenger'); - $this->view->messages = $this->messenger->getMessages(); - $this->view->theme=new Theme(); - } +db=Zend_Registry::get('db'); + $this->view->config = Zend_Registry::get('config'); + $this->messenger=$this->_helper->getHelper('FlashMessenger'); + $this->view->messages = $this->messenger->getMessages(); + $this->view->theme=new Theme(); + } function datacenterAction() { $siteid="e31f5ea7-a4af-4ae3-9ac1-1a84132c4338";//site uuid from geonetowrk @@ -24,8 +24,8 @@ class KnowledgeController extends Zend_Controller_Action $paginator->setItemCountPerPage(10); $paginator->setView($this->view); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml'); - $this->view->paginator=$paginator; - } + $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"; @@ -37,8 +37,8 @@ class KnowledgeController extends Zend_Controller_Action $paginator->setItemCountPerPage(10); $paginator->setView($this->view); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml'); - $this->view->paginator=$paginator; - } + $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"; @@ -50,12 +50,12 @@ class KnowledgeController extends Zend_Controller_Action $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"; + $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(); @@ -64,11 +64,11 @@ class KnowledgeController extends Zend_Controller_Action $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'); + $this->view->paginator=$paginator; + } + function searchAction() + { + $key=$this->_request->getParam('q'); $source=$this->_request->getParam('searchsource'); if(preg_match("/\"|'|<|>/",$key)) { @@ -89,7 +89,7 @@ class KnowledgeController extends Zend_Controller_Action if (!empty($key) && $source=='datasource') { $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 id desc"; $sth = $this->db->prepare($sql); $sth->execute(); $rows = $sth->fetchAll(); @@ -98,14 +98,14 @@ class KnowledgeController extends Zend_Controller_Action $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->view->paginator=$paginator; + $this->view->key=$key; + $this->view->source=$source; $this->_helper->viewRenderer('search-data'); - } - else if (!empty($key) && $source=='westsource') { + } + else if (!empty($key) && $source=='westsource') { $search=new SimpleSearch($key); - $where=$search->sql_expr(array("c.title","a.author")); + $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(); @@ -115,28 +115,28 @@ class KnowledgeController extends Zend_Controller_Action $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"; - $sth = $this->db->prepare($sql); - $sth->execute(); - $this->view->paper = $sth->fetch(); - - $sql="select * from ref_author where id=$id order by place"; - $sth = $this->db->prepare($sql); - $sth->execute(); - $this->view->author = $sth->fetchAll(); - - $sql="select * from ref_tag where id=$id"; - $sth = $this->db->prepare($sql); - $sth->execute(); - $this->view->tag = $sth->fetchAll(); - } + $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"; + $sth = $this->db->prepare($sql); + $sth->execute(); + $this->view->paper = $sth->fetch(); + + $sql="select * from ref_author where id=$id order by place"; + $sth = $this->db->prepare($sql); + $sth->execute(); + $this->view->author = $sth->fetchAll(); + + $sql="select * from ref_tag where id=$id"; + $sth = $this->db->prepare($sql); + $sth->execute(); + $this->view->tag = $sth->fetchAll(); + } } \ No newline at end of file diff --git a/application/default/controllers/ServiceController.php b/application/default/controllers/ServiceController.php index 446dd0a6..8d2c5af4 100644 --- a/application/default/controllers/ServiceController.php +++ b/application/default/controllers/ServiceController.php @@ -1453,6 +1453,24 @@ class ServiceController extends Zend_Controller_Action echo ''; echo $pagnation; }//文档页面相关数据 + + function refdatacountAction() + { + if(view::isXmlHttpRequest($this)) + { + $id = (int)$this->_getParam('id'); + if($id < 1){ + echo 0; + return; + } + $sql = "select count(md.id) as total from mdref mr + right join normalmetadata md on md.uuid=mr.uuid + where mr.refid=$id"; + $rs = $this->db->query($sql); + $row = $rs->fetch(); + echo $row['total']; + } + } function tagdatalistAction(){ diff --git a/application/default/views/scripts/knowledge/paper.phtml b/application/default/views/scripts/knowledge/paper.phtml index fe82d450..a0fa71e8 100644 --- a/application/default/views/scripts/knowledge/paper.phtml +++ b/application/default/views/scripts/knowledge/paper.phtml @@ -6,7 +6,7 @@ $this->headLink()->appendStylesheet('/css/mdreview.css'); $this->breadcrumb('首页'); $this->breadcrumb('知识积累'); $this->breadcrumb('文章查看'); -$this->breadcrumb()->setSeparator(' > '); +$this->breadcrumb()->setSeparator(' > '); $this->headScript()->appendFile('/js/jquery.colorbox-min.js'); $this->headLink()->appendStylesheet('/css/colorbox.css'); ?> @@ -16,48 +16,71 @@ $this->headLink()->appendStylesheet('/css/colorbox.css');
    -

    paper['title']; ?>

    -
      - author as $a) : ?> -
    • - -
    - paper['abstract']) : ?> - 摘要: - paper['abstract']; endif; if ($this->tag) : ?> - 关键词: -
      - tag as $t) : ?> -
    • - -
    - - - paper['reference']; ?> - + paper['title'])){ ?> +

    paper['title']; ?>

    +
    + + author) > 0) {?> +

    作者

    +
      + author as $a) : ?> +
    • + +
    +
    + + + paper['abstract']){ ?> +

    摘要

    +

    paper['abstract']; ?>

    +
    + + + tag) > 0) { ?> +

    关键词

    +
      + tag as $t) : ?> +
    • + +
    +
    + + + paper['reference'])) { ?> +

    引用方式

    +
    + paper['reference']; ?> +
    +
    + -
    - paper['link'])) - { - if(!empty($this->paper[‘attid’])) - echo 'PDF下载'; - }else{ - echo 'PDF下载'; - } - - if (!empty($item['link'])) : - echo ' 下载'; - endif; - ?> - 相关数据(共?条) - -
    +
    + paper['link'])) + { + if(!empty($this->paper['attid'])) + { + echo 'PDF下载'; + } + }else{ + echo 'PDF下载'; + } + + + if (!empty($item['link'])) : + echo ' 下载'; + endif; + ?> + 相关数据(共条) +
    + +
    - - + + \ No newline at end of file From 8e1db6cd3d1e3bb29a286a0e653d1416a704b59b Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Wed, 30 Oct 2013 06:51:28 +0000 Subject: [PATCH 023/126] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B2=A1=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/default/controllers/AccountController.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/application/default/controllers/AccountController.php b/application/default/controllers/AccountController.php index 40dd9b20..78487b85 100755 --- a/application/default/controllers/AccountController.php +++ b/application/default/controllers/AccountController.php @@ -374,15 +374,6 @@ class AccountController extends Zend_Controller_Action view::Post($this,"登录成功,正在跳转",$tohref); return true; } - - if($options['module']=="default" && $options['controller'] == "account" && $options['action'] == "login") - { - view::Post($this,"登录成功,正在跳转",'/'); - return true; - }else{ - view::Post($this,"登录成功,正在跳转",$_SERVER['REQUEST_URI']); - return true; - } } }else{ $this->setCaptcha($captcha); From e3a6acc635254b6220c47d4b63fc9b4147f6bff7 Mon Sep 17 00:00:00 2001 From: wlx Date: Thu, 31 Oct 2013 05:17:00 +0000 Subject: [PATCH 024/126] fix logic error --- .../default/views/scripts/water/view.phtml | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/application/default/views/scripts/water/view.phtml b/application/default/views/scripts/water/view.phtml index 3d4a58e9..db5ab149 100755 --- a/application/default/views/scripts/water/view.phtml +++ b/application/default/views/scripts/water/view.phtml @@ -23,10 +23,10 @@ h3.gs_rt{font-size:110%;} render('breadcrumbs.phtml'); ?> metadata;if ($md):?> -

    escape($md->title); -if ($md->title_en) echo '
    '.$this->escape($md->title_en);?> -

    -
    +

    escape($md->title); + if ($md->title_en) echo '
    '.$this->escape($md->title_en);?> +

    +
    @@ -36,18 +36,19 @@ if ($md->title_en) echo '
    '.$this->escape($md->title_en);?>

    - citation) : ?> + citation) : ?>

    本数据引用方式数据引用帮助

    datadoi) || !strpos($md->citation,$md->datadoi)) : ?>文章的引用 escape($md->citation);?>

    - datadoi) && !strpos($md->citation,$md->datadoi)) : ?> -

    数据的引用datadoi) && !strpos($md->citation,$md->datadoi)) : ?> +

    数据的引用 + authors,1,-1).'. '.$md->title.'. '.$md->publisher.', '.$md->publish_year.'. doi:'.$md->doi; echo ' ['.substr($md->author_en,1,-1).'. '.$md->title_en.'. '.$md->publisher_en.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi.']'; ?> (下载引用:RIS格式 | RIS英文格式 | Bibtex格式 | Bibtex英文格式)

    - - ref) : ?> + ref) : ?>

    相关文献(作者推荐)

      @@ -65,7 +66,7 @@ if ($md->title_en) echo '
      '.$this->escape($md->title_en);?> endforeach; ?>
    - themeref) :?> + themeref) :?>

    专题文献

    @@ -84,7 +85,7 @@ if ($md->title_en) echo '
    '.$this->escape($md->title_en);?> endforeach; ?> - userref) : ?> + userref) : ?>

    数据施引文献

      From fff01b40ce9eaf1c0978ee1122026194a63dadbb Mon Sep 17 00:00:00 2001 From: wlx Date: Fri, 1 Nov 2013 09:13:35 +0000 Subject: [PATCH 025/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=82=E8=80=83?= =?UTF-8?q?=E6=96=87=E7=8C=AE=E6=A0=BC=E5=BC=8F=E7=94=9F=E6=88=90=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=9B=E4=BF=AE=E6=94=B9=E6=89=B9=E9=87=8F=E5=AF=BC?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/module/Reference/Reference.php | 2 +- application/module/Reference/Ris.php | 30 ++++++++++++---------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/application/module/Reference/Reference.php b/application/module/Reference/Reference.php index ca7abfd6..bb9731dd 100644 --- a/application/module/Reference/Reference.php +++ b/application/module/Reference/Reference.php @@ -453,7 +453,7 @@ class Reference public function referenceType() { return array( - 0 => '相关文献', + 0 => '相关文献',//作者建议的文献或数据中心建议的文献 1 => '施引文献', 2 => '参考文献', 3 => '多篇文献', diff --git a/application/module/Reference/Ris.php b/application/module/Reference/Ris.php index 3b891373..c9432ddd 100644 --- a/application/module/Reference/Ris.php +++ b/application/module/Reference/Ris.php @@ -174,18 +174,20 @@ class Ris $results = $this->events()->trigger('checkLoad', $this, compact('ref')); $id = $results->bottom(); - $this->unsetVar($ref); + if ($id > 0) - { + { + $this->unsetVar($ref); $this->events()->trigger('deleteAuthor', $this, compact('id')); $this->events()->trigger('deleteTag', $this, compact('id')); 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); } @@ -272,17 +274,17 @@ class Ris //创建reference 字段 public function makeReferenceFlag($ref){ - $str = array(); - isset($ref['author']) ? $str[] = join(",",$ref['author']):""; - isset($ref['title']) ? $str[] = $ref['title']:""; - isset($ref['year']) ? $str[] = $ref['year']:""; - isset($ref['volume']) ? $str[] = $ref['volume']:""; - isset($ref['issue']) ? $str[] = $ref['issue']:""; - isset($ref['pages']) ? $str[] = $ref['pages']:""; - isset($ref['endpage'])? $str[] = $ref['endpage']:""; - isset($ref['doi']) ? $str[] = $ref['doi'] : ""; + $str = join(', ',$ref['author']).'. '; + $str .= $ref['title'].'. '; + $str .= $ref['publisher'].', '; + isset($ref['year']) ? $str .= $ref['year'].', ':""; + isset($ref['volume']) ? $str .= $ref['volume']:""; + isset($ref['issue']) ? $str .= '('.$ref['issue'].')':""; + isset($ref['pages']) ? $str .= ':'.$ref['pages']:""; + isset($ref['endpage'])? $str .= '-'.$ref['endpage']:""; + isset($ref['doi']) ? $str .= '. doi:'.$ref['doi'] : ""; - return join(",",$str); + return $str; } //卸载不需要的变量 From 075ff2b2c09b45351dca70a7fdf8c405dff7a9cb Mon Sep 17 00:00:00 2001 From: wlx Date: Fri, 1 Nov 2013 09:14:13 +0000 Subject: [PATCH 026/126] =?UTF-8?q?=E6=94=BE=E5=AE=BD=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E7=9A=84=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/module/Reference/Handler/RisHandler.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/application/module/Reference/Handler/RisHandler.php b/application/module/Reference/Handler/RisHandler.php index 6659abee..9de4d5d0 100644 --- a/application/module/Reference/Handler/RisHandler.php +++ b/application/module/Reference/Handler/RisHandler.php @@ -36,13 +36,14 @@ class RisHandler implements \Reference\Event\RisEvent $wheresql = array(); - $wheresql[] = " title='{$ref['title']}' "; + $wheresql[] = " lower(title)=lower('{$ref['title']}') "; $wheresql[] = " year='{$ref['year']}' "; - - if(isset($ref['publisher'])) + + //暂时不使用期刊限制 + /*if(isset($ref['publisher'])) { $wheresql[] = " publisher='{$ref['publisher']}' "; - } + }*/ if(count($wheresql) > 0) { From 6ae3223a84b2f5b459bc36e8f8f307ed118c8011 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Mon, 4 Nov 2013 07:08:58 +0000 Subject: [PATCH 027/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E7=8C=AE?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA=E6=96=B9=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8C=89=E5=B9=B4=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/DataController.php | 29 +++- .../views/scripts/data/attachmentsadd.phtml | 3 +- .../admin/views/scripts/data/ref-nav.phtml | 5 +- .../admin/views/scripts/data/ref.phtml | 46 ++--- application/module/Helpers/Table.php | 7 + application/module/Helpers/dbh.php | 28 +++ application/module/Open/App.php | 162 +++++++++++++++++- application/module/Open/Open.php | 70 +++----- application/module/Reference/Reference.php | 58 +++++++ 9 files changed, 328 insertions(+), 80 deletions(-) diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index ed9cf60e..5389eabf 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -1128,6 +1128,7 @@ class Admin_DataController extends Zend_Controller_Action $keyword = $this->view->q = trim($this->_getParam('q')); $order = $this->view->search_order = trim($this->_getParam('order')); $sort = $this->view->search_sort = trim($this->_getParam('sort')); + $field = $this->view->search_field = $this->_getParam('field'); $reference = new Reference(); @@ -1136,6 +1137,11 @@ class Admin_DataController extends Zend_Controller_Action $reference->keyword = $keyword; } + if(!empty($field)) + { + $reference->field = $field; + } + if(!empty($order)) { $reference->order = $order; @@ -1146,11 +1152,18 @@ class Admin_DataController extends Zend_Controller_Action $reference->sort = $sort; } + $this->view->reference = $reference; + //文献首页 if(empty($ac)) { $this->view->referenceType = $reference->referenceType(); - view::addPaginator($reference->fetchReferences(),$this,12); + + $this->view->page = $this->_getParam('page'); + $this->view->pagelimit = 12; + + view::addPaginator($reference->fetchReferences(),$this, $this->view->pagelimit); + $this->view->years = $reference->countByYear(); return true; } else if ($ac == "water") @@ -1172,6 +1185,8 @@ class Admin_DataController extends Zend_Controller_Action return true; } + unset($this->view->reference); + //添加 if($ac == "add") { @@ -1378,6 +1393,18 @@ class Admin_DataController extends Zend_Controller_Action return true; }//ris单篇更新 + + //ris导出 + if($ac == "risoutput") + { + $this->_helper->viewRenderer('ref-risoutput'); + $this->view->years = $reference->countByYear(); + + if(!empty($submit)) + { + + } + }//ris output }//文献管理 refAction() diff --git a/application/admin/views/scripts/data/attachmentsadd.phtml b/application/admin/views/scripts/data/attachmentsadd.phtml index 5660ef70..3c7c33f4 100644 --- a/application/admin/views/scripts/data/attachmentsadd.phtml +++ b/application/admin/views/scripts/data/attachmentsadd.phtml @@ -28,7 +28,6 @@
      -

      @@ -71,7 +70,7 @@ var upload = { makeFileHtml : function(data){ return '
      ' + '' - + data.realname + + '' +data.realname + '' +'' +'
      '; }, diff --git a/application/admin/views/scripts/data/ref-nav.phtml b/application/admin/views/scripts/data/ref-nav.phtml index 85329fdd..c3406955 100644 --- a/application/admin/views/scripts/data/ref-nav.phtml +++ b/application/admin/views/scripts/data/ref-nav.phtml @@ -1,10 +1,11 @@ \ No newline at end of file diff --git a/application/admin/views/scripts/data/ref.phtml b/application/admin/views/scripts/data/ref.phtml index b1298c2b..7813e18a 100644 --- a/application/admin/views/scripts/data/ref.phtml +++ b/application/admin/views/scripts/data/ref.phtml @@ -37,6 +37,13 @@ table thead tr th {background:#EBF2F6;} msg)) { ?> msg ?> + + years)) { ?> + years as $k=>$v){ ?> + () + + +
      paginator)): ?> @@ -45,8 +52,7 @@ table thead tr th {background:#EBF2F6;} - @@ -58,37 +64,31 @@ table thead tr th {background:#EBF2F6;} - page > 1) + { + $autoindex = ($this->page - 1) * $this->pagelimit; + }else{ + $autoindex=0; + } foreach ($this->paginator as $item): $autoindex++;?> - - - - + - - - - - - - - - - -
      标题 - 年份 + 年份
      + []  + {reference->getAuthorByReference($item['id'],true); echo count($authors) ? join(",",$authors):'未知作者'; ?>}  + {未知标题':$item['title'] ?>}  + {未知期刊':$item['publisher'] ?>}  + {未知年份':$item['year'] ?>}  + + 编辑 RIS编辑 数据(+) 删除
      - 编辑 - RIS编辑 - 数据 - 删除 -
      diff --git a/application/module/Helpers/Table.php b/application/module/Helpers/Table.php index 87ceade0..69256584 100644 --- a/application/module/Helpers/Table.php +++ b/application/module/Helpers/Table.php @@ -20,4 +20,11 @@ class Table //元数据 public $metadata = "metadata"; + + //会员 + public $member = "users"; + + //开放平台 + public $oauth_clients = "oauth_clients"; + public $oauth_access_tokens = "oauth_access_tokens"; } \ No newline at end of file diff --git a/application/module/Helpers/dbh.php b/application/module/Helpers/dbh.php index 83791cd1..b9f2e7a8 100644 --- a/application/module/Helpers/dbh.php +++ b/application/module/Helpers/dbh.php @@ -1,11 +1,15 @@ debug == 1) + { + view::Dump($sql,false); + } + try{ return $this->db->exec($sql); }catch (Exception $e) { @@ -53,6 +63,12 @@ class dbh } }else{ $sql = "INSERT INTO \"".$table."\" ($fields) VALUES ($datas) RETURNING id"; + + if($this->debug == 1) + { + view::Dump($sql,false); + } + try{ $sth = $this->db->prepare($sql); if($sth->execute()) @@ -108,6 +124,12 @@ class dbh try{ $sql = "UPDATE \"".$table."\" SET $fields $wheresql"; + + if($this->debug == 1) + { + view::Dump($sql,false); + } + if($this->db->exec($sql)) { return true; @@ -125,6 +147,12 @@ class dbh }else{ try{ $sql = "UPDATE \"".$table."\" SET $fields $wheresql"; + + if($this->debug == 1) + { + view::Dump($sql,false); + } + return $this->db->exec($sql); }catch (Exception $e) { if($this->product) diff --git a/application/module/Open/App.php b/application/module/Open/App.php index 23d3b377..a4da49a0 100644 --- a/application/module/Open/App.php +++ b/application/module/Open/App.php @@ -1,15 +1,72 @@ load(); + if(empty($db)) + { + $this->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 appStatus() + { + return array( + -1 => '关闭', + 0 => '测试', + 1 => '启用' + ); + } + + //检查用户资料完整性 + public function checkinfo() + { + $uid = view::User('id'); + $sql = "SELECT * FROM ".$this->table->member. " WHERE id=$uid"; + $rs = $this->db->query($sql); + $row = $rs->fetch(); + + foreach($this->checkFiled as $v) + { + if(empty($row[$v])) + { + return "请完善个人信息"; + } + } + + return true; } //获得用户创建的app @@ -17,10 +74,10 @@ class app extends open implements openbase { if(empty($uid)) { - $uid = $this->user->id; + $uid = view::User('id'); } - $sql = "SELECT * FROM ".$this->tbl_oauth_clients." WHERE user_id=".$this->user->id; + $sql = "SELECT * FROM ".$this->table->oauth_clients." WHERE user_id=".$uid ." ORDER BY id DESC"; $rs = $this->db->query($sql); $rows = $rs->fetchAll(); @@ -34,12 +91,103 @@ class app extends open implements openbase { return false; } - $sql = "SELECT * FROM ".$this->tbl_oauth_clients." WHERE id=".$id; + $sql = "SELECT * FROM ".$this->table->oauth_clients." WHERE id=".$id; $rs = $this->db->query($sql); $rows = $rs->fetch(); return $rows; } + //收集创建应用的参数 + public function getAppCreateParam(\Zend_Controller_Request_Abstract $request = NULL) + { + $request = new \Zend_Controller_Request_Http(); + $data = array( + 'subject' => trim($request->getParam('subject')), + 'client_domain' => trim($request->getParam('client_domain')), + 'redirect_uri' => trim($request->getParam('redirect_uri')), + 'status' => (int)$request->getParam('status') + ); + return $data; + }//getAppCreateParam + //添加或者编辑 + public function appCreate($id = NULL) + { + if(!empty($id)) + { + if(!is_numeric($id) || $id<1) + { + return "参数错误"; + } + } + + $data = $this->getAppCreateParam(); + + $params = compact('data'); + $results = $this->events()->trigger('app.checkParam', $this, $params); + $cache_data = $results->bottom(); + + if($cache_data !== true) + { + return $cache_data; + } + + if(!empty($id)) + { + $params = compact('data','id'); + } + + $results = $this->events()->trigger('app.processData', $this, $params); + $data = $results->bottom(); + + $dbh = new dbh(); + + if(empty($id)) + { + $id = $dbh->insert($this->table->oauth_clients,$data,true); + if($id > 0) + { + $results = $this->events()->trigger('app.created', $this, compact("data","id")); + $cache_data = $results->bottom(); + return $id; + }else{ + return "应用创建中发生错误,请重试!"; + } + }else{ + $status = $dbh->update($this->table->oauth_clients,$data," id=$id "); + if($status) + { + $results = $this->events()->trigger('app.eidted', $this, compact("data","id")); + $cache_data = $results->bottom(); + return true; + }else{ + return "应用编辑中发生错误,请重试"; + } + } + + }//appCreate + + //删除App + public function delete($id) + { + if(!is_numeric($id) || $id<1) + { + return "参数错误"; + } + + try{ + $sql = "DELETE FROM {$this->table->oauth_clients} WHERE id=$id"; + $rs = $this->db->exec($sql); + if($rs) + { + return true; + }else{ + return "删除失败"; + } + }catch(Excaption $e){ + return "服务器处理中遇到错误"; + } + + }//delete } \ No newline at end of file diff --git a/application/module/Open/Open.php b/application/module/Open/Open.php index 8a6445df..29534eb9 100644 --- a/application/module/Open/Open.php +++ b/application/module/Open/Open.php @@ -1,26 +1,18 @@ config = \Zend_Registry::get('config'); + + public function __construct($db = NULL,$auth = NULL){ if(empty($db)) { $this->db = \Zend_Registry::get('db'); @@ -28,39 +20,27 @@ abstract class open extends \Zend_Controller_Plugin_Abstract implements openexte $this->db = $db; } - if(empty($auth)) - { - $this->auth = \Zend_Auth::getInstance(); - if($this->auth->hasIdentity()) - { - $this->user = $this->auth->getIdentity(); - } - }else{ - $this->auth = false; - } + $this->config = \Zend_Registry::get('config'); + + $Listener = new Listener(); + @$this->events()->attachAggregate($Listener); + + $this->table = new \Helpers\Table(); } - //检查用户资料完整性 - public function checkinfo() + 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 clientCredentials() { - if($this->auth === false) - { - return "未登陆"; - } - include_once("Users.php"); - $user = new \Users($this->db); - $info = $user->getUserInfo($this->user->id); - - foreach($this->checkFiled as $v) - { - if(empty($info[$v])) - { - return "请完善个人信息"; - } - } - - return true; } } \ No newline at end of file diff --git a/application/module/Reference/Reference.php b/application/module/Reference/Reference.php index bb9731dd..0b8fc73c 100644 --- a/application/module/Reference/Reference.php +++ b/application/module/Reference/Reference.php @@ -16,6 +16,7 @@ class Reference public $keyword; public $order; public $sort = "DESC"; + public $field; public $reftype; @@ -176,6 +177,24 @@ class Reference { $wheresql[] = " ({$this->table->reference}.title LIKE '%{$this->keyword}%' OR {$this->table->reference}.reference LIKE '%{$this->keyword}%') "; } + + if(!empty($this->field)) + { + foreach($this->field as $k=>$v) + { + if(!empty($v)) + { + if(!is_numeric($v)) $v="'{$v}'"; + $wheresql[] = " ({$this->table->reference}.{$k}={$v} ) "; + }else{ + if(is_numeric($v)) + $wheresql[] = " ({$this->table->reference}.{$k} IS NULL OR {$this->table->reference}.{$k}=0 ) "; + else + $wheresql[] = " ({$this->table->reference}.{$k} IS NULL ) "; + }//if(empty($v) + }//foreach + } + if(count($wheresql)>0) { $wheresql = " WHERE ".join(" AND ",$wheresql); @@ -517,4 +536,43 @@ class Reference } } + //按年份获得文献数量 + public function countByYear() + { + $sql = "SELECT count(id) as num,year FROM {$this->table->reference} GROUP BY year ORDER BY year DESC"; + $rs = $this->db->query($sql); + $rows = $rs->fetchAll(); + + return $rows; + } + + //获得作者 + public function getAuthorByReference($id,$join = false) + { + if(is_numeric($id)) + { + $sql = "SELECT * FROM {$this->table->reference_author} WHERE id=$id ORDER BY place ASC"; + $rs = $this->db->query($sql); + if(!$join) + { + return $rs->fetchAll(); + }else{ + foreach($rows = $rs->fetchAll() as $k=>$v) + { + $rows[$k] = (string)$v['firstname'].$v['lastname']; + } + return $rows; + } + } + + if(is_array($id)) + { + $sql = "SELECT * FROM {$this->table->reference_author} WHERE id IN (".join(",",$id).")"; + $rs = $this->db->query($sql); + return $rs->fetchAll(); + } + + return; + } + } From 8d89e9f43578129842a435da459c1c56b7085749 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Mon, 4 Nov 2013 09:04:07 +0000 Subject: [PATCH 028/126] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86ris=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=8A=9F=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-risoutput.phtml | 50 ++++++ application/module/Reference/Reference.php | 22 +++ application/module/Reference/RisOutput.php | 153 ++++++++++++++++++ 4 files changed, 246 insertions(+) create mode 100644 application/admin/views/scripts/data/ref-risoutput.phtml create mode 100644 application/module/Reference/RisOutput.php diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index 5389eabf..3ee7db2a 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -2,6 +2,7 @@ use Helpers\View as view; use Reference\Reference; use Reference\Ris; +use Reference\RisOutput; use Helpers\dbh; use \Files\Files; @@ -1402,9 +1403,29 @@ class Admin_DataController extends Zend_Controller_Action if(!empty($submit)) { + $mode = $this->_getParam('mode'); + $risOutput = new RisOutput(); + $preData = $risOutput->preRead($mode); + + $risData = $risOutput->processArrayDataToRisData($preData); + + $risText = $risOutput->output($risData); + view::Dump($risText); } }//ris output + + if($ac == "ristest") + { + $this->_helper->viewRenderer('ref-ris'); + $submit = $this->_getParam('submit'); + + if(!empty($submit)) + { + $ris = new \Reference\Ris(); + view::Dump($ris->processRis(NULL,$this->_getParam('ristext')),false); + } + } }//文献管理 refAction() diff --git a/application/admin/views/scripts/data/ref-risoutput.phtml b/application/admin/views/scripts/data/ref-risoutput.phtml new file mode 100644 index 00000000..d12726d0 --- /dev/null +++ b/application/admin/views/scripts/data/ref-risoutput.phtml @@ -0,0 +1,50 @@ +headTitle($this->config->title->site); +$this->headTitle('后台管理'); +$this->headTitle()->setSeparator(' - '); +$this->breadcrumb('首页'); +$this->breadcrumb('数据管理'); +$this->breadcrumb('文献管理'); +$this->breadcrumb()->setSeparator(' > '); +$this->theme->AppendPlus($this,'colorbox'); +$this->theme->AppendPlus($this,"uploadify"); +$this->theme->AppendPlus($this,'admin_plugin'); +?> + +
      +
      + partial('data/left.phtml'); ?> +
      +
      +
      + partial('data/ref-nav.phtml',array('ac'=>$this->ac)); ?> +
      + error)) { ?> + error ?> + + msg)) { ?> + msg ?> + +

      RIS导出

      +
      + +
      + years)) { ?> + 按年份 : + years as $k=>$v){ ?> + () + +
      + +
      + +
      + 其它方式:全部 +
      + + +
      +
      + \ No newline at end of file diff --git a/application/module/Reference/Reference.php b/application/module/Reference/Reference.php index 0b8fc73c..a38a9627 100644 --- a/application/module/Reference/Reference.php +++ b/application/module/Reference/Reference.php @@ -575,4 +575,26 @@ class Reference return; } + //获得标签 + public function getTagsByReference($id,$single = false) + { + if(is_numeric($id)) + { + $sql = "SELECT * FROM {$this->table->reference_tag} WHERE id=$id"; + $rs = $this->db->query($sql); + if(!$single) + { + return $rs->fetchAll(); + }else{ + foreach($rows = $rs->fetchAll() as $k=>$v) + { + $rows[$k] = (string)$v['tag']; + } + return $rows; + } + } + + return; + } + } diff --git a/application/module/Reference/RisOutput.php b/application/module/Reference/RisOutput.php new file mode 100644 index 00000000..842b2ba2 --- /dev/null +++ b/application/module/Reference/RisOutput.php @@ -0,0 +1,153 @@ +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 preRead($mode = "all") + { + if($mode == "all") + { + $sql = "SELECT * FROM {$this->table->reference} ORDER BY year DESC,title ASC,id ASC"; + $rs = $this->db->query($sql); + return $rs->fetchAll(); + } + + + }//preRead + + //将数据组成RIS数组格式 + public function processArrayDataToRisData($arrayData,$risPrior = true,$mixAuthor = true,$mixTags = true) + { + if(!is_array($arrayData)) + { + return false; + } + + $risData = array(); + + if($risPrior === true) + { + $risReader = new RISReader(); + } + + $this->ris = new Ris(); + $this->attr = $this->ris->attr; + $this->attr_flip = array_flip($this->ris->attr); + unset($this->ris); + + $this->reference = new Reference(); + + foreach($arrayData as $k=>$v) + { + $risData[$k] = $this->transformToRis($v); + if($mixAuthor === true || $mixTags === true) + { + if($mixAuthor === true) + { + $author = $this->reference->getAuthorByReference($v['id'],true); + if(is_array($author) && count($author)>0) + { + $risData[$k] = array_merge($risData[$k],array("AU"=>$author)); + } + unset($author); + }//mixAuthor + + if($mixTags === true) + { + $tags = $this->reference->getTagsByReference($v['id'],true); + if(is_array($tags) && count($tags) > 0) + { + $risData[$k] = array_merge($risData[$k],array("KW"=>$tags)); + } + unset($tags); + } + } + + if(!is_array($risData[$k]) || count($risData[$k]) < 1) + { + unset($risData[$k]); + } + + unset($arrayData[$k]); + } + + return $risData; + }//processArrayDataToRisData + + //单条记录的整编 + public function transformToRis($record) + { + $arr = array(); + + foreach($record as $k=>$v) + { + if(!empty($v)) + { + if(isset($this->attr_flip[$k])) + { + //echo $k ."-". $this->attr_flip[$k] . '-' .$v; + //echo "
      "; + $arr[$this->attr_flip[$k]] = array(0=>$v); + } + } + } + //echo "
      "; + return $arr; + }//transformToRis + + //输出成文件 + public function output($risData) + { + $risWirte = new RISWriter(); + return @$risWirte->writeRecords($risData); + }//output +} From 838afc1d5dc964217916e6858146c442fc84b32a Mon Sep 17 00:00:00 2001 From: wlx Date: Mon, 4 Nov 2013 12:09:57 +0000 Subject: [PATCH 029/126] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E7=8C=AE?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/views/scripts/data/ref.phtml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/application/admin/views/scripts/data/ref.phtml b/application/admin/views/scripts/data/ref.phtml index 7813e18a..f3b3afcb 100644 --- a/application/admin/views/scripts/data/ref.phtml +++ b/application/admin/views/scripts/data/ref.phtml @@ -75,11 +75,16 @@ table thead tr th {background:#EBF2F6;} $autoindex++;?> - []  + []  + {reference->getAuthorByReference($item['id'],true); echo count($authors) ? join(",",$authors):'未知作者'; ?>}  {未知标题':$item['title'] ?>}  {未知期刊':$item['publisher'] ?>}  {未知年份':$item['year'] ?>}  + 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 @@
      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;} msg ?> + ac == 'westdc'){ ?> + + + years)) { ?> years as $k=>$v){ ?> () 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): ?> +
        1. 查看'; + if (!empty($item['link'])) : + echo ' 下载'; + else : + if (!empty($item['attid'])) echo ' 下载'; + endif; ?> - 相关数据 -
        2. - -
      + 相关数据 + + +
      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): ?> -
        1. - 下载'; - endif; +
        2. 查看'; + if (!empty($item['link'])) : + echo ' 下载'; + else : + if (!empty($item['attid'])) echo ' 下载'; + endif; ?>
        3. -
      +
      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(' > ');
      + \ 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;} +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 '
      1. '.$ref->reference; + echo '
      2. '.$ref->reference; + echo '查看'; if (empty($ref->link)) { - if(!empty($ref->attid)) + if(!empty($ref->attid)) echo '下载'; + }else{ + echo '下载'; + } + echo "
      3. "; + endforeach; + ?> +
      + themeref) :?> + +
      +

      专题文献

      +
        + themeref as $ref) : + echo '
      1. '.$ref->reference; + echo '查看'; + if (empty($ref->link)) + { + if(!empty($ref->attid)) + echo ' | 下载'; }else{ - echo '下载'; + echo ' | 下载'; } echo "
      2. "; endforeach; ?>
      - - userref) : ?> + userref) : ?>
      -

      数据用户发表文献

      +

      数据施引文献

        userref as $ref) : + echo '
      1. '.$ref->reference; + echo '查看'; if (empty($ref->link)) - echo '
      2. '.$ref->reference.'
      3. '; - else - echo '
      4. '.$ref->reference.' 下载
      5. '; + { + 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 '
      1. '.$ref->reference; + echo '查看'; if (empty($ref->link)) { - if(!empty($ref->attid)) + if(!empty($ref->attid)) echo '下载'; + }else{ + echo '下载'; + } + echo "
      2. "; + endforeach; + ?> +
      + themeref) :?> + +
      +

      专题文献

      +
        + themeref as $ref) : + echo '
      1. '.$ref->reference; + echo '查看'; + if (empty($ref->link)) + { + if(!empty($ref->attid)) + echo ' | 下载'; }else{ - echo '下载'; + echo ' | 下载'; } echo "
      2. "; endforeach; ?>
      - - userref) : ?> + userref) : ?>
      -

      数据用户发表文献

      +

      数据施引文献

        userref as $ref) : + echo '
      1. '.$ref->reference; + echo '查看'; if (empty($ref->link)) - echo '
      2. '.$ref->reference.'
      3. '; - else - echo '
      4. '.$ref->reference.' 下载
      5. '; + { + 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 '
      1. '.$ref->reference; + echo '查看'; if (empty($ref->link)) { - if(!empty($ref->attid)) + if(!empty($ref->attid)) echo '下载'; + }else{ + echo '下载'; + } + echo "
      2. "; + endforeach; + ?> +
      + themeref) :?> + +
      +

      专题文献

      +
        + themeref as $ref) : + echo '
      1. '.$ref->reference; + echo '查看'; + if (empty($ref->link)) + { + if(!empty($ref->attid)) + echo ' | 下载'; }else{ - echo '下载'; + echo ' | 下载'; } echo "
      2. "; endforeach; ?>
      - - userref) : ?> + userref) : ?>
      -

      数据用户发表文献

      +

      数据施引文献

        userref as $ref) : + echo '
      1. '.$ref->reference; + echo '查看'; if (empty($ref->link)) - echo '
      2. '.$ref->reference.'
      3. '; - else - echo '
      4. '.$ref->reference.' 下载
      5. '; + { + 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): ?> -
      1. 数据中心施引文献'; + 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 "
      2. "; 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 '

      '.$this->md['title'].'

      '; + 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)) { ?> + msg ?> + + error)) { ?> + error ?> + +
      +
      + +
      + info['name']; ?>" /> +
      +
      +
      + +
      + info['uri']; ?>" /> +
      +
      + +
      + + + +
      + + +
      +
      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)) { ?> + msg ?> + + error)) { ?> + 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(' > '); +?> + +
      +
      + 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 '
      1. '.$ref->reference.'
      2. '; + { + echo '
      3. '.$ref->reference; + echo '查看'; + if(!empty($ref->attid)) { + echo ' 下载'; + } + echo "
      4. "; + } else - echo '
      5. '.$ref->reference.' 下载
      6. '; + echo '
      7. '.$ref->reference.'查看 下载
      8. '; 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 @@
      - info['unit']; ?>" class="span8" /> + info['unit']; ?>" class="input-block-level" />
      - info['address']; ?>" class="span8" /> + info['address']; ?>" class="input-block-level" />
      @@ -107,13 +107,13 @@
      - info['project_title']; ?>" class="span8" /> + info['project_title']; ?>" class="input-block-level" />
      - +
      From c2225d4e2169f1343d3930814166a888c354ea04 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Thu, 26 Dec 2013 02:15:41 +0000 Subject: [PATCH 076/126] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=9A=84=E7=BB=9F=E4=B8=80=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/views/scripts/data/left.phtml | 4 ++-- application/admin/views/scripts/down/left.phtml | 4 ++-- application/admin/views/scripts/news/left.phtml | 4 ++-- application/admin/views/scripts/stat/left.phtml | 4 ++-- application/admin/views/scripts/sys/left.phtml | 6 +++--- application/admin/views/scripts/user/left.phtml | 4 ++-- application/admin/views/scripts/watermd/left.phtml | 14 +++++++------- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/application/admin/views/scripts/data/left.phtml b/application/admin/views/scripts/data/left.phtml index 5e4684a6..9f3d6c21 100644 --- a/application/admin/views/scripts/data/left.phtml +++ b/application/admin/views/scripts/data/left.phtml @@ -1,5 +1,5 @@ -
        -
      • 数据管理
      • +
      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)) { ?> + 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)) { ?> + error ?> + +
      +
      + +
      + + 请输入注册时填写的Email地址 +
      +
      +
      + +
      + + + 看不清? +
      +
      +
      +
      + + href)){?> + + + + 登录 注册新用户 +
      +
      + +
      + \ 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(' > '); ?> -
      error)) { ?> @@ -29,7 +14,7 @@
      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(' > '); +?> +
      + + error)) { ?> + + + + +
      + +
      + " name="username" /> + (必填) +
      +
      +
      + +
      + + (必填) +
      +
      +
      + +
      + + (必填) +
      +
      +
      + +
      + " name="email" /> + (必填) +
      +
      +
      + +
      + " name="realname" /> +
      +
      +
      + +
      + " name="phone" /> +
      +
      +
      + +
      + " name="unit" class="input-block-level" /> +
      +
      +
      + +
      + " name="address" class="input-block-level" /> +
      +
      +
      + +
      + " name="project_id" /> +
      +
      +
      + +
      + " name="project_leader" /> +
      +
      +
      + +
      + +
      +
      +
      + +
      + " name="project_title" class="input-block-level" /> +
      +
      +
      + +
      + " name="project" class="input-block-level" /> +
      +
      +
      + + href)){?> + + + + 忘记密码? +
      + +
      +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 @@ 请输入用户名和密码登录
      - + 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 @@ 请输入您的基本信息进行注册
      - + 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 = '
      ' - + '
      查看详细 接收 - 退回 + 退回 上传申请表 重置申请表
      +
      - - - - - - - - + + + + + + + + paginator as $item): ?> - + - - + + @@ -78,6 +84,64 @@ + + + \ No newline at end of file diff --git a/application/default/views/scripts/haihe/index.phtml b/application/default/views/scripts/haihe/index.phtml new file mode 100644 index 00000000..47590f84 --- /dev/null +++ b/application/default/views/scripts/haihe/index.phtml @@ -0,0 +1,18 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->data); +$this->headTitle()->setSeparator(' - '); +$this->headLink()->appendStylesheet('/css/water.css'); +$this->nav[] = array('link'=>"/haihe",'title'=>'海河流域观测数据集'); +?> +render('breadcrumbs.phtml'); ?> +
      +
      +
      +

      info['title'])) echo $this->info['title']; ?>

      +
      姓名单位地址邮编用途数据清单申请时间操作姓名单位地址邮编用途数据清单申请时间操作
      page; ?>">编辑 | 删除 | PDF | 详细 | - 重新通过 + 重新通过 | + 上传签字申请表 + + | 查看签字申请表 +
      + +
      info['body'])) echo $this->info['body'];?>
      +
    +
    +
    diff --git a/application/default/views/scripts/haihe/view.phtml b/application/default/views/scripts/haihe/view.phtml new file mode 100755 index 00000000..8ae014c5 --- /dev/null +++ b/application/default/views/scripts/haihe/view.phtml @@ -0,0 +1,577 @@ +headTitle($this->config->title->site); + $this->headTitle($this->config->title->data); + $this->headTitle($this->metadata->title); + $this->headTitle()->setSeparator(' - '); + $this->breadcrumb('首页'); + $this->breadcrumb(''.$this->config->title->data.''); + $this->breadcrumb('查看元数据'); + $this->breadcrumb()->setSeparator(' > '); + $this->theme->AppendPlus($this,'google_map_v3'); + $this->theme->AppendPlus($this,'colorbox'); + if(!empty($this->dataService)) { + $this->theme->AppendModel($this,"dataservice"); + } +?> + +render('breadcrumbs.phtml'); ?> +metadata;if ($md):?> +

    escape($md->title); +if ($md->title_en) echo '
    '.$this->escape($md->title_en);?> +

    +
    +
    +
    +
    + +

    +

    ',$md->description);?> +

    +
    +
    + mcitation) : ?> +
    +

    本数据要求的多篇文献引用

    +
      + mcitation as $ref) : + echo '
    1. '.$ref->reference; + echo '查看'; + if (empty($ref->link)) + { + if(!empty($ref->attid)) + echo '下载'; + }else{ + echo '下载'; + } + echo "
    2. "; + endforeach; + ?> +
    + + citation) : ?> +
    +

    本数据引用方式数据引用帮助

    +

    datadoi) || !strpos($md->citation,$md->datadoi)) : ?>文章的引用 + escape($md->citation);if (strpos($md->citation,$md->datadoi)) : ?> + (下载引用:RIS格式 | RIS英文格式 | Bibtex格式 | Bibtex英文格式) + +

    + datadoi) && !strpos($md->citation,$md->datadoi)) : ?> +

    数据的引用authors,1,-1).'. '.$md->title.'. '.$md->publisher.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi; + echo ' ['.str_replace('"','',substr($md->author_en,1,-1)).'. '.$md->title_en.'. '.$md->publisher_en.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi.']'; + ?> (下载引用:RIS格式 | RIS英文格式 | Bibtex格式 | Bibtex英文格式)

    + ref) : ?> +
    +

    相关文献(作者推荐)

    +
      + ref as $ref) : + echo '
    1. '.$ref->reference; + echo '查看'; + if (empty($ref->link)) + { + if(!empty($ref->attid)) + echo '下载'; + }else{ + echo '下载'; + } + echo "
    2. "; + endforeach; + ?> +
    + themeref) :?> + +
    +

    专题文献

    +
      + themeref as $ref) : + echo '
    1. '.$ref->reference; + echo '查看'; + if (empty($ref->link)) + { + if(!empty($ref->attid)) + echo ' | 下载'; + }else{ + echo ' | 下载'; + } + echo "
    2. "; + endforeach; + ?> +
    + userref) : ?> +
    +

    数据施引文献

    +
      + userref as $ref) : + echo '
    1. '.$ref->reference; + echo '查看'; + if (empty($ref->link)) + { + if(!empty($ref->attid)) + echo '下载'; + }else{ + echo '下载'; + } + echo "
    2. "; + endforeach; + if (count($this->userref)==15) + { + echo '更多施引文献'; + } + ?> +
    + +
    +

    数据使用声明

    + uselimits) : + foreach($this->uselimits as $uselimit) : + echo '

    '.str_replace(array("\r\n", "\n", "\r"),'

    ',$this->escape($uselimit->uselimit)).'

    '; + endforeach; + ?> + +

    为尊重知识产权、保障数据作者的权益、扩展数据中心的服务、评估数据的应用潜力,请数据使用者在使用数据所产生的研究成果中(包括公开发表的论文、论著、数据产品和未公开发表的研究报告、数据产品等成果),明确注明数据来源和数据作者。对于转载(二次或多次发布)的数据,作者还须注明原始数据来源。

    +

    中文发表的成果参考以下规范注明: 数据来源于黑河计划数据管理中心、寒区旱区科学数据中心(http://westdc.westgis.ac.cn)

    +

    英文发表的成果依据以下规范注明: The data set is provided by Cold and Arid Regions Sciences Data Center at Lanzhou (http://westdc.westgis.ac.cn)

    +

    + + data_archives){ ?> +

    数据相关新闻

    +
      + data_archives as $v){?> +
    • + +
    +
    + + suppinfo || $this->fund) : ?> +

    资助项目

    + fund)) : ?> +
      + fund as $k=>$v) : ?> +
    • (项目编号:) [(No. )]
    • + +
    + suppinfo)) : ?> + '.str_replace(array("\r\n", "\n", "\r"),'

    ',$this->escape($md->suppinfo)).'

    ';?> + +
    + + resources) : ?> +

    相关资源

    + +
    + +
    +
    + keys as $cg){ + if($cg['keytype']=="theme") + $keywords[]=$cg['keyword']; + } + $ev = join(" ",$keywords); + ?> +
    + +
    + + +
    +
      +
      +
      + downhistory) : ?> +

      最近10条服务记录如下:

      +
        + downhistory as $v){ + echo '
      1. '.date("Y-m-d",strtotime($v->ts_created))." ".$v->unit." ".$v->realname; + if (!empty($v->offlineproject)) + echo ' 用途:'.$v->offlineproject; + elseif (!empty($v->onlineproject)) + echo ' 用途:'.$v->onlineproject; + echo '
      2. '; + } + ?> +
      + + 暂时没有服务记录,欢迎您下载使用! + +
      +
      + +
      +
      +
      +
      +
      + status>0 and $md->status<5) : ?> +

      此数据还在评审过程中,我们真切地邀请您参加此数据的评审,以便我们能尽快发布此数据!评审

      + +

      数据评论

      +
      +
      评论加载中
      +
      + hasIdentity()) + { + $user = $auth->getIdentity(); + $name = $user->realname; + $email = $user->email; + }else + { + $name = ""; + $email = ""; + } + ?> +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + e.g. http://westdc.westgis.ac.cn/ +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      +
      + + + 提交 +
      +
      +
      +
      + +
      +
      +
      +
      + + '学科','place'=>'地点','theme'=>'主题','temporal'=>'时间词','stratum'=>'地层'); +$kt=''; +$i=0; +foreach($this->keys as $cg) : + if ($kt==$cg['keytype']) : + $i+=1; + else : + if (!empty($kt)) echo ''; + $kt=$cg['keytype']; + $i=0; + endif; + if ($i==0) { + ?> + + doi) : ?> +
      • 数据DOI:doi; ?>
      + +
      +
      +

      数据细节文件列表

      +
        + fileformat) : ?> +
      • 格式:fileformat; ?>
      • + +
      • 大小:filesize; ?>MB
      • + downloaded>9) :?> +
      • 下载:downloaded; ?>次
      • + +
      • 浏览:viewed; ?>次
      • + + timebegin)) : ?> +
      • 数据时间范围:timebegin));if (!empty($md->timeend)) echo " 至 ".date('Y-m-d',strtotime($md->timeend)); ?>
      • + + doc)) : ?> + + + attachments) : ?> +
      • 相关文档: + attachments as $k=>$a) : ?> + + + +
      • + +
      • 数据共享方式:datatype) print "离线"; else print "在线(可直接下载)";?>
      • +
      +
      + status>0 and $md->status<5) : ?> + 数据评审 + datatype) : ?> + + 在线下载 + + + dataService)) { ?> + theme->AppendPlus($this,'datepicker'); ?> + + + + + 放入数据篮 + + + + 收藏此数据 + +
      +
      +
      +

      空间位置

      +
      +
      +

      联系信息

      +
      +
        + '资源提供者','custodian'=>'维护者','owner'=>'拥有者','user'=>'用户','distributor'=>'数据服务联系人','originator'=>'创建者','pointOfContact'=>'联系人','principalInvestigator'=>'数据调查与处理者','processor'=>'处理者','publisher'=>'元数据发布者','author'=>'元数据作者'); + $r=''; + $i=0; + foreach($this->authors as $k=>$author) : + if ($author->role!=$r) + { + $r=$author->role; + $i=0; + if ($k>0) echo ''; + echo '
      • '.$party_zh[$author->role].':'; + } + if ($i>0) echo ','; + $i+=1; + if (!empty($author->email) && $r!='principalInvestigator') + echo ''; + echo ''; + if (!empty($author->individual)) + echo $author->individual; + else + echo $author->organisation; + echo ''; + if (!empty($author->email)) echo ''; + if ($k+1==count($this->authors)) echo '
      • '; + endforeach; + ?> +
      +
      +
        +
      • 元数据更新时间:ts_created)); ?>
      • +
      • 下载元数据: + Adobe PDF格式 + OpenOffice odt格式 + Word doc格式 + 查看XML源文件 +
      • + + version->c>0):?> +
      • 版本历史:version->c ?> 个
      • + +
      +
      + +
      +
      +
      分享到
      + +
      + + + + + + + + + +
      + +
      +
      +
      + + + +

      Cannot find the metadata.

      +

      没有找到对应的元数据。

      + + + From 51f3adfa794787c730904b3b4a8639da259403b6 Mon Sep 17 00:00:00 2001 From: wlx Date: Fri, 10 Jan 2014 04:09:50 +0000 Subject: [PATCH 099/126] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=B5=B7=E6=B2=B3?= =?UTF-8?q?=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/default/controllers/HaiheController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/default/controllers/HaiheController.php b/application/default/controllers/HaiheController.php index 88e38d6f..106b6287 100644 --- a/application/default/controllers/HaiheController.php +++ b/application/default/controllers/HaiheController.php @@ -15,7 +15,7 @@ class HaiheController extends DataController function indexAction() { $archive = new Archive($this->db); - $this->view->info = $archive->getOneArchive('海河流域地表通量、气象要素观测数据集','about'); + $this->view->info = $archive->getOneArchive('海河流域多尺度地表通量与气象要素观测数据集','about'); } function documentAction() From 7871ebfb6af5dc681c2bb2d2c71335f6d80da771 Mon Sep 17 00:00:00 2001 From: wlx Date: Fri, 10 Jan 2014 05:01:42 +0000 Subject: [PATCH 100/126] add breadcrump and reference link --- .../default/views/scripts/haihe/document.phtml | 12 +++++++----- application/default/views/scripts/haihe/view.phtml | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/application/default/views/scripts/haihe/document.phtml b/application/default/views/scripts/haihe/document.phtml index bc9de0f4..485bdd71 100644 --- a/application/default/views/scripts/haihe/document.phtml +++ b/application/default/views/scripts/haihe/document.phtml @@ -19,12 +19,14 @@ $this->nav[] = array('link'=>"/haihe",'title'=>'海河流域观测数据集');
        refs as $md) : ?>
      1. 下载'; - } + echo ' 查看'; + if (!empty($md['link'])) : + echo ' 下载'; + else : + if (!empty($md['attid'])) echo ' 下载'; + endif; ?> - [相关数据] + [相关数据]
      diff --git a/application/default/views/scripts/haihe/view.phtml b/application/default/views/scripts/haihe/view.phtml index 8ae014c5..99de4298 100755 --- a/application/default/views/scripts/haihe/view.phtml +++ b/application/default/views/scripts/haihe/view.phtml @@ -12,6 +12,7 @@ if(!empty($this->dataService)) { $this->theme->AppendModel($this,"dataservice"); } + $this->nav[] = array('link'=>"/haihe",'title'=>'海河流域观测数据集'); ?> -
      -partial('stat/left.phtml'); ?> -
      -
      - - -
      -点击列名进行排序 -
      -
      - - - - - - - - - - - - - -
      ID用户离线申请次数在线申请次数总申请次数
      -
      - -
      - \ No newline at end of file diff --git a/application/module/Statistics/User.php b/application/module/Statistics/User.php new file mode 100644 index 00000000..c7b69c04 --- /dev/null +++ b/application/module/Statistics/User.php @@ -0,0 +1,130 @@ +db = \Zend_Registry::get('db'); + }else{ + $this->db = $db; + } + + $this->config = \Zend_Registry::get('config'); + + $this->table = new \Helpers\Table(); + } + + public function ThisYear(){ + return date("Y",time()); + } + + //按年统计新用户 + public function getNewUsersByYear($year = 0) + { + if(empty($year)) + { + $year = $this->ThisYear(); + } + + if($year == -1) + { + $sql = "select count(id),extract(year from ts_created) + from users + group by extract(year from ts_created) + order by date_part"; + }else{ + $sql = "select count(id),extract(year from ts_created) + from users + where extract(year from ts_created)='$year' + group by extract(year from ts_created)"; + } + + $rs = $this->db->query($sql); + $rows = $rs->fetchAll(); + return $rows; + } + + //按月统计新用户 + public function getNewUsersByMonth($year = 0) + { + if(empty($year)) + { + $year = $this->ThisYear(); + } + + $sql = "select count(id),extract(month from ts_created) + from users + where extract(year from ts_created)=$year + group by extract(month from ts_created) + order by date_part"; + + $rs = $this->db->query($sql); + $rows = $rs->fetchAll(); + return $rows; + } + + //月均注册量 + public function getAverageSingupByMonth($year = 0) + { + if(empty($year)) + { + $year = $this->ThisYear(); + } + + $sql = "select round(count(id)/12) as count,extract(year from ts_created) + from users + where extract(year from ts_created)='$year' + group by extract(year from ts_created)"; + + $rs = $this->db->query($sql); + $rows = $rs->fetchAll(); + return $rows; + } + + //总用户量 + public function getTotal($year = 0) + { + if(empty($year)) + { + $year = $this->ThisYear(); + } + + $sql = ""; + + $rs = $this->db->query($sql); + $rows = $rs->fetchAll(); + return $rows; + } + + //平均申请数 + public function getAverageApplicationTimes($times = 1) + { + if(empty($year)) + { + $times = 1; + } + + $sql = ""; + + $rs = $this->db->query($sql); + $rows = $rs->fetchAll(); + return $rows; + } + +} From 7ccd999fd5dd20b0ff4ee45423ec60e56dd5763f Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Mon, 13 Jan 2014 07:16:22 +0000 Subject: [PATCH 106/126] =?UTF-8?q?#569=20=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=8F=91=E5=B8=83=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E5=8C=BA=E5=88=86=EF=BC=8C=E6=9C=AA=E5=8F=91=E5=B8=83=E6=97=B6?= =?UTF-8?q?doi=E6=A0=87=E9=A2=98=E5=8F=AF=E4=BF=AE=E6=94=B9=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E8=AF=BB=E5=8F=96=E5=85=83=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84=E6=A0=87=E9=A2=98=E4=BD=9C=E4=B8=BA=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controllers/DataController.php | 5 +++++ application/admin/views/scripts/data/doi-add.phtml | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index b7675d6d..5e36363b 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -4000,6 +4000,11 @@ class Admin_DataController extends Zend_Controller_Action }else{ $this->view->data['doi'] = $metadata['doi']; $this->view->data['info'] = $doi->data_process_out($this->view->data); + if(empty($this->view->data['ts_published'])) + { + $this->view->data['title'] = $metadata['title']; + $this->view->data['title_en'] = $metadata['title_en']; + } } }else{ $this->view->data = $doi->view($uuid); diff --git a/application/admin/views/scripts/data/doi-add.phtml b/application/admin/views/scripts/data/doi-add.phtml index 39ed9c36..7a6a7028 100644 --- a/application/admin/views/scripts/data/doi-add.phtml +++ b/application/admin/views/scripts/data/doi-add.phtml @@ -57,13 +57,15 @@ $this->theme->AppendPlus($this,'colorbox');
      - " /> + data['ts_published']) ? 'readonly="readonly"':""?> + value="data['title']) ? $this->data['title']:"" ?>" />
      - " /> + data['ts_published']) ? 'readonly="readonly"':""?> + value="data['title_en']) ? $this->data['title_en']:"" ?>" />
      From 3967c23ecbc6b6ca854c5ce3d6ae8c667c94ed89 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Mon, 13 Jan 2014 07:28:36 +0000 Subject: [PATCH 107/126] =?UTF-8?q?#569=E5=B0=86=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E8=AE=BE=E4=B8=BA=E9=BB=98=E8=AE=A4=E4=B8=8D=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/views/scripts/data/doi-add.phtml | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/application/admin/views/scripts/data/doi-add.phtml b/application/admin/views/scripts/data/doi-add.phtml index 7a6a7028..01ca5041 100644 --- a/application/admin/views/scripts/data/doi-add.phtml +++ b/application/admin/views/scripts/data/doi-add.phtml @@ -29,43 +29,47 @@ $this->theme->AppendPlus($this,'colorbox'); msg)) { ?> msg ?> +
      + +

      提示

      + 如果元数据中标题发生了变更,在DOI中也需要变更时需要在这里点击“提交”按钮才能生效 +
      - " /> + " />
      - " /> + " class="input-block-level" />
      - " /> + " class="input-block-level" />
      - " /> + " class="input-block-level"/>
      - data['ts_published']) ? 'readonly="readonly"':""?> - value="data['title']) ? $this->data['title']:"" ?>" /> + " class="input-block-level"/>
      - data['ts_published']) ? 'readonly="readonly"':""?> - value="data['title_en']) ? $this->data['title_en']:"" ?>" /> + " class="input-block-level" />
      From ed6d450d4a013187bc979375e60667a678f5fc35 Mon Sep 17 00:00:00 2001 From: wlx Date: Tue, 14 Jan 2014 02:16:49 +0000 Subject: [PATCH 108/126] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BA=E5=88=86?= =?UTF-8?q?=E6=A0=8F=E7=9B=AE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/controllers/HaiheController.php | 60 ++++++++++++++++--- .../default/views/scripts/haihe/base.phtml | 30 ++++++++++ .../views/scripts/haihe/document.phtml | 5 +- .../default/views/scripts/haihe/index.phtml | 6 +- .../default/views/scripts/haihe/navi.phtml | 38 ++++++++++++ 5 files changed, 130 insertions(+), 9 deletions(-) create mode 100644 application/default/views/scripts/haihe/base.phtml create mode 100644 application/default/views/scripts/haihe/navi.phtml diff --git a/application/default/controllers/HaiheController.php b/application/default/controllers/HaiheController.php index 106b6287..d1aed6a2 100644 --- a/application/default/controllers/HaiheController.php +++ b/application/default/controllers/HaiheController.php @@ -20,20 +20,66 @@ class HaiheController extends DataController function documentAction() { - $page=(int)$this->_request->getParam('page'); - if (empty($page)) $page=1; - $offset=$this->limit*($page-1); - $row=$this->db->fetchAll("select count(*) from reference where id in (select refid from mdref where uuid in (select uuid from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='haihe') ))"); - $sum=$row[0]['count']; + $page=(int)$this->_request->getParam('page'); + if (empty($page)) $page=1; + $offset=$this->limit*($page-1); + $row=$this->db->fetchAll("select count(*) from reference where id in (select refid from mdref where uuid in (select uuid from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='haihe') ))"); + $sum=$row[0]['count']; $sql="select * from reference where id in (select refid from mdref where uuid in (select uuid from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='haihe') )) order by reference limit ? offset ?"; $this->view->refs=$this->db->fetchAll($sql,array($this->limit,$offset)); - $this->view->page=new Pagination($sum,$page,$this->limit,"文献"); - $this->view->offset=$offset+1; + $this->view->page=new Pagination($sum,$page,$this->limit,"文献"); + $this->view->offset=$offset+1; + } + + function daxingAction() + { + $this->getmd(array('大兴区')); + $this->_helper->viewRenderer('base'); } + function miyunAction() + { + $this->getmd(array('密云')); + $this->_helper->viewRenderer('base'); + } + + function guantaoAction() + { + $this->getmd(array('馆陶县')); + $this->_helper->viewRenderer('base'); + } + function viewAction() { parent::viewAction(); $this->_helper->viewRenderer('haihe/view'); } + + private function getmd($keyword,$type='theme') + { + $page=(int)$this->_request->getParam('page'); + if (empty($page)) $page=1; + $offset=$this->limit*($page-1); + if (!is_array($keyword)) + { + $keyword=array($keyword); + } + $key="("; + foreach($keyword as $k) + { + $key.="'".$k."',"; + } + $key=substr($key,0,-1); + $key.=")"; + $keyword=$key; + + $state=$this->db->query("select count(m.*) from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='haihe' and m.id in (select id from keyword where keytype='".$type."' and keyword in ".$keyword.")"); + $row=$state->fetchAll(); + $sum=$row[0]['count']; + //@todo: add order with title + $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='haihe') and id in (select id from keyword where keytype='".$type."' and keyword in ".$keyword.") order by title limit ? offset ?"; + $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); + $this->view->page=new Pagination($sum,$page,$this->limit); + $this->view->offset=$offset+1; + } } \ No newline at end of file diff --git a/application/default/views/scripts/haihe/base.phtml b/application/default/views/scripts/haihe/base.phtml new file mode 100644 index 00000000..4c53ca20 --- /dev/null +++ b/application/default/views/scripts/haihe/base.phtml @@ -0,0 +1,30 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->data); +$this->headTitle()->setSeparator(' - '); +$this->headLink()->appendStylesheet('/css/water.css'); +$this->nav[] = array('link'=>"/haihe",'title'=>'海河流域观测数据集'); +?> +render('breadcrumbs.phtml'); ?> +
      +
      + partial('haihe/navi.phtml'); ?> +
      +
      + info) : ?> +
      + info['body'])) echo $this->info['body'];?> +
      + + metadata) : ?> + page->getNavigation(); ?> +
      +
        + metadata as $md) : ?> +
      1. + +
      +
      + +
      +
      \ No newline at end of file diff --git a/application/default/views/scripts/haihe/document.phtml b/application/default/views/scripts/haihe/document.phtml index 643f3411..370b05ff 100644 --- a/application/default/views/scripts/haihe/document.phtml +++ b/application/default/views/scripts/haihe/document.phtml @@ -10,8 +10,11 @@ $this->nav[] = array('link'=>"/haihe",'title'=>'海河流域观测数据集'); ?> render('breadcrumbs.phtml'); ?>
      -
      +
      + partial('haihe/navi.phtml'); ?> +
      +

      数据相关文献

      refs) : ?> page->getNavigation(); ?> diff --git a/application/default/views/scripts/haihe/index.phtml b/application/default/views/scripts/haihe/index.phtml index 47590f84..11407b57 100644 --- a/application/default/views/scripts/haihe/index.phtml +++ b/application/default/views/scripts/haihe/index.phtml @@ -7,7 +7,11 @@ $this->nav[] = array('link'=>"/haihe",'title'=>'海河流域观测数据集'); ?> render('breadcrumbs.phtml'); ?>
      -
      +
      + partial('haihe/navi.phtml'); ?> +
      + +

      info['title'])) echo $this->info['title']; ?>

      diff --git a/application/default/views/scripts/haihe/navi.phtml b/application/default/views/scripts/haihe/navi.phtml new file mode 100644 index 00000000..ad49c1a3 --- /dev/null +++ b/application/default/views/scripts/haihe/navi.phtml @@ -0,0 +1,38 @@ + \ No newline at end of file From 4f7a2765b30a8286cdf5f4e6062c1484e8b276c8 Mon Sep 17 00:00:00 2001 From: wlx Date: Tue, 14 Jan 2014 02:22:56 +0000 Subject: [PATCH 109/126] fix link problem --- application/default/controllers/HaiheController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/default/controllers/HaiheController.php b/application/default/controllers/HaiheController.php index d1aed6a2..5c54b895 100644 --- a/application/default/controllers/HaiheController.php +++ b/application/default/controllers/HaiheController.php @@ -33,19 +33,19 @@ class HaiheController extends DataController function daxingAction() { - $this->getmd(array('大兴区')); + $this->getmd(array('大兴区'),'place'); $this->_helper->viewRenderer('base'); } function miyunAction() { - $this->getmd(array('密云')); + $this->getmd(array('密云'),'place'); $this->_helper->viewRenderer('base'); } function guantaoAction() { - $this->getmd(array('馆陶县')); + $this->getmd(array('馆陶县'),'place'); $this->_helper->viewRenderer('base'); } From 9954be07f905f147e2d294247dfbea0de6315304 Mon Sep 17 00:00:00 2001 From: wlx Date: Thu, 16 Jan 2014 02:42:20 +0000 Subject: [PATCH 110/126] add more link --- application/admin/views/scripts/stat/month.phtml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/application/admin/views/scripts/stat/month.phtml b/application/admin/views/scripts/stat/month.phtml index 3b4b03ac..429cc39f 100644 --- a/application/admin/views/scripts/stat/month.phtml +++ b/application/admin/views/scripts/stat/month.phtml @@ -39,7 +39,10 @@ 2009 2010 2011 - 2012 + 2012 + 2013 + 2014 + 2015
      y.'年按月在线下载条数(有用途记录,且无数据重复)统计';?>
      From b3b09c1839d9ed13dc1053a78137fd9420c365ae Mon Sep 17 00:00:00 2001 From: Li Heng Date: Thu, 16 Jan 2014 03:15:24 +0000 Subject: [PATCH 111/126] =?UTF-8?q?=E6=96=B0=E6=B3=A8=E5=86=8C=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8C=89=E6=9C=88=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/views/scripts/stat/user-new.phtml | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/application/admin/views/scripts/stat/user-new.phtml b/application/admin/views/scripts/stat/user-new.phtml index bc40c7d5..adcf0a37 100644 --- a/application/admin/views/scripts/stat/user-new.phtml +++ b/application/admin/views/scripts/stat/user-new.phtml @@ -63,6 +63,37 @@
      + + +
      @@ -149,6 +180,7 @@
      +
      From 8f8ffeee43478e1473e45efcb50806f8dfe710df Mon Sep 17 00:00:00 2001 From: wlx Date: Wed, 22 Jan 2014 01:45:38 +0000 Subject: [PATCH 112/126] update glacier theme --- .../default/controllers/GlacierController.php | 249 +++++++++--------- .../default/views/scripts/glacier/base.phtml | 30 +++ .../views/scripts/glacier/browse.phtml | 4 +- .../views/scripts/glacier/category.phtml | 43 --- .../views/scripts/glacier/everestnorth.phtml | 33 --- .../default/views/scripts/glacier/field.phtml | 33 --- .../views/scripts/glacier/frozensoil.phtml | 33 --- .../views/scripts/glacier/geobase.phtml | 34 --- .../views/scripts/glacier/glacier.phtml | 33 --- .../views/scripts/glacier/gongga.phtml | 33 --- .../default/views/scripts/glacier/gps.phtml | 33 --- .../default/views/scripts/glacier/hydro.phtml | 33 --- .../default/views/scripts/glacier/index.phtml | 73 +---- .../views/scripts/glacier/inventory.phtml | 35 --- .../default/views/scripts/glacier/lake.phtml | 34 --- .../default/views/scripts/glacier/lidar.phtml | 35 --- .../views/scripts/glacier/material.phtml | 35 --- .../default/views/scripts/glacier/meteo.phtml | 33 --- .../views/scripts/glacier/movement.phtml | 33 --- .../default/views/scripts/glacier/namco.phtml | 33 --- .../default/views/scripts/glacier/navi.phtml | 11 +- .../views/scripts/glacier/nianchu.phtml | 33 --- .../scripts/glacier/photogrammetry.phtml | 33 --- .../views/scripts/glacier/physical.phtml | 33 --- .../views/scripts/glacier/qilian.phtml | 33 --- .../views/scripts/glacier/quatemary.phtml | 33 --- .../default/views/scripts/glacier/rs.phtml | 33 --- .../views/scripts/glacier/search.phtml | 6 +- .../default/views/scripts/glacier/tag.phtml | 55 ++-- .../default/views/scripts/glacier/thumb.phtml | 57 ++-- .../views/scripts/glacier/tianshan.phtml | 33 --- .../views/scripts/glacier/timeline.phtml | 6 +- .../views/scripts/glacier/timemap.phtml | 8 +- .../views/scripts/glacier/vegetation.phtml | 33 --- .../views/scripts/glacier/yangtze.phtml | 33 --- 35 files changed, 244 insertions(+), 1098 deletions(-) create mode 100644 application/default/views/scripts/glacier/base.phtml delete mode 100755 application/default/views/scripts/glacier/category.phtml delete mode 100644 application/default/views/scripts/glacier/everestnorth.phtml delete mode 100644 application/default/views/scripts/glacier/field.phtml delete mode 100644 application/default/views/scripts/glacier/frozensoil.phtml delete mode 100644 application/default/views/scripts/glacier/geobase.phtml delete mode 100644 application/default/views/scripts/glacier/glacier.phtml delete mode 100644 application/default/views/scripts/glacier/gongga.phtml delete mode 100644 application/default/views/scripts/glacier/gps.phtml delete mode 100644 application/default/views/scripts/glacier/hydro.phtml delete mode 100644 application/default/views/scripts/glacier/inventory.phtml delete mode 100644 application/default/views/scripts/glacier/lake.phtml delete mode 100644 application/default/views/scripts/glacier/lidar.phtml delete mode 100644 application/default/views/scripts/glacier/material.phtml delete mode 100644 application/default/views/scripts/glacier/meteo.phtml delete mode 100644 application/default/views/scripts/glacier/movement.phtml delete mode 100644 application/default/views/scripts/glacier/namco.phtml delete mode 100644 application/default/views/scripts/glacier/nianchu.phtml delete mode 100644 application/default/views/scripts/glacier/photogrammetry.phtml delete mode 100644 application/default/views/scripts/glacier/physical.phtml delete mode 100644 application/default/views/scripts/glacier/qilian.phtml delete mode 100644 application/default/views/scripts/glacier/quatemary.phtml delete mode 100644 application/default/views/scripts/glacier/rs.phtml delete mode 100644 application/default/views/scripts/glacier/tianshan.phtml delete mode 100644 application/default/views/scripts/glacier/vegetation.phtml delete mode 100644 application/default/views/scripts/glacier/yangtze.phtml diff --git a/application/default/controllers/GlacierController.php b/application/default/controllers/GlacierController.php index 719bcdf9..0d36abc4 100644 --- a/application/default/controllers/GlacierController.php +++ b/application/default/controllers/GlacierController.php @@ -25,8 +25,8 @@ class GlacierController extends DataController function indexAction() { - $sql="select m.uuid,m.title,m.id,m.description from normalmetadata m left join thumbnail t on m.id=t.id where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and length(t.data)>2 order by random() limit 3"; - $this->view->meatdata=$this->db->fetchAll($sql); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-项目简介','about'); } /* @@ -78,187 +78,148 @@ class GlacierController extends DataController function geobaseAction() { - $page=(int)$this->_request->getParam('page'); - if (empty($page)) $page=1; - $offset=$this->limit*($page-1); - $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='遥感影像' or keyword='DEM'))"); - $row=$state->fetchAll(); - $sum=$row[0]['count']; - $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='遥感影像' or keyword='DEM')) order by timebegin,title limit ? offset ?"; - $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); - $this->view->page=new Pagination($sum,$page,$this->limit); - $this->view->offset=$offset+1; + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-基础数据','about'); + $this->getmd(array('遥感影像','DEM')); + $this->_helper->viewRenderer('base'); } function demAction() { $this->getmd('DEM'); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-DEM','about'); + $this->_helper->viewRenderer('base'); } function rsAction() { $this->getmd('遥感影像'); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-遥感影像','about'); + $this->_helper->viewRenderer('base'); } function inventoryAction() { - $page=(int)$this->_request->getParam('page'); - if (empty($page)) $page=1; - $offset=$this->limit*($page-1); - $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='冰川编目' or keyword='冰湖编目'))"); - $row=$state->fetchAll(); - $sum=$row[0]['count']; - $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='冰川编目' or keyword='冰湖编目')) order by timebegin,title limit ? offset ?"; - $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); - $this->view->page=new Pagination($sum,$page,$this->limit); - $this->view->offset=$offset+1; + $this->getmd(array('冰川编目','冰湖编目')); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-冰川冰湖编目','about'); + $this->_helper->viewRenderer('base'); } function glacierAction() { $this->getmd('冰川编目'); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-冰川编目','about'); + $this->_helper->viewRenderer('base'); } function lakeAction() { $this->getmd('冰湖编目'); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-冰湖编目','about'); + $this->_helper->viewRenderer('base'); } function fieldAction() { - $page=(int)$this->_request->getParam('page'); - if (empty($page)) $page=1; - $offset=$this->limit*($page-1); - $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' - and (keyword='水文' or keyword='流量' or keyword='水质' or keyword='同位素' or keyword='径流' or keyword='水位' or keyword='气象' or keyword='雨量' or keyword='GPS' - or keyword='雷达' or keyword='雷达测厚' or keyword='冰川厚度' or keyword='物质平衡' or keyword='花杆' or keyword='运动速度' or keyword='花杆消融观测' or keyword='冰舌' - or keyword='冰雪物理过程' or keyword='冰温' or keyword='摄影测量' or keyword='照片' or keyword='第四纪' or keyword='冻土' or keyword='植被' ))"); - $row=$state->fetchAll(); - $sum=$row[0]['count']; - $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='水文' or keyword='流量' or keyword='水质' or keyword='同位素' or keyword='径流' or keyword='水位' or keyword='气象' or keyword='雨量' or keyword='GPS' - or keyword='雷达' or keyword='雷达测厚' or keyword='冰川厚度' or keyword='物质平衡' or keyword='花杆' or keyword='运动速度' or keyword='花杆消融观测' or keyword='冰舌' - or keyword='冰雪物理过程' or keyword='冰温' or keyword='摄影测量' or keyword='照片' or keyword='第四纪' or keyword='冻土' or keyword='植被' )) order by timebegin,title limit ? offset ?"; - $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); - $this->view->page=new Pagination($sum,$page,$this->limit); - $this->view->offset=$offset+1; + $this->getmd(array('水文','流量','水质','同位素','径流','水位','气象','雨量','GPS', + '雷达','雷达测厚','冰川厚度','物质平衡','花杆','运动速度','花杆消融观测','冰舌', + '冰雪物理过程','冰温','摄影测量','照片','第四纪','冻土','植被')); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-野外考察与定位观测','about'); + $this->_helper->viewRenderer('base'); } function meteoAction() { - $page=(int)$this->_request->getParam('page'); - if (empty($page)) $page=1; - $offset=$this->limit*($page-1); - $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='气象' or keyword='雨量'))"); - $row=$state->fetchAll(); - $sum=$row[0]['count']; - $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='气象' or keyword='雨量')) order by timebegin,title limit ? offset ?"; - $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); - $this->view->page=new Pagination($sum,$page,$this->limit); - $this->view->offset=$offset+1; + $this->getmd(array('气象','雨量')); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-气象','about'); + $this->_helper->viewRenderer('base'); } function hydroAction() { - $page=(int)$this->_request->getParam('page'); - if (empty($page)) $page=1; - $offset=$this->limit*($page-1); - $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='水文' or keyword='流量' or keyword='水质' or keyword='同位素' or keyword='径流' or keyword='水位'))"); - $row=$state->fetchAll(); - $sum=$row[0]['count']; - $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='水文' or keyword='流量' or keyword='水质' or keyword='同位素' or keyword='径流' or keyword='水位')) order by timebegin,title limit ? offset ?"; - $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); - $this->view->page=new Pagination($sum,$page,$this->limit); - $this->view->offset=$offset+1; + $this->getmd(array('水文','流量','水质','同位素','径流','水位')); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-水文','about'); + $this->_helper->viewRenderer('base'); } function gpsAction() { $this->getmd('GPS','theme'); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-GPS','about'); + $this->_helper->viewRenderer('base'); } function lidarAction() { - $page=(int)$this->_request->getParam('page'); - if (empty($page)) $page=1; - $offset=$this->limit*($page-1); - $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='雷达' or keyword='雷达测厚' or keyword='冰川厚度'))"); - $row=$state->fetchAll(); - $sum=$row[0]['count']; - $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='雷达' or keyword='雷达测厚' or keyword='冰川厚度')) order by timebegin,title limit ? offset ?"; - $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); - $this->view->page=new Pagination($sum,$page,$this->limit); - $this->view->offset=$offset+1; + $this->getmd(array('雷达','雷达测厚','冰川厚度')); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-雷达测厚','about'); + $this->_helper->viewRenderer('base'); } function materialAction() { - $page=(int)$this->_request->getParam('page'); - if (empty($page)) $page=1; - $offset=$this->limit*($page-1); - $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='物质平衡' or keyword='花杆'))"); - $row=$state->fetchAll(); - $sum=$row[0]['count']; - $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='物质平衡' or keyword='花杆')) order by timebegin,title limit ? offset ?"; - $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); - $this->view->page=new Pagination($sum,$page,$this->limit); - $this->view->offset=$offset+1; + $this->getmd(array('物质平衡','花杆')); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-物质平衡','about'); + $this->_helper->viewRenderer('base'); } function movementAction() { - $page=(int)$this->_request->getParam('page'); - if (empty($page)) $page=1; - $offset=$this->limit*($page-1); - $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='运动速度' or keyword='花杆消融观测' or keyword='冰舌'))"); - $row=$state->fetchAll(); - $sum=$row[0]['count']; - $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='运动速度' or keyword='花杆消融观测' or keyword='冰舌')) order by timebegin,title limit ? offset ?"; - $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); - $this->view->page=new Pagination($sum,$page,$this->limit); - $this->view->offset=$offset+1; + $this->getmd(array('运动速度','花杆消融观测','冰舌')); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-冰川运动','about'); + $this->_helper->viewRenderer('base'); } function physicalAction() { - $page=(int)$this->_request->getParam('page'); - if (empty($page)) $page=1; - $offset=$this->limit*($page-1); - $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='冰雪物理过程' or keyword='冰温'))"); - $row=$state->fetchAll(); - $sum=$row[0]['count']; - $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='冰雪物理过程' or keyword='冰温')) order by timebegin,title limit ? offset ?"; - $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); - $this->view->page=new Pagination($sum,$page,$this->limit); - $this->view->offset=$offset+1; + $this->getmd(array('冰雪物理过程','冰温')); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-冰雪物理过程','about'); + $this->_helper->viewRenderer('base'); } function photogrammetryAction() { - $page=(int)$this->_request->getParam('page'); - if (empty($page)) $page=1; - $offset=$this->limit*($page-1); - $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='摄影测量' or keyword='照片'))"); - $row=$state->fetchAll(); - $sum=$row[0]['count']; - $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='摄影测量' or keyword='照片')) order by timebegin,title limit ? offset ?"; - $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); - $this->view->page=new Pagination($sum,$page,$this->limit); - $this->view->offset=$offset+1; + $this->getmd(array('摄影测量','照片')); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-近景摄影测量','about'); + $this->_helper->viewRenderer('base'); } function vegetationAction() { $this->getmd('植被'); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-植被调查','about'); + $this->_helper->viewRenderer('base'); } function frozensoilAction() { $this->getmd('冻土'); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-冻土调查','about'); + $this->_helper->viewRenderer('base'); } function quatemaryAction() { $this->getmd('第四纪'); + $archive = new Archive($this->db); + $this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-第四纪','about'); + $this->_helper->viewRenderer('base'); } function listAction() @@ -270,12 +231,13 @@ class GlacierController extends DataController function tagAction() { $key = $this->_request->getParam('key'); + $keytype = $this->_request->getParam('keytype'); $page=(int)$this->_request->getParam('page'); if (empty($page)) $page=1; $offset=$this->limit*($page-1); if (!empty($key)) { $this->view->codename=$key; - $sql=$this->db->quoteInto('select count(id) from keyword where keyword=?',$key); + $sql=$this->db->quoteInto("select count(k.id) from keyword k left join normalmetadata m on k.id=m.id where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glaicer') and k.keyword=?",$key); $state=$this->db->query($sql); $row=$state->fetchAll(); $sum=$row[0]['count']; @@ -283,17 +245,12 @@ class GlacierController extends DataController $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); $this->view->page=new Pagination($sum,$page,$this->limit); } else { - $state=$this->db->query("select keyword.keyword,count(*) from keyword left join normalmetadata m on keyword.id=m.id where keyword.keytype='place' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') group by keyword.keyword order by count desc"); - $k1=$state->fetchAll(); - $state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='theme' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') group by k.keyword order by k.keyword"); - $k2=$state->fetchAll(); - $state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='discipline' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') group by k.keyword order by k.keyword"); - $k3=$state->fetchAll(); - $state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='stratum' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') group by k.keyword order by k.keyword"); - $k4=$state->fetchAll(); - $state=$this->db->query("select keyword.keyword,count(*) from keyword left join normalmetadata m on keyword.id=m.id where keyword.keytype='temporal' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') group by keyword.keyword order by keyword.keyword"); - $k5=$state->fetchAll(); - $this->view->keywords=array('place'=>$k1,'theme'=>$k2,'discipline'=>$k3,'stratum'=>$k4,'temporal'=>$k5); + $sql="select k.keyword,count(*),k.keytype from keyword k left join normalmetadata m on k.id=m.id where length(k.keyword)>0 and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') "; + if (!empty($keytype) && ($keytype=='place' || $keytype=='theme' || $keytype=='discipline'||$keytype=='temporal')) $sql.=" and k.keytype='".$keytype."'"; + $sql.=' group by k.keyword,k.keytype order by k.keytype,k.keyword,count desc'; + $state=$this->db->query($sql); + $this->view->keytype=$keytype; + $this->view->keywords=$state->fetchAll(); } } @@ -376,14 +333,58 @@ class GlacierController extends DataController private function getmd($keyword,$type='theme') { - $page=(int)$this->_request->getParam('page'); - if (empty($page)) $page=1; - $offset=$this->limit*($page-1); - $state=$this->db->query("select count(m.*) from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='glacier' and m.id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."')"); + $page=(int)$this->_request->getParam('page'); + if (empty($page)) $page=1; + $offset=$this->limit*($page-1); + if (!is_array($keyword)) + { + $keyword=array($keyword); + } + $key="("; + foreach($keyword as $k) + { + $key.="'".$k."',"; + } + $key=substr($key,0,-1); + $key.=")"; + $keyword=$key; + + $state=$this->db->query("select count(m.*) from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='glacier' and m.id in (select id from keyword where keytype='".$type."' and keyword in ".$keyword.")"); $row=$state->fetchAll(); $sum=$row[0]['count']; //@todo: add order with title - $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."') order by timebegin,title limit ? offset ?"; + $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='".$type."' and keyword in ".$keyword.") order by timebegin,title limit ? offset ?"; + $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); + $this->view->page=new Pagination($sum,$page,$this->limit); + $this->view->offset=$offset+1; + } + + //获取多项条件并列关系的数据并必须满足limited条件 + //$keyword:字符串或字符串数组 + //$limited:限制字符串 + private function getmdlimited($keyword,$limited) + { + $page=(int)$this->_request->getParam('page'); + if (empty($page)) $page=1; + $offset=$this->limit*($page-1); + if (!is_array($keyword)) + { + $keyword=array($keyword); + } + $key="("; + foreach($keyword as $k) + { + $key.="'".$k."',"; + } + $key=substr($key,0,-1); + $key.=")"; + $keyword=$key; + + $state=$this->db->query("select count(m.*) from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='glacier' and m.id in (select id from keyword where keyword='".$limited."') and m.id in (select id from keyword where keyword in ".$keyword.")"); + $row=$state->fetchAll(); + $sum=$row[0]['count']; + //@todo: add order with title + $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keyword='".$limited."') and id in (select id from keyword where keyword in ".$keyword.") order by title limit ? offset ?"; $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); $this->view->page=new Pagination($sum,$page,$this->limit); $this->view->offset=$offset+1; diff --git a/application/default/views/scripts/glacier/base.phtml b/application/default/views/scripts/glacier/base.phtml new file mode 100644 index 00000000..23caa2c3 --- /dev/null +++ b/application/default/views/scripts/glacier/base.phtml @@ -0,0 +1,30 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->data); +$this->headTitle()->setSeparator(' - '); +$this->headLink()->appendStylesheet('/css/water.css'); +$this->nav[] = array('link'=>"/glacier",'title'=>$this->config->title->glacier); +?> +render('breadcrumbs.phtml'); ?> +
      +
      + partial('glacier/navi.phtml'); ?> +
      +
      + info) : ?> +
      + info['body'])) echo $this->info['body'];?> +
      + + metadata) : ?> + page->getNavigation(); ?> +
      +
        + metadata as $md) : ?> +
      1. + +
      +
      + +
      +
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/browse.phtml b/application/default/views/scripts/glacier/browse.phtml index 1825019c..3d2cb3b8 100755 --- a/application/default/views/scripts/glacier/browse.phtml +++ b/application/default/views/scripts/glacier/browse.phtml @@ -11,10 +11,10 @@ $this->breadcrumb('浏览'); $this->breadcrumb()->setSeparator(' > '); ?>
      -
      +
      partial('glacier/navi.phtml'); ?>
      -
      +
      page->getNavigation(); ?>
      diff --git a/application/default/views/scripts/glacier/category.phtml b/application/default/views/scripts/glacier/category.phtml deleted file mode 100755 index e30bde12..00000000 --- a/application/default/views/scripts/glacier/category.phtml +++ /dev/null @@ -1,43 +0,0 @@ -headTitle($this->config->title->site); - $this->headTitle($this->config->title->data); -$this->headTitle('分类浏览'); -if (!empty($this->codename)) $this->headTitle($this->codename); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('分类浏览:'.$this->codename); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      - - - metadata)) : ?> -
      - page->getNavigation(); ?> -
      -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      -
      - page->getNavigation(); ?> -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/everestnorth.phtml b/application/default/views/scripts/glacier/everestnorth.phtml deleted file mode 100644 index 1d531234..00000000 --- a/application/default/views/scripts/glacier/everestnorth.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('珠穆朗玛峰北坡'); -$this->breadcrumb()->setSeparator(' > '); -?> - - - diff --git a/application/default/views/scripts/glacier/field.phtml b/application/default/views/scripts/glacier/field.phtml deleted file mode 100644 index 1f18f4de..00000000 --- a/application/default/views/scripts/glacier/field.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('冰湖编目数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      为了对冰川编目结果进行验证并获得更多的冰川环境信息,项目开展了大量的野外考察。考察范围包括:祁连山、昆仑山-唐古拉山、喜马拉雅山、青藏高原腹地冰川考察、黄河源-念青唐古拉山中段北坡-喜马拉雅山中段。考察内容包括GPS测量、冰川厚度测量、冰川区地形摄影测量、冰川物质平衡测量、冰川区气象水文要素测量、冰湖水位和温度测量等。

      - -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/frozensoil.phtml b/application/default/views/scripts/glacier/frozensoil.phtml deleted file mode 100644 index 8a984fea..00000000 --- a/application/default/views/scripts/glacier/frozensoil.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('冻土数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      与多年冻土相关的测量数据,包括探地雷达测量的地下冰厚度、冻土层上限等。 -

      -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/geobase.phtml b/application/default/views/scripts/glacier/geobase.phtml deleted file mode 100644 index 72369e3f..00000000 --- a/application/default/views/scripts/glacier/geobase.phtml +++ /dev/null @@ -1,34 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('基础数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      基础数据是指用于开展冰川和冰湖编目的遥感影像、地形图和数字地形模型,由于地形图属国家保密数据,不在共享范围内。

      -

      地形图主要用来地第一次冰川编目数据进行校正,并辅助第二次冰川编目中冰川边界和山脊线的判断。冰川编目中使用和参考的地形图约1105幅,其中1:50,000地形图546幅(航摄制图512幅,陆地摄影测量成果15幅,平板仪测绘及其他地图19幅),1:100,000地形图572幅(航摄制图558幅,平板仪测绘及其他地图14幅),另外还参考了1975年左右的MSS遥感数据地形图7幅。

      - -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/glacier.phtml b/application/default/views/scripts/glacier/glacier.phtml deleted file mode 100644 index b4c70c2c..00000000 --- a/application/default/views/scripts/glacier/glacier.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('冰川编目数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      冰川编目数据:基于遥感影像解译获得的反应我国2005年前后冰川现状的冰川分布图及其基本属性。除了包括中国全境的冰川编目数据外,还包括祁连山、天山、贡嘎山、纳木错流域、长江源区、年楚河流域和珠穆朗玛峰北坡等典型地区的多年代冰川分布数据。 -

      -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/gongga.phtml b/application/default/views/scripts/glacier/gongga.phtml deleted file mode 100644 index 91f1585c..00000000 --- a/application/default/views/scripts/glacier/gongga.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('贡嘎山'); -$this->breadcrumb()->setSeparator(' > '); -?> - - - diff --git a/application/default/views/scripts/glacier/gps.phtml b/application/default/views/scripts/glacier/gps.phtml deleted file mode 100644 index 9f86e3f2..00000000 --- a/application/default/views/scripts/glacier/gps.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('GPS测量数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      采用高精度GPS设备在冰川表面或周边地区测量获得的数据,可用来获得冰川高程信息,也可与以前的观测数据相比较获得冰川流动和物质平衡变化信息。

      - -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/hydro.phtml b/application/default/views/scripts/glacier/hydro.phtml deleted file mode 100644 index 8e50adcd..00000000 --- a/application/default/views/scripts/glacier/hydro.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('水文数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      在冰川下游观测获得的水文数据,观测要素包括径流、水质和水文化学等,也包括部分冰湖的观测数据。

      - -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/index.phtml b/application/default/views/scripts/glacier/index.phtml index 0592ae59..f6fe0be2 100755 --- a/application/default/views/scripts/glacier/index.phtml +++ b/application/default/views/scripts/glacier/index.phtml @@ -3,73 +3,20 @@ $this->headTitle($this->config->title->site); $this->headTitle($this->config->title->data); $this->headTitle()->setSeparator(' - '); $this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb($this->config->title->glacier); -$this->breadcrumb()->setSeparator(' > '); +$this->nav[] = array('link'=>"/glacier",'title'=>$this->config->title->glacier); ?> +render('breadcrumbs.phtml'); ?>
      -
      - partial('glacier/navi.phtml'); ?> +
      + partial('glacier/navi.phtml'); ?>
      -
      + +
      -

      “中国冰川资源及其变化调查”项目简介

      -

      - 冰川是最敏感、最直接、最易于辩识、长纪录、高分辨的气候变化信息指示器和储存体,冰川变化信息是全球变化中的重要基础性资源。我国是中、低纬度山 地冰川面积最多的国家(占52%),是两极冰盖之外最重要的冰川集结地,冰川变化信息的挖掘、调查、监测、编目是十分重要的基础性工作。 -

      -

      - 始于1978年的第一次冰川编目历时24年,查清了截止到第一次全国航空测量时(西部冰川区约为1960s-1980s)中国冰川资源的基本情况。第一次冰川清查工作在国际和国内产生了重大影响,被国际冰川学会主席誉为建立了一座“冰川和气候变化研究的金矿”。 - 本次冰川资源调查是在中国科技部和中国科学院的联合支持下开展的一次大规模冰川普查,其目标以第一次冰川编目为参考,以2005-2006年为现状 年,以高分辨率遥感数据与地理信息系统技术为基础,深入研究基于遥感的冰川制图方法,结合冰川野外考察考察,获取我国冰川的分布状况,对有观测历史的典型 冰川进行重点监测;并与第一次冰川编目数据进行比较,查明我国冰川资源变化情况;同时,以此调查数据为基础,综合定位监测与相关资料,评估冰川变化对水资 源的影响,为西部水资源开发利用提供决策依据 。 -

      -

      《中国冰川资源及其变化调查》主要研究内容

      -
        -
      1. 第一次冰川编目的数字化:重点开展第一次冰川编目时期冰川及冰湖分布的数字化,为冰川遥感监测提供基础数据。
      2. -
      3. 现状年(2005-2006年)西北干旱区和其它典型区冰川(湖)分布遥感调查:重点开展现状年基于高分辨率遥感影像的冰川与冰湖分布调查,同时,开展研究区部分冰川表面高程和运动速度信息的提取。
      4. -
      5. 遥感冰川制图地面验证、典型冰川厚度测量与冰川变化野外调查:重点开展代表性区域野外调查和典型冰川定位观测,验证遥感解译结果,获取典型监测冰川过程观测数据;开展代表性冰川厚度的雷达测量。
      6. -
      7. 冰川变化对水资源的影响评估:以现有定位观测冰川和区域冰川变化遥感调查数据为基础,评估西北干旱区和其它典型区冰川变化特征及其对水资源的影响。
      8. -
      9. 冰川资源及其变化调查信息共享平台建设:建立冰川资源管理及共享信息系统,为资源共享服务。
      10. -
      -

      《西部冰川变化监测及其影响评估方法研究》主要研究内容

      -
        -
      1. 各类冰川参数的遥感提取方法研究:针对西部三类冰川特点,综合运用现有卫星遥感数据,建立冰川几何尺寸、特征要素、物理特征、表面高程等信息的提取算法,为大范围冰川调查提供适合各类冰川下垫面状况和气候条件的参数提取方法集,提高遥感获取冰川信息的自动化程度。
      2. -
      3. 冰川储量估算与冰川参数遥感提取精度评估:研制或改进冰川厚度测量雷达,对不同类型典型冰川流域不同规模的代表性冰川进行冰川厚度测量,建立适 合不同规模冰川的储量计算公式;开展各典型监测冰川区遥感冰川制图的野外验证、控制点采集与冰川变化的调查,进行遥感提取参数的误差分析与方法验证研究。
      4. -
      5. 流域冰川融水径流估算方法研究:以典型监测冰川长期观测资料为基础,并进行加强观测,同时收集流域出山口径流长期水文气象观测数据,建立适合不同资料条件的简单和复杂冰川融水径流模型,在对比分析基础上,提出适合西部流域尺度的冰川融水径流计算方案。
      6. -
      7. 冰川变化对水资源影响的评估方法及其应用研究:分析典型冰川流域冰川变化的空间特征及其差异;以典型冰川融水径流过程和流域尺度冰川动力响应研 究为基础,研究不同融水径流计算方案、基于冰川动力响应和基于冰川几何尺度转换关系模型对于不同性质冰川流域融水径流年际变化的模拟能力;根据流域融水径 流模型集,剖析冰川变化对冰川径流临界转变的影响及其强度。
      8. -
      +

      info['title'])) echo $this->info['title']; ?>

      +
      + +
      info['body'])) echo $this->info['body'];?>
      -
      - \ No newline at end of file diff --git a/application/default/views/scripts/glacier/inventory.phtml b/application/default/views/scripts/glacier/inventory.phtml deleted file mode 100644 index 96ad5eeb..00000000 --- a/application/default/views/scripts/glacier/inventory.phtml +++ /dev/null @@ -1,35 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('冰川冰湖编目数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      冰川编目数据:基于遥感影像解译获得的反应我国2005年前后冰川现状的冰川分布图及其基本属性。除了包括中国全境的冰川编目数据外,还包括祁连山、天山、贡嘎山、纳木错流域、长江源区、年楚河流域和珠穆朗玛峰北坡等典型地区的多年代冰川分布数据。 -

      -

      冰湖编目数据: - 冰湖是指在冰川前端、表面或内部形成的湖泊。冰湖编目是指利用地形图和遥感数据等资料对位于冰川前端和表面的湖泊进行登记的调查行为。

      -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/lake.phtml b/application/default/views/scripts/glacier/lake.phtml deleted file mode 100644 index 20156b61..00000000 --- a/application/default/views/scripts/glacier/lake.phtml +++ /dev/null @@ -1,34 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('冰湖编目数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      冰湖编目数据: - 冰湖是指在冰川前端、表面或内部形成的湖泊。冰湖编目是指利用地形图和遥感数据等资料对位于冰川前端和表面的湖泊进行登记的调查行为。

      - -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/lidar.phtml b/application/default/views/scripts/glacier/lidar.phtml deleted file mode 100644 index 4086d158..00000000 --- a/application/default/views/scripts/glacier/lidar.phtml +++ /dev/null @@ -1,35 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('雷达测厚数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      - 利用冰川测厚雷达获得的反应冰川厚度和冰下地形的野外测量数据,可为冰川厚度分布图和冰下地形图等提供重要的基础资料。同时,利用这些测量资料可以估算冰川的冰储量,为冰川变化响应气候变化提供定量科学依据,而且可以为各种水文模型提供重要的冰下地形参数。 -

      - -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/material.phtml b/application/default/views/scripts/glacier/material.phtml deleted file mode 100644 index 8b116cc2..00000000 --- a/application/default/views/scripts/glacier/material.phtml +++ /dev/null @@ -1,35 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('物质平衡观测数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      - 冰川在一定时间内的物质变化即积累与消融之差。积累大于消融为正平衡,消融大于积累为负平衡。冰川物质平衡野外观测一般包括利用雪坑剖面观测冰川积累量和花杆观测冰川消融量。 -

      - -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/meteo.phtml b/application/default/views/scripts/glacier/meteo.phtml deleted file mode 100644 index 9ff309a7..00000000 --- a/application/default/views/scripts/glacier/meteo.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('气象数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      在冰川区观测的气象数据,观测要素包括温度、风速、风向、降水等。受观测条件的限制,观测要素和观测时段不能保持完全一致。

      - -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/movement.phtml b/application/default/views/scripts/glacier/movement.phtml deleted file mode 100644 index 4425b6bf..00000000 --- a/application/default/views/scripts/glacier/movement.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('冰川运动数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      冰川运动观测一般分为冰川表面运动观测和冰川内部运动观测。前者一般采用GPS和花杆等测量方法,后者一般采用挖坑法、冰隧道法和钻孔法。 -

      -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/namco.phtml b/application/default/views/scripts/glacier/namco.phtml deleted file mode 100644 index b9c72707..00000000 --- a/application/default/views/scripts/glacier/namco.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('纳木错流域'); -$this->breadcrumb()->setSeparator(' > '); -?> - - - diff --git a/application/default/views/scripts/glacier/navi.phtml b/application/default/views/scripts/glacier/navi.phtml index d0a577ee..24d80aeb 100644 --- a/application/default/views/scripts/glacier/navi.phtml +++ b/application/default/views/scripts/glacier/navi.phtml @@ -70,13 +70,6 @@
      -
      - - + \ No newline at end of file diff --git a/application/default/views/scripts/glacier/tianshan.phtml b/application/default/views/scripts/glacier/tianshan.phtml deleted file mode 100644 index 51b4b6f6..00000000 --- a/application/default/views/scripts/glacier/tianshan.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('天山'); -$this->breadcrumb()->setSeparator(' > '); -?> - - - diff --git a/application/default/views/scripts/glacier/timeline.phtml b/application/default/views/scripts/glacier/timeline.phtml index aca2c805..89c7b4e8 100755 --- a/application/default/views/scripts/glacier/timeline.phtml +++ b/application/default/views/scripts/glacier/timeline.phtml @@ -12,12 +12,14 @@ $this->breadcrumb()->setSeparator(' > '); $this->headScript()->appendFile('/js/timeline_var.js'); $this->headScript()->appendFile('/js/timeline_js/timeline-api.js'); $this->headScript()->appendFile('/js/glaciertime.js'); +$this->nav[] = array('link'=>"/glacier/",'title'=>$this->config->title->glacier); +$this->nav[] = array('link'=>"/glacier/timeline",'title'=>'时间轴导航'); ?>
      -
      +
      partial('glacier/navi.phtml'); ?>
      -
      +
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/timemap.phtml b/application/default/views/scripts/glacier/timemap.phtml index 77c6ff2c..71a0e216 100644 --- a/application/default/views/scripts/glacier/timemap.phtml +++ b/application/default/views/scripts/glacier/timemap.phtml @@ -14,16 +14,18 @@ $this->theme->AppendPlus($this,'colorbox'); $this->headScript()->appendFile('/js/timeline_var.js'); $this->headScript()->appendFile('/js/timeline_js/timeline-api.js'); $this->headScript()->appendFile('/js/timemap.2.0.1/lib/mxn/mxn.js?(googlev3)'); -$this->headScript()->appendFile('/js/timemap.2.0.1/timemap.pack.js'); +$this->headScript()->appendFile('/js/timemap.2.0.1/timemap.pack.js'); +$this->nav[] = array('link'=>"/glacier/",'title'=>$this->config->title->glacier); +$this->nav[] = array('link'=>"/glaicer/timemap",'title'=>'时空导航'); ?>
      -
      +
      partial('glacier/navi.phtml'); ?>
      -
      +
      breadcrumb() ?>
      diff --git a/application/default/views/scripts/glacier/vegetation.phtml b/application/default/views/scripts/glacier/vegetation.phtml deleted file mode 100644 index 3f2258e0..00000000 --- a/application/default/views/scripts/glacier/vegetation.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('植被数据'); -$this->breadcrumb()->setSeparator(' > '); -?> -
      -
      - partial('glacier/navi.phtml'); ?> -
      -
      -
      -

      冰川区附近的植被分布情况调查 -

      -
      -
      - metadata) : ?> - page->getNavigation(); ?> -
      -
        - metadata as $md) : ?> -
      1. - -
      -
      - -
      -
      \ No newline at end of file diff --git a/application/default/views/scripts/glacier/yangtze.phtml b/application/default/views/scripts/glacier/yangtze.phtml deleted file mode 100644 index ffdd5286..00000000 --- a/application/default/views/scripts/glacier/yangtze.phtml +++ /dev/null @@ -1,33 +0,0 @@ -headTitle($this->config->title->site); -$this->headTitle($this->config->title->data); -$this->headTitle()->setSeparator(' - '); -$this->headLink()->appendStylesheet('/css/water.css'); -$this->breadcrumb('首页'); -$this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->glacier.''); -$this->breadcrumb('长江源区'); -$this->breadcrumb()->setSeparator(' > '); -?> - - - From 9818347102b3c44685c9bfdba57979fb5caf01dd Mon Sep 17 00:00:00 2001 From: wlx Date: Wed, 22 Jan 2014 02:55:07 +0000 Subject: [PATCH 113/126] update glacier theme --- .../views/scripts/glacier/search.phtml | 2 +- .../default/views/scripts/glacier/view.phtml | 187 ++++++++++++------ 2 files changed, 126 insertions(+), 63 deletions(-) diff --git a/application/default/views/scripts/glacier/search.phtml b/application/default/views/scripts/glacier/search.phtml index cafc0c2d..5c16a193 100644 --- a/application/default/views/scripts/glacier/search.phtml +++ b/application/default/views/scripts/glacier/search.phtml @@ -14,12 +14,12 @@ $this->breadcrumb()->setSeparator(' > '); $this->nav[] = array('link'=>"/glacier/",'title'=>$this->config->title->glacier); $this->nav[] = array('link'=>"",'title'=>'快速搜索'); ?> +render('breadcrumbs.phtml'); ?>
      partial('glacier/navi.phtml',array('key'=>$this->key)); ?>
      -
      breadcrumb() ?>
      metadata)) : ?> page->getNavigation(); ?>
      diff --git a/application/default/views/scripts/glacier/view.phtml b/application/default/views/scripts/glacier/view.phtml index fc17c688..bb49bc56 100755 --- a/application/default/views/scripts/glacier/view.phtml +++ b/application/default/views/scripts/glacier/view.phtml @@ -4,32 +4,34 @@ $this->headTitle($this->metadata->title); $this->headTitle()->setSeparator(' - '); $this->headLink()->appendStylesheet('/css/water.css'); - $this->breadcrumb('首页'); - $this->breadcrumb(''.$this->config->title->data.''); - $this->breadcrumb(''.$this->config->title->glacier.''); - $this->breadcrumb('查看元数据'); - $this->breadcrumb()->setSeparator(' > '); - $this->headLink()->appendStylesheet('/css/water.css'); $this->theme->AppendPlus($this,'google_map_v3'); $this->theme->AppendPlus($this,'colorbox'); -?> + if(!empty($this->dataService)) { + $this->theme->AppendModel($this,"dataservice"); + } + $this->nav[] = array('link'=>"/glacier/",'title'=>$this->config->title->glacier); + $this->nav[] = array('link'=>"",'title'=>'查看元数据'); +?> +render('breadcrumbs.phtml'); ?> metadata;if ($md):?>
      -
      +
      partial('glacier/navi.phtml'); ?> -
      -
      -
      breadcrumb() ?>
      +
      +

      escape($md->title); if ($md->title_en) echo '
      '.$this->escape($md->title_en);?>


      - -
      -
      + +
      +

      @@ -37,21 +39,11 @@ if ($md->title_en) echo '
      '.$this->escape($md->title_en);?>

      - citation) : ?> -
      -

      本数据引用方式数据引用帮助

      -

      datadoi) || !strpos($md->citation,$md->datadoi)) : ?>文章的引用 - escape($md->citation);?>

      - datadoi) && !strpos($md->citation,$md->datadoi)) : ?> -

      数据的引用authors,1,-1).'. '.$md->title.'. '.$md->publisher.', '.$md->publish_year.'. doi:'.$md->doi; - echo ' ['.substr($md->author_en,1,-1).'. '.$md->title_en.'. '.$md->publisher_en.', '.$md->publish_year.'. doi:'.$md->doi.']'; - ?> (下载引用:RIS格式 | RIS英文格式 | Bibtex格式 | Bibtex英文格式)

      - ref) : ?> + mcitation) : ?>
      -

      建议参考文献

      +

      本数据要求的多篇文献引用

        - ref as $ref) : + mcitation as $ref) : if (empty($ref->link)) echo '
      1. '.$ref->reference.'
      2. '; else @@ -59,17 +51,78 @@ if ($md->title_en) echo '
        '.$this->escape($md->title_en);?> endforeach; ?>
      - - userref) : ?> + + + citation) : ?>
      -

      数据用户发表文献

      +

      本数据引用方式数据引用帮助

      +

      datadoi) || !strpos($md->citation,$md->datadoi)) : ?>文章的引用 + escape($md->citation);if (strpos($md->citation,$md->datadoi)) : ?> + (下载引用:RIS格式 | RIS英文格式 | Bibtex格式 | Bibtex英文格式) + +

      + datadoi) && !strpos($md->citation,$md->datadoi)) : ?> +

      数据的引用authors,1,-1).'. '.$md->title.'. '.$md->publisher.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi; + echo ' ['.str_replace('"','',substr($md->author_en,1,-1)).'. '.$md->title_en.'. '.$md->publisher_en.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi.']'; + ?> (下载引用:RIS格式 | RIS英文格式 | Bibtex格式 | Bibtex英文格式)

      + ref) : ?> +
      +

      相关文献(作者推荐)

      +
        + ref as $ref) : + echo '
      1. '.$ref->reference; + echo '查看'; + if (empty($ref->link)) + { + if(!empty($ref->attid)) + echo '下载'; + }else{ + echo '下载'; + } + echo "
      2. "; + endforeach; + ?> +
      + themeref) :?> + +
      +

      专题文献

      +
        + themeref as $ref) : + echo '
      1. '.$ref->reference; + echo '查看'; + if (empty($ref->link)) + { + if(!empty($ref->attid)) + echo ' | 下载'; + }else{ + echo ' | 下载'; + } + echo "
      2. "; + endforeach; + ?> +
      + userref) : ?> +
      +

      数据施引文献

        userref as $ref) : + echo '
      1. '.$ref->reference; + echo '查看'; if (empty($ref->link)) - echo '
      2. '.$ref->reference.'
      3. '; - else - echo '
      4. '.$ref->reference.' 下载
      5. '; + { + if(!empty($ref->attid)) + echo '下载'; + }else{ + echo '下载'; + } + echo ""; endforeach; + if (count($this->userref)==15) + { + echo '更多施引文献'; + } ?>
      @@ -83,8 +136,8 @@ if ($md->title_en) echo '
      '.$this->escape($md->title_en);?> ?>

      为尊重知识产权、保障数据作者的权益、扩展数据中心的服务、评估数据的应用潜力,请数据使用者在使用数据所产生的研究成果中(包括公开发表的论文、论著、数据产品和未公开发表的研究报告、数据产品等成果),明确注明数据来源和数据作者。对于转载(二次或多次发布)的数据,作者还须注明原始数据来源。

      -

      中文发表的成果参考以下规范注明: 数据来源于国家自然科学基金委员会"中国西部环境与生态科学数据中心"(http://westdc.westgis.ac.cn)

      -

      英文发表的成果依据以下规范注明: The data set is provided by Environmental and Ecological Science Data Center for West China,National Natural Science Foundation of China (http://westdc.westgis.ac.cn)

      +

      中文发表的成果参考以下规范注明: 数据来源于黑河计划数据管理中心、寒区旱区科学数据中心(http://westdc.westgis.ac.cn)

      +

      英文发表的成果依据以下规范注明: The data set is provided by Cold and Arid Regions Sciences Data Center at Lanzhou (http://westdc.westgis.ac.cn)

      data_archives){ ?> @@ -97,18 +150,18 @@ if ($md->title_en) echo '
      '.$this->escape($md->title_en);?>
      - suppinfo || $this->fund) : ?> -

      资助项目

      - fund)) : ?> -
        - fund as $k=>$v) : ?> -
      • (项目编号:) [(No. )]
      • - -
      - suppinfo)) : ?> - '.str_replace(array("\r\n", "\n", "\r"),'

      ',$this->escape($md->suppinfo)).'

      ';?> - -
      + suppinfo || $this->fund) : ?> +

      资助项目

      + fund)) : ?> +
        + fund as $k=>$v) : ?> +
      • (项目编号:) [(No. )]
      • + +
      + suppinfo)) : ?> + '.str_replace(array("\r\n", "\n", "\r"),'

      ',$this->escape($md->suppinfo)).'

      ';?> + +
      resources) : ?>

      相关资源

      @@ -251,7 +304,7 @@ if ($md->title_en) echo '
      '.$this->escape($md->title_en);?>
      -
      +
      @@ -412,7 +476,7 @@ endforeach;
      -
      +
      @@ -444,6 +508,9 @@ $(function() { googleSearch(''); } }); + $('#show-list').click(function(e) { + method.filelist.get($(this).attr('rel')); + }); }); //ajax literature function literature(page){ @@ -460,10 +527,6 @@ function recommend(page){ recommend_get(page,'uuid; ?>'); } -function getFileList(){ - getFileList_h('uuid;?>'); -} - function ajaxpage(page){ ajaxpage_get(page,'uuid; ?>'); } From 622a0331a5684319e1018ab2b3f7aad223889a7f Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Mon, 27 Jan 2014 08:29:18 +0000 Subject: [PATCH 114/126] fixed a bug about upload folder path --- application/module/Files/Files.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/module/Files/Files.php b/application/module/Files/Files.php index f017d4a5..9ec49a2f 100644 --- a/application/module/Files/Files.php +++ b/application/module/Files/Files.php @@ -151,7 +151,7 @@ class Files{ $msg['file_url'] = $file_url; $msg['file_size'] = $file_size; - $msg['db_path'] = $this->config->upload . $dbsave; + $msg['db_path'] = $dbsave; $msg['realname'] = $file_name; $msg['file_ext'] = $file_ext; $msg['file_mime'] = $this->getFileMime($file_path); From fbd1876e15521f4d1717c2ff7635d372c1d37c25 Mon Sep 17 00:00:00 2001 From: wlx Date: Wed, 29 Jan 2014 04:39:36 +0000 Subject: [PATCH 115/126] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E6=9B=B4?= =?UTF-8?q?=E7=B2=BE=E5=87=86=E6=8F=90=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controllers/DownController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/controllers/DownController.php b/application/admin/controllers/DownController.php index 4fd47712..a371ca04 100644 --- a/application/admin/controllers/DownController.php +++ b/application/admin/controllers/DownController.php @@ -1375,7 +1375,7 @@ class Admin_DownController extends Zend_Controller_Action $sql = "select distinct u.email from dataorder d LEFT JOIN users u on d.userid = u.id - WHERE u.email IS NOT NULL + WHERE u.email IS NOT NULL and d.status in (0,5) and d.ts_approved is not null AND d.uuid=? GROUP BY u.email"; From 5f2f07207a65d9b871c33044208ba43085d150e3 Mon Sep 17 00:00:00 2001 From: wlx Date: Mon, 17 Feb 2014 03:24:32 +0000 Subject: [PATCH 116/126] change url --- .../default/views/scripts/hiwater/list.phtml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/application/default/views/scripts/hiwater/list.phtml b/application/default/views/scripts/hiwater/list.phtml index f2e67d7b..8f25ebdb 100644 --- a/application/default/views/scripts/hiwater/list.phtml +++ b/application/default/views/scripts/hiwater/list.phtml @@ -5,16 +5,16 @@ $this->headTitle()->setSeparator(' - '); $this->headLink()->appendStylesheet('/css/water.css'); $this->breadcrumb('首页'); $this->breadcrumb(''.$this->config->title->data.''); -$this->breadcrumb(''.$this->config->title->heihe.''); +$this->breadcrumb(''.$this->config->title->hiwater.''); $this->breadcrumb('数据列表'); $this->breadcrumb()->setSeparator(' > '); $this->theme->AppendPlus($this,'colorbox'); ?>
      -
      +
      partial('hiwater/navi.phtml'); ?>
      -
      +
      breadcrumb() ?>
      metadata) : ?> @@ -22,12 +22,12 @@ $this->theme->AppendPlus($this,'colorbox');
        metadata as $md) : ?>
      1. - + [缩略图幻灯片] - [PDF版本下载] - [ODT版本下载] - [DOC版本下载] + [PDF版本下载] + [ODT版本下载] + [DOC版本下载]
      2. From 6c3f3bf0c3d232574dc19ebcae29dc580d8c7c77 Mon Sep 17 00:00:00 2001 From: wlx Date: Fri, 21 Feb 2014 08:47:39 +0000 Subject: [PATCH 117/126] =?UTF-8?q?=E8=B5=84=E5=8A=A9=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=BB=A5=E7=BC=96=E5=8F=B7=E8=BF=9B=E8=A1=8C=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/default/controllers/HeiheController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/application/default/controllers/HeiheController.php b/application/default/controllers/HeiheController.php index 742b59c1..782b3fa6 100644 --- a/application/default/controllers/HeiheController.php +++ b/application/default/controllers/HeiheController.php @@ -1167,7 +1167,10 @@ class HeiheController extends DataController } } else { //提供全部分类列表 - $sql="select f.id,f.title,f.fund_id,f.fund_type,f.ts_created,count(m.id) as datacount,sum(md.filesize) as filesize from fund f left join mdfund m on f.id=m.fid left join metadata md on m.uuid=md.uuid left join heiheproject hp on f.fund_id=hp.code where hp.id is not null and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') group by f.id,f.title,f.fund_id,f.fund_type,f.ts_created order by f.ts_created desc"; + $sql="select f.id,f.title,f.fund_id,f.fund_type,f.ts_created,count(m.id) as datacount,sum(md.filesize) as filesize + from fund f left join mdfund m on f.id=m.fid left join metadata md on m.uuid=md.uuid left join heiheproject hp on f.fund_id=hp.code + where hp.id is not null and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') + group by f.id,f.title,f.fund_id,f.fund_type,f.ts_created order by f.fund_id asc"; $sth = $this->db->prepare($sql); $sth->execute(); $rows = $sth->fetchAll(); From d57090d5bc2f89d1ae4633e2dde150ebe33e4760 Mon Sep 17 00:00:00 2001 From: wlx Date: Fri, 21 Feb 2014 08:48:03 +0000 Subject: [PATCH 118/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=95=E9=83=A8?= =?UTF-8?q?=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/default/views/scripts/footer.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/default/views/scripts/footer.phtml b/application/default/views/scripts/footer.phtml index 9be61fdd..92fd1fcb 100755 --- a/application/default/views/scripts/footer.phtml +++ b/application/default/views/scripts/footer.phtml @@ -1,6 +1,6 @@
        pageID)) {?> From 334403081a832d3427221eb67c4ebb8d41855497 Mon Sep 17 00:00:00 2001 From: wlx Date: Fri, 21 Feb 2014 08:48:35 +0000 Subject: [PATCH 119/126] =?UTF-8?q?=E5=9C=A8=E5=85=83=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E4=B8=AD=E5=A2=9E=E5=8A=A0=E8=B5=84=E5=8A=A9?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/default/views/scripts/data/view.phtml | 2 +- application/default/views/scripts/glacier/view.phtml | 2 +- application/default/views/scripts/haihe/view.phtml | 2 +- application/default/views/scripts/heihe/view.phtml | 2 +- application/default/views/scripts/hiwater/view.phtml | 2 +- application/default/views/scripts/water/view.phtml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/application/default/views/scripts/data/view.phtml b/application/default/views/scripts/data/view.phtml index 8ae014c5..210e1f28 100755 --- a/application/default/views/scripts/data/view.phtml +++ b/application/default/views/scripts/data/view.phtml @@ -155,7 +155,7 @@ if ($md->title_en) echo '
        '.$this->escape($md->title_en);?> fund)) : ?>
          fund as $k=>$v) : ?> -
        • (项目编号:) [(No. )]
        • +
        • (项目编号:) [(No. )]
        suppinfo)) : ?> diff --git a/application/default/views/scripts/glacier/view.phtml b/application/default/views/scripts/glacier/view.phtml index bb49bc56..34d9053a 100755 --- a/application/default/views/scripts/glacier/view.phtml +++ b/application/default/views/scripts/glacier/view.phtml @@ -155,7 +155,7 @@ if ($md->title_en) echo '
        '.$this->escape($md->title_en);?> fund)) : ?>
          fund as $k=>$v) : ?> -
        • (项目编号:) [(No. )]
        • +
        • (项目编号:) [(No. )]
        suppinfo)) : ?> diff --git a/application/default/views/scripts/haihe/view.phtml b/application/default/views/scripts/haihe/view.phtml index 303632ab..3eff1e69 100755 --- a/application/default/views/scripts/haihe/view.phtml +++ b/application/default/views/scripts/haihe/view.phtml @@ -156,7 +156,7 @@ if ($md->title_en) echo '
        '.$this->escape($md->title_en);?> fund)) : ?>
          fund as $k=>$v) : ?> -
        • (项目编号:) [(No. )]
        • +
        • (项目编号:) [(No. )]
        suppinfo)) : ?> diff --git a/application/default/views/scripts/heihe/view.phtml b/application/default/views/scripts/heihe/view.phtml index f5a5b84a..d93ac569 100755 --- a/application/default/views/scripts/heihe/view.phtml +++ b/application/default/views/scripts/heihe/view.phtml @@ -158,7 +158,7 @@ if ($md->title_en) echo '
        '.$this->escape($md->title_en);?> fund)) : ?>
          fund as $k=>$v) : ?> -
        • (项目编号:) [(No. )]
        • +
        • (项目编号:) [(No. )]
        suppinfo)) : ?> diff --git a/application/default/views/scripts/hiwater/view.phtml b/application/default/views/scripts/hiwater/view.phtml index 1cf65878..ff449a18 100644 --- a/application/default/views/scripts/hiwater/view.phtml +++ b/application/default/views/scripts/hiwater/view.phtml @@ -163,7 +163,7 @@ if ($md->title_en) echo '
        '.$this->escape($md->title_en);?> fund)) : ?>
          fund as $k=>$v) : ?> -
        • (项目编号:) [(No. )]
        • +
        • (项目编号:) [(No. )]
        suppinfo)) : ?> diff --git a/application/default/views/scripts/water/view.phtml b/application/default/views/scripts/water/view.phtml index a548d2bb..e17dd3e4 100755 --- a/application/default/views/scripts/water/view.phtml +++ b/application/default/views/scripts/water/view.phtml @@ -137,7 +137,7 @@ h3.gs_rt{font-size:110%;} fund)) : ?>
          fund as $k=>$v) : ?> -
        • (项目编号:) [(No. )]
        • +
        • (项目编号:) [(No. )]
        suppinfo)) : ?> From f99e98f2c712d552fe571478c0460b5374fb440c Mon Sep 17 00:00:00 2001 From: wlx Date: Tue, 25 Feb 2014 04:11:54 +0000 Subject: [PATCH 120/126] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=82=B9=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/doc.xsl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/doc.xsl b/data/doc.xsl index 3414eabc..53882637 100644 --- a/data/doc.xsl +++ b/data/doc.xsl @@ -111,6 +111,10 @@
      3. 结束时间:
      +
        +
      1. 日期:
      2. +
        +
    • 本数据的引用

        From 70eb46f5417e208060bc8936121e3d3d1173255e Mon Sep 17 00:00:00 2001 From: wlx Date: Tue, 25 Feb 2014 04:12:57 +0000 Subject: [PATCH 121/126] =?UTF-8?q?=E4=BF=AE=E6=AD=A3docAction=E5=92=8Codt?= =?UTF-8?q?Action=E4=B8=AD=E6=95=B0=E6=8D=AE=E5=BC=95=E7=94=A8=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E7=9A=84=E9=80=BB=E8=BE=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/controllers/ServiceController.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/application/default/controllers/ServiceController.php b/application/default/controllers/ServiceController.php index a8301e89..1167a21d 100644 --- a/application/default/controllers/ServiceController.php +++ b/application/default/controllers/ServiceController.php @@ -314,11 +314,8 @@ class ServiceController extends Zend_Controller_Action $citation=$row['mcitation']; } else if ($row['citation']) { - if (empty($row['datadoi'])) - { - $citation=$row['citation']; - } - elseif (!strpos($row['citation'],$row['datadoi'])) + $citation=$row['citation']; + if (!empty($row['datadoi']) && !strpos($row['citation'],$row['datadoi'])) { $citation='
      1. 文章引用:'.$row['citation'].'
      2. '; $citation.="
      3. 数据的引用:"; @@ -722,11 +719,8 @@ class ServiceController extends Zend_Controller_Action $cit=$row['mcitation']; } else if ($row['citation']) { - if (empty($row['datadoi'])) - { - $cit=$row['citation']; - } - elseif (!strpos($row['citation'],$row['datadoi'])) + $cit=$row['citation']; + if (!empty($row['datadoi']) && !strpos($row['citation'],$row['datadoi'])) { $cit='文章引用:'.$row['citation']; $cit.="\r\n数据的引用:"; From a8f0424aa6058972b3a12ceb01e2f23675bf0e4d Mon Sep 17 00:00:00 2001 From: wlx Date: Thu, 27 Feb 2014 07:46:10 +0000 Subject: [PATCH 122/126] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=A7=94=E5=91=98=E4=BC=9A=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controllers/DownController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/admin/controllers/DownController.php b/application/admin/controllers/DownController.php index a371ca04..82f6f0fa 100644 --- a/application/admin/controllers/DownController.php +++ b/application/admin/controllers/DownController.php @@ -375,8 +375,8 @@ class Admin_DownController extends Zend_Controller_Action $mail->setSubject($mailtp->getSubject()); $addrs=array(); $addrs[] = 'nztong@lzb.ac.cn'; - $addrs[] = 'wjian@lzb.ac.cn'; - $addrs[] = 'lixin@lzb.ac.cn'; + $addrs[] = 'wangliangxu@lzb.ac.cn'; + $addrs[] = 'wulizong@lzb.ac.cn'; $mail->addTo($addrs); $mail->addCc($this->view->config->service->email,'西部数据中心服务组'); $mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf'); From 8a4a5c43866e179c92509ff60d6ba2cf7ebfa0c5 Mon Sep 17 00:00:00 2001 From: wlx Date: Thu, 27 Feb 2014 14:11:54 +0000 Subject: [PATCH 123/126] add DCI action --- .../default/controllers/ServiceController.php | 52 ++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/application/default/controllers/ServiceController.php b/application/default/controllers/ServiceController.php index 1167a21d..426c0ccb 100644 --- a/application/default/controllers/ServiceController.php +++ b/application/default/controllers/ServiceController.php @@ -1805,6 +1805,54 @@ class ServiceController extends Zend_Controller_Action public function jsonexit($data){ $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK)); return true; - } - + } + + public function dciAction() + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + //must have doi to output dci + $uuid=$this->_request->getParam('uuid'); + + $xml=' + + +
        + '.date("Y-m-d").' + Cold and Arid Regions Science Data Center at Lanzhou + CARD-WDS + '.$uuid.' +
        + + '; + + $sql="select title_en,doi,author_en,ts_published from datadoi where uuid=".$this->db->quote($uuid); + $row=$this->db->fetchRow($sql); + $authors=explode(',',str_replace('"','',substr($row['author_en'],1,-1))); + $i=0; + foreach($authors as $a) + { + $i=$i+1; + $xml.=''; + $xml.=''.$a.''; + } + $xml.=' + + + '.$row['title_en'].' + + + http://card.westgis.ac.cn/data/'.$uuid.' + CARD + '.date('Y',strtotime($row['ts_published'])).' + + + English + + +
        +
        '; + $this->getResponse()->setHeader('Content-Type', 'text/xml') + ->setBody($xml); + } } From 7a9d11a977c9c73e1c4d6f641f7506776d3ef993 Mon Sep 17 00:00:00 2001 From: wlx Date: Mon, 3 Mar 2014 13:34:19 +0000 Subject: [PATCH 124/126] add elements to dci --- .../default/controllers/ServiceController.php | 50 +++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/application/default/controllers/ServiceController.php b/application/default/controllers/ServiceController.php index 426c0ccb..eede4257 100644 --- a/application/default/controllers/ServiceController.php +++ b/application/default/controllers/ServiceController.php @@ -1826,7 +1826,8 @@ class ServiceController extends Zend_Controller_Action '; - $sql="select title_en,doi,author_en,ts_published from datadoi where uuid=".$this->db->quote($uuid); + $sql="select d.title_en,d.doi,author_en,d.ts_published,m.description,m.timebegin,m.timeend + from datadoi d left join en.normalmetadata m on d.uuid=m.uuid where d.uuid=".$this->db->quote($uuid); $row=$this->db->fetchRow($sql); $authors=explode(',',str_replace('"','',substr($row['author_en'],1,-1))); $i=0; @@ -1839,7 +1840,7 @@ class ServiceController extends Zend_Controller_Action $xml.=' - '.$row['title_en'].' + http://card.westgis.ac.cn/data/'.$uuid.' @@ -1849,7 +1850,50 @@ class ServiceController extends Zend_Controller_Action English - + '; + $xml.=''; + $xml.=''; + $sql="select k.keyword from en.keyword k left join en.normalmetadata m on k.id=m.id where k.keytype='theme' and m.uuid=".$this->db->quote($uuid); + $rowk=$this->db->fetchAll($sql); + $xml.=''; + foreach ($rowk as $k) + { + $xml.=''; + } + $xml.=' + '; + if ($row['timebegin']) + { + $xml.=' + '.date('Y-m-d',strtotime($row['timebegin'])).''; + if ($row['timeend'] && (date('Y-m-d',strtotime($row['timebegin']))!=date('Y-m-d',strtotime($row['timeend'])))) $xml.=' + '.$row['timeend'].''; + $xml.=''; + } + $xml.=''; + $sql="select f.* from fund f left join mdfund mf on f.id=mf.fid where mf.uuid=".$this->db->quote($uuid).' order by mf.place asc'; + $rowf=$this->db->fetchAll($sql); + $xml.=''; + foreach ($rowf as $f) + { + $xml.=' + + '.$f['fund_id'].''.$f['fund_type_en'].' + '; + } + $xml.=''; + $sql="select r.* from reference r left join mdref mr on r.id=mr.refid where mr.reftype=1 and r.language<>'zh' and mr.uuid=".$this->db->quote($uuid).' order by mr.place asc'; + $rowc=$this->db->fetchAll($sql); + $xml.=''; + foreach ($rowc as $c) + { + $xml.=' + '.$c['reference'].''; + if ($c['doi']) + $xml.=''.$c['doi'].''; + $xml.=''; + } + $xml.=' '; $this->getResponse()->setHeader('Content-Type', 'text/xml') From 6ffe628c27f98fdbd9474a763fd42201de262600 Mon Sep 17 00:00:00 2001 From: wlx Date: Mon, 3 Mar 2014 13:37:10 +0000 Subject: [PATCH 125/126] =?UTF-8?q?=E6=8F=90=E5=8D=87=E7=A8=B3=E5=AE=9A?= =?UTF-8?q?=E6=80=A7=E5=92=8C=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/wsndata.php | 270 ++++++++++++++++++++++++---------------------- 1 file changed, 143 insertions(+), 127 deletions(-) diff --git a/tools/wsndata.php b/tools/wsndata.php index bf74c503..44e093b5 100644 --- a/tools/wsndata.php +++ b/tools/wsndata.php @@ -1,5 +1,8 @@ 0)) { die("Error in parameter."); } - $action=@$_GET['action']; - + $action=@$_GET['action']; + if(!empty($action) && $action=='prepare') { $content="php -f /var/www/ftp2.westgis.ac.cn/wsndata.php $uid"; - $filename='wsndata.sh'; - if (!file_put_contents($filename, $content, LOCK_EX)) - { - sleep(1); - if (!file_put_contents($filename, $content, LOCK_EX)) - { - sleep(1); - if (!file_put_contents($filename, $content, LOCK_EX)) - die("error in write wsndatar.sh"); - } - } - } else { - $sql_user = "SELECT * from users_pm_down where starttime is not null and result=-1 and type='down' and uid=$uid"; - $sth_user = $db->query($sql_user); - $rows_user = $sth_user->fetchAll(); - - //有需要生成的数据 - if(!empty($rows_user)) - { - foreach($rows_user as $k=>$v ) - { + $filename='wsndata.sh'; + if (!file_put_contents($filename, $content, LOCK_EX)) + { + sleep(1); + if (!file_put_contents($filename, $content, LOCK_EX)) + { + sleep(1); + if (!file_put_contents($filename, $content, LOCK_EX)) + die("error in write wsndatar.sh"); + } + } + } else { + $sql_user = "SELECT distinct uid,site,variable,starttime,endtime from users_pm_down where starttime is not null and result=-1 and type='down' and uid=$uid"; + $sth_user = $db->query($sql_user); + $rows_user = $sth_user->fetchAll(); + + //有需要生成的数据 + if($rows_user) + { + foreach($rows_user as $k=>$v ) + { //逐个生成 $site = $v['site']; - $variable = $v['variable']; - $start = $v['starttime']; - $end = $v['endtime']; - $uid = $v['uid']; - //计算有多少天 - $days=round((strtotime($end)-strtotime($start))/3600/24)+1; - //获取观测点的名称 - $sql_site= "SELECT fld_name from tbl_site_info where fld_site_id=$site"; - $sth_site = $db->query($sql_site); - $rows_site = $sth_site->fetch(); - $sitename= $rows_site['fld_name']; - //获取用户的邮箱 - $sql_mail= "SELECT email from users where id=$uid"; - $sth_mail = $db->query($sql_mail); - $rows_mail = $sth_mail->fetch(); - if(empty($rows_mail)) - {$rows_mail['email']=="wuadan@lzb.ac.cn";} - //先为该用户创建一个文件夹 - $aimDir_user=$basepath.'wsn_'.$uid; + $variable = $v['variable']; + $start = date('Y-m-d',strtotime($v['starttime'])); + $end = date('Y-m-d',strtotime($v['endtime'])); + $uid = $v['uid']; + + //计算有多少天 + $days=round((strtotime($end)-strtotime($start))/3600/24)+1; + + //获取观测点的名称 + $sql_site= "SELECT fld_name from tbl_site_info where fld_site_id=$site"; + $sth_site = $db->query($sql_site); + $rows_site = $sth_site->fetch(); + $sitename= $rows_site['fld_name']; + + //先为该用户创建一个文件夹 + $aimDir_user=$basepath.'wsn_'.$uid; if (!file_exists($aimDir_user)) { $result = mkdir($aimDir_user); - } - //在该用户文件夹下面再建立一个观测点文件夹 - $aimDir_site=$aimDir_user.DIRECTORY_SEPARATOR.$site; + } + + //在该用户文件夹下面再建立一个观测点文件夹 + $aimDir_site=$aimDir_user.DIRECTORY_SEPARATOR.$sitename; if (!file_exists($aimDir_site)) { $result = mkdir($aimDir_site); - } - - //选择全部变量 - if($variable==-1) - { + } + + //选择全部变量 + if($variable==-1) + { //获取数据 - for ($i = 1; $i <= $days; $i++) + $sql2= "SELECT v.fld_time as time,v.fld_value as value,va.fld_name as variablename FROM tbl_value v left join tbl_variable_info va on v.fld_variable_id=va.fld_variable_id WHERE v.fld_site_id=$site AND v.fld_time>='$start' AND v.fld_time<'$endtime' ORDER BY time "; + $sth2 = $db->query($sql2); + $rows2 = $sth2->fetchAll(); + $endtime=date("Y-m-d",strtotime($start)+24*3600); + $head = "Time,Variable,Value, \n"; + $html=""; + foreach ($rows2 as $k=>$v) { - $endtime=date("Y-m-d 00:00:00",strtotime($start)+24*3600); - $sql2= "SELECT v.fld_time as time,v.fld_value as value,va.fld_name as variablename FROM tbl_value v left join tbl_variable_info va on v.fld_variable_id=va.fld_variable_id WHERE v.fld_site_id=$site AND v.fld_time>='$start' AND v.fld_time<'$endtime' ORDER BY time "; - - $sth2 = $db->query($sql2); - $rows2 = $sth2->fetchAll(); - $datamount=count( $rows2); //组装数据 - $html=""; - foreach($rows2 as $k=>$v) + if ($v['time']>=$start && $v['time']<$endtime) { - $time[$k] = $v['time']; - $value[$k] = $v['value']; - $var[$k] = $v['variablename']; - $html .=$time[$k].",".$var[$k].",".$value[$k]."\n"; - } - - $head = "Time,Variable,Value, \n"; - - //将数据写入文件 - $resulttime=date("Ymd",strtotime($start)); - - $fp = fopen($aimDir_site.DIRECTORY_SEPARATOR.$sitename."_all_".$resulttime.".CSV","a"); //打开csv文件,如果不存在则创建 - fwrite($fp,$head.$html); //写入数据 - fclose($fp); //关闭文件句柄 - - $start = $endtime; - } + $html.=$v['time'].",".$v['variablename'].",".$v['value']."\n"; + } elseif ($v['time']>=$endtime) { + //写入文件 + $resulttime=date("Ymd",strtotime($start)); + $fp = fopen($aimDir_site.DIRECTORY_SEPARATOR.$sitename."_all_".$resulttime.".CSV","w+"); + fwrite($fp,$head.$html); //写入数据 + fclose($fp); //关闭文件句柄 + $start=$endtime; + $endtime=date("Y-m-d",strtotime($start)+24*3600); + $html=$v['time'].",".$v['variablename'].",".$v['value']."\n"; + } + if ($k==count($rows2)) //last record + { + //写入文件 + $resulttime=date("Ymd",strtotime($start)); + $fp = fopen($aimDir_site.DIRECTORY_SEPARATOR.$sitename."_all_".$resulttime.".CSV","w+"); + fwrite($fp,$head.$html); //写入数据 + fclose($fp); //关闭文件句柄 + } + } + print $sitename."\r\n"; $sql_up= "update users_pm_down set result=0 WHERE site=$site and variable=-1 and uid=$uid and result=-1 and type='down'"; - $sth_up = $db->query($sql_up); - } else { - //获取观测变量的名称 + $db->query($sql_up); + } else { + //获取观测变量的名称 $sql3= "SELECT fld_name from tbl_variable_info where fld_variable_id=$variable"; $sth3 = $db->query($sql3); $rows3 = $sth3->fetch(); $varname=$rows3['fld_name']; //获取数据 - $endtime=""; - for ($i = 1; $i <= $days; $i++) + $endtime=date("Y-m-d",strtotime($start)+24*3600); + $sql2= "SELECT v.fld_time as time,v.fld_value as value,va.fld_name as variablename FROM tbl_value v left join tbl_variable_info va on v.fld_variable_id=va.fld_variable_id WHERE v.fld_variable_id=$variable and v.fld_site_id=$site AND v.fld_time>='$start' AND v.fld_time<='$end' ORDER BY time "; + $sth2 = $db->query($sql2); + $rows2 = $sth2->fetchAll(); + $head = "Time,Variable,Value, \n"; + $html=""; + foreach ($rows2 as $k=>$v) { - $endtime=date("Y-m-d H:m:s",strtotime($start)+24*3600); - $sql2= "SELECT v.fld_time as time,v.fld_value as value,va.fld_name as variablename FROM tbl_value v left join tbl_variable_info va on v.fld_variable_id=va.fld_variable_id WHERE v.fld_variable_id =$variable and v.fld_site_id=$site AND v.fld_time>='$start' AND v.fld_time<='$endtime' ORDER BY time "; - - $sth2 = $db->query($sql2); - $rows2 = $sth2->fetchAll(); - $datamount=count( $rows2); //组装数据 - $html=""; - foreach($rows2 as $k=>$v) + if ($v['time']>=$start && $v['time']<$endtime) { - $time[$k] = $v['time']; - $value[$k] = $v['value']; - $var[$k] = $v['variablename']; - $html .=$time[$k].",".$var[$k].",".$value[$k]."\n"; - } - - $head = "Time,Variable,Value, \n"; - //写入文件 - $resulttime=date("Ymd",strtotime($start)); - $fp = fopen($aimDir_site.DIRECTORY_SEPARATOR.$sitename."_".$varname."_".$resulttime.".CSV","a+"); - fwrite($fp,$head.$html); //写入数据 - fclose($fp); //关闭文件句柄 - $start = $endtime; + $html.=$v['time'].",".$v['variablename'].",".$v['value']."\n"; + } elseif ($v['time']>=$endtime) { + //写入文件 + $resulttime=date("Ymd",strtotime($start)); + $fp = fopen($aimDir_site.DIRECTORY_SEPARATOR.$sitename."_".$varname."_".$resulttime.".CSV","w+"); + fwrite($fp,$head.$html); //写入数据 + fclose($fp); //关闭文件句柄 + $start=$endtime; + $endtime=date("Y-m-d",strtotime($start)+24*3600); + $html=$v['time'].",".$v['variablename'].",".$v['value']."\n"; + } + if ($k==count($rows2)) //last record + { + //写入文件 + $resulttime=date("Ymd",strtotime($start)); + $fp = fopen($aimDir_site.DIRECTORY_SEPARATOR.$sitename."_".$varname."_".$resulttime.".CSV","w+"); + fwrite($fp,$head.$html); //写入数据 + fclose($fp); //关闭文件句柄 + } } + print $sitename.'--'.$varname."\r\n"; //给处理的数据做个标记result=0 - $sql_up= "update users_pm_down set result=0 WHERE site=$site and variable=$variable and uid=$uid and result=-1 and type='down'"; - $sth_up = $db->query($sql_up); - } - } - } - } \ No newline at end of file + $sql_up= "update users_pm_down set result=0 WHERE site=$site and variable=$variable and uid=$uid and result=-1 and type='down'"; + $db->query($sql_up); + } + + } + + } + + } From 3db63caac9a95e7a1f06bacd9de355b36b141f41 Mon Sep 17 00:00:00 2001 From: wlx Date: Tue, 4 Mar 2014 16:00:08 +0000 Subject: [PATCH 126/126] change var name --- tools/wsndata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/wsndata.php b/tools/wsndata.php index 44e093b5..032d2f56 100644 --- a/tools/wsndata.php +++ b/tools/wsndata.php @@ -107,7 +107,7 @@ ini_set('error_log','/tmp/wsn.log'); if($variable==-1) { //获取数据 - $sql2= "SELECT v.fld_time as time,v.fld_value as value,va.fld_name as variablename FROM tbl_value v left join tbl_variable_info va on v.fld_variable_id=va.fld_variable_id WHERE v.fld_site_id=$site AND v.fld_time>='$start' AND v.fld_time<'$endtime' ORDER BY time "; + $sql2= "SELECT v.fld_time as time,v.fld_value as value,va.fld_name as variablename FROM tbl_value v left join tbl_variable_info va on v.fld_variable_id=va.fld_variable_id WHERE v.fld_site_id=$site AND v.fld_time>='$start' AND v.fld_time<'$end' ORDER BY time "; $sth2 = $db->query($sql2); $rows2 = $sth2->fetchAll(); $endtime=date("Y-m-d",strtotime($start)+24*3600);