private function _adminUserInfo($act) { global $_G; $defaultop = ''; $profilegroup = C::t('common_setting')->fetch('profilegroup', true); foreach ($profilegroup as $key => $value) { if ($value['available']) { $defaultop = $key; break; } } $errorMsg = ''; $operation = $act; require_once libfile('function/editor'); include_once libfile('function/profile'); $space = getuserbyuid($_G['uid']); space_merge($space, 'profile'); space_merge($space, 'field_home'); space_merge($space, 'field_forum'); $space['sightml'] = html2bbcode($space['sightml']); $vid = $_GET['vid'] ? intval($_GET['vid']) : 0; $privacy = $space['privacy']['profile'] ? $space['privacy']['profile'] : array(); $_G['setting']['privacy'] = $_G['setting']['privacy'] ? $_G['setting']['privacy'] : array(); $_G['setting']['privacy'] = is_array($_G['setting']['privacy']) ? $_G['setting']['privacy'] : dunserialize($_G['setting']['privacy']); $_G['setting']['privacy']['profile'] = !empty($_G['setting']['privacy']['profile']) ? $_G['setting']['privacy']['profile'] : array(); $privacy = array_merge($_G['setting']['privacy']['profile'], $privacy); $actives = array('profile' => ' class="a"'); $opactives = array($operation => ' class="a"'); $allowitems = array(); $allowitems = $profilegroup[$operation]['field']; $showbtn = $vid && $verify['verify' . $vid] != 1 || empty($vid); if (!empty($verify) && is_array($verify)) { foreach ($verify as $key => $flag) { if (in_array($key, array('verify1', 'verify2', 'verify3', 'verify4', 'verify5', 'verify6', 'verify7')) && $flag == 1) { $verifyid = intval(substr($key, -1, 1)); if ($_G['setting']['verify'][$verifyid]['available']) { foreach ($_G['setting']['verify'][$verifyid]['field'] as $field) { $_G['cache']['profilesetting'][$field]['unchangeable'] = 1; } } } } } if ($vid) { if ($value = C::t('common_member_verify_info')->fetch_by_uid_verifytype($_G['uid'], $vid)) { $field = dunserialize($value['field']); foreach ($field as $key => $fvalue) { $space[$key] = $fvalue; } } } $htmls = $settings = array(); foreach ($allowitems as $fieldid) { if (!in_array($fieldid, array('sightml', 'customstatus', 'timeoffset'))) { $html = profile_setting($fieldid, $space, $vid ? false : true); if ($html) { $settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid]; $htmls[$fieldid] = $html; } } } if (!empty($_POST)) { require_once libfile('function/discuzcode'); $forum = $setarr = $verifyarr = $errorarr = array(); $forumfield = array('customstatus', 'sightml'); $censor = discuz_censor::instance(); if ($_GET['vid']) { $vid = intval($_GET['vid']); $verifyconfig = $_G['setting']['verify'][$vid]; if ($verifyconfig['available'] && (empty($verifyconfig['groupid']) || in_array($_G['groupid'], $verifyconfig['groupid']))) { $verifyinfo = C::t('common_member_verify_info')->fetch_by_uid_verifytype($_G['uid'], $vid); if (!empty($verifyinfo)) { $verifyinfo['field'] = dunserialize($verifyinfo['field']); } foreach ($verifyconfig['field'] as $key => $field) { if (!isset($verifyinfo['field'][$key])) { $verifyinfo['field'][$key] = $key; } } } else { $_GET['vid'] = $vid = 0; $verifyconfig = array(); } } if (isset($_POST['birthprovince'])) { $initcity = array('birthprovince', 'birthcity', 'birthdist', 'birthcommunity'); foreach ($initcity as $key) { $_GET['' . $key] = $_POST[$key] = !empty($_POST[$key]) ? $_POST[$key] : ''; } } if (isset($_POST['resideprovince'])) { $initcity = array('resideprovince', 'residecity', 'residedist', 'residecommunity'); foreach ($initcity as $key) { $_GET['' . $key] = $_POST[$key] = !empty($_POST[$key]) ? $_POST[$key] : ''; } } foreach ($_POST as $key => $value) { $field = $_G['cache']['profilesetting'][$key]; if (in_array($field['formtype'], array('text', 'textarea')) || in_array($key, $forumfield)) { $censor->check($value); if ($censor->modbanned() || $censor->modmoderated()) { $list = $this->makeErrorInfo($res, 'profile_censor'); $this->_exitWithHtmlAlert($list['errcode']); // profile_showerror($key, lang('spacecp', 'profile_censor')); } } if (in_array($key, $forumfield)) { if ($key == 'sightml') { loadcache(array('smilies', 'smileytypes')); $value = cutstr($value, $_G['group']['maxsigsize'], ''); foreach ($_G['cache']['smilies']['replacearray'] as $skey => $smiley) { $_G['cache']['smilies']['replacearray'][$skey] = '[img]' . $_G['siteurl'] . 'static/image/smiley/' . $_G['cache']['smileytypes'][$_G['cache']['smilies']['typearray'][$skey]]['directory'] . '/' . $smiley . '[/img]'; } $value = preg_replace($_G['cache']['smilies']['searcharray'], $_G['cache']['smilies']['replacearray'], trim($value)); $forum[$key] = discuzcode($value, 1, 0, 0, 0, $_G['group']['allowsigbbcode'], $_G['group']['allowsigimgcode'], 0, 0, 1); } elseif ($key == 'customstatus' && $allowcstatus) { $forum[$key] = dhtmlspecialchars(trim($value)); } continue; } elseif ($field && !$field['available']) { continue; } elseif ($key == 'timeoffset') { if ($value >= -12 && $value <= 12 || $value == 9999) { C::t('common_member')->update($_G['uid'], array('timeoffset' => intval($value))); } } elseif ($key == 'site') { if (!in_array(strtolower(substr($value, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://')) && !preg_match('/^static\\//', $value) && !preg_match('/^data\\//', $value)) { $value = 'http://' . $value; } } if ($field['formtype'] == 'file') { if (!empty($_FILES[$key]) && $_FILES[$key]['error'] == 0 || !empty($space[$key]) && empty($_GET['deletefile'][$key])) { $value = '1'; } else { $value = ''; } } if (empty($field)) { continue; } elseif (profile_check($key, $value, $space)) { $setarr[$key] = dhtmlspecialchars(trim($value)); } else { if ($key == 'birthprovince') { $key = 'birthcity'; } elseif ($key == 'resideprovince' || $key == 'residecommunity' || $key == 'residedist') { $key = 'residecity'; } elseif ($key == 'birthyear' || $key == 'birthmonth') { $key = 'birthday'; } // profile_showerror($key); $list = $this->makeErrorInfo($res, 'check_date_item'); $errcode = $list['errcode'] . $settings[$key]['title']; $this->_exitWithHtmlAlert($errcode); } if ($field['formtype'] == 'file') { unset($setarr[$key]); } if ($vid && $verifyconfig['available'] && isset($verifyconfig['field'][$key])) { if (isset($verifyinfo['field'][$key]) && $setarr[$key] !== $space[$key]) { $verifyarr[$key] = $setarr[$key]; } unset($setarr[$key]); } if (isset($setarr[$key]) && $_G['cache']['profilesetting'][$key]['needverify']) { if ($setarr[$key] !== $space[$key]) { $verifyarr[$key] = $setarr[$key]; } unset($setarr[$key]); } } if ($vid && !empty($verifyinfo['field']) && is_array($verifyinfo['field'])) { foreach ($verifyinfo['field'] as $key => $fvalue) { if (!isset($verifyconfig['field'][$key])) { unset($verifyinfo['field'][$key]); continue; } if (empty($verifyarr[$key]) && !isset($verifyarr[$key]) && isset($verifyinfo['field'][$key])) { $verifyarr[$key] = !empty($fvalue) && $key != $fvalue ? $fvalue : $space[$key]; } } } if ($forum) { if (!$_G['group']['maxsigsize']) { $forum['sightml'] = ''; } C::t('common_member_field_forum')->update($_G['uid'], $forum); } if (isset($_POST['birthmonth']) && ($space['birthmonth'] != $_POST['birthmonth'] || $space['birthday'] != $_POST['birthday'])) { $setarr['constellation'] = get_constellation($_POST['birthmonth'], $_POST['birthday']); } if (isset($_POST['birthyear']) && $space['birthyear'] != $_POST['birthyear']) { $setarr['zodiac'] = get_zodiac($_POST['birthyear']); } if ($setarr) { C::t('common_member_profile')->update($_G['uid'], $setarr); } if ($verifyarr) { C::t('common_member_verify_info')->delete_by_uid($_G['uid'], $vid); $setverify = array('uid' => $_G['uid'], 'username' => $_G['username'], 'verifytype' => $vid, 'field' => serialize($verifyarr), 'dateline' => $_G['timestamp']); C::t('common_member_verify_info')->insert($setverify); if (!C::t('common_member_verify')->count_by_uid($_G['uid'])) { C::t('common_member_verify')->insert(array('uid' => $_G['uid'])); } if ($_G['setting']['verify'][$vid]['available']) { manage_addnotify('verify_' . $vid, 0, array('langkey' => 'manage_verify_field', 'verifyname' => $_G['setting']['verify'][$vid]['title'], 'doid' => $vid)); } } if (isset($_POST['privacy'])) { foreach ($_POST['privacy'] as $key => $value) { if (isset($_G['cache']['profilesetting'][$key])) { $space['privacy']['profile'][$key] = intval($value); } } C::t('common_member_field_home')->update($space['uid'], array('privacy' => serialize($space['privacy']))); } manyoulog('user', $_G['uid'], 'update'); include_once libfile('function/feed'); feed_add('profile', 'feed_profile_update_' . $operation, array('hash_data' => 'profile')); countprofileprogress(); // $message = $vid ? lang('spacecp', 'profile_verify_verifying', array('verify' => $verifyconfig['title'])) : ''; $list = $this->makeErrorInfo($res, 'update_date_success'); $this->_exitWithHtmlAlert($list['errcode']); } $this->getController()->renderPartial('userInfoAdmin', array('formUrl' => WebUtils::createUrl_oldVersion('user/userinfoadminview', array('act' => $act)), 'errorMsg' => $errorMsg, 'action' => $act, '_G' => $_G, 'htmls' => $htmls, 'settings' => $settings)); }
if (in_array($thread['displayorder'], array(2, 3))) { $stickmodify = 1; } if ($_G['forum']['status'] == 3 && $thread['closed'] > 1) { $deleteredirect[] = $thread['closed']; } if ($thread['isgroup'] == 1 && $thread['closed'] > 1) { $remarkclosed[] = $thread['closed']; } } $modaction = 'DEL'; require_once libfile('function/delete'); $tids = array_keys($threadlist); if ($_G['forum']['recyclebin']) { deletethread($tids, true, true, true); manage_addnotify('verifyrecycle', $modpostsnum); } else { deletethread($tids, true, true); $updatemodlog = FALSE; } $forumstickthreads = $_G['setting']['forumstickthreads']; $forumstickthreads = !empty($forumstickthreads) ? unserialize($forumstickthreads) : array(); $delkeys = array_keys($threadlist); foreach ($delkeys as $k) { unset($forumstickthreads[$k]); } $forumstickthreads = addslashes(serialize($forumstickthreads)); DB::query("UPDATE " . DB::table('common_setting') . " SET svalue='{$forumstickthreads}' WHERE skey='forumstickthreads'"); DB::delete('forum_forum_threadtable', "threads='0'"); if (!empty($deleteredirect)) { deletethread($deleteredirect);
public static function register($username, $return = 0, $groupid = 0) { global $_G; if (!$username) { return; } if (!$_G['wechat']['setting']) { $_G['wechat']['setting'] = unserialize($_G['setting']['mobilewechat']); } loaducenter(); $groupid = !$groupid ? $_G['wechat']['setting']['wechat_newusergroupid'] ? $_G['wechat']['setting']['wechat_newusergroupid'] : $_G['setting']['newusergroupid'] : $groupid; $password = md5(random(10)); $email = 'wechat_' . strtolower(random(10)) . '@null.null'; $usernamelen = dstrlen($username); if ($usernamelen < 3) { $username = $username . '_' . random(5); } if ($usernamelen > 15) { if (!$return) { showmessage('profile_username_toolong'); } else { return; } } $censorexp = '/^(' . str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote($_G['setting']['censoruser'] = trim($_G['setting']['censoruser']), '/')) . ')$/i'; if ($_G['setting']['censoruser'] && @preg_match($censorexp, $username)) { if (!$return) { showmessage('profile_username_protect'); } else { return; } } if (!$_G['wechat']['setting']['wechat_disableregrule']) { loadcache('ipctrl'); if ($_G['cache']['ipctrl']['ipregctrl']) { foreach (explode("\n", $_G['cache']['ipctrl']['ipregctrl']) as $ctrlip) { if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) { $ctrlip = $ctrlip . '%'; $_G['setting']['regctrl'] = $_G['setting']['ipregctrltime']; break; } else { $ctrlip = $_G['clientip']; } } } else { $ctrlip = $_G['clientip']; } if ($_G['setting']['regctrl']) { if (C::t('common_regip')->count_by_ip_dateline($ctrlip, $_G['timestamp'] - $_G['setting']['regctrl'] * 3600)) { if (!$return) { showmessage('register_ctrl', NULL, array('regctrl' => $_G['setting']['regctrl'])); } else { return; } } } $setregip = null; if ($_G['setting']['regfloodctrl']) { $regip = C::t('common_regip')->fetch_by_ip_dateline($_G['clientip'], $_G['timestamp'] - 86400); if ($regip) { if ($regip['count'] >= $_G['setting']['regfloodctrl']) { if (!$return) { showmessage('register_flood_ctrl', NULL, array('regfloodctrl' => $_G['setting']['regfloodctrl'])); } else { return; } } else { $setregip = 1; } } else { $setregip = 2; } } if ($setregip !== null) { if ($setregip == 1) { C::t('common_regip')->update_count_by_ip($_G['clientip']); } else { C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => 1, 'dateline' => $_G['timestamp'])); } } } $uid = uc_user_register(addslashes($username), $password, $email, '', '', $_G['clientip']); if ($uid <= 0) { if (!$return) { if ($uid == -1) { showmessage('profile_username_illegal'); } elseif ($uid == -2) { showmessage('profile_username_protect'); } elseif ($uid == -3) { showmessage('profile_username_duplicate'); } elseif ($uid == -4) { showmessage('profile_email_illegal'); } elseif ($uid == -5) { showmessage('profile_email_domain_illegal'); } elseif ($uid == -6) { showmessage('profile_email_duplicate'); } else { showmessage('undefined_action'); } } else { return; } } $init_arr = array('credits' => explode(',', $_G['setting']['initcredits'])); C::t('common_member')->insert($uid, $username, $password, $email, $_G['clientip'], $groupid, $init_arr); if ($_G['setting']['regctrl'] || $_G['setting']['regfloodctrl']) { C::t('common_regip')->delete_by_dateline($_G['timestamp'] - ($_G['setting']['regctrl'] > 72 ? $_G['setting']['regctrl'] : 72) * 3600); if ($_G['setting']['regctrl']) { C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => -1, 'dateline' => $_G['timestamp'])); } } if ($_G['setting']['regverify'] == 2) { C::t('common_member_validate')->insert(array('uid' => $uid, 'submitdate' => $_G['timestamp'], 'moddate' => 0, 'admin' => '', 'submittimes' => 1, 'status' => 0, 'message' => '', 'remark' => ''), false, true); manage_addnotify('verifyuser'); } setloginstatus(array('uid' => $uid, 'username' => $username, 'password' => $password, 'groupid' => $groupid), 0); //统计 include_once libfile('function/stat'); updatestat('register'); return $uid; }
public function newthread($parameters) { require_once libfile('function/post'); $this->tid = $this->pid = 0; $this->_init_parameters($parameters); if (trim($this->param['subject']) == '') { return $this->showmessage('post_sm_isnull'); } if (!$this->param['sortid'] && !$this->param['special'] && trim($this->param['message']) == '') { return $this->showmessage('post_sm_isnull'); } list($this->param['modnewthreads'], $this->param['modnewreplies']) = threadmodstatus($this->param['subject'] . "\t" . $this->param['message'] . $this->param['extramessage']); if ($post_invalid = checkpost($this->param['subject'], $this->param['message'], $this->param['special'] || $this->param['sortid'])) { return $this->showmessage($post_invalid, '', array('minpostsize' => $this->setting['minpostsize'], 'maxpostsize' => $this->setting['maxpostsize'])); } if (checkflood()) { return $this->showmessage('post_flood_ctrl', '', array('floodctrl' => $this->setting['floodctrl'])); } elseif (checkmaxperhour('tid')) { return $this->showmessage('thread_flood_ctrl_threads_per_hour', '', array('threads_per_hour' => $this->group['maxthreadsperhour'])); } $this->param['save'] = $this->member['uid'] ? $this->param['save'] : 0; $this->param['typeid'] = isset($this->param['typeid']) && isset($this->forum['threadtypes']['types'][$this->param['typeid']]) && (!$this->forum['threadtypes']['moderators'][$this->param['typeid']] || $this->forum['ismoderator']) ? $this->param['typeid'] : 0; $this->param['displayorder'] = $this->param['modnewthreads'] ? -2 : ($this->forum['ismoderator'] && $this->group['allowstickthread'] && !empty($this->param['sticktopic']) ? 1 : (empty($this->param['save']) ? 0 : -4)); if ($this->param['displayorder'] == -2) { C::t('forum_forum')->update($this->forum['fid'], array('modworks' => '1')); } $this->param['digest'] = $this->forum['ismoderator'] && $this->group['allowdigestthread'] && !empty($this->param['digest']) ? 1 : 0; $this->param['readperm'] = $this->group['allowsetreadperm'] ? $this->param['readperm'] : 0; $this->param['isanonymous'] = $this->group['allowanonymous'] && $this->param['isanonymous'] ? 1 : 0; $this->param['price'] = intval($this->param['price']); if (!$this->param['special']) { $this->param['price'] = $this->group['maxprice'] ? $this->param['price'] <= $this->group['maxprice'] ? $this->param['price'] : $this->group['maxprice'] : 0; } if (!$this->param['typeid'] && $this->forum['threadtypes']['required'] && !$this->param['special']) { return $this->showmessage('post_type_isnull'); } if (!$this->param['sortid'] && $this->forum['threadsorts']['required'] && !$this->param['special']) { return $this->showmessage('post_sort_isnull'); } if (!$this->param['special'] && $this->param['price'] > 0 && floor($this->param['price'] * (1 - $this->setting['creditstax'])) == 0) { return $this->showmessage('post_net_price_iszero'); } $this->param['sortid'] = $this->param['special'] && $this->forum['threadsorts']['types'][$this->param['sortid']] ? 0 : $this->param['sortid']; $this->param['typeexpiration'] = intval($this->param['typeexpiration']); if ($this->forum['threadsorts']['expiration'][$this->param['typeid']] && !$this->param['typeexpiration']) { return $this->showmessage('threadtype_expiration_invalid'); } $author = !$this->param['isanonymous'] ? $this->member['username'] : ''; $this->param['moderated'] = $this->param['digest'] || $this->param['displayorder'] > 0 ? 1 : 0; $this->param['ordertype'] && ($this->param['tstatus'] = setstatus(4, 1, $this->param['tstatus'])); $this->param['imgcontent'] && ($this->param['tstatus'] = setstatus(15, $this->param['imgcontent'], $this->param['tstatus'])); $this->param['hiddenreplies'] && ($this->param['tstatus'] = setstatus(2, 1, $this->param['tstatus'])); $this->param['allownoticeauthor'] && ($this->param['tstatus'] = setstatus(6, 1, $this->param['tstatus'])); $this->param['isgroup'] = $this->forum['status'] == 3 ? 1 : 0; $this->param['publishdate'] = !$this->param['modnewthreads'] ? $this->param['publishdate'] : TIMESTAMP; $newthread = array('fid' => $this->forum['fid'], 'posttableid' => 0, 'readperm' => $this->param['readperm'], 'price' => $this->param['price'], 'typeid' => $this->param['typeid'], 'sortid' => $this->param['sortid'], 'author' => $author, 'authorid' => $this->member['uid'], 'subject' => $this->param['subject'], 'dateline' => $this->param['publishdate'], 'lastpost' => $this->param['publishdate'], 'lastposter' => $author, 'displayorder' => $this->param['displayorder'], 'digest' => $this->param['digest'], 'special' => $this->param['special'], 'attachment' => 0, 'moderated' => $this->param['moderated'], 'status' => $this->param['tstatus'], 'isgroup' => $this->param['isgroup'], 'replycredit' => $this->param['replycredit'], 'closed' => $this->param['closed'] ? 1 : 0); $this->tid = C::t('forum_thread')->insert($newthread, true); C::t('forum_newthread')->insert(array('tid' => $this->tid, 'fid' => $this->forum['fid'], 'dateline' => $this->param['publishdate'])); useractionlog($this->member['uid'], 'tid'); if (!getuserprofile('threads') && $this->setting['newbie']) { C::t('forum_thread')->update($this->tid, array('icon' => $this->setting['newbie'])); } if ($this->param['publishdate'] != TIMESTAMP) { $cron_publish_ids = dunserialize($this->cache('cronpublish')); $cron_publish_ids[$this->tid] = $this->tid; $cron_publish_ids = serialize($cron_publish_ids); savecache('cronpublish', $cron_publish_ids); } if (!$this->param['isanonymous']) { C::t('common_member_field_home')->update($this->member['uid'], array('recentnote' => $this->param['subject'])); } if ($this->param['moderated']) { updatemodlog($this->tid, $this->param['displayorder'] > 0 ? 'STK' : 'DIG'); updatemodworks($this->param['displayorder'] > 0 ? 'STK' : 'DIG', 1); } $this->param['bbcodeoff'] = checkbbcodes($this->param['message'], !empty($this->param['bbcodeoff'])); $this->param['smileyoff'] = checksmilies($this->param['message'], !empty($this->param['smileyoff'])); $this->param['parseurloff'] = !empty($this->param['parseurloff']); $this->param['htmlon'] = $this->group['allowhtml'] && !empty($this->param['htmlon']) ? 1 : 0; $this->param['usesig'] = !empty($this->param['usesig']) && $this->group['maxsigsize'] ? 1 : 0; $class_tag = new tag(); $this->param['tagstr'] = $class_tag->add_tag($this->param['tags'], $this->tid, 'tid'); $this->param['pinvisible'] = $this->param['modnewthreads'] ? -2 : (empty($this->param['save']) ? 0 : -3); $this->param['message'] = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $this->param['message']); $this->param['pstatus'] = intval($this->param['pstatus']); defined('IN_MOBILE') && ($this->param['pstatus'] = setstatus(4, 1, $this->param['pstatus'])); if ($this->param['imgcontent']) { stringtopic($this->param['message'], $this->tid, true, $this->param['imgcontentwidth']); } $this->pid = insertpost(array('fid' => $this->forum['fid'], 'tid' => $this->tid, 'first' => '1', 'author' => $this->member['username'], 'authorid' => $this->member['uid'], 'subject' => $this->param['subject'], 'dateline' => $this->param['publishdate'], 'message' => $this->param['message'], 'useip' => $this->param['clientip'] ? $this->param['clientip'] : getglobal('clientip'), 'port' => $this->param['remoteport'] ? $this->param['remoteport'] : getglobal('remoteport'), 'invisible' => $this->param['pinvisible'], 'anonymous' => $this->param['isanonymous'], 'usesig' => $this->param['usesig'], 'htmlon' => $this->param['htmlon'], 'bbcodeoff' => $this->param['bbcodeoff'], 'smileyoff' => $this->param['smileyoff'], 'parseurloff' => $this->param['parseurloff'], 'attachment' => '0', 'tags' => $this->param['tagstr'], 'replycredit' => 0, 'status' => $this->param['pstatus'])); $statarr = array(0 => 'thread', 1 => 'poll', 2 => 'trade', 3 => 'reward', 4 => 'activity', 5 => 'debate', 127 => 'thread'); include_once libfile('function/stat'); updatestat($this->param['isgroup'] ? 'groupthread' : $statarr[$this->param['special']]); if ($this->param['geoloc'] && IN_MOBILE == 2) { list($mapx, $mapy, $location) = explode('|', $this->param['geoloc']); if ($mapx && $mapy && $location) { C::t('forum_post_location')->insert(array('pid' => $this->pid, 'tid' => $this->tid, 'uid' => $this->member['uid'], 'mapx' => $mapx, 'mapy' => $mapy, 'location' => $location)); } } if ($this->param['modnewthreads']) { updatemoderate('tid', $this->tid); C::t('forum_forum')->update_forum_counter($this->forum['fid'], 0, 0, 1); manage_addnotify('verifythread'); return 'post_newthread_mod_succeed'; } else { if ($this->param['displayorder'] != -4) { if ($this->param['digest']) { updatepostcredits('+', $this->member['uid'], 'digest', $this->forum['fid']); } updatepostcredits('+', $this->member['uid'], 'post', $this->forum['fid']); if ($this->param['isgroup']) { C::t('forum_groupuser')->update_counter_for_user($this->member['uid'], $this->forum['fid'], 1); } $subject = str_replace("\t", ' ', $this->param['subject']); $lastpost = "{$this->tid}\t" . $subject . "\t" . TIMESTAMP . "\t{$author}"; C::t('forum_forum')->update($this->forum['fid'], array('lastpost' => $lastpost)); C::t('forum_forum')->update_forum_counter($this->forum['fid'], 1, 1, 1); if ($this->forum['type'] == 'sub') { C::t('forum_forum')->update($this->forum['fup'], array('lastpost' => $lastpost)); } } if ($this->param['isgroup']) { C::t('forum_forumfield')->update($this->forum['fid'], array('lastupdate' => TIMESTAMP)); require_once libfile('function/grouplog'); updategroupcreditlog($this->forum['fid'], $this->member['uid']); } C::t('forum_sofa')->insert(array('tid' => $this->tid, 'fid' => $this->forum['fid'])); return 'post_newthread_succeed'; } }
function addportalarticlecomment($id, $message, $idtype = 'aid') { global $_G; $id = intval($id); if (empty($id)) { return 'comment_comment_noexist'; } $message = getstr($message, $_G['group']['allowcommentarticle'], 0, 0, 1, 0); if (strlen($message) < 2) { return 'content_is_too_short'; } $idtype = in_array($idtype, array('aid', 'topicid')) ? $idtype : 'aid'; $tablename = $idtype == 'aid' ? 'portal_article_title' : 'portal_topic'; $data = C::t($tablename)->fetch($id); if (empty($data)) { return 'comment_comment_noexist'; } if ($data['allowcomment'] != 1) { return 'comment_comment_notallowed'; } $message = censor($message); if (censormod($message)) { $comment_status = 1; } else { $comment_status = 0; } $setarr = array('uid' => $_G['uid'], 'username' => $_G['username'], 'id' => $id, 'idtype' => $idtype, 'postip' => $_G['clientip'], 'dateline' => $_G['timestamp'], 'status' => $comment_status, 'message' => $message); $pcid = C::t('portal_comment')->insert($setarr, true); if ($comment_status == 1) { updatemoderate($idtype . '_cid', $pcid); $notifykey = $idtype == 'aid' ? 'verifyacommont' : 'verifytopiccommont'; manage_addnotify($notifykey); } $tablename = $idtype == 'aid' ? 'portal_article_count' : 'portal_topic'; C::t($tablename)->increase($id, array('commentnum' => 1)); C::t('common_member_status')->update($_G['uid'], array('lastpost' => $_G['timestamp']), 'UNBUFFERED'); if ($data['uid'] != $_G['uid']) { updatecreditbyaction('portalcomment', 0, array(), $idtype . $id); } return 'do_success'; }
function blog_post($POST, $olds=array()) { global $_G, $space; $isself = 1; if(!empty($olds['uid']) && $olds['uid'] != $_G['uid']) { $isself = 0; $__G = $_G; $_G['uid'] = $olds['uid']; $_G['username'] = addslashes($olds['username']); } $POST['subject'] = getstr(trim($POST['subject']), 80); $POST['subject'] = censor($POST['subject']); if(strlen($POST['subject'])<1) $POST['subject'] = dgmdate($_G['timestamp'], 'Y-m-d'); $POST['friend'] = intval($POST['friend']); $POST['target_ids'] = ''; if($POST['friend'] == 2) { $uids = array(); $names = empty($_POST['target_names'])?array():explode(',', preg_replace("/(\s+)/s", ',', $_POST['target_names'])); if($names) { $uids = C::t('common_member')->fetch_all_uid_by_username($names); } if(empty($uids)) { $POST['friend'] = 3; } else { $POST['target_ids'] = implode(',', $uids); } } elseif($POST['friend'] == 4) { $POST['password'] = trim($POST['password']); if($POST['password'] == '') $POST['friend'] = 0; } if($POST['friend'] !== 2) { $POST['target_ids'] = ''; } if($POST['friend'] !== 4) { $POST['password'] == ''; } $POST['tag'] = dhtmlspecialchars(trim($POST['tag'])); $POST['tag'] = getstr($POST['tag'], 500); $POST['tag'] = censor($POST['tag']); $POST['message'] = checkhtml($POST['message']); if($_G['mobile']) { $POST['message'] = getstr($POST['message'], 0, 0, 0, 1); $POST['message'] = censor($POST['message']); } else { $POST['message'] = getstr($POST['message'], 0, 0, 0, 0, 1); $POST['message'] = censor($POST['message']); $POST['message'] = preg_replace(array( "/\<div\>\<\/div\>/i", "/\<a\s+href\=\"([^\>]+?)\"\>/i" ), array( '', '<a href="\\1" target="_blank">' ), $POST['message']); } $message = $POST['message']; if(censormod($message) || censormod($POST['subject']) || $_G['group']['allowblogmod']) { $blog_status = 1; } else { $blog_status = 0; } if(empty($olds['classid']) || $POST['classid'] != $olds['classid']) { if(!empty($POST['classid']) && substr($POST['classid'], 0, 4) == 'new:') { $classname = dhtmlspecialchars(trim(substr($POST['classid'], 4))); $classname = getstr($classname); $classname = censor($classname); if(empty($classname)) { $classid = 0; } else { $classid = C::t('home_class')->fetch_classid_by_uid_classname($_G['uid'], $classname); if(empty($classid)) { $setarr = array( 'classname' => $classname, 'uid' => $_G['uid'], 'dateline' => $_G['timestamp'] ); $classid = C::t('home_class')->insert($setarr, true); } } } else { $classid = intval($POST['classid']); } } else { $classid = $olds['classid']; } if($classid && empty($classname)) { $query = C::t('home_class')->fetch($classid); $classname = ($query['uid'] == $_G['uid']) ? $query['classname'] : ''; if(empty($classname)) $classid = 0; } $blogarr = array( 'subject' => $POST['subject'], 'classid' => $classid, 'friend' => $POST['friend'], 'password' => $POST['password'], 'noreply' => empty($POST['noreply'])?0:1, 'catid' => intval($POST['catid']), 'status' => $blog_status, ); $titlepic = ''; $uploads = array(); if(!empty($POST['picids'])) { $picids = array_keys($POST['picids']); $query = C::t('home_pic')->fetch_all_by_uid($_G['uid'], 0, 0, $picids); foreach($query as $value) { if(empty($titlepic) && $value['thumb']) { $titlepic = getimgthumbname($value['filepath']); $blogarr['picflag'] = $value['remote']?2:1; } $picurl = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0); $uploads[md5($picurl)] = $value; } if(empty($titlepic) && $value) { $titlepic = $value['filepath']; $blogarr['picflag'] = $value['remote']?2:1; } } if($uploads) { $albumid = 0; if($POST['savealbumid'] < 0 && !empty($POST['newalbum'])) { $albumname = addslashes(dhtmlspecialchars(trim($POST['newalbum']))); if(empty($albumname)) $albumname = dgmdate($_G['timestamp'],'Ymd'); $albumarr = array('albumname' => $albumname); $albumid = album_creat($albumarr); } else { $albumid = $POST['savealbumid'] < 0 ? 0 : intval($POST['savealbumid']); } if($albumid) { C::t('home_pic')->update_for_uid($_G['uid'], $picids, array('albumid' => $albumid)); album_update_pic($albumid); } preg_match_all("/\s*\<img src=\"(.+?)\".*?\>\s*/is", $message, $mathes); if(!empty($mathes[1])) { foreach ($mathes[1] as $key => $value) { $urlmd5 = md5($value); if(!empty($uploads[$urlmd5])) { unset($uploads[$urlmd5]); } } } foreach ($uploads as $value) { $picurl = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0); $message .= "<div class=\"uchome-message-pic\"><img src=\"$picurl\"><p>$value[title]</p></div>"; } } $ckmessage = preg_replace("/(\<div\>|\<\/div\>|\s|\ \;|\<br\>|\<p\>|\<\/p\>)+/is", '', $message); if(empty($ckmessage)) { return false; } if(checkperm('manageblog')) { $blogarr['hot'] = intval($POST['hot']); } if($olds['blogid']) { if($blogarr['catid'] != $olds['catid']) { if($olds['catid']) { C::t('home_blog_category')->update_num_by_catid(-1, $olds['catid'], true, true); } if($blogarr['catid']) { C::t('home_blog_category')->update_num_by_catid(1, $blogarr['catid']); } } $blogid = $olds['blogid']; C::t('home_blog')->update($blogid, $blogarr); $fuids = array(); $blogarr['uid'] = $olds['uid']; $blogarr['username'] = $olds['username']; } else { if($blogarr['catid']) { C::t('home_blog_category')->update_num_by_catid(1, $blogarr['catid']); } $blogarr['uid'] = $_G['uid']; $blogarr['username'] = $_G['username']; $blogarr['dateline'] = empty($POST['dateline'])?$_G['timestamp']:$POST['dateline']; $blogid = C::t('home_blog')->insert($blogarr, true); C::t('common_member_status')->update($_G['uid'], array('lastpost' => $_G['timestamp'])); C::t('common_member_field_home')->update($_G['uid'], array('recentnote'=>$POST['subject'])); } $blogarr['blogid'] = $blogid; $class_tag = new tag(); $POST['tag'] = $olds ? $class_tag->update_field($POST['tag'], $blogid, 'blogid') : $class_tag->add_tag($POST['tag'], $blogid, 'blogid'); $fieldarr = array( 'message' => $message, 'postip' => $_G['clientip'], 'target_ids' => $POST['target_ids'], 'tag' => $POST['tag'] ); if(!empty($titlepic)) { $fieldarr['pic'] = $titlepic; } if($olds) { C::t('home_blogfield')->update($blogid, $fieldarr); } else { $fieldarr['blogid'] = $blogid; $fieldarr['uid'] = $blogarr['uid']; C::t('home_blogfield')->insert($fieldarr); } if($isself && !$olds && $blog_status == 0) { updatecreditbyaction('publishblog', 0, array('blogs' => 1)); include_once libfile('function/stat'); updatestat('blog'); } if($olds['blogid'] && $blog_status == 1) { updatecreditbyaction('publishblog', 0, array('blogs' => -1), '', -1); include_once libfile('function/stat'); updatestat('blog'); } if($POST['makefeed'] && $blog_status == 0) { include_once libfile('function/feed'); feed_publish($blogid, 'blogid', $olds?0:1); } if(!empty($__G)) $_G = $__G; if($blog_status == 1) { updatemoderate('blogid', $blogid); manage_addnotify('verifyblog'); } return $blogarr; }
public function editpost($parameters) { $this->_init_parameters($parameters); $isfirstpost = $this->post['first'] ? 1 : 0; $isorigauthor = $this->member['uid'] && $this->member['uid'] == $this->post['authorid']; $this->param['audit'] = $this->post['invisible'] == -2 || $this->thread['displayorder'] == -2 ? $this->param['audit'] : 0; list($this->param['modnewthreads'], $this->param['modnewreplies']) = threadmodstatus($this->param['subject'] . "\t" . $this->param['message'] . $this->param['extramessage']); if ($post_invalid = checkpost($this->param['subject'], $this->param['message'], $isfirstpost && ($this->param['special'] || $this->param['sortid']))) { showmessage($post_invalid, '', array('minpostsize' => $this->setting['minpostsize'], 'maxpostsize' => $this->setting['maxpostsize'])); } if (!$isorigauthor && !$this->group['allowanonymous']) { if ($this->post['anonymous'] && !$this->param['isanonymous']) { $this->param['isanonymous'] = 0; $this->param['threadupdatearr']['author'] = $this->post['author']; $anonymousadd = 0; } else { $this->param['isanonymous'] = $this->post['anonymous']; $anonymousadd = ''; } } else { $this->param['threadupdatearr']['author'] = $this->param['isanonymous'] ? '' : $this->post['author']; $anonymousadd = $this->param['isanonymous']; } if ($isfirstpost) { if (trim($this->param['subject']) == '' && $this->thread['special'] != 2) { showmessage('post_sm_isnull'); } if (!$this->param['sortid'] && !$this->thread['special'] && trim($this->param['message']) == '') { showmessage('post_sm_isnull'); } $publishdate = null; if ($this->group['allowsetpublishdate'] && $this->thread['displayorder'] == -4) { $cron_publish_ids = dunserialize($this->cache('cronpublish')); if (!$this->param['cronpublish'] && in_array($this->thread['tid'], $cron_publish_ids) || $this->param['modnewthreads']) { $this->param['threadupdatearr']['dateline'] = $publishdate = TIMESTAMP; unset($cron_publish_ids[$this->thread['tid']]); $cron_publish_ids = serialize($cron_publish_ids); savecache('cronpublish', $cron_publish_ids); } elseif ($this->param['cronpublish'] && $this->param['cronpublishdate']) { $this->param['threadupdatearr']['dateline'] = $publishdate = strtotime($this->param['cronpublishdate']); $this->param['save'] = 1; if (!in_array($this->thread['tid'], $cron_publish_ids)) { $cron_publish_ids[$this->thread['tid']] = $this->thread['tid']; $cron_publish_ids = serialize($cron_publish_ids); savecache('cronpublish', $cron_publish_ids); } } } $this->param['readperm'] = $this->group['allowsetreadperm'] ? intval($this->param['readperm']) : ($isorigauthor ? 0 : 'ignore'); if ($this->thread['special'] != 3) { $this->param['price'] = intval($this->param['price']); $this->param['price'] = $this->thread['price'] < 0 && !$this->thread['special'] ? $isorigauthor || !$this->param['price'] ? -1 : $this->param['price'] : ($this->group['maxprice'] ? $this->param['price'] <= $this->group['maxprice'] ? $this->param['price'] > 0 ? $this->param['price'] : 0 : $this->group['maxprice'] : ($isorigauthor ? $this->param['price'] : $this->thread['price'])); if ($this->param['price'] > 0 && floor($this->param['price'] * (1 - $this->setting['creditstax'])) == 0) { return $this->showmessage('post_net_price_iszero'); } } $this->thread['status'] = setstatus(4, $this->param['ordertype'], $this->thread['status']); $this->thread['status'] = setstatus(15, $this->param['imgcontent'], $this->thread['status']); if ($this->param['imgcontent']) { stringtopic($this->param['message'], $this->post['tid'], true, $this->param['imgcontentwidth']); } $this->thread['status'] = setstatus(2, $this->param['hiddenreplies'], $this->thread['status']); $this->thread['status'] = setstatus(6, $this->param['allownoticeauthor'] ? 1 : 0, $this->thread['status']); $displayorder = empty($this->param['save']) ? $this->thread['displayorder'] == -4 ? -4 : $this->thread['displayorder'] : -4; $this->param['threadupdatearr']['typeid'] = $this->param['typeid']; $this->param['threadupdatearr']['sortid'] = $this->param['sortid']; $this->param['threadupdatearr']['subject'] = $this->param['subject']; if ($this->param['readperm'] !== 'ignore') { $this->param['threadupdatearr']['readperm'] = $this->param['readperm']; } $this->param['threadupdatearr']['price'] = $this->param['price']; $this->param['threadupdatearr']['status'] = $this->thread['status']; if (getglobal('forum_auditstatuson') && $this->param['audit'] == 1) { $this->param['threadupdatearr']['displayorder'] = 0; $this->param['threadupdatearr']['moderated'] = 1; } else { $this->param['threadupdatearr']['displayorder'] = $displayorder; } C::t('forum_thread')->update($this->thread['tid'], $this->param['threadupdatearr'], true); if ($this->thread['tid'] > 1) { if ($this->thread['closed'] > 1) { C::t('forum_thread')->update($this->thread['closed'], array('subject' => $this->param['subject']), true); } elseif (empty($this->thread['isgroup'])) { $threadclosed = C::t('forum_threadclosed')->fetch($thread['tid']); if ($threadclosed['redirect']) { C::t('forum_thread')->update($threadclosed['redirect'], array('subject' => $this->param['subject']), true); } } } $class_tag = new tag(); $tagstr = $class_tag->update_field($this->param['tags'], $this->thread['tid'], 'tid', $this->thread); } else { if ($this->param['subject'] == '' && $this->param['message'] == '' && $this->thread['special'] != 2) { showmessage('post_sm_isnull'); } } $this->param['htmlon'] = $this->group['allowhtml'] && !empty($this->param['htmlon']) ? 1 : 0; if ($this->setting['editedby'] && TIMESTAMP - $this->post['dateline'] > 60 && $this->member['adminid'] != 1) { $editor = $this->param['isanonymous'] && $isorigauthor ? lang('forum/misc', 'anonymous') : $this->member['username']; $edittime = dgmdate(TIMESTAMP); $this->param['message'] = lang('forum/misc', $this->param['htmlon'] ? 'post_edithtml' : (!$this->forum['allowbbcode'] || $this->param['bbcodeoff'] ? 'post_editnobbcode' : 'post_edit'), array('editor' => $editor, 'edittime' => $edittime)) . $this->param['message']; } $this->param['bbcodeoff'] = checkbbcodes($this->param['message'], !empty($this->param['bbcodeoff'])); $this->param['smileyoff'] = checksmilies($this->param['message'], !empty($this->param['smileyoff'])); $tagoff = $isfirstpost ? !empty($tagoff) : 0; if (getglobal('forum_auditstatuson') && $this->param['audit'] == 1) { C::t('forum_post')->update($this->thread['posttableid'], $this->post['pid'], array('status' => 4), false, false, null, -2, null, 0); updatepostcredits('+', $this->post['authorid'], $isfirstpost ? 'post' : 'reply', $this->forum['fid']); updatemodworks('MOD', 1); updatemodlog($this->thread['tid'], 'MOD'); } $displayorder = $pinvisible = 0; if ($isfirstpost) { $displayorder = $this->param['modnewthreads'] ? -2 : $this->thread['displayorder']; $pinvisible = $this->param['modnewthreads'] ? -2 : (empty($this->param['save']) ? 0 : -3); } else { $pinvisible = $this->param['modnewreplies'] ? -2 : ($this->thread['displayorder'] == -4 ? -3 : 0); } $this->param['message'] = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $this->param['message']); $this->param['parseurloff'] = !empty($this->param['parseurloff']); $setarr = array('message' => $this->param['message'], 'usesig' => $this->param['usesig'], 'htmlon' => $this->param['htmlon'], 'bbcodeoff' => $this->param['bbcodeoff'], 'parseurloff' => $this->param['parseurloff'], 'smileyoff' => $this->param['smileyoff'], 'subject' => $this->param['subject'], 'tags' => $tagstr, 'port' => getglobal('remoteport')); $setarr['status'] = $this->post['status']; if ($this->param['modstatus']) { foreach ($this->param['modstatus'] as $modbit => $modvalue) { $setarr['status'] = setstatus($modbit, $modvalue, $setarr['status']); } } if ($anonymousadd !== '') { $setarr['anonymous'] = $anonymousadd; } if ($publishdate) { $setarr['dateline'] = $publishdate; } if (getglobal('forum_auditstatuson') && $this->param['audit'] == 1) { $setarr['invisible'] = 0; } else { $setarr['invisible'] = $pinvisible; } C::t('forum_post')->update('tid:' . $this->thread['tid'], $this->post['pid'], $setarr); $this->forum['lastpost'] = explode("\t", $this->forum['lastpost']); if ($this->post['dateline'] == $this->forum['lastpost'][2] && ($this->post['author'] == $this->forum['lastpost'][3] || $this->forum['lastpost'][3] == '' && $this->post['anonymous'])) { $lastpost = $this->thread['tid'] . "\t" . ($isfirstpost ? $this->param['subject'] : $this->thread['subject']) . "\t" . $this->post['dateline'] . "\t" . ($this->param['isanonymous'] ? '' : $this->post['author']); C::t('forum_forum')->update($this->forum['fid'], array('lastpost' => $lastpost)); } if (!getglobal('forum_auditstatuson') || $this->param['audit'] != 1) { if ($isfirstpost && $this->param['modnewthreads']) { C::t('forum_thread')->update($this->thread['tid'], array('displayorder' => -2)); manage_addnotify('verifythread'); } elseif (!$isfirstpost && $this->param['modnewreplies']) { C::t('forum_thread')->increase($this->thread['tid'], array('replies' => -1)); manage_addnotify('verifypost'); } if ($this->param['modnewreplies'] || $this->param['modnewthreads']) { C::t('forum_forum')->update($this->forum['fid'], array('modworks' => '1')); } } if ($this->thread['lastpost'] == $this->post['dateline'] && (!$this->post['anonymous'] && $this->thread['lastposter'] == $this->post['author'] || $this->post['anonymous'] && $this->thread['lastposter'] == '') && $this->post['anonymous'] != $this->param['isanonymous']) { C::t('forum_thread')->update($this->thread['tid'], array('lastposter' => $this->param['isanonymous'] ? '' : $this->post['author']), true); } if (!$isorigauthor) { updatemodworks('EDT', 1); require_once libfile('function/misc'); modlog($this->thread, 'EDT'); } if ($isfirstpost && $this->thread['displayorder'] == -4 && empty($this->param['save'])) { threadpubsave($this->thread['tid']); } }
} $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message); $parseurloff = !empty($_G['gp_parseurloff']); DB::query("UPDATE " . DB::table($posttable) . " SET message='{$message}', usesig='{$_G['gp_usesig']}', htmlon='{$htmlon}', bbcodeoff='{$bbcodeoff}', parseurloff='{$parseurloff}',\r\n\t\t\tsmileyoff='{$smileyoff}', subject='{$subject}' {$anonymousadd} " . ($_G['forum_auditstatuson'] && $audit == 1 ? ",invisible='0'" : ", invisible='{$pinvisible}'") . " , tags='" . $tagstr . "' WHERE pid='{$pid}'"); $_G['forum']['lastpost'] = explode("\t", $_G['forum']['lastpost']); if ($orig['dateline'] == $_G['forum']['lastpost'][2] && ($orig['author'] == $_G['forum']['lastpost'][3] || $_G['forum']['lastpost'][3] == '' && $orig['anonymous'])) { $lastpost = "{$_G['tid']}\t" . ($isfirstpost ? $subject : addslashes($thread['subject'])) . "\t{$orig['dateline']}\t" . ($isanonymous ? '' : addslashes($orig['author'])); DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}' WHERE fid='{$_G['fid']}'", 'UNBUFFERED'); } if (!$_G['forum_auditstatuson'] || $audit != 1) { if ($isfirstpost && $modnewthreads) { DB::query("UPDATE " . DB::table('forum_thread') . " SET displayorder='-2' WHERE tid='{$_G['tid']}'"); manage_addnotify('verifythread'); } elseif (!$isfirstpost && $modnewreplies) { DB::query("UPDATE " . DB::table('forum_thread') . " SET replies=replies-'1' WHERE tid='{$_G['tid']}'"); manage_addnotify('verifypost'); } if ($modnewreplies || $modnewthreads) { DB::update('forum_forum', array('modworks' => '1'), "fid='{$_G['fid']}'"); } } if ($thread['lastpost'] == $orig['dateline'] && (!$orig['anonymous'] && $thread['lastposter'] == $orig['author'] || $orig['anonymous'] && $thread['lastposter'] == '') && $orig['anonymous'] != $isanonymous) { DB::query("UPDATE " . DB::table('forum_thread') . " SET lastposter='" . ($isanonymous ? '' : addslashes($orig['author'])) . "' WHERE tid='{$_G['tid']}'", 'UNBUFFERED'); } if (!$isorigauthor) { updatemodworks('EDT', 1); require_once libfile('function/misc'); modlog($thread, 'EDT'); } } else { if (!$_G['setting']['editperdel']) {
function on_register() { global $_G; $_G['gp_username'] = $_G['gp_' . $this->setting['reginput']['username']]; $_G['gp_password'] = $_G['gp_' . $this->setting['reginput']['password']]; $_G['gp_password2'] = $_G['gp_' . $this->setting['reginput']['password2']]; $_G['gp_email'] = $_G['gp_' . $this->setting['reginput']['email']]; if ($_G['uid']) { $ucsynlogin = $this->setting['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : ''; $url_forward = dreferer(); if (strpos($url_forward, $this->setting['regname']) !== false) { $url_forward = 'forum.php'; } showmessage('login_succeed', $url_forward ? $url_forward : './', array('username' => $_G['member']['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['uid']), array('extrajs' => $ucsynlogin)); } elseif (!$this->setting['regclosed'] && (!$this->setting['regstatus'] || !$this->setting['ucactivation'])) { if ($_G['gp_action'] == 'activation' || $this->setting['gp_activationauth']) { if (!$this->setting['ucactivation'] && !$this->setting['closedallowactivation']) { showmessage('register_disable_activation'); } } elseif (!$this->setting['regstatus']) { showmessage(!$this->setting['regclosemessage'] ? 'register_disable' : str_replace(array("\r", "\n"), '', $this->setting['regclosemessage'])); } } $bbrules =& $this->setting['bbrules']; $bbrulesforce =& $this->setting['bbrulesforce']; $bbrulestxt =& $this->setting['bbrulestxt']; $welcomemsg =& $this->setting['welcomemsg']; $welcomemsgtitle =& $this->setting['welcomemsgtitle']; $welcomemsgtxt =& $this->setting['welcomemsgtxt']; $regname = $this->setting['regname']; if ($this->setting['regverify']) { if ($this->setting['areaverifywhite']) { $location = $whitearea = ''; $location = trim(convertip($_G['clientip'], "./")); if ($location) { $whitearea = preg_quote(trim($this->setting['areaverifywhite']), '/'); $whitearea = str_replace(array("\\*"), array('.*'), $whitearea); $whitearea = '.*' . $whitearea . '.*'; $whitearea = '/^(' . str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea) . ')$/i'; if (@preg_match($whitearea, $location)) { $this->setting['regverify'] = 0; } } } if ($_G['cache']['ipctrl']['ipverifywhite']) { foreach (explode("\n", $_G['cache']['ipctrl']['ipverifywhite']) as $ctrlip) { if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) { $this->setting['regverify'] = 0; break; } } } } $invitestatus = false; if ($this->setting['regstatus'] == 2) { if ($this->setting['inviteconfig']['inviteareawhite']) { $location = $whitearea = ''; $location = trim(convertip($_G['clientip'], "./")); if ($location) { $whitearea = preg_quote(trim($this->setting['inviteconfig']['inviteareawhite']), '/'); $whitearea = str_replace(array("\\*"), array('.*'), $whitearea); $whitearea = '.*' . $whitearea . '.*'; $whitearea = '/^(' . str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea) . ')$/i'; if (@preg_match($whitearea, $location)) { $invitestatus = true; } } } if ($this->setting['inviteconfig']['inviteipwhite']) { foreach (explode("\n", $this->setting['inviteconfig']['inviteipwhite']) as $ctrlip) { if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) { $invitestatus = true; break; } } } } $groupinfo = array(); if ($this->setting['regverify']) { $groupinfo['groupid'] = 8; } else { $groupinfo['groupid'] = $this->setting['newusergroupid']; } $seccodecheck = $this->setting['seccodestatus'] & 1; $secqaacheck = $this->setting['secqaa']['status'] & 1; $fromuid = !empty($_G['cookie']['promotion']) && $this->setting['creditspolicy']['promotion_register'] ? intval($_G['cookie']['promotion']) : 0; $username = isset($_G['gp_username']) ? $_G['gp_username'] : ''; $bbrulehash = $bbrules ? substr(md5(FORMHASH), 0, 8) : ''; $auth = $_G['gp_auth']; if (!$invitestatus) { $invite = getinvite(); } if (!submitcheck('regsubmit', 0, $seccodecheck, $secqaacheck)) { if ($_G['gp_action'] == 'activation') { $auth = explode("\t", authcode($auth, 'DECODE')); if (FORMHASH != $auth[1]) { showmessage('register_activation_invalid', 'member.php?mod=logging&action=login'); } $username = $auth[0]; $activationauth = authcode("{$auth['0']}\t" . FORMHASH, 'ENCODE'); } if ($fromuid) { $query = DB::query("SELECT username FROM " . DB::table('common_member') . " WHERE uid='{$fromuid}'"); if (DB::num_rows($query)) { $fromuser = dhtmlspecialchars(DB::result($query, 0)); } else { dsetcookie('promotion'); } } $bbrulestxt = nl2br("\n{$bbrulestxt}\n\n"); if ($_G['gp_action'] == 'activation') { $auth = dhtmlspecialchars($auth); } if ($seccodecheck) { $seccode = random(6, 1); } $username = dhtmlspecialchars($username); $htmls = $settings = array(); foreach ($_G['cache']['fields_register'] as $field) { $fieldid = $field['fieldid']; $html = profile_setting($fieldid, array(), false, false, true); if ($html) { $settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid]; $htmls[$fieldid] = $html; } } $navtitle = $this->setting['reglinkname']; if ($this->extrafile && file_exists(libfile('member/' . $this->extrafile, 'module'))) { require_once libfile('member/' . $this->extrafile, 'module'); } $dreferer = dreferer(); include template($this->template); } else { if ($this->setting['regstatus'] == 2 && empty($invite) && !$invitestatus) { showmessage('not_open_registration_invite'); } if ($bbrules && $bbrulehash != $_POST['agreebbrule']) { showmessage('register_rules_agree'); } $activation = array(); if (isset($_G['gp_activationauth'])) { $activationauth = explode("\t", authcode($_G['gp_activationauth'], 'DECODE')); if ($activationauth[1] == FORMHASH && !($activation = daddslashes(uc_get_user($activationauth[0]), 1))) { showmessage('register_activation_invalid', 'member.php?mod=logging&action=login'); } } if (!$activation) { $usernamelen = dstrlen($username); if ($usernamelen < 3) { showmessage('profile_username_tooshort'); } elseif ($usernamelen > 15) { showmessage('profile_username_toolong'); } $username = addslashes(trim(dstripslashes($username))); if (uc_get_user($username) && !DB::result_first("SELECT uid FROM " . DB::table('common_member') . " WHERE username='******'")) { if ($_G['inajax']) { showmessage('profile_username_duplicate'); } else { showmessage('register_activation_message', 'member.php?mod=logging&action=login', array('username' => stripslashes($username))); } } $email = trim($_G['gp_email']); if (empty($this->setting['ignorepassword'])) { if ($_G['gp_password'] !== $_G['gp_password2']) { showmessage('profile_passwd_notmatch'); } if (!$_G['gp_password'] || $_G['gp_password'] != addslashes($_G['gp_password'])) { showmessage('profile_passwd_illegal'); } $password = $_G['gp_password']; } else { $password = md5(random(10)); } } $censorexp = '/^(' . str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote($this->setting['censoruser'] = trim($this->setting['censoruser']), '/')) . ')$/i'; if ($this->setting['censoruser'] && @preg_match($censorexp, $username)) { showmessage('profile_username_protect'); } if ($this->setting['regverify'] == 2 && !trim($_G['gp_regmessage'])) { showmessage('profile_required_info_invalid'); } if ($_G['cache']['ipctrl']['ipregctrl']) { foreach (explode("\n", $_G['cache']['ipctrl']['ipregctrl']) as $ctrlip) { if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) { $ctrlip = $ctrlip . '%'; $this->setting['regctrl'] = $this->setting['ipregctrltime']; break; } else { $ctrlip = $_G['clientip']; } } } else { $ctrlip = $_G['clientip']; } if ($this->setting['regctrl']) { $query = DB::query("SELECT ip FROM " . DB::table('common_regip') . " WHERE ip LIKE '{$ctrlip}' AND count='-1' AND dateline>{$_G['timestamp']}-'" . $this->setting['regctrl'] . "'*3600 LIMIT 1"); if (DB::num_rows($query)) { showmessage('register_ctrl', NULL, array('regctrl' => $this->setting['regctrl'])); } } $regipsql = ''; if ($this->setting['regfloodctrl']) { if ($regattempts = DB::result_first("SELECT count FROM " . DB::table('common_regip') . " WHERE ip='{$_G['clientip']}' AND count>'0' AND dateline>'{$_G['timestamp']}'-86400")) { if ($regattempts >= $this->setting['regfloodctrl']) { showmessage('register_flood_ctrl', NULL, array('regfloodctrl' => $this->setting['regfloodctrl'])); } else { $regipsql = "UPDATE " . DB::table('common_regip') . " SET count=count+1 WHERE ip='{$_G['clientip']}' AND count>'0'"; } } else { $regipsql = "INSERT INTO " . DB::table('common_regip') . " (ip, count, dateline)\r\n\t\t\t\t\t\tVALUES ('{$_G['clientip']}', '1', '{$_G['timestamp']}')"; } } $profile = $verifyarr = array(); foreach ($_G['cache']['fields_register'] as $field) { if (defined('IN_MOBILE')) { break; } $field_key = $field['fieldid']; $field_val = $_G['gp_' . $field_key]; if ($field['formtype'] == 'file' && !empty($_FILES[$field_key]) && $_FILES[$field_key]['error'] == 0) { $field_val = true; } if (!profile_check($field_key, $field_val)) { $showid = !in_array($field['fieldid'], array('birthyear', 'birthmonth')) ? $field['fieldid'] : 'birthday'; showmessage($field['title'] . lang('message', 'profile_illegal'), '', array(), array('showid' => 'chk_' . $showid, 'extrajs' => $field['title'] . lang('message', 'profile_illegal') . ($field['formtype'] == 'text' ? '<script type="text/javascript">' . '$(\'registerform\').' . $field['fieldid'] . '.className = \'px er\';' . '$(\'registerform\').' . $field['fieldid'] . '.onblur = function () { if(this.value != \'\') {this.className = \'px\';$(\'chk_' . $showid . '\').innerHTML = \'\';}}' . '</script>' : ''))); } if ($field['needverify']) { $verifyarr[$field_key] = $field_val; } else { $profile[$field_key] = $field_val; } } if (!$activation) { $uid = uc_user_register($username, $password, $email, $questionid, $answer, $_G['clientip']); if ($uid <= 0) { if ($uid == -1) { showmessage('profile_username_illegal'); } elseif ($uid == -2) { showmessage('profile_username_protect'); } elseif ($uid == -3) { showmessage('profile_username_duplicate'); } elseif ($uid == -4) { showmessage('profile_email_illegal'); } elseif ($uid == -5) { showmessage('profile_email_domain_illegal'); } elseif ($uid == -6) { showmessage('profile_email_duplicate'); } else { showmessage('undefined_action'); } } } else { list($uid, $username, $email) = $activation; } $_G['username'] = $username; if (DB::result_first("SELECT uid FROM " . DB::table('common_member') . " WHERE uid='{$uid}'")) { if (!$activation) { uc_user_delete($uid); } showmessage('profile_uid_duplicate', '', array('uid' => $uid)); } $password = md5(random(10)); $secques = $questionid > 0 ? random(8) : ''; if (isset($_POST['birthmonth']) && isset($_POST['birthday'])) { $profile['constellation'] = get_constellation($_POST['birthmonth'], $_POST['birthday']); } if (isset($_POST['birthyear'])) { $profile['zodiac'] = get_zodiac($_POST['birthyear']); } if ($_FILES) { require_once libfile('class/upload'); $upload = new discuz_upload(); foreach ($_FILES as $key => $file) { $field_key = 'field_' . $key; if (!empty($_G['cache']['fields_register'][$field_key]) && $_G['cache']['fields_register'][$field_key]['formtype'] == 'file') { $upload->init($file, 'profile'); $attach = $upload->attach; if (!$upload->error()) { $upload->save(); if (!$upload->get_image_info($attach['target'])) { @unlink($attach['target']); continue; } $attach['attachment'] = dhtmlspecialchars(trim($attach['attachment'])); if ($_G['cache']['fields_register'][$field_key]['needverify']) { $verifyarr[$key] = $attach['attachment']; } else { $profile[$key] = $attach['attachment']; } } } } } if ($regipsql) { DB::query($regipsql); } if ($invite && $this->setting['inviteconfig']['invitegroupid']) { $groupinfo['groupid'] = $this->setting['inviteconfig']['invitegroupid']; } $init_arr = explode(',', $this->setting['initcredits']); $userdata = array('uid' => $uid, 'username' => $username, 'password' => $password, 'email' => $email, 'adminid' => 0, 'groupid' => $groupinfo['groupid'], 'regdate' => TIMESTAMP, 'credits' => $init_arr[0], 'timeoffset' => 9999); $status_data = array('uid' => $uid, 'regip' => $_G['clientip'], 'lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP, 'lastpost' => 0, 'lastsendmail' => 0); $profile['uid'] = $uid; $field_forum['uid'] = $uid; $field_home['uid'] = $uid; if ($this->extrafile && file_exists(libfile('member/' . $this->extrafile, 'module'))) { require_once libfile('member/' . $this->extrafile, 'module'); } DB::insert('common_member', $userdata); DB::insert('common_member_status', $status_data); DB::insert('common_member_profile', $profile); DB::insert('common_member_field_forum', $field_forum); DB::insert('common_member_field_home', $field_home); if ($verifyarr) { $setverify = array('uid' => $uid, 'username' => $username, 'verifytype' => '0', 'field' => daddslashes(serialize($verifyarr)), 'dateline' => TIMESTAMP); DB::insert('common_member_verify_info', $setverify); DB::insert('common_member_verify', array('uid' => $uid)); } $count_data = array('uid' => $uid, 'extcredits1' => $init_arr[1], 'extcredits2' => $init_arr[2], 'extcredits3' => $init_arr[3], 'extcredits4' => $init_arr[4], 'extcredits5' => $init_arr[5], 'extcredits6' => $init_arr[6], 'extcredits7' => $init_arr[7], 'extcredits8' => $init_arr[8]); DB::insert('common_member_count', $count_data); DB::insert('common_setting', array('skey' => 'lastmember', 'svalue' => $username), false, true); manyoulog('user', $uid, 'add'); $totalmembers = DB::result_first("SELECT COUNT(*) FROM " . DB::table('common_member')); $userstats = array('totalmembers' => $totalmembers, 'newsetuser' => stripslashes($username)); save_syscache('userstats', $userstats); if ($this->setting['regctrl'] || $this->setting['regfloodctrl']) { DB::query("DELETE FROM " . DB::table('common_regip') . " WHERE dateline<='{$_G['timestamp']}'-" . ($this->setting['regctrl'] > 72 ? $this->setting['regctrl'] : 72) . "*3600", 'UNBUFFERED'); if ($this->setting['regctrl']) { DB::query("INSERT INTO " . DB::table('common_regip') . " (ip, count, dateline)\r\n\t\t\t\t\t\tVALUES ('{$_G['clientip']}', '-1', '{$_G['timestamp']}')"); } } $regmessage = dhtmlspecialchars($_G['gp_regmessage']); if ($this->setting['regverify'] == 2) { DB::query("REPLACE INTO " . DB::table('common_member_validate') . " (uid, submitdate, moddate, admin, submittimes, status, message, remark)\r\n\t\t\t\t\tVALUES ('{$uid}', '{$_G['timestamp']}', '0', '', '1', '0', '{$regmessage}', '')"); manage_addnotify('verifyuser'); } setloginstatus(array('uid' => $uid, 'username' => dstripslashes($_G['username']), 'password' => $password, 'groupid' => $groupinfo['groupid']), 0); include_once libfile('function/stat'); updatestat('register'); if ($invite['id']) { $result = DB::result_first("SELECT COUNT(*) FROM " . DB::table('common_invite') . " WHERE uid='{$invite['uid']}' AND fuid='{$uid}'"); if (!$result) { DB::update("common_invite", array('fuid' => $uid, 'fusername' => $_G['username'], 'regdateline' => $_G['timestamp'], 'status' => 2), array('id' => $invite['id'])); updatestat('invite'); } else { $invite = array(); } } if ($invite['uid']) { if ($this->setting['inviteconfig']['inviteaddcredit']) { updatemembercount($uid, array($this->setting['inviteconfig']['inviterewardcredit'] => $this->setting['inviteconfig']['inviteaddcredit'])); } if ($this->setting['inviteconfig']['invitedaddcredit']) { updatemembercount($invite['uid'], array($this->setting['inviteconfig']['inviterewardcredit'] => $this->setting['inviteconfig']['invitedaddcredit'])); } require_once libfile('function/friend'); friend_make($invite['uid'], $invite['username'], false); notification_add($invite['uid'], 'friend', 'invite_friend', array('actor' => '<a href="home.php?mod=space&uid=' . $invite['uid'] . '" target="_blank">' . $invite['username'] . '</a>'), 1); space_merge($invite, 'field_home'); if (!empty($invite['privacy']['feed']['invite'])) { require_once libfile('function/feed'); $tite_data = array('username' => '<a href="home.php?mod=space&uid=' . $_G['uid'] . '">' . $_G['username'] . '</a>'); feed_add('friend', 'feed_invite', $tite_data, '', array(), '', array(), array(), '', '', '', 0, 0, '', $invite['uid'], $invite['username']); } if ($invite['appid']) { updatestat('appinvite'); } } if ($welcomemsg && !empty($welcomemsgtxt)) { $welcomemsgtitle = addslashes(replacesitevar($welcomemsgtitle)); $welcomemsgtxt = addslashes(replacesitevar($welcomemsgtxt)); if ($welcomemsg == 1) { $welcomemsgtxt = nl2br(str_replace(':', ':', $welcomemsgtxt)); notification_add($uid, 'system', $welcomemsgtxt, array(), 1); } elseif ($welcomemsg == 2) { sendmail_cron($email, $welcomemsgtitle, $welcomemsgtxt); } elseif ($welcomemsg == 3) { sendmail_cron($email, $welcomemsgtitle, $welcomemsgtxt); $welcomemsgtxt = nl2br(str_replace(':', ':', $welcomemsgtxt)); notification_add($uid, 'system', $welcomemsgtxt, array(), 1); } } if ($fromuid) { updatecreditbyaction('promotion_register', $fromuid); dsetcookie('promotion', ''); } dsetcookie('loginuser', ''); dsetcookie('activationauth', ''); dsetcookie('invite_auth', ''); loadcache('setting', true); $_G['setting']['lastmember'] = stripslashes($username); $settingnew = $_G['setting']; $settingnew['pluginhooks'] = array(); save_syscache('setting', $settingnew); switch ($this->setting['regverify']) { case 1: $idstring = random(6); $authstr = $this->setting['regverify'] == 1 ? "{$_G['timestamp']}\t2\t{$idstring}" : ''; DB::query("UPDATE " . DB::table('common_member_field_forum') . " SET authstr='{$authstr}' WHERE uid='{$_G['uid']}'"); $verifyurl = "{$_G[siteurl]}member.php?mod=activate&uid={$_G[uid]}&id={$idstring}"; $email_verify_message = lang('email', 'email_verify_message', array('username' => $_G['member']['username'], 'bbname' => $this->setting['bbname'], 'siteurl' => $_G['siteurl'], 'url' => $verifyurl)); sendmail("{$username} <{$email}>", lang('email', 'email_verify_subject'), $email_verify_message); $message = 'register_email_verify'; $locationmessage = 'register_email_verify_location'; $url_forward = dreferer(); break; case 2: $message = 'register_manual_verify'; $locationmessage = 'register_manual_verify_location'; $url_forward = $_G['setting']['homestatus'] ? 'home.php?mod=space&do=home' : 'home.php?mod=spacecp'; break; default: $message = 'register_succeed'; $locationmessage = 'register_succeed_location'; $url_forward = dreferer(); break; } $param = array('bbname' => $this->setting['bbname'], 'username' => $_G['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['uid']); if (strpos($url_forward, $this->setting['regname']) !== false || strpos($url_forward, 'buyinvitecode') !== false) { $url_forward = 'forum.php'; } $href = str_replace("'", "\\'", $url_forward); $extra = array('showid' => 'succeedmessage', 'extrajs' => '<script type="text/javascript">' . 'setTimeout("window.location.href =\'' . $href . '\';", 3000);' . '$(\'succeedmessage_href\').href = \'' . $href . '\';' . '$(\'main_message\').style.display = \'none\';' . '$(\'main_succeed\').style.display = \'\';' . '$(\'succeedlocation\').innerHTML = \'' . lang('message', $locationmessage) . '\';' . '</script>', 'striptags' => false); showmessage($message, $url_forward, $param, $extra); } }
function add_comment($message, $id, $idtype, $cid = 0) { global $_G, $bbcode; $allowcomment = false; switch ($idtype) { case 'uid': $allowcomment = helper_access::check_module('wall'); break; case 'picid': $allowcomment = helper_access::check_module('album'); break; case 'blogid': $allowcomment = helper_access::check_module('blog'); break; case 'sid': $allowcomment = helper_access::check_module('share'); break; } if (!$allowcomment) { showmessage('quickclear_noperm'); } $summay = getstr($message, 150, 0, 0, 0, -1); $comment = array(); if ($cid) { $comment = C::t('home_comment')->fetch_by_id_idtype($id, $idtype, $cid); if ($comment && $comment['authorid'] != $_G['uid']) { $comment['message'] = preg_replace("/\\<div class=\"quote\"\\>\\<blockquote\\>.*?\\<\\/blockquote\\>\\<\\/div\\>/is", '', $comment['message']); $comment['message'] = $bbcode->html2bbcode($comment['message']); $message = "<div class=\"quote\"><blockquote><b>" . $comment['author'] . "</b>: " . getstr($comment['message'], 150, 0, 0, 2, 1) . '</blockquote></div>' . $message; if ($comment['idtype'] == 'uid') { $id = $comment['authorid']; } } else { $comment = array(); } } $hotarr = array(); $stattype = ''; $tospace = $pic = $blog = $album = $share = $poll = array(); switch ($idtype) { case 'uid': $tospace = getuserbyuid($id); $stattype = 'wall'; break; case 'picid': $pic = C::t('home_pic')->fetch($id); if (empty($pic)) { showmessage('view_images_do_not_exist'); } $picfield = C::t('home_picfield')->fetch($id); $pic['hotuser'] = $picfield['hotuser']; $tospace = getuserbyuid($pic['uid']); $album = array(); if ($pic['albumid']) { $query = C::t('home_album')->fetch($pic['albumid']); if (!$query['albumid']) { C::t('home_pic')->update_for_albumid($albumid, array('albumid' => 0)); } } if (!ckfriend($album['uid'], $album['friend'], $album['target_ids'])) { showmessage('no_privilege_ckfriend_pic'); } elseif (!$tospace['self'] && $album['friend'] == 4) { $cookiename = "view_pwd_album_{$album['albumid']}"; $cookievalue = empty($_G['cookie'][$cookiename]) ? '' : $_G['cookie'][$cookiename]; if ($cookievalue != md5(md5($album['password']))) { showmessage('no_privilege_ckpassword_pic'); } } $hotarr = array('picid', $pic['picid'], $pic['hotuser']); $stattype = 'piccomment'; break; case 'blogid': $blog = array_merge(C::t('home_blog')->fetch($id), C::t('home_blogfield')->fetch_targetids_by_blogid($id)); if (empty($blog)) { showmessage('view_to_info_did_not_exist'); } $tospace = getuserbyuid($blog['uid']); if (!ckfriend($blog['uid'], $blog['friend'], $blog['target_ids'])) { showmessage('no_privilege_ckfriend_blog'); } elseif (!$tospace['self'] && $blog['friend'] == 4) { $cookiename = "view_pwd_blog_{$blog['blogid']}"; $cookievalue = empty($_G['cookie'][$cookiename]) ? '' : $_G['cookie'][$cookiename]; if ($cookievalue != md5(md5($blog['password']))) { showmessage('no_privilege_ckpassword_blog'); } } if (!empty($blog['noreply'])) { showmessage('do_not_accept_comments'); } if ($blog['target_ids']) { $blog['target_ids'] .= ",{$blog['uid']}"; } $hotarr = array('blogid', $blog['blogid'], $blog['hotuser']); $stattype = 'blogcomment'; break; case 'sid': $share = C::t('home_share')->fetch($id); if (empty($share)) { showmessage('sharing_does_not_exist'); } $tospace = getuserbyuid($share['uid']); $hotarr = array('sid', $share['sid'], $share['hotuser']); $stattype = 'sharecomment'; break; default: showmessage('non_normal_operation'); break; } if (empty($tospace)) { showmessage('space_does_not_exist', '', array(), array('return' => true)); } if (isblacklist($tospace['uid'])) { showmessage('is_blacklist'); } if ($hotarr && $tospace['uid'] != $_G['uid']) { hot_update($hotarr[0], $hotarr[1], $hotarr[2]); } $fs = array(); $fs['icon'] = 'comment'; $fs['target_ids'] = ''; $fs['friend'] = ''; $fs['body_template'] = ''; $fs['body_data'] = array(); $fs['body_general'] = ''; $fs['images'] = array(); $fs['image_links'] = array(); switch ($idtype) { case 'uid': $fs['icon'] = 'wall'; $fs['title_template'] = 'feed_comment_space'; $fs['title_data'] = array('touser' => "<a href=\"home.php?mod=space&uid={$tospace['uid']}\">{$tospace['username']}</a>"); break; case 'picid': $fs['title_template'] = 'feed_comment_image'; $fs['title_data'] = array('touser' => "<a href=\"home.php?mod=space&uid={$tospace['uid']}\">" . $tospace['username'] . "</a>"); $fs['body_template'] = '{pic_title}'; $fs['body_data'] = array('pic_title' => $pic['title']); $fs['body_general'] = $summay; $fs['images'] = array(pic_get($pic['filepath'], 'album', $pic['thumb'], $pic['remote'])); $fs['image_links'] = array("home.php?mod=space&uid={$tospace['uid']}&do=album&picid={$pic['picid']}"); $fs['target_ids'] = $album['target_ids']; $fs['friend'] = $album['friend']; break; case 'blogid': C::t('home_blog')->increase($id, 0, array('replynum' => 1)); $fs['title_template'] = 'feed_comment_blog'; $fs['title_data'] = array('touser' => "<a href=\"home.php?mod=space&uid={$tospace['uid']}\">" . $tospace['username'] . "</a>", 'blog' => "<a href=\"home.php?mod=space&uid={$tospace['uid']}&do=blog&id={$id}\">{$blog['subject']}</a>"); $fs['target_ids'] = $blog['target_ids']; $fs['friend'] = $blog['friend']; break; case 'sid': $fs['title_template'] = 'feed_comment_share'; $fs['title_data'] = array('touser' => "<a href=\"home.php?mod=space&uid={$tospace['uid']}\">" . $tospace['username'] . "</a>", 'share' => "<a href=\"home.php?mod=space&uid={$tospace['uid']}&do=share&id={$id}\">" . str_replace(lang('spacecp', 'share_action'), '', $share['title_template']) . "</a>"); break; } $message = censor($message); if (censormod($message)) { $comment_status = 1; } else { $comment_status = 0; } $setarr = array('uid' => $tospace['uid'], 'id' => $id, 'idtype' => $idtype, 'authorid' => $_G['uid'], 'author' => $_G['username'], 'dateline' => $_G['timestamp'], 'message' => $message, 'ip' => $_G['clientip'], 'port' => $_G['remoteport'], 'status' => $comment_status); $cid = C::t('home_comment')->insert($setarr, true); $action = 'comment'; $becomment = 'getcomment'; $note = $q_note = ''; $note_values = $q_values = array(); switch ($idtype) { case 'uid': $n_url = "home.php?mod=space&uid={$tospace['uid']}&do=wall&cid={$cid}"; $note_type = 'wall'; $note = 'wall'; $note_values = array('url' => $n_url); $q_note = 'wall_reply'; $q_values = array('url' => $n_url); if ($comment) { $msg = 'note_wall_reply_success'; $magvalues = array('username' => $tospace['username']); $becomment = ''; } else { $msg = 'do_success'; $magvalues = array(); $becomment = 'getguestbook'; } $action = 'guestbook'; break; case 'picid': $n_url = "home.php?mod=space&uid={$tospace['uid']}&do=album&picid={$id}&cid={$cid}"; $note_type = 'comment'; $note = 'pic_comment'; $note_values = array('url' => $n_url); $q_note = 'pic_comment_reply'; $q_values = array('url' => $n_url); $msg = 'do_success'; $magvalues = array(); break; case 'blogid': $n_url = "home.php?mod=space&uid={$tospace['uid']}&do=blog&id={$id}&cid={$cid}"; $note_type = 'comment'; $note = 'blog_comment'; $note_values = array('url' => $n_url, 'subject' => $blog['subject']); $q_note = 'blog_comment_reply'; $q_values = array('url' => $n_url); $msg = 'do_success'; $magvalues = array(); break; case 'sid': $n_url = "home.php?mod=space&uid={$tospace['uid']}&do=share&id={$id}&cid={$cid}"; $note_type = 'comment'; $note = 'share_comment'; $note_values = array('url' => $n_url); $q_note = 'share_comment_reply'; $q_values = array('url' => $n_url); $msg = 'do_success'; $magvalues = array(); break; } if (empty($comment)) { if ($tospace['uid'] != $_G['uid']) { if (ckprivacy('comment', 'feed')) { require_once libfile('function/feed'); $fs['title_data']['hash_data'] = "{$idtype}{$id}"; feed_add($fs['icon'], $fs['title_template'], $fs['title_data'], $fs['body_template'], $fs['body_data'], $fs['body_general'], $fs['images'], $fs['image_links'], $fs['target_ids'], $fs['friend']); } $note_values['from_id'] = $id; $note_values['from_idtype'] = $idtype; $note_values['url'] .= "&goto=new#comment_{$cid}_li"; notification_add($tospace['uid'], $note_type, $note, $note_values); } } elseif ($comment['authorid'] != $_G['uid']) { notification_add($comment['authorid'], $note_type, $q_note, $q_values); } if ($comment_status == 1) { updatemoderate($idtype . '_cid', $cid); manage_addnotify('verifycommontes'); } if ($stattype) { include_once libfile('function/stat'); updatestat($stattype); } if ($tospace['uid'] != $_G['uid']) { $needle = $id; if ($idtype != 'uid') { $needle = $idtype . $id; } else { $needle = $tospace['uid']; } updatecreditbyaction($action, 0, array(), $needle); if ($becomment) { if ($idtype == 'uid') { $needle = $_G['uid']; } updatecreditbyaction($becomment, $tospace['uid'], array(), $needle); } } C::t('common_member_status')->update($_G['uid'], array('lastpost' => $_G['timestamp']), 'UNBUFFERED'); $magvalues['cid'] = $cid; return array('cid' => $cid, 'msg' => $msg, 'magvalues' => $magvalues); }
if (!($comment = DB::fetch($query))) { showmessage('no_privilege_comment_edit'); } if (submitcheck('editsubmit')) { $message = getstr($_POST['message'], 0, 1, 1, 2); if (strlen($message) < 2) { showmessage('content_is_too_short'); } $message = censor($message); if (censormod($message)) { $comment_status = 1; } else { $comment_status = 0; } if ($comment_status == 1) { manage_addnotify('verifycommontes'); } DB::update('home_comment', array('message' => $message, 'status' => $comment_status), array('cid' => $comment['cid'])); showmessage('do_success', dreferer(), array('cid' => $comment['cid']), array('showdialog' => 1, 'showmsg' => true, 'closetime' => true)); } $comment['message'] = $bbcode->html2bbcode($comment['message']); } elseif ($_GET['op'] == 'delete') { if (submitcheck('deletesubmit')) { require_once libfile('function/delete'); if (deletecomments(array($cid))) { showmessage('do_success', dreferer(), array('cid' => $cid), array('showdialog' => 1, 'showmsg' => true, 'closetime' => true)); } else { showmessage('no_privilege_comment_del'); } } } elseif ($_GET['op'] == 'reply') {
/** * 用户注册 * * @author HanPengyu * @param string $username 用户名. * @param string $password 用户密码. * @param string $email 用户邮件. * @param string $type 注册类型,默认general. * @return array . */ public static function register($username, $password, $email, $type = 'general') { global $_G; require_once libfile('function/member'); require libfile('class/member'); require_once libfile('function/misc'); loaducenter(); $ctlObj = new register_ctl(); $ctlObj->setting = $_G['setting']; // 客户端是否开启注册功能 $mobAllowReg = WebUtils::getDzPluginAppbymeAppConfig('mobile_allow_register'); if ($mobAllowReg === '0') { return self::errorInfo(Webutils::t('客户端不允许注册')); } // 客户端是否开启跳转web页注册 // 系统是否允许注册 if (!$ctlObj->setting['regclosed'] && (!$ctlObj->setting['regstatus'] || !$ctlObj->setting['ucactivation'])) { if (!$ctlObj->setting['regstatus']) { $message = !$ctlObj->setting['regclosemessage'] ? 'register_disable' : str_replace(array("\r", "\n"), '', $ctlObj->setting['regclosemessage']); return self::errorInfo(lang('message', $message)); } } // $username = isset($username) ? trim(WebUtils::t($username)) : ''; $password = isset($password) ? $password : ''; // $password2 = isset($password2) ? $password2 : ''; $email = strtolower(trim($email)); if ($ctlObj->setting['regverify']) { // 对注册 IP 的限制 if ($ctlObj->setting['areaverifywhite']) { $location = $whitearea = ''; $location = trim(convertip($_G['clientip'], "./")); if ($location) { $whitearea = preg_quote(trim($ctlObj->setting['areaverifywhite']), '/'); $whitearea = str_replace(array("\\*"), array('.*'), $whitearea); $whitearea = '.*' . $whitearea . '.*'; $whitearea = '/^(' . str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea) . ')$/i'; if (@preg_match($whitearea, $location)) { $ctlObj->setting['regverify'] = 0; } } } if ($_G['cache']['ipctrl']['ipverifywhite']) { foreach (explode("\n", $_G['cache']['ipctrl']['ipverifywhite']) as $ctrlip) { if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) { $ctlObj->setting['regverify'] = 0; break; } } } } if ($ctlObj->setting['regverify'] && $type == 'general') { $groupinfo['groupid'] = 8; } else { $groupinfo['groupid'] = $ctlObj->setting['newusergroupid']; } // 在插件中设置的用户组 date:2015.01.15 $registerGroup = WebUtils::getDzPluginAppbymeAppConfig('mobile_register_group'); if ($registerGroup) { $groupinfo['groupid'] = $registerGroup; } $usernamelen = dstrlen($username); if ($usernamelen < 3) { return self::errorInfo(lang('message', 'profile_username_tooshort')); } elseif ($usernamelen > 15) { return self::errorInfo(lang('message', 'profile_username_toolong')); } if ($ctlObj->setting['pwlength']) { if (strlen($password) < $ctlObj->setting['pwlength']) { // 密码最小的长度 return self::errorInfo(lang('message', 'profile_password_tooshort', array('pwlength' => $ctlObj->setting['pwlength']))); } } // 密码复杂度的限制 if ($ctlObj->setting['strongpw']) { $strongpw_str = array(); if (in_array(1, $ctlObj->setting['strongpw']) && !preg_match("/\\d+/", $password)) { $strongpw_str[] = lang('member/template', 'strongpw_1'); } if (in_array(2, $ctlObj->setting['strongpw']) && !preg_match("/[a-z]+/", $password)) { $strongpw_str[] = lang('member/template', 'strongpw_2'); } if (in_array(3, $ctlObj->setting['strongpw']) && !preg_match("/[A-Z]+/", $password)) { $strongpw_str[] = lang('member/template', 'strongpw_3'); } if (in_array(4, $ctlObj->setting['strongpw']) && !preg_match("/[^a-zA-z0-9]+/", $password)) { $strongpw_str[] = lang('member/template', 'strongpw_4'); } if ($strongpw_str) { // 密码太弱,密码中必须包含什么 return self::errorInfo(lang('member/template', 'password_weak') . implode(',', $strongpw_str)); } } // if($password !== $password2) { // // 两次输入的密码不同 // return WebUtils::makeErrorInfo_oldVersion($res, lang('message', 'profile_passwd_notmatch')); // } if (!$password || $password != addslashes($password)) { // 密码有特殊的字符 return self::errorInfo(lang('message', 'profile_passwd_illegal')); } $censorexp = '/^(' . str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote($ctlObj->setting['censoruser'] = trim($ctlObj->setting['censoruser']), '/')) . ')$/i'; if ($ctlObj->setting['censoruser'] && @preg_match($censorexp, $username)) { // 用户名包含被系统屏蔽的字符 return self::errorInfo(lang('message', 'profile_username_protect')); } // 这里是对ip注册的限制 if ($_G['cache']['ipctrl']['ipregctrl']) { foreach (explode("\n", $_G['cache']['ipctrl']['ipregctrl']) as $ctrlip) { if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) { $ctrlip = $ctrlip . '%'; $ctlObj->setting['regctrl'] = $ctlObj->setting['ipregctrltime']; break; } else { $ctrlip = $_G['clientip']; } } } else { $ctrlip = $_G['clientip']; } // ip在一定时间内不能注册 if ($ctlObj->setting['regctrl']) { if (C::t('common_regip')->count_by_ip_dateline($ctrlip, $_G['timestamp'] - $ctlObj->setting['regctrl'] * 3600)) { return self::errorInfo(lang('message', 'register_ctrl', array('regctrl' => $ctlObj->setting['regctrl']))); } } // IP 地址在 24 小时内只能注册几次 $setregip = null; if ($ctlObj->setting['regfloodctrl']) { $regip = C::t('common_regip')->fetch_by_ip_dateline($_G['clientip'], $_G['timestamp'] - 86400); if ($regip) { if ($regip['count'] >= $ctlObj->setting['regfloodctrl']) { return self::errorInfo(lang('message', 'register_flood_ctrl', array('regfloodctrl' => $ctlObj->setting['regfloodctrl']))); } else { $setregip = 1; } } else { $setregip = 2; } } $uid = uc_user_register(addslashes($username), $password, $email, '', '', $_G['clientip']); if ($uid <= 0) { if ($uid == -1) { // 用户名包含敏感字符 return self::errorInfo(lang('message', 'profile_username_illegal')); } elseif ($uid == -2) { // 用户名包含被系统屏蔽的字符 return self::errorInfo(lang('message', 'profile_username_protect')); } elseif ($uid == -3) { // 该用户名已被注册 return self::errorInfo(lang('message', 'profile_username_duplicate')); } elseif ($uid == -4) { // Email 地址无效 return self::errorInfo(lang('message', 'profile_email_illegal')); } elseif ($uid == -5) { // 抱歉,Email 包含不可使用的邮箱域名 return self::errorInfo(lang('message', 'profile_email_domain_illegal')); } elseif ($uid == -6) { // 该 Email 地址已被注册 return self::errorInfo(lang('message', 'profile_email_duplicate')); } } $_G['username'] = $username; $password = md5(random(10)); if ($setregip !== null) { if ($setregip == 1) { C::t('common_regip')->update_count_by_ip($_G['clientip']); } else { C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => 1, 'dateline' => $_G['timestamp'])); } } $profile = $verifyarr = array(); $emailstatus = 0; $init_arr = array('credits' => explode(',', $ctlObj->setting['initcredits']), 'profile' => $profile, 'emailstatus' => $emailstatus); C::t('common_member')->insert($uid, $username, $password, $email, $_G['clientip'], $groupinfo['groupid'], $init_arr); if ($ctlObj->setting['regctrl'] || $ctlObj->setting['regfloodctrl']) { C::t('common_regip')->delete_by_dateline($_G['timestamp'] - ($ctlObj->setting['regctrl'] > 72 ? $ctlObj->setting['regctrl'] : 72) * 3600); if ($ctlObj->setting['regctrl']) { C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => -1, 'dateline' => $_G['timestamp'])); } } if ($ctlObj->setting['regverify'] == 1) { $idstring = random(6); $authstr = $ctlObj->setting['regverify'] == 1 ? "{$_G['timestamp']}\t2\t{$idstring}" : ''; C::t('common_member_field_forum')->update($uid, array('authstr' => $authstr)); $verifyurl = "{$_G[siteurl]}member.php?mod=activate&uid={$uid}&id={$idstring}"; $email_verify_message = lang('email', 'email_verify_message', array('username' => $username, 'bbname' => $ctlObj->setting['bbname'], 'siteurl' => $_G['siteurl'], 'url' => $verifyurl)); if (!sendmail("{$username} <{$email}>", lang('email', 'email_verify_subject'), $email_verify_message)) { runlog('sendmail', "{$email} sendmail failed."); } } // [add]更新欢迎注册等 data:2015.01.04 require_once libfile('cache/userstats', 'function'); build_cache_userstats(); $_GET['regmessage'] = Webutils::t('来自手机客户端注册'); $regmessage = dhtmlspecialchars($_GET['regmessage']); if ($ctlObj->setting['regverify'] == 2) { C::t('common_member_validate')->insert(array('uid' => $uid, 'submitdate' => $_G['timestamp'], 'moddate' => 0, 'admin' => '', 'submittimes' => 1, 'status' => 0, 'message' => $regmessage, 'remark' => ''), false, true); manage_addnotify('verifyuser'); } setloginstatus(array('uid' => $uid, 'username' => $_G['username'], 'password' => $password, 'groupid' => $groupinfo['groupid']), 0); // 统计用户表 include_once libfile('function/stat'); updatestat('register'); return self::errorInfo('', 0, array('uid' => $uid)); }
function blog_post($POST, $olds = array()) { global $_G, $space; $isself = 1; if (!empty($olds['uid']) && $olds['uid'] != $_G['uid']) { $isself = 0; $__G = $_G; $_G['uid'] = $olds['uid']; $_G['username'] = addslashes($olds['username']); } $POST['subject'] = getstr(trim($POST['subject']), 80, 1, 1); $POST['subject'] = censor($POST['subject']); if (strlen($POST['subject']) < 1) { $POST['subject'] = dgmdate($_G['timestamp'], 'Y-m-d'); } $POST['friend'] = intval($POST['friend']); $POST['target_ids'] = ''; if ($POST['friend'] == 2) { $uids = array(); $names = empty($_POST['target_names']) ? array() : explode(',', preg_replace("/(\\s+)/s", ',', $_POST['target_names'])); if ($names) { $query = DB::query("SELECT uid FROM " . DB::table('common_member') . " WHERE username IN (" . dimplode($names) . ")"); while ($value = DB::fetch($query)) { $uids[] = $value['uid']; } } if (empty($uids)) { $POST['friend'] = 3; } else { $POST['target_ids'] = implode(',', $uids); } } elseif ($POST['friend'] == 4) { $POST['password'] = trim($POST['password']); if ($POST['password'] == '') { $POST['friend'] = 0; } } if ($POST['friend'] !== 2) { $POST['target_ids'] = ''; } if ($POST['friend'] !== 4) { $POST['password'] == ''; } $POST['tag'] = dhtmlspecialchars(trim($POST['tag'])); $POST['tag'] = getstr($POST['tag'], 500, 1, 1); $POST['tag'] = censor($POST['tag']); if ($_G['mobile']) { $POST['message'] = getstr($POST['message'], 0, 1, 0, 1); $POST['message'] = censor($POST['message']); } else { $POST['message'] = checkhtml($POST['message']); $POST['message'] = getstr($POST['message'], 0, 1, 0, 0, 1); $POST['message'] = censor($POST['message']); $POST['message'] = preg_replace(array("/\\<div\\>\\<\\/div\\>/i", "/\\<a\\s+href\\=\"([^\\>]+?)\"\\>/i"), array('', '<a href="\\1" target="_blank">'), $POST['message']); } $message = $POST['message']; if (censormod($message) || censormod($POST['subject']) || $_G['group']['allowblogmod']) { $blog_status = 1; } else { $blog_status = 0; } if (empty($olds['classid']) || $POST['classid'] != $olds['classid']) { if (!empty($POST['classid']) && substr($POST['classid'], 0, 4) == 'new:') { $classname = dhtmlspecialchars(trim(substr($POST['classid'], 4))); $classname = getstr($classname, 0, 1, 1); $classname = censor($classname); if (empty($classname)) { $classid = 0; } else { $classid = DB::result(DB::query("SELECT classid FROM " . DB::table('home_class') . " WHERE uid='{$_G['uid']}' AND classname='{$classname}'")); if (empty($classid)) { $setarr = array('classname' => $classname, 'uid' => $_G['uid'], 'dateline' => $_G['timestamp']); $classid = DB::insert('home_class', $setarr, 1); } } } else { $classid = intval($POST['classid']); } } else { $classid = $olds['classid']; } if ($classid && empty($classname)) { $classname = DB::result(DB::query("SELECT classname FROM " . DB::table('home_class') . " WHERE classid='{$classid}' AND uid='{$_G['uid']}'")); if (empty($classname)) { $classid = 0; } } $blogarr = array('subject' => $POST['subject'], 'classid' => $classid, 'friend' => $POST['friend'], 'password' => $POST['password'], 'noreply' => empty($POST['noreply']) ? 0 : 1, 'catid' => intval($POST['catid']), 'status' => $blog_status); $titlepic = ''; $uploads = array(); if (!empty($POST['picids'])) { $picids = array_keys($POST['picids']); $query = DB::query("SELECT * FROM " . DB::table('home_pic') . " WHERE picid IN (" . dimplode($picids) . ") AND uid='{$_G['uid']}'"); while ($value = DB::fetch($query)) { if (empty($titlepic) && $value['thumb']) { $titlepic = getimgthumbname($value['filepath']); $blogarr['picflag'] = $value['remote'] ? 2 : 1; } $uploads[$POST['picids'][$value['picid']]] = $value; } if (empty($titlepic) && $value) { $titlepic = $value['filepath']; $blogarr['picflag'] = $value['remote'] ? 2 : 1; } } if ($uploads) { preg_match_all("/\\[imgid\\=(\\d+)\\]/i", $message, $mathes); if (!empty($mathes[1])) { $searchs = $replaces = array(); foreach ($mathes[1] as $key => $value) { if (!empty($uploads[$value])) { $picurl = pic_get($uploads[$value]['filepath'], 'album', $uploads[$value]['thumb'], $uploads[$value]['remote'], 0); $searchs[] = "[imgid={$value}]"; $replaces[] = "<img src=\"{$picurl}\">"; unset($uploads[$value]); } } if ($searchs) { $message = str_replace($searchs, $replaces, $message); } } foreach ($uploads as $value) { $picurl = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0); $message .= "<div class=\"uchome-message-pic\"><img src=\"{$picurl}\"><p>{$value['title']}</p></div>"; } } $ckmessage = preg_replace("/(\\<div\\>|\\<\\/div\\>|\\s|\\ \\;|\\<br\\>|\\<p\\>|\\<\\/p\\>)+/is", '', $message); if (empty($ckmessage)) { return false; } $message = addslashes($message); if (checkperm('manageblog')) { $blogarr['hot'] = intval($POST['hot']); } if ($olds['blogid']) { if ($blogarr['catid'] != $olds['catid']) { if ($olds['catid']) { DB::query("UPDATE " . DB::table('home_blog_category') . " SET num=num-1 WHERE catid='{$olds['catid']}' AND num>0"); } if ($blogarr['catid']) { DB::query("UPDATE " . DB::table('home_blog_category') . " SET num=num+1 WHERE catid='{$blogarr['catid']}'"); } } $blogid = $olds['blogid']; DB::update('home_blog', $blogarr, array('blogid' => $blogid)); $fuids = array(); $blogarr['uid'] = $olds['uid']; $blogarr['username'] = $olds['username']; } else { if ($blogarr['catid']) { DB::query("UPDATE " . DB::table('home_blog_category') . " SET num=num+1 WHERE catid='{$blogarr['catid']}'"); } $blogarr['uid'] = $_G['uid']; $blogarr['username'] = $_G['username']; $blogarr['dateline'] = empty($POST['dateline']) ? $_G['timestamp'] : $POST['dateline']; $blogid = DB::insert('home_blog', $blogarr, 1); DB::update('common_member_status', array('lastpost' => $_G['timestamp']), array('uid' => $_G['uid'])); DB::update('common_member_field_home', array('recentnote' => $POST['subject']), array('uid' => $_G['uid'])); } $blogarr['blogid'] = $blogid; $POST['tag'] = $olds ? modblogtag($POST['tag'], $blogid) : addblogtag($POST['tag'], $blogid); $fieldarr = array('message' => $message, 'postip' => $_G['clientip'], 'target_ids' => $POST['target_ids'], 'tag' => $POST['tag']); if (!empty($titlepic)) { $fieldarr['pic'] = $titlepic; } if ($olds) { DB::update('home_blogfield', $fieldarr, array('blogid' => $blogid)); } else { $fieldarr['blogid'] = $blogid; $fieldarr['uid'] = $blogarr['uid']; DB::insert('home_blogfield', $fieldarr); } if ($isself && !$olds && $blog_status == 0) { updatecreditbyaction('publishblog', 0, array('blogs' => 1)); include_once libfile('function/stat'); updatestat('blog'); } if ($POST['makefeed'] && $blog_status == 0) { include_once libfile('function/feed'); feed_publish($blogid, 'blogid', $olds ? 0 : 1); } if (!empty($__G)) { $_G = $__G; } if ($blog_status == 1) { updatemoderate('blogid', $blogid); manage_addnotify('verifyblog'); } return $blogarr; }
DB::query("UPDATE " . DB::table('home_pic') . " SET sharetimes=sharetimes+1 WHERE picid='{$picid}'"); break; case 'thread': DB::query("UPDATE " . DB::table('forum_thread') . " SET sharetimes=sharetimes+1 WHERE tid='{$id}'"); if ($_G['setting']['heatthread']['type'] == 2) { require_once libfile('function/forum'); update_threadpartake($id); } break; case 'article': DB::query("UPDATE " . DB::table('portal_article_count') . " SET sharetimes=sharetimes+1 WHERE aid='{$id}'"); break; } if ($arr['status'] == 1) { updatemoderate('sid', $sid); manage_addnotify('verifyshare'); } if ($type == 'link' || !DB::result_first("SELECT COUNT(*) FROM " . DB::table('home_share') . " WHERE uid='{$_G['uid']}' AND itemid='{$id}' AND type='{$type}'")) { include_once libfile('function/stat'); updatestat('share'); } if ($note_uid && $note_uid != $_G['uid']) { notification_add($note_uid, 'sharenotice', $note_message, $note_values); } $needle = $id ? $type . $id : ''; updatecreditbyaction('createshare', $_G['uid'], array('sharings' => 1), $needle); $referer = "home.php?mod=space&uid={$_G['uid']}&do=share&view={$_GET['view']}&from={$_GET['from']}"; $magvalues['sid'] = $sid; if (!$redirecturl) { $redirecturl = dreferer(); }
function on_register() { global $_G; $_GET['username'] = $_GET['' . $this->setting['reginput']['username']]; $_GET['password'] = $_GET['' . $this->setting['reginput']['password']]; $_GET['password2'] = $_GET['' . $this->setting['reginput']['password2']]; $_GET['email'] = $_GET['' . $this->setting['reginput']['email']]; if ($_G['uid']) { $ucsynlogin = $this->setting['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : ''; $url_forward = dreferer(); if (strpos($url_forward, $this->setting['regname']) !== false) { $url_forward = 'forum.php'; } showmessage('login_succeed', $url_forward ? $url_forward : './', array('username' => $_G['member']['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['uid']), array('extrajs' => $ucsynlogin)); } elseif (!$this->setting['regclosed'] && (!$this->setting['regstatus'] || !$this->setting['ucactivation'])) { if ($_GET['action'] == 'activation' || $_GET['activationauth']) { if (!$this->setting['ucactivation'] && !$this->setting['closedallowactivation']) { showmessage('register_disable_activation'); } } elseif (!$this->setting['regstatus']) { if ($this->setting['regconnect']) { dheader('location:connect.php?mod=login&op=init&referer=forum.php&statfrom=login_simple'); } showmessage(!$this->setting['regclosemessage'] ? 'register_disable' : str_replace(array("\r", "\n"), '', $this->setting['regclosemessage'])); } } $bbrules =& $this->setting['bbrules']; $bbrulesforce =& $this->setting['bbrulesforce']; $bbrulestxt =& $this->setting['bbrulestxt']; $welcomemsg =& $this->setting['welcomemsg']; $welcomemsgtitle =& $this->setting['welcomemsgtitle']; $welcomemsgtxt =& $this->setting['welcomemsgtxt']; $regname = $this->setting['regname']; if ($this->setting['regverify']) { if ($this->setting['areaverifywhite']) { $location = $whitearea = ''; $location = trim(convertip($_G['clientip'], "./")); if ($location) { $whitearea = preg_quote(trim($this->setting['areaverifywhite']), '/'); $whitearea = str_replace(array("\\*"), array('.*'), $whitearea); $whitearea = '.*' . $whitearea . '.*'; $whitearea = '/^(' . str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea) . ')$/i'; if (@preg_match($whitearea, $location)) { $this->setting['regverify'] = 0; } } } if ($_G['cache']['ipctrl']['ipverifywhite']) { foreach (explode("\n", $_G['cache']['ipctrl']['ipverifywhite']) as $ctrlip) { if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) { $this->setting['regverify'] = 0; break; } } } } $invitestatus = false; if ($this->setting['regstatus'] == 2) { if ($this->setting['inviteconfig']['inviteareawhite']) { $location = $whitearea = ''; $location = trim(convertip($_G['clientip'], "./")); if ($location) { $whitearea = preg_quote(trim($this->setting['inviteconfig']['inviteareawhite']), '/'); $whitearea = str_replace(array("\\*"), array('.*'), $whitearea); $whitearea = '.*' . $whitearea . '.*'; $whitearea = '/^(' . str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea) . ')$/i'; if (@preg_match($whitearea, $location)) { $invitestatus = true; } } } if ($this->setting['inviteconfig']['inviteipwhite']) { foreach (explode("\n", $this->setting['inviteconfig']['inviteipwhite']) as $ctrlip) { if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) { $invitestatus = true; break; } } } } $groupinfo = array(); if ($this->setting['regverify']) { $groupinfo['groupid'] = 8; } else { $groupinfo['groupid'] = $this->setting['newusergroupid']; } $seccodecheck = $this->setting['seccodestatus'] & 1; $secqaacheck = $this->setting['secqaa']['status'] & 1; $fromuid = !empty($_G['cookie']['promotion']) && $this->setting['creditspolicy']['promotion_register'] ? intval($_G['cookie']['promotion']) : 0; $username = isset($_GET['username']) ? $_GET['username'] : ''; $bbrulehash = $bbrules ? substr(md5(FORMHASH), 0, 8) : ''; $auth = $_GET['auth']; if (!$invitestatus) { $invite = getinvite(); } $sendurl = $this->setting['sendregisterurl'] ? true : false; if ($sendurl) { if (!empty($_GET['hash'])) { $_GET['hash'] = preg_replace("/[^\\[A-Za-z0-9_\\]%]/", '', $_GET['hash']); $hash = explode("\t", authcode($_GET['hash'], 'DECODE', $_G['config']['security']['authkey'])); if (is_array($hash) && isemail($hash[0]) && TIMESTAMP - $hash[1] < 259200) { $sendurl = false; } } } if (!submitcheck('regsubmit', 0, $seccodecheck, $secqaacheck)) { if ($_GET['action'] == 'activation') { $auth = explode("\t", authcode($auth, 'DECODE')); if (FORMHASH != $auth[1]) { showmessage('register_activation_invalid', 'member.php?mod=logging&action=login'); } $username = $auth[0]; $activationauth = authcode("{$auth['0']}\t" . FORMHASH, 'ENCODE'); $sendurl = false; } if (!$sendurl) { if ($fromuid) { $member = getuserbyuid($fromuid); if (!empty($member)) { $fromuser = dhtmlspecialchars($member['username']); } else { dsetcookie('promotion'); } } if ($_GET['action'] == 'activation') { $auth = dhtmlspecialchars($auth); } if ($seccodecheck) { $seccode = random(6, 1); } $username = dhtmlspecialchars($username); $htmls = $settings = array(); foreach ($_G['cache']['fields_register'] as $field) { $fieldid = $field['fieldid']; $html = profile_setting($fieldid, array(), false, false, true); if ($html) { $settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid]; $htmls[$fieldid] = $html; } } $navtitle = $this->setting['reglinkname']; if ($this->extrafile && file_exists($this->extrafile)) { require_once $this->extrafile; } } $bbrulestxt = nl2br("\n{$bbrulestxt}\n\n"); $dreferer = dreferer(); include template($this->template); } else { $activationauth = array(); if (isset($_GET['activationauth']) && $_GET['activationauth']) { $activationauth = explode("\t", authcode($_GET['activationauth'], 'DECODE')); if ($activationauth[1] != FORMHASH) { showmessage('register_activation_invalid', 'member.php?mod=logging&action=login'); } $sendurl = false; } if (!$activationauth && ($sendurl || !$_G['setting']['forgeemail'])) { checkemail($_GET['email']); } if ($sendurl) { $hashstr = urlencode(authcode("{$_GET['email']}\t{$_G['timestamp']}", 'ENCODE', $_G['config']['security']['authkey'])); $registerurl = "{$_G[siteurl]}member.php?mod=" . $this->setting['regname'] . "&hash={$hashstr}&email={$_GET[email]}"; $email_register_message = lang('email', 'email_register_message', array('bbname' => $this->setting['bbname'], 'siteurl' => $_G['siteurl'], 'url' => $registerurl)); if (!sendmail("{$_GET['email']} <{$_GET['email']}>", lang('email', 'email_register_subject'), $email_register_message)) { runlog('sendmail', "{$_GET['email']} sendmail failed."); } showmessage('register_email_send_succeed', dreferer(), array('bbname' => $this->setting['bbname']), array('showdialog' => false, 'msgtype' => 3, 'closetime' => 10)); } $emailstatus = 0; if ($this->setting['sendregisterurl'] && !$sendurl) { $_GET['email'] = strtolower($hash[0]); $this->setting['regverify'] = $this->setting['regverify'] == 1 ? 0 : $this->setting['regverify']; if (!$this->setting['regverify']) { $groupinfo['groupid'] = $this->setting['newusergroupid']; } $emailstatus = 1; } if ($this->setting['regstatus'] == 2 && empty($invite) && !$invitestatus) { showmessage('not_open_registration_invite'); } if ($bbrules && $bbrulehash != $_POST['agreebbrule']) { showmessage('register_rules_agree'); } $activation = array(); if (isset($_GET['activationauth']) && $activationauth && is_array($activationauth)) { if ($activationauth[1] == FORMHASH && !($activation = uc_get_user($activationauth[0]))) { showmessage('register_activation_invalid', 'member.php?mod=logging&action=login'); } } if (!$activation) { $usernamelen = dstrlen($username); if ($usernamelen < 3) { showmessage('profile_username_tooshort'); } elseif ($usernamelen > 15) { showmessage('profile_username_toolong'); } if (uc_get_user(addslashes($username)) && !C::t('common_member')->fetch_uid_by_username($username) && !C::t('common_member_archive')->fetch_uid_by_username($username)) { if ($_G['inajax']) { showmessage('profile_username_duplicate'); } else { showmessage('register_activation_message', 'member.php?mod=logging&action=login', array('username' => $username)); } } if ($this->setting['pwlength']) { if (strlen($_GET['password']) < $this->setting['pwlength']) { showmessage('profile_password_tooshort', '', array('pwlength' => $this->setting['pwlength'])); } } if ($this->setting['strongpw']) { $strongpw_str = array(); if (in_array(1, $this->setting['strongpw']) && !preg_match("/\\d+/", $_GET['password'])) { $strongpw_str[] = lang('member/template', 'strongpw_1'); } if (in_array(2, $this->setting['strongpw']) && !preg_match("/[a-z]+/", $_GET['password'])) { $strongpw_str[] = lang('member/template', 'strongpw_2'); } if (in_array(3, $this->setting['strongpw']) && !preg_match("/[A-Z]+/", $_GET['password'])) { $strongpw_str[] = lang('member/template', 'strongpw_3'); } if (in_array(4, $this->setting['strongpw']) && !preg_match("/[^a-zA-z0-9]+/", $_GET['password'])) { $strongpw_str[] = lang('member/template', 'strongpw_4'); } if ($strongpw_str) { showmessage(lang('member/template', 'password_weak') . implode(',', $strongpw_str)); } } $email = strtolower(trim($_GET['email'])); if (empty($email) && $_G['setting']['forgeemail']) { $_GET['email'] = $email = strtolower(random(6)) . '@' . $_SERVER['HTTP_HOST']; } if (empty($this->setting['ignorepassword'])) { if ($_GET['password'] !== $_GET['password2']) { showmessage('profile_passwd_notmatch'); } if (!$_GET['password'] || $_GET['password'] != addslashes($_GET['password'])) { showmessage('profile_passwd_illegal'); } $password = $_GET['password']; } else { $password = md5(random(10)); } } $censorexp = '/^(' . str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote($this->setting['censoruser'] = trim($this->setting['censoruser']), '/')) . ')$/i'; if ($this->setting['censoruser'] && @preg_match($censorexp, $username)) { showmessage('profile_username_protect'); } if ($this->setting['regverify'] == 2 && !trim($_GET['regmessage'])) { showmessage('profile_required_info_invalid'); } if ($_G['cache']['ipctrl']['ipregctrl']) { foreach (explode("\n", $_G['cache']['ipctrl']['ipregctrl']) as $ctrlip) { if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) { $ctrlip = $ctrlip . '%'; $this->setting['regctrl'] = $this->setting['ipregctrltime']; break; } else { $ctrlip = $_G['clientip']; } } } else { $ctrlip = $_G['clientip']; } if ($this->setting['regctrl']) { if (C::t('common_regip')->count_by_ip_dateline($ctrlip, $_G['timestamp'] - $this->setting['regctrl'] * 3600)) { showmessage('register_ctrl', NULL, array('regctrl' => $this->setting['regctrl'])); } } $setregip = null; if ($this->setting['regfloodctrl']) { $regip = C::t('common_regip')->fetch_by_ip_dateline($_G['clientip'], $_G['timestamp'] - 86400); if ($regip) { if ($regip['count'] >= $this->setting['regfloodctrl']) { showmessage('register_flood_ctrl', NULL, array('regfloodctrl' => $this->setting['regfloodctrl'])); } else { $setregip = 1; } } else { $setregip = 2; } } $profile = $verifyarr = array(); foreach ($_G['cache']['fields_register'] as $field) { if (defined('IN_MOBILE')) { break; } $field_key = $field['fieldid']; $field_val = $_GET['' . $field_key]; if ($field['formtype'] == 'file' && !empty($_FILES[$field_key]) && $_FILES[$field_key]['error'] == 0) { $field_val = true; } if (!profile_check($field_key, $field_val)) { $showid = !in_array($field['fieldid'], array('birthyear', 'birthmonth')) ? $field['fieldid'] : 'birthday'; showmessage($field['title'] . lang('message', 'profile_illegal'), '', array(), array('showid' => 'chk_' . $showid, 'extrajs' => $field['title'] . lang('message', 'profile_illegal') . ($field['formtype'] == 'text' ? '<script type="text/javascript">' . '$(\'registerform\').' . $field['fieldid'] . '.className = \'px er\';' . '$(\'registerform\').' . $field['fieldid'] . '.onblur = function () { if(this.value != \'\') {this.className = \'px\';$(\'chk_' . $showid . '\').innerHTML = \'\';}}' . '</script>' : ''))); } if ($field['needverify']) { $verifyarr[$field_key] = $field_val; } else { $profile[$field_key] = $field_val; } } if (!$activation) { $uid = uc_user_register(addslashes($username), $password, $email, $questionid, $answer, $_G['clientip']); if ($uid <= 0) { if ($uid == -1) { showmessage('profile_username_illegal'); } elseif ($uid == -2) { showmessage('profile_username_protect'); } elseif ($uid == -3) { showmessage('profile_username_duplicate'); } elseif ($uid == -4) { showmessage('profile_email_illegal'); } elseif ($uid == -5) { showmessage('profile_email_domain_illegal'); } elseif ($uid == -6) { showmessage('profile_email_duplicate'); } else { showmessage('undefined_action'); } } } else { list($uid, $username, $email) = $activation; } $_G['username'] = $username; if (getuserbyuid($uid, 1)) { if (!$activation) { uc_user_delete($uid); } showmessage('profile_uid_duplicate', '', array('uid' => $uid)); } $password = md5(random(10)); $secques = $questionid > 0 ? random(8) : ''; if (isset($_POST['birthmonth']) && isset($_POST['birthday'])) { $profile['constellation'] = get_constellation($_POST['birthmonth'], $_POST['birthday']); } if (isset($_POST['birthyear'])) { $profile['zodiac'] = get_zodiac($_POST['birthyear']); } if ($_FILES) { $upload = new discuz_upload(); foreach ($_FILES as $key => $file) { $field_key = 'field_' . $key; if (!empty($_G['cache']['fields_register'][$field_key]) && $_G['cache']['fields_register'][$field_key]['formtype'] == 'file') { $upload->init($file, 'profile'); $attach = $upload->attach; if (!$upload->error()) { $upload->save(); if (!$upload->get_image_info($attach['target'])) { @unlink($attach['target']); continue; } $attach['attachment'] = dhtmlspecialchars(trim($attach['attachment'])); if ($_G['cache']['fields_register'][$field_key]['needverify']) { $verifyarr[$key] = $attach['attachment']; } else { $profile[$key] = $attach['attachment']; } } } } } if ($setregip !== null) { if ($setregip == 1) { C::t('common_regip')->update_count_by_ip($_G['clientip']); } else { C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => 1, 'dateline' => $_G['timestamp'])); } } if ($invite && $this->setting['inviteconfig']['invitegroupid']) { $groupinfo['groupid'] = $this->setting['inviteconfig']['invitegroupid']; } $init_arr = array('credits' => explode(',', $this->setting['initcredits']), 'profile' => $profile, 'emailstatus' => $emailstatus); C::t('common_member')->insert($uid, $username, $password, $email, $_G['clientip'], $groupinfo['groupid'], $init_arr); if ($emailstatus) { updatecreditbyaction('realemail', $uid); } if ($verifyarr) { $setverify = array('uid' => $uid, 'username' => $username, 'verifytype' => '0', 'field' => serialize($verifyarr), 'dateline' => TIMESTAMP); C::t('common_member_verify_info')->insert($setverify); C::t('common_member_verify')->insert(array('uid' => $uid)); } require_once libfile('cache/userstats', 'function'); build_cache_userstats(); if ($this->extrafile && file_exists($this->extrafile)) { require_once $this->extrafile; } if ($this->setting['regctrl'] || $this->setting['regfloodctrl']) { C::t('common_regip')->delete_by_dateline($_G['timestamp'] - ($this->setting['regctrl'] > 72 ? $this->setting['regctrl'] : 72) * 3600); if ($this->setting['regctrl']) { C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => -1, 'dateline' => $_G['timestamp'])); } } $regmessage = dhtmlspecialchars($_GET['regmessage']); if ($this->setting['regverify'] == 2) { C::t('common_member_validate')->insert(array('uid' => $uid, 'submitdate' => $_G['timestamp'], 'moddate' => 0, 'admin' => '', 'submittimes' => 1, 'status' => 0, 'message' => $regmessage, 'remark' => ''), false, true); manage_addnotify('verifyuser'); } setloginstatus(array('uid' => $uid, 'username' => $_G['username'], 'password' => $password, 'groupid' => $groupinfo['groupid']), 0); include_once libfile('function/stat'); updatestat('register'); if ($invite['id']) { $result = C::t('common_invite')->count_by_uid_fuid($invite['uid'], $uid); if (!$result) { C::t('common_invite')->update($invite['id'], array('fuid' => $uid, 'fusername' => $_G['username'], 'regdateline' => $_G['timestamp'], 'status' => 2)); updatestat('invite'); } else { $invite = array(); } } if ($invite['uid']) { if ($this->setting['inviteconfig']['inviteaddcredit']) { updatemembercount($uid, array($this->setting['inviteconfig']['inviterewardcredit'] => $this->setting['inviteconfig']['inviteaddcredit'])); } if ($this->setting['inviteconfig']['invitedaddcredit']) { updatemembercount($invite['uid'], array($this->setting['inviteconfig']['inviterewardcredit'] => $this->setting['inviteconfig']['invitedaddcredit'])); } require_once libfile('function/friend'); friend_make($invite['uid'], $invite['username'], false); notification_add($invite['uid'], 'friend', 'invite_friend', array('actor' => '<a href="home.php?mod=space&uid=' . $invite['uid'] . '" target="_blank">' . $invite['username'] . '</a>'), 1); space_merge($invite, 'field_home'); if (!empty($invite['privacy']['feed']['invite'])) { require_once libfile('function/feed'); $tite_data = array('username' => '<a href="home.php?mod=space&uid=' . $_G['uid'] . '">' . $_G['username'] . '</a>'); feed_add('friend', 'feed_invite', $tite_data, '', array(), '', array(), array(), '', '', '', 0, 0, '', $invite['uid'], $invite['username']); } if ($invite['appid']) { updatestat('appinvite'); } } if ($welcomemsg && !empty($welcomemsgtxt)) { $welcomemsgtitle = replacesitevar($welcomemsgtitle); $welcomemsgtxt = replacesitevar($welcomemsgtxt); if ($welcomemsg == 1) { $welcomemsgtxt = nl2br(str_replace(':', ':', $welcomemsgtxt)); notification_add($uid, 'system', $welcomemsgtxt, array('from_id' => 0, 'from_idtype' => 'welcomemsg'), 1); } elseif ($welcomemsg == 2) { sendmail_cron($email, $welcomemsgtitle, $welcomemsgtxt); } elseif ($welcomemsg == 3) { sendmail_cron($email, $welcomemsgtitle, $welcomemsgtxt); $welcomemsgtxt = nl2br(str_replace(':', ':', $welcomemsgtxt)); notification_add($uid, 'system', $welcomemsgtxt, array('from_id' => 0, 'from_idtype' => 'welcomemsg'), 1); } } if ($fromuid) { updatecreditbyaction('promotion_register', $fromuid); dsetcookie('promotion', ''); } dsetcookie('loginuser', ''); dsetcookie('activationauth', ''); dsetcookie('invite_auth', ''); $url_forward = dreferer(); $refreshtime = 3000; switch ($this->setting['regverify']) { case 1: $idstring = random(6); $authstr = $this->setting['regverify'] == 1 ? "{$_G['timestamp']}\t2\t{$idstring}" : ''; C::t('common_member_field_forum')->update($_G['uid'], array('authstr' => $authstr)); $verifyurl = "{$_G[siteurl]}member.php?mod=activate&uid={$_G[uid]}&id={$idstring}"; $email_verify_message = lang('email', 'email_verify_message', array('username' => $_G['member']['username'], 'bbname' => $this->setting['bbname'], 'siteurl' => $_G['siteurl'], 'url' => $verifyurl)); if (!sendmail("{$username} <{$email}>", lang('email', 'email_verify_subject'), $email_verify_message)) { runlog('sendmail', "{$email} sendmail failed."); } $message = 'register_email_verify'; $locationmessage = 'register_email_verify_location'; $refreshtime = 10000; break; case 2: $message = 'register_manual_verify'; $locationmessage = 'register_manual_verify_location'; break; default: $message = 'register_succeed'; $locationmessage = 'register_succeed_location'; break; } $param = array('bbname' => $this->setting['bbname'], 'username' => $_G['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['uid']); if (strpos($url_forward, $this->setting['regname']) !== false || strpos($url_forward, 'buyinvitecode') !== false) { $url_forward = 'forum.php'; } $href = str_replace("'", "\\'", $url_forward); $extra = array('showid' => 'succeedmessage', 'extrajs' => '<script type="text/javascript">' . 'setTimeout("window.location.href =\'' . $href . '\';", ' . $refreshtime . ');' . '$(\'succeedmessage_href\').href = \'' . $href . '\';' . '$(\'main_message\').style.display = \'none\';' . '$(\'main_succeed\').style.display = \'\';' . '$(\'succeedlocation\').innerHTML = \'' . lang('message', $locationmessage) . '\';' . '</script>', 'striptags' => false); showmessage($message, $url_forward, $param, $extra); } }
if ($_POST['to_signhtml'] && $_G['group']['maxsigsize']) { if ($_G['group']['maxsigsize'] < 200) { $signhtml = getstr($_POST['message'], $_G['group']['maxsigsize'], 0, 0, 1); $signhtml = preg_replace("/\\<br.*?\\>/i", ' ', $signhtml); } else { $signhtml = $message; } C::t('common_member_field_forum')->update($_G['uid'], array('sightml' => $signhtml)); } if (helper_access::check_module('feed') && ckprivacy('doing', 'feed') && $doing_status == '0') { $feedarr = array('appid' => '', 'icon' => 'doing', 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'title_template' => lang('feed', 'feed_doing_title'), 'title_data' => serialize(array('message' => $message)), 'body_template' => '', 'body_data' => '', 'id' => $newdoid, 'idtype' => 'doid'); C::t('home_feed')->insert($feedarr); } if ($doing_status == '1') { updatemoderate('doid', $newdoid); manage_addnotify('verifydoing'); } require_once libfile('function/stat'); updatestat('doing'); C::t('common_member_status')->update($_G['uid'], array('lastpost' => TIMESTAMP), 'UNBUFFERED'); if (!empty($_GET['fromcard'])) { showmessage($message . lang('spacecp', 'card_update_doing')); } else { showmessage('do_success', dreferer(), array('doid' => $newdoid), $_GET['spacenote'] ? array('showmsg' => false) : array('header' => true)); } } elseif (submitcheck('commentsubmit')) { if (!checkperm('allowdoing')) { showmessage('no_privilege_doing_comment'); } cknewuser(); $waittime = interval_check('post');
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)); } }
function addportalarticlecomment($id, $message, $idtype = 'aid') { global $_G; $id = intval($id); if (empty($id)) { return 'comment_comment_noexist'; } $message = getstr($message, $_G['group']['allowcommentarticle'], 1, 1, 1, 0); if (strlen($message) < 2) { return 'content_is_too_short'; } $idtype = in_array($idtype, array('aid', 'topicid')) ? $idtype : 'aid'; $tablename = $idtype == 'aid' ? 'portal_article_title' : 'portal_topic'; $data = DB::fetch_first("SELECT uid,allowcomment FROM " . DB::table($tablename) . " WHERE {$idtype}='{$id}'"); if (empty($data)) { return 'comment_comment_noexist'; } if ($data['allowcomment'] != 1) { return 'comment_comment_notallowed'; } $message = censor($message); if (censormod($message)) { $comment_status = 1; } else { $comment_status = 0; } $setarr = array('uid' => $_G['uid'], 'username' => $_G['username'], 'id' => $id, 'idtype' => $idtype, 'postip' => $_G['onlineip'], 'dateline' => $_G['timestamp'], 'status' => $comment_status, 'message' => $message); $pcid = DB::insert('portal_comment', $setarr, true); if ($comment_status == 1) { updatemoderate($idtype . '_cid', $pcid); $notifykey = $idtype == 'aid' ? 'verifyacommont' : 'verifytopiccommont'; manage_addnotify($notifykey); } $tablename = $idtype == 'aid' ? 'portal_article_count' : 'portal_topic'; DB::query("UPDATE " . DB::table($tablename) . " SET commentnum=commentnum+1 WHERE {$idtype}='{$id}'"); DB::update('common_member_status', array('lastpost' => $_G['timestamp']), array('uid' => $_G['uid'])); if ($data['uid'] != $_G['uid']) { updatecreditbyaction('portalcomment', 0, array(), $idtype . $id); } return 'do_success'; }
function register() { /*{{{*/ require_once dirname(dirname(dirname(__FILE__))) . '/bigappjson.class.php'; require_once libfile('function/misc'); require_once libfile('function/member'); require_once libfile('class/member'); $userName = isset($_REQUEST["username"]) ? $_REQUEST["username"] : ""; $password = isset($_REQUEST["password"]) ? $_REQUEST["password"] : ""; $email = isset($_REQUEST["email"]) ? strtolower($_REQUEST["email"]) : ""; global $_G; if (function_exists('iconv')) { $userName = iconv('UTF-8', CHARSET . '//ignore', $userName); } else { $userName = mb_convert_encoding($userName, CHARSET, 'UTF-8'); } if (empty($userName) || empty($password) || empty($email)) { echo BIGAPPJSON::encode(array('error_code' => 2, 'error_msg' => lang('plugin/bigapp', 'empty_params'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'empty_params')))); die(0); } $userNamelen = dstrlen($userName); if ($userNamelen < 3) { echo BIGAPPJSON::encode(array('error_code' => 3, 'error_msg' => lang('plugin/bigapp', 'username_short'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_short')))); die(0); } if ($userNamelen > 15) { echo BIGAPPJSON::encode(array('error_code' => 4, 'error_msg' => lang('plugin/bigapp', 'username_long'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_long')))); die(0); } $ctlObj = new register_ctl(); $ctlObj->setting = $_G['setting']; if (isset($ctlObj->setting['pwlength']) && $ctlObj->setting['pwlength']) { if (strlen($password) < $ctlObj->setting['pwlength']) { echo BIGAPPJSON::encode(array('error_code' => 5, 'error_msg' => lang('plugin/bigapp', 'password_length') . ' [ >= ' . $ctlObj->setting['pwlength'] . ' ]', 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'password_not_equal') . ' [ >= ' . $ctlObj->setting['pwlength'] . ' ]'))); die(0); } } if (isset($ctlObj->setting['strongpw']) && $ctlObj->setting['strongpw']) { $strongpw_str = array(); if (in_array(1, $ctlObj->setting['strongpw']) && !preg_match("/\\d+/", $password)) { $strongpw_str[] = lang('plugin/bigapp', 'password_number'); } if (in_array(2, $ctlObj->setting['strongpw']) && !preg_match("/[a-z]+/", $password)) { $strongpw_str[] = lang('plugin/bigapp', 'password_lowercase_char'); } if (in_array(3, $ctlObj->setting['strongpw']) && !preg_match("/[A-Z]+/", $password)) { $strongpw_str[] = lang('plugin/bigapp', 'password_uppercase_char'); } if (in_array(4, $ctlObj->setting['strongpw']) && !preg_match("/[^a-zA-Z0-9]+/", $password)) { $strongpw_str[] = lang('plugin/bigapp', 'password_charset'); } if ($strongpw_str) { echo BIGAPPJSON::encode(array('error_code' => 6, 'error_msg' => lang('plugin/bigapp', 'password_invalid') . ' [ ' . implode(', ', $strongpw_str) . ' ]', 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'password_invalid') . ' [ ' . implode(', ', $strongpw_str) . ' ]'))); die(0); } } /* if(!isset($_G['setting']['mobile']['mobileregister']) || !$_G['setting']['mobile']['mobileregister']){ echo BIGAPPJSON::encode(array('error_code' => 7, 'error_msg' => lang('plugin/bigapp', 'forbid_mobreg'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_mobreg')))); die(0); } */ loaducenter(); if (!$ctlObj->setting['regclosed'] && (!$ctlObj->setting['regstatus'] || !$ctlObj->setting['ucactivation'])) { if (!$ctlObj->setting['regstatus']) { echo BIGAPPJSON::encode(array('error_code' => 8, 'error_msg' => lang('plugin/bigapp', 'forbid_registration'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_registration')))); die(0); } } if ($ctlObj->setting['regverify']) { if ($ctlObj->setting['areaverifywhite']) { $location = $whitearea = ''; $location = trim(convertip($_G['clientip'], "./")); if ($location) { $whitearea = preg_quote(trim($ctlObj->setting['areaverifywhite']), '/'); $whitearea = str_replace(array("\\*"), array('.*'), $whitearea); $whitearea = '.*' . $whitearea . '.*'; $whitearea = '/^(' . str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea) . ')$/i'; if (@preg_match($whitearea, $location)) { $ctlObj->setting['regverify'] = 0; } } } if ($_G['cache']['ipctrl']['ipverifywhite']) { foreach (explode("\n", $_G['cache']['ipctrl']['ipverifywhite']) as $ctrlip) { if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) { $ctlObj->setting['regverify'] = 0; break; } } } } if ($ctlObj->setting['regverify']) { $groupinfo['groupid'] = 8; } else { $groupinfo['groupid'] = $ctlObj->setting['newusergroupid']; } if (!$password || $password != addslashes($password)) { echo BIGAPPJSON::encode(array('error_code' => 9, 'error_msg' => lang('plugin/bigapp', 'password_invalid_char'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'password_invalid_char')))); die(0); } $censorexp = '/^(' . str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote($ctlObj->setting['censoruser'] = trim($ctlObj->setting['censoruser']), '/')) . ')$/i'; if ($ctlObj->setting['censoruser'] && @preg_match($censorexp, $userName)) { echo BIGAPPJSON::encode(array('error_code' => 10, 'error_msg' => lang('plugin/bigapp', 'forbid_username'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_username')))); die(0); } if ($_G['cache']['ipctrl']['ipregctrl']) { foreach (explode("\n", $_G['cache']['ipctrl']['ipregctrl']) as $ctrlip) { if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) { $ctrlip = $ctrlip . '%'; $ctlObj->setting['regctrl'] = $ctlObj->setting['ipregctrltime']; break; } else { $ctrlip = $_G['clientip']; } } } else { $ctrlip = $_G['clientip']; } if ($ctlObj->setting['regctrl']) { if (C::t('common_regip')->count_by_ip_dateline($ctrlip, $_G['timestamp'] - $ctlObj->setting['regctrl'] * 3600)) { echo BIGAPPJSON::encode(array('error_code' => 11, 'error_msg' => lang('plugin/bigapp', 'forbid_ip'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_ip')))); die(0); } } $setregip = null; if ($ctlObj->setting['regfloodctrl']) { $regip = C::t('common_regip')->fetch_by_ip_dateline($_G['clientip'], $_G['timestamp'] - 86400); if ($regip) { if ($regip['count'] >= $ctlObj->setting['regfloodctrl']) { echo BIGAPPJSON::encode(array('error_code' => 12, 'error_msg' => lang('plugin/bigapp', 'forbid_ip_today'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_ip_today')))); die(0); } else { $setregip = 1; } } else { $setregip = 2; } } $uid = uc_user_register($userName, $password, $email, '', '', $_G['clientip']); if ($uid <= 0) { if ($uid == -1) { echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'username_invalid_char'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_invalid_char')))); } elseif ($uid == -2) { echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'username_invalid_char'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_invalid_char')))); } elseif ($uid == -3) { echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'username_used'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_used')))); } elseif ($uid == -4) { echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'invalid_email'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'invalid_email')))); } elseif ($uid == -5) { echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'invalid_email'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'invalid_email')))); } elseif ($uid == -6) { echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'email_used'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'email_used')))); } die(0); } $_G['username'] = $userName; $password = md5(random(10)); if ($setregip !== null) { if ($setregip == 1) { C::t('common_regip')->update_count_by_ip($_G['clientip']); } else { C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => 1, 'dateline' => $_G['timestamp'])); } } $profile = $verifyarr = array(); $emailstatus = 0; $init_arr = array('credits' => explode(',', $ctlObj->setting['initcredits']), 'profile' => $profile, 'emailstatus' => $emailstatus); C::t('common_member')->insert($uid, $userName, $password, $email, $_G['clientip'], $groupinfo['groupid'], $init_arr); if ($ctlObj->setting['regctrl'] || $ctlObj->setting['regfloodctrl']) { C::t('common_regip')->delete_by_dateline($_G['timestamp'] - ($ctlObj->setting['regctrl'] > 72 ? $ctlObj->setting['regctrl'] : 72) * 3600); if ($ctlObj->setting['regctrl']) { C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => -1, 'dateline' => $_G['timestamp'])); } } if ($ctlObj->setting['regverify'] == 1) { $idstring = random(6); $authstr = $ctlObj->setting['regverify'] == 1 ? "{$_G['timestamp']}\t2\t{$idstring}" : ''; C::t('common_member_field_forum')->update($uid, array('authstr' => $authstr)); $verifyurl = "{$_G[siteurl]}member.php?mod=activate&uid={$uid}&id={$idstring}"; $email_verify_message = lang('email', 'email_verify_message', array('username' => $username, 'bbname' => $ctlObj->setting['bbname'], 'siteurl' => $_G['siteurl'], 'url' => $verifyurl)); if (!sendmail("{$username} <{$email}>", lang('email', 'email_verify_subject'), $email_verify_message)) { runlog('sendmail', "{$email} sendmail failed."); } } require_once libfile('cache/userstats', 'function'); build_cache_userstats(); $_GET['regmessage'] = 'from bigapp client'; $regmessage = dhtmlspecialchars($_GET['regmessage']); if ($ctlObj->setting['regverify'] == 2) { C::t('common_member_validate')->insert(array('uid' => $uid, 'submitdate' => $_G['timestamp'], 'moddate' => 0, 'admin' => '', 'submittimes' => 1, 'status' => 0, 'message' => $regmessage, 'remark' => ''), false, true); manage_addnotify('verifyuser'); } setloginstatus(array('uid' => $uid, 'username' => $_G['username'], 'password' => $password, 'groupid' => $groupinfo['groupid']), 0); include_once libfile('function/stat'); updatestat('register'); checkfollowfeed(); C::t('common_member_status')->update($_G['uid'], array('lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP)); //////////////////////////////////////////////// // 注册成功,绑定第三方openid $plat = $_GET["platform"]; if ($plat == "qq") { include_once CUR_PATH . "/../qqconnect/bind.php"; } else { if ($plat == "wechat") { include_once CUR_PATH . "/../wechatconnect/bind.php"; } } //////////////////////////////////////////////// echo BIGAPPJSON::encode(array('error_code' => 0, 'error_msg' => lang('plugin/bigapp', 'regist_succ'), 'Message' => array('messageval' => 'register_succeed', 'messagestr' => lang('plugin/bigapp', 'regist_succ')), 'Variables' => array('auth' => 'in order to be comapatible'))); die(0); }
function threadpubsave($tid, $passapproval = false) { global $_G; if ($_G['setting']['plugins']['func'][HOOKTYPE]['threadpubsave']) { $hookparam = func_get_args(); hookscript('threadpubsave', 'global', 'funcs', array('param' => $hookparam, 'step' => 'check'), 'threadpubsave'); } $thread = C::t('forum_thread')->fetch_by_tid_displayorder($tid, -4, '=', !$passapproval ? $_G['uid'] : null); if (!$thread) { return 0; } $threadpost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($tid); $thread['message'] = $threadpost['message']; $modworksql = 0; $displayorder = 0; $dateline = $_G['timestamp']; $moderatepids = $saveposts = array(); $return = 1; list($modnewthreads) = threadmodstatus($thread['subject'] . "\t" . $thread['message']); if ($modnewthreads && $passapproval === false) { updatemoderate('tid', $tid); manage_addnotify('verifythread'); $displayorder = -2; $modworksql = 1; $return = -1; } else { C::t('forum_post')->update_by_tid('tid:' . $tid, $tid, array('dateline' => $dateline, 'invisible' => '0'), false, false, 1); } C::t('forum_thread')->update($tid, array('displayorder' => $displayorder, 'dateline' => $_G['timestamp'], 'lastpost' => $_G['timestamp'])); $posts = $thread['replies'] + 1; if ($thread['replies']) { $saveposts = C::t('forum_post')->fetch_all_by_tid('tid:' . $tid, $tid, true, '', 0, 0, 0); foreach ($saveposts as $post) { $dateline++; $invisible = 0; list(, $modnewreplies) = threadmodstatus($post['subject'] . "\t" . $post['message']); if ($modnewreplies) { $moderatepids[] = $post['pid']; $verifypost = true; $invisible = -2; $modworksql = 1; $return = -2; } C::t('forum_post')->update('tid:' . $tid, $post['pid'], array('dateline' => $dateline, 'invisible' => $invisible)); updatepostcredits('+', $thread['authorid'], 'reply', $thread['fid']); } } if ($moderatepids) { updatemoderate('pid', $moderatepids); manage_addnotify('verifypost'); } updatepostcredits('+', $thread['authorid'], 'post', $thread['fid']); $attachcount = C::t('forum_attachment_n')->count_by_id('tid:' . $thread['tid'], 'tid', $thread['tid']); updatecreditbyaction('postattach', $thread['authorid'], array(), '', $attachcount, 1, $thread['fid']); if ($_G['forum']['status'] == 3) { C::t('forum_groupuser')->update_counter_for_user($thread['authorid'], $thread['fid'], 1); } $subject = str_replace("\t", ' ', $thread['subject']); $lastpost = $thread['tid'] . "\t" . $subject . "\t" . $thread['lastpost'] . "\t" . $thread['lastposter']; C::t('forum_forum')->update($_G['fid'], array('lastpost' => $lastpost)); C::t('forum_forum')->update_forum_counter($thread['fid'], 1, $posts, $posts, $modworksql); if ($_G['forum']['type'] == 'sub') { C::t('forum_forum')->update($_G['forum']['fup'], array('lastpost' => $lastpost)); } if ($_G['setting']['plugins']['func'][HOOKTYPE]['threadpubsave']) { hookscript('threadpubsave', 'global', 'funcs', array('param' => $hookparam, 'step' => 'save', 'posts' => $saveposts), 'threadpubsave'); } return $return; }
updatemembercount($_G['uid'], array($medal['credit'] => -$medal['price']), true, 'BME', $medal['medalid']); } $memberfieldforum = C::t('common_member_field_forum')->fetch($_G['uid']); $usermedal = $memberfieldforum; unset($memberfieldforum); $medal['medalid'] = $medal['medalid'] . (empty($expiration) ? '' : '|' . $expiration); $medalnew = $usermedal['medals'] ? $usermedal['medals'] . "\t" . $medal['medalid'] : $medal['medalid']; C::t('common_member_field_forum')->update($_G['uid'], array('medals' => $medalnew)); C::t('common_member_medal')->insert(array('uid' => $_G['uid'], 'medalid' => $medal['medalid']), 0, 1); $medalmessage = 'medal_get_succeed'; } else { if (C::t('forum_medallog')->count_by_verify_medalid($_G['uid'], $medal['medalid'])) { showmessage('medal_apply_existence', 'home.php?mod=medal'); } $medalmessage = 'medal_apply_succeed'; manage_addnotify('verifymedal'); } C::t('forum_medallog')->insert(array('uid' => $_G['uid'], 'medalid' => $medalid, 'type' => $medal['type'], 'dateline' => TIMESTAMP, 'expiration' => $expiration, 'status' => $expiration ? 1 : 0)); showmessage($medalmessage, 'home.php?mod=medal', array('medalname' => $medal['name'])); } } elseif ($_GET['action'] == 'log') { include libfile('function/forum'); foreach (C::t('forum_medal')->fetch_all_data(1) as $medal) { $medallist[$medal['medalid']] = $medal; } $memberfieldforum = C::t('common_member_field_forum')->fetch($_G['uid']); $membermedal = $memberfieldforum['medals'] ? explode("\t", $memberfieldforum['medals']) : array(); foreach ($membermedal as $k => $medal) { if (!in_array($medal, array_keys($medallist))) { unset($membermedal[$k]); }
showmessage('no_privilege_pic_edit', 'home.php?mod=space&uid=' . $_G['uid'] . '&do=album&view=me', array(), array('return' => true)); } } else { $album['uid'] = $_G['uid']; } if (submitcheck('editpicsubmit')) { $return = true; foreach ($_POST['title'] as $picid => $value) { if ($value == $_GET['oldtitle'][$picid]) { continue; } $title = getstr($value, 150); $title = censor($title); if (censormod($title) || $_G['group']['allowuploadmod']) { $pic_status = 1; manage_addnotify('verifypic'); } else { $pic_status = 0; } $wherearr = array('picid' => $picid); if (!$managealbum) { $wherearr['uid'] = $_G['uid']; } C::t('home_pic')->update($picid, array('title' => $title, 'status' => $pic_status)); } if ($_GET['subop'] == 'delete') { if ($_POST['ids']) { require_once libfile('function/delete'); deletepics($_POST['ids']); if ($albumid > 0) { $return = album_update_pic($albumid);
private function _adminTopic($fid, $tid, $pid, $act, $type) { global $_G; $errorMsg = ''; $_GET['topiclist'] = array($_GET['pid']); // 在DISCUZ_ROOT/source/module/forum/forum_topicadmin.php基础上进行二次开发 $_GET['topiclist'] = !empty($_GET['topiclist']) ? is_array($_GET['topiclist']) ? array_unique($_GET['topiclist']) : $_GET['topiclist'] : array(); loadcache(array('modreasons', 'stamptypeid', 'threadtableids')); require_once libfile('function/post'); require_once libfile('function/misc'); $modpostsnum = 0; $resultarray = $thread = array(); if ($_G['group']['reasonpm'] == 2 || $_G['group']['reasonpm'] == 3 || !empty($_GET['sendreasonpm'])) { $forumname = strip_tags($_G['forum']['name']); $sendreasonpm = 1; } else { $sendreasonpm = 0; } if ($type == 'topic') { if ($act == 'band') { $resultarray = $this->_topicAdmin_band($fid, $tid, $pid, $act, $type, array('sendreasonpm' => $sendreasonpm, 'thread' => $_G['forum_thread'])); } else { // 在DISCUZ_ROOT/source/include/topicadmin/topicadmin_moderate.php基础上进行二次开发 $thread = $_G['forum_thread']; $thread['dblastpost'] = $thread['lastpost']; $threadlist[$thread['tid']] = $thread; $modpostsnum = count($threadlist); $stickcheck = $closecheck = $digestcheck = array('', '', '', '', ''); empty($threadlist[$_G['tid']]['displayorder']) ? $stickcheck[0] = 'selected="selected"' : ($stickcheck[$threadlist[$_G['tid']]['displayorder']] = 'selected="selected"'); empty($threadlist[$_G['tid']]['digest']) ? $digestcheck[0] = 'selected="selected"' : ($digestcheck[$threadlist[$_G['tid']]['digest']] = 'selected="selected"'); empty($threadlist[$_G['tid']]['closed']) ? $closecheck[0] = 'checked="checked"' : ($closecheck[1] = 'checked="checked"'); if (!empty($_POST)) { $tidsarr = array_keys($threadlist); $moderatetids = dimplode($tidsarr); $reason = checkreasonpm(); $stampstatus = 0; $stampaction = 'SPA'; $operationMap = array('top' => 'stick', 'marrow' => 'digest', 'delete' => 'delete'); $operation = $operationMap[$act]; $updatemodlog = TRUE; switch ($act) { case 'top': $sticklevel = intval($_GET['sticklevel']); if ($sticklevel < 0 || $sticklevel > 3 || $sticklevel > $_G['group']['allowstickthread']) { // showmessage('no_privilege_stickthread'); $this->_exitWithHtmlAlert('no_privilege_stickthread'); } $expiration = checkexpiration($_GET['expirationstick'], $operation); $expirationstick = $sticklevel ? $_GET['expirationstick'] : 0; $forumstickthreads = $_G['setting']['forumstickthreads']; $forumstickthreads = isset($forumstickthreads) ? dunserialize($forumstickthreads) : array(); C::t('forum_thread')->update($tidsarr, array('displayorder' => $sticklevel, 'moderated' => 1), true); $delkeys = array_keys($threadlist); foreach ($delkeys as $k) { unset($forumstickthreads[$k]); } C::t('common_setting')->update('forumstickthreads', $forumstickthreads); $stickmodify = 0; foreach ($threadlist as $thread) { $stickmodify = (in_array($thread['displayorder'], array(2, 3)) || in_array($sticklevel, array(2, 3))) && $sticklevel != $thread['displayorder'] ? 1 : $stickmodify; } if ($_G['setting']['globalstick'] && $stickmodify) { require_once libfile('function/cache'); updatecache('globalstick'); } $modaction = $sticklevel ? $expiration ? 'EST' : 'STK' : 'UST'; C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('STK', 'UST', 'EST', 'UES'), array('status' => 0)); if (!$sticklevel) { $stampaction = 'SPD'; } $stampstatus = 1; break; case 'marrow': $digestlevel = intval($_GET['digestlevel']); if ($digestlevel < 0 || $digestlevel > 3 || $digestlevel > $_G['group']['allowdigestthread']) { // showmessage('no_privilege_digestthread'); $this->_exitWithHtmlAlert('no_privilege_digestthread'); } $expiration = checkexpiration($_GET['expirationdigest'], $operation); $expirationdigest = $digestlevel ? $expirationdigest : 0; C::t('forum_thread')->update($tidsarr, array('digest' => $digestlevel, 'moderated' => 1), true); foreach ($threadlist as $thread) { if ($thread['digest'] != $digestlevel) { if ($digestlevel == $thread['digest']) { continue; } $extsql = array(); if ($digestlevel > 0 && $thread['digest'] == 0) { $extsql = array('digestposts' => 1); } if ($digestlevel == 0 && $thread['digest'] > 0) { $extsql = array('digestposts' => -1); } if ($digestlevel == 0) { $stampaction = 'SPD'; } updatecreditbyaction('digest', $thread['authorid'], $extsql, '', $digestlevel - $thread['digest']); } } $modaction = $digestlevel ? $expiration ? 'EDI' : 'DIG' : 'UDG'; C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('DIG', 'UDI', 'EDI', 'UED'), array('status' => 0)); $stampstatus = 2; break; case 'delete': if (!$_G['group']['allowdelpost']) { // showmessage('no_privilege_delpost'); $this->_exitWithHtmlAlert('no_privilege_delpost'); } loadcache('threadtableids'); $stickmodify = 0; $deleteredirect = $remarkclosed = array(); foreach ($threadlist as $thread) { if ($thread['digest']) { updatecreditbyaction('digest', $thread['authorid'], array('digestposts' => -1), '', -$thread['digest']); } if (in_array($thread['displayorder'], array(2, 3))) { $stickmodify = 1; } if ($_G['forum']['status'] == 3 && $thread['closed'] > 1) { $deleteredirect[] = $thread['closed']; } if ($thread['isgroup'] == 1 && $thread['closed'] > 1) { $remarkclosed[] = $thread['closed']; } } $modaction = 'DEL'; require_once libfile('function/delete'); $tids = array_keys($threadlist); if ($_G['forum']['recyclebin']) { deletethread($tids, true, true, true); manage_addnotify('verifyrecycle', $modpostsnum); } else { deletethread($tids, true, true); $updatemodlog = FALSE; } $forumstickthreads = $_G['setting']['forumstickthreads']; $forumstickthreads = !empty($forumstickthreads) ? dunserialize($forumstickthreads) : array(); $delkeys = array_keys($threadlist); foreach ($delkeys as $k) { unset($forumstickthreads[$k]); } C::t('common_setting')->update('forumstickthreads', $forumstickthreads); C::t('forum_forum_threadtable')->delete_none_threads(); if (!empty($deleteredirect)) { deletethread($deleteredirect); } if (!empty($remarkclosed)) { C::t('forum_thread')->update($remarkclosed, array('closed' => 0)); } if ($_G['setting']['globalstick'] && $stickmodify) { require_once libfile('function/cache'); updatecache('globalstick'); } updateforumcount($_G['fid']); if ($_GET['crimerecord']) { include_once libfile('function/member'); foreach ($threadlist as $thread) { crime('recordaction', $thread['authorid'], 'crime_delpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $thread['tid'], 'pid' => 0))); } } break; case 'close': if (!$_G['group']['allowclosethread']) { $this->_exitWithHtmlAlert('no_privilege_closethread'); } $expiration = checkexpiration($_GET['expirationclose'], $operation); $modaction = $expiration ? 'ECL' : 'CLS'; C::t('forum_thread')->update($tidsarr, array('closed' => 1, 'moderated' => 1), true); C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('CLS', 'OPN', 'ECL', 'UCL', 'EOP', 'UEO'), array('status' => 0)); break; case 'open': if (!$_G['group']['allowclosethread']) { $this->_exitWithHtmlAlert('no_privilege_openthread'); } $expiration = checkexpiration($_GET['expirationclose'], $operation); $modaction = $expiration ? 'EOP' : 'OPN'; C::t('forum_thread')->update($tidsarr, array('closed' => 0, 'moderated' => 1), true); C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('CLS', 'OPN', 'ECL', 'UCL', 'EOP', 'UEO'), array('status' => 0)); break; case 'move': if (!$_G['group']['allowmovethread']) { $this->_exitWithHtmlAlert('no_privilege_movethread'); } $moveto = $_GET['moveto']; $toforum = C::t('forum_forum')->fetch_info_by_fid($moveto); if (!$toforum || $_G['adminid'] != 1 && $toforum['status'] != 1 || $toforum['type'] == 'group') { // showmessage('admin_move_invalid'); $this->_exitWithHtmlAlert('admin_move_invalid'); } elseif ($_G['fid'] == $toforum['fid']) { continue; } else { $moveto = $toforum['fid']; $modnewthreads = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 1) && $toforum['modnewposts'] ? 1 : 0; $modnewreplies = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 2) && $toforum['modnewposts'] ? 1 : 0; if ($modnewthreads || $modnewreplies) { // showmessage('admin_move_have_mod'); $this->_exitWithHtmlAlert('admin_move_have_mod'); } } if ($_G['adminid'] == 3) { $priv = C::t('forum_forumfield')->check_moderator_for_uid($moveto, $_G['uid'], $_G['member']['accessmasks']); if (($priv['postperm'] && !in_array($_G['groupid'], explode("\t", $priv['postperm'])) || $_G['member']['accessmasks'] && ($priv['allowview'] || $priv['allowreply'] || $priv['allowgetattach'] || $priv['allowpostattach']) && !$priv['allowpost']) && !$priv['istargetmod']) { // showmessage('admin_move_nopermission'); $this->_exitWithHtmlAlert('admin_move_nopermission'); } } $moderate = array(); $stickmodify = 0; $toforumallowspecial = array(1 => $toforum['allowpostspecial'] & 1, 2 => $toforum['allowpostspecial'] & 2, 3 => isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]) && $toforum['allowpostspecial'] & 4, 4 => $toforum['allowpostspecial'] & 8, 5 => $toforum['allowpostspecial'] & 16, 127 => $_G['setting']['threadplugins'] ? dunserialize($toforum['threadplugin']) : array()); foreach ($threadlist as $tid => $thread) { $allowmove = 0; if (!$thread['special']) { $allowmove = 1; } else { if ($thread['special'] != 127) { $allowmove = $toforum['allowpostspecial'] ? $toforumallowspecial[$thread['special']] : 0; } else { if ($toforumallowspecial[127]) { $posttable = getposttablebytid($thread['tid']); $message = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']); $message = $message['message']; $sppos = strrpos($message, chr(0) . chr(0) . chr(0)); $specialextra = substr($message, $sppos + 3); $allowmove = in_array($specialextra, $toforumallowspecial[127]); } else { $allowmove = 0; } } } if ($allowmove) { $moderate[] = $tid; if (in_array($thread['displayorder'], array(2, 3))) { $stickmodify = 1; } if ($_GET['appbyme_movetype'] == 'redirect') { // if($_GET['type'] == 'redirect') { $insertdata = array('fid' => $thread['fid'], 'readperm' => $thread['readperm'], 'author' => $thread['author'], 'authorid' => $thread['authorid'], 'subject' => $thread['subject'], 'dateline' => $thread['dateline'], 'lastpost' => $thread['dblastpost'], 'lastposter' => $thread['lastposter'], 'views' => 0, 'replies' => 0, 'displayorder' => 0, 'digest' => 0, 'closed' => $thread['tid'], 'special' => 0, 'attachment' => 0, 'typeid' => $_GET['threadtypeid']); $newtid = C::t('forum_thread')->insert($insertdata, true); if ($newtid) { C::t('forum_threadclosed')->insert(array('tid' => $thread['tid'], 'redirect' => $newtid), true, true); } } } } if (!($moderatetids = implode(',', $moderate))) { showmessage('admin_moderate_invalid'); } $fieldarr = array('fid' => $moveto, 'isgroup' => 0, 'typeid' => $_GET['threadtypeid'], 'moderated' => 1); if ($_G['adminid'] == 3) { $fieldarr['displayorder'] = 0; } C::t('forum_thread')->update($tidsarr, $fieldarr, true); C::t('forum_forumrecommend')->update($tidsarr, array('fid' => $moveto)); loadcache('posttableids'); $posttableids = $_G['cache']['posttableids'] ? $_G['cache']['posttableids'] : array('0'); foreach ($posttableids as $id) { C::t('forum_post')->update_by_tid($id, $tidsarr, array('fid' => $moveto)); } $typeoptionvars = C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tidsarr); foreach ($typeoptionvars as $typeoptionvar) { C::t('forum_typeoptionvar')->update_by_tid($typeoptionvar['tid'], array('fid' => $moveto)); C::t('forum_optionvalue')->update($typeoptionvar['sortid'], $typeoptionvar['tid'], $_G['fid'], "fid='{$moveto}'"); } if ($_G['setting']['globalstick'] && $stickmodify) { require_once libfile('function/cache'); updatecache('globalstick'); } $modaction = 'MOV'; $_G['toforum'] = $toforum; updateforumcount($moveto); updateforumcount($_G['fid']); break; default: $errorMsg = '错误的动作参数'; break; } if ($errorMsg == '') { if ($updatemodlog) { if ($operation != 'delete') { updatemodlog($moderatetids, $modaction, $expiration); } else { updatemodlog($moderatetids, $modaction, $expiration, 0, $reason); } } updatemodworks($modaction, $modpostsnum); foreach ($threadlist as $thread) { modlog($thread, $modaction); } if ($sendreasonpm) { $modactioncode = lang('forum/modaction'); $modtype = $modaction; $modaction = $modactioncode[$modaction]; foreach ($threadlist as $thread) { if ($operation == 'move') { sendreasonpm($thread, 'reason_move', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'tofid' => $toforum['fid'], 'toname' => $toforum['name'], 'from_id' => 0, 'from_idtype' => 'movethread')); } else { sendreasonpm($thread, 'reason_moderate', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'from_id' => 0, 'from_idtype' => 'moderate_' . $modtype)); } } } if ($stampstatus) { set_stamp($stampstatus, $stampaction, $threadlist, $expiration); } $this->getController()->redirect(WebUtils::createUrl_oldVersion('index/returnmobileview')); } } else { if ($act == 'move') { require_once libfile('function/forumlist'); $forumselect = forumselect(FALSE, 0, $threadlist[$_G['tid']]['fid'], $_G['adminid'] == 1 ? TRUE : FALSE); } } } } else { if ($type == 'post') { if ($act == 'band') { $resultarray = $this->_topicAdmin_band($fid, $tid, $pid, $act, $type, array('sendreasonpm' => $sendreasonpm, 'thread' => $_G['forum_thread'])); } else { // 在DISCUZ_ROOT/source/include/topicadmin/topicadmin_delpost.php基础上进行二次开发 $resultarray = array(); $thread = $_G['forum_thread']; $topiclist = array($pid); $modpostsnum = 1; $pids = $posts = $authors = array(); $posttable = getposttablebytid($_G['tid']); foreach (C::t('forum_post')->fetch_all('tid:' . $_G['tid'], $topiclist, false) as $post) { if ($post['tid'] != $_G['tid']) { continue; } if ($post['first'] == 1) { dheader("location: {$_G['siteurl']}forum.php?mod=topicadmin&action=moderate&operation=delete&optgroup=3&fid={$_G['fid']}&moderate[]={$thread['tid']}&inajax=yes" . ($_GET['infloat'] ? "&infloat=yes&handlekey={$_GET['handlekey']}" : '')); } else { $authors[$post['authorid']] = 1; $pids[] = $post['pid']; $posts[] = $post; } } if (!empty($_POST)) { $reason = checkreasonpm(); $uidarray = $puidarray = $auidarray = array(); $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0; if ($pids) { require_once libfile('function/delete'); if ($_G['forum']['recyclebin']) { deletepost($pids, 'pid', true, false, true); manage_addnotify('verifyrecyclepost', $modpostsnum); } else { $logs = array(); $ratelog = C::t('forum_ratelog')->fetch_all_by_pid($pids); $rposts = C::t('forum_post')->fetch_all('tid:' . $_G['tid'], $pids, false); foreach (C::t('forum_ratelog')->fetch_all_by_pid($pids) as $rpid => $author) { if ($author['score'] > 0) { $rpost = $rposts[$rpid]; updatemembercount($rpost['authorid'], array($author['extcredits'] => -$author['score'])); $author['score'] = $_G['setting']['extcredits'][$id]['title'] . ' ' . -$author['score'] . ' ' . $_G['setting']['extcredits'][$id]['unit']; $logs[] = dhtmlspecialchars("{$_G['timestamp']}\t{$_G[member][username]}\t{$_G['adminid']}\t{$rpost['author']}\t{$author['extcredits']}\t{$author['score']}\t{$thread['tid']}\t{$thread['subject']}\t{$delpostsubmit}"); } } if (!empty($logs)) { writelog('ratelog', $logs); unset($logs); } deletepost($pids, 'pid', true); } if ($_GET['crimerecord']) { include_once libfile('function/member'); foreach ($posts as $post) { crime('recordaction', $post['authorid'], 'crime_delpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $post['tid'], 'pid' => $post['pid']))); } } } updatethreadcount($_G['tid'], 1); updateforumcount($_G['fid']); $_G['forum']['threadcaches'] && deletethreadcaches($thread['tid']); $modaction = 'DLP'; $resultarray = array('redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page={$_GET['page']}", 'reasonpm' => $sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_delete_post', 'notictype' => 'post') : array(), 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason), 'modtids' => 0, 'modlog' => $thread); } } } } // 在DISCUZ_ROOT/source/module/forum/forum_topicadmin.php基础上进行二次开发 if ($resultarray) { if ($resultarray['modtids']) { updatemodlog($resultarray['modtids'], $modaction, $resultarray['expiration']); } updatemodworks($modaction, $modpostsnum); if (is_array($resultarray['modlog'])) { if (isset($resultarray['modlog']['tid'])) { modlog($resultarray['modlog'], $modaction); } else { foreach ($resultarray['modlog'] as $thread) { modlog($thread, $modaction); } } } if ($resultarray['reasonpm']) { $modactioncode = lang('forum/modaction'); $modaction = $modactioncode[$modaction]; foreach ($resultarray['reasonpm']['data'] as $var) { sendreasonpm($var, $resultarray['reasonpm']['item'], $resultarray['reasonvar'], $resultarray['reasonpm']['notictype']); } } // showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'), $resultarray['redirect']); $this->getController()->redirect(WebUtils::createUrl_oldVersion('index/returnmobileview')); } $this->getController()->renderPartial('topicAdmin', array('formUrl' => WebUtils::createUrl_oldVersion('forum/topicadminview', array('fid' => $fid, 'tid' => $tid, 'pid' => $pid, 'act' => $act, 'type' => $type)), 'errorMsg' => $errorMsg, 'action' => $act, '_G' => $_G, 'stickcheck' => $stickcheck, 'digestcheck' => $digestcheck, 'closecheck' => $closecheck, 'forumselect' => WebUtils::u($forumselect))); }
} foreach ($dbcontents as $key => $value) { C::t('portal_article_content')->update($value['cid'], array('title' => $pagetitle[$key], 'content' => $contents[$key], 'pageorder' => $key + 1)); unset($pagetitle[$key], $contents[$key]); } if ($cdbcount < $cpostcount) { foreach ($contents as $key => $value) { C::t('portal_article_content')->insert(array('aid' => $aid, 'id' => $setarr['id'], 'idtype' => $setarr['idtype'], 'title' => $pagetitle[$key], 'content' => $contents[$key], 'pageorder' => $key + 1, 'dateline' => TIMESTAMP)); } $pagecount = $cpostcount; } $updatearticle = array('contents' => $pagecount); if ($article_status == 1) { $updatearticle['status'] = 1; updatemoderate('aid', $aid); manage_addnotify('verifyarticle'); } $updatearticle = array_merge($updatearticle, portalcp_article_pre_next($catid, $aid)); C::t('portal_article_title')->update($aid, $updatearticle); $newaids = array(); $_POST['attach_ids'] = explode(',', $_POST['attach_ids']); foreach ($_POST['attach_ids'] as $newaid) { $newaid = intval($newaid); if ($newaid) { $newaids[$newaid] = $newaid; } } if ($newaids) { C::t('portal_attachment')->update_to_used($newaids, $aid); } addrelatedarticle($aid, $_POST['raids']);
} $param = array('fid' => $_G['fid'], 'tid' => $tid, 'pid' => $pid); $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]); dsetcookie('clearUserdata', 'forum'); if ($specialextra) { $classname = 'threadplugin_' . $specialextra; if (class_exists($classname) && method_exists($threadpluginclass = new $classname(), 'newthread_submit_end')) { $threadpluginclass->newthread_submit_end($_G['fid'], $tid); } } if ($modnewthreads) { updatemoderate('tid', $tid); DB::query("UPDATE " . DB::table('forum_forum') . " SET todayposts=todayposts+1 WHERE fid='{$_G['fid']}'", 'UNBUFFERED'); manage_addnotify('verifythread'); showmessage('post_newthread_mod_succeed', "forum.php?mod=viewthread&tid={$tid}&extra={$extra}", $param); } else { $feed = array('icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data' => array(), 'images' => array()); if (!empty($_G['gp_addfeed']) && $_G['forum']['allowfeed'] && !$isanonymous) { $message = !($price || $readperm) ? $message : ''; if ($special == 0) { $feed['icon'] = 'thread'; $feed['title_template'] = 'feed_thread_title'; $feed['body_template'] = 'feed_thread_message'; $feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$tid}\">{$subject}</a>", 'message' => messagecutstr($message, 150)); if (!empty($_G['forum_attachexist'])) { $firstaid = DB::result_first("SELECT aid FROM " . DB::table(getattachtablebytid($tid)) . " WHERE pid='{$pid}' AND dateline>'0' AND isimage='1' ORDER BY dateline LIMIT 1"); if ($firstaid) { $feed['images'] = array(getforumimg($firstaid)); $feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}");
if (isset($_POST['birthyear']) && $space['birthyear'] != $_POST['birthyear']) { $setarr['zodiac'] = get_zodiac($_POST['birthyear']); } if ($setarr) { DB::update('common_member_profile', $setarr, array('uid' => $_G['uid'])); } if ($verifyarr) { DB::query('DELETE FROM ' . DB::table('common_member_verify_info') . " WHERE uid='{$_G['uid']}' AND verifytype='{$vid}'"); $setverify = array('uid' => $_G['uid'], 'username' => $_G['username'], 'verifytype' => $vid, 'field' => daddslashes(serialize($verifyarr)), 'dateline' => $_G['timestamp']); DB::insert('common_member_verify_info', $setverify); $count = DB::result(DB::query("SELECT COUNT(*) FROM " . DB::table('common_member_verify') . " WHERE uid='{$_G['uid']}'"), 0); if (!$count) { DB::insert('common_member_verify', array('uid' => $_G['uid'])); } if ($_G['setting']['verify'][$vid]['available']) { manage_addnotify('verify_' . $vid, 0, array('langkey' => 'manage_verify_field', 'verifyname' => $_G['setting']['verify'][$vid]['title'], 'doid' => $vid)); } } if (isset($_POST['privacy'])) { foreach ($_POST['privacy'] as $key => $value) { if (isset($_G['cache']['profilesetting'][$key])) { $space['privacy']['profile'][$key] = intval($value); } } DB::update('common_member_field_home', array('privacy' => addslashes(serialize($space['privacy']))), array('uid' => $space['uid'])); } manyoulog('user', $_G['uid'], 'update'); include_once libfile('function/feed'); feed_add('profile', 'feed_profile_update_' . $operation, array('hash_data' => 'profile')); countprofileprogress(); $message = $vid ? lang('spacecp', 'profile_verify_verifying', array('verify' => $verifyconfig['title'])) : '';
function pick_blog_post($POST, $olds = array()) { global $_G, $space; $__G = $_G; $_G['uid'] = $POST['uid']; $_G['username'] = addslashes($POST['username']); $POST['subject'] = getstr(trim($POST['subject']), 80, 1, 1); //$POST['subject'] = addslashes($POST['subject']); if (strlen($POST['subject']) < 1) { $POST['subject'] = dgmdate($POST['public_time'], 'Y-m-d'); } $POST['friend'] = intval($POST['friend']); $POST['target_ids'] = ''; if ($POST['friend'] == 2) { $uids = array(); $names = empty($_GET['target_names']) ? array() : explode(',', preg_replace("/(\\s+)/s", ',', $_GET['target_names'])); if ($names) { $query = DB::query("SELECT uid FROM " . DB::table('common_member') . " WHERE username IN (" . dimplode($names) . ")"); while ($value = DB::fetch($query)) { $uids[] = $value['uid']; } } if (empty($uids)) { $POST['friend'] = 3; } else { $POST['target_ids'] = implode(',', $uids); } } elseif ($POST['friend'] == 4) { $POST['password'] = trim($POST['password']); if ($POST['password'] == '') { $POST['friend'] = 0; } } if ($POST['friend'] !== 2) { $POST['target_ids'] = ''; } if ($POST['friend'] !== 4) { $POST['password'] == ''; } $POST['tag'] = dhtmlspecialchars(trim($POST['article_tag'])); $POST['tag'] = getstr($POST['tag'], 500, 1, 1); $POST['tag'] = censor($POST['tag']); if ($_G['mobile']) { $POST['message'] = getstr($POST['message'], 0, 1, 0, 1); $POST['message'] = censor($POST['message']); } else { $POST['message'] = checkhtml($POST['message']); $POST['message'] = getstr($POST['message'], 0, 1, 0, 0, 1); //$POST['message'] = addslashes($POST['message']); $POST['message'] = preg_replace(array("/\\<div\\>\\<\\/div\\>/i", "/\\<a\\s+href\\=\"([^\\>]+?)\"\\>/i"), array('', '<a href="\\1" target="_blank">'), $POST['message']); } $message = $POST['message']; $blog_status = 0; if ($olds['blog_id']) { $info = DB::fetch_first("SELECT blogid FROM " . DB::table('home_blog') . " WHERE blogid='" . $olds['blog_id'] . "'"); } if (empty($olds['classid']) || $POST['classid'] != $olds['classid']) { if (!empty($POST['classid']) && substr($POST['classid'], 0, 4) == 'new:') { $classname = dhtmlspecialchars(trim(substr($POST['classid'], 4))); $classname = getstr($classname, 0, 1, 1); $classname = censor($classname); if (empty($classname)) { $classid = 0; } else { $classid = DB::result(DB::query("SELECT classid FROM " . DB::table('home_class') . " WHERE uid='{$_G['uid']}' AND classname='{$classname}'")); if (empty($classid)) { $setarr = array('classname' => $classname, 'uid' => $_G['uid'], 'dateline' => $_G['timestamp']); $classid = DB::insert('home_class', $setarr, 1); } } } else { $classid = intval($POST['classid']); } } else { $classid = $olds['classid']; } if ($classid && empty($classname)) { $classname = DB::result(DB::query("SELECT classname FROM " . DB::table('home_class') . " WHERE classid='{$classid}' AND uid='{$_G['uid']}'")); if (empty($classname)) { $classid = 0; } } $blogarr = array('subject' => $POST['subject'], 'classid' => $classid, 'viewnum' => $POST['view_num'], 'friend' => $POST['friend'], 'password' => $POST['password'], 'noreply' => empty($POST['noreply']) ? 0 : 1, 'catid' => intval($POST['catid']), 'status' => $blog_status); $titlepic = ''; $ckmessage = preg_replace("/(\\<div\\>|\\<\\/div\\>|\\s|\\ \\;|\\<br\\>|\\<p\\>|\\<\\/p\\>)+/is", '', $message); if (empty($ckmessage)) { return false; } $message = addslashes($message); if (checkperm('manageblog')) { $blogarr['hot'] = intval($POST['hot']); } if ($blogarr['catid']) { DB::query("UPDATE " . DB::table('home_blog_category') . " SET num=num+1 WHERE catid='{$blogarr['catid']}'"); } $blogarr['uid'] = $_G['uid']; $blogarr['username'] = $_G['username']; $blogarr['dateline'] = empty($POST['public_time']) ? $_G['timestamp'] : $POST['public_time']; if ($info['blogid']) { DB::update('home_blog', $blogarr, array('blogid' => $info['blogid'])); $blogid = $info['blogid']; } else { $blogid = DB::insert('home_blog', $blogarr, 1); } DB::update('common_member_status', array('lastpost' => $POST['public_time']), array('uid' => $_G['uid'])); DB::update('common_member_field_home', array('recentnote' => $POST['subject']), array('uid' => $_G['uid'])); $blogarr['blogid'] = $blogid; if (function_exists('modblogtag')) { $POST['tag'] = $olds ? modblogtag($POST['tag'], $blogid) : addblogtag($POST['tag'], $blogid); } else { $class_tag = new tag(); $POST['tag'] = $olds ? $class_tag->update_field($POST['tag'], $blogid, 'blogid') : $class_tag->add_tag($POST['tag'], $blogid, 'blogid'); } $fieldarr = array('message' => $message, 'postip' => $_G['clientip'], 'target_ids' => $POST['target_ids'], 'tag' => $POST['tag']); if (!empty($titlepic)) { $fieldarr['pic'] = $titlepic; } $fieldarr['blogid'] = $blogid; $fieldarr['uid'] = $blogarr['uid']; if ($info['blogid']) { DB::update('home_blogfield', $fieldarr, array('blogid' => $info['blogid'])); } else { DB::query("UPDATE " . DB::table('common_member_count') . " SET blogs=blogs+1 WHERE uid='{$fieldarr['uid']}'"); //更新数 DB::insert('home_blogfield', $fieldarr); } if ($isself && !$olds && $blog_status == 0) { updatecreditbyaction('publishblog', 0, array('blogs' => 1)); include_once libfile('function/stat'); updatestat('blog'); } if ($POST['makefeed'] && $blog_status == 0) { include_once libfile('function/feed'); feed_publish($blogid, 'blogid', $olds ? 0 : 1); } if (!empty($__G)) { $_G = $__G; } if ($blog_status == 1) { updatemoderate('blogid', $blogid); manage_addnotify('verifyblog'); } return $blogarr; }