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

Function admin_self_destruct

Scripts/ButSystem.py:12324–12390  ·  view source on GitHub ↗

Delete all ButSystem data from storage. Admin-only, requires creds.

()

Source from the content-addressed store, hash-verified

12322
12323def _parse_date_start(value: str) -> Optional[float]:
12324 try:
12325 return datetime.strptime(value, "%Y-%m-%d").timestamp() if value else None
12326 except Exception:
12327 return None
12328
12329
12330def _parse_date_end(value: str) -> Optional[float]:
12331 try:
12332 return (datetime.strptime(value, "%Y-%m-%d") + timedelta(days=1)).timestamp() if value else None
12333 except Exception:
12334 return None
12335
12336
12337def list_dir_entries(username: str, rel: str, sort: str = "name", order: str = "asc", query: str = "", category: str = "all", size_min: int = 0, size_max: Optional[int] = None, date_from_ts: Optional[float] = None, date_to_ts: Optional[float] = None):
12338 rel = safe_relpath(rel)
12339 base = abs_user_path(username, rel)
12340 os.makedirs(base, exist_ok=True)
12341 if not os.path.isdir(base):
12342 raise ValueError("Not a directory")
12343 query_cf = (query or "").strip().casefold()
12344 rows = []
12345 if query_cf:
12346 iterator = []
12347 for current, dirs, files_ in os.walk(base, followlinks=False):
12348 dirs[:] = [d for d in dirs if not os.path.islink(os.path.join(current, d))]
12349 for name in dirs + files_:
12350 iterator.append((current, name))
12351 else:
12352 iterator = [(base, name) for name in os.listdir(base)]
12353 user_base = user_root(username)
12354 for current, name in iterator:
12355 full = os.path.join(current, name)
12356 try:
12357 if os.path.islink(full):
12358 continue
12359 st = os.stat(full)
12360 except Exception:
12361 continue
12362 is_dir = os.path.isdir(full)
12363 item_rel = os.path.relpath(full, user_base).replace(os.sep, "/")
12364 parent_rel = os.path.dirname(item_rel).replace(os.sep, "/")
12365 cat = _file_category(name, is_dir)
12366 if query_cf and query_cf not in name.casefold() and query_cf not in item_rel.casefold():
12367 continue
12368 if category != "all" and cat != category:
12369 continue
12370 if not is_dir:
12371 if st.st_size < max(0, int(size_min or 0)):
12372 continue
12373 if size_max is not None and st.st_size > int(size_max):
12374 continue
12375 if date_from_ts is not None and st.st_mtime < date_from_ts:
12376 continue
12377 if date_to_ts is not None and st.st_mtime >= date_to_ts:
12378 continue
12379 rows.append({"name": name, "relpath": item_rel, "display_parent": parent_rel if query_cf else "", "is_dir": is_dir, "category": cat, "kind": "Folder" if is_dir else guess_mime(name), "size": st.st_size, "mtime": st.st_mtime})
12380 reverse = order == "desc"
12381 key_map = {

Callers

nothing calls this directly

Calls 5

require_adminFunction · 0.70
current_userFunction · 0.70
db_connectFunction · 0.70
clearMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected