public function auth switch func_num_args case if preg_match 16 func_g

 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
public function auth() {
switch (func_num_args()) {
case 1:
if(preg_match('/^\d{16}$/', func_get_arg(0))) {
curl_setopt($this->ch, CURLOPT_COOKIE, 'sid=' . func_get_arg(0));
$this->account['sid'] = func_get_arg(0);
$res = $this->request('/mysite/');
if(!preg_match('/Активность/', $res))
$this->toLog('Невозможно авторизоваться!', self::ERROR);
else
$this->toLog('Успешная авторизация!');
} elseif(preg_match('/^[0-9a-f]{32}$/', func_get_arg(0))) {
$res = $this->request('/tm/' . func_get_arg(0));
preg_match('/sid=(\d+)/', $res, $data);
$this->account['tm'] = func_get_arg(0);
$this->account['sid'] = $data[1];
$this->auth($this->account['sid']);
} else
$this->toLog('Неверные данные для входа', self::ERROR);
break;
case 2:
if(preg_match('/^\d{16}$/', func_get_arg(0)) && preg_match('/^\d{4}$/', func_get_arg(1))) {
curl_setopt($this->ch, CURLOPT_COOKIE, 'sid=' . func_get_arg(0));
$this->account['sid'] = func_get_arg(0);
$this->account['pn_nums'] = func_get_arg(1);
$res = $this->request('/mysite/');
if(!preg_match('/Активность/', $res))
$this->toLog('Невозможно авторизоваться!', self::ERROR);
else
$this->toLog('Успешная авторизация!');
} elseif(preg_match('/^[0-9a-f]{32}$/', func_get_arg(0)) && preg_match('/^\d{4}$/', func_get_arg(1))) {
$res = $this->request('/tm/' . func_get_arg(0));
preg_match('/sid=(\d+)/', $res, $data);
$this->account['tm'] = func_get_arg(0);
$this->account['pn_nums'] = func_get_arg(1);
$this->account['sid'] = $data[1];
$this->auth($this->account['sid'], $this->account['pn_nums']);
} else {
$res = $this->request('/registration/?r=reg/loginform');
preg_match('/name="CK" value="(\d+)"/', $res, $ck);
preg_match('/sid=(\d+)/', $res, $sid);
$ck = $ck[1];
$sid = $sid[1];
$res = $this->request('/registration/?r=reg/loginform&sid=' . $sid, array(
'contact' => func_get_arg(0),
'password' => func_get_arg(1),
'CK' => $ck,
'sid' => $sid
));
echo $res;
}
break;
}
}