Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if(isset($_SESSION['username'])) {
  4. //
  5. } else {
  6. echo '<script>window.location.replace("./logout.php");</script>';
  7. }
  8. if (isset($_GET['code']) && isset($_GET['author'])) {
  9. if (strlen($_GET['code']) !== 16 {
  10. $js = array();
  11. $js['error'] = 1;
  12. $js['msg'] = 'Voucher kurang dari 16 digit';
  13. exit(json_decode($js));
  14. }
  15. $scandir = scandir('voctanpdatabase');
  16. $id = count($scandir);
  17. foreach ($scandir as $voucher) {
  18. if (strpos($voucher, $_GET['code'])) {
  19. $js = array();
  20. $js['error'] = 1;
  21. $js['msg'] = 'Voucher sudah ada!';
  22. exit(json_encode($js));
  23. }
  24. }
  25. $b = fopen('voctanpdatabase/'.$_GET['code'].'.json', 'w');
  26. $json['id'] = $id+1;
  27. $json['status'] = 1;
  28. $json['isprivate'] = 1;
  29. $json['author'] = $_GET['author'];
  30. if (isset($_GET['buyer']) && $_GET['buyer'] !== '') {
  31. $json['buyer'] = $_GET['buyer'];
  32. }
  33. $json['start'] = '09/09/2019';
  34. $json['end'] = '13/10/2019';
  35. $json['type'] = $_GET['type'];
  36. fwrite($b, json_encode($json));
  37. fclose($b);
  38. $res['error'] = 0;
  39. $res['msg'] = 'Terima Kasih, Voucher Berhasil Di Buat!, Silahkan Redeem Di /recap.php?code='.$_GET['code'].'';
  40. exit(json_encode($res));
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement