System: You are a professional software developer with expertise in PHP, Python, and JavaScript. When users ask for coding help:

Respond with clear, well-commented code examples tailored to both entry-level developers and those with 10+ years of experience.
Provide complete code files when initiating solutions, emphasizing readability and best practices.
Encourage incremental learning by offering explanations alongside the code.
When a user highlights an error, scan the recent chat history to identify relevant code segments and suggest corrections specific to the issue without resending the entire code, unless necessary.
Leverage your comprehensive knowledge base to address issues as if searching the internet for the latest techniques and solutions, given current limitations.
Strive to make your explanations as accessible as possible while respecting the expertise level of different users.
Emphasize debugging strategies and tools entry-level developers might use to better understand problem-solving processes.
Remember, the goal is to help the user become a more competent and confident programmer, whatever their experience level.
User: EPG Project.
We have an epg project are you ready to dive in?
Assistant: Absolutely, I'm ready to help with your EPG (Electronic Program Guide) project. Whether you're looking to build features from scratch, debug existing code, or improve your current implementation, I'm here to assist. Please provide more details on what specifically you'd like help with in your EPG project. This could include anything from setting up the initial architecture, parsing data, displaying the guide in a web application, or optimizing the existing code.
User: Perfect, Here is how it will work.

We have xml files of EPG in ../data/epg/xxx.xml (where xx is country code i.e: USA.xml UK.xml)

Now we have to create a simple responsive webui to for our website that will show users that we have best EPG in world with a header containing .,
Home, Pricing, Channels, API, Support.

We will include header everytime from include header.php in all pages.
for api page we have a markdown file i.e API.md we can use that and render that in api.php with exesting header, and below that code.
Also make sur we will use 1 stylesheet for everything i.e main.css and if any JS required will be main.jss that will call in header.

Also in header show a DARK/LIGHT mode option so users can switch to darkmode willl work on all pages.

For channels we have a file a channels in ../data/channels.txt 
in channels.txt show channels from channels.txt 
channel formate 
Channel Name;Country
Also for channels show a search box above channels list so we can search for channels using js.

Pricing show 3 pricing models 
Monthly, Quartaly, Annuall with some descriptiona and Order now button.

(Later will will create checkout.php file so it will checkout.php?type=order&id=1&term=30


Assistant: Let's break down your EPG project requirements and draft a basic skeleton to get you started. This will include the HTML structure, a basic PHP setup, and placeholder CSS and JavaScript for the functionality you described.

### Step 1: Project Structure

Create the following directory structure for your project:

```
/my_epg_project
    /data
        /epg
            USA.xml
            UK.xml
        channels.txt
    /include
        header.php
    /css
        main.css
    /js
        main.js
    index.php
    pricing.php
    channels.php
    api.php
```

### Step 2: Header.php

Create a reusable `header.php` file that includes navigation and a dark/light mode toggle.

```php
<!-- /include/header.php -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>EPG Project</title>
    <link rel="stylesheet" href="/css/main.css">
    <script src="/js/main.js" defer></script>
</head>
<body>
    <header>
        <nav>
            <ul>
                <li><a href="/index.php">Home</a></li>
                <li><a href="/pricing.php">Pricing</a></li>
                <li><a href="/channels.php">Channels</a></li>
                <li><a href="/api.php">API</a></li>
                <li><a href="/support.php">Support</a></li>
            </ul>
            <div class="theme-toggle">
                <label for="theme-switch">Dark Mode</label>
                <input type="checkbox" id="theme-switch">
            </div>
        </nav>
    </header>
    <main>
```

### Step 3: Main Pages

Each main page will include the header and have individual content.

- **Index.php (Home Page Example)**

```php
<!-- /index.php -->
<?php include 'include/header.php'; ?>
<h1>Welcome to the Best EPG in the World!</h1>
<p>Explore our features and enjoy a personalized viewing experience.</p>
</main>
<?php include 'include/footer.php'; ?>
```

- **API.md Rendering in api.php**

```php
<!-- /api.php -->
<?php include 'include/header.php'; ?>
<div class="api-content">
    <?php echo markdownToHtml('../data/API.md'); ?>
</div>
</main>
<?php include 'include/footer.php'; ?>

<?php
function markdownToHtml($filepath) {
    $markdown = file_get_contents($filepath);
    // Simple Markdown to HTML conversion (using a library would be better here)
    $html = '<p>' . str_replace("\n", '</p><p>', $markdown) . '</p>';
    return $html;
}
?>
```

- **Channels Display in channels.php**

```php
<!-- /channels.php -->
<?php include 'include/header.php'; ?>
<h2>Channels</h2>
<input type="text" id="channel-search" placeholder="Search Channels">

<ul id="channel-list">
    <?php
    $channels = file('../data/channels.txt', FILE_IGNORE_NEW_LINES);
    foreach ($channels as $channel) {
        list($name, $country) = explode(';', $channel);
        echo "<li data-channel-name=\"$name\">$name - $country</li>";
    }
    ?>
</ul>
</main>
<?php include 'include/footer.php'; ?>
```

- **Pricing Details in pricing.php**

```php
<!-- /pricing.php -->
<?php include 'include/header.php'; ?>
<h2>Pricing</h2>
<div class="pricing-options">
    <div class="pricing-model">
        <h3>Monthly</h3>
        <p>Description of the monthly plan.</p>
        <button onclick="location.href='/checkout.php?type=order&id=1&term=30'">Order Now</button>
    </div>
    <div class="pricing-model">
        <h3>Quarterly</h3>
        <p>Description of the quarterly plan.</p>
        <button onclick="location.href='/checkout.php?type=order&id=2&term=90'">Order Now</button>
    </div>
    <div class="pricing-model">
        <h3>Annual</h3>
        <p>Description of the annual plan.</p>
        <button onclick="location.href='/checkout.php?type=order&id=3&term=365'">Order Now</button>
    </div>
</div>
</main>
<?php include 'include/footer.php'; ?>
```

### Step 4: JavaScript and CSS

- **main.js**: for the theme toggle and channel search functionality.

```javascript
// /js/main.js
document.addEventListener('DOMContentLoaded', function() {
    const themeSwitch = document.getElementById('theme-switch');
    const body = document.body;
    const channelSearch = document.getElementById('channel-search');
    const channelList = document.getElementById('channel-list');

    themeSwitch.addEventListener('change', function() {
        body.classList.toggle('dark-mode', themeSwitch.checked);
    });

    channelSearch.addEventListener('keyup', function() {
        const searchTerm = channelSearch.value.toLowerCase();
        const channels = channelList.getElementsByTagName('li');
        
        Array.from(channels).forEach(function(channel) {
            const channelName = channel.dataset.channelName.toLowerCase();
            channel.style.display = channelName.includes(searchTerm) ? '' : 'none';
        });
    });
});
```

- **main.css**: for styling the dark mode and responsive layout.

```css
/* /css/main.css */
body {
    font-family: Arial, sans-serif;
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}

header {
    background-color: #f8f9fa;
    padding: 10px;
}

header.dark-mode {
    background-color: #333;
}

header nav ul {
    list-style-type: none;
    display: flex;
    gap: 15px;
}

main {
    margin: 20px;
}

.theme-toggle {
    margin-left: auto;
}

.pricing-options {
    display: flex;
    gap: 20px;
    justify-content: space-around;
}

.pricing-model {
    border: 1px solid #ccc;
    padding: 20px;
    border-radius: 8px;
    min-width: 150px;
    text-align: center;
}

.pricing-model button {
    margin-top: 10px;
}

@media (max-width: 600px) {
    .pricing-options {
        flex-direction: column;
        align-items: center;
    }
}
```

### Explanation and Next Steps

**Explanation**: This setup is a basic framework that includes a header with navigation, a toggle for dark/light mode, and separate PHP pages for different functionalities like channel browsing and pricing plans. It uses simple PHP and JavaScript solutions to render markdown content and to search channels dynamically.

**Next Steps**:
1. Implement the `checkout.php` page to handle the ordering process.
2. Use a more robust markdown library for better markdown to HTML conversion.
3. Enhance the CSS for more sophisticated design according to your branding guidelines.
4. Consider adding server-side scripting to handle EPG data from XML files if needed.

This should provide a solid foundation to build upon. Feel free to ask further questions or for clarifications on any part!
User: Perfect now lets build admin.php 

Where admin can login with $username $password .
Then admin can see a table of users.

id: Name: Contact: Payment: IP: Valid: Action.

---------------------------------------------------
In admin header add Menu ADD USER.

/// Add user.
We can add users and will be saved in json with below details.
id;name;contact;ip;payment;trxid;date;status;valid

id will be like autoincrement.
name we will add a name.
contact: we will add 
ip: we will add
payment: Amount paid by user.s
trxid: Transaction ID;
date: payment date
status:can be only, valid or expired or revoked or fruad
valid: date when it will be expired.

// Edit user > 
In table Under action we will have 2 options.
EDIT USER | BAN USER,
Ban user: Click on that will change the status of that user to revoked.

EDIT: So we can edit users dropdown for status, date picker for date and dropdown for valid , 1 month , 2 month , 3 month, 6 month 12 month.
Choosing month will add expiry date based on days choose from creating date.


Save in ../data/users.json 

Assistant: