返回列表 发布新帖
查看: 173|回复: 0

comiis_app_avatar.inc

90

主题

36

回帖

594

积分

管理员

积分
594
发表于 2024-5-28 16:54:11 | 显示全部楼层 |阅读模式
  1. <?php
  2. /**
  3. *
  4. * 克米出品 必属精品
  5. * 克米设计工作室 版权所有 https://www.comiis.com
  6. * 专业论坛首页及风格制作, 页面设计美化, 数据搬家/升级, 程序二次开发, 网站效果图设计, 页面标准DIV+CSS生成, 各类大中小型企业网站设计...
  7. * 我们致力于为企业提供优质网站建设、网站推广、网站优化、程序开发、域名注册、虚拟主机等服务,
  8. * 一流设计和解决方案为企业量身打造适合自己需求的网站运营平台,最大限度地使企业在信息时代稳握无限商机。
  9. *
  10. *   电话: 0668-8810200
  11. *   手机: 13450110120  15813025137
  12. *    Q Q: 21400445  8821775  11012081  327460889
  13. * E-mail: ceo@comiis.com
  14. *
  15. * 工作时间: 周一到周五早上09:00-11:00, 下午03:00-05:00, 晚上08:30-10:30(周六、日休息)
  16. * 克米设计用户交流群: ①群83667771 ②群83667772 ③群83667773 ④群110900020 ⑤群110900021 ⑥群70068388 ⑦群110899987
  17. *
  18. */
  19. if(!defined('IN_DISCUZ')) {
  20.         exit('Access Denied');
  21. }
  22. if(submitcheck('comiis_submit') && $_G['uid'] && $_GET['formhash'] == FORMHASH){
  23.         $plugin_id = 'comiis_app_avatar';
  24.         header("Cache-Control: no-cache, must-revalidate");
  25.         $avatarpath = $_G['setting']['attachdir'];
  26.         $base64 = htmlspecialchars($_GET['str']);
  27.         if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64, $result)) {
  28.                 $type = $result[2];
  29.                 $tmpavatar = $avatarpath. './temp/twt'. time() .'.jpg';
  30.                 if(file_put_contents($tmpavatar, base64_decode(str_replace($result['1'], '', $base64)))){
  31.                         list($width, $height, $type, $attr) = getimagesize($tmpavatar);
  32.                         $imgtype = array(1 => '.gif', 2 => '.jpg', 3 => '.png');
  33.                         $filetype = $imgtype[$type];
  34.                         if(!$filetype) $filetype = '.jpg';
  35.                         if($width < 10 || $height < 10 || $type == 4){
  36.                                 @unlink($tmpavatar);
  37.                         }
  38.                         require_once libfile('class/image');
  39.                         $image = new image;
  40.                         $tmpavatarbig = './temp/upload'.$_G['uid'].'big'.$filetype;
  41.                         $tmpavatarmiddle = './temp/upload'.$_G['uid'].'middle'.$filetype;
  42.                         $tmpavatarsmall = './temp/upload'.$_G['uid'].'small'.$filetype;
  43.                         $image->Thumb($tmpavatar, $tmpavatarbig, 200, 200, 1);
  44.                         $image->Thumb($tmpavatar, $tmpavatarmiddle, 120, 120, 1);
  45.                         $image->Thumb($tmpavatar, $tmpavatarsmall, 48, 48, 2);
  46.                         loaducenter();
  47.                         $tmpavatarbig = $avatarpath.$tmpavatarbig;
  48.                         $tmpavatarmiddle = $avatarpath.$tmpavatarmiddle;
  49.                         $tmpavatarsmall = $avatarpath.$tmpavatarsmall;
  50.                         if($_G['cache']['plugin']['comiis_app_avatar']['avatar'] == 1){
  51.                                 $uid = abs(intval($_G['uid']));
  52.                                 $uid = sprintf("%09d", $uid);
  53.                                 $dir1 = substr($uid, 0, 3);
  54.                                 $dir2 = substr($uid, 3, 2);
  55.                                 $dir3 = substr($uid, 5, 2);
  56.                                 $avatar_dir = DISCUZ_ROOT. './'. ($_G['cache']['plugin']['comiis_app_avatar']['dir'] ? $_G['cache']['plugin']['comiis_app_avatar']['dir'] : 'uc_server/data/avatar/'). $dir1. '/'. $dir2. '/'. $dir3;
  57.                                 if(!file_exists($avatar_dir)){
  58.                                         mkdir($avatar_dir, 0755, true);
  59.                                 }
  60.                                 if($fp = @fopen($avatar_dir.'/'.substr($uid, -2)."_avatar_big.jpg", 'wb')) {
  61.                                         fwrite($fp, file_get_contents($tmpavatarbig));
  62.                                         fclose($fp);
  63.                                 }
  64.                                 if($fp = @fopen($avatar_dir.'/'.substr($uid, -2)."_avatar_middle.jpg", 'wb')) {
  65.                                         fwrite($fp, file_get_contents($tmpavatarmiddle));
  66.                                         fclose($fp);
  67.                                 }
  68.                                 if($fp = @fopen($avatar_dir.'/'.substr($uid, -2)."_avatar_small.jpg", 'wb')) {
  69.                                         fwrite($fp, file_get_contents($tmpavatarsmall));
  70.                                         fclose($fp);
  71.                                 }
  72.                         }else{
  73.                                 $extra = '&avatar1='.comiis_app_avatar_byte2hex(file_get_contents($tmpavatarbig)).'&avatar2='.comiis_app_avatar_byte2hex(file_get_contents($tmpavatarmiddle)).'&avatar3='.comiis_app_avatar_byte2hex(file_get_contents($tmpavatarsmall));
  74.                                 $postdata = uc_api_requestdata('user', 'rectavatar', 'uid='. $_G['uid'], $extra);
  75.                                 $result = uc_fopen2(UC_API.'/index.php', 500000, $postdata, '', TRUE, UC_IP, 20);
  76.                         }
  77.                         @unlink($tmpavatar);
  78.                         @unlink($tmpavatarbig);
  79.                         @unlink($tmpavatarmiddle);
  80.                         @unlink($tmpavatarsmall);
  81.                         if(empty($space['avatarstatus']) && uc_check_avatar($_G['uid'], 'middle')) {
  82.                                 C::t('common_member')->update($_G['uid'], array('avatarstatus'=>'1'));
  83.                                 updatecreditbyaction('setavatar');
  84.                                 // manyoulog('user', $_G['uid'], 'update');
  85.                         }
  86.                 }else{
  87.                         exit('err:0');
  88.                 }
  89.         }
  90. }
  91. function comiis_app_avatar_byte2hex($string){
  92.         $buffer = '';
  93.         $value = unpack('H*', $string);
  94.         $value = str_split($value['1'], 2);
  95.         $b = '';
  96.         foreach($value as $k => $v){
  97.                 $b .= strtoupper($v);
  98.         }
  99.         return $b;
  100. }
复制代码

本网名无法描述本人
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Powered by 【杭州赋睿科技有限公司】 萤石用户社区(浙ICP备2024101974号-2) 使用条款 | 隐私政策 | 经营许可
关灯 返回顶部
快速回复 返回顶部 返回列表