Create a Messenger with a Single AI Prompt 1. Project: A web system for sending, receiving, and managing text messages. 2. Objective: Create a three-page web application (PHP, JavaScript, HTML) with functionality for sending, server-side processing, and viewing text data through file system interaction. 3. Functional Requirements: 3.1. Send Page (send.php): Interface Elements: Text field (textarea) for entering a message. Hard limit on the length of entered text on the client side: 120 characters. Real-time character counter indicator (format: X/120). Send button with the text "Send Message." Client-side Logic (JavaScript): Message length validation before sending. Asynchronous data sending (POST request) to a remote script http://mysite.com/page.php. After sending, clear the input field and reset the counter. Server-side logic (PHP in save_count.php): Get the number of characters in the sent message. Create (if it doesn't exist) or completely overwrite the file count.txt in the current directory. Write a string representation of the number of characters sent to count.txt. Set access rights for the created file: read and write (0666). Return the operation status (JSON). 3.2. Server-side processing script (page.php): Input data: Text message received via the POST method. Output data: Text response "Data saved" (success) or "Data Not Saved" (error). Main workflow: Writing a message: The received message is completely overwritten in the messages.txt file. If the file doesn't exist, it is created with permissions 0666. The number of characters written is counted. Working with the aggregate counter: Read the current value from the received.txt file into the $cnt variable. If the file does not exist, create it with permissions 0666, write the value 0, and assign $cnt = 0. Updating the counter: The number of characters written in step 1 is added to the $cnt value. The new $cnt value is completely overwritten in the received.txt file. Error handling: If any input/output error occurs, the script should return the "Data Not Saved" status. 3.3. View and control page (view.php): Style: Should match the design of the send.php page. Interface elements: Area (e.g., textarea) for displaying the contents of the messages.txt file. File information panel (path, size, modification time, access rights). View/Edit mode switch. A set of control buttons: "Refresh," "Save," "Copy to Clipboard," "Clear," and "Download." Character count indicator. System message display area. Navigation links to other system pages. Functionality: Data Loading: Asynchronously read and display the current contents of messages.txt when the page loads. Editing: In editing mode, the user can change the text in the input field. The "Save" button becomes active only when changes have been made. Saving: Asynchronously send the changed content to the server to completely overwrite the messages.txt file and update the associated counter in received.txt. Auxiliary Functions: Copy content to the clipboard, download a file, clear the input field. Validation: Visual warning when the 120-character limit is exceeded. 4. General Technical Requirements: Security and Reliability: All file read/write operations must explicitly open and close file descriptors. Mandatory handling and logging of possible errors (missing files, access rights issues, I/O failures). Input data validation on both the client and server sides. Architecture: Uses asynchronous requests (Fetch API) for interaction between the client and server without page reloads. Clear separation of concerns: HTML/PHP for markup and primary logic, JavaScript for interactivity. File Handling: All .txt files (count.txt, messages.txt, received.txt) contain only text data. Permissions for created files must be explicitly set to read and write (0666). 5. Additional Components (implemented): get_messages.php — helper API endpoint for securely reading the contents of messages.txt. update_messages.php — helper API endpoint for securely writing to messages.txt and updating received.txt. index.php — the system's central index page with navigation and file status. (c) by Valery Shmelev https://github.com/vallshmeleff/oflameron-obfuscation-language https://t.me/llmsource/