function avddelete($file) { @chmod($file, 0777); if (@is_dir($file)) { $handle = @opendir($file); while ($filename = readdir($handle)) { if ($filename != "." && $filename != "..") { avddelete($file . "/" . $filename); } } closedir($handle); @rmdir($file); } else { @unlink($file); } }
function avddelete($file) { $file = html_entity_decode($file, ENT_QUOTES); chmod($file, 0777); if (@is_dir($file)) { $handle = @opendir($file); while ($filename = readdir($handle)) { if ($filename != "." && $filename != "..") { avddelete($file . "/" . $filename); } } closedir($handle); @rmdir($file); } else { @unlink($file); } }
/** * deletes a dir-entry. recursive process via avddelete * * @param $del entry to delete * @return string with current */ function delDirEntry($del) { global $cfg; $current = ""; // The following lines of code were suggested by Jody Steele jmlsteele@stfu.ca // this is so only the owner of the file(s) or admin can delete if (IsAdmin($cfg["user"]) || preg_match("/^" . $cfg["user"] . "/", $del)) { // Yes, then delete it // we need to strip slashes twice in some circumstances // Ex. If we are trying to delete test/tester's file/test.txt // $del will be "test/tester\\\'s file/test.txt" // one strip will give us "test/tester\'s file/test.txt // the second strip will give us the correct // "test/tester's file/test.txt" $del = stripslashes(stripslashes($del)); if (!ereg("(\\.\\.\\/)", $del)) { avddelete($cfg["path"] . $del); $arTemp = explode("/", $del); if (count($arTemp) > 1) { array_pop($arTemp); $current = implode("/", $arTemp); } AuditAction($cfg["constants"]["fm_delete"], $del); } else { AuditAction($cfg["constants"]["error"], "ILLEGAL DELETE: " . $cfg['user'] . " tried to delete " . $del); } } else { AuditAction($cfg["constants"]["error"], "ILLEGAL DELETE: " . $cfg['user'] . " tried to delete " . $del); } return $current; }
/** * deletes data of a transfer * * @param $transfer name of the transfer * @return array */ function deleteTransferData($transfer) { global $cfg, $transfers; $msgs = array(); $isTransmissionTorrent = false; if ($cfg["transmission_rpc_enable"] == 2 && isHash($transfer)) { require_once 'inc/classes/Transmission.class.php'; $trans = new Transmission(); require_once 'inc/functions/functions.rpc.transmission.php'; $theTorrent = getTransmissionTransfer($transfer, array('hashString', 'id', 'name')); $isTransmissionTorrent = is_array($theTorrent); } if ($isTransmissionTorrent) { $response = $trans->remove($theTorrent['id'], true); if ($response[result] != "success") { @error("Delete of torrent failed", "", "", $response[result]); } } else { if ($cfg['isAdmin'] || IsOwner($cfg["user"], getOwner($transfer))) { // only torrent if (substr($transfer, -8) != ".torrent") { return $msgs; } // delete data $datapath = getTransferDatapath($transfer); if ($datapath != "" && $datapath != ".") { $targetPath = getTransferSavepath($transfer) . $datapath; if (tfb_isValidPath($targetPath)) { if (@is_dir($targetPath) || @is_file($targetPath)) { avddelete($targetPath); AuditAction($cfg["constants"]["fm_delete"], $targetPath); } } else { $msg = "ILLEGAL DELETE: " . $cfg["user"] . " attempted to delete data of " . $transfer; AuditAction($cfg["constants"]["error"], $msg); array_push($msgs, $msg); } } } else { $msg = "ILLEGAL DELETE: " . $cfg["user"] . " attempted to delete data of " . $transfer; AuditAction($cfg["constants"]["error"], $msg); array_push($msgs, $msg); } } return $msgs; }
/** * deletes a dir-entry. recursive process via avddelete * * @param $del entry to delete * @return string with current */ function delDirEntry($del) { global $cfg; $current = ""; if (tfb_isValidPath($del)) { avddelete($cfg["path"] . $del); $arTemp = explode("/", $del); if (count($arTemp) > 1) { array_pop($arTemp); $current = implode("/", $arTemp); } AuditAction($cfg["constants"]["fm_delete"], $del); } else { AuditAction($cfg["constants"]["error"], "ILLEGAL DELETE: " . $cfg["user"] . " tried to delete " . $del); } return $current; }
/** * deletes data of a transfer * * @param $transfer name of the transfer * @return array */ function deleteTransferData($transfer) { global $cfg, $transfers; $msgs = array(); if ($cfg['isAdmin'] || IsOwner($cfg["user"], getOwner($transfer))) { // only torrent if (substr($transfer, -8) != ".torrent") { return $msgs; } // delete data $datapath = getTransferDatapath($transfer); if ($datapath != "" && $datapath != ".") { $targetPath = getTransferSavepath($transfer) . $datapath; if (tfb_isValidPath($targetPath)) { if (@is_dir($targetPath) || @is_file($targetPath)) { avddelete($targetPath); AuditAction($cfg["constants"]["fm_delete"], $targetPath); } } else { $msg = "ILLEGAL DELETE: " . $cfg["user"] . " attempted to delete data of " . $transfer; AuditAction($cfg["constants"]["error"], $msg); array_push($msgs, $msg); } } } else { $msg = "ILLEGAL DELETE: " . $cfg["user"] . " attempted to delete data of " . $transfer; AuditAction($cfg["constants"]["error"], $msg); array_push($msgs, $msg); } return $msgs; }
// Are we to delete something? if ($del != "") { $current = ""; // The following lines of code were suggested by Jody Steele jmlsteele@stfu.ca // this is so only the owner of the file(s) or admin can delete if (IsAdmin($cfg["user"]) || preg_match("/^" . $cfg["user"] . "/", $del)) { // Yes, then delete it // we need to strip slashes twice in some circumstances // Ex. If we are trying to delete test/tester's file/test.txt // $del will be "test/tester\\\'s file/test.txt" // one strip will give us "test/tester\'s file/test.txt // the second strip will give us the correct // "test/tester's file/test.txt" $del = stripslashes(stripslashes($del)); if (!ereg("(\\.\\.\\/)", $del)) { avddelete($cfg["path"] . $del); $arTemp = explode("/", $del); if (count($arTemp) > 1) { array_pop($arTemp); $current = implode("/", $arTemp); } AuditAction($cfg["constants"]["fm_delete"], $del); } else { AuditAction($cfg["constants"]["error"], "ILLEGAL DELETE: " . $cfg['user'] . " tried to delete " . $del); } } else { AuditAction($cfg["constants"]["error"], "ILLEGAL DELETE: " . $cfg['user'] . " tried to delete " . $del); } header("Location: dir.php?dir=" . urlencode($current)); } // Are we to download something?
function delFile($del) { global $cfg; if (IsAdmin($cfg["user"]) || preg_match("/^" . $cfg["user"] . "/", $del)) { // Yes, then delete it // we need to strip slashes twice in some circumstances // Ex. If we are trying to delete test/tester's file/test.txt // $del will be "test/tester\\\'s file/test.txt" // one strip will give us "test/tester\'s file/test.txt // the second strip will give us the correct // "test/tester's file/test.txt" $del = stripslashes(stripslashes($del)); if (!ereg("(\\.\\.\\/)", $del)) { avddelete($cfg["path"] . $del); $arTemp = explode("/", $del); if (count($arTemp) > 1) { array_pop($arTemp); $current = implode("/", $arTemp); } AuditAction($cfg["constants"]["fm_delete"], $del); } else { AuditAction($cfg["constants"]["error"], "ILLEGAL DELETE: " . $cfg['user'] . " tried to delete " . $del); } } else { AuditAction($cfg["constants"]["error"], "ILLEGAL DELETE: " . $cfg['user'] . " tried to delete " . $del); } }