if ($userInfo) { $wall['wall_creatorname'] = $userInfo['user_name']; } $wall['wall_type'] = $info['wall_type']; $wall['wall_usercount'] = $info['wall_usercount']; } $wall['relationship'] = 'like'; array_push($ret, $wall); } } $walls = WaWall::FindWallIdsByCreator($id); if ($walls) { while (list($key, $value) = each($walls)) { $wall = array(); $wall['wall_id'] = $value['wall_id']; if (isset($_GET['fulldata'])) { $info = WaWall::GetWallInfo($wall['wall_id']); $wall['wall_name'] = $info['wall_name']; $wall['wall_desc'] = $info['wall_desc']; $userInfo = WaUser::GetUserInfo($info['wall_creator']); if ($userInfo) { $wall['wall_creatorname'] = $userInfo['user_name']; } $wall['wall_type'] = $info['wall_type']; $wall['wall_usercount'] = $info['wall_usercount']; } $wall['relationship'] = 'own'; array_push($ret, $wall); } } echo json_encode($ret);
<div class="wall-user"> <h3>用户列表</h3> <h5>墙主:<?php echo $creatorName; ?> </h5> </div> <?php } ?> </span> <?php $users = WaWall::FindUserIdsByWall($wall); if ($users) { foreach ($users as $user) { $userInfo = WaUser::GetUserInfo($user['user_id']); if ($userInfo) { ?> <span class="wall-user list-group-item"> <h4 class="list-group-item-text"><?php echo $userInfo['user_name']; ?> </h4> </span> <?php } } } ?> </div> <?php
} for ($i = 0; $i < $offset; $i++) { next($posts); } while (list($key, $post) = each($posts)) { $post_id = $post['post_id']; try { $postInfo = WaPost::GetPostInfo($post_id); if (!$postInfo) { throw new Exception(''); } } catch (Exception $e) { continue; } $post = array(); $post['post_id'] = $postInfo['post_id']; $post['post_title'] = $postInfo['post_title']; $post['post_content'] = $postInfo['post_content']; $creator = $postInfo['post_creator']; try { $creator_info = WaUser::GetUserInfo($creator); } catch (Exception $e) { continue; } $post['post_creator'] = $creator_info['user_name']; array_unshift($ret, $post); if (--$limit <= 0) { break; } } echo json_encode(array('post' => $ret));
<ul class="nav navbar-nav"> <li class="divider"></li> <li><a href="#hall" title="大厅">大厅</a></li> <li><a href="#mywall" title="我的墙">我的墙</a></li> <li><a href="#inprogress" title="动态(建设中)" class="unimplemented">动态</a></li> <li><a href="#inprogress" title="消息(建设中)" class="unimplemented">消息</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <?php global $loginUser; if ($loginUser) { ?> <li> <a href="#inprogress" title="我的资料(建设中)" class="unimplemented" style="text-decoration:none"> <?php $info = WaUser::GetUserInfo($loginUser); $data = WaUser::GetUserData($loginUser); if ($info) { echo '您好,' . $info['user_name']; } ?> </a></li> <?php if (!signedIn($loginUser)) { ?> <li> <button id="sign-btn" class="btn btn-warning navbar-btn">点击签到</button> </li> <?php } else { ?> <li>
function createPost($wall, $title, $content) { global $loginUser; if (!$loginUser) { returnError('请先登录'); return; } try { $userData = WaUser::GetUserData($loginUser); if (!$userData) { throw new Exception('获取用户失败。'); } } catch (Exception $e) { returnError($e->getMessage()); return; } $wealth = $userData['user_wealth']; if ($wealth < 1) { returnError('墙砖不够。'); return; } $userData['user_wealth'] -= 1; $userData['user_exp'] += 1; try { $ret = WaPost::CreatePost($wall, $title, $content, $loginUser); if (!$ret) { throw new Exception('创建帖子失败。'); } $ret = WaUser::SetUserData($loginUser, $userData); if (!$ret) { throw new Exception('扣墙砖失败。'); } } catch (Exception $e) { returnError($e->getMessage()); return; } $ret = array('post_id', $ret); echo json_encode($ret); }