From b3ee0dd320e20fa368cd08ab00e32ae3e3dd99fb Mon Sep 17 00:00:00 2001 From: Mushan3420 Date: Fri, 13 Jan 2017 14:45:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20PHP=207.x=20=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=8B=E7=A7=BB=E5=8A=A8=E7=AB=AF=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=A4=B4=E5=83=8F=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/mobile/api/2/uploadavatar.php | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/upload/source/plugin/mobile/api/2/uploadavatar.php b/upload/source/plugin/mobile/api/2/uploadavatar.php index 6a51bc9fa..028f87fb4 100644 --- a/upload/source/plugin/mobile/api/2/uploadavatar.php +++ b/upload/source/plugin/mobile/api/2/uploadavatar.php @@ -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 == '') { $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); -- Gitee From 1bc92c7e111c10c0631192907fc7151f567ceff8 Mon Sep 17 00:00:00 2001 From: Mushan3420 Date: Wed, 18 Jan 2017 18:27:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20SEO=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A9=BA=E6=A0=BC=E6=97=A0=E6=95=88=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- upload/source/class/helper/helper_seo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upload/source/class/helper/helper_seo.php b/upload/source/class/helper/helper_seo.php index 4ea402826..7b743a3c5 100644 --- a/upload/source/class/helper/helper_seo.php +++ b/upload/source/class/helper/helper_seo.php @@ -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)), ' ,-|_'); } -- Gitee