Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function open_logs($CONF_LOG) {
- return fopen($CONF_LOG, "a");
- }
- function do_log($stdlog, $text_log) {
- fputs($stdlog, get_date() . " " . $text_log . "\n");
- }
- function do_log_sql($stdlog, $text_log, $child) {
- $LINK = $GLOBALS["LINK"];
- if (!mysql_ping($LINK)) {
- $do_mysql_reconect = 1;
- fputs($stdlog, get_date() . " " . $text_log . "\n");
- fputs($stdlog, get_date() . " " . "Child " . $child . " MySQL Connect failed" . "\n");
- }
- else {
- fputs($stdlog, get_date() . " " . $text_log . "\n");
- }
- while ($do_mysql_reconect == 1) {
- $config_file = "../etc/config.xml";
- if (file_exists($config_file)) {
- $xml = simplexml_load_file($config_file);
- $CONF_MYSQL_HOST = (string)$xml->parameters->mysql->host;
- $CONF_MYSQL_USERNAME = (string)$xml->parameters->mysql->username;
- $CONF_MYSQL_PASSWORD = (string)$xml->parameters->mysql->password;
- $CONF_MYSQL_DBNAME = (string)$xml->parameters->mysql->dbname;
- }
- $GLOBALS["LINK"] = mysql_pconnect($CONF_MYSQL_HOST, $CONF_MYSQL_USERNAME, $CONF_MYSQL_PASSWORD);
- mysql_select_db($CONF_MYSQL_DBNAME, $LINK);
- mysql_query("SET NAMES koi8r", $LINK) || do_log_sql($stdlog, "#0000 " . mysql_error($GLOBALS["LINK"]), $child);
- mysql_query("SET NAMES koi8r", $LINK) || do_log_sql($stdlog, "#0000 " . mysql_error($GLOBALS["LINK"]), $child);
- mysql_query("SET CHARSET koi8r", $LINK) || do_log_sql($stdlog, "#0000 " . mysql_error($GLOBALS["LINK"]), $child);
- mysql_query("SET CHARSET koi8r", $LINK) || do_log_sql($stdlog, "#0000 " . mysql_error($GLOBALS["LINK"]), $child);
- if (mysql_ping($LINK)) {
- $do_mysql_reconect = 0;
- fputs($stdlog, get_date() . " " . "Child " . $child . " MySQL Connect restored" . "\n");
- }
- sleep(5);
- continue;
- }
- $return_var = false;
- return $return_var;
- }
- function get_date() {
- $date_current = date("d.m.Y H:i:s");
- return $date_current;
- }
- function billing_init_packets_pool($LINK, $stdlog, $child) {
- $packets = (array());
- $i = 0;
- $result = mysql_query("SELECT * FROM " . BILL_IPPOOL_PACKET_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#132 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_IPPOOL_PACKET_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#132 " . mysql_error($LINK), $child);
- while ($i < mysql_num_rows($result)) {
- $i++;
- $res = mysql_fetch_array($result);
- $packets[$i] = $res;
- continue;
- }
- mysql_free_result($result);
- return $packets;
- }
- function billing_init_pools($LINK, $stdlog, $child) {
- $packets = (array());
- $i = 0;
- $result = mysql_query("SELECT poolid,usegw,poolmask,poolgw FROM " . BILL_IPPOOL . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#145 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT poolid,usegw,poolmask,poolgw FROM " . BILL_IPPOOL . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#145 " . mysql_error($LINK), $child);
- while ($i < mysql_num_rows($result)) {
- $i++;
- $res = mysql_fetch_array($result);
- $packets[$res["poolid"]] = $res;
- continue;
- }
- mysql_free_result($result);
- return $packets;
- }
- function billing_init_packets($LINK, $stdlog, $child) {
- $packets = (array());
- $i = 0;
- $result = mysql_query("SELECT * FROM " . BILL_PACKET_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#1 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_PACKET_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#1 " . mysql_error($LINK), $child);
- while ($i < mysql_num_rows($result)) {
- $i++;
- $res = mysql_fetch_array($result);
- $packets[$res["gid"]] = $res;
- continue;
- }
- mysql_free_result($result);
- return $packets;
- }
- function billing_init_sectors($LINK, $stdlog, $child) {
- $sectors = (array());
- $i = 0;
- $result = mysql_query("SELECT * FROM " . BILL_SECTORS_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#157 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_SECTORS_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#157 " . mysql_error($LINK), $child);
- while ($i < mysql_num_rows($result)) {
- $i++;
- $res = mysql_fetch_array($result);
- $sectors[$res["sectorid"]] = $res;
- continue;
- }
- mysql_free_result($result);
- return $sectors;
- }
- function billing_init_switch($LINK, $stdlog, $child) {
- $switches = (array());
- $i = 0;
- $result = mysql_query("SELECT * FROM " . BILL_SWITCH_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#170 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_SWITCH_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#170 " . mysql_error($LINK), $child);
- while ($i < mysql_num_rows($result)) {
- $i++;
- $res = mysql_fetch_array($result);
- $switches[$res["swid"]] = $res;
- continue;
- }
- mysql_free_result($result);
- return $switches;
- }
- function billing_init_nas($LINK, $stdlog, $child) {
- $sql_init_nas = "SELECT * FROM " . BILL_NAS_TABLE;
- $nases = (array());
- $i = 0;
- $result = mysql_query($sql_init_nas, $LINK) || do_log_sql($stdlog, "#2 " . mysql_error($LINK), $child);
- $result = mysql_query($sql_init_nas, $LINK) || do_log_sql($stdlog, "#2 " . mysql_error($LINK), $child);
- while ($i < mysql_num_rows($result)) {
- $i++;
- $res = mysql_fetch_array($result);
- $nases[$res["nasname"]] = $res;
- continue;
- }
- mysql_free_result($result);
- return $nases;
- }
- function get_card_from_active_cards($LINK, $stdlog, $child, $password) {
- $SQL = "SELECT " . BILL_CARDS_ACTIVATE_CARD . ".cardactid," . BILL_CARDS_ACTIVATE_CARD . ".serieid," . BILL_CARDS_ACTIVATE_CARD . ".secret," . BILL_CARDS_ACTIVATE_CARD . ".status, " . BILL_CARDS_ACTIVATE_SERIE . ".serie," . BILL_CARDS_ACTIVATE_SERIE . ".serieid, " . BILL_CARDS_ACTIVATE_SERIE . ".gid," . BILL_CARDS_ACTIVATE_SERIE . ".deposit," . BILL_CARDS_ACTIVATE_SERIE . ".credit," . BILL_CARDS_ACTIVATE_SERIE . ".expired," . BILL_CARDS_ACTIVATE_SERIE . ".active FROM " . BILL_CARDS_ACTIVATE_CARD . "," . BILL_CARDS_ACTIVATE_SERIE . " WHERE " . BILL_CARDS_ACTIVATE_CARD . ".secret LIKE '" . $password . "' and " . BILL_CARDS_ACTIVATE_CARD . ".serieid=" . BILL_CARDS_ACTIVATE_SERIE . ".serieid";
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#70 " . mysql_error($LINK), $child);
- $result = mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#70 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_ip_from_pool_unknown($LINK, $stdlog, $system_options, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_IPPOOL_POOL . " WHERE poolid = " . $system_options["accl_unk_ippololid"] . " ORDER BY RAND() LIMIT 1 ", $LINK) || do_log_sql($stdlog, "#3 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_IPPOOL_POOL . " WHERE poolid = " . $system_options["accl_unk_ippololid"] . " ORDER BY RAND() LIMIT 1 ", $LINK) || do_log_sql($stdlog, "#3 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_ip_from_pool_bez_deneg($LINK, $stdlog, $system_options, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_IPPOOL_POOL . " WHERE poolid = " . $system_options["dolgnik_ippololid"] . " ORDER BY RAND() LIMIT 1 ", $LINK) || do_log_sql($stdlog, "#3 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_IPPOOL_POOL . " WHERE poolid = " . $system_options["dolgnik_ippololid"] . " ORDER BY RAND() LIMIT 1 ", $LINK) || do_log_sql($stdlog, "#3 " . mysql_error($LINK), $child);
- return $res;
- }
- function check_if_dolg_ip_pool($LINK, $stdlog, $RAD_REQUEST, $system_options, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_IPPOOL_POOL_USE . " WHERE poolid = " . $system_options["dolgnik_ippololid"] . " AND poolip='" . $RAD_REQUEST["Framed-IP-Address"] . "' ", $LINK) || do_log_sql($stdlog, "#38 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_IPPOOL_POOL_USE . " WHERE poolid = " . $system_options["dolgnik_ippololid"] . " AND poolip='" . $RAD_REQUEST["Framed-IP-Address"] . "' ", $LINK) || do_log_sql($stdlog, "#38 " . mysql_error($LINK), $child);
- if ($res != false) {
- $res = true;
- }
- return $res;
- }
- function get_ip_from_pool($LINK, $stdlog, $gid, $system_options, $child, $packets_pool) {
- $tmp = 0;
- $subquerry = "";
- foreach ($packets_pool as $key => $value) {
- if ($value["gid"] == $gid) {
- if ($tmp == 0) {
- $subquerry = $value["poolid"];
- $tmp = 1;
- }
- else {
- $subquerry .= "," . $value["poolid"];
- }
- }
- continue;
- }
- $querry = "SELECT poolip,poolid\n\tFROM " . BILL_IPPOOL_POOL . ",\n\t(SELECT FLOOR(MAX(" . BILL_IPPOOL_POOL . ".id) * RAND()) AS randId FROM " . BILL_IPPOOL_POOL . ") AS someRandId\n\tWHERE " . BILL_IPPOOL_POOL . ".id = someRandId.randId AND " . BILL_IPPOOL_POOL . ".poolid IN (" . $subquerry . ")";
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query($querry, $LINK) || do_log_sql($stdlog, "#3dddddd " . mysql_error($LINK), $child);
- $result = mysql_query($querry, $LINK) || do_log_sql($stdlog, "#3dddddd " . mysql_error($LINK), $child);
- return $res;
- }
- function billing_init_price_floors($LINK, $stdlog, $child) {
- $i = 0;
- $result = mysql_query("SELECT gid, floor FROM " . BILL_PRICES_TABLE . " WHERE 1 GROUP BY gid, floor ORDER BY gid ", $LINK) || do_log_sql($stdlog, "#4 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT gid, floor FROM " . BILL_PRICES_TABLE . " WHERE 1 GROUP BY gid, floor ORDER BY gid ", $LINK) || do_log_sql($stdlog, "#4 " . mysql_error($LINK), $child);
- while ($i < mysql_num_rows($result)) {
- $i++;
- $res = mysql_fetch_array($result);
- $price_floors[$res["gid"]] = $res;
- continue;
- }
- mysql_free_result($result);
- return $price_floors;
- }
- function billing_init_prices($LINK, $stdlog, $child) {
- $i = 0;
- $result = mysql_query("SELECT * FROM " . BILL_PRICES_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#5 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_PRICES_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#5 " . mysql_error($LINK), $child);
- while ($i < mysql_num_rows($result)) {
- $i++;
- $res = mysql_fetch_array($result);
- $key = $res["gid"] . $res["week_day"] . $res["floor"];
- $price_diff[$key] = $res;
- continue;
- }
- mysql_free_result($result);
- return $price_diff;
- }
- function billing_init_system_options($LINK, $stdlog, $child) {
- $options = (array());
- $i = 0;
- $result = mysql_query("SELECT * FROM " . BILL_SYSTEM_OPTIONS_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#6EDF " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_SYSTEM_OPTIONS_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#6EDF " . mysql_error($LINK), $child);
- while ($i < mysql_num_rows($result)) {
- $i++;
- $res = mysql_fetch_array($result);
- $options[$res["key"]] = $res["value"];
- continue;
- }
- mysql_free_result($result);
- return $options;
- }
- function billing_init_sysopts($LINK, $stdlog, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_SYSPOTS_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#6 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_SYSPOTS_TABLE . " WHERE 1 ", $LINK) || do_log_sql($stdlog, "#6 " . mysql_error($LINK), $child);
- return $res;
- }
- function billing_init_version($LINK, $stdlog, $child) {
- $version = "2.8.16";
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $version = $res["version"];
- $result = mysql_query("SELECT get_version() as version; ", $LINK) || do_log_sql($stdlog, "#335 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT get_version() as version; ", $LINK) || do_log_sql($stdlog, "#335 " . mysql_error($LINK), $child);
- return $version;
- }
- function billing_init_count($LINK, $stdlog, $child) {
- $count = 0;
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $count = $count + $res["count"];
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $count = $count + $res["count"];
- $res["count"] = $count;
- $result = mysql_query("SELECT count(uid) as count FROM " . BILL_AUTH_TABLE . " ", $LINK) || do_log_sql($stdlog, "#40 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT count(uid) as count FROM " . BILL_AUTH_TABLE . " ", $LINK) || do_log_sql($stdlog, "#40 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT count(uid) as count FROM " . BILL_USERFREEZE_TABLE . " ", $LINK) || do_log_sql($stdlog, "#40 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT count(uid) as count FROM " . BILL_USERFREEZE_TABLE . " ", $LINK) || do_log_sql($stdlog, "#40 " . mysql_error($LINK), $child);
- return $res;
- }
- function user_coa($RAD_REQUEST, $system_options, $nases) {
- $NAS_TYPE = $nases[$RAD_REQUEST["NAS-IP-Address"]]["nastype"];
- $SNMP_RW = $nases[$RAD_REQUEST["NAS-IP-Address"]]["secret"];
- $INPUT_PORT = $nases[$RAD_REQUEST["NAS-IP-Address"]]["impruport"];
- if (strlen($RAD_REQUEST["User-Name"]) == 17) {
- $user = $RAD_REQUEST["User-Name"];
- }
- else {
- $user = $RAD_REQUEST["Called-Station-Id"];
- }
- if ($NAS_TYPE == "accelipoe") {
- $command = $system_options["sudo"] . " " . $system_options["ECHO"] . " \"User-Name=" . $user . ",Framed-IP-Address=" . $RAD_REQUEST["Framed-IP-Address"] . "\" | " . $system_options["exec_radclient"] . " -r 1 " . $RAD_REQUEST["NAS-IP-Address"] . ":" . $INPUT_PORT . " disconnect " . $SNMP_RW . " &>/dev/null 2>&1 ";
- }
- if (isset($command)) {
- exec($command);
- }
- }
- function user_kill($RAD_REQUEST, $system_options, $nases) {
- $NAS_TYPE = $nases[$RAD_REQUEST["NAS-IP-Address"]]["nastype"];
- $SNMP_RW = $nases[$RAD_REQUEST["NAS-IP-Address"]]["secret"];
- $INPUT_PORT = $nases[$RAD_REQUEST["NAS-IP-Address"]]["impruport"];
- if ($NAS_TYPE == "cisco") {
- $command = $system_options["sudo"] . " " . $system_options["ECHO"] . " \"User-Name=\\\"" . $RAD_REQUEST["User-Name"] . "\\\",Cisco-AVPair=\\\"subscriber:command=account-logoff\\\",Framed-IP-Address=" . $RAD_REQUEST["Framed-IP-Address"] . "\" | " . $system_options["exec_radclient"] . " -r 1 " . $RAD_REQUEST["NAS-IP-Address"] . ":" . $INPUT_PORT . " coa " . $SNMP_RW . " &>/dev/null 2>&1 ";
- }
- if ($NAS_TYPE == "finger") {
- $command = $system_options["sudo"] . " " . $system_options["CLRLINE_PORTSLAVE"] . " reset:" . $SNMP_RW . ":S" . $RAD_REQUEST["NAS-Port"] . "\\@" . $RAD_REQUEST["NAS-IP-Address"] . " &>/dev/null 2>&1 ";
- }
- if ($NAS_TYPE == "pppd") {
- $command = $system_options["sudo"] . " " . $system_options["ECHO"] . " \"NAS-Port=" . $RAD_REQUEST["NAS-Port"] . ",User-Name=" . $RAD_REQUEST["User-Name"] . ",Framed-IP-Address=" . $RAD_REQUEST["Framed-IP-Address"] . "\" | " . $system_options["exec_radclient"] . " -r 1 " . $RAD_REQUEST["NAS-IP-Address"] . ":" . $INPUT_PORT . " disconnect " . $SNMP_RW . " &>/dev/null 2>&1 ";
- }
- if ($NAS_TYPE == "accelppp") {
- $command = $system_options["sudo"] . " " . $system_options["ECHO"] . " \"NAS-Port=" . $RAD_REQUEST["NAS-Port"] . ",User-Name=" . $RAD_REQUEST["User-Name"] . ",Framed-IP-Address=" . $RAD_REQUEST["Framed-IP-Address"] . "\" | " . $system_options["exec_radclient"] . " -r 1 " . $RAD_REQUEST["NAS-IP-Address"] . ":" . $INPUT_PORT . " disconnect " . $SNMP_RW . " &>/dev/null 2>&1 ";
- }
- if ($NAS_TYPE == "se100") {
- $command = $system_options["sudo"] . " " . $system_options["ECHO"] . " \"User-Name=" . $RAD_REQUEST["User-Name"] . ",Framed-IP-Address=" . $RAD_REQUEST["Framed-IP-Address"] . "\" | " . $system_options["exec_radclient"] . " -r 1 " . $RAD_REQUEST["NAS-IP-Address"] . ":" . $INPUT_PORT . " disconnect " . $SNMP_RW . " &>/dev/null 2>&1 ";
- }
- if ($NAS_TYPE == "junnoip") {
- $command = $system_options["sudo"] . " " . $system_options["ECHO"] . " \"Acct-Session-Id=" . $RAD_REQUEST["Acct-Session-Id"] . "\" | " . $system_options["exec_radclient"] . " -r 1 " . $RAD_REQUEST["NAS-IP-Address"] . ":" . $INPUT_PORT . " disconnect " . $SNMP_RW . " &>/dev/null 2>&1 ";
- }
- if ($NAS_TYPE == "junip") {
- $command = $system_options["sudo"] . " " . $system_options["ECHO"] . " \"Acct-Session-Id=" . $RAD_REQUEST["Acct-Session-Id"] . "\" | " . $system_options["exec_radclient"] . " -r 1 " . $RAD_REQUEST["NAS-IP-Address"] . ":" . $INPUT_PORT . " disconnect " . $SNMP_RW . " &>/dev/null 2>&1 ";
- }
- if (strlen($RAD_REQUEST["User-Name"]) == 17) {
- $user = $RAD_REQUEST["User-Name"];
- }
- else {
- $user = $RAD_REQUEST["Framed-IP-Address"];
- }
- if ($NAS_TYPE == "accelipoe") {
- $command = $system_options["sudo"] . " " . $system_options["ECHO"] . " \"NAS-Port=" . $RAD_REQUEST["NAS-Port"] . ",User-Name=" . $user . ",Framed-IP-Address=" . $RAD_REQUEST["Framed-IP-Address"] . "\" | " . $system_options["exec_radclient"] . " -r 1 " . $RAD_REQUEST["NAS-IP-Address"] . ":" . $INPUT_PORT . " disconnect " . $SNMP_RW . " &>/dev/null 2>&1 ";
- }
- if ($NAS_TYPE == "mikrotik") {
- $command = $system_options["sudo"] . " " . $system_options["ECHO"] . " \"User-Name=" . $RAD_REQUEST["User-Name"] . ",Framed-IP-Address=" . $RAD_REQUEST["Framed-IP-Address"] . "\" | " . $system_options["exec_radclient"] . " -r 1 " . $RAD_REQUEST["NAS-IP-Address"] . ":" . $INPUT_PORT . " disconnect " . $SNMP_RW . " &>/dev/null 2>&1 ";
- }
- if ($NAS_TYPE == "MPD5") {
- $command = $system_options["sudo"] . " " . $system_options["ECHO"] . " \"Acct-Session-Id=" . $RAD_REQUEST["Acct-Session-Id"] . ",User-Name=" . $RAD_REQUEST["User-Name"] . ",NAS-IP-Address=" . $RAD_REQUEST["NAS-IP-Address"] . ",Framed-IP-Address=" . $RAD_REQUEST["Framed-IP-Address"] . "\" | " . $system_options["exec_radclient"] . " -r 1 " . $RAD_REQUEST["NAS-IP-Address"] . ":" . $INPUT_PORT . " disconnect " . $SNMP_RW . " &>/dev/null 2>&1 ";
- }
- if ($NAS_TYPE == "lisg") {
- $command = $system_options["sudo"] . " " . $system_options["ECHO"] . " \"User-Name=" . $RAD_REQUEST["User-Name"] . ",NAS-IP-Address=" . $RAD_REQUEST["NAS-IP-Address"] . ",NAS-Port=" . $RAD_REQUEST["NAS-Port"] . ",NAS-Identifier=" . $RAD_REQUEST["NAS-Identifier"] . "\" | " . $system_options["exec_radclient"] . " -r 1 " . $RAD_REQUEST["NAS-IP-Address"] . ":" . $INPUT_PORT . " disconnect " . $SNMP_RW . " &>/dev/null 2>&1 ";
- }
- if ($NAS_TYPE == "HotSpot") {
- $command = $system_options["sudo"] . " " . $system_options["ECHO"] . " \"User-Name=" . $RAD_REQUEST["User-Name"] . ",Framed-IP-Address=" . $RAD_REQUEST["Framed-IP-Address"] . "\" | " . $system_options["exec_radclient"] . " -r 1 " . $RAD_REQUEST["NAS-IP-Address"] . ":" . $INPUT_PORT . " disconnect " . $SNMP_RW . " &>/dev/null 2>&1 ";
- }
- if (isset($command)) {
- exec($command);
- }
- }
- function get_old_session_data($LINK, $stdlog, $acctsessionid, $user_name, $nasipaddress, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT acctinputoctets,acctoutputoctets,acctsessiontime FROM " . BILL_ACCT_TABLE . " WHERE username = '" . $user_name . "' AND acctsessionid = '" . $acctsessionid . "' and nasipaddress = '" . $nasipaddress . "' ", $LINK) || do_log_sql($stdlog, "#7 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT acctinputoctets,acctoutputoctets,acctsessiontime FROM " . BILL_ACCT_TABLE . " WHERE username = '" . $user_name . "' AND acctsessionid = '" . $acctsessionid . "' and nasipaddress = '" . $nasipaddress . "' ", $LINK) || do_log_sql($stdlog, "#7 " . mysql_error($LINK), $child);
- return $res;
- }
- function do_update_mac_by_dhcp($LINK, $stdlog, $uid, $child, $user_proper, $new_mac) {
- $ts = time();
- $gid = $user_proper["gid"];
- $stuffid = 0;
- $logtypeid = 1;
- $ip_remote = "";
- $oldvalue = $user_proper["local_mac"];
- $newvalue = $new_mac;
- $valuename = "local_mac";
- $SQL = "INSERT INTO " . BILL_LOG_TABLE . " (logid ,stuffid ,date ,logtypeid ,uid ,gid ,ip,valuename ,oldvalue ,newvalue) VALUES (NULL," . $stuffid . ", FROM_UNIXTIME(" . $ts . ")," . $logtypeid . "," . $uid . "," . $gid . ",'" . $ip_remote . "','" . $valuename . "','" . $oldvalue . "','" . $newvalue . "')";
- $SQL = "UPDATE " . BILL_AUTH_TABLE . " SET local_mac=\"" . $new_mac . "\" where uid=" . $uid;
- mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#505 " . mysql_error($LINK), $child);
- mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#505 " . mysql_error($LINK), $child);
- mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#508 " . mysql_error($LINK), $child);
- mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#508 " . mysql_error($LINK), $child);
- }
- function do_fixed_one_day_abonplata_by_uid($LINK, $stdlog, $uid, $child, $packets, $gid, $user_proper) {
- $ts = time();
- $SQL = "INSERT INTO " . BILL_PLATEGI_STAT_TABLE . " (`plategid` ,`uid` ,`date` ,`who` ,`bughtypeid` ,`before_billing` ,`summa` ,`comment` ) VALUES (NULL , " . $uid . ", FROM_UNIXTIME(" . $ts . "), NULL , '2', '" . $user_proper["deposit"] . "', '" . $packets[$gid]["fixed_cost"] . "', NULL );";
- $SQL = "UPDATE " . BILL_AUTH_TABLE . " SET deposit=deposit-" . $packets[$gid]["fixed_cost"] . " where uid=" . $uid;
- mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#517 " . mysql_error($LINK), $child);
- mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#517 " . mysql_error($LINK), $child);
- mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#520 " . mysql_error($LINK), $child);
- mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#520 " . mysql_error($LINK), $child);
- }
- function get_switch_options_by_swid($LINK, $stdlog, $swid, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT swid, do_check_switch_port, do_mac_autoreg_by_radius, do_ip_unnumbered,strict_dhcp_mode, mac, swunit, swmodule,use_circut_template,circut_template,use_unit_find,use_module_find FROM " . BILL_SWITCH_TABLE . " NATURAL JOIN " . BILL_SWITCH_TYPE_TABLE . " WHERE swid='" . $swid . "' ", $LINK) || do_log_sql($stdlog, "#525 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT swid, do_check_switch_port, do_mac_autoreg_by_radius, do_ip_unnumbered,strict_dhcp_mode, mac, swunit, swmodule,use_circut_template,circut_template,use_unit_find,use_module_find FROM " . BILL_SWITCH_TABLE . " NATURAL JOIN " . BILL_SWITCH_TYPE_TABLE . " WHERE swid='" . $swid . "' ", $LINK) || do_log_sql($stdlog, "#525 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_switch_options_by_qnq($LINK, $stdlog, $qnq, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT swid, do_check_switch_port, do_mac_autoreg_by_radius, do_ip_unnumbered,strict_dhcp_mode, swunit, swmodule,use_circut_template,circut_template,use_unit_find,use_module_find FROM " . BILL_SWITCH_TABLE . " NATURAL JOIN " . BILL_SWITCH_TYPE_TABLE . " WHERE qnq='" . $qnq . "' ", $LINK) || do_log_sql($stdlog, "#437 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT swid, do_check_switch_port, do_mac_autoreg_by_radius, do_ip_unnumbered,strict_dhcp_mode, swunit, swmodule,use_circut_template,circut_template,use_unit_find,use_module_find FROM " . BILL_SWITCH_TABLE . " NATURAL JOIN " . BILL_SWITCH_TYPE_TABLE . " WHERE qnq='" . $qnq . "' ", $LINK) || do_log_sql($stdlog, "#437 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_ip_from_segment_lease_by_mac_ip($LINK, $stdlog, $sectorid, $mac, $ip, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT ip,ip2long,sectorid,expired FROM " . BILL_SECTORS_LEASE_TABLE . " WHERE mac like '" . $mac . "' AND IP like '" . $ip . "' LIMIT 1 ", $LINK) || do_log_sql($stdlog, "#460 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT ip,ip2long,sectorid,expired FROM " . BILL_SECTORS_LEASE_TABLE . " WHERE mac like '" . $mac . "' AND IP like '" . $ip . "' LIMIT 1 ", $LINK) || do_log_sql($stdlog, "#460 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_ip_from_segment_lease_by_ip($LINK, $stdlog, $sectorid, $ip, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT ip,ip2long,sectorid,expired FROM " . BILL_SECTORS_LEASE_TABLE . " WHERE ip like '" . $ip . "' LIMIT 1 ", $LINK) || do_log_sql($stdlog, "#482 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT ip,ip2long,sectorid,expired FROM " . BILL_SECTORS_LEASE_TABLE . " WHERE ip like '" . $ip . "' LIMIT 1 ", $LINK) || do_log_sql($stdlog, "#482 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_ip_from_segment_lease($LINK, $stdlog, $sectorid, $mac, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT ip,ip2long,sectorid,expired FROM " . BILL_SECTORS_LEASE_TABLE . " WHERE mac like '" . $mac . "' LIMIT 1 ", $LINK) || do_log_sql($stdlog, "#481 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT ip,ip2long,sectorid,expired FROM " . BILL_SECTORS_LEASE_TABLE . " WHERE mac like '" . $mac . "' LIMIT 1 ", $LINK) || do_log_sql($stdlog, "#481 " . mysql_error($LINK), $child);
- if (empty($res)) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT ip,ip2long,sectorid,expired FROM " . BILL_SECTORS_LEASE_TABLE . " WHERE sectorid='" . $sectorid . "' AND used=0 LIMIT 1 ", $LINK) || do_log_sql($stdlog, "#487 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT ip,ip2long,sectorid,expired FROM " . BILL_SECTORS_LEASE_TABLE . " WHERE sectorid='" . $sectorid . "' AND used=0 LIMIT 1 ", $LINK) || do_log_sql($stdlog, "#487 " . mysql_error($LINK), $child);
- }
- return $res;
- }
- function set_ip_in_use_by_segment_lease($LINK, $stdlog, $sectorid, $ip2long, $ip, $mac, $child, $system_options) {
- if (isset($system_options["default_lease_time"])) {
- if (!is_numeric($system_options["default_lease_time"])) {
- $system_options["default_lease_time"] = 3600;
- }
- else {
- if ($system_options["default_lease_time"] < 600) {
- $system_options["default_lease_time"] = 3600;
- }
- }
- }
- else {
- $system_options["default_lease_time"] = 3600;
- }
- $querry = "UPDATE " . BILL_SECTORS_LEASE_TABLE . " SET `used` = '1',\n`mac` = '" . $mac . "',expired='" . $system_options["default_lease_time"] . "' WHERE `ip2long` = " . $ip2long . " AND `ip` = '" . $ip . "' AND `sectorid` = " . $sectorid . " ;";
- mysql_query($querry, $LINK) || do_log_sql($stdlog, "#484 " . mysql_error($LINK), $child);
- mysql_query($querry, $LINK) || do_log_sql($stdlog, "#484 " . mysql_error($LINK), $child);
- }
- function get_segment_options_by_vlan($LINK, $stdlog, $vlanid, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_SECTORS_TABLE . " WHERE vlanid='" . $vlanid . "' ", $LINK) || do_log_sql($stdlog, "#475 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_SECTORS_TABLE . " WHERE vlanid='" . $vlanid . "' ", $LINK) || do_log_sql($stdlog, "#475 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_switch_options_by_mac($LINK, $stdlog, $switch_mac, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT swid, swunit, swmodule, do_check_switch_port, do_mac_autoreg_by_radius, do_ip_unnumbered,use_circut_template,circut_template,use_unit_find,use_module_find,strict_dhcp_mode FROM " . BILL_SWITCH_TABLE . " NATURAL JOIN " . BILL_SWITCH_TYPE_TABLE . " WHERE mac like '" . $switch_mac . "' ", $LINK) || do_log_sql($stdlog, "#690 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT swid, swunit, swmodule, do_check_switch_port, do_mac_autoreg_by_radius, do_ip_unnumbered,use_circut_template,circut_template,use_unit_find,use_module_find,strict_dhcp_mode FROM " . BILL_SWITCH_TABLE . " NATURAL JOIN " . BILL_SWITCH_TYPE_TABLE . " WHERE mac like '" . $switch_mac . "' ", $LINK) || do_log_sql($stdlog, "#690 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_switch_options_by_mac_all($LINK, $stdlog, $switch_mac, $child) {
- $switches = (array());
- $i = 0;
- $result = mysql_query("SELECT swid, swunit, swmodule, do_check_switch_port, do_mac_autoreg_by_radius, do_ip_unnumbered,use_circut_template,circut_template,use_unit_find,use_module_find,strict_dhcp_mode FROM " . BILL_SWITCH_TABLE . " NATURAL JOIN " . BILL_SWITCH_TYPE_TABLE . " WHERE mac like '" . $switch_mac . "' ", $LINK) || do_log_sql($stdlog, "#710 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT swid, swunit, swmodule, do_check_switch_port, do_mac_autoreg_by_radius, do_ip_unnumbered,use_circut_template,circut_template,use_unit_find,use_module_find,strict_dhcp_mode FROM " . BILL_SWITCH_TABLE . " NATURAL JOIN " . BILL_SWITCH_TYPE_TABLE . " WHERE mac like '" . $switch_mac . "' ", $LINK) || do_log_sql($stdlog, "#710 " . mysql_error($LINK), $child);
- while ($i < mysql_num_rows($result)) {
- $i++;
- $res = mysql_fetch_array($result);
- $switches[$i] = $res;
- continue;
- }
- mysql_free_result($result);
- return $switches;
- }
- function get_switch_options_by_mac_unit($LINK, $stdlog, $switch_mac, $swunit, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT swid, swunit, swmodule, do_check_switch_port, do_mac_autoreg_by_radius, do_ip_unnumbered,use_circut_template,circut_template,use_unit_find,use_module_find,strict_dhcp_mode FROM " . BILL_SWITCH_TABLE . " NATURAL JOIN " . BILL_SWITCH_TYPE_TABLE . " WHERE mac like '" . $switch_mac . "' AND swunit = " . $swunit, $LINK) || do_log_sql($stdlog, "#736 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT swid, swunit, swmodule, do_check_switch_port, do_mac_autoreg_by_radius, do_ip_unnumbered,use_circut_template,circut_template,use_unit_find,use_module_find,strict_dhcp_mode FROM " . BILL_SWITCH_TABLE . " NATURAL JOIN " . BILL_SWITCH_TYPE_TABLE . " WHERE mac like '" . $switch_mac . "' AND swunit = " . $swunit, $LINK) || do_log_sql($stdlog, "#736 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_switch_options_by_mac_module($LINK, $stdlog, $switch_mac, $swmodule, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT swid, swunit, swmodule, do_check_switch_port, do_mac_autoreg_by_radius, do_ip_unnumbered,use_circut_template,circut_template,use_unit_find,use_module_find,strict_dhcp_mode FROM " . BILL_SWITCH_TABLE . " NATURAL JOIN " . BILL_SWITCH_TYPE_TABLE . " WHERE mac like '" . $switch_mac . "' AND swmodule = " . $swmodule, $LINK) || do_log_sql($stdlog, "#757 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT swid, swunit, swmodule, do_check_switch_port, do_mac_autoreg_by_radius, do_ip_unnumbered,use_circut_template,circut_template,use_unit_find,use_module_find,strict_dhcp_mode FROM " . BILL_SWITCH_TABLE . " NATURAL JOIN " . BILL_SWITCH_TYPE_TABLE . " WHERE mac like '" . $switch_mac . "' AND swmodule = " . $swmodule, $LINK) || do_log_sql($stdlog, "#757 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_swid_port_mac($LINK, $stdlog, $swid, $switchport, $mac, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE swid = '" . $swid . "' AND switchport = '" . $switchport . "' AND local_mac = '" . $mac . "';", $LINK) || do_log_sql($stdlog, "#2345624 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE swid = '" . $swid . "' AND switchport = '" . $switchport . "' AND local_mac = '" . $mac . "';", $LINK) || do_log_sql($stdlog, "#2345624 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_DHCP_circuit_remote_ids($RAD_REQUEST, $LINK, $stdlog, $child) {
- $DHCP_Relay_Circuit_Id = $RAD_REQUEST["DHCP-Relay-Circuit-Id"];
- $DHCP_Relay_Remote_Id = $RAD_REQUEST["DHCP-Relay-Remote-Id"];
- $client_code = "";
- $client_length = "";
- $client_unit = "";
- $client_module = "";
- $client_port = "0";
- $client_vlan = "0";
- $switch_circuit_id = "";
- $switch_mac = "";
- $swid_by_mac = "";
- $use_circut_template = 0;
- $swid_by_mac_arr = (array());
- if ($DHCP_Relay_Remote_Id == "") {
- $tmp_var = explode("x", $DHCP_Relay_Circuit_Id);
- if (isset($tmp_var[1])) {
- $switch_circuit_id = substr($tmp_var[1], 0, 2);
- $client_vlan = hexdec(substr($tmp_var[1], 4, 4));
- $client_port = hexdec(substr($tmp_var[1], 2, 2));
- }
- unset(${$tmp_var});
- unset(${$tmp_var});
- }
- else {
- $tmp_var = explode("x", $DHCP_Relay_Remote_Id);
- if (isset($tmp_var[1])) {
- if (strlen($tmp_var[1]) == 12) {
- $switch_mac = substr($tmp_var[1], 0, 2) . ":" . substr($tmp_var[1], 2, 2) . ":" . substr($tmp_var[1], 4, 2) . ":" . substr($tmp_var[1], 6, 2) . ":" . substr($tmp_var[1], 8, 2) . ":" . substr($tmp_var[1], 10, 2);
- }
- if (strlen($tmp_var[1]) == 16) {
- $switch_mac = substr($tmp_var[1], 4, 2) . ":" . substr($tmp_var[1], 6, 2) . ":" . substr($tmp_var[1], 8, 2) . ":" . substr($tmp_var[1], 10, 2) . ":" . substr($tmp_var[1], 12, 2) . ":" . substr($tmp_var[1], 14, 2);
- }
- if ($switch_mac == "") {
- $switch_mac = $tmp_var[1];
- }
- }
- $switch_mac = trim(strtoupper($switch_mac));
- unset(${$tmp_var});
- unset(${$tmp_var});
- $swid_by_mac_arr = get_switch_options_by_mac_all($LINK, $stdlog, $switch_mac, $child);
- if (count($swid_by_mac_arr) == 1) {
- $swid_by_mac = $swid_by_mac_arr[0];
- $use_circut_template = $swid_by_mac["use_circut_template"];
- }
- else {
- if (0 < count($swid_by_mac_arr)) {
- $swid_by_mac = $swid_by_mac_arr[0];
- $use_circut_template = $swid_by_mac_arr[0]["use_circut_template"];
- }
- }
- if ($use_circut_template == 0) {
- $tmp_var = explode("x", $DHCP_Relay_Circuit_Id);
- if (isset($tmp_var[1])) {
- if (strlen($DHCP_Relay_Circuit_Id) == 10) {
- $switch_circuit_id = substr($tmp_var[1], 0, 4);
- if ($switch_circuit_id == "0000") {
- $client_port = hexdec(substr($tmp_var[1], 4, 4));
- }
- else {
- $client_vlan = hexdec(substr($tmp_var[1], 0, 4));
- $client_port = hexdec(substr($tmp_var[1], 6, 2));
- }
- }
- if (strlen($DHCP_Relay_Circuit_Id) == 14) {
- $switch_circuit_id = substr($tmp_var[1], 0, 4);
- $client_vlan = hexdec(substr($tmp_var[1], 4, 4));
- $client_port = hexdec(substr($tmp_var[1], 8, 4));
- }
- }
- }
- else {
- $template_arr = explode(",", $swid_by_mac["circut_template"]);
- $circuitid = $DHCP_Relay_Circuit_Id;
- foreach ($template_arr as $key => $value) {
- $tmp_val1 = explode("=", $value);
- if (isset($tmp_val1[1])) {
- $tag_code = $tmp_val1[0];
- $tag_len = $tmp_val1[1];
- switch ($tag_code) {
- case "C": {
- $client_code = substr($circuitid, 0, $tag_len);
- $client_code = hexdec($client_code);
- $circuitid = substr($circuitid, $tag_len, strlen($circuitid) - $tag_len);
- break;
- }
- case "L": {
- $client_length = substr($circuitid, 0, $tag_len);
- $client_length = hexdec($client_length);
- $circuitid = substr($circuitid, $tag_len, strlen($circuitid) - $tag_len);
- break;
- }
- case "U": {
- $client_unit = substr($circuitid, 0, $tag_len);
- $client_unit = hexdec($client_unit);
- $circuitid = substr($circuitid, $tag_len, strlen($circuitid) - $tag_len);
- break;
- }
- case "M": {
- $client_module = substr($circuitid, 0, $tag_len);
- $client_module = hexdec($client_module);
- $circuitid = substr($circuitid, $tag_len, strlen($circuitid) - $tag_len);
- break;
- }
- case "V": {
- $client_vlan = substr($circuitid, 0, $tag_len);
- $client_vlan = hexdec($client_vlan);
- $circuitid = substr($circuitid, $tag_len, strlen($circuitid) - $tag_len);
- break;
- }
- case "CP": {
- $client_port = substr($circuitid, 0, $tag_len);
- $client_port = hexdec($client_port);
- $client_port = $client_port + 1;
- $circuitid = substr($circuitid, $tag_len, strlen($circuitid) - $tag_len);
- break;
- }
- case "P": {
- $client_port = substr($circuitid, 0, $tag_len);
- $client_port = hexdec($client_port);
- $circuitid = substr($circuitid, $tag_len, strlen($circuitid) - $tag_len);
- break;
- }
- }
- }
- continue;
- }
- }
- unset(${$tmp_var});
- unset(${$tmp_var});
- }
- if (1 < count($swid_by_mac_arr)) {
- if ($swid_by_mac["use_unit_find"] == 1 && $swid_by_mac["use_module_find"] == 1) {
- if ($client_unit != "" && $client_module != "") {
- if (is_numeric($client_module) && is_numeric($client_unit)) {
- foreach ($swid_by_mac_arr as $key => $value) {
- if ($value["swunit"] == $client_unit && $value["swmodule"] == $client_module) {
- $swid_by_mac = $swid_by_mac_arr[$key];
- }
- continue;
- }
- }
- }
- }
- else {
- if ($swid_by_mac["use_unit_find"] == 1) {
- if ($client_unit != "") {
- if (is_numeric($client_unit)) {
- foreach ($swid_by_mac_arr as $key => $value) {
- if ($value["swunit"] == $client_unit) {
- $swid_by_mac = $swid_by_mac_arr[$key];
- }
- continue;
- }
- }
- }
- }
- if ($swid_by_mac["use_module_find"] == 1) {
- if ($client_module != "") {
- if (is_numeric($client_module)) {
- foreach ($swid_by_mac_arr as $key => $value) {
- if ($value["swmodule"] == $client_module) {
- $swid_by_mac = $swid_by_mac_arr[$key];
- }
- continue;
- }
- }
- }
- }
- }
- }
- $result = (array("client_module" => $client_module, "client_unit" => $client_unit, "client_port" => $client_port, "client_vlan" => $client_vlan, "switch_circuit_id" => $switch_circuit_id, "switch_mac" => $switch_mac, "DHCP_Relay_Circuit_Id" => $DHCP_Relay_Circuit_Id, "DHCP_Relay_Remote_Id" => $DHCP_Relay_Remote_Id, "swid_by_mac" => $swid_by_mac));
- unset(${$client_port});
- unset(${$client_port});
- unset(${$client_vlan});
- unset(${$client_vlan});
- unset(${$client_module});
- unset(${$client_module});
- unset(${$client_unit});
- unset(${$client_unit});
- unset(${$switch_circuit_id});
- unset(${$switch_circuit_id});
- unset(${$switch_mac});
- unset(${$switch_mac});
- unset(${$DHCP_Relay_Circuit_Id});
- unset(${$DHCP_Relay_Circuit_Id});
- unset(${$DHCP_Relay_Remote_Id});
- unset(${$DHCP_Relay_Remote_Id});
- unset(${$swid_by_mac});
- unset(${$swid_by_mac});
- unset(${$swid_by_mac_arr});
- unset(${$swid_by_mac_arr});
- return $result;
- }
- function fill_rad_reply($user_proper, $switches, $sectors, $system_options, &$RAD_REPLY, &$RAD_REQUEST) {
- $local_ip = $user_proper["local_ip"];
- $sectorid = $user_proper["sectorid"];
- $user_installed = $user_proper["user_installed"];
- $vlan = $sectors[$sectorid]["vlanid"];
- $mask = $sectors[$sectorid]["mask"];
- $dns_serv = $sectors[$sectorid]["dns_serv"];
- $dns_serv2 = $sectors[$sectorid]["dns_serv2"];
- $wins_serv = $sectors[$sectorid]["wins_serv"];
- $netbios_dd_serv = $sectors[$sectorid]["wins_serv"];
- $routers = $sectors[$sectorid]["routers"];
- $time_serv = $sectors[$sectorid]["time_serv"];
- $static_routes = $sectors[$sectorid]["static_routes"];
- $classless_route = $sectors[$sectorid]["classless_route"];
- if (isset($RAD_REQUEST["DHCP-Client-IP-Address"])) {
- $RAD_REPLY["DHCP-Client-IP-Address"] = $RAD_REQUEST["DHCP-Client-IP-Address"];
- }
- $RAD_REPLY["DHCP-Your-IP-Address"] = $local_ip;
- $RAD_REPLY["DHCP-Subnet-Mask"] = $mask;
- if (trim($classless_route) != "") {
- $tmp = preg_split("/\\,/", $classless_route);
- $tmp_str = "";
- foreach ($tmp as $key => $value) {
- $tmp_str2 = dechex($value);
- if (strlen($tmp_str2) == 1) {
- $tmp_str2 = "0" . $tmp_str2;
- }
- $tmp_str .= $tmp_str2;
- continue;
- }
- $tmp_str = strtoupper($tmp_str);
- $RAD_REPLY["DHCP-Classless-Static-Route"] = "0x" . $tmp_str;
- $RAD_REPLY["DHCP-MS-Static-Routes"] = "0x" . $tmp_str;
- unset(${$tmp});
- unset(${$tmp});
- unset(${$tmp_str2});
- unset(${$tmp_str2});
- unset(${$tmp_str});
- unset(${$tmp_str});
- }
- if (trim($routers) != "") {
- $RAD_REPLY["DHCP-Router-Address"] = $routers;
- }
- if (trim($dns_serv) != "" && trim($dns_serv2) != "") {
- $RAD_REPLY["DHCP-Domain-Name-Server"] = (array($dns_serv, $dns_serv2));
- }
- else {
- if (trim($dns_serv) != "") {
- $RAD_REPLY["DHCP-Domain-Name-Server"] = (array($dns_serv));
- }
- if (trim($dns_serv2) != "") {
- $RAD_REPLY["DHCP-Domain-Name-Server"] = (array($dns_serv2));
- }
- }
- if (trim($time_serv) != "") {
- $RAD_REPLY["DHCP-NTP-Servers"] = $time_serv;
- $RAD_REPLY["DHCP-Time-Server"] = $time_serv;
- }
- if (trim($wins_serv) != "") {
- $RAD_REPLY["DHCP-NETBIOS-Name-Servers"] = $wins_serv;
- $RAD_REPLY["DHCP-NETBIOS-Node-Type"] = "8";
- }
- if (trim($system_options["DHCP_PARAM_DOMAIN"] != "")) {
- $RAD_REPLY["DHCP-Domain-Name"] = $system_options["DHCP_PARAM_DOMAIN"];
- }
- $RAD_REPLY["DHCP-IP-Address-Lease-Time"] = $system_options["default_lease_time"];
- }
- function get_user_proper_by_swid_port($LINK, $stdlog, $swid, $switchport, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE swid = '" . $swid . "' AND switchport = '" . $switchport . "';", $LINK) || do_log_sql($stdlog, "##2345625 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE swid = '" . $swid . "' AND switchport = '" . $switchport . "';", $LINK) || do_log_sql($stdlog, "##2345625 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_switch_port_by_parent_swid_and_vlan($LINK, $stdlog, $parent_swid, $client_vlan, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT `swid`, `port` FROM `" . BILL_SWITCH_IP_UNNUMBERED_TABLE . "` WHERE `vlan` = '" . $client_vlan . "' AND `swid` IN (SELECT `swid` FROM `" . BILL_SWITCH_TABLE . "` WHERE `parent_swid` = '" . $parent_swid . "');", $LINK) || do_log_sql($stdlog, "#2345626 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT `swid`, `port` FROM `" . BILL_SWITCH_IP_UNNUMBERED_TABLE . "` WHERE `vlan` = '" . $client_vlan . "' AND `swid` IN (SELECT `swid` FROM `" . BILL_SWITCH_TABLE . "` WHERE `parent_swid` = '" . $parent_swid . "');", $LINK) || do_log_sql($stdlog, "#2345626 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_vlan_for_accel_qnqunnumbered($LINK, $stdlog, $vlan, $qnq, $child) {
- $SQL_Query = "SELECT `swid`,`port` FROM `" . BILL_SWITCH_IP_UNNUMBERED_TABLE . "` WHERE `vlan` = " . $vlan . " and `swid` IN (SELECT swid FROM " . BILL_SWITCH_TABLE . " WHERE qnq=" . $qnq . ");";
- $switch_port_pair = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query($SQL_Query, $LINK) || do_log_sql($stdlog, "#switch by qnq " . mysql_error($LINK), $child);
- $result = mysql_query($SQL_Query, $LINK) || do_log_sql($stdlog, "#switch by qnq " . mysql_error($LINK), $child);
- if (!empty($switch_port_pair)) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE swid=" . $switch_port_pair["swid"] . " and switchport =" . $switch_port_pair["port"] . "; ", $LINK) || do_log_sql($stdlog, "#8433s4 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE swid=" . $switch_port_pair["swid"] . " and switchport =" . $switch_port_pair["port"] . "; ", $LINK) || do_log_sql($stdlog, "#8433s4 " . mysql_error($LINK), $child);
- return $res;
- }
- else {
- return array();
- }
- }
- function get_user_proper_by_vlan_for_accel_unnumbered($LINK, $stdlog, $vlan, $child) {
- $switch_port_pair = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT `swid`, `port` FROM `" . BILL_SWITCH_IP_UNNUMBERED_TABLE . "` WHERE `vlan` = " . $vlan . ";", $LINK) || do_log_sql($stdlog, "#switch by vlan " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT `swid`, `port` FROM `" . BILL_SWITCH_IP_UNNUMBERED_TABLE . "` WHERE `vlan` = " . $vlan . ";", $LINK) || do_log_sql($stdlog, "#switch by vlan " . mysql_error($LINK), $child);
- if (!empty($switch_port_pair)) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE swid=" . $switch_port_pair["swid"] . " and switchport =" . $switch_port_pair["port"] . " ", $LINK) || do_log_sql($stdlog, "#844 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE swid=" . $switch_port_pair["swid"] . " and switchport =" . $switch_port_pair["port"] . " ", $LINK) || do_log_sql($stdlog, "#844 " . mysql_error($LINK), $child);
- return $res;
- }
- else {
- return array();
- }
- }
- function get_abonplata_by_uid_fixed_pays($LINK, $stdlog, $uid, $child) {
- $month = date("m");
- $years = date("Y");
- $current_day = date("d");
- $SQL = "SELECT count(plategid) as count FROM " . BILL_PLATEGI_STAT_TABLE . " WHERE bughtypeid=2 and uid=" . $uid . " AND `date` BETWEEN '" . $years . "-" . $month . "-" . $current_day . " 00:00:00' AND '" . $years . "-" . $month . "-" . $current_day . " 23:59:59'";
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#80 " . mysql_error($LINK), $child);
- $result = mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#80 " . mysql_error($LINK), $child);
- return $res["count"];
- }
- function get_sum_all_by_uid($LINK, $stdlog, $uid, $child) {
- $month = date("m");
- $years = date("Y");
- $last_day = date("t");
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $return = $res["acctinputoctets"] + $res["acctoutputoctets"];
- $result = mysql_query("SELECT SUM(acctinputoctets)/1048576 as acctinputoctets, SUM(acctoutputoctets)/1048576 as acctoutputoctets FROM " . BILL_ACCT_TABLE . " WHERE uid=" . $uid . " AND `acctstarttime` BETWEEN '" . $years . "-" . $month . "-01 00:00:00' AND '" . $years . "-" . $month . "-" . $last_day . " 23:59:59'", $LINK) || do_log_sql($stdlog, "#80 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT SUM(acctinputoctets)/1048576 as acctinputoctets, SUM(acctoutputoctets)/1048576 as acctoutputoctets FROM " . BILL_ACCT_TABLE . " WHERE uid=" . $uid . " AND `acctstarttime` BETWEEN '" . $years . "-" . $month . "-01 00:00:00' AND '" . $years . "-" . $month . "-" . $last_day . " 23:59:59'", $LINK) || do_log_sql($stdlog, "#80 " . mysql_error($LINK), $child);
- return $return;
- }
- function get_sum_by_uid($LINK, $stdlog, $uid, $child) {
- $month = date("m");
- $years = date("Y");
- $last_day = date("t");
- $SQL = "SELECT SUM(acctinputoctets)/1048576 as acctinputoctets, SUM(acctoutputoctets)/1048576 as acctoutputoctets FROM " . BILL_ACCT_TABLE . " WHERE uid=" . $uid . " AND `acctstarttime` BETWEEN '" . $years . "-" . $month . "-01 00:00:00' AND '" . $years . "-" . $month . "-" . $last_day . " 23:59:59'";
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#8 " . mysql_error($LINK), $child);
- $result = mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#8 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_price_diff_limit($price_floors, $gid, $traf_sum) {
- $limits = 0;
- $limit_old = 0;
- foreach ($price_floors as $key => $value) {
- if ($limit_old < $price_floors[$key][1] && $price_floors[$key][1] < $traf_sum && $gid == $key) {
- $limit_old = $limits;
- list(, $limits) = $price_floors[$key];
- }
- continue;
- }
- return $limits;
- }
- function do_billing_minus($LINK, $stdlog, $acctsessionid, $user_name, $nasipaddress, $uid, $billing_minus_current, $child) {
- mysql_query("UPDATE " . BILL_AUTH_TABLE . " SET deposit = deposit - " . $billing_minus_current . " WHERE uid = " . $uid . "", $LINK) || do_log_sql($stdlog, "#9 " . mysql_error($LINK), $child);
- mysql_query("UPDATE " . BILL_AUTH_TABLE . " SET deposit = deposit - " . $billing_minus_current . " WHERE uid = " . $uid . "", $LINK) || do_log_sql($stdlog, "#9 " . mysql_error($LINK), $child);
- mysql_query("UPDATE " . BILL_ACCT_TABLE . " SET billing_minus = billing_minus + " . $billing_minus_current . " WHERE acctsessionid='" . $acctsessionid . "' and username='" . $user_name . "' and nasipaddress='" . $nasipaddress . "' and uid=" . $uid . "", $LINK) || do_log_sql($stdlog, "#10 " . mysql_error($LINK), $child);
- mysql_query("UPDATE " . BILL_ACCT_TABLE . " SET billing_minus = billing_minus + " . $billing_minus_current . " WHERE acctsessionid='" . $acctsessionid . "' and username='" . $user_name . "' and nasipaddress='" . $nasipaddress . "' and uid=" . $uid . "", $LINK) || do_log_sql($stdlog, "#10 " . mysql_error($LINK), $child);
- }
- function do_postauth_log($LINK, $stdlog, $RAD_REQUEST, $RAD_CHECK, $packettypeid, $replymessageid, $nasid, $uid, $child) {
- if (isset($RAD_REQUEST["User-Password"])) {
- $Clear_text_password = $RAD_REQUEST["User-Password"];
- }
- else {
- if (!isset($RAD_CHECK["Cleartext-Password"])) {
- $Clear_text_password = "";
- }
- else {
- $Clear_text_password = $RAD_CHECK["Cleartext-Password"];
- }
- }
- if (!is_numeric($uid)) {
- $uid = 0;
- }
- if (isset($RAD_REQUEST["NAS-Port"])) {
- if (!is_numeric($RAD_REQUEST["NAS-Port"])) {
- $RAD_REQUEST["NAS-Port"] = 0;
- }
- }
- else {
- $RAD_REQUEST["NAS-Port"] = 0;
- }
- if ($nasid == "") {
- $nasid = 0;
- }
- $SQL = "call do_post_auth(" . $uid . ",'" . $RAD_REQUEST["User-Name"] . "','" . $Clear_text_password . "'," . $packettypeid . "," . $replymessageid . "," . $nasid . ",'" . $RAD_REQUEST["NAS-Port"] . "','" . $RAD_REQUEST["Calling-Station-Id"] . "');";
- mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#Do log Post Auth " . mysql_error($LINK), $child);
- mysql_query($SQL, $LINK) || do_log_sql($stdlog, "#Do log Post Auth " . mysql_error($LINK), $child);
- }
- function get_user_proper_by_login($LINK, $stdlog, $login, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE user='" . $login . "' ", $LINK) || do_log_sql($stdlog, "#1225 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE user='" . $login . "' ", $LINK) || do_log_sql($stdlog, "#1225 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_login_freeze($LINK, $stdlog, $login, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_USERFREEZE_TABLE . " WHERE user='" . $login . "' ", $LINK) || do_log_sql($stdlog, "#12434 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_USERFREEZE_TABLE . " WHERE user='" . $login . "' ", $LINK) || do_log_sql($stdlog, "#12434 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_login_otkl($LINK, $stdlog, $login, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_USERBLOCK_TABLE . " WHERE user='" . $login . "' ", $LINK) || do_log_sql($stdlog, "#1243 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_USERBLOCK_TABLE . " WHERE user='" . $login . "' ", $LINK) || do_log_sql($stdlog, "#1243 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_login_del($LINK, $stdlog, $login, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_USERDEL_TABLE . " WHERE user='" . $login . "' ", $LINK) || do_log_sql($stdlog, "#1253 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_USERDEL_TABLE . " WHERE user='" . $login . "' ", $LINK) || do_log_sql($stdlog, "#1253 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_password($LINK, $stdlog, $pass, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE password='" . $pass . "' ", $LINK) || do_log_sql($stdlog, "#1263 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE password='" . $pass . "' ", $LINK) || do_log_sql($stdlog, "#1263 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_ip($LINK, $stdlog, $ip, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE local_ip='" . $ip . "' ", $LINK) || do_log_sql($stdlog, "#1272 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE local_ip='" . $ip . "' ", $LINK) || do_log_sql($stdlog, "#1272 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_ip_freeze($LINK, $stdlog, $ip, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_USERFREEZE_TABLE . " WHERE local_ip='" . $ip . "' ", $LINK) || do_log_sql($stdlog, "#1286 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_USERFREEZE_TABLE . " WHERE local_ip='" . $ip . "' ", $LINK) || do_log_sql($stdlog, "#1286 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_ip_otkl($LINK, $stdlog, $ip, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_USERBLOCK_TABLE . " WHERE local_ip='" . $ip . "' ", $LINK) || do_log_sql($stdlog, "#1290 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_USERBLOCK_TABLE . " WHERE local_ip='" . $ip . "' ", $LINK) || do_log_sql($stdlog, "#1290 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_ip_del($LINK, $stdlog, $ip, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_USERDEL_TABLE . " WHERE local_ip='" . $ip . "' ", $LINK) || do_log_sql($stdlog, "#1301 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_USERDEL_TABLE . " WHERE local_ip='" . $ip . "' ", $LINK) || do_log_sql($stdlog, "#1301 " . mysql_error($LINK), $child);
- return $res;
- }
- function do_last_connection($LINK, $stdlog, $uid, $child) {
- if (is_numeric($uid)) {
- mysql_free_result($result);
- $result = mysql_query("CALL last_connection(" . $uid . "); ", $LINK) || do_log_sql($stdlog, "#1320 " . mysql_error($LINK), $child);
- $result = mysql_query("CALL last_connection(" . $uid . "); ", $LINK) || do_log_sql($stdlog, "#1320 " . mysql_error($LINK), $child);
- }
- }
- function get_user_proper_by_switch_port_groupe_del($LINK, $stdlog, $swid, $port, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_USERDEL_TABLE . " WHERE swid='" . $swid . "' and switchport ='" . $port . "' ", $LINK) || do_log_sql($stdlog, "#844 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_USERDEL_TABLE . " WHERE swid='" . $swid . "' and switchport ='" . $port . "' ", $LINK) || do_log_sql($stdlog, "#844 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_switch_port_groupe_otkl($LINK, $stdlog, $swid, $port, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_USERBLOCK_TABLE . " WHERE swid='" . $swid . "' and switchport ='" . $port . "' ", $LINK) || do_log_sql($stdlog, "#844 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_USERBLOCK_TABLE . " WHERE swid='" . $swid . "' and switchport ='" . $port . "' ", $LINK) || do_log_sql($stdlog, "#844 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_switch_port_groupe_freeze($LINK, $stdlog, $swid, $port, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_USERFREEZE_TABLE . " WHERE swid='" . $swid . "' and switchport ='" . $port . "' ", $LINK) || do_log_sql($stdlog, "#844 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_USERFREEZE_TABLE . " WHERE swid='" . $swid . "' and switchport ='" . $port . "' ", $LINK) || do_log_sql($stdlog, "#844 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_switch_port($LINK, $stdlog, $swid, $port, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE swid='" . $swid . "' and switchport ='" . $port . "' ", $LINK) || do_log_sql($stdlog, "#844 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE swid='" . $swid . "' and switchport ='" . $port . "' ", $LINK) || do_log_sql($stdlog, "#844 " . mysql_error($LINK), $child);
- return $res;
- }
- function check_mac_in_segment_not_uid($LINK, $stdlog, $mac, $uid, $sectorid, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT count(uid) as count FROM " . BILL_AUTH_TABLE . " WHERE local_mac='" . $mac . "' and sectorid = " . $sectorid . " and uid!=" . $uid . "", $LINK) || do_log_sql($stdlog, "#2345629 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT count(uid) as count FROM " . BILL_AUTH_TABLE . " WHERE local_mac='" . $mac . "' and sectorid = " . $sectorid . " and uid!=" . $uid . "", $LINK) || do_log_sql($stdlog, "#2345629 " . mysql_error($LINK), $child);
- return $res["count"];
- }
- function get_user_proper_by_mac_for_switch($LINK, $stdlog, $mac, $swid, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE local_mac='" . $mac . "' and sectorid in (select sectorid from " . BILL_SWITCH_VLAN_TABLE . " where swid = " . $swid . ")", $LINK) || do_log_sql($stdlog, "#2345630 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE local_mac='" . $mac . "' and sectorid in (select sectorid from " . BILL_SWITCH_VLAN_TABLE . " where swid = " . $swid . ")", $LINK) || do_log_sql($stdlog, "#2345630 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_mac_hs($LINK, $stdlog, $mac, $child) {
- $res = mysql_fetch_array($result);
- mysql_free_result($result);
- $result = mysql_query("SELECT * FROM " . BILL_hotspot_free_users_TABLE . " WHERE local_mac='" . $mac . "' ", $LINK) || do_log_sql($stdlog, "#2345631 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_hotspot_free_users_TABLE . " WHERE local_mac='" . $mac . "' ", $LINK) || do_log_sql($stdlog, "#2345631 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_user_proper_by_vlan_port($LINK, $stdlog, $client_vlan, $client_port, $child) {
- $res = mysql_fetch_array($result);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE `switchport` = '" . $client_port . "' AND `swid` IN (SELECT `swid` FROM `" . BILL_SWITCH_IP_UNNUMBERED_TABLE . "` WHERE `vlan` = '" . $client_vlan . "' AND `port` = '" . $client_port . "');", $LINK) || do_log_sql($stdlog, "#1432423f2 " . mysql_error($LINK), $child);
- $result = mysql_query("SELECT * FROM " . BILL_AUTH_TABLE . " WHERE `switchport` = '" . $client_port . "' AND `swid` IN (SELECT `swid` FROM `" . BILL_SWITCH_IP_UNNUMBERED_TABLE . "` WHERE `vlan` = '" . $client_vlan . "' AND `port` = '" . $client_port . "');", $LINK) || do_log_sql($stdlog, "#1432423f2 " . mysql_error($LINK), $child);
- return $res;
- }
- function get_basic_users_list_by_mac($LINK, $stdlog, $mac, $child) {
- $mac = strtoupper($mac);
- $mac = trim($mac);
- ....................................
- ...........
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement