private function pn_nums if array_key_exists pn_nums this- accounts th

 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
private function pn_nums() {
if(array_key_exists('pn_nums', $this->accounts[$this->selected_account]))
$this->request('/mysite/?', array(
'pn_nums' => $this->accounts[$this->selected_account]['pn_nums']
));
else
$this->toLog('Введите последние 4 цифры номера для аккаунта!', self::ERROR);
}
private function request($link, $post = false) {
$time_delta = microtime() - $this->last_request_time;
if($time_delta < $this->request_interval) {
if($this->hits_count >= $this->hits_per_interval){
usleep(($this->request_interval - $time_delta) * 1000000);
$this->hits_count = 0;
}
}else
$this->hits_count = 0;
if($post)
curl_setopt_array($this->ch, array(
CURLOPT_URL => self::HOST . $link,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $post
));
else
curl_setopt($this->ch, CURLOPT_URL, self::HOST . $link);
$res = curl_exec($this->ch);
if($post)
curl_setopt($this->ch, CURLOPT_POST, false);
$this->last_request_time = microtime();
++$this->hits_count;
if(preg_match('/name="pn_nums" size="10"/', $res)) {
$this->pn_nums();
$res = $this->request($link, $post);
}
return $res;
}