Код: Выделить всё
<?php
#-------------------------------------------------------------------------------
/** @author Rootden for Lowhosting.ru */
/******************************************************************************/
/******************************************************************************/
Eval(COMP_INIT);
if(Is_Error(System_Load('libs/Http.php')))
return ERROR | @Trigger_Error(500);
/******************************************************************************/
function internetbs_parseResult($data) {
$result = array ();
$arr = explode ( "\n", $data );
foreach ( $arr as $str ) {
list ( $varName, $value ) = explode ( "=", $str, 2 );
$varName = trim ( $varName );
$value = trim ( $value );
$result [$varName] = $value;
}
return $result;
}
#------------------------------------------------------------------------------------------------------------
# GET BALANS SPSPILOT
$commandUrl = "/api.php?balance=sms&apikey=*********************";
$Http = Array(
'Address' => 'smspilot.ru',
'Port' => 80,
'Host' => 'smspilot.ru'
);
$Result = Http_Send($commandUrl,$Http,Array());
if(Is_Error($Result))
return ERROR | @Trigger_Error('[GET_SMSpilot_Balans]:не удалось выполнить запрос к серверу');
#Debug(Print_r($Result));
$sms = trim($Result['Body']*1);
#------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------
# GET BALANS InternetBS
$commandUrl = "/Account/Balance/Get?ApiKey=********&Password=********";
$Http = Array(
'Address' => 'api.internet.bs',
'Port' => '443',
'Protocol' => 'ssl',
'Host' => 'api.internet.bs'
);
$Result = Http_Send($commandUrl,$Http,Array());
if(Is_Error($Result))
return ERROR | @Trigger_Error('[GET_SMSpilot_Balans]:не удалось выполнить запрос к серверу');
$Result = Trim($Result['Body']);
$Result = internetbs_parseResult($Result);
if (isset($Result['status']) && $Result['status'] == 'SUCCESS'){
$ibs = trim($Result['balance_0_amount']*1);
}else{
$ibs = 'bad';
}
#Debug(Print_r($Result));
#Debug("Key = " . $Result['status']);
#------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------
# GET BALANS 2domains
$commandUrl = '/reg/api/';
$Http = Array(
'Address' => '2domains.ru',
'Port' => '443',
'Protocol' => 'ssl',
'Host' => '2domains.ru'
);
$Query = Array(
'action' => 'balance_get',
'username' => ' **************** ',
'password' => ' ************** ',
);
$Result = Http_Send($commandUrl,$Http,Array(),$Query);
if(Is_Error($Result))
return ERROR | @Trigger_Error('[GET_SMSpilot_Balans]:не удалось выполнить запрос к серверу');
$Result = Trim($Result['Body']);
if(Preg_Match('/Success:/',$Result)){
$s = explode(' ', $Result);
$dba = $s[4];
}else{
$dba = 'bad';
}
#------------------------------------------------------------------------------------------------------------
$Table = Array('Состояние баланса');
$Table[] = Array(new Tag('A',Array('href'=>SPrintF('http://www.smspilot.ru/my.php'),'target'=>'blank','title'=>'Пополнить'),'Смс пилот'),$sms .'шт');
$Table[] = Array(new Tag('A',Array('href'=>SPrintF('https://internetbs.net/ru/domain-name-registrations/controller.html?action=HomePageAction'),'target'=>'blank','title'=>'Пополнить'),'InternetBS'),$ibs .' $');
$Table[] = Array(new Tag('A',Array('href'=>SPrintF('https://2domains.ru/reg/login.php'),'target'=>'blank','title'=>'Пополнить'),'2domains'),$dba .' руб');
#------------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------
$Comp = Comp_Load('Tables/Standard',$Table);
if(Is_Error($Comp))
return ERROR | @Trigger_Error(500);
#---------------------------------------------------------------------------
return Array('Title'=>'Мой виджет','DOM'=>$Comp);
#-------------------------------------------------------------------------------
?>