Example #1
0
 public function update_views($uid)
 {
     if (AWS_APP::cache()->get('update_views_people_' . md5(session_id()) . '_' . intval($uid))) {
         return false;
     }
     AWS_APP::cache()->set('update_views_people_' . md5(session_id()) . '_' . intval($uid), time(), get_setting('cache_level_normal'));
     return $this->query('UPDATE ' . $this->get_table('users') . ' SET views_count = views_count + 1 WHERE uid = ' . intval($uid));
 }
Example #2
0
 public function get_font()
 {
     if (!($captcha_fonts = AWS_APP::cache()->get('captcha_fonts'))) {
         $captcha_fonts = fetch_file_lists(AWS_PATH . 'core/fonts/');
         AWS_APP::cache()->set('captcha_fonts', $captcha_fonts, get_setting('cache_level_normal'));
     }
     return array_random($captcha_fonts);
 }
Example #3
0
 public function get_notifications_texts()
 {
     $notifications = AWS_APP::cache()->get('admin_notifications');
     if (!$notifications) {
         $notifications = get_setting('admin_notifications');
     }
     if (!$notifications) {
         return false;
     }
     if ($notifications['question_approval']) {
         $notifications_texts[] = array('url' => 'admin/approval/list/', 'text' => AWS_APP::lang()->_t('有 %s 个主题待审核', $notifications['question_approval']));
     }
     if ($notifications['unverified_modify_count']) {
         $notifications_texts[] = array('url' => 'admin/approval/list/type-unverified_modify', 'text' => AWS_APP::lang()->_t('有 %s 个主题修改待审核', $notifications['unverified_modify_count']));
     }
     if ($notifications['answer_approval']) {
         $notifications_texts[] = array('url' => 'admin/approval/list/type-answer', 'text' => AWS_APP::lang()->_t('有 %s 个回复待审核', $notifications['answer_approval']));
     }
     if ($notifications['article_approval']) {
         $notifications_texts[] = array('url' => 'admin/approval/list/type-article', 'text' => AWS_APP::lang()->_t('有 %s 篇文章待审核', $notifications['article_approval']));
     }
     if ($notifications['article_comment_approval']) {
         $notifications_texts[] = array('url' => 'admin/approval/list/type-article_comment', 'text' => AWS_APP::lang()->_t('有 %s 个文章评论待审核', $notifications['article_comment_approval']));
     }
     if ($notifications['weibo_msg_approval']) {
         $notifications_texts[] = array('url' => 'admin/approval/list/type-weibo_msg', 'text' => AWS_APP::lang()->_t('有 %s 个微博消息待审核', $notifications['weibo_msg_approval']));
     }
     if ($notifications['received_email_approval']) {
         $notifications_texts[] = array('url' => 'admin/approval/list/type-received_email', 'text' => AWS_APP::lang()->_t('有 %s 个邮件咨询待审核', $notifications['received_email_approval']));
     }
     if ($notifications['user_report']) {
         $notifications_texts[] = array('url' => 'admin/question/report_list/', 'text' => AWS_APP::lang()->_t('有 %s 个用户举报待查看', $notifications['user_report']));
     }
     if (get_setting('register_valid_type') == 'approval' and $notifications['register_approval']) {
         $notifications_texts[] = array('url' => 'admin/user/register_approval_list/', 'text' => AWS_APP::lang()->_t('有 %s 个新用户待审核', $notifications['register_approval']));
     }
     if ($notifications['verify_approval']) {
         $notifications_texts[] = array('url' => 'admin/user/verify_approval_list/', 'text' => AWS_APP::lang()->_t('有 %s 个认证申请待审核', $notifications['verify_approval']));
     }
     if ($notifications['last_version']['build_day'] > G_VERSION_BUILD and $this->user_info['is_administortar']) {
         $notifications_texts[] = array('url' => 'http://www.HeavenSpree.com/downloads/', 'text' => AWS_APP::lang()->_t('程序需要更新,最新版本为 %s', $notifications['last_version']['version']));
     }
     if (get_setting('weibo_msg_enabled') == 'Y' and $notifications['sina_users']) {
         foreach ($notifications['sina_users'] as $sina_user) {
             $notifications_texts[] = array('url' => 'admin/weibo/msg/', 'text' => AWS_APP::lang()->_t('用户 %s 的微博账号需要更新 Access Token,请重新授权', $sina_user['user_name']));
         }
     }
     $receiving_email_global_config = get_setting('receiving_email_global_config');
     if ($receiving_email_global_config['enabled'] == 'Y' and $notifications['receive_email_error']) {
         foreach ($notifications['receive_email_error'] as $error_msg) {
             $notifications_texts[] = array('url' => 'admin/edm/receiving/id-' . $error_msg['id'], 'text' => AWS_APP::lang()->_t('邮件导入失败,错误为 %s,请重新配置', $error_msg['msg']));
         }
     }
     return $notifications_texts;
 }
 public function save_mobile_app_secret($mobile_app_secret)
 {
     if ($this->fetch_row('system_setting', "varname = 'mobile_app_secret'")) {
         $this->update('system_setting', array('value' => serialize($mobile_app_secret)), "`varname` = 'mobile_app_secret'");
         $this->update('system_setting', array('value' => serialize(time())), "`varname` = 'mobile_app_secret_update_time'");
     } else {
         $this->insert('system_setting', array('value' => serialize($mobile_app_secret), 'varname' => 'mobile_app_secret'));
         $this->insert('system_setting', array('value' => serialize(time()), 'varname' => 'mobile_app_secret_update_time'));
     }
     AWS_APP::cache()->delete('mobile_app_secret');
 }
