private function _updateUser($res, $gender, $avatar) { global $_G; include_once libfile('function/profile'); $setarr['gender'] = intval($gender); if ($setarr) { C::t('common_member_profile')->update($_G['uid'], $setarr); } manyoulog('user', $uid, 'update'); $operation = 'gender'; include_once libfile('function/feed'); feed_add('profile', 'feed_profile_update_' . $operation, array('hash_data' => 'profile')); countprofileprogress(); // ob_start(); // $this->getController()->forward('user/uploadavatar', false); // $result = ob_get_clean(); // $picInfo = WebUtils::jsonDecode($result, true); // $avatar = $picInfo['pic_path']; // $avatar = !empty($_GET['avatar']) ? $_GET['avatar'] : ''; if (!empty($avatar)) { $_GET = array_merge($_GET, array('avatar' => $avatar)); ob_start(); $this->getController()->forward('user/saveavatar', false); $result = ob_get_clean(); $result = WebUtils::jsonDecode($result); if (WebUtils::checkError($result)) { return $this->makeErrorInfo($res, 'user_info_avatar_error'); } } return $this->makeErrorInfo($res, lang('message', 'profile_succeed'), array('noError' => 1)); }
public function run($json) { $res = WebUtils::initWebApiArray_oldVersion(); // $json = "{'id': 1, 'idType': 'aid', 'page': 1, 'pageSize': 10, }"; $json = rawurldecode($json); $json = WebUtils::jsonDecode($json); $res = $this->_checkComment($res, $json); if (!WebUtils::checkError($res)) { $comments = $this->getCommentList($json); $res['body']['list'] = $comments['list']; $res = array_merge($res, WebUtils::getWebApiArrayWithPage($res, $json['page'], $json['pageSize'], $comments['count'])); } echo WebUtils::outputWebApi($res, '', false); }
private function _viewRate($res, $tid, $pid) { $res = $this->_checkRate($res, $tid, $pid); $status = WebUtils::checkError($res); $location = WebUtils::createUrl_oldVersion('index/returnmobileview'); if ($status) { $str = <<<HTML <script> alert("{$res['head']['errInfo']}"); location.href = "{$location}"; </script> HTML; echo $str; exit; } // [add]修复gbk编码导致的评分理由不显示。Author:HanPengyu Data:04.09.27 if (!empty($_POST)) { // 把$_POST转成utf-8, 这是由于discuz源码会在mobile情况下把$_POST预先转码成对应的charset, $_POST = array_intersect_key($_REQUEST, $_POST); // 手动把转成utf-8的$_POST数据再次转成对应的charset foreach ($_POST as $key => $value) { if (is_string($value)) { $_POST[$key] = WebUtils::t($value); } } $_GET = array_merge($_GET, $_POST); } global $_G; require_once libfile('function/misc'); require_once libfile('function/forum'); //今日剩余积分 $maxratetoday = $this->_getratingleft($_G['group']['raterange']); $post = C::t('forum_post')->fetch('tid:' . $tid, $pid); $thread = C::t('forum_thread')->fetch($tid); if (!empty($_POST)) { $reason = checkreasonpm(); $rate = $ratetimes = 0; $creditsarray = $sub_self_credit = array(); getuserprofile('extcredits1'); foreach ($_G['group']['raterange'] as $id => $rating) { $score = intval($_GET['score' . $id]); if (isset($_G['setting']['extcredits'][$id]) && !empty($score)) { if ($rating['isself'] && intval($_G['member']['extcredits' . $id]) - $score < 0) { //抱歉,您的{extcreditstitle}(评分栏目)不足,无法评分 $errorMsg = lang('message', 'thread_rate_range_self_invalid', array('extcreditstitle' => $_G['setting']['extcredits'][$id]['title'])); $this->_renderTemplates($tid, $pid, $errorMsg); exit; } if (abs($score) <= $maxratetoday[$id]) { if ($score > $rating['max'] || $score < $rating['min']) { //请输入正确的分值 $errorMsg = lang('message', 'thread_rate_range_invalid'); $this->_renderTemplates($tid, $pid, $errorMsg); exit; } else { $creditsarray[$id] = $score; if ($rating['isself']) { $sub_self_credit[$id] = -abs($score); } $rate += $score; $ratetimes += ceil(max(abs($rating['min']), abs($rating['max'])) / 5); } } else { //抱歉,24 小时评分数超过限制 $errorMsg = lang('message', 'thread_rate_ctrl'); $this->_renderTemplates($tid, $pid, $errorMsg); exit; } } } if (!$creditsarray) { //请输入正确的分值 $errorMsg = lang('message', 'thread_rate_range_invalid'); $this->_renderTemplates($tid, $pid, $errorMsg); exit; } updatemembercount($post['authorid'], $creditsarray, 1, 'PRC', $_GET['pid']); if (!empty($sub_self_credit)) { updatemembercount($_G['uid'], $sub_self_credit, 1, 'RSC', $_GET['pid']); } C::t('forum_post')->increase_rate_by_pid('tid:' . $_G['tid'], $_GET['pid'], $rate, $ratetimes); if ($post['first']) { $threadrate = intval(@($post['rate'] + $rate) / abs($post['rate'] + $rate)); C::t('forum_thread')->update($_G['tid'], array('rate' => $threadrate)); } require_once libfile('function/discuzcode'); $sqlvalues = $comma = ''; $sqlreason = censor(trim($_GET['reason'])); $sqlreason = cutstr(dhtmlspecialchars($sqlreason), 40, '.'); foreach ($creditsarray as $id => $addcredits) { $insertarr = array('pid' => $_GET['pid'], 'uid' => $_G['uid'], 'username' => $_G['username'], 'extcredits' => $id, 'dateline' => $_G['timestamp'], 'score' => $addcredits, 'reason' => $sqlreason); C::t('forum_ratelog')->insert($insertarr); } include_once libfile('function/post'); $_G['forum']['threadcaches'] && @deletethreadcaches($_G['tid']); $reason = dhtmlspecialchars(censor(trim($reason))); //对是否通知作者做的一些初始工作 if ($_G['group']['resasonpm'] == 2 || $_G['group']['reasonpm'] == 3 || !empty($_GET['sendreasonpm'])) { $forumname = strip_tags($_G['forum']['name']); $sendreasonpm = 1; } else { $sendreasonpm = 0; } if ($sendreasonpm) { $ratescore = $slash = ''; foreach ($creditsarray as $id => $addcredits) { $ratescore .= $slash . $_G['setting']['extcredits'][$id]['title'] . ' ' . ($addcredits > 0 ? '+' . $addcredits : $addcredits) . ' ' . $_G['setting']['extcredits'][$id]['unit']; $slash = ' / '; } sendreasonpm($post, 'rate_reason', array('tid' => $thread['tid'], 'pid' => $_GET['pid'], 'subject' => $thread['subject'], 'ratescore' => $ratescore, 'reason' => $reason, 'from_id' => 0, 'from_idtype' => 'rate')); } $logs = array(); foreach ($creditsarray as $id => $addcredits) { $logs[] = dhtmlspecialchars("{$_G['timestamp']}\t{$_G[member][username]}\t{$_G['adminid']}\t{$post['author']}\t{$id}\t{$addcredits}\t{$_G['tid']}\t{$thread['subject']}\t{$reason}"); } update_threadpartake($post['tid']); C::t('forum_postcache')->delete($_GET['pid']); writelog('ratelog', $logs); //评分成功 $this->getController()->redirect(WebUtils::createUrl_oldVersion('index/returnmobileview')); } $this->_renderTemplates($tid, $pid); }