avatar.php 996 B

123456789101112131415161718192021222324252627
  1. <?php
  2. include '../../../system/db.class.php';
  3. if (!empty($_FILES)) {
  4. $filepart = pathinfo($_FILES['avatar']['name']);
  5. if (in_array(strtolower($filepart['extension']), array('jpg', 'jpeg', 'gif', 'png'))) {
  6. $type = $_POST['type'];
  7. $upw = SafeSql($_POST['upw']);
  8. $uid = intval($_POST['uid']);
  9. if (!db('user')->where('in_userid', $uid)->where('in_userpassword', $upw)->count()) {
  10. exit('-2');
  11. }
  12. if ($type == 'avatar') {
  13. $path = IN_ROOT . 'data/attachment/avatar/' . $uid;
  14. @move_uploaded_file($_FILES['avatar']['tmp_name'], $path . '.jpg');
  15. } elseif (in_array($type, array('prev', 'after', 'hand'))) {
  16. $dir = IN_ROOT . 'data/tmp/';
  17. if (!is_dir($dir)) {
  18. @mkdir($dir, 0777, true);
  19. }
  20. @move_uploaded_file($_FILES['avatar']['tmp_name'], $dir . $uid . '-' . $type . '.jpg');
  21. }
  22. echo '1';
  23. } else {
  24. echo '-1';
  25. }
  26. }