public function deleteObject($bucket_name, $object_name) { $Connection = isset($this->ceph_conn) ? $this->ceph_conn : $this->connectionCeph(); $user = new UserService(); $fileinfo = self::queryFile($bucket_name, ${$object_name}); if ($Connection->if_object_exists($bucket_name, $object_name)) { $res = $Connection->delete_object($bucket_name, $object_name); if (!$res->isOK()) { return false; } } elseif ($Connection->if_object_exists($bucket_name, $object_name . '~')) { $upload = $user->queryUserUploadId(session('userid'), $object_name); $Connection->abort_multipart_upload($bucket_name, $object_name . '~', $upload['uploadid']); $res = $Connection->delete_object($bucket_name, $object_name . '~'); if (!$res->isOK()) { return false; } } $user->deleteUserUploadMarker(session('userid'), $object_name); $part_file_path = session('user_upload_path') . DIRECTORY_SEPARATOR . $object_name . '~' . DIRECTORY_SEPARATOR; removeFile($part_file_path); if ($fileinfo['status'] == 0) { $filesize = $fileinfo['filesize']; $user_space = $user->querySpace(session('userid')); $user->updateUserUspace(session('userid'), $user_space['uspace'] - intval($filesize)); } return true; }
public function loginAuth($username, $password, $salt) { $username = isset($username) ? $username : ''; $password = isset($password) ? $password : ''; $salt = isset($salt) ? $salt : 0; $token_c = new \lib\Token_Core(); $token = $token_c->grante_token(); $ret_h = new \proto\RetHead(array('ret' => 1, 'msg' => 'login auth error')); $ret_arr = array('result' => $ret_h, 'token' => '', 'space' => 0, 'uspace' => 0, 'aliasname' => '', 'userid' => 0, 'flow' => 0, 'uflow' => 0); $user = new UserService(); $status = $user->loginAuth($username, $password, $salt); if ($status) { $userspace = $user->querySpace(session("userid")); session('space', $userspace['space']); session('uspace', $userspace['uspace']); $user_flow = $user->queryFlow(session("userid")); session('flow', $user_flow['flow']); session('uflow', $user_flow['uflow']); $user->queryCephAuth(session("userid")); $ret_h = new \proto\RetHead(array('ret' => 0, 'msg' => 'Login Auth Success')); $ret_arr = array('result' => $ret_h, 'token' => $token, 'space' => session('space'), 'uspace' => session('uspace'), 'aliasname' => session("alias"), 'userid' => session("userid"), 'flow' => session('flow'), 'uflow' => session('uflow')); session('user_upload_path', DEFAULT_CACHE_PATH . DIRECTORY_SEPARATOR . session('userid')); mkdirs(session('user_upload_path')); } $ret = new loginResult($ret_arr); return $ret; }
public function delObj($token, $oid, $type) { $ret = array('ret' => 1, 'msg' => 'delete object token invalid!'); $token_c = new \lib\Token_Core(); if ($token_c->is_token($token)) { if (in_array($type, self::_get_user_all_ftype())) { $Bucket_name = self::_get_bucket_name_by_ftype($type); $host = CEPH_HOST; $aws_key = session('user_key'); $aws_secret_key = session('user_secret_key'); $conn = new cephService($host, $aws_key, $aws_secret_key); $q_ret = $conn->queryFile($Bucket_name, $oid); if ($conn->deleteObject($Bucket_name, $oid)) { $ret = array('ret' => 0, 'msg' => ''); try { $user = new UserService(); if ($q_ret['status'] === 0) { $filesize = $q_ret['filesize']; $user_space = $user->querySpace(session('userid')); $user->updateUserUspace(session('userid'), $user_space['uspace'] - intval($filesize)); } } catch (Exception $e) { } } else { $ret = array('ret' => 2, 'msg' => 'delete object failed!'); } } else { $ret = array('ret' => 3, 'msg' => 'delete object error,INVAILD_PARAMETER!'); } } $ret_h = new \proto\RetHead($ret); return $ret_h; }