Пример #1
0
 /**
  * Request the api.
  * 
  * @param  string $moduleName 
  * @param  string $methodName 
  * @param  string $action 
  * @access public
  * @return void
  */
 public function request($moduleName, $methodName, $action)
 {
     $host = common::getSysURL() . $this->config->webRoot;
     $param = '';
     if ($action == 'extendModel') {
         if (!isset($_POST['noparam'])) {
             foreach ($_POST as $key => $value) {
                 $param .= ',' . $key . '=' . $value;
             }
             $param = ltrim($param, ',');
         }
         $url = rtrim($host, '/') . inlink('getModel', "moduleName={$moduleName}&methodName={$methodName}&params={$param}", 'json');
         $url .= $this->config->requestType == "PATH_INFO" ? '?' : '&';
         $url .= $this->config->sessionVar . '=' . session_id();
     } else {
         if (!isset($_POST['noparam'])) {
             foreach ($_POST as $key => $value) {
                 $param .= '&' . $key . '=' . $value;
             }
             $param = ltrim($param, '&');
         }
         $url = rtrim($host, '/') . helper::createLink($moduleName, $methodName, $param, 'json');
         $url .= $this->config->requestType == "PATH_INFO" ? '?' : '&';
         $url .= $this->config->sessionVar . '=' . session_id();
     }
     /* Unlock session. After new request, restart session. */
     session_write_close();
     $content = file_get_contents($url);
     session_start();
     return array('url' => $url, 'content' => $content);
 }
Пример #2
0
 /**
  * SSO login.
  * 
  * @param  string $type 
  * @access public
  * @return void
  */
 public function login($type = 'notify')
 {
     $referer = empty($_GET['referer']) ? '' : $this->get->referer;
     $locate = empty($referer) ? getWebRoot() : base64_decode($referer);
     if ($this->loadModel('user')->isLogon()) {
         die($this->locate($locate));
     }
     $this->app->loadConfig('sso');
     if (!$this->config->sso->turnon) {
         die($this->locate($locate));
     }
     $userIP = $this->server->remote_addr;
     $code = $this->config->sso->code;
     $key = $this->config->sso->key;
     if ($type != 'return') {
         $token = $this->get->token;
         $auth = md5($code . $userIP . $token . $key);
         $callback = urlencode(common::getSysURL() . inlink('login', "type=return"));
         $location = $this->config->sso->addr;
         if (strpos($location, '&') !== false) {
             $location = rtrim($location, '&') . "&token={$token}&auth={$auth}&userIP={$userIP}&callback={$callback}&referer={$referer}";
         } else {
             $location = rtrim($location, '?') . "?token={$token}&auth={$auth}&userIP={$userIP}&callback={$callback}&referer={$referer}";
         }
         $this->locate($location);
     }
     if ($this->get->status == 'success' and md5($this->get->data) == $this->get->md5) {
         $last = $this->server->request_time;
         $data = json_decode(base64_decode($this->get->data));
         $token = $data->token;
         if ($data->auth == md5($code . $userIP . $token . $key)) {
             $user = $this->sso->getBindUser($data->account);
             if (!$user) {
                 $this->session->set('ssoData', $data);
                 $this->locate($this->createLink('sso', 'bind', "referer=" . helper::safe64Encode($locate)));
             }
             $this->user->cleanLocked($user->account);
             /* Authorize him and save to session. */
             $user->rights = $this->user->authorize($user->account);
             $user->groups = $this->user->getGroups($user->account);
             $this->dao->update(TABLE_USER)->set('visits = visits + 1')->set('ip')->eq($userIP)->set('last')->eq($last)->where('account')->eq($user->account)->exec();
             $user->last = date(DT_DATETIME1, $last);
             $this->session->set('user', $user);
             $this->app->user = $this->session->user;
             $this->loadModel('action')->create('user', $user->id, 'login');
             die($this->locate($locate));
         }
     }
     $this->locate($this->createLink('user', 'login', empty($referer) ? '' : "referer={$referer}"));
 }
Пример #3
0
 /**
  * Export the stories of release to HTML.
  * 
  * @param  string $type story | bug
  * @access public
  * @return void
  */
 public function export()
 {
     if (!empty($_POST)) {
         $type = $this->post->type;
         $html = '';
         if ($type == 'story' or $type == 'all') {
             $html .= "<h3>{$this->lang->release->stories}</h3>";
             $this->loadModel('story');
             $stories = $this->dao->select('id, title')->from(TABLE_STORY)->where($this->session->storyQueryCondition)->beginIF($this->session->storyOrderBy != false)->orderBy($this->session->storyOrderBy)->fi()->fetchAll('id');
             foreach ($stories as $story) {
                 $story->title = "<a href='" . common::getSysURL() . $this->createLink('story', 'view', "storyID={$story->id}") . "' target='_blank'>{$story->title}</a>";
             }
             $fields = array('id' => $this->lang->story->id, 'title' => $this->lang->story->title);
             $rows = $stories;
             $html .= '<table><tr>';
             foreach ($fields as $fieldLabel) {
                 $html .= "<th><nobr>{$fieldLabel}</nobr></th>\n";
             }
             $html .= '</tr>';
             foreach ($rows as $row) {
                 $html .= "<tr valign='top'>\n";
                 foreach ($fields as $fieldName => $fieldLabel) {
                     $fieldValue = isset($row->{$fieldName}) ? $row->{$fieldName} : '';
                     $html .= "<td><nobr>{$fieldValue}</nobr></td>\n";
                 }
                 $html .= "</tr>\n";
             }
             $html .= '</table>';
         }
         if ($type == 'bug' or $type == 'all') {
             $html .= "<h3>{$this->lang->release->bugs}</h3>";
             $this->loadModel('bug');
             $bugs = $this->dao->select('id, title')->from(TABLE_BUG)->where($this->session->linkedBugQueryCondition)->beginIF($this->session->bugOrderBy != false)->orderBy($this->session->bugOrderBy)->fi()->fetchAll('id');
             foreach ($bugs as $bug) {
                 $bug->title = "<a href='" . common::getSysURL() . $this->createLink('bug', 'view', "bugID={$bug->id}") . "' target='_blank'>{$bug->title}</a>";
             }
             $fields = array('id' => $this->lang->bug->id, 'title' => $this->lang->bug->title);
             $rows = $bugs;
             $html .= '<table><tr>';
             foreach ($fields as $fieldLabel) {
                 $html .= "<th><nobr>{$fieldLabel}</nobr></th>\n";
             }
             $html .= '</tr>';
             foreach ($rows as $row) {
                 $html .= "<tr valign='top'>\n";
                 foreach ($fields as $fieldName => $fieldLabel) {
                     $fieldValue = isset($row->{$fieldName}) ? $row->{$fieldName} : '';
                     $html .= "<td><nobr>{$fieldValue}</nobr></td>\n";
                 }
                 $html .= "</tr>\n";
             }
             $html .= '</table>';
         }
         if ($type == 'newbug' or $type == 'all') {
             $html .= "<h3>{$this->lang->release->generatedBugs}</h3>";
             $bugs = $this->dao->select('id, title')->from(TABLE_BUG)->where($this->session->newBugsQueryCondition)->beginIF($this->session->bugOrderBy != false)->orderBy($this->session->bugOrderBy)->fi()->fetchAll('id');
             foreach ($bugs as $bug) {
                 $bug->title = "<a href='" . common::getSysURL() . $this->createLink('bug', 'view', "bugID={$bug->id}") . "' target='_blank'>{$bug->title}</a>";
             }
             $fields = array('id' => $this->lang->bug->id, 'title' => $this->lang->bug->title);
             $rows = $bugs;
             $html .= '<table><tr>';
             foreach ($fields as $fieldLabel) {
                 $html .= "<th><nobr>{$fieldLabel}</nobr></th>\n";
             }
             $html .= '</tr>';
             foreach ($rows as $row) {
                 $html .= "<tr valign='top'>\n";
                 foreach ($fields as $fieldName => $fieldLabel) {
                     $fieldValue = isset($row->{$fieldName}) ? $row->{$fieldName} : '';
                     $html .= "<td><nobr>{$fieldValue}</nobr></td>\n";
                 }
                 $html .= "</tr>\n";
             }
             $html .= '</table>';
         }
         $html = "<html><head><meta charset='utf-8'><title>{$this->post->fileName}</title><style>table, th, td{font-size:12px; border:1px solid gray; border-collapse:collapse;}</style></head><body>{$html}</body></html>";
         die($this->fetch('file', 'sendDownHeader', array('fileName' => $this->post->fileName, 'html', $html)));
     }
     $this->display();
 }
Пример #4
0
 /**
  * Get System URL.
  * 
  * @access public
  * @return void
  */
 public function getSysURL()
 {
     /* Ger URL when run in shell. */
     if (PHP_SAPI == 'cli') {
         $url = parse_url(trim($this->server->argv[1]));
         $port = (empty($url['port']) or $url['port'] == 80) ? '' : $url['port'];
         $host = empty($port) ? $url['host'] : $url['host'] . ':' . $port;
         return $url['scheme'] . '://' . $host;
     } else {
         return common::getSysURL();
     }
 }
Пример #5
0
 /**
  * User login, identify him and authorize him.
  * 
  * @access public
  * @return void
  */
 public function login($referer = '', $from = '')
 {
     $this->setReferer($referer);
     $loginLink = $this->createLink('user', 'login');
     $denyLink = $this->createLink('user', 'deny');
     /* Reload lang by lang of get when viewType is json. */
     if ($this->app->getViewType() == 'json' and $this->get->lang and $this->get->lang != $this->app->getClientLang()) {
         $this->app->setClientLang($this->get->lang);
         $this->app->loadLang('user');
     }
     /* If user is logon, back to the rerferer. */
     if ($this->user->isLogon()) {
         if ($this->app->getViewType() == 'json') {
             $data = $this->user->getDataInJSON($this->app->user);
             die(helper::removeUTF8Bom(json_encode(array('status' => 'success') + $data)));
         }
         if (strpos($this->referer, $loginLink) === false and strpos($this->referer, $denyLink) === false and $this->referer) {
             die(js::locate($this->referer, 'parent'));
         } else {
             die(js::locate($this->createLink($this->config->default->module), 'parent'));
         }
     }
     /* Passed account and password by post or get. */
     if (!empty($_POST) or isset($_GET['account']) and isset($_GET['password'])) {
         $account = '';
         $password = '';
         if ($this->post->account) {
             $account = $this->post->account;
         }
         if ($this->get->account) {
             $account = $this->get->account;
         }
         if ($this->post->password) {
             $password = $this->post->password;
         }
         if ($this->get->password) {
             $password = $this->get->password;
         }
         if ($this->user->checkLocked($account)) {
             $failReason = sprintf($this->lang->user->loginLocked, $this->config->user->lockMinutes);
             if ($this->app->getViewType() == 'json') {
                 die(helper::removeUTF8Bom(json_encode(array('status' => 'failed', 'reason' => $failReason))));
             }
             die(js::error($failReason));
         }
         $user = $this->user->identify($account, $password);
         if ($user) {
             $this->user->cleanLocked($account);
             /* Authorize him and save to session. */
             $user->rights = $this->user->authorize($account);
             $user->groups = $this->user->getGroups($account);
             $this->session->set('user', $user);
             $this->app->user = $this->session->user;
             $this->loadModel('action')->create('user', $user->id, 'login');
             /* Keep login. */
             if ($this->post->keepLogin) {
                 $this->user->keepLogin($user);
             }
             /* Check password. */
             if (isset($this->config->safe->mode) and $this->user->computePasswordStrength($password) < $this->config->safe->mode) {
                 echo js::alert($this->lang->user->weakPassword);
             }
             /* Go to the referer. */
             if ($this->post->referer and strpos($this->post->referer, $loginLink) === false and strpos($this->post->referer, $denyLink) === false) {
                 if ($this->app->getViewType() == 'json') {
                     $data = $this->user->getDataInJSON($user);
                     die(helper::removeUTF8Bom(json_encode(array('status' => 'success') + $data)));
                 }
                 /* Get the module and method of the referer. */
                 if ($this->config->requestType == 'PATH_INFO') {
                     $path = substr($this->post->referer, strrpos($this->post->referer, '/') + 1);
                     $path = rtrim($path, '.html');
                     if (empty($path)) {
                         $path = $this->config->requestFix;
                     }
                     list($module, $method) = explode($this->config->requestFix, $path);
                 } else {
                     $url = html_entity_decode($this->post->referer);
                     $param = substr($url, strrpos($url, '?') + 1);
                     list($module, $method) = explode('&', $param);
                     $module = str_replace('m=', '', $module);
                     $method = str_replace('f=', '', $method);
                 }
                 if (common::hasPriv($module, $method)) {
                     die(js::locate($this->post->referer, 'parent'));
                 } else {
                     die(js::locate($this->createLink($this->config->default->module), 'parent'));
                 }
             } else {
                 if ($this->app->getViewType() == 'json') {
                     $data = $this->user->getDataInJSON($user);
                     die(helper::removeUTF8Bom(json_encode(array('status' => 'success') + $data)));
                 }
                 die(js::locate($this->createLink($this->config->default->module), 'parent'));
             }
         } else {
             $fails = $this->user->failPlus($account);
             if ($this->app->getViewType() == 'json') {
                 die(helper::removeUTF8Bom(json_encode(array('status' => 'failed', 'reason' => $this->lang->user->loginFailed))));
             }
             $remainTimes = $this->config->user->failTimes - $fails;
             if ($remainTimes <= 0) {
                 die(js::error(sprintf($this->lang->user->loginLocked, $this->config->user->lockMinutes)));
             } else {
                 if ($remainTimes <= 3) {
                     die(js::error(sprintf($this->lang->user->lockWarning, $remainTimes)));
                 }
             }
             die(js::error($this->lang->user->loginFailed));
         }
     } else {
         if (!empty($this->config->global->showDemoUsers)) {
             $demoUsers = $this->user->getPairs('nodeleted, noletter, noempty, noclosed');
             $this->view->demoUsers = $demoUsers;
         }
         $this->app->loadLang('misc');
         $this->view->noGDLib = sprintf($this->lang->misc->noGDLib, common::getSysURL() . $this->config->webRoot);
         $this->view->title = $this->lang->user->login;
         $this->view->referer = $this->referer;
         $this->view->s = zget($this->config->global, 'sn');
         $this->view->keepLogin = $this->cookie->keepLogin ? $this->cookie->keepLogin : '******';
         $this->display();
     }
 }
Пример #6
0
/**
 * The mail file of bug module of ZenTaoPMS.
 *
 * @copyright   Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
 * @license     LGPL (http://www.gnu.org/licenses/lgpl.html)
 * @author      Chunsheng Wang <*****@*****.**>
 * @package     bug
 * @version     $Id: sendmail.html.php 2963 2012-05-22 01:08:20Z chencongzhi520@gmail.com $
 * @link        http://www.zentao.net
 */
?>
<table width='98%' align='center'>
  <tr class='header'>
    <td>
      BUG #<?php 
echo $bug->id . "=>{$bug->assignedTo} " . html::a(common::getSysURL() . $this->createLink('bug', 'view', "bugID={$bug->id}"), $bug->title);
?>
    </td>
  </tr>
  <tr>
    <td>
    <fieldset>
      <legend><?php 
echo $lang->bug->legendSteps;
?>
</legend>
      <div class='content'>
      <?php 
if (strpos($bug->steps, '<img src="data/upload')) {
    $bug->steps = str_replace('<img src="', '<img src="http://' . $this->server->http_host . $this->config->webRoot, $bug->steps);
}
Пример #7
0
 /**
  * export as html format
  * 
  * @access public
  * @return void
  */
 public function export2HTML()
 {
     $this->view->fields = $this->post->fields;
     $this->view->rows = $this->post->rows;
     $this->host = common::getSysURL();
     switch ($this->post->kind) {
         case 'task':
             foreach ($this->view->rows as $row) {
                 $row->name = html::a($this->host . $this->createLink('task', 'view', "taskID={$row->id}"), $row->name);
             }
             break;
         case 'story':
             foreach ($this->view->rows as $row) {
                 $row->title = html::a($this->host . $this->createLink('story', 'view', "storyID={$row->id}"), $row->title);
             }
             break;
         case 'bug':
             foreach ($this->view->rows as $row) {
                 $row->title = html::a($this->host . $this->createLink('bug', 'view', "bugID={$row->id}"), $row->title);
             }
             break;
         case 'testcase':
             foreach ($this->view->rows as $row) {
                 $row->title = html::a($this->host . $this->createLink('testcase', 'view', "caseID={$row->id}"), $row->title);
             }
             break;
     }
     $this->view->fileName = $this->post->fileName;
     $output = $this->parse('file', 'export2Html');
     $this->sendDownHeader($this->post->fileName, 'html', $output);
 }
Пример #8
0
/**
 * The mail file of task module of ZenTaoPMS.
 *
 * @copyright   Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
 * @license     LGPL (http://www.gnu.org/licenses/lgpl.html)
 * @author      Yangyang Shi<*****@*****.**>
 * @package     task
 * @version     $Id$
 * @link        http://www.zentao.net
 */
?>
<table width='98%' align='center'>
  <tr class='header'>
    <td>
      TASK #<?php 
echo $task->id . "=>{$task->assignedTo} " . html::a(common::getSysURL() . $this->createLink('task', 'view', "taskID={$task->id}"), $task->name);
?>
    </td>
  </tr>
  <tr>
    <td>
    <fieldset>
      <legend><?php 
echo $lang->task->legendDesc;
?>
</legend>
      <div class='content'>
      <?php 
if (strpos($task->desc, '<img src="data/upload')) {
    $task->desc = str_replace('<img src="', '<img src="http://' . $this->server->http_host . $this->config->webRoot, $task->desc);
}
Пример #9
0
 /**
  * Export the stories of release to HTML.
  * 
  * @param  string $type story | bug
  * @access public
  * @return void
  */
 public function export($type)
 {
     if (!empty($_POST)) {
         if ($type == 'story') {
             $this->loadModel('story');
             $stories = $this->dao->select('id, title')->from(TABLE_STORY)->where($this->session->storyQueryCondition)->beginIF($this->session->storyOrderBy != false)->orderBy($this->session->storyOrderBy)->fi()->fetchAll('id');
             foreach ($stories as $story) {
                 $story->title = "<a href='" . common::getSysURL() . $this->createLink('story', 'view', "storyID={$story->id}") . "' target='_blank'>{$story->title}</a>";
             }
             $this->post->set('fields', array('id' => $this->lang->story->id, 'title' => $this->lang->story->title));
             $this->post->set('rows', $stories);
             $this->fetch('file', 'export2HTML', $_POST);
         } else {
             if ($type == 'bug') {
                 $this->loadModel('bug');
                 $bugs = $this->dao->select('id, title')->from(TABLE_BUG)->where($this->session->linkedBugQueryCondition)->beginIF($this->session->bugOrderBy != false)->orderBy($this->session->bugOrderBy)->fi()->fetchAll('id');
                 foreach ($bugs as $bug) {
                     $bug->title = "<a href='" . common::getSysURL() . $this->createLink('bug', 'view', "bugID={$bug->id}") . "' target='_blank'>{$bug->title}</a>";
                 }
                 $this->post->set('fields', array('id' => $this->lang->bug->id, 'title' => $this->lang->bug->title));
                 $this->post->set('rows', $bugs);
                 $this->fetch('file', 'export2HTML', $_POST);
             } else {
                 if ($type == 'newBugs') {
                     $this->loadModel('bug');
                     $bugs = $this->dao->select('id, title')->from(TABLE_BUG)->where($this->session->newBugsQueryCondition)->beginIF($this->session->bugOrderBy != false)->orderBy($this->session->bugOrderBy)->fi()->fetchAll('id');
                     foreach ($bugs as $bug) {
                         $bug->title = "<a href='" . common::getSysURL() . $this->createLink('bug', 'view', "bugID={$bug->id}") . "' target='_blank'>{$bug->title}</a>";
                     }
                     $this->post->set('fields', array('id' => $this->lang->bug->id, 'title' => $this->lang->bug->title));
                     $this->post->set('rows', $bugs);
                     $this->fetch('file', 'export2HTML', $_POST);
                 }
             }
         }
     }
     $this->display();
 }
Пример #10
0
 * @license     LGPL (http://www.gnu.org/licenses/lgpl.html)
 * @author      Chunsheng Wang <*****@*****.**>
 * @package     bug
 * @version     $Id: sendmail.html.php 3717 2012-12-10 00:37:07Z zhujinyonging@gmail.com $
 * @link        http://www.zentao.net
 */
$onlybody = isonlybody() ? true : false;
if ($onlybody) {
    $_GET['onlybody'] = 'no';
}
?>
<table width='98%' align='center'>
  <tr class='header'>
    <td>
      TESTTASK #<?php 
echo $testtask->id . "=>{$testtask->owner} " . html::a(common::getSysURL() . $this->createLink('testtask', 'view', "testtaskID={$testtask->id}"), $testtask->name);
?>
    </td>
  </tr>
  <tr>
    <td>
    <fieldset>
      <legend><?php 
echo $lang->testtask->desc;
?>
</legend>
      <div class='content'><?php 
echo $testtask->desc;
?>
</div>
    </fieldset>
Пример #11
0
 * @license     ZPL (http://zpl.pub/page/zplv12.html)
 * @author      Chunsheng Wang <*****@*****.**>
 * @package     bug
 * @version     $Id: sendmail.html.php 4129 2013-01-18 01:58:14Z wwccss $
 * @link        http://www.zentao.net
 */
$onlybody = isonlybody() ? true : false;
if ($onlybody) {
    $_GET['onlybody'] = 'no';
}
?>
<table width='98%' align='center'>
  <tr class='header'>
    <td>
      STORY #<?php 
echo $story->id . "=>{$story->assignedTo} " . html::a(common::getSysURL() . $this->createLink('story', 'view', "storyID={$story->id}"), $story->title);
?>
    </td>
  </tr>
  <tr>
    <td>
    <fieldset>
      <legend><?php 
echo $lang->story->legendSpec;
?>
</legend>
      <div class='content'><?php 
echo $story->spec;
?>
</div>
    </fieldset>
Пример #12
0
<h1 class="caption"><?php 
echo $lang->info->mailModify;
?>
</h1>
<table width='98%' align='center'>
  <tr class='header'>
    <td>
      INFO #<?php 
echo $info->id . html::a(common::getSysURL() . $this->createLink('info', 'view', "infoID={$info->id}"), $info->title);
?>
    </td>
  </tr>
  <tr>
    <td><?php 
include '../../common/view/mail.html.php';
?>
</td>
  </tr>
</table>
<h1 class="caption"><?php 
echo $lang->info->mailMain;
?>
</h1>
<table width='98%' align='center'>
  <tr>
    <td class="content"><?php 
echo $info->content;
?>
</td>
  </tr>
</table>
Пример #13
0
 /**
  * Create qrcode for mobile login.
  * 
  * @access public
  * @return void
  */
 public function qrCode()
 {
     $loginAPI = common::getSysURL() . $this->config->webRoot;
     $session = $this->loadModel('user')->isLogon() ? '?sid=' . session_id() : '';
     if (!extension_loaded('gd')) {
         $this->view->noGDLib = sprintf($this->lang->misc->noGDLib, $loginAPI);
         die($this->display());
     }
     $this->app->loadClass('qrcode');
     QRcode::png($loginAPI . $session, false, 4, 9);
 }
Пример #14
0
 /**
  * Create qrcode for mobile login.
  * 
  * @access public
  * @return void
  */
 public function qrCode()
 {
     $loginAPI = common::getSysURL() . $this->config->webRoot;
     if ($this->loadModel('user')->isLogon()) {
         $loginAPI .= "?sid=" . session_ID();
     }
     if (!extension_loaded('gd')) {
         die(printf($this->lang->misc->noGDLib, $loginAPI));
     }
     $ciqrcode = $this->app->loadClass('qrcode');
     QRcode::png($loginAPI, false, 4, 9);
 }
Пример #15
0
 /**
  * User login, identify him and authorize him.
  * 
  * @access public
  * @return void
  */
 public function login($referer = '', $from = '')
 {
     $this->setReferer($referer);
     $loginLink = $this->createLink('user', 'login');
     $denyLink = $this->createLink('user', 'deny');
     /* If user is logon, back to the rerferer. */
     if ($this->user->isLogon()) {
         if (strpos($this->referer, $loginLink) === false and strpos($this->referer, $denyLink) === false) {
             $this->locate($this->referer);
         } else {
             $this->locate($this->createLink($this->config->default->module));
         }
     }
     /* Passed account and password by post or get. */
     if (!empty($_POST) or isset($_GET['account']) and isset($_GET['password'])) {
         $account = '';
         $password = '';
         if ($this->post->account) {
             $account = $this->post->account;
         }
         if ($this->get->account) {
             $account = $this->get->account;
         }
         if ($this->post->password) {
             $password = $this->post->password;
         }
         if ($this->get->password) {
             $password = $this->get->password;
         }
         if ($this->user->checkLocked($account)) {
             die(js::error(sprintf($this->lang->user->loginLocked, $this->config->user->lockMinutes)));
         }
         $user = $this->user->identify($account, $password);
         if ($user) {
             $this->user->cleanLocked($account);
             /* Authorize him and save to session. */
             $user->rights = $this->user->authorize($account);
             $user->groups = $this->user->getGroups($account);
             $this->session->set('user', $user);
             $this->app->user = $this->session->user;
             $this->loadModel('action')->create('user', $user->id, 'login');
             /* Keep login. */
             if ($this->post->keepLogin) {
                 $this->user->keepLogin($user);
             }
             $isDefult = $this->dao->select('password')->from(TABLE_DEFAULTPASSWORD)->Where('password')->eq($password)->fetchAll();
             //如果用户使用默认密码则跳到修改密码界面
             if ($isDefult) {
                 die(js::locate($this->createLink('my', 'changePassword', 'type=type'), 'parent'));
             }
             /* Go to the referer. */
             if ($this->post->referer and strpos($this->post->referer, $loginLink) === false and strpos($this->post->referer, $denyLink) === false) {
                 if ($this->app->getViewType() == 'json') {
                     die(json_encode(array('status' => 'success')));
                 }
                 /* Get the module and method of the referer. */
                 if ($this->config->requestType == 'PATH_INFO') {
                     $path = substr($this->post->referer, strrpos($this->post->referer, '/') + 1);
                     $path = rtrim($path, '.html');
                     if (empty($path)) {
                         $path = $this->config->requestFix;
                     }
                     list($module, $method) = explode($this->config->requestFix, $path);
                 } else {
                     $url = html_entity_decode($this->post->referer);
                     $param = substr($url, strrpos($url, '?') + 1);
                     list($module, $method) = explode('&', $param);
                     $module = str_replace('m=', '', $module);
                     $method = str_replace('f=', '', $method);
                 }
                 if (common::hasPriv($module, $method)) {
                     die(js::locate($this->post->referer, 'parent'));
                 } else {
                     die(js::locate($this->createLink($this->config->default->module), 'parent'));
                 }
             } else {
                 if ($this->app->getViewType() == 'json') {
                     die(json_encode(array('status' => 'success')));
                 }
                 die(js::locate($this->createLink($this->config->default->module), 'parent'));
             }
         } else {
             if ($this->app->getViewType() == 'json') {
                 die(json_encode(array('status' => 'failed')));
             }
             $fails = $this->user->failPlus($account);
             $remainTimes = $this->config->user->failTimes - $fails;
             if ($remainTimes <= 0) {
                 die(js::error(sprintf($this->lang->user->loginLocked, $this->config->user->lockMinutes)));
             } else {
                 if ($remainTimes <= 3) {
                     die(js::error(sprintf($this->lang->user->lockWarning, $remainTimes)));
                 }
             }
             die(js::error($this->lang->user->loginFailed));
         }
     } else {
         if (!empty($this->config->global->showDemoUsers)) {
             $demoUsers = $this->user->getPairs('nodeleted, noletter, noempty, noclosed');
             $this->view->demoUsers = $demoUsers;
         }
         $this->app->loadLang('misc');
         $this->view->noGDLib = sprintf($this->lang->misc->noGDLib, common::getSysURL() . $this->config->webRoot);
         $this->view->title = $this->lang->user->login;
         $this->view->referer = $this->referer;
         $this->view->s = zget($this->config->global, 'sn');
         $this->view->keepLogin = $this->cookie->keepLogin ? $this->cookie->keepLogin : '******';
         $this->display();
     }
 }