Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if(isset($_SESSION['username'])) {
- //
- } else {
- echo '<script>window.location.replace("./logout.php");</script>';
- }
- if (isset($_GET['code']) && isset($_GET['author'])) {
- if (strlen($_GET['code']) !== 16 {
- $js = array();
- $js['error'] = 1;
- $js['msg'] = 'Voucher kurang dari 16 digit';
- exit(json_decode($js));
- }
- $scandir = scandir('voctanpdatabase');
- $id = count($scandir);
- foreach ($scandir as $voucher) {
- if (strpos($voucher, $_GET['code'])) {
- $js = array();
- $js['error'] = 1;
- $js['msg'] = 'Voucher sudah ada!';
- exit(json_encode($js));
- }
- }
- $b = fopen('voctanpdatabase/'.$_GET['code'].'.json', 'w');
- $json['id'] = $id+1;
- $json['status'] = 1;
- $json['isprivate'] = 1;
- $json['author'] = $_GET['author'];
- if (isset($_GET['buyer']) && $_GET['buyer'] !== '') {
- $json['buyer'] = $_GET['buyer'];
- }
- $json['start'] = '09/09/2019';
- $json['end'] = '13/10/2019';
- $json['type'] = $_GET['type'];
- fwrite($b, json_encode($json));
- fclose($b);
- $res['error'] = 0;
- $res['msg'] = 'Terima Kasih, Voucher Berhasil Di Buat!, Silahkan Redeem Di /recap.php?code='.$_GET['code'].'';
- exit(json_encode($res));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement