afd - PHP Online
Form of PHP Sandbox
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of afd.php
- <?php
- // Nome do usuário fornecido pela query string
- $userName = isset($_GET['name']) ? $_GET['name'] : '';
- // Verifica se o nome de usuário foi fornecido
- if(empty($userName)) {
- die("");
- }
- // Lê o conteúdo do arquivo JSON
- $jsonData = file_get_contents('db.json');
- // Decodifica o JSON para um array associativo
- $userData = json_decode($jsonData, true);
- // Verifica se o nome de usuário existe no arquivo JSON
- if(!isset($userData[$userName])) {
- die("");
- }
- // Diretório onde os vídeos estão localizados
- $videoDirectory = 'videos/';
- // Lista todos os arquivos no diretório de vídeos
- $videoFiles = scandir($videoDirectory);
- // Obtém a lista de vídeos permitidos para o usuário
- $allowedVideos = $userData[$userName]['videos'];
- echo "<h1>Welcome!</h1>";
- echo "<h1>You only have 7 days to download the videos</h1>";
- echo "To download the videos, just click on their name and the download will start.";
- echo "<br>";
- echo "If you want to purchase videos in other quantities or of other genres, our telegram: @MINHAPICAEXTREMAMENTEGRANDE";
- echo "<br>";
- echo "<br>";
- echo "<br>";
- echo "Videos:<br><br>";
- // Exibe apenas os vídeos permitidos para o usuário na página
- foreach($videoFiles as $videoFile) {
- if($videoFile != '.' && $videoFile != '..') {
- // Remove a extensão do nome do arquivo
- $videoName = pathinfo($videoFile, PATHINFO_FILENAME);
- if(in_array($videoName, $allowedVideos)) {
- // Link para o script intermediário que lida com o download
- echo "<a href='download.php?video=$videoFile&name=$userName'>$videoName</a><br>";
- }
- }
- }
- ?>