/** * Remove previous scan files * @return string */ public function actionAntivirusclear() { File::remove('/Private/Antivirus/Infected.json'); File::remove('/Private/Antivirus/ScanFiles.json'); $this->setJsonHeader(); return json_encode(['status' => 1]); }
/** * Delete user from database * @throws \Exception */ public function delete() { foreach ($this->users as $user) { /** @var iUser $user */ $uid = $user->getParam('id'); // delete wall records WallPost::where('target_id', '=', $uid)->orWhere('sender_id', '=', $uid)->delete(); // delete avatars File::remove('/upload/user/avatar/big/' . $uid . '.jpg'); File::remove('/upload/user/avatar/medium/' . $uid . '.jpg'); File::remove('/upload/user/avatar/small/' . $uid . '.jpg'); File::remove('/upload/user/avatar/original/' . $uid . '.jpg'); // delete user profile and auth data $user->getProfile()->delete(); // delete user provider data $user->getProviders()->delete(); // delete user object $user->delete(); } }
/** * Remove items from gallery (preview+full) * @param int $id * @param string $file * @throws ForbiddenException * @throws NativeException * @return string */ public function actionGallerydelete($id, $file = null) { if ($file === null || Str::likeEmpty($file)) { $file = (string) $this->request->query->get('file', null); } // check passed data if (Str::likeEmpty($file) || !Obj::isLikeInt($id)) { throw new NativeException('Wrong input data'); } // check passed file extension $fileExt = Str::lastIn($file, '.', true); $fileName = Str::firstIn($file, '.'); if (!Arr::in($fileExt, $this->allowedExt)) { throw new ForbiddenException('Wrong file extension'); } // generate path $thumb = '/upload/gallery/' . $id . '/thumb/' . $fileName . '.jpg'; $full = '/upload/gallery/' . $id . '/orig/' . $file; // check if file exists and remove if (File::exist($thumb) || File::exist($full)) { File::remove($thumb); File::remove($full); } else { throw new NativeException('Image is not founded'); } return json_encode(['status' => 1, 'msg' => 'Image is removed']); }