revert r4499

This commit is contained in:
wlx 2014-05-27 08:11:33 +00:00
parent 192f2a6ddf
commit 5525ac67e5
38 changed files with 658 additions and 2503 deletions

View File

@ -1,135 +1,210 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
return array(
'router' => array(
'routes' => array(
//home
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
//'type' => 'Segment',
'options' => array(
'route' => '/',
'defaults' => array(
'module' => 'Application',
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
'may_terminate' => true,
),//home
//post
'post' => array(
'type' => 'Segment',
'options' => array(
'route' => '/post[/:action]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'module' => 'Application',
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Application\Controller\Post',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'wildcard' => array(
'type' => 'Wildcard'
)
)
),//service
//service
'service' => array(
'type' => 'Segment',
'options' => array(
'route' => '/service[/:action]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'module' => 'Application',
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Application\Controller\Service',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'wildcard' => array(
'type' => 'Wildcard'
)
)
),//service
),
),
'service_manager' => array(
'abstract_factories' => array(
'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
'Zend\Log\LoggerAbstractServiceFactory',
),
'aliases' => array(
'translator' => 'MvcTranslator',
),
),
'translator' => array(
'locale' => 'en_US',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController',
'Application\Controller\Post' => 'Application\Controller\PostController',
'Application\Controller\Service' => 'Application\Controller\ServiceController',
'Application\Controller\Search' => 'Application\Controller\SearchController',
),
),
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
'layout/layout/message' => __DIR__ . '/../view/layout/post-message.phtml',
'layout/layout/header' => __DIR__ . '/../view/layout/header.phtml',
'layout/layout/footer' => __DIR__ . '/../view/layout/footer.phtml',
'pagination/control' => __DIR__ . '/../view/layout/pagination.phtml',
'pagination/search' => __DIR__ . '/../view/layout/pagination-search.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
'strategies' => array(
'ViewJsonStrategy',
),
),
// Placeholder for console routes
'console' => array(
'router' => array(
'routes' => array(
),
),
),
);
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
return array(
'router' => array(
'routes' => array(
//home
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
//'type' => 'Segment',
'options' => array(
'route' => '/',
'defaults' => array(
'module' => 'Application',
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '[:controller[/:action][/]]',
'constraints' => array(
'module' => 'Application',
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'module' => 'Application',
'action' => 'index',
'__NAMESPACE__' => 'Application\Controller',
),
),
'may_terminate' => true,
'child_routes' => array(
'wildcard' => array(
'type' => 'Wildcard'
)
)
),//default
'about' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => 'about',
'defaults' => array(
'module' => 'Application',
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Application\Controller\Index',
'action' => 'about',
),
),
),
),
),//home
//login
'login' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/account/login',
'defaults' => array(
'module' => 'Application',
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Application\Controller\Account',
'action' => 'login',
),
),
'may_terminate' => true,
),
//service
'service' => array(
'type' => 'Segment',
'options' => array(
'route' => '/service[/:action]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'module' => 'Application',
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Application\Controller\Service',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'wildcard' => array(
'type' => 'Wildcard'
)
)
),//service
//search
'search' => array(
'type' => 'Segment',
'options' => array(
'route' => '/search[/page/:page]',
'constraints' => array(
'page' => '[a-zA-Z0-9][a-zA-Z0-9_-]*',
),
'defaults' => array(
'module' => 'Application',
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Application\Controller\Search',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'wildcard' => array(
'type' => 'Wildcard'
)
)
),//search
//about
'about' => array(
'type' => 'Segment',
'options' => array(
'route' => '/about[/:id]',
'constraints' => array(
'id' => '.*',
),
'defaults' => array(
'module' => 'Application',
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Application\Controller\Index',
'action' => 'about',
),
),
'may_terminate' => true,
'child_routes' => array(
'wildcard' => array(
'type' => 'Wildcard'
)
)
),//default
),
),
'service_manager' => array(
'abstract_factories' => array(
'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
'Zend\Log\LoggerAbstractServiceFactory',
),
'aliases' => array(
'translator' => 'MvcTranslator',
),
),
'translator' => array(
'locale' => 'en_US',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController',
'Application\Controller\Account' => 'Application\Controller\AccountController',
'Application\Controller\Service' => 'Application\Controller\ServiceController',
'Application\Controller\Search' => 'Application\Controller\SearchController',
),
),
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
'layout/layout/message' => __DIR__ . '/../view/layout/post-message.phtml',
'layout/layout/header' => __DIR__ . '/../view/layout/header.phtml',
'layout/layout/footer' => __DIR__ . '/../view/layout/footer.phtml',
'pagination/control' => __DIR__ . '/../view/layout/pagination.phtml',
'pagination/search' => __DIR__ . '/../view/layout/pagination-search.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
'strategies' => array(
'ViewJsonStrategy',
),
),
// Placeholder for console routes
'console' => array(
'router' => array(
'routes' => array(
),
),
),
);

View File

@ -1,38 +1,79 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Sookon\Helpers\View as view;
class IndexController extends AbstractActionController
{
public $ViewModel;
function __construct($db = NULL)
{
$this->ViewModel = new ViewModel();
}
//首页
public function indexAction()
{
return $this->ViewModel;
}
//关于我们
public function aboutAction()
{
return $this->ViewModel;
}
}
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Sookon\Helpers\View as view;
class IndexController extends AbstractActionController
{
public $ViewModel;
function __construct($db = NULL)
{
$this->ViewModel = new ViewModel();
}
public function indexAction()
{
$article = new \Sookon\Article\Lists;
$article->opt->limit = 10;
$article->opt->where = array(" cate.ptype='news' ");
$this->ViewModel->setVariable('articles',$article->fetchAll());
$article->opt->where = array(" cate.ptype='news' ");
$this->ViewModel->setVariable('news',$article->fetchAll());
unset($article);
$metadata = new \Westdc\Metadata\Outlink;
$metadata->opt->limit = 10;
$metadata->opt->sort = "desc";
$metadata->opt->order = "m.ts_created";
$this->ViewModel->setVariable('metadata_latest',$metadata->fetchAll());
$metadata->opt->order = "md.viewed";
$this->ViewModel->setVariable('metadata',$metadata->fetchAll());
$metadata->opt->order = "m.ts_created";
$metadata->opt->where = array(" ol.host='http://deep.qherc.org' ");
$this->ViewModel->setVariable('qinghaihu',$metadata->fetchAll());
$metadata->opt->where = array(" ol.host='http://www.sanjiangyuan.org.cn' ");
$this->ViewModel->setVariable('sanjiangyuan',$metadata->fetchAll());
unset($metadata);
return $this->ViewModel;
}
public function aboutAction()
{
$article = new \Sookon\Article\Lists;
$article->opt->limit = 10;
$article->opt->where = array("cate.code='aboutus'");
$this->ViewModel->setVariable('articles',$article->fetchAll());
unset($article);
$id = $this->params()->fromRoute("id");
if(empty($id))
{
$id = 89;
}
$article = new \Sookon\Article\Article;
$this->ViewModel->setVariable('content',$article->fetch($id));
return $this->ViewModel;
}
}

View File

@ -1,47 +0,0 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Sookon\Helpers\View as view;
class PostController extends AbstractActionController
{
public $ViewModel;
function __construct($db = NULL)
{
$this->ViewModel = new ViewModel();
}
//首页
public function indexAction()
{
return $this->ViewModel;
}
//发布信息
public function createAction()
{
return $this->ViewModel;
}
//搜索
public function searchAction()
{
return $this->ViewModel;
}
}

View File

@ -1 +0,0 @@
信息发布

View File

@ -1 +0,0 @@
信息列表

View File

@ -1,107 +1,108 @@
<h1><?php echo $this->translate('A 404 error occurred') ?></h1>
<h2><?php echo $this->message ?></h2>
<?php if (isset($this->reason) && $this->reason): ?>
<?php
$reasonMessage= '';
switch ($this->reason) {
case 'error-controller-cannot-dispatch':
$reasonMessage = $this->translate('The requested controller was unable to dispatch the request.');
break;
case 'error-controller-not-found':
$reasonMessage = $this->translate('The requested controller could not be mapped to an existing controller class.');
break;
case 'error-controller-invalid':
$reasonMessage = $this->translate('The requested controller was not dispatchable.');
break;
case 'error-router-no-match':
$reasonMessage = $this->translate('The requested URL could not be matched by routing.');
break;
default:
$reasonMessage = $this->translate('We cannot determine at this time why a 404 was generated.');
break;
}
?>
<p><?php echo $reasonMessage ?></p>
<?php endif ?>
<?php if (isset($this->controller) && $this->controller): ?>
<dl>
<dt><?php echo $this->translate('Controller') ?>:</dt>
<dd><?php echo $this->escapeHtml($this->controller) ?>
<?php
if (isset($this->controller_class)
&& $this->controller_class
&& $this->controller_class != $this->controller
) {
echo '(' . sprintf($this->translate('resolves to %s'), $this->escapeHtml($this->controller_class)) . ')';
}
?>
</dd>
</dl>
<?php endif ?>
<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?>
<?php if(isset($this->exception) && $this->exception instanceof Exception): ?>
<hr/>
<h2><?php echo $this->translate('Additional information') ?>:</h2>
<h3><?php echo get_class($this->exception); ?></h3>
<dl>
<dt><?php echo $this->translate('File') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getFile() ?>:<?php echo $this->exception->getLine() ?></pre>
</dd>
<dt><?php echo $this->translate('Message') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getMessage() ?></pre>
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getTraceAsString() ?></pre>
</dd>
</dl>
<?php
$e = $this->exception->getPrevious();
if ($e) :
?>
<hr/>
<h2><?php echo $this->translate('Previous exceptions') ?>:</h2>
<ul class="unstyled">
<?php while($e) : ?>
<li>
<h3><?php echo get_class($e); ?></h3>
<dl>
<dt><?php echo $this->translate('File') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getFile() ?>:<?php echo $e->getLine() ?></pre>
</dd>
<dt><?php echo $this->translate('Message') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getMessage() ?></pre>
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getTraceAsString() ?></pre>
</dd>
</dl>
</li>
<?php
$e = $e->getPrevious();
endwhile;
?>
</ul>
<?php endif; ?>
<?php else: ?>
<h3><?php echo $this->translate('No Exception available') ?></h3>
<?php endif ?>
<?php endif ?>
<img src="/img/404error.jpg" class="pull-left img-circle" />
<h1><?php echo $this->translate('A 404 error occurred') ?></h1>
<h2><?php echo empty($this->message) ? "This page has been eaten by dinosaurs":$this->message ?></h2>
<hr />
<?php if (isset($this->reason) && $this->reason): ?>
<?php
$reasonMessage= '';
switch ($this->reason) {
case 'error-controller-cannot-dispatch':
$reasonMessage = $this->translate('The requested controller was unable to dispatch the request.');
break;
case 'error-controller-not-found':
$reasonMessage = $this->translate('The requested controller could not be mapped to an existing controller class.');
break;
case 'error-controller-invalid':
$reasonMessage = $this->translate('The requested controller was not dispatchable.');
break;
case 'error-router-no-match':
$reasonMessage = $this->translate('The requested URL could not be matched by routing.');
break;
default:
$reasonMessage = $this->translate('We cannot determine at this time why a 404 was generated.');
break;
}
?>
<p><?php echo $reasonMessage ?></p>
<?php endif ?>
<?php if (isset($this->controller) && $this->controller): ?>
<dl>
<dt><?php echo $this->translate('Controller') ?>:</dt>
<dd><?php echo $this->escapeHtml($this->controller) ?>
<?php
if (isset($this->controller_class)
&& $this->controller_class
&& $this->controller_class != $this->controller
) {
echo '(' . sprintf($this->translate('resolves to %s'), $this->escapeHtml($this->controller_class)) . ')';
}
?>
</dd>
</dl>
<?php endif ?>
<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?>
<?php if(isset($this->exception) && $this->exception instanceof Exception): ?>
<hr/>
<h2><?php echo $this->translate('Additional information') ?>:</h2>
<h3><?php echo get_class($this->exception); ?></h3>
<dl>
<dt><?php echo $this->translate('File') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getFile() ?>:<?php echo $this->exception->getLine() ?></pre>
</dd>
<dt><?php echo $this->translate('Message') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getMessage() ?></pre>
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getTraceAsString() ?></pre>
</dd>
</dl>
<?php
$e = $this->exception->getPrevious();
if ($e) :
?>
<hr/>
<h2><?php echo $this->translate('Previous exceptions') ?>:</h2>
<ul class="unstyled">
<?php while($e) : ?>
<li>
<h3><?php echo get_class($e); ?></h3>
<dl>
<dt><?php echo $this->translate('File') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getFile() ?>:<?php echo $e->getLine() ?></pre>
</dd>
<dt><?php echo $this->translate('Message') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getMessage() ?></pre>
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getTraceAsString() ?></pre>
</dd>
</dl>
</li>
<?php
$e = $e->getPrevious();
endwhile;
?>
</ul>
<?php endif; ?>
<?php else: ?>
<h3><?php echo $this->translate('No Exception available') ?></h3>
<?php endif ?>
<?php endif ?>

View File

@ -1,62 +1,64 @@
<h1><?php echo $this->translate('An error occurred') ?></h1>
<h2><?php echo $this->message ?></h2>
<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?>
<?php if(isset($this->exception) && $this->exception instanceof Exception): ?>
<hr/>
<h2><?php echo $this->translate('Additional information') ?>:</h2>
<h3><?php echo get_class($this->exception); ?></h3>
<dl>
<dt><?php echo $this->translate('File') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getFile() ?>:<?php echo $this->exception->getLine() ?></pre>
</dd>
<dt><?php echo $this->translate('Message') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->escapeHtml($this->exception->getMessage()) ?></pre>
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->escapeHtml($this->exception->getTraceAsString()) ?></pre>
</dd>
</dl>
<?php
$e = $this->exception->getPrevious();
if ($e) :
?>
<hr/>
<h2><?php echo $this->translate('Previous exceptions') ?>:</h2>
<ul class="unstyled">
<?php while($e) : ?>
<li>
<h3><?php echo get_class($e); ?></h3>
<dl>
<dt><?php echo $this->translate('File') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getFile() ?>:<?php echo $e->getLine() ?></pre>
</dd>
<dt><?php echo $this->translate('Message') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->escapeHtml($e->getMessage()) ?></pre>
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->escapeHtml($e->getTraceAsString()) ?></pre>
</dd>
</dl>
</li>
<?php
$e = $e->getPrevious();
endwhile;
?>
</ul>
<?php endif; ?>
<?php else: ?>
<h3><?php echo $this->translate('No Exception available') ?></h3>
<?php endif ?>
<?php endif ?>
<div class="container">
<h1><?php echo $this->translate('An error occurred') ?></h1>
<h2><?php echo $this->message ?></h2>
<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?>
<?php if(isset($this->exception) && $this->exception instanceof Exception): ?>
<hr/>
<h2><?php echo $this->translate('Additional information') ?>:</h2>
<h3><?php echo get_class($this->exception); ?></h3>
<dl>
<dt><?php echo $this->translate('File') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getFile() ?>:<?php echo $this->exception->getLine() ?></pre>
</dd>
<dt><?php echo $this->translate('Message') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getMessage() ?></pre>
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getTraceAsString() ?></pre>
</dd>
</dl>
<?php
$e = $this->exception->getPrevious();
if ($e) :
?>
<hr/>
<h2><?php echo $this->translate('Previous exceptions') ?>:</h2>
<ul class="unstyled">
<?php while($e) : ?>
<li>
<h3><?php echo get_class($e); ?></h3>
<dl>
<dt><?php echo $this->translate('File') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getFile() ?>:<?php echo $e->getLine() ?></pre>
</dd>
<dt><?php echo $this->translate('Message') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getMessage() ?></pre>
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getTraceAsString() ?></pre>
</dd>
</dl>
</li>
<?php
$e = $e->getPrevious();
endwhile;
?>
</ul>
<?php endif; ?>
<?php else: ?>
<h3><?php echo $this->translate('No Exception available') ?></h3>
<?php endif ?>
<?php endif ?>
</div>

View File

@ -1,55 +1,41 @@
<?php echo $this->doctype(); ?>
<html lang="en">
<head>
<meta charset="utf-8">
<?php echo $this->headTitle('ZF2 '. $this->translate('Skeleton Application'))->setSeparator(' - ')->setAutoEscape(false) ?>
<?php echo $this->headMeta()
->appendName('viewport', 'width=device-width, initial-scale=1.0')
->appendHttpEquiv('X-UA-Compatible', 'IE=edge')
?>
<!-- Le styles -->
<?php echo $this->headLink(array('rel' => 'shortcut icon', 'type' => 'image/vnd.microsoft.icon', 'href' => $this->basePath() . '/img/favicon.ico'))
->prependStylesheet($this->basePath() . '/css/style.css')
->prependStylesheet($this->basePath() . '/css/bootstrap-theme.min.css')
->prependStylesheet($this->basePath() . '/css/bootstrap.min.css') ?>
<!-- Scripts -->
<?php echo $this->headScript()
->prependFile($this->basePath() . '/js/bootstrap.min.js')
->prependFile($this->basePath() . '/js/jquery.min.js')
->prependFile($this->basePath() . '/js/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9',))
->prependFile($this->basePath() . '/js/html5shiv.js', 'text/javascript', array('conditional' => 'lt IE 9',))
; ?>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php echo $this->url('home') ?>"><img src="<?php echo $this->basePath('img/zf2-logo.png') ?>" alt="Zend Framework 2"/>&nbsp;<?php echo $this->translate('Skeleton Application') ?></a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="<?php echo $this->url('home') ?>"><?php echo $this->translate('Home') ?></a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container">
<?php echo $this->content; ?>
<hr>
<footer>
<p>&copy; 2005 - <?php echo date('Y') ?> by Zend Technologies Ltd. <?php echo $this->translate('All rights reserved.') ?></p>
</footer>
</div> <!-- /container -->
<?php echo $this->inlineScript() ?>
</body>
</html>
<?php echo $this->doctype(); ?>
<html lang="en">
<head>
<meta charset="utf-8">
<?php $config = \Sookon\Helpers\Config::get(); ?>
<?php echo $this->headTitle($config->site_title)->setSeparator(' - ')->setAutoEscape(false) ?>
<?php echo $this->headMeta()
->appendName('viewport', 'width=device-width, initial-scale=1.0')
->appendHttpEquiv('X-UA-Compatible', 'IE=edge')
?>
<!-- Le styles -->
<?php echo $this->headLink(array('rel' => 'shortcut icon', 'type' => 'image/vnd.microsoft.icon', 'href' => $this->basePath() . '/img/favicon.ico'))
->prependStylesheet($this->basePath() . '/sjyportal/css/bootstrap.min.css')
->appendStylesheet($this->basePath() . '/sjyportal/css/bootstrap-responsive.min.css')
->appendStylesheet($this->basePath() . '/sjyportal/css/style.css')
?>
<!-- Scripts -->
<?php echo $this->headScript()
->prependFile($this->basePath() . '/sjyportal/js/bootstrap.min.js')
->prependFile($this->basePath() . '/js/jquery.min.js')
->prependFile($this->basePath() . '/js/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9',))
->prependFile($this->basePath() . '/js/html5shiv.js', 'text/javascript', array('conditional' => 'lt IE 9',))
; ?>
</head>
<body>
<?php echo $this->partial('layout/layout/header');?>
<?php echo $this->content; ?>
<?php echo $this->partial('layout/layout/footer');?>
<?php echo $this->inlineScript() ?>
</body>
</html>

View File

@ -1,48 +0,0 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Member;
use Zend\ModuleManager\ModuleManager;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
use Sookon\Authentication\AuthenticationService;
use Sookon\Helpers\View as view;
use Sookon\Helpers\LayoutHelpers;
class Module
{
public function onBootstrap(MvcEvent $e)
{
}
public function init(ModuleManager $moduleManager)
{
$sharedEvents = $moduleManager->getEventManager()->getSharedManager();
$sharedEvents->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH ,array(new LayoutHelpers, 'setMemberScript'), 100);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
}

View File

@ -1,101 +0,0 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
return array(
'router' => array(
'routes' => array(
//member
'member' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
//'type' => 'Segment',
'options' => array(
'route' => '/member',
'defaults' => array(
'module' => 'Member',
'__NAMESPACE__' => 'Member\Controller',
'controller' => 'Member\Controller\Index',
'action' => 'index',
),
),
'may_terminate' => true,
),//member
//login
'login' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/member/login',
'defaults' => array(
'module' => 'Member',
'__NAMESPACE__' => 'Member\Controller',
'controller' => 'Member\Controller\Account',
'action' => 'login',
),
),
'may_terminate' => true,
),//login
//register
'register' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/member/register',
'defaults' => array(
'module' => 'Member',
'__NAMESPACE__' => 'Member\Controller',
'controller' => 'Member\Controller\Account',
'action' => 'register',
),
),
'may_terminate' => true,
),//register
),
),
'service_manager' => array(
'abstract_factories' => array(
'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
'Zend\Log\LoggerAbstractServiceFactory',
),
'aliases' => array(
'translator' => 'MvcTranslator',
),
),
'translator' => array(
'locale' => 'en_US',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),
'controllers' => array(
'invokables' => array(
'Member\Controller\Index' => 'Member\Controller\IndexController',
'Member\Controller\Account' => 'Member\Controller\AccountController',
),
),
'view_manager' => array(
'template_path_stack' => array(
__DIR__ . '/../view',
),
'strategies' => array(
'ViewJsonStrategy',
),
),
// Placeholder for console routes
'console' => array(
'router' => array(
'routes' => array(
),
),
),
);

Binary file not shown.

View File

@ -1,153 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: ZendSkeletonApplication\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-07-05 22:17-0700\n"
"PO-Revision-Date: 2012-07-05 22:17-0700\n"
"Last-Translator: Evan Coury <me@evancoury.com>\n"
"Language-Team: ZF Contibutors <zf-devteam@zend.com>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: translate\n"
"X-Poedit-Language: English\n"
"X-Poedit-Country: UNITED STATES\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-SearchPath-0: ..\n"
#: ../view/layout/layout.phtml:6
#: ../view/layout/layout.phtml:33
msgid "Skeleton Application"
msgstr ""
#: ../view/layout/layout.phtml:36
msgid "Home"
msgstr ""
#: ../view/layout/layout.phtml:50
msgid "All rights reserved."
msgstr ""
#: ../view/application/index/index.phtml:2
#, php-format
msgid "Welcome to %sZend Framework 2%s"
msgstr ""
#: ../view/application/index/index.phtml:3
#, php-format
msgid "Congratulations! You have successfully installed the %sZF2 Skeleton Application%s. You are currently running Zend Framework version %s. This skeleton can serve as a simple starting point for you to begin building your application on ZF2."
msgstr ""
#: ../view/application/index/index.phtml:4
msgid "Fork Zend Framework 2 on GitHub"
msgstr ""
#: ../view/application/index/index.phtml:10
msgid "Follow Development"
msgstr ""
#: ../view/application/index/index.phtml:11
#, php-format
msgid "Zend Framework 2 is under active development. If you are interested in following the development of ZF2, there is a special ZF2 portal on the official Zend Framework website which provides links to the ZF2 %swiki%s, %sdev blog%s, %sissue tracker%s, and much more. This is a great resource for staying up to date with the latest developments!"
msgstr ""
#: ../view/application/index/index.phtml:12
msgid "ZF2 Development Portal"
msgstr ""
#: ../view/application/index/index.phtml:16
msgid "Discover Modules"
msgstr ""
#: ../view/application/index/index.phtml:17
#, php-format
msgid "The community is working on developing a community site to serve as a repository and gallery for ZF2 modules. The project is available %son GitHub%s. The site is currently live and currently contains a list of some of the modules already available for ZF2."
msgstr ""
#: ../view/application/index/index.phtml:18
msgid "Explore ZF2 Modules"
msgstr ""
#: ../view/application/index/index.phtml:22
msgid "Help &amp; Support"
msgstr ""
#: ../view/application/index/index.phtml:23
#, php-format
msgid "If you need any help or support while developing with ZF2, you may reach us via IRC: %s#zftalk on Freenode%s. We'd love to hear any questions or feedback you may have regarding the beta releases. Alternatively, you may subscribe and post questions to the %smailing lists%s."
msgstr ""
#: ../view/application/index/index.phtml:24
msgid "Ping us on IRC"
msgstr ""
#: ../view/error/index.phtml:1
msgid "An error occurred"
msgstr ""
#: ../view/error/index.phtml:8
msgid "Additional information"
msgstr ""
#: ../view/error/index.phtml:11
#: ../view/error/index.phtml:35
msgid "File"
msgstr ""
#: ../view/error/index.phtml:15
#: ../view/error/index.phtml:39
msgid "Message"
msgstr ""
#: ../view/error/index.phtml:19
#: ../view/error/index.phtml:43
#: ../view/error/404.phtml:55
msgid "Stack trace"
msgstr ""
#: ../view/error/index.phtml:29
msgid "Previous exceptions"
msgstr ""
#: ../view/error/index.phtml:58
msgid "No Exception available"
msgstr ""
#: ../view/error/404.phtml:1
msgid "A 404 error occurred"
msgstr ""
#: ../view/error/404.phtml:10
msgid "The requested controller was unable to dispatch the request."
msgstr ""
#: ../view/error/404.phtml:13
msgid "The requested controller could not be mapped to an existing controller class."
msgstr ""
#: ../view/error/404.phtml:16
msgid "The requested controller was not dispatchable."
msgstr ""
#: ../view/error/404.phtml:19
msgid "The requested URL could not be matched by routing."
msgstr ""
#: ../view/error/404.phtml:22
msgid "We cannot determine at this time why a 404 was generated."
msgstr ""
#: ../view/error/404.phtml:34
msgid "Controller"
msgstr ""
#: ../view/error/404.phtml:41
#, php-format
msgid "resolves to %s"
msgstr ""
#: ../view/error/404.phtml:51
msgid "Exception"
msgstr ""

Binary file not shown.

View File

@ -1,174 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: ZendSkeletonApplication\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-07-05 22:17-0700\n"
"PO-Revision-Date: 2012-09-08 13:15+0800\n"
"Last-Translator: Evan Coury <me@evancoury.com>\n"
"Language-Team: ZF Contibutors <zf-devteam@zend.com>\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: translate\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-SearchPath-0: ..\n"
#: ../view/layout/layout.phtml:6 ../view/layout/layout.phtml:33
msgid "Skeleton Application"
msgstr "框架应用"
#: ../view/layout/layout.phtml:36
msgid "Home"
msgstr "主页"
#: ../view/layout/layout.phtml:50
msgid "All rights reserved."
msgstr "All rights reserved."
#: ../view/application/index/index.phtml:2
#, php-format
msgid "Welcome to %sZend Framework 2%s"
msgstr "欢迎使用%sZend Framework 2%s"
#: ../view/application/index/index.phtml:3
#, php-format
msgid ""
"Congratulations! You have successfully installed the %sZF2 Skeleton "
"Application%s. You are currently running Zend Framework version %s. This "
"skeleton can serve as a simple starting point for you to begin building your "
"application on ZF2."
msgstr ""
"恭喜!您已经成功安装了%sZF2 Skeleton Application%s。您现在运行的Zend "
"Framework的版本为%s。这个框架应用可以用作您创建自己的ZF2应用的起点。"
#: ../view/application/index/index.phtml:4
msgid "Fork Zend Framework 2 on GitHub"
msgstr "在GitHub中获取Zend Framework 2到您的应用"
#: ../view/application/index/index.phtml:10
msgid "Follow Development"
msgstr "关注开发"
#: ../view/application/index/index.phtml:11
#, php-format
msgid ""
"Zend Framework 2 is under active development. If you are interested in "
"following the development of ZF2, there is a special ZF2 portal on the "
"official Zend Framework website which provides links to the ZF2 %swiki%s, "
"%sdev blog%s, %sissue tracker%s, and much more. This is a great resource for "
"staying up to date with the latest developments!"
msgstr ""
"Zend Framework 2正在开发中。如果您有兴趣关注ZF2的开发Zend Framework的官方网"
"站有一个专门的ZF2入口从这个入口可以进入ZF2的%swiki%s, %sdev blog%s, "
"%sissue tracker%s等。这些是关注我们最新开发的好资源"
#: ../view/application/index/index.phtml:12
msgid "ZF2 Development Portal"
msgstr "ZF2 开发入口"
#: ../view/application/index/index.phtml:16
msgid "Discover Modules"
msgstr "探索模块"
#: ../view/application/index/index.phtml:17
#, php-format
msgid ""
"The community is working on developing a community site to serve as a "
"repository and gallery for ZF2 modules. The project is available %son GitHub"
"%s. The site is currently live and currently contains a list of some of the "
"modules already available for ZF2."
msgstr ""
"社区正在开发一个能够存储和展示ZF2模块的功能。这个项目可以在%son GitHub%s找"
"到。这个网站现在已经包含了许多ZF2可用的模块。"
#: ../view/application/index/index.phtml:18
msgid "Explore ZF2 Modules"
msgstr "浏览ZF2模块"
#: ../view/application/index/index.phtml:22
msgid "Help &amp; Support"
msgstr "帮助 &amp; 支持"
#: ../view/application/index/index.phtml:23
#, php-format
msgid ""
"If you need any help or support while developing with ZF2, you may reach us "
"via IRC: %s#zftalk on Freenode%s. We'd love to hear any questions or "
"feedback you may have regarding the beta releases. Alternatively, you may "
"subscribe and post questions to the %smailing lists%s."
msgstr ""
"如果您需要一些关于ZF2开发的帮助和支持可以通过IRC: %s#zftalk on Freenode"
"%s。我们非常乐意收到您对于发布的公测版提问和反馈。或者您也可以通"
"过%smailing lists%s订阅并发布问题。"
#: ../view/application/index/index.phtml:24
msgid "Ping us on IRC"
msgstr "在IRC上ping我们"
#: ../view/error/index.phtml:1
msgid "An error occurred"
msgstr "发生错误"
#: ../view/error/index.phtml:8
msgid "Additional information"
msgstr "附加信息"
#: ../view/error/index.phtml:11 ../view/error/index.phtml:35
msgid "File"
msgstr "文件"
#: ../view/error/index.phtml:15 ../view/error/index.phtml:39
msgid "Message"
msgstr "消息"
#: ../view/error/index.phtml:19 ../view/error/index.phtml:43
#: ../view/error/404.phtml:55
msgid "Stack trace"
msgstr "Stack trace"
#: ../view/error/index.phtml:29
msgid "Previous exceptions"
msgstr "上一个异常"
#: ../view/error/index.phtml:58
msgid "No Exception available"
msgstr "没有可用的Exception"
#: ../view/error/404.phtml:1
msgid "A 404 error occurred"
msgstr "404 缺少目标文件"
#: ../view/error/404.phtml:10
msgid "The requested controller was unable to dispatch the request."
msgstr "所请求的控制器不能分发该请求"
#: ../view/error/404.phtml:13
msgid ""
"The requested controller could not be mapped to an existing controller class."
msgstr "所请求的控制器不能映射到已存在的控制器类"
#: ../view/error/404.phtml:16
msgid "The requested controller was not dispatchable."
msgstr ""
#: ../view/error/404.phtml:19
msgid "The requested URL could not be matched by routing."
msgstr "所请求的URL不能与路由对应"
#: ../view/error/404.phtml:22
msgid "We cannot determine at this time why a 404 was generated."
msgstr "我们不能确定为什么这次会出现404"
#: ../view/error/404.phtml:34
msgid "Controller"
msgstr "控制器"
#: ../view/error/404.phtml:41
#, php-format
msgid "resolves to %s"
msgstr "解决: %s"
#: ../view/error/404.phtml:51
msgid "Exception"
msgstr "异常"

View File

@ -1,314 +0,0 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Member\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\View\Model\JsonModel;
use Zend\Authentication\AuthenticationService;
use Zend\Authentication\Storage\Session as SessionStorage;
use Sookon\User\Account;
use Sookon\User\Member;
use Sookon\User\Gravatar;
use Sookon\Helpers\Auth;
use Sookon\Helpers\Captcha;
use Sookon\Helpers\View as view;
class AccountController extends AbstractActionController
{
public $ViewModel;
public function __construct()
{
$this->ViewModel = new ViewModel();
}
public function indexAction()
{
$submit = $this->params()->fromPost('submit');
$account = new Account();
if(!empty($submit))
{
$data = $account->getEditParam($this->getRequest());
$Listener = new \Sookon\User\Listener\EditListener();
$account->getEventManager()->attachAggregate($Listener);
$type = $this->params()->fromPost('type');
$this->ViewModel->setVariable('section',$type) ;
$status = $account->edit($data,$type);
if($status !== true)
{
$this->ViewModel->setVariable('error',view::Error($status));
}else{
$this->ViewModel->setVariable('error',view::Error("修改成功","alert-success"));
}
}
$user = $account->getAccountInfo();
$av = new Gravatar();
$this->ViewModel->setVariable('user',$user);
$this->ViewModel->setVariable('avatar',$av->Get($user['email'],100));
return $this->ViewModel;
}
public function loginAction()
{
if($this->getRequest()->isXmlHttpRequest())
{
$submit = $this->params()->fromPost('submit');
if(!empty($submit))
{
if ($auth->hasIdentity())
{
return JsonModel(array('error'=>"您已登录,无需重复登录"));
}
else{
$account = new Account();
$status = $account->login(array(
'username'=>$this->params()->fromPost('username'),
'password'=>$this->params()->fromPost('password')
));
if(is_array($status))
{
return new JsonModel($status);
}
}
}
return;
}
$auth = new Auth;
$instance = $auth->getInstance();
if ($instance->hasIdentity())
{
view::Post($this,'您已经登陆过了,无需重复登陆','/');
return $this->ViewModel;
}
$submit = $this->params()->fromPost('submit');
if(!empty($submit))
{
$account = new Account();
$status = $account->login(array(
'username'=>$this->params()->fromPost('username'),
'password'=>$this->params()->fromPost('password')
));
if(isset($status['error']))
{
$viewModel = array('error' => view::Error($status['error']));
if(isset($status['place']))
{
array_push($viewModel,array("place"=>$status['place']));
}
return new ViewModel($viewModel);
}else{
if(isset($_GET['href']) && !preg_match("/http:\/\//",$_GET['href']) && $_GET['href'] != '/account/login')
{
$href = $_GET['href'];
}else{
$href = "/";
}
view::Post($this,"登陆成功!",$href);
return $this->ViewModel;
}
}
}//login
public function registerAction()
{
if($this->getRequest()->isXmlHttpRequest())
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$account = new Account();
$data = $account->getParam($this->_request);
$result = $account->register($data);
if(!empty($result))
{
$this->jsonexit($result);
return true;
}
$this->jsonexit(array('error'=>'|o| 服务器掉链子了,请重试'));
return;
}
$success = false;
$auth = new Auth;
$instance = $auth->getInstance();
if ($instance->hasIdentity())
{
view::Post($this,'您已经登陆过了,无需重复登陆','/');
return $this->ViewModel;
}
$submit = $this->params()->fromPost('submit');
if(!empty($submit))
{
$account = new Account();
$data = array(
'username' => $this->params()->fromPost('username'),
'password'=>$this->params()->fromPost('password'),
'confirm_password'=>$this->params()->fromPost('confirm_password'),
'email'=>$this->params()->fromPost('email'),
'realname'=>$this->params()->fromPost('realname')
);
$result = $account->register($data);
if(!empty($result))
{
if(isset($result['error']))
{
$this->ViewModel->setVariable('error',view::Error($result['error']));
$this->ViewModel->setVariable('data',$data);
if(isset($result['place']))
{
$this->ViewModel->setVariable('place',$result['place']);
}
return $this->ViewModel;
}
if(isset($result['success']))
{
view::Post($this,"注册成功!",'/');
return $this->ViewModel;
}
}else{
$this->ViewModel->setVariable('error','处理中出现问题');
$this->ViewModel->setVariable('data',$data);
return $this->ViewModel;
}
}//submit
}//用户注册
//登录状态
public function loginstatus()
{
}
public function logoutAction()
{
$auth = new Auth();
$result = $auth->clearIndentity();
Member::flushcookie();
view::Post($this,"您已经成功注销",'/');
return $this->ViewModel;
}
//找回密码
public function forgotpasswordAction()
{
$submit = $this->params()->fromPost('submit');
$captcha = new Captcha();
if(!empty($submit))
{
$email = $this->params()->fromPost('email');
$captchaword = $this->params()->fromPost('captcha');
if(!$captcha->isValid($captchaword))
{
$this->ViewModel->setVariable('error',view::Error("验证码错误"));
$this->ViewModel->setVariable('captcha', $captcha->setCaptcha());
return $this->ViewModel;
}
$account = new Account();
$status = $account->getMyPassword($email);
if(isset($status['error']) && !empty($status['error']))
{
$this->ViewModel->setVariable('captcha', $captcha->setCaptcha());
$this->ViewModel->setVariable('error',$status['error']);
return $this->ViewModel;
}else{
$this->ViewModel->setVariable('msg',"申请成功!请在您的邮箱中查看密码重置邮件");
return $this->ViewModel;
}
}else{
$this->ViewModel->setVariable('captcha', $captcha->setCaptcha());
return $this->ViewModel;
}
}
//重置密码
public function getpasswordAction()
{
$submit = $this->params()->fromPost('submit');
$salt = $this->params()->fromQuery('salt');
if(empty($salt))
{
$this->ViewModel->setVariable('msg',view::Msg("alert-danger","缺少密码重置密钥"));
return $this->ViewModel;
}
$this->ViewModel->setVariable('salt',$salt);
if(!empty($submit))
{
$data = array(
'username' => $this->params()->fromPost('username'),
'password' => $this->params()->fromPost('password'),
'confirm_password' => $this->params()->fromPost('confirm_password'),
'salt' => $salt
);
$account = new Account();
$Listener = new \Sookon\User\Listener\PwdListener();
$account->getEventManager()->attachAggregate($Listener);
$status = $account->resetPassword($data);
if(isset($status['error']) && !empty($status['error']))
{
$this->ViewModel->setVariable('username',$data['username']);
$this->ViewModel->setVariable('error',view::Error($status['error']));
return $this->ViewModel;
}else{
$this->ViewModel->setVariable('msg',view::Msg("alert-success","您的密码已经成功更改,<a href='/account/login'>请点击这里登陆</a>"));
return $this->ViewModel;
}
}
}//getpasswordAction()
public function captchaAction()
{
if($this->getRequest()->isXmlHttpRequest())
{
$this->ViewModel->setTerminal(true);
$captcha = new Captcha();
$url = $captcha->setCaptcha();
echo $url;
exit();
}else{
echo "bad request!";
exit();
}
}
}

View File

@ -1,36 +0,0 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Member\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Sookon\Helpers\View as view;
class IndexController extends AbstractActionController
{
public $ViewModel;
function __construct($db = NULL)
{
$this->ViewModel = new ViewModel();
}
public function indexAction()
{
return $this->ViewModel;
}
public function aboutAction()
{
return $this->ViewModel;
}
}

View File

@ -1,107 +0,0 @@
<h1><?php echo $this->translate('A 404 error occurred') ?></h1>
<h2><?php echo $this->message ?></h2>
<?php if (isset($this->reason) && $this->reason): ?>
<?php
$reasonMessage= '';
switch ($this->reason) {
case 'error-controller-cannot-dispatch':
$reasonMessage = $this->translate('The requested controller was unable to dispatch the request.');
break;
case 'error-controller-not-found':
$reasonMessage = $this->translate('The requested controller could not be mapped to an existing controller class.');
break;
case 'error-controller-invalid':
$reasonMessage = $this->translate('The requested controller was not dispatchable.');
break;
case 'error-router-no-match':
$reasonMessage = $this->translate('The requested URL could not be matched by routing.');
break;
default:
$reasonMessage = $this->translate('We cannot determine at this time why a 404 was generated.');
break;
}
?>
<p><?php echo $reasonMessage ?></p>
<?php endif ?>
<?php if (isset($this->controller) && $this->controller): ?>
<dl>
<dt><?php echo $this->translate('Controller') ?>:</dt>
<dd><?php echo $this->escapeHtml($this->controller) ?>
<?php
if (isset($this->controller_class)
&& $this->controller_class
&& $this->controller_class != $this->controller
) {
echo '(' . sprintf($this->translate('resolves to %s'), $this->escapeHtml($this->controller_class)) . ')';
}
?>
</dd>
</dl>
<?php endif ?>
<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?>
<?php if(isset($this->exception) && $this->exception instanceof Exception): ?>
<hr/>
<h2><?php echo $this->translate('Additional information') ?>:</h2>
<h3><?php echo get_class($this->exception); ?></h3>
<dl>
<dt><?php echo $this->translate('File') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getFile() ?>:<?php echo $this->exception->getLine() ?></pre>
</dd>
<dt><?php echo $this->translate('Message') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getMessage() ?></pre>
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getTraceAsString() ?></pre>
</dd>
</dl>
<?php
$e = $this->exception->getPrevious();
if ($e) :
?>
<hr/>
<h2><?php echo $this->translate('Previous exceptions') ?>:</h2>
<ul class="unstyled">
<?php while($e) : ?>
<li>
<h3><?php echo get_class($e); ?></h3>
<dl>
<dt><?php echo $this->translate('File') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getFile() ?>:<?php echo $e->getLine() ?></pre>
</dd>
<dt><?php echo $this->translate('Message') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getMessage() ?></pre>
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getTraceAsString() ?></pre>
</dd>
</dl>
</li>
<?php
$e = $e->getPrevious();
endwhile;
?>
</ul>
<?php endif; ?>
<?php else: ?>
<h3><?php echo $this->translate('No Exception available') ?></h3>
<?php endif ?>
<?php endif ?>

View File

@ -1,62 +0,0 @@
<h1><?php echo $this->translate('An error occurred') ?></h1>
<h2><?php echo $this->message ?></h2>
<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?>
<?php if(isset($this->exception) && $this->exception instanceof Exception): ?>
<hr/>
<h2><?php echo $this->translate('Additional information') ?>:</h2>
<h3><?php echo get_class($this->exception); ?></h3>
<dl>
<dt><?php echo $this->translate('File') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->exception->getFile() ?>:<?php echo $this->exception->getLine() ?></pre>
</dd>
<dt><?php echo $this->translate('Message') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->escapeHtml($this->exception->getMessage()) ?></pre>
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->escapeHtml($this->exception->getTraceAsString()) ?></pre>
</dd>
</dl>
<?php
$e = $this->exception->getPrevious();
if ($e) :
?>
<hr/>
<h2><?php echo $this->translate('Previous exceptions') ?>:</h2>
<ul class="unstyled">
<?php while($e) : ?>
<li>
<h3><?php echo get_class($e); ?></h3>
<dl>
<dt><?php echo $this->translate('File') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $e->getFile() ?>:<?php echo $e->getLine() ?></pre>
</dd>
<dt><?php echo $this->translate('Message') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->escapeHtml($e->getMessage()) ?></pre>
</dd>
<dt><?php echo $this->translate('Stack trace') ?>:</dt>
<dd>
<pre class="prettyprint linenums"><?php echo $this->escapeHtml($e->getTraceAsString()) ?></pre>
</dd>
</dl>
</li>
<?php
$e = $e->getPrevious();
endwhile;
?>
</ul>
<?php endif; ?>
<?php else: ?>
<h3><?php echo $this->translate('No Exception available') ?></h3>
<?php endif ?>
<?php endif ?>

View File

@ -1,55 +0,0 @@
<?php echo $this->doctype(); ?>
<html lang="en">
<head>
<meta charset="utf-8">
<?php echo $this->headTitle('ZF2 '. $this->translate('Skeleton Application'))->setSeparator(' - ')->setAutoEscape(false) ?>
<?php echo $this->headMeta()
->appendName('viewport', 'width=device-width, initial-scale=1.0')
->appendHttpEquiv('X-UA-Compatible', 'IE=edge')
?>
<!-- Le styles -->
<?php echo $this->headLink(array('rel' => 'shortcut icon', 'type' => 'image/vnd.microsoft.icon', 'href' => $this->basePath() . '/img/favicon.ico'))
->prependStylesheet($this->basePath() . '/css/style.css')
->prependStylesheet($this->basePath() . '/css/bootstrap-theme.min.css')
->prependStylesheet($this->basePath() . '/css/bootstrap.min.css') ?>
<!-- Scripts -->
<?php echo $this->headScript()
->prependFile($this->basePath() . '/js/bootstrap.min.js')
->prependFile($this->basePath() . '/js/jquery.min.js')
->prependFile($this->basePath() . '/js/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9',))
->prependFile($this->basePath() . '/js/html5shiv.js', 'text/javascript', array('conditional' => 'lt IE 9',))
; ?>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php echo $this->url('home') ?>"><img src="<?php echo $this->basePath('img/zf2-logo.png') ?>" alt="Zend Framework 2"/>&nbsp;<?php echo $this->translate('Skeleton Application') ?></a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="<?php echo $this->url('home') ?>"><?php echo $this->translate('Home') ?></a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container">
<?php echo $this->content; ?>
<hr>
<footer>
<p>&copy; 2005 - <?php echo date('Y') ?> by Zend Technologies Ltd. <?php echo $this->translate('All rights reserved.') ?></p>
</footer>
</div> <!-- /container -->
<?php echo $this->inlineScript() ?>
</body>
</html>

View File

@ -1 +0,0 @@
登陆

View File

@ -1 +0,0 @@
注册

View File

@ -1 +0,0 @@
会员首页

View File

@ -1,70 +1,70 @@
<?php
namespace Sookon\Authentication;
use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Role\GenericRole as Role;
use Zend\Permissions\Acl\Resource\GenericResource as Resource;
use Sookon\Helpers\View as view;
class AclAuthorize
{
public $acl;
public $role;
function __construct(Acl &$acl)
{
$this->acl = $acl;
$this->loadAuthorize();
$acl = $this->acl;
}
public function loadAuthorize()
{
$this->role = new \stdClass();
$this->role->guest = 'guest';
$this->role->staff = 'member';
$this->role->admin = 'administrator';
$roleGuest = new Role($this->role->guest);
$this->acl->addRole($roleGuest);
$this->acl->addRole(new Role($this->role->staff), $roleGuest);
$this->acl->addRole(new Role($this->role->admin));
$this->authorizeGuest();
$this->authorizestaff();
$this->authorizeAdministrator();
}
public function authorizeGuest()
{
$this->acl->deny($this->role->guest);
$this->acl->allow($this->role->guest,'Member\Controller\Account',array('login','register','logout','forgotpassword','getpassword','captcha'));
$this->acl->allow($this->role->guest,'Application\Controller\Service',array('upload','thumb'));
$this->acl->allow($this->role->guest,'Application\Controller\Index');
$this->acl->allow($this->role->guest,'Application\Controller\Search');
$this->acl->allow($this->role->guest,'Application\Controller\Post');
}
public function authorizestaff()
{
$this->acl->allow($this->role->staff,'Application\Controller\Index',array('index'));
$this->acl->allow($this->role->staff,'Application\Controller\Service',array('upload','delatt','thumb'));
$this->acl->allow($this->role->staff,'Member\Controller\Index');
$this->acl->allow($this->role->staff,'Member\Controller\Account',array('index'));
}
public function authorizeAdministrator()
{
$this->acl->allow($this->role->admin);
}
<?php
namespace Sookon\Authentication;
use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Role\GenericRole as Role;
use Zend\Permissions\Acl\Resource\GenericResource as Resource;
use Sookon\Helpers\View as view;
class AclAuthorize
{
public $acl;
public $role;
function __construct(Acl &$acl)
{
$this->acl = $acl;
$this->loadAuthorize();
$acl = $this->acl;
}
public function loadAuthorize()
{
$this->role = new \stdClass();
$this->role->guest = 'guest';
$this->role->staff = 'member';
$this->role->admin = 'administrator';
$roleGuest = new Role($this->role->guest);
$this->acl->addRole($roleGuest);
$this->acl->addRole(new Role($this->role->staff), $roleGuest);
$this->acl->addRole(new Role($this->role->admin));
$this->authorizeGuest();
$this->authorizestaff();
$this->authorizeAdministrator();
}
public function authorizeGuest()
{
$this->acl->deny($this->role->guest);
$this->acl->allow($this->role->guest,'Application\Controller\Account',array('login','register','logout','forgotpassword','getpassword','captcha'));
$this->acl->allow($this->role->guest,'Application\Controller\Service',array('upload','thumb'));
$this->acl->allow($this->role->guest,'Application\Controller\Index');
$this->acl->allow($this->role->guest,'Application\Controller\Search');
$this->acl->allow($this->role->guest,'Article\Controller\Article',array('index','view'));
$this->acl->allow($this->role->guest,'Article\Controller\Category',array('index','list'));
$this->acl->allow($this->role->guest,'Metadata\Controller\Index');
}
public function authorizestaff()
{
$this->acl->allow($this->role->staff,'Application\Controller\Index',array('index'));
$this->acl->allow($this->role->staff,'Application\Controller\Account',array('index'));
$this->acl->allow($this->role->staff,'Application\Controller\Service',array('upload','delatt','thumb'));
}
public function authorizeAdministrator()
{
$this->acl->allow($this->role->admin);
}
}

View File

@ -1,81 +1,88 @@
<?php
namespace Sookon\Authentication;
use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Resource\GenericResource as Resource;
use Sookon\Helpers\View as view;
class AclResource
{
public $acl;
public $config = array(
'Admin\Controller\Index',
'Admin\Controller\Article',
'Admin\Controller\Category',
'Admin\Controller\Metadata',
'Admin\Controller\Users',
//index
'Application\Controller\Index',
'Application\Controller\Search',
'Application\Controller\Post' => array(
'index',
'create',
),
//service
'Application\Controller\Service' => array(
'upload',
'delatt',
'thumb',
'bigthumb'
),
'Member\Controller\Index',
//account
'Member\Controller\Account' => array(
'login',
'logout',
'register',
'forgotpassword',
'getpassword',
'captcha',
'index'
),
);
function __construct(Acl &$acl)
{
$this->acl = $acl;
$this->loadResource();
$acl = $this->acl;
}
public function loadResource()
{
foreach($this->config as $index => $resource)
{
if(!is_array($resource))
{
$this->acl->addResource(new Resource($resource));
continue;
}
$this->acl->addResource(new Resource($index));
foreach($resource as $action)
{
if($this->acl->hasResource($action))
{
continue;
}
$this->acl->addResource(new Resource($action),$index);
}
}
}
<?php
namespace Sookon\Authentication;
use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Resource\GenericResource as Resource;
use Sookon\Helpers\View as view;
class AclResource
{
public $acl;
public $config = array(
'Admin\Controller\Index',
'Admin\Controller\Article',
'Admin\Controller\Category',
'Admin\Controller\Metadata',
'Admin\Controller\Users',
//index
'Application\Controller\Index',
'Application\Controller\Search',
//account
'Application\Controller\Account' => array(
'login',
'logout',
'register',
'forgotpassword',
'getpassword',
'captcha',
'index'
),
//service
'Application\Controller\Service' => array(
'upload',
'delatt',
'thumb',
'bigthumb'
),
'Article\Controller\Article' => array(
'index',
'view'
),
'Article\Controller\Category' => array(
'index',
'list'
),
'Metadata\Controller\Index',
);
function __construct(Acl &$acl)
{
$this->acl = $acl;
$this->loadResource();
$acl = $this->acl;
}
public function loadResource()
{
foreach($this->config as $index => $resource)
{
if(!is_array($resource))
{
$this->acl->addResource(new Resource($resource));
continue;
}
$this->acl->addResource(new Resource($index));
foreach($resource as $action)
{
if($this->acl->hasResource($action))
{
continue;
}
$this->acl->addResource(new Resource($action),$index);
}
}
}
}

View File

@ -1,115 +0,0 @@
<?php
namespace Wbb\Vhome\Member\Account;
use Zend\EventManager\EventManagerInterface;
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerAwareInterface;
use Zend\Authentication\AuthenticationService;
use Zend\Authentication\Storage\Session as SessionStorage;
use Sookon\Helpers\View as view;
use Sookon\Helpers\Config as GlobalConfig;
use Sookon\Helpers\PDO as Db;
use Sookon\Helpers\Db as Zend_Db;
use Sookon\User\Member;
use Wbb\Vhome\Member\Listener\MemberListener as Listener;
abstract class Account implements EventManagerAwareInterface
{
private $db;
protected $events = NULL; //事件
private $config;
private $conf;
function __construct()
{
$this->db = new Db();
$this->config = GlobalConfig::get();
$this->conf = Config::get();
$Listener = new Listener();
$this->getEventManager()->attachAggregate($Listener);
}
public function setEventManager(EventManagerInterface $events)
{
$events->setIdentifiers(array(
__CLASS__,
get_called_class(),
));
$this->events = $events;
return $this;
}
public function getEventManager()
{
if (NULL === $this->events) {
$this->setEventManager(new EventManager());
}
return $this->events;
}
//获取账号信息,数组
public function getAccountInfo($id = 0)
{
if($id == 0)
{
$id = view::User('id');
}
$sql = "SELECT * FROM {$this->conf->table->member} WHERE id=$id";
$rs = $this->db->query($sql);
return $rs->fetch();
}
//storeLogin
public function storeLogin($data,$md5 = true)
{
$auth = new AuthenticationService();
$auth->setStorage(new SessionStorage($this->config->session_namespace));
new Zend_Db($dbAdapter);
$authAdapter = new \Zend\Authentication\Adapter\DbTable(
$dbAdapter,
$this->conf->table->member,
$this->conf->field->uname,
$this->conf->field->pwd
);
if($md5 === true)
{
$password = md5($data[$this->conf->field->pwd]);
}else{
$password = $data[$this->conf->field->pwd];
}
$authAdapter
->setIdentity($data[$this->conf->field->uname])
->setCredential($password)
;
$result = $authAdapter->authenticate();
$user = $authAdapter->getResultRowObject(null,array($this->conf->field->pwd));
if(!$result->isValid())
{
return array("error"=>"用户信息验证失败");
}
$email = $user->email;
$results = $this->getEventManager()->trigger('login.success.createAvatar', $this, compact('email'));
$user->avatar = $results->last();
$auth->getStorage()->write($user);
$id = $user->id;
$results = $this->getEventManager()->trigger('login.success.updateStatus', $this, compact('id'));
return array('success'=>1);
}
public function cookieLogin($data)
{
return $this->storeLogin($data,false);
}
}

View File

@ -1,47 +0,0 @@
<?php
namespace Wbb\Vhome\Member\Account;
class Config
{
public $conf;
function __construct()
{
}
static function get()
{
$conf = new \stdClass();
$conf->ck = 'DT0xe28SqIcmy334asEfUf';
$conf->table = new \stdClass();
$conf->field = new \stdClass();
$conf->role = new \stdClass();
$conf->form = new \stdClass();
$conf->table->member = "users";
$conf->field->uname = "username";
$conf->field->pwd = "password";
$conf->field->email = "email";
$conf->field->lastlogin = "ts_last_login";
$conf->field->lastip = "last_login_ip";
$conf->field->gravatar = "email";
$conf->field->realname = "realname";
$conf->role->member = "member";
$conf->role->admin = "admin";
$conf->role->guest = "guest";
$conf->form->uname = "username";
$conf->form->pwd = "password";
$conf->form->c_pwd = "confirm_password";
$conf->form->email = "email";
$conf->form->realname = "realname";
return $conf;
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace Wbb\Vhome\Member\Account;
use Sookon\User\Member;
class Login extends Account
{
function __construct()
{
parent::__construct();
}
//登陆
public function login($data)
{
$results = $this->getEventManager()->trigger('login.checkParam', $this, compact('data'));
$cache_data = $results->last();
if($cache_data !== true)
{
if(!is_array($cache_data))
{
return array('error'=>$cache_data);
}else{
return $cache_data;
}
}
$state = $this->storeLogin($data);
if(isset($state['success']))
{
$mb = new Member();
$mb->putcookie($data[$this->conf->field->uname],md5($data[$this->conf->field->pwd]));
}
return $state;
}//login
}

View File

@ -1,91 +0,0 @@
<?php
namespace Wbb\Vhome\Member\Account;
use Sookon\User\Member;
class Register extends Account
{
function __construct()
{
parent::__construct();
}
//注册
public function register($data)
{
$params = compact('data');
$results = $this->getEventManager()->trigger('register.checkParam', $this, $params);
$cache_data = $results->last();
if($cache_data !== true)
{
if(!is_array($cache_data))
{
return array('error'=>$cache_data);
}else{
return $cache_data;
}
}
$results = $this->getEventManager()->trigger('register.checkUser', $this, $params);
$cache_data = $results->last();
if($cache_data !== true)
{
if(!is_array($cache_data))
{
return array('error'=>$cache_data);
}else{
return $cache_data;
}
}
$loginData = array(
$this->conf->field->uname => $data['username'],
$this->conf->field->pwd => $data['password']
);
$data['password'] = md5($data['password']);
$data['usertype'] = $this->config->member->default_role;
unset($data['confirm_password']);
$dbh = new dbh();
$id = $dbh->insert($this->conf->table->member,$data,true);
if(!empty($id) && is_numeric($id))
{
$this->storeLogin($loginData);
if(isset($state['success']))
{
$mb = new Member();
$mb->putcookie($data[$this->conf->field->uname],$data[$this->FieldPasword]);
}
$params = compact('data','id');
$results = $this->getEventManager()->trigger('register.success', $this, $params);
return array("success" => 1);
}else{
if($id === false)
{
return array('error'=>'服务器开小差了,请稍后再试');
}else{
return array('error'=>'服务器处理中遇到错误,请联系管理员');
}
}
}//register
//注册信息参数
public function getParam(\Zend_Controller_Request_Abstract $request)
{
$data = array(
$this->conf->field->uname => $request->getParam('username'),
$this->conf->field->pwd => $request->getParam('password'),
$this->conf->form->c_pwd => $request->getParam('confirm_password'),
$this->conf->form->email => $request->getParam('email'),
$this->conf->form->realname =>$request->getParam('realname')
);
return $data;
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Wbb\Vhome\Member\Event;
use Zend\EventManager\EventInterface;
interface LoginEvent
{
public function checkParam(EventInterface $e);
public function updateStatus(EventInterface $e);
public function createAvatar(EventInterface $e);
}

View File

@ -1,12 +0,0 @@
<?php
namespace Wbb\Vhome\Member\Event;
use Zend\EventManager\EventInterface;
interface MemberEvent
{
public function checkParam(EventInterface $e);
public function processData(EventInterface $e);
public function recordPosted(EventInterface $e);
public function recordChanged(EventInterface $e);
}

View File

@ -1,13 +0,0 @@
<?php
namespace Wbb\Vhome\Member\Event;
use Zend\EventManager\EventInterface;
interface RegisterEvent
{
public function checkParam(EventInterface $e);
public function checkUser(EventInterface $e);
public function registerSuccess(EventInterface $e);
}

View File

@ -1,102 +0,0 @@
<?php
namespace Wbb\Vhome\Member\Handle;
use Sookon\Helpers\Dbh as dbh;
use Sookon\Helpers\PDO as Db;
use Sookon\User\Gravatar;
use Sookon\Helpers\View as view;
use Zend\EventManager\EventInterface;
use Wbb\Vhome\Member\Account\Config;
class LoginHandle implements \Wbb\Vhome\Member\Event\LoginEvent
{
private $db; //传入PDO对象
private $config; //全局配置
private $conf;
function __construct()
{
$this->db = new Db();
$this->conf = Config::get();
}
public function checkParam(EventInterface $e){
$data = $e->getParam('data');
if(!is_array($data))
{
return "参数错误";
}
if(empty($data[$this->conf->field->uname]))
{
return array('error'=>"请输入用户名",'place'=>'username');
}
if(!empty($data[$this->conf->field->uname]))
{
if(!preg_match("/^[a-zA-Z][a-zA-Z0-9_]{2,15}$/",$data[$this->conf->field->uname]))
{
return array('error'=>"用户名应当以字母开头由字母数字和下划线组成并且长度在2到25个字符之间",'place'=>'username');
}
}
if(empty($data[$this->conf->field->pwd]))
{
return array('error'=>"请输入密码",'place'=>'password');
}
$sql = "SELECT id,{$this->conf->field->pwd} FROM {$this->conf->table->member} WHERE {$this->conf->field->uname}=?";
$sth = $this->db->prepare($sql);
$rs = $sth->execute(array($data[$this->conf->field->uname]));
$row = $sth->fetch();
if(isset($row['id']) && !empty($row['id']))
{
if(strlen($row[$this->conf->field->pwd]) !== 32)
{
return array('error'=>"您的密码或因安全猿因或其他问题已经被重置,请先<a href='/account/forgotpassword'>重置密码</a>再登陆",'place'=>'password');
}
if($row[$this->conf->field->pwd] !== md5($data[$this->conf->field->pwd]))
{
return array('error'=>"密码错误",'place'=>'password');
}
return true;
}else{
return array('error'=>"用户不存在",'place'=>'username');
}
}//checkParam
public function updateStatus(EventInterface $e){
$id = (int)$e->getParam('id');
if(!is_numeric($id))
{
return false;
}
$update = array(
$this->conf->field->lastlogin => date("Y-m-d H:i:s"),
//$this->FieldLastloginIp => $_SERVER["REMOTE_ADDR"]
);
$dbh = new dbh();
@$statusUpdate = $dbh->update($this->conf->table->member,$update," id=$id ");
return true;
}//loginSuccess
public function createAvatar(EventInterface $e){
$email = $e->getParam('email');
$avatar = new Gravatar();
return $avatar->Get($email);
}//loginSuccess
}

View File

@ -1,76 +0,0 @@
<?php
namespace Wbb\Vhome\Member\Handle;
use Sookon\Helpers\PDO as Pdo;
use Sookon\Helpers\Config;
use Sookon\Helpers\View as view;
use Sookon\Mail\Mail;
use Sookon\Search\Search;
use Zend\EventManager\EventInterface;
use Wbb\Vhome\Member\Event\MemberEvent as Event;
class MemberHandle implements Event
{
private $db;
private $config;
function __construct($db = NULL)
{
$this->db = new Pdo();
$this->config = Config::get();
}
//检查字段
public function checkParam(EventInterface $e){
$data = $e->getParam('data');
if(!is_array($data))
{
return "参数错误";
}
if(empty($data["username"]))
{
return "用户名";
}
return true;
}//checkParam
//处理字段
public function processData(EventInterface $e)
{
$data = $e->getParam('data');
if(empty($data['uuid']))
{
unset($data['uuid']);
}
return $data;
}
//注册成功
public function recordPosted(EventInterface $e)
{
$data = $e->getParam('data');
$id = $e->getParam('id');
//view::Dump(array($data,$id,$params));
//return $data;
}
//用户修改
public function recordChanged(EventInterface $e)
{
$data = $e->getParam('data');
$id = $e->getParam('id');
//return $data;
}
}

View File

@ -1,173 +0,0 @@
<?php
namespace Wbb\Vhome\Member\Account\Handle;
use Zend\EventManager\EventInterface;
use Sookon\Mail\Mail;
use Sookon\Helpers\View as view;
use Sookon\Helpers\PDO as Db;
use Sookon\Helpers\Config as GlobalConfig;
use Wbb\Vhome\Member\Account\Event\RegisterEvent as Event;
use Wbb\Vhome\Member\Account\Config;
class RegisterHandle implements Event
{
private $db; //传入PDO对象
private $conf;
private $config;
function __construct($db = NULL)
{
$this->db = new Db();
$this->conf = Config::get();
$this->config = GlobalConfig::get('email');
}
public function checkParam(EventInterface $e){
$data = $e->getParam('data');
if(!is_array($data))
{
return "参数错误";
}
if(empty($data[$this->conf->field->uname]))
{
return array('error'=>"请输入用户名",'place'=> $this->conf->form->uname );
}
if(!empty($data[$this->conf->field->uname]))
{
if(!preg_match("/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/",$data[$this->conf->field->uname]))
{
return array(
'error'=>"用户名应当以字母开头由字母数字和下划线组成并且长度在5到16个字符之间",
'place'=>$this->conf->form->uname
);
}
}
if(empty($data[$this->conf->field->pwd]))
{
return array('error'=>"请输入密码",'place'=>$this->conf->form->pwd);
}
if(strlen($data[$this->conf->field->pwd]) < 6)
{
return array('error'=>"密码长度太短为了安全最少输入6位哦",'place'=>$this->conf->form->pwd);
}
if(strlen($data[$this->conf->field->pwd]) > 14)
{
return array('error'=>"密码太长亲您记得住吗不要超过14位哦",'place'=>$this->conf->form->pwd);
}
if(empty($data[$this->conf->form->c_pwd]))
{
return array('error'=>"请再次输入密码已确认输入正确",'place'=>$this->conf->form->c_pwd);
}
if(md5($data[$this->conf->field->pwd]) != md5($data[$this->conf->form->c_pwd]))
{
return array('error'=>"两次输入的密码不同,请重新输入",'place'=>$this->conf->form->c_pwd);
}
if(empty($data[$this->conf->field->email]))
{
return array('error'=>"请输入电子邮箱,作为找回密码和接受通知的联系方式",'place' => $this->conf->form->email);
}
if (!preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',$data[$this->conf->field->email]))
{
return array('error'=>"请输入正确的电子邮件推荐使用QQ邮箱和Gmail邮箱",'place' => $this->conf->form->email);
}
if(empty($data[$this->conf->field->realname]))
{
return array('error'=>"起个响亮的名号吧",'place'=> $this->conf->form->realname);
}
if(mb_strlen($data[$this->conf->field->realname],"UTF-8")>15 )
{
return array('error'=>":-(这名号也太长了吧不要超过15个字哦",'place'=> $this->conf->form->realname);
}
return true;
}//checkParam
public function checkUser(EventInterface $e){
$data = $e->getParam('data');
if(!is_array($data))
{
return "用户信息验证失败,请重新尝试";
}
$sql = "SELECT
id,{$this->conf->field->uname},{$this->conf->field->email}
FROM {$this->conf->table->member}
WHERE {$this->conf->field->uname}='".$data[$this->conf->field->uname]."'
OR {$this->conf->field->email}='".$data[$this->conf->field->email]."'";
$rs = $this->db->query($sql);
$row = $rs->fetch();
if(isset($row['id']) && !empty($row['id']))
{
if($row[$this->conf->field->uname] == $data[$this->conf->field->uname])
{
return array('error'=>'您的用户名已经注册过账号,您是否<a href="/account/forgotpassword">忘记了密码?</a>','place'=>$this->conf->form->uname);
}
if($row[$this->conf->field->email] == $data[$this->conf->field->email])
{
return array('error'=>'您的邮箱已经注册过账号,请换一个邮箱','place'=>$this->conf->form->email);
}
return array('error'=>'您的用户名或邮箱已经使用过,注册马甲请换一个用户名');
}
return true;
}//checkUser
public function registerSuccess(EventInterface $e){
$data = $e->getParam('data');
if(!is_array($data))
{
return false;
}
$id = $e->getParam('id');
if(!is_numeric($id))
{
return false;
}
$mail_template = $this->config->template->register;
$mail_data = array(
'name'=>$data[$this->conf->field->realname],
'content' => ''
);
$mail = new Mail();
$mail->loadTemplate($mail_template,$mail_data);
$mail->addTo($data[$this->conf->field->email],$data[$this->conf->field->realname]);
$mail->send();
return true;
}//registerSuccess
//邮件内容
public function getMailContent()
{
$content = "";
return $content;
}//getMailContent();
}

View File

@ -1,38 +0,0 @@
<?php
namespace Wbb\Vhome\Member\Listener;
use Zend\EventManager\ListenerAggregateInterface;
use Zend\EventManager\EventManagerInterface;
use Wbb\Vhome\Member\Handle;
class MemberListener implements ListenerAggregateInterface
{
protected $listeners = array();
function __construct()
{
}
public function attach(EventManagerInterface $events)
{
$_Events = new Handle\RegisterHandle();
$this->listeners[] = $events->attach('register.checkParam', array($_Events, 'checkParam'), 100);
$this->listeners[] = $events->attach('register.checkUser', array($_Events, 'checkUser'), 80);
$this->listeners[] = $events->attach('register.success', array($_Events, 'registerSuccess'), 50);
$_Events = new Handle\LoginHandle();
$this->listeners[] = $events->attach('login.checkParam', array($_Events, 'checkParam'), 100);
$this->listeners[] = $events->attach('login.success.updateStatus', array($_Events, 'updateStatus'), 50);
$this->listeners[] = $events->attach('login.success.createAvatar', array($_Events, 'createAvatar'), 50);
}
public function detach(EventManagerInterface $events)
{
foreach ($this->listeners as $index => $listener) {
if ($events->detach($listener)) {
unset($this->listeners[$index]);
}
}
}
}

View File

@ -1,12 +0,0 @@
<?php
namespace Wbb\Vhome\Post\Event;
use Zend\EventManager\EventInterface;
interface PostEvent
{
public function checkParam(EventInterface $e);
public function processData(EventInterface $e);
public function recordPosted(EventInterface $e);
public function recordChanged(EventInterface $e);
}

View File

@ -1,89 +0,0 @@
<?php
namespace Wbb\Vhome\Post\Handle;
use Sookon\Helpers\PDO as Pdo;
use Sookon\Helpers\Config;
use Sookon\Helpers\View as view;
use Sookon\Mail\Mail;
use Sookon\Search\Search;
use Zend\EventManager\EventInterface;
use Wbb\Vhome\Post\Event\PostEvent as Event;
class PostHandle implements Event
{
private $db;
private $config;
function __construct($db = NULL)
{
$this->db = new Pdo();
$this->config = Config::get();
}
//检查字段
public function checkParam(EventInterface $e){
$data = $e->getParam('data');
if(!is_array($data))
{
return "参数错误";
}
if(empty($data["title"]))
{
return "请输入标题";
}
if(empty($data["body"]))
{
return "请输入内容";
}
return true;
}//checkParam
//处理字段
public function processData(EventInterface $e)
{
$data = $e->getParam('data');
if(empty($data['uuid']))
{
unset($data['uuid']);
}
if(empty($data['ts_published']))
{
$data['ts_published'] = date("Y-m-d H:i:s");
}
unset($data['tags']);
unset($data['category']);
return $data;
}
//发布
public function recordPosted(EventInterface $e)
{
$data = $e->getParam('data');
$id = $e->getParam('id');
//view::Dump(array($data,$id,$params));
//return $data;
}
//更改
public function recordChanged(EventInterface $e)
{
$data = $e->getParam('data');
$id = $e->getParam('id');
//return $data;
}
}

View File

@ -1,34 +0,0 @@
<?php
namespace Wbb\Vhome\Post\Listener;
use Zend\EventManager\ListenerAggregateInterface;
use Zend\EventManager\EventManagerInterface;
use Wbb\Vhome\Post\Handle as Handle;
class PostListener implements ListenerAggregateInterface
{
protected $listeners = array();
function __construct()
{
}
public function attach(EventManagerInterface $events)
{
$_Events = new Handle;
$this->listeners[] = $events->attach('submit.checkParam', array($_Events, 'checkParam'), 100);
$this->listeners[] = $events->attach('submit.processData', array($_Events, 'processData'), 100);
$this->listeners[] = $events->attach('submit.recordPosted', array($_Events, 'recordPosted'), 100);
$this->listeners[] = $events->attach('submit.recordChanged', array($_Events, 'recordChanged'), 100);
}
public function detach(EventManagerInterface $events)
{
foreach ($this->listeners as $index => $listener) {
if ($events->detach($listener)) {
unset($this->listeners[$index]);
}
}
}
}