MastodonHelp/web/lib/delinstbyid.php

50 lines
2.8 KiB
PHP
Raw Normal View History

2023-12-26 11:16:24 +01:00
<?php
function delinstbyid(&$link,&$id,$efunc,$eol) {
if (!query($link,'DELETE FROM Instances WHERE ID='.$id,'eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from Instances table.'.$eol);
if (!query($link,'DELETE FROM InstActivity WHERE InstID='.$id,'eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from InstActivity table.'.$eol);
2023-12-27 20:34:45 +01:00
if (!query($link,'DELETE FROM InstBlocks WHERE InstID='.$id,'eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from Instances table.'.$eol);
2023-12-26 11:16:24 +01:00
if (!query($link,'DELETE FROM InstChecks WHERE InstID='.$id,'eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from InstChecks table.'.$eol);
if (!query($link,'DELETE FROM InstFinancing WHERE InstID='.$id,'eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from InstFinancing table.'.$eol);
if (!query($link,'DELETE FROM InstLangs WHERE InstID='.$id,'eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from InstLangs table.'.$eol);
if (!query($link,'DELETE FROM InstOurLangs WHERE InstID='.$id,'eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from InstOurLangs table.'.$eol);
if (!query($link,'DELETE FROM InstPolicies WHERE InstID='.$id,'eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from InstPolicies table.'.$eol);
2023-12-27 20:34:45 +01:00
if (!query($link,'DELETE FROM InstRules WHERE InstID='.$id,'eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from Instances table.'.$eol);
2023-12-26 11:16:24 +01:00
if (!query($link,'DELETE FROM InstTags WHERE InstID='.$id,'eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from InstTags table.'.$eol);
if (!query($link,'DELETE FROM InstTrends WHERE InstID='.$id,'eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from InstTrends table.'.$eol);
if (!query($link,'DELETE FROM UsersFields WHERE UserID IN (SELECT ID FROM Users WHERE InstID='.$id.')','eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from UsersFields table.'.$eol);
if (!query($link,'DELETE FROM Users WHERE InstID='.$id,'eecho',$eol)) return(false);
$efunc('Deleted '.mysqli_affected_rows($link).' records from Users table.'.$eol);
return(true);
}
function query(&$link,$query,$efunc,&$eol) {
try {
$res=mysqli_query($link,$query);
}
catch (Exception $error) {
$efunc('Query «'.$query.'» failed: '.$error->getMessage().' ('.$error->getCode().').'.$eol);
return(false);
}
// for php versions < 8, which seem to not catch mysql exceptions
if ($res===false) {
$efunc('Query «'.$query.'» failed: '.mysqli_errno($link).': '.mysqli_error($link).'.'.$eol);
return(false);
}
return($res);
}
?>