📁 Folder Navigator
Position:
Root
/
apphome
/
network
/
clients
Create
Folders
📁 chats
Rename
Copy
Delete
📁 studio
Rename
Copy
Delete
📁 uploads
Rename
Copy
Delete
Files
📄 admindir.php
📄 chat_history.txt
📄 dir.php
📄 displaychat.php
📄 index.php
📄 mychats.php
📄 purge_chat.php22
📄 users.xml
📝 File Editor
Editing:
admindir.php
<?php $file = 'users.xml'; // Initialize file with root element if it doesn't exist if (!file_exists($file)) { file_put_contents($file, '<?xml version="1.0" encoding="UTF-8"?><users></users>'); } $xml = simplexml_load_file($file); $search = $_GET['q'] ?? ''; $uploadDir = 'uploads/'; // Helper function to process file uploads safely function uploadMedia($fileKey, $allowedTypes) { global $uploadDir; if (!isset($_FILES[$fileKey]) || $_FILES[$fileKey]['error'] !== UPLOAD_ERR_OK) { return ''; } $fileName = time() . '_' . basename($_FILES[$fileKey]['name']); $targetPath = $uploadDir . $fileName; $fileType = strtolower(pathinfo($targetPath, PATHINFO_EXTENSION)); if (in_array($fileType, $allowedTypes)) { if (!is_dir($uploadDir)) { mkdir($uploadDir, 0777, true); } if (move_uploaded_file($_FILES[$fileKey]['tmp_name'], $targetPath)) { return $fileName; } } return ''; } // CREATE if (isset($_POST['add'])) { $photo = uploadMedia('photo', ['jpg', 'jpeg', 'png', 'gif']); $video = uploadMedia('video', ['mp4', 'webm', 'ogg']); $user = $xml->addChild('user'); $user->addAttribute('id', time()); $user->addChild('name', htmlspecialchars($_POST['name'])); $user->addChild('vid', htmlspecialchars($_POST['vid'])); $user->addChild('myapp', htmlspecialchars($_POST['myapp'])); $user->addChild('mesgs', htmlspecialchars($_POST['mesgs'])); $user->addChild('photo', $photo); $user->addChild('video', $video); $xml->asXML($file); header("Location: admindir.php"); exit; } // UPDATE if (isset($_POST['update'])) { foreach ($xml->user as $user) { if ($user['id'] == $_POST['id']) { $user->name = htmlspecialchars($_POST['name']); $user->vid = htmlspecialchars($_POST['vid']); } } $xml->asXML($file); header("Location: admindir.php"); exit; } // DELETE if (isset($_GET['delete'])) { $i = 0; foreach ($xml->user as $user) { if ($user['id'] == $_GET['delete']) { if (!empty($user->photo) && file_exists($uploadDir . $user->photo)) @unlink($uploadDir . $user->photo); if (!empty($user->video) && file_exists($uploadDir . $user->video)) @unlink($uploadDir . $user->video); unset($xml->user[$i]); break; } $i++; } $xml->asXML($file); header("Location: admindir.php"); exit; } ?> <!DOCTYPE html> <html> <head> <title>MY NETWORK</title> <style> .box { padding: 5px 10px; border: 1px solid #444; border-radius: 3px; background: #222; opacity: 1; transition: 0.2s; cursor: pointer; font-weight: bold; font-size: 11px; text-transform: uppercase; color: #00ff00; border-color: #00ff00; } .box:hover { background: #333; } body { font-family: Arial, sans-serif; margin: 10px; background-color:white; background-image: url('uploads/backroundimage.jpg'); /* The path to your photo */ } table { width: 100%; border-collapse: collapse; margin-top: 10px; } th, td { font-size:7px; width:0px; padding:2px;background: ;height:0px; text-align: center; } .media-preview { max-width: 70px; max-height: 100px; object-fit: curtain; display: block; border-radius: 2px; } .video-preview { width: 100px; max-height: 100px; display: block; border-radius: 2px; } /* Action header styles */ .top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; } /* Hidden Form Container Styling */ #formContainer { display: block; background: #f9f9f9; padding: 2px; border: 1px solid #ddd; border-radius: 5px; margin-bottom: 10px; } .form-group { margin-bottom: 5px; } .form-group label { display: inline-block; width: 20px; } /* Button UI */ .btn { padding: 2px 4px; cursor: pointer; border: 0 solid #ccc; border-radius: 2px; background: #f0f0f0; } .btn-add { background: #28a745; color: white; border-color: #28a745; font-weight: bold; } .btn-search { background: #007bff; color: white; border-color: #007bff; } </style> </head> <body> <div> <button type="button" class="btn btn-add" onclick="toggleForm()">➕ CLICK 2 ADD/CLICK 2 CLOSE</button> <br><a class="bt" font-size: 50px; href="../mychats.php" target="iframe_bb">CHAT NOW</a></div> <h2>MY NETWORK PORTAL </h2> <!-- TOP BAR WITH SEARCH AND TOGGLE BUTTON --> <div class="top-bar"> <!-- SEARCH FORM --> <form method="GET"> <input type="text" name="q" value="<?= htmlspecialchars($search) ?>" placeholder="Search name,my app, or virtualid..." style="padding: 5px;"> <button type="submit" class="btn btn-search">Search</button> <?php if ($search !== ''): ?><a href="admindir.php" style="margin-left: 5px;">Clear</a><?php endif; ?> </form> <!-- TOGGLE BUTTON --> </div> <!-- ADD NEW USER FORM (Hidden by default) --> <div id="formContainer" > <h3>ADD YOUR PROFILE </h3> <form method="POST" enctype="multipart/form-data" > <div class="form-group"> <label><b>Name:<b></label><br> <input type="text" name="name" required> </div> <div class="form-group"> <label><b>VirtualID:<b></label><br> <input type="text" name="vid" required> </div> <div class="form-group"> <label><b>MyApp:</label><br> <text>(Add your app address.)</text><br> <input type="text" name="myapp" > </div> <div class="form-group"> <label><b>Message:</label><br> <text>(Add Message)</text><br> <textarea type="text" name=" mesgs" ></textarea> </div> <div class="form-group"> <label><b>Photo:<b></label><br> <input type="file" name="photo" accept="image/*"> <br><text>(Select photo from your device <br>or use studio below to take photo to upload. )</text> </div> <div class="form-group"> <div class="form-group"> <label><b>Video:<b></label><br> <text>(Select recording from your device or use studio below <br>,to record a new video to upload. )</text><br> <input type="file" name="video" accept="video/*" > </div> </div> <label><b>RECORDING STUDIO<b></label><br> <text>(Record here first ,upload new recording,then hit the submit button) </text><br><br> <div class="form-group"> <iframe class="" allow="camera *;microphone *" autoplay class="" src="studio/record.html" crossorigin="allowed" name="iframe_bb" style="width:40%; font-size: 2px; background:; color:white; height:350px; border: 1px solid red;" title="nav"></iframe> </div> <button type="submit" name="add" class="btn btn-add">Submit</button> <button type="button" class="btn" onclick="toggleForm()">Cancel</button> </form> </div> <!-- READ, UPDATE & DELETE TABLE --> <table border="1" id="formContainer" hidden> <thead style="background: #f2f2f2;"> <tr> <th >Photo</th> <th>Video</th> <th>Name</th> <th>Virtual-ID</th> <th>MYAPP</th> <th>Message</th> <th>Actions</th> </tr> </thead> <tbody> <?php $hasRows = false; foreach ($xml->user as $user): if ($search !== '' && strpos(strtolower($user->name), strtolower($search)) === false && strpos(strtolower($user->vid), strtolower($search)) === false && strpos(strtolower($user->myapp), strtolower($search)) === false) { continue; } $hasRows = true; ?> <tr> <form method="POST"> <!-- INLINE PHOTO DISPLAY --> <td> <?php if (!empty($user->photo) && file_exists($uploadDir . $user->photo)): ?> <img src="<?= $uploadDir . $user->photo ?>" class="media-preview" alt="User Photo"> <?php else: ?> <small style="color: #999;">No Photo</small> <?php endif; ?> </td> <!-- INLINE VIDEO DISPLAY --> <td> <?php if (!empty($user->video) && file_exists($uploadDir . $user->video)): ?> <video src="<?= $uploadDir . $user->video ?>" class="video-preview" controls muted></video> <?php else: ?> <small style="color: #999;">No Video</small> <?php endif; ?> </td> <td><input type="text" name="name" value="<?= htmlspecialchars($user->name) ?>" style="padding: 4px; width: 50px;" readonly></td> <td><input type="text" name="vid" value="<?= htmlspecialchars($user->vid) ?>" style="padding: 4px; width: 30px;" readonly></td> <td><input type="text" name="myapp" value="<?= htmlspecialchars($user->myapp) ?>" style="padding: 4px; width: 120px;" ></td> <td> <input type="text" name="mesgs" value="<?= htmlspecialchars($user->mesgs) ?>" style="padding: 0px; width: 100px; ; " > </td> <td> <input type="hidden" name="id" value="<?= $user['id'] ?>" readonly> <a href="admindir.php?delete=<?= $user['id'] ?>" class="bt" style="background: #dc3545; color: white; border-color: #dc3545; text-decoration: none; padding: 2px 2px; font-size: 6px;" onclick="return confirm('Delete user permanently?')">Delete</a> </td> </form> </tr> <?php endforeach; ?> <?php if (!$hasRows): ?> <tr> <td colspan="6" style="text-align: center; color: #666; padding: 20px;">No users found.</td> </tr> <?php endif; ?> </tbody> </table> <!-- JAVASCRIPT FOR TOGGLE EFFECT --> <script> // This event keeps the table closed on page entry instantly document.addEventListener("DOMContentLoaded", function() { var form = document.getElementById("formContainer"); if (form) { form.style.display = "none"; } }); function toggleForm() { var form = document.getElementById("formContainer"); if (!form) return; // Prevents the button click from breaking if it can't find the table if (form.style.display === "none") { form.style.display = "table"; } else { form.style.display = "none"; } } </script> </body> </html>
💾 Save Changes