[PHP] 纯文本查看 复制代码<?php
define('APPTYPEID', 100);
define('CURSCRIPT', 'appapi');
require './source/class/class_core.php';
$discuz = & discuz_core::instance();
//$discuz->init_mobile = false;
$discuz->init();
$ac = $_G['gp_ac'];
if(empty($_GET['ac']) || !in_array($_GET['ac'], array('pushthread'))) $_GET['ac'] = 'index';
define('CURMODULE', $_GET['ac']);
runhooks();
$discuz_url = "https://www.baidu.com";
$json = file_get_contents("php://input");
$json = json_decode($json, true);
$json = api_utf8_to_gbk($json);
if($ac == 'pushthread' && $json['key'] == 'jfjoff979868sjcoidscio'){
// $_POST = array(
// 'thread' => $thread,
// 'thread_forum_attachment' => $thread_forum_attachment,
// 'thread_forum_attachment_subs' => $thread_forum_attachment_subs,
// 'thread_posts' => $thread_posts,
// );
$thread = arrayaddslashes($json['thread']);
unset($thread['isposttoline']);
$thread_forum_attachment = arrayaddslashes($json['thread_forum_attachment']);
$thread_forum_attachment_subs = arrayaddslashes($json['thread_forum_attachment_subs']);
$thread_posts = arrayaddslashes($json['thread_posts']);
$posttableid = $thread['posttableid'] > 0 ? '_'.$thread['posttableid'] : '';
// echo "
";
// print_r($json);
// echo "
";// exit;
//记录到图书表 tid=''
if(empty($thread['tid']) || empty($thread['subject']) ){
exit('参数不完整');
}
//thread表
if($thread){
DB::insert('forum_thread', $thread);
//useractionlog($thread['authorid'], 'tid');
DB::update('common_member_field_home', array('recentnote'=>$thread['subject']), array('uid'=>$thread['authorid']));
//updatepostcredits('+', $thread['authorid'], 'post', $thread['fid']);
$newlastpost = "$thread[tid]\t$thread[subject]\t$_G[timestamp]\t$thread[author]";
DB::query("UPDATE ".DB::table('forum_forum')." SET lastpost='$newlastpost', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='$thread[fid]'", 'UNBUFFERED');
}
//post或分表
if($thread_posts){
for ($i=0;$i
DB::insert('forum_post'.$posttableid, $thread_posts[$i]);
}
DB::query("UPDATE ".DB::table('common_member_count')." SET posts=posts+1 WHERE uid='".$thread['authorid']."'", 'UNBUFFERED');
DB::query("UPDATE ".DB::table('common_member_status')." SET lastip='$_G[clientip]',lastvisit='$_G[timestamp]',lastactivity='$_G[timestamp]',lastpost='$_G[timestamp]' WHERE uid='".$thread['authorid']."'", 'UNBUFFERED');
}
//attachment主表
if($thread_forum_attachment){
DB::insert('forum_attachment', $thread_forum_attachment);
}
//attachment分表
if($thread_forum_attachment_subs){
for ($i=0; $i
DB::insert('forum_attachment_'.$thread_forum_attachment['tableid'], $thread_forum_attachment_subs[$i]);
}
}
$url = $discuz_url."/thread-".$thread['tid']."-1-1.html";
echo $url;
exit;
}else{
exit('nothing');
}
function arrayaddslashes($string) {
if(is_array($string)) {
foreach($string as $key => $value) {
$string[$key] = arrayaddslashes($value);
}
} else {
$string = addslashes($string);
}
return $string;
}
function api_utf8_to_gbk($string) {
if(is_array($string)) {
foreach($string as $key => $value) {
$string[$key] = api_utf8_to_gbk($value);
}
} else {
//$string = diconv($string,'utf-8', CHARSET);
if(mb_detect_encoding($string, 'UTF-8',true) === 'UTF-8'){
$string = iconv('UTF-8','gbk',$string);
}
}
return $string;
}
?>