-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVerificationService.php
More file actions
69 lines (55 loc) · 1.72 KB
/
Copy pathVerificationService.php
File metadata and controls
69 lines (55 loc) · 1.72 KB
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
59
60
61
62
63
64
65
66
67
68
69
<?php
include_once './CarrierHelper.php';
include_once './config_verify.php';
include_once './VerificationManager.php';
/**
* Verification Service to verify a users phone number
*/
class VerificationService {
private $number;
private $areaCode;
private $numHead;
private $numTail;
private $network;
private $verifyKey;
private $verificationManager;
private $carrier;
/**
* Setup proper settings to send notification
*/
public function __construct($number, $network, $debug = FALSE) {
$this->number = $number;
$this->areaCode = intval(substr($number, 0, 3));
$this->numHead = intval(substr($number, 3, 3));
$this->numTail = intval(substr($number, 6, 4));
$this->network = $network;
$this->carrier = new CarrierHelper();
$this->verificationManager = new VerificationManager($debug);
}
public static function getVID($number){
return md5(MD5_VID.$number);
}
/*
* Generate and store a new verification code
*/
public function generateVerificationKey(){
$t = intval(((time() % 13589) + rand(0, 99999)) / 2);
$sec1 = ($this->areaCode + $this->numHead + $this->numTail) % 482;
$sec2 = intval(($this->carrier->getNetworkId($this->network) + rand(0, 99)) / 2);
$sec3 = $t % 61335;
$code = sprintf("%03s%02s%05s", $sec1, $sec2, $sec3);
$this->verifyKey = $code;
$vid = $this->getVID($this->number);
return $this->verificationManager->addVerification($vid, $this->verifyKey);
}
/**
* Send Verification Message
*/
public function send()
{
$address = $this->carrier->getNetworkDomain($this->network);
$email = $this->number."@".$address;
mail($email, "", "verification code:\n".$this->verifyKey, "From: verify@staticvillage.com\r\n", "-fverify@staticvillage.com");
}
}
?>