Skip to content

Commit dfd912a

Browse files
committed
累积更新
1 parent b50eadd commit dfd912a

File tree

8 files changed

+436
-362
lines changed

8 files changed

+436
-362
lines changed

server/apps/classes/FrontPage.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,13 @@ function getActiveUsers($num = 10)
133133
$_mblog = createModel('MicroBlog');
134134
$_user = createModel('UserInfo');
135135
$table = $_mblog->table;
136-
$uids = $this->swoole->db->query("select uid from $table order by id desc limit 500")->fetchall();
136+
$uids = $this->swoole->db->query("select distinct uid from $table order by id desc limit 20")->fetchall();
137137
foreach($uids as $u)
138138
{
139-
$_uids[$u['uid']] = 1;
139+
$_uids[] = $u['uid'];
140140
}
141-
$gets['select'] = 'id,nickname,avatar';
142-
$gets['in'] = array('id', implode(',', array_keys($_uids)));
143-
$_users = $_user->getMap($gets);
144-
$new = array();
145-
foreach($_uids as $uid=>$u)
146-
{
147-
$new[] = $_users[$uid];
148-
}
149-
return $new;
141+
$gets['select'] = 'id, nickname, avatar';
142+
$gets['in'] = array('id', $_uids);
143+
return $_user->getMap($gets);
150144
}
151145
}

server/apps/controllers/Page.php

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace App\Controller;
33
use App;
44
use Swoole;
5+
use ZenAPI\Exception;
56
use ZenAPI\QqClient;
67
use ZenAPI\QqOAuth2;
78

@@ -55,25 +56,28 @@ function callback_weibo()
5556
//不存在,则插入数据库
5657
if (!$u->exist())
5758
{
58-
$u['username'] = $username;
59-
$u['nickname'] = $userinfo['name'];
60-
$u['avatar'] = $userinfo['avatar_large'];
61-
$u['blog'] = $userinfo['url'];
62-
list($u['province'], $u['city']) = explode(' ', $userinfo['location']);
59+
$user['username'] = $username;
60+
$user['nickname'] = $userinfo['name'];
61+
$user['avatar'] = $userinfo['avatar_large'];
62+
$user['blog'] = $userinfo['url'];
63+
list($user['province'], $user['city']) = explode(' ', $userinfo['location']);
6364
//插入到表中
64-
$u['id'] = $model->put($u);
65+
$user['id'] = $model->put($user);
66+
$uid = $user['id'];
6567
}
6668
else
6769
{
6870
$u->nickname = $userinfo['name'];
6971
$u->avatar = $userinfo['avatar_large'];
7072
$u->blog = $userinfo['url'];
7173
$u->save();
74+
$user = $u->get();
75+
$uid = $user['id'];
7276
}
7377
//写入SESSION
7478
$_SESSION['isLogin'] = 1;
75-
$_SESSION['user_id'] = $u['id'];
76-
$_SESSION['user'] = $u;
79+
$_SESSION['user_id'] = $uid;
80+
$_SESSION['user'] = $user;
7781
$this->setLoginStat();
7882
$this->http->redirect(WEBROOT."/person/index/");
7983
}
@@ -98,6 +102,11 @@ function callback_qq()
98102
if ($token)
99103
{
100104
$openid = $oauth->getOpenid($token['access_token']);
105+
if (empty($openid['openid']))
106+
{
107+
return "请求错误. 错误码:{$openid['ret']}\n";
108+
}
109+
101110
$_SESSION['qq_token'] = $token;
102111
$client = new QqClient($token['access_token'], $conf['appid'], $openid['openid']);
103112
$userinfo = $client->get('user/get_user_info');
@@ -106,21 +115,25 @@ function callback_qq()
106115
return "请求错误. 错误码:{$userinfo['ret']}\n";
107116
}
108117
$model = createModel('UserInfo');
109-
$username = $openid['openid'];
118+
$username = trim($openid['openid']);
119+
if (empty($username))
120+
{
121+
throw new Exception("QQ登录出错了");
122+
}
110123
$u = $model->get($username, 'username');
111124
//不存在,则插入数据库
112125
if (!$u->exist())
113126
{
114-
$u['username'] = $username;
115-
$u['nickname'] = $userinfo['nickname'];
116-
$u['avatar'] = $userinfo['figureurl_2'];
117-
$u['birth_year'] = $userinfo['year'];
118-
$u['province'] = $userinfo['province'];
119-
$u['city'] = $userinfo['city'];
120-
$u['sex'] = $userinfo['gender'] == '' ? 1 : 2;
127+
$user['username'] = $username;
128+
$user['nickname'] = $userinfo['nickname'];
129+
$user['avatar'] = $userinfo['figureurl_2'];
130+
$user['birth_year'] = $userinfo['year'];
131+
$user['province'] = $userinfo['province'];
132+
$user['city'] = $userinfo['city'];
133+
$user['sex'] = $userinfo['gender'] == '' ? 1 : 2;
121134
//插入到表中
122-
$u['id'] = $model->put($u);
123-
$uid = $u['id'];
135+
$user['id'] = $model->put($user);
136+
$uid = $user['id'];
124137
}
125138
else
126139
{
@@ -129,12 +142,13 @@ function callback_qq()
129142
$u->province = $userinfo['province'];
130143
$u->city = $userinfo['city'];
131144
$u->save();
132-
$uid = $u->get()['id'];
145+
$user = $u->get();
146+
$uid = $user['id'];
133147
}
134148
//写入SESSION
135149
$_SESSION['isLogin'] = 1;
136150
$_SESSION['user_id'] = $uid;
137-
$_SESSION['user'] = $u;
151+
$_SESSION['user'] = $user;
138152
$this->setLoginStat();
139153
$this->http->redirect(WEBROOT."/person/index/");
140154
}
@@ -176,6 +190,7 @@ function flist()
176190
$this->swoole->tpl->assign('ltitle',$ftype['typename']);
177191
$this->swoole->tpl->display('page_news_index.html');
178192
}
193+
179194
function detail()
180195
{
181196
$pagenews = $this->swoole->model->CmsNews->get((int)$_GET['d'])->get();
@@ -537,5 +552,6 @@ private function setLoginStat()
537552
$user = $this->model->UserInfo->get($_SESSION['user_id']);
538553
$user->lastlogin = Swoole\Tool::now();
539554
$user->lastip = $this->request->getClientIP();
555+
$user->save();
540556
}
541557
}

server/apps/controllers/Wiki.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ function edit()
257257
'uid' => $uid,
258258
'content' => $cont->content,
259259
'title' => $cont->title,
260+
'project_id' => $node->project_id,
260261
'version' => intval($cont->version),
261262
));
262263
//增加版本号

server/apps/controllers/Wiki_admin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ function create()
492492
'uid' => $this->uid,
493493
'content' => $_POST['content'],
494494
'title' => $in['text'],
495+
'project_id' => $this->project_id,
495496
'version' => 0,
496497
));
497498
$this->reflushPage('增加成功');
@@ -655,6 +656,7 @@ function modify()
655656
'uid' => $this->uid,
656657
'content' => $cont->content,
657658
'title' => $cont->title,
659+
'project_id' => $this->project_id,
658660
'version' => intval($cont->version),
659661
));
660662
//增加版本号

server/apps/templates/mblog_index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ <h3 style="margin-left:5px;">最活跃微博主</h3>
3333

3434
{{foreach from=$users item=v}}
3535
<div style="clear:both;">
36-
<div class="userPic" style="margin-bottom:12px;"> <a href="/page/user/uid-{{$v.uid}}"><img class="avatar photo" src="{{$v.avatar|default:'/static/images/default.png'}}" /></a> </div>
37-
<a href="/page/user/uid-{{$v.uid}}" class="f12">{{$v.nickname}}</a>
36+
<div class="userPic" style="margin-bottom:12px;"> <a href="/page/user/uid-{{$v.id}}">
37+
<img class="avatar photo" src="{{$v.avatar|default:'/static/images/default.png'}}" /></a> </div>
38+
<a href="/page/user/uid-{{$v.id}}" class="f12">{{$v.nickname}}</a>
3839
</div>
3940
{{/foreach}}
4041
</div>

server/apps/templates/wiki_admin/diff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<title>比较_Swoole文档中心</title>
2727
</head>
2828
<body>
29-
<div class="main_right">
29+
<div class="main_right" style="width: 96%">
3030
<style type="text/css">
3131
td {
3232
vertical-align: middle !important;

server/apps/templates/wiki_admin/top.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
<?php endforeach; ?>
2020
</ul>
2121
<div class="btn-group" style="margin-left: 600px;line-height: 50px;">
22+
23+
<a href="/wiki_admin/update_list/" class="small" target="main">
24+
<span class="glyphicon glyphicon-list"></span> 更新列表</a>
25+
<span style="color: #fff; margin-left: 10px;margin-right: 10px;">|</span>
2226
<a href="/wiki_admin/setting/prid-<?=$project_id?>" class="small" target="main">
2327
<span class="glyphicon glyphicon-th"></span> 项目设置</a>
2428
<span style="color: #fff; margin-left: 10px;margin-right: 10px;">|</span>

0 commit comments

Comments
 (0)