Файл: controllers/accounts.class.php
Строк: 35
<?php
/****
* Класс для регистрации пользоваелей в системе avisosms.ru
* Автор: Михаил Асташкевич
* Контакты: ICQ 417672423, Skype asmisha
*****/
class RegisterClass{
private $RefID;
private $Gateway = 'http://api.avisosms.ru/rar';
private $Curl;
private $AllowedOptionalFields = array('phone', 'referral');
private function CurlInit(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$this->Curl = $ch;
}
private function Send($URL, $POST){
curl_setopt($this->Curl, CURLOPT_URL, $URL);
curl_setopt($this->Curl, CURLOPT_POSTFIELDS, $POST);
return curl_exec($this->Curl);
}
private function ParseResponse($Resp){
$Resp = json_decode($Resp);
if (isset($Resp->RegisterUserResult))
return true;
else
return $Resp->Result;
}
public function __construct($RefID = 0){
$this->RefID = $RefID;
$this->CurlInit();
}
public function Register($UserName, $Password, $Email, $Optional){
$msg = array('username' => $UserName, 'password' => $Password, 'email' => $Email, 'referral' => $this->RefID);
foreach($Optional as $k=>$i){
if (in_array($k, $this->AllowedOptionalFields)){
$msg[$k] = $i;
}
}
$msg = json_encode($msg);
$Answer = $this->Send($this->Gateway, $msg);
return $this->ParseResponse($Answer);
}
}
?>