First commit

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

235
uc_client/lib/dbi.class.php Normal file
View File

@@ -0,0 +1,235 @@
<?php
/*
[UCenter] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: db.class.php 922 2009-02-19 01:30:22Z zhaoxiongfei $
*/
class ucclient_db {
var $querynum = 0;
var $link;
var $histories;
var $stmtcache = array();
var $dbhost;
var $dbuser;
var $dbpw;
var $dbcharset;
var $pconnect;
var $tablepre;
var $time;
var $goneaway = 5;
function connect($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = '', $pconnect = 0, $tablepre='', $time = 0) {
if (intval($pconnect) === 1) $dbhost = 'p:' . $dbhost;
$this->dbhost = $dbhost;
$this->dbuser = $dbuser;
$this->dbpw = $dbpw;
$this->dbname = $dbname;
$this->dbcharset = $dbcharset;
$this->pconnect = $pconnect;
$this->tablepre = $tablepre;
$this->time = $time;
mysqli_report(MYSQLI_REPORT_OFF);
if(!$this->link = new mysqli($dbhost, $dbuser, $dbpw, $dbname)) {
$this->halt('Can not connect to MySQL server');
}
$this->link->options(MYSQLI_OPT_LOCAL_INFILE, false);
if($dbcharset) {
$this->link->set_charset($dbcharset);
}
$this->link->query("SET sql_mode=''");
$this->link->query("SET character_set_client=binary");
}
function fetch_array($query, $result_type = MYSQLI_ASSOC) {
return $query ? $query->fetch_array($result_type) : null;
}
function result_first($sql) {
$query = $this->query($sql);
return $this->result($query, 0);
}
function fetch_first($sql) {
$query = $this->query($sql);
return $this->fetch_array($query);
}
function fetch_all($sql, $id = '') {
$arr = array();
$query = $this->query($sql);
while($data = $this->fetch_array($query)) {
$id ? $arr[$data[$id]] = $data : $arr[] = $data;
}
return $arr;
}
function result_first_stmt($sql, $key = array(), $value = array()) {
$query = $this->query_stmt($sql, $key, $value);
return $this->result($query, 0);
}
function fetch_first_stmt($sql, $key = array(), $value = array()) {
$query = $this->query_stmt($sql, $key, $value);
return $this->fetch_array($query);
}
function fetch_all_stmt($sql, $key = array(), $value = array(), $id = '') {
$arr = array();
$query = $this->query_stmt($sql, $key, $value);
while($data = $this->fetch_array($query)) {
$id ? $arr[$data[$id]] = $data : $arr[] = $data;
}
return $arr;
}
function cache_gc() {
$this->query("DELETE FROM {$this->tablepre}sqlcaches WHERE expiry<$this->time");
}
function query($sql, $type = '', $cachetime = FALSE) {
$resultmode = $type == 'UNBUFFERED' ? MYSQLI_USE_RESULT : MYSQLI_STORE_RESULT;
if(!($query = $this->link->query($sql, $resultmode)) && $type != 'SILENT') {
$this->halt('MySQL Query Error', $sql);
}
$this->querynum++;
$this->histories[] = $sql;
return $query;
}
function query_stmt($sql, $key = array(), $value = array(), $type = '', $saveprep = FALSE, $cachetime = FALSE) {
$parse = $this->parse_query($sql, $key, $value);
if($saveprep && array_key_exists(hash("sha256", $parse[0]), $this->stmtcache)) {
$stmt = & $this->stmtcache[hash("sha256", $parse[0])];
} else {
$stmt = $this->link->prepare($parse[0]);
$saveprep && $this->stmtcache[hash("sha256", $parse[0])] = & $stmt;
}
if(!empty($key)) {
$stmt->bind_param(...$parse[1]);
}
if(!($query = $stmt->execute()) && $type != 'SILENT') {
$this->halt('MySQL Query Error', $parse[0]);
}
$this->querynum++;
$this->histories[] = $parse[0];
return strncasecmp("SELECT", $sql, 6) ? $query : $stmt->get_result();
}
function affected_rows() {
return $this->link->affected_rows;
}
function error() {
return $this->link->error;
}
function errno() {
return $this->link->errno;
}
function result($query, $row) {
if(!$query || $query->num_rows == 0) {
return null;
}
$query->data_seek($row);
$assocs = $query->fetch_row();
return $assocs[0];
}
function num_rows($query) {
$query = $query ? $query->num_rows : 0;
return $query;
}
function num_fields($query) {
return $query ? $query->field_count : 0;
}
function free_result($query) {
return $query ? $query->free() : false;
}
function insert_id() {
return ($id = $this->link->insert_id) >= 0 ? $id : $this->result($this->query("SELECT last_insert_id()"), 0);
}
function fetch_row($query) {
$query = $query ? $query->fetch_row() : null;
return $query;
}
function fetch_fields($query) {
return $query ? $query->fetch_field() : null;
}
function version() {
return $this->link->server_info;
}
function escape_string($str) {
return $this->link->escape_string($str);
}
function close() {
return $this->link->close();
}
function parse_query($sql, $key = array(), $value = array()) {
$list = '';
$array = array();
if(strpos($sql, '?')) {
foreach ($key as $k => $v) {
if(in_array($v, array('i', 'd', 's', 'b'))) {
$list .= $v;
$array = array_merge($array, (array)$value[$k]);
}
}
} else {
preg_match_all("/:([A-Za-z0-9]*?)( |$)/", $sql, $matches);
foreach ($matches[1] as $match) {
if(in_array($key[$match], array('i', 'd', 's', 'b'))) {
$list .= $key[$match];
$array = array_merge($array, (array)$value[$match]);
$sql = str_replace(":".$match, "?", $sql);
}
}
}
return array($sql, array_merge((array)$list, $array));
}
function halt($message = '', $sql = '') {
$error = $this->error();
$errorno = $this->errno();
if($errorno == 2006 && $this->goneaway-- > 0) {
$this->connect($this->dbhost, $this->dbuser, $this->dbpw, $this->dbname, $this->dbcharset, $this->pconnect, $this->tablepre, $this->time);
$this->query($sql);
} else {
$s = '';
if($message) {
$s = "<b>UCenter info:</b> $message<br />";
}
if($sql) {
$s .= '<b>SQL:</b>'.htmlspecialchars($sql).'<br />';
}
$s .= '<b>Error:</b>'.$error.'<br />';
$s .= '<b>Errno:</b>'.$errorno.'<br />';
$s = str_replace(UC_DBTABLEPRE, '[Table]', $s);
exit($s);
}
}
}
?>

1
uc_client/lib/index.htm Normal file
View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,146 @@
<?php
/*
[UCenter] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: sendmail.inc.php 1124 2011-12-06 11:03:23Z svn_project_zhangjie $
*/
!defined('IN_UC') && exit('Access Denied');
if($mail_setting['mailsilent']) {
error_reporting(0);
}
$maildelimiter = $mail_setting['maildelimiter'] == 1 ? "\r\n" : ($mail_setting['maildelimiter'] == 2 ? "\r" : "\n");
$mailusername = isset($mail_setting['mailusername']) ? $mail_setting['mailusername'] : 1;
$appname = $this->base->cache['apps'][$mail['appid']]['name'];
$mail['subject'] = '=?'.$mail['charset'].'?B?'.base64_encode(str_replace("\r", '', str_replace("\n", '', '['.$appname.'] '.$mail['subject']))).'?=';
$mail['message'] = chunk_split(base64_encode(str_replace("\r\n.", " \r\n..", str_replace("\n", "\r\n", str_replace("\r", "\n", str_replace("\r\n", "\n", str_replace("\n\r", "\r", $mail['message'])))))));
$email_from = $mail['frommail'] == '' ? '=?'.$mail['charset'].'?B?'.base64_encode($appname)."?= <{$mail_setting['maildefault']}>" : (preg_match('/^(.+?) \<(.+?)\>$/',$email_from, $from) ? '=?'.$mail['charset'].'?B?'.base64_encode($from[1])."?= <$from[2]>" : $mail['frommail']);
foreach(explode(',', $mail['email_to']) as $touser) {
$tousers[] = preg_match('/^(.+?) \<(.+?)\>$/',$touser, $to) ? ($mailusername ? '=?'.$mail['charset'].'?B?'.base64_encode($to[1])."?= <$to[2]>" : $to[2]) : $touser;
}
$tousers = is_array($tousers) ? $tousers : array($tousers);
$mail['email_to'] = implode(',', $tousers);
$headers = "From: $email_from{$maildelimiter}X-Priority: 3{$maildelimiter}X-Mailer: Discuz! $version{$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: text/".($mail['htmlon'] ? 'html' : 'plain')."; charset={$mail['charset']}{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}";
$mail_setting['mailport'] = $mail_setting['mailport'] ? $mail_setting['mailport'] : 25;
$mail_setting['mailtimeout'] = isset($mail_setting['mailtimeout']) && strlen($mail_setting['mailtimeout']) ? intval($mail_setting['mailtimeout']) : 30;
if($mail_setting['mailsend'] == 1 && function_exists('mail')) {
return @mail($mail['email_to'], $mail['subject'], $mail['message'], $headers);
} elseif($mail_setting['mailsend'] == 2) {
if(!$fp = fsocketopen($mail_setting['mailserver'], $mail_setting['mailport'], $errno, $errstr, $mail_setting['mailtimeout'])) {
return false;
}
stream_set_blocking($fp, true);
stream_set_timeout($fp, $mail_setting['mailtimeout']);
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != '220') {
return false;
}
fputs($fp, ($mail_setting['mailauth'] ? 'EHLO' : 'HELO')." discuz\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) {
return false;
}
while(1) {
if(substr($lastmessage, 3, 1) != '-' || empty($lastmessage)) {
break;
}
$lastmessage = fgets($fp, 512);
}
if($mail_setting['mailauth']) {
fputs($fp, "AUTH LOGIN\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 334) {
return false;
}
fputs($fp, base64_encode($mail_setting['mailauth_username'])."\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 334) {
return false;
}
fputs($fp, base64_encode($mail_setting['mailauth_password'])."\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 235) {
return false;
}
$email_from = $mail_setting['mailfrom'];
}
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) {
return false;
}
}
$email_tos = array();
foreach(explode(',', $mail['email_to']) as $touser) {
$touser = trim($touser);
if($touser) {
fputs($fp, "RCPT TO: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $touser).">\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 250) {
fputs($fp, "RCPT TO: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $touser).">\r\n");
$lastmessage = fgets($fp, 512);
return false;
}
}
}
fputs($fp, "DATA\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 354) {
return false;
}
$headers .= 'Message-ID: <'.gmdate('YmdHs').'.'.substr(md5($mail['message'].microtime()), 0, 6).rand(100000, 999999).'@'.$_SERVER['HTTP_HOST'].">{$maildelimiter}";
fputs($fp, "Date: ".gmdate('r')."\r\n");
fputs($fp, "To: ".$mail['email_to']."\r\n");
fputs($fp, "Subject: ".$mail['subject']."\r\n");
fputs($fp, $headers."\r\n");
fputs($fp, "\r\n\r\n");
fputs($fp, "{$mail['message']}\r\n.\r\n");
$lastmessage = fgets($fp, 512);
if(substr($lastmessage, 0, 3) != 250) {
return false;
}
fputs($fp, "QUIT\r\n");
return true;
} elseif($mail_setting['mailsend'] == 3) {
ini_set('SMTP', $mail_setting['mailserver']);
ini_set('smtp_port', $mail_setting['mailport']);
ini_set('sendmail_from', $email_from);
return @mail($mail['email_to'], $mail['subject'], $mail['message'], $headers);
}
?>

View File

@@ -0,0 +1,148 @@
<?php
/*
[UCenter] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: uccode.class.php 1166 2014-11-03 01:49:32Z hypowang $
*/
class uccode {
var $uccodes;
function __construct() {
$this->uccode();
}
function uccode() {
$this->uccode = array(
'pcodecount' => -1,
'codecount' => 0,
'codehtml' => array()
);
}
function codedisp($code) {
$this->uccode['pcodecount']++;
$code = str_replace('\\"', '"', preg_replace("/^[\n\r]*(.+?)[\n\r]*$/is", "\\1", $code));
$this->uccode['codehtml'][$this->uccode['pcodecount']] = $this->tpl_codedisp($code);
$this->uccode['codecount']++;
return "[\tUCENTER_CODE_".$this->uccode['pcodecount']."\t]";
}
function complie($message) {
$message = dhtmlspecialchars($message);
if(strpos($message, '[/code]') !== FALSE) {
$message = preg_replace_callback("/\s*\[code\](.+?)\[\/code\]\s*/is", array($this, 'complie_callback_codedisp_1'), $message);
}
if(strpos($message, '[/url]') !== FALSE) {
$message = preg_replace_callback("/\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\/\/|www\.)([^\[\"']+?))?\](.+?)\[\/url\]/is", array($this, 'complie_callback_parseurl_15'), $message);
}
if(strpos($message, '[/email]') !== FALSE) {
$message = preg_replace_callback("/\[email(=([A-Za-z0-9\-_.+]+)@([A-Za-z0-9\-_]+[.][A-Za-z0-9\-_.]+))?\](.+?)\[\/email\]/is", array($this, 'complie_callback_parseemail_14'), $message);
}
$message = str_replace(array(
'[/color]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]',
'[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]',
'[list=A]', '[*]', '[/list]', '[indent]', '[/indent]', '[/float]'
), array(
'</font>', '</font>', '</font>', '</p>', '<strong>', '</strong>', '<i>',
'</i>', '<u>', '</u>', '<ul>', '<ul type="1">', '<ul type="a">',
'<ul type="A">', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>'
), preg_replace(array(
"/\[color=([#\w]+?)\]/i",
"/\[size=(\d+?)\]/i",
"/\[size=(\d+(\.\d+)?(px|pt|in|cm|mm|pc|em|ex|%)+?)\]/i",
"/\[font=([^\[\<]+?)\]/i",
"/\[align=(left|center|right)\]/i",
"/\[float=(left|right)\]/i"
), array(
"<font color=\"\\1\">",
"<font size=\"\\1\">",
"<font style=\"font-size: \\1\">",
"<font face=\"\\1 \">",
"<p align=\"\\1\">",
"<span style=\"float: \\1;\">"
), $message));
if(strpos($message, '[/quote]') !== FALSE) {
$message = preg_replace("/\s*\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is", $this->tpl_quote(), $message);
}
if(strpos($message, '[/img]') !== FALSE) {
$message = preg_replace_callback("/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is", array($this, 'complie_callback_bbcodeurl_1'), $message);
$message = preg_replace_callback("/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is", array($this, 'complie_callback_bbcodeurl_312'), $message);
}
for($i = 0; $i <= $this->uccode['pcodecount']; $i++) {
$message = str_replace("[\tUCENTER_CODE_$i\t]", $this->uccode['codehtml'][$i], $message);
}
return nl2br(str_replace(array("\t", ' ', ' '), array('&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), $message));
}
function complie_callback_codedisp_1($matches) {
return $this->codedisp($matches[1]);
}
function complie_callback_parseurl_15($matches) {
return $this->parseurl($matches[1], $matches[5]);
}
function complie_callback_parseemail_14($matches) {
return $this->parseemail($matches[1], $matches[4]);
}
function complie_callback_bbcodeurl_1($matches) {
return $this->bbcodeurl($matches[1], '<img src="%s" border="0" alt="" />');
}
function complie_callback_bbcodeurl_312($matches) {
return $this->bbcodeurl($matches[3], '<img width="'.$matches[1].'" height="'.$matches[2].'" src="%s" border="0" alt="" />');
}
function parseurl($url, $text) {
if(!$url && preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\/\/|www\.)[^\[\"']+/i", trim($text), $matches)) {
$url = $matches[0];
$length = 65;
if(strlen($url) > $length) {
$text = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3));
}
return '<a href="'.(substr(strtolower($url), 0, 4) == 'www.' ? 'http://'.$url : $url).'" target="_blank">'.$text.'</a>';
} else {
$url = substr($url, 1);
if(substr(strtolower($url), 0, 4) == 'www.') {
$url = 'http://'.$url;
}
return '<a href="'.$url.'" target="_blank">'.$text.'</a>';
}
}
function parseemail($email, $text) {
$text = str_replace('\"', '"', $text);
if(!$email && preg_match("/\s*([A-Za-z0-9\-_.+]+)@([A-Za-z0-9\-_]+[.][A-Za-z0-9\-_.]+)\s*/i", $text, $matches)) {
$email = trim($matches[0]);
return '<a href="mailto:'.$email.'">'.$email.'</a>';
} else {
return '<a href="mailto:'.substr($email, 1).'">'.$text.'</a>';
}
}
function bbcodeurl($url, $tags) {
if(!preg_match("/<.+?>/s", $url)) {
if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://'))) {
$url = 'http://'.$url;
}
return str_replace(array('submit', 'logging.php'), array('', ''), sprintf($tags, $url, addslashes($url)));
} else {
return '&nbsp;'.$url;
}
}
function tpl_codedisp($code) {
return '<div class="blockcode"><code id="code'.$this->uccodes['codecount'].'">'.$code.'</code></div>';
}
function tpl_quote() {
return '<div class="quote"><blockquote>\\1</blockquote></div>';
}
}
?>

View File

@@ -0,0 +1,88 @@
<?php
/*
[UCenter] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: ucip.class.php 803 2019-12-19 12:00:00Z community $
*/
class ucip {
function __construct() {
}
public static function validate_ip($ip) {
return filter_var($ip, FILTER_VALIDATE_IP) !== false;
}
public static function check_ip($requestIp, $ips)
{
if (!self::validate_ip($requestIp)) {
return false;
}
if (!\is_array($ips)) {
$ips = [$ips];
}
$method = substr_count($requestIp, ':') > 1 ? 'check_ip6' : 'check_ip4';
foreach ($ips as $ip) {
if (self::$method($requestIp, $ip)) {
return true;
}
}
return false;
}
public static function check_ip6($requestIp, $ip)
{
if (false !== strpos($ip, '/')) {
list($address, $netmask) = explode('/', $ip, 2);
if ('0' === $netmask) {
return (bool) unpack('n*', @inet_pton($address));
}
if ($netmask < 1 || $netmask > 128) {
return false;
}
} else {
$address = $ip;
$netmask = 128;
}
$bytesAddr = unpack('n*', @inet_pton($address));
$bytesTest = unpack('n*', @inet_pton($requestIp));
if (!$bytesAddr || !$bytesTest) {
return false;
}
for ($i = 1, $ceil = ceil($netmask / 16); $i <= $ceil; ++$i) {
$left = $netmask - 16 * ($i - 1);
$left = ($left <= 16) ? $left : 16;
$mask = ~(0xffff >> $left) & 0xffff;
if (($bytesAddr[$i] & $mask) != ($bytesTest[$i] & $mask)) {
return false;
}
}
return true;
}
public static function check_ip4($requestIp, $ip)
{
if (false !== strpos($ip, '/')) {
list($address, $netmask) = explode('/', $ip, 2);
if ('0' === $netmask) {
return false;
}
if ($netmask < 0 || $netmask > 32) {
return false;
}
} else {
$address = $ip;
$netmask = 32;
}
if (false === ip2long($address)) {
return false;
}
return 0 === substr_compare(sprintf('%032b', ip2long($requestIp)), sprintf('%032b', ip2long($address)), 0, $netmask);
}
}
?>

View File

@@ -0,0 +1,35 @@
<?php
/*
[UCenter] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: ucip_getter_dnslist.class.php 969 2019-12-19 12:00:00Z community $
*/
class ucip_getter_dnslist {
public static function get($s) {
if (empty($s['header']) || empty($s['list'])) {
return $_SERVER['REMOTE_ADDR'];
}
$ip = $_SERVER['REMOTE_ADDR'];
$rdns = gethostbyaddr($ip);
foreach($s['list'] as $host) {
if (preg_match('/'.$host.'$/i', $rdns)) {
if ($s['header'] != 'HTTP_X_FORWARDED_FOR') {
$ip = ucip::validate_ip($_SERVER[$s['header']]) ? $_SERVER[$s['header']] : $ip;
} else {
if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ",") > 0) {
$exp = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']);
$ip = ucip::validate_ip(trim($exp[0])) ? $exp[0] : $ip;
} else {
$ip = ucip::validate_ip($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $ip;
}
}
}
}
return $ip;
}
}

View File

@@ -0,0 +1,30 @@
<?php
/*
[UCenter] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: ucip_getter_header.class.php 809 2019-12-19 12:00:00Z community $
*/
class ucip_getter_header {
public static function get($s) {
if (empty($s['header'])) {
return $_SERVER['REMOTE_ADDR'];
}
$ip = $_SERVER['REMOTE_ADDR'];
if ($s['header'] != 'HTTP_X_FORWARDED_FOR') {
$ip = ucip::validate_ip($_SERVER[$s['header']]) ? $_SERVER[$s['header']] : $ip;
} else {
if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ",") > 0) {
$exp = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']);
$ip = ucip::validate_ip(trim($exp[0])) ? $exp[0] : $ip;
} else {
$ip = ucip::validate_ip($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $ip;
}
}
return $ip;
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
[UCenter] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: ucip_getter_iplist.class.php 959 2019-12-19 12:00:00Z community $
*/
class ucip_getter_iplist {
public static function get($s) {
if (empty($s['header']) || empty($s['list'])) {
return $_SERVER['REMOTE_ADDR'];
}
$ip = $_SERVER['REMOTE_ADDR'];
$rdns = gethostbyaddr($ip);
foreach($s['list'] as $host) {
if (ucip::check_ip($ip, $host)) {
if ($s['header'] != 'HTTP_X_FORWARDED_FOR') {
$ip = ucip::validate_ip($_SERVER[$s['header']]) ? $_SERVER[$s['header']] : $ip;
} else {
if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ",") > 0) {
$exp = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']);
$ip = ucip::validate_ip(trim($exp[0])) ? $exp[0] : $ip;
} else {
$ip = ucip::validate_ip($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $ip;
}
}
}
}
return $ip;
}
}

105
uc_client/lib/xml.class.php Normal file
View File

@@ -0,0 +1,105 @@
<?php
/*
[UCenter] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: xml.class.php 1059 2011-03-01 07:25:09Z monkey $
*/
function xml_unserialize(&$xml, $isnormal = FALSE) {
$xml_parser = new XML($isnormal);
$data = $xml_parser->parse($xml);
$xml_parser->destruct();
return $data;
}
function xml_serialize($arr, $htmlon = FALSE, $isnormal = FALSE, $level = 1) {
$s = $level == 1 ? "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n<root>\r\n" : '';
$space = str_repeat("\t", $level);
foreach($arr as $k => $v) {
if(!is_array($v)) {
$s .= $space."<item id=\"$k\">".($htmlon ? '<![CDATA[' : '').$v.($htmlon ? ']]>' : '')."</item>\r\n";
} else {
$s .= $space."<item id=\"$k\">\r\n".xml_serialize($v, $htmlon, $isnormal, $level + 1).$space."</item>\r\n";
}
}
$s = preg_replace("/([\x01-\x08\x0b-\x0c\x0e-\x1f])+/", ' ', $s);
return $level == 1 ? $s."</root>" : $s;
}
class XML {
var $parser;
var $document;
var $stack;
var $data;
var $last_opened_tag;
var $isnormal;
var $attrs = array();
var $failed = FALSE;
function __construct($isnormal) {
$this->XML($isnormal);
}
function XML($isnormal) {
$this->isnormal = $isnormal;
$this->parser = xml_parser_create('ISO-8859-1');
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, 'open','close');
xml_set_character_data_handler($this->parser, 'data');
}
function destruct() {
xml_parser_free($this->parser);
}
function parse(&$data) {
$this->document = array();
$this->stack = array();
return xml_parse($this->parser, $data, true) && !$this->failed ? $this->document : '';
}
function open($parser, $tag, $attributes) {
$this->data = '';
$this->failed = FALSE;
if(!$this->isnormal) {
if(isset($attributes['id']) && !(isset($this->document[$attributes['id']]) && is_string($this->document[$attributes['id']]))) {
$this->document = &$this->document[$attributes['id']];
} else {
$this->failed = TRUE;
}
} else {
if(!isset($this->document[$tag]) || !is_string($this->document[$tag])) {
$this->document = &$this->document[$tag];
} else {
$this->failed = TRUE;
}
}
$this->stack[] = &$this->document;
$this->last_opened_tag = $tag;
$this->attrs = $attributes;
}
function data($parser, $data) {
if($this->last_opened_tag != NULL) {
$this->data .= $data;
}
}
function close($parser, $tag) {
if($this->last_opened_tag == $tag) {
$this->document = $this->data;
$this->last_opened_tag = NULL;
}
array_pop($this->stack);
if($this->stack) {
$this->document = &$this->stack[count($this->stack)-1];
}
}
}
?>