Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $name = $_GET['name'];
- $gender = $_GET['gender'];
- $pin = $_GET['pin'];
- $isCorrectMonth = true;
- $nums = [2,4,8,5,10,9,7,3,6];
- $card = [];
- $month = (int)$pin[2].$pin[3];
- if ($month > 12) {
- if ($month - 20 >= 1 && $month - 20 <= 12) {
- $isCorrectMonth = true;
- }
- else if ($month - 40 >= 1 && $month - 40 <= 12) {
- $isCorrectMonth = true;
- }
- else {
- $isCorrectMonth = false;
- }
- }
- else if ($month <= 12 && $month >= 1) {
- $isCorrectMonth = true;
- }
- else {
- $isCorrectMonth = false;
- }
- if ($isCorrectMonth) {
- if ($pin[8] % 2 === 0) {
- $genderID = "male";
- }
- else {
- $genderID = "female";
- }
- }
- else {
- echo "<h2>Incorrect data</h2>";
- die();
- }
- if ($genderID === $gender) {
- $combo = 0;
- for ($i=0; $i < count($nums); $i++) {
- $combo += $nums[$i] * $pin[$i];
- }
- $combo = $combo % 11;
- if ($combo === 10) {
- $combo = 0;
- }
- if ($combo === (int)$pin[9]) {
- $card['name'] = $name;
- $card['gender'] = $gender;
- $card['pin'] = $pin;
- echo json_encode($card);
- }
- else {
- echo "<h2>Incorrect data</h2>";
- die();
- }
- }
- else {
- echo "<h2>Incorrect data</h2>";
- die();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment