1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2016/12/21
- * Time: 下午4:06
- */
- class util
- {
- const min_memno = 500;
- const max_memno = 2000;
- public static function member_avatar($path)
- {
- if (is_null($path) || empty($path)) {
- $img = 'female.png';
- return RESOURCE_SITE_URL . '/mobile/defimg/' . $img;
- } else {
- if (strncasecmp($path, "http://", strlen("http://")) == 0) {
- $url = $path;
- } else {
- $url = UPLOAD_SITE_URL . "/shop/avatar{$path}";
- }
- return $url;
- }
- }
- public static function goods_thumb_image($path, $store_id)
- {
- return cthumb($path, 480, $store_id);
- }
- public static function goods_spec($item)
- {
- $keyval = unserialize($item);
- if($keyval == false) {
- return "";
- }
- foreach ($keyval as $key => $val) {
- return $val;
- }
- return "";
- }
- public static function nickname($nick, $mobile, $name)
- {
- if (isset($nick) && !empty($nick)) {
- return $nick;
- }
- if (isset($name) && !empty($name)) {
- return $name;
- }
- if (isset($mobile) && !empty($mobile)) {
- if (strlen($mobile) == 11) {
- return substr_replace($mobile, '****', 3, 4);
- }
- }
- return '';
- }
- public static function mem_no()
- {
- $number = self::mb_incr('member_no',1,self::min_memno);
- if($number > self::max_memno) {
- self::mb_del_incr('member_no');
- $start_number = mt_rand(self::min_memno,2 * self::min_memno);
- $number = self::mb_incr('member_no',1,$start_number);
- }
- return $number;
- }
- private static function mb_incr($key,$val,$def_value = 0)
- {
- return incrcache('global_incr',$key,$val,'mb_',$def_value);
- }
- private static function mb_del_incr($key)
- {
- return del_incr('global_incr',$key,'mb_');
- }
- }
|