Merge pull request !9 from Mushan3420/master

This commit is contained in:
Mushan3420 2017-01-19 09:02:24 +08:00 committed by 康盛Discuz!
commit e6d090054d
2 changed files with 25 additions and 23 deletions

View File

@ -47,8 +47,8 @@ class helper_seo {
public static function strreplace_strip_split($searchs, $replaces, $str) { public static function strreplace_strip_split($searchs, $replaces, $str) {
$searchspace = array('((\s*\-\s*)+)', '((\s*\,\s*)+)', '((\s*\|\s*)+)', '((\s*\t\s*)+)', '((\s*_\s*)+)'); $searchspace = array('(((\s)*\-(\s)*)+)', '(((\s)*\,(\s)*)+)', '(((\s)*\|(\s)*)+)', '(((\s)*\t(\s)*)+)', '(((\s)*_(\s)*)+)');
$replacespace = array('-', ',', '|', ' ', '_'); $replacespace = array('$3-$3', '$3,$3', '$3|$3', '$3 $3', '$3_$3');
return trim(preg_replace($searchspace, $replacespace, str_replace($searchs, $replaces, $str)), ' ,-|_'); return trim(preg_replace($searchspace, $replacespace, str_replace($searchs, $replaces, $str)), ' ,-|_');
} }

View File

@ -16,12 +16,12 @@ include_once 'home.php';
class mobile_api { class mobile_api {
var $tmpavatar; public static $tmpavatar;
var $tmpavatarbig; public static $tmpavatarbig;
var $tmpavatarmiddle; public static $tmpavatarmiddle;
var $tmpavatarsmall; public static $tmpavatarsmall;
function common() { public static function common() {
global $_G; global $_G;
if(empty($_G['uid'])) { if(empty($_G['uid'])) {
self::error('api_uploadavatar_unavailable_user'); self::error('api_uploadavatar_unavailable_user');
@ -33,7 +33,9 @@ class mobile_api {
list($width, $height, $type, $attr) = getimagesize($_FILES['Filedata']['tmp_name']); list($width, $height, $type, $attr) = getimagesize($_FILES['Filedata']['tmp_name']);
$imgtype = array(1 => '.gif', 2 => '.jpg', 3 => '.png'); $imgtype = array(1 => '.gif', 2 => '.jpg', 3 => '.png');
$filetype = $imgtype[$type]; $filetype = $imgtype[$type];
if(!$filetype) $filetype = '.jpg'; if (!$filetype) {
$filetype = '.jpg';
}
$avatarpath = $_G['setting']['attachdir']; $avatarpath = $_G['setting']['attachdir'];
$tmpavatar = $avatarpath.'./temp/upload'.$_G['uid'].$filetype; $tmpavatar = $avatarpath.'./temp/upload'.$_G['uid'].$filetype;
file_exists($tmpavatar) && @unlink($tmpavatar); file_exists($tmpavatar) && @unlink($tmpavatar);
@ -62,27 +64,27 @@ class mobile_api {
self::error('api_uploadavatar_unusable_image'); self::error('api_uploadavatar_unusable_image');
} }
$this->tmpavatar = $tmpavatar; self::$tmpavatar = $tmpavatar;
$this->tmpavatarbig = $avatarpath.$tmpavatarbig; self::$tmpavatarbig = $avatarpath.$tmpavatarbig;
$this->tmpavatarmiddle = $avatarpath.$tmpavatarmiddle; self::$tmpavatarmiddle = $avatarpath.$tmpavatarmiddle;
$this->tmpavatarsmall = $avatarpath.$tmpavatarsmall; self::$tmpavatarsmall = $avatarpath.$tmpavatarsmall;
} }
function output() { public static function output() {
global $_G; global $_G;
if(!empty($_G['uid'])) { if(!empty($_G['uid'])) {
if($this->tmpavatarbig && $this->tmpavatarmiddle && $this->tmpavatarsmall) { if (self::$tmpavatarbig && self::$tmpavatarmiddle && self::$tmpavatarsmall) {
$avatar1 = self::byte2hex(file_get_contents($this->tmpavatarbig)); $avatar1 = self::byte2hex(file_get_contents(self::$tmpavatarbig));
$avatar2 = self::byte2hex(file_get_contents($this->tmpavatarmiddle)); $avatar2 = self::byte2hex(file_get_contents(self::$tmpavatarmiddle));
$avatar3 = self::byte2hex(file_get_contents($this->tmpavatarsmall)); $avatar3 = self::byte2hex(file_get_contents(self::$tmpavatarsmall));
$extra = '&avatar1='.$avatar1.'&avatar2='.$avatar2.'&avatar3='.$avatar3; $extra = '&avatar1='.$avatar1.'&avatar2='.$avatar2.'&avatar3='.$avatar3;
$result = self::uc_api_post_ex('user', 'rectavatar', array('uid' => $_G['uid']), $extra); $result = self::uc_api_post_ex('user', 'rectavatar', array('uid' => $_G['uid']), $extra);
@unlink($this->tmpavatar); @unlink(self::$tmpavatar);
@unlink($this->tmpavatarbig); @unlink(self::$tmpavatarbig);
@unlink($this->tmpavatarmiddle); @unlink(self::$tmpavatarmiddle);
@unlink($this->tmpavatarsmall); @unlink(self::$tmpavatarsmall);
if($result == '<?xml version="1.0" ?><root><face success="1"/></root>') { if($result == '<?xml version="1.0" ?><root><face success="1"/></root>') {
$variable = array( $variable = array(
@ -99,7 +101,7 @@ class mobile_api {
} }
} }
function byte2hex($string) { public static function byte2hex($string) {
$buffer = ''; $buffer = '';
$value = unpack('H*', $string); $value = unpack('H*', $string);
$value = str_split($value[1], 2); $value = str_split($value[1], 2);
@ -111,7 +113,7 @@ class mobile_api {
return $b; return $b;
} }
function uc_api_post_ex($module, $action, $arg = array(), $extra = '') { public static function uc_api_post_ex($module, $action, $arg = array(), $extra = '') {
$s = $sep = ''; $s = $sep = '';
foreach($arg as $k => $v) { foreach($arg as $k => $v) {
$k = urlencode($k); $k = urlencode($k);