<?php
// IV1 WP Tools – Virus Scanner Tab
defined('ABSPATH') || exit;

$iv1wpt_has_pro = iv1wpt_has_pro();

$ignorelist = get_option(IV1WPT_VIRUS_SCANNER_IGNORELIST_OPTION, '');
?>
<div class="card">
    <h2>🛡️ <?php esc_html_e('Virus Scanner', 'iv1-wp-tools'); ?></h2>
    <p>
        <?php esc_html_e('Scans WordPress files and the database for known malware patterns, suspicious code, and injected content.', 'iv1-wp-tools'); ?>
    </p>

    <?php /* ── Signatur-Scan ── */ ?>
    <h3><?php esc_html_e('Signature Scan (Files)', 'iv1-wp-tools'); ?></h3>
    <p><?php esc_html_e('Scans PHP, JS and HTML files for known malware signatures: obfuscated code, shell backdoors, hidden iframes, and more.', 'iv1-wp-tools'); ?></p>

    <p>
        <label for="iv1wpt-vs-scope"><strong><?php esc_html_e('Scan scope:', 'iv1-wp-tools'); ?></strong></label>
        <select id="iv1wpt-vs-scope" <?php disabled(!$iv1wpt_has_pro); ?>>
            <option value="full"><?php esc_html_e('Complete installation', 'iv1-wp-tools'); ?></option>
            <option value="plugins"><?php esc_html_e('Plugins only', 'iv1-wp-tools'); ?></option>
            <option value="themes"><?php esc_html_e('Themes only', 'iv1-wp-tools'); ?></option>
            <option value="uploads"><?php esc_html_e('Upload directory only', 'iv1-wp-tools'); ?></option>
            <option value="core"><?php esc_html_e('WordPress core only', 'iv1-wp-tools'); ?></option>
        </select>
        &nbsp;
        <button type="button" class="button button-primary" id="iv1wpt-vs-scan-files" <?php disabled(!$iv1wpt_has_pro); ?>>
			<?php echo !$iv1wpt_has_pro ? '🔒 ' : ''; ?>
            <?php esc_html_e('Start file scan', 'iv1-wp-tools'); ?>
        </button>
    </p>
    <div id="iv1wpt-vs-files-result"></div>
</div>

<div class="card" style="margin-top:16px;">
    <?php /* ── Upload-Verzeichnis ── */ ?>
    <h3><?php esc_html_e('Suspicious Files in Upload Directory', 'iv1-wp-tools'); ?></h3>
    <p><?php esc_html_e('Detects executable files (PHP, ASP, Shell scripts, etc.) that should not exist in the upload directory.', 'iv1-wp-tools'); ?></p>
    <p>
        <button type="button" class="button button-primary" id="iv1wpt-vs-scan-uploads" <?php disabled(!$iv1wpt_has_pro); ?>>
			<?php echo !$iv1wpt_has_pro ? '🔒 ' : ''; ?>
            <?php esc_html_e('Scan upload directory', 'iv1-wp-tools'); ?>
        </button>
    </p>
    <div id="iv1wpt-vs-uploads-result"></div>
</div>

<div class="card" style="margin-top:16px;">
    <?php /* ── Datenbank-Scan ── */ ?>
    <h3><?php esc_html_e('Database Scan', 'iv1-wp-tools'); ?></h3>
    <p><?php esc_html_e('Checks posts, comments, options and user meta for injected code, spam links, pharma hacks and obfuscated JavaScript.', 'iv1-wp-tools'); ?></p>
    <p>
        <button type="button" class="button button-primary" id="iv1wpt-vs-scan-db" <?php disabled(!$iv1wpt_has_pro); ?>>
			<?php echo !$iv1wpt_has_pro ? '🔒 ' : ''; ?>
            <?php esc_html_e('Start database scan', 'iv1-wp-tools'); ?>
        </button>
    </p>
    <div id="iv1wpt-vs-db-result"></div>
</div>

<div class="card" style="margin-top:16px;">
    <?php /* ── Einstellungen ── */ ?>
    <h3><?php esc_html_e('Scanner Settings', 'iv1-wp-tools'); ?></h3>

    <table class="main-form-table">
        <tr>
            <th><?php esc_html_e('Ignore list', 'iv1-wp-tools'); ?></th>
            <td>
                <textarea id="iv1wpt-vs-ignorelist" rows="6" style="width:100%;font-family:monospace;font-size:12px;"
                    placeholder="# <?php esc_attr_e('One path per line, # = comment', 'iv1-wp-tools'); ?>&#10;wp-content/plugins/my-plugin/vendor/&#10;wp-content/themes/my-theme/assets/"
                ><?php echo esc_textarea($ignorelist); ?></textarea>
                <p class="description"><?php esc_html_e('One path per line (relative to WordPress root). Lines starting with # are comments. Paths can be files or directories.', 'iv1-wp-tools'); ?></p>
            </td>
        </tr>
    </table>

    <p>
        <button type="button" class="button button-primary" id="iv1wpt-vs-save-settings" <?php disabled(!$iv1wpt_has_pro); ?>>
			<?php echo !$iv1wpt_has_pro ? '🔒 ' : ''; ?>
            <?php esc_html_e('Save settings', 'iv1-wp-tools'); ?>
        </button>
    </p>
    <div id="iv1wpt-vs-settings-result"></div>
</div>


<?php /* ── Datei-Inhalt Modal ── */ ?>
<div id="iv1wpt-vs-modal" class="iv1wpt-modal-overlay iv1wpt-vs-modal-overlay">
    <div class="iv1wpt-vs-modal-box">
        <div class="iv1wpt-vs-modal-header">
            <span id="iv1wpt-vs-modal-title" class="iv1wpt-vs-modal-title"></span>
            <button id="iv1wpt-vs-modal-close" class="iv1wpt-vs-modal-close">&times;</button>
        </div>
        <div id="iv1wpt-vs-modal-meta" class="iv1wpt-vs-modal-meta"></div>
        <pre id="iv1wpt-vs-modal-code" class="iv1wpt-vs-modal-code"></pre>
        <div class="iv1wpt-vs-modal-footer">
            <button id="iv1wpt-vs-modal-delete" class="button button-danger">
				<?php esc_html_e('Delete file', 'iv1-wp-tools'); ?>
            </button>
            <span id="iv1wpt-vs-modal-delete-status" class="iv1wpt-vs-modal-delete-status"></span>
        </div>
    </div>
</div>

<?php /* ── Datenbank-Datensätze Modal ── */ ?>
<div id="iv1wpt-vs-db-modal" class="iv1wpt-modal-overlay iv1wpt-vs-modal-overlay">
    <div class="iv1wpt-vs-modal-box iv1wpt-vs-modal-box--wide">
        <div class="iv1wpt-vs-modal-header">
            <span id="iv1wpt-vs-db-modal-title" class="iv1wpt-vs-modal-title"></span>
            <button id="iv1wpt-vs-db-modal-close" class="iv1wpt-vs-modal-close">&times;</button>
        </div>
        <div id="iv1wpt-vs-db-modal-meta" class="iv1wpt-vs-modal-meta"></div>
        <div class="iv1wpt-vs-modal-body--scroll">
            <div id="iv1wpt-vs-db-modal-body"></div>
        </div>
    </div>
</div>
