📁 Folder Navigator
Position:
Root
/
apphome
/
content
/
socialmedia
Create
Folders
📁 chats
Rename
Copy
Delete
📁 contentuploads
Rename
Copy
Delete
📁 studio
Rename
Copy
Delete
Files
📄 .htaccess
📄 .user.ini
📄 auto_purge.php
📄 clean_xml.php
📄 contentplus.xml
📄 error_log
📄 index.php
📄 index2.php
📄 mychats.php
📄 post_content.php
📄 purge_chat.php
📄 purge_post.php
📄 space.php
📄 stats.json
📝 File Editor
Editing:
mychats.php
<?php session_start(); // Define your master files paths $xmlFile = '../../admin/access/vidkeys/masterusers.xml'; $chatsFolder = 'chats/'; // Ensure your chats directory exists on the server disk if (!is_dir($chatsFolder)) { mkdir($chatsFolder, 0755, true); } // 1. GATEKEEPER VALIDATION: Grab the session ID and look it up in the XML $userId = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : ''; $isUserValid = false; if (!empty($userId) && file_exists($xmlFile)) { $xml = simplexml_load_file($xmlFile); if ($xml) { foreach ($xml->user as $user) { if (isset($user->virtual_id) && (string)$user->virtual_id === $userId) { $isUserValid = true; // Found them! The session ID is matching a real virtual_id break; } } } } // Kick them out instantly if they aren't listed in the masterusers.xml if (!$isUserValid) { session_destroy(); header("Location: index2.php?error=unauthorized"); exit; } // 2. NAME THE CHAT FILE WITH THEIR EXCLUSIVE VID // This names files exactly like: "chats/chat_1777053907.txt" $chatFile = $chatsFolder . "chat_" . $userId . ".txt"; // 3. HANDLE NEW MESSAGE SUBMISSIONS if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) { $msg = trim(strip_tags($_POST['message'])); if (!empty($msg)) { $timestamp = date("H:i"); $formattedMsg = "[" . $timestamp . "] " . $userId . ": " . $msg . "\n"; // Append text to their specific chat file safely file_put_contents($chatFile, $formattedMsg, FILE_APPEND | LOCK_EX); } header("Location: mychats.php"); exit; } // 4. READ CURRENT CHAT STREAM HISTORY FOR VIEWPORT DISPLAY $chatHistory = ""; if (file_exists($chatFile)) { $chatHistory = htmlspecialchars(file_get_contents($chatFile)); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Secure Personal Chat</title> <style> body { font-family: Arial, sans-serif; background: #0f172a; color: #fff; padding: 20px; display: flex; justify-content: center; } .chat-container { width: 100%; max-width: 500px; background: #1e293b; padding: 20px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.3); border: 1px solid #334155; } .header { display: flex; justify-content: space-between; align-items: center; borderbottom: 1px solid #334155; padding-bottom: 10px; margin-bottom: 15px; } .user-tag { background: #2563eb; padding: 4px 12px; border-radius: 20px; font-size: 0.85rem; font-weight: bold; } textarea { width: 100%; height: 250px; background: #0f172a; color: #10b981; fontfamily: monospace; border: 1px solid #334155; border-radius: 6px; padding: 10px; resize: none; box-sizing: border-box; font-size: 0.95rem; } form { display: flex; gap: 10px; margin-top: 15px; } input[type="text"] { flex: 1; padding: 12px; background: #0f172a; border: 1px solid #334155; border-radius: 6px; color: #fff; font-size: 1rem; } button { background: #10b981; color: #fff; border: none; padding: 0 20px; borderradius: 6px; font-weight: bold; cursor: pointer; } </style> </head> <body> <div class="chat-container"> <div class="header"> <h3>💬 Secure Chat Console</h3> <span class="user-tag"><?php echo htmlspecialchars($userId); ?></span> </div> <textarea id="chatLog" readonly><?php echo $chatHistory; ?></textarea> <form action="mychats.php" method="POST"> <input type="text" name="message" placeholder="Type a message..." required autocomplete="off" autofocus> <button type="submit">Send</button> </form> </div> <script> const chatLog = document.getElementById('chatLog'); if (chatLog) { chatLog.scrollTop = chatLog.scrollHeight; } </script> </body> </html>
💾 Save Changes