function rss() { if (!empty($_GET['id'])) { $uid = (int) $_GET['id']; $user = App\Func::getUser($uid); $_mblog = createModel('MicroBlog'); $_blog = createModel('UserLogs'); $gets['uid'] = $uid; $gets['select'] = 'id,content,addtime'; $gets['limit'] = 10; $mblogs = $_mblog->gets($gets); foreach ($mblogs as &$v) { $v['title'] = strip_tags(App\Func::mblog_link($v['id'], $v['content'], 30, true)); $v['content'] = nl2br($v['content']); $v['url'] = WEBROOT . '/mblog/detail/' . $v['id']; } $gets['uid'] = $uid; $gets['select'] = 'id,title,content,addtime'; $gets['limit'] = 10; $gets['dir'] = 0; $blogs = $_blog->gets($gets); $list = array_merge($mblogs, $blogs); usort($list, 'Func::time_sort'); foreach ($list as &$v) { $v['addtime'] = date('r', strtotime($v['addtime'])); if (empty($v['url'])) { $v['url'] = WEBROOT . '/blog/detail/' . $v['id']; } } $this->swoole->tpl->ref('user', $user); $this->swoole->tpl->ref('list', $list); $this->swoole->tpl->display('blog_rss.xml'); } }
function detail() { if (!isset($_GET['id'])) { exit; } $id = (int) $_GET['id']; $model = model('MicroBlog'); $_u = model('UserInfo'); $_c = model('UserComment'); $comments = $_c->getByAid('mblog', $id); $mblog = $model->get($id)->get(); $this->userinfo($mblog['uid']); $mblog['addtime'] = date('n月j日 H:i', strtotime($mblog['addtime'])); $this->swoole->tpl->assign('mblog', $mblog); $title = strip_tags(App\Func::mblog_link(0, $mblog['content'], 32, true)); $this->swoole->tpl->assign('title', $title); $this->swoole->tpl->assign('comments', $comments); $this->swoole->tpl->display(); }
/** * 获取微博客内容列表 * @param $pagesize * @return unknown_type */ protected function getMblogs($pagesize = 10, $uid = 0) { $_mblog = createModel('MicroBlog'); $_user = createModel('UserInfo'); $_photo = createModel('UserPhoto'); $_link = createModel('UserLink'); $gets1['select'] = $_mblog->table . '.id as id,uid,pic_id,url_id,sex,substring(content,1,170) as content,nickname,avatar,UNIX_TIMESTAMP(addtime) as addtime,reply_count'; $gets1['order'] = $_mblog->table . '.id desc'; if (!empty($uid)) { $gets1['uid'] = $uid; } $gets1['leftjoin'] = array($_user->table, $_user->table . '.id=' . $_mblog->table . '.uid'); $gets1['page'] = empty($_GET['page']) ? 1 : (int) $_GET['page']; $gets1['pagesize'] = $pagesize; $pager = ''; $mblogs_atta = array(); $mblogs = $_mblog->gets($gets1, $pager); $pager->span_open = array(); $pager = array('total' => $pager->total, 'render' => $pager->render()); foreach ($mblogs as &$m) { $m['content'] = Func::mblog_link($m['id'], $m['content']); $m['addtime'] = date('n月j日 H:i', $m['addtime']); if (!empty($m['url_id'])) { $mblogs_atta['url'][] = $m['url_id']; } if (!empty($m['pic_id'])) { $mblogs_atta['pic'][] = $m['pic_id']; } } if (!empty($mblogs_atta['pic'])) { $pics = $_photo->getMap(array('select' => 'id,imagep,picture', 'in' => array('id', implode(',', $mblogs_atta['pic'])))); $this->swoole->tpl->assign('pics', $pics); } if (!empty($mblogs_atta['url'])) { $urls = $_link->getMap(array('select' => 'id,title,url', 'in' => array('id', implode(',', $mblogs_atta['url'])))); $this->swoole->tpl->assign('urls', $urls); } $this->swoole->tpl->assign('mblogs', $mblogs); $this->swoole->tpl->assign('pager', $pager); }
public static function storeCMPicture($img_url) { // post save $post = \App\Post::create(array('user_id' => \Auth::user()->id, 'content' => '')); $post->postGroups()->attach(\Auth::user()->postGroups()->first()->id); // photo save $types = array('_s.', '_m.', '_l.'); $sizes = array(100, 300, 600); $original_file_name = $img_url; $file_ext = 'jpg'; $target_path = base_path() . '/public/imgs/'; $hashSeed = "post" . $post->id . $original_file_name; while (1) { $file_name = \Func::getHashedValue($hashSeed); if (!\File::exists($target_path . \Func::getImgPath($file_name))) { break; } $hashSeed .= rand(); } $target_path .= \Func::getImgPath($file_name) . '/'; if (!\File::exists($target_path)) { \File::makeDirectory($target_path, 0775, true); } foreach ($types as $key => $type) { $new_name = $file_name . $type . $file_ext; $img = \Image::make($img_url); $img->resize($sizes[$key], null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->save($target_path . $new_name); $img->destroy(); } \App\Photo::create(array('post_id' => $post->id, 'sequence' => 1, 'img_path' => $file_name . '.' . $file_ext)); }
/** * 忘记密码 * @return unknown_type */ function forgot() { if ($_POST) { $gets['realname'] = $_POST['realname']; $gets['username'] = $_POST['email']; $gets['mobile'] = $_POST['mobile']; $gets['select'] = 'id'; $ul = $this->model->UserInfo->gets($gets); if (count($ul) != 0) { $password = App\Func::randomkeys(6); $this->model->UserInfo->set($ul[0]['id'], array('password' => Auth::mkpasswd($gets['username'], $password))); App\Func::success('找回成功!', '您的新密码是 <span style="color:#fe7e00;">' . $password . '</a>'); } } else { $this->swoole->tpl->display(); } }