/*
// Codi creat per M Minoves, tots els drets reservats. Sota llicència GNU/GPL però per modificació o adaptació contactar amb l'autor.
// Code created by M Minoves, All rights reserved. Under GNU/GPL licence but for modification notificate the author.
// www.aldeaglobal.net/callserver
// call.php VERSION: 3.11253
Explanations are bilingual in catalan and english
SINTAXI DE LA URL ÉS LA SEGÜENT: / URL SINTAX IS AS FOLLOWS:
call.php?provider=justvoip.com&disp=1&default=0034&forcea=0034&forceb=0034&us=USER&ps=PASSWORD&tela=TELEPHONEA&telb=TELEPHONEB
Està instalat a / It is installed on:
http://www.aldeaglobal.net/callserver/call.php?provider=justvoip.com&disp=0&hideprice=0&default=0034&forcea=0034&forceb=0034&us=USER&ps=PASSWORD&tela=TELEPHONEA&telb=TELEPHONEB
Un exemple senzill podria ser / A simplified example could be:
http://www.aldeaglobal.net/callserver/call.php?provider=justvoip.com&us=myusername&ps=mypassword&tela=00496151000000&telb=0034938550000
provider=justvoip Proveidor de Betamax / Betamax provider used ex: justvoip.com, voipbusterpro.com, internetcalls.com ...
(Price comparition at http://backsla.sh/betamax)
freecall.com
internetcalls.com
justvoip.com
lowratevoip.com
netappel.fr
poivy.com
sipdiscount.com
sparvoip.de
voipbuster.com
voipbusterpro.com
voipcheap.co.uk
voipcheap.com
voipdiscount.com
voipstunt.com
webcalldirect.com
voicetrading.com
disp=1 Ensenya el header i el contingut de les pàgines que descarrega. / Show the header and the content of the downloaded pages
server= Url del compte Betamax (No necessari) / Betamax account URL (Not needed) ex. 'https://myaccount.justvoip.com'
default=0034 Si un número de telèfon no està en format internacional, assumeix que aquest prefix / If one telephone number is not specified in the international format, it assumes it will have as prefix
forcea=0034 Força un prefix als numeros / Forces the numbers to have one prefix
forceb=0034
us=USER Usuari i contrasenya / Account user and password
ps=PASSWORD
tela=TELEPHONEA Telèfon origen / Source telephone
telb=TELEPHONEB Telèfon destí / Destination telephone
hidecountry=1 No mostra informació de paisos / Hides country names (only easyvoip)
hideprice=1 No mostra informació de preus / Hides pricing information
hidelogin=1 En errors no mostra informacio del login / On errors it does not show login info
hidelogin=2 En errors no mostra informacio del login pero si demana pels telefons / On errors it does not show login info but it asks for telephones if missing.
hidelogin=3 No mostra errors, ni mostra informacio del login pero si demana pels telefons / It doesn't show error or login info but it asks for telephones if missing.
easyvoip=1 Uses an alternative method to login. For servers working like easyvoip.com
method=1 Activa mètode estricte. Més ràpid però poc robust / Uses old strict method. Faster but less robust.
Set method=1 if you don't have Simpletest installed. Download it at http://simpletest.org
Simply decompress simpletest_1.1.0.tar.gz into the same folder where call.php is located.
slow=1 Activa negociacó lenta / Forces slow negotiation during login
myaccount1 Initial URL. Ex. https://www.easyvoip.com/login
myaccount2 URL for the Login. Ex https://www.easyvoip.com/login
myaccount3 URL to set the call. Ex https://www.easyvoip.com/phone_to_phone
// Installation notes on a server / Instal·lació avançada en un servidor:
The only requirement is that you have to have installed the OpenSSL (i.e.: 0.9.7i 14 Oct 2005) in order to let the script login to the secure server. This means that your scripts can open secure https pages.
You do not need to have CURL installed for this script.
This script has been tested on a FreeBSD 4.10-RELEASE FreeBSD 4.10-RELEASE #5 with the PHP Version 4.4.4
It shouldn't be dependant on the version, but I have tried several PHP servers and some configurations did not work.
I managed to make it work on a PHP Version 4.3.4 on a Windows NT 6.0 build 6000 by commenting the whole BE3B section.
Betamax probably checks the way the socket connections are performed in order to detect fake browsers (like this one), and
in that case applies automatically the logout method. If somebody knows another reason please tell me.
You are also free to use the already installed script on such a server at (please do not abuse of it):
www.aldeaglobal.net/callserver/call.php
Which with all the sintax would be:
www.aldeaglobal.net/callserver/call.php?provider=justvoip.com&disp=0&hideprice=0&default=0034&forcea=0034&forceb=0034&us=USER&ps=PASSWORD&tela=TELEPHONEA&telb=TELEPHONEB
// Donations:
If you like this program you can give me a beer! All donations are voluntary. They are all welcome and they help me paying the server maintenance and "buying time" to keep updating.
http://www.aldeaglobal.net/donate
// Disclaimer:
I developed and published this script because I think it is not against any agreement with Betamax.
In fact Betamax should be aware that this is a promotion of people having/opening accounts with them. It is a service that they could already offer, and that I programmed for free for non lucrative personal interest.
If anybody thinks this goes against it or it is illegal please contact me.
*/
// START
//####################################################################################################################
// Cache control and HTML startup:
// Add the headers to avoid proxy cache of this page. We want a new call every time the page is called / Afegeix les capçaleres que eviten que es la pàgina es guardi en un caché d'un proxy, ja que volem una nova trucada cada vegada que obrim la pàgina:
// 1. Allows cache for 30 seconds, this avoids making the same call twice, but it also do not let to call twice in 30 sec (even different numbers).
header("Cache-Control: must-revalidate");
$offset = 30; // 60 * 60 * 24 * 1;
header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
// 2. Instead, to avoid completely proxy caches could be:
// header( 'Cache-Control: no-cache, must-revalidate' );
// header( 'Last-Modified: ' . gmdate( "D, d M Y H:i:s" ) . ' GMT' );
// header( 'Expires: now' );
// header( 'Pragma: no-cache' );
// Detect if the user access via wap or normal browser. This is not needed for a PDA like XDA which can accept WAP 2.0 and so it is able to read normal HTML pages.
// Detecta si l'usuari accedeix via wap o normal. Això no és necessari per PDA's com la XDA ja que accepten WAP 2.0 i per això poden llegir pàgines normals.
if(eregi("text/vnd.wap.wml",$HTTP_ACCEPT)) {
// The user can accept WML format, for WAP 1.0 / L'usuari accepta accepta WML, per WAP 1.0
$wapuser= true;
header("Content-type: text/vnd.wap.wml");
echo ("");
echo '';
echo '';
echo '';
//header("Location: /wap/index.wml");
// exit;
}
else
{
$wapuser = false;
echo '';
echo '';
echo ' TelWeb ';
echo "\n\n";
}
/*
// We empty the buffer and send the first part of the web page to the user:
flush();
ob_flush();
echo "\n";
flush();
ob_flush();
flush();
ob_flush();
*/
//####################################################################################################################
// We check not to overuse this script, and also avoids making the same call twice when clicked double.
$counter_file = "ultimacces.txt";
if (file_exists($counter_file))
$visits = file($counter_file);
else
$visits[0]=0;
if($visits[0] + 3 > time())
showerror("Server overuse. Please wait 10 seconds..");
$fp = fopen($counter_file , "w");
fputs($fp , time());
fclose($fp);
//####################################################################################################################
// Variable/parameters control
// En cas de cridar el script sense parametres / In case of calling this script directly without parameters
if ($_REQUEST["tela"] =='' && $_REQUEST["telb"] =='' && $_REQUEST["us"] =='' && $_REQUEST["ps"] =='' && $_REQUEST["provider"] =='')
{
showerror('');
}
// Usuari i contrasenya / Account user and password
if(!isset($_REQUEST["us"]) || !isset($_REQUEST["ps"]))
{
showerror("Missing Login information");
}
$usuari = $_REQUEST["us"];
$contrasenya = $_REQUEST["ps"];
if($usuari == "")
{
showerror("Login name cannot be empty");
}
if($contrasenya == "")
{
showerror("Password cannot be empty");
}
// $disp=1; // Ensenya el header i el contingut de les pàgines que descarrega. / Show the header and the content of the downloaded pages
if($_REQUEST["disp"] > 0)
{
$disp=1;
}
// tela= Telèfon origen / Source telephone
// telb= Telèfon destí / Destination telephone
if (isset($_REQUEST["tela"]) && $_REQUEST["tela"] != "")
{
$tela= $_REQUEST["tela"];
}else{
showerror("Missing TelA");
}
if (isset($_REQUEST["telb"]) && $_REQUEST["telb"] != "")
{
$telb= $_REQUEST["telb"];
}else{
showerror("Missing TelB");
}
if ($tela == $telb)
{
showerror("TelA = TelB");
}
// Força un prefix als numeros de telèfon / Forces the telephone numbers to have one prefix
if($_REQUEST["forcea"] !="")
{
$tela = $_REQUEST["forcea"] . $tela;
}
if($_REQUEST["forceb"] !="")
{
$telb = $_REQUEST["forceb"] . $telb;
}
// Si un número de telèfon no està en format internacional, assumeix que te aquest prefix / If one telephone number is not specified in the international format, it assumes it will have as prefix
if($_REQUEST["default"] !="")
{
if (substr($tela,0,2)!= "00" && substr($tela,0,1)!= "+")
{
$tela = $_REQUEST["default"] . $tela;
}
if (substr($telb,0,2)!= "00" && substr($telb,0,1)!= "+")
{
$telb = $_REQUEST["default"] . $telb;
}
}
if (strlen($tela)<5 || (substr($tela,0,2)!= "00" && substr($tela,0,1)!= "+") || !is_numeric($tela))
{
showerror("Invalid number tela: $tela");
}
if (strlen($telb)<5 || (substr($telb,0,2)!= "00" && substr($telb,0,1)!= "+") || !is_numeric($telb))
{
showerror("Invalid number telb: $telb");
}
if (substr($tela,0,1) == "+")
{
$tela = "00" . substr($tela,1);
}
if (substr($telb,0,1) == "+")
{
$telb = "00" . substr($telb,1);
}
// $easyvoip=1; // system used by easyvoip
if(isset($_REQUEST["easyvoip"]))
{
$easyvoip = $_REQUEST["provider"];
}
// Proveidor de Betamax / Betamax provider used ex: justvoip.com, voipbusterpro.com, internetcalls.com ...
if(isset($_REQUEST["provider"]))
{
$servidor = 'https://www.' . $_REQUEST["provider"]; // . '.com';
if($_REQUEST["provider"] == "easyvoip.com")
$easyvoip = 1;
}
//if($easyvoip == 1)
//{
/*
//We aprox that tela/telb is in format "0049176000000" where 49 is the country (only 2 digit)
$country_from = substr($tela,2,2);
$country_to = substr($telb,2,2);
$prefix_from = "%2B" . substr($tela,2,2);
$prefix_to = "%2B" . substr($telb,2,2);
$phonenumber_from = substr($tela,4);
$phonenumber_to = substr($telb,4);
*/
list($country_from, $phonenumber_from, $paisa) = findprefix($tela);
list($country_to, $phonenumber_to, $paisb) = findprefix($telb);
$prefix_from = "%2B" . $country_from;
$prefix_to = "%2B" . $country_to;
//}
// Url del compte Betamax (No necessari) / Betamax account URL (Not needed) ex. 'https://myaccount.justvoip.com'
if(isset($_REQUEST["server"]))
{
$servidor = $_REQUEST["server"];
}
if($servidor == "")
{
$servidor = "https://www.justvoip.com";
}
echo "TelA: $tela TelB: $telb ";
if ($_REQUEST['hidecountry'] != 1){
echo $paisa . " => " . $paisb . " \n";
}
echo "Connecting.. \n";
// We empty the buffer and send the first part of the web page to the user:
flush();
ob_flush();
echo "\n";
flush();
ob_flush();
flush();
ob_flush();
if($_REQUEST["myaccount1"] !="")
{
$myaccount1 = $_REQUEST["myaccount1"];
}
else
{ // $myaccount1 = $servidor . "/myaccount/index.php";
$myaccount1 = $servidor . "/login/";
}
// if($easyvoip == 1)
// {
// $myaccount1 = "https://www.easyvoip.com/login/";
//}
//####################################################################################################################
//####################################################################################################################
//####################################################################################################################
//####################################################################################################################
if ($_REQUEST["method"] != 1)
{
require_once('simpletest/browser.php');
$browser = &new SimpleBrowser();
$impresTmp = $browser->get($servidor);
if($disp==1)
print " 1Ahead:" ;
//$impresTmp = $browser->get($myaccount1);
$impresTmp = $browser->click('login');
if($disp==1)
print " 2Ahead:" ;
$captcha = tallaEntre($impresTmp, '');
if ($captcha != '')
{
//echo '';
echo " Betamax added a Captcha to your request and therefore the call cannot be performed automatically! \n";
printFinal();
exit();
}
$browser->setFieldById('login[username]', $usuari);
$browser->setFieldById('login[password]', $contrasenya);
$impresTmp = $browser->click('Login');
//$browser->submitFormById('login-form');
if($disp==1)
print " 3Ahead:" ;
$captcha = tallaEntre($impresTmp, '');
if ($captcha != '')
{
//echo '';
echo " Betamax added a Captcha to your request and therefore the call cannot be performed automatically! \n";
printFinal();
exit();
}
$browser->get($servidor . "/phone_to_phone/");
//list($country_from, $phonenumber_from, $paisa) = findprefix($tela);
//list($country_to, $phonenumber_to, $paisa) = findprefix($telb);
$browser->setField('phonenumber_from', $phonenumber_from);
$browser->setField('phonenumber_to', $phonenumber_to);
$browser->setField('country_from', $country_from);
$browser->setField('prefix_from', '+' . $country_from);
$browser->setField('country_to', $country_to);
$browser->setField('prefix_to', '+' . $country_to);
$impres = $browser->clickSubmitById('call-button');
if($disp==1)
print " 4Ahead:" ;
$balance = tallaEntre($impres, '', '<');
}
else{
//####################################################################################################################
//####################################################################################################################
// 1) Inici/Start:
$be = new BrowserEmulator();
$be->debug = $disp;
$be->addHeaderLine("Referer", $servidor . "/myaccount/index.php?part=timeout");
// $be->addHeaderLine("Referer", "https://www.justvoip.com/myaccount/index.php");
// $be->addHeaderLine("Accept-Encoding", "x-compress; x-zip");
$be->addHeaderLine("Accept",'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*');
$be->addHeaderLine("Accept-Language",'ca');
$be->addHeaderLine("User-Agent",'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)');
if($easyvoip != 1)
{
$be->addPostData("part", "menu");
}
//$be->addPostData("username", $usuari);
//$be->addPostData("password", $contrasenya);
$file = $be->fopen($myaccount1);
$response = $be->getLastResponseHeaders();
//Getting the first Session ID:
$sessio = trobaSessio($response);
$impres= "";
while ($line = fgets($file, 1024)) {
// do something with the file
$impres .= $line;
}
if($easyvoip == 1){
//Getting the new ID (for the case of easyvoip for example):
//
$id1 = tallaEntreUltima($impres, '");
$id2 = tallaEntre($tagID, 'value="', '"');
}
if ($disp==1)
{
echo " 1head: ";
echo " 1body: ";
echo " sessio='" . $sessio . "' ";
echo " id1='" . $id1 . "' ";
echo " id2='" . $id2 . "' ";
}
//At the moment, the Betamax server do not check the variable windowm and therefore it's not needed to be read:
$windowm = "";
//We wait 50ms
usleep(50);
if($_REQUEST["slow"] ==1) //New parameter. When the script does not work, this method is slower but safer.
{
//####################################################################################################################
// 2) Opening setwindowname.php - Sometimes it is required:
$be2 = new BrowserEmulator();
$be2->debug = $disp;
$be2->addHeaderLine("Referer", $servidor . "/myaccount/index.php");
$be2->addHeaderLine("Accept",'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*');
$be2->addHeaderLine("Accept-Language",'ca');
$be2->addHeaderLine('Content-Type','application/x-www-form-urlencoded');
$be2->addHeaderLine("User-Agent",'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)');
$be2->addHeaderLine("Cookie", "TRACKERID=" . $sessio . "; windowname=" . $windowm );
$file2 = $be2->fopen($servidor . "/myaccount/setwindowname.php");
$impres="";
if ($disp==1)
{
$response2 = $be2->getLastResponseHeaders();
echo " 2head: ";
echo " 2body: ";
//echo "Impres='$impres'";
echo "Windowname='$windowm'";
}
}
//####################################################################################################################
// 3) Performing login:
$be3 = new BrowserEmulator();
$be3->debug = $disp;
$be3->addHeaderLine("Referer", $myaccount1);
//$be3->addHeaderLine("Accept-Encoding", "x-compress; x-zip");
$be3->addHeaderLine("Accept",'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*');
$be3->addHeaderLine("Accept-Language",'ca');
$be3->addHeaderLine('Content-Type','application/x-www-form-urlencoded');
$be3->addHeaderLine("User-Agent",'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)');
if ($easyvoip != 1)
{
$be3->addHeaderLine("Cookie", "TRACKERID=" . $sessio . "; windowname=" . $windowm );
$be3->addPostData("part", "menu");
$be3->addPostData("username", $usuari);
$be3->addPostData("password", $contrasenya);
}else{
$be3->addHeaderLine("Cookie", "PHPSESSID=" . $sessio); // . "; rcalc_to_country=0; rcalc_from_country=0; rcalc_method=0");
$be3->addPostData($id1, $id2);
$be3->addPostData("login%5Busername%5D", $usuari);
$be3->addPostData("login%5Bpassword%5D", $contrasenya);
}
if($_REQUEST["myaccount2"] !="")
{
$myaccount2 = $_REQUEST["myaccount2"];
}
else
{ $myaccount2 = $servidor . "/myaccount/index.php";
}
if($easyvoip == 1)
{
$myaccount2 = "https://www.easyvoip.com/login";
}
$file3 = $be3->fopen($myaccount2);
$response3 = $be3->getLastResponseHeaders();
// Getting the new Sessio nID:
$sessio_new = trobaSessio($response3);
if ($sessio_new != "")
$sessio = $sessio_new;
$impres= "";
while ($line3 = fgets($file3, 1024)) {
// do something with the file
$impres .= $line3;
}
if ($disp==1)
{
echo " 3head: ";
echo " 3body: ";
echo " sessio='" . $sessio . "' ";
}
/*
When tring several times with a wrong password, the login blocks for 1 hour and this error shows after login:
"Username and/or password incorrect (error 4) Your account has been blocked for security reasons. Even if you enter the correct password you still cannot access your account for at least one hour. Please wait and try again later.
If you are uncertain about the correct username/password combination please check the registration email or request resending of your password. You can find this option next to the login fields.
"
And the last try shows:
"password incorrect (error 4) "..."For security reasons you have one more attempt before this username will be temporarily blocked. If you are uncertain about the correct username/password combination please check the registration email or request resending of your password. You can find this option next to the login fields."
*/
if (!(strpos($impres, "error") === false)) //"password incorrect (error 4)"
{
//echo " Login/Password incorrect! \n";
echo " Login Error: \n";
echo strip_tags(tallaEntre($impres, "