public function send_action() { if (trim($_POST['message']) == '') { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请输入私信内容'))); } if (!($recipient_user = $this->model('account')->get_user_info_by_username($_POST['recipient']))) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('接收私信的用户不存在'))); } if ($recipient_user['uid'] == $this->user_id) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('不能给自己发私信'))); } if ($recipient_user['inbox_recv']) { if (!$this->model('message')->check_permission($recipient_user['uid'], $this->user_id)) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('对方设置了只有 Ta 关注的人才能给 Ta 发送私信'))); } } // !注: 来路检测后面不能再放报错提示 if (!valid_post_hash($_POST['post_hash'])) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('页面停留时间过长,或内容已提交,请刷新页面'))); } $this->model('message')->send_message($this->user_id, $recipient_user['uid'], $_POST['message']); if ($_POST['return_url']) { $rsm = array('url' => get_js_url(strip_tags($_POST['return_url']))); } else { $rsm = array('url' => get_js_url('/inbox/')); } H::ajax_json_output(AWS_APP::RSM($rsm, 1, null)); }
public function apply_action() { $site_name = $_POST['site_name']; $site_url = $_POST['site_url']; //此处就是控制器(C)指派模型(M)的过程,表示调用models\link.php中的is_exist_url() //用于判断该网站地址是否已经存在 //对提交的参数进行简单的判断 if ($this->model('link')->is_exist_url1($site_name, $site_url)) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('邮件已发送,请勿重复发送!'))); } if (trim($site_name) == '') { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请输入客户邮箱!'))); } if (!$this->model('link')->checkEmail($site_name)) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请输入正确的邮箱!'))); } if (trim($site_url) == '') { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请输入邮件内容!'))); } //表示调用models\link.php中的apply(),将申请数据插入数据库中 if (!$this->model('link')->apply($site_name, $site_url)) { $this->model('link')->sendEmail($site_name, $site_url); } H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('发送成功,请关闭对话框!'))); }
public function sign_in_action() { if ($_GET['uid'] != $this->user_id) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('签到失败!'))); } if ($this->model('sign')->is_signed_today($_GET['uid'])) { H::ajax_json_output(AWS_APP::RSM(array('is_signed' => true)), 1, null); } $continous = $this->model('sign')->sign_in($_GET['uid']); $integral_every_day = get_setting('sign_integral_every_day'); $integral_seventh_day = get_setting('sign_integral_seventh_day'); // 积分操作 $is_seventh_day = false; if ($continous < 0) { H::ajax_json_output(AWS_APP::RSM(array('is_signed' => true)), 1, null); } else { if ($continous == 6) { $integral = $integral_seventh_day; $integral_message = '连续7天签到积分'; $is_seventh_day = true; } else { $integral = $integral_every_day; $integral_message = '每日签到积分'; } } $this->model('integral')->process($_GET['uid'], 'SIGN_IN', $integral, $integral_message, $_GET['uid']); H::ajax_json_output(AWS_APP::RSM(array('is_signed' => false, 'continous' => $continous, 'integral_every_day' => $integral_every_day, 'integral_seventh_day' => $integral_seventh_day, 'user_integral' => $this->user_info['integral'] + $integral)), 1, null); }
public function list_action() { if ($this->is_post()) { foreach ($_POST as $key => $val) { if ($key == 'start_date' or $key == 'end_date') { $val = base64_encode($val); } if ($key == 'keyword' or $key == 'user_name') { $val = rawurlencode($val); } $param[] = $key . '-' . $val; } H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/admin/article/list/' . implode('__', $param))), 1, null)); } $where = array(); if ($_GET['keyword']) { $where[] = "(`title` LIKE '%" . $this->model('article')->quote($_GET['keyword']) . "%')"; } if ($_GET['start_date']) { $where[] = 'add_time >= ' . strtotime(base64_decode($_GET['start_date'])); } if ($_GET['end_date']) { $where[] = 'add_time <= ' . strtotime('+1 day', strtotime(base64_decode($_GET['end_date']))); } if ($_GET['user_name']) { $user_info = $this->model('account')->get_user_info_by_username($_GET['user_name']); $where[] = 'uid = ' . intval($user_info['uid']); } if ($_GET['comment_count_min']) { $where[] = 'comments >= ' . intval($_GET['comment_count_min']); } if ($_GET['answer_count_max']) { $where[] = 'comments <= ' . intval($_GET['comment_count_max']); } if ($articles_list = $this->model('article')->fetch_page('article', implode(' AND ', $where), 'id DESC', $_GET['page'], $this->per_page)) { $search_articles_total = $this->model('article')->found_rows(); } if ($articles_list) { foreach ($articles_list as $key => $val) { $articles_list_uids[$val['uid']] = $val['uid']; } if ($articles_list_uids) { $articles_list_user_infos = $this->model('account')->get_user_info_by_uids($articles_list_uids); } foreach ($articles_list as $key => $val) { $articles_list[$key]['user_info'] = $articles_list_user_infos[$val['uid']]; } } $url_param = array(); foreach ($_GET as $key => $val) { if (!in_array($key, array('app', 'c', 'act', 'page'))) { $url_param[] = $key . '-' . $val; } } TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/admin/article/list/') . implode('__', $url_param), 'total_rows' => $search_articles_total, 'per_page' => $this->per_page))->create_links()); $this->crumb(AWS_APP::lang()->_t('文章管理'), 'admin/article/list/'); TPL::assign('articles_count', $search_articles_total); TPL::assign('list', $articles_list); TPL::output('admin/article/list'); }
public function index_action() { $_GET['per_page'] = $_GET['per_page'] ? intval($_GET['per_page']) : get_setting('contents_per_page'); $result = $this->model('search')->search(cjk_substr($_GET['q'], 0, 64), $_GET['type'], $_GET['page'], $_GET['per_page'], $_GET['topic_ids'], $_GET['is_recommend']); if (!$result) { $result = array(); } if ($_GET['is_question_id'] and is_digits($_GET['q'])) { $question_info = $this->model('question')->get_question_info_by_id($_GET['q']); if ($question_info) { $result[] = $this->model('search')->prase_result_info($question_info); } } if ($result) { $key_arr = array('type', 'search_id', 'name', 'detail'); foreach ($result as $key => $val) { foreach ($val as $k => $v) { if (!in_array($k, $key_arr)) { unset($result[$key][$k]); } } } } H::ajax_json_output(AWS_APP::RSM(array('total_rows' => count($result), 'rows' => $result), 1, null)); }
public function remove_slide_action() { if (!$this->model('slide')->remove_slide($_POST['id'])) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('删除幻灯片失败'))); } H::ajax_json_output(AWS_APP::RSM(null, 1, null)); }
function binding_callback_action() { $oauth = new Services_Weibo_WeiboOAuth(get_setting('sina_akey'), get_setting('sina_skey')); if ($_GET['uid'] and $this->user_info['permission']['is_administortar']) { $user_id = intval($_GET['uid']); $user_info = $this->model('account')->get_user_info_by_uid($user_id); if (empty($user_info)) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('本地用户不存在,无法绑定'))); } $sina_token = $oauth->getAccessToken('code', array('code' => $_GET['code'], 'redirect_uri' => get_js_url('/account/sina/binding_callback/uid-' . $user_id))); } else { $user_id = $this->user_id; AWS_APP::session()->sina_token = $oauth->getAccessToken('code', array('code' => $_GET['code'], 'redirect_uri' => get_js_url('/account/sina/binding_callback/'))); $sina_token = AWS_APP::session()->sina_token; $redirect = get_js_url('/account/setting/openid/'); } $client = new Services_Weibo_WeiboClient(get_setting('sina_akey'), get_setting('sina_skey'), $sina_token['access_token']); $uid_get = $client->get_uid(); $sina_profile = $client->show_user_by_id($uid_get['uid']); if ($sina_profile['error']) { H::redirect_msg(AWS_APP::lang()->_t('与微博通信出错, 错误代码: %s', $sina_profile['error']), "/account/setting/openid/"); } if (!$this->model('integral')->fetch_log($user_id, 'BIND_OPENID')) { $this->model('integral')->process($user_id, 'BIND_OPENID', round(get_setting('integral_system_config_profile') * 0.2), '绑定 OPEN ID'); } //$this->model('openid_weibo')->bind_account($sina_profile, get_js_url('/account/setting/openid/'), $user_id, $last_key['oauth_token'], $last_key['oauth_token_secret'], $sina_token); $this->model('openid_weibo')->bind_account($sina_profile, $redirect, $user_id, $sina_token); }
public function list_action() { $this->crumb(AWS_APP::lang()->_t('话题管理'), 'admin/topic/list/'); if ($_POST) { foreach ($_POST as $key => $val) { if ($key == 'keyword') { $val = rawurlencode($val); } $param[] = $key . '-' . $val; } H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/admin/topic/list/' . implode('__', $param))), 1, null)); } $where = array(); if ($_GET['keyword']) { $where[] = "topic_title LIKE '" . $this->model('topic')->quote($_GET['keyword']) . "%'"; } if ($_GET['discuss_count_min'] or $_GET['discuss_count_min'] == '0') { $where[] = 'discuss_count >= ' . intval($_GET['discuss_count_min']); } if ($_GET['discuss_count_max'] or $_GET['discuss_count_max'] == '0') { $where[] = 'discuss_count <= ' . intval($_GET['discuss_count_max']); } if (base64_decode($_GET['start_date'])) { $where[] = 'add_time >= ' . strtotime(base64_decode($_GET['start_date'])); } if (base64_decode($_GET['end_date'])) { $where[] = 'add_time <= ' . strtotime('+1 day', strtotime(base64_decode($_GET['end_date']))); } $topic_list = $this->model('topic')->get_topic_list(implode(' AND ', $where), 'topic_id DESC', $this->per_page, $_GET['page']); $total_rows = $this->model('topic')->found_rows(); if ($topic_list) { foreach ($topic_list as $key => $topic_info) { $action_log = ACTION_LOG::get_action_by_event_id($topic_info['topic_id'], 1, ACTION_LOG::CATEGORY_TOPIC, implode(',', 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_RELATED_TOPIC, ACTION_LOG::DELETE_RELATED_TOPIC)), -1); $action_log = $action_log[0]; $topic_list[$key]['last_edited_uid'] = $action_log['uid']; $topic_list[$key]['last_edited_time'] = $action_log['add_time']; $last_edited_uids[] = $topic_list[$key]['last_edited_uid']; } $users_info_query = $this->model('account')->get_user_info_by_uids($last_edited_uids); if ($users_info_query) { foreach ($users_info_query as $user_info) { $users_info[$user_info['uid']] = $user_info; } } } $parent_topic_list = $this->model('topic')->get_parent_topics(); $url_param = array(); foreach ($_GET as $key => $val) { if (!in_array($key, array('app', 'c', 'act', 'page'))) { $url_param[] = $key . '-' . $val; } } TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/admin/topic/list/') . implode('__', $url_param), 'total_rows' => $total_rows, 'per_page' => $this->per_page))->create_links()); TPL::assign('topics_count', $total_rows); TPL::assign('list', $topic_list); TPL::assign('users_info', $users_info); TPL::assign('parent_topic_list', $parent_topic_list); TPL::output('admin/topic/list'); }
public function index_action() { if ($_POST['mobile_app_secret']) { $this->model('myapi')->save_mobile_app_secret(trim($_POST['mobile_app_secret'])); H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('保存设置成功'))); } TPL::output('admin/mobile_app_config'); }
public function search_action() { if ($result = $this->model('search')->search($_GET['q'], $_GET['type'], 1, $_GET['limit'], $_GET['topic_ids'])) { H::ajax_json_output($result); } else { H::ajax_json_output(array()); } }
public function save_order_action() { if (!$_POST['id']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择订单'))); } $this->model('project')->update_order($_POST['id'], $_POST); H::ajax_json_output(AWS_APP::RSM(null, 1, null)); }
function __construct($message) { if ($_POST['_post_type'] == 'ajax') { H::ajax_json_output(AWS_APP::RSM(null, -1, 'SDK 异常: ' . $message)); } else { H::redirect_msg('SDK 异常: ' . $message); } }
public function index_action() { if (!$this->user_id) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请先登录或注册'))); } $this->per_page = get_setting('contents_per_page'); if ($_GET['per_page']) { $this->per_page = intval($_GET['per_page']); } //$data = $this->model('myhome')->home_activity($this->user_id, (intval($_GET['page']) * $this->per_page) . ", {$this->per_page}"); $data = $this->model('actions')->home_activity($this->user_id, intval($_GET['page']) * $this->per_page . ", {$this->per_page}"); if (!is_array($data)) { $data = array(); } else { $data_key = array('history_id', 'associate_action', 'user_info', 'answer_info', 'question_info', 'article_info', 'comment_info', 'add_time'); $user_info_key = array('uid', 'user_name', 'signature'); $article_info_key = array('id', 'title', 'message', 'comments', 'views', 'add_time'); $answer_info_key = array('answer_id', 'answer_content', 'add_time', 'against_count', 'agree_count'); $question_info_key = array('question_id', 'question_content', 'add_time', 'update_time', 'answer_count', 'agree_count'); foreach ($data as $key => $val) { foreach ($val as $k => $v) { if (!in_array($k, $data_key)) { unset($data[$key][$k]); } } if ($val['user_info']) { foreach ($val['user_info'] as $k => $v) { if (!in_array($k, $user_info_key)) { unset($data[$key]['user_info'][$k]); } } $data[$key]['user_info']['avatar_file'] = get_avatar_url($data[$key]['user_info']['uid'], 'mid'); } if ($val['article_info']) { foreach ($val['article_info'] as $k => $v) { if (!in_array($k, $article_info_key)) { unset($data[$key]['article_info'][$k]); } } } if ($val['answer_info']) { foreach ($val['answer_info'] as $k => $v) { if (!in_array($k, $answer_info_key)) { unset($data[$key]['answer_info'][$k]); } } } if ($val['question_info']) { foreach ($val['question_info'] as $k => $v) { if (!in_array($k, $question_info_key)) { unset($data[$key]['question_info'][$k]); } } } } } H::ajax_json_output(AWS_APP::RSM(array('total_rows' => count($data), 'rows' => array_values($data)), 1, null)); }
public function read_notification_action() { if (isset($_GET['notification_id'])) { $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id); } else { $this->model('notify')->mark_read_all($this->user_id); } H::ajax_json_output(AWS_APP::RSM(null, 1, null)); }
public function recommend_homepage_batch_remove_action() { if (!$_POST['recommend_homepage_ids']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请批量选择首页精选项目'))); } foreach ($_POST['recommend_homepage_ids'] as $id) { $this->model('recommend')->recommend_homepage_remove_by_id($id); } H::ajax_json_output(AWS_APP::RSM(null, 1, null)); }
public static function error_404() { if ($_POST['_post_type'] == 'ajax') { H::ajax_json_output(AWS_APP::RSM(null, -1, 'HTTP/1.1 404 Not Found')); } else { header('HTTP/1.1 404 Not Found'); TPL::output('global/error_404'); exit; } }
public function invite_cancel_action() { if (!$_GET['invitation_id']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('邀请记录不存在'))); } if (!$this->model('invitation')->get_invitation_by_id($_GET['invitation_id'])) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('邀请记录不存在'))); } $this->model('invitation')->cancel_invitation_by_id($_GET['invitation_id']); H::ajax_json_output(AWS_APP::RSM(null, 1, null)); }
public function search_action() { $result = $this->model('search')->search(cjk_substr($_GET['q'], 0, 64), $_GET['type'], 1, $_GET['limit'], $_GET['topic_ids'], $_GET['is_recommend']); if (!$result) { $result = array(); } if ($_GET['is_question_id'] and is_digits($_GET['q'])) { $question_info = $this->model('question')->get_question_info_by_id($_GET['q']); if ($question_info) { $result[] = $this->model('search')->prase_result_info($question_info); } } H::ajax_json_output($result); }
public function user_info_action() { if ($this->user_id == $_GET['uid']) { $user_info = $this->user_info; } else { if (!($user_info = $this->model('account')->get_user_info_by_uid($_GET['uid'], ture))) { H::ajax_json_output(array('uid' => null)); } } if ($this->user_id != $user_info['uid']) { $user_follow_check = $this->model('follow')->user_follow_check($this->user_id, $user_info['uid']); } H::ajax_json_output(array('reputation' => $user_info['reputation'], 'agree_count' => $user_info['agree_count'], 'thanks_count' => $user_info['thanks_count'], 'type' => 'people', 'uid' => $user_info['uid'], 'user_name' => $user_info['user_name'], 'avatar_file' => get_avatar_url($user_info['uid'], 'mid'), 'signature' => $user_info['signature'], 'focus' => $user_follow_check ? true : false, 'is_me' => $this->user_id == $user_info['uid'] ? true : false, 'url' => get_js_url('/people/' . $user_info['url_token']), 'category_enable' => get_setting('category_enable') == 'Y' ? 1 : 0, 'verified' => $user_info['verified'], 'fans_count' => $user_info['fans_count'])); }
public function follow_people_action() { if (!$_POST['uid'] or $_POST['uid'] == $this->user_id) { die; } // 首先判断是否存在关注 if ($this->model('follow')->user_follow_check($this->user_id, $_POST['uid'])) { $action = 'remove'; $this->model('follow')->user_follow_del($this->user_id, $_POST['uid']); } else { $action = 'add'; $this->model('follow')->user_follow_add($this->user_id, $_POST['uid']); $this->model('notify')->send($this->user_id, $_POST['uid'], notify_class::TYPE_PEOPLE_FOCUS, notify_class::CATEGORY_PEOPLE, $this->user_id, array('from_uid' => $this->user_id)); $this->model('email')->action_email('FOLLOW_ME', $_POST['uid'], get_js_url('/people/' . $this->user_info['url_token']), array('user_name' => $this->user_info['user_name'])); } H::ajax_json_output(AWS_APP::RSM(array('type' => $action), 1, null)); }
public function bind_account($uinfo, $redirect, $uid, $is_ajax = false) { if (!($openid = load_class('Services_Tencent_QQConnect_V2')->get_openid())) { if ($is_ajax) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'))); } else { H::redirect_msg(AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'), '/account/logout/'); } } if ($openid_info = $this->get_user_info_by_uid($uid)) { if ($openid_info['openid'] != $openid) { if ($is_ajax) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('QQ 账号已经被其他账号绑定'))); } else { H::redirect_msg(AWS_APP::lang()->_t('QQ 账号已经被其他账号绑定'), '/account/logout/'); } } } if (!($users_qq = $this->get_user_info_by_open_id($openid))) { if ($uinfo['gender'] == '男') { $uinfo['gender'] = 'm'; } else { if ($uinfo['gender'] == '女') { $uinfo['gender'] = 'f'; } else { $uinfo['gender'] = 'n'; } } $users_qq = $this->user_add($uid, $openid, $uinfo['nickname'], $uinfo['gender']); } else { if ($users_qq['uid'] != $uid) { if ($is_ajax) { H::ajax_json_output(AWS_APP::RSM(null, '-1', 'QQ 已经被其他账号绑定')); } else { H::redirect_msg(AWS_APP::lang()->_t('QQ 已经被其他账号绑定'), '/account/setting/openid/'); } } } $this->update_token($openid, AWS_APP::session()->QQConnect['access_token']); if ($redirect) { HTTP::redirect($redirect); } }
public function save_service_group_action() { if (!$_POST['edit_group'] and !$_POST['remove_group'] and !$_POST['new_group']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择要新增或删除的客服组'))); } if ($_POST['edit_group'] and is_array($_POST['edit_group'])) { foreach ($_POST['edit_group'] as $group_id => $group_name) { $this->model('ticket')->edit_service_group($group_id, $group_name); } } if ($_POST['remove_group'] and is_array($_POST['remove_group'])) { foreach ($_POST['remove_group'] as $remove_group) { $this->model('ticket')->remove_service_group($remove_group); } } if ($_POST['new_group'] and is_array($_POST['new_group'])) { foreach ($_POST['new_group'] as $new_group) { $this->model('ticket')->add_service_group($new_group); } } H::ajax_json_output(AWS_APP::RSM(null, 1, null)); }
public function recommend_homepage_action() { if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator']) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('对不起, 你没有设置推荐的权限'))); } if ($this->model('recommend')->recommend_homepage_check($_POST['type'], $_POST['id'])) { $action = 'remove'; $this->model('recommend')->recommend_homepage_del($_POST['type'], $_POST['id']); } else { $action = 'add'; $this->model('recommend')->recommend_homepage_add($_POST['type'], $_POST['id']); } // 消息通知 // if($action == 'add') // { // // $this->model('notify')->send($this->user_id, $_POST['uid'], notify_class::TYPE_PEOPLE_FOCUS, notify_class::CATEGORY_PEOPLE, $this->user_id, array( // // 'from_uid' => $this->user_id // // )); // // $this->model('email')->action_email('FOLLOW_ME', $_POST['uid'], get_js_url('/people/' . $this->user_info['url_token']), array( // // 'user_name' => $this->user_info['user_name'], // // )); // } H::ajax_json_output(AWS_APP::RSM(array('type' => $action), 1, null)); }
public function save_third_party_login_status_action() { if (!$_POST['rule_ids']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择要操作的规则'))); } foreach ($_POST['rule_ids'] as $rule_id) { $this->model('openid_weixin_thirdlogin')->update_third_party_login($rule_id, 'update', null, null, null, $_POST['enabled'][$rule_id], null, $_POST['rank'][$rule_id]); } H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('规则状态已自动保存'))); }
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)); }
public function remove_favorite_tag_action() { $this->model('favorite')->remove_favorite_tag($_POST['item_id'], $_POST['item_type'], $_POST['tags'], $this->user_id); H::ajax_json_output(AWS_APP::RSM(null, 1, null)); }
public function check_actions_new_action() { $new_count = 0; if ($data = $this->model('actions')->home_activity($this->user_id, $this->per_page)) { foreach ($data as $key => $val) { if ($val['add_time'] > intval($_GET['time'])) { $new_count++; } } } H::ajax_json_output(AWS_APP::RSM(array('new_count' => $new_count), 1, null)); }
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(); }
public function modify_password_action() { if (!$_POST['old_password']) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请输入当前密码'))); } if ($_POST['password'] != $_POST['re_password']) { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请输入相同的确认密码'))); } if (strlen($_POST['password']) < 6 or strlen($_POST['password']) > 16) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('密码长度不符合规则'))); } if ($this->model('account')->update_user_password($_POST['old_password'], $_POST['password'], $this->user_id, $this->user_info['salt'])) { H::ajax_json_output(AWS_APP::RSM(null, 1, AWS_APP::lang()->_t('密码修改成功, 请牢记新密码'))); } else { H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请输入正确的当前密码'))); } }
public function remove_receiving_account_action() { if (!$_POST['id']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择要删除的账号'))); } $this->model('edm')->delete('receiving_email_config', 'id = ' . intval($_POST['id'])); H::ajax_json_output(AWS_APP::RSM(null, 1, null)); }