更新到正式版1.0
This commit is contained in:
64
core/function/cache/cache_fields_optional.php
vendored
64
core/function/cache/cache_fields_optional.php
vendored
@@ -1,33 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||
* @license https://www.oaooa.com/licenses/
|
||||
*
|
||||
* @link https://www.oaooa.com
|
||||
* @author zyx(zyx@oaooa.com)
|
||||
*/
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_fields_optional() {
|
||||
$data = array();
|
||||
|
||||
foreach(C::t('user_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);
|
||||
}
|
||||
|
||||
<?php
|
||||
/*
|
||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||
* @license https://www.oaooa.com/licenses/
|
||||
*
|
||||
* @link https://www.oaooa.com
|
||||
* @author zyx(zyx@oaooa.com)
|
||||
*/
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_fields_optional() {
|
||||
$data = array();
|
||||
|
||||
foreach(C::t('user_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);
|
||||
}
|
||||
|
||||
?>
|
||||
50
core/function/cache/cache_fields_register.php
vendored
50
core/function/cache/cache_fields_register.php
vendored
@@ -1,26 +1,26 @@
|
||||
<?php
|
||||
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_fields_register() {
|
||||
$data = array();
|
||||
|
||||
foreach(C::t('user_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);
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_fields_register() {
|
||||
$data = array();
|
||||
|
||||
foreach(C::t('user_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);
|
||||
}
|
||||
|
||||
?>
|
||||
66
core/function/cache/cache_fields_required.php
vendored
66
core/function/cache/cache_fields_required.php
vendored
@@ -1,34 +1,34 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||
* @license https://www.oaooa.com/licenses/
|
||||
*
|
||||
* @link https://www.oaooa.com
|
||||
* @author zyx(zyx@oaooa.com)
|
||||
*/
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
|
||||
function build_cache_fields_required() {
|
||||
$data = array();
|
||||
|
||||
foreach(C::t('user_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);
|
||||
}
|
||||
|
||||
<?php
|
||||
/*
|
||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||
* @license https://www.oaooa.com/licenses/
|
||||
*
|
||||
* @link https://www.oaooa.com
|
||||
* @author zyx(zyx@oaooa.com)
|
||||
*/
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
|
||||
function build_cache_fields_required() {
|
||||
$data = array();
|
||||
|
||||
foreach(C::t('user_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);
|
||||
}
|
||||
|
||||
?>
|
||||
44
core/function/cache/cache_organization.php
vendored
44
core/function/cache/cache_organization.php
vendored
@@ -1,22 +1,22 @@
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_organization() {
|
||||
global $_G;
|
||||
set_time_limit(0);
|
||||
@ini_set("memory_limit","512M");
|
||||
include_once libfile('function/organization');
|
||||
$data=array();
|
||||
/*$query=DB::query("select * from ".DB::table('organization')." where 1 limit 1000");
|
||||
while($value=DB::fetch($query)){
|
||||
//获取此机构下的用户;
|
||||
$value['uids']=C::t('organization_user')->fetch_uids_by_orgid($value['orgid']);//获取部门所有用户(不包括下级)
|
||||
$value['moderators']=C::t('organization_admin')->fetch_moderators_by_orgid($value['orgid']);
|
||||
$data[$value['orgid']]=$value;
|
||||
}*/
|
||||
savecache('organization', $data);
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_organization() {
|
||||
global $_G;
|
||||
set_time_limit(0);
|
||||
@ini_set("memory_limit","512M");
|
||||
include_once libfile('function/organization');
|
||||
$data=array();
|
||||
/*$query=DB::query("select * from ".DB::table('organization')." where 1 limit 1000");
|
||||
while($value=DB::fetch($query)){
|
||||
//获取此机构下的用户;
|
||||
$value['uids']=C::t('organization_user')->fetch_uids_by_orgid($value['orgid']);//获取部门所有用户(不包括下级)
|
||||
$value['moderators']=C::t('organization_admin')->fetch_moderators_by_orgid($value['orgid']);
|
||||
$data[$value['orgid']]=$value;
|
||||
}*/
|
||||
savecache('organization', $data);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
24
core/function/cache/cache_profilesetting.php
vendored
24
core/function/cache/cache_profilesetting.php
vendored
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_profilesetting() {
|
||||
$data = C::t('user_profile_setting')->fetch_all_by_available(1);
|
||||
|
||||
savecache('profilesetting', $data);
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_profilesetting() {
|
||||
$data = C::t('user_profile_setting')->fetch_all_by_available(1);
|
||||
|
||||
savecache('profilesetting', $data);
|
||||
}
|
||||
|
||||
?>
|
||||
298
core/function/cache/cache_setting.php
vendored
298
core/function/cache/cache_setting.php
vendored
@@ -1,149 +1,149 @@
|
||||
<?php
|
||||
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_setting() {
|
||||
global $_G;
|
||||
|
||||
$skipkeys = array('backupdir','custombackup');
|
||||
$serialized = array('verify','unRunExts','iconview','storage','reginput', 'memory', 'secqaa', 'sitemessage','disallowfloat',
|
||||
'seccodedata', 'strongpw','upgrade','desktop_default','loginset','at_range','thumbsize',);
|
||||
|
||||
$data = array();
|
||||
|
||||
foreach(C::t('setting')->fetch_all_not_key($skipkeys) as $setting) {
|
||||
if($setting['skey'] == 'attachdir') {
|
||||
$setting['svalue'] = preg_replace("/\.asp|\\0/i", '0', $setting['svalue']);
|
||||
$setting['svalue'] = str_replace('\\', '/', substr($setting['svalue'], 0, 2) == './' ? DZZ_ROOT.$setting['svalue'] : $setting['svalue']);
|
||||
$setting['svalue'] .= substr($setting['svalue'], -1, 1) != '/' ? '/' : '';
|
||||
} elseif($setting['skey'] == 'attachurl') {
|
||||
$setting['svalue'] .= substr($setting['svalue'], -1, 1) != '/' ? '/' : '';
|
||||
|
||||
} elseif(in_array($setting['skey'], $serialized) || is_serialized($setting['svalue'])) {
|
||||
$setting['svalue'] = @dunserialize($setting['svalue']);
|
||||
if($setting['skey'] == 'search') {
|
||||
foreach($setting['svalue'] as $key => $val) {
|
||||
foreach($val as $k => $v) {
|
||||
$setting['svalue'][$key][$k] = max(0, intval($v));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$_G['setting'][$setting['skey']] = $data[$setting['skey']] = $setting['svalue'];
|
||||
}
|
||||
|
||||
include_once DZZ_ROOT.'./core/core_version.php';
|
||||
$_G['setting']['version'] = $data['version'] = CORE_VERSION;
|
||||
|
||||
$data['sitemessage']['time'] = !empty($data['sitemessage']['time']) ? $data['sitemessage']['time'] * 1000 : 0;
|
||||
|
||||
$data['disallowfloat'] = is_array($data['disallowfloat']) ? implode('|', $data['disallowfloat']) : '';
|
||||
|
||||
if(!$data['imagelib']) unset($data['imageimpath']);
|
||||
|
||||
//$data['iconview']=C::t('iconview')->fetch_all();
|
||||
|
||||
|
||||
$data['seccodedata'] = is_array($data['seccodedata']) ? $data['seccodedata'] : array();
|
||||
if($data['seccodedata']['type'] == 2) {
|
||||
if(extension_loaded('ming')) {
|
||||
unset($data['seccodedata']['background'], $data['seccodedata']['adulterate'],
|
||||
$data['seccodedata']['ttf'], $data['seccodedata']['angle'],
|
||||
$data['seccodedata']['color'], $data['seccodedata']['size'],
|
||||
$data['seccodedata']['animator']);
|
||||
} else {
|
||||
$data['seccodedata']['animator'] = 0;
|
||||
}
|
||||
} elseif($data['seccodedata']['type'] == 99) {
|
||||
$data['seccodedata']['width'] = 50;
|
||||
$data['seccodedata']['height'] = 34;
|
||||
}
|
||||
|
||||
$data['watermarktext'] = !empty($data['watermarktext']) ? ($data['watermarktext']) : array();
|
||||
if($data['watermarktype'] == 'text' && $data['watermarktext']['text']) {
|
||||
if($data['watermarktext']['text'] && strtoupper(CHARSET) != 'UTF-8') {
|
||||
$data['watermarktext']['text'] = diconv($data['watermarktext']['text'], CHARSET, 'UTF-8', true);
|
||||
}
|
||||
$data['watermarktext']['textfull'] = $data['watermarktext']['text'];
|
||||
$data['watermarktext']['text'] = bin2hex($data['watermarktext']['text']);
|
||||
if(file_exists('static/image/seccode/font/en/'.$data['watermarktext']['fontpath'])) {
|
||||
$data['watermarktext']['fontpath'] = 'static/image/seccode/font/en/'.$data['watermarktext']['fontpath'];
|
||||
} elseif(file_exists('static/image/seccode/font/ch/'.$data['watermarktext']['fontpath'])) {
|
||||
$data['watermarktext']['fontpath'] = 'static/image/seccode/font/ch/'.$data['watermarktext']['fontpath'];
|
||||
} else {
|
||||
$data['watermarktext']['fontpath'] = 'static/image/seccode/font/'.$data['watermarktext']['fontpath'];
|
||||
}
|
||||
$data['watermarktext']['color'] = preg_replace_callback('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/', function($matches) {
|
||||
$alpha=hexdec($matches[4]);
|
||||
if($alpha<0 || $alpha>127) $alpha=0;
|
||||
return hexdec($matches[1]).','.hexdec($matches[2]).','.hexdec($matches[3]).','.$alpha; }, $data['watermarktext']['color']);
|
||||
$data['watermarktext']['shadowcolor'] = preg_replace_callback('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/', function($matches) {
|
||||
$alpha=hexdec($matches[4]);
|
||||
if($alpha<0 || $alpha>127) $alpha=0;
|
||||
return hexdec($matches[1]).','.hexdec($matches[2]).','.hexdec($matches[3]).','.$alpha; }, $data['watermarktext']['shadowcolor']);
|
||||
|
||||
$data['watermarktext']['icolor'] = preg_replace_callback('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/', function($matches) {
|
||||
$alpha=hexdec($matches[4]);
|
||||
if($alpha<0 || $alpha>100) $alpha = 1;
|
||||
else $alpha = $alpha/100;
|
||||
return hexdec($matches[1]).','.hexdec($matches[2]).','.hexdec($matches[3]).','.$alpha; }, $data['watermarktext']['icolor']);
|
||||
$data['watermarktext']['shadowicolor'] = preg_replace_callback('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9]{2})([0-9a-fA-F]{2})/', function($matches) {
|
||||
$alpha=hexdec($matches[4]);
|
||||
if($alpha<0 || $alpha>100) $alpha=1;
|
||||
else $alpha=$alpha/100;
|
||||
return hexdec($matches[1]).','.hexdec($matches[2]).','.hexdec($matches[3]).','.$alpha; }, $data['watermarktext']['shadowicolor']);
|
||||
|
||||
} else {
|
||||
$data['watermarktext']['text'] = '';
|
||||
$data['watermarktext']['fontpath'] = '';
|
||||
$data['watermarktext']['color'] = '';
|
||||
$data['watermarktext']['shadowcolor'] = '';
|
||||
}
|
||||
if(!$data['jspath']) {
|
||||
$data['jspath'] = 'static/js/';
|
||||
}
|
||||
|
||||
|
||||
$reginputbwords = array('username', 'password', 'password2', 'email');
|
||||
if(in_array($data['reginput']['username'], $reginputbwords) || !preg_match('/^[A-z]\w+?$/', $data['reginput']['username'])) {
|
||||
$data['reginput']['username'] = random(6);
|
||||
}
|
||||
if(in_array($data['reginput']['password'], $reginputbwords) || !preg_match('/^[A-z]\w+?$/', $data['reginput']['password'])) {
|
||||
$data['reginput']['password'] = random(6);
|
||||
}
|
||||
if(in_array($data['reginput']['password2'], $reginputbwords) || !preg_match('/^[A-z]\w+?$/', $data['reginput']['password2'])) {
|
||||
$data['reginput']['password2'] = random(6);
|
||||
}
|
||||
if(in_array($data['reginput']['email'], $reginputbwords) || !preg_match('/^[A-z]\w+?$/', $data['reginput']['email'])) {
|
||||
$data['reginput']['email'] = random(6);
|
||||
}
|
||||
|
||||
$data['verhash']=random(3);
|
||||
|
||||
$data['output'] = $output;
|
||||
|
||||
savecache('setting', $data);
|
||||
$_G['setting'] = $data;
|
||||
}
|
||||
|
||||
function parsehighlight($highlight) {
|
||||
if($highlight) {
|
||||
$colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
|
||||
$string = sprintf('%02d', $highlight);
|
||||
$stylestr = sprintf('%03b', $string[0]);
|
||||
|
||||
$style = ' style="';
|
||||
$style .= $stylestr[0] ? 'font-weight: bold;' : '';
|
||||
$style .= $stylestr[1] ? 'font-style: italic;' : '';
|
||||
$style .= $stylestr[2] ? 'text-decoration: underline;' : '';
|
||||
$style .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
|
||||
$style .= '"';
|
||||
} else {
|
||||
$style = '';
|
||||
}
|
||||
return $style;
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_setting() {
|
||||
global $_G;
|
||||
|
||||
$skipkeys = array('backupdir','custombackup');
|
||||
$serialized = array('verify','unRunExts','iconview','storage','reginput', 'memory', 'secqaa', 'sitemessage','disallowfloat',
|
||||
'seccodedata', 'strongpw','upgrade','desktop_default','loginset','at_range','thumbsize',);
|
||||
|
||||
$data = array();
|
||||
|
||||
foreach(C::t('setting')->fetch_all_not_key($skipkeys) as $setting) {
|
||||
if($setting['skey'] == 'attachdir') {
|
||||
$setting['svalue'] = preg_replace("/\.asp|\\0/i", '0', $setting['svalue']);
|
||||
$setting['svalue'] = str_replace('\\', '/', substr($setting['svalue'], 0, 2) == './' ? DZZ_ROOT.$setting['svalue'] : $setting['svalue']);
|
||||
$setting['svalue'] .= substr($setting['svalue'], -1, 1) != '/' ? '/' : '';
|
||||
} elseif($setting['skey'] == 'attachurl') {
|
||||
$setting['svalue'] .= substr($setting['svalue'], -1, 1) != '/' ? '/' : '';
|
||||
|
||||
} elseif(in_array($setting['skey'], $serialized) || is_serialized($setting['svalue'])) {
|
||||
$setting['svalue'] = @dunserialize($setting['svalue']);
|
||||
if($setting['skey'] == 'search') {
|
||||
foreach($setting['svalue'] as $key => $val) {
|
||||
foreach($val as $k => $v) {
|
||||
$setting['svalue'][$key][$k] = max(0, intval($v));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$_G['setting'][$setting['skey']] = $data[$setting['skey']] = $setting['svalue'];
|
||||
}
|
||||
|
||||
include_once DZZ_ROOT.'./core/core_version.php';
|
||||
$_G['setting']['version'] = $data['version'] = CORE_VERSION;
|
||||
|
||||
$data['sitemessage']['time'] = !empty($data['sitemessage']['time']) ? $data['sitemessage']['time'] * 1000 : 0;
|
||||
|
||||
$data['disallowfloat'] = is_array($data['disallowfloat']) ? implode('|', $data['disallowfloat']) : '';
|
||||
|
||||
if(!$data['imagelib']) unset($data['imageimpath']);
|
||||
|
||||
//$data['iconview']=C::t('iconview')->fetch_all();
|
||||
|
||||
|
||||
$data['seccodedata'] = is_array($data['seccodedata']) ? $data['seccodedata'] : array();
|
||||
if($data['seccodedata']['type'] == 2) {
|
||||
if(extension_loaded('ming')) {
|
||||
unset($data['seccodedata']['background'], $data['seccodedata']['adulterate'],
|
||||
$data['seccodedata']['ttf'], $data['seccodedata']['angle'],
|
||||
$data['seccodedata']['color'], $data['seccodedata']['size'],
|
||||
$data['seccodedata']['animator']);
|
||||
} else {
|
||||
$data['seccodedata']['animator'] = 0;
|
||||
}
|
||||
} elseif($data['seccodedata']['type'] == 99) {
|
||||
$data['seccodedata']['width'] = 50;
|
||||
$data['seccodedata']['height'] = 34;
|
||||
}
|
||||
|
||||
$data['watermarktext'] = !empty($data['watermarktext']) ? ($data['watermarktext']) : array();
|
||||
if($data['watermarktype'] == 'text' && $data['watermarktext']['text']) {
|
||||
if($data['watermarktext']['text'] && strtoupper(CHARSET) != 'UTF-8') {
|
||||
$data['watermarktext']['text'] = diconv($data['watermarktext']['text'], CHARSET, 'UTF-8', true);
|
||||
}
|
||||
$data['watermarktext']['textfull'] = $data['watermarktext']['text'];
|
||||
$data['watermarktext']['text'] = bin2hex($data['watermarktext']['text']);
|
||||
if(file_exists('static/image/seccode/font/en/'.$data['watermarktext']['fontpath'])) {
|
||||
$data['watermarktext']['fontpath'] = 'static/image/seccode/font/en/'.$data['watermarktext']['fontpath'];
|
||||
} elseif(file_exists('static/image/seccode/font/ch/'.$data['watermarktext']['fontpath'])) {
|
||||
$data['watermarktext']['fontpath'] = 'static/image/seccode/font/ch/'.$data['watermarktext']['fontpath'];
|
||||
} else {
|
||||
$data['watermarktext']['fontpath'] = 'static/image/seccode/font/'.$data['watermarktext']['fontpath'];
|
||||
}
|
||||
$data['watermarktext']['color'] = preg_replace_callback('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/', function($matches) {
|
||||
$alpha=hexdec($matches[4]);
|
||||
if($alpha<0 || $alpha>127) $alpha=0;
|
||||
return hexdec($matches[1]).','.hexdec($matches[2]).','.hexdec($matches[3]).','.$alpha; }, $data['watermarktext']['color']);
|
||||
$data['watermarktext']['shadowcolor'] = preg_replace_callback('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/', function($matches) {
|
||||
$alpha=hexdec($matches[4]);
|
||||
if($alpha<0 || $alpha>127) $alpha=0;
|
||||
return hexdec($matches[1]).','.hexdec($matches[2]).','.hexdec($matches[3]).','.$alpha; }, $data['watermarktext']['shadowcolor']);
|
||||
|
||||
$data['watermarktext']['icolor'] = preg_replace_callback('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/', function($matches) {
|
||||
$alpha=hexdec($matches[4]);
|
||||
if($alpha<0 || $alpha>100) $alpha = 1;
|
||||
else $alpha = $alpha/100;
|
||||
return hexdec($matches[1]).','.hexdec($matches[2]).','.hexdec($matches[3]).','.$alpha; }, $data['watermarktext']['icolor']);
|
||||
$data['watermarktext']['shadowicolor'] = preg_replace_callback('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9]{2})([0-9a-fA-F]{2})/', function($matches) {
|
||||
$alpha=hexdec($matches[4]);
|
||||
if($alpha<0 || $alpha>100) $alpha=1;
|
||||
else $alpha=$alpha/100;
|
||||
return hexdec($matches[1]).','.hexdec($matches[2]).','.hexdec($matches[3]).','.$alpha; }, $data['watermarktext']['shadowicolor']);
|
||||
|
||||
} else {
|
||||
$data['watermarktext']['text'] = '';
|
||||
$data['watermarktext']['fontpath'] = '';
|
||||
$data['watermarktext']['color'] = '';
|
||||
$data['watermarktext']['shadowcolor'] = '';
|
||||
}
|
||||
if(!$data['jspath']) {
|
||||
$data['jspath'] = 'static/js/';
|
||||
}
|
||||
|
||||
|
||||
$reginputbwords = array('username', 'password', 'password2', 'email');
|
||||
if(in_array($data['reginput']['username'], $reginputbwords) || !preg_match('/^[A-z]\w+?$/', $data['reginput']['username'])) {
|
||||
$data['reginput']['username'] = random(6);
|
||||
}
|
||||
if(in_array($data['reginput']['password'], $reginputbwords) || !preg_match('/^[A-z]\w+?$/', $data['reginput']['password'])) {
|
||||
$data['reginput']['password'] = random(6);
|
||||
}
|
||||
if(in_array($data['reginput']['password2'], $reginputbwords) || !preg_match('/^[A-z]\w+?$/', $data['reginput']['password2'])) {
|
||||
$data['reginput']['password2'] = random(6);
|
||||
}
|
||||
if(in_array($data['reginput']['email'], $reginputbwords) || !preg_match('/^[A-z]\w+?$/', $data['reginput']['email'])) {
|
||||
$data['reginput']['email'] = random(6);
|
||||
}
|
||||
|
||||
$data['verhash']=random(3);
|
||||
|
||||
$data['output'] = $output;
|
||||
|
||||
savecache('setting', $data);
|
||||
$_G['setting'] = $data;
|
||||
}
|
||||
|
||||
function parsehighlight($highlight) {
|
||||
if($highlight) {
|
||||
$colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
|
||||
$string = sprintf('%02d', $highlight);
|
||||
$stylestr = sprintf('%03b', $string[0]);
|
||||
|
||||
$style = ' style="';
|
||||
$style .= $stylestr[0] ? 'font-weight: bold;' : '';
|
||||
$style .= $stylestr[1] ? 'font-style: italic;' : '';
|
||||
$style .= $stylestr[2] ? 'text-decoration: underline;' : '';
|
||||
$style .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
|
||||
$style .= '"';
|
||||
} else {
|
||||
$style = '';
|
||||
}
|
||||
return $style;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
88
core/function/cache/cache_usergroups.php
vendored
88
core/function/cache/cache_usergroups.php
vendored
@@ -1,44 +1,44 @@
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_usergroups() {
|
||||
global $_G;
|
||||
$data_uf = C::t('usergroup_field')->fetch_all();
|
||||
foreach(C::t('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]);
|
||||
|
||||
$groupid = $group['groupid'];
|
||||
$group['grouptitle'] = $group['color'] ? '<font color="'.$group['color'].'">'.$group['grouptitle'].'</font>' : $group['grouptitle'];
|
||||
unset($group['creditshigher'], $group['creditslower']);
|
||||
unset($group['groupid']);
|
||||
$data[$groupid] = $group;
|
||||
}
|
||||
savecache('usergroups', $data);
|
||||
|
||||
build_cache_usergroups_single();
|
||||
|
||||
|
||||
}
|
||||
|
||||
function build_cache_usergroups_single() {
|
||||
$data_uf = C::t('usergroup_field')->fetch_all();
|
||||
foreach(C::t('usergroup')->range() as $gid => $data) {
|
||||
$data = array_merge($data, (array)$data_uf[$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['maxspacesize'] = intval($data['maxspacesize']);
|
||||
unset($data['type'], $data['system'], $data['creditshigher'], $data['creditslower'], $data['groupavatar'], $data['admingid']);
|
||||
savecache('usergroup_'.$data['groupid'], $data);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_usergroups() {
|
||||
global $_G;
|
||||
$data_uf = C::t('usergroup_field')->fetch_all();
|
||||
foreach(C::t('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]);
|
||||
|
||||
$groupid = $group['groupid'];
|
||||
$group['grouptitle'] = $group['color'] ? '<font color="'.$group['color'].'">'.$group['grouptitle'].'</font>' : $group['grouptitle'];
|
||||
unset($group['creditshigher'], $group['creditslower']);
|
||||
unset($group['groupid']);
|
||||
$data[$groupid] = $group;
|
||||
}
|
||||
savecache('usergroups', $data);
|
||||
|
||||
build_cache_usergroups_single();
|
||||
|
||||
|
||||
}
|
||||
|
||||
function build_cache_usergroups_single() {
|
||||
$data_uf = C::t('usergroup_field')->fetch_all();
|
||||
foreach(C::t('usergroup')->range() as $gid => $data) {
|
||||
$data = array_merge($data, (array)$data_uf[$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['maxspacesize'] = intval($data['maxspacesize']);
|
||||
unset($data['type'], $data['system'], $data['creditshigher'], $data['creditslower'], $data['groupavatar'], $data['admingid']);
|
||||
savecache('usergroup_'.$data['groupid'], $data);
|
||||
}
|
||||
}
|
||||
|
||||
30
core/function/cache/cache_userstats.php
vendored
30
core/function/cache/cache_userstats.php
vendored
@@ -1,16 +1,16 @@
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_userstats() {
|
||||
global $_G;
|
||||
$totalmembers = C::t('user')->count();
|
||||
$member = C::t('user')->range(0, 1, 'DESC');
|
||||
$member = current($member);
|
||||
$newsetuser = $member['username'];
|
||||
$data = array('totalmembers' => $totalmembers, 'newsetuser' => $newsetuser);
|
||||
savecache('userstats', $data);
|
||||
}
|
||||
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function build_cache_userstats() {
|
||||
global $_G;
|
||||
$totalmembers = C::t('user')->count();
|
||||
$member = C::t('user')->range(0, 1, 'DESC');
|
||||
$member = current($member);
|
||||
$newsetuser = $member['username'];
|
||||
$data = array('totalmembers' => $totalmembers, 'newsetuser' => $newsetuser);
|
||||
savecache('userstats', $data);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,162 +1,162 @@
|
||||
<?php
|
||||
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
error_reporting(E_ERROR);
|
||||
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 = DZZ_ROOT.'./core/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('app_market')->fetch_all_identifier(1) as $value) {
|
||||
if(empty($value['app_path'])) $value['app_path']='dzz';
|
||||
$appdir=$value['app_path'];
|
||||
$dir=$value['identifier'];
|
||||
$cachedir = DZZ_ROOT.'./'.$appdir.'/'.$dir.'/cache';
|
||||
if(is_dir($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)) {
|
||||
try{
|
||||
@include_once $cachedir.'/'.$entry;
|
||||
//call_user_func('build_cache_'.$dir.'_'.$entryr[1]);
|
||||
if(function_exists('build_cache_'.$appdir.'_'.$dir.'_'.$entryr[1])) call_user_func('build_cache_'.$appdir.'_'.$dir.'_'.$entryr[1]);
|
||||
elseif(function_exists('build_cache_'.$dir.'_'.$entryr[1])) call_user_func('build_cache_'.$dir.'_'.$entryr[1]);
|
||||
elseif(function_exists('build_cache_app_'.$entryr[1])) call_user_func('build_cache_app_'.$entryr[1]);;
|
||||
}catch(Exception $e){continue;}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
foreach($updatelist as $entry) {
|
||||
$entrys = explode(':', $entry);
|
||||
|
||||
if(count($entrys) == 1) {//核心缓存
|
||||
@include_once libfile('cache/'.$entry, 'function');
|
||||
call_user_func('build_cache_'.$entry);
|
||||
}elseif(count($entrys)==2){//兼容原先默认dzz目录的情况,dzz目录内的可以忽略app_path;
|
||||
try{
|
||||
@include_once DZZ_ROOT.'./dzz/'.$entrys[0].'/cache/cache_'.$entrys[1].'.php';
|
||||
if(function_exists('build_cache_'.$entrys[0].'_'.$entrys[1])) call_user_func('build_cache_'.$entrys[0].'_'.$entrys[1]);
|
||||
elseif(function_exists('build_cache_app_'.$entrys[1])) call_user_func('build_cache_app_'.$entrys[1]);
|
||||
}catch(Exception $e){continue;}
|
||||
}elseif(count($entrys)==3){
|
||||
try{
|
||||
@include_once DZZ_ROOT.'./'.$entrys[0].'/'.$entrys[1].'/cache/cache_'.$entrys[2].'.php';
|
||||
if(function_exists('build_cache_'.$entrys[1].'_'.$entrys[2])) call_user_func('build_cache_'.$entrys[1].'_'.$entrys[2]);
|
||||
elseif(function_exists('build_cache_app_'.$entrys[1])) call_user_func('build_cache_app_'.$entrys[1]);
|
||||
}catch(Exception $e){continue;}
|
||||
} else {//插件缓存
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
function writetocache($script, $cachedata, $prefix = 'cache_') {
|
||||
global $_G;
|
||||
|
||||
$dir = DZZ_ROOT.'./data/sysdata/';
|
||||
if(!is_dir($dir)) {
|
||||
dmkdir($dir, 0777);
|
||||
}
|
||||
if($fp = @fopen("$dir$prefix$script.php", 'wb')) {
|
||||
fwrite($fp, "<?php\n//Dzz! cache file, DO NOT modify me!\n//Identify: ".md5($prefix.$script.'.php'.$cachedata.$_G['config']['security']['authkey'])."\n\n$cachedata?>");
|
||||
fclose($fp);
|
||||
} else {
|
||||
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 cleartemplatecache() {
|
||||
clearHooksCache();
|
||||
$tpl = dir(DZZ_ROOT.'./data/template');
|
||||
while($entry = $tpl->read()) {
|
||||
if(preg_match("/(\.tpl\.php|\.js)$/", $entry)) {
|
||||
@unlink(DZZ_ROOT.'./data/template/'.$entry);
|
||||
}
|
||||
}
|
||||
$tpl->close();
|
||||
}
|
||||
function clearHooksCache(){
|
||||
@unlink(DZZ_ROOT.'./data/cache/tags.php');
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
error_reporting(E_ERROR);
|
||||
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 = DZZ_ROOT.'./core/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('app_market')->fetch_all_identifier(1) as $value) {
|
||||
if(empty($value['app_path'])) $value['app_path']='dzz';
|
||||
$appdir=$value['app_path'];
|
||||
$dir=$value['identifier'];
|
||||
$cachedir = DZZ_ROOT.'./'.$appdir.'/'.$dir.'/cache';
|
||||
if(is_dir($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)) {
|
||||
try{
|
||||
@include_once $cachedir.'/'.$entry;
|
||||
//call_user_func('build_cache_'.$dir.'_'.$entryr[1]);
|
||||
if(function_exists('build_cache_'.$appdir.'_'.$dir.'_'.$entryr[1])) call_user_func('build_cache_'.$appdir.'_'.$dir.'_'.$entryr[1]);
|
||||
elseif(function_exists('build_cache_'.$dir.'_'.$entryr[1])) call_user_func('build_cache_'.$dir.'_'.$entryr[1]);
|
||||
elseif(function_exists('build_cache_app_'.$entryr[1])) call_user_func('build_cache_app_'.$entryr[1]);;
|
||||
}catch(Exception $e){continue;}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
foreach($updatelist as $entry) {
|
||||
$entrys = explode(':', $entry);
|
||||
|
||||
if(count($entrys) == 1) {//核心缓存
|
||||
@include_once libfile('cache/'.$entry, 'function');
|
||||
call_user_func('build_cache_'.$entry);
|
||||
}elseif(count($entrys)==2){//兼容原先默认dzz目录的情况,dzz目录内的可以忽略app_path;
|
||||
try{
|
||||
@include_once DZZ_ROOT.'./dzz/'.$entrys[0].'/cache/cache_'.$entrys[1].'.php';
|
||||
if(function_exists('build_cache_'.$entrys[0].'_'.$entrys[1])) call_user_func('build_cache_'.$entrys[0].'_'.$entrys[1]);
|
||||
elseif(function_exists('build_cache_app_'.$entrys[1])) call_user_func('build_cache_app_'.$entrys[1]);
|
||||
}catch(Exception $e){continue;}
|
||||
}elseif(count($entrys)==3){
|
||||
try{
|
||||
@include_once DZZ_ROOT.'./'.$entrys[0].'/'.$entrys[1].'/cache/cache_'.$entrys[2].'.php';
|
||||
if(function_exists('build_cache_'.$entrys[1].'_'.$entrys[2])) call_user_func('build_cache_'.$entrys[1].'_'.$entrys[2]);
|
||||
elseif(function_exists('build_cache_app_'.$entrys[1])) call_user_func('build_cache_app_'.$entrys[1]);
|
||||
}catch(Exception $e){continue;}
|
||||
} else {//插件缓存
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
function writetocache($script, $cachedata, $prefix = 'cache_') {
|
||||
global $_G;
|
||||
|
||||
$dir = DZZ_ROOT.'./data/sysdata/';
|
||||
if(!is_dir($dir)) {
|
||||
dmkdir($dir, 0777);
|
||||
}
|
||||
if($fp = @fopen("$dir$prefix$script.php", 'wb')) {
|
||||
fwrite($fp, "<?php\n//Dzz! cache file, DO NOT modify me!\n//Identify: ".md5($prefix.$script.'.php'.$cachedata.$_G['config']['security']['authkey'])."\n\n$cachedata?>");
|
||||
fclose($fp);
|
||||
} else {
|
||||
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 cleartemplatecache() {
|
||||
clearHooksCache();
|
||||
$tpl = dir(DZZ_ROOT.'./data/template');
|
||||
while($entry = $tpl->read()) {
|
||||
if(preg_match("/(\.tpl\.php|\.js)$/", $entry)) {
|
||||
@unlink(DZZ_ROOT.'./data/template/'.$entry);
|
||||
}
|
||||
}
|
||||
$tpl->close();
|
||||
}
|
||||
function clearHooksCache(){
|
||||
@unlink(DZZ_ROOT.'./data/cache/tags.php');
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,190 +1,190 @@
|
||||
<?php
|
||||
|
||||
if(!defined('IN_OAOOA')) {
|
||||
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()) {
|
||||
$return = '';
|
||||
$matches = parse_url($url);
|
||||
$scheme = $matches['scheme'];
|
||||
$host = $matches['host'];
|
||||
$path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
|
||||
$port = !empty($matches['port']) ? $matches['port'] : ($scheme == 'http' ? '80' : '');
|
||||
$boundary = $encodetype == 'URLENCODE' ? '' : random(40);
|
||||
if($post) {
|
||||
if(!is_array($post)) {
|
||||
parse_str($post, $post);
|
||||
}
|
||||
_format_postkey($post, $postnew);
|
||||
$post = $postnew;
|
||||
}
|
||||
if(function_exists('curl_init') && function_exists('curl_exec') && $allowcurl) {
|
||||
$ch = curl_init();
|
||||
$httpheader = array();
|
||||
if($ip) {
|
||||
$httpheader[] = "Host: ".$host;
|
||||
}
|
||||
if($httpheader) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).($port ? ':'.$port : '').$path);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||
if($post) {
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
if($encodetype == 'URLENCODE') {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
} else {
|
||||
foreach($post as $k => $v) {
|
||||
if(isset($files[$k])) {
|
||||
$post[$k] = '@'.$files[$k];
|
||||
}
|
||||
}
|
||||
foreach($files as $k => $file) {
|
||||
if(!isset($post[$k]) && file_exists($file)) {
|
||||
$post[$k] = '@'.$file;
|
||||
}
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
}
|
||||
}
|
||||
if($cookie) {
|
||||
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
|
||||
}
|
||||
if($timeout<1){
|
||||
$timeout_ms=intval($timeout*1000);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
|
||||
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $timeout_ms);
|
||||
}else{
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
}
|
||||
$data = curl_exec($ch);
|
||||
$status = curl_getinfo($ch);
|
||||
$errno = curl_errno($ch);
|
||||
curl_close($ch);
|
||||
if($errno || $status['http_code'] != 200) {
|
||||
return;
|
||||
} else {
|
||||
$GLOBALS['filesockheader'] = substr($data, 0, $status['header_size']);
|
||||
$data = substr($data, $status['header_size']);
|
||||
return !$limit ? $data : substr($data, 0, $limit);
|
||||
}
|
||||
}
|
||||
|
||||
if($post) {
|
||||
if($encodetype == 'URLENCODE') {
|
||||
$data = http_build_query($post);
|
||||
} else {
|
||||
$data = '';
|
||||
foreach($post as $k => $v) {
|
||||
$data .= "--$boundary\r\n";
|
||||
$data .= 'Content-Disposition: form-data; name="'.$k.'"'.(isset($files[$k]) ? '; filename="'.basename($files[$k]).'"; Content-Type: application/octet-stream' : '')."\r\n\r\n";
|
||||
$data .= $v."\r\n";
|
||||
}
|
||||
foreach($files as $k => $file) {
|
||||
if(!isset($post[$k]) && file_exists($file)) {
|
||||
if($fp = @fopen($file, 'r')) {
|
||||
$v = fread($fp, filesize($file));
|
||||
fclose($fp);
|
||||
$data .= "--$boundary\r\n";
|
||||
$data .= 'Content-Disposition: form-data; name="'.$k.'"; filename="'.basename($file).'"; Content-Type: application/octet-stream'."\r\n\r\n";
|
||||
$data .= $v."\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$data .= "--$boundary\r\n";
|
||||
}
|
||||
$out = "POST $path HTTP/1.0\r\n";
|
||||
$header = "Accept: */*\r\n";
|
||||
$header .= "Accept-Language: zh-cn\r\n";
|
||||
$header .= $encodetype == 'URLENCODE' ? "Content-Type: application/x-www-form-urlencoded\r\n" : "Content-Type: multipart/form-data; boundary=$boundary\r\n";
|
||||
$header .= 'Content-Length: '.strlen($data)."\r\n";
|
||||
$header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
|
||||
$header .= "Host: $host:$port\r\n";
|
||||
$header .= "Connection: Close\r\n";
|
||||
$header .= "Cache-Control: no-cache\r\n";
|
||||
$header .= "Cookie: $cookie\r\n\r\n";
|
||||
$out .= $header;
|
||||
$out .= $data;
|
||||
} else {
|
||||
$out = "GET $path HTTP/1.0\r\n";
|
||||
$header = "Accept: */*\r\n";
|
||||
$header .= "Accept-Language: zh-cn\r\n";
|
||||
$header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
|
||||
$header .= "Host: $host:$port\r\n";
|
||||
$header .= "Connection: Close\r\n";
|
||||
$header .= "Cookie: $cookie\r\n\r\n";
|
||||
$out .= $header;
|
||||
}
|
||||
|
||||
$fpflag = 0;
|
||||
if(!$fp = @fsocketopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout)) {
|
||||
$context = array(
|
||||
'http' => array(
|
||||
'method' => $post ? 'POST' : 'GET',
|
||||
'header' => $header,
|
||||
'content' => $post,
|
||||
'timeout' => $timeout,
|
||||
),
|
||||
);
|
||||
$context = stream_context_create($context);
|
||||
$fp = @fopen($scheme.'://'.($ip ? $ip : $host).':'.$port.$path, 'b', false, $context);
|
||||
$fpflag = 1;
|
||||
}
|
||||
|
||||
if(!$fp) {
|
||||
return '';
|
||||
} else {
|
||||
stream_set_blocking($fp, $block);
|
||||
stream_set_timeout($fp, $timeout);
|
||||
@fwrite($fp, $out);
|
||||
$status = stream_get_meta_data($fp);
|
||||
if(!$status['timed_out']) {
|
||||
while (!feof($fp) && !$fpflag) {
|
||||
$header = @fgets($fp);
|
||||
$headers .= $header;
|
||||
if($header && ($header == "\r\n" || $header == "\n")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$GLOBALS['filesockheader'] = $headers;
|
||||
|
||||
if($position) {
|
||||
for($i=0; $i<$position; $i++) {
|
||||
$char = fgetc($fp);
|
||||
/*if($char == "\n" && $oldchar != "\r") {
|
||||
$i++;
|
||||
}*/
|
||||
$oldchar = $char;
|
||||
}
|
||||
}
|
||||
|
||||
if($limit) {
|
||||
$return = stream_get_contents($fp, $limit);
|
||||
} else {
|
||||
$return = stream_get_contents($fp);
|
||||
}
|
||||
}
|
||||
@fclose($fp);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
function _format_postkey($post, &$result, $key = '') {
|
||||
foreach($post as $k => $v) {
|
||||
$_k = $key ? $key.'['.$k.']' : $k;
|
||||
if(is_array($v)) {
|
||||
_format_postkey($v, $result, $_k);
|
||||
} else {
|
||||
$result[$_k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<?php
|
||||
|
||||
if(!defined('IN_OAOOA')) {
|
||||
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()) {
|
||||
$return = '';
|
||||
$matches = parse_url($url);
|
||||
$scheme = $matches['scheme'];
|
||||
$host = $matches['host'];
|
||||
$path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
|
||||
$port = !empty($matches['port']) ? $matches['port'] : ($scheme == 'http' ? '80' : '');
|
||||
$boundary = $encodetype == 'URLENCODE' ? '' : random(40);
|
||||
if($post) {
|
||||
if(!is_array($post)) {
|
||||
parse_str($post, $post);
|
||||
}
|
||||
_format_postkey($post, $postnew);
|
||||
$post = $postnew;
|
||||
}
|
||||
if(function_exists('curl_init') && function_exists('curl_exec') && $allowcurl) {
|
||||
$ch = curl_init();
|
||||
$httpheader = array();
|
||||
if($ip) {
|
||||
$httpheader[] = "Host: ".$host;
|
||||
}
|
||||
if($httpheader) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).($port ? ':'.$port : '').$path);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||
if($post) {
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
if($encodetype == 'URLENCODE') {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
} else {
|
||||
foreach($post as $k => $v) {
|
||||
if(isset($files[$k])) {
|
||||
$post[$k] = '@'.$files[$k];
|
||||
}
|
||||
}
|
||||
foreach($files as $k => $file) {
|
||||
if(!isset($post[$k]) && file_exists($file)) {
|
||||
$post[$k] = '@'.$file;
|
||||
}
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
}
|
||||
}
|
||||
if($cookie) {
|
||||
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
|
||||
}
|
||||
if($timeout<1){
|
||||
$timeout_ms=intval($timeout*1000);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
|
||||
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $timeout_ms);
|
||||
}else{
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
}
|
||||
$data = curl_exec($ch);
|
||||
$status = curl_getinfo($ch);
|
||||
$errno = curl_errno($ch);
|
||||
curl_close($ch);
|
||||
if($errno || $status['http_code'] != 200) {
|
||||
return;
|
||||
} else {
|
||||
$GLOBALS['filesockheader'] = substr($data, 0, $status['header_size']);
|
||||
$data = substr($data, $status['header_size']);
|
||||
return !$limit ? $data : substr($data, 0, $limit);
|
||||
}
|
||||
}
|
||||
|
||||
if($post) {
|
||||
if($encodetype == 'URLENCODE') {
|
||||
$data = http_build_query($post);
|
||||
} else {
|
||||
$data = '';
|
||||
foreach($post as $k => $v) {
|
||||
$data .= "--$boundary\r\n";
|
||||
$data .= 'Content-Disposition: form-data; name="'.$k.'"'.(isset($files[$k]) ? '; filename="'.basename($files[$k]).'"; Content-Type: application/octet-stream' : '')."\r\n\r\n";
|
||||
$data .= $v."\r\n";
|
||||
}
|
||||
foreach($files as $k => $file) {
|
||||
if(!isset($post[$k]) && file_exists($file)) {
|
||||
if($fp = @fopen($file, 'r')) {
|
||||
$v = fread($fp, filesize($file));
|
||||
fclose($fp);
|
||||
$data .= "--$boundary\r\n";
|
||||
$data .= 'Content-Disposition: form-data; name="'.$k.'"; filename="'.basename($file).'"; Content-Type: application/octet-stream'."\r\n\r\n";
|
||||
$data .= $v."\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$data .= "--$boundary\r\n";
|
||||
}
|
||||
$out = "POST $path HTTP/1.0\r\n";
|
||||
$header = "Accept: */*\r\n";
|
||||
$header .= "Accept-Language: zh-cn\r\n";
|
||||
$header .= $encodetype == 'URLENCODE' ? "Content-Type: application/x-www-form-urlencoded\r\n" : "Content-Type: multipart/form-data; boundary=$boundary\r\n";
|
||||
$header .= 'Content-Length: '.strlen($data)."\r\n";
|
||||
$header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
|
||||
$header .= "Host: $host:$port\r\n";
|
||||
$header .= "Connection: Close\r\n";
|
||||
$header .= "Cache-Control: no-cache\r\n";
|
||||
$header .= "Cookie: $cookie\r\n\r\n";
|
||||
$out .= $header;
|
||||
$out .= $data;
|
||||
} else {
|
||||
$out = "GET $path HTTP/1.0\r\n";
|
||||
$header = "Accept: */*\r\n";
|
||||
$header .= "Accept-Language: zh-cn\r\n";
|
||||
$header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
|
||||
$header .= "Host: $host:$port\r\n";
|
||||
$header .= "Connection: Close\r\n";
|
||||
$header .= "Cookie: $cookie\r\n\r\n";
|
||||
$out .= $header;
|
||||
}
|
||||
|
||||
$fpflag = 0;
|
||||
if(!$fp = @fsocketopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout)) {
|
||||
$context = array(
|
||||
'http' => array(
|
||||
'method' => $post ? 'POST' : 'GET',
|
||||
'header' => $header,
|
||||
'content' => $post,
|
||||
'timeout' => $timeout,
|
||||
),
|
||||
);
|
||||
$context = stream_context_create($context);
|
||||
$fp = @fopen($scheme.'://'.($ip ? $ip : $host).':'.$port.$path, 'b', false, $context);
|
||||
$fpflag = 1;
|
||||
}
|
||||
|
||||
if(!$fp) {
|
||||
return '';
|
||||
} else {
|
||||
stream_set_blocking($fp, $block);
|
||||
stream_set_timeout($fp, $timeout);
|
||||
@fwrite($fp, $out);
|
||||
$status = stream_get_meta_data($fp);
|
||||
if(!$status['timed_out']) {
|
||||
while (!feof($fp) && !$fpflag) {
|
||||
$header = @fgets($fp);
|
||||
$headers .= $header;
|
||||
if($header && ($header == "\r\n" || $header == "\n")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$GLOBALS['filesockheader'] = $headers;
|
||||
|
||||
if($position) {
|
||||
for($i=0; $i<$position; $i++) {
|
||||
$char = fgetc($fp);
|
||||
/*if($char == "\n" && $oldchar != "\r") {
|
||||
$i++;
|
||||
}*/
|
||||
$oldchar = $char;
|
||||
}
|
||||
}
|
||||
|
||||
if($limit) {
|
||||
$return = stream_get_contents($fp, $limit);
|
||||
} else {
|
||||
$return = stream_get_contents($fp);
|
||||
}
|
||||
}
|
||||
@fclose($fp);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
function _format_postkey($post, &$result, $key = '') {
|
||||
foreach($post as $k => $v) {
|
||||
$_k = $key ? $key.'['.$k.']' : $k;
|
||||
if(is_array($v)) {
|
||||
_format_postkey($v, $result, $_k);
|
||||
} else {
|
||||
$result[$_k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,247 +1,247 @@
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
@set_time_limit(300);
|
||||
function sendmail($toemail, $subject, $message, $from = '') {
|
||||
global $_G;
|
||||
if(!is_array($_G['setting']['mail'])) {
|
||||
$_G['setting']['mail'] = dunserialize($_G['setting']['mail']);
|
||||
}
|
||||
$_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);
|
||||
$smtp = $_G['setting']['mail']['smtp'][$rid];
|
||||
$_G['setting']['mail']['server'] = $smtp['server'];
|
||||
$_G['setting']['mail']['port'] = $smtp['port'];
|
||||
$_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'];
|
||||
}
|
||||
}
|
||||
$message = preg_replace("/href\=\"(?!(http|https)\:\/\/)(.+?)\"/i", 'href="'.$_G['siteurl'].'\\1"', $message);
|
||||
|
||||
$message = <<<EOT
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=$_G[charset]">
|
||||
<title>$subject</title>
|
||||
</head>
|
||||
<body>
|
||||
$subject<br />
|
||||
$message
|
||||
</body>
|
||||
</html>
|
||||
EOT;
|
||||
|
||||
$maildelimiter = $_G['setting']['mail']['maildelimiter'] == 1 ? "\r\n" : ($_G['setting']['mail']['maildelimiter'] == 2 ? "\r" : "\n");
|
||||
$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 = $_SERVER['HTTP_HOST'];
|
||||
$version = $_G['setting']['version'];
|
||||
$headers = "From: $email_from{$maildelimiter}X-Priority: 3{$maildelimiter}X-Mailer: $host $version {$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: text/html; charset=".CHARSET."{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}";
|
||||
if($_G['setting']['mail']['mailsend'] == 1) {
|
||||
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, 30)) {
|
||||
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);
|
||||
|
||||
$lastmessage = fgets($fp, 512);
|
||||
if(substr($lastmessage, 0, 3) != '220') {
|
||||
runlog('SMTP', "{$_G[setting][mail][server]}:{$_G[setting][mail][port]} CONNECT - $lastmessage", 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($fp, ($_G['setting']['mail']['auth'] ? 'EHLO' : 'HELO')." uchome\r\n");
|
||||
$lastmessage = fgets($fp, 512);
|
||||
if(substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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);
|
||||
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) {
|
||||
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)));
|
||||
}
|
||||
|
||||
$headers .= 'Message-ID: <'.date('YmdHs').'.'.substr(md5($email_message.microtime()), 0, 6).rand(100000, 999999).'@'.$_SERVER['HTTP_HOST'].">{$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) {
|
||||
runlog('SMTP', "({$_G[setting][mail][server]}:{$_G[setting][mail][port]}) END - $lastmessage", 0);
|
||||
}
|
||||
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);
|
||||
|
||||
if(function_exists('mail') && @mail($email_to, $email_subject, $email_message, $headers)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function sendmail_cron($toemail, $subject, $message) {
|
||||
global $_G;
|
||||
$toemail = addslashes($toemail);
|
||||
|
||||
$value = C::t('mailcron')->fetch_all_by_email($toemail, 0, 1);
|
||||
$value = $value[0];
|
||||
if($value) {
|
||||
$cid = $value['cid'];
|
||||
} else {
|
||||
$cid = C::t('mailcron')->insert(array('email' => $toemail), true);
|
||||
}
|
||||
$message = preg_replace("/href\=\"(?!(http|https)\:\/\/)(.+?)\"/i", 'href="'.$_G['siteurl'].'\\1"', $message);
|
||||
$setarr = array(
|
||||
'cid' => $cid,
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'dateline' => $_G['timestamp']
|
||||
);
|
||||
C::t('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/user','','user');
|
||||
$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('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('mailcron')->update($cid, array('email' => $tospace['email'], 'sendtime' => $sendtime));
|
||||
} else {
|
||||
$cid = C::t('mailcron')->insert(array(
|
||||
'touid' => $touid,
|
||||
'email' => $tospace['email'],
|
||||
'sendtime' => $sendtime,
|
||||
), true);
|
||||
}
|
||||
$message = preg_replace("/href\=\"(?!(http|https)\:\/\/)(.+?)\"/i", 'href="'.$_G['siteurl'].'\\1"', $message);
|
||||
$setarr = array(
|
||||
'cid' => $cid,
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'dateline' => $_G['timestamp']
|
||||
);
|
||||
C::t('mailqueue')->insert($setarr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
@set_time_limit(300);
|
||||
function sendmail($toemail, $subject, $message, $from = '') {
|
||||
global $_G;
|
||||
if(!is_array($_G['setting']['mail'])) {
|
||||
$_G['setting']['mail'] = dunserialize($_G['setting']['mail']);
|
||||
}
|
||||
$_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);
|
||||
$smtp = $_G['setting']['mail']['smtp'][$rid];
|
||||
$_G['setting']['mail']['server'] = $smtp['server'];
|
||||
$_G['setting']['mail']['port'] = $smtp['port'];
|
||||
$_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'];
|
||||
}
|
||||
}
|
||||
$message = preg_replace("/href\=\"(?!(http|https)\:\/\/)(.+?)\"/i", 'href="'.$_G['siteurl'].'\\1"', $message);
|
||||
|
||||
$message = <<<EOT
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=$_G[charset]">
|
||||
<title>$subject</title>
|
||||
</head>
|
||||
<body>
|
||||
$subject<br />
|
||||
$message
|
||||
</body>
|
||||
</html>
|
||||
EOT;
|
||||
|
||||
$maildelimiter = $_G['setting']['mail']['maildelimiter'] == 1 ? "\r\n" : ($_G['setting']['mail']['maildelimiter'] == 2 ? "\r" : "\n");
|
||||
$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 = $_SERVER['HTTP_HOST'];
|
||||
$version = $_G['setting']['version'];
|
||||
$headers = "From: $email_from{$maildelimiter}X-Priority: 3{$maildelimiter}X-Mailer: $host $version {$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: text/html; charset=".CHARSET."{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}";
|
||||
if($_G['setting']['mail']['mailsend'] == 1) {
|
||||
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, 30)) {
|
||||
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);
|
||||
|
||||
$lastmessage = fgets($fp, 512);
|
||||
if(substr($lastmessage, 0, 3) != '220') {
|
||||
runlog('SMTP', "{$_G[setting][mail][server]}:{$_G[setting][mail][port]} CONNECT - $lastmessage", 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($fp, ($_G['setting']['mail']['auth'] ? 'EHLO' : 'HELO')." uchome\r\n");
|
||||
$lastmessage = fgets($fp, 512);
|
||||
if(substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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);
|
||||
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) {
|
||||
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)));
|
||||
}
|
||||
|
||||
$headers .= 'Message-ID: <'.date('YmdHs').'.'.substr(md5($email_message.microtime()), 0, 6).rand(100000, 999999).'@'.$_SERVER['HTTP_HOST'].">{$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) {
|
||||
runlog('SMTP', "({$_G[setting][mail][server]}:{$_G[setting][mail][port]}) END - $lastmessage", 0);
|
||||
}
|
||||
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);
|
||||
|
||||
if(function_exists('mail') && @mail($email_to, $email_subject, $email_message, $headers)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function sendmail_cron($toemail, $subject, $message) {
|
||||
global $_G;
|
||||
$toemail = addslashes($toemail);
|
||||
|
||||
$value = C::t('mailcron')->fetch_all_by_email($toemail, 0, 1);
|
||||
$value = $value[0];
|
||||
if($value) {
|
||||
$cid = $value['cid'];
|
||||
} else {
|
||||
$cid = C::t('mailcron')->insert(array('email' => $toemail), true);
|
||||
}
|
||||
$message = preg_replace("/href\=\"(?!(http|https)\:\/\/)(.+?)\"/i", 'href="'.$_G['siteurl'].'\\1"', $message);
|
||||
$setarr = array(
|
||||
'cid' => $cid,
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'dateline' => $_G['timestamp']
|
||||
);
|
||||
C::t('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/user','','user');
|
||||
$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('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('mailcron')->update($cid, array('email' => $tospace['email'], 'sendtime' => $sendtime));
|
||||
} else {
|
||||
$cid = C::t('mailcron')->insert(array(
|
||||
'touid' => $touid,
|
||||
'email' => $tospace['email'],
|
||||
'sendtime' => $sendtime,
|
||||
), true);
|
||||
}
|
||||
$message = preg_replace("/href\=\"(?!(http|https)\:\/\/)(.+?)\"/i", 'href="'.$_G['siteurl'].'\\1"', $message);
|
||||
$setarr = array(
|
||||
'cid' => $cid,
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'dateline' => $_G['timestamp']
|
||||
);
|
||||
C::t('mailqueue')->insert($setarr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,220 +1,220 @@
|
||||
<?php
|
||||
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function dshowmessage($message, $url_forward = '', $values = array(), $extraparam = array(), $custom = 0) {
|
||||
global $_G, $show_message;
|
||||
$_G['messageparam'] = func_get_args();
|
||||
|
||||
if($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' => '',
|
||||
'striptags' => false,
|
||||
);
|
||||
|
||||
$navtitle = lang('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(!$url_forward && dreferer() && 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'] && @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;
|
||||
}
|
||||
if(!empty($_G['inajax'])) {
|
||||
$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']['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($_GET['ajaxdata'] === 'json') {
|
||||
$param['header'] = '';
|
||||
}
|
||||
|
||||
if($param['header']) {
|
||||
header("HTTP/1.1 301 Moved Permanently");
|
||||
dheader("location: ".str_replace('&', '&', $url_forward));
|
||||
}
|
||||
$url_forward_js = addslashes(str_replace('\\', '%27', $url_forward));
|
||||
if($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();
|
||||
}
|
||||
|
||||
$vars = explode(':', $message);
|
||||
if(count($vars) == 2) {
|
||||
$show_message = lang($vars[1], $values,null,$vars[0]);
|
||||
} else {
|
||||
$show_message = lang($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($param['msgtype'] == 2 && $param['login']) {
|
||||
dheader('location: user.php?mod=login');
|
||||
}
|
||||
|
||||
$show_jsmessage = str_replace("'", "\\'", $param['striptags'] ? strip_tags($show_message) : $show_message);
|
||||
|
||||
if((!$param['showmsg'] || $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($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']) {
|
||||
$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'] : '';
|
||||
//print_r($param);exit($show_message);
|
||||
include template('common/showmessage');
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function dshowmessage($message, $url_forward = '', $values = array(), $extraparam = array(), $custom = 0) {
|
||||
global $_G, $show_message;
|
||||
$_G['messageparam'] = func_get_args();
|
||||
|
||||
if($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' => '',
|
||||
'striptags' => false,
|
||||
);
|
||||
|
||||
$navtitle = lang('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(!$url_forward && dreferer() && 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'] && @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;
|
||||
}
|
||||
if(!empty($_G['inajax'])) {
|
||||
$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']['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($_GET['ajaxdata'] === 'json') {
|
||||
$param['header'] = '';
|
||||
}
|
||||
|
||||
if($param['header']) {
|
||||
header("HTTP/1.1 301 Moved Permanently");
|
||||
dheader("location: ".str_replace('&', '&', $url_forward));
|
||||
}
|
||||
$url_forward_js = addslashes(str_replace('\\', '%27', $url_forward));
|
||||
if($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();
|
||||
}
|
||||
|
||||
$vars = explode(':', $message);
|
||||
if(count($vars) == 2) {
|
||||
$show_message = lang($vars[1], $values,null,$vars[0]);
|
||||
} else {
|
||||
$show_message = lang($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($param['msgtype'] == 2 && $param['login']) {
|
||||
dheader('location: user.php?mod=login');
|
||||
}
|
||||
|
||||
$show_jsmessage = str_replace("'", "\\'", $param['striptags'] ? strip_tags($show_message) : $show_message);
|
||||
|
||||
if((!$param['showmsg'] || $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($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']) {
|
||||
$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'] : '';
|
||||
//print_r($param);exit($show_message);
|
||||
include template('common/showmessage');
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,257 +1,257 @@
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function convertip($ip) {
|
||||
|
||||
$return = '';
|
||||
|
||||
if(preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $ip)) {
|
||||
|
||||
$iparray = explode('.', $ip);
|
||||
|
||||
if($iparray[0] == 10 || $iparray[0] == 127 || ($iparray[0] == 192 && $iparray[1] == 168) || ($iparray[0] == 172 && ($iparray[1] >= 16 && $iparray[1] <= 31))) {
|
||||
$return = '- LAN';
|
||||
} elseif($iparray[0] > 255 || $iparray[1] > 255 || $iparray[2] > 255 || $iparray[3] > 255) {
|
||||
$return = '- Invalid IP Address';
|
||||
} else {
|
||||
$tinyipfile = DZZ_ROOT.'./data/ipdata/tinyipdata.dat';
|
||||
$fullipfile = DZZ_ROOT.'./data/ipdata/wry.dat';
|
||||
if(@file_exists($tinyipfile)) {
|
||||
$return = convertip_tiny($ip, $tinyipfile);
|
||||
} elseif(@file_exists($fullipfile)) {
|
||||
$return = convertip_full($ip, $fullipfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
function convertip_tiny($ip, $ipdatafile) {
|
||||
|
||||
static $fp = NULL, $offset = array(), $index = NULL;
|
||||
|
||||
$ipdot = explode('.', $ip);
|
||||
$ip = pack('N', ip2long($ip));
|
||||
|
||||
$ipdot[0] = (int)$ipdot[0];
|
||||
$ipdot[1] = (int)$ipdot[1];
|
||||
|
||||
if($fp === NULL && $fp = @fopen($ipdatafile, 'rb')) {
|
||||
$offset = @unpack('Nlen', @fread($fp, 4));
|
||||
$index = @fread($fp, $offset['len'] - 4);
|
||||
} elseif($fp == FALSE) {
|
||||
return '- Invalid IP data file';
|
||||
}
|
||||
|
||||
$length = $offset['len'] - 1028;
|
||||
$start = @unpack('Vlen', $index[$ipdot[0] * 4] . $index[$ipdot[0] * 4 + 1] . $index[$ipdot[0] * 4 + 2] . $index[$ipdot[0] * 4 + 3]);
|
||||
|
||||
for ($start = $start['len'] * 8 + 1024; $start < $length; $start += 8) {
|
||||
|
||||
if ($index[$start] . $index[$start + 1] . $index[$start + 2] . $index[$start + 3] >= $ip) {
|
||||
$index_offset = @unpack('Vlen', $index[$start + 4] . $index[$start + 5] . $index[$start + 6] . "\x0");
|
||||
$index_length = @unpack('Clen', $index[$start + 7]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@fseek($fp, $offset['len'] + $index_offset['len'] - 1024);
|
||||
if($index_length['len']) {
|
||||
return '- '.@fread($fp, $index_length['len']);
|
||||
} else {
|
||||
return '- Unknown';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function convertip_full($ip, $ipdatafile) {
|
||||
|
||||
if(!$fd = @fopen($ipdatafile, 'rb')) {
|
||||
return '- Invalid IP data file';
|
||||
}
|
||||
|
||||
$ip = explode('.', $ip);
|
||||
$ipNum = $ip[0] * 16777216 + $ip[1] * 65536 + $ip[2] * 256 + $ip[3];
|
||||
|
||||
if(!($DataBegin = fread($fd, 4)) || !($DataEnd = fread($fd, 4)) ) return;
|
||||
@$ipbegin = implode('', unpack('L', $DataBegin));
|
||||
if($ipbegin < 0) $ipbegin += pow(2, 32);
|
||||
@$ipend = implode('', unpack('L', $DataEnd));
|
||||
if($ipend < 0) $ipend += pow(2, 32);
|
||||
$ipAllNum = ($ipend - $ipbegin) / 7 + 1;
|
||||
|
||||
$BeginNum = $ip2num = $ip1num = 0;
|
||||
$ipAddr1 = $ipAddr2 = '';
|
||||
$EndNum = $ipAllNum;
|
||||
|
||||
while($ip1num > $ipNum || $ip2num < $ipNum) {
|
||||
$Middle= intval(($EndNum + $BeginNum) / 2);
|
||||
|
||||
fseek($fd, $ipbegin + 7 * $Middle);
|
||||
$ipData1 = fread($fd, 4);
|
||||
if(strlen($ipData1) < 4) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$ip1num = implode('', unpack('L', $ipData1));
|
||||
if($ip1num < 0) $ip1num += pow(2, 32);
|
||||
|
||||
if($ip1num > $ipNum) {
|
||||
$EndNum = $Middle;
|
||||
continue;
|
||||
}
|
||||
|
||||
$DataSeek = fread($fd, 3);
|
||||
if(strlen($DataSeek) < 3) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$DataSeek = implode('', unpack('L', $DataSeek.chr(0)));
|
||||
fseek($fd, $DataSeek);
|
||||
$ipData2 = fread($fd, 4);
|
||||
if(strlen($ipData2) < 4) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$ip2num = implode('', unpack('L', $ipData2));
|
||||
if($ip2num < 0) $ip2num += pow(2, 32);
|
||||
|
||||
if($ip2num < $ipNum) {
|
||||
if($Middle == $BeginNum) {
|
||||
fclose($fd);
|
||||
return '- Unknown';
|
||||
}
|
||||
$BeginNum = $Middle;
|
||||
}
|
||||
}
|
||||
|
||||
$ipFlag = fread($fd, 1);
|
||||
if($ipFlag == chr(1)) {
|
||||
$ipSeek = fread($fd, 3);
|
||||
if(strlen($ipSeek) < 3) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$ipSeek = implode('', unpack('L', $ipSeek.chr(0)));
|
||||
fseek($fd, $ipSeek);
|
||||
$ipFlag = fread($fd, 1);
|
||||
}
|
||||
|
||||
if($ipFlag == chr(2)) {
|
||||
$AddrSeek = fread($fd, 3);
|
||||
if(strlen($AddrSeek) < 3) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$ipFlag = fread($fd, 1);
|
||||
if($ipFlag == chr(2)) {
|
||||
$AddrSeek2 = fread($fd, 3);
|
||||
if(strlen($AddrSeek2) < 3) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0)));
|
||||
fseek($fd, $AddrSeek2);
|
||||
} else {
|
||||
fseek($fd, -1, SEEK_CUR);
|
||||
}
|
||||
|
||||
while(($char = fread($fd, 1)) != chr(0))
|
||||
$ipAddr2 .= $char;
|
||||
|
||||
$AddrSeek = implode('', unpack('L', $AddrSeek.chr(0)));
|
||||
fseek($fd, $AddrSeek);
|
||||
|
||||
while(($char = fread($fd, 1)) != chr(0))
|
||||
$ipAddr1 .= $char;
|
||||
} else {
|
||||
fseek($fd, -1, SEEK_CUR);
|
||||
while(($char = fread($fd, 1)) != chr(0))
|
||||
$ipAddr1 .= $char;
|
||||
|
||||
$ipFlag = fread($fd, 1);
|
||||
if($ipFlag == chr(2)) {
|
||||
$AddrSeek2 = fread($fd, 3);
|
||||
if(strlen($AddrSeek2) < 3) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0)));
|
||||
fseek($fd, $AddrSeek2);
|
||||
} else {
|
||||
fseek($fd, -1, SEEK_CUR);
|
||||
}
|
||||
while(($char = fread($fd, 1)) != chr(0))
|
||||
$ipAddr2 .= $char;
|
||||
}
|
||||
fclose($fd);
|
||||
|
||||
if(preg_match('/http/i', $ipAddr2)) {
|
||||
$ipAddr2 = '';
|
||||
}
|
||||
$ipaddr = "$ipAddr1 $ipAddr2";
|
||||
$ipaddr = preg_replace('/CZ88\.NET/is', '', $ipaddr);
|
||||
$ipaddr = preg_replace('/^\s*/is', '', $ipaddr);
|
||||
$ipaddr = preg_replace('/\s*$/is', '', $ipaddr);
|
||||
if(preg_match('/http/i', $ipaddr) || $ipaddr == '') {
|
||||
$ipaddr = '- Unknown';
|
||||
}
|
||||
|
||||
return '- '.$ipaddr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 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;
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function convertip($ip) {
|
||||
|
||||
$return = '';
|
||||
|
||||
if(preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $ip)) {
|
||||
|
||||
$iparray = explode('.', $ip);
|
||||
|
||||
if($iparray[0] == 10 || $iparray[0] == 127 || ($iparray[0] == 192 && $iparray[1] == 168) || ($iparray[0] == 172 && ($iparray[1] >= 16 && $iparray[1] <= 31))) {
|
||||
$return = '- LAN';
|
||||
} elseif($iparray[0] > 255 || $iparray[1] > 255 || $iparray[2] > 255 || $iparray[3] > 255) {
|
||||
$return = '- Invalid IP Address';
|
||||
} else {
|
||||
$tinyipfile = DZZ_ROOT.'./data/ipdata/tinyipdata.dat';
|
||||
$fullipfile = DZZ_ROOT.'./data/ipdata/wry.dat';
|
||||
if(@file_exists($tinyipfile)) {
|
||||
$return = convertip_tiny($ip, $tinyipfile);
|
||||
} elseif(@file_exists($fullipfile)) {
|
||||
$return = convertip_full($ip, $fullipfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
function convertip_tiny($ip, $ipdatafile) {
|
||||
|
||||
static $fp = NULL, $offset = array(), $index = NULL;
|
||||
|
||||
$ipdot = explode('.', $ip);
|
||||
$ip = pack('N', ip2long($ip));
|
||||
|
||||
$ipdot[0] = (int)$ipdot[0];
|
||||
$ipdot[1] = (int)$ipdot[1];
|
||||
|
||||
if($fp === NULL && $fp = @fopen($ipdatafile, 'rb')) {
|
||||
$offset = @unpack('Nlen', @fread($fp, 4));
|
||||
$index = @fread($fp, $offset['len'] - 4);
|
||||
} elseif($fp == FALSE) {
|
||||
return '- Invalid IP data file';
|
||||
}
|
||||
|
||||
$length = $offset['len'] - 1028;
|
||||
$start = @unpack('Vlen', $index[$ipdot[0] * 4] . $index[$ipdot[0] * 4 + 1] . $index[$ipdot[0] * 4 + 2] . $index[$ipdot[0] * 4 + 3]);
|
||||
|
||||
for ($start = $start['len'] * 8 + 1024; $start < $length; $start += 8) {
|
||||
|
||||
if ($index[$start] . $index[$start + 1] . $index[$start + 2] . $index[$start + 3] >= $ip) {
|
||||
$index_offset = @unpack('Vlen', $index[$start + 4] . $index[$start + 5] . $index[$start + 6] . "\x0");
|
||||
$index_length = @unpack('Clen', $index[$start + 7]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@fseek($fp, $offset['len'] + $index_offset['len'] - 1024);
|
||||
if($index_length['len']) {
|
||||
return '- '.@fread($fp, $index_length['len']);
|
||||
} else {
|
||||
return '- Unknown';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function convertip_full($ip, $ipdatafile) {
|
||||
|
||||
if(!$fd = @fopen($ipdatafile, 'rb')) {
|
||||
return '- Invalid IP data file';
|
||||
}
|
||||
|
||||
$ip = explode('.', $ip);
|
||||
$ipNum = $ip[0] * 16777216 + $ip[1] * 65536 + $ip[2] * 256 + $ip[3];
|
||||
|
||||
if(!($DataBegin = fread($fd, 4)) || !($DataEnd = fread($fd, 4)) ) return;
|
||||
@$ipbegin = implode('', unpack('L', $DataBegin));
|
||||
if($ipbegin < 0) $ipbegin += pow(2, 32);
|
||||
@$ipend = implode('', unpack('L', $DataEnd));
|
||||
if($ipend < 0) $ipend += pow(2, 32);
|
||||
$ipAllNum = ($ipend - $ipbegin) / 7 + 1;
|
||||
|
||||
$BeginNum = $ip2num = $ip1num = 0;
|
||||
$ipAddr1 = $ipAddr2 = '';
|
||||
$EndNum = $ipAllNum;
|
||||
|
||||
while($ip1num > $ipNum || $ip2num < $ipNum) {
|
||||
$Middle= intval(($EndNum + $BeginNum) / 2);
|
||||
|
||||
fseek($fd, $ipbegin + 7 * $Middle);
|
||||
$ipData1 = fread($fd, 4);
|
||||
if(strlen($ipData1) < 4) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$ip1num = implode('', unpack('L', $ipData1));
|
||||
if($ip1num < 0) $ip1num += pow(2, 32);
|
||||
|
||||
if($ip1num > $ipNum) {
|
||||
$EndNum = $Middle;
|
||||
continue;
|
||||
}
|
||||
|
||||
$DataSeek = fread($fd, 3);
|
||||
if(strlen($DataSeek) < 3) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$DataSeek = implode('', unpack('L', $DataSeek.chr(0)));
|
||||
fseek($fd, $DataSeek);
|
||||
$ipData2 = fread($fd, 4);
|
||||
if(strlen($ipData2) < 4) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$ip2num = implode('', unpack('L', $ipData2));
|
||||
if($ip2num < 0) $ip2num += pow(2, 32);
|
||||
|
||||
if($ip2num < $ipNum) {
|
||||
if($Middle == $BeginNum) {
|
||||
fclose($fd);
|
||||
return '- Unknown';
|
||||
}
|
||||
$BeginNum = $Middle;
|
||||
}
|
||||
}
|
||||
|
||||
$ipFlag = fread($fd, 1);
|
||||
if($ipFlag == chr(1)) {
|
||||
$ipSeek = fread($fd, 3);
|
||||
if(strlen($ipSeek) < 3) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$ipSeek = implode('', unpack('L', $ipSeek.chr(0)));
|
||||
fseek($fd, $ipSeek);
|
||||
$ipFlag = fread($fd, 1);
|
||||
}
|
||||
|
||||
if($ipFlag == chr(2)) {
|
||||
$AddrSeek = fread($fd, 3);
|
||||
if(strlen($AddrSeek) < 3) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$ipFlag = fread($fd, 1);
|
||||
if($ipFlag == chr(2)) {
|
||||
$AddrSeek2 = fread($fd, 3);
|
||||
if(strlen($AddrSeek2) < 3) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0)));
|
||||
fseek($fd, $AddrSeek2);
|
||||
} else {
|
||||
fseek($fd, -1, SEEK_CUR);
|
||||
}
|
||||
|
||||
while(($char = fread($fd, 1)) != chr(0))
|
||||
$ipAddr2 .= $char;
|
||||
|
||||
$AddrSeek = implode('', unpack('L', $AddrSeek.chr(0)));
|
||||
fseek($fd, $AddrSeek);
|
||||
|
||||
while(($char = fread($fd, 1)) != chr(0))
|
||||
$ipAddr1 .= $char;
|
||||
} else {
|
||||
fseek($fd, -1, SEEK_CUR);
|
||||
while(($char = fread($fd, 1)) != chr(0))
|
||||
$ipAddr1 .= $char;
|
||||
|
||||
$ipFlag = fread($fd, 1);
|
||||
if($ipFlag == chr(2)) {
|
||||
$AddrSeek2 = fread($fd, 3);
|
||||
if(strlen($AddrSeek2) < 3) {
|
||||
fclose($fd);
|
||||
return '- System Error';
|
||||
}
|
||||
$AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0)));
|
||||
fseek($fd, $AddrSeek2);
|
||||
} else {
|
||||
fseek($fd, -1, SEEK_CUR);
|
||||
}
|
||||
while(($char = fread($fd, 1)) != chr(0))
|
||||
$ipAddr2 .= $char;
|
||||
}
|
||||
fclose($fd);
|
||||
|
||||
if(preg_match('/http/i', $ipAddr2)) {
|
||||
$ipAddr2 = '';
|
||||
}
|
||||
$ipaddr = "$ipAddr1 $ipAddr2";
|
||||
$ipaddr = preg_replace('/CZ88\.NET/is', '', $ipaddr);
|
||||
$ipaddr = preg_replace('/^\s*/is', '', $ipaddr);
|
||||
$ipaddr = preg_replace('/\s*$/is', '', $ipaddr);
|
||||
if(preg_match('/http/i', $ipaddr) || $ipaddr == '') {
|
||||
$ipaddr = '- Unknown';
|
||||
}
|
||||
|
||||
return '- '.$ipaddr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 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;
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,281 +1,281 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||
* @license https://www.oaooa.com/licenses/
|
||||
*
|
||||
* @link https://www.oaooa.com
|
||||
* @author zyx(zyx@oaooa.com)
|
||||
*/
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function checkAtPerm($gid){//检查@部门权限
|
||||
global $_G;
|
||||
$range=$at_range=$_G['setting']['at_range'][$_G['groupid']];
|
||||
if($range==3){//所有机构
|
||||
return true;
|
||||
}elseif($range==2){//机构
|
||||
$orgids=C::t('organization_user')->fetch_orgids_by_uid($_G['uid']);
|
||||
foreach($orgids as $orgid){
|
||||
$toporgids= C::t('organization')->fetch_parent_by_orgid($orgid);
|
||||
if(in_array($gid,$toporgids)) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}elseif($range==1){//部门
|
||||
$orgids=C::t('organization_user')->fetch_orgids_by_uid($_G['uid']);
|
||||
if(in_array($gid,$orgids)) return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//获取部门的目录树,返回从机构到此部门的名称的数组
|
||||
function getPathByOrgid($orgid,$path=array()){
|
||||
return C::t('organization')->getPathByOrgid($orgid,false);
|
||||
}
|
||||
//获取机构树
|
||||
function getDepartmentOption($orgid,$url='',$all=false,$i=0,$pname=array()){
|
||||
$html='';
|
||||
|
||||
//$data[$orgid]['i']=$i;
|
||||
|
||||
if( $i<1){
|
||||
if($all){
|
||||
$html.='<li role="presentation">';
|
||||
$html.='<a href="'.($url?($url.'&depid=0'):'javascript:;').'" tabindex="-1" role="menuitem" _orgid="0" '.(!$url?'onclick="selDepart(this)"':'').'>';
|
||||
$html.='<div class="child-org">';
|
||||
for($j=0;$j<$i-1;$j++){
|
||||
$html.='<span class="child-tree tree-su"> </span>';
|
||||
}
|
||||
$html.=lang('all');
|
||||
$html.='</div>';
|
||||
$html.='</a></li>';
|
||||
}
|
||||
if($org=C::t('organization')->fetch($orgid)){
|
||||
$pname[$i]=$org['orgname'];
|
||||
$html.='<li role="presentation">';
|
||||
$html.='<a href="'.($url?($url.'&depid='.$org['orgid']):'javascript:;').'" tabindex="-1" role="menuitem" _orgid="'.$org['orgid'].'" '.(!$url?'onclick="selDepart(this)"':'').' data-orgname='.implode('-',$pname).'>';
|
||||
$html.='<div class="child-org">';
|
||||
for($j=0;$j<$i-1;$j++){
|
||||
$html.='<span class="child-tree tree-su"> </span>';
|
||||
}
|
||||
$html.=$org['orgname'];
|
||||
$html.='</div>';
|
||||
$html.='</a></li>';
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
$count=C::t('organization')->fetch_all_by_forgid($orgid,true,0);
|
||||
if($count){
|
||||
$k=1;
|
||||
|
||||
foreach(C::t('organization')->fetch_all_by_forgid($orgid) as $key=> $value){
|
||||
$pname[$i]=$value['orgname'];
|
||||
$html.='<li role="presentation">';
|
||||
$html.='<a href="'.($url?($url.'&depid='.$value['orgid']):'javascript:;').'" tabindex="-1" role="menuitem" _orgid="'.$value['orgid'].'" '.(!$url?'onclick="selDepart(this)"':'').' data-orgname='.implode('-',$pname).'>';
|
||||
$html.='<div class="child-org">';
|
||||
for($j=0;$j<$i-1;$j++){
|
||||
$html.='<span class="child-tree tree-su"> </span>';
|
||||
}
|
||||
$html.='<span class="child-tree '.($k<$count?'tree-heng':'tree-heng1').'"> </span>'.$value['orgname'];
|
||||
$html.='</div>';
|
||||
$html.='</a></li>';
|
||||
$html.=getDepartmentOption($value['orgid'],$url,false,$i,$pname);
|
||||
$k++;
|
||||
}
|
||||
//$html.='</tbody>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
//获取机构树
|
||||
function getDepartmentOption_admin($orgid,$url='',$all=false,$i=0,$tree=array()){
|
||||
global $_G;
|
||||
$html='';
|
||||
if($i<1 && ($org=C::t('organization')->fetch($orgid)) && $org['forgid']<1){
|
||||
$tree[]=$org['orgname'];
|
||||
if(!$all){
|
||||
$ismoderator=C::t('organization_admin')->ismoderator_by_uid_orgid($org['orgid'],$_G['uid']);
|
||||
}else{
|
||||
$ismoderator=1;
|
||||
}
|
||||
if($ismoderator){
|
||||
$html.='<li role="presentation">';
|
||||
}else{
|
||||
$html.='<li role="presentation" class="disabled">';
|
||||
}
|
||||
|
||||
|
||||
$html.='<a href="'.($url?($url.'&depid='.$org['orgid']):'javascript:;').'" tabindex="-1" role="menuitem" _orgid="'.$org['orgid'].'" '.(!$url?($ismoderator?'onclick="selDepart(this)"':''):'').' data-text="'.implode(' - ',$tree).'">'.$org['orgname'].'</a>';
|
||||
$html+'</li>';
|
||||
}
|
||||
|
||||
$i++;
|
||||
$count=C::t('organization')->fetch_all_by_forgid($orgid,true);
|
||||
if($count){
|
||||
$k=1;
|
||||
$value=array();
|
||||
foreach(C::t('organization')->fetch_all_by_forgid($orgid) as $key=> $value){
|
||||
if(!$all){
|
||||
$ismoderator=C::t('organization_admin')->ismoderator_by_uid_orgid($value['orgid'],$_G['uid']);
|
||||
}else{
|
||||
$ismoderator=1;
|
||||
}
|
||||
|
||||
if($ismoderator){
|
||||
$html.='<li role="presentation">';
|
||||
}else{
|
||||
$html.='<li role="presentation" class="disabled">';
|
||||
}
|
||||
|
||||
$html.='<a href="'.($url?($url.'&depid='.$value['orgid']):'javascript:;').'" tabindex="-1" role="menuitem" _orgid="'.$value['orgid'].'" '.(!$url?($ismoderator?'onclick="selDepart(this)"':''):'').' data-text="'.($tree?(implode(' - ',$tree).' - '):'').$value['orgname'].'">';
|
||||
$html.='<div class="child-org">';
|
||||
for($j=0;$j<$i-1;$j++){
|
||||
$html.='<span class="child-tree tree-su"> </span>';
|
||||
}
|
||||
$html.='<span class="child-tree '.($k<$count?'tree-heng':'tree-heng1').'"> </span>'.$value['orgname'];
|
||||
$html.='</div>';
|
||||
$html.='</a></li>';
|
||||
$html.=getDepartmentOption_admin($value['orgid'],$url,$all,$i,array_merge($tree,array($value['orgname'])));
|
||||
$k++;
|
||||
}
|
||||
//$html.='</tbody>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
//获取机构树
|
||||
function getDepartmentJStree($orgid=0,$notin=array()){
|
||||
static $uids=array();
|
||||
$html='';
|
||||
foreach(C::t('organization')->fetch_all_by_forgid($orgid) as $key=> $value){
|
||||
$html.='<li data-jstree=\'{"type":"org","icon":"dzz/system/images/organization.png"}\'>'.$value['orgname'];
|
||||
$html.='<ul>';
|
||||
if(C::t('organization')->fetch_all_by_forgid($value['orgid'],true)){
|
||||
$re=getDepartmentJStree($value['orgid'],$notin,$html);
|
||||
$html.= $re['html'];
|
||||
}
|
||||
$users=getUserByOrgid($value['orgid'],0,$notin);
|
||||
foreach($users as $value1){
|
||||
$uids[]=$value1['uid'];
|
||||
$html.='<li uid="'.$value1['uid'].'" data-jstree=\'{"type":"user","icon":"dzz/system/images/user.png"}\'>'.$value1['username'].'</li>';
|
||||
}
|
||||
|
||||
$html.='</ul>';
|
||||
$html.=' </li>';
|
||||
}
|
||||
return array('html'=>$html,'uids'=>$uids);
|
||||
}
|
||||
//获取用户所在的部门
|
||||
function getDepartmentByUid($uid,$getManage=0){
|
||||
$data=array();
|
||||
//获取用户所加入的所有部门
|
||||
$orgids=C::t('organization_user')->fetch_orgids_by_uid($uid);
|
||||
if($getManage && $orgids_m=C::t('organization_admin')->fetch_orgids_by_uid($uid)){
|
||||
$orgids=array_merge($orgids,$orgids_m);
|
||||
}
|
||||
foreach($orgids as $orgid){
|
||||
if($tree=getTreeByOrgid($orgid)){
|
||||
$data[$orgid]=$tree;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
//获取用户部门及所属机构
|
||||
function getOrgByUid($uid,$getManage=0){
|
||||
$orglist=array();
|
||||
$arr=getDepartmentByUid($uid,$getManage);
|
||||
foreach($arr as $key => $value){
|
||||
$orglist[$value[0]['orgid']]=$value[0];
|
||||
}
|
||||
foreach($arr as $key => $value){
|
||||
if(count($value)>1){
|
||||
$orglist[$value[0]['orgid']]['sublist'][$value[count($value)-1]['orgid']]=$value[count($value)-1];
|
||||
}
|
||||
}
|
||||
return $orglist;
|
||||
}
|
||||
//获取应用可以使用的部门
|
||||
function getDepartmentByAppid($appid){
|
||||
$data=array();
|
||||
//获取用户所加入的所有部门
|
||||
$orgids=C::t('app_organization')->fetch_orgids_by_appid($appid);
|
||||
foreach($orgids as $orgid){
|
||||
if($tree=getTreeByOrgid($orgid)){
|
||||
$data[$orgid]=$tree;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
function getTreeByOrgid($orgid){
|
||||
$orgarr= C::t('organization')->fetch_parent_by_orgid($orgid,false);
|
||||
return $orgarr;
|
||||
}
|
||||
//获取机构或部门的用户列表
|
||||
//$dep: ==0 只获取此机构的用户;
|
||||
// >0 获取全部下级机构的成员
|
||||
// $notin 排除的用户列表;
|
||||
//返回 user列表数组;
|
||||
function getUserByOrgid($orgids,$dep=0,$notin=array(),$onlyuid=false){
|
||||
$orgids=(array)$orgids;
|
||||
if(!$orgids){ return array();}
|
||||
$ids=array();
|
||||
foreach($orgids as $orgid){
|
||||
if($dep){
|
||||
$ids=array_merge($ids,getOrgidTree($orgid));
|
||||
}else{
|
||||
$ids[]=$orgid;
|
||||
}
|
||||
}
|
||||
$uids=C::t('organization_user')->fetch_uids_by_orgid($ids);
|
||||
if($notin){
|
||||
$arr=array();
|
||||
foreach($uids as $uid){
|
||||
if(!in_array($uid ,$notin)) $arr[]=$uid;
|
||||
}
|
||||
$uids=$arr;
|
||||
unset($arr);
|
||||
}
|
||||
|
||||
if($onlyuid) return $uids;
|
||||
|
||||
return DB::fetch_all("select uid,username from %t where uid IN (%n) ",array('user',$uids));
|
||||
}
|
||||
function getOrgidByUid($uid,$sub=true){//获取用户所在部门ID和所有下级部门ID
|
||||
$ret=array();
|
||||
$orgids=C::t('organization_user')->fetch_orgids_by_uid($uid);
|
||||
if($sub){
|
||||
foreach($orgids as $orgid){
|
||||
$ret=array_merge($ret,getOrgidTree($orgid));
|
||||
}
|
||||
}else{
|
||||
$ret=$orgids;
|
||||
}
|
||||
return array_unique($ret);
|
||||
}
|
||||
//获取此机构和所有下属机构的id
|
||||
function getOrgidTree($orgid){
|
||||
$oids=array();
|
||||
if($org=C::t('organization')->fetch($orgid)){
|
||||
foreach(DB::fetch_all("select orgid from %t where pathkey LIKE %s order by disp",array('organization',$org['pathkey'].'%')) as $value){
|
||||
$oids[]=$value['orgid'];
|
||||
}
|
||||
$oids=array_diff($oids,array($orgid));
|
||||
array_unshift($oids,$orgid);
|
||||
}
|
||||
return $oids;
|
||||
}
|
||||
//获取此机构和所有上级机构的id
|
||||
//获取此机构和所有上级机构的id
|
||||
function getUpOrgidTree($orgid,$onlyid=true,$pids=array()){
|
||||
global $_G;
|
||||
if($org=C::t('organization')->fetch($orgid)){
|
||||
if($onlyid){
|
||||
array_unshift($pids,$orgid);
|
||||
}else{
|
||||
$pids[$orgid]=$org;
|
||||
}
|
||||
$pids=getUpOrgidTree($org['forgid'],$onlyid,$pids);
|
||||
}
|
||||
return ($pids);
|
||||
<?php
|
||||
/*
|
||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||
* @license https://www.oaooa.com/licenses/
|
||||
*
|
||||
* @link https://www.oaooa.com
|
||||
* @author zyx(zyx@oaooa.com)
|
||||
*/
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function checkAtPerm($gid){//检查@部门权限
|
||||
global $_G;
|
||||
$range=$at_range=$_G['setting']['at_range'][$_G['groupid']];
|
||||
if($range==3){//所有机构
|
||||
return true;
|
||||
}elseif($range==2){//机构
|
||||
$orgids=C::t('organization_user')->fetch_orgids_by_uid($_G['uid']);
|
||||
foreach($orgids as $orgid){
|
||||
$toporgids= C::t('organization')->fetch_parent_by_orgid($orgid);
|
||||
if(in_array($gid,$toporgids)) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}elseif($range==1){//部门
|
||||
$orgids=C::t('organization_user')->fetch_orgids_by_uid($_G['uid']);
|
||||
if(in_array($gid,$orgids)) return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//获取部门的目录树,返回从机构到此部门的名称的数组
|
||||
function getPathByOrgid($orgid,$path=array()){
|
||||
return C::t('organization')->getPathByOrgid($orgid,false);
|
||||
}
|
||||
//获取机构树
|
||||
function getDepartmentOption($orgid,$url='',$all=false,$i=0,$pname=array()){
|
||||
$html='';
|
||||
|
||||
//$data[$orgid]['i']=$i;
|
||||
|
||||
if( $i<1){
|
||||
if($all){
|
||||
$html.='<li role="presentation">';
|
||||
$html.='<a href="'.($url?($url.'&depid=0'):'javascript:;').'" tabindex="-1" role="menuitem" _orgid="0" '.(!$url?'onclick="selDepart(this)"':'').'>';
|
||||
$html.='<div class="child-org">';
|
||||
for($j=0;$j<$i-1;$j++){
|
||||
$html.='<span class="child-tree tree-su"> </span>';
|
||||
}
|
||||
$html.=lang('all');
|
||||
$html.='</div>';
|
||||
$html.='</a></li>';
|
||||
}
|
||||
if($org=C::t('organization')->fetch($orgid)){
|
||||
$pname[$i]=$org['orgname'];
|
||||
$html.='<li role="presentation">';
|
||||
$html.='<a href="'.($url?($url.'&depid='.$org['orgid']):'javascript:;').'" tabindex="-1" role="menuitem" _orgid="'.$org['orgid'].'" '.(!$url?'onclick="selDepart(this)"':'').' data-orgname='.implode('-',$pname).'>';
|
||||
$html.='<div class="child-org">';
|
||||
for($j=0;$j<$i-1;$j++){
|
||||
$html.='<span class="child-tree tree-su"> </span>';
|
||||
}
|
||||
$html.=$org['orgname'];
|
||||
$html.='</div>';
|
||||
$html.='</a></li>';
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
$count=C::t('organization')->fetch_all_by_forgid($orgid,true,0);
|
||||
if($count){
|
||||
$k=1;
|
||||
|
||||
foreach(C::t('organization')->fetch_all_by_forgid($orgid) as $key=> $value){
|
||||
$pname[$i]=$value['orgname'];
|
||||
$html.='<li role="presentation">';
|
||||
$html.='<a href="'.($url?($url.'&depid='.$value['orgid']):'javascript:;').'" tabindex="-1" role="menuitem" _orgid="'.$value['orgid'].'" '.(!$url?'onclick="selDepart(this)"':'').' data-orgname='.implode('-',$pname).'>';
|
||||
$html.='<div class="child-org">';
|
||||
for($j=0;$j<$i-1;$j++){
|
||||
$html.='<span class="child-tree tree-su"> </span>';
|
||||
}
|
||||
$html.='<span class="child-tree '.($k<$count?'tree-heng':'tree-heng1').'"> </span>'.$value['orgname'];
|
||||
$html.='</div>';
|
||||
$html.='</a></li>';
|
||||
$html.=getDepartmentOption($value['orgid'],$url,false,$i,$pname);
|
||||
$k++;
|
||||
}
|
||||
//$html.='</tbody>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
//获取机构树
|
||||
function getDepartmentOption_admin($orgid,$url='',$all=false,$i=0,$tree=array()){
|
||||
global $_G;
|
||||
$html='';
|
||||
if($i<1 && ($org=C::t('organization')->fetch($orgid)) && $org['forgid']<1){
|
||||
$tree[]=$org['orgname'];
|
||||
if(!$all){
|
||||
$ismoderator=C::t('organization_admin')->ismoderator_by_uid_orgid($org['orgid'],$_G['uid']);
|
||||
}else{
|
||||
$ismoderator=1;
|
||||
}
|
||||
if($ismoderator){
|
||||
$html.='<li role="presentation">';
|
||||
}else{
|
||||
$html.='<li role="presentation" class="disabled">';
|
||||
}
|
||||
|
||||
|
||||
$html.='<a href="'.($url?($url.'&depid='.$org['orgid']):'javascript:;').'" tabindex="-1" role="menuitem" _orgid="'.$org['orgid'].'" '.(!$url?($ismoderator?'onclick="selDepart(this)"':''):'').' data-text="'.implode(' - ',$tree).'">'.$org['orgname'].'</a>';
|
||||
$html+'</li>';
|
||||
}
|
||||
|
||||
$i++;
|
||||
$count=C::t('organization')->fetch_all_by_forgid($orgid,true);
|
||||
if($count){
|
||||
$k=1;
|
||||
$value=array();
|
||||
foreach(C::t('organization')->fetch_all_by_forgid($orgid) as $key=> $value){
|
||||
if(!$all){
|
||||
$ismoderator=C::t('organization_admin')->ismoderator_by_uid_orgid($value['orgid'],$_G['uid']);
|
||||
}else{
|
||||
$ismoderator=1;
|
||||
}
|
||||
|
||||
if($ismoderator){
|
||||
$html.='<li role="presentation">';
|
||||
}else{
|
||||
$html.='<li role="presentation" class="disabled">';
|
||||
}
|
||||
|
||||
$html.='<a href="'.($url?($url.'&depid='.$value['orgid']):'javascript:;').'" tabindex="-1" role="menuitem" _orgid="'.$value['orgid'].'" '.(!$url?($ismoderator?'onclick="selDepart(this)"':''):'').' data-text="'.($tree?(implode(' - ',$tree).' - '):'').$value['orgname'].'">';
|
||||
$html.='<div class="child-org">';
|
||||
for($j=0;$j<$i-1;$j++){
|
||||
$html.='<span class="child-tree tree-su"> </span>';
|
||||
}
|
||||
$html.='<span class="child-tree '.($k<$count?'tree-heng':'tree-heng1').'"> </span>'.$value['orgname'];
|
||||
$html.='</div>';
|
||||
$html.='</a></li>';
|
||||
$html.=getDepartmentOption_admin($value['orgid'],$url,$all,$i,array_merge($tree,array($value['orgname'])));
|
||||
$k++;
|
||||
}
|
||||
//$html.='</tbody>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
//获取机构树
|
||||
function getDepartmentJStree($orgid=0,$notin=array()){
|
||||
static $uids=array();
|
||||
$html='';
|
||||
foreach(C::t('organization')->fetch_all_by_forgid($orgid) as $key=> $value){
|
||||
$html.='<li data-jstree=\'{"type":"org","icon":"dzz/system/images/organization.png"}\'>'.$value['orgname'];
|
||||
$html.='<ul>';
|
||||
if(C::t('organization')->fetch_all_by_forgid($value['orgid'],true)){
|
||||
$re=getDepartmentJStree($value['orgid'],$notin,$html);
|
||||
$html.= $re['html'];
|
||||
}
|
||||
$users=getUserByOrgid($value['orgid'],0,$notin);
|
||||
foreach($users as $value1){
|
||||
$uids[]=$value1['uid'];
|
||||
$html.='<li uid="'.$value1['uid'].'" data-jstree=\'{"type":"user","icon":"dzz/system/images/user.png"}\'>'.$value1['username'].'</li>';
|
||||
}
|
||||
|
||||
$html.='</ul>';
|
||||
$html.=' </li>';
|
||||
}
|
||||
return array('html'=>$html,'uids'=>$uids);
|
||||
}
|
||||
//获取用户所在的部门
|
||||
function getDepartmentByUid($uid,$getManage=0){
|
||||
$data=array();
|
||||
//获取用户所加入的所有部门
|
||||
$orgids=C::t('organization_user')->fetch_orgids_by_uid($uid);
|
||||
if($getManage && $orgids_m=C::t('organization_admin')->fetch_orgids_by_uid($uid)){
|
||||
$orgids=array_merge($orgids,$orgids_m);
|
||||
}
|
||||
foreach($orgids as $orgid){
|
||||
if($tree=getTreeByOrgid($orgid)){
|
||||
$data[$orgid]=$tree;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
//获取用户部门及所属机构
|
||||
function getOrgByUid($uid,$getManage=0){
|
||||
$orglist=array();
|
||||
$arr=getDepartmentByUid($uid,$getManage);
|
||||
foreach($arr as $key => $value){
|
||||
$orglist[$value[0]['orgid']]=$value[0];
|
||||
}
|
||||
foreach($arr as $key => $value){
|
||||
if(count($value)>1){
|
||||
$orglist[$value[0]['orgid']]['sublist'][$value[count($value)-1]['orgid']]=$value[count($value)-1];
|
||||
}
|
||||
}
|
||||
return $orglist;
|
||||
}
|
||||
//获取应用可以使用的部门
|
||||
function getDepartmentByAppid($appid){
|
||||
$data=array();
|
||||
//获取用户所加入的所有部门
|
||||
$orgids=C::t('app_organization')->fetch_orgids_by_appid($appid);
|
||||
foreach($orgids as $orgid){
|
||||
if($tree=getTreeByOrgid($orgid)){
|
||||
$data[$orgid]=$tree;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
function getTreeByOrgid($orgid){
|
||||
$orgarr= C::t('organization')->fetch_parent_by_orgid($orgid,false);
|
||||
return $orgarr;
|
||||
}
|
||||
//获取机构或部门的用户列表
|
||||
//$dep: ==0 只获取此机构的用户;
|
||||
// >0 获取全部下级机构的成员
|
||||
// $notin 排除的用户列表;
|
||||
//返回 user列表数组;
|
||||
function getUserByOrgid($orgids,$dep=0,$notin=array(),$onlyuid=false){
|
||||
$orgids=(array)$orgids;
|
||||
if(!$orgids){ return array();}
|
||||
$ids=array();
|
||||
foreach($orgids as $orgid){
|
||||
if($dep){
|
||||
$ids=array_merge($ids,getOrgidTree($orgid));
|
||||
}else{
|
||||
$ids[]=$orgid;
|
||||
}
|
||||
}
|
||||
$uids=C::t('organization_user')->fetch_uids_by_orgid($ids);
|
||||
if($notin){
|
||||
$arr=array();
|
||||
foreach($uids as $uid){
|
||||
if(!in_array($uid ,$notin)) $arr[]=$uid;
|
||||
}
|
||||
$uids=$arr;
|
||||
unset($arr);
|
||||
}
|
||||
|
||||
if($onlyuid) return $uids;
|
||||
|
||||
return DB::fetch_all("select uid,username from %t where uid IN (%n) ",array('user',$uids));
|
||||
}
|
||||
function getOrgidByUid($uid,$sub=true){//获取用户所在部门ID和所有下级部门ID
|
||||
$ret=array();
|
||||
$orgids=C::t('organization_user')->fetch_orgids_by_uid($uid);
|
||||
if($sub){
|
||||
foreach($orgids as $orgid){
|
||||
$ret=array_merge($ret,getOrgidTree($orgid));
|
||||
}
|
||||
}else{
|
||||
$ret=$orgids;
|
||||
}
|
||||
return array_unique($ret);
|
||||
}
|
||||
//获取此机构和所有下属机构的id
|
||||
function getOrgidTree($orgid){
|
||||
$oids=array();
|
||||
if($org=C::t('organization')->fetch($orgid)){
|
||||
foreach(DB::fetch_all("select orgid from %t where pathkey LIKE %s order by disp",array('organization',$org['pathkey'].'%')) as $value){
|
||||
$oids[]=$value['orgid'];
|
||||
}
|
||||
$oids=array_diff($oids,array($orgid));
|
||||
array_unshift($oids,$orgid);
|
||||
}
|
||||
return $oids;
|
||||
}
|
||||
//获取此机构和所有上级机构的id
|
||||
//获取此机构和所有上级机构的id
|
||||
function getUpOrgidTree($orgid,$onlyid=true,$pids=array()){
|
||||
global $_G;
|
||||
if($org=C::t('organization')->fetch($orgid)){
|
||||
if($onlyid){
|
||||
array_unshift($pids,$orgid);
|
||||
}else{
|
||||
$pids[$orgid]=$org;
|
||||
}
|
||||
$pids=getUpOrgidTree($org['forgid'],$onlyid,$pids);
|
||||
}
|
||||
return ($pids);
|
||||
}
|
||||
@@ -1,59 +1,59 @@
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function make_seccode($idhash){
|
||||
global $_G;
|
||||
$seccode = random(6, 1);
|
||||
$seccodeunits = '';
|
||||
if($_G['setting']['seccodedata']['type'] == 1) {
|
||||
$len = strtoupper(CHARSET) == 'GBK' ? 2 : 3;
|
||||
$code = array(substr($seccode, 0, 3), substr($seccode, 3, 3));
|
||||
$seccode = '';
|
||||
for($i = 0; $i < 2; $i++) {
|
||||
$seccode .= substr(lang('chn'), $code[$i] * $len, $len);
|
||||
}
|
||||
} elseif($_G['setting']['seccodedata']['type'] == 3) {
|
||||
$s = sprintf('%04s', base_convert($seccode, 10, 20));
|
||||
$seccodeunits = 'CEFHKLMNOPQRSTUVWXYZ';
|
||||
} else {
|
||||
$s = sprintf('%04s', base_convert($seccode, 10, 24));
|
||||
$seccodeunits = 'BCEFGHJKMPQRTVWXY2346789';
|
||||
}
|
||||
if($seccodeunits) {
|
||||
$seccode = '';
|
||||
for($i = 0; $i < 4; $i++) {
|
||||
$unit = ord($s{$i});
|
||||
$seccode .= ($unit >= 0x30 && $unit <= 0x39) ? $seccodeunits[$unit - 0x30] : $seccodeunits[$unit - 0x57];
|
||||
}
|
||||
}
|
||||
dsetcookie('seccode'.$idhash, authcode(strtoupper($seccode)."\t".(TIMESTAMP - 180)."\t".$idhash."\t".FORMHASH, 'ENCODE', $_G['config']['security']['authkey']), 0, 1, true);
|
||||
return $seccode;
|
||||
}
|
||||
|
||||
function make_secqaa($idhash) {
|
||||
global $_G;
|
||||
loadcache('secqaa');
|
||||
$secqaakey = max(1, random(1, 1));
|
||||
|
||||
if($_G['cache']['secqaa'][$secqaakey]['type']) {
|
||||
|
||||
$qaafile = libfile('secqaa/'.$_G['cache']['secqaa'][$secqaakey]['question'], 'class');
|
||||
$class = $_G['cache']['secqaa'][$secqaakey]['question'];
|
||||
|
||||
if(file_exists($qaafile)) {
|
||||
@include_once $qaafile;
|
||||
$class = 'secqaa_'.$class;
|
||||
if(class_exists($class)) {
|
||||
$qaa = new $class();
|
||||
if(method_exists($qaa, 'make')) {
|
||||
$_G['cache']['secqaa'][$secqaakey]['answer'] = md5($qaa->make($_G['cache']['secqaa'][$secqaakey]['question']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dsetcookie('secqaa'.$idhash, authcode($_G['cache']['secqaa'][$secqaakey]['answer']."\t".(TIMESTAMP - 180)."\t".$idhash."\t".FORMHASH, 'ENCODE', $_G['config']['security']['authkey']), 0, 1, true);
|
||||
return $_G['cache']['secqaa'][$secqaakey]['question'];
|
||||
}
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
function make_seccode($idhash){
|
||||
global $_G;
|
||||
$seccode = random(6, 1);
|
||||
$seccodeunits = '';
|
||||
if($_G['setting']['seccodedata']['type'] == 1) {
|
||||
$len = strtoupper(CHARSET) == 'GBK' ? 2 : 3;
|
||||
$code = array(substr($seccode, 0, 3), substr($seccode, 3, 3));
|
||||
$seccode = '';
|
||||
for($i = 0; $i < 2; $i++) {
|
||||
$seccode .= substr(lang('chn'), $code[$i] * $len, $len);
|
||||
}
|
||||
} elseif($_G['setting']['seccodedata']['type'] == 3) {
|
||||
$s = sprintf('%04s', base_convert($seccode, 10, 20));
|
||||
$seccodeunits = 'CEFHKLMNOPQRSTUVWXYZ';
|
||||
} else {
|
||||
$s = sprintf('%04s', base_convert($seccode, 10, 24));
|
||||
$seccodeunits = 'BCEFGHJKMPQRTVWXY2346789';
|
||||
}
|
||||
if($seccodeunits) {
|
||||
$seccode = '';
|
||||
for($i = 0; $i < 4; $i++) {
|
||||
$unit = ord($s{$i});
|
||||
$seccode .= ($unit >= 0x30 && $unit <= 0x39) ? $seccodeunits[$unit - 0x30] : $seccodeunits[$unit - 0x57];
|
||||
}
|
||||
}
|
||||
dsetcookie('seccode'.$idhash, authcode(strtoupper($seccode)."\t".(TIMESTAMP - 180)."\t".$idhash."\t".FORMHASH, 'ENCODE', $_G['config']['security']['authkey']), 0, 1, true);
|
||||
return $seccode;
|
||||
}
|
||||
|
||||
function make_secqaa($idhash) {
|
||||
global $_G;
|
||||
loadcache('secqaa');
|
||||
$secqaakey = max(1, random(1, 1));
|
||||
|
||||
if($_G['cache']['secqaa'][$secqaakey]['type']) {
|
||||
|
||||
$qaafile = libfile('secqaa/'.$_G['cache']['secqaa'][$secqaakey]['question'], 'class');
|
||||
$class = $_G['cache']['secqaa'][$secqaakey]['question'];
|
||||
|
||||
if(file_exists($qaafile)) {
|
||||
@include_once $qaafile;
|
||||
$class = 'secqaa_'.$class;
|
||||
if(class_exists($class)) {
|
||||
$qaa = new $class();
|
||||
if(method_exists($qaa, 'make')) {
|
||||
$_G['cache']['secqaa'][$secqaakey]['answer'] = md5($qaa->make($_G['cache']['secqaa'][$secqaakey]['question']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dsetcookie('secqaa'.$idhash, authcode($_G['cache']['secqaa'][$secqaakey]['answer']."\t".(TIMESTAMP - 180)."\t".$idhash."\t".FORMHASH, 'ENCODE', $_G['config']['security']['authkey']), 0, 1, true);
|
||||
return $_G['cache']['secqaa'][$secqaakey]['question'];
|
||||
}
|
||||
?>
|
||||
@@ -1,137 +1,137 @@
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
global $_G;
|
||||
if(is_string($this->config['security']['attackevasive'])) {
|
||||
$attackevasive_tmp = explode('|', $this->config['security']['attackevasive']);
|
||||
$attackevasive = 0;
|
||||
foreach($attackevasive_tmp AS $key => $value) {
|
||||
$attackevasive += intval($value);
|
||||
}
|
||||
unset($attackevasive_tmp);
|
||||
} else {
|
||||
$attackevasive = $this->config['security']['attackevasive'];
|
||||
}
|
||||
|
||||
$lastrequest = isset($_G['cookie']['lastrequest']) ? authcode($_G['cookie']['lastrequest'], 'DECODE') : '';
|
||||
|
||||
if($attackevasive & 1 || $attackevasive & 4) {
|
||||
dsetcookie('lastrequest', authcode(TIMESTAMP, 'ENCODE'), TIMESTAMP + 816400, 1, true);
|
||||
}
|
||||
|
||||
if($attackevasive & 1) {
|
||||
if(TIMESTAMP - $lastrequest < 1) {
|
||||
securitymessage('attackevasive_1_subject', 'attackevasive_1_message');
|
||||
}
|
||||
}
|
||||
|
||||
if(($attackevasive & 2) && ($_SERVER['HTTP_X_FORWARDED_FOR'] ||
|
||||
$_SERVER['HTTP_VIA'] || $_SERVER['HTTP_PROXY_CONNECTION'] ||
|
||||
$_SERVER['HTTP_USER_AGENT_VIA'] || $_SERVER['HTTP_CACHE_INFO'] ||
|
||||
$_SERVER['HTTP_PROXY_CONNECTION'])) {
|
||||
securitymessage('attackevasive_2_subject', 'attackevasive_2_message', FALSE);
|
||||
}
|
||||
|
||||
if($attackevasive & 4) {
|
||||
if(empty($lastrequest) || TIMESTAMP - $lastrequest > 300) {
|
||||
securitymessage('attackevasive_4_subject', 'attackevasive_4_message');
|
||||
}
|
||||
}
|
||||
|
||||
if($attackevasive & 8) {
|
||||
list($visitcode, $visitcheck, $visittime) = explode('|', authcode($_G['cookie']['visitcode'], 'DECODE'));
|
||||
if(!$visitcode || !$visitcheck || !$visittime || TIMESTAMP - $visittime > 60 * 60 * 4 ) {
|
||||
if(empty($_POST['secqsubmit']) || ($visitcode != md5($_POST['answer']))) {
|
||||
$answer = 0;
|
||||
$question = '';
|
||||
for ($i = 0; $i< rand(2, 5); $i ++) {
|
||||
$r = rand(1, 20);
|
||||
$question .= $question ? ' + '.$r : $r;
|
||||
$answer += $r;
|
||||
}
|
||||
$question .= ' = ?';
|
||||
dsetcookie('visitcode', authcode(md5($answer).'|0|'.TIMESTAMP, 'ENCODE'), TIMESTAMP + 816400, 1, true);
|
||||
securitymessage($question, '<input type="text" name="answer" size="8" maxlength="150" /><input type="submit" name="secqsubmit" class="button" value=" Submit " />', FALSE, TRUE);
|
||||
} else {
|
||||
dsetcookie('visitcode', authcode($visitcode.'|1|'.TIMESTAMP, 'ENCODE'), TIMESTAMP + 816400, 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function securitymessage($subject, $message, $reload = TRUE, $form = FALSE) {
|
||||
global $_G;
|
||||
$scuritylang = array(
|
||||
'attackevasive_1_subject' => '频繁刷新限制',
|
||||
'attackevasive_1_message' => '您访问本站速度过快或者刷新间隔时间小于两秒!请等待页面自动跳转 ...',
|
||||
'attackevasive_2_subject' => '代理服务器访问限制',
|
||||
'attackevasive_2_message' => '本站现在限制使用代理服务器访问,请去除您的代理设置,直接访问本站。',
|
||||
'attackevasive_4_subject' => '页面重载开启',
|
||||
'attackevasive_4_message' => '欢迎光临本站,页面正在重新载入,请稍候 ...'
|
||||
);
|
||||
|
||||
$subject = $scuritylang[$subject] ? $scuritylang[$subject] : $subject;
|
||||
$message = $scuritylang[$message] ? $scuritylang[$message] : $message;
|
||||
if($_GET['inajax']) {
|
||||
security_ajaxshowheader();
|
||||
echo '<div id="attackevasive_1" class="popupmenu_option"><b style="font-size: 16px">'.$subject.'</b><br /><br />'.$message.'</div>';
|
||||
security_ajaxshowfooter();
|
||||
} else {
|
||||
echo '<html>';
|
||||
echo '<head>';
|
||||
echo '<title>'.$subject.'</title>';
|
||||
echo '</head>';
|
||||
echo '<body bgcolor="#FFFFFF">';
|
||||
if($reload) {
|
||||
echo '<script language="JavaScript">';
|
||||
echo 'function reload() {';
|
||||
echo ' document.location.reload();';
|
||||
echo '}';
|
||||
echo 'setTimeout("reload()", 1001);';
|
||||
echo '</script>';
|
||||
}
|
||||
if($form) {
|
||||
echo '<form action="'.$G['PHP_SELF'].'" method="post" autocomplete="off">';
|
||||
}
|
||||
echo '<table cellpadding="0" cellspacing="0" border="0" width="700" align="center" height="85%">';
|
||||
echo ' <tr align="center" valign="middle">';
|
||||
echo ' <td>';
|
||||
echo ' <table cellpadding="10" cellspacing="0" border="0" width="80%" align="center" style="font-family: Verdana, Tahoma; color: #666666; font-size: 11px">';
|
||||
echo ' <tr>';
|
||||
echo ' <td valign="middle" align="center" bgcolor="#EBEBEB">';
|
||||
echo ' <br /><br /> <b style="font-size: 16px">'.$subject.'</b> <br /><br />';
|
||||
echo $message;
|
||||
echo ' <br /><br />';
|
||||
echo ' </td>';
|
||||
echo ' </tr>';
|
||||
echo ' </table>';
|
||||
echo ' </td>';
|
||||
echo ' </tr>';
|
||||
echo '</table>';
|
||||
if($form) {
|
||||
echo '</form>';
|
||||
}
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
function security_ajaxshowheader() {
|
||||
$charset = getglobal('config/output/charset');
|
||||
ob_end_clean();
|
||||
@header("Expires: -1");
|
||||
@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
|
||||
@header("Pragma: no-cache");
|
||||
header("Content-type: application/xml");
|
||||
echo "<?xml version=\"1.0\" encoding=\"".$charset."\"?>\n<root><![CDATA[";
|
||||
}
|
||||
|
||||
function security_ajaxshowfooter() {
|
||||
echo ']]></root>';
|
||||
exit();
|
||||
}
|
||||
|
||||
<?php
|
||||
if(!defined('IN_OAOOA')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
global $_G;
|
||||
if(is_string($this->config['security']['attackevasive'])) {
|
||||
$attackevasive_tmp = explode('|', $this->config['security']['attackevasive']);
|
||||
$attackevasive = 0;
|
||||
foreach($attackevasive_tmp AS $key => $value) {
|
||||
$attackevasive += intval($value);
|
||||
}
|
||||
unset($attackevasive_tmp);
|
||||
} else {
|
||||
$attackevasive = $this->config['security']['attackevasive'];
|
||||
}
|
||||
|
||||
$lastrequest = isset($_G['cookie']['lastrequest']) ? authcode($_G['cookie']['lastrequest'], 'DECODE') : '';
|
||||
|
||||
if($attackevasive & 1 || $attackevasive & 4) {
|
||||
dsetcookie('lastrequest', authcode(TIMESTAMP, 'ENCODE'), TIMESTAMP + 816400, 1, true);
|
||||
}
|
||||
|
||||
if($attackevasive & 1) {
|
||||
if(TIMESTAMP - $lastrequest < 1) {
|
||||
securitymessage('attackevasive_1_subject', 'attackevasive_1_message');
|
||||
}
|
||||
}
|
||||
|
||||
if(($attackevasive & 2) && ($_SERVER['HTTP_X_FORWARDED_FOR'] ||
|
||||
$_SERVER['HTTP_VIA'] || $_SERVER['HTTP_PROXY_CONNECTION'] ||
|
||||
$_SERVER['HTTP_USER_AGENT_VIA'] || $_SERVER['HTTP_CACHE_INFO'] ||
|
||||
$_SERVER['HTTP_PROXY_CONNECTION'])) {
|
||||
securitymessage('attackevasive_2_subject', 'attackevasive_2_message', FALSE);
|
||||
}
|
||||
|
||||
if($attackevasive & 4) {
|
||||
if(empty($lastrequest) || TIMESTAMP - $lastrequest > 300) {
|
||||
securitymessage('attackevasive_4_subject', 'attackevasive_4_message');
|
||||
}
|
||||
}
|
||||
|
||||
if($attackevasive & 8) {
|
||||
list($visitcode, $visitcheck, $visittime) = explode('|', authcode($_G['cookie']['visitcode'], 'DECODE'));
|
||||
if(!$visitcode || !$visitcheck || !$visittime || TIMESTAMP - $visittime > 60 * 60 * 4 ) {
|
||||
if(empty($_POST['secqsubmit']) || ($visitcode != md5($_POST['answer']))) {
|
||||
$answer = 0;
|
||||
$question = '';
|
||||
for ($i = 0; $i< rand(2, 5); $i ++) {
|
||||
$r = rand(1, 20);
|
||||
$question .= $question ? ' + '.$r : $r;
|
||||
$answer += $r;
|
||||
}
|
||||
$question .= ' = ?';
|
||||
dsetcookie('visitcode', authcode(md5($answer).'|0|'.TIMESTAMP, 'ENCODE'), TIMESTAMP + 816400, 1, true);
|
||||
securitymessage($question, '<input type="text" name="answer" size="8" maxlength="150" /><input type="submit" name="secqsubmit" class="button" value=" Submit " />', FALSE, TRUE);
|
||||
} else {
|
||||
dsetcookie('visitcode', authcode($visitcode.'|1|'.TIMESTAMP, 'ENCODE'), TIMESTAMP + 816400, 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function securitymessage($subject, $message, $reload = TRUE, $form = FALSE) {
|
||||
global $_G;
|
||||
$scuritylang = array(
|
||||
'attackevasive_1_subject' => '频繁刷新限制',
|
||||
'attackevasive_1_message' => '您访问本站速度过快或者刷新间隔时间小于两秒!请等待页面自动跳转 ...',
|
||||
'attackevasive_2_subject' => '代理服务器访问限制',
|
||||
'attackevasive_2_message' => '本站现在限制使用代理服务器访问,请去除您的代理设置,直接访问本站。',
|
||||
'attackevasive_4_subject' => '页面重载开启',
|
||||
'attackevasive_4_message' => '欢迎光临本站,页面正在重新载入,请稍候 ...'
|
||||
);
|
||||
|
||||
$subject = $scuritylang[$subject] ? $scuritylang[$subject] : $subject;
|
||||
$message = $scuritylang[$message] ? $scuritylang[$message] : $message;
|
||||
if($_GET['inajax']) {
|
||||
security_ajaxshowheader();
|
||||
echo '<div id="attackevasive_1" class="popupmenu_option"><b style="font-size: 16px">'.$subject.'</b><br /><br />'.$message.'</div>';
|
||||
security_ajaxshowfooter();
|
||||
} else {
|
||||
echo '<html>';
|
||||
echo '<head>';
|
||||
echo '<title>'.$subject.'</title>';
|
||||
echo '</head>';
|
||||
echo '<body bgcolor="#FFFFFF">';
|
||||
if($reload) {
|
||||
echo '<script language="JavaScript">';
|
||||
echo 'function reload() {';
|
||||
echo ' document.location.reload();';
|
||||
echo '}';
|
||||
echo 'setTimeout("reload()", 1001);';
|
||||
echo '</script>';
|
||||
}
|
||||
if($form) {
|
||||
echo '<form action="'.$G['PHP_SELF'].'" method="post" autocomplete="off">';
|
||||
}
|
||||
echo '<table cellpadding="0" cellspacing="0" border="0" width="700" align="center" height="85%">';
|
||||
echo ' <tr align="center" valign="middle">';
|
||||
echo ' <td>';
|
||||
echo ' <table cellpadding="10" cellspacing="0" border="0" width="80%" align="center" style="font-family: Verdana, Tahoma; color: #666666; font-size: 11px">';
|
||||
echo ' <tr>';
|
||||
echo ' <td valign="middle" align="center" bgcolor="#EBEBEB">';
|
||||
echo ' <br /><br /> <b style="font-size: 16px">'.$subject.'</b> <br /><br />';
|
||||
echo $message;
|
||||
echo ' <br /><br />';
|
||||
echo ' </td>';
|
||||
echo ' </tr>';
|
||||
echo ' </table>';
|
||||
echo ' </td>';
|
||||
echo ' </tr>';
|
||||
echo '</table>';
|
||||
if($form) {
|
||||
echo '</form>';
|
||||
}
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
function security_ajaxshowheader() {
|
||||
$charset = getglobal('config/output/charset');
|
||||
ob_end_clean();
|
||||
@header("Expires: -1");
|
||||
@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
|
||||
@header("Pragma: no-cache");
|
||||
header("Content-type: application/xml");
|
||||
echo "<?xml version=\"1.0\" encoding=\"".$charset."\"?>\n<root><![CDATA[";
|
||||
}
|
||||
|
||||
function security_ajaxshowfooter() {
|
||||
echo ']]></root>';
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user