Пример #1
0
function get_web_avatar($args, $i = 0)
{
    d_s();
    $info = $args;
    if ($i > 49) {
        show_pick_info(milu_lang('alway_no_get'), 'show_err');
        exit;
    }
    extract($args);
    $_SESSION['avatar_get']['now_get'] = $info['now_get'] = $now_get;
    $_SESSION['avatar_get']['avatar_get_uid'] = $info['avatar_get_uid'] = $avatar_get_uid;
    $_SESSION['avatar_get']['all_get_time'] = $all_get_time;
    $avatar = get_avatar($avatar_get_uid, 'middle');
    $icon_url = $avatar_web_url . $avatar;
    show_pick_info(array(milu_lang('the_uid'), ' <a target="_blank" href="' . $icon_url . '">' . $avatar_get_uid . '</a>' . milu_lang('the_avatar')), 'left', array('li_no_end' => 1, 'no_border' => 1, 'now' => $now_get));
    $snoopy_args = array();
    $snoopy_obj = get_snoopy_obj($snoopy_args);
    if (!$snoopy_obj) {
        show_pick_info(milu_lang('no_get_avatar'), 'err', $show_arr);
        $info['all_get_time'] = $all_get_time;
        $info['now_get']++;
        $info['avatar_get_uid']++;
        avatar_page_jump($now_get, $avata_jump_num, $get_count);
        return get_web_avatar($info, $i + 1);
    }
    $img_re = get_img_content($icon_url, $snoopy_obj);
    //得到的是middle的头像
    $show_arr = get_show_arr($now_get, $success_count, $get_count, $all_get_time);
    $info['all_get_time'] = $show_arr['all_get_time'];
    if (!$img_re) {
        show_pick_info(milu_lang('avatar_no_exists'), 'err', $show_arr);
        $info['now_get']++;
        $info['avatar_get_uid']++;
        avatar_page_jump($now_get, $avata_jump_num, $get_count);
        return get_web_avatar($info, $i + 1);
    }
    if (strlen($img_re) == 3972 || strlen($img_re) < 1000) {
        //3972是discuz默认头像的大小
        show_pick_info(milu_lang('user_no_set_avatar'), 'err', $show_arr);
        $info['now_get']++;
        $info['avatar_get_uid']++;
        avatar_page_jump($now_get, $avata_jump_num, $get_count);
        return get_web_avatar($info, $i + 1);
    } else {
        //得到头像
        $now_time = time();
        $show_arr['show_js'] = 'show_icon(\'' . $show_arr['now'] . '\');';
        show_pick_info('<img width="48" height="48" style="margin:5px 0;float:right;" src="' . $icon_url . '">', 'success', $show_arr);
        show_pick_info(array(milu_lang('the_uid_set'), '<a target="_blank" href="home.php?mod=space&uid=' . $uid . '&do=profile">' . $uid . '</a>' . milu_lang('the_user_set_avatar')), 'left', array('li_no_end' => 1, 'no_border' => 1, 'now' => '-' . $show_arr['now'] . $now_time));
        $size_arr = array('middle', 'big', 'small');
        //顺序一定不可以变
        $create_re = create_avatar_dir($uid, $size);
        //建立头像目录
        if (!$create_re) {
            show_pick_info(milu_lang('avatar_dir_no_wirte'), 'err', $show_arr);
            return FALSE;
        }
        foreach ($size_arr as $size) {
            if ($size != 'middle') {
                $icon_url = $avatar_web_url . get_avatar($avatar_get_uid, $size);
                $img_re = get_img_content($icon_url, $snoopy_obj);
            }
            $avatar_dir_save = './uc_server/' . get_avatar($uid, $size);
            if ($cover_avatar == 1 && file_exists($avatar_dir_save)) {
                //覆盖旧头像
                @unlink($avatar_dir_save);
            }
            $put_re = file_put_contents($avatar_dir_save, $img_re);
            //写入头像
            if (!$put_re) {
                show_pick_info(milu_lang('avatar_dir_no_wirte'), 'err', $show_arr);
                return FALSE;
            }
        }
        $success_count++;
        $_SESSION['avatar_get']['success_count'] = $success_count;
        $show_arr = get_show_arr($now_get, $success_count, $get_count, $all_get_time);
        $show_arr['now_get']++;
        $show_arr['avatar_get_uid']++;
        $show_arr['get_count'] = $get_count;
        $show_info_arr = $show_arr;
        $show_info_arr['now'] = '-' . $show_arr['now'] . $now_time;
        show_pick_info(milu_lang('success'), 'success', $show_info_arr);
        avatar_page_jump($now_get, $avata_jump_num, $get_count);
        $arr = array('content' => $img_re, 'avatar_get_uid' => $avatar_get_uid + 1, 'now_get' => $now_get + 1, 'success_count' => $success_count, 'get_count' => $get_count);
        return $show_arr ? array_merge($show_arr, $arr) : $arr;
    }
}
Пример #2
0
 function finsh()
 {
     cache_del('pick' . $this->pid);
     $this->all_get_time = $this->pick_cache_data['all_get_time'];
     $all_get_time_str = diff_time($this->all_get_time, 1);
     $get_url_count = $this->i - 1;
     $avg_get_time = $this->all_get_time / $get_url_count;
     $all_get_time_str = $all_get_time_str ? $all_get_time_str : sprintf('%.2f', $this->all_get_time) . milu_lang('sec');
     $finsh_output = milu_lang('pick_finsh', array('guc' => $get_url_count, 'g_v' => $get_url_count - $this->v_i, 'v_i' => $this->v_i, 'a' => $this->a, 'a_va' => $this->a - $this->v_a, 'v_a' => $this->v_a, 'all' => $all_get_time_str, 'avg' => sprintf('%.2f', $avg_get_time)));
     $this->get_pick_status(1);
     $this->status_arr['pro'] = 100;
     $this->status_arr['wait_time'] = $this->status_arr['wait_count'] = 0;
     show_pick_info($finsh_output, 'finsh', $this->status_arr);
     $this->words = null;
     $this->snoopy = null;
     $this->p_arr = null;
     exit;
 }