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) {
$searchspace = array('((\s*\-\s*)+)', '((\s*\,\s*)+)', '((\s*\|\s*)+)', '((\s*\t\s*)+)', '((\s*_\s*)+)');
$replacespace = array('-', ',', '|', ' ', '_');
$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)), ' ,-|_');
}

View File

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