Server IP : 14.241.111.210 / Your IP : 18.221.100.52 Web Server : Apache System : Linux localhost.localdomain 3.10.0-1160.66.1.el7.x86_64 #1 SMP Wed May 18 16:02:34 UTC 2022 x86_64 User : www ( 1001) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /www/wwwroot/checkemail.webthanhha.com/ |
Upload File : |
<?php include('include/header.php'); include('include/config_db.php'); $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $chars = "abcdefghijklmnopqrstuvwxyzJKLMNOPQRSTUVWXYZ0123456789-_ABCDEFGHIJKABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ABCOPQRSTUVWXYZ0123456789-_"; //echo 'token: '.$token = substr(str_shuffle($chars),0, 120); echo '<br>'; $result = $conn->query("SELECT * FROM package"); $check_admin = false; if(isset($_SESSION['username']) && $_SESSION['username']){ $result_usertype = $conn->query("SELECT id FROM users WHERE username = '".$_SESSION['username']."' AND admin = 1"); $check_admin = (bool)($result_usertype->num_rows == 1); } //echo var_dump($check_admin); ?> <div class="text-center"> <h1>SERVICE PRICE LIST</h1> <p>Choose the email verification package that suits your needs.</p> </div> <div class="container main py-1"> <div class="row"> <?php if($check_admin){ ?> <button type="button" class="btn btn-success mb-3" data-toggle="modal" data-target="#add-package">ADD PACKAGE</button> <?php } ?> <table class="table table-hover table-bordered table-striped table-price"> <thead> <tr> <th>Package name</th> <th>Number of verified emails/month</th> <th>Price (USD)</th> <th>Unit Price</th> <th> <?php if(!isset($_SESSION['username'])): echo "Login / Signup To Buy Credits"; else: echo "Buy Now"; endif; ?> </th> <?php if($check_admin){echo "<th>Action</th>";} ?> </tr> </thead> <tbody> <?php while($row = $result->fetch_assoc()){ ?> <tr> <td><strong><?=$row['name'] ?></strong></td> <td><?=number_format($row['credits']) ?></td> <td><?='$'.number_format($row['price']) ?></td> <td><?='$'.number_format($row['price'] / $row['credits'], 5).' / email' ?></td> <td class="text-center"> <?php if(!isset($_SESSION['username'])): ?> <a href="#"><img src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/buy-logo-large.png" alt="Buy now with Paypal" /></a> <p class="mt-2 mb-0">You need to <a href="/signup.php">Signup </a> or <a href="/login.php">Login</a> to buy Credits</p> <?php elseif(isset($_SESSION['username']) && $_SESSION['username']): ?> <a href="<?='pricing-detail.php?name='.strtolower($row['name']).'&id='.$row['id']?>"><img src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/buy-logo-large.png" alt="Buy now with Paypal" /></a> <?php endif; ?> </td> <?php if($check_admin): ?> <td> <button type="button" class="btn btn-info btn" data-toggle="modal" data-target="#edit-package-<?=$row['id'] ?>">Edit</button> <span><a href="/pricing.php?delete-package=<?=$row['id']?>" Onclick="return ConfirmDelete();">Delete</a></span> </td> <?php endif; ?> </tr> <!-- Edit Package --> <div class="modal fade" id="edit-package-<?=$row['id'] ?>" data-id="edit-package-<?=$row['id'] ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="myModalLabel">Edit Package <?=$row['name'] ?></h4> </div> <div class="modal-body"> <form method="POST" action="pricing.php?do=update-package" accept-charset="UTF-8" enctype="multipart/form-data"> <ul> <li> <label for="name" >Name:</label> <input style="background-color: #ccc;" name="name" type="text" id="name" class="form-control" value="<?=$row['name'] ?>"> <input hidden name="id" type="text" value="<?=$row['id'] ?>"> </li> <li> <label for="credits" >credits:</label> <input name="credits" type="text" id="credits" class="form-control" value="<?=$row['credits'] ?>"> </li> <li> <label for="price" >Price ($):</label> <input name="price" type="text" id="price" class="form-control" value="<?=$row['price'] ?>"> </li> </ul> </div> <div class="modal-footer"> <button type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button> <button type="submit" class="btn btn-success" name="update-package" value="UPDATE">Update</button> </div> </form> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal --> <!-- End Edit Package --> <?php } ?> </tbody> </table> </div> </div> <!-- Add Package --> <?php if($check_admin){ ?> <div class="modal fade" id="add-package" data-id="add-package" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="myModalLabel">Add Package</h4> </div> <form method="POST" action="pricing.php?do=add-package" accept-charset="UTF-8" enctype="multipart/form-data"> <div class="modal-body"> <ul> <li> <label for="name" >Name <span>(*)</span>:</label> <input name="name" type="text" id="name" class="form-control" required placeholder="Package name, different from existing name"> </li> <li> <label for="credits" >Credits <span>(*)</span>:</label> <input name="credits" type="text" id="credits" class="form-control" required placeholder="The corresponding number of credits"> </li> <li> <label for="price" >Price <span>(*)</span>:</label> <input name="price" type="text" id="price" class="form-control" required placeholder="Enter the price $"> </li> </ul> </div> <div class="modal-footer"> <button type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button> <button type="submit" class="btn btn-success" name="add-package" value="SUBMIT">Submit</button> </div> </form> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal --> <?php } ?> <!-- End Add Package --> <script> function ConfirmDelete() { var x = confirm("Are you sure you want to delete?"); if (x) return true; else return false; } </script> <?php //Edit Package: if(isset($_POST['update-package']) && $check_admin){ //$sql_update = "UPDATE package SET name='".$_POST['name']."', credits = '".$_POST['credits']."', price = '".$_POST['price']."' WHERE id ='".$_POST['id']."'"; if ($conn->query("UPDATE package SET name='".$_POST['name']."', credits = '".$_POST['credits']."', price = '".$_POST['price']."' WHERE id ='".$_POST['id']."'") === TRUE) { echo "<p style='text-align: center;'>Update User Success!</p>"; echo "<p style='text-align: center;'><a href='javascript: history.go(-1)'>BACK</a></p>"; } else { echo "Error updating record: " . $conn->error; } } //End Edit Package //Delete Package if(isset($_GET['delete-package']) && $_GET['delete-package'] && $check_admin){ if ($conn->query("DELETE FROM package WHERE id = '".$_GET['delete-package']."'") === TRUE) { echo "<h3 style='text-align: center;'>Delete Package Success!</h3>"; echo "<h3 style='text-align: center;'><a href='javascript: history.go(-1)'>BACK</a></h3>"; } else { echo "Error updating record: " . $conn->error; } } //End delete Package //Add Package if(isset($_POST['add-package']) && $_POST['add-package'] && $check_admin){ if ($conn->query("INSERT INTO package(name, credits, price, type, updated_at) VALUES ('".$_POST['name']."', '".$_POST['credits']."', '".$_POST['price']."', 1, '".date('Y-m-d H:i:s')."') ") === TRUE) { echo "<h3 style='text-align: center;'>Add Package Success!</h3>"; echo "<h3 style='text-align: center;'><a href='javascript: history.go(-1)'>BACK</a></h3>"; } else { echo "Error updating record: " . $conn->error; } } //End Add Package $conn->close(); include('include/footer.php'); ?>