First commit

This commit is contained in:
2025-06-18 10:24:27 +08:00
commit ebc39cd5dd
3873 changed files with 412712 additions and 0 deletions

View File

@@ -0,0 +1,172 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_activity.php 35202 2015-02-04 08:07:39Z hypowang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_activity extends extend_thread_base {
public $activity;
public $activitytime;
public function before_newthread($parameters) {
$this->activitytime = intval($_GET['activitytime']);
if(empty($_GET['starttimefrom'][$this->activitytime])) {
showmessage('activity_fromtime_please');
} elseif(@strtotime($_GET['starttimefrom'][$this->activitytime]) === -1 || @strtotime($_GET['starttimefrom'][$this->activitytime]) === FALSE) {
showmessage('activity_fromtime_error');
} elseif($this->activitytime && ((@strtotime($_GET['starttimefrom'][$this->activitytime]) > @strtotime($_GET['starttimeto']) || !$_GET['starttimeto']))) {
showmessage('activity_fromtime_error');
} elseif(!trim($_GET['activityclass'])) {
showmessage('activity_sort_please');
} elseif(!trim($_GET['activityplace'])) {
showmessage('activity_address_please');
} elseif(trim($_GET['activityexpiration']) && (@strtotime($_GET['activityexpiration']) === -1 || @strtotime($_GET['activityexpiration']) === FALSE)) {
showmessage('activity_totime_error');
}
$this->activity = array();
$this->activity['class'] = censor(dhtmlspecialchars(trim($_GET['activityclass'])));
$this->activity['starttimefrom'] = @strtotime($_GET['starttimefrom'][$this->activitytime]);
$this->activity['starttimeto'] = $this->activitytime ? @strtotime($_GET['starttimeto']) : 0;
$this->activity['place'] = censor(dhtmlspecialchars(trim($_GET['activityplace'])));
$this->activity['cost'] = intval($_GET['cost']);
$this->activity['gender'] = intval($_GET['gender']);
$this->activity['number'] = intval($_GET['activitynumber']);
if($_GET['activityexpiration']) {
$this->activity['expiration'] = @strtotime($_GET['activityexpiration']);
} else {
$this->activity['expiration'] = 0;
}
if(trim($_GET['activitycity'])) {
$this->param['subject'] = $parameters['subject'].'['.dhtmlspecialchars(trim($_GET['activitycity'])).']';
}
$extfield = $_GET['extfield'];
$extfield = explode("\n", $_GET['extfield']);
foreach($extfield as $key => $value) {
$extfield[$key] = dhtmlspecialchars(strip_tags(censor(trim($value))));
if($extfield[$key] === '' || is_numeric($extfield[$key])) {
unset($extfield[$key]);
}
}
$extfield = array_unique($extfield);
if(count($extfield) > $this->setting['activityextnum']) {
showmessage('post_activity_extfield_toomany', '', array('maxextfield' => $this->setting['activityextnum']));
}
$this->activity['ufield'] = array('userfield' => $_GET['userfield'], 'extfield' => $extfield);
$this->activity['ufield'] = serialize($this->activity['ufield']);
if(intval($_GET['activitycredit']) > 0) {
$this->activity['credit'] = intval($_GET['activitycredit']);
}
$this->param['extramessage'] = "\t".$_GET['activityplace']."\t".$_GET['activitycity']."\t".$_GET['activityclass'];
}
public function after_newthread() {
if($this->group['allowpostactivity']) {
$data = array('tid' => $this->tid, 'uid' => $this->member['uid'], 'cost' => $this->activity['cost'], 'starttimefrom' => $this->activity['starttimefrom'], 'starttimeto' => $this->activity['starttimeto'], 'place' => $this->activity['place'], 'class' => $this->activity['class'], 'gender' => $this->activity['gender'], 'number' => $this->activity['number'], 'expiration' => $this->activity['expiration'], 'aid' => $_GET['activityaid'], 'ufield' => $this->activity['ufield'], 'credit' => $this->activity['credit']);
C::t('forum_activity')->insert($data);
}
}
public function before_feed() {
$message = !$this->param['price'] && !$this->param['readperm'] ? $this->param['message'] : '';
$this->feed['icon'] = 'activity';
$this->feed['title_template'] = 'feed_thread_activity_title';
$this->feed['body_template'] = 'feed_thread_activity_message';
$this->feed['body_data'] = array(
'subject' => "<a href=\"forum.php?mod=viewthread&tid={$this->tid}\">{$this->param['subject']}</a>",
'starttimefrom' => $_GET['starttimefrom'][$this->activitytime],
'activityplace'=> $this->activity['place'],
'message' => messagecutstr($message, 150),
);
if($_GET['activityaid']) {
$this->feed['images'] = array(getforumimg($_GET['activityaid']));
$this->feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$this->tid}&pid={$this->pid}");
}
}
public function before_editpost($parameters) {
$isfirstpost = $this->post['first'] ? 1 : 0;
if($isfirstpost) {
if($this->thread['special'] == 4 && $this->group['allowpostactivity']) {
$activitytime = intval($_GET['activitytime']);
if(empty($_GET['starttimefrom'][$activitytime])) {
showmessage('activity_fromtime_please');
} elseif(strtotime($_GET['starttimefrom'][$activitytime]) === -1 || @strtotime($_GET['starttimefrom'][$activitytime]) === FALSE) {
showmessage('activity_fromtime_error');
} elseif($activitytime && ((@strtotime($_GET['starttimefrom'][$activitytime]) > @strtotime($_GET['starttimeto']) || !$_GET['starttimeto']))) {
showmessage('activity_fromtime_error');
} elseif(!trim($_GET['activityclass'])) {
showmessage('activity_sort_please');
} elseif(!trim($_GET['activityplace'])) {
showmessage('activity_address_please');
} elseif(trim($_GET['activityexpiration']) && (@strtotime($_GET['activityexpiration']) === -1 || @strtotime($_GET['activityexpiration']) === FALSE)) {
showmessage('activity_totime_error');
}
$activity = array();
$activity['class'] = censor(dhtmlspecialchars(trim($_GET['activityclass'])));
$activity['starttimefrom'] = @strtotime($_GET['starttimefrom'][$activitytime]);
$activity['starttimeto'] = $activitytime ? @strtotime($_GET['starttimeto']) : 0;
$activity['place'] = censor(dhtmlspecialchars(trim($_GET['activityplace'])));
$activity['cost'] = intval($_GET['cost']);
$activity['gender'] = intval($_GET['gender']);
$activity['number'] = intval($_GET['activitynumber']);
if($_GET['activityexpiration']) {
$activity['expiration'] = @strtotime($_GET['activityexpiration']);
} else {
$activity['expiration'] = 0;
}
$extfield = $_GET['extfield'];
$extfield = explode("\n", $_GET['extfield']);
foreach($extfield as $key => $value) {
$extfield[$key] = dhtmlspecialchars(strip_tags(censor(trim($value))));
if($extfield[$key] === '' || is_numeric($extfield[$key])) {
unset($extfield[$key]);
}
}
$extfield = array_unique($extfield);
if(count($extfield) > $this->setting['activityextnum']) {
showmessage('post_activity_extfield_toomany', '', array('maxextfield' => $this->setting['activityextnum']));
}
$activity['ufield'] = array('userfield' => $_GET['userfield'], 'extfield' => $extfield);
$activity['ufield'] = serialize($activity['ufield']);
if(intval($_GET['activitycredit']) > 0) {
$activity['credit'] = intval($_GET['activitycredit']);
}
$data = array('cost' => $activity['cost'], 'starttimefrom' => $activity['starttimefrom'], 'starttimeto' => $activity['starttimeto'], 'place' => $activity['place'], 'class' => $activity['class'], 'gender' => $activity['gender'], 'number' => $activity['number'], 'expiration' => $activity['expiration'], 'ufield' => $activity['ufield'], 'credit' => $activity['credit']);
C::t('forum_activity')->update($this->thread['tid'], $data);
}
}
if($parameters['special'] == 4 && $isfirstpost && $this->group['allowpostactivity']) {
$activity = C::t('forum_activity')->fetch($this->thread['tid']);
$activityaid = $activity['aid'];
if($activityaid && $activityaid != $_GET['activityaid']) {
$attach = C::t('forum_attachment_n')->fetch_attachment('tid:'.$this->thread['tid'], $activityaid);
C::t('forum_attachment')->delete($activityaid);
C::t('forum_attachment_n')->delete_attachment('tid:'.$this->thread['tid'], $activityaid);
dunlink($attach);
}
if($_GET['activityaid']) {
$threadimageaid = $_GET['activityaid'];
convertunusedattach($_GET['activityaid'], $this->thread['tid'], $this->post['pid']);
C::t('forum_activity')->update($this->thread['tid'], array('aid' => $_GET['activityaid']));
}
}
}
}
?>

View File

@@ -0,0 +1,184 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_allowat.php 34144 2013-10-21 05:56:02Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_allowat extends extend_thread_base {
public $atlist;
public $allowat;
public function before_newthread($parameters) {
if($this->group['allowat']) {
$this->atlist = $atlist_tmp = array();
preg_match_all("/@([^\r\n]*?)\s/i", $parameters['message'].' ', $atlist_tmp);
$atlist_tmp = array_slice(array_unique($atlist_tmp[1]), 0, $this->group['allowat']);
if(!empty($atlist_tmp)) {
if(!$this->setting['at_anyone']) {
foreach(C::t('home_follow')->fetch_all_by_uid_fusername($this->member['uid'], $atlist_tmp) as $row) {
$this->atlist[$row['followuid']] = $row['fusername'];
}
if(count($this->atlist) < $this->group['allowat']) {
$query = C::t('home_friend')->fetch_all_by_uid_username($this->member['uid'], $atlist_tmp);
foreach($query as $row) {
$this->atlist[$row['fuid']] = $row['fusername'];
}
}
} else {
foreach(C::t('common_member')->fetch_all_by_username($atlist_tmp) as $row) {
$this->atlist[$row['uid']] = $row['username'];
}
}
}
if($this->atlist) {
foreach($this->atlist as $atuid => $atusername) {
$atsearch[] = "/@".preg_quote($atusername, '/')." /i";
$atreplace[] = "[url=home.php?mod=space&uid=$atuid]@{$atusername}[/url] ";
}
$this->param['message'] = preg_replace($atsearch, $atreplace, $parameters['message'].' ', 1);
$this->param['message'] = substr($this->param['message'], 0, strlen($this->param['message']) - 1);
}
}
}
public function after_newthread() {
if($this->group['allowat'] && $this->atlist) {
foreach($this->atlist as $atuid => $atusername) {
notification_add($atuid, 'at', 'at_message', array('from_id' => $this->tid, 'from_idtype' => 'at', 'buyerid' => $this->member['uid'], 'buyer' => $this->member['username'], 'tid' => $this->tid, 'subject' => $this->param['subject'], 'pid' => $this->pid, 'message' => messagecutstr($this->param['message'], 150)));
}
set_atlist_cookie(array_keys($this->atlist));
}
}
public function before_newreply($parameters) {
if($this->group['allowat']) {
$this->atlist = $atlist_tmp = $ateduids = array();
preg_match_all("/@([^\r\n]*?)\s/i", $parameters['message'].' ', $atlist_tmp);
$atlist_tmp = array_slice(array_unique($atlist_tmp[1]), 0, $this->group['allowat']);
$atnum = $maxselect = 0;
foreach(C::t('home_notification')->fetch_all_by_authorid_fromid($this->member['uid'], $this->thread['tid'], 'at') as $row) {
$atnum ++;
$ateduids[$row['uid']] = $row['uid'];
}
$maxselect = $this->group['allowat'] - $atnum;
if($maxselect > 0 && !empty($atlist_tmp)) {
$at_anyone = $this->setting['at_anyone'];
if(empty($at_anyone)) {
foreach(C::t('home_follow')->fetch_all_by_uid_fusername($this->member['uid'], $atlist_tmp) as $row) {
if(!in_array($row['followuid'], $ateduids)) {
$this->atlist[$row['followuid']] = $row['fusername'];
}
if(count($this->atlist) == $maxselect) {
break;
}
}
if(count($this->atlist) < $maxselect) {
$query = C::t('home_friend')->fetch_all_by_uid_username($this->member['uid'], $atlist_tmp);
foreach($query as $row) {
if(!in_array($row['fuid'], $ateduids)) {
$this->atlist[$row['fuid']] = $row['fusername'];
}
}
}
} else {
foreach(C::t('common_member')->fetch_all_by_username($atlist_tmp) as $row) {
if(!in_array($row['uid'], $ateduids)) {
$this->atlist[$row['uid']] = $row['username'];
}
if(count($this->atlist) == $maxselect) {
break;
}
}
}
}
if($this->atlist) {
foreach($this->atlist as $atuid => $atusername) {
$atsearch[] = "/@".preg_quote($atusername, '/')." /i";
$atreplace[] = "[url=home.php?mod=space&uid=$atuid]@{$atusername}[/url] ";
}
$this->param['message'] = preg_replace($atsearch, $atreplace, $parameters['message'].' ', 1);
$this->param['message'] = substr($this->param['message'], 0, strlen($this->param['message']) - 1);
}
}
}
public function after_newreply() {
if($this->group['allowat'] && $this->atlist) {
foreach($this->atlist as $atuid => $atusername) {
notification_add($atuid, 'at', 'at_message', array('from_id' => $this->thread['tid'], 'from_idtype' => 'at', 'buyerid' => $this->member['uid'], 'buyer' => $this->member['username'], 'tid' => $this->thread['tid'], 'subject' => $this->thread['subject'], 'pid' => $this->pid, 'message' => messagecutstr($this->param['message'], 150)));
}
set_atlist_cookie(array_keys($this->atlist));
}
}
public function before_editpost($parameters) {
if($this->group['allowat']) {
$this->atlist = $atlist_tmp = $ateduids = array();
$atnum = $maxselect = 0;
foreach(C::t('home_notification')->fetch_all_by_authorid_fromid($this->member['uid'], $this->thread['tid'], 'at') as $row) {
$atnum ++;
$ateduids[$row['uid']] = $row['uid'];
}
$maxselect = $this->group['allowat'] - $atnum;
preg_match_all("/@([^\r\n]*?)\s/i", $parameters['message'].' ', $atlist_tmp);
$atlist_tmp = array_slice(array_unique($atlist_tmp[1]), 0, $this->group['allowat']);
if($maxselect > 0 && !empty($atlist_tmp)) {
if(empty($this->setting['at_anyone'])) {
foreach(C::t('home_follow')->fetch_all_by_uid_fusername($this->member['uid'], $atlist_tmp) as $row) {
if(!in_array($row['followuid'], $ateduids)) {
$this->atlist[$row['followuid']] = $row['fusername'];
}
if(count($this->atlist) == $maxselect) {
break;
}
}
if(count($this->atlist) < $maxselect) {
$query = C::t('home_friend')->fetch_all_by_uid_username($this->member['uid'], $atlist_tmp);
foreach($query as $row) {
if(!in_array($row['fuid'], $ateduids)) {
$this->atlist[$row['fuid']] = $row['fusername'];
}
}
}
} else {
foreach(C::t('common_member')->fetch_all_by_username($atlist_tmp) as $row) {
if(!in_array($row['uid'], $ateduids)) {
$this->atlist[$row['uid']] = $row['username'];
}
if(count($this->atlist) == $maxselect) {
break;
}
}
}
if($this->atlist) {
foreach($this->atlist as $atuid => $atusername) {
$atsearch[] = "/@".preg_quote($atusername, '/')." /i";
$atreplace[] = "[url=home.php?mod=space&uid=$atuid]@{$atusername}[/url] ";
}
$this->param['message'] = preg_replace($atsearch, $atreplace, $parameters['message'].' ', 1);
$this->param['message'] = substr($this->param['message'], 0, strlen($this->param['message']) - 1);
}
}
}
}
public function after_editpost() {
if($this->group['allowat'] && $this->atlist) {
foreach($this->atlist as $atuid => $atusername) {
notification_add($atuid, 'at', 'at_message', array('from_id' => $this->thread['tid'], 'from_idtype' => 'at', 'buyerid' => $this->member['uid'], 'buyer' => $this->member['username'], 'tid' => $this->thread['tid'], 'subject' => $this->thread['subject'], 'pid' => $this->post['pid'], 'message' => messagecutstr($this->param['message'], 150)));
}
set_atlist_cookie(array_keys($this->atlist));
}
}
}
?>

View File

@@ -0,0 +1,31 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_base.php 30673 2012-06-11 07:51:54Z svn_project_zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_base extends discuz_extend {
public $forum;
public $thread;
public $post;
public $feed;
public function init_base_var() {
$this->forum = &$this->_obj->forum;
$this->thread = &$this->_obj->thread;
$this->post = &$this->_obj->post;
$this->feed = &$this->_obj->feed;
parent::init_base_var();
}
}
?>

View File

@@ -0,0 +1,61 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_comment.php 33709 2013-08-06 09:06:56Z andyzheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_comment extends extend_thread_base {
private $postcomment;
public function before_newreply($parameters) {
global $nauthorid;
list(, $this->param['modnewreplies']) = threadmodstatus($this->param['subject']."\t".$this->param['message'].$this->param['extramessage']);
if($this->thread['displayorder'] == -4) {
$this->param['modnewreplies'] = 0;
}
$pinvisible = $parameters['modnewreplies'] ? -2 : ($this->thread['displayorder'] == -4 ? -3 : 0);
$this->postcomment = is_array($this->setting['allowpostcomment']) && in_array(2, $this->setting['allowpostcomment']) && $this->group['allowcommentreply'] && !$pinvisible && !empty($_GET['reppid']) && ($nauthorid != $this->member['uid'] || $this->setting['commentpostself']) ? messagecutstr($parameters['message'], 200, ' ') : '';
}
public function after_newreply() {
if(!empty($_GET['noticeauthor']) && !$this->param['isanonymous'] && !$this->param['modnewreplies']) {
if($this->postcomment) {
$rpid = intval($_GET['reppid']);
if($rpost = C::t('forum_post')->fetch_post('tid:'.$this->thread['tid'], $rpid)) {
if(!$rpost['first']) {
$cid = C::t('forum_postcomment')->insert(array(
'tid' => $this->thread['tid'],
'pid' => $rpid,
'rpid' => $this->pid,
'author' => $this->member['username'],
'authorid' => $this->member['uid'],
'dateline' => TIMESTAMP,
'comment' => $this->postcomment,
'score' => 0,
'useip' => getglobal('clientip'),
'port'=>getglobal('remoteport')
), true);
C::t('forum_post')->update_post('tid:'.$this->thread['tid'], $rpid, array('comment' => 1));
C::t('forum_postcache')->delete($rpid);
}
}
unset($this->postcomment);
}
}
}
public function after_deletepost() {
C::t('forum_postcomment')->delete_by_rpid($this->post['pid']);
}
}
?>

View File

@@ -0,0 +1,140 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_debate.php 30673 2012-06-11 07:51:54Z svn_project_zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_debate extends extend_thread_base {
public $affirmpoint;
public $negapoint;
public $endtime;
public $stand;
public function before_newthread($parameters) {
if(empty($_GET['affirmpoint']) || empty($_GET['negapoint'])) {
showmessage('debate_position_nofound');
} elseif(!empty($_GET['endtime']) && (!($this->endtime = @strtotime($_GET['endtime'])) || $this->endtime < TIMESTAMP)) {
showmessage('debate_endtime_invalid');
} elseif(!empty($_GET['umpire'])) {
if(!C::t('common_member')->fetch_uid_by_username($_GET['umpire'])) {
$_GET['umpire'] = dhtmlspecialchars($_GET['umpire']);
showmessage('debate_umpire_invalid', '', array('umpire' => $_GET['umpire']));
}
}
$this->affirmpoint = censor(dhtmlspecialchars($_GET['affirmpoint']));
$this->negapoint = censor(dhtmlspecialchars($_GET['negapoint']));
$this->stand = intval($_GET['stand']);
$this->param['extramessage'] = "\t".$_GET['affirmpoint']."\t".$_GET['negapoint'];
}
public function after_newthread() {
if($this->group['allowpostdebate']) {
C::t('forum_debate')->insert(array(
'tid' => $this->tid,
'uid' => $this->member['uid'],
'starttime' => $this->param['publishdate'],
'endtime' => $this->endtime,
'affirmdebaters' => 0,
'negadebaters' => 0,
'affirmvotes' => 0,
'negavotes' => 0,
'umpire' => $_GET['umpire'],
'winner' => '',
'bestdebater' => '',
'affirmpoint' => $this->affirmpoint,
'negapoint' => $this->negapoint,
'umpirepoint' => ''
));
}
}
public function before_feed() {
$message = !$this->param['price'] && !$this->param['readperm'] ? $this->param['message'] : '';
$this->feed['icon'] = 'debate';
$this->feed['title_template'] = 'feed_thread_debate_title';
$this->feed['body_template'] = 'feed_thread_debate_message';
$this->feed['body_data'] = array(
'subject' => "<a href=\"forum.php?mod=viewthread&tid={$this->tid}\">{$this->param['subject']}</a>",
'message' => messagecutstr($message, 150),
'affirmpoint'=> messagecutstr($this->affirmpoint, 150),
'negapoint'=> messagecutstr($this->negapoint, 150)
);
}
public function after_newreply() {
global $firststand, $stand;
if($this->param['special'] == 5) {
if(!$firststand) {
C::t('forum_debate')->update_debaters($this->thread['tid'], $stand);
} else {
$stand = $firststand;
}
C::t('forum_debate')->update_replies($this->thread['tid'], $stand);
C::t('forum_debatepost')->insert(array(
'tid' => $this->thread['tid'],
'pid' => $this->pid,
'uid' => $this->member['uid'],
'dateline' => getglobal('timestamp'),
'stand' => $stand,
'voters' => 0,
'voterids' => '',
));
}
}
public function before_replyfeed() {
global $stand;
if($this->forum['allowfeed'] && !$this->param['isanonymous']) {
if($this->param['special'] == 5 && $this->thread['authorid'] != $this->member['uid']) {
$this->feed['icon'] = 'debate';
if($stand == 1) {
$this->feed['title_template'] = 'feed_thread_debatevote_title_1';
} elseif($stand == 2) {
$this->feed['title_template'] = 'feed_thread_debatevote_title_2';
} else {
$this->feed['title_template'] = 'feed_thread_debatevote_title_3';
}
$this->feed['title_data'] = array(
'subject' => "<a href=\"forum.php?mod=viewthread&tid=".$this->thread['tid']."\">".$this->thread['subject']."</a>",
'author' => "<a href=\"home.php?mod=space&uid=".$this->thread['authorid']."\">".$this->thread['author']."</a>"
);
}
}
}
public function before_editpost($parameters) {
$isfirstpost = $this->post['first'] ? 1 : 0;
if($isfirstpost) {
if($this->thread['special'] == 5 && $this->group['allowpostdebate']) {
if(empty($_GET['affirmpoint']) || empty($_GET['negapoint'])) {
showmessage('debate_position_nofound');
} elseif(!empty($_GET['endtime']) && (!($endtime = @strtotime($_GET['endtime'])) || $endtime < TIMESTAMP)) {
showmessage('debate_endtime_invalid');
} elseif(!empty($_GET['umpire'])) {
if(!C::t('common_member')->fetch_uid_by_username($_GET['umpire'])) {
$_GET['umpire'] = dhtmlspecialchars($_GET['umpire']);
showmessage('debate_umpire_invalid');
}
}
$affirmpoint = censor(dhtmlspecialchars($_GET['affirmpoint']));
$negapoint = censor(dhtmlspecialchars($_GET['negapoint']));
C::t('forum_debate')->update($this->thread['tid'], array('affirmpoint' => $affirmpoint, 'negapoint' => $negapoint, 'endtime' => $endtime, 'umpire' => $_GET['umpire']));
}
}
}
}
?>

View File

@@ -0,0 +1,97 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_filter.php 33048 2013-04-12 08:50:27Z zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_filter extends extend_thread_base {
private $curFilterCheck = -1;
private function _check_post_length($message, $length) {
if($this->param['special'] || $this->thread['special'] || getstatus($this->thread['status'], 3) || !$length) {
return 0;
}
require_once libfile('function/discuzcode');
$langthread = lang('forum/thread');
$content = discuzcode($message);
$content = strip_tags($content);
$content = str_replace(array(',', '.', '?', '!', $langthread['t_question'], $langthread['t_exclamatory'], $langthread['t_period'], $langthread['t_comma'], '~', $langthread['t_suspension']), '', $content);
$content = preg_replace('/\s+/', '', $content);
$realLength = dstrlen($content);
$checkQuote = (preg_match("/\s?\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s?/is", $message) > 0) || (preg_match("/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/i", $message) > 0) || (preg_match("/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/i", $message) > 0) || (preg_match("/\[attach\](\d+)\[\/attach\]/i", $message) > 0);
if($checkQuote || $realLength >= $length) {
return ($realLength <= 0 ? 1 : $realLength) ;
} else {
return 0;
}
}
public function before_newreply($parameters) {
$this->curFilterCheck = $this->_check_post_length($parameters['noticetrimstr'].$parameters['message'], $this->setting['threadfilternum']);
if($this->curFilterCheck <= 0) {
$this->param['modstatus'][11] = 1;
}
}
public function after_newreply() {
if($this->curFilterCheck > 0) {
$data = array(
'tid' => $this->thread['tid'],
'pid' => $this->pid,
'postlength' => $this->curFilterCheck
);
C::t('forum_filter_post')->insert($data);
}
}
public function before_editpost($parameters) {
$isfirstpost = $this->post['first'] ? 1 : 0;
if(!$isfirstpost) {
$this->curFilterCheck = $this->_check_post_length($parameters['message'], $this->setting['threadfilternum']);
if($this->curFilterCheck <= 0) {
$this->param['modstatus'][11] = 1;
} else {
$this->param['modstatus'][11] = 0;
}
}
}
public function after_editpost() {
$isfirstpost = $this->post['first'] ? 1 : 0;
if(!$isfirstpost) {
if($this->curFilterCheck > 0) {
$data = array(
'tid' => $this->thread['tid'],
'pid' => $this->post['pid'],
'postlength' => $this->curFilterCheck
);
C::t('forum_filter_post')->insert($data, false, true);
} else {
C::t('forum_filter_post')->delete_by_tid_pid($this->thread['tid'], $this->post['pid']);
}
}
}
public function after_deletepost() {
$isfirstpost = $this->post['first'] ? 1 : 0;
if($isfirstpost) {
C::t('forum_filter_post')->delete_by_tid($this->thread['tid']);
C::t('forum_hotreply_number')->delete_by_tid($this->thread['tid']);
C::t('forum_hotreply_member')->delete_by_tid($this->thread['tid']);
} else {
C::t('forum_filter_post')->delete_by_tid_pid($this->thread['tid'], $this->post['pid']);
C::t('forum_hotreply_number')->delete_by_pid($this->post['pid']);
C::t('forum_hotreply_member')->delete_by_pid($this->post['pid']);
}
}
}
?>

View File

@@ -0,0 +1,92 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_follow.php 34174 2013-10-28 07:18:04Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_follow extends extend_thread_base {
public function after_newthread() {
$tid = $this->tid;
$pid = $this->pid;
$uid = $this->member['uid'];
if($this->param['displayorder'] >= 0 && helper_access::check_module('follow') && !$this->param['isanonymous']) {
$values = array();
require_once libfile('function/discuzcode');
require_once libfile('function/followcode');
$feedcontent = array(
'tid' => $tid,
'content' => followcode($this->param['message'], $tid, $pid, 1000),
);
C::t('forum_threadpreview')->insert($feedcontent);
C::t('forum_thread')->update_status_by_tid($tid, '512');
$followfeed = array(
'uid' => $uid,
'username' => $this->member['username'],
'tid' => $tid,
'note' => '',
'dateline' => TIMESTAMP
);
$values['feedid'] = C::t('home_follow_feed')->insert($followfeed, true);
C::t('common_member_count')->increase($uid, array('feeds'=>1));
$this->param['values'] = array_merge((array)$this->param['values'], $values);
}
}
public function after_newreply() {
$feedid = 0;
if(helper_access::check_module('follow') && !$this->param['isanonymous']) {
require_once libfile('function/discuzcode');
require_once libfile('function/followcode');
$feedcontent = C::t('forum_threadpreview')->count_by_tid($this->thread['tid']);
$firstpost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($this->thread['tid']);
if(empty($feedcontent)) {
$feedcontent = array(
'tid' => $this->thread['tid'],
'content' => followcode($firstpost['message'], $this->thread['tid'], $this->pid, 1000),
);
C::t('forum_threadpreview')->insert($feedcontent);
C::t('forum_thread')->update_status_by_tid($this->thread['tid'], '512');
} else {
C::t('forum_threadpreview')->update_relay_by_tid($this->thread['tid'], 1);
}
$notemsg = cutstr(followcode($this->param['message'], $this->thread['tid'], $this->pid, 0, false), 140);
$followfeed = array(
'uid' => $this->member['uid'],
'username' => $this->member['username'],
'tid' => $this->thread['tid'],
'note' => $notemsg,
'dateline' => TIMESTAMP
);
$feedid = C::t('home_follow_feed')->insert($followfeed, true);
C::t('common_member_count')->increase($this->member['uid'], array('feeds'=>1));
}
if($feedid) {
$this->param['showmsgparam'] = array_merge((array)$this->param['showmsgparam'], array('feedid' => $feedid));
}
}
public function after_editpost() {
$isfirstpost = $this->post['first'] ? 1 : 0;
if($isfirstpost) {
require_once libfile('function/discuzcode');
require_once libfile('function/followcode');
$feed = C::t('forum_threadpreview')->fetch($this->thread['tid']);
if($feed) {
C::t('forum_threadpreview')->update($this->thread['tid'], array('content' => followcode($this->param['message'], $this->thread['tid'], $this->post['pid'], 1000)));
}
}
}
}
?>

View File

@@ -0,0 +1,149 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_image.php 32709 2013-03-04 03:28:55Z zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_image extends extend_thread_base {
public function after_newthread() {
$threadimageaid = 0;
$threadimage = array();
$tid = $this->tid;
$pid = $this->pid;
$fid = $this->forum['fid'];
if($this->param['special'] == 4 && $_GET['activityaid']) {
$threadimageaid = $_GET['activityaid'];
convertunusedattach($_GET['activityaid'], $tid, $pid);
}
$this->mobile_upload();
if(($this->group['allowpostattach'] || $this->group['allowpostimage']) && (getgpc('attachnew') || $this->param['sortid'] || !empty($_GET['activityaid']))) {
updateattach($this->param['displayorder'] == -4 || $this->param['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' => $fid, 'tid' => $tid, 'pid' => $pid, 'coverimg' => '');
$param = array();
setthreadcover($pid, 0, $threadimageaid);
if($threadimageaid) {
if(!$threadimage) {
$threadimage = C::t('forum_attachment_n')->fetch_attachment('tid:'.$tid, $threadimageaid);
}
$threadimage = daddslashes($threadimage);
C::t('forum_threadimage')->insert(array(
'tid' => $tid,
'attachment' => $threadimage['attachment'],
'remote' => $threadimage['remote'],
));
}
$this->param['values'] = array_merge((array)$this->param['values'], $values);
$this->param['param'] = array_merge((array)$this->param['param'], $param);
}
private function mobile_upload() {
global $_G;
if(getgpc('mobile') == 'yes' && !empty($_FILES['Filedata'])) {
$forumattachextensions = '';
if($_G['forum']) {
$forum = $_G['forum'];
if($forum['status'] == 3 && $forum['level']) {
$levelinfo = C::t('forum_grouplevel')->fetch($forum['level']);
if($postpolicy = $levelinfo['postpolicy']) {
$postpolicy = dunserialize($postpolicy);
$forumattachextensions = $postpolicy['attachextensions'];
}
} else {
$forumattachextensions = $forum['attachextensions'];
}
if($forumattachextensions) {
$_G['group']['attachextensions'] = $forumattachextensions;
}
}
$upload = new forum_upload(1);
if($upload) {
$_GET['attachnew'][$upload->getaid] = array('description' => '');
}
}
}
public function after_newreply() {
$this->mobile_upload();
($this->group['allowpostattach'] || $this->group['allowpostimage']) && ($_GET['attachnew'] || $this->param['special'] == 2 && $_GET['tradeaid']) && updateattach($this->thread['displayorder'] == -4 || $this->param['modnewreplies'], $this->thread['tid'], $this->pid, $_GET['attachnew']);
}
public function before_editpost($parameters) {
global $_G;
$isfirstpost = $this->post['first'] ? 1 : 0;
$attachupdate = !empty($_GET['delattachop']) || ($this->group['allowpostattach'] || $this->group['allowpostimage']) && ($_GET['attachnew'] || $parameters['special'] == 2 && $_GET['tradeaid'] || $parameters['special'] == 4 && $_GET['activityaid'] || $isfirstpost && $parameters['sortid']);
if($attachupdate) {
updateattach($this->thread['displayorder'] == -4 || $_G['forum_auditstatuson'], $this->thread['tid'], $this->post['pid'], $_GET['attachnew'], $_GET['attachupdate'], $this->post['authorid']);
}
if($isfirstpost && $attachupdate) {
if(!$this->param['threadimageaid']) {
$this->param['threadimage'] = C::t('forum_attachment_n')->fetch_max_image('tid:'.$this->thread['tid'], 'pid', $this->post['pid']);
$this->param['threadimageaid'] = $this->param['threadimage']['aid'];
}
if(empty($this->thread['cover'])) {
setthreadcover($this->post['pid'], 0, $this->param['threadimageaid']);
} else {
setthreadcover($this->post['pid'], $this->thread['tid'], 0, 1);
}
if($this->param['threadimageaid']) {
if(!$this->param['threadimage']) {
$this->param['threadimage'] = C::t('forum_attachment_n')->fetch_max_image('tid:'.$this->thread['tid'], 'tid', $this->thread['tid']);
}
C::t('forum_threadimage')->delete_by_tid($this->thread['tid']);
C::t('forum_threadimage')->insert(array(
'tid' => $this->thread['tid'],
'attachment' => $this->param['threadimage']['attachment'],
'remote' => $this->param['threadimage']['remote'],
));
}
}
}
public function before_deletepost($parameters) {
$thread_attachment = $post_attachment = 0;
foreach(C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$this->thread['tid'], 'tid', $this->thread['tid']) as $attach) {
if($attach['pid'] == $this->post['pid']) {
if($this->thread['displayorder'] >= 0) {
$post_attachment++;
}
dunlink($attach);
} else {
if($attach['isimage']) {
$thread_attachment = 2;
}
if($thread_attachment == 0) {
$thread_attachment = 1;
}
}
}
$this->param['updatefieldarr']['attachment'] = array($thread_attachment);
if($post_attachment) {
C::t('forum_attachment')->delete_by_id('pid', $this->post['pid']);
DB::query("DELETE FROM ".DB::table(getattachtablebytid($this->thread['tid']))." WHERE pid='".$this->post['pid']."'", 'UNBUFFEREED');
updatecreditbyaction('postattach', $this->post['authorid'], array(), '', -$post_attachment);
}
}
}
?>

View File

@@ -0,0 +1,194 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_poll.php 36284 2016-12-12 00:47:50Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_poll extends extend_thread_base {
public $pollarray;
public $polloptionpreview;
public function before_newthread($parameters){
$polloption = $_GET['tpolloption'] == 2 ? explode("\n", $_GET['polloptions']) : $_GET['polloption'];
foreach($polloption as $key => $value) {
$polloption[$key] = censor($polloption[$key]);
if(trim($value) === '') {
unset($polloption[$key]);
}
}
$maxpolloptions = $this->setting['maxpolloptions'];
if(count($polloption) > $maxpolloptions) {
showmessage('post_poll_option_toomany', '', array('maxpolloptions' => $maxpolloptions));
} elseif(count($polloption) < 2) {
showmessage('post_poll_inputmore');
}
$curpolloption = count($polloption);
$this->pollarray['maxchoices'] = empty($_GET['maxchoices']) ? 0 : ($_GET['maxchoices'] > $curpolloption ? $curpolloption : $_GET['maxchoices']);
$this->pollarray['multiple'] = empty($_GET['maxchoices']) || $_GET['maxchoices'] == 1 ? 0 : 1;
$this->pollarray['options'] = $polloption;
$this->pollarray['visible'] = empty($_GET['visibilitypoll']);
$this->pollarray['overt'] = !empty($_GET['overt']);
$this->pollarray['pollimage'] = $_GET['pollimage'];
$this->pollarray['isimage'] = 0;
if(preg_match("/^\d*$/", trim($_GET['expiration']))) {
if(empty($_GET['expiration'])) {
$this->pollarray['expiration'] = 0;
} else {
$this->pollarray['expiration'] = TIMESTAMP + 86400 * $_GET['expiration'];
}
} else {
showmessage('poll_maxchoices_expiration_invalid');
}
if($_GET['polloptions'] || $_GET['polloption']) {
$this->param['extramessage'] = "\t".implode("\t", $_GET['tpolloption'] == 2 ? explode("\n", $_GET['polloptions']) : $_GET['polloption']);
}
}
public function after_newthread() {
foreach($this->pollarray['options'] as $ppkey => $polloptvalue) {
$polloptvalue = dhtmlspecialchars(trim($polloptvalue));
$polloptionid = C::t('forum_polloption')->insert(array('tid' => $this->tid, 'polloption' => $polloptvalue), true);
if($this->pollarray['pollimage'][$ppkey]) {
C::t('forum_polloption_image')->update($this->pollarray['pollimage'][$ppkey], array('poid' => $polloptionid, 'tid' => $this->tid, 'pid' => $this->pid));
$this->pollarray['isimage'] = 1;
}
}
$this->polloptionpreview = '';
$query = C::t('forum_polloption')->fetch_all_by_tid($this->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']);
$this->polloptionpreview .= $polloptvalue."\t";
}
$this->polloptionpreview = daddslashes($this->polloptionpreview);
$data = array('tid' => $this->tid, 'multiple' => $this->pollarray['multiple'], 'visible' => $this->pollarray['visible'], 'maxchoices' => $this->pollarray['maxchoices'], 'expiration' => $this->pollarray['expiration'], 'overt' => $this->pollarray['overt'], 'pollpreview' => $this->polloptionpreview, 'isimage' => $this->pollarray['isimage']);
C::t('forum_poll')->insert($data);
}
public function before_feed() {
$pvs = explode("\t", messagecutstr($this->polloptionpreview, 150));
$s = '';
$i = 1;
foreach($pvs as $pv) {
$s .= $i.'. '.$pv.'<br />';
}
$s .= '&nbsp;&nbsp;&nbsp;...';
$this->feed['icon'] = 'poll';
$this->feed['title_template'] = 'feed_thread_poll_title';
$this->feed['body_template'] = 'feed_thread_poll_message';
$this->feed['body_data'] = array(
'subject' => "<a href=\"forum.php?mod=viewthread&tid={$this->tid}\">".$this->param['subject']."</a>",
'message' => $s
);
}
public function before_editpost($parameters) {
$isfirstpost = $this->post['first'] ? 1 : 0;
$isorigauthor = $this->member['uid'] && $this->member['uid'] == $this->post['authorid'];
if($isfirstpost) {
if($this->thread['special'] == 1 && ($this->group['alloweditpoll'] || $isorigauthor) && !empty($_GET['polls'])) {
$pollarray = array();
foreach($_GET['polloption'] as $key => $val) {
if(trim($val) === '') {
unset($_GET['polloption'][$key]);
}
}
$pollarray['options'] = $_GET['polloption'];
if($pollarray['options']) {
if(count($pollarray['options']) > $this->setting['maxpolloptions']) {
showmessage('post_poll_option_toomany', '', array('maxpolloptions' => $this->setting['maxpolloptions']));
}
foreach($pollarray['options'] as $key => $value) {
$pollarray['options'][$key] = censor($pollarray['options'][$key]);
if(!trim($value)) {
C::t('forum_polloption')->delete_safe_tid($this->thread['tid'], $key);
unset($pollarray['options'][$key]);
}
}
$this->param['threadupdatearr']['special'] = 1;
foreach($_GET['displayorder'] as $key => $value) {
if(preg_match("/^-?\d*$/", $value)) {
$pollarray['displayorder'][$key] = $value;
}
}
$curpolloption = count($pollarray['options']);
$pollarray['maxchoices'] = empty($_GET['maxchoices']) ? 0 : ($_GET['maxchoices'] > $curpolloption ? $curpolloption : $_GET['maxchoices']);
$pollarray['multiple'] = empty($_GET['maxchoices']) || $_GET['maxchoices'] == 1 ? 0 : 1;
$pollarray['visible'] = empty($_GET['visibilitypoll']);
$pollarray['expiration'] = $_GET['expiration'];
$pollarray['overt'] = !empty($_GET['overt']);
$pollarray['pollimage'] = $_GET['pollimage'];
foreach($_GET['polloptionid'] as $key => $value) {
if(!preg_match("/^\d*$/", $value)) {
showmessage('submit_invalid');
}
}
$expiration = intval($_GET['expiration']);
if($this->thread['close']) {
$pollarray['expiration'] = TIMESTAMP;
} elseif($expiration) {
if(empty($pollarray['expiration'])) {
$pollarray['expiration'] = 0;
} else {
$pollarray['expiration'] = TIMESTAMP + 86400 * $expiration;
}
}
$optid = array();
$query = C::t('forum_polloption')->fetch_all_by_tid($this->thread['tid']);
foreach($query as $tempoptid) {
$optid[] = $tempoptid['polloptionid'];
}
foreach($pollarray['options'] as $key => $value) {
$value = dhtmlspecialchars(trim($value));
if(in_array($_GET['polloptionid'][$key], $optid)) {
if($this->group['alloweditpoll']) {
C::t('forum_polloption')->update_safe_tid($_GET['polloptionid'][$key], $this->thread['tid'], $pollarray['displayorder'][$key], $value);
} else {
C::t('forum_polloption')->update_safe_tid($_GET['polloptionid'][$key], $this->thread['tid'], $pollarray['displayorder'][$key]);
}
} else {
$polloptionid = C::t('forum_polloption')->insert(array('tid' => $this->thread['tid'], 'displayorder' => $pollarray['displayorder'][$key], 'polloption' => $value), true);
if($pollarray['pollimage'][$key]) {
C::t('forum_polloption_image')->update($pollarray['pollimage'][$key], array('poid' => $polloptionid, 'tid' => $this->thread['tid'], 'pid' => $this->post['pid']));
$pollarray['isimage'] = 1;
}
}
}
$polloptionpreview = '';
$query = C::t('forum_polloption')->fetch_all_by_tid($this->thread['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('multiple' => $pollarray['multiple'], 'visible' => $pollarray['visible'], 'maxchoices' => $pollarray['maxchoices'], 'expiration' => $pollarray['expiration'], 'overt' => $pollarray['overt'], 'pollpreview' => $polloptionpreview);
if($pollarray['isimage']) {
$data['isimage'] = 1;
}
C::t('forum_poll')->update($this->thread['tid'], $data);
} else {
$this->param['threadupdatearr']['special'] = 0;
C::t('forum_poll')->delete($this->thread['tid']);
C::t('forum_polloption')->delete_safe_tid($this->thread['tid']);
}
}
}
}
}
?>

View File

@@ -0,0 +1,147 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_replycredit.php 33418 2013-06-08 08:46:32Z andyzheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_replycredit extends extend_thread_base {
public $replycredit_real;
public function before_newthread($parameters) {
if($this->group['allowreplycredit']) {
$_GET['replycredit_extcredits'] = intval($_GET['replycredit_extcredits']);
$_GET['replycredit_times'] = intval($_GET['replycredit_times']);
$_GET['replycredit_membertimes'] = intval($_GET['replycredit_membertimes']) > 0 && intval($_GET['replycredit_membertimes']) <= 10 ? intval($_GET['replycredit_membertimes']) : 1;
$_GET['replycredit_random'] = intval($_GET['replycredit_random']);
$_GET['replycredit_random'] = $_GET['replycredit_random'] < 0 || $_GET['replycredit_random'] > 99 ? 0 : $_GET['replycredit_random'] ;
$this->replycredit_real = 0;
$this->param['replycredit'] = 0;
if($_GET['replycredit_extcredits'] > 0 && $_GET['replycredit_times'] > 0) {
$this->replycredit_real = ceil(($_GET['replycredit_extcredits'] * $_GET['replycredit_times']) + ($_GET['replycredit_extcredits'] * $_GET['replycredit_times'] * $this->setting['creditstax']));
if($this->replycredit_real > getuserprofile('extcredits'.$this->setting['creditstransextra']['10'])) {
showmessage('replycredit_morethan_self');
} else {
$this->param['replycredit'] = ceil($_GET['replycredit_extcredits'] * $_GET['replycredit_times']);
}
}
}
}
public function after_newthread() {
if($this->group['allowreplycredit']) {
if($this->param['replycredit'] > 0 && $this->replycredit_real > 0) {
updatemembercount($this->member['uid'], array('extcredits'.$this->setting['creditstransextra']['10'] => -$this->replycredit_real), 1, 'RCT', $this->tid);
$insertdata = array(
'tid' => $this->tid,
'extcredits' => $_GET['replycredit_extcredits'],
'extcreditstype' => $this->setting['creditstransextra']['10'],
'times' => $_GET['replycredit_times'],
'membertimes' => $_GET['replycredit_membertimes'],
'random' => $_GET['replycredit_random']
);
C::t('forum_replycredit')->insert($insertdata);
}
}
}
public function after_newreply() {
if($this->thread['replycredit'] > 0 && !$this->param['modnewreplies'] && $this->thread['authorid'] != $this->member['uid'] && $this->member['uid']) {
$replycredit_rule = C::t('forum_replycredit')->fetch($this->thread['tid']);
if(!empty($replycredit_rule['times'])) {
$have_replycredit = C::t('common_credit_log')->count_by_uid_operation_relatedid($this->member['uid'], 'RCA', $this->thread['tid']);
if($replycredit_rule['membertimes'] - $have_replycredit > 0 && $this->thread['replycredit'] - $replycredit_rule['extcredits'] >= 0) {
$creditstransextra = $this->setting['creditstransextra'];
$replycredit_rule['extcreditstype'] = $replycredit_rule['extcreditstype'] ? $replycredit_rule['extcreditstype'] : $creditstransextra[10];
if($replycredit_rule['random'] > 0) {
$rand = rand(1, 100);
$rand_replycredit = $rand <= $replycredit_rule['random'] ? true : false ;
} else {
$rand_replycredit = true;
}
if($rand_replycredit) {
updatemembercount($this->member['uid'], array($replycredit_rule['extcreditstype'] => $replycredit_rule['extcredits']), 1, 'RCA', $this->thread['tid']);
C::t('forum_post')->update_post('tid:'.$this->thread['tid'], $this->pid, array('replycredit' => $replycredit_rule['extcredits']));
C::t('forum_thread')->update($this->thread['tid'], (array)DB::field('replycredit', $this->thread['replycredit'] - $replycredit_rule['extcredits']), false, false, 0, true);
}
}
}
}
}
public function before_editpost($parameters) {
$isfirstpost = $this->post['first'] ? 1 : 0;
$isorigauthor = $this->member['uid'] && $this->member['uid'] == $this->post['authorid'];
if($isfirstpost) {
if($isorigauthor && $this->group['allowreplycredit']) {
$replycredit_rule = isset($parameters['replycredit_rule']) && $parameters['replycredit_rule'] ? $parameters['replycredit_rule'] : array();
$_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']) <= 10 ? 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 - $this->thread['replycredit'];
if($replycredit_diff > 0) {
$replycredit_diff = ceil($replycredit_diff + ($replycredit_diff * $this->setting['creditstax']));
if(!$replycredit_rule) {
if($this->setting['creditstransextra']['10']) {
$replycredit_rule['extcreditstype'] = $this->setting['creditstransextra']['10'];
}
}
if($replycredit_diff > getuserprofile('extcredits'.$replycredit_rule['extcreditstype'])) {
showmessage('post_edit_thread_replaycredit_nocredit');
}
}
if($replycredit_diff) {
updatemembercount($this->thread['authorid'], array($replycredit_rule['extcreditstype'] => ($replycredit_diff > 0 ? -$replycredit_diff : abs($replycredit_diff))), 1, ($replycredit_diff > 0 ? 'RCT' : 'RCB'), $this->thread['tid']);
}
} elseif(($_POST['replycredit_extcredits'] == 0 || $_POST['replycredit_times'] == 0) && $this->thread['replycredit'] > 0) {
$replycredit = 0;
C::t('forum_replycredit')->delete($this->thread['tid']);
updatemembercount($this->thread['authorid'], array($replycredit_rule['extcreditstype'] => $this->thread['replycredit']), 1, 'RCB', $this->thread['tid']);
$this->param['threadupdatearr']['replycredit'] = 0;
} else {
$replycredit = $this->thread['replycredit'];
}
if($replycredit) {
$this->param['threadupdatearr']['replycredit'] = $replycredit;
$replydata = array(
'tid' => $this->thread['tid'],
'extcredits' => $_POST['replycredit_extcredits'],
'extcreditstype' => $replycredit_rule['extcreditstype'],
'times' => $_POST['replycredit_times'],
'membertimes' => $_POST['replycredit_membertimes'],
'random' => $_POST['replycredit_random']
);
C::t('forum_replycredit')->insert($replydata, false, true);
}
}
}
}
public function before_deletepost() {
global $replycredit_rule;
$isfirstpost = $this->post['first'] ? 1 : 0;
if($this->thread['replycredit'] && $isfirstpost && !$this->param['isanonymous']) {
updatemembercount($this->post['authorid'], array($replycredit_rule['extcreditstype'] => $this->thread['replycredit']), true, 'RCB', $this->thread['tid']);
C::t('forum_replycredit')->delete($this->thread['tid']);
$this->param['handlereplycredit'] = true;
}
}
}
?>

View File

@@ -0,0 +1,126 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_reward.php 34351 2014-03-19 04:34:04Z hypowang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_reward extends extend_thread_base {
public $rewardprice;
public $realprice;
public function before_newthread($parameters) {
$this->rewardprice = intval($_GET['rewardprice']);
$minrewardprice = $this->group['minrewardprice'];
$maxrewardprice = $this->group['maxrewardprice'];
if($this->rewardprice < 1) {
showmessage('reward_credits_please');
} elseif($this->rewardprice > 32767) {
showmessage('reward_credits_overflow');
} elseif($this->rewardprice < $minrewardprice || ($maxrewardprice > 0 && $this->rewardprice > $maxrewardprice)) {
if($maxrewardprice > 0) {
showmessage('reward_credits_between', '', array('minrewardprice' => $minrewardprice, 'maxrewardprice' => $maxrewardprice));
} else {
showmessage('reward_credits_lower', '', array('minrewardprice' => $minrewardprice));
}
} elseif(($this->realprice = $this->rewardprice + ceil($this->rewardprice * $this->setting['creditstax'])) > getuserprofile('extcredits'.$this->setting['creditstransextra'][2])) {
showmessage('reward_credits_shortage');
}
$this->param['price'] = $this->rewardprice;
}
public function after_newthread() {
if($this->group['allowpostreward']) {
updatemembercount($this->member['uid'], array($this->setting['creditstransextra']['2'] => -$this->realprice), 1, 'RTC', $this->tid);
}
}
public function before_feed() {
$this->feed['icon'] = 'reward';
$this->feed['title_template'] = 'feed_thread_reward_title';
$this->feed['body_template'] = 'feed_thread_reward_message';
$this->feed['body_data'] = array(
'subject'=> "<a href=\"forum.php?mod=viewthread&tid={$this->tid}\">".$this->param['subject']."</a>",
'rewardprice'=> $this->rewardprice,
'extcredits' => $this->setting['extcredits'][$this->setting['creditstransextra']['2']]['title'],
);
}
public function before_replyfeed() {
if($this->forum['allowfeed'] && !$this->param['isanonymous']) {
if($this->param['special'] == 3 && $this->thread['authorid'] != $this->member['uid']) {
$this->feed['icon'] = 'reward';
$this->feed['title_template'] = 'feed_reply_reward_title';
$this->feed['title_data'] = array(
'subject' => "<a href=\"forum.php?mod=viewthread&tid=".$this->thread['tid']."\">".$this->thread['subject']."</a>",
'author' => "<a href=\"home.php?mod=space&uid=".$this->thread['authorid']."\">".$this->thread['author']."</a>"
);
}
}
}
public function before_editpost($parameters) {
$isfirstpost = $this->post['first'] ? 1 : 0;
$isorigauthor = $this->member['uid'] && $this->member['uid'] == $this->post['authorid'];
if($isfirstpost) {
if($this->thread['special'] == 3) {
$this->param['price'] = $isorigauthor ? ($this->thread['price'] > 0 && $this->thread['price'] != $_GET['rewardprice'] ? $_GET['rewardprice'] : 0) : $this->thread['price'];
}
if($this->thread['special'] == 3 && $isorigauthor) {
$rewardprice = $this->thread['price'] > 0 ? intval($_GET['rewardprice']) : $this->thread['price'];
if($this->thread['price'] > 0 && $this->thread['price'] != $_GET['rewardprice']) {
if($rewardprice <= 0){
showmessage('reward_credits_invalid');
}
$addprice = ceil(($rewardprice - $this->thread['price']) + ($rewardprice - $this->thread['price']) * $this->setting['creditstax']);
if($rewardprice < $this->thread['price']) {
showmessage('reward_credits_fall');
} elseif($rewardprice < $this->group['minrewardprice'] || ($this->group['maxrewardprice'] > 0 && $rewardprice > $this->group['maxrewardprice'])) {
showmessage('reward_credits_between', '', array('minrewardprice' => $this->group['minrewardprice'], 'maxrewardprice' => $this->group['maxrewardprice']));
} elseif($addprice > getuserprofile('extcredits'.$this->setting['creditstransextra'][2])) {
showmessage('reward_credits_shortage');
}
$realprice = ceil($rewardprice + $rewardprice * $this->setting['creditstax']);
updatemembercount($this->thread['authorid'], array($this->setting['creditstransextra'][2] => -$addprice));
C::t('common_credit_log')->update_by_uid_operation_relatedid($this->thread['authorid'], 'RTC', $this->thread['tid'], array('extcredits'.$this->setting['creditstransextra'][2] => -$realprice));
}
if(!$this->forum['ismoderator']) {
if($this->thread['replies'] > 1) {
$this->param['subject'] = addslashes($this->thread['subject']);
}
}
$this->param['price'] = $rewardprice;
}
}
}
public function before_deletepost($parameters) {
$isfirstpost = $this->post['first'] ? 1 : 0;
if($this->thread['special'] == 3) {
if($this->thread['price'] < 0 && ($this->thread['dateline'] + 1 == $this->post['dateline'])) {
showmessage('post_edit_reward_nopermission', NULL);
}
}
if($this->thread['special'] == 3 && $isfirstpost) {
updatemembercount($this->post['authorid'], array($this->setting['creditstransextra'][2] => $this->thread['price']));
C::t('common_credit_log')->delete_by_uid_operation_relatedid($this->thread['authorid'], 'RTC', $this->thread['tid']);
}
}
}
?>

View File

@@ -0,0 +1,128 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_rushreply.php 34216 2013-11-14 02:32:06Z hypowang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_rushreply extends extend_thread_base {
public function before_newthread($parameters) {
if($this->group['allowpostrushreply']) {
$_GET['rushreplyfrom'] = strtotime($_GET['rushreplyfrom']);
$_GET['rushreplyto'] = strtotime($_GET['rushreplyto']);
$_GET['rewardfloor'] = preg_replace('#[^0-9|*|,]#', '', $_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'];
}
}
public function after_newthread() {
if($this->group['allowpostrushreply']) {
$rushdata = array('tid' => $this->tid, 'stopfloor' => $_GET['stopfloor'], 'starttimefrom' => $_GET['rushreplyfrom'], 'starttimeto' => $_GET['rushreplyto'], 'rewardfloor' => $_GET['rewardfloor'], 'creditlimit' => $_GET['creditlimit'], 'replylimit' => $_GET['replylimit']);
C::t('forum_threadrush')->insert($rushdata);
}
}
public function before_newreply() {
global $_G, $rushinfo;
if(getstatus($this->thread['status'], 3) && $rushinfo['replylimit'] > 0) {
$replycount = C::t('forum_post')->count_by_tid_invisible_authorid($this->thread['tid'], $_G['uid']);
if($replycount >= $rushinfo['replylimit']) {
showmessage('noreply_replynum_error');
}
}
}
public function after_newreply() {
global $rushinfo;
if(getstatus($this->thread['status'], 3) && $this->param['maxposition']) {
$rushstopfloor = $rushinfo['stopfloor'];
if($rushstopfloor > 0 && $this->thread['closed'] == 0 && $this->param['maxposition'] >= $rushstopfloor) {
$this->param['updatethreaddata'] = array_merge((array)$this->param['updatethreaddata'], array('closed' => 1));
}
}
}
public function before_editpost($parameters) {
global $_G, $rushreply;
$isfirstpost = $this->post['first'] ? 1 : 0;
if($isfirstpost) {
if($rushreply) {
$_GET['rushreplyfrom'] = strtotime($_GET['rushreplyfrom']);
$_GET['rushreplyto'] = strtotime($_GET['rushreplyto']);
$_GET['rewardfloor'] = preg_replace('#[^0-9|*|,]#', '', $_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');
}
$maxposition = C::t('forum_post')->fetch_maxposition_by_tid($this->thread['posttableid'], $this->thread['tid']);
if($this->thread['closed'] == 1 && ((!$_GET['rushreplyfrom'] && !$_GET['rushreplyto']) || ($_GET['rushreplyfrom'] < $_G['timestamp'] && $_GET['rushreplyto'] > $_G['timestamp']) || (!$_GET['rushreplyfrom'] && $_GET['rushreplyto'] > $_G['timestamp']) || ($_GET['stopfloor'] && $_GET['stopfloor'] > $maxposition) )) {
$this->param['threadupdatearr']['closed'] = 0;
} elseif($this->thread['closed'] == 0 && (($_GET['rushreplyfrom'] && $_GET['rushreplyfrom'] > $_G['timestamp']) || ($_GET['rushreplyto'] && $_GET['rushreplyto'] && $_GET['rushreplyto'] < $_G['timestamp']) || ($_GET['stopfloor'] && $_GET['stopfloor'] <= $maxposition) )) {
$this->param['threadupdatearr']['closed'] = 1;
}
if(!empty($_GET['rewardfloor']) && !empty($_GET['stopfloor'])) {
$floors = explode(',', $_GET['rewardfloor']);
if(!empty($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'] = is_array($floors) ? implode(',', $floors) : (string)$floors;
}
$rushdata = array('stopfloor' => $_GET['stopfloor'], 'starttimefrom' => $_GET['rushreplyfrom'], 'starttimeto' => $_GET['rushreplyto'], 'rewardfloor' => $_GET['rewardfloor'], 'creditlimit' => $_GET['creditlimit'], 'replylimit' => $_GET['replylimit']);
C::t('forum_threadrush')->update($this->thread['tid'], $rushdata);
}
}
}
public function before_deletepost() {
global $rushreply;
if($rushreply) {
showmessage('post_edit_delete_rushreply_nopermission', NULL);
}
}
}
?>

View File

@@ -0,0 +1,151 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_sort.php 34201 2013-11-04 06:21:04Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_sort extends extend_thread_base {
public function before_newthread() {
if($_GET['typeoption']) {
$this->param['extramessage'] = "\t".implode("\t", $_GET['typeoption']);
}
}
public function after_newthread() {
global $_G;
$sortid = $this->param['sortid'];
$pid = $this->pid;
$_G['forum_optiondata'] = array();
if($this->forum['threadsorts']['types'][$sortid] && !$this->forum['allowspecialonly']) {
$_G['forum_optiondata'] = threadsort_validator($_GET['typeoption'], $pid);
}
if($this->forum['threadsorts']['types'][$sortid] && !empty($_G['forum_optiondata']) && is_array($_G['forum_optiondata'])) {
$sortaids = array();
$filedname = $valuelist = $separator = '';
$fid = $this->forum['fid'];
$tid = $this->tid;
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']);
}
$typeexpiration = intval($_GET['typeexpiration']);
C::t('forum_typeoptionvar')->insert(array(
'sortid' => $sortid,
'tid' => $tid,
'fid' => $fid,
'optionid' => $optionid,
'value' => $value,
'expiration' => ($typeexpiration ? $this->param['publishdate'] + $typeexpiration : 0),
));
}
if($filedname && $valuelist) {
C::t('forum_optionvalue')->insert_optionvalue($sortid, "($filedname, tid, fid) VALUES ($valuelist, '{$tid}', '$fid')");
}
if($sortaids) {
foreach($sortaids as $sortaid) {
convertunusedattach($sortaid, $tid, $pid);
}
}
}
}
public function before_editpost($parameters) {
global $_G;
$sortid = $parameters['sortid'];
$isfirstpost = $this->post['first'] ? 1 : 0;
if($isfirstpost) {
$parameters['typeid'] = isset($this->forum['threadtypes']['types'][$parameters['typeid']]) ? $parameters['typeid'] : 0;
if(!$this->forum['ismoderator'] && !empty($this->forum['threadtypes']['moderators'][$this->thread['typeid']])) {
$parameters['typeid'] = $this->thread['typeid'];
}
$parameters['sortid'] = isset($this->forum['threadsorts']['types'][$parameters['sortid']]) ? $parameters['sortid'] : 0;
$typeexpiration = intval($_GET['typeexpiration']);
if(!$parameters['typeid'] && $this->forum['threadtypes']['required'] && !$this->thread['special']) {
showmessage('post_type_isnull');
}
if($this->forum['threadsorts']['types'][$sortid] && $_G['forum_checkoption']) {
$_G['forum_optiondata'] = threadsort_validator($_GET['typeoption'], $this->post['pid']);
}
$this->param['threadimageaid'] = 0;
$this->param['threadimage'] = array();
if($this->forum['threadsorts']['types'][$parameters['sortid']] && $_G['forum_optiondata'] && is_array($_G['forum_optiondata'])) {
$sql = $separator = $filedname = $valuelist = '';
foreach($_G['forum_optiondata'] as $optionid => $value) {
$value = censor(daddslashes($value));
if($_G['forum_optionlist'][$optionid]['type'] == 'image') {
$identifier = $_G['forum_optionlist'][$optionid]['identifier'];
$newsortaid = intval($_GET['typeoption'][$identifier]['aid']);
if($newsortaid && $_GET['oldsortaid'][$identifier] && $newsortaid != $_GET['oldsortaid'][$identifier]) {
$attach = C::t('forum_attachment_n')->fetch_attachment('tid:'.$this->thread['tid'], $_GET['oldsortaid'][$identifier]);
C::t('forum_attachment')->delete($_GET['oldsortaid'][$identifier]);
C::t('forum_attachment_n')->delete_attachment('tid:'.$this->thread['tid'], $_GET['oldsortaid'][$identifier]);
dunlink($attach);
$this->param['threadimageaid'] = $newsortaid;
convertunusedattach($newsortaid, $this->thread['tid'], $this->post['pid']);
}
}
if($_G['forum_optionlist'][$optionid]['unchangeable']) {
continue;
}
if(($_G['forum_optionlist'][$optionid]['search'] || in_array($_G['forum_optionlist'][$optionid]['type'], array('radio', 'select', 'number'))) && $value) {
$filedname .= $separator.$_G['forum_optionlist'][$optionid]['identifier'];
$valuelist .= $separator."'$value'";
$sql .= $separator.$_G['forum_optionlist'][$optionid]['identifier']."='$value'";
$separator = ' ,';
}
C::t('forum_typeoptionvar')->update_by_tid($this->thread['tid'], array('value' => $value, 'sortid' => $parameters['sortid']), false, false, $optionid);
}
if($typeexpiration) {
C::t('forum_typeoptionvar')->update_by_tid($this->thread['tid'], array('expiration' => (TIMESTAMP + $typeexpiration)), false, false, null, $parameters['sortid']);
}
if($sql || ($filedname && $valuelist)) {
if(C::t('forum_optionvalue')->fetch_all_tid($parameters['sortid'], "WHERE tid='".$this->thread['tid']."'")) {
if($sql) {
C::t('forum_optionvalue')->update_optionvalue($parameters['sortid'], $this->thread['tid'], $this->forum['fid'], $sql);
}
} elseif($filedname && $valuelist) {
C::t('forum_optionvalue')->insert_optionvalue($parameters['sortid'], "($filedname, tid, fid) VALUES ($valuelist, '".$this->thread['tid']."', '".$this->forum['fid']."')");
}
}
}
}
}
public function after_deletepost() {
$isfirstpost = $this->post['first'] ? 1 : 0;
if($isfirstpost) {
C::t('forum_typeoptionvar')->delete_by_tid($this->thread['tid']);
}
}
}
?>

View File

@@ -0,0 +1,349 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_trade.php 34221 2013-11-15 09:10:23Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_trade extends extend_thread_base {
private $trademessage;
public function before_newthread($parameters) {
$item_price = floatval($_GET['item_price']);
$item_credit = intval($_GET['item_credit']);
$_GET['item_name'] = censor($_GET['item_name']);
if(!trim($_GET['item_name'])) {
return $this->showmessage('trade_please_name');
} elseif($this->group['maxtradeprice'] && $item_price > 0 && ($this->group['mintradeprice'] > $item_price || $this->group['maxtradeprice'] < $item_price)) {
return $this->showmessage('trade_price_between', '', array('mintradeprice' => $this->group['mintradeprice'], 'maxtradeprice' => $this->group['maxtradeprice']));
} elseif($this->group['maxtradeprice'] && $item_credit > 0 && ($this->group['mintradeprice'] > $item_credit || $this->group['maxtradeprice'] < $item_credit)) {
return $this->showmessage('trade_credit_between', '', array('mintradeprice' => $this->group['mintradeprice'], 'maxtradeprice' => $this->group['maxtradeprice']));
} elseif(!$this->group['maxtradeprice'] && $item_price > 0 && $this->group['mintradeprice'] > $item_price) {
return $this->showmessage('trade_price_more_than', '', array('mintradeprice' => $this->group['mintradeprice']));
} elseif(!$this->group['maxtradeprice'] && $item_credit > 0 && $this->group['mintradeprice'] > $item_credit) {
return $this->showmessage('trade_credit_more_than', '', array('mintradeprice' => $this->group['mintradeprice']));
} elseif($item_price <= 0 && $item_credit <= 0) {
return $this->showmessage('trade_pricecredit_need');
} elseif($_GET['item_number'] < 1) {
return $this->showmessage('tread_please_number');
}
if(!empty($_FILES['tradeattach']['tmp_name'][0])) {
$_FILES['attach'] = array_merge_recursive((array)$_FILES['attach'], $_FILES['tradeattach']);
}
if(($this->group['allowpostattach'] || $this->group['allowpostimage']) && is_array($_FILES['attach'])) {
foreach($_FILES['attach']['name'] as $attachname) {
if($attachname != '') {
checklowerlimit('postattach', 0, 1, $this->forum['fid']);
break;
}
}
}
$this->trademessage = $parameters['message'];
$this->param['message'] = '';
}
public function after_newthread() {
if(!$this->tid) {
return;
}
$this->trademessage = preg_replace('/\[attachimg\](\d+)\[\/attachimg\]/is', '[attach]\1[/attach]', $this->trademessage);
$pid = insertpost(array(
'fid' => $this->forum['fid'],
'tid' => $this->tid,
'first' => '0',
'author' => $this->member['username'],
'authorid' => $this->member['uid'],
'subject' => $this->param['subject'],
'dateline' => getglobal('timestamp'),
'message' => $this->trademessage,
'useip' => getglobal('clientip'),
'invisible' => 0,
'anonymous' => $this->param['isanonymous'],
'usesig' => $_GET['usesig'],
'htmlon' => $this->param['htmlon'],
'bbcodeoff' => 0,
'smileyoff' => $this->param['smileyoff'],
'parseurloff' => $this->param['parseurloff'],
'attachment' => 0,
'tags' => $this->param['tagstr'],
'status' => (defined('IN_MOBILE') ? 8 : 0)
));
if(!empty($_GET['tradeaid'])) {
convertunusedattach($_GET['tradeaid'], $this->tid, $pid);
}
($this->group['allowpostattach'] || $this->group['allowpostimage']) && ($_GET['attachnew'] || $_GET['tradeaid']) && updateattach($this->param['displayorder'] == -4 || $this->param['modnewthreads'], $this->tid, $pid, $_GET['attachnew']);
require_once libfile('function/trade');
$author = !$this->param['isanonymous'] ? $this->member['username'] : '';
trade_create(array(
'tid' => $this->tid,
'pid' => $pid,
'aid' => $_GET['tradeaid'],
'item_expiration' => $_GET['item_expiration'],
'thread' => $this->thread,
'discuz_uid' => $this->member['uid'],
'author' => $author,
'seller' => empty($_GET['paymethod']) && $_GET['seller'] ? dhtmlspecialchars(trim($_GET['seller'])) : '',
'tenpayaccount' => $_GET['tenpay_account'],
'item_name' => $_GET['item_name'],
'item_price' => $_GET['item_price'],
'item_number' => $_GET['item_number'],
'item_quality' => $_GET['item_quality'],
'item_locus' => $_GET['item_locus'],
'transport' => $_GET['transport'],
'postage_mail' => $_GET['postage_mail'],
'postage_express' => $_GET['postage_express'],
'postage_ems' => $_GET['postage_ems'],
'item_type' => $_GET['item_type'],
'item_costprice' => $_GET['item_costprice'],
'item_credit' => $_GET['item_credit'],
'item_costcredit' => $_GET['item_costcredit']
));
$this->param['tradepid'] = $pid;
}
public function before_feed() {
if(!empty($_GET['addfeed']) && $this->forum['allowfeed'] && !$this->param['isanonymous']) {
$this->feed['icon'] = 'goods';
$this->feed['title_template'] = 'feed_thread_goods_title';
if($_GET['item_price'] > 0) {
if($this->setting['creditstransextra'][5] != -1 && $_GET['item_credit']) {
$this->feed['body_template'] = 'feed_thread_goods_message_1';
} else {
$this->feed['body_template'] = 'feed_thread_goods_message_2';
}
} else {
$this->feed['body_template'] = 'feed_thread_goods_message_3';
}
$pid = $this->param['tradepid'];
$this->feed['body_data'] = array(
'itemname'=> "<a href=\"forum.php?mod=viewthread&do=tradeinfo&tid=".$this->tid."&pid=$pid\">{$_GET['item_name']}</a>",
'itemprice'=> $_GET['item_price'],
'itemcredit'=> $_GET['item_credit'],
'creditunit'=> $this->setting['extcredits'][$this->setting['creditstransextra'][5]]['unit'].$this->setting['extcredits'][$this->setting['creditstransextra'][5]]['title']
);
if($_GET['tradeaid']) {
$this->feed['images'] = array(getforumimg($_GET['tradeaid']));
$this->feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid=".$this->tid."&pid=$pid");
}
if($_GET['tradeaid']) {
$attachment = C::t('forum_attachment_n')->fetch_attachment('tid:'.$this->tid, $_GET['tradeaid']);
if(in_array($attachment['filetype'], array('image/gif', 'image/jpeg', 'image/png'))) {
$imgurl = $this->setting['attachurl'].'forum/'.($attachment['thumb'] && $attachment['filetype'] != 'image/gif' ? getimgthumbname($attachment['attachment']) : $attachment['attachment']);
$this->feed['images'][] = $attachment['attachment'] ? $imgurl : '';
$this->feed['image_links'][] = $attachment['attachment'] ? "forum.php?mod=viewthread&tid=".$this->tid : '';
}
}
}
}
public function after_feed() {
global $extra;
$values = array('fid' => $this->forum['fid'], 'tid' => $this->tid, 'pid' => $this->pid, 'coverimg' => '');
$values = array_merge($values, (array)$this->param['values'], $this->param['param']);
if(!empty($_GET['continueadd'])) {
showmessage('post_newthread_succeed', "forum.php?mod=post&action=reply&fid=".$this->forum['fid']."&tid=".$this->tid."&addtrade=yes", $values, array('header' => true));
} else {
showmessage('post_newthread_succeed', "forum.php?mod=viewthread&tid=".$this->tid."&extra=$extra", $values);
}
}
public function before_newreply($parameters) {
$item_price = floatval($_GET['item_price']);
$item_credit = intval($_GET['item_credit']);
if(!trim($_GET['item_name'])) {
return $this->showmessage('trade_please_name');
} elseif($this->group['maxtradeprice'] && $item_price > 0 && ($this->group['mintradeprice'] > $item_price || $this->group['maxtradeprice'] < $item_price)) {
return $this->showmessage('trade_price_between', '', array('mintradeprice' => $this->group['mintradeprice'], 'maxtradeprice' => $this->group['maxtradeprice']));
} elseif($this->group['maxtradeprice'] && $item_credit > 0 && ($this->group['mintradeprice'] > $item_credit || $this->group['maxtradeprice'] < $item_credit)) {
return $this->showmessage('trade_credit_between', '', array('mintradeprice' => $this->group['mintradeprice'], 'maxtradeprice' => $this->group['maxtradeprice']));
} elseif(!$this->group['maxtradeprice'] && $item_price > 0 && $this->group['mintradeprice'] > $item_price) {
return $this->showmessage('trade_price_more_than', '', array('mintradeprice' => $this->group['mintradeprice']));
} elseif(!$this->group['maxtradeprice'] && $item_credit > 0 && $this->group['mintradeprice'] > $item_credit) {
return $this->showmessage('trade_credit_more_than', '', array('mintradeprice' => $this->group['mintradeprice']));
} elseif($item_price <= 0 && $item_credit <= 0) {
return $this->showmessage('trade_pricecredit_need');
} elseif($_GET['item_number'] < 1) {
return $this->showmessage('tread_please_number');
}
}
public function after_newreply() {
if(!$this->pid) {
return;
}
if($this->param['special'] == 2 && $this->group['allowposttrade'] && $this->thread['authorid'] == $this->member['uid'] && !empty($_GET['trade']) && !empty($_GET['item_name'])) {
$author = (!$this->param['isanonymous']) ? $this->member['username'] : '';
require_once libfile('function/trade');
trade_create(array(
'tid' => $this->thread['tid'],
'pid' => $this->pid,
'aid' => $_GET['tradeaid'],
'item_expiration' => $_GET['item_expiration'],
'thread' => $this->thread,
'discuz_uid' => $this->member['uid'],
'author' => $author,
'seller' => empty($_GET['paymethod']) && $_GET['seller'] ? dhtmlspecialchars(trim($_GET['seller'])) : '',
'item_name' => $_GET['item_name'],
'item_price' => $_GET['item_price'],
'item_number' => $_GET['item_number'],
'item_quality' => $_GET['item_quality'],
'item_locus' => $_GET['item_locus'],
'transport' => $_GET['transport'],
'postage_mail' => $_GET['postage_mail'],
'postage_express' => $_GET['postage_express'],
'postage_ems' => $_GET['postage_ems'],
'item_type' => $_GET['item_type'],
'item_costprice' => $_GET['item_costprice'],
'item_credit' => $_GET['item_credit'],
'item_costcredit' => $_GET['item_costcredit']
));
if(!empty($_GET['tradeaid'])) {
convertunusedattach($_GET['tradeaid'], $this->thread['tid'], $this->pid);
}
}
if(!$this->forum['allowfeed'] || !$_GET['addfeed']) {
$this->after_replyfeed();
}
}
public function before_replyfeed() {
if($this->forum['allowfeed'] && !$this->param['isanonymous']) {
if($this->param['special'] == 2 && !empty($_GET['trade'])) {
$creditstransextra = $this->setting['creditstransextra'];
$extcredits = $this->setting['extcredits'];
$this->feed['icon'] = 'goods';
$this->feed['title_template'] = 'feed_thread_goods_title';
if($_GET['item_price'] > 0) {
if($creditstransextra[5] != -1 && $_GET['item_credit']) {
$this->feed['body_template'] = 'feed_thread_goods_message_1';
} else {
$this->feed['body_template'] = 'feed_thread_goods_message_2';
}
} else {
$this->feed['body_template'] = 'feed_thread_goods_message_3';
}
$this->feed['body_data'] = array(
'itemname'=> "<a href=\"forum.php?mod=viewthread&do=tradeinfo&tid=".$this->thread['tid']."&pid=".$this->pid."\">".dhtmlspecialchars($_GET['item_name'])."</a>",
'itemprice'=> $_GET['item_price'],
'itemcredit'=> $_GET['item_credit'],
'creditunit'=> $extcredits[$creditstransextra[5]]['unit'].$extcredits[$creditstransextra[5]]['title'],
);
if($_GET['tradeaid']) {
$this->feed['images'] = array(getforumimg($_GET['tradeaid']));
$this->feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid=".$this->thread['tid']."&pid=".$this->pid);
}
}
}
}
public function after_replyfeed() {
global $extra;
if($this->param['special'] == 2 && $this->group['allowposttrade'] && $this->thread['authorid'] == $this->member['uid']) {
if(!empty($_GET['continueadd'])) {
dheader("location: forum.php?mod=post&action=reply&fid=".$this->forum['fid']."&firstpid=".$this->pid."&tid=".$this->thread['tid']."&addtrade=yes");
} else {
if($this->param['modnewreplies']) {
$url = "forum.php?mod=viewthread&tid=".$this->thread['tid'];
} else {
$url = "forum.php?mod=viewthread&tid=".$this->thread['tid']."&pid=".$this->pid."&page=".$this->param['page']."&extra=".$extra."#pid".$this->pid;
}
return $this->showmessage('trade_add_succeed', $url, $this->param['showmsgparam']);
}
}
}
public function before_editpost($parameters) {
global $closed;
if($parameters['special'] == 2 && $this->group['allowposttrade']) {
if($trade = C::t('forum_trade')->fetch_goods($this->thread['tid'], $this->post['pid'])) {
$seller = empty($_GET['paymethod']) && $_GET['seller'] ? censor(dhtmlspecialchars(trim($_GET['seller']))) : '';
$item_name = censor(dhtmlspecialchars(trim($_GET['item_name'])));
$item_price = floatval($_GET['item_price']);
$item_credit = intval($_GET['item_credit']);
$item_locus = censor(dhtmlspecialchars(trim($_GET['item_locus'])));
$item_number = intval($_GET['item_number']);
$item_quality = intval($_GET['item_quality']);
$item_transport = intval($_GET['item_transport']);
$postage_mail = intval($_GET['postage_mail']);
$postage_express = intval(trim($_GET['postage_express']));
$postage_ems = intval($_GET['postage_ems']);
$item_type = intval($_GET['item_type']);
$item_costprice = floatval($_GET['item_costprice']);
if(!trim($item_name)) {
showmessage('trade_please_name');
} elseif($this->group['maxtradeprice'] && $item_price > 0 && ($this->group['mintradeprice'] > $item_price || $this->group['maxtradeprice'] < $item_price)) {
showmessage('trade_price_between', '', array('mintradeprice' => $this->group['mintradeprice'], 'maxtradeprice' => $this->group['maxtradeprice']));
} elseif($this->group['maxtradeprice'] && $item_credit > 0 && ($this->group['mintradeprice'] > $item_credit || $this->group['maxtradeprice'] < $item_credit)) {
showmessage('trade_credit_between', '', array('mintradeprice' => $this->group['mintradeprice'], 'maxtradeprice' => $this->group['maxtradeprice']));
} elseif(!$this->group['maxtradeprice'] && $item_price > 0 && $this->group['mintradeprice'] > $item_price) {
showmessage('trade_price_more_than', '', array('mintradeprice' => $this->group['mintradeprice']));
} elseif(!$this->group['maxtradeprice'] && $item_credit > 0 && $this->group['mintradeprice'] > $item_credit) {
showmessage('trade_credit_more_than', '', array('mintradeprice' => $this->group['mintradeprice']));
} elseif($item_price <= 0 && $item_credit <= 0) {
showmessage('trade_pricecredit_need');
} elseif($item_number < 1) {
showmessage('tread_please_number');
}
if($trade['aid'] && $_GET['tradeaid'] && $trade['aid'] != $_GET['tradeaid']) {
$attach = C::t('forum_attachment_n')->fetch_attachment('tid:'.$this->thread['tid'], $trade['aid']);
C::t('forum_attachment')->delete($trade['aid']);
C::t('forum_attachment_n')->delete_attachment('tid:'.$this->thread['tid'], $trade['aid']);
dunlink($attach);
$this->param['threadimageaid'] = $_GET['tradeaid'];
convertunusedattach($_GET['tradeaid'], $this->thread['tid'], $this->post['pid']);
}
$expiration = $_GET['item_expiration'] ? @strtotime($_GET['item_expiration']) : 0;
$closed = $expiration > 0 && @strtotime($_GET['item_expiration']) < TIMESTAMP ? 1 : $closed;
switch($_GET['transport']) {
case 'seller':$item_transport = 1;break;
case 'buyer':$item_transport = 2;break;
case 'virtual':$item_transport = 3;break;
case 'logistics':$item_transport = 4;break;
}
if(!$item_price || $item_price <= 0) {
$item_price = $postage_mail = $postage_express = $postage_ems = '';
}
$data = array('aid' => $_GET['tradeaid'], 'account' => $seller, 'tenpayaccount' => $_GET['tenpay_account'], 'subject' => $item_name, 'price' => $item_price, 'amount' => $item_number, 'quality' => $item_quality, 'locus' => $item_locus, 'transport' => $item_transport, 'ordinaryfee' => $postage_mail, 'expressfee' => $postage_express, 'emsfee' => $postage_ems, 'itemtype' => $item_type, 'expiration' => $expiration, 'closed' => $closed, 'costprice' => $item_costprice, 'credit' => $item_credit, 'costcredit' => $_GET['item_costcredit']);
C::t('forum_trade')->update_trade($this->thread['tid'], $this->post['pid'], $data);
if(!empty($_GET['infloat'])) {
$viewpid = C::t('forum_post')->fetch_threadpost_by_tid_invisible($this->thread['tid']);
$viewpid = $viewpid['pid'];
$this->param['redirecturl'] = "forum.php?mod=viewthread&tid=".$this->thread['tid']."&viewpid=$viewpid#pid$viewpid";
} else {
$this->param['redirecturl'] = "forum.php?mod=viewthread&do=tradeinfo&tid=".$this->thread['tid']."&pid=".$this->post['pid'];
}
}
}
}
public function after_deletepost() {
if($this->thread['special'] == 2) {
C::t('forum_trade')->delete_by_id_idtype($this->post['pid'], 'pid');
}
}
}
?>

View File