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

27
.gitignore vendored Normal file
View File

@@ -0,0 +1,27 @@
data/**
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
__MACOSX/*

71
admin.php Normal file
View File

@@ -0,0 +1,71 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admin.php 34285 2013-12-13 03:39:35Z hypowang $
*/
define('IN_ADMINCP', TRUE);
define('NOROBOT', TRUE);
define('ADMINSCRIPT', basename(__FILE__));
define('CURSCRIPT', 'admin');
define('HOOKTYPE', 'hookscript');
define('APPTYPEID', 0);
require './source/class/class_core.php';
require './source/function/function_misc.php';
require './source/function/function_forum.php';
require './source/function/function_admincp.php';
require './source/function/function_cache.php';
$discuz = C::app();
$discuz->init_cron = false;
$discuz->init();
$admincp = new discuz_admincp();
$admincp->core = & $discuz;
$admincp->init();
$admincp_actions_founder = array('templates', 'db', 'founder', 'postsplit', 'threadsplit', 'cloudaddons', 'optimizer', 'runtests');
$admincp_actions_normal = array('index', 'setting', 'members', 'admingroup', 'usergroups', 'usertag',
'forums', 'threadtypes', 'threads', 'moderate', 'attach', 'smilies', 'recyclebin', 'recyclebinpost', 'prune', 'grid',
'styles', 'addons', 'plugins', 'tasks', 'magics', 'medals', 'announce', 'faq', 'ec', 'remoderate', 'smsgw',
'tradelog', 'jswizard', 'project', 'counter', 'misc', 'adv', 'logs', 'tools', 'portalperm', 'blogrecyclebin',
'checktools', 'search', 'article', 'block', 'blockstyle', 'blockxml', 'portalcategory', 'blogcategory', 'albumcategory', 'topic', 'credits',
'doing', 'group', 'blog', 'feed', 'album', 'pic', 'comment', 'share', 'click', 'specialuser', 'postsplit', 'threadsplit', 'report',
'district', 'diytemplate', 'verify', 'nav', 'domain', 'postcomment', 'tag', 'connect', 'card', 'portalpermission', 'collection', 'membersplit', 'makehtml');
$action = preg_replace('/[^\[A-Za-z0-9_\]]/', '', getgpc('action'));
$operation = preg_replace('/[^\[A-Za-z0-9_\]]/', '', getgpc('operation'));
$do = preg_replace('/[^\[A-Za-z0-9_\]]/', '', getgpc('do'));
$frames = preg_replace('/[^\[A-Za-z0-9_\]]/', '', getgpc('frames'));
lang('admincp');
$lang = & $_G['lang']['admincp'];
$page = max(1, intval(getgpc('page')));
$isfounder = $admincp->isfounder;
if(empty($action) || $frames != null) {
$admincp->show_admincp_main();
} elseif($action == 'logout') {
$admincp->do_admin_logout();
dheader("Location: ./index.php");
} elseif(in_array($action, $admincp_actions_normal) || ($admincp->isfounder && in_array($action, $admincp_actions_founder))) {
if($admincp->allow($action, $operation, $do) || $action == 'index') {
require $admincp->admincpfile($action);
} else {
cpheader();
cpmsg('action_noaccess', '', 'error');
}
} else {
cpheader();
if($action == 'cloudaddons') {
cpmsg('cloudaddons_noaccess', '', 'error');
} else {
cpmsg('action_noaccess', '', 'error');
}
}
?>

32
api.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: api.php 33591 2013-07-12 06:39:49Z andyzheng $
*/
define('IN_API', true);
define('CURSCRIPT', 'api');
$modarray = array('js' => 'javascript/javascript', 'ad' => 'javascript/advertisement');
$mod = !empty($_GET['mod']) ? $_GET['mod'] : '';
if(empty($mod) || !in_array($mod, array('js', 'ad'))) {
exit('Access Denied');
}
require_once './api/'.$modarray[$mod].'.php';
function loadcore() {
global $_G;
require_once './source/class/class_core.php';
$discuz = C::app();
$discuz->init_cron = false;
$discuz->init_session = false;
$discuz->init();
}
?>

20
api/addons/channel.htm Normal file
View File

@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="renderer" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script type="text/javascript">
var querystring = location.search.substr(1);
if(querystring.indexOf('/') != -1) {
var e = querystring.split('/');
var url = '../../admin.php?frames=yes&action=cloudaddons&operation=download&addonids=' + e[0] + '&md5hash=' + e[1] + '&timestamp=' + e[2];
try {
top.location.href = url;
} catch(e) {}
}
</script>
</head>
<body>
</body>
</html>

0
api/addons/index.htm Normal file
View File

9
api/addons/zendcheck.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
if(phpversion() >= '5.3') {
include 'zendcheck53.php';
} else {
include 'zendcheck52.php';
}
?>

View File

@@ -0,0 +1,3 @@
<?php @Zend;
4123;
/*

View File

@@ -0,0 +1,3 @@
<?php @Zend;
3074;
/*

21
api/avatar/index.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
require_once '../../source/class/class_core.php';
$discuz = C::app();
$discuz->init();
if(getgpc('m') !== 'user' || getgpc('a') !== 'rectavatar') {
exit;
}
loaducenter();
if(!UC_AVTPATH) {
$avtpath = './data/avatar/';
} else {
$avtpath = str_replace('..', '', UC_AVTPATH);
}
define('UC_UPAVTDIR', realpath(DISCUZ_ROOT.$avtpath).'/');
if(!empty($_G['uid'])) {
echo uc_rectavatar($_G['uid']);
} else {
echo uc_rectavatar(0);
}

795
api/db/dbbak.php Normal file
View File

@@ -0,0 +1,795 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: dbbak.php 35016 2014-10-13 08:16:14Z nemohou $
*/
@define('IN_API', true);
@define('CURSCRIPT', 'api');
error_reporting(0);
$code = @$_GET['code'];
$apptype = @$_GET['apptype'];
$apptype = strtolower($apptype);
define('IN_COMSENZ', TRUE);
if($apptype == 'discuzx') {
define('ROOT_PATH', dirname(__FILE__).'/../../');
} else {
define('ROOT_PATH', dirname(__FILE__).'/../');
}
define('EXPLOR_SUCCESS', 0);
define('IMPORT_SUCCESS', 0);
define('DELETE_SQLPATH_SUCCESS', 4);
define('MKDIR_ERROR', 1);
define('DATABASE_EXPORT_FILE_INVALID', 2);
define('RUN_SQL_ERROR', 3);
define('SQLPATH_NULL_NOEXISTS', 4);
define('SQLPATH_NOMATCH_BAKFILE', 5);
define('BAK_FILE_LOSE', 6);
define('DIR_NO_EXISTS', 7);
define('DELETE_DUMPFILE_ERROR', 8);
define('DB_API_NO_MATCH', 9);
$sizelimit = 2000;
$usehex = true;
if($apptype == 'discuz') {
require ROOT_PATH.'./config.inc.php';
} elseif($apptype == 'uchome' || $apptype == 'supesite' || $apptype == 'supev') {
require ROOT_PATH.'./config.php';
} elseif($apptype == 'ucenter') {
require ROOT_PATH.'./data/config.inc.php';
} elseif($apptype == 'ecmall') {
require ROOT_PATH.'./data/inc.config.php';
} elseif($apptype == 'ecshop') {
require ROOT_PATH.'./data/config.php';
} elseif($apptype == 'discuzx') {
require ROOT_PATH.'./config/config_global.php';
require ROOT_PATH.'./config/config_ucenter.php';
} else {
api_msg('db_api_no_match', $apptype);
}
parse_str(_authcode($code, 'DECODE', UC_KEY), $get);
if(empty($get)) {
exit('Invalid Request');
}
$timestamp = time();
if($timestamp - $get['time'] > 3600) {
exit('Authorization has expired');
}
$get['time'] = $timestamp;
class dbstuffi {
var $querynum = 0;
var $link;
var $histories;
var $time;
var $tablepre;
function connect($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = '', $pconnect = 0, $tablepre='', $time = 0) {
$this->time = $time;
$this->tablepre = $tablepre;
mysqli_report(MYSQLI_REPORT_OFF);
$this->link = new mysqli();
if(!$this->link->real_connect($dbhost, $dbuser, $dbpw, $dbname, null, null, MYSQLI_CLIENT_COMPRESS)) {
$this->halt('Can not connect to MySQL server');
}
if($dbcharset) {
$this->link->set_charset($dbcharset);
}
$this->link->query("SET sql_mode=''");
$this->link->query("SET character_set_client=binary");
}
function fetch_array($query, $result_type = MYSQLI_ASSOC) {
return $query ? $query->fetch_array($result_type) : null;
}
function result_first($sql) {
$query = $this->query($sql);
return $this->result($query, 0);
}
function fetch_first($sql) {
$query = $this->query($sql);
return $this->fetch_array($query);
}
function fetch_all($sql) {
$arr = array();
$query = $this->query($sql);
while($data = $this->fetch_array($query)) {
$arr[] = $data;
}
return $arr;
}
function cache_gc() {
$this->query("DELETE FROM {$this->tablepre}sqlcaches WHERE expiry<$this->time");
}
function query($sql, $type = '', $cachetime = FALSE) {
$resultmode = $type == 'UNBUFFERED' ? MYSQLI_USE_RESULT : MYSQLI_STORE_RESULT;
if(!($query = $this->link->query($sql, $resultmode)) && $type != 'SILENT') {
$this->halt('MySQL Query Error', $sql);
}
$this->querynum++;
$this->histories[] = $sql;
return $query;
}
function affected_rows() {
return $this->link->affected_rows;
}
function error() {
return $this->link->error;
}
function errno() {
return $this->link->errno;
}
function result($query, $row) {
if(!$query || $query->num_rows == 0) {
return null;
}
$query->data_seek($row);
$assocs = $query->fetch_row();
return $assocs[0];
}
function num_rows($query) {
$query = $query ? $query->num_rows : 0;
return $query;
}
function num_fields($query) {
return $query ? $query->field_count : 0;
}
function free_result($query) {
return $query ? $query->free() : false;
}
function insert_id() {
return ($id = $this->link->insert_id) >= 0 ? $id : $this->result($this->query("SELECT last_insert_id()"), 0);
}
function fetch_row($query) {
$query = $query ? $query->fetch_row() : null;
return $query;
}
function fetch_fields($query) {
return $query ? $query->fetch_field() : null;
}
function version() {
return $this->link->server_info;
}
function escape_string($str) {
return $this->link->escape_string($str);
}
function close() {
return $this->link->close();
}
function halt($message = '', $sql = '') {
api_msg('run_sql_error', $message.'<br /><br />'.$sql.'<br /> '.$this->link->error());
}
}
$db = new dbstuffi();
$version = '';
if($apptype == 'discuz') {
define('BACKUP_DIR', ROOT_PATH.'forumdata/');
$tablepre = $tablepre;
if(empty($dbcharset)) {
$dbcharset = in_array(strtolower($charset), array('gbk', 'big5', 'utf-8')) ? str_replace('-', '', $charset) : '';
}
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $dbcharset, $pconnect, $tablepre);
define('IN_DISCUZ', true);
include ROOT_PATH.'discuz_version.php';
$version = DISCUZ_VERSION;
} elseif($apptype == 'uchome' || $apptype == 'supesite') {
define('BACKUP_DIR', ROOT_PATH.'./data/');
$tablepre = $_SC['tablepre'];
$dbcharset = $_SC['dbcharset'];
$db->connect($_SC['dbhost'], $_SC['dbuser'], $_SC['dbpw'], $_SC['dbname'], $dbcharset, $_SC['pconnect'], $tablepre);
} elseif($apptype == 'ucenter') {
define('BACKUP_DIR', ROOT_PATH.'./data/backup/');
$tablepre = UC_DBTABLEPRE;
$dbcharset = UC_DBCHARSET;
$db->connect(UC_DBHOST, UC_DBUSER, UC_DBPW, UC_DBNAME, $dbcharset, UC_DBCONNECT, $tablepre);
} elseif($apptype == 'ecmall') {
define('BACKUP_DIR', ROOT_PATH.'./data/backup/');
$tablepre = DB_PREFIX;
$dbcharset = strtolower(str_replace('-', '', strstr(LANG, '-')));
$cfg = parse_url(DB_CONFIG);
if(empty($cfg['pass'])) {
$cfg['pass'] = '';
} else {
$cfg['pass'] = urldecode($cfg['pass']);
}
$cfg['user'] = urldecode($cfg['user']);
$cfg['path'] = str_replace('/', '', $cfg['path']);
$db->connect($cfg['host'].':'.$cfg['port'], $cfg['user'], $cfg['pass'], $cfg['path'], $dbcharset, 0, $tablepre);
} elseif($apptype == 'supev') {
define('BACKUP_DIR', ROOT_PATH.'data/backup/');
$tablepre = $tablepre;
if(empty($dbcharset)) {
$dbcharset = in_array(strtolower($_config['output']['charset']), array('gbk', 'big5', 'utf-8')) ? str_replace('-', '', CHARSET) : '';
}
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $dbcharset, $pconnect, $tablepre);
} elseif($apptype == 'ecshop') {
define('BACKUP_DIR', ROOT_PATH.'data/backup/');
$tablepre = $prefix;
$dbcharset = 'utf8';
$db->connect($db_host, $db_user, $db_pass, $db_name, $dbcharset, 0, $tablepre);
} elseif($apptype == 'discuzx') {
define('BACKUP_DIR', ROOT_PATH.'data/');
extract($_config['db']['1']);
if(empty($dbcharset)) {
$dbcharset = in_array(strtolower(CHARSET), array('gbk', 'big5', 'utf-8')) ? str_replace('-', '', $_config['output']['charset']) : '';
}
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $dbcharset, $pconnect, $tablepre);
define('IN_DISCUZ', true);
include ROOT_PATH.'source/discuz_version.php';
$version = DISCUZ_VERSION;
}
if($get['method'] == 'export') {
$db->query('SET SQL_QUOTE_SHOW_CREATE=0', 'SILENT');
$time = date("Y-m-d H:i:s", $timestamp);
$tables = array();
$tables = arraykeys2(fetchtablelist($tablepre), 'Name');
if($apptype == 'discuz') {
$query = $db->query("SELECT datatables FROM {$tablepre}plugins WHERE datatables<>''");
while($plugin = $db->fetch_array($query)) {
foreach(explode(',', $plugin['datatables']) as $table) {
if($table = trim($table)) {
$tables[] = $table;
}
}
}
}
if($apptype == 'discuzx') {
$query = $db->query("SELECT datatables FROM {$tablepre}common_plugin WHERE datatables<>''");
while($plugin = $db->fetch_array($query)) {
foreach(explode(',', $plugin['datatables']) as $table) {
if($table = trim($table)) {
$tables[] = $table;
}
}
}
}
$memberexist = array_search("{$tablepre}common_member", $tables);
if($memberexist !== FALSE) {
unset($tables[$memberexist]);
array_unshift($tables, "{$tablepre}common_member");
}
$get['volume'] = isset($get['volume']) ? intval($get['volume']) : 0;
$get['volume'] = $get['volume'] + 1;
$version = $version ? $version : $apptype;
$idstring = '# Identify: '.base64_encode("$timestamp,$version,$apptype,multivol,{$get['volume']}")."\n";
if(!isset($get['sqlpath']) || empty($get['sqlpath'])) {
$get['sqlpath'] = 'backup_'.date('ymd', $timestamp).'_'.random(6);
if(!mkdir(BACKUP_DIR.'./'.$get['sqlpath'], 0777)) {
api_msg('mkdir_error', 'make dir error:'.BACKUP_DIR.'./'.$get['sqlpath']);
}
} else {
$get['sqlpath'] = str_replace(array('/', '\\', '.', "'"), '', $get['sqlpath']);
if(!is_dir(BACKUP_DIR.'./'.$get['sqlpath'])) {
if(!mkdir(BACKUP_DIR.'./'.$get['sqlpath'], 0777)) {
api_msg('mkdir_error', 'make dir error:'.BACKUP_DIR.'./'.$get['sqlpath']);
}
}
}
if(!isset($get['backupfilename']) || empty($get['backupfilename'])) {
$get['backupfilename'] = date('ymd', $timestamp).'_'.random(6);
}
$sqldump = '';
$get['tableid'] = isset($get['tableid']) ? intval($get['tableid']) : 0;
$get['startfrom'] = isset($get['startfrom']) ? intval($get['startfrom']) : 0;
if(!$get['tableid'] && $get['volume'] == 1) {
foreach($tables as $table) {
$sqldump .= sqldumptablestruct($table);
}
}
$complete = TRUE;
for(; $complete && $get['tableid'] < count($tables) && strlen($sqldump) + 500 < $sizelimit * 1000; $get['tableid']++) {
$sqldump .= sqldumptable($tables[$get['tableid']], strlen($sqldump));
if($complete) {
$get['startfrom'] = 0;
}
}
!$complete && $get['tableid']--;
$dumpfile = BACKUP_DIR.$get['sqlpath'].'/'.$get['backupfilename'].'-'.$get['volume'].'.sql';
if(trim($sqldump)) {
$sqldump = "$idstring".
"# <?php exit();?>\n".
"# $apptype Multi-Volume Data Dump Vol.{$get['volume']}\n".
"# Time: $time\n".
"# Type: $apptype\n".
"# Table Prefix: $tablepre\n".
"# $dbcharset\n".
"# $apptype Home: https://www.discuz.vip\n".
"# Please visit our website for newest infomation about $apptype\n".
"# --------------------------------------------------------\n\n\n".
$sqldump;
$fp = fopen($dumpfile, 'cb');
if(!($fp && flock($fp, LOCK_EX) && ftruncate($fp, 0) && fwrite($fp, $sqldump) && fflush($fp) && flock($fp, LOCK_UN) && fclose($fp))) {
flock($fp, LOCK_UN);
fclose($fp);
api_msg('database_export_file_invalid', $dumpfile);
} else {
auto_next($get, $dumpfile);
}
} else {
@touch(BACKUP_DIR.$get['sqlpath'].'/index.htm');
api_msg('explor_success', 'explor_success');
}
} elseif($get['method'] == 'import') {
if(!isset($get['dumpfile']) || empty($get['dumpfile'])) {
$get['dumpfile'] = get_dumpfile_by_path($get['sqlpath']);
$get['volume'] = 0;
}
if(!preg_match('/^backup_(\d+)_\w+$/', $get['sqlpath']) || !preg_match('/^\d+_\w+\-(\d+).sql$/', $get['dumpfile'])) {
api_msg('bak_file_lose', $get['dumpfile']);
}
$get['volume']++;
$next_dumpfile = preg_replace('/^(\d+)\_(\w+)\-(\d+)\.sql$/', '\\1_\\2-'.$get['volume'].'.sql', $get['dumpfile']);
if(!is_file(BACKUP_DIR.$get['sqlpath'].'/'.$get['dumpfile'])) {
if(is_file(BACKUP_DIR.$get['sqlpath'].'/'.$next_dumpfile)) {
api_msg('bak_file_lose', $get['dumpfile']);
} else {
api_msg('import_success', 'import_success');
}
}
$sqldump = file_get_contents(BACKUP_DIR.$get['sqlpath'].'/'.$get['dumpfile']);
$sqlquery = splitsql($sqldump);
unset($sqldump);
foreach($sqlquery as $sql) {
$sql = syntablestruct(trim($sql), true, $dbcharset);
if($sql != '') {
$db->query($sql, 'SILENT');
if(($sqlerror = $db->error()) && $db->errno() != 1062) {
$db->halt('MySQL Query Error', $sql);
}
}
}
$cur_file = $get['dumpfile'];
$get['dumpfile'] = $next_dumpfile;
auto_next($get, BACKUP_DIR.$get['sqlpath'].'/'.$cur_file);
} elseif($get['method'] == 'ping') {
if($get['dir'] && is_dir(BACKUP_DIR.$get['dir'])) {
echo "1";exit;
} else {
echo "-1";exit;
}
} elseif($get['method'] == 'list') {
$str = "<root>\n";
$directory = dir(BACKUP_DIR);
while($entry = $directory->read()) {
$filename = BACKUP_DIR.$entry;
if(is_dir($filename) && preg_match('/^backup_(\d+)_\w+$/', $entry, $match)) {
$str .= "\t<dir>\n";
$str .= "\t\t<dirname>$filename</dirname>\n";
$str .= "\t\t<dirdate>$match[1]</dirdate>\n";
$str .= "\t</dir>\n";
}
}
$directory->close();
$str .= "</root>";
send_mime_type_header();
echo $str;
exit;
} elseif($get['method'] == 'view') {
$sqlpath = trim($get['sqlpath']);
if(empty($sqlpath) || !is_dir(BACKUP_DIR.$sqlpath)) {
api_msg('dir_no_exists', $sqlpath);
}
$str = "<root>\n";
$directory = dir(BACKUP_DIR.$sqlpath);
while($entry = $directory->read()) {
$filename = BACKUP_DIR.$sqlpath.'/'.$entry;
if(is_file($filename) && preg_match('/\d+_\w+\-(\d+).sql$/', $filename, $match)) {
$str .= "\t<file>\n";
$str .= "\t\t<file_name>$match[0]</file_name>\n";
$str .= "\t\t<file_size>".filesize($filename)."</file_size>\n";
$str .= "\t\t<file_num>$match[1]</file_num>\n";
$str .= "\t\t<file_url>".str_replace(ROOT_PATH, (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].'/', $filename)."</file_url>\n";
$str .= "\t\t<last_modify>".filemtime($filename)."</last_modify>\n";
$str .= "\t</file>\n";
}
}
$directory->close();
$str .= "</root>";
send_mime_type_header();
echo $str;
exit;
} elseif($get['method'] == 'delete') {
$sqlpath = trim($get['sqlpath']);
if(empty($sqlpath) || !is_dir(BACKUP_DIR.$sqlpath) || !preg_match('/^backup_(\d+)_\w+$/', $get['sqlpath'])) {
api_msg('dir_no_exists', $sqlpath);
}
$directory = dir(BACKUP_DIR.$sqlpath);
while($entry = $directory->read()) {
$filename = BACKUP_DIR.$sqlpath.'/'.$entry;
if(is_file($filename) && preg_match('/^\d+_\w+\-(\d+).sql$/', $entry) && !@unlink($filename)) {
api_msg('delete_dumpfile_error', $filename);
}
}
$directory->close();
@rmdir(BACKUP_DIR.$sqlpath);
api_msg('delete_sqlpath_success', 'delete_sqlpath_success');
}
function syntablestruct($sql, $version, $dbcharset) {
if(strpos(trim(substr($sql, 0, 18)), 'CREATE TABLE') === FALSE) {
return $sql;
}
$sqlversion = strpos($sql, 'ENGINE=') === FALSE ? FALSE : TRUE;
if($sqlversion === $version) {
return $sqlversion && $dbcharset ? preg_replace(array('/ character set \w+/i', '/ collate \w+/i', "/DEFAULT CHARSET=\w+/is"), array('', '', "DEFAULT CHARSET=$dbcharset"), $sql) : $sql;
}
if($version) {
return preg_replace(array('/TYPE=HEAP/i', '/TYPE=(\w+)/is'), array("ENGINE=MEMORY DEFAULT CHARSET=$dbcharset", "ENGINE=\\1 DEFAULT CHARSET=$dbcharset"), $sql);
} else {
return preg_replace(array('/character set \w+/i', '/collate \w+/i', '/ENGINE=MEMORY/i', '/\s*DEFAULT CHARSET=\w+/is', '/\s*COLLATE=\w+/is', '/ENGINE=(\w+)(.*)/is'), array('', '', 'ENGINE=HEAP', '', '', 'TYPE=\\1\\2'), $sql);
}
}
function splitsql($sql) {
$sql = str_replace("\r", "\n", $sql);
$ret = array();
$num = 0;
$queriesarray = explode(";\n", trim($sql));
unset($sql);
foreach($queriesarray as $query) {
$ret[$num] = isset($ret[$num]) ? $ret[$num] : '';
$queries = explode("\n", trim($query));
foreach($queries as $query) {
$ret[$num] .= isset($query[0]) && $query[0] == "#" ? NULL : $query;
}
$num++;
}
return($ret);
}
function get_dumpfile_by_path($path) {
if(empty($path) || !is_dir(BACKUP_DIR.$path)) {
api_msg('sqlpath_null_noexists', $path);
}
$directory = dir(BACKUP_DIR.$path);
while($entry = $directory->read()) {
$filename = BACKUP_DIR.$path.'/'.$entry;
if(is_file($filename)) {
if(preg_match('/^\d+\_\w+\-\d+\.sql$/', $entry)) {
$file_bakfile = preg_replace('/^(\d+)\_(\w+)\-(\d+)\.sql$/', '\\1_\\2-1.sql', $entry);
if(is_file(BACKUP_DIR.$path.'/'.$file_bakfile)) {
return $file_bakfile;
} else {
api_msg('sqlpath_nomatch_bakfile', $path);
}
}
}
}
$directory->close();
api_msg('sqlpath_nomatch_bakfile', $path);
}
function api_msg($code, $msg) {
$msg = htmlspecialchars($msg);
$out = "<root>\n";
$out .= "\t<error errorCode=\"".constant(strtoupper($code))."\" errorMessage=\"$msg\" />\n";
$out .= "\t<fileinfo>\n";
$out .= "\t\t<file_num></file_num>\n";
$out .= "\t\t<file_size></file_size>\n";
$out .= "\t\t<file_name></file_name>\n";
$out .= "\t\t<file_url></file_url>\n";
$out .= "\t\t<last_modify></last_modify>\n";
$out .= "\t</fileinfo>\n";
$out .= "\t<nexturl></nexturl>\n";
$out .= "</root>";
send_mime_type_header();
echo $out;
exit;
}
function arraykeys2($array, $key2) {
$return = array();
foreach($array as $val) {
$return[] = $val[$key2];
}
return $return;
}
function auto_next($get, $sqlfile) {
$next_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?apptype='.$GLOBALS['apptype'].'&code='.urlencode(encode_arr($get));
$out = "<root>\n";
$out .= "\t<error errorCode=\"0\" errorMessage=\"ok\" />\n";
$out .= "\t<fileinfo>\n";
$out .= "\t\t<file_num>{$get['volume']}</file_num>\n";
$out .= "\t\t<file_size>".filesize($sqlfile)."</file_size>\n";
$out .= "\t\t<file_name>".basename($sqlfile)."</file_name>\n";
$out .= "\t\t<file_url>".str_replace(ROOT_PATH, (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].'/', $sqlfile)."</file_url>\n";
$out .= "\t\t<last_modify>".filemtime($sqlfile)."</last_modify>\n";
$out .= "\t</fileinfo>\n";
$out .= "\t<nexturl><![CDATA[$next_url]]></nexturl>\n";
$out .= "</root>";
send_mime_type_header();
echo $out;
exit;
}
function encode_arr($get) {
$tmp = '';
foreach($get as $key => $val) {
$tmp .= '&'.$key.'='.$val;
}
return _authcode($tmp, 'ENCODE', UC_KEY);
}
function sqldumptablestruct($table) {
global $db;
$createtable = $db->query("SHOW CREATE TABLE $table", 'SILENT');
if(!$db->error()) {
$tabledump = "DROP TABLE IF EXISTS $table;\n";
} else {
return '';
}
$create = $db->fetch_row($createtable);
if(strpos($table, '.') !== FALSE) {
$tablename = substr($table, strpos($table, '.') + 1);
$create[1] = str_replace("CREATE TABLE $tablename", 'CREATE TABLE '.$table, $create[1]);
}
$tabledump .= $create[1];
$tablestatus = $db->fetch_first("SHOW TABLE STATUS LIKE '$table'");
$tabledump .= ($tablestatus['Auto_increment'] ? " AUTO_INCREMENT={$tablestatus['Auto_increment']}" : '').";\n\n";
return $tabledump;
}
function sqldumptable($table, $currsize = 0) {
global $get, $db, $sizelimit, $startrow, $extendins, $sqlcompat, $sqlcharset, $dumpcharset, $usehex, $complete, $excepttables;
$offset = 300;
$tabledump = '';
$tablefields = array();
$query = $db->query("SHOW FULL COLUMNS FROM $table", 'SILENT');
if(strexists($table, 'adminsessions')) {
return ;
} elseif(!$query && $db->errno() == 1146) {
return;
} elseif(!$query) {
$usehex = FALSE;
} else {
while($fieldrow = $db->fetch_array($query)) {
$tablefields[] = $fieldrow;
}
}
$tabledumped = 0;
$numrows = $offset;
$firstfield = $tablefields[0];
while($currsize + strlen($tabledump) + 500 < $sizelimit * 1000 && $numrows == $offset) {
if($firstfield['Extra'] == 'auto_increment') {
$selectsql = "SELECT * FROM $table WHERE {$firstfield['Field']} > {$get['startfrom']} LIMIT $offset";
} else {
$selectsql = "SELECT * FROM $table LIMIT {$get['startfrom']}, $offset";
}
$tabledumped = 1;
$rows = $db->query($selectsql);
$numfields = $db->num_fields($rows);
$numrows = $db->num_rows($rows);
while($row = $db->fetch_row($rows)) {
$comma = $t = '';
for($i = 0; $i < $numfields; $i++) {
$t .= $comma.($usehex && !empty($row[$i]) && (strexists($tablefields[$i]['Type'], 'char') || strexists($tablefields[$i]['Type'], 'text')) ? '0x'.bin2hex($row[$i]) : '\''.$db->escape_string($row[$i]).'\'');
$comma = ',';
}
if(strlen($t) + $currsize + strlen($tabledump) + 500 < $sizelimit * 1000) {
if($firstfield['Extra'] == 'auto_increment') {
$get['startfrom'] = $row[0];
} else {
$get['startfrom']++;
}
$tabledump .= "INSERT INTO $table VALUES ($t);\n";
} else {
$complete = FALSE;
break 2;
}
}
}
$tabledump .= "\n";
return $tabledump;
}
function random($length, $numeric = 0) {
$seed = base_convert(md5(microtime().$_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35);
$seed = $numeric ? (str_replace('0', '', $seed).'012340567890') : ($seed.'zZ'.strtoupper($seed));
if($numeric) {
$hash = '';
} else {
$hash = chr(rand(1, 26) + rand(0, 1) * 32 + 64);
$length--;
}
$max = strlen($seed) - 1;
for($i = 0; $i < $length; $i++) {
$hash .= $seed[mt_rand(0, $max)];
}
return $hash;
}
function fetchtablelist($tablepre = '') {
global $db;
$arr = explode('.', $tablepre);
$dbname = isset($arr[1]) && $arr[1] ? $arr[0] : '';
$tablepre = str_replace('_', '\_', $tablepre);
$sqladd = $dbname ? " FROM $dbname LIKE '$arr[1]%'" : "LIKE '$tablepre%'";
$tables = $table = array();
$query = $db->query("SHOW TABLE STATUS $sqladd");
while($table = $db->fetch_array($query)) {
$table['Name'] = ($dbname ? "$dbname." : '').$table['Name'];
$tables[] = $table;
}
return $tables;
}
function _authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
$ckey_length = 4;
$key = md5($key ? $key : UC_KEY);
$keya = md5(substr($key, 0, 16));
$keyb = md5(substr($key, 16, 16));
$keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';
$cryptkey = $keya.md5($keya.$keyc);
$key_length = strlen($cryptkey);
$string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;
$string_length = strlen($string);
$result = '';
$box = range(0, 255);
$rndkey = array();
for($i = 0; $i <= 255; $i++) {
$rndkey[$i] = ord($cryptkey[$i % $key_length]);
}
for($j = $i = 0; $i < 256; $i++) {
$j = ($j + $box[$i] + $rndkey[$i]) % 256;
$tmp = $box[$i];
$box[$i] = $box[$j];
$box[$j] = $tmp;
}
for($a = $j = $i = 0; $i < $string_length; $i++) {
$a = ($a + 1) % 256;
$j = ($j + $box[$a]) % 256;
$tmp = $box[$a];
$box[$a] = $box[$j];
$box[$j] = $tmp;
$result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
}
if($operation == 'DECODE') {
if(((int)substr($result, 0, 10) == 0 || (int)substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) === substr(md5(substr($result, 26).$keyb), 0, 16)) {
return substr($result, 26);
} else {
return '';
}
} else {
return $keyc.str_replace('=', '', base64_encode($result));
}
}
function strexists($haystack, $needle) {
return !(strpos($haystack, $needle) === FALSE);
}
function send_mime_type_header($type = 'application/xml') {
header("Content-Type: ".$type);
}
function is_https() {
if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') {
return true;
}
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') {
return true;
}
if(isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https') {
return true;
}
if(isset($_SERVER['HTTP_FROM_HTTPS']) && strtolower($_SERVER['HTTP_FROM_HTTPS']) != 'off') {
return true;
}
if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) {
return true;
}
return false;
}
?>

0
api/db/index.htm Normal file
View File

1
api/index.htm Normal file
View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,25 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: advertisement.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
header('Expires: '.gmdate('D, d M Y H:i:s', time() + 60).' GMT');
if(!defined('IN_API')) {
exit('document.write(\'Access Denied\')');
}
loadcore();
$adid = $_GET['adid'];
$data = adshow($adid);
dheader('Content-Type: application/javascript');
echo 'document.write(\''.preg_replace("/\r\n|\n|\r/", '\n', addcslashes($data, "'\\")).'\');';
?>

0
api/javascript/index.htm Normal file
View File

View File

@@ -0,0 +1,33 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: javascript.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
header('Expires: '.gmdate('D, d M Y H:i:s', time() + 60).' GMT');
if(!defined('IN_API')) {
exit('document.write(\'Access Denied\')');
}
loadcore();
include_once libfile('function/block');
loadcache('blockclass');
$bid = intval($_GET['bid']);
block_get_batch($bid);
$data = block_fetch_content($bid, true);
$search = "/(href|src)\=(\"|')(?![fhtps]+\:)(.*?)\\2/i";
$replace = "\\1=\\2{$_G['siteurl']}\\3\\2";
$data = preg_replace($search, $replace, $data);
dheader('Content-Type: application/javascript');
echo 'document.write(\''.preg_replace("/\r\n|\n|\r/", '\n', addcslashes($data, "'\\")).'\');';
?>

21
api/mobile/index.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: index.php 33969 2013-09-10 08:32:14Z nemohou $
*/
if(!empty($_SERVER['QUERY_STRING'])) {
$plugin = !empty($_GET['oem']) ? 'mobileoem' : 'mobile';
$dir = '../../source/plugin/'.$plugin.'/';
chdir($dir);
if((isset($_GET['check']) && $_GET['check'] == 'check' || $_SERVER['QUERY_STRING'] == 'check') && is_file('check.php')) {
require_once 'check.php';
} elseif(is_file('mobile.php')) {
require_once 'mobile.php';
}
}
?>

0
api/payment/index.htm Normal file
View File

View File

View File

@@ -0,0 +1,48 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: notify_alipay.php 36342 2021-05-17 14:14:54Z dplugin $
*/
define('IN_API', true);
define('CURSCRIPT', 'api');
define('DISABLEXSSCHECK', true);
require '../../../source/class/class_core.php';
require '../payment_alipay.php';
$discuz = C::app();
$discuz->init();
if(!$_POST['sign'] || !$_POST['sign_type']) {
exit('fail');
}
$sign = $_POST['sign'];
unset($_POST['sign']);
$payment = new payment_alipay();
$isright = $payment->alipay_sign_verify($sign, $_POST);
if(!$isright) {
$_POST['sign'] = $sign;
payment::paymentlog('alipay', 0, 0, 0, 50001, $_POST);
exit('fail');
}
if($_POST['trade_status'] == 'TRADE_SUCCESS') {
$out_biz_no = $_POST['out_trade_no'];
$payment_time = strtotime($_POST['gmt_payment']);
$is_success = payment::finish_order('alipay', $out_biz_no, $_POST['trade_no'], $payment_time);
if($is_success) {
exit('success');
}
} else {
payment::paymentlog('alipay', 0, 0, 0, 50001, $_POST);
}
exit('fail');
?>

View File

@@ -0,0 +1,37 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id$
*/
define('IN_API', true);
define('CURSCRIPT', 'api');
define('DISABLEXSSCHECK', true);
require '../../../source/class/class_core.php';
require '../payment_qpay.php';
$discuz = C::app();
$discuz->init();
$payment = new payment_qpay();
$data = $payment->qpay_sign_verify();
if($data && $data['code'] == 200) {
$data = $data['data'];
$out_biz_no = $data['out_trade_no'];
$payment_time = strtotime(preg_replace('/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/', '$1-$2-$3 $4:$5:$6', $data['time_end']));
$is_success = payment::finish_order('qpay', $out_biz_no, $data['transaction_id'], $payment_time);
if($is_success) {
echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
exit();
}
} else {
payment::paymentlog('qpay', 0, 0, 0, 50001, $data ? json_encode($data) : '');
}
echo '<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[FAIL]]></return_msg></xml>';
exit();

View File

@@ -0,0 +1,55 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: notify_wechat.php 36342 2021-05-17 14:15:04Z dplugin $
*/
define('IN_API', true);
define('CURSCRIPT', 'api');
define('DISABLEXSSCHECK', true);
require '../../../source/class/class_core.php';
require '../payment_wechat.php';
$discuz = C::app();
$discuz->init();
$payment = new payment_wechat();
if($_SERVER['HTTP_WECHATPAY_SIGNATURE']) {
$data = $payment->v3_wechat_sign_verify();
if($data && $data['code'] == 200) {
$data = json_decode($data['data'], true);
if($data['trade_state'] == 'SUCCESS') {
$out_biz_no = $data['out_trade_no'];
$payment_time = strtotime($data['success_time']);
$is_success = payment::finish_order('wechat', $out_biz_no, $data['transaction_id'], $payment_time);
if($is_success) {
exit('{"code":"SUCCESS","message":"ok"}');
}
}
} else {
payment::paymentlog('wechat', 0, 0, 0, 50001, $data ? json_encode($data) : '');
}
exit('{"code":"fail","message":"fail"}');
} else {
$data = $payment->wechat_sign_verify();
if($data && $data['code'] == 200) {
$data = $data['data'];
$out_biz_no = $data['out_trade_no'];
$payment_time = strtotime(preg_replace('/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/', '$1-$2-$3 $4:$5:$6', $data['time_end']));
$is_success = payment::finish_order('wechat', $out_biz_no, $data['transaction_id'], $payment_time);
if($is_success) {
echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
exit();
}
} else {
payment::paymentlog('wechat', 0, 0, 0, 50001, $data ? json_encode($data) : '');
}
echo '<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[FAIL]]></return_msg></xml>';
exit();
}
?>

View File

@@ -0,0 +1,496 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: payment_alipay.php 36342 2021-05-17 14:15:14Z dplugin $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('SDK_ALIPAY_GATEWAYURL', 'https://openapi.alipay.com/gateway.do');
require DISCUZ_ROOT . './api/payment/payment_base.php';
class payment_alipay extends payment_base {
public function __construct() {
global $_G;
$this->settings = C::t('common_setting')->fetch_setting('ec_alipay', true);
$this->notify_url = $_G['siteurl'] . 'api/payment/notify/notify_alipay.php';
parent::__construct();
}
public function pay($order) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'Did not open payment');
}
if(defined('IN_MOBILE')) {
return $this->alipay_trade_wap_pay($order);
} else {
return $this->alipay_trade_page_pay($order);
}
}
public function status($out_biz_no) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'Did not open payment');
}
return $this->alipay_trade_query($out_biz_no);
}
public function refund($refund_no, $trade_no, $total_amount, $refund_amount, $refund_desc) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'Did not open payment');
}
return $this->alipay_refund($refund_no, $trade_no, $refund_amount, $refund_desc);
}
public function refund_status($refund_no, $trade_no) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'Did not open payment');
}
return $this->alipay_refund_status($refund_no, $trade_no);
}
public function transfer($transfer_no, $amount, $realname, $account, $title = '', $desc = '') {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'Did not open payment');
}
return $this->alipay_fund_trans_uni_transfer($transfer_no, $amount, $realname, $account, $title, $desc);
}
public function transfer_status($transfer_no) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'Did not open payment');
}
return $this->alipay_fund_trans_order_query($transfer_no);
}
public function alipay_sign_verify($sign, $data) {
if(!$data) {
return false;
}
if($this->settings['ec_alipay_sign_mode']) {
$public_key = $this->settings['mode_b_alipay_cert'];
} else {
$public_key = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($this->settings['mode_a_alipay_public_key'], 64, "\n", true) . "\n-----END PUBLIC KEY-----";
}
$data = $this->alipay_make_notify_signstr($data);
$public_keyres = openssl_pkey_get_public($public_key);
$result = (openssl_verify($data, base64_decode($sign), $public_keyres, OPENSSL_ALGO_SHA256) === 1);
openssl_free_key($public_keyres);
return $result;
}
private function alipay_trade_query($out_biz_no) {
global $_G;
$data = array(
'method' => 'alipay.trade.query',
'charset' => 'utf-8',
'sign_type' => 'RSA2',
'format' => 'JSON',
'timestamp' => dgmdate(time(), 'Y-m-d H:i:s'),
'version' => '1.0',
'biz_content' => json_encode(array('out_trade_no' => $out_biz_no))
);
if($this->settings['ec_alipay_sign_mode']) {
$appid = $this->settings['mode_b_appid'];
$private_key = $this->settings['mode_b_app_private_key'];
$data['app_cert_sn'] = $this->alipay_cert_sn($this->settings['mode_b_app_cert']);
$data['alipay_root_cert_sn'] = $this->alipay_root_cert_sn($this->settings['mode_b_alipay_root_cert']);
} else {
$appid = $this->settings['mode_a_appid'];
$private_key = $this->settings['mode_a_app_private_key'];
}
$data['app_id'] = $appid;
$signstr = $this->alipay_make_signstr($data);
$data['sign'] = $this->alipay_sign($private_key, $signstr);
$api = SDK_ALIPAY_GATEWAYURL . '?' . http_build_query($data);
$res = $this->alipay_request($api);
$res = json_decode($res, true);
$res = $res['alipay_trade_query_response'];
if($res['code'] == 10000) {
if($res['trade_status'] == 'TRADE_SUCCESS') {
return array('code' => 200, 'data' => array('trade_no' => $res['trade_no'], 'payment_time' => strtotime($res['send_pay_date'])));
} else {
return array('code' => 500, 'message' => $res['trade_status']);
}
} else {
if(strtoupper($_G['charset'] != 'UTF-8')) {
$res['sub_msg'] = diconv($res['sub_msg'], 'UTF-8', $_G['charset']);
}
return array('code' => $res['sub_code'], 'message' => $res['sub_msg']);
}
}
private function alipay_trade_page_pay($order) {
global $_G;
if(strtoupper($_G['charset'] != 'UTF-8')) {
$order['subject'] = diconv($order['subject'], $_G['charset'], 'UTF-8');
$order['description'] = diconv($order['description'], $_G['charset'], 'UTF-8');
}
$data = array(
'method' => 'alipay.trade.page.pay',
'charset' => 'utf-8',
'sign_type' => 'RSA2',
'format' => 'JSON',
'timestamp' => dgmdate(time(), 'Y-m-d H:i:s'),
'version' => '1.0',
'biz_content' => json_encode(array(
'out_trade_no' => $order['out_biz_no'],
'product_code' => 'FAST_INSTANT_TRADE_PAY',
'total_amount' => $order['amount'] / 100,
'subject' => $order['subject'],
'body' => $order['description'],
'timeout_express' => '1d',
'qr_pay_mode' => '2',
'integration_type' => 'PCWEB'
))
);
if($this->notify_url) {
$data['notify_url'] = $this->notify_url;
}
if($order['return_url']) {
$data['return_url'] = $order['return_url'];
}
if($this->settings['ec_alipay_sign_mode']) {
$appid = $this->settings['mode_b_appid'];
$private_key = $this->settings['mode_b_app_private_key'];
$data['app_cert_sn'] = $this->alipay_cert_sn($this->settings['mode_b_app_cert']);
$data['alipay_root_cert_sn'] = $this->alipay_root_cert_sn($this->settings['mode_b_alipay_root_cert']);
} else {
$appid = $this->settings['mode_a_appid'];
$private_key = $this->settings['mode_a_app_private_key'];
}
$data['app_id'] = $appid;
$signstr = $this->alipay_make_signstr($data);
$data['sign'] = $this->alipay_sign($private_key, $signstr);
$api = SDK_ALIPAY_GATEWAYURL . '?' . http_build_query($data);
$res = $this->alipay_request($api);
if(strtoupper($_G['charset'] != 'GBK')) {
$res = diconv($res, 'GB2312', $_G['charset']);
}
if(preg_match('/^https?:\/\/.+$/', $res)) {
return array('code' => 200, 'url' => $res);
} else {
if(preg_match('/<div\s+class="Todo">([^<]+)<\/div>/i', $res, $matchers)) {
return array('code' => 500, 'message' => $matchers[1]);
} else {
return array('code' => 501, 'message' => $res);
}
}
}
private function alipay_trade_wap_pay($order) {
global $_G;
if(strtoupper($_G['charset'] != 'UTF-8')) {
$order['subject'] = diconv($order['subject'], $_G['charset'], 'UTF-8');
$order['description'] = diconv($order['description'], $_G['charset'], 'UTF-8');
}
$data = array(
'method' => 'alipay.trade.wap.pay',
'format' => 'JSON',
'charset' => 'utf-8',
'sign_type' => 'RSA2',
'timestamp' => dgmdate(time(), 'Y-m-d H:i:s'),
'version' => '1.0',
'biz_content' => json_encode(array(
'out_trade_no' => $order['out_biz_no'],
'product_code' => 'FAST_INSTANT_TRADE_PAY',
'total_amount' => $order['amount'] / 100,
'subject' => $order['subject'],
'body' => $order['description'],
'timeout_express' => '1d',
'qr_pay_mode' => '2',
'integration_type' => 'PCWEB'
))
);
if($this->notify_url) {
$data['notify_url'] = $this->notify_url;
}
if($order['return_url']) {
$data['return_url'] = $order['return_url'];
}
if($this->settings['ec_alipay_sign_mode']) {
$appid = $this->settings['mode_b_appid'];
$private_key = $this->settings['mode_b_app_private_key'];
$data['app_cert_sn'] = $this->alipay_cert_sn($this->settings['mode_b_app_cert']);
$data['alipay_root_cert_sn'] = $this->alipay_root_cert_sn($this->settings['mode_b_alipay_root_cert']);
} else {
$appid = $this->settings['mode_a_appid'];
$private_key = $this->settings['mode_a_app_private_key'];
}
$data['app_id'] = $appid;
if($order['referer_url']) {
$data['return_url'] = $order['referer_url'];
$data['quit_url'] = $order['referer_url'];
} else {
$data['quit_url'] = $_G['siteurl'];
}
$signstr = $this->alipay_make_signstr($data);
$data['sign'] = $this->alipay_sign($private_key, $signstr);
$api = SDK_ALIPAY_GATEWAYURL . '?' . http_build_query($data);
$res = $this->alipay_request($api);
if(!preg_match('/^https?:\/\/.+$/', $res) && strtoupper($_G['charset'] != 'GBK')) {
$res = diconv($res, 'GB2312', $_G['charset']);
}
if(preg_match('/^https?:\/\/.+$/', $res)) {
return array('code' => 200, 'url' => $res);
} else {
if(preg_match('/<div\s+class="Todo">([^<]+)<\/div>/i', $res, $matchers)) {
return array('code' => 500, 'message' => $matchers[1]);
} else {
return array('code' => 501, 'message' => $res);
}
}
}
private function alipay_fund_trans_uni_transfer($transfer_no, $amount, $realname, $account, $title = '', $desc = '') {
global $_G;
if(strtoupper($_G['charset'] != 'UTF-8')) {
$title = diconv($title, $_G['charset'], 'UTF-8');
$desc = diconv($desc, $_G['charset'], 'UTF-8');
}
if(!$this->settings['ec_alipay_sign_mode']) {
return array('code' => 500, 'message' => 'not support sign mode.');
}
$data = array(
'app_id' => $this->settings['mode_b_appid'],
'method' => 'alipay.fund.trans.uni.transfer',
'format' => 'JSON',
'charset' => 'utf-8',
'sign_type' => 'RSA2',
'app_cert_sn' => $this->alipay_cert_sn($this->settings['mode_b_app_cert']),
'alipay_root_cert_sn' => $this->alipay_root_cert_sn($this->settings['mode_b_alipay_root_cert']),
'timestamp' => dgmdate(time(), 'Y-m-d H:i:s'),
'version' => '1.0'
);
$biz_content = array(
'out_biz_no' => $transfer_no,
'trans_amount' => sprintf('%.2f', $amount / 100),
'product_code' => 'TRANS_ACCOUNT_NO_PWD',
'biz_scene' => 'DIRECT_TRANSFER',
'payee_info' => array('identity' => $account, 'identity_type' => 'ALIPAY_LOGON_ID', 'name' => $realname)
);
if($title) {
$biz_content['order_title'] = $title;
}
if($desc) {
$biz_content['remark'] = $desc;
}
$data['biz_content'] = json_encode($biz_content);
$signstr = $this->alipay_make_signstr($data);
$data['sign'] = $this->alipay_sign($this->settings['mode_b_app_private_key'], $signstr);
$api = SDK_ALIPAY_GATEWAYURL . '?' . http_build_query($data);
$res = $this->alipay_request($api);
$res = json_decode($res, true);
$res = $res['alipay_fund_trans_uni_transfer_response'];
if($res['code'] == 10000) {
if($res['status'] == 'SUCCESS') {
return array('code' => 200, 'data' => array('transfer_time' => strtotime($res['trans_date'])));
} elseif($res['status'] == 'DEALING') {
return array('code' => 201, 'message' => 'DEALING');
} else {
return array('code' => 500, 'message' => $res['status']);
}
} else {
if($res['sub_msg'] && strtoupper($_G['charset'] != 'UTF-8')) {
$res['sub_msg'] = diconv($res['sub_msg'], 'UTF-8', $_G['charset']);
}
return array('code' => $res['sub_code'], 'message' => $res['sub_msg']);
}
}
private function alipay_fund_trans_order_query($transfer_no) {
global $_G;
$data = array('method' => 'alipay.fund.trans.order.query', 'format' => 'JSON', 'charset' => 'utf-8', 'sign_type' => 'RSA2', 'timestamp' => dgmdate(time(), 'Y-m-d H:i:s'), 'version' => '1.0',);
if($this->settings['ec_alipay_sign_mode']) {
$appid = $this->settings['mode_b_appid'];
$private_key = $this->settings['mode_b_app_private_key'];
$data['app_cert_sn'] = $this->alipay_cert_sn($this->settings['mode_b_app_cert']);
$data['alipay_root_cert_sn'] = $this->alipay_root_cert_sn($this->settings['mode_b_alipay_root_cert']);
} else {
$appid = $this->settings['mode_a_appid'];
$private_key = $this->settings['mode_a_app_private_key'];
}
$data['app_id'] = $appid;
$biz_content = array('out_biz_no' => $transfer_no,);
$data['biz_content'] = json_encode($biz_content);
$signstr = $this->alipay_make_signstr($data);
$data['sign'] = $this->alipay_sign($private_key, $signstr);
$api = SDK_ALIPAY_GATEWAYURL . '?' . http_build_query($data);
$res = $this->alipay_request($api);
$res = json_decode($res, true);
$res = $res['alipay_fund_trans_order_query_response'];
if($res['code'] == 10000) {
if($res['status'] == 'SUCCESS') {
return array('code' => 200, 'data' => array('transfer_time' => strtotime($res['trans_date'])));
} elseif($res['status'] == 'DEALING') {
return array('code' => 201, 'message' => 'DEALING');
} else {
return array('code' => 500, 'message' => $res['status']);
}
} else {
if($res['sub_msg'] && strtoupper($_G['charset'] != 'UTF-8')) {
$res['sub_msg'] = diconv($res['sub_msg'], 'UTF-8', $_G['charset']);
}
return array('code' => $res['sub_code'], 'message' => $res['sub_msg']);
}
}
private function alipay_refund($refund_no, $trade_no, $amount, $refund_desc) {
global $_G;
if(strtoupper($_G['charset'] != 'UTF-8')) {
$refund_desc = diconv($refund_desc, $_G['charset'], 'UTF-8');
}
$data = array('method' => 'alipay.trade.refund', 'format' => 'JSON', 'charset' => 'utf-8', 'sign_type' => 'RSA2', 'timestamp' => dgmdate(time(), 'Y-m-d H:i:s'), 'version' => '1.0', 'biz_content' => json_encode(array('trade_no' => $trade_no, 'refund_amount' => $amount / 100, 'out_request_no' => $refund_no, 'refund_reason' => $refund_desc)),);
if($this->settings['ec_alipay_sign_mode']) {
$appid = $this->settings['mode_b_appid'];
$private_key = $this->settings['mode_b_app_private_key'];
$data['app_cert_sn'] = $this->alipay_cert_sn($this->settings['mode_b_app_cert']);
$data['alipay_root_cert_sn'] = $this->alipay_root_cert_sn($this->settings['mode_b_alipay_root_cert']);
} else {
$appid = $this->settings['mode_a_appid'];
$private_key = $this->settings['mode_a_app_private_key'];
}
$data['app_id'] = $appid;
$signstr = $this->alipay_make_signstr($data);
$data['sign'] = $this->alipay_sign($private_key, $signstr);
$api = SDK_ALIPAY_GATEWAYURL . '?' . http_build_query($data);
$res = $this->alipay_request($api);
$res = json_decode($res, true);
$res = $res['alipay_trade_refund_response'];
if($res['code'] == 10000) {
return array('code' => 200, 'data' => array('refund_time' => time()));
} else {
if(strtoupper($_G['charset'] != 'UTF-8')) {
$res['sub_msg'] = diconv($res['sub_msg'], 'UTF-8', $_G['charset']);
}
return array('code' => $res['sub_code'], 'message' => $res['sub_msg']);
}
}
private function alipay_refund_status($refund_no, $trade_no) {
global $_G;
$data = array('method' => 'alipay.trade.fastpay.refund.query', 'format' => 'JSON', 'charset' => 'utf-8', 'sign_type' => 'RSA2', 'timestamp' => dgmdate(time(), 'Y-m-d H:i:s'), 'version' => '1.0', 'biz_content' => json_encode(array('trade_no' => $trade_no, 'out_request_no' => $refund_no,)),);
if($this->settings['ec_alipay_sign_mode']) {
$appid = $this->settings['mode_b_appid'];
$private_key = $this->settings['mode_b_app_private_key'];
$data['app_cert_sn'] = $this->alipay_cert_sn($this->settings['mode_b_app_cert']);
$data['alipay_root_cert_sn'] = $this->alipay_root_cert_sn($this->settings['mode_b_alipay_root_cert']);
} else {
$appid = $this->settings['mode_a_appid'];
$private_key = $this->settings['mode_a_app_private_key'];
}
$data['app_id'] = $appid;
$signstr = $this->alipay_make_signstr($data);
$data['sign'] = $this->alipay_sign($private_key, $signstr);
$api = SDK_ALIPAY_GATEWAYURL . '?' . http_build_query($data);
$res = $this->alipay_request($api);
$res = json_decode($res, true);
$res = $res['alipay_trade_fastpay_refund_query_response'];
if($res['code'] == 10000) {
return array('code' => 200, 'data' => array('refund_time' => time()));
} else {
if(strtoupper($_G['charset'] != 'UTF-8')) {
$res['sub_msg'] = diconv($res['sub_msg'], 'UTF-8', $_G['charset']);
}
return array('code' => $res['sub_code'], 'message' => $res['sub_msg']);
}
}
private function alipay_make_signstr($data) {
ksort($data);
$signstr = array();
foreach($data as $key => $value) {
$signstr[] = $key . '=' . $value;
}
$signstr = implode('&', $signstr);
return $signstr;
}
private function alipay_sign($private_key, $data) {
$private_key = "-----BEGIN RSA PRIVATE KEY-----\n" . wordwrap($private_key, 64, "\n", true) . "\n-----END RSA PRIVATE KEY-----";
openssl_sign($data, $sign, $private_key, OPENSSL_ALGO_SHA256);
return base64_encode($sign);
}
private function alipay_make_notify_signstr($data) {
ksort($data);
$signstr = array();
foreach($data as $key => $value) {
if(in_array($key, array('sign', 'sign_type')) || !$value) {
continue;
}
if(is_array($value)) {
$value = json_encode($value);
}
$signstr[] = $key . '=' . $value;
}
$signstr = implode('&', $signstr);
return $signstr;
}
private function alipay_array_to_string($data) {
$str = [];
foreach($data as $name => $value) {
$str[] = $name . '=' . $value;
}
return implode(',', $str);
}
private function alipay_cert_sn($appcert) {
$ssl = openssl_x509_parse($appcert);
$sn = md5($this->alipay_array_to_string(array_reverse($ssl['issuer'])) . $ssl['serialNumber']);
return $sn;
}
private function alipay_root_cert_sn($alipayrootcert) {
$array = explode("-----END CERTIFICATE-----", $alipayrootcert);
$sn = array();
for($i = 0; $i < count($array) - 1; $i++) {
$ssl = openssl_x509_parse($array[$i] . "-----END CERTIFICATE-----");
if($ssl['signatureTypeLN'] == "sha256WithRSAEncryption") {
$sn[] = md5($this->alipay_array_to_string(array_reverse($ssl['issuer'])) . $ssl['serialNumber']);
}
}
return implode('_', $sn);
}
private function alipay_request($api, $post = array()) {
$client = filesock::open(array(
'url' => $api,
'method' => 'POST',
'post' => $post
));
$data = $client->request();
if($client->curlstatus['http_code'] == 200) {
return $data;
} elseif(preg_match('/^30\d+$/', $client->curlstatus['http_code'])) {
return $client->curlstatus['redirect_url'];
} else {
return;
}
}
}

View File

@@ -0,0 +1,41 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: payment_base.php 36342 2021-05-17 14:15:31Z dplugin $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class payment_base {
var $settings;
var $notify_url;
public function __construct() {}
protected function enable() {
if($this->settings && $this->settings['on']) {
return true;
} else {
return false;
}
}
public function pay($order) { }
public function status($out_biz_no) { }
public function refund($refund_no, $trade_no, $total_amount, $refund_amount, $refund_desc) { }
public function refund_status($refund_no, $trade_no) { }
public function transfer($transfer_no, $amount, $realname, $account, $title = '', $desc = '') { }
public function transfer_status($transfer_no) { }
}

View File

@@ -0,0 +1,245 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id$
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('SDK_QPAY_PAY_UNIFIEDORDER', 'https://qpay.qq.com/cgi-bin/pay/qpay_unified_order.cgi');
define('SDK_QPAY_PAY_ORDERQUERY', 'https://qpay.qq.com/cgi-bin/pay/qpay_order_query.cgi');
define('SDK_QPAY_PAY_REFUND', 'https://api.qpay.qq.com/cgi-bin/pay/qpay_refund.cgi');
define('SDK_QPAY_PAY_REFUNDQUERY', 'https://qpay.qq.com/cgi-bin/pay/qpay_refund_query.cgi');
require DISCUZ_ROOT . './api/payment/payment_base.php';
class payment_qpay extends payment_base {
public function __construct() {
global $_G;
$this->settings = C::t('common_setting')->fetch_setting('ec_qpay', true);
$this->notify_url = $_G['siteurl'] . 'api/payment/notify/notify_qpay.php';
parent::__construct();
}
public function pay($order) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'This payment method is not open yet.');
}
return $this->qpay_unifiedorder_pay($order);
}
public function status($out_biz_no) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'This payment method is not open yet.');
}
return $this->qpay_order_query($out_biz_no);
}
public function refund($refund_no, $trade_no, $total_amount, $refund_amount, $refund_desc) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'This payment method is not open yet.');
}
return $this->qpay_refund($refund_no, $trade_no, $total_amount, $refund_amount, $refund_desc);
}
public function refund_status($refund_no, $trade_no) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'This payment method is not open yet.');
}
return $this->qpay_refund_status($refund_no);
}
public function transfer($transfer_no, $amount, $realname, $account, $title = '', $desc = '') {
return array('code' => 500, 'message' => 'This payment method is not support this feature.');
}
public function transfer_status($transfer_no) {
return array('code' => 500, 'message' => 'This payment method is not support this feature.');
}
public function pay_jsapi($order) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'This payment method is not open yet.');
}
return $this->qpay_unifiedorder_pay($order, 'JSAPI');
}
public function qpay_sign_verify() {
$xml = file_get_contents('php://input');
$data = $this->qpay_x2o($xml);
$sign = $this->qpay_sign($this->settings['v1_key'], $data, 1);
if($sign != $data['sign']) {
return array('code' => 50001, 'data' => $data);
}
if($data['return_code'] != 'SUCCESS') {
return array('code' => 50002, 'data' => $data);
}
if($data['result_code'] != 'SUCCESS') {
return array('code' => 50003, 'data' => $data);
}
return array('code' => 200, 'data' => $data);
}
protected function enable() {
return $this->settings && $this->settings['on'];
}
private function qpay_unifiedorder_pay($order, $type = 'NATIVE') {
global $_G;
if(strtoupper($_G['charset'] != 'UTF-8')) {
$order['subject'] = diconv($order['subject'], $_G['charset'], 'UTF-8');
$order['description'] = diconv($order['description'], $_G['charset'], 'UTF-8');
}
$data = array('appid' => $this->settings['appid'], 'mch_id' => $this->settings['mch_id'], 'nonce_str' => $this->qpay_nonce(), 'body' => $order['subject'], 'attach' => $order['description'], 'out_trade_no' => $order['out_biz_no'], 'fee_type' => 'CNY', 'total_fee' => intval($order['amount']), 'spbill_create_ip' => $_G['clientip'], 'time_expire' => dgmdate(time() + 86400, 'YmdHis'), 'notify_url' => $this->notify_url, 'trade_type' => $type);
$data['sign'] = $this->qpay_sign($this->settings['v1_key'], $data);
$data = $this->qpay_o2x($data);
$api = SDK_QPAY_PAY_UNIFIEDORDER;
$res = $this->qpay_request_xml($api, $data);
if(strtoupper($_G['charset'] != 'UTF-8')) {
$res = diconv($res, 'UTF-8', $_G['charset']);
}
$res = $this->qpay_x2o($res);
if($res['return_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['return_msg']);
} elseif($res['result_code'] != 'SUCCESS') {
return array('code' => 501, 'message' => $res['err_code_des']);
} else {
return array('code' => 200, 'url' => isset($res['code_url']) ? $res['code_url'] : $res['prepay_id']);
}
}
private function qpay_order_query($out_biz_no) {
global $_G;
$data = array('appid' => $this->settings['appid'], 'mch_id' => $this->settings['mch_id'], 'out_trade_no' => $out_biz_no, 'nonce_str' => $this->qpay_nonce());
$data['sign'] = $this->qpay_sign($this->settings['v1_key'], $data);
$data = $this->qpay_o2x($data);
$api = SDK_QPAY_PAY_ORDERQUERY;
$res = $this->qpay_request_xml($api, $data);
if(strtoupper($_G['charset'] != 'UTF-8')) {
$res = diconv($res, 'UTF-8', $_G['charset']);
}
$res = $this->qpay_x2o($res);
if($res['return_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['return_msg']);
} elseif($res['result_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['err_code_des']);
} else{
$pay_time = strtotime(preg_replace('/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/', '$1-$2-$3 $4:$5:$6', $res['time_end']));
return array('code' => 200, 'data' => array('trade_no' => $res['transaction_id'], 'payment_time' => $pay_time));
}
}
private function qpay_refund($refund_no, $trade_no, $total_amount, $refund_amount, $refund_desc) {
global $_G;
if(strtoupper($_G['charset'] != 'UTF-8')) {
$refund_desc = diconv($refund_desc, $_G['charset'], 'UTF-8');
}
$data = array('appid' => $this->settings['appid'], 'mch_id' => $this->settings['mch_id'], 'nonce_str' => $this->qpay_nonce(), 'transaction_id' => $trade_no, 'out_refund_no' => $refund_no, 'refund_fee' => $refund_amount, 'op_user_id' => $this->settings['op_user_id'], 'op_user_passwd' => $this->settings['op_user_passwd']);
$data['sign'] = $this->qpay_sign($this->settings['v1_key'], $data);
$data = $this->qpay_o2x($data);
$api = SDK_QPAY_PAY_REFUND;
$res = $this->qpay_request_xml($api, $data, true);
if(strtoupper($_G['charset'] != 'UTF-8')) {
$res = diconv($res, 'UTF-8', $_G['charset']);
}
$res = $this->qpay_x2o($res);
if($res['return_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['return_msg']);
} elseif($res['result_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['err_code_des']);
} else {
return array('code' => 200, 'data' => array('refund_time' => time()));
}
}
private function qpay_refund_status($refund_no) {
global $_G;
$data = array('appid' => $this->settings['appid'], 'mch_id' => $this->settings['mch_id'], 'nonce_str' => $this->qpay_nonce(), 'out_refund_no' => $refund_no);
$data['sign'] = $this->qpay_sign($this->settings['v1_key'], $data);
$data = $this->qpay_o2x($data);
$api = SDK_QPAY_PAY_REFUNDQUERY;
$res = $this->qpay_request_xml($api, $data);
if(strtoupper($_G['charset'] != 'UTF-8')) {
$res = diconv($res, 'UTF-8', $_G['charset']);
}
$res = $this->qpay_x2o($res);
if($res['return_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['return_msg']);
} elseif($res['result_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['err_code'] . '-' . $res['err_code_des']);
} else {
return array('code' => 200, 'data' => array('refund_time' => time()));
}
}
private function qpay_o2x($data) {
$xml = '<xml>';
foreach($data as $key => $value) {
$xml .= "\n<{$key}>{$value}</{$key}>";
}
$xml .= "\n</xml>";
return $xml;
}
private function qpay_x2o($xml) {
libxml_disable_entity_loader(true);
$data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
return $data;
}
private function qpay_sign($token, $data, $sign = 0) {
ksort($data);
$signstr = '';
foreach($data as $key => $value) {
if(!$value || ($sign && $key == 'sign')) continue;
$signstr .= $key . '=' . $value . '&';
}
$signstr .= 'key=' . $token;
$sign = strtoupper(md5($signstr));
return $sign;
}
private function qpay_nonce() {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for($i = 0; $i < 32; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
private function qpay_request_xml($api, $xml, $cert = false) {
$params = array(
'url' => $api,
'method' => 'POST',
'rawdata' => $xml,
'encodetype' => 'application/xml',
);
if($cert) {
if(!$this->settings['v1_cert_path'] || !file_exists(DISCUZ_ROOT . $this->settings['v1_cert_path']) || !is_file(DISCUZ_ROOT . $this->settings['v1_cert_path'])) {
return '<xml><return_code>400</return_code><return_msg>p12 not found.</return_msg></xml>';
}
$params['verifypeer'] = $this->settings['v1_cert_path'];
}
$client = filesock::open($params);
$data = $client -> request();
if(!$data) {
$data = $client -> filesockbody;
}
return $data;
}
}

View File

@@ -0,0 +1,585 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: payment_wechat.php 36342 2021-05-17 14:15:31Z dplugin $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('SDK_WEIXIN_PAY_UNIFIEDORDER', 'https://api.mch.weixin.qq.com/pay/unifiedorder');
define('SDK_WEIXIN_PAY_ORDERQUERY', 'https://api.mch.weixin.qq.com/pay/orderquery');
define('SDK_WEIXIN_PAY_REFUND', 'https://api.mch.weixin.qq.com/secapi/pay/refund');
define('SDK_WEIXIN_PAY_REFUNDQUERY', 'https://api.mch.weixin.qq.com/pay/refundquery');
define('SDK_WEIXIN_AUTHORIZE', 'https://open.weixin.qq.com/connect/oauth2/authorize');
define('SDK_WEIXIN_SNS_ACCESS_TOKEN', 'https://api.weixin.qq.com/sns/oauth2/access_token');
define('SDK_WEIXIN_PAY_V3_TRANSACTIONS_NATIVE', 'https://api.mch.weixin.qq.com/v3/pay/transactions/native');
define('SDK_WEIXIN_PAY_V3_TRANSACTIONS_H5', 'https://api.mch.weixin.qq.com/v3/pay/transactions/h5');
define('SDK_WEIXIN_PAY_V3_TRANSACTIONS_JSAPI', 'https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi');
define('SDK_WEIXIN_PAY_V3_TRANSACTIONS_OUTTRADENO', 'https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/');
define('SDK_WEIXIN_PAY_V3_REFUND_DOMESTIC_REFUNDS', 'https://api.mch.weixin.qq.com/v3/refund/domestic/refunds');
define('SDK_WEIXIN_PAY_V3_REFUND_DOMESTIC_REFUNDS_QUERY', 'https://api.mch.weixin.qq.com/v3/refund/domestic/refunds/');
define('SDK_WEIXIN_PAY_V3_CERTIFICATES', 'https://api.mch.weixin.qq.com/v3/certificates');
require DISCUZ_ROOT . './api/payment/payment_base.php';
class payment_wechat extends payment_base {
public function __construct() {
global $_G;
$this->settings = C::t('common_setting')->fetch_setting('ec_wechat', true);
$this->notify_url = $_G['siteurl'] . 'api/payment/notify/notify_wechat.php';
parent::__construct();
}
public function pay($order) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'Did not open payment');
}
$device = $this->wechat_device();
if($device) {
if($this->settings['ec_wechat_version']) {
return $this->v3_wechat_h5_pay($order);
} else {
return $this->wechat_unifiedorder_pay($order, 'MWEB');
}
} else {
if($this->settings['ec_wechat_version']) {
return $this->v3_wechat_native_pay($order);
} else {
return $this->wechat_unifiedorder_pay($order, 'NATIVE');
}
}
}
public function status($out_biz_no) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'Did not open payment');
}
if($this->settings['ec_wechat_version']) {
return $this->v3_wechat_query_order($out_biz_no);
} else {
return $this->wechat_order_query($out_biz_no);
}
}
public function refund($refund_no, $trade_no, $total_amount, $refund_amount, $refund_desc) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'Did not open payment');
}
if($this->settings['ec_wechat_version']) {
return $this->v3_wechat_refund($refund_no, $trade_no, $total_amount, $refund_amount, $refund_desc);
} else {
return $this->wechat_refund($refund_no, $trade_no, $total_amount, $refund_amount, $refund_desc);
}
}
public function refund_status($refund_no, $trade_no) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'Did not open payment');
}
if($this->settings['ec_wechat_version']) {
return $this->v3_wechat_refund_query($refund_no);
} else {
return $this->wechat_refund_status($refund_no);
}
}
public function transfer($transfer_no, $amount, $realname, $account, $title = '', $desc = '') {
return array('code' => 500, 'message' => 'not support.');
}
public function transfer_status($transfer_no) {
return array('code' => 500, 'message' => 'not support.');
}
public function pay_jsapi($order, $openid) {
if(!$this->enable()) {
return array('code' => 500, 'message' => 'Did not open payment');
}
if($this->settings['ec_wechat_version']) {
return $this->v3_wechat_h5_jsapi($order, $openid);
} else {
return $this->wechat_unifiedorder_pay($order, 'JSAPI', $openid);
}
}
public function wechat_jsapidata($prepay_id) {
if($this->settings['ec_wechat_version']) {
$jsapidata = array(
'appId' => $this->settings['appid'],
'timeStamp' => time() . '',
'nonceStr' => $this->wechat_nonce(),
'package' => 'prepay_id=' . $prepay_id,
'signType' => 'RSA'
);
$jsapidata['paySign'] = $this->v3_wechat_jsapi_authorization($jsapidata);
} else {
$jsapidata = array('appId' => $this->settings['appid'], 'timeStamp' => time() . '', 'nonceStr' => $this->wechat_nonce(), 'package' => 'prepay_id=' . $prepay_id, 'signType' => 'MD5');
$jsapidata['paySign'] = $this->wechat_sign($this -> settings['v1_key'], $jsapidata);
}
return json_encode($jsapidata);
}
public function wechat_authorize($redirect_uri, $state, $scope = 'snsapi_base') {
$appid = $this->settings['appid'];
$redirect_uri = urlencode($redirect_uri);
return SDK_WEIXIN_AUTHORIZE . "?appid={$appid}&redirect_uri={$redirect_uri}&response_type=code&scope={$scope}&state={$state}#wechat_redirect";
}
public function wechat_access_token_by_code($code) {
$appid = $this->settings['appid'];
$appsecret = $this->settings['appsecret'];
$api = SDK_WEIXIN_SNS_ACCESS_TOKEN . "?appid={$appid}&secret={$appsecret}&code=$code&grant_type=authorization_code";
return $this->wechat_request($api);
}
public function wechat_sign_verify() {
$xml = file_get_contents('php://input');
$data = $this->wechat_x2o($xml);
$sign = $this->wechat_sign($this->settings['v1_key'], $data, 1);
if($sign != $data['sign']) {
return array('code' => 50001, 'data' => $data);
}
if($data['return_code'] != 'SUCCESS') {
return array('code' => 50002, 'data' => $data);
}
if($data['result_code'] != 'SUCCESS') {
return array('code' => 50003, 'data' => $data);
}
return array('code' => 200, 'data' => $data);
}
public function v3_wechat_sign_verify() {
$nonce = $_SERVER['HTTP_WECHATPAY_NONCE'];
$timestamp = $_SERVER['HTTP_WECHATPAY_TIMESTAMP'];
$serial = $_SERVER['HTTP_WECHATPAY_SERIAL'];
$json = file_get_contents('php://input');
$signature = $_SERVER['HTTP_WECHATPAY_SIGNATURE'];
$serial = strtoupper(ltrim($serial, '0'));
$public_key = $this->settings['v3_certificates'][$serial];
if(!$public_key) {
return array('code' => 50001, 'data' => $json);
}
$signature = base64_decode($signature);
$signstr = $timestamp . "\n" . $nonce . "\n" . $json . "\n";
if(!openssl_verify($signstr, $signature, $public_key, 'sha256WithRSAEncryption')) {
return array('code' => 50002, 'data' => $json);
}
$resource = json_decode($json, true);
if($resource['event_type'] != 'TRANSACTION.SUCCESS') {
return array('code' => 50003, 'data' => $resource);
}
$resource = $resource['resource'];
$data = $this->v3_wechat_decrypt2string($resource['associated_data'], $resource['nonce'], $resource['ciphertext']);
return array('code' => 200, 'data' => $data);
}
public function v3_wechat_support() {
if(function_exists('sodium_crypto_aead_aes256gcm_is_available') && sodium_crypto_aead_aes256gcm_is_available()) {
return true;
}
if(PHP_VERSION_ID >= 70100 && in_array('aes-256-gcm', openssl_get_cipher_methods())) {
return true;
}
return false;
}
public function v3_wechat_certificates() {
global $_G;
$api = SDK_WEIXIN_PAY_V3_CERTIFICATES;
$res = $this->v3_wechat_request_json($api, '', 'GET');
$res = json_decode($res, true);
$list = array();
if($res['data']) {
foreach($res['data'] as $item) {
$serial_no = $item['serial_no'];
$item = $item['encrypt_certificate'];
$data = $this->v3_wechat_decrypt2string($item['associated_data'], $item['nonce'], $item['ciphertext']);
$list[$serial_no] = $data;
}
}
return array('code' => 200, 'data' => $list);
}
protected function enable() {
if($this->settings && $this->settings['on']) {
if($this->settings['ec_wechat_version']) {
return $this->v3_wechat_support();
}
return true;
} else {
return false;
}
}
private function wechat_unifiedorder_pay($order, $type = 'NATIVE', $openid = null) {
global $_G;
if(strtoupper($_G['charset'] != 'UTF-8')) {
$order['subject'] = diconv($order['subject'], $_G['charset'], 'UTF-8');
$order['description'] = diconv($order['description'], $_G['charset'], 'UTF-8');
}
$data = array('appid' => $this->settings['appid'], 'mch_id' => $this->settings['mch_id'], 'nonce_str' => $this->wechat_nonce(), 'sign_type' => 'MD5', 'body' => $order['subject'], 'detail' => $order['description'], 'out_trade_no' => $order['out_biz_no'], 'total_fee' => intval($order['amount']), 'spbill_create_ip' => $_G['clientip'], 'time_expire' => dgmdate(time() + 86400, 'YmdHis'), 'notify_url' => $this->notify_url, 'trade_type' => $type,);
if($openid) {
$data['openid'] = $openid;
}
$data['sign'] = $this->wechat_sign($this->settings['v1_key'], $data);
$data = $this->wechat_o2x($data);
$api = SDK_WEIXIN_PAY_UNIFIEDORDER;
$res = $this->wechat_request_xml($api, $data);
if(strtoupper($_G['charset'] != 'UTF-8')) {
$res = diconv($res, 'UTF-8', $_G['charset']);
}
$res = $this->wechat_x2o($res);
if($res['return_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['return_msg']);
} elseif($res['result_code'] != 'SUCCESS') {
return array('code' => 501, 'message' => $res['err_code_des']);
} else {
if($res['code_url']) {
$url = $res['code_url'];
} elseif($res['mweb_url']) {
$url = $res['mweb_url'];
} else {
$url = $res['prepay_id'];
}
return array('code' => 200, 'url' => $url);
}
}
private function wechat_order_query($out_biz_no) {
global $_G;
$data = ['appid' => $this->settings['appid'], 'mch_id' => $this->settings['mch_id'], 'out_trade_no' => $out_biz_no, 'nonce_str' => $this->wechat_nonce(), 'sign_type' => 'MD5'];
$data['sign'] = $this->wechat_sign($this->settings['v1_key'], $data);
$data = $this->wechat_o2x($data);
$api = SDK_WEIXIN_PAY_ORDERQUERY;
$res = $this->wechat_request_xml($api, $data);
if(strtoupper($_G['charset'] != 'UTF-8')) {
$res = diconv($res, 'UTF-8', $_G['charset']);
}
$res = $this->wechat_x2o($res);
if($res['return_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['return_msg']);
} elseif($res['result_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['err_code_des']);
} else {
$pay_time = strtotime(preg_replace('/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/', '$1-$2-$3 $4:$5:$6', $res['time_end']));
return array('code' => 200, 'data' => array('trade_no' => $res['transaction_id'], 'payment_time' => $pay_time));
}
}
private function wechat_refund($refund_no, $trade_no, $total_amount, $refund_amount, $refund_desc) {
global $_G;
if(strtoupper($_G['charset'] != 'UTF-8')) {
$refund_desc = diconv($refund_desc, $_G['charset'], 'UTF-8');
}
$data = ['appid' => $this->settings['appid'], 'mch_id' => $this->settings['mch_id'], 'nonce_str' => $this->wechat_nonce(), 'sign_type' => 'MD5', 'transaction_id' => $trade_no, 'out_refund_no' => $refund_no, 'total_fee' => $total_amount, 'refund_fee' => $refund_amount, 'refund_desc' => $refund_desc];
$data['sign'] = $this->wechat_sign($this->settings['v1_key'], $data);
$data = $this->wechat_o2x($data);
$api = SDK_WEIXIN_PAY_REFUND;
$res = $this->wechat_request_xml($api, $data, true);
if(strtoupper($_G['charset'] != 'UTF-8')) {
$res = diconv($res, 'UTF-8', $_G['charset']);
}
$res = $this->wechat_x2o($res);
if($res['return_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['return_msg']);
} elseif($res['result_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['err_code_des']);
} else {
return array('code' => 200, 'data' => array('refund_time' => time()));
}
}
private function wechat_refund_status($refund_no) {
global $_G;
$data = ['appid' => $this->settings['appid'], 'mch_id' => $this->settings['mch_id'], 'nonce_str' => $this->wechat_nonce(), 'sign_type' => 'MD5', 'out_refund_no' => $refund_no,];
$data['sign'] = $this->wechat_sign($this->settings['v1_key'], $data);
$data = $this->wechat_o2x($data);
$api = SDK_WEIXIN_PAY_REFUNDQUERY;
$res = $this->wechat_request_xml($api, $data);
if(strtoupper($_G['charset'] != 'UTF-8')) {
$res = diconv($res, 'UTF-8', $_G['charset']);
}
$res = $this->wechat_x2o($res);
if($res['return_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['return_msg']);
} elseif($res['result_code'] != 'SUCCESS') {
return array('code' => 500, 'message' => $res['err_code'] . '-' . $res['err_code_des']);
} else {
return array('code' => 200, 'data' => array('refund_time' => time()));
}
}
private function v3_wechat_native_pay($order) {
global $_G;
if(strtoupper($_G['charset'] != 'UTF-8')) {
$order['subject'] = diconv($order['subject'], $_G['charset'], 'UTF-8');
$order['description'] = diconv($order['description'], $_G['charset'], 'UTF-8');
}
$data = array('appid' => $this->settings['appid'], 'mchid' => $this->settings['mch_id'], 'description' => $order['subject'] . ': ' . $order['description'], 'out_trade_no' => $order['out_biz_no'], 'notify_url' => $this->notify_url, 'amount' => array('total' => intval($order['amount']), 'currency' => 'CNY'));
$api = SDK_WEIXIN_PAY_V3_TRANSACTIONS_NATIVE;
$res = $this->v3_wechat_request_json($api, json_encode($data));
$res = json_decode($res, true);
if($res['code_url']) {
return array('code' => 200, 'url' => $res['code_url']);
} else {
if(strtoupper($_G['charset'] != 'UTF-8') && $res['message']) {
$res['message'] = diconv($res['message'], 'UTF-8', $_G['charset']);
}
return array('code' => $res['code'], 'message' => $res['message']);
}
}
private function v3_wechat_h5_pay($order) {
global $_G;
if(strtoupper($_G['charset'] != 'UTF-8')) {
$order['subject'] = diconv($order['subject'], $_G['charset'], 'UTF-8');
$order['description'] = diconv($order['description'], $_G['charset'], 'UTF-8');
}
$data = array('appid' => $this->settings['appid'], 'mchid' => $this->settings['mch_id'], 'description' => $order['subject'] . ': ' . $order['description'], 'out_trade_no' => $order['out_biz_no'], 'notify_url' => $this->notify_url, 'amount' => array('total' => intval($order['amount']), 'currency' => 'CNY'), 'scene_info' => array('payer_client_ip' => $_G['clientip'], 'h5_info' => array('type' => checkmobile())));
$api = SDK_WEIXIN_PAY_V3_TRANSACTIONS_H5;
$res = $this->v3_wechat_request_json($api, json_encode($data));
$res = json_decode($res, true);
if($res['h5_url']) {
return array('code' => 200, 'url' => $res['h5_url']);
} else {
if(strtoupper($_G['charset'] != 'UTF-8') && $res['message']) {
$res['message'] = diconv($res['message'], 'UTF-8', $_G['charset']);
}
return array('code' => $res['code'], 'message' => $res['message']);
}
}
private function v3_wechat_h5_jsapi($order, $openid) {
global $_G;
if(strtoupper($_G['charset'] != 'UTF-8')) {
$order['subject'] = diconv($order['subject'], $_G['charset'], 'UTF-8');
$order['description'] = diconv($order['description'], $_G['charset'], 'UTF-8');
}
$data = array('appid' => $this->settings['appid'], 'mchid' => $this->settings['mch_id'], 'description' => $order['subject'] . ': ' . $order['description'], 'out_trade_no' => $order['out_biz_no'], 'notify_url' => $this->notify_url, 'amount' => array('total' => intval($order['amount']), 'currency' => 'CNY'), 'payer' => array('openid' => $openid));
$api = SDK_WEIXIN_PAY_V3_TRANSACTIONS_H5;
$res = $this->v3_wechat_request_json($api, json_encode($data));
$res = json_decode($res, true);
if($res['prepay_id']) {
return array('code' => 200, 'url' => $res['prepay_id']);
} else {
if(strtoupper($_G['charset'] != 'UTF-8') && $res['message']) {
$res['message'] = diconv($res['message'], 'UTF-8', $_G['charset']);
}
return array('code' => $res['code'], 'message' => $res['message']);
}
}
private function v3_wechat_query_order($out_biz_no) {
global $_G;
$api = SDK_WEIXIN_PAY_V3_TRANSACTIONS_OUTTRADENO;
$res = $this->v3_wechat_request_json($api . $out_biz_no . '?mchid=' . $this->settings['mch_id'], '', 'GET');
$res = json_decode($res, true);
if($res['trade_state'] && $res['trade_state'] == 'SUCCESS') {
$pay_time = strtotime($res['success_time']);
return array('code' => 200, 'data' => array('trade_no' => $res['transaction_id'], 'payment_time' => $pay_time));
} elseif($res['trade_state']) {
return array('code' => $res['trade_state'], 'message' => $res['trade_state_desc']);
} else {
if(strtoupper($_G['charset'] != 'UTF-8') && $res['message']) {
$res['message'] = diconv($res['message'], 'UTF-8', $_G['charset']);
}
return array('code' => $res['code'], 'message' => $res['message']);
}
}
private function v3_wechat_refund($refund_no, $trade_no, $total_amount, $refund_amount, $refund_desc) {
global $_G;
if(strtoupper($_G['charset'] != 'UTF-8')) {
$refund_desc = diconv($refund_desc, $_G['charset'], 'UTF-8');
}
$data = array('transaction_id' => $trade_no, 'out_refund_no' => $refund_no, 'reason' => $refund_desc, 'amount' => array('refund' => intval($refund_amount), 'total' => intval($total_amount), 'currency' => 'CNY'));
$api = SDK_WEIXIN_PAY_V3_REFUND_DOMESTIC_REFUNDS;
$res = $this->v3_wechat_request_json($api, json_encode($data));
$res = json_decode($res, true);
if($res['status'] == 'SUCCESS') {
return array('code' => 200, 'data' => array('refund_time' => strtotime($res['success_time'])));
} elseif($res['status']) {
return array('code' => 201, 'message' => $res['status']);
} elseif($res['status']) {
return array('code' => 500, 'message' => $res['status']);
} else {
if(strtoupper($_G['charset'] != 'UTF-8') && $res['message']) {
$res['message'] = diconv($res['message'], 'UTF-8', $_G['charset']);
}
return array('code' => $res['code'], 'message' => $res['message']);
}
}
private function v3_wechat_refund_query($refund_no) {
global $_G;
$api = SDK_WEIXIN_PAY_V3_REFUND_DOMESTIC_REFUNDS_QUERY;
$res = $this->v3_wechat_request_json($api . $refund_no, '', 'GET');
$res = json_decode($res, true);
if($res['status'] == 'SUCCESS') {
return array('code' => 200, 'data' => array('refund_time' => strtotime($res['success_time'])));
} elseif($res['status']) {
return array('code' => 201, 'message' => $res['status']);
} elseif($res['status']) {
return array('code' => 500, 'message' => $res['status']);
} else {
if(strtoupper($_G['charset'] != 'UTF-8') && $res['message']) {
$res['message'] = diconv($res['message'], 'UTF-8', $_G['charset']);
}
return array('code' => $res['code'], 'message' => $res['message']);
}
}
private function wechat_o2x($data) {
$xml = '<xml>';
foreach($data as $key => $value) {
$xml .= "\n<{$key}>{$value}</{$key}>";
}
$xml .= "\n</xml>";
return $xml;
}
private function wechat_x2o($xml) {
if(function_exists('libxml_disable_entity_loader')) {
libxml_disable_entity_loader(true);
}
$data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
return $data;
}
private function wechat_sign($token, $data, $sign = 0) {
ksort($data);
$signstr = '';
foreach($data as $key => $value) {
if(!$value || ($sign && $key == 'sign')) {
continue;
}
$signstr .= $key . '=' . $value . '&';
}
$signstr .= 'key=' . $token;
$sign = strtoupper(md5($signstr));
return $sign;
}
private function wechat_nonce() {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for($i = 0; $i < 32; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
private function v3_wechat_jsapi_authorization($data) {
$message = $data['appId'] . "\n" . $data['timeStamp'] . "\n" . $data['nonceStr'] . "\n" . $data['package'];
openssl_sign($message, $sign, $this->settings['v3_private_key'], 'sha256WithRSAEncryption');
$sign = base64_encode($sign);
return $sign;
}
private function v3_wechat_authorization($api, $method, $json) {
$url_values = parse_url($api);
$timestamp = time();
$nonce = $this->wechat_nonce();
$message = $method . "\n" . $url_values['path'] . ($url_values['query'] ? ('?' . $url_values['query']) : '') . "\n" . $timestamp . "\n" . $nonce . "\n" . $json . "\n";
openssl_sign($message, $sign, $this->settings['v3_private_key'], 'sha256WithRSAEncryption');
$sign = base64_encode($sign);
$token = sprintf('mchid="%s",nonce_str="%s",timestamp="%d",serial_no="%s",signature="%s"', $this->settings['mch_id'], $nonce, $timestamp, $this->settings['v3_serial_no'], $sign);
return $token;
}
private function v3_wechat_decrypt2string($associateddata, $noncestr, $ciphertext) {
$ciphertext = base64_decode($ciphertext);
if(strlen($ciphertext) <= 16) {
return false;
}
if(function_exists('sodium_crypto_aead_aes256gcm_is_available') && sodium_crypto_aead_aes256gcm_is_available()) {
return sodium_crypto_aead_aes256gcm_decrypt($ciphertext, $associateddata, $noncestr, $this->settings['v3_key']);
}
if(PHP_VERSION_ID >= 70100 && in_array('aes-256-gcm', openssl_get_cipher_methods())) {
$ctext = substr($ciphertext, 0, -16);
$authTag = substr($ciphertext, -16);
return openssl_decrypt($ctext, 'aes-256-gcm', $this->settings['v3_key'], OPENSSL_RAW_DATA, $noncestr, $authTag, $associateddata);
}
return false;
}
private function wechat_request($api, $data = array()) {
$client = filesock::open(array(
'url' => $api,
'method' => 'POST',
'post' => $data
));
return $client->request();
}
private function wechat_request_xml($api, $xml, $cert = false) {
$params = array(
'url' => $api,
'method' => 'POST',
'rawdata' => $xml,
'encodetype' => 'application/xml',
);
if($cert) {
if(!$this->settings['v1_cert_path'] || !file_exists(DISCUZ_ROOT . $this->settings['v1_cert_path']) || !is_file(DISCUZ_ROOT . $this->settings['v1_cert_path'])) {
return '<xml><return_code>400</return_code><return_msg>p12 not found.</return_msg></xml>';
}
$params['verifypeer'] = $this->settings['v1_cert_path'];
}
$client = filesock::open($params);
$data = $client -> request();
if(!$data) {
$data = $client -> filesockbody;
}
return $data;
}
private function v3_wechat_request_json($api, $json = '', $method = 'POST') {
$client = filesock::open(array(
'url' => $api,
'method' => $method,
'rawdata' => $json,
'encodetype' => 'JSON',
'header' => array(
'Accept' => 'application/json',
'Authorization' => 'WECHATPAY2-SHA256-RSA2048 ' . $this->v3_wechat_authorization($api, $method, $json)
)
));
$data = $client->request();
if(!$data) {
$data = $client->filesockbody;
}
return $data;
}
private function wechat_device() {
$useragent = $_SERVER['HTTP_USER_AGENT'];
if(strpos($useragent, 'MicroMessenger') !== false) {
return 'wechat';
} else {
return checkmobile();
}
}
}

0
api/remote/index.htm Normal file
View File

142
api/remote/index.php Normal file
View File

@@ -0,0 +1,142 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: index.php 23508 2011-07-21 06:34:40Z cnteacher $
*/
define('IN_API', true);
define('CURSCRIPT', 'api_mserver');
define('APPTYPEID', 200);
$_ENV['remote'] = new discuz_remote();
$_ENV['remote']->init();
$_ENV['remote']->loadservice();
class discuz_remote {
var $mod;
var $modobj;
var $core;
function init() {
require_once('../../source/class/class_core.php');
$cachelist = array();
$this->core = C::app();
$this->core->cachelist = $cachelist;
$this->core->init_setting = true;
$this->core->init_cron = false;
$this->core->init_user = false;
$this->core->init_session = false;
$this->core->init_misc = false;
$this->core->init_mobile = false;
$this->core->init();
define('SERVICE_DIR', getglobal('config/remote/dir') ? getglobal('config/remote/dir') : 'remote');
$this->core->reject_robot();
if (empty($_GET['mod']) || preg_match('/[^0-9a-z]/i', $_GET['mod'])) {
$this->mod = 'index';
} else {
$this->mod = $_GET['mod'];
}
}
function loadservice() {
if(!$this->core->config['remote']['on']) {
$this->error(1, 'remote service is down');
}
if(!$this->core->config['remote']['appkey']) {
$this->error(1, 'remote service need a appkey, please edit you config.global.php');
}
if ($this->mod != 'index') {
$sign = $_GET['sign'];
unset($_GET['sign']);
if (empty($sign) || $sign != $this->sign($_GET)) {
}
}
if(!$this->check_timestamp()) {
$this->error(5, 'your request is time out');
}
$modfile = DISCUZ_ROOT . './api/' . SERVICE_DIR . '/mod/mod_' . $this->mod . '.php';
if (!is_file($modfile)) {
$this->error(3, 'mod file is missing');
}
require $modfile;
$classname = 'mod_'.$this->mod;
if(class_exists($classname)) {
$service = new $classname;
$service->run();
}
}
function check_timestamp()
{
if(empty($_GET['timestamp'])) {
return 1;
}
$ttl = abs(empty($_GET['ttl']) ? 600 : $_GET['ttl']);
$check = abs(TIMESTAMP - $_GET['timestamp']);
return $check > $ttl ? 0 : 1;
}
function sign($arg) {
$str = '';
foreach ($arg as $k => $v) {
$str .= $k . '=' . $v . '&';
}
return md5($str . getglobal('config/remote/appkey'));
}
function error($code, $msg) {
$code = sprintf("%04d", $code);
echo $code.':'.ucfirst($msg);
exit();
}
}
class remote_service {
var $version = '1.0.0';
var $config;
function __construct() {
$this->config = getglobal('config/remote');
}
function run() {
remote_service::success('service is done.');
}
function error($code, $msg) {
$code = sprintf("%04d", $code);
echo $code.':'.ucfirst($msg);
exit();
}
function success($msg) {
remote_service::error(0, $msg);
}
}
?>

0
api/remote/mod/index.htm Normal file
View File

View File

@@ -0,0 +1,36 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: mod_cron.php 30364 2012-05-24 07:43:27Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class mod_cron extends remote_service
{
function run() {
if(!$this->config['cron']) {
$this->error(100, 'cron service is off. Please check "config.global.php" on your webserver folder.');
}
$discuz = C::app();
$discuz->initated = false;
$discuz->init_db = false;
$discuz->init_setting = true;
$discuz->init_user = false;
$discuz->init_session = false;
$discuz->init_misc = false;
$discuz->init_mobile = false;
$discuz->init_cron = true;
$discuz->init();
$this->success('Cron work is done');
}
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: mod_index.php 30462 2012-05-30 03:27:10Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class mod_index extends remote_service {
var $config;
function __construct() {
parent::__construct();
}
function run() {
$this->success('Discuz! Remote Service API '.$this->version);
}
}

296
api/trade/api_alipay.php Normal file
View File

@@ -0,0 +1,296 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: api_alipay.php 31606 2012-09-13 07:26:35Z monkey $
*/
define('IN_API', true);
define('CURSCRIPT', 'api');
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
list($ec_contract, $ec_securitycode, $ec_partner, $ec_creditdirectpay) = explode("\t", authcode($_G['setting']['ec_contract'], 'DECODE', $_G['config']['security']['authkey']));
define('DISCUZ_PARTNER', $ec_partner);
define('DISCUZ_SECURITYCODE', $ec_securitycode);
define('DISCUZ_DIRECTPAY', $ec_creditdirectpay);
define('STATUS_SELLER_SEND', 4);
define('STATUS_WAIT_BUYER', 5);
define('STATUS_TRADE_SUCCESS', 7);
define('STATUS_REFUND_CLOSE', 17);
function credit_payurl($price, &$orderid) {
global $_G;
$orderid = dgmdate(TIMESTAMP, 'YmdHis').random(18);
$args = array(
'subject' => $_G['setting']['bbname'].' - '.$_G['member']['username'].' - '.lang('forum/misc', 'credit_payment'),
'body' => lang('forum/misc', 'credit_forum_payment').' '.$_G['setting']['extcredits'][$_G['setting']['creditstrans']]['title'].' '.intval($price * $_G['setting']['ec_ratio']).' '.$_G['setting']['extcredits'][$_G['setting']['creditstrans']]['unit'],
'service' => 'trade_create_by_buyer',
'partner' => DISCUZ_PARTNER,
'notify_url' => $_G['siteurl'].'api/trade/notify_credit.php',
'return_url' => $_G['siteurl'].'api/trade/notify_credit.php',
'show_url' => $_G['siteurl'],
'_input_charset' => CHARSET,
'out_trade_no' => $orderid,
'price' => $price,
'quantity' => 1,
'seller_email' => $_G['setting']['ec_account'],
'extend_param' => 'isv^dz11'
);
if(DISCUZ_DIRECTPAY) {
$args['service'] = 'create_direct_pay_by_user';
$args['payment_type'] = '1';
} else {
$args['logistics_type'] = 'EXPRESS';
$args['logistics_fee'] = 0;
$args['logistics_payment'] = 'SELLER_PAY';
$args['payment_type'] = 1;
}
return trade_returnurl($args);
}
function invite_payurl($amount, $price, &$orderid) {
global $_G;
$orderid = dgmdate(TIMESTAMP, 'YmdHis').random(18);
$args = array(
'subject' => $_G['setting']['bbname'].' - '.lang('forum/misc', 'invite_payment'),
'body' => lang('forum/misc', 'invite_forum_payment').' '.intval($amount).' '.lang('forum/misc', 'invite_forum_payment_unit'),
'service' => 'trade_create_by_buyer',
'partner' => DISCUZ_PARTNER,
'notify_url' => $_G['siteurl'].'api/trade/notify_invite.php',
'return_url' => $_G['siteurl'].'api/trade/notify_invite.php',
'show_url' => $_G['siteurl'],
'_input_charset' => CHARSET,
'out_trade_no' => $orderid,
'price' => $price,
'quantity' => 1,
'seller_email' => $_G['setting']['ec_account'],
'extend_param' => 'isv^dz11'
);
if(DISCUZ_DIRECTPAY) {
$args['service'] = 'create_direct_pay_by_user';
$args['payment_type'] = '1';
} else {
$args['logistics_type'] = 'EXPRESS';
$args['logistics_fee'] = 0;
$args['logistics_payment'] = 'SELLER_PAY';
$args['payment_type'] = 1;
}
return trade_returnurl($args);
}
function trade_payurl($pay, $trade, $tradelog) {
global $_G;
$args = array(
'service' => 'trade_create_by_buyer',
'partner' => DISCUZ_PARTNER,
'notify_url' => $_G['siteurl'].'api/trade/notify_trade.php',
'return_url' => $_G['siteurl'].'api/trade/notify_trade.php',
'show_url' => $tradelog['tid'] ? $_G['siteurl'].'forum.php?mod=viewthread&do=tradeinfo&tid='.$tradelog['tid'].'&pid='.$tradelog['pid'] : $_G['siteurl'],
'_input_charset' => CHARSET,
'subject' => $trade['subject'],
'body' => $trade['subject'],
'out_trade_no' => $tradelog['orderid'],
'price' => $tradelog['baseprice'],
'quantity' => $tradelog['number'],
'logistics_type' => $pay['logistics_type'],
'logistics_fee' => $tradelog['transportfee'],
'logistics_payment' => $pay['transport'],
'payment_type' => $trade['itemtype'],
'seller_email' => $trade['account'],
'extend_param' => 'isv^dz11'
);
if($pay['logistics_type'] == 'VIRTUAL') {
if(DISCUZ_DIRECTPAY) {
$args['service'] = 'create_direct_pay_by_user';
$args['payment_type'] = '1';
unset($args['logistics_type'], $args['logistics_fee'], $args['logistics_payment']);
} else {
$args['logistics_type'] = 'EXPRESS';
$args['logistics_payment'] = 'SELLER_PAY';
$args['payment_type'] = '1';
}
}
return trade_returnurl($args);
}
function trade_returnurl($args) {
global $_G;
ksort($args);
$urlstr = $sign = '';
foreach($args as $key => $val) {
$sign .= '&'.$key.'='.$val;
$urlstr .= $key.'='.rawurlencode($val).'&';
}
$sign = substr($sign, 1);
$sign = md5($sign.DISCUZ_SECURITYCODE);
return 'https://www.alipay.com/cooperate/gateway.do?'.$urlstr.'sign='.$sign.'&sign_type=MD5';
}
function trade_notifycheck($type) {
global $_G;
if(!empty($_POST)) {
$notify = $_POST;
$location = FALSE;
} elseif(!empty($_GET)) {
$notify = $_GET;
$location = TRUE;
} else {
exit('Access Denied');
}
unset($notify['diy']);
if(dfsockopen("https://notify.alipay.com/trade/notify_query.do?partner=".DISCUZ_PARTNER."&notify_id=".$notify['notify_id'], 60) !== 'true') {
exit('Access Denied');
}
if($type == 'trade') {
$urlstr = '';
foreach($notify as $key => $val) {
$urlstr .= $key.'='.rawurlencode($val).'&';
}
} else {
if(!DISCUZ_SECURITYCODE) {
exit('Access Denied');
}
ksort($notify);
$sign = '';
foreach($notify as $key => $val) {
if($key != 'sign' && $key != 'sign_type') $sign .= "&$key=$val";
}
if($notify['sign'] != md5(substr($sign,1).DISCUZ_SECURITYCODE)) {
exit('Access Denied');
}
}
if(($type == 'credit' || $type == 'invite') && (!DISCUZ_DIRECTPAY && $notify['notify_type'] == 'trade_status_sync' && ($notify['trade_status'] == 'WAIT_SELLER_SEND_GOODS' || $notify['trade_status'] == 'TRADE_FINISHED') || DISCUZ_DIRECTPAY && ($notify['trade_status'] == 'TRADE_FINISHED' || $notify['trade_status'] == 'TRADE_SUCCESS'))
|| $type == 'trade' && $notify['notify_type'] == 'trade_status_sync') {
return array(
'validator' => TRUE,
'status' => trade_getstatus(!empty($notify['refund_status']) ? $notify['refund_status'] : $notify['trade_status'], 1),
'order_no' => $notify['out_trade_no'],
'price' => !DISCUZ_DIRECTPAY && $notify['price'] ? $notify['price'] : $notify['total_fee'],
'trade_no' => $notify['trade_no'],
'notify' => 'success',
'location' => $location
);
} else {
return array(
'validator' => FALSE,
'notify' => 'fail',
'location' => $location
);
}
}
function trade_getorderurl($orderid) {
return 'https://www.alipay.com/trade/query_trade_detail.htm?trade_no='.$orderid;
}
function trade_typestatus($method, $status = -1) {
switch($method) {
case 'buytrades' : $methodvalue = array(1, 5, 11, 12);break;
case 'selltrades' : $methodvalue = array(2, 4, 10, 13);break;
case 'successtrades' : $methodvalue = array(7);break;
case 'tradingtrades' : $methodvalue = array(1, 2, 3, 4, 5, 6, 10, 11, 12, 13, 14, 15, 16);break;
case 'closedtrades' : $methodvalue = array(8, 17);break;
case 'refundsuccess' : $methodvalue = array(17);break;
case 'refundtrades' : $methodvalue = array(14, 15, 16, 17, 18);break;
case 'unstarttrades' : $methodvalue = array(0);break;
case 'eccredittrades' : $methodvalue = array(7, 17);break;
}
return $status != -1 ? in_array($status, $methodvalue) : $methodvalue;
}
function trade_getstatus($key, $method = 2) {
$language = lang('forum/misc');
$status[1] = array(
'WAIT_BUYER_PAY' => 1,
'WAIT_SELLER_CONFIRM_TRADE' => 2,
'WAIT_SYS_CONFIRM_PAY' => 3,
'WAIT_SELLER_SEND_GOODS' => 4,
'WAIT_BUYER_CONFIRM_GOODS' => 5,
'WAIT_SYS_PAY_SELLER' => 6,
'TRADE_FINISHED' => 7,
'TRADE_CLOSED' => 8,
'WAIT_SELLER_AGREE' => 10,
'SELLER_REFUSE_BUYER' => 11,
'WAIT_BUYER_RETURN_GOODS' => 12,
'WAIT_SELLER_CONFIRM_GOODS' => 13,
'WAIT_ALIPAY_REFUND' => 14,
'ALIPAY_CHECK' => 15,
'OVERED_REFUND' => 16,
'REFUND_SUCCESS' => 17,
'REFUND_CLOSED' => 18
);
$status[2] = array(
0 => $language['trade_unstart'],
1 => $language['trade_waitbuyerpay'],
2 => $language['trade_waitsellerconfirm'],
3 => $language['trade_sysconfirmpay'],
4 => $language['trade_waitsellersend'],
5 => $language['trade_waitbuyerconfirm'],
6 => $language['trade_syspayseller'],
7 => $language['trade_finished'],
8 => $language['trade_closed'],
10 => $language['trade_waitselleragree'],
11 => $language['trade_sellerrefusebuyer'],
12 => $language['trade_waitbuyerreturn'],
13 => $language['trade_waitsellerconfirmgoods'],
14 => $language['trade_waitalipayrefund'],
15 => $language['trade_alipaycheck'],
16 => $language['trade_overedrefund'],
17 => $language['trade_refundsuccess'],
18 => $language['trade_refundclosed']
);
return $method == -1 ? $status[2] : $status[$method][$key];
}
function trade_setprice($data, &$price, &$pay, &$transportfee) {
if($data['transport'] == 1) {
$pay['transport'] = 'SELLER_PAY';
} elseif($data['transport'] == 2) {
$pay['transport'] = 'BUYER_PAY';
} elseif($data['transport'] == 3) {
$pay['logistics_type'] = 'VIRTUAL';
} else {
$pay['transport'] = 'BUYER_PAY_AFTER_RECEIVE';
}
if($data['transport'] != 3) {
if($data['fee'] == 1) {
$pay['logistics_type'] = 'POST';
$pay['logistics_fee'] = $data['trade']['ordinaryfee'];
if($data['transport'] == 2) {
$price = $price + $data['trade']['ordinaryfee'];
$transportfee = $data['trade']['ordinaryfee'];
}
} elseif($data['fee'] == 2) {
$pay['logistics_type'] = 'EMS';
$pay['logistics_fee'] = $data['trade']['emsfee'];
if($data['transport'] == 2) {
$price = $price + $data['trade']['emsfee'];
$transportfee = $data['trade']['emsfee'];
}
} else {
$pay['logistics_type'] = 'EXPRESS';
$pay['logistics_fee'] = $data['trade']['expressfee'];
if($data['transport'] == 2) {
$price = $price + $data['trade']['expressfee'];
$transportfee = $data['trade']['expressfee'];
}
}
}
}
?>

582
api/trade/api_tenpay.php Normal file
View File

@@ -0,0 +1,582 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: api_tenpay.php 32222 2012-12-03 02:28:43Z monkey $
*/
define('IN_API', true);
define('CURSCRIPT', 'api');
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('DISCUZ_PARTNER', $_G['setting']['ec_tenpay_bargainor']);
define('DISCUZ_SECURITYCODE', $_G['setting']['ec_tenpay_key']);
define('DISCUZ_AGENTID', '1204737401');
define('DISCUZ_TENPAY_OPENTRANS_CHNID', $_G['setting']['ec_tenpay_opentrans_chnid']);
define('DISCUZ_TENPAY_OPENTRANS_KEY', $_G['setting']['ec_tenpay_opentrans_key']);
define('STATUS_SELLER_SEND', 3);
define('STATUS_WAIT_BUYER', 4);
define('STATUS_TRADE_SUCCESS', 5);
define('STATUS_REFUND_CLOSE', 9);
class RequestHandler {
var $gateUrl;
var $key;
var $parameters;
var $debugInfo;
function __construct() {
$this->RequestHandler();
}
function RequestHandler() {
$this->gateUrl = "https://www.tenpay.com/cgi-bin/med/show_opentrans.cgi";
$this->key = "";
$this->parameters = array();
$this->debugInfo = "";
}
function init() {
}
function getGateURL() {
return $this->gateUrl;
}
function setGateURL($gateUrl) {
$this->gateUrl = $gateUrl;
}
function getKey() {
return $this->key;
}
function setKey($key) {
$this->key = $key;
}
function getParameter($parameter) {
return $this->parameters[$parameter];
}
function setParameter($parameter, $parameterValue) {
$this->parameters[$parameter] = $parameterValue;
}
function getAllParameters() {
$this->createSign();
return $this->parameters;
}
function getRequestURL() {
$this->createSign();
$reqPar = "";
ksort($this->parameters);
foreach($this->parameters as $k => $v) {
$reqPar .= $k . "=" . urlencode($v) . "&";
}
$reqPar = substr($reqPar, 0, strlen($reqPar)-1);
$requestURL = $this->getGateURL() . "?" . $reqPar;
return $requestURL;
}
function getDebugInfo() {
return $this->debugInfo;
}
function doSend() {
header("Location:" . $this->getRequestURL());
exit;
}
function createSign() {
$signPars = "";
ksort($this->parameters);
foreach($this->parameters as $k => $v) {
if("" !== $v && "sign" !== $k) {
$signPars .= $k . "=" . $v . "&";
}
}
$signPars .= "key=" . $this->getKey();
$sign = strtolower(md5($signPars));
$this->setParameter("sign", $sign);
$this->_setDebugInfo($signPars . " => sign:" . $sign);
}
function _setDebugInfo($debugInfo) {
$this->debugInfo = $debugInfo;
}
}
class ResponseHandler {
var $key;
var $parameters;
var $debugInfo;
function __construct() {
$this->ResponseHandler();
}
function ResponseHandler() {
$this->key = "";
$this->parameters = array();
$this->debugInfo = "";
foreach($_GET as $k => $v) {
$this->setParameter($k, $v);
}
foreach($_POST as $k => $v) {
$this->setParameter($k, $v);
}
}
function getKey() {
return $this->key;
}
function setKey($key) {
$this->key = $key;
}
function getParameter($parameter) {
return $this->parameters[$parameter];
}
function setParameter($parameter, $parameterValue) {
$this->parameters[$parameter] = $parameterValue;
}
function getAllParameters() {
return $this->parameters;
}
function isTenpaySign() {
$signPars = "";
ksort($this->parameters);
foreach($this->parameters as $k => $v) {
if("sign" !== $k && "" !== $v) {
$signPars .= $k . "=" . $v . "&";
}
}
$signPars .= "key=" . $this->getKey();
$sign = strtolower(md5($signPars));
$tenpaySign = strtolower($this->getParameter("sign"));
$this->_setDebugInfo($signPars . " => sign:" . $sign .
" tenpaySign:" . $this->getParameter("sign"));
return $sign == $tenpaySign;
}
function getDebugInfo() {
return $this->debugInfo;
}
function _setDebugInfo($debugInfo) {
$this->debugInfo = $debugInfo;
}
}
class MediPayRequestHandler extends RequestHandler {
function __construct() {
$this->MediPayRequestHandler();
}
function MediPayRequestHandler() {
$this->setGateURL("https://www.tenpay.com/cgi-bin/med/show_opentrans.cgi");
}
function init() {
$this->setParameter("attach", "1");
$this->setParameter("chnid", "");
$this->setParameter("cmdno", "12");
$this->setParameter("encode_type", "1");
$this->setParameter("mch_desc", "");
$this->setParameter("mch_name", "");
$this->setParameter("mch_price", "");
$this->setParameter("mch_returl", "");
$this->setParameter("mch_type", "");
$this->setParameter("mch_vno", "");
$this->setParameter("need_buyerinfo", "");
$this->setParameter("seller", "");
$this->setParameter("show_url", "");
$this->setParameter("transport_desc", "");
$this->setParameter("transport_fee", "");
$this->setParameter("version", "2");
$this->setParameter("sign", "");
}
}
class MediPayResponseHandler extends ResponseHandler {
function doShow() {
$strHtml = "<html><head>\r\n" .
"<meta name=\"TENCENT_ONLINE_PAYMENT\" content=\"China TENCENT\">" .
"</head><body></body></html>";
echo $strHtml;
exit;
}
function isTenpaySign() {
$signParameterArray = array(
'attach',
'buyer_id',
'cft_tid',
'chnid',
'cmdno',
'mch_vno',
'retcode',
'seller',
'status',
'total_fee',
'trade_price',
'transport_fee',
'version'
);
ksort($signParameterArray);
foreach($signParameterArray as $k ) {
$v = $this->getParameter($k);
if(isset($v)) {
$signPars .= $k . "=" . urldecode($v) . "&";
}
}
$signPars .= "key=" . $this->getKey();
$sign = strtolower(md5($signPars));
$tenpaySign = strtolower($this->getParameter("sign"));
$this->_setDebugInfo($signPars . " => sign:" . $sign .
" tenpaySign:" . $this->getParameter("sign"));
return $sign == $tenpaySign;
}
}
function credit_payurl($price, &$orderid, $bank = 'DEFAULT') {
include_once DISCUZ_ROOT . './source/class/class_chinese.php';
global $_G;
$date = dgmdate(TIMESTAMP, 'YmdHis');
$suffix = dgmdate(TIMESTAMP, 'His').rand(1000, 9999);
$transaction_id = DISCUZ_PARTNER.$date.$suffix;
$orderid = dgmdate(TIMESTAMP, 'YmdHis').random(14);
$chinese = new Chinese(strtoupper(CHARSET), 'GBK');
$subject = $chinese->Convert(lang('forum/misc', 'credit_forum_payment').' '.$_G['setting']['extcredits'][$_G['setting']['creditstrans']]['title'].' '.intval($price * $_G['setting']['ec_ratio']).' '.$_G['setting']['extcredits'][$_G['setting']['creditstrans']]['unit']);
$reqHandler = new RequestHandler();
$reqHandler->setGateURL("https://gw.tenpay.com/gateway/pay.htm");
$reqHandler->init();
$reqHandler->setKey(DISCUZ_SECURITYCODE);
$reqHandler->setParameter("partner", DISCUZ_PARTNER);
$reqHandler->setParameter("out_trade_no", $orderid);
$reqHandler->setParameter("total_fee", $price * 100);
$reqHandler->setParameter("return_url", $_G['siteurl'].'api/trade/notify_credit.php');
$reqHandler->setParameter("notify_url", $_G['siteurl'].'api/trade/notify_credit.php');
$reqHandler->setParameter("body", $subject);
$reqHandler->setParameter("bank_type", $bank);
$reqHandler->setParameter("spbill_create_ip", $_G['clientip']);
$reqHandler->setParameter("fee_type", "1");
$reqHandler->setParameter("subject", $subject);
$reqHandler->setParameter("sign_type", "MD5");
$reqHandler->setParameter("service_version", "1.0");
$reqHandler->setParameter("input_charset", "GBK");
$reqHandler->setParameter("sign_key_index", "1");
$reqHandler->setParameter("attach", "tenpay");
$reqHandler->setParameter("time_start", $date);
$reqHandler->setParameter("trade_mode","1");
$reqHandler->setParameter("trans_type","1");
$reqHandler->setParameter("agentid", DISCUZ_AGENTID);
$reqHandler->setParameter("agent_type","2");
$reqUrl = $reqHandler->getRequestURL();
return $reqUrl;
}
function trade_payurl($pay, $trade, $tradelog) {
global $_G;
$key = DISCUZ_TENPAY_OPENTRANS_KEY;
$chnid = DISCUZ_TENPAY_OPENTRANS_CHNID;
$seller = $trade['tenpayaccount'];
$mch_desc = $trade['subject'];
$mch_name = $trade['subject'];
$mch_price = $tradelog['baseprice'] * $tradelog['number'] * 100;
$mch_returl = $_G['siteurl'].'api/trade/notify_trade.php';
$mch_vno = $tradelog['orderid'];
$show_url = $_G['siteurl'].'api/trade/notify_trade.php';
$transport_desc = $pay['logistics_type'];
$transport_fee = $tradelog['transportfee'] * 100;
if(strtolower(CHARSET) == 'gbk') {
$encode_type = '1';
} else {
$encode_type = '2';
}
$mch_type = '1';
$need_buyerinfo = '1';
if($pay['logistics_type'] == 'VIRTUAL') {
$mch_type = '2';
$need_buyerinfo = '2';
}
$reqHandler = new MediPayRequestHandler();
$reqHandler->init();
$reqHandler->setKey($key);
$reqHandler->setParameter("chnid", $chnid);
$reqHandler->setParameter("encode_type", $encode_type);
$reqHandler->setParameter("mch_desc", $mch_desc);
$reqHandler->setParameter("mch_name", $mch_name);
$reqHandler->setParameter("mch_price", $mch_price);
$reqHandler->setParameter("mch_returl", $mch_returl);
$reqHandler->setParameter("mch_type", $mch_type);
$reqHandler->setParameter("mch_vno", $mch_vno);
$reqHandler->setParameter("need_buyerinfo", $need_buyerinfo);
$reqHandler->setParameter("seller", $seller);
$reqHandler->setParameter("show_url", $show_url);
$reqHandler->setParameter("transport_desc", $transport_desc);
$reqHandler->setParameter("transport_fee", $transport_fee);
$reqHandler->setParameter('attach', 'tenpay');
$reqUrl = $reqHandler->getRequestURL();
return $reqUrl;
}
function invite_payurl($amount, $price, &$orderid, $bank = 'DEFAULT') {
include_once DISCUZ_ROOT . './source/class/class_chinese.php';
global $_G;
$date = dgmdate(TIMESTAMP, 'YmdHis');
$suffix = dgmdate(TIMESTAMP, 'His').rand(1000, 9999);
$transaction_id = DISCUZ_PARTNER.$date.$suffix;
$orderid = dgmdate(TIMESTAMP, 'YmdHis').random(14);
$chinese = new Chinese(strtoupper(CHARSET), 'GBK');
$subject = $chinese->Convert(lang('forum/misc', 'invite_forum_payment').' '.intval($amount).' '.lang('forum/misc', 'invite_forum_payment_unit'));
$reqHandler = new RequestHandler();
$reqHandler->setGateURL("https://gw.tenpay.com/gateway/pay.htm");
$reqHandler->init();
$reqHandler->setKey(DISCUZ_SECURITYCODE);
$reqHandler->setParameter("partner", DISCUZ_PARTNER);
$reqHandler->setParameter("out_trade_no", $orderid);
$reqHandler->setParameter("total_fee", $price * 100);
$reqHandler->setParameter("return_url", $_G['siteurl'].'api/trade/notify_invite.php');
$reqHandler->setParameter("notify_url", $_G['siteurl'].'api/trade/notify_invite.php');
$reqHandler->setParameter("body", $subject);
$reqHandler->setParameter("bank_type", $bank);
$reqHandler->setParameter("spbill_create_ip", $_G['clientip']);
$reqHandler->setParameter("fee_type", "1");
$reqHandler->setParameter("subject", $subject);
$reqHandler->setParameter("sign_type", "MD5");
$reqHandler->setParameter("service_version", "1.0");
$reqHandler->setParameter("input_charset", "GBK");
$reqHandler->setParameter("sign_key_index", "1");
$reqHandler->setParameter("attach", "tenpay");
$reqHandler->setParameter("time_start", $date);
$reqHandler->setParameter("trade_mode","1");
$reqHandler->setParameter("trans_type","1");
$reqHandler->setParameter("agentid", DISCUZ_AGENTID);
$reqHandler->setParameter("agent_type","2");
$reqUrl = $reqHandler->getRequestURL();
return $reqUrl;
}
function trade_notifycheck($type) {
global $_G;
if($type == 'credit' || $type == 'invite') {
if(!DISCUZ_SECURITYCODE) {
exit('Access Denied');
}
$resHandler = new ResponseHandler();
$resHandler->setKey(DISCUZ_SECURITYCODE);
$resHandler->setParameter("bankname", "");
} else {
if(!DISCUZ_TENPAY_OPENTRANS_KEY) {
exit('Access Denied');
}
$resHandler = new MediPayResponseHandler();
$resHandler->setKey(DISCUZ_TENPAY_OPENTRANS_KEY);
}
if($type == 'credit' || $type == 'invite') {
if($resHandler->isTenpaySign() && DISCUZ_PARTNER == $_GET['partner']) {
return array(
'validator' => isset($_GET['trade_state']) ? !$_GET['trade_state'] : 0,
'order_no' => $_GET['out_trade_no'],
'trade_no' => isset($_GET['transaction_id']) ? $_GET['transaction_id'] : '',
'price' => $_GET['total_fee'] / 100,
'bargainor_id' => $_GET['partner'],
'location' => true,
);
}
} elseif($type == 'trade') {
if($resHandler->isTenpaySign()) {
return array(
'validator' => $resHandler->getParameter('retcode') == '0',
'order_no' => $resHandler->getParameter('mch_vno'),
'trade_no' => $resHandler->getParameter('cft_tid'),
'price' => $resHandler->getParameter('total_fee') / 100,
'status' => $resHandler->getParameter('status'),
'location' => true,
);
}
} else {
return array(
'validator' => FALSE,
'location' => 'forum.php?mod=memcp&action=credits&operation=addfunds&return=fail'
);
}
}
function trade_setprice($data, &$price, &$pay, &$transportfee) {
if($data['transport'] == 3) {
$pay['logistics_type'] = 'VIRTUAL';
}
if($data['transport'] != 3) {
if($data['fee'] == 1) {
$pay['logistics_type'] = 'POST';
$pay['logistics_fee'] = $data['trade']['ordinaryfee'];
if($data['transport'] == 2) {
$price = $price + $data['trade']['ordinaryfee'];
$transportfee = $data['trade']['ordinaryfee'];
}
} elseif($data['fee'] == 2) {
$pay['logistics_type'] = 'EMS';
$pay['logistics_fee'] = $data['trade']['emsfee'];
if($data['transport'] == 2) {
$price = $price + $data['trade']['emsfee'];
$transportfee = $data['trade']['emsfee'];
}
} else {
$pay['logistics_type'] = 'EXPRESS';
$pay['logistics_fee'] = $data['trade']['expressfee'];
if($data['transport'] == 2) {
$price = $price + $data['trade']['expressfee'];
$transportfee = $data['trade']['expressfee'];
}
}
}
}
function trade_getorderurl($orderid) {
return "https://www.tenpay.com/med/tradeDetail.shtml?b=1&trans_id=$orderid";
}
function trade_typestatus($method, $status = -1) {
switch($method) {
case 'buytrades' : $methodvalue = array(1, 3);break;
case 'selltrades' : $methodvalue = array(2, 4);break;
case 'successtrades' : $methodvalue = array(5);break;
case 'tradingtrades' : $methodvalue = array(1, 2, 3, 4);break;
case 'closedtrades' : $methodvalue = array(6, 10);break;
case 'refundsuccess' : $methodvalue = array(9);break;
case 'refundtrades' : $methodvalue = array(9, 10);break;
case 'unstarttrades' : $methodvalue = array(0);break;
}
return $status != -1 ? in_array($status, $methodvalue) : $methodvalue;
}
function trade_getstatus($key, $method = 2) {
$language = lang('forum/misc');
$status[1] = array(
'WAIT_BUYER_PAY' => 1,
'WAIT_SELLER_CONFIRM_TRADE' => 2,
'WAIT_SELLER_SEND_GOODS' => 3,
'WAIT_BUYER_CONFIRM_GOODS' => 4,
'TRADE_FINISHED' => 5,
'TRADE_CLOSED' => 6,
'REFUND_SUCCESS' => 9,
'REFUND_CLOSED' => 10,
);
$status[2] = array(
0 => $language['trade_unstart'],
1 => $language['trade_waitbuyerpay'],
2 => $language['trade_waitsellerconfirm'],
3 => $language['trade_waitsellersend'],
4 => $language['trade_waitbuyerconfirm'],
5 => $language['trade_finished'],
6 => $language['trade_closed'],
9 => $language['trade_refundsuccess'],
10 => $language['trade_refundclosed']
);
return $method == -1 ? $status[2] : $status[$method][$key];
}
?>

0
api/trade/index.htm Normal file
View File

View File

@@ -0,0 +1,73 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: notify_credit.php 34251 2013-11-25 03:10:11Z nemohou $
*/
define('IN_API', true);
define('CURSCRIPT', 'api');
define('DISABLEXSSCHECK', true);
require '../../source/class/class_core.php';
require '../../source/function/function_forum.php';
$discuz = C::app();
$discuz->init();
$apitype = empty($_GET['attach']) || !preg_match('/^[a-z0-9]+$/i', $_GET['attach']) ? 'alipay' : $_GET['attach'];
require_once DISCUZ_ROOT.'./api/trade/api_'.$apitype.'.php';
$PHP_SELF = $_SERVER['PHP_SELF'];
$_G['siteurl'] = dhtmlspecialchars($_G['scheme'].'://'.$_SERVER['HTTP_HOST'].preg_replace("/\/+(api\/trade)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))).'/');
$notifydata = trade_notifycheck('credit');
if($notifydata['validator']) {
$orderid = $notifydata['order_no'];
$postprice = $notifydata['price'];
$order = C::t('forum_order')->fetch($orderid);
$order = array_merge($order, C::t('common_member')->fetch_by_username($order['uid']));
if($order && floatval($postprice) == floatval($order['price']) && ($apitype == 'tenpay' || strtolower($_G['setting']['ec_account']) == strtolower($_REQUEST['seller_email']))) {
if($order['status'] == 1) {
C::t('forum_order')->update($orderid, array('status' => '2', 'buyer' => "{$notifydata['trade_no']}\t$apitype", 'confirmdate' => $_G['timestamp']));
updatemembercount($order['uid'], array($_G['setting']['creditstrans'] => $order['amount']), 1, 'AFD', $order['uid']);
updatecreditbyaction($action, $uid = 0, $extrasql = array(), $needle = '', $coef = 1, $update = 1, $fid = 0);
C::t('forum_order')->delete_by_submitdate($_G['timestamp']-60*86400);
$submitdate = dgmdate($order['submitdate']);
$confirmdate = dgmdate(TIMESTAMP);
notification_add($order['uid'], 'credit', 'addfunds', array(
'orderid' => $order['orderid'],
'price' => $order['price'],
'value' => $_G['setting']['extcredits'][$_G['setting']['creditstrans']]['title'].' '.$order['amount'].' '.$_G['setting']['extcredits'][$_G['setting']['creditstrans']]['unit']
), 1);
}
}
}
if($notifydata['location']) {
$url = rawurlencode('home.php?mod=spacecp&ac=credit');
if($apitype == 'tenpay') {
echo <<<EOS
<meta name="TENCENT_ONLINE_PAYMENT" content="China TENCENT">
<html>
<body>
<script language="javascript" type="text/javascript">
window.location.href='{$_G['siteurl']}forum.php?mod=misc&action=paysucceed';
</script>
</body>
</html>
EOS;
} else {
dheader('location: '.$_G['siteurl'].'forum.php?mod=misc&action=paysucceed');
}
} else {
exit($notifydata['notify']);
}
?>

View File

@@ -0,0 +1,90 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: notify_invite.php 34251 2013-11-25 03:10:11Z nemohou $
*/
define('IN_API', true);
define('CURSCRIPT', 'api');
define('DISABLEXSSCHECK', true);
require '../../source/class/class_core.php';
require '../../source/function/function_forum.php';
$discuz = C::app();
$discuz->init();
$apitype = empty($_GET['attach']) || !preg_match('/^[a-z0-9]+$/i', $_GET['attach']) ? 'alipay' : $_GET['attach'];
require_once DISCUZ_ROOT.'./api/trade/api_'.$apitype.'.php';
$PHP_SELF = $_SERVER['PHP_SELF'];
$_G['siteurl'] = dhtmlspecialchars($_G['scheme'].'://'.$_SERVER['HTTP_HOST'].preg_replace("/\/+(api\/trade)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))).'/');
$notifydata = trade_notifycheck('invite');
if($notifydata['validator']) {
$orderid = $notifydata['order_no'];
$postprice = $notifydata['price'];
$order = C::t('forum_order')->fetch($orderid);
if($order && floatval($postprice) == floatval($order['price']) && ($apitype == 'tenpay' || $_G['setting']['ec_account'] == $_REQUEST['seller_email'])) {
if($order['status'] == 1) {
C::t('forum_order')->update($orderid, array('status' => '2', 'buyer' => "{$notifydata['trade_no']}\t$apitype", 'confirmdate' => $_G['timestamp']));
$codes = $codetext = array();
$dateline = TIMESTAMP;
for($i=0; $i<$order['amount']; $i++) {
$code = strtolower(random(6));
$codetext[] = $code;
$codes[] = "('0', '$code', '$dateline', '".($_G['group']['maxinviteday']?($_G['timestamp']+$_G['group']['maxinviteday']*24*3600):$_G['timestamp']+86400*10)."', '{$order['email']}', '{$_G['clientip']}', '$orderid')";
$invitedata = array(
'uid' => 0,
'code' => $code,
'dateline' => $dateline,
'endtime' => $_G['group']['maxinviteday'] ? ($_G['timestamp']+$_G['group']['maxinviteday']*24*3600) : $_G['timestamp']+86400*10,
'email' => $order['email'],
'inviteip' => $_G['clientip'],
'orderid' => $orderid
);
C::t('common_invite')->insert($invitedata);
}
C::t('forum_order')->delete_by_submitdate($_G['timestamp']-60*86400);
$submitdate = dgmdate($order['submitdate']);
$confirmdate = dgmdate(TIMESTAMP);
if(!function_exists('sendmail')) {
include libfile('function/mail');
}
$add_member_subject = $_G['setting']['bbname'].' - '.lang('forum/misc', 'invite_payment');
$add_member_message = lang('email', 'invite_payment_email_message', array(
'orderid' => $order['orderid'],
'codetext' => implode('<br />', $codetext),
'siteurl' => $_G['siteurl'],
'bbname' => $_G['setting']['bbname'],
));
if(!sendmail($order['email'], $add_member_subject, $add_member_message)) {
runlog('sendmail', "{$order['email']} sendmail failed.");
}
}
}
}
if($notifydata['location']) {
if($apitype == 'tenpay') {
echo <<<EOS
<meta name="TENCENT_ONLINE_PAYMENT" content="China TENCENT">
<html>
<body>
<script language="javascript" type="text/javascript">
window.location.href='{$_G['siteurl']}misc.php?mod=buyinvitecode&action=paysucceed&orderid=$orderid';
</script>
</body>
</html>
EOS;
} else {
dheader('location: '.$_G['siteurl'].'misc.php?mod=buyinvitecode&action=paysucceed&orderid='.$orderid);
}
} else {
exit($notifydata['notify']);
}
?>

118
api/trade/notify_trade.php Normal file
View File

@@ -0,0 +1,118 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: notify_trade.php 34251 2013-11-25 03:10:11Z nemohou $
*/
define('IN_API', true);
define('CURSCRIPT', 'api');
define('DISABLEXSSCHECK', true);
require '../../source/class/class_core.php';
require '../../source/function/function_forum.php';
$discuz = C::app();
$discuz->init();
$apitype = empty($_GET['attach']) || !preg_match('/^[a-z0-9]+$/i', $_GET['attach']) ? 'alipay' : $_GET['attach'];
require_once DISCUZ_ROOT.'./api/trade/api_' . $apitype . '.php';
$PHP_SELF = $_SERVER['PHP_SELF'];
$_G['siteurl'] = dhtmlspecialchars($_G['scheme'].'://'.$_SERVER['HTTP_HOST'].preg_replace("/\/+(api\/trade)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))).'/');
$notifydata = trade_notifycheck('trade');
if($notifydata['validator']) {
$orderid = $notifydata['order_no'];
if($orderid) {
$tradelog = C::t('forum_tradelog')->fetch($orderid);
if($tradelog && $tradelog['status'] != STATUS_TRADE_SUCCESS && $tradelog['status'] != STATUS_REFUND_CLOSE && ($apitype == 'tenpay' || $tradelog['selleraccount'] == $_REQUEST['seller_email'])) {
$status = $notifydata['status'];
C::t('forum_tradelog')->update($orderid, array(
'status' => $status,
'lastupdate' => $_G['timestamp'],
'tradeno' => $notifydata['trade_no']
));
if($status != $tradelog['status']) {
if($status == STATUS_SELLER_SEND) {
notification_add($tradelog['sellerid'], 'goods', 'trade_seller_send', array(
'buyerid' => $tradelog['buyerid'],
'buyer' => $tradelog['buyer'],
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
} elseif($status == STATUS_WAIT_BUYER) {
notification_add($tradelog['buyerid'], 'goods', 'trade_buyer_confirm', array(
'sellerid' => $tradelog['sellerid'],
'seller' => $tradelog['seller'],
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
} elseif($status == STATUS_TRADE_SUCCESS) {
if($_G['setting']['creditstransextra'][5] != -1 && $tradelog['basecredit']) {
$netcredit = round($tradelog['number'] * $tradelog['basecredit'] * (1 - $_G['setting']['creditstax']));
updatemembercount($tradelog['sellerid'], array($_G['setting']['creditstransextra'][5] => $netcredit));
} else {
$netcredit = 0;
}
C::t('forum_trade')->update_trade($tradelog['tid'], $tradelog['pid'], array('lastbuyer' => $tradelog['buyer'], 'lastupdate' => $_G['timestamp']));
C::t('forum_trade')->update_counter($tradelog['tid'], $tradelog['pid'], $tradelog['number'], $tradelog['price'], $netcredit);
updatecreditbyaction('tradefinished', $tradelog['sellerid']);
updatecreditbyaction('tradefinished', $tradelog['buyerid']);
notification_add($tradelog['sellerid'], 'goods', 'trade_success', array(
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
notification_add($tradelog['buyerid'], 'goods', 'trade_success', array(
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
} elseif($status == STATUS_REFUND_CLOSE) {
C::t('forum_trade')->update_counter($tradelog['tid'], $tradelog['pid'], 0, 0, 0, $tradelog['number']);
notification_add($tradelog['sellerid'], 'goods', 'trade_fefund_success', array(
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
notification_add($tradelog['buyerid'], 'goods', 'trade_fefund_success', array(
'orderid' => $orderid,
'subject' => $tradelog['subject']
));
if($_G['setting']['creditstrans'] && $tradelog['buyerid']) {
updatemembercount($tradelog['buyerid'], array($_G['setting']['creditstrans'] => $tradelog['buyercredits']));
}
if($_G['setting']['creditstransextra'][5] != -1 && $tradelog['basecredit'] && $tradelog['buyerid']) {
$credit = $tradelog['number'] * $tradelog['basecredit'];
updatemembercount($tradelog['buyerid'], array($_G['setting']['creditstransextra'][5] => $credit));
}
}
}
}
}
}
if($notifydata['location']) {
dheader('location: '.$_G['siteurl'].'forum.php?mod=misc&action=paysucceed&orderid='.$orderid);
} else {
exit($notifydata['notify']);
}
?>

359
api/uc.php Normal file
View File

@@ -0,0 +1,359 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: uc.php 36358 2017-01-20 02:05:50Z nemohou $
*/
error_reporting(0);
define('API_DELETEUSER', 1);
define('API_RENAMEUSER', 1);
define('API_GETTAG', 1);
define('API_SYNLOGIN', 1);
define('API_SYNLOGOUT', 1);
define('API_UPDATEPW', 1);
define('API_UPDATEBADWORDS', 1);
define('API_UPDATEHOSTS', 1);
define('API_UPDATEAPPS', 1);
define('API_UPDATECLIENT', 1);
define('API_UPDATECREDIT', 1);
define('API_GETCREDIT', 1);
define('API_GETCREDITSETTINGS', 1);
define('API_UPDATECREDITSETTINGS', 1);
define('API_ADDFEED', 1);
define('API_RETURN_SUCCEED', '1');
define('API_RETURN_FAILED', '-1');
define('API_RETURN_FORBIDDEN', '1');
define('IN_API', true);
define('CURSCRIPT', 'api');
define('DISABLEXSSCHECK', true);
if(!defined('IN_UC')) {
require_once '../source/class/class_core.php';
$discuz = C::app();
$discuz->init();
require DISCUZ_ROOT.'./config/config_ucenter.php';
require DISCUZ_ROOT.'./uc_client/release/release.php';
$get = $post = array();
$code = @$_GET['code'];
parse_str(authcode($code, 'DECODE', UC_KEY), $get);
if(empty($get) || UC_STANDALONE) {
exit('Invalid Request');
}
if(time() - $get['time'] > 3600) {
exit('Authorization has expired');
}
include_once DISCUZ_ROOT.'./uc_client/lib/xml.class.php';
$phpinput = file_get_contents('php://input');
$post = xml_unserialize($phpinput);
require DISCUZ_ROOT.'./uc_client/extend_client.php';
if(in_array($get['action'], array('test', 'deleteuser', 'renameuser', 'gettag', 'synlogin', 'synlogout', 'updatepw', 'updatebadwords', 'updatehosts', 'updateapps', 'updateclient', 'updatecredit', 'getcredit', 'getcreditsettings', 'updatecreditsettings', 'addfeed'))) {
$uc_note = new uc_note();
echo call_user_func(array($uc_note, $get['action']), $get, $post);
exit();
} else {
exit(API_RETURN_FAILED);
}
} else {
exit;
}
class uc_note {
var $dbconfig = '';
var $db = '';
var $tablepre = '';
var $appdir = '';
function _serialize($arr, $htmlon = 0) {
if(!function_exists('xml_serialize')) {
include_once DISCUZ_ROOT.'./uc_client/lib/xml.class.php';
}
return xml_serialize($arr, $htmlon);
}
function __construct() {
}
function test($get, $post) {
return API_RETURN_SUCCEED;
}
function deleteuser($get, $post) {
global $_G;
if(!API_DELETEUSER) {
return API_RETURN_FORBIDDEN;
}
return uc_note_handler::deleteuser($get, $post);
}
function renameuser($get, $post) {
global $_G;
if(!API_RENAMEUSER) {
return API_RETURN_FORBIDDEN;
}
return uc_note_handler::renameuser($get, $post);
}
function gettag($get, $post) {
global $_G;
if(!API_GETTAG) {
return API_RETURN_FORBIDDEN;
}
return $this->_serialize(array($get['id'], array()), 1);
}
function synlogin($get, $post) {
global $_G;
if(!API_SYNLOGIN) {
return API_RETURN_FORBIDDEN;
}
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
$cookietime = 31536000;
$uid = intval($get['uid']);
if(($member = getuserbyuid($uid, 1))) {
dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}", 'ENCODE'), $cookietime);
}
}
function synlogout($get, $post) {
global $_G;
if(!API_SYNLOGOUT) {
return API_RETURN_FORBIDDEN;
}
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
dsetcookie('auth', '', -31536000);
}
function updatepw($get, $post) {
global $_G;
if(!API_UPDATEPW) {
return API_RETURN_FORBIDDEN;
}
return uc_note_handler::updatepw($get, $post);
}
function updatebadwords($get, $post) {
global $_G;
if(!API_UPDATEBADWORDS) {
return API_RETURN_FORBIDDEN;
}
$data = array();
if(is_array($post)) {
foreach($post as $k => $v) {
if(substr($v['findpattern'], 0, 1) != '/' || substr($v['findpattern'], -3) != '/is') {
$v['findpattern'] = '/' . preg_quote($v['findpattern'], '/') . '/is';
}
$data['findpattern'][$k] = $v['findpattern'];
$data['replace'][$k] = $v['replacement'];
}
}
$cachefile = DISCUZ_ROOT.'./uc_client/data/cache/badwords.php';
$s = "<?php\r\n";
$s .= '$_CACHE[\'badwords\'] = '.var_export($data, TRUE).";\r\n";
if(file_put_contents($cachefile, $s, LOCK_EX) === false) {
return API_RETURN_FAILED;
}
return API_RETURN_SUCCEED;
}
function updatehosts($get, $post) {
global $_G;
if(!API_UPDATEHOSTS) {
return API_RETURN_FORBIDDEN;
}
$cachefile = DISCUZ_ROOT.'./uc_client/data/cache/hosts.php';
$s = "<?php\r\n";
$s .= '$_CACHE[\'hosts\'] = '.var_export($post, TRUE).";\r\n";
if(file_put_contents($cachefile, $s, LOCK_EX) === false) {
return API_RETURN_FAILED;
}
return API_RETURN_SUCCEED;
}
function updateapps($get, $post) {
global $_G;
if(!API_UPDATEAPPS) {
return API_RETURN_FORBIDDEN;
}
$UC_API = '';
if($post['UC_API']) {
$UC_API = str_replace(array('\'', '"', '\\', "\0", "\n", "\r"), '', $post['UC_API']);
unset($post['UC_API']);
}
$cachefile = DISCUZ_ROOT.'./uc_client/data/cache/apps.php';
$s = "<?php\r\n";
$s .= '$_CACHE[\'apps\'] = '.var_export($post, TRUE).";\r\n";
if(file_put_contents($cachefile, $s, LOCK_EX) === false) {
return API_RETURN_FAILED;
}
if($UC_API && is_writeable(DISCUZ_ROOT.'./config/config_ucenter.php')) {
if(preg_match('/^https?:\/\//is', $UC_API)) {
require DISCUZ_ROOT.'./config/config_ucenter.php';
$configfile = trim(file_get_contents(DISCUZ_ROOT.'./config/config_ucenter.php'));
$configfile = substr($configfile, -2) == '?>' ? substr($configfile, 0, -2) : $configfile;
$configfile = str_replace("define('UC_API', '".addslashes(UC_API)."')", "define('UC_API', '".addslashes($UC_API)."')", $configfile);
if(file_put_contents(DISCUZ_ROOT.'./config/config_ucenter.php', trim($configfile)) === false) {
return API_RETURN_FAILED;
}
}
}
return API_RETURN_SUCCEED;
}
function updateclient($get, $post) {
global $_G;
if(!API_UPDATECLIENT) {
return API_RETURN_FORBIDDEN;
}
$cachefile = DISCUZ_ROOT.'./uc_client/data/cache/settings.php';
$s = "<?php\r\n";
$s .= '$_CACHE[\'settings\'] = '.var_export($post, TRUE).";\r\n";
if(file_put_contents($cachefile, $s, LOCK_EX) === false) {
return API_RETURN_FAILED;
}
return API_RETURN_SUCCEED;
}
function updatecredit($get, $post) {
global $_G;
if(!API_UPDATECREDIT) {
return API_RETURN_FORBIDDEN;
}
$credit = $get['credit'];
$amount = $get['amount'];
$uid = $get['uid'];
if(!getuserbyuid($uid)) {
return API_RETURN_SUCCEED;
}
updatemembercount($uid, array($credit => $amount));
C::t('common_credit_log')->insert(array('uid' => $uid, 'operation' => 'ECU', 'relatedid' => $uid, 'dateline' => time(), 'extcredits'.$credit => $amount));
return API_RETURN_SUCCEED;
}
function getcredit($get, $post) {
global $_G;
if(!API_GETCREDIT) {
return API_RETURN_FORBIDDEN;
}
$uid = intval($get['uid']);
$credit = intval($get['credit']);
$_G['uid'] = $_G['member']['uid'] = $uid;
return getuserprofile('extcredits'.$credit);
}
function getcreditsettings($get, $post) {
global $_G;
if(!API_GETCREDITSETTINGS) {
return API_RETURN_FORBIDDEN;
}
$credits = array();
foreach($_G['setting']['extcredits'] as $id => $extcredits) {
$credits[$id] = array(strip_tags($extcredits['title']), $extcredits['unit']);
}
return $this->_serialize($credits);
}
function updatecreditsettings($get, $post) {
global $_G;
if(!API_UPDATECREDITSETTINGS) {
return API_RETURN_FORBIDDEN;
}
$outextcredits = array();
foreach($get['credit'] as $appid => $credititems) {
if($appid == UC_APPID) {
foreach($credititems as $value) {
$outextcredits[$value['appiddesc'].'|'.$value['creditdesc']] = array(
'appiddesc' => $value['appiddesc'],
'creditdesc' => $value['creditdesc'],
'creditsrc' => $value['creditsrc'],
'title' => $value['title'],
'unit' => $value['unit'],
'ratiosrc' => $value['ratiosrc'],
'ratiodesc' => $value['ratiodesc'],
'ratio' => $value['ratio']
);
}
}
}
$tmp = array();
foreach($outextcredits as $value) {
$key = $value['appiddesc'].'|'.$value['creditdesc'];
if(!isset($tmp[$key])) {
$tmp[$key] = array('title' => $value['title'], 'unit' => $value['unit']);
}
$tmp[$key]['ratiosrc'][$value['creditsrc']] = $value['ratiosrc'];
$tmp[$key]['ratiodesc'][$value['creditsrc']] = $value['ratiodesc'];
$tmp[$key]['creditsrc'][$value['creditsrc']] = $value['ratio'];
}
$outextcredits = $tmp;
$cachefile = DISCUZ_ROOT.'./uc_client/data/cache/creditsettings.php';
$s = "<?php\r\n";
$s .= '$_CACHE[\'creditsettings\'] = '.var_export($outextcredits, TRUE).";\r\n";
if(file_put_contents($cachefile, $s, LOCK_EX) === false) {
return API_RETURN_FAILED;
}
return API_RETURN_SUCCEED;
}
function addfeed($get, $post) {
global $_G;
if(!API_ADDFEED) {
return API_RETURN_FORBIDDEN;
}
return API_RETURN_SUCCEED;
}
}

30
archiver/index.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: index.php 17587 2010-10-25 01:25:10Z monkey $
*/
define('IN_ARCHIVER', 1);
chdir('../');
$querystring = $_SERVER['QUERY_STRING'];
if(!empty($_GET['action']) && !empty($_GET['value'])) {
$querystring = $_GET['action'].'-'.$_GET['value'];
}
if(substr($querystring, 0, 3) == 'fid') {
$_GET['mod'] = 'forumdisplay';
$_GET['fid'] = intval(substr($querystring, 4));
} elseif(substr($querystring, 0, 3) == 'tid') {
$_GET['mod'] = 'viewthread';
$_GET['tid'] = intval(substr($querystring, 4));
}
include 'forum.php';
?>

136
config/config_global.php Normal file
View File

@@ -0,0 +1,136 @@
<?php
$_config = array();
// ---------------------------- CONFIG DB ----------------------------- //
$_config['db'][1]['dbhost'] = 'localhost';
$_config['db'][1]['dbuser'] = 'discuzuser';
$_config['db'][1]['dbpw'] = 'Zht20000418?';
$_config['db'][1]['dbcharset'] = 'utf8mb4';
$_config['db'][1]['pconnect'] = 0;
$_config['db'][1]['dbname'] = 'discuz';
$_config['db'][1]['tablepre'] = 'pre_';
$_config['db']['slave'] = '';
$_config['db']['common']['slave_except_table'] = '';
$_config['db']['common']['engine'] = 'innodb';
// -------------------------- CONFIG MEMORY --------------------------- //
$_config['memory']['prefix'] = 'oyM8vc_';
$_config['memory']['redis']['server'] = '';
$_config['memory']['redis']['port'] = 6379;
$_config['memory']['redis']['pconnect'] = 1;
$_config['memory']['redis']['timeout'] = 0;
$_config['memory']['redis']['requirepass'] = '';
$_config['memory']['redis']['db'] = 0;
$_config['memory']['memcache']['server'] = '';
$_config['memory']['memcache']['port'] = 11211;
$_config['memory']['memcache']['pconnect'] = 1;
$_config['memory']['memcache']['timeout'] = 1;
$_config['memory']['memcached']['server'] = '';
$_config['memory']['memcached']['port'] = 11211;
$_config['memory']['apc'] = 0;
$_config['memory']['apcu'] = 0;
$_config['memory']['xcache'] = 0;
$_config['memory']['eaccelerator'] = 0;
$_config['memory']['wincache'] = 0;
$_config['memory']['yac'] = 0;
$_config['memory']['file']['server'] = '';
// -------------------------- CONFIG SERVER --------------------------- //
$_config['server']['id'] = 1;
// ------------------------- CONFIG DOWNLOAD -------------------------- //
$_config['download']['readmod'] = 2;
$_config['download']['xsendfile']['type'] = 0;
$_config['download']['xsendfile']['dir'] = '/down/';
// -------------------------- CONFIG OUTPUT --------------------------- //
$_config['output']['charset'] = 'utf-8';
$_config['output']['forceheader'] = 1;
$_config['output']['gzip'] = 0;
$_config['output']['tplrefresh'] = 1;
$_config['output']['language'] = 'zh_cn';
$_config['output']['staticurl'] = 'static/';
$_config['output']['ajaxvalidate'] = 0;
$_config['output']['upgradeinsecure'] = 0;
$_config['output']['css4legacyie'] = 1;
// -------------------------- CONFIG COOKIE --------------------------- //
$_config['cookie']['cookiepre'] = 'ArYe_';
$_config['cookie']['cookiedomain'] = '';
$_config['cookie']['cookiepath'] = '/';
// ------------------------- CONFIG SECURITY -------------------------- //
$_config['security']['authkey'] = '0cce2ddd3c59e7c200abc6dc8b4e7416iJFYiJNrE2VzQbOWHQKsr9Rp9w5vMy1l';
$_config['security']['urlxssdefend'] = 1;
$_config['security']['attackevasive'] = 0;
$_config['security']['onlyremoteaddr'] = 1;
$_config['security']['useipban'] = 1;
$_config['security']['querysafe']['status'] = 1;
$_config['security']['querysafe']['dfunction'][0] = 'load_file';
$_config['security']['querysafe']['dfunction'][1] = 'hex';
$_config['security']['querysafe']['dfunction'][2] = 'substring';
$_config['security']['querysafe']['dfunction'][3] = 'if';
$_config['security']['querysafe']['dfunction'][4] = 'ord';
$_config['security']['querysafe']['dfunction'][5] = 'char';
$_config['security']['querysafe']['daction'][0] = '@';
$_config['security']['querysafe']['daction'][1] = 'intooutfile';
$_config['security']['querysafe']['daction'][2] = 'intodumpfile';
$_config['security']['querysafe']['daction'][3] = 'unionselect';
$_config['security']['querysafe']['daction'][4] = '(select';
$_config['security']['querysafe']['daction'][5] = 'unionall';
$_config['security']['querysafe']['daction'][6] = 'uniondistinct';
$_config['security']['querysafe']['dnote'][0] = '/*';
$_config['security']['querysafe']['dnote'][1] = '*/';
$_config['security']['querysafe']['dnote'][2] = '#';
$_config['security']['querysafe']['dnote'][3] = '--';
$_config['security']['querysafe']['dnote'][4] = '"';
$_config['security']['querysafe']['dlikehex'] = 1;
$_config['security']['querysafe']['afullnote'] = 0;
$_config['security']['creditsafe']['second'] = 0;
$_config['security']['creditsafe']['times'] = 10;
$_config['security']['fsockopensafe']['port'][0] = 80;
$_config['security']['fsockopensafe']['port'][1] = 443;
$_config['security']['fsockopensafe']['ipversion'][0] = 'ipv6';
$_config['security']['fsockopensafe']['ipversion'][1] = 'ipv4';
$_config['security']['fsockopensafe']['verifypeer'] = '';
$_config['security']['error']['showerror'] = '1';
$_config['security']['error']['guessplugin'] = '1';
// -------------------------- CONFIG ADMINCP -------------------------- //
// -------- Founders: $_config['admincp']['founder'] = '1,2,3'; --------- //
$_config['admincp']['founder'] = '1';
$_config['admincp']['forcesecques'] = 0;
$_config['admincp']['checkip'] = 1;
$_config['admincp']['runquery'] = 0;
$_config['admincp']['dbimport'] = 1;
$_config['admincp']['mustlogin'] = 1;
// -------------------------- CONFIG REMOTE --------------------------- //
$_config['remote']['on'] = 0;
$_config['remote']['dir'] = 'remote';
$_config['remote']['appkey'] = '62cf0b3c3e6a4c9468e7216839721d8e';
$_config['remote']['cron'] = 0;
// --------------------------- CONFIG INPUT --------------------------- //
$_config['input']['compatible'] = 0;
// --------------------------- CONFIG IPDB ---------------------------- //
$_config['ipdb']['setting']['fullstack'] = '';
$_config['ipdb']['setting']['default'] = '';
$_config['ipdb']['setting']['ipv4'] = 'tiny';
$_config['ipdb']['setting']['ipv6'] = 'v6wry';
// ------------------------- CONFIG IPGETTER -------------------------- //
$_config['ipgetter']['setting'] = 'header';
$_config['ipgetter']['header']['header'] = 'HTTP_X_FORWARDED_FOR';
$_config['ipgetter']['iplist']['header'] = 'HTTP_X_FORWARDED_FOR';
$_config['ipgetter']['iplist']['list'][0] = '127.0.0.1';
$_config['ipgetter']['dnslist']['header'] = 'HTTP_X_FORWARDED_FOR';
$_config['ipgetter']['dnslist']['list'][0] = 'comsenz.com';
// ------------------- THE END -------------------- //
?>

View File

@@ -0,0 +1,262 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: config_global_default.php 36362 2017-02-04 02:02:03Z nemohou $
*/
$_config = array();
// 提示:自当前版本起,本文件不支持调用系统内任何变量或函数,请依赖此行为的站点修正实现 //
// ---------------------------- CONFIG DB ----------------------------- //
// ---------------------------- 数据库相关设置---------------------------- //
/**
* 数据库主服务器设置, 支持多组服务器设置, 当设置多组服务器时, 则会根据分布式策略使用某个服务器
* @example
* $_config['db']['1']['dbhost'] = 'localhost'; // 服务器地址
* $_config['db']['1']['dbuser'] = 'root'; // 用户
* $_config['db']['1']['dbpw'] = 'root';// 密码
* $_config['db']['1']['dbcharset'] = 'gbk';// 字符集
* $_config['db']['1']['pconnect'] = '0';// 是否持续连接
* $_config['db']['1']['dbname'] = 'x1';// 数据库
* $_config['db']['1']['tablepre'] = 'pre_';// 表名前缀
*
* $_config['db']['2']['dbhost'] = 'localhost';
* ...
*
*/
$_config['db'][1]['dbhost'] = '127.0.0.1';
$_config['db'][1]['dbuser'] = 'root';
$_config['db'][1]['dbpw'] = '';
$_config['db'][1]['dbcharset'] = 'utf8mb4';
$_config['db'][1]['pconnect'] = 0;
$_config['db'][1]['dbname'] = 'ultrax';
$_config['db'][1]['tablepre'] = 'pre_';
/**
* 数据库从服务器设置( slave, 只读 ), 支持多组服务器设置, 当设置多组服务器时, 系统根据每次随机使用
* @example
* $_config['db']['1']['slave']['1']['dbhost'] = 'localhost';
* $_config['db']['1']['slave']['1']['dbuser'] = 'root';
* $_config['db']['1']['slave']['1']['dbpw'] = 'root';
* $_config['db']['1']['slave']['1']['dbcharset'] = 'gbk';
* $_config['db']['1']['slave']['1']['pconnect'] = '0';
* $_config['db']['1']['slave']['1']['dbname'] = 'x1';
* $_config['db']['1']['slave']['1']['tablepre'] = 'pre_';
* $_config['db']['1']['slave']['1']['weight'] = '0'; //权重:数据越大权重越高
*
* $_config['db']['1']['slave']['2']['dbhost'] = 'localhost';
* ...
*
*/
$_config['db']['1']['slave'] = array();
//启用从服务器的开关
$_config['db']['slave'] = false;
/**
* 数据库 分布部署策略设置
*
* @example 将 common_member 部署到第二服务器, common_session 部署在第三服务器, 则设置为
* $_config['db']['map']['common_member'] = 2;
* $_config['db']['map']['common_session'] = 3;
*
* 对于没有明确声明服务器的表, 则一律默认部署在第一服务器上
*
*/
$_config['db']['map'] = array();
/**
* 数据库 公共设置, 此类设置通常对针对每个部署的服务器
*/
$_config['db']['common'] = array();
/**
* 禁用从数据库的数据表, 表名字之间使用逗号分割
*
* @example common_session, common_member 这两个表仅从主服务器读写, 不使用从服务器
* $_config['db']['common']['slave_except_table'] = 'common_session, common_member';
*
*/
$_config['db']['common']['slave_except_table'] = '';
/*
* 数据库引擎根据自己的数据库引擎进行设置3.5之后默认为innodb之前为myisam
* 对于从3.4升级到3.5并且没有转换数据库引擎的用户在此设置为myisam
*/
$_config['db']['common']['engine'] = 'innodb';
/**
* 内存服务器优化设置
* 以下设置需要PHP扩展组件支持其中 memcache 优先于其他设置,
* 当 memcache 无法启用时,会自动开启另外的两种优化模式
*/
//内存变量前缀, 可更改,避免同服务器中的程序引用错乱
$_config['memory']['prefix'] = 'discuz_';
/* Redis设置, 需要PHP扩展组件支持, timeout参数的作用没有查证 */
$_config['memory']['redis']['server'] = '';
$_config['memory']['redis']['port'] = 6379;
$_config['memory']['redis']['pconnect'] = 1;
$_config['memory']['redis']['timeout'] = 0;
$_config['memory']['redis']['requirepass'] = '';
$_config['memory']['redis']['db'] = 0; //这里可以填写0到15的数字每个站点使用不同的db
/**
* 此配置现在已经取消默认对array使用php serializer进行编码保存其它数据直接原样保存
*/
// $_config['memory']['redis']['serializer'] = 1;
$_config['memory']['memcache']['server'] = ''; // memcache 服务器地址
$_config['memory']['memcache']['port'] = 11211; // memcache 服务器端口
$_config['memory']['memcache']['pconnect'] = 1; // memcache 是否长久连接
$_config['memory']['memcache']['timeout'] = 1; // memcache 服务器连接超时
$_config['memory']['memcached']['server'] = ''; // memcached 服务器地址
$_config['memory']['memcached']['port'] = 11211; // memcached 服务器端口
$_config['memory']['apc'] = 0; // 启动对 APC 的支持
$_config['memory']['apcu'] = 0; // 启动对 APCu 的支持
$_config['memory']['xcache'] = 0; // 启动对 xcache 的支持
$_config['memory']['eaccelerator'] = 0; // 启动对 eaccelerator 的支持
$_config['memory']['wincache'] = 0; // 启动对 wincache 的支持
$_config['memory']['yac'] = 0; //启动对 YAC 的支持
$_config['memory']['file']['server'] = ''; // File 缓存存放目录,如设置为 data/cache/filecache ,设置后启动 File 缓存
// 服务器相关设置
$_config['server']['id'] = 1; // 服务器编号多webserver的时候用于标识当前服务器的ID
// 附件下载相关
//
// 本地文件读取模式; 模式2为最节省内存方式但不支持多线程下载
// 如需附件URL地址、媒体附件播放需选择支持Range参数的读取模式1或4其他模式会导致部分浏览器下视频播放异常
// 1=fread 2=readfile 3=fpassthru 4=fpassthru+multiple
$_config['download']['readmod'] = 2;
// 是否启用 X-Sendfile 功能需要服务器支持0=close 1=nginx 2=lighttpd 3=apache
$_config['download']['xsendfile']['type'] = 0;
// 启用 nginx X-sendfile 时,论坛附件目录的虚拟映射路径,请使用 / 结尾
$_config['download']['xsendfile']['dir'] = '/down/';
// 页面输出设置
$_config['output']['charset'] = 'utf-8'; // 页面字符集
$_config['output']['forceheader'] = 1; // 强制输出页面字符集,用于避免某些环境乱码
$_config['output']['gzip'] = 0; // 是否采用 Gzip 压缩输出
$_config['output']['tplrefresh'] = 1; // 模板自动刷新开关 0=关闭, 1=打开
$_config['output']['language'] = 'zh_cn'; // 页面语言 zh_cn/zh_tw
$_config['output']['staticurl'] = 'static/'; // 站点静态文件路径,“/”结尾
$_config['output']['ajaxvalidate'] = 0; // 是否严格验证 Ajax 页面的真实性 0=关闭1=打开
$_config['output']['upgradeinsecure'] = 0; // 在HTTPS环境下请求浏览器升级HTTP内链到HTTPS此选项影响外域资源链接且与自定义CSP冲突 0=关闭(默认)1=打开
$_config['output']['css4legacyie'] = 1; // 是否加载兼容低版本IE的css文件 0=关闭1=打开默认关闭可避免现代浏览器加载不必要的数据但IE6-8的显示效果会受较大影响IE9受较小影响。
// COOKIE 设置
$_config['cookie']['cookiepre'] = 'discuz_'; // COOKIE前缀
$_config['cookie']['cookiedomain'] = ''; // COOKIE作用域
$_config['cookie']['cookiepath'] = '/'; // COOKIE作用路径
// 站点安全设置
$_config['security']['authkey'] = 'asdfasfas'; // 站点加密密钥
$_config['security']['urlxssdefend'] = true; // 自身 URL XSS 防御
$_config['security']['attackevasive'] = 0; // CC 攻击防御 1|2|4|8
$_config['security']['onlyremoteaddr'] = 1; // 用户IP地址获取方式 0=信任HTTP_CLIENT_IP、HTTP_X_FORWARDED_FOR(默认) 1=只信任 REMOTE_ADDR(推荐)
// 考虑到防止IP撞库攻击、IP限制策略失效的风险建议您设置为1。使用CDN的用户可以配置ipgetter选项
// 安全提示由于UCenter、UC_Client独立性原因您需要单独在两个应用内定义常量从而开启功能
$_config['security']['useipban'] = 1; // 是否开启允许/禁止IP功能高负载站点可以将此功能疏解至HTTP Server/CDN/SLB/WAF上降低服务器压力
$_config['security']['querysafe']['status'] = 1; // 是否开启SQL安全检测可自动预防SQL注入攻击
$_config['security']['querysafe']['dfunction'] = array('load_file','hex','substring','if','ord','char');
$_config['security']['querysafe']['daction'] = array('@','intooutfile','intodumpfile','unionselect','(select', 'unionall', 'uniondistinct');
$_config['security']['querysafe']['dnote'] = array('/*','*/','#','--','"');
$_config['security']['querysafe']['dlikehex'] = 1;
$_config['security']['querysafe']['afullnote'] = 0;
$_config['security']['creditsafe']['second'] = 0; // 开启用户积分信息安全,可防止并发刷分,满足 times(次数)/second(秒) 的操作无法提交
$_config['security']['creditsafe']['times'] = 10;
$_config['security']['fsockopensafe']['port'] = array(80, 443); //fsockopen 有效的端口
$_config['security']['fsockopensafe']['ipversion'] = array('ipv6', 'ipv4'); //fsockopen 有效的IP协议
$_config['security']['fsockopensafe']['verifypeer'] = false; // fsockopen是否验证证书有效性开启可提升安全性但需自行解决证书配置问题
$_config['security']['error']['showerror'] = '1'; //是否在数据库或系统严重异常时显示错误详细信息0=不显示(更安全)1=显示详细信息(默认)2=只显示错误本身
$_config['security']['error']['guessplugin'] = '1'; //是否在数据库或系统严重异常时猜测可能报错的插件0=不猜测1=猜测(默认)
$_config['admincp']['founder'] = '1'; // 站点创始人:拥有站点管理后台的最高权限,每个站点可以设置 1名或多名创始人
// 可以使用uid也可以使用用户名多个创始人之间请使用逗号“,”分开;
$_config['admincp']['forcesecques'] = 0; // 管理人员必须设置安全提问才能进入系统设置 0=否, 1=是[安全]
$_config['admincp']['checkip'] = 1; // 后台管理操作是否验证管理员的 IP, 1=是[安全], 0=否。仅在管理员无法登陆后台时设置 0。
$_config['admincp']['runquery'] = 0; // 是否允许后台运行 SQL 语句 1=是 0=否[安全]
$_config['admincp']['dbimport'] = 1; // 是否允许后台恢复论坛数据 1=是 0=否[安全]
$_config['admincp']['mustlogin'] = 1; // 是否必须前台登录后才允许后台登录 1=是[安全] 0=否
/**
* 系统远程调用功能模块
*/
// 远程调用: 总开关 0=关 1=开
$_config['remote']['on'] = 0;
// 远程调用: 程序目录名. 出于安全考虑,您可以更改这个目录名, 修改完毕, 请手工修改程序的实际目录
$_config['remote']['dir'] = 'remote';
// 远程调用: 通信密钥. 用于客户端和本服务端的通信加密. 长度不少于 32 位
// 默认值是 $_config['security']['authkey'] 的 md5, 您也可以手工指定
$_config['remote']['appkey'] = md5($_config['security']['authkey']);
// 远程调用: 开启外部 cron 任务. 系统内部不再执行cron, cron任务由外部程序激活
$_config['remote']['cron'] = 0;
// $_GET|$_POST的兼容处理0为关闭1为开启开启后即可使用$_G['gp_xx'](xx为变量名$_GET和$_POST集合的所有变量名)值为已经addslashes()处理过
// 考虑到安全风险自X3.5版本起本开关恢复默认值为0的设定后续版本可能取消此功能请各位开发人员注意
$_config['input']['compatible'] = 0;
/**
* IP数据库扩展
* $_config['ipdb']下除setting外均可用作自定义扩展IP库设置选项也欢迎大家PR自己的扩展IP库。
* 扩展IP库的设置请使用格式
* $_config['ipdb']['扩展ip库名称']['设置项名称'] = '值';
* 比如:
* $_config['ipdb']['redis_ip']['server'] = '172.16.1.8';
*/
$_config['ipdb']['setting']['fullstack'] = ''; // 系统使用的全栈IP库优先级最高
$_config['ipdb']['setting']['default'] = ''; // 系统使用的默认IP库优先级最低
$_config['ipdb']['setting']['ipv4'] = 'tiny'; // 系统使用的默认IPv4库留空为使用默认库
$_config['ipdb']['setting']['ipv6'] = 'v6wry'; // 系统使用的默认IPv6库留空为使用默认库
/**
* IP获取扩展
* 考虑到不同的CDN服务供应商提供的判断CDN源IP的策略不同您可以定义自己服务供应商的IP获取扩展。
* 为空为使用默认体系非空情况下会自动调用source/class/ip/getter_值.php内的get方法获取IP地址。
* 系统提供dnslist(IP反解析域名白名单)、serverlist(IP地址白名单支持CIDR)、header扩展具体请参考扩展文件。
* 性能提示自带的两款工具由于依赖RDNS、CIDR判定等操作对系统效率有较大影响建议大流量站点使用HTTP Server
* 或CDN/SLB/WAF上的IP黑白名单等逻辑实现CDN IP地址白名单随后使用header扩展指定服务商提供的IP头的方式实现。
* 安全提示由于UCenter、UC_Client独立性及扩展性原因您需要单独修改相关文件的相关业务逻辑从而实现此类功能。
* $_config['ipgetter']下除setting外均可用作自定义IP获取模型设置选项也欢迎大家PR自己的扩展IP获取模型。
* 扩展IP获取模型的设置请使用格式
* $_config['ipgetter']['IP获取扩展名称']['设置项名称'] = '值';
* 比如:
* $_config['ipgetter']['onlinechk']['server'] = '100.64.10.24';
*/
$_config['ipgetter']['setting'] = 'header';
$_config['ipgetter']['header']['header'] = 'HTTP_X_FORWARDED_FOR';
$_config['ipgetter']['iplist']['header'] = 'HTTP_X_FORWARDED_FOR';
$_config['ipgetter']['iplist']['list']['0'] = '127.0.0.1';
$_config['ipgetter']['dnslist']['header'] = 'HTTP_X_FORWARDED_FOR';
$_config['ipgetter']['dnslist']['list']['0'] = 'comsenz.com';
// Addon Setting
//$_config['addonsource'] = 'xx1';
//$_config['addon'] = array(
// 'xx1' => array(
// 'website_url' => 'http://127.0.0.1/AppCenter',
// 'download_url' => 'http://127.0.0.1/AppCenter/index.php',
// 'download_ip' => '',
// 'check_url' => 'http://127.0.0.1/AppCenter/?ac=check&file=',
// 'check_ip' => ''
// )
//);
?>

24
config/config_ucenter.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
define('UC_CONNECT', 'mysql');
define('UC_STANDALONE', 0);
define('UC_DBHOST', 'localhost');
define('UC_DBUSER', 'discuzuser');
define('UC_DBPW', 'Zht20000418?');
define('UC_DBNAME', 'discuz');
define('UC_DBCHARSET', 'utf8mb4');
define('UC_DBTABLEPRE', '`discuz`.pre_ucenter_');
define('UC_DBCONNECT', 0);
define('UC_AVTURL', '');
define('UC_AVTPATH', '');
define('UC_CHARSET', 'utf-8');
define('UC_KEY', 'ec685982r273EdT4RaReHar6q3C1877dE5tdKeObudH913iaC0V4V630m6X57bmb');
define('UC_API', 'http://localhost:8080/discuz/uc_server');
define('UC_APPID', '1');
define('UC_IP', '');
define('UC_PPP', 20);
?>

View File

@@ -0,0 +1,36 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: config_ucenter_default.php 11023 2010-05-20 02:23:09Z monkey $
*/
// ============================================================================
define('UC_CONNECT', 'mysql'); // 连接 UCenter 的方式: mysql/NULL, 默认为空时为 fscoketopen(), mysql 是直接连接的数据库, 为了效率, 建议采用 mysql
define('UC_STANDALONE', 1); // 独立模式开关0=关闭, 1=打开开启后将不再依赖UCenter Server。注意开启时必须将 UC_CONNECT 改为 mysql
// 数据库相关 (mysql 连接时)
define('UC_DBHOST', 'localhost'); // UCenter 数据库主机
define('UC_DBUSER', 'root'); // UCenter 数据库用户名
define('UC_DBPW', 'root'); // UCenter 数据库密码
define('UC_DBNAME', 'ucenter'); // UCenter 数据库名称
define('UC_DBCHARSET', 'utf8mb4'); // UCenter 数据库字符集
define('UC_DBTABLEPRE', '`ucenter`.uc_'); // UCenter 数据库表前缀
define('UC_DBCONNECT', '0'); // UCenter 数据库持久连接 0=关闭, 1=打开
// 头像相关
define('UC_AVTURL', ''); // 头像服务的基础路径,为空则为默认值,可以设置为独立域名/路径(结尾不能有/配合CDN使用更佳。如涉及 avatar.php 需在其中再配置一次。
define('UC_AVTPATH', ''); // 头像存储路径,为空则为默认值,仅限独立模式使用,建议保持默认。
// 通信相关
define('UC_KEY', 'yeN3g9EbNfiaYfodV63dI1j8Fbk5HaL7W4yaW4y7u2j4Mf45mfg2v899g451k576'); // 与 UCenter 的通信密钥, 要与 UCenter 保持一致
define('UC_API', 'http://localhost/ucenter/branches/1.5.0/server'); // UCenter 的 URL 地址, 在调用头像时依赖此常量
define('UC_CHARSET', 'utf-8'); // UCenter 的字符集
define('UC_IP', '127.0.0.1'); // UCenter 的 IP, 当 UC_CONNECT 为非 mysql 方式时, 并且当前应用服务器解析域名有问题时, 请设置此值
define('UC_APPID', '1'); // 当前应用的 ID
// ============================================================================
define('UC_PPP', '20');
?>

1
config/index.htm Normal file
View File

@@ -0,0 +1 @@

43
connect.php Normal file
View File

@@ -0,0 +1,43 @@
<?php
/*
[Discuz!] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: connect.php 26424 2011-12-13 03:02:20Z zhouxiaobo $
*/
if(isset($_GET['mod']) && $_GET['mod'] == 'register') {
$_GET['mod'] = 'connect';
$_GET['action'] = 'register';
require_once 'member.php';
exit;
}
define('APPTYPEID', 126);
define('CURSCRIPT', 'connect');
define('NOT_IN_MOBILE_API', 1);
require_once './source/class/class_core.php';
require_once './source/function/function_home.php';
$discuz = C::app();
$mod = $discuz->var['mod'];
$discuz->init();
if(!in_array($mod, array('config', 'login', 'feed', 'check', 'user'))) {
showmessage('undefined_action');
}
if(!$_G['setting']['connect']['allow']) {
showmessage('qqconnect:qqconnect_closed');
}
define('CURMODULE', $mod);
runhooks();
require_once DISCUZ_ROOT.'/source/plugin/qqconnect/lib/Connect.php';
$connectService = new Cloud_Service_Connect();
require_once libfile('connect/'.$mod, 'plugin/qqconnect');
?>

4
crossdomain.xml Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

73
forum.php Normal file
View File

@@ -0,0 +1,73 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum.php 33828 2013-08-20 02:29:32Z nemohou $
*/
define('APPTYPEID', 2);
define('CURSCRIPT', 'forum');
require './source/class/class_core.php';
require './source/function/function_forum.php';
$modarray = array('ajax','announcement','attachment','forumdisplay',
'group','image','index','misc','modcp','post','redirect',
'rss','topicadmin','trade','viewthread','tag','collection','guide'
);
$modcachelist = array(
'index' => array('announcements', 'onlinelist', 'forumlinks',
'heats', 'historyposts', 'onlinerecord', 'userstats', 'diytemplatenameforum'),
'forumdisplay' => array('smilies', 'announcements_forum', 'globalstick', 'forums',
'onlinelist', 'forumstick', 'threadtable_info', 'threadtableids', 'stamps', 'diytemplatenameforum'),
'viewthread' => array('smilies', 'smileytypes', 'forums', 'usergroups',
'stamps', 'bbcodes', 'smilies', 'custominfo', 'groupicon', 'stamps',
'threadtableids', 'threadtable_info', 'posttable_info', 'diytemplatenameforum'),
'redirect' => array('threadtableids', 'threadtable_info', 'posttable_info'),
'post' => array('bbcodes_display', 'bbcodes', 'smileycodes', 'smilies', 'smileytypes',
'domainwhitelist', 'albumcategory'),
'space' => array('fields_required', 'fields_optional', 'custominfo'),
'group' => array('grouptype', 'diytemplatenamegroup'),
'topicadmin' => array('usergroups'),
);
$mod = !in_array(C::app()->var['mod'], $modarray) ? 'index' : C::app()->var['mod'];
define('CURMODULE', $mod);
$cachelist = array();
if(isset($modcachelist[CURMODULE])) {
$cachelist = $modcachelist[CURMODULE];
$cachelist[] = 'plugin';
$cachelist[] = 'pluginlanguage_system';
}
if(C::app()->var['mod'] == 'group') {
$_G['basescript'] = 'group';
}
C::app()->cachelist = $cachelist;
C::app()->init();
loadforum();
set_rssauth();
runhooks();
if(!$_G['setting']['forumstatus'] && !in_array($mod, array('ajax', 'misc', 'modcp'))) {
showmessage('forum_status_off');
}
$navtitle = str_replace('{bbname}', $_G['setting']['bbname'], $_G['setting']['seotitle']['forum']);
$_G['setting']['threadhidethreshold'] = 1;
require DISCUZ_ROOT.'./source/module/forum/forum_'.$mod.'.php';
?>

37
group.php Normal file
View File

@@ -0,0 +1,37 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: group.php 31307 2012-08-10 02:10:56Z zhengqingpeng $
*/
define('APPTYPEID', 3);
define('CURSCRIPT', 'group');
require './source/class/class_core.php';
$discuz = C::app();
$cachelist = array('grouptype', 'groupindex', 'diytemplatenamegroup');
$discuz->cachelist = $cachelist;
$discuz->init();
$_G['disabledwidthauto'] = 0;
$modarray = array('index', 'my', 'attentiongroup');
$mod = !in_array($_G['mod'], $modarray) ? 'index' : $_G['mod'];
define('CURMODULE', $mod);
runhooks();
if(!$_G['setting']['groupstatus']) {
showmessage('group_module_status_off');
}
$navtitle = str_replace('{bbname}', $_G['setting']['bbname'], $_G['setting']['seotitle']['group']);
require DISCUZ_ROOT.'./source/module/group/group_'.$mod.'.php';
?>

44
home.php Normal file
View File

@@ -0,0 +1,44 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: home.php 32932 2013-03-25 06:53:01Z zhangguosheng $
*/
define('APPTYPEID', 1);
define('CURSCRIPT', 'home');
if(!empty($_GET['mod']) && ($_GET['mod'] == 'misc' || $_GET['mod'] == 'invite')) {
define('ALLOWGUEST', 1);
}
require_once './source/class/class_core.php';
require_once './source/function/function_home.php';
$discuz = C::app();
$cachelist = array('magic','usergroups', 'diytemplatenamehome');
$discuz->cachelist = $cachelist;
$discuz->init();
$space = array();
$mod = getgpc('mod');
if(!in_array($mod, array('space', 'spacecp', 'misc', 'magic', 'editor', 'invite', 'task', 'medal', 'rss', 'follow'))) {
$mod = 'space';
$_GET['do'] = $_G['setting']['feedstatus'] ? 'home' : 'profile';
}
if($mod == 'space' && ((empty($_GET['do']) || $_GET['do'] == 'index') && ($_G['inajax']))) {
$_GET['do'] = 'profile';
}
$curmod = !empty($_G['setting']['followstatus']) && (empty($_GET['diy']) && empty($_GET['do']) && $mod == 'space' || $_GET['do'] == 'follow') ? 'follow' : $mod;
define('CURMODULE', $curmod);
runhooks(getgpc('do') == 'profile' && $_G['inajax'] ? 'card' : getgpc('do'));
require_once libfile('home/'.$mod, 'module');
?>

191
index.php Normal file
View File

@@ -0,0 +1,191 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: index.php 34524 2014-05-15 04:42:23Z nemohou $
*/
if(version_compare(PHP_VERSION, '9.0.0', '>=')) {
exit('This version of Discuz! is not compatible with >= PHP 9.0, Please install or update to higher version.');
}
if(!empty($_SERVER['QUERY_STRING']) && is_numeric($_SERVER['QUERY_STRING'])) {
$_ENV['curapp'] = 'home';
$_GET = array('mod'=>'space', 'uid'=>$_SERVER['QUERY_STRING']);
} else {
$url = '';
$domain = $_ENV = array();
$jump = false;
@include_once './data/sysdata/cache_domain.php';
$_ENV['domain'] = $domain;
if(empty($_ENV['domain'])) {
$_ENV['curapp'] = 'forum';
} else {
$_ENV['defaultapp'] = array('portal.php' => 'portal', 'forum.php' => 'forum', 'group.php' => 'group', 'home.php' => 'home');
$_ENV['hostarr'] = explode('.', $_SERVER['HTTP_HOST']);
$_ENV['domainroot'] = substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.')+1);
if(!empty($_ENV['domain']['app']) && is_array($_ENV['domain']['app']) && in_array($_SERVER['HTTP_HOST'], $_ENV['domain']['app'])) {
$_ENV['curapp'] = array_search($_SERVER['HTTP_HOST'], $_ENV['domain']['app']);
if($_ENV['curapp'] == 'mobile') {
$_ENV['curapp'] = 'forum';
if(!isset($_GET['mobile'])) {
@$_GET['mobile'] = '2';
}
}
if($_ENV['curapp'] == 'default' || !isset($_ENV['defaultapp'][$_ENV['curapp'].'.php'])) {
$_ENV['curapp'] = '';
}
} elseif(!empty($_ENV['domain']['root']) && is_array($_ENV['domain']['root']) && in_array($_ENV['domainroot'], $_ENV['domain']['root'])) {
$_G['setting']['holddomain'] = $_ENV['domain']['holddomain'] ? $_ENV['domain']['holddomain'] : array('www');
$list = $_ENV['domain']['list'];
if(isset($list[$_SERVER['HTTP_HOST']])) {
$domain = $list[$_SERVER['HTTP_HOST']];
switch($domain['idtype']) {
case 'subarea':
$_ENV['curapp'] = 'forum';
$_GET['gid'] = intval($domain['id']);
break;
case 'forum':
$_ENV['curapp'] = 'forum';
$_GET['mod'] = 'forumdisplay';
$_GET['fid'] = intval($domain['id']);
break;
case 'topic':
$_ENV['curapp'] = 'portal';
$_GET['mod'] = 'topic';
$_GET['topicid'] = intval($domain['id']);
break;
case 'channel':
$_ENV['curapp'] = 'portal';
$_GET['mod'] = 'list';
$_GET['catid'] = intval($domain['id']);
break;
case 'plugin':
$_ENV['curapp'] = 'plugin';
$_GET['id'] = $domain['id'];
$_GET['fromapp'] = 'index';
break;
}
} elseif(count($_ENV['hostarr']) > 2 && $_ENV['hostarr'][0] != 'www' && !checkholddomain($_ENV['hostarr'][0])) {
$_ENV['prefixdomain'] = addslashes($_ENV['hostarr'][0]);
$_ENV['domainroot'] = addslashes($_ENV['domainroot']);
require_once './source/class/class_core.php';
C::app()->init_setting = true;
C::app()->init_user = false;
C::app()->init_session = false;
C::app()->init_cron = false;
C::app()->init_misc = false;
C::app()->init();
$jump = true;
$domain = C::t('common_domain')->fetch_by_domain_domainroot($_ENV['prefixdomain'], $_ENV['domainroot']);
$apphost = $_ENV['domain']['app'][$domain['idtype']] ? $_ENV['domain']['app'][$domain['idtype']] : $_ENV['domain']['app']['default'];
$apphost = $apphost ? $_G['scheme'].'://'.$apphost.'/' : '';
switch($domain['idtype']) {
case 'home':
if($_G['setting']['rewritestatus'] && is_array($_G['setting']['rewritestatus']) && in_array('home_space', $_G['setting']['rewritestatus'])) {
$url = rewriteoutput('home_space', 1, $apphost, $domain['id']);
} else {
$url = $apphost.'home.php?mod=space&uid='.$domain['id'];
}
break;
case 'group':
if($_G['setting']['rewritestatus'] && is_array($_G['setting']['rewritestatus']) && in_array('group_group', $_G['setting']['rewritestatus'])) {
$url = rewriteoutput('group_group', 1, $apphost, $domain['id']);
} else {
$url = $apphost.'forum.php?mod=group&fid='.$domain['id'].'&page=1';
}
break;
}
}
} else {
$jump = true;
}
if(empty($url) && empty($_ENV['curapp'])) {
if(!empty($_ENV['domain']['defaultindex']) && !$jump) {
if(!empty($_ENV['defaultapp'][$_ENV['domain']['defaultindex']])) {
$_ENV['curapp'] = $_ENV['defaultapp'][$_ENV['domain']['defaultindex']];
} else {
$url = $_ENV['domain']['defaultindex'];
}
} else {
if($jump) {
$url = empty($_ENV['domain']['app']['default']) ? (!empty($_ENV['domain']['defaultindex']) ? $_ENV['domain']['defaultindex'] : 'forum.php') : (is_https() ? 'https' : 'http').'://'.$_ENV['domain']['app']['default'];
} else {
$_ENV['curapp'] = 'forum';
}
}
}
}
}
if(!empty($url)) {
$delimiter = strrpos($url, '?') ? '&' : '?';
if(isset($_GET['fromuid']) && $_GET['fromuid']) {
$url .= sprintf('%sfromuid=%d', $delimiter, $_GET['fromuid']);
} elseif(isset($_GET['fromuser']) && $_GET['fromuser']) {
$url .= sprintf('%sfromuser=%s', $delimiter, rawurlencode($_GET['fromuser']));
}
$parse = parse_url($url);
if(!isset($parse['host']) && file_exists($parse['path']) && preg_match("/^[\w-]+\.php$/i", $parse['path'])) {
if(!empty($parse['query'])) {
parse_str($parse['query'], $_GET);
}
require './'.$parse['path'];
} else {
header("location: $url");
}
} else {
if(preg_match("/^[\w-]+$/i", $_ENV['curapp'])) {
require './'.$_ENV['curapp'].'.php';
} else {
header('location: ./'.$_ENV['curapp'].'.php');
}
}
function checkholddomain($domain) {
global $_G;
$domain = strtolower($domain);
if(preg_match("/^[^a-z]/i", $domain)) return true;
$holdmainarr = empty($_G['setting']['holddomain']) ? array('www') : explode('|', $_G['setting']['holddomain']);
$ishold = false;
foreach ($holdmainarr as $value) {
if(strpos($value, '*') === false) {
if(strtolower($value) == $domain) {
$ishold = true;
break;
}
} else {
$value = str_replace('*', '.*?', $value);
if(@preg_match("/$value/i", $domain)) {
$ishold = true;
break;
}
}
}
return $ishold;
}
function is_https() {
if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') {
return true;
}
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') {
return true;
}
if(isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https') {
return true;
}
if(isset($_SERVER['HTTP_FROM_HTTPS']) && strtolower($_SERVER['HTTP_FROM_HTTPS']) != 'off') {
return true;
}
if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) {
return true;
}
return false;
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,208 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<item id="spacecss"><![CDATA[#portal_block_1 .dxb_bc {margin-left:0px !important;}#portal_block_2 .dxb_bc {font-size:14px !important;margin-left:10px !important;}]]></item>
<item id="layoutdata">
<item id="diy1"><![CDATA[]]></item>
<item id="diycontenttop"><![CDATA[]]></item>
<item id="diy5">
<item id="frame`framez4HEbL">
<item id="attr">
<item id="name"><![CDATA[framez4HEbL]]></item>
<item id="moveable"><![CDATA[true]]></item>
<item id="className"><![CDATA[frame move-span cl frame-1-1]]></item>
<item id="titles"><![CDATA[]]></item>
</item>
<item id="column`framez4HEbL_left">
<item id="attr">
<item id="name"><![CDATA[framez4HEbL_left]]></item>
<item id="className"><![CDATA[column frame-1-1-l]]></item>
</item>
<item id="block`portal_block_1">
<item id="attr">
<item id="name"><![CDATA[portal_block_1]]></item>
<item id="className"><![CDATA[block move-span]]></item>
<item id="titles"><![CDATA[]]></item>
</item>
</item>
</item>
<item id="column`framez4HEbL_center">
<item id="attr">
<item id="name"><![CDATA[framez4HEbL_center]]></item>
<item id="className"><![CDATA[column frame-1-1-r]]></item>
</item>
<item id="block`portal_block_2">
<item id="attr">
<item id="name"><![CDATA[portal_block_2]]></item>
<item id="className"><![CDATA[block move-span]]></item>
<item id="titles"><![CDATA[]]></item>
</item>
</item>
</item>
</item>
</item>
<item id="diycommendtop"><![CDATA[]]></item>
<item id="diycategorytop"><![CDATA[]]></item>
<item id="diycontentbottom"><![CDATA[]]></item>
<item id="diysidetop"><![CDATA[]]></item>
<item id="diysidemiddle"><![CDATA[]]></item>
<item id="diysidebottom"><![CDATA[]]></item>
<item id="diy4"><![CDATA[]]></item>
</item>
<item id="style"><![CDATA[]]></item>
<item id="blockdata">
<item id="block">
<item id="1">
<item id="bid"><![CDATA[1]]></item>
<item id="blockclass"><![CDATA[group_thread]]></item>
<item id="blocktype"><![CDATA[0]]></item>
<item id="name"><![CDATA[]]></item>
<item id="title"><![CDATA[]]></item>
<item id="classname"><![CDATA[]]></item>
<item id="summary"><![CDATA[]]></item>
<item id="uid"><![CDATA[1]]></item>
<item id="username"><![CDATA[admin]]></item>
<item id="styleid"><![CDATA[0]]></item>
<item id="blockstyle">
<item id="name"><![CDATA[]]></item>
<item id="blockclass"><![CDATA[group_thread]]></item>
<item id="makethumb"><![CDATA[1]]></item>
<item id="getpic"><![CDATA[1]]></item>
<item id="getsummary"><![CDATA[0]]></item>
<item id="settarget"><![CDATA[1]]></item>
<item id="fields">
<item id="0"><![CDATA[url]]></item>
<item id="1"><![CDATA[pic]]></item>
<item id="2"><![CDATA[title]]></item>
</item>
<item id="template">
<item id="raw"><![CDATA[<div class="module cl slidebox">
<ul class="slideshow">
[loop]
<li style="width: {picwidth}px; height: {picheight}px;"><a href="{url}"{target}><img src="{pic}" width="{picwidth}" height="{picheight}" /></a><span class="title">{title}</span></li>
[/loop]
</ul>
</div>
<script type="text/javascript">
runslideshow();
</script>]]></item>
<item id="footer"><![CDATA[]]></item>
<item id="header"><![CDATA[]]></item>
<item id="indexplus">
</item>
<item id="index">
</item>
<item id="orderplus">
</item>
<item id="order">
</item>
<item id="loopplus">
</item>
<item id="loop"><![CDATA[<li style="width: {picwidth}px; height: {picheight}px;"><a href="{url}"{target}><img src="{pic}" width="{picwidth}" height="{picheight}" /></a><span class="title">{title}</span></li>]]></item>
</item>
<item id="hash"><![CDATA[7af6727c]]></item>
</item>
<item id="picwidth"><![CDATA[339]]></item>
<item id="picheight"><![CDATA[215]]></item>
<item id="target"><![CDATA[blank]]></item>
<item id="dateformat"><![CDATA[Y-m-d]]></item>
<item id="dateuformat"><![CDATA[0]]></item>
<item id="script"><![CDATA[groupthread]]></item>
<item id="param">
<item id="gtids">
<item id="0"><![CDATA[0]]></item>
</item>
<item id="rewardstatus"><![CDATA[0]]></item>
<item id="titlelength"><![CDATA[40]]></item>
<item id="summarylength"><![CDATA[80]]></item>
<item id="startrow"><![CDATA[0]]></item>
<item id="items"><![CDATA[4]]></item>
<item id="special">
<item id="0"><![CDATA[0]]></item>
</item>
<item id="picrequired"><![CDATA[1]]></item>
</item>
<item id="shownum"><![CDATA[4]]></item>
<item id="cachetime"><![CDATA[0]]></item>
<item id="punctualupdate"><![CDATA[0]]></item>
<item id="hidedisplay"><![CDATA[0]]></item>
<item id="dateline"><![CDATA[1308275841]]></item>
<item id="notinherited"><![CDATA[0]]></item>
<item id="isblank"><![CDATA[0]]></item>
</item>
<item id="2">
<item id="bid"><![CDATA[2]]></item>
<item id="blockclass"><![CDATA[group_thread]]></item>
<item id="blocktype"><![CDATA[0]]></item>
<item id="name"><![CDATA[]]></item>
<item id="title"><![CDATA[]]></item>
<item id="classname"><![CDATA[]]></item>
<item id="summary"><![CDATA[]]></item>
<item id="uid"><![CDATA[1]]></item>
<item id="username"><![CDATA[admin]]></item>
<item id="styleid"><![CDATA[24]]></item>
<item id="blockstyle"><![CDATA[]]></item>
<item id="picwidth"><![CDATA[0]]></item>
<item id="picheight"><![CDATA[0]]></item>
<item id="target"><![CDATA[blank]]></item>
<item id="dateformat"><![CDATA[Y-m-d]]></item>
<item id="dateuformat"><![CDATA[0]]></item>
<item id="script"><![CDATA[groupthreadspecial]]></item>
<item id="param">
<item id="gtids">
<item id="0"><![CDATA[0]]></item>
</item>
<item id="rewardstatus"><![CDATA[0]]></item>
<item id="picrequired"><![CDATA[0]]></item>
<item id="titlelength"><![CDATA[40]]></item>
<item id="summarylength"><![CDATA[80]]></item>
<item id="items"><![CDATA[10]]></item>
</item>
<item id="shownum"><![CDATA[10]]></item>
<item id="cachetime"><![CDATA[3600]]></item>
<item id="punctualupdate"><![CDATA[0]]></item>
<item id="hidedisplay"><![CDATA[0]]></item>
<item id="dateline"><![CDATA[1308275761]]></item>
<item id="notinherited"><![CDATA[0]]></item>
<item id="isblank"><![CDATA[0]]></item>
</item>
</item>
<item id="style">
<item id="24">
<item id="styleid"><![CDATA[24]]></item>
<item id="blockclass"><![CDATA[group_thread]]></item>
<item id="name"><![CDATA[[内置]文章标题]]></item>
<item id="template">
<item id="raw"><![CDATA[<div class="module cl xl xl1">
<ul>
[loop]
<li><a href="{url}" title="{title}"{target}>{title}</a></li>
[/loop]
</ul>
</div>]]></item>
<item id="footer"><![CDATA[]]></item>
<item id="header"><![CDATA[]]></item>
<item id="indexplus">
</item>
<item id="index">
</item>
<item id="orderplus">
</item>
<item id="order">
</item>
<item id="loopplus">
</item>
<item id="loop"><![CDATA[<li><a href="{url}" title="{title}"{target}>{title}</a></li>]]></item>
</item>
<item id="hash"><![CDATA[176fcc68]]></item>
<item id="getpic"><![CDATA[0]]></item>
<item id="getsummary"><![CDATA[0]]></item>
<item id="makethumb"><![CDATA[0]]></item>
<item id="settarget"><![CDATA[1]]></item>
<item id="fields">
<item id="0"><![CDATA[url]]></item>
<item id="1"><![CDATA[title]]></item>
</item>
</item>
</item>
</item>
</root>

0
install/data/index.htm Normal file
View File

4161
install/data/install.sql Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

View File

@@ -0,0 +1,49 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: install_extvar.php 31245 2012-07-31 02:54:24Z liulanbo $
*/
if(!defined('IN_COMSENZ')) {
exit('Access Denied');
}
$settings = array(
'extcredits' => array(
1 => array('title' => $lang['init_credits_money'], 'ratio' => 0, 'available' => 1),
2 => array('title' => $lang['init_credits_karma'], 'ratio' => 0, 'available' => 1),
),
'postnocustom' => array(
0 => $lang['init_postno0'], 1 => $lang['init_postno1'], 2 => $lang['init_postno2'], 3 => $lang['init_postno3']
),
'recommendthread' => array(
'status' => '1',
'addtext' => $lang['init_support'],
'subtracttext' => $lang['init_opposition'],
'defaultshow' => '1',
'daycount' => '0',
'ownthread' => '0',
'iconlevels' => '0,100,200',
),
'tasktypes' => array(
'promotion' => array(
'name' => $lang['init_promotion_task'],
'version' => '1.0',
),
'gift' => array(
'name' => $lang['init_gift_task'],
'version' => '1.0',
),
'avatar' => array(
'name' => $lang['init_avatar_task'],
'version' => '1.0',
),
),
);
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,389 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: install_lang.php 36287 2016-12-12 03:59:05Z nemohou $
*/
if(!defined('IN_COMSENZ')) {
exit('Access Denied');
}
define('UC_VERNAME', '中文版');
$lang = array(
'SC_UTF8' => '简体中文 UTF8 版',
'TC_UTF8' => '繁体中文 UTF8 版',
'title_install' => SOFT_NAME.' 安装向导',
'agreement_yes' => '同意',
'agreement_no' => '取消',
'notset' => '不限制',
'enable' => '开启',
'disable' => '关闭',
'message_title' => '提示信息',
'error_message' => '错误信息',
'message_return' => '返回',
'return' => '返回',
'install_wizard' => '安装向导',
'config_nonexistence' => '配置文件不存在',
'nodir' => '目录不存在',
'redirect' => '浏览器会自动跳转页面,无需人工干预。<br>除非当您的浏览器没有自动跳转时,请点击这里',
'auto_redirect' => '浏览器会自动跳转页面,无需人工干预',
'database_errno_1064' => 'SQL 语法错误',
'dbpriv_createtable' => '没有CREATE TABLE权限无法继续安装',
'dbpriv_insert' => '没有INSERT权限无法继续安装',
'dbpriv_select' => '没有SELECT权限无法继续安装',
'dbpriv_update' => '没有UPDATE权限无法继续安装',
'dbpriv_delete' => '没有DELETE权限无法继续安装',
'dbpriv_droptable' => '没有DROP TABLE权限无法安装',
'db_not_null' => '数据库中已经安装过 UCenter, 继续安装会清空原有数据。',
'db_drop_table_confirm' => '继续安装会清空全部原有数据,您确定要继续吗?',
'writeable' => '可写',
'unwriteable' => '不可写',
'old_step' => '上一步',
'new_step' => '下一步',
'database_errno_2003' => '无法连接数据库,请检查数据库是否启动,数据库服务器地址是否正确',
'database_errno_1044' => '无法创建新的数据库,请检查数据库名称填写是否正确',
'database_errno_1045' => '无法连接数据库,请检查数据库用户名或者密码是否正确',
'database_connect_error' => '数据库连接错误',
'run_sql_error' => 'Discuz! Database Error',
'step_title_1' => '检查安装环境',
'step_title_2' => '设置运行环境',
'step_title_3' => '创建数据库',
'step_title_4' => '安装',
'step_env_check_title' => '开始安装',
'step_env_check_desc' => '环境以及文件目录权限检查',
'step_db_init_title' => '安装数据库',
'step_db_init_desc' => '正在执行数据库安装',
'step1_file' => '目录文件',
'step1_need_status' => '所需状态',
'step1_status' => '当前状态',
'not_continue' => '请将以上红叉部分修正再试',
'tips_dbinfo' => '填写数据库信息',
'tips_dbinfo_comment' => '',
'tips_admininfo' => '填写管理员信息',
'step_ext_info_title' => '安装成功。',
'step_ext_info_comment' => '点击进入登录',
'ext_info_succ' => '安装成功。',
'install_submit' => '提交',
'install_locked' => '安装锁定,已经安装过了,如果您确定要重新安装,请到服务器上删除<br /> '.str_replace(ROOT_PATH, '', $lockfile),
'error_stuck_msg' => '安装进程已经很久没有进展了,可能相关请求已经因网络超时或服务器严重错误而异常退出',
'error_quit_msg' => '您必须解决以上问题,安装才可以继续',
'error_reinstall_msg' => '您的数据库可能InnoDB性能不佳请调高PHP超时时间刷新页面尝试重新安装',
'step_app_reg_title' => '设置运行环境',
'step_app_reg_desc' => '检测服务器环境以及设置 UCenter',
'tips_ucenter' => '请填写 UCenter 相关信息',
'tips_ucenter_comment' => 'UCenter 是 Comsenz 公司产品的核心服务程序Discuz! Board 的安装和运行依赖此程序。如果您已经安装了 UCenter请填写以下信息。否则请到 <a href="https://www.discuz.vip/" target="blank">Comsenz 产品中心</a> 下载并且安装,然后再继续。',
'advice_mysqli_connect' => '请检查 mysqli 模块是否正确加载',
'advice_xml_parser_create' => '该函数需要 PHP 支持 XML 。请联系服务商,确定开启了此项功能',
'advice_json_encode' => '该函数需要 PHP 支持 JSON 。请联系服务商,确定开启了此项功能',
'advice_dns_get_record' => '该函数需要 PHP 支持 DNS 查询PHP 默认自带。错误的编译安装或缺少组件等原因容易引起此问题。请联系服务商,确定开启了此项功能',
'advice_fsockopen' => '该函数需要 php.ini 中 allow_url_fopen 选项开启。请联系服务商,确定开启了此项功能',
'advice_pfsockopen' => '该函数需要 php.ini 中 allow_url_fopen 选项开启。请联系服务商,确定开启了此项功能',
'advice_stream_socket_client' => '该函数需要 php.ini 中 stream_socket_client 函数开启。请联系服务商,确定开启了此项功能',
'advice_curl_init' => '该函数需要 php.ini 中 curl_init 函数开启。请联系服务商,确定开启了此项功能',
'ucurl' => 'UCenter 的 URL',
'ucpw' => 'UCenter 创始人密码',
'ucip' => 'UCenter 的 IP 地址',
'ucenter_ucip_invalid' => '格式错误,请填写正确的 IP 地址',
'ucip_comment' => '绝大多数情况下您可以不填',
'tips_siteinfo' => '请填写站点信息',
'sitename' => '站点名称',
'siteurl' => '站点 URL',
'forceinstall' => '强制安装',
'dbinfo_forceinstall_invalid' => '当前数据库当中已经含有同样表前缀的数据表,您可以修改“表名前缀”来避免删除旧的数据,或者选择强制安装。强制安装会删除旧数据,且无法恢复',
'dbinfo_myisam2innodb_invalid' => 'InnoDB性能不佳安装超时失败的可以尝试这种方式强制安装',
'click_to_back' => '点击返回上一步',
'adminemail' => '系统信箱 Email',
'adminemail_comment' => '用于发送程序错误报告',
'dbhost_comment' => '一般为 127.0.0.1 或 localhost',
'dbname_comment' => '用于安装 Discuz! 的数据库',
'dbuser_comment' => '您的数据库用户名',
'dbpw_comment' => '您的数据库密码',
'tablepre_comment' => '同一数据库运行多个论坛时,请修改前缀',
'forceinstall_check_label' => '我要删除数据,强制安装 !!!',
'myisam2innodb_check_label' => '以MyISAM方式安装再转换为InnoDB',
'initdbresult_succ' => '数据库表创建完成',
'initdbdataresult_succ' => '数据库数据初始化完成',
'initdbinnodbresult_succ' => 'InnoDB数据表转换完成',
'initsys' => '正在系统初始化',
'uc_url_empty' => '您没有填写 UCenter 的 URL请返回填写',
'uc_url_invalid' => 'URL 格式错误',
'uc_url_unreachable' => 'UCenter 的 URL 地址可能填写错误,可能原因有:<br />1. UCenter 路径不正确或状态异常<br />2. 应用查询 UCenter 状态请求无法发起或被拦截<br />3. UCenter 后台 “ 通过 URL 添加应用功能 ” 未开启',
'uc_ip_invalid' => '无法解析该域名,请填写站点的 IP',
'uc_admin_invalid' => 'UCenter 创始人密码校验未通过, 可能原因有:<br />1. UCenter 创始人密码不正确<br />2. 多次错误输入密码导致创始人用户和 IP 地址被锁定<br />3. UCenter 后台 “ 通过 URL 添加应用功能 ” 未开启',
'uc_data_invalid' => '通信失败,请检查 UCenter 的URL 地址是否正确 ',
'uc_dbcharset_incorrect' => 'UCenter 数据库字符集与当前应用字符集不一致',
'uc_api_add_app_error' => '向 UCenter 添加应用错误',
'uc_dns_error' => 'UCenter DNS解析错误请返回填写一下 UCenter 的 IP地址',
'ucenter_ucurl_invalid' => 'UCenter 的URL为空或者格式错误请检查',
'ucenter_ucpw_invalid' => 'UCenter 的创始人密码为空,或者格式错误,请检查',
'siteinfo_siteurl_invalid' => '站点URL为空或者格式错误请检查',
'siteinfo_sitename_invalid' => '站点名称为空,或者格式错误,请检查',
'dbinfo_dbhost_invalid' => '数据库服务器为空,或者格式错误,请检查',
'dbinfo_dbname_invalid' => '数据库名为空,或者格式错误,请检查',
'dbinfo_dbuser_invalid' => '数据库用户名为空,或者格式错误,请检查',
'dbinfo_dbpw_invalid' => '数据库密码为空,或者格式错误,请检查',
'dbinfo_adminemail_invalid' => '系统邮箱为空,或者格式错误,请检查',
'dbinfo_tablepre_invalid' => '数据表前缀为空,或者格式错误,请检查',
'admininfo_username_invalid' => '管理员用户名为空,或者格式错误,请检查',
'admininfo_email_invalid' => '管理员Email为空或者格式错误请检查',
'admininfo_password_invalid' => '管理员密码为空,请填写',
'admininfo_password2_invalid' => '两次密码不一致,请检查',
'install_dzstandalone' => '<div class="selradio"><input type="radio" id="install_ucenter_standalone" name="install_ucenter" value="standalone" onclick="if(this.checked)$(\'form_items_2\').style.display=\'none\';" /><label for="install_ucenter_standalone">全新安装 Discuz! X (独立模式安装)</label></div>',
'install_dzfull' => '<div class="selradio"><input type="radio" id="install_ucenter_yes"'.(getgpc('install_ucenter') != 'no' ? ' checked="checked"' : '').' name="install_ucenter" value="yes" onclick="if(this.checked)$(\'form_items_2\').style.display=\'none\';" /><label for="install_ucenter_yes">全新安装 Discuz! X 与 UCenter Server</label></div>',
'install_dzonly' => '<div class="selradio"><input type="radio" id="install_ucenter_no"'.(getgpc('install_ucenter') == 'no' ? ' checked="checked"' : '').' name="install_ucenter" value="no" onclick="if(this.checked)$(\'form_items_2\').style.display=\'\';" /><label for="install_ucenter_no">仅安装 Discuz! X (连接到已经安装的 UCenter Server)</label></div>',
'username' => '管理员账号',
'email' => '管理员 Email',
'password' => '管理员密码',
'password_comment' => '管理员密码不能为空',
'password2' => '重复密码',
'admininfo_invalid' => '管理员信息不完整,请检查管理员账号,密码,邮箱',
'dbname_invalid' => '数据库名为空,请填写数据库名称',
'tablepre_invalid' => '数据表前缀为空,或者格式错误,请检查',
'admin_username_invalid' => '非法用户名,用户名长度不应当超过 15 个英文字符,且不能包含特殊字符,一般是中文,字母或者数字',
'admin_password_invalid' => '密码和上面不一致,请重新输入',
'admin_email_invalid' => 'Email 地址错误,此邮件地址已经被使用或者格式无效,请更换为其他地址',
'admin_invalid' => '您的信息管理员信息没有填写完整,请仔细填写每个项目',
'admin_exist_password_error' => '该用户已经存在,如果您要设置此用户为论坛的管理员,请正确输入该用户的密码,或者请更换论坛管理员的名字',
'tagtemplates_subject' => '标题',
'tagtemplates_uid' => '用户 ID',
'tagtemplates_username' => '发帖者',
'tagtemplates_dateline' => '日期',
'tagtemplates_url' => '主题地址',
'uc_version_incorrect' => '您的 UCenter 服务端版本过低,请升级 UCenter 服务端到最新版本并且升级下载地址https://www.discuz.vip/ 。',
'config_unwriteable' => '安装向导无法写入配置文件, 请设置 config.inc.php 程序属性为可写状态(777)',
'install_in_processed' => '正在安装...',
'install_succeed' => '安装成功,点击进入',
'init_credits_karma' => '威望',
'init_credits_money' => '金钱',
'init_postno0' => '楼主',
'init_postno1' => '沙发',
'init_postno2' => '板凳',
'init_postno3' => '地板',
'init_support' => '支持',
'init_opposition' => '反对',
'init_group_0' => '会员',
'init_group_1' => '管理员',
'init_group_2' => '超级版主',
'init_group_3' => '版主',
'init_group_4' => '禁止发言',
'init_group_5' => '禁止访问',
'init_group_6' => '禁止 IP',
'init_group_7' => '游客',
'init_group_8' => '等待验证会员',
'init_group_9' => '乞丐',
'init_group_10' => '新手上路',
'init_group_11' => '注册会员',
'init_group_12' => '中级会员',
'init_group_13' => '高级会员',
'init_group_14' => '金牌会员',
'init_group_15' => '论坛元老',
'init_rank_1' => '新生入学',
'init_rank_2' => '小试牛刀',
'init_rank_3' => '实习记者',
'init_rank_4' => '自由撰稿人',
'init_rank_5' => '特聘作家',
'init_cron_1' => '清空今日发帖数',
'init_cron_2' => '清空本月在线时间',
'init_cron_3' => '每日数据清理',
'init_cron_4' => '生日统计与邮件祝福',
'init_cron_5' => '主题回复通知',
'init_cron_6' => '每日公告清理',
'init_cron_7' => '限时操作清理',
'init_cron_8' => '论坛推广清理',
'init_cron_9' => '每月主题清理',
'init_cron_10' => '每日 X-Space更新用户',
'init_cron_11' => '每周主题更新',
'init_bbcode_1' => '使内容横向滚动,这个效果类似 HTML 的 marquee 标签,注意:这个效果只在 Internet Explorer 浏览器下有效。',
'init_bbcode_2' => '嵌入 Flash 动画',
'init_bbcode_3' => '显示 QQ 在线状态,点这个图标可以和他(她)聊天',
'init_bbcode_4' => '上标',
'init_bbcode_5' => '下标',
'init_bbcode_6' => '嵌入 Windows media 音频',
'init_bbcode_7' => '嵌入 Windows media 音频或视频',
'init_qihoo_searchboxtxt' =>'输入关键词,快速搜索本论坛',
'init_threadsticky' =>'全局置顶,分类置顶,本版置顶',
'init_default_style' => '默认风格',
'init_default_forum' => '默认版块',
'init_default_template' => '默认模板套系',
'init_default_template_copyright' => 'Discuz!',
'init_dataformat' => 'Y-n-j',
'init_modreasons' => '广告/SPAM\r\n恶意灌水\r\n违规内容\r\n文不对题\r\n重复发帖\r\n\r\n我很赞同\r\n精品文章\r\n原创内容',
'init_userreasons' => '很给力!\r\n神马都是浮云\r\n赞一个!\r\n山寨\r\n淡定',
'init_link' => 'Discuz! 官方论坛',
'init_link_note' => '提供最新 Discuz! 产品新闻、软件下载与技术交流',
'init_promotion_task' => '网站推广任务',
'init_gift_task' => '红包类任务',
'init_avatar_task' => '头像类任务',
'copyright' => '&copy; 2001-'.date('Y').' <a href="https://code.dismall.com/" target="_blank">Discuz! Team</a>.',
'license' => '
<div class="license"><h1>中文版授权协议 适用于中文用户</h1>
<p>版权所有 (c) 2001-'.date('Y').',腾讯云计算(北京)有限责任公司 保留所有权利。</p>
<p>感谢您选择腾讯云产品。希望我们的努力能为您提供一个高效快速、强大的站点解决方案,和强大的社区论坛解决方案。产品官方讨论社区网址为 https://www.dismall.com。产品官方应用中心网址为https://addon.dismall.com。开源代码网址为 https://code.dismall.com。</p>
<p>腾讯云产品的 Discuz! X 项目内所包含的官方应用中心由合肥贰道网络科技有限公司承接运营。Discuz! X 开源项目由合肥贰道网络科技有限公司承接维护Discuz! X 开源代码由项目开源管理委员会及社区开发者共同维护。除以上服务外,均由腾讯云提供服务。</p>
<p>用户须知:本协议是您与腾讯云公司之间关于您使用腾讯云公司提供的各种软件产品及服务的法律协议。无论您是个人或组织、盈利与否、用途如何(包括以学习和研究为目的),均需仔细阅读本协议,包括免除或者限制腾讯云责任的免责条款及对您的权利限制。请您审阅并接受或不接受本服务条款。如您不同意本服务条款及/或腾讯云随时对其的修改,您应不使用或主动取消腾讯云公司提供的腾讯云产品。否则,您的任何对腾讯云产品中的相关服务的注册、登陆、下载、查看等使用行为将被视为您对本服务条款全部的完全接受,包括接受腾讯云对服务条款随时所做的任何修改。</p>
<p>本服务条款一旦发生变更, 腾讯云将在网页上公布修改内容。修改后的服务条款一旦在网站管理后台上公布即有效代替原来的服务条款。您可随时登录开源代码网址查阅最新版服务条款。如果您选择接受本条款,即表示您同意接受协议各项条件的约束。如果您不同意本服务条款,则不能获得使用本服务的权利。您若有违反本条款规定,腾讯云公司有权随时中止或终止您对腾讯云产品的使用资格并保留追究相关法律责任的权利。</p>
<p>在理解、同意、并遵守本协议的全部条款后,方可开始使用腾讯云产品。您可能与腾讯云公司直接签订另一书面协议,以补充或者取代本协议的全部或者任何部分。</p>
<p>腾讯云拥有本软件的全部知识产权。本软件只供许可协议,并非出售。腾讯云只允许您在遵守本协议各项条款的情况下复制、下载、安装、使用或者以其他方式受益于本软件的功能或者知识产权。</p>
<h3>I. 协议许可的权利</h3>
<ol>
<li>您可以在完全遵守本许可协议的基础上,将本软件应用于非商业用途或商业用途使用(局限于本协议所适配许可的情况下),而不必支付软件版权许可费用。</li>
<li>您可以在协议规定的约束和限制范围内修改腾讯云产品源代码(如果被提供的话)或界面风格以适应您的网站要求。</li>
<li>您拥有使用本软件构建的网站中全部会员资料、文章及相关信息的所有权,并独立承担与使用本软件构建的网站内容的审核、注意义务,确保其不侵犯任何人的合法权益,独立承担因使用腾讯云软件和服务带来的全部责任,若造成腾讯云公司或用户损失的,您应予以全部赔偿。</li>
<li>若您需将腾讯云软件或服务用户商业用途必须遵守中国人民共和国相关法律。若需提供技术支持方式或技术支持内容请向官方https://www.discuz.vip/)获取技术支持服务。</li>
<li>您可以从腾讯云提供的应用中心服务中下载适合您网站的应用程序,但应向应用程序开发者/所有者支付相应的费用。</li>
</ol>
<h3>II. 协议规定的约束和限制</h3>
<ol>
<li>不得对本软件或与之关联的商业授权进行出租、出售、抵押或发放子许可证。</li>
<li>无论如何,即无论用途如何、是否经过修改或美化、修改程度如何,只要使用腾讯云产品的整体或任何部分,未经书面许可,页面页脚处的 Powered by Discuz! 及链接https://www.discuz.vip/和程序后台官方应用中心的链接https://addon.dismall.com都必须保留而不能清除或修改、替换。</li>
<li>禁止在腾讯云产品的整体或任何部分基础上以发展任何派生版本、修改版本或第三方版本用于重新分发。</li>
<li>您从应用中心下载的应用程序,未经应用程序开发者/所有者的书面许可,不得对其进行反向工程、反向汇编、反向编译等,不得擅自复制、修改、链接、转载、汇编、发表、出版、发展与之有关的衍生产品、作品等。</li>
<li>如果您未能遵守本协议的条款,您的授权将被终止,所许可的权利将被收回,同时您应承担相应法律责任。</li>
</ol>
<h3>III. 有限担保和免责声明</h3>
<ol>
<li>本软件及所附带的文件是作为不提供任何明确的或隐含的赔偿或担保的形式提供的。</li>
<li>用户出于自愿而使用本软件,您必须了解使用本软件的风险,我们不承诺提供任何形式的技术支持、使用担保,也不承担任何因使用本软件而产生问题的相关责任。</li>
<li>腾讯云公司不对使用本软件构建的网站中或者论坛中的文章或信息承担责任,全部责任由您自行承担。</li>
<li>官方应用中心无法全面监控由第三方上传至应用中心的应用程序,因此不保证应用程序的合法性、安全性、完整性、真实性或品质等;您从应用中心下载应用程序时,同意自行判断并承担所有风险,而不依赖于腾讯云公司及官方应用中心。但在任何情况下,官方应用中心有权依法停止应用中心服务并采取相应行动,包括但不限于对于相关应用程序进行卸载,暂停服务的全部或部分,保存有关记录,并向有关机关报告。由此对您及第三人可能造成的损失,腾讯云公司及官方应用中心不承担任何直接、间接或者连带的责任。</li>
<li>腾讯云公司对腾讯云提供的软件和服务之及时性、安全性、准确性不作担保,由于不可抗力因素、腾讯云公司无法控制的因素(包括黑客攻击、停断电等)等造成软件使用和服务中止或终止,而给您造成损失的,您同意放弃追究腾讯云公司责任的全部权利。 </li>
<li>腾讯云公司特别提请您注意,腾讯云公司为了保障公司业务发展和调整的自主权,腾讯云公司拥有随时经或未经事先通知而修改服务内容、中止或终止部分或全部软件使用和服务的权利,修改会公布于腾讯云公司网站相关页面上,一经公布视为通知。 腾讯云公司行使修改或中止、终止部分或全部软件使用和服务的权利而造成损失的,腾讯云公司不需对您或任何第三方负责。</li>
</ol>
<p>有关腾讯云产品最终用户授权协议、商业授权与技术服务的详细内容,均由腾讯云公司独家提供。腾讯云公司拥有在不事先通知的情况下,修改授权协议和服务价目表的权利,修改后的协议或价目表对自改变之日起的新授权用户生效。</p>
<p>一旦您开始安装腾讯云产品,即被视为完全理解并接受本协议的各项条款,在享有上述条款授予的权利的同时,受到相关的约束和限制。协议许可范围以外的行为,将直接违反本授权协议并构成侵权,我们有权随时终止授权,责令停止损害,并保留追究相关责任的权力。</p>
<p>本许可协议条款的解释,效力及纠纷的解决,适用于中华人民共和国大陆法律。</p>
<p>若您和腾讯云之间发生任何纠纷或争议,首先应友好协商解决,协商不成的,您在此完全同意将纠纷或争议提交腾讯云所在地北京市海淀区人民法院管辖。腾讯云公司拥有对以上各项条款内容的解释权及修改权。</p>
<p>(正文完)</p>
<p align="right">Discuz!</p>
</div>',
'php8_tips' => '您好,当前产品暂不支持 PHP 9 安装,请降级到至少 PHP 8.0 后再试!',
'no_utf8_tips' => '您好,您使用的版本为 GBK / BIG-5 等本地化编码版本,此版本已经不作为主推版本,如果您计划建设新站点【强烈】建议您使用最新正式 UTF-8 版本安装。',
'no_latest_tips' => '您好,您使用的版本较老,可能存在 Bug 以及安全隐患,如无特殊情况建议您改用最新正式 UTF-8 版本安装。',
'unstable_tips' => '您好,您使用的版本为非正式版本,可能存在未知的 Bug 或缺陷,如果您计划正式建站或购买插件建议您使用最新正式 UTF-8 版本安装。',
'next_tips' => '\r\n点击【确定】跳转到最新正式 UTF-8 版本下载页面,点击【取消】继续安装(不推荐)',
'uc_installed' => '您已经安装过 UCenter如果需要重新安装请删除 data/install.lock 文件',
'i_agree' => '我已仔细阅读,并同意上述条款中的所有内容',
'supportted' => '支持',
'unsupportted' => '不支持',
'max_size' => '支持/最大尺寸',
'project' => '项目',
'ucenter_required' => 'Discuz! 所需配置',
'ucenter_best' => 'Discuz! 最佳',
'curr_server' => '当前服务器',
'env_check' => '环境检查',
'os' => '操作系统',
'php' => 'PHP 版本',
'attachmentupload' => '附件上传',
'unlimit' => '不限制',
'version' => '版本',
'gdversion' => 'GD 库',
'allow' => '允许 ',
'unix' => '类Unix',
'diskspace' => '磁盘空间',
'opcache' => 'OPcache',
'curl' => 'cURL 库',
'priv_check' => '目录、文件权限检查',
'func_depend' => '函数依赖性检查',
'func_name' => '函数名称',
'check_result' => '检查结果',
'suggestion' => '建议',
'advice_mysqli' => '请检查 mysqli 模块是否正确加载',
'advice_fopen' => '该函数需要 php.ini 中 allow_url_fopen 选项开启。请联系服务商,确定开启了此项功能',
'advice_xml' => '该函数需要 PHP 支持 XML。请联系服务商确定开启了此项功能',
'none' => '无',
'undefine_func' => '不存在的函数',
'mysqli_unsupport' => '请检查 mysqli 模块是否正确加载',
'dbhost' => '数据库服务器地址',
'dbuser' => '数据库用户名',
'dbpw' => '数据库密码',
'dbname' => '数据库名',
'tablepre' => '数据表前缀',
'ucfounderpw' => '创始人密码',
'ucfounderpw2' => '重复创始人密码',
'clear_dir' => '清空目录',
'innodb' => 'InnoDB数据表转换',
'select_db' => '选择数据库',
'create_table' => '建立数据表',
'succeed' => '成功',
'failed' => '失败',
'init_table_data' => '正在初始化数据表中的数据',
'install_data' => '正在安装数据',
'install_test_data' => '正在安装附加数据',
'method_undefined' => '未定义方法',
'database_nonexistence' => '数据库操作对象不存在',
'skip_current' => '跳过本步',
'topic' => '专题',
'install_finish' => '站点安装完成,感谢您的支持!',
'install_finish_next' => '接下来您可以:',
'finish_btn_admin' => '进入管理后台',
'finish_btn_cloudaddon' => '安装插件模板',
'finish_btn_direct' => '直接访问站点',
);
$msglang = array(
'config_nonexistence' => '您的 config.inc.php 不存在, 无法继续安装, 请用 FTP 将该文件上传后再试。',
);
?>

View File

@@ -0,0 +1,145 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: install_mysql.php 6758 2010-03-25 09:05:10Z cnteacher $
*/
if(!defined('IN_COMSENZ')) {
exit('Access Denied');
}
class dbstuff {
var $querynum = 0;
var $link;
var $histories;
var $time;
var $tablepre;
function connect($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = '', $pconnect = 0, $tablepre='', $time = 0) {
$this->time = $time;
$this->tablepre = $tablepre;
mysqli_report(MYSQLI_REPORT_OFF);
$this->link = new mysqli();
if(!$this->link->real_connect($dbhost, $dbuser, $dbpw, $dbname, null, null, MYSQLI_CLIENT_COMPRESS)) {
$this->halt('Can not connect to MySQL server');
}
if (version_compare($this->version(), '5.5.3', '<')) {
$this->halt('MySQL version must be 5.5.3 or greater');
}
if($dbcharset) {
$this->link->set_charset($dbcharset);
}
$this->link->query("SET sql_mode=''");
$this->link->query("SET character_set_client=binary");
}
function fetch_array($query, $result_type = MYSQLI_ASSOC) {
return $query ? $query->fetch_array($result_type) : null;
}
function result_first($sql, &$data) {
$query = $this->query($sql);
$data = $this->result($query, 0);
}
function fetch_first($sql, &$arr) {
$query = $this->query($sql);
$arr = $this->fetch_array($query);
}
function fetch_all($sql, &$arr) {
$query = $this->query($sql);
while($data = $this->fetch_array($query)) {
$arr[] = $data;
}
}
function cache_gc() {
$this->query("DELETE FROM {$this->tablepre}sqlcaches WHERE expiry<$this->time");
}
function query($sql, $type = '', $cachetime = FALSE) {
$resultmode = $type == 'UNBUFFERED' ? MYSQLI_USE_RESULT : MYSQLI_STORE_RESULT;
if(!($query = $this->link->query($sql, $resultmode)) && $type != 'SILENT') {
$this->halt('SQL:', $sql);
}
$this->querynum++;
$this->histories[] = $sql;
return $query;
}
function affected_rows() {
return $this->link->affected_rows;
}
function error() {
return $this->link->error;
}
function errno() {
return $this->link->errno;
}
function result($query, $row) {
if(!$query || $query->num_rows == 0) {
return null;
}
$query->data_seek($row);
$assocs = $query->fetch_row();
return $assocs[0];
}
function num_rows($query) {
$query = $query ? $query->num_rows : 0;
return $query;
}
function num_fields($query) {
return $query ? $query->field_count : 0;
}
function free_result($query) {
return $query ? $query->free() : false;
}
function insert_id() {
return ($id = $this->link->insert_id) >= 0 ? $id : $this->result($this->query("SELECT last_insert_id()"), 0);
}
function fetch_row($query) {
$query = $query ? $query->fetch_row() : null;
return $query;
}
function fetch_fields($query) {
return $query ? $query->fetch_field() : null;
}
function version() {
return $this->link->server_info;
}
function escape_string($str) {
return $this->link->escape_string($str);
}
function close() {
return $this->link->close();
}
function halt($message = '', $sql = '') {
show_error('run_sql_error', $message.$sql.'<br /> Error:'.$this->error().'<br />Errno:'.$this->errno(), 0);
}
}
?>

View File

@@ -0,0 +1,421 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: install_var.php 36324 2016-12-22 01:01:16Z nemohou $
*/
if(!defined('IN_COMSENZ')) {
exit('Access Denied');
}
define('SOFT_NAME', 'Discuz!');
define('INSTALL_LANG', 'SC_UTF8');
define('CONFIG', './config/config_global.php');
define('CONFIG_UC', './config/config_ucenter.php');
$sqlfile = ROOT_PATH.((file_exists(ROOT_PATH.'./install/data/install_dev.sql')) ? './install/data/install_dev.sql' : './install/data/install.sql');
$lockfile = ROOT_PATH.'./data/install.lock';
@include ROOT_PATH.CONFIG;
define('CHARSET', 'utf-8');
define('DBCHARSET', 'utf8mb4');
define('ORIG_TABLEPRE', 'pre_');
define('METHOD_UNDEFINED', 255);
define('ENV_CHECK_RIGHT', 0);
define('ERROR_CONFIG_VARS', 1);
define('SHORT_OPEN_TAG_INVALID', 2);
define('INSTALL_LOCKED', 3);
define('DATABASE_NONEXISTENCE', 4);
define('PHP_VERSION_TOO_LOW', 5);
define('MYSQL_VERSION_TOO_LOW', 6);
define('UC_URL_INVALID', 7);
define('UC_DNS_ERROR', 8);
define('UC_URL_UNREACHABLE', 9);
define('UC_VERSION_INCORRECT', 10);
define('UC_DBCHARSET_INCORRECT', 11);
define('UC_API_ADD_APP_ERROR', 12);
define('UC_ADMIN_INVALID', 13);
define('UC_DATA_INVALID', 14);
define('DBNAME_INVALID', 15);
define('DATABASE_ERRNO_2003', 16);
define('DATABASE_ERRNO_1044', 17);
define('DATABASE_ERRNO_1045', 18);
define('DATABASE_CONNECT_ERROR', 19);
define('TABLEPRE_INVALID', 20);
define('CONFIG_UNWRITEABLE', 21);
define('ADMIN_USERNAME_INVALID', 22);
define('ADMIN_EMAIL_INVALID', 25);
define('ADMIN_EXIST_PASSWORD_ERROR', 26);
define('ADMININFO_INVALID', 27);
define('LOCKFILE_NO_EXISTS', 28);
define('TABLEPRE_EXISTS', 29);
define('ERROR_UNKNOW_TYPE', 30);
define('ENV_CHECK_ERROR', 31);
define('UNDEFINE_FUNC', 32);
define('MISSING_PARAMETER', 33);
define('LOCK_FILE_NOT_TOUCH', 34);
$func_items = array('mysqli_connect', 'xml_parser_create', 'json_encode', 'dns_get_record');
$filesock_items = array('fsockopen', 'pfsockopen', 'stream_socket_client', 'curl_init');
$env_items = array
(
'os' => array('c' => 'PHP_OS', 'r' => 'notset', 'b' => 'unix'),
'php' => array('c' => 'PHP_VERSION', 'r' => '5.6', 'b' => '7.4'),
'attachmentupload' => array('r' => 'notset', 'b' => '2M'),
'gdversion' => array('r' => '1.0', 'b' => '2.0'),
'curl' => array('r' => 'notset', 'b' => 'enable'),
'opcache' => array('r' => 'notset', 'b' => 'enable'),
'diskspace' => array('r' => 30 * 1048576, 'b' => 'notset'),
);
$dirfile_items = array
(
'config' => array('type' => 'file', 'path' => CONFIG),
'ucenter config' => array('type' => 'file', 'path' => CONFIG_UC),
'config_dir' => array('type' => 'dir', 'path' => './config'),
'data' => array('type' => 'dir', 'path' => './data'),
'cache' => array('type' => 'dir', 'path' => './data/cache'),
'avatar' => array('type' => 'dir', 'path' => './data/avatar'),
'plugindata' => array('type' => 'dir', 'path' => './data/plugindata'),
'plugindownload' => array('type' => 'dir', 'path' => './data/download'),
'addonmd5' => array('type' => 'dir', 'path' => './data/addonmd5'),
'ftemplates' => array('type' => 'dir', 'path' => './data/template'),
'threadcache' => array('type' => 'dir', 'path' => './data/threadcache'),
'attach' => array('type' => 'dir', 'path' => './data/attachment'),
'attach_album' => array('type' => 'dir', 'path' => './data/attachment/album'),
'attach_category' => array('type' => 'dir', 'path' => './data/attachment/category'),
'attach_common' => array('type' => 'dir', 'path' => './data/attachment/common'),
'attach_forum' => array('type' => 'dir', 'path' => './data/attachment/forum'),
'attach_group' => array('type' => 'dir', 'path' => './data/attachment/group'),
'attach_portal' => array('type' => 'dir', 'path' => './data/attachment/portal'),
'attach_profile' => array('type' => 'dir', 'path' => './data/attachment/profile'),
'attach_swfupload' => array('type' => 'dir', 'path' => './data/attachment/swfupload'),
'attach_temp' => array('type' => 'dir', 'path' => './data/attachment/temp'),
'logs' => array('type' => 'dir', 'path' => './data/log'),
'uccache' => array('type' => 'dir', 'path' => './uc_client/data/cache'),
'uc_server_data' => array('type' => 'dir', 'path' => './uc_server/data/'),
'uc_server_data_cache' => array('type' => 'dir', 'path' => './uc_server/data/cache'),
'uc_server_data_avatar' => array('type' => 'dir', 'path' => './uc_server/data/avatar'),
'uc_server_data_backup' => array('type' => 'dir', 'path' => './uc_server/data/backup'),
'uc_server_data_logs' => array('type' => 'dir', 'path' => './uc_server/data/logs'),
'uc_server_data_tmp' => array('type' => 'dir', 'path' => './uc_server/data/tmp'),
'uc_server_data_view' => array('type' => 'dir', 'path' => './uc_server/data/view'),
);
$form_app_reg_items = array
(
'ucenter' => array
(
'ucurl' => array('type' => 'text', 'required' => 1, 'reg' => '/^https?:\/\//', 'value' => array('type' => 'var', 'var' => 'ucapi')),
'ucip' => array('type' => 'text', 'required' => 0, 'reg' => '/^\d+\.\d+\.\d+\.\d+$/'),
'ucpw' => array('type' => 'password', 'required' => 1, 'reg' => '/^.*$/')
),
'siteinfo' => array
(
'sitename' => array('type' => 'text', 'required' => 1, 'reg' => '/^.*$/', 'value' => array('type' => 'constant', 'var' => 'SOFT_NAME')),
'siteurl' => array('type' => 'text', 'required' => 1, 'reg' => '/^https?:\/\//', 'value' => array('type' => 'var', 'var' => 'default_appurl'))
)
);
$form_db_init_items = array
(
'dbinfo' => array
(
'dbhost' => array('type' => 'text', 'required' => 1, 'reg' => '/^.+$/', 'value' => array('type' => 'var', 'var' => 'dbhost')),
'dbname' => array('type' => 'text', 'required' => 1, 'reg' => '/^.+$/', 'value' => array('type' => 'var', 'var' => 'dbname')),
'dbuser' => array('type' => 'text', 'required' => 0, 'reg' => '/^.*$/', 'value' => array('type' => 'var', 'var' => 'dbuser')),
'dbpw' => array('type' => 'text', 'required' => 0, 'reg' => '/^.*$/', 'value' => array('type' => 'var', 'var' => 'dbpw')),
'tablepre' => array('type' => 'text', 'required' => 0, 'reg' => '/^.*+/', 'value' => array('type' => 'var', 'var' => 'tablepre')),
'adminemail' => array('type' => 'text', 'required' => 1, 'reg' => '/@/', 'value' => array('type' => 'var', 'var' => 'adminemail')),
),
'admininfo' => array
(
'username' => array('type' => 'text', 'required' => 1, 'reg' => '/^.*$/', 'value' => array('type' => 'constant', 'var' => 'admin')),
'password' => array('type' => 'password', 'required' => 1, 'reg' => '/^.*$/'),
'password2' => array('type' => 'password', 'required' => 1, 'reg' => '/^.*$/'),
'email' => array('type' => 'text', 'required' => 1, 'reg' => '/@/', 'value' => array('type' => 'var', 'var' => 'adminemail')),
)
);
$serialize_sql_setting = array (
'extcredits' =>
array (
1 =>
array (
'img' => '',
'title' => '威望',
'unit' => '',
'ratio' => 0,
'available' => '1',
'showinthread' => NULL,
'allowexchangein' => NULL,
'allowexchangeout' => NULL,
),
2 =>
array (
'img' => '',
'title' => '金钱',
'unit' => '',
'ratio' => 0,
'available' => '1',
'showinthread' => NULL,
'allowexchangein' => NULL,
'allowexchangeout' => NULL,
),
3 =>
array (
'img' => '',
'title' => '贡献',
'unit' => '',
'ratio' => 0,
'available' => '1',
'showinthread' => NULL,
'allowexchangein' => NULL,
'allowexchangeout' => NULL,
),
4 =>
array (
'img' => '',
'title' => '',
'unit' => '',
'ratio' => 0,
'available' => NULL,
'showinthread' => NULL,
'allowexchangein' => NULL,
'allowexchangeout' => NULL,
),
5 =>
array (
'img' => '',
'title' => '',
'unit' => '',
'ratio' => 0,
'available' => NULL,
'showinthread' => NULL,
'allowexchangein' => NULL,
'allowexchangeout' => NULL,
),
6 =>
array (
'img' => '',
'title' => '',
'unit' => '',
'ratio' => 0,
'available' => NULL,
'showinthread' => NULL,
'allowexchangein' => NULL,
'allowexchangeout' => NULL,
),
7 =>
array (
'img' => '',
'title' => '',
'unit' => '',
'ratio' => 0,
'available' => NULL,
'showinthread' => NULL,
'allowexchangein' => NULL,
'allowexchangeout' => NULL,
),
8 =>
array (
'img' => '',
'title' => '',
'unit' => '',
'ratio' => 0,
'available' => NULL,
'showinthread' => NULL,
'allowexchangein' => NULL,
'allowexchangeout' => NULL,
),
),
'postnocustom' =>
array (
0 => '楼主',
1 => '沙发',
2 => '板凳',
3 => '地板',
),
'recommendthread' =>
array (
'status' => '0',
'addtext' => '支持',
'subtracttext' => '反对',
'defaultshow' => '1',
'daycount' => '0',
'ownthread' => '0',
'iconlevels' => '50,100,200',
),
'seotitle' =>
array (
'portal' => '门户',
'forum' => '论坛',
'group' => '圈子',
'home' => '家园',
),
'activityfield' =>
array (
'realname' => '真实姓名',
'mobile' => '手机',
'qq' => 'QQ号',
),
'article_tags' =>
array (
1 => '原创',
2 => '热点',
3 => '组图',
4 => '爆料',
5 => '头条',
6 => '幻灯',
7 => '滚动',
8 => '推荐',
),
'verify' =>
array (
6 =>
array (
'title' => '实名认证',
'available' => '0',
'showicon' => '0',
'viewrealname' => '0',
'field' =>
array (
'realname' => 'realname',
),
'icon' => false,
),
'enabled' => false,
1 =>
array (
'icon' => '',
),
2 =>
array (
'icon' => '',
),
3 =>
array (
'icon' => '',
),
4 =>
array (
'icon' => '',
),
5 =>
array (
'icon' => '',
),
),
'focus' =>
array (
'title' => '站长推荐',
'data' =>
array (
),
'cookie' => '1',
),
'profilegroup' =>
array (
'base' =>
array (
'available' => 1,
'displayorder' => 0,
'title' => '基本资料',
'field' =>
array (
'realname' => 'realname',
'gender' => 'gender',
'birthday' => 'birthday',
'birthcity' => 'birthcity',
'residecity' => 'residecity',
'residedist' => 'residedist',
'affectivestatus' => 'affectivestatus',
'lookingfor' => 'lookingfor',
'bloodtype' => 'bloodtype',
'field1' => 'field1',
'field2' => 'field2',
'field3' => 'field3',
'field4' => 'field4',
'field5' => 'field5',
'field6' => 'field6',
'field7' => 'field7',
'field8' => 'field8',
),
),
'contact' =>
array (
'title' => '联系方式',
'available' => '1',
'displayorder' => '1',
'field' =>
array (
'telephone' => 'telephone',
'mobile' => 'mobile',
'icq' => 'icq',
'qq' => 'qq',
'yahoo' => 'yahoo',
'msn' => 'msn',
'taobao' => 'taobao',
),
),
'edu' =>
array (
'available' => 1,
'displayorder' => 2,
'title' => '教育情况',
'field' =>
array (
'graduateschool' => 'graduateschool',
'education' => 'education',
),
),
'work' =>
array (
'available' => 1,
'displayorder' => 3,
'title' => '工作情况',
'field' =>
array (
'occupation' => 'occupation',
'company' => 'company',
'position' => 'position',
'revenue' => 'revenue',
),
),
'info' =>
array (
'title' => '个人信息',
'available' => '1',
'displayorder' => '4',
'field' =>
array (
'idcardtype' => 'idcardtype',
'idcard' => 'idcard',
'address' => 'address',
'zipcode' => 'zipcode',
'site' => 'site',
'bio' => 'bio',
'interest' => 'interest',
'sightml' => 'sightml',
'customstatus' => 'customstatus',
'timeoffset' => 'timeoffset',
),
),
),
);
?>

0
install/static/index.htm Normal file
View File

139
install/static/style.css Normal file
View File

@@ -0,0 +1,139 @@
/* based on acrylic_vision.css (c) popcorner MIT License */
/* common */
html, body { width: 100%; min-height: 100%; margin: 0; padding: 0; }
html { background: #c8e2fb; background-image: linear-gradient(45deg, #8fc1f1, #fde2ba); background-attachment: fixed; }
body { display: flex; justify-content: center; font-size: 16px; min-width: 960px; }
ul, dl, dd, p, h1, h2, h3, h4, h5, h6, form, fieldset { margin: 0; padding: 0; }
input, select, button { line-height: 1.5; padding: 7px 11px; border: 1px solid #ccc; border-radius: 5px; font-size: 16px; }
input:focus, select:focus, button:focus { outline: none; border-color: #2b7acd; box-shadow: 0 0 3px 2px rgba(43, 122, 205, 0.4); }
button { margin-bottom: 0; border-color: #2b7acd; background: #2b7acd; color: #fff; cursor: pointer; }
/* container */
.container { display: flex; width: 900px; flex-direction: column; overflow: hidden; border-radius: 30px; position: relative; margin: 35px; }
.header { background: #2b7acd; color: #fff; display: flex; justify-content: space-between; align-items: center; padding: 3px 50px 60px 50px; }
.nostep .header { padding-bottom: 5px; }
.header h1 { font-size: 30px; font-weight: 400; margin: 20px 0; }
.header h1 span { font-weight: 700; margin-right: 14px; }
.main { background: linear-gradient(135deg, #fff, rgba(255, 255, 255, 0.5) 50%); padding: 180px 25px 15px 25px; color: #35435c; }
.nostep .main { padding-top: 25px; }
.footer { text-align: center; font-size: 12px; color: #93a3bb; }
.footer a { color: #93a3bb; }
/* step */
.setup { position: absolute; width: 100%; top: 80px; }
.setup > div { margin: 0 30px; padding: 10px 25px; border-radius: 30px; background: #aacaeb; background-image: linear-gradient(0deg, #fff 40%, #aacaeb); display: flex; box-shadow: 0 0 20px rgba(43, 122, 205, 0.15); flex-direction: column; align-items: center; }
.setup .step { display: flex; align-items: center; height: 100px; }
.stepnum { display: flex; font-size: 40px; height: 60px; width: 60px; justify-content: center; align-items: center; border-radius: 30px; font-weight: 700; background: #2b7acd; background-image: linear-gradient(0deg, #2b99cd, #2b7acd); color: #fff; box-shadow: -6px -6px 6px rgba(255, 255, 255, 0.3), 6px 6px 6px rgba(43, 122, 205, 0.25), 0 0 0 8px rgba(255, 255, 255, 0.5); margin-right: 30px; }
.step h2 { color: #35435c; margin-bottom: 8px; font-size: 28px; }
.step p { color: #72767c; }
.stepstat { position: relative; width: 100%; height: 50px; overflow: hidden; background: #ffe7db; border-radius: 20px; margin: 20px 0; }
.stepstat .stepstattxt { position: absolute; width: 100%; display: flex; height: 50px; align-items: center; font-size: 14px; }
.stepstat .stepstattxt > div { flex-basis: 0; flex-grow: 1; margin: 0 10px; text-align: center; color: #fff; }
.stepstatbg { height: 50px; background: #f7a659; border-radius: 0 20px 20px 0; }
.stepstat .stepstattxt > div.unactivated { color: #956334; }
.stepstat1 { width: 25%; }
.stepstat2 { width: 50%; }
.stepstat3 { width: 75%; }
.stepstat4 { width: 100%; border-radius: 0; }
/* license */
.licenseblock { margin-bottom: 25px; padding: 15px; height: 360px; background: #fff; overflow: scroll; overflow-x: hidden; }
.license { color: #35435c; }
.license h1 { padding-bottom: 10px; font-size: 18px; text-align: center; }
.license h3 { margin: 0; }
.license p { margin: 10px 0; text-indent: 25px; }
.license li { margin: 5px 0; }
.license ol { margin: 0; }
/* button */
.btnbox { text-align: center; margin-bottom: 20px; }
.btnbox input { margin: 0 2px; }
.btnbox textarea { margin-bottom: 10px; height: 150px; }
.btnbox .inputbox { width: 50%; margin: 0 auto; }
.btn { margin-top: 10px; cursor: pointer; background: #2b7acd; color: #fff; border-color: #2b7acd; padding: 10px 16px; font-size: 20px; border-radius: 15px; text-decoration: none; }
.btn:hover { background-image: linear-gradient(0deg, rgba(11, 65, 120, 0.2), transparent); }
.btn.oldbtn { background: #fff; border-color: #fff; color: #35435c; margin-right: 15px; }
.btn.oldbtn:hover { background-image: linear-gradient(0deg, rgba(124, 169, 217, 0.1), transparent); }
.btn:disabled { background-color: #5e96d1; cursor: not-allowed; }
.btn:disabled:hover { background-image: none; }
/* form */
.tbopt { flex: 0 0 25%; cursor: pointer; }
.txt { flex: 1 0 70%; }
.comm { flex: 1 0 70%; margin-left: 25%; font-size: 14px; padding-top: 8px; color: #72767c; }
.inputbox { display: flex; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.inputbox .btn { margin: 0 8px; flex-grow: 1; }
.desc { font-size: 20px; margin-bottom: 30px; font-weight: 700; }
.selradio { display: flex; align-items: center; }
.selradio input { width: 18px; height: 18px; border-radius: 9px; margin: 0; margin-right: 10px; padding: 0; cursor: pointer; -webkit-appearance: none; -moz-appearance: none; appearance: none; }
.selradio input:checked { background-color: #2b7acd; border-color: #2b7acd; background-image: radial-gradient(#fff 30%, #2b7acd 45%); }
.selradio label { font-size: 18px; cursor: pointer; }
.inputbox .ckb { width: 18px; height: 18px; margin: 0 10px 0 25%; padding: 0; background: #fff; -webkit-appearance: none; -moz-appearance: none; appearance: none; }
.inputbox .ckb:checked { background: #2b7acd url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff'%3e%3cpath d='M18.9 4.9L9 14.8l-3.5-3.5-2.8 2.8L9 20.4 21.7 7.7l-2.8-2.8z'/%3e%3c/svg%3e") no-repeat 50% 50%; border-color: #2b7acd; background-size: 14px; }
.box > .desc:last-child, .box > .inputbox:last-child { margin-bottom: 0; }
.desc .comm { margin: 0; font-weight: 400; }
.inputbox.red .txt { border-color: #d31f0d; background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23d31f0d'%3e%3cpath d='M1.3 1.3c.4-.4 1-.4 1.4 0L8 6.6l5.3-5.3c.4-.4 1-.4 1.4 0 .4.4.4 1 0 1.4L9.4 8l5.3 5.3c.4.4.4 1 0 1.4-.4.4-1 .4-1.4 0L8 9.4l-5.3 5.3c-.4.4-1 .4-1.4 0-.4-.4-.4-1 0-1.4L6.6 8 1.3 2.7c-.4-.4-.4-1 0-1.4z'/%3e%3c/svg%3e") no-repeat; background-position: calc(100% - 9px) 50%; background-size: 20px; }
.inputbox.red .txt:focus { box-shadow: 0 0 3px 2px rgba(211, 31, 13, 0.4); }
.comm.red { color: #d31f0d; }
/* box */
.box { background: #fff; padding: 30px 20px; border-radius: 25px; margin-bottom: 30px; }
.box.warnbox { background: #ffd2d2; padding-left: 150px; position: relative; }
.box.warnbox::before { content: "\21"; display: flex; width: 50px; height: 50px; border-radius: 25px; background: #d31f0d; left: 50px; position: absolute; align-items: center; justify-content: center; color: #fff; font-size: 36px; font-weight: 700; }
.box.warnbox h3 { margin-bottom: 20px; }
.box.warnbox .red { color: #d31f0d; }
.box.warnbox ul { padding-left: 2em; }
h2.title { padding-bottom: 10px; border-bottom: 1px solid #c6d1e3; margin-bottom: 20px; font-size: 20px; }
.box.collapse h2.title { padding-bottom: 0; border: 0; margin: 0; cursor: pointer; }
.box.valid h2.title { padding-left: 30px; background: no-repeat 0 2px; cursor: pointer; }
.box.collapse .tb { display: none; }
.box.valid.collapse { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2335435c' viewBox='0 0 16 16'%3e%3cpath d='M1.6 4.6c.2-.2.5-.2.7 0L8 10.3l5.6-5.6c.2-.2.5-.2.7 0s.2.5 0 .7l-6 6c-.2.2-.5.2-.7 0l-6-6c-.1-.3-.1-.6 0-.8z'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: calc(100% - 30px) 50%; }
/* table */
.tb { border-spacing: 0; border-collapse: collapse; width: 100%; overflow: auto; }
.tb th { font-weight: 600; }
.tb th, .tb td { padding: 6px 13px; border: 1px solid #c6d1e3; }
.tb tr { background-color: #fff; border-top: 1px solid #c6cbd1; }
.tb tr:nth-child(2n) { background-color: #f3f8fd; }
.tb td.w, .tb td.nw { padding-left: 35px; background: no-repeat 10px center; }
.tb td.w, .box.valid h2.title { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%231ca3a6'%3e%3cpath d='M18.9 4.9L9 14.8l-3.5-3.5-2.8 2.8L9 20.4 21.7 7.7l-2.8-2.8z'/%3e%3c/svg%3e"); }
.tb td.nw { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23d31f0d'%3e%3cpath d='M20.4 6.4l-2.8-2.8L12 9.2 6.4 3.6 3.6 6.4 9.2 12l-5.6 5.6 2.8 2.8 5.6-5.6 5.6 5.6 2.8-2.8-5.6-5.6 5.6-5.6z'/%3e%3c/svg%3e"); }
.tb tr.nwbg { background-color: #ffd2d2; }
/* install progress */
#notice { display: none; overflow-x: hidden; overflow-y: auto; margin: 20px; padding: 15px; border: 1px solid #ddd; height: 300px; text-align: left; line-height: 2; }
#lastmsg .red, #notice .red { color: #d31f0d; }
#lastmsg .red::before, #notice .red::before { content: "\d7"; margin-right: 10px; }
.progress { flex-grow: 0; height: 40px; margin: 0 20px; background: #e6e9e9; border-radius: 15px; position: relative; overflow: hidden; cursor: pointer; }
#pgb { width: 0%; height: 100%; background: #32cb92; border-radius: 0 12px 12px 0; position: absolute; bottom: 0; left: 0; transition: 0.2s ease; background-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.25) 40%, rgba(255, 255, 255, 0.25) 60%, rgba(255, 255, 255, 0) 100%); background-size: 240px 100%; background-repeat: no-repeat; background-position: -240px 0; }
#pgb.move { animation: bar-move 2s linear infinite; }
#lastmsg { padding: 0 40px; }
.instfail #notice { display: block; }
.instfail #pgb { background: #d31f0d; animation: none; }
.instfail .progress { cursor: default; }
/* success page */
.inst_success { animation: sinext .5s ease 2s 1; animation-fill-mode: both; }
.inst_success .success_icon { width: 200px; height: 200px; border-radius: 100px; background: #1ca3a6; background-size: cover; margin: 30px auto; position: relative; transform: rotate(45deg); animation: sipop .4s ease .5s; animation-fill-mode: backwards; }
.success_icon::before { content: ""; display: block; background: #fff; position: absolute; top: 125px; left: 70px; width: 50px; height: 20px; animation: sibefore .2s ease 1.1s 1; animation-fill-mode: both; }
.success_icon::after { content: ""; display: block; background: #fff; position: absolute; bottom: 55px; left: 100px; width: 20px; height: 100px; animation: siafter .2s ease 1.3s 1; animation-fill-mode: both; }
.inst_success h2 { text-align: center; font-size: 24px; margin-bottom: 60px; }
.inst_success p { text-align: center; margin-bottom: 10px; }
.inst_success a.btn { display: block; width: 50%; margin: 20px auto; padding: 14px 16px; text-align: center; font-size: 22px; background: #f7a659; }
.inst_success a.btn.finish { background: #1ca3a6; }
/* keyframes */
@keyframes bar-move { 0% { background-position: -240px 0; }
100% { background-position: calc(100% + 480px) 0; } }
@keyframes sipop { 0% { opacity: 0;
transform: rotate(45deg) scale(0.5); }
80% { opacity: 1;
transform: rotate(45deg) scale(1.02); }
100% { opacity: 1;
transform: rotate(45deg) scale(1); } }
@keyframes sibefore { 0% { width: 0px; }
100% { width: 50px; } }
@keyframes siafter { 0% { height: 0px; }
100% { height: 100px; } }
@keyframes sinext { 0% { margin-bottom: -335px; }
100% { margin-bottom: 0; } }

39
member.php Normal file
View File

@@ -0,0 +1,39 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: member.php 34253 2013-11-25 03:36:23Z nemohou $
*/
define('APPTYPEID', 0);
define('CURSCRIPT', 'member');
require './source/class/class_core.php';
$discuz = C::app();
$modarray = array('getpasswd',
'groupexpiry', 'logging', 'lostpasswd',
'register', 'regverify', 'switchstatus');
$mod = !in_array($discuz->var['mod'], $modarray) && (!preg_match('/^\w+$/', $discuz->var['mod']) || !file_exists(DISCUZ_ROOT.'./source/module/member/member_'.$discuz->var['mod'].'.php')) ? 'register' : $discuz->var['mod'];
define('CURMODULE', $mod);
$discuz->init();
if($mod == 'register' && $discuz->var['mod'] != $_G['setting']['regname']) {
showmessage('undefined_action');
}
require libfile('function/member');
require libfile('class/member');
runhooks();
require DISCUZ_ROOT.'./source/module/member/member_'.$mod.'.php';
?>

98
misc.php Normal file
View File

@@ -0,0 +1,98 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: misc.php 34264 2013-11-27 03:14:58Z nemohou $
*/
if(isset($_GET['css'])) {
$css = explode('|', $_GET['css']);
$string = '';
$size = 0;
foreach($css as $file) {
if(preg_match('/^\w+$/', $file)) {
$file = './data/cache/style_'.$file.'.css';
$string .= @implode('', file($file));
}
}
ob_start('ob_gzhandler');
header('Content-Type: text/css');
header('Expires: '.gmdate('D, d M Y H:i:s', time() + 2592000).' GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
echo $string;
exit;
}
if(isset($_GET['js'])) {
$js = explode('|', $_GET['js']);
$string = '';
$size = 0;
foreach($js as $file) {
$file = substr($file, 0, strpos($file, '.'));
if(preg_match('/^\w+$/', $file)) {
$file = './data/cache/'.$file.'.js';
$string .= @implode('', file($file));
}
}
ob_start('ob_gzhandler');
header('Content-Type: text/javascript');
header('Expires: '.gmdate('D, d M Y H:i:s', time() + 2592000).' GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
echo $string;
exit;
}
define('APPTYPEID', 100);
define('CURSCRIPT', 'misc');
require './source/class/class_core.php';
$discuz = C::app();
if(isset($_GET['mod']) && $_GET['mod'] != 'tag'){
$discuz->reject_robot();
}
$modarray = array('seccode', 'secqaa', 'initsys', 'invite', 'faq', 'report',
'swfupload', 'stat', 'ranklist', 'buyinvitecode',
'tag', 'diyhelp', 'mobile', 'patch', 'getatuser', 'imgcropper',
'userstatus', 'secmobseccode');
$modcachelist = array(
'ranklist' => array('forums', 'diytemplatename'),
);
$mod = getgpc('mod');
$mod = (empty($mod) || !in_array($mod, $modarray)) ? 'error' : $mod;
if(in_array($mod, array('seccode', 'secqaa', 'initsys', 'faq', 'swfupload', 'mobile'))) {
define('ALLOWGUEST', 1);
}
$cachelist = array();
if(isset($modcachelist[$mod])) {
$cachelist = $modcachelist[$mod];
}
$discuz->cachelist = $cachelist;
switch ($mod) {
case 'secqaa':
case 'userstatus':
case 'seccode':
$discuz->init_cron = false;
$discuz->init_session = false;
break;
default:
break;
}
$discuz->init();
define('CURMODULE', $mod);
runhooks();
require DISCUZ_ROOT.'./source/module/misc/misc_'.$mod.'.php';
?>

49
plugin.php Normal file
View File

@@ -0,0 +1,49 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: plugin.php 27335 2012-01-16 10:15:37Z monkey $
*/
define('APPTYPEID', 127);
define('CURSCRIPT', 'plugin');
define('NOT_IN_MOBILE_API', 1);
require './source/class/class_core.php';
$discuz = C::app();
$cachelist = array('plugin', 'diytemplatename');
$discuz->cachelist = $cachelist;
$discuz->init();
if(!empty($_GET['id'])) {
list($identifier, $module) = explode(':', $_GET['id'].':');
$module = $module !== '' ? $module : $identifier;
} else {
showmessage('plugin_nonexistence');
}
$mnid = 'plugin_'.$identifier.'_'.$module;
$pluginmodule = isset($_G['setting']['pluginlinks'][$identifier][$module]) ? $_G['setting']['pluginlinks'][$identifier][$module] : (isset($_G['setting']['plugins']['script'][$identifier][$module]) ? $_G['setting']['plugins']['script'][$identifier][$module] : array('adminid' => 0, 'directory' => preg_match("/^[a-z]+[a-z0-9_]*$/i", $identifier) ? $identifier.'/' : ''));
if(!preg_match('/^[\w\_]+$/', $identifier)) {
showmessage('plugin_nonexistence');
}
if(empty($identifier) || !preg_match("/^[a-z0-9_\-]+$/i", $module) || !in_array($identifier, $_G['setting']['plugins']['available'])) {
showmessage('plugin_nonexistence');
} elseif($pluginmodule['adminid'] && ($_G['adminid'] < 1 || ($_G['adminid'] > 0 && $pluginmodule['adminid'] < $_G['adminid']))) {
showmessage('plugin_nopermission');
} elseif(@!file_exists(DISCUZ_ROOT.($modfile = './source/plugin/'.$pluginmodule['directory'].$module.'.inc.php'))) {
showmessage('plugin_module_nonexistence', '', array('mod' => $modfile));
}
define('CURMODULE', $identifier);
runhooks();
include DISCUZ_ROOT.$modfile;
?>

38
portal.php Normal file
View File

@@ -0,0 +1,38 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: portal.php 33234 2013-05-08 04:13:19Z andyzheng $
*/
define('APPTYPEID', 4);
define('CURSCRIPT', 'portal');
require './source/class/class_core.php';
$discuz = C::app();
$cachelist = array('portalcategory', 'diytemplatenameportal');
$discuz->cachelist = $cachelist;
$discuz->init();
require DISCUZ_ROOT.'./source/function/function_home.php';
require DISCUZ_ROOT.'./source/function/function_portal.php';
if(empty($_GET['mod']) || !in_array($_GET['mod'], array('list', 'view', 'comment', 'portalcp', 'topic', 'attachment', 'rss', 'block'))) $_GET['mod'] = 'index';
define('CURMODULE', $_GET['mod']);
runhooks();
if(!$_G['setting']['portalstatus'] && $_GET['mod'] != 'portalcp'){
showmessage('portal_status_off');
}
$navtitle = str_replace('{bbname}', $_G['setting']['bbname'], $_G['setting']['seotitle']['portal']);
$_G['disabledwidthauto'] = 1;
require_once libfile('portal/'.$_GET['mod'], 'module');
?>

29
robots.txt Normal file
View File

@@ -0,0 +1,29 @@
#
# robots.txt for Discuz! X3.5
#
User-agent: *
Allow: /data/attachment/
Allow: /data/avatar/
Allow: /data/cache/
Allow: /uc_server/data/avatar/
Disallow: /api/
Disallow: /data/
Disallow: /source/
Disallow: /install/
Disallow: /template/default/
Disallow: /config/
Disallow: /uc_client/
Disallow: /uc_server/
Disallow: /admin.php
Disallow: /search.php
Disallow: /member.php
Disallow: /api.php
Disallow: /misc.php
Disallow: /connect.php
Disallow: /forum.php?mod=redirect*
Disallow: /forum.php?mod=post*
Disallow: /home.php?mod=spacecp*
Disallow: /*?mod=misc*
Disallow: /*?mod=attachment*
Disallow: /*mobile=yes*

63
search.php Normal file
View File

@@ -0,0 +1,63 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: search.php 34131 2013-10-17 03:54:09Z andyzheng $
*/
define('APPTYPEID', 0);
define('CURSCRIPT', 'search');
require './source/class/class_core.php';
$discuz = C::app();
$modarray = array('user', 'curforum', 'newthread');
$cachelist = $slist = array();
$mod = '';
$discuz->cachelist = $cachelist;
$discuz->init();
if(in_array($discuz->var['mod'], $modarray) || (!empty($_G['setting']['search'][$discuz->var['mod']]['status']) && $_G['setting'][($discuz->var['mod'] == 'curforum' ? 'forum' : ($discuz->var['mod'] == 'user' ? 'friend' : $discuz->var['mod'])).'status'])) {
$mod = $discuz->var['mod'];
} else {
foreach($_G['setting']['search'] as $mod => $value) {
if(!empty($value['status']) && $_G['setting'][($mod == 'curforum' ? 'forum' : ($mod == 'user' ? 'friend' : $mod)).'status']) {
break;
}
}
}
if(empty($mod)) {
showmessage('search_closed');
}
define('CURMODULE', $mod);
runhooks();
if (!$_G['setting'][($mod == 'curforum' ? 'forum' : ($mod == 'user' ? 'friend' : $mod)).'status']) {
showmessage(($mod == 'curforum' ? 'forum' : ($mod == 'user' ? 'friend' : ($mod == 'group' ? 'group_module' : $mod))).'_status_off');
}
require_once libfile('function/search');
$navtitle = lang('core', 'title_search');
if($mod == 'curforum') {
$mod = 'forum';
$_GET['srchfid'] = array($_GET['srhfid']);
} elseif($mod == 'forum') {
$_GET['srhfid'] = 0;
}
if(!empty($_GET['srchtxt']) && getglobal('setting/srchcensor')) {
$_GET['srchtxt'] = censor($_GET['srchtxt']);
}
require DISCUZ_ROOT.'./source/module/search/search_'.$mod.'.php';
?>

View File

@@ -0,0 +1,442 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_admingroup.php 31651 2012-09-18 10:23:26Z zhangjie $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!$operation) {
if(submitcheck('groupsubmit') && $ids = dimplode($_GET['delete'])) {
$gids = array();
$query = C::t('common_usergroup')->fetch_all_by_groupid($_GET['delete']);
foreach($query as $g) {
$gids[] = $g['groupid'];
}
if($gids) {
C::t('common_usergroup')->delete_usergroup($gids);
C::t('common_usergroup_field')->delete($gids);
C::t('common_admingroup')->delete($gids);
$newgroupid = C::t('common_usergroup')->fetch_new_groupid();
C::t('common_member')->update_by_groupid($gids, array('groupid' => $newgroupid, 'adminid' => '0'), 'UNBUFFERED');
deletegroupcache($gids);
}
}
$grouplist = C::t('common_admingroup')->fetch_all_merge_usergroup();
if(!submitcheck('groupsubmit')) {
shownav('user', 'nav_admingroups');
showsubmenu('nav_admingroups');
showtips('admingroup_tips');
showformheader('admingroup');
showtableheader('', 'fixpadding');
showsubtitle(array('', 'usergroups_title', '', 'type', 'admingroup_level', 'usergroups_stars', 'usergroups_color',
'<input class="checkbox" type="checkbox" name="gbcmember" onclick="checkAll(\'value\', this.form, \'gbmember\', \'gbcmember\', 1)" /> <a href="javascript:;" onclick="if(getmultiids()) location.href=\''.ADMINSCRIPT.'?action=usergroups&operation=edit&multi=\' + getmultiids();return false;">'.$lang['multiedit'].'</a>',
'<input class="checkbox" type="checkbox" name="gpcmember" onclick="checkAll(\'value\', this.form, \'gpmember\', \'gpcmember\', 1)" /> <a href="javascript:;" onclick="if(getmultiids()) location.href=\''.ADMINSCRIPT.'?action=admingroup&operation=edit&multi=\' + getmultiids();return false;">'.$lang['multiedit'].'</a>',
));
foreach($grouplist as $gid => $group) {
$adminidselect = '<select name="newradminid['.$group['groupid'].']">';
for($i = 1;$i <= 3;$i++) {
$adminidselect .= '<option value="'.$i.'"'.($i == $group['radminid'] ? ' selected="selected"' : '').'>'.$lang['usergroups_system_'.$i].'</option>';
}
$adminidselect .= '</select>';
$staticurl = STATICURL;
showtablerow('', array('', '', 'class="td23 lightfont"', 'class="td25"', '', 'class="td25"'), array(
$group['type'] == 'system' ? '<input type="checkbox" class="checkbox" disabled="disabled" />' : "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"{$group['groupid']}\">",
'<span style="color:'.$group['color'].'">'.$group['grouptitle'].'</span>',
"(groupid:{$group['groupid']})",
$group['type'] == 'system' ? cplang('inbuilt') : cplang('custom'),
$group['type'] == 'system' ? $lang['usergroups_system_'.$group['radminid']] : $adminidselect,
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"group_stars[{$group['groupid']}]\" value=\"{$group['stars']}\">",
"<input type=\"text\" id=\"group_color_{$group['groupid']}_v\" class=\"left txt\" size=\"6\" name=\"group_color[{$group['groupid']}]\" value=\"{$group['color']}\" onchange=\"updatecolorpreview('group_color_P{$group['groupid']}')\"><input type=\"button\" id=\"group_color_{$group['groupid']}\" class=\"colorwd\" onclick=\"group_color_{$group['groupid']}_frame.location='{$staticurl}image/admincp/getcolor.htm?group_color_{$group['groupid']}|group_color_{$group['groupid']}_v';showMenu({'ctrlid':'group_color_{$group['groupid']}'})\" style=\"background: {$group['color']}\" /><span id=\"group_color_{$group['groupid']}_menu\" style=\"display: none\"><iframe name=\"group_color_{$group['groupid']}_frame\" src=\"\" frameborder=\"0\" width=\"210\" height=\"148\" scrolling=\"no\"></iframe></span>",
"<input class=\"checkbox\" type=\"checkbox\" chkvalue=\"gbmember\" value=\"{$group['groupid']}\" onclick=\"multiupdate(this)\" /><a href=\"".ADMINSCRIPT."?action=usergroups&operation=edit&id={$group['admingid']}\" class=\"act\">{$lang['admingroup_setting_user']}</a>",
"<input class=\"checkbox\" type=\"checkbox\" chkvalue=\"gpmember\" value=\"{$group['groupid']}\" onclick=\"multiupdate(this)\" /><a href=\"".ADMINSCRIPT."?action=admingroup&operation=edit&id={$group['admingid']}\" class=\"act\">{$lang['admingroup_setting_admin']}</a>"
));
}
showtablerow('', array('class="td25"', '', '', '', 'colspan="6"'), array(
cplang('add_new'),
'<input type="text" class="txt" size="12" name="grouptitlenew">',
'',
cplang('custom'),
"<select name=\"radminidnew\"><option value=\"1\">{$lang['usergroups_system_1']}</option><option value=\"2\">{$lang['usergroups_system_2']}</option><option value=\"3\" selected=\"selected\">{$lang['usergroups_system_3']}</option>",
));
showsubmit('groupsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
foreach($grouplist as $gid => $group) {
$stars = intval($_GET['group_stars'][$gid]);
$color = dhtmlspecialchars($_GET['group_color'][$gid]);
if($group['color'] != $color || $group['stars'] != $stars || $group['icon'] != $avatar) {
C::t('common_usergroup')->update_usergroup($gid, array('stars' => $stars, 'color' => $color));
}
}
$grouptitlenew = dhtmlspecialchars(trim($_GET['grouptitlenew']));
$radminidnew = intval($_GET['radminidnew']);
foreach($_GET['newradminid'] as $groupid => $newradminid) {
C::t('common_usergroup')->update_usergroup($groupid, array('radminid' => $newradminid));
}
if($grouptitlenew && in_array($radminidnew, array(1, 2, 3))) {
$data = array();
$usergroup = C::t('common_usergroup')->fetch($radminidnew);
foreach ($usergroup as $key => $val) {
if(!in_array($key, array('groupid', 'radminid', 'type', 'system', 'grouptitle'))) {
$val = addslashes($val);
$data[$key] = $val;
}
}
$fielddata = array();
$usergroup = C::t('common_usergroup_field')->fetch($radminidnew);
foreach ($usergroup as $key => $val) {
if(!in_array($key, array('groupid'))) {
$val = addslashes($val);
$fielddata[$key] = $val;
}
}
$adata = array();
$admingroup = C::t('common_admingroup')->fetch($radminidnew);
foreach ($admingroup as $key => $val) {
if(!in_array($key, array('admingid'))) {
$val = addslashes($val);
$adata[$key] = $val;
}
}
$data['radminid'] = $radminidnew;
$data['type'] = 'special';
$data['grouptitle'] = $grouptitlenew;
$newgroupid = C::t('common_usergroup')->insert($data, true);
if($newgroupid) {
$adata['admingid'] = $newgroupid;
$fielddata['groupid'] = $newgroupid;
C::t('common_admingroup')->insert($adata);
C::t('common_usergroup_field')->insert($fielddata);
}
}
updatecache(array('usergroups', 'groupreadaccess', 'admingroups'));
cpmsg('admingroups_edit_succeed', 'action=admingroup', 'succeed');
}
} elseif($operation == 'edit') {
$submitcheck = submitcheck('groupsubmit');
$multiset = 0;
if(empty($_GET['multi'])) {
$gids = $_GET['id'];
} else {
$multiset = 1;
if(is_array($_GET['multi'])) {
$gids = $_GET['multi'];
} else {
$_GET['multi'] = explode(',', $_GET['multi']);
array_walk($_GET['multi'], 'intval');
$gids = $_GET['multi'];
}
}
if(!empty($_GET['multi']) && is_array($_GET['multi']) && count($_GET['multi']) == 1) {
$gids = $_GET['multi'][0];
$multiset = 0;
}
if(!$submitcheck) {
if(empty($gids)) {
$grouplist = "<select name=\"id\" style=\"width: 150px\">\n";
foreach(C::t('common_admingroup')->fetch_all_merge_usergroup() as $group) {
$grouplist .= "<option value=\"{$group['groupid']}\">{$group['grouptitle']}</option>\n";
}
$grouplist .= '</select>';
$highlight = getgpc('highlight');
$highlight = !empty($highlight) ? dhtmlspecialchars($highlight, ENT_QUOTES) : '';
cpmsg('admingroups_edit_nonexistence', 'action=admingroup&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', array(), $grouplist);
}
$mgroup = C::t('common_admingroup')->fetch_all_merge_usergroup($gids);
if(!$mgroup) {
cpmsg('usergroups_nonexistence', '', 'error');
}/* else {
while($group = DB::fetch($query)) {
$mgroup[] = $group;
}
}*/
$grouplist = $gutype = '';
foreach(C::t('common_admingroup')->fetch_all_order() as $ggroup) {
$checked = $_GET['id'] == $ggroup['groupid'] || (is_array($_GET['multi']) && in_array($ggroup['groupid'], $_GET['multi']));
if($gutype != $ggroup['radminid']) {
$grouplist .= '<em><span class="right"><input name="checkall_'.$ggroup['radminid'].'" onclick="checkAll(\'value\', this.form, \'g'.$ggroup['radminid'].'\', \'checkall_'.$ggroup['radminid'].'\')" type="checkbox" class="vmiddle checkbox" /></span>'.
($ggroup['radminid'] == 1 ? $lang['usergroups_system_1'] : ($ggroup['radminid'] == 2 ? $lang['usergroups_system_2'] : $lang['usergroups_system_3'])).'</em>';
$gutype = $ggroup['radminid'];
}
$grouplist .= '<input class="left checkbox ck" chkvalue="g'.$ggroup['radminid'].'" name="multi[]" value="'.$ggroup['groupid'].'" type="checkbox" '.($checked ? 'checked="checked" ' : '').'/>'.
'<a href="###" onclick="location.href=\''.ADMINSCRIPT.'?action=admingroup&operation=edit&switch=yes&id='.$ggroup['groupid'].'&anchor=\'+currentAnchor+\'&scrolltop=\'+document.documentElement.scrollTop"'.($checked ? ' class="current"' : '').'>'.$ggroup['grouptitle'].'</a>';
}
$gselect = '<span id="ugselect" class="right popupmenu_dropmenu" onmouseover="showMenu({\'ctrlid\':this.id,\'pos\':\'34\'});$(\'ugselect_menu\').style.top=(parseInt($(\'ugselect_menu\').style.top)-scrollTopBody())+\'px\';$(\'ugselect_menu\').style.left=(parseInt($(\'ugselect_menu\').style.left)-document.documentElement.scrollLeft-20)+\'px\'">'.$lang['usergroups_switch'].'<em>&nbsp;&nbsp;</em></span>'.
'<div id="ugselect_menu" class="popupmenu_popup" style="display:none">'.
$grouplist.
'<br style="clear:both" /><div class="cl"><input type="button" class="btn right" onclick="$(\'menuform\').submit()" value="'.cplang('admingroups_multiedit').'" /></div>'.
'</div>';
$_GET['anchor'] = in_array($_GET['anchor'], array('threadperm', 'postperm', 'modcpperm', 'portalperm', 'otherperm', 'spaceperm')) ? $_GET['anchor'] : 'threadperm';
$anchorarray = array(
array('admingroup_edit_threadperm', 'threadperm', $_GET['anchor'] == 'threadperm'),
array('admingroup_edit_postperm', 'postperm', $_GET['anchor'] == 'postperm'),
array('admingroup_edit_modcpperm', 'modcpperm', $_GET['anchor'] == 'modcpperm'),
array('admingroup_edit_spaceperm', 'spaceperm', $_GET['anchor'] == 'spaceperm'),
array('admingroup_edit_portalperm', 'portalperm', $_GET['anchor'] == 'portalperm'),
array('admingroup_edit_otherperm', 'otherperm', $_GET['anchor'] == 'otherperm'),
);
showformheader('', '', 'menuform', 'get');
showhiddenfields(array('action' => 'admingroup', 'operation' => 'edit'));
showsubmenuanchors($lang['admingroup_edit'].(count($mgroup) == 1 ? ' - '.$mgroup[$_GET['id']]['grouptitle'].'(groupid:'.$mgroup[$_GET['id']]['groupid'].')' : ''), $anchorarray, $gselect);
showformfooter();
if($multiset) {
showtips('setting_multi_tips');
}
showformheader("admingroup&operation=edit&id={$_GET['id']}");
if($multiset) {
$_G['showsetting_multi'] = 0;
$_G['showsetting_multicount'] = count($mgroup);
foreach($mgroup as $group) {
$_G['showtableheader_multi'][] = '<a href="javascript:;" onclick="location.href=\''.ADMINSCRIPT.'?action=admingroup&operation=edit&id='.$group['groupid'].'&anchor=\'+$(\'cpform\').anchor.value;return false">'.$group['grouptitle'].'(groupid:'.$group['groupid'].')</a>';
}
}
$mgids = array();
foreach($mgroup as $group) {
$_GET['id'] = $gid = $group['groupid'];
$mgids[] = $gid;
showmultititle();
showtableheader('', 'nobottom');
showtagheader('tbody', 'threadperm', $_GET['anchor'] == 'threadperm');
showtitle('admingroup_edit_threadperm');
showsetting('admingroup_edit_stick_thread', array('allowstickthreadnew', array(
array(0, $lang['admingroup_edit_stick_thread_none']),
array(1, $lang['admingroup_edit_stick_thread_1']),
array(2, $lang['admingroup_edit_stick_thread_2']),
array(3, $lang['admingroup_edit_stick_thread_3'])
)), $group['allowstickthread'], 'mradio');
showsetting('admingroup_edit_digest_thread', array('allowdigestthreadnew', array(
array(0, $lang['admingroup_edit_digest_thread_none']),
array(1, $lang['admingroup_edit_digest_thread_1']),
array(2, $lang['admingroup_edit_digest_thread_2']),
array(3, $lang['admingroup_edit_digest_thread_3'])
)), $group['allowdigestthread'], 'mradio');
showsetting('admingroup_edit_bump_thread', 'allowbumpthreadnew', $group['allowbumpthread'], 'radio');
showsetting('admingroup_edit_highlight_thread', 'allowhighlightthreadnew', $group['allowhighlightthread'], 'radio');
showsetting('admingroup_edit_live_thread', 'allowlivethreadnew', $group['allowlivethread'], 'radio');
showsetting('admingroup_edit_recommend_thread', 'allowrecommendthreadnew', $group['allowrecommendthread'], 'radio');
showsetting('admingroup_edit_stamp_thread', 'allowstampthreadnew', $group['allowstampthread'], 'radio');
showsetting('admingroup_edit_stamp_list', 'allowstamplistnew', $group['allowstamplist'], 'radio');
showsetting('admingroup_edit_close_thread', 'allowclosethreadnew', $group['allowclosethread'], 'radio');
showsetting('admingroup_edit_move_thread', 'allowmovethreadnew', $group['allowmovethread'], 'radio');
showsetting('admingroup_edit_edittype_thread', 'allowedittypethreadnew', $group['allowedittypethread'], 'radio');
showsetting('admingroup_edit_copy_thread', 'allowcopythreadnew', $group['allowcopythread'], 'radio');
showsetting('admingroup_edit_merge_thread', 'allowmergethreadnew', $group['allowmergethread'], 'radio');
showsetting('admingroup_edit_split_thread', 'allowsplitthreadnew', $group['allowsplitthread'], 'radio');
showsetting('admingroup_edit_repair_thread', 'allowrepairthreadnew', $group['allowrepairthread'], 'radio');
showsetting('admingroup_edit_refund', 'allowrefundnew', $group['allowrefund'], 'radio');
showsetting('admingroup_edit_edit_poll', 'alloweditpollnew', $group['alloweditpoll'], 'radio');
showsetting('admingroup_edit_remove_reward', 'allowremoverewardnew', $group['allowremovereward'], 'radio');
showsetting('admingroup_edit_edit_activity', 'alloweditactivitynew', $group['alloweditactivity'], 'radio');
showsetting('admingroup_edit_edit_trade', 'allowedittradenew', $group['allowedittrade'], 'radio');
showsetting('admingroup_edit_usertag', 'alloweditusertagnew', $group['alloweditusertag'], 'radio');
showtagfooter('tbody');
showtagheader('tbody', 'postperm', $_GET['anchor'] == 'postperm');
showtitle('admingroup_edit_postperm');
showsetting('admingroup_edit_edit_post', 'alloweditpostnew', $group['alloweditpost'], 'radio');
showsetting('admingroup_edit_warn_post', 'allowwarnpostnew', $group['allowwarnpost'], 'radio');
showsetting('admingroup_edit_ban_post', 'allowbanpostnew', $group['allowbanpost'], 'radio');
showsetting('admingroup_edit_del_post', 'allowdelpostnew', $group['allowdelpost'], 'radio');
showsetting('admingroup_edit_stick_post', 'allowstickreplynew', $group['allowstickreply'], 'radio');
showsetting('admingroup_edit_manage_tag', 'allowmanagetagnew', $group['allowmanagetag'], 'radio');
showtagfooter('tbody');
showtagheader('tbody', 'modcpperm', $_GET['anchor'] == 'modcpperm');
showtitle('admingroup_edit_modcpperm');
showsetting('admingroup_edit_mod_post', 'allowmodpostnew', $group['allowmodpost'], 'radio');
showsetting('admingroup_edit_mod_user', 'allowmodusernew', $group['allowmoduser'], 'radio');
showsetting('admingroup_edit_ban_user', 'allowbanusernew', $group['allowbanuser'], 'radio');
showsetting('admingroup_edit_ban_user_visit', 'allowbanvisitusernew', $group['allowbanvisituser'], 'radio');
showsetting('admingroup_edit_ban_ip', 'allowbanipnew', $group['allowbanip'], 'radio');
showsetting('admingroup_edit_edit_user', 'alloweditusernew', $group['allowedituser'], 'radio');
showsetting('admingroup_edit_mass_prune', 'allowmassprunenew', $group['allowmassprune'], 'radio');
showsetting('admingroup_edit_edit_forum', 'alloweditforumnew', $group['alloweditforum'], 'radio');
showsetting('admingroup_edit_post_announce', 'allowpostannouncenew', $group['allowpostannounce'], 'radio');
showsetting('admingroup_edit_clear_recycle', 'allowclearrecyclenew', $group['allowclearrecycle'], 'radio');
showsetting('admingroup_edit_view_log', 'allowviewlognew', $group['allowviewlog'], 'radio');
showtagfooter('tbody');
showtagheader('tbody', 'spaceperm', $_GET['anchor'] == 'spaceperm');
showtitle('admingroup_edit_spaceperm');
showsetting('admingroup_edit_manage_feed', 'managefeednew', $group['managefeed'], 'radio');
showsetting('admingroup_edit_manage_doing', 'managedoingnew', $group['managedoing'], 'radio');
showsetting('admingroup_edit_manage_share', 'managesharenew', $group['manageshare'], 'radio');
showsetting('admingroup_edit_manage_blog', 'manageblognew', $group['manageblog'], 'radio');
showsetting('admingroup_edit_manage_album', 'managealbumnew', $group['managealbum'], 'radio');
showsetting('admingroup_edit_manage_comment', 'managecommentnew', $group['managecomment'], 'radio');
showsetting('admingroup_edit_manage_magiclog', 'managemagiclognew', $group['managemagiclog'], 'radio');
showsetting('admingroup_edit_manage_report', 'managereportnew', $group['managereport'], 'radio');
showsetting('admingroup_edit_manage_hotuser', 'managehotusernew', $group['managehotuser'], 'radio');
showsetting('admingroup_edit_manage_defaultuser', 'managedefaultusernew', $group['managedefaultuser'], 'radio');
showsetting('admingroup_edit_manage_magic', 'managemagicnew', $group['managemagic'], 'radio');
showsetting('admingroup_edit_manage_click', 'manageclicknew', $group['manageclick'], 'radio');
showtagfooter('tbody');
showtagheader('tbody', 'otherperm', $_GET['anchor'] == 'otherperm');
showtitle('admingroup_edit_otherperm');
showsetting('admingroup_edit_view_ip', 'allowviewipnew', $group['allowviewip'], 'radio');
showsetting('admingroup_edit_manage_collection', 'allowmanagecollectionnew', $group['allowmanagecollection'], 'radio');
showsetting('admingroup_edit_allow_make_html', 'allowmakehtmlnew', $group['allowmakehtml'], 'radio');
showtagfooter('tbody');
showtablefooter();
showtagheader('div', 'portalperm', $_GET['anchor'] == 'portalperm');
showtableheader('', 'nobottom');
showtagheader('tbody', '', true);
showtitle('admingroup_edit_portalperm');
showsetting('admingroup_edit_manage_article', 'allowmanagearticlenew', $group['allowmanagearticle'], 'radio');
showtagfooter('tbody');
showtagheader('tbody', '', true);
showsetting('admingroup_edit_add_topic', 'allowaddtopicnew', $group['allowaddtopic'], 'radio');
showsetting('admingroup_edit_manage_topic', 'allowmanagetopicnew', $group['allowmanagetopic'], 'radio');
showsetting('admingroup_edit_diy', 'allowdiynew', $group['allowdiy'], 'radio');
showtagfooter('tbody');
showtablefooter();
showtagfooter('div');
showtableheader();
showsubmit('groupsubmit');
showtablefooter();
$_G['showsetting_multi']++;
}
if($_G['showsetting_multicount'] > 1) {
showhiddenfields(array('multi' => implode(',', $mgids)));
showmulti();
}
showformfooter();
} else {
if(!$multiset) {
$_GET['multinew'] = array(0 => array('single' => 1));
}
foreach($_GET['multinew'] as $k => $row) {
if(empty($row['single'])) {
foreach($row as $key => $value) {
$_GET[''.$key] = $value;
}
$_GET['id'] = $_GET['multi'][$k];
}
$group = $mgroup[$k];
$data = array(
'alloweditpost' => $_GET['alloweditpostnew'],
'alloweditpoll' => $_GET['alloweditpollnew'],
'allowedittrade' => $_GET['allowedittradenew'],
'alloweditusertag' => $_GET['alloweditusertagnew'],
'allowremovereward' => $_GET['allowremoverewardnew'],
'alloweditactivity' => $_GET['alloweditactivitynew'],
'allowstickthread' => $_GET['allowstickthreadnew'],
'allowmodpost' => $_GET['allowmodpostnew'],
'allowbanpost' => $_GET['allowbanpostnew'],
'allowdelpost' => $_GET['allowdelpostnew'],
'allowmassprune' => $_GET['allowmassprunenew'],
'allowrefund' => $_GET['allowrefundnew'],
'allowcensorword' => $_GET['allowcensorwordnew'],
'allowviewip' => $_GET['allowviewipnew'],
'allowmanagecollection' => $_GET['allowmanagecollectionnew'],
'allowbanip' => $_GET['allowbanipnew'],
'allowedituser' => $_GET['alloweditusernew'],
'allowbanuser' => $_GET['allowbanusernew'],
'allowbanvisituser' => $_GET['allowbanvisitusernew'],
'allowmoduser' => $_GET['allowmodusernew'],
'allowpostannounce' => $_GET['allowpostannouncenew'],
'allowclearrecycle' => $_GET['allowclearrecyclenew'],
'allowhighlightthread' => $_GET['allowhighlightthreadnew'],
'allowlivethread' => $_GET['allowlivethreadnew'],
'allowdigestthread' => $_GET['allowdigestthreadnew'],
'allowrecommendthread' => $_GET['allowrecommendthreadnew'],
'allowbumpthread' => $_GET['allowbumpthreadnew'],
'allowclosethread' => $_GET['allowclosethreadnew'],
'allowmovethread' => $_GET['allowmovethreadnew'],
'allowedittypethread' => $_GET['allowedittypethreadnew'],
'allowstampthread' => $_GET['allowstampthreadnew'],
'allowstamplist' => $_GET['allowstamplistnew'],
'allowcopythread' => $_GET['allowcopythreadnew'],
'allowmergethread' => $_GET['allowmergethreadnew'],
'allowsplitthread' => $_GET['allowsplitthreadnew'],
'allowrepairthread' => $_GET['allowrepairthreadnew'],
'allowwarnpost' => $_GET['allowwarnpostnew'],
'alloweditforum' => $_GET['alloweditforumnew'],
'allowviewlog' => $_GET['allowviewlognew'],
'allowmanagearticle' => $_GET['allowmanagearticlenew'],
'allowaddtopic' => $_GET['allowaddtopicnew'],
'allowmanagetopic' => $_GET['allowmanagetopicnew'],
'allowdiy' => $_GET['allowdiynew'],
'allowstickreply' => $_GET['allowstickreplynew'],
'allowmanagetag' => $_GET['allowmanagetagnew'],
'managefeed' => $_GET['managefeednew'],
'managedoing' => $_GET['managedoingnew'],
'manageshare' => $_GET['managesharenew'],
'manageblog' => $_GET['manageblognew'],
'managealbum' => $_GET['managealbumnew'],
'managecomment' => $_GET['managecommentnew'],
'managemagiclog' => $_GET['managemagiclognew'],
'managereport' => $_GET['managereportnew'],
'managehotuser' => $_GET['managehotusernew'],
'managedefaultuser' => $_GET['managedefaultusernew'],
'managemagic' => $_GET['managemagicnew'],
'manageclick' => $_GET['manageclicknew'],
'allowmakehtml' => $_GET['allowmakehtmlnew'],
);
C::t('common_admingroup')->update($_GET['id'], array_map('intval', $data));
}
updatecache(array('usergroups', 'groupreadaccess', 'admingroups'));
cpmsg('admingroups_edit_succeed', 'action=admingroup&operation=edit&'.($multiset ? 'multi='.implode(',', $_GET['multi']) : 'id='.$_GET['id']).'&anchor='.$_GET['anchor'], 'succeed');
}
}
function deletegroupcache($groupidarray) {
if(!empty($groupidarray) && is_array($groupidarray)) {
$cachenames = array();
foreach ($groupidarray as $id) {
if(($id = dintval($id))) {
$cachenames['usergroup_'.$id] = 'usergroup_'.$id;
$cachenames['admingroup_'.$id] = 'admingroup_'.$id;
}
}
if(!empty($cachenames)) {
C::t('common_syscache')->delete_syscache($cachenames);
}
}
}
?>

View File

@@ -0,0 +1,718 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_adv.php 34093 2013-10-09 05:41:18Z nemohou $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$root = '<a href="'.ADMINSCRIPT.'?action=adv">'.cplang('adv_admin').'</a>';
$operation = $operation ? $operation : 'list';
$defaulttargets = array('portal', 'home', 'member', 'forum', 'group', 'plugin');
if(!empty($_GET['preview'])) {
$_GET['advnew'][$_GET['advnew']['style']]['url'] = $_GET['TMPadvnew'.$_GET['advnew']['style']] ? $_GET['TMPadvnew'.$_GET['advnew']['style']] : $_GET['advnew'.$_GET['advnew']['style']];
$data = encodeadvcode($_GET['advnew']);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="<?php echo CHARSET;?>" />
<meta name="renderer" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script type="text/javascript">var IMGDIR = '<?php echo $_G['style']['imgdir']; ?>', cookiepre = '<?php echo $_G['config']['cookie']['cookiepre'];?>', cookiedomain = '<?php echo $_G['config']['cookie']['cookiedomain'];?>', cookiepath = '<?php echo $_G['config']['cookie']['cookiepath'];?>';</script>
<script type="text/javascript" src="<?php echo STATICURL; ?>js/common.js"></script>
<link rel="stylesheet" type="text/css" href="data/cache/style_<?php echo $_G['setting']['styleid'];?>_common.css" />
</head>
<body>
<div id="append_parent"></div><div id="ajaxwaitid"></div>
<div id="hd"><div class="wp">
<?php echo $data;?>
</div></div>
</body>
</html>
<?php
exit;
}
cpheader();
if($operation == 'ad') {
if(!submitcheck('advsubmit')) {
shownav('extended', 'adv_admin');
$type = $_GET['type'];
$target = $_GET['target'];
$typeadd = $advfile = '';
if($type) {
$etype = explode(':', $type);
if(count($etype) > 1 && preg_match('/^[\w\_:]+$/', $type)) {
if(ispluginkey($etype[0]) && preg_match('/^\w$/', $etype[1])) {
$advfile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/adv/adv_'.$etype[1].'.php';
$advclass = 'adv_'.$etype[1];
}
} else {
$advfile = libfile('adv/'.$type, 'class');
$advclass = 'adv_'.$type;
}
if($advfile && file_exists($advfile)) {
require_once $advfile;
$advclassv = new $advclass();
if(class_exists($advclass)) {
$advsetting = $advclassv->getsetting();
$typeadd = ' - '.lang('adv/'.$type, $advclassv->name);
if($type == 'custom') {
$typeadd .= ' '.$advclassv->customname;
}
$typeadd .= ' <a href="'.ADMINSCRIPT.'?action=adv&operation=ad" style="font-weight:normal;font-size:12px">('.cplang('adv_admin_listall').')</a>';
}
}
}
showsubmenu($root.' &raquo; '.cplang('adv_list').$typeadd);
showformheader('adv&operation=ad');
showtableheader('', 'fixpadding');
showsubtitle(array('', 'display_order', 'available', 'subject', !$type ? 'type' : '', 'adv_style', 'start_time', 'end_time', 'adv_targets', ''));
$advppp = $type != 'custom' ? 25 : 9999;
$conditions = '';
$order_by = 'displayorder, advid DESC, targets DESC';
$start_limit = ($page - 1) * $advppp;
$title = $_GET['title'];
$starttime = $_GET['starttime'];
$endtime = $_GET['endtime'];
$orderby = $_GET['orderby'];
$advnum = C::t('common_advertisement')->count_search($title, $starttime, $endtime, $type, $target);
if(!$type) {
$customadv = array();
foreach(C::t('common_advertisement_custom')->fetch_all_data() as $custom) {
$customadv[$custom['id']] = $custom['name'];
}
}
$typenames = array();
foreach(C::t('common_advertisement')->fetch_all_search($title, $starttime, $endtime, $type, $target, $orderby, $start_limit, $advppp) as $adv) {
if(!$type) {
$advfile = '';
$etype = explode(':', $adv['type']);
if(count($etype) > 1 && preg_match('/^[\w\_:]+$/', $adv['type'])) {
$advfile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/adv/adv_'.$etype[1].'.php';
$advclass = 'adv_'.$etype[1];
} else {
$advfile = libfile('adv/'.$adv['type'], 'class');
$advclass = 'adv_'.$adv['type'];
}
if(!$advfile || !file_exists($advfile)) {
continue;
}
if(!isset($typenames[$adv['type']])) {
require_once $advfile;
if(class_exists($advclass)) {
$advclassv = new $advclass();
$typenames[$adv['type']] = lang('adv/'.$adv['type'], $advclassv->name);
} else {
$typenames[$adv['type']] = $adv['type'];
}
}
}
$adv['parameters'] = dunserialize($adv['parameters']);
if($adv['type'] == 'custom' && $type && $_GET['customid'] != $adv['parameters']['extra']['customid']) {
continue;
}
$targets = array();
foreach(explode("\t", $adv['targets']) as $t) {
if('adv_edit_targets_'.$t != 'adv_edit_targets_custom') {
$targets[] = $lang['adv_edit_targets_'.$t] ? $lang['adv_edit_targets_'.$t] : $t;
}
}
showtablerow('', array('class="td25"', 'class="td25"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"{$adv['advid']}\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[{$adv['advid']}]\" value=\"{$adv['displayorder']}\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[{$adv['advid']}]\" value=\"1\" ".($adv['available'] ? 'checked' : '').">",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"titlenew[{$adv['advid']}]\" value=\"".dhtmlspecialchars($adv['title'])."\">",
!$type ? '<a href="'.ADMINSCRIPT.'?action=adv&operation=ad&type='.$adv['type'].($adv['type'] != 'custom' ? '' : '&customid='.$adv['parameters']['extra']['customid']).'">'.$typenames[$adv['type']].($adv['type'] != 'custom' ? '' : ' '.$customadv[$adv['parameters']['extra']['customid']]).'</a>' : '',
$lang['adv_style_'.$adv['parameters']['style']],
$adv['starttime'] ? dgmdate($adv['starttime'], 'd') : $lang['unlimited'],
$adv['endtime'] ? dgmdate($adv['endtime'], 'd') : $lang['unlimited'],
$adv['type'] != 'custom' ? implode(', ', $targets) : $lang['custom'],
"<a href=\"".ADMINSCRIPT."?action=adv&operation=edit&advid={$adv['advid']}".($adv['type'] != 'custom' ? '' : '&customid='.$adv['parameters']['extra']['customid']).(!$type ? '&from=all' : '')."\" class=\"act\">{$lang['edit']}</a>"
));
}
$multipage = multi($advnum, $advppp, $page, ADMINSCRIPT.'?action=adv&operation=ad'.($type ? '&type='.rawurlencode($type) : '').($target ? '&target='.rawurlencode($target) : '').($title ? '&title='.rawurlencode($title) : '').($starttime ? "&starttime=$starttime" : '').($endtime ? "&endtime=$endtime" : '').($orderby ? "&orderby=$orderby" : ''), 0, 3, TRUE, TRUE);
$starttimecheck = array($starttime => 'selected="selected"');
$endtimecheck = array($endtime => 'selected="selected"');
$orderbycheck = array($orderby => 'selected="selected"');
$targetselect = '<select name="target"><option value="">'.$lang['adv_targets'].'</option>';
foreach($defaulttargets as $v) {
$targetselect .= '<option value="'.$v.'"'.($v == $target ? ' selected="selected"' : '').'>'.$lang['adv_edit_targets_'.$v].'</option>';
}
$targetselect .= '</select>';
showsubmit('advsubmit', 'submit', 'del', $type ? '<input type="button" class="btn" onclick="location.href=\''.ADMINSCRIPT.'?action=adv&operation=add&type='.$_GET['type'].($_GET['type'] != 'custom' ? '' : '&customid='.$_GET['customid']).'\'" value="'.cplang('add').'" />' : '', $multipage.'
<input type="text" class="txt" name="title" value="'.$title.'" size="15" onkeyup="if(event.keyCode == 13) this.form.searchsubmit.click()" onclick="this.value=\'\'"> &nbsp;&nbsp;
<select name="starttime">
<option value=""> '.cplang('start_time').'</option>
<option value="0" '.$starttimecheck['0'].'> '.cplang('all').'</option>
<option value="-1" '.$starttimecheck['-1'].'> '.cplang('nolimit').'</option>
<option value="86400" '.$starttimecheck['86400'].'> '.cplang('1_day').'</option>
<option value="604800" '.$starttimecheck['604800'].'> '.cplang('7_day').'</option>
<option value="2592000" '.$starttimecheck['2592000'].'> '.cplang('30_day').'</option>
<option value="7776000" '.$starttimecheck['7776000'].'> '.cplang('90_day').'</option>
<option value="15552000" '.$starttimecheck['15552000'].'> '.cplang('180_day').'</option>
<option value="31536000" '.$starttimecheck['31536000'].'> '.cplang('365_day').'</option>
</select> &nbsp;&nbsp;
<select name="endtime">
<option value=""> '.cplang('end_time').'</option>
<option value="0" '.$endtimecheck['0'].'> '.cplang('all').'</option>
<option value="-1" '.$endtimecheck['-1'].'> '.cplang('nolimit').'</option>
<option value="86400" '.$endtimecheck['86400'].'> '.cplang('1_day').'</option>
<option value="604800" '.$endtimecheck['604800'].'> '.cplang('7_day').'</option>
<option value="2592000" '.$endtimecheck['2592000'].'> '.cplang('30_day').'</option>
<option value="7776000" '.$endtimecheck['7776000'].'> '.cplang('90_day').'</option>
<option value="15552000" '.$endtimecheck['15552000'].'> '.cplang('180_day').'</option>
<option value="31536000" '.$endtimecheck['31536000'].'> '.cplang('365_day').'</option>
</select> &nbsp;&nbsp;
<select name="orderby">
<option value=""> '.cplang('adv_orderby').'</option>
<option value="starttime" '.$orderbycheck['starttime'].'> '.cplang('adv_addtime').'</option>
'.(!$type ? '<option value="type" '.$orderbycheck['type'].'> '.cplang('adv_type').'</option>' : '').'
<option value="displayorder" '.$orderbycheck['displayorder'].'> '.cplang('display_order').'</option>
</select> &nbsp;&nbsp;
'.$targetselect.' &nbsp;&nbsp;
<input type="button" class="btn" name="searchsubmit" value="'.cplang('search').'" onclick="if(this.form.title.value==\''.cplang('adv_inputtitle').'\'){this.form.title.value=\'\'}location.href=\''.ADMINSCRIPT.'?action=adv&operation=ad'.($type ? '&type='.rawurlencode($type) : '').'&title=\'+this.form.title.value+\'&starttime=\'+this.form.starttime.value+\'&endtime=\'+this.form.endtime.value+\'&target=\'+this.form.target.value+\'&orderby=\'+this.form.orderby.value;"> &nbsp;
');
showtablefooter();
showformfooter();
} else {
if($_GET['delete']) {
C::t('common_advertisement')->delete($_GET['delete']);
}
if(is_array($_GET['titlenew'])) {
foreach($_GET['titlenew'] as $advid => $title) {
C::t('common_advertisement')->update($advid, array(
'available' => $_GET['availablenew'][$advid],
'displayorder' => $_GET['displayordernew'][$advid],
'title' => cutstr($_GET['titlenew'][$advid], 50)
));
}
}
updatecache('advs');
updatecache('setting');
cpmsg('adv_update_succeed', dreferer(), 'succeed');
}
} elseif($operation == 'add' && !empty($_GET['type']) || $operation == 'edit' && !empty($_GET['advid'])) {
if(!submitcheck('advsubmit')) {
if($operation == 'edit') {
$advid = $_GET['advid'];
$adv = C::t('common_advertisement')->fetch($advid);
if(!$adv) {
cpmsg('advertisement_nonexistence', '', 'error');
}
$adv['parameters'] = dunserialize($adv['parameters']);
$type = $adv['type'];
} else {
$adv['parameters']['style'] = 'code';
$type = $_GET['type'];
}
$etype = explode(':', $type);
if(count($etype) > 1 && preg_match('/^[\w\_:]+$/', $type)) {
include_once DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/adv/adv_'.$etype[1].'.php';
$advclass = 'adv_'.$etype[1];
} else {
require_once libfile('adv/'.$type, 'class');
$advclass = 'adv_'.$type;
}
$advclass = new $advclass;
$advsetting = $advclass->getsetting();
$advtitle = lang('adv/'.$type, $advclass->name).($type != 'custom' ? '' : ' '.$advclass->customname);
$returnurl = 'action=adv&operation=ad'.(empty($_GET['from']) ? '&type='.$type.($type != 'custom' ? '' : '&customid='.$_GET['customid']) : '');
$return = '<a href="'.ADMINSCRIPT.'?'.$returnurl.'">'.cplang('adv_list').(empty($_GET['from']) ? ' - '.$advtitle : '').'</a>';
shownav('extended', 'adv_admin');
showsubmenu($root.' &raquo; '.$return.' &raquo; '.($operation == 'edit' ? cplang('adv_edit') : cplang('adv_add')));
echo '<br />';
$targets = array();
foreach($advclass->targets as $target) {
if($target != 'custom') {
$targets[] = array($target, $lang['adv_edit_targets_'.$target]);
} else {
$ets = explode("\t", $adv['targets']);
$customv = array();
foreach($ets as $et) {
if(!in_array($et, $advclass->targets)) {
$customv[] = $et;
}
}
$targets[] = array($target, '<input title="'.cplang('adv_custom_target').'" name="advnew[targetcustom]" value="'.implode(',', $customv).'" />');
}
}
$imagesizes = '';
if(!empty($advclass->imagesizes)) {
foreach($advclass->imagesizes as $size) {
$imagesizes .= '<option value="'.$size.'">'.$size.'</option>';
}
}
$adv['starttime'] = $adv['starttime'] ? dgmdate($adv['starttime'], 'Y-n-j') : '';
$adv['endtime'] = $adv['endtime'] ? dgmdate($adv['endtime'], 'Y-n-j') : '';
echo '<script type="text/javascript" src="' . STATICURL . 'js/calendar.js"></script>'.
'<div class="colorbox"><h4>'.lang('adv/'.$type, $advclass->name).'</h4>'.
'<table cellspacing="0" cellpadding="3"><tr><td>'.
(count($etype) > 1 && preg_match('/^[\w\_:]+$/', $type) ? (file_exists(DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/adv/adv_'.$etype[1].'.gif') ? '<img src="source/plugin/'.$etype[0].'/adv/adv_'.$etype[1].'.gif" />' : '')
: (file_exists(DISCUZ_ROOT.'./static/image/admincp/'.$type.'.gif') ? '<img src="static/image/admincp/'.$type.'.gif" />' : '')).
'</td><td valign="top">'.lang('adv/'.$type, $advclass->description).'</td></tr></table>'.
'<div style="width:95%" align="right">'.lang('adv/'.$type, $advclass->copyright).'</div></div>';
if($operation == 'edit') {
echo '<input type="button" class="btn" onclick="$(\'previewbtn\').click()" name="jspreview" value="'.$lang['preview'].'">';
echo '<div class="jswizard" id="advpreview" style="display:none"><iframe id="preview" name="preview" frameborder="0" allowtransparency="true" onload="this.style.height = (this.contentWindow.document.body.scrollHeight + 50) + \'px\'" width="95%" height="0"></iframe></div>';
}
showformheader("adv&operation=$operation".($operation == 'add' ? '&type='.$type : '&advid='.$advid), 'enctype');
if($type == 'custom') {
showhiddenfields(array('parameters[extra][customid]' => $_GET['customid']));
}
showhiddenfields(array('referer' => $returnurl));
showtableheader();
showtableheader(($operation == 'edit' ? cplang('adv_edit') : cplang('adv_add')).' - '.lang('adv/'.$type, $advclass->name), 'fixpadding');
showsetting('adv_edit_title', 'advnew[title]', $adv['title'], 'text');
if($type != 'custom') {
showsetting('adv_edit_targets', array('advnew[targets]', $targets), explode("\t",$adv['targets']), 'mcheckbox');
}
if(is_array($advsetting)) {
foreach($advsetting as $settingvar => $setting) {
if(!empty($setting['value']) && is_array($setting['value'])) {
foreach($setting['value'] as $k => $v) {
$setting['value'][$k][1] = lang('adv/'.$type, $setting['value'][$k][1]);
}
}
$varname = in_array($setting['type'], array('mradio', 'mcheckbox', 'select', 'mselect')) ?
($setting['type'] == 'mselect' ? array('parameters[extra]['.$settingvar.'][]', $setting['value']) : array('parameters[extra]['.$settingvar.']', $setting['value']))
: 'parameters['.$settingvar.']';
$value = $adv['parameters']['extra'][$settingvar] != '' ? $adv['parameters']['extra'][$settingvar] : $setting['default'];
$comment = lang('adv/'.$type, $setting['title'].'_comment');
$comment = $comment != $setting['title'].'_comment' ? $comment : '';
showsetting(lang('adv/'.$type, $setting['title']).':', $varname, $value, $setting['type'], '', 0, $comment);
}
}
$adtypearray = array();
$adtypes = array('code', 'text', 'image', 'flash');
foreach($adtypes as $adtype) {
$displayary = array();
foreach($adtypes as $adtype1) {
$displayary['style_'.$adtype1] = $adtype1 == $adtype ? '' : 'none';
}
$adtypearray[] = array($adtype, $lang['adv_style_'.$adtype], $displayary);
}
showsetting('adv_edit_starttime', 'advnew[starttime]', $adv['starttime'], 'calendar');
showsetting('adv_edit_endtime', 'advnew[endtime]', $adv['endtime'], 'calendar');
showsetting('adv_edit_style', array('advnew[style]', $adtypearray), $adv['parameters']['style'], 'mradio');
showtagheader('tbody', 'style_code', $adv['parameters']['style'] == 'code');
showtitle('adv_edit_style_code');
showsetting('adv_edit_style_code_html', 'advnew[code][html]', $adv['parameters']['html'], 'textarea');
showtagfooter('tbody');
showtagheader('tbody', 'style_text', $adv['parameters']['style'] == 'text');
showtitle('adv_edit_style_text');
showsetting('adv_edit_style_text_title', 'advnew[text][title]', $adv['parameters']['title'], 'htmltext');
showsetting('adv_edit_style_text_link', 'advnew[text][link]', $adv['parameters']['link'], 'text');
showsetting('adv_edit_style_text_size', 'advnew[text][size]', $adv['parameters']['size'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'style_image', $adv['parameters']['style'] == 'image');
showtitle('adv_edit_style_image');
showsetting('adv_edit_style_image_url', 'advnewimage', $adv['parameters']['url'], 'filetext');
showsetting('adv_edit_style_image_link', 'advnew[image][link]', $adv['parameters']['link'], 'text');
showsetting('adv_edit_style_image_alt', 'advnew[image][alt]', $adv['parameters']['alt'], 'text');
if($imagesizes) {
$v = $adv['parameters']['width'].'x'.$adv['parameters']['height'];
showsetting('adv_edit_style_image_size', '', '', '<select onchange="setsize(this.value, \'image\')"><option value="x">'.cplang('adv_edit_style_custom').'</option>'.str_replace('"'.$v.'"', '"'.$v.'" selected="selected"', $imagesizes).'</select>');
}
showsetting('adv_edit_style_image_width', 'advnew[image][width]', $adv['parameters']['width'], 'text', '', 0, '', 'id="imagewidth" onchange="setpreview(\'image\')"');
showsetting('adv_edit_style_image_height', 'advnew[image][height]', $adv['parameters']['height'], 'text', '', 0, '', 'id="imageheight" onchange="setpreview(\'image\')"');
showtagfooter('tbody');
showtagheader('tbody', 'style_flash', $adv['parameters']['style'] == 'flash');
showtitle('adv_edit_style_flash');
showsetting('adv_edit_style_flash_url', 'advnewflash', $adv['parameters']['url'], 'filetext');
if($imagesizes) {
$v = $adv['parameters']['flash'].'x'.$adv['parameters']['flash'];
showsetting('adv_edit_style_flash_size', '', '', '<select onchange="setsize(this.value, \'flash\')"><option>'.cplang('adv_edit_style_custom').'</option>'.str_replace('"'.$v.'"', '"'.$v.'" selected="selected"', $imagesizes).'</select>');
}
showsetting('adv_edit_style_flash_width', 'advnew[flash][width]', $adv['parameters']['width'], 'text', '', 0, '', 'id="flashwidth" onchange="setpreview(\'flash\')"');
showsetting('adv_edit_style_flash_height', 'advnew[flash][height]', $adv['parameters']['height'], 'text', '', 0, '', 'id="flashheight" onchange="setpreview(\'flash\')"');
showtagfooter('tbody');
echo '<tr><td colspan="2">';
if($operation == 'edit') {
echo '<input id="previewbtn" type="button" class="btn" onclick="$(\'advpreview\').style.display=\'\';this.form.preview.value=1;this.form.target=\'preview\';this.form.submit();" name="jspreview" value="'.$lang['preview'].'">&nbsp; &nbsp;';
}
echo '<input type="submit" class="btn" name="advsubmit" onclick="this.form.preview.value=0;this.form.target=\'\'" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="0"></td></tr>';
showtablefooter();
showtableheader();
echo '<tr><td colspan="2" id="imagesizepreviewtd" style="border:0"><div id="imagesizepreview" style="display:none;border:1px dotted gray"></div></td></tr>';
echo '<tr><td colspan="2" id="flashsizepreviewtd" style="border:0"><div id="flashsizepreview" style="display:none;border:1px dotted gray"></div></td></tr>';
showtablefooter();
showformfooter();
echo '<script type="text/JavaScript">
function setsize(v, o) {
if(v) {
var size = v.split(\'x\');
$(o + \'width\').value = size[0];
$(o + \'height\').value = size[1];
}
setpreview(o);
}
function setpreview(o) {
var w = $(o + \'width\').value > 0 ? $(o + \'width\').value : 0;
var h = $(o + \'height\').value > 0 ? $(o + \'height\').value : 0;
var obj = $(o + \'sizepreview\');
var tdobj = $(o + \'sizepreviewtd\');
obj.style.display = \'\';
obj.style.width = w + \'px\';
obj.style.height = h + \'px\';
tdobj.style.height = (parseInt(h) + 10) + \'px\';
}';
if($operation == 'edit' && ($adv['parameters']['style'] == 'image' || $adv['parameters']['style'] == 'flash')) {
echo 'setpreview(\''.$adv['parameters']['style'].'\');';
}
echo '</script>';
} else {
if($operation == 'edit') {
$advid = $_GET['advid'];
$adv = C::t('common_advertisement')->fetch($advid);
$type = $adv['type'];
$adv['parameters'] = dunserialize($adv['parameters']);
} else {
$type = $_GET['type'];
}
$etype = explode(':', $type);
if(count($etype) > 1 && preg_match('/^[\w\_:]+$/', $type)) {
include_once DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/adv/adv_'.$etype[1].'.php';
$advclass = 'adv_'.$etype[1];
} else {
require_once libfile('adv/'.$type, 'class');
$advclass = 'adv_'.$type;
}
$advclass = new $advclass;
$advnew = $_GET['advnew'];
$parameters = !empty($_GET['parameters']) ? $_GET['parameters'] : array();
if(is_array($advnew['targets']) && in_array('custom', $advnew['targets'])) {
$targetcustom = explode(',', $advnew['targetcustom']);
$advnew['targets'] = array_merge($advnew['targets'], $targetcustom);
}
$advclass->setsetting($advnew, $parameters);
$advnew['starttime'] = $advnew['starttime'] ? strtotime($advnew['starttime']) : 0;
$advnew['endtime'] = $advnew['endtime'] ? strtotime($advnew['endtime']) : 0;
if(!$advnew['title']) {
cpmsg('adv_title_invalid', '', 'error');
} elseif(strlen($advnew['title']) > 50) {
cpmsg('adv_title_more', '', 'error');
} elseif($advnew['endtime'] && ($advnew['endtime'] <= TIMESTAMP || $advnew['endtime'] <= $advnew['starttime'])) {
cpmsg('adv_endtime_invalid', '', 'error');
} elseif(($advnew['style'] == 'code' && !$advnew['code']['html'])
|| ($advnew['style'] == 'text' && (!$advnew['text']['title'] || !$advnew['text']['link']))
|| ($advnew['style'] == 'image' && (!$_FILES['advnewimage'] && !$_GET['advnewimage'] || !$advnew['image']['link']))
|| ($advnew['style'] == 'flash' && (!$_FILES['advnewflash'] && !$_GET['advnewflash'] || !$advnew['flash']['width'] || !$advnew['flash']['height']))) {
cpmsg('adv_parameter_invalid', '', 'error');
}
if($operation == 'add') {
$advid = C::t('common_advertisement')->insert(array('available' => 1, 'type' => $type), true);
}
if($advnew['style'] == 'image' || $advnew['style'] == 'flash') {
if($_FILES['advnew'.$advnew['style']]) {
$upload = new discuz_upload();
if($upload->init($_FILES['advnew'.$advnew['style']], 'common') && $upload->save(1)) {
$advnew[$advnew['style']]['url'] = (!strstr($_G['setting']['attachurl'], '://') ? $_G['siteurl'] : '').$_G['setting']['attachurl'].'common/'.$upload->attach['attachment'];
}
} else {
$advnew[$advnew['style']]['url'] = $_GET['advnew'.$advnew['style']];
}
}
$advnew['displayorder'] = isset($advnew['displayorder']) ? implode("\t", $advnew['displayorder']) : '';
$advnew['code'] = encodeadvcode($advnew);
$extra = $type != 'custom' ? '' : '&customid='.$parameters['extra']['customid'];
$advnew['parameters'] = serialize(array_merge(is_array($parameters) ? $parameters : array(), array('style' => $advnew['style']), $advnew['style'] == 'code' ? array() : $advnew[$advnew['style']], array('html' => $advnew['code']), array('displayorder' => $advnew['displayorder'])));
C::t('common_advertisement')->update($advid, array(
'title' => $advnew['title'],
'targets' => $advnew['targets'],
'parameters' => $advnew['parameters'],
'code' => $advnew['code'],
'starttime' => $advnew['starttime'],
'endtime' => $advnew['endtime']
));
updatecache('advs');
updatecache('setting');
cpmsg('adv_succeed', 'action=adv&operation=edit&advid='.$advid.$extra, 'succeed');
}
} elseif($operation == 'setting') {
if(submitcheck('advsubmit')) {
$_GET['advexpirationnew']['allow'] = $_GET['advexpirationnew']['allow'] && $_GET['advexpirationnew']['day'] > 0 && $_GET['advexpirationnew']['method'] && $_GET['advexpirationnew']['users'];
C::t('common_setting')->update_setting('advexpiration', $_GET['advexpirationnew']);
updatecache('setting');
cpmsg('setting_update_succeed', 'action=adv&operation=setting', 'succeed');
} else {
shownav('extended', 'adv_admin');
showsubmenu('adv_admin', array(
array('adv_admin_setting', 'adv&operation=setting', 1),
array('adv_admin_list', 'adv&operation=list', 0),
array('adv_admin_listall', 'adv&operation=ad', 0),
));
$advexpiration = C::t('common_setting')->fetch_setting('advexpiration', true);
showformheader('adv&operation=setting');
showtableheader();
showsetting('adv_setting_advexpiration', 'advexpirationnew[allow]', $advexpiration['allow'], 'radio', 0, 1);
showsetting('adv_setting_advexpiration_day', 'advexpirationnew[day]', $advexpiration['day'], 'text');
showsetting('adv_setting_advexpiration_method', array('advexpirationnew[method]', array(
array('email', cplang('adv_setting_advexpiration_method_email')),
array('notice', cplang('adv_setting_advexpiration_method_notice')),
)), $advexpiration['method'], 'mcheckbox');
showsetting('adv_setting_advexpiration_users', 'advexpirationnew[users]', $advexpiration['users'], 'textarea');
showtagfooter('tbody');
showsubmit('advsubmit');
showtablefooter();
showformfooter();
}
} elseif($operation == 'list') {
shownav('extended', 'adv_admin');
showsubmenu('adv_admin', array(
array('adv_admin_setting', 'adv&operation=setting', 0),
array('adv_admin_list', 'adv&operation=list', 1),
array('adv_admin_listall', 'adv&operation=ad', 0),
));
showtips('adv_list_tip');
$advs = getadvs();
showtableheader('', 'fixpadding');
echo '<tr><td colspan="4">'.$lang['adv_targets'].': &nbsp;&nbsp; ';
foreach($defaulttargets as $target) {
echo '<a href="'.ADMINSCRIPT.'?action=adv&operation=ad&target='.$target.'">'.$lang['adv_edit_targets_'.$target].'</a> &nbsp;&nbsp; ';
}
$row = 4;
$rowwidth = 1 / $row * 100;
$customadv = $ads = array();
$tmp = $advs['adv_custom.php'];
unset($advs['adv_custom.php']);
$advs['adv_custom.php'] = $tmp;
foreach(C::t('common_advertisement')->fetch_all_type() as $ad) {
$ads[$ad['type']] = $ad['count'];
}
foreach(C::t('common_advertisement')->fetch_all_by_type('custom') as $ad) {
$parameters = dunserialize($ad['parameters']);
$ads['custom_'.$parameters['extra']['customid']]++;
}
if($advs) {
$i = $row;
foreach($advs as $adv) {
if($i == $row) {
echo '<tr>';
}
if($adv['class'] == 'custom') {
$customadv = $adv;
$img = file_exists(DISCUZ_ROOT.'./static/image/admincp/'.$customadv['class'].'.gif') ? '<img src="static/image/admincp/'.$customadv['class'].'.gif" /><br />' : '';
echo '<td width="'.$rowwidth.'%" class="hover" align="center">';
echo $img.$lang['adv_custom_add'];
showformheader("adv&operation=custom&do=add");
echo '<input name="addcustom" class="txt" /><input name="submit" class="btn" type="submit" value="'.$lang['submit'].'" />';
showformfooter();
echo '</td>';
} else {
echo '<td width="'.$rowwidth.'%" class="hover" align="center"><a href="'.ADMINSCRIPT.'?action=adv&operation=ad&type='.$adv['class'].'">';
$eclass = explode(':', $adv['class']);
if(count($eclass) > 1) {
echo file_exists(DISCUZ_ROOT.'./source/plugin/'.$eclass[0].'/adv/adv_'.$eclass[1].'.gif') ? '<img src="source/plugin/'.$eclass[0].'/adv/adv_'.$eclass[1].'.gif" /><br />' : '';
} else {
echo file_exists(DISCUZ_ROOT.'./static/image/admincp/'.$adv['class'].'.gif') ? '<img src="static/image/admincp/'.$adv['class'].'.gif" /><br />' : '';
}
echo $adv['name'].($ads[$adv['class']] ? '('.$ads[$adv['class']].')' : '').($adv['filemtime'] > TIMESTAMP - 86400 ? ' <font color="red">New!</font>' : '');
echo '</a></td>';
}
$i--;
if(!$i) {
$i = $row;
}
}
if($i != $row) {
echo str_repeat('<td></td>', $i);
}
} else {
showtablerow('', '', $lang['adv_nonexistence']);
}
if($customadv) {
$img = file_exists(DISCUZ_ROOT.'./static/image/admincp/'.$customadv['class'].'.gif') ? '<img src="static/image/admincp/'.$customadv['class'].'.gif" /><br />' : '';
$i = $row;
foreach(C::t('common_advertisement_custom')->fetch_all_data() as $custom) {
if($i == $row) {
echo '<tr>';
}
echo '<td width="'.$rowwidth.'%" class="hover" align="center"><div id="op_'.$custom['id'].'"><a href="'.ADMINSCRIPT.'?action=adv&operation=ad&type='.$customadv['class'].'&customid='.$custom['id'].'">';
echo $img.$lang['adv_custom'].' '.$custom['name'].($ads['custom_'.$custom['id']] ? '('.$ads['custom_'.$custom['id']].')' : '');
echo '</a><br /><div class="right">';
echo '<a onclick="ajaxget(this.href, \'op_'.$custom['id'].'\');return false;" href="'.ADMINSCRIPT.'?action=adv&operation=custom&do=edit&id='.$custom['id'].'">'.$lang['edit'].'</a>&nbsp;';
echo '<a onclick="ajaxget(this.href, \'op_'.$custom['id'].'\');return false;" href="'.ADMINSCRIPT.'?action=adv&operation=custom&do=delete&id='.$custom['id'].'">'.$lang['delete'].'</a>';
echo '</div></div></td>';
$i--;
if(!$i) {
$i = $row;
}
}
if($i != $row) {
echo str_repeat('<td></td>', $i);
}
}
echo '<tr>'.str_repeat('<td width="'.$rowwidth.'%"></td>', $row).'</tr>';
showtablefooter();
} elseif($operation == 'custom') {
if($do == 'add') {
$addcustom = strip_tags($_GET['addcustom']);
if($addcustom) {
if(!($customid = C::t('common_advertisement_custom')->get_id_by_name($addcustom))) {
$customid = C::t('common_advertisement_custom')->insert(array('name' => $addcustom), true);
}
dheader('location: '.ADMINSCRIPT.'?action=adv&operation=add&type=custom&customid='.$customid);
}
} elseif($do == 'edit') {
$custom = C::t('common_advertisement_custom')->fetch($_GET['id']);
$name = $custom['name'];
if(!submitcheck('submit')) {
ajaxshowheader();
showformheader("adv&operation=custom&do=edit&id={$_GET['id']}");
echo $lang['adv_custom_edit'].'<br /><input name="customnew" class="txt" value="'.dhtmlspecialchars($name).'" />&nbsp;'.
'<input name="submit" class="btn" type="submit" value="'.$lang['submit'].'" />&nbsp;'.
'<input class="btn" type="button" onclick="location.href=\''.ADMINSCRIPT.'?action=adv&operation=list\'" value="'.$lang['cancel'].'" />';
showformfooter();
ajaxshowfooter();
} else {
$customnew = strip_tags($_GET['customnew']);
if($_GET['customnew'] != $name) {
C::t('common_advertisement_custom')->update($_GET['id'], array('name' => $customnew));
}
}
} elseif($do == 'delete') {
if(!submitcheck('submit')) {
ajaxshowheader();
showformheader("adv&operation=custom&do=delete&id={$_GET['id']}");
echo $lang['adv_custom_delete'].'<br /><input name="submit" class="btn" type="submit" value="'.$lang['delete'].'" />&nbsp;'.
'<input class="btn" type="button" onclick="location.href=\''.ADMINSCRIPT.'?action=adv&operation=list\'" value="'.$lang['cancel'].'" />';
showformfooter();
ajaxshowfooter();
} else {
C::t('common_advertisement_custom')->delete($_GET['id']);
}
}
dheader('location: '.ADMINSCRIPT.'?action=adv&operation=list');
}
function encodeadvcode($advnew) {
switch($advnew['style']) {
case 'code':
$advnew['code'] = $advnew['code']['html'];
break;
case 'text':
$advnew['code'] = '<a href="'.$advnew['text']['link'].'" target="_blank" '.($advnew['text']['size'] ? 'style="font-size: '.$advnew['text']['size'].'"' : '').'>'.$advnew['text']['title'].'</a>';
break;
case 'image':
$advnew['code'] = '<a href="'.$advnew['image']['link'].'" target="_blank"><img src="'.$advnew['image']['url'].'"'.($advnew['image']['height'] ? ' height="'.$advnew['image']['height'].'"' : '').($advnew['image']['width'] ? ' width="'.$advnew['image']['width'].'"' : '').($advnew['image']['alt'] ? ' alt="'.$advnew['image']['alt'].'"' : '').' border="0"></a>';
break;
case 'flash':
$advnew['code'] = '<embed width="'.$advnew['flash']['width'].'" height="'.$advnew['flash']['height'].'" src="'.$advnew['flash']['url'].'" type="application/x-shockwave-flash" wmode="transparent"></embed>';
break;
}
return $advnew['code'];
}
function getadvs() {
global $_G;
$checkdirs = array_merge(array(''), $_G['setting']['plugins']['available']);
$advs = array();
foreach($checkdirs as $key) {
if($key) {
$dir = DISCUZ_ROOT.'./source/plugin/'.$key.'/adv';
} else {
$dir = DISCUZ_ROOT.'./source/class/adv';
}
if(!file_exists($dir)) {
continue;
}
$advdir = dir($dir);
while($entry = $advdir->read()) {
if(!in_array($entry, array('.', '..')) && preg_match("/^adv\_[\w\.]+$/", $entry) && substr($entry, -4) == '.php' && strlen($entry) < 30 && is_file($dir.'/'.$entry)) {
@include_once $dir.'/'.$entry;
$advclass = substr($entry, 0, -4);
if(class_exists($advclass)) {
$adv = new $advclass();
$script = substr($advclass, 4);
$script = ($key ? $key.':' : '').$script;
$advs[$entry] = array(
'class' => $script,
'name' => lang('adv/'.$script, $adv->name),
'version' => $adv->version,
'copyright' => lang('adv/'.$script, $adv->copyright),
'filemtime' => @filemtime($dir.'/'.$entry)
);
}
}
}
}
uasort($advs, 'filemtimesort');
return $advs;
}
?>

View File

@@ -0,0 +1,293 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_album.php 27892 2012-02-16 07:24:19Z chenmengshu $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
include_once libfile('function/portalcp');
cpheader();
$detail = $_GET['detail'];
$albumname = $_GET['albumname'];
$albumid = $_GET['albumid'];
$uid = $_GET['uid'];
$users = $_GET['users'];
$starttime = $_GET['starttime'];
$endtime = $_GET['endtime'];
$searchsubmit = $_GET['searchsubmit'];
$albumids = $_GET['albumids'];
$friend = $_GET['friend'];
$orderby = $_GET['orderby'];
$ordersc = $_GET['ordersc'];
$fromumanage = $_GET['fromumanage'] ? 1 : 0;
$muticondition = '';
$muticondition .= $albumname ? '&albumname='.$albumname : '';
$muticondition .= $albumid ? '&albumid='.$albumid : '';
$muticondition .= $uid ? '&uid='.$uid : '';
$muticondition .= $users ? '&users='.$users : '';
$muticondition .= $starttime ? '&starttime='.$starttime : '';
$muticondition .= $endtime ? '&endtime='.$endtime : '';
$muticondition .= $friend ? '&friend='.$friend : '';
$muticondition .= $orderby ? '&orderby='.$orderby : '';
$muticondition .= $ordersc ? '&ordersc='.$ordersc : '';
$muticondition .= $fromumanage ? '&fromumanage='.$fromumanage : '';
$muticondition .= $searchsubmit ? '&searchsubmit='.$searchsubmit : '';
$muticondition .= $_GET['search'] ? '&search='.$_GET['search'] : '';
$muticondition .= $detail ? '&detail='.$detail : '';
if(!submitcheck('albumsubmit')) {
if(empty($_GET['search'])) {
$newlist = 1;
$detail = 1;
}
if($fromumanage) {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? '' : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? '' : $endtime;
} else {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? dgmdate(TIMESTAMP - 86400 * 7, 'Y-n-j') : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? dgmdate(TIMESTAMP, 'Y-n-j') : $endtime;
}
shownav('topic', 'nav_album');
showsubmenu('nav_album', array(
array('newlist', 'album', !empty($newlist)),
array('search', 'album&search=true', empty($newlist)),
));
empty($newlist) && showsubmenusteps('', array(
array('album_search', !$searchsubmit),
array('nav_album', $searchsubmit)
));
if($muticondition) {
showtips('album_tips');
}
$staticurl = STATICURL;
echo <<<EOT
<script type="text/javascript" src="{$staticurl}js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('albumforum').page.value=number;
$('albumforum').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'searchposts', !$searchsubmit && empty($newlist));
showformheader("album".(!empty($_GET['search']) ? '&search=true' : ''), '', 'albumforum');
showhiddenfields(array('page' => $page, 'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']));
showtableheader();
showsetting('album_search_detail', 'detail', $detail, 'radio');
showsetting('album_search_perpage', '', $_GET['perpage'], "<select name='perpage'><option value='20'>{$lang['perpage_20']}</option><option value='50'>{$lang['perpage_50']}</option><option value='100'>{$lang['perpage_100']}</option></select>");
showsetting('resultsort', '', $orderby, "<select name='orderby'><option value=''>{$lang['defaultsort']}</option><option value='dateline'>{$lang['topic_dateline']}</option><option value='updatetime'>{$lang['updatetime']}</option><option value='picnum'>{$lang['pic_num']}</option></select> ");
showsetting('', '', $ordersc, "<select name='ordersc'><option value='desc'>{$lang['orderdesc']}</option><option value='asc'>{$lang['orderasc']}</option></select>", '', 0, '', '', '', true);
showsetting('album_search_albumname', 'albumname', $albumname, 'text');
showsetting('album_search_albumid', 'albumid', $albumid, 'text');
showsetting('album_search_uid', 'uid', $uid, 'text');
showsetting('album_search_user', 'users', $users, 'text');
showsetting('blog_search_friend', '', $friend, "<select name='friend'><option value='0'>{$lang['setting_home_privacy_alluser']}</option><option value='1'>{$lang['setting_home_privacy_friend']}</option><option value='2'>{$lang['setting_home_privacy_specified_friend']}</option><option value='3'>{$lang['setting_home_privacy_self']}</option><option value='4'>{$lang['setting_home_privacy_password']}</option></select>");
showsetting('album_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
echo '<input type="hidden" name="fromumanage" value="'.$fromumanage.'">';
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
if($_GET['albumids']) {
$albumids = authcode($_GET['albumids'], 'DECODE');
$albumidsadd = $albumids ? explode(',', $albumids) : $_GET['delete'];
include_once libfile('function/delete');
$deletecount = count(deletealbums($albumidsadd));
$cpmsg = cplang('album_succeed', array('deletecount' => $deletecount));
} else {
$albums = $catids = array();
$selectalbumids = !empty($_GET['ids']) && is_array($_GET['ids']) ? $_GET['ids'] : array();
if($selectalbumids) {
$query = C::t('home_album')->fetch_all_album($selectalbumids);
foreach($query as $value) {
$albums[$value['albumid']] = $value;
$catids[] = intval($value['catid']);
}
}
if($albums) {
$selectalbumids = array_keys($albums);
if($_POST['optype'] == 'delete') {
include_once libfile('function/delete');
$deletecount = count(deletealbums($selectalbumids));
$cpmsg = cplang('album_succeed', array('deletecount' => $deletecount));
} elseif($_POST['optype'] == 'move') {
$tocatid = intval($_POST['tocatid']);
$catids[] = $tocatid;
$catids = array_merge($catids);
C::t('home_album')->update($selectalbumids, array('catid'=>$tocatid));
foreach($catids as $catid) {
$catid = intval($catid);
$cnt = C::t('home_album')->count_by_catid($catid);
C::t('home_album_category')->update($catid, array('num'=>intval($cnt)));
}
$cpmsg = cplang('album_move_succeed');
} else {
$cpmsg = cplang('album_choose_at_least_one_operation');
}
} else {
$cpmsg = cplang('album_choose_at_least_one_album');
}
}
?>
<script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('albumforum').searchsubmit.click();</script>
<?php
}
if(submitcheck('searchsubmit', 1) || $newlist) {
$albumids = $albumcount = '0';
$sql = $error = '';
$users = trim($users);
if($users != '') {
$uids = array(-1);
$query = C::t('home_album')->fetch_uid_by_username(explode(',', $users));
$uids = array_keys($query) + $uids;
}
if($starttime != '') {
$starttime = strtotime($starttime);
}
if($_G['adminid'] == 1 && $endtime != dgmdate(TIMESTAMP, 'Y-n-j')) {
if($endtime != '') {
$endtime = strtotime($endtime);
}
} else {
$endtime = TIMESTAMP;
}
if($albumid != '') {
$albumids = explode(',', $albumid);
}
if($uid != '') {
$query = C::t('home_album')->fetch_uid_by_uid($uid);
if(!$uids) {
$uids = array_keys($query);
} else {
$uids = array_intersect(array_keys($query), $uids);
}
if(!$uids) {
$uids = array(-1);
}
}
$orderby = $orderby ? $orderby : 'updatetime';
$ordersc = $ordersc ? $ordersc : 'DESC';
if(($_G['adminid'] == 2 && $endtime - $starttime > 86400 * 16) || ($_G['adminid'] == 3 && $endtime - $starttime > 86400 * 8)) {
$error = 'album_mod_range_illegal';
}
if(!$error) {
if($detail) {
$_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
$perpage = $_GET['pp'] ? $_GET['pp'] : $_GET['perpage'];
$query = C::t('home_album')->fetch_all_by_search(1, $uids, $albumname, false, '', $starttime, $endtime, $albumids, $friend, $orderby, $ordersc, (($page - 1) * $perpage), $perpage);
$albums = '';
include_once libfile('function/home');
foreach($query as $album) {
if($album['friend'] != 4 && ckfriend($album['uid'], $album['friend'], $album['target_ids'])) {
$album['pic'] = pic_cover_get($album['pic'], $album['picflag']);
} else {
$album['pic'] = STATICURL.'image/common/nopublish.svg';
}
$album['updatetime'] = dgmdate($album['updatetime']);
switch ($album['friend']) {
case '0':
$privacy_name = $lang['setting_home_privacy_alluser'];
break;
case '1':
$privacy_name = $lang['setting_home_privacy_friend'];
break;
case '2':
$privacy_name = $lang['setting_home_privacy_specified_friend'];
break;
case '3':
$privacy_name = $lang['setting_home_privacy_self'];
break;
case '4':
$privacy_name = $lang['setting_home_privacy_password'];
break;
default:
$privacy_name = $lang['setting_home_privacy_alluser'];
}
$album['friend'] = $album['friend'] ? " <a href=\"".ADMINSCRIPT."?action=album&friend={$album['friend']}\">$privacy_name</a>" : $privacy_name;
$albums .= showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"ids[]\" value=\"{$album['albumid']}\" />",
"<a href=\"home.php?mod=space&uid={$album['uid']}&do=album&id={$album['albumid']}\" target=\"_blank\"><img src='{$album['pic']}' /></a>",
"<a href=\"home.php?mod=space&uid={$album['uid']}&do=album&id={$album['albumid']}\" target=\"_blank\">{$album['albumname']}</a>",
"<a href=\"home.php?mod=space&uid={$album['uid']}\" target=\"_blank\">".$album['username']."</a>",
$album['updatetime'],"<a href=\"".ADMINSCRIPT."?action=pic&albumid={$album['albumid']}\">".$album['picnum']."</a>",
$album['friend']
), TRUE);
}
$albumcount = C::t('home_album')->fetch_all_by_search(3, $uids, $albumname, false, '', $starttime, $endtime, $albumids, $friend);
$multi = multi($albumcount, $perpage, $page, ADMINSCRIPT."?action=album$muticondition");
} else {
$albumcount = 0;
$query = C::t('home_album')->fetch_all_by_search(2, $uids, $albumname, false, '', $starttime, $endtime, $albumids, $friend);
foreach($query as $album) {
$albumids .= ','.$album['albumid'];
$albumcount++;
}
$multi = '';
}
if(!$albumcount) {
$error = 'album_post_nonexistence';
}
}
showtagheader('div', 'postlist', $searchsubmit || $newlist);
showformheader('album&frame=no', 'target="albumframe"');
if(!$muticondition) {
showtableheader(cplang('album_new_result').' '.$albumcount, 'fixpadding');
} else {
showtableheader(cplang('album_result').' '.$albumcount.(empty($newlist) ? ' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';$(\'albumforum\').pp.value=\'\';$(\'albumforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>' : ''), 'fixpadding');
}
if($error) {
echo "<tr><td class=\"lineheight\" colspan=\"15\">$lang[$error]</td></tr>";
} else {
if($detail) {
showsubtitle(array('', 'albumpic', 'albumname', 'author', 'updatetime', 'pic_num', 'privacy'));
echo $albums;
$optypehtml = ''
.'<input type="radio" name="optype" id="optype_delete" value="delete" class="radio" /><label for="optype_delete">'.cplang('delete').'</label>&nbsp;&nbsp;'
;
$optypehtml .= '<input type="radio" name="optype" id="optype_move" value="move" class="radio" /><label for="optype_move">'.cplang('article_opmove').'</label> '
.category_showselect('album', 'tocatid', false)
.'&nbsp;&nbsp;';
showsubmit('', '', '', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'ids\')" /><label for="chkall">'.cplang('select_all').'</label>&nbsp;&nbsp;'.$optypehtml.'<input type="submit" class="btn" name="albumsubmit" value="'.cplang('submit').'" />', $multi);
} else {
showhiddenfields(array('albumids' => authcode($albumids, 'ENCODE')));
showsubmit('albumsubmit', 'delete', $detail ? 'del' : '', '', $multi);
}
}
showtablefooter();
showformfooter();
echo '<iframe name="albumframe" style="display:none;"></iframe>';
showtagfooter('div');
}
?>

View File

@@ -0,0 +1,212 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_albumcategory.php 24658 2011-09-29 09:39:40Z chenmengshu $
*/
if(!defined('IN_DISCUZ') || !defined('IN_DISCUZ')) {
exit('Access Denied');
}
cpheader();
$operation = $operation == 'delete' ? 'delete' : 'list';
loadcache('albumcategory');
$category = $_G['cache']['albumcategory'];
if($operation == 'list') {
if(!submitcheck('editsubmit')) {
shownav('portal', 'albumcategory');
showsubmenu('albumcategory', array(
array('list', 'albumcategory', 1)
));
showformheader('albumcategory');
showtableheader('', 'nobottom');
showsetting('system_category_stat', 'settingnew[albumcategorystat]', $_G['setting']['albumcategorystat'], 'radio', '', 1);
showsetting('system_category_required', 'settingnew[albumcategoryrequired]', $_G['setting']['albumcategoryrequired'], 'radio', '');
echo '<tr><td colspan="2">';
showtableheader();
showsubtitle(array('order', 'albumcategory_name', 'albumcategory_num', 'operation'));
foreach ($category as $key=>$value) {
if($value['level'] == 0) {
echo showcategoryrow($key, 0, '');
}
}
echo '<tr><td class="td25">&nbsp;</td><td colspan="3"><div><a class="addtr" onclick="addrow(this, 0, 0)" href="###">'.cplang('albumcategory_addcategory').'</a></div></td></tr>';
showtablefooter();
echo '</td></tr>';
showtablefooter();
showtableheader('', 'notop');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
$langs = array();
$keys = array('albumcategory_addcategory', 'albumcategory_addsubcategory', 'albumcategory_addthirdcategory');
foreach ($keys as $key) {
$langs[$key] = cplang($key);
}
echo <<<SCRIPT
<script type="text/Javascript">
var rowtypedata = [
[[1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [3, '<div class="parentboard"><input type="text" class="txt" value="{$lang['albumcategory_addcategory']}" name="newname[{1}][]"/></div>']],
[[1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [3, '<div class="board"><input type="text" class="txt" value="{$lang['albumcategory_addsubcategory']}" name="newname[{1}][]"/></div>']],
[[1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [3, '<div class="childboard"><input type="text" class="txt" value="{$lang['albumcategory_addthirdcategory']}" name="newname[{1}][]"/></div>']],
];
</script>
SCRIPT;
} else {
if($_POST['name']) {
foreach($_POST['name'] as $key=>$value) {
$sets = array();
$value = trim($value);
if($category[$key] && $category[$key]['catname'] != $value) {
$sets['catname'] = $value;
}
if($category[$key] && $category[$key]['displayorder'] != $_POST['order'][$key]) {
$sets['displayorder'] = $_POST['order'][$key] ? $_POST['order'][$key] : '0';
}
if($sets) {
C::t('home_album_category')->update($key, $sets);
}
}
}
if($_POST['newname']) {
foreach ($_POST['newname'] as $upid=>$names) {
foreach ($names as $nameid=>$name) {
C::t('home_album_category')->insert(array('upid' => $upid, 'catname' => trim($name), 'displayorder'=>intval($_POST['neworder'][$upid][$nameid])));
}
}
}
if($_POST['settingnew']) {
$_POST['settingnew'] = array_map('intval', $_POST['settingnew']);
C::t('common_setting')->update_batch($_POST['settingnew']);
updatecache('setting');
}
include_once libfile('function/cache');
updatecache('albumcategory');
cpmsg('albumcategory_update_succeed', 'action=albumcategory', 'succeed');
}
} elseif($operation == 'delete') {
if(!$_GET['catid'] || !$category[$_GET['catid']]) {
cpmsg('albumcategory_catgory_not_found', '', 'error');
}
if(!submitcheck('deletesubmit')) {
$a_count = C::t('home_album')->count_by_catid($_GET['catid']);
if(!$a_count && empty($category[$_GET['catid']]['children'])) {
C::t('home_album_category')->delete($_GET['catid']);
include_once libfile('function/cache');
updatecache('albumcategory');
cpmsg('albumcategory_delete_succeed', 'action=albumcategory', 'succeed');
}
shownav('portal', 'albumcategory');
showsubmenu('albumcategory', array(
array('list', 'albumcategory', 0),
array('delete', 'albumcategory&operation=delete&catid='.$_GET['catid'], 1)
));
showformheader('albumcategory&operation=delete&catid='.$_GET['catid']);
showtableheader();
if($category[$_GET['catid']]['children']) {
showsetting('albumcategory_subcategory_moveto', '', '',
'<input type="radio" name="subcat_op" value="trash" id="subcat_op_trash" checked="checked" />'.
'<label for="subcat_op_trash" />'.cplang('albumcategory_subcategory_moveto_trash').'</label>'.
'<input type="radio" name="subcat_op" value="parent" id="subcat_op_parent" checked="checked" />'.
'<label for="subcat_op_parent" />'.cplang('albumcategory_subcategory_moveto_parent').'</label>'
);
}
include_once libfile('function/portalcp');
showsetting('albumcategory_article_moveto', '', '', category_showselect('album', 'tocatid', false, $category[$_GET['catid']]['upid']));
showsubmit('deletesubmit');
showtablefooter();
showformfooter();
} else {
if($_POST['tocatid'] == $_GET['catid']) {
cpmsg('albumcategory_move_category_failed', 'action=albumcategory', 'error');
}
$delids = array($_GET['catid']);
if($category[$_GET['catid']]['children']) {
if($_POST['subcat_op'] == 'parent') {
$upid = intval($category[$_GET['catid']]['upid']);
C::t('home_album_category')->update($category[$_GET['catid']]['children'], array('upid'=>$upid));
} else {
$delids = array_merge($delids, $category[$_GET['catid']]['children']);
foreach ($category[$_GET['catid']]['children'] as $id) {
$value = $category[$id];
if($value['children']) {
$delids = array_merge($delids, $value['children']);
}
}
if(!$category[$_POST['tocatid']] || in_array($_POST['tocatid'], $delids)) {
cpmsg('albumcategory_move_category_failed', 'action=albumcategory', 'error');
}
}
}
if($delids) {
C::t('home_album')->update_by_catid($delids, array('catid' => $_POST['tocatid']));
C::t('home_album_category')->delete($delids);
$num =C::t('home_album')->count_by_catid($_GET['tocatid']);
C::t('home_album_category')->update($_POST['tocatid'], array('num'=>$num));
}
include_once libfile('function/cache');
updatecache('albumcategory');
cpmsg('albumcategory_delete_succeed', 'action=albumcategory', 'succeed');
}
}
function showcategoryrow($key, $level = 0, $last = '') {
global $_G;
loadcache('albumcategory');
$value = $_G['cache']['albumcategory'][$key];
$return = '';
include_once libfile('function/portalcp');
$value['num'] = category_get_num('album', $key);
if($level == 2) {
$class = $last ? 'lastchildboard' : 'childboard';
$return = '<tr class="hover"><td class="td25"><input type="text" class="txt" name="order['.$value['catid'].']" value="'.$value['displayorder'].'" /></td><td><div class="'.$class.'">'.
'<input type="text" name="name['.$value['catid'].']" value="'.$value['catname'].'" class="txt" />'.
'</div>'.
'</td><td>'.$value['num'].'</td><td><a href="'.ADMINSCRIPT.'?action=albumcategory&operation=delete&catid='.$value['catid'].'">'.cplang('delete').'</a></td></tr>';
} elseif($level == 1) {
$return = '<tr class="hover"><td class="td25"><input type="text" class="txt" name="order['.$value['catid'].']" value="'.$value['displayorder'].'" /></td><td><div class="board">'.
'<input type="text" name="name['.$value['catid'].']" value="'.$value['catname'].'" class="txt" />'.
'<a class="addchildboard" onclick="addrowdirect = 1;addrow(this, 2, '.$value['catid'].')" href="###">'.cplang('albumcategory_addthirdcategory').'</a></div>'.
'</td><td>'.$value['num'].'</td><td><a href="'.ADMINSCRIPT.'?action=albumcategory&operation=delete&catid='.$value['catid'].'">'.cplang('delete').'</a></td></tr>';
for($i=0,$L=(is_array($value['children']) ? count($value['children']) : 0); $i<$L; $i++) {
$return .= showcategoryrow($value['children'][$i], 2, $i==$L-1);
}
} else {
$return = '<tr class="hover"><td class="td25"><input type="text" class="txt" name="order['.$value['catid'].']" value="'.$value['displayorder'].'" /></td><td><div class="parentboard">'.
'<input type="text" name="name['.$value['catid'].']" value="'.$value['catname'].'" class="txt" />'.
'</div>'.
'</td><td>'.$value['num'].'</td><td><a href="'.ADMINSCRIPT.'?action=albumcategory&operation=delete&catid='.$value['catid'].'">'.cplang('delete').'</a></td></tr>';
for($i=0,$L=(is_array($value['children']) ? count($value['children']) : 0); $i<$L; $i++) {
$return .= showcategoryrow($value['children'][$i], 1, '');
}
$return .= '<tr><td class="td25"></td><td colspan="3"><div class="lastboard"><a class="addtr" onclick="addrow(this, 1, '.$value['catid'].')" href="###">'.cplang('albumcategory_addsubcategory').'</a></div>';
}
return $return;
}
?>

View File

@@ -0,0 +1,208 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_announce.php 33271 2013-05-13 08:16:21Z kamichen $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(empty($operation)) {
if(!submitcheck('announcesubmit')) {
shownav('extended', 'announce', 'admin');
showsubmenu('announce', array(
array('admin', 'announce', 1),
array('add', 'announce&operation=add', 0)
));
showtips('announce_tips');
showformheader('announce');
showtableheader();
showsubtitle(array('del', 'display_order', 'author', 'subject', 'message', 'announce_type', 'start_time', 'end_time', ''));
$announce_type = array(0=>$lang['announce_words'], 1=>$lang['announce_url']);
$annlist = C::t('forum_announcement')->fetch_all_by_displayorder();
foreach ($annlist as $announce) {
$disabled = $_G['adminid'] != 1 && $announce['author'] != $_G['member']['username'] ? 'disabled' : NULL;
$announce['starttime'] = $announce['starttime'] ? dgmdate($announce['starttime'], 'Y-n-j H:i') : $lang['unlimited'];
$announce['endtime'] = $announce['endtime'] ? dgmdate($announce['endtime'], 'Y-n-j H:i') : $lang['unlimited'];
showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"{$announce['id']}\" $disabled>",
"<input type=\"text\" class=\"txt\" name=\"displayordernew[{$announce['id']}]\" value=\"{$announce['displayorder']}\" size=\"2\" $disabled>",
"<a href=\"./home.php?mod=space&username=".rawurlencode($announce['author'])."\" target=\"_blank\">{$announce['author']}</a>",
$announce['subject'],
cutstr(strip_tags($announce['message']), 20),
$announce_type[$announce['type']],
$announce['starttime'],
$announce['endtime'],
"<a href=\"".ADMINSCRIPT."?action=announce&operation=edit&announceid={$announce['id']}\" $disabled>{$lang['edit']}</a>"
));
}
showsubmit('announcesubmit', 'submit', 'select_all');
showtablefooter();
showformfooter();
} else {
if(is_array($_GET['delete'])) {
C::t('forum_announcement')->delete_by_id_username($_GET['delete'], $_G['username'], $_G['adminid']);
}
if(is_array($_GET['displayordernew'])) {
foreach($_GET['displayordernew'] as $id => $displayorder) {
C::t('forum_announcement')->update_displayorder_by_id_username($id, $displayorder, $_G['username'], $_G['adminid']);
}
}
updatecache(array('announcements', 'announcements_forum'));
cpmsg('announce_update_succeed', 'action=announce', 'succeed');
}
} elseif($operation == 'add') {
if(!submitcheck('addsubmit')) {
$newstarttime = dgmdate(TIMESTAMP, 'Y-n-j H:i');
$newendtime = dgmdate(TIMESTAMP + 86400* 7, 'Y-n-j H:i');
shownav('extended', 'announce', 'add');
showsubmenu('announce', array(
array('admin', 'announce', 0),
array('add', 'announce&operation=add', 1)
));
showformheader('announce&operation=add');
showtableheader('announce_add');
showsetting($lang['subject'], 'newsubject', '', 'htmltext');
showsetting($lang['start_time'], 'newstarttime', $newstarttime, 'calendar', '', 0, '', 1);
showsetting($lang['end_time'], 'newendtime', $newendtime, 'calendar', '', 0, '', 1);
showsetting('announce_type', array('newtype', array(
array(0, $lang['announce_words']),
array(1, $lang['announce_url']))), 0, 'mradio');
showsetting('announce_message', 'newmessage', '', 'textarea');
showsubmit('addsubmit');
showtablefooter();
showformfooter();
} else {
$newstarttime = $_GET['newstarttime'] ? strtotime($_GET['newstarttime']) : 0;
$newendtime = $_GET['newendtime'] ? strtotime($_GET['newendtime']) : 0;
if($newendtime && $newstarttime > $newendtime) {
cpmsg('announce_time_invalid', '', 'error');
}
$newsubject = trim($_GET['newsubject']);
$newmessage = trim($_GET['newmessage']);
if(!$newstarttime) {
cpmsg('announce_time_invalid', '', 'error');
} elseif(!$newsubject || !$newmessage) {
cpmsg('announce_invalid', '', 'error');
} else {
$newmessage = $_GET['newtype'] == 1 ? explode("\n", $_GET['newmessage']) : array(0 => $_GET['newmessage']);
$data = array(
'author' => $_G['username'],
'subject' => strip_tags($newsubject, '<u><i><b><font>'),
'type' => $_GET['newtype'],
'starttime' => $newstarttime,
'endtime' => $newendtime,
'message' => $newmessage[0],
);
C::t('forum_announcement')->insert($data);
updatecache(array('announcements', 'announcements_forum'));
cpmsg('announce_succeed', 'action=announce', 'succeed');
}
}
} elseif($operation == 'edit' && $_GET['announceid']) {
$announce = C::t('forum_announcement')->fetch_by_id_username($_GET['announceid'], $_G['username'], $_G['adminid']);
if(!$announce) {
cpmsg('announce_nonexistence', '', 'error');
}
if(!submitcheck('editsubmit')) {
$announce['starttime'] = $announce['starttime'] ? dgmdate($announce['starttime'], 'Y-n-j H:i') : "";
$announce['endtime'] = $announce['endtime'] ? dgmdate($announce['endtime'], 'Y-n-j H:i') : "";
$b = $i = $u = $colorselect = $colorcheck = '';
if(preg_match('/<b>(.*?)<\/b>/i', $announce['subject'])) {
$b = 'class="a"';
}
if(preg_match('/<i>(.*?)<\/i>/i', $announce['subject'])) {
$i = 'class="a"';
}
if(preg_match('/<u>(.*?)<\/u>/i', $announce['subject'])) {
$u = 'class="a"';
}
$colorselect = preg_replace('/<font color=(.*?)>(.*?)<\/font>/i', '$1', $announce['subject']);
$colorselect = strip_tags($colorselect);
$_G['forum_colorarray'] = array(1=>'#EE1B2E', 2=>'#EE5023', 3=>'#996600', 4=>'#3C9D40', 5=>'#2897C5', 6=>'#2B65B7', 7=>'#8F2A90', 8=>'#EC1282');
if(in_array($colorselect, $_G['forum_colorarray'])) {
$colorcheck = "style=\"background: $colorselect\"";
}
shownav('extended', 'announce');
showsubmenu('announce', array(
array('admin', 'announce', 0),
array('add', 'announce&operation=add', 0)
));
showformheader("announce&operation=edit&announceid={$_GET['announceid']}");
showtableheader();
showtitle('announce_edit');
showsetting($lang['subject'], 'newsubject', $announce['subject'], 'htmltext');
showsetting('start_time', 'starttimenew', $announce['starttime'], 'calendar', '', 0, '', 1);
showsetting('end_time', 'endtimenew', $announce['endtime'], 'calendar', '', 0, '', 1);
showsetting('announce_type', array('typenew', array(
array(0, $lang['announce_words']),
array(1, $lang['announce_url'])
)), $announce['type'], 'mradio');
showsetting('announce_message', 'messagenew', $announce['message'], 'textarea');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
if(strpos($_GET['starttimenew'], '-')) {
$starttimenew = strtotime($_GET['starttimenew']);
} else {
$starttimenew = 0;
}
if(strpos($_GET['endtimenew'], '-')) {
$endtimenew = strtotime($_GET['endtimenew']);
} else {
$endtimenew = 0;
}
$subjectnew = trim($_GET['newsubject']);
$messagenew = trim($_GET['messagenew']);
if(!$starttimenew || ($endtimenew && $endtimenew <= TIMESTAMP) || $endtimenew && $starttimenew > $endtimenew) {
cpmsg('announce_time_invalid', '', 'error');
} elseif(!$subjectnew || !$messagenew) {
cpmsg('announce_invalid', '', 'error');
} else {
$messagenew = $_GET['typenew'] == 1 ? explode("\n", $messagenew) : array(0 => $messagenew);
C::t('forum_announcement')->update_by_id_username($_GET['announceid'], array(
'subject' => strip_tags($subjectnew, '<u><i><b><font>'),
'type' => $_GET['typenew'],
'starttime' => $starttimenew,
'endtime' => $endtimenew,
'message' => $messagenew[0],
), $_G['username'], $_G['adminid']);
updatecache(array('announcements', 'announcements_forum'));
cpmsg('announce_succeed', 'action=announce', 'succeed');
}
}
}
echo '<script type="text/javascript" src="' . STATICURL . 'js/calendar.js"></script>';
?>

View File

@@ -0,0 +1,452 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_article.php 33047 2013-04-12 08:46:56Z zhangguosheng $
*/
if(!defined('IN_DISCUZ') || !defined('IN_DISCUZ')) {
exit('Access Denied');
}
$operation = in_array($operation, array('trash', 'tag')) ? $operation : 'list';
loadcache('portalcategory');
$category = $_G['cache']['portalcategory'];
cpheader();
shownav('portal', 'article');
$searchctrl = '';
if($operation == 'list') {
$searchctrl = '<span style="float: right; padding-right: 40px;">'
.'<a href="javascript:;" onclick="$(\'tb_search\').style.display=\'\';$(\'a_search_show\').style.display=\'none\';$(\'a_search_hide\').style.display=\'\';" id="a_search_show" style="display:none">'.cplang('show_search').'</a>'
.'<a href="javascript:;" onclick="$(\'tb_search\').style.display=\'none\';$(\'a_search_show\').style.display=\'\';$(\'a_search_hide\').style.display=\'none\';" id="a_search_hide">'.cplang('hide_search').'</a>'
.'</span>';
}
$catid = $_GET['catid'] = intval($_GET['catid']);
showsubmenu('article', array(
array('list', 'article&catid='.$catid, $operation == 'list'),
array('article_trash', 'article&operation=trash&catid='.$catid, $operation == 'trash'),
array('article_tag', 'article&operation=tag', $operation == 'tag'),
array('article_add', 'portal.php?mod=portalcp&ac=article', false, 1, 1)
), $searchctrl);
if($operation == 'tag') {
showtips('article_tag_tip');
if(submitcheck('articletagsubmit')) {
C::t('common_setting')->update_setting('article_tags', $_POST['tag']);
updatecache('setting');
cpmsg('update_articletag_succeed', 'action=article&operation=tag', 'succeed');
}
require_once libfile('function/portalcp');
$tag_names = article_tagnames();
showformheader('article&operation=tag');
showtableheader('article_tag_setting');
for($i=1; $i<=8; $i++) {
showtablerow('', array('width=80', ''),
array(lang('portalcp', 'article_tag').$i, "<input type=\"text\" class=\"txt\" name=\"tag[$i]\" value=\"$tag_names[$i]\" />"));
}
showsubmit('articletagsubmit', 'submit');
showtablefooter();
showformfooter();
} elseif($operation == 'trash') {
if(submitcheck('batchsubmit', true)) {
$_POST['optype'] = empty($_POST['optype']) ? $_GET['optype'] : $_POST['optype'];
if(empty($_POST['ids']) && $_POST['optype'] != 'clear') {
cpmsg('article_choose_at_least_one_article', 'action=article&operation=trash', 'error');
}
if($_POST['optype'] == 'recover') {
$inserts = $ids = $catids = array();
foreach(C::t('portal_article_trash')->fetch_all($_POST['ids']) as $value) {
$ids[] = intval($value['aid']);
$article = dunserialize($value['content']);
$catids[] = intval($article['catid']);
$inserts[] = array (
'aid' => $article['aid'],
'catid' => $article['catid'],
'uid' => $article['uid'],
'username' => $article['username'],
'title' => $article['title'],
'url' => $article['url'],
'summary' => $article['summary'],
'pic' => $article['pic'],
'id' => $article['id'],
'idtype' => $article['idtype'],
'contents' => $article['contents'],
'dateline' => $article['dateline'],
'thumb' => $article['thumb'],
'remote' => $article['remote'],
'click1' => $article['click1'],
'click2' => $article['click2'],
'click3' => $article['click3'],
'click4' => $article['click4'],
'click5' => $article['click5'],
'click6' => $article['click6'],
'click7' => $article['click7'],
'click8' => $article['click8'],
'author' => $article['author'],
'from' => $article['from'],
'fromurl' => $article['fromurl'],
'bid' => $article['bid'],
'allowcomment' => $article['allowcomment'],
'tag' => $article['tag'],
'owncomment' => $article['owncomment'],
'status' => $article['status'],
'highlight' => $article['highlight'],
'showinnernav' => $article['showinnernav'],
'preaid' => $article['preaid'],
'nextaid' => $article['nextaid'],
'htmlmade' => $article['htmlmade'],
'htmlname' => $article['htmlname'],
'htmldir' => $article['htmldir'],
);
}
if($inserts) {
foreach($inserts as $data) {
C::t('portal_article_title')->insert($data, 0, 1);
}
C::t('portal_article_trash')->delete($ids);
}
$catids = array_unique($catids);
if($catids) {
foreach($catids as $catid) {
$cnt = C::t('portal_article_title')->fetch_count_for_cat($catid);
C::t('portal_category')->update($catid, array('articles'=>dintval($cnt)));
}
}
cpmsg('article_trash_recover_succeed', 'action=article&operation=trash', 'succeed');
} elseif($_POST['optype'] == 'delete') {
require_once libfile('function/delete');
deletetrasharticle($_POST['ids']);
cpmsg('article_trash_delete_succeed', 'action=article&operation=trash', 'succeed');
} elseif($_POST['optype'] == 'clear') {
$aids = array();
foreach(C::t('portal_article_trash')->range(50) as $value) {
$aids[$value['aid']] = $value['aid'];
}
if(!empty($aids)) {
require_once libfile('function/delete');
deletetrasharticle($aids);
cpmsg('article_trash_is_clearing', 'action=article&operation=trash&optype=clear&batchsubmit=yes&formhash='.FORMHASH);
} else {
cpmsg('article_trash_is_empty', 'action=article');
}
} else {
cpmsg('article_choose_at_least_one_operation', 'action=article&operation=trash', 'error');
}
} else {
$perpage = 50;
$start = ($page-1)*$perpage;
$mpurl .= '&perpage='.$perpage;
$perpages = array($perpage => ' selected');
$mpurl = ADMINSCRIPT.'?mod=portal&action=article&operation='.$operation;
showformheader('article&operation=trash');
showtableheader('article_trash_list');
showsubtitle(array('', 'article_title', 'article_category', 'article_username', 'article_dateline'));
$multipage = '';
$count = C::t('portal_article_trash')->count();
if($count) {
foreach(C::t('portal_article_trash')->range($start, $perpage) as $value) {
$value = dunserialize($value['content']);
showtablerow('', array('class="td25"', 'class=""', 'class="td28"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"ids[]\" value=\"{$value['aid']}\">",
$value['title'],
$category[$value['catid']]['catname'],
"<a href=\"home.php?mod=space&uid={$value['uid']}&do=profile\" target=\"_blank\">{$value['username']}</a>",
dgmdate($value['dateline'])
));
}
$multipage = multi($count, $perpage, $page, $mpurl);
}
$batchradio = '<input type="radio" name="optype" value="recover" id="op_recover" class="radio" /><label for="op_recover">'.cplang('article_trash_recover').'</label>&nbsp;&nbsp;';
$batchradio .= '<input type="radio" name="optype" value="delete" id="op_delete" class="radio" /><label for="op_delete">'.cplang('article_trash_delete').'</label>&nbsp;&nbsp;';
$batchradio .= '<input type="radio" name="optype" value="clear" id="op_clear" class="radio" style="display:none;"/><input type="hidden" name="batchsubmit" value="yes" />';
showsubmit('', '', '', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'ids\')" /><label for="chkall">'.cplang('select_all').'</label>&nbsp;&nbsp;'
.$batchradio.'<input type="submit" class="btn" name="batchbutton" value="'.cplang('submit').'" />
<input type="button" class="btn" name="clearbutton" value="'.cplang('article_clear_trash').'" onclick="if(confirm(\''.cplang('article_clear_trash_confirm').'?\')){this.form.optype[2].checked=\'checked\';this.form.submit();}"/>', $multipage);
showtablefooter();
showformfooter();
}
} else {
if(submitcheck('articlesubmit')) {
$perpage = intval($_GET['hiddenperpage']);
$page = intval($_GET['hiddenpage']);
$catid = intval($_GET['hiddencatid']);
$articles = $catids = array();
$aids = !empty($_GET['ids']) && is_array($_GET['ids']) ? $_GET['ids'] : array();
if($aids) {
$query = C::t('portal_article_title')->fetch_all($aids);
foreach($query as $value) {
$articles[$value['aid']] = array('aid' => $value['aid'], 'catid' => $value['catid']);
$catids[] = intval($value['catid']);
}
}
if(empty($articles)) {
cpmsg('article_choose_at_least_one_article', 'action=article&catid='.$catid.'&perpage='.$perpage.'&page='.$page, 'error');
}
$aids = array_keys($articles);
if($_POST['optype'] == 'trash') {
require_once libfile('function/delete');
deletearticle($aids, true);
cpmsg('article_trash_succeed', 'action=article&catid='.$catid.'&perpage='.$perpage.'&page='.$page, 'succeed');
} elseif($_POST['optype'] == 'move') {
$tocatid = intval($_POST['tocatid']);
$catids[] = $tocatid;
$catids = array_merge($catids);
C::t('portal_article_title')->update($aids, array('catid'=>$tocatid));
foreach($catids as $catid) {
$catid = intval($catid);
$cnt = C::t('portal_article_title')->fetch_count_for_cat($catid);
C::t('portal_category')->update($catid, array('articles'=>dintval($cnt)));
}
cpmsg('article_move_succeed', 'action=article&catid='.$catid.'&perpage='.$perpage.'&page='.$page, 'succeed');
} else {
cpmsg('article_choose_at_least_one_operation', 'action=article&catid='.$catid.'&perpage='.$perpage.'&page='.$page, 'error');
}
} else {
include_once libfile('function/portalcp');
$mpurl = ADMINSCRIPT.'?action=article&operation='.$operation;
$intkeys = array('aid', 'uid');
$strkeys = array();
$randkeys = array();
$likekeys = array('title', 'username');
$results = getwheres($intkeys, $strkeys, $randkeys, $likekeys);
foreach($likekeys as $k) {
$_GET[$k] = dhtmlspecialchars($_GET[$k]);
}
$wherearr = $results['wherearr'];
$mpurl .= '&'.implode('&', $results['urls']);
if(!empty($_GET['catid'])) {
$catid = intval($_GET['catid']);
$mpurl .= '&catid='.$catid;
$catids = category_get_childids('portal', $_GET['catid']);
$catids[] = $_GET['catid'];
$wherearr[] = 'catid IN ('.dimplode($catids).')';
}
if(!empty($_GET['tag'])) {
$tag = article_make_tag($_GET['tag']);
$wherearr[] = "(tag & '$tag' = '$tag')";
foreach($_GET['tag'] as $k=>$v) {
$mpurl .= "&tag[$k]=$v";
}
}
$wheresql = empty($wherearr)?'1':implode(' AND ', $wherearr);
$orders = getorders(array('dateline'), 'aid');
$ordersql = $orders['sql'];
if($orders['urls']) $mpurl .= '&'.implode('&', $orders['urls']);
$orderby = array($_GET['orderby']=>' selected');
$ordersc = array($_GET['ordersc']=>' selected');
$perpage = empty($_GET['perpage'])?0:intval($_GET['perpage']);
if(!in_array($perpage, array(10,20,50,100))) $perpage = 10;
$categoryselect = category_showselect('portal', 'catid', true, $_GET['catid']);
$searchlang = array();
$keys = array('search', 'likesupport', 'resultsort', 'defaultsort', 'orderdesc', 'orderasc', 'perpage_10', 'perpage_20', 'perpage_50', 'perpage_100',
'article_dateline', 'article_id', 'article_title', 'article_uid', 'article_username', 'article_category', 'article_tag');
foreach ($keys as $key) {
$searchlang[$key] = cplang($key);
}
$articletagcheckbox = '';
$article_tags = article_tagnames();
foreach($article_tags as $k=>$v) {
$checked = !empty($_GET['tag']) && !empty($_GET['tag'][$k]) ? 'checked="checked"' : '';
$articletagcheckbox .= "<input type=\"checkbox\" class=\"checkbox\" id=\"tag_$k\" name=\"tag[$k]\" value=\"1\"$checked />";
$articletagcheckbox .= "<label for=\"tag_$k\">$v</label>";
}
$start = ($page-1)*$perpage;
$mpurl .= '&perpage='.$perpage;
$perpages = array($perpage => ' selected');
$adminscript = ADMINSCRIPT;
$staticurl = STATICURL;
echo <<<SEARCH
<form method="get" autocomplete="off" action="$adminscript" id="tb_search">
<table cellspacing="3" cellpadding="3" class="tb tb2">
<tr>
<th>{$searchlang['article_id']}</th><td><input type="text" class="txt" name="aid" value="{$_GET['aid']}"></td>
<th>{$searchlang['article_title']}*</th><td><input type="text" class="txt" name="title" value="{$_GET['title']}">*{$searchlang['likesupport']}</td>
</tr>
<tr>
<th>{$searchlang['article_uid']}</th><td><input type="text" class="txt" name="uid" value="{$_GET['uid']}"></td>
<th>{$searchlang['article_username']}*</th><td><input type="text" class="txt" name="username" value="{$_GET['username']}"></td>
</tr>
<tr>
<th>{$searchlang['article_category']}</th><td>$categoryselect</td>
<th>&nbsp;</th><td>&nbsp;</td>
</tr>
<tr>
<th>{$searchlang['article_tag']}</th><td colspan="3">$articletagcheckbox</td>
</tr>
<tr>
<th>{$searchlang['resultsort']}</th>
<td colspan="3">
<select name="orderby">
<option value="">{$searchlang['defaultsort']}</option>
<option value="dateline"{$orderby['dateline']}>{$searchlang['article_dateline']}</option>
</select>
<select name="ordersc">
<option value="desc"{$ordersc['desc']}>{$searchlang['orderdesc']}</option>
<option value="asc"{$ordersc['asc']}>{$searchlang['orderasc']}</option>
</select>
<select name="perpage">
<option value="10"{$perpages[10]}>{$searchlang['perpage_10']}</option>
<option value="20"{$perpages[20]}>{$searchlang['perpage_20']}</option>
<option value="50"{$perpages[50]}>{$searchlang['perpage_50']}</option>
<option value="100"{$perpages[100]}>{$searchlang['perpage_100']}</option>
</select>
<input type="hidden" name="action" value="article">
<input type="submit" name="searchsubmit" value="{$searchlang['search']}" class="btn">
</td>
</tr>
</table>
</form>
<script src="{$staticurl}js/makehtml.js?1" type="text/javascript"></script>
SEARCH;
$makehtmlflag = !empty($_G['setting']['makehtml']['flag']);
showformheader('article&operation=list');
showtableheader('article_list');
$subtitle = array('', 'article_title', 'article_category', 'article_username', 'article_dateline');
if($makehtmlflag) {
$subtitle[] = 'HTML';
}
$subtitle[] = 'operation';
showsubtitle($subtitle);
$multipage = '';
$count = C::t('portal_article_title')->fetch_all_by_sql($wheresql, '', 0, 0, 1);
if($count) {
$repairs = array();
$query = C::t('portal_article_title')->fetch_all_by_sql($wheresql, $ordersql, $start, $perpage);
foreach($query as $value) {
$htmlname = $value['htmldir'].$value['htmlname'].'.'.$_G['setting']['makehtml']['extendname'];
if($makehtmlflag && $value['htmlmade'] && !file_exists(DISCUZ_ROOT.'./'.$htmlname)) {
$value['htmlmade'] = 0;
$repairs[$value['aid']] = $value['aid'];
}
$tags = article_parse_tags($value['tag']);
$taghtml = '';
foreach($tags as $k=>$v) {
if($v) {
$taghtml .= ' [<a href="'.ADMINSCRIPT.'?action=article&operation=list&tag['.$k.']=1" style="color: #666">'.$article_tags[$k].'</a>] ';
}
}
$tablerow = array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"ids[]\" value=\"{$value['aid']}\">",
"<a href=\"portal.php?mod=view&aid={$value['aid']}\" target=\"_blank\">{$value['title']}</a>".($taghtml ? $taghtml : ''),
'<a href="'.ADMINSCRIPT.'?action=article&operation=list&catid='.$value['catid'].'">'.$category[$value['catid']]['catname'].'</a>',
"<a href=\"".ADMINSCRIPT."?action=article&uid={$value['uid']}\">{$value['username']}</a>",
dgmdate($value['dateline']),
);
if($makehtmlflag) {
$tablerow[] = "<span id='mkhtml_{$value['aid']}' style='color:".($value['htmlmade'] ? "blue;'>".cplang('setting_functions_makehtml_made') : "red;'>".cplang('setting_functions_makehtml_dismake'))."</span>";
}
$tablerow[] = ($makehtmlflag ? ($category[$value['catid']]['fullfoldername'] ? "<a href='javascript:void(0);' onclick=\"make_html('portal.php?mod=view&aid={$value['aid']}', $('mkhtml_{$value['aid']}'))\">".cplang('setting_functions_makehtml_make')."</a>" : cplang('setting_functions_makehtml_make_has_no_foldername')) : '')
." <a href=\"portal.php?mod=portalcp&ac=article&aid={$value['aid']}\" target=\"_blank\">".cplang('edit')."</a>";
showtablerow('', array('class="td25"', 'width="480"', 'class="td28"'), $tablerow);
}
$multipage = multi($count, $perpage, $page, $mpurl);
if($repairs) {
C::t('portal_article_title')->repair_htmlmade($repairs);
}
}
$optypehtml = ''
.'<input type="hidden" name="hiddenpage" id="hiddenpage" value="'.$page.'"/><input type="hidden" name="hiddencatid" id="hiddencatid" value="'.$catid.'"/><input type="hidden" name="hiddenperpage" id="hiddenperpage" value="'.$perpage.'"/><input type="radio" name="optype" id="optype_trash" value="trash" class="radio" /><label for="optype_trash">'.cplang('article_optrash').'</label>&nbsp;&nbsp;'
.'<input type="radio" name="optype" id="optype_move" value="move" class="radio" /><label for="optype_move">'.cplang('article_opmove').'</label> '
.category_showselect('portal', 'tocatid', false)
.'&nbsp;&nbsp;';
showsubmit('', '', '', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'ids\')" /><label for="chkall">'.cplang('select_all').'</label>&nbsp;&nbsp;'.$optypehtml.'<input type="submit" class="btn" name="articlesubmit" value="'.cplang('submit').'" />', $multipage);
showtablefooter();
showformfooter();
}
}
function showcategoryrow($key, $type = '', $last = '') {
global $category, $lang;
$forum = $forums[$key];
$showedforums[] = $key;
if($last == '') {
$return = '<tr class="hover"><td class="td25"><input type="text" class="txt" name="order['.$forum['fid'].']" value="'.$forum['displayorder'].'" /></td><td>';
if($type == 'group') {
$return .= '<div class="parentboard">';
} elseif($type == '') {
$return .= '<div class="board">';
} elseif($type == 'sub') {
$return .= '<div id="cb_'.$forum['fid'].'" class="childboard">';
}
$boardattr = '';
if(!$forum['status'] || $forum['password'] || $forum['redirect']) {
$boardattr = '<div class="boardattr">';
$boardattr .= $forum['status'] ? '' : $lang['forums_admin_hidden'];
$boardattr .= !$forum['password'] ? '' : ' '.$lang['forums_admin_password'];
$boardattr .= !$forum['redirect'] ? '' : ' '.$lang['forums_admin_url'];
$boardattr .= '</div>';
}
$return .= '<input type="text" class="txt" name="name['.$forum['fid'].']" value="'.dhtmlspecialchars($forum['name']).'" class="txt" />'.
($type == '' ? '<a href="###" onclick="addrowdirect = 1;addrow(this, 2, '.$forum['fid'].')" class="addchildboard">'.$lang['forums_admin_add_sub'].'</a>' : '').
'</div>'.$boardattr.
'</td><td>'.showforum_moderators($forum).'</td>
<td><a href="'.ADMINSCRIPT.'?action=forums&operation=edit&fid='.$forum['fid'].'" title="'.$lang['forums_edit_comment'].'" class="act">'.$lang['edit'].'</a>'.
($type != 'group' ? '<a href="'.ADMINSCRIPT.'?action=forums&operation=copy&source='.$forum['fid'].'" title="'.$lang['forums_copy_comment'].'" class="act">'.$lang['forums_copy'].'</a>' : '').
'<a href="'.ADMINSCRIPT.'?action=forums&operation=delete&fid='.$forum['fid'].'" title="'.$lang['forums_delete_comment'].'" class="act">'.$lang['delete'].'</a></td></tr>';
} else {
if($last == 'lastboard') {
$return = '<tr><td></td><td colspan="3"><div class="lastboard"><a href="###" onclick="addrow(this, 1, '.$forum['fid'].')" class="addtr">'.$lang['forums_admin_add_forum'].'</a></div></td></tr>';
} elseif($last == 'lastchildboard' && $type) {
$return = '<script type="text/JavaScript">$(\'cb_'.$type.'\').className = \'lastchildboard\';</script>';
} elseif($last == 'last') {
$return = '<tr><td></td><td colspan="3"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['forums_admin_add_category'].'</a></div></td></tr>';
}
}
return $return;
}
?>

View File

@@ -0,0 +1,193 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_attach.php 31441 2012-08-28 07:46:04Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$searchsubmit = $_GET['searchsubmit'];
if(!submitcheck('deletesubmit')) {
require_once libfile('function/forumlist');
$anchor = isset($_GET['anchor']) ? $_GET['anchor'] : '';
$anchor = in_array($anchor, array('search', 'admin')) ? $anchor : 'search';
shownav('topic', 'nav_attaches'.($operation ? '_'.$operation : ''));
showsubmenusteps('nav_attaches'.($operation ? '_'.$operation : ''), array(
array('search', !$searchsubmit),
array('admin', $searchsubmit),
));
showtips('attach_tips', 'attach_tips', $searchsubmit);
showtagheader('div', 'search', !$searchsubmit);
showformheader('attach'.($operation ? '&operation='.$operation : ''));
showtableheader();
showsetting('attach_nomatched', 'nomatched', 0, 'radio');
if($operation != 'group') {
showsetting('attach_forum', '', '', '<select name="inforum"><option value="all">&nbsp;&nbsp;>'.cplang('all').'</option><option value="">&nbsp;</option>'.forumselect(FALSE, 0, 0, TRUE).'</select>');
}
showsetting('attach_search_perpage', '', $_GET['perpage'], "<select name='perpage'><option value='20'>{$lang['perpage_20']}</option><option value='50'>{$lang['perpage_50']}</option><option value='100'>{$lang['perpage_100']}</option></select>");
showsetting('attach_sizerange', array('sizeless', 'sizemore'), array('', ''), 'range');
showsetting('attach_dlcountrange', array('dlcountless', 'dlcountmore'), array('', ''), 'range');
showsetting('attach_daysold', 'daysold', '', 'text');
showsetting('filename', 'filename', '', 'text');
showsetting('attach_keyword', 'keywords', '', 'text');
showsetting('attach_author', 'author', '', 'text');
showsubmit('searchsubmit', 'search');
showtablefooter();
showformfooter();
showtagfooter('div');
if(submitcheck('searchsubmit')) {
require_once libfile('function/attachment');
$operation == 'group' && $_GET['inforum'] = 'isgroup';
$inforum = $_GET['inforum'] != 'all' && $_GET['inforum'] != 'isgroup' ? intval($_GET['inforum']) : $_GET['inforum'];
$authorid = $_GET['author'] ? C::t('common_member')->fetch_uid_by_username($_GET['author']) : 0;
$authorid = $_GET['author'] && !$authorid ? C::t('common_member_archive')->fetch_uid_by_username($_GET['author']) : $authorid;
$attachments = '';
$attachuids = $attachusers = array();
$_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
$perpage = ($_GET['pp'] ? $_GET['pp'] : $_GET['perpage']) / 10;
$attachmentcount = 0;
for($attachi = 0;$attachi < 10;$attachi++) {
$attachmentarray = array();
$attachmentcount += C::t('forum_attachment')->fetch_all_for_manage($attachi, $inforum, $authorid, $_GET['filename'], $_GET['keywords'], $_GET['sizeless'], $_GET['sizemore'], $_GET['dlcountless'], $_GET['dlcountmore'], $_GET['daysold'], 1);
$query = C::t('forum_attachment')->fetch_all_for_manage($attachi, $inforum, $authorid, $_GET['filename'], $_GET['keywords'], $_GET['sizeless'], $_GET['sizemore'], $_GET['dlcountless'], $_GET['dlcountmore'], $_GET['daysold'], 0, (($page - 1) * $perpage), $perpage);
foreach($query as $attachment) {
$attachuids[$attachment['uid']] = $attachment['uid'];
$attachmentarray[] = $attachment;
}
$attachusers += C::t('common_member')->fetch_all($attachuids);
foreach($attachmentarray as $attachment) {
if(!$attachment['remote']) {
$matched = file_exists($_G['setting']['attachdir'].'/forum/'.$attachment['attachment']) ? '' : cplang('attach_lost');
$attachment['url'] = $_G['setting']['attachurl'].'forum/';
} else {
@set_time_limit(0);
if(@fclose(@fopen($_G['setting']['ftp']['attachurl'].'forum/'.$attachment['attachment'], 'r'))) {
$matched = '';
} else {
$matched = cplang('attach_lost');
}
$attachment['url'] = $_G['setting']['ftp']['attachurl'].'forum/';
}
$attachsize = sizecount($attachment['filesize']);
if(!$_GET['nomatched'] || ($_GET['nomatched'] && $matched)) {
$attachment['url'] = trim($attachment['url'], '/');
$attachments .= showtablerow('', array('class="td25"', 'title="'.$attachment['description'].'" class="td21"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"{$attachment['aid']}\" />",
$attachment['remote'] ? "<span class=\"diffcolor3\">{$attachment['filename']}" : $attachment['filename'],
$attachusers[$attachment['uid']]['username'],
"<a href=\"forum.php?mod=viewthread&tid={$attachment['tid']}\" target=\"_blank\">".cutstr($attachment['subject'], 20)."</a>",
$attachsize,
$attachment['downloads'],
$matched ? "<em class=\"error\">$matched<em>" : "<a href=\"forum.php?mod=attachment&aid=".aidencode($attachment['aid'])."&noupdate=yes\" target=\"_blank\" class=\"act nomargin\">{$lang['download']}</a>"
), TRUE);
}
}
}
$multipage = '<div class="cuspages right"><div class="pg">'.
($page > 1 ? '<a href="javascript:page('.($page-1).')" class="nxt">&lsaquo;&lsaquo;</a>' : '').
'<a href="javascript:page('.($page+1).')" class="nxt">&rsaquo;&rsaquo;</a>'.
'</div></div>';
echo <<<EOT
<script type="text/JavaScript">
function page(number) {
$('attachmentforum').page.value=number;
$('attachmentforum').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'admin', $searchsubmit);
showformheader('attach'.($operation ? '&operation='.$operation : ''), '', 'attachmentforum');
showhiddenfields(array(
'page' => $page,
'nomatched' => $_GET['nomatched'],
'inforum' => $_GET['inforum'],
'sizeless' => $_GET['sizeless'],
'sizemore' => $_GET['sizemore'],
'dlcountless' => $_GET['dlcountless'],
'dlcountmore' => $_GET['dlcountmore'],
'daysold' => $_GET['daysold'],
'filename' => $_GET['filename'],
'keywords' => $_GET['keywords'],
'author' => $_GET['author'],
'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']
));
echo '<input type="submit" name="searchsubmit" value="'.cplang('submit').'" class="btn" style="display: none" />';
showformfooter();
showformheader('attach&frame=no'.($operation ? '&operation='.$operation : ''), 'target="attachmentframe"');
showboxheader();
showtableheader();
showsubtitle(array('', 'filename', 'author', 'attach_thread', 'size', 'attach_downloadnums', ''));
echo $attachments;
showsubmit('deletesubmit', 'submit', 'del', '<a href="###" onclick="$(\'admin\').style.display=\'none\';$(\'search\').style.display=\'\';$(\'attachmentforum\').pp.value=\'\';$(\'attachmentforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>', $multipage);
showtablefooter();
showboxfooter();
showformfooter();
echo '<iframe name="attachmentframe" style="display:none"></iframe>';
showtagfooter('div');
}
} else {
if($_GET['delete']) {
$tids = $pids = array();
for($attachi = 0;$attachi < 10;$attachi++) {
foreach(C::t('forum_attachment_n')->fetch_all_attachment($attachi, $_GET['delete']) as $attach) {
dunlink($attach);
$tids[$attach['tid']] = $attach['tid'];
$pids[$attach['pid']] = $attach['pid'];
}
C::t('forum_attachment_n')->delete_attachment($attachi, $_GET['delete']);
$attachtids = array();
foreach(C::t('forum_attachment_n')->fetch_all_by_id($attachi, 'tid', $tids) as $attach) {
unset($tids[$attach['tid']]);
}
if($tids) {
C::t('forum_thread')->update($tids, array('attachment' => 0));
}
$attachpids = array();
foreach(C::t('forum_attachment_n')->fetch_all_by_id($attachi, 'pid', $pids) as $attach) {
$attachpids[$attach['pid']] = $attach['pid'];
}
}
if($attachpids) {
$pids = array_diff($pids, $attachpids);
}
loadcache('posttableids');
$posttableids = $_G['cache']['posttableids'] ? $_G['cache']['posttableids'] : array('0');
foreach($posttableids as $id) {
C::t('forum_post')->update_post($id, $pids, array('attachment' => '0'));
}
$cpmsg = cplang('attach_edit_succeed');
} else {
$cpmsg = cplang('attach_edit_invalid');
}
echo "<script type=\"text/JavaScript\">alert('$cpmsg');parent.\$('attachmentforum').searchsubmit.click();</script>";
}
?>

View File

@@ -0,0 +1,372 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_block.php 29236 2012-03-30 05:34:47Z chenmengshu $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = in_array($operation, array('jscall', 'list', 'perm')) ? $operation : 'list';
shownav('portal', 'block');
loadcache('blockclass');
if($operation=='perm') {
$bid = intval($_GET['bid']);
if(!submitcheck('permsubmit')) {
loadcache('diytemplatename');
$block = C::t('common_block')->fetch($bid);
shownav('portal', 'block', 'block_perm');
showsubmenu(cplang('block_perm_edit').' - '.($block['name'] ? $block['name'] : cplang('block_name_null')));
showtips('block_perm_tips');
showformheader("block&operation=perm&bid=$bid");
$inheritance_checked = !$block['notinherited'] ? 'checked' : '';
showtableheader('<label><input class="checkbox" type="checkbox" name="inheritance" value="1" '.$inheritance_checked.'/>'.cplang('block_perm_inheritance').'</label>', 'fixpadding');
showsubtitle(array('', 'username',
'<input class="checkbox" type="checkbox" name="chkallmanage" onclick="checkAll(\'prefix\', this.form, \'allowmanage\', \'chkallmanage\')" id="chkallmanage" /><label for="chkallmanage">'.cplang('block_perm_manage').'</label>',
'<input class="checkbox" type="checkbox" name="chkallrecommend" onclick="checkAll(\'prefix\', this.form, \'allowrecommend\', \'chkallrecommend\')" id="chkallrecommend" /><label for="chkallrecommend">'.cplang('block_perm_recommend').'</label>',
'<input class="checkbox" type="checkbox" name="chkallneedverify" onclick="checkAll(\'prefix\', this.form, \'needverify\', \'chkallneedverify\')" id="chkallneedverify" /><label for="chkallneedverify">'.cplang('block_perm_needverify').'</label>',
'block_perm_inherited'
));
$block_per = C::t('common_block_permission')->fetch_all_by_bid($bid);
$members = C::t('common_member')->fetch_all(array_keys($block_per));
$line = '&minus;';
foreach($block_per as $uid => $value) {
if(!empty($value['inheritedtplname'])) {
showtablerow('', array('class="td25"'), array(
"",
"{$members[$uid]['username']}",
$value['allowmanage'] ? '&radic;' : $line,
$value['allowrecommend'] ? '&radic;' : $line,
$value['needverify'] ? '&radic;' : $line,
'<a href="'.ADMINSCRIPT.'?action=diytemplate&operation=perm&targettplname='.$value['inheritedtplname'].'">'.$_G['cache']['diytemplatename'][$value['inheritedtplname']].'</a>',
));
} else {
showtablerow('', array('class="td25"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[$uid]\" value=\"$uid\" />
<input type=\"hidden\" name=\"perm[$uid][allowmanage]\" value=\"{$value['allowmanage']}\" />
<input type=\"hidden\" name=\"perm[$uid][allowrecommend]\" value=\"{$value['allowrecommend']}\" />
<input type=\"hidden\" name=\"perm[$uid][needverify]\" value=\"{$value['needverify']}\" />",
"{$members[$uid]['username']}",
"<input type=\"checkbox\" class=\"checkbox\" name=\"allowmanage[$uid]\" value=\"1\" ".($value['allowmanage'] ? 'checked' : '').' />',
"<input type=\"checkbox\" class=\"checkbox\" name=\"allowrecommend[$uid]\" value=\"1\" ".($value['allowrecommend'] ? 'checked' : '').' />',
"<input type=\"checkbox\" class=\"checkbox\" name=\"needverify[$uid]\" value=\"1\" ".($value['needverify'] ? 'checked' : '').' />',
$line,
));
}
}
showtablerow('', array('class="td25"'), array(
cplang('add_new'),
'<input type="text" class="txt" name="newuser" value="" size="20" />',
'<input type="checkbox" class="checkbox" name="newallowmanage" value="1" />',
'<input type="checkbox" class="checkbox" name="newallowrecommend" value="1" />',
'<input type="checkbox" class="checkbox" name="newneedverify" value="1" />',
'',
));
showsubmit('permsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if(!($block = C::t('common_block')->fetch($bid))) {
cpmsg('block_not_exists');
}
$users = array();
if(is_array($_GET['perm'])) {
foreach($_GET['perm'] as $uid => $value) {
$user = array();
if(empty($_GET['delete']) || !in_array($uid, $_GET['delete'])) {
$user = array();
$user['allowmanage'] = $_GET['allowmanage'][$uid] ? 1 : 0;
$user['allowrecommend'] = $_GET['allowrecommend'][$uid] ? 1 : 0;
$user['needverify'] = $_GET['needverify'][$uid] ? 1 : 0;
if($value['allowmanage'] != $user['allowmanage'] || $value['allowrecommend'] != $user['allowrecommend'] || $value['needverify'] != $user['needverify'] ) {
$user['uid'] = intval($uid);
$users[] = $user;
}
}
}
}
if(!empty($_GET['newuser'])) {
$uid = C::t('common_member')->fetch_uid_by_username($_GET['newuser']);
if($uid) {
$user['uid'] = $uid;
$user['allowmanage'] = $_GET['newallowmanage'] ? 1 : 0;
$user['allowrecommend'] = $_GET['newallowrecommend'] ? 1 : 0;
$user['needverify'] = $_GET['newneedverify'] ? 1 : 0;
$users[$user['uid']] = $user;
} else {
cpmsg_error($_GET['newuser'].cplang('block_has_no_allowauthorizedblock'));
}
}
require_once libfile('class/blockpermission');
$blockpermsission = & block_permission::instance();
if(!empty($users)) {
$blockpermsission->add_users_perm($bid, $users);
}
if(!empty($_GET['delete'])) {
$blockpermsission->delete_users_perm($bid, $_GET['delete']);
}
$notinherited = !$_POST['inheritance'] ? '1' : '0';
if($notinherited != $block['notinherited']) {
if($notinherited) {
$blockpermsission->delete_inherited_perm_by_bid($bid);
} else {
$blockpermsission->remake_inherited_perm($bid);
}
C::t('common_block')->update($bid, array('notinherited' => $notinherited));
}
cpmsg('block_perm_update_succeed', "action=block&operation=perm&bid=$bid", 'succeed');
}
} else {
if(submitcheck('deletesubmit')) {
if($_POST['ids']) {
C::t('common_block_item')->delete_by_bid($_POST['ids']);
C::t('common_block')->delete($_POST['ids']);
C::t('common_block_permission')->delete_by_bid_uid_inheritedtplname($_POST['ids']);
cpmsg('block_delete_succeed', 'action=block&operation=jscall', 'succeed');
} else {
cpmsg('block_choose_at_least_one_block', 'action=block&operation=jscall', 'error');
}
} elseif(submitcheck('clearsubmit')) {
include_once libfile('function/block');
block_clear();
cpmsg('block_clear_unused_succeed', 'action=block', 'succeed');
} else {
loadcache(array('diytemplatename'));
$searchctrl = '<span style="float: right; padding-right: 40px;">'
.'<a href="javascript:;" onclick="$(\'tb_search\').style.display=\'\';$(\'a_search_show\').style.display=\'none\';$(\'a_search_hide\').style.display=\'\';" id="a_search_show" style="display:none">'.cplang('show_search').'</a>'
.'<a href="javascript:;" onclick="$(\'tb_search\').style.display=\'none\';$(\'a_search_show\').style.display=\'\';$(\'a_search_hide\').style.display=\'none\';" id="a_search_hide">'.cplang('hide_search').'</a>'
.'</span>';
showsubmenu('block', array(
array('block_list', 'block', $operation=='list'),
array('block_jscall', 'block&operation=jscall', $operation=='jscall')
), $searchctrl);
$mpurl = ADMINSCRIPT.'?action=block&operation='.$operation;
$intkeys = array('bid');
$strkeys = array('blockclass');
$strkeys[] = 'targettplname';
$randkeys = array();
$likekeys = array('name');
$results = getwheres($intkeys, $strkeys, $randkeys, $likekeys);
foreach($likekeys as $k) {
$_GET[$k] = dhtmlspecialchars($_GET[$k]);
}
$wherearr = $results['wherearr'];
$mpurl .= '&'.implode('&', $results['urls']);
$wherearr[] = $operation=='jscall' ? "blocktype='1'" : "blocktype='0'";
if($_GET['permname']) {
$bids = '';
$uid = ($uid = C::t('common_member')->fetch_uid_by_username($_GET['permname'])) ? $uid : C::t('common_member_archive')->fetch_uid_by_username($_GET['permname']);
if($uid) {
$bids = array_keys(C::t('common_block_permission')->fetch_all_by_uid($uid));
}
if(($bids = dimplode($bids))) {
$wherearr[] = 'bid IN ('.$bids.')';
} else {
cpmsg_error($_GET['permname'].cplang('block_the_username_has_not_block'));
}
$mpurl .= '&permname='.$_GET['permname'];
}
$wheresql = empty($wherearr)?'1':implode(' AND ', $wherearr);
$wheresql = str_replace(array('bid', 'blockclass', ' name', 'blocktype', 'targettplname'), array('b.bid', 'b.blockclass', ' b.name', 'b.blocktype', 'tb.targettplname'), $wheresql);
$orders = getorders(array('bid', 'dateline'), 'bid');
$ordersql = $orders['sql'];
if($orders['urls']) $mpurl .= '&'.implode('&', $orders['urls']);
$orderby = array($_GET['orderby']=>' selected');
$ordersc = array($_GET['ordersc']=>' selected');
$perpage = empty($_GET['perpage'])?0:intval($_GET['perpage']);
if(!in_array($perpage, array(10,20,50,100))) $perpage = 20;
$perpages = array($perpage=>' selected');
$mpurl .= '&perpage='.$perpage;
$searchlang = array();
$keys = array('search', 'likesupport', 'lengthabove1', 'resultsort', 'defaultsort', 'orderdesc', 'orderasc', 'perpage_10', 'perpage_20', 'perpage_50', 'perpage_100',
'block_dateline', 'block_id', 'block_name', 'block_blockclass', 'block_add_jscall', 'block_choose_blockclass_to_add_jscall', 'block_diytemplate', 'block_permname', 'block_permname_tips');
foreach ($keys as $key) {
$searchlang[$key] = cplang($key);
}
$diytemplatename_sel = '<select name="targettplname" id="targettplname">';
$diytemplatename_sel .= '<option value="">'.cplang('diytemplate_name').'</option>';
foreach($_G['cache']['diytemplatename'] as $key=>$value) {
$selected = ($key == $_GET['targettplname'] ? ' selected' : '');
$diytemplatename_sel .= "<option value=\"$key\"$selected>$value</option>";
}
$diytemplatename_sel .= '</select>';
$blockclass_sel = '<select name="blockclass" id="blockclass">';
$blockclass_sel .= '<option value="">'.cplang('blockstyle_blockclass_sel').'</option>';
foreach($_G['cache']['blockclass'] as $key=>$value) {
foreach($value['subs'] as $subkey=>$subvalue) {
$selected = ($subkey == $_GET['blockclass'] ? ' selected' : '');
$blockclass_sel .= "<option value=\"$subkey\"$selected>{$subvalue['name']}</option>";
}
}
$blockclass_sel .= '</select>';
$addjscall = $operation == 'jscall' ? '<input type="button" class="btn" onclick="addjscall()" value="'.$searchlang['block_add_jscall'].'" />' : '';
$firstrow = "<th>{$searchlang['block_diytemplate']}</th><td>$diytemplatename_sel</td><th>{$searchlang['block_blockclass']}</th><td colspan=\"2\">$blockclass_sel $addjscall</td>";
$adminscript = ADMINSCRIPT;
echo <<<SEARCH
<script>disallowfloat = '{$_G['setting']['disallowfloat']}';</script>
<script type="text/javascript" src="{$_G['setting']['jspath']}portal.js?{$_G['style']['verhash']}"></script>
<div id="ajaxwaitid"></div>
<form method="get" autocomplete="off" action="$adminscript" id="tb_search">
<table cellspacing="3" cellpadding="3" class="tb tb2">
<tr>
$firstrow
</tr>
<tr>
<th>{$searchlang['block_id']}</th><td><input type="text" class="txt" name="bid" value="{$_GET['bid']}"></td>
<th>{$searchlang['block_name']}*</th><td><input type="text" class="txt" name="name" value="{$_GET['name']}">{$searchlang['lengthabove1']}&nbsp;&nbsp; *{$searchlang['likesupport']}</td>
</tr>
<tr>
<th>{$searchlang['resultsort']}</th>
<td>
<select name="orderby">
<option value="">{$searchlang['defaultsort']}</option>
<option value="dateline"{$orderby['dateline']}>{$searchlang['block_dateline']}</option>
</select>
<select name="ordersc">
<option value="desc"{$ordersc['desc']}>{$searchlang['orderdesc']}</option>
<option value="asc"{$ordersc['asc']}>{$searchlang['orderasc']}</option>
</select>
<select name="perpage">
<option value="10"{$perpages[10]}>{$searchlang['perpage_10']}</option>
<option value="20"{$perpages[20]}>{$searchlang['perpage_20']}</option>
<option value="50"{$perpages[50]}>{$searchlang['perpage_50']}</option>
<option value="100"{$perpages[100]}>{$searchlang['perpage_100']}</option>
</select>
<input type="hidden" name="action" value="block">
<input type="hidden" name="operation" value="$operation">
</td>
<th>{$searchlang['block_permname']}</th><td><input type="text" class="txt" name="permname" value="{$_GET['permname']}">{$searchlang['block_permname_tips']}
<input type="submit" name="searchsubmit" value="{$searchlang['search']}" class="btn"></td>
</tr>
</table>
</form>
<script type="text/javascript">
function addjscall() {
var blockclass = $('blockclass').value;
if(blockclass) {
showWindow('blockclass', 'portal.php?mod=portalcp&ac=block&op=block&blocktype=1&from=cp&classname=' + blockclass);
} else {
alert('{$searchlang['block_choose_blockclass_to_add_jscall']}');
}
}
</script>
SEARCH;
$start = ($page-1)*$perpage;
showformheader('block&operation='.$operation);
showtableheader();
$list = $diypage = array();
include_once libfile('function/block');
if($operation=='jscall') {
showsubtitle(array('', 'block_name', 'block_script', 'block_style', 'block_dateline', 'block_page', 'operation'));
$multipage = '';
if(($count = C::t('common_block')->count_by_admincpwhere($wheresql))) {
foreach(C::t('common_block')->fetch_all_by_admincpwhere($wheresql, $ordersql, $start, $perpage) as $value) {
if($value['targettplname']) {
$diyurl = block_getdiyurl($value['targettplname']);
$diyurl = $diyurl['url'];
$tplname = isset($_G['cache']['diytemplatename'][$value['targettplname']]) ? $_G['cache']['diytemplatename'][$value['targettplname']] : $value['targettplname'];
$diypage[$value['bid']][$value['targettplname']] = $diyurl ? '<a href="'.$diyurl.'" target="_blank">'.$tplname.'</a>' : $tplname;
}
$list[$value['bid']] = $value;
}
if($list) {
foreach($list as $bid => $value) {
$inpage = empty($diypage[$bid]) ? cplang('block_page_nopage') : implode('<br/>' ,$diypage[$bid]);
$theclass = block_getclass($value['blockclass'], true);
showtablerow('', array('class="td25"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"ids[]\" value=\"{$value['bid']}\">",
!empty($value['name']) ? $value['name'] : cplang('block_name_null'),
$theclass['script'][$value['script']],
$value['styleid'] ? $theclass['style'][$value['styleid']]['name'] : lang('portalcp', 'blockstyle_diy'),
!empty($value['dateline']) ? dgmdate($value['dateline']) : cplang('block_dateline_null'),
$inpage,
"<a href=\"portal.php?mod=portalcp&ac=block&op=block&bid={$value['bid']}&blocktype=1&from=cp\" target=\"_blank\" onclick=\"showWindow('showblock',this.href);return false;\">".cplang('block_setting')."</a> &nbsp;&nbsp".
"<a href=\"portal.php?mod=portalcp&ac=block&op=getblock&forceupdate=1&inajax=1&bid={$value['bid']}&from=cp\" onclick=\"ajaxget(this.href,'','','','',function(){location.reload();});return false;\">".cplang('block_update')."</a> &nbsp;&nbsp".
"<a href=\"portal.php?mod=portalcp&ac=block&op=data&bid={$value['bid']}&blocktype=1&from=cp\" target=\"_blank\" onclick=\"showWindow('showblock',this.href);return false;\">".cplang('block_data')."</a> &nbsp;&nbsp".
"<a href=\"javascript:;\" onclick=\"prompt('".cplang('block_copycode_message')."', '<!--{block/{$value['bid']}}-->')\">".cplang('block_copycode_inner')."</a> &nbsp;&nbsp".
"<a href=\"javascript:;\" onclick=\"prompt('".cplang('block_copycode_jsmessage')."', '&lt;script type=&quot;text/javascript&quot; src=&quot;{$_G['siteurl']}api.php?mod=js&bid={$value['bid']}&quot;&gt;&lt;/script&gt;')\">".cplang('block_copycode_outer')."</a>&nbsp;&nbsp;<a href=\"".ADMINSCRIPT."?action=block&operation=perm&bid={$value['bid']}\">".cplang('portalcategory_perm').'</a>'
));
}
}
$multipage = multi($count, $perpage, $page, $mpurl);
}
showsubmit('', '', '', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'ids\')" /><label for="chkall">'.cplang('select_all').'</label>&nbsp;&nbsp;<input type="submit" class="btn" name="deletesubmit" value="'.cplang('block_delete').'" />', $multipage);
showtablefooter();
showformfooter();
} else {
showsubtitle(array('block_name', 'block_script', 'block_style', 'block_dateline', 'block_page', 'operation'));
$multipage = '';
if(($count = C::t('common_block')->count_by_admincpwhere($wheresql))) {
foreach(C::t('common_block')->fetch_all_by_admincpwhere($wheresql, $ordersql, $start, $perpage) as $value) {
if($value['targettplname']) {
$diyurl = block_getdiyurl($value['targettplname']);
$diyurl = $diyurl['url'];
$tplname = isset($_G['cache']['diytemplatename'][$value['targettplname']]) ? $_G['cache']['diytemplatename'][$value['targettplname']] : $value['targettplname'];
$diypage[$value['bid']][$value['targettplname']] = $diyurl ? '<a href="'.$diyurl.'" target="_blank">'.$tplname.'</a>' : $tplname;
}
$list[$value['bid']] = $value;
}
if($list) {
foreach($list as $bid => $value) {
$inpage = empty($diypage[$bid]) ? cplang('block_page_unused') : implode('<br/>' ,$diypage[$bid]);
$theclass = block_getclass($value['blockclass'], true);
showtablerow('', '', array(
$value['name'] ? $value['name'] : cplang('block_name_null'),
$theclass['script'][$value['script']],
$value['styleid'] ? $theclass['style'][$value['styleid']]['name'] : lang('portalcp', 'blockstyle_diy'),
!empty($value['dateline']) ? dgmdate($value['dateline']) : cplang('block_dateline_null'),
$inpage,
"<a href=\"portal.php?mod=portalcp&ac=block&op=block&bid={$value['bid']}&from=cp\" target=\"_blank\" onclick=\"showWindow('showblock',this.href);return false;\">".cplang('block_setting')."</a> &nbsp;&nbsp"
."<a href=\"portal.php?mod=portalcp&ac=block&op=data&bid={$value['bid']}&from=cp\" target=\"_blank\" onclick=\"showWindow('showblock',this.href);return false;\">".cplang('block_data')."</a> &nbsp;&nbsp"
.$diyop."&nbsp;&nbsp;<a href=\""
.ADMINSCRIPT."?action=block&operation=perm&bid={$value['bid']}\">".cplang('portalcategory_perm').'</a>'
));
}
}
$multipage = multi($count, $perpage, $page, $mpurl);
}
showsubmit('', '', '', '<input type="submit" class="btn" name="clearsubmit" value="'.cplang('block_clear_unused').'" />', $multipage);
showtablefooter();
showformfooter();
}
}
}
?>

View File

@@ -0,0 +1,334 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_blockstyle.php 32661 2013-02-28 06:29:46Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = in_array($operation, array('add', 'edit', 'delete')) ? $operation : 'list';
loadcache('blockclass');
shownav('portal', 'blockstyle');
if($operation=='add' || $operation=='edit') {
if($operation=='edit') {
showsubmenu('blockstyle', array(
array('list', 'blockstyle', 0),
array('edit', 'blockstyle&operation=edit&blockclass='.$_GET['blockclass'].'&styleid='.$_GET['styleid'], 1)
));
} else {
showsubmenu('blockstyle', array(
array('list', 'blockstyle', 0),
array('add', 'blockstyle&operation=add', 1)
));
}
include_once libfile('function/block');
if(empty($_GET['blockclass'])) {
$blockclass_sel = '<select name="blockclass">';
$blockclass_sel .= '<option value="">'.cplang('blockstyle_blockclass_sel').'</option>';
foreach($_G['cache']['blockclass'] as $key=>$value) {
foreach($value['subs'] as $subkey=>$subvalue) {
$blockclass_sel .= "<option value=\"$subkey\">{$subvalue['name']}</option>";
}
}
$blockclass_sel .= '</select>';
$adminscript = ADMINSCRIPT;
$lang_blockclasssel = cplang('blockstyle_blockclass_sel');
$lang_submit = cplang('submit');
echo <<<BLOCKCLASSSEL
<form method="get" autocomplete="off" action="$adminscript">
<div style="margin-top:8px;">
<table class="tb tb2 nobottom nobdb" cellspacing="3" cellpadding="3">
<tr>
<th class="td27">$lang_blockclasssel</th>
</tr>
<tr>
<td class="vtop rowform">$blockclass_sel</td>
</tr>
<tr>
<td class="vtop rowform">
<input type="hidden" name="action" value="blockstyle" />
<input type="hidden" name="operation" value="add" />
<div class="fixsel"><input type="submit" value="$lang_submit" class="btn" /></div>
</td>
</tr>
</table>
</div>
</form>
BLOCKCLASSSEL;
} else {
showtips('blockstyle_add_tips');
if(submitcheck('stylesubmit')) {
$arr = array(
'name' => $_POST['name'],
'blockclass' => $_GET['blockclass'],
);
$_POST['template'] = $_POST['template'];
include_once libfile('function/block');
block_parse_template($_POST['template'], $arr);
if($_GET['styleid']) {
$styleid = intval($_GET['styleid']);
C::t('common_block_style')->update($styleid, $arr);
require_once libfile('function/block');
blockclass_cache();
cpmsg('blockstyle_edit_succeed', 'action=blockstyle&operation=edit&blockclass='.$_GET['blockclass'].'&styleid='.$styleid.'&preview='.($_POST['preview']?'1':'0'), 'succeed');
} else {
$styleid = C::t('common_block_style')->insert($arr, true);
$msg = 'blockstyle_create_succeed';
require_once libfile('function/block');
blockclass_cache();
cpmsg('blockstyle_create_succeed', 'action=blockstyle&operation=edit&blockclass='.$_GET['blockclass'].'&styleid='.$styleid.'&preview='.($_POST['preview']?'1':'0'), 'succeed');
}
}
if($_GET['styleid']) {
$_GET['styleid'] = intval($_GET['styleid']);
include_once libfile('function/block');
$thestyle = block_getstyle($_GET['styleid']);
if(!$thestyle) {
cpmsg('blockstyle_not_found!');
}
$thestyle['template'] = block_build_template($thestyle['template']);
$_GET['blockclass'] = $thestyle['blockclass'];
} else {
$_GET['styleid'] = 0;
$thestyle = array(
'template' => "<div class=\"module cl\">\n<ul>\n[loop]\n\t<li><a href=\"{url}\"{target}>{title}</a></li>\n[/loop]\n</ul>\n</div>"
);
}
$theclass = block_getclass($_GET['blockclass']);
if($preview) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$preview;
}
showformheader('blockstyle&operation='.$operation.'&blockclass='.$_GET['blockclass'].'&styleid='.$_GET['styleid']);
showtableheader('', 'nobottom');
if($_GET['styleid']) {
showtitle('blockstyle_add_editstyle');
} else {
showtitle('blockstyle_add_addstyle');
}
showsetting('blockstyle_name', 'name', $thestyle['name'], 'text');
showtablefooter();
$template = '';
foreach($theclass['fields'] as $key=>$value) {
if($value['name']) {
$template .= $value['name']. ': <a href="###" onclick="insertunit($(\'jstemplate\'), \'{'.$key.'}\')">{'.$key.'}</a>';
}
}
$template .= '<br />';
$template .= cplang('blockstyle_add_loop').': <a href="###" onclick="insertunit($(\'jstemplate\'), \'[loop]\n\n[/loop]\')">[loop]...[/loop]</a>';
$template .= cplang('blockstyle_add_order').': <a href="###" onclick="insertunit($(\'jstemplate\'), \'[order=N]\n\n[/order]\')">[order=N]...[/order]</a>';
$template .= cplang('blockstyle_add_index').': <a href="###" onclick="insertunit($(\'jstemplate\'), \'[index=N]\n\n[/index]\')">[index=N]...[/index]</a>';
$template .= cplang('blockstyle_add_urltitle').': <a href="###" onclick=\'insertunit($("jstemplate"), "<a href=\"{url}\"{target}>{title}</a>")\'>&lt;a href=...</a>';
$template .= cplang('blockstyle_add_picthumb').': <a href="###" onclick=\'insertunit($("jstemplate"), "<img src=\"{pic}\" width=\"{picwidth}\" height=\"{picheight}\" />")\'>&lt;img src=...&gt;</a>';
if(in_array($_GET['blockclass'], array('forum_thread', 'portal_article', 'group_thread'), true)) {
$template .= cplang('blockstyle_add_moreurl').': <a href="###" onclick="insertunit($(\'jstemplate\'), \'{moreurl}\')">{moreurl}</a>';
}
$template .= cplang('blockstyle_add_currentorder').': <a href="###" onclick="insertunit($(\'jstemplate\'), \'{currentorder}\')">{currentorder}</a>';
$template .= cplang('blockstyle_add_parity').': <a href="###" onclick="insertunit($(\'jstemplate\'), \'{parity}\')">{parity}</a>';
$template .= '</div><br />';
$template .= '<textarea cols="100" rows="5" id="jstemplate" name="template" style="width: 95%;" onkeyup="textareasize(this)" onkeydown="textareakey(this, event)">'.$thestyle['template'].'</textarea>';
$template .= '<input type="hidden" name="preview" value="0" /><input type="hidden" name="stylesubmit" value="1" />';
$template .= '<br /><!--input type="button" class="btn" onclick="this.form.preview=\'1\';this.form.submit()" value="'.$lang['preview'].'">&nbsp; &nbsp;--><input type="submit" class="btn" style="margin-left: 0px;" value="'.$lang['submit'].'"></div>';
echo '<div class="colorbox" style="padding-bottom: 10px;">';
echo '<div class="extcredits">';
echo $template;
echo '</div>';
showformfooter();
}
} elseif($operation=='delete') {
$_GET['styleid'] = intval($_GET['styleid']);
$thestyle = C::t('common_block_style')->fetch($_GET['styleid']);
if(empty($thestyle)) {
cpmsg('blockstyle_not_found', 'action=blockstyle', 'error');
}
$styles = array();
if(($styles = C::t('common_block_style')->fetch_all_by_blockclass($thestyle['blockclass']))) {
unset($styles[$_GET['styleid']]);
}
if(empty($styles)) {
cpmsg('blockstyle_should_be_kept', 'action=blockstyle', 'error');
}
if(submitcheck('deletesubmit')) {
$_POST['moveto'] = intval($_POST['moveto']);
$newstyle = C::t('common_block_style')->fetch($_POST['moveto']);
if($newstyle['blockclass'] != $thestyle['blockclass']) {
cpmsg('blockstyle_blockclass_not_match', 'action=blockstyle', 'error');
}
C::t('common_block')->update_by_styleid($styleid, array('styleid' => $_POST['moveto']));
C::t('common_block_style')->delete($_GET['styleid']);
require_once libfile('function/block');
blockclass_cache();
cpmsg('blockstyle_delete_succeed', 'action=blockstyle', 'succeed');
}
if(C::t('common_block')->fetch_by_styleid($_GET['styleid'])) {
showtips('blockstyle_delete_tips');
showformheader('blockstyle&operation=delete&styleid='.$_GET['styleid']);
showtableheader();
$movetoselect = '<select name="moveto">';
foreach($styles as $key=>$value) {
$movetoselect .= "<option value=\"$key\">{$value['name']}</option>";
}
$movetoselect .= '</select>';
showsetting('blockstyle_moveto', '', '', $movetoselect);
showsubmit('deletesubmit');
showtablefooter();
showformfooter();
} else {
C::t('common_block_style')->delete($_GET['styleid']);
require_once libfile('function/block');
blockclass_cache();
cpmsg('blockstyle_delete_succeed', 'action=blockstyle', 'succeed');
}
} else {
$_GET = $_GET + $_POST;
$searchctrl = '<span style="float: right; padding-right: 40px;">'
.'<a href="javascript:;" onclick="$(\'tb_search\').style.display=\'\';$(\'a_search_show\').style.display=\'none\';$(\'a_search_hide\').style.display=\'\';" id="a_search_show" style="display:none">'.cplang('show_search').'</a>'
.'<a href="javascript:;" onclick="$(\'tb_search\').style.display=\'none\';$(\'a_search_show\').style.display=\'\';$(\'a_search_hide\').style.display=\'none\';" id="a_search_hide">'.cplang('hide_search').'</a>'
.'</span>';
showsubmenu('blockstyle', array(
array('list', 'blockstyle', 1),
array('add', 'blockstyle&operation=add', 0)
), $searchctrl);
$mpurl = ADMINSCRIPT.'?action=blockstyle';
$intkeys = array('styleid');
$strkeys = array('blockclass');
$randkeys = array();
$likekeys = array('name', 'template');
$results = getwheres($intkeys, $strkeys, $randkeys, $likekeys);
foreach($likekeys as $k) {
$_GET[$k] = dhtmlspecialchars($_GET[$k]);
}
$wherearr = $results['wherearr'];
$mpurl .= '&'.implode('&', $results['urls']);
$wheresql = empty($wherearr)?'1':implode(' AND ', $wherearr);
$orders = getorders(array('blockclass'), 'styleid');
$ordersql = $orders['sql'];
if($orders['urls']) $mpurl .= '&'.implode('&', $orders['urls']);
$orderby = array($_GET['orderby']=>' selected');
$ordersc = array($_GET['ordersc']=>' selected');
$perpage = empty($_GET['perpage'])?0:intval($_GET['perpage']);
if(!in_array($perpage, array(10,20,50,100))) $perpage = 20;
$perpages = array($perpage=>' selected');
$mpurl .= '&perpage='.$perpage;
$searchlang = array();
$keys = array('search', 'likesupport', 'resultsort', 'defaultsort', 'orderdesc', 'orderasc', 'perpage_10', 'perpage_20', 'perpage_50', 'perpage_100',
'blockstyle_id', 'blockstyle_name', 'blockstyle_blockclass', 'blockstyle_template');
foreach ($keys as $key) {
$searchlang[$key] = cplang($key);
}
$blockclass_sel = '<select name="blockclass">';
$blockclass_sel .= '<option value="">'.cplang('blockstyle_blockclass_sel').'</option>';
foreach($_G['cache']['blockclass'] as $key=>$value) {
foreach($value['subs'] as $subkey=>$subvalue) {
$selected = (!empty($_GET['blockclass']) && $subkey == $_GET['blockclass'] ? ' selected' : '');
$blockclass_sel .= "<option value=\"$subkey\"$selected>{$subvalue['name']}</option>";
}
}
$blockclass_sel .= '</select>';
$adminscript = ADMINSCRIPT;
echo <<<SEARCH
<form method="post" autocomplete="off" action="$adminscript" id="tb_search">
<div class="dbox"><div class="boxbody">
<table cellspacing="3" cellpadding="3" class="tb tb2">
<tr>
<th>{$searchlang['blockstyle_id']}</th><td><input type="text" class="txt" name="styleid" value="{$_GET['styleid']}"></td>
<th>{$searchlang['blockstyle_name']}*</th><td><input type="text" class="txt" name="name" value="{$_GET['name']}">*{$searchlang['likesupport']}</td>
</tr>
<tr>
<th>{$searchlang['blockstyle_blockclass']}</th><td>$blockclass_sel</td>
<th>{$searchlang['blockstyle_template']}*</th><td><input type="text" name="template" value="{$_GET['template']}">*{$searchlang['likesupport']}</td>
</tr>
<tr>
<th>{$searchlang['resultsort']}</th>
<td colspan="3">
<select name="orderby">
<option value="styleid">{$searchlang['defaultsort']}</option>
<option value="blockclass"{$orderby['blockclass']}>{$searchlang['blockstyle_blockclass']}</option>
</select>
<select name="ordersc">
<option value="desc"{$ordersc['desc']}>{$searchlang['orderdesc']}</option>
<option value="asc"{$ordersc['asc']}>{$searchlang['orderasc']}</option>
</select>
<select name="perpage">
<option value="10"{$perpages[10]}>{$searchlang['perpage_10']}</option>
<option value="20"{$perpages[20]}>{$searchlang['perpage_20']}</option>
<option value="50"{$perpages[50]}>{$searchlang['perpage_50']}</option>
<option value="100"{$perpages[100]}>{$searchlang['perpage_100']}</option>
</select>
<input type="hidden" name="action" value="blockstyle">
<input type="submit" name="searchsubmit" value="{$searchlang['search']}" class="btn">
</td>
</tr>
</table>
</div></div>
</form>
SEARCH;
$start = ($page-1)*$perpage;
showformheader('blockstyle');
showboxheader('blockstyle_list');
showtableheader();
showsubtitle(array('blockstyle_name', 'blockstyle_blockclass', 'operation'));
$multipage = '';
if(($count = C::t('common_block_style')->count_by_where($wheresql))) {
include_once libfile('function/block');
foreach(C::t('common_block_style')->fetch_all_by_where($wheresql, $ordersql, $start, $perpage) as $value) {
$theclass = block_getclass($value['blockclass']);
list($c1, $c2) = explode('_', $value['blockclass']);
showtablerow('', array('class=""', 'class=""', 'class="td28"'), array(
$value['name'],
$theclass['name'],
"<a href=\"".ADMINSCRIPT."?action=blockstyle&operation=edit&blockclass={$value['blockclass']}&styleid={$value['styleid']}\">".cplang('blockstyle_edit')."</a>&nbsp;&nbsp;".
"<a href=\"".ADMINSCRIPT."?action=blockstyle&operation=delete&styleid={$value['styleid']}\">".cplang('blockstyle_delete')."</a>"
));
}
$multipage = multi($count, $perpage, $page, $mpurl);
}
showsubmit('', '', '', '', $multipage);
showtablefooter();
showboxfooter();
showformfooter();
}
?>

View File

@@ -0,0 +1,127 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_blockxml.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = in_array($operation, array('add', 'edit', 'update', 'delete')) ? $operation : 'list';
$signtypearr = array(array('',cplang('blockxml_signtype_no')), array('MD5',cplang('blockxml_signtype_md5')));
shownav('portal', 'blockxml');
if($operation == 'add') {
if(submitcheck('addsubmit')) {
require_once libfile('function/importdata');
import_block($_GET['xmlurl'], $_GET['clientid'], $_GET['key'], $_GET['signtype'], $_GET['ignoreversion']);
require_once libfile('function/block');
blockclass_cache();
cpmsg('blockxml_xmlurl_add_succeed', 'action=blockxml', 'succeed');
} else {
showsubmenu('blockxml', array(
array('list', 'blockxml', 0),
array('add', 'blockxml&operation=add', 1)
));
showtips('blockxml_tips');
showformheader('blockxml&operation=add');
showtableheader('blockxml_add');
showsetting('blockxml_xmlurl', 'xmlurl', '', 'text');
showsetting('blockxml_clientid', 'clientid', $blockxml['clientid'], 'text');
showsetting('blockxml_signtype', array('signtype', $signtypearr), $blockxml['signtype'], 'select');
showsetting('blockxml_xmlkey', 'key', $blockxml['key'], 'text');
echo '<tr><td colspan="2" class="rowform"><input class="checkbox" type="checkbox" name="ignoreversion" id="ignoreversion" value="1" /><label for="ignoreversion"> '.cplang('blockxml_import_ignore_version').'</label></td></tr>';
showsubmit('addsubmit');
showtablefooter();
showformfooter();
}
} elseif($operation == 'edit' && !empty($_GET['id'])) {
$id = intval($_GET['id']);
if(!($blockxml = C::t('common_block_xml')->fetch($id))) {
cpmsg('blockxml_xmlurl_notfound', '', 'error');
}
if(submitcheck('editsubmit')) {
require_once libfile('function/importdata');
import_block($_GET['xmlurl'], $_GET['clientid'], $_GET['key'], $_GET['signtype'], 1, $id);
require_once libfile('function/block');
blockclass_cache();
cpmsg('blockxml_xmlurl_update_succeed', 'action=blockxml', 'succeed');
} else {
showsubmenu('blockxml', array(
array('list', 'blockxml', 0),
array('add', 'blockxml&operation=add', 1)
));
showformheader('blockxml&operation=edit&id='.$id);
showtableheader(cplang('blockxml_edit').' - '.$blockxml['name']);
showsetting('blockxml_xmlurl', 'xmlurl', $blockxml['url'], 'text');
showsetting('blockxml_clientid', 'clientid', $blockxml['clientid'], 'text');
showsetting('blockxml_signtype', array('signtype', $signtypearr), $blockxml['signtype'], 'select');
showsetting('blockxml_xmlkey', 'key', $blockxml['key'], 'text');
showtablerow('', '', '<input class="checkbox" type="checkbox" name="ignoreversion" id="ignoreversion" value="1" /><label for="ignoreversion"> '.cplang('blockxml_import_ignore_version').'</label>');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
}
} elseif($operation == 'update' && !empty($_GET['id'])) {
$id = intval($_GET['id']);
if(!($blockxml = C::t('common_block_xml')->fetch($id))) {
cpmsg('blockxml_xmlurl_notfound', '', 'error');
}
require_once libfile('function/importdata');
import_block($blockxml['url'], $blockxml['clientid'], $blockxml['key'], $blockxml['signtype'], 1, $id);
require_once libfile('function/block');
blockclass_cache();
cpmsg('blockxml_xmlurl_update_succeed', 'action=blockxml', 'succeed');
} elseif($operation == 'delete' && !empty($_GET['id'])) {
$id = intval($_GET['id']);
if(!empty($_GET['confirm'])) {
C::t('common_block_xml')->delete($id);
require_once libfile('function/block');
blockclass_cache();
cpmsg('blockxml_xmlurl_delete_succeed', 'action=blockxml', 'succeed');
} else {
cpmsg('blockxml_xmlurl_delete_confirm', 'action=blockxml&operation=delete&id='.$id.'&confirm=yes', 'form');
}
} else {
showsubmenu('blockxml', array(
array('list', 'blockxml', 1),
array('add', 'blockxml&operation=add', 0)
));
showtableheader('blockxml_list');
showsubtitle(array('blockxml_name', 'blockxml_xmlurl', 'operation'));
foreach(C::t('common_block_xml')->range() as $row) {
showtablerow('', array('class=""', 'class=""', 'class="td28"'), array(
$row['name'],
$row['url'],
"<a href=\"".ADMINSCRIPT."?action=blockxml&operation=update&id={$row['id']}\">".cplang('blockxml_update')."</a>&nbsp;&nbsp;".
"<a href=\"".ADMINSCRIPT."?action=blockxml&operation=edit&id={$row['id']}\">".cplang('edit')."</a>&nbsp;&nbsp;".
"<a href=\"".ADMINSCRIPT."?action=blockxml&operation=delete&id={$row['id']}\">".cplang('delete')."</a>&nbsp;&nbsp;"
));
}
showtablefooter();
showformfooter();
}
?>

View File

@@ -0,0 +1,317 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_blog.php 32130 2012-11-14 09:20:40Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
include_once libfile('function/portalcp');
cpheader();
$detail = $_GET['detail'];
$uid = $_GET['uid'];
$blogid = $_GET['blogid'];
$users = $_GET['users'];
$keywords = $_GET['keywords'];
$lengthlimit = $_GET['lengthlimit'];
$viewnum1 = $_GET['viewnum1'];
$viewnum2 = $_GET['viewnum2'];
$replynum1 = $_GET['replynum1'];
$replynum2 = $_GET['replynum2'];
$hot1 = $_GET['hot1'];
$hot2 = $_GET['hot2'];
$starttime = $_GET['starttime'];
$endtime = $_GET['endtime'];
$searchsubmit = $_GET['searchsubmit'];
$blogids = $_GET['blogids'];
$friend = $_GET['friend'];
$ip = $_GET['ip'];
$orderby = $_GET['orderby'];
$ordersc = $_GET['ordersc'];
$fromumanage = $_GET['fromumanage'] ? 1 : 0;
$muticondition = '';
$muticondition .= $uid ? '&uid='.$uid : '';
$muticondition .= $blogid ? '&blogid='.$blogid : '';
$muticondition .= $users ? '&users='.$users : '';
$muticondition .= $keywords ? '&keywords='.$keywords : '';
$muticondition .= $lengthlimit ? '&lengthlimit='.$lengthlimit : '';
$muticondition .= $viewnum1 ? '&viewnum1='.$viewnum1 : '';
$muticondition .= $viewnum2 ? '&viewnum2='.$viewnum2 : '';
$muticondition .= $replynum1 ? '&replynum1='.$replynum1 : '';
$muticondition .= $replynum2 ? '&replynum2='.$replynum2 : '';
$muticondition .= $hot1 ? '&hot1='.$hot1 : '';
$muticondition .= $hot2 ? '&hot2='.$hot2 : '';
$muticondition .= $starttime ? '&starttime='.$starttime : '';
$muticondition .= $endtime ? '&endtime='.$endtime : '';
$muticondition .= $friend ? '&friend='.$friend : '';
$muticondition .= $ip ? '&ip='.$ip : '';
$muticondition .= $orderby ? '&orderby='.$orderby : '';
$muticondition .= $ordersc ? '&ordersc='.$ordersc : '';
$muticondition .= $fromumanage ? '&fromumanage='.$fromumanage : '';
$muticondition .= $searchsubmit ? '&searchsubmit='.$searchsubmit : '';
$muticondition .= $_GET['search'] ? '&search='.$_GET['search'] : '';
$muticondition .= $detail ? '&detail='.$detail : '';
if(!submitcheck('blogsubmit')) {
if(empty($_GET['search'])) {
$newlist = 1;
$detail = 1;
}
if($fromumanage) {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? '' : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? '' : $endtime;
} else {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? dgmdate(TIMESTAMP - 86400 * 7, 'Y-n-j') : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? dgmdate(TIMESTAMP, 'Y-n-j') : $endtime;
}
shownav('topic', 'nav_blog');
showsubmenu('nav_blog', array(
array('newlist', 'blog', !empty($newlist)),
array('search', 'blog&search=true', empty($newlist)),
));
empty($newlist) && showsubmenusteps('', array(
array('blog_search', !$searchsubmit),
array('nav_blog', $searchsubmit)
));
if($muticondition) {
showtips('blog_tips');
}
$staticurl = STATICURL;
echo <<<EOT
<script type="text/javascript" src="{$staticurl}js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('blogforum').page.value=number;
$('blogforum').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'searchposts', !$searchsubmit && empty($newlist));
showformheader("blog".(!empty($_GET['search']) ? '&search=true' : ''), '', 'blogforum');
showhiddenfields(array('page' => $page, 'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']));
showtableheader();
showsetting('blog_search_detail', 'detail', $detail, 'radio');
showsetting('blog_search_perpage', '', $_GET['perpage'], "<select name='perpage'><option value='20'>{$lang['perpage_20']}</option><option value='50'>{$lang['perpage_50']}</option><option value='100'>{$lang['perpage_100']}</option></select>");
showsetting('resultsort', '', $orderby, "<select name='orderby'><option value=''>{$lang['defaultsort']}</option><option value='dateline'>{$lang['forums_edit_extend_order_starttime']}</option><option value='viewnum'>{$lang['blog_search_view']}</option><option value='replynum'>{$lang['blog_search_reply']}</option><option value='hot'>{$lang['blog_search_hot']}</option></select> ");
showsetting('', '', $ordersc, "<select name='ordersc'><option value='desc'>{$lang['orderdesc']}</option><option value='asc'>{$lang['orderasc']}</option></select>", '', 0, '', '', '', true);
showsetting('blog_search_uid', 'uid', $uid, 'text');
showsetting('blog_search_blogid', 'blogid', $blogid, 'text');
showsetting('blog_search_user', 'users', $users, 'text');
showsetting('blog_search_keyword', 'keywords', $keywords, 'text');
showsetting('blog_search_friend', '', $friend, "<select name='friend'><option value='0'>{$lang['setting_home_privacy_alluser']}</option><option value='1'>{$lang['setting_home_privacy_friend']}</option><option value='2'>{$lang['setting_home_privacy_specified_friend']}</option><option value='3'>{$lang['setting_home_privacy_self']}</option><option value='4'>{$lang['setting_home_privacy_password']}</option></select>");
showsetting('blog_search_ip', 'ip', $ip, 'text');
showsetting('blog_search_lengthlimit', 'lengthlimit', $lengthlimit, 'text');
showsetting('blog_search_view', array('viewnum1', 'viewnum2'), array('', ''), 'range');
showsetting('blog_search_reply', array('replynum1', 'replynum2'), array('', ''), 'range');
showsetting('blog_search_hot', array('hot1', 'hot2'), array('', ''), 'range');
showsetting('blog_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
echo '<input type="hidden" name="fromumanage" value="'.$fromumanage.'">';
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
if($_GET['blogids']) {
$blogids = authcode($_GET['blogids'], 'DECODE');
$blogidsadd = $blogids ? explode(',', $blogids) : $_GET['delete'];
include_once libfile('function/delete');
$deletecount = count(deleteblogs($blogidsadd));
$cpmsg = cplang('blog_succeed', array('deletecount' => $deletecount));
} else {
$blogs = $catids = array();
$selectblogids = !empty($_GET['ids']) && is_array($_GET['ids']) ? $_GET['ids'] : array();
if($selectblogids) {
$query = C::t('home_blog')->fetch_all_blog($selectblogids);
foreach($query as $value) {
$blogs[$value['blogid']] = $value;
$catids[] = intval($value['catid']);
}
}
if($blogs) {
$selectblogids = array_keys($blogs);
if($_POST['optype'] == 'delete') {
include_once libfile('function/delete');
$deletecount = count(deleteblogs($selectblogids));
$cpmsg = cplang('blog_succeed', array('deletecount' => $deletecount));
} elseif($_POST['optype'] == 'move') {
$tocatid = intval($_POST['tocatid']);
$catids[] = $tocatid;
$catids = array_merge($catids);
C::t('home_blog')->update($selectblogids, array('catid'=>$tocatid));
foreach($catids as $catid) {
$catid = intval($catid);
$cnt = C::t('home_blog')->count_by_catid($catid);
C::t('home_blog_category')->update($catid, array('num'=>$cnt));
}
$cpmsg = cplang('blog_move_succeed');
} else {
$cpmsg = cplang('blog_choose_at_least_one_operation');
}
} else {
$cpmsg = cplang('blog_choose_at_least_one_blog');
}
}
?>
<script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('blogforum').searchsubmit.click();</script>
<?php
}
if(submitcheck('searchsubmit', 1) || $newlist) {
$blogids = $blogcount = '0';
$sql = $error = '';
$keywords = trim($keywords);
$users = trim($users);
$uids = array();
if($blogid != '') {
$blogid = explode(',', $blogid);
}
if($users != '') {
$uids = C::t('common_member')->fetch_all_uid_by_username(array_map('trim', explode(',', $users)));
if(!$uids) {
$uids = array(-1);
}
}
$uid = trim($uid, ', ');
if($uid != '') {
$uid = explode(',', $uid);
if($uids && $uids[0] != -1) {
$uids = array_intersect($uids, $uid);
} else {
$uids = $uid;
}
if(!$uids) {
$uids = array(-1);
}
}
if($starttime != '') {
$starttime = strtotime($starttime);
}
if($_G['adminid'] == 1 && $endtime != dgmdate(TIMESTAMP, 'Y-n-j')) {
if($endtime != '') {
$endtime = strtotime($endtime);
}
} else {
$endtime = TIMESTAMP;
}
if(($_G['adminid'] == 2 && $endtime - $starttime > 86400 * 16) || ($_G['adminid'] == 3 && $endtime - $starttime > 86400 * 8)) {
$error = 'blog_mod_range_illegal';
}
if(!$error) {
if($detail) {
$pagetmp = $page;
$_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
$perpage = $_GET['pp'] ? $_GET['pp'] : $_GET['perpage'];
do{
$query = C::t('home_blog')->fetch_all_by_search(1, $blogid, $uids, $starttime, $endtime, $hot1, $hot2, $viewnum1, $viewnum2, $replynum1, $replynum2, $friend, $ip, $keywords, $lengthlimit, $orderby, $ordersc, (($pagetmp - 1) * $perpage), $perpage, null, null, null, null, false, array(0, 1));
$pagetmp--;
} while(!count($query) && $pagetmp);
$blogs = '';
foreach($query as $blog) {
$blog['dateline'] = dgmdate($blog['dateline']);
$blog['subject'] = cutstr($blog['subject'], 30);
switch ($blog['friend']) {
case '0':
$privacy_name = $lang['setting_home_privacy_alluser'];
break;
case '1':
$privacy_name = $lang['setting_home_privacy_friend'];
break;
case '2':
$privacy_name = $lang['setting_home_privacy_specified_friend'];
break;
case '3':
$privacy_name = $lang['setting_home_privacy_self'];
break;
case '4':
$privacy_name = $lang['setting_home_privacy_password'];
break;
default:
$privacy_name = $lang['setting_home_privacy_alluser'];
}
$blog['friend'] = $blog['friend'] ? " <a href=\"".ADMINSCRIPT."?action=blog&friend={$blog['friend']}\">$privacy_name</a>" : $privacy_name;
$blogs .= showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"ids[]\" value=\"{$blog['blogid']}\" />",
$blog['blogid'],
"<a href=\"home.php?mod=space&uid={$blog['uid']}\" target=\"_blank\">{$blog['username']}</a>",
"<a href=\"home.php?mod=space&uid={$blog['uid']}&do=blog&id={$blog['blogid']}\" target=\"_blank\">{$blog['subject']}</a>",
$blog['viewnum'],
$blog['replynum'],
$blog['hot'],
$blog['dateline'],
$blog['friend']
), TRUE);
}
$blogcount = C::t('home_blog')->count_all_by_search($blogid, $uids, $starttime, $endtime, $hot1, $hot2, $viewnum1, $viewnum2, $replynum1, $replynum2, $friend, $ip, $keywords, $lengthlimit, null, null, null, false, array(0, 1));
$multi = multi($blogcount, $perpage, $page, ADMINSCRIPT."?action=blog".($perpage ? '&perpage='.$perpage : '').$muticondition);
} else {
$blogcount = 0;
$query = C::t('home_blog')->fetch_all_by_search(2, $blogid, $uids, $starttime, $endtime, $hot1, $hot2, $viewnum1, $viewnum2, $replynum1, $replynum2, $friend, $ip, $keywords, $lengthlimit, null, null, 0, 0, null, null, null, null, false, array(0, 1));
foreach($query as $blog) {
$blogids .= ','.$blog['blogid'];
$blogcount++;
}
$multi = '';
}
if(!$blogcount) {
$error = 'blog_post_nonexistence';
}
}
showtagheader('div', 'postlist', $searchsubmit || $newlist);
showformheader('blog&frame=no', 'target="blogframe"');
if(!$muticondition) {
showtableheader(cplang('blog_new_result').' '.$blogcount, 'fixpadding');
} else {
showtableheader(cplang('blog_result').' '.$blogcount.(empty($newlist) ? ' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';$(\'blogforum\').pp.value=\'\';$(\'blogforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>' : ''), 'fixpadding');
}
if($error) {
echo "<tr><td class=\"lineheight\" colspan=\"15\">$lang[$error]</td></tr>";
} else {
if($detail) {
showsubtitle(array('', 'blogid', 'author', 'subject', 'view', 'reply', 'hot', 'time', 'privacy'));
echo $blogs;
$optypehtml = ''
.'<input type="radio" name="optype" id="optype_delete" value="delete" class="radio" /><label for="optype_delete">'.cplang('delete').'</label>&nbsp;&nbsp;'
;
$optypehtml .= '<input type="radio" name="optype" id="optype_move" value="move" class="radio" /><label for="optype_move">'.cplang('article_opmove').'</label> '
.category_showselect('blog', 'tocatid', false)
.'&nbsp;&nbsp;';
showsubmit('', '', '', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'ids\')" /><label for="chkall">'.cplang('select_all').'</label>&nbsp;&nbsp;'.$optypehtml.'<input type="submit" class="btn" name="blogsubmit" value="'.cplang('submit').'" />', $multi);
} else {
showhiddenfields(array('blogids' => authcode($blogids, 'ENCODE')));
showsubmit('blogsubmit', 'delete', $detail ? 'del' : '', '', $multi);
}
}
showtablefooter();
showformfooter();
echo '<iframe name="blogframe" style="display:none;"></iframe>';
showtagfooter('div');
}
?>

View File

@@ -0,0 +1,213 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_blogcategory.php 26322 2011-12-09 02:20:12Z chenmengshu $
*/
if(!defined('IN_DISCUZ') || !defined('IN_DISCUZ')) {
exit('Access Denied');
}
cpheader();
$operation = $operation == 'delete' ? 'delete' : 'list';
loadcache('blogcategory');
$category = $_G['cache']['blogcategory'];
if($operation == 'list') {
if(!submitcheck('editsubmit')) {
shownav('portal', 'blogcategory');
showsubmenu('blogcategory', array(
array('list', 'blogcategory', 1)
));
showformheader('blogcategory');
showtableheader('', 'nobottom');
showsetting('system_category_stat', 'settingnew[blogcategorystat]', $_G['setting']['blogcategorystat'], 'radio', '', 1);
showsetting('system_category_required', 'settingnew[blogcategoryrequired]', $_G['setting']['blogcategoryrequired'], 'radio', '');
echo '<tr><td colspan="2">';
showtableheader();
showsubtitle(array('order', 'blogcategory_name', 'blogcategory_num', 'operation'));
foreach ($category as $key=>$value) {
if($value['level'] == 0) {
echo showcategoryrow($key, 0, '');
}
}
echo '<tr><td class="td25">&nbsp;</td><td colspan="3"><div><a class="addtr" onclick="addrow(this, 0, 0)" href="###">'.cplang('blogcategory_addcategory').'</a></div></td></tr>';
showtablefooter();
echo '</td></tr>';
showtablefooter();
showtableheader('', 'notop');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
$langs = array();
$keys = array('blogcategory_addcategory', 'blogcategory_addsubcategory', 'blogcategory_addthirdcategory');
foreach ($keys as $key) {
$langs[$key] = cplang($key);
}
echo <<<SCRIPT
<script type="text/JavaScript">
var rowtypedata = [
[[1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [3, '<div class="parentboard"><input type="text" class="txt" value="{$lang['blogcategory_addcategory']}" name="newname[{1}][]"/></div>']],
[[1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [3, '<div class="board"><input type="text" class="txt" value="{$lang['blogcategory_addsubcategory']}" name="newname[{1}][]"/></div>']],
[[1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [3, '<div class="childboard"><input type="text" class="txt" value="{$lang['blogcategory_addthirdcategory']}" name="newname[{1}][]"/></div>']],
];
</script>
SCRIPT;
} else {
if($_POST['name']) {
foreach($_POST['name'] as $key=>$value) {
$sets = array();
$value = trim($value);
if($category[$key] && $category[$key]['catname'] != $value) {
$sets['catname'] = $value;
}
if($category[$key] && $category[$key]['displayorder'] != $_POST['order'][$key]) {
$sets['displayorder'] = $_POST['order'][$key] ? $_POST['order'][$key] : '0';
}
if($sets) {
C::t('home_blog_category')->update($key, $sets);
}
}
}
if($_POST['newname']) {
foreach ($_POST['newname'] as $upid=>$names) {
foreach ($names as $nameid=>$name) {
C::t('home_blog_category')->insert(array('upid' => $upid, 'catname' => trim($name), 'displayorder'=>intval($_POST['neworder'][$upid][$nameid])));
}
}
}
if($_POST['settingnew']) {
$_POST['settingnew'] = array_map('intval', $_POST['settingnew']);
C::t('common_setting')->update_batch($_POST['settingnew']);
updatecache('setting');
}
include_once libfile('function/cache');
updatecache('blogcategory');
cpmsg('blogcategory_update_succeed', 'action=blogcategory', 'succeed');
}
} elseif($operation == 'delete') {
if(!$_GET['catid'] || !$category[$_GET['catid']]) {
cpmsg('blogcategory_catgory_not_found', '', 'error');
}
if(!submitcheck('deletesubmit')) {
$blog_count = C::t('home_blog')->count_by_catid($_GET['catid']);
if(!$blog_count && empty($category[$_GET['catid']]['children'])) {
C::t('home_blog_category')->delete($_GET['catid']);
include_once libfile('function/cache');
updatecache('blogcategory');
cpmsg('blogcategory_delete_succeed', 'action=blogcategory', 'succeed');
}
shownav('portal', 'blogcategory');
showsubmenu('blogcategory', array(
array('list', 'blogcategory', 0),
array('delete', 'blogcategory&operation=delete&catid='.$_GET['catid'], 1)
));
showformheader('blogcategory&operation=delete&catid='.$_GET['catid']);
showtableheader();
if($category[$_GET['catid']]['children']) {
showsetting('blogcategory_subcategory_moveto', '', '',
'<input type="radio" name="subcat_op" value="trash" id="subcat_op_trash" checked="checked" />'.
'<label for="subcat_op_trash" />'.cplang('blogcategory_subcategory_moveto_trash').'</label>'.
'<input type="radio" name="subcat_op" value="parent" id="subcat_op_parent" checked="checked" />'.
'<label for="subcat_op_parent" />'.cplang('blogcategory_subcategory_moveto_parent').'</label>'
);
}
include_once libfile('function/portalcp');
showsetting('blogcategory_blog_moveto', '', '', category_showselect('blog', 'tocatid', false, $category[$_GET['catid']]['upid']));
showsubmit('deletesubmit');
showtablefooter();
showformfooter();
} else {
if($_POST['tocatid'] == $_GET['catid']) {
cpmsg('blogcategory_move_category_failed', 'action=blogcategory', 'error');
}
$delids = array($_GET['catid']);
if($category[$_GET['catid']]['children']) {
if($_POST['subcat_op'] == 'parent') {
$upid = intval($category[$_GET['catid']]['upid']);
C::t('home_blog_category')->update($category[$_GET['catid']]['children'], array('upid' => $upid));
} else {
$delids = array_merge($delids, $category[$_GET['catid']]['children']);
foreach ($category[$_GET['catid']]['children'] as $id) {
$value = $category[$id];
if($value['children']) {
$delids = array_merge($delids, $value['children']);
}
}
if(!$category[$_POST['tocatid']] || in_array($_POST['tocatid'], $delids)) {
cpmsg('blogcategory_move_category_failed', 'action=blogcategory', 'error');
}
}
}
if($delids) {
C::t('home_blog_category')->delete($delids);
C::t('home_blog')->update_by_catid($delids, array('catid'=>$_POST['tocatid']));
$num = C::t('home_blog')->count_by_catid($_POST['tocatid']);
C::t('home_blog_category')->update_num_by_catid($num, $_POST['tocatid'], false);
}
include_once libfile('function/cache');
updatecache('blogcategory');
cpmsg('blogcategory_delete_succeed', 'action=blogcategory', 'succeed');
}
}
function showcategoryrow($key, $level = 0, $last = '') {
global $_G;
loadcache('blogcategory');
$value = $_G['cache']['blogcategory'][$key];
$return = '';
include_once libfile('function/portalcp');
$value['num'] = category_get_num('blog', $key);
if($level == 2) {
$class = $last ? 'lastchildboard' : 'childboard';
$return = '<tr class="hover"><td class="td25"><input type="text" class="txt" name="order['.$value['catid'].']" value="'.$value['displayorder'].'" /></td><td><div class="'.$class.'">'.
'<input type="text" name="name['.$value['catid'].']" value="'.$value['catname'].'" class="txt" />'.
'</div>'.
'</td><td>'.$value['num'].'</td><td><a href="'.ADMINSCRIPT.'?action=blogcategory&operation=delete&catid='.$value['catid'].'">'.cplang('delete').'</a></td></tr>';
} elseif($level == 1) {
$return = '<tr class="hover"><td class="td25"><input type="text" class="txt" name="order['.$value['catid'].']" value="'.$value['displayorder'].'" /></td><td><div class="board">'.
'<input type="text" name="name['.$value['catid'].']" value="'.$value['catname'].'" class="txt" />'.
'<a class="addchildboard" onclick="addrowdirect = 1;addrow(this, 2, '.$value['catid'].')" href="###">'.cplang('blogcategory_addthirdcategory').'</a></div>'.
'</td><td>'.$value['num'].'</td><td><a href="'.ADMINSCRIPT.'?action=blogcategory&operation=delete&catid='.$value['catid'].'">'.cplang('delete').'</a></td></tr>';
for($i=0,$L=(is_array($value['children']) ? count($value['children']) : 0); $i<$L; $i++) {
$return .= showcategoryrow($value['children'][$i], 2, $i==$L-1);
}
} else {
$return = '<tr class="hover"><td class="td25"><input type="text" class="txt" name="order['.$value['catid'].']" value="'.$value['displayorder'].'" /></td><td><div class="parentboard">'.
'<input type="text" name="name['.$value['catid'].']" value="'.$value['catname'].'" class="txt" />'.
'</div>'.
'</td><td>'.$value['num'].'</td><td><a href="'.ADMINSCRIPT.'?action=blogcategory&operation=delete&catid='.$value['catid'].'">'.cplang('delete').'</a></td></tr>';
for($i=0,$L=(is_array($value['children']) ? count($value['children']) : 0); $i<$L; $i++) {
$return .= showcategoryrow($value['children'][$i], 1, '');
}
$return .= '<tr><td class="td25"></td><td colspan="3"><div class="lastboard"><a class="addtr" onclick="addrow(this, 1, '.$value['catid'].')" href="###">'.cplang('blogcategory_addsubcategory').'</a></div>';
}
return $return;
}
?>

View File

@@ -0,0 +1,307 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_blogrecyclebin.php 32130 2012-11-14 09:20:40Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
include_once libfile('function/portalcp');
cpheader();
$detail = $_GET['detail'];
$uid = $_GET['uid'];
$blogid = $_GET['blogid'];
$users = $_GET['users'];
$keywords = $_GET['keywords'];
$lengthlimit = $_GET['lengthlimit'];
$viewnum1 = $_GET['viewnum1'];
$viewnum2 = $_GET['viewnum2'];
$replynum1 = $_GET['replynum1'];
$replynum2 = $_GET['replynum2'];
$hot1 = $_GET['hot1'];
$hot2 = $_GET['hot2'];
$starttime = $_GET['starttime'];
$endtime = $_GET['endtime'];
$searchsubmit = $_GET['searchsubmit'];
$blogids = $_GET['blogids'];
$friend = $_GET['friend'];
$ip = $_GET['ip'];
$orderby = $_GET['orderby'];
$ordersc = $_GET['ordersc'];
$fromumanage = $_GET['fromumanage'] ? 1 : 0;
$muticondition = '';
$muticondition .= $uid ? '&uid='.$uid : '';
$muticondition .= $blogid ? '&blogid='.$blogid : '';
$muticondition .= $users ? '&users='.$users : '';
$muticondition .= $keywords ? '&keywords='.$keywords : '';
$muticondition .= $lengthlimit ? '&lengthlimit='.$lengthlimit : '';
$muticondition .= $viewnum1 ? '&viewnum1='.$viewnum1 : '';
$muticondition .= $viewnum2 ? '&viewnum2='.$viewnum2 : '';
$muticondition .= $replynum1 ? '&replynum1='.$replynum1 : '';
$muticondition .= $replynum2 ? '&replynum2='.$replynum2 : '';
$muticondition .= $hot1 ? '&hot1='.$hot1 : '';
$muticondition .= $hot2 ? '&hot2='.$hot2 : '';
$muticondition .= $starttime ? '&starttime='.$starttime : '';
$muticondition .= $endtime ? '&endtime='.$endtime : '';
$muticondition .= $friend ? '&friend='.$friend : '';
$muticondition .= $ip ? '&ip='.$ip : '';
$muticondition .= $orderby ? '&orderby='.$orderby : '';
$muticondition .= $ordersc ? '&ordersc='.$ordersc : '';
$muticondition .= $fromumanage ? '&fromumanage='.$fromumanage : '';
$muticondition .= $searchsubmit ? '&searchsubmit='.$searchsubmit : '';
$muticondition .= $_GET['search'] ? '&search='.$_GET['search'] : '';
$muticondition .= $detail ? '&detail='.$detail : '';
if(!submitcheck('blogsubmit')) {
if(empty($_GET['search'])) {
$newlist = 1;
$detail = 1;
}
if($fromumanage) {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? '' : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? '' : $endtime;
} else {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? dgmdate(TIMESTAMP - 86400 * 7, 'Y-n-j') : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? dgmdate(TIMESTAMP, 'Y-n-j') : $endtime;
}
shownav('topic', 'nav_blog_recycle_bin');
showsubmenu('nav_blog_recycle_bin', array(
array('bloglist', 'blogrecyclebin', !empty($newlist)),
array('search', 'blogrecyclebin&search=true', empty($newlist)),
));
empty($newlist) && showsubmenusteps('', array(
array('blog_search', !$searchsubmit),
array('nav_blog_recycle_bin', $searchsubmit)
));
if($muticondition) {
showtips('blog_tips');
}
$staticurl = STATICURL;
echo <<<EOT
<script type="text/javascript" src="{$staticurl}js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('blogforum').page.value=number;
$('blogforum').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'searchposts', !$searchsubmit && empty($newlist));
showformheader("blogrecyclebin".(!empty($_GET['search']) ? '&search=true' : ''), '', 'blogforum');
showhiddenfields(array('page' => $page, 'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']));
showtableheader();
showsetting('blog_search_detail', 'detail', $detail, 'radio');
showsetting('blog_search_perpage', '', $_GET['perpage'], "<select name='perpage'><option value='20'>{$lang['perpage_20']}</option><option value='50'>{$lang['perpage_50']}</option><option value='100'>{$lang['perpage_100']}</option></select>");
showsetting('resultsort', '', $orderby, "<select name='orderby'><option value=''>{$lang['defaultsort']}</option><option value='dateline'>{$lang['forums_edit_extend_order_starttime']}</option><option value='viewnum'>{$lang['blog_search_view']}</option><option value='replynum'>{$lang['blog_search_reply']}</option><option value='hot'>{$lang['blog_search_hot']}</option></select> ");
showsetting('', '', $ordersc, "<select name='ordersc'><option value='desc'>{$lang['orderdesc']}</option><option value='asc'>{$lang['orderasc']}</option></select>", '', 0, '', '', '', true);
showsetting('blog_search_uid', 'uid', $uid, 'text');
showsetting('blog_search_blogid', 'blogid', $blogid, 'text');
showsetting('blog_search_user', 'users', $users, 'text');
showsetting('blog_search_keyword', 'keywords', $keywords, 'text');
showsetting('blog_search_friend', '', $friend, "<select name='friend'><option value='0'>{$lang['setting_home_privacy_alluser']}</option><option value='1'>{$lang['setting_home_privacy_friend']}</option><option value='2'>{$lang['setting_home_privacy_specified_friend']}</option><option value='3'>{$lang['setting_home_privacy_self']}</option><option value='4'>{$lang['setting_home_privacy_password']}</option></select>");
showsetting('blog_search_ip', 'ip', $ip, 'text');
showsetting('blog_search_lengthlimit', 'lengthlimit', $lengthlimit, 'text');
showsetting('blog_search_view', array('viewnum1', 'viewnum2'), array('', ''), 'range');
showsetting('blog_search_reply', array('replynum1', 'replynum2'), array('', ''), 'range');
showsetting('blog_search_hot', array('hot1', 'hot2'), array('', ''), 'range');
showsetting('blog_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
echo '<input type="hidden" name="fromumanage" value="'.$fromumanage.'">';
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
if($_GET['blogids']) {
$blogids = authcode($_GET['blogids'], 'DECODE');
$blogidsadd = $blogids ? explode(',', $blogids) : $_GET['delete'];
include_once libfile('function/delete');
$deletecount = count(deleteblogs($blogidsadd, true));
$cpmsg = cplang('blog_succeed', array('deletecount' => $deletecount));
} else {
$blogs = $catids = array();
$selectblogids = !empty($_GET['ids']) && is_array($_GET['ids']) ? $_GET['ids'] : array();
if($selectblogids) {
$query = C::t('home_blog')->fetch_all_blog($selectblogids);
foreach($query as $value) {
$blogs[$value['blogid']] = $value;
$catids[] = intval($value['catid']);
}
}
if($blogs) {
$selectblogids = array_keys($blogs);
if($_POST['optype'] == 'delete') {
include_once libfile('function/delete');
$deletecount = count(deleteblogs($selectblogids, true));
$cpmsg = cplang('blog_succeed', array('deletecount' => $deletecount));
} elseif($_POST['optype'] == 'restore') {
$restore = C::t('home_blog')->update($selectblogids, array('status' => 0));
$cpmsg = cplang('blog_restore_succeed', array('restorecount' => $restore));
} else {
$cpmsg = cplang('blog_choose_at_least_one_operation');
}
} else {
$cpmsg = cplang('blog_choose_at_least_one_blog');
}
}
?>
<script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('blogforum').searchsubmit.click();</script>
<?php
}
if(submitcheck('searchsubmit', 1) || $newlist) {
$blogids = $blogcount = '0';
$sql = $error = '';
$keywords = trim($keywords);
$users = trim($users);
$uids = array();
if($blogid != '') {
$blogid = explode(',', $blogid);
}
if($users != '') {
$uids = C::t('common_member')->fetch_all_uid_by_username(array_map('trim', explode(',', $users)));
if(!$uids) {
$uids = array(-1);
}
}
$uid = trim($uid, ', ');
if($uid != '') {
$uid = explode(',', $uid);
if($uids && $uids[0] != -1) {
$uids = array_intersect($uids, $uid);
} else {
$uids = $uid;
}
if(!$uids) {
$uids = array(-1);
}
}
if($starttime != '') {
$starttime = strtotime($starttime);
}
if($_G['adminid'] == 1 && $endtime != dgmdate(TIMESTAMP, 'Y-n-j')) {
if($endtime != '') {
$endtime = strtotime($endtime);
}
} else {
$endtime = TIMESTAMP;
}
if(($_G['adminid'] == 2 && $endtime - $starttime > 86400 * 16) || ($_G['adminid'] == 3 && $endtime - $starttime > 86400 * 8)) {
$error = 'blog_mod_range_illegal';
}
if(!$error) {
if($detail) {
$pagetmp = $page;
$_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
$perpage = $_GET['pp'] ? $_GET['pp'] : $_GET['perpage'];
do{
$query = C::t('home_blog')->fetch_all_by_search(1, $blogid, $uids, $starttime, $endtime, $hot1, $hot2, $viewnum1, $viewnum2, $replynum1, $replynum2, $friend, $ip, $keywords, $lengthlimit, $orderby, $ordersc, (($pagetmp - 1) * $perpage), $perpage, null, null, null, null, false, -1);
$pagetmp--;
} while(!count($query) && $pagetmp);
$blogs = '';
foreach($query as $blog) {
$blog['dateline'] = dgmdate($blog['dateline']);
$blog['subject'] = cutstr($blog['subject'], 30);
switch ($blog['friend']) {
case '0':
$privacy_name = $lang['setting_home_privacy_alluser'];
break;
case '1':
$privacy_name = $lang['setting_home_privacy_friend'];
break;
case '2':
$privacy_name = $lang['setting_home_privacy_specified_friend'];
break;
case '3':
$privacy_name = $lang['setting_home_privacy_self'];
break;
case '4':
$privacy_name = $lang['setting_home_privacy_password'];
break;
default:
$privacy_name = $lang['setting_home_privacy_alluser'];
}
$blog['friend'] = $blog['friend'] ? " <a href=\"".ADMINSCRIPT."?action=blog&friend={$blog['friend']}\">$privacy_name</a>" : $privacy_name;
$blogs .= showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"ids[]\" value=\"{$blog['blogid']}\" />",
$blog['blogid'],
"<a href=\"home.php?mod=space&uid={$blog['uid']}\" target=\"_blank\">{$blog['username']}</a>",
"<a href=\"home.php?mod=space&uid={$blog['uid']}&do=blog&id={$blog['blogid']}\" target=\"_blank\">{$blog['subject']}</a>",
$blog['viewnum'],
$blog['replynum'],
$blog['hot'],
$blog['dateline'],
$blog['friend']
), TRUE);
}
$blogcount = C::t('home_blog')->count_all_by_search($blogid, $uids, $starttime, $endtime, $hot1, $hot2, $viewnum1, $viewnum2, $replynum1, $replynum2, $friend, $ip, $keywords, $lengthlimit, null, null, null, false, -1);
$multi = multi($blogcount, $perpage, $page, ADMINSCRIPT."?action=blogrecyclebin".($perpage ? '&perpage='.$perpage : '').$muticondition);
} else {
$blogcount = 0;
$query = C::t('home_blog')->fetch_all_by_search(2, $blogid, $uids, $starttime, $endtime, $hot1, $hot2, $viewnum1, $viewnum2, $replynum1, $replynum2, $friend, $ip, $keywords, $lengthlimit, null, null, 0, 0, null, null, null, null, false, -1);
foreach($query as $blog) {
$blogids .= ','.$blog['blogid'];
$blogcount++;
}
$multi = '';
}
if(!$blogcount) {
$error = 'blog_post_nonexistence';
}
}
showtagheader('div', 'postlist', $searchsubmit || $newlist);
showformheader('blogrecyclebin&frame=no', 'target="blogframe"');
if(!$muticondition) {
showtableheader(cplang('blog_new_result').' '.$blogcount, 'fixpadding');
} else {
showtableheader(cplang('blog_result').' '.$blogcount.(empty($newlist) ? ' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';$(\'blogforum\').pp.value=\'\';$(\'blogforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>' : ''), 'fixpadding');
}
if($error) {
echo "<tr><td class=\"lineheight\" colspan=\"15\">$lang[$error]</td></tr>";
} else {
if($detail) {
showsubtitle(array('', 'blogid', 'author', 'subject', 'view', 'reply', 'hot', 'time', 'privacy'));
echo $blogs;
$optypehtml = ''
.'<input type="radio" name="optype" id="optype_delete" value="delete" class="radio" /><label for="optype_delete">'.cplang('delete').'</label>&nbsp;&nbsp;'
.'<input type="radio" name="optype" id="optype_restore" value="restore" class="radio" /><label for="optype_restore">'.cplang('restore').'</label>&nbsp;&nbsp;'
;
showsubmit('', '', '', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'ids\')" /><label for="chkall">'.cplang('select_all').'</label>&nbsp;&nbsp;'.$optypehtml.'<input type="submit" class="btn" name="blogsubmit" value="'.cplang('submit').'" />', $multi);
} else {
showhiddenfields(array('blogids' => authcode($blogids, 'ENCODE')));
showsubmit('blogsubmit', 'delete', $detail ? 'del' : '', '', $multi);
}
}
showtablefooter();
showformfooter();
echo '<iframe name="blogframe" style="display:none;"></iframe>';
showtagfooter('div');
}
?>

View File

@@ -0,0 +1,620 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_card.php 29335 2012-04-05 02:08:34Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
if($operation != 'export') {
cpheader();
}
$operation = $_GET['operation'] ? $_GET['operation'] : 'set' ;
$card_setting = $_G['setting']['card'];
if($operation == 'set') {
$nav = 'config';
$submenu['set'] = 1;
} elseif ($operation == 'manage') {
$nav = 'admin';
$submenu['manage'] = 1;
} elseif ($operation == 'type') {
$nav = 'nav_card_type';
$submenu['type'] = 1;
} elseif ($operation == 'make') {
$nav = 'nav_card_make';
$submenu['make'] = 1;
} elseif ($operation == 'log') {
$nav = 'nav_card_log';
} else {
$nav = '';
}
if($nav != '') {
if(!submitcheck('cardsubmit', 1) || $operation == 'manage' || $operation == 'type') {
shownav('extended', 'nav_card', $nav);
showsubmenu('nav_card', array(
array('config', 'card', $submenu['set']),
array('admin', 'card&operation=manage', $submenu['manage']),
array('nav_card_type', 'card&operation=type', $submenu['type']),
array('nav_card_make', 'card&operation=make', $submenu['make']),
array(array('menu' => 'nav_card_log', 'submenu' => array(
array('nav_card_log_add', 'card&operation=log&do=add', $_GET['do'] == 'add'),
array('nav_card_log_del', 'card&operation=log&do=del', $_GET['do'] == 'del'),
array('nav_card_log_cron', 'card&operation=log&do=cron', $_GET['do'] == 'cron')
)), in_array($_GET['do'], array('add', 'del', 'cron')))
));
}
}
if($operation == 'set') {
if(!submitcheck('cardsubmit')) {
showformheader('card&operation=set&');
showtableheader();
showsetting('card_config_open', 'card_config_open', ($card_setting['open'] ? $card_setting['open'] : 0), 'radio');
showsubmit('cardsubmit');
showtablefooter();
showformfooter();
} else {
C::t('common_setting')->update_setting('card', array('open' => $_POST['card_config_open']));
updatecache('setting');
cpmsg('card_config_succeed', 'action=card&operation=set', 'succeed');
}
} elseif($operation == 'manage'){
if(submitcheck('cardsubmit')) {
if(is_array($_POST['delete'])) {
$delnum = C::t('common_card')->delete($_POST['delete']);
$card_info = serialize(array('num' => ($delnum ? $delnum : 0)));
$cardlog = array(
'uid' => $_G['uid'],
'cardrule' => '',
'info' => $card_info,
'dateline' => $_G['timestamp'],
'operation' => 3,
'username' => $_G['member']['username']
);
C::t('common_card_log')->insert($cardlog);
}
}
$sqladd = cardsql();
foreach($_GET AS $key => $val) {
if(strpos($key, 'srch_') !== false && $val) {
if(in_array($key, array('srch_username'))){
$val = rawurlencode($val);
}
$export_url[] = $key.'='.$val;
}
}
$perpage = max(20, empty($_GET['perpage']) ? 20 : intval($_GET['perpage']));
echo '<script type="text/javascript" src="' . STATICURL . 'js/calendar.js"></script>';
showtips('card_manage_tips');
$card_type_option = '';
foreach(C::t('common_card_type')->range(0, 0, 'ASC') as $result) {
$card_type[$result['id']] = $result;
$card_type_option .= "<option value=\"{$result['id']}\" ".($_GET['srch_card_type'] == $result['id'] ? 'selected' : '').">{$result['typename']}</option>";
}
showformheader('card', '', 'cdform', 'get');
showtableheader('', 'fixpadding');
showtablerow('', array('width="80"', 'width="160"', 'width=100'),
array(
cplang('card_number'), '<input type="text" name="srch_id" class="txt" value="'.$_GET['srch_id'].'" />',
cplang('card_log_price').cplang('between'), '<input type="text" name="srch_price_min" class="txt" value="'.($_GET['srch_price_min'] ? $_GET['srch_price_min'] : '').'" />- &nbsp;<input type="text" name="srch_price_max" class="txt" value="'.($_GET['srch_price_max'] ? $_GET['srch_price_max'] :'' ).'" />',
)
);
echo "<input type='hidden' name='action' value='card'><input type='hidden' name='operation' value='manage'>";
$extcredits_option = "<option value=''>".cplang('nolimit')."</option>";
foreach($_G['setting']['extcredits'] AS $key => $val) {
$extcredits_option .= "<option value='$key' ".($_GET['srch_extcredits'] == $key ? 'selected' : '').">{$val['title']}</option>";
}
foreach(array('1' => cplang('card_manage_status_1'), '2' => cplang('card_manage_status_2'), '9' => cplang('card_manage_status_9')) AS $key => $val) {
$status_option .= "<option value='{$key}' ".($_GET['srch_card_status'] == $key ? "selected" : '').">{$val}</option>";
}
showtablerow('', array(),
array(
cplang('card_extcreditsval'), '<input type="text" name="srch_extcreditsval" class="txt" style="width:42px;" value="'.$_GET['srch_extcreditsval'].'" /><select name="srch_extcredits">'.$extcredits_option.'</select>',
cplang('card_status'), "<select name='srch_card_status'><option value=''>".cplang('nolimit')."</option>".$status_option."</select>",
)
);
showtablerow('', array('class="td23"', 'class="td23"'),
array(
cplang('card_log_used_user'), '<input type="text" name="srch_username" class="txt" value="'.$_GET['srch_username'].'" />',
cplang('card_used_dateline'), '<input type="text" name="srch_useddateline_start" class="txt" value="'.$_GET['srch_useddateline_start'].'" onclick="showcalendar(event, this);" />- &nbsp;<input type="text" name="srch_useddateline_end" class="txt" value="'.$_GET['srch_useddateline_end'].'" onclick="showcalendar(event, this)" />',
)
);
$perpage_selected[$perpage] = "selected=selected";
showtablerow('', array(),
array(
cplang('card_type'), '<select name="srch_card_type"><option value="">'.cplang('nolimit').'</option><option value="0" '.($_GET['srch_card_type'] != '' && $_GET['srch_card_type'] == 0 ? 'selected' : '').'>'.cplang('card_type_default').'</option>'.$card_type_option.'</select>',
cplang('card_search_perpage'), '<select name="perpage" class="ps" onchange="this.form.submit();" ><option value="20" '.$perpage_selected[20].'>'.cplang('perpage_20').'</option><option value="50" '.$perpage_selected[50].'>'.cplang('perpage_50').'</option><option value="100" '.$perpage_selected[100].'>'.cplang('perpage_100').'</option></select>',
)
);
showtablerow('', array('width="40"', 'width="100"', 'width=50', 'width="260"'),
array(
'<input type="submit" name="srchbtn" class="btn" value="'.$lang['search'].'" />',''
)
);
showtablefooter();
showformfooter();
showformheader('card&operation=manage&');
showtableheader('card_manage_title');
showsubtitle(array('', cplang('card_number'), cplang('card_log_price'), cplang('card_extcreditsval'), cplang('card_type'), cplang('card_status'), cplang('card_log_used_user'), cplang('card_used_dateline'), cplang('card_make_cleardateline')/*, cplang('card_maketype')*/, cplang('card_maketime'), cplang('card_log_maker')));
$start_limit = ($page - 1) * $perpage;
$export_url[] = 'start='.$start_limit;
foreach ($_GET AS $key => $val) {
if(strpos($key, 'srch_') !== FALSE) {
$url_add .= '&'.$key.'='.$val;
}
}
$url = ADMINSCRIPT.'?action=card&operation=manage&page='.$page.'&perpage='.$perpage.$url_add;
$count = $sqladd ? C::t('common_card')->count_by_where($sqladd) : C::t('common_card')->count();
if($count) {
$multipage = multi($count, $perpage, $page, $url, 0, 3);
foreach(C::t('common_card')->fetch_all_by_where($sqladd, $start_limit, $perpage) as $result) {
$userlist[$result['makeruid']] = $result['makeruid'];
$userlist[$result['uid']] = $result['uid'];
$cardlist[] = $result;
}
if($userlist) {
$members = C::t('common_member')->fetch_all($userlist);
unset($userlist);
}
foreach($cardlist AS $key => $val) {
showtablerow('', array('class="smallefont"', '', '', '', '', '', '', '', '', '', '', ''), array(
'<input class="checkbox" type="checkbox" name="delete[]" value="'.$val['id'].'">',
$val['id'],
$val['price'].cplang('card_make_price_unit'),
$val['extcreditsval'].$_G['setting']['extcredits'][$val['extcreditskey']]['title'],
$card_type[$val['typeid']]['typename'] ? $card_type[$val['typeid']]['typename'] : cplang('card_type_default'),
cplang("card_manage_status_".$val['status']),
$val['uid'] ? "<a href='home.php?mod=space&uid={$val['uid']}' target='_blank'>".$members[$val['uid']]['username'] : ' -- ',
$val['useddateline'] ? dgmdate($val['useddateline']) : ' -- ',
$val['cleardateline'] ? dgmdate($val['cleardateline'], 'Y-m-d') : cplang('card_make_cleardateline_none'),
dgmdate($val['dateline'], 'u'),
"<a href='home.php?mod=space&uid={$val['makeruid']}' target='_blank'>".$members[$val['makeruid']]['username']."</a>"
));
}
echo '<input type="hidden" name="perpage" value="'.$perpage.'">';
showsubmit('cardsubmit', 'submit', 'del', '<a href="'.ADMINSCRIPT.'?action=card&operation=export&'.implode('&', $export_url).'" title="'.$lang['card_export_title'].'">'.$lang['card_export'].'</a>', $multipage, false);
}
showtablefooter();
showformfooter();
} elseif($operation == 'type') {
if(submitcheck('cardsubmit')) {
if(is_array($_POST['delete'])) {
C::t('common_card_type')->delete($_POST['delete']);
C::t('common_card')->update_by_typeid($_POST['delete'], array('typeid'=>1));
}
if(is_array($_POST['newtype'])) {
$_POST['newtype'] = dhtmlspecialchars(daddslashes($_POST['newtype']));
foreach($_POST['newtype'] AS $key => $val) {
if(trim($val)) {
C::t('common_card_type')->insert(array('typename' => trim($val)));
}
}
}
}
showtips('card_type_tips');
showformheader('card&operation=type&');
showtableheader();
showtablerow('class="header"', array('', ''), array(
cplang('delete'),
cplang('card_type'),
));
showtablerow('', '', array(
'<input class="checkbox" type="checkbox" value ="" disabled="disabled" >',
cplang('card_type_default'),
));
foreach(C::t('common_card_type')->range(0, 0, 'ASC') as $result) {
showtablerow('', '', array(
'<input class="checkbox" type="checkbox" name ="delete[]" value ="'.$result['id'].'" >',
$result['typename'],
));
}
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[[1,''], [1,'<input type="text" class="txt" size="30" name="newtype[]">']],
];
</script>
EOT;
echo '<tr><td></td><td colspan="2"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['add_new'].'</a></div></td></tr>';
showsubmit('cardsubmit', 'submit', 'select_all');
showtablefooter();
showformfooter();
} elseif($operation == 'make') {
if(!submitcheck('cardsubmit', 1)) {
if($card_log = C::t('common_card_log')->fetch_by_operation(1)) {
$card_log['rule'] = dunserialize($card_log['cardrule']);
}
$card_type[] = array(0, cplang('card_type_default'));
foreach(C::t('common_card_type')->range(0, 0, 'ASC') as $result) {
$card_type[] = array($result['id'], $result['typename']);
}
echo '<script type="text/javascript" src="' . STATICURL . 'js/calendar.js"></script>';
showformheader('card&operation=make&');
showtips('card_make_tips');
showtableheader();
showsetting('card_make_rule', '', '', '<input type="text" name="rule" class="txt" value="'.($card_log['rule']['rule'] ? $card_log['rule']['rule'] : '').'" onkeyup="javascript:checkcardrule(this);"><br /><span id="cardrule_view" class="tips2" style="display:none;"></span>');
echo <<<EOT
<script type="text/javascript" charset="{$_G['charset']}">
function checkcardrule(obj) {
var chrLength = obj.value.length;
$('cardrule_view').style.display = "";
$('cardrule_view').innerHTML = "{$lang['card_number']}<strong>"+chrLength+"</strong>{$lang['card_number_unit']}";
}
</script>
EOT;
showsetting('card_type', array('typeid', $card_type), $card_log['rule']['typeid'], 'select');
showsetting('card_make_num', 'num', ($card_log['rule']['num'] ? $card_log['rule']['num'] : 1), 'text');
$extcredits_option = '';
foreach($_G['setting']['extcredits'] AS $key => $val) {
$extcredits_option .= "<option value='$key'".($card_log['rule']['extcreditskey'] == $key ? 'selected' : '').">{$val['title']}</option>";
}
showsetting('card_make_extcredits', '', '', '<select name="extcreditskey" style="width:80px;">'.$extcredits_option.'</select><input type="text" name="extcreditsval" value="'.($card_log['rule']['extcreditsval'] ? $card_log['rule']['extcreditsval'] : 1).'" class="txt" style="width:50px;">');
showsetting('card_make_price', 'price', ($card_log['rule']['price'] ? $card_log['rule']['price'] : 0), 'text');
showsetting('card_make_cleardateline', 'cleardateline', date("Y-m-d", $_G['timestamp']+31536000), 'calendar', '', 0, '');
showsetting('card_make_description', 'description', $card_log['description'] , 'text');
showsubmit('cardsubmit');
showtablefooter();
showformfooter();
} else {
$_GET['rule'] = rawurldecode(trim($_GET['rule']));
$_GET['num'] = intval($_GET['num']);
list($y, $m, $d) = explode("-", $_GET['cleardateline']);
$_GET['step'] = $_GET['step'] ? $_GET['step'] : 1;
$cleardateline = $_GET['cleardateline'] && $y && $m ? mktime(23, 59, 59, $m, $d, $y) : 0 ;
if($cleardateline < TIMESTAMP) {
cpmsg('card_make_cleardateline_early', '', 'error');
}
if(!$_GET['rule']) {
cpmsg('card_make_rule_empty', '', 'error');
}
if($_GET['num'] < 1) {
cpmsg('card_make_num_error', '', 'error');
}
include libfile("class/card");
$card = new card();
$checkrule = $card->checkrule($_GET['rule'], 1);
if($checkrule === -2) {
cpmsg('card_make_rule_error', '', 'error');
}
if($_GET['step'] == 1) {
$card_rule = serialize(array('rule' => $_GET['rule'], 'price' => $_GET['price'], 'extcreditskey' => $_GET['extcreditskey'], 'extcreditsval' => $_GET['extcreditsval'], 'num' => $_GET['num'], 'cleardateline' => $cleardateline, 'typeid' => $_GET['typeid']));
$cardlog = array(
'uid' => $_G['uid'],
'username' => $_G['member']['username'],
'cardrule' => $card_rule,
'dateline' => $_G['timestamp'],
'description' => $_GET['description'],
'operation' => 1,
);
$logid = C::t('common_card_log')->insert($cardlog, true);
}
$onepage_make = 500;
$_GET['logid'] = $logid ? $logid : $_GET['logid'];
if($_GET['num'] > $onepage_make) {
$step_num = ceil($_GET['num']/$onepage_make);
if($step_num > 1) {
if($_GET['step'] == $step_num) {
if($_GET['num'] % $onepage_make == 0) {
$makenum = $onepage_make;
} else {
$makenum = $_GET['num'] % $onepage_make;
}
} else {
$makenum = $onepage_make;
$nextstep = $_GET['step'] + 1;
}
}
} else {
$makenum = $_GET['num'];
}
$cardval = array(
'typeid' => $_GET['typeid'],
'price' => $_GET['price'],
'extcreditskey' => $_GET['extcreditskey'],
'extcreditsval' => $_GET['extcreditsval'],
'cleardateline' => $cleardateline
);
$card->make($_GET['rule'], $makenum, $cardval);
$_GET['succeed_num'] += $card->succeed;
$_GET['fail_num'] += $card->fail;
if($nextstep) {
$_GET['rule'] = rawurlencode($_GET['rule']);
$nextlink = "action=card&operation=make&rule={$_GET['rule']}&num={$_GET['num']}&price={$_GET['price']}&extcreditskey={$_GET['extcreditskey']}&extcreditsval={$_GET['extcreditsval']}&cleardateline={$_GET['cleardateline']}&step={$nextstep}&succeed_num={$_GET['succeed_num']}&fail_num={$_GET['fail_num']}&typeid={$_GET['typeid']}&logid={$_GET['logid']}&cardsubmit=yes";
cpmsg('card_make_step', $nextlink, 'loading', array('step' => $nextstep - 1, 'step_num' => $step_num, 'succeed_num' => $card->succeed, 'fail_num' => $card->fail));
} else {
$card_info = serialize(array('num' => $_GET['num'], 'succeed_num' => $_GET['succeed_num'], 'fail_num' => $_GET['fail_num']));
C::t('common_card_log')->update($_GET['logid'], array('info'=>$card_info));
if(ceil($_GET['num']*0.6) > $_GET['succeed_num']) {
cpmsg('card_make_rate_succeed', 'action=card&operation=make', 'succeed', array('succeed_num' => $_GET['succeed_num'], 'fail_num' => $_GET['fail_num']));
}
cpmsg('card_make_succeed', 'action=card&operation=manage', 'succeed', array('succeed_num' => $_GET['succeed_num'], 'fail_num' => $_GET['fail_num']));
}
}
} elseif($operation == 'log'){
showformheader('card&operation=log&');
showtableheader();
$perpage = max(20, empty($_GET['perpage']) ? 20 : intval($_GET['perpage']));
$start_limit = ($page - 1) * $perpage;
$do = in_array($_GET['do'], array('add', 'task', 'del', 'cron')) ? $_GET['do'] : 'add';
$operation = 0;
switch($do) {
case 'add':
$operation = 1;
break;
case 'task':
$operation = 2;
break;
case 'del':
$operation = 3;
break;
case 'cron':
$operation = 9;
break;
}
if($do == 'add' || $do == 'task') {
$showtabletitle = array(
cplang('time'),
cplang('card_log_operation'),
cplang('card_log_user'),
cplang('card_log_rule'),
cplang('card_log_add_info'),
cplang('card_log_description')
);
} elseif($do == 'del') {
$showtabletitle = array(
cplang('time'),
cplang('card_log_operation'),
cplang('card_log_user'),
cplang('card_log_del_info')
);
} elseif($do == 'cron') {
$showtabletitle = array(
cplang('time'),
cplang('card_log_operation'),
cplang('card_log_cron_info')
);
}
showtablerow('class="header"', array('class="td21"','class="td23"','class="td23"','class="td21"','class="td23"'), $showtabletitle);
$count = C::t('common_card_log')->count_by_operation($operation);
if($count) {
$url = ADMINSCRIPT."?action=card&operation=log&do=".$do."&page=".$page.'&perpage='.$perpage;
$multipage = multi($count, $perpage, $page, $url, 0, 3);
foreach(C::t('common_card_log')->fetch_all_by_operation($operation, $start_limit, $perpage) as $result) {
$result['info_arr'] = dunserialize($result['info']);
if($result['operation'] == 1 || $result['operation'] == 2) {
$result['cardrule_arr'] = dunserialize($result['cardrule']);
$showrule = array(
$result['cardrule_arr']['rule'],
cplang('card_log_price').' : '.$result['cardrule_arr']['price'].cplang('card_make_price_unit'),
cplang('card_log_make_num').' : '.$result['cardrule_arr']['num'],
cplang('card_extcreditsval').' : '.$result['cardrule_arr']['extcreditsval'].$_G['setting']['extcredits'][$result['cardrule_arr']['extcreditskey']]['title'],
cplang('card_make_cleardateline').' : '.($result['cardrule_arr']['cleardateline'] ? dgmdate($result['cardrule_arr']['cleardateline'], 'Y-m-d H:i') : cplang('card_make_cleardateline_none')),
);
$showinfo = array(
cplang('succeed_num').' : '.$result['info_arr']['succeed_num'],
cplang('fail_num').' : '.$result['info_arr']['fail_num']
);
$showtablerow = array(
dgmdate($result['dateline']),
$result['operation'] == 1 ? cplang('card_log_operation_add') : cplang('card_log_operation_task'),
$result['username'],
implode("<br />", $showrule),
implode("<br />", $showinfo),
$result['description']
);
} elseif ($result['operation'] == 3 || $result['operation'] == 9) {
$showinfo =array(
cplang('card_log_num').$result['info_arr']['num'],
);
$showtablerow = $result['operation'] == 3 ? array(
dgmdate($result['dateline']),
cplang('card_log_operation_del'),
$result['username'],
implode("<br />", $showinfo),
) : array(
dgmdate($result['dateline']),
cplang('card_log_operation_cron'),
implode("<br />", $showinfo),
);
}
showtablerow('', array('class="smallefont"'), $showtablerow);
}
} else {
}
showsubmit('', '', '', '', $multipage);
showtablefooter();
showformfooter();
} elseif ($operation == 'export'){
$sqladd = cardsql();
$_GET['start'] = intval($_GET['start']);
$count = $sqladd ? C::t('common_card')->count_by_where($sqladd) : C::t('common_card')->count();
if($count) {
$cardtype = C::t('common_card_type')->range();
$count = min(10000, $count);
foreach(C::t('common_card')->fetch_all_by_where($sqladd, $_GET['start'], $count) as $result) {
$userlist[$result['uid']] = $result['uid'];
$userlist[$result['makeruid']] = $result['makeruid'];
$result['extcreditsval'] = $result['extcreditsval'].$_G['setting']['extcredits'][$result['extcreditskey']]['title'];
unset($result['extcreditskey']);
unset($result['maketype']);
$cardlist[] = $result;
}
if($userlist) {
$members = C::t('common_member')->fetch_all($userlist);
unset($userlist);
}
foreach($cardlist AS $key => $val) {
foreach($val as $skey => $sval) {
$sval = preg_replace('/\s+/', ' ', $sval);
if($skey == 'id' && !$title['id']) { $title['id'] = cplang('card_number'); }
if($skey == 'typeid') {
if(!$title['typeid']) {
$title['typeid'] = cplang("card_type");
}
$sval = $sval != 0 ? $cardtype[$sval]['typename'] : cplang('card_type_default');
}
if(in_array($skey, array('uid', 'makeruid'))) {
if($skey == 'makeruid' && !$title['makeruid']) {
$title['makeruid'] = cplang("card_log_maker");
}
if($skey == 'uid' && !$title['uid']) {
$title['uid'] = cplang("card_log_used_user");
}
$sval = $members[$sval]['username'];
}
if($skey == 'price') {
if(!$title['price']) {
$title['price'] = cplang('card_log_price');
}
$sval = $sval.cplang("card_make_price_unit");
}
if($skey == 'extcreditsval') {
if(!$title['extcreditsval']) {
$title['extcreditsval'] = cplang('card_extcreditsval');
}
}
if($skey == 'status') {
if(!$title['status']) {
$title['status'] = cplang('card_status');
}
$sval = cplang("card_manage_status_".$sval);
}
if(in_array($skey, array('dateline', 'cleardateline', 'useddateline'))) {
if($skey == 'dateline' && !$title['dateline']) {
$title['dateline'] = cplang('card_maketime');
}
if($skey == 'cleardateline' && !$title['cleardateline']) {
$title['cleardateline'] = cplang('card_make_cleardateline');
}
if($skey == 'useddateline' && !$title['useddateline']) {
$title['useddateline'] = cplang('card_used_dateline');
}
$sval = $sval ? date("Y-m-d", $sval) : '';
}
$detail .= strlen($sval) > 11 && is_numeric($sval) ? '['.$sval.'],' : $sval.',';
}
$detail = $detail."\n";
}
}
$title = is_array($title) ? $title : array($title);
$detail = implode(',', $title)."\n".$detail;
$filename = 'card_'.date('Ymd', TIMESTAMP).'.csv';
ob_end_clean();
header('Content-Encoding: none');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename);
header('Pragma: no-cache');
header('Expires: 0');
if($_G['charset'] != 'gbk') {
$detail = diconv($detail, $_G['charset'], 'GBK');
}
echo $detail;
exit();
} else {
cpmsg('action_noaccess', '', 'error');
}
function cardsql() {
$_GET = daddslashes($_GET);
$_GET['srch_id'] = trim($_GET['srch_id']);
$_GET['srch_price_max'] = intval($_GET['srch_price_max']);
$_GET['srch_price_min'] = intval($_GET['srch_price_min']);
$_GET['srch_useddateline'] = trim($_GET['srch_useddateline']);
$_GET['srch_username'] = trim($_GET['srch_username']);
$_GET['srch_extcredits'] = trim($_GET['srch_extcredits']);
$_GET['srch_extcreditsval'] = intval($_GET['srch_extcreditsval']) > 0 ? intval($_GET['srch_extcreditsval']) : '' ;
$_GET['srch_username'] = trim($_GET['srch_username']);
$_GET['srch_useddateline_start'] = trim($_GET['srch_useddateline_start']);
$_GET['srch_useddateline_end'] = trim($_GET['srch_useddateline_end']);
$sqladd = '';
if($_GET['srch_id']) {
$sqladd .= " AND id LIKE '%{$_GET['srch_id']}%' ";
}
if($_GET['srch_card_type'] != '') {
$sqladd .= " AND typeid = '{$_GET['srch_card_type']}'";
}
if($_GET['srch_price_min'] && !$_GET['srch_price_max']) {
$sqladd .= " AND price = '{$_GET['srch_price_min']}'";
} elseif($_GET['srch_price_max'] && !$_GET['srch_price_min']) {
$sqladd .= " AND price = '{$_GET['srch_price_max']}'";
} elseif($_GET['srch_price_min'] && $_GET['srch_price_max']) {
$sqladd .= " AND price between '{$_GET['srch_price_min']}' AND '{$_GET['srch_price_max']}'";
}
if($_GET['srch_extcredits']) {
$sqladd .= " AND extcreditskey = '{$_GET['srch_extcredits']}'";
}
if($_GET['srch_extcreditsval']) {
$sqladd .= " AND extcreditsval = '{$_GET['srch_extcreditsval']}'";
}
if($_GET['srch_username']) {
$uid = ($uid = C::t('common_member')->fetch_uid_by_username($_GET['srch_username'])) ? $uid : C::t('common_member_archive')->fetch_uid_by_username($_GET['srch_username']);
$sqladd .= " AND uid = '{$uid}'";
}
if($_GET['srch_card_status']) {
$sqladd .= " AND status = '{$_GET['srch_card_status']}'";
}
if($_GET['srch_useddateline_start'] || $_GET['srch_useddateline_end']) {
if($_GET['srch_useddateline_start']) {
list($y, $m, $d) = explode("-", $_GET['srch_useddateline_start']);
$sqladd .= " AND useddateline >= '".mktime('0', '0', '0', $m, $d, $y)."' ";
}
if($_GET['srch_useddateline_end']) {
list($y, $m, $d) = explode("-", $_GET['srch_useddateline_end']);
$sqladd .= " AND useddateline <= '".mktime('23', '59', '59', $m, $d, $y)."' AND useddateline <> 0 ";
}
}
return $sqladd ? ' 1 '.$sqladd : '';
}
?>

View File

@@ -0,0 +1,699 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_checktools.php 36334 2017-01-03 01:32:35Z nemohou $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
if($operation == 'filecheck') {
$homecheck = !empty($_GET['homecheck']);
if(!$homecheck) {
$step = max(1, intval($_GET['step']));
shownav('tools', 'nav_filecheck');
showsubmenusteps('nav_filecheck', array(
array('nav_filecheck_confirm', $step == 1),
array('nav_filecheck_verify', $step == 2),
array('nav_filecheck_completed', $step == 3)
));
} else {
define('FOOTERDISABLED', true);
$step = 3;
}
if($step == 1) {
cpmsg(cplang('filecheck_tips_step1'), 'action=checktools&operation=filecheck&step=2', 'button', '', FALSE);
} elseif($step == 2) {
cpmsg(cplang('filecheck_verifying'), "action=checktools&operation=filecheck&step=3", 'loading', '', FALSE);
} elseif($step == 3) {
if(!$discuzfiles = @file('./source/admincp/discuzfiles.md5')) {
if(!$homecheck) {
cpmsg('filecheck_nofound_md5file', '', 'error');
} else {
ajaxshowheader();
ajaxshowfooter();
}
}
$md5data = $md5datanew = $addlist = $dellist = $modifylist = $showlist = array();
$cachelist = checkcachefiles('data/sysdata/');
checkfiles('./', '', 0);
checkfiles('config/', '', 1, 'config_global.php,config_ucenter.php');
checkfiles('data/', '\.xml', 0);
checkfiles('data/', '\.htm', 0);
checkfiles('data/log/', '\.htm', 0);
checkfiles('data/plugindata/', '\.htm', 0);
checkfiles('data/download/', '\.htm', 0);
checkfiles('data/addonmd5/', '\.htm', 0);
checkfiles('data/avatar/', '\.htm', 0);
checkfiles('data/cache/', '\.htm', 0);
checkfiles('data/ipdata/', '\.htm|\.dat', 0);
checkfiles('data/template/', '\.htm', 0);
checkfiles('data/threadcache/', '\.htm', 0);
checkfiles('template/', '');
checkfiles('api/', '');
checkfiles('source/', '', 1, 'discuzfiles.md5,plugin');
checkfiles('static/', '');
checkfiles('archiver/', '');
checkfiles('uc_client/', '\.php|\.htm', 0);
checkfiles('uc_client/data/', '\.htm');
checkfiles('uc_client/control/', '\.php|\.htm');
checkfiles('uc_client/model/', '\.php|\.htm');
checkfiles('uc_client/lib/', '\.php|\.htm');
checkfiles('uc_server/', '\.php|\.htm|\.txt|\.xml', 0);
checkfiles('uc_server/data/', '\.htm');
checkfiles('uc_server/api/', '\.php|\.htm');
checkfiles('uc_server/control/', '\.php|\.htm|\.md5');
checkfiles('uc_server/model/', '\.php|\.htm');
checkfiles('uc_server/lib/', '\.php|\.htm');
checkfiles('uc_server/plugin/', '\.php|\.htm|\.xml');
checkfiles('uc_server/upgrade/', '\.php');
checkfiles('uc_server/images/', '\..+?');
checkfiles('uc_server/js/', '\.js|\.htm');
checkfiles('uc_server/release/', '\.php');
checkfiles('uc_server/view/', '\.php|\.htm');
C::t('common_cache')->insert(array(
'cachekey' => 'checktools_filecheck',
'cachevalue' => serialize(array('dateline' => $_G['timestamp'])),
'dateline' => $_G['timestamp'],
), false, true);
foreach($discuzfiles as $line) {
$file = trim(substr($line, 34));
$md5datanew[$file] = substr($line, 0, 32);
if($md5datanew[$file] != $md5data[$file]) {
$modifylist[$file] = $md5data[$file];
}
$md5datanew[$file] = $md5data[$file];
}
$weekbefore = TIMESTAMP - 604800;
$md5data = is_array($md5data) ? $md5data : array();
$md5datanew = is_array($md5datanew) ? $md5datanew : array();
$addlist = array_merge(array_diff_assoc($md5data, $md5datanew), is_array($cachelist[2]) ? $cachelist[2] : array());
$dellist = array_diff_assoc($md5datanew, $md5data);
$modifylist = array_merge(array_diff_assoc($modifylist, $dellist), is_array($cachelist[1]) ? $cachelist[1] : array());
$showlist = array_merge($md5data, $md5datanew, $cachelist[0]);
$doubt = 0;
$dirlist = $dirlog = array();
foreach($showlist as $file => $md5) {
$dir = dirname($file);
if(is_array($modifylist) && array_key_exists($file, $modifylist)) {
$fileststus = 'modify';
} elseif(is_array($dellist) && array_key_exists($file, $dellist)) {
$fileststus = 'del';
} elseif(is_array($addlist) && array_key_exists($file, $addlist)) {
$fileststus = 'add';
} else {
$filemtime = @filemtime($file);
if($filemtime > $weekbefore) {
$fileststus = 'doubt';
$doubt++;
} else {
$fileststus = '';
}
}
if(file_exists($file)) {
$filemtime = @filemtime($file);
$fileststus && $dirlist[$fileststus][$dir][basename($file)] = array(number_format(filesize($file)).' Bytes', dgmdate($filemtime));
} else {
$fileststus && $dirlist[$fileststus][$dir][basename($file)] = array('', '');
}
}
$modifiedfiles = count($modifylist);
$deletedfiles = count($dellist);
$unknownfiles = count($addlist);
$doubt = intval($doubt);
C::t('common_cache')->insert(array(
'cachekey' => 'checktools_filecheck_result',
'cachevalue' => serialize(array($modifiedfiles, $deletedfiles, $unknownfiles, $doubt)),
'dateline' => $_G['timestamp'],
), false, true);
if($homecheck) {
ajaxshowheader();
echo "<div><em class=\"".($modifiedfiles ? 'edited' : 'correct')."\">{$lang['filecheck_modify']}<span class=\"bignum\">$modifiedfiles</span></em>".
"<em class=\"".($deletedfiles ? 'del' : 'correct')."\">{$lang['filecheck_delete']}<span class=\"bignum\">$deletedfiles</span></em>".
"<em class=\"unknown\">{$lang['filecheck_unknown']}<span class=\"bignum\">$unknownfiles</span></em>".
"<em class=\"unknown\">{$lang['filecheck_doubt']}<span class=\"bignum\">$doubt</span></em></div><p>".
$lang['filecheck_last_homecheck'].': '.dgmdate(TIMESTAMP, 'u').' <a href="'.ADMINSCRIPT.'?action=checktools&operation=filecheck&step=3">['.$lang['filecheck_view_list'].']</a></p>';
ajaxshowfooter();
}
$result = $resultjs = '';
$dirnum = 0;
foreach($dirlist as $status => $filelist) {
$dirnum++;
$class = $status == 'modify' ? 'edited' : ($status == 'del' ? 'del' : 'unknown');
$result .= '<tbody id="status_'.$status.'" style="display:'.($status != 'modify' ? 'none' : '').'">';
foreach($filelist as $dir => $files) {
$result .= '<tr><td colspan="4"><div class="ofolder">'.$dir.'</div><div class="margintop marginbot">';
foreach($files as $filename => $file) {
$result .= '<tr><td><em class="files bold">'.$filename.'</em></td><td style="text-align: right">'.$file[0].'&nbsp;&nbsp;</td><td>'.$file[1].'</td><td><em class="'.$class.'">&nbsp;</em></td></tr>';
}
}
$result .= '</tbody>';
$resultjs .= '$(\'status_'.$status.'\').style.display=\'none\';';
}
$result .= '<script>function showresult(o) {'.$resultjs.'$(\'status_\' + o).style.display=\'\';}</script>';
showtips('filecheck_tips');
showboxheader('filecheck_completed');
echo "<div>".
"<em class=\"edited\">{$lang['filecheck_modify']}: $modifiedfiles</em> ".($modifiedfiles > 0 ? "<a href=\"###\" onclick=\"showresult('modify')\">[{$lang['view']}]</a> " : '').
" &nbsp; <em class=\"del\">{$lang['filecheck_delete']}: $deletedfiles</em> ".($deletedfiles > 0 ? "<a href=\"###\" onclick=\"showresult('del')\">[{$lang['view']}]</a> " : '').
" &nbsp; <em class=\"unknown\">{$lang['filecheck_unknown']}: $unknownfiles</em> ".($unknownfiles > 0 ? "<a href=\"###\" onclick=\"showresult('add')\">[{$lang['view']}]</a> " : '').
($doubt > 0 ? "&nbsp;&nbsp;&nbsp;&nbsp;<em class=\"unknown\">{$lang['filecheck_doubt']}: $doubt</em> <a href=\"###\" onclick=\"showresult('doubt')\">[{$lang['view']}]</a> " : '').
"</div></div><div class=\"boxbody\">";
showtableheader();
showsubtitle(array('filename', '', 'lastmodified', ''));
echo $result;
showtablefooter();
showboxfooter();
}
} elseif($operation == 'hookcheck') {
$step = max(1, intval($_GET['step']));
shownav('tools', 'nav_hookcheck');
showsubmenusteps('nav_hookcheck', array(
array('nav_hookcheck_confirm', $step == 1),
array('nav_hookcheck_verify', $step == 2),
array('nav_hookcheck_completed', $step == 3)
));
showtips('hookcheck_tips');
if($step == 1) {
$styleselect = "<br><br><select name=\"styleid\">";
foreach(C::t('common_style')->fetch_all_data() as $style) {
$styleselect .= "<option value=\"{$style['styleid']}\" ".
($style['styleid'] == $_G['setting']['styleid'] ? 'selected="selected"' : NULL).
">{$style['name']}</option>\n";
}
$styleselect .= '</select>';
cpmsg(cplang('hookcheck_tips_step1', array('template' => $styleselect)), 'action=checktools&operation=hookcheck&step=2', 'form', '', FALSE);
} elseif($step == 2) {
cpmsg(cplang('hookcheck_verifying'), "action=checktools&operation=hookcheck&step=3&styleid={$_POST['styleid']}", 'loading', '', FALSE);
} elseif($step == 3) {
if(!$discuzfiles = @file('./source/admincp/discuzhook.dat')) {
cpmsg('filecheck_nofound_md5file', '', 'error');
}
$discuzhookdata = $hookdata = array();
$discuzhookdata_hook = array();
$styleid = intval($_GET['styleid']);
if(!$styleid) {
$styleid = $_G['setting']['styleid'];
}
$style = C::t('common_style')->fetch_by_styleid($styleid);
checkhook(substr($style['directory'], 2).'/', '\.htm|\.php', 1);
foreach($discuzfiles as $line) {
list($file, $hook) = explode(' *', trim($line));
if($hook) {
$discuzhookdata[$file][$hook][] = $hook;
$discuzhookdata_hook[$file][] = $hook;
}
}
$diffhooklist = $difffilelist = array();
$diffnum = 0;
foreach($discuzhookdata as $file => $hook) {
$dir = dirname($file);
$filen = str_replace('template/default/', substr($style['directory'], 2).'/', $file);
if(isset($hookdata[$filen])) {
foreach($hook as $k => $hookarr) {
$hooknum = empty($hookarr) ? 0 : count($hookarr);
$hookdatanum = empty($hookdata[$filen][$k]) ? 0 : count($hookdata[$filen][$k]);
if(($diff = $hooknum - $hookdatanum) > 0) {
for($i = 0; $i < $diff; $i++) {
$diffhooklist[$file][] = $k;
}
}
}
if(!empty($diffhooklist[$file])) {
$difffilelist[$dir][] = $file;
$diffnum++;
}
}
}
foreach($difffilelist as $dir => $files) {
$dir = str_replace('template/default/', substr($style['directory'], 2).'/', $dir);
$result .= '<tbody><tr><td class="td30"><a href="javascript:;" onclick="toggle_group(\'dir_'.$dir.'\')" id="a_dir_'.$dir.'">[-]</a></td><td colspan="3"><div class="ofolder">'.$dir.'</div></td></tr></tbody>';
$result .= '<tbody id="dir_'.$dir.'">';
foreach($files as $file) {
$result .= '<tr><td></td><td><em class="files bold">'.basename($file).'</em></td><td>';
foreach($discuzhookdata_hook[$file] as $hook) {
$result .= '<p>'.dhtmlspecialchars($hook).'</p>';
}
$result .= '</td><td>';
foreach($diffhooklist[$file] as $hook) {
$result .= '<p>'.dhtmlspecialchars($hook).'</p>';
}
$result .= '</td></tr>';
}
$result .= '</tbody>';
}
if($diffnum > 20) {
$result .= '<script type="text/javascript">hide_all_hook(\'dir_\', \'tbody\');</script>';
}
if($diffnum) {
showformheader('forums');
showtableheader('hookcheck_completed');
showtablerow('', 'colspan="4"', "<div class=\"margintop marginbot\">".
'<a href="javascript:;" onclick="show_all_hook(\'dir_\', \'tbody\')">'.$lang['show_all'].'</a> | <a href="javascript:;" onclick="hide_all_hook(\'dir_\', \'tbody\')">'.$lang['hide_all'].'</a>'.
" &nbsp; <em class=\"del\">{$lang['hookcheck_delete']}: $diffnum</em> ".
"</div>");
showsubtitle(array('', 'filename', 'hookcheck_discuzhook', 'hookcheck_delhook'));
echo $result;
showtablefooter();
showformfooter();
} else {
cpmsg('hookcheck_nodelhook', '', 'succeed', '', FALSE);
}
}
} elseif($operation == 'replacekey') {
$step = max(1, intval($_GET['step']));
shownav('tools', 'nav_replacekey');
showsubmenusteps('nav_replacekey', array(
array('nav_replacekey_confirm', $step == 1),
array('nav_replacekey_verify', $step == 2),
array('nav_replacekey_completed', $step == 3)
));
showtips('replacekey_tips');
if($step == 1) {
cpmsg(cplang('replacekey_tips_step1'), 'action=checktools&operation=replacekey&step=2', 'form', '', FALSE);
} elseif($step == 2) {
cpmsg(cplang('replacekey_tips_step2'), "action=checktools&operation=replacekey&step=3", 'loading', '', FALSE);
} elseif($step == 3) {
if(!is_writeable('./config/config_global.php')) {
cpmsg('replacekey_must_write_config', '', 'error');
}
$oldauthkey = $_G['config']['security']['authkey'];
$newauthkey = generate_key(64);
$configfile = trim(file_get_contents(DISCUZ_ROOT.'./config/config_global.php'));
$configfile = substr($configfile, -2) == '?>' ? substr($configfile, 0, -2) : $configfile;
$configfile = str_replace($oldauthkey, $newauthkey, $configfile);
if(file_put_contents(DISCUZ_ROOT.'./config/config_global.php', trim($configfile)) === false) {
cpmsg('replacekey_must_write_config', '', 'error');
}
$ecdata = authcode($_G['setting']['ec_contract'], 'DECODE', $oldauthkey);
$ecdata = authcode($ecdata, 'ENCODE', $newauthkey);
C::t('common_setting')->update('ec_contract', $ecdata);
$ftpdata = $_G['setting']['ftp'];
$ftppasswd = authcode($ftpdata['password'], 'DECODE', md5($oldauthkey));
$ftpdata['password'] = authcode($ftppasswd, 'ENCODE', md5($newauthkey));
C::t('common_setting')->update('ftp', $ftpdata);
updatecache('setting');
cpmsg('replacekey_succeed', '', 'succeed', '', FALSE);
}
} elseif($operation == 'ftpcheck') {
$alertmsg = '';
$testcontent = md5('Discuz!' . random(64));
$testfile = 'test/discuztest.txt';
$attach_dir = $_G['setting']['attachdir'];
@mkdir($attach_dir.'test', 0777);
if(file_put_contents($attach_dir.'/'.$testfile, $testcontent) === false) {
$alertmsg = cplang('setting_attach_remote_wtferr');
}
if(!$alertmsg) {
$settingnew = $_GET['settingnew'];
$settings['ftp'] = C::t('common_setting')->fetch_setting('ftp', true);
$settings['ftp']['password'] = authcode($settings['ftp']['password'], 'DECODE', md5($_G['config']['security']['authkey']));
$pwlen = strlen($settingnew['ftp']['password']);
if($settingnew['ftp']['password'][0] == $settings['ftp']['password'][0] && $settingnew['ftp']['password'][$pwlen - 1] == $settings['ftp']['password'][strlen($settings['ftp']['password']) - 1] && substr($settingnew['ftp']['password'], 1, $pwlen - 2) == '********') {
$settingnew['ftp']['password'] = $settings['ftp']['password'];
}
$settingnew['ftp']['password'] = authcode($settingnew['ftp']['password'], 'ENCODE', md5($_G['config']['security']['authkey']));
$settingnew['ftp']['attachurl'] .= substr($settingnew['ftp']['attachurl'], -1, 1) != '/' ? '/' : '';
$_G['setting']['ftp'] = $settingnew['ftp'];
ftpcmd('upload', $testfile);
$ftp = ftpcmd('object');
if(ftpcmd('error')) {
$alertmsg = cplang('setting_attach_remote_'.ftpcmd('error'));
}
if(!$alertmsg) {
$str = getremotefile($_G['setting']['ftp']['attachurl'].$testfile);
if($str !== $testcontent) {
$alertmsg = cplang('setting_attach_remote_geterr');
}
}
if(!$alertmsg) {
ftpcmd('delete', $testfile);
ftpcmd('delete', 'test/index.htm');
$ftp->ftp_rmdir('test');
$str = getremotefile($_G['setting']['ftp']['attachurl'].$testfile);
if($str === $testcontent) {
$alertmsg = cplang('setting_attach_remote_delerr');
}
@unlink($attach_dir.'/'.$testfile);
@rmdir($attach_dir.'test');
}
}
if(!$alertmsg) {
$alertmsg = cplang('setting_attach_remote_ok');
}
echo '<script language="javascript">alert(\''.str_replace('\'', '\\\'', $alertmsg).'\');parent.$(\'cpform\').action=\''.ADMINSCRIPT.'?action=setting&edit=yes\';parent.$(\'cpform\').target=\'_self\'</script>';
} elseif($operation == 'mailcheck') {
$oldmail = dunserialize($_G['setting']['mail']);
$settingnew = $_GET['settingnew'];
$oldsmtp = $settingnew['mail']['mailsend'] == 3 ? $settingnew['mail']['smtp'] : $settingnew['mail']['esmtp'];
$deletesmtp = $settingnew['mail']['mailsend'] != 1 ? ($settingnew['mail']['mailsend'] == 3 ? $settingnew['mail']['smtp']['delete'] : $settingnew['mail']['esmtp']['delete']) : array();
$settingnew['mail']['smtp'] = array();
foreach($oldsmtp as $id => $value) {
if((empty($deletesmtp) || !in_array($id, $deletesmtp)) && !empty($value['server']) && !empty($value['port'])) {
$passwordmask = $oldmail['smtp'][$id]['auth_password'] ? $oldmail['smtp'][$id]['auth_password'][0].'********'.substr($oldmail['smtp'][$id]['auth_password'], -2) : '';
$value['auth_password'] = $value['auth_password'] == $passwordmask ? $oldmail['smtp'][$id]['auth_password'] : $value['auth_password'];
$settingnew['mail']['smtp'][] = $value;
}
}
if(!empty($_GET['newsmtp'])) {
foreach($_GET['newsmtp']['server'] as $id => $smtp) {
if(!empty($smtp) && !empty($_GET['newsmtp']['port'][$id])) {
$settingnew['mail']['smtp'][] = array(
'server' => $smtp,
'port' => $_GET['newsmtp']['port'][$id] ? intval($_GET['newsmtp']['port'][$id]) : 25,
'auth' => $_GET['newsmtp']['auth'][$id] ? 1 : 0,
'from' => $_GET['newsmtp']['from'][$id],
'auth_username' => $_GET['newsmtp']['auth_username'][$id],
'auth_password' => $_GET['newsmtp']['auth_password'][$id],
'precedence' => $_GET['newsmtp']['precedence'][$id]
);
}
}
}
$_G['setting']['mail'] = serialize($settingnew['mail']);
$test_to = $_GET['test_to'];
$test_from = $_GET['test_from'];
$date = date('Y-m-d H:i:s');
$alertmsg = '';
$title = $lang['setting_mailcheck_title_'.$settingnew['mail']['mailsend']];
$message = $lang['setting_mailcheck_message_'.$settingnew['mail']['mailsend']].' '.$test_from.$lang['setting_mailcheck_date'].' '.$date;
$_G['setting']['bbname'] = $lang['setting_mail_check_method_1'];
include libfile('function/mail');
$succeed = sendmail($test_to, $title.' @ '.$date, $_G['setting']['bbname']."\n\n\n$message", $test_from);
$_G['setting']['bbname'] = $lang['setting_mail_check_method_2'];
$succeed = sendmail($test_to, $title.' @ '.$date, $_G['setting']['bbname']."\n\n\n$message", $test_from);
if($succeed) {
$alertmsg = $lang['setting_mail_check_success_1']."$title @ $date".$lang['setting_mail_check_success_2'];
} else {
$alertmsg = $lang['setting_mail_check_error'].$alertmsg;
}
echo '<script language="javascript">alert(\''.str_replace(array('\'', "\n", "\r"), array('\\\'', '\n', ''), $alertmsg).'\');parent.$(\'cpform\').action=\''.ADMINSCRIPT.'?action=setting&edit=yes\';parent.$(\'cpform\').target=\'_self\';parent.$(\'cpform\').operation.value=\'mail\';</script>';
} elseif($operation == 'imagepreview') {
$settingnew = $_GET['settingnew'];
if(!empty($_GET['previewthumb'])) {
$_G['setting']['imagelib'] = $settingnew['imagelib'];
$_G['setting']['thumbwidth'] = $settingnew['thumbwidth'];
$_G['setting']['thumbheight'] = $settingnew['thumbheight'];
$_G['setting']['thumbquality'] = $settingnew['thumbquality'];
require_once libfile('class/image');
@unlink(DISCUZ_ROOT.$_G['setting']['attachdir'].'./temp/watermark_temp1.jpg');
@unlink(DISCUZ_ROOT.$_G['setting']['attachdir'].'./temp/watermark_temp2.jpg');
$image = new image;
$r = 0;
if(!($r = $image->Thumb(DISCUZ_ROOT.'./static/image/admincp/watermarkpreview.jpg', 'temp/watermark_temp1.jpg', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], 1))) {
$r = $image->error();
}
$sizetarget1 = $image->imginfo['size'];
$image->Thumb(DISCUZ_ROOT.'./static/image/admincp/watermarkpreview.jpg', 'temp/watermark_temp2.jpg', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], 2);
$sizetarget2 = $image->imginfo['size'];
if($r > 0) {
showsubmenu('imagepreview_thumb');
$sizesource = filesize(DISCUZ_ROOT.'./static/image/admincp/watermarkpreview.jpg');
echo '<img src="data/attachment/temp/watermark_temp1.jpg?'.random(5).'"><br /><br />'.
$lang['imagepreview_imagesize_source'].' '.number_format($sizesource).' Bytes &nbsp;&nbsp;'.
$lang['imagepreview_imagesize_target'].' '.number_format($sizetarget1).' Bytes ('.
(sprintf("%2.1f", $sizetarget1 / $sizesource * 100)).'%)<br /><br />';
echo '<img src="data/attachment/temp/watermark_temp2.jpg?'.random(5).'"><br /><br />'.
$lang['imagepreview_imagesize_source'].' '.number_format($sizesource).' Bytes &nbsp;&nbsp;'.
$lang['imagepreview_imagesize_target'].' '.number_format($sizetarget2).' Bytes ('.
(sprintf("%2.1f", $sizetarget2 / $sizesource * 100)).'%)';
} else {
cpmsg('imagepreview_errorcode_'.$r, '', 'error');
}
} else {
$type = $_GET['type'];
$status = dunserialize($_G['setting']['watermarkstatus']);
$status = is_array($status) ? $status : array();
if(!array_key_exists($type, $status) || !$status[$type]) {
cpmsg('watermarkpreview_error', '', 'error');
}
require_once libfile('class/image');
@unlink(DISCUZ_ROOT.'./data/attachment/temp/watermark_temp3.jpg');
$image = new image;
if(!($r = $image->Watermark(DISCUZ_ROOT.'./static/image/admincp/watermarkpreview.jpg', 'temp/watermark_temp3.jpg', $type))) {
$r = $image->error();
}
if($r > 0) {
showsubmenu('imagepreview_watermark');
$sizesource = filesize('static/image/admincp/watermarkpreview.jpg');
$sizetarget = $image->imginfo['size'];
echo '<img src="data/attachment/temp/watermark_temp3.jpg?'.random(5).'"><br /><br />'.
$lang['imagepreview_imagesize_source'].' '.number_format($sizesource).' Bytes &nbsp;&nbsp;'.
$lang['imagepreview_imagesize_target'].' '.number_format($sizetarget).' Bytes ('.
(sprintf("%2.1f", $sizetarget / $sizesource * 100)).'%)';
} else {
cpmsg('imagepreview_errorcode_'.$r, '', 'error');
}
}
} elseif($operation == 'rewrite') {
$rule = array();
$rewritedata = rewritedata();
$rule['{apache1}'] = $rule['{apache2}'] = $rule['{iis}'] = $rule['{iis7}'] = $rule['{nginx}'] = $rule['{lighttpd}'] = $rule['{caddy}'] = '';
foreach($rewritedata['rulesearch'] as $k => $v) {
if(!is_array($_G['setting']['rewritestatus']) || !in_array($k, $_G['setting']['rewritestatus'])) {
continue;
}
$v = empty($_G['setting']['rewriterule'][$k]) ? $v : $_G['setting']['rewriterule'][$k];
$pvmaxv = count($rewritedata['rulevars'][$k]) + 2;
$vkeys = array_keys($rewritedata['rulevars'][$k]);
$rewritedata['rulereplace'][$k] = pvsort($vkeys, $v, $rewritedata['rulereplace'][$k]);
$v = str_replace($vkeys, $rewritedata['rulevars'][$k], addcslashes($v, '?*+^$.[]()|'));
$rulepath = $k != 'forum_archiver' ? '' : 'archiver/';
$rule['{apache1}'] .= "\t".'RewriteCond %{QUERY_STRING} ^(.*)$'."\n\t".'RewriteRule ^(.*)/'.$rulepath.$v.'$ $1/'.$rulepath.pvadd($rewritedata['rulereplace'][$k])."&%1\n";
$rule['{apache2}'] .= 'RewriteCond %{QUERY_STRING} ^(.*)$'."\n".'RewriteRule ^'.$rulepath.$v.'$ '.$rulepath.$rewritedata['rulereplace'][$k]."&%1\n";
$rule['{iis}'] .= 'RewriteRule ^(.*)/'.$rulepath.$v.'(\?(.*))*$ $1/'.$rulepath.addcslashes(pvadd($rewritedata['rulereplace'][$k]).'&$'.($pvmaxv + 1), '.?')."\n";
$rule['{iis7}'] .= "\t\t".'&lt;rule name="'.$k.'"&gt;'."\n\t\t\t".'&lt;match url="^(.*/)*'.$rulepath.str_replace('\.', '.', $v).'\?*(.*)$" /&gt;'."\n\t\t\t".'&lt;action type="Rewrite" url="{R:1}/'.str_replace(array('&', 'page\%3D'), array('&amp;amp;', 'page%3D'), $rulepath.addcslashes(pvadd($rewritedata['rulereplace'][$k], array('{R:', '}')).'&{R:'.$pvmaxv.'}', '?')).'" /&gt;'."\n\t\t".'&lt;/rule&gt;'."\n";
$rule['{nginx}'] .= 'rewrite ^([^\.]*)/'.$rulepath.$v.'$ $1/'.$rulepath.stripslashes(pvadd($rewritedata['rulereplace'][$k]))." last;\n";
$rule['{lighttpd}'] .= '"(.*)/'.$rulepath.$v.'\?*(.*)$" =&gt; "$1/'.$rulepath.pvadd($rewritedata['rulereplace'][$k]).'&$'.$pvmaxv.'",'."\n";
$rule['{caddy}'] .= '@'.$k.' path_regexp '.$k.' ^(.*)/'.$rulepath.$v."$\n".'rewrite @'.$k.' {re.'.$k.'.1}/'.$rulepath.pvadd($rewritedata['rulereplace'][$k], array('{re.'.$k.'.', '}')).'&{query}'."\n";
}
$rule['{nginx}'] .= "if (!-e \$request_filename) {\n\treturn 404;\n}";
$rule['{siteroot}'] = !empty($_G['siteroot']) ? $_G['siteroot'] : '/';
echo str_replace(array_keys($rule), $rule, cplang('rewrite_message'));
} elseif($operation == 'robots') {
if($do == 'output') {
$robots = implode('', file(DISCUZ_ROOT.'./source/admincp/robots.txt'));
$robots = str_replace('{path}', $_G['siteroot'], $robots);
$robots = str_replace('{ver}', $_G['setting']['version'], $robots);
ob_end_clean();
dheader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
dheader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
dheader('Cache-Control: no-cache, must-revalidate');
dheader('Pragma: no-cache');
dheader('Content-Encoding: none');
dheader('Content-Length: '.strlen($robots));
dheader('Content-Disposition: attachment; filename=robots.txt');
dheader('Content-Type: text/plain');
echo $robots;
define('FOOTERDISABLED' , 1);
exit();
}
cpmsg('robots_output', 'action=checktools&operation=robots&do=output&frame=no', 'download', array('siteurl' => dhtmlspecialchars($_G['scheme'].'://'.$_SERVER['HTTP_HOST'].'/')));
}
function pvsort($key, $v, $s) {
$r = '/';
$p = '';
foreach($key as $k) {
$r .= $p.preg_quote($k);
$p = '|';
}
$r .= '/';
preg_match_all($r, $v, $a);
$a = $a[0];
$a = array_flip($a);
foreach($a as $key => $value) {
$s = str_replace($key, '$'.($value + 1), $s);
}
return $s;
}
function pvadd($s, $t = array()) {
$s = str_replace(array('$3', '$2', '$1'), array('~4', '~3', '~2'), $s);
if(!$t) {
return str_replace(array('~4', '~3', '~2'), array('$4', '$3', '$2'), $s);
} else {
return str_replace(array('~4', '~3', '~2'), array($t[0].'4'.$t[1], $t[0].'3'.$t[1], $t[0].'2'.$t[1]), $s);
}
}
function checkfiles($currentdir, $ext = '', $sub = 1, $skip = '') {
global $md5data;
$dir = @opendir(DISCUZ_ROOT.$currentdir);
$exts = '/('.$ext.')$/i';
$skips = explode(',', $skip);
if($dir == false) {
return;
}
while($entry = @readdir($dir)) {
$file = $currentdir.$entry;
if($entry != '.' && $entry != '..' && (($ext && preg_match($exts, $entry) || !$ext) || $sub && is_dir($file)) && !in_array($entry, $skips)) {
if($sub && is_dir($file)) {
checkfiles($file.'/', $ext, $sub, $skip);
} else {
if(is_dir($file)) {
$md5data[$file] = md5($file);
} else {
$md5data[$file] = md5_file($file);
}
}
}
}
}
function checkcachefiles($currentdir) {
global $_G;
$dir = opendir($currentdir);
$exts = '/\.php$/i';
$showlist = $modifylist = $addlist = array();
while($entry = readdir($dir)) {
$file = $currentdir.$entry;
if($entry != '.' && $entry != '..' && preg_match($exts, $entry)) {
$fp = fopen($file, "rb");
$cachedata = fread($fp, filesize($file));
fclose($fp);
if(preg_match("/^<\?php\n\/\/Discuz! cache file, DO NOT modify me!\n\/\/Identify: (\w+)\n\n(.+?)\?>$/s", $cachedata, $match)) {
$showlist[$file] = $md5 = $match[1];
$cachedata = $match[2];
if(md5($entry.$cachedata.$_G['config']['security']['authkey']) != $md5) {
$modifylist[$file] = $md5;
}
} else {
$showlist[$file] = '';
}
}
}
return array($showlist, $modifylist, $addlist);
}
function checkmailerror($type, $error) {
global $alertmsg;
$alertmsg .= !$alertmsg ? $error : '';
}
function getremotefile($file) {
global $_G;
@set_time_limit(0);
$file = $file.'?'.TIMESTAMP.rand(1000, 9999);
if(strpos($file, 'ftp://') === 0) {
$str = file_get_contents($file);
} else {
$str = dfsockopen($file);
}
return $str;
}
function checkhook($currentdir, $ext = '', $sub = 1, $skip = '') {
global $hooks, $hookdata;
$dir = opendir($currentdir);
$exts = '/('.$ext.')$/i';
$skips = explode(',', $skip);
while($entry = readdir($dir)) {
$file = $currentdir.$entry;
if($entry != '.' && $entry != '..' && (preg_match($exts, $entry) || $sub && is_dir($file)) && !in_array($entry, $skips)) {
if($sub && is_dir($file)) {
checkhook($file.'/', $ext, $sub, $skip);
} else {
$data = file_get_contents($file);
$hooks = array();
preg_replace_callback("/\{hook\/(\w+?)(\s+(.+?))?\}/i", 'checkhook_callback_findhook_13', $data);
if($hooks) {
foreach($hooks as $v) {
if(preg_match('/\.php$/', $file)) {
$file = substr($file, 0, -4).'.htm';
}
$hookdata[$file][$v][] = $v;
}
}
}
}
}
}
function checkhook_callback_findhook_13($matches) {
return findhook($matches[1], $matches[3]);
}
function findhook($hookid, $key) {
global $hooks;
if($key) {
$key = ' '.$key;
}
$hooks[] = '<!--{hook/'.$hookid.$key.'}-->';
}
function generate_key($length = 32) {
$random = secrandom($length);
$info = md5($_SERVER['SERVER_SOFTWARE'].$_SERVER['SERVER_NAME'].$_SERVER['SERVER_ADDR'].$_SERVER['SERVER_PORT'].$_SERVER['HTTP_USER_AGENT'].time());
$return = '';
for($i=0; $i<$length; $i++) {
$return .= $random[$i].$info[$i];
}
return $return;
}

View File

@@ -0,0 +1,130 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_click.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$operation = $operation ? $operation : '';
cpheader();
if(empty($operation)) {
$idtype = in_array($_GET['idtype'], array('blogid', 'picid', 'aid')) ? trim($_GET['idtype']) : 'blogid';
if(!submitcheck('clicksubmit')) {
shownav('style', 'click_edit');
showsubmenu('nav_click', array(
array('click_edit_blogid', 'click&idtype=blogid', $idtype == 'blogid' ? 1 : 0),
array('click_edit_picid', 'click&idtype=picid', $idtype == 'picid' ? 1 : 0),
array('click_edit_aid', 'click&idtype=aid', $idtype == 'aid' ? 1 : 0),
));
showtips('click_edit_tips');
showformheader('click&idtype='.$idtype);
showtableheader();
showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"', 'class="td25"', '', '', '', 'class="td23"', 'class="td25"'), array(
'',
cplang('display_order'),
'',
cplang('available'),
cplang('name'),
cplang('click_edit_image'),
cplang('click_edit_type'),
));
print <<<EOF
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" name="newdisplayorder[]" size="3">', 'td28'],
[1,'', 'td25'],
[1,'<input type="checkbox" name="newavailable[]" value="1">', 'td25'],
[1,'<input type="text" class="txt" name="newname[]" size="10">'],
[1,'<input type="text" class="txt" name="newicon[]" size="20">'],
[1,'', 'td23']
]
];
</script>
EOF;
foreach(C::t('home_click')->fetch_all_by_idtype($idtype) as $click) {
$checkavailable = $click['available'] ? 'checked' : '';
$click['idtype'] = cplang('click_edit_'.$click['idtype']);
$iconurl = preg_match('/^https?:\/\//is', $click['icon']) ? $click['icon'] : STATICURL . 'image/click/' . $click['icon'];
showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"', 'class="td25"', '', '', '', 'class="td23"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"{$click['clickid']}\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[{$click['clickid']}]\" value=\"{$click['displayorder']}\">",
"<img src=\"$iconurl\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"available[{$click['clickid']}]\" value=\"1\" $checkavailable>",
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"name[{$click['clickid']}]\" value=\"{$click['name']}\">",
"<input type=\"text\" class=\"txt\" size=\"20\" name=\"icon[{$click['clickid']}]\" value=\"{$click['icon']}\">",
$click['idtype']
));
}
echo '<tr><td></td><td colspan="8"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['click_edit_addnew'].'</a></div></td></tr>';
showsubmit('clicksubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
$ids = array();
if(is_array($_GET['delete'])) {
foreach($_GET['delete'] as $id) {
$ids[] = $id;
}
if($ids) {
C::t('home_click')->delete($ids, true);
}
}
if(is_array($_GET['name'])) {
foreach($_GET['name'] as $id => $val) {
$id = intval($id);
$updatearr = array(
'name' => dhtmlspecialchars($_GET['name'][$id]),
'icon' => $_GET['icon'][$id],
'idtype' => $idtype,
'available' => intval($_GET['available'][$id]),
'displayorder' => intval($_GET['displayorder'][$id]),
);
C::t('home_click')->update($id, $updatearr);
}
}
if(is_array($_GET['newname'])) {
foreach($_GET['newname'] as $key => $value) {
if($value != '' && $_GET['newicon'][$key] != '') {
$data = array(
'name' => dhtmlspecialchars($value),
'icon' => $_GET['newicon'][$key],
'idtype' => $idtype,
'available' => intval($_GET['newavailable'][$key]),
'displayorder' => intval($_GET['newdisplayorder'][$key])
);
C::t('home_click')->insert($data);
}
}
}
$keys = $ids = $_G['cache']['click'] = array();
foreach(C::t('home_click')->fetch_all_by_available() as $value) {
if(!isset($_G['cache']['click'][$value['idtype']]) || count($_G['cache']['click'][$value['idtype']]) < 8) {
$keys[$value['idtype']] = $keys[$value['idtype']] ? ++$keys[$value['idtype']] : 1;
$_G['cache']['click'][$value['idtype']][$keys[$value['idtype']]] = $value;
} else {
$ids[] = $value['clickid'];
}
}
if($ids) {
C::t('home_click')->update($ids, array('available'=>0), true);
}
updatecache('click');
cpmsg('click_edit_succeed', 'action=click&idtype='.$idtype, 'succeed');
}
}
?>

View File

@@ -0,0 +1,312 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_cloudaddons.php 36311 2016-12-19 01:47:34Z nemohou $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
require_once libfile('function/cloudaddons');
cpheader();
if(!$admincp->isfounder) {
cpmsg('noaccess_isfounder', '', 'error');
}
if(!$operation || in_array($operation, array('plugins', 'templates'))) {
cloudaddons_check();
shownav('cloudaddons');
$extra = '';
if(empty($_GET['frame'])) {
parse_str($_SERVER['QUERY_STRING'], $query);
$query['frame'] = 'no';
$query_sting_tmp = http_build_query($query);
$url = ADMINSCRIPT.'?'.$query_sting_tmp;
echo '<script type="text/javascript">top.location.href=\''.$url.'\';</script>';
} else {
if(!empty($operation)) {
$extra .= '&view='.rawurlencode($operation);
}elseif(!empty($_GET['id'])) {
$extra .= '&mod=app&ac=item&id='.rawurlencode($_GET['id']);
}
if(!empty($_GET['from'])) {
$extra .= '&from='.rawurlencode($_GET['from']);
}
if(!empty($_GET['extra'])) {
$extra .= '&'.addslashes($_GET['extra']);
}
$url = cloudaddons_url($extra);
echo '<script type="text/javascript">location.href=\''.$url.'\';</script>';
}
} elseif($operation == 'download') {
$step = intval($_GET['step']);
$addoni = intval($_GET['i']);
if(!$_GET['md5hash'] || md5($_GET['addonids'].md5(cloudaddons_getuniqueid().$_GET['timestamp'])) != $_GET['md5hash']) {
cpmsg('cloudaddons_validator_error', '', 'error');
}
$addonids = explode(',', $_GET['addonids']);
list($_GET['key'], $_GET['type'], $_GET['rid']) = explode('.', isset($addonids[$addoni]) ? $addonids[$addoni] : $addonids[0]);
if($step == 0) {
cpmsg('cloudaddons_downloading', "action=cloudaddons&operation=download&addonids={$_GET['addonids']}&i=$addoni&step=1&md5hash=".$_GET['md5hash'].'&timestamp='.$_GET['timestamp'], 'loading', array('addonid' => $_GET['key'].'.'.$_GET['type']), '<div>0%</div>', FALSE);
} elseif($step == 1) {
$packnum = isset($_GET['num']) ? $_GET['num'] : 0;
$tmpdir = DISCUZ_ROOT.'./data/download/'.$_GET['rid'];
$end = '';
$md5tmp = DISCUZ_ROOT.'./data/download/'.$_GET['rid'].'.md5';
if($packnum) {
list($md5total, $md5s) = dunserialize(implode('', @file($md5tmp)));
dmkdir($tmpdir, 0777, false);
} else {
dir_clear($tmpdir);
@unlink($md5tmp);
dmkdir($tmpdir, 0777, false);
$md5total = '';
$md5s = array();
}
$data = cloudaddons_open('&mod=app&ac=download&rid='.$_GET['rid'].'&packnum='.$packnum.'&downloadts='.$_GET['timestamp'], '', 999);
if(empty($data)){
cpmsg('cloudaddons_downloading', "action=cloudaddons&operation=download&addonids={$_GET['addonids']}&i=$addoni&step=1&md5hash=".$_GET['md5hash'].'&timestamp='.$_GET['timestamp'].'&num='.$packnum, 'loading', array('addonid' => $_GET['key'].'.'.$_GET['type']), '<div></div>', FALSE);
exit;
}
$_GET['importtxt'] = $data;
$array = getimportdata('Discuz! File Pack');
if(!$array['Status']) {
list($_cur, $_max) = explode('/', $array['part']);
$percent = intval($_cur/$_max * 100);
if($array['type'] != $_GET['type'] || $array['key'] != $_GET['key'] || !$array['files']) {
dir_clear($tmpdir);
@unlink($md5tmp);
cloudaddons_faillog($_GET['rid'], 100);
cpmsg('cloudaddons_download_error', '', 'error', array('ErrorCode' => 100));
}
foreach($array['files'] as $file => $data) {
$filename = $tmpdir.'/'.$file.'._addons_';
$dirname = dirname($filename);
dmkdir($dirname, 0777, false);
$fp = fopen($filename, !$data['Part'] ? 'w' : 'a');
if(!$fp) {
dir_clear($tmpdir);
@unlink($md5tmp);
cloudaddons_faillog($_GET['rid'], 101);
cpmsg('cloudaddons_download_write_error', '', 'error');
}
fwrite($fp, gzuncompress(base64_decode($data['Data'])));
fclose($fp);
if($data['MD5']) {
$md5total .= $data['MD5'];
$md5s[$filename] = $data['MD5'];
}
}
if(file_put_contents($md5tmp, serialize(array($md5total, $md5s))) === false) {
dir_clear($tmpdir);
@unlink($md5tmp);
cloudaddons_faillog($_GET['rid'], 101);
cpmsg('cloudaddons_download_write_md5_error', '', 'error');
}
} elseif($array['Status'] == 'Error') {
dir_clear($tmpdir);
@unlink($md5tmp);
cloudaddons_faillog($_GET['rid'], $array['ErrorCode']);
cpmsg('cloudaddons_install_error', '', 'error', array('ErrorCode' => $array['ErrorCode']));
} else {
foreach($md5s as $file => $md5) {
if($md5 != md5_file($file)) {
dir_clear($tmpdir);
@unlink($md5tmp);
cloudaddons_faillog($_GET['rid'], 102);
cpmsg('cloudaddons_download_error', '', 'error', array('ErrorCode' => 102));
}
}
@unlink($md5tmp);
$end = rawurlencode(cloudaddons_http_build_query($array));
}
if(!$end) {
$packnum++;
cpmsg('cloudaddons_downloading', "action=cloudaddons&operation=download&addonids={$_GET['addonids']}&i=$addoni&step=1&md5hash=".$_GET['md5hash'].'&timestamp='.$_GET['timestamp'].'&num='.$packnum, 'loading', array('addonid' => $_GET['key'].'.'.$_GET['type']), '<div>'.$percent.'%</div>', FALSE);
} else {
if($md5total !== '' && md5($md5total) !== cloudaddons_md5($_GET['key'].'_'.$_GET['rid'].(!empty($array['MD5Key']) ? '_'.$array['MD5Key'] : ''))) {
dir_clear($tmpdir);
@unlink($md5tmp);
cloudaddons_faillog($_GET['rid'], 105);
cpmsg('cloudaddons_download_error', '', 'error', array('ErrorCode' => 105));
}
cpmsg('cloudaddons_installing', "action=cloudaddons&operation=download&addonids={$_GET['addonids']}&i=$addoni&end=$end&step=2&md5hash=".$_GET['md5hash'].'&timestamp='.$_GET['timestamp'], 'loading', array('addonid' => $_GET['key'].'.'.$_GET['type']), FALSE);
}
} elseif($step == 2) {
$tmpdir = DISCUZ_ROOT.'./data/download/'.$_GET['rid'];
if(!file_exists($tmpdir)) {
dir_clear($tmpdir);
cloudaddons_faillog($_GET['rid'], 103);
cpmsg('cloudaddons_download_error', '', 'error', array('ErrorCode' => 103));
}
$typedir = array(
'plugin' => 'source/plugin',
'template' => 'template',
'pack' => '.',
);
if(!$typedir[$_GET['type']]) {
dir_clear($tmpdir);
cloudaddons_faillog($_GET['rid'], 104);
cpmsg('cloudaddons_download_error', '', 'error', array('ErrorCode' => 104));
}
if($_GET['type'] != 'pack') {
$descdir = DISCUZ_ROOT.$typedir[$_GET['type']].'/';
$subdir = $_GET['key'];
} else {
$descdir = DISCUZ_ROOT;
$subdir = '';
}
$unwriteabledirs = cloudaddons_dirwriteable($descdir, $subdir, $tmpdir);
if($unwriteabledirs) {
if(!submitcheck('settingsubmit')) {
shownav('cloudaddons', 'cloudaddons_ftp_setting');
showsubmenu('cloudaddons_ftp_setting');
showtips(cplang('cloudaddons_unwriteabledirs', array('basedir' => $typedir[$_GET['type']] != '.' ? $typedir[$_GET['type']] : '/', 'unwriteabledirs' => implode(', ', $unwriteabledirs))));
siteftp_form("cloudaddons&operation=download&addonids={$_GET['addonids']}&i=$addoni&end=".rawurlencode($_GET['end'])."&step=2&md5hash=".$_GET['md5hash'].'&timestamp='.$_GET['timestamp']);
exit;
} else {
siteftp_check($_GET['siteftp'], $typedir[$_GET['type']]);
}
}
$descdir .= $subdir;
cloudaddons_comparetree($tmpdir, $descdir, $tmpdir, $_GET['key'].'.'.$_GET['type'], 1);
if(!empty($_G['treeop']['oldchange']) && empty($_GET['confirmed'])) {
cpmsg('cloudaddons_install_files_changed', '', 'form', array('files' => implode('<br />', $_G['treeop']['oldchange'])));
}
cloudaddons_copytree($tmpdir, $descdir);
cloudaddons_savemd5($_GET['key'].'.'.$_GET['type'], $_GET['end'], $_G['treeop']['md5']);
cloudaddons_deltree($tmpdir);
if(count($addonids) - 1 > $addoni) {
$addoni++;
cpmsg('cloudaddons_downloading', "action=cloudaddons&operation=download&addonids={$_GET['addonids']}&i=$addoni&step=1&md5hash=".$_GET['md5hash'].'&timestamp='.$_GET['timestamp'], 'loading', array('addonid' => $_GET['key'].'.'.$_GET['type']), FALSE);
}
$extra = currentlang();
$extra = $extra ? '_'.$extra : '';
$batch = array();
foreach ($addonids as $addonid) {
list($key, $type, $rid) = explode('.', $addonid);
cloudaddons_downloadlog($key.'.'.$type);
if(empty($batch[$key.'.'.$type][1])) {
if($type == 'plugin') {
$entrytitle = $importtxt = '';
$plugindir = DISCUZ_ROOT.'./source/plugin/'.$key;
if(file_exists($plugindir.'/discuz_plugin_'.$key.$extra.'.xml')) {
$importtxt = @implode('', file($plugindir.'/discuz_plugin_'.$key.$extra.'.xml'));
} elseif(file_exists($plugindir.'/discuz_plugin_'.$key.'.xml')) {
$importtxt = @implode('', file($plugindir.'/discuz_plugin_'.$key.'.xml'));
}
if(!empty($importtxt)) {
$pluginarray = getimportdata('Discuz! Plugin', 0, 1);
if(!empty($pluginarray['plugin']['name'])) {
$entrytitle = dhtmlspecialchars($pluginarray['plugin']['name'].' '.$pluginarray['plugin']['version']);
}
}
$plugin = C::t('common_plugin')->fetch_by_identifier($key);
if(!$plugin['pluginid']) {
$batch[$key.'.'.$type] = array(
ADMINSCRIPT.'?action=plugins&operation=import&dir='.$key,
$lang['plugins_config_install'].' '.$entrytitle,
);
} else {
if ($pluginarray['plugin']['version'] != $plugin['version']) {
$batch[$key.'.'.$type] = array(
ADMINSCRIPT.'?action=plugins&operation=upgrade&pluginid='.$plugin['pluginid'],
$lang['plugins_config_upgrade'].' '.$entrytitle,
);
}
}
} elseif($type == 'template') {
$pluginarray = array();
$entrytitle = $importtxt = '';
$templatedir = DISCUZ_ROOT.'./template/'.$key;
$searchdir = dir($templatedir);
while($searchentry = $searchdir->read()) {
if(substr($searchentry, 0, 13) == 'discuz_style_' && fileext($searchentry) == 'xml') {
$importtxt = @implode('', file($templatedir.'/'.$searchentry));
if(!empty($importtxt)) {
break;
}
}
}
if(!empty($importtxt)) {
$stylearray = getimportdata('Discuz! Style');
if(!empty($stylearray['tplname'])) {
$entrytitle = dhtmlspecialchars($stylearray['tplname']);
}
}
$batch[$key.'.'.$type] = array(
ADMINSCRIPT.'?action=styles&operation=import&dir='.$key,
$entrytitle,
);
} else {
cloudaddons_validator($key.'.pack');
cloudaddons_installlog($key.'.pack');
if(file_exists(DISCUZ_ROOT.'./data/addonpack/'.$key.'.php')) {
$batch[$key.'.'.$type] = array(
$_G['siteurl'].'data/addonpack/'.$key.'.php',
$key.'.'.$type,
);
}
}
}
}
if(count($batch) > 1) {
$message = '';
foreach ($batch as $k => $v) {
$message .= '<p class="margintop"><a href="'.$v[0].'&frames=yes" onclick="return removelink(this);" target="_blank">'.($v[1] ? $v[1] : $k).'</a></p>';
}
echo '<div class="infobox"><h4 class="infotitle2">'.cplang('cloudaddons_batch_succeed').'<br /><br /><div id="addonlist">'.$message.'</div></h4></div>
<script type="text/javascript">
function removelink(obj){
if(document.getElementById(\'addonlist\').children.length > 1){
obj.parentNode.remove();
}else{
obj.target = \'_top\';
}
return true;
}
</script>
';
exit;
} elseif(count($batch) == 1) {
$v = reset($batch);
dheader('location: '.$v[0]);
} else {
list($_GET['key'], $_GET['type'], $_GET['rid']) = explode('.', $addonids[0]);
if($_GET['type'] == 'plugin') {
dheader('location: '.ADMINSCRIPT.'?action=plugins&operation=upgrade&pluginid='.$plugin['pluginid']);
} else {
cpmsg('cloudaddons_pack_installed', '', 'succeed');
}
}
}
}
function dir_clear($dir) {
if($directory = @dir($dir)) {
while($entry = $directory->read()) {
if($entry == '.' || $entry == '..') {
continue;
}
$filename = $dir.'/'.$entry;
if(is_file($filename)) {
@unlink($filename);
} else {
dir_clear($filename);
}
}
$directory->close();
@rmdir($dir);
}
}
?>

View File

@@ -0,0 +1,260 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_collection.php 32581 2013-02-22 04:03:45Z chenmengshu $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = in_array($operation, array('admin', 'comment', 'recommend')) ? $operation : 'admin';
$current = array($operation => 1);
$fromumanage = $_GET['fromumanage'] ? 1 : 0;
shownav('global', 'collection');
showsubmenu('collection', array(
array('collection_admin', 'collection&operation=admin', $current['admin']),
array('collection_comment', 'collection&operation=comment', $current['comment']),
array('collection_recommend', 'collection&operation=recommend', $current['recommend'])
));
echo '<script src="' . STATICURL . 'js/calendar.js"></script>';
if($operation == 'comment') {
$tagarray = array();
if(submitcheck('submit') && !empty($_GET['cidarray']) && is_array($_GET['cidarray']) && count($_GET['cidarray']) && !empty($_GET['operate_type'])) {
$class_tag = new tag();
$cidarray = array();
$operate_type = $_GET['operate_type'];
$cidarray = $_GET['cidarray'];
if($operate_type == 'delete') {
require_once libfile('function/delete');
$cidlist = C::t('forum_collectioncomment')->fetch_all($cidarray);
C::t('forum_collectioncomment')->delete_by_cid_ctid($cidarray);
foreach($cidlist as $uniquecid) {
$decreasnum[$uniquecid['ctid']]++;
}
foreach($decreasnum as $ctid => $num) {
C::t('forum_collection')->update_by_ctid($ctid, 0, 0, -$num);
}
}
cpmsg('collection_admin_updated', 'action=collection&operation=comment&searchsubmit=yes&perpage='.$_GET['perpage'].'&page='.$_GET['page'], 'succeed');
}
if(!submitcheck('searchsubmit', 1)) {
showformheader('collection&operation=comment');
showtableheader();
showsetting('collection_ctid', 'comment_ctid', $comment_ctid, 'text');
showsetting('collection_comment_message', 'comment_message', $comment_message, 'text');
showsetting('collection_comment_cid', 'comment_cid', $comment_cid, 'text');
showsetting('collection_comment_username', 'comment_username', $comment_username, 'text');
showsetting('collection_comment_uid', 'comment_uid', $comment_uid, 'text');
showsetting('collection_comment_rate', 'comment_rate', $comment_rate, 'text');
showsetting('collection_comment_useip', 'comment_useip', $comment_useip, 'text');
if(!$fromumanage) {
empty($_GET['starttime']) && $_GET['starttime'] = date('Y-m-d', time() - 86400 * 30);
}
echo '<input type="hidden" name="fromumanage" value="'.$fromumanage.'">';
showsetting('threads_search_time', array('starttime', 'endtime'), array($_GET['starttime'], $_GET['endtime']), 'daterange');
showsetting('feed_search_perpage', '', $_GET['perpage'], "<select name='perpage'><option value='20'>{$lang['perpage_20']}</option><option value='50'>{$lang['perpage_50']}</option><option value='100'>{$lang['perpage_100']}</option></select>");
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
$comment_message = trim($_GET['comment_message']);
$comment_cid = dintval($_GET['comment_cid']);
$comment_ctid = dintval($_GET['comment_ctid']);
$comment_uid = dintval($_GET['comment_uid']);
$comment_username = trim($_GET['comment_username']);
$comment_useip = trim($_GET['comment_useip']);
$comment_rate = dintval($_GET['comment_rate']);
$starttime = $_GET['starttime'] ? strtotime($_GET['starttime']) : '';
$endtime = $_GET['endtime'] ? strtotime($_GET['endtime']) : '';
$ppp = $_GET['perpage'];
$startlimit = ($page - 1) * $ppp;
$multipage = '';
$totalcount = C::t('forum_collectioncomment')->fetch_all_for_search($comment_cid, $comment_ctid, $comment_username, $comment_uid, $comment_useip, $comment_rate, $comment_message, $starttime, $endtime, -1);
$multipage = multi($totalcount, $ppp, $page, ADMINSCRIPT."?action=collection&operation=comment&searchsubmit=yes&comment_message=$comment_message&comment_cid=$comment_cid&comment_username=$comment_username&comment_uid=$comment_uid&comment_ctid=$comment_ctid&comment_useip=$comment_useip&comment_rate=$comment_rate&starttime=$starttime&endtime=$endtime&perpage=$ppp");
$collectioncomment = C::t('forum_collectioncomment')->fetch_all_for_search($comment_cid, $comment_ctid, $comment_username, $comment_uid, $comment_useip, $comment_rate, $comment_message, $starttime, $endtime, $startlimit, $ppp);
showformheader('collection&operation=comment');
showtableheader(cplang('collection_comment_result').' '.$totalcount.' <a href="###" onclick="location.href=\''.ADMINSCRIPT.'?action=collection&operation=comment\';" class="act lightlink normal">'.cplang('research').'</a>', 'nobottom');
showhiddenfields(array('page' => $_GET['page'], 'tagname' => $tagname, 'status' => $status, 'perpage' => $ppp));
showsubtitle(array('', 'collection_comment_message', 'collection_comment_cid', 'collection_name', 'collection_comment_username', 'collection_comment_useip', 'collection_comment_ratenum', 'collection_date'));
foreach($collectioncomment as $uniquecomment) {
$ctidarray[$uniquecomment['ctid']] = 1;
}
$ctidarray = array_keys($ctidarray);
$collectiondata = C::t('forum_collection')->fetch_all($ctidarray);
foreach($collectioncomment as $uniquecomment) {
if($uniquecomment['rate'] == 0) $uniquecomment['rate'] = '-';
showtablerow('', array('class="td25"', 'width=400', ''), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"cidarray[]\" value=\"{$uniquecomment['cid']}\" />",
$uniquecomment['message'],
$uniquecomment['cid'],
"<a href='forum.php?mod=collection&action=view&ctid={$uniquecomment['ctid']}' target='_blank'>{$collectiondata[$uniquecomment['ctid']]['name']}</a>",
"<a href='home.php?mod=space&uid={$uniquecomment['uid']}' target='_blank'>{$uniquecomment['username']}</a>",
$uniquecomment['useip'],
$uniquecomment['rate'],
dgmdate($uniquecomment['dateline']),
));
}
showtablerow('', array('class="td25" colspan="3"'), array('<input name="chkall" id="chkall" type="checkbox" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'cidarray\', \'chkall\')" /><label for="chkall">'.cplang('select_all').'</label>'));
showtablerow('', array('class="td25"', 'colspan="2"'), array(
cplang('operation'),
'<input class="radio" type="radio" name="operate_type" value="delete"> '.cplang('delete').' '
));
showsubmit('submit', 'submit', '', '', $multipage);
showtablefooter();
showformfooter();
}
} elseif($operation == 'admin') {
$tagarray = array();
if(submitcheck('submit') && !empty($_GET['ctidarray']) && is_array($_GET['ctidarray']) && count($_GET['ctidarray']) && !empty($_GET['operate_type'])) {
$class_tag = new tag();
$ctidarray = array();
$operate_type = $_GET['operate_type'];
$ctidarray = $_GET['ctidarray'];
if($operate_type == 'delete') {
require_once libfile('function/delete');
foreach($ctidarray as $ctid) {
deletecollection($ctid);
}
}
cpmsg('collection_admin_updated', 'action=collection&operation=admin&searchsubmit=yes&perpage='.$_GET['perpage'].'&page='.$_GET['page'], 'succeed');
}
if(!submitcheck('searchsubmit', 1)) {
showformheader('collection&operation=admin');
showtableheader();
showsetting('collection_name', 'collection_name', $collection_name, 'text');
showsetting('collection_ctid', 'collection_ctid', $collection_ctid, 'text');
showsetting('collection_username', 'collection_username', $collection_username, 'text');
showsetting('collection_uid', 'collection_uid', $collection_uid, 'text');
showsetting('feed_search_perpage', '', $_GET['perpage'], "<select name='perpage'><option value='20'>{$lang['perpage_20']}</option><option value='50'>{$lang['perpage_50']}</option><option value='100'>{$lang['perpage_100']}</option></select>");
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
$collection_name = trim($_GET['collection_name']);
$collection_ctid = dintval($_GET['collection_ctid']);
$collection_username = trim($_GET['collection_username']);
$collection_uid = dintval($_GET['collection_uid']);
$ppp = $_GET['perpage'];
$startlimit = ($page - 1) * $ppp;
$multipage = '';
$totalcount = C::t('forum_collection')->fetch_all_for_search($collection_name, $collection_ctid, $collection_username, $collection_uid, -1);
$multipage = multi($totalcount, $ppp, $page, ADMINSCRIPT."?action=collection&operation=admin&searchsubmit=yes&collection_name=$collection_name&collection_ctid=$collection_ctid&collection_username=$collection_username&collection_uid=$collection_uid&perpage=$ppp&status=$status");
$collection = C::t('forum_collection')->fetch_all_for_search($collection_name, $collection_ctid, $collection_username, $collection_uid, $startlimit, $ppp);
showformheader('collection&operation=admin');
showtableheader(cplang('collection_result').' '.$totalcount.' <a href="###" onclick="location.href=\''.ADMINSCRIPT.'?action=collection&operation=admin\';" class="act lightlink normal">'.cplang('research').'</a>', 'nobottom');
showhiddenfields(array('page' => $_GET['page'], 'collection_name' => $collection_name, 'collection_ctid' => $collection_ctid, 'perpage' => $ppp));
showsubtitle(array('', 'collection_name', 'collection_username', 'collection_date', 'collection_recommend'));
foreach($collection as $uniquecollection) {
showtablerow('', array('class="td25"', 'width=400', ''), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"ctidarray[]\" value=\"{$uniquecollection['ctid']}\" />",
"<a href='forum.php?mod=collection&action=view&ctid={$uniquecollection['ctid']}' target='_blank'>{$uniquecollection['name']}</a>",
"<a href='home.php?mod=space&uid={$uniquecollection['uid']}' target='_blank'>{$uniquecollection['username']}</a>",
dgmdate($uniquecollection['dateline']),
"<a href='".ADMINSCRIPT."?action=collection&operation=recommend&recommentctid={$uniquecollection['ctid']}'>".cplang('collection_recommend')."</a>",
));
}
showtablerow('', array('class="td25" colspan="3"'), array('<input name="chkall" id="chkall" type="checkbox" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'ctidarray\', \'chkall\')" /><label for="chkall">'.cplang('select_all').'</label>'));
showtablerow('', array('class="td25"', 'colspan="2"'), array(
cplang('operation'),
'<input class="radio" type="radio" name="operate_type" value="delete"> '.cplang('delete').' '
));
showsubmit('submit', 'submit', '', '', $multipage);
showtablefooter();
showformfooter();
}
} elseif($operation == 'recommend') {
if(is_numeric($_GET['recommentctid'])) {
$collectiondata = C::t('forum_collection')->fetch($_GET['recommentctid']);
if($collectiondata['ctid']) {
$collectionrecommend = $_G['setting']['collectionrecommend'] ? dunserialize($_G['setting']['collectionrecommend']) : array();
$collectionrecommend['ctids'][$collectiondata['ctid']] = 0;
$collectionrecommend['ctids'] = removeNonExistsCollection($collectionrecommend['ctids']);
$collectionrecommend['adminrecommend'] = count($collectionrecommend['ctids']);
asort($collectionrecommend['ctids']);
$data = array('collectionrecommendnum' => $collectionrecommend['autorecommend']+$collectionrecommend['adminrecommend'], 'collectionrecommend' => $collectionrecommend);
C::t('common_setting')->update_batch($data);
updatecache('setting');
savecache('collection_index', array());
}
cpmsg('collection_admin_updated', 'action=collection&operation=recommend', 'succeed');
}
if(!submitcheck('submit', 1)) {
$ctidarray = array();
$collectionrecommend = dunserialize($_G['setting']['collectionrecommend']);
showformheader('collection&operation=recommend');
showtableheader(cplang('collection_recommend_settings'), 'nobottom');
showsetting('collection_recommend_index_autonumber', 'settingnew[autorecommend]', $collectionrecommend['autorecommend'] ? $collectionrecommend['autorecommend'] : 0, 'text');
showtableheader(cplang('collection_recommend_existed'), 'nobottom');
showhiddenfields(array('page' => $_GET['page'], 'tagname' => $tagname, 'status' => $status, 'perpage' => $ppp));
showsubtitle(array('', 'collection_name', 'collection_username', 'collection_threadnum', 'collection_commentnum', 'collection_date', 'display_order'));
if($collectionrecommend['ctids']) {
$collectiondata = C::t('forum_collection')->fetch_all(array_keys($collectionrecommend['ctids']));
foreach($collectiondata as $collection) {
showtablerow('', array('class="td25"', 'width=400', ''), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"ctidarray[]\" value=\"{$collection['ctid']}\" />",
"<a href='forum.php?mod=collection&action=view&ctid={$collection['ctid']}' target='_blank'>{$collection['name']}</a>",
"<a href='home.php?mod=space&uid={$collection['uid']}' target='_blank'>{$collection['username']}</a>",
$collection['threadnum'],
$collection['commentnum'],
dgmdate($collection['dateline']),
"<input class=\"txt\" type=\"text\" name=\"ctidorder[{$collection['ctid']}]\" value=\"{$collectionrecommend['ctids'][$collection['ctid']]}\" />",
));
}
} else {
showtablerow('', array('class="td25" colspan="7" align="center"', ''), array(
cplang('collection_recommend_tips'),
));
}
showtablerow('', array('class="td25" colspan="7"'), array('<input name="chkall" id="chkall" type="checkbox" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'ctidarray\', \'chkall\')" /><label for="chkall"> '.cplang('select_all').'</label>'));
showtablerow('', array('class="td25"', 'colspan="2"'), array(
cplang('operation'),
'<input class="checkbox" type="checkbox" name="operate_type" id="operate_type" value="delete"><label for="operate_type"> '.cplang('delete').'</label> '
));
showsubmit('submit', 'submit', '', '');
showtablefooter();
showformfooter();
} else {
$collectionrecommend = $_G['setting']['collectionrecommend'] ? dunserialize($_G['setting']['collectionrecommend']) : array();
foreach($collectionrecommend['ctids'] as $rCtid=>&$rCollection) {
if($_GET['operate_type'] == 'delete' && in_array($rCtid, $_GET['ctidarray'])) {
unset($collectionrecommend['ctids'][$rCtid]);
continue;
}
$rCollection = $_GET['ctidorder'][$rCtid];
}
$collectionrecommend['ctids'] = is_array($collectionrecommend['ctids']) ? removeNonExistsCollection($collectionrecommend['ctids']) : array();
$collectionrecommend['autorecommend'] = intval($_GET['settingnew']['autorecommend']);
$collectionrecommend['adminrecommend'] = count($collectionrecommend['ctids']);
asort($collectionrecommend['ctids']);
$data = array('collectionrecommendnum' => $collectionrecommend['autorecommend']+$collectionrecommend['adminrecommend'], 'collectionrecommend' => $collectionrecommend);
C::t('common_setting')->update_batch($data);
updatecache('setting');
savecache('collection_index', array());
cpmsg('collection_admin_updated', 'action=collection&operation=recommend', 'succeed');
}
}
function removeNonExistsCollection($collectionrecommend) {
$tmpcollection = C::t('forum_collection')->fetch_all(array_keys($collectionrecommend));
foreach($collectionrecommend as $ctid=>$setcollection) {
if(!$tmpcollection[$ctid]) {
unset($collectionrecommend[$ctid]);
}
}
return $collectionrecommend;
}
?>

View File

@@ -0,0 +1,378 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_comment.php 28774 2012-03-12 10:09:50Z chenmengshu $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$detail = $_GET['detail'];
$idtype = $_GET['idtype'];
$id = $_GET['id'];
$author = $_GET['author'];
$authorid = $_GET['authorid'];
$uid = $_GET['uid'];
$message = $_GET['message'];
$ip = $_GET['ip'];
$users = $_GET['users'];
$starttime = $_GET['starttime'];
$endtime = $_GET['endtime'];
$searchsubmit = $_GET['searchsubmit'];
$cids = $_GET['cids'];
$page = max(1, $_GET['page']);
$fromumanage = $_GET['fromumanage'] ? 1 : 0;
cpheader();
if(empty($operation)) {
if(!submitcheck('commentsubmit')) {
if($fromumanage) {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? '' : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? '' : $endtime;
} else {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? dgmdate(TIMESTAMP - 86400 * 7, 'Y-n-j') : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? dgmdate(TIMESTAMP, 'Y-n-j') : $endtime;
}
shownav('topic', 'nav_comment');
showsubmenu('nav_comment', array(
array('comment_comment', 'comment', 1),
array('comment_article_comment', 'comment&operation=article', 0),
array('comment_topic_comment', 'comment&operation=topic', 0)
));
showtips('comment_tips');
$staticurl = STATICURL;
echo <<<EOT
<script type="text/javascript" src="{$staticurl}js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('commentforum').page.value=number;
$('commentforum').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'searchposts', !$searchsubmit);
showformheader("comment", '', 'commentforum');
showhiddenfields(array('page' => $page, 'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']));
showtableheader();
showsetting('comment_search_detail', 'detail', $detail, 'radio');
showsetting('comment_search_perpage', '', $_GET['perpage'], "<select name='perpage'><option value='20'>{$lang['perpage_20']}</option><option value='50'>{$lang['perpage_50']}</option><option value='100'>{$lang['perpage_100']}</option></select>");
showsetting('comment_idtype', array('idtype', array(
array('', $lang['all']),
array('uid', $lang['comment_uid']),
array('blogid', $lang['comment_blogid']),
array('picid', $lang['comment_picid']),
array('sid', $lang['comment_sid']),
)), 'comment_idtype', 'select');
showsetting('comment_search_id', 'id', $id, 'text');
showsetting('comment_search_author', 'author', $author, 'text');
showsetting('comment_search_authorid', 'authorid', $authorid, 'text');
showsetting('comment_search_uid', 'uid', $uid, 'text');
showsetting('comment_search_message', 'message', $message, 'text');
showsetting('comment_search_ip', 'ip', $ip, 'text');
showsetting('comment_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
echo '<input type="hidden" name="fromumanage" value="'.$fromumanage.'">';
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
$cids = authcode($cids, 'DECODE');
$cidsadd = $cids ? explode(',', $cids) : $_GET['delete'];
include_once libfile('function/delete');
$deletecount = count(deletecomments($cidsadd));
$cpmsg = cplang('comment_succeed', array('deletecount' => $deletecount));
?>
<script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('commentforum').searchsubmit.click();</script>
<?php
}
if(submitcheck('searchsubmit', 1)) {
$comments = $commentcount = '0';
$sql = $error = '';
$authorids = array();
$author = trim($author);
if($id !='') {
$id = explode(',', $id);
}
if($author != '') {
$authorids = C::t('common_member')->fetch_all_uid_by_username(array_map('trim', explode(',', $author)));
if (!$authorids) {
$authorids = array(-1);
}
}
$authorid = trim($authorid, ', ');
if($authorid != '') {
if (!$authorids) {
$authorids = explode(',', $authorid);
} else {
$authorids = array_intersect($authorids, explode(',', $authorid));
}
if (!$authorids) {
$authorids = array(-1);
}
}
if($_G['adminid'] == 1 && $endtime != dgmdate(TIMESTAMP, 'Y-n-j')) {
if($endtime != '') {
$endtime = strtotime($endtime);
}
} else {
$endtime = TIMESTAMP;
}
if(($_G['adminid'] == 2 && $endtime - $starttime > 86400 * 16) || ($_G['adminid'] == 3 && $endtime - $starttime > 86400 * 8)) {
$error = 'comment_mod_range_illegal';
}
$uid = trim($uid, ', ');
if($uid !='') {
$uid = explode(',', $uid);
}
if(!$error) {
if($commentcount = C::t('home_comment')->fetch_all_search(3, $id, $authorids, $uid, $ip, $message, $idtype, $starttime, $endtime)) {
if($detail) {
$_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
$perpage = $_GET['pp'] ? $_GET['pp'] : $_GET['perpage'];
$query = C::t('home_comment')->fetch_all_search(1, $id, $authorids, $uid, $ip, $message, $idtype, $starttime, $endtime, (($page - 1) * $perpage), $perpage);
$comments = '';
foreach ($query as $comment) {
$comment['dateline'] = dgmdate($comment['dateline']);
switch($comment['idtype']) {
case 'picid':
$address = "<a href=\"home.php?mod=space&uid={$comment['uid']}&do=album&picid={$comment['id']}\" target=\"_blank\">{$comment['message']}</a>";
break;
case 'uid':
$address = "<a href=\"home.php?mod=space&uid={$comment['uid']}&do=wall\" target=\"_blank\">{$comment['message']}</a>";
break;
case 'sid':
$address = "<a href=\"home.php?mod=space&uid=1&do=share&id={$comment['id']}\" target=\"_blank\">{$comment['message']}</a>";
break;
case 'blogid':
$address = "<a href=\"home.php?mod=space&uid={$comment['uid']}&do=blog&id={$comment['id']}\" target=\"_blank\">{$comment['message']}</a>";
break;
}
$comments .= showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"{$comment['cid']}\" />",
$address,
"<a href=\"home.php?mod=space&uid={$comment['uid']}\" target=\"_blank\">{$comment['author']}</a>",
$comment['ip'],
$comment['idtype'],
$comment['dateline']
), TRUE);
}
$multi = multi($commentcount, $perpage, $page, ADMINSCRIPT."?action=comment");
$multi = preg_replace("/href=\"".ADMINSCRIPT."\?action=comment&amp;page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
$multi = str_replace("window.location='".ADMINSCRIPT."?action=comment&amp;page='+this.value", "page(this.value)", $multi);
} else {
$query = C::t('home_comment')->fetch_all_search(2, $id, $authorids, $uid, $ip, $message, $idtype, $starttime, $endtime);
foreach ($query as $comment) {
$cids .= ','.$comment['cid'];
}
}
} else
$error = 'comment_post_nonexistence';
}
showtagheader('div', 'postlist', $searchsubmit);
showformheader('comment&frame=no', 'target="commentframe"');
showhiddenfields(array('cids' => authcode($cids, 'ENCODE')));
showtableheader(cplang('comment_result').' '.$commentcount.' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';$(\'commentforum\').pp.value=\'\';$(\'commentforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>', 'fixpadding');
if($error) {
echo "<tr><td class=\"lineheight\" colspan=\"15\">$lang[$error]</td></tr>";
} else {
if($detail) {
showsubtitle(array('', 'message', 'author', 'ip', 'comment_idtype', 'time'));
echo $comments;
}
}
showsubmit('commentsubmit', 'delete', $detail ? 'del' : '', '', $multi);
showtablefooter();
showformfooter();
echo '<iframe name="commentframe" style="display:none"></iframe>';
showtagfooter('div');
}
}
if($operation == 'article' || $operation == 'topic') {
$aid = $_GET['aid'];
$subject = $_GET['subject'];
$idtype = $operation == 'article' ? 'aid' : 'topicid';
$tablename = $idtype == 'aid' ? 'portal_article_title' : 'portal_topic';
if(!submitcheck('articlesubmit')) {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? dgmdate(TIMESTAMP - 86400 * 7, 'Y-n-j') : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? dgmdate(TIMESTAMP, 'Y-n-j') : $endtime;
shownav('topic', 'nav_comment');
showsubmenu('nav_comment', array(
array('comment_comment', 'comment', 0),
array('comment_article_comment', 'comment&operation=article', $operation == 'article' ? 1 : 0),
array('comment_topic_comment', 'comment&operation=topic', $operation == 'topic' ? 1 : 0)
));
showtips('comment_'.$operation.'_tips');
$staticurl = STATICURL;
echo <<<EOT
<script type="text/javascript" src="{$staticurl}js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('articleforum').page.value=number;
$('articleforum').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'searchposts', !$searchsubmit);
showformheader("comment&operation=$operation", '', 'articleforum');
showhiddenfields(array('page' => $page, 'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']));
showtableheader();
showsetting('comment_search_perpage', '', $_GET['perpage'], "<select name='perpage'><option value='20'>{$lang['perpage_20']}</option><option value='50'>{$lang['perpage_50']}</option><option value='100'>{$lang['perpage_100']}</option></select>");
showsetting("comment_{$operation}_subject", 'subject', $subject, 'text');
showsetting("comment_{$operation}_id", 'aid', $aid, 'text');
showsetting('comment_search_message', 'message', $message, 'text');
showsetting('comment_search_author', 'author', $author, 'text');
showsetting('comment_search_authorid', 'authorid', $authorid, 'text');
showsetting('comment_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
$commentnum = array();
foreach(C::t('portal_comment')->fetch_all($_GET['delete']) as $value) {
$commentnum[$value['idtype']][$value['id']] = $value['id'];
}
if($commentnum['aid']) {
C::t('portal_article_count')->increase($commentnum['aid'], array('commentnum' => -1));
} elseif($commentnum['topicid']) {
C::t('portal_topic')->increase($commentnum['topicid'], array('commentnum' => -1));
}
C::t('portal_comment')->delete($_GET['delete']);
$cpmsg = cplang('comment_article_delete');
?>
<script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('articleforum').searchsubmit.click();</script>
<?php
}
if(submitcheck('searchsubmit')) {
$comments = $commentcount = '0';
$sql = $error = '';
$author = trim($author);
$queryAId = $aid ? array($aid) : array();
if($subject != '') {
$ids = array();
$query = C::t($tablename)->fetch_all_by_title($idtype, $subject);
foreach($query as $value) {
$ids[] = intval($value[$idtype]);
}
$queryAId = array_merge($queryAId, $ids);
}
$queryAuthorIDs = $authorid ? array($authorid) : array();
if($author != '') {
$authorids = C::t('common_member')->fetch_all_uid_by_username(array_map('trim', explode(',', $author)));
$queryAuthorIDs = array_merge($queryAuthorIDs, $authorids);
}
if($starttime != '0') {
$starttime = strtotime($starttime);
}
$sqlendtime = '';
if($_G['adminid'] == 1 && $endtime != dgmdate(TIMESTAMP, 'Y-n-j')) {
if($endtime != '0') {
$sqlendtime = $endtime = strtotime($endtime);
}
} else {
$endtime = TIMESTAMP;
}
if(($_G['adminid'] == 2 && $endtime - $starttime > 86400 * 16) || ($_G['adminid'] == 3 && $endtime - $starttime > 86400 * 8)) {
$error = 'comment_mod_range_illegal';
}
if(!$error) {
$commentcount = C::t('portal_comment')->count_all_by_search($queryAId, $queryAuthorIDs, $starttime, $sqlendtime, $idtype, $message);
if($commentcount) {
$_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
$perpage = $_GET['pp'] ? $_GET['pp'] : $_GET['perpage'];
$query = C::t('portal_comment')->fetch_all_by_search($queryAId, $queryAuthorIDs, $starttime, $sqlendtime, $idtype, $message, (($page - 1) * $perpage), $perpage);
$comments = '';
$mod = $idtype == 'aid' ? 'view' : 'topic';
foreach($query as $comment) {
$comment['dateline'] = dgmdate($comment['dateline']);
$comments .= showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"{$comment['cid']}\" />",
"<a href=\"portal.php?mod=$mod&$idtype={$comment['id']}\" target=\"_blank\">{$comment['title']}</a>",
$comment['message'],
"<a href=\"home.php?mod=space&uid={$comment['uid']}\" target=\"_blank\">{$comment['username']}</a>",
$comment['dateline']
), TRUE);
}
$multi = multi($commentcount, $perpage, $page, ADMINSCRIPT."?action=comment&operation=$operation");
$multi = preg_replace("/href=\"".ADMINSCRIPT."\?action=comment&operation=$operation&amp;page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
$multi = str_replace("window.location='".ADMINSCRIPT."?action=comment&amp;operation=$operation&amp;page='+this.value", "page(this.value)", $multi);
} else {
$error = 'comment_post_nonexistence';
}
}
showtagheader('div', 'postlist', $searchsubmit);
showformheader('comment&operation='.$operation.'&frame=no', 'target="articleframe"');
showtableheader(cplang('comment_result').' '.$commentcount.' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';$(\'articleforum\').pp.value=\'\';$(\'articleforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>', 'fixpadding');
if($error) {
echo "<tr><td class=\"lineheight\" colspan=\"15\">$lang[$error]</td></tr>";
} else {
showsubtitle(array('', 'article_title', 'message', 'author', 'time'));
echo $comments;
}
showsubmit('articlesubmit', 'delete', 'del', '', $multi);
showtablefooter();
showformfooter();
echo '<iframe name="articleframe" style="display:none"></iframe>';
showtagfooter('div');
}
}
?>

View File

@@ -0,0 +1,529 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_counter.php 33048 2013-04-12 08:50:27Z zhangjie $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$pertask = isset($_GET['pertask']) ? intval($_GET['pertask']) : 100;
$current = isset($_GET['current']) && $_GET['current'] > 0 ? intval($_GET['current']) : 0;
$next = $current + $pertask;
if(submitcheck('forumsubmit', 1)) {
$nextlink = "action=counter&current=$next&pertask=$pertask&forumsubmit=yes";
$processed = 0;
$queryf = C::t('forum_forum')->fetch_all_fids(1, '', '', $current, $pertask);
foreach($queryf as $forum) {
$processed = 1;
$threads = $posts = 0;
$threadtables = array('0');
$archive = 0;
foreach(C::t('forum_forum_threadtable')->fetch_all_by_fid($forum['fid']) as $data) {
if($data['threadtableid']) {
$threadtables[] = $data['threadtableid'];
}
}
$threadtables = array_unique($threadtables);
foreach($threadtables as $tableid) {
$data = C::t('forum_thread')->count_posts_by_fid($forum['fid'], $tableid);
$threads += $data['threads'];
$posts += $data['posts'];
if($data['threads'] == 0 && $tableid != 0) {
C::t('forum_forum_threadtable')->delete_threadtable($forum['fid'], $tableid);
}
if($data['threads'] > 0 && $tableid != 0) {
$archive = 1;
}
}
C::t('forum_forum')->update($forum['fid'], array('archive' => $archive));
$thread = C::t('forum_thread')->fetch_by_fid_displayorder($forum['fid']);
$subject = cutstr($thread['subject'], 80);
$lastpost = "{$thread['tid']}\t{$subject}\t{$thread['lastpost']}\t{$thread['lastposter']}";
C::t('forum_forum')->update($forum['fid'], array('threads' => $threads, 'posts' => $posts, 'lastpost' => $lastpost));
}
if($processed) {
cpmsg("{$lang['counter_forum']}: ".cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
C::t('forum_forum')->clear_forum_counter_for_group();
cpmsg('counter_forum_succeed', 'action=counter', 'succeed');
}
} elseif(submitcheck('digestsubmit', 1)) {
if(!$current) {
C::t('common_member_count')->clear_digestposts();
$current = 0;
}
$nextlink = "action=counter&current=$next&pertask=$pertask&digestsubmit=yes";
$processed = 0;
$membersarray = $postsarray = array();
foreach(C::t('forum_thread')->fetch_all_by_digest_displayorder(0, '<>', 0, '>=', $current, $pertask) as $thread) {
$processed = 1;
$membersarray[$thread['authorid']]++;
}
$threadtableids = C::t('common_setting')->fetch_setting('threadtableids', true);
foreach($threadtableids as $tableid) {
if(!$tableid) {
continue;
}
foreach(C::t('forum_thread')->fetch_all_by_digest_displayorder(0, '<>', 0, '>=', $current, $pertask, $tableid) as $thread) {
$processed = 1;
$membersarray[$thread['authorid']] ++;
}
}
foreach($membersarray as $uid => $posts) {
$postsarray[$posts][] = $uid;
}
unset($membersarray);
foreach($postsarray as $posts => $uids) {
C::t('common_member_count')->increase($uids, array('digestposts' => $posts));
}
if($processed) {
cpmsg("{$lang['counter_digest']}: ".cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
cpmsg('counter_digest_succeed', 'action=counter', 'succeed');
}
} elseif(submitcheck('membersubmit', 1)) {
$nextlink = "action=counter&current=$next&pertask=$pertask&membersubmit=yes";
$processed = 0;
$threadtableids = C::t('common_setting')->fetch_setting('threadtableids', true);
$queryt = C::t('common_member')->range($current, $pertask);
foreach($queryt as $mem) {
$processed = 1;
$postcount = 0;
loadcache('posttable_info');
if(!empty($_G['cache']['posttable_info']) && is_array($_G['cache']['posttable_info'])) {
foreach($_G['cache']['posttable_info'] as $key => $value) {
$postcount += C::t('forum_post')->count_by_authorid($key, $mem['uid']);
}
} else {
$postcount += C::t('forum_post')->count_by_authorid(0, $mem['uid']);
}
$postcount += C::t('forum_postcomment')->count_by_authorid($mem['uid']);
$threadcount = C::t('forum_thread')->count_by_authorid($mem['uid']);
foreach($threadtableids as $tableid) {
if(!$tableid) {
continue;
}
$threadcount += C::t('forum_thread')->count_by_authorid($mem['uid'], $tableid);
}
C::t('common_member_count')->update($mem['uid'], array('posts' => $postcount, 'threads' => $threadcount));
}
if($processed) {
cpmsg("{$lang['counter_member']}: ".cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
cpmsg('counter_member_succeed', 'action=counter', 'succeed');
}
} elseif(submitcheck('threadsubmit', 1)) {
$nextlink = "action=counter&current=$next&pertask=$pertask&threadsubmit=yes";
$processed = 0;
foreach(C::t('forum_thread')->fetch_all_by_displayorder(0, '>=', $current, $pertask) as $threads) {
$processed = 1;
$replynum = C::t('forum_post')->count_visiblepost_by_tid($threads['tid']);
$replynum--;
$lastpost = C::t('forum_post')->fetch_visiblepost_by_tid('tid:'.$threads['tid'], $threads['tid'], 0, 1);
if($threads['replies'] != $replynum || $threads['lastpost'] != $lastpost['dateline'] || $threads['lastposter'] != $lastpost['author']) {
if(empty($threads['author'])) {
$lastpost['author'] = '';
}
$updatedata = array(
'replies' => $replynum,
'lastpost' => $lastpost['dateline'],
'lastposter' => $lastpost['author']
);
C::t('forum_thread')->update($threads['tid'], $updatedata, true, true);
}
}
if($processed) {
cpmsg("{$lang['counter_thread']}: ".cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
cpmsg('counter_thread_succeed', 'action=counter', 'succeed');
}
} elseif(submitcheck('movedthreadsubmit', 1)) {
$nextlink = "action=counter&current=$next&pertask=$pertask&movedthreadsubmit=yes";
$processed = 0;
$tids = array();
$updateclosed = array();
foreach(C::t('forum_thread')->fetch_all_movedthread($current, $pertask) as $thread) {
$processed = 1;
if($thread['isgroup'] && $thread['status'] == 3) {
$updateclosed[] = $thread['tid'];
} elseif($thread['threadexists']) {
$tids[] = $thread['tid'];
}
}
if($tids) {
C::t('forum_thread')->delete_by_tid($tids, true);
}
if($updateclosed) {
C::t('forum_thread')->update($updateclosed, array('closed' => ''));
}
if($processed) {
cpmsg(cplang('counter_moved_thread').': '.cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
cpmsg('counter_moved_thread_succeed', 'action=counter', 'succeed');
}
} elseif(submitcheck('specialarrange', 1)) {
$cursort = empty($_GET['cursort']) ? 0 : intval($_GET['cursort']);
$changesort = isset($_GET['changesort']) && empty($_GET['changesort']) ? 0 : 1;
$processed = 0;
$fieldtypes = array('number' => 'bigint(20)', 'text' => 'mediumtext', 'radio' => 'smallint(6)', 'checkbox' => 'mediumtext', 'textarea' => 'mediumtext', 'select' => 'smallint(6)', 'calendar' => 'mediumtext', 'email' => 'mediumtext', 'url' => 'mediumtext', 'image' => 'mediumtext');
$optionvalues = array();
$optionvalues = $sortids = array();
foreach(C::t('forum_typevar')->fetch_all_by_search_optiontype(1, array('checkbox', 'radio', 'select', 'number')) as $row) {
$optionvalues[$row['sortid']][$row['identifier']] = $row['type'];
$optionids[$row['sortid']][$row['optionid']] = $row['identifier'];
$searchs[$row['sortid']][$row['optionid']] = $row['search'];
$sortids[] = $row['sortid'];
}
$sortids = array_unique($sortids);
sort($sortids);
if($sortids[$cursort] && $optionvalues[$sortids[$cursort]]) {
$processed = 1;
$sortid = $sortids[$cursort];
$options = $optionvalues[$sortid];
$search = $searchs[$sortid];
$dbcharset = $_G['config']['db'][1]['dbcharset'];
$dbcharset = empty($dbcharset) ? str_replace('-', '', CHARSET) : $dbcharset;
$fields = "tid mediumint(8) UNSIGNED NOT NULL DEFAULT '0',fid smallint(6) UNSIGNED NOT NULL DEFAULT '0',KEY (fid)";
C::t('forum_optionvalue')->create($sortid, $fields, $dbcharset);
if($changesort) {
C::t('forum_optionvalue')->truncate_by_sortid($sortid);
}
$opids = array_keys($optionids[$sortid]);
$tables = C::t('forum_optionvalue')->showcolumns($sortid);
foreach($optionids[$sortid] as $optionid => $identifier) {
if(!$tables[$identifier] && (in_array($options[$identifier], array('checkbox', 'radio', 'select', 'number')) || $search[$optionid])) {
$fieldname = $identifier;
if(in_array($options[$identifier], array('radio'))) {
$fieldtype = 'smallint(6) UNSIGNED NOT NULL DEFAULT \'0\'';
} elseif(in_array($options[$identifier], array('number', 'range'))) {
$fieldtype = 'int(10) UNSIGNED NOT NULL DEFAULT \'0\'';
} elseif($options[$identifier] == 'select') {
$fieldtype = 'varchar(50) NOT NULL';
} else {
$fieldtype = 'mediumtext NOT NULL';
}
C::t('forum_optionvalue')->alter($sortid, "ADD $fieldname $fieldtype");
if(in_array($options[$identifier], array('radio', 'select', 'number'))) {
C::t('forum_optionvalue')->alter($sortid, "ADD INDEX ($fieldname)");
}
}
}
$inserts = array();
$typeoptionvararr = C::t('forum_typeoptionvar')->fetch_all_by_search($sortid, null, null, $opids);
if($typeoptionvararr) {
$tids = array();
foreach($typeoptionvararr as $value) {
$tids[$value['tid']] = $value['tid'];
}
$tids = C::t('forum_thread')->fetch_all($tids);
foreach($typeoptionvararr as $row) {
$row['fid'] = $tids[$row['tid']]['fid'];
$opname = $optionids[$sortid][$row['optionid']];
if(empty($inserts[$row['tid']])) {
$inserts[$row['tid']]['tid'] = $row['tid'];
$inserts[$row['tid']]['fid'] = $row['fid'];
}
$inserts[$row['tid']][$opname] = addslashes($row['value']);
}
unset($tids, $typeoptionvararr);
}
if($inserts) {
foreach($inserts as $tid => $fieldval) {
$rfields = array();
$ikey = $ival = '';
foreach($fieldval as $ikey => $ival) {
$rfields[] = "`$ikey`='$ival'";
}
C::t('forum_optionvalue')->insert_optionvalue($sortid, "SET ".implode(',', $rfields), true);
}
}
$cursort ++;
$changesort = 1;
}
$nextlink = "action=counter&changesort=$changesort&cursort=$cursort&specialarrange=yes";
if($processed) {
cpmsg('counter_special_arrange', $nextlink, 'loading', array('cursort' => $cursort, 'sortids' => count($sortids)));
} else {
cpmsg('counter_special_arrange_succeed', 'action=counter', 'succeed');
}
$nextlink = "action=counter&current=$next&pertask=$pertask&membersubmit=yes";
$processed = 0;
$queryt = C::t('common_member')->range($current, $pertask);
foreach($queryt as $mem) {
$processed = 1;
$postcount = 0;
loadcache('posttable_info');
if(!empty($_G['cache']['posttable_info']) && is_array($_G['cache']['posttable_info'])) {
foreach($_G['cache']['posttable_info'] as $key => $value) {
$postcount += C::t('forum_post')->count_by_authorid($key, $mem['uid']);
}
} else {
$postcount += C::t('forum_post')->count_by_authorid(0, $mem['uid']);
}
$postcount += C::t('forum_postcomment')->count_by_authorid($mem['uid']);
$threadcount = C::t('forum_thread')->count_by_authorid($mem['uid']);
C::t('common_member_count')->update($mem['uid'], array('posts' => $postcount, 'threads' => $threadcount));
}
if($processed) {
cpmsg("{$lang['counter_member']}: ".cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
cpmsg('counter_member_succeed', 'action=counter', 'succeed');
}
} elseif(submitcheck('groupmembernum', 1)) {
$nextlink = "action=counter&current=$next&pertask=$pertask&groupmembernum=yes";
$processed = 0;
$query = C::t('forum_forum')->fetch_all_fid_for_group($current, $pertask, 1);
foreach($query as $group) {
$processed = 1;
$membernum = C::t('forum_groupuser')->fetch_count_by_fid($group['fid']);
C::t('forum_forumfield')->update($group['fid'], array('membernum' => $membernum));
}
if($processed) {
cpmsg("{$lang['counter_groupmember_num']}: ".cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
cpmsg('counter_groupmember_num_succeed', 'action=counter', 'succeed');
}
} elseif(submitcheck('groupmemberpost', 1)) {
$nextlink = "action=counter&current=$next&pertask=$pertask&groupmemberpost=yes";
$processed = 0;
$queryf = C::t('forum_forum')->fetch_all_fid_for_group($current, $pertask, 1);
foreach($queryf as $group) {
$processed = 1;
$mreplies_array = array();
loadcache('posttableids');
$posttables = empty($_G['cache']['posttableids']) ? array(0) : $_G['cache']['posttableids'];
foreach($posttables as $posttableid) {
$mreplieslist = C::t('forum_post')->count_group_authorid_by_fid($posttableid, $group['fid']);
if($mreplieslist) {
foreach($mreplieslist as $mreplies) {
$mreplies_array[$mreplies['authorid']] = $mreplies_array[$mreplies['authorid']] + $mreplies['num'];
}
}
}
unset($mreplieslist);
foreach($mreplies_array as $authorid => $num) {
C::t('forum_groupuser')->update_for_user($authorid, $group['fid'], null, $num);
}
foreach(C::t('forum_thread')->count_group_thread_by_fid($group['fid']) as $mthreads) {
C::t('forum_groupuser')->update_for_user($mthreads['authorid'], $group['fid'], $mthreads['num']);
}
}
if($processed) {
cpmsg("{$lang['counter_groupmember_post']}: ".cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
cpmsg('counter_groupmember_post_succeed', 'action=counter', 'succeed');
}
} elseif(submitcheck('groupnum', 1)) {
$nextlink = "action=counter&current=$next&pertask=$pertask&groupnum=yes";
$processed = 0;
$queryf = C::t('forum_forum')->fetch_all_fid_for_group($current, $pertask);
foreach($queryf as $group) {
$processed = 1;
$groupnum = C::t('forum_forum')->fetch_groupnum_by_fup($group['fid']);
C::t('forum_forumfield')->update($group['fid'], array('groupnum' => intval($groupnum)));
}
if($processed) {
cpmsg("{$lang['counter_groupnum']}: ".cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
updatecache('grouptype');
cpmsg('counter_groupnum_succeed', 'action=counter', 'succeed');
}
} elseif(submitcheck('blogreplynum', 1)) {
$nextlink = "action=counter&current=$next&pertask=$pertask&blogreplynum=yes";
if(blog_replynum_stat($current, $pertask)) {
cpmsg("{$lang['counter_blog_replynum']}: ".cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
cpmsg('counter_blog_replynum_succeed', 'action=counter', 'succeed');
}
} elseif(submitcheck('friendnum', 1)) {
$nextlink = "action=counter&current=$next&pertask=$pertask&friendnum=yes";
if(space_friendnum_stat($current, $pertask)) {
cpmsg("{$lang['counter_friendnum']}: ".cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
cpmsg('counter_friendnum_succeed', 'action=counter', 'succeed');
}
} elseif(submitcheck('albumpicnum', 1)) {
$nextlink = "action=counter&current=$next&pertask=$pertask&albumpicnum=yes";
if(album_picnum_stat($current, $pertask)) {
cpmsg("{$lang['counter_album_picnum']}: ".cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
cpmsg('counter_album_picnum_succeed', 'action=counter', 'succeed');
}
} elseif(submitcheck('setthreadcover', 1)) {
$fid = intval($_GET['fid']);
$allthread = intval($_GET['allthread']);
if(empty($fid)) {
cpmsg('counter_thread_cover_fiderror', 'action=counter', 'error');
}
$nextlink = "action=counter&current=$next&pertask=$pertask&setthreadcover=yes&fid=$fid&allthread=$allthread";
$starttime = strtotime($_GET['starttime']);
$endtime = strtotime($_GET['endtime']);
$timesql = '';
if($starttime) {
$timesql .= " AND lastpost > $starttime";
$nextlink .= '&starttime='.$_GET['starttime'];
}
if($endtime) {
$timesql .= " AND lastpost < $endtime";
$nextlink .= '&endtime='.$_GET['endtime'];
}
$processed = 0;
$foruminfo = C::t('forum_forum')->fetch_info_by_fid($fid);
if(empty($foruminfo['picstyle'])) {
cpmsg('counter_thread_cover_fidnopicstyle', 'action=counter', 'error');
}
if($_G['setting']['forumpicstyle']) {
$_G['setting']['forumpicstyle'] = dunserialize($_G['setting']['forumpicstyle']);
empty($_G['setting']['forumpicstyle']['thumbwidth']) && $_G['setting']['forumpicstyle']['thumbwidth'] = 203;
empty($_G['setting']['forumpicstyle']['thumbheight']) && $_G['setting']['forumpicstyle']['thumbheight'] = 0;
} else {
$_G['setting']['forumpicstyle'] = array('thumbwidth' => 203, 'thumbheight' => 0);
}
require_once libfile('function/post');
$coversql = empty($allthread) ? 'AND cover=\'0\'' : '';
$cover = empty($allthread) ? 0 : null;
$_G['forum']['ismoderator'] = 1;
foreach(C::t('forum_thread')->fetch_all_by_fid_cover_lastpost($fid, $cover, $starttime, $endtime, $current, $pertask) as $thread) {
$processed = 1;
$pid = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid'], 0);
$pid = $pid['pid'];
setthreadcover($pid);
}
if($processed) {
cpmsg("{$lang['counter_thread_cover']}: ".cplang('counter_processing', array('current' => $current, 'next' => $next)), $nextlink, 'loading');
} else {
cpmsg('counter_thread_cover_succeed', 'action=counter', 'succeed');
}
} else {
shownav('tools', 'nav_updatecounters');
showsubmenu('nav_updatecounters');
showtips('counter_tips');
showformheader('counter');
showtableheader();
showsubtitle(array('', 'counter_amount'));
showhiddenfields(array('pertask' => ''));
showtablerow('', array('class="td31 bold"'), array(
"{$lang['counter_forum']}:",
'<input name="pertask1" type="text" class="txt" value="15" /><input type="submit" class="btn" name="forumsubmit" onclick="this.form.pertask.value=this.form.pertask1.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td31 bold"'), array(
"{$lang['counter_digest']}:",
'<input name="pertask2" type="text" class="txt" value="1000" /><input type="submit" class="btn" name="digestsubmit" onclick="this.form.pertask.value=this.form.pertask2.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td31 bold"'), array(
"{$lang['counter_member']}:",
'<input name="pertask3" type="text" class="txt" value="1000" /><input type="submit" class="btn" name="membersubmit" onclick="this.form.pertask.value=this.form.pertask3.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td31 bold"'), array(
"{$lang['counter_thread']}:",
'<input name="pertask4" type="text" class="txt" value="500" /><input type="submit" class="btn" name="threadsubmit" onclick="this.form.pertask.value=this.form.pertask4.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td31 bold"'), array(
"{$lang['counter_special']}:",
'<input name="pertask7" type="text" class="txt" value="1" disabled/><input type="submit" class="btn" name="specialarrange" onclick="this.form.pertask.value=this.form.pertask7.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td31 bold"'), array(
"{$lang['counter_groupnum']}:",
'<input name="pertask8" type="text" class="txt" value="10" /><input type="submit" class="btn" name="groupnum" onclick="this.form.pertask.value=this.form.pertask8.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td31 bold"'), array(
"{$lang['counter_groupmember_num']}:",
'<input name="pertask9" type="text" class="txt" value="100" /><input type="submit" class="btn" name="groupmembernum" onclick="this.form.pertask.value=this.form.pertask9.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td31 bold"'), array(
"{$lang['counter_groupmember_post']}:",
'<input name="pertask10" type="text" class="txt" value="100" /><input type="submit" class="btn" name="groupmemberpost" onclick="this.form.pertask.value=this.form.pertask10.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td31 bold"'), array(
"{$lang['counter_blog_replynum']}:",
'<input name="pertask11" type="text" class="txt" value="100" /><input type="submit" class="btn" name="blogreplynum" onclick="this.form.pertask.value=this.form.pertask11.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td31 bold"'), array(
"{$lang['counter_friendnum']}:",
'<input name="pertask12" type="text" class="txt" value="100" /><input type="submit" class="btn" name="friendnum" onclick="this.form.pertask.value=this.form.pertask12.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td31 bold"'), array(
"{$lang['counter_album_picnum']}:",
'<input name="pertask13" type="text" class="txt" value="100" /><input type="submit" class="btn" name="albumpicnum" onclick="this.form.pertask.value=this.form.pertask13.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td31 bold"'), array(
"{$lang['counter_thread_cover']}:",
'<script type="text/javascript" src="' . STATICURL . 'js/calendar.js"></script><input name="pertask14" type="text" class="txt" value="100" /> '.$lang['counter_forumid'].': <input type="text" class="txt marginleft10" name="fid" value="" size="10">&nbsp;<input type="checkbox" class="checkbox" value="1" name="allthread">'.$lang['counter_have_cover'].'<br><input type="text" onclick="showcalendar(event, this)" value="" name="starttime" class="txt"> -- <input type="text" onclick="showcalendar(event, this)" value="" name="endtime" class="txt marginleft10">('.$lang['counter_thread_cover_settime'].') &nbsp;&nbsp;<input type="submit" class="btn" name="setthreadcover" onclick="this.form.pertask.value=this.form.pertask14.value" value="'.$lang['submit'].'" />'
));
showtablefooter();
showformfooter();
}
function runuchcount($start, $perpage) {
}
?>

View File

@@ -0,0 +1,218 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_credits.php 32527 2013-02-05 09:56:25Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = $operation ? $operation : 'list';
if($operation == 'list') {
$rules = array();
foreach(C::t('common_credit_rule')->fetch_all_rule() as $value) {
$rules[$value['rid']] = $value;
}
if(!submitcheck('rulesubmit')) {
$anchor = in_array($_GET['anchor'], array('base', 'policytable', 'edit')) ? $_GET['anchor'] : 'base';
$current = array($anchor => 1);
showsubmenu('setting_credits', array(
array('setting_credits_base', 'setting&operation=credits&anchor=base', $current['base']),
array('setting_credits_policy', 'credits&operation=list&anchor=policytable', $current['policytable']),
));
showformheader("credits&operation=list");
showboxheader('setting_credits_policy', 'nobottom', 'id="policytable"'.($anchor != 'policytable' ? ' style="display: none"' : ''));
showtableheader();
echo '<tr class="header"><th class="td28 nowrap">'.$lang['setting_credits_policy_name'].'</th><th class="td28 nowrap">'.$lang['setting_credits_policy_cycletype'].'</th><th class="td28 nowrap">'.$lang['setting_credits_policy_rewardnum'].'</th>';
for($i = 1; $i <= 8; $i++) {
if($_G['setting']['extcredits'][$i]) {
echo "<th class=\"td25\" id=\"policy$i\" ".($_G['setting']['extcredits'][$i] ? '' : 'disabled')." valign=\"top\">".$_G['setting']['extcredits'][$i]['title']."</th>";
}
}
echo '<th class="td25">&nbsp;</th></tr>';
foreach($rules as $rid => $rule) {
$tdarr = array($rule['rulename'], $rule['rid'] ? $lang['setting_credits_policy_cycletype_'.$rule['cycletype']] : 'N/A', $rule['rid'] && $rule['cycletype'] ? $rule['rewardnum'] : 'N/A');
for($i = 1; $i <= 8; $i++) {
if($_G['setting']['extcredits'][$i]) {
array_push($tdarr, '<input name="credit['.$rule['rid'].']['.$i.']" class="txt" value="'.$rule['extcredits'.$i].'" />');
}
}
$opstr = '<a href="'.ADMINSCRIPT.'?action=credits&operation=edit&rid='.$rule['rid'].'" title="" class="act">'.$lang['edit'].'</a>';
array_push($tdarr, $opstr);
showtablerow('', array_fill(0, count($_G['setting']['extcredits']) + 4, 'class="td25"'), $tdarr);
}
showtablerow('', 'class="lineheight" colspan="9"', $lang['setting_credits_policy_comment']);
showtablefooter();
showboxfooter();
showtableheader('', 'nobottom', '');
showsetting('setting_credits_policy_mobile', 'settingnew[creditspolicymobile]', $_G['setting']['creditspolicymobile'], 'text');
showsubmit('rulesubmit');
showtablefooter();
showformfooter();
} else {
foreach($_GET['credit'] as $rid => $credits) {
$rule = array();
for($i = 1; $i <= 8; $i++) {
if($_G['setting']['extcredits'][$i]) {
$rule['extcredits'.$i] = $credits[$i];
}
}
C::t('common_credit_rule')->update($rid, $rule);
}
$settings = array(
'creditspolicymobile' => $_GET['settingnew']['creditspolicymobile'],
);
C::t('common_setting')->update_batch($settings);
updatecache(array('setting', 'creditrule'));
cpmsg('credits_update_succeed', 'action=credits&operation=list&anchor=policytable', 'succeed');
}
} elseif($operation == 'edit') {
$rid = intval($_GET['rid']);
$fid = intval($_GET['fid']);
if($rid) {
$globalrule = $ruleinfo = C::t('common_credit_rule')->fetch($rid);
if($fid) {
$query = C::t('forum_forum')->fetch_info_by_fid($fid);
$forumname = $query['name'];
$policy = $query['creditspolicy'] ? dunserialize($query['creditspolicy']) : array();
if(isset($policy[$ruleinfo['action']])) {
$ruleinfo = $policy[$ruleinfo['action']];
}
}
}
if(!submitcheck('rulesubmit')) {
if(!$rid) {
$ruleinfo['rulename'] = $lang['credits_edit_lowerlimit'];
}
if(!$fid) {
shownav('global', 'credits_edit');
showsubmenu("{$lang['credits_edit']} - {$ruleinfo['rulename']}");
} else {
if(!in_array($fid, explode(',', $globalrule['fids']))) {
for($i = 1; $i <= 8; $i++) {
$ruleinfo['extcredits'.$i] = '';
}
}
shownav('forum', 'forums_edit');
showsubmenu("$forumname - {$lang['credits_edit']} - {$ruleinfo['rulename']}");
showtips('forums_edit_tips');
}
showformheader("credits&operation=edit&rid=$rid&".($fid ? "fid=$fid" : ''));
$extra = '';
if($fid) {
$actives = $checkarr = array();
$usecustom = in_array($fid, explode(',', $globalrule['fids'])) ? 1 : 0;
$actives[$usecustom] = ' class="checked"';
$checkarr[$usecustom] = ' checked';
showtableheader('', 'nobottom');
$str = <<<EOF
<ul onmouseover="altStyle(this);">
<li$actives[1]><input type="radio" onclick="$('edit').style.display = '';" $checkarr[1] value="1" name="rule[usecustom]" class="radio">&nbsp;{$lang['yes']}</li>
<li$actives[0]><input type="radio" onclick="$('edit').style.display = 'none';" $checkarr[0] value="0" name="rule[usecustom]" class="radio">&nbsp;{$lang['no']}</li>
</ul>
EOF;
showsetting('setting_credits_use_custom_credit', 'usecustom', $usecustom, $str);
showtablefooter();
$extra = !$usecustom ? ' style="display:none;" ' : '';
}
showtips('setting_credits_policy_comment');
showtableheader('credits_edit', 'nobottom', 'id="edit"'.$extra);
if($rid) {
showsetting('setting_credits_policy_cycletype', array('rule[cycletype]', array(
array(0, $lang['setting_credits_policy_cycletype_0'], array('cycletimetd' => 'none', 'rewardnumtd' => 'none')),
array(1, $lang['setting_credits_policy_cycletype_1'], array('cycletimetd' => 'none', 'rewardnumtd' => '')),
array(2, $lang['setting_credits_policy_cycletype_2'], array('cycletimetd' => '', 'rewardnumtd' => '')),
array(3, $lang['setting_credits_policy_cycletype_3'], array('cycletimetd' => '', 'rewardnumtd' => '')),
array(4, $lang['setting_credits_policy_cycletype_4'], array('cycletimetd' => 'none', 'rewardnumtd' => '')),
)), $ruleinfo['cycletype'], 'mradio');
showtagheader('tbody', 'cycletimetd', in_array($ruleinfo['cycletype'], array(2, 3)), 'sub');
showsetting('credits_edit_cycletime', 'rule[cycletime]', $ruleinfo['cycletime'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'rewardnumtd', in_array($ruleinfo['cycletype'], array(1, 2, 3, 4)), 'sub');
showsetting('credits_edit_rewardnum', 'rule[rewardnum]', $ruleinfo['rewardnum'], 'text');
showtagfooter('tbody');
}
for($i = 1; $i <= 8; $i++) {
if($_G['setting']['extcredits'][$i]) {
if($rid) {
showsetting("extcredits{$i}(".$_G['setting']['extcredits'][$i]['title'].')', "rule[extcredits{$i}]", $ruleinfo['extcredits'.$i], 'text', '', 0, $fid ? '('.$lang['credits_edit_globalrule'].':'.$globalrule['extcredits'.$i].')' : '');
} else {
showsetting("extcredits{$i}(".$_G['setting']['extcredits'][$i]['title'].')', "rule[extcredits{$i}]", $_G['setting']['creditspolicy']['lowerlimit'][$i], 'text');
}
}
}
showtablefooter();
showtableheader('', 'nobottom');
showsubmit('rulesubmit');
showtablefooter();
showformfooter();
} else {
$rid = $_GET['rid'];
$rule = $_GET['rule'];
if($rid) {
if(!$rule['cycletype']) {
$rule['cycletime'] = 0;
$rule['rewardnum'] = 1;
}
$havecredit = $rule['usecustom'] ? true : false;
for($i = 1; $i <= 8; $i++) {
if(!$_G['setting']['extcredits'][$i]) {
$rule['extcredits'.$i] = 0;
}
}
foreach($rule as $key => $val) {
$rule[$key] = intval($val);
}
if($fid) {
$fids = $globalrule['fids'] ? explode(',', $globalrule['fids']) : array();
if($havecredit) {
$rule['rid'] = $rid;
$rule['fid'] = $fid;
$rule['rulename'] = $ruleinfo['rulename'];
$rule['action'] = $ruleinfo['action'];
$policy[$ruleinfo['action']] = $rule;
if(!in_array($fid, $fids)) {
$fids[] = $fid;
}
} else {
if($rule['cycletype'] != 0 && ($rule['cycletype'] == 4 && !$rule['rewardnum'])) {
require_once DISCUZ_ROOT.'./source/class/class_credit.php';
credit::deletelogbyfid($rid, $fid);
}
unset($policy[$ruleinfo['action']]);
if(in_array($fid, $fids)) {
unset($fids[array_search($fid, $fids)]);
}
}
C::t('forum_forumfield')->update($fid, array('creditspolicy' => serialize($policy)));
C::t('common_credit_rule')->update($rid, array('fids' => implode(',', $fids)));
updatecache('creditrule');
cpmsg('credits_update_succeed', 'action=forums&operation=edit&anchor=credits&fid='.$fid, 'succeed');
} else {
C::t('common_credit_rule')->update($rid, $rule);
}
updatecache('creditrule');
} else {
$lowerlimit['creditspolicy']['lowerlimit'] = array();
for($i = 1; $i <= 8; $i++) {
if($_G['setting']['extcredits'][$i]) {
$lowerlimit['creditspolicy']['lowerlimit'][$i] = (float)$rule['extcredits'.$i];
}
}
C::t('common_setting')->update_setting('creditspolicy', $lowerlimit['creditspolicy']);
updatecache(array('setting', 'creditrule'));
}
cpmsg('credits_update_succeed', 'action=credits&operation=list&anchor=policytable', 'succeed');
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,162 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_district.php 26298 2011-12-08 03:58:22Z chenmengshu $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
shownav('global', 'district');
$values = array(intval($_GET['countryid']), intval($_GET['pid']), intval($_GET['cid']), intval($_GET['did']));
$elems = array($_GET['country'], $_GET['province'], $_GET['city'], $_GET['district']);
$level = 0;
$upids = array(0);
$theid = 0;
for($i=0;$i<4;$i++) {
if(!empty($values[$i])) {
$theid = intval($values[$i]);
$upids[] = $theid;
$level++;
} else {
for($j=$i; $j<4; $j++) {
$values[$j] = '';
}
break;
}
}
if(submitcheck('editsubmit')) {
$delids = array();
foreach(C::t('common_district')->fetch_all_by_upid($theid) as $value) {
$usetype = 0;
if($_POST['birthcity'][$value['id']] && $_POST['residecity'][$value['id']]) {
$usetype = 3;
} elseif($_POST['birthcity'][$value['id']]) {
$usetype = 1;
} elseif($_POST['residecity'][$value['id']]) {
$usetype = 2;
}
if(!isset($_POST['district'][$value['id']])) {
$delids[] = $value['id'];
} elseif($_POST['district'][$value['id']] != $value['name'] || $_POST['displayorder'][$value['id']] != $value['displayorder'] || $usetype != $value['usetype']) {
C::t('common_district')->update($value['id'], array('name'=>$_POST['district'][$value['id']], 'displayorder'=>$_POST['displayorder'][$value['id']], 'usetype'=>$usetype));
}
}
if($delids) {
$ids = $delids;
for($i=$level; $i<4; $i++) {
$ids = array();
foreach(C::t('common_district')->fetch_all_by_upid($delids) as $value) {
$value['id'] = intval($value['id']);
$delids[] = $value['id'];
$ids[] = $value['id'];
}
if(empty($ids)) {
break;
}
}
C::t('common_district')->delete($delids);
}
if(!empty($_POST['districtnew'])) {
$inserts = array();
$displayorder = '';
foreach($_POST['districtnew'] as $key => $value) {
$displayorder = trim($_POST['districtnew_order'][$key]);
$value = trim($value);
if(!empty($value)) {
C::t('common_district')->insert(array('name' => $value, 'level' => $level, 'upid' => $theid, 'displayorder' => $displayorder));
}
}
}
cpmsg('setting_district_edit_success', 'action=district&countryid='.$values[0].'&pid='.$values[1].'&cid='.$values[2].'&did='.$values[3], 'succeed');
} else {
showsubmenu('district');
showtips('district_tips');
showformheader('district&countryid='.$values[0].'&pid='.$values[1].'&cid='.$values[2].'&did='.$values[3]);
showboxheader();
showtableheader();
$options = array(0=>array(), 1=>array(), 2=>array(), 3=>array());
$thevalues = array();
foreach(C::t('common_district')->fetch_all_by_upid($upids) as $value) {
$options[$value['level']][] = array($value['id'], $value['name']);
if($value['upid'] == $theid) {
$thevalues[] = array($value['id'], $value['name'], $value['displayorder'], $value['usetype']);
}
}
$names = array('country', 'province', 'city', 'district');
for($i=0; $i<4;$i++) {
$elems[$i] = !empty($elems[$i]) ? $elems[$i] : $names[$i];
}
$html = '';
for($i=0;$i<4;$i++) {
$jscall = ($i == 0 ? 'this.form.province.value=\'\';this.form.city.value=\'\';this.form.district.value=\'\';' : '')."refreshdistrict('$elems[0]', '$elems[1]', '$elems[2]', '$elems[3]')";
$html .= '<select name="'.$elems[$i].'" id="'.$elems[$i].'" onchange="'.$jscall.'">';
$html .= '<option value="">'.lang('spacecp', 'district_level_'.$i).'</option>';
foreach($options[$i] as $option) {
$selected = $option[0] == $values[$i] ? ' selected="selected"' : '';
$html .= '<option value="'.$option[0].'"'.$selected.'>'.$option[1].'</option>';
}
$html .= '</select>&nbsp;&nbsp;';
}
echo cplang('district_choose').' &nbsp; '.$html;
showsubtitle($values[0] ? array('', 'display_order', 'name', 'operation') : array('', 'display_order', 'name', 'district_birthcity', 'district_residecity', 'operation'));
foreach($thevalues as $value) {
$valarr = array();
$valarr[] = '';
$valarr[] = '<input type="text" id="displayorder_'.$value[0].'" class="txt" name="displayorder['.$value[0].']" value="'.$value[2].'"/>';
$valarr[] = '<p id="p_'.$value[0].'"><input type="text" id="input_'.$value[0].'" class="txt" name="district['.$value[0].']" value="'.$value[1].'"/></p>';
if(!$values[0]) {
$valarr[] = '<input type="checkbox" name="birthcity['.$value[0].']" value="1" class="checkbox"'.($value[3] && in_array($value[3], array(1,3)) ? ' checked="checked" ':'').' />';
$valarr[] = '<input type="checkbox" name="residecity['.$value[0].']" value="1" class="checkbox"'.($value[3] && in_array($value[3], array(2,3)) ? ' checked="checked" ':'').' />';
}
$valarr[] = '<a href="javascript:;" onclick="deletedistrict('.$value[0].');return false;">'.cplang('delete').'</a>';
showtablerow('id="td_'.$value[0].'"', array('', 'class="td25"','','','',''), $valarr);
}
showtablerow('', array('colspan=2'), array(
'<div><a href="javascript:;" onclick="addrow(this, 0, 1);return false;" class="addtr">'.cplang('add').'</a></div>'
));
showsubmit('editsubmit', 'submit');
$adminurl = ADMINSCRIPT.'?action=district';
echo <<<SCRIPT
<script type="text/javascript">
var rowtypedata = [
[[1,'', ''],[1,'<input type="text" class="txt" name="districtnew_order[]" value="0" />', 'td25'],[2,'<input type="text" class="txt" name="districtnew[]" value="" />', '']],
];
function refreshdistrict(country, province, city, district) {
location.href = "$adminurl"
+"&country="+country+"&province="+province+"&city="+city+"&district="+district
+"&countryid="+$(country).value+"&pid="+$(province).value + "&cid="+$(city).value+"&did="+$(district).value;
}
function editdistrict(did) {
$('input_' + did).style.display = "block";
$('span_' + did).style.display = "none";
}
function deletedistrict(did) {
var elem = $('p_' + did);
elem.parentNode.removeChild(elem);
var elem = $('td_' + did);
elem.parentNode.removeChild(elem);
}
</script>
SCRIPT;
showtablefooter();
showboxfooter();
showformfooter();
}
?>

View File

@@ -0,0 +1,294 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_diytemplate.php 29236 2012-03-30 05:34:47Z chenmengshu $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = in_array($operation, array('edit', 'perm')) ? $operation : 'list';
shownav('portal', 'diytemplate');
if($operation == 'list') {
$searchctrl = '<span style="float: right; padding-right: 40px;">'
.'<a href="javascript:;" onclick="$(\'tb_search\').style.display=\'\';$(\'a_search_show\').style.display=\'none\';$(\'a_search_hide\').style.display=\'\';" id="a_search_show" style="display:none">'.cplang('show_search').'</a>'
.'<a href="javascript:;" onclick="$(\'tb_search\').style.display=\'none\';$(\'a_search_show\').style.display=\'\';$(\'a_search_hide\').style.display=\'none\';" id="a_search_hide">'.cplang('hide_search').'</a>'
.'</span>';
showsubmenu('diytemplate', array(
array('list', 'diytemplate', 1),
), $searchctrl);
$intkeys = array('uid', 'closed');
$strkeys = array();
$randkeys = array();
$likekeys = array('targettplname', 'primaltplname', 'username', 'name');
$results = getwheres($intkeys, $strkeys, $randkeys, $likekeys);
foreach($likekeys as $k) {
$_GET[$k] = dhtmlspecialchars($_GET[$k]);
}
$wherearr = $results['wherearr'];
$mpurl = ADMINSCRIPT.'?action=diytemplate';
$mpurl .= '&'.implode('&', $results['urls']);
$wherearr[] = " primaltplname NOT LIKE 'portal/list%' ";
$wherearr[] = " primaltplname NOT LIKE 'portal/portal_topic_content%' ";
if($_GET['permname']) {
$tpls = '';
$member = C::t('common_member')->fetch_by_username($_GET['permname']);
if($member && $member['adminid'] != 1) {
$tpls = array_keys(C::t('common_template_permission')->fetch_all_by_uid($member['uid']));
if(($tpls = dimplode($tpls))) {
$wherearr[] = 'targettplname IN ('.$tpls.')';
} else {
cpmsg_error($_GET['permname'].cplang('diytemplate_the_username_has_not_template'));
}
}
$mpurl .= '&permname='.$_GET['permname'];
}
$wheresql = empty($wherearr)?'':implode(' AND ', $wherearr);
$orders = getorders(array('dateline','targettplname'), 'dateline');
$ordersql = $orders['sql'];
if($orders['urls']) $mpurl .= '&'.implode('&', $orders['urls']);
$orderby = array($_GET['orderby']=>' selected');
$ordersc = array($_GET['ordersc']=>' selected');
$perpage = empty($_GET['perpage'])?0:intval($_GET['perpage']);
if(!in_array($perpage, array(10,20,50,100))) $perpage = 20;
$perpages = array($perpage=>' selected');
$searchlang = array();
$keys = array('search', 'likesupport', 'resultsort', 'defaultsort', 'orderdesc', 'orderasc', 'perpage_10', 'perpage_20', 'perpage_50', 'perpage_100',
'diytemplate_name', 'diytemplate_dateline', 'diytemplate_targettplname', 'diytemplate_primaltplname', 'diytemplate_uid', 'diytemplate_username',
'nolimit', 'no', 'yes', 'diytemplate_permname', 'diytemplate_permname_tips');
foreach ($keys as $key) {
$searchlang[$key] = cplang($key);
}
$adminscript = ADMINSCRIPT;
echo <<<SEARCH
<form method="get" autocomplete="off" action="$adminscript" id="tb_search">
<table cellspacing="3" cellpadding="3" class="tb tb2">
<tr>
<th>{$searchlang['diytemplate_name']}*</th><td><input type="text" class="txt" name="name" value="{$_GET['name']}"></td>
<th>{$searchlang['diytemplate_targettplname']}*</th><td><input type="text" class="txt" name="targettplname" value="{$_GET['targettplname']}"></td>
<th>{$searchlang['diytemplate_primaltplname']}*</th><td><input type="text" class="txt" name="primaltplname" value="{$_GET['primaltplname']}"> *{$searchlang['likesupport']}</td>
</tr>
<tr>
<th>{$searchlang['diytemplate_uid']}</th><td><input type="text" class="txt" name="uid" value="{$_GET['uid']}"></td>
<th>{$searchlang['diytemplate_username']}*</th><td><input type="text" class="txt" name="username" value="{$_GET['username']}" colspan="2"></td>
</tr>
<tr>
<th>{$searchlang['resultsort']}</th>
<td colspan="3">
<select name="orderby">
<option value="">{$searchlang['defaultsort']}</option>
<option value="dateline"{$orderby['dateline']}>{$searchlang['diytemplate_dateline']}</option>
<option value="targettplname"{$orderby['targettplname']}>{$searchlang['diytemplate_targettplname']}</option>
</select>
<select name="ordersc">
<option value="desc"{$ordersc['desc']}>{$searchlang['orderdesc']}</option>
<option value="asc"{$ordersc['asc']}>{$searchlang['orderasc']}</option>
</select>
<select name="perpage">
<option value="10"{$perpages[10]}>{$searchlang['perpage_10']}</option>
<option value="20"{$perpages[20]}>{$searchlang['perpage_20']}</option>
<option value="50"{$perpages[50]}>{$searchlang['perpage_50']}</option>
<option value="100"{$perpages[100]}>{$searchlang['perpage_100']}</option>
</select>
<input type="hidden" name="action" value="diytemplate">
</td>
<th>{$searchlang['diytemplate_permname']}</th>
<td><input type="text" class="txt" name="permname" value="{$_GET['permname']}"> {$searchlang['diytemplate_permname_tips']}
<input type="submit" name="searchsubmit" value="{$searchlang['search']}" class="btn"></td>
</tr>
</table>
</form>
SEARCH;
$start = ($page-1)*$perpage;
$mpurl .= '&perpage='.$perpage;
$perpages = array($perpage => ' selected');
showformheader('diytemplate');
showtableheader('diytemplate_list');
showsubtitle(array('diytemplate_name', 'diytemplate_targettplname', 'diytemplate_primaltplname', 'username', 'diytemplate_dateline', 'operation'));
$multipage = '';
if(($count = C::t('common_diy_data')->count_by_where($wheresql))) {
loadcache('diytemplatename');
require_once libfile('function/block');
foreach(C::t('common_diy_data')->fetch_all_by_where($wheresql, $ordersql, $start, $perpage) as $value) {
$value['name'] = $_G['cache']['diytemplatename'][$value['targettplname']];
$value['dateline'] = $value['dateline'] ? dgmdate($value['dateline']) : '';
$diyurl = block_getdiyurl($value['targettplname']);
$diytitle = cplang($diyurl['flag'] ? 'diytemplate_share' : 'diytemplate_alone');
showtablerow('', array('class=""', 'class=""', 'class="td28"'), array(
"<a href=\"{$diyurl['url']}\" title=\"$diytitle\" target=\"_blank\">{$value['name']}</a>",
'<span title="'.cplang('diytemplate_path').'./data/diy/'.$value['targettplname'].'.htm">'.$value['targettplname'].'</span>',
'<span title="'.cplang('diytemplate_path').$_G['style']['tpldir'].'/'.$value['primaltplname'].'.htm">'.$value['primaltplname'].'</span>',
"<a href=\"home.php?mod=space&uid={$value['uid']}&do=profile\" target=\"_blank\">{$value['username']}</a>",
$value['dateline'],
'<a href="'.ADMINSCRIPT.'?action=diytemplate&operation=edit&targettplname='.$value['targettplname'].'&tpldirectory='.$value['tpldirectory'].'">'.cplang('edit').'</a> '.
'<a href="'.ADMINSCRIPT.'?action=diytemplate&operation=perm&targettplname='.$value['targettplname'].'&tpldirectory='.$value['tpldirectory'].'">'.cplang('diytemplate_perm').'</a>',
));
}
$multipage = multi($count, $perpage, $page, $mpurl);
}
showsubmit('', '', '', '', $multipage);
showtablefooter();
showformfooter();
} elseif($operation == 'edit') {
loadcache('diytemplatename');
$targettplname = $_GET['targettplname'];
$tpldirectory = $_GET['tpldirectory'];
$diydata = C::t('common_diy_data')->fetch_diy($targettplname, $tpldirectory);
if(empty($diydata)) { cpmsg_error('diytemplate_targettplname_error', dreferer());}
if(!submitcheck('editsubmit')) {
if(empty($diydata['name'])) $diydata['name'] = $_G['cache']['diytemplatename'][$diydata['targettplname']];
shownav('portal', 'diytemplate', $diydata['name']);
showsubmenu(cplang('diytemplate_edit').' - '.$diydata['name'], array(
array('list', 'diytemplate', 0),
array('edit', 'diytemplate&operation=edit&targettplname='.$_GET['targettplname']."&tpldirectory=$tpldirectory", 1)
));
showformheader("diytemplate&operation=edit&targettplname=$targettplname&tpldirectory=$tpldirectory");
showtableheader();
showtitle('edit');
showsetting('diytemplate_name', 'name', $diydata['name'],'text');
showsetting('diytemplate_targettplname', '', '',cplang('diytemplate_path').'./data/diy/'.$diydata['targettplname'].'.htm');
showsetting('diytemplate_primaltplname', '', '',cplang('diytemplate_path').$_G['style']['tpldir'].'/'.$diydata['primaltplname'].'.htm');
showsetting('diytemplate_username', '', '',$diydata['username']);
showsetting('diytemplate_dateline', '', '',$diydata['dateline'] ? dgmdate($diydata['dateline']) : '');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$editdiydata = array('name'=>$_GET['name']);
C::t('common_diy_data')->update_diy($targettplname, $tpldirectory, $editdiydata);
include_once libfile('function/cache');
updatecache('diytemplatename');
cpmsg('diytemplate_edit_succeed', 'action=diytemplate', 'succeed');
}
} elseif($operation=='perm') {
loadcache('diytemplatename');
$targettplname = $_GET['targettplname'];
$tpldirectory = $_GET['tpldirectory'];
$diydata = C::t('common_diy_data')->fetch_diy($targettplname, $tpldirectory);
if(empty($diydata)) { cpmsg_error('diytemplate_targettplname_error', dreferer());}
if(!submitcheck('permsubmit')) {
shownav('portal', 'diytemplate', 'diytemplate_perm');
showsubmenu(cplang('diytemplate_perm_edit').' - '.($diydata['name'] ? cplang($diydata['name']) : $_G['cache']['diytemplatename'][$diydata['targettplname']]));
showtips('diytemplate_perm_tips');
showformheader("diytemplate&operation=perm&targettplname=$targettplname&tpldirectory=$tpldirectory");
showtableheader('', 'fixpadding');
showsubtitle(array('', 'username',
'<input class="checkbox" type="checkbox" name="chkallmanage" onclick="checkAll(\'prefix\', this.form, \'allowmanage\', \'chkallmanage\')" id="chkallmanage" /><label for="chkallmanage">'.cplang('block_perm_manage').'</label>',
'<input class="checkbox" type="checkbox" name="chkallrecommend" onclick="checkAll(\'prefix\', this.form, \'allowrecommend\', \'chkallrecommend\')" id="chkallrecommend" /><label for="chkallrecommend">'.cplang('block_perm_recommend').'</label>',
'<input class="checkbox" type="checkbox" name="chkallneedverify" onclick="checkAll(\'prefix\', this.form, \'needverify\', \'chkallneedverify\')" id="chkallneedverify" /><label for="chkallneedverify">'.cplang('block_perm_needverify').'</label>',
'block_perm_inherited'
));
$allpermission = C::t('common_template_permission')->fetch_all_by_targettplname($targettplname);
$allusername = C::t('common_member')->fetch_all_username_by_uid(array_keys($allpermission));
$line = '&minus;';
foreach($allpermission as $uid => $value) {
if(!empty($value['inheritedtplname'])) {
showtablerow('', array('class="td25"'), array(
"",
"$allusername[$uid]",
$value['allowmanage'] ? '&radic;' : $line,
$value['allowrecommend'] ? '&radic;' : $line,
$value['needverify'] ? '&radic;' : $line,
'<a href="'.ADMINSCRIPT.'?action=diytemplate&operation=perm&targettplname='.$value['inheritedtplname'].'">'.$_G['cache']['diytemplatename'][$value['inheritedtplname']].'</a>',
));
} else {
showtablerow('', array('class="td25"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[{$value['uid']}]\" value=\"{$value['uid']}\" />
<input type=\"hidden\" name=\"perm[{$value['uid']}][allowmanage]\" value=\"{$value['allowmanage']}\" />
<input type=\"hidden\" name=\"perm[{$value['uid']}][allowrecommend]\" value=\"{$value['allowrecommend']}\" />
<input type=\"hidden\" name=\"perm[{$value['uid']}][needverify]\" value=\"{$value['needverify']}\" />",
"$allusername[$uid]",
"<input type=\"checkbox\" class=\"checkbox\" name=\"allowmanage[{$value['uid']}]\" value=\"1\" ".($value['allowmanage'] ? 'checked' : '').' />',
"<input type=\"checkbox\" class=\"checkbox\" name=\"allowrecommend[{$value['uid']}]\" value=\"1\" ".($value['allowrecommend'] ? 'checked' : '').' />',
"<input type=\"checkbox\" class=\"checkbox\" name=\"needverify[{$value['uid']}]\" value=\"1\" ".($value['needverify'] ? 'checked' : '').' />',
$line,
));
}
}
showtablerow('', array('class="td25"'), array(
cplang('add_new'),
'<input type="text" class="txt" name="newuser" value="" size="20" />',
'<input type="checkbox" class="checkbox" name="newallowmanage" value="1" />',
'<input type="checkbox" class="checkbox" name="newallowrecommend" value="1" />',
'<input type="checkbox" class="checkbox" name="newneedverify" value="1" />',
'',
));
showsubmit('permsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
$users = array();
if(!empty($_GET['newuser'])) {
$uid = C::t('common_member')->fetch_uid_by_username($_GET['newuser']);
if($uid) {
$user = array();
$user['uid'] = $uid;
$user['allowmanage'] = $_GET['newallowmanage'] ? 1 : 0;
$user['allowrecommend'] = $_GET['newallowrecommend'] ? 1 : 0;
$user['needverify'] = $_GET['newneedverify'] ? 1 : 0;
$users[] = $user;
} else {
cpmsg_error($_GET['newuser'].cplang('block_has_no_allowauthorizedblock'), dreferer());
}
}
if(is_array($_GET['perm'])) {
foreach($_GET['perm'] as $uid => $value) {
if(empty($_GET['delete']) || !in_array($uid, $_GET['delete'])) {
$user = array();
$user['allowmanage'] = $_GET['allowmanage'][$uid] ? 1 : 0;
$user['allowrecommend'] = $_GET['allowrecommend'][$uid] ? 1 : 0;
$user['needverify'] = $_GET['needverify'][$uid] ? 1 : 0;
if($value['allowmanage'] != $user['allowmanage'] || $value['allowrecommend'] != $user['allowrecommend'] || $value['needverify'] != $user['needverify'] ) {
$user['uid'] = intval($uid);
$users[] = $user;
}
}
}
}
if(!empty($users) || $_GET['delete']) {
require_once libfile('class/blockpermission');
$tplpermsission = & template_permission::instance();
if($_GET['delete']) {
$tplpermsission->delete_users($targettplname ,$_GET['delete']);
}
if(!empty($users)) {
$tplpermsission->add_users($targettplname, $users);
}
}
cpmsg('diytemplate_perm_update_succeed', "action=diytemplate&operation=perm&targettplname=$targettplname&tpldirectory=$tpldirectory", 'succeed');
}
}
?>

View File

@@ -0,0 +1,181 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_doing.php 27696 2012-02-10 03:39:50Z svn_project_zhangjie $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$detail = $_GET['detail'];
$users = $_GET['users'];
$userip = $_GET['userip'];
$keywords = $_GET['keywords'];
$lengthlimit = $_GET['lengthlimit'];
$starttime = $_GET['starttime'];
$endtime = $_GET['endtime'];
$searchsubmit = $_GET['searchsubmit'];
$doids = $_GET['doids'];
$fromumanage = $_GET['fromumanage'] ? 1 : 0;
cpheader();
if(!submitcheck('doingsubmit')) {
if(empty($_GET['search'])) {
$newlist = 1;
$detail = 1;
}
if($fromumanage) {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? '' : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? '' : $endtime;
} else {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? dgmdate(TIMESTAMP - 86400 * 7, 'Y-n-j') : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? dgmdate(TIMESTAMP, 'Y-n-j') : $endtime;
}
shownav('topic', 'nav_doing');
showsubmenu('nav_doing', array(
array('newlist', 'doing', !empty($newlist)),
array('search', 'doing&search=true', empty($newlist)),
));
empty($newlist) && showsubmenusteps('', array(
array('doing_search', !$searchsubmit),
array('nav_doing', $searchsubmit)
));
if(empty($newlist)) {
$search_tips = 1;
showtips('doing_tips');
}
$staticurl = STATICURL;
echo <<<EOT
<script type="text/javascript" src="{$staticurl}js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('doingforum').page.value=number;
$('doingforum').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'searchposts', !$searchsubmit && empty($newlist));
showformheader("doing".(!empty($_GET['search']) ? '&search=true' : ''), '', 'doingforum');
showhiddenfields(array('page' => $page, 'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']));
showtableheader();
showsetting('doing_search_detail', 'detail', $detail, 'radio');
showsetting('doing_search_perpage', '', $_GET['perpage'], "<select name='perpage'><option value='20'>{$lang['perpage_20']}</option><option value='50'>{$lang['perpage_50']}</option><option value='100'>{$lang['perpage_100']}</option></select>");
showsetting('doing_search_user', 'users', $users, 'text');
showsetting('doing_search_ip', 'userip', $userip, 'text');
showsetting('doing_search_keyword', 'keywords', $keywords, 'text');
showsetting('doing_search_lengthlimit', 'lengthlimit', $lengthlimit, 'text');
showsetting('doing_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
echo '<input type="hidden" name="fromumanage" value="'.$fromumanage.'">';
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
$doids = authcode($doids, 'DECODE');
$doidsadd = $doids ? explode(',', $doids) : $_GET['delete'];
include_once libfile('function/delete');
$deletecount = count(deletedoings($doidsadd));
$cpmsg = cplang('doing_succeed', array('deletecount' => $deletecount));
?>
<script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('doingforum').searchsubmit.click();</script>
<?php
}
if(submitcheck('searchsubmit', 1) || $newlist) {
$doids = $doingcount = '0';
$sql = $error = '';
$keywords = trim($keywords);
$users = trim($users);
if($users != '') {
$uids = C::t('common_member')->fetch_all_uid_by_username(array_map('trim', explode(',', $users)));
if(!$uids) {
$uids = array(-1);
}
}
if(($_G['adminid'] == 2 && $endtime - $starttime > 86400 * 16) || ($_G['adminid'] == 3 && $endtime - $starttime > 86400 * 8)) {
$error = 'prune_mod_range_illegal';
}
if(!($_G['adminid'] == 1 && $endtime != dgmdate(TIMESTAMP, 'Y-n-j'))) {
$endtime = TIMESTAMP;
}
if(!$error) {
if($detail) {
$_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
$perpage = $_GET['pp'] ? $_GET['pp'] : $_GET['perpage'];
$query = C::t('home_doing')->fetch_all_search((($page - 1) * $perpage), $perpage, 1, $uids, $userip, $keywords, $lengthlimit, $starttime, $endtime);
$doings = '';
foreach ($query as $doing) {
$doing['dateline'] = dgmdate($doing['dateline']);
$doings .= showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"{$doing['doid']}\" />",
"<a href=\"home.php?mod=space&uid={$doing['uid']}\" target=\"_blank\">{$doing['username']}</a>",
$doing['message'],
$doing['ip'],
$doing['dateline']
), TRUE);
}
$doingcount = C::t('home_doing')->fetch_all_search((($page - 1) * $perpage), $perpage, 3, $uids, $userip, $keywords, $lengthlimit, $starttime, $endtime);
$multi = multi($doingcount, $perpage, $page, ADMINSCRIPT."?action=doing");
$multi = preg_replace("/href=\"".ADMINSCRIPT."\?action=doing&amp;page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
$multi = str_replace("window.location='".ADMINSCRIPT."?action=doing&amp;page='+this.value", "page(this.value)", $multi);
} else {
$doingcount = 0;
$query = C::t('home_doing')->fetch_all_search((($page - 1) * $perpage), $perpage, 2, $uids, $userip, $keywords, $lengthlimit, $starttime, $endtime);
foreach ($query as $doing) {
$doids .= ','.$doing['doid'];
$doingcount++;
}
$multi = '';
}
if(!$doingcount) {
$error = 'doing_post_nonexistence';
}
}
showtagheader('div', 'postlist', $searchsubmit || $newlist);
showformheader('doing&frame=no', 'target="doingframe"');
showhiddenfields(array('doids' => authcode($doids, 'ENCODE')));
if(!$search_tips) {
showtableheader(cplang('doing_new_result').' '.$doingcount, 'fixpadding');
} else {
showtableheader(cplang('doing_result').' '.$doingcount.(empty($newlist) ? ' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';$(\'doingforum\').pp.value=\'\';$(\'doingforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>' : ''), 'fixpadding');
}
if($error) {
echo "<tr><td class=\"lineheight\" colspan=\"15\">$lang[$error]</td></tr>";
} else {
if($detail) {
showsubtitle(array('', 'author', 'message', 'ip', 'time'));
echo $doings;
}
}
showsubmit('doingsubmit', 'delete', $detail ? 'del' : '', '', $multi);
showtablefooter();
showformfooter();
echo '<iframe name="doingframe" style="display:none"></iframe>';
showtagfooter('div');
}
?>

View File

@@ -0,0 +1,171 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_domain.php 32699 2013-03-01 02:54:05Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = in_array($operation, array('global', 'app', 'root')) ? $operation : 'global';
$current = array($operation => 1);
shownav('global', 'setting_domain');
showsubmenu('setting_domain', array(
array('setting_domain_base', 'domain', $current['global']),
array('setting_domain_app', 'domain&operation=app', $current['app']),
array('setting_domain_root', 'domain&operation=root', $current['root']),
));
$navs = $_G['setting']['navs'];
if($operation == 'app') {
if(!submitcheck('submit')) {
$appkeyarr = array(
'portal' => $navs[1]['navname'],
'forum' => $navs[2]['navname'],
'group' => $navs[3]['navname'],
'home' => $lang['nav_home'],
'mobile' => $lang['mobile'],
'default' => $lang['default']
);
showtips('setting_domain_app_tips');
showformheader('domain&operation=app');
showboxheader();
showtableheader();
showsubtitle(array('name', 'setting_domain_app_domain'));
$app = array();
$hiddenarr = array();
foreach($appkeyarr as $key => $desc) {
if(in_array($key, array('portal', 'group')) && !helper_access::check_module($key) || ($key == 'home' && !helper_access::check_module('feed'))) {
$hiddenarr["appnew[$key]"] = '';
} else {
showtablerow('', array('class="td25"', ''), array(
$desc,
"<input type=\"text\" class=\"txt\" style=\"width:50%;\" name=\"appnew[$key]\" value=\"".$_G['setting']['domain']['app'][$key]."\">".($key == 'mobile' ? cplang('setting_domain_app_mobile_tips') : '')
));
}
}
showsubmit('submit');
showtablefooter();
showboxfooter();
showhiddenfields($hiddenarr);
showformfooter();
} else {
$olddomain = $_G['setting']['domain']['app'];
$_G['setting']['domain']['app'] = array();
$appset = false;
foreach($_GET['appnew'] as $appkey => $domain) {
$domain = strtolower($domain);
if(!empty($domain) && !preg_match('/^((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}$/', $domain)) {
cpmsg('setting_domain_http_error', '', 'error');
}
if(!empty($domain) && in_array($domain, $_G['setting']['domain']['app'])) {
cpmsg('setting_domain_repeat_error', '', 'error');
}
if($appkey != 'default' && $domain) {
$appset = true;
}
$_G['setting']['domain']['app'][$appkey] = $domain;
}
if($appset && !$_G['setting']['domain']['app']['default']) {
cpmsg('setting_domain_need_default_error', '', 'error');
}
if($_GET['appnew']['mobile'] != $olddomain['mobile']) {
C::t('common_nav')->update_by_identifier('mobile', array('url' => (!$_GET['appnew']['mobile'] ? 'forum.php?mobile=yes' : $_G['scheme'].'://'.$_GET['appnew']['mobile'])));
}
C::t('common_setting')->update_setting('domain',$_G['setting']['domain']);
updatecache('setting');
cpmsg('setting_update_succeed', 'action=domain&operation=app', 'succeed');
}
} elseif($operation == 'root') {
$roottype = array(
'home' => $lang['domain_home'],
'group' => $navs[3]['navname'],
'forum' => $lang['domain_forum'],
'topic' => $lang['domain_topic'],
'channel' => $lang['channel'],
);
if(!submitcheck('submit')) {
showtips('setting_domain_root_tips');
showformheader('domain&operation=root');
showboxheader();
showtableheader();
showsubtitle(array('name', 'setting_domain_app_domain'));
$hiddenarr = array();
foreach($roottype as $type => $desc) {
if(in_array($type, array('topic', 'channel')) && !helper_access::check_module('portal') || ($type == 'home' && !$_G['setting']['homepagestyle']) || ($type == 'group' && !helper_access::check_module('group'))) {
$hiddenarr["domainnew[$type]"] = '';
} else {
$domainroot = $_G['setting']['domain']['root'][$type];
showtablerow('', array('class="td25"', ''), array(
$desc,
"<input type=\"text\" class=\"txt\" style=\"width:50%;\" name=\"domainnew[$type]\" value=\"$domainroot\">"
));
}
}
showsubmit('submit');
showtablefooter();
showboxfooter();
showhiddenfields($hiddenarr);
showformfooter();
} else {
$oldroot = $_G['setting']['domain']['root'];
$_G['setting']['domain']['root'] = array();
foreach($_GET['domainnew'] as $idtype => $domain) {
$domain = strtolower($domain);
if(!empty($domain) && !preg_match('/^((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}$/', $domain)) {
cpmsg('setting_domain_http_error', '', 'error');
}
if($_G['setting']['domain']['root'][$idtype] != $domain) {
$updatetype = $idtype == 'forum' ? array('forum', 'channel') : $idtype;
C::t('common_domain')->update_by_idtype($updatetype, array('domainroot' => $domain));
}
$_G['setting']['domain']['root'][$idtype] = $domain;
}
C::t('common_setting')->update_setting('domain', $_G['setting']['domain']);
updatecache('setting');
cpmsg('setting_update_succeed', 'action=domain&operation=root', 'succeed');
}
} else {
if(!submitcheck('domainsubmit')) {
showtips('setting_domain_base_tips');
showformheader("domain");
showtableheader();
if($_G['setting']['homepagestyle']) {
showsetting('setting_domain_allow_space', 'settingnew[allowspacedomain]', $_G['setting']['allowspacedomain'], 'radio');
} else {
showhiddenfields(array('settingnew[allowspacedomain]' => 0));
}
if(helper_access::check_module('group')) {
showsetting('setting_domain_allow_group', 'settingnew[allowgroupdomain]', $_G['setting']['allowgroupdomain'], 'radio');
} else {
showhiddenfields(array('settingnew[allowgroupdomain]' => 0));
}
showsetting('setting_domain_hold_domain', 'settingnew[holddomain]', $_G['setting']['holddomain'], 'text');
showsubmit('domainsubmit');
showtablefooter();
showformfooter();
} else {
$settings = $_GET['settingnew'];
$settings['allowspacedomain'] = (float)$settings['allowspacedomain'];
$settings['allowgroupdomain'] = (float)$settings['allowgroupdomain'];
if($settings) {
C::t('common_setting')->update_batch($settings);
updatecache('setting');
}
cpmsg('setting_update_succeed', 'action=domain', 'succeed');
}
}
?>

View File

@@ -0,0 +1,918 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_ec.php 30969 2012-07-04 10:18:10Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
if(!defined('APPTYPEID')) {
define('APPTYPEID', 2);
}
$checktype = $_GET['checktype'];
cpheader();
if($operation == 'alipay') {
$alipaysettings = C::t('common_setting')->fetch_setting('ec_alipay', true);
if(!empty($checktype)) {
if($checktype == 'credit') {
$return_url = $_G['siteurl'] . 'home.php?mod=spacecp&ac=credit';
$pay_url = payment::create_order('payment_credit', $lang['ec_alipay_checklink_credit'], $lang['ec_alipay_checklink_credit'], 1, $return_url);
ob_end_clean();
dheader('location: ' . $pay_url);
}
exit;
}
if(!submitcheck('alipaysubmit')) {
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'setting&operation=ec', 0),
array('nav_ec_qpay', 'ec&operation=qpay', 0),
array('nav_ec_wechat', 'ec&operation=wechat', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 1),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0),
array('nav_ec_inviteorders', 'ec&operation=inviteorders', 0),
array('nav_ec_paymentorders', 'ec&operation=paymentorders', 0),
array('nav_ec_transferorders', 'ec&operation=transferorders', 0),
));
showtips('ec_alipay_tips');
showformheader('ec&operation=alipay');
showtableheader('', 'nobottom');
showtitle('ec_alipay');
showtagheader('tbody', 'alipay_setting', true);
showsetting('ec_alipay_on', 'settingsnew[on]', $alipaysettings['on'], 'radio');
$check = array();
$alipaysettings['ec_alipay_sign_mode'] ? $check['true'] = "checked" : $check['false'] = "checked";
$alipaysettings['ec_alipay_sign_mode'] ? $check['false'] = '' : $check['true'] = '';
$check['hidden1'] = ' onclick="$(\'sign_model_01\').style.display = \'none\';$(\'sign_model_02\').style.display = \'\';"';
$check['hidden0'] = ' onclick="$(\'sign_model_01\').style.display = \'\';$(\'sign_model_02\').style.display = \'none\';"';
$html = '<ul onmouseover="altStyle(this);">' .
'<li' . ($check['false'] ? ' class="checked"' : '') . '><input class="radio" type="radio" name="settingsnew[ec_alipay_sign_mode]" value="0" ' . $check['false'] . $check['hidden0'] . '>&nbsp;' . lang('admincp', 'ec_alipay_sign_mode_01') . '</li>' .
'<li' . ($check['true'] ? ' class="checked"' : '') . '><input class="radio" type="radio" name="settingsnew[ec_alipay_sign_mode]" value="1" ' . $check['true'] . $check['hidden1'] . '>&nbsp;' . lang('admincp', 'ec_alipay_sign_mode_02') . '</li>' .
'</ul>';
showsetting('ec_alipay_sign_mode', '', '', $html);
showtagfooter('tbody');
showtagheader('tbody', 'sign_model_01', !$alipaysettings['ec_alipay_sign_mode']);
showsetting('ec_alipay_appid', 'settingsnew[mode_a_appid]', $alipaysettings['mode_a_appid'], 'text');
$alipay_securitycodemask = $alipaysettings['mode_a_app_private_key'] ? substr($alipaysettings['mode_a_app_private_key'], 0, 40) . '********' . substr($alipaysettings['mode_a_app_private_key'], -40) : '';
showsetting('ec_alipay_app_private_key', 'settingsnew[mode_a_app_private_key]', $alipay_securitycodemask, 'textarea');
$alipay_securitycodemask = $alipaysettings['mode_a_alipay_public_key'] ? substr($alipaysettings['mode_a_alipay_public_key'], 0, 40) . '********' . substr($alipaysettings['mode_a_alipay_public_key'], -40) : '';
showsetting('ec_alipay_public_key', 'settingsnew[mode_a_alipay_public_key]', $alipay_securitycodemask, 'textarea');
showtagfooter('tbody');
showtagheader('tbody', 'sign_model_02', $alipaysettings['ec_alipay_sign_mode']);
showsetting('ec_alipay_appid', 'settingsnew[mode_b_appid]', $alipaysettings['mode_b_appid'], 'text');
$alipay_securitycodemask = $alipaysettings['mode_b_app_private_key'] ? $alipaysettings['mode_b_app_private_key'][0] . '********' . substr($alipaysettings['mode_b_app_private_key'], -4) : '';
showsetting('ec_alipay_app_private_key', 'settingsnew[mode_b_app_private_key]', $alipay_securitycodemask, 'textarea', '', 0, lang('admincp', 'ec_alipay_app_private_key_b_comment'));
$alipay_securitycodemask = $alipaysettings['mode_b_app_cert'] ? substr($alipaysettings['mode_b_app_cert'], 0, 40) . '********' . substr($alipaysettings['mode_b_app_cert'], -40) : '';
showsetting('ec_alipay_app_cert', 'settingsnew[mode_b_app_cert]', $alipay_securitycodemask, 'textarea');
$alipay_securitycodemask = $alipaysettings['mode_b_alipay_cert'] ? substr($alipaysettings['mode_b_alipay_cert'], 0, 40) . '********' . substr($alipaysettings['mode_b_alipay_cert'], -40) : '';
showsetting('ec_alipay_alipay_cert', 'settingsnew[mode_b_alipay_cert]', $alipay_securitycodemask, 'textarea');
$alipay_securitycodemask = $alipaysettings['mode_b_alipay_root_cert'] ? substr($alipaysettings['mode_b_alipay_root_cert'], 0, 40) . '********' . substr($alipaysettings['mode_b_alipay_root_cert'], -40) : '';
showsetting('ec_alipay_alipay_root_cert', 'settingsnew[mode_b_alipay_root_cert]', $alipay_securitycodemask, 'textarea');
showtagfooter('tbody');
showsetting('ec_alipay_check', '', '',
'<a href="' . ADMINSCRIPT . '?action=ec&operation=alipay&checktype=credit" target="_blank">' . $lang['ec_alipay_checklink_credit'] . '</a><br />'
);
showtableheader('', 'notop');
showsubmit('alipaysubmit');
showtablefooter();
showformfooter();
} else {
$settingsnew = $_GET['settingsnew'];
foreach($settingsnew as $name => $value) {
if($value == $alipaysettings[$name] || strpos($value, '********') !== false) {
continue;
}
$value = daddslashes($value);
$alipaysettings[$name] = $value;
}
C::t('common_setting')->update_setting('ec_alipay', $alipaysettings);
updatecache('setting');
cpmsg('alipay_succeed', 'action=ec&operation=alipay', 'succeed');
}
} elseif($operation == 'wechat') {
$wechatsettings = C::t('common_setting')->fetch_setting('ec_wechat', true);
if(!empty($checktype)) {
if($checktype == 'credit') {
$return_url = $_G['siteurl'] . 'home.php?mod=spacecp&ac=credit';
$pay_url = payment::create_order('payment_credit', $lang['ec_alipay_checklink_credit'], $lang['ec_alipay_checklink_credit'], 1, $return_url);
ob_end_clean();
dheader('location: ' . $pay_url);
}
exit;
}
if(!submitcheck('wechatsubmit')) {
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'setting&operation=ec', 0),
array('nav_ec_qpay', 'ec&operation=qpay', 0),
array('nav_ec_wechat', 'ec&operation=wechat', 1),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0),
array('nav_ec_inviteorders', 'ec&operation=inviteorders', 0),
array('nav_ec_paymentorders', 'ec&operation=paymentorders', 0),
array('nav_ec_transferorders', 'ec&operation=transferorders', 0)
));
showtips('ec_wechat_tips');
showformheader('ec&operation=wechat');
showtableheader('', 'nobottom');
showtitle('ec_wechat');
showtagheader('tbody', 'alipay_wechat', true);
showsetting('ec_wechat_on', 'settingsnew[on]', $wechatsettings['on'], 'radio');
$wxpayment = payment::get('wechat');
$check = array();
$wechatsettings['ec_wechat_version'] ? $check['true'] = "checked" : $check['false'] = "checked";
$wechatsettings['ec_wechat_version'] ? $check['false'] = '' : $check['true'] = '';
$check['hidden1'] = ' onclick="$(\'api_version_2\').style.display = \'none\';$(\'api_version_3\').style.display = \'\';"';
$check['hidden0'] = ' onclick="$(\'api_version_2\').style.display = \'\';$(\'api_version_3\').style.display = \'none\';"';
$html = '<ul onmouseover="altStyle(this);"><li' . ($check['false'] ? ' class="checked"' : '') . '><input class="radio" type="radio" name="settingsnew[ec_wechat_version]" value="0" ' . $check['false'] . $check['hidden0'] . '>&nbsp;' . $lang['ec_wechat_version_2'] . '</li>';
if($wxpayment->v3_wechat_support()) {
$html .= '<li' . ($check['true'] ? ' class="checked"' : '') . '><input class="radio" type="radio" name="settingsnew[ec_wechat_version]" value="1" ' . $check['true'] . $check['hidden1'] . '>&nbsp;' . $lang['ec_wechat_version_3'] . '</li>';
} else {
$html .= '<li style="margin-left: 5px; color: red;">' . $lang['ec_wechat_version_3'] . '(' . $lang['ec_wechat_php_version_low'] . ')</li>';
}
$html .= '</ul>';
showsetting('ec_wechat_version', '', '', $html);
showsetting('ec_wechat_appid', 'settingsnew[appid]', $wechatsettings['appid'], 'text');
$wechat_securitycodemask = $wechatsettings['appsecret'] ? $wechatsettings['appsecret'][0] . '********' . substr($wechatsettings['appsecret'], -4) : '';
showsetting('ec_wechat_appsecret', 'settingsnew[appsecret]', $wechat_securitycodemask, 'text');
showsetting('ec_wechat_mch_id', 'settingsnew[mch_id]', $wechatsettings['mch_id'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'api_version_2', !$wechatsettings['ec_wechat_version']);
$wechat_securitycodemask = $wechatsettings['v1_key'] ? $wechatsettings['v1_key'][0] . '********' . substr($wechatsettings['v1_key'], -4) : '';
showsetting('ec_wechat_v1_key', 'settingsnew[v1_key]', $wechat_securitycodemask, 'text');
showsetting('ec_wechat_v1_cert', 'settingsnew[v1_cert_path]', $wechatsettings['v1_cert_path'], 'text', '', 0, lang('admincp', 'ec_wechat_v1_cert_comment', array('randomstr' => random(10))));
showtagfooter('tbody');
showtagheader('tbody', 'api_version_3', $wechatsettings['ec_wechat_version']);
$wechat_securitycodemask = $wechatsettings['v3_key'] ? $wechatsettings['v3_key'][0] . '********' . substr($wechatsettings['v3_key'], -4) : '';
showsetting('ec_wechat_v3_key', 'settingsnew[v3_key]', $wechat_securitycodemask, 'text');
$wechat_securitycodemask = $wechatsettings['v3_private_key'] ? substr($wechatsettings['v3_private_key'], 0, 40) . '********' . substr($wechatsettings['v3_private_key'], -40) : '';
showsetting('ec_wechat_v3_private_key', 'settingsnew[v3_private_key]', $wechat_securitycodemask, 'textarea');
$wechat_securitycodemask = $wechatsettings['v3_serial_no'] ? $wechatsettings['v3_serial_no'][0] . '********' . substr($wechatsettings['v3_serial_no'], -4) : '';
showsetting('ec_wechat_v3_serial_no', 'settingsnew[v3_serial_no]', $wechat_securitycodemask, 'text');
showtagfooter('tbody');
showsetting('ec_wechat_check', '', '',
'<a href="' . ADMINSCRIPT . '?action=ec&operation=wechat&checktype=credit" target="_blank">' . $lang['ec_wechat_checklink_credit'] . '</a><br />'
);
showtableheader('', 'notop');
showsubmit('wechatsubmit');
showtablefooter();
showformfooter();
} else {
$settingsnew = $_GET['settingsnew'];
foreach($settingsnew as $name => $value) {
if($value == $wechatsettings[$name] || strpos($value, '********') !== false) {
continue;
}
$value = daddslashes($value);
$wechatsettings[$name] = $value;
}
C::t('common_setting')->update_setting('ec_wechat', $wechatsettings);
updatecache('setting');
if($wechatsettings['ec_wechat_version'] && $wechatsettings['appid'] && $wechatsettings['mch_id'] && $wechatsettings['v3_key'] && $wechatsettings['v3_private_key'] && $wechatsettings['v3_serial_no']) {
$payment = payment::get('wechat');
$result = $payment->v3_wechat_certificates();
if($result['code'] == 200) {
$wechatsettings['v3_certificates'] = $result['data'];
}
C::t('common_setting')->update_setting('ec_wechat', $wechatsettings);
updatecache('setting');
}
cpmsg('wechat_succeed', 'action=ec&operation=wechat', 'succeed');
}
} elseif($operation == 'qpay') {
$qpaysettings = C::t('common_setting')->fetch_setting('ec_qpay', true);
if(!empty($checktype)) {
if($checktype == 'credit') {
$return_url = $_G['siteurl'] . 'home.php?mod=spacecp&ac=credit';
$pay_url = payment::create_order('payment_credit', $lang['ec_alipay_checklink_credit'], $lang['ec_alipay_checklink_credit'], 1, $return_url);
ob_end_clean();
dheader('location: ' . $pay_url);
}
exit;
}
if(!submitcheck('qpaysubmit')) {
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'setting&operation=ec', 0),
array('nav_ec_qpay', 'ec&operation=qpay', 1),
array('nav_ec_wechat', 'ec&operation=wechat', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0),
array('nav_ec_inviteorders', 'ec&operation=inviteorders', 0),
array('nav_ec_paymentorders', 'ec&operation=paymentorders', 0),
array('nav_ec_transferorders', 'ec&operation=transferorders', 0)
));
showtips('ec_qpay_tips');
showformheader('ec&operation=qpay');
showtableheader('', 'nobottom');
showtitle('ec_qpay');
showtagheader('tbody', 'alipay_wechat', true);
showsetting('ec_qpay_on', 'settingsnew[on]', $qpaysettings['on'], 'radio');
showsetting('ec_qpay_jsapi', 'settingsnew[jsapi]', $qpaysettings['jsapi'], 'radio');
showsetting('ec_qpay_appid', 'settingsnew[appid]', $qpaysettings['appid'], 'text');
showsetting('ec_qpay_mch_id', 'settingsnew[mch_id]', $qpaysettings['mch_id'], 'text');
showsetting('ec_qpay_op_user_id', 'settingsnew[op_user_id]', $qpaysettings['op_user_id'], 'text');
$qpay_securitycodemask = $qpaysettings['op_user_passwd'] ? $qpaysettings['op_user_passwd'][0] . '********' . substr($qpaysettings['op_user_passwd'], -4) : '';
showsetting('ec_qpay_op_user_passwd', 'settingsnew[op_user_passwd]', $qpay_securitycodemask, 'text');
showtagfooter('tbody');
showtagheader('tbody', 'api_version_2', true);
$qpay_securitycodemask = $qpaysettings['v1_key'] ? $qpaysettings['v1_key'][0] . '********' . substr($qpaysettings['v1_key'], -4) : '';
showsetting('ec_qpay_v1_key', 'settingsnew[v1_key]', $qpay_securitycodemask, 'text');
showsetting('ec_qpay_v1_cert', 'settingsnew[v1_cert_path]', $qpaysettings['v1_cert_path'], 'text', '', 0, lang('admincp', 'ec_qpay_v1_cert_comment', array('randomstr' => random(10))));
showtagfooter('tbody');
showsetting('ec_qpay_check', '', '',
'<a href="' . ADMINSCRIPT . '?action=ec&operation=qpay&checktype=credit" target="_blank">' . $lang['ec_qpay_checklink_credit'] . '</a><br />'
);
showtableheader('', 'notop');
showsubmit('qpaysubmit');
showtablefooter();
showformfooter();
} else {
$settingsnew = $_GET['settingsnew'];
foreach($settingsnew as $name => $value) {
if($value == $qpaysettings[$name] || strpos($value, '********') !== false) {
continue;
}
$value = daddslashes($value);
if($name == 'op_user_passwd') {
$value = md5($value);
}
$qpaysettings[$name] = $value;
}
C::t('common_setting')->update_setting('ec_qpay', $qpaysettings);
updatecache('setting');
cpmsg('qpay_succeed', 'action=ec&operation=qpay', 'succeed');
}
} elseif($operation == 'paymentorders') {
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'setting&operation=ec', 0),
array('nav_ec_qpay', 'ec&operation=qpay', 0),
array('nav_ec_wechat', 'ec&operation=wechat', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0),
array('nav_ec_inviteorders', 'ec&operation=inviteorders', 0),
array('nav_ec_paymentorders', 'ec&operation=paymentorders', 1),
array('nav_ec_transferorders', 'ec&operation=transferorders', 0)
));
if(submitcheck('querysubmit')) {
$order_id = intval($_GET['order_id']);
$channel = daddslashes($_GET['channel']);
$result = payment::query_order($channel, $order_id);
if($result['code'] == 200) {
cpmsg('payment_succeed', $_G['siteurl'] . ADMINSCRIPT . '?action=ec&operation=paymentorders', 'succeed');
} else {
cpmsg($result['message'], $_G['siteurl'] . ADMINSCRIPT . '?action=ec&operation=paymentorders', 'error');
}
} elseif($_GET['op'] == 'retry') {
$order_id = intval($_GET['order_id']);
$order = C::t('common_payment_order')->fetch($order_id);
$result = payment::retry_callback_order($order);
if($result['code'] == 200) {
cpmsg('payment_succeed', $_G['siteurl'] . ADMINSCRIPT . '?action=ec&operation=paymentorders', 'succeed');
} else {
cpmsg($result['message'], $_G['siteurl'] . ADMINSCRIPT . '?action=ec&operation=paymentorders', 'error');
}
} elseif($_GET['op'] == 'query') {
$order_id = intval($_GET['order_id']);
$order = C::t('common_payment_order')->fetch($order_id);
$channels = payment::channels();
$user = getuserbyuid($order['uid']);
showformheader('ec&operation=paymentorders');
showhiddenfields(array('order_id' => $order['id']));
showtableheader('ec_paymentorders_detail');
showsetting('ec_paymentorders_no', '', '', $order['out_biz_no']);
showsetting('ec_paymentorders_type', '', '', $order['type_name']);
showsetting('ec_paymentorders_desc', '', '', $order['subject'] . ($order['description'] ? '<br/>' . $order['description'] : ''));
showsetting('ec_paymentorders_user', '', '', $user['username'] . ' (' . $order['uid'] . ')' . '<br/>' . $order['clientip'] . ':' . $order['remoteport']);
showsetting('ec_paymentorders_amount', '', '', number_format($order['amount'] / 100, 2, '.', ','));
showsetting('ec_orders_submitdate', '', '', dgmdate($order['dateline']));
$channelradios = '<ul onmouseover="altStyle(this);">';
$channelindex = 0;
foreach($channels as $index => $channel) {
$channelradios .= '<li'.($channelindex === 0 ? ' class="checked"' : '').'><input class="radio" type="radio" name="channel" '.($channelindex === 0 ? 'checked' : '').' value="' . $channel['id'] . '">&nbsp;' . $channel['title'] . '</li>';
$channelindex++;
}
$channelradios .= '</ul>';
showsetting('ec_paymentorders_channel', '', '', $channelradios);
showtablefooter();
showsubmit('querysubmit', 'ec_paymentorders_op_status', '', $lang['ec_paymentorders_query_submit_tips']);
showtablefooter();
showformfooter();
} else {
$start_limit = ($page - 1) * $_G['tpp'];
echo '<style type="text/css">.order-status-0 td { color: #555; } .order-status-1 td { color: green; } .order-status-1 td a { color: #fe8080; } .order-status-2 td, .order-status-2 td a { color: #ccc; } .order-status-3 td { color: red; }</style>';
echo '<script src="static/js/calendar.js" type="text/javascript"></script>';
$queryparams = array(
'out_biz_no' => daddslashes($_GET['out_biz_no']),
'user' => daddslashes($_GET['user']),
'type' => daddslashes($_GET['type']),
'channel' => daddslashes($_GET['channel']),
'status' => daddslashes($_GET['status']),
'starttime' => daddslashes($_GET['starttime']),
'endtime' => daddslashes($_GET['endtime']),
);
$types = C::t('common_payment_order')->fetch_type_all();
$typeoptions = array();
$typeoptions[] = '<option value="">' . $lang['all'] . '</option>';
foreach($types as $k => $v) {
$typeoptions[] = "<option value=\"{$k}\"" . ($k == $queryparams['type'] ? ' selected' : '') . ">{$v}</option>";
}
showformheader('ec&operation=paymentorders');
showtableheader('ec_paymentorders_search');
showtablerow('', array(
'style="width:100px"', 'style="width:200px"',
'style="width:100px"', 'style="width:200px"',
'style="width:100px"', ''
),
array(
lang('admincp', 'ec_orders_search_id'), '<input type="text" class="txt" name="out_biz_no" value="' . $queryparams['out_biz_no'] . '" />',
lang('admincp', 'ec_paymentorders_user'), '<input type="text" class="txt" name="user" value="' . $queryparams['user'] . '" />',
lang('admincp', 'ec_paymentorders_type'), '<select name="type">' . implode('', $typeoptions) . '</select>',
)
);
$channels = payment::channels();
$channeloptions = array();
$channeloptions[] = '<option value="">' . $lang['all'] . '</option>';
foreach($channels as $channel) {
$channeloptions[] = '<option value="' . $channel['id'] . '"' . ($queryparams['channel'] == $channel['id'] ? ' selected' : '') . '>' . $channel['title'] . '</option>';
}
$statusoptions = array();
$statusoptions[] = '<option value="">' . $lang['all'] . '</option>';
$statusoptions[] = '<option value="0"' . ($queryparams['status'] === '0' ? ' selected' : '') . '>' . $lang['ec_paymentorders_status_0'] . '</option>';
$statusoptions[] = '<option value="1"' . ($queryparams['status'] === '1' ? ' selected' : '') . '>' . $lang['ec_paymentorders_status_1'] . '</option>';
$statusoptions[] = '<option value="2"' . ($queryparams['status'] === '2' ? ' selected' : '') . '>' . $lang['ec_paymentorders_status_2'] . '</option>';
showtablerow('', array(),
array(
lang('admincp', 'ec_paymentorders_channel'), '<select name="channel">' . implode('', $channeloptions) . '</select>',
lang('admincp', 'ec_paymentorders_status'), '<select name="status">' . implode('', $statusoptions) . '</select>',
lang('admincp', 'ec_paymentorders_date'), '<input type="text" class="txt" name="starttime" value="' . $queryparams['starttime'] . '" style="width: 108px;" onclick="showcalendar(event, this)"> - <input type="text" class="txt" name="endtime" value="' . $queryparams['endtime'] . '" style="width: 108px;" onclick="showcalendar(event, this)">',
)
);
showtablefooter();
showtableheader('', 'notop');
showsubmit('searchsubmit');
showtablefooter();
if($queryparams['user']) {
if(preg_match('/^\d+$/', $queryparams['user'])) {
$queryparams['uid'] = $queryparams['user'];
} else {
$user = C::t('common_member')->fetch_uid_by_username($queryparams['user']);
if($user) {
$queryparams['uid'] = $user['uid'];
} else {
$queryparams['uid'] = -1;
}
}
}
$ordercount = C::t('common_payment_order')->count_by_search($queryparams['uid'], $queryparams['type'], $queryparams['starttime'], $queryparams['endtime'], $queryparams['out_biz_no'], $queryparams['channel'], $queryparams['status']);
$multipage = multi($ordercount, $_G['tpp'], $page, ADMINSCRIPT . "?action=ec&operation=paymentorders&" . http_build_query($queryparams));
$tdstyles = array(
'style="width: 220px;"',
'style="width: 100px; text-align: center"',
'',
'style="width: 120px;"',
'style="width: 100px; text-align: center"',
'style="width: 120px; text-align: right"',
'style="width: 100px; text-align: center"',
'style="width: 100px; text-align: right"',
'style="width: 100px; text-align: right"',
'style="width: 110px; text-align: right"'
);
showtableheader('result');
showsubtitle(array('ec_paymentorders_no', 'ec_paymentorders_type', 'ec_paymentorders_desc', 'ec_paymentorders_buyer', 'ec_paymentorders_channel', 'ec_paymentorders_amount', 'ec_paymentorders_status', 'ec_orders_submitdate', 'ec_orders_confirmdate', ''), 'header', $tdstyles);
if($ordercount > 0) {
$order_list = C::t('common_payment_order')->fetch_all_by_search($queryparams['uid'], $queryparams['type'], $queryparams['starttime'], $queryparams['endtime'], $queryparams['out_biz_no'], $queryparams['channel'], $queryparams['status'], $start_limit, $_G['tpp']);
$refund_list = C::t('common_payment_refund')->sum_by_orders(array_keys($order_list));
foreach($order_list as $order) {
$user = getuserbyuid($order['uid']);
if(!$order['status'] && $order['expire_time'] < time()) {
$order['status'] = 2;
} elseif($order['status'] == 1 && $refund_list[$order['id']]) {
$order['status'] = 3;
$order['refund_amount'] = $refund_list[$order['id']]['amount'];
}
$amountstr = number_format($order['amount'] / 100, 2, '.', ',');
if($order['status'] == 3) {
$amountstr .= '<br/>' . $lang['ec_paymentorders_refund_amount'] . ': ' . number_format($order['refund_amount'] / 100, 2, '.', ',');
}
$operations = '';
if(in_array($order['status'], array(0, 2))) {
$operations .= '<a href="' . ADMINSCRIPT . '?action=ec&operation=paymentorders&op=query&order_id=' . $order['id'] . '">' . $lang['ec_paymentorders_op_status'] . '</a>';
} elseif($order['status'] == 1 && !$order['callback_status']) {
$operations = '<a href="' . ADMINSCRIPT . '?action=ec&operation=paymentorders&op=retry&order_id=' . $order['id'] . '">'.$lang['ec_paymentorders_callback_tips'].'</a>';
}
showtablerow('class="order-status-' . $order['status'] . '"', $tdstyles, array(
$order['out_biz_no'],
$order['type_name'],
$order['subject'] . ($order['description'] ? '<br/>' . $order['description'] : ''),
$user['username'] . ' (' . $order['uid'] . ')' . '<br/>' . $order['clientip'] . ':' . $order['remoteport'],
$channels[$order['channel']]['title'],
$amountstr,
$lang['ec_paymentorders_status_' . $order['status']],
dgmdate($order['dateline']),
$order['payment_time'] ? dgmdate($order['payment_time']) : 'N/A',
$operations
));
}
showsubmit('', '', '', '', $multipage);
} else {
showtablerow('', array('class="center" colspan="25"'), array($lang['ec_paymentorders_no_data']));
}
showtablefooter();
showformfooter();
}
} elseif($operation == 'transferorders') {
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'setting&operation=ec', 0),
array('nav_ec_qpay', 'ec&operation=qpay', 0),
array('nav_ec_wechat', 'ec&operation=wechat', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0),
array('nav_ec_inviteorders', 'ec&operation=inviteorders', 0),
array('nav_ec_paymentorders', 'ec&operation=paymentorders', 0),
array('nav_ec_transferorders', 'ec&operation=transferorders', 1)
));
if($_GET['op'] == 'query') {
$transfer_no = daddslashes($_GET['transfer_no']);
$result = payment::transfer_status($transfer_no);
if($result['code'] == 200) {
cpmsg('payment_transfer_succeed', $_G['siteurl'] . ADMINSCRIPT . '?action=ec&operation=transferorders&out_biz_no=' . $transfer_no, 'succeed');
} else {
cpmsg($result['message'], $_G['siteurl'] . ADMINSCRIPT . '?action=ec&operation=transferorders&out_biz_no=' . $transfer_no, 'error');
}
} elseif($_GET['op'] == 'retry') {
$order_id = intval($_GET['order_id']);
$order = C::t('common_payment_transfer')->fetch($order_id);
$result = payment::transfer($order['channel'], $order['out_biz_no'], $order['amount'], $order['uid'], $order['realname'], $order['account'], $order['subject'], $order['description']);
if($result['code'] == 200) {
cpmsg('payment_transfer_succeed', $_G['siteurl'] . ADMINSCRIPT . '?action=ec&operation=transferorders&out_biz_no=' . $order['out_biz_no'], 'succeed');
} else {
cpmsg($result['message'], $_G['siteurl'] . ADMINSCRIPT . '?action=ec&operation=transferorders&out_biz_no=' . $order['out_biz_no'], 'error');
}
} else {
$start_limit = ($page - 1) * $_G['tpp'];
echo '<style type="text/css">.order-status-1 td { color: #555; } .order-status-2 td { color: green; } .order-status-3 td { color: red; }</style>';
echo '<script src="static/js/calendar.js" type="text/javascript"></script>';
$queryparams = array(
'out_biz_no' => daddslashes($_GET['out_biz_no']),
'user' => daddslashes($_GET['user']),
'channel' => daddslashes($_GET['channel']),
'status' => daddslashes($_GET['status']),
'starttime' => daddslashes($_GET['starttime']),
'endtime' => daddslashes($_GET['endtime']),
);
showformheader('ec&operation=transferorders');
showtableheader('ec_transferorders_search');
showtablerow('', array(),
array(
lang('admincp', 'ec_orders_search_id'), '<input type="text" class="txt" name="out_biz_no" value="' . $queryparams['out_biz_no'] . '" />',
lang('admincp', 'ec_transferorders_user'), '<input type="text" class="txt" name="user" value="' . $queryparams['user'] . '" />',
)
);
$channels = payment::channels();
$channeloptions = array();
$channeloptions[] = '<option value="">' . $lang['all'] . '</option>';
foreach($channels as $channel) {
$channeloptions[] = '<option value="' . $channel['id'] . '"' . ($queryparams['channel'] == $channel['id'] ? ' selected' : '') . '>' . $channel['title'] . '</option>';
}
$statusoptions = array();
$statusoptions[] = '<option value="">' . $lang['all'] . '</option>';
$statusoptions[] = '<option value="0"' . ($queryparams['status'] === '1' ? ' selected' : '') . '>' . $lang['ec_transferorders_status_1'] . '</option>';
$statusoptions[] = '<option value="1"' . ($queryparams['status'] === '2' ? ' selected' : '') . '>' . $lang['ec_transferorders_status_2'] . '</option>';
$statusoptions[] = '<option value="2"' . ($queryparams['status'] === '3' ? ' selected' : '') . '>' . $lang['ec_transferorders_status_3'] . '</option>';
showtablerow('', array(
'style="width:100px"', 'style="width:200px"',
'style="width:100px"', 'style="width:200px"',
'style="width:100px"', ''
),
array(
lang('admincp', 'ec_transferorders_channel'), '<select name="channel">' . implode('', $channeloptions) . '</select>',
lang('admincp', 'ec_paymentorders_status'), '<select name="status">' . implode('', $statusoptions) . '</select>',
lang('admincp', 'ec_paymentorders_date'), '<input type="text" class="txt" name="starttime" value="' . $queryparams['starttime'] . '" style="width: 108px;" onclick="showcalendar(event, this)"> - <input type="text" class="txt" name="endtime" value="' . $queryparams['endtime'] . '" style="width: 108px;" onclick="showcalendar(event, this)">',
)
);
showtablefooter();
showtableheader('', 'notop');
showsubmit('searchsubmit');
showtablefooter();
if($queryparams['user']) {
if(preg_match('/^\d+$/', $queryparams['user'])) {
$queryparams['uid'] = $queryparams['user'];
} else {
$user = C::t('common_member')->fetch_uid_by_username($queryparams['user']);
if($user) {
$queryparams['uid'] = $user['uid'];
} else {
$queryparams['uid'] = -1;
}
}
}
$ordercount = C::t('common_payment_transfer')->count_by_search($queryparams['uid'], $queryparams['starttime'], $queryparams['endtime'], $queryparams['out_biz_no'], $queryparams['channel'], $queryparams['status']);
$multipage = multi($ordercount, $_G['tpp'], $page, ADMINSCRIPT . "?action=ec&operation=transferorders&" . http_build_query($queryparams));
$tdstyles = array(
'style="width: 220px;"',
'style="width: 100px; text-align: center"',
'style="width: 100px; text-align: center"',
'',
'style="width: 130px; text-align: right"',
'style="width: 100px; text-align: center"',
'',
'style="width: 100px; text-align: right"',
'style="width: 100px; text-align: right"',
'style="width: 25px; text-align: right"'
);
showtableheader('result');
showsubtitle(array('ec_paymentorders_no', 'ec_transferorders_user', 'ec_transferorders_channel', 'ec_transferorders_desc', 'ec_paymentorders_amount', 'ec_paymentorders_status', 'ec_transferorders_error', 'ec_orders_submitdate', 'ec_orders_confirmdate', ''), 'header', $tdstyles);
if($ordercount > 0) {
$order_list = C::t('common_payment_transfer')->fetch_all_by_search($queryparams['uid'], $queryparams['type'], $queryparams['starttime'], $queryparams['endtime'], $queryparams['out_biz_no'], $queryparams['channel'], $queryparams['status'], $start_limit, $_G['tpp']);
foreach($order_list as $order) {
$user = getuserbyuid($order['uid']);
if($order['status'] == 1) {
$operations = '<a href="' . ADMINSCRIPT . '?action=ec&operation=transferorders&op=query&transfer_no=' . $order['out_biz_no'] . '">' . $lang['ec_paymentorders_op_status'] . '</a>';
} elseif($order['status'] == 3) {
$operations = '<a href="' . ADMINSCRIPT . '?action=ec&operation=transferorders&op=retry&order_id=' . $order['id'] . '">' . $lang['ec_transferorders_op_retry'] . '</a>';
}
showtablerow('class="order-status-' . $order['status'] . '"', $tdstyles, array(
$order['out_biz_no'],
$user['username'] . ' (' . $order['uid'] . ')' . '<br/>' . $order['clientip'] . ':' . $order['remoteport'],
$channels[$order['channel']]['title'],
$order['subject'] . ($order['description'] ? '<br/>' . $order['description'] : ''),
number_format($order['amount'] / 100, 2, '.', ','),
$lang['ec_transferorders_status_' . $order['status']],
$order['status'] == 3 ? $order['error'] : '',
dgmdate($order['dateline']),
$order['trade_time'] ? dgmdate($order['trade_time']) : 'N/A',
$operations
));
}
showsubmit('', '', '', '', $multipage);
} else {
showtablerow('', array('class="center" colspan="25"'), array($lang['ec_transferorders_no_data']));
}
showtablefooter();
showformfooter();
}
} elseif($operation == 'orders') {
$orderurl = array(
'alipay' => 'https://www.alipay.com/trade/query_trade_detail.htm?trade_no=',
'tenpay' => 'https://www.tenpay.com/med/tradeDetail.shtml?trans_id=',
);
if(!$_G['setting']['creditstrans'] || !$_G['setting']['ec_ratio']) {
cpmsg('orders_disabled', '', 'error');
}
if(!submitcheck('ordersubmit')) {
echo '<script type="text/javascript" src="' . STATICURL . 'js/calendar.js"></script>';
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'setting&operation=ec', 0),
array('nav_ec_qpay', 'ec&operation=qpay', 0),
array('nav_ec_wechat', 'ec&operation=wechat', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 1),
array('nav_ec_tradelog', 'tradelog', 0),
array('nav_ec_inviteorders', 'ec&operation=inviteorders', 0),
array('nav_ec_paymentorders', 'ec&operation=paymentorders', 0),
array('nav_ec_transferorders', 'ec&operation=transferorders', 0)
));
showtips('ec_orders_tips');
showtagheader('div', 'ordersearch', !submitcheck('searchsubmit', 1));
showformheader('ec&operation=orders');
showtableheader('ec_orders_search');
showsetting('ec_orders_search_status', array('orderstatus', array(
array('', $lang['ec_orders_search_status_all']),
array(1, $lang['ec_orders_search_status_pending']),
array(2, $lang['ec_orders_search_status_auto_finished']),
array(3, $lang['ec_orders_search_status_manual_finished'])
)), intval($orderstatus), 'select');
showsetting('ec_orders_search_id', 'orderid', $orderid, 'text');
showsetting('ec_orders_search_users', 'users', $users, 'text');
showsetting('ec_orders_search_buyer', 'buyer', $buyer, 'text');
showsetting('ec_orders_search_admin', 'admin', $admin, 'text');
showsetting('ec_orders_search_submit_date', array('sstarttime', 'sendtime'), array($sstarttime, $sendtime), 'daterange');
showsetting('ec_orders_search_confirm_date', array('cstarttime', 'cendtime'), array($cstarttime, $cendtime), 'daterange');
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
if(submitcheck('searchsubmit', 1)) {
$start_limit = ($page - 1) * $_G['tpp'];
$ordercount = C::t('forum_order')->count_by_search(null, $_GET['orderstatus'], $_GET['orderid'], null, ($_GET['users'] ? explode(',', str_replace(' ', '', $_GET['users'])) : null), $_GET['buyer'], $_GET['admin'], strtotime($_GET['sstarttime']), strtotime($_GET['sendtime']), strtotime($_GET['cstarttime']), strtotime($_GET['cendtime']));
$multipage = multi($ordercount, $_G['tpp'], $page, ADMINSCRIPT."?action=ec&operation=orders&searchsubmit=yes&orderstatus={$_GET['orderstatus']}&orderid={$_GET['orderid']}&users={$_GET['users']}&buyer={$_GET['buyer']}&admin={$_GET['admin']}&sstarttime={$_GET['sstarttime']}&sendtime={$_GET['sendtime']}&cstarttime={$_GET['cstarttime']}&cendtime={$_GET['cendtime']}");
showtagheader('div', 'orderlist', true);
showformheader('ec&operation=orders');
showtableheader('result');
showsubtitle(array('', 'ec_orders_id', 'ec_orders_status', 'ec_orders_buyer', 'ec_orders_amount', 'ec_orders_price', 'ec_orders_submitdate', 'ec_orders_confirmdate'));
foreach(C::t('forum_order')->fetch_all_by_search(null, $_GET['orderstatus'], $_GET['orderid'], null, ($_GET['users'] ? explode(',', str_replace(' ', '', $_GET['users'])) : null), $_GET['buyer'], $_GET['admin'], strtotime($_GET['sstarttime']), strtotime($_GET['sendtime']), strtotime($_GET['cstarttime']), strtotime($_GET['cendtime']), $start_limit, $_G['tpp']) as $order) {
switch($order['status']) {
case 1: $order['orderstatus'] = $lang['ec_orders_search_status_pending']; break;
case 2: $order['orderstatus'] = '<b>'.$lang['ec_orders_search_status_auto_finished'].'</b>'; break;
case 3: $order['orderstatus'] = '<b>'.$lang['ec_orders_search_status_manual_finished'].'</b><br />(<a href="home.php?mod=space&username='.rawurlencode($order['admin']).'" target="_blank">'.$order['admin'].'</a>)'; break;
}
$order['submitdate'] = dgmdate($order['submitdate']);
$order['confirmdate'] = $order['confirmdate'] ? dgmdate($order['confirmdate']) : 'N/A';
list($orderid, $apitype) = explode("\t", $order['buyer']);
$apitype = $apitype ? $apitype : 'alipay';
$orderid = '<a href="'.$orderurl[$apitype].$orderid.'" target="_blank">'.$orderid.'</a>';
showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"validate[]\" value=\"{$order['orderid']}\" ".($order['status'] != 1 ? 'disabled' : '').">",
"{$order['orderid']}<br />$orderid",
$order['orderstatus'],
"<a href=\"home.php?mod=space&uid={$order['uid']}\" target=\"_blank\">{$order['username']}</a>",
"{$_G['setting']['extcredits'][$_G['setting']['creditstrans']]['title']} {$order['amount']} {$_G['setting']['extcredits'][$_G['setting']['creditstrans']]['unit']}",
"{$lang['rmb']} {$order['price']} {$lang['rmb_yuan']}",
$order['submitdate'],
$order['confirmdate']
));
}
showsubmit('ordersubmit', 'submit', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'validate\')" /><label for="chkall">'.cplang('ec_orders_validate').'</label>', '<a href="#" onclick="$(\'orderlist\').style.display=\'none\';$(\'ordersearch\').style.display=\'\';">'.cplang('research').'</a>', $multipage);
showtablefooter();
showformfooter();
showtagfooter('div');
}
} else {
$numvalidate = 0;
if($_GET['validate']) {
$orderids = array();
$confirmdate = dgmdate(TIMESTAMP);
foreach(C::t('forum_order')->fetch_all_order($_GET['validate'], '1') as $order) {
updatemembercount($order['uid'], array($_G['setting']['creditstrans'] => $order['amount']));
$orderids[] = $order['orderid'];
$submitdate = dgmdate($order['submitdate']);
notification_add($order['uid'], 'system', 'addfunds', array(
'orderid' => $order['orderid'],
'price' => $order['price'],
'from_id' => 0,
'from_idtype' => 'buycredit',
'value' => $_G['setting']['extcredits'][$_G['setting']['creditstrans']]['title'].' '.$order['amount'].' '.$_G['setting']['extcredits'][$_G['setting']['creditstrans']]['unit']
), 1);
}
if($orderids) {
C::t('forum_order')->update($orderids, array('status' => '3', 'admin' => $_G['username'], 'confirmdate' => $_G['timestamp']));
}
}
cpmsg('orders_validate_succeed', "action=ec&operation=orders&searchsubmit=yes&orderstatus={$_GET['orderstatus']}&orderid={$_GET['orderid']}&users={$_GET['users']}&buyer={$_GET['buyer']}&admin={$_GET['admin']}&sstarttime={$_GET['sstarttime']}&sendtime={$_GET['sendtime']}&cstarttime={$_GET['cstarttime']}&cendtime={$_GET['cendtime']}", 'succeed');
}
} elseif($operation == 'credit') {
$defaultrank = array(
1 => 4,
2 => 11,
3 => 41,
4 => 91,
5 => 151,
6 => 251,
7 => 501,
8 => 1001,
9 => 2001,
10 => 5001,
11 => 10001,
12 => 20001,
13 => 50001,
14 => 100001,
15 => 200001
);
if(!submitcheck('creditsubmit')) {
$ec_credit = C::t('common_setting')->fetch_setting('ec_credit', true);
$ec_credit = $ec_credit ? $ec_credit : array(
'maxcreditspermonth' => '6',
'rank' => $defaultrank
);
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'setting&operation=ec', 0),
array('nav_ec_qpay', 'ec&operation=qpay', 0),
array('nav_ec_wechat', 'ec&operation=wechat', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_credit', 'ec&operation=credit', 1),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0),
array('nav_ec_inviteorders', 'ec&operation=inviteorders', 0),
array('nav_ec_paymentorders', 'ec&operation=paymentorders', 0),
array('nav_ec_transferorders', 'ec&operation=transferorders', 0)
));
showtips('ec_credit_tips');
showformheader('ec&operation=credit');
showtableheader('ec_credit', 'nobottom');
showsetting('ec_credit_maxcreditspermonth', 'ec_creditnew[maxcreditspermonth]', $ec_credit['maxcreditspermonth'], 'text');
showtablefooter('</tbody>');
showtableheader('ec_credit_rank', 'notop fixpadding');
showsubtitle(array('ec_credit_rank', 'ec_credit_between', 'ec_credit_sellericon', 'ec_credit_buyericon'));
$staticurl = STATICURL;
foreach($ec_credit['rank'] as $rank => $mincredits) {
showtablerow('', '', array(
$rank,
'<input type="text" class="txt" size="6" name="ec_creditnew[rank]['.$rank.']" value="'.$mincredits.'" /> ~ '.$ec_credit['rank'][$rank + 1],
"<img src=\"{$staticurl}image/traderank/seller/$rank.gif\" border=\"0\">",
"<img src=\"{$staticurl}image/traderank/buyer/$rank.gif\" border=\"0\">"
));
}
showsubmit('creditsubmit');
showtablefooter();
showformfooter();
} else {
$ec_creditnew = $_GET['ec_creditnew'];
$ec_creditnew['maxcreditspermonth'] = intval($ec_creditnew['maxcreditspermonth']);
if(is_array($ec_creditnew['rank'])) {
foreach($ec_creditnew['rank'] as $rank => $mincredits) {
$mincredits = intval($mincredits);
if($rank == 1 && $mincredits <= 0) {
cpmsg('ecommerce_invalidcredit', '', 'error');
} elseif($rank > 1 && $mincredits <= $ec_creditnew['rank'][$rank - 1]) {
cpmsg('ecommerce_must_larger', '', 'error', array('rank' => $rank));
}
$ec_creditnew['rank'][$rank] = $mincredits;
}
} else {
$ec_creditnew['rank'] = $defaultrank;
}
C::t('common_setting')->update_setting('ec_credit', $ec_creditnew);
updatecache('setting');
cpmsg('ec_credit_succeed', 'action=ec&operation=credit', 'succeed');
}
} elseif($operation == 'inviteorders') {
if(!submitcheck('ordersubmit')) {
$start_limit = ($page - 1) * $_G['tpp'];
$orderurl = array(
'alipay' => 'https://www.alipay.com/trade/query_trade_detail.htm?trade_no=',
'tenpay' => 'https://www.tenpay.com/med/tradeDetail.shtml?trans_id=',
);
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'setting&operation=ec', 0),
array('nav_ec_qpay', 'ec&operation=qpay', 0),
array('nav_ec_wechat', 'ec&operation=wechat', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0),
array('nav_ec_inviteorders', 'ec&operation=inviteorders', 1),
array('nav_ec_paymentorders', 'ec&operation=paymentorders', 0),
array('nav_ec_transferorders', 'ec&operation=transferorders', 0)
));
$ordercount = C::t('forum_order')->count_by_search(0, $_GET['orderstatus'], $_GET['orderid'], $_GET['email']);
$multipage = multi($ordercount, $_G['tpp'], $page, ADMINSCRIPT."?action=ec&operation=inviteorders&orderstatus={$_GET['orderstatus']}&orderid={$_GET['orderid']}&email={$_GET['email']}");
showtagheader('div', 'orderlist', TRUE);
showformheader('ec&operation=inviteorders');
showtableheader('ec_inviteorders_search');
$_G['showsetting_multirow'] = 1;
showsetting('ec_orders_search_status', array('orderstatus', array(
array('', $lang['ec_orders_search_status_all']),
array(1, $lang['ec_orders_search_status_pending']),
array(2, $lang['ec_orders_search_status_auto_finished'])
)), intval($_GET['orderstatus']), 'select');
showsetting('ec_orders_search_id', 'orderid', $_GET['orderid'], 'text');
showsetting('ec_orders_search_email', 'email', $_GET['email'], 'text');
showsubmit('searchsubmit', 'submit');
showtablefooter();
showtableheader('result');
showsubtitle(array('', 'ec_orders_id', 'ec_inviteorders_status', 'ec_inviteorders_buyer', 'ec_orders_amount', 'ec_orders_price', 'ec_orders_submitdate', 'ec_orders_confirmdate'));
foreach(C::t('forum_order')->fetch_all_by_search(0, $_GET['orderstatus'], $_GET['orderid'], $_GET['email'], null, null, null, null, null, null, null, $start_limit, $_G['tpp']) as $order) {
switch($order['status']) {
case 1: $order['orderstatus'] = $lang['ec_orders_search_status_pending']; break;
case 2: $order['orderstatus'] = '<b>'.$lang['ec_orders_search_status_auto_finished'].'</b>'; break;
case 3: $order['orderstatus'] = '<b>'.$lang['ec_orders_search_status_manual_finished'].'</b><br />(<a href="home.php?mod=space&username='.rawurlencode($order['admin']).'" target="_blank">'.$order['admin'].'</a>)'; break;
}
$order['submitdate'] = dgmdate($order['submitdate']);
$order['confirmdate'] = $order['confirmdate'] ? dgmdate($order['confirmdate']) : 'N/A';
list($orderid, $apitype) = explode("\t", $order['buyer']);
$apitype = $apitype ? $apitype : 'alipay';
$orderid = '<a href="'.$orderurl[$apitype].$orderid.'" target="_blank">'.$orderid.'</a>';
showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"validate[]\" value=\"{$order['orderid']}\" ".($order['status'] != 1 ? 'disabled' : '').">",
"{$order['orderid']}<br />$orderid",
$order['orderstatus'],
"{$order['email']}<br>{$order['ip']}",
$order['amount'],
"{$lang['rmb']} {$order['price']} {$lang['rmb_yuan']}",
$order['submitdate'],
$order['confirmdate']
));
}
showtablerow('', array('colspan="7"'), array($multipage));
showsubmit('ordersubmit', 'ec_orders_validate', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'validate\')" />');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
if($_GET['validate']) {
if(C::t('forum_order')->fetch_all_order($_GET['validate'], '1')) {
C::t('forum_order')->update($_GET['validate'], array('status' => '3', 'admin' => $_G['username'], 'confirmdate' => $_G['timestamp']));
}
}
cpmsg('orders_validate_succeed', "action=ec&operation=inviteorders&orderstatus={$_GET['orderstatus']}&orderid={$_GET['orderid']}&email={$_GET['email']}", 'succeed');
}
}
?>

View File

@@ -0,0 +1,170 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_faq.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = $operation ? $operation : 'list';
if($operation == 'list') {
if(!submitcheck('faqsubmit')) {
shownav('extended', 'faq');
showsubmenu('faq');
showformheader('faq&operation=list');
showtableheader();
echo '<tr><th class="td25"></th><th class="td25"><strong>'.$lang['display_order'].'</stong></th><th class="td25"><strong>'.$lang['faq_thread'].'</strong></th><th></th></tr>';
$faqparent = $faqsub = array();
$faqlists = $faqselect = '';
foreach(C::t('forum_faq')->fetch_all_by_fpid() as $faq) {
if(empty($faq['fpid'])) {
$faqparent[$faq['id']] = $faq;
$faqselect .= "<option value=\"{$faq['id']}\">{$faq['title']}</option>";
} else {
$faqsub[$faq['fpid']][] = $faq;
}
}
foreach($faqparent as $parent) {
$disabled = !empty($faqsub[$parent['id']]) ? 'disabled' : '';
showtablerow('', array('', 'class="td23 td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"{$parent['id']}\" $disabled>",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[{$parent['id']}]\" value=\"{$parent['displayorder']}\">",
"<div class=\"parentnode\"><input type=\"text\" class=\"txt\" size=\"30\" name=\"title[{$parent['id']}]\" value=\"".dhtmlspecialchars($parent['title'])."\"></div>",
"<a href=\"".ADMINSCRIPT."?action=faq&operation=detail&id={$parent['id']}\" class=\"act\">".$lang['detail']."</a>"
));
if(!empty($faqsub[$parent['id']])) {
foreach($faqsub[$parent['id']] as $sub) {
showtablerow('', array('', 'class="td23 td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"{$sub['id']}\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[{$sub['id']}]\" value=\"{$sub['displayorder']}\">",
"<div class=\"node\"><input type=\"text\" class=\"txt\" size=\"30\" name=\"title[{$sub['id']}]\" value=\"".dhtmlspecialchars($sub['title'])."\"></div>",
"<a href=\"".ADMINSCRIPT."?action=faq&operation=detail&id={$sub['id']}\" class=\"act\">".$lang['detail']."</a>"
));
}
}
echo '<tr><td></td><td></td><td colspan="2"><div class="lastnode"><a href="###" onclick="addrow(this, 1, '.$parent['id'].')" class="addtr">'.cplang('faq_additem').'</a></div></td></tr>';
}
echo '<tr><td></td><td></td><td colspan="2"><div><a href="###" onclick="addrow(this, 0, 0)" class="addtr">'.cplang('faq_addcat').'</a></div></td></tr>';
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[[1,''], [1,'<input name="newdisplayorder[]" value="" size="3" type="text" class="txt">', 'td25'], [1, '<input name="newtitle[]" value="" size="30" type="text" class="txt">'], [1, '<input type="hidden" name="newfpid[]" value="0" />']],
[[1,''], [1,'<input name="newdisplayorder[]" value="" size="3" type="text" class="txt">', 'td25'], [1, '<div class=\"node\"><input name="newtitle[]" value="" size="30" type="text" class="txt"></div>'], [1, '<input type="hidden" name="newfpid[]" value="{1}" />']]
];
</script>
EOT;
showsubmit('faqsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($_GET['delete']) {
C::t('forum_faq')->delete($_GET['delete']);
}
if(is_array($_GET['title'])) {
foreach($_GET['title'] as $id => $val) {
C::t('forum_faq')->update($id, array(
'displayorder' => $_GET['displayorder'][$id],
'title' => $_GET['title'][$id]
));
}
}
if(is_array($_GET['newtitle'])) {
foreach($_GET['newtitle'] as $k => $v) {
$v = trim($v);
if($v) {
C::t('forum_faq')->insert(array(
'fpid' => intval($_GET['newfpid'][$k]),
'displayorder' => intval($_GET['newdisplayorder'][$k]),
'title' => $v
));
}
}
}
cpmsg('faq_list_update', 'action=faq&operation=list', 'succeed');
}
} elseif($operation == 'detail') {
$id = $_GET['id'];
if(!submitcheck('detailsubmit')) {
$faq = C::t('forum_faq')->fetch($id);
if(!$faq) {
cpmsg('faq_nonexistence', '', 'error');
}
foreach(C::t('forum_faq')->fetch_all_by_fpid(0) as $parent) {
$faqselect .= "<option value=\"{$parent['id']}\" ".($faq['fpid'] == $parent['id'] ? 'selected' : '').">{$parent['title']}</option>";
}
shownav('extended', 'faq');
showsubmenu('faq');
showformheader("faq&operation=detail&id=$id");
showtableheader();
showtitle('faq_edit');
showsetting('faq_title', 'titlenew', $faq['title'], 'text');
if(!empty($faq['fpid'])) {
showsetting('faq_sortup', '', '', '<select name="fpidnew"><option value=\"\">'.$lang['none'].'</option>'.$faqselect.'</select>');
showsetting('faq_identifier', 'identifiernew', $faq['identifier'], 'text');
showsetting('faq_keywords', 'keywordnew', $faq['keyword'], 'text');
showsetting('faq_content', 'messagenew', $faq['message'], 'textarea');
}
showsubmit('detailsubmit');
showtablefooter();
showformfooter();
} else {
if(!$_GET['titlenew']) {
cpmsg('faq_no_title', '', 'error');
}
if(!empty($_GET['identifiernew'])) {
if(C::t('forum_faq')->check_identifier($_GET['identifiernew'], $id)) {
cpmsg('faq_identifier_invalid', '', 'error');
}
}
if(strlen($_GET['keywordnew']) > 50) {
cpmsg('faq_keyword_toolong', '', 'error');
}
$fpidnew = $_GET['fpidnew'] ? intval($_GET['fpidnew']) : 0;
$titlenew = trim($_GET['titlenew']);
$messagenew = trim($_GET['messagenew']);
$identifiernew = trim($_GET['identifiernew']);
$keywordnew = trim($_GET['keywordnew']);
C::t('forum_faq')->update($id, array(
'fpid' => $fpidnew,
'identifier' => $identifiernew,
'keyword' => $keywordnew,
'title' => $titlenew,
'message' => $messagenew,
));
cpmsg('faq_list_update', 'action=faq&operation=list', 'succeed');
}
}
?>

View File

@@ -0,0 +1,341 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_feed.php 31634 2012-09-17 06:43:39Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = $operation ? $operation : 'search';
shownav('topic', 'nav_feed');
$anchor = in_array($operation, array('search', 'global')) ? $operation : 'search';
$current = array($anchor => 1);
showsubmenu('nav_feed', array(
array('nav_feed', 'feed', $current['search']),
array('feed_global', 'feed&operation=global', $current['global']),
));
if($operation == 'global') {
if(!submitcheck('globalsubmit')) {
$feedid = intval($_GET['feedid']);
$feed = array();
if($feedid) {
$feed = C::t('home_feed')->fetch_feed('', '', '', $feedid);
if($feed['uid']) {
require_once libfile('function/feed');
$feed = mkfeed($feed);
}
$feed['body_template'] = dhtmlspecialchars($feed['body_template']);
$feed['body_general'] = dhtmlspecialchars($feed['body_general']);
$feed['dateline'] = dgmdate($feed['dateline'], 'Y-m-d H:i');
}
if(empty($feed['dateline'])) {
$feed['dateline'] = dgmdate($_G['timestamp'], 'Y-m-d H:i');
}
showformheader('feed&operation=global', $feed['uid'] ? '' : 'onsubmit="edit_save();"');
echo '<script type="text/javascript" src="'.STATICURL.'image/editor/editor_function.js"></script>';
echo "<input type=\"hidden\" name=\"feednew[feedid]\" value=\"{$feed['feedid']}\" /><input type=\"hidden\" name=\"{feednew['feeduid']}\" value=\"{$feed['uid']}\" />";
showtableheader();
if(empty($feed['uid'])) {
showsetting('feed_global_title', 'feednew[title_template]', $feed['title_template'], 'text');
$src = 'home.php?mod=editor&charset='.CHARSET.'&allowhtml=1&doodle=0';
print <<<EOF
<tr><td>{$lang['message']}</td><td></td></tr>
<tr>
<td colspan="2">
<textarea class="userData" name="feednew[body_template]" id="uchome-ttHtmlEditor" style="height:100%;width:100%;display:none;border:0px" onkeydown="textareakey(this, event)">{$feed['body_template']}</textarea>
<iframe src="$src" name="uchome-ifrHtmlEditor" id="uchome-ifrHtmlEditor" scrolling="no" border="0" frameborder="0" style="width:100%;border: 1px solid #C5C5C5;" height="400"></iframe>
<td>
</tr>
EOF;
showsetting('feed_global_body_general', 'feednew[body_general]', $feed['body_general'], 'text');
} else {
print <<<EOF
<tr><td class="td27">{$lang['feed_global_title']}</td><td></td></tr>
<tr class="noborder"><td colspan="2">{$feed['title_template']}&nbsp;<td></tr>
<tr><td class="td27">{$lang['message']}</td><td></td></tr>
<tr class="noborder"><td colspan="2">{$feed['body_template']}&nbsp;<td></tr>
<tr><td class="td27">{$lang['feed_global_body_general']}</td><td></td></tr>
<tr class="noborder"><td colspan="2">{$feed['body_general']}&nbsp;<td></tr>
EOF;
}
showsetting('feed_global_image_1', 'feednew[image_1]', $feed['image_1'], 'text');
showsetting('feed_global_image_1_link', 'feednew[image_1_link]', $feed['image_1_link'], 'text');
showsetting('feed_global_image_2', 'feednew[image_2]', $feed['image_2'], 'text');
showsetting('feed_global_image_2_link', 'feednew[image_2_link]', $feed['image_2_link'], 'text');
showsetting('feed_global_image_3', 'feednew[image_3]', $feed['image_3'], 'text');
showsetting('feed_global_image_3_link', 'feednew[image_3_link]', $feed['image_3_link'], 'text');
showsetting('feed_global_image_4', 'feednew[image_4]', $feed['image_4'], 'text');
showsetting('feed_global_image_4_link', 'feednew[image_4_link]', $feed['image_4_link'], 'text');
showsetting('feed_global_dateline', 'feednew[dateline]', $feed['dateline'], 'text');
if($feed['id']) {
showsetting('feed_global_hot', 'feednew[hot]', $feed['hot'], 'text');
}
showsubmit('globalsubmit');
showtablefooter();
showformfooter();
} else {
$feednew = getgpc('feednew');
$feedid = intval($feednew['feedid']);
if(empty($feednew['feeduid']) || empty($feedid)) {
$setarr = array(
'title_template' => trim($feednew['title_template']),
'body_template' => trim($feednew['body_template'])
);
if(empty($setarr['title_template']) && empty($setarr['body_template'])) {
cpmsg('sitefeed_error', '', 'error');
}
} else {
$setarr = array();
}
$feednew['dateline'] = trim($feednew['dateline']);
if($feednew['dateline']) {
require_once libfile('function/home');
$newtimestamp = strtotime($feednew['dateline']);
if($newtimestamp > $_G['timestamp']) {
$_G['timestamp'] = $newtimestamp;
}
}
if(empty($feedid)) {
$_G['uid'] = 0;
require_once libfile('function/feed');
$feedid = feed_add('sitefeed',
trim($feednew['title_template']),array(),
trim($feednew['body_template']),array(),
trim($feednew['body_general']),
array(trim($feednew['image_1']),trim($feednew['image_2']),trim($feednew['image_3']),trim($feednew['image_4'])),
array(trim($feednew['image_1_link']),trim($feednew['image_2_link']),trim($feednew['image_3_link']),trim($feednew['image_4_link'])),
'','','',1
);
} else {
if(empty($feednew['feeduid'])) {
$setarr['body_general'] = trim($feednew['body_general']);
}
$setarr['image_1'] = trim($feednew['image_1']);
$setarr['image_1_link'] = trim($feednew['image_1_link']);
$setarr['image_2'] = trim($feednew['image_2']);
$setarr['image_2_link'] = trim($feednew['image_2_link']);
$setarr['image_3'] = trim($feednew['image_3']);
$setarr['image_3_link'] = trim($feednew['image_3_link']);
$setarr['image_4'] = trim($feednew['image_4']);
$setarr['image_4_link'] = trim($feednew['image_4_link']);
$setarr['dateline'] = $newtimestamp;
$setarr['hot'] = intval($feednew['hot']);
C::t('home_feed')->update_feed('', $setarr, '', '', $feedid);
}
cpmsg('feed_global_add_success', '', 'succeed');
}
} else {
$detail = $_GET['detail'];
$uid = $_GET['uid'];
$users = $_GET['users'];
$feedid = $_GET['feedid'];
$icon = $_GET['icon'];
$hot1 = $_GET['hot1'];
$hot2 = $_GET['hot2'];
$starttime = $_GET['starttime'];
$endtime = $_GET['endtime'];
$searchsubmit = $_GET['searchsubmit'];
$feedids = $_GET['feedids'];
$fromumanage = $_GET['fromumanage'] ? 1 : 0;
showtips('feed_tips');
if(!submitcheck('feedsubmit')) {
if($fromumanage) {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? '' : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? '' : $endtime;
} else {
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? dgmdate(TIMESTAMP - 86400 * 7, 'Y-n-j') : $starttime;
$endtime = $_G['adminid'] == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? dgmdate(TIMESTAMP, 'Y-n-j') : $endtime;
}
$staticurl = STATICURL;
echo <<<EOT
<script type="text/javascript" src="{$staticurl}js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('feedforum').page.value=number;
$('feedforum').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'searchposts', !$searchsubmit);
showformheader("feed", '', 'feedforum');
showhiddenfields(array('page' => $page, 'pp' => $_GET['pp'] ? $_GET['pp'] : $_GET['perpage']));
showtableheader();
showsetting('feed_search_detail', 'detail', $detail, 'radio');
showsetting('feed_search_perpage', '', $_GET['perpage'], "<select name='perpage'><option value='20'>{$lang['perpage_20']}</option><option value='50'>{$lang['perpage_50']}</option><option value='100'>{$lang['perpage_100']}</option></select>");
$selected[$icon] = $icon ? 'selected="selected"' : '';
showsetting('feed_search_icon', '', $icon, "<select name='icon'><option value=''>{$lang['all']}</option><option value='blog' {$selected['blog']}>{$lang['feed_blog']}</option>
<option value='thread' {$selected['thread']}>{$lang['feed_thread']}</option><option value='album' {$selected['album']}>{$lang['feed_album']}</option><option value='doing' {$selected['doing']}>{$lang['doing']}</option>
<option value='share' {$selected['share']}>{$lang['shares']}</option><option value='friend' {$selected['friend']}>{$lang['feed_friend']}</option><option value='poll' {$selected['poll']}>{$lang['feed_poll']}</option>
<option value='comment' {$selected['comment']}>{$lang['feed_comment']}</option><option value='click' {$selected['click']}>{$lang['feed_click']}</option>
<option value='show' {$selected['show']}>{$lang['feed_show']}</option><option value='profile' {$selected['profile']}>{$lang['feed_profile']}</option><option value='sitefeed' {$selected['sitefeed']}>{$lang['feed_sitefeed']}</option></select>");
showsetting('feed_search_uid', 'uid', $uid, 'text');
showsetting('feed_search_user', 'users', $users, 'text');
showsetting('feed_search_feedid', 'feedid', $feedid, 'text');
showsetting('feed_search_hot', array('hot1', 'hot2'), array('', ''), 'range');
showsetting('feed_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
echo '<input type="hidden" name="fromumanage" value="'.$fromumanage.'">';
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
$feedids = authcode($feedids, 'DECODE');
$feedidsadd = $feedids ? explode(',', $feedids) : $_GET['delete'];
include_once libfile('function/delete');
$deletecount = count(deletefeeds($feedidsadd));
$cpmsg = cplang('feed_succeed', array('deletecount' => $deletecount));
?>
<script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('feedforum').searchsubmit.click();</script>
<?php
}
if(submitcheck('searchsubmit', 1)) {
$feedids = $feedcount = '0';
$sql = $error = '';
$users = trim($users);
if($users != '') {
$uids = array(-1);
$query = C::t('home_feed')->fetch_uid_by_username(explode(',', $users));
$uids = array_keys($query) + $uids;
}
if($icon != '') {
$feedarr = C::t('home_feed')->fetch_icon_by_icon($icon);
$icon = $feedarr['icon'];
if($icon == '') {
$icon = '-1';
}
}
if($starttime != '') {
$starttime = strtotime($starttime);
}
if($_G['adminid'] == 1 && $endtime != dgmdate(TIMESTAMP, 'Y-n-j')) {
if($endtime != '') {
$endtime = strtotime($endtime);
}
} else {
$endtime = TIMESTAMP;
}
if($feedid != '') {
$feedids = array(-1);
$query = C::t('home_feed')->fetch_feedid_by_feedid(explode(',', $feedid));
$feedids = array_keys($query) + $feedids;
}
if($uid != '') {
$query = C::t('home_feed')->fetch_uid_by_uid(explode(',', $uid));
if(!$uids) {
$uids = array_keys($query);
} else {
$uids = array_intersect(array_keys($query), $uids);
}
if(!$uids) {
$uids = array(-1);
}
}
if(($_G['adminid'] == 2 && $endtime - $starttime > 86400 * 16) || ($_G['adminid'] == 3 && $endtime - $starttime > 86400 * 8)) {
$error = 'feed_mod_range_illegal';
}
if(!$error) {
if($detail) {
$_GET['perpage'] = intval($_GET['perpage']) < 1 ? 20 : intval($_GET['perpage']);
$perpage = $_GET['pp'] ? $_GET['pp'] : $_GET['perpage'];
$query = C::t('home_feed')->fetch_all_by_search(1, $uids, $icon, $starttime, $endtime, $feedids, $hot1, $hot2, (($page - 1) * $perpage), $perpage);
$feeds = '';
include_once libfile('function/feed');
foreach ($query as $feed) {
$feed['dateline'] = dgmdate($feed['dateline']);
$feed = mkfeed($feed);
$feeds .= showtablerow('', array('style="width:20px;"', 'style="width:260px;"', '', 'style="width:120px;"', 'style="width:60px;"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"{$feed['feedid']}\" />",
$feed['title_template'],
$feed['body_template'],
$feed['dateline'],
'<a href="'.ADMINSCRIPT.'?action=feed&operation=global&feedid='.$feed['feedid'].'">'.$lang['edit'].'</a>'
), TRUE);
}
$feedcount = C::t('home_feed')->fetch_all_by_search(3, $uids, $icon, $starttime, $endtime, $feedids, $hot1, $hot2);
$multi = multi($feedcount, $perpage, $page, ADMINSCRIPT."?action=feed");
$multi = preg_replace("/href=\"".ADMINSCRIPT."\?action=feed&amp;page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
$multi = str_replace("window.location='".ADMINSCRIPT."?action=feed&amp;page='+this.value", "page(this.value)", $multi);
} else {
$feedcount = 0;
$query = C::t('home_feed')->fetch_all_by_search(2, $uids, $icon, $starttime, $endtime, $feedids, $hot1, $hot2);
foreach ($query as $feed) {
$feedids .= ','.$feed['feedid'];
$feedcount++;
}
$multi = '';
}
if(!$feedcount) {
$error = 'feed_post_nonexistence';
}
}
showtagheader('div', 'postlist', $searchsubmit);
showformheader('feed&frame=no', 'target="feedframe"');
showhiddenfields(array('feedids' => authcode($feedids, 'ENCODE')));
showtableheader(cplang('feed_result').' '.$feedcount.' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';$(\'feedforum\').pp.value=\'\';$(\'feedforum\').page.value=\'\';" class="act lightlink normal">'.cplang('research').'</a>', 'fixpadding');
if($error) {
echo "<tr><td class=\"lineheight\" colspan=\"15\">$lang[$error]</td></tr>";
} else {
if($detail) {
showsubtitle(array('', 'feed_title', 'feed_body', 'time', ''));
echo $feeds;
}
}
showsubmit('feedsubmit', 'delete', $detail ? 'del' : '', '', $multi);
showtablefooter();
showformfooter();
echo '<iframe name="feedframe" style="display:none"></iframe>';
showtagfooter('div');
}
}
?>

Some files were not shown because too many files have changed in this diff Show More