if ($_FILES["file"]["error"] == 4) { echo "Error: Please select a torrent file"; } else { echo "Error: " . $_FILES["file"]["error"]; } } else { $fileName = str_replace(" ", "_", $_FILES["file"]["name"]); $tmpPath = $_FILES["file"]["tmp_name"]; $filePath = $uploadDir . "/" . $fileName; $fileType = $_FILES["file"]["type"]; if ($client->checkTorrentExt($fileName) || $client->checkFileType($fileType)) { if (file_exists($filePath)) { echo "Error: {$fileName} already exists"; } else { move_uploaded_file($tmpPath, $filePath); if (!$client->validateTorrentFile($filePath)) { echo "Error: Invalid torrent file"; } else { echo "Uploaded: {$fileName}"; } } } else { echo "Error: Invalid file type"; } } } ##### Upload File Validation ##### ##### Function ##### function display() { global $client;
<?php require_once "torrentClient.php"; $client = new torrentClient(); $client->getUploadDir(); $client->start(); echo $client->listScreen() . "\n"; echo $client->countTorrentFile(); echo $client->checkTorrentExt("HOBBIT:THE DESOLATION OF SMAUG.torrent"); echo $client->validateTorrentFile("/var/www/html/phoe721.com/project/bt/upload/test.torrent"); echo $client->validateTorrentFile("/var/www/html/phoe721.com/project/bt/upload/a"); echo $client->removeTorrentFile("/var/www/html/phoe721.com/project/bt/upload/a"); echo $client->checkFileType("application/x-bittorrent"); echo $client->checkFileType("application/abc"); $client->stop();