Example #5
0
 public function minute()
 {
     @unlink(TEMP_PATH . 'plugins_table.php');
     @unlink(TEMP_PATH . 'plugins_model.php');
     if ($this->model('reputation')->calculate(AWS_APP::cache()->get('reputation_calculate_start'), 100)) {
         AWS_APP::cache()->set('reputation_calculate_start', intval(AWS_APP::cache()->get('reputation_calculate_start')) + 100, 604800);
     } else {
         AWS_APP::cache()->set('reputation_calculate_start', 0, 604800);
     }
     $this->model('email')->send_mail_queue(120);
     $this->model('online')->delete_expire_users();
 }
Example #6
0
 public function minute()
 {
     @unlink(TEMP_PATH . 'plugins_table.php');
     @unlink(TEMP_PATH . 'plugins_model.php');
     if ($this->model('reputation')->calculate(AWS_APP::cache()->get('reputation_calculate_start'), 100)) {
         AWS_APP::cache()->set('reputation_calculate_start', intval(AWS_APP::cache()->get('reputation_calculate_start')) + 100, 604800);
     } else {
         AWS_APP::cache()->set('reputation_calculate_start', 0, 604800);
     }
     if (!get_setting('wecenter_access_token')) {
         $this->model('weixin')->get_weixin_app_id_setting_var();
     }
     $this->model('email')->send_mail_queue(120);
     $this->model('online')->delete_expire_users();
 }
Example #7
0
 function bind_account($sina_profile, $redirect, $uid, $sina_token, $is_ajax = false)
 {
     if ($openid_info = $this->get_users_sina_by_uid($uid)) {
         if ($openid_info['id'] != $sina_profile['id']) {
             if ($is_ajax) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('此微博已经与本站的另外一个账号绑定')));
             } else {
                 H::redirect_msg(AWS_APP::lang()->_t('此微博已经与本站的另外一个账号绑定'), '/account/logout/');
             }
         }
     }
     $user_sina = $this->get_users_sina_by_id($sina_profile['id']);
     if (empty($user_sina)) {
         $this->users_sina_add($sina_profile['id'], $uid, $sina_profile['screen_name'], $sina_profile['location'], $sina_profile['description'], $sina_profile['profile_url'], $sina_profile['profile_image_url'], $sina_profile['gender']);
     } else {
         if ($user_sina['uid'] != $uid) {
             if ($is_ajax) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('此账号已经与另外一个微博绑定')));
             } else {
                 H::redirect_msg(AWS_APP::lang()->_t('此账号已经与另外一个微博绑定'), $redirect);
             }
         }
     }
     $this->refresh_access_token($sina_profile['id'], $sina_token);
     $tmp_service_account = AWS_APP::cache()->get('tmp_service_account');
     if ($tmp_service_account[$uid]) {
         $this->model('weibo')->update_service_account($uid, 'add');
         unset($tmp_service_account[$uid]);
         AWS_APP::cache()->set('tmp_service_account', $tmp_service_account, 86400);
     }
     $admin_notifications = get_setting('admin_notifications');
     if ($admin_notifications['sina_users'][$uid]) {
         unset($admin_notifications['sina_users'][$uid]);
     }
     $this->model('setting')->set_vars(array('admin_notifications' => $admin_notifications));
     if ($redirect) {
         HTTP::redirect($redirect);
     } else {
         if ($is_ajax) {
             H::ajax_json_output(AWS_APP::RSM(array('url' => '/'), 1, null));
         } else {
             H::redirect_msg(AWS_APP::lang()->_t('绑定成功'));
         }
     }
 }
Example #8
0
 public function msg_action()
 {
     $this->crumb(AWS_APP::lang()->_t('消息接收'), 'admin/weibo/msg/');
     $services_info = $this->model('weibo')->get_services_info();
     if (!empty($services_info)) {
         foreach ($services_info as $service_info) {
             $service_uids[] = $service_info['uid'];
         }
         $service_users_info = $this->model('account')->get_user_info_by_uids($service_uids);
         TPL::assign('service_users_info', $service_users_info);
     }
     $tmp_service_users_info = AWS_APP::cache()->get('tmp_service_account');
     if (!empty($tmp_service_users_info)) {
         TPL::assign('tmp_service_users_info', $tmp_service_users_info);
     }
     TPL::assign('published_user', get_setting('weibo_msg_published_user'));
     TPL::assign('menu_list', $this->model('admin')->fetch_menu_list(806));
     TPL::output('admin/weibo/msg');
 }
Example #9
0
 public function minute()
 {
     @unlink(TEMP_PATH . 'plugins_table.php');
     @unlink(TEMP_PATH . 'plugins_model.php');
     if ($this->model('reputation')->calculate(AWS_APP::cache()->get('reputation_calculate_start'), 100)) {
         AWS_APP::cache()->set('reputation_calculate_start', intval(AWS_APP::cache()->get('reputation_calculate_start')) + 100, 604800);
     } else {
         AWS_APP::cache()->set('reputation_calculate_start', 0, 604800);
     }
     $this->model('online')->delete_expire_users();
     if (check_extension_package('project')) {
         $expire_orders = $this->fetch_all('product_order', 'add_time < ' . (time() - 600) . ' AND payment_time = 0 AND cancel_time = 0 AND refund_time = 0');
         if ($expire_orders) {
             foreach ($expire_orders as $order_info) {
                 $this->model('project')->cancel_project_order_by_id($order_info['id']);
             }
         }
     }
     $this->model('email')->send_mail_queue(120);
 }
Example #10
0
 public function fetch_answers_list_by_topic_ids($topic_ids, $page, $limit)
 {
     if (!is_array($topic_ids)) {
         return false;
     }
     array_walk_recursive($topic_ids, 'intval_string');
     $result_cache_key = 'reader_list_by_topic_ids_' . md5(implode('_', $topic_ids) . $page . $limit);
     if (!($result = AWS_APP::cache()->get($result_cache_key))) {
         $topic_relation_where[] = '`topic_id` IN(' . implode(',', $topic_ids) . ')';
         $topic_relation_where[] = "`type` = 'question'";
         if ($topic_relation_query = $this->query_all("SELECT item_id FROM " . get_table('topic_relation') . " WHERE " . implode(' AND ', $topic_relation_where))) {
             foreach ($topic_relation_query as $key => $val) {
                 $question_ids[$val['item_id']] = $val['item_id'];
             }
         }
         if (!$question_ids) {
             return false;
         }
         $result = $this->fetch_all('answer', 'question_id IN (' . implode(',', $question_ids) . ') AND add_time > ' . (time() - 86400 * intval(get_setting('reader_questions_last_days'))) . ' AND agree_count >= ' . intval(get_setting('reader_questions_agree_count')), 'add_time DESC', calc_page_limit($page, $limit));
         AWS_APP::cache()->set($result_cache_key, $result, get_setting('cache_level_low'));
     }
     return $result;
 }
Example #11
0
 public function get_groups()
 {
     $groups = AWS_APP::cache()->get('weixin_groups');
     if (!$groups) {
         $result = $this->model('openid_weixin_weixin')->access_request(get_setting('weixin_app_id'), get_setting('weixin_app_secret'), 'groups/get', 'GET');
         if (!$result) {
             return AWS_APP::lang()->_t('远程服务器忙');
         }
         if ($result['errcode']) {
             return $result['errmsg'];
         }
         foreach ($result['groups'] as $group) {
             $groups[$group['id']] = $group;
         }
         AWS_APP::cache()->set('weixin_groups', $groups, get_setting('cache_level_normal'));
     }
     return $groups;
 }
Example #12
0
 public function publish_question_action()
 {
     if (!$this->user_info['permission']['publish_question']) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限发布问题')));
     }
     if ($this->user_info['integral'] < 0 and get_setting('integral_system_enabled') == 'Y') {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你的剩余积分已经不足以进行此操作')));
     }
     if (!$_POST['question_content']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入问题标题')));
     }
     if (get_setting('category_enable') == 'N') {
         $_POST['category_id'] = 1;
     }
     if (!$_POST['category_id']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择问题分类')));
     }
     if (cjk_strlen($_POST['question_content']) < 5) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('问题标题字数不得少于 5 个字')));
     }
     if (get_setting('question_title_limit') > 0 and cjk_strlen($_POST['question_content']) > get_setting('question_title_limit')) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('问题标题字数不得大于 %s 字节', get_setting('question_title_limit'))));
     }
     if (!$this->user_info['permission']['publish_url'] and FORMAT::outside_url_exists($_POST['question_detail'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你所在的用户组不允许发布站外链接')));
     }
     if (human_valid('question_valid_hour') and !AWS_APP::captcha()->is_validate($_POST['seccode_verify'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请填写正确的验证码')));
     }
     if ($_POST['topics']) {
         foreach ($_POST['topics'] as $key => $topic_title) {
             $topic_title = trim($topic_title);
             if (!$topic_title) {
                 unset($_POST['topics'][$key]);
             } else {
                 $_POST['topics'][$key] = $topic_title;
             }
         }
         if (get_setting('question_topics_limit') and sizeof($_POST['topics']) > get_setting('question_topics_limit')) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('单个问题话题数量最多为 %s 个, 请调整话题数量', get_setting('question_topics_limit'))));
         }
     }
     if (!$_POST['topics'] and get_setting('new_question_force_add_topic') == 'Y') {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请为问题添加话题')));
     }
     if (!$this->model('publish')->insert_attach_is_self_upload($_POST['question_detail'], $_POST['attach_ids'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('只允许插入当前页面上传的附件')));
     }
     if ($_POST['weixin_media_id']) {
         $_POST['weixin_media_id'] = base64_decode($_POST['weixin_media_id']);
         $weixin_pic_url = AWS_APP::cache()->get('weixin_pic_url_' . md5($_POST['weixin_media_id']));
         if (!$weixin_pic_url) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('图片已过期或 media_id 无效')));
         }
         $file = $this->model('openid_weixin_weixin')->get_file($_POST['weixin_media_id']);
         if (!$file) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('远程服务器忙')));
         }
         if (is_array($file) and $file['errmsg']) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('获取图片失败,错误为: %s', $file['errmsg'])));
         }
         AWS_APP::upload()->initialize(array('allowed_types' => get_setting('allowed_upload_types'), 'upload_path' => get_setting('upload_dir') . '/questions/' . gmdate('Ymd'), 'is_image' => TRUE, 'max_size' => get_setting('upload_size_limit')));
         AWS_APP::upload()->do_upload($_POST['weixin_media_id'] . '.jpg', $file);
         $upload_error = AWS_APP::upload()->get_error();
         if ($upload_error) {
             switch ($upload_error) {
                 default:
                     H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('保存图片失败,错误为 %s' . $upload_error)));
                     break;
                 case 'upload_invalid_filetype':
                     H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('保存图片失败,本站不允许上传 jpeg 格式的图片')));
                     break;
                 case 'upload_invalid_filesize':
                     H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('图片尺寸过大, 最大允许尺寸为 %s KB', get_setting('upload_size_limit'))));
                     break;
             }
         }
         $upload_data = AWS_APP::upload()->data();
         if (!$upload_data) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('保存图片失败,请与管理员联系')));
         }
         foreach (AWS_APP::config()->get('image')->attachment_thumbnail as $key => $val) {
             $thumb_file[$key] = $upload_data['file_path'] . $val['w'] . 'x' . $val['h'] . '_' . basename($upload_data['full_path']);
             AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $thumb_file[$key], 'width' => $val['w'], 'height' => $val['h']))->resize();
         }
         $this->model('publish')->add_attach('question', $upload_data['orig_name'], $_POST['attach_access_key'], time(), basename($upload_data['full_path']), true);
     }
     // !注: 来路检测后面不能再放报错提示
     if (!valid_post_hash($_POST['post_hash'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('页面停留时间过长,或内容已提交,请刷新页面')));
     }
     $this->model('draft')->delete_draft(1, 'question', $this->user_id);
     if ($this->publish_approval_valid()) {
         $this->model('publish')->publish_approval('question', array('question_content' => $_POST['question_content'], 'question_detail' => $_POST['question_detail'], 'category_id' => $_POST['category_id'], 'topics' => $_POST['topics'], 'anonymous' => $_POST['anonymous'], 'attach_access_key' => $_POST['attach_access_key'], 'ask_user_id' => $_POST['ask_user_id'], 'permission_create_topic' => $this->user_info['permission']['create_topic']), $this->user_id, $_POST['attach_access_key']);
         H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/publish/wait_approval/')), 1, null));
     } else {
         $question_id = $this->model('publish')->publish_question($_POST['question_content'], $_POST['question_detail'], $_POST['category_id'], $this->user_id, $_POST['topics'], $_POST['anonymous'], $_POST['attach_access_key'], $_POST['ask_user_id'], $this->user_info['permission']['create_topic']);
         if ($_POST['_is_mobile']) {
             if ($weixin_user = $this->model('openid_weixin_weixin')->get_user_info_by_uid($this->user_id)) {
                 if ($weixin_user['location_update'] > time() - 7200) {
                     $this->model('geo')->set_location('question', $question_id, $weixin_user['longitude'], $weixin_user['latitude']);
                 }
             }
             $url = get_js_url('/m/question/' . $question_id);
         } else {
             $url = get_js_url('/question/' . $question_id);
         }
         H::ajax_json_output(AWS_APP::RSM(array('url' => $url), 1, null));
     }
 }
Example #13
0
 public function get_user_actions($uid, $limit = 10, $actions = false, $this_uid = 0)
 {
     $cache_key = 'user_actions_' . md5($uid . $limit . $actions . $this_uid);
     if ($user_actions = AWS_APP::cache()->get($cache_key)) {
         return $user_actions;
     }
     $associate_action = ACTION_LOG::ADD_QUESTION;
     if (strstr($actions, ',')) {
         $associate_action = explode(',', $actions);
         array_walk_recursive($associate_action, 'intval_string');
         $associate_action = implode(',', $associate_action);
     } else {
         if ($actions) {
             $associate_action = intval($actions);
         }
     }
     if (!$uid) {
         $where[] = "(associate_type = " . ACTION_LOG::CATEGORY_QUESTION . " AND associate_action IN(" . $this->quote($associate_action) . "))";
     } else {
         $where[] = "(associate_type = " . ACTION_LOG::CATEGORY_QUESTION . " AND uid = " . intval($uid) . " AND associate_action IN(" . $this->quote($associate_action) . "))";
     }
     if ($this_uid == $uid) {
         $show_anonymous = true;
     }
     $action_list = ACTION_LOG::get_action_by_where(implode($where, ' OR '), $limit, $show_anonymous);
     // 重组信息
     foreach ($action_list as $key => $val) {
         $uids[] = $val['uid'];
         switch ($val['associate_type']) {
             case ACTION_LOG::CATEGORY_QUESTION:
                 if (in_array($val['associate_action'], array(ACTION_LOG::ADD_ARTICLE, ACTION_LOG::ADD_COMMENT_ARTICLE))) {
                     $article_ids[] = $val['associate_id'];
                 } else {
                     $question_ids[] = $val['associate_id'];
                 }
                 if (in_array($val['associate_action'], array(ACTION_LOG::ADD_TOPIC, ACTION_LOG::MOD_TOPIC, ACTION_LOG::MOD_TOPIC_DESCRI, ACTION_LOG::MOD_TOPIC_PIC, ACTION_LOG::DELETE_TOPIC, ACTION_LOG::ADD_TOPIC_FOCUS)) and $val['associate_attached']) {
                     $associate_topic_ids[] = $val['associate_attached'];
                 }
                 break;
         }
     }
     if ($uids) {
         $action_list_users = $this->model('account')->get_user_info_by_uids($uids, true);
     }
     if ($question_ids) {
         $action_questions_info = $this->model('question')->get_question_info_by_ids($question_ids);
     }
     if ($associate_topic_ids) {
         $associate_topics = $this->model('topic')->get_topics_by_ids($associate_topic_ids);
     }
     if ($article_ids) {
         $action_articles_info = $this->model('article')->get_article_info_by_ids($article_ids);
     }
     foreach ($action_list as $key => $val) {
         $action_list[$key]['user_info'] = $action_list_users[$val['uid']];
         switch ($val['associate_type']) {
             case ACTION_LOG::CATEGORY_QUESTION:
                 switch ($val['associate_action']) {
                     case ACTION_LOG::ADD_ARTICLE:
                     case ACTION_LOG::ADD_COMMENT_ARTICLE:
                         $article_info = $action_articles_info[$val['associate_id']];
                         $action_list[$key]['title'] = $article_info['title'];
                         $action_list[$key]['link'] = get_js_url('/article/' . $article_info['id']);
                         $action_list[$key]['article_info'] = $article_info;
                         $action_list[$key]['last_action_str'] = ACTION_LOG::format_action_data($val['associate_action'], $val['uid'], $action_list_users[$val['uid']]['user_name']);
                         break;
                     default:
                         $question_info = $action_questions_info[$val['associate_id']];
                         $action_list[$key]['title'] = $question_info['question_content'];
                         $action_list[$key]['link'] = get_js_url('/question/' . $question_info['question_id']);
                         if (in_array($val['associate_action'], array(ACTION_LOG::ADD_TOPIC, ACTION_LOG::MOD_TOPIC, ACTION_LOG::MOD_TOPIC_DESCRI, ACTION_LOG::MOD_TOPIC_PIC, ACTION_LOG::DELETE_TOPIC, ACTION_LOG::ADD_TOPIC_FOCUS)) and $val['associate_attached']) {
                             $topic_info = $associate_topics[$val['associate_attached']];
                         } else {
                             unset($topic_info);
                         }
                         if (in_array($val['associate_action'], array(ACTION_LOG::ADD_QUESTION)) and $question_info['has_attach']) {
                             $question_info['attachs'] = $question_attachs[$question_info['question_id']];
                         }
                         if ($val['uid']) {
                             $action_list[$key]['last_action_str'] = ACTION_LOG::format_action_data($val['associate_action'], $val['uid'], $action_list_users[$val['uid']]['user_name'], $question_info, $topic_info);
                         }
                         if (in_array($val['associate_action'], array(ACTION_LOG::ANSWER_QUESTION)) and $question_info['answer_count']) {
                             if ($answer_list = $this->model('answer')->get_answer_by_id($val['associate_attached'])) {
                                 $action_list[$key]['answer_info'] = $answer_list;
                             }
                         }
                         $action_list[$key]['question_info'] = $question_info;
                         break;
                 }
                 break;
         }
     }
     AWS_APP::cache()->set($cache_key, $action_list, get_setting('cache_level_normal'));
     return $action_list;
 }
Example #14
0
 public function get_answer_users_by_question_id($question_id, $limit = 5, $published_uid = null)
 {
     if ($result = AWS_APP::cache()->get('answer_users_by_question_id_' . md5($question_id . $limit . $published_uid))) {
         return $result;
     }
     if (!$published_uid) {
         if (!($question_info = $this->get_question_info_by_id($question_id))) {
             return false;
         }
         $published_uid = $question_info['published_uid'];
     }
     if ($answer_users = $this->query_all("SELECT DISTINCT uid FROM " . get_table('answer') . " WHERE question_id = " . intval($question_id) . " AND uid <> " . intval($published_uid) . " AND anonymous = 0 ORDER BY agree_count DESC LIMIT " . intval($limit))) {
         foreach ($answer_users as $key => $val) {
             $answer_uids[] = $val['uid'];
         }
         $result = $this->model('account')->get_user_info_by_uids($answer_uids);
         AWS_APP::cache()->set('answer_users_by_question_id_' . md5($question_id . $limit . $published_uid), $result, get_setting('cache_level_normal'));
     }
     return $result;
 }
Example #15
0
 public function send_valid_email_crond()
 {
     $now = time();
     $lock_time = AWS_APP::cache()->get('send_valid_email_locker');
     if ($lock_time and $now - $lock_time <= 300) {
         return false;
     }
     $where[] = 'valid_email <> 1';
     $where[] = 'reg_time < ' . ($now - 604800);
     $last_sent_id = get_setting('last_sent_valid_email_id');
     if ($last_sent_id) {
         $where[] = 'uid > ' . intval($last_sent_id);
     }
     $invalid_email_users = $this->fetch_all('users', implode(' AND ', $where), null, 200);
     if (!$invalid_email_users) {
         return false;
     }
     AWS_APP::cache()->set('send_valid_email_locker', $now, 300);
     foreach ($invalid_email_users as $invalid_email_user) {
         if ($invalid_email_user['email']) {
             $this->new_valid_email($invalid_email_user['uid'], $invalid_email_user['email'], 'slave');
         }
         $this->model('setting')->set_vars(array('last_sent_valid_email_id' => $invalid_email_user['uid']));
     }
     AWS_APP::cache()->delete('send_valid_email_locker');
     return true;
 }
Example #16
0
 public function run_action()
 {
     foreach ($this->versions as $version) {
         $sql_query = null;
         $sql_file = ROOT_PATH . 'app/upgrade/db/' . $version . '.sql';
         $upgrade_script = ROOT_PATH . 'app/upgrade/script/' . $version . '.php';
         if ($this->db_version <= $version and file_exists($sql_file)) {
             $sql_query = file_get_contents($sql_file);
         }
         if ($this->db_version <= $version and file_exists($upgrade_script)) {
             $this->model('upgrade')->setup_upgrade_script($version);
         }
         if ($this->db_version == $version and $this->ignore_sql) {
             unset($sql_query);
         }
         if (trim($sql_query)) {
             if ($sql_error = $this->model('upgrade')->run_query($sql_query)) {
                 TPL::assign('sql_error', $sql_error);
                 TPL::assign('version', $version);
                 TPL::output('install/upgrade_fail');
                 die;
             }
         }
         $this->model('setting')->set_vars(array('db_version' => $version));
     }
     $this->model('setting')->set_vars(array('db_version' => G_VERSION_BUILD));
     AWS_APP::cache()->clean();
     $upgrade_script = $this->model('upgrade')->get_upgrade_script();
     if (sizeof($upgrade_script) > 0) {
         HTTP::redirect('/upgrade/script/');
     }
     HTTP::redirect('/upgrade/final/');
 }
Example #17
0
 public function publish_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']) {
             if ($question_info['published_uid'] != $this->user_id) {
                 H::redirect_msg(AWS_APP::lang()->_t('你没有权限编辑这个主题'), '/m/question/' . $_GET['id']);
             }
         }
         TPL::assign('question_info', $question_info);
     } else {
         if (!$this->user_info['permission']['publish_question']) {
             H::redirect_msg(AWS_APP::lang()->_t('你所在用户组没有权限发布主题'));
         } else {
             if ($this->is_post() and $_POST['question_detail']) {
                 TPL::assign('question_info', array('question_content' => $_POST['question_content'], 'question_detail' => $_POST['question_detail']));
                 $question_info['category_id'] = $_POST['category_id'];
             } else {
                 if ($_GET['weixin_media_id']) {
                     $weixin_pic_url = AWS_APP::cache()->get('weixin_pic_url_' . md5(base64_decode($_GET['weixin_media_id'])));
                     if (!$weixin_pic_url) {
                         H::redirect_msg(AWS_APP::lang()->_t('图片已过期或 media_id 无效'));
                     }
                     TPL::assign('weixin_media_id', $_GET['weixin_media_id']);
                     TPL::assign('weixin_pic_url', $weixin_pic_url);
                 } else {
                     $draft_content = $this->model('draft')->get_data(1, 'question', $this->user_id);
                     TPL::assign('question_info', array('question_content' => $_POST['question_content'], 'question_detail' => $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 (!$question_info['category_id'] and $_GET['category_id']) {
         $question_info['category_id'] = $_GET['category_id'];
     }
     if (get_setting('category_enable') == 'Y') {
         TPL::assign('question_category_list', $this->model('system')->build_category_html('question', 0, $question_info['category_id']));
     }
     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()));
     }
     TPL::import_js(array('js/fileupload.js'));
     TPL::assign('body_class', 'active');
     TPL::assign('human_valid', human_valid('question_valid_hour'));
     TPL::output('m/publish');
 }
 public function get_posts_list_by_topic_ids($post_type, $topic_type, $topic_ids, $category_id = null, $answer_count = null, $order_by = 'post_id DESC', $is_recommend = false, $page = 1, $per_page = 10)
 {
     if (!is_array($topic_ids)) {
         return false;
     }
     array_walk_recursive($topic_ids, 'intval_string');
     $result_cache_key = 'posts_list_by_topic_ids_' . md5(implode(',', $topic_ids) . $answer_count . $category_id . $order_by . $is_recommend . $page . $per_page . $post_type . $topic_type);
     $found_rows_cache_key = 'posts_list_by_topic_ids_found_rows_' . md5(implode(',', $topic_ids) . $answer_count . $category_id . $is_recommend . $per_page . $post_type . $topic_type);
     $topic_relation_where[] = '`topic_id` IN(' . implode(',', $topic_ids) . ')';
     if ($topic_type) {
         $topic_relation_where[] = "`type` = '" . $this->quote($topic_type) . "'";
     }
     if ($topic_relation_query = $this->query_all("SELECT `item_id`, `type` FROM " . get_table('topic_relation') . " WHERE " . implode(' AND ', $topic_relation_where))) {
         foreach ($topic_relation_query as $key => $val) {
             $post_ids[$val['type']][$val['item_id']] = $val['item_id'];
         }
     }
     if (!$post_ids) {
         return false;
     }
     foreach ($post_ids as $key => $val) {
         $post_id_where[] = "(post_id IN (" . implode(',', $val) . ") AND post_type = '" . $this->quote($key) . "')";
     }
     if ($post_id_where) {
         $where[] = '(' . implode(' OR ', $post_id_where) . ')';
     }
     if (is_digits($answer_count)) {
         if ($answer_count == 0) {
             $where[] = "answer_count = " . $answer_count;
         } else {
             if ($answer_count > 0) {
                 $where[] = "answer_count >= " . $answer_count;
             }
         }
     }
     if ($is_recommend) {
         $where[] = 'is_recommend = 1';
     }
     if ($post_type) {
         $where[] = "post_type = '" . $this->quote($post_type) . "'";
     }
     if ($category_id) {
         $where[] = 'category_id IN(' . implode(',', $this->model('system')->get_category_with_child_ids('question', $category_id)) . ')';
     }
     if (!($result = AWS_APP::cache()->get($result_cache_key))) {
         $result = $this->fetch_page('posts_index', implode(' AND ', $where), $order_by, $page, $per_page);
         AWS_APP::cache()->set($result_cache_key, $result, get_setting('cache_level_high'));
     }
     if (!($found_rows = AWS_APP::cache()->get($found_rows_cache_key))) {
         $found_rows = $this->found_rows();
         AWS_APP::cache()->set($found_rows_cache_key, $found_rows, get_setting('cache_level_high'));
     }
     $this->posts_list_total = $found_rows;
     return $result;
 }
Example #19
0
 public function get_user_group_by_id($group_id, $field = null)
 {
     if (!$group_id) {
         return false;
     }
     static $user_groups;
     if (isset($user_groups[$group_id])) {
         if ($field) {
             return $user_groups[$group_id][$field];
         } else {
             return $user_groups[$group_id];
         }
     }
     if (!($user_group = AWS_APP::cache()->get('user_group_' . intval($group_id)))) {
         $user_group = $this->fetch_row('users_group', 'group_id = ' . intval($group_id));
         if ($user_group['permission']) {
             $user_group['permission'] = unserialize($user_group['permission']);
         }
         AWS_APP::cache()->set('user_group_' . intval($group_id), $user_group, get_setting('cache_level_normal'), 'users_group');
     }
     $user_groups[$group_id] = $user_group;
     if ($field) {
         return $user_group[$field];
     } else {
         return $user_group;
     }
 }
Example #20
0
 public function get_file($media_id)
 {
     $app_id = get_setting('weixin_app_id');
     $app_secret = get_setting('weixin_app_secret');
     $media_id_md5 = md5($media_id);
     $cached_file = AWS_APP::cache()->get('weixin_get_file_' . $media_id_md5);
     if ($cached_file) {
         return $cached_file;
     }
     $file = curl_get_contents(self::WEIXIN_FILE_API . 'media/get?access_token=' . $this->get_access_token($app_id, $app_secret) . '&media_id=' . $media_id);
     if ($file) {
         $result = json_decode($file, true);
         if ($result) {
             if ($result['errcode'] == 40001) {
                 $this->refresh_access_token($app_id, $app_secret);
             }
             return $result;
         }
         AWS_APP::cache()->set('weixin_get_file_' . $media_id_md5, $file, 259200);
         return $file;
     }
 }
Example #21
0
 public function update_views($article_id)
 {
     if (AWS_APP::cache()->get('update_views_article_' . md5(session_id()) . '_' . intval($article_id))) {
         return false;
     }
     AWS_APP::cache()->set('update_views_article_' . md5(session_id()) . '_' . intval($article_id), time(), 60);
     $this->shutdown_query("UPDATE " . $this->get_table('article') . " SET views = views + 1 WHERE id = " . intval($article_id));
     return true;
 }
 public function save_post_hash_lib()
 {
     AWS_APP::cache()->set($this->post_hash_cache_key, $this->post_hash_lib, 3600);
 }
Example #23
0
 /**
  * 获取系统缓存处理类
  *
  * 调用 core/cache.php
  *
  * @access	public
  * @return	object
  */
 public static function cache()
 {
     if (!self::$cache) {
         self::$cache = load_class('core_cache');
     }
     return self::$cache;
 }
Example #24
0
 public function remove_nav_menu($nav_menu_id)
 {
     AWS_APP::cache()->cleanGroup('nav_menu');
     return $this->delete('nav_menu', 'id = ' . intval($nav_menu_id));
 }
Example #25
0
 public function get_jsapi_ticket($access_token)
 {
     if (!$access_token) {
         return false;
     }
     $cached_ticket = 'weixin_jsapi_ticket_' . md5($access_token);
     $jsapi_ticket = AWS_APP::cache()->get($jsapi_ticket);
     if ($jsapi_ticket) {
         return $jsapi_ticket;
     }
     $result = curl_get_contents(self::WEIXIN_API . 'ticket/getticket?access_token=' . $access_token . '&type=jsapi');
     if (!$result) {
         return false;
     }
     $result = json_decode($result, true);
     if (!$result['ticket']) {
         return false;
     }
     AWS_APP::cache()->set($cached_ticket, $result['ticket'], 60);
     return $result['ticket'];
 }
Example #26
0
 public function notification_of_refresh_access_token($uid, $user_name)
 {
     if (!is_digits($uid)) {
         return false;
     }
     $admin_notifications = AWS_APP::cache()->get('admin_notifications');
     if (!$admin_notifications) {
         $admin_notifications = get_setting('admin_notifications');
     }
     if ($user_name === NULL) {
         unset($admin_notifications['sina_users'][$uid]);
     } else {
         $admin_notifications['sina_users'][$uid] = array('uid' => $uid, 'user_name' => $user_name);
     }
     AWS_APP::cache()->set('admin_notifications', $admin_notifications, 1800);
     return $this->model('setting')->set_vars(array('admin_notifications' => $admin_notifications));
 }
Example #27
0
 public function weibo_batch_action()
 {
     if (!$_POST['action'] or !isset($_POST['uid'])) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('错误的请求')));
     }
     if (in_array($_POST['action'], array('add_service_user', 'del_service_user'))) {
         $user_info = $this->model('account')->get_user_info_by_uid($_POST['uid']);
         if (!$user_info) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('所选用户不存在')));
         }
         $service_info = $this->model('openid_weibo_oauth')->get_weibo_user_by_uid($user_info['uid']);
         $tmp_service_account = AWS_APP::cache()->get('tmp_service_account');
     }
     switch ($_POST['action']) {
         case 'add_service_user':
             if ($service_info) {
                 if (isset($service_info['last_msg_id'])) {
                     H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('该用户已是回答用户')));
                 }
                 $this->model('openid_weibo_weibo')->update_service_account($user_info['uid'], 'add');
                 $rsm = array('staus' => 'bound');
             } else {
                 if ($tmp_service_account[$user_info['uid']]) {
                     H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('该用户已是回答用户')));
                 }
                 $tmp_service_account[$user_info['uid']] = array('uid' => $user_info['uid'], 'user_name' => $user_info['user_name'], 'url_token' => $user_info['url_token']);
                 natsort($tmp_service_account);
                 AWS_APP::cache()->set('tmp_service_account', $tmp_service_account, 86400);
                 $rsm = array('staus' => 'unbound');
             }
             break;
         case 'del_service_user':
             if ($service_info) {
                 if (!isset($service_info['last_msg_id'])) {
                     H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('该用户不是回答用户')));
                 }
                 $this->model('openid_weibo_weibo')->update_service_account($user_info['uid'], 'del');
             } else {
                 if (!$tmp_service_account[$user_info['uid']]) {
                     H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('该用户不是回答用户')));
                 }
                 unset($tmp_service_account[$user_info['uid']]);
                 AWS_APP::cache()->set('tmp_service_account', $tmp_service_account, 86400);
             }
             break;
         case 'add_published_user':
             $weibo_msg_published_user = get_setting('weibo_msg_published_user');
             if ($_POST['uid'] != $weibo_msg_published_user['uid']) {
                 $published_user_info = $this->model('account')->get_user_info_by_uid($_POST['uid']);
                 if (!$published_user_info) {
                     H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('所选用户不存在')));
                 }
                 $this->model('setting')->set_vars(array('weibo_msg_published_user' => array('uid' => $published_user_info['uid'], 'user_name' => $published_user_info['user_name'], 'url_token' => $published_user_info['url_token'])));
             }
             break;
         case 'weibo_msg_enabled':
             if (in_array($_POST['uid'], array('question', 'ticket', 'N'))) {
                 $this->model('setting')->set_vars(array('weibo_msg_enabled' => $_POST['uid']));
             }
             break;
     }
     H::ajax_json_output(AWS_APP::RSM($rsm, 1, null));
 }
Example #28
0
 /**
  * parse
  *
  * @param string $url
  * @static
  * @access public
  * @return void
  */
 public static function parse($url = '')
 {
     $lowerurl = strtolower($url);
     if (strstr($lowerurl, '.swf')) {
         return '<p><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="560" height="360"><param name="movie" value="' . $url . '" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true" /><embed src="' . $url . '" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="460" height="360" wmode="transparent" allowfullscreen="true"></embed></object></p>';
     }
     preg_match(self::CHECK_URL_VALID, $lowerurl, $matches);
     if (!$matches) {
         return '<p><img src="' . G_STATIC_URL . '/common/video_parser_unsupport.png" alt="" /></p>';
     }
     if (!($data = AWS_APP::cache()->get('video_parse_' . md5($url)))) {
         switch ($matches[1]) {
             case 'youku.com':
                 $data = self::_parseYouku($url);
                 break;
             case 'tudou.com':
                 $data = self::_parseTudou($url);
                 break;
             case 'ku6.com':
                 $data = self::_parseKu6($url);
                 break;
             case '56.com':
                 $data = self::_parse56($url);
                 break;
             case 'letv.com':
                 $data = self::_parseLetv($url);
                 break;
             case 'video.sina.com.cn':
                 $data = self::_parseSina($url);
                 break;
             case 'my.tv.sohu.com':
             case 'tv.sohu.com':
             case 'sohu.com':
                 $data = self::_parseSohu($url);
                 break;
             case 'v.qq.com':
                 $data = self::_parseQq($url);
                 break;
             case 'youtube.com':
                 $data = self::_parseYoutube($url);
                 break;
             default:
                 return $url;
         }
         if ($data) {
             AWS_APP::cache()->set('video_parse_' . md5($url), $data, 3600, 'video_parser');
         }
     }
     if ($data) {
         if ($data['iframe']) {
             return '<p><iframe width="560" height="360" src="' . $data['iframe'] . '" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>';
         } else {
             return '<p><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="560" height="360"><param name="movie" value="' . $data['swf'] . '" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true" /><embed src="' . $data['swf'] . '" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="460" height="360" wmode="transparent" allowfullscreen="true"></embed></object></p>';
         }
     }
     return '<p><img src="' . G_STATIC_URL . '/common/video_parser_unsupport.png" alt="" /></p>';
 }
Example #29
0
 public function save_topic_relation_action()
 {
     if (!$_POST['topic_title'] or !$_POST['item_id'] or !$_POST['type']) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('指定的项目不存在')));
     }
     switch ($_POST['type']) {
         case 'question':
             if (!($question_info = $this->model('question')->get_question_info_by_id($_POST['item_id']))) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('指定问题不存在')));
             }
             if (!$this->user_info['permission']['edit_question_topic'] and $this->user_id != $question_info['published_uid']) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限进行此操作')));
             }
             break;
         case 'article':
             if (!($article_info = $this->model('article')->get_article_info_by_id($_POST['item_id']))) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('指定项目不存在')));
             }
             if (!$this->user_info['permission']['edit_question_topic'] and $this->user_id != $article_info['uid']) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限进行此操作')));
             }
             break;
     }
     if (!($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
         if ($this->user_info['permission']['function_interval'] and AWS_APP::cache()->get('function_interval_timer_question_topic_last_edit_' . $this->user_id) == $_POST['item_id']) {
             AWS_APP::cache()->set('function_interval_timer_question_topic_' . $this->user_id, time(), 86400);
         } else {
             if ($this->user_info['permission']['function_interval'] and time() - AWS_APP::cache()->get('function_interval_timer_question_topic_' . $this->user_id) < $this->user_info['permission']['function_interval']) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('灌水预防机制已经打开, 在 %s 秒内不能操作', $this->user_info['permission']['function_interval'])));
             }
         }
     }
     if (trim($_POST['topic_title']) == '') {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请输入话题标题')));
     }
     if (strstr($_POST['topic_title'], '/') or strstr($_POST['topic_title'], '-')) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('话题标题不能包含 / 与 -')));
     }
     if (!$this->model('topic')->get_topic_id_by_title($_POST['topic_title']) and get_setting('topic_title_limit') and cjk_strlen($_POST['topic_title']) > get_setting('topic_title_limit')) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('话题标题字数不得超过 %s 字节', get_setting('topic_title_limit'))));
     }
     switch ($_POST['type']) {
         case 'question':
             if ($question_info['lock'] and !($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('锁定问题不能添加话题')));
             }
             break;
         case 'article':
             if ($article_info['lock'] and !($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('锁定文章不能添加话题')));
             }
             break;
     }
     if (sizeof($this->model('topic')->get_topics_by_item_id($_POST['item_id'], $_POST['type'])) >= get_setting('question_topics_limit') and get_setting('question_topics_limit')) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('单个问题或文章话题数量最多为 %s 个, 请调整话题数量', get_setting('question_topics_limit'))));
     }
     if (!($topic_id = $this->model('topic')->save_topic($_POST['topic_title'], $this->user_id, $this->user_info['permission']['create_topic']))) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('话题已锁定或没有创建话题权限, 不能添加话题')));
     }
     $this->model('topic')->save_topic_relation($this->user_id, $topic_id, $_POST['item_id'], $_POST['type']);
     if (!($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
         AWS_APP::cache()->set('function_interval_timer_question_topic_' . $this->user_id, time(), 86400);
         AWS_APP::cache()->set('function_interval_timer_question_topic_last_edit_' . $this->user_id, intval($_POST['item_id']), 86400);
     }
     H::ajax_json_output(AWS_APP::RSM(array('topic_id' => $topic_id, 'topic_url' => get_js_url('topic/' . $topic_id)), 1, null));
 }
Example #30
0
 public function bind_account($weibo_user, $uid)
 {
     if ($this->get_weibo_user_by_id($weibo_user['id']) or $this->get_weibo_user_by_uid($uid)) {
         return false;
     }
     $result = $this->insert('users_sina', array('id' => htmlspecialchars($weibo_user['id']), 'uid' => intval($uid), 'name' => htmlspecialchars($weibo_user['screen_name']), 'location' => htmlspecialchars($weibo_user['location']), 'description' => htmlspecialchars($weibo_user['description']), 'url' => htmlspecialchars($weibo_user['profile_url']), 'profile_image_url' => htmlspecialchars($weibo_user['profile_image_url']), 'gender' => htmlspecialchars($weibo_user['gender']), 'access_token' => htmlspecialchars($weibo_user['access_token']), 'expires_time' => intval($weibo_user['expires_time']), 'add_time' => time()));
     $tmp_service_account = AWS_APP::cache()->get('tmp_service_account');
     if ($tmp_service_account[$uid]) {
         $this->model('openid_weibo_weibo')->update_service_account($uid, 'add');
         unset($tmp_service_account[$uid]);
         AWS_APP::cache()->set('tmp_service_account', $tmp_service_account, 86400);
     }
     $this->model('openid_weibo_weibo')->notification_of_refresh_access_token($uid, null);
     return $result;
 }