Voipbuster PHP script not working (anymore)

I'm using the script below to get the remaining balance of my VoipBuster
account.
I'm using this script in my Astrerisk PBX server.

==========================begin script =======================

function encryptString($string) {
for($i=0; $i < strlen($string); $i++) {
if(is_numeric($string[$i])) {
if($string[$i] < "5")
$string[$i]= $string[$i] + 5;
else
$string[$i]= $string[$i] - 5;
}
}
return str_rot13($string);
}

// Set username and password:
$username = encryptString('your_own_voipbusterusername');
$password = encryptString('your_own_voipbusterpassword');

$loginurl=
('https://myaccount.voipbuster.com/clx/index.php?part=plogin &username=' .
$username . '&password=' . $password);
$mainmenuurl =
('https://myaccount.voipbuster.com/clx/index.php?part=menu&j ustloggedin=true');

//========== FIRST PART (LOGIN): ==========================

$cookiejar = tempnam("", "");
if ($cookiejar) {
$ch = curl_init(); // curl initialization

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar); //connecting cookie input
and output to
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar); //this curl session

curl_setopt ($ch, CURLOPT_URL, $loginurl); //set URL to use in GET/POST
action

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); //return received data
(instead of curl result code)

curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); //DISABLE HTTPS
AUTHENTICATION CHECKING:

curl_exec ($ch); //EXECUTE 1st REQUEST (FORM LOGIN):
//will give a redirect to: /index.php?part=menu&justloggedin=true


//========== SECOND PART: ==========

// FOLLOWING REDIRECT TO /index.php?....:
curl_setopt($ch, CURLOPT_URL, $mainmenuurl);

$content = curl_exec ($ch); //EXECUTE 2nd REQUEST (load 'main menu'),
saving data in $content:

curl_close ($ch); //close curl session


$start = strpos($content,'balanceid'); //bepaal start van balanceid
$deelstring = substr($content,$start+26,10); //kopieer het begin van het
bedrag de string naar een tussen waarde
//print $deelstring;
$einde = strpos($deelstring,'<'); //einde van het bedrag is waar de
afsluit tag begint
$bedrag = substr($deelstring,0,$einde);
print "Remaining credit: $bedrag\n"; //use this for testing
// print "$bedrag"; //gebruik dit als je het als AGI script gaat gebruiken
in Asterisk

}
else { print "error creating cookie file"; }

?>

==========================end script ===============================

Here is where I use the script in my Asterisk server:

exten=>3002,1,Answer()
exten=>3002,2,Set(status=${CURL(http://localhost/credit/cred it_voipbuster.php)})
exten=>3002,3,NoOP(${status})
exten=>3002,4,SayDigits(${status})
exten=>3002,5,Playback(vm-goodbye)
exten=>3002,6,Hangup()


When I dial extension 3002, I will here the remaining balance.

I have been using this script without any problems.
However................after a new installation of Linux (SuSE102.2) and a
new installation of Asterisk, the result is always 0.

This line :

exten=>3002,2,Set(status=${CURL(http://localhost/credit/cred it_voipbuster.php)})

should assign the value of the remaining balance to the variable 'status'.
It contains only the value 0, instead of the real balance.

If I run the script directly from a web browser, it prints the RIGHT value
(print "Remaining credit: $bedrag\n"; //use this for testing)

The funny thing is that the script worked correctly before I did a new
installation.
(I jus copied the old file to the new installation)

Somebody who can help? ::)

Rgds
Henk
Henk Oegema [ Di, 12 Juni 2007 23:58 ] [ ID #1735951 ]

Re: Voipbuster PHP script not working (anymore)

On Tue, 12 Jun 2007 21:58:24 GMT, Henk Oegema <henk [at] oegema.com> wrote:

>I'm using the script below to get the remaining balance of my VoipBuster
>account.
>I'm using this script in my Astrerisk PBX server.
[snip]

>I have been using this script without any problems.
>However................after a new installation of Linux (SuSE102.2) and a
>new installation of Asterisk, the result is always 0.

[snip]

>If I run the script directly from a web browser, it prints the RIGHT value
>(print "Remaining credit: $bedrag\n"; //use this for testing)
>
>The funny thing is that the script worked correctly before I did a new
>installation.
>(I jus copied the old file to the new installation)
>
>Somebody who can help? ::)

Maybe a long shot, but always look for the most obvious thing first...
Is localhost in your hosts file?
--
Locate your Mobile phone: <http://www.bizorg.co.uk/news.html>
Great gifts: <http://www.ThisBritain.com/ASOS_popup.html>
David Quinton [ Mi, 13 Juni 2007 08:33 ] [ ID #1736804 ]

Re: Voipbuster PHP script not working (anymore)

David Quinton wrote:

> On Tue, 12 Jun 2007 21:58:24 GMT, Henk Oegema <henk [at] oegema.com> wrote:
>
>>I'm using the script below to get the remaining balance of my VoipBuster
>>account.
>>I'm using this script in my Astrerisk PBX server.
> [snip]
>
>>I have been using this script without any problems.
>>However................after a new installation of Linux (SuSE102.2) and a
>>new installation of Asterisk, the result is always 0.
>
> [snip]
>
>>If I run the script directly from a web browser, it prints the RIGHT value
>>(print "Remaining credit: $bedrag\n"; //use this for testing)
>>
>>The funny thing is that the script worked correctly before I did a new
>>installation.
>>(I jus copied the old file to the new installation)
>>
>>Somebody who can help? ::)
>
> Maybe a long shot, but always look for the most obvious thing first...
> Is localhost in your hosts file?

#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server.
# Syntax:
#
# IP-Address Full-Qualified-Hostname Short-Hostname
#

127.0.0.1 localhost

# special IPv6 addresses
::1 localhost ipv6-localhost ipv6-loopback

fe00::0 ipv6-localnet

ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
192.168.1.100 asterisk.site asterisk
Henk Oegema [ Mi, 13 Juni 2007 10:25 ] [ ID #1736805 ]
PHP » alt.php » Voipbuster PHP script not working (anymore)

Vorheriges Thema: Re: Sexual fascism and the Mark Foley scandel
Nächstes Thema: Re: Sexual fascism and the Mark Foley scandel