-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_reputation.php
59 lines (48 loc) · 1.54 KB
/
check_reputation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
$phoneNumber = $_POST['phoneNumber'];
$percentage = 0;
if (strlen($phoneNumber) === 10 && $phoneNumber[0] === '0') {
$thirdDigit = $phoneNumber[2];
$fourthDigit = $phoneNumber[3];
$fifthDigit = $phoneNumber[4];
$sixthDigit = $phoneNumber[5]; // Added this line for Rule 9
$seventhDigit = $phoneNumber[6];
$eighthDigit = $phoneNumber[7];
$ninthDigit = $phoneNumber[8];
$tenthDigit = $phoneNumber[9];
if (in_array($thirdDigit, ['7', '1', '8', '5', '2'])) {
// Rule 4: Check if 3rd and 4th digits are the same
if ($ninthDigit === $seventhDigit && $tenthDigit === $eighthDigit) {
$percentage = 80;
} elseif ($ninthDigit === $seventhDigit) {
$percentage = 70;
} elseif ($fifthDigit === $eighthDigit) {
$percentage = 85;
} else {
$percentage = 51;
}
} elseif (in_array($thirdDigit, ['0', '4', '6'])) {
// Rule 4: Check if 3rd and 4th digits are the same
if ($ninthDigit === $seventhDigit && $tenthDigit === $eighthDigit) {
$percentage = 80;
} elseif ($ninthDigit === $seventhDigit) {
$percentage = 70;
} elseif ($fifthDigit === $eighthDigit) {
$percentage = 85;
} else {
$percentage = 30;
}
}
if ($thirdDigit === $fourthDigit && $ninthDigit === $seventhDigit && $tenthDigit === $eighthDigit) {
$percentage = 94;
}
if ($fifthDigit === $sixthDigit && $eighthDigit === $ninthDigit) {
$percentage = 96;
}
}
// Return the percentage as JSON response
$response = [
'percentage' => $percentage
];
echo json_encode($response);
?>