Универсальный PHP клиент для биллинговой системы NetUp UTM5 на основе api.xml
- Зависимости:
UTM 5.2.1-008+
PHP 5.3+
Bcmath
Filter
Hash
OpenSSL
SimpleXML
![Smile :)](./images/smilies/icon_smile.gif)
Код: Выделить всё
<function name="rpcf_user5_change_password_service" id="-0x4302">
<input>
<integer name="slink_id" />
<integer name="item_id" />
<string name="login" />
<string name="old_password" />
<string name="new_password" />
<string name="new_password_ret" />
</input>
<output>
<integer name="status" />
</output>
</function>
Да, вызывать можно любые функции. Выполните действия в ЛК и посмотрите в лог файле какие функции для этого используются.valaykhal писал(а):Скажите возмож ли поменя услуги абоненту средствами данного урфа клиента? Пример: абон вошел в личный кабинет. зашел в раздел IPTV и выбрал себе пакет тв, ему он добавился, прошло какое то время, чел вошел и выбрал другой пакет, старый пакет удалился. Возможно такое? управление в сервисных связках определенными услугами
Код: Выделить всё
Array
(
[dhs_log_size] => Array
(
[0] => Array
(
[id] => 6588597
[account_id] => 115
[slink_id] => 15631
[recv_date] => 1438403288
[last_update_date] => 1438413266
[Called_Station_Id] => 10.10.10.1
[Calling_Station_Id] => 10.10.7.14
[b] [framed_ip4] => 104.0.168.192[/b] наоборот
[framed_ip6] => ::
[nas_port] => 364
[acct_session_id] => 69688d7e6b128fb3
[nas_port_type] => 5
[uname] => user
[service_type] => 2
[framed_protocol] => 1
[nas_ip] => 67176970
[nas_id] => 10.10.10.1
[acct_status_type] => 2
[acct_inp_pack] => 22335.0000000
[acct_inp_oct] => 3571748.0000000
[acct_inp_giga] => 0.0000000
[acct_out_pack] => 29183.0000000
[acct_out_oct] => 25746045.0000000
[acct_out_giga] => 0.0000000
[acct_sess_time] => 9979.0000000
[acct_term_cause] => 0
[total_cost] =>
)
[1] => Array
(
[id] => 0
[account_id] => 0
[slink_id] => 6593245
[recv_date] => 115
[last_update_date] => 15631
[Called_Station_Id] => U�δ
[Calling_Station_Id] => U�ފ
[framed_ip4] =>
[framed_ip6] =>
[nas_port] => 73924776
[acct_session_id] =>
[nas_port_type] => 232
[uname] => 69688d7e6b18c522
[service_type] => 5
[framed_protocol] => 1802464879
[nas_ip] => 2
[nas_id] =>
[acct_status_type] => 67176970
[acct_inp_pack] => 3544383695537189168.0000000
[acct_inp_oct] =>
[acct_inp_giga] => 37546.0000000
[acct_out_pack] => 6852331.0000000
[acct_out_oct] => 0.0000000
[acct_out_giga] => 47403.0000000
[acct_sess_time] => 42833182.0000000
[acct_term_cause] => 0
[total_cost] => 2.0039302595321E-320
)
[2] => Array
(
[id] => 0
[account_id] => 0
[slink_id] => 0
[recv_date] => 0
[last_update_date] => 6594344
[Called_Station_Id] => s
[Calling_Station_Id] => =
[framed_ip4] =>
[framed_ip6] =>
[nas_port] => 825241137
[acct_session_id] => 10.10.7.14
[nas_port_type] => 73924776
[uname] =>
[service_type] => 230
[framed_protocol] => 909719096
[nas_ip] => 5
[nas_id] => konovalov
[acct_status_type] => 2
[acct_inp_pack] =>
[acct_inp_oct] =>
[acct_inp_giga] => 3544383695537189168.0000000
[acct_out_pack] =>
[acct_out_oct] => 122982.0000000
[acct_out_giga] => 19331435.0000000
[acct_sess_time] => 0.0000000
[acct_term_cause] => 0
[total_cost] => 6.9501214389355E-316
)
[3] => Array
(
[id] => 0
[account_id] => 0
[slink_id] => 0
[recv_date] => 0
[last_update_date] => 0
[Called_Station_Id] =>
[Calling_Station_Id] => d��
[framed_ip4] =>
[framed_ip6] =>
[nas_port] => 1438585017
[acct_session_id] => U�\�
[nas_port_type] => 825241137
[uname] => 10.10.7.14
[service_type] => 73924776
[framed_protocol] => 100663296
[nas_ip] => 29
[nas_id] => 69688d7e6b1e9e52
[acct_status_type] => 5
[acct_inp_pack] => 7741527709479693423.0000000
[acct_inp_oct] =>
[acct_inp_giga] =>
[acct_out_pack] =>
[acct_out_oct] => 3544383695537189168.0000000
[acct_out_giga] =>
[acct_sess_time] => 335961.0000000
[acct_term_cause] => 0
[total_cost] => 0
)
Код: Выделить всё
<function name="rpcf_get_dhs_report" id="0x5019">
<input>
<integer name="user_id" />
<integer name="account_id" />
<integer name="apid" />
<integer name="t_start" />
<integer name="t_end" />
</input>
<output>
<integer name="dhs_log_size" />
<for name="i" from="0" count="dhs_log_size">
<integer name="id" array_index="i" />
<integer name="account_id" array_index="i" />
<integer name="slink_id" array_index="i" />
<integer name="recv_date" array_index="i" />
<integer name="last_update_date" array_index="i" />
<string name="Called_Station_Id" array_index="i" />
<string name="Calling_Station_Id" array_index="i" />
<ip_address name="framed_ip4" array_index="i" />
<ip_address name="framed_ip6" array_index="i" />
<integer name="nas_port" array_index="i" />
<string name="acct_session_id" array_index="i" />
<integer name="nas_port_type" array_index="i" />
<string name="uname" array_index="i" />
<integer name="service_type" array_index="i" />
<integer name="framed_protocol" array_index="i" />
<integer name="nas_ip" array_index="i" />
<string name="nas_id" array_index="i" />
<integer name="acct_status_type" array_index="i" />
<long name="acct_inp_pack" array_index="i" />
<long name="acct_inp_oct" array_index="i" />
<long name="acct_inp_giga" array_index="i" />
<long name="acct_out_pack" array_index="i" />
<long name="acct_out_oct" array_index="i" />
<long name="acct_out_giga" array_index="i" />
<long name="acct_sess_time" array_index="i" />
<integer name="acct_term_cause" array_index="i" />
<double name="total_cost" array_index="i" />
<integer name="tmp" array_index="i" />
<integer name="online" array_index="i" />
</for>
</output>
</function>
Код: Выделить всё
<function name="rpcf_user5_set_next_tp" id="-0x15006">
<input>
<integer name="account_id" />
<integer name="tp_link" default="0"/>
<integer name="tp_next" default="0"/>
</input>
<output>
<integer name="result"/>
</output>
</function>
Код: Выделить всё
try { $urfa_admin = new URFAClient_Admin($UTMCore_Login,$UTMCore_Password);
} catch (Exception $exception) {
echo "Error in line ", $exception->getLine();
echo $exception->getMessage();
exit;}
foreach($payment_array as $key => $value) {
$payment_account = $key;
$payment_summa = $value['summa'];
$user_id = $value['user_id'];
$loyalty = get_loyalty($payment_account,$loyalty_config);
$bonus_summa = $payment_summa*$loyalty;
$str_log = "Лояльность : ".($loyalty * 100)."%, Аккаунт ".$payment_account.", User_ID=".$user_id." , Платеж = ".$payment_summa."р."." , Бонус = ".$bonus_summa."р.";
if ($loyalty<>0) {
$urfa_admin->rpcf_add_once_service_new(0, 0, $ServiceID, 'Бонус лояльности', '', 0, -$bonus_summa, 0); //0x2116
sleep(1);
$urfa_admin->rpcf_add_once_service_to_user($user_id,$payment_account,$ServiceID,0,0,time(),1,0); //0x2555
sleep(1);
}
Данная урфа работает с версии 5.2 (UTM 5.2.1-008+)apathy_sidex писал(а):Помогите пожалуйста адаптировать эти функции к 5.3.002-up 18 я так понимаю Ваша урфа работает с 5.3.002 но я не нашел этих функции в API
Код: Выделить всё
[shym@shym URFAClient]$ php cmd.php -f rpcf_add_once_service_new
array (
'parent_id' => 0,
'tariff_id' => 0,
'service_id' => 0,
'service_name' => '',
'comment' => '',
'link_by_default' => 0,
'cost' => 0,
'drop_from_group' => 0,
)
Код: Выделить всё
[shym@shym URFAClient]$ php cmd.php -f rpcf_add_once_slink_ex
array (
'user_id' => 0,
'account_id' => 0,
'service_id' => 0,
'tariff_link_id' => 0,
'discount_date' => 0,
'cost_coef' => 0,
)
Код: Выделить всё
//Deleting ipgroup
$report = $this->urfa->rpcf_remove_ip_from_slink(Array(
"slink_id" => $service_new['slink_id'],
"ip" => long2ip($service_new['ip_address']),
"mask" => $service_new['mask'],
"login" => $service_new['iptraffic_login'],
"mac" => $service_new['mac']
));
echo "<br \>" . var_dump($report) . "<br \>";
//Adding service for user with different Mac rest stays the same
$report = $this->urfa->rpcf_add_ip_to_slink( Array(
"slink_id" => $service_new['slink_id'],
"ip" => long2ip($service_new['ip_address']),
"mask" => $service_new['mask'],
"mac" => $mac
));
echo "<br \>" . var_dump($report) . "<br \>";
Код: Выделить всё
<!--Для rpcf_remove_ip_from_slink-->
Notice: Undefined offset: 0 in /usr/local/www/apache24/data/userside/urfa/lib/URFAClient/classes/URFAClient/Packet.php on line 95
Warning: unpack(): Type N: not enough input, need 4, have 0 in /usr/local/www/apache24/data/userside/urfa/lib/URFAClient/classes/URFAClient/Packet.php on line 275
Notice: Undefined offset: 1 in /usr/local/www/apache24/data/userside/urfa/lib/URFAClient/classes/URFAClient/Packet.php on line 139
array(2) { ["result"]=> NULL ["err_desc"]=> string(0) "" }
<!--Для rpcf_add_ip_to_slink-->
Notice: Undefined offset: 0 in /usr/local/www/apache24/data/userside/urfa/lib/URFAClient/classes/URFAClient/Packet.php on line 95
Warning: unpack(): Type N: not enough input, need 4, have 0 in /usr/local/www/apache24/data/userside/urfa/lib/URFAClient/classes/URFAClient/Packet.php on line 275
Notice: Undefined offset: 1 in /usr/local/www/apache24/data/userside/urfa/lib/URFAClient/classes/URFAClient/Packet.php on line 139
array(2) { ["result"]=> NULL ["err_desc"]=> string(0) "" }
Код: Выделить всё
$service_new['slink_id'] = "11736";
$all_service = $urfa->rpcf_get_iptraffic_service_link_ipv6($service_new);
$all_service["ip_groups_count"][0]["iptraffic_login"]="172.30.49.40";
$all_service["ip_groups_count"][0]["iptraffic_password"]="172.30.49.40";
$services_tariff = $urfa->rpcf_edit_iptraffic_service_link_ipv6($all_service);
print_r(URFAClient::trace_log());
UPD.[1] => 2016.05.23 14:46:20 ERROR: rpcf_edit_iptraffic_service_link_ipv6( Array ( [tariff_link_id] => 1741 [is_blocked] => 0 [discount_period_id] => 2171 [start_date] => 1392148800 [expire_date] => 2130706431 [policy_id] => 1 [cost_coef] => 1 [unabon] => 0 [unprepay] => 0 [tariff_id] => 73 [parent_id] => 2 [bandwidth_in] => 0 [bandwidth_out] => 0 [ip_groups_count] => Array ( [0] => Array ( [ip_address] => 192.168.0.10 [mask] => 32 [mac] => [iptraffic_login] => 172.30.49.40 [iptraffic_password] => 172.30.49.40 [iptraffic_allowed_cid] => [pool_name] => [ip_not_vpn] => 0 [dont_use_fw] => 0 [is_dynamic] => 0 [router_id] => 0 [switch_id] => 0 [port_id] => 0 [vlan_id] => 0 [pool_id] => 0 ) ) [quotas_count] => Array ( [0] => Array ( [tclass_id] => 0 [tclass_name] => Unknown [quota] => 0.0000000 ) [1] => Array ( [tclass_id] => 10 [tclass_name] => Входящий [quota] => 0.0000000 ) [2] => Array ( [tclass_id] => 20 [tclass_name] => Исходящий [quota] => 0.0000000 ) [3] => Array ( [tclass_id] => 30 [tclass_name] => локальный [quota] => 0.0000000 ) ) ) ): Not implemented for PHP x32
$service_new['slink_id'] = "11736";
$all_service = $urfa->rpcf_get_iptraffic_service_link_ipv6($service_new);
$all_service['slink_id'] = "11736";
$all_service["ip_groups_count"][0]["iptraffic_login"]="172.30.49.40";
$all_service["ip_groups_count"][0]["iptraffic_password"]="172.30.49.40";
unset($all_service["quotas_count"]);
$services_tariff = $urfa->rpcf_edit_iptraffic_service_link_ipv6($all_service);
print_r(URFAClient::trace_log());
Код: Выделить всё
Notice: Undefined index: j
Код: Выделить всё
if ( ! isset($sibling[0])) throw new Exception('Not provided an error, contact the developer (' . __FUNCTION__ . ')');
$name = (string) $sibling[0]->attributes()->{'name'};
$count = (int) $result[$name];
$array = array();
for ($i=0; $i<$count; $i++) $array[] = $this->_proccess_data_output($node, $packet);