You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.7 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. <?php
  2. /*
  3. * @copyright Leyun internet Technology(Shanghai)Co.,Ltd
  4. * @license http://www.dzzoffice.com/licenses/license.txt
  5. * @package DzzOffice
  6. * @link http://www.dzzoffice.com
  7. * @author zyx(zyx@dzz.cc)
  8. */
  9. error_reporting(0);
  10. define('SITEURL', strtolower(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'))));
  11. $uid = $_GET['uid'] ?? 0;
  12. $size = $_GET['size'] ?? '';
  13. $random = $_GET['random'] ?? '';
  14. $type = $_GET['type'] ?? '';
  15. $check = $_GET['check_file_exists'] ?? '';
  16. $avatar = './data/avatar/' . get_avatar($uid, $size, $type);
  17. if (file_exists(dirname(__FILE__) . '/' . $avatar)) {
  18. if ($check) {
  19. echo 1;
  20. exit;
  21. }
  22. $random = !empty($random) ? rand(1000, 9999) : '';
  23. $avatar_url = empty($random) ? $avatar : $avatar . '?random=' . $random;
  24. } else {
  25. if ($check) {
  26. echo 0;
  27. exit;
  28. }
  29. $size = in_array($size, array('big', 'middle', 'small')) ? $size : 'middle';
  30. $avatar_url = 'static/image/avatar/noavatar_' . $size . '.gif';
  31. }
  32. if (empty($random)) {
  33. header("HTTP/1.1 301 Moved Permanently");
  34. header("Last-Modified:" . date('r'));
  35. header("Expires: " . date('r', time() + 86400));
  36. }
  37. header('Location: ' . SITEURL . '/' . $avatar_url);
  38. exit;
  39. function get_avatar($uid, $size = 'middle', $type = '') {
  40. $size = in_array($size, array('big', 'middle', 'small')) ? $size : 'middle';
  41. $uid = abs(intval($uid));
  42. $uid = sprintf("%09d", $uid);
  43. $dir1 = substr($uid, 0, 3);
  44. $dir2 = substr($uid, 3, 2);
  45. $dir3 = substr($uid, 5, 2);
  46. $typeadd = $type == 'real' ? '_real' : '';
  47. return $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($uid, -2) . $typeadd . "_avatar_$size.jpg";
  48. }