Create New Item
×
Item Type
File
Folder
Item Name
×
Search file in folder and subfolders...
File Manager
/
admin
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<link rel="stylesheet" href="assets/vendors/datatables.net-bs4/datatable.css"> <?php session_start(); include_once("header.php"); if(!isset($_SESSION["admin_id"])){ header("location: dashborad.php"); exit; } ?> <style> form#balance_form { width: 300px; margin: 0; } form#domain { width: 280px; margin: 0; } </style> <div class="row"> <div class="col-md-12"> <div class="card mb-4"> <?php include 'includes/marquee.php'; $id =4; $marquee = new Marquee($conn, $id); $marquee->display(); ?> </div> </div> <div class="container overflow-auto"> <div class="card my-3 py-4 px-2"> <table id="myTable" class="table table-striped table-hover"> <thead> <tr> <th>#</th> <th>Email</th> <th>Number</th> <th>Link</th> <th>Balance</th> <th>Status</th> <th>Delete</th> <th>Change Password</th> </tr> </thead> <tbody> <?php $user = $_SESSION["user_token"]; $sql = "SELECT * from users"; $result = $conn->query($sql); $cnt = 1; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $id = $row["id"]; $email = $row["email"]; $domain = $row["domain"]; $api_key = $row["api_key"]; $token = $row["token"]; $balance = $row["balance"]; $status = $row["status"]; $number = $row["mobile"]; ?> <tr> <td><?php echo $cnt;?></td> <td><?php echo $email;?></td> <td><?php echo $number;?></td> <td> <form action="pages/udpate_token.php" id="domain" method="post"> <div class="input-group"> <button type="button" class="btn btn-secondary" onclick="copyLink(event, this)">Copy Link</button> <input type="text" name="id" hidden value="<?php echo $id; ?>"> <input type="text" name="old_token" value="<?php echo $token; ?>" hidden class="form-control"> <input type="text" hidden name="hidden_link" class="hidden_link" value="<?php echo $_SERVER['HTTP_HOST']."/index.php?text_token=".$token; ?>"> <div class="input-group-append"> <button name="token_submit" onclick="return confirm('Do you want to regenerate token for <?php echo $email; ?>?');" type="submit" class="input-group-text text-secondary">Generate New</button> </div> </div> </form> </td> <td> <form id="balance_form" action="pages/balance_add.php" method="post"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text"><?php echo $balance;?></span> </div> <input type="number" name="balance" class="form-control" placeholder="Add Balance put here"> <input type="text" name="id" hidden value="<?php echo $id;?>"> <div class="input-group-append"> <button name="submit" onclick="return confirm('Do you want add Balance <?php echo $email; ?>');" type="submit" class="btn btn-secondary">Add</button> </div> </div> </form> </td> <td><?php if($status == 1){ ?> <a onclick="return confirm('Do you want deactive this user <?php echo $email; ?>');" href="pages/active_deactive.php?token=<?php echo $token; ?>&status=<?php echo $status; ?>"><button class="btn btn-success">Active</button></a> <?php }else{ ?> <a onclick="return confirm('Do you want active this user <?php echo $email; ?>');" href="pages/active_deactive.php?token=<?php echo $token; ?>&status=<?php echo $status; ?>"><button class="btn btn-danger">Active</button></a> <?php } ?></td> <td><a onclick="return confirm('Do you want Delete this user <?php echo $email; ?>');" href="pages/delete_user.php?token=<?php echo $token; ?>"><button class="btn btn-danger">Delete</button></a> </td> <td> <button class="btn btn-warning" onclick="changePassword('<?php echo $token; ?>', '<?php echo $email; ?>');">ChangePass</button> </td> </tr> <?php $cnt = $cnt + 1; } } ?> </tbody> </table> </div> </div> <?php include_once("footer.php");?> <script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script> <script> $(document).ready(function () { $('.nav-item').removeClass('active'); $('.user_list').addClass('active'); $('#myTable').DataTable({ "info": false, "ordering": false, "language": { "search": '<i class="fa-solid fa-magnifying-glass"></i>', 'searchPlaceholder': "search here..." } }); }); function copyLink(event, button) { event.preventDefault(); // Prevent any default action (like form submission) // Find the closest form to the clicked button var form = button.closest("form"); // Get the hidden input element in the form var hiddenLinkInput = form.querySelector("input[name='hidden_link']"); // Copy the hidden input value to the clipboard navigator.clipboard.writeText(hiddenLinkInput.value).then(function() { alert("Link copied to clipboard: " + hiddenLinkInput.value); }).catch(function(error) { console.error("Failed to copy text: ", error); }); } function changePassword(token, email) { Swal.fire({ title: 'Change Password', input: 'text', inputLabel: 'Enter new password for ' + email, inputPlaceholder: 'New password', showCancelButton: true, confirmButtonText: 'Change', cancelButtonText: 'Cancel', inputAttributes: { 'aria-label': 'Type your password here' }, preConfirm: (newPassword) => { if (!newPassword) { Swal.showValidationMessage('You need to enter a password'); } else { return newPassword; } } }).then((result) => { if (result.isConfirmed) { $.ajax({ url: 'pages/change_password_admin.php', type: 'POST', data: { token: token, new_password: result.value }, success: function(response) { // Ensure the response is an object if (response.success) { Swal.fire('Success!', 'Password changed successfully.', 'success'); location.reload(); // Reload the page to see changes } else { Swal.fire('Error!', response.message || 'An unexpected error occurred.', 'error'); console.log(response); } }, error: function() { Swal.fire('Error!', 'Failed to change password.', 'error'); } }); } }); } </script>