"MYUSERNAME", "pass"=>"MYPASSWORD", "service"=>"MYSERVICE", "auth"=>"MYSECRET"), array("user"=>"MYUSERNAME", "pass"=>"MYPASSWORD", "service"=>"voipstunt"), array("user"=>"MYUSERNAME", "pass"=>"MYPASSWORD", "service"=>"sparvoip.de")); */ // // NO MORE SETTINGS TO EDIT BELOW THIS LINE ***************************************************************************** function usage() { $sOutput = "
\n";
$sOutput .= "usage: ".$_SERVER['PHP_SELF'].
"?cmd=[freedays|creditcents|call|sms|tariffwizard|callforward]&usernumber=usernumber&auth=yoursecret [monthsago|daysago|sourcenumber|smstext] [destinationnumber]
\n";
$sOutput .= " Extra options when sending an sms. After [destinationnumber] there is [monthtosend] [daytosend] [hourtosend] [minutetosend] [gmt](difference in hours) and [callerid]
\n";
$sOutput .= " Extra options when using the callforward command. After [destinationnumber] there is " .
"fwdtype=[-1|0|1|2|3] for Get current status, Never, Always, When offline and When offline or away.
\n";
$sOutput .= "
\n"; $sExUsage = $_SERVER['PHP_SELF']."?cmd=creditcents&usernumber=1&auth=yoursecret"; $sOutput .= "eg. ".$sExUsage."\n"; $sOutput .= "
\n"; $sOutput .= "\n";
$sOutput .= "You can also run this php script as a shell or cron job ...
\n";
$sOutput .= "/pathToPHP/php " . $_SERVER['PHP_SELF']." 'cmd=creditcents&usernumber=1&auth=yoursecret'
\n";
$sOutput .= "
\n"; $sOutput .= "Use the example form below to get started.\n"; $sOutput .= "
\n"; return $sOutput; } function html_select($sName,$aItems,$sSelected=""){ // Where $aItems is an array of POST VALUE => DISPLAY VALUE $sOutput = ""; $sOutput .= "\n"; return $sOutput; } function num_to_array($iNum,$iStart=1){ $aArray = ""; for ($i = $iStart; $i <= $iNum; $i++) { $aArray[$i] = $i; } return $aArray; } if (! function_exists('array_combine')) { // Exists from PHP5 function array_combine($a1, $a2){ if(count($a1) != count($a2)) return false; if(count($a1) <= 0) return false; $a1 = array_values($a1); $a2 = array_values($a2); $output = array(); for($i = 0; $i < count($a1); $i++) { $output[$a1[$i]] = $a2[$i]; } return $output; } } function print_form() { // TODO Get rid of these globals !!! global $sCommand, $aUsers, $iSourceNum, $iDestNum, $iFwdType, $sMsg, $iUserNumber, $sAuth, $iMonthToSend, $iDayToSend, $iHourToSend, $iMinuteToSend, $iGmtDiff, $iCallerId; $sOutput = "EXAMPLE FORM:\n"; $sOutput .= "
\n"; $sOutput .= "\n"; return $sOutput; } // Here we set all the required GETs $iUserNumber = (isset($_GET['usernumber'])) ? $_GET['usernumber'] : 1; // If unspecified then use the 1st user $sCommand = (isset($_GET['cmd'])) ? $_GET['cmd'] : ""; // Check for a command. $sAuth = (isset($_GET['auth'])) ? $_GET['auth'] : ""; // Auth if set. $iSourceNum = $_GET['sourcenumber']; $iDestNum = $_GET['destinationnumber']; $sMsg = $_GET['smstext']; // The optional sms vars. [monthtosend] [daytosend] [hourtosend] [minutetosend] [gmt difference in hours] $iMonthToSend = $_GET['monthtosend']; $iDayToSend = $_GET['daytosend']; $iHourToSend = $_GET['hourtosend']; $iMinuteToSend = $_GET['minutetosend']; $iGmtDiff = $_GET['gmt']; $iCallerId = $_GET['callerid']; // // The optional callforward vars. [fwdtype] $iFwdType = $_GET['fwdtype']; // // If there is an auth for this user check it if (isset($aUsers[($iUserNumber - 1)]['auth'])){ // iUserNumber - 1 because arrays start at 0 NOT 1 $sDebugAuth = ""; if ($sAuth <> ""){ if ( $aUsers[($iUserNumber - 1)]['auth'] <> $sAuth){ $bAuth = FALSE; // Auth required but did NOT match. $sDebugAuth .= " Auth required but did NOT match. You used auth=\"".$sAuth."\" for user number ".$iUserNumber."."; } else { $bAuth = TRUE; // Auth required and was correct. $sDebugAuth .= " Auth required and was correct."; } } else { $bAuth = FALSE; // Auth required but was not specified. ($_GET['auth'] NOT set) $sDebugAuth .= " Auth required but was not specified."; } } else { $bAuth = TRUE; // Auth NOT required. $sDebugAuth .= " Auth NOT required."; } if ( $bAuth === TRUE ){ // All ok then set-up the finarea account details. $USER = $aUsers[($iUserNumber - 1)]['user']; // iUserNumber - 1 because arrays start at 0 NOT 1 $PASS = $aUsers[($iUserNumber - 1)]['pass']; $SERVICE = $aUsers[($iUserNumber - 1)]['service']; $iMatchNonDotCom = preg_match('/\./', $SERVICE, $aMatches); // Look for a dot. if ( $iMatchNonDotCom == 0 ) { // .com Betamax service $iMatchURLType = preg_match('/intervoip/', $SERVICE, $aMatches); // Look for intervoip service print_r($aMatches); if ( $iMatchURLType == 0 ){ // Normal .com Betamax service // echo "Betamax .com type 1Destination number: | ".$iDestNum." |
Service provider URL: | ".$sUrl." |
Rate per Min.: | ".$iRatePerMinute." |
Call setup cost: | ".$iCallSetup." |