Remove image.
このコミットが含まれているのは:
コミット
8fbff6df86
@ -358,7 +358,43 @@ class ImageController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
function is_dir_empty($dir) {
|
||||
if (!is_readable($dir)) return NULL;
|
||||
return (count(scandir($dir)) == 2);
|
||||
}
|
||||
|
||||
public function removeImage(Request $request) { // /api/rpc/image/remove
|
||||
|
||||
$check = $this->objAuth->checkLegit($request->username, $request->password);
|
||||
|
||||
if ($check == 0) {
|
||||
return 'Err!';
|
||||
}
|
||||
else {
|
||||
$valid = $this->objAuth->getPermissions($request->username, $request->password);
|
||||
|
||||
if ($valid['usr_editother'] == 1) {
|
||||
if (isset($request->name)) {
|
||||
$fname = 'assets/images/'.$request->id.'/'.$request->name;
|
||||
unlink('storage/'.$fname);
|
||||
if ($this->is_dir_empty('storage/assets/images/'.$request->id)) rmdir('storage/assets/images/'.$request->id);
|
||||
|
||||
return 'Deleted';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isset($request->name)) {
|
||||
if ($check == $request->id) {
|
||||
$fname = 'assets/images/'.$check.'/'.$request->name;
|
||||
unlink('storage/'.$fname);
|
||||
if ($this->is_dir_empty('storage/assets/images/'.$check)) rmdir('storage/assets/images/'.$check);
|
||||
|
||||
return 'Deleted';
|
||||
}
|
||||
else {
|
||||
return 'Permission denied.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
新しいイシューから参照
ユーザーをブロックする