Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($handler == 'newlicense') {
- if(!$TOTP->validateCode($token))
- {
- $json['status'] = 401;
- $json['message']['header'] = 'Oops!';
- $json['message']['text'] = 'Invalid Token. Refresh the page and try again.';
- $json['message']['type'] = 'error';
- die(json_encode($json));
- }
- $addeddate = strtotime($_REQUEST['addeddate']);
- $productid = $Gauntlet->filter($_REQUEST['productid']);
- $categoryid = $Gauntlet->filter($_REQUEST['categoryid']);
- $status = $Gauntlet->filter($_REQUEST['status']);
- $serialkey = $Gauntlet->filter($_REQUEST['serialkey']);
- $type = $Gauntlet->filter($_REQUEST['type']);
- if ($type == '' || $serialkey == '' || $addeddate == '' || $status == '') {
- $json['status'] = 500;
- $json['message']['header'] = 'Oops!';
- $json['message']['text'] = 'You need to input all values.';
- $json['message']['type'] = 'error';
- die(json_encode($json));
- }
- $userid = $_SESSION['id'];
- $sql = "SELECT * FROM licenses";
- //die(var_dump($sql));
- $query = $DatabaseHandler->query($sql);
- $data = $query->fetch_array();
- if ($type = $data['type'] && $serialkey = $data['licensekey'] && $productid = $data['productid']) {
- $json['status'] = 300;
- $json['message']['header'] = 'Oops!';
- $json['message']['text'] = 'Data sudah ada.';
- $json['message']['type'] = 'error';
- die(json_encode($json));
- }
- $sql = "INSERT INTO `licenses` (`addeddate`, `productid`, `categoryid`, `status`, `licensekey`, `type`, `issued-by`) VALUES ('$addeddate', '$productid', '$categoryid', '$status', '$serialkey', '$type', '$userid');";
- //die(var_dump($sql));
- $query = $DatabaseHandler->query($sql);
- if ($query) {
- $json['status'] = 200;
- $json['message']['header'] = 'Success!';
- $json['message']['text'] = 'License inserted successfully!';
- $json['message']['type'] = 'success';
- die(json_encode($json));
- } else {
- $json['status'] = 500;
- $json['message']['header'] = 'Oops!';
- $json['message']['text'] = 'Error in Database.';
- $json['message']['type'] = 'error';
- die(json_encode($json));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement