MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / admin_demote

Function admin_demote

Scripts/ButSystem.py:12170–12214  ·  view source on GitHub ↗

admin_demote. Admin-only route handler. This docstring was expanded to make future maintenance easier. Returns: Varies.

()

Source from the content-addressed store, hash-verified

12168FILE_CATEGORIES = (
12169 ("all", "All"), ("folders", "Folders"), ("documents", "Documents"),
12170 ("images", "Images"), ("videos", "Videos"), ("audio", "Audio"),
12171 ("archives", "Archives"), ("code", "Code"), ("apps", "Applications"),
12172 ("other", "Other"),
12173)
12174_FILE_DOC_EXTS = {".pdf", ".txt", ".md", ".rtf", ".doc", ".docx", ".odt", ".xls", ".xlsx", ".ods", ".ppt", ".pptx", ".odp", ".csv", ".epub"}
12175_FILE_IMAGE_EXTS = {".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp", ".tif", ".tiff", ".heic", ".avif", ".svg"}
12176_FILE_VIDEO_EXTS = {".mp4", ".webm", ".mkv", ".mov", ".avi", ".m4v", ".3gp", ".mpeg", ".mpg"}
12177_FILE_AUDIO_EXTS = {".mp3", ".wav", ".ogg", ".oga", ".m4a", ".aac", ".flac", ".opus", ".wma"}
12178_FILE_ARCHIVE_EXTS = {".zip", ".7z", ".rar", ".tar", ".gz", ".bz2", ".xz", ".tgz", ".apk", ".jar"}
12179_FILE_CODE_EXTS = {".py", ".js", ".ts", ".html", ".css", ".json", ".xml", ".yaml", ".yml", ".sh", ".bash", ".java", ".c", ".h", ".cpp", ".hpp", ".cs", ".go", ".rs", ".php", ".sql", ".ini", ".toml"}
12180_FILE_APP_EXTS = {".apk", ".exe", ".msi", ".appimage", ".deb", ".rpm", ".dmg", ".ipa"}
12181FILE_UPLOAD_CHUNK_BYTES = 16 * 1024 * 1024
12182FILE_STORAGE_MAX_RATIO = 0.85
12183FILE_META_LOCK = threading.RLock()
12184
12185
12186def _file_category(path_or_name: str, is_dir: bool = False) -> str:
12187 if is_dir:
12188 return "folders"
12189 ext = pathlib.Path(path_or_name).suffix.lower()
12190 mime = guess_mime(path_or_name).lower()
12191 if ext in _FILE_APP_EXTS:
12192 return "apps"
12193 if ext in _FILE_IMAGE_EXTS or mime.startswith("image/"):
12194 return "images"
12195 if ext in _FILE_VIDEO_EXTS or mime.startswith("video/"):
12196 return "videos"
12197 if ext in _FILE_AUDIO_EXTS or mime.startswith("audio/"):
12198 return "audio"
12199 if ext in _FILE_ARCHIVE_EXTS:
12200 return "archives"
12201 if ext in _FILE_CODE_EXTS:
12202 return "code"
12203 if ext in _FILE_DOC_EXTS or mime.startswith("text/"):
12204 return "documents"
12205 return "other"
12206
12207
12208def _category_label(key: str) -> str:
12209 return dict(FILE_CATEGORIES).get(key, key.title())
12210
12211
12212def _validate_entry_name(value: str) -> str:
12213 name = (value or "").strip()
12214 if not name or name in (".", "..") or len(name) > 255:
12215 raise ValueError("bad_name")
12216 if any(ch in name for ch in ("/", "\\", "\x00", "\n", "\r")):
12217 raise ValueError("bad_name")

Callers

nothing calls this directly

Calls 3

require_adminFunction · 0.70
current_userFunction · 0.70
db_connectFunction · 0.70

Tested by

no test coverage detected