<?php $this->xinclude('partials/header'); ?>

<?php if(System\Session::exists('success')): ?>
    <div class="home-error-wrap">
        <div class="alert alert-success view-success">
          <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
          <h1><i class="fa fa-check" aria-hidden="true"></i>
          &nbsp; <?php echo System\Session::flash('success'); ?></h1>
        </div>
    </div><br/>
<?php endif; ?>

<div class="edit-links-wrapper">
    <h1 class="register-title">Bypass Protection Manager</h1>
    <p style="color:#888;margin-bottom:20px;">Enable protection on specific users — their links will require Cloudflare CAPTCHA verification.</p>
    <div class="tab-content home-content">
        <table class="table table-bordered table-hover">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Username</th>
                    <th>Email</th>
                    <th>Status</th>
                    <th>Protection</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($this->users as $u): ?>
                <tr>
                    <td><?php echo $u->id; ?></td>
                    <td><?php echo htmlspecialchars($u->username); ?></td>
                    <td><?php echo htmlspecialchars($u->email); ?></td>
                    <td>
                        <?php if($u->status === 'active'): ?>
                            <span style="color:green;font-weight:bold;">Active</span>
                        <?php else: ?>
                            <span style="color:red;font-weight:bold;">Inactive</span>
                        <?php endif; ?>
                    </td>
                    <td>
                        <?php if($u->bypass_protect === 'yes'): ?>
                            <span style="color:green;font-weight:bold;"><i class="fa fa-shield"></i> ON</span>
                        <?php else: ?>
                            <span style="color:#aaa;"><i class="fa fa-times"></i> OFF</span>
                        <?php endif; ?>
                    </td>
                    <td>
                        <form method="post" action="" style="display:inline;">
                            <input type="hidden" name="toggle[id]" value="<?php echo $u->id; ?>">
                            <?php if($u->bypass_protect === 'yes'): ?>
                                <input type="hidden" name="toggle[value]" value="no">
                                <button type="submit" class="btn btn-danger btn-sm">Turn OFF</button>
                            <?php else: ?>
                                <input type="hidden" name="toggle[value]" value="yes">
                                <button type="submit" class="btn btn-success btn-sm">Turn ON</button>
                            <?php endif; ?>
                        </form>
                    </td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>

<?php $this->xinclude('partials/footer'); ?>
