Esempio n. 1
0
 public static function RecvPortraits($input_name, $img_id, $dir, $hash_type = 'null')
 {
     if (GlobalCore::disuploadedfile($_FILES[$input_name]['tmp_name']) && $_FILES[$input_name]['tmp_name'] != 'none' && $_FILES[$input_name]['tmp_name'] && trim($_FILES[$input_name]['name'])) {
         $pic_extarray = array('gif', 'jpg', 'png');
         $_FILES[$input_name]['name'] = GlobalCore::chobits_addslashes($_FILES[$input_name]['name']);
         $pic_ext = strtolower(GlobalCore::fileext($_FILES[$input_name]['name']));
         if (is_array($pic_extarray) && !in_array($pic_ext, $pic_extarray)) {
             GlobalCore::showmessage('profile_avatar_invalid');
         }
         if ($hash_type == 'id') {
             $filename = $img_id;
             $pic = $dir . '/l/' . GlobalCore::mkdir_by_uid($img_id, NOWHERE_ROOT . $dir . '/l') . '/' . $filename . '.' . $pic_ext;
         } else {
             $filename = $img_id . '_' . GlobalCore::random(5);
             $pic = $dir . '/l/' . GlobalCore::mkdir_hash($img_id, NOWHERE_ROOT . $dir . '/l') . '/' . $filename . '.' . $pic_ext;
         }
         $pic_target = NOWHERE_ROOT . './' . $pic;
         if (!@copy($_FILES[$input_name]['tmp_name'], $pic_target)) {
             @move_uploaded_file($_FILES[$input_name]['tmp_name'], $pic_target);
         }
         if (file_exists($pic_target)) {
             $port['pic'] = $pic;
             $port['filename'] = $filename;
             $port['pic_target'] = $pic_target;
             $port['pic_ext'] = $pic_ext;
             return $port;
         }
     }
 }