включите в php вывод ошибок (error_reporting), проверьте подключенные модули php особенно opensslHighwayStar писал(а):Извиняюсь что повторяюсь, но скажите есть ли тут те, кто успешно использует urfaclient php на php 5.3? У меня при переходе на 5.3 не работает ни одна функция из URFAClient_User5.php
urfaclient на php
а за что отвечает последняя функция добавления? Разовая услуга?Kayfolom писал(а):
function URFA_Change_MAC($urfa_admin, $user_id, $account_id, $ip_wildcart, $MAC) {
$service_new['user_id'] = $user_id;
$service_new['account_id'] = $account_id;
// Выясняем id сервисной связки
$services = $urfa_admin->rpcf_get_all_services_for_user($service_new['account_id']);
foreach ($services['services'] as $key => $value) {
if ($services['services'][$key]['type']==3) {
$slink_id = $services['services'][$key]['slink_id'];
$service_new['service_id'] = $services['services'][$key]['id'];
$service_new['service_type'] = $services['services'][$key]['type'];
$service_new['slink_id'] = $services['services'][$key]['slink_id'];
}
}
// получаем список сервисов и список связок ip&mac в том числе
$services_tariff = $urfa_admin->rpcf_get_iptraffic_service_link($slink_id); // { //0x2702
// Получаем первый ip вида $ip_wildcart
$service_new['tariff_link_id'] = $services_tariff['tariff_link_id'];
$service_new['discount_period_id'] = $services_tariff['discount_period_id'];
$service_new['ip_groups_count'] = 1;
foreach ($services_tariff['ip_groups'] as $key => $value) {
$pos = strpos($services_tariff['ip_groups'][$key]['ip'], $ip_wildcart);
if ($pos!==false) {
$service_new['ip_groups'][0]['ip_address'] = $services_tariff['ip_groups'][$key]['ip'];
$service_new['ip_groups'][0]['mask'] = $services_tariff['ip_groups'][$key]['mask'];
$service_new['ip_groups'][0]['mac'] = $services_tariff['ip_groups'][$key]['mac'];
$service_new['ip_groups'][0]['iptraffic_login'] = $services_tariff['ip_groups'][$key]['login'];
$service_new['ip_groups'][0]['iptraffic_allowed_cid'] = $services_tariff['ip_groups'][$key]['allowed_cid'];
$service_new['ip_groups'][0]['iptraffic_password'] = $services_tariff['ip_groups'][$key]['password'];
$service_new['ip_groups'][0]['ip_not_vpn'] = $services_tariff['ip_groups'][$key]['not_vpn'];
$service_new['ip_groups'][0]['dont_use_fw'] = $services_tariff['ip_groups'][$key]['dont_use_fw'];
$service_new['ip_groups'][0]['router_id'] = $services_tariff['ip_groups'][$key]['router_id'];
break;
}
}
$service_new['ip_groups'][0]['mac'] = $MAC;
$report = $urfa_admin->rpcf_delete_from_ipgroup($service_new['slink_id'],$service_new['ip_groups'][0]['ip_address'],$service_new['ip_groups'][0]['mask']); //{ //0x5101
$report = $urfa_admin->rpcf_add_service_to_user($service_new); // { //0x2551
$urfa_admin->rpcf_add_once_service_to_user($service_new['user_id'],$service_new['account_id'],$id_once_service_registration,0,0,time(),1,0); //0x2555
}
}
скажите плиз из питона запускаю скрипт ... отрабатывает наполовину
скрипт
лог дебага
Код: Выделить всё
#import os
import subprocess
#User_Name= nat512
#IP_Address= 172.18.6.3
#os.system('/usr/bin/php -f /netup/utm5/urfaphp/add_ip.php User_Name IP_Address')
p = subprocess.Popen('/usr/bin/php -f /netup/utm5/urfaphp/add_ip.php nat512 172.18.6.3', shell=True)
Код: Выделить всё
[root@solomon urfaphp]# cat add_ip.php
<?php
echo "1 ".$argv[1]."\n"; //Name user
echo "2 ".$argv[2]."\n"; // IP user
@ini_set("display_errors", "1");
error_reporting(E_ALL);
require_once("/netup/utm5/urfaphp/URFAClient.php");
$UTMCore_Login='init';
$UTMCore_Password='Ld12turs#S';
$UTMCoreHost='127.0.0.1';
$UTMCorePort='11758';
try {
$urfa_user5 = new URFAClient_User5("nat512", "nat512",$UTMCoreHost,$UTMCorePort);
$urfa_admin = new URFAClient_Admin($UTMCore_Login, $UTMCore_Password);
} catch (Exception $exception) {
echo "Error in line ", $exception->getLine();
echo $exception->getMessage();
}
$UserName=$argv[1];
echo "UsName - ".$UserName."\n";
$dbhost="localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "UTM5007";
$link= mysql_connect($dbhost, $dbuser, $dbpass) or die("Ошибка подключения к серверу БД").mysql_errno();
$db_sel = mysql_select_db($dbname) or die("Ошибка выбора БД").mysql_errno();
$query = mysql_query("select id as user_id from users where login='$UserName'");
$row_query = mysql_fetch_array($query);
$UserID = $row_query['user_id'];
$user_id = $UserID;
$acc_id = $UserID;
$acc_ip = $argv[2];
echo "AcIP - ".$acc_ip."\n";
$acc_mac = '';
echo "UsID - ".$user_id."\n";
$service = array();
$service['service_type'] = 3;
$service['user_id'] = $user_id;
$service['account_id']= $acc_id;
$service['return_type'] = "integer_return";
$service['tariff_link_id'] = 0;
$service['is_blocked'] = 0;
$service['start_date'] = '';
$service['expire_date'] = ''; // 2000000000;
$service['unabon'] = 0;
$service['unprepay']= 0;
$service['ip_groups'] = array();
$service['ip_groups'][0]['ip_address'] = $acc_ip;
$service['ip_groups'][0]['mask'] = '255.255.255.255';
$service['ip_groups'][0]['mac'] = $acc_mac;
$service['ip_groups'][0]['iptraffic_login'] = "log_".$UserName;
echo "SerIpGroupLogin - ".$service['ip_groups'][0]['iptraffic_login']."\n";
$service['ip_groups'][0]['iptraffic_allowed_cid']= '';
$service['ip_groups'][0]['iptraffic_password'] = "log_".$UserName;
echo "SerIpGroupPass - ".$service['ip_groups'][0]['iptraffic_password']."\n";
$service['ip_groups'][0]['ip_not_vpn'] = 1;
$service['ip_groups'][0]['dont_use_fw'] = 0;
$service['ip_groups'][0]['router_id'] = 0;
$service['quotas'] = array();
$out = $urfa_admin->rpcf_get_all_services_for_user($acc_id);
print_r($out);
echo "FROM $out - ".$acc_id."\n";
if ($out=true) { echo " GOOOOOOD";} else { echo "BAAAAAD"; }
$count = count($out);
echo "Кол-во коунтов - ".$out."\n";
for($i = 0; $i < $count; $i ++)
{
if ($out['services'][$i]['type'] == $service['service_type'])
{
$service['service_id'] = $out['services'][$i]['id'];
$service['discount_period_id'] = $out['services'][$i]['period'];
$service['slink_id']= $out['services'][$i]['slink_id'];
}
}
echo $service['service_id']."<br>";
echo $service['discount_period_id']."<br>";
echo $service['slink_id']."<br>";
if ($out = $urfa_admin->rpcf_add_service_to_user($service)) { echo "Good Add IP \n";}
else { "BAD Add IP";}
//unset($UserName, $UserID, $user_id, $acc_id);
Код: Выделить всё
lomon log]# tail -f debug.log
?Debug : Apr 19 15:37:17 TransactionQueueManager: pushing transaction <0x8da4540> into queue <2> (default)
?Debug : Apr 19 15:37:17 TransactionHandlerImpl: push: transaction ptr <0x08da4540> (size 1, Events [ 114 ])
?Debug : Apr 19 15:37:17 TransactionHandlerImpl: incoming transaction ptr <0x08da4540>, outgoing transaction ptr <0xb5713d80>
?Debug : Apr 19 15:37:17 DBA:Ctx: Looking for free context (system=1)
?Debug : Apr 19 15:37:17 PluginManagerImpl: no registered plugin for event_id <114>
Info : Apr 19 15:37:17 TransactionHandlerImpl: plugin handler for event 114 not defined, event not handled
Info : Apr 19 15:37:17 TransactionHandlerImpl: some plugins not loaded due to license limitations, contact NetUP,Inc for more info
?Debug : Apr 19 15:37:17 TransactionFilter: transaction sent to the internal queue
?Debug : Apr 19 15:37:17 TransactionQueueManager: pushing transaction <0xb5713d80> into queue <1> (default)
?Debug : Apr 19 15:37:17 TransactionHandlerImpl: push: empty transaction ptr <0xb5713d80> dropped
?Debug : Apr 19 15:37:17 DummyTransactionQueue: commit: 0 transactions
?Debug : Apr 19 15:37:17 DBA:Ctx: Pushing back free context (system=1)
?Debug : Apr 19 15:37:17 TransactionHandlerImpl: incoming transaction ptr <0x08da4540> done
Info : Apr 19 15:37:34 RPCServer@0.0.0.0: Client connecting: 127.0.0.1:58152
Info : Apr 19 15:37:34 RPCConn: Connection from: 127.0.0.1:58152
Info : Apr 19 15:37:34 RPCConn: Card user <nat512@127.0.0.1> is connecting
?Debug : Apr 19 15:37:34 StreamManager: connection <26> created
Info : Apr 19 15:37:34 RPCConn<nat512@127.0.0.1>: Access granted to <nat512@127.0.0.1> (UID: 108)
Info : Apr 19 15:37:34 RPCServer@0.0.0.0: Client connecting: 127.0.0.1:58153
Info : Apr 19 15:37:34 RPCConn: Connection from: 127.0.0.1:58153
Info : Apr 19 15:37:34 RPCConn: Card user <init@127.0.0.1> is connecting
?Debug : Apr 19 15:37:34 DBA:Ctx: Looking for urgent DB context
?Debug : Apr 19 15:37:34 DBA Groups: Group: -1 from 1
?Debug : Apr 19 15:37:34 DBA:Ctx: Pushing back urgent DB context
-Stats : Apr 19 15:37:34 DBA Groups: Stats: Uptime: 00:00:00. Events: 0; Errors: 0
?Debug : Apr 19 15:37:34 StreamManager: connection <27> created
Info : Apr 19 15:37:34 RPCConn<init@127.0.0.1>: Access granted to <init@127.0.0.1> (UID: -1)
?Debug : Apr 19 15:37:34 RPCConn<init@127.0.0.1>: Call: 0x2700 (rpcf_get_all_services_for_user)
?Debug : Apr 19 15:37:34 RPCConn<init@127.0.0.1>: Real Call: 0x2700 (rpcf_get_all_services_for_user)
?Debug : Apr 19 15:37:34 RPCConn<init@127.0.0.1>: Call 0x2700 (rpcf_get_all_services_for_user) finished...
?Debug : Apr 19 15:37:34 RPCConn<init@127.0.0.1>: Stream cleared
Warn : Apr 19 15:37:34 RPCConn<init@127.0.0.1>: Session closed
?Debug : Apr 19 15:37:34 RPCConn<init@127.0.0.1>: Session stored for UID -1 from <127.0.0.1>
Warn : Apr 19 15:37:34 RPCConn<nat512@127.0.0.1>: Session closed
?Debug : Apr 19 15:37:34 StreamManager: connection <27> closed
?Debug : Apr 19 15:37:34 RPCConn<init@127.0.0.1>: Session closed...
?Debug : Apr 19 15:37:34 RPCConn<nat512@127.0.0.1>: Session stored for UID 108 from <127.0.0.1>
?Debug : Apr 19 15:37:34 StreamManager: connection <26> closed
?Debug : Apr 19 15:37:34 RPCConn<nat512@127.0.0.1>: Session closed...
Может ли кто-нибудь выслать рабочую пропатченную версию urfaphp под 008? php 5.1.6
chostik@mail.ru
Заранее благодарен.
chostik@mail.ru
Заранее благодарен.
вот по логам отдебажил не пойму дальше вызова первой функции не идет
Код: Выделить всё
[root@solomon staticDHCPd-1.5.4]# pychecker test_ex.py
Processing test_ex...
1 nat512
2 172.18.6.3
UsName - nat512
AcIP - 172.18.6.3
UsID - 108
SerIpGroupLogin - log_nat512
SerIpGroupPass - log_nat512
Array
(
[service_type] => 3
[user_id] => 108
[account_id] => 108
[return_type] => integer_return
[tariff_link_id] => 0
[is_blocked] => 0
[start_date] =>
[expire_date] =>
[unabon] => 0
[unprepay] => 0
[ip_groups] => Array
(
[0] => Array
(
[ip_address] => 172.18.6.3
[mask] => 255.255.255.255
[mac] =>
[iptraffic_login] => log_nat512
[iptraffic_allowed_cid] =>
[iptraffic_password] => log_nat512
[ip_not_vpn] => 1
[dont_use_fw] => 0
[router_id] => 0
)
)
[quotas] => Array
(
)
)
Код: Выделить всё
require_once("/netup/utm5/urfaphp/URFAClient.php");
$UTMCore_Login='init';
$UTMCore_Password='Ld12turs#S';
$UTMCoreHost='127.0.0.1';
$UTMCorePort='11758';
try {
$urfa_user5 = new URFAClient_User5("nat512", "nat512",$UTMCoreHost,$UTMCorePort);
$urfa_admin = new URFAClient_Admin($UTMCore_Login, $UTMCore_Password);
} catch (Exception $exception) {
echo "Error in line ", $exception->getLine();
echo $exception->getMessage();
}
$UserName=$argv[1];
echo "UsName - ".$UserName."\n";
$dbhost="localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "UTM5007";
$link= mysql_connect($dbhost, $dbuser, $dbpass) or die("Ошибка подключения к серверу БД").mysql_errno();
$db_sel = mysql_select_db($dbname) or die("Ошибка выбора БД").mysql_errno();
$query = mysql_query("select id as user_id from users where login='$UserName'");
$row_query = mysql_fetch_array($query);
$UserID = $row_query['user_id'];
$user_id = $UserID;
$acc_id = $UserID;
$acc_ip = $argv[2];
echo "AcIP - ".$acc_ip."\n";
$acc_mac = '';
echo "UsID - ".$user_id."\n";
$service = array();
$service['service_type'] = 3;
$service['user_id'] = $user_id;
$service['account_id']= $acc_id;
$service['return_type'] = "integer_return";
$service['tariff_link_id'] = 0;
$service['is_blocked'] = 0;
$service['start_date'] = '';
$service['expire_date'] = ''; // 2000000000;
$service['unabon'] = 0;
$service['unprepay']= 0;
$service['ip_groups'] = array();
$service['ip_groups'][0]['ip_address'] = $acc_ip;
$service['ip_groups'][0]['mask'] = '255.255.255.255';
$service['ip_groups'][0]['mac'] = $acc_mac;
$service['ip_groups'][0]['iptraffic_login'] = "log_".$UserName;
echo "SerIpGroupLogin - ".$service['ip_groups'][0]['iptraffic_login']."\n";
$service['ip_groups'][0]['iptraffic_allowed_cid']= '';
$service['ip_groups'][0]['iptraffic_password'] = "log_".$UserName;
echo "SerIpGroupPass - ".$service['ip_groups'][0]['iptraffic_password']."\n";
$service['ip_groups'][0]['ip_not_vpn'] = 1;
$service['ip_groups'][0]['dont_use_fw'] = 0;
$service['ip_groups'][0]['router_id'] = 0;
$service['quotas'] = array();
print_r ($service)."\n";
$out = $urfa_admin->rpcf_get_all_services_for_user($acc_id);
$count = count($out);
print_r ($count)."\n";
for($i = 0; $i < $count; $i ++)
{
if ($out['services'][$i]['type'] == $service['service_type'])
{
$service['service_id'] = $out['services'][$i]['id'];
$service['discount_period_id'] = $out['services'][$i]['period'];
$service['slink_id']= $out['services'][$i]['slink_id'];
}
}
echo $service['service_id']."<br>";
echo $service['discount_period_id']."<br>";
echo $service['slink_id']."<br>";
$out = $urfa_admin->rpcf_add_service_to_user($service);
возможно высылать ничего не надо... вроде кое-что заработало
только вот при вызове функции
выходит ошибка
Fatal error: Call to undefined function bcmul() in /home/reginaweb/urfaphp/URFAClient_Packet.php on line 212
в чём дело не подскажете?
у меня php 5.1.6 .... и по ходу bcmul - это функция умножения двух чисел... у меня отсутствует.... куда копать?
только вот при вызове функции
выходит ошибка
Fatal error: Call to undefined function bcmul() in /home/reginaweb/urfaphp/URFAClient_Packet.php on line 212
в чём дело не подскажете?
у меня php 5.1.6 .... и по ходу bcmul - это функция умножения двух чисел... у меня отсутствует.... куда копать?
-
- Сообщения: 13
- Зарегистрирован: Вт окт 18, 2011 15:12
- Откуда: Россия
Ошибка оказалась в файле URFAClient_Packet.php в функции function AttrGetInt($code)HighwayStar писал(а):Извиняюсь что повторяюсь, но скажите есть ли тут те, кто успешно использует urfaclient php на php 5.3? У меня при переходе на 5.3 не работает ни одна функция из URFAClient_User5.php
При запуске example.php выдаетэтот же код работает на php 5.2.Код: Выделить всё
Error calling function rpcf_user5_get_services
Где искать ошибку? в логах биллинга при выполнении example.php появлются строки:Код: Выделить всё
Warn : Apr 13 22:10:05 RPCConn<apache@192.168.1.2>: Session closed Warn : Apr 13 22:10:05 RPCConn<testoke@10.254.254.3>: Session closed
Решение нашел несколькими страницами ранее
Проблема решена, рабочий скрипт добавления тарифа и двух услуг в нем (иптрафик и абонплата)
код
код
Код: Выделить всё
URFA_add_tarif($urfa_admin, "1064", "1070","56",1, "172.20.20.20","255.255.255.255","logintest","password");
function URFA_add_tarif ($urfa_admin, $user_id, $account_id, $tariff_id, $discount_period_id, $ip_add, $netmask_add, $login_add, $password_add)
{
# Получаем информацию об услугах тарифа
$tsvc = $urfa_admin->rpcf_get_tariff($tariff_id);
print_r($tsvc);
//Подключаем тариф
$tariff_link_id = $urfa_admin->rpcf_link_user_tariff($user_id,$account_id,$tariff_id,$tariff_id,$discount_period_id);
print_r($tariff_link_id);
# Поделючение всех услуг
$max = count($tsvc['services']);
for ( $i = 0; $i < $max; $i++ )
{
$srv_in_tarif = $tsvc['services'][$i];
echo "<br>srv_i=$srv_i";
echo "<br>srv_in_tarif=";
print_r($srv_in_tarif);
echo "<br>";
$service_new = array();
$service_new['user_id'] = $user_id;
$service_new['account_id'] = $account_id;
$service_new['return_type'] = '';
$service_new['service_id'] = $srv_in_tarif['service_id'];
$service_new['service_type'] = $srv_in_tarif['service_type'];
$service_new['tariff_link_id'] = $tariff_link_id['tariff_link_id'];
if ( $srv_in_tarif['service_type'] == '2' ) {
# Периодическая услуга
$service_new['slink_id'] = 0;
$service_new['is_blocked'] = 0;
$service_new['discount_period_id'] = $discount_period_id;
$service_new['start_date'] = time();
$service_new['expire_date'] = mktime(0,0,0,1,1,2020);;
$service_new['unabon'] = 0;
$service_new['unprepay'] = 0;
}
if ( $srv_in_tarif['service_type'] == '3' )
{
# Передача трафика
$service_new['slink_id'] = 0;
$service_new['is_blocked'] = 0;
$service_new['discount_period_id'] = $discount_period_id;
$service_new['start_date'] = time();
$service_new['expire_date'] = mktime(0,0,0,1,1,2020);;
$service_new['unabon'] = 0;
$service_new['unprepay'] = 0;
# Подключаем IP
$service_new['ip_groups'][] = array(
'ip_address' => $ip_add,
'mask' => $netmask_add,
'iptraffic_login'=> $login_add,
'iptraffic_password'=> $password_add,
'ip_not_vpn' => 0,
'dont_use_fw' => 0
);
$service_new['quota'] = array();
}
print_r($service_new);
# Добавляем услугу
$report = $urfa_admin->rpcf_add_service_to_user($service_new);
print_r($report);
}
}