Ejemplo n.º 1
0
 public static function endAppWithErrorInfo($res, $message, $params = array())
 {
     $tmpRes = WebUtils::initWebApiArray_oldVersion();
     $tmpRes = WebUtils::makeErrorInfo_oldVersion($tmpRes, $message, $params);
     $tmpRes = array_merge($tmpRes, $res);
     WebUtils::outputWebApi($tmpRes);
 }
Ejemplo n.º 2
0
 private function _getImageInfoList($res, $landUid, $uid, $page, $pageSize, $albumId)
 {
     $list = array();
     $imageList = UserPhotoInfo::getImageListByAlbumId($albumId, $uid, $page, $pageSize);
     foreach ($imageList as $image) {
         $tempimageInfo = PhotoUtils::getPhotoInfo($image);
         // $imageInfo['board_id'] = (Int)$albumId;
         $imageInfo['pic_id'] = (int) $image;
         $imageInfo['title'] = $tempimageInfo['title'] == "" ? $tempimageInfo['filename'] : $tempimageInfo['title'];
         $imageInfo['title'] = WebUtils::emptyHtml($imageInfo['title']);
         $imageInfo['user_id'] = (int) $uid;
         $imageInfo['release_date'] = $tempimageInfo['dateline'] . "000";
         $lastReplyDate = PhotoUtils::getReplyDate($image);
         $imageInfo['last_update_date'] = $lastReplyDate['last_reply_date'] . "000";
         $imageInfo['user_nick_name'] = $tempimageInfo['username'];
         $imageInfo['hot'] = (int) $tempimageInfo['hot'];
         $imageInfo['replies'] = (int) PhotoUtils::getReplyCount($image);
         $imageInfo['thumb_pic'] = PhotoUtils::getImageCover($image);
         $imageInfo['origin_pic'] = PhotoUtils::getPhotosoRiginCover($tempimageInfo);
         $list[] = $imageInfo;
     }
     global $_G;
     if ($_G['adminid'] != 1) {
         $albumInfo = UserPhotoInfo::getAlbumInfo($uid, $albumId);
         switch ($albumInfo['friend']) {
             case 0:
                 $list;
                 break;
             case 1:
                 UserUtils::isFriend($uid, $landUid) || $landUid == $uid ? $list : ($list = 1);
                 break;
             case 2:
                 $list = PhotoUtils::judgeDesignatedFriends($albumInfo, $landUid, $uid, $list);
                 break;
             case 3:
                 $uid == $landUid ? $list : ($list = 3);
                 break;
             case 4:
                 $landUid == $uid ? $list : ($list = 4);
                 break;
         }
     }
     $res['list'] = $list;
     if ($albumId == 0) {
         $count = UserPhotoInfo::getImageListCountByAlbumId($uid);
     } else {
         $count = UserPhotoInfo::getImageListCount($albumId, $uid);
     }
     $res = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count, $res);
     if (empty($res['list'])) {
         if ($albumId == 0) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'to_view_the_defaultAlbum_does_not_exist');
         }
         return WebUtils::makeErrorInfo_oldVersion($res, 'to_view_the_photo_does_not_exist');
     } elseif ($res['list'] == 1 || $res['list'] == 2 || $res['list'] == 3 || $res['list'] == 4) {
         $res['list'] = array();
         return WebUtils::makeErrorInfo_oldVersion($res, 'to_view_the_photo_set_privacy', array('{username}' => $albumInfo['username']));
     }
     return $res;
 }
Ejemplo n.º 3
0
 private function _checkComment($res, $data)
 {
     $_GET['id'] = $data['id'];
     $_GET['idType'] = $data['idType'];
     // 在DISCUZ_ROOT/source/module/portal/portal_comment.php基础上二次开发
     $id = empty($_GET['id']) ? 0 : intval($_GET['id']);
     $idtype = in_array($_GET['idtype'], array('aid', 'topicid')) ? $_GET['idtype'] : 'aid';
     if (empty($id)) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'comment_no_' . $idtype . '_id');
     }
     if ($idtype == 'aid') {
         $csubject = C::t('portal_article_title')->fetch($id);
         if ($csubject) {
             $csubject = array_merge($csubject, C::t('portal_article_count')->fetch($id));
         }
         // $url = fetch_article_url($csubject);
     } elseif ($idtype == 'topicid') {
         $csubject = C::t('portal_topic')->fetch($id);
         // $url = fetch_topic_url($csubject);
     }
     if (empty($csubject)) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'comment_' . $idtype . '_no_exist');
     } elseif (empty($csubject['allowcomment'])) {
         return WebUtils::makeErrorInfo_oldVersion($res, $idtype . '_comment_is_forbidden');
     }
     return $res;
 }
Ejemplo n.º 4
0
 private function _runAction($params)
 {
     extract($params);
     $isSaveSuccess = false;
     $image = $avatar;
     if (!empty($image) && ($imageData = WebUtils::httpRequest($image)) != '') {
         $savePath = UploadUtils::getTempAvatarPath();
         if (!empty($savePath)) {
             $config = Yii::app()->params['mobcent']['user'];
             $this->_deleteTempAvatarFiles($uid);
             $avatarFiles = $this->_getTempAvatarFiles($uid);
             $avatarBigFile = $savePath . '/' . $avatarFiles['big'];
             $avatarMidFile = $savePath . '/' . $avatarFiles['mid'];
             $avatarSmallFile = $savePath . '/' . $avatarFiles['small'];
             file_put_contents($avatarBigFile, $imageData);
             file_put_contents($avatarMidFile, $imageData);
             file_put_contents($avatarSmallFile, $imageData);
             require_once MOBCENT_APP_ROOT . '/components/discuz/source/class/class_image.php';
             $thumb = new Mobcent_Image();
             $zoomRes = true;
             $zoomRes &= $thumb->makeThumb($avatarBigFile, '', $config['avatarBigLength']);
             $zoomRes &= $thumb->makeThumb($avatarMidFile, '', $config['avatarMidLength']);
             $zoomRes &= $thumb->makeThumb($avatarSmallFile, '', $config['avatarSmallLength']);
             $isSaveSuccess = $zoomRes && $this->_saveAvatarByUcenter($uid, $this->flashdata_encode(file_get_contents($avatarBigFile)), $this->flashdata_encode(file_get_contents($avatarMidFile)), $this->flashdata_encode(file_get_contents($avatarSmallFile)));
             $this->_deleteTempAvatarFiles($uid);
         }
     }
     if ($isSaveSuccess) {
         $this->_updateAvatarStatus();
         return $res;
     } else {
         return WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('保存文件失败'));
     }
     // return $isSaveSuccess ? $res : WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('保存文件失败'));
 }
 public function run($attachment)
 {
     $res = WebUtils::initWebApiArray_oldVersion();
     $uid = $this->getController()->uid;
     // $attachment ="{'head': {'errCode': 0, 'errInfo': ''}, 'body': {'attachment': {'name': 'test', 'isPost': 1, 'data': 'ss', 'type': 'image', 'module':'forum'}, 'externInfo': {}}}";
     $attachment = rawurldecode($attachment);
     $attachment = WebUtils::jsonDecode($attachment);
     $attachment = isset($attachment['body']['attachment']) ? $attachment['body']['attachment'] : array();
     !isset($attachment['module']) && ($attachment['module'] = 'forum');
     $resAttachment = false;
     if (!empty($attachment)) {
         if ($attachment['isPost'] == 1) {
             if (($data = file_get_contents('php://input')) === false) {
                 $attachment['data'] = $GLOBALS['HTTP_RAW_POST_DATA'];
             } else {
                 $attachment['data'] = $data;
             }
         }
         // $attachment['data'] = WebUtils::httpRequest('http://bbs.appbyme.com/static/image/common/logo.png');// test
         $resAttachment = $this->_saveAttachment($uid, $attachment);
     }
     if ($resAttachment === false) {
         $attachmentTypes = array('audio' => WebUtils::t('语音'), 'image' => WebUtils::t('图片'));
         $res = WebUtils::makeErrorInfo_oldVersion($res, 'UPLOAD_ATTACHMENT_ERROR', array('{attachment}' => $attachmentTypes[$attachment['type']]));
     } else {
         $res['body']['attachment'] = $resAttachment;
     }
     echo WebUtils::outputWebApi($res, '', false);
 }
 public function run($json)
 {
     $res = WebUtils::initWebApiArray_oldVersion();
     // $json = "{'action': 'reply', 'idType': 'aid', 'id': 1, 'content': [{'type': 0, 'infor': '呵呵\r\nhaha%25E5%2591%25B5%25E5%2591%25B5%25E2%2580%259C%25E2%2580%259D%2522%2522',}], 'quoteCommentId': 12, }";
     $json = rawurldecode($json);
     $json = WebUtils::jsonDecode($json);
     !isset($json['action']) && ($json['action'] = 'reply');
     !isset($json['idType']) && ($json['idType'] = 'aid');
     switch ($json['action']) {
         case 'reply':
             $res = $this->_commentReply($res, $json);
             break;
         default:
             $res = WebUtils::makeErrorInfo_oldVersion($res, 'mobcent_error_params');
             break;
     }
     echo WebUtils::outputWebApi($res, '', false);
 }
Ejemplo n.º 7
0
 private function _getUserInfo($res, $uid, $puid)
 {
     loadcache('usergroups');
     $space = UserUtils::getUserInfo($puid);
     if (empty($space)) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'space_does_not_exist');
     }
     $spacePro = UserUtils::getUserProfile($puid);
     $spaceCount = DzUserInfo::getCommonMemberCount($puid);
     $space = array_merge($space, $spacePro, $spaceCount);
     $listCount = (int) DzUserInfo::getUserPhotosHomeAlbumCount($puid);
     $res['flag'] = $uid == $puid ? 1 : 0;
     $res['is_black'] = (int) UserUtils::isBlacklist($uid, $puid) ? 1 : 0;
     $res['is_follow'] = (int) UserUtils::isFollow($uid, $puid);
     $res['isFriend'] = (int) UserUtils::isFriend($uid, $puid) ? 1 : 0;
     $res['icon'] = UserUtils::getUserAvatar($puid, $spacePro);
     $res['level_url'] = '';
     $res['name'] = $space['username'];
     $res['email'] = $space['email'];
     $res['status'] = (int) UserUtils::getUserLoginStatus($puid);
     $res['gender'] = (int) UserUtils::getUserGender($puid, $spacePro);
     $res['email'] = $space['email'];
     $res['score'] = (int) $space['credits'];
     $res['credits'] = (int) $space['credits'];
     $res['gold_num'] = (int) $space['extcredits2'];
     $res['topic_num'] = (int) $this->_getHomeTopicNum($puid);
     $res['photo_num'] = (int) $listCount['nums'];
     $res['reply_posts_num'] = (int) DzUserInfo::getTopicsByUidWithPostCount($puid);
     $res['essence_num'] = (int) $space['digestposts'];
     $res['friend_num'] = (int) DzUserInfo::getFollowFriendsCount($puid);
     $res['follow_num'] = (int) DzUserInfo::getFollowedFriendsCount($puid);
     $res['level'] = (int) DzCommonUserList::getUserLevel($space['groupid']);
     $res['userTitle'] = UserUtils::getUserTitle($puid, $space);
     $repeatList = array();
     foreach (UserUtils::getRepeatList($uid) as $user) {
         $repeatList[] = array('userName' => $user);
     }
     $res['body']['repeatList'] = $repeatList;
     $res['body']['profileList'] = $this->_getPersonalDataInfo($puid, $space);
     $res['body']['creditList'] = $this->_getStatisticalInformation($uid, $space);
     $res['body']['creditShowList'] = $this->_getStatisticalInforSet($uid, $space);
     return $res;
 }
 private function _runAction($res, $uid)
 {
     ($imageData = file_get_contents('php://input')) === false && ($imageData = $GLOBALS['HTTP_RAW_POST_DATA']);
     //$imageData = file_get_contents('http://appbyme.com/mobcentACA/resource/images/logo.jpg');
     if (!empty($imageData)) {
         if (($savePath = UploadUtils::getTempAvatarPath()) != '') {
             $fileName = sprintf('%s/avatar_%s.jpg', $savePath, $uid);
             if (($pfile = fopen($fileName, 'wb')) != false) {
                 if (fwrite($pfile, $imageData) !== false) {
                     $image = $this->_uploadAvatarByUcenter($uid, $fileName, $imageData);
                 }
                 fclose($pfile);
                 FileUtils::safeDeleteFile($fileName);
                 if (!empty($image)) {
                     return array_merge($res, array('icon_url' => '', 'pic_path' => $image));
                 }
             }
         }
     }
     return WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('上传文件失败'));
 }
 private function _makeErrorInfo($res, $message, $params = array())
 {
     return WebUtils::makeErrorInfo_oldVersion($res, $message, $params);
 }
Ejemplo n.º 10
0
 protected function makeErrorInfo($res, $message, $params = array())
 {
     return WebUtils::makeErrorInfo_oldVersion($res, $message, $params);
 }
Ejemplo n.º 11
0
 private function sendPost($extract)
 {
     global $_G;
     extract($extract);
     // 获取主题和帖子要插入的状态信息
     $topicStatus = ForumUtils::getPostSendStatus('topic', $_GET['platType']);
     $postStatus = ForumUtils::getPostSendStatus('post', $_GET['platType']);
     //copy from dz source/include/post/post_newthread.php
     if (empty($_G['forum']['fid']) || $_G['forum']['type'] == 'group') {
         return WebUtils::makeErrorInfo_oldVersion($res, 'forum_nonexistence');
     }
     if ($special == 1 && !$_G['group']['allowpostpoll'] || $special == 2 && !$_G['group']['allowposttrade'] || $special == 3 && !$_G['group']['allowpostreward'] || $special == 4 && !$_G['group']['allowpostactivity'] || $special == 5 && !$_G['group']['allowpostdebate']) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'group_nopermission', array('{grouptitle}' => $_G['group']['grouptitle']));
     }
     if (!$_G['uid'] && !(!$_G['forum']['postperm'] && $_G['group']['allowpost'] || $_G['forum']['postperm'] && forumperm($_G['forum']['postperm']))) {
         if (!defined('IN_MOBILE')) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_login_nopermission', array('{login}' => 1));
         } else {
             return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_login_nopermission_mobile', array('{login}' => 1));
         }
     } elseif (empty($_G['forum']['allowpost'])) {
         if (!$_G['forum']['postperm'] && !$_G['group']['allowpost']) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_none_nopermission');
         } elseif ($_G['forum']['postperm'] && !forumperm($_G['forum']['postperm'])) {
             $msg = mobcent_showmessagenoperm('postperm', $_G['fid'], $_G['forum']['formulaperm']);
             return WebUtils::makeErrorInfo_oldVersion($res, $msg['message'], $msg['params']);
         }
     } elseif ($_G['forum']['allowpost'] == -1) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_forum_newthread_nopermission');
     }
     if (!$_G['uid'] && ($_G['setting']['need_avatar'] || $_G['setting']['need_email'] || $_G['setting']['need_friendnum'])) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_login_nopermission');
     }
     if (trim($subject) == '') {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_sm_isnull');
     }
     if (!$sortid && !$special && trim($message) == '') {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_sm_isnull');
     }
     if ($post_invalid = checkpost($subject, $message, $special || $sortid)) {
         return WebUtils::makeErrorInfo_oldVersion($res, $post_invalid, array('{minpostsize}' => $_G['setting']['minpostsize'], '{maxpostsize}' => $_G['setting']['maxpostsize']));
         //showmessage($post_invalid, '', array('minpostsize' => $_G['setting']['minpostsize'], 'maxpostsize' => $_G['setting']['maxpostsize']));
     }
     if (checkflood()) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_flood_ctrl', array('{floodctrl}' => $_G['setting']['floodctrl']));
     } elseif (checkmaxperhour('tid')) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'thread_flood_ctrl_threads_per_hour', array('{threads_per_hour}' => $_G['group']['maxthreadsperhour']));
     }
     $_GET['save'] = $_G['uid'] ? $_GET['save'] : 0;
     if ($_G['group']['allowsetpublishdate'] && $_GET['cronpublish'] && $_GET['cronpublishdate']) {
         $publishdate = strtotime($_GET['cronpublishdate']);
         if ($publishdate > $_G['timestamp']) {
             $_GET['save'] = 1;
         } else {
             $publishdate = $_G['timestamp'];
         }
     } else {
         $publishdate = $_G['timestamp'];
     }
     $typeid = isset($typeid) && isset($_G['forum']['threadtypes']['types'][$typeid]) && (empty($_G['forum']['threadtypes']['moderators'][$typeid]) || $_G['forum']['ismoderator']) ? $typeid : 0;
     $displayorder = $modnewthreads ? -2 : ($_G['forum']['ismoderator'] && $_G['group']['allowstickthread'] && !empty($_GET['sticktopic']) ? 1 : (empty($_GET['save']) ? 0 : -4));
     if ($displayorder == -2) {
         C::t('forum_forum')->update($_G['fid'], array('modworks' => '1'));
     } elseif ($displayorder == -4) {
         $_GET['addfeed'] = 0;
     }
     $digest = $_G['forum']['ismoderator'] && $_G['group']['allowdigestthread'] && !empty($_GET['addtodigest']) ? 1 : 0;
     $readperm = $_G['group']['allowsetreadperm'] ? $readperm : 0;
     $isanonymous = $_G['group']['allowanonymous'] && $_GET['isanonymous'] ? 1 : 0;
     $price = intval($price);
     $price = $_G['group']['maxprice'] && !$special ? $price <= $_G['group']['maxprice'] ? $price : $_G['group']['maxprice'] : 0;
     //强制主题类别判断
     if (!$typeid && $_G['forum']['threadtypes']['required'] && !$special) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_type_isnull');
     }
     //强制主题分类判断
     if (!$sortid && $_G['forum']['threadsorts']['required'] && !$special) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_sort_isnull');
     }
     //主题售价 客户端暂不支持
     if ($price > 0 && floor($price * (1 - $_G['setting']['creditstax'])) == 0) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
         showmessage('post_net_price_iszero');
     }
     //投票贴相关
     if ($special == 1) {
         $polloption = $_GET['tpolloption'] == 2 ? explode("\n", $_GET['polloptions']) : $_GET['polloption'];
         $pollarray = array();
         foreach ($polloption as $key => $value) {
             $polloption[$key] = censor($polloption[$key]);
             if (trim($value) === '') {
                 unset($polloption[$key]);
             }
         }
         if (count($polloption) > $_G['setting']['maxpolloptions']) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('post_poll_option_toomany', '', array('maxpolloptions' => $_G['setting']['maxpolloptions']));
         } elseif (count($polloption) < 2) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('post_poll_inputmore');
         }
         $curpolloption = count($polloption);
         $pollarray['maxchoices'] = empty($_GET['maxchoices']) ? 0 : ($_GET['maxchoices'] > $curpolloption ? $curpolloption : $_GET['maxchoices']);
         $pollarray['multiple'] = empty($_GET['maxchoices']) || $_GET['maxchoices'] == 1 ? 0 : 1;
         $pollarray['options'] = $polloption;
         $pollarray['visible'] = empty($_GET['visibilitypoll']);
         $pollarray['overt'] = !empty($_GET['overt']);
         if (preg_match("/^\\d*\$/", trim($_GET['expiration']))) {
             if (empty($_GET['expiration'])) {
                 $pollarray['expiration'] = 0;
             } else {
                 $pollarray['expiration'] = TIMESTAMP + 86400 * $_GET['expiration'];
             }
         } else {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('poll_maxchoices_expiration_invalid');
         }
     }
     // 分类信息有效期
     $_GET['typeexpiration'] = $_GET['typeoption']['typeexpiration'];
     $sortid = $special && $_G['forum']['threadsorts']['types'][$sortid] ? 0 : $sortid;
     $typeexpiration = intval($_GET['typeexpiration']);
     if ($_G['forum']['threadsorts']['expiration'][$typeid] && !$typeexpiration) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'threadtype_expiration_invalid');
     }
     $_G['forum_optiondata'] = array();
     if ($_G['forum']['threadsorts']['types'][$sortid] && !$_G['forum']['allowspecialonly']) {
         Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_threadsort.php');
         $_G['forum_optiondata'] = mobcent_threadsort_validator($_GET['typeoption'], $pid);
         if ($_G['forum_optiondata']['message'] != '') {
             return WebUtils::makeErrorInfo_oldVersion($res, $_G['forum_optiondata']['message'], $_G['forum_optiondata']['params']);
         }
     }
     $author = !$isanonymous ? $_G['username'] : '';
     $moderated = $digest || $displayorder > 0 ? 1 : 0;
     $thread['status'] = 0;
     $_GET['ordertype'] && ($thread['status'] = setstatus(4, 1, $thread['status']));
     $_GET['hiddenreplies'] && ($thread['status'] = setstatus(2, 1, $thread['status']));
     /*             if($_G['group']['allowpostrushreply'] && $_GET['rushreply']) {
              $_GET['rushreplyfrom'] = strtotime($_GET['rushreplyfrom']);
             $_GET['rushreplyto'] = strtotime($_GET['rushreplyto']);
             $_GET['rewardfloor'] = trim($_GET['rewardfloor']);
             $_GET['stopfloor'] = intval($_GET['stopfloor']);
             $_GET['creditlimit'] = $_GET['creditlimit'] == '' ? '-996' : intval($_GET['creditlimit']);
             if($_GET['rushreplyfrom'] > $_GET['rushreplyto'] && !empty($_GET['rushreplyto'])) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('post_rushreply_timewrong');
             }
             if(($_GET['rushreplyfrom'] > $_G['timestamp']) || (!empty($_GET['rushreplyto']) && $_GET['rushreplyto'] < $_G['timestamp']) || ($_GET['stopfloor'] == 1) ) {
             $closed = true;
             }
             if(!empty($_GET['rewardfloor']) && !empty($_GET['stopfloor'])) {
             $floors = explode(',', $_GET['rewardfloor']);
             if(!empty($floors) && is_array($floors)) {
             foreach($floors AS $key => $floor) {
             if(strpos($floor, '*') === false) {
             if(intval($floor) == 0) {
             unset($floors[$key]);
             } elseif($floor > $_GET['stopfloor']) {
             unset($floors[$key]);
             }
             }
             }
             $_GET['rewardfloor'] = implode(',', $floors);
             }
             }
             $thread['status'] = setstatus(3, 1, $thread['status']);
             $thread['status'] = setstatus(1, 1, $thread['status']);
             } */
     $_GET['allownoticeauthor'] && ($thread['status'] = setstatus(6, 1, $thread['status']));
     $isgroup = $_G['forum']['status'] == 3 ? 1 : 0;
     /*  if($_G['group']['allowreplycredit']) {
              $_GET['replycredit_extcredits'] = intval($_GET['replycredit_extcredits']);
             $_GET['replycredit_times'] = intval($_GET['replycredit_times']);
             $_GET['replycredit_membertimes'] = intval($_GET['replycredit_membertimes']);
             $_GET['replycredit_random'] = intval($_GET['replycredit_random']);
     
             $_GET['replycredit_random'] = $_GET['replycredit_random'] < 0 || $_GET['replycredit_random'] > 99 ? 0 : $_GET['replycredit_random'] ;
             $replycredit = $replycredit_real = 0;
             if($_GET['replycredit_extcredits'] > 0 && $_GET['replycredit_times'] > 0) {
             $replycredit_real = ceil(($_GET['replycredit_extcredits'] * $_GET['replycredit_times']) + ($_GET['replycredit_extcredits'] * $_GET['replycredit_times'] *  $_G['setting']['creditstax']));
             if($replycredit_real > getuserprofile('extcredits'.$_G['setting']['creditstransextra'][10])) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('replycredit_morethan_self');
             } else {
             $replycredit = ceil($_GET['replycredit_extcredits'] * $_GET['replycredit_times']);
             }
             }
             } */
     $newthread = array('fid' => $_G['fid'], 'posttableid' => 0, 'readperm' => $readperm, 'price' => $price, 'typeid' => $typeid, 'sortid' => $sortid, 'author' => $author, 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $publishdate, 'lastpost' => $publishdate, 'lastposter' => $author, 'displayorder' => $displayorder, 'digest' => $digest, 'special' => $special, 'attachment' => 0, 'moderated' => $moderated, 'status' => $thread['status'] | $topicStatus, 'isgroup' => $isgroup, 'replycredit' => $replycredit, 'closed' => $closed ? 1 : 0);
     $tid = C::t('forum_thread')->insert($newthread, true);
     useractionlog($_G['uid'], 'tid');
     if (!getuserprofile('threads') && $_G['setting']['newbie']) {
         C::t('forum_thread')->update($tid, array('icon' => $_G['setting']['newbie']));
     }
     if ($publishdate != $_G['timestamp']) {
         loadcache('cronpublish');
         $cron_publish_ids = dunserialize($_G['cache']['cronpublish']);
         $cron_publish_ids[$tid] = $tid;
         $cron_publish_ids = serialize($cron_publish_ids);
         savecache('cronpublish', $cron_publish_ids);
     }
     if (!$isanonymous) {
         C::t('common_member_field_home')->update($_G['uid'], array('recentnote' => $subject));
     }
     if ($special == 3 && $_G['group']['allowpostreward']) {
         updatemembercount($_G['uid'], array($_G['setting']['creditstransextra'][2] => -$realprice), 1, 'RTC', $tid);
     }
     if ($moderated) {
         updatemodlog($tid, $displayorder > 0 ? 'STK' : 'DIG');
         updatemodworks($displayorder > 0 ? 'STK' : 'DIG', 1);
     }
     /* if($special == 1) {
     
             foreach($pollarray['options'] as $polloptvalue) {
             $polloptvalue = dhtmlspecialchars(trim($polloptvalue));
             C::t('forum_polloption')->insert(array('tid' => $tid, 'polloption' => $polloptvalue));
             }
             $polloptionpreview = '';
             $query = C::t('forum_polloption')->fetch_all_by_tid($tid, 1, 2);
             foreach($query as $option) {
             $polloptvalue = preg_replace("/\[url=(https?){1}:\/\/([^\[\"']+?)\](.+?)\[\/url\]/i", "<a href=\"\\1://\\2\" target=\"_blank\">\\3</a>", $option['polloption']);
             $polloptionpreview .= $polloptvalue."\t";
             }
     
             $polloptionpreview = daddslashes($polloptionpreview);
     
             $data = array('tid' => $tid, 'multiple' => $pollarray['multiple'], 'visible' => $pollarray['visible'], 'maxchoices' => $pollarray['maxchoices'], 'expiration' => $pollarray['expiration'], 'overt' => $pollarray['overt'], 'pollpreview' => $polloptionpreview);
             C::t('forum_poll')->insert($data);
             } */
     if ($_G['forum']['threadsorts']['types'][$sortid] && !empty($_G['forum_optiondata']) && is_array($_G['forum_optiondata'])) {
         $filedname = $valuelist = $separator = '';
         foreach ($_G['forum_optiondata'] as $optionid => $value) {
             if ($value) {
                 $filedname .= $separator . $_G['forum_optionlist'][$optionid]['identifier'];
                 $valuelist .= $separator . "'" . daddslashes($value) . "'";
                 $separator = ' ,';
             }
             if ($_G['forum_optionlist'][$optionid]['type'] == 'image') {
                 $identifier = $_G['forum_optionlist'][$optionid]['identifier'];
                 $sortaids[] = intval($_GET['typeoption'][$identifier]['aid']);
             }
             C::t('forum_typeoptionvar')->insert(array('sortid' => $sortid, 'tid' => $tid, 'fid' => $_G['fid'], 'optionid' => $optionid, 'value' => censor($value), 'expiration' => $typeexpiration ? $publishdate + $typeexpiration : 0));
         }
         if ($filedname && $valuelist) {
             C::t('forum_optionvalue')->insert($sortid, "({$filedname}, tid, fid) VALUES ({$valuelist}, '{$tid}', '{$_G['fid']}')");
         }
     }
     if ($_G['group']['allowat']) {
         $atlist = $atlist_tmp = array();
         preg_match_all("/@([^\r\n]*?)\\s/i", $message . ' ', $atlist_tmp);
         $atlist_tmp = array_slice(array_unique($atlist_tmp[1]), 0, $_G['group']['allowat']);
         if (!empty($atlist_tmp)) {
             if (empty($_G['setting']['at_anyone'])) {
                 foreach (C::t('home_follow')->fetch_all_by_uid_fusername($_G['uid'], $atlist_tmp) as $row) {
                     $atlist[$row['followuid']] = $row['fusername'];
                 }
                 if (count($atlist) < $_G['group']['allowat']) {
                     $query = C::t('home_friend')->fetch_all_by_uid_username($_G['uid'], $atlist_tmp);
                     foreach ($query as $row) {
                         $atlist[$row['fuid']] = $row['fusername'];
                     }
                 }
             } else {
                 foreach (C::t('common_member')->fetch_all_by_username($atlist_tmp) as $row) {
                     $atlist[$row['uid']] = $row['username'];
                 }
             }
         }
         if ($atlist) {
             foreach ($atlist as $atuid => $atusername) {
                 $atsearch[] = "/@" . str_replace('/', '\\/', preg_quote($atusername)) . " /i";
                 $atreplace[] = "[url=home.php?mod=space&uid={$atuid}]@{$atusername}[/url] ";
             }
             $message = preg_replace($atsearch, $atreplace, $message . ' ', 1);
         }
     }
     $bbcodeoff = checkbbcodes($message, !empty($_GET['bbcodeoff']));
     $smileyoff = checksmilies($message, !empty($_GET['smileyoff']));
     $parseurloff = !empty($_GET['parseurloff']);
     $htmlon = $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0;
     $usesig = !empty($_GET['usesig']) && $_G['group']['maxsigsize'] ? 1 : 0;
     $class_tag = new tag();
     $tagstr = $class_tag->add_tag($_GET['tags'], $tid, 'tid');
     /* if($_G['group']['allowreplycredit']) {
         if($replycredit > 0 && $replycredit_real > 0) {
        updatemembercount($_G['uid'], array('extcredits'.$_G['setting']['creditstransextra'][10] => -$replycredit_real), 1, 'RCT', $tid);
        $insertdata = array(
                'tid' => $tid,
                'extcredits' => $_GET['replycredit_extcredits'],
                'extcreditstype' => $_G['setting']['creditstransextra'][10],
                'times' => $_GET['replycredit_times'],
                'membertimes' => $_GET['replycredit_membertimes'],
                'random' => $_GET['replycredit_random']
        );
        C::t('forum_replycredit')->insert($insertdata);
        }
        } */
     if ($_G['group']['allowpostrushreply'] && $_GET['rushreply']) {
         $rushdata = array('tid' => $tid, 'stopfloor' => $_GET['stopfloor'], 'starttimefrom' => $_GET['rushreplyfrom'], 'starttimeto' => $_GET['rushreplyto'], 'rewardfloor' => $_GET['rewardfloor'], 'creditlimit' => $_GET['creditlimit']);
         C::t('forum_threadrush')->insert($rushdata);
     }
     $pinvisible = $modnewthreads ? -2 : (empty($_GET['save']) ? 0 : -3);
     $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message);
     $pid = insertpost(array('fid' => $_G['fid'], 'tid' => $tid, 'first' => '1', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $publishdate, 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => $pinvisible, 'anonymous' => $isanonymous, 'usesig' => $usesig, 'htmlon' => $htmlon, 'bbcodeoff' => $bbcodeoff, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => '0', 'tags' => $tagstr, 'replycredit' => 0, 'status' => (defined('IN_MOBILE') ? 8 : 0) | $postStatus));
     if ($_G['group']['allowat'] && $atlist) {
         foreach ($atlist as $atuid => $atusername) {
             notification_add($atuid, 'at', 'at_message', array('from_id' => $tid, 'from_idtype' => 'at', 'buyerid' => $_G['uid'], 'buyer' => $_G['username'], 'tid' => $tid, 'subject' => $subject, 'pid' => $pid, 'message' => messagecutstr($message, 150)));
         }
         set_atlist_cookie(array_keys($atlist));
     }
     $threadimageaid = 0;
     $threadimage = array();
     if ($special == 4 && $_GET['activityaid']) {
         $threadimageaid = $_GET['activityaid'];
         convertunusedattach($_GET['activityaid'], $tid, $pid);
     }
     if ($_G['forum']['threadsorts']['types'][$sortid] && !empty($_G['forum_optiondata']) && is_array($_G['forum_optiondata']) && $sortaids) {
         foreach ($sortaids as $sortaid) {
             convertunusedattach($sortaid, $tid, $pid);
         }
     }
     if (($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) && ($_GET['attachnew'] || $sortid || !empty($_GET['activityaid']))) {
         updateattach($displayorder == -4 || $modnewthreads, $tid, $pid, $_GET['attachnew']);
         if (!$threadimageaid) {
             $threadimage = C::t('forum_attachment_n')->fetch_max_image('tid:' . $tid, 'tid', $tid);
             $threadimageaid = $threadimage['aid'];
         }
     }
     $values = array('fid' => $_G['fid'], 'tid' => $tid, 'pid' => $pid, 'coverimg' => '', 'sechash' => !empty($_GET['sechash']) ? $_GET['sechash'] : '');
     $param = array();
     Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_post.php');
     if ($_G['forum']['picstyle']) {
         if (!mobcent_setthreadcover($pid, 0, $threadimageaid)) {
             preg_match_all("/(\\[img\\]|\\[img=\\d{1,4}[x|\\,]\\d{1,4}\\])\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/is", $message, $imglist, PREG_SET_ORDER);
             $values['coverimg'] = "<p id=\"showsetcover\">" . lang('message', 'post_newthread_set_cover') . "<span id=\"setcoverwait\"></span></p><script>if(\$('forward_a')){\$('forward_a').style.display='none';setTimeout(\"\$('forward_a').style.display=''\", 5000);};ajaxget('forum.php?mod=ajax&action=setthreadcover&tid={$tid}&pid={$pid}&fid={$_G['fid']}&imgurl={$imglist[0][2]}&newthread=1', 'showsetcover', 'setcoverwait')</script>";
             $param['clean_msgforward'] = 1;
             $param['timeout'] = $param['refreshtime'] = 15;
         }
     }
     if ($threadimageaid) {
         if (!$threadimage) {
             $threadimage = C::t('forum_attachment_n')->fetch('tid:' . $tid, $threadimageaid);
         }
         $threadimage = daddslashes($threadimage);
         C::t('forum_threadimage')->insert(array('tid' => $tid, 'attachment' => $threadimage['attachment'], 'remote' => $threadimage['remote']));
     }
     $statarr = array(0 => 'thread', 1 => 'poll', 2 => 'trade', 3 => 'reward', 4 => 'activity', 5 => 'debate', 127 => 'thread');
     include_once libfile('function/stat');
     updatestat($isgroup ? 'groupthread' : $statarr[$special]);
     if ($modnewthreads) {
         updatemoderate('tid', $tid);
         C::t('forum_forum')->update_forum_counter($_G['fid'], 0, 0, 1);
         manage_addnotify('verifythread');
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_newthread_mod_succeed', array('noError' => 1));
         //showmessage('post_newthread_mod_succeed', $returnurl, $values, $param);
     } else {
         if ($displayorder >= 0 && helper_access::check_module('follow') && !empty($_GET['adddynamic']) && !$isanonymous) {
             require_once libfile('function/discuzcode');
             require_once libfile('function/followcode');
             $feedcontent = array('tid' => $tid, 'content' => followcode($message, $tid, $pid, 1000));
             C::t('forum_threadpreview')->insert($feedcontent);
             C::t('forum_thread')->update_status_by_tid($tid, '512');
             $followfeed = array('uid' => $_G['uid'], 'username' => $_G['username'], 'tid' => $tid, 'note' => '', 'dateline' => TIMESTAMP);
             $values['feedid'] = C::t('home_follow_feed')->insert($followfeed, true);
             C::t('common_member_count')->increase($_G['uid'], array('feeds' => 1));
         }
         $feed = array('icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data' => array(), 'images' => array());
         if ($displayorder != -4) {
             if ($digest) {
                 updatepostcredits('+', $_G['uid'], 'digest', $_G['fid']);
             }
             //updatepostcredits('+',  $_G['uid'], 'post', $_G['fid']);
             Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_post.php');
             //Yii::import('application.components.discuz.source.function.function_post', true);
             mobcent_updatepostcredits('+', $_G['uid'], 'post', $_G['fid']);
             if ($isgroup) {
                 C::t('forum_groupuser')->update_counter_for_user($_G['uid'], $_G['fid'], 1);
             }
             $subject = str_replace("\t", ' ', $subject);
             $lastpost = "{$tid}\t" . $subject . "\t{$_G['timestamp']}\t{$author}";
             C::t('forum_forum')->update($_G['fid'], array('lastpost' => $lastpost));
             C::t('forum_forum')->update_forum_counter($_G['fid'], 1, 1, 1);
             if ($_G['forum']['type'] == 'sub') {
                 C::t('forum_forum')->update($_G['forum']['fup'], array('lastpost' => $lastpost));
             }
         }
         if ($_G['forum']['status'] == 3) {
             C::t('forum_forumfield')->update($_G['fid'], array('lastupdate' => TIMESTAMP));
             require_once libfile('function/grouplog');
             updategroupcreditlog($_G['fid'], $_G['uid']);
         }
         /*如果显示地理位置,入库到表里*/
         if ($jsonInfo['isShowPostion']) {
             $data = DB::query('INSERT INTO  %t VALUES(null,%f,%f,%d,%d,%s)', array('home_surrounding_user', $jsonInfo['longitude'], $jsonInfo['latitude'], $tid, 3, (string) $jsonInfo['location']));
         }
         /*  //客户端发表主题积分入库
                $temp = DB::fetch_first('SELECT extcredits3  FROM '.DB::table('common_credit_rule').' WHERE rid =%d ',array(1));
                $extcredits3 = DB::fetch_first('SELECT extcredits3 FROM '.DB::table('common_member_count').' WHERE uid = %d',array($_G['uid']));
                $temp = $extcredits3['extcredits3'] + $temp['extcredits3'];
                DB::query('UPDATE '.DB::table('common_member_count').' set extcredits3 = %d WHERE uid = %d',array($temp,$_G['uid']));
             */
         //showmessage('post_newthread_succeed', $returnurl, $values, $param);
         // return array('rs'=>1,'errcode'=>WebUtils::t('发贴成功'));
         return $this->makeErrorInfo($res, 'mobcent_post_newthread_success', array('noError' => 1));
     }
 }
Ejemplo n.º 12
0
 private function _zhSearchData($kw, $page, $pagesize, $res, $searchparams)
 {
     $keyword = dhtmlspecialchars(trim($kw));
     $keyword = WebUtils::t($keyword);
     require_once libfile('function/search');
     require_once libfile('function/misc');
     require_once libfile('function/post');
     // $searchHelper = Cloud::loadClass('Service_SearchHelper');
     // $searchparams = $searchHelper->makeSearchSignUrl();
     $appService = Cloud::loadClass('Service_App');
     if ($appService->getCloudAppStatus('search') && $searchparams) {
         $source = 'discuz';
         $params = array();
         $params['source'] = $source;
         $params['q'] = $keyword;
         $params['module'] = 'forum';
         $searchparams['params'] = array_merge($searchparams['params'], $params);
         $utilService = Cloud::loadClass('Service_Util');
         $url = $searchparams['url'] . '?' . $utilService->httpBuildQuery($searchparams['params'], '', '&');
     }
     $url = $url . '&page=' . $page;
     // $pageInfo = WebUtils::emptyReturnLine(file_get_contents($url));
     $pageInfo = WebUtils::emptyReturnLine(WebUtils::httpRequest($url));
     $pregIds = '/&tid=(\\d*)"/';
     $pregCount = '/<div class="allnum">(.*?)<\\/div>/';
     //取出搜索结果总数
     preg_match_all($pregIds, $pageInfo, $id);
     $ids = $id[1];
     if (empty($ids)) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'search_no_results');
     }
     preg_match_all($pregCount, $pageInfo, $count);
     $countStr = trim($count[1][0]);
     preg_match_all('/\\d/', $countStr, $total);
     $total_num = (int) str_replace(',', '', implode(',', $total[0]));
     $ids = $id[1];
     $data = $topicInfo = $topicSummary = array();
     foreach ($ids as $v) {
         $topicInfo = ForumUtils::getTopicInfo($v);
         // $topicInfo['lastpost'] = dgmdate($topicInfo['lastpost'], 'u');
         $topicInfos[] = $topicInfo;
     }
     unset($ids);
     $rows = $this->_fieldInfo($topicInfos);
     $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, 10, $total_num);
     $res['searchid'] = 0;
     $res = array_merge($res, $pageInfo);
     $res['list'] = $rows;
     return $res;
 }
Ejemplo n.º 13
0
 private function _startSign($res)
 {
     global $_G;
     loadcache('pluginlanguage_script');
     $lang = $_G['cache']['pluginlanguage_script']['dsu_paulsign'];
     //获取语言包
     $var = $_G['cache']['plugin']['dsu_paulsign'];
     // 获取插件的配置信息
     if (!$var['ifopen']) {
         if ($var['plug_clsmsg'] == '') {
             $var['plug_clsmsg'] = WebUtils::t('签到插件没有开启');
         }
         return WebUtils::makeErrorInfo_oldVersion($res, MOBCENT_ERROR_DEFAULT . ":{$var['plug_clsmsg']}");
     }
     $htime = dgmdate($_G['timestamp'], 'H', $var['tos']);
     // 获取当前的时间,小时
     $groups = unserialize($var['groups']);
     // 获取允许签到的用户组
     // 本月签到的处理
     $qddb = DB::fetch_first("SELECT time FROM " . DB::table('dsu_paulsign') . " ORDER BY time DESC limit 0,1");
     $lastmonth = dgmdate($qddb['time'], 'm', $var['tos']);
     $nowmonth = dgmdate($_G['timestamp'], 'm', $var['tos']);
     if ($nowmonth != $lastmonth) {
         DB::query("UPDATE " . DB::table('dsu_paulsign') . " SET mdays=0 WHERE uid");
     }
     // 获取当前用户发贴总数
     $post = DB::fetch_first("SELECT posts FROM " . DB::table('common_member_count') . " WHERE uid='{$_G['uid']}'");
     $read_ban = explode(",", $var['ban']);
     //查看黑名单用户
     // 用户签到的信息
     $qiandaodb = DB::fetch_first("SELECT * FROM " . DB::table('dsu_paulsign') . " WHERE uid='{$_G['uid']}'");
     $tdtime = gmmktime(0, 0, 0, dgmdate($_G['timestamp'], 'n', $var['tos']), dgmdate($_G['timestamp'], 'j', $var['tos']), dgmdate($_G['timestamp'], 'Y', $var['tos'])) - $var['tos'] * 3600;
     // 心情初始化
     // $emots = unserialize($_G['setting']['paulsign_emot']);
     $_GET['qdxq'] = 'kx';
     $credit = mt_rand($var['mincredit'], $var['maxcredit']);
     // 奖励积分值的设置
     // 客户端奖励倍数
     $appbymePlug = WebUtils::getDzPluginAppbymeAppConfig('dzsyscache_sign_extcredit_base');
     $appbymePlug = $appbymePlug !== false ? $appbymePlug : 100;
     $credit = $appbymePlug * 0.01 * $credit;
     $jlxgroups = unserialize($var['jlxgroups']);
     //奖励增倍的指定用户组选择
     //前N额外奖励项自定义
     $njlmain = str_replace(array("\r\n", "\n", "\r"), '/hhf/', $var['jlmain']);
     $extreward = explode("/hhf/", $njlmain);
     $extreward_num = count($extreward);
     $stats = DB::fetch_first("SELECT * FROM " . DB::table('dsu_paulsignset') . " WHERE id='1'");
     // 判断是否开启时间段限制
     if ($var['timeopen']) {
         if ($htime < $var['stime']) {
             return WebUtils::makeErrorInfo_oldVersion($res, MOBCENT_ERROR_DEFAULT . ":{$lang['ts_timeearly1']}{$var[stime]}{$lang['ts_timeearly2']}");
         } elseif ($htime > $var['ftime']) {
             return WebUtils::makeErrorInfo_oldVersion($res, MOBCENT_ERROR_DEFAULT . ":{$lang['ts_timeov']}");
         }
     }
     // 判断允许签到的用户组
     if (!in_array($_G['groupid'], $groups)) {
         return WebUtils::makeErrorInfo_oldVersion($res, MOBCENT_ERROR_DEFAULT . ":{$lang['ts_notallow']}");
     }
     // 判断当前用户的发帖总数是否允许签到
     if ($var['mintdpost'] > $post['posts']) {
         return WebUtils::makeErrorInfo_oldVersion($res, MOBCENT_ERROR_DEFAULT . ":{$lang['ts_minpost1']}{$var[mintdpost]}{$lang['ts_minpost2']}");
     }
     //判断当前用户是否在黑名单中
     if (in_array($_G['uid'], $read_ban)) {
         return WebUtils::makeErrorInfo_oldVersion($res, MOBCENT_ERROR_DEFAULT . ":{$lang['ts_black']}");
     }
     // 当前用户是否签到的判断
     if ($qiandaodb['time'] > $tdtime) {
         return WebUtils::makeErrorInfo_oldVersion($res, MOBCENT_ERROR_DEFAULT . ":{$lang['ts_yq']}");
     }
     // 心情的处理
     // if (!array_key_exists($_GET['qdxq'], $emots)) {
     //     return WebUtils::makeErrorInfo_oldVersion($res, MOBCENT_ERROR_DEFAULT.":{$lang['ts_xqnr']}");
     // }
     // 今日想说的话
     $todaysay = WebUtils::getDzPluginAppbymeAppConfig('mobile_sign_text');
     empty($todaysay) && ($todaysay = $lang['wttodaysay']);
     //判断签到进程锁
     if ($var['lockopen']) {
         while (discuz_process::islocked('dsu_paulsign', 5)) {
             usleep(100000);
         }
     }
     // jlx : 指定用户组获取奖励是一般的几倍
     if (in_array($_G['groupid'], $jlxgroups) && $var['jlx'] !== '0') {
         $credit = $credit * $var['jlx'];
     }
     // 连续签到指数开关
     if ($tdtime - $qiandaodb['time'] < 86400 && $var['lastedop'] && $qiandaodb['lasted'] !== '0') {
         $randlastednum = mt_rand($var['lastednuml'], $var['lastednumh']);
         $randlastednum = sprintf("%03d", $randlastednum);
         $randlastednum = '0.' . $randlastednum;
         $randlastednum = $randlastednum * $qiandaodb['lasted'];
         $credit = round($credit * (1 + $randlastednum));
     }
     $num = DB::result_first("SELECT COUNT(*) FROM " . DB::table('dsu_paulsign') . " WHERE time >= {$tdtime} ");
     if (!$qiandaodb['uid']) {
         DB::query("INSERT INTO " . DB::table('dsu_paulsign') . " (uid,time) VALUES ('{$_G['uid']}',{$_G['timestamp']})");
     }
     // 连续签到指数
     if ($tdtime - $qiandaodb['time'] < 86400 && $var['lastedop']) {
         DB::query("UPDATE " . DB::table('dsu_paulsign') . " SET days=days+1,mdays=mdays+1,time='{$_G['timestamp']}',qdxq='{$_GET['qdxq']}',todaysay='{$todaysay}',reward=reward+{$credit},lastreward='{$credit}',lasted=lasted+1 WHERE uid='{$_G['uid']}'");
     } else {
         DB::query("UPDATE " . DB::table('dsu_paulsign') . " SET days=days+1,mdays=mdays+1,time='{$_G['timestamp']}',qdxq='{$_GET['qdxq']}',todaysay='{$todaysay}',reward=reward+{$credit},lastreward='{$credit}',lasted='1' WHERE uid='{$_G['uid']}'");
     }
     // 添加积分操作
     updatemembercount($_G['uid'], array($var['nrcredit'] => $credit));
     require_once libfile('function/post');
     require_once libfile('function/forum');
     // 是否同步到记录
     if ($var['sync_say'] && $_GET['qdmode'] == '1') {
     }
     // 是否同步到广播大厅
     if ($var['sync_follow'] && $_GET['qdmode'] == '1' && $_G['setting']['followforumid']) {
     }
     // 每日最想说是否同步到签名
     if ($var['sync_sign'] && $_G['group']['maxsigsize']) {
         $signhtml = cutstr(strip_tags($todaysay . $lang['fromsign']), $_G['group']['maxsigsize']);
         DB::update('common_member_field_forum', array('sightml' => $signhtml), "uid='{$_G['uid']}'");
     }
     // 对前N额外奖励项
     if ($num <= $extreward_num - 1) {
         list($exacr, $exacz) = explode("|", $extreward[$num]);
         $psc = $num + 1;
         if ($exacr && $exacz) {
             updatemembercount($_G['uid'], array($exacr => $exacz));
         }
     }
     // 获取主题和帖子要插入的状态信息
     $topicStatus = $this->getClientApp('topic', $_GET['platType']);
     $postStatus = $this->getClientApp('post', $_GET['platType']);
     // 对签到自动回复的类型进行处理
     // 2:指定贴自动回复
     if ($var['qdtype'] == '2') {
         $thread = DB::fetch_first("SELECT * FROM " . DB::table('forum_thread') . " WHERE tid='{$var['tidnumber']}'");
         $hft = dgmdate($_G['timestamp'], 'Y-m-d H:i', $var['tos']);
         if ($num >= 0 && $num <= $extreward_num - 1 && $exacr && $exacz) {
             $message = "[quote][size=2][color=gray][color=teal] [/color][color=gray]{$lang[tsn_01]}[/color] [color=darkorange]{$hft}[/color] {$lang[tsn_02]}[color=red]{$lang[tsn_03]}[/color][color=darkorange]{$lang[tsn_04]}{$psc}{$lang[tsn_05]}[/color]{$lang[tsn_06]} [/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][title]} [/color][color=darkorange]{$credit}[/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][unit]}[/color][color=gray]{$lang[tsn_17]}[/color] [color=gray]{$_G[setting][extcredits][$exacr][title]} [/color][color=darkorange]{$exacz}[/color][color=gray]{$_G[setting][extcredits][$exacr][unit]}.{$another_vip}[/color][/color][/size][/quote][size=3][color=dimgray]{$lang[tsn_07]}[color=red]{$todaysay}[/color]{$lang[tsn_08]}[/color][/size]";
         } else {
             $message = "[quote][size=2][color=gray][color=teal] [/color][color=gray]{$lang[tsn_01]}[/color] [color=darkorange]{$hft}[/color] {$lang[tsn_09]}{$lang[tsn_06]} [/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][title]} [/color][color=darkorange]{$credit} [/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][unit]}.{$another_vip}[/color][/size][/quote][size=3][color=dimgray]{$lang[tsn_07]}[color=red]{$todaysay}[/color]{$lang[tsn_08]}[/color][/size]";
         }
         $pid = insertpost(array('fid' => $thread['fid'], 'tid' => $var['tidnumber'], 'first' => '0', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => '', 'dateline' => $_G['timestamp'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => '0', 'anonymous' => '0', 'usesig' => '0', 'htmlon' => '0', 'bbcodeoff' => '0', 'smileyoff' => '0', 'parseurloff' => '0', 'attachment' => '0', 'status' => $postStatus));
         DB::query("UPDATE " . DB::table('forum_thread') . " SET lastposter='{$_G['username']}', lastpost='{$_G['timestamp']}', replies=replies+1 WHERE tid='{$var['tidnumber']}' AND fid='{$thread['fid']}'", 'UNBUFFERED');
         updatepostcredits('+', $_G['uid'], 'reply', $thread['fid']);
         $lastpost = "{$thread['tid']}\t" . addslashes($thread['subject']) . "\t{$_G['timestamp']}\t{$_G['username']}";
         DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}', posts=posts+1, todayposts=todayposts+1 WHERE fid='{$thread['fid']}'", 'UNBUFFERED');
         $tidnumber = $var['tidnumber'];
         // 指定板块每天一主题
     } elseif ($var['qdtype'] == '3') {
         if ($num == '0' || $stats['qdtidnumber'] == '0') {
             $subject = str_replace(array('{m}', '{d}', '{y}', '{bbname}', '{author}'), array(dgmdate($_G['timestamp'], 'n', $var['tos']), dgmdate($_G['timestamp'], 'j', $var['tos']), dgmdate($_G['timestamp'], 'Y', $var['tos']), $_G['setting']['bbname'], $_G['username']), $var['title_thread']);
             $hft = dgmdate($_G['timestamp'], 'Y-m-d H:i', $var['tos']);
             if ($exacr && $exacz) {
                 $message = "[quote][size=2][color=dimgray]{$lang[tsn_10]}[/color][url={$_G[siteurl]}plugin.php?id=dsu_paulsign:sign][color=darkorange]{$lang[tsn_11]}[/color][/url][color=dimgray]{$lang[tsn_12]}[/color][/size][/quote][quote][size=2][color=gray][color=teal] [/color][color=gray]{$lang[tsn_01]}[/color] [color=darkorange]{$hft}[/color] {$lang[tsn_02]}[color=red]{$lang[tsn_03]}[/color][color=darkorange]{$lang[tsn_04]}{$lang[tsn_13]}{$lang[tsn_05]}[/color]{$lang[tsn_06]} [/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][title]} [/color][color=darkorange]{$credit}[/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][unit]}[/color][color=gray]{$lang[tsn_17]}[/color] [color=gray]{$_G[setting][extcredits][$exacr][title]} [/color][color=darkorange]{$exacz}[/color][color=gray]{$_G[setting][extcredits][$exacr][unit]}.{$another_vip}[/color][/color][/size][/quote][size=3][color=dimgray]{$lang[tsn_07]}[color=red]{$todaysay}[/color]{$lang[tsn_08]}[/color][/size]";
             } else {
                 $message = "[quote][size=2][color=dimgray]{$lang[tsn_10]}[/color][url={$_G[siteurl]}plugin.php?id=dsu_paulsign:sign][color=darkorange]{$lang[tsn_11]}[/color][/url][color=dimgray]{$lang[tsn_12]}[/color][/size][/quote][quote][size=2][color=gray][color=teal] [/color][color=gray]{$lang[tsn_01]}[/color] [color=darkorange]{$hft}[/color] {$lang[tsn_02]}[color=red]{$lang[tsn_03]}[/color][color=darkorange]{$lang[tsn_04]}{$lang[tsn_13]}{$lang[tsn_05]}[/color]{$lang[tsn_06]} [/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][title]} [/color][color=darkorange]{$credit}[/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][unit]}.{$another_vip}[/color][/color][/size][/quote][size=3][color=dimgray]{$lang[tsn_07]}[color=red]{$todaysay}[/color]{$lang[tsn_08]}[/color][/size]";
             }
             DB::query("INSERT INTO " . DB::table('forum_thread') . " (fid, posttableid, readperm, price, typeid, sortid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, special, attachment, moderated, highlight, closed, status, isgroup) VALUES ('{$var['fidnumber']}', '0', '0', '0', '{$var['qdtypeid']}', '0', '{$_G['username']}', '{$_G['uid']}', '{$subject}', '{$_G['timestamp']}', '{$_G['timestamp']}', '{$_G['username']}', '0', '0', '0', '0', '1', '1', '1', '{$topicStatus}', '0')");
             $tid = DB::insert_id();
             DB::query("UPDATE " . DB::table('dsu_paulsignset') . " SET qdtidnumber = '{$tid}' WHERE id='1'");
             $pid = insertpost(array('fid' => $var['fidnumber'], 'tid' => $tid, 'first' => '1', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $_G['timestamp'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => '0', 'anonymous' => '0', 'usesig' => '0', 'htmlon' => '0', 'bbcodeoff' => '0', 'smileyoff' => '0', 'parseurloff' => '0', 'attachment' => '0', 'status' => $postStatus));
             $expiration = $_G['timestamp'] + 86400;
             DB::query("INSERT INTO " . DB::table('forum_thread') . "mod (tid, uid, username, dateline, action, expiration, status) VALUES ('{$tid}', '{$_G['uid']}', '{$_G['username']}', '{$_G['timestamp']}', 'EHL', '{$expiration}', '1')");
             DB::query("INSERT INTO " . DB::table('forum_thread') . "mod (tid, uid, username, dateline, action, expiration, status) VALUES ('{$tid}', '{$_G['uid']}', '{$_G['username']}', '{$_G['timestamp']}', 'CLS', '0', '1')");
             updatepostcredits('+', $_G['uid'], 'post', $var['fidnumber']);
             $lastpost = "{$tid}\t" . addslashes($subject) . "\t{$_G['timestamp']}\t{$_G['username']}";
             DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='{$var['fidnumber']}'", 'UNBUFFERED');
             $tidnumber = $tid;
         } else {
             $tidnumber = $stats['qdtidnumber'];
             $thread = DB::fetch_first("SELECT subject FROM " . DB::table('forum_thread') . " WHERE tid='{$tidnumber}'");
             $hft = dgmdate($_G['timestamp'], 'Y-m-d H:i', $var['tos']);
             if ($num >= 1 && $num <= $extreward_num - 1 && $exacr && $exacz) {
                 $message = "[quote][size=2][color=gray][color=teal] [/color][color=gray]{$lang[tsn_01]}[/color] [color=darkorange]{$hft}[/color] {$lang[tsn_02]}[color=red]{$lang[tsn_03]}[/color][color=darkorange]{$lang[tsn_04]}{$psc}{$lang[tsn_05]}[/color]{$lang[tsn_06]} [/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][title]} [/color][color=darkorange]{$credit}[/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][unit]}[/color][color=gray]{$lang[tsn_17]}[/color] [color=gray]{$_G[setting][extcredits][$exacr][title]} [/color][color=darkorange]{$exacz}[/color][color=gray]{$_G[setting][extcredits][$exacr][unit]}[/color][/color][/size][/quote][size=3][color=dimgray]{$lang[tsn_07]}[color=red]{$todaysay}[/color]{$lang[tsn_08]}[/color][/size]";
             } else {
                 $message = "[quote][size=2][color=gray][color=teal] [/color][color=gray]{$lang[tsn_01]}[/color] [color=darkorange]{$hft}[/color] {$lang[tsn_09]}{$lang[tsn_06]} [/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][title]} [/color][color=darkorange]{$credit} [/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][unit]}[/color][/size][/quote][size=3][color=dimgray]{$lang[tsn_07]}[color=red]{$todaysay}[/color]{$lang[tsn_08]}[/color][/size]";
             }
             // $message = $this->getClientApp($message, $_GET['platType']);
             $pid = insertpost(array('fid' => $var['fidnumber'], 'tid' => $tidnumber, 'first' => '0', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => '', 'dateline' => $_G['timestamp'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => '0', 'anonymous' => '0', 'usesig' => '0', 'htmlon' => '0', 'bbcodeoff' => '0', 'smileyoff' => '0', 'parseurloff' => '0', 'attachment' => '0', 'status' => $postStatus));
             DB::query("UPDATE " . DB::table('forum_thread') . " SET lastposter='{$_G['username']}', lastpost='{$_G['timestamp']}', replies=replies+1 WHERE tid='{$tidnumber}' AND fid='{$var['fidnumber']}'", 'UNBUFFERED');
             updatepostcredits('+', $_G['uid'], 'reply', $var['fidnumber']);
             $lastpost = "{$tidnumber}\t" . addslashes($thread['subject']) . "\t{$_G['timestamp']}\t{$_G['username']}";
             DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}', posts=posts+1, todayposts=todayposts+1 WHERE fid='{$var['fidnumber']}'", 'UNBUFFERED');
         }
     }
     if (memory('check')) {
         memory('set', 'dsu_pualsign_' . $_G['uid'], $_G['timestamp'], 86400);
     }
     if ($num == 0) {
         if ($stats['todayq'] > $stats['highestq']) {
             DB::query("UPDATE " . DB::table('dsu_paulsignset') . " SET highestq='{$stats['todayq']}' WHERE id='1'");
         }
         DB::query("UPDATE " . DB::table('dsu_paulsignset') . " SET yesterdayq='{$stats['todayq']}',todayq=1 WHERE id='1'");
         DB::query("UPDATE " . DB::table('dsu_paulsignemot') . " SET count=0");
     } else {
         DB::query("UPDATE " . DB::table('dsu_paulsignset') . " SET todayq=todayq+1 WHERE id='1'");
     }
     DB::query("UPDATE " . DB::table('dsu_paulsignemot') . " SET count=count+1 WHERE qdxq='{$_GET['qdxq']}'");
     $lasted = DB::result_first("SELECT lasted FROM " . DB::table('dsu_paulsign') . " WHERE uid='{$_G['uid']}'");
     if ($exacr && $exacz) {
         $message = "{$lang[tsn_14]}{$lang[tsn_03]}{$lang[tsn_04]}{$psc}{$lang[tsn_15]}{$lang[classn_12]}{$lasted}{$lang[classn_02]}{$lang[tsn_06]}{$_G[setting][extcredits][$var[nrcredit]][title]}{$credit}{$_G[setting][extcredits][$var[nrcredit]][unit]}{$lang[tsn_16]}{$_G[setting][extcredits][$exacr][title]}{$exacz}{$_G[setting][extcredits][$exacr][unit]}";
         return WebUtils::makeErrorInfo_oldVersion($res, $message, $params = array('noError' => 1));
     } else {
         $psc = $num + 1;
         $message = "{$lang[tsn_14]}{$lang[tsn_03]}{$lang[tsn_04]} {$psc} {$lang[tsn_15]}{$lang[classn_12]} {$lasted} {$lang[classn_02]}{$lang[tsn_06]}{$_G[setting][extcredits][$var[nrcredit]][title]} {$credit} {$_G[setting][extcredits][$var[nrcredit]][unit]}";
         return WebUtils::makeErrorInfo_oldVersion($res, $message, $params = array('noError' => 1));
     }
 }
Ejemplo n.º 14
-4
 private function _runAction($res, $uid)
 {
     if (empty($_FILES['userAvatar']['tmp_name'])) {
         return WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('请选择上传的文件'));
     }
     if ($_FILES['userAvatar']['error'] > 0) {
         return WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('上传文件失败'));
     }
     if ($_FILES['userAvatar']['size'] > 2000000) {
         return WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('上传文件太大'));
     }
     $savePath = UploadUtils::getTempAvatarPath();
     $fileName = sprintf('%s/avatar_%s.jpg', $savePath, $uid);
     if (move_uploaded_file($_FILES['userAvatar']['tmp_name'], $fileName)) {
         $imageData = file_get_contents($fileName);
         $image = $this->_uploadAvatarByUcenter($uid, $fileName, $imageData);
         FileUtils::safeDeleteFile($fileName);
         if (!empty($image)) {
             return array_merge($res, array('icon_url' => '', 'pic_path' => $image));
         }
         // WebUtils::httpRequestAppAPI('user/saveavatar', array('avatar' => $image, 'hacker_uid' => 1));
         // die();
     }
     return WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('上传文件失败'));
 }