<?PHP
$error5="error5 Przykro nam, serwis jest dostepny wylacznie dla
autoryzowanych uzytkownikow";

if(file_exists(".config.php")) include(".config.php");


//$komputery="/home/www/netsatmedia_portal/abonenci/www/komputery";
$czy_error_5=exec("cat $komputery |grep $REMOTE_ADDR");
//echo "$REMOTE_ADDR $czy_error_5 <br>" ;
if($czy_error_5) {



$ADM_USER=$SQL_USER ;
$ADM_USER_PASS=$SQL_USER_PASS ;


if($test) echo "OK"; else {
     $conn=mysql_pconnect($INTERFACE_ADDR,$ADM_USER,$ADM_USER_PASS);
     if (!$conn) die("ERROR podczas tworzenia polaczenia do bazy $SQL_DATABASE !\n");
     mysql_select_db($SQL_DATABASE) or die("ERROR podczas wyboru bazy!");
     $zapSQL="SELECT * FROM $SQL_TABLE_USERS  where T_TELBOX_ADDRESS like '%$dana1%' ;";
//echo "$zapSQL";
     $result = mysql_query($zapSQL,$conn) or die("Blad zapytania!");
 //   $user=mysql_fetch_object($result);
 //    if ((mysql_num_rows($result)>0) && ($user->pass==$PHP_AUTH_PW))
while ($h=mysql_fetch_object($result))
{
echo "\n"; 
echo "$h->S_IP;";
if ($h->S_ADDRESS_STREET) echo "$h->S_ADDRESS_STREET;"; else echo "$h->S_IP-N/A;";
echo "$h->T_TELBOX_ADDRESS;";
     $zapSQL2="SELECT * FROM TELBOXES  where T_TELBOX_NAME = '$h->T_TELBOX_ADDRESS' ;";
     $result2 = mysql_query($zapSQL2,$conn) or die("Blad zapytania!");
      while ($t=mysql_fetch_object($result2)) {
      echo "$t->T_TELBOX_NEIGHBOUR_IN;";	
      $T_TELBOX_NAME = $t->T_TELBOX_NAME ;
					      }
     $zapSQL2="SELECT * FROM TELBOXES  where T_TELBOX_NEIGHBOUR_IN = '".$T_TELBOX_NAME."' ;";
     $result2 = mysql_query($zapSQL2,$conn) or die("Blad zapytania!");
      while ($t=mysql_fetch_object($result2)) {
      echo "$t->T_TELBOX_NAME,";	
					      }
      echo ";";

	}

if(mysql_num_rows($result)==0) {
echo ";;;";
     $zapSQL2="SELECT * FROM TELBOXES  where T_TELBOX_NAME like '$DANA1%' limit 0,1;";
     $result2 = mysql_query($zapSQL2,$conn) or die("Blad zapytania!");
      while ($t=mysql_fetch_object($result2)) {
      echo "$t->T_TELBOX_NEIGHBOUR_IN;";	
      $T_TELBOX_NAME=$t->T_TELBOX_NAME ;
					      }
     $zapSQL2="SELECT * FROM TELBOXES  where T_TELBOX_NEIGHBOUR_IN = '".$T_TELBOX_NAME."' ;";
     $result2 = mysql_query($zapSQL2,$conn) or die("Blad zapytania!");
      while ($t=mysql_fetch_object($result2)) {
      echo "$t->T_TELBOX_NAME,";	
					      }
      echo ";";
 				}
}
} else {
echo $error5 ;
}
//echo "\n";
?>

