Curl

Hi can some one help me out with this it did work 2 month ago but now i just get Connection problem.

[php]<?php

class IdsManager
{
private $login = “mail adress”;
private $pw = “xxxxxxxxxx”;
private $authId;
private $playerId;
private $authIdFile;
private $player;

public function __construct($playerName)
{
	$this->authIdFile = fopen('ramdisk/authid', 'r');
	$this->authId = fgets($this->authIdFile);
	$this->retrieveAuthAndPlayerId($playerName);
	$this->player = $playerName;
	fclose($this->authIdFile);
}

private function connection()
{
	$usermail = urlencode($this->login);
	$password = urlencode($this->pw);
	$post = "email=".$usermail."&password=".$password."&frm_action=login";

	$ch = curl_init("http://secure.thehunter.com/submit/");
	curl_setopt($ch, CURLOPT_HEADER, 1);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$response = curl_exec($ch);
	$header  = curl_getinfo( $ch );
	curl_close($ch);
	unset($ch);
	
	$securestr = explode("/", $header['url']);
	$this->authId = $securestr[4];
	
	fclose($this->authIdFile);
	$this->authIdFile = fopen('./ramdisk/authid', 'w');
	fseek($this->authIdFile, 0);
	fputs($this->authIdFile, $this->authId);
}

private function retrieveAuthAndPlayerId($playerName)
{

	if(empty($this->authId))
	{
		$this->connection();
	}

	$this->retrievePlayerIdFromSite($playerName);

	if($this->playerId === 0)
	{
		$this->connection();
		$this->retrievePlayerIdFromSite($playerName);
	}
}

private function retrievePlayerIdFromSite($playerName)
{
	$ch = curl_init("http://".$playerName.".thehunter.com/sid/".$this->authId."/site/statistics/");
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HEADER, 1);
	$response = curl_exec($ch);
	$header  = curl_getinfo( $ch );
	curl_close($ch);
	unset($ch);

	
	if(strpos($header['url'], "reason=no-profile-exists"))
	{
		$this->playerId = -1;
	} elseif($header['url'] == "http://www.thehunter.com/pub/")
	{
		$this->playerId = 0;
	} else {
		$useridpos = strpos($response, "onclick=") + 12;
		$this->playerId = substr($response, $useridpos, 11);
	}

}

public function getPlayerId()
{
	return $this->playerId;
}

public function getAuthId()
{
	return $this->authId;
}

public function getPlayerName()
{
	return $this->player;
}

public function isValid()
{
	return (!empty($this->authId) && !empty($this->playerId) && $this->playerId != -1);
}

}
?>[/php]

Can you still connect to the service manually?

yes that is no problem its just when i use this script

Sponsor our Newsletter | Privacy Policy | Terms of Service