예제 #1
0
 public function index_action()
 {
     if ($_GET['id']) {
         if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['id']))) {
             H::redirect_msg(AWS_APP::lang()->_t('指定问题不存在'));
         }
         if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator'] and !$this->user_info['permission']['edit_question'] and $question_info['published_uid'] != $this->user_id) {
             H::redirect_msg(AWS_APP::lang()->_t('你没有权限编辑这个问题'), '/question/' . $question_info['question_id']);
         }
     } else {
         if (!$this->user_info['permission']['publish_question']) {
             H::redirect_msg(AWS_APP::lang()->_t('你所在用户组没有权限发布问题'));
         } else {
             if ($this->is_post() and $_POST['question_detail']) {
                 $question_info = array('question_content' => htmlspecialchars($_POST['question_content']), 'question_detail' => htmlspecialchars($_POST['question_detail']), 'category_id' => intval($_POST['category_id']));
             } else {
                 $draft_content = $this->model('draft')->get_data(1, 'question', $this->user_id);
                 $question_info = array('question_content' => htmlspecialchars($_POST['question_content']), 'question_detail' => htmlspecialchars($draft_content['message']));
             }
         }
     }
     if ($this->user_info['integral'] < 0 and get_setting('integral_system_enabled') == 'Y' and !$_GET['id']) {
         H::redirect_msg(AWS_APP::lang()->_t('你的剩余积分已经不足以进行此操作'));
     }
     if ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or $question_info['published_uid'] == $this->user_id and $_GET['id'] or !$_GET['id']) {
         TPL::assign('attach_access_key', md5($this->user_id . time()));
     }
     if (!$question_info['category_id']) {
         $question_info['category_id'] = $_GET['category_id'] ? intval($_GET['category_id']) : 0;
     }
     if (get_setting('category_enable') == 'Y') {
         TPL::assign('question_category_list', $this->model('system')->build_category_html('question', 0, $question_info['category_id']));
     }
     if ($modify_reason = $this->model('question')->get_modify_reason()) {
         TPL::assign('modify_reason', $modify_reason);
     }
     TPL::assign('human_valid', human_valid('question_valid_hour'));
     TPL::import_js('js/app/publish.js');
     TPL::import_js('js/jquery.barrating.min.js');
     TPL::import_css('css/publish.css');
     TPL::import_js('js/icheck.min.js');
     TPL::import_css('css/icheck/square/blue.css');
     TPL::import_js('js/quiz.js');
     TPL::import_css('css/quiz.css');
     if (get_setting('advanced_editor_enable') == 'Y') {
         import_editor_static_files();
     }
     if (get_setting('upload_enable') == 'Y') {
         // fileupload
         TPL::import_js('js/fileupload.js');
     }
     // 答题选项
     if (intval($question_info['quiz_id']) > 0) {
         $question_quiz = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']);
         TPL::assign('question_quiz', $question_quiz);
     }
     TPL::assign('question_info', $question_info);
     TPL::assign('recent_topics', @unserialize($this->user_info['recent_topics']));
     TPL::output('publish/index');
 }
예제 #2
0
 public function setup()
 {
     HTTP::no_cache_header();
     TPL::import_clean();
     TPL::import_css(array('mobile/css/icon.css', 'mobile/css/mobile.css'));
     TPL::import_js(array('js/jquery.2.js', 'js/jquery.form.js', 'mobile/js/framework.js', 'mobile/js/aws-mobile.js', 'mobile/js/app.js', 'mobile/js/aw-mobile-template.js'));
 }
예제 #3
0
 public function setup()
 {
     if (get_setting('project_enabled') != 'Y') {
         H::redirect_msg(AWS_APP::lang()->_t('活动系统未启用'), '/');
     }
     $this->crumb(AWS_APP::lang()->_t('活动'), '/project/');
     TPL::import_css('css/project.css');
 }
예제 #4
0
파일: main.php 프로젝트: tenstone/wecenter
 public function index_action()
 {
     if (isset($_GET['notification_id'])) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if (is_mobile()) {
         HTTP::redirect('/m/people/' . $_GET['id']);
     }
     if (is_digits($_GET['id'])) {
         if (!($user = $this->model('account')->get_user_info_by_uid($_GET['id'], TRUE))) {
             $user = $this->model('account')->get_user_info_by_username($_GET['id'], TRUE);
         }
     } else {
         if ($user = $this->model('account')->get_user_info_by_username($_GET['id'], TRUE)) {
         } else {
             $user = $this->model('account')->get_user_info_by_url_token($_GET['id'], TRUE);
         }
     }
     if (!$user) {
         header('HTTP/1.1 404 Not Found');
         H::redirect_msg(AWS_APP::lang()->_t('用户不存在'), '/');
     }
     if ($user['forbidden'] and !$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator']) {
         header('HTTP/1.1 404 Not Found');
         H::redirect_msg(AWS_APP::lang()->_t('该用户已被封禁'), '/');
     }
     if (urldecode($user['url_token']) != $_GET['id']) {
         HTTP::redirect('/people/' . $user['url_token']);
     }
     $this->model('people')->update_views($user['uid']);
     TPL::assign('user', $user);
     $job_info = $this->model('account')->get_jobs_by_id($user['job_id']);
     TPL::assign('job_name', $job_info['job_name']);
     if ($user['weibo_visit']) {
         if ($users_sina = $this->model('openid_weibo_oauth')->get_weibo_user_by_uid($user['uid'])) {
             TPL::assign('sina_weibo_url', 'http://www.weibo.com/' . $users_sina['id']);
         }
     }
     TPL::assign('education_experience_list', $this->model('education')->get_education_experience_list($user['uid']));
     $jobs_list = $this->model('work')->get_jobs_list();
     if ($work_experience_list = $this->model('work')->get_work_experience_list($user['uid'])) {
         foreach ($work_experience_list as $key => $val) {
             $work_experience_list[$key]['job_name'] = $jobs_list[$val['job_id']];
         }
     }
     TPL::assign('work_experience_list', $work_experience_list);
     TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $user['uid']));
     $this->crumb(AWS_APP::lang()->_t('%s 的个人主页', $user['user_name']), 'people/' . $user['url_token']);
     TPL::import_css('css/user.css');
     TPL::assign('reputation_topics', $this->model('people')->get_user_reputation_topic($user['uid'], $user['reputation'], 12));
     TPL::assign('fans_list', $this->model('follow')->get_user_fans($user['uid'], 5));
     TPL::assign('friends_list', $this->model('follow')->get_user_friends($user['uid'], 5));
     TPL::assign('focus_topics', $this->model('topic')->get_focus_topic_list($user['uid'], 10));
     TPL::assign('user_actions_questions', $this->model('actions')->get_user_actions($user['uid'], 5, ACTION_LOG::ADD_QUESTION, $this->user_id));
     TPL::assign('user_actions_answers', $this->model('actions')->get_user_actions($user['uid'], 5, ACTION_LOG::ANSWER_QUESTION, $this->user_id));
     TPL::assign('user_actions', $this->model('actions')->get_user_actions($user['uid'], 5, implode(',', array(ACTION_LOG::ADD_QUESTION, ACTION_LOG::ANSWER_QUESTION, ACTION_LOG::ADD_REQUESTION_FOCUS, ACTION_LOG::ADD_AGREE, ACTION_LOG::ADD_TOPIC, ACTION_LOG::ADD_TOPIC_FOCUS, ACTION_LOG::ADD_ARTICLE)), $this->user_id));
     TPL::output('people/index');
 }
예제 #5
0
 public function setup()
 {
     if (get_setting('ticket_enabled') != 'Y') {
         H::redirect_msg(AWS_APP::lang()->_t('工单系统未启用'), '/');
     }
     $this->crumb(AWS_APP::lang()->_t('工单'), '/ticket/');
     $this->per_page = get_setting('contents_per_page');
     TPL::import_css('css/ticket.css');
 }
예제 #6
0
 public function login_action()
 {
     if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator']) {
         H::redirect_msg(AWS_APP::lang()->_t('你没有访问权限, 请重新登录'), '/');
     } else {
         if (AWS_APP::session()->admin_login) {
             HTTP::redirect('/admin/');
         }
     }
     TPL::import_css('admin/css/login.css');
     TPL::output('admin/login');
 }
예제 #7
0
 public function qq_login_callback_action()
 {
     if ($this->is_post() and AWS_APP::session()->qq_profile and AWS_APP::session()->QQConnect) {
         if (get_setting('register_type') == 'close') {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('本站目前关闭注册')));
         } else {
             if (get_setting('register_type') == 'invite') {
                 H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('本站只能通过邀请注册')));
             } else {
                 if (get_setting('register_type') == 'weixin') {
                     H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('本站只能通过微信注册')));
                 }
             }
         }
         if (trim($_POST['user_name']) == '') {
             H::ajax_json_output(AWS_APP::RSM(array('input' => 'user_name'), -1, AWS_APP::lang()->_t('请输入真实姓名')));
         } else {
             if ($this->model('account')->check_username($_POST['user_name'])) {
                 H::ajax_json_output(AWS_APP::RSM(array('input' => 'user_name'), -1, AWS_APP::lang()->_t('真实姓名已经存在')));
             } else {
                 if ($check_rs = $this->model('account')->check_username_char($_POST['user_name'])) {
                     H::ajax_json_output(AWS_APP::RSM(array('input' => 'user_name'), -1, $check_rs));
                 } else {
                     if ($this->model('account')->check_username_sensitive_words($_POST['user_name'])) {
                         H::ajax_json_output(AWS_APP::RSM(array('input' => 'user_name'), -1, AWS_APP::lang()->_t('真实姓名中包含敏感词或系统保留字')));
                     }
                 }
             }
         }
         if ($this->model('account')->check_email($_POST['email'])) {
             H::ajax_json_output(AWS_APP::RSM(array('input' => 'email'), -1, AWS_APP::lang()->_t('E-Mail 已经被使用, 或格式不正确')));
         }
         if (strlen($_POST['password']) < 6 or strlen($_POST['password']) > 16) {
             H::ajax_json_output(AWS_APP::RSM(array('input' => 'userPassword'), -1, AWS_APP::lang()->_t('密码长度不符合规则')));
         }
         if (!$_POST['agreement_chk']) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('你必需同意用户协议才能继续')));
         }
         if (get_setting('ucenter_enabled') == 'Y') {
             $result = $this->model('ucenter')->register($_POST['user_name'], $_POST['password'], $_POST['email'], true);
             if (is_array($result)) {
                 $uid = $result['user_info']['uid'];
             } else {
                 H::ajax_json_output(AWS_APP::RSM(null, -1, $result));
             }
         } else {
             $uid = $this->model('account')->user_register($_POST['user_name'], $_POST['password'], $_POST['email']);
             if (get_setting('register_valid_type') == 'email') {
                 $this->model('active')->new_valid_email($uid);
             }
             if (get_setting('register_valid_type') != 'approval') {
                 $this->model('active')->active_user_by_uid($uid);
             }
         }
         if ($uid) {
             $this->model('openid_qq')->bind_account(AWS_APP::session()->qq_profile, null, $uid, true);
             if (AWS_APP::session()->qq_profile['figureurl_2']) {
                 $this->model('account')->associate_remote_avatar($uid, AWS_APP::session()->qq_profile['figureurl_2']);
             }
             H::ajax_json_output(AWS_APP::RSM(null, 1, null));
         } else {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('与 QQ 通信出错 (Register), 请重新登录')));
         }
     } else {
         if (!$_GET['code']) {
             H::redirect_msg(AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'), "/account/login/");
         }
         if (!AWS_APP::session()->QQConnect['access_token']) {
             if (!$this->model('openid_qq')->request_access_token(get_js_url('/account/openid/qq_login_callback/'))) {
                 H::redirect_msg(AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'), "/account/login/");
             }
         }
         if (!AWS_APP::session()->QQConnect['access_token'] or !($uinfo = $this->model('openid_qq')->request_user_info())) {
             H::redirect_msg(AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'), "/account/login/");
         }
         AWS_APP::session()->qq_profile = $uinfo;
         if ($qq_user = $this->model('openid_qq')->get_user_info_by_open_id(load_class('Services_Tencent_QQConnect_V2')->get_openid())) {
             $user_info = $this->model('account')->get_user_info_by_uid($qq_user['uid']);
             HTTP::set_cookie('_user_login', get_login_cookie_hash($user_info['user_name'], $user_info['password'], $user_info['salt'], $user_info['uid'], false));
             $this->model('openid_qq')->update_token($qq_user['name'], AWS_APP::session()->QQConnect['access_token']);
             HTTP::redirect('/');
         } else {
             if ($this->user_id) {
                 $this->model('openid_qq')->bind_account($this->model('openid_qq')->request_user_info(), '/', $this->user_id);
             } else {
                 if (get_setting('register_type') == 'close') {
                     H::redirect_msg(AWS_APP::lang()->_t('本站目前关闭注册'));
                 } else {
                     if (get_setting('register_type') == 'invite') {
                         H::redirect_msg(AWS_APP::lang()->_t('本站只能通过邀请注册'));
                     } else {
                         $this->crumb(AWS_APP::lang()->_t('完善资料'), '/account/login/');
                         TPL::assign('user_name', str_replace(' ', '_', AWS_APP::session()->qq_profile['nickname']));
                         TPL::import_css('css/register.css');
                         TPL::output('account/openid/callback');
                     }
                 }
             }
         }
     }
 }
예제 #8
0
 public function index_action()
 {
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if (is_mobile()) {
         HTTP::redirect('/m/question/' . $_GET['id']);
     }
     if ($_GET['column'] == 'log' and !$this->user_id) {
         HTTP::redirect('/question/' . $_GET['id']);
     }
     if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('问题不存在或已被删除'), '/question/');
     }
     if (!$_GET['sort'] or $_GET['sort'] != 'ASC') {
         $_GET['sort'] = 'DESC';
     } else {
         $_GET['sort'] = 'ASC';
     }
     if (get_setting('unfold_question_comments') == 'Y') {
         $_GET['comment_unfold'] = 'all';
     }
     $question_info['redirect'] = $this->model('question')->get_redirect($question_info['question_id']);
     if ($question_info['redirect']['target_id']) {
         $target_question = $this->model('question')->get_question_info_by_id($question_info['redirect']['target_id']);
     }
     if (is_digits($_GET['rf']) and $_GET['rf']) {
         if ($from_question = $this->model('question')->get_question_info_by_id($_GET['rf'])) {
             $redirect_message[] = AWS_APP::lang()->_t('从问题 %s 跳转而来', '<a href="' . get_js_url('/question/' . $_GET['rf'] . '?rf=false') . '">' . $from_question['question_content'] . '</a>');
         }
     }
     if ($question_info['redirect'] and !$_GET['rf']) {
         if ($target_question) {
             HTTP::redirect('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']);
         } else {
             $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
         }
     } else {
         if ($question_info['redirect']) {
             if ($target_question) {
                 $message = AWS_APP::lang()->_t('此问题将跳转至') . ' <a href="' . get_js_url('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']) . '">' . $target_question['question_content'] . '</a>';
                 if ($this->user_id and ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or !$this->question_info['lock'] and $this->user_info['permission']['redirect_question'])) {
                     $message .= '&nbsp; (<a href="javascript:;" onclick="AWS.ajax_request(G_BASE_URL + \'/question/ajax/redirect/\', \'item_id=' . $question_info['question_id'] . '\');">' . AWS_APP::lang()->_t('撤消重定向') . '</a>)';
                 }
                 $redirect_message[] = $message;
             } else {
                 $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
             }
         }
     }
     if ($question_info['has_attach']) {
         $question_info['attachs'] = $this->model('publish')->get_attach('question', $question_info['question_id'], 'min');
         $question_info['attachs_ids'] = FORMAT::parse_attachs($question_info['question_detail'], true);
     }
     if ($question_info['category_id'] and get_setting('category_enable') == 'Y') {
         $question_info['category_info'] = $this->model('system')->get_category_info($question_info['category_id']);
     }
     $question_info['user_info'] = $this->model('account')->get_user_info_by_uid($question_info['published_uid'], true);
     if ($_GET['column'] != 'log') {
         $this->model('question')->calc_popular_value($question_info['question_id']);
         $this->model('question')->update_views($question_info['question_id']);
         if (is_digits($_GET['uid'])) {
             $answer_list_where[] = 'uid = ' . intval($_GET['uid']);
             $answer_count_where = 'uid = ' . intval($_GET['uid']);
         } else {
             if ($_GET['uid'] == 'focus' and $this->user_id) {
                 if ($friends = $this->model('follow')->get_user_friends($this->user_id, false)) {
                     foreach ($friends as $key => $val) {
                         $follow_uids[] = $val['uid'];
                     }
                 } else {
                     $follow_uids[] = 0;
                 }
                 $answer_list_where[] = 'uid IN(' . implode($follow_uids, ',') . ')';
                 $answer_count_where = 'uid IN(' . implode($follow_uids, ',') . ')';
                 $answer_order_by = 'add_time ASC';
             } else {
                 if ($_GET['sort_key'] == 'add_time') {
                     $answer_order_by = $_GET['sort_key'] . " " . $_GET['sort'];
                 } else {
                     $answer_order_by = "agree_count " . $_GET['sort'] . ", against_count ASC, add_time ASC";
                 }
             }
         }
         if ($answer_count_where) {
             $answer_count = $this->model('answer')->get_answer_count_by_question_id($question_info['question_id'], $answer_count_where);
         } else {
             $answer_count = $question_info['answer_count'];
         }
         if (isset($_GET['answer_id']) and (!$this->user_id or $_GET['single'])) {
             $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
         } else {
             if (!$this->user_id and !$this->user_info['permission']['answer_show']) {
                 if ($question_info['best_answer']) {
                     $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
                 } else {
                     $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
                 }
             } else {
                 if ($answer_list_where) {
                     $answer_list_where = implode(' AND ', $answer_list_where);
                 }
                 $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 100), $answer_list_where, $answer_order_by);
             }
         }
         // 最佳回复预留
         $answers[0] = '';
         if (!is_array($answer_list)) {
             $answer_list = array();
         }
         $answer_ids = array();
         $answer_uids = array();
         foreach ($answer_list as $answer) {
             $answer_ids[] = $answer['answer_id'];
             $answer_uids[] = $answer['uid'];
             if ($answer['has_attach']) {
                 $has_attach_answer_ids[] = $answer['answer_id'];
             }
         }
         if (!in_array($question_info['best_answer'], $answer_ids) and intval($_GET['page']) < 2) {
             $answer_list = array_merge($this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . $question_info['best_answer']), $answer_list);
         }
         if ($answer_ids) {
             $answer_agree_users = $this->model('answer')->get_vote_user_by_answer_ids($answer_ids);
             $answer_vote_status = $this->model('answer')->get_answer_vote_status($answer_ids, $this->user_id);
             $answer_users_rated_thanks = $this->model('answer')->users_rated('thanks', $answer_ids, $this->user_id);
             $answer_users_rated_uninterested = $this->model('answer')->users_rated('uninterested', $answer_ids, $this->user_id);
             $answer_attachs = $this->model('publish')->get_attachs('answer', $has_attach_answer_ids, 'min');
         }
         foreach ($answer_list as $answer) {
             if ($answer['has_attach']) {
                 $answer['attachs'] = $answer_attachs[$answer['answer_id']];
                 $answer['insert_attach_ids'] = FORMAT::parse_attachs($answer['answer_content'], true);
             }
             $answer['user_rated_thanks'] = $answer_users_rated_thanks[$answer['answer_id']];
             $answer['user_rated_uninterested'] = $answer_users_rated_uninterested[$answer['answer_id']];
             $answer['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($answer['answer_content']))));
             $answer['agree_users'] = $answer_agree_users[$answer['answer_id']];
             $answer['agree_status'] = $answer_vote_status[$answer['answer_id']];
             if ($question_info['best_answer'] == $answer['answer_id'] and intval($_GET['page']) < 2) {
                 $answers[0] = $answer;
             } else {
                 $answers[] = $answer;
             }
         }
         if (!$answers[0]) {
             unset($answers[0]);
         }
         if (get_setting('answer_unique') == 'Y') {
             if ($this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id)) {
                 TPL::assign('user_answered', 1);
             } else {
                 TPL::assign('user_answered', 0);
             }
         }
         TPL::assign('answers', $answers);
         TPL::assign('answer_count', $answer_count);
     }
     if ($this->user_id) {
         TPL::assign('question_thanks', $this->model('question')->get_question_thanks($question_info['question_id'], $this->user_id));
         TPL::assign('invite_users', $this->model('question')->get_invite_users($question_info['question_id']));
         TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $question_info['published_uid']));
         if ($this->user_info['draft_count'] > 0) {
             TPL::assign('draft_content', $this->model('draft')->get_data($question_info['question_id'], 'answer', $this->user_id));
         }
     }
     $question_info['question_detail'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($question_info['question_detail'])));
     TPL::assign('question_info', $question_info);
     TPL::assign('question_focus', $this->model('question')->has_focus_question($question_info['question_id'], $this->user_id));
     $question_topics = $this->model('topic')->get_topics_by_item_id($question_info['question_id'], 'question');
     if (sizeof($question_topics) == 0 and $this->user_id) {
         $related_topics = $this->model('question')->get_related_topics($question_info['question_content']);
         TPL::assign('related_topics', $related_topics);
     }
     TPL::assign('question_topics', $question_topics);
     TPL::assign('question_related_list', $this->model('question')->get_related_question_list($question_info['question_id'], $question_info['question_content']));
     TPL::assign('question_related_links', $this->model('related')->get_related_links('question', $question_info['question_id']));
     if ($this->user_id) {
         if ($question_topics) {
             foreach ($question_topics as $key => $val) {
                 $question_topic_ids[] = $val['topic_id'];
             }
         }
         if ($helpful_users = $this->model('topic')->get_helpful_users_by_topic_ids($question_topic_ids, 17)) {
             foreach ($helpful_users as $key => $val) {
                 if ($val['user_info']['uid'] == $this->user_id) {
                     unset($helpful_users[$key]);
                 } else {
                     $helpful_users[$key]['has_invite'] = $this->model('question')->has_question_invite($question_info['question_id'], $val['user_info']['uid'], $this->user_id);
                     $helpful_users[$key]['experience'] = end($helpful_users[$key]['experience']);
                 }
             }
             TPL::assign('helpful_users', $helpful_users);
         }
     }
     $this->crumb($question_info['question_content'], '/question/' . $question_info['question_id']);
     if ($_GET['column'] == 'log') {
         $this->crumb(AWS_APP::lang()->_t('日志'), '/question/id-' . $question_info['question_id'] . '__column-log');
     } else {
         TPL::assign('human_valid', human_valid('answer_valid_hour'));
         if ($this->user_id) {
             TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/question/id-' . $question_info['question_id'] . '__sort_key-' . $_GET['sort_key'] . '__sort-' . $_GET['sort'] . '__uid-' . $_GET['uid']), 'total_rows' => $answer_count, 'per_page' => 100))->create_links());
         }
     }
     TPL::set_meta('keywords', implode(',', $this->model('system')->analysis_keyword($question_info['question_content'])));
     TPL::set_meta('description', $question_info['question_content'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($question_info['question_detail'])), 0, 128, 'UTF-8', '...'));
     if (get_setting('advanced_editor_enable') == 'Y') {
         import_editor_static_files();
     }
     if (get_setting('upload_enable') == 'Y') {
         // fileupload
         TPL::import_js('js/fileupload.js');
     }
     TPL::assign('attach_access_key', md5($this->user_id . time()));
     TPL::assign('redirect_message', $redirect_message);
     $recommend_posts = $this->model('posts')->get_recommend_posts_by_topic_ids($question_topic_ids);
     if ($recommend_posts) {
         foreach ($recommend_posts as $key => $value) {
             if ($value['question_id'] and $value['question_id'] == $question_info['question_id']) {
                 unset($recommend_posts[$key]);
                 break;
             }
         }
         TPL::assign('recommend_posts', $recommend_posts);
     }
     // 答题选项
     if (intval($question_info['quiz_id']) > 0) {
         $question_quiz = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']);
         TPL::import_js('js/quiz.js');
         TPL::import_css('css/quiz.css');
         TPL::import_js('js/app/question.js');
         TPL::assign('question_quiz', $question_quiz);
     }
     TPL::output('question/index');
 }
 public function __construct()
 {
     parent::__construct(false);
     if ($_GET['app'] != 'admin') {
         return false;
     }
     TPL::import_clean();
     if (defined('SYSTEM_LANG')) {
         TPL::import_js(base_url() . '/language/' . SYSTEM_LANG . '.js');
     }
     if (HTTP::is_browser('ie', 8)) {
         TPL::import_js('js/jquery.js');
     } else {
         TPL::import_js('js/jquery.2.js');
     }
     TPL::import_js(array('admin/js/aws_admin.js', 'admin/js/aws_admin_template.js', 'js/jquery.form.js', 'admin/js/framework.js', 'admin/js/global.js'));
     TPL::import_css(array('admin/css/common.css'));
     if (in_array($_GET['act'], array('login', 'login_process'))) {
         return true;
     }
     if ($admin_info = H::decode_hash(AWS_APP::session()->admin_login)) {
         if ($admin_info['uid'] != $this->user_id or $admin_info['UA'] != $_SERVER['HTTP_USER_AGENT'] or !AWS_APP::session()->permission['is_administortar'] and !AWS_APP::session()->permission['is_moderator']) {
             unset(AWS_APP::session()->admin_login);
             if ($_POST['_post_type'] == 'ajax') {
                 H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('会话超时, 请重新登录')));
             } else {
                 H::redirect_msg(AWS_APP::lang()->_t('会话超时, 请重新登录'), '/admin/login/url-' . base64_encode($_SERVER['REQUEST_URI']));
             }
         }
     } else {
         if ($_POST['_post_type'] == 'ajax') {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('会话超时, 请重新登录')));
         } else {
             HTTP::redirect('/admin/login/url-' . base64_encode($_SERVER['REQUEST_URI']));
         }
     }
     $this->setup();
 }
예제 #10
0
 public function bind_action()
 {
     if (AWS_APP::session()->weibo_user) {
         $weibo_user_info = AWS_APP::session()->weibo_user;
         unset(AWS_APP::session()->weibo_user);
     }
     if ($_GET['error'] == 'access_denied') {
         H::redirect_msg(AWS_APP::lang()->_t('授权失败'), '/account/login/');
     }
     if ($this->user_id) {
         $weibo_user = $this->model('openid_weibo_oauth')->get_weibo_user_by_uid($this->user_id);
         if ($weibo_user) {
             H::redirect_msg(AWS_APP::lang()->_t('此账号已绑定微博账号'), '/account/login/');
         }
     }
     $callback_url = '/account/openid/weibo/bind/';
     if ($_GET['return_url']) {
         $callback_url .= 'return_url-' . $_GET['return_url'];
     }
     if ($_GET['code']) {
         if ($_GET['code'] != $weibo_user_info['authorization_code']) {
             $this->model('openid_weibo_oauth')->authorization_code = $_GET['code'];
             $this->model('openid_weibo_oauth')->redirect_url = $callback_url;
             if (!$this->model('openid_weibo_oauth')->oauth2_login()) {
                 H::redirect_msg($this->model('openid_weibo_oauth')->error_msg, '/account/login/');
             }
             $weibo_user_info = $this->model('openid_weibo_oauth')->user_info;
         }
         if (!$weibo_user_info) {
             H::redirect_msg(AWS_APP::lang()->_t('微博登录失败,用户信息不存在'), '/account/login/');
         }
         $weibo_user = $this->model('openid_weibo_oauth')->get_weibo_user_by_id($weibo_user_info['id']);
         if ($this->user_id) {
             if ($weibo_user) {
                 H::redirect_msg(AWS_APP::lang()->_t('此微博账号已被绑定'), '/account/login/');
             }
             $this->model('openid_weibo_oauth')->bind_account($weibo_user_info, $this->user_id);
             if (!$this->model('integral')->fetch_log($this->user_id, 'BIND_OPENID')) {
                 $this->model('integral')->process($this->user_id, 'BIND_OPENID', round(get_setting('integral_system_config_profile') * 0.2), '绑定 OPEN ID');
             }
             HTTP::redirect('/account/setting/openid/');
         } else {
             if ($weibo_user) {
                 $user = $this->model('account')->get_user_info_by_uid($weibo_user['uid']);
                 if (!$user) {
                     $this->model('openid_weibo_oauth')->unbind_account($weibo_user['uid']);
                     H::redirect_msg(AWS_APP::lang()->_t('本地用户不存在'), '/account/login/');
                 }
                 $this->model('openid_weibo_oauth')->update_user_info($weibo_user['id'], $weibo_user_info);
                 if (get_setting('register_valid_type') == 'approval' and $user['group_id'] == 3) {
                     $redirect_url = '/account/valid_approval/';
                 } else {
                     if ($_GET['state']) {
                         $state = base64_url_decode($_GET['state']);
                     }
                     if (get_setting('ucenter_enabled') == 'Y') {
                         $redirect_url = '/account/sync_login/';
                         if ($state['return_url']) {
                             $redirect_url .= 'url-' . base64_encode($state['return_url']);
                         }
                     } else {
                         if ($state['return_url']) {
                             $redirect_url = $state['return_url'];
                         } else {
                             $redirect_url = '/';
                         }
                     }
                     HTTP::set_cookie('_user_login', get_login_cookie_hash($user['user_name'], $user['password'], $user['salt'], $user['uid'], false));
                     if (get_setting('register_valid_type') == 'email' and !$user['valid_email']) {
                         AWS_APP::session()->valid_email = $user['email'];
                     }
                 }
                 HTTP::redirect($redirect_url);
             } else {
                 switch (get_setting('register_type')) {
                     case 'close':
                         H::redirect_msg(AWS_APP::lang()->_t('本站目前关闭注册'), '/account/login/');
                         break;
                     case 'invite':
                         H::redirect_msg(AWS_APP::lang()->_t('本站只能通过邀请注册'), '/account/login/');
                         break;
                     case 'weixin':
                         H::redirect_msg(AWS_APP::lang()->_t('本站只能通过微信注册'), '/account/login/');
                         break;
                 }
                 AWS_APP::session()->weibo_user = $weibo_user_info;
                 $this->crumb(AWS_APP::lang()->_t('完善资料'), '/account/login/');
                 TPL::assign('register_url', 'account/ajax/weibo/register/');
                 $user_name = str_replace('-', '', AWS_APP::session()->weibo_user['screen_name']);
                 while ($this->model('account')->check_username($user_name) || !$this->model('account')->is_valid_username($user_name) || $this->model('account')->check_username_sensitive_words($user_name)) {
                     $user_name = $this->model('account')->random_username();
                 }
                 TPL::assign('user_name', $user_name);
                 TPL::assign('sns_type', 'weibo');
                 TPL::import_css('css/register.css');
                 TPL::output('account/openid/callback');
             }
         }
     } else {
         $state = $_GET['return_url'] ? base64_url_encode(array('return_url' => base64_decode($_GET['return_url']))) : null;
         HTTP::redirect($this->model('openid_weibo_oauth')->get_redirect_url('/account/openid/weibo/bind/', $state));
     }
 }
예제 #11
0
 public function setup()
 {
     if ($_GET['ignore_ua_check'] == 'FALSE') {
         HTTP::set_cookie('_ignore_ua_check', 'FALSE');
     }
     if (!is_mobile()) {
         switch ($_GET['act']) {
             default:
                 HTTP::redirect('/');
                 break;
             case 'home':
                 HTTP::redirect('/home/');
                 break;
             case 'login':
                 HTTP::redirect('/account/login/');
                 break;
             case 'question':
                 HTTP::redirect('/question/' . $_GET['id']);
                 break;
             case 'register':
                 HTTP::redirect('/account/register/');
                 break;
             case 'topic':
                 HTTP::redirect('/topic/' . $_GET['id']);
                 break;
             case 'people':
                 HTTP::redirect('/people/' . $_GET['id']);
                 break;
             case 'article':
                 HTTP::redirect('/article/' . $_GET['id']);
                 break;
         }
     }
     if (!$this->user_id and !$this->user_info['permission']['visit_site'] and $_GET['act'] != 'login' and $_GET['act'] != 'register') {
         HTTP::redirect('/m/login/url-' . base64_encode($_SERVER['REQUEST_URI']));
     }
     switch ($_GET['act']) {
         default:
             if (!$this->user_id) {
                 HTTP::redirect('/m/login/url-' . base64_encode($_SERVER['REQUEST_URI']));
             }
             break;
         case 'index':
         case 'explore':
         case 'login':
         case 'question':
         case 'register':
         case 'topic':
         case 'search':
         case 'people':
         case 'article':
         case 'find_password':
         case 'find_password_success':
         case 'find_password_modify':
             // Public page..
             break;
     }
     TPL::import_clean();
     TPL::import_css(array('mobile/css/mobile.css'));
     TPL::import_js(array('js/jquery.2.js', 'js/jquery.form.js', 'mobile/js/framework.js', 'mobile/js/aws-mobile.js', 'mobile/js/app.js', 'mobile/js/aw-mobile-template.js'));
 }
예제 #12
0
파일: main.php 프로젝트: egogg/wecenter-dev
 public function index_action()
 {
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if ($_GET['column'] == 'log' and !$this->user_id) {
         HTTP::redirect('/question/' . $_GET['id']);
     }
     if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('问题不存在或已被删除'), '/question/');
     }
     if (!$_GET['sort'] or $_GET['sort'] != 'ASC') {
         $_GET['sort'] = 'DESC';
     } else {
         $_GET['sort'] = 'ASC';
     }
     if (get_setting('unfold_question_comments') == 'Y') {
         $_GET['comment_unfold'] = 'all';
     }
     $question_info['redirect'] = $this->model('question')->get_redirect($question_info['question_id']);
     if ($question_info['redirect']['target_id']) {
         $target_question = $this->model('question')->get_question_info_by_id($question_info['redirect']['target_id']);
     }
     if (is_digits($_GET['rf']) and $_GET['rf']) {
         if ($from_question = $this->model('question')->get_question_info_by_id($_GET['rf'])) {
             $redirect_message[] = AWS_APP::lang()->_t('从问题 %s 跳转而来', '<a href="' . get_js_url('/question/' . $_GET['rf'] . '?rf=false') . '">' . $from_question['question_content'] . '</a>');
         }
     }
     if ($question_info['redirect'] and !$_GET['rf']) {
         if ($target_question) {
             HTTP::redirect('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']);
         } else {
             $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
         }
     } else {
         if ($question_info['redirect']) {
             if ($target_question) {
                 $message = AWS_APP::lang()->_t('此问题将跳转至') . ' <a href="' . get_js_url('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']) . '">' . $target_question['question_content'] . '</a>';
                 if ($this->user_id and ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or !$this->question_info['lock'] and $this->user_info['permission']['redirect_question'])) {
                     $message .= '&nbsp; (<a href="javascript:;" onclick="AWS.ajax_request(G_BASE_URL + \'/question/ajax/redirect/\', \'item_id=' . $question_info['question_id'] . '\');">' . AWS_APP::lang()->_t('撤消重定向') . '</a>)';
                 }
                 $redirect_message[] = $message;
             } else {
                 $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
             }
         }
     }
     if ($question_info['has_attach']) {
         $question_info['attachs'] = $this->model('publish')->get_attach('question', $question_info['question_id'], 'min');
         $question_info['attachs_ids'] = FORMAT::parse_attachs($question_info['question_detail'], true);
     }
     $question_info['user_info'] = $this->model('account')->get_user_info_by_uid($question_info['published_uid'], true);
     // 分类信息
     if ($question_info['category_id']) {
         $question_info['category_info'] = $this->model('system')->get_category_info($question_info['category_id']);
     }
     if (intval($question_info['quiz_id']) > 0) {
         $question_info['question_quiz'] = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']);
     }
     $this->model('question')->calc_popular_value($question_info['question_id']);
     $this->model('question')->update_views($question_info['question_id']);
     // if ($_GET['column'] != 'log')
     // {
     // $this->model('question')->calc_popular_value($question_info['question_id']);
     // $this->model('question')->update_views($question_info['question_id']);
     // if (is_digits($_GET['uid']))
     // {
     // 	$answer_list_where[] = 'uid = ' . intval($_GET['uid']);
     // 	$answer_count_where = 'uid = ' . intval($_GET['uid']);
     // }
     // else if ($_GET['uid'] == 'focus' and $this->user_id)
     // {
     // 	if ($friends = $this->model('follow')->get_user_friends($this->user_id, false))
     // 	{
     // 		foreach ($friends as $key => $val)
     // 		{
     // 			$follow_uids[] = $val['uid'];
     // 		}
     // 	}
     // 	else
     // 	{
     // 		$follow_uids[] = 0;
     // 	}
     // 	$answer_list_where[] = 'uid IN(' . implode($follow_uids, ',') . ')';
     // 	$answer_count_where = 'uid IN(' . implode($follow_uids, ',') . ')';
     // 	$answer_order_by = 'add_time ASC';
     // }
     // else if ($_GET['sort_key'] == 'add_time')
     // {
     // 	$answer_order_by = $_GET['sort_key'] . " " . $_GET['sort'];
     // }
     // else
     // {
     // 	$answer_order_by = "agree_count " . $_GET['sort'] . ", against_count ASC, add_time ASC";
     // }
     // if ($answer_count_where)
     // {
     // 	$answer_count = $this->model('answer')->get_answer_count_by_question_id($question_info['question_id'], $answer_count_where);
     // }
     // else
     // {
     // 	$answer_count = $question_info['answer_count'];
     // }
     // if (isset($_GET['answer_id']) and (! $this->user_id OR $_GET['single']))
     // {
     // 	$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
     // }
     // else if (! $this->user_id AND !$this->user_info['permission']['answer_show'])
     // {
     // 	if ($question_info['best_answer'])
     // 	{
     // 		$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
     // 	}
     // 	else
     // 	{
     // 		$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
     // 	}
     // }
     // else
     // {
     // 	if ($answer_list_where)
     // 	{
     // 		$answer_list_where = implode(' AND ', $answer_list_where);
     // 	}
     // 	$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 100), $answer_list_where, $answer_order_by);
     // }
     // // 最佳回复预留
     // $answers[0] = '';
     // if (! is_array($answer_list))
     // {
     // 	$answer_list = array();
     // }
     // $answer_ids = array();
     // $answer_uids = array();
     // foreach ($answer_list as $answer)
     // {
     // 	$answer_ids[] = $answer['answer_id'];
     // 	$answer_uids[] = $answer['uid'];
     // 	if ($answer['has_attach'])
     // 	{
     // 		$has_attach_answer_ids[] = $answer['answer_id'];
     // 	}
     // }
     // if (!in_array($question_info['best_answer'], $answer_ids) AND intval($_GET['page']) < 2)
     // {
     // 	$answer_list = array_merge($this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . $question_info['best_answer']), $answer_list);
     // }
     // if ($answer_ids)
     // {
     // 	$answer_agree_users = $this->model('answer')->get_vote_user_by_answer_ids($answer_ids);
     // 	$answer_vote_status = $this->model('answer')->get_answer_vote_status($answer_ids, $this->user_id);
     // 	$answer_users_rated_thanks = $this->model('answer')->users_rated('thanks', $answer_ids, $this->user_id);
     // 	$answer_users_rated_uninterested = $this->model('answer')->users_rated('uninterested', $answer_ids, $this->user_id);
     // 	$answer_attachs = $this->model('publish')->get_attachs('answer', $has_attach_answer_ids, 'min');
     // }
     // foreach ($answer_list as $answer)
     // {
     // 	if ($answer['has_attach'])
     // 	{
     // 		$answer['attachs'] = $answer_attachs[$answer['answer_id']];
     // 		$answer['insert_attach_ids'] = FORMAT::parse_attachs($answer['answer_content'], true);
     // 	}
     // 	$answer['user_rated_thanks'] = $answer_users_rated_thanks[$answer['answer_id']];
     // 	$answer['user_rated_uninterested'] = $answer_users_rated_uninterested[$answer['answer_id']];
     // 	$answer['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($answer['answer_content']))));
     // 	$answer['agree_users'] = $answer_agree_users[$answer['answer_id']];
     // 	$answer['agree_status'] = $answer_vote_status[$answer['answer_id']];
     // 	if ($question_info['best_answer'] == $answer['answer_id'] AND intval($_GET['page']) < 2)
     // 	{
     // 		$answers[0] = $answer;
     // 	}
     // 	else
     // 	{
     // 		$answers[] = $answer;
     // 	}
     // 	// 获取回答评论列表
     // 	$comments = $this->model('answer')->get_answer_comments($answer['answer_id']);
     // 	$user_infos = $this->model('account')->get_user_info_by_uids(fetch_array_value($comments, 'uid'));
     // 	foreach ($comments as $key => $val)
     // 	{
     // 		$comments[$key]['message'] = FORMAT::parse_links($this->model('question')->parse_at_user($comments[$key]['message']));
     // 		$comments[$key]['user_name'] = $user_infos[$val['uid']]['user_name'];
     // 		$comments[$key]['url_token'] = $user_infos[$val['uid']]['url_token'];
     // 	}
     // 	$answer_comments[$answer['answer_id']] = $comments;
     // }
     // if (! $answers[0])
     // {
     // 	unset($answers[0]);
     // }
     // if (get_setting('answer_unique') == 'Y')
     // {
     // if ($this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id))
     // {
     // 	TPL::assign('user_answered', 1);
     // }
     // else
     // {
     // 	TPL::assign('user_answered', 0);
     // }
     // }
     $user_answered = $this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id);
     $answer_count = $question_info['answer_count'];
     TPL::assign('user_answered', $user_answered);
     // TPL::assign('answers', $answers);
     // TPL::assign('comments', $answer_comments);
     TPL::assign('answer_count', $answer_count);
     // }
     // 用户是否通过答题
     $passed_quiz = $this->model('quiz')->user_question_quiz_passed($question_info['question_id'], $this->user_id);
     $show_answers = ($question_info['published_uid'] == $this->user_id or $this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or $user_answered or $passed_quiz);
     TPL::assign('show_answers', $show_answers);
     if ($this->user_id) {
         TPL::assign('question_thanks', $this->model('question')->get_question_thanks($question_info['question_id'], $this->user_id));
         // TPL::assign('invite_users', $this->model('question')->get_invite_users($question_info['question_id']));
         TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $question_info['published_uid']));
         if ($this->user_info['draft_count'] > 0) {
             TPL::assign('draft_content', $this->model('draft')->get_data($question_info['question_id'], 'answer', $this->user_id));
         }
     }
     $question_info['question_detail'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($question_info['question_detail'])));
     // 获取答题选项类型
     if ($question_info['quiz_id']) {
         $question_info['quiz_info'] = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']);
     }
     TPL::assign('question_info', $question_info);
     TPL::assign('question_focus', $this->model('question')->has_focus_question($question_info['question_id'], $this->user_id));
     $question_topics = $this->model('topic')->get_topics_by_item_id($question_info['question_id'], 'question');
     if (sizeof($question_topics) == 0 and $this->user_id) {
         $related_topics = $this->model('question')->get_related_topics($question_info['question_content']);
         TPL::assign('related_topics', $related_topics);
     }
     TPL::assign('question_topics', $question_topics);
     // 可能喜欢的问题
     $exclude_qids[] = $question_info['question_id'];
     $recommend_questions = $this->model('question')->get_recommend_question_list_by_category($question_info['question_id'], $exclude_qids, $this->user_id, 8);
     if ($recommend_questions) {
         foreach ($recommend_questions as $key => $value) {
             // 获取相关问题的附加图片
             if ($value['has_attach']) {
                 $recommend_questions[$key]['attachs'] = $this->model('publish')->get_attach('question', $value['question_id'], 'min');
             }
             // 获取是否为限时答题信息
             $is_countdown = false;
             if ($value['quiz_id']) {
                 $quiz_info = $this->model('quiz')->get_question_quiz_info_by_id($value['quiz_id']);
                 $is_countdown = $quiz_info['countdown'] > 0;
             }
             $recommend_questions[$key]['is_countdown'] = $is_countdown;
         }
         TPL::assign('recommend_question_list', $recommend_questions);
     }
     TPL::assign('question_related_links', $this->model('related')->get_related_links('question', $question_info['question_id']));
     // 推荐用户答题功能
     $exclude_uids[] = $question_info['published_uid'];
     if ($this->user_id) {
         $exclude_uids[] = $this->user_id;
     }
     $invited_uids = $this->model('question')->get_invited_user_ids($question_info['question_id']);
     if ($invited_uids) {
         foreach ($invited_uids as $key => $val) {
             $exclude_uids[] = $val['uid'];
         }
     }
     if ($question_info['quiz_id']) {
         $answered_uids = $this->model('question')->get_quized_uids($question_info['question_id']);
     } else {
         $answered_uids = $this->model('question')->get_commented_uids($question_info['question_id']);
     }
     if ($answered_uids) {
         foreach ($answered_uids as $val) {
             if (!in_array($val, $exclude_uids)) {
                 $exclude_uids[] = $val['uid'];
             }
         }
     }
     TPL::assign('exclude_uids', $exclude_uids);
     $recommend_users = $this->model('question')->get_recommend_users_by_category_id($question_info['category_id'], $exclude_uids, get_setting('user_question_invite_recommend'));
     if ($recommend_users) {
         $uids = null;
         foreach ($recommend_users as $key => $val) {
             $uids[] = $val['uid'];
         }
         $users_info = $this->model('account')->get_user_info_by_uids($uids, true);
         foreach ($recommend_users as $key => $val) {
             $recommend_users[$key]['user_info'] = $users_info[$val['uid']];
         }
     }
     TPL::assign('recommend_users', $recommend_users);
     TPL::assign('invited_user_count', $this->model('question')->get_invited_user_count($question_info['question_id']));
     // if ($this->user_id)
     // {
     // 	if ($question_topics)
     // 	{
     // 		foreach ($question_topics AS $key => $val)
     // 		{
     // 			$question_topic_ids[] = $val['topic_id'];
     // 		}
     // 	}
     // 	if ($recommend_users = $this->model('topic')->get_recommend_users_by_topic_ids($question_topic_ids, 17))
     // 	{
     // 		foreach ($recommend_users AS $key => $val)
     // 		{
     // 			if ($val['user_info']['uid'] == $this->user_id)
     // 			{
     // 				unset($recommend_users[$key]);
     // 			}
     // 			else
     // 			{
     // 				$recommend_users[$key]['has_invite'] = $this->model('question')->has_question_invite($question_info['question_id'], $val['user_info']['uid'], $this->user_id);
     // 				$recommend_users[$key]['experience'] = end($recommend_users[$key]['experience']);
     // 			}
     // 		}
     // 		TPL::assign('recommend_users', $recommend_users);
     // 	}
     // }
     $this->crumb($question_info['question_content'], '/question/' . $question_info['question_id']);
     if ($_GET['column'] == 'log') {
         // $this->crumb(AWS_APP::lang()->_t('日志'), '/question/id-' . $question_info['question_id'] . '__column-log');
     } else {
         TPL::assign('human_valid', human_valid('answer_valid_hour'));
         if ($this->user_id) {
             TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/question/id-' . $question_info['question_id'] . '__sort_key-' . $_GET['sort_key'] . '__sort-' . $_GET['sort'] . '__uid-' . $_GET['uid']), 'total_rows' => $answer_count, 'per_page' => 100))->create_links());
         }
     }
     TPL::set_meta('keywords', implode(',', $this->model('system')->analysis_keyword($question_info['question_content'])));
     TPL::set_meta('description', $question_info['question_content'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($question_info['question_detail'])), 0, 128, 'UTF-8', '...'));
     if (get_setting('advanced_editor_enable') == 'Y') {
         import_editor_static_files();
     }
     if (get_setting('upload_enable') == 'Y') {
         // fileupload
         TPL::import_js('js/fileupload.js');
     }
     TPL::assign('redirect_message', $redirect_message);
     $recommend_posts = $this->model('posts')->get_recommend_posts_by_topic_ids($question_topic_ids);
     if ($recommend_posts) {
         foreach ($recommend_posts as $key => $value) {
             if ($value['question_id'] and $value['question_id'] == $question_info['question_id']) {
                 unset($recommend_posts[$key]);
                 break;
             }
         }
         TPL::assign('recommend_posts', $recommend_posts);
     }
     // 是否进行出题成功提示
     if ($this->user_id == $question_info['published_uid'] and $question_info['is_first']) {
         TPL::assign('is_first_visited', true);
         TPL::assign('publish_integral', get_setting('integral_system_config_new_question'));
         TPL::assign('user_integral', $this->user_info['integral']);
         $this->model('question')->set_is_first_visited($question_info['question_id'], 0);
     }
     // 答题动态信息
     $question_quiz_record = $this->model('quiz')->get_question_quiz_record_list_page($question_info['question_id'], 1, 5);
     TPL::assign('question_quiz_record', $question_quiz_record);
     // // 添加题目解析提示提示
     // if($this->user_id == $question_info['published_uid'] AND !$question_info['solution_id'])
     // {
     // 	TPL::assign('show_add_solution_hint', true);
     // }
     // 获取上一道题目和下一道题目的信息
     // $question_info_next = $this->model('question')->get_next_question_info($question_info['question_id']);
     // $question_info_previous = $this->model('question')->get_previous_question_info($question_info['question_id']);
     // TPL::assign('question_info_next', $question_info_next);
     // TPL::assign('question_info_previous', $question_info_previous);
     TPL::import_js('js/app/question.js');
     TPL::import_js('js/bootstrap-growl.min.js');
     TPL::import_js('js/quiz.js');
     TPL::import_css('css/quiz.css');
     TPL::import_js('js/sweetalert.min.js');
     TPL::import_css('css/sweetalert.css');
     TPL::import_js('js/jquery-qrcode.min.js');
     TPL::import_js('js/share.js');
     TPL::output('question/index');
 }
예제 #13
0
 public function setup()
 {
     $this->crumb(AWS_APP::lang()->_t('找回密码'), '/account/find_password/');
     TPL::import_css('css/register.css');
 }
예제 #14
0
 public function setup()
 {
     if ($_GET['ignore_ua_check'] == 'FALSE') {
         HTTP::set_cookie('_ignore_ua_check', 'FALSE');
     }
     if (!is_mobile()) {
         switch ($_GET['act']) {
             default:
                 HTTP::redirect('/');
                 break;
             case 'home':
                 HTTP::redirect('/home/');
                 break;
             case 'login':
                 HTTP::redirect('/account/login/');
                 break;
             case 'question':
                 HTTP::redirect('/question/' . $_GET['id']);
                 break;
             case 'register':
                 HTTP::redirect('/account/register/');
                 break;
             case 'topic':
                 HTTP::redirect('/topic/' . $_GET['id']);
                 break;
             case 'people':
                 HTTP::redirect('/people/' . $_GET['id']);
                 break;
             case 'article':
                 HTTP::redirect('/article/' . $_GET['id']);
                 break;
         }
     }
     if (!$this->user_id and !$this->user_info['permission']['visit_site'] and $_GET['act'] != 'login' and $_GET['act'] != 'register') {
         HTTP::redirect('/m/login/url-' . base64_encode($_SERVER['REQUEST_URI']));
     }
     switch ($_GET['act']) {
         default:
             if (!$this->user_id) {
                 HTTP::redirect('/m/login/url-' . base64_encode($_SERVER['REQUEST_URI']));
             }
             break;
         case 'index':
         case 'explore':
         case 'login':
         case 'question':
         case 'register':
         case 'topic':
         case 'search':
         case 'people':
         case 'article':
         case 'find_password':
         case 'find_password_success':
         case 'find_password_modify':
             // Public page..
             break;
     }
     TPL::import_clean();
     TPL::import_css(array('mobile/css/mobile.css'));
     TPL::import_js(array('js/jquery.2.js', 'js/jquery.form.js', 'mobile/js/framework.js', 'mobile/js/aws-mobile.js', 'mobile/js/app.js', 'mobile/js/aw-mobile-template.js'));
     if (in_weixin()) {
         $noncestr = mt_rand(1000000000, 9999999999.0);
         TPL::assign('weixin_noncestr', $noncestr);
         $jsapi_ticket = $this->model('openid_weixin_weixin')->get_jsapi_ticket($this->model('openid_weixin_weixin')->get_access_token(get_setting('weixin_app_id'), get_setting('weixin_app_secret')));
         $url = ($_SERVER['HTTPS'] and !in_array(strtolower($_SERVER['HTTPS']), array('off', 'no'))) ? 'https' : 'http';
         $url .= '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         TPL::assign('weixin_signature', $this->model('openid_weixin_weixin')->generate_jsapi_ticket_signature($jsapi_ticket, $noncestr, TIMESTAMP, $url));
     }
 }
예제 #15
0
 public function setup()
 {
     $this->crumb(AWS_APP::lang()->_t('设置'), '/account/setting/');
     TPL::import_css('css/user-setting.css');
 }
예제 #16
0
파일: main.php 프로젝트: egogg/wecenter-dev
 public function index_action()
 {
     if ($this->user_id) {
         $this->crumb(AWS_APP::lang()->_t('精选'), '/explore');
         if (!$this->user_info['email']) {
             HTTP::redirect('/account/complete_profile/');
         }
     }
     if ($_GET['category']) {
         if (is_digits($_GET['category'])) {
             $category_info = $this->model('system')->get_category_info($_GET['category']);
         } else {
             $category_info = $this->model('system')->get_category_info_by_url_token($_GET['category']);
         }
     }
     if ($category_info) {
         TPL::assign('category_info', $category_info);
         $this->crumb($category_info['title'], '/category-' . $category_info['id']);
         $meta_description = $category_info['title'];
         if ($category_info['description']) {
             $meta_description .= ' - ' . $category_info['description'];
         }
         TPL::set_meta('description', $meta_description);
     }
     // 首页幻灯片
     $slides = $this->model('slide')->get_frontend_slides();
     foreach ($slides as $key => $val) {
         $slides[$key]['category_info'] = $this->model('slide')->get_slide_category_info($val['category']);
     }
     TPL::assign('slides', $slides);
     // 导航
     if (TPL::is_output('block/content_nav_menu.tpl.htm', 'explore/index')) {
         TPL::assign('content_nav_menu', $this->model('menu')->get_nav_menu_list('explore'));
     }
     // 置顶问题
     $recommend_items = $this->model('recommend')->get_recommend_homepage_items('top_question', $limit = 4);
     foreach ($recommend_items as $key => $item) {
         $question_info = $this->model('question')->get_question_info_by_id($item['item_id']);
         if ($question_info['has_attach']) {
             $question_info['attachs'] = $this->model('publish')->get_attach('question', $question_info['question_id'], 'square');
         }
         // 答题选项
         if ($question_info['quiz_id'] > 0) {
             $question_info['quiz_info'] = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']);
         }
         // 分类信息
         $question_info['category_info'] = $this->model('system')->get_category_info($question_info['category_id']);
         $top_question_list[$key] = $question_info;
     }
     TPL::assign('top_question_list', $top_question_list);
     // 精选问题
     $filter_info = array('sort_type' => $_GET['sort_type'], 'category_id' => $category_info['id'], 'difficulty' => intval($_GET['difficulty']), 'quiztype' => intval($_GET['quiztype']), 'countdown' => intval($_GET['countdown']), 'urecord' => $_GET['urecord'], 'date' => $_GET['date'], 'url_base' => '/');
     TPL::assign('filter_info', $filter_info);
     $recommend_question_list = $this->model('question')->get_homepage_recommend_question_list($_GET['page'], get_setting('contents_per_page'), $_GET['sort_type'], $category_info['id'], $_GET['difficulty'], $_GET['quiztype'], $_GET['countdown'], $_GET['urecord'], $_GET['date'], $this->user_id);
     if ($recommend_question_list) {
         foreach ($recommend_question_list as $key => $val) {
             $this->model('question')->load_list_question_info($recommend_question_list[$key], $val, $this->user_id);
         }
     }
     TPL::assign('recommend_homepage_questions', $recommend_question_list);
     // TPL::assign('pagination', AWS_APP::pagination()->initialize(array(
     // 	'base_url' => get_js_url('/sort_type-' . preg_replace("/[\(\)\.;']/", '', $_GET['sort_type']) . '__category-' . $category_info['id'] . '__difficulty-' . $_GET['difficulty'] . '__quiztype-' . $_GET['quiztype'] . '__countdown-' . $_GET['countdown'] . '__is_recommend-' . $_GET['is_recommend'] . '__urecord-' . $_GET['urecord'] . '__date-' . $_GET['date']),
     // 	'total_rows' => $this->model('question')->get_homepage_recommend_question_list_total(),
     // 	'per_page' => get_setting('contents_per_page'),
     // 	'num_links' => 2
     // ))->create_links());
     // 精选专题
     $recommend_items = $this->model('recommend')->get_recommend_homepage_items('topic', $limit = 4);
     foreach ($recommend_items as $key => $item) {
         $topic_info = $this->model('topic')->get_topic_by_id($item['item_id']);
         $topic_info['topic_description'] = nl2br(FORMAT::parse_bbcode($topic_info['topic_description']));
         if ($topic_info['parent_id']) {
             $parent_topic_info = $this->model('topic')->get_topic_by_id($topic_info['parent_id']);
             $topic_info['category'] = $parent_topic_info['topic_title'];
             $topic_info['category_id'] = $parent_topic_info['topic_id'];
         }
         $recommend_homepage_topics[$key] = $topic_info;
     }
     TPL::assign('recommend_homepage_topics', $recommend_homepage_topics);
     // 精选知识
     $recommend_items = $this->model('recommend')->get_recommend_homepage_items('article', $limit = 5);
     foreach ($recommend_items as $key => $item) {
         $article_ids[] = $item['item_id'];
     }
     // 获取文章缩略图
     $article_attachs = $this->model('publish')->get_attachs('article', $article_ids, 'min');
     foreach ($recommend_items as $key => $item) {
         $article_info = $this->model('article')->get_article_info_by_id($item['item_id']);
         $article_info['attachs'] = $article_attachs[$article_info['id']];
         $recommend_homepage_articles[$key] = $article_info;
     }
     TPL::assign('recommend_homepage_articles', $recommend_homepage_articles);
     // 边栏可能感兴趣的人
     if (TPL::is_output('block/sidebar_recommend_users_topics.tpl.htm', 'explore/index')) {
         TPL::assign('sidebar_recommend_users_topics', $this->model('module')->recommend_users_topics($this->user_id));
     }
     // 边栏热门用户
     if (TPL::is_output('block/sidebar_hot_users.tpl.htm', 'explore/index')) {
         TPL::assign('sidebar_hot_users', $this->model('module')->sidebar_hot_users($this->user_id, 5));
     }
     // 边栏热门话题
     if (TPL::is_output('block/sidebar_hot_topics.tpl.htm', 'explore/index')) {
         TPL::assign('sidebar_hot_topics', $this->model('module')->sidebar_hot_topics($category_info['id']));
     }
     // 边栏专题
     if (TPL::is_output('block/sidebar_feature.tpl.htm', 'explore/index')) {
         TPL::assign('feature_list', $this->model('module')->feature_list());
     }
     // if (! $_GET['sort_type'] AND !$_GET['is_recommend'])
     // {
     // 	$_GET['sort_type'] = 'new';
     // }
     // if ($_GET['sort_type'] == 'hot')
     // {
     // 	$posts_list = $this->model('posts')->get_hot_posts(null, $category_info['id'], null, $_GET['day'], $_GET['page'], get_setting('contents_per_page'));
     // }
     // else
     // {
     // 	$posts_list = $this->model('posts')->get_posts_list(null, $_GET['page'], get_setting('contents_per_page'), $_GET['sort_type'], null, $category_info['id'], $_GET['answer_count'], $_GET['day'], $_GET['is_recommend']);
     // }
     // if ($posts_list)
     // {
     // 	foreach ($posts_list AS $key => $val)
     // 	{
     // 		if ($val['answer_count'])
     // 		{
     // 			$posts_list[$key]['answer_users'] = $this->model('question')->get_answer_users_by_question_id($val['question_id'], 2, $val['published_uid']);
     // 		}
     // 	}
     // }
     // TPL::assign('pagination', AWS_APP::pagination()->initialize(array(
     // 	'base_url' => get_js_url('/sort_type-' . preg_replace("/[\(\)\.;']/", '', $_GET['sort_type']) . '__category-' . $category_info['id'] . '__day-' . intval($_GET['day']) . '__is_recommend-' . intval($_GET['is_recommend'])),
     // 	'total_rows' => $this->model('posts')->get_posts_list_total(),
     // 	'per_page' => get_setting('contents_per_page')
     // ))->create_links());
     // TPL::assign('posts_list', $posts_list);
     // TPL::assign('posts_list_bit', TPL::output('explore/ajax/list', false));
     // 是否签到成功
     TPL::assign('signed_in', $this->model('sign')->is_signed_today($this->user_id));
     // 用户排行榜
     TPL::assign('top_user_list_success_ratio', array_values($this->model('account')->get_top_users('success_ratio', 3)));
     TPL::assign('top_user_list_integral', array_values($this->model('account')->get_top_users('integral', 3)));
     TPL::import_js('js/sweetalert.min.js');
     TPL::import_css('css/sweetalert.css');
     TPL::output('explore/index');
 }
예제 #17
0
 public function bind_action()
 {
     if (AWS_APP::session()->twitter_request_token) {
         $twitter_request_token = AWS_APP::session()->twitter_request_token;
         unset(AWS_APP::session()->twitter_request_token);
     }
     if (AWS_APP::session()->twitter_user) {
         $twitter_user_info = AWS_APP::session()->twitter_user;
         unset(AWS_APP::session()->twitter_user);
     }
     if ($_GET['denied']) {
         H::redirect_msg(AWS_APP::lang()->_t('授权失败'), '/account/login/');
     }
     if ($this->user_id) {
         $twitter_user = $this->model('openid_twitter')->get_twitter_user_by_uid($this->user_id);
         if ($twitter_user) {
             H::redirect_msg(AWS_APP::lang()->_t('此账号已绑定 Twitter 账号'), '/account/login/');
         }
     }
     if ($_GET['oauth_token']) {
         if (!$twitter_user_info) {
             if ($_GET['oauth_token'] != $twitter_request_token['oauth_token']) {
                 H::redirect_msg(AWS_APP::lang()->_t('oauth token 不一致'), '/account/login/');
             }
             if (!$_GET['oauth_verifier']) {
                 H::redirect_msg(AWS_APP::lang()->_t('oauth verifier 为空'), '/account/login/');
             }
             $this->model('openid_twitter')->request_token = $twitter_request_token;
             $this->model('openid_twitter')->request_token['oauth_verifier'] = $_GET['oauth_verifier'];
             if (!$this->model('openid_twitter')->get_user_info()) {
                 H::redirect_msg($this->model('openid_twitter')->error_msg, '/account/login/');
             }
             $twitter_user_info = $this->model('openid_twitter')->user_info;
         }
         if (!$twitter_user_info) {
             H::redirect_msg(AWS_APP::lang()->_t('Twitter 登录失败,用户信息不存在'), '/account/login/');
         }
         $twitter_user = $this->model('openid_twitter')->get_twitter_user_by_id($twitter_user_info['id']);
         if ($this->user_id) {
             if ($twitter_user) {
                 H::redirect_msg(AWS_APP::lang()->_t('此 Twitter 账号已被绑定'), '/account/login/');
             }
             $this->model('openid_twitter')->bind_account($twitter_user_info, $this->user_id);
             if (!$this->model('integral')->fetch_log($this->user_id, 'BIND_OPENID')) {
                 $this->model('integral')->process($this->user_id, 'BIND_OPENID', round(get_setting('integral_system_config_profile') * 0.2), '绑定 OPEN ID');
             }
             HTTP::redirect('/account/setting/openid/');
         } else {
             if ($twitter_user) {
                 $user = $this->model('account')->get_user_info_by_uid($twitter_user['uid']);
                 if (!$user) {
                     $this->model('openid_twitter')->unbind_account($twitter_user['uid']);
                     H::redirect_msg(AWS_APP::lang()->_t('本地用户不存在'), '/account/login/');
                 }
                 $this->model('openid_twitter')->update_user_info($twitter_user['id'], $twitter_user_info);
                 if (get_setting('register_valid_type') == 'approval' and $user['group_id'] == 3) {
                     $redirect_url = '/account/valid_approval/';
                 } else {
                     if (get_setting('ucenter_enabled') == 'Y') {
                         $redirect_url = '/account/sync_login/';
                         if ($_GET['return_url']) {
                             $redirect_url .= 'url-' . $_GET['return_url'];
                         }
                     } else {
                         if ($state['return_url']) {
                             $redirect_url = $state['return_url'];
                         } else {
                             $redirect_url = '/';
                         }
                     }
                     HTTP::set_cookie('_user_login', get_login_cookie_hash($user['user_name'], $user['password'], $user['salt'], $user['uid'], false));
                     if (get_setting('register_valid_type') == 'email' and !$user['valid_email']) {
                         AWS_APP::session()->valid_email = $user['email'];
                     }
                 }
                 HTTP::redirect($redirect_url);
             } else {
                 switch (get_setting('register_type')) {
                     case 'close':
                         H::redirect_msg(AWS_APP::lang()->_t('本站目前关闭注册'), '/account/login/');
                         break;
                     case 'invite':
                         H::redirect_msg(AWS_APP::lang()->_t('本站只能通过邀请注册'), '/account/login/');
                         break;
                     case 'weixin':
                         H::redirect_msg(AWS_APP::lang()->_t('本站只能通过微信注册'), '/account/login/');
                         break;
                 }
                 AWS_APP::session()->twitter_user = $twitter_user_info;
                 $this->crumb(AWS_APP::lang()->_t('完善资料'), '/account/login/');
                 TPL::assign('register_url', '/account/ajax/twitter/register/');
                 TPL::assign('user_name', AWS_APP::session()->twitter_user['name']);
                 TPL::import_css('css/register.css');
                 TPL::output('account/openid/callback');
             }
         }
     } else {
         $this->model('openid_twitter')->oauth_callback = '/account/openid/twitter/bind/';
         if ($_GET['return_url']) {
             $this->model('openid_twitter')->oauth_callback .= 'return_url-' . $_GET['return_url'];
         }
         if (!$this->model('openid_twitter')->oauth_redirect()) {
             H::redirect_msg($this->model('openid_twitter')->error_msg, '/account/login/');
         }
         AWS_APP::session()->twitter_request_token = $this->model('openid_twitter')->request_token;
         HTTP::redirect($this->model('openid_twitter')->redirect_url);
     }
 }
예제 #18
0
 public function valid_approval_action()
 {
     if ($this->user_id and $this->user_info['group_id'] != 3) {
         HTTP::redirect('/');
     }
     TPL::import_css('css/register.css');
     TPL::output('account/valid_approval');
 }
예제 #19
0
파일: main.php 프로젝트: egogg/wecenter-dev
 public function index_action()
 {
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if (!($article_info = $this->model('article')->get_article_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('文章不存在或已被删除'), '/');
     }
     if ($article_info['has_attach']) {
         $article_info['attachs'] = $this->model('publish')->get_attach('article', $article_info['id'], 'min');
         $article_info['attachs_ids'] = FORMAT::parse_attachs($article_info['message'], true);
     }
     $article_info['user_info'] = $this->model('account')->get_user_info_by_uid($article_info['uid'], true);
     $article_info['message'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($article_info['message'])));
     if ($this->user_id) {
         $article_info['vote_info'] = $this->model('article')->get_article_vote_by_id('article', $article_info['id'], null, $this->user_id);
     }
     $article_info['vote_users'] = $this->model('article')->get_article_vote_users_by_id('article', $article_info['id'], 1, 10);
     // 是否为推荐到首页
     $article_info['is_recommend_homepage'] = $this->model('recommend')->recommend_homepage_check('article', $article_info['id']);
     TPL::assign('article_info', $article_info);
     $article_topics = $this->model('topic')->get_topics_by_item_id($article_info['id'], 'article');
     if ($article_topics) {
         TPL::assign('article_topics', $article_topics);
         foreach ($article_topics as $topic_info) {
             $article_topic_ids[] = $topic_info['topic_id'];
         }
     }
     TPL::assign('reputation_topics', $this->model('people')->get_user_reputation_topic($article_info['user_info']['uid'], $user['reputation'], 5));
     $this->crumb($article_info['title'], '/article/' . $article_info['id']);
     TPL::assign('human_valid', human_valid('answer_valid_hour'));
     if ($_GET['item_id']) {
         $comments[] = $this->model('article')->get_comment_by_id($_GET['item_id']);
     } else {
         $comments = $this->model('article')->get_comments($article_info['id'], $_GET['page'], 50);
     }
     if ($comments and $this->user_id) {
         foreach ($comments as $key => $val) {
             $comments[$key]['vote_info'] = $this->model('article')->get_article_vote_by_id('comment', $val['id'], 1, $this->user_id);
             $comments[$key]['message'] = $this->model('question')->parse_at_user($val['message']);
         }
     }
     if ($this->user_id) {
         TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $article_info['uid']));
     }
     TPL::assign('question_related_list', $this->model('question')->get_related_question_list(null, $article_info['title']));
     // 最新推荐文章
     $hot_articles = $this->model('article')->get_articles_list(null, 1, 5, 'votes DESC', null);
     foreach ($hot_articles as $key => $val) {
         $article_ids[] = $val['id'];
     }
     $article_attachs = $this->model('publish')->get_attachs('article', $article_ids, 'min');
     foreach ($hot_articles as $key => $val) {
         $hot_articles[$key]['attachs'] = $article_attachs[$val['id']];
     }
     TPL::assign('hot_articles', $hot_articles);
     // 推荐专题
     if (TPL::is_output('block/sidebar_hot_topics.tpl.htm', 'question/square')) {
         TPL::assign('sidebar_hot_topics', $this->model('module')->sidebar_hot_topics($_GET['category'], 4));
     }
     $this->model('article')->update_views($article_info['id']);
     TPL::assign('comments', $comments);
     TPL::assign('comments_count', $article_info['comments']);
     TPL::assign('human_valid', human_valid('answer_valid_hour'));
     TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/article/id-' . $article_info['id']), 'total_rows' => $article_info['comments'], 'per_page' => 50))->create_links());
     TPL::set_meta('keywords', implode(',', $this->model('system')->analysis_keyword($article_info['title'])));
     TPL::set_meta('description', $article_info['title'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($article_info['message'])), 0, 128, 'UTF-8', '...'));
     TPL::assign('attach_access_key', md5($this->user_id . time()));
     $recommend_posts = $this->model('posts')->get_recommend_posts_by_topic_ids($article_topic_ids);
     if ($recommend_posts) {
         foreach ($recommend_posts as $key => $value) {
             if ($value['id'] and $value['id'] == $article_info['id']) {
                 unset($recommend_posts[$key]);
                 break;
             }
         }
         TPL::assign('recommend_posts', $recommend_posts);
     }
     // 收藏数量
     $bookmark_count = $this->model('favorite')->get_favorite_counts('article', $article_info['id']);
     TPL::assign('bookmark_count', $bookmark_count);
     TPL::import_js('js/sweetalert.min.js');
     TPL::import_css('css/sweetalert.css');
     TPL::import_js('js/jquery-qrcode.min.js');
     TPL::import_js('js/share.js');
     TPL::output('article/index');
 }
예제 #20
0
파일: main.php 프로젝트: egogg/wecenter-dev
 public function questions_action()
 {
     if (isset($_GET['notification_id'])) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if (is_digits($_GET['id'])) {
         if (!($user = $this->model('account')->get_user_info_by_uid($_GET['id'], TRUE))) {
             $user = $this->model('account')->get_user_info_by_username($_GET['id'], TRUE);
         }
     } else {
         if ($user = $this->model('account')->get_user_info_by_username($_GET['id'], TRUE)) {
         } else {
             $user = $this->model('account')->get_user_info_by_url_token($_GET['id'], TRUE);
         }
     }
     if (!$user) {
         H::redirect_msg(AWS_APP::lang()->_t('用户不存在'), '/');
     }
     // if (urldecode($user['url_token']) != $_GET['id'])
     // {
     //     HTTP::redirect('/people/' . $user['url_token']);
     // }
     // $this->model('people')->update_views($user['uid']);
     TPL::assign('user', $user);
     // $job_info = $this->model('account')->get_jobs_by_id($user['job_id']);
     // TPL::assign('job_name', $job_info['job_name']);
     if ($user['weibo_visit']) {
         if ($users_sina = $this->model('openid_weibo_oauth')->get_weibo_user_by_uid($user['uid'])) {
             TPL::assign('sina_weibo_url', 'http://www.weibo.com/' . $users_sina['id']);
         }
     }
     TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $user['uid']));
     $this->crumb(AWS_APP::lang()->_t('%s 的个人主页', $user['user_name']), 'people/' . $user['url_token']);
     TPL::import_css('css/user.css');
     TPL::assign('user_answered_question_count', $this->model('quiz')->get_user_answerd_question_count($user['uid']));
     TPL::assign('user_failed_question_count', $this->model('quiz')->get_user_failed_question_count($user['uid']));
     if ($_GET['type'] == 'answered') {
         TPL::assign('user_question_list_answered', $this->model('question')->get_user_question_list_answered($user['uid'], 1, get_setting('contents_per_page')));
         TPL::assign('current_menu', 'questions_answered');
     } else {
         if ($_GET['type'] == 'comments') {
             TPL::assign('user_answer_list', $this->model('answer')->get_user_answer_list($user['uid'], 1, get_setting('contents_per_page')));
             TPL::assign('current_menu', 'questions_comments');
         } else {
             if ($_GET['type'] == 'failed') {
                 TPL::assign('user_question_list_failed', $this->model('question')->get_user_question_list_failed($user['uid'], 1, get_setting('contents_per_page')));
                 TPL::assign('current_menu', 'questions_failed');
             } else {
                 if ($_GET['type'] == 'publish') {
                     TPL::assign('user_question_list_publish', $this->model('question')->get_user_question_list_publish($user['uid'], 1, get_setting('contents_per_page')));
                     TPL::assign('current_menu', 'questions_publish');
                 } else {
                     TPL::assign('user_question_list_answered', $this->model('question')->get_user_question_list_answered($user['uid'], 1, get_setting('contents_per_page')));
                     TPL::assign('current_menu', 'questions_answered');
                 }
             }
         }
     }
     TPL::output('people/questions');
 }