예제 #1
0
             $NewUserAccountStatus = $UserInfo['UserAccountStatus'] ? 0 : 1;
             if (UpdateUserInfo(array('UserAccountStatus' => $NewUserAccountStatus), $ID)) {
                 $Message = $NewUserAccountStatus ? $Lang['Block_User'] : $Lang['Unblock_User'];
             }
             break;
             //重置头像
         //重置头像
         case 'ResetAvatar':
             Auth(4, $ID);
             if (extension_loaded('gd')) {
                 require dirname(__FILE__) . "/includes/MaterialDesign.Avatars.class.php";
                 $Avatar = new MDAvtars(mb_substr($UserInfo['UserName'], 0, 1, "UTF-8"), 256);
                 $Avatar->Save('upload/avatar/large/' . $ID . '.png', 256);
                 $Avatar->Save('upload/avatar/middle/' . $ID . '.png', 48);
                 $Avatar->Save('upload/avatar/small/' . $ID . '.png', 24);
                 $Avatar->Free();
                 $Message = $Lang['Reset_Avatar_Successfully'];
             } else {
                 $Message = $Lang['Reset_Avatar_Successfully'];
                 //Failure
             }
             break;
         default:
             AlertMsg('Bad Request', 'Bad Request');
             break;
     }
     break;
     //Follow or Favorite
 //Follow or Favorite
 case 4:
     Auth(1);
예제 #2
0
function avatar($user_name, $uid = 0, $size = 120)
{
    global $_G;
    if (!$user_name) {
        return '/assets/global/images/avatar.png';
    }
    if ($uid > 0 && $uid == $_G['uid']) {
        if ($_G['member']['picurl']) {
            return $_G['member']['picurl'];
        }
    }
    $name = $uid;
    if (!$uid) {
        $name = $_G['uid'];
    }
    if (!$uid) {
        $name = cutstr(md5($user_name), 5, '');
    }
    $path = '/assets/' . $_G['setting']['template'] . '/avatars/' . $name . '.png';
    if (file_exists(ROOT_PATH . $path)) {
        return $path;
    }
    $dir = dirname(ROOT_PATH . $path);
    if (!is_dir($dir)) {
        dmkdir($dir);
    }
    $atavar_type = $_G['setting']['avatar_type'];
    if ($atavar_type == 1) {
        if (!class_exists('MDAvtars')) {
            require_once ROOT_PATH . "web/lib/md_avtars/MaterialDesign.Avatars.class.php";
        }
        $Avatar = new MDAvtars($user_name, $size);
        $Avatar->Save(ROOT_PATH . $path, $size);
        $Avatar->Free();
    } elseif ($atavar_type == 2) {
        if (!class_exists('Identicon')) {
            require_once ROOT_PATH . "web/lib/generator_avatar/Identicon.php";
        }
        $identicon = new Identicon();
        $identicon->save($user_name, ROOT_PATH . $path, $size);
    }
    return $path;
}