/**
  * 更新用户表中allowadmincp的状态
  */
 function _update_member_allowadmincp($uids)
 {
     if (!empty($uids)) {
         $userperms = C::t('common_block_permission')->fetch_permission_by_uid($uids);
         foreach (C::t('common_member')->fetch_all($uids, false, 0) as $uid => $v) {
             $v['allowadmincp'] = setstatus(4, empty($userperms[$uid]['allowmanage']) ? 0 : 1, $v['allowadmincp']);
             if ($userperms[$uid]['allowrecommend'] > 0) {
                 if ($userperms[$uid]['allowrecommend'] == $userperms[$uid]['needverify']) {
                     $v['allowadmincp'] = setstatus(5, 1, $v['allowadmincp']);
                     //推送数据到模块且需要审核的权限
                     $v['allowadmincp'] = setstatus(6, 0, $v['allowadmincp']);
                     //取消 推送数据到模块不需要审核的权限(既管理模块数据权限)
                 } else {
                     $v['allowadmincp'] = setstatus(5, 0, $v['allowadmincp']);
                     //取消 推送数据到模块且需要审核的权限
                     $v['allowadmincp'] = setstatus(6, 1, $v['allowadmincp']);
                     //推送数据到模块不需要审核的权限(既管理模块数据权限)
                 }
             } else {
                 $v['allowadmincp'] = setstatus(5, 0, $v['allowadmincp']);
                 //取消 推送数据到模块且需要审核的权限
                 $v['allowadmincp'] = setstatus(6, 0, $v['allowadmincp']);
                 //取消 推送数据到模块不需要审核的权限(既管理模块数据权限)
             }
             C::t('common_member')->update($uid, array('allowadmincp' => $v['allowadmincp']));
         }
     }
 }
 function _update_member_allowadmincp($uids)
 {
     if (!empty($uids)) {
         $userperms = array();
         $query = DB::query('SELECT uid, sum(allowmanage) as mn, sum(allowrecommend) as rc, sum(needverify) as nv FROM ' . DB::table('common_block_permission') . " WHERE uid IN (" . dimplode($uids) . ") GROUP BY uid");
         while ($v = DB::fetch($query)) {
             $userperms[$v['uid']] = array('allowmanage' => $v['mn'], 'allowrecommend' => $v['rc'], 'needverify' => $v['nv']);
         }
         $query = DB::query('SELECT uid,allowadmincp FROM ' . DB::table('common_member') . " WHERE uid IN (" . dimplode($uids) . ")");
         while ($v = DB::fetch($query)) {
             $v['allowadmincp'] = setstatus(4, empty($userperms[$v['uid']]['allowmanage']) ? 0 : 1, $v['allowadmincp']);
             if ($userperms[$v['uid']]['allowrecommend'] > 0) {
                 if ($userperms[$v['uid']]['allowrecommend'] == $userperms[$v['uid']]['needverify']) {
                     $v['allowadmincp'] = setstatus(5, 1, $v['allowadmincp']);
                     $v['allowadmincp'] = setstatus(6, 0, $v['allowadmincp']);
                 } else {
                     $v['allowadmincp'] = setstatus(5, 0, $v['allowadmincp']);
                     $v['allowadmincp'] = setstatus(6, 1, $v['allowadmincp']);
                 }
             } else {
                 $v['allowadmincp'] = setstatus(5, 0, $v['allowadmincp']);
                 $v['allowadmincp'] = setstatus(6, 0, $v['allowadmincp']);
             }
             DB::update('common_member', array('allowadmincp' => $v['allowadmincp']), "uid='{$v['uid']}'");
         }
     }
 }
 public function before_newthread($parameters)
 {
     if ($this->group['allowpostrushreply']) {
         $_GET['rushreplyfrom'] = strtotime($_GET['rushreplyfrom']);
         $_GET['rushreplyto'] = strtotime($_GET['rushreplyto']);
         $_GET['rewardfloor'] = trim($_GET['rewardfloor']);
         $_GET['stopfloor'] = intval($_GET['stopfloor']);
         $_GET['replylimit'] = intval($_GET['replylimit']);
         $_GET['creditlimit'] = $_GET['creditlimit'] == '' ? '-996' : intval($_GET['creditlimit']);
         if ($_GET['rushreplyfrom'] > $_GET['rushreplyto'] && !empty($_GET['rushreplyto'])) {
             showmessage('post_rushreply_timewrong');
         }
         if ($_GET['rushreplyfrom'] > TIMESTAMP || !empty($_GET['rushreplyto']) && $_GET['rushreplyto'] < TIMESTAMP || $_GET['stopfloor'] == 1) {
             $this->param['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);
             }
         }
         $parameters['tstatus'] = setstatus(3, 1, $parameters['tstatus']);
         $parameters['tstatus'] = setstatus(1, 1, $parameters['tstatus']);
         $this->param['tstatus'] = $parameters['tstatus'];
     }
 }
Exemple #4
0
 function setTopicPostData($postdata)
 {
     if (empty($this->info['classid']) || empty($this->info['iftopicshowinforum'])) {
         $postdata['ifcheck'] = 2;
     }
     setstatus($postdata['tpcstatus'], 1);
     return $postdata;
 }
 function post_mobile_message($message, $url_forward, $values, $extraparam, $custom)
 {
     if ($message == 'comment_add_succeed') {
         showmessage($message);
     }
     if ($values['tid'] && $values['pid']) {
         global $_G;
         $threadstatus = DB::result_first("SELECT status FROM " . DB::table('forum_thread') . " WHERE tid='{$values['tid']}'");
         $setstatusold = base_convert(getstatus($threadstatus, 13) . getstatus($threadstatus, 12) . getstatus($threadstatus, 11), 2, 10);
         $updatestatus = false;
         if (!empty($_POST['allowsound'])) {
             $setstatus = array(1, 0, 0);
             $updatestatus = $setstatusold < 4;
         } elseif (!empty($_POST['allowphoto'])) {
             $setstatus = array(0, 1, 1);
             $updatestatus = $setstatusold < 3;
         } elseif (!empty($_POST['allowlocal'])) {
             $setstatus = array(0, 1, 0);
             $updatestatus = $setstatusold < 2;
         } else {
             $setstatus = array(0, 0, 1);
         }
         if ($updatestatus) {
             foreach ($setstatus as $i => $bit) {
                 $threadstatus = setstatus(13 - $i, $bit, $threadstatus);
             }
             //note DB::update('forum_thread', array('status' => $threadstatus), "tid='$values[tid]'");
             C::t('forum_thread')->update($values['tid'], array('status' => $threadstatus));
         }
         $posttable = getposttablebytid($values['tid']);
         $poststatus = DB::result_first("SELECT status FROM " . DB::table($posttable) . " WHERE pid='{$values['pid']}'");
         $poststatus = setstatus(4, 1, $poststatus);
         if (!empty($_POST['allowlocal'])) {
             $poststatus = setstatus(6, 1, $poststatus);
         }
         if (!empty($_POST['allowsound'])) {
             $poststatus = setstatus(7, 1, $poststatus);
         }
         if (!empty($_POST['mobiletype']) && $_POST['mobiletype'] < 8) {
             $mobiletype = base_convert($_POST['mobiletype'], 10, 2);
             $mobiletype = sprintf('%03d', $mobiletype);
             for ($i = 0; $i < 3; $i++) {
                 $poststatus = setstatus(10 - $i, $mobiletype[$i], $poststatus);
             }
         }
         //note DB::update($posttable, array('status' => $poststatus), "pid='$values[pid]'");
         C::t('forum_post')->update('tid:' . $values['tid'], $values['pid'], array('status' => $poststatus));
         if ($_POST['location']) {
             list($mapx, $mapy, $location) = explode('|', dhtmlspecialchars($_POST['location']));
             C::t('forum_post_location')->insert(array('pid' => $values['pid'], 'tid' => $values['tid'], 'uid' => $_G['uid'], 'mapx' => $mapx, 'mapy' => $mapy, 'location' => $location));
         }
     }
 }
 function _update_member_allowadmincp($uids)
 {
     if (!empty($uids)) {
         $userperms = array();
         $userperms = C::t('portal_category_permission')->fetch_permission_by_uid($uids);
         foreach (C::t('common_member')->fetch_all($uids, false, 0) as $uid => $v) {
             $v['allowadmincp'] = setstatus(3, empty($userperms[$v['uid']]['allowpublish']) ? 0 : 1, $v['allowadmincp']);
             $v['allowadmincp'] = setstatus(2, empty($userperms[$v['uid']]['allowmanage']) ? 0 : 1, $v['allowadmincp']);
             C::t('common_member')->update($uid, array('allowadmincp' => $v['allowadmincp']));
         }
     }
 }
Exemple #7
0
	function post_mobile_message($message, $url_forward, $values, $extraparam, $custom) {
		if($values['tid'] && $values['pid']) {
			global $_G;

			$threadstatus = DB::result_first("SELECT status FROM ".DB::table('forum_thread')." WHERE tid='$values[tid]'");
			if(!empty($_POST['allowsound'])) {
				$setstatus = array(1, 0, 0);
			} elseif(!empty($_POST['allowphoto'])) {
				$setstatus = array(0, 1, 1);
			} elseif(!empty($_POST['allowlocal'])) {
				$setstatus = array(0, 1, 0);
			} else {
				$setstatus = array(0, 0, 1);
			}
			foreach($setstatus as $i => $bit) {
				$threadstatus = setstatus(13 - $i, $bit, $threadstatus);
			}
			//note DB::update('forum_thread', array('status' => $threadstatus), "tid='$values[tid]'");
			C::t('forum_thread')->update($values['tid'], array('status' => $threadstatus));

			$poststatus = DB::result_first("SELECT status FROM ".DB::table('forum_post')." WHERE pid='$values[pid]'");
			$poststatus = setstatus(4, 1, $poststatus);
			if(!empty($_POST['allowlocal'])) {
				$poststatus = setstatus(6, 1, $poststatus);
			}
			if(!empty($_POST['allowsound'])) {
				$poststatus = setstatus(7, 1, $poststatus);
			}
			if(!empty($_POST['mobiletype'])) {
				$mobiletype = base_convert($_POST['mobiletype'], 10, 2);
				$mobiletype = sprintf('%03d', $mobiletype);
				for($i = 0;$i < 3;$i++) {
					$poststatus = setstatus(10 - $i, $mobiletype{$i}, $poststatus);
				}
			}
			//note DB::update('forum_post', array('status' => $poststatus), "pid='$values[pid]'");
			C::t('forum_post')->update(0, $values['pid'], array('status' => $poststatus));

			if($_POST['location']) {
				list($mapx, $mapy, $location) = explode('|', dhtmlspecialchars($_POST['location']));
				C::t('forum_post_location')->insert(array(
					'pid' => $values['pid'],
					'tid' => $values['tid'],
					'uid' => $_G['uid'],
					'mapx' => $mapx,
					'mapy' => $mapy,
					'location' => $location,
				));
			}
		}
	}
 function _update_member_allowadmincp($uids)
 {
     if (!empty($uids)) {
         $userperms = array();
         $query = DB::query('SELECT uid, sum(allowpublish) as pb, sum(allowmanage) as mn FROM ' . DB::table('portal_category_permission') . " WHERE uid IN (" . dimplode($uids) . ") GROUP BY uid");
         while ($v = DB::fetch($query)) {
             $userperms[$v['uid']] = array('allowpublish' => $v['pb'], 'allowmanage' => $v['mn']);
         }
         $query = DB::query('SELECT uid,allowadmincp FROM ' . DB::table('common_member') . " WHERE uid IN (" . dimplode($uids) . ")");
         while ($v = DB::fetch($query)) {
             $v['allowadmincp'] = setstatus(3, empty($userperms[$v['uid']]['allowpublish']) ? 0 : 1, $v['allowadmincp']);
             $v['allowadmincp'] = setstatus(2, empty($userperms[$v['uid']]['allowmanage']) ? 0 : 1, $v['allowadmincp']);
             DB::update('common_member', array('allowadmincp' => $v['allowadmincp']), "uid='{$v['uid']}'");
         }
     }
 }
Exemple #9
0
 /**
  * 
  * 更新tpc状态
  * @param int $threadId
  * @param int $b 位
  * @param int $v 0|1
  */
 function setTpcStatusByThreadId($threadId, $b, $v = '1')
 {
     $b = intval($b);
     $threadId = intval($threadId);
     if (!$threadId) {
         return false;
     }
     $v != 1 && ($v = '0');
     $threadInfo = $this->getByThreadId($threadId);
     if (!S::isArray($threadInfo)) {
         return false;
     }
     $tpcstatus = $threadInfo['tpcstatus'];
     setstatus($tpcstatus, $b, $v);
     $_dbService = L::loadDB('threads', 'forum');
     $_dbService->update(array('tpcstatus' => $tpcstatus), $threadId);
     return true;
 }
function notifymembers($operation, $variable)
{
    global $_G, $lang, $urladd, $conditions, $search_condition;
    if (!empty($_GET['current'])) {
        $subject = $message = '';
        if ($settings = C::t('common_setting')->fetch($variable, true)) {
            $subject = $settings['subject'];
            $message = $settings['message'];
        }
        $setarr = array();
        foreach ($_G['setting']['extcredits'] as $id => $value) {
            if (isset($_GET['extcredits' . $id])) {
                if ($_GET['updatecredittype'] == 0) {
                    $setarr['extcredits' . $id] = $_GET['extcredits' . $id];
                } else {
                    $setarr[] = 'extcredits' . $id;
                }
            }
        }
    } else {
        $current = 0;
        $subject = $_GET['subject'];
        $message = $_GET['message'];
        $subject = trim($subject);
        $message = trim(str_replace("\t", ' ', $message));
        $addmsg = '';
        if ($_GET['notifymembers'] && $_GET['notifymember'] && !($subject && $message)) {
            cpmsg('members_newsletter_sm_invalid', '', 'error');
        }
        if ($operation == 'reward') {
            $serarr = array();
            if ($_GET['updatecredittype'] == 0) {
                if (is_array($_GET['addextcredits']) && !empty($_GET['addextcredits'])) {
                    foreach ($_GET['addextcredits'] as $key => $value) {
                        $value = intval($value);
                        if (isset($_G['setting']['extcredits'][$key]) && !empty($value)) {
                            $setarr['extcredits' . $key] = $value;
                            $addmsg .= $_G['setting']['extcredits'][$key]['title'] . ": " . ($value > 0 ? '<em class="xi1">+' : '<em class="xg1">') . "{$value}</em> " . $_G['setting']['extcredits'][$key]['unit'] . ' &nbsp; ';
                        }
                    }
                }
            } else {
                if (is_array($_GET['resetextcredits']) && !empty($_GET['resetextcredits'])) {
                    foreach ($_GET['resetextcredits'] as $key => $value) {
                        $value = intval($value);
                        if (isset($_G['setting']['extcredits'][$key]) && !empty($value)) {
                            $setarr[] = 'extcredits' . $key;
                            $addmsg .= $_G['setting']['extcredits'][$key]['title'] . ': <em class="xg1">' . cplang('members_reward_clean') . '</em> &nbsp; ';
                        }
                    }
                }
            }
            if ($addmsg) {
                $addmsg = ' &nbsp; <br /><br /><b>' . cplang('members_reward_affect') . ':</b><br \\>' . $addmsg;
            }
            if (!empty($setarr)) {
                $limit = 2000;
                set_time_limit(0);
                $i = 0;
                while (true) {
                    $uids = searchmembers($search_condition, $limit, $i * $limit);
                    $allcount = C::t('common_member_count')->fetch_all($uids);
                    $insertmember = array_diff($uids, array_keys($allcount));
                    foreach ($insertmember as $uid) {
                        C::t('common_member_count')->insert(array('uid' => $uid));
                    }
                    if ($_GET['updatecredittype'] == 0) {
                        C::t('common_member_count')->increase($uids, $setarr);
                    } else {
                        C::t('common_member_count')->clear_extcredits($uids, $setarr);
                    }
                    if (count($uids) < $limit) {
                        break;
                    }
                    $i++;
                }
            } else {
                cpmsg('members_reward_invalid', '', 'error');
            }
            if (!$_GET['notifymembers']) {
                cpmsg('members_reward_succeed', '', 'succeed');
            }
        } elseif ($operation == 'confermedal') {
            $medals = $_GET['medals'];
            if (!empty($medals)) {
                $medalids = array();
                foreach ($medals as $key => $medalid) {
                    $medalids[] = $key;
                }
                $medalsnew = $comma = '';
                $medalsnewarray = $medalidarray = array();
                foreach (C::t('forum_medal')->fetch_all_by_id($medalids) as $medal) {
                    $medal['status'] = empty($medal['expiration']) ? 0 : 1;
                    $medal['expiration'] = empty($medal['expiration']) ? 0 : TIMESTAMP + $medal['expiration'] * 86400;
                    $medal['medal'] = $medal['medalid'] . (empty($medal['expiration']) ? '' : '|' . $medal['expiration']);
                    $medalsnew .= $comma . $medal['medal'];
                    $medalsnewarray[] = $medal;
                    $medalidarray[] = $medal['medalid'];
                    $comma = "\t";
                }
                $uids = searchmembers($search_condition);
                if ($uids) {
                    foreach (C::t('common_member_field_forum')->fetch_all($uids) as $uid => $medalnew) {
                        $usermedal = array();
                        $addmedalnew = '';
                        if (empty($medalnew['medals'])) {
                            $addmedalnew = $medalsnew;
                        } else {
                            foreach ($medalidarray as $medalid) {
                                $usermedal_arr = explode("\t", $medalnew['medals']);
                                foreach ($usermedal_arr as $key => $medalval) {
                                    list($usermedalid, ) = explode("|", $medalval);
                                    $usermedal[] = $usermedalid;
                                }
                                if (!in_array($medalid, $usermedal)) {
                                    $addmedalnew .= $medalid . "\t";
                                }
                            }
                            $addmedalnew .= $medalnew['medals'];
                        }
                        C::t('common_member_field_forum')->update($medalnew['uid'], array('medals' => $addmedalnew), true);
                        foreach ($medalsnewarray as $medalnewarray) {
                            $data = array('uid' => $medalnew['uid'], 'medalid' => $medalnewarray['medalid'], 'type' => 0, 'dateline' => $_G['timestamp'], 'expiration' => $medalnewarray['expiration'], 'status' => $medalnewarray['status']);
                            C::t('forum_medallog')->insert($data);
                            C::t('common_member_medal')->insert(array('uid' => $medalnew['uid'], 'medalid' => $medalnewarray['medalid']), 0, 1);
                        }
                    }
                }
            }
            if (!$_GET['notifymember']) {
                cpmsg('members_confermedal_succeed', '', 'succeed');
            }
        } elseif ($operation == 'confermagic') {
            $magics = $_GET['magic'];
            $magicnum = $_GET['magicnum'];
            if ($magics) {
                require_once libfile('function/magic');
                $limit = 200;
                set_time_limit(0);
                for ($i = 0; $i > -1; $i++) {
                    $uids = searchmembers($search_condition, $limit, $i * $limit);
                    foreach ($magics as $magicid) {
                        $uparray = $insarray = array();
                        if (empty($magicnum[$magicid])) {
                            continue;
                        }
                        $query = C::t('common_member_magic')->fetch_all($uids ? $uids : -1, $magicid);
                        foreach ($query as $row) {
                            $uparray[] = $row['uid'];
                        }
                        if ($uparray) {
                            C::t('common_member_magic')->increase($uparray, $magicid, array('num' => $magicnum[$magicid]));
                        }
                        $insarray = array_diff($uids, $uparray);
                        if ($insarray) {
                            $sqls = array();
                            foreach ($insarray as $uid) {
                                C::t('common_member_magic')->insert(array('uid' => $uid, 'magicid' => $magicid, 'num' => $magicnum[$magicid]));
                            }
                        }
                        foreach ($uids as $uid) {
                            updatemagiclog($magicid, '3', $magicnum[$magicid], '', $uid);
                        }
                    }
                    if (count($uids) < $limit) {
                        break;
                    }
                }
            }
        }
        C::t('common_setting')->update($variable, array('subject' => $subject, 'message' => $message));
    }
    $pertask = intval($_GET['pertask']);
    $current = $_GET['current'] ? intval($_GET['current']) : 0;
    $continue = FALSE;
    if (!function_exists('sendmail')) {
        include libfile('function/mail');
    }
    if ($_GET['notifymember'] && in_array($_GET['notifymembers'], array('pm', 'notice', 'email', 'mobile'))) {
        $uids = searchmembers($search_condition, $pertask, $current);
        require_once libfile('function/discuzcode');
        $message = in_array($_GET['notifymembers'], array('email', 'notice')) && $_GET['posttype'] ? discuzcode($message, 1, 0, 1, '', '', '', 1) : discuzcode($message, 1, 0);
        $pmuids = array();
        if ($_GET['notifymembers'] == 'pm') {
            $membernum = countmembers($search_condition, $urladd);
            $gpmid = $_GET['gpmid'];
            if (!$gpmid) {
                $pmdata = array('authorid' => $_G['uid'], 'author' => !$_GET['system'] ? $_G['member']['username'] : '', 'dateline' => TIMESTAMP, 'message' => ($subject ? '<b>' . $subject . '</b><br /> &nbsp; ' : '') . $message . $addmsg, 'numbers' => $membernum);
                $gpmid = C::t('common_grouppm')->insert($pmdata, true);
            }
            $urladd .= '&gpmid=' . $gpmid;
        }
        $members = C::t('common_member')->fetch_all($uids);
        if ($_GET['notifymembers'] == 'mobile') {
            $toUids = array_keys($members);
            if ($_G['setting']['cloud_status'] && !empty($toUids)) {
                try {
                    $noticeService = Cloud::loadClass('Service_Client_Notification');
                    $fromType = $_GET['system'] ? 1 : 2;
                    $noticeService->addSiteMasterUserNotify($toUids, $subject, $message, $_G['uid'], $_G['username'], $fromType, TIMESTAMP);
                } catch (Cloud_Service_Client_RestfulException $e) {
                    cpmsg('[' . $e->getCode() . ']' . $e->getMessage(), '', 'error');
                }
            }
        } else {
            foreach ($members as $member) {
                if ($_GET['notifymembers'] == 'pm') {
                    C::t('common_member_grouppm')->insert(array('uid' => $member['uid'], 'gpmid' => $gpmid, 'status' => 0), false, true);
                    $newpm = setstatus(2, 1, $member['newpm']);
                    C::t('common_member')->update($member['uid'], array('newpm' => $newpm));
                } elseif ($_GET['notifymembers'] == 'notice') {
                    notification_add($member['uid'], 'system', 'system_notice', array('subject' => $subject, 'message' => $message . $addmsg, 'from_id' => 0, 'from_idtype' => 'sendnotice'), 1);
                } elseif ($_GET['notifymembers'] == 'email') {
                    if (!sendmail("{$member['username']} <{$member['email']}>", $subject, $message . $addmsg)) {
                        runlog('sendmail', "{$member['email']} sendmail failed.");
                    }
                }
                $log = array();
                if ($_GET['updatecredittype'] == 0) {
                    foreach ($setarr as $key => $val) {
                        if (empty($val)) {
                            continue;
                        }
                        $val = intval($val);
                        $id = intval($key);
                        $id = !$id && substr($key, 0, -1) == 'extcredits' ? intval(substr($key, -1, 1)) : $id;
                        if (0 < $id && $id < 9) {
                            $log['extcredits' . $id] = $val;
                        }
                    }
                    $logtype = 'RPR';
                } else {
                    foreach ($setarr as $val) {
                        if (empty($val)) {
                            continue;
                        }
                        $id = intval($val);
                        $id = !$id && substr($val, 0, -1) == 'extcredits' ? intval(substr($val, -1, 1)) : $id;
                        if (0 < $id && $id < 9) {
                            $log['extcredits' . $id] = '-1';
                        }
                    }
                    $logtype = 'RPZ';
                }
                include_once libfile('function/credit');
                credit_log($member['uid'], $logtype, $member['uid'], $log);
                $continue = TRUE;
            }
        }
    }
    $newsletter_detail = array();
    if ($continue) {
        $next = $current + $pertask;
        $newsletter_detail = array('uid' => $_G['uid'], 'current' => $current, 'next' => $next, 'search_condition' => serialize($search_condition), 'action' => "action=members&operation={$operation}&{$operation}submit=yes&current={$next}&pertask={$pertask}&system={$_GET['system']}&posttype={$_GET['posttype']}&notifymember={$_GET['notifymember']}&notifymembers=" . rawurlencode($_GET['notifymembers']) . $urladd);
        save_newsletter('newsletter_detail', $newsletter_detail);
        $logaddurl = '';
        foreach ($setarr as $k => $v) {
            if ($_GET['updatecredittype'] == 0) {
                $logaddurl .= '&' . $k . '=' . $v;
            } else {
                $logaddurl .= '&' . $v . '=-1';
            }
        }
        $logaddurl .= '&updatecredittype=' . $_GET['updatecredittype'];
        cpmsg("{$lang['members_newsletter_send']}: " . cplang('members_newsletter_processing', array('current' => $current, 'next' => $next, 'search_condition' => serialize($search_condition))), "action=members&operation={$operation}&{$operation}submit=yes&current={$next}&pertask={$pertask}&system={$_GET['system']}&posttype={$_GET['posttype']}&notifymember={$_GET['notifymember']}&notifymembers=" . rawurlencode($_GET['notifymembers']) . $urladd . $logaddurl, 'loadingform');
    } else {
        del_newsletter('newsletter_detail');
        if ($operation == 'reward' && $_GET['notifymembers'] == 'pm') {
            $message = '';
        } else {
            $message = '_notify';
        }
        cpmsg('members' . ($operation ? '_' . $operation : '') . $message . '_succeed', '', 'succeed');
    }
}
Exemple #11
0
 function setStatus($pos, $value = '1')
 {
     setstatus($this->data['tpcstatus'], $pos, $value);
 }
Exemple #12
0
        try {
            if ($t_params['pic']) {
                $method = 'connectAddPicT';
            } else {
                $method = 'connectAddT';
            }
            $response = $connectOAuthClient->{$method}($_G['member']['conopenid'], $_G['member']['conuin'], $_G['member']['conuinsecret'], $t_params);
            if ($response['ret'] == 0) {
                $weibo_succ = true;
            }
        } catch (Exception $e) {
            if ($e->getCode()) {
                $weiboErrorCode = $e->getCode();
            }
            $weibo_succ = false;
        }
        if ($weibo_succ) {
            $feedlog_status = $feedlog['status'];
            $feedlog_status = setstatus(4, 1, $feedlog_status);
            $feedlog_status = setstatus(3, 0, $feedlog_status);
            C::t('#qqconnect#connect_postfeedlog')->update_by_pid($pid, array('status' => $feedlog_status, 'lastpublished' => $_G['timestamp'], 'publishtimes' => $feedlog['publishtimes'] + 1));
        }
        if (!$weiboErrorCode) {
            dsetcookie('connect_sync_post');
            $connectService->connectJsOutputMessage(lang('plugin/qqconnect', 'connect_feed_sync_success'), '', 0);
        } else {
            C::t('#qqconnect#connect_postfeedlog')->update_by_pid($pid, array('lastpublished' => $_G['timestamp'], 'publishtimes' => $feedlog['publishtimes'] + 1));
            $connectService->connectJsOutputMessage('', '', $weiboErrorCode);
        }
    }
}
function buildbitsql($fieldname, $position, $value)
{
    $t = " `{$fieldname}`=`{$fieldname}`";
    if ($value) {
        $t .= ' | ' . setstatus($position, 1);
    } else {
        $t .= ' & ' . setstatus($position, 0);
    }
    return $t . ' ';
}
Exemple #14
0
    $t = getdate($timestamp + 8 * 3600);
    $tdtime = (floor($timestamp / 3600) - $t['hours']) * 3600;
    $lang['db_bbsurl'] = $bbsurl;
    $lang['db_manager'] = $manager[0];
    $content = str_replace(array("\r", "\n\n", ";\n"), array('', "\n", ";<wind>\n"), trim(readover(R_P . 'lang/install_wind.sql'), " \n"));
    $db_floorname = array($lang['db_floorname_1'], $lang['db_floorname_2'], $lang['db_floorname_3'], $lang['db_floorname_4']);
    $db_sitemsg = array("reg" => array($lang['db_sitemsg_1'], $lang['db_sitemsg_2']), "login" => array($lang['db_sitemsg_3']), "post" => array($lang['db_sitemsg_4'], $lang['db_sitemsg_5'], $lang['db_sitemsg_6']), "reply" => array($lang['db_sitemsg_4'], $lang['db_sitemsg_5'], $lang['db_sitemsg_6']));
    $lang['db_floorname'] = addslashes(serialize($db_floorname));
    $lang['db_sitemsg'] = addslashes(serialize($db_sitemsg));
    $content = preg_replace("/{#(.+?)}/eis", '$lang[\'\\1\']', $content) . '<wind>';
    $content = explode("\n", $content);
    $writearray = array($lang['success_3']);
    $writearray = SQLCreate($content);
    $userstatus = 0;
    setstatus($userstatus, 7);
    setstatus($userstatus, 8);
    $db->update("REPLACE INTO pw_members (username,password,icon,email,groupid,memberid,regdate,userstatus,shortcut) VALUES ('{$manager['0']}','{$manager_pwd['0']}','none.gif|1|||','{$manager_email}','3','8','{$timestamp}','{$userstatus}',',article,write,diary,share,groups,photos,')");
    $uid = $db->insert_id();
    $db->update("REPLACE INTO pw_memberdata (uid,lastvisit,thisvisit) VALUES ('{$uid}','{$timestamp}','{$timestamp}')");
    $db->update("REPLACE INTO pw_bbsinfo (id,newmember,totalmember,tdtcontrol) VALUES ('1','{$manager['0']}','1','{$tdtime}')");
    $db->update("REPLACE INTO pw_administrators(uid,username,groupid,groups) VALUES('{$uid}','{$manager['0']}','3','')");
    writeover(D_P . "data/install.log", implode("\n", $writearray) . "\n{$lang['success_3_2']}", 'ab+');
    list($prev, $next) = getStepto($action);
    pwHeader("{$basename}?action={$next}");
    exit;
}
/**
 * 初始化数据库数据
 */
if ($action == 'initdata') {
    if ($step != 2) {
function notifymembers($operation, $variable)
{
    global $_G, $lang, $urladd, $conditions, $search_condition;
    if (!empty($_G['gp_current'])) {
        $subject = $message = '';
        if ($settings = DB::result_first("SELECT svalue FROM " . DB::table('common_setting') . " WHERE skey='{$variable}'")) {
            $settings = unserialize($settings);
            $subject = $settings['subject'];
            $message = $settings['message'];
        }
    } else {
        $current = 0;
        $subject = $_G['gp_subject'];
        $message = $_G['gp_message'];
        $subject = trim($subject);
        $message = trim(str_replace("\t", ' ', $message));
        $message = stripslashes($message);
        $addmsg = '';
        if ($_G['gp_notifymembers'] && $_G['gp_notifymember'] && !($subject && $message)) {
            cpmsg('members_newsletter_sm_invalid', '', 'error');
        }
        if ($operation == 'reward') {
            $updatesql = '';
            if ($_G['gp_updatecredittype'] == 0) {
                if (is_array($_G['gp_addextcredits']) && !empty($_G['gp_addextcredits'])) {
                    foreach ($_G['gp_addextcredits'] as $key => $value) {
                        $value = intval($value);
                        if (isset($_G['setting']['extcredits'][$key]) && !empty($value)) {
                            $updatesql .= ", extcredits{$key}=extcredits{$key}+({$value})";
                            $addmsg .= $_G['setting']['extcredits'][$key]['title'] . ": " . ($value > 0 ? '<em class="xi1">+' : '<em class="xg1">') . "{$value}</em> " . $_G['setting']['extcredits'][$key]['unit'] . ' &nbsp; ';
                        }
                    }
                }
            } else {
                if (is_array($_G['gp_resetextcredits']) && !empty($_G['gp_resetextcredits'])) {
                    foreach ($_G['gp_resetextcredits'] as $key => $value) {
                        $value = intval($value);
                        if (isset($_G['setting']['extcredits'][$key]) && !empty($value)) {
                            $updatesql .= ", extcredits{$key}=0";
                            $addmsg .= $_G['setting']['extcredits'][$key]['title'] . ': <em class="xg1">' . cplang('members_reward_clean') . '</em> &nbsp; ';
                        }
                    }
                }
            }
            if ($addmsg) {
                $addmsg = ' &nbsp; <br /><br /><b>' . cplang('members_reward_affect') . ':</b><br \\>' . $addmsg;
            }
            if (!empty($updatesql)) {
                $limit = 2000;
                set_time_limit(0);
                for ($i = 0; $i > -1; $i++) {
                    $uids = searchmembers($search_condition, $limit, $i * $limit);
                    $conditions = $uids ? 'm.uid IN (' . dimplode($uids) . ')' : '0';
                    $uids_query = DB::query("SELECT m.uid AS m_uid, mc.uid AS mc_uid FROM " . DB::table('common_member') . " m LEFT JOIN " . DB::table('common_member_count') . " mc ON m.uid=mc.uid WHERE {$conditions}");
                    while ($uid_tmp = DB::fetch($uids_query)) {
                        if (empty($uid_tmp['mc_uid'])) {
                            DB::insert('common_member_count', array('uid' => $uid_tmp['m_uid']));
                        }
                    }
                    $uids_conditions = dimplode($uids);
                    DB::query("UPDATE " . DB::table('common_member_count') . " SET uid=uid {$updatesql} WHERE uid IN ({$uids_conditions})", 'UNBUFFTERED');
                    if (count($uids) < $limit) {
                        break;
                    }
                }
            } else {
                cpmsg('members_reward_invalid', '', 'error');
            }
            if (!$_G['gp_notifymembers']) {
                cpmsg('members_reward_succeed', '', 'succeed');
            }
        } elseif ($operation == 'confermedal') {
            $medals = $_G['gp_medals'];
            if (!empty($medals)) {
                $medalids = $comma = '';
                foreach ($medals as $key => $medalid) {
                    $medalids .= "{$comma}'{$key}'";
                    $comma = ',';
                }
                $medalsnew = $comma = '';
                $medalsnewarray = $medalidarray = array();
                $query = DB::query("SELECT medalid, expiration FROM " . DB::table('forum_medal') . " WHERE medalid IN ({$medalids}) ORDER BY displayorder");
                while ($medal = DB::fetch($query)) {
                    $medal['status'] = empty($medal['expiration']) ? 0 : 1;
                    $medal['expiration'] = empty($medal['expiration']) ? 0 : TIMESTAMP + $medal['expiration'] * 86400;
                    $medal['medal'] = $medal['medalid'] . (empty($medal['expiration']) ? '' : '|' . $medal['expiration']);
                    $medalsnew .= $comma . $medal['medal'];
                    $medalsnewarray[] = $medal;
                    $medalidarray[] = $medal['medalid'];
                    $comma = "\t";
                }
                $uids = searchmembers($search_condition);
                if ($uids) {
                    $query = DB::query("SELECT uid, medals FROM " . DB::table('common_member_field_forum') . " WHERE uid IN (" . dimplode($uids) . ")");
                    while ($medalnew = DB::fetch($query)) {
                        $usermedal = array();
                        $addmedalnew = '';
                        if (empty($medalnew['medals'])) {
                            $addmedalnew = $medalsnew;
                        } else {
                            foreach ($medalidarray as $medalid) {
                                $usermedal_arr = explode("\t", $medalnew['medals']);
                                foreach ($usermedal_arr as $key => $medalval) {
                                    list($usermedalid, ) = explode("|", $medalval);
                                    $usermedal[] = $usermedalid;
                                }
                                if (!in_array($medalid, $usermedal)) {
                                    $addmedalnew .= $medalid . "\t";
                                }
                            }
                            $addmedalnew .= $medalnew['medals'];
                        }
                        DB::query("UPDATE " . DB::table('common_member_field_forum') . " SET medals='" . $addmedalnew . "' WHERE uid='" . $medalnew['uid'] . "'", 'UNBUFFTERED');
                        foreach ($medalsnewarray as $medalnewarray) {
                            $data = array('uid' => $medalnew['uid'], 'medalid' => $medalnewarray['medalid'], 'type' => 0, 'dateline' => $_G['timestamp'], 'expiration' => $medalnewarray['expiration'], 'status' => $medalnewarray['status']);
                            DB::insert('forum_medallog', $data);
                        }
                    }
                }
            }
            if (!$_G['gp_notifymembers']) {
                cpmsg('members_confermedal_succeed', '', 'succeed');
            }
        } elseif ($operation == 'confermagic') {
            $magics = $_G['gp_magic'];
            $magicnum = $_G['gp_magicnum'];
            if ($magics) {
                require_once libfile('function/magic');
                $limit = 200;
                set_time_limit(0);
                for ($i = 0; $i > -1; $i++) {
                    $uids = searchmembers($search_condition, $limit, $i * $limit);
                    $conditions = $uids ? 'uid IN (' . dimplode($uids) . ')' : '0';
                    foreach ($magics as $magicid) {
                        $uparray = $insarray = array();
                        if (empty($magicnum[$magicid])) {
                            continue;
                        }
                        $query = DB::query("SELECT uid, magicid FROM " . DB::table('common_member_magic') . " WHERE {$conditions} AND magicid='{$magicid}'");
                        while ($row = DB::fetch($query)) {
                            $uparray[] = $row['uid'];
                        }
                        if ($uparray) {
                            DB::query("UPDATE " . DB::table('common_member_magic') . " SET num=num+{$magicnum[$magicid]} WHERE uid IN (" . dimplode($uparray) . ") AND magicid='{$magicid}'");
                        }
                        $insarray = array_diff($uids, $uparray);
                        if ($insarray) {
                            $sqls = array();
                            $sql = "INSERT INTO " . DB::table('common_member_magic') . " (uid, magicid, num) VALUES ";
                            foreach ($insarray as $uid) {
                                $sqls[] = "('{$uid}', '{$magicid}', '{$magicnum[$magicid]}')";
                            }
                            $sql .= implode(',', $sqls);
                            DB::query($sql);
                        }
                        foreach ($uids as $uid) {
                            updatemagiclog($magicid, '3', $magicnum[$magicid], '', $uid);
                        }
                    }
                    if (count($uids) < $limit) {
                        break;
                    }
                }
            }
        }
        DB::query("REPLACE INTO " . DB::table('common_setting') . " (skey, svalue) VALUES ('{$variable}', '" . addslashes(serialize(array('subject' => $subject, 'message' => $message))) . "')");
    }
    $pertask = intval($_G['gp_pertask']);
    $current = $_G['gp_current'] ? intval($_G['gp_current']) : 0;
    $continue = FALSE;
    if (!function_exists('sendmail')) {
        include libfile('function/mail');
    }
    if ($_G['gp_notifymember'] && in_array($_G['gp_notifymembers'], array('pm', 'notice', 'email'))) {
        $uids = searchmembers($search_condition, $pertask, $current);
        $conditions = $uids ? 'uid IN (' . dimplode($uids) . ')' : '0';
        require_once libfile('function/discuzcode');
        $message = $_G['gp_notifymembers'] == 'email' && $_G['gp_posttype'] ? discuzcode($message, 1, 0, 1, '', '', '', 1) : discuzcode($message, 1, 0);
        $pmuids = array();
        if ($_G['gp_notifymembers'] == 'pm') {
            $membernum = countmembers($search_condition, $urladd);
            $gpmid = empty($_G['gp_gpmid']) ? DB::insert('common_grouppm', array('authorid' => $_G['uid'], 'author' => !$_G['gp_system'] ? $_G['member']['username'] : '', 'dateline' => TIMESTAMP, 'message' => ($subject ? '<b>' . $subject . '</b><br /> &nbsp; ' : '') . addslashes($message) . $addmsg, 'numbers' => $membernum), true) : $_G['gp_gpmid'];
            $urladd .= '&gpmid=' . $gpmid;
        }
        $query = DB::query("SELECT uid, username, groupid, email, newpm FROM " . DB::table('common_member') . " m WHERE {$conditions}");
        while ($member = DB::fetch($query)) {
            if ($_G['gp_notifymembers'] == 'pm') {
                DB::insert('common_member_grouppm', array('uid' => $member['uid'], 'gpmid' => $gpmid, 'status' => 0), false, true);
                $newpm = setstatus(2, 1, $member['newpm']);
                DB::query("UPDATE " . DB::table('common_member') . " SET newpm='{$newpm}' WHERE uid='{$member['uid']}'");
            } elseif ($_G['gp_notifymembers'] == 'notice') {
                notification_add($member['uid'], 'system', 'system_notice', array('subject' => $subject, 'message' => $message . $addmsg), 1);
            } elseif ($_G['gp_notifymembers'] == 'email') {
                sendmail("{$member['username']} <{$member['email']}>", $subject, $message . $addmsg);
            }
            $continue = TRUE;
        }
    }
    $newsletter_detail = array();
    if ($continue) {
        $next = $current + $pertask;
        $newsletter_detail = array('uid' => $_G['uid'], 'current' => $current, 'next' => $next, 'search_condition' => serialize($search_condition), 'action' => "action=members&operation={$operation}&{$operation}submit=yes&current={$next}&pertask={$pertask}&notifymember={$_G['gp_notifymember']}&notifymembers=" . rawurlencode($_G['gp_notifymembers']) . $urladd);
        save_newsletter('newsletter_detail', $newsletter_detail);
        cpmsg("{$lang['members_newsletter_send']}: " . cplang('members_newsletter_processing', array('current' => $current, 'next' => $next, 'search_condition' => serialize($search_condition))), "action=members&operation={$operation}&{$operation}submit=yes&current={$next}&pertask={$pertask}&notifymember={$_G['gp_notifymember']}&notifymembers=" . rawurlencode($_G['gp_notifymembers']) . $urladd, 'loadingform');
    } else {
        del_newsletter('newsletter_detail');
        if ($operation == 'reward' && $_G['gp_notifymembers'] == 'pm') {
            $message = '';
        } else {
            $message = '_notify';
        }
        cpmsg('members' . ($operation ? '_' . $operation : '') . $message . '_succeed', '', 'succeed');
    }
}
Exemple #16
0
                    // 用户未开通微博
                    $message = lang('plugin/qqconnect', 'connect_weibo_account_not_signup');
                } else {
                    $code = 100;
                    $message = lang('plugin/qqconnect', 'connect_server_busy');
                    $connectService->connectErrlog($code, lang('plugin/qqconnect', 'connect_errlog_server_no_response'));
                }
            }
        } else {
            $thread = C::t('forum_thread')->fetch($tid);
            if ($response['data']['id'] && $_G['setting']['connect']['t']['reply'] && $thread['tid'] && !$thread['closed'] && !getstatus($thread['status'], 3) && empty($_G['forum']['replyperm'])) {
                //DB::insert('connect_tthreadlog', array(
                C::t('#qqconnect#connect_tthreadlog')->insert(array('twid' => $response['data']['id'], 'tid' => $tid, 'conopenid' => $_G['member']['conopenid'], 'pagetime' => 0, 'lasttwid' => '0', 'nexttime' => $_G['timestamp'] + 30 * 60, 'updatetime' => 0, 'dateline' => $_G['timestamp']));
            }
            if (!getstatus($thread['status'], 8)) {
                C::t('forum_thread')->update($tid, array('status' => setstatus(8, 1, $thread['status'])));
                //note 分享也增加推送微博标志
            }
            $code = $response['ret'];
            $message = lang('plugin/qqconnect', 'connect_broadcast_success');
        }
    }
} elseif ($pluginop == 'sync_tthread') {
    // hash 验证
    if (trim($_GET['formhash']) != formhash()) {
        showmessage('submit_invalid');
    }
    if (!$_G['setting']['connect']['t']['reply']) {
        exit;
        //note 未开启
    }
 function _post_feedlog_message($param)
 {
     if (!$this->allow) {
         return;
     }
     global $_G;
     $condition1 = substr($param['param'][0], -8) != '_succeed';
     $condition2 = $_GET['action'] == 'edit' && !$GLOBALS['isfirstpost'];
     $condition3 = !$this->_allowconnectfeed() && !$this->_allowconnectt();
     $condition4 = empty($_GET['connect_publish_feed']) && empty($_GET['connect_publish_t']);
     if (empty($_GET['connect_publish_feed']) && $_GET['action'] != 'reply') {
         dsetcookie('connect_not_sync_feed', 1);
     } else {
         dsetcookie('connect_not_sync_feed', 0);
     }
     if (empty($_GET['connect_publish_t'])) {
         dsetcookie('connect_not_sync_t', 1);
     } else {
         dsetcookie('connect_not_sync_t', 0);
     }
     if ($condition1 || $condition2 || $condition3 || $condition4) {
         return false;
     }
     if ($_GET['action'] == 'reply') {
         $tid = $param['param'][2]['tid'];
         $pid = $param['param'][2]['pid'];
         if ($_GET['connect_publish_t']) {
             dsetcookie('connect_sync_post', $tid . '|' . $pid);
             $data = array('pid' => $pid, 'uid' => $_G['uid'], 'lastpublished' => 0, 'dateline' => $_G['timestamp'], 'status' => 0);
             C::t('#qqconnect#connect_postfeedlog')->insert($data, 0, 1);
         }
     } else {
         $tid = $param['param'][2]['tid'];
         $thread = C::t('forum_thread')->fetch($tid);
         if ($_GET['connect_publish_feed']) {
             $thread['status'] = setstatus(7, 1, $thread['status']);
         }
         if ($_GET['connect_publish_t']) {
             $thread['status'] = setstatus(8, 1, $thread['status']);
         }
         C::t('forum_thread')->update($tid, array('status' => $thread['status']));
         $data = array('tid' => $tid, 'uid' => $_G['uid'], 'lastpublished' => 0, 'dateline' => $_G['timestamp'], 'status' => 0);
         C::t('#qqconnect#connect_feedlog')->insert($data, 0, 1);
     }
 }
 function _viewthread_share_method_output()
 {
     global $_G;
     require_once libfile('function/connect');
     if ($GLOBALS['page'] == 1 && $_G['forum_firstpid'] && $GLOBALS['postlist'][$_G['forum_firstpid']]['invisible'] == 0) {
         $_G['connect']['feed_js'] = $_G['connect']['t_js'] = false;
         if (!getstatus($_G['forum_thread']['status'], 7) && $_G['forum_thread']['displayorder'] >= 0) {
             $feedlogstatus = false;
             $_G['connect']['feed_log'] = DB::fetch_first("SELECT * FROM " . DB::table('connect_feedlog') . " WHERE tid='{$_G['tid']}'");
             if ($_G['connect']['feed_log']) {
                 $_G['connect']['feed_interval'] = 300;
                 $_G['connect']['feed_publish_max'] = 1000;
                 if ($_G['connect']['feed_log'] && $_G['member']['conisbind'] && $_G['uid'] == $_G['forum_thread']['authorid']) {
                     if ($_G['connect']['feed_log']['status'] == 1 || $_G['connect']['feed_log']['status'] == 2 && TIMESTAMP - $_G['connect']['feed_log']['lastpublished'] > $_G['connect']['feed_interval'] && $_G['connect']['feed_log']['publishtimes'] < $_G['connect']['feed_publish_max']) {
                         DB::query("UPDATE " . DB::table('connect_feedlog') . " SET status='2', lastpublished='{$_G['timestamp']}', publishtimes=publishtimes+1 WHERE tid='{$_G['tid']}' AND status!=4");
                         $_G['connect']['feed_js'] = $feedlogstatus = true;
                     }
                 }
             } else {
                 $feedlogstatus = true;
             }
         }
         if (!getstatus($_G['forum_thread']['status'], 8) && $_G['forum_thread']['displayorder'] >= 0) {
             $_G['connect']['t_log'] = DB::fetch_first("SELECT * FROM " . DB::table('connect_tlog') . " WHERE tid='{$_G['tid']}'");
             if ($_G['connect']['t_log']) {
                 $_G['connect']['t_interval'] = 300;
                 $_G['connect']['t_publish_max'] = 1000;
                 if ($_G['connect']['t_log'] && $_G['member']['conisbind'] && $_G['uid'] == $_G['forum_thread']['authorid']) {
                     if ($_G['connect']['t_log']['status'] == 1 || $_G['connect']['t_log']['status'] == 2 && TIMESTAMP - $_G['connect']['t_log']['lastpublished'] > $_G['connect']['t_interval'] && $_G['connect']['t_log']['publishtimes'] < $_G['connect']['t_publish_max']) {
                         DB::query("UPDATE " . DB::table('connect_tlog') . " SET status='2', lastpublished='{$_G['timestamp']}', publishtimes=publishtimes+1 WHERE tid='{$_G['tid']}' AND status!=4");
                         $_G['connect']['t_js'] = $tlogstatus = true;
                     }
                 }
             } else {
                 $tlogstatus = true;
             }
         }
         if ($feedlogstatus || $tlogstatus) {
             $newstatus = $_G['forum_thread']['status'];
             $newstatus = $feedlogstatus ? setstatus(7, 1, $newstatus) : $newstatus;
             $newstatus = $tlogstatus ? setstatus(8, 1, $newstatus) : $newstatus;
             DB::query("UPDATE " . DB::table('forum_thread') . " SET status='{$newstatus}' WHERE tid='{$_G['tid']}'");
         }
         $_G['connect']['thread_url'] = $_G['siteurl'] . $GLOBALS['canonical'];
         $_G['connect']['qzone_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=1&thread_id=' . $_G['tid'];
         $_G['connect']['weibo_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=2&thread_id=' . $_G['tid'];
         $_G['connect']['pengyou_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=share&sh_type=3&thread_id=' . $_G['tid'];
         $_G['connect']['qzone_share_api'] = $_G['connect']['qzone_public_share_url'] . '?url=' . urlencode($_G['connect']['thread_url']);
         $_G['connect']['pengyou_share_api'] = $_G['connect']['qzone_public_share_url'] . '?to=pengyou&url=' . urlencode($_G['connect']['thread_url']);
         $params = array('oauth_consumer_key' => $_G['setting']['connectappid'], 'title' => $GLOBALS['postlist'][$_G['forum_firstpid']]['subject'], 'url' => $_G['connect']['thread_url']);
         $params['sig'] = connect_get_sig($params, connect_get_sig_key());
         $_G['connect']['t_share_api'] = $_G['connect']['url'] . '/mblog/redirect?' . cloud_http_build_query($params, '', '&');
         $_G['connect']['first_post'] = daddslashes($GLOBALS['postlist'][$_G['forum_firstpid']]);
         $_G['gp_connect_autoshare'] = !empty($_G['gp_connect_autoshare']) ? 1 : 0;
         $_G['connect']['weibo_appkey'] = $_G['connect']['weibo_public_appkey'];
         if ($this->allow && $_G['setting']['connect']['mblog_app_key']) {
             $_G['connect']['weibo_appkey'] = $_G['setting']['connect']['mblog_app_key'];
         }
         $extrajs = '';
         if ($_G['connect']['feed_js'] || $_G['connect']['t_js']) {
             $params = array();
             $params['thread_id'] = $_G['tid'];
             $params['ts'] = TIMESTAMP;
             $params['type'] = bindec(($_G['connect']['t_js'] ? '1' : '0') . ($_G['connect']['feed_js'] ? '1' : '0'));
             $params['sig'] = connect_get_sig($params, connect_get_sig_key());
             $jsurl = $_G['connect']['discuz_new_feed_url'] . '&' . cloud_http_build_query($params, '', '&');
             $extrajs = connect_output_javascript($jsurl);
         }
         if (!$_G['member']['conisbind'] && $_G['group']['allowgetimage'] && $_G['thread']['price'] == 0) {
             if ($_G['connect']['first_post']['message']) {
                 require_once libfile('function/connect');
                 $post['html_content'] = connect_parse_bbcode($_G['connect']['first_post']['message'], $_G['connect']['first_post']['fid'], $_G['connect']['first_post']['pid'], $_G['connect']['first_post']['htmlon'], $attach_images);
                 if ($attach_images && is_array($attach_images)) {
                     $attach_images = array_slice($attach_images, 0, 3);
                     $share_images = array();
                     foreach ($attach_images as $attach_image) {
                         $share_images[] = urlencode($attach_image['big']);
                     }
                     $_G['connect']['share_images'] = implode('|', $share_images);
                     unset($share_images);
                 }
             }
         }
         connect_merge_member();
         return tpl_viewthread_share_method() . $extrajs;
     }
 }
Exemple #19
0
 $online = 0;
 foreach ($result as $key => $value) {
     if ($value['authorid'] != $_G['uid']) {
         $msguser = $value['author'];
     }
     $daykey = dgmdate($value['dateline'], 'Y-m-d');
     $msglist[$daykey][$key] = $value;
 }
 if ($touid && empty($msguser)) {
     $member = getuserbyuid($touid);
     $msguser = $member['username'];
 }
 if (!$msgonly) {
     $online = C::app()->session->fetch_by_uid($touid) ? 1 : 0;
     if ($_G['member']['newpm']) {
         $newpm = setstatus(1, 0, $_G['member']['newpm']);
         C::t('common_member')->update($_G['uid'], array('newpm' => $newpm));
         uc_pm_ignore($_G['uid']);
     }
 }
 if (!empty($_GET['tradeid'])) {
     $trade = C::t('forum_trade')->fetch_goods(0, $_GET['tradeid']);
     if ($trade) {
         $messageappend = dhtmlspecialchars('[url=' . $_G['siteurl'] . 'forum.php?mod=viewthread&tid=' . $trade['tid'] . '&do=tradeinfo&pid=' . $trade['pid'] . '][b]' . $trade['subject'] . '[/b][/url]');
     }
 } elseif (!empty($_GET['commentid'])) {
     $comment = C::t('forum_postcomment')->fetch($_GET['commentid']);
     if ($comment) {
         $comment['comment'] = str_replace(array('[b]', '[/b]', '[/color]'), array(''), preg_replace("/\\[color=([#\\w]+?)\\]/i", '', strip_tags($comment['comment'])));
         $messageappend = dhtmlspecialchars('[url=' . $_G['siteurl'] . 'forum.php?mod=redirect&goto=findpost&pid=' . $comment['pid'] . '&ptid=' . $comment['tid'] . '][b]' . lang('spacecp', 'pm_comment') . '[/b][/url][quote]' . $comment['comment'] . '[/quote]');
     }
Exemple #20
0
                     dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
                 }
             }
         }
         if (($_DTYPE[$optionid]['search'] || in_array($_DTYPE[$optionid]['type'], array('radio', 'select', 'number'))) && $value) {
             $sql .= $separator . $_DTYPE[$optionid]['identifier'] . "='{$value}'";
             $separator = ' ,';
         }
         $db->query("UPDATE {$tablepre}typeoptionvars SET value='{$value}', sortid='{$sortid}' WHERE tid='{$tid}' AND optionid='{$optionid}'");
     }
     if ($sql) {
         $db->query("UPDATE {$tablepre}optionvalue{$sortid} SET {$sql} WHERE tid='{$tid}' AND fid='{$fid}'");
     }
 }
 $thread['status'] = setstatus(4, $ordertype, $thread['status']);
 $thread['status'] = setstatus(2, $hiddenreplies, $thread['status']);
 $db->query("UPDATE {$tablepre}threads SET iconid='{$iconid}', typeid='{$typeid}', sortid='{$sortid}', subject='{$subject}', readperm='{$readperm}', price='{$price}' {$authoradd} {$polladd} " . ($auditstatuson && $audit == 1 ? ",displayorder='0', moderated='1'" : '') . ", status='{$thread['status']}' WHERE tid='{$tid}'", 'UNBUFFERED');
 if ($tagstatus) {
     $tags = str_replace(array(chr(0xa3) . chr(0xac), chr(0xa1) . chr(0x41), chr(0xef) . chr(0xbc) . chr(0x8c)), ',', censor($tags));
     if (strexists($tags, ',')) {
         $tagarray = array_unique(explode(',', $tags));
     } else {
         $tags = str_replace(array(chr(0xa1) . chr(0xa1), chr(0xa1) . chr(0x40), chr(0xe3) . chr(0x80) . chr(0x80)), ' ', $tags);
         $tagarray = array_unique(explode(' ', $tags));
     }
     $threadtagsnew = array();
     $tagcount = 0;
     foreach ($tagarray as $tagname) {
         $tagname = trim($tagname);
         if (preg_match('/^([\\x7f-\\xff_-]|\\w|\\s){3,20}$/', $tagname)) {
             $threadtagsnew[] = $tagname;
 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']);
     }
 }
Exemple #22
0
             foreach ($floors as $key => $floor) {
                 if (strpos($floor, '*') === false) {
                     if (intval($floor) == 0) {
                         unset($floors[$key]);
                     } elseif ($floor > $_G['gp_stopfloor']) {
                         unset($floors[$key]);
                     }
                 }
             }
             $_G['gp_rewardfloor'] = implode(',', $floors);
         }
     }
     $thread['status'] = setstatus(3, 1, $thread['status']);
     $thread['status'] = setstatus(1, 1, $thread['status']);
 }
 $_G['gp_allownoticeauthor'] && ($thread['status'] = setstatus(6, 1, $thread['status']));
 $isgroup = $_G['forum']['status'] == 3 ? 1 : 0;
 if ($_G['group']['allowreplycredit']) {
     $_G['gp_replycredit_extcredits'] = intval($_G['gp_replycredit_extcredits']);
     $_G['gp_replycredit_times'] = intval($_G['gp_replycredit_times']);
     $_G['gp_replycredit_membertimes'] = intval($_G['gp_replycredit_membertimes']);
     $_G['gp_replycredit_random'] = intval($_G['gp_replycredit_random']);
     $_G['gp_replycredit_random'] = $_G['gp_replycredit_random'] < 0 || $_G['gp_replycredit_random'] > 99 ? 0 : $_G['gp_replycredit_random'];
     $replycredit = $replycredit_real = 0;
     if ($_G['gp_replycredit_extcredits'] > 0 && $_G['gp_replycredit_times'] > 0) {
         $replycredit_real = ceil($_G['gp_replycredit_extcredits'] * $_G['gp_replycredit_times'] + $_G['gp_replycredit_extcredits'] * $_G['gp_replycredit_times'] * $_G['setting']['creditstax']);
         if ($replycredit_real > getuserprofile('extcredits' . $_G['setting']['creditstransextra'][10])) {
             showmessage('replycredit_morethan_self');
         } else {
             $replycredit = ceil($_G['gp_replycredit_extcredits'] * $_G['gp_replycredit_times']);
         }
 public function makeSearchSignUrl()
 {
     global $_G;
     $url = '';
     $params = array();
     $mySearchData = $_G['setting']['my_search_data'];
     $mySiteId = $_G['setting']['my_siteid'];
     $mySiteKey = $_G['setting']['my_sitekey'];
     $cloudAppService = Cloud::loadClass('Service_App');
     if ($mySearchData['status'] && $cloudAppService->getCloudAppStatus('search') && $mySiteId) {
         $myExtGroupIds = array();
         $_extGroupIds = explode("\t", $_G['member']['extgroupids']);
         foreach ($_extGroupIds as $v) {
             if ($v) {
                 $myExtGroupIds[] = $v;
             }
         }
         $myExtGroupIdsStr = implode(',', $myExtGroupIds);
         $params = array('sId' => $mySiteId, 'ts' => time(), 'cuId' => $_G['uid'], 'cuName' => $_G['username'], 'gId' => intval($_G['groupid']), 'agId' => intval($_G['adminid']), 'egIds' => $myExtGroupIdsStr, 'fmSign' => '');
         $groupIds = array($params['gId']);
         if ($params['agId']) {
             $groupIds[] = $params['agId'];
         }
         if ($myExtGroupIds) {
             $groupIds = array_merge($groupIds, $myExtGroupIds);
         }
         $groupIds = array_unique($groupIds);
         foreach ($groupIds as $v) {
             $key = 'ugSign' . $v;
             $params[$key] = '';
         }
         $extraParams = array();
         if (isset($_G['setting']['verify']['enabled']) && $_G['setting']['verify']['enabled']) {
             $verifyGroups = C::t('common_member_verify')->fetch($_G['uid']);
             $extraParams['ext_vgIds'] = 0;
             foreach ($verifyGroups as $k => $v) {
                 if ($k != 'uid') {
                     $position = dintval(substr($k, strlen('verify')));
                     $extraParams['ext_vgIds'] = setstatus($position, dintval($v), $extraParams['ext_vgIds']);
                 }
             }
         }
         if ($_G['cookie']['ffids' . $_G['uid']]) {
             $ext_ffids = str_replace('D', ',', authcode($_G['cookie']['ffids' . $_G['uid']], 'DECODE'));
             $extraParams['ext_ffids'] = $ext_ffids;
         }
         if (!empty($extraParams)) {
             ksort($extraParams);
             $params = array_merge($params, $extraParams);
         }
         $params['sign'] = md5(implode('|', $params) . '|' . $mySiteKey);
         if ($cloudAppService->getCloudAppStatus('connect') && $_G['member']['conopenid']) {
             $connectService = Cloud::loadClass('Service_Connect');
             $connectService->connectMergeMember();
             $params['openid'] = $_G['member']['conopenid'];
         }
         $params['charset'] = $_G['charset'];
         if ($mySearchData['domain']) {
             $domain = $mySearchData['domain'];
         } else {
             $domain = 'search.discuz.qq.com';
         }
         $url = 'http://' . $domain . '/f/discuz';
     }
     return !empty($url) ? array('url' => $url, 'params' => $params) : array();
 }
 public static function getPostSendStatus($type = 'topic', $platType = APP_TYPE_ANDROID)
 {
     // return $platType == APP_TYPE_APPLE ? DzForumPost::STATUS_SEND_FROM_APP_APPLE : DzForumPost::STATUS_SEND_FROM_APP_ANDROID;
     // topic 的15位的apple status代码有冲突,故改为与apple相同
     return $platType == APP_TYPE_APPLE && $type == 'post' ? setstatus(15, 1) : setstatus(16, 1);
 }
Exemple #25
0
 $typeexpiration = intval($typeexpiration);
 if ($forum['threadsorts']['expiration'][$typeid] && !$typeexpiration) {
     showmessage('threadtype_expiration_invalid');
 }
 $optiondata = array();
 if ($forum['threadsorts']['types'][$sortid] && !$forum['allowspecialonly']) {
     $optiondata = threadsort_validator($typeoption);
 }
 $author = !$isanonymous ? $discuz_user : '';
 $moderated = $digest || $displayorder > 0 ? 1 : 0;
 $thread['status'] = 0;
 $ordertype && ($thread['status'] = setstatus(4, 1, $thread['status']));
 $hiddenreplies && ($thread['status'] = setstatus(2, 1, $thread['status']));
 if ($allowpostrushreply && $rushreply) {
     $thread['status'] = setstatus(3, 1, $thread['status']);
     $thread['status'] = setstatus(1, 1, $thread['status']);
 }
 $db->query("INSERT INTO {$tablepre}threads (fid, readperm, price, iconid, typeid, sortid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, special, attachment, moderated, status)\r\n\t\tVALUES ('{$fid}', '{$readperm}', '{$price}', '{$iconid}', '{$typeid}', '{$sortid}', '{$author}', '{$discuz_uid}', '{$subject}', '{$timestamp}', '{$timestamp}', '{$author}', '{$displayorder}', '{$digest}', '{$special}', '0', '{$moderated}', '{$thread['status']}')");
 $tid = $db->insert_id();
 if ($discuz_uid) {
     $stataction = '';
     if ($attentionon) {
         $stataction = 'attentionon';
         $db->query("REPLACE INTO {$tablepre}favoritethreads (tid, uid, dateline) VALUES ('{$tid}', '{$discuz_uid}', '{$timestamp}')", 'UNBUFFERED');
     }
     if ($stataction) {
         write_statlog('', 'item=attention&action=newthread_' . $stataction, '', '', 'my.php');
     }
     $db->query("UPDATE {$tablepre}favoriteforums SET newthreads=newthreads+1 WHERE fid='{$fid}' AND uid<>'{$discuz_uid}'", 'UNBUFFERED');
 }
 if ($special == 3 && $allowpostreward) {
Exemple #26
0
     if ($typeexpiration) {
         DB::query("UPDATE " . DB::table('forum_typeoptionvar') . " SET expiration='" . (TIMESTAMP + $typeexpiration) . "' WHERE tid='{$_G['tid']}' AND sortid='{$sortid}'");
     }
     if ($sql || $filedname && $valuelist) {
         if (DB::result_first("SELECT tid FROM " . DB::table('forum_optionvalue') . "{$sortid} WHERE tid='{$_G['tid']}'")) {
             if ($sql) {
                 DB::query("UPDATE " . DB::table('forum_optionvalue') . "{$sortid} SET {$sql} WHERE tid='{$_G['tid']}' AND fid='{$_G['fid']}'");
             }
         } elseif ($filedname && $valuelist) {
             DB::query("INSERT INTO " . DB::table('forum_optionvalue') . "{$sortid} ({$filedname}, tid, fid) VALUES ({$valuelist}, '{$_G['tid']}', '{$_G['fid']}')");
         }
     }
 }
 $thread['status'] = setstatus(4, $_G['gp_ordertype'], $thread['status']);
 $thread['status'] = setstatus(2, $_G['gp_hiddenreplies'], $thread['status']);
 $thread['status'] = setstatus(6, $_G['gp_allownoticeauthor'] ? 1 : 0, $thread['status']);
 $displayorder = empty($_G['gp_save']) ? $thread['displayorder'] == -4 ? 0 : $thread['displayorder'] : -4;
 if ($isorigauthor && $_G['group']['allowreplycredit']) {
     $_POST['replycredit_extcredits'] = intval($_POST['replycredit_extcredits']);
     $_POST['replycredit_times'] = intval($_POST['replycredit_times']);
     $_POST['replycredit_membertimes'] = intval($_POST['replycredit_membertimes']) > 0 ? intval($_POST['replycredit_membertimes']) : 1;
     $_POST['replycredit_random'] = intval($_POST['replycredit_random']) < 0 || intval($_POST['replycredit_random']) > 99 ? 0 : intval($_POST['replycredit_random']);
     if ($_POST['replycredit_extcredits'] > 0 && $_POST['replycredit_times'] > 0) {
         $replycredit = $_POST['replycredit_extcredits'] * $_POST['replycredit_times'];
         $replycredit_diff = $replycredit - $thread['replycredit'];
         if ($replycredit_diff > 0) {
             $replycredit_diff = ceil($replycredit_diff + $replycredit_diff * $_G['setting']['creditstax']);
             if (!$replycredit_rule) {
                 $replycredit_rule = array();
                 if ($_G['setting']['creditstransextra']['10']) {
                     $replycredit_rule['extcreditstype'] = $_G['setting']['creditstransextra']['10'];
            require_once libfile('function/discuzcode');
            $message = discuzcode($message, $savepost['smileyoff'], $savepost['bbcodeoff'], $savepost['htmlon']);
        }
        $message = $message ? $message : '&nbsp;';
    }
    include template('common/header_ajax');
    echo $message;
    include template('common/footer_ajax');
    exit;
} elseif ($_GET['action'] == 'replynotice') {
    $tid = intval($_GET['tid']);
    $status = $_GET['op'] == 'ignore' ? 0 : 1;
    if (!empty($tid)) {
        $thread = C::t('forum_thread')->fetch_by_tid_displayorder($tid, 0);
        if ($thread['authorid'] == $_G['uid']) {
            $thread['status'] = setstatus(6, $status, $thread['status']);
            C::t('forum_thread')->update($tid, array('status' => $thread['status']), true);
            showmessage('replynotice_success_' . $status);
        }
    }
    showmessage('replynotice_error', 'forum.php?mod=viewthread&tid=' . $tid);
} elseif ($_GET['action'] == 'removeindexheats') {
    if ($_G['adminid'] != 1) {
        showmessage('no_privilege_indexheats');
    }
    C::t('forum_thread')->update($_G['tid'], array('heats' => 0));
    require_once libfile('function/cache');
    updatecache('heats');
    dheader('Location: ' . dreferer());
} else {
    if (empty($_G['forum']['allowview'])) {
Exemple #28
0
 private function sendPost($extract)
 {
     global $_G;
     extract($extract);
     // 获取主题和帖子要插入的状态信息
     $topicStatus = ForumUtils::getPostSendStatus('topic', $_GET['platType']);
     $postStatus = ForumUtils::getPostSendStatus('post', $_GET['platType']);
     //copy from dz source/include/post/post_newthread.php
     if (empty($_G['forum']['fid']) || $_G['forum']['type'] == 'group') {
         return WebUtils::makeErrorInfo_oldVersion($res, 'forum_nonexistence');
     }
     if ($special == 1 && !$_G['group']['allowpostpoll'] || $special == 2 && !$_G['group']['allowposttrade'] || $special == 3 && !$_G['group']['allowpostreward'] || $special == 4 && !$_G['group']['allowpostactivity'] || $special == 5 && !$_G['group']['allowpostdebate']) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'group_nopermission', array('{grouptitle}' => $_G['group']['grouptitle']));
     }
     if (!$_G['uid'] && !(!$_G['forum']['postperm'] && $_G['group']['allowpost'] || $_G['forum']['postperm'] && forumperm($_G['forum']['postperm']))) {
         if (!defined('IN_MOBILE')) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_login_nopermission', array('{login}' => 1));
         } else {
             return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_login_nopermission_mobile', array('{login}' => 1));
         }
     } elseif (empty($_G['forum']['allowpost'])) {
         if (!$_G['forum']['postperm'] && !$_G['group']['allowpost']) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_none_nopermission');
         } elseif ($_G['forum']['postperm'] && !forumperm($_G['forum']['postperm'])) {
             $msg = mobcent_showmessagenoperm('postperm', $_G['fid'], $_G['forum']['formulaperm']);
             return WebUtils::makeErrorInfo_oldVersion($res, $msg['message'], $msg['params']);
         }
     } elseif ($_G['forum']['allowpost'] == -1) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_forum_newthread_nopermission');
     }
     if (!$_G['uid'] && ($_G['setting']['need_avatar'] || $_G['setting']['need_email'] || $_G['setting']['need_friendnum'])) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_login_nopermission');
     }
     if (trim($subject) == '') {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_sm_isnull');
     }
     if (!$sortid && !$special && trim($message) == '') {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_sm_isnull');
     }
     if ($post_invalid = checkpost($subject, $message, $special || $sortid)) {
         return WebUtils::makeErrorInfo_oldVersion($res, $post_invalid, array('{minpostsize}' => $_G['setting']['minpostsize'], '{maxpostsize}' => $_G['setting']['maxpostsize']));
         //showmessage($post_invalid, '', array('minpostsize' => $_G['setting']['minpostsize'], 'maxpostsize' => $_G['setting']['maxpostsize']));
     }
     if (checkflood()) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_flood_ctrl', array('{floodctrl}' => $_G['setting']['floodctrl']));
     } elseif (checkmaxperhour('tid')) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'thread_flood_ctrl_threads_per_hour', array('{threads_per_hour}' => $_G['group']['maxthreadsperhour']));
     }
     $_GET['save'] = $_G['uid'] ? $_GET['save'] : 0;
     if ($_G['group']['allowsetpublishdate'] && $_GET['cronpublish'] && $_GET['cronpublishdate']) {
         $publishdate = strtotime($_GET['cronpublishdate']);
         if ($publishdate > $_G['timestamp']) {
             $_GET['save'] = 1;
         } else {
             $publishdate = $_G['timestamp'];
         }
     } else {
         $publishdate = $_G['timestamp'];
     }
     $typeid = isset($typeid) && isset($_G['forum']['threadtypes']['types'][$typeid]) && (empty($_G['forum']['threadtypes']['moderators'][$typeid]) || $_G['forum']['ismoderator']) ? $typeid : 0;
     $displayorder = $modnewthreads ? -2 : ($_G['forum']['ismoderator'] && $_G['group']['allowstickthread'] && !empty($_GET['sticktopic']) ? 1 : (empty($_GET['save']) ? 0 : -4));
     if ($displayorder == -2) {
         C::t('forum_forum')->update($_G['fid'], array('modworks' => '1'));
     } elseif ($displayorder == -4) {
         $_GET['addfeed'] = 0;
     }
     $digest = $_G['forum']['ismoderator'] && $_G['group']['allowdigestthread'] && !empty($_GET['addtodigest']) ? 1 : 0;
     $readperm = $_G['group']['allowsetreadperm'] ? $readperm : 0;
     $isanonymous = $_G['group']['allowanonymous'] && $_GET['isanonymous'] ? 1 : 0;
     $price = intval($price);
     $price = $_G['group']['maxprice'] && !$special ? $price <= $_G['group']['maxprice'] ? $price : $_G['group']['maxprice'] : 0;
     //强制主题类别判断
     if (!$typeid && $_G['forum']['threadtypes']['required'] && !$special) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_type_isnull');
     }
     //强制主题分类判断
     if (!$sortid && $_G['forum']['threadsorts']['required'] && !$special) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_sort_isnull');
     }
     //主题售价 客户端暂不支持
     if ($price > 0 && floor($price * (1 - $_G['setting']['creditstax'])) == 0) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
         showmessage('post_net_price_iszero');
     }
     //投票贴相关
     if ($special == 1) {
         $polloption = $_GET['tpolloption'] == 2 ? explode("\n", $_GET['polloptions']) : $_GET['polloption'];
         $pollarray = array();
         foreach ($polloption as $key => $value) {
             $polloption[$key] = censor($polloption[$key]);
             if (trim($value) === '') {
                 unset($polloption[$key]);
             }
         }
         if (count($polloption) > $_G['setting']['maxpolloptions']) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('post_poll_option_toomany', '', array('maxpolloptions' => $_G['setting']['maxpolloptions']));
         } elseif (count($polloption) < 2) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('post_poll_inputmore');
         }
         $curpolloption = count($polloption);
         $pollarray['maxchoices'] = empty($_GET['maxchoices']) ? 0 : ($_GET['maxchoices'] > $curpolloption ? $curpolloption : $_GET['maxchoices']);
         $pollarray['multiple'] = empty($_GET['maxchoices']) || $_GET['maxchoices'] == 1 ? 0 : 1;
         $pollarray['options'] = $polloption;
         $pollarray['visible'] = empty($_GET['visibilitypoll']);
         $pollarray['overt'] = !empty($_GET['overt']);
         if (preg_match("/^\\d*\$/", trim($_GET['expiration']))) {
             if (empty($_GET['expiration'])) {
                 $pollarray['expiration'] = 0;
             } else {
                 $pollarray['expiration'] = TIMESTAMP + 86400 * $_GET['expiration'];
             }
         } else {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('poll_maxchoices_expiration_invalid');
         }
     }
     // 分类信息有效期
     $_GET['typeexpiration'] = $_GET['typeoption']['typeexpiration'];
     $sortid = $special && $_G['forum']['threadsorts']['types'][$sortid] ? 0 : $sortid;
     $typeexpiration = intval($_GET['typeexpiration']);
     if ($_G['forum']['threadsorts']['expiration'][$typeid] && !$typeexpiration) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'threadtype_expiration_invalid');
     }
     $_G['forum_optiondata'] = array();
     if ($_G['forum']['threadsorts']['types'][$sortid] && !$_G['forum']['allowspecialonly']) {
         Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_threadsort.php');
         $_G['forum_optiondata'] = mobcent_threadsort_validator($_GET['typeoption'], $pid);
         if ($_G['forum_optiondata']['message'] != '') {
             return WebUtils::makeErrorInfo_oldVersion($res, $_G['forum_optiondata']['message'], $_G['forum_optiondata']['params']);
         }
     }
     $author = !$isanonymous ? $_G['username'] : '';
     $moderated = $digest || $displayorder > 0 ? 1 : 0;
     $thread['status'] = 0;
     $_GET['ordertype'] && ($thread['status'] = setstatus(4, 1, $thread['status']));
     $_GET['hiddenreplies'] && ($thread['status'] = setstatus(2, 1, $thread['status']));
     /*             if($_G['group']['allowpostrushreply'] && $_GET['rushreply']) {
              $_GET['rushreplyfrom'] = strtotime($_GET['rushreplyfrom']);
             $_GET['rushreplyto'] = strtotime($_GET['rushreplyto']);
             $_GET['rewardfloor'] = trim($_GET['rewardfloor']);
             $_GET['stopfloor'] = intval($_GET['stopfloor']);
             $_GET['creditlimit'] = $_GET['creditlimit'] == '' ? '-996' : intval($_GET['creditlimit']);
             if($_GET['rushreplyfrom'] > $_GET['rushreplyto'] && !empty($_GET['rushreplyto'])) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('post_rushreply_timewrong');
             }
             if(($_GET['rushreplyfrom'] > $_G['timestamp']) || (!empty($_GET['rushreplyto']) && $_GET['rushreplyto'] < $_G['timestamp']) || ($_GET['stopfloor'] == 1) ) {
             $closed = true;
             }
             if(!empty($_GET['rewardfloor']) && !empty($_GET['stopfloor'])) {
             $floors = explode(',', $_GET['rewardfloor']);
             if(!empty($floors) && is_array($floors)) {
             foreach($floors AS $key => $floor) {
             if(strpos($floor, '*') === false) {
             if(intval($floor) == 0) {
             unset($floors[$key]);
             } elseif($floor > $_GET['stopfloor']) {
             unset($floors[$key]);
             }
             }
             }
             $_GET['rewardfloor'] = implode(',', $floors);
             }
             }
             $thread['status'] = setstatus(3, 1, $thread['status']);
             $thread['status'] = setstatus(1, 1, $thread['status']);
             } */
     $_GET['allownoticeauthor'] && ($thread['status'] = setstatus(6, 1, $thread['status']));
     $isgroup = $_G['forum']['status'] == 3 ? 1 : 0;
     /*  if($_G['group']['allowreplycredit']) {
              $_GET['replycredit_extcredits'] = intval($_GET['replycredit_extcredits']);
             $_GET['replycredit_times'] = intval($_GET['replycredit_times']);
             $_GET['replycredit_membertimes'] = intval($_GET['replycredit_membertimes']);
             $_GET['replycredit_random'] = intval($_GET['replycredit_random']);
     
             $_GET['replycredit_random'] = $_GET['replycredit_random'] < 0 || $_GET['replycredit_random'] > 99 ? 0 : $_GET['replycredit_random'] ;
             $replycredit = $replycredit_real = 0;
             if($_GET['replycredit_extcredits'] > 0 && $_GET['replycredit_times'] > 0) {
             $replycredit_real = ceil(($_GET['replycredit_extcredits'] * $_GET['replycredit_times']) + ($_GET['replycredit_extcredits'] * $_GET['replycredit_times'] *  $_G['setting']['creditstax']));
             if($replycredit_real > getuserprofile('extcredits'.$_G['setting']['creditstransextra'][10])) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('replycredit_morethan_self');
             } else {
             $replycredit = ceil($_GET['replycredit_extcredits'] * $_GET['replycredit_times']);
             }
             }
             } */
     $newthread = array('fid' => $_G['fid'], 'posttableid' => 0, 'readperm' => $readperm, 'price' => $price, 'typeid' => $typeid, 'sortid' => $sortid, 'author' => $author, 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $publishdate, 'lastpost' => $publishdate, 'lastposter' => $author, 'displayorder' => $displayorder, 'digest' => $digest, 'special' => $special, 'attachment' => 0, 'moderated' => $moderated, 'status' => $thread['status'] | $topicStatus, 'isgroup' => $isgroup, 'replycredit' => $replycredit, 'closed' => $closed ? 1 : 0);
     $tid = C::t('forum_thread')->insert($newthread, true);
     useractionlog($_G['uid'], 'tid');
     if (!getuserprofile('threads') && $_G['setting']['newbie']) {
         C::t('forum_thread')->update($tid, array('icon' => $_G['setting']['newbie']));
     }
     if ($publishdate != $_G['timestamp']) {
         loadcache('cronpublish');
         $cron_publish_ids = dunserialize($_G['cache']['cronpublish']);
         $cron_publish_ids[$tid] = $tid;
         $cron_publish_ids = serialize($cron_publish_ids);
         savecache('cronpublish', $cron_publish_ids);
     }
     if (!$isanonymous) {
         C::t('common_member_field_home')->update($_G['uid'], array('recentnote' => $subject));
     }
     if ($special == 3 && $_G['group']['allowpostreward']) {
         updatemembercount($_G['uid'], array($_G['setting']['creditstransextra'][2] => -$realprice), 1, 'RTC', $tid);
     }
     if ($moderated) {
         updatemodlog($tid, $displayorder > 0 ? 'STK' : 'DIG');
         updatemodworks($displayorder > 0 ? 'STK' : 'DIG', 1);
     }
     /* if($special == 1) {
     
             foreach($pollarray['options'] as $polloptvalue) {
             $polloptvalue = dhtmlspecialchars(trim($polloptvalue));
             C::t('forum_polloption')->insert(array('tid' => $tid, 'polloption' => $polloptvalue));
             }
             $polloptionpreview = '';
             $query = C::t('forum_polloption')->fetch_all_by_tid($tid, 1, 2);
             foreach($query as $option) {
             $polloptvalue = preg_replace("/\[url=(https?){1}:\/\/([^\[\"']+?)\](.+?)\[\/url\]/i", "<a href=\"\\1://\\2\" target=\"_blank\">\\3</a>", $option['polloption']);
             $polloptionpreview .= $polloptvalue."\t";
             }
     
             $polloptionpreview = daddslashes($polloptionpreview);
     
             $data = array('tid' => $tid, 'multiple' => $pollarray['multiple'], 'visible' => $pollarray['visible'], 'maxchoices' => $pollarray['maxchoices'], 'expiration' => $pollarray['expiration'], 'overt' => $pollarray['overt'], 'pollpreview' => $polloptionpreview);
             C::t('forum_poll')->insert($data);
             } */
     if ($_G['forum']['threadsorts']['types'][$sortid] && !empty($_G['forum_optiondata']) && is_array($_G['forum_optiondata'])) {
         $filedname = $valuelist = $separator = '';
         foreach ($_G['forum_optiondata'] as $optionid => $value) {
             if ($value) {
                 $filedname .= $separator . $_G['forum_optionlist'][$optionid]['identifier'];
                 $valuelist .= $separator . "'" . daddslashes($value) . "'";
                 $separator = ' ,';
             }
             if ($_G['forum_optionlist'][$optionid]['type'] == 'image') {
                 $identifier = $_G['forum_optionlist'][$optionid]['identifier'];
                 $sortaids[] = intval($_GET['typeoption'][$identifier]['aid']);
             }
             C::t('forum_typeoptionvar')->insert(array('sortid' => $sortid, 'tid' => $tid, 'fid' => $_G['fid'], 'optionid' => $optionid, 'value' => censor($value), 'expiration' => $typeexpiration ? $publishdate + $typeexpiration : 0));
         }
         if ($filedname && $valuelist) {
             C::t('forum_optionvalue')->insert($sortid, "({$filedname}, tid, fid) VALUES ({$valuelist}, '{$tid}', '{$_G['fid']}')");
         }
     }
     if ($_G['group']['allowat']) {
         $atlist = $atlist_tmp = array();
         preg_match_all("/@([^\r\n]*?)\\s/i", $message . ' ', $atlist_tmp);
         $atlist_tmp = array_slice(array_unique($atlist_tmp[1]), 0, $_G['group']['allowat']);
         if (!empty($atlist_tmp)) {
             if (empty($_G['setting']['at_anyone'])) {
                 foreach (C::t('home_follow')->fetch_all_by_uid_fusername($_G['uid'], $atlist_tmp) as $row) {
                     $atlist[$row['followuid']] = $row['fusername'];
                 }
                 if (count($atlist) < $_G['group']['allowat']) {
                     $query = C::t('home_friend')->fetch_all_by_uid_username($_G['uid'], $atlist_tmp);
                     foreach ($query as $row) {
                         $atlist[$row['fuid']] = $row['fusername'];
                     }
                 }
             } else {
                 foreach (C::t('common_member')->fetch_all_by_username($atlist_tmp) as $row) {
                     $atlist[$row['uid']] = $row['username'];
                 }
             }
         }
         if ($atlist) {
             foreach ($atlist as $atuid => $atusername) {
                 $atsearch[] = "/@" . str_replace('/', '\\/', preg_quote($atusername)) . " /i";
                 $atreplace[] = "[url=home.php?mod=space&uid={$atuid}]@{$atusername}[/url] ";
             }
             $message = preg_replace($atsearch, $atreplace, $message . ' ', 1);
         }
     }
     $bbcodeoff = checkbbcodes($message, !empty($_GET['bbcodeoff']));
     $smileyoff = checksmilies($message, !empty($_GET['smileyoff']));
     $parseurloff = !empty($_GET['parseurloff']);
     $htmlon = $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0;
     $usesig = !empty($_GET['usesig']) && $_G['group']['maxsigsize'] ? 1 : 0;
     $class_tag = new tag();
     $tagstr = $class_tag->add_tag($_GET['tags'], $tid, 'tid');
     /* if($_G['group']['allowreplycredit']) {
         if($replycredit > 0 && $replycredit_real > 0) {
        updatemembercount($_G['uid'], array('extcredits'.$_G['setting']['creditstransextra'][10] => -$replycredit_real), 1, 'RCT', $tid);
        $insertdata = array(
                'tid' => $tid,
                'extcredits' => $_GET['replycredit_extcredits'],
                'extcreditstype' => $_G['setting']['creditstransextra'][10],
                'times' => $_GET['replycredit_times'],
                'membertimes' => $_GET['replycredit_membertimes'],
                'random' => $_GET['replycredit_random']
        );
        C::t('forum_replycredit')->insert($insertdata);
        }
        } */
     if ($_G['group']['allowpostrushreply'] && $_GET['rushreply']) {
         $rushdata = array('tid' => $tid, 'stopfloor' => $_GET['stopfloor'], 'starttimefrom' => $_GET['rushreplyfrom'], 'starttimeto' => $_GET['rushreplyto'], 'rewardfloor' => $_GET['rewardfloor'], 'creditlimit' => $_GET['creditlimit']);
         C::t('forum_threadrush')->insert($rushdata);
     }
     $pinvisible = $modnewthreads ? -2 : (empty($_GET['save']) ? 0 : -3);
     $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message);
     $pid = insertpost(array('fid' => $_G['fid'], 'tid' => $tid, 'first' => '1', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $publishdate, 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => $pinvisible, 'anonymous' => $isanonymous, 'usesig' => $usesig, 'htmlon' => $htmlon, 'bbcodeoff' => $bbcodeoff, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => '0', 'tags' => $tagstr, 'replycredit' => 0, 'status' => (defined('IN_MOBILE') ? 8 : 0) | $postStatus));
     if ($_G['group']['allowat'] && $atlist) {
         foreach ($atlist as $atuid => $atusername) {
             notification_add($atuid, 'at', 'at_message', array('from_id' => $tid, 'from_idtype' => 'at', 'buyerid' => $_G['uid'], 'buyer' => $_G['username'], 'tid' => $tid, 'subject' => $subject, 'pid' => $pid, 'message' => messagecutstr($message, 150)));
         }
         set_atlist_cookie(array_keys($atlist));
     }
     $threadimageaid = 0;
     $threadimage = array();
     if ($special == 4 && $_GET['activityaid']) {
         $threadimageaid = $_GET['activityaid'];
         convertunusedattach($_GET['activityaid'], $tid, $pid);
     }
     if ($_G['forum']['threadsorts']['types'][$sortid] && !empty($_G['forum_optiondata']) && is_array($_G['forum_optiondata']) && $sortaids) {
         foreach ($sortaids as $sortaid) {
             convertunusedattach($sortaid, $tid, $pid);
         }
     }
     if (($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) && ($_GET['attachnew'] || $sortid || !empty($_GET['activityaid']))) {
         updateattach($displayorder == -4 || $modnewthreads, $tid, $pid, $_GET['attachnew']);
         if (!$threadimageaid) {
             $threadimage = C::t('forum_attachment_n')->fetch_max_image('tid:' . $tid, 'tid', $tid);
             $threadimageaid = $threadimage['aid'];
         }
     }
     $values = array('fid' => $_G['fid'], 'tid' => $tid, 'pid' => $pid, 'coverimg' => '', 'sechash' => !empty($_GET['sechash']) ? $_GET['sechash'] : '');
     $param = array();
     Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_post.php');
     if ($_G['forum']['picstyle']) {
         if (!mobcent_setthreadcover($pid, 0, $threadimageaid)) {
             preg_match_all("/(\\[img\\]|\\[img=\\d{1,4}[x|\\,]\\d{1,4}\\])\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/is", $message, $imglist, PREG_SET_ORDER);
             $values['coverimg'] = "<p id=\"showsetcover\">" . lang('message', 'post_newthread_set_cover') . "<span id=\"setcoverwait\"></span></p><script>if(\$('forward_a')){\$('forward_a').style.display='none';setTimeout(\"\$('forward_a').style.display=''\", 5000);};ajaxget('forum.php?mod=ajax&action=setthreadcover&tid={$tid}&pid={$pid}&fid={$_G['fid']}&imgurl={$imglist[0][2]}&newthread=1', 'showsetcover', 'setcoverwait')</script>";
             $param['clean_msgforward'] = 1;
             $param['timeout'] = $param['refreshtime'] = 15;
         }
     }
     if ($threadimageaid) {
         if (!$threadimage) {
             $threadimage = C::t('forum_attachment_n')->fetch('tid:' . $tid, $threadimageaid);
         }
         $threadimage = daddslashes($threadimage);
         C::t('forum_threadimage')->insert(array('tid' => $tid, 'attachment' => $threadimage['attachment'], 'remote' => $threadimage['remote']));
     }
     $statarr = array(0 => 'thread', 1 => 'poll', 2 => 'trade', 3 => 'reward', 4 => 'activity', 5 => 'debate', 127 => 'thread');
     include_once libfile('function/stat');
     updatestat($isgroup ? 'groupthread' : $statarr[$special]);
     if ($modnewthreads) {
         updatemoderate('tid', $tid);
         C::t('forum_forum')->update_forum_counter($_G['fid'], 0, 0, 1);
         manage_addnotify('verifythread');
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_newthread_mod_succeed', array('noError' => 1));
         //showmessage('post_newthread_mod_succeed', $returnurl, $values, $param);
     } else {
         if ($displayorder >= 0 && helper_access::check_module('follow') && !empty($_GET['adddynamic']) && !$isanonymous) {
             require_once libfile('function/discuzcode');
             require_once libfile('function/followcode');
             $feedcontent = array('tid' => $tid, 'content' => followcode($message, $tid, $pid, 1000));
             C::t('forum_threadpreview')->insert($feedcontent);
             C::t('forum_thread')->update_status_by_tid($tid, '512');
             $followfeed = array('uid' => $_G['uid'], 'username' => $_G['username'], 'tid' => $tid, 'note' => '', 'dateline' => TIMESTAMP);
             $values['feedid'] = C::t('home_follow_feed')->insert($followfeed, true);
             C::t('common_member_count')->increase($_G['uid'], array('feeds' => 1));
         }
         $feed = array('icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data' => array(), 'images' => array());
         if ($displayorder != -4) {
             if ($digest) {
                 updatepostcredits('+', $_G['uid'], 'digest', $_G['fid']);
             }
             //updatepostcredits('+',  $_G['uid'], 'post', $_G['fid']);
             Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_post.php');
             //Yii::import('application.components.discuz.source.function.function_post', true);
             mobcent_updatepostcredits('+', $_G['uid'], 'post', $_G['fid']);
             if ($isgroup) {
                 C::t('forum_groupuser')->update_counter_for_user($_G['uid'], $_G['fid'], 1);
             }
             $subject = str_replace("\t", ' ', $subject);
             $lastpost = "{$tid}\t" . $subject . "\t{$_G['timestamp']}\t{$author}";
             C::t('forum_forum')->update($_G['fid'], array('lastpost' => $lastpost));
             C::t('forum_forum')->update_forum_counter($_G['fid'], 1, 1, 1);
             if ($_G['forum']['type'] == 'sub') {
                 C::t('forum_forum')->update($_G['forum']['fup'], array('lastpost' => $lastpost));
             }
         }
         if ($_G['forum']['status'] == 3) {
             C::t('forum_forumfield')->update($_G['fid'], array('lastupdate' => TIMESTAMP));
             require_once libfile('function/grouplog');
             updategroupcreditlog($_G['fid'], $_G['uid']);
         }
         /*如果显示地理位置,入库到表里*/
         if ($jsonInfo['isShowPostion']) {
             $data = DB::query('INSERT INTO  %t VALUES(null,%f,%f,%d,%d,%s)', array('home_surrounding_user', $jsonInfo['longitude'], $jsonInfo['latitude'], $tid, 3, (string) $jsonInfo['location']));
         }
         /*  //客户端发表主题积分入库
                $temp = DB::fetch_first('SELECT extcredits3  FROM '.DB::table('common_credit_rule').' WHERE rid =%d ',array(1));
                $extcredits3 = DB::fetch_first('SELECT extcredits3 FROM '.DB::table('common_member_count').' WHERE uid = %d',array($_G['uid']));
                $temp = $extcredits3['extcredits3'] + $temp['extcredits3'];
                DB::query('UPDATE '.DB::table('common_member_count').' set extcredits3 = %d WHERE uid = %d',array($temp,$_G['uid']));
             */
         //showmessage('post_newthread_succeed', $returnurl, $values, $param);
         // return array('rs'=>1,'errcode'=>WebUtils::t('发贴成功'));
         return $this->makeErrorInfo($res, 'mobcent_post_newthread_success', array('noError' => 1));
     }
 }
 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';
     }
 }
                         }
                     }
                 }
             }
             foreach ($addoption as $id => $val) {
                 $optionid = DB::fetch_first("SELECT optionid FROM " . DB::table('forum_typeoption') . " WHERE optionid='{$id}'");
                 if ($optionid) {
                     $data = array('sortid' => $_G['gp_sortid'], 'optionid' => $id, 'available' => 1, 'required' => intval($val));
                     DB::insert('forum_typevar', $data, 0, 0, 1);
                     $search_bit = 0;
                     foreach ($_G['gp_search'][$id] as $key => $val) {
                         if ($val == 1) {
                             if ($key == 'font') {
                                 $search_bit = setstatus(2, 1, $search_bit);
                             } elseif ($key == 'form') {
                                 $search_bit = setstatus(1, 1, $search_bit);
                             }
                         }
                     }
                     DB::update('forum_typevar', array('displayorder' => $_G['gp_displayorder'][$id], 'available' => $_G['gp_available'][$id], 'required' => $_G['gp_required'][$id], 'unchangeable' => $_G['gp_unchangeable'][$id], 'search' => $search_bit, 'subjectshow' => $_G['gp_subjectshow'][$id]), "sortid='{$_G['gp_sortid']}' AND optionid='{$id}'");
                 } else {
                     DB::query("DELETE FROM " . DB::table('forum_typevar') . " WHERE sortid='{$_G['gp_sortid']}' AND optionid IN ({$id})");
                 }
             }
         }
         updatecache('threadsorts');
         cpmsg('threadtype_infotypes_succeed', 'action=threadtypes&operation=sortdetail&sortid=' . $_G['gp_sortid'], 'succeed');
     } elseif (submitcheck('sortpreviewsubmit')) {
         header("Location: {$_G['siteurl']}" . ADMINSCRIPT . "?action=threadtypes&operation=sortdetail&sortid={$_G['gp_sortid']}#template");
     }
 }