First commit
This commit is contained in:
26
source/class/helper/helper_access.php
Normal file
26
source/class/helper/helper_access.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_access.php 28057 2012-02-21 22:19:33Z zhengqingpeng $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_access {
|
||||
|
||||
public static function check_module($module) {
|
||||
$status = 0;
|
||||
$allowfuntype = array('portal', 'forum', 'friend', 'group', 'follow', 'collection', 'guide', 'feed', 'blog', 'doing', 'album', 'share', 'wall', 'homepage', 'ranklist', 'medal', 'task', 'magic', 'favorite');
|
||||
$module = in_array($module, $allowfuntype) ? trim($module) : '';
|
||||
if(!empty($module)) {
|
||||
$status = getglobal('setting/'.$module.'status');
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
178
source/class/helper/helper_antitheft.php
Normal file
178
source/class/helper/helper_antitheft.php
Normal file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_antitheft.php 33494 2013-06-26 05:26:25Z laoguozhang $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_antitheft {
|
||||
|
||||
public static function check($id, $idtype) {
|
||||
if((!isset($_GET['_dsign']) || $_GET['_dsign'] !== ($_dsign = dsign($id.$idtype, 8))) && !self::check_allow($id, $idtype)) {
|
||||
if(!isset($_dsign)) {
|
||||
$_dsign = dsign($id.$idtype, 8);
|
||||
}
|
||||
echo self::make_content($id, $idtype, $_dsign);exit;
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_sign($id, $idtype) {
|
||||
return !self::check_allow($id, $idtype) ? dsign($id.$idtype, 8) : '';
|
||||
}
|
||||
|
||||
protected static function check_allow($id, $idtype) {
|
||||
global $_G;
|
||||
loadcache('antitheft');
|
||||
if($_G['cache']['antitheft']['white']) {
|
||||
foreach(explode("\n", trim($_G['cache']['antitheft']['white'])) as $ctrlip) {
|
||||
if(preg_match("/^(".preg_quote(($ctrlip = trim($ctrlip)), '/').")/", $_G['clientip'])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($_G['cache']['antitheft']['black']) {
|
||||
foreach(explode("\n",trim($_G['cache']['antitheft']['black'])) as $ctrlip) {
|
||||
if(preg_match("/^(".preg_quote(($ctrlip = trim($ctrlip)), '/').")/", $_G['clientip'])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!($log = C::t('common_visit')->fetch($_G['clientip']))) {
|
||||
C::t('common_visit')->insert(array(
|
||||
'ip' => $_G['clientip'],
|
||||
'view' => 1,
|
||||
));
|
||||
return true;
|
||||
} elseif($log['view'] >= $_G['setting']['antitheft']['max']) {
|
||||
return false;
|
||||
} else {
|
||||
C::t('common_visit')->inc($_G['clientip']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected static function make_content($id, $idtype, $dsign) {
|
||||
$url = '';
|
||||
$urls = parse_url($_SERVER['REQUEST_URI']);
|
||||
$addstr = $urls['query'] ? $urls['query'].'&' : '';
|
||||
$url = $urls['path'].'?'.$addstr.'_dsign='.$dsign.($urls['fragment'] ? '#'.$urls['fragment'] : '');
|
||||
|
||||
return self::make_js($url);
|
||||
}
|
||||
|
||||
protected static function make_js($url){
|
||||
$js = '<script type="text/javascript">';
|
||||
$varname = array();
|
||||
$codes = array();
|
||||
$window = '_'.random(5);
|
||||
$location = '_'.random(5);
|
||||
$href = '_'.random(5);
|
||||
$replace = '_'.random(5);
|
||||
$assign = '_'.random(5);
|
||||
$codes[$window] = "$window = window;";
|
||||
$codes[$location] = "$location = location;";
|
||||
$codes[$href] = "$href = 'href';";
|
||||
$codes[$replace] = "$replace = 'replace';";
|
||||
$codes[$assign] = "$assign = 'assign';";
|
||||
$codes['getname'] = 'function getName(){var caller=getName.caller;if(caller.name){return caller.name} var str=caller.toString().replace(/[\s]*/g,"");var name=str.match(/^function([^\(]+?)\(/);if(name && name[1]){return name[1];} else {return \'\';}}';
|
||||
$jskeywords = array('for' => '', 'case' => '', 'if' => '', 'else' => '', 'try' => '', 'new' => '', 'eval' => '', 'var' => ''); //js关键字
|
||||
$methods = array(1,2,3,4,5,6,7);
|
||||
$lenths = array(2,2,3,4);
|
||||
for($i = 0, $l = strlen($url); $i < $l; $i++) {
|
||||
$len = $lenths[array_rand($lenths)];
|
||||
$cflag = $len % 2;
|
||||
$var = random($len);
|
||||
if(ctype_digit($var[0])) {
|
||||
$var = '_'.$var;
|
||||
}
|
||||
while(isset($varname[$var])) {
|
||||
$var = random(3);
|
||||
if(ctype_digit($var[0])) {
|
||||
$var = '_'.$var;
|
||||
}
|
||||
}
|
||||
$val = substr($url, $i, $len-1);
|
||||
$i = $i + $len - 2;
|
||||
switch ($methods[array_rand($methods)]) {
|
||||
case 1:
|
||||
if($cflag) {
|
||||
$varname[$var] = "'$val'";
|
||||
} else {
|
||||
$codes[] = "$var='$val';";
|
||||
$varname[$var] = $var;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(!isset($jskeywords[$val]) && ctype_alnum($val) && !ctype_digit($val[0])) {
|
||||
$codes[] = "function $var({$var}_){function $val(){return getName();};return $val();return '{$var}'}";
|
||||
$varname[$var] = "$var('".random($len)."')";
|
||||
} else {
|
||||
$codes[] = "function $var(){'return $var';return '$val'}";
|
||||
$varname[$var] = $var.'()';
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if($cflag) {
|
||||
$codes[] = "$var=function({$var}_){'return $var';return {$var}_;};";
|
||||
$varname[$var] = "$var('$val')";
|
||||
} else {
|
||||
$codes[] = "$var=function(){'return $var';return '$val';};";
|
||||
$varname[$var] = "$var()";
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if($cflag) {
|
||||
$varname[$var] = "(function({$var}_){'return $var';return {$var}_})('$val')";
|
||||
} else {
|
||||
$varname[$var] = "(function(){'return $var';return '$val'})()";
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if(!isset($jskeywords[$val]) && ctype_alnum($val) && !ctype_digit($val[0])) {
|
||||
$codes[] = "function $var({$var}_){function _{$var[0]}({$var}_){function $val(){return getName();}function {$var}_(){}return $val();return {$var}_}; return _{$var[0]}({$var}_);}";
|
||||
$varname[$var] = "$var('".random($len)."')";
|
||||
} else {
|
||||
$codes[] = "function $var(){'$var';function _{$var[0]}(){return '$val'}; return _{$var[0]}();}";
|
||||
$varname[$var] = $var.'()';
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if($cflag) {
|
||||
$codes[] = "$var=function({$var}_){var _{$var[0]}=function({$var}_){'return $var';return {$var}_;}; return _{$var[0]}({$var}_);};";
|
||||
$varname[$var] = "$var('$val')";
|
||||
} else {
|
||||
$codes[] = "$var=function(){'$var';var _{$var[0]}=function(){return '$val'}; return _{$var[0]}();};";
|
||||
$varname[$var] = $var.'()';
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if($cflag) {
|
||||
$varname[$var] = "(function({$var}_){return (function({$var}_){return {$var}_;})({$var}_);})('$val')";
|
||||
} else {
|
||||
$varname[$var] = "(function(){'return $var';return (function(){return '$val';})();})()";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
shuffle($codes);
|
||||
$js .= implode('', $codes);
|
||||
$hrefheader = array('location.href=', 'location=', "{$location}[$href]=", "location[$href]=",
|
||||
'location.replace(', 'location.assign(', "location[$assign](", "location[$replace](");
|
||||
$hreffooter = array('','','','',')',')',')',')');
|
||||
$index = array_rand($hrefheader);
|
||||
$js .= $hrefheader[$index]. implode('+', $varname).$hreffooter[$index].';';
|
||||
$fix = array("{$window}[$href]=", "{$window}['href']=", "{$window}.href=");
|
||||
$js .= $fix[array_rand($fix)].implode('+', array_slice($varname, 0, 8)).';';
|
||||
$js .= '</script>';
|
||||
return $js;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
38
source/class/helper/helper_attach.php
Normal file
38
source/class/helper/helper_attach.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_attach.php 32531 2013-02-06 10:15:19Z zhangguosheng $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_attach {
|
||||
|
||||
public static function makethumbpath($id, $w, $h){
|
||||
$dw = intval($w);
|
||||
$dh = intval($h);
|
||||
$_daid = sprintf("%09d", $id);
|
||||
$dir1 = substr($_daid, 0, 3);
|
||||
$dir2 = substr($_daid, 3, 2);
|
||||
$dir3 = substr($_daid, 5, 2);
|
||||
return $dir1.'/'.$dir2.'/'.$dir3.'/'.substr($_daid, -2).'_'.$dw.'_'.$dh.'.jpg';
|
||||
}
|
||||
|
||||
public static function attachpreurl() {
|
||||
static $attachurl = null;
|
||||
if($attachurl === null) {
|
||||
global $_G;
|
||||
$parse = parse_url($_G['setting']['attachurl']);
|
||||
$attachurl = !isset($parse['host']) ? $_G['siteurl'].$_G['setting']['attachurl'] : $_G['setting']['attachurl'];
|
||||
}
|
||||
return $attachurl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
66
source/class/helper/helper_dbtool.php
Normal file
66
source/class/helper/helper_dbtool.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_dbtool.php 36319 2016-12-20 02:03:23Z nemohou $
|
||||
*/
|
||||
if (!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_dbtool {
|
||||
|
||||
public static function dbversion() {
|
||||
$db = & DB::object();
|
||||
return $db->version();
|
||||
}
|
||||
|
||||
public static function dbsize() {
|
||||
$dbsize = 0;
|
||||
$query = DB::query("SHOW TABLE STATUS LIKE '".getglobal('config/db/1/tablepre')."%'", 'SILENT');
|
||||
while($table = DB::fetch($query)) {
|
||||
$dbsize += $table['Data_length'] + $table['Index_length'];
|
||||
}
|
||||
return $dbsize;
|
||||
}
|
||||
|
||||
public static function gettablestatus($tablename, $formatsize = true) {
|
||||
$status = DB::fetch_first("SHOW TABLE STATUS LIKE '".str_replace('_', '\_', $tablename)."'");
|
||||
|
||||
if($formatsize) {
|
||||
$status['Data_length'] = sizecount($status['Data_length']);
|
||||
$status['Index_length'] = sizecount($status['Index_length']);
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
public static function showtablecloumn($tablename) {
|
||||
$data = array();
|
||||
$db = &DB::object();
|
||||
$query = $db->query("SHOW FULL COLUMNS FROM ".DB::table($tablename), 'SILENT');
|
||||
while($field = @DB::fetch($query)) {
|
||||
$data[$field['Field']] = $field;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function isexisttable($tablename) {
|
||||
$tablearr = array();
|
||||
$query = DB::query('SHOW TABLES', 'SILENT');
|
||||
while($table = DB::fetch($query)) {
|
||||
foreach($table as $value) {
|
||||
$tablearr[] = $value;
|
||||
}
|
||||
}
|
||||
if(in_array(DB::table($tablename), $tablearr)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
137
source/class/helper/helper_form.php
Normal file
137
source/class/helper/helper_form.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_form.php 35986 2016-06-06 01:37:04Z nemohou $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_form {
|
||||
|
||||
|
||||
public static function submitcheck($var, $allowget = 0, $seccodecheck = 0, $secqaacheck = 0) {
|
||||
if(!getgpc($var)) {
|
||||
return FALSE;
|
||||
} else {
|
||||
global $_G;
|
||||
if(($allowget && ($allowget !== 2 || (!empty($_GET['formhash']) && $_GET['formhash'] == formhash()))) || ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_GET['formhash']) && $_GET['formhash'] == formhash() && empty($_SERVER['HTTP_X_FLASH_VERSION']) && (empty($_SERVER['HTTP_REFERER']) ||
|
||||
strncmp($_SERVER['HTTP_REFERER'], 'http://wsq.discuz.com/', 22) === 0 || preg_replace("/https?:\/\/([^\:\/]+).*/i", "\\1", $_SERVER['HTTP_REFERER']) == preg_replace("/([^\:]+).*/", "\\1", $_SERVER['HTTP_HOST'])))) {
|
||||
if(checkperm('seccode')) {
|
||||
if($secqaacheck && !check_secqaa($_GET['secanswer'], $_GET['secqaahash'])) {
|
||||
showmessage('submit_secqaa_invalid');
|
||||
}
|
||||
if($seccodecheck && !check_seccode($_GET['seccodeverify'], $_GET['seccodehash'], 0, $_GET['seccodemodid'])) {
|
||||
showmessage('submit_seccode_invalid');
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
showmessage('submit_invalid');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function censor($message, $modword = NULL, $return = FALSE, $modasban = TRUE) {
|
||||
global $_G;
|
||||
$censor = discuz_censor::instance();
|
||||
$censor->check($message, $modword);
|
||||
if(($censor->modbanned() && empty($_G['group']['ignorecensor'])) || (($modasban && !empty($_G['setting']['modasban'])) && $censor->modmoderated() && empty($_G['group']['ignorecensor']))) {
|
||||
$wordbanned = implode(', ', $censor->words_found);
|
||||
if($return) {
|
||||
return array('message' => lang('message', 'word_banned', array('wordbanned' => $wordbanned)));
|
||||
}
|
||||
if(!defined('IN_ADMINCP')) {
|
||||
showmessage('word_banned', '', array('wordbanned' => $wordbanned));
|
||||
} else {
|
||||
cpmsg(lang('message', 'word_banned'), '', 'error', array('wordbanned' => $wordbanned));
|
||||
}
|
||||
}
|
||||
if($_G['group']['allowposturl'] == 0) {
|
||||
$urllist = self::get_url_list($message);
|
||||
if(is_array($urllist[1])) {
|
||||
foreach($urllist[1] as $key => $val) {
|
||||
if(!$val = trim($val)) continue;
|
||||
if(!iswhitelist($val)) {
|
||||
if($return) {
|
||||
return array('message' => 'post_url_nopermission');
|
||||
}
|
||||
showmessage('post_url_nopermission');
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif($_G['group']['allowposturl'] == 2) {
|
||||
$message = preg_replace("/\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.|mailto:|tel:|magnet:)?([^\r\n\[\"']+?))?\](.+?)\[\/url\]/is", '\\5', $message);
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
public static function censormod($message) {
|
||||
global $_G;
|
||||
if($_G['group']['ignorecensor']) {
|
||||
return false;
|
||||
}
|
||||
$modposturl = false;
|
||||
if($_G['group']['allowposturl'] == 1) {
|
||||
$urllist = self::get_url_list($message);
|
||||
if(is_array($urllist[1])) foreach($urllist[1] as $key => $val) {
|
||||
if(!$val = trim($val)) continue;
|
||||
if(!iswhitelist($val)) {
|
||||
$modposturl = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($modposturl) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$censor = discuz_censor::instance();
|
||||
$censor->check($message);
|
||||
return $censor->modmoderated();
|
||||
}
|
||||
|
||||
public static function get_url_list($message) {
|
||||
$return = array();
|
||||
|
||||
(strpos($message, '[/img]') || strpos($message, '[/flash]')) && $message = preg_replace("/\[img[^\]]*\]\s*([^\[\<\r\n]+?)\s*\[\/img\]|\[flash[^\]]*\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is", '', $message);
|
||||
if(preg_match_all("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.)[^ \[\]\"']+/i", $message, $urllist)) {
|
||||
foreach($urllist[0] as $key => $val) {
|
||||
$val = trim($val);
|
||||
$return[0][$key] = $val;
|
||||
if(!preg_match('/^https?:\/\//is', $val)) $val = 'http://'.$val;
|
||||
$tmp = parse_url($val);
|
||||
$return[1][$key] = $tmp['host'];
|
||||
if($tmp['port']){
|
||||
$return[1][$key] .= ":{$tmp['port']}";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function updatemoderate($idtype, $ids, $status = 0) {
|
||||
$ids = is_array($ids) ? $ids : array($ids);
|
||||
if(!$ids) {
|
||||
return;
|
||||
}
|
||||
if(!$status) {
|
||||
foreach($ids as $id) {
|
||||
C::t('common_moderate')->insert_moderate($idtype, array(
|
||||
'id' => $id,
|
||||
'status' => 0,
|
||||
'dateline' => TIMESTAMP,
|
||||
), false, true);
|
||||
}
|
||||
} elseif($status == 1) {
|
||||
C::t('common_moderate')->update_moderate($ids, $idtype, array('status' => 1));
|
||||
} elseif($status == 2) {
|
||||
C::t('common_moderate')->delete_moderate($ids, $idtype);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
21
source/class/helper/helper_invite.php
Normal file
21
source/class/helper/helper_invite.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_invite {
|
||||
|
||||
public static function generate_key($uid) {
|
||||
global $_G;
|
||||
$user = C::t('common_member')->fetch($uid);
|
||||
return substr(md5(md5($user['password']).'|'.$uid), 8, 16);
|
||||
}
|
||||
|
||||
}
|
53
source/class/helper/helper_json.php
Normal file
53
source/class/helper/helper_json.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_json.php 32779 2013-03-08 02:57:37Z zhangguosheng $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_json {
|
||||
|
||||
public static function encode($data) {
|
||||
switch ($type = gettype($data)) {
|
||||
case 'NULL':
|
||||
return 'null';
|
||||
case 'boolean':
|
||||
return ($data ? 'true' : 'false');
|
||||
case 'integer':
|
||||
case 'double':
|
||||
case 'float':
|
||||
return $data;
|
||||
case 'string':
|
||||
return '"' . addcslashes($data, "\r\n\t\"") . '"';
|
||||
case 'object':
|
||||
$data = get_object_vars($data);
|
||||
case 'array':
|
||||
$count = 0;
|
||||
$indexed = array();
|
||||
$associative = array();
|
||||
foreach ($data as $key => $value) {
|
||||
if($count !== NULL && (gettype($key) !== 'integer' || $count++ !== $key)) {
|
||||
$count = NULL;
|
||||
}
|
||||
$one = self::encode($value);
|
||||
$indexed[] = $one;
|
||||
$associative[] = self::encode($key) . ':' . $one;
|
||||
}
|
||||
if ($count !== NULL) {
|
||||
return '[' . implode(',', $indexed) . ']';
|
||||
} else {
|
||||
return '{' . implode(',', $associative) . '}';
|
||||
}
|
||||
default:
|
||||
return ''; // Not supported
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
87
source/class/helper/helper_log.php
Normal file
87
source/class/helper/helper_log.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_log.php 28822 2012-03-14 06:35:55Z zhangguosheng $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_log {
|
||||
|
||||
public static function runlog($file, $message, $halt=0) {
|
||||
global $_G;
|
||||
|
||||
$nowurl = $_SERVER['REQUEST_URI']?$_SERVER['REQUEST_URI']:($_SERVER['PHP_SELF']?$_SERVER['PHP_SELF']:$_SERVER['SCRIPT_NAME']);
|
||||
$log = dgmdate($_G['timestamp'], 'Y-m-d H:i:s')."\t".$_G['clientip']."\t{$_G['uid']}\t{$nowurl}\t".str_replace(array("\r", "\n"), array(' ', ' '), trim($message))."\n";
|
||||
helper_log::writelog($file, $log);
|
||||
if($halt) {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function writelog($file, $log) {
|
||||
global $_G;
|
||||
$yearmonth = dgmdate(TIMESTAMP, 'Ym', $_G['setting']['timeoffset']);
|
||||
$logdir = DISCUZ_ROOT.'./data/log/';
|
||||
$logfile = $logdir.$yearmonth.'_'.$file.'.php';
|
||||
if(@filesize($logfile) > 2048000) {
|
||||
$dir = opendir($logdir);
|
||||
$length = strlen($file);
|
||||
$maxid = $id = 0;
|
||||
while($entry = readdir($dir)) {
|
||||
if(strpos($entry, $yearmonth.'_'.$file) !== false) {
|
||||
$id = intval(substr($entry, $length + 8, -4));
|
||||
$id > $maxid && $maxid = $id;
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
$logfilebak = $logdir.$yearmonth.'_'.$file.'_'.($maxid + 1).'.php';
|
||||
@rename($logfile, $logfilebak);
|
||||
}
|
||||
$fp = fopen($logfile, 'a');
|
||||
if($fp) {
|
||||
if(!is_array($log)) {
|
||||
$log = array($log);
|
||||
}
|
||||
foreach($log as $tmp) {
|
||||
fwrite($fp, "<?PHP exit;?>\t".str_replace(array('<?', '?>'), '', $tmp)."\n");
|
||||
}
|
||||
fflush($fp);
|
||||
fclose($fp);
|
||||
} else {
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function useractionlog($uid, $action) {
|
||||
$uid = intval($uid);
|
||||
if(empty($uid) || empty($action)) {
|
||||
return false;
|
||||
}
|
||||
$action = getuseraction($action);
|
||||
C::t('common_member_action_log')->insert(array('uid' => $uid, 'action' => $action, 'dateline' => TIMESTAMP));
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getuseraction($var) {
|
||||
$value = false;
|
||||
$ops = array('tid', 'pid', 'blogid', 'picid', 'doid', 'sid', 'aid', 'uid_cid', 'blogid_cid', 'sid_cid', 'picid_cid', 'aid_cid', 'topicid_cid', 'pmid');
|
||||
if(is_numeric($var)) {
|
||||
$value = isset($ops[$var]) ? $ops[$var] : false;
|
||||
} else {
|
||||
$value = array_search($var, $ops);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
163
source/class/helper/helper_makehtml.php
Normal file
163
source/class/helper/helper_makehtml.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_makehtml.php 34675 2014-07-01 05:58:13Z laoguozhang $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_makehtml {
|
||||
|
||||
public static $callback;
|
||||
|
||||
public static $callbackdata;
|
||||
|
||||
public static $htmlfilename;
|
||||
|
||||
public static $returndata = array();
|
||||
|
||||
public static $viewurl;
|
||||
|
||||
public static function make_html() {
|
||||
global $_G;
|
||||
if(self::$htmlfilename) {
|
||||
$filepath = DISCUZ_ROOT.'/'.self::$htmlfilename.'.'.$_G['setting']['makehtml']['extendname'];
|
||||
dmkdir(dirname($filepath));
|
||||
$cend = '</body></html>';
|
||||
$code = ob_get_clean().$cend;
|
||||
$code = preg_replace('/language\s*=[\s|\'|\"]*php/is', '_', $code);
|
||||
$code = str_replace(array('<?', '?>'), array('<?', '?>'), $code);
|
||||
if(file_put_contents($filepath, $code) !== false) {
|
||||
$_G['gzipcompress'] ? ob_start('ob_gzhandler') : ob_start();
|
||||
if(self::$callback && is_callable(self::$callback)) {
|
||||
call_user_func(self::$callback);
|
||||
self::$callback = self::$callbackdata = null;
|
||||
}
|
||||
self::$returndata['status'] = 'html_ok';
|
||||
if(isset(self::$viewurl)) {
|
||||
self::$returndata['path'] = self::$viewurl;
|
||||
} else {
|
||||
self::$returndata['path'] = self::$htmlfilename.'.'.$_G['setting']['makehtml']['extendname'];
|
||||
}
|
||||
showmessage('do_success', null, self::$returndata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function portal_index() {
|
||||
global $_G;
|
||||
if(!empty($_G['setting']['makehtml']['flag'])) {
|
||||
$_G['dynamicurl'] = 'portal.php';
|
||||
self::$htmlfilename = $_G['setting']['makehtml']['indexname'] ? $_G['setting']['makehtml']['indexname'] : 'index';
|
||||
}
|
||||
}
|
||||
|
||||
public static function portal_list($cat) {
|
||||
global $_G;
|
||||
if(!empty($_G['setting']['makehtml']['flag']) && $cat['fullfoldername']) {
|
||||
$_G['dynamicurl'] = 'portal.php?mod=list&catid='.$cat['catid'];
|
||||
self::$htmlfilename = $cat['fullfoldername'].'/index';
|
||||
} else if(!empty($_G['setting']['makehtml']['flag']) && !$cat['fullfoldername']) {
|
||||
showmessage('portal_category_has_no_folder_name');
|
||||
}
|
||||
}
|
||||
public static function portal_article($cat, $article, $page) {
|
||||
global $_G;
|
||||
if(!empty($_G['setting']['makehtml']['flag']) && $cat['fullfoldername']) {
|
||||
$_G['dynamicurl'] = 'portal.php?mod=view&aid='.$article['aid'];
|
||||
self::$callbackdata['data'] = array();
|
||||
if(!$article['htmlmade']) {
|
||||
self::$callbackdata['data']['htmlmade'] = 1;
|
||||
}
|
||||
if(!$article['htmlname']) {
|
||||
self::$callbackdata['data']['htmlname'] = $article['htmlname'] = str_pad($article['aid'], 8, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
$htmldir = self::fetch_dir($cat['fullfoldername'], $article['timestamp']);
|
||||
if($article['htmldir'] != $htmldir) {
|
||||
self::$callbackdata['data']['htmldir'] = $htmldir;
|
||||
}
|
||||
if($article['contents'] > 1 && $page > 1) {
|
||||
$article['htmlname'] = $article['htmlname'].$page;
|
||||
}
|
||||
if($article['contents'] > $page) {
|
||||
self::$returndata['nexturl'] = "portal.php?mod=view&aid={$article['aid']}&page=".(++$page);//'url'
|
||||
self::$returndata['current'] = $page;//'cur'
|
||||
self::$returndata['count'] = $article['contents'];//'count'
|
||||
}
|
||||
|
||||
if(!empty($cat['topid'])) {
|
||||
$caturl = $_G['cache']['portalcategory'][$cat['topid']]['domain'] ? $_G['cache']['portalcategory'][$cat['topid']]['caturl'] : '';
|
||||
self::$viewurl = $caturl.$article['htmldir'].$article['htmlname'].'.'.$_G['setting']['makehtml']['extendname'];
|
||||
}
|
||||
|
||||
self::$htmlfilename = $htmldir.$article['htmlname'];
|
||||
if(self::$callbackdata['data']) {
|
||||
self::$callback = array(get_class(), 'portal_article_success');
|
||||
self::$callbackdata['id'] = $article['aid'];
|
||||
}
|
||||
if($article['allowcomment']) {
|
||||
$_G['htmlcheckupdate'] = '1';
|
||||
}
|
||||
} else if(!empty($_G['setting']['makehtml']['flag']) && !$cat['fullfoldername']) {
|
||||
showmessage('portal_category_has_no_folder_name');
|
||||
}
|
||||
}
|
||||
|
||||
public static function fetch_dir($folder, $time) {
|
||||
global $_G;
|
||||
$formatarr = array('/Ym/', '/Ym/d/', '/Y/m/', '/Y/m/d/');
|
||||
$htmldirformat = isset($formatarr[$_G['setting']['makehtml']['htmldirformat']]) ? $formatarr[$_G['setting']['makehtml']['htmldirformat']] : $formatarr[0];
|
||||
$htmldir = $folder.dgmdate($time, $htmldirformat);
|
||||
if(!empty($_G['setting']['makehtml']['articlehtmldir'])) {
|
||||
$htmldir = $_G['setting']['makehtml']['articlehtmldir'].'/'.$htmldir;
|
||||
}
|
||||
return $htmldir;
|
||||
}
|
||||
|
||||
public static function portal_article_success(){
|
||||
if(!empty(self::$callbackdata['data'])) {
|
||||
C::t('portal_article_title')->update(self::$callbackdata['id'], self::$callbackdata['data']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function portal_topic($topic) {
|
||||
global $_G;
|
||||
if(!empty($_G['setting']['makehtml']['flag']) && !empty($_G['setting']['makehtml']['topichtmldir']) && $topic['name']) {
|
||||
$_G['dynamicurl'] = 'portal.php?mod=topic&topicid='.$topic['topicid'];
|
||||
self::$callbackdata['data'] = array();
|
||||
if(!$topic['htmlmade']) {
|
||||
self::$callbackdata['data']['htmlmade'] = 1;
|
||||
}
|
||||
|
||||
if($topic['htmldir'] != $_G['setting']['makehtml']['topichtmldir']) {
|
||||
self::$callbackdata['data']['htmldir'] = $_G['setting']['makehtml']['topichtmldir'];
|
||||
}
|
||||
self::$htmlfilename = $_G['setting']['makehtml']['topichtmldir'].'/'.$topic['name'];
|
||||
if(self::$callbackdata['data']) {
|
||||
self::$callback = array(get_class(), 'portal_topic_success');
|
||||
self::$callbackdata['id'] = $topic['topicid'];
|
||||
}
|
||||
if($topic['allowcomment']) {
|
||||
$_G['htmlcheckupdate'] = '1';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function portal_topic_success(){
|
||||
if(!empty(self::$callbackdata['data'])) {
|
||||
C::t('portal_topic')->update(self::$callbackdata['id'], self::$callbackdata['data']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
102
source/class/helper/helper_mobile.php
Normal file
102
source/class/helper/helper_mobile.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_mobile.php 36342 2017-01-09 01:15:30Z nemohou $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_mobile {
|
||||
|
||||
|
||||
public static function mobileoutput() {
|
||||
global $_G;
|
||||
if(!defined('TPL_DEFAULT')) {
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$content = self::mobilereplace_rewrite($content);
|
||||
$content = preg_replace_callback("/href=\"(\w+\.php)(.*?)\"/", array(__CLASS__, 'mobileoutput_callback_mobilereplace_12'), $content);
|
||||
|
||||
ob_start();
|
||||
if('utf-8' != CHARSET) {
|
||||
$content = diconv($content, CHARSET, 'utf-8');
|
||||
}
|
||||
@header('Content-Type: text/html; charset=utf-8');
|
||||
echo $content;
|
||||
exit();
|
||||
|
||||
} elseif (defined('TPL_DEFAULT') && !$_G['cookie']['dismobilemessage'] && $_G['mobile']) {
|
||||
ob_end_clean();
|
||||
ob_start();
|
||||
$_G['forcemobilemessage'] = true;
|
||||
parse_str($_SERVER['QUERY_STRING'], $query);
|
||||
$query['forcemobile'] = '1';
|
||||
$query_sting_tmp = http_build_query($query);
|
||||
$_G['setting']['mobile']['pageurl'] = $_G['siteurl'].basename($_G['PHP_SELF']).'?'.$query_sting_tmp;
|
||||
unset($query_sting_tmp);
|
||||
if(isset($_G['config']['templatedeveloper']) && $_G['config']['templatedeveloper']) {
|
||||
showmessage('template_developer_not_in_mobile', '', array('file' => constant('TPL_DEFAULT_FILE')));
|
||||
} else {
|
||||
showmessage('not_in_mobile');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public static function mobileoutput_callback_mobilereplace_12($matches) {
|
||||
return self::mobilereplace($matches[1], $matches[2]);
|
||||
}
|
||||
|
||||
public static function mobilereplace($file, $replace) {
|
||||
if(strpos($replace, 'mobile=') === false) {
|
||||
if(strpos($replace, '?') === false) {
|
||||
$replace = 'href="'.$file.$replace.'?mobile='.IN_MOBILE.'"';
|
||||
} else {
|
||||
$replace = 'href="'.$file.$replace.'&mobile='.IN_MOBILE.'"';
|
||||
}
|
||||
return $replace;
|
||||
} else {
|
||||
return 'href="'.$file.$replace.'"';
|
||||
}
|
||||
}
|
||||
|
||||
private static function mobilereplace_rewrite($content) {
|
||||
global $_G;
|
||||
|
||||
if(defined('IN_MODCP') || defined('IN_ADMINCP') || !defined('IN_MOBILE') || constant('IN_MOBILE') !== '2') {
|
||||
return $content;
|
||||
}
|
||||
if(!empty($_G['setting']['output']['str']['search'])) {
|
||||
if(empty($_G['setting']['domain']['app']['default'])) {
|
||||
$_G['setting']['output']['str']['replace'] = str_replace('{CURHOST}', $_G['siteurl'], $_G['setting']['output']['str']['replace']);
|
||||
}
|
||||
$content = str_replace($_G['setting']['output']['str']['search'], $_G['setting']['output']['str']['replace'], $content);
|
||||
}
|
||||
if(!empty($_G['setting']['output']['preg']['search']) && (empty($_G['setting']['rewriteguest']) || empty($_G['uid'])) && !empty($_G['setting']['rewritemobile'])) {
|
||||
if(empty($_G['setting']['domain']['app']['default'])) {
|
||||
$_G['setting']['output']['preg']['search'] = str_replace('\{CURHOST\}', preg_quote($_G['siteurl'], '/'), $_G['setting']['output']['preg']['search']);
|
||||
$_G['setting']['output']['preg']['replace'] = str_replace('{CURHOST}', $_G['siteurl'], $_G['setting']['output']['preg']['replace']);
|
||||
}
|
||||
|
||||
foreach($_G['setting']['output']['preg']['search'] as $key => $value) {
|
||||
$content = preg_replace_callback(
|
||||
$value,
|
||||
function ($matches) use ($_G, $key) {
|
||||
return eval('return ' . $_G['setting']['output']['preg']['replace'][$key] . ';');
|
||||
},
|
||||
$content
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
203
source/class/helper/helper_notification.php
Normal file
203
source/class/helper/helper_notification.php
Normal file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_notification.php 34003 2013-09-18 04:31:14Z nemohou $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_notification {
|
||||
|
||||
|
||||
public static function notification_add($touid, $type, $note, $notevars = array(), $system = 0, $category = -1) {
|
||||
global $_G;
|
||||
|
||||
if(!($tospace = getuserbyuid($touid))) {
|
||||
return false;
|
||||
}
|
||||
space_merge($tospace, 'field_home');
|
||||
$filter = empty($tospace['privacy']['filter_note'])?array():array_keys($tospace['privacy']['filter_note']);
|
||||
|
||||
if($filter && (in_array($type.'|0', $filter) || in_array($type.'|'.$_G['uid'], $filter))) {
|
||||
return false;
|
||||
}
|
||||
if($category == -1) {
|
||||
$category = 0;
|
||||
$categoryname = '';
|
||||
if($type == 'follow' || $type == 'follower') {
|
||||
switch ($type) {
|
||||
case 'follow' : $category = 5; break;
|
||||
case 'follower' : $category = 6; break;
|
||||
}
|
||||
$categoryname = $type;
|
||||
} else {
|
||||
foreach($_G['notice_structure'] as $key => $val) {
|
||||
if(in_array($type, $val)) {
|
||||
switch ($key) {
|
||||
case 'mypost' : $category = 1; break;
|
||||
case 'interactive' : $category = 2; break;
|
||||
case 'system' : $category = 3; break;
|
||||
case 'manage' : $category = 4; break;
|
||||
default : $category = 0;
|
||||
}
|
||||
$categoryname = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch ($category) {
|
||||
case 1 : $categoryname = 'mypost'; break;
|
||||
case 2 : $categoryname = 'interactive'; break;
|
||||
case 3 : $categoryname = 'system'; break;
|
||||
case 4 : $categoryname = 'manage'; break;
|
||||
case 5 : $categoryname = 'follow'; break;
|
||||
case 6 : $categoryname = 'follower'; break;
|
||||
default : $categoryname = 'app';
|
||||
}
|
||||
}
|
||||
if($category == 0) {
|
||||
$categoryname = 'app';
|
||||
} elseif($category == 1 || $category == 2) {
|
||||
$categoryname = $type;
|
||||
}
|
||||
$notevars['actor'] = "<a href=\"home.php?mod=space&uid={$_G['uid']}\">".$_G['member']['username']."</a>";
|
||||
|
||||
$vars = explode(':', $note);
|
||||
if(count($vars) == 2) {
|
||||
$notestring = lang('plugin/'.$vars[0], $vars[1], $notevars);
|
||||
} else {
|
||||
$notestring = lang('notification', $note, $notevars);
|
||||
}
|
||||
|
||||
$oldnote = array();
|
||||
if($notevars['from_id'] && $notevars['from_idtype']) {
|
||||
$oldnote = C::t('home_notification')->fetch_by_fromid_uid($notevars['from_id'], $notevars['from_idtype'], $touid);
|
||||
}
|
||||
if(empty($oldnote['from_num'])) $oldnote['from_num'] = 0;
|
||||
$notevars['from_num'] = $notevars['from_num'] ? $notevars['from_num'] : 1;
|
||||
$setarr = array(
|
||||
'uid' => $touid,
|
||||
'type' => $type,
|
||||
'new' => 1,
|
||||
'authorid' => $_G['uid'],
|
||||
'author' => $_G['username'],
|
||||
'note' => $notestring,
|
||||
'dateline' => $_G['timestamp'],
|
||||
'from_id' => $notevars['from_id'],
|
||||
'from_idtype' => $notevars['from_idtype'],
|
||||
'from_num' => ($oldnote['from_num']+$notevars['from_num']),
|
||||
'category' => $category
|
||||
);
|
||||
if($system) {
|
||||
$setarr['authorid'] = 0;
|
||||
$setarr['author'] = '';
|
||||
}
|
||||
$pkId = 0;
|
||||
if($oldnote['id']) {
|
||||
C::t('home_notification')->update($oldnote['id'], $setarr);
|
||||
$pkId = $oldnote['id'];
|
||||
} else {
|
||||
$oldnote['new'] = 0;
|
||||
$pkId = C::t('home_notification')->insert($setarr, true);
|
||||
}
|
||||
$banType = array('task');
|
||||
|
||||
if(empty($oldnote['new'])) {
|
||||
C::t('common_member')->increase($touid, array('newprompt' => 1));
|
||||
$newprompt = C::t('common_member_newprompt')->fetch($touid);
|
||||
if($newprompt) {
|
||||
$newprompt['data'] = dunserialize($newprompt['data']);
|
||||
if(!empty($newprompt['data'][$categoryname])) {
|
||||
$newprompt['data'][$categoryname] = intval($newprompt['data'][$categoryname]) + 1;
|
||||
} else {
|
||||
$newprompt['data'][$categoryname] = 1;
|
||||
}
|
||||
C::t('common_member_newprompt')->update($touid, array('data' => serialize($newprompt['data'])));
|
||||
} else {
|
||||
C::t('common_member_newprompt')->insert_newprompt($touid, array($categoryname => 1));
|
||||
}
|
||||
require_once libfile('function/mail');
|
||||
$mail_subject = lang('notification', 'mail_to_user');
|
||||
sendmail_touser($touid, $mail_subject, $notestring, $type);
|
||||
}
|
||||
|
||||
if(!$system && $_G['uid'] && $touid != $_G['uid']) {
|
||||
C::t('home_friend')->update_num_by_uid_fuid(1, $_G['uid'], $touid);
|
||||
}
|
||||
}
|
||||
|
||||
public static function manage_addnotify($type, $from_num = 0, $langvar = array()) {
|
||||
global $_G;
|
||||
$notifyusers = dunserialize($_G['setting']['notifyusers']);
|
||||
$notifytypes = explode(',', $_G['setting']['adminnotifytypes']);
|
||||
$notifytypes = array_flip($notifytypes);
|
||||
$notearr = array('from_id' => 1,'from_idtype' => $type, 'from_num' => $from_num);
|
||||
if($langvar) {
|
||||
$langkey = $langvar['langkey'];
|
||||
$notearr = array_merge($notearr, $langvar);
|
||||
} else {
|
||||
$langkey = 'manage_'.$type;
|
||||
}
|
||||
foreach($notifyusers as $uid => $user) {
|
||||
if($user['types'][$notifytypes[$type]]) {
|
||||
helper_notification::notification_add($uid, $type, $langkey, $notearr, 1, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_categorynum($newprompt_data) {
|
||||
global $_G;
|
||||
$categorynum = array();
|
||||
if(empty($newprompt_data) || !is_array($newprompt_data)) {
|
||||
return array();
|
||||
}
|
||||
foreach($newprompt_data as $key => $val) {
|
||||
if(in_array($key, array('follow', 'follower'))) {
|
||||
continue;
|
||||
}
|
||||
if(in_array($key, $_G['notice_structure']['mypost'])) {
|
||||
$categorynum['mypost'] += $val;
|
||||
} elseif(in_array($key, $_G['notice_structure']['interactive'])) {
|
||||
$categorynum['interactive'] += $val;
|
||||
}else{
|
||||
$categorynum[$key] = $val;
|
||||
}
|
||||
}
|
||||
return $categorynum;
|
||||
}
|
||||
|
||||
public static function update_newprompt($uid, $type) {
|
||||
global $_G;
|
||||
if($_G['member']['newprompt_num']) {
|
||||
$tmpprompt = $_G['member']['newprompt_num'];
|
||||
$num = 0;
|
||||
$updateprompt = 0;
|
||||
if(!$type) {
|
||||
$tmpprompt = [];
|
||||
} elseif(!empty($tmpprompt[$type])) {
|
||||
unset($tmpprompt[$type]);
|
||||
$updateprompt = true;
|
||||
}
|
||||
foreach($tmpprompt as $key => $val) {
|
||||
$num += $val;
|
||||
}
|
||||
if($num) {
|
||||
if($updateprompt) {
|
||||
C::t('common_member_newprompt')->update($uid, array('data' => serialize($tmpprompt)));
|
||||
C::t('common_member')->update($uid, array('newprompt'=>$num));
|
||||
}
|
||||
} else {
|
||||
C::t('common_member_newprompt')->delete($_G['uid']);
|
||||
C::t('common_member')->update($_G['uid'], array('newprompt'=>0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
45
source/class/helper/helper_output.php
Normal file
45
source/class/helper/helper_output.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_output.php 31663 2012-09-19 09:56:03Z zhangguosheng $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_output {
|
||||
|
||||
protected static function _header($type = 'text/xml') {
|
||||
global $_G;
|
||||
ob_end_clean();
|
||||
$_G['gzipcompress'] ? ob_start('ob_gzhandler') : ob_start();
|
||||
@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: ".$type."; charset=".CHARSET);
|
||||
}
|
||||
|
||||
public static function xml($s) {
|
||||
self::_header('text/xml');
|
||||
echo '<?xml version="1.0" encoding="'.CHARSET.'"?>'."\r\n", '<root><![CDATA[', $s, ']]></root>';
|
||||
exit();
|
||||
}
|
||||
|
||||
public static function json($data) {
|
||||
self::_header('application/json');
|
||||
echo helper_json::encode($data);
|
||||
exit();
|
||||
}
|
||||
|
||||
public static function html($s) {
|
||||
self::_header('text/html');
|
||||
echo $s;
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
168
source/class/helper/helper_page.php
Normal file
168
source/class/helper/helper_page.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_page.php 33588 2013-07-12 06:34:56Z hypowang $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_page {
|
||||
|
||||
|
||||
public static function multi($num, $perpage, $curpage, $mpurl, $maxpages = 0, $page = 10, $autogoto = FALSE, $simple = FALSE, $jsfunc = FALSE) {
|
||||
global $_G;
|
||||
$ajaxtarget = !empty($_GET['ajaxtarget']) ? " ajaxtarget=\"".dhtmlspecialchars($_GET['ajaxtarget'])."\" " : '';
|
||||
|
||||
$a_name = '';
|
||||
|
||||
$mpurl = str_replace(array("'", '"', "\\"), array('%27', '%22', '%5c'), $mpurl);
|
||||
|
||||
if(strpos($mpurl, '#') !== FALSE) {
|
||||
$a_strs = explode('#', $mpurl);
|
||||
$mpurl = $a_strs[0];
|
||||
$a_name = '#'.$a_strs[1];
|
||||
}
|
||||
if($jsfunc !== FALSE) {
|
||||
$mpurl = 'javascript:'.$mpurl;
|
||||
$a_name = $jsfunc;
|
||||
$pagevar = '';
|
||||
} else {
|
||||
$pagevar = 'page=';
|
||||
}
|
||||
|
||||
if(defined('IN_ADMINCP')) {
|
||||
$shownum = $showkbd = TRUE;
|
||||
$showpagejump = FALSE;
|
||||
$lang['prev'] = '‹‹';
|
||||
$lang['next'] = '››';
|
||||
} else {
|
||||
$shownum = $showkbd = FALSE;
|
||||
$showpagejump = TRUE;
|
||||
if(defined('IN_MOBILE') && !defined('TPL_DEFAULT')) {
|
||||
$lang['prev'] = lang('core', 'prevpage');
|
||||
$lang['next'] = lang('core', 'nextpage');
|
||||
} else {
|
||||
$lang['prev'] = ' ';
|
||||
$lang['next'] = lang('core', 'nextpage');
|
||||
}
|
||||
$lang['pageunit'] = lang('core', 'pageunit');
|
||||
$lang['total'] = lang('core', 'total');
|
||||
$lang['pagejumptip'] = lang('core', 'pagejumptip');
|
||||
}
|
||||
if(defined('IN_MOBILE') && !defined('TPL_DEFAULT')) {
|
||||
$dot = '..';
|
||||
$page = intval($page) < 10 && intval($page) > 0 ? $page : 4 ;
|
||||
} else {
|
||||
$dot = '...';
|
||||
}
|
||||
$multipage = '';
|
||||
if($jsfunc === FALSE) {
|
||||
$mpurl .= strpos($mpurl, '?') !== FALSE ? '&' : '?';
|
||||
}
|
||||
|
||||
$realpages = 1;
|
||||
$_G['page_next'] = 0;
|
||||
$page -= strlen($curpage) - 1;
|
||||
if($page <= 0) {
|
||||
$page = 1;
|
||||
}
|
||||
if($num > $perpage) {
|
||||
|
||||
$offset = floor($page * 0.5);
|
||||
|
||||
$realpages = @ceil($num / $perpage);
|
||||
$curpage = $curpage > $realpages ? $realpages : $curpage;
|
||||
$pages = $maxpages && $maxpages < $realpages ? $maxpages : $realpages;
|
||||
|
||||
if($page > $pages) {
|
||||
$from = 1;
|
||||
$to = $pages;
|
||||
} else {
|
||||
$from = $curpage - $offset;
|
||||
$to = $from + $page - 1;
|
||||
if($from < 1) {
|
||||
$to = $curpage + 1 - $from;
|
||||
$from = 1;
|
||||
if($to - $from < $page) {
|
||||
$to = $page;
|
||||
}
|
||||
} elseif($to > $pages) {
|
||||
$from = $pages - $page + 1;
|
||||
$to = $pages;
|
||||
}
|
||||
}
|
||||
$_G['page_next'] = $to;
|
||||
$multipage = ($curpage - $offset > 1 && $pages > $page ? '<a href="'.(self::mpurl($mpurl, $pagevar, 1)).$a_name.'" class="first"'.$ajaxtarget.'>1 '.$dot.'</a>' : '').
|
||||
($curpage > 1 && !$simple ? '<a href="'.(self::mpurl($mpurl, $pagevar, $curpage - 1)).$a_name.'" class="prev"'.$ajaxtarget.'>'.$lang['prev'].'</a>' : '');
|
||||
for($i = $from; $i <= $to; $i++) {
|
||||
$multipage .= $i == $curpage ? '<strong>'.$i.'</strong>' :
|
||||
'<a href="'.(self::mpurl($mpurl, $pagevar, $i)).($ajaxtarget && $i == $pages && $autogoto ? '#' : $a_name).'"'.$ajaxtarget.'>'.$i.'</a>';
|
||||
}
|
||||
|
||||
$wml = defined('IN_MOBILE') && IN_MOBILE == 3;
|
||||
$jsurl = '';
|
||||
if(($showpagejump || $showkbd) && !$simple && !$ajaxtarget && !$wml) {
|
||||
$jsurl = $mpurl.(strpos($mpurl, '{page}') !== false ? '\'.replace(\'{page}\', this.value == 1 ? \'\' : this.value)': $pagevar.'\'+this.value;').'; doane(event);';
|
||||
}
|
||||
|
||||
$multipage .= ($to < $pages ? '<a href="'.(self::mpurl($mpurl, $pagevar, $pages)).$a_name.'" class="last"'.$ajaxtarget.'>'.$dot.' '.$pages.'</a>' : '').
|
||||
($showpagejump && !$simple && !$ajaxtarget && !$wml ? '<label><input type="text" name="custompage" class="px" size="2" title="'.$lang['pagejumptip'].'" value="'.$curpage.'" onkeydown="if(event.keyCode==13) {window.location=\''.$jsurl.'}" /><span title="'.$lang['total'].' '.$pages.' '.$lang['pageunit'].'"> / '.$pages.' '.$lang['pageunit'].'</span></label>' : '').
|
||||
($curpage < $pages && !$simple ? '<a href="'.(self::mpurl($mpurl, $pagevar, $curpage + 1)).$a_name.'" class="nxt"'.$ajaxtarget.'>'.$lang['next'].'</a>' : '').
|
||||
($showkbd && !$simple && $pages > $page && !$ajaxtarget && !$wml ? '<kbd><input type="text" name="custompage" size="3" onkeydown="if(event.keyCode==13) {window.location=\''.$jsurl.'}" /></kbd>' : '');
|
||||
|
||||
if(defined('IN_MOBILE') && !defined('TPL_DEFAULT') && $multipage) {
|
||||
$multipage_url = '';
|
||||
parse_str(preg_replace('#^\w+\.php\?#i', '', str_replace('&', '&', $mpurl)), $query);
|
||||
if(!empty($query['mod']) && $query['mod'] == 'viewthread' && !empty($query['tid']) && $query['tid'] == $_G['tid']) {
|
||||
$multipage_url = rewriteoutput('forum_viewthread', 1, $_G['siteurl'], $_G['tid'], '{page}', '', '');
|
||||
} elseif(!empty($query['mod']) && $query['mod'] == 'forumdisplay' && !empty($query['fid']) && $query['fid'] == $_G['fid']) {
|
||||
$multipage_url = rewriteoutput('forum_forumdisplay', 1, $_G['siteurl'], $_G['fid'], '{page}', '', '');
|
||||
} else {
|
||||
$multipage_url = self::mpurl($mpurl, $pagevar, '{page}');
|
||||
$multipage_url = (stripos($multipage_url, $_G['siteurl']) === false && !preg_match('/^https?:\/\//is', $multipage_url) ? $_G['siteurl'] : '').$multipage_url;
|
||||
}
|
||||
if(!empty($multipage_url)) {
|
||||
$multipage .= '<input type="hidden" name="multipage_url" id="multipage_url" value="'.$multipage_url.'" />';
|
||||
}
|
||||
}
|
||||
$multipage = $multipage ? '<div class="pg">'.($shownum && !$simple ? '<em> '.$num.' </em>' : '').$multipage.'</div>' : '';
|
||||
}
|
||||
$maxpage = $realpages;
|
||||
return $multipage;
|
||||
}
|
||||
|
||||
public static function mpurl($mpurl, $pagevar, $page) {
|
||||
if(strpos($mpurl, '{page}') !== false) {
|
||||
return trim(str_replace('{page}', ($page == 1 ? '' : $page), $mpurl), '?');
|
||||
} else {
|
||||
$separator = '';
|
||||
if($pagevar[0] !== '&' && $pagevar[0] !== '?') {
|
||||
if(strpos($mpurl, '?') !== FALSE) {
|
||||
$separator = '';
|
||||
} else {
|
||||
$separator = '?';
|
||||
}
|
||||
}
|
||||
return $mpurl.$separator.$pagevar.$page;
|
||||
}
|
||||
}
|
||||
|
||||
public static function simplepage($num, $perpage, $curpage, $mpurl) {
|
||||
$return = '';
|
||||
$lang['next'] = lang('core', 'nextpage');
|
||||
$lang['prev'] = lang('core', 'prevpage');
|
||||
$next = $num == $perpage ? '<a href="'.(self::mpurl($mpurl, '&page=', $curpage + 1)).'" class="nxt">'.$lang['next'].'</a>' : '';
|
||||
$prev = $curpage > 1 ? '<span class="pgb"><a href="'.(self::mpurl($mpurl, '&page=', $curpage - 1)).'">'.$lang['prev'].'</a></span>' : '';
|
||||
if($next || $prev) {
|
||||
$return = '<div class="pg">'.$prev.$next.'</div>';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
48
source/class/helper/helper_pm.php
Normal file
48
source/class/helper/helper_pm.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_pm.php 31440 2012-08-28 07:22:57Z zhengqingpeng $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_pm {
|
||||
|
||||
|
||||
public static function sendpm($toid, $subject, $message, $fromid = '', $replypmid = 0, $isusername = 0, $type = 0) {
|
||||
global $_G;
|
||||
if($fromid === '') {
|
||||
$fromid = $_G['uid'];
|
||||
}
|
||||
if($fromid) {
|
||||
if($fromid == $_G['uid']) {
|
||||
$sendpmmaxnum = $_G['group']['allowsendpmmaxnum'];
|
||||
} else {
|
||||
$user = getuserbyuid($fromid);
|
||||
loadcache('usergroup_'.$user['groupid']);
|
||||
$sendpmmaxnum = $_G['cache']['usergroup_'.$user['groupid']]['allowsendpmmaxnum'];
|
||||
}
|
||||
$currentnum = C::t('common_member_action_log')->count_day_hours(getuseraction('pmid'), $fromid);
|
||||
if($sendpmmaxnum && $currentnum >= $sendpmmaxnum) {
|
||||
return -16;
|
||||
}
|
||||
}
|
||||
|
||||
loaducenter();
|
||||
$return = uc_pm_send($fromid, $toid, addslashes($subject), addslashes($message), 1, $replypmid, $isusername, $type);
|
||||
if($return > 0 && $fromid) {
|
||||
foreach(explode(',', $fromid) as $v) {
|
||||
useractionlog($v, 'pmid');
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
352
source/class/helper/helper_seccheck.php
Normal file
352
source/class/helper/helper_seccheck.php
Normal file
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: function_seccode.php 33661 2013-07-29 08:18:34Z nemohou $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_seccheck {
|
||||
|
||||
private static function _check($type) {
|
||||
global $_G;
|
||||
$secappend = '';
|
||||
if(!defined('IN_MOBILE')) {
|
||||
if(isset($_GET['idhash']) && $_GET['idhash']) {
|
||||
$secappend = $_GET['idhash'];
|
||||
} elseif($type == 'code') {
|
||||
if(isset($_GET['seccodehash']) && $_GET['seccodehash']) {
|
||||
$secappend = $_GET['seccodehash'];
|
||||
}
|
||||
} elseif($type == 'qaa') {
|
||||
if(isset($_GET['secqaahash']) && $_GET['secqaahash']) {
|
||||
$secappend = $_GET['secqaahash'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!isset($_G['cookie']['sec'.$type.$secappend])) {
|
||||
return false;
|
||||
}
|
||||
list($ssid, $sign) = explode('.', $_G['cookie']['sec'.$type.$secappend]);
|
||||
if($sign != substr(md5($ssid.$_G['uid'].$_G['authkey']), 8, 18)) {
|
||||
return false;
|
||||
}
|
||||
$seccheck = C::t('common_seccheck')->fetch($ssid);
|
||||
if(!$seccheck) {
|
||||
return false;
|
||||
}
|
||||
if(TIMESTAMP - $seccheck['dateline'] > 600 || $seccheck['verified'] > 4) {
|
||||
C::t('common_seccheck')->delete_expiration($ssid);
|
||||
return false;
|
||||
}
|
||||
return $seccheck;
|
||||
}
|
||||
|
||||
private static function _create($type, $code = '') {
|
||||
global $_G;
|
||||
$secappend = '';
|
||||
if(!defined('IN_MOBILE')) {
|
||||
if(isset($_GET['idhash']) && $_GET['idhash']) {
|
||||
$secappend = $_GET['idhash'];
|
||||
} elseif($type == 'code') {
|
||||
if(isset($_GET['seccodehash']) && $_GET['seccodehash']) {
|
||||
$secappend = $_GET['seccodehash'];
|
||||
}
|
||||
} elseif($type == 'qaa') {
|
||||
if(isset($_GET['secqaahash']) && $_GET['secqaahash']) {
|
||||
$secappend = $_GET['secqaahash'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$ssid = C::t('common_seccheck')->insert(array(
|
||||
'dateline' => TIMESTAMP,
|
||||
'code' => $code,
|
||||
'succeed' => 0,
|
||||
'verified' => 0,
|
||||
), true);
|
||||
dsetcookie('sec'.$type.$secappend, $ssid.'.'.substr(md5($ssid.$_G['uid'].$_G['authkey']), 8, 18));
|
||||
}
|
||||
|
||||
public static function make_seccode($seccode = ''){
|
||||
global $_G;
|
||||
if(!$seccode) {
|
||||
$seccode = random(6, 1);
|
||||
$seccodeunits = '';
|
||||
if($_G['setting']['seccodedata']['type'] == 1) {
|
||||
$lang = lang('seccode');
|
||||
$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];
|
||||
}
|
||||
}
|
||||
}
|
||||
self::_create('code', $seccode);
|
||||
return $seccode;
|
||||
}
|
||||
|
||||
public static function make_secqaa() {
|
||||
global $_G;
|
||||
loadcache('secqaa');
|
||||
$secqaakey = max(1, random(1, 1));
|
||||
if($_G['cache']['secqaa'][$secqaakey]['type']) {
|
||||
$etype = explode(':', $_G['cache']['secqaa'][$secqaakey]['question']);
|
||||
if(count($etype) > 1) {
|
||||
if(!preg_match('/^\w+$/', $etype[0]) || !preg_match('/^\w+$/', $etype[1])) {
|
||||
return;
|
||||
}
|
||||
$qaafile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/secqaa/secqaa_'.$etype[1].'.php';
|
||||
$class = $etype[1];
|
||||
} else {
|
||||
if(!preg_match('/^\w+$/', $_G['cache']['secqaa'][$secqaakey]['question'])) {
|
||||
return;
|
||||
}
|
||||
$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']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self::_create('qaa', substr($_G['cache']['secqaa'][$secqaakey]['answer'], 0, 6));
|
||||
return $_G['cache']['secqaa'][$secqaakey]['question'];
|
||||
}
|
||||
|
||||
public static function check_seccode($value, $idhash, $fromjs = 0, $modid = '', $verifyonly = false) {
|
||||
global $_G;
|
||||
if(!$_G['setting']['seccodestatus']) {
|
||||
return true;
|
||||
}
|
||||
$seccheck = self::_check('code');
|
||||
if(!$seccheck) {
|
||||
return false;
|
||||
}
|
||||
$ssid = $seccheck['ssid'];
|
||||
if(!is_numeric($_G['setting']['seccodedata']['type'])) {
|
||||
$etype = explode(':', $_G['setting']['seccodedata']['type']);
|
||||
if(count($etype) > 1) {
|
||||
if(!preg_match('/^\w+$/', $etype[0]) || !preg_match('/^\w+$/', $etype[1])) {
|
||||
return false;
|
||||
}
|
||||
$codefile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/seccode/seccode_'.$etype[1].'.php';
|
||||
$class = $etype[1];
|
||||
} else {
|
||||
if(!preg_match('/^\w+$/', $_G['setting']['seccodedata']['type'])) {
|
||||
return false;
|
||||
}
|
||||
$codefile = libfile('seccode/'.$_G['setting']['seccodedata']['type'], 'class');
|
||||
$class = $_G['setting']['seccodedata']['type'];
|
||||
}
|
||||
if(file_exists($codefile)) {
|
||||
@include_once $codefile;
|
||||
$class = 'seccode_'.$class;
|
||||
if(class_exists($class)) {
|
||||
$code = new $class();
|
||||
if(method_exists($code, 'check')) {
|
||||
$return = $code->check($value, $idhash, $seccheck, $fromjs, $modid, $verifyonly);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$return = false;
|
||||
}
|
||||
} else {
|
||||
$return = $seccheck['code'] == strtoupper($value);
|
||||
}
|
||||
if($return) {
|
||||
C::t('common_seccheck')->update_succeed($ssid);
|
||||
} else {
|
||||
C::t('common_seccheck')->update_verified($ssid);
|
||||
}
|
||||
if(!$verifyonly) {
|
||||
C::t('common_seccheck')->delete($ssid);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function check_secqaa($value, $idhash, $verifyonly = false) {
|
||||
global $_G;
|
||||
if(!$_G['setting']['secqaa']) {
|
||||
return true;
|
||||
}
|
||||
$seccheck = self::_check('qaa');
|
||||
if(!$seccheck) {
|
||||
return false;
|
||||
}
|
||||
$ssid = $seccheck['ssid'];
|
||||
$return = $seccheck['code'] == substr(md5($value), 0, 6);
|
||||
if($return) {
|
||||
C::t('common_seccheck')->update_succeed($ssid);
|
||||
} else {
|
||||
C::t('common_seccheck')->update_verified($ssid);
|
||||
}
|
||||
if(!$verifyonly) {
|
||||
C::t('common_seccheck')->delete($ssid);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function rule_register() {
|
||||
global $_G;
|
||||
$seccheckrule = & $_G['setting']['seccodedata']['rule']['register'];
|
||||
if($seccheckrule['allow'] == 1) {
|
||||
$seccode = true;
|
||||
} elseif($seccheckrule['allow'] == 2) {
|
||||
if($seccheckrule['numlimit'] > 0) {
|
||||
loadcache('seccodedata', true);
|
||||
if($_G['cache']['seccodedata']['register']['show']) {
|
||||
$seccode = true;
|
||||
} else {
|
||||
$regnumber = C::t('common_member')->count_by_regdate(TIMESTAMP - $seccheckrule['timelimit']);
|
||||
if($regnumber >= $seccheckrule['numlimit']) {
|
||||
$seccode = true;
|
||||
$_G['cache']['seccodedata']['register']['show'] = 1;
|
||||
savecache('seccodedata', $_G['cache']['seccodedata']);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$seccode = false;
|
||||
}
|
||||
return array(
|
||||
$seccode,
|
||||
$_G['setting']['secqaa']['status'] & 1
|
||||
);
|
||||
}
|
||||
|
||||
public static function rule_login() {
|
||||
global $_G;
|
||||
$seccheckrule = & $_G['setting']['seccodedata']['rule']['login'];
|
||||
if($seccheckrule['allow'] == 1) {
|
||||
$seccode = true;
|
||||
} elseif($seccheckrule['allow'] == 2) {
|
||||
$seccode = false;
|
||||
} else {
|
||||
$seccode = false;
|
||||
}
|
||||
return array($seccode, $_G['setting']['secqaa']['status'] & 8);
|
||||
}
|
||||
|
||||
public static function rule_post($action) {
|
||||
global $_G;
|
||||
$seccheckrule = & $_G['setting']['seccodedata']['rule']['post'];
|
||||
if($seccheckrule['allow'] == 1) {
|
||||
$seccode = !$_G['setting']['seccodedata']['minposts'] || getuserprofile('posts') < $_G['setting']['seccodedata']['minposts'];
|
||||
} elseif($seccheckrule['allow'] == 2) {
|
||||
if(C::t('common_member_secwhite')->check($_G['uid'])) {
|
||||
$seccode = false;
|
||||
} else {
|
||||
$seccode = getuserprofile('posts') < $_G['setting']['seccodedata']['minposts'];
|
||||
if(!$seccode && $seccheckrule['numlimit']) {
|
||||
$count = C::t('forum_post')->count_by_search('pid:0', null, null, null, null, $_G['uid'], null, TIMESTAMP - $seccheckrule['timelimit']);
|
||||
$seccode = $seccheckrule['numlimit'] <= $count;
|
||||
}
|
||||
if($action == 'newthread' && !$seccode && !empty($_POST) && $seccheckrule['nplimit']) {
|
||||
if(!$_G['cookie']['st_t']) {
|
||||
$seccode = true;
|
||||
} else {
|
||||
list($uid, $t, $hash) = explode('|', $_G['cookie']['st_t']);
|
||||
list($t, $m) = explode(',', $t);
|
||||
if(md5($uid.'|'.$t.$_G['config']['security']['authkey']) == $hash && !$m) {
|
||||
if(TIMESTAMP - $t <= $seccheckrule['nplimit']) {
|
||||
$seccode = true;
|
||||
} else {
|
||||
$seccode = false;
|
||||
}
|
||||
} else {
|
||||
$seccode = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($action == 'reply' && !$seccode && !empty($_POST) && $seccheckrule['vplimit']) {
|
||||
if(!$_G['cookie']['st_p']) {
|
||||
$seccode = true;
|
||||
} else {
|
||||
list($uid, $t, $hash) = explode('|', $_G['cookie']['st_p']);
|
||||
list($t, $m) = explode(',', $t);
|
||||
if(md5($uid.'|'.$t.$_G['config']['security']['authkey']) == $hash && !$m) {
|
||||
if(TIMESTAMP - $t <= $seccheckrule['vplimit']) {
|
||||
$seccode = true;
|
||||
} else {
|
||||
$seccode = false;
|
||||
}
|
||||
} else {
|
||||
$seccode = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$seccode = false;
|
||||
}
|
||||
return array(
|
||||
$seccode,
|
||||
$_G['setting']['secqaa']['status'] & 2 && (!$_G['setting']['secqaa']['minposts'] || getuserprofile('posts') < $_G['setting']['secqaa']['minposts'])
|
||||
);
|
||||
}
|
||||
|
||||
public static function rule_publish($rule) {
|
||||
global $_G;
|
||||
$seccheckrule = & $_G['setting']['seccodedata']['rule']['post'];
|
||||
return array(
|
||||
$seccheckrule['allow'] && (!$_G['setting']['seccodedata']['minposts'] || getuserprofile('posts') < $_G['setting']['seccodedata']['minposts']),
|
||||
$_G['setting']['secqaa']['status'] & 2 && (!$_G['setting']['secqaa']['minposts'] || getuserprofile('posts') < $_G['setting']['secqaa']['minposts'])
|
||||
);
|
||||
}
|
||||
|
||||
public static function rule_password($rule) {
|
||||
global $_G;
|
||||
$seccheckrule = & $_G['setting']['seccodedata']['rule']['password'];
|
||||
return array(
|
||||
$seccheckrule['allow'] && (!$_G['setting']['seccodedata']['minposts'] || getuserprofile('posts') < $_G['setting']['seccodedata']['minposts']),
|
||||
$_G['setting']['secqaa']['status'] & 4 && (!$_G['setting']['secqaa']['minposts'] || getuserprofile('posts') < $_G['setting']['secqaa']['minposts'])
|
||||
);
|
||||
}
|
||||
|
||||
public static function rule_card() {
|
||||
global $_G;
|
||||
$seccheckrule = & $_G['setting']['seccodedata']['rule']['card'];
|
||||
return array($seccheckrule['allow'], $_G['setting']['secqaa']['status'] & 16);
|
||||
}
|
||||
|
||||
public static function seccheck($rule, $param = array()) {
|
||||
global $_G;
|
||||
if($_G['uid'] && !checkperm('seccode')) {
|
||||
return array();
|
||||
}
|
||||
if(method_exists('helper_seccheck', 'rule_'.$rule)) {
|
||||
$return = call_user_func(array('helper_seccheck', 'rule_'.$rule), $param);
|
||||
return $return;
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
122
source/class/helper/helper_seo.php
Normal file
122
source/class/helper/helper_seo.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_seo.php 36278 2016-12-09 07:52:35Z nemohou $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_seo {
|
||||
|
||||
|
||||
public static function get_seosetting($page, $data = array(), $defset = array()) {
|
||||
global $_G;
|
||||
$searchs = array('{bbname}');
|
||||
$replaces = array($_G['setting']['bbname']);
|
||||
|
||||
$seotitle = $seodescription = $seokeywords = '';
|
||||
$titletext = !empty($defset['seotitle']) ? $defset['seotitle'] : (!empty($_G['setting']['seotitle'][$page]) ? $_G['setting']['seotitle'][$page] : '');
|
||||
$descriptiontext = !empty($defset['seodescription']) ? $defset['seodescription'] : (!empty($_G['setting']['seodescription'][$page]) ? $_G['setting']['seodescription'][$page] : '');
|
||||
$keywordstext = !empty($defset['seokeywords']) ? $defset['seokeywords'] : getglobal('setting/seokeywords/'.$page);
|
||||
preg_match_all("/\{([a-z0-9_-]+?)\}/", $titletext.$descriptiontext.$keywordstext, $pageparams);
|
||||
if($pageparams) {
|
||||
foreach($pageparams[1] as $var) {
|
||||
$searchs[] = '{'.$var.'}';
|
||||
if($var == 'page') {
|
||||
$data['page'] = $data['page'] > 1 ? lang('core', 'page', array('page' => $data['page'])) : '';
|
||||
}
|
||||
$replaces[] = $data[$var] ? strip_tags($data[$var]) : '';
|
||||
}
|
||||
if($titletext) {
|
||||
$seotitle = helper_seo::strreplace_strip_split($searchs, $replaces, $titletext);
|
||||
}
|
||||
if($descriptiontext) {
|
||||
$seodescription = helper_seo::strreplace_strip_split($searchs, $replaces, $descriptiontext);
|
||||
}
|
||||
if($keywordstext) {
|
||||
$seokeywords = helper_seo::strreplace_strip_split($searchs, $replaces, $keywordstext);
|
||||
}
|
||||
}
|
||||
return array($seotitle, $seodescription, $seokeywords);
|
||||
}
|
||||
|
||||
|
||||
public static function strreplace_strip_split($searchs, $replaces, $str) {
|
||||
$searchspace = array('(((\s)*\-(\s)*)+)', '(((\s)*\,(\s)*)+)', '(((\s)*\|(\s)*)+)', '(((\s)*\t(\s)*)+)', '(((\s)*_(\s)*)+)');
|
||||
$replacespace = array('$3-$3', '$3,$3', '$3|$3', '$3 $3', '$3_$3');
|
||||
return trim(preg_replace($searchspace, $replacespace, str_replace($searchs, $replaces, $str)), ' ,-|_');
|
||||
}
|
||||
|
||||
public static function get_title_page($navtitle, $page){
|
||||
if($page > 1) {
|
||||
$navtitle .= ' - '.lang('core', 'page', array('page' => $page));
|
||||
}
|
||||
return $navtitle;
|
||||
}
|
||||
|
||||
public static function get_related_link($extent) {
|
||||
global $_G;
|
||||
loadcache('relatedlink');
|
||||
$allextent = array('article' => 0, 'forum' => 1, 'group' => 2, 'blog' => 3);
|
||||
$links = array();
|
||||
if($_G['cache']['relatedlink'] && isset($allextent[$extent])) {
|
||||
foreach($_G['cache']['relatedlink'] as $link) {
|
||||
$link['extent'] = sprintf('%04b', $link['extent']);
|
||||
if($link['extent'][$allextent[$extent]] && $link['name'] && $link['url']) {
|
||||
$links[] = daddslashes($link);
|
||||
}
|
||||
}
|
||||
}
|
||||
rsort($links);
|
||||
return $links;
|
||||
}
|
||||
|
||||
public static function parse_related_link($content, $extent) {
|
||||
global $_G;
|
||||
loadcache('relatedlink');
|
||||
$allextent = array('article' => 0, 'forum' => 1, 'group' => 2, 'blog' => 3);
|
||||
if($_G['cache']['relatedlink'] && isset($allextent[$extent])) {
|
||||
$searcharray = $replacearray = $sortarray = $_G['trunsform_tmp'] = array();
|
||||
foreach($_G['cache']['relatedlink'] as $link) {
|
||||
$link['extent'] = sprintf('%04b', $link['extent']);
|
||||
if($link['extent'][$allextent[$extent]] && $link['name'] && $link['url']) {
|
||||
$sortarray[$link['name']] = strlen($link['name']);
|
||||
$searcharray[$link['name']] = '/('.preg_quote($link['name']).')/i';
|
||||
$replacearray[$link['name']] = self::base64_transform('encode', '<relatedlink>', "<a href=\"{$link['url']}\" target=\"_blank\" class=\"relatedlink\">{$link['name']}</a>", '</relatedlink>');
|
||||
}
|
||||
}
|
||||
if($searcharray && $replacearray) {
|
||||
array_multisort($sortarray,SORT_DESC,$searcharray,SORT_DESC,$replacearray);
|
||||
$content = preg_replace_callback("/(<script\s+.*?>.*?<\/script>)|(<a\s+.*?>.*?<\/a>)|(<img\s+.*?[\/]?>)|(\[attach\](\d+)\[\/attach\])/is", array(__CLASS__, 'parse_related_link_callback_base64_transform_1234'), $content);
|
||||
$content = preg_replace($searcharray, $replacearray, $content, 1);
|
||||
$content = preg_replace_callback("/<relatedlink>(.*?)<\/relatedlink>/is", array(__CLASS__, 'parse_related_link_callback_base64_transform_1'), $content);
|
||||
}
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
static public function parse_related_link_callback_base64_transform_1234($matches) {
|
||||
return self::base64_transform('encode', '<relatedlink>', $matches[1].$matches[2].$matches[3].$matches[4], '</relatedlink>');
|
||||
}
|
||||
|
||||
static function parse_related_link_callback_base64_transform_1($matches) {
|
||||
return self::base64_transform('decode', '', $matches[1], '');
|
||||
}
|
||||
|
||||
public static function base64_transform($type, $prefix, $string, $suffix) {
|
||||
global $_G;
|
||||
if($type == 'encode') {
|
||||
$_G['trunsform_tmp'][] = base64_encode(str_replace("\\\"", "\"", $string));
|
||||
return $prefix.(count($_G['trunsform_tmp']) - 1).$suffix;
|
||||
} elseif($type == 'decode') {
|
||||
return $prefix.base64_decode($_G['trunsform_tmp'][$string]).$suffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
66
source/class/helper/helper_sysmessage.php
Normal file
66
source/class/helper/helper_sysmessage.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_sysmessage.php 32459 2013-01-22 02:01:02Z monkey $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_sysmessage {
|
||||
|
||||
public static function show($message, $title = '', $msgvar = array()) {
|
||||
if(function_exists('lang')) {
|
||||
$message = lang('message', $message, $msgvar);
|
||||
$title = $title ? lang('message', $title) : lang('error', 'System Message');
|
||||
} else {
|
||||
$title = $title ? $title : 'System Message';
|
||||
}
|
||||
$charset = CHARSET;
|
||||
$version = DISCUZ_VERSION;
|
||||
$copy = lang('template', 'copyright_s');
|
||||
echo <<<EOT
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="$charset" />
|
||||
<meta name="renderer" content="webkit" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<title>$title</title>
|
||||
<meta name="keywords" content="" />
|
||||
<meta name="description" content="System Message - Discuz! Board" />
|
||||
<meta name="generator" content="Discuz! $version" />
|
||||
<meta name="author" content="Discuz! Team and Comsenz UI Team" />
|
||||
<meta name="copyright" content="$copy" />
|
||||
<meta name="MSSmartTagsPreventParsing" content="True" />
|
||||
<meta http-equiv="MSThemeCompatible" content="Yes" />
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="850" align="center" height="85%">
|
||||
<tr align="center" valign="middle">
|
||||
<td>
|
||||
<table cellpadding="20" cellspacing="0" border="0" width="80%" align="center" style="font-family: Verdana, Tahoma; color: #666666; font-size: 12px">
|
||||
<tr>
|
||||
<td valign="middle" align="center" bgcolor="#EBEBEB">
|
||||
<b style="font-size: 16px">$title</b>
|
||||
<br /><br /><p style="text-align:left;">$message</p>
|
||||
<br /><br />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
EOT;
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
124
source/class/helper/helper_util.php
Normal file
124
source/class/helper/helper_util.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: helper_util.php 29887 2012-05-02 07:36:50Z liulanbo $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class helper_util {
|
||||
|
||||
public static function compute($v1, $v2, $glue = '+') {
|
||||
switch ($glue) {
|
||||
case '+':
|
||||
return $v1 + $v2;
|
||||
break;
|
||||
case '-':
|
||||
return $v1 - $v2;
|
||||
break;
|
||||
case '.':
|
||||
return $v1 . $v2;
|
||||
break;
|
||||
case '=':
|
||||
case '==':
|
||||
return $v1 == $v2;
|
||||
break;
|
||||
case 'merge':
|
||||
return array_merge((array)$v1, (array)$v2);
|
||||
break;
|
||||
case '===':
|
||||
return $v1 === $v2;
|
||||
break;
|
||||
case '!==':
|
||||
return $v1 === $v2;
|
||||
break;
|
||||
case '&&':
|
||||
return $v1 && $v2;
|
||||
break;
|
||||
case '||':
|
||||
return $v1 && $v2;
|
||||
break;
|
||||
case 'and':
|
||||
return $v1 and $v2;
|
||||
break;
|
||||
case 'xor':
|
||||
return $v1 xor $v2;
|
||||
break;
|
||||
case '|':
|
||||
return $v1 | $v2;
|
||||
break;
|
||||
case '&':
|
||||
return $v1 & $v2;
|
||||
break;
|
||||
case '^':
|
||||
return $v1 ^ $v2;
|
||||
break;
|
||||
case '>':
|
||||
return $v1 > $v2;
|
||||
break;
|
||||
case '<':
|
||||
return $v1 < $v2;
|
||||
break;
|
||||
case '<>':
|
||||
return $v1 <> $v2;
|
||||
break;
|
||||
case '!=':
|
||||
return $v1 != $v2;
|
||||
break;
|
||||
case '<=':
|
||||
return $v1 <= $v2;
|
||||
break;
|
||||
case '>=':
|
||||
return $v1 >= $v2;
|
||||
break;
|
||||
case '*':
|
||||
return $v1 * $v2;
|
||||
break;
|
||||
case '/':
|
||||
return $v1 / $v2;
|
||||
break;
|
||||
case '%':
|
||||
return $v1 % $v2;
|
||||
break;
|
||||
case 'or':
|
||||
return $v1 or $v2;
|
||||
break;
|
||||
case '<<':
|
||||
return $v1 << $v2;
|
||||
break;
|
||||
case '>>':
|
||||
return $v1 >> $v2;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function single_compute($v, $glue = '+') {
|
||||
switch ($glue) {
|
||||
case '!':
|
||||
return ! $v;
|
||||
break;
|
||||
case '-':
|
||||
return - $v;
|
||||
break;
|
||||
case '~':
|
||||
return ~ $v;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static function check_glue($glue = '=') {
|
||||
return in_array($glue, array('=', '<', '<=', '>', '>=', '!=', '+', '-', '|', '&', '<>')) ? $glue : '=';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
0
source/class/helper/index.htm
Normal file
0
source/class/helper/index.htm
Normal file
Reference in New Issue
Block a user