public function login($credentials)
{
$this->_credentials = $credentials;
$valuesLogin = array(new \Oara\Curl\Parameter('username', $this->_credentials['user']), new \Oara\Curl\Parameter('password', $this->_credentials['password']));
$this->_client = new \Oara\Curl\Access($credentials);
$urls = array();
$urls[] = new \Oara\Curl\Request("https://billing.purevpn.com/clientarea.php", array());
$exportReport = $this->_client->get($urls);
$doc = new \DOMDocument();
@$doc->loadHTML($exportReport[0]);
$xpath = new \DOMXPath($doc);
$hidden = $xpath->query('//input[@name="token"]');
foreach ($hidden as $values) {
$valuesLogin[] = new \Oara\Curl\Parameter($values->getAttribute("name"), $values->getAttribute("value"));
}
$urls = array();
$urls[] = new \Oara\Curl\Request("https://billing.purevpn.com/dologin.php?goto=clientarea.php", $valuesLogin);
$this->_client->post($urls);
$urls = array();
$urls[] = new \Oara\Curl\Request("https://billing.purevpn.com/check_affiliate.php?check=affiliate", $valuesLogin);
$oldOptions = $this->_client->getOptions();
$newOptions = $oldOptions;
$newOptions[CURLOPT_HEADER] = true;
$this->_client->setOptions($newOptions);
$exportReport = $this->_client->get($urls);
$this->_client->setOptions($oldOptions);
\preg_match('/Location:(.*?)\\n/', $exportReport[0], $matches);
$newurl = trim(array_pop($matches));
if (\preg_match("/S=(.*)/", $newurl, $matches)) {
$this->_s = $matches[1];
}
$urls = array();
$urls[] = new \Oara\Curl\Request($newurl, array());
$this->_client->get($urls);
}