First commit

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

View File

@@ -0,0 +1,20 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_admingroups.php 24830 2011-10-12 08:23:34Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_admingroups() {
foreach(C::t('common_admingroup')->range() as $data) {
savecache('admingroup_'.$data['admingid'], $data);
}
}
?>

65
source/function/cache/cache_advs.php vendored Normal file
View File

@@ -0,0 +1,65 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_advs.php 30323 2012-05-22 09:33:36Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_advs() {
global $_G;
$advlist = $data = array();
$data['code'] = $data['parameters'] = $data['evalcode'] = array();
foreach(C::t('common_advertisement')->fetch_all_old() as $adv) {
foreach(explode("\t", $adv['targets']) as $target) {
$data['code'][$target][$adv['type']][$adv['advid']] = $adv['code'];
}
$etype = explode(':', $adv['type']);
if(count($etype) > 1) {
$advtype_class = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/adv/adv_'.$etype[1].'.php';
if(!file_exists($advtype_class) || !in_array($etype[0], $_G['setting']['plugins']['available'])) {
continue;
}
require_once $advtype_class;
$advclass = 'adv_'.$etype[1];
} else {
$advtype_class = libfile('adv/'.$adv['type'], 'class');
if(!file_exists($advtype_class)) {
continue;
}
require_once $advtype_class;
$advclass = 'adv_'.$adv['type'];
}
$advclass = new $advclass;
$adv['parameters'] = dunserialize($adv['parameters']);
unset($adv['parameters']['style'], $adv['parameters']['html'], $adv['parameters']['displayorder']);
$data['parameters'][$adv['type']][$adv['advid']] = $adv['parameters'];
if($adv['parameters']['extra']) {
$data['parameters'][$adv['type']][$adv['advid']] = array_merge($data['parameters'][$adv['type']][$adv['advid']], $adv['parameters']['extra']);
unset($data['parameters'][$adv['type']][$adv['advid']]['extra']);
}
$advlist[] = $adv;
$data['evalcode'][$adv['type']] = $advclass->evalcode($adv);
}
updateadvtype();
savecache('advs', $data);
}
function updateadvtype() {
global $_G;
$advtype = array();
foreach(C::t('common_advertisement')->fetch_all_old() as $row) {
$advtype[$row['type']] = 1;
}
$_G['setting']['advtype'] = $advtype = array_keys($advtype);
C::t('common_setting')->update_setting('advtype', $advtype);
}
?>

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: cache_albumcategory.php 24538 2011-09-23 06:42:48Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_albumcategory() {
$data = array();
$query = C::t('home_album_category')->fetch_all_by_displayorder();
foreach ($query as $value) {
$value['catname'] = dhtmlspecialchars($value['catname']);
$data[$value['catid']] = $value;
}
foreach($data as $key=>$value) {
$upid = $value['upid'];
$data[$key]['level'] = 0;
if($upid && isset($data[$upid])) {
$data[$upid]['children'][] = $key;
while($upid && isset($data[$upid])) {
$data[$key]['level'] += 1;
$upid = $data[$upid]['upid'];
}
}
}
savecache('albumcategory', $data);
}
?>

View File

@@ -0,0 +1,31 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_announcements.php 24152 2011-08-26 10:04:08Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_announcements() {
$data = C::t('forum_announcement')->fetch_all_by_date(TIMESTAMP);
foreach ($datarow as $data) {
if($datarow['type'] == 2) {
$datarow['pmid'] = $datarow['id'];
unset($datarow['id']);
unset($datarow['message']);
$datarow['subject'] = cutstr($datarow['subject'], 60);
}
$datarow['groups'] = empty($datarow['groups']) ? array() : explode(',', $datarow['groups']);
$data[] = $datarow;
}
savecache('announcements', $data);
}
?>

View File

@@ -0,0 +1,31 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_announcements_forum.php 26271 2011-12-07 09:15:53Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_announcements_forum() {
$data = array();
$data = C::t('forum_announcement')->fetch_by_displayorder(TIMESTAMP);
if($data) {
$uid = C::t('common_member')->fetch_uid_by_username($data['author']);
$data['authorid'] = $uid;
$data['authorid'] = intval($data['authorid']);
if(empty($data['type'])) {
unset($data['message']);
}
} else {
$data = array();
}
savecache('announcements_forum', $data);
}
?>

View File

@@ -0,0 +1,19 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_antitheft.php 32740 2013-03-05 08:32:47Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_antitheft() {
$data = C::t('common_setting')->fetch_setting('antitheftsetting', true);
savecache('antitheft', $data);
}
?>

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: cache_attachtype.php 28372 2012-02-28 08:15:06Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_attachtype() {
$attachtypes = C::t('forum_attachtype')->fetch_all_data();
$data = array();
foreach($attachtypes as $row) {
$data[$row['fid']][strtolower($row['extension'])] = $row['maxsize'];
}
savecache('attachtype', $data);
}
?>

61
source/function/cache/cache_bbcodes.php vendored Normal file
View File

@@ -0,0 +1,61 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_bbcodes.php 24610 2011-09-28 03:02:49Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_bbcodes() {
$data = array();
$regexp = array (
1 => "/\[{bbtag}\](.*?)\[\/{bbtag}\]/is",
2 => "/\[{bbtag}=(['\"]?)(.+?)(['\"]?)\](.*?)\[\/{bbtag}\]/is",
3 => "/\[{bbtag}=(['\"]?)(.+?)(['\"]?),(['\"]?)(.+?)(['\"]?)\](.*?)\[\/{bbtag}\]/is"
);
foreach(C::t('forum_bbcode')->fetch_all_by_available_icon(0, false, '>') as $bbcode) {
$bbcode['perm'] = explode("\t", $bbcode['perm']);
if(in_array('', $bbcode['perm']) || !$bbcode['perm']) {
continue;
}
$search = str_replace('{bbtag}', $bbcode['tag'], $regexp[$bbcode['params']]);
$bbcode['replacement'] = preg_replace("/([\r\n])/", '', $bbcode['replacement']);
switch($bbcode['params']) {
case 2:
$bbcode['replacement'] = str_replace('{1}', '\\2', $bbcode['replacement']);
$bbcode['replacement'] = str_replace('{2}', '\\4', $bbcode['replacement']);
break;
case 3:
$bbcode['replacement'] = str_replace('{1}', '\\2', $bbcode['replacement']);
$bbcode['replacement'] = str_replace('{2}', '\\5', $bbcode['replacement']);
$bbcode['replacement'] = str_replace('{3}', '\\7', $bbcode['replacement']);
break;
default:
$bbcode['replacement'] = str_replace('{1}', '\\1', $bbcode['replacement']);
break;
}
if(preg_match("/\{(RANDOM|MD5)\}/", $bbcode['replacement'])) {
$replace = str_replace('{RANDOM}', '', str_replace('{MD5}', '', $bbcode['replacement']));
} else {
$replace = $bbcode['replacement'];
}
foreach($bbcode['perm'] as $groupid) {
for($i = 0; $i < $bbcode['nest']; $i++) {
$data[$groupid]['searcharray'][] = $search;
$data[$groupid]['replacearray'][] = $replace;
}
}
}
savecache('bbcodes', $data);
}
?>

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: cache_bbcodes_display.php 24599 2011-09-27 11:06:53Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_bbcodes_display() {
$data = array();
$i = 0;
foreach(C::t('forum_bbcode')->fetch_all_by_available_icon(2, true) as $bbcode) {
$bbcode['perm'] = explode("\t", $bbcode['perm']);
if(in_array('', $bbcode['perm']) || !$bbcode['perm']) {
continue;
}
$i++;
$tag = $bbcode['tag'];
$bbcode['i'] = $i;
$bbcode['icon'] = preg_match('/^https?:\/\//is', $bbcode['icon']) ? $bbcode['icon'] : STATICURL.'image/common/'.$bbcode['icon'];
$bbcode['explanation'] = dhtmlspecialchars(trim($bbcode['explanation']));
$bbcode['prompt'] = addcslashes($bbcode['prompt'], '\\\'');
unset($bbcode['tag']);
foreach($bbcode['perm'] as $groupid) {
$data[$groupid][$tag] = $bbcode;
}
}
savecache('bbcodes_display', $data);
}
?>

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: cache_blogcategory.php 24543 2011-09-23 08:30:17Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_blogcategory() {
$data = array();
$query = C::t('home_blog_category')->fetch_all_by_displayorder();
foreach ($query as $value) {
$value['catname'] = dhtmlspecialchars($value['catname']);
$data[$value['catid']] = $value;
}
foreach($data as $key => $value) {
$upid = $value['upid'];
$data[$key]['level'] = 0;
if($upid && isset($data[$upid])) {
$data[$upid]['children'][] = $key;
while($upid && isset($data[$upid])) {
$data[$key]['level'] += 1;
$upid = $data[$upid]['upid'];
}
}
}
savecache('blogcategory', $data);
}
?>

80
source/function/cache/cache_censor.php vendored Normal file
View File

@@ -0,0 +1,80 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_censor.php 36347 2017-01-13 01:17:50Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_censor() {
$banned = $mod = array();
$bannednum = $modnum = 0;
$data = array('filter' => array(), 'banned' => array(), 'mod' => array());
foreach(C::t('common_word')->fetch_all_word() as $censor) {
if(preg_match('/^\/(.+?)\/$/', $censor['find'], $a)) {
switch($censor['replacement']) {
case '{BANNED}':
$data['banned'][] = $censor['find'];
break;
case '{MOD}':
$data['mod'][] = $censor['find'];
break;
default:
$data['filter']['find'][] = $censor['find'];
$data['filter']['replace'][] = preg_replace("/\((\d+)\)/", "\\\\1", $censor['replacement']);
break;
}
} else {
$censor['find'] = preg_replace("/\\\{(\d+)\\\}/", ".{0,\\1}", preg_quote($censor['find'], '/'));
switch($censor['replacement']) {
case '{BANNED}':
$banned[] = $censor['find'];
$bannednum ++;
if($bannednum == 1000) {
$data['banned'][] = '/('.implode('|', $banned).')/i';
$banned = array();
$bannednum = 0;
}
break;
case '{MOD}':
$mod[] = $censor['find'];
$modnum ++;
if($modnum == 1000) {
$data['mod'][] = '/('.implode('|', $mod).')/i';
$mod = array();
$modnum = 0;
}
break;
default:
$data['filter']['find'][] = '/'.$censor['find'].'/i';
$data['filter']['replace'][] = $censor['replacement'];
break;
}
}
}
if($banned) {
$data['banned'][] = '/('.implode('|', $banned).')/i';
}
if($mod) {
$data['mod'][] = '/('.implode('|', $mod).')/i';
}
if(!empty($data['filter'])) {
$temp = str_repeat('o', 7); $l = strlen($temp);
$data['filter']['find'][] = str_rot13('/1q9q78n7p473'.'o3q1925oo7p'.'5o6sss2sr/v');
$data['filter']['replace'][] = str_rot13(str_replace($l, ' ', '****7JR7JVYY7JVA7'.
'GUR7SHGHER7****\aCbjrerq7ol7Pebffqnl7Qvfphm!7Obneq7I')).$l;
}
savecache('censor', $data);
}
?>

27
source/function/cache/cache_click.php vendored Normal file
View File

@@ -0,0 +1,27 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_click.php 24403 2011-09-16 12:32:45Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_click() {
$data = $keys = array();
foreach(C::t('home_click')->fetch_all_by_available() as $value) {
$value['icon'] = preg_match('/^https?:\/\//is', $value['icon']) ? $value['icon'] : STATICURL . 'image/click/' . $value['icon'];
if(!isset($data[$value['idtype']]) || count($data[$value['idtype']]) < 8) {
$keys[$value['idtype']] = $keys[$value['idtype']] ? ++$keys[$value['idtype']] : 1;
$data[$value['idtype']][$keys[$value['idtype']]] = $value;
}
}
savecache('click', $data);
}
?>

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: cache_connect_blacklist.php 24406 2011-09-18 06:53:04Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_connect_blacklist() {
global $_G;
$data = array();
foreach(C::t('common_uin_black')->fetch_all_by_uin() as $blacklist) {
$data[] = $blacklist['uin'];
}
savecache('connect_blacklist', $data);
}
?>

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: cache_creditrule.php 24850 2011-10-12 11:09:19Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_creditrule() {
$data = array();
foreach(C::t('common_credit_rule')->fetch_all_rule() as $rule) {
$rule['rulenameuni'] = urlencode(diconv($rule['rulename'], CHARSET, 'UTF-8', true));
$data[$rule['action']] = $rule;
}
savecache('creditrule', $data);
}
?>

View File

@@ -0,0 +1,61 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_custominfo.php 26112 2011-12-02 03:06:01Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_custominfo() {
$data = C::t('common_setting')->fetch_all_setting(array('extcredits', 'customauthorinfo', 'postno', 'postnocustom'));
$data['customauthorinfo'] = dunserialize($data['customauthorinfo']);
$data['customauthorinfo'] = $data['customauthorinfo'][0];
$data['fieldsadd'] = '';
$data['extcredits'] = dunserialize($data['extcredits']);
$order = array();
if($data['customauthorinfo']) {
foreach($data['customauthorinfo'] as $k => $v) {
if($v['left']) {
$order['left'][$k] = $v['order'];
}
if($v['menu']) {
$order['menu'][$k] = $v['order'];
}
}
if(!empty($order['left'])) {
asort($order['left']);
}
if(!empty($order['menu'])) {
asort($order['menu']);
}
}
$data['setting'] = $order;
$profile = array();
foreach(C::t('common_member_profile_setting')->fetch_all_by_available_showinthread(1, 1) as $field) {
$data['fieldsadd'] .= ', mp.'.$field['fieldid'].' AS '.$field['fieldid'];
$profile['field_'.$field['fieldid']] = array($field['title'], $field['fieldid']);
}
$data['profile'] = $profile;
$postnocustomnew[0] = $data['postno'] != '' ? (preg_match("/^[\x01-\x7f]+$/", $data['postno']) ? '<sup>'.$data['postno'].'</sup>' : $data['postno']) : '<sup>#</sup>';
$data['postnocustom'] = dunserialize($data['postnocustom']);
if(is_array($data['postnocustom'])) {
foreach($data['postnocustom'] as $key => $value) {
$value = trim($value);
$postnocustomnew[$key + 1] = preg_match("/^[\x01-\x7f]+$/", $value) ? '<sup>'.$value.'</sup>' : $value;
}
}
unset($data['customauthorinfo'], $data['postno'], $data['postnocustom'], $data['extcredits']);
$data['postno'] = $postnocustomnew;
savecache('custominfo', $data);
}
?>

View File

@@ -0,0 +1,46 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_diytemplatename.php 24927 2011-10-17 03:13:33Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_diytemplatename() {
$data = array();
$apps = array('portal', 'forum', 'group', 'home');
$nullname = lang('portalcp', 'diytemplate_name_null');
$scriptarr = $lostname = array();
foreach(C::t('common_diy_data')->range() as $datarow) {
$datarow['name'] = $datarow['name'] ? $datarow['name'] : lang('portalcp', $datarow['targettplname'], '', '');
if(empty($datarow['name'])) {
$lostname[$datarow['targettplname']] = $datarow['targettplname'];
$datarow['name'] = $nullname;
}
$data[$datarow['targettplname']] = dhtmlspecialchars($datarow['name']);
$curscript = substr($datarow['targettplname'], 0, strpos($datarow['targettplname'], '/'));
if(in_array($curscript, $apps)) {
$scriptarr[$curscript][$datarow['targettplname']] = true;
}
}
if($lostname) {
require_once libfile('function/portalcp');
foreach(getdiytplnames($lostname) as $pre => $datas) {
foreach($datas as $id => $name) {
$data[$pre.$id] = $name;
}
}
}
savecache('diytemplatename', $data);
foreach($scriptarr as $curscript => $value) {
savecache('diytemplatename'.$curscript, $value);
}
}
?>

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: cache_domainwhitelist.php 24152 2011-08-26 10:04:08Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_domainwhitelist() {
$data = C::t('common_setting')->fetch_setting('domainwhitelist');
$data = $data ? explode("\r\n", $data) : array();
savecache('domainwhitelist', $data);
}
?>

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: cache_fields_connect_register.php 24935 2011-10-17 07:41:48Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_fields_connect_register() {
global $_G;
$data = array();
$fields = array();
if($_G['setting']['connect']['register_gender']) {
$fields[] = 'gender';
}
if($_G['setting']['connect']['register_birthday']) {
$fields[] = 'birthyear';
$fields[] = 'birthmonth';
$fields[] = 'birthday';
}
if($fields) {
foreach(C::t('common_member_profile_setting')->fetch_all($fields) as $field) {
$choices = array();
if($field['selective']) {
foreach(explode("\n", $field['choices']) as $item) {
list($index, $choice) = explode('=', $item);
$choices[trim($index)] = trim($choice);
}
$field['choices'] = $choices;
} else {
unset($field['choices']);
}
$field['showinregister'] = 1;
$field['available'] = 1;
$data['field_'.$field['fieldid']] = $field;
}
}
savecache('fields_connect_register', $data);
}
?>

View File

@@ -0,0 +1,34 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_fields_optional.php 24935 2011-10-17 07:41:48Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_fields_optional() {
$data = array();
foreach(C::t('common_member_profile_setting')->fetch_all_by_available_required(1, 0) as $field) {
$choices = array();
if($field['selective']) {
foreach(explode("\n", $field['choices']) as $item) {
list($index, $choice) = explode('=', $item);
$choices[trim($index)] = trim($choice);
}
$field['choices'] = $choices;
} else {
unset($field['choices']);
}
$data['field_'.$field['fieldid']] = $field;
}
savecache('fields_optional', $data);
}
?>

View File

@@ -0,0 +1,34 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_fields_register.php 24935 2011-10-17 07:41:48Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_fields_register() {
$data = array();
foreach(C::t('common_member_profile_setting')->fetch_all_by_available_showinregister(1, 1) as $field) {
$choices = array();
if($field['selective']) {
foreach(explode("\n", $field['choices']) as $item) {
list($index, $choice) = explode('=', $item);
$choices[trim($index)] = trim($choice);
}
$field['choices'] = $choices;
} else {
unset($field['choices']);
}
$data['field_'.$field['fieldid']] = $field;
}
savecache('fields_register', $data);
}
?>

View File

@@ -0,0 +1,34 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_fields_required.php 24935 2011-10-17 07:41:48Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_fields_required() {
$data = array();
foreach(C::t('common_member_profile_setting')->fetch_all_by_available_required(1, 1) as $field) {
$choices = array();
if($field['selective']) {
foreach(explode("\n", $field['choices']) as $item) {
list($index, $choice) = explode('=', $item);
$choices[trim($index)] = trim($choice);
}
$field['choices'] = $choices;
} else {
unset($field['choices']);
}
$data['field_'.$field['fieldid']] = $field;
}
savecache('fields_required', $data);
}
?>

30
source/function/cache/cache_focus.php vendored 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: cache_focus.php 24152 2011-08-26 10:04:08Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_focus() {
$data = array();
$focus = C::t('common_setting')->fetch_setting('focus', true);
$data['title'] = $focus['title'];
$data['cookie'] = intval($focus['cookie']);
$data['data'] = array();
if(is_array($focus['data'])) foreach($focus['data'] as $k => $v) {
if($v['available']) {
$data['data'][$k] = $v;
}
}
savecache('focus', $data);
}
?>

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: cache_forumlinks.php 28612 2012-03-06 08:10:47Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_forumlinks() {
global $_G;
$data = array();
$query = C::t('common_friendlink')->fetch_all_by_displayorder();
if($_G['setting']['forumlinkstatus']) {
$tightlink_content = $tightlink_text = $tightlink_logo = $comma = '';
foreach ($query as $flink) {
if($flink['description']) {
if($flink['logo']) {
$tightlink_content .= '<li class="lk_logo mbm bbda cl"><img src="'.$flink['logo'].'" border="0" alt="'.strip_tags($flink['name']).'" /><div class="lk_content z"><h5><a href="'.$flink['url'].'" target="_blank">'.$flink['name'].'</a></h5><p>'.$flink['description'].'</p></div></li>';
} else {
$tightlink_content .= '<li class="mbm bbda"><div class="lk_content"><h5><a href="'.$flink['url'].'" target="_blank">'.$flink['name'].'</a></h5><p>'.$flink['description'].'</p></div></li>';
}
} else {
if($flink['logo']) {
$tightlink_logo .= '<a href="'.$flink['url'].'" target="_blank"><img src="'.$flink['logo'].'" border="0" alt="'.strip_tags($flink['name']).'" /></a> ';
} else {
$tightlink_text .= '<li><a href="'.$flink['url'].'" target="_blank" title="'.strip_tags($flink['name']).'">'.$flink['name'].'</a></li>';
}
}
}
$data = array($tightlink_content, $tightlink_logo, $tightlink_text);
}
savecache('forumlinks', $data);
}
?>

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: cache_forumrecommend.php 24152 2011-08-26 10:04:08Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_forumrecommend() {
$data = array();
$fids = C::t('forum_forum')->fetch_all_fids();
foreach($fids as $row) {
require_once libfile('function/group');
$recommendlist = C::t('forum_forum')->fetch_all_recommend_by_fid($row['fid']);
foreach($recommendlist as $info) {
$group = array('fid' => $info['fid'], 'name' => $info['name'], 'threads' => $info['threads'], 'lastpost' => $info['lastpost'], 'icon' => $info['icon'], 'membernum' => $info['membernum'], 'description' => $info['description']);
$group['icon'] = get_groupimg($group['icon'], 'icon');
$lastpost = array(0, 0, '', '');
$group['lastpost'] = is_string($group['lastpost']) ? explode("\t", $group['lastpost']) : $group['lastpost'];
$group['lastpost'] =count($group['lastpost']) != 4 ? $lastpost : $group['lastpost'];
list($lastpost['tid'], $lastpost['subject'], $lastpost['dateline'], $lastpost['author']) = $group['lastpost'];
if($lastpost['tid']) {
$lastpost['dateline'] = dgmdate($lastpost['dateline'], 'Y-m-d H:i:s');
if($lastpost['author']) {
$lastpost['encode_author'] = rawurlencode($lastpost['author']);
}
$group['lastpost'] = $lastpost;
} else {
$group['lastpost'] = '';
}
$data[$row['fid']][] = $group;
}
}
savecache('forumrecommend', $data);
}
?>

87
source/function/cache/cache_forums.php vendored Normal file
View File

@@ -0,0 +1,87 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_forums.php 31989 2012-10-30 05:31:52Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_forums() {
$data = array();
$forums = C::t('forum_forum')->fetch_all_forum();
$pluginvalue = $forumlist = array();
$pluginvalue = pluginsettingvalue('forums');
$forumnoperms = array();
foreach($forums as $val) {
$forum = array('fid' => $val['fid'], 'type' => $val['type'], 'name' => $val['name'], 'fup' => $val['fup'], 'simple' => $val['simple'], 'status' => $val['status'], 'allowpostspecial' => $val['allowpostspecial'], 'viewperm' => $val['viewperm'], 'formulaperm' => $val['formulaperm'], 'havepassword' => $val['password'], 'postperm' => $val['postperm'], 'replyperm' => $val['replyperm'], 'getattachperm' => $val['getattachperm'], 'postattachperm' => $val['postattachperm'], 'extra' => $val['extra'], 'commentitem' => $val['commentitem'], 'uid' => $val['uid'], 'archive' => $val['archive'], 'domain' => $val['domain']);
$forum['orderby'] = bindec((($forum['simple'] & 128) ? 1 : 0).(($forum['simple'] & 64) ? 1 : 0));
$forum['ascdesc'] = ($forum['simple'] & 32) ? 'ASC' : 'DESC';
$forum['extra'] = dunserialize($forum['extra']);
if(!is_array($forum['extra'])) {
$forum['extra'] = array();
}
if(!isset($forumlist[$forum['fid']])) {
if($forum['uid']) {
$forum['users'] = "\t{$forum['uid']}\t";
}
unset($forum['uid']);
if($forum['fup']) {
$forumlist[$forum['fup']]['count']++;
}
$forumlist[$forum['fid']] = $forum;
} elseif($forum['uid']) {
if(!$forumlist[$forum['fid']]['users']) {
$forumlist[$forum['fid']]['users'] = "\t";
}
$forumlist[$forum['fid']]['users'] .= "{$forum['uid']}\t";
}
}
$data = array();
if(!empty($forumlist)) {
foreach($forumlist as $fid1 => $forum1) {
if(($forum1['type'] == 'group' && $forum1['count'])) {
$data[$fid1] = formatforumdata($forum1, $pluginvalue);
unset($data[$fid1]['users'], $data[$fid1]['allowpostspecial'], $data[$fid1]['commentitem']);
foreach($forumlist as $fid2 => $forum2) {
if($forum2['fup'] == $fid1 && $forum2['type'] == 'forum') {
$data[$fid2] = formatforumdata($forum2, $pluginvalue);
foreach($forumlist as $fid3 => $forum3) {
if($forum3['fup'] == $fid2 && $forum3['type'] == 'sub') {
$data[$fid3] = formatforumdata($forum3, $pluginvalue);
}
}
}
}
}
}
}
savecache('forums', $data);
}
function formatforumdata($forum, &$pluginvalue) {
static $keys = array('fid', 'type', 'name', 'fup', 'viewperm', 'postperm', 'orderby', 'ascdesc', 'users', 'status',
'extra', 'plugin', 'allowpostspecial', 'commentitem', 'archive', 'domain', 'havepassword');
static $orders = array('lastpost', 'dateline', 'replies', 'views');
$data = array();
foreach ($keys as $key) {
switch ($key) {
case 'orderby': $data[$key] = $orders[$forum['orderby']]; break;
case 'plugin': $data[$key] = $pluginvalue[$forum['fid']]; break;
case 'havepassword': $data[$key] = $forum[$key] ? 1 : 0; break;
case 'allowpostspecial': $data[$key] = sprintf('%06b', $forum['allowpostspecial']); break;
default: $data[$key] = $forum[$key];
}
}
return $data;
}
?>

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: cache_forumstick.php 24152 2011-08-26 10:04:08Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_forumstick() {
$data = array();
$forumstickthreads = C::t('common_setting')->fetch_setting('forumstickthreads', true);
$forumstickcached = array();
if($forumstickthreads) {
foreach($forumstickthreads as $forumstickthread) {
foreach($forumstickthread['forums'] as $fid) {
$forumstickcached[$fid][] = $forumstickthread['tid'];
}
}
$data = $forumstickcached;
} else {
$data = array();
}
savecache('forumstick', $data);
}
?>

53
source/function/cache/cache_founder.php vendored Normal file
View File

@@ -0,0 +1,53 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_founder.php 25782 2011-11-22 05:29:19Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_founder() {
global $_G;
$allowadmincp = $status0 = $status1 = array();
$founders = explode(',', str_replace(' ', '', $_G['config']['admincp']['founder']));
if($founders) {
foreach($founders as $founder) {
if(is_numeric($founder)) {
$fuid[] = $founder;
} else {
$fuser[] = $founder;
}
}
if($fuid) {
$allowadmincp = C::t('common_member')->fetch_all($fuid, false, 0);
}
if($fuser) {
$allowadmincp = $allowadmincp + C::t('common_member')->fetch_all_by_username($fuser);
}
}
$allowadmincp = $allowadmincp + C::t('common_admincp_member')->range();
$allallowadmincp = C::t('common_member')->fetch_all_by_allowadmincp('0', '>') + C::t('common_member')->fetch_all(array_keys($allowadmincp), false, 0);
foreach($allallowadmincp as $uid => $user) {
if(isset($allowadmincp[$uid]) && !getstatus($user['allowadmincp'], 1)) {
$status1[$uid] = $uid;
} elseif(!isset($allowadmincp[$uid]) && getstatus($user['allowadmincp'], 1)) {
$status0[$uid] = $uid;
}
}
if(!empty($status0)) {
C::t('common_member')->clean_admincp_manage($status0);
}
if(!empty($status1)) {
C::t('common_member')->update_admincp_manage($status1);
}
}
?>

View File

@@ -0,0 +1,54 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_globalstick.php 24152 2011-08-26 10:04:08Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_globalstick() {
$data = array();
$query = C::t('forum_forum')->fetch_all_valid_forum();
$fuparray = $threadarray = array();
foreach($query as $forum) {
switch($forum['type']) {
case 'forum':
$fuparray[$forum['fid']] = $forum['fup'];
break;
case 'sub':
$fuparray[$forum['fid']] = $fuparray[$forum['fup']];
break;
}
}
foreach(C::t('forum_thread')->fetch_all_by_displayorder(array(2, 3)) as $thread) {
switch($thread['displayorder']) {
case 2:
$threadarray[$fuparray[$thread['fid']]][] = $thread['tid'];
break;
case 3:
$threadarray['global'][] = $thread['tid'];
break;
}
}
foreach(array_unique($fuparray) as $gid) {
if(!empty($threadarray[$gid])) {
$data['categories'][$gid] = array(
'tids' => dimplode($threadarray[$gid]),
'count' => intval(is_array($threadarray[$gid]) ? count($threadarray[$gid]) : 0)
);
}
}
$data['global'] = array(
'tids' => empty($threadarray['global']) ? '' : dimplode($threadarray['global']),
'count' => intval(is_array($threadarray['global']) ? count($threadarray['global']) : 0)
);
savecache('globalstick', $data);
}
?>

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: cache_groupicon.php 24596 2011-09-27 10:39:31Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_groupicon() {
$data = array();
foreach(C::t('forum_onlinelist')->fetch_all_order_by_displayorder() as $list) {
if($list['url']) {
$data[$list['groupid']] = preg_match('/^https?:\/\//is', $list['url']) ? $list['url'] : STATICURL.'image/common/'.$list['url'];
}
}
savecache('groupicon', $data);
}
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_grouplevels.php 24623 2011-09-28 06:54:39Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_grouplevels() {
$data = array();
$query = C::t('forum_grouplevel')->range();
foreach($query as $level) {
$level['creditspolicy'] = dunserialize($level['creditspolicy']);
$level['postpolicy'] = dunserialize($level['postpolicy']);
$level['specialswitch'] = dunserialize($level['specialswitch']);
$data[$level['levelid']] = $level;
}
savecache('grouplevels', $data);
}
?>

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: cache_groupreadaccess.php 27076 2012-01-04 08:01:37Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_groupreadaccess() {
$data = array();
$gf_data = C::t('common_usergroup_field')->fetch_readaccess_by_readaccess(0);
$ug_data = C::t('common_usergroup')->fetch_all_usergroup(array_keys($gf_data));
foreach($gf_data as $key => $datarow) {
if(!$ug_data[$key]['groupid']) {
continue;
}
$datarow['grouptitle'] = $ug_data[$key]['grouptitle'];
$data[] = $datarow;
}
savecache('groupreadaccess', $data);
}
?>

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: cache_grouptype.php 24236 2011-09-01 08:49:14Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_grouptype() {
$data = array();
$query = C::t('forum_forum')->fetch_all_group_type(1);
$data['second'] = $data['first'] = array();
foreach($query as $group) {
if($group['type'] == 'forum') {
$data['second'][$group['fid']] = $group;
} else {
$data['first'][$group['fid']] = $group;
}
}
foreach($data['second'] as $fid => $secondgroup) {
$data['first'][$secondgroup['fup']]['groupnum'] += $secondgroup['groupnum'];
$data['first'][$secondgroup['fup']]['secondlist'][] = $secondgroup['fid'];
}
savecache('grouptype', $data);
}
?>

58
source/function/cache/cache_heats.php vendored Normal file
View File

@@ -0,0 +1,58 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_heats.php 27425 2012-01-31 06:53:25Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_heats() {
global $_G;
$addsql = '';
$data = array();
if(discuz_process::islocked('update_heats_list')) {
return false;
}
if($_G['setting']['indexhot']['status']) {
require_once libfile('function/post');
$_G['setting']['indexhot'] = array(
'status' => 1,
'limit' => intval($_G['setting']['indexhot']['limit'] ? $_G['setting']['indexhot']['limit'] : 10),
'days' => intval($_G['setting']['indexhot']['days'] ? $_G['setting']['indexhot']['days'] : 7),
'expiration' => intval($_G['setting']['indexhot']['expiration'] ? $_G['setting']['indexhot']['expiration'] : 900),
'messagecut' => intval($_G['setting']['indexhot']['messagecut'] ? $_G['setting']['indexhot']['messagecut'] : 200)
);
$messageitems = 2;
$limit = $_G['setting']['indexhot']['limit'];
foreach(C::t('forum_thread')->fetch_all_heats() as $heat) {
$post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($heat['tid']);
$heat = array_merge($heat, (array)$post);
if($limit == 0) {
break;
}
if($messageitems > 0) {
$heat['message'] = threadmessagecutstr($heat, $heat['message'], $_G['setting']['indexhot']['messagecut']);
$data['message'][$heat['tid']] = $heat;
} else {
unset($heat['message']);
$data['subject'][$heat['tid']] = $heat;
}
$messageitems--;
$limit--;
}
$data['expiration'] = TIMESTAMP + $_G['setting']['indexhot']['expiration'];
}
savecache('heats', $data);
discuz_process::unlock('update_heats_list');
}
?>

19
source/function/cache/cache_ipctrl.php vendored Normal file
View File

@@ -0,0 +1,19 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_ipctrl.php 24152 2011-08-26 10:04:08Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_ipctrl() {
$data = C::t('common_setting')->fetch_all_setting(array('ipregctrl', 'ipverifywhite'));
savecache('ipctrl', $data);
}
?>

23
source/function/cache/cache_magics.php vendored Normal file
View File

@@ -0,0 +1,23 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_magics.php 24589 2011-09-27 07:45:55Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_magics() {
$data = array();
foreach(C::t('common_magic')->fetch_all_data(1) as $magic) {
$data[$magic['magicid']] = $magic;
}
savecache('magics', $data);
}
?>

24
source/function/cache/cache_medals.php vendored Normal file
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: cache_medals.php 29236 2012-03-30 05:34:47Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_medals() {
$data = array();
foreach(C::t('forum_medal')->fetch_all_data(1) as $medal) {
$medal['image'] = preg_match('/^https?:\/\//is', $medal['image']) ? $medal['image'] : STATICURL.'image/common/'.$medal['image'];
$data[$medal['medalid']] = array('name' => $medal['name'], 'image' => $medal['image'], 'description' => dhtmlspecialchars($medal['description']));
}
savecache('medals', $data);
}
?>

View File

@@ -0,0 +1,23 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_modreasons.php 24152 2011-08-26 10:04:08Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_modreasons() {
$settings = C::t('common_setting')->fetch_all_setting(array('modreasons', 'userreasons'));
foreach($settings as $key => $data) {
$data = str_replace(array("\r\n", "\r"), array("\n", "\n"), $data);
$data = explode("\n", trim($data));
savecache($key, $data);
}
}
?>

View File

@@ -0,0 +1,29 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_onlinelist.php 24596 2011-09-27 10:39:31Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_onlinelist() {
$data = array();
$data['legend'] = '';
foreach(C::t('forum_onlinelist')->fetch_all_order_by_displayorder() as $list) {
$url = preg_match('/^https?:\/\//is', $list['url']) ? $list['url'] : STATICURL.'image/common/'.$list['url'];
$data[$list['groupid']] = $url;
$data['legend'] .= !empty($url) ? "<img src=\"".$url."\" /> {$list['title']} &nbsp; &nbsp; &nbsp; " : '';
if($list['groupid'] == 7) {
$data['guest'] = $list['title'];
}
}
savecache('onlinelist', $data);
}
?>

63
source/function/cache/cache_plugin.php vendored 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: cache_plugin.php 33987 2013-09-13 06:48:25Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_plugin() {
global $importtxt;
$data = $pluginsetting = array();
foreach(C::t('common_plugin')->fetch_all_data(1) as $plugin) {
$dir = substr($plugin['directory'], 0, -1);
$plugin['modules'] = dunserialize($plugin['modules']);
if($plugin['modules']['extra']['langexists']) {
$file = DISCUZ_ROOT.'./source/plugin/'.$dir.'/discuz_plugin_'.$dir.($plugin['modules']['extra']['installtype'] ? '_'.$plugin['modules']['extra']['installtype'] : '').'.xml';
if(file_exists($file)) {
require_once libfile('function/plugin');
require_once libfile('function/admincp');
$importtxt = @implode('', file($file));
$pluginarray = getimportdata('Discuz! Plugin', 0, 1);
if($pluginarray) {
updatepluginlanguage($pluginarray);
}
}
}
foreach(C::t('common_pluginvar')->fetch_all_by_pluginid($plugin['pluginid']) as $var) {
$data[$plugin['identifier']][$var['variable']] = $var['value'];
if(in_array(substr($var['type'], 0, 6), array('group_', 'forum_'))) {
$stype = substr($var['type'], 0, 5).'s';
$type = substr($var['type'], 6);
if($type == 'select') {
foreach(explode("\n", $var['extra']) as $key => $option) {
$option = trim($option);
if(strpos($option, '=') === FALSE) {
$key = $option;
} else {
$item = explode('=', $option);
$key = trim($item[0]);
$option = trim($item[1]);
}
$var['select'][] = array($key, $option);
}
}
$pluginsetting[$stype][$plugin['identifier']]['name'] = $plugin['name'];
$pluginsetting[$stype][$plugin['identifier']]['setting'][$var['pluginvarid']] = array('title' => $var['title'], 'description' => $var['description'], 'type' => $type, 'select' => $var['select']);
}
}
}
writetocache('pluginsetting', getcachevars(array('pluginsetting' => $pluginsetting)));
savecache('plugin', $data);
}
?>

View File

@@ -0,0 +1,92 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_portalcategory.php 31224 2012-07-27 03:54:18Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_portalcategory() {
global $_G;
$data = C::t('portal_category')->range_category();
foreach($data as $key => $value) {
$upid = $value['upid'];
$data[$key]['level'] = 0;
if($upid && isset($data[$upid])) {
$data[$upid]['children'][] = $key;
while($upid && isset($data[$upid])) {
$data[$key]['level'] += 1;
$upid = $data[$upid]['upid'];
}
}
}
$domain = $_G['setting']['domain'];
$channelrootdomain = !empty($domain['root']) && !empty($domain['root']['channel']) ? $domain['root']['channel'] : '';
$portaldomain = '';
if(!empty($domain['app']['portal'])) {
$portaldomain = $_G['scheme'].'://'.$domain['app']['portal'].$_G['siteroot'];
} elseif(!empty($domain['app']['default'])) {
$portaldomain = $_G['scheme'].'://'.$domain['app']['default'].$_G['siteroot'];
} else {
$portaldomain = $_G['siteurl'];
}
foreach($data as $key => &$value){
$url = $topid = '';
$foldername = $value['foldername'];
if($value['level']) {
$topid = $key;
$foldername = '';
while($data[$topid]['upid']) {
if($data[$topid]['foldername'] && $data[$key]['foldername']) {
$foldername = $data[$topid]['foldername'].'/'.$foldername;
}
$topid = $data[$topid]['upid'];
}
if($foldername) $foldername = $data[$topid]['foldername'].'/'.$foldername;
} else {
$topid = $key;
}
$value['topid'] = $topid;
if($channelrootdomain && $data[$topid]['domain']){
$url = $_G['scheme'].'://'.$data[$topid]['domain'].'.'.$channelrootdomain.'/';
if($foldername) {
if(!empty($value['upid'])) {
$url .= $foldername;
}
} else {
$url = $portaldomain.'portal.php?mod=list&catid='.$key;
}
} elseif ($foldername) {
$url = $portaldomain.$foldername;
if(substr($url, -1, 1) != '/') $url.= '/';
} else {
$url = $portaldomain.'portal.php?mod=list&catid='.$key;
}
$value['caturl'] = $url;
$value['fullfoldername'] = trim($foldername, '/');
if($value['shownav']) {
$rs = C::t('common_nav')->update_by_type_identifier(4, $key, array('url' => addslashes($url), 'name' =>$value['catname']));
}
}
savecache('portalcategory', $data);
if(!function_exists('get_cachedata_mainnav')) {
include_once libfile('cache/setting','function');
}
$data = $_G['setting'];
list($data['navs'], $data['subnavs'], $data['menunavs'], $data['navmns'], $data['navmn'], $data['navdms']) = get_cachedata_mainnav();
savecache('setting', $data);
}
?>

40
source/function/cache/cache_postimg.php vendored Normal file
View File

@@ -0,0 +1,40 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_postimg.php 31464 2012-08-30 08:59:27Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_postimg() {
$imgextarray = array('jpg', 'gif', 'png');
$imgdir = array('hrline', 'postbg');
$postimgjs = 'var postimg_type = new Array();';
foreach($imgdir as $perdir) {
$count = 0;
$pdir = DISCUZ_ROOT.'./static/image/'.$perdir;
$postimgdir = dir($pdir);
$postimgjs .= 'postimg_type["'.$perdir.'"]=[';
while($entry = $postimgdir->read()) {
if(in_array(strtolower(fileext($entry)), $imgextarray) && preg_match("/^[\w\-\.\[\]\(\)\<\> &]+$/", substr($entry, 0, strrpos($entry, '.'))) && strlen($entry) < 30 && is_file($pdir.'/'.$entry)) {
$postimg[$perdir][] = array('url' => $entry);
$postimgjs .= ($count ? ',' : '').'"'.$entry.'"';
$count++;
}
}
$postimgjs .='];';
$postimgdir->close();
}
savecache('postimg', $postimg);
$cachedir = DISCUZ_ROOT.'./data/cache/';
if(file_put_contents($cachedir.'common_postimg.js', $postimgjs, LOCK_EX) === false) {
exit('Can not write to cache files, please check directory ./data/ and ./data/cache/ .');
}
}
?>

View File

@@ -0,0 +1,20 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_profilesetting.php 24935 2011-10-17 07:41:48Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_profilesetting() {
$data = C::t('common_member_profile_setting')->fetch_all_by_available(1);
savecache('profilesetting', $data);
}
?>

View File

@@ -0,0 +1,28 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_relatedlink.php 24479 2011-09-21 06:40:33Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_relatedlink() {
global $_G;
$data = array();
$query = C::t('common_relatedlink')->range();
foreach($query as $link) {
if(!preg_match('/^https?:\/\//is', $link['url'])) {
$link['url'] = 'http://'.$link['url'];
}
$data[] = $link;
}
savecache('relatedlink', $data);
}
?>

35
source/function/cache/cache_secqaa.php vendored Normal file
View File

@@ -0,0 +1,35 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_secqaa.php 24522 2011-09-23 02:12:46Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_secqaa() {
$data = array();
$secqaanum = C::t('common_secquestion')->count();
$start_limit = $secqaanum <= 10 ? 0 : mt_rand(0, $secqaanum - 10);
$i = 1;
foreach(C::t('common_secquestion')->fetch_all_secquestion($start_limit, 10) as $secqaa) {
if(!$secqaa['type']) {
$secqaa['answer'] = md5($secqaa['answer']);
}
$data[$i] = $secqaa;
$i++;
}
if(!empty($data)) {
while(($secqaas = count($data)) < 9) {
$data[$secqaas + 1] = $data[array_rand($data)];
}
}
savecache('secqaa', $data);
}
?>

1170
source/function/cache/cache_setting.php vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,27 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_smileycodes.php 24968 2011-10-19 09:51:28Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_smileycodes() {
$data = array();
foreach(C::t('forum_imagetype')->fetch_all_by_type('smiley', 1) as $type) {
foreach(C::t('common_smiley')->fetch_all_by_type_code_typeid('smiley', $type['typeid']) as $smiley) {
if($size = @getimagesize('./static/image/smiley/'.$type['directory'].'/'.$smiley['url'])) {
$data[$smiley['id']] = $smiley['code'];
}
}
}
savecache('smileycodes', $data);
}
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_smileytypes.php 24968 2011-10-19 09:51:28Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_smileytypes() {
$data = array();
foreach(C::t('forum_imagetype')->fetch_all_by_type('smiley', 1) as $type) {
$typeid = $type['typeid'];
unset($type['typeid']);
if(C::t('common_smiley')->count_by_type_code_typeid('smiley', $typeid)) {
$data[$typeid] = $type;
}
}
savecache('smileytypes', $data);
}
?>

27
source/function/cache/cache_smilies.php vendored Normal file
View File

@@ -0,0 +1,27 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_smilies.php 24968 2011-10-19 09:51:28Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_smilies() {
$data = array();
$data = array('searcharray' => array(), 'replacearray' => array(), 'typearray' => array());
foreach(C::t('common_smiley')->fetch_all_cache() as $smiley) {
$data['searcharray'][$smiley['id']] = '/'.preg_quote(dhtmlspecialchars($smiley['code']), '/').'/';
$data['replacearray'][$smiley['id']] = $smiley['url'];
$data['typearray'][$smiley['id']] = $smiley['typeid'];
}
savecache('smilies', $data);
}
?>

View File

@@ -0,0 +1,62 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_smilies_js.php 24968 2011-10-19 09:51:28Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_smilies_js() {
global $_G;
$fastsmiley = C::t('common_setting')->fetch_setting('fastsmiley', true);
$return_type = 'var smilies_type = new Array();';
$return_array = 'var smilies_array = new Array();var smilies_fast = new Array();';
$spp = $_G['setting']['smcols'] * $_G['setting']['smrows'];
$fpre = '';
foreach(C::t('forum_imagetype')->fetch_all_by_type('smiley', 1) as $type) {
$return_data = array();
$return_datakey = '';
$i = 0;$j = 1;$pre = '';
$return_type .= 'smilies_type[\'_'.$type['typeid'].'\'] = [\''.str_replace('\'', '\\\'', $type['name']).'\', \''.str_replace('\'', '\\\'', $type['directory']).'\'];';
$return_datakey .= 'smilies_array['.$type['typeid'].'] = new Array();';
foreach(C::t('common_smiley')->fetch_all_by_type_code_typeid('smiley', $type['typeid']) as $smiley) {
if($i >= $spp) {
$return_data[$j] = 'smilies_array['.$type['typeid'].']['.$j.'] = ['.$return_data[$j].'];';
$j++;$i = 0;$pre = '';
}
if($size = @getimagesize(DISCUZ_ROOT.'./static/image/smiley/'.$type['directory'].'/'.$smiley['url'])) {
$smiley['code'] = str_replace('\'', '\\\'', $smiley['code']);
$smileyid = $smiley['id'];
$s = smthumb($size, $_G['setting']['smthumb']);
$smiley['w'] = $s['w'];
$smiley['h'] = $s['h'];
$l = smthumb($size);
$smiley['lw'] = $l['w'];
unset($smiley['id'], $smiley['directory']);
$return_data[$j] .= $pre.'[\''.$smileyid.'\', \''.$smiley['code'].'\',\''.str_replace('\'', '\\\'', $smiley['url']).'\',\''.$smiley['w'].'\',\''.$smiley['h'].'\',\''.$smiley['lw'].'\']';
if(is_array($fastsmiley[$type['typeid']]) && in_array($smileyid, $fastsmiley[$type['typeid']])) {
$return_fast .= $fpre.'[\''.$type['typeid'].'\',\''.$j.'\',\''.$i.'\']';
$fpre = ',';
}
$pre = ',';
}
$i++;
}
$return_data[$j] = 'smilies_array['.$type['typeid'].']['.$j.'] = ['.$return_data[$j].'];';
$return_array .= $return_datakey.implode('', $return_data);
}
$cachedir = DISCUZ_ROOT.'./data/cache/';
$common_smilies_var_js = 'var smthumb = \''.$_G['setting']['smthumb'].'\';'.$return_type.$return_array.'var smilies_fast=['.$return_fast.'];';
if(file_put_contents($cachedir.'common_smilies_var.js', $common_smilies_var_js, LOCK_EX) === false) {
exit('Can not write to cache files, please check directory ./data/ and ./data/cache/ .');
}
}
?>

25
source/function/cache/cache_split.php vendored Normal file
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: cache_split.php 24152 2011-08-26 10:04:08Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_split() {
global $_G;
$splitcaches = array('threadtableids', 'threadtable_info', 'posttable_info', 'posttableids');
foreach($splitcaches as $splitcache) {
loadcache($splitcache);
if(empty($_G['cache'][$splitcache])) {
savecache($splitcache, '');
}
}
}
?>

50
source/function/cache/cache_stamps.php vendored Normal file
View File

@@ -0,0 +1,50 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_stamps.php 25773 2011-11-22 04:22:39Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_stamps() {
$data = array();
$fillarray = range(0, 99);
$count = 0;
$repeats = $stampicon = array();
foreach(C::t('common_smiley')->fetch_all_by_type(array('stamp','stamplist')) as $stamp) {
if(isset($fillarray[$stamp['displayorder']])) {
unset($fillarray[$stamp['displayorder']]);
} else {
$repeats[] = $stamp['id'];
}
$count++;
}
foreach($repeats as $id) {
reset($fillarray);
$displayorder = current($fillarray);
unset($fillarray[$displayorder]);
C::t('common_smiley')->update($id, array('displayorder'=>$displayorder));
}
foreach(C::t('common_smiley')->fetch_all_by_type('stamplist') as $stamp) {
if($stamp['typeid'] < 1) {
continue;
}
$row = C::t('common_smiley')->fetch_by_id_type($stamp['typeid'], 'stamp');
$stampicon[$row['displayorder']] = $stamp['displayorder'];
}
foreach(C::t('common_smiley')->fetch_all_by_type(array('stamp','stamplist')) as $stamp) {
$icon = $stamp['type'] == 'stamp' ? (isset($stampicon[$stamp['displayorder']]) ? $stampicon[$stamp['displayorder']] : 0) :
($stamp['type'] == 'stamplist' && !in_array($stamp['displayorder'], $stampicon) ? 1 : 0);
$data[$stamp['displayorder']] = array('url' => $stamp['url'], 'text' => $stamp['code'], 'type' => $stamp['type'], 'icon' => $icon);
}
savecache('stamps', $data);
}
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_stamptypeid.php 24968 2011-10-19 09:51:28Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_stamptypeid() {
$data = array();
foreach(C::t('common_smiley')->fetch_all_by_type('stamp') as $stamp) {
if($stamp['typeid'] < 0) {
continue;
}
$data[$stamp['typeid']] = $stamp['displayorder'];
}
savecache('stamptypeid', $data);
}
?>

153
source/function/cache/cache_styles.php vendored Normal file
View File

@@ -0,0 +1,153 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_styles.php 36353 2017-01-17 07:19:28Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_styles() {
global $_G;
$stylevars = $styledata = array();
$defaultstyleid = $_G['setting']['styleid'];
foreach(C::t('common_stylevar')->range() as $var) {
$stylevars[$var['styleid']][$var['variable']] = $var['substitute'];
}
foreach(C::t('common_style')->fetch_all_data(true) as $data) {
$data['tpldir'] = $data['directory'];
$data = array_merge($data, (array)$stylevars[$data['styleid']]);
$datanew = array();
$data['imgdir'] = $data['imgdir'] ? $data['imgdir'] : STATICURL.'image/common';
$data['styleimgdir'] = $data['styleimgdir'] ? $data['styleimgdir'] : $data['imgdir'];
foreach($data as $k => $v) {
if(substr($k, -7, 7) == 'bgcolor') {
$newkey = substr($k, 0, -7).'bgcode';
$datanew[$newkey] = setcssbackground($data, $k);
}
}
$data = array_merge($data, $datanew);
if(strstr($data['boardimg'], ',')) {
$flash = explode(",", $data['boardimg']);
$flash[0] = trim($flash[0]);
$flash[0] = preg_match('/^(https?:)?\/\//i', $flash[0]) ? $flash[0] : $data['styleimgdir'].'/'.$flash[0];
$data['boardlogo'] = "<embed src=\"".$flash[0]."\" width=\"".trim($flash[1])."\" height=\"".trim($flash[2])."\" type=\"application/x-shockwave-flash\" wmode=\"transparent\"></embed>";
} else {
$data['boardimg'] = empty($data['boardimg']) ? $data['imgdir'].'/logo.svg' : (preg_match('/^(https?:)?\/\//i', $data['boardimg']) || file_exists(DISCUZ_ROOT.$data['boardimg']) ? '' : (file_exists(DISCUZ_ROOT.$data['styleimgdir'].'/'.$data['boardimg']) ? $data['styleimgdir'].'/' : $data['imgdir'].'/')).$data['boardimg'];
$data['boardlogo'] = "<img src=\"{$data['boardimg']}\" alt=\"".$_G['setting']['bbname']."\" class=\"boardlogo\" id=\"boardlogo\" border=\"0\" />";
}
$data['searchimg'] = empty($data['searchimg']) ? $data['imgdir'].'/logo_sc.svg' : (preg_match('/^(https?:)?\/\//i', $data['searchimg']) || file_exists(DISCUZ_ROOT.$data['searchimg']) ? '' : (file_exists(DISCUZ_ROOT.$data['styleimgdir'].'/'.$data['searchimg']) ? $data['styleimgdir'].'/' : $data['imgdir'].'/')).$data['searchimg'];
$data['searchlogo'] = "<img src=\"{$data['searchimg']}\" alt=\"".$_G['setting']['bbname']."\" class=\"searchlogo\" id=\"searchlogo\" border=\"0\" />";
$data['touchimg'] = empty($data['touchimg']) ? $data['imgdir'].'/logo_m.svg' : (preg_match('/^(https?:)?\/\//i', $data['touchimg']) || file_exists(DISCUZ_ROOT.$data['touchimg']) ? '' : (file_exists(DISCUZ_ROOT.$data['styleimgdir'].'/'.$data['touchimg']) ? $data['styleimgdir'].'/' : $data['imgdir'].'/')).$data['touchimg'];
$data['touchlogo'] = "<img src=\"{$data['touchimg']}\" alt=\"".$_G['setting']['bbname']."\" class=\"touchlogo\" id=\"touchlogo\" border=\"0\" />";
$data['bold'] = $data['nobold'] ? 'normal' : 'bold';
$contentwidthint = intval($data['contentwidth']);
$contentwidthint = $contentwidthint ? $contentwidthint : 600;
if($data['extstyle']) {
list($data['extstyle'], $data['defaultextstyle']) = explode('|', $data['extstyle']);
$extstyle = explode("\t", $data['extstyle']);
$data['extstyle'] = array();
foreach($extstyle as $dir) {
if(file_exists($extstylefile = DISCUZ_ROOT.$data['tpldir'].'/style/'.$dir.'/style.css')) {
if($data['defaultextstyle'] == $dir) {
$data['defaultextstyle'] = $data['tpldir'].'/style/'.$dir;
}
$content = file_get_contents($extstylefile);
if(preg_match('/\[name\](.+?)\[\/name\]/i', $content, $r1) && preg_match('/\[iconbgcolor](.+?)\[\/iconbgcolor]/i', $content, $r2)) {
$data['extstyle'][] = array($data['tpldir'].'/style/'.$dir, $r1[1], $r2[1]);
}
}
}
}
$data['verhash'] = random(3);
$styledata[] = $data;
}
foreach($styledata as $data) {
savecache('style_'.$data['styleid'], $data);
if($defaultstyleid == $data['styleid']) {
savecache('style_default', $data);
}
writetocsscache($data);
}
}
function setcssbackground(&$data, $code) {
$codes = explode(' ', $data[$code]);
$css = $codevalue = '';
for($i = 0; $i < count($codes); $i++) {
if($i < 2) {
if($codes[$i] != '') {
if($codes[$i][0] == '#') {
$css .= strtoupper($codes[$i]).' ';
$codevalue = strtoupper($codes[$i]);
} elseif(preg_match('/^(https?:)?\/\//i', $codes[$i])) {
$css .= 'url("'.$codes[$i].'") ';
} else {
$css .= 'url("'.$data['styleimgdir'].'/'.$codes[$i].'") ';
}
}
} else {
$css .= $codes[$i].' ';
}
}
$data[$code] = $codevalue;
$css = trim($css);
return $css ? 'background: '.$css : '';
}
function writetocsscache($data) {
global $_G;
$dir = DISCUZ_ROOT.'./template/default/common/';
$dh = opendir($dir);
$data['staticurl'] = STATICURL;
while(($entry = readdir($dh)) !== false) {
if(fileext($entry) == 'css') {
$cssfile = DISCUZ_ROOT.'./'.$data['tpldir'].'/common/'.$entry;
!file_exists($cssfile) && $cssfile = $dir.$entry;
$cssdata = @implode('', file($cssfile));
if(file_exists($cssfile = DISCUZ_ROOT.'./'.$data['tpldir'].'/common/extend_'.$entry)) {
$cssdata .= @implode('', file($cssfile));
}
if(is_array($_G['setting']['plugins']['available']) && $_G['setting']['plugins']['available']) {
foreach($_G['setting']['plugins']['available'] as $plugin) {
if(file_exists($cssfile = DISCUZ_ROOT.'./source/plugin/'.$plugin.'/template/extend_'.$entry)) {
$cssdata .= @implode('', file($cssfile));
}
}
}
writetocsscache_callback_1($data, 1);
$cssdata = preg_replace_callback("/\{([A-Z0-9]+)\}/", 'writetocsscache_callback_1', $cssdata);
$cssdata = preg_replace("/<\?.+?\?>\s*/", '', $cssdata);
$cssdata = !preg_match('/^(https?:)?\/\//i', $data['styleimgdir']) ? preg_replace("/url\(([\"'])?".preg_quote($data['styleimgdir'], '/')."/i", "url(\\1{$_G['siteurl']}{$data['styleimgdir']}", $cssdata) : $cssdata;
$cssdata = !preg_match('/^(https?:)?\/\//i', $data['imgdir']) ? preg_replace("/url\(([\"'])?".preg_quote($data['imgdir'], '/')."/i", "url(\\1{$_G['siteurl']}{$data['imgdir']}", $cssdata) : $cssdata;
$cssdata = !preg_match('/^(https?:)?\/\//i', $data['staticurl']) ? preg_replace("/url\(([\"'])?".preg_quote($data['staticurl'], '/')."/i", "url(\\1{$_G['siteurl']}{$data['staticurl']}", $cssdata) : $cssdata;
if($entry == 'module.css') {
$cssdata = preg_replace('/\/\*\*\s*(.+?)\s*\*\*\//', '[\\1]', $cssdata);
}
$cssdata = preg_replace(array('/\s*([,;:\{\}])\s*/', '/[\t\n\r]/', '/\/\*.+?\*\//'), array('\\1', '',''), $cssdata);
if(file_put_contents(DISCUZ_ROOT.'./data/cache/style_'.$data['styleid'].'_'.$entry, $cssdata, LOCK_EX) === false) {
exit('Can not write to cache files, please check directory ./data/ and ./data/cache/ .');
}
}
}
}
function writetocsscache_callback_1($matches, $action = 0) {
static $data = array();
if($action == 1) {
$data = $matches;
} else {
return $data[strtolower($matches[1])];
}
}
?>

View File

@@ -0,0 +1,102 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_threadsorts.php 26205 2011-12-05 10:09:32Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_threadsorts() {
$sortlist = $templatedata = $stemplatedata = $ptemplatedata = $btemplatedata = $template = array();
$query = C::t('forum_threadtype')->fetch_all_for_cache();
foreach($query as $data) {
$data['rules'] = dunserialize($data['rules']);
$sortid = $data['sortid'];
$optionid = $data['optionid'];
$sortlist[$sortid][$optionid] = array(
'title' => dhtmlspecialchars($data['title']),
'type' => dhtmlspecialchars($data['type']),
'unit' => dhtmlspecialchars($data['unit']),
'identifier' => dhtmlspecialchars($data['identifier']),
'description' => dhtmlspecialchars($data['description']),
'permprompt' => $data['permprompt'],
'required' => intval($data['required']),
'unchangeable' => intval($data['unchangeable']),
'search' => intval($data['search']),
'subjectshow' => intval($data['subjectshow']),
'expiration' => intval($data['expiration']),
'protect' => dunserialize($data['protect']),
);
if(in_array($data['type'], array('select', 'checkbox', 'radio'))) {
if($data['rules']['choices']) {
$choices = array();
foreach(explode("\n", $data['rules']['choices']) as $item) {
list($index, $choice) = explode('=', $item);
$choices[trim($index)] = trim($choice);
}
$sortlist[$sortid][$optionid]['choices'] = $choices;
} else {
$sortlist[$sortid][$optionid]['choices'] = array();
}
if($data['type'] == 'select') {
$sortlist[$sortid][$optionid]['inputsize'] = $data['rules']['inputsize'] ? intval($data['rules']['inputsize']) : 108;
}
} elseif(in_array($data['type'], array('text', 'textarea', 'calendar'))) {
$sortlist[$sortid][$optionid]['maxlength'] = intval($data['rules']['maxlength']);
if($data['type'] == 'textarea') {
$sortlist[$sortid][$optionid]['rowsize'] = $data['rules']['rowsize'] ? intval($data['rules']['rowsize']) : 5;
$sortlist[$sortid][$optionid]['colsize'] = $data['rules']['colsize'] ? intval($data['rules']['colsize']) : 50;
} else {
$sortlist[$sortid][$optionid]['inputsize'] = $data['rules']['inputsize'] ? intval($data['rules']['inputsize']) : '';
}
if(in_array($data['type'], array('text', 'textarea'))) {
$sortlist[$sortid][$optionid]['defaultvalue'] = $data['rules']['defaultvalue'];
}
if($data['type'] == 'text') {
$sortlist[$sortid][$optionid]['profile'] = $data['rules']['profile'];
}
} elseif($data['type'] == 'image') {
$sortlist[$sortid][$optionid]['maxwidth'] = intval($data['rules']['maxwidth']);
$sortlist[$sortid][$optionid]['maxheight'] = intval($data['rules']['maxheight']);
$sortlist[$sortid][$optionid]['inputsize'] = $data['rules']['inputsize'] ? intval($data['rules']['inputsize']) : '';
} elseif(in_array($data['type'], array('number', 'range'))) {
$sortlist[$sortid][$optionid]['inputsize'] = $data['rules']['inputsize'] ? intval($data['rules']['inputsize']) : '';
$sortlist[$sortid][$optionid]['maxnum'] = intval($data['rules']['maxnum']);
$sortlist[$sortid][$optionid]['minnum'] = intval($data['rules']['minnum']);
if($data['rules']['searchtxt']) {
$sortlist[$sortid][$optionid]['searchtxt'] = explode(',', $data['rules']['searchtxt']);
}
if($data['type'] == 'number') {
$sortlist[$sortid][$optionid]['defaultvalue'] = $data['rules']['defaultvalue'];
}
}
}
$query = C::t('forum_threadtype')->range();
foreach($query as $data) {
$templatedata[$data['typeid']] = addcslashes($data['template'], '",\\');
$stemplatedata[$data['typeid']] = addcslashes($data['stemplate'], '",\\');
$ptemplatedata[$data['typeid']] = addcslashes($data['ptemplate'], '",\\');
$btemplatedata[$data['typeid']] = addcslashes($data['btemplate'], '",\\');
}
$data['sortoption'] = $data['template'] = array();
foreach($sortlist as $sortid => $option) {
$template['viewthread'] = $templatedata[$sortid];
$template['subject'] = $stemplatedata[$sortid];
$template['post'] = $ptemplatedata[$sortid];
$template['block'] = $btemplatedata[$sortid];
savecache('threadsort_option_'.$sortid, $option);
savecache('threadsort_template_'.$sortid, $template);
}
}
?>

View File

@@ -0,0 +1,18 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_updatediytemplate.php 16693 2010-09-13 04:31:03Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_updatediytemplate() {
updatediytemplate();
}
?>

View File

@@ -0,0 +1,81 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_usergroups.php 32967 2013-03-28 10:57:48Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_usergroups() {
global $_G;
$data_uf = C::t('common_usergroup_field')->fetch_all_fields(null, array('groupid', 'readaccess', 'allowgetattach', 'allowgetimage', 'allowmediacode', 'maxsigsize', 'allowbegincode'));
foreach(C::t('common_usergroup')->range_orderby_creditshigher() as $key=>$value) {
$group = array_merge(array('groupid' => $value['groupid'], 'type' => $value['type'], 'grouptitle' => $value['grouptitle'], 'creditshigher' => $value['creditshigher'], 'creditslower' => $value['creditslower'], 'stars' => $value['stars'], 'color' => $value['color'], 'icon' => $value['icon'], 'system' => $value['system']), $data_uf[$key]);
if($group['type'] == 'special') {
if($group['system'] != 'private') {
list($dailyprice) = explode("\t", $group['system']);
$group['pubtype'] = $dailyprice > 0 ? 'buy' : 'free';
}
}
unset($group['system']);
$groupid = $group['groupid'];
$group['grouptitle'] = $group['color'] ? '<font color="'.$group['color'].'">'.$group['grouptitle'].'</font>' : $group['grouptitle'];
if($_G['setting']['userstatusby'] == 1) {
$group['userstatusby'] = 1;
} elseif($_G['setting']['userstatusby'] == 2) {
if($group['type'] != 'member') {
$group['userstatusby'] = 1;
} else {
$group['userstatusby'] = 2;
}
}
if($group['type'] != 'member') {
unset($group['creditshigher'], $group['creditslower']);
}
unset($group['groupid']);
$data[$groupid] = $group;
}
savecache('usergroups', $data);
build_cache_usergroups_single();
foreach(C::t('common_admingroup')->range() as $data) {
savecache('admingroup_'.$data['admingid'], $data);
}
}
function build_cache_usergroups_single() {
$pluginvalue = pluginsettingvalue('groups');
$allowthreadplugin = C::t('common_setting')->fetch_setting('allowthreadplugin', true);
$data_uf = C::t('common_usergroup_field')->range();
$data_ag = C::t('common_admingroup')->range();
foreach(C::t('common_usergroup')->range() as $gid => $data) {
$data = array_merge($data, (array)$data_uf[$gid], (array)$data_ag[$gid]);
$ratearray = array();
if($data['raterange']) {
foreach(explode("\n", $data['raterange']) as $rating) {
$rating = explode("\t", $rating);
$ratearray[$rating[0]] = array('isself' => $rating[1], 'min' => $rating[2], 'max' => $rating[3], 'mrpd' => $rating[4]);
}
}
$data['raterange'] = $ratearray;
$data['grouptitle'] = $data['color'] ? '<font color="'.$data['color'].'">'.$data['grouptitle'].'</font>' : $data['grouptitle'];
$data['grouptype'] = $data['type'];
$data['grouppublic'] = $data['system'] != 'private';
$data['groupcreditshigher'] = $data['creditshigher'];
$data['groupcreditslower'] = $data['creditslower'];
$data['maxspacesize'] = intval($data['maxspacesize']) * 1024 * 1024;
$data['allowthreadplugin'] = !empty($allowthreadplugin[$data['groupid']]) ? $allowthreadplugin[$data['groupid']] : array();
$data['plugin'] = $pluginvalue[$data['groupid']];
unset($data['type'], $data['system'], $data['creditshigher'], $data['creditslower'], $data['groupavatar'], $data['admingid']);
savecache('usergroup_'.$data['groupid'], $data);
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cache_userstats.php 26680 2011-12-20 01:05:48Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function build_cache_userstats() {
global $_G;
$totalmembers = C::t('common_member')->count();
$member = C::t('common_member')->range(0, 1, 'DESC');
$member = current($member);
$newsetuser = $member['username'];
$data = array('totalmembers' => $totalmembers, 'newsetuser' => $newsetuser);
if($_G['setting']['plugins']['func'][HOOKTYPE]['cacheuserstats']) {
$_G['userstatdata'] = & $data;
hookscript('cacheuserstats', 'global', 'funcs', array(), 'cacheuserstats');
}
savecache('userstats', $data);
}
?>

0
source/function/cache/index.htm vendored Normal file
View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,243 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_attachment.php 28348 2012-02-28 06:16:29Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function attachtype($type, $returnval = 'html') {
static $attachicons = array(
1 => 'unknown.gif',
2 => 'binary.gif',
3 => 'zip.gif',
4 => 'rar.gif',
5 => 'msoffice.gif',
6 => 'text.gif',
7 => 'html.gif',
8 => 'real.gif',
9 => 'av.gif',
10 => 'flash.gif',
11 => 'image.gif',
12 => 'pdf.gif',
13 => 'torrent.gif'
);
if(is_numeric($type)) {
$typeid = $type;
} else {
if(preg_match("/bittorrent|^torrent\t/", $type)) {
$typeid = 13;
} elseif(preg_match("/pdf|^pdf\t/", $type)) {
$typeid = 12;
} elseif(preg_match("/image|^(jpg|gif|png|bmp|webp)\t/", $type)) {
$typeid = 11;
} elseif(preg_match("/flash|^(swf|fla|flv|swi)\t/", $type)) {
$typeid = 10;
} elseif(preg_match("/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv|mov|mp4|m4a|m4v|3gp|ogv|ogg|webm|weba|aac|flac)\t/", $type)) {
$typeid = 9;
} elseif(preg_match("/real|^(ra|rm|rv)\t/", $type)) {
$typeid = 8;
} elseif(preg_match("/htm|^(php|js|pl|cgi|asp)\t/", $type)) {
$typeid = 7;
} elseif(preg_match("/text|^(txt|rtf|wri|chm)\t/", $type)) {
$typeid = 6;
} elseif(preg_match("/word|excel|powerpoint|^(doc|xls|ppt|docx|xlsx|pptx)\t/", $type)) {
$typeid = 5;
} elseif(preg_match("/^rar\t/", $type)) {
$typeid = 4;
} elseif(preg_match("/compressed|^(zip|arj|arc|cab|lzh|lha|tar|gz|7z|xz|bz2)\t/", $type)) {
$typeid = 3;
} elseif(preg_match("/octet-stream|^(exe|com|bat|dll)\t/", $type)) {
$typeid = 2;
} elseif($type) {
$typeid = 1;
} else {
$typeid = 0;
}
}
if($returnval == 'html') {
return '<img src="'.STATICURL.'image/filetype/'.$attachicons[$typeid].'" border="0" class="vm" alt="" />';
} elseif($returnval == 'id') {
return $typeid;
}
}
function parseattach($attachpids, $attachtags, &$postlist, $skipaids = array()) {
global $_G, $aimgs, $firstimgs;
if(!$attachpids) {
return;
}
$attachpids = is_array($attachpids) ? $attachpids : array($attachpids);
$attachexists = FALSE;
$skipattachcode = $aids = $payaids = $findattach = array();
foreach(C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$_G['tid'], 'pid', $attachpids) as $attach) {
$attachexists = TRUE;
if($skipaids && in_array($attach['aid'], $skipaids)) {
$skipattachcode[$attach['pid']][] = "/\[attach\]{$attach['aid']}\[\/attach\]/i";
continue;
}
$attached = 0;
$extension = strtolower(fileext($attach['filename']));
$attach['ext'] = $extension;
$attach['imgalt'] = $attach['isimage'] ? strip_tags(str_replace('"', '', $attach['description'] ? $attach['description'] : $attach['filename'])) : '';
$attach['attachicon'] = attachtype($extension."\t".$attach['filetype']);
$attach['attachsize'] = sizecount($attach['filesize']);
if($attach['isimage'] && !$_G['setting']['attachimgpost']) {
$attach['isimage'] = 0;
}
$attach['attachimg'] = $attach['isimage'] && (!$attach['readperm'] || $_G['group']['readaccess'] >= $attach['readperm']) ? 1 : 0;
if($attach['attachimg']) {
$aimgs[$attach['pid']][] = $attach['aid'];
}
if($attach['price']) {
if($_G['setting']['maxchargespan'] && TIMESTAMP - $attach['dateline'] >= $_G['setting']['maxchargespan'] * 3600) {
C::t('forum_attachment_n')->update_attachment('tid:'.$_G['tid'], $attach['aid'], array('price' => 0));
$attach['price'] = 0;
} elseif(!$_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']) {
$payaids[$attach['aid']] = $attach['pid'];
}
}
$attach['payed'] = $_G['forum_attachmentdown'] || $_G['uid'] == $attach['uid'] ? 1 : 0;
$attach['url'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/';
$attach['dbdateline'] = $attach['dateline'];
$attach['dateline'] = dgmdate($attach['dateline'], 'u');
$hideattachs = $_G['adminid'] != 1 && $_G['setting']['bannedmessages'] & 1 && (($postlist[$attach['pid']]['authorid'] && !$postlist[$attach['pid']]['username'])
|| ($postlist[$attach['pid']]['groupid'] == 4 || $postlist[$attach['pid']]['groupid'] == 5) || $postlist[$attach['pid']]['status'] == -1 || $postlist[$attach['pid']]['memberstatus'])
|| $_G['adminid'] != 1 && $postlist[$attach['pid']]['status'] & 1 || $postlist[$attach['pid']]['first'] && $_G['forum_threadpay'];
if(!$hideattachs) {
if(defined('IN_MOBILE_API')) {
$attach['aidencode'] = packaids($attach);
}
$postlist[$attach['pid']]['attachments'][$attach['aid']] = $attach;
}
if(!defined('IN_MOBILE_API') && !empty($attachtags[$attach['pid']]) && is_array($attachtags[$attach['pid']]) && in_array($attach['aid'], $attachtags[$attach['pid']])) {
$findattach[$attach['pid']][$attach['aid']] = "/\[attach\]{$attach['aid']}\[\/attach\]/i";
$attached = 1;
}
if(!$attached) {
if($attach['isimage']) {
if(!$hideattachs) {
$postlist[$attach['pid']]['imagelist'][] = $attach['aid'];
$postlist[$attach['pid']]['imagelistcount']++;
}
if($postlist[$attach['pid']]['first']) {
$firstimgs[] = $attach['aid'];
}
} else {
if(!$hideattachs && (!$_G['forum_skipaidlist'] || !in_array($attach['aid'], $_G['forum_skipaidlist']))) {
$postlist[$attach['pid']]['attachlist'][] = $attach['aid'];
}
}
}
$aids[] = $attach['aid'];
}
if($aids) {
$attachs = C::t('forum_attachment')->fetch_all($aids);
foreach($attachs as $aid => $attach) {
if($postlist[$attach['pid']]) {
$postlist[$attach['pid']]['attachments'][$attach['aid']]['downloads'] = $attach['downloads'];
}
}
}
if($payaids) {
foreach(C::t('common_credit_log')->fetch_all_by_uid_operation_relatedid($_G['uid'], 'BAC', array_keys($payaids)) as $creditlog) {
$postlist[$payaids[$creditlog['relatedid']]]['attachments'][$creditlog['relatedid']]['payed'] = 1;
}
}
if(!empty($skipattachcode)) {
foreach($skipattachcode as $pid => $findskipattach) {
foreach($findskipattach as $findskip) {
$postlist[$pid]['message'] = preg_replace($findskip, '', $postlist[$pid]['message']);
}
}
}
if($attachexists) {
foreach($attachtags as $pid => $aids) {
if($findattach[$pid]) {
foreach($findattach[$pid] as $aid => $find) {
$postlist[$pid]['message'] = preg_replace($find, attachinpost($postlist[$pid]['attachments'][$aid], $postlist[$pid]), $postlist[$pid]['message'], 1);
$postlist[$pid]['message'] = preg_replace($find, '', $postlist[$pid]['message']);
}
}
}
} else {
loadcache('posttableids');
$posttableids = $_G['cache']['posttableids'] ? $_G['cache']['posttableids'] : array('0');
foreach($posttableids as $id) {
C::t('forum_post')->update_post($id, $attachpids, array('attachment' => '0'), true);
}
}
}
function attachwidth($width) {
global $_G;
if($_G['setting']['imagemaxwidth'] && $width) {
return 'class="zoom" onclick="zoom(this, this.src, 0, 0, '.($_G['setting']['showexif'] ? 1 : 0).')" width="'.($width > $_G['setting']['imagemaxwidth'] ? $_G['setting']['imagemaxwidth'] : $width).'"';
} else {
return 'thumbImg="1"';
}
}
function packaids($attach) {
global $_G;
return aidencode($attach['aid'], 0, $_G['tid']);
}
function showattach($post, $type = 0) {
$type = !$type ? 'attachlist' : 'imagelist';
$return = '';
if(!empty($post[$type]) && is_array($post[$type])) {
foreach($post[$type] as $aid) {
if(!empty($post['attachments'][$aid])) {
$return .= $type($post['attachments'][$aid], $post['first']);
}
}
}
return $return;
}
function getattachexif($aid, $path = '') {
global $_G;
$return = $filename = '';
if(!$path) {
if($attach = C::t('forum_attachment_n')->fetch_attachment('aid:'.$aid, $aid, array(1, -1))) {
if($attach['remote']) {
$filename = $_G['setting']['ftp']['attachurl'].'forum/'.$attach['attachment'];
} else {
$filename = $_G['setting']['attachdir'].'forum/'.$attach['attachment'];
}
}
} else {
$filename = $path;
}
if($filename) {
require_once libfile('function/exif');
$exif = getexif($filename);
$keys = array(
exif_lang('Model'),
exif_lang('ShutterSpeedValue'),
exif_lang('ApertureValue'),
exif_lang('FocalLength'),
exif_lang('ExposureTime'),
exif_lang('DateTimeOriginal'),
exif_lang('ISOSpeedRatings'),
);
foreach($exif as $key => $value) {
if(in_array($key, $keys)) {
$return .= "$key : $value<br />";
}
}
}
return $return;
}
?>

File diff suppressed because it is too large Load Diff

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: function_blog.php 36278 2016-12-09 07:52:35Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function blog_check_url($url) {
$url = durlencode(trim($url));
if(preg_match("/^(https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\//i", $url)) {
$return = '<a href="'.$url.'" target="_blank">';
} else {
$return = '<a href="'.(!empty($GLOBALS['_G']['siteurl']) ? $GLOBALS['_G']['siteurl'] : 'http://').$url.'" target="_blank">';
}
return $return;
}
function blog_post($POST, $olds=array()) {
global $_G, $space;
$isself = 1;
if(!empty($olds['uid']) && $olds['uid'] != $_G['uid']) {
$isself = 0;
$__G = $_G;
$_G['uid'] = $olds['uid'];
$_G['username'] = addslashes($olds['username']);
}
$POST['subject'] = empty($_GET['subject']) ? '' : (dstrlen($_GET['subject']) > $_G['setting']['maxsubjectsize'] ? getstr($_GET['subject'], $_G['setting']['maxsubjectsize']) : $_GET['subject']);
$POST['subject'] = censor($POST['subject'], NULL, FALSE, FALSE);
if(strlen($POST['subject'])<1) $POST['subject'] = dgmdate($_G['timestamp'], 'Y-m-d');
$POST['friend'] = intval($POST['friend']);
$POST['target_ids'] = '';
if($POST['friend'] == 2) {
$uids = array();
$names = empty($_POST['target_names'])?array():explode(',', preg_replace("/(\s+)/s", ',', $_POST['target_names']));
if($names) {
$uids = C::t('common_member')->fetch_all_uid_by_username($names);
}
if(empty($uids)) {
$POST['friend'] = 3;
} else {
$POST['target_ids'] = implode(',', $uids);
}
} elseif($POST['friend'] == 4) {
$POST['password'] = trim($POST['password']);
if($POST['password'] == '') $POST['friend'] = 0;
}
if($POST['friend'] !== 2) {
$POST['target_ids'] = '';
}
if($POST['friend'] !== 4) {
$POST['password'] = '';
}
$POST['tag'] = dhtmlspecialchars(trim($POST['tag']));
$POST['tag'] = getstr($POST['tag'], 500);
$POST['tag'] = censor($POST['tag']);
if($POST['plaintext'] == true){
$POST['message'] = nl2br($POST['message']);
}
$POST['message'] = preg_replace("/\<div\>\<\/div\>/i", '', $POST['message']);
$POST['message'] = checkhtml($POST['message']);
$POST['message'] = getstr($POST['message'], 0, 0, 0, 0, 1);
$POST['message'] = censor($POST['message'], NULL, FALSE, FALSE);
$POST['message'] = preg_replace_callback("/<a .*?href=\"(.*?)\".*?>/is", 'blog_post_callback_blog_check_url_1', $POST['message']);
$message = $POST['message'];
if(censormod($message) || censormod($POST['subject']) || $_G['group']['allowblogmod']) {
$blog_status = 1;
} else {
$blog_status = 0;
}
if(empty($olds['classid']) || $POST['classid'] != $olds['classid']) {
if(!empty($POST['classid']) && substr($POST['classid'], 0, 4) == 'new:') {
$classname = dhtmlspecialchars(trim(substr($POST['classid'], 4)));
$classname = getstr($classname);
$classname = censor($classname);
if(empty($classname)) {
$classid = 0;
} else {
$classid = C::t('home_class')->fetch_classid_by_uid_classname($_G['uid'], $classname);
if(empty($classid)) {
$setarr = array(
'classname' => $classname,
'uid' => $_G['uid'],
'dateline' => $_G['timestamp']
);
$classid = C::t('home_class')->insert($setarr, true);
}
}
} else {
$classid = intval($POST['classid']);
}
} else {
$classid = $olds['classid'];
}
if($classid && empty($classname)) {
$query = C::t('home_class')->fetch($classid);
$classname = ($query['uid'] == $_G['uid']) ? $query['classname'] : '';
if(empty($classname)) $classid = 0;
}
$blogarr = array(
'subject' => $POST['subject'],
'classid' => $classid,
'friend' => $POST['friend'],
'password' => $POST['password'],
'noreply' => empty($POST['noreply'])?0:1,
'catid' => intval($POST['catid']),
'status' => $blog_status,
);
$titlepic = '';
$uploads = array();
if(!empty($POST['picids'])) {
$picids = array_keys($POST['picids']);
$query = C::t('home_pic')->fetch_all_by_uid($_G['uid'], 0, 0, $picids);
foreach($query as $value) {
if(empty($titlepic) && $value['thumb']) {
$titlepic = getimgthumbname($value['filepath']);
$blogarr['picflag'] = $value['remote']?2:1;
}
$picurl = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0);
$uploads[md5($picurl)] = $value;
}
if(empty($titlepic) && $value) {
$titlepic = $value['filepath'];
$blogarr['picflag'] = $value['remote']?2:1;
}
}
if($uploads) {
$albumid = 0;
if($POST['savealbumid'] < 0 && !empty($POST['newalbum'])) {
$albumname = addslashes(dhtmlspecialchars(trim($POST['newalbum'])));
if(empty($albumname)) $albumname = dgmdate($_G['timestamp'],'Ymd');
$albumarr = array('albumname' => $albumname);
$albumid = album_creat($albumarr);
} else {
$albumid = $POST['savealbumid'] < 0 ? 0 : intval($POST['savealbumid']);
$albuminfo = C::t('home_album')->fetch_album($albumid, $_G['uid']);
if(empty($albuminfo)) {
$albumid = 0;
}
}
if($albumid) {
C::t('home_pic')->update_for_uid($_G['uid'], $picids, array('albumid' => $albumid));
album_update_pic($albumid);
}
preg_match_all("/\s*\<img src=\"(.+?)\".*?\>\s*/is", $message, $mathes);
if(!empty($mathes[1])) {
foreach ($mathes[1] as $key => $value) {
$urlmd5 = md5($value);
if(!empty($uploads[$urlmd5])) {
unset($uploads[$urlmd5]);
}
}
}
foreach ($uploads as $value) {
$picurl = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0);
$message .= "<div class=\"uchome-message-pic\"><img src=\"$picurl\"><p>{$value['title']}</p></div>";
}
}
$ckmessage = preg_replace("/(\<div\>|\<\/div\>|\s|\&nbsp\;|\<br\>|\<p\>|\<\/p\>)+/is", '', $message);
if(empty($ckmessage)) {
return false;
}
if(checkperm('manageblog')) {
$blogarr['hot'] = intval($POST['hot']);
}
if($olds['blogid']) {
if($blogarr['catid'] != $olds['catid']) {
if($olds['catid']) {
C::t('home_blog_category')->update_num_by_catid(-1, $olds['catid'], true, true);
}
if($blogarr['catid']) {
C::t('home_blog_category')->update_num_by_catid(1, $blogarr['catid']);
}
}
$blogid = $olds['blogid'];
C::t('home_blog')->update($blogid, $blogarr);
$fuids = array();
$blogarr['uid'] = $olds['uid'];
$blogarr['username'] = $olds['username'];
} else {
if($blogarr['catid']) {
C::t('home_blog_category')->update_num_by_catid(1, $blogarr['catid']);
}
$blogarr['uid'] = $_G['uid'];
$blogarr['username'] = $_G['username'];
$blogarr['dateline'] = empty($POST['dateline'])?$_G['timestamp']:$POST['dateline'];
$blogid = C::t('home_blog')->insert($blogarr, true);
C::t('common_member_status')->update($_G['uid'], array('lastpost' => $_G['timestamp']));
C::t('common_member_field_home')->update($_G['uid'], array('recentnote'=>$POST['subject']));
}
$blogarr['blogid'] = $blogid;
$class_tag = new tag();
$POST['tag'] = $olds ? $class_tag->update_field($POST['tag'], $blogid, 'blogid') : $class_tag->add_tag($POST['tag'], $blogid, 'blogid');
$fieldarr = array(
'message' => $message,
'postip' => $_G['clientip'],
'port' => $_G['remoteport'],
'target_ids' => $POST['target_ids'],
'tag' => $POST['tag']
);
if(!empty($titlepic)) {
$fieldarr['pic'] = $titlepic;
}
if($olds) {
C::t('home_blogfield')->update($blogid, $fieldarr);
} else {
$fieldarr['blogid'] = $blogid;
$fieldarr['uid'] = $blogarr['uid'];
C::t('home_blogfield')->insert($fieldarr);
}
if($isself && !$olds && $blog_status == 0) {
updatecreditbyaction('publishblog', 0, array('blogs' => 1));
include_once libfile('function/stat');
updatestat('blog');
}
if($olds['blogid'] && $blog_status == 1) {
updatecreditbyaction('publishblog', 0, array('blogs' => -1), '', -1);
include_once libfile('function/stat');
updatestat('blog');
}
if($POST['makefeed'] && $blog_status == 0) {
include_once libfile('function/feed');
feed_publish($blogid, 'blogid', $olds?0:1);
}
if(!empty($__G)) $_G = $__G;
if($blog_status == 1) {
updatemoderate('blogid', $blogid);
manage_addnotify('verifyblog');
}
return $blogarr;
}
function blog_post_callback_blog_check_url_1($matches) {
return blog_check_url($matches[1]);
}
function checkhtml($html) {
if(!checkperm('allowhtml')) {
preg_match_all("/\<([^\<]+)\>/is", $html, $ms);
$searchs[] = '<';
$replaces[] = '&lt;';
$searchs[] = '>';
$replaces[] = '&gt;';
if($ms[1]) {
$allowtags = 'img|a|font|div|table|tbody|caption|tr|td|th|br|p|b|strong|i|u|em|span|ol|ul|li|blockquote';
$ms[1] = array_unique($ms[1]);
foreach ($ms[1] as $value) {
$searchs[] = "&lt;".$value."&gt;";
$value = str_replace('&amp;', '_uch_tmp_str_', $value);
$value = dhtmlspecialchars($value);
$value = str_replace('_uch_tmp_str_', '&amp;', $value);
$value = str_replace(array('\\','/*'), array('.','/.'), $value);
$skipkeys = array('onabort','onactivate','onafterprint','onafterupdate','onbeforeactivate','onbeforecopy','onbeforecut','onbeforedeactivate',
'onbeforeeditfocus','onbeforepaste','onbeforeprint','onbeforeunload','onbeforeupdate','onblur','onbounce','oncellchange','onchange',
'onclick','oncontextmenu','oncontrolselect','oncopy','oncut','ondataavailable','ondatasetchanged','ondatasetcomplete','ondblclick',
'ondeactivate','ondrag','ondragend','ondragenter','ondragleave','ondragover','ondragstart','ondrop','onerror','onerrorupdate',
'onfilterchange','onfinish','onfocus','onfocusin','onfocusout','onhelp','onkeydown','onkeypress','onkeyup','onlayoutcomplete',
'onload','onlosecapture','onmousedown','onmouseenter','onmouseleave','onmousemove','onmouseout','onmouseover','onmouseup','onmousewheel',
'onmove','onmoveend','onmovestart','onpaste','onpropertychange','onreadystatechange','onreset','onresize','onresizeend','onresizestart',
'onrowenter','onrowexit','onrowsdelete','onrowsinserted','onscroll','onselect','onselectionchange','onselectstart','onstart','onstop',
'onsubmit','onunload','javascript','script','eval','behaviour','expression','style','class');
$skipstr = implode('|', $skipkeys);
$value = preg_replace(array("/($skipstr)/i"), '.', $value);
if(!preg_match("/^[\/|\s]?($allowtags)(\s+|$)/is", $value)) {
$value = '';
}
$replaces[] = empty($value)?'':"<".str_replace('&quot;', '"', $value).">";
}
}
$html = str_replace($searchs, $replaces, $html);
}
return $html;
}
function blog_bbcode($message) {
require_once libfile('function/discuzcode');
$message = preg_replace_callback("/\[media=([\w%,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/i", 'discuzcode_callback_parsemedia_12', $message);
$message = preg_replace_callback("/\[flash\=?(media|real|mp3)*\](.+?)\[\/flash\]/i", 'blog_bbcode_callback_blog_flash_21', $message);
return $message;
}
function blog_bbcode_callback_blog_flash_21($matches) {
return blog_flash($matches[2], $matches[1]);
}
function blog_flash($url, $type='') {
$width = '520';
$height = '390';
preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.)[^\[\"']+/i", $url, $matches);
$url = $matches[0];
require_once libfile('function/discuzcode');
if($flv = parseflv($url, $width, $height)) {
return $flv;
}
$type = fileext($url);
$randomid = random(3);
return '<ignore_js_op><div id="'.$type.'_'.$randomid.'" class="media"><div id="'.$type.'_'.$randomid.'_container" class="media_container"></div><div id="'.$type.'_'.$randomid.'_tips" class="media_tips"><a href="'.$url.'" target="_blank">'.lang('template', 'parse_av_tips').'</a></div></div><script type="text/javascript">detectPlayer("'.$type.'_'.$randomid.'", "'.$type.'", "'.$url.'", "'.$width.'", "'.$height.'");</script></ignore_js_op>';
}
?>

View File

@@ -0,0 +1,174 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_cache.php 33604 2013-07-16 03:20:08Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function updatecache($cachename = '') {
$updatelist = empty($cachename) ? array() : (is_array($cachename) ? $cachename : array($cachename));
if(!$updatelist) {
@include_once libfile('cache/setting', 'function');
build_cache_setting();
$cachedir = DISCUZ_ROOT.'./source/function/cache';
$cachedirhandle = dir($cachedir);
while($entry = $cachedirhandle->read()) {
if(!in_array($entry, array('.', '..')) && preg_match("/^cache\_([\_\w]+)\.php$/", $entry, $entryr) && $entryr[1] != 'setting' && substr($entry, -4) == '.php' && is_file($cachedir.'/'.$entry)) {
@include_once libfile('cache/'.$entryr[1], 'function');
call_user_func('build_cache_'.$entryr[1]);
}
}
foreach(C::t('common_plugin')->fetch_all_data(1) as $plugin) {
$dir = substr($plugin['directory'], 0, -1);
$cachedir = DISCUZ_ROOT.'./source/plugin/'.$dir.'/cache';
if(file_exists($cachedir)) {
$cachedirhandle = dir($cachedir);
while($entry = $cachedirhandle->read()) {
if(!in_array($entry, array('.', '..')) && preg_match("/^cache\_([\_\w]+)\.php$/", $entry, $entryr) && substr($entry, -4) == '.php' && is_file($cachedir.'/'.$entry)) {
@include_once libfile('cache/'.$entryr[1], 'plugin/'.$dir);
call_user_func('build_cache_plugin_'.$entryr[1]);
}
}
}
}
} else {
foreach($updatelist as $entry) {
$entrys = explode(':', $entry);
if(count($entrys) == 1) {
@include_once libfile('cache/'.$entry, 'function');
call_user_func('build_cache_'.$entry);
} else {
@include_once libfile('cache/'.$entrys[1], 'plugin/'.$entrys[0]);
call_user_func('build_cache_plugin_'.$entrys[1]);
}
}
}
}
function writetocache($script, $cachedata, $prefix = 'cache_') {
global $_G;
$dir = DISCUZ_ROOT.'./data/sysdata/';
if(!is_dir($dir)) {
dmkdir($dir, 0777);
}
$s = "<?php\n//Discuz! cache file, DO NOT modify me!\n//Identify: ".md5($prefix.$script.'.php'.$cachedata.$_G['config']['security']['authkey'])."\n\n$cachedata?>";
$fp = fopen("$dir$prefix$script.php", 'cb');
if(!($fp && flock($fp, LOCK_EX) && ftruncate($fp, 0) && fwrite($fp, $s) && fflush($fp) && flock($fp, LOCK_UN) && fclose($fp))) {
flock($fp, LOCK_UN);
fclose($fp);
unlink("$dir$prefix$script.php");
exit('Can not write to cache files, please check directory ./data/ and ./data/sysdata/ .');
}
}
function getcachevars($data, $type = 'VAR') {
$evaluate = '';
foreach($data as $key => $val) {
if(!preg_match("/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/", $key)) {
continue;
}
if(is_array($val)) {
$evaluate .= "\$$key = ".arrayeval($val).";\n";
} else {
$val = addcslashes($val, '\'\\');
$evaluate .= $type == 'VAR' ? "\$$key = '$val';\n" : "define('".strtoupper($key)."', '$val');\n";
}
}
return $evaluate;
}
function smthumb($size, $smthumb = 50) {
if($size[0] <= $smthumb && $size[1] <= $smthumb) {
return array('w' => $size[0], 'h' => $size[1]);
}
$sm = array();
$x_ratio = $smthumb / $size[0];
$y_ratio = $smthumb / $size[1];
if(($x_ratio * $size[1]) < $smthumb) {
$sm['h'] = ceil($x_ratio * $size[1]);
$sm['w'] = $smthumb;
} else {
$sm['w'] = ceil($y_ratio * $size[0]);
$sm['h'] = $smthumb;
}
return $sm;
}
function arrayeval($array, $level = 0) {
if(!is_array($array)) {
return "'".$array."'";
}
if(is_array($array) && function_exists('var_export')) {
return var_export($array, true);
}
$space = '';
for($i = 0; $i <= $level; $i++) {
$space .= "\t";
}
$evaluate = "Array\n$space(\n";
$comma = $space;
if(is_array($array)) {
foreach($array as $key => $val) {
$key = is_string($key) ? '\''.addcslashes($key, '\'\\').'\'' : $key;
$val = !is_array($val) && (!preg_match("/^\-?[1-9]\d*$/", $val) || strlen($val) > 12) ? '\''.addcslashes($val, '\'\\').'\'' : $val;
if(is_array($val)) {
$evaluate .= "$comma$key => ".arrayeval($val, $level + 1);
} else {
$evaluate .= "$comma$key => $val";
}
$comma = ",\n$space";
}
}
$evaluate .= "\n$space)";
return $evaluate;
}
function pluginsettingvalue($type) {
$pluginsetting = $pluginvalue = array();
@include DISCUZ_ROOT.'./data/sysdata/cache_pluginsetting.php';
$pluginsetting = isset($pluginsetting[$type]) ? $pluginsetting[$type] : array();
$varids = $pluginids = array();
foreach($pluginsetting as $pluginid => $v) {
foreach($v['setting'] as $varid => $var) {
$varids[] = $varid;
$pluginids[$varid] = $pluginid;
}
}
if($varids) {
foreach(C::t('common_pluginvar')->fetch_all($varids) as $plugin) {
$values = (array)dunserialize($plugin['value']);
foreach($values as $id => $value) {
$pluginvalue[$id][$pluginids[$plugin['pluginvarid']]][$plugin['variable']] = $value;
}
}
}
return $pluginvalue;
}
function cleartemplatecache() {
$tpl = dir(DISCUZ_ROOT.'./data/template');
while($entry = $tpl->read()) {
if(preg_match("/\.tpl\.php$/", $entry)) {
@unlink(DISCUZ_ROOT.'./data/template/'.$entry);
}
}
$tpl->close();
}
?>

View File

@@ -0,0 +1,447 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_cloudaddons.php 36333 2016-12-30 02:29:39Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$addonsource = !empty($_G['config']['addonsource']) ? $_G['config']['addonsource'] : (!empty($_G['setting']['addon_source']) ? $_G['setting']['addon_source'] : array());
$addon = $addonsource ?
$_G['config']['addon'][$addonsource] :
array(
'website_url' => 'https://addon.dismall.com',
'download_url' => 'https://addon.dismall.com/index.php',
'download_ip' => '',
'check_url' => 'https://addon1.dismall.com/md5/',
'check_ip' => '',
);
define('CLOUDADDONS_WEBSITE_URL', $addon['website_url']);
define('CLOUDADDONS_DOWNLOAD_URL', $addon['download_url']);
define('CLOUDADDONS_DOWNLOAD_IP', $addon['download_ip']);
define('CLOUDADDONS_CHECK_URL', $addon['check_url']);
define('CLOUDADDONS_CHECK_IP', $addon['check_ip']);
function cloudaddons_md5($file) {
return dfsockopen(CLOUDADDONS_CHECK_URL.$file, 0, '', '', false, CLOUDADDONS_CHECK_IP, 999);
}
function cloudaddons_getuniqueid() {
global $_G;
if(CLOUDADDONS_WEBSITE_URL == 'https://addon.dismall.com') {
return $_G['setting']['siteuniqueid'] ? $_G['setting']['siteuniqueid'] : C::t('common_setting')->fetch_setting('siteuniqueid');
} else {
if(!$_G['setting']['addon_uniqueid']) {
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$addonuniqueid = $chars[date('y')%60].$chars[date('n')].$chars[date('j')].$chars[date('G')].$chars[date('i')].$chars[date('s')].substr(md5($_G['clientip'].TIMESTAMP), 0, 4).random(6);
C::t('common_setting')->update_setting('addon_uniqueid', $addonuniqueid);
require_once libfile('function/cache');
updatecache('setting');
}
return $_G['setting']['addon_uniqueid'];
}
}
function cloudaddons_url($extra) {
global $_G;
require_once DISCUZ_ROOT.'./source/discuz_version.php';
$data = 'siteuniqueid='.rawurlencode(cloudaddons_getuniqueid()).'&siteurl='.rawurlencode($_G['siteurl']).'&sitever='.DISCUZ_VERSION.'/'.DISCUZ_RELEASE.'&sitecharset='.CHARSET.'&mysiteid='.$_G['setting']['my_siteid'].'&addonversion=1&dlip='.CLOUDADDONS_DOWNLOAD_IP.'&os='.PHP_OS .'&php='.PHP_VERSION.'&web='.$_SERVER['SERVER_SOFTWARE'].'&db='.helper_dbtool::dbversion().'&lang='.currentlang();
$param = 'data='.rawurlencode(base64_encode($data));
$param .= '&md5hash='.substr(md5($data.TIMESTAMP), 8, 8).'&timestamp='.TIMESTAMP;
return CLOUDADDONS_DOWNLOAD_URL.'?'.$param.$extra;
}
function cloudaddons_check() {
if(!function_exists('gzuncompress')) {
cpmsg('cloudaddons_check_gzuncompress_error', '', 'error');
}
if(!function_exists('curl_init') || !function_exists('curl_exec')) {
cpmsg('cloudaddons_check_curl_error', '', 'error');
}
foreach(array('download', 'addonmd5') as $path) {
$tmpdir = DISCUZ_ROOT.'./data/'.$path.'/'.random(5);
$tmpfile = $tmpdir.'/index.html';
dmkdir($tmpdir, 0777);
if(!is_dir($tmpdir) || !file_exists($tmpfile)) {
cpmsg('cloudaddons_check_write_error', '', 'error');
}
@unlink($tmpfile);
@rmdir($tmpdir);
if(is_dir($tmpdir) || file_exists($tmpfile)) {
cpmsg('cloudaddons_check_write_error', '', 'error');
}
}
}
function cloudaddons_open($extra, $post = '', $timeout = 15) {
return dfsockopen(cloudaddons_url('&from=s').$extra, 0, $post, '', false, CLOUDADDONS_DOWNLOAD_IP, $timeout);
}
function cloudaddons_pluginlogo_url($id, $type = 'plugin') {
return CLOUDADDONS_WEBSITE_URL.'?_'.$id.'&type='.$type;
}
function cloudaddons_installlog($addonid) {
$array = cloudaddons_getmd5($addonid);
if($array['RevisionID']) {
cloudaddons_open('&mod=app&ac=installlog&rid='.$array['RevisionID']);
}
}
function cloudaddons_downloadlog($addonid) {
$array = cloudaddons_getmd5($addonid);
if($array['RevisionID']) {
cloudaddons_open('&mod=app&ac=downloadlog&rid='.$array['RevisionID']);
}
}
function cloudaddons_faillog($rid, $type) {
$rid = intval($rid);
$type = intval($type);
cloudaddons_open('&mod=app&ac=faillog&rid='.$rid.'&type='.$type.'&serverinfo='.urlencode($_SERVER['SERVER_SOFTWARE']));
}
function cloudaddons_removelog($rid) {
global $_G;
cloudaddons_open('&mod=app&ac=removelog&rid='.$rid);
}
function cloudaddons_validator($addonid) {
$array = cloudaddons_getmd5($addonid);
if(cloudaddons_open('&mod=app&ac=validator&ver=2&addonid='.$addonid.($array !== false ? '&rid='.$array['RevisionID'].'&sn='.$array['SN'].'&rd='.$array['RevisionDateline'] : '')) === '0') {
cpmsg('cloudaddons_genuine_message', '', 'error', array('addonid' => $addonid));
}
}
function cloudaddons_upgradecheck($addonids) {
$post = array();
foreach($addonids as $addonid) {
$array = cloudaddons_getmd5($addonid);
if($array) {
$post[] = 'rid['.$addonid.']='.$array['RevisionID'].'&sn['.$addonid.']='.$array['SN'].'&rd['.$addonid.']='.$array['RevisionDateline'];
} else {
$post[] = 'rid['.$addonid.']=&sn['.$addonid.']=&rd['.$addonid.']=';
}
}
return cloudaddons_open('&mod=app&ac=validator&ver=2', implode('&', $post), 15);
}
function cloudaddons_recommendaddon($addonids) {
$post = array();
foreach($addonids as $addonid) {
$array = cloudaddons_getmd5($addonid);
if($array) {
$post[] = 'rid['.$addonid.']='.$array['RevisionID'].'&sn['.$addonid.']='.$array['SN'].'&rd['.$addonid.']='.$array['RevisionDateline'];
} else {
$post[] = 'rid['.$addonid.']=&sn['.$addonid.']=&rd['.$addonid.']=';
}
}
return cloudaddons_open('&mod=app&ac=newaddon&ver=2', implode('&', $post), 15);
}
function cloudaddons_getmd5($md5file) {
$array = array();
if(preg_match('/^[a-z0-9_\.]+$/i', $md5file) && file_exists(DISCUZ_ROOT.'./data/addonmd5/'.$md5file.'.xml')) {
require_once libfile('class/xml');
$xml = implode('', @file(DISCUZ_ROOT.'./data/addonmd5/'.$md5file.'.xml'));
$array = xml2array($xml);
} else {
return false;
}
return $array;
}
function cloudaddons_uninstall($md5file, $dir) {
$array = cloudaddons_getmd5($md5file);
if($array === false) {
return;
}
if(!empty($array['RevisionID'])) {
cloudaddons_removelog($array['RevisionID']);
}
@unlink(DISCUZ_ROOT.'./data/addonmd5/'.$md5file.'.xml');
cloudaddons_cleardir($dir);
}
function cloudaddons_savemd5($md5file, $end, $md5) {
global $_G;
parse_str($end, $r);
require_once libfile('class/xml');
$data = $array = array();
if(file_exists(DISCUZ_ROOT.'./data/addonmd5/'.$md5file.'.xml')) {
$xml = implode('', @file(DISCUZ_ROOT.'./data/addonmd5/'.$md5file.'.xml'));
$array = xml2array($xml);
}
if(!empty($array['RevisionID'])) {
foreach(explode(',', $array['RevisionID']) as $i => $rid) {
$sns = explode(',', $array['SN']);
$datalines = explode(',', $array['RevisionDateline']);
$data[$rid]['SN'] = $sns[$i];
$data[$rid]['RevisionDateline'] = $datalines[$i];
}
}
$data[$r['RevisionID']]['SN'] = $r['SN'];
$data[$r['RevisionID']]['RevisionDateline'] = $r['RevisionDateline'];
$array['Title'] = 'Discuz! Addon MD5';
$array['ID'] = $r['ID'];
$array['RevisionDateline'] = $array['SN'] = $array['RevisionID'] = array();
foreach($data as $rid => $tmp) {
$array['RevisionID'][] = $rid;
$array['SN'][] = $tmp['SN'];
$array['RevisionDateline'][] = $tmp['RevisionDateline'];
}
$array['RevisionID'] = implode(',', $array['RevisionID']);
$array['SN'] = implode(',', $array['SN']);
$array['RevisionDateline'] = implode(',', $array['RevisionDateline']);
$array['Data'] = $array['Data'] ? array_merge($array['Data'], $md5) : $md5;
if(!isset($_G['siteftp'])) {
dmkdir(DISCUZ_ROOT.'./data/addonmd5/', 0777, false);
file_put_contents(DISCUZ_ROOT.'./data/addonmd5/'.$md5file.'.xml', array2xml($array));
} else {
$localfile = DISCUZ_ROOT.'./data/'.random(5);
file_put_contents($localfile, array2xml($array));
dmkdir(DISCUZ_ROOT.'./data/addonmd5/', 0777, false);
siteftp_upload($localfile, 'data/addonmd5/'.$md5file.'.xml');
@unlink($localfile);
}
}
function cloudaddons_comparetree($new, $old, $basedir, $md5file = '', $first = 0) {
global $_G;
if($first && file_exists(DISCUZ_ROOT.'./data/addonmd5/'.$md5file.'.xml')) {
require_once libfile('class/xml');
$xml = implode('', @file(DISCUZ_ROOT.'./data/addonmd5/'.$md5file.'.xml'));
$array = xml2array($xml);
$_G['treeop']['md5old'] = $array['Data'];
}
$dh = opendir($new);
while(($file = readdir($dh)) !== false) {
if($file != '.' && $file != '..') {
$newfile = $new.'/'.$file;
$oldfile = $old.'/'.$file;
if(is_file($newfile)) {
$oldfile = preg_replace('/\._addons_$/', '', $oldfile);
$md5key = str_replace($basedir, '', preg_replace('/\._addons_$/', '', $newfile));
$newmd5 = md5_file($newfile);
$oldmd5 = file_exists($oldfile) ? md5_file($oldfile) : '';
if(isset($_G['treeop']['md5old'][$md5key]) && $_G['treeop']['md5old'][$md5key] != $oldmd5 && $oldmd5) {
$_G['treeop']['oldchange'][] = $md5key;
}
if($newmd5 != $oldmd5) {
$_G['treeop']['copy'][] = $newfile;
}
$_G['treeop']['md5'][$md5key] = $newmd5;
} else {
cloudaddons_comparetree($newfile, $oldfile, $basedir);
}
}
}
}
function cloudaddons_copytree($from, $to) {
global $_G;
$dh = opendir($from);
while(($file = readdir($dh)) !== false) {
if($file != '.' && $file != '..') {
$readfile = $from.'/'.$file;
$writefile = $to.'/'.$file;
if(is_file($readfile)) {
if(!is_array($_G['treeop']['copy']) || !in_array($readfile, $_G['treeop']['copy'])) {
continue;
}
if(!isset($_G['siteftp'])) {
$content = false;
if($fp = @fopen($readfile, 'r')) {
$startTime = microtime();
do {
$canRead = flock($fp, LOCK_SH);
if(!$canRead) {
usleep(round(rand(0, 100) * 1000));
}
} while ((!$canRead) && ((microtime() - $startTime) < 1000));
if(!$canRead) {
cpmsg('cloudaddons_file_read_error', '', 'error');
}
if(filesize($readfile) == 0) {
$content = '';
} else {
$content = fread($fp, filesize($readfile));
flock($fp, LOCK_UN);
fclose($fp);
}
}
if($content === false) {
cpmsg('cloudaddons_file_read_error', '', 'error');
}
dmkdir(dirname($writefile), 0777, false);
$writefile = preg_replace('/\._addons_$/', '', $writefile);
if($fp = fopen($writefile, 'w')) {
$startTime = microtime();
do {
$canWrite = flock($fp, LOCK_EX);
if(!$canWrite) {
usleep(round(rand(0, 100) * 1000));
}
} while ((!$canWrite) && ((microtime() - $startTime) < 1000));
if(!$canWrite) {
cpmsg('cloudaddons_file_write_error', '', 'error');
}
fwrite($fp, $content);
flock($fp, LOCK_UN);
fclose($fp);
}
if(!$canWrite) {
cpmsg('cloudaddons_file_write_error', '', 'error');
}
} else {
$writefile = preg_replace('/\._addons_$/', '', $writefile);
siteftp_upload($readfile, preg_replace('/^'.preg_quote(DISCUZ_ROOT).'/', '', $writefile));
}
if(md5_file($readfile) != md5_file($writefile)) {
cpmsg('cloudaddons_file_write_error', '', 'error');
}
} else {
cloudaddons_copytree($readfile, $writefile);
}
}
}
}
function cloudaddons_deltree($dir) {
if($directory = @dir($dir)) {
while($entry = $directory->read()) {
if($entry == '.' || $entry == '..') {
continue;
}
$filename = $dir.'/'.$entry;
if(is_file($filename)) {
@unlink($filename);
} else {
cloudaddons_deltree($filename);
}
}
$directory->close();
@rmdir($dir);
}
}
function cloudaddons_cleardir($dir) {
if(is_dir($dir)) {
cloudaddons_deltree($dir);
}
}
function cloudaddons_dirwriteable($basedir, $dir, $sourcedir) {
$checkdirs = array($dir);
cloudaddons_getsubdirs($sourcedir, $dir, $checkdirs);
$return = array();
foreach($checkdirs as $k => $dir) {
$writeable = false;
$checkdir = $basedir.'/'.$dir;
if(!is_dir($checkdir)) {
@mkdir($checkdir, 0777);
}
if(is_dir($checkdir)) {
$fp = fopen($checkdir.'/test.txt', 'w');
if($fp) {
fclose($fp);
unlink($checkdir.'/test.txt');
$writeable = true;
} else {
$writeable = false;
}
}
if(!$writeable && $dir) {
$return[] = $dir;
}
}
return $return;
}
function cloudaddons_getsubdirs($dir, $root, &$return) {
static $prefix = false;
if($prefix === false) {
$prefix = strlen($dir) + 1;
}
$dh = opendir($dir);
while(($file = readdir($dh)) !== false) {
if($file != '.' && $file != '..') {
$readfile = $dir.'/'.$file;
if(is_dir($readfile)) {
$return[] = $root.'/'.substr($readfile, $prefix);
cloudaddons_getsubdirs($readfile, $root, $return);
}
}
}
}
function cloudaddons_http_build_query($formdata, $numeric_prefix = null, $key = null) {
$res = array();
foreach((array) $formdata as $k => $v) {
$tmp_key = urlencode(is_int($k) ? $numeric_prefix . $k : $k);
if ($key) {
$tmp_key = $key.'['.$tmp_key.']';
}
if (is_array($v) || is_object($v)) {
$res[] = cloudaddons_http_build_query($v, null, $tmp_key);
} else {
$res[] = $tmp_key.'='.urlencode($v);
}
}
return implode('&', $res);
}
function cloudaddons_clear($type, $id) {
global $_G;
if(isset($_G['config']['plugindeveloper']) && $_G['config']['plugindeveloper'] > 0) {
return;
}
$dirs = array('plugin' => array('plugin', './source/plugin/'), 'template' => array('style', './template/'));
if($dirs[$type] && cloudaddons_getmd5($id.'.'.$type)) {
$entrydir = DISCUZ_ROOT.$dirs[$type][1].$id;
$d = dir($entrydir);
$filedeleted = false;
while($f = $d->read()) {
if(preg_match('/^discuz\_'.$dirs[$type][0].'\_'.$id.'(\_\w+)?\.xml$/', $f)) {
if($type == 'plugin' && !$filedeleted) {
$pluginarray = getimportdata('Discuz! Plugin');
if($pluginarray['installfile']) {
@unlink($entrydir.'/'.$pluginarray['installfile']);
}
if($pluginarray['upgradefile']) {
@unlink($entrydir.'/'.$pluginarray['upgradefile']);
}
$filedeleted = true;
}
@unlink($entrydir.'/'.$f);
}
}
}
}
function versioncompatible($versions) {
global $_G;
list($currentversion) = explode(' ', trim(strip_tags($_G['setting']['version'])));
$versions = strip_tags($versions);
foreach(explode(',', $versions) as $version) {
list($version) = explode(' ', trim($version));
if($version && ($currentversion === $version)) {
return true;
}
}
return false;
}
?>

View File

@@ -0,0 +1,164 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_collection.php 31438 2012-08-28 06:03:08Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function getmycollection($uid) {
$collections = C::t('forum_collection')->fetch_all_by_uid($uid);
$collectionteamworker = C::t('forum_collectionteamworker')->fetch_all_by_uid($uid);
return $collections + $collectionteamworker;
}
function getHotCollection($number = 500, $pK = true) {
$collection = array();
if($number > 0) {
$collection = C::t('forum_collection')->range_collection(0, $number, 10, $pK);
if(!$collection || count($collection) < $number) {
$collection += C::t('forum_collection')->range_collection(0, $number, null, $pK);
}
}
return $collection;
}
function checkcollectionperm($collection, $uid, $allowteamworker = false) {
global $_G;
if($_G['group']['allowmanagecollection'] == 1) {
return true;
}
if($collection['uid'] == $uid) {
return true;
}
if($allowteamworker) {
$collectionteamworker = C::t('forum_collectionteamworker')->fetch_all_by_ctid($collection['ctid']);
$collectionteamworker = array_keys($collectionteamworker);
if(in_array($uid, $collectionteamworker)) {
return true;
}
}
return false;
}
function processCollectionData($collection, $tf = array(), $orderby = '') {
if(count($collection) <= 0) {
return array();
}
require_once libfile('function/discuzcode');
foreach($collection as $ctid=>&$curvalue) {
$curvalue['updated'] = ($curvalue['lastupdate'] > $tf[$ctid]['lastvisit']) ? 1 : 0;
$curvalue['tflastvisit'] = $tf[$ctid]['lastvisit'];
$curvalue['lastupdate'] = dgmdate($curvalue['lastupdate']);
$curvalue['dateline'] = dgmdate($curvalue['dateline']);
$curvalue['lastposttime'] = dgmdate($curvalue['lastposttime']);
$curvalue['avgrate'] = number_format($curvalue['rate'], 1);
$curvalue['star'] = imgdisplayrate($curvalue['rate']);
$curvalue['lastposterhtml'] = rawurlencode($curvalue['lastposter']);
$curvalue['shortdesc'] = cutstr(strip_tags(discuzcode($curvalue['desc'])), 50);
$curvalue['arraykeyword'] = parse_keyword($curvalue['keyword'], false, false);
if($curvalue['arraykeyword']) {
foreach ($curvalue['arraykeyword'] as $kid=>$s_keyword) {
$curvalue['urlkeyword'][$kid] = rawurlencode($s_keyword);
}
}
if($orderby == 'commentnum') {
$curvalue['displaynum'] = $curvalue['commentnum'];
} elseif($orderby == 'follownum') {
$curvalue['displaynum'] = $curvalue['follownum'];
} else {
$curvalue['displaynum'] = $curvalue['threadnum'];
}
}
return $collection;
}
function collectionThread(&$threadlist, $foruminfo = false, $lastvisit = null, &$collectiontids = null) {
global $todaytime;
if($foruminfo) {
foreach ($threadlist as $thread) {
$fids[$thread['fid']] = $thread['fid'];
}
$foruminfo = C::t('forum_forum')->fetch_all($fids);
}
foreach($threadlist as $curtid=>&$curvalue) {
if($lastvisit) {
$curvalue['reason'] = &$collectiontids[$curtid]['reason'];
$curvalue['updatedthread'] = $lastvisit !== null && $lastvisit < $curvalue['dateline'] ? 1 : 0;
}
if($foruminfo) {
$curvalue['forumname'] = $foruminfo[$curvalue['fid']]['name'];
}
$curvalue['istoday'] = $curvalue['dateline'] > $todaytime ? 1 : 0;
$curvalue['dbdateline'] = $curvalue['dateline'];
$curvalue['htmlsubject'] = dhtmlspecialchars($curvalue['subject']);
$curvalue['cutsubject'] = $curvalue['subject'];
$curvalue['dateline'] = dgmdate($curvalue['dateline'], 'u', '9999', getglobal('setting/dateformat'));
$curvalue['dblastpost'] = $curvalue['lastpost'];
$curvalue['lastpost'] = dgmdate($curvalue['lastpost'], 'u');
$curvalue['lastposterenc'] = rawurlencode($curvalue['lastposter']);
}
if($collectiontids) {
foreach($collectiontids as $curkey=>&$curthread) {
if(!$threadlist[$curthread['tid']]) {
unset($collectiontids[$curkey]);
} else {
$curthread = $threadlist[$curthread['tid']] + $curthread;
}
}
}
}
function imgdisplayrate($rate) {
$roundscore = floor($rate);
return $roundscore;
}
function parse_keyword($keywords, $string = false, $filter = true) {
if($keywords == '') {
return $string === true ? '' : array();
}
$return = array();
if($filter === true) {
$keywords = str_replace(array(chr(0xa3).chr(0xac), chr(0xa1).chr(0x41), chr(0xef).chr(0xbc).chr(0x8c)), ',', censor($keywords));
}
if(strexists($keywords, ',')) {
$tagarray = array_unique(explode(',', $keywords));
} else {
$langcore = lang('core');
$keywords = str_replace($langcore['fullblankspace'], ' ', $keywords);
$tagarray = array_unique(explode(' ', $keywords));
}
$tagcount = 0;
foreach($tagarray as $tagname) {
$tagname = trim($tagname);
if(preg_match('/^([\x7f-\xff_-]|\w|\s){3,20}$/', $tagname)) {
$tagcount++;
$return[] = $tagname;
if($tagcount > 4) {
unset($tagarray);
break;
}
}
}
if($string === true) {
$return = implode(',', $return);
}
return $return;
}
?>

View File

@@ -0,0 +1,329 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_comment.php 33714 2013-08-07 01:42:26Z andyzheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function add_comment($message, $id, $idtype, $cid = 0) {
global $_G, $bbcode;
$allowcomment = false;
switch($idtype) {
case 'uid':
$allowcomment = helper_access::check_module('wall');
break;
case 'picid':
$allowcomment = helper_access::check_module('album');
break;
case 'blogid':
$allowcomment = helper_access::check_module('blog');
break;
case 'sid':
$allowcomment = helper_access::check_module('share');
break;
}
if(!$allowcomment) {
showmessage('quickclear_noperm');
}
$summay = getstr($message, 150, 0, 0, 0, -1);
$comment = array();
if($cid) {
$comment = C::t('home_comment')->fetch_by_id_idtype($id, $idtype, $cid);
if($comment && $comment['authorid'] != $_G['uid']) {
$comment['message'] = preg_replace("/\<div class=\"quote\"\>\<blockquote\>.*?\<\/blockquote\>\<\/div\>/is", '', $comment['message']);
$comment['message'] = $bbcode->html2bbcode($comment['message']);
$message = ("<div class=\"quote\"><blockquote><b>".$comment['author']."</b>: ".getstr($comment['message'], 150, 0, 0, 2, 1).'</blockquote></div>').$message;
if($comment['idtype'] == 'uid') {
$id = $comment['authorid'];
}
} else {
$comment = array();
}
}
$hotarr = array();
$stattype = '';
$tospace = $pic = $blog = $album = $share = $poll = array();
switch($idtype) {
case 'uid':
$tospace = getuserbyuid($id);
$stattype = 'wall';
break;
case 'picid':
$pic = C::t('home_pic')->fetch($id);
if(empty($pic)) {
showmessage('view_images_do_not_exist');
}
$picfield = C::t('home_picfield')->fetch($id);
$pic['hotuser'] = $picfield['hotuser'];
$tospace = getuserbyuid($pic['uid']);
$album = array();
if($pic['albumid']) {
$album = C::t('home_album')->fetch_album($pic['albumid']);
if(!$album['albumid']) {
C::t('home_pic')->update_for_albumid($pic['albumid'], array('albumid' => 0));
}
}
if(!ckfriend($album['uid'], $album['friend'], $album['target_ids'])) {
showmessage('no_privilege_ckfriend_pic');
} elseif(!$tospace['self'] && $album['friend'] == 4) {
$cookiename = "view_pwd_album_{$album['albumid']}";
$cookievalue = empty($_G['cookie'][$cookiename])?'':$_G['cookie'][$cookiename];
if($cookievalue != md5(md5($album['password']))) {
showmessage('no_privilege_ckpassword_pic');
}
}
$hotarr = array('picid', $pic['picid'], $pic['hotuser']);
$stattype = 'piccomment';
break;
case 'blogid':
$blog = array_merge(
C::t('home_blog')->fetch($id),
C::t('home_blogfield')->fetch_targetids_by_blogid($id)
);
if(empty($blog)) {
showmessage('view_to_info_did_not_exist');
}
$tospace = getuserbyuid($blog['uid']);
if(!ckfriend($blog['uid'], $blog['friend'], $blog['target_ids'])) {
showmessage('no_privilege_ckfriend_blog');
} elseif(!$tospace['self'] && $blog['friend'] == 4) {
$cookiename = "view_pwd_blog_{$blog['blogid']}";
$cookievalue = empty($_G['cookie'][$cookiename])?'':$_G['cookie'][$cookiename];
if($cookievalue != md5(md5($blog['password']))) {
showmessage('no_privilege_ckpassword_blog');
}
}
if(!empty($blog['noreply'])) {
showmessage('do_not_accept_comments');
}
if($blog['target_ids']) {
$blog['target_ids'] .= ",{$blog['uid']}";
}
$hotarr = array('blogid', $blog['blogid'], $blog['hotuser']);
$stattype = 'blogcomment';
break;
case 'sid':
$share = C::t('home_share')->fetch($id);
if(empty($share)) {
showmessage('sharing_does_not_exist');
}
$tospace = getuserbyuid($share['uid']);
$hotarr = array('sid', $share['sid'], $share['hotuser']);
$stattype = 'sharecomment';
break;
default:
showmessage('non_normal_operation');
break;
}
if(empty($tospace)) {
showmessage('space_does_not_exist', '', array(), array('return' => true));
}
if(isblacklist($tospace['uid'])) {
showmessage('is_blacklist');
}
if($hotarr && $tospace['uid'] != $_G['uid']) {
hot_update($hotarr[0], $hotarr[1], $hotarr[2]);
}
$fs = array();
$fs['icon'] = 'comment';
$fs['target_ids'] = '';
$fs['friend'] = '';
$fs['body_template'] = '';
$fs['body_data'] = array();
$fs['body_general'] = '';
$fs['images'] = array();
$fs['image_links'] = array();
switch ($idtype) {
case 'uid':
$fs['icon'] = 'wall';
$fs['title_template'] = 'feed_comment_space';
$fs['title_data'] = array('touser'=>"<a href=\"home.php?mod=space&uid={$tospace['uid']}\">{$tospace['username']}</a>");
break;
case 'picid':
$fs['title_template'] = 'feed_comment_image';
$fs['title_data'] = array('touser'=>"<a href=\"home.php?mod=space&uid={$tospace['uid']}\">".$tospace['username']."</a>");
$fs['body_template'] = '{pic_title}';
$fs['body_data'] = array('pic_title'=>$pic['title']);
$fs['body_general'] = $summay;
$fs['images'] = array(pic_get($pic['filepath'], 'album', $pic['thumb'], $pic['remote']));
$fs['image_links'] = array("home.php?mod=space&uid={$tospace['uid']}&do=album&picid={$pic['picid']}");
$fs['target_ids'] = $album['target_ids'];
$fs['friend'] = $album['friend'];
break;
case 'blogid':
C::t('home_blog')->increase($id, 0, array('replynum'=>1));
$fs['title_template'] = 'feed_comment_blog';
$fs['title_data'] = array('touser'=>"<a href=\"home.php?mod=space&uid={$tospace['uid']}\">".$tospace['username']."</a>", 'blog'=>"<a href=\"home.php?mod=space&uid={$tospace['uid']}&do=blog&id=$id\">{$blog['subject']}</a>");
$fs['target_ids'] = $blog['target_ids'];
$fs['friend'] = $blog['friend'];
break;
case 'sid':
$fs['title_template'] = 'feed_comment_share';
$fs['title_data'] = array('touser'=>"<a href=\"home.php?mod=space&uid={$tospace['uid']}\">".$tospace['username']."</a>", 'share'=>"<a href=\"home.php?mod=space&uid={$tospace['uid']}&do=share&id=$id\">".str_replace(lang('spacecp', 'share_action'), '', $share['title_template'])."</a>");
break;
}
$message = censor($message, NULL, FALSE, FALSE);
if(censormod($message) || $_G['group']['allowcommentmod']) {
$comment_status = 1;
} else {
$comment_status = 0;
}
$setarr = array(
'uid' => $tospace['uid'],
'id' => $id,
'idtype' => $idtype,
'authorid' => $_G['uid'],
'author' => $_G['username'],
'dateline' => $_G['timestamp'],
'message' => $message,
'ip' => $_G['clientip'],
'port' => $_G['remoteport'],
'status' => $comment_status,
);
$cid = C::t('home_comment')->insert($setarr, true);
$action = 'comment';
$becomment = 'getcomment';
$note = $q_note = '';
$note_values = $q_values = array();
switch ($idtype) {
case 'uid':
$n_url = "home.php?mod=space&uid={$tospace['uid']}&do=wall&cid=$cid";
$note_type = 'wall';
$note = 'wall';
$note_values = array('url'=>$n_url);
$q_note = 'wall_reply';
$q_values = array('url'=>$n_url);
if($comment) {
$msg = 'note_wall_reply_success';
$magvalues = array('username' => $tospace['username']);
$becomment = '';
} else {
$msg = 'do_success';
$magvalues = array();
$becomment = 'getguestbook';
}
$action = 'guestbook';
break;
case 'picid':
$n_url = "home.php?mod=space&uid={$tospace['uid']}&do=album&picid=$id&cid=$cid";
$note_type = 'comment';
$note = 'pic_comment';
$note_values = array('url'=>$n_url);
$q_note = 'pic_comment_reply';
$q_values = array('url'=>$n_url);
$msg = 'do_success';
$magvalues = array();
break;
case 'blogid':
$n_url = "home.php?mod=space&uid={$tospace['uid']}&do=blog&id=$id&cid=$cid";
$note_type = 'comment';
$note = 'blog_comment';
$note_values = array('url'=>$n_url, 'subject'=>$blog['subject']);
$q_note = 'blog_comment_reply';
$q_values = array('url'=>$n_url);
$msg = 'do_success';
$magvalues = array();
break;
case 'sid':
$n_url = "home.php?mod=space&uid={$tospace['uid']}&do=share&id=$id&cid=$cid";
$note_type = 'comment';
$note = 'share_comment';
$note_values = array('url'=>$n_url);
$q_note = 'share_comment_reply';
$q_values = array('url'=>$n_url);
$msg = 'do_success';
$magvalues = array();
break;
}
if(empty($comment)) {
if($tospace['uid'] != $_G['uid']) {
if(ckprivacy('comment', 'feed')) {
require_once libfile('function/feed');
$fs['title_data']['hash_data'] = "{$idtype}{$id}";
feed_add($fs['icon'], $fs['title_template'], $fs['title_data'], $fs['body_template'], $fs['body_data'], $fs['body_general'],$fs['images'], $fs['image_links'], $fs['target_ids'], $fs['friend']);
}
$note_values['from_id'] = $id;
$note_values['from_idtype'] = $idtype;
$note_values['url'] .= "&goto=new#comment_{$cid}_li";
notification_add($tospace['uid'], $note_type, $note, $note_values);
}
} elseif($comment['authorid'] != $_G['uid']) {
notification_add($comment['authorid'], $note_type, $q_note, $q_values);
}
if($comment_status == 1) {
updatemoderate($idtype.'_cid', $cid);
manage_addnotify('verifycommontes');
}
if($stattype) {
include_once libfile('function/stat');
updatestat($stattype);
}
if($tospace['uid'] != $_G['uid']) {
$needle = $id;
if($idtype != 'uid') {
$needle = $idtype.$id;
} else {
$needle = $tospace['uid'];
}
updatecreditbyaction($action, 0, array(), $needle);
if($becomment) {
if($idtype == 'uid') {
$needle = $_G['uid'];
}
updatecreditbyaction($becomment, $tospace['uid'], array(), $needle);
}
}
C::t('common_member_status')->update($_G['uid'], array('lastpost' => $_G['timestamp']), 'UNBUFFERED');
$magvalues['cid'] = $cid;
return array('cid' => $cid, 'msg' => $msg, 'magvalues' => $magvalues);
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,266 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_credit.php 36284 2016-12-12 00:47:50Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function _checklowerlimit($action, $uid = 0, $coef = 1, $fid = 0, $returnonly = 0) {
global $_G;
include_once libfile('class/credit');
$credit = & credit::instance();
$limit = $credit->lowerlimit($action, $uid, $coef, $fid);
if($returnonly) return $limit;
if($limit !== true) {
$GLOBALS['id'] = $limit;
$lowerlimit = is_array($action) && $action['extcredits'.$limit] ? abs($action['extcredits'.$limit]) + $_G['setting']['creditspolicy']['lowerlimit'][$limit] : $_G['setting']['creditspolicy']['lowerlimit'][$limit];
$rulecredit = array();
if(!is_array($action)) {
$rule = $credit->getrule($action, $fid);
foreach($_G['setting']['extcredits'] as $extcreditid => $extcredit) {
if($rule['extcredits'.$extcreditid]) {
$rulecredit[] = $extcredit['title'].($rule['extcredits'.$extcreditid] > 0 ? '+'.$rule['extcredits'.$extcreditid] : $rule['extcredits'.$extcreditid]);
}
}
} else {
$rule = array();
}
$values = array(
'title' => $_G['setting']['extcredits'][$limit]['title'],
'lowerlimit' => $lowerlimit,
'unit' => $_G['setting']['extcredits'][$limit]['unit'],
'ruletext' => $rule['rulename'],
'rulecredit' => implode(', ', $rulecredit)
);
if(!is_array($action)) {
if(!$fid) {
showmessage('credits_policy_lowerlimit', '', $values);
} else {
showmessage('credits_policy_lowerlimit_fid', '', $values);
}
} else {
showmessage('credits_policy_lowerlimit_norule', '', $values);
}
}
}
function _updatemembercount($uids, $dataarr = array(), $checkgroup = true, $operation = '', $relatedid = 0, $ruletxt = '', $customtitle = '', $custommemo = '') {
if(empty($uids)) return;
if(!is_array($dataarr) || empty($dataarr)) return;
if($operation && $relatedid || $customtitle) {
$writelog = true;
} else {
$writelog = false;
}
$data = $log = array();
foreach($dataarr as $key => $val) {
if(empty($val)) continue;
$val = intval($val);
$id = intval($key);
$id = !$id && substr($key, 0, -1) == 'extcredits' ? intval(substr($key, -1, 1)) : $id;
if(0 < $id && $id < 9) {
$data['extcredits'.$id] = $val;
if($writelog) {
$log['extcredits'.$id] = $val;
}
} else {
$data[$key] = $val;
}
}
if($writelog) {
credit_log($uids, $operation, $relatedid, $log, $customtitle, $custommemo);
}
if($data) {
include_once libfile('class/credit');
$credit = & credit::instance();
$credit->updatemembercount($data, $uids, $checkgroup, $ruletxt);
}
}
function credit_log($uids, $operation, $relatedid, $data, $customtitle = '', $custommemo = '') {
if((!$operation || empty($relatedid)) && !strlen($customtitle) || empty($uids) || empty($data)) {
return;
}
$log = array(
'uid' => $uids,
'operation' => $operation,
'relatedid' => $relatedid,
'dateline' => TIMESTAMP,
);
foreach($data as $k => $v) {
$log[$k] = $v;
}
if(is_array($uids)) {
foreach($uids as $k => $uid) {
$log['uid'] = $uid;
$log['relatedid'] = is_array($relatedid) ? $relatedid[$k] : $relatedid;
$insertid = C::t('common_credit_log')->insert($log, true);
C::t('common_credit_log_field')->insert(array('logid' => $insertid, 'title' => $customtitle, 'text' => $custommemo));
}
} else {
$insertid = C::t('common_credit_log')->insert($log, true);
C::t('common_credit_log_field')->insert(array('logid' => $insertid, 'title' => $customtitle, 'text' => $custommemo));
}
}
function makecreditlog($log, $otherinfo=array()) {
global $_G;
$log['dateline'] = dgmdate($log['dateline'], 'Y-m-d H:i');
$log['optype'] = lang('spacecp', 'logs_credit_update_'.$log['operation']);
$log['opinfo'] = '';
$info = $url = '';
switch($log['operation']) {
case 'TRC':
$log['opinfo'] = '<a href="home.php?mod=task&do=view&id='.$log['relatedid'].'" target="_blank">'.lang('home/template', 'done').(!empty($otherinfo['tasks'][$log['relatedid']]) ? ' <strong>'.$otherinfo['tasks'][$log['relatedid']].'</strong> '.lang('home/template', 'eccredit_s') : '').lang('spacecp', 'task_credit').'</a>';
break;
case 'RTC':
$log['opinfo'] = '<a href="forum.php?mod=viewthread&tid='.$log['relatedid'].'" target="_blank">'.lang('forum/template', 'published').(!empty($otherinfo['threads'][$log['relatedid']]['subject']) ? ' <strong>'.$otherinfo['threads'][$log['relatedid']]['subject'].'</strong> '.lang('home/template', 'eccredit_s') : '').lang('spacecp', 'special_3_credit').'</a>';
break;
case 'RAC':
$log['opinfo'] = '<a href="forum.php?mod=viewthread&tid='.$log['relatedid'].'" target="_blank">'.lang('home/template', 'security_answer').(!empty($otherinfo['threads'][$log['relatedid']]['subject']) ? ' <strong>'.$otherinfo['threads'][$log['relatedid']]['subject'].'</strong> '.lang('home/template', 'eccredit_s') : '').lang('spacecp', 'special_3_best_answer').'</a>';
break;
case 'MRC':
$log['opinfo'] = lang('spacecp', 'magic_credit');
break;
case 'BMC':
$log['opinfo'] = '<a href="home.php?mod=magic&action=log&operation=buylog" target="_blank">'.lang('home/template', 'magics_operation_buy').' <strong>'.(!empty($_G['cache']['magics'][$log['relatedid']]['name']) ? $_G['cache']['magics'][$log['relatedid']]['name'] : '').'</strong> '.lang('home/template', 'magic').'</a>';
break;
case 'BME':
$log['opinfo'] = '<a href="home.php?mod=medal" target="_blank">'.lang('spacecp', 'buy_medal').'</a>';
break;
case 'BGC':
$log['opinfo'] = lang('spacecp','magic_space_gift');
break;
case 'RGC':
$log['opinfo'] = lang('spacecp','magic_space_re_gift');
break;
case 'AGC':
$log['opinfo'] = lang('spacecp', 'magic_space_get_gift');
break;
case 'TFR':
$log['opinfo'] = '<a href="home.php?mod=space&uid='.$log['relatedid'].'" target="_blank">'.lang('home/template', 'to').'<strong> '.$otherinfo['users'][$log['relatedid']].' </strong>'.lang('spacecp', 'credit_transfer').'</a>';
break;
case 'RCV':
$log['opinfo'] = '<a href="home.php?mod=space&uid='.$log['relatedid'].'" target="_blank">'.lang('home/template', 'comefrom').'<strong> '.$otherinfo['users'][$log['relatedid']].' </strong>'.lang('spacecp', 'credit_transfer_tips').'</a>';
break;
case 'CEC':
$log['opinfo'] = lang('spacecp', 'credit_exchange_tips_1').'<strong>'.$_G['setting']['extcredits'][$log['minid']]['title'].'</strong> '.lang('spacecp', 'credit_exchange_to').' <strong>'.$_G['setting']['extcredits'][$log['maxid']]['title'].'</strong>';
break;
case 'ECU':
$log['opinfo'] = lang('spacecp', 'credit_exchange_center');
break;
case 'SAC':
$log['opinfo'] = '<a href="forum.php?mod=redirect&goto=findpost&ptid='.$otherinfo['attachs'][$log['relatedid']]['tid'].'&pid='.$otherinfo['attachs'][$log['relatedid']]['pid'].'" target="_blank">'.lang('spacecp', 'attach_sell').' <strong>'.$otherinfo['attachs'][$log['relatedid']]['filename'].'</strong> '.lang('spacecp', 'attach_sell_tips').'</a>';
break;
case 'BAC':
$log['opinfo'] = '<a href="forum.php?mod=redirect&goto=findpost&ptid='.$otherinfo['attachs'][$log['relatedid']]['tid'].'&pid='.$otherinfo['attachs'][$log['relatedid']]['pid'].'" target="_blank">'.lang('spacecp', 'attach_buy').' <strong>'.$otherinfo['attachs'][$log['relatedid']]['filename'].'</strong> '.lang('spacecp', 'attach_buy_tips').'</a>';
break;
case 'PRC':
$tid = $otherinfo['post'][$log['relatedid']];
$log['opinfo'] = '<a href="forum.php?mod=redirect&goto=findpost&pid='.$log['relatedid'].'" target="_blank">'.(!empty($otherinfo['threads'][$tid]['subject']) ? ' <strong>'.$otherinfo['threads'][$tid]['subject'].'</strong> ' : lang('home/template', 'post')).lang('spacecp', 'grade_credit').'</a>';
break;
case 'RSC':
$tid = $otherinfo['post'][$log['relatedid']];
$log['opinfo'] = '<a href="forum.php?mod=redirect&goto=findpost&pid='.$log['relatedid'].'" target="_blank">'.lang('home/template', 'credits_give').(!empty($otherinfo['threads'][$tid]['subject']) ? ' <strong>'.$otherinfo['threads'][$tid]['subject'].'</strong> '.lang('home/template', 'eccredit_s') : '').lang('spacecp', 'grade_credit2').'</a>';
break;
case 'STC':
$log['opinfo'] = '<a href="forum.php?mod=viewthread&tid='.$log['relatedid'].'" target="_blank">'.lang('spacecp', 'attach_sell').(!empty($otherinfo['threads'][$log['relatedid']]['subject']) ? ' <strong>'.$otherinfo['threads'][$log['relatedid']]['subject'].'</strong> '.lang('home/template', 'eccredit_s') : '').lang('spacecp', 'thread_credit').'</a>';
break;
case 'BTC':
$log['opinfo'] = '<a href="forum.php?mod=viewthread&tid='.$log['relatedid'].'" target="_blank">'.lang('spacecp', 'attach_buy').(!empty($otherinfo['threads'][$log['relatedid']]['subject']) ? ' <strong>'.$otherinfo['threads'][$log['relatedid']]['subject'].'</strong> '.lang('home/template', 'eccredit_s') : '').lang('spacecp', 'thread_credit2').'</a>';
break;
case 'AFD':
$log['opinfo'] = lang('spacecp', 'buy_credit');
break;
case 'UGP':
$log['opinfo'] = lang('spacecp', 'buy_usergroup');
break;
case 'RPC':
$log['opinfo'] = lang('spacecp', 'report_credit');
break;
case 'ACC':
$log['opinfo'] = '<a href="forum.php?mod=viewthread&tid='.$log['relatedid'].'" target="_blank">'.lang('spacecp', 'join').(!empty($otherinfo['threads'][$log['relatedid']]['subject']) ? ' <strong>'.$otherinfo['threads'][$log['relatedid']]['subject'].'</strong> '.lang('home/template', 'eccredit_s') : '').lang('spacecp', 'activity_credit').'</a>';
break;
case 'RCT':
$log['opinfo'] = '<a href="forum.php?mod=viewthread&tid='.$log['relatedid'].'" target="_blank">'.lang('spacecp', 'thread_send').(!empty($otherinfo['threads'][$log['relatedid']]['subject']) ? ' <strong>'.$otherinfo['threads'][$log['relatedid']]['subject'].'</strong> ' : '').lang('spacecp', 'replycredit').'</a>';
break;
case 'RCA':
$log['opinfo'] = '<a href="forum.php?mod=viewthread&tid='.$log['relatedid'].'" target="_blank">'.lang('home/template', 'reply').(!empty($otherinfo['threads'][$log['relatedid']]['subject']) ? ' <strong>'.$otherinfo['threads'][$log['relatedid']]['subject'].'</strong> '.lang('home/template', 'eccredit_s') : '').lang('spacecp', 'add_credit').'</a>';
break;
case 'RCB':
$log['opinfo'] = '<a href="forum.php?mod=viewthread&tid='.$log['relatedid'].'" target="_blank">'.lang('spacecp', 'recovery').(!empty($otherinfo['threads'][$log['relatedid']]['subject']) ? ' <strong>'.$otherinfo['threads'][$log['relatedid']]['subject'].'</strong> ' : lang('spacecp', 'replycredit_post')).lang('spacecp', 'replycredit_thread').'</a>';
break;
case 'CDC':
$log['opinfo'] = lang('spacecp', 'card_credit');
break;
case 'RKC':
$log['opinfo'] = lang('spacecp', 'ranklist_top');
break;
case 'RPR':
$log['opinfo'] = lang('spacecp', 'admincp_op_credit');
break;
case 'RPZ':
$log['opinfo'] = lang('spacecp', 'admincp_op_credit');
break;
case 'FCP':
$log['opinfo'] = '<a href="forum.php?mod=forumdisplay&fid='.$log['relatedid'].'" target="_blank">'.lang('spacecp', 'buy_forum').'</a>';
break;
case 'BGR':
$log['opinfo'] = '<a href="forum.php?mod=forumdisplay&fid='.$log['relatedid'].'" target="_blank">'.lang('spacecp', 'buildgroup').'</a>';
break;
default:
$log['opinfo'] = !empty($log['title']) ? $log['title'] : '';
}
return $log;
}
function getotherinfo($aids, $pids, $tids, $taskids, $uids) {
global $_G;
$otherinfo = array('attachs' => array(), 'threads' => array(), 'tasks' => array(), 'users' => array());
if(!empty($aids)) {
$attachs = C::t('forum_attachment')->fetch_all($aids);
foreach($attachs as $value) {
$value['tableid'] = intval($value['tableid']);
$attachtable[$value['tableid']][] = $value['aid'];
$tids[$value['tid']] = $value['tid'];
}
foreach($attachtable as $id => $value) {
$attachs = C::t('forum_attachment_n')->fetch_all($id, $value);
foreach($attachs as $value) {
$otherinfo['attachs'][$value['aid']] = $value;
}
}
}
if(!empty($pids)) {
foreach(C::t('forum_post')->fetch_all(0, $pids) as $value) {
$tids[$value['tid']] = $value['tid'];
$otherinfo['post'][$value['pid']] = $value['tid'];
}
}
if(!empty($tids)) {
foreach(C::t('forum_thread')->fetch_all_by_tid($tids) as $value) {
$otherinfo['threads'][$value['tid']] = $value;
}
}
if(!empty($taskids)) {
foreach(C::t('common_task')->fetch_all($taskids) as $value) {
$otherinfo['tasks'][$value['taskid']] = $value['name'];
}
}
if(!empty($uids)) {
foreach(C::t('common_member')->fetch_all($uids) as $uid => $value) {
$otherinfo['users'][$uid] = $value['username'];
}
}
return $otherinfo;
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,724 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_discuzcode.php 36331 2016-12-28 01:08:45Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
include template('forum/discuzcode');
$_G['forum_discuzcode'] = array(
'pcodecount' => -1,
'codecount' => 0,
'codehtml' => array(),
'passwordlock' => array(),
'smiliesreplaced' => 0,
'seoarray' => array(
0 => '',
1 => $_SERVER['HTTP_HOST'],
2 => $_G['setting']['bbname'],
3 => str_replace('{bbname}', $_G['setting']['bbname'], $_G['setting']['seotitle']),
4 => $_G['setting']['seokeywords'],
5 => $_G['setting']['seodescription']
)
);
if(!isset($_G['cache']['bbcodes']) || !is_array($_G['cache']['bbcodes']) || !is_array($_G['cache']['smilies'])) {
loadcache(array('bbcodes', 'smilies', 'smileytypes'));
}
function creditshide($creditsrequire, $message, $pid, $authorid) {
global $_G;
if($_G['member']['credits'] >= $creditsrequire || $_G['forum']['ismoderator'] || $_G['uid'] && $authorid == $_G['uid']) {
return tpl_hide_credits($creditsrequire, str_replace('\\"', '"', $message));
} else {
return tpl_hide_credits_hidden($creditsrequire);
}
}
function expirehide($expiration, $creditsrequire, $message, $dateline) {
$expiration = $expiration ? substr($expiration, 1) : 0;
if($expiration && $dateline && (TIMESTAMP - $dateline) / 86400 > $expiration) {
return str_replace('\\"', '"', $message);
}
return '[hide'.($creditsrequire ? "=$creditsrequire" : '').']'.str_replace('\\"', '"', $message).'[/hide]';
}
function codedisp($code) {
global $_G;
$_G['forum_discuzcode']['pcodecount']++;
$code = dhtmlspecialchars(str_replace('\\"', '"', $code));
$code = str_replace("\n", "<li>", $code);
$_G['forum_discuzcode']['codehtml'][$_G['forum_discuzcode']['pcodecount']] = tpl_codedisp($code);
$_G['forum_discuzcode']['codecount']++;
return "[\tDISCUZ_CODE_".$_G['forum_discuzcode']['pcodecount']."\t]";
}
function karmaimg($rate, $ratetimes) {
$karmaimg = '';
if($rate && $ratetimes) {
$image = $rate > 0 ? 'agree.gif' : 'disagree.gif';
for($i = 0; $i < ceil(abs($rate) / $ratetimes); $i++) {
$karmaimg .= '<img src="'.$_G['style']['imgdir'].'/'.$image.'" border="0" alt="" />';
}
}
return $karmaimg;
}
function discuzcode($message, $smileyoff = false, $bbcodeoff = false, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = '0', $authorid = '0', $allowmediacode = '0', $pid = 0, $lazyload = 0, $pdateline = 0, $first = 0) {
global $_G;
static $authorreplyexist;
if($pid && strpos($message, '[/password]') !== FALSE) {
if($authorid != $_G['uid'] && !$_G['forum']['ismoderator']) {
$message = preg_replace_callback(
"/\s?\[password\](.+?)\[\/password\]\s?/i",
function ($matches) use ($pid) {
return parsepassword($matches[1], intval($pid));
},
$message
);
if($_G['forum_discuzcode']['passwordlock'][$pid]) {
return '';
}
} else {
$message = preg_replace("/\s?\[password\](.+?)\[\/password\]\s?/i", "", $message);
$_G['forum_discuzcode']['passwordauthor'][$pid] = 1;
}
}
$message = preg_replace('/\[\tDISCUZ_CODE_\d+\t\]/', '', $message);
if($parsetype != 1 && !$bbcodeoff && $allowbbcode && (strpos($message, '[/code]') || strpos($message, '[/CODE]')) !== FALSE) {
$message = preg_replace_callback("/\s?\[code\](.+?)\[\/code\]\s?/is", 'discuzcode_callback_codedisp_1', $message);
}
$msglower = strtolower($message);
$htmlon = $htmlon && $allowhtml ? 1 : 0;
if(!$htmlon) {
$message = dhtmlspecialchars($message);
} else {
$message = preg_replace("/<script[^\>]*?>(.*?)<\/script>/i", '', $message);
}
if($_G['setting']['plugins']['func'][HOOKTYPE]['discuzcode']) {
$_G['discuzcodemessage'] = & $message;
$param = func_get_args();
hookscript('discuzcode', 'global', 'funcs', array('param' => $param, 'caller' => 'discuzcode'), 'discuzcode');
}
if(!$smileyoff && $allowsmilies) {
$message = parsesmiles($message);
}
if($_G['setting']['allowattachurl'] && strpos($msglower, 'attach://') !== FALSE) {
$message = preg_replace_callback("/attach:\/\/(\d+)\.?(\w*)/i", 'discuzcode_callback_parseattachurl_12', $message);
}
if($allowbbcode) {
if(strpos($msglower, 'ed2k://') !== FALSE) {
$message = preg_replace_callback("/ed2k:\/\/([^\/\s'\"]+)\//", 'discuzcode_callback_parseed2k_1', $message);
}
}
if(!$bbcodeoff && $allowbbcode) {
if(strpos($msglower, '[/url]') !== FALSE) {
$message = preg_replace_callback("/\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.|mailto:|tel:|magnet:)?([^\r\n\[\"']+?))?\](.+?)\[\/url\]/is", 'discuzcode_callback_parseurl_152', $message);
}
if(strpos($msglower, '[/email]') !== FALSE) {
$message = preg_replace_callback("/\[email(=([A-Za-z0-9\-_.+]+)@([A-Za-z0-9\-_]+[.][A-Za-z0-9\-_.]+))?\](.+?)\[\/email\]/is", 'discuzcode_callback_parseemail_14', $message);
}
$nest = 0;
while(strpos($msglower, '[table') !== FALSE && strpos($msglower, '[/table]') !== FALSE){
$message = preg_replace_callback("/\[table(?:=(\d{1,4}%?)(?:,([\(\)%,#\w ]+))?)?\]\s*(.+?)\s*\[\/table\]/is", 'discuzcode_callback_parsetable_123', $message);
if(++$nest > 4) break;
}
$message = str_replace(array(
'[/color]', '[/backcolor]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[s]', '[/s]', '[hr]', '[/p]',
'[i=s]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]',
'[list=A]', "\r\n[*]", '[*]', '[/list]', '[indent]', '[/indent]', '[/float]'
), array(
'</font>', '</font>', '</font>', '</font>', '</div>', '<strong>', '</strong>', '<strike>', '</strike>', '<hr class="l" />', '</p>', '<i class="pstatus">', '<i>',
'</i>', '<u>', '</u>', '<ul>', '<ul type="1" class="litype_1">', '<ul type="a" class="litype_2">',
'<ul type="A" class="litype_3">', '<li>', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>'
), preg_replace(array(
"/\[color=([#\w]+?)\]/i",
"/\[color=((rgb|rgba)\([\d\s\.,]+?\))\]/i",
"/\[backcolor=([#\w]+?)\]/i",
"/\[backcolor=((rgb|rgba)\([\d\s\.,]+?\))\]/i",
"/\[size=(\d{1,2}?)\]/i",
"/\[size=(\d{1,2}(\.\d{1,5})?(px|pt)+?)\]/i",
"/\[size=(\d+(\.\d+)?(px|pt)+?)\]/i",
"/\[font=([^\[\<]+?)\]/i",
"/\[align=(left|center|right)\]/i",
"/\[p=(\d{1,2}|null), (\d{1,2}|null), (left|center|right)\]/i",
"/\[float=left\]/i",
"/\[float=right\]/i"
), array(
"<font color=\"\\1\">",
"<font style=\"color:\\1\">",
"<font style=\"background-color:\\1\">",
"<font style=\"background-color:\\1\">",
"<font size=\"\\1\">",
"<font style=\"font-size:\\1\">",
"<font>",
"<font face=\"\\1\">",
"<div align=\"\\1\">",
"<p style=\"line-height:\\1px;text-indent:\\2em;text-align:\\3\">",
"<span style=\"float:left;margin-right:5px\">",
"<span style=\"float:right;margin-left:5px\">"
), $message));
if($pid && !defined('IN_MOBILE')) {
$message = preg_replace_callback(
"/\s?\[postbg\]\s*([^\[\<\r\n;'\"\?\(\)]+?)\s*\[\/postbg\]\s?/is",
function ($matches) use ($pid) {
return parsepostbg($matches[1], intval($pid));
},
$message
);
} else {
$message = preg_replace("/\s?\[postbg\]\s*([^\[\<\r\n;'\"\?\(\)]+?)\s*\[\/postbg\]\s?/is", "", $message);
}
if($parsetype != 1) {
if(strpos($msglower, '[/quote]') !== FALSE) {
$message = preg_replace("/\s?\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s?/is", tpl_quote(), $message);
}
if(strpos($msglower, '[/free]') !== FALSE) {
$message = preg_replace("/\s*\[free\][\n\r]*(.+?)[\n\r]*\[\/free\]\s*/is", tpl_free(), $message);
}
}
if(!defined('IN_MOBILE') || !in_array(constant('IN_MOBILE'), array('1', '3', '4'))) {
if(strpos($msglower, '[/media]') !== FALSE) {
$message = preg_replace_callback("/\[media=([\w%,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", $allowmediacode ? 'discuzcode_callback_parsemedia_12' : 'discuzcode_callback_bbcodeurl_2', $message);
}
if(strpos($msglower, '[/audio]') !== FALSE) {
$message = preg_replace_callback("/\[audio(=1)*\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/is", $allowmediacode ? 'discuzcode_callback_parseaudio_2' : 'discuzcode_callback_bbcodeurl_2', $message);
}
if(strpos($msglower, '[/flash]') !== FALSE) {
$message = preg_replace_callback("/\[flash(=(\d+),(\d+))?\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is", $allowmediacode ? 'discuzcode_callback_parseflash_234' : 'discuzcode_callback_bbcodeurl_4', $message);
}
} else {
if(strpos($msglower, '[/media]') !== FALSE) {
$message = preg_replace("/\[media=([\w%,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", "[media]\\2[/media]", $message);
}
if(strpos($msglower, '[/audio]') !== FALSE) {
$message = preg_replace("/\[audio(=1)*\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/is", "[media]\\2[/media]", $message);
}
if(strpos($msglower, '[/flash]') !== FALSE) {
$message = preg_replace("/\[flash(=(\d+),(\d+))?\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is", "[media]\\4[/media]", $message);
}
}
if($parsetype != 1 && $allowbbcode < 0 && isset($_G['cache']['bbcodes'][-$allowbbcode])) {
$message = preg_replace($_G['cache']['bbcodes'][-$allowbbcode]['searcharray'], $_G['cache']['bbcodes'][-$allowbbcode]['replacearray'], $message);
}
if($parsetype != 1 && strpos($msglower, '[/hide]') !== FALSE && $pid) {
if($_G['setting']['hideexpiration'] && $pdateline && (TIMESTAMP - $pdateline) / 86400 > $_G['setting']['hideexpiration']) {
$message = preg_replace("/\[hide[=]?(d\d+)?[,]?(\d+)?\]\s*(.*?)\s*\[\/hide\]/is", "\\3", $message);
$msglower = strtolower($message);
}
if(strpos($msglower, '[hide=d') !== FALSE) {
$message = preg_replace_callback(
"/\[hide=(d\d+)?[,]?(\d+)?\]\s*(.*?)\s*\[\/hide\]/is",
function ($matches) use ($pdateline) {
return expirehide($matches[1], $matches[2], $matches[3], intval($pdateline));
},
$message
);
$msglower = strtolower($message);
}
if(strpos($msglower, '[hide]') !== FALSE) {
if($authorreplyexist === null) {
if(!$_G['forum']['ismoderator']) {
if($_G['uid']) {
$_post = C::t('forum_post')->fetch_post('tid:'.$_G['tid'], $pid);
$authorreplyexist = $_post['tid'] == $_G['tid'] ? C::t('forum_post')->fetch_pid_by_tid_authorid($_G['tid'], $_G['uid']) : FALSE;
}
} else {
$authorreplyexist = TRUE;
}
}
if($authorreplyexist) {
$message = preg_replace("/\[hide\]\s*(.*?)\s*\[\/hide\]/is", tpl_hide_reply(), $message);
} else {
$message = preg_replace("/\[hide\](.*?)\[\/hide\]/is", tpl_hide_reply_hidden(), $message);
$message = '<script type="text/javascript">replyreload += \',\' + '.$pid.';</script>'.$message;
}
}
if(strpos($msglower, '[hide=') !== FALSE) {
$message = preg_replace_callback(
"/\[hide=(\d+)\]\s*(.*?)\s*\[\/hide\]/is",
function ($matches) use ($pid, $authorid) {
return creditshide($matches[1], $matches[2], intval($pid), intval($authorid));
},
$message
);
}
}
}
if(!$bbcodeoff) {
if($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) {
$message = preg_replace_callback("/\[swf\]\s*([^\[\<\r\n]+?)\s*\[\/swf\]/is", 'discuzcode_callback_bbcodeurl_1', $message);
}
$attrsrc = !IS_ROBOT && $lazyload ? 'file' : 'src';
if(strpos($msglower, '[/img]') !== FALSE) {
$message = preg_replace_callback(
"/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is",
function ($matches) use ($allowimgcode, $lazyload, $pid, $allowbbcode) {
if (intval($allowimgcode)) {
return parseimg(0, 0, $matches[1], intval($lazyload), intval($pid), 'onmouseover="img_onmouseoverfunc(this)" '.(intval($lazyload) ? 'lazyloadthumb="1"' : 'onload="thumbImg(this)"'));
}
return (intval($allowbbcode) ? (!defined('IN_MOBILE') ? bbcodeurl($matches[1], '<a href="{url}" target="_blank">{url}</a>') : bbcodeurl($matches[1], '')) : bbcodeurl($matches[1], '{url}'));
},
$message
);
$message = preg_replace_callback(
"/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is",
function ($matches) use ($allowimgcode, $lazyload, $pid, $allowbbcode) {
if (intval($allowimgcode)) {
return parseimg($matches[1], $matches[2], $matches[3], intval($lazyload), intval($pid));
}
return (intval($allowbbcode) ? (!defined('IN_MOBILE') ? bbcodeurl($matches[3], '<a href="{url}" target="_blank">{url}</a>') : bbcodeurl($matches[3], '')) : bbcodeurl($matches[3], '{url}'));
},
$message
);
}
}
for($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) {
$message = str_replace("[\tDISCUZ_CODE_$i\t]", $_G['forum_discuzcode']['codehtml'][$i], $message);
}
unset($msglower);
if($jammer) {
$message = preg_replace_callback("/\r\n|\n|\r/", 'discuzcode_callback_jammer', $message);
}
if($first) {
if(helper_access::check_module('group')) {
$message = preg_replace("/\[groupid=(\d+)\](.*)\[\/groupid\]/i", lang('forum/template', 'fromgroup').': <a href="forum.php?mod=forumdisplay&fid=\\1" target="_blank">\\2</a>', $message);
} else {
$message = preg_replace("/(\[groupid=\d+\].*\[\/groupid\])/i", '', $message);
}
}
return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ' '), array('&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), $message));
}
function discuzcode_callback_codedisp_1($matches) {
return codedisp($matches[1]);
}
function discuzcode_callback_parseattachurl_12($matches) {
return parseattachurl($matches[1], $matches[2], 1);
}
function discuzcode_callback_parseed2k_1($matches) {
return parseed2k($matches[1]);
}
function discuzcode_callback_parseurl_152($matches) {
return parseurl($matches[1], $matches[5], $matches[2]);
}
function discuzcode_callback_parseemail_14($matches) {
return parseemail($matches[1], $matches[4]);
}
function discuzcode_callback_parsetable_123($matches) {
return parsetable($matches[1], $matches[2], $matches[3]);
}
function discuzcode_callback_parsemedia_12($matches) {
return parsemedia($matches[1], $matches[2]);
}
function discuzcode_callback_bbcodeurl_2($matches) {
return bbcodeurl($matches[2], '<a href="{url}" target="_blank">{url}</a>');
}
function discuzcode_callback_parseaudio_2($matches) {
return parseaudio($matches[2], 400);
}
function discuzcode_callback_parseflash_234($matches) {
return parseflash($matches[2], $matches[3], $matches[4]);
}
function discuzcode_callback_bbcodeurl_4($matches) {
return bbcodeurl($matches[4], '<a href="{url}" target="_blank">{url}</a>');
}
function discuzcode_callback_bbcodeurl_1($matches) {
return bbcodeurl($matches[1], ' <img src="'.STATICURL.'image/filetype/flash.gif" align="absmiddle" alt="" /> <a href="{url}" target="_blank">Flash: {url}</a> ');
}
function discuzcode_callback_jammer($matches) {
return jammer();
}
function parseurl($url, $text, $scheme) {
global $_G;
if(!$url && preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.)[^\[\"']+/i", trim($text), $matches)) {
$url = $matches[0];
$length = 65;
if(strlen($url) > $length) {
$text = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3));
}
return '<a href="'.(substr(strtolower($url), 0, 4) == 'www.' ? 'http://'.$url : $url).'" target="_blank">'.$text.'</a>';
} else {
$url = substr($url, 1);
if(substr(strtolower($url), 0, 4) == 'www.') {
$url = 'http://'.$url;
}
$url = !$scheme ? $_G['siteurl'].$url : $url;
return '<a href="'.$url.'" target="_blank">'.$text.'</a>';
}
}
function parseflash($w, $h, $url) {
$w = !$w ? 550 : $w;
$h = !$h ? 400 : $h;
$ext = fileext($url) == 'flv' ? 'flv' : 'swf';
$params = "$ext,$w,$h";
return parsemedia($params, $url);
}
function parseed2k($url) {
global $_G;
list(,$type, $name, $size,) = explode('|', $url);
$url = 'ed2k://'.$url.'/';
$name = addslashes($name);
if($type == 'file') {
$ed2kid = 'ed2k_'.random(3);
return '<a id="'.$ed2kid.'" href="'.$url.'" target="_blank">'.dhtmlspecialchars(urldecode($name)).' ('.sizecount($size).')</a><script language="javascript">$(\''.$ed2kid.'\').innerHTML=htmlspecialchars(unescape(decodeURIComponent(\''.$name.'\')))+\' ('.sizecount($size).')\';</script>';
} else {
return '<a href="'.$url.'" target="_blank">'.$url.'</a>';
}
}
function parseattachurl($aid, $ext, $ignoretid = 0) {
global $_G;
require_once libfile('function/attachment');
$_G['forum_skipaidlist'][] = $aid;
if(!empty($ext)) {
$attach = C::t('forum_attachment_n')->fetch('aid:'.$aid, $aid);
if(!in_array(attachtype(fileext($attach['filename'])."\t", 'id'), array(9, 10))) {
$ext = 0;
}
}
return $_G['siteurl'].'forum.php?mod=attachment&aid='.aidencode($aid, $ext, $ignoretid ? '' : $_G['tid']).($ext ? '&request=yes&_f=.'.$ext : '');
}
function parseemail($email, $text) {
$text = str_replace('\"', '"', $text);
if(!$email && preg_match("/\s*([A-Za-z0-9\-_.+]+)@([A-Za-z0-9\-_]+[.][A-Za-z0-9\-_.]+)\s*/i", $text, $matches)) {
$email = trim($matches[0]);
return '<a href="mailto:'.$email.'">'.$email.'</a>';
} else {
return '<a href="mailto:'.substr($email, 1).'">'.$text.'</a>';
}
}
function parsetable($width, $bgcolor, $message) {
if(strpos($message, '[/tr]') === FALSE && strpos($message, '[/td]') === FALSE) {
$rows = explode("\n", $message);
$s = !defined('IN_MOBILE') ? '<table cellspacing="0" class="t_table" '.
($width == '' ? NULL : 'style="width:'.$width.'"').
($bgcolor ? ' bgcolor="'.$bgcolor.'">' : '>') : '<table>';
foreach($rows as $row) {
$s .= '<tr><td>'.str_replace(array('\|', '|', '\n'), array('&#124;', '</td><td>', "\n"), $row).'</td></tr>';
}
$s .= '</table>';
return $s;
} else {
if(!preg_match("/^\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td([=\d,%]+)?\]/", $message) && !preg_match("/^<tr[^>]*?>\s*<td[^>]*?>/", $message)) {
return str_replace('\\"', '"', preg_replace("/\[tr(?:=([\(\)\s%,#\w]+))?\]|\[td([=\d,%]+)?\]|\[\/td\]|\[\/tr\]/", '', $message));
}
if(substr($width, -1) == '%') {
$width = substr($width, 0, -1) <= 98 ? intval($width).'%' : '98%';
} else {
$width = intval($width);
$width = $width ? ($width <= 560 ? $width.'px' : '98%') : '';
}
$message = preg_replace_callback("/\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td(?:=(\d{1,4}%?))?\]/i", 'parsetable_callback_parsetrtd_12', $message);
$message = preg_replace_callback("/\[\/td\]\s*\[td(?:=(\d{1,4}%?))?\]/i", 'parsetable_callback_parsetrtd_1', $message);
$message = preg_replace_callback("/\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/i", 'parsetable_callback_parsetrtd_1234', $message);
$message = preg_replace_callback("/\[\/td\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/i", 'parsetable_callback_parsetrtd_123', $message);
$message = preg_replace("/\[\/td\]\s*\[\/tr\]\s*/i", '</td></tr>', $message);
return (!defined('IN_MOBILE') ? '<table cellspacing="0" class="t_table" '.
($width == '' ? NULL : 'style="width:'.$width.'"').
($bgcolor ? ' bgcolor="'.$bgcolor.'">' : '>') : '<table>').
str_replace('\\"', '"', $message).'</table>';
}
}
function parsetable_callback_parsetrtd_12($matches) {
return parsetrtd($matches[1], 0, 0, $matches[2]);
}
function parsetable_callback_parsetrtd_1($matches) {
return parsetrtd('td', 0, 0, $matches[1]);
}
function parsetable_callback_parsetrtd_1234($matches) {
return parsetrtd($matches[1], $matches[2], $matches[3], $matches[4]);
}
function parsetable_callback_parsetrtd_123($matches) {
return parsetrtd('td', $matches[1], $matches[2], $matches[3]);
}
function parsetrtd($bgcolor, $colspan, $rowspan, $width) {
return ($bgcolor == 'td' ? '</td>' : '<tr'.($bgcolor && !defined('IN_MOBILE') ? ' style="background-color:'.$bgcolor.'"' : '').'>').'<td'.($colspan > 1 ? ' colspan="'.$colspan.'"' : '').($rowspan > 1 ? ' rowspan="'.$rowspan.'"' : '').($width && !defined('IN_MOBILE') ? ' width="'.$width.'"' : '').'>';
}
function parseaudio($url, $width = 400) {
$url = addslashes($url);
if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://')) && !preg_match('/^static\//', $url) && !preg_match('/^data\//', $url)) {
return dhtmlspecialchars($url);
}
$type = fileext($url);
$randomid = random(3);
return '<ignore_js_op><div id="'.$type.'_'.$randomid.'" class="media"><div id="'.$type.'_'.$randomid.'_container" class="media_container"></div><div id="'.$type.'_'.$randomid.'_tips" class="media_tips"><a href="'.$url.'" target="_blank">'.lang('template', 'parse_av_tips').'</a></div></div><script type="text/javascript">detectPlayer("'.$type.'_'.$randomid.'", "'.$type.'", "'.$url.'", "'.$width.'", "66");</script></ignore_js_op>';
}
function parsemedia($params, $url) {
$params = explode(',', $params);
if(preg_match('/^(auto|100%|[0-9]{1,2}%)$/', $params[1], $matches)) {
$width = $matches[1];
} else {
$width = ($params[1] > 0 && $params[1] < 8192) ? intval($params[1]) : 800;
}
if(preg_match('/^(auto|100%|[0-9]{1,2}%)$/', $params[2], $matches)) {
$height = $matches[1];
} else {
$height = ($params[2] > 0 && $params[2] < 4096) ? intval($params[2]) : 600;
}
$width = defined('IN_MOBILE') ? '100%' : $width;
$height = defined('IN_MOBILE') ? 'auto' : $height;
$url = addslashes($url);
if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://')) && !preg_match('/^static\//', $url) && !preg_match('/^data\//', $url)) {
return dhtmlspecialchars($url);
}
if($flv = parseflv($url, $width, $height)) {
return $flv;
}
if(in_array(count($params), array(3, 4))) {
$type = fileext($url);
$url = str_replace(array('<', '>'), '', str_replace('\\"', '\"', $url));
if(in_array($params[0], array('rtsp', 'mms'))) {
$mediaid = 'media_'.random(3);
return $params[0] == 'rtsp' ? '<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="'.$width.'" height="'.$height.'"><param name="autostart" value="0" /><param name="src" value="'.$url.'" /><param name="controls" value="imagewindow" /><param name="console" value="'.$mediaid.'_" /><embed src="'.$url.'" autostart="0" type="audio/x-pn-realaudio-plugin" controls="imagewindow" console="'.$mediaid.'_" width="'.$width.'" height="'.$height.'"></embed></object><br /><object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="'.$width.'" height="32"><param name="src" value="'.$url.'" /><param name="controls" value="controlpanel" /><param name="console" value="'.$mediaid.'_" /><embed src="'.$url.'" autostart="0" type="audio/x-pn-realaudio-plugin" controls="controlpanel" console="'.$mediaid.'_" width="'.$width.'" height="32"></embed></object>' : '<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'.$width.'" height="'.$height.'"><param name="invokeURLs" value="0"><param name="autostart" value="0" /><param name="url" value="'.$url.'" /><embed src="'.$url.'" autostart="0" type="application/x-mplayer2" width="'.$width.'" height="'.$height.'"></embed></object>';
}
$audio = array('aac', 'flac', 'ogg', 'mp3', 'm4a', 'weba', 'wma', 'mid', 'wav', 'ra', 'ram');
$video = array('rm', 'rmvb', 'flv', 'swf', 'asf', 'asx', 'wmv', 'avi', 'mpg', 'mpeg', 'mp4', 'm4v', '3gp', 'ogv', 'webm', 'mov');
if (in_array($type, $audio)) {
return parseaudio($url, $width);
} else if (in_array($type, $video)) {
$randomid = random(3);
return '<ignore_js_op><div id="'.$type.'_'.$randomid.'" class="media"><div id="'.$type.'_'.$randomid.'_container" class="media_container"></div><div id="'.$type.'_'.$randomid.'_tips" class="media_tips"><a href="'.$url.'" target="_blank">'.lang('template', 'parse_av_tips').'</a></div></div><script type="text/javascript">detectPlayer("'.$type.'_'.$randomid.'", "'.$type.'", "'.$url.'", "'.$width.'", "'.$height.'");</script></ignore_js_op>';
} else {
return '<a href="'.$url.'" target="_blank">'.$url.'</a>';
}
}
return;
}
function bbcodeurl($url, $tags) {
if(!preg_match("/<.+?>/s", $url)) {
if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://')) && !preg_match('/^static\//', $url) && !preg_match('/^data\//', $url)) {
$url = 'http://'.$url;
}
return str_replace(array('submit', 'member.php?mod=logging'), array('', ''), str_replace('{url}', addslashes($url), $tags));
} else {
return '&nbsp;'.$url;
}
}
function jammer() {
$randomstr = '';
for($i = 0; $i < mt_rand(5, 15); $i++) {
$randomstr .= chr(mt_rand(32, 59)).' '.chr(mt_rand(63, 126));
}
return mt_rand(0, 1) ? '<font class="jammer">'.$randomstr.'</font>'."\r\n" :
"\r\n".'<span style="display:none">'.$randomstr.'</span>';
}
function highlightword($text, $words, $prepend) {
$text = str_replace('\"', '"', $text);
foreach($words AS $key => $replaceword) {
$text = str_replace($replaceword, '<highlight>'.$replaceword.'</highlight>', $text);
}
return "$prepend$text";
}
function parseflv($url, $width = 0, $height = 0) {
global $_G;
$lowerurl = strtolower($url);
$flv = $iframe = $imgurl = '';
if(empty($_G['setting']['parseflv']) || !is_array($_G['setting']['parseflv'])) {
return FALSE;
}
foreach($_G['setting']['parseflv'] as $script => $checkurl) {
$check = FALSE;
foreach($checkurl as $row) {
if(strpos($lowerurl, $row) !== FALSE) {
$check = TRUE;
break;
}
}
if($check) {
@include_once libfile('media/'.$script, 'function');
if(function_exists('media_'.$script)) {
list($flv, $iframe, $url, $imgurl) = call_user_func('media_'.$script, $url, $width, $height);
}
break;
}
}
if($flv || $iframe) {
if(!$width && !$height) {
return array('flv' => $flv, 'iframe' => $iframe, 'imgurl' => $imgurl);
} else {
$width = addslashes($width);
$height = addslashes($height);
$flv = addslashes($flv);
$iframe = addslashes($iframe);
$randomid = 'flv_'.random(3);
$player_iframe = $iframe ? "\"<iframe src='$iframe' border='0' scrolling='no' framespacing='0' allowfullscreen='true' style='max-width: 100%' width='$width' height='$height' frameborder='no'></iframe>\"" : '';
$player_flv = $flv ? "AC_FL_RunContent('width', '$width', 'height', '$height', 'allowNetworking', 'internal', 'allowScriptAccess', 'never', 'src', '$flv', 'quality', 'high', 'bgcolor', '#ffffff', 'wmode', 'transparent', 'allowfullscreen', 'true')" : '';
$player = (!empty($player_iframe) && !empty($player_flv)) ? "detectHtml5Support() ? $player_iframe : $player_flv" : (empty($player_iframe) ? $player_flv : $player_iframe);
return '<ignore_js_op><span id="'.$randomid.'"></span><script type="text/javascript" reload="1">document.getElementById(\''.$randomid.'\').innerHTML=('.$player.');</script></ignore_js_op>';
}
} else {
return FALSE;
}
}
function parseimg($width, $height, $src, $lazyload, $pid, $extra = '') {
global $_G, $aimgs;
static $styleoutput = null;
if($_G['setting']['domainwhitelist_affectimg']) {
$tmp = parse_url($src);
if(!empty($tmp['host']) && !iswhitelist($tmp['host'])) {
return $src;
}
}
if(strstr($src, 'file:') || substr($src, 1, 1) == ':') {
return $src;
}
if($width > $_G['setting']['imagemaxwidth']) {
$height = intval($_G['setting']['imagemaxwidth'] * $height / $width);
$width = $_G['setting']['imagemaxwidth'];
if(defined('IN_MOBILE')) {
$extra = '';
} else {
$extra = 'onmouseover="img_onmouseoverfunc(this)" onclick="zoom(this)" style="cursor:pointer"';
}
}
$attrsrc = !IS_ROBOT && $lazyload ? 'file' : 'src';
$rimg_id = random(5);
$aimgs[$pid][] = $rimg_id;
$guestviewthumb = !empty($_G['setting']['guestviewthumb']['flag']) && empty($_G['uid']);
$img = '';
if($guestviewthumb) {
if(!isset($styleoutput)) {
$img .= guestviewthumbstyle();
$styleoutput = true;
}
$img .= '<div class="guestviewthumb"><img id="aimg_'.$rimg_id.'" class="guestviewthumb_cur" onclick="showWindow(\'login\', \'{loginurl}\'+\'&referer=\'+encodeURIComponent(location))" '.$attrsrc.'="{url}" border="0" alt="" />
<br><a href="{loginurl}" onclick="showWindow(\'login\', this.href+\'&referer=\'+encodeURIComponent(location));">'.lang('forum/template', 'guestviewthumb').'</a></div>';
} else {
if(defined('IN_MOBILE')) {
$img = '<img'.($width > 0 ? ' width="'.$width.'"' : '').($height > 0 ? ' height="'.$height.'"' : '').' src="{url}" border="0" alt="" />';
} else {
$img = '<img id="aimg_'.$rimg_id.'" onclick="zoom(this, this.src, 0, 0, '.($_G['setting']['showexif'] ? 1 : 0).')" class="zoom"'.($width > 0 ? ' width="'.$width.'"' : '').($height > 0 ? ' height="'.$height.'"' : '').' '.$attrsrc.'="{url}" '.($extra ? $extra.' ' : '').'border="0" alt="" />';
}
}
$code = bbcodeurl($src, $img);
if($guestviewthumb) {
$code = str_replace('{loginurl}', 'member.php?mod=logging&action=login', $code);
}
return $code;
}
function parsesmiles(&$message) {
global $_G;
static $enablesmiles;
if($enablesmiles === null) {
$enablesmiles = false;
if(!empty($_G['cache']['smilies']) && is_array($_G['cache']['smilies'])) {
foreach($_G['cache']['smilies']['replacearray'] AS $key => $smiley) {
$_G['cache']['smilies']['replacearray'][$key] = '<img src="'.STATICURL.'image/smiley/'.$_G['cache']['smileytypes'][$_G['cache']['smilies']['typearray'][$key]]['directory'].'/'.$smiley.'" smilieid="'.$key.'" border="0" alt="" />';
}
$enablesmiles = true;
}
}
$enablesmiles && $message = preg_replace($_G['cache']['smilies']['searcharray'], $_G['cache']['smilies']['replacearray'], $message, $_G['setting']['maxsmilies']);
return $message;
}
function parsepostbg($bgimg, $pid) {
global $_G;
static $postbg;
if($postbg[$pid]) {
return '';
}
loadcache('postimg');
foreach($_G['cache']['postimg']['postbg'] as $postbg) {
if($postbg['url'] != $bgimg) {
continue;
}
$bgimg = dhtmlspecialchars(basename($bgimg), ENT_QUOTES);
$postbg[$pid] = true;
$_G['forum_posthtml']['header'][$pid] .= '<style type="text/css">#pid'.$pid.'{background-image:url("'.STATICURL.'image/postbg/'.$bgimg.'");}</style>';
break;
}
return '';
}
function parsepassword($password, $pid) {
global $_G;
static $postpw = array();
if($postpw[$pid]) {
return '';
}
$postpw[$pid] = true;
if(empty($_G['cookie']['postpw_'.$pid]) || $_G['cookie']['postpw_'.$pid] != md5($password)) {
$_G['forum_discuzcode']['passwordlock'][$pid] = 1;
}
return '';
}
function guestviewthumbstyle() {
static $styleoutput = null;
$return = '';
if ($styleoutput === null) {
global $_G;
$return = '<style>.guestviewthumb {margin:10px auto; text-align:center;}.guestviewthumb a {font-size:12px;}.guestviewthumb_cur {cursor:url("'.IMGDIR.'/scf.gif"), default; max-width:'.$_G['setting']['guestviewthumb']['width'].'px;}.ie6 .guestviewthumb_cur { width:'.$_G['setting']['guestviewthumb']['width'].'px !important;}</style>';
$styleoutput = true;
}
return $return;
}
?>

View File

@@ -0,0 +1,69 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_domain.php 24601 2011-09-27 12:26:41Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function domaincheck($domain, $domainroot, $domainlength, $msgtype = 1) {
if(strlen($domain) < $domainlength) {
showmessage('domain_length_error', '', array('length' => $domainlength), array('return' => true));
}
if(strlen($domain) > 30) {
$msgtype ? showmessage('two_domain_length_not_more_than_30_characters', '', array(), array('return' => true)) : cpmsg('two_domain_length_not_more_than_30_characters', '', 'error');
}
if(!preg_match("/^[a-z0-9]*$/", $domain)) {
$msgtype ? showmessage('only_two_names_from_english_composition_and_figures', '', array(), array('return' => true)) : cpmsg('only_two_names_from_english_composition_and_figures', '', 'error');
}
if($msgtype && isholddomain($domain)) {
showmessage('domain_be_retained', '', array(), array('return' => true));
}
if(existdomain($domain, $domainroot)) {
$msgtype ? showmessage('two_domain_have_been_occupied', '', array(), array('return' => true)) : cpmsg('two_domain_have_been_occupied', '', 'error');
}
return true;
}
function isholddomain($domain) {
global $_G;
$domain = strtolower($domain);
$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 existdomain($domain, $domainroot) {
global $_G;
$exist = false;
if(C::t('common_domain')->count_by_domain_domainroot($domain, $domainroot)) {
$exist = true;
}
return $exist;
}
?>

View File

@@ -0,0 +1,85 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_ec_credit.php 26205 2011-12-05 10:09:32Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function updatecreditcache($uid, $type, $return = 0) {
$all = countcredit($uid, $type);
$halfyear = countcredit($uid, $type, 180);
$thismonth = countcredit($uid, $type, 30);
$thisweek = countcredit($uid, $type, 7);
$before = array(
'good' => $all['good'] - $halfyear['good'],
'soso' => $all['soso'] - $halfyear['soso'],
'bad' => $all['bad'] - $halfyear['bad'],
'total' => $all['total'] - $halfyear['total']
);
$data = array('all' => $all, 'before' => $before, 'halfyear' => $halfyear, 'thismonth' => $thismonth, 'thisweek' => $thisweek);
C::t('forum_spacecache')->insert(array(
'uid' => $uid,
'variable' => $type,
'value' => serialize($data),
'expiration' => getexpiration(),
), false, true);
if($return) {
return $data;
}
}
function countcredit($uid, $type, $days = 0) {
$type = $type == 'sellercredit' ? 1 : 0;
$good = $soso = $bad = 0;
foreach(C::t('forum_tradecomment')->fetch_all_by_rateeid($uid, $type, $days ? TIMESTAMP - $days * 86400 : 0) as $credit) {
if($credit['score'] == 1) {
$good++;
} elseif($credit['score'] == 0) {
$soso++;
} else {
$bad++;
}
}
return array('good' => $good, 'soso' => $soso, 'bad' => $bad, 'total' => $good + $soso + $bad);
}
function updateusercredit($uid, $type, $level) {
$uid = intval($uid);
if(!$uid || !in_array($type, array('buyercredit', 'sellercredit')) || !in_array($level, array('good', 'soso', 'bad'))) {
return;
}
if($cache = C::t('forum_spacecache')->fetch_spacecache($uid, $type)) {
$expiration = $cache['expiration'];
$cache = dunserialize($cache['value']);
} else {
$init = array('good' => 0, 'soso' => 0, 'bad' => 0, 'total' => 0);
$cache = array('all' => $init, 'before' => $init, 'halfyear' => $init, 'thismonth' => $init, 'thisweek' => $init);
$expiration = getexpiration();
}
foreach(array('all', 'halfyear', 'thismonth', 'thisweek') as $key) {
$cache[$key][$level]++;
$cache[$key]['total']++;
}
C::t('forum_spacecache')->insert(array(
'uid' => $uid,
'variable' => $type,
'value' => serialize($cache),
'expiration' => $expiration,
), false, true);
$score = $level == 'good' ? 1 : ($level == 'soso' ? 0 : -1);
C::t('common_member_status')->increase($uid, array($type=>$score));
}
?>

View File

@@ -0,0 +1,430 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_editor.php 36278 2016-12-09 07:52:35Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function absoluteurl($url) {
global $_G;
if($url[0] == '/') {
return 'http://'.$_SERVER['HTTP_HOST'].$url;
} else {
return $_G['siteurl'].$url;
}
}
function atag($aoptions, $text) {
$href = getoptionvalue('href', $aoptions);
if(substr($href, 0, 7) == 'mailto:') {
$tag = 'email';
$href = substr($href, 7);
} else {
$tag = 'url';
if(!preg_match("/^[a-z0-9]+:/i", $href)) {
$href = absoluteurl($href);
}
}
return "[$tag=$href]".trim(recursion('a', $text, 'atag'))."[/$tag]";
}
function divtag($divoptions, $text) {
$prepend = $append = '';
parsestyle($divoptions, $prepend, $append);
$align = getoptionvalue('align', $divoptions);
switch($align) {
case 'left':
case 'center':
case 'right':
break;
default:
$align = '';
}
if($align) {
$prepend .= "[align=$align]";
$append .= "[/align]";
}
$append .= "\n";
return $prepend.recursion('div', $text, 'divtag').$append;
}
function fetchoptionvalue($option, $text) {
if(($position = strpos($text, $option)) !== false) {
$delimiter = $position + strlen($option);
if($text[$delimiter] == '"') {
$delimchar = '"';
} elseif($text[$delimiter] == '\'') {
$delimchar = '\'';
} else {
$delimchar = ' ';
}
$delimloc = strpos($text, $delimchar, $delimiter + 1);
if($delimloc === false) {
$delimloc = strlen($text);
} elseif($delimchar == '"' OR $delimchar == '\'') {
$delimiter++;
}
return trim(substr($text, $delimiter, $delimloc - $delimiter));
} else {
return '';
}
}
function fonttag($fontoptions, $text) {
$tags = array('font' => 'face=', 'size' => 'size=', 'color' => 'color=');
$prependtags = $appendtags = '';
foreach($tags as $bbcode => $locate) {
$optionvalue = fetchoptionvalue($locate, $fontoptions);
if($optionvalue) {
$prependtags .= "[$bbcode=$optionvalue]";
$appendtags = "[/$bbcode]$appendtags";
}
}
parsestyle($fontoptions, $prependtags, $appendtags);
return $prependtags.recursion('font', $text, 'fonttag').$appendtags;
}
function getoptionvalue($option, $text) {
preg_match("/$option(\s+?)?\=(\s+?)?[\"']?(.+?)([\"']|$|>)/is", $text, $matches);
return isset($matches[3]) ? trim($matches[3]) : '';
}
function html2bbcode($text) {
$text = strip_tags($text, '<table><tr><td><b><strong><i><em><u><a><div><span><p><strike><blockquote><ol><ul><li><font><img><br><br/><h1><h2><h3><h4><h5><h6><script><hr>');
if(ismozilla()) {
$text = preg_replace("/(?<!<br>|<br \/>|\r)(\r\n|\n|\r)/", ' ', $text);
}
$pregfind = array(
"/<script.*>.*<\/script>/siU",
'/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i',
"/(\r\n|\n|\r)/",
"/<table.*>/siU",
"/<tr.*>/siU",
"/<td>/i",
"/<\/td>/i",
"/<\/tr>/i",
"/<\/table>/i",
'/<\/h([0-9]+)>/siU',
"/<a\s+?name=.+?\".\">(.+?)<\/a>/is",
"/<br.*>/siU",
"/<span\s+?style=\"float:\s+(left|right);\">(.+?)<\/span>/is",
"/<font\s+?style=\"background-color:\s*([#\w]+?);?\">(.+?)<\/font>/is",
"/<font\s+?style=\"background-color:\s*((rgb|rgba)\([\d\s\.,]+?\));?\">(.+?)<\/font>/is",
"/<hr\s+.*>/siU",
);
$pregreplace = array(
'',
'',
'',
'[table]',
'[tr]',
'[td]',
'[/td]',
'[/tr]',
'[/table]',
"[/size]\n\n",
'\1',
"\n",
"[float=\\1]\\2[/float]",
"[backcolor=\\1]\\2[/backcolor]",
"[backcolor=\\1]\\2[/backcolor]",
"[hr]",
);
$text = preg_replace($pregfind, $pregreplace, $text);
$text = preg_replace_callback("/<table([^>]*(width|background|background-color|bgcolor)[^>]*)>/siU", 'html2bbcode_callback_tabletag_1', $text);
$text = preg_replace_callback("/<td(.+)>/siU", 'html2bbcode_callback_tdtag_1', $text);
$text = preg_replace_callback('/<h([0-9]+)[^>]*>/siU', 'html2bbcode_callback_1', $text);
$text = preg_replace_callback("/<img[^>]+smilieid=\"(\d+)\".*>/siU", 'html2bbcode_callback_smileycode_1', $text);
$text = preg_replace_callback("/<img([^>]*src[^>]*)>/iU", 'html2bbcode_callback_imgtag_1', $text);
$text = recursion('b', $text, 'simpletag', 'b');
$text = recursion('strong', $text, 'simpletag', 'b');
$text = recursion('i', $text, 'simpletag', 'i');
$text = recursion('em', $text, 'simpletag', 'i');
$text = recursion('u', $text, 'simpletag', 'u');
$text = recursion('a', $text, 'atag');
$text = recursion('font', $text, 'fonttag');
$text = recursion('blockquote', $text, 'simpletag', 'indent');
$text = recursion('ol', $text, 'listtag');
$text = recursion('ul', $text, 'listtag');
$text = recursion('div', $text, 'divtag');
$text = recursion('span', $text, 'spantag');
$text = recursion('p', $text, 'ptag');
$pregfind = array("/(?<!\r|\n|^)\[(\/list|list|\*)\]/", "/<li>(.*)((?=<li>)|<\/li>)/iU", "/<p.*>/iU", "/<p><\/p>/i", "/(<a>|<\/a>|<\/li>)/is", "/<\/?(A|LI|FONT|DIV|SPAN)>/siU", "/\[url[^\]]*\]\[\/url\]/i", "/\[url=javascript:[^\]]*\](.+?)\[\/url\]/is");
$pregreplace = array("\n[\\1]", "\\1\n", "\n", '', '', '', '', "\\1");
$text = preg_replace($pregfind, $pregreplace, $text);
$strfind = array('&nbsp;', '&lt;', '&gt;', '&amp;');
$strreplace = array(' ', '<', '>', '&');
$text = str_replace($strfind, $strreplace, $text);
return dhtmlspecialchars(trim($text));
}
function html2bbcode_callback_tabletag_1($matches) {
return tabletag($matches[1]);
}
function html2bbcode_callback_tdtag_1($matches) {
return tdtag($matches[1]);
}
function html2bbcode_callback_1($matches) {
return '[size='.(7 - $matches[1]).']';
}
function html2bbcode_callback_smileycode_1($matches) {
return smileycode($matches[1]);
}
function html2bbcode_callback_imgtag_1($matches) {
return imgtag($matches[1]);
}
function imgtag($attributes) {
$value = array('src' => '', 'width' => '', 'height' => '');
preg_match_all("/(src|width|height)=([\"|\']?)([^\"']+)(\\2)/is", dstripslashes($attributes), $matches);
if(is_array($matches[1])) {
foreach($matches[1] as $key => $attribute) {
$value[strtolower($attribute)] = $matches[3][$key];
}
}
@extract($value);
if(!preg_match("/^https?:\/\//is", $src)) {
$src = absoluteurl($src);
}
return $src ? ($width && $height ? '[img='.$width.','.$height.']'.$src.'[/img]' : '[img]'.$src.'[/img]') : '';
}
function ismozilla() {
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if(strpos($useragent, 'gecko') !== FALSE) {
preg_match("/gecko\/(\d+)/", $useragent, $regs);
return isset($regs[1]) ? $regs[1] : FALSE;
}
return FALSE;
}
function litag($listoptions, $text) {
return '[*]'.rtrim($text);
}
function listtag($listoptions, $text, $tagname) {
require_once libfile('function/post');
$text = preg_replace('/<li>((.(?!<\/li))*)(?=<\/?ol|<\/?ul|<li|\[list|\[\/list)/siU', '<li>\\1</li>', $text).(isopera() ? '</li>' : NULL);
$text = recursion('li', $text, 'litag');
if($tagname == 'ol') {
$listtype = fetchoptionvalue('type=', $listoptions) ? fetchoptionvalue('type=', $listoptions) : 1;
if(in_array($listtype, array('1', 'a', 'A'))) {
$opentag = '[list='.$listtype.']';
}
} else {
$opentag = '[list]';
}
return $text ? $opentag.recursion($tagname, $text, 'listtag').'[/list]' : FALSE;
}
function parsestyle($tagoptions, &$prependtags, &$appendtags) {
$searchlist = array(
array('tag' => 'align', 'option' => TRUE, 'regex' => 'text-align:\s*(left);?', 'match' => 1),
array('tag' => 'align', 'option' => TRUE, 'regex' => 'text-align:\s*(center);?', 'match' => 1),
array('tag' => 'align', 'option' => TRUE, 'regex' => 'text-align:\s*(right);?', 'match' => 1),
array('tag' => 'color', 'option' => TRUE, 'regex' => '(?<![a-z0-9-])color:\s*([^;]+);?', 'match' => 1),
array('tag' => 'font', 'option' => TRUE, 'regex' => 'font-family:\s*([^;]+);?', 'match' => 1),
array('tag' => 'size', 'option' => TRUE, 'regex' => 'font-size:\s*(\d+(\.\d+)?(px|pt|in|cm|mm|pc|em|ex|%|));?', 'match' => 1),
array('tag' => 'b', 'option' => FALSE, 'regex' => 'font-weight:\s*(bold);?'),
array('tag' => 'i', 'option' => FALSE, 'regex' => 'font-style:\s*(italic);?'),
array('tag' => 'u', 'option' => FALSE, 'regex' => 'text-decoration:\s*(underline);?')
);
$style = getoptionvalue('style', $tagoptions);
$style = preg_replace_callback("/(?<![a-z0-9-])color:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)(;?)/i", 'parsestyle_callback_sprintf_4123', $style);
foreach($searchlist as $searchtag) {
if(preg_match('/'.$searchtag['regex'].'/i', $style, $match)) {
$opnvalue = $match["{$searchtag['match']}"];
$prependtags .= '['.$searchtag['tag'].($searchtag['option'] == TRUE ? '='.$opnvalue.']' : ']');
$appendtags = '[/'.$searchtag['tag']."]$appendtags";
}
}
}
function parsestyle_callback_sprintf_4123($matches) {
return sprintf("color: #%02X%02X%02X".$matches[4], $matches[1], $matches[2], $matches[3]);
}
function ptag($poptions, $text) {
$align = getoptionvalue('align', $poptions);
switch($align) {
case 'left':
case 'center':
case 'right':
break;
default:
$align = '';
}
$prepend = $append = '';
parsestyle($poptions, $prepend, $append);
if($align) {
$prepend .= "[align=$align]";
$append .= "[/align]";
}
$append .= "\n";
return $prepend.recursion('p', $text, 'ptag').$append;
}
function recursion($tagname, $text, $function, $extraargs = '') {
$tagname = strtolower($tagname);
$open_tag = "<$tagname";
$open_tag_len = strlen($open_tag);
$close_tag = "</$tagname>";
$close_tag_len = strlen($close_tag);
$beginsearchpos = 0;
do {
$textlower = strtolower($text);
$tagbegin = @strpos($textlower, $open_tag, $beginsearchpos);
if($tagbegin === FALSE) {
break;
}
$strlen = strlen($text);
$inquote = '';
$found = FALSE;
$tagnameend = FALSE;
for($optionend = $tagbegin; $optionend <= $strlen; $optionend++) {
$char = $text[$optionend];
if(($char == '"' || $char == "'") && $inquote == '') {
$inquote = $char;
} elseif(($char == '"' || $char == "'") && $inquote == $char) {
$inquote = '';
} elseif($char == '>' && !$inquote) {
$found = TRUE;
break;
} elseif(($char == '=' || $char == ' ') && !$tagnameend) {
$tagnameend = $optionend;
}
}
if(!$found) {
break;
}
if(!$tagnameend) {
$tagnameend = $optionend;
}
$offset = $optionend - ($tagbegin + $open_tag_len);
$tagoptions = substr($text, $tagbegin + $open_tag_len, $offset);
$acttagname = substr($textlower, $tagbegin + 1, $tagnameend - $tagbegin - 1);
if($acttagname != $tagname) {
$beginsearchpos = $optionend;
continue;
}
$tagend = strpos($textlower, $close_tag, $optionend);
if($tagend === FALSE) {
break;
}
$nestedopenpos = strpos($textlower, $open_tag, $optionend);
while($nestedopenpos !== FALSE && $tagend !== FALSE) {
if($nestedopenpos > $tagend) {
break;
}
$tagend = strpos($textlower, $close_tag, $tagend + $close_tag_len);
$nestedopenpos = strpos($textlower, $open_tag, $nestedopenpos + $open_tag_len);
}
if($tagend === FALSE) {
$beginsearchpos = $optionend;
continue;
}
$localbegin = $optionend + 1;
$localtext = $function($tagoptions, substr($text, $localbegin, $tagend - $localbegin), $tagname, $extraargs);
$text = substr_replace($text, $localtext, $tagbegin, $tagend + $close_tag_len - $tagbegin);
$beginsearchpos = $tagbegin + strlen($localtext);
} while($tagbegin !== FALSE);
return $text;
}
function simpletag($options, $text, $tagname, $parseto) {
if(trim($text) == '') {
return '';
}
$text = recursion($tagname, $text, 'simpletag', $parseto);
return "[$parseto]{$text}[/$parseto]";
}
function smileycode($smileyid) {
global $_G;
if(!is_array($_G['cache']['smileycodes'])) {
loadcache(array('bbcodes_display', 'bbcodes', 'smileycodes', 'smilies', 'smileytypes', 'domainwhitelist'));
}
foreach($_G['cache']['smileycodes'] as $id => $code) {
if($smileyid == $id) {
return $code;
}
}
}
function spantag($spanoptions, $text) {
$prependtags = $appendtags = '';
parsestyle($spanoptions, $prependtags, $appendtags);
return $prependtags.recursion('span', $text, 'spantag').$appendtags;
}
function tabletag($attributes) {
$attributes = dstripslashes($attributes);
$width = '';
if(preg_match("/width=([\"|\']?)(\d{1,4}%?)(\\1)/is", $attributes, $matches)) {
$width = substr($matches[2], -1) == '%' ? (substr($matches[2], 0, -1) <= 98 ? $matches[2] : '98%') : ($matches[2] <= 560 ? $matches[2] : '560');
} elseif(preg_match("/width\s?:\s?(\d{1,4})([px|%])/is", $attributes, $matches)) {
$width = $matches[2] == '%' ? ($matches[1] <= 98 ? $matches[1].'%' : '98%') : ($matches[1] <= 560 ? $matches[1] : '560');
}
if(preg_match("/(?:background|background-color|bgcolor)[:=]\s*([\"']?)((rgb\(\d{1,3}%?,\s*\d{1,3}%?,\s*\d{1,3}%?\))|(#[0-9a-fA-F]{3,6})|([a-zA-Z]{1,20}))(\\1)/i", $attributes, $matches)) {
$bgcolor = $matches[2];
$width = $width ? $width : '98%';
} else {
$bgcolor = '';
}
return $bgcolor ? "[table=$width,$bgcolor]" :($width ? "[table=$width]" : '[table]');
}
function tdtag($attributes) {
$value = array('colspan' => 1, 'rowspan' => 1, 'width' => '');
preg_match_all("/(colspan|rowspan|width)=([\"|\']?)(\d{1,4}%?)(\\2)/is", dstripslashes($attributes), $matches);
if(is_array($matches[1])) {
foreach($matches[1] as $key => $attribute) {
$value[strtolower($attribute)] = $matches[3][$key];
}
}
@extract($value);
return $width == '' ? ($colspan == 1 && $rowspan == 1 ? '[td]' : "[td=$colspan,$rowspan]") : "[td=$colspan,$rowspan,$width]";
}
?>

View File

@@ -0,0 +1,124 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_exif.php 30348 2012-05-24 03:27:54Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function getimageinfoval($ImageInfo,$val_arr) {
$InfoVal = exif_lang('unknown');
foreach($val_arr as $name=>$val) {
if ($name == $ImageInfo) {
$InfoVal = &$val;
break;
}
}
return $InfoVal;
}
function getexif($img) {
$imgtype = array("", "GIF", "JPG", "PNG", "SWF", "PSD", "BMP", "WEBP", "TIFF(intel byte order)", "TIFF(motorola byte order)", "JPC", "JP2", "JPX", "JB2", "SWC", "IFF", "WBMP", "XBM");
$Orientation = array("", "top left side", "top right side", "bottom right side", "bottom left side", "left side top", "right side top", "right side bottom", "left side bottom");
$ResolutionUnit = exif_lang('resolutionunit');
$YCbCrPositioning = array("", "the center of pixel array", "the datum point");
$ExposureProgram = exif_lang('exposureprogram');
$MeteringMode_arr = exif_lang('meteringmode');
$Lightsource_arr = exif_lang('lightsource');
$Flash_arr = array(
"0" => "flash did not fire",
"1" => "flash fired",
"5" => "flash fired but strobe return light not detected",
"7" => "flash fired and strobe return light detected",
);
if(!function_exists('exif_read_data')) {
return exif_lang('img_info');
}
$exif = @exif_read_data($img,"IFD0");
if ($exif === false) {
$new_img_info = exif_lang('img_info');
} else {
@$exif = exif_read_data($img, 0, true);
foreach($exif as $type => $typearr) {
foreach($typearr as $key => $kval) {
if(is_array($kval)) {
foreach($kval as $vkey => $value) {
$str = dhtmlspecialchars(preg_replace("/[^\[A-Za-z0-9_\.\/:\s-\]]/", '', trim($value)));
$exif[$type][$key][$vkey] = $str;
}
} elseif(!in_array($key, array('ComponentsConfiguration', 'FileSource', 'SceneType'))) {
$str = dhtmlspecialchars(preg_replace("/[^\[A-Za-z0-9_\.\/:\s-\]]/", '', trim($kval)));
$exif[$type][$key] = $str;
}
}
}
$new_img_info = array (
exif_lang('FileName') => $exif['FILE']['FileName'],
exif_lang('FileType') => $imgtype[$exif['FILE']['FileType']],
exif_lang('MimeType') => $exif['FILE']['MimeType'],
exif_lang('FileSize') => $exif['FILE']['FileSize'],
exif_lang('FileDateTime') => empty($exif['FILE']['FileDateTime'])?'':date("Y-m-d H:i:s",$exif['FILE']['FileDateTime']),
exif_lang('ImageDescription') => $exif['IFD0']['ImageDescription'],
exif_lang('Make') => $exif['IFD0']['Make'],
exif_lang('Model') => $exif['IFD0']['Model'],
exif_lang('Orientation') => $Orientation[$exif['IFD0']['Orientation']],
exif_lang('XResolution') => $exif['IFD0']['XResolution'].$ResolutionUnit[$exif['IFD0']['ResolutionUnit']],
exif_lang('YResolution') => $exif['IFD0']['YResolution'].$ResolutionUnit[$exif['IFD0']['ResolutionUnit']],
exif_lang('Software') => $exif['IFD0']['Software'],
exif_lang('DateTime') => $exif['IFD0']['DateTime'],
exif_lang('Artist') => $exif['IFD0']['Artist'],
exif_lang('YCbCrPositioning') => $YCbCrPositioning[$exif['IFD0']['YCbCrPositioning']],
exif_lang('Copyright') => $exif['IFD0']['Copyright'],
exif_lang('Photographer') => $exif['COMPUTED']['Copyright.Photographer'],
exif_lang('Editor') => $exif['COMPUTED']['Copyright.Editor'],
exif_lang('ExifVersion') => $exif['EXIF']['ExifVersion'],
exif_lang('FlashPixVersion') => "Ver. ".number_format($exif['EXIF']['FlashPixVersion']/100,2),
exif_lang('DateTimeOriginal') => $exif['EXIF']['DateTimeOriginal'],
exif_lang('DateTimeDigitized') => $exif['EXIF']['DateTimeDigitized'],
exif_lang('Height') => $exif['COMPUTED']['Height'],
exif_lang('Width') => $exif['COMPUTED']['Width'],
exif_lang('ApertureValue') => $exif['EXIF']['ApertureValue'],
exif_lang('ShutterSpeedValue') => $exif['EXIF']['ShutterSpeedValue'],
exif_lang('ApertureFNumber') => $exif['COMPUTED']['ApertureFNumber'],
exif_lang('MaxApertureValue') => "F".$exif['EXIF']['MaxApertureValue'],
exif_lang('ExposureTime') => $exif['EXIF']['ExposureTime'],
exif_lang('FNumber') => $exif['EXIF']['FNumber'],
exif_lang('MeteringMode') => getimageinfoval($exif['EXIF']['MeteringMode'],$MeteringMode_arr),
exif_lang('LightSource') => getimageinfoval($exif['EXIF']['LightSource'], $Lightsource_arr),
exif_lang('Flash') => getimageinfoval($exif['EXIF']['Flash'], $Flash_arr),
exif_lang('ExposureMode') => ($exif['EXIF']['ExposureMode']==1?exif_lang('manual'):exif_lang('auto')),
exif_lang('WhiteBalance') => ($exif['EXIF']['WhiteBalance']==1?exif_lang('manual'):exif_lang('auto')),
exif_lang('ExposureProgram') => $ExposureProgram[$exif['EXIF']['ExposureProgram']],
exif_lang('ExposureBiasValue') => $exif['EXIF']['ExposureBiasValue']."EV",
exif_lang('ISOSpeedRatings') => $exif['EXIF']['ISOSpeedRatings'],
exif_lang('ComponentsConfiguration') => (bin2hex($exif['EXIF']['ComponentsConfiguration'])=="01020300"?"YCbCr":"RGB"),//'0x04,0x05,0x06,0x00'="RGB" '0x01,0x02,0x03,0x00'="YCbCr"
exif_lang('CompressedBitsPerPixel') => $exif['EXIF']['CompressedBitsPerPixel']."Bits/Pixel",
exif_lang('FocusDistance') => $exif['COMPUTED']['FocusDistance']."m",
exif_lang('FocalLength') => $exif['EXIF']['FocalLength']."mm",
exif_lang('FocalLengthIn35mmFilm') => $exif['EXIF']['FocalLengthIn35mmFilm']."mm",
exif_lang('UserCommentEncoding') => $exif['COMPUTED']['UserCommentEncoding'],
exif_lang('UserComment') => $exif['COMPUTED']['UserComment'],
exif_lang('ColorSpace') => ($exif['EXIF']['ColorSpace']==1?"sRGB":"Uncalibrated"),
exif_lang('ExifImageLength') => $exif['EXIF']['ExifImageLength'],
exif_lang('ExifImageWidth') => $exif['EXIF']['ExifImageWidth'],
exif_lang('FileSource') => (bin2hex($exif['EXIF']['FileSource'])==0x03?"digital still camera":"unknown"),
exif_lang('SceneType') => (bin2hex($exif['EXIF']['SceneType'])==0x01?"A directly photographed image":"unknown"),
exif_lang('ThumbFileType') => $exif['COMPUTED']['Thumbnail.FileType'],
exif_lang('ThumbMimeType') => $exif['COMPUTED']['Thumbnail.MimeType']
);
}
return $new_img_info;
}
function exif_lang($langkey) {
return lang('exif', $langkey);
}
?>

View File

@@ -0,0 +1,267 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_feed.php 28299 2012-02-27 08:48:36Z svn_project_zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function feed_add($icon, $title_template='', $title_data=array(), $body_template='', $body_data=array(), $body_general='', $images=array(), $image_links=array(), $target_ids='', $friend='', $appid='', $returnid=0, $id=0, $idtype='', $uid=0, $username='') {
global $_G;
if(!helper_access::check_module('feed')) {
return false;
}
$title_template = $title_template?lang('feed', $title_template):'';
$body_template = $body_template?lang('feed', $body_template):'';
$body_general = $body_general?lang('feed', $body_general):'';
if(empty($uid) || empty($username)) {
$uid = $username = '';
}
$feedarr = array(
'icon' => $icon,
'uid' => $uid ? intval($uid) : $_G['uid'],
'username' => $username ? $username : $_G['username'],
'dateline' => $_G['timestamp'],
'title_template' => $title_template,
'body_template' => $body_template,
'body_general' => $body_general,
'image_1' => empty($images[0])?'':$images[0],
'image_1_link' => empty($image_links[0])?'':$image_links[0],
'image_2' => empty($images[1])?'':$images[1],
'image_2_link' => empty($image_links[1])?'':$image_links[1],
'image_3' => empty($images[2])?'':$images[2],
'image_3_link' => empty($image_links[2])?'':$image_links[2],
'image_4' => empty($images[3])?'':$images[3],
'image_4_link' => empty($image_links[3])?'':$image_links[3],
'target_ids' => $target_ids,
'friend' => $friend,
'id' => $id,
'idtype' => $idtype
);
$feedarr['title_data'] = serialize($title_data);
$feedarr['body_data'] = serialize($body_data);
$feedarr['hash_data'] = empty($title_data['hash_data'])?'':$title_data['hash_data'];
if($feedarr['hash_data']) {
$oldfeed = C::t('home_feed')->fetch_feedid_by_hashdata($feedarr['uid'], $feedarr['hash_data']);
if($oldfeed) {
return 0;
}
}
$feed_table = 'home_feed';
return C::t($feed_table)->insert($feedarr, $returnid);
}
function mkfeed($feed, $actors=array()) {
global $_G;
require_once libfile('function/discuzcode');
$feed['title_data'] = empty($feed['title_data'])?array():(is_array($feed['title_data'])?$feed['title_data']:@dunserialize($feed['title_data']));
if(!is_array($feed['title_data'])) $feed['title_data'] = array();
$feed['body_data'] = empty($feed['body_data'])?array():(is_array($feed['body_data'])?$feed['body_data']:@dunserialize($feed['body_data']));
if(!is_array($feed['body_data'])) $feed['body_data'] = array();
$searchs = $replaces = array();
if($feed['title_data']) {
foreach (array_keys($feed['title_data']) as $key) {
$searchs[] = '{'.$key.'}';
$replaces[] = $feed['title_data'][$key];
}
}
$searchs[] = '{actor}';
$replaces[] = empty($actors)?"<a href=\"home.php?mod=space&uid={$feed['uid']}\" target=\"_blank\">{$feed['username']}</a>":implode(lang('core', 'dot'), $actors);
$feed['title_template'] = str_replace($searchs, $replaces, $feed['title_template']);
$feed['title_template'] = feed_mktarget($feed['title_template']);
$searchs = $replaces = array();
$searchs[] = '{actor}';
$replaces[] = empty($actors)?"<a href=\"home.php?mod=space&uid={$feed['uid']}\" target=\"_blank\">{$feed['username']}</a>":implode(lang('core', 'dot'), $actors);
if($feed['body_data'] && is_array($feed['body_data'])) {
foreach (array_keys($feed['body_data']) as $key) {
$searchs[] = '{'.$key.'}';
$replaces[] = $feed['body_data'][$key];
}
}
if($feed['body_data']['flashvar']){
$feed['body_data']['player'] = parseflv($feed['body_data']['data'], '500', '373');
}
if($feed['body_data']['musicvar']){
$feed['body_data']['player'] = parseaudio($feed['body_data']['data']);
}
if($feed['body_data']['videovar']){
$feed['body_data']['player'] = parsemedia('x,500,373', $feed['body_data']['data']);
}
$feed['magic_class'] = '';
if(!empty($feed['body_data']['magic_thunder'])) {
$feed['magic_class'] = 'magicthunder';
}
$feed['body_template'] = str_replace($searchs, $replaces, $feed['body_template']);
$feed['body_template'] = feed_mktarget($feed['body_template']);
$feed['body_general'] = feed_mktarget($feed['body_general']);
$feed['icon_image'] = STATICURL."image/feed/{$feed['icon']}.gif";
$feed['new'] = 0;
if($_G['cookie']['home_readfeed'] && $feed['dateline']+300 > $_G['cookie']['home_readfeed']) {
$feed['new'] = 1;
}
return $feed;
}
function feed_mktarget($html) {
global $_G;
if($html && $_G['setting']['feedtargetblank']) {
$html = preg_replace("/target\=([\'\"]?)[\w]+([\'\"]?)/i", '', $html);
$html = preg_replace("/<a(.+?)href=([\'\"]?)([^>\s]+)\\2([^>]*)>/i", '<a href="\\3" target="_blank" \\1 \\4>', $html);
}
return $html;
}
function feed_publish($id, $idtype, $add=0) {
global $_G;
$id = intval($id);
if(empty($id)) {
return;
}
if(!helper_access::check_module('feed')) {
return false;
}
$setarr = array();
switch ($idtype) {
case 'blogid':
$value = array_merge(
C::t('home_blog')->fetch($id),
C::t('home_blogfield')->fetch($id)
);
if($value) {
if($value['friend'] != 3) {
$setarr['icon'] = 'blog';
$setarr['id'] = $value['blogid'];
$setarr['idtype'] = $idtype;
$setarr['uid'] = $value['uid'];
$setarr['username'] = $value['username'];
$setarr['dateline'] = $value['dateline'];
$setarr['target_ids'] = $value['target_ids'];
$setarr['friend'] = $value['friend'];
$setarr['hot'] = $value['hot'];
$status = $value['status'];
$url = "home.php?mod=space&uid={$value['uid']}&do=blog&id={$value['blogid']}";
if($value['friend'] == 4) {
$setarr['title_template'] = 'feed_blog_password';
$setarr['title_data'] = array('subject' => "<a href=\"$url\">{$value['subject']}</a>");
} else {
if($value['pic']) {
$setarr['image_1'] = pic_cover_get($value['pic'], $value['picflag']);
$setarr['image_1_link'] = $url;
}
$setarr['title_template'] = 'feed_blog_title';
$setarr['body_template'] = 'feed_blog_body';
$value['message'] = preg_replace("/&[a-z]+\;/i", '', $value['message']);
$setarr['body_data'] = array(
'subject' => "<a href=\"$url\">{$value['subject']}</a>",
'summary' => getstr($value['message'], 150, 0, 0, 0, -1)
);
}
}
}
break;
case 'albumid':
$key = 1;
if($id > 0) {
$query = C::t('home_pic')->fetch_all_by_sql('p.'.DB::field('albumid', $id), 'a.dateline DESC', 0, 4);
foreach($query as $value) {
if($value['friend'] <= 2) {
if(empty($setarr['icon'])) {
$setarr['icon'] = 'album';
$setarr['id'] = $value['albumid'];
$setarr['idtype'] = $idtype;
$setarr['uid'] = $value['uid'];
$setarr['username'] = $value['username'];
$setarr['dateline'] = $value['dateline'];
$setarr['target_ids'] = $value['target_ids'];
$setarr['friend'] = $value['friend'];
$status = $value['status'];
$setarr['title_template'] = 'feed_album_title';
$setarr['body_template'] = 'feed_album_body';
$setarr['body_data'] = array(
'album' => "<a href=\"home.php?mod=space&uid={$value['uid']}&do=album&id={$value['albumid']}\">{$value['albumname']}</a>",
'picnum' => $value['picnum']
);
}
$setarr['image_'.$key] = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote']);
$setarr['image_'.$key.'_link'] = "home.php?mod=space&uid={$value['uid']}&do=album&picid={$value['picid']}";
$key++;
} else {
break;
}
}
}
break;
case 'picid':
$plussql = $id>0 ? 'p.'.DB::field('picid', $id) : 'p.'.DB::field('uid', $_G['uid']).' ORDER BY dateline DESC LIMIT 1';
$query = C::t('home_pic')->fetch_all_by_sql($plussql);
if($value = $query[0]) {
if(empty($value['friend'])) {
$setarr['icon'] = 'album';
$setarr['id'] = $value['picid'];
$setarr['idtype'] = $idtype;
$setarr['uid'] = $value['uid'];
$setarr['username'] = $value['username'];
$setarr['dateline'] = $value['dateline'];
$setarr['target_ids'] = $value['target_ids'];
$setarr['friend'] = $value['friend'];
$setarr['hot'] = $value['hot'];
$status = $value['status'];
$url = "home.php?mod=space&uid={$value['uid']}&do=album&picid={$value['picid']}";
$setarr['image_1'] = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote']);
$setarr['image_1_link'] = $url;
$setarr['title_template'] = 'feed_pic_title';
$setarr['body_template'] = 'feed_pic_body';
$setarr['body_data'] = array('title' => $value['title']);
}
}
break;
}
if($setarr['icon']) {
$setarr['title_template'] = $setarr['title_template']?lang('feed', $setarr['title_template']):'';
$setarr['body_template'] = $setarr['body_template']?lang('feed', $setarr['body_template']):'';
$setarr['body_general'] = $setarr['body_general']?lang('feed', $setarr['body_general']):'';
$setarr['title_data']['hash_data'] = "{$idtype}{$id}";
$setarr['title_data'] = serialize($setarr['title_data']);
$setarr['body_data'] = serialize($setarr['body_data']);
$feedid = 0;
if(!$add && $setarr['id']) {
$feedid = C::t('home_feed')->fetch_feed($id, $idtype);
$feedid = $feedid['feedid'];
}
if($status == 0) {
if($feedid) {
C::t('home_feed')->update_feed('', $setarr, '', '', $feedid);
} else {
C::t('home_feed')->insert($setarr);
}
}
}
}
?>

View File

@@ -0,0 +1,31 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_filesock.php 36279 2016-12-09 07:54:31Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function _dfsockopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE, $encodetype = 'URLENCODE', $allowcurl = TRUE, $position = 0, $files = array()) {
$param = array(
'url' => $url,
'limit' => $limit,
'post' => $post,
'cookie' => $cookie,
'ip' => $ip,
'block' => $block,
'encodetype' => $encodetype,
'allowcurl' => $allowcurl,
'position' => $position,
'files' => $files
);
$fs = filesock::open($param);
return $fs->request();
}
?>

View File

@@ -0,0 +1,533 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_followcode.php 36284 2016-12-12 00:47:50Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$_G['post_attach'] = array();
function fcodedisp($code, $type='codehtml') {
global $_G;
$_G['forum_discuzcode']['pcodecount']++;
$_G['forum_discuzcode'][$type][$_G['forum_discuzcode']['pcodecount']] = $code;
$_G['forum_discuzcode']['codecount']++;
return "[\tD_".$_G['forum_discuzcode']['pcodecount']."\t]";
}
function followcode($message, $tid = 0, $pid = 0, $length = 0, $allowimg = true) {
global $_G;
include_once libfile('function/post');
$message = strip_tags($message);
$message = messagesafeclear($message);
if((strpos($message, '[/code]') || strpos($message, '[/CODE]')) !== FALSE) {
$message = preg_replace("/\s?\[code\](.+?)\[\/code\]\s?/is", "", $message);
}
$msglower = strtolower($message);
$htmlon = 0;
$message = dhtmlspecialchars($message);
if($_G['setting']['plugins']['func'][HOOKTYPE]['discuzcode']) {
$_G['discuzcodemessage'] = & $message;
$param = func_get_args();
hookscript('discuzcode', 'global', 'funcs', array('param' => $param, 'caller' => 'followcode'), 'discuzcode');
}
$_G['delattach'] = array();
$message = fparsesmiles($message);
if(strpos($msglower, 'attach://') !== FALSE) {
$message = preg_replace("/attach:\/\/(\d+)\.?(\w*)/i", '', $message);
}
if(strpos($msglower, 'ed2k://') !== FALSE) {
$message = preg_replace("/ed2k:\/\/(.+?)\//", '', $message);
}
if(strpos($msglower, '[/i]') !== FALSE) {
$message = preg_replace("/\s*\[i=s\][\n\r]*(.+?)[\n\r]*\[\/i\]\s*/is", '', $message);
}
$message = str_replace('[/p]', "\n", $message);
$message = str_replace(array(
'[/color]', '[/backcolor]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[s]', '[/s]', '[hr]',
'[i=s]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]',
'[list=A]', "\r\n[*]", '[*]', '[/list]', '[indent]', '[/indent]', '[/float]'
), '', preg_replace(array(
"/\[color=([#\w]+?)\]/i",
"/\[color=((rgb|rgba)\([\d\s\.,]+?\))\]/i",
"/\[backcolor=([#\w]+?)\]/i",
"/\[backcolor=((rgb|rgba)\([\d\s\.,]+?\))\]/i",
"/\[size=(\d+?)\]/i",
"/\[size=(\d+(\.\d+)?(px|pt)+?)\]/i",
"/\[font=([^\[\<]+?)\]/i",
"/\[align=(left|center|right)\]/i",
"/\[float=left\]/i",
"/\[float=right\]/i"
), '', $message));
if(strpos($msglower, '[/p]') !== FALSE) {
$message = preg_replace("/\[p=(\d{1,2}|null), (\d{1,2}|null), (left|center|right)\]/i", "<p style=\"line-height:\\1px;text-indent:\\2em;text-align:left;\">", $message);
$message = str_replace('[/p]', '</p>', $message);
}
if(strpos($msglower, '[/quote]') !== FALSE) {
$message = preg_replace("/\s?\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s?/is", '', $message);
}
if(strpos($msglower, '[/free]') !== FALSE) {
$message = preg_replace("/\s*\[free\][\n\r]*(.+?)[\n\r]*\[\/free\]\s*/is", '', $message);
}
if(isset($_G['cache']['bbcodes'][-$allowbbcode])) {
$message = preg_replace($_G['cache']['bbcodes'][-$allowbbcode]['searcharray'], '', $message);
}
if(strpos($msglower, '[/hide]') !== FALSE) {
preg_replace_callback("/\[hide.*?\]\s*(.*?)\s*\[\/hide\]/is", 'followcode_callback_hideattach_1', $message);
if(strpos($msglower, '[hide]') !== FALSE) {
$message = preg_replace("/\[hide\]\s*(.*?)\s*\[\/hide\]/is", '', $message);
}
if(strpos($msglower, '[hide=') !== FALSE) {
$message = preg_replace("/\[hide=(d\d+)?[,]?(\d+)?\]\s*(.*?)\s*\[\/hide\]/is", '', $message);
}
}
if(strpos($msglower, '[/url]') !== FALSE) {
$message = preg_replace_callback("/\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.|mailto:)?([^\r\n\[\"']+?))?\](.+?)\[\/url\]/is", 'followcode_callback_fparseurl_152', $message);
}
if(strpos($msglower, '[/email]') !== FALSE) {
$message = preg_replace_callback("/\[email(=([A-Za-z0-9\-_.+]+)@([A-Za-z0-9\-_]+[.][A-Za-z0-9\-_.]+))?\](.+?)\[\/email\]/is", 'followcode_callback_fparseemail_14', $message);
}
$nest = 0;
while(strpos($msglower, '[table') !== FALSE && strpos($msglower, '[/table]') !== FALSE){
$message = preg_replace_callback("/\[table(?:=(\d{1,4}%?)(?:,([\(\)%,#\w ]+))?)?\]\s*(.+?)\s*\[\/table\]/is", 'followcode_callback_fparsetable_123', $message);
if(++$nest > 4) break;
}
if(strpos($msglower, '[/media]') !== FALSE) {
$message = preg_replace_callback("/\[media=([\w%,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", 'followcode_callback_fparsemedia_12', $message);
}
if(strpos($msglower, '[/audio]') !== FALSE) {
$message = preg_replace_callback("/\[audio(=1)*\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/is", 'followcode_callback_fparseaudio_2', $message);
}
if(strpos($msglower, '[/flash]') !== FALSE) {
$message = preg_replace_callback("/\[flash(=(\d+),(\d+))?\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is", 'followcode_callback_fparseflash_4', $message);
}
if($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) {
$message = preg_replace_callback("/\[swf\]\s*([^\[\<\r\n]+?)\s*\[\/swf\]/is", 'followcode_callback_bbcodeurl_1', $message);
}
$flag = $length ? 1 : 0;
if($tid) {
$extra = "onclick=\"changefeed($tid, $pid, $flag, this)\"";
}
if(strpos($msglower, '[/img]') !== FALSE) {
$message = preg_replace_callback(
"/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is",
function ($matches) use ($allowimg, $extra) {
return intval($allowimg) ? fparseimg($matches[1], ''.addslashes($extra).'') : '';
},
$message
);
$message = preg_replace_callback(
"/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is",
function ($matches) use($allowimg, $extra) {
return intval($allowimg) ? fparseimg($matches[3], ''.addslashes($extra).'') : '';
},
$message
);
}
if($tid && $pid) {
$_G['post_attach'] = C::t('forum_attachment_n')->fetch_all_by_id(getattachtableid($tid), 'pid', $pid);
foreach($_G['post_attach'] as $aid => $attach) {
if(!empty($_G['delattach']) && in_array($aid, $_G['delattach'])) {
continue;
}
$message .= "[attach]{$attach['aid']}[/attach]";
$message = preg_replace("/\[attach\]{$attach['aid']}\[\/attach\]/i", fparseattach($attach['aid'], $length, $extra), $message, 1);
}
}
if(strpos($msglower, '[/attach]') !== FALSE) {
$message = preg_replace("/\[attach\]\s*([^\[\<\r\n]+?)\s*\[\/attach\]/is", '', $message);
}
$message = clearnl($message);
if($length) {
$sppos = strpos($message, chr(0).chr(0).chr(0));
if($sppos !== false) {
$message = substr($message, 0, $sppos);
}
$checkstr = cutstr($message, $length, '');
if(strpos($checkstr, '[') && strpos(strrchr($checkstr, "["), ']') === FALSE) {
$length = strpos($message, ']', strrpos($checkstr, strrchr($checkstr, "[")));
}
$message = cutstr($message, $length+1, ' <a href="javascript:;" class="flw_readfull xi2 xs1"'.$extra.'>'.lang('space', 'follow_view_fulltext').'</a>');
} elseif($allowimg && !empty($extra)) {
$message .= '<div class="ptm cl"><a href="javascript:;" class="flw_readfull y xi2 xs1"'.$extra.'>'.lang('space', 'follow_retract').'</a></div>';
}
for($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) {
$code = '';
if(isset($_G['forum_discuzcode']['codehtml'][$i]) && !empty($_G['forum_discuzcode']['codehtml'][$i])) {
$code = $_G['forum_discuzcode']['codehtml'][$i];
} elseif(!$length) {
if(isset($_G['forum_discuzcode']['audio'][$i]) && !empty($_G['forum_discuzcode']['audio'][$i])) {
$code = $_G['forum_discuzcode']['audio'][$i];
} elseif(isset($_G['forum_discuzcode']['video'][$i]) && !empty($_G['forum_discuzcode']['video'][$i])) {
$code = $_G['forum_discuzcode']['video'][$i];
} elseif(isset($_G['forum_discuzcode']['media'][$i]) && !empty($_G['forum_discuzcode']['media'][$i])) {
$code = $_G['forum_discuzcode']['media'][$i];
} elseif(isset($_G['forum_discuzcode']['image'][$i]) && !empty($_G['forum_discuzcode']['image'][$i])) {
$code = $_G['forum_discuzcode']['image'][$i];
} elseif(isset($_G['forum_discuzcode']['attach'][$i]) && !empty($_G['forum_discuzcode']['attach'][$i])) {
$code = $_G['forum_discuzcode']['attach'][$i];
}
}
$message = str_replace("[\tD_$i\t]", $code, $message);
}
$message = clearnl($message);
if(!empty($_GET['highlight'])) {
$highlightarray = explode('+', $_GET['highlight']);
$sppos = strrpos($message, chr(0).chr(0).chr(0));
if($sppos !== FALSE) {
$specialextra = substr($message, $sppos + 3);
$message = substr($message, 0, $sppos);
}
followcode_callback_highlightword_21($highlightarray, 1);
$message = preg_replace_callback("/(^|>)([^<]+)(?=<|$)/sU", 'followcode_callback_highlightword_21', $message);
$message = preg_replace("/<highlight>(.*)<\/highlight>/siU", "<strong><font color=\"#FF0000\">\\1</font></strong>", $message);
if($sppos !== FALSE) {
$message = $message.chr(0).chr(0).chr(0).$specialextra;
}
}
unset($msglower);
if($length) {
$count = 0;
$imagecode = $mediacode = $videocode = $audiocode = $mediahtml = '';
for($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) {
if(isset($_G['forum_discuzcode']['audio'][$i]) && !empty($_G['forum_discuzcode']['audio'][$i])) {
$audiocode .= '<li>'.$_G['forum_discuzcode']['audio'][$attachcodei].'</li>';
} elseif(isset($_G['forum_discuzcode']['video'][$i]) && !empty($_G['forum_discuzcode']['video'][$i])) {
$videocode .= '<li>'.$_G['forum_discuzcode']['video'][$i].'</li>';
} elseif(isset($_G['forum_discuzcode']['media'][$i]) && !empty($_G['forum_discuzcode']['media'][$i])) {
$mediacode .= '<li>'.$_G['forum_discuzcode']['media'][$i].'</li>';
} elseif(isset($_G['forum_discuzcode']['image'][$i]) && !empty($_G['forum_discuzcode']['image'][$i]) && $count < 4) {
$imagecode .= '<li>'.$_G['forum_discuzcode']['image'][$i].'</li>';
$count++;
} elseif(isset($_G['forum_discuzcode']['attach'][$i]) && !empty($_G['forum_discuzcode']['attach'][$i])) {
$attachcode .= '<li>'.$_G['forum_discuzcode']['attach'][$i].'</li>';
}
}
if(!empty($audiocode)) {
$message .= '<div class="flw_music"><ul>'.$audiocode.'</ul></div>';
}
if(!empty($videocode)) {
$message .= '<div class="flw_video"><ul>'.$videocode.'</ul></div>';
}
if(!empty($mediacode)) {
$message .= '<div class="flw_video"><ul>'.$mediacode.'</ul></div>';
}
if(!empty($imagecode)) {
$message = '<div class="flw_image'.($count < 2 ? ' flw_image_1' : '').'"><ul>'.$imagecode.'</ul></div>'.$message;
}
if(!empty($attachcode)) {
$message .= '<div class="flw_attach"><ul>'.$attachcode.'</ul></div>';
}
}
return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ' '), ' ', $message));
}
function followcode_callback_hideattach_1($matches) {
return hideattach($matches[1]);
}
function followcode_callback_fparseurl_152($matches) {
return fparseurl($matches[1], $matches[5], $matches[2]);
}
function followcode_callback_fparseemail_14($matches) {
return fparseemail($matches[1], $matches[4]);
}
function followcode_callback_fparsetable_123($matches) {
return fparsetable($matches[1], $matches[2], $matches[3]);
}
function followcode_callback_fparsemedia_12($matches) {
return fparsemedia($matches[1], $matches[2]);
}
function followcode_callback_fparseaudio_2($matches) {
return fparseaudio($matches[2]);
}
function followcode_callback_fparseflash_4($matches) {
return fparseflash($matches[4]);
}
function followcode_callback_bbcodeurl_1($matches) {
return bbcodeurl($matches[1], ' <img src="'.STATICURL.'image/filetype/flash.gif" align="absmiddle" alt="" /> <a href="{url}" target="_blank">Flash: {url}</a> ');
}
function followcode_callback_highlightword_21($matches, $action = 0) {
static $highlightarray = array();
if($action == 1) {
$highlightarray = $matches;
} else {
return highlightword($matches[2], $highlightarray, $matches[1]);
}
}
function clearnl($message) {
$message = preg_replace("/[\r\n|\n|\r]\s*[\r\n|\n|\r]/i", "\n", $message);
$message = preg_replace("/^[\r\n|\n|\r]{1,}/i", "", $message);
$message = preg_replace("/[\r\n|\n|\r]{2,}/i", "\n", $message);
return $message;
}
function hideattach($hidestr) {
global $_G;
preg_match_all("/\[attach\]\s*(.*?)\s*\[\/attach\]/is", $hidestr, $del);
foreach($del[1] as $aid) {
$_G['delattach'][$aid] = $aid;
}
}
function fparseurl($url, $text, $scheme) {
global $_G;
$html = '';
if(!$url && preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.)[^\[\"']+/i", trim($text), $matches)) {
$url = $matches[0];
$length = 65;
if(strlen($url) > $length) {
$text = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3));
}
$html = '<a href="'.(substr(strtolower($url), 0, 4) == 'www.' ? 'http://'.$url : $url).'" target="_blank">'.$text.'</a>';
} else {
$url = substr($url, 1);
if(substr(strtolower($url), 0, 4) == 'www.') {
$url = 'http://'.$url;
}
$url = !$scheme ? $_G['siteurl'].$url : $url;
$atclass = substr(strtolower($text), 0, 1) == '@' ? ' class="xi2" ' : '';
$html = '<a href="'.$url.'" target="_blank" '.$atclass.'>'.$text.'</a>';
}
return fcodedisp($html);
}
function fparseattach($aid, $length = 0, $extra = '') {
global $_G;
$html = '';
if(!empty($_G['post_attach']) && !empty($_G['post_attach'][$aid])) {
$attach = $_G['post_attach'][$aid];
unset($_G['post_attach'][$attach['aid']]);
$attach['url'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/';
$attach['isimage'] = $attach['isimage'] && !$attach['price'] ? $attach['isimage'] : 0;
$attach['refcheck'] = (!$attach['remote'] && $_G['setting']['attachrefcheck']) || ($attach['remote'] && ($_G['setting']['ftp']['hideurl'] || ($attach['isimage'] && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp')));
$rimg_id = random(5).$attach['aid'];
if($attach['isimage'] && !$attach['price'] && !$attach['readperm']) {
$nothumb = $length ? 0 : 1;
$src = $attach['url'].(!$attach['thumb'] ? $attach['attachment'] : getimgthumbname($attach['attachment']));
$html = bbcodeurl($src, '<img id="aimg_'.$rimg_id.'" src="'.$src.'" border="0" alt="'.$attach['filename'].'" '.$extra.' style="cursor: pointer;" />');
return fcodedisp($html, 'image');
} else {
if($attach['price'] || $attach['readperm']) {
$html = '<a href="forum.php?mod=viewthread&tid='.$attach['tid'].'" id="attach_'.$rimg_id.'" target="_blank" class="flw_attach_price"><strong>'.$attach['filename'].'</strong><span>'.sizecount($attach['filesize']).'</span></a>';
} else {
require_once libfile('function/attachment');
$aidencode = packaids($attach);
$attachurl = "forum.php?mod=attachment&aid=$aidencode";
$html = '<a href="'.$attachurl.'" id="attach_'.$rimg_id.'"><strong>'.$attach['filename'].'</strong><span>'.sizecount($attach['filesize']).'</span></a>';
}
return fcodedisp($html, 'attach');
}
}
return '';
}
function fparseflash($url) {
preg_match("/((https?){1}:\/\/|www\.)[^\[\"']+/i", $url, $matches);
$url = $matches[0];
if(fileext($url) != 'flv') {
$rimg_id = 'swf_'.random(5);
$html = bbcodeurl($url, '<img src="'.IMGDIR.'/flash.gif" alt="'.lang('space', 'follow_click_play').'" onclick="javascript:showFlash(\'flash\', \''.$url.'\', this, \''.$rimg_id.'\');" class="tn" style="cursor: pointer;" />');
return fcodedisp($html, 'media');
} else {
return fmakeflv($url);
}
}
function fparseemail($email, $text) {
global $_G;
$text = str_replace('\"', '"', $text);
$html = '';
if(!$email && preg_match("/\s*([A-Za-z0-9\-_.+]+)@([A-Za-z0-9\-_]+[.][A-Za-z0-9\-_.]+)\s*/i", $text, $matches)) {
$email = trim($matches[0]);
$html = '<a href="mailto:'.$email.'">'.$email.'</a>';
} else {
$html = '<a href="mailto:'.substr($email, 1).'">'.$text.'</a>';
}
return fcodedisp($html);
}
function fparsetable($width, $bgcolor, $message) {
global $_G;
$html = '';
if(strpos($message, '[/tr]') === FALSE && strpos($message, '[/td]') === FALSE) {
$rows = explode("\n", $message);
$html = '<table cellspacing="0" class="t_table" '.
($width == '' ? NULL : 'style="width:'.$width.'"').
($bgcolor ? ' bgcolor="'.$bgcolor.'">' : '>');
foreach($rows as $row) {
$html .= '<tr><td>'.str_replace(array('\|', '|', '\n'), array('&#124;', '</td><td>', "\n"), $row).'</td></tr>';
}
$html .= '</table>';
} else {
if(!preg_match("/^\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td([=\d,%]+)?\]/", $message) && !preg_match("/^<tr[^>]*?>\s*<td[^>]*?>/", $message)) {
return str_replace('\\"', '"', preg_replace("/\[tr(?:=([\(\)\s%,#\w]+))?\]|\[td([=\d,%]+)?\]|\[\/td\]|\[\/tr\]/", '', $message));
}
if(substr($width, -1) == '%') {
$width = substr($width, 0, -1) <= 98 ? intval($width).'%' : '98%';
} else {
$width = intval($width);
$width = $width ? ($width <= 560 ? $width.'px' : '98%') : '';
}
$message = preg_replace_callback("/\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td(?:=(\d{1,4}%?))?\]/i", 'fparsetable_callback_parsetrtd_12', $message);
$message = preg_replace_callback("/\[\/td\]\s*\[td(?:=(\d{1,4}%?))?\]/i", 'fparsetable_callback_parsetrtd_1', $message);
$message = preg_replace_callback("/\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/i", 'fparsetable_callback_parsetrtd_1234', $message);
$message = preg_replace_callback("/\[\/td\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/i", 'fparsetable_callback_parsetrtd_123', $message);
$html = '<table cellspacing="0" class="t_table" '.
($width == '' ? NULL : 'style="width:'.$width.'"').
($bgcolor ? ' bgcolor="'.$bgcolor.'">' : '>').
str_replace('\\"', '"', preg_replace("/\[\/td\]\s*\[\/tr\]\s*/i", '</td></tr>', $message)
).'</table>';
}
return fcodedisp($html);
}
function fparsetable_callback_parsetrtd_12($matches) {
return parsetrtd($matches[1], 0, 0, $matches[2]);
}
function fparsetable_callback_parsetrtd_1($matches) {
return parsetrtd('td', 0, 0, $matches[1]);
}
function fparsetable_callback_parsetrtd_1234($matches) {
return parsetrtd($matches[1], $matches[2], $matches[3], $matches[4]);
}
function fparsetable_callback_parsetrtd_123($matches) {
return parsetrtd('td', $matches[1], $matches[2], $matches[3]);
}
function fparseaudio($url) {
$url = addslashes($url);
if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://')) && !preg_match('/^static\//', $url) && !preg_match('/^data\//', $url)) {
return dhtmlspecialchars($url);
}
if(fileext($url) == 'mp3') {
$randomid = 'music_'.random(3);
$html = '<img src="'.IMGDIR.'/music.gif" alt="'.lang('space', 'follow_click_play').'" onclick="javascript:showFlash(\'music\', \''.$url.'\', this, \''.$randomid.'\');" class="tn" style="cursor: pointer;" />';
return fcodedisp($html, 'audio');
} else {
$html = '<a href="'.$url.'" target="_blank">'.$url.'</a>';
return $html;
}
}
function fmakeflv($flv) {
$randomid = 'video_'.random(3);
$flv = is_array($flv) ? $flv : array('flv' => $flv);
if(!preg_match("/^((https?){1}:\/\/|www\.)[^\[\"']+$/i", $flv['flv'])) {
return fcodedisp('', 'video');
}
if(!empty($flv['imgurl'])) {
if(!preg_match("/^((https?){1}:\/\/|www\.)[^\[\"']+$/i", $flv['imgurl'])) {
$html = '';
} else {
$html = '<table class="mtm" title="'.lang('space', 'follow_click_play').'" onclick="javascript:showFlash(\'flash\', \''.$flv['flv'].'\', this, \''.$randomid.'\');"><tr><td class="vdtn hm" style="background: url('.$flv['imgurl'].') no-repeat; border: 1px solid #CDCDCD; cursor: pointer; height: 95px; width: 126px;"><img src="'.IMGDIR.'/vds.png" alt="'.lang('space', 'follow_click_play').'" /> </td></tr></table>';
}
} else {
$html = '<img src="'.IMGDIR.'/vd.gif" alt="'.lang('space', 'follow_click_play').'" onclick="javascript:showFlash(\'flash\', \''.$flv['flv'].'\', this, \''.$randomid.'\');" class="tn" style="cursor: pointer;" />';
}
return fcodedisp($html, 'video');
}
function fparsemedia($params, $url) {
$params = explode(',', $params);
$url = addslashes($url);
$html = '';
if($flv = parseflv($url, 0, 0)) {
return fmakeflv($flv);
}
if(in_array(count($params), array(3, 4))) {
$type = $params[0];
$url = str_replace(array('<', '>'), '', str_replace('\\"', '\"', $url));
switch($type) {
case 'mp3':
return fparseaudio($url);
break;
case 'flv':
return fmakeflv($url);
break;
case 'swf':
return fparseflash($url);
break;
default:
$html = '<a href="'.$url.'" target="_blank">'.$url.'</a>';
break;
}
}
return fcodedisp($html, 'media');
}
function fparseimg($src, $extra = '') {
global $_G;
$rimg_id = random(5);
$html = bbcodeurl($src, '<img id="iimg_'.$rimg_id.'" src="'.$src.'" border="0" alt="" '.$extra.' style="cursor: pointer;" />');
return fcodedisp($html, 'image');
}
function fparsesmiles(&$message) {
global $_G;
static $enablesmiles;
if($enablesmiles === null) {
$enablesmiles = false;
if(!empty($_G['cache']['smilies']) && is_array($_G['cache']['smilies'])) {
foreach($_G['cache']['smilies']['replacearray'] AS $key => $smiley) {
if(substr($_G['cache']['smilies']['replacearray'][$key], 0, 1) == '<') {
break;
}
$_G['cache']['smilies']['replacearray'][$key] = '<img src="'.STATICURL.'image/smiley/'.$_G['cache']['smileytypes'][$_G['cache']['smilies']['typearray'][$key]]['directory'].'/'.$smiley.'" smilieid="'.$key.'" border="0" class="s" alt="" />';
}
$enablesmiles = true;
}
}
$enablesmiles && $message = preg_replace($_G['cache']['smilies']['searcharray'], $_G['cache']['smilies']['replacearray'], $message, $_G['setting']['maxsmilies']);
return $message;
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,484 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_forumlist.php 31960 2012-10-26 06:27:50Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function checkautoclose($thread) {
global $_G;
if(!$_G['forum']['ismoderator'] && $_G['forum']['autoclose']) {
$closedby = $_G['forum']['autoclose'] > 0 ? 'dateline' : 'lastpost';
if(TIMESTAMP - $thread[$closedby] > abs($_G['forum']['autoclose']) * 86400) {
return 'post_thread_closed_by_'.$closedby;
}
}
return FALSE;
}
function forum(&$forum) {
global $_G;
$lastvisit = $_G['member']['lastvisit'];
if(!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || !empty($forum['allowview']) || (isset($forum['users']) && strstr($forum['users'], "\t{$_G['uid']}\t"))) {
$forum['permission'] = 2;
} elseif(!$_G['setting']['hideprivate']) {
$forum['permission'] = 1;
} else {
return FALSE;
}
if($forum['icon']) {
$forum['icon'] = get_forumimg($forum['icon']);
$forum['icon'] = '<a href="forum.php?mod=forumdisplay&fid='.$forum['fid'].'"><img src="'.$forum['icon'].'" '.(!empty($forum['extra']['iconwidth']) && !defined('IN_MOBILE') ? 'style="width: '.$forum['extra']['iconwidth'].'px;"' : '').' align="left" alt="'.$forum['name'].'" /></a>';
}
$lastpost = array(0, 0, '', '');
$forum['lastpost'] = is_string($forum['lastpost']) ? explode("\t", $forum['lastpost']) : $forum['lastpost'];
$forum['lastpost'] =count($forum['lastpost']) != 4 ? $lastpost : $forum['lastpost'];
list($lastpost['tid'], $lastpost['subject'], $lastpost['dateline'], $lastpost['author']) = $forum['lastpost'];
$thisforumlastvisit = array();
if(!empty($_G['cookie']['forum_lastvisit'])) {
preg_match("/D\_".$forum['fid']."\_(\d+)/", $_G['cookie']['forum_lastvisit'], $thisforumlastvisit);
}
$forum['folder'] = ($thisforumlastvisit && $thisforumlastvisit[1] > $lastvisit ? $thisforumlastvisit[1] : $lastvisit) < $lastpost['dateline'] ? ' class="new"' : '';
if($lastpost['tid']) {
$lastpost['dateline'] = dgmdate($lastpost['dateline'], 'u');
$lastpost['authorusername'] = $lastpost['author'];
if($lastpost['author']) {
$lastpost['author'] = '<a href="home.php?mod=space&username='.rawurlencode($lastpost['author']).'">'.$lastpost['author'].'</a>';
}
$forum['lastpost'] = $lastpost;
} else {
$forum['lastpost'] = $lastpost['authorusername'] = '';
}
$forum['moderators'] = moddisplay($forum['moderators'], $_G['setting']['moddisplay'], !empty($forum['inheritedmod']));
if(isset($forum['subforums'])) {
$forum['subforums'] = implode(', ', $forum['subforums']);
}
return TRUE;
}
function forumselect($groupselectable = FALSE, $arrayformat = 0, $selectedfid = 0, $showhide = FALSE, $evalue = FALSE, $special = 0) {
global $_G;
if(!isset($_G['cache']['forums'])) {
loadcache('forums');
}
$forumcache = &$_G['cache']['forums'];
$forumlist = $arrayformat ? array() : '<optgroup label="&nbsp;">';
foreach($forumcache as $forum) {
if(!$forum['status'] && !$showhide) {
continue;
}
$selected = '';
if($selectedfid) {
if(!is_array($selectedfid)) {
$selected = $selectedfid == $forum['fid'] ? ' selected' : '';
} else {
$selected = in_array($forum['fid'], $selectedfid) ? ' selected' : '';
}
}
if($forum['type'] == 'group') {
if($arrayformat) {
$forumlist[$forum['fid']]['name'] = $forum['name'];
} else {
$forumlist .= $groupselectable ? '<option value="'.($evalue ? 'gid_' : '').$forum['fid'].'" class="bold">--'.$forum['name'].'</option>' : '</optgroup><optgroup label="--'.$forum['name'].'">';
}
$visible[$forum['fid']] = true;
} elseif($forum['type'] == 'forum' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || strstr($forum['users'], "\t{$_G['uid']}\t")) && (!$special || (substr($forum['allowpostspecial'], -$special, 1)))) {
if($arrayformat) {
$forumlist[$forum['fup']]['sub'][$forum['fid']] = $forum['name'];
} else {
$forumlist .= '<option value="'.($evalue ? 'fid_' : '').$forum['fid'].'"'.$selected.'>'.$forum['name'].'</option>';
}
$visible[$forum['fid']] = true;
} elseif($forum['type'] == 'sub' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || strstr($forum['users'], "\t{$_G['uid']}\t")) && (!$special || substr($forum['allowpostspecial'], -$special, 1))) {
if($arrayformat) {
$forumlist[$forumcache[$forum['fup']]['fup']]['child'][$forum['fup']][$forum['fid']] = $forum['name'];
} else {
$forumlist .= '<option value="'.($evalue ? 'fid_' : '').$forum['fid'].'"'.$selected.'>&nbsp; &nbsp; &nbsp; '.$forum['name'].'</option>';
}
}
}
if(!$arrayformat) {
$forumlist .= '</optgroup>';
$forumlist = str_replace('<optgroup label="&nbsp;"></optgroup>', '', $forumlist);
}
return $forumlist;
}
function visitedforums() {
global $_G;
$count = 0;
$visitedforums = '';
$fidarray = array($_G['forum']['fid']);
$_G['cookie']['visitedfid'] = isset($_G['cookie']['visitedfid']) ? $_G['cookie']['visitedfid'] : '';
if(!empty($_G['cookie']['visitedfid'])) {
foreach(explode('D', $_G['cookie']['visitedfid']) as $fid) {
if(isset($_G['cache']['forums'][$fid]) && !in_array($fid, $fidarray)) {
if($fid != $_G['forum']['fid']) {
$visitedforums .= '<li><a href="forum.php?mod=forumdisplay&fid='.$fid.'">'.$_G['cache']['forums'][$fid]['name'].'</a></li>';
if(++$count >= $_G['setting']['visitedforums']) {
break;
}
}
$fidarray[] = $fid;
}
}
}
if(($visitedfid = implode('D', $fidarray)) != $_G['cookie']['visitedfid']) {
dsetcookie('visitedfid', $visitedfid, 2592000);
}
return $visitedforums;
}
function moddisplay($moderators, $type, $inherit = 0) {
if($moderators) {
$modlist = $comma = '';
foreach(explode("\t", $moderators) as $moderator) {
$modlist .= $comma.'<a href="home.php?mod=space&username='.rawurlencode($moderator).'" class="notabs" c="1">'.($inherit ? '<strong>'.$moderator.'</strong>' : $moderator).'</a>';
$comma = ', ';
}
} else {
$modlist = '';
}
return $modlist;
}
function getcacheinfo($tid) {
global $_G;
$tid = intval($tid);
$cachethreaddir2 = DISCUZ_ROOT.'./'.$_G['setting']['cachethreaddir'];
$cache = array('filemtime' => 0, 'filename' => '');
$tidmd5 = substr(md5($tid), 3);
$fulldir = $cachethreaddir2.'/'.$tidmd5[0].'/'.$tidmd5[1].'/'.$tidmd5[2].'/';
$cache['filename'] = $fulldir.$tid.'.htm';
if(file_exists($cache['filename'])) {
$cache['filemtime'] = filemtime($cache['filename']);
} else {
if(!is_dir($fulldir)) {
dmkdir($fulldir);
}
}
return $cache;
}
function replace_formhash($timestamp, $input) {
global $_G;
$temp_md5 = md5(substr($timestamp, 0, -3).substr($_G['config']['security']['authkey'], 3, -3));
$temp_formhash = substr($temp_md5, 8, 8);
$input = preg_replace('/(name=[\'|\"]formhash[\'|\"] value=[\'\"]|formhash=)'.$temp_formhash.'/ismU', '${1}'.constant("FORMHASH"), $input);
$temp_siteurl = 'siteurl_'.substr($temp_md5, 16, 8);
$input = preg_replace('/("|\')'.$temp_siteurl.'/ismU', '${1}'.$_G['siteurl'], $input);
return $input;
}
function recommendupdate($fid, &$modrecommend, $force = '', $position = 0) {
global $_G;
$recommendlist = $modedtids = array();
$num = $modrecommend['num'] ? intval($modrecommend['num']) : 10;
$imagenum = $modrecommend['imagenum'] = $modrecommend['imagenum'] ? intval($modrecommend['imagenum']) : 0;
$imgw = $modrecommend['imagewidth'] = $modrecommend['imagewidth'] ? intval($modrecommend['imagewidth']) : 200;
$imgh = $modrecommend['imageheight'] = $modrecommend['imageheight'] ? intval($modrecommend['imageheight']) : 150;
if($modrecommend['sort'] && (TIMESTAMP - $modrecommend['updatetime'] > $modrecommend['cachelife'] || $force)) {
foreach(C::t('forum_forumrecommend')->fetch_all_by_fid($fid) as $row) {
if($modrecommend['sort'] == 2 && $row['moderatorid']) {
$modedtids[] = $row['tid'];
}
}
C::t('forum_forumrecommend')->delete_by_fid($fid, $modrecommend['sort'] == 2 ? 0 : false);
$orderby = 'dateline';
$dateline = $modrecommend['dateline'] ? (TIMESTAMP - $modrecommend['dateline'] * 3600) : null;
$recommends = null;
switch($modrecommend['orderby']) {
case '':
case '1':$orderby = 'lastpost';break;
case '2':$orderby = 'views';break;
case '3':$orderby = 'replies';break;
case '4':$orderby = 'digest';break;
case '5':$orderby = 'recommends';$recommends = 0;break;
case '6':$orderby = 'heats';break;
}
$i = 0;
$addthread = $addimg = $recommendlist = $recommendimagelist = $tids = array();
foreach(C::t('forum_thread')->fetch_all_by_fid_displayorder($fid, 0, $dateline, $recommends, 0, $num, $orderby) as $thread) {
$recommendlist[$thread['tid']] = $thread;
$tids[] = $thread['tid'];
if(!$modedtids || !in_array($thread['tid'], $modedtids)) {
$addthread[$thread['tid']] = array(
'fid' => $thread['fid'],
'tid' => $thread['tid'],
'position' => 1,
'displayorder' => $i,
'subject' => $thread['subject'],
'author' => $thread['author'],
'authorid' => $thread['authorid'],
'moderatorid' => 0,
'expiration' => 0,
'highlight' => $thread['highlight']
);
$i++;
}
}
if($tids && $imagenum) {
$attachtables = array();
foreach($tids as $tid) {
$attachtables[getattachtablebytid($tid)][] = $tid;
}
foreach($attachtables as $attachtable => $tids) {
$attachmentpost = array();
$postlist = C::t('forum_post')->fetch_all_by_tid(0, $tids, false, '', 0, 0, 1);
if($postlist) {
$pids = array();
foreach($postlist as $post) {
$pids[] = $post['pid'];
}
$attachmentlist = C::t('forum_attachment_n')->fetch_all_by_pid_width('tid:'.$tids[0], $pids, $imgw);
if($attachmentlist) {
foreach($attachmentlist as $k => $attachment) {
$attachmentpost[$k]['fid'] = $postlist[$attachment['pid']]['fid'];
$attachmentpost[$k]['tid'] = $postlist[$attachment['pid']]['tid'];
$attachmentpost[$k]['aid'] = $attachment['aid'];
}
}
unset($postlist, $attachmentlist, $pids);
}
foreach($attachmentpost as $attachment) {
if(isset($recommendimagelist[$attachment['tid']])) {
continue;
}
$key = md5($attachment['aid'].'|'.$imgw.'|'.$imgh);
$recommendlist[$attachment['tid']]['filename'] = $attachment['aid']."\t".$imgw."\t".$imgh."\t".$key;
$recommendimagelist[$attachment['tid']] = $recommendlist[$attachment['tid']];
$recommendimagelist[$attachment['tid']]['subject'] = addslashes($recommendimagelist[$attachment['tid']]['subject']);
$addthread[$attachment['tid']]['aid'] = '';
$addthread[$attachment['tid']]['filename'] = $recommendlist[$attachment['tid']]['filename'];
$addthread[$attachment['tid']]['typeid'] = 1;
if(count($recommendimagelist) == $imagenum) {
break;
}
}
}
}
unset($recommendimagelist);
if($addthread) {
foreach($addthread as $row) {
C::t('forum_forumrecommend')->insert($row, false, true);
}
$modrecommend['updatetime'] = TIMESTAMP;
$modrecommendnew = serialize($modrecommend);
C::t('forum_forumfield')->update($fid, array('modrecommend' => $modrecommendnew));
}
}
$recommendlists = $recommendlist = $recommendimagelist = array();
foreach(C::t('forum_forumrecommend')->fetch_all_by_fid($fid, $position) as $recommend) {
if(($recommend['expiration'] && $recommend['expiration'] > TIMESTAMP) || !$recommend['expiration']) {
if($recommend['filename'] && strexists($recommend['filename'], "\t")) {
$imgd = explode("\t", $recommend['filename']);
if($imgd[0] && $imgd[3]) {
$recommend['filename'] = getforumimg($imgd[0], 0, $imgd[1], $imgd[2]);
}
}
$recommendlist[] = $recommend;
if($recommend['typeid'] && count($recommendimagelist) < $imagenum) {
$recommendimagelist[] = $recommend;
}
}
if(count($recommendlist) == $num) {
break;
}
}
if($recommendlist) {
$_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
foreach($recommendlist as $thread) {
if($thread['highlight']) {
$string = sprintf('%02d', $thread['highlight']);
$stylestr = sprintf('%03b', $string[0]);
$thread['highlight'] = ' style="';
$thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
$thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
$thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
$thread['highlight'] .= $string[1] ? 'color: '.$_G['forum_colorarray'][$string[1]] : '';
$thread['highlight'] .= '"';
} else {
$thread['highlight'] = '';
}
$recommendlists[$thread['tid']]['author'] = $thread['author'];
$recommendlists[$thread['tid']]['authorid'] = $thread['authorid'];
$recommendlists[$thread['tid']]['subject'] = $modrecommend['maxlength'] ? cutstr($thread['subject'], $modrecommend['maxlength']) : $thread['subject'];
$recommendlists[$thread['tid']]['subjectstyles'] = $thread['highlight'];
}
}
if($recommendimagelist && $recommendlist) {
$recommendlists['images'] = $recommendimagelist;
}
return $recommendlists;
}
function showstars($num) {
global $_G;
$return = '';
$alt = 'title="Rank: '.$num.'"';
if(empty($_G['setting']['starthreshold'])) {
for($i = 0; $i < $num; $i++) {
$return .= '<i class="fico-star1 fic4 fc-l" '.$alt.'></i>';
}
} else {
for($i = 3; $i > 0; $i--) {
$numlevel = intval($num / pow($_G['setting']['starthreshold'], ($i - 1)));
$num = ($num % pow($_G['setting']['starthreshold'], ($i - 1)));
for($j = 0; $j < $numlevel; $j++) {
$return .= '<i class="fico-star'.$i.' fic4 fc-l" '.$alt.'></i>';
}
}
}
return $return;
}
function get_forumimg($imgname) {
global $_G;
if($imgname) {
$parse = parse_url($imgname);
if(isset($parse['host'])) {
$imgpath = $imgname;
} else {
if($_G['forum']['status'] != 3) {
$imgpath = $_G['setting']['attachurl'].'common/'.$imgname;
} else {
$imgpath = $_G['setting']['attachurl'].'group/'.$imgname;
}
}
return $imgpath;
}
}
function forumleftside() {
global $_G;
$leftside = array('favorites' => array(), 'forums' => array());
$leftside['forums'] = forumselect(FALSE, 1);
if($_G['uid']) {
foreach(C::t('home_favorite')->fetch_all_by_uid_idtype($_G['uid'], 'fid') as $id => $forum) {
if($_G['fid'] == $forum['id']) {
$_G['forum_fidinfav'] = $forum['favid'];
}
$leftside['favorites'][$forum['id']] = array($forum['title'], $forum['favid']);
}
}
$_G['leftsidewidth_mwidth'] = $_G['setting']['leftsidewidth'] + 15;
return $leftside;
}
function threadclasscount($fid, $id = 0, $idtype = '', $count = null) {
if(!$fid) {
return false;
}
$typeflag = ($id && $idtype && in_array($idtype, array('typeid', 'sortid')));
$threadclasscount = C::t('common_cache')->fetch('threadclasscount_'.$fid);
$threadclasscount = dunserialize($threadclasscount['cachevalue']);
if($count !== null) {
if($typeflag) {
$threadclasscount[$idtype][$id] = $count;
C::t('common_cache')->insert(array(
'cachekey' => 'threadclasscount_'.$fid,
'cachevalue' => serialize($threadclasscount),
), false, true);
return true;
} else {
return false;
}
} else {
if($typeflag) {
return $threadclasscount[$idtype][$id];
} else {
return $threadclasscount;
}
}
}
function get_attach($list, $video = false, $audio = false){
global $_G;
require_once libfile('function/post');
require_once libfile('function/discuzcode');
$tids = $threads = $attachtableid_array = $threadlist_data = $posttableids = array();
foreach($list as $value) {
$tids[] = $value['tid'];
if(!in_array($value['posttableid'], $posttableids)){
$posttableids[] = $value['posttableid'];
}
$threads[$value['tid']] = $value;
}
foreach ($posttableids as $id) {
$posts = C::t('forum_post')->fetch_all_by_tid($id, $tids, true, '', 0, 0, 1, null, null, null);
foreach($posts as $value) {
if(!$_G['forum']['ismoderator'] && $value['status'] & 1) {
$threadlist_data[$value['tid']]['message'] = lang('forum/template', 'message_single_banned');
} elseif(strpos($value['message'], '[/password]') !== FALSE) {
$threadlist_data[$value['tid']]['message'] = lang('forum/template', 'message_password_exists');
} elseif($threads[$value['tid']]['readperm'] > 0) {
$value['message'] = '';
} else {
if($threads[$value['tid']]['price'] > 0) {
preg_match_all("/\[free\](.+?)\[\/free\]/is", $value['message'], $matches);
$value['message'] = '';
if(!empty($matches[1])) {
foreach($matches[1] as $match) {
$value['message'] .= $match.' ';
}
}
}
if($value['message'] && ($video || $audio)){
$value['media'] = '';
$value['message'] = preg_replace(array("/\[hide=?\d*\](.*?)\[\/hide\]/is"), array(""), $value['message']);
$value['msglower'] = strtolower($value['message']);
if(strpos($value['msglower'], '[/media]') !== FALSE && $video) {
preg_match("/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/is", $value['message'], $value['video']);
$threadlist_data[$value['tid']]['media'] = parsemedia($value['video'][1], $value['video'][2]);
}elseif(strpos($value['msglower'], '[/audio]') !== FALSE && $audio) {
preg_match("/\[audio(=1)*\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/is", $value['message'], $value['audio']);
$threadlist_data[$value['tid']]['media'] = parseaudio($value['audio'][2], 400);
}
}
$threadlist_data[$value['tid']]['message'] = messagecutstr($value['message'], defined('IN_MOBILE') ? 90 : 300);
if($threads[$value['tid']]['attachment'] == 2) {
$attachtableid_array[getattachtableid($value['tid'])][] = $value['pid'];
}
}
}
}
foreach($attachtableid_array as $tableid => $pids) {
$attachs = C::t('forum_attachment_n')->fetch_all_by_pid_width($tableid, $pids, 0);
foreach($attachs as $value){
$threadlist_data[$value['tid']]['attachment'][] = getforumimg($value['aid'], 0, 550, 350);
}
}
return $threadlist_data;
}
?>

View File

@@ -0,0 +1,278 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_friend.php 26635 2011-12-19 01:59:13Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function friend_list($uid, $limit, $start=0) {
$list = array();
$query = C::t('home_friend')->fetch_all_by_uid($uid, $start, $limit, true);
foreach($query as $value) {
$list[$value['fuid']] = $value;
}
return $list;
}
function friend_group_list() {
global $_G;
$space = array('uid' => $_G['uid']);
space_merge($space, 'field_home');
$groups = array();
$spacegroup = empty($space['privacy']['groupname'])?array():$space['privacy']['groupname'];
for($i = 0; $i < $_G['setting']['friendgroupnum']; $i++) {
if($i == 0) {
$groups[0] = lang('friend', 'friend_group_default');
} else {
if(!empty($spacegroup[$i])) {
$groups[$i] = $spacegroup[$i];
} else {
if($i<8) {
$groups[$i] = lang('friend', 'friend_group_'.$i);
} else {
$groups[$i] = lang('friend', 'friend_group_more', array('num'=>$i));
}
}
}
}
return $groups;
}
function friend_check($touids, $isfull = 0) {
global $_G;
if(empty($_G['uid'])) return false;
if(is_array($touids)) {
$query = C::t('home_friend')->fetch_all_by_uid_fuid($_G['uid'], $touids);
foreach($query as $value) {
$touid = $value['fuid'];
$var = "home_friend_{$_G['uid']}_{$touid}";
$fvar = "home_friend_{$touid}_{$_G['uid']}";
$_G[$var] = $_G[$fvar] = true;
if($isfull) {
$fvarinfo = "home_friend_info_{$touid}_{$_G['uid']}";
$_G[$fvarinfo] = $value;
}
}
if(count($query) != count($touids)) {
return false;
} else {
return true;
}
} else {
$touid = $touids;
$var = "home_friend_{$_G['uid']}_{$touid}";
$fvar = "home_friend_{$touid}_{$_G['uid']}";
if(!isset($_G[$var])) {
$query = C::t('home_friend')->fetch_all_by_uid_fuid($_G['uid'], $touid);
$friend = isset($query[0]) ? $query[0] : '';
if($friend) {
$_G[$var] = $_G[$fvar] = true;
if($isfull) {
$fvarinfo = "home_friend_info_{$touid}_{$_G['uid']}";
$_G[$fvarinfo] = $friend;
}
} else {
$_G[$var] = $_G[$fvar] = false;
}
}
return $_G[$var];
}
}
function friend_request_check($touid) {
global $_G;
$var = "home_friend_request_{$touid}";
if(!isset($_G[$var])) {
$result = C::t('home_friend_request')->fetch_by_uid_fuid($_G['uid'], $touid);
$_G[$var] = $result?true:false;
}
return $_G[$var];
}
function friend_add($touid, $gid=0, $note='') {
global $_G;
if($touid == $_G['uid']) return -2;
if(friend_check($touid)) return -2;
include_once libfile('function/stat');
$freind_request = C::t('home_friend_request')->fetch_by_uid_fuid($_G['uid'], $touid);
if($freind_request) {
$setarr = array(
'uid' => $_G['uid'],
'fuid' => $freind_request['fuid'],
'fusername' => addslashes($freind_request['fusername']),
'gid' => $gid,
'dateline' => $_G['timestamp']
);
C::t('home_friend')->insert($setarr);
friend_request_delete($touid);
friend_cache($_G['uid']);
$setarr = array(
'uid' => $touid,
'fuid' => $_G['uid'],
'fusername' => $_G['username'],
'gid' => $freind_request['gid'],
'dateline' => $_G['timestamp']
);
C::t('home_friend')->insert($setarr);
addfriendlog($_G['uid'], $touid);
friend_cache($touid);
updatestat('friend');
} else {
$to_freind_request = C::t('home_friend_request')->fetch_by_uid_fuid($touid, $_G['uid']);
if($to_freind_request) {
return -1;
}
$setarr = array(
'uid' => $touid,
'fuid' => $_G['uid'],
'fusername' => $_G['username'],
'gid' => $gid,
'note' => $note,
'dateline' => $_G['timestamp']
);
C::t('home_friend_request')->insert($setarr);
updatestat('addfriend');
}
return 1;
}
function friend_make($touid, $tousername, $checkrequest=true) {
global $_G;
if($touid == $_G['uid']) return false;
if($checkrequest) {
$to_freind_request = C::t('home_friend_request')->fetch_by_uid_fuid($touid, $_G['uid']);
if($to_freind_request) {
C::t('home_friend_request')->delete_by_uid_fuid($touid, $_G['uid']);
}
$to_freind_request = C::t('home_friend_request')->fetch_by_uid_fuid($_G['uid'], $touid);
if($to_freind_request) {
C::t('home_friend_request')->delete_by_uid_fuid($_G['uid'], $touid);
}
}
$insertarray = array(
'uid' => $touid,
'fuid' => $_G['uid'],
'fusername' => $_G['username'],
'dateline' => $_G['timestamp'],
);
C::t('home_friend')->insert($insertarray, false, true);
$insertarray = array(
'uid' => $_G['uid'],
'fuid' => $touid,
'fusername' => $tousername,
'dateline' => $_G['timestamp'],
);
C::t('home_friend')->insert($insertarray, false, true);
addfriendlog($_G['uid'], $touid);
include_once libfile('function/stat');
updatestat('friend');
friend_cache($touid);
friend_cache($_G['uid']);
}
function addfriendlog($uid, $touid, $action = 'add') {
global $_G;
if($uid && $touid) {
$flog = array(
'uid' => $uid > $touid ? $uid : $touid,
'fuid' => $uid > $touid ? $touid : $uid,
'dateline' => $_G['timestamp'],
'action' => $action
);
DB::insert('home_friendlog', $flog, false, true);
return true;
}
return false;
}
function friend_addnum($touid) {
global $_G;
if($_G['uid'] && $_G['uid'] != $touid) {
C::t('home_friend')->update_num_by_uid_fuid(1, $_G['uid'], $touid);
}
}
function friend_cache($touid) {
global $_G;
$tospace = array('uid' => $touid);
space_merge($tospace, 'field_home');
$filtergids = empty($tospace['privacy']['filter_gid'])?array():$tospace['privacy']['filter_gid'];
$uids = array();
$count = 0;
$fcount = 0;
$query = C::t('home_friend')->fetch_all_by_uid($touid, 0, 0, true);
foreach($query as $value) {
if($value['fuid'] == $touid) continue;
if($fcount > 200) {
$count = count($query);
break;
} elseif(empty($filtergids) || !in_array($value['gid'], $filtergids)) {
$uids[] = $value['fuid'];
$fcount++;
}
$count++;
}
C::t('common_member_field_home')->update($touid, array('feedfriend'=>implode(',', $uids)));
C::t('common_member_count')->update($touid, array('friends'=>$count));
}
function friend_request_delete($touid) {
global $_G;
return C::t('home_friend_request')->delete_by_uid_fuid($_G['uid'], $touid);
}
function friend_delete($touid) {
global $_G;
if(!friend_check($touid)) return false;
C::t('home_friend')->delete_by_uid_fuid_dual($_G['uid'], $touid);
if(DB::affected_rows()) {
addfriendlog($_G['uid'], $touid, 'delete');
friend_cache($_G['uid']);
friend_cache($touid);
}
}
?>

View File

@@ -0,0 +1,365 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_group.php 32367 2013-01-07 02:30:12Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function delgroupcache($fid, $cachearray) {
C::t('forum_groupfield')->delete_by_type($cachearray, $fid);
}
function groupperm(&$forum, $uid, $action = '', $isgroupuser = '') {
if($forum['status'] != 3 || $forum['type'] != 'sub') {
return -1;
}
if(!empty($forum['founderuid']) && $forum['founderuid'] == $uid) {
return 'isgroupuser';
}
$isgroupuser = empty($isgroupuser) && $isgroupuser !== false ? C::t('forum_groupuser')->fetch_userinfo($uid, $forum['fid']) : $isgroupuser;
if($forum['ismoderator'] && !$isgroupuser) {
return '';
}
if($forum['jointype'] < 0 && !$forum['ismoderator']) {
return 1;
}
if(!$forum['gviewperm'] && !$isgroupuser) {
return 2;
}
if($forum['jointype'] == 2 && (!$forum['gviewperm'] || $action == 'post') && !empty($isgroupuser['uid']) && $isgroupuser['level'] == 0) {
return 3;
}
if($action == 'post' && !$isgroupuser) {
return 4;
}
if(is_array($isgroupuser['level']) && $isgroupuser['level'] === 0) {
return 5;
}
return $isgroupuser ? 'isgroupuser' : '';
}
function grouplist($orderby = 'displayorder', $fieldarray = array(), $num = 1, $fids = array(), $sort = 0, $getcount = 0, $grouplevel = array()) {
$query = C::t('forum_forum')->fetch_all_for_grouplist($orderby, $fieldarray, $num, $fids, $sort, $getcount);
if($getcount) {
return $query;
}
$grouplist = array();
foreach($query as $group) {
$group['iconstatus'] = $group['icon'] ? 1 : 0;
isset($group['icon']) && $group['icon'] = get_groupimg($group['icon'], 'icon');
isset($group['banner']) && $group['banner'] = get_groupimg($group['banner']);
$group['orderid'] = $orderid ? intval($orderid) : '';
isset($group['dateline']) && $group['dateline'] = $group['dateline'] ? dgmdate($group['dateline'], 'd') : '';
isset($group['lastupdate']) && $group['lastupdate'] = $group['lastupdate'] ? dgmdate($group['lastupdate'], 'd') : '';
$group['level'] = !empty($grouplevel) ? intval($grouplevel[$group['fid']]) : 0;
isset($group['description']) && $group['description'] = cutstr($group['description'], 130);
$grouplist[$group['fid']] = $group;
$orderid ++;
}
return $grouplist;
}
function mygrouplist($uid, $orderby = '', $fieldarray = array(), $num = 0, $start = 0, $ismanager = 0, $count = 0) {
$uid = intval($uid);
if(empty($uid)) {
return array();
}
$groupfids = $grouplevel = array();
$query = C::t('forum_groupuser')->fetch_all_group_for_user($uid, $count, $ismanager, $start, $num);
if($count == 1) {
return $query;
}
foreach($query as $group) {
$groupfids[] = $group['fid'];
$grouplevel[$group['fid']] = $group['level'];
}
if(empty($groupfids)) {
return false;
}
$mygrouplist = grouplist($orderby, $fieldarray, $num, $groupfids, 0, 0, $grouplevel);
return $mygrouplist;
}
function get_groupimg($imgname, $imgtype = '') {
global $_G;
$imgpath = $_G['setting']['attachurl'].'group/'.$imgname;
if($imgname) {
return $imgpath;
} else {
if($imgtype == 'icon') {
return STATICURL.'image/common/groupicon.gif';
} else {
return '';
}
}
}
function get_groupselect($fup = 0, $groupid = 0, $ajax = 1) {
global $_G;
loadcache('grouptype');
$firstgroup = $_G['cache']['grouptype']['first'];
$secondgroup = $_G['cache']['grouptype']['second'];
$grouptypeselect = array('first' => '', 'second' => '');
if($ajax) {
$fup = intval($fup);
$groupid = intval($groupid);
foreach($firstgroup as $gid => $group) {
$selected = $fup == $gid ? 'selected="selected"' : '';
$grouptypeselect['first'] .= '<option value="'.$gid.'" '.$selected.'>'.$group['name'].'</option>';
}
if($fup && !empty($firstgroup[$fup]['secondlist'])) {
foreach($firstgroup[$fup]['secondlist'] as $sgid) {
$selected = $sgid == $groupid ? 'selected="selected"' : '';
$grouptypeselect['second'] .= '<option value="'.$sgid.'" '.$selected.'>'.$secondgroup[$sgid]['name'].'</option>';
}
}
} else {
foreach($firstgroup as $gid => $group) {
$gselected = $groupid == $gid ? 'selected="selected"' : '';
$grouptypeselect .= '<option value="'.$gid.'" '.$gselected.'>'.$group['name'].'</option>';
if(is_array($group['secondlist'])) {
foreach($group['secondlist'] as $secondid) {
$selected = $groupid == $secondid ? 'selected="selected"' : '';
$grouptypeselect .= '<option value="'.$secondid.'" '.$selected.'>&nbsp;&nbsp;'.$secondgroup[$secondid]['name'].'</option>';
}
}
$grouptypeselect .= '</optgroup>';
}
}
return $grouptypeselect;
}
function get_groupnav($forum) {
global $_G;
if(empty($forum) || empty($forum['fid']) || empty($forum['name'])) {
return '';
}
loadcache('grouptype');
$groupnav = '';
$groupsecond = $_G['cache']['grouptype']['second'];
if($forum['type'] == 'sub') {
$secondtype = !empty($groupsecond[$forum['fup']]) ? $groupsecond[$forum['fup']] : array();
} else {
$secondtype = !empty($groupsecond[$forum['fid']]) ? $groupsecond[$forum['fid']] : array();
}
$firstid = !empty($secondtype) ? $secondtype['fup'] : (!empty($forum['fup']) ? $forum['fup'] : $forum['fid']);
$firsttype = $_G['cache']['grouptype']['first'][$firstid];
if($firsttype) {
$groupnav = ' <em>&rsaquo;</em> <a href="group.php?gid='.$firsttype['fid'].'">'.$firsttype['name'].'</a>';
}
if($secondtype) {
$groupnav .= ' <em>&rsaquo;</em> <a href="group.php?sgid='.$secondtype['fid'].'">'.$secondtype['name'].'</a>';
}
if($forum['type'] == 'sub') {
$mod_action = $_GET['mod'] == 'forumdisplay' || $_GET['mod'] == 'viewthread' ? 'mod=forumdisplay&action=list' : 'mod=group';
$groupnav .= ($groupnav ? ' <em>&rsaquo;</em> ' : '').'<a href="forum.php?'.$mod_action.'&fid='.$forum['fid'].'">'.$forum['name'].'</a>';
}
return array('nav' => $groupnav, 'first' => $firsttype, 'second' => $secondtype);
}
function get_viewedgroup() {
$groupviewed_list = $list = array();
$groupviewed = getcookie('groupviewed');
$groupviewed = $groupviewed ? explode(',', $groupviewed) : array();
if($groupviewed) {
$query = C::t('forum_forum')->fetch_all_info_by_fids($groupviewed);
foreach($query as $row) {
$icon = get_groupimg($row['icon'], 'icon');
$list[$row['fid']] = array('fid' => $row['fid'], 'name' => $row['name'], 'icon' => $icon, 'membernum' => $row['membernum']);
}
}
foreach($groupviewed as $fid) {
$groupviewed_list[$fid] = $list[$fid];
}
return $groupviewed_list;
}
function getgroupthread($fid, $type, $timestamp = 0, $num = 10) {
$typearray = array('replies', 'views', 'dateline', 'lastpost', 'digest', 'comments');
$type = in_array($type, $typearray) ? $type : '';
$groupthreadlist = array();
if($type) {
$dateline = $lastpost = $digest = null;
if($timestamp && in_array($type, array('dateline', 'lastpost'))) {
if($type == 'dateline') {
$dateline = TIMESTAMP - $timestamp;
} else {
$lastpost = TIMESTAMP - $timestamp;
}
}
if($type == 'digest') {
$digest = 0;
$type = 'dateline';
}
foreach(C::t('forum_thread')->fetch_all_group_thread_by_fid_displayorder($fid, 0, $dateline, $lastpost, $digest, $type, 0, $num) as $thread) {
$groupthreadlist[$thread['tid']]['tid'] = $thread['tid'];
$groupthreadlist[$thread['tid']]['subject'] = $thread['subject'];
$groupthreadlist[$thread['tid']]['special'] = $thread['special'];
$groupthreadlist[$thread['tid']]['closed'] = $thread['closed'];
$groupthreadlist[$thread['tid']]['dateline'] = dgmdate($thread['dateline'], 'd');
$groupthreadlist[$thread['tid']]['author'] = $thread['author'];
$groupthreadlist[$thread['tid']]['authorid'] = $thread['authorid'];
$groupthreadlist[$thread['tid']]['views'] = $thread['views'];
$groupthreadlist[$thread['tid']]['replies'] = $thread['replies'];
$groupthreadlist[$thread['tid']]['comments'] = $thread['comments'];
$groupthreadlist[$thread['tid']]['lastpost'] = dgmdate($thread['lastpost'], 'u');
$groupthreadlist[$thread['tid']]['lastposter'] = $thread['lastposter'];
$groupthreadlist[$thread['tid']]['lastposterenc'] = rawurlencode($thread['lastposter']);
}
}
return $groupthreadlist;
}
function getgroupcache($fid, $typearray = array(), $timestamp = 0, $num = 10, $privacy = 0, $force = 0) {
$groupcache = array();
if(!$force) {
$query = C::t('forum_groupfield')->fetch_all_group_cache($fid, $typearray, $privacy);
foreach($query as $group) {
$groupcache[$group['type']] = dunserialize($group['data']);
$groupcache[$group['type']]['dateline'] = $group['dateline'];
}
}
$cachetimearray = array('replies' => 3600, 'views' => 3600, 'dateline' => 900, 'lastpost' => 3600, 'digest' => 86400, 'ranking' => 86400, 'activityuser' => 3600);
$userdataarray = array('activityuser' => 'lastupdate', 'newuserlist' => 'joindateline');
foreach($typearray as $type) {
if(empty($groupcache[$type]) || (!empty($cachetimearray[$type]) && TIMESTAMP - $groupcache[$type]['dateline'] > $cachetimearray[$type])) {
if($type == 'ranking') {
$groupcache[$type]['data'] = getgroupranking($fid, $groupcache[$type]['data']['today']);
} elseif(in_array($type, array('activityuser', 'newuserlist'))) {
$num = $type == 'activityuser' ? 50 : 8;
$groupcache[$type]['data'] = C::t('forum_groupuser')->groupuserlist($fid, $userdataarray[$type], $num, '', "AND level>'0'");
} else {
$groupcache[$type]['data'] = getgroupthread($fid, $type, $timestamp, $num);
}
if(!$force && $fid) {
C::t('forum_groupfield')->insert(array('fid' => $fid, 'dateline' => TIMESTAMP, 'type' => $type, 'data' => serialize($groupcache[$type])), false, true);
}
}
}
return $groupcache;
}
function getgroupranking($fid = '', $nowranking = '') {
$topgroup = $rankingdata = $topyesterday = array();
$ranking = 1;
$query = C::t('forum_forum')->fetch_all_group_for_ranking();
foreach($query as $group) {
$topgroup[$group['fid']] = $ranking++;
}
if($fid && $topgroup) {
$rankingdata['yesterday'] = intval($nowranking);
$rankingdata['today'] = intval($topgroup[$fid]);
$rankingdata['trend'] = $rankingdata['yesterday'] ? grouptrend($rankingdata['yesterday'], $rankingdata['today']) : 0;
$topgroup = $rankingdata;
}
return $topgroup;
}
function grouponline($fid, $getlist = '') {
$fid = intval($fid);
if(empty($getlist)) {
$onlinemember = (array)C::app()->session->count_by_fid($fid);
$onlinemember['count'] = $onlinemember ? intval($onlinemember) : 0;
} else {
$onlinemember = array('count' => 0, 'list' => array());
$onlinemember['list'] = C::app()->session->fetch_all_by_fid($fid);
$onlinemember['count'] = count($onlinemember['list']);
}
return $onlinemember;
}
function grouptrend($yesterday, $today) {
$trend = $yesterday - $today;
return $trend;
}
function write_groupviewed($fid) {
$fid = intval($fid);
if($fid) {
$groupviewed_limit = 8;
$groupviewed = getcookie('groupviewed');
if(!strexists(",$groupviewed,", ",$fid,")) {
$groupviewed = $groupviewed ? explode(',', $groupviewed) : array();
$groupviewed[] = $fid;
if(count($groupviewed) > $groupviewed_limit) {
array_shift($groupviewed);
}
dsetcookie('groupviewed', implode(',', $groupviewed), 86400);
}
}
}
function update_groupmoderators($fid) {
if(empty($fid)) return false;
$moderators = C::t('forum_groupuser')->groupuserlist($fid, 'level_join', 0, 0, array('level' => array('1', '2')), array('username', 'level'));
if(!empty($moderators)) {
C::t('forum_forumfield')->update($fid, array('moderators' => serialize($moderators)));
return $moderators;
} else {
return array();
}
}
function update_usergroups($uids) {
global $_G;
if(empty($uids)) return '';
if(!is_array($uids)) $uids = array($uids);
foreach($uids as $uid) {
$groups = $grouptype = $usergroups = array();
$fids = C::t('forum_groupuser')->fetch_all_fid_by_uids($uid);
$query = C::t('forum_forum')->fetch_all_info_by_fids($fids);
foreach($query as $group) {
$groups[$group['fid']] = $group['name'];
$typegroup[$group['fup']][] = $group['fid'];
}
if(!empty($typegroup)) {
$fups = array_keys($typegroup);
$query = C::t('forum_forum')->fetch_all_info_by_fids($fups);
foreach($query as $fup) {
$grouptype[$fup['fid']] = array('fid' => $fup['fid'], 'fup' => $fup['fup'], 'name' => $fup['name']);
$grouptype[$fup['fid']]['groups'] = implode(',', $typegroup[$fup['fid']]);
}
$usergroups = array('groups' => $groups, 'grouptype' => $grouptype);
if(!empty($usergroups)) {
$setarr = array();
$member = C::t('common_member_field_forum')->fetch($uid);
$attentiongroups = $member['attentiongroup'];
if($attentiongroups) {
$attentiongroups = explode(',', $attentiongroups);
$updateattention = 0;
foreach($attentiongroups as $key => $val) {
if(empty($usergroups['groups'][$val])) {
unset($attentiongroups[$key]);
$updateattention = 1;
}
}
if($updateattention) {
$setarr['attentiongroup'] = implode(',', $attentiongroups);
C::t('common_member_field_forum')->update($uid, $setarr);
}
$_G['member']['attentiongroup'] = implode(',', $attentiongroups);
}
}
} else {
}
}
return $usergroups;
}
?>

View File

@@ -0,0 +1,56 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_grouplog.php 30465 2012-05-30 04:10:03Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function updategroupcreditlog($fid, $uid) {
global $_G;
if(empty($fid) || empty($uid)) {
return false;
}
$today = date('Ymd', TIMESTAMP);
$updategroupcredit = getcookie('groupcredit_'.$fid);
if($updategroupcredit < $today) {
$status = C::t('forum_groupcreditslog')->check_logdate($fid, $uid, $today);
if(empty($status)) {
C::t('forum_forum')->update_commoncredits($fid);
C::t('forum_groupcreditslog')->insert(array('fid' => $fid, 'uid' => $uid, 'logdate' => $today), false, true);
if(empty($_G['forum']) || empty($_G['forum']['level'])) {
$forum = C::t('forum_forum')->fetch($fid);
$forum = array('name' => $forum['name'], 'level' => $forum['level'], 'commoncredits' => $forum['commoncredits']);
} else {
$_G['forum']['commoncredits'] ++;
$forum = &$_G['forum'];
}
if(empty($_G['grouplevels'])) {
loadcache('grouplevels');
}
$grouplevel = $_G['grouplevels'][$forum['level']];
if($grouplevel['type'] == 'default' && !($forum['commoncredits'] >= $grouplevel['creditshigher'] && $forum['commoncredits'] < $grouplevel['creditslower'])) {
$levelinfo = C::t('forum_grouplevel')->fetch_by_credits($forum['commoncredits']);
$levelid = $levelinfo['levelid'];
if(!empty($levelid)) {
C::t('forum_forum')->update_group_level($levelid, $fid);
$query = C::t('forum_forumfield')->fetch($fid);
$groupfounderuid = $query['founderuid'];
notification_add($groupfounderuid, 'system', 'grouplevel_update', array(
'groupname' => '<a href="forum.php?mod=group&fid='.$fid.'">'.$forum['name'].'</a>',
'newlevel' => $_G['grouplevels'][$levelid]['leveltitle'],
'from_id' => 0,
'from_idtype' => 'changeusergroup'
));
}
}
}
dsetcookie('groupcredit_'.$fid, $today, 86400);
}
}

View File

@@ -0,0 +1,632 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_home.php 36284 2016-12-12 00:47:50Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function getstr($string, $length = 0, $in_slashes=0, $out_slashes=0, $bbcode=0, $html=0) {
global $_G;
$string = trim($string);
$sppos = strpos($string, chr(0).chr(0).chr(0));
if($sppos !== false) {
$string = substr($string, 0, $sppos);
}
if($in_slashes) {
$string = dstripslashes($string);
}
$string = preg_replace("/\[hide=?\d*\](.*?)\[\/hide\]/is", '', $string);
if($html < 0) {
$string = preg_replace("/(\<[^\<]*\>|\r|\n|\s|\[.+?\])/is", ' ', $string);
} elseif ($html == 0) {
$string = dhtmlspecialchars($string);
}
if($length) {
$string = cutstr($string, $length);
}
if($bbcode) {
require_once DISCUZ_ROOT.'./source/class/class_bbcode.php';
$bb = & bbcode::instance();
$string = $bb->bbcode2html($string, $bbcode);
}
if($out_slashes) {
$string = daddslashes($string);
}
return trim($string);
}
function obclean() {
ob_end_clean();
if (getglobal('config/output/gzip') && function_exists('ob_gzhandler')) {
ob_start('ob_gzhandler');
} else {
ob_start();
}
}
function dreaddir($dir, $extarr=array()) {
$dirs = array();
if($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if(!empty($extarr) && is_array($extarr)) {
if(in_array(strtolower(fileext($file)), $extarr)) {
$dirs[] = $file;
}
} else if($file != '.' && $file != '..') {
$dirs[] = $file;
}
}
closedir($dh);
}
return $dirs;
}
function url_implode($gets) {
$arr = array();
foreach ($gets as $key => $value) {
if($value) {
$arr[] = $key.'='.urlencode($value);
}
}
return implode('&', $arr);
}
function ckstart($start, $perpage) {
global $_G;
$_G['setting']['maxpage'] = $_G['setting']['maxpage'] ? $_G['setting']['maxpage'] : 100;
$maxstart = $perpage*intval($_G['setting']['maxpage']);
if($start < 0 || ($maxstart > 0 && $start >= $maxstart)) {
showmessage('length_is_not_within_the_scope_of');
}
}
function getspace($uid) {
return getuserbyuid($uid);
}
function ckprivacy($key, $privace_type) {
global $_G, $space;
$var = "home_ckprivacy_{$key}_{$privace_type}";
if(isset($_G[$var])) {
return $_G[$var];
}
space_merge($space, 'field_home');
$result = false;
if($_G['adminid'] == 1) {
$result = true;
} else {
if($privace_type == 'feed') {
if(!empty($space['privacy'][$privace_type][$key])) {
$result = true;
}
} elseif($space['self']){
$result = true;
} else {
if(empty($space['privacy'][$privace_type][$key])) {
$result = true;
} elseif ($space['privacy'][$privace_type][$key] == 1) {
include_once libfile('function/friend');
if(friend_check($space['uid'])) {
$result = true;
}
} elseif ($space['privacy'][$privace_type][$key] == 3) {
$result = in_array($_G['groupid'], array(4, 5, 6, 7)) ? false : true;
}
}
}
$_G[$var] = $result;
return $result;
}
function app_ckprivacy($privacy) {
global $_G, $space;
$var = "home_app_ckprivacy_{$privacy}";
if(isset($_G[$var])) {
return $_G[$var];
}
$result = false;
switch ($privacy) {
case 0:
$result = true;
break;
case 1:
include_once libfile('function/friend');
if(friend_check($space['uid'])) {
$result = true;
}
break;
case 2:
break;
case 3:
if($space['self']) {
$result = true;
}
break;
case 4:
break;
case 5:
break;
default:
$result = true;
break;
}
$_G[$var] = $result;
return $result;
}
function formatsize($size) {
$prec=3;
$size = round(abs($size));
$units = array(0=>" B ", 1=>" KB", 2=>" MB", 3=>" GB", 4=>" TB");
if ($size==0) return str_repeat(" ", $prec)."0$units[0]";
$unit = min(4, floor(log($size)/log(2)/10));
$size = $size * pow(2, -10*$unit);
$digi = $prec - 1 - floor(log($size)/log(10));
$size = round($size * pow(10, $digi)) * pow(10, -$digi);
return $size.$units[$unit];
}
function ckfriend($touid, $friend, $target_ids='') {
global $_G;
if(empty($_G['uid'])) return $friend?false:true;
if($touid == $_G['uid'] || $_G['adminid'] == 1) return true;
$var = 'home_ckfriend_'.md5($touid.'_'.$friend.'_'.$target_ids);
if(isset($_G[$var])) return $_G[$var];
$_G[$var] = false;
switch ($friend) {
case 0:
$_G[$var] = true;
break;
case 1:
include_once libfile('function/friend');
if(friend_check($touid)) {
$_G[$var] = true;
}
break;
case 2:
if($target_ids) {
$target_ids = explode(',', $target_ids);
if(in_array($_G['uid'], $target_ids)) $_G[$var] = true;
}
break;
case 3:
break;
case 4:
$_G[$var] = true;
break;
default:
break;
}
return $_G[$var];
}
function ckfollow($followuid) {
global $_G;
if(empty($_G['uid'])) return false;
$var = 'home_follow_'.$_G['uid'].'_'.$followuid;
if(isset($_G[$var])) return $_G[$var];
$_G[$var] = false;
$follow = C::t('home_follow')->fetch_status_by_uid_followuid($_G['uid'], $followuid);
if(isset($follow[$_G['uid']])) {
$_G[$var] = true;
}
return $_G[$var];
}
function sub_url($url, $length) {
if(strlen($url) > $length) {
$url = str_replace(array('%3A', '%2F'), array(':', '/'), rawurlencode($url));
$url = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3));
}
return $url;
}
function space_domain($space) {
global $_G;
if($_G['setting']['allowspacedomain'] && $_G['setting']['domain']['root']['home']) {
space_merge($space, 'field_home');
if($space['domain']) {
$space['domainurl'] = $_G['scheme'].'://'.$space['domain'].'.'.$_G['setting']['domain']['root']['home'];
}
}
if(!empty($_G['setting']['domain']['app']['home'])) {
$space['domainurl'] = $_G['scheme'].'://'.$_G['setting']['domain']['app']['home'].'/?'.$space['uid'];
} elseif(empty($space['domainurl'])) {
$space['domainurl'] = $_G['siteurl'].'?'.$space['uid'];
}
return $space['domainurl'];
}
function g_name($groupid) {
global $_G;
echo $_G['cache']['usergroups'][$groupid]['grouptitle'];
}
function g_color($groupid) {
global $_G;
if(empty($_G['cache']['usergroups'][$groupid]['color'])) {
echo '';
} else {
echo ' style="color:'.$_G['cache']['usergroups'][$groupid]['color'].';"';
}
}
function mob_perpage($perpage) {
global $_G;
$newperpage = isset($_GET['perpage'])?intval($_GET['perpage']):0;
if($_G['mobile'] && $newperpage>0 && $newperpage<500) {
$perpage = $newperpage;
}
return $perpage;
}
function ckicon_uid($feed) {
global $_G, $space;
space_merge($space, 'field_home');
$filter_icon = empty($space['privacy']['filter_icon'])?array():array_keys($space['privacy']['filter_icon']);
if($filter_icon && (in_array($feed['icon'].'|0', $filter_icon) || in_array($feed['icon'].'|'.$feed['uid'], $filter_icon))) {
return false;
}
return true;
}
function sarray_rand($arr, $num=1) {
$r_values = array();
if($arr && count($arr) > $num) {
if($num > 1) {
$r_keys = array_rand($arr, $num);
foreach ($r_keys as $key) {
$r_values[$key] = $arr[$key];
}
} else {
$r_key = array_rand($arr, 1);
$r_values[$r_key] = $arr[$r_key];
}
} else {
$r_values = $arr;
}
return $r_values;
}
function getsiteurl() {
global $_G;
return $_G['siteurl'];
}
function pic_get($filepath, $type, $thumb, $remote, $return_thumb=1, $hastype = '') {
global $_G;
$url = $filepath;
if($return_thumb && $thumb) $url = getimgthumbname($url);
if($remote > 1 && $type == 'album') {
$remote -= 2;
$type = 'forum';
}
$type = $hastype ? '' : $type.'/';
return ($remote?$_G['setting']['ftp']['attachurl']:$_G['setting']['attachurl']).$type.$url;
}
function pic_cover_get($pic, $picflag) {
global $_G;
$type = 'album';
if($picflag > 2) {
$picflag = $picflag - 2;
$type = 'forum';
}
if($picflag == 1) {
$url = $_G['setting']['attachurl'].$type.'/'.$pic;
} elseif ($picflag == 2) {
$url = $_G['setting']['ftp']['attachurl'].$type.'/'.$pic;
} else {
$url = $pic;
}
return $url;
}
function pic_delete($pic, $type, $thumb, $remote) {
global $_G;
if($remote > 1 && $type == 'album') {
$remote -= 2;
$type = 'forum';
return true;
}
if($remote) {
ftpcmd('delete', $type.'/'.$pic);
if($thumb) {
ftpcmd('delete', $type.'/'.getimgthumbname($pic));
}
ftpcmd('close');
} else {
@unlink($_G['setting']['attachdir'].'/'.$type.'/'.$pic);
if($thumb) {
@unlink($_G['setting']['attachdir'].'/'.$type.'/'.getimgthumbname($pic));
}
}
return true;
}
function pic_upload($FILES, $type='album', $thumb_width=0, $thumb_height=0, $thumb_type=2) {
$upload = new discuz_upload();
$result = array('pic'=>'', 'thumb'=>0, 'remote'=>0);
$upload->init($FILES, $type);
if($upload->error()) {
return array();
}
$upload->save();
if($upload->error()) {
return array();
}
$result['pic'] = $upload->attach['attachment'];
if($thumb_width && $thumb_height) {
require_once libfile('class/image');
$image = new image();
if($image->Thumb($upload->attach['target'], '', $thumb_width, $thumb_height, $thumb_type)) {
$result['thumb'] = 1;
}
}
if(ftpperm($upload->attach['ext'], $upload->attach['size'])) {
if(ftpcmd('upload', $type.'/'.$upload->attach['attachment'])) {
if($result['thumb']) {
ftpcmd('upload', $type.'/'.getimgthumbname($upload->attach['attachment']));
}
ftpcmd('close');
$result['remote'] = 1;
} else {
if(getglobal('setting/ftp/mirror')) {
@unlink($upload->attach['target']);
@unlink(getimgthumbname($upload->attach['target']));
return array();
}
}
}
return $result;
}
function member_count_update($uid, $counts) {
global $_G;
$setsqls = array();
foreach ($counts as $key => $value) {
if($key == 'credit') {
if($_G['setting']['creditstransextra'][6]) {
$key = 'extcredits'.intval($_G['setting']['creditstransextra'][6]);
} elseif ($_G['setting']['creditstrans']) {
$key = 'extcredits'.intval($_G['setting']['creditstrans']);
} else {
continue;
}
}
$setsqls[$key] = $value;
}
if($setsqls) {
updatemembercount($uid, $setsqls);
}
}
function getdefaultdoing() {
global $_G;
$result = array();
$key = 0;
if(($result = C::t('common_setting')->fetch_setting('defaultdoing'))) {
$_G['setting']['defaultdoing'] = explode("\r\n", $result);
$key = rand(0, count($_G['setting']['defaultdoing'])-1);
} else {
$_G['setting']['defaultdoing'] = array(lang('space', 'doing_you_can'));
}
return $_G['setting']['defaultdoing'][$key];
}
function getuserdiydata($space) {
global $_G;
if(empty($_G['blockposition'])) {
$userdiy = getuserdefaultdiy();
if (!empty($space['blockposition'])) {
$blockdata = dunserialize($space['blockposition']);
foreach ((array)$blockdata as $key => $value) {
if ($key == 'parameters') {
foreach ((array)$value as $k=>$v) {
if (!empty($v)) $userdiy[$key][$k] = $v;
}
} else {
if (!empty($value)) $userdiy[$key] = $value;
}
}
}
$_G['blockposition'] = $userdiy;
}
return $_G['blockposition'];
}
function getuserdefaultdiy() {
$defaultdiy = array(
'currentlayout' => '1:2:1',
'block' => array(
'frame`frame1' => array(
'attr' => array('name'=>'frame1'),
'column`frame1_left' => array(
'block`profile' => array('attr' => array('name'=>'profile')),
'block`statistic' => array('attr' => array('name'=>'statistic')),
'block`album' => array('attr' => array('name'=>'album')),
'block`doing' => array('attr' => array('name'=>'doing'))
),
'column`frame1_center' => array(
'block`personalinfo' => array('attr' => array('name'=>'personalinfo')),
'block`feed' => array('attr' => array('name'=>'feed')),
'block`share' => array('attr' => array('name'=>'share')),
'block`blog' => array('attr' => array('name'=>'blog')),
'block`thread' => array('attr' => array('name'=>'thread')),
'block`wall' => array('attr' => array('name'=>'wall'))
),
'column`frame1_right' => array(
'block`friend' => array('attr' => array('name'=>'friend')),
'block`visitor' => array('attr' => array('name'=>'visitor')),
'block`group' => array('attr' => array('name'=>'group'))
)
)
),
'parameters' => array(
'blog' => array('showmessage' => 150, 'shownum' => 6),
'doing' => array('shownum' => 15),
'album' => array('shownum' => 8),
'thread' => array('shownum' => 10),
'share' => array('shownum' => 10),
'friend' => array('shownum' => 18),
'group' => array('shownum' => 12),
'visitor' => array('shownum' => 18),
'wall' => array('shownum' => 16),
'feed' => array('shownum' => 16),
),
'nv' => array(
'nvhidden' => 0,
'items' => array(),
'banitems' => array(),
),
);
return $defaultdiy;
}
function getonlinemember($uids) {
global $_G;
if ($uids && is_array($uids) && empty($_G['ols'])) {
$_G['ols'] = array();
foreach(C::app()->session->fetch_all_by_uid($uids) as $value) {
if(!$value['invisible']) {
$_G['ols'][$value['uid']] = $value['lastactivity'];
}
}
}
}
function getfollowfeed($uid, $viewtype, $archiver = false, $start = 0, $perpage = 0) {
global $_G;
$list = array();
if(isset($_G['follwusers'][$uid])) {
$list['user'] = $_G['follwusers'][$uid];
} else {
if($viewtype == 'follow') {
$list['user'] = C::t('home_follow')->fetch_all_following_by_uid($uid);
$list['user'][$uid] = array('uid' => $uid);
} elseif($viewtype == 'special') {
$list['user'] = C::t('home_follow')->fetch_all_following_by_uid($uid, 1);
}
if(!empty($list['user'])) {
$_G['follwusers'][$uid] = $list['user'];
}
}
$uids = in_array($viewtype, array('other', 'self')) ? $uid : array_keys($list['user']);
if(!empty($uids) || in_array($viewtype, array('other', 'self'))) {
$list['feed'] = C::t('home_follow_feed')->fetch_all_by_uid($uids, $archiver, $start, $perpage);
if($list['feed']) {
$list['content'] = C::t('forum_threadpreview')->fetch_all(C::t('home_follow_feed')->get_tids());
if(!$_G['group']['allowgetattach'] || !$_G['group']['allowgetimage']) {
foreach($list['content'] as $key => $feed) {
if(!$_G['group']['allowgetimage']) {
$list['content'][$key]['content'] = preg_replace("/[ \t]*\<li\>\<img id=\"aimg_(.+?)\".*?\>[ \t]*\<\/li\>/is", '', $feed['content']);
}
if(!$_G['group']['allowgetattach']) {
$list['content'][$key]['content'] = preg_replace("/[ \t]*\<li\>\<a href=\"(.+?)\" id=\"attach_(.+?)\".*?\>.*?\<\/a\>[ \t]*\<\/li\>/is", '', $feed['content']);
}
}
}
$list['threads'] = C::t('forum_thread')->fetch_all_by_tid(C::t('home_follow_feed')->get_tids());
if (!empty($list['threads']) && is_array($list['threads'])) {
foreach ($list['threads'] as $key => $thread) {
if (empty($_G['setting']['followforumid']) || $thread['fid'] != $_G['setting']['followforumid']) {
if (!empty($list['content'][$key]['content'])) {
$list['content'][$key]['content'] = preg_replace('#onclick="changefeed\([^"]+\)"\s*style="cursor:\s*pointer;"#is', '', $list['content'][$key]['content']);
}
}
}
}
}
}
return $list;
}
function getthread() {
$threads = array();
foreach(C::t('home_follow_feed')->get_ids() as $idtype => $ids) {
if($idtype == 'thread') {
$threads = C::t('forum_thread')->fetch_all_by_tid($ids);
}
}
return $threads;
}
function show_view() {
global $_G, $space;
if(!$space['self'] && $_G['uid']) {
$visitor = C::t('home_visitor')->fetch_by_uid_vuid($space['uid'], $_G['uid']);
$is_anonymous = empty($_G['cookie']['anonymous_visit_'.$_G['uid'].'_'.$space['uid']]) ? 0 : 1;
if(empty($visitor['dateline'])) {
$setarr = array(
'uid' => $space['uid'],
'vuid' => $_G['uid'],
'vusername' => $is_anonymous ? '' : $_G['username'],
'dateline' => $_G['timestamp']
);
C::t('home_visitor')->insert($setarr, false, true);
show_credit();
} else {
if($_G['timestamp'] - $visitor['dateline'] >= 300) {
C::t('home_visitor')->update_by_uid_vuid($space['uid'], $_G['uid'], array('dateline'=>$_G['timestamp'], 'vusername'=>$is_anonymous ? '' : $_G['username']));
}
if($_G['timestamp'] - $visitor['dateline'] >= 3600) {
show_credit();
}
}
updatecreditbyaction('visit', 0, array(), $space['uid']);
}
}
function show_credit() {
global $_G, $space;
$showinfo = C::t('home_show')->fetch($space['uid']);
if($showinfo['credit'] > 0) {
$showinfo['unitprice'] = intval($showinfo['unitprice']);
if($showinfo['credit'] <= $showinfo['unitprice']) {
notification_add($space['uid'], 'show', 'show_out');
C::t('home_show')->delete($space['uid']);
} else {
C::t('home_show')->update_credit_by_uid($space['uid'], -$showinfo['unitprice']);
}
}
}
?>

View File

@@ -0,0 +1,220 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_importdata.php 33985 2013-09-13 05:45:27Z nemohou $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
function import_smilies() {
$smileyarray = getimportdata('Discuz! Smilies');
$renamed = 0;
if(C::t('forum_imagetype')->count_by_name('smiley', $smileyarray['name'])) {
$smileyarray['name'] .= '_'.random(4);
$renamed = 1;
}
$data = array(
'name' => $smileyarray['name'],
'type' => 'smiley',
'directory' => $smileyarray['directory'],
);
$typeid = C::t('forum_imagetype')->insert($data, true);
foreach($smileyarray['smilies'] as $key => $smiley) {
C::t('common_smiley')->insert(array('type'=>'smiley', 'typeid'=>$typeid, 'displayorder'=>$smiley['displayorder'], 'code'=>'', 'url'=>$smiley['url']));
}
C::t('common_smiley')->update_code_by_typeid($typeid);
updatecache(array('smileytypes', 'smilies', 'smileycodes', 'smilies_js'));
return $renamed;
}
function import_styles($ignoreversion = 1, $dir = '', $restoreid = 0, $updatecache = 1, $validate = 1) {
global $_G, $importtxt, $stylearray;
if(!isset($dir)) {
$stylearrays = array(getimportdata('Discuz! Style'));
} else {
require_once libfile('function/cloudaddons');
if(!$restoreid) {
$dir = str_replace(array('/', '\\'), '', $dir);
$templatedir = DISCUZ_ROOT.'./template/'.$dir;
if($validate) {
cloudaddons_validator($dir.'.template');
}
} else {
$templatedir = DISCUZ_ROOT.$dir;
$dir = basename($dir);
if($validate) {
cloudaddons_validator($dir.'.template');
}
}
$searchdir = dir($templatedir);
$stylearrays = array();
while($searchentry = $searchdir->read()) {
if(substr($searchentry, 0, 13) == 'discuz_style_' && fileext($searchentry) == 'xml') {
$importfile = $templatedir.'/'.$searchentry;
$importtxt = implode('', file($importfile));
$stylearrays[] = getimportdata('Discuz! Style');
}
}
}
foreach($stylearrays as $stylearray) {
if(empty($ignoreversion) && !versioncompatible($stylearray['version'])) {
cpmsg('styles_import_version_invalid', 'action=styles', 'error', array('cur_version' => $stylearray['version'], 'set_version' => $_G['setting']['version']));
}
$styleidnew = 0;
if(!$restoreid) {
$renamed = 0;
if($stylearray['templateid'] != 1) {
$templatedir = DISCUZ_ROOT.'./'.$stylearray['directory'];
if(!is_dir($templatedir)) {
if(!@mkdir($templatedir, 0777)) {
$basedir = dirname($stylearray['directory']);
cpmsg('styles_import_directory_invalid', 'action=styles', 'error', array('basedir' => $basedir, 'directory' => $stylearray['directory']));
}
}
$templateid = C::t('common_template')->get_templateid_by_directory($stylearray['directory']);
if (!$templateid) {
$templateid = C::t('common_template')->get_templateid($stylearray['tplname']);
}
if(!$templateid) {
$templateid = C::t('common_template')->insert(array(
'name' => $stylearray['tplname'],
'directory' => $stylearray['directory'],
'copyright' => $stylearray['copyright']
), true);
}
} else {
$templateid = 1;
}
if(C::t('common_style')->check_stylename($stylearray['name'])) {
$renamed = 1;
$styleinfo = C::t('common_style')->fetch_by_stylename_templateid($stylearray['name']);
if(!empty($styleinfo['styleid'])) {
if($styleinfo['templateid'] != $templateid) {
$template = C::t('common_template')->fetch_by_templateid($styleinfo['templateid']);
if (empty($template)) {
C::t('common_style')->update($styleinfo['styleid'], array('templateid' => $templateid), true);
$styleidnew = $styleinfo['styleid'];
}else{
$styleinfo = C::t('common_style')->fetch_by_stylename_templateid($stylearray['name'], $templateid);
if(!empty($styleinfo['styleid'])) {
$styleidnew = $styleinfo['styleid'];
}else{
$styleidnew = C::t('common_style')->insert(array('name' => $stylearray['name'], 'templateid' => $templateid), true);
}
}
}else{
$styleidnew = $styleinfo['styleid'];
}
}
} else {
$styleidnew = C::t('common_style')->insert(array('name' => $stylearray['name'], 'templateid' => $templateid), true);
}
} else {
$styleidnew = $restoreid;
C::t('common_stylevar')->delete_by_styleid($styleidnew);
}
if($styleidnew) {
$stylevars = array();
$result = C::t('common_stylevar')->fetch_all_by_styleid($styleidnew);
if(is_array($result) && !empty($result)) {
foreach($result as $style) {
$stylevars[$style['variable']] = $style['substitute'];
}
}
foreach($stylearray['style'] as $variable => $substitute) {
if(!isset($stylevars[$variable])) {
$substitute = @dhtmlspecialchars($substitute);
C::t('common_stylevar')->insert(array('styleid' => $styleidnew, 'variable' => $variable, 'substitute' => $substitute));
}
}
}
}
if($dir) {
cloudaddons_installlog($dir.'.template');
cloudaddons_clear('template', $dir);
}
if($updatecache) {
updatecache('styles');
updatecache('setting');
}
return $renamed;
}
function import_block($xmlurl, $clientid, $xmlkey = '', $signtype = '', $ignoreversion = 1, $update = 0) {
global $_G, $importtxt;
$_GET['importtype'] = $_GET['importtxt'] = '';
$xmlurl = strip_tags($xmlurl);
$clientid = strip_tags($clientid);
$xmlkey = strip_tags($xmlkey);
$parse = parse_url($xmlurl);
if(!empty($parse['host'])) {
$queryarr = explode('&', $parse['query']);
$para = array();
foreach($queryarr as $value){
$k = $v = '';
list($k,$v) = explode('=', $value);
if(!empty($k) && !empty($v)) {
$para[$k] = $v;
}
}
$para['clientid'] = $clientid;
$para['op'] = 'getconfig';
$para['charset'] = CHARSET;
$signurl = create_sign_url($para, $xmlkey, $signtype);
$pos = strpos($xmlurl, '?');
$pos = $pos === false ? strlen($xmlurl) : $pos;
$signurl = substr($xmlurl, 0, $pos).'?'.$signurl;
$importtxt = @dfsockopen($signurl);
} else {
$importtxt = @implode('', file($xmlurl));
}
$blockarrays = getimportdata('Discuz! Block', 0);
if(empty($blockarrays['name']) || empty($blockarrays['fields']) || empty($blockarrays['getsetting'])) {
cpmsg(cplang('import_data_typeinvalid').cplang($importtxt), '', 'error');
}
require_once libfile('function/cloudaddons');
if(empty($ignoreversion) && !versioncompatible($blockarrays['version'])) {
cpmsg(cplang('blockxml_import_version_invalid'), '', 'error', array('cur_version' => $blockarrays['version'], 'set_version' => $_G['setting']['version']));
}
$data = array(
'name' => dhtmlspecialchars($blockarrays['name']),
'version' => dhtmlspecialchars($blockarrays['version']),
'url' => $xmlurl,
'clientid' => $clientid,
'key' => $xmlkey,
'signtype' => !empty($signtype) ? 'MD5' : '',
'data' => serialize($blockarrays)
);
if(!$update) {
C::t('common_block_xml')->insert($data);
} else {
C::t('common_block_xml')->update($update, $data);
}
}
function create_sign_url($para, $key = '', $signtype = ''){
ksort($para);
$url = http_build_query($para);
if(!empty($signtype) && strtoupper($signtype) == 'MD5') {
$sign = md5(urldecode($url).$key);
$url = $url.'&sign='.$sign;
} else {
$url = $url.'&sign='.$key;
}
return $url;
}
?>

View File

@@ -0,0 +1,247 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_magic.php 27757 2012-02-14 03:08:15Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function checkmagicperm($perms, $id) {
$id = $id ? intval($id) : '';
return strexists("\t".trim($perms)."\t", "\t".trim($id)."\t") || !$perms;
}
function getmagic($magicid, $magicnum, $weight, $totalweight, $uid, $maxmagicsweight, $force = 0) {
if($weight + $totalweight > $maxmagicsweight && !$force) {
showmessage('magics_weight_range_invalid', '', array('less' => $weight + $totalweight - $maxmagicsweight));
} else {
if(C::t('common_member_magic')->count_magic($uid, $magicid)) {
C::t('common_member_magic')->increase($uid, $magicid, array('num' => $magicnum), false, true);
} else {
C::t('common_member_magic')->insert(array(
'uid' => $uid,
'magicid' => $magicid,
'num' => $magicnum
));
}
}
}
function getmagicweight($uid, $magicarray) {
$totalweight = 0;
$query = C::t('common_member_magic')->fetch_all_magic($uid);
foreach($query as $magic) {
$totalweight += $magicarray[$magic['magicid']]['weight'] * $magic['num'];
}
return $totalweight;
}
function getpostinfo($id, $type, $colsarray = '') {
global $_G;
$type = in_array($type, array('tid', 'pid', 'blogid')) && !empty($type) ? $type : 'tid';
switch($type) {
case 'tid':
$info = C::t('forum_thread')->fetch_by_tid_displayorder($id, 0);
break;
case 'pid':
$info = C::t('forum_post')->fetch_post($_G['tid'], $id);
if($info && $info['invisible'] == 0) {
$thread = C::t('forum_thread')->fetch_thread($_G['tid']);
$thread['thread_author'] = $thread['author'];
$thread['thread_authorid'] = $thread['authorid'];
$thread['thread_status'] = $thread['status'];
$thread['thread_replycredit'] = $thread['replycredit'];
$info = array_merge($thread, $info);
} else {
$info = array();
}
break;
case 'blogid':
$info = C::t('home_blog')->fetch($id);
if(!($info && $info['status'] == '0')) {
$info = array();
}
break;
}
if(empty($info)) {
showmessage('magics_target_nonexistence');
} else {
return daddslashes($info, 1);
}
}
function getuserinfo($username) {
$member = C::t('common_member')->fetch_by_username($username);
if(!$member) {
showmessage('magics_target_member_nonexistence');
} else {
return daddslashes($member, 1);
}
}
function givemagic($username, $magicid, $magicnum, $totalnum, $totalprice, $givemessage, $magicarray) {
global $_G;
$member = C::t('common_member')->fetch_by_username($username);
if(!$member) {
showmessage('magics_target_member_nonexistence');
} elseif($member['uid'] == $_G['uid']) {
showmessage('magics_give_myself');
}
$member = array_merge(C::t('common_usergroup_field')->fetch($member['groupid']), $member);
$totalweight = getmagicweight($member['uid'], $magicarray);
$magicweight = $magicarray[$magicid]['weight'] * $magicnum;
if($magicarray[$magicid]['weight'] && $magicweight + $totalweight > $member['maxmagicsweight']) {
$num = floor(($member['maxmagicsweight'] - $totalweight) / $magicarray[$magicid]['weight']);
$num = max(0, $num);
showmessage('magics_give_weight_range_invalid', '', array('num' => $num));
}
getmagic($magicid, $magicnum, $magicweight, $totalweight, $member['uid'], $member['maxmagicsweight']);
notification_add($member['uid'], 'magic', 'magics_receive', array('magicname' => $magicarray[$magicid]['name'], 'msg' => $givemessage));
updatemagiclog($magicid, '3', $magicnum, $magicarray[$magicid]['price'], $member['uid']);
if(empty($totalprice)) {
usemagic($magicid, $totalnum, $magicnum);
showmessage('magics_give_succeed', 'home.php?mod=magic&action=mybox', array('toname' => $username, 'num' => $magicnum, 'magicname' => $magicarray[$magicid]['name']));
}
}
function magicthreadmod($tid) {
foreach(C::t('forum_threadmod')->fetch_all_by_tid_magicid($tid) as $threadmod) {
if(!$threadmod['magicid'] && in_array($threadmod['action'], array('CLS', 'ECL', 'STK', 'EST', 'HLT', 'EHL'))) {
showmessage('magics_mod_forbidden');
}
}
}
function magicshowsetting($setname, $varname, $value, $type = 'radio', $width = '20%') {
$check = array();
echo '<p class="mtm mbn">'.$setname.'</p>';
if($type == 'radio') {
$value ? $check['true'] = 'checked="checked"' : $check['false'] = 'checked="checked"';
echo "<input type=\"radio\" name=\"$varname\" class=\"pr\" value=\"1\" {$check['true']} /> ".lang('core', 'yes')." &nbsp; &nbsp; \n".
"<input type=\"radio\" name=\"$varname\" class=\"pr\" value=\"0\" {$check['false']} /> ".lang('core', 'no')."\n";
} elseif($type == 'text') {
echo "<input type=\"text\" name=\"$varname\" class=\"px p_fre\" value=\"".dhtmlspecialchars($value)."\" size=\"12\" autocomplete=\"off\" />\n";
} elseif($type == 'hidden') {
echo "<input type=\"hidden\" name=\"$varname\" value=\"".dhtmlspecialchars($value)."\" />\n";
} else {
echo $type;
}
}
function magicshowtips($tips) {
echo '<p>'.$tips.'</p>';
}
function magicshowtype($type = '') {
if($type != 'bottom') {
echo '<p>';
} else {
echo '</p>';
}
}
function usemagic($magicid, $totalnum, $num = 1) {
global $_G;
if($totalnum == $num) {
C::t('common_member_magic')->delete_magic($_G['uid'], $magicid);
} else {
C::t('common_member_magic')->increase($_G['uid'], $magicid, array('num' => -$num));
}
}
function updatemagicthreadlog($tid, $magicid, $action = 'MAG', $expiration = 0, $extra = 0) {
global $_G;
$_G['username'] = !$extra ? $_G['username'] : '';
$data = array(
'tid' => $tid,
'uid' => $_G['uid'],
'magicid' => $magicid,
'username' => $_G['username'],
'dateline' => $_G['timestamp'],
'expiration' => $expiration,
'action' => $action,
'status' => 1
);
C::t('forum_threadmod')->insert($data);
}
function updatemagiclog($magicid, $action, $amount, $price, $targetuid = 0, $idtype = '', $targetid = 0) {
global $_G;
list($price, $credit) = explode('|', $price);
$data = array(
'uid' => $_G['uid'],
'magicid' => $magicid,
'action' => $action,
'dateline' => $_G['timestamp'],
'amount' => $amount,
'price' => $price,
'credit' => $credit,
'idtype' => $idtype,
'targetid' => $targetid,
'targetuid' => $targetuid
);
C::t('common_magiclog')->insert($data);
}
function magic_check_idtype($id, $idtype) {
global $_G;
include_once libfile('function/spacecp');
$value = '';
$tablename = gettablebyidtype($idtype);
if($tablename) {
$value = C::t($tablename)->fetch_by_id_idtype($id);
if($value['uid'] != $_G['uid']) {
$value = null;
}
}
if(empty($value)) {
showmessage('magicuse_bad_object');
}
return $value;
}
function magic_peroid($magic, $uid) {
global $_G;
if($magic['useperoid']) {
$dateline = 0;
if($magic['useperoid'] == 1) {
$dateline = TIMESTAMP - (TIMESTAMP + $_G['setting']['timeoffset'] * 3600) % 86400;
} elseif($magic['useperoid'] == 4) {
$dateline = TIMESTAMP - 86400;
} elseif($magic['useperoid'] == 2) {
$dateline = TIMESTAMP - 86400 * 7;
} elseif($magic['useperoid'] == 3) {
$dateline = TIMESTAMP - 86400 * 30;
}
$num = C::t('common_magiclog')->count_by_uid_magicid_action_dateline($uid, $magic['magicid'], 2, $dateline);
return $magic['usenum'] - $num;
} else {
return true;
}
}
?>

View File

@@ -0,0 +1,302 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_mail.php 33961 2013-09-06 07:39:33Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
set_time_limit(0);
function sendmail($toemail, $subject, $message = '', $from = '') {
global $_G;
if(preg_match("/@m\.invalid$/i", $toemail)){
return false;
}
if(!is_array($_G['setting']['mail'])) {
$_G['setting']['mail'] = dunserialize($_G['setting']['mail']);
}
if($_G['setting']['mail']['mailsend'] == 4) {
$etype = explode(':', $_G['setting']['mail']['plugin']);
$codefile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/mailsend/mailsend_'.$etype[1].'.php';
include_once $codefile;
$class = 'mailsend_'.$etype[1];
$code = new $class();
return $code->sendmail($toemail, $subject, $message, $from);
}
$_G['setting']['mail']['server'] = $_G['setting']['mail']['port'] = $_G['setting']['mail']['auth'] = $_G['setting']['mail']['from'] = $_G['setting']['mail']['auth_username'] = $_G['setting']['mail']['auth_password'] = '';
if($_G['setting']['mail']['mailsend'] != 1) {
$smtpnum = count($_G['setting']['mail']['smtp']);
if($smtpnum) {
$rid = rand(0, $smtpnum-1);
$maildomain = explode('@', $toemail);
foreach(array_column($_G['setting']['mail']['smtp'], 'precedence') as $smtpkey => $smtpval) {
$ismail = in_array($maildomain[1], explode(',', $smtpval));
if($ismail !== false) {
$rid = $smtpkey;
break;
}
}
$smtp = $_G['setting']['mail']['smtp'][$rid];
$_G['setting']['mail']['server'] = $smtp['server'];
$_G['setting']['mail']['port'] = $smtp['port'];
$_G['setting']['mail']['timeout'] = isset($smtp['timeout']) && strlen($smtp['timeout']) ? intval($smtp['timeout']) : 30;
$_G['setting']['mail']['auth'] = $smtp['auth'] ? 1 : 0;
$_G['setting']['mail']['from'] = $smtp['from'];
$_G['setting']['mail']['auth_username'] = $smtp['auth_username'];
$_G['setting']['mail']['auth_password'] = $smtp['auth_password'];
}
}
ob_start();
if(is_array($subject) && $subject['tpl']) {
$tpl = $subject['tpl'];
$var = $subject['var'];
$subject = lang('email/template', $tpl.'_subject', (!empty($subject['svar']) ? $subject['svar'] : array()));
include template('email/'.$tpl);
} else {
include template('email/default');
}
$message = ob_get_contents();
ob_end_clean();
$message = preg_replace("/href\=\"(?!(http|https)\:\/\/)(.+?)\"/i", 'href="'.$_G['setting']['securesiteurl'].'\\2"', $message);
$mailusername = isset($_G['setting']['mail']['mailusername']) ? $_G['setting']['mail']['mailusername'] : 1;
$_G['setting']['mail']['port'] = $_G['setting']['mail']['port'] ? $_G['setting']['mail']['port'] : 25;
$_G['setting']['mail']['mailsend'] = $_G['setting']['mail']['mailsend'] ? $_G['setting']['mail']['mailsend'] : 1;
if($_G['setting']['mail']['mailsend'] == 3) {
$email_from = empty($from) ? $_G['setting']['adminemail'] : $from;
} else {
$email_from = $from == '' ? '=?'.CHARSET.'?B?'.base64_encode($_G['setting']['sitename'])."?= <".$_G['setting']['adminemail'].">" : (preg_match('/^(.+?) \<(.+?)\>$/',$from, $mats) ? '=?'.CHARSET.'?B?'.base64_encode($mats[1])."?= <$mats[2]>" : $from);
}
$email_to = preg_match('/^(.+?) \<(.+?)\>$/',$toemail, $mats) ? ($mailusername ? '=?'.CHARSET.'?B?'.base64_encode($mats[1])."?= <$mats[2]>" : $mats[2]) : $toemail;
$email_subject = '=?'.CHARSET.'?B?'.base64_encode(preg_replace("/[\r|\n]/", '', '['.$_G['setting']['sitename'].'] '.$subject)).'?=';
$email_message = chunk_split(base64_encode(str_replace("\n", "\r\n", str_replace("\r", "\n", str_replace("\r\n", "\n", str_replace("\n\r", "\r", $message))))));
$host = parse_url('http://'.$_SERVER['HTTP_HOST'], PHP_URL_HOST);
$version = $_G['setting']['version'];
if($_G['setting']['mail']['mailsend'] == 1) {
$maildelimiter = $_G['setting']['mail']['maildelimiter'] == 1 ? "\r\n" : ($_G['setting']['mail']['maildelimiter'] == 2 ? "\r" : "\n");
$headers = "From: $email_from{$maildelimiter}X-Mailer: Discuz! $version {$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: text/html; charset=".CHARSET."{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}";
if(function_exists('mail') && @mail($email_to, $email_subject, $email_message, $headers)) {
return true;
}
return false;
} elseif($_G['setting']['mail']['mailsend'] == 2) {
if(!$fp = fsocketopen($_G['setting']['mail']['server'], $_G['setting']['mail']['port'], $errno, $errstr, $_G['setting']['mail']['timeout'])) {
runlog('SMTP', "({$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']}) CONNECT - Unable to connect to the SMTP server", 0);
return false;
}
stream_set_blocking($fp, true);
stream_set_timeout($fp, $_G['setting']['mail']['timeout']);
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != '220') {
fputs($fp, "QUIT\r\n");
runlog('SMTP', "{$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']} CONNECT - $lastmessage", 0);
return false;
}
while(1) {
if(substr($lastmessage, 3, 1) != '-' || empty($lastmessage)) {
break;
}
$lastmessage = fgets($fp, 512);
}
fputs($fp, ($_G['setting']['mail']['auth'] ? 'EHLO' : 'HELO')." $host\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) {
fputs($fp, "QUIT\r\n");
runlog('SMTP', "({$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']}) HELO/EHLO - $lastmessage", 0);
return false;
}
while(1) {
if(substr($lastmessage, 3, 1) != '-' || empty($lastmessage)) {
break;
}
$lastmessage = fgets($fp, 512);
}
if($_G['setting']['mail']['auth']) {
fputs($fp, "AUTH LOGIN\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 334) {
fputs($fp, "QUIT\r\n");
runlog('SMTP', "({$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']}) AUTH LOGIN - $lastmessage", 0);
return false;
}
fputs($fp, base64_encode($_G['setting']['mail']['auth_username'])."\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 334) {
fputs($fp, "QUIT\r\n");
runlog('SMTP', "({$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']}) USERNAME - $lastmessage", 0);
return false;
}
fputs($fp, base64_encode($_G['setting']['mail']['auth_password'])."\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 235) {
fputs($fp, "QUIT\r\n");
runlog('SMTP', "({$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']}) PASSWORD - $lastmessage", 0);
return false;
}
$email_from = $_G['setting']['mail']['from'];
}
fputs($fp, "MAIL FROM: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $email_from).">\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 250) {
fputs($fp, "MAIL FROM: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $email_from).">\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 250) {
fputs($fp, "QUIT\r\n");
runlog('SMTP', "({$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']}) MAIL FROM - $lastmessage", 0);
return false;
}
}
fputs($fp, "RCPT TO: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $toemail).">\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 250) {
fputs($fp, "RCPT TO: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $toemail).">\r\n");
$lastmessage = fgets($fp, 512);
fputs($fp, "QUIT\r\n");
runlog('SMTP', "({$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']}) RCPT TO - $lastmessage", 0);
return false;
}
fputs($fp, "DATA\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 354) {
fputs($fp, "QUIT\r\n");
runlog('SMTP', "({$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']}) DATA - $lastmessage", 0);
return false;
}
$timeoffset = $_G['setting']['timeoffset'];
if(function_exists('date_default_timezone_set')) {
@date_default_timezone_set('Etc/GMT'.($timeoffset > 0 ? '-' : '+').(abs($timeoffset)));
}
$maildomain = substr(strrchr($email_from, "@"), 1);
$maildelimiter = "\r\n";
$headers = "From: $email_from{$maildelimiter}X-Mailer: Discuz! $version {$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: text/html; charset=".CHARSET."{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}";
$headers .= 'Message-ID: <'.date('YmdHs').'.'.substr(md5($email_message.microtime()), 0, 6).rand(100000, 999999).'@'.$maildomain.">{$maildelimiter}";
fputs($fp, "Date: ".date('r')."\r\n");
fputs($fp, "To: ".$email_to."\r\n");
fputs($fp, "Subject: ".$email_subject."\r\n");
fputs($fp, $headers."\r\n");
fputs($fp, "\r\n\r\n");
fputs($fp, "$email_message\r\n.\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 250) {
fputs($fp, "QUIT\r\n");
runlog('SMTP', "({$_G['setting']['mail']['server']}:{$_G['setting']['mail']['port']}) END - $lastmessage", 0);
return false;
}
fputs($fp, "QUIT\r\n");
return true;
} elseif($_G['setting']['mail']['mailsend'] == 3) {
ini_set('SMTP', $_G['setting']['mail']['server']);
ini_set('smtp_port', $_G['setting']['mail']['port']);
ini_set('sendmail_from', $email_from);
$maildelimiter = "\r\n";
$headers = "From: $email_from{$maildelimiter}X-Mailer: Discuz! $version {$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: text/html; charset=".CHARSET."{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}";
if(function_exists('mail') && @mail($email_to, $email_subject, $email_message, $headers)) {
return true;
}
return false;
}
}
function sendmail_cron($toemail, $subject, $message) {
global $_G;
if(preg_match("/@m\.invalid$/i", $toemail)){
return false;
}
$toemail = addslashes($toemail);
$value = C::t('common_mailcron')->fetch_all_by_email($toemail, 0, 1);
$value = $value[0];
if($value) {
$cid = $value['cid'];
} else {
$cid = C::t('common_mailcron')->insert(array('email' => $toemail), true);
}
$message = preg_replace("/href\=\"(?!(http|https)\:\/\/)(.+?)\"/i", 'href="'.$_G['setting']['securesiteurl'].'\\1"', $message);
$setarr = array(
'cid' => $cid,
'subject' => $subject,
'message' => $message,
'dateline' => $_G['timestamp']
);
C::t('common_mailqueue')->insert($setarr);
return true;
}
function sendmail_touser($touid, $subject, $message, $mailtype='') {
global $_G;
if(empty($_G['setting']['sendmailday'])) return false;
require_once libfile('function/home');
$tospace = getuserbyuid($touid);
if(empty($tospace['email'])) return false;
space_merge($tospace, 'field_home');
space_merge($tospace, 'status');
$acceptemail = $tospace['acceptemail'];
if(!empty($acceptemail[$mailtype]) && $_G['timestamp'] - $tospace['lastvisit'] > $_G['setting']['sendmailday']*86400) {
if(empty($tospace['lastsendmail'])) {
$tospace['lastsendmail'] = $_G['timestamp'];
}
$sendtime = $tospace['lastsendmail'] + $acceptemail['frequency'];
$value = C::t('common_mailcron')->fetch_all_by_touid($touid, 0, 1);
$value = $value[0];
if($value) {
$cid = $value['cid'];
if($value['sendtime'] < $sendtime) $sendtime = $value['sendtime'];
C::t('common_mailcron')->update($cid, array('email' => $tospace['email'], 'sendtime' => $sendtime));
} else {
$cid = C::t('common_mailcron')->insert(array(
'touid' => $touid,
'email' => $tospace['email'],
'sendtime' => $sendtime,
), true);
}
$message = preg_replace("/href\=\"(?!(http|https)\:\/\/)(.+?)\"/i", 'href="'.$_G['setting']['securesiteurl'].'\\1"', $message);
$setarr = array(
'cid' => $cid,
'subject' => $subject,
'message' => $message,
'dateline' => $_G['timestamp']
);
C::t('common_mailqueue')->insert($setarr);
return true;
}
return false;
}
?>

View File

@@ -0,0 +1,319 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_member.php 35030 2014-10-23 07:43:23Z laoguozhang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function userlogin($username, $password, $questionid, $answer, $loginfield = 'username', $ip = '') {
$return = array();
if($loginfield == 'uid' && getglobal('setting/uidlogin')) {
$isuid = 1;
} elseif($loginfield == 'email') {
$isuid = 2;
} elseif($loginfield == 'auto') {
$isuid = 3;
} elseif($loginfield == 'secmobile' && getglobal('setting/secmobilelogin')) {
$isuid = 4;
} else {
$isuid = 0;
}
if(!function_exists('uc_user_login')) {
loaducenter();
}
if($isuid == 3) {
if(!strcmp(dintval($username), $username) && getglobal('setting/uidlogin')) {
$return['ucresult'] = uc_user_login($username, $password, 1, 1, $questionid, $answer, $ip, 1);
} elseif(isemail($username)) {
$return['ucresult'] = uc_user_login($username, $password, 2, 1, $questionid, $answer, $ip, 1);
} elseif(preg_match('/^(\d{1,12}|\d{1,3}-\d{1,12})$/', $username) && getglobal('setting/secmobilelogin')) {
$username = strpos($username, '-') === false ? (getglobal('setting/smsdefaultcc') . '-' . $username) : $username;
$return['ucresult'] = uc_user_login($username, $password, 4, 1, $questionid, $answer, $ip, 1);
}
if($return['ucresult'][0] <= 0 && $return['ucresult'][0] != -3) {
$return['ucresult'] = uc_user_login(addslashes($username), $password, 0, 1, $questionid, $answer, $ip);
}
} else {
if($isuid == 4) {
$username = strpos($username, '-') === false ? (getglobal('setting/smsdefaultcc') . '-' . $username) : $username;
}
$return['ucresult'] = uc_user_login(addslashes($username), $password, $isuid, 1, $questionid, $answer, $ip);
}
$tmp = array();
$duplicate = '';
list($tmp['uid'], $tmp['username'], $tmp['password'], $tmp['email'], $duplicate) = $return['ucresult'];
$return['ucresult'] = $tmp;
if($duplicate && $return['ucresult']['uid'] > 0 || $return['ucresult']['uid'] <= 0) {
$return['status'] = 0;
return $return;
}
$member = getuserbyuid($return['ucresult']['uid'], 1);
if(!$member || empty($member['uid'])) {
$return['status'] = -1;
return $return;
}
$return['member'] = $member;
$return['status'] = 1;
if($member['_inarchive']) {
C::t('common_member_archive')->move_to_master($member['uid']);
}
if($member['email'] != $return['ucresult']['email']) {
C::t('common_member')->update($return['ucresult']['uid'], array('email' => $return['ucresult']['email']));
}
return $return;
}
function setloginstatus($member, $cookietime) {
global $_G;
$_G['uid'] = intval($member['uid']);
$_G['username'] = $member['username'];
$_G['adminid'] = $member['adminid'];
$_G['groupid'] = $member['groupid'];
$_G['formhash'] = formhash();
$_G['session']['invisible'] = getuserprofile('invisible');
$_G['member'] = $member;
loadcache('usergroup_'.$_G['groupid']);
C::app()->session->isnew = true;
C::app()->session->updatesession();
dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}", 'ENCODE'), $cookietime, 1, true);
dsetcookie('loginuser');
dsetcookie('activationauth');
dsetcookie('pmnum');
include_once libfile('function/stat');
updatestat('login', 1);
if(defined('IN_MOBILE')) {
updatestat('mobilelogin', 1);
}
if($_G['setting']['connect']['allow'] && $_G['member']['conisbind']) {
updatestat('connectlogin', 1);
}
$rule = updatecreditbyaction('daylogin', $_G['uid']);
if(!$rule['updatecredit']) {
checkusergroup($_G['uid']);
}
}
function logincheck($username) {
global $_G;
$return = 0;
$username = trim($username);
loaducenter();
if(function_exists('uc_user_logincheck')) {
$return = uc_user_logincheck(addslashes($username), $_G['clientip']);
} else {
$login = C::t('common_failedlogin')->fetch_ip($_G['clientip']);
$return = (!$login || (TIMESTAMP - $login['lastupdate'] > 900)) ? 5 : max(0, 5 - $login['count']);
if(!$login) {
C::t('common_failedlogin')->insert(array(
'ip' => $_G['clientip'],
'count' => 0,
'lastupdate' => TIMESTAMP
), false, true);
} elseif(TIMESTAMP - $login['lastupdate'] > 900) {
C::t('common_failedlogin')->insert(array(
'ip' => $_G['clientip'],
'count' => 0,
'lastupdate' => TIMESTAMP
), false, true);
C::t('common_failedlogin')->delete_old(901);
}
}
return $return;
}
function loginfailed($username) {
global $_G;
loaducenter();
if(function_exists('uc_user_logincheck')) {
return;
}
C::t('common_failedlogin')->update_failed($_G['clientip']);
}
function failedipcheck($numiptry, $timeiptry) {
global $_G;
if(!$numiptry) {
return false;
}
return $numiptry <= C::t('common_failedip')->get_ip_count($_G['clientip'], TIMESTAMP - $timeiptry);
}
function failedip() {
global $_G;
C::t('common_failedip')->insert_ip($_G['clientip']);
}
function getinvite() {
global $_G;
if($_G['setting']['regstatus'] == 1) return array();
$result = array();
$cookies = empty($_G['cookie']['invite_auth']) ? array() : explode(',', $_G['cookie']['invite_auth']);
$cookiecount = count($cookies);
$_GET['invitecode'] = trim($_GET['invitecode']);
if($cookiecount == 2 || $_GET['invitecode']) {
$id = intval($cookies[0]);
$code = trim($cookies[1]);
if($_GET['invitecode']) {
$invite = C::t('common_invite')->fetch_by_code($_GET['invitecode']);
$code = trim($_GET['invitecode']);
} else {
$invite = C::t('common_invite')->fetch($id);
}
if(!empty($invite)) {
if($invite['code'] == $code && empty($invite['fuid']) && (empty($invite['endtime']) || $_G['timestamp'] < $invite['endtime'])) {
$result['uid'] = $invite['uid'];
$result['id'] = $invite['id'];
}
}
} elseif($cookiecount == 3) {
$uid = intval($cookies[0]);
$code = trim($cookies[1]);
$invite_code = helper_invite::generate_key($uid);
if($code === $invite_code) {
$member = getuserbyuid($uid);
if($member) {
$usergroup = C::t('common_usergroup')->fetch($member['groupid']);
if(!$usergroup['allowinvite'] || $usergroup['inviteprice'] > 0) return array();
} else {
return array();
}
$result['uid'] = $uid;
}
}
if($result['uid']) {
$member = getuserbyuid($result['uid']);
$result['username'] = $member['username'];
} else {
dsetcookie('invite_auth', '');
}
return $result;
}
function replacesitevar($string, $replaces = array()) {
global $_G;
$sitevars = array(
'{sitename}' => $_G['setting']['sitename'],
'{bbname}' => $_G['setting']['bbname'],
'{time}' => dgmdate(TIMESTAMP, 'Y-n-j H:i'),
'{adminemail}' => $_G['setting']['adminemail'],
'{username}' => $_G['member']['username'],
'{myname}' => $_G['member']['username']
);
$replaces = array_merge($sitevars, $replaces);
return str_replace(array_keys($replaces), array_values($replaces), $string);
}
function clearcookies() {
global $_G;
foreach($_G['cookie'] as $k => $v) {
if($k != 'widthauto') {
dsetcookie($k);
}
}
$_G['uid'] = $_G['adminid'] = 0;
$_G['username'] = $_G['member']['password'] = '';
}
function crime($fun) {
if(!$fun) {
return false;
}
include_once libfile('class/member');
$crimerecord = & crime_action_ctl::instance();
$arg_list = func_get_args();
if($fun == 'recordaction') {
list(, $uid, $action, $reason) = $arg_list;
return $crimerecord->$fun($uid, $action, $reason);
} elseif($fun == 'getactionlist') {
list(, $uid) = $arg_list;
return $crimerecord->$fun($uid);
} elseif($fun == 'getcount') {
list(, $uid, $action) = $arg_list;
return $crimerecord->$fun($uid, $action);
} elseif($fun == 'search') {
list(, $action, $username, $operator, $starttime, $endtime, $reason, $start, $limit) = $arg_list;
return $crimerecord->$fun($action, $username, $operator, $starttime, $endtime, $reason, $start, $limit);
} elseif($fun == 'actions') {
return crime_action_ctl::$actions;
}
return false;
}
function checkfollowfeed() {
global $_G;
if($_G['uid']) {
$lastcheckfeed = 0;
if(!empty($_G['cookie']['lastcheckfeed'])) {
$time = explode('|', $_G['cookie']['lastcheckfeed']);
if($time[0] == $_G['uid']) {
$lastcheckfeed = $time[1];
}
}
if(!$lastcheckfeed) {
$lastcheckfeed = getuserprofile('lastactivity');
}
dsetcookie('lastcheckfeed', $_G['uid'].'|'.TIMESTAMP, 31536000);
$followuser = C::t('home_follow')->fetch_all_following_by_uid($_G['uid']);
$uids = array_keys($followuser);
if(!empty($uids)) {
$count = C::t('home_follow_feed')->count_by_uid_dateline($uids, $lastcheckfeed);
if($count) {
notification_add($_G['uid'], 'follow', 'member_follow', array('count' => $count, 'from_id'=>$_G['uid'], 'from_idtype' => 'follow'), 1);
}
}
}
dsetcookie('checkfollow', 1, 30);
}
function checkemail($email) {
global $_G;
$email = strtolower(trim($email));
if(strlen($email) > 255) {
showmessage('profile_email_illegal', '', array(), array('handle' => false));
}
if($_G['setting']['regmaildomain']) {
$maildomainexp = '/('.str_replace("\r\n", '|', preg_quote(trim($_G['setting']['maildomainlist']), '/')).')$/i';
if($_G['setting']['regmaildomain'] == 1 && !preg_match($maildomainexp, $email)) {
showmessage('profile_email_domain_illegal', '', array(), array('handle' => false));
} elseif($_G['setting']['regmaildomain'] == 2 && preg_match($maildomainexp, $email)) {
showmessage('profile_email_domain_illegal', '', array(), array('handle' => false));
}
}
loaducenter();
$ucresult = uc_user_checkemail($email);
if($ucresult == -4) {
showmessage('profile_email_illegal', '', array(), array('handle' => false));
} elseif($ucresult == -5) {
showmessage('profile_email_domain_illegal', '', array(), array('handle' => false));
} elseif($ucresult == -6) {
showmessage('profile_email_duplicate', '', array(), array('handle' => false));
}
}
function make_getpws_sign($uid, $idstring) {
global $_G;
$link = "member.php?mod=getpasswd&uid={$uid}&id={$idstring}";
return dsign($link);
}
?>

View File

@@ -0,0 +1,254 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_message.php 32580 2013-02-22 03:40:28Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function dshowmessage($message, $url_forward = '', $values = array(), $extraparam = array(), $custom = 0) {
global $_G, $show_message;
$_G['messageparam'] = func_get_args();
if(empty($_G['inhookscript']) && defined('CURMODULE')) {
hookscript(CURMODULE, $_G['basescript'], 'messagefuncs', array('param' => $_G['messageparam']));
}
if(!empty($extraparam['break'])) {
return;
}
$_G['inshowmessage'] = true;
$param = array(
'header' => false,
'timeout' => null,
'refreshtime' => null,
'closetime' => null,
'locationtime' => null,
'alert' => null,
'return' => false,
'redirectmsg' => 0,
'msgtype' => 1,
'showmsg' => true,
'showdialog' => false,
'login' => false,
'handle' => false,
'extrajs' => '',
'mobileextrajs' => '',
'striptags' => true,
);
$navtitle = lang('core', 'title_board_message');
if($custom) {
$alerttype = 'alert_info';
$show_message = $message;
include template('common/showmessage');
dexit();
}
define('CACHE_FORBIDDEN', TRUE);
$_G['setting']['msgforward'] = @dunserialize($_G['setting']['msgforward']);
$handlekey = $leftmsg = '';
if(defined('IN_MOBILE')) {
unset($extraparam['showdialog']);
unset($extraparam['closetime']);
unset($extraparam['extrajs']);
if ($extraparam['mobileextrajs']) {
$extraparam['extrajs'] = $extraparam['mobileextrajs'];
}
if(!$url_forward && dreferer() && defined('IN_MOBILE') && constant('IN_MOBILE') == 1) {
$url_forward = $referer = dreferer();
}
if(!empty($url_forward) && strpos($url_forward, 'mobile') === false) {
$url_forward_arr = explode("#", $url_forward);
if(strpos($url_forward_arr[0], '?') !== false) {
$url_forward_arr[0] = $url_forward_arr[0].'&mobile='.IN_MOBILE;
} else {
$url_forward_arr[0] = $url_forward_arr[0].'?mobile='.IN_MOBILE;
}
$url_forward = implode("#", $url_forward_arr);
}
}
if(empty($_G['inajax']) && (!empty($_GET['quickforward']) || $_G['setting']['msgforward']['quick'] && empty($extraparam['clean_msgforward']) && $_G['setting']['msgforward']['messages'] && is_array($_G['setting']['msgforward']['messages']) && in_array($message, $_G['setting']['msgforward']['messages']))) {
$param['header'] = true;
}
$_GET['handlekey'] = !empty($_GET['handlekey']) && preg_match('/^\w+$/', $_GET['handlekey']) ? $_GET['handlekey'] : '';
if(!empty($_G['inajax'])) {
$handlekey = $_GET['handlekey'] = !empty($_GET['handlekey']) ? dhtmlspecialchars($_GET['handlekey']) : '';
$param['handle'] = true;
$param['msgtype'] = empty($_GET['ajaxmenu']) && (empty($_POST) || !empty($_GET['nopost'])) ? 2 : 3;
}
if($url_forward) {
$param['timeout'] = true;
if($param['handle'] && !empty($_G['inajax'])) {
$param['showmsg'] = false;
}
}
foreach($extraparam as $k => $v) {
$param[$k] = $v;
}
if(array_key_exists('set', $extraparam)) {
$setdata = array('1' => array('msgtype' => 3));
if($setdata[$extraparam['set']]) {
foreach($setdata[$extraparam['set']] as $k => $v) {
$param[$k] = $v;
}
}
}
$timedefault = intval($param['refreshtime'] === null ? $_G['setting']['msgforward']['refreshtime'] : $param['refreshtime']);
if($param['timeout'] !== null) {
$refreshsecond = !empty($timedefault) ? $timedefault : 3;
$refreshtime = $refreshsecond * 1000;
} else {
$refreshtime = $refreshsecond = 0;
}
if($param['login'] && $_G['uid'] || $url_forward) {
$param['login'] = false;
}
$param['header'] = $url_forward && $param['header'] ? true : false;
if(getgpc('ajaxdata') === 'json') {
$param['header'] = '';
}
if($param['header']) {
header("HTTP/1.1 301 Moved Permanently");
dheader("location: ".str_replace('&amp;', '&', $url_forward));
}
$url_forward_js = addslashes(str_replace('\\', '%27', $url_forward));
if(!empty($param['location']) && !empty($_G['inajax'])) {
include template('common/header_ajax');
echo '<script type="text/javascript" reload="1">window.location.href=\''.$url_forward_js.'\';</script>';
include template('common/footer_ajax');
dexit();
}
$_G['hookscriptmessage'] = $message;
$_G['hookscriptvalues'] = $values;
$vars = explode(':', $message);
if(count($vars) == 2) {
$show_message = lang('plugin/'.$vars[0], $vars[1], $values);
} else {
$show_message = lang('message', $message, $values);
}
if(isset($_GET['ajaxdata'])) {
if($_GET['ajaxdata'] === 'json') {
helper_output::json(array('message' => $show_message, 'data' => $values));
} else if($_GET['ajaxdata'] === 'html') {
helper_output::html($show_message);
}
}
if($_G['connectguest']) {
$param['login'] = false;
$param['alert'] = 'info';
if (defined('IN_MOBILE')) {
if ($message == 'postperm_login_nopermission_mobile') {
$show_message = lang('plugin/qqconnect', 'connect_register_mobile_bind_error');
}
$show_message = str_replace(lang('forum/misc', 'connectguest_message_mobile_search'), lang('forum/misc', 'connectguest_message_mobile_replace'), $show_message);
} else {
$show_message = str_replace(lang('forum/misc', 'connectguest_message_search'), lang('forum/misc', 'connectguest_message_replace'), $show_message);
}
if ($message == 'group_nopermission') {
$show_message = lang('plugin/qqconnect', 'connectguest_message_complete_or_bind');
}
}
if($param['msgtype'] == 2 && $param['login']) {
dheader('location: member.php?mod=logging&action=login&handlekey='.$handlekey.'&infloat=yes&inajax=yes&guestmessage=yes');
}
if(strpos($message, 'nopermission') > 0) {
if ($_G['member']['groupid'] == 8 && $_G['setting']['regverify'] == 1) {
$show_message .= lang('message', 'nopermission_email');
} else if ($_G['member']['groupid'] == 8 && $_G['setting']['regverify'] == 2) {
$show_message .= lang('message', 'nopermission_verify');
}
}
$show_jsmessage = str_replace("'", "\\'", $param['striptags'] ? strip_tags($show_message) : $show_message);
if((!$param['showmsg'] || !empty($param['showid'])) && !defined('IN_MOBILE') ) {
$show_message = '';
}
$allowreturn = !$param['timeout'] && !$url_forward && !$param['login'] || $param['return'] ? true : false;
if($param['alert'] === null) {
$alerttype = $url_forward ? (preg_match('/\_(succeed|success)$/', $message) ? 'alert_right' : 'alert_info') : ($allowreturn ? 'alert_error' : 'alert_info');
} else {
$alerttype = 'alert_'.$param['alert'];
}
$extra = '';
if(!empty($param['showid'])) {
$extra .= 'if($(\''.$param['showid'].'\')) {$(\''.$param['showid'].'\').innerHTML = \''.$show_jsmessage.'\';}';
}
if($param['handle']) {
$valuesjs = $comma = $subjs = '';
foreach($values as $k => $v) {
$v = daddslashes($v);
if(is_array($v)) {
$subcomma = '';
foreach ($v as $subk => $subv) {
$subjs .= $subcomma.'\''.$subk.'\':\''.$subv.'\'';
$subcomma = ',';
}
$valuesjs .= $comma.'\''.$k.'\':{'.$subjs.'}';
} else {
$valuesjs .= $comma.'\''.$k.'\':\''.$v.'\'';
}
$comma = ',';
}
$valuesjs = '{'.$valuesjs.'}';
if($url_forward) {
$extra .= 'if(typeof succeedhandle_'.$handlekey.'==\'function\') {succeedhandle_'.$handlekey.'(\''.$url_forward_js.'\', \''.$show_jsmessage.'\', '.$valuesjs.');}';
} else {
$extra .= 'if(typeof errorhandle_'.$handlekey.'==\'function\') {errorhandle_'.$handlekey.'(\''.$show_jsmessage.'\', '.$valuesjs.');}';
}
}
if($param['closetime'] !== null) {
$param['closetime'] = $param['closetime'] === true ? $timedefault : $param['closetime'];
}
if($param['locationtime'] !== null) {
$param['locationtime'] = $param['locationtime'] === true ? $timedefault : $param['locationtime'];
}
if($handlekey) {
if($param['showdialog']) {
$modes = array('alert_error' => 'alert', 'alert_right' => 'right', 'alert_info' => 'notice');
$extra .= 'hideWindow(\''.$handlekey.'\');showDialog(\''.$show_jsmessage.'\', \''.$modes[$alerttype].'\', null, '.($param['locationtime'] !== null ? 'function () { window.location.href =\''.$url_forward_js.'\'; }' : 'null').', 0, null, null, null, null, '.($param['closetime'] ? $param['closetime'] : 'null').', '.($param['locationtime'] ? $param['locationtime'] : 'null').');';
$param['closetime'] = null;
$st = '';
if($param['showmsg']) {
$show_message = '';
}
}
if($param['closetime'] !== null) {
$extra .= 'setTimeout("hideWindow(\''.$handlekey.'\')", '.($param['closetime'] * 1000).');';
}
} else {
$st = $param['locationtime'] !== null ?'setTimeout("window.location.href =\''.$url_forward_js.'\';", '.($param['locationtime'] * 1000).');' : '';
}
if(!$extra && $param['timeout'] && !defined('IN_MOBILE')) {
$extra .= 'setTimeout("window.location.href =\''.$url_forward_js.'\';", '.$refreshtime.');';
}
$show_message .= $extra ? '<script type="text/javascript" reload="1">'.$extra.$st.'</script>' : '';
$show_message .= $param['extrajs'] ? $param['extrajs'] : '';
include template('common/showmessage');
dexit();
}
?>

View File

@@ -0,0 +1,327 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_misc.php 33487 2013-06-21 08:00:39Z kamichen $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function convertip($ip) {
return ip::convert($ip);
}
function procthread($thread, $timeformat = 'd') {
global $_G;
$lastvisit = $_G['member']['lastvisit'];
if(empty($_G['forum_colorarray'])) {
$_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
}
if($thread['closed']) {
$thread['new'] = 0;
if($thread['isgroup'] && $thread['closed'] > 1) {
$thread['folder'] = 'common';
} else {
$thread['folder'] = 'lock';
}
} else {
$thread['folder'] = 'common';
if($lastvisit < $thread['lastpost'] && (empty($_G['cookie']['oldtopics']) || strpos($_G['cookie']['oldtopics'], 'D'.$thread['tid'].'D') === FALSE)) {
$thread['new'] = 1;
$thread['folder'] = 'new';
} else {
$thread['new'] = 0;
}
}
$thread['icon'] = '';
$thread['id'] = random(6, 1);
if(!$thread['forumname']) {
$thread['forumname'] = empty($_G['cache']['forums'][$thread['fid']]['name']) ? 'Forum' : $_G['cache']['forums'][$thread['fid']]['name'];
}
$thread['dateline'] = dgmdate($thread['dateline'], $timeformat);
$thread['lastpost'] = dgmdate($thread['lastpost'], 'u');
$thread['lastposterenc'] = rawurlencode($thread['lastposter']);
if($thread['replies'] > $thread['views']) {
$thread['views'] = $thread['replies'];
}
$postsnum = $thread['special'] ? $thread['replies'] : $thread['replies'] + 1;
$pagelinks = '';
if($postsnum > $_G['ppp']) {
if($_G['setting']['domain']['app']['forum'] || $_G['setting']['domain']['app']['default']) {
$domain = $_G['scheme'].'://'.($_G['setting']['domain']['app']['forum'] ? $_G['setting']['domain']['app']['forum'] : ($_G['setting']['domain']['app']['default'] ? $_G['setting']['domain']['app']['default'] : '')).'/';
} else {
$domain = $_G['siteurl'];
}
$posts = $postsnum;
$topicpages = ceil($posts / $_G['ppp']);
for($i = 1; $i <= $topicpages; $i++) {
if(!is_array($_G['setting']['rewritestatus']) || !in_array('forum_viewthread', $_G['setting']['rewritestatus'])) {
$pagelinks .= '<a href="forum.php?mod=viewthread&tid='.$thread['tid'].'&page='.$i.($_GET['from'] ? '&from='.$_GET['from'] : '').'" target="_blank">'.$i.'</a> ';
} else {
$pagelinks .= '<a href="'.rewriteoutput('forum_viewthread', 1, $domain, $thread['tid'], $i, '', '').'" target="_blank">'.$i.'</a> ';
}
if($i == 6) {
$i = $topicpages + 1;
}
}
if($topicpages > 6) {
if(!is_array($_G['setting']['rewritestatus']) || !in_array('forum_viewthread', $_G['setting']['rewritestatus'])) {
$pagelinks .= ' .. <a href="forum.php?mod=viewthread&tid='.$thread['tid'].'&page='.$topicpages.'" target="_blank">'.$topicpages.'</a> ';
} else {
$pagelinks .= ' .. <a href="'.rewriteoutput('forum_viewthread', 1, $domain, $thread['tid'], $topicpages, '', '').'" target="_blank">'.$topicpages.'</a> ';
}
}
$thread['multipage'] = '... '.$pagelinks;
} else {
$thread['multipage'] = '';
}
if($thread['highlight']) {
$string = sprintf('%02d', $thread['highlight']);
$stylestr = sprintf('%03b', $string[0]);
$thread['highlight'] = 'style="';
$thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
$thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
$thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
$thread['highlight'] .= $string[1] ? 'color: '.$_G['forum_colorarray'][$string[1]] : '';
$thread['highlight'] .= '"';
} else {
$thread['highlight'] = '';
}
return $thread;
}
function modlog($thread, $action) {
global $_G;
$reason = $_GET['reason'];
writelog('modslog', dhtmlspecialchars("{$_G['timestamp']}\t{$_G['username']}\t{$_G['adminid']}\t{$_G['clientip']}\t".$_G['forum']['fid']."\t".$_G['forum']['name']."\t{$thread['tid']}\t{$thread['subject']}\t$action\t$reason\t".$_G['toforum']['fid']."\t".$_G['toforum']['name']));
}
function checkreasonpm() {
global $_G;
$reason = trim(strip_tags($_GET['reason']));
if(($_G['group']['reasonpm'] == 1 || $_G['group']['reasonpm'] == 3) && !$reason) {
showmessage('admin_reason_invalid');
}
return $reason;
}
function sendreasonpm($var, $item, $notevar, $notictype = '', $system = 1) {
global $_G;
if(!empty($var['authorid']) && $var['authorid'] != $_G['uid']) {
if(!empty($notevar['modaction'])) {
$notevar['from_id'] = 0;
$notevar['from_idtype'] = 'moderate_'.$notevar['modaction'];
$notevar['modaction'] = lang('forum/modaction', $notevar['modaction']);
}
empty($notictype) && $notictype = 'system';
notification_add($var['authorid'], $notictype, $item, $notevar, $system);
}
}
function modreasonselect($isadmincp = 0, $reasionkey = 'modreasons') {
global $_G;
if(!isset($_G['cache'][$reasionkey]) || !is_array($_G['cache'][$reasionkey])) {
loadcache(array($reasionkey, 'stamptypeid'));
}
$select = '';
if(!empty($_G['cache'][$reasionkey])) {
foreach($_G['cache'][$reasionkey] as $reason) {
$select .= !$isadmincp ? ($reason ? '<li>'.$reason.'</li>' : '<li>--------</li>') : ($reason ? '<option value="'.dhtmlspecialchars($reason).'">'.$reason.'</option>' : '<option></option>');
}
}
if($select) {
return $select;
} else {
return false;
}
}
function acpmsg($message, $url = '', $type = '', $extra = '') {
if(defined('IN_ADMINCP')) {
!defined('CPHEADER_SHOWN') && cpheader();
cpmsg($message, $url, $type, $extra);
} else {
showmessage($message, $url, $extra);
}
}
function savebanlog($username, $origgroupid, $newgroupid, $expiration, $reason) {
global $_G;
if($_G['setting']['plugins']['func'][HOOKTYPE]['savebanlog']) {
$param = func_get_args();
hookscript('savebanlog', 'global', 'funcs', array('param' => $param), 'savebanlog');
}
writelog('banlog', dhtmlspecialchars("{$_G['timestamp']}\t{$_G['member']['username']}\t{$_G['groupid']}\t{$_G['clientip']}\t$username\t$origgroupid\t$newgroupid\t$expiration\t$reason"));
}
function clearlogstring($str) {
if(!empty($str)) {
if(!is_array($str)) {
$str = dhtmlspecialchars(trim($str));
$str = str_replace(array("\t", "\r\n", "\n", " ", " "), ' ', $str);
} else {
foreach ($str as $key => $val) {
$str[$key] = clearlogstring($val);
}
}
}
return $str;
}
function implodearray($array, $skip = array()) {
$return = '';
if(is_array($array) && !empty($array)) {
foreach ($array as $key => $value) {
if(empty($skip) || !in_array($key, $skip, true)) {
if(is_array($value)) {
$return .= "$key={".implodearray($value, $skip)."}; ";
} elseif(!empty($value)) {
$return .= "$key=$value; ";
} else {
$return .= '';
}
}
}
}
return $return;
}
function undeletethreads($tids) {
global $_G;
if($_G['setting']['plugins']['func'][HOOKTYPE]['undeletethreads']) {
$param = func_get_args();
hookscript('undeletethreads', 'global', 'funcs', array('param' => $param), 'undeletethreads');
}
$threadsundel = 0;
if($tids && is_array($tids)) {
$arrtids = $tids;
$tids = '\''.implode('\',\'', $tids).'\'';
$tuidarray = $ruidarray = $fidarray = $posttabletids = array();
foreach(C::t('forum_thread')->fetch_all_by_tid($arrtids) as $thread) {
$posttabletids[$thread['posttableid'] ? $thread['posttableid'] : 0][] = $thread['tid'];
}
foreach($posttabletids as $posttableid => $ptids) {
foreach(C::t('forum_post')->fetch_all_by_tid($posttableid, $ptids, false) as $post) {
if($post['first']) {
$tuidarray[$post['fid']][] = $post['authorid'];
} else {
$ruidarray[$post['fid']][] = $post['authorid'];
}
if(!in_array($post['fid'], $fidarray)) {
$fidarray[] = $post['fid'];
}
}
C::t('forum_post')->update_by_tid($posttableid, $ptids, array('invisible' => '0'), true);
}
if($tuidarray) {
foreach($tuidarray as $fid => $tuids) {
updatepostcredits('+', $tuids, 'post', $fid);
}
}
if($ruidarray) {
foreach($ruidarray as $fid => $ruids) {
updatepostcredits('+', $ruids, 'reply', $fid);
}
}
$threadsundel = C::t('forum_thread')->update($arrtids, array('displayorder'=>0, 'moderated'=>1));
updatemodlog($tids, 'UDL');
updatemodworks('UDL', $threadsundel);
foreach($fidarray as $fid) {
updateforumcount($fid);
}
}
return $threadsundel;
}
function recyclebinpostdelete($deletepids, $posttableid = false) {
if(empty($deletepids)) {
return 0;
}
require_once libfile('function/delete');
return deletepost($deletepids, 'pid', true, $posttableid);
}
function recyclebinpostundelete($undeletepids, $posttableid = false) {
global $_G;
if($_G['setting']['plugins']['func'][HOOKTYPE]['recyclebinpostundelete']) {
$param = func_get_args();
hookscript('recyclebinpostundelete', 'global', 'funcs', array('param' => $param), 'recyclebinpostundelete');
}
$postsundel = 0;
if(empty($undeletepids)) {
return $postsundel;
}
loadcache('posttableids');
$posttableids = !empty($_G['cache']['posttableids']) ? ($posttableid !== false && in_array($posttableid, $_G['cache']['posttableids']) ? array($posttableid) : $_G['cache']['posttableids']): array('0');
$postarray = $ruidarray = $fidarray = $tidarray = array();
foreach($posttableids as $ptid) {
foreach(C::t('forum_post')->fetch_all_post($ptid, $undeletepids, false) as $post) {
if(!$post['first']) {
$ruidarray[$post['fid']][] = $post['authorid'];
}
$fidarray[$post['fid']] = $post['fid'];
$tidarray[$post['tid']] = $post['tid'];
}
}
if(empty($fidarray)) {
return $postsundel;
}
C::t('forum_post')->update_post($posttableid, $undeletepids, array('invisible' => '0'), true);
include_once libfile('function/post');
if($ruidarray) {
foreach($ruidarray as $fid => $ruids) {
updatepostcredits('+', $ruids, 'reply', $fid);
}
}
foreach($tidarray as $tid) {
updatethreadcount($tid, 1);
}
foreach($fidarray as $fid) {
updateforumcount($fid);
}
return count($undeletepids);
}
function process_ipnotice($ipconverted) {
if(!$ipconverted) {
return '';
}
$ipconverted = substr($ipconverted, 1);
if(strpos($ipconverted, '-') !== false) {
$ipconverted = substr($ipconverted, 0, strpos($ipconverted, '-'));
}
$ipconverted = trim($ipconverted);
return '- '.$ipconverted ;
}
?>

View File

@@ -0,0 +1,511 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_plugin.php 36284 2016-12-12 00:47:50Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
require_once libfile('function/cloudaddons');
function plugininstall($pluginarray, $installtype = '', $available = 0) {
if(!$pluginarray || !$pluginarray['plugin']['identifier']) {
return false;
}
$plugin = C::t('common_plugin')->fetch_by_identifier($pluginarray['plugin']['identifier']);
if($plugin) {
return false;
}
$pluginarray['plugin']['modules'] = dunserialize($pluginarray['plugin']['modules']);
$pluginarray['plugin']['modules']['extra']['installtype'] = $installtype;
if(updatepluginlanguage($pluginarray)) {
$pluginarray['plugin']['modules']['extra']['langexists'] = 1;
}
if(!empty($pluginarray['intro'])) {
if(!empty($pluginarray['intro'])) {
require_once libfile('function/discuzcode');
$pluginarray['plugin']['modules']['extra']['intro'] = discuzcode(strip_tags($pluginarray['intro']), 1, 0);
}
}
if(!empty($pluginarray['uninstallfile'])) {
$pluginarray['plugin']['modules']['extra']['uninstallfile'] = $pluginarray['uninstallfile'];
}
if(!empty($pluginarray['checkfile'])) {
$pluginarray['plugin']['modules']['extra']['checkfile'] = $pluginarray['checkfile'];
}
if(!empty($pluginarray['enablefile'])) {
$pluginarray['plugin']['modules']['extra']['enablefile'] = $pluginarray['enablefile'];
}
if(!empty($pluginarray['disablefile'])) {
$pluginarray['plugin']['modules']['extra']['disablefile'] = $pluginarray['disablefile'];
}
$pluginarray['plugin']['modules'] = serialize($pluginarray['plugin']['modules']);
$data = array();
foreach($pluginarray['plugin'] as $key => $val) {
if($key == 'directory') {
$val .= (!empty($val) && substr($val, -1) != '/') ? '/' : '';
} elseif($key == 'available') {
$val = $available;
}
$data[$key] = $val;
}
$pluginid = C::t('common_plugin')->insert($data, true);
if(is_array($pluginarray['var'])) {
foreach($pluginarray['var'] as $config) {
$data = array('pluginid' => $pluginid);
foreach($config as $key => $val) {
$data[$key] = $val;
}
C::t('common_pluginvar')->insert($data);
}
}
if(!empty($dir) && !empty($pluginarray['importfile'])) {
require_once libfile('function/importdata');
foreach($pluginarray['importfile'] as $importtype => $file) {
if(in_array($importtype, array('smilies', 'styles'))) {
$files = explode(',', $file);
foreach($files as $file) {
if(file_exists($file = DISCUZ_ROOT.'./source/plugin/'.$dir.'/'.$file)) {
$importtxt = @implode('', file($file));
$imporfun = 'import_'.$importtype;
$imporfun();
}
}
}
}
}
cloudaddons_installlog($pluginarray['plugin']['identifier'].'.plugin');
cron_create($pluginarray['plugin']['identifier']);
updatecache(array('plugin', 'setting', 'styles'));
cleartemplatecache();
dsetcookie('addoncheck_plugin', '', -1);
return $pluginid;
}
function pluginupgrade($pluginarray, $installtype) {
if(!$pluginarray || !$pluginarray['plugin']['identifier']) {
return false;
}
$plugin = C::t('common_plugin')->fetch_by_identifier($pluginarray['plugin']['identifier']);
if(!$plugin) {
return false;
}
if(is_array($pluginarray['var'])) {
$pluginvars = $pluginvarsnew = array();
foreach(C::t('common_pluginvar')->fetch_all_by_pluginid($plugin['pluginid']) as $pluginvar) {
$pluginvars[] = $pluginvar['variable'];
}
foreach($pluginarray['var'] as $config) {
if(!in_array($config['variable'], $pluginvars)) {
$data = array('pluginid' => $plugin['pluginid']);
foreach($config as $key => $val) {
$data[$key] = $val;
}
C::t('common_pluginvar')->insert($data);
} else {
$data = array();
foreach($config as $key => $val) {
if($key != 'value') {
$data[$key] = $val;
}
}
if($data) {
C::t('common_pluginvar')->update_by_variable($plugin['pluginid'], $config['variable'], $data);
}
}
$pluginvarsnew[] = $config['variable'];
}
$pluginvardiff = array_diff($pluginvars, $pluginvarsnew);
if($pluginvardiff) {
C::t('common_pluginvar')->delete_by_variable($plugin['pluginid'], $pluginvardiff);
}
}
$langexists = updatepluginlanguage($pluginarray);
$pluginarray['plugin']['modules'] = dunserialize($pluginarray['plugin']['modules']);
$plugin['modules'] = dunserialize($plugin['modules']);
if(!empty($plugin['modules']['system'])) {
$pluginarray['plugin']['modules']['system'] = $plugin['modules']['system'];
}
$plugin['modules']['extra']['installtype'] = $installtype;
$pluginarray['plugin']['modules']['extra'] = $plugin['modules']['extra'];
if(!empty($pluginarray['intro']) || $langexists) {
if(!empty($pluginarray['intro'])) {
require_once libfile('function/discuzcode');
$pluginarray['plugin']['modules']['extra']['intro'] = discuzcode(strip_tags($pluginarray['intro']), 1, 0);
}
$langexists && $pluginarray['plugin']['modules']['extra']['langexists'] = 1;
}
if(!empty($pluginarray['uninstallfile'])) {
$pluginarray['plugin']['modules']['extra']['uninstallfile'] = $pluginarray['uninstallfile'];
}
if(!empty($pluginarray['checkfile'])) {
$pluginarray['plugin']['modules']['extra']['checkfile'] = $pluginarray['checkfile'];
}
if(!empty($pluginarray['enablefile'])) {
$pluginarray['plugin']['modules']['extra']['enablefile'] = $pluginarray['enablefile'];
}
if(!empty($pluginarray['disablefile'])) {
$pluginarray['plugin']['modules']['extra']['disablefile'] = $pluginarray['disablefile'];
}
$pluginarray['plugin']['modules'] = serialize($pluginarray['plugin']['modules']);
$data = array();
foreach($pluginarray['plugin'] as $key => $val) {
if($key == 'directory') {
$val .= (!empty($val) && substr($val, -1) != '/') ? '/' : '';
} elseif($key == 'available') {
continue;
}
$data[$key] = $val;
}
C::t('common_plugin')->update($plugin['pluginid'], $data);
cloudaddons_installlog($pluginarray['plugin']['identifier'].'.plugin');
cron_create($pluginarray['plugin']['identifier']);
updatecache(array('plugin', 'setting', 'styles'));
cleartemplatecache();
dsetcookie('addoncheck_plugin', '', -1);
return true;
}
function modulecmp($a, $b) {
return $a['displayorder'] > $b['displayorder'] ? 1 : -1;
}
function updatepluginlanguage($pluginarray) {
global $_G;
if(!$pluginarray['language']) {
return false;
}
foreach(array('script', 'template', 'install', 'system') as $type) {
loadcache('pluginlanguage_'.$type, 1);
if(empty($_G['cache']['pluginlanguage_'.$type])) {
$_G['cache']['pluginlanguage_'.$type] = array();
}
if($type != 'system') {
if(!empty($pluginarray['language'][$type.'lang'])) {
$_G['cache']['pluginlanguage_'.$type][$pluginarray['plugin']['identifier']] = $pluginarray['language'][$type.'lang'];
}
} else {
if(!empty($_G['config']['plugindeveloper']) && @include(DISCUZ_ROOT.'./data/plugindata/'.$pluginarray['plugin']['identifier'].'.lang.php')) {
if(!empty($systemlang[$pluginarray['plugin']['identifier']])) {
$pluginarray['language']['systemlang'] = $systemlang[$pluginarray['plugin']['identifier']];
}
}
foreach($pluginarray['language']['systemlang'] as $file => $vars) {
foreach($vars as $key => $var) {
$_G['cache']['pluginlanguage_system'][$file][$key] = $var;
}
}
}
savecache('pluginlanguage_'.$type, $_G['cache']['pluginlanguage_'.$type]);
}
return true;
}
function runquery($sql) {
global $_G;
$tablepre = $_G['config']['db'][1]['tablepre'];
$dbcharset = $_G['config']['db'][1]['dbcharset'];
$sql = str_replace(array(' cdb_', ' `cdb_', ' pre_', ' `pre_'), array(' {tablepre}', ' `{tablepre}', ' {tablepre}', ' `{tablepre}'), $sql);
$sql = str_replace("\r", "\n", str_replace(array(' {tablepre}', ' `{tablepre}'), array(' '.$tablepre, ' `'.$tablepre), $sql));
$ret = array();
$num = 0;
foreach(explode(";\n", trim($sql)) as $query) {
$queries = explode("\n", trim($query));
foreach($queries as $query) {
$ret[$num] .= $query[0] == '#' || $query[0].$query[1] == '--' ? '' : $query;
}
$num++;
}
unset($sql);
foreach($ret as $query) {
$query = trim($query);
if($query) {
if(substr($query, 0, 12) == 'CREATE TABLE') {
$name = preg_replace("/CREATE TABLE ([a-z0-9_]+) .*/is", "\\1", $query);
DB::query(createtable($query, $dbcharset));
} else {
DB::query($query);
}
}
}
}
function createtable($sql, $dbcharset) {
$type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql));
$defaultengine = strtolower(getglobal("config/db/common/engine")) !== 'innodb' ? 'MyISAM' : 'InnoDB';
$type = in_array($type, array('INNODB', 'MYISAM', 'HEAP', 'MEMORY')) ? $type : $defaultengine;
return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql) . " ENGINE=$type DEFAULT CHARSET=" . getglobal("config/db/1/dbcharset") . (getglobal("config/db/1/dbcharset") === 'utf8mb4' ? " COLLATE=utf8mb4_unicode_ci" : "");
}
function updatetable($sql) {
global $_G;
$config = array(
'dbcharset' => $_G['config']['db']['1']['dbcharset'],
'charset' => $_G['config']['output']['charset'],
'tablepre' => $_G['config']['db']['1']['tablepre'],
'engine' => $_G['config']['db']['common']['engine']
);
preg_match_all("/CREATE\s+TABLE.+?pre\_(.+?)\s*\((.+?)\)\s*(ENGINE|TYPE)\s*=\s*(\w+)/is", $sql, $matches);
$newtables = empty($matches[1])?array():$matches[1];
$newsqls = empty($matches[0])?array():$matches[0];
if(empty($newtables) || empty($newsqls)) {
return array(1);
}
foreach($newtables as $i => $newtable) {
$newcols = updatetable_getcolumn($newsqls[$i]);
if(!$query = DB::query("SHOW CREATE TABLE ".DB::table($newtable), 'SILENT')) {
preg_match("/(CREATE TABLE .+?)\s*(ENGINE|TYPE)\s*=\s*(\w+)/is", $newsqls[$i], $maths);
$maths[3] = strtoupper($maths[3]);
if($maths[3] == 'MEMORY' || $maths[3] == 'HEAP') {
$type = " ENGINE=MEMORY".(empty($config['dbcharset'])?'':" DEFAULT CHARSET={$config['dbcharset']}" );
} else {
$engine = $config['engine'] !== 'innodb' ? 'MyISAM' : 'InnoDB';
$type = " ENGINE=". $engine . (empty($config['dbcharset']) ? '' :" DEFAULT CHARSET={$config['dbcharset']}");
}
$usql = $maths[1].$type;
$usql = str_replace("CREATE TABLE IF NOT EXISTS pre_", 'CREATE TABLE IF NOT EXISTS '.$config['tablepre'], $usql);
$usql = str_replace("CREATE TABLE pre_", 'CREATE TABLE '.$config['tablepre'], $usql);
if(!DB::query($usql, 'SILENT')) {
return array(-1, $newtable);
}
} else {
$value = DB::fetch($query);
$oldcols = updatetable_getcolumn($value['Create Table']);
$updates = array();
$allfileds =array_keys($newcols);
foreach ($newcols as $key => $value) {
if($key == 'PRIMARY') {
if($value != $oldcols[$key]) {
if(!empty($oldcols[$key])) {
$usql = "RENAME TABLE ".DB::table($newtable)." TO ".DB::table($newtable.'_bak');
if(!DB::query($usql, 'SILENT')) {
return array(-1, $newtable);
}
}
$updates[] = "ADD PRIMARY KEY $value";
}
} elseif ($key == 'KEY') {
foreach ($value as $subkey => $subvalue) {
if(!empty($oldcols['KEY'][$subkey])) {
if($subvalue != $oldcols['KEY'][$subkey]) {
$updates[] = "DROP INDEX `$subkey`";
$updates[] = "ADD INDEX `$subkey` $subvalue";
}
} else {
$updates[] = "ADD INDEX `$subkey` $subvalue";
}
}
} elseif ($key == 'UNIQUE') {
foreach ($value as $subkey => $subvalue) {
if(!empty($oldcols['UNIQUE'][$subkey])) {
if($subvalue != $oldcols['UNIQUE'][$subkey]) {
$updates[] = "DROP INDEX `$subkey`";
$updates[] = "ADD UNIQUE INDEX `$subkey` $subvalue";
}
} else {
$usql = "ALTER TABLE ".DB::table($newtable)." DROP INDEX `$subkey`";
DB::query($usql, 'SILENT');
$updates[] = "ADD UNIQUE INDEX `$subkey` $subvalue";
}
}
} else {
if(!empty($oldcols[$key])) {
if(strtolower($value) != strtolower($oldcols[$key])) {
$updates[] = "CHANGE `$key` `$key` $value";
}
} else {
$i = array_search($key, $allfileds);
$fieldposition = $i > 0 ? 'AFTER `'.$allfileds[$i-1].'`' : 'FIRST';
$updates[] = "ADD `$key` $value $fieldposition";
}
}
}
if(!empty($updates)) {
$usql = "ALTER TABLE ".DB::table($newtable)." ".implode(', ', $updates);
if(!DB::query($usql, 'SILENT')) {
return array(-1, $newtable);
}
}
}
}
return array(1);
}
function updatetable_getcolumn($creatsql) {
$creatsql = preg_replace("/ COMMENT '.*?'/i", '', $creatsql);
preg_match("/\((.+)\)\s*(ENGINE|TYPE)\s*\=/is", $creatsql, $matchs);
$cols = explode("\n", $matchs[1]);
$newcols = array();
foreach ($cols as $value) {
$value = trim($value);
if(empty($value)) continue;
$value = updatetable_remakesql($value);
if(substr($value, -1) == ',') $value = substr($value, 0, -1);
$vs = explode(' ', $value);
$cname = $vs[0];
if($cname == 'KEY' || $cname == 'INDEX' || $cname == 'UNIQUE') {
$name_length = strlen($cname);
if($cname == 'UNIQUE') $name_length = $name_length + 4;
$subvalue = trim(substr($value, $name_length));
$subvs = explode(' ', $subvalue);
$subcname = $subvs[0];
$newcols[$cname][$subcname] = trim(substr($value, ($name_length+2+strlen($subcname))));
} elseif($cname == 'PRIMARY') {
$newcols[$cname] = trim(substr($value, 11));
} else {
$newcols[$cname] = trim(substr($value, strlen($cname)));
}
}
return $newcols;
}
function updatetable_remakesql($value) {
$value = trim(preg_replace("/\s+/", ' ', $value));
$value = str_replace(array('`',', ', ' ,', '( ' ,' )', 'mediumtext'), array('', ',', ',','(',')','text'), $value);
return $value;
}
function cron_create($pluginid, $filename = null, $name = null, $weekday = null, $day = null, $hour = null, $minute = null) {
if(!ispluginkey($pluginid)) {
return false;
}
$dir = DISCUZ_ROOT.'./source/plugin/'.$pluginid.'/cron';
if(!file_exists($dir)) {
return false;
}
$crondir = dir($dir);
while($filename = $crondir->read()) {
if(!in_array($filename, array('.', '..')) && preg_match("/^cron\_[\w\.]+$/", $filename)) {
$content = file_get_contents($dir.'/'.$filename);
preg_match("/cronname\:(.+?)\n/", $content, $r);$name = lang('plugin/'.$pluginid, trim($r[1]));
preg_match("/week\:(.+?)\n/", $content, $r);$weekday = trim($r[1]) ? intval($r[1]) : -1;
preg_match("/day\:(.+?)\n/", $content, $r);$day = trim($r[1]) ? intval($r[1]) : -1;
preg_match("/hour\:(.+?)\n/", $content, $r);$hour = trim($r[1]) ? intval($r[1]) : -1;
preg_match("/minute\:(.+?)\n/", $content, $r);$minute = trim($r[1]) ? trim($r[1]) : 0;
$minutenew = explode(',', $minute);
foreach($minutenew as $key => $val) {
$minutenew[$key] = $val = intval($val);
if($val < 0 || $var > 59) {
unset($minutenew[$key]);
}
}
$minutenew = array_slice(array_unique($minutenew), 0, 12);
$minutenew = implode("\t", $minutenew);
$filename = $pluginid.':'.$filename;
$cronid = C::t('common_cron')->get_cronid_by_filename($filename);
if(!$cronid) {
C::t('common_cron')->insert(array(
'available' => 1,
'type' => 'plugin',
'name' => $name,
'filename' => $filename,
'weekday' => $weekday,
'day' => $day,
'hour' => $hour,
'minute' => $minutenew,
), true);
} else {
C::t('common_cron')->update($cronid, array(
'name' => $name,
'weekday' => $weekday,
'day' => $day,
'hour' => $hour,
'minute' => $minutenew,
));
}
}
}
return true;
}
function cron_delete($pluginid) {
if(!ispluginkey($pluginid)) {
return false;
}
$dir = DISCUZ_ROOT.'./source/plugin/'.$pluginid.'/cron';
if(!file_exists($dir)) {
return false;
}
$crondir = dir($dir);
$count = 0;
while($filename = $crondir->read()) {
if(!in_array($filename, array('.', '..')) && preg_match("/^cron\_[\w\.]+$/", $filename)) {
$filename = $pluginid.':'.$filename;
$cronid = C::t('common_cron')->get_cronid_by_filename($filename);
C::t('common_cron')->delete($cronid);
$count++;
}
}
return $count;
}
function domain_create($pluginid, $domain, $domainroot) {
$plugin = C::t('common_plugin')->fetch_by_identifier($pluginid);
if(!$plugin || !$plugin['available']) {
return;
}
C::t('common_domain')->delete_by_id_idtype($plugin['pluginid'], 'plugin');
$data = array(
'id' => $plugin['pluginid'],
'idtype' => 'plugin',
'domain' => $domain,
'domainroot' => $domainroot,
);
C::t('common_domain')->insert($data);
require_once libfile('function/cache');
updatecache('setting');
}
function domain_delete($pluginid) {
$plugin = C::t('common_plugin')->fetch_by_identifier($pluginid);
if(!$plugin || !$plugin['available']) {
return;
}
C::t('common_domain')->delete_by_id_idtype($plugin['pluginid'], 'plugin');
require_once libfile('function/cache');
updatecache('setting');
}
?>

View File

@@ -0,0 +1,128 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_portal.php 33047 2013-04-12 08:46:56Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function category_remake($catid) {
global $_G;
$cat = $_G['cache']['portalcategory'][$catid];
if(empty($cat)) return array();
require_once libfile('function/portalcp');
$categoryperm = getallowcategory($_G['uid']);
foreach ($_G['cache']['portalcategory'] as $value) {
if($value['catid'] == $cat['upid']) {
$cat['ups'][$value['catid']] = $value;
$upid = $value['catid'];
while(!empty($upid)) {
if(!empty($_G['cache']['portalcategory'][$upid]['upid'])) {
$upid = $_G['cache']['portalcategory'][$upid]['upid'];
$cat['ups'][$upid] = $_G['cache']['portalcategory'][$upid];
} else {
$upid = 0;
}
}
} elseif($value['upid'] == $cat['catid']) {
$cat['subs'][$value['catid']] = $value;
} elseif($value['upid'] == $cat['upid']) {
if (!$value['closed'] || $_G['group']['allowdiy'] || $categoryperm[$value['catid']]['allowmanage']) {
$cat['others'][$value['catid']] = $value;
}
}
}
if(!empty($cat['ups'])) $cat['ups'] = array_reverse($cat['ups'], TRUE);
return $cat;
}
function getportalcategoryurl($catid) {
if(empty($catid)) return '';
loadcache('portalcategory');
$portalcategory = getglobal('cache/portalcategory');
if($portalcategory[$catid]) {
return $portalcategory[$catid]['caturl'];
} else {
return '';
}
}
function fetch_article_url($article) {
global $_G;
if(!empty($_G['setting']['makehtml']['flag']) && $article && $article['htmlmade']) {
if(empty($_G['cache']['portalcategory'])) {
loadcache('portalcategory');
}
$caturl = '';
if(!empty($_G['cache']['portalcategory'][$article['catid']])) {
$topid = $_G['cache']['portalcategory'][$article['catid']]['topid'];
$caturl = $_G['cache']['portalcategory'][$topid]['domain'] ? $_G['cache']['portalcategory'][$topid]['caturl'] : '';
}
return $caturl.$article['htmldir'].$article['htmlname'].'.'.$_G['setting']['makehtml']['extendname'];
} else {
return 'portal.php?mod=view&aid='.$article['aid'];
}
}
function fetch_topic_url($topic) {
global $_G;
if(!empty($_G['setting']['makehtml']['flag']) && $topic && $topic['htmlmade']) {
return $_G['setting']['makehtml']['topichtmldir'].'/'.$topic['name'].'.'.$_G['setting']['makehtml']['extendname'];
} else {
return 'portal.php?mod=topic&topicid='.$topic['topicid'];
}
}
function portal_get_list($page = 1, $perpage = 15, $wheresql = '') {
global $_G;
$page = min($page, 1000);
$start = ($page-1) * $perpage;
if($start < 0) {
$start = 0;
}
$list = array();
$pricount = 0;
$multi = '';
$count = C::t('portal_article_title')->fetch_all_by_sql($wheresql, '', 0, 0, 1, 'at');
if($count) {
$query = C::t('portal_article_title')->fetch_all_by_sql($wheresql, 'ORDER BY at.dateline DESC', $start, $perpage, 0, 'at');
foreach($query as $value) {
$value['catname'] = $_G['cache']['portalcategory'][$value['catid']]['catname'];
$value['onerror'] = '';
if($value['pic']) {
$value['pic'] = pic_get($value['pic'], '', $value['thumb'], $value['remote'], 1, 1);
}
$value['dateline'] = dgmdate($value['dateline']);
if($value['status'] == 0 || $value['uid'] == $_G['uid'] || $_G['adminid'] == 1) {
$list[] = $value;
} else {
$pricount++;
}
}
$multi = multi($count, $perpage, $page, 'portal.php', 1000);
}
return $return = array('list'=>$list, 'count'=>$count, 'multi'=>$multi, 'pricount'=>$pricount);
}
function article_title_style($value = array()) {
$style = array();
$highlight = '';
if($value['highlight']) {
$style = explode('|', $value['highlight']);
$highlight = ' style="';
$highlight .= $style[0] ? 'color: '.$style[0].';' : '';
$highlight .= $style[1] ? 'font-weight: bold;' : '';
$highlight .= $style[2] ? 'font-style: italic;' : '';
$highlight .= $style[3] ? 'text-decoration: underline;' : '';
$highlight .= '"';
}
return $highlight;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,724 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_post.php 35198 2015-02-04 03:44:54Z hypowang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function getattach($pid, $posttime = 0, $aids = '') {
global $_G;
require_once libfile('function/attachment');
$attachs = $imgattachs = array();
$aids = $aids ? explode('|', $aids) : array();
if($aids) {
$aidsnew = array();
foreach($aids as $aid) {
if($aid) {
$aidsnew[] = intval($aid);
}
}
$aids = "aid IN (".dimplode($aidsnew).") AND";
} else {
$aids = '';
}
$sqladd1 = $posttime > 0 ? "AND af.dateline>'$posttime'" : '';
if(!empty($_G['fid']) && $_G['forum']['attachextensions']) {
$allowext = str_replace(' ', '', strtolower($_G['forum']['attachextensions']));
$allowext = explode(',', $allowext);
} else {
$allowext = '';
}
foreach(C::t('forum_attachment')->fetch_all_unused_attachment($_G['uid'], empty($aidsnew) ? null : $aidsnew, $posttime > 0 ? $posttime : null) as $attach) {
$attach['filenametitle'] = $attach['filename'];
$attach['ext'] = fileext($attach['filename']);
if($allowext && !in_array($attach['ext'], $allowext)) {
continue;
}
getattach_row($attach, $attachs, $imgattachs);
}
if($pid > 0) {
$attachmentns = C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$_G['tid'], 'pid', $pid);
foreach(C::t('forum_attachment')->fetch_all_by_id('pid', $pid, 'aid') as $attach) {
if(!empty($attachmentns[$attach['aid']])) {
$attach = array_merge($attach, $attachmentns[$attach['aid']]);
}
$attach['filenametitle'] = $attach['filename'];
$attach['ext'] = fileext($attach['filename']);
if($allowext && !in_array($attach['ext'], $allowext)) {
continue;
}
getattach_row($attach, $attachs, $imgattachs);
}
}
return array('attachs' => $attachs, 'imgattachs' => $imgattachs);
}
function getattach_row($attach, &$attachs, &$imgattachs) {
global $_G;
$attach['filename'] = cutstr($attach['filename'], $_G['setting']['allowattachurl'] ? 25 : 30);
$attach['attachsize'] = sizecount($attach['filesize']);
$attach['dateline'] = dgmdate($attach['dateline']);
$attach['filetype'] = attachtype($attach['ext']."\t".$attach['filetype']);
if($attach['isimage'] < 1) {
if($attach['isimage']) {
$attach['url'] = $attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl'];
$attach['width'] = $attach['width'] > 300 ? 300 : $attach['width'];
}
if($attach['pid']) {
$attachs['used'][] = $attach;
} else {
$attachs['unused'][] = $attach;
}
} else {
$attach['url'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'/forum';
$attach['width'] = $attach['width'] > 300 ? 300 : $attach['width'];
if($attach['pid']) {
$imgattachs['used'][] = $attach;
} else {
$imgattachs['unused'][] = $attach;
}
}
}
function parseattachmedia($attach) {
$attachurl = 'attach://'.$attach['aid'].'.'.$attach['ext'];
switch(strtolower($attach['ext'])) {
case 'mp3':
case 'm4a':
case 'wma':
case 'ra':
case 'ram':
case 'wav':
case 'mid':
case 'ogg':
case 'aac':
case 'flac':
case 'weba':
return '[audio]'.$attachurl.'[/audio]';
case 'wmv':
case 'rm':
case 'rmvb':
case 'avi':
case 'asf':
case 'asx':
case 'mpg':
case 'mpeg':
case 'mov':
case 'flv':
case 'swf':
case 'mp4':
case 'm4v':
case '3gp':
case 'ogv':
case 'webm':
return '[media='.$attach['ext'].',400,300]'.$attachurl.'[/media]';
default:
return;
}
}
function ftpupload($aids, $uid = 0) {
global $_G;
$uid = $uid ? $uid : $_G['uid'];
if(!$aids || !$_G['setting']['ftp']['on']) {
return;
}
$attachtables = $pics = array();
foreach(C::t('forum_attachment')->fetch_all($aids) as $attach) {
if($uid != $attach['uid'] && !$_G['forum']['ismoderator']) {
continue;
}
$attachtables[$attach['tableid']][] = $attach['aid'];
}
foreach($attachtables as $attachtable => $aids) {
$remoteaids = array();
foreach(C::t('forum_attachment_n')->fetch_all_attachment($attachtable, $aids, 0) as $attach) {
if(ftpperm(fileext($attach['filename']), $attach['filesize'])) {
if(ftpcmd('upload', 'forum/'.$attach['attachment']) && (!$attach['thumb'] || ftpcmd('upload', 'forum/'.getimgthumbname($attach['attachment'])))) {
dunlink($attach);
$remoteaids[$attach['aid']] = $attach['aid'];
if($attach['picid']) {
$pics[] = $attach['picid'];
}
}
}
}
if($remoteaids) {
C::t('forum_attachment_n')->update_attachment($attachtable, $remoteaids, array('remote' => 1));
}
}
if($pics) {
C::t('home_pic')->update($pics, array('remote' => 3));
}
}
function updateattach($modnewthreads, $tid, $pid, $attachnew, $attachupdate = array(), $uid = 0) {
global $_G;
$thread = C::t('forum_thread')->fetch_thread($tid);
$uid = $uid ? $uid : $_G['uid'];
if($attachnew) {
$newaids = array_keys($attachnew);
$newattach = $newattachfile = $albumattach = array();
foreach(C::t('forum_attachment_unused')->fetch_all($newaids) as $attach) {
if($attach['uid'] != $uid && !$_G['forum']['ismoderator']) {
continue;
}
$attach['uid'] = $uid;
$newattach[$attach['aid']] = daddslashes($attach);
if($attach['isimage']) {
$newattachfile[$attach['aid']] = $attach['attachment'];
}
}
if($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark']) || !$_G['setting']['thumbdisabledmobile']) {
require_once libfile('class/image');
$image = new image;
}
if(!empty($_GET['albumaid'])) {
array_unshift($_GET['albumaid'], '');
$_GET['albumaid'] = array_unique($_GET['albumaid']);
unset($_GET['albumaid'][0]);
foreach($_GET['albumaid'] as $aid) {
if(isset($newattach[$aid])) {
$albumattach[$aid] = $newattach[$aid];
}
}
if(!empty($_GET['uploadalbum'])) {
$_GET['uploadalbum'] = intval($_GET['uploadalbum']);
$albuminfo = C::t('home_album')->fetch_album($_GET['uploadalbum'], $uid);
if(empty($albuminfo)) {
$_GET['uploadalbum'] = 0;
}
}
}
foreach($attachnew as $aid => $attach) {
$update = array();
$update['readperm'] = $_G['group']['allowsetattachperm'] ? $attach['readperm'] : 0;
$update['price'] = $_G['group']['maxprice'] ? (intval($attach['price']) <= $_G['group']['maxprice'] ? intval($attach['price']) : $_G['group']['maxprice']) : 0;
$update['tid'] = $tid;
$update['pid'] = $pid;
$update['uid'] = $uid;
$update['description'] = censor(cutstr(dhtmlspecialchars($attach['description']), 100));
C::t('forum_attachment_n')->update_attachment('tid:'.$tid, $aid, $update);
if(!$newattach[$aid]) {
continue;
}
$update = array_merge($update, $newattach[$aid]);
if(!empty($newattachfile[$aid])) {
if($_G['setting']['thumbstatus'] && $_G['forum']['disablethumb']) {
$update['thumb'] = 0;
@unlink($_G['setting']['attachdir'].'/forum/'.getimgthumbname($newattachfile[$aid]));
if(!empty($albumattach[$aid])) {
$albumattach[$aid]['thumb'] = 0;
}
} elseif(!$_G['setting']['thumbdisabledmobile']) {
$_daid = sprintf("%09d", $aid);
$dir1 = substr($_daid, 0, 3);
$dir2 = substr($_daid, 3, 2);
$dir3 = substr($_daid, 5, 2);
$dw = 320;
$dh = 320;
$thumbfile = 'image/'.$dir1.'/'.$dir2.'/'.$dir3.'/'.substr($_daid, -2).'_'.$dw.'_'.$dh.'.jpg';
$image->Thumb($_G['setting']['attachdir'].'/forum/'.$newattachfile[$aid], $thumbfile, $dw, $dh, 'fixwr');
$dw = 720;
$dh = 720;
$thumbfile = 'image/'.$dir1.'/'.$dir2.'/'.$dir3.'/'.substr($_daid, -2).'_'.$dw.'_'.$dh.'.jpg';
$image->Thumb($_G['setting']['attachdir'].'/forum/'.$newattachfile[$aid], $thumbfile, $dw, $dh, 'fixwr');
}
if($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
$image->Watermark($_G['setting']['attachdir'].'/forum/'.$newattachfile[$aid], '', 'forum');
$update['filesize'] = $image->imginfo['size'];
}
}
if(!empty($_GET['albumaid']) && isset($albumattach[$aid])) {
$newalbum = 0;
if(!$_GET['uploadalbum']) {
require_once libfile('function/spacecp');
$_GET['uploadalbum'] = album_creat(array('albumname' => $_GET['newalbum']));
$newalbum = 1;
}
$picdata = array(
'albumid' => $_GET['uploadalbum'],
'uid' => $uid,
'username' => $_G['username'],
'dateline' => $albumattach[$aid]['dateline'],
'postip' => $_G['clientip'],
'filename' => censor($albumattach[$aid]['filename']),
'title' => censor(cutstr(dhtmlspecialchars($attach['description']), 100)),
'type' => fileext($albumattach[$aid]['attachment']),
'size' => $albumattach[$aid]['filesize'],
'filepath' => $albumattach[$aid]['attachment'],
'thumb' => $albumattach[$aid]['thumb'],
'remote' => $albumattach[$aid]['remote'] + 2,
);
$update['picid'] = C::t('home_pic')->insert($picdata, 1);
if($newalbum) {
require_once libfile('function/home');
require_once libfile('function/spacecp');
album_update_pic($_GET['uploadalbum']);
}
}
C::t('forum_attachment_n')->insert('tid:'.$tid, $update, false, true);
C::t('forum_attachment')->update($aid, array('tid' => $tid, 'pid' => $pid, 'tableid' => getattachtableid($tid)));
C::t('forum_attachment_unused')->delete($aid);
}
if(!empty($_GET['albumaid'])) {
$albumdata = array(
'picnum' => C::t('home_pic')->check_albumpic($_GET['uploadalbum']),
'updatetime' => $_G['timestamp'],
);
C::t('home_album')->update($_GET['uploadalbum'], $albumdata);
require_once libfile('function/home');
require_once libfile('function/spacecp');
album_update_pic($_GET['uploadalbum']);
}
if($newattach) {
ftpupload($newaids, $uid);
}
}
if(!$modnewthreads && $newattach && $uid == $_G['uid']) {
updatecreditbyaction('postattach', $uid, array(), '', count($newattach), 1, $_G['fid']);
}
if($attachupdate) {
$attachs = C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$tid, 'aid', array_keys($attachupdate));
foreach($attachs as $attach) {
if(array_key_exists($attach['aid'], $attachupdate) && $attachupdate[$attach['aid']]) {
dunlink($attach);
}
}
$unusedattachs = C::t('forum_attachment_unused')->fetch_all($attachupdate);
$attachupdate = array_flip($attachupdate);
$unusedaids = array();
foreach($unusedattachs as $attach) {
if($attach['uid'] != $uid && !$_G['forum']['ismoderator']) {
continue;
}
$unusedaids[] = $attach['aid'];
$update = $attach;
$update['dateline'] = TIMESTAMP;
$update['remote'] = 0;
unset($update['aid']);
if($attach['isimage'] && $_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) {
$image->Watermark($_G['setting']['attachdir'].'/forum/'.$attach['attachment'], '', 'forum');
$update['filesize'] = $image->imginfo['size'];
}
C::t('forum_attachment_n')->update('tid:'.$tid, $attachupdate[$attach['aid']], $update);
@unlink($_G['setting']['attachdir'].'image/'.$attach['aid'].'_100_100.jpg');
C::t('forum_attachment_exif')->delete($attachupdate[$attach['aid']]);
C::t('forum_attachment_exif')->update($attach['aid'], array('aid' => $attachupdate[$attach['aid']]));
ftpupload(array($attachupdate[$attach['aid']]), $uid);
}
if($unusedaids) {
C::t('forum_attachment_unused')->delete($unusedaids);
}
}
$attachcount = C::t('forum_attachment_n')->count_by_id('tid:'.$tid, $pid ? 'pid' : 'tid', $pid ? $pid : $tid);
$attachment = 0;
if($attachcount) {
if(C::t('forum_attachment_n')->count_image_by_id('tid:'.$tid, $pid ? 'pid' : 'tid', $pid ? $pid : $tid)) {
$attachment = 2;
} else {
$attachment = 1;
}
} else {
$attachment = 0;
}
C::t('forum_thread')->update($tid, array('attachment'=>$attachment));
C::t('forum_post')->update_post('tid:'.$tid, $pid, array('attachment' => $attachment), true);
if(!$attachment) {
C::t('forum_threadimage')->delete_by_tid($tid);
}
$_G['forum_attachexist'] = $attachment;
}
function checkflood() {
global $_G;
if(!$_G['group']['disablepostctrl'] && $_G['uid']) {
if($_G['setting']['floodctrl'] && discuz_process::islocked("post_lock_".$_G['uid'], $_G['setting']['floodctrl'])) {
return true;
}
return false;
}
return FALSE;
}
function checkmaxperhour($type) {
global $_G;
$morenumperhour = false;
if(!$_G['group']['disablepostctrl'] && $_G['uid']) {
if($_G['group']['max'.($type == 'pid' ? 'posts' : 'threads').'perhour']) {
$usernum = C::t('common_member_action_log')->count_per_hour($_G['uid'], $type);
$var = $type === 'tid' ? 'maxthreadsperhour' : 'maxpostsperhour';
$isflood = $usernum && ($usernum >= $_G['group'][$var]);
if($isflood) {
$morenumperhour = true;
}
}
}
return $morenumperhour;
}
function checkpost($subject, $message, $special = 0) {
global $_G;
if(dstrlen($subject) > 255) {
return 'post_subject_toolong';
}
if(!$_G['group']['disablepostctrl'] && !$special) {
if($_G['setting']['maxpostsize'] && strlen($message) > $_G['setting']['maxpostsize']) {
return 'post_message_toolong';
} elseif($_G['setting']['minpostsize']) {
$minpostsize = !defined('IN_MOBILE') || !constant('IN_MOBILE') || !$_G['setting']['minpostsize_mobile'] ? $_G['setting']['minpostsize'] : $_G['setting']['minpostsize_mobile'];
if(strlen(preg_replace("/\[quote\].+?\[\/quote\]/is", '', $message)) < $minpostsize || strlen(preg_replace("/\[postbg\].+?\[\/postbg\]/is", '', $message)) < $minpostsize) {
return 'post_message_tooshort';
}
}
if($_G['setting']['maxsubjectsize'] && dstrlen($subject) > $_G['setting']['maxsubjectsize']) {
return 'post_subject_toolong';
} elseif(dstrlen($subject) && $_G['setting']['minsubjectsize'] && dstrlen($subject) < $_G['setting']['minsubjectsize']) {
return 'post_subject_tooshort';
}
}
return FALSE;
}
function checkbbcodes($message, $bbcodeoff) {
return !$bbcodeoff && (!strpos($message, '[/') && !strpos($message, '[hr]')) ? -1 : $bbcodeoff;
}
function checksmilies($message, $smileyoff) {
global $_G;
if($smileyoff) {
return 1;
} else {
if(!empty($_G['cache']['smileycodes']) && is_array($_G['cache']['smileycodes'])) {
foreach($_G['cache']['smileycodes'] as $id => $code) {
if(strpos($message, $code) !== FALSE) {
return 0;
}
}
}
return -1;
}
}
function updatepostcredits($operator, $uidarray, $action, $fid = 0) {
global $_G;
$val = $operator == '+' ? 1 : -1;
$extsql = array();
if(empty($uidarray)) {
return false;
}
$uidarray = (array)$uidarray;
$uidarr = array();
foreach($uidarray as $uid) {
$uidarr[$uid] = !isset($uidarr[$uid]) ? 1 : $uidarr[$uid]+1;
}
foreach($uidarr as $uid => $coef) {
$opnum = $val*$coef;
if($action == 'reply') {
$extsql = array('posts' => $opnum);
} elseif($action == 'post') {
$extsql = array('threads' => $opnum, 'posts' => $opnum);
}
if($uid == $_G['uid']) {
updatecreditbyaction($action, $uid, $extsql, '', $opnum, 1, $fid);
} elseif(empty($uid)) {
continue;
} else {
batchupdatecredit($action, $uid, $extsql, $opnum, $fid);
}
}
if($operator == '+' && ($action == 'reply' || $action == 'post')) {
C::t('common_member_status')->update(array_keys($uidarr), array('lastpost' => TIMESTAMP), 'UNBUFFERED');
}
}
function updateattachcredits($operator, $uidarray) {
global $_G;
foreach($uidarray as $uid => $attachs) {
updatecreditbyaction('postattach', $uid, array(), '', $operator == '-' ? -$attachs : $attachs, 1, $_G['fid']);
}
}
function updateforumcount($fid) {
$fidposts = C::t('forum_thread')->count_posts_by_fid($fid);
extract($fidposts);
$thread = C::t('forum_thread')->fetch_by_fid_displayorder($fid, 0, '=');
$thread['subject'] = addslashes($thread['subject']);
$thread['lastposter'] = $thread['author'] ? addslashes($thread['lastposter']) : lang('forum/misc', 'anonymous');
$tid = $thread['closed'] > 1 ? $thread['closed'] : $thread['tid'];
$setarr = array('posts' => $posts, 'threads' => $threads, 'lastpost' => "$tid\t{$thread['subject']}\t{$thread['lastpost']}\t${thread['lastposter']}");
C::t('forum_forum')->update($fid, $setarr);
}
function updatethreadcount($tid, $updateattach = 0) {
$replycount = C::t('forum_post')->count_visiblepost_by_tid($tid) - 1;
$lastpost = C::t('forum_post')->fetch_visiblepost_by_tid('tid:'.$tid, $tid, 0, 1);
$lastpost['author'] = $lastpost['anonymous'] ? lang('forum/misc', 'anonymous') : addslashes($lastpost['author']);
$lastpost['dateline'] = !empty($lastpost['dateline']) ? $lastpost['dateline'] : TIMESTAMP;
$data = array('replies'=>$replycount, 'lastposter'=>$lastpost['author'], 'lastpost'=>$lastpost['dateline']);
if($updateattach) {
$attach = C::t('forum_post')->fetch_attachment_by_tid($tid);
$data['attachment'] = $attach ? 1 : 0;
}
C::t('forum_thread')->update($tid, $data);
}
function updatemodlog($tids, $action, $expiration = 0, $iscron = 0, $reason = '', $stamp = 0) {
global $_G;
if(is_array($tids)){
$tids = implode(',',$tids);
}
$uid = empty($iscron) ? $_G['uid'] : 0;
$username = empty($iscron) ? $_G['member']['username'] : 0;
$expiration = empty($expiration) ? 0 : intval($expiration);
$data = $comma = '';
$stampadd = $stampaddvalue = '';
if($stamp) {
$stampadd = ', stamp';
$stampaddvalue = ", '$stamp'";
}
foreach(explode(',', str_replace(array('\'', ' '), array('', ''), $tids)) as $tid) {
if($tid) {
$data = array(
'tid' => $tid,
'uid' => $uid,
'username' => $username,
'dateline' => $_G['timestamp'],
'action' => $action,
'expiration' => $expiration,
'status' => 1,
'reason' => $reason
);
if($stamp) {
$data['stamp'] = $stamp;
}
C::t('forum_threadmod')->insert($data);
}
}
}
function isopera() {
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if(strpos($useragent, 'opera') !== false) {
preg_match('/opera(\/| )([0-9\.]+)/', $useragent, $regs);
return $regs[2];
}
return FALSE;
}
function deletethreadcaches($tids) {
global $_G;
if(!$_G['setting']['cachethreadon']) {
return FALSE;
}
require_once libfile('function/forumlist');
if(!empty($tids)) {
foreach(explode(',', $tids) as $tid) {
$fileinfo = getcacheinfo($tid);
@unlink($fileinfo['filename']);
}
}
return TRUE;
}
function disuploadedfile($file) {
return function_exists('is_uploaded_file') && (is_uploaded_file($file) || is_uploaded_file(str_replace('\\\\', '\\', $file)));
}
function postfeed($feed) {
global $_G;
if($feed) {
require_once libfile('function/feed');
feed_add($feed['icon'], $feed['title_template'], $feed['title_data'], $feed['body_template'], $feed['body_data'], '', $feed['images'], $feed['image_links'], '', '', '', 0, $feed['id'], $feed['idtype']);
}
}
function messagesafeclear($message) {
if(strpos($message, '[/password]') !== FALSE) {
$message = '';
}
if(strpos($message, '[/postbg]') !== FALSE) {
$message = preg_replace("/\s?\[postbg\]\s*([^\[\<\r\n;'\"\?\(\)]+?)\s*\[\/postbg\]\s?/is", '', $message);
}
if(strpos($message, '[/begin]') !== FALSE) {
$message = preg_replace("/\[begin(=\s*([^\[\<\r\n]*?)\s*,(\d*),(\d*),(\d*),(\d*))?\]\s*([^\[\<\r\n]+?)\s*\[\/begin\]/is", '', $message);
}
if(strpos($message, '[page]') !== FALSE) {
$message = preg_replace("/\s?\[page\]\s?/is", '', $message);
}
if(strpos($message, '[/index]') !== FALSE) {
$message = preg_replace("/\s?\[index\](.+?)\[\/index\]\s?/is", '', $message);
}
if(strpos($message, '[/begin]') !== FALSE) {
$message = preg_replace("/\[begin(=\s*([^\[\<\r\n]*?)\s*,(\d*),(\d*),(\d*),(\d*))?\]\s*([^\[\<\r\n]+?)\s*\[\/begin\]/is", '', $message);
}
if(strpos($message, '[/groupid]') !== FALSE) {
$message = preg_replace("/\[groupid=\d+\].*\[\/groupid\]/i", '', $message);
}
$language = lang('forum/misc');
$message = preg_replace(array($language['post_edithtml_regexp'],$language['post_editnobbcode_regexp'],$language['post_edit_regexp']), '', $message);
return $message;
}
function messagecutstr($message, $length = 0, $dot = ' ...') {
global $_G;
$str = messagesafeclear($message);
$sppos = strpos($str, chr(0).chr(0).chr(0));
if($sppos !== false) {
$str = substr($str, 0, $sppos);
}
$language = lang('forum/misc');
loadcache(array('bbcodes_display', 'bbcodes', 'smileycodes', 'smilies', 'smileytypes', 'domainwhitelist'));
$bbcodes = 'b|i|u|p|color|backcolor|size|font|align|list|indent|float';
$bbcodesclear = 'email|code|free|table|tr|td|img|swf|flash|attach|media|audio|groupid|payto'.(!empty($_G['cache']['bbcodes_display'][$_G['groupid']]) ? '|'.implode('|', array_keys($_G['cache']['bbcodes_display'][$_G['groupid']])) : '');
$str = strip_tags(preg_replace(array(
"/\[hide=?\d*\](.*?)\[\/hide\]/is",
"/\[quote](.*?)\[\/quote]/si",
$language['post_edit_regexp'],
"/\[url=?.*?\](.+?)\[\/url\]/si",
"/\[($bbcodesclear)(=.*?)?\].+?\[\/\\1\]/si",
"/\[($bbcodes)(=.*?)?\]/i",
"/\[\/($bbcodes)\]/i",
"/\\\\u/i"
), array(
$language['post_hidden'],
'',
'',
'\\1',
'',
'',
'',
'%u'
), $str));
$str = preg_replace($_G['cache']['smilies']['searcharray'], '', $str);
if($_G['setting']['plugins']['func'][HOOKTYPE]['discuzcode']) {
$_G['discuzcodemessage'] = & $str;
$param = func_get_args();
hookscript('discuzcode', 'global', 'funcs', array('param' => $param, 'caller' => 'messagecutstr'), 'discuzcode');
}
if($length) {
$str = cutstr($str, $length, $dot);
}
return trim($str);
}
function threadmessagecutstr($thread, $str, $length = 0, $dot = ' ...') {
global $_G;
if(!empty($thread)) {
if(!empty($thread['readperm']) && $thread['readperm'] > 0) {
$str = '';
}elseif(!empty($thread['price']) && $thread['price'] > 0) {
preg_match_all("/\[free\](.+?)\[\/free\]/is", $str, $matches);
$str = '';
if(!empty($matches[1])) {
foreach($matches[1] as $match) {
$str .= $match.' ';
}
} else {
$language = lang('forum/misc');
$str = $language['post_sold'];
}
}
}
return messagecutstr($str, $length, $dot);
}
function setthreadcover($pid, $tid = 0, $aid = 0, $countimg = 0, $imgurl = '') {
global $_G;
$cover = 0;
if(empty($_G['uid']) || !intval($_G['setting']['forumpicstyle']['thumbwidth'])) {
return false;
}
if(($pid || $aid) && empty($countimg)) {
if(empty($imgurl)) {
if($aid) {
$attachtable = 'aid:'.$aid;
$attach = C::t('forum_attachment_n')->fetch_attachment('aid:'.$aid, $aid, array(1, -1));
} else {
$attachtable = 'pid:'.$pid;
$attach = C::t('forum_attachment_n')->fetch_max_image('pid:'.$pid, 'pid', $pid);
}
if(!$attach) {
return false;
}
if(empty($_G['forum']['ismoderator']) && $_G['uid'] != $attach['uid']) {
return false;
}
$pid = empty($pid) ? $attach['pid'] : $pid;
$tid = empty($tid) ? $attach['tid'] : $tid;
$picsource = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$attach['attachment'];
} else {
return true;
}
$basedir = !$_G['setting']['attachdir'] ? (DISCUZ_ROOT.'./data/attachment/') : $_G['setting']['attachdir'];
$coverdir = 'threadcover/'.substr(md5($tid), 0, 2).'/'.substr(md5($tid), 2, 2).'/';
dmkdir($basedir.'./forum/'.$coverdir);
require_once libfile('class/image');
$image = new image();
if($image->Thumb($picsource, 'forum/'.$coverdir.$tid.'.jpg', $_G['setting']['forumpicstyle']['thumbwidth'], $_G['setting']['forumpicstyle']['thumbheight'], 2)) {
$remote = '';
if(ftpperm('jpg', filesize($_G['setting']['attachdir'].'forum/'.$coverdir.$tid.'.jpg'))) {
if(ftpcmd('upload', 'forum/'.$coverdir.$tid.'.jpg')) {
@unlink($_G['setting']['attachdir'].'forum/'.$coverdir.$tid.'.jpg');
$remote = '-';
}
}
$cover = C::t('forum_attachment_n')->count_image_by_id($attachtable, 'pid', $pid);
if($imgurl && empty($cover)) {
$cover = 1;
}
$cover = $remote.$cover;
} else {
return false;
}
}
if($countimg) {
if(empty($cover)) {
$thread = C::t('forum_thread')->fetch_thread($tid);
$oldcover = $thread['cover'];
$cover = C::t('forum_attachment_n')->count_image_by_id('tid:'.$tid, 'pid', $pid);
if($cover) {
$cover = $oldcover < 0 ? '-'.$cover : $cover;
}
}
}
if($cover) {
C::t('forum_thread')->update($tid, array('cover' => $cover));
return true;
}
}
?>

View File

@@ -0,0 +1,120 @@
<?php
if(!defined('IN_DISCUZ') || (PHP_VERSION < '7.0.0')) {
exit('Access Denied');
}
function dpreg_replace_impl($pattern, $replacement, $subject, $limit, &$count) {
$eval = false;
$delimiter = $pattern[0];
if(($position_of_modifier = (int) strrpos($pattern, $delimiter)) > 0) {
if(($position_of_eval = strpos($pattern, 'e', $position_of_modifier)) !== false) {
$eval = true;
$pattern = substr($pattern, 0, $position_of_eval).substr($pattern, $position_of_eval + 1);
}
}
if($eval) {
return preg_replace_callback($pattern, function($matches) use ($replacement) {
$result = '';
$instance = false;
for($i = 0, $j = strlen($replacement); $i < $j; $i ++) {
if(($replacement[$i] == '$') || ($replacement[$i] == '\\')) {
if((($i == 0) || ($replacement[$i - 1] != '\\')) && isset($replacement[$i + 1])) {
$get_backref_string = substr($replacement, $i + 1);
if($get_backref_string[0] == '{') {
$get_backref_result = preg_match('/^\{([0-9]{1,2})}/', $get_backref_string, $get_backref_match);
} else {
$get_backref_result = preg_match('/^([0-9]{1,2})/', $get_backref_string, $get_backref_match);
}
if($get_backref_result) {
$backref = $get_backref_match[1];
if(isset($matches[$backref])) {
$result .= addslashes($matches[$backref]);
}
$i += strlen($get_backref_match[0]);
continue;
} else {
if(preg_match('/^this([^a-z0-9_]+)/i', $get_backref_string)) {
$result .= '$_';
$instance = true;
continue;
}
}
}
}
$result .= $replacement[$i];
}
if($instance) {
$_this = null;
@$stack = (array) debug_backtrace();
if(isset($stack[6]) && isset($stack[6]['object'])) {
if(is_object($stack[6]['object'])) {
$_this = $stack[6]['object'];
}
}
}
return eval("return {$result};");
}, $subject, $limit, $count);
} else {
return preg_replace($pattern, $replacement, $subject, $limit, $count);
}
}
function dpreg_replace_in_subject($pattern, $replacement, $subject, $limit, &$count) {
if(is_array($pattern)) {
if(is_array($replacement)) {
reset($replacement);
} else {
$replacement_value = $replacement;
}
foreach($pattern as $pattern_value) {
if(is_array($replacement)) {
if(key($replacement) === null) {
$replacement_value = '';
} else {
$replacement_value = current($replacement);
next($replacement);
}
}
if(($subject = dpreg_replace_impl($pattern_value, $replacement_value, $subject, $limit, $count)) === null) {
return null;
}
}
return $subject;
} else {
return dpreg_replace_impl($pattern, $replacement, $subject, $limit, $count);
}
}
function _dpreg_replace($pattern, $replacement, $subject, $limit = -1, &$count = null) {
if(is_array($replacement) && !is_array($pattern))
return preg_replace($pattern, $replacement, $subject, $limit, $count);
if(is_array($subject)) {
$result = array();
foreach($subject as $subject_key => $subject_value) {
$result[$subject_key] = dpreg_replace_in_subject($pattern, $replacement, $subject_value, $limit, $count);
}
return $result;
} else {
return dpreg_replace_in_subject($pattern, $replacement, $subject, $limit, $count);
}
}

View File

@@ -0,0 +1,475 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_profile.php 36354 2017-01-17 07:52:44Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function profile_setting($fieldid, $space=array(), $showstatus=false, $ignoreunchangable = false, $ignoreshowerror = false) {
global $_G;
if(empty($_G['cache']['profilesetting'])) {
loadcache('profilesetting');
}
$field = getglobal('cache/profilesetting/'.$fieldid);
if(empty($field) || !$field['available'] || in_array($fieldid, array('uid', 'constellation', 'zodiac', 'birthmonth', 'birthyear', 'birthcountry', 'birthprovince', 'birthdist', 'birthcommunity', 'residecountry', 'resideprovince', 'residedist', 'residecommunity'))) {
return '';
}
if($showstatus) {
$uid = intval($space['uid']);
if($uid && !isset($_G['profile_verifys'][$uid])) {
$_G['profile_verifys'][$uid] = array();
if($value = C::t('common_member_verify_info')->fetch_by_uid_verifytype($uid, 0)) {
$fields = dunserialize($value['field']);
foreach($fields as $key => $fvalue) {
if($_G['cache']['profilesetting'][$key]['needverify']) {
$_G['profile_verifys'][$uid][$key] = $fvalue;
}
}
}
}
$verifyvalue = NULL;
if(isset($_G['profile_verifys'][$uid][$fieldid])) {
if($fieldid=='gender') {
$verifyvalue = lang('space', 'gender_'.intval($_G['profile_verifys'][$uid][$fieldid]));
} elseif($fieldid=='birthday') {
$verifyvalue = $_G['profile_verifys'][$uid]['birthyear'].'-'.$_G['profile_verifys'][$uid]['birthmonth'].'-'.$_G['profile_verifys'][$uid]['birthday'];
} else {
$verifyvalue = $_G['profile_verifys'][$uid][$fieldid];
}
}
}
$html = '';
$field['unchangeable'] = !$ignoreunchangable && $field['unchangeable'] ? 1 : 0;
if($fieldid == 'birthday') {
if($field['unchangeable'] && !empty($space[$fieldid])) {
return '<span>'.$space['birthyear'].'-'.$space['birthmonth'].'-'.$space['birthday'].'</span>';
}
$birthyeayhtml = '';
$nowy = dgmdate($_G['timestamp'], 'Y');
for ($i=0; $i<100; $i++) {
$they = $nowy - $i;
$selectstr = $they == $space['birthyear']?' selected':'';
$birthyeayhtml .= "<option value=\"$they\"$selectstr>$they</option>";
}
$birthmonthhtml = '';
for ($i=1; $i<13; $i++) {
$selectstr = $i == $space['birthmonth']?' selected':'';
$birthmonthhtml .= "<option value=\"$i\"$selectstr>$i</option>";
}
$birthdayhtml = '';
if(empty($space['birthmonth']) || in_array($space['birthmonth'], array(1, 3, 5, 7, 8, 10, 12))) {
$days = 31;
} elseif(in_array($space['birthmonth'], array(4, 6, 9, 11))) {
$days = 30;
} elseif($space['birthyear'] && (($space['birthyear'] % 400 == 0) || ($space['birthyear'] % 4 == 0 && $space['birthyear'] % 100 != 0))) {
$days = 29;
} else {
$days = 28;
}
for ($i=1; $i<=$days; $i++) {
$selectstr = $i == $space['birthday']?' selected':'';
$birthdayhtml .= "<option value=\"$i\"$selectstr>$i</option>";
}
$html = '<select name="birthyear" id="birthyear" class="ps'.(defined('IN_MOBILE') ? ' sort_sel' : '').'" onchange="showbirthday();">'
.'<option value="">'.lang('space', 'year').'</option>'
.$birthyeayhtml
.'</select>'
.'&nbsp;&nbsp;'
.'<select name="birthmonth" id="birthmonth" class="ps'.(defined('IN_MOBILE') ? ' sort_sel' : '').'" onchange="showbirthday();">'
.'<option value="">'.lang('space', 'month').'</option>'
.$birthmonthhtml
.'</select>'
.'&nbsp;&nbsp;'
.'<select name="birthday" id="birthday" class="ps'.(defined('IN_MOBILE') ? ' sort_sel' : '').'">'
.'<option value="">'.lang('space', 'day').'</option>'
.$birthdayhtml
.'</select>';
} elseif($fieldid=='gender') {
if($field['unchangeable'] && $space[$fieldid] > 0) {
return '<span>'.lang('space', 'gender_'.intval($space[$fieldid])).'</span>';
}
$selected = array($space[$fieldid]=>' selected="selected"');
$html = '<select name="gender" id="gender" class="ps'.(defined('IN_MOBILE') ? ' sort_sel' : '').'">';
if($field['unchangeable']) {
$html .= '<option value="">'.lang('space', 'gender').'</option>';
} else {
$html .= '<option value="0"'.($space[$fieldid]=='0' ? ' selected="selected"' : '').'>'.lang('space', 'gender_0').'</option>';
}
$html .= '<option value="1"'.($space[$fieldid]=='1' ? ' selected="selected"' : '').'>'.lang('space', 'gender_1').'</option>'
.'<option value="2"'.($space[$fieldid]=='2' ? ' selected="selected"' : '').'>'.lang('space', 'gender_2').'</option>'
.'</select>';
} elseif($fieldid=='birthcity') {
if($field['unchangeable'] && !empty($space[$fieldid])) {
return '<span>'.$space['birthcountry'].'-'.$space['birthprovince'].'-'.$space['birthcity'].'</span>';
}
$values = array(0,0,0,0,0);
$elems = array('birthcountry', 'birthprovince', 'birthcity', 'birthdist', 'birthcommunity');
if(!empty($space['birthcountry'])) {
$html = profile_show('birthcity', $space);
$html .= '&nbsp;(<a href="javascript:;" onclick="showdistrict(\'birthdistrictbox\', [\'birthcountry\', \'birthprovince\', \'birthcity\', \'birthdist\', \'birthcommunity\'], 4, \'\', \'birth\'); return false;">'.lang('spacecp', 'profile_edit').'</a>)';
$html .= '<p id="birthdistrictbox"></p>';
} else {
$html = '<p id="birthdistrictbox">'.showdistrict($values, $elems, 'birthdistrictbox', 1, 'birth').'</p>';
}
} elseif($fieldid=='residecity') {
if($field['unchangeable'] && !empty($space[$fieldid])) {
return '<span>'.$space['resideprovince'].'-'.$space['residecity'].'</span>';
}
$values = array(0,0,0,0,0);
$elems = array('residecountry', 'resideprovince', 'residecity', 'residedist', 'residecommunity');
if(!empty($space['residecountry'])) {
$html = profile_show('residecity', $space);
$html .= '&nbsp;(<a href="javascript:;" onclick="showdistrict(\'residedistrictbox\', [\'residecountry\', \'resideprovince\', \'residecity\', \'residedist\', \'residecommunity\'], 4, \'\', \'reside\'); return false;">'.lang('spacecp', 'profile_edit').'</a>)';
$html .= '<p id="residedistrictbox"></p>';
} else {
$html = '<p id="residedistrictbox">'.showdistrict($values, $elems, 'residedistrictbox', 1, 'reside').'</p>';
}
} elseif($fieldid=='qq') {
$html = "<input type=\"text\" name=\"$fieldid\" id=\"$fieldid\" class=\"px\" value=\"$space[$fieldid]\" placeholder=\"\" /><p><a href=\"\" class=\"xi2\" onclick=\"this.href='//wp.qq.com/set.html?from=discuz&uin='+$('$fieldid').value\" target=\"_blank\">".lang('spacecp', 'qq_set_status')."</a></p>";
} else {
if($field['unchangeable'] && $space[$fieldid]!='') {
if($field['formtype']=='file') {
$imgurl = getglobal('setting/attachurl').'./profile/'.$space[$fieldid];
return '<span><a href="'.$imgurl.'" target="_blank"><img src="'.$imgurl.'" style="max-width: 500px;" /></a></span>';
} else {
return '<span>'.nl2br($space[$fieldid]).'</span>';
}
}
if($field['formtype']=='textarea') {
$html = "<textarea name=\"$fieldid\" id=\"$fieldid\" class=\"pt\" rows=\"3\" cols=\"40\">$space[$fieldid]</textarea>";
} elseif($field['formtype']=='select') {
$field['choices'] = explode("\n", $field['choices']);
$html = "<select name=\"$fieldid\" id=\"$fieldid\" class=\"ps\">";
foreach($field['choices'] as $op) {
$html .= "<option value=\"$op\"".($op==$space[$fieldid] ? 'selected="selected"' : '').">$op</option>";
}
$html .= '</select>';
} elseif($field['formtype']=='list') {
$field['choices'] = explode("\n", $field['choices']);
$html = "<select name=\"{$fieldid}[]\" id=\"$fieldid\" class=\"ps\" multiple=\"multiplue\">";
$space[$fieldid] = explode("\n", $space[$fieldid]);
foreach($field['choices'] as $op) {
$html .= "<option value=\"$op\"".(in_array($op, $space[$fieldid]) ? 'selected="selected"' : '').">$op</option>";
}
$html .= '</select>';
} elseif($field['formtype']=='checkbox') {
$field['choices'] = explode("\n", $field['choices']);
$space[$fieldid] = explode("\n", $space[$fieldid]);
foreach($field['choices'] as $op) {
$html .= ''
."<label class=\"lb\"><input type=\"checkbox\" name=\"{$fieldid}[]\" id=\"$fieldid\" class=\"pc\" value=\"$op\"".(in_array($op, $space[$fieldid]) ? ' checked="checked"' : '')." />"
."$op</label>";
}
} elseif($field['formtype']=='radio') {
$field['choices'] = explode("\n", $field['choices']);
foreach($field['choices'] as $op) {
$html .= ''
."<label class=\"lb\"><input type=\"radio\" name=\"{$fieldid}\" class=\"pr\" value=\"$op\"".($op == $space[$fieldid] ? ' checked="checked"' : '')." />"
."$op</label>";
}
} elseif($field['formtype']=='file') {
$html = "<input type=\"file\" value=\"\" name=\"$fieldid\" id=\"$fieldid\" class=\"pf\" style=\"height:26px;\" /><input type=\"hidden\" name=\"$fieldid\" value=\"$space[$fieldid]\" />";
if(!empty($space[$fieldid])) {
$url = getglobal('setting/attachurl').'./profile/'.$space[$fieldid];
$html .= "&nbsp;<label><input type=\"checkbox\" class=\"checkbox\" name=\"deletefile[$fieldid]\" id=\"$fieldid\" value=\"yes\" />".lang('spacecp', 'delete')."</label><br /><a href=\"$url\" target=\"_blank\"><img src=\"$url\" width=\"200\" class=\"mtm\" /></a>";
}
} else {
$html = "<input type=\"text\" name=\"$fieldid\" id=\"$fieldid\" class=\"px\" value=\"$space[$fieldid]\" placeholder=\"".$field['title']."\" />";
}
}
$html .= !$ignoreshowerror ? "<div class=\"rq mtn\" id=\"showerror_$fieldid\"></div>" : '';
if($showstatus) {
$tips = isset($field['description']) ? $field['description'] : '';
if($space[$fieldid] == '' && !empty($field['unchangeable'])) {
$tips .= (empty($tips) ? '' : ' ').lang('spacecp', 'profile_unchangeable');
}
if($verifyvalue !== null) {
if($field['formtype'] == 'file') {
$imgurl = getglobal('setting/attachurl').'./profile/'.$verifyvalue;
$verifyvalue = "<img src='$imgurl' alt='$imgurl' style='max-width: 500px;'/>";
}
$tips .= (empty($tips) ? '' : ' ')."<strong>".lang('spacecp', 'profile_is_verifying')." (<a href=\"#\" onclick=\"display('newvalue_$fieldid');return false;\">".lang('spacecp', 'profile_mypost')."</a>)</strong>"
."<p id=\"newvalue_$fieldid\" style=\"display:none\">".$verifyvalue."</p>";
} elseif($field['needverify']) {
$tips .= (empty($tips) ? '' : ' ').lang('spacecp', 'profile_need_verifying');
}
$html .= '<p class="d">' . $tips . '</p>';
}
return $html;
}
function profile_check($fieldid, &$value, $space=array()) {
global $_G;
if(empty($_G['cache']['profilesetting'])) {
loadcache('profilesetting');
}
if(empty($_G['profilevalidate'])) {
include libfile('spacecp/profilevalidate', 'include');
$_G['profilevalidate'] = $profilevalidate;
}
$field = $_G['cache']['profilesetting'][$fieldid];
if(empty($field) || !$field['available']) {
return false;
}
if($value=='') {
if($field['required']) {
if(in_array($fieldid, array('birthcountry', 'birthprovince', 'birthcity', 'birthdist', 'birthcommunity', 'residecountry', 'resideprovince', 'residecity', 'residedist', 'residecommunity'))) {
if(substr($fieldid, 0, 5) == 'birth') {
if(!empty($_GET['birthcountry']) || !empty($_GET['birthprovince']) || !empty($_GET['birthcity']) || !empty($_GET['birthdist']) || !empty($_GET['birthcommunity'])) {
return true;
}
} elseif(!empty($_GET['residecountry']) || !empty($_GET['resideprovince']) || !empty($_GET['residecity']) || !empty($_GET['residedist']) || !empty($_GET['residecommunity'])) {
return true;
}
}
return false;
} else {
return true;
}
}
if($field['unchangeable'] && !empty($space[$fieldid])) {
return false;
}
include_once libfile('function/home');
if(in_array($fieldid, array('birthday', 'birthmonth', 'birthyear', 'gender'))) {
$value = intval($value);
return true;
} elseif(in_array($fieldid, array('birthcountry', 'birthprovince', 'birthcity', 'birthdist', 'birthcommunity', 'residecountry', 'resideprovince', 'residecity', 'residedist', 'residecommunity'))) {
$value = getstr($value);
return true;
}
if($field['choices']) {
$field['choices'] = explode("\n", $field['choices']);
}
if($field['formtype'] == 'text' || $field['formtype'] == 'textarea') {
$value = getstr($value);
if($field['size'] && strlen($value) > $field['size']) {
return false;
} else {
$field['validate'] = !empty($field['validate']) ? $field['validate'] : ($_G['profilevalidate'][$fieldid] ? $_G['profilevalidate'][$fieldid] : '');
if($field['validate'] && !preg_match($field['validate'], $value)) {
return false;
}
}
} elseif($field['formtype'] == 'checkbox' || $field['formtype'] == 'list') {
$arr = array();
foreach ($value as $op) {
if(in_array($op, $field['choices'])) {
$arr[] = $op;
}
}
$value = implode("\n", $arr);
if($field['size'] && count($arr) > $field['size']) {
return false;
}
} elseif($field['formtype'] == 'radio' || $field['formtype'] == 'select') {
if(!in_array($value, $field['choices'])){
return false;
}
}
return true;
}
function profile_show($fieldid, $space=array(), $getalone = false) {
global $_G;
if(empty($_G['cache']['profilesetting'])) {
loadcache('profilesetting');
}
if($fieldid == 'qqnumber') {
$_G['cache']['profilesetting'][$fieldid] = $_G['cache']['profilesetting']['qq'];
}
$field = $_G['cache']['profilesetting'][$fieldid];
if(empty($field) || !$field['available'] || (!$getalone && in_array($fieldid, array('uid', 'birthmonth', 'birthyear', 'birthcountry', 'residecountry')))) {
return false;
}
if($fieldid=='gender') {
return lang('space', 'gender_'.intval($space['gender']));
} elseif($fieldid=='birthday' && !$getalone) {
$return = $space['birthyear'] ? $space['birthyear'].' '.lang('space', 'year').' ' : '';
if($space['birthmonth'] && $space['birthday']) {
$return .= $space['birthmonth'].' '.lang('space', 'month').' '.$space['birthday'].' '.lang('space', 'day');
}
return $return;
} elseif($fieldid=='birthcity' && !$getalone) {
return $space['birthcountry']
.(!empty($space['birthprovince']) ? ' '.$space['birthprovince'] : '')
.(!empty($space['birthcity']) ? ' '.$space['birthcity'] : '')
.(!empty($space['birthdist']) ? ' '.$space['birthdist'] : '')
.(!empty($space['birthcommunity']) ? ' '.$space['birthcommunity'] : '');
} elseif($fieldid=='residecity' && !$getalone) {
return $space['residecountry']
.(!empty($space['resideprovince']) ? ' '.$space['resideprovince'] : '')
.(!empty($space['residecity']) ? ' '.$space['residecity'] : '')
.(!empty($space['residedist']) ? ' '.$space['residedist'] : '')
.(!empty($space['residecommunity']) ? ' '.$space['residecommunity'] : '');
} elseif($fieldid == 'site') {
$url = str_replace('"', '\\"', $space[$fieldid]);
return "<a href=\"$url\" target=\"_blank\">$url</a>";
} elseif($fieldid == 'position') {
return nl2br($space['office'] ? : ($space['field_position']?:$space['position']));
} elseif($fieldid == 'qq') {
return '<a href="//wpa.qq.com/msgrd?v=3&uin='.$space[$fieldid].'&site='.$_G['setting']['bbname'].'&menu=yes&from=discuz" target="_blank" title="'.lang('spacecp', 'qq_dialog').'"><img src="'.STATICURL.'image/common/qq.gif" alt="QQ" style="margin:0px;"/></a>';
} elseif($fieldid == 'qqnumber') {
return $space['qq'];
} else {
return nl2br($space[$fieldid]);
}
}
function showdistrict($values, $elems=array(), $container='districtbox', $showlevel=null, $containertype = 'birth') {
$html = '';
if(!preg_match("/^[A-Za-z0-9_]+$/", $container)) {
return $html;
}
$showlevel = !empty($showlevel) ? intval($showlevel) : count($values);
$showlevel = $showlevel <= 5 ? $showlevel : 5;
$upids = array(0);
for($i=0;$i<$showlevel;$i++) {
if(!empty($values[$i])) {
$upids[] = intval($values[$i]);
} else {
for($j=$i; $j<$showlevel; $j++) {
$values[$j] = '';
}
break;
}
}
$options = array(0=>array(), 1=>array(), 2=>array(), 3=>array(), 4=>array());
if($upids && is_array($upids)) {
foreach(C::t('common_district')->fetch_all_by_upid($upids, 'displayorder', 'ASC') as $value) {
if($value['level'] == 0 && ($value['id'] != $values[0] && ($value['usetype'] == 0 || !(($containertype == 'birth' && in_array($value['usetype'], array(1, 3))) || ($containertype != 'birth' && in_array($value['usetype'], array(2, 3))))))) {
continue;
}
$options[$value['level']][] = array($value['id'], $value['name']);
}
}
$names = array('country', 'province', 'city', 'district', 'community');
for($i=0; $i<4;$i++) {
if(!empty($elems[$i])) {
$elems[$i] = dhtmlspecialchars(preg_replace("/[^\[A-Za-z0-9_\]]/", '', $elems[$i]));
} else {
$elems[$i] = ($containertype == 'birth' ? 'birth' : 'reside').$names[$i];
}
}
for($i=0;$i<$showlevel;$i++) {
$level = $i;
if(!empty($options[$level])) {
$jscall = "showdistrict('$container', ['$elems[0]', '$elems[1]', '$elems[2]', '$elems[3]', '$elems[4]'], $showlevel, $level, '$containertype')";
$html .= '<select name="'.$elems[$i].'" id="'.$elems[$i].'" class="ps" onchange="'.$jscall.'">';
$html .= '<option value="">'.lang('spacecp', 'district_level_'.$level).'</option>';
foreach($options[$level] as $option) {
$selected = $option[0] == $values[$i] ? ' selected="selected"' : '';
$html .= '<option did="'.$option[0].'" value="'.$option[1].'"'.$selected.'>'.$option[1].'</option>';
}
$html .= '</select>';
$html .= '&nbsp;&nbsp;';
}
}
return $html;
}
function countprofileprogress($uid = 0) {
global $_G;
$uid = intval(!$uid ? $_G['uid'] : $uid);
if(($profilegroup = C::t('common_setting')->fetch_setting('profilegroup', true))) {
$fields = array();
foreach($profilegroup as $type => $value) {
foreach($value['field'] as $key => $field) {
$fields[$key] = $field;
}
}
if(isset($fields['sightml']) && empty($_G['group']['maxsigsize'])) {
unset($fields['sightml']);
}
if(isset($fields['customstatus']) && empty($_G['group']['allowcstatus'])) {
unset($fields['customstatus']);
}
loadcache('profilesetting');
$allowcstatus = !empty($_G['group']['allowcstatus']) ? true : false;
$complete = 0;
$profile = array_merge(C::t('common_member_profile')->fetch($uid), C::t('common_member_field_forum')->fetch($uid));
foreach($fields as $key) {
if((!isset($_G['cache']['profilesetting'][$key]) || !$_G['cache']['profilesetting'][$key]['available']) && !in_array($key, array('sightml', 'customstatus'))) {
unset($fields[$key]);
continue;
}
if(in_array($key, array('birthday', 'birthyear', 'birthcountry', 'birthprovince', 'birthcity', 'birthdist', 'birthcommunity', 'residecountry', 'resideprovince', 'residecity', 'residedist', 'residecommunity'))) {
if($key=='birthday') {
if(!empty($profile['birthyear']) || !empty($profile[$key])) {
$complete++;
}
unset($fields['birthyear']);
} elseif($key=='birthcity') {
if(!empty($profile['birthcountry']) || !empty($profile['birthprovince']) || !empty($profile[$key]) || !empty($profile['birthdist']) || !empty($profile['birthcommunity'])) {
$complete++;
}
unset($fields['birthcountry']);
unset($fields['birthprovince']);
unset($fields['birthdist']);
unset($fields['birthcommunity']);
} elseif($key=='residecity') {
if(!empty($profile['residecountry']) || !empty($profile['resideprovince']) || !empty($profile[$key]) || !empty($profile['residedist']) || !empty($profile['residecommunity'])) {
$complete++;
}
unset($fields['residecountry']);
unset($fields['resideprovince']);
unset($fields['residedist']);
unset($fields['residecommunity']);
}
} else if($profile[$key] != '') {
$complete++;
}
}
$progress = empty($fields) ? 0 : floor($complete / count($fields) * 100);
C::t('common_member_status')->update($uid, array('profileprogress' => $progress > 100 ? 100 : $progress), 'UNBUFFERED');
return $progress;
}
}
function get_constellation($birthmonth,$birthday) {
$birthmonth = intval($birthmonth);
$birthday = intval($birthday);
$idx = $birthmonth;
if ($birthday <= 22) {
if (1 == $birthmonth) {
$idx = 12;
} else {
$idx = $birthmonth - 1;
}
}
return $idx > 0 && $idx <= 12 ? lang('space', 'constellation_'.$idx) : '';
}
function get_zodiac($birthyear) {
$birthyear = intval($birthyear);
$idx = (($birthyear - 1900) % 12) + 1;
return $idx > 0 && $idx <= 12 ? lang('space', 'zodiac_'. $idx) : '';
}
function isprofileimage($file) {
return is_file(getglobal('setting/attachdir').'./profile/'.$file) && strpos(realpath(getglobal('setting/attachdir').'./profile/'.$file), realpath(getglobal('setting/attachdir').'./profile/').DIRECTORY_SEPARATOR) === 0 && in_array(fileext($file), array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp'));
}
?>

View File

@@ -0,0 +1,75 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_search.php 36278 2016-12-09 07:52:35Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function searchkey($keyword, $field, $returnsrchtxt = 0) {
$srchtxt = '';
if($field && $keyword) {
if(preg_match("(AND|\+|&|\s)", $keyword) && !preg_match("(OR|\|)", $keyword)) {
$andor = ' AND ';
$keywordsrch = '1';
$keyword = preg_replace("/( AND |&| )/is", "+", $keyword);
} else {
$andor = ' OR ';
$keywordsrch = '0';
$keyword = preg_replace("/( OR |\|)/is", "+", $keyword);
}
$keyword = str_replace('*', '%', addcslashes($keyword, '%_'));
$srchtxt = $returnsrchtxt ? $keyword : '';
foreach(explode('+', $keyword) as $text) {
$text = trim(daddslashes($text));
if($text) {
$keywordsrch .= $andor;
$keywordsrch .= str_replace('{text}', $text, $field);
}
}
$keyword = " AND ($keywordsrch)";
}
return $returnsrchtxt ? array($srchtxt, $keyword) : $keyword;
}
function highlight($text, $words, $prepend) {
$text = str_replace('\"', '"', $text);
foreach($words AS $key => $replaceword) {
$text = str_replace($replaceword, '<highlight>'.$replaceword.'</highlight>', $text);
}
return "$prepend$text";
}
function bat_highlight($message, $words, $color = '#ff0000') {
if(!empty($words)) {
$highlightarray = explode(' ', $words);
$sppos = strrpos($message, chr(0).chr(0).chr(0));
if($sppos !== FALSE) {
$specialextra = substr($message, $sppos + 3);
$message = substr($message, 0, $sppos);
}
bat_highlight_callback_highlight_21($highlightarray, 1);
$message = preg_replace_callback("/(^|>)([^<]+)(?=<|$)/sU", 'bat_highlight_callback_highlight_21', $message);
$message = preg_replace("/<highlight>(.*)<\/highlight>/siU", "<strong><font color=\"$color\">\\1</font></strong>", $message);
if($sppos !== FALSE) {
$message = $message.chr(0).chr(0).chr(0).$specialextra;
}
}
return $message;
}
function bat_highlight_callback_highlight_21($matches, $action = 0) {
static $highlightarray = array();
if($action == 1) {
$highlightarray = $matches;
} else {
return highlight($matches[2], $highlightarray, $matches[1]);
}
}
?>

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$
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function searchindex_cache() {
global $_G;
include_once DISCUZ_ROOT.'./source/discuz_version.php';
if(preg_match("#\d{8}#i", DISCUZ_RELEASE)) {
$cachedata = "lang('admincp_searchindex');\n\$searchindex = & \$_G['lang']['admincp_searchindex'];";
require_once libfile('function/cache');
writetocache('searchindex', $cachedata);
return null;
}
$siteurl = $_G['siteurl'];
$_G['siteurl'] = '';
require DISCUZ_ROOT.'./source/language/lang_admincp_menu.php';
$menulang = $lang;
require DISCUZ_ROOT.'./source/language/lang_admincp.php';
$genlang = $lang + $menulang;
$_G['siteurl'] = $siteurl;
$indexdata = array();
require DISCUZ_ROOT.'./source/admincp/admincp_menu.php';
foreach($menu as $topmenu => $leftmenu) {
foreach($leftmenu as $item) {
if(!isset($item[2]) && isset($menulang[$item[0]])) {
list($action, $operation, $do) = explode('_', $item[1]);
$indexdata[] = array('index' => array(
$menulang[$item[0]] => 'action='.$action.($operation ? '&operation='.$operation.($do ? '&do='.$do : '') : '')
), 'text' => array($menulang[$item[0]]));
}
}
}
$genlangi = '|'.implode('|', array_keys($genlang)).'|';
$flag = false;
$dir = opendir(DISCUZ_ROOT.'./source/admincp/');
while($entry = readdir($dir)) {
if($entry != '.' && $entry != '..' && preg_match('/^admincp\_/', $entry)) {
$adminfile = DISCUZ_ROOT.'./source/admincp/'.$entry;
$data = file_get_contents($adminfile);
$data = preg_replace('/\/\/.+?\r/', '', $data);
$data = preg_replace_callback(
'/\/\*(.+?)\*\//s',
function ($matches) {
if(!preg_match('/^search/i', $matches[1])) {
return '';
} else {
return '/*'.$matches[1].'*/';
}
},
$data
);
$isfullindex = preg_match_all('#/\*search=\s*(\{.+?\})\s*\*/(.+?)/\*search\*/#is', $data, $search);
if($isfullindex) {
foreach($search[0] as $k => $item) {
$search[1][$k] = stripslashes($search[1][$k]);
$titles = json_decode($search[1][$k], 1);
$titlesnew = $titletext = array();
foreach($titles as $title => $url) {
$titlekey = strip_tags(isset($genlang[$title]) ? $genlang[$title] : $title);
$titlesnew[$titlekey] = $url;
if($titlekey[0] != '_') {
$titletext[] = $titlekey;
}
}
$data = $search[2][$k];
$l = $tm = array();
preg_match_all("/(showsetting|showtitle|showtableheader|showtips)\('(\w+)'/", $data, $r);
if($r[2]) {
if($titletext) {
$l[] = implode(' &raquo; ', $titletext);
}
foreach($r[2] as $i) {
if(in_array($i,$tm)) {
continue;
}
$tm[] = $i;
$l[] = strip_tags($i);
$l[] = strip_tags($genlang[$i]);
$preg = '/\|('.preg_quote($i).'_comment)\|/';
preg_match_all($preg, $genlangi, $lr);
if($lr[1]) {
foreach($lr[1] as $li) {
$l[] = strip_tags($genlang[$li]);
}
}
}
}
preg_match_all("/\\\$lang\['(\w+)'\]/", $data, $r);
if($r[1]) {
if(empty($l) && $titletext) {
$l[] = implode(' &raquo; ', $titletext);
}
foreach($r[1] as $i) {
if(in_array($i,$tm)) {
continue;
}
$tm[] = $i;
$l[] = strip_tags($i);
$l[] = strip_tags($genlang[$i]);
$preg = '/\|('.preg_quote($i).'_comment)\|/';
preg_match_all($preg, $genlangi, $lr);
if($lr[1]) {
foreach($lr[1] as $li) {
$l[] = strip_tags($genlang[$li]);
}
}
}
}
if (!empty($l)) {
$indexdata[] = array('index' => $titlesnew, 'text' => $l);
$flag = true;
}
}
}
}
}
if($flag) {
$cachedata = '$searchindex = '.var_export($indexdata, 1).';';
} else {
$cachedata = "lang('admincp_searchindex');\n\$searchindex = & \$_G['lang']['admincp_searchindex'];";
}
require_once libfile('function/cache');
writetocache('searchindex', $cachedata);
}

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: function_share.php 31894 2012-10-23 02:13:29Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function mkshare($share) {
require_once libfile('function/discuzcode');
$share['body_data'] = dunserialize($share['body_data']);
$searchs = $replaces = array();
if($share['body_data']) {
if(isset($share['body_data']['flashaddr'])) {
$share['body_data']['flashaddr'] = addslashes($share['body_data']['flashaddr']);
} elseif(isset($share['body_data']['musicvar'])) {
$share['body_data']['musicvar'] = addslashes($share['body_data']['musicvar']);
}
foreach (array_keys($share['body_data']) as $key) {
$searchs[] = '{'.$key.'}';
$replaces[] = $share['body_data'][$key];
}
if($share['body_data']['flashvar']){
$share['body_data']['player'] = parseflv($share['body_data']['data'], '500', '373');
}
if($share['body_data']['musicvar']){
$share['body_data']['player'] = parseaudio($share['body_data']['data']);
}
if($share['body_data']['videovar']){
$share['body_data']['player'] = parsemedia('x,500,373',$share['body_data']['data']);
}
}
$share['body_template'] = str_replace($searchs, $replaces, $share['body_template']);
return $share;
}
?>

View File

@@ -0,0 +1,728 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_space.php 34052 2013-09-25 06:18:43Z andyzheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function getblockhtml($blockname,$parameters = array()) {
global $_G, $space;
$parameters = empty($parameters) ? array() : $parameters;
$list = array();
$sql = $title = $html = $wheresql = $ordersql = $titlemore = $do = $contentclassname = '';
$view = $from = false;
$contenttagname = 'div';
$shownum = 6;
$uid = intval($space['uid']);
$shownum = empty($parameters['shownum']) ? $shownum : intval($parameters['shownum']);
switch ($blockname) {
case 'personalinfo':
$do = 'profile';
space_merge($space, 'profile');
require_once libfile('function/friend');
$isfriend = friend_check($space['uid']);
require_once libfile('function/spacecp');
loadcache('profilesetting');
include_once libfile('function/profile');
$profiles = array();
$privacy = $space['privacy']['profile'] ? $space['privacy']['profile'] : array();
foreach($_G['cache']['profilesetting'] as $fieldid=>$field) {
if($_G['setting']['nsprofiles']) {
break;
}
if(!$field['available'] || in_array($fieldid, array('birthcountry', 'birthprovince', 'birthdist', 'birthcommunity', 'residecountry', 'resideprovince', 'residedist', 'residecommunity'))) {
continue;
}
if(
$field['available'] && $field['invisible'] != '1' && strlen($space[$fieldid]) > 0 &&
(
$field['showinthread'] ||
$field['showincard'] ||
(
$space['self'] || empty($privacy[$fieldid]) || ($isfriend && $privacy[$fieldid] == 1)
)
)
) {
$val = profile_show($fieldid, $space);
if($val !== false) {
if($fieldid == 'realname' && $_G['uid'] != $space['uid'] && !ckrealname(1)) {
continue;
}
if($field['formtype'] == 'file' && $val) {
$imgurl = getglobal('setting/attachurl').'./profile/'.$val;
$val = '<span><a href="'.$imgurl.'" target="_blank"><img src="'.$imgurl.'" style="max-width: 300px;" /></a></span>';
}
if ($val == '') $val = '';
$html .= '<li><em>'.$field['title'].'</em>'.$val.'</li>';
}
}
}
$html = $html ? $html : '<li>'.lang('space', 'block_view_profileinfo_noperm').'</li>';
$html = '<ul id="pprl" class="mbm pbm bbda cl">'.$html.$more.'</ul>';
$more = lang('space', 'block_profile_all', array('uid' => $uid));
$html = $html.$more;
$titlemore = $space['self'] ? lang('space', 'block_profile_edit') : '';
break;
case 'profile':
$do = $blockname;
$managehtml = '';
$avatar = empty($parameters['banavatar']) ? 'middle' : $parameters['banavatar'];
$html .= "<div class=\"hm\"><p><a href=\"home.php?mod=space&uid=$uid\" target=\"_blank\">".avatar($uid,$avatar).'</a></p>';
$memberfieldforum = C::t('common_member_field_forum')->fetch($space['uid']);
$space['medals'] = $memberfieldforum['medals'];
unset($memberfieldforum);
$usermedals = $medal_detial = $usermedalmenus = '';
if($space['medals']) {
loadcache('medals');
foreach($space['medals'] = explode("\t", $space['medals']) as $key => $medalid) {
list($medalid, $medalexpiration) = explode("|", $medalid);
if(isset($_G['cache']['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > TIMESTAMP)) {
$usermedals .= '<img src="'.$_G['cache']['medals'][$medalid]['image'].'" id="md_'.$medalid.'" alt="'.$_G['cache']['medals'][$medalid]['name'].'\'" onmouseover="showMenu({\'ctrlid\':this.id, \'menuid\':\'md_'.$medalid.'_menu\', \'pos\':\'12!\'});" />&nbsp;';
$usermedalmenus .= '
<div id="md_'.$medalid.'_menu" class="tip tip_4" style="display: none;">
<div class="tip_horn"></div>
<div class="tip_c">
<h4>'.$_G['cache']['medals'][$medalid]['name'].'</h4>
<p>'.$_G['cache']['medals'][$medalid]['description'].'</p>
</div>
</div>';
}
}
if($usermedals) {
$usermedals = '<p class="md_ctrl"><a href="home.php?mod=medal">'.$usermedals.'</a></p>'.$usermedalmenus;
}
}
$html .= "<h2 class=\"mbn\"><a href=\"home.php?mod=space&uid=$uid\" target=\"_blank\">".$space['username']."</a></h2>$usermedals";
$html .= '</div><ul class="xl xl2 cl ul_list">';
$magicinfo = $showmagicgift = false;
if($_G['setting']['magicstatus'] && $_G['setting']['magics']['gift']) {
$showmagicgift = true;
$magicinfo = !empty($space['magicgift']) ? dunserialize($space['magicgift']) : array();
}
if(helper_access::check_module('follow')) {
$html .= '<li class="ul_broadcast"><a href="home.php?mod=space&uid='.$uid.'">'.lang('space', 'block_profile_follow').'</a></li>';
}
if ($space['self']) {
$html .= '<li class="ul_diy"><a href="home.php?mod=space&do=index&diy=yes">'.lang('space', 'block_profile_diy').'</a></li>';
$html .= '<li class="ul_msg"><a href="home.php?mod=space&uid='.$uid.'&do=wall">'.lang('space', 'block_profile_wall').'</a></li>';
$html .= '<li class="ul_avt"><a href="home.php?mod=spacecp&ac=avatar">'.lang('space', 'block_profile_avatar').'</a></li>';
$html .= '<li class="ul_profile"><a href="home.php?mod=spacecp&ac=profile">'.lang('space', 'block_profile_update').'</a></li>';
if($showmagicgift) {
$html .= '<li class="ul_magicgift"><div style="'.'background: url('.STATICURL.'image/magic/gift.small.gif) no-repeat 0 50%;'.'">';
if($magicinfo) {
$html .= '<a onclick="showWindow(\'magicgift\', this.href, \'get\', 0)" href="home.php?mod=spacecp&ac=magic&op=retiregift">'.lang('magic/gift', 'gift_gc').'</a>';
} else {
$html .= '<a onclick="showWindow(\'magicgift\', this.href, \'get\', 0)" href="home.php?mod=magic&mid=gift">'.lang('magic/gift', 'gift_use').'</a>';
}
$html .= '</div></li>';
}
} else {
if(helper_access::check_module('follow')) {
$follow = C::t('home_follow')->fetch_by_uid_followuid($_G['uid'], $uid);
if($follow) {
$html .= "<li class='ul_flw'><a href=\"home.php?mod=spacecp&ac=follow&op=del&fuid={$space['uid']}\" id=\"followmod\" onclick=\"showWindow(this.id, this.href, 'get', 0);\">".lang('space', 'follow_cancle_follow')."</a></li>";
} else {
$html .= "<li class='ul_flw'><a href=\"home.php?mod=spacecp&ac=follow&op=add&hash=".FORMHASH."&fuid={$space['uid']}\" id=\"followmod\" onclick=\"showWindow(this.id, this.href, 'get', 0);\">".lang('space', 'follow_follow_ta')."</a></li>";
}
}
if(helper_access::check_module('friend')) {
require_once libfile('function/friend');
$isfriend = friend_check($uid);
if (!$isfriend) {
$html .= "<li class='ul_add'><a href=\"home.php?mod=spacecp&ac=friend&op=add&uid={$space['uid']}&handlekey=addfriendhk_{$space['uid']}\" id=\"a_friend_li_{$space['uid']}\" onclick=\"showWindow(this.id, this.href, 'get', 0);\">".lang('space', 'block_profile_friend_add')."</a></li>";
} else {
$html .= "<li class='ul_ignore'><a href=\"home.php?mod=spacecp&ac=friend&op=ignore&uid={$space['uid']}&handlekey=ignorefriendhk_{$space['uid']}\" id=\"a_ignore_{$space['uid']}\" onclick=\"showWindow(this.id, this.href, 'get', 0);\">".lang('space', 'block_profile_friend_ignore')."</a></li>";
}
$html .= "<li class='ul_poke'><a href=\"home.php?mod=spacecp&ac=poke&op=send&uid={$space['uid']}&handlekey=propokehk_{$space['uid']}\" id=\"a_poke_{$space['uid']}\" onclick=\"showWindow(this.id, this.href, 'get', 0);\">".lang('space', 'block_profile_poke')."</a></li>";
}
if(helper_access::check_module('wall')) {
$html .= "<li class='ul_msg'><a href=\"home.php?mod=space&uid={$space['uid']}&do=wall\">".lang('space', 'block_profile_wall_to_me')."</a></li>";
}
$html .= "<li class='ul_pm'><a href=\"home.php?mod=spacecp&ac=pm&op=showmsg&handlekey=showmsg_{$space['uid']}&touid={$space['uid']}&pmid=0&daterange=2\" id=\"a_sendpm_{$space['uid']}\" onclick=\"showWindow('showMsgBox', this.href, 'get', 0)\">".lang('space', 'block_profile_sendmessage')."</a></li>";
}
$html .= '</ul>';
$encodeusername = rawurlencode($space['username']);
if(checkperm('allowbanuser')) {
$managehtml .= '<li><a href="'.($_G['adminid'] == 1 ? "admin.php?action=members&operation=ban&username=$encodeusername&frames=yes" : "forum.php?mod=modcp&action=member&op=ban&uid={$space['uid']}").'" id="usermanageli" onmouseover="showMenu(this.id)" class="showmenu" target="_blank">'.lang('home/template', 'member_manage').'</a></li>';
} elseif (checkperm('allowedituser')) {
$managehtml .= '<li><a href="'.($_G['adminid'] == 1 ? "admin.php?action=members&operation=search&username=$encodeusername&submit=yes&frames=yes" : "forum.php?mod=modcp&action=member&op=edit&uid={$space['uid']}").'" id="usermanageli" onmouseover="showMenu(this.id)" class="showmenu" target="_blank">'.lang('home/template', 'member_manage').'</a></li>';
}
if($_G['adminid'] == 1) {
if(helper_access::check_module('forum')) {
$managehtml .= "<li><a href=\"forum.php?mod=modcp&action=thread&op=post&do=search&searchsubmit=1&users=$encodeusername\" id=\"umanageli\" onmouseover=\"showMenu(this.id)\" class=\"showmenu\">".lang('home/template', 'content_manage')."</a></li>";
} else {
$managehtml .= "<li><a id=\"umanageli\" onmouseover=\"showMenu(this.id)\" class=\"showmenu\">".lang('home/template', 'content_manage')."</a></li>";
}
}
if(!empty($managehtml)) {
$html .= '<hr class="da mtn m0" /><ul class="ptn xl xl2 cl">'.$managehtml.'</ul><ul id="usermanageli_menu" class="p_pop" style="width: 80px; display:none;">';
if(checkperm('allowbanuser')) {
$html .= '<li><a href="'.($_G['adminid'] == 1 ? "admin.php?action=members&operation=ban&username=$encodeusername&frames=yes" : "forum.php?mod=modcp&action=member&op=ban&uid=$space[uid]").'" target="_blank">'.lang('home/template', 'user_ban').'</a></li>';
}
if (checkperm('allowedituser')) {
$html .= '<li><a href="'.($_G['adminid'] == 1 ? "admin.php?action=members&operation=search&username=$encodeusername&submit=yes&frames=yes" : "forum.php?mod=modcp&action=member&op=edit&uid=$space[uid]").'" target="_blank">'.lang('home/template', 'user_edit').'</a></li>';
}
$html .= '</ul>';
if($_G['adminid'] == 1) {
$html .= '<ul id="umanageli_menu" class="p_pop" style="width: 80px; display:none;">';
helper_access::check_module('forum') && $html .= '<li><a href="forum.php?mod=modcp&action=thread&op=post&searchsubmit=1&do=search&users='.$encodeusername.'" target="_blank">'.lang('space', 'manage_post').'</a></li>';
helper_access::check_module('doing') && $html .= '<li><a href="admin.php?action=doing&searchsubmit=1&detail=1&search=true&fromumanage=1&users='.$encodeusername.'" target="_blank">'.lang('space', 'manage_doing').'</a></li>';
helper_access::check_module('blog') && $html .= '<li><a href="admin.php?action=blog&searchsubmit=1&detail=1&search=true&fromumanage=1&uid='.$uid.'" target="_blank">'.lang('space', 'manage_blog').'</a></li>';
helper_access::check_module('feed') && $html .= '<li><a href="admin.php?action=feed&searchsubmit=1&detail=1&fromumanage=1&uid='.$uid.'" target="_blank">'.lang('space', 'manage_feed').'</a></li>';
helper_access::check_module('album') && $html .= '<li><a href="admin.php?action=album&searchsubmit=1&detail=1&search=true&fromumanage=1&uid='.$uid.'" target="_blank">'.lang('space', 'manage_album').'</a></li>';
helper_access::check_module('album') && $html .= '<li><a href="admin.php?action=pic&searchsubmit=1&detail=1&search=true&fromumanage=1&users='.$encodeusername.'" target="_blank">'.lang('space', 'manage_pic').'</a></li>';
$html .= '<li><a href="admin.php?action=comment&searchsubmit=1&detail=1&fromumanage=1&authorid='.$uid.'" target="_blank">'.lang('space', 'manage_comment').'</a></li>';
helper_access::check_module('share') && $html .= '<li><a href="admin.php?action=share&searchsubmit=1&detail=1&search=true&fromumanage=1&uid='.$uid.'" target="_blank">'.lang('space', 'manage_share').'</a></li>';
helper_access::check_module('group') && $html .= '<li><a href="admin.php?action=threads&operation=group&searchsubmit=1&detail=1&search=true&fromumanage=1&users='.$encodeusername.'" target="_blank">'.lang('space', 'manage_group_threads').'</a></li>';
helper_access::check_module('group') && $html .= '<li><a href="admin.php?action=prune&operation=group&searchsubmit=1&detail=1&fromumanage=1&users='.$encodeusername.'" target="_blank">'.lang('space', 'manage_group_prune').'</a></li>';
$html .= '</ul>';
}
}
if($_G['setting']['magicstatus'] && $_G['setting']['magics']['gift']) {
$info = !empty($space['magicgift']) ? dunserialize($space['magicgift']) : array();
if($space['self']) {
} elseif($info) {
if($info['left'] && !in_array($_G['uid'], (array)$info['receiver'])) {
$percredit = min($info['percredit'], $info['left']);
if($info['credittype']=='credits') {
$credittype = lang('core', 'title_credit');
} else {
$extcredits = str_replace('extcredits', '', $info['credittype']);
$credittype = $_G['setting']['extcredits'][$extcredits]['title'];
}
$html .= '<div id="magicreceivegift">';
$html .= '<a onclick="showWindow(\'magicgift\', this.href, \'get\', 0)" href="home.php?mod=spacecp&ac=magic&op=receivegift&uid='.$uid.'" title="'.lang('magic/gift', 'gift_receive_gift', array('percredit'=>$percredit,'credittype'=>$credittype)).'">';
$html .= '<img src="'.STATICURL.'image/magic/gift.gif" alt="gift" />';
$html .= '</a>';
$html .= '</div>';
}
}
}
$html = '<div>'.$html.'</div>';
break;
case 'statistic':
space_merge($space, 'count');
$html .= '<p class="mbm xw1">';
if(empty($parameters['banviews'])) $html .= lang('space', 'space_views', array('views' => $space['views'] ? $space['views'] : '--'));
$html .= '</p><ul class="xl xl2 cl">';
if(empty($parameters['bancredits'])) {
$html .= "<li>".lang('space', 'credits').': <a href="home.php?mod=spacecp&ac=credit">'.($space['credits'] ? $space['credits'] : '--')."</a></li>";
foreach($_G['setting']['extcredits'] as $extcreditid => $extcredit) {
$html .= "<li>".($extcredit['img'] ? $extcredit['img'].' ' : '').$extcredit['title'].': <a href="home.php?mod=spacecp&ac=credit">'.($space['extcredits'.$extcreditid] ? $space['extcredits'.$extcreditid] : '--').'</a>';
}
}
if(empty($parameters['banfriends'])) $html .= "<li>".lang('space', 'friends').': <a href="home.php?mod=space&uid='.$uid.'&do=friend&view=me&from=space">'.($space['friends'] ? $space['friends'] : '--')."</a></li>";
if(empty($parameters['banthreads']) && $_G['setting']['allowviewuserthread'] !== -1 || $_G['adminid'] == 1) {
$html .= "<li>".lang('space', 'threads').': <a href="home.php?mod=space&uid='.$uid.'&do=thread&view=me&from=space">'.($space['threads'] ? $space['threads'] : '--')."</a></li>";
}
if(empty($parameters['banblogs'])) $html .= "<li>".lang('space', 'blogs').': <a href="home.php?mod=space&uid='.$uid.'&do=blog&view=me&from=space">'.($space['blogs'] ? $space['blogs'] : '--')."</a></li>";
if(empty($parameters['banalbums'])) $html .= "<li>".lang('space', 'albums').': <a href="home.php?mod=space&uid='.$uid.'&do=album&view=me&from=space">'.($space['albums'] ? $space['albums'] : '--')."</a></li>";
if(empty($parameters['bansharings'])) $html .= "<li>".lang('space', 'sharings').': <a href="home.php?mod=space&uid='.$uid.'&do=share&view=me&from=space">'.($space['sharings'] ? $space['sharings'] : '--')."</a></li>";
$html .= '</ul>';
$html = '<div>'.$html.'</div>';
break;
case 'doing':
$do = $blockname;
$view = 'me';
$from = 'space';
if(ckprivacy('doing', 'view')) {
$dolist = array();
$query = C::t('home_doing')->fetch_all_by_uid_doid(array($uid), '', 'dateline', 0, $shownum, false, true);
foreach ($query as $value) {
if($value['status'] == 0 || $value['uid'] == $_G['uid']) {
$dolist[] = $value;
}
}
if ($dolist) {
foreach($dolist as $dv) {
$doid = $dv['doid'];
$_GET['key'] = $key = random(8);
$html .= "<li class=\"pbn bbda\">";
$html .= $dv['message'];
$html .= "&nbsp;<a href=\"home.php?mod=space&uid={$dv['uid']}&do=doing&view=me&from=space&doid={$dv['doid']}\" target=\"_blank\" class=\"xg1\">".lang('space', 'block_doing_reply')."</a>";
$html .= "</li>";
}
} else {
$html .= "<p class=\"emp\">".lang('space', 'block_doing_no_content').($space['self'] ? lang('space', 'block_doing_no_content_publish', $space) : '')."</p>";
}
} else {
$html .= "<p class=\"emp\">".lang('space', 'block_view_noperm')."</p>";
}
$html = '<ul class="xl">'.$html.'</ul>';
break;
case 'stickblog' :
space_merge($space, 'profile');
$stickblogs = explode(',', $space['stickblogs']);
if(!empty($stickblogs)) {
$bids = array_slice($stickblogs, 0, $shownum);
if(count($bids)) {
if(!isset($parameters['showmessage'])) $parameters['showmessage'] = 150;
$data_blog = C::t('home_blog')->fetch_all_blog($bids);
if($parameters['showmessage'] > 0) {
$data_blogfield = C::t('home_blogfield')->fetch_all($bids);
}
foreach($data_blog as $curblogid => $value) {
$value = array_merge($value, (array)$data_blogfield[$curblogid]);
if(ckfriend($value['uid'], $value['friend'], $value['target_ids'])) {
if($value['pic']) $value['pic'] = pic_cover_get($value['pic'], $value['picflag']);
$value['message'] = $value['friend'] == 4 ? '' : getstr($value['message'], $parameters['showmessage'], 0, 0, 0, -1);
$html .= lang('space', 'blog_li', array(
'uid' => $value['uid'],
'blogid' => $value['blogid'],
'subject' => $value['subject'],
'date' => dgmdate($value['dateline'],'Y-m-d')));
if(!empty($parameters['showmessage'])) {
if ($value['pic']) {
$html .= lang('space', 'blog_li_img', array(
'uid' => $value['uid'],
'blogid' => $value['blogid'],
'src' => $value['pic']));
}
$html .= "<dd>{$value['message']}</dd>";
}
$html .= lang('space', 'blog_li_ext', array('uid'=>$value['uid'],'blogid'=>$value['blogid'],'viewnum'=>$value['viewnum'],'replynum'=>$value['replynum']));
$html .= "</dl>";
} else {
$html .= '<p>'.lang('space','block_view_noperm').'</p>';
}
}
}
}
$more = $html ? '<p class="ptm" style="text-align: right;"><a href="home.php?mod=space&uid='.$uid.'&do=blog&view=me&from=space">'.lang('space', 'viewmore').'</a></p>' : '';
$contentclassname = ' xld';
$html = $html.$more;
break;
case 'blog':
$do = $blockname;
$view = 'me';
$from = 'space';
if(!isset($parameters['showmessage'])) $parameters['showmessage'] = 150;
$data_blog = C::t('home_blog')->fetch_all_by_uid($uid, 'dateline', 0, $shownum);
$blogids = array_keys($data_blog);
$data_blogfield = C::t('home_blogfield')->fetch_all($blogids);
foreach($data_blog as $curblogid => $value) {
$value = array_merge($value, (array)$data_blogfield[$curblogid]);
if(ckfriend($value['uid'], $value['friend'], $value['target_ids'])) {
if($value['pic']) $value['pic'] = pic_cover_get($value['pic'], $value['picflag']);
$value['message'] = $value['friend'] == 4 ? '' : getstr($value['message'], $parameters['showmessage'], 0, 0, 0, -1);
$html .= lang('space', 'blog_li', array(
'uid' => $value['uid'],
'blogid' => $value['blogid'],
'subject' => $value['subject'],
'date' => dgmdate($value['dateline'],'Y-m-d')));
if(!empty($parameters['showmessage'])) {
if ($value['pic']) {
$html .= lang('space', 'blog_li_img', array(
'uid' => $value['uid'],
'blogid' => $value['blogid'],
'src' => $value['pic']));
}
$html .= "<dd>{$value['message']}</dd>";
}
$html .= lang('space', 'blog_li_ext', array('uid'=>$value['uid'],'blogid'=>$value['blogid'],'viewnum'=>$value['viewnum'],'replynum'=>$value['replynum']));
$html .= "</dl>";
} else {
$html .= '<p>'.lang('space','block_view_noperm').'</p>';
}
}
if($html) {
$more = '<p class="ptm" style="text-align: right;"><a href="home.php?mod=space&uid='.$uid.'&do=blog&view=me&from=space">'.lang('space', 'viewmore').'</a></p>';
} else {
$html = '<p class="emp">'.lang('space','block_blog_no_content').($space['self'] ? lang('space', 'block_blog_no_content_publish', $space) : '').'</p>';
$more = '';
}
$contentclassname = ' xld';
$html = $html.$more;
break;
case 'album':
$do = $blockname;
$view = 'me';
$from = 'space';
if(ckprivacy('album', 'view')) {
$query = C::t('home_album')->fetch_all_by_uid($uid, 'updatetime', 0, $shownum);
foreach($query as $value) {
if(ckfriend($value['uid'], $value['friend'], $value['target_ids'])) {
$value['pic'] = pic_cover_get($value['pic'], $value['picflag']);
$html .= lang('space', 'album_li', array(
'albumid' =>$value['albumid'],
'src' => $value['pic'],
'albumname' => $value['albumname'],
'uid' => $value['uid'],
'picnum' => $value['picnum'],
'date' => dgmdate($value['updatetime'],'n-j')
));
}
}
if(!$html) {
$html = '<p class="emp">'.lang('space','block_album_no_content').($space['self'] ? lang('space', 'block_album_no_content_publish', $space) : '').'</p>';
}
} else {
$html .= '<li>'.lang('space','block_view_noperm').'</li>';
}
$html = '<ul class="ml cl">'.$html.'</ul>';
break;
case 'feed':
$do = 'home';
$view = 'me';
$from = 'space';
if(!IS_ROBOT && ckprivacy('feed', 'view')) {
require_once libfile('function/feed');
$query = C::t('home_feed')->fetch_all_by_uid_dateline($uid, false, 0, $shownum);
foreach($query as $value) {
if(ckfriend($value['uid'], $value['friend'], $value['target_ids'])) {
$html .= mkfeedhtml(mkfeed($value));
}
}
}
$contenttagname = 'ul';
$contentclassname = ' el';
$html = !$html ? '<p class="emp">'.lang('space','block_feed_no_content').'</p>' : $html;
break;
case 'thread':
$do = $blockname;
$view = 'me';
$from = 'space';
if ($_G['setting']['allowviewuserthread'] !== -1) {
$fidsql = empty($_G['setting']['allowviewuserthread']) ? '' : " AND fid IN({$_G['setting']['allowviewuserthread']}) ";
$viewfids = str_replace("'", '', $_G['setting']['allowviewuserthread']);
if(!empty($viewfids)) {
$viewfids = explode(',', $viewfids);
}
foreach(C::t('forum_thread')->fetch_all_by_authorid_displayorder($uid, 0, '>=', null, '', 0, $shownum, null, $viewfids ? $viewfids : null) as $thread) {
if($thread['author']) {
$html .= "<li><a href=\"forum.php?mod=viewthread&tid={$thread['tid']}\" target=\"_blank\">{$thread['subject']}</a></li>";
}
}
}
$html = !$html ? '<p class="emp">'.lang('space','block_thread_no_content').($space['self'] ? lang('space', 'block_thread_no_content_publish', $space) : '').'</p>' : '<ul class="xl">'.$html.'</ul>';
break;
case 'friend':
$do = $blockname;
$view = 'me';
$from = 'space';
require_once libfile('function/friend');
$friendlist = array();
$friendlist = friend_list($uid, $shownum);
$fuids = array_keys($friendlist);
getonlinemember($fuids);
foreach ($friendlist as $key => $value) {
$classname = $_G['ols'][$value['fuid']]?'gol':'';
$html .= '<li><a href="home.php?mod=space&uid='.$value['fuid'].'" target="_blank" class="avt"><em class="'.$classname.'"></em>'.avatar($value['fuid'],'small').'</a><p><a href="home.php?mod=space&uid='.$value['fuid'].'" target="_blank">'.$value['fusername'].'</a></p></li>';
}
$html = !$html ? '<p class="emp">'.lang('space','block_friend_no_content').($space['self'] ? lang('space', 'block_friend_no_content_publish', $space) : '').'</p>' : '<ul class="ml mls cl">'.$html.'</ul>';
break;
case 'visitor':
if($space['self']) {
$do = 'friend';
$view = 'visitor';
}
$list = $fuids = array();
foreach(C::t('home_visitor')->fetch_all_by_uid($uid, $shownum) as $value) {
$list[] = $value;
$fuids[] = $value['vuid'];
}
getonlinemember($fuids);
foreach($list as $value) {
$html .= "<li>";
if ($value['vusername'] == '') {
$html .= lang('space', 'visitor_anonymity');
} else {
$html .= lang('space', 'visitor_list', array(
'uid' => $value['vuid'],
'cuid' => $uid,
'username' => $value['vusername'],
'class' => ($_G['ols'][$value['vuid']]?'gol':''),
'self' => $value['vuid'] == $_G['uid'] ? 'god' : '',
'avatar' => avatar($value['vuid'],'small')));
}
$html .= "<span class=\"xg2\">".dgmdate($value['dateline'],'u', '9999', 'Y-m-d')."</span>";
$html .= "</li>";
}
$html = !$html ? '<p class="emp">'.lang('space','block_visitor_no_content').($space['self'] ? lang('space', 'block_visitor_no_content_publish', $space) : '').'</p>' : '<ul class="ml mls cl">'.$html.'</ul>';
break;
case 'share':
$do = $blockname;
$view = 'me';
$from = 'space';
if(!IS_ROBOT && ckprivacy('share', 'view')) {
require_once libfile('function/share');
foreach(C::t('home_share')->fetch_all_by_uid($uid, 0, $shownum) as $value) {
$value = mkshare($value);
$html .= '<li><em><a href="home.php?mod=space&uid='.$value['uid'].'&do=share&id='.$value['sid'].'">'.$value['title_template'].'</a>('.dgmdate($value['dateline'], 'u').')</em><div class="ec cl">';
if ($value['image']) {
$html .= '<a href="'.$value['image_link'].'" target="_blank"><img src="'.$value['image'].'" class="tn" alt="" /></a>';
}
$html .= '<div class="d">'.$value['body_template'].'</div>';
if ($value['type'] == 'video') {
if(!empty($value['body_data']['imgurl'])) {
$html .= '<table class="mtm" title="'.lang('space', 'click_play').'" onclick="javascript:showFlash(\''.$value['body_data']['host'].'\', \''.$value['body_data']['flashvar'].'\', this, \''.$value['sid'].'\');"><tr><td class="vdtn hm" style="background: url('.$value['body_data']['imgurl'].') no-repeat"><img src="'.STATICURL.'image/common/vds.png" alt="'.lang('space', 'click_play').'" /></td></tr></table>';
} else {
$html .= "<img src=\"".STATICURL."/image/common/vd.gif\" alt=\"".lang('space', 'click_play')."\" onclick=\"javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['sid']}');\" class=\"tn\" />";
}
}elseif ($value['type'] == 'music') {
$html .= "<img src=\"".STATICURL."/image/common/music.gif\" alt=\"".lang('space', 'click_play')."\" onclick=\"javascript:showFlash('music', '{$value['body_data']['musicvar']}', this, '{$value['sid']}');\" class=\"tn\" />";
}elseif ($value['type'] == 'flash') {
$html .= "<img src=\"".STATICURL."/image/common/flash.gif\" alt=\"".lang('space', 'click_view')."\" onclick=\"javascript:showFlash('flash', '{$value['body_data']['flashaddr']}', this, '{$value['sid']}');\" class=\"tn\" />";
}
if ($value['body_general']) {
$html .= '<div class="quote'.($value['image'] ? 'z' : '')."\"><blockquote>{$value['body_general']}</blockquote></div>";
}
$html .= '</div></li>';
}
$html = !$html ? '<p class="emp">'.lang('space','block_share_no_content').'</p>' : '<ul class="el">'.$html.'</ul>';
}
break;
case 'wall':
$do = $blockname;
$walllist = array();
if(ckprivacy('wall', 'view')) {
$query = C::t('home_comment')->fetch_all_by_id_idtype($uid, 'uid', 0, $shownum, '', 'DESC');
foreach($query as $value) {
$value['message'] = strlen($value['message'])>500? getstr($value['message'], 500, 0, 0, 0, -1).' ...':$value['message'];
if($value['status'] == 0 || $value['authorid'] == $_G['uid']) {
$walllist[] = $value;
}
}
}
foreach ($walllist as $key => $value) {
$op = '';
if ($value['author']) {
$author_avatar = '<a href="home.php?mod=space&uid='.$value['authorid'].'" target="_blank">'.avatar($value['authorid'],'small').'</a>';
$author = '<a href="home.php?mod=space&uid='.$value['authorid'].'" id="author_'.$value['cid'].'" target="_blank">'.$value['author'].'</a>';
}else {
$author_avatar = '<img src="'.STATICURL.'image/magic/hidden.gif" alt="hidden" />';
$author = $_G['setting']['anonymoustext'];
}
if ($value['authorid']==$_G['uid']) {
$op .= lang('space', 'wall_edit', array('cid'=>$value['cid']));
}
if ($value['authorid']==$_G['uid'] || $space['self'] || checkperm('managecomment')){
$op .= lang('space', 'wall_del', array('cid'=>$value['cid']));
}
if ($value['authorid']!=$_G['uid'] && ($value['idtype'] != 'uid' || $space['self'])) {
$op .= lang('space', 'wall_reply', array('cid'=>$value['cid']));
}
$moderate_need = $value['status'] == 1 ? lang('template', 'moderate_need') : '';
$date = dgmdate($value['dateline'], 'u');
$replacearr = array('author'=>$author, 'author_avatar' => $author_avatar, 'moderated' => $moderate_need, 'cid' => $value['cid'], 'message'=> $value['message'] , 'date' => $date, 'op'=> $op);
$html .= lang('space', 'wall_li', $replacearr);
}
$html = !empty($walllist) ? $html.lang('space', 'wall_more', array('uid'=>$uid)) : '<p class="emp">'.lang('space','block_wall_no_content').'</p>';
$html = '<div class="xld xlda el" id="comment_ul">'.$html.'</div>';
if(helper_access::check_module('wall')) {
$html = lang('space', 'wall_form', array('uid' => $uid, 'FORMHASH'=>FORMHASH)).'<hr class="da mtm m0">'.$html;
}
$titlemore = '<span class="y xw0"><a href="home.php?mod=space&uid='.$uid.'&do=wall">'.lang('space', 'all').'</a></span>';
break;
case 'group':
require_once libfile('function/group');
$grouplist = mygrouplist($uid, 'lastupdate', array('f.name', 'ff.icon'), $shownum);
if(empty($grouplist)) $grouplist = array();
foreach ($grouplist as $groupid => $group) {
$group['groupid'] = $groupid;
$html .= lang('space', 'group_li',$group);
}
$html = !$html ? '<p class="emp">'.lang('space','block_group_no_content').($space['self'] ? lang('space', ($_G['group']['allowbuildgroup'] ? 'block_group_no_content_publish' : 'block_group_no_content_join'), $space) : '').'</p>' : '<ul class="ml mls cl">'.$html.'</ul>';
break;
case 'music':
if(!empty($parameters['mp3list'])) {
$authcode = substr(md5($_G['authkey'].$uid), 6, 16);
$view = ($_G['adminid'] == 1 && $_G['setting']['allowquickviewprofile']) ? '&view=admin' : '';
$querystring = "home.php?mod=space&uid=$uid&do=index&op=getmusiclist&hash=$authcode$view&t=".TIMESTAMP;
$height = (empty($parameters['config']['height']) && $parameters['config']['height'] !== 0) ? 200 : $parameters['config']['height'];
$html = "<script type=\"text/javascript\">appendstyle(STATICURL + 'js/player/aplayer.min.css');appendscript(STATICURL + 'js/player/aplayer.min.js');spaceMusicPlayer('$querystring', '$height');</script>";
} else {
$html = lang('space', 'music_no_content');
}
$html = '<div class="ml mls cl">'.$html.'</div>';
break;
case 'block1':
case 'block2':
case 'block3':
case 'block4':
case 'block5':
if($space['self']) {
$_G['space_group'] = $_G['group'];
} elseif(empty($_G['space_group'])) {
$_G['space_group'] = C::t('common_usergroup_field')->fetch($space['groupid']);
}
require_once libfile('function/discuzcode');
if ($_G['space_group']['allowspacediyimgcode']) {
if (empty($_G['cache']['smilies']['loaded'])) {
loadcache(array('smilies', 'smileytypes'));
foreach($_G['cache']['smilies']['replacearray'] AS $skey => $smiley) {
$_G['cache']['smilies']['replacearray'][$skey] = '[img]'.$_G['siteurl'].'static/image/smiley/'.$_G['cache']['smileytypes'][$_G['cache']['smilies']['typearray'][$skey]]['directory'].'/'.$smiley.'[/img]';
}
$_G['cache']['smilies']['loaded'] = 1;
}
$parameters['content'] = preg_replace($_G['cache']['smilies']['searcharray'], $_G['cache']['smilies']['replacearray'], trim($parameters['content']));
}
if ($_G['space_group']['allowspacediybbcode'] || $_G['space_group']['allowspacediyimgcode'] || $_G['space_group']['allowspacediyhtml'] ){
$parameters['content'] = discuzcode($parameters['content'], 1, 0, 1, 0, $_G['space_group']['allowspacediybbcode'], $_G['space_group']['allowspacediyimgcode'], $_G['space_group']['allowspacediyhtml']);
} else {
$parameters['content'] = dhtmlspecialchars($parameters['content']);
}
$parameters['content'] = nl2br($parameters['content']);
if (empty ($parameters['content'])) $parameters['content'] = lang('space',$blockname);
$html .= $parameters['content'];
break;
default:
return false;
}
if (isset($parameters['title'])) {
if(empty($parameters['title'])) {
$title = '';
} else {
$view = $view === false ? '' : '&view='.$view;
$from = $from === false ? '' : '&from='.$from;
$bnamelink = $do ? '<a href="home.php?mod=space&uid='.$uid.'&do='.$do.$view.$from.'">'.$parameters['title'].'</a>' : $parameters['title'];
$title = lang('space', 'block_title', array('bname' => $bnamelink, 'more' => $titlemore));
}
} else {
$view = $view === false ? '' : '&view='.$view;
$from = $from === false ? '' : '&from='.$from;
$bnamelink = $do ? '<a href="home.php?mod=space&uid='.$uid.'&do='.$do.$view.$from.'">'.getblockdata($blockname).'</a>' : getblockdata($blockname);
$title = lang('space', 'block_title', array('bname' => $bnamelink, 'more' => $titlemore));
}
$html = $title.'<'.$contenttagname.' id="'.$blockname.'_content" class="dxb_bc'.$contentclassname.'">'.$html.'</'.$contenttagname.'>';
return $html;
}
function mkfeedhtml($value) {
global $_G;
$_GET['uid'] = intval($_GET['uid']);
$_GET['view'] = dhtmlspecialchars($_GET['view']);
$html = '';
$html .= "<li class=\"cl {$value['magic_class']}\" id=\"feed_{$value['feedid']}_li\">";
$html .= "<div class=\"cl\" {$value['style']}>";
$html .= "<a class=\"t\" href=\"home.php?mod=space&uid={$_GET['uid']}&do=home&view={$_GET['view']}&icon={$value['icon']}\" title=\"".lang('space', 'feed_view_only')."\"><img src=\"{$value['icon_image']}\" /></a>{$value['title_template']}";
$html .= "\t<span class=\"xg1\">".dgmdate($value['dateline'], 'n-j H:i')."</span>";
$html .= "<div class=\"ec\">";
if ($value['image_1']) {
$html .= "<a href=\"{$value['image_1_link']}\"{$value['target']}><img src=\"{$value['image_1']}\" alt=\"\" class=\"tn\" /></a>";
}
if ($value['image_2']) {
$html .= "<a href=\"{$value['image_2_link']}}\"{$value['target']}><img src=\"{$value['image_2']}\" alt=\"\" class=\"tn\" /></a>";
}
if ($value['image_3']) {
$html .= "<a href=\"{$value['image_3_link']}\"{$value['target']}><img src=\"{$value['image_3']}\" alt=\"\" class=\"tn\" /></a>";
}
if ($value['image_4']) {
$html .= "<a href=\"{$value['image_4_link']}\"{$value['target']}><img src=\"{$value['image_4']}\" alt=\"\" class=\"tn\" /></a>";
}
if ($value['body_template']) {
$style = $value['image_3'] ? ' style="clear: both; zoom: 1;"' : '';
$html .= "<div class=\"d\" $style>{$value['body_template']}</div>";
}
if (!empty($value['body_data']['flashvar'])) {
if(!empty($value['body_data']['imgurl'])) {
$html .= '<table class="mtm" title="'.lang('space', 'click_play').'" onclick="javascript:showFlash(\''.$value['body_data']['host'].'\', \''.$value['body_data']['flashvar'].'\', this, \''.$value['sid'].'\');"><tr><td class="vdtn hm" style="background: url('.$value['body_data']['imgurl'].') no-repeat"><img src="'.STATICURL.'image/common/vds.png" alt="'.lang('space', 'click_play').'" /></td></tr></table>';
} else {
$html .= "<img src=\"".STATICURL."/image/common/vd.gif\" alt=\"".lang('space', 'click_play')."\" onclick=\"javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['sid']}');\" class=\"tn\" />";
}
}elseif (!empty($value['body_data']['musicvar'])) {
$html .= "<img src=\"".STATICURL."/image/common/music.gif\" alt=\"".lang('space', 'click_play')."\" onclick=\"javascript:showFlash('music', '{$value['body_data']['musicvar']}', this, '{$value['feedid']}');\" class=\"tn\" />";
}elseif (!empty($value['body_data']['flashaddr'])) {
$html .= "<img src=\"".STATICURL."/image/common/flash.gif\" alt=\"".lang('space', 'click_view')."\" onclick=\"javascript:showFlash('flash', '{$value['body_data']['flashaddr']}', this, '{$value['feedid']}');\" class=\"tn\" />";
}
if ($value['body_general']) {
$classname = $value['image_1'] ? ' z' : '';
$html .= "<div class=\"quote$classname\"><blockquote>{$value['body_general']}</blockquote></div>";
}
$html .= "</div>";
$html .= "</div>";
$html .= "</li>";
return $html;
}
function &getlayout($layout='') {
$layoutarr = array(
'1:2:1' => array('300', '600', '300'),
'1:1:2' => array('300', '300', '600'),
'2:1:1' => array('600', '300', '300'),
'2:2' => array('600', '600'),
'1:3' => array('300', '900'),
'3:1' => array('900', '300'),
'1:4' => array('240', '960'),
'4:1' => array('960', '240'),
'2:2:1' => array('480', '480', '240'),
'1:2:2' => array('240', '480', '480'),
'1:1:3' => array('240', '240', '720'),
'1:3:1' => array('240', '720', '240'),
'3:1:1' => array('720', '240', '240'),
'3:2' => array('720', '480'),
'2:3' => array('480', '720')
);
if (!empty($layout)) {
$rt = (isset($layoutarr[$layout])) ? $layoutarr[$layout] : false;
} else {
$rt = $layoutarr;
}
return $rt;
}
function getblockdata($blockname = '') {
$blockarr = lang('space', 'blockdata');
$r = empty($blockname) ? $blockarr : (isset($blockarr[$blockname]) ? $blockarr[$blockname] : false);
return $r;
}
function check_ban_block($blockname, $space) {
global $_G;
$return = true;
loadcache('usergroup_'.$space['groupid']);
if($blockname == 'group' && !helper_access::check_module('group')) {
$return = false;
} elseif($blockname == 'thread' && $_G['setting']['allowviewuserthread'] === -1) {
$return = false;
}
return $return;
}
?>

View File

@@ -0,0 +1,705 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_spacecp.php 36294 2016-12-14 03:11:30Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function album_creat_by_id($albumid, $catid = 0) {
global $_G, $space;
if(!$_G['uid']) {
return 0;
}
preg_match("/^new\:(.+)$/i", $albumid, $matchs);
if(!empty($matchs[1])) {
$albumname = dhtmlspecialchars(trim($matchs[1]));
if(empty($albumname)) $albumname = dgmdate($_G['timestamp'],'Ymd');
$albumarr = array('albumname' => $albumname);
if($catid) {
$albumarr['catid'] = $catid;
}
$albumid = album_creat($albumarr);
} else {
$albumid = intval($albumid);
if($albumid) {
$value = C::t('home_album')->fetch_all_by_uid($_G['uid'], false, 0, 0, $albumid);
if($value = $value[0]) {
$albumname = addslashes($value['albumname']);
$albumfriend = $value['friend'];
} else {
$albumname = dgmdate($_G['timestamp'],'Ymd');
$albumarr = array('albumname' => $albumname);
if($catid) {
$albumarr['catid'] = $catid;
}
$albumid = album_creat($albumarr);
}
}
}
return $albumid;
}
function album_update_pic($albumid, $picid=0) {
global $_G;
$setarr = array();
if(!$picid) {
$piccount = C::t('home_pic')->check_albumpic($albumid, 0);
if(empty($piccount) && C::t('home_pic')->check_albumpic($albumid) == 0) {
C::t('home_album')->delete($albumid);
return false;
} else {
$setarr['picnum'] = $piccount;
}
}
$query = C::t('home_pic')->fetch_all_by_albumid($albumid, 0, 1, $picid, 1);
if(!$pic = $query[0]) {
return false;
}
$from = $pic['remote'];
$pic['remote'] = $pic['remote'] > 1 ? $pic['remote'] - 2 : $pic['remote'];
$basedir = !getglobal('setting/attachdir') ? (DISCUZ_ROOT.'./data/attachment/') : getglobal('setting/attachdir');
$picdir = 'cover/'.substr(md5($albumid), 0, 2).'/';
dmkdir($basedir.'./album/'.$picdir);
if($pic['remote']) {
$picsource = pic_get($pic['filepath'], $from > 1 ? 'forum' : 'album', $pic['thumb'], $pic['remote'], 0);
} else {
$picsource = $basedir.'./'.($from > 1 ? 'forum' : 'album').'/'.$pic['filepath'];
}
require_once libfile('class/image');
$image = new image();
if($image->Thumb($picsource, 'album/'.$picdir.$albumid.'.jpg', 300, 300, 2)) {
$setarr['pic'] = $picdir.$albumid.'.jpg';
$setarr['picflag'] = 1;
if(ftpperm('jpg', filesize($_G['setting']['attachdir'].'album/'.$picdir.$albumid.'.jpg'))) {
if(ftpcmd('upload', 'album/'.$picdir.$albumid.'.jpg')) {
$setarr['picflag'] = 2;
@unlink($_G['setting']['attachdir'].'album/'.$picdir.$albumid.'.jpg');
}
}
} else {
if($pic['status'] == 0) {
$setarr['pic'] = $pic['thumb'] ? getimgthumbname($pic['filepath']) : $pic['filepath'];
}
if($from > 1) {
$setarr['picflag'] = $pic['remote'] ? 4:3;
} else {
$setarr['picflag'] = $pic['remote'] ? 2:1;
}
}
$setarr['updatetime'] = $_G['timestamp'];
C::t('home_album')->update($albumid, $setarr);
return true;
}
function pic_save($FILE, $albumid, $title, $iswatermark = true, $catid = 0) {
global $_G, $space;
if($albumid<0) $albumid = 0;
$allowpictype = array('jpg','jpeg','gif','png');
$upload = new discuz_upload();
$upload->init($FILE, 'album');
if($upload->error()) {
return lang('spacecp', 'lack_of_access_to_upload_file_size');
}
if(!$upload->attach['isimage']) {
return lang('spacecp', 'only_allows_upload_file_types');
}
$oldgid = $_G['groupid'];
if(empty($space)) {
$_G['member'] = $space = getuserbyuid($_G['uid']);
$_G['username'] = $space['username'];
$_G['groupid'] = $space['groupid'];
}
$_G['member'] = $space;
loadcache('usergroup_'.$space['groupid'], $oldgid != $_G['groupid'] ? true : false);
$_G['group'] = $_G['cache']['usergroup_'.$space['groupid']];
if(!checkperm('allowupload')) {
return lang('spacecp', 'not_allow_upload');
}
if(!cknewuser(1)) {
if($_G['setting']['newbiespan'] && $_G['timestamp'] - $_G['member']['regdate'] < $_G['setting']['newbiespan'] * 60) {
return lang('message', 'no_privilege_newbiespan', array('newbiespan' => $_G['setting']['newbiespan']));
}
if($_G['setting']['need_avatar'] && empty($_G['member']['avatarstatus'])) {
return lang('message', 'no_privilege_avatar');
}
if($_G['setting']['need_secmobile'] && empty($_G['member']['secmobilestatus'])) {
return lang('message', 'no_privilege_secmobile');
}
if($_G['setting']['need_email'] && empty($_G['member']['emailstatus'])) {
return lang('message', 'no_privilege_email');
}
if($_G['setting']['need_friendnum']) {
space_merge($_G['member'], 'count');
if($_G['member']['friends'] < $_G['setting']['need_friendnum']) {
return lang('message', 'no_privilege_friendnum', array('friendnum' => $_G['setting']['need_friendnum']));
}
}
}
if($_G['group']['maximagesize'] && $upload->attach['size'] > $_G['group']['maximagesize']) {
return lang('spacecp', 'files_can_not_exceed_size', array('extend' => $upload->attach['ext'], 'size' => sizecount($_G['group']['maximagesize'])));
}
$maxspacesize = checkperm('maxspacesize');
if($maxspacesize) {
space_merge($space, 'count');
space_merge($space, 'field_home');
if($space['attachsize'] + $upload->attach['size'] > $maxspacesize + $space['addsize'] * 1024 * 1024) {
return lang('spacecp', 'inadequate_capacity_space');
}
}
$showtip = true;
$albumfriend = 0;
if($albumid) {
$catid = intval($catid);
$albumid = album_creat_by_id($albumid, $catid);
} else {
$albumid = 0;
$showtip = false;
}
$upload->save();
if($upload->error()) {
return lang('spacecp', 'mobile_picture_temporary_failure');
}
if(!$upload->attach['imageinfo'] || !in_array($upload->attach['imageinfo']['2'], array(1,2,3,6))) {
@unlink($upload->attach['target']);
return lang('spacecp', 'only_allows_upload_file_types');
}
$new_name = $upload->attach['target'];
require_once libfile('class/image');
$image = new image();
$result = $image->Thumb($new_name, '', 140, 140, 1);
$thumb = empty($result)?0:1;
if($_G['setting']['maxthumbwidth'] && $_G['setting']['maxthumbheight']) {
if($_G['setting']['maxthumbwidth'] < 300) $_G['setting']['maxthumbwidth'] = 300;
if($_G['setting']['maxthumbheight'] < 300) $_G['setting']['maxthumbheight'] = 300;
$image->Thumb($new_name, '', $_G['setting']['maxthumbwidth'], $_G['setting']['maxthumbheight'], 1, 1);
}
if ($iswatermark) {
$image->Watermark($new_name, '', 'album');
}
$pic_remote = 0;
$album_picflag = 1;
if(ftpperm($upload->attach['ext'], $upload->attach['size'])) {
$ftpresult_thumb = 0;
$ftpresult = ftpcmd('upload', 'album/'.$upload->attach['attachment']);
if($ftpresult) {
@unlink($_G['setting']['attachdir'].'album/'.$upload->attach['attachment']);
if($thumb) {
$thumbpath = getimgthumbname($upload->attach['attachment']);
ftpcmd('upload', 'album/'.$thumbpath);
@unlink($_G['setting']['attachdir'].'album/'.$thumbpath);
}
$pic_remote = 1;
$album_picflag = 2;
} else {
if(getglobal('setting/ftp/mirror')) {
@unlink($upload->attach['target']);
@unlink(getimgthumbname($upload->attach['target']));
return lang('spacecp', 'ftp_upload_file_size');
}
}
}
$title = getstr($title, 200);
$title = censor($title, NULL, TRUE, FALSE);
if(is_array($title)) {
return lang('message', 'word_banned');
}
if(censormod($title) || $_G['group']['allowuploadmod']) {
$pic_status = 1;
} else {
$pic_status = 0;
}
$setarr = array(
'albumid' => $albumid,
'uid' => $_G['uid'],
'username' => $_G['username'],
'dateline' => $_G['timestamp'],
'filename' => addslashes($upload->attach['name']),
'postip' => $_G['clientip'],
'port' => $_G['remoteport'],
'title' => $title,
'type' => addslashes($upload->attach['ext']),
'size' => $upload->attach['size'],
'filepath' => $upload->attach['attachment'],
'thumb' => $thumb,
'remote' => $pic_remote,
'status' => $pic_status,
);
$setarr['picid'] = C::t('home_pic')->insert($setarr, 1);
C::t('common_member_count')->increase($_G['uid'], array('attachsize' => $upload->attach['size']));
include_once libfile('function/stat');
if($pic_status) {
updatemoderate('picid', $setarr['picid']);
}
updatestat('pic');
return $setarr;
}
function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name='', $title='', $delsize=0, $from = false) {
global $_G, $space;
if($albumid<0) $albumid = 0;
$allowPicType = array('jpg','jpeg','gif','png');
if(!in_array($fileext, $allowPicType)) {
return -3;
}
$setarr = array();
$upload = new discuz_upload();
$filepath = $upload->get_target_dir('album').$upload->get_target_filename('album').'.'.$fileext;
$newfilename = $_G['setting']['attachdir'].'./album/'.$filepath;
if($handle = fopen($newfilename, 'wb')) {
if(fwrite($handle, $strdata) !== FALSE) {
fclose($handle);
$size = filesize($newfilename);
if(empty($space)) {
$_G['member'] = $space = getuserbyuid($_G['uid']);
$_G['username'] = $space['username'];
}
$_G['member'] = $space;
loadcache('usergroup_'.$space['groupid']);
$_G['group'] = $_G['cache']['usergroup_'.$space['groupid']];
$maxspacesize = checkperm('maxspacesize');
if($maxspacesize) {
space_merge($space, 'count');
space_merge($space, 'field_home');
if($space['attachsize'] + $size - $delsize > $maxspacesize + $space['addsize'] * 1024 * 1024) {
@unlink($newfilename);
return -1;
}
}
if(!$upload->get_image_info($newfilename)) {
@unlink($newfilename);
return -2;
}
require_once libfile('class/image');
$image = new image();
$result = $image->Thumb($newfilename, NULL, 140, 140, 1);
$thumb = empty($result)?0:1;
$image->Watermark($newfilename);
$pic_remote = 0;
$album_picflag = 1;
if(ftpperm($fileext, filesize($_G['setting']['attachdir'].'album/'.$filepath))) {
$ftpresult_thumb = 0;
$ftpresult = ftpcmd('upload', 'album/'.$filepath);
if($ftpresult) {
@unlink($_G['setting']['attachdir'].'album/'.$filepath);
if($thumb) {
$thumbpath = getimgthumbname($filepath);
ftpcmd('upload', 'album/'.$thumbpath);
@unlink($_G['setting']['attachdir'].'album/'.$thumbpath);
}
$pic_remote = 1;
$album_picflag = 2;
} else {
if(getglobal('setting/ftp/mirror')) {
@unlink($newfilename);
@unlink(getimgthumbname($newfilename));
return -3;
}
}
}
$filename = $name ? $name : substr(strrchr($filepath, '/'), 1);
$title = getstr($title, 200);
$title = censor($title, NULL, TRUE, FALSE);
if(is_array($title)) {
return lang('message', 'word_banned');
}
if(censormod($title) || $_G['group']['allowuploadmod']) {
$pic_status = 1;
} else {
$pic_status = 0;
}
if($albumid) {
$albumid = album_creat_by_id($albumid);
} else {
$albumid = 0;
}
$setarr = array(
'albumid' => $albumid,
'uid' => $_G['uid'],
'username' => $_G['username'],
'dateline' => $_G['timestamp'],
'filename' => $filename,
'postip' => $_G['clientip'],
'port' => $_G['remoteport'],
'title' => $title,
'type' => $fileext,
'size' => $size,
'filepath' => $filepath,
'thumb' => $thumb,
'remote' => $pic_remote,
'status' => $pic_status,
);
$setarr['picid'] = C::t('home_pic')->insert($setarr, 1);
C::t('common_member_count')->increase($_G['uid'], array('attachsize' => $size));
include_once libfile('function/stat');
updatestat('pic');
return $setarr;
} else {
fclose($handle);
}
}
return -3;
}
function album_creat($arr) {
global $_G;
$albumid = C::t('home_album')->fetch_albumid_by_albumname_uid($arr['albumname'], $_G['uid']);
if($albumid) {
return $albumid;
} else {
$arr['uid'] = $_G['uid'];
$arr['username'] = $_G['username'];
$arr['dateline'] = $arr['updatetime'] = $_G['timestamp'];
$albumid = C::t('home_album')->insert($arr, TRUE);
C::t('common_member_count')->increase($_G['uid'], array('albums' => 1));
if(isset($arr['catid']) && $arr['catid']) {
C::t('home_album_category')->update_num_by_catid('1', $arr['catid']);
}
return $albumid;
}
}
function getfilepath($fileext, $mkdir=false) {
global $_G;
$filepath = "{$_G['uid']}_{$_G['timestamp']}".random(4).".$fileext";
$name1 = gmdate('Ym');
$name2 = gmdate('j');
if($mkdir) {
$newfilename = $_G['setting']['attachdir'].'./album/'.$name1;
if(!is_dir($newfilename)) {
if(!@mkdir($newfilename)) {
runlog('error', "DIR: $newfilename can not make");
return $filepath;
}
}
$newfilename .= '/'.$name2;
if(!is_dir($newfilename)) {
if(!@mkdir($newfilename)) {
runlog('error', "DIR: $newfilename can not make");
return $name1.'/'.$filepath;
}
}
}
return $name1.'/'.$name2.'/'.$filepath;
}
function getalbumpic($uid, $id) {
global $_G;
$pic = C::t('home_pic')->fetch_album_pic($id, $uid);
if($pic) {
return $pic['thumb'] ? getimgthumbname($pic['filepath']) : $pic['filepath'];
} else {
return '';
}
}
function getclassarr($uid) {
global $_G;
$classarr = array();
$query = C::t('home_class')->fetch_all_by_uid($uid);
foreach($query as $value) {
$classarr[$value['classid']] = $value;
}
return $classarr;
}
function getalbums($uid) {
global $_G;
$albums = array();
$query = C::t('home_album')->fetch_all_by_uid($uid, 'albumid');
foreach($query as $value) {
$albums[$value['albumid']] = $value;
}
return $albums;
}
function hot_update($idtype, $id, $hotuser) {
global $_G;
$hotusers = empty($hotuser)?array():explode(',', $hotuser);
if($hotusers && in_array($_G['uid'], $hotusers)) {
return false;
} else {
$hotusers[] = $_G['uid'];
$hotuser = implode(',', $hotusers);
}
$hotuser = daddslashes($hotuser);
$newhot = count($hotusers)+1;
if($newhot == $_G['setting']['feedhotmin']) {
$tablename = gettablebyidtype($idtype);
if($tablename) {
$item = C::t($tablename)->fetch_by_id_idtype($id);
$itemuid = $item['uid'];
updatecreditbyaction('hotinfo', $itemuid);
}
}
switch ($idtype) {
case 'blogid':
C::t('home_blogfield')->update($id, array('hotuser' => $hotuser));
C::t('home_blog')->increase($id, 0, array('hot' => 1));
break;
case 'picid':
C::t('home_picfield')->insert(array('picid' => $id, 'hotuser' => $hotuser), 0, 1);
C::t('home_pic')->update_hot($id);
break;
case 'sid':
C::t('home_share')->update_hot_by_sid($id, $hotuser);
break;
default:
return false;
}
if($feed = C::t('home_feed')->fetch_feed($id, $idtype)) {
if(empty($feed['friend'])) {
C::t('home_feed')->update_hot_by_feedid($feed['feedid'], 1);
}
} elseif($idtype == 'picid') {
require_once libfile('function/feed');
feed_publish($id, $idtype);
}
return true;
}
function gettablebyidtype($idtype) {
$tablename = '';
if($idtype == 'blogid') {
$tablename = 'home_blog';
} elseif($idtype == 'picid') {
$tablename = 'home_pic';
} elseif($idtype == 'sid') {
$tablename = 'home_share';
}
return $tablename;
}
function privacy_update() {
global $_G, $space;
C::t('common_member_field_home')->update($_G['uid'], array('privacy'=>serialize($space['privacy'])));
}
function ckrealname($return=0) {
global $_G;
$result = true;
if($_G['adminid'] != 1 && $_G['setting']['verify'][6]['available'] && empty($_G['setting']['verify'][6]['viewrealname'])) {
space_merge($_G['member'], 'profile');
space_merge($_G['member'], 'verify');
if(empty($_G['member']['realname']) || !$_G['member']['verify6']) {
if(empty($return)) showmessage('no_privilege_realname', '', array(), array('return' => true));
$result = false;
}
}
return $result;
}
function isblacklist($touid) {
global $_G;
return C::t('home_blacklist')->count_by_uid_buid($touid, $_G['uid']);
}
function emailcheck_send($uid, $email) {
global $_G;
if($uid && $email) {
$memberauthstr = C::t('common_member_field_forum')->fetch($uid);
if(!empty($memberauthstr['authstr'])) {
list($dateline) = explode("\t", $memberauthstr['authstr']);
$interval = $_G['setting']['mailinterval'] > 0 ? (int)$_G['setting']['mailinterval'] : 300;
if($dateline && $dateline > TIMESTAMP - $interval) {
return false;
}
}
$timestamp = $_G['timestamp'];
$idstring = substr(md5($email), 0, 6);
C::t('common_member_field_forum')->update($uid, array('authstr' => "$timestamp\t3\t$idstring"));
$hash = authcode("$uid\t$email\t$timestamp", 'ENCODE', md5(substr(md5($_G['config']['security']['authkey']), 0, 16)));
$verifyurl = $_G['setting']['securesiteurl'].'home.php?mod=misc&amp;ac=emailcheck&amp;hash='.urlencode($hash);
$mailmessage = array(
'tpl' => 'email_verify',
'var' => array(
'username' => $_G['member']['username'],
'bbname' => $_G['setting']['bbname'],
'siteurl' => $_G['setting']['securesiteurl'],
'url' => $verifyurl
)
);
require_once libfile('function/mail');
if(!sendmail($email, $mailmessage)) {
runlog('sendmail', "$email sendmail failed.");
}
}
return true;
}
function picurl_get($picurl, $maxlenth='200') {
$picurl = dhtmlspecialchars(trim($picurl));
if($picurl) {
if(preg_match("/^http\:\/\/.{5,$maxlenth}\.(jpg|gif|png)$/i", $picurl)) return $picurl;
}
return '';
}
function avatar_file($uid, $size) {
global $_G;
$var = "home_avatarfile_{$uid}_{$size}";
if(empty($_G[$var])) {
$uid = abs(intval($uid));
$uid = sprintf("%09d", $uid);
$dir1 = substr($uid, 0, 3);
$dir2 = substr($uid, 3, 2);
$dir3 = substr($uid, 5, 2);
$_G[$var] = $dir1.'/'.$dir2.'/'.$dir3.'/'.substr($uid, -2)."_avatar_$size.jpg";
}
return $_G[$var];
}
function makepokeaction($iconid) {
global $_G;
$icons = array(
0 => lang('home/template', 'say_hi'),
1 => '<img alt="cyx" src="'.STATICURL.'image/poke/cyx.gif" class="vm" /> '.lang('home/template', 'poke_1'),
2 => '<img alt="wgs" src="'.STATICURL.'image/poke/wgs.gif" class="vm" /> '.lang('home/template', 'poke_2'),
3 => '<img alt="wx" src="'.STATICURL.'image/poke/wx.gif" class="vm" /> '.lang('home/template', 'poke_3'),
4 => '<img alt="jy" src="'.STATICURL.'image/poke/jy.gif" class="vm" /> '.lang('home/template', 'poke_4'),
5 => '<img alt="pmy" src="'.STATICURL.'image/poke/pmy.gif" class="vm" /> '.lang('home/template', 'poke_5'),
6 => '<img alt="yb" src="'.STATICURL.'image/poke/yb.gif" class="vm" /> '.lang('home/template', 'poke_6'),
7 => '<img alt="fw" src="'.STATICURL.'image/poke/fw.gif" class="vm" /> '.lang('home/template', 'poke_7'),
8 => '<img alt="nyy" src="'.STATICURL.'image/poke/nyy.gif" class="vm" /> '.lang('home/template', 'poke_8'),
9 => '<img alt="gyq" src="'.STATICURL.'image/poke/gyq.gif" class="vm" /> '.lang('home/template', 'poke_9'),
10 => '<img alt="dyx" src="'.STATICURL.'image/poke/dyx.gif" class="vm" /> '.lang('home/template', 'poke_10'),
11 => '<img alt="yw" src="'.STATICURL.'image/poke/yw.gif" class="vm" /> '.lang('home/template', 'poke_11'),
12 => '<img alt="ppjb" src="'.STATICURL.'image/poke/ppjb.gif" class="vm" /> '.lang('home/template', 'poke_12'),
13 => '<img alt="yyk" src="'.STATICURL.'image/poke/yyk.gif" class="vm" /> '.lang('home/template', 'poke_13')
);
return isset($icons[$iconid]) ? $icons[$iconid] : $icons[0];
}
function interval_check($type) {
global $_G;
$waittime = 0;
if(checkperm('disablepostctrl')) {
return $waittime;
}
if($_G['setting']['floodctrl']) {
space_merge($_G['member'], 'status');
getuserprofile('lastpost');
$waittime = $_G['setting']['floodctrl'] - ($_G['timestamp'] - $_G['member']['lastpost']);
}
return $waittime;
}
function geturltitle($link, $charset = '') {
$title = $linkcharset = '';
$linkstr = gzfile($link);
$linkstr = implode('', $linkstr);
if(!$charset) {
preg_match('/<meta [^>]*charset="?(.*)"/i', $linkstr, $linkcharset);
$charset = strtolower($linkcharset[1]);
}
if(!$charset) {
return $title;
}
if($charset != strtolower(CHARSET)) {
$linkstr = diconv($linkstr, $charset);
}
if(!empty($linkstr) && preg_match('/\<title\>(.*)\<\/title\>/i', $linkstr, $title)) {
$tmptitle = explode('_', $title[1]);
if($title[1] == $tmptitle[0]) {
$tmptitle = explode('-', $title[1]);
}
$title = trim($tmptitle[0]);
}
return $title;
}
function allowverify($vid = 0) {
global $_G;
if(empty($_G['setting']['verify'])) {
loadcache('setting');
}
$allow = false;
$vid = 0 < $vid && $vid < 8 ? intval($vid) : 0;
if($vid) {
$setting = $_G['setting']['verify'][$vid];
if($setting['available'] && (empty($setting['groupid']) || in_array($_G['groupid'], $setting['groupid']))) {
$allow = true;
}
} else {
foreach($_G['setting']['verify'] as $key => $setting) {
if($setting['available'] && (empty($setting['groupid']) || in_array($_G['groupid'], $setting['groupid']))) {
$allow = true;
break;
}
}
}
return $allow;
}
?>

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