-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor remove.php and moderation.js scripts
- Loading branch information
Showing
3 changed files
with
29 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,31 @@ | ||
<?php | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', 1); | ||
|
||
include_once(dirname(__FILE__) . "/secrets.php"); | ||
|
||
if (!isset($_POST['adminPassword'], $_POST['mediaPath'])) { | ||
echo json_encode(['error' => 'Missing required parameters.']); | ||
exit(); | ||
} | ||
|
||
$adminPassword = $_POST['adminPassword']; | ||
$mediaPath = $_POST['mediaPath']; | ||
$mediaPath = dirname(__FILE__) . "/../" . $_POST['mediaPath']; | ||
|
||
if($adminPassword !== ADMIN_PASSWORD){ | ||
if ($adminPassword !== ADMIN_PASSWORD) { | ||
echo json_encode(['error' => 'Unauthorized']); | ||
exit(); | ||
} | ||
|
||
if(unlink($mediaPath)){ | ||
if (!file_exists($mediaPath)) { | ||
echo json_encode(['error' => 'Media file does not exist.']); | ||
exit(); | ||
} | ||
|
||
}else{ | ||
if (unlink($mediaPath)) { | ||
echo json_encode(['success' => 'Media removed successfully.']); | ||
} else { | ||
echo json_encode(['error' => 'Error while removing media.']); | ||
exit(); | ||
} | ||
?> | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters