Re: [PHP] PHP debugger

[email protected] ("J. Manuel Velasco - UBILIBET")
Newsgroups php.general
Message-ID <[email protected]>
Hi,

Thanks for the replay, at least the debugger runs and it's easy to 
install :)

I am new here, this is a small company and I am the only computing man, 
so the person who implemented theses scripts are far away to ask for 
something.

Since I deduced there are different whoises scripts because the way to 
make the petition is different depending on the domain (es) the query is 
to an organization, ESNIC, (eu) query is to another organization, EURID 
and for the rest it is executed just the *NIX whois command.

So since the connection, and the data exchange structure are different, 
we need diferent scripts.

I attach now the files I metioned in my last email. If anybody can check 
why the whois_es script doesn't run... you will be my idol !

Note: I hae change the name os the scripts since they are located in 
specific place.

Thanks in advance.

Jason Pruim escribió:
>
> On Apr 28, 2008, at 10:58 AM, J. Manuel Velasco - UBILIBET wrote:
>
>> Ok, so I am going to try this one, Jason Pruim, let's check how it 
>> works ... :p
>>
>> PROBLEM DESCRIPTION:
>> In my whois web-app, when a EU doamin is queried, whois.pl perl 
>> script is lunched and I got the right result to my PHP script I the 
>> result is shown at the web.
>> If I do the query to a ES domain, other whois.pl script is lunched, 
>> but passthru doesn't execute it.
>> Both scripts are almost the same, they are in the same file 
>> structure, same machine, same permissions...
>
> Have you tried to use a program to compare the files? Make sure that 
> only the necessary lines are different?
>>
>>
>> The most strange is that I logged the command petition and If I copy 
>> and paste exaclty the same that is passed to passthru, the command 
>> for the whois to ESNIC is executed in the command line and shows the 
>> result.
>>
>> Collegues told me to check the ENV, permissions, and so on, I did 
>> with no results, also, the other perl script that is almost the same 
>> is executed, so I feel very very lost.
>>
>> Three files attached:
>> whois_es.pl         -> perl script to query whois in ESNIC
>> whois_eu.pl         -> perl script to query whois in EURID
>> container.php      -> intermediate page where the commands are build 
>> and passthru is executed.
>
> Is there any particular reason you are using different perl scripts 
> instead of a simple whois script for all of them?
>
> Also... the only attachment was your logo :)
>
>
>>
>>
>> Thank you very much for any hint. I feel lost almost one week with 
>> this BUG.
>>
>> Jason Pruim escribió:
>>>
>>> On Apr 28, 2008, at 10:32 AM, Thijs Lensselink wrote:
>>>
>>>> Quoting Daniel Brown <[email protected]>:
>>>>
>>>>> On Mon, Apr 28, 2008 at 7:00 AM, J. Manuel Velasco - UBILIBET
>>>>> <[email protected]> wrote:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> Anybody knows a good debugger for PHP and basic usage?
>>>>>
>>>>>    There's a pretty good one known as Jason Pruim.  ;-P
>>>>
>>>> ROFL!
>>>
>>>
>>> Yall have too much time on your hands! :P
>>>
>>>
>>>>
>>>>
>>>>>
>>>>> -- 
>>>>> </Daniel P. Brown>
>>>>> Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
>>>>> $59.99/mo. with no contract!
>>>>> Dedicated servers, VPS, and hosting from $2.50/mo.
>>>>>
>>>>> -- 
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>>
>>> -- 
>>>
>>> Jason Pruim
>>> Raoset Inc.
>>> Technology Manager
>>> MQC Specialist
>>> 3251 132nd ave
>>> Holland, MI, 49424-9337
>>> www.raoset.com
>>> [email protected]
>>>
>>>
>>>
>>>
>>
>> -- 
>> <Manucastellano.jpg>
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 3251 132nd ave
> Holland, MI, 49424-9337
> www.raoset.com <http://www.raoset.com>
> [email protected] <mailto:[email protected]>
>
>
>

--
whois_es.pl (application/x-perl, 2.8 KB)
#!/usr/bin/perl

package EPP::whois;

use strict;
use lib('/home/httpd/lib');
use UBILIBET::Debug;
use UBILIBET::Config qw(:path :epp :esnic);
use EPP::Client;
use EPP::Actions::ESNIC;

use UBILIBET::Log;
our $log = new UBILIBET::Log({'filename' => '/var/log/whois.log', 'screen' => 0, 'write' => 1, 'open' => 0});

use Data::Dumper;
################################################################################

my $nom = $ARGV[0] || die("No s'ha especificat cap domini");
my $ext = $ARGV[1] || 'es';
my $domain = {'nom' => $nom, 'extensio' => $ext };

$log->log("Dominio consultado: " .$domain->{'nom'}.".".$domain->{'extensio'});

my $epp = new EPP::Client({ 'url' => EPP_SERVER_URL,
   	                        'lib' => 'ESNIC',
      	                    'debug' => 0,
         	             });
$epp->setAuth('user', 'password');

my $dominiInfo = EPP::Actions::ESNIC::getDomainInfo($epp, $domain);

$log->log("Resultado: " . $dominiInfo->{'name'});

unless($dominiInfo) {
	print("Dominio no registrado en ESNIC\n");
	exit();
}

my $ca = EPP::Actions::ESNIC::getContactInfo($epp, $dominiInfo->{'contact'}->{'admin'});
my $ct = EPP::Actions::ESNIC::getContactInfo($epp, $dominiInfo->{'contact'}->{'tech'});

my $dns_str = join("\n", @{$dominiInfo->{'ns'}});

my $body = <<BODY;
################################################################################
# ESNIC WHOIS
################################################################################

___[ DOMINIO ]__________________________________________________________________
Nombre:           $dominiInfo->{'name'}
Handle:           $dominiInfo->{'handle'}
Fecha creaci�n:   $dominiInfo->{'creat'}
Fecha expiraci�n: $dominiInfo->{'expira'}

___[ TITULAR ]__________________________________________________________________
Nombre:		$dominiInfo->{'registrant'}
Puedes encontrar la informaci�n completa en el Whois oficial de ESNIC:
<a href="https://www.nic.es/esnic/esn/verValidacionWhoisAction?dominio=$nom.$ext" target="_blank">Whois ESNIC</a>

___[ CONTACTO ADMINISTRATIVO ]__________________________________________________
Nombre:		$ca->{'name'} ($ca->{'email'})
Handle:		$dominiInfo->{'contact'}->{'admin'}$dominiInfo->{'contact'}->{'admin'}
Direcci�n:	$ca->{'street'}
         	$ca->{'pc'}, $ca->{'city'} 
         	$ca->{'sp'} ($ca->{'cc'})
Tel�fono:	$ca->{'voice'}
Fax:			$ca->{'fax'}

___[ CONTACTO T�CNICO ]_________________________________________________________
Nombre:		$ct->{'name'} ($ct->{'email'})
Handle:		$dominiInfo->{'contact'}->{'tech'}
Direcci�n:	$ct->{'street'}
         	$ct->{'pc'}, $ct->{'city'} 
         	$ct->{'sp'} ($ct->{'cc'})
Tel�fono:	$ct->{'voice'}
Fax:			$ct->{'fax'}

___[ SERVIDORES DNS ]___________________________________________________________
$dns_str

BODY

print($body);
$log->log("BODY:" . $body);

1;
whois_eu.pl (application/x-perl, 4.6 KB)
#!/usr/bin/perl

package EPP::whois;

use strict;
use lib('/home/httpd/lib');
use UBILIBET::Debug;
use UBILIBET::Config qw(:path :epp :eurid);
use EURid::Client;
use EURid::Command;
use EURid::Actions;
use EURid::Actions::Domain;
use EURid::Actions::Contact;

use UBILIBET::Log;
our $log = new UBILIBET::Log({'filename' => '/var/log/whois.log', 'screen' => 0, 'write' => 1, 'open' => 0});

use Data::Dumper;
################################################################################

my $nom = $ARGV[0] || die("No s'ha especificat cap domini");
my $domain = {'nom' => $nom, 'extensio' => 'eu' }; 
my $client = new EURid::client({ 
               'server'  => EURID_SERVER_IP,	'port' => EURID_SERVER_PORT,
               'user'    => EURID_USER, 	'password' => EURID_PASSWORD,
               'debug'	 => 0,
             });
	$client->connect(1);
	$client->login();
	
$log->log("Dominio consultado: " .$domain->{'nom'}.".".$domain->{'extensio'});

my ($error, $response, $msg) = EURid::Actions::Domain::info($client, $domain);
if ($error) {
    $log->log("Resultado: ERROR - " .$error->{'num'});
	if ($error->{'num'} eq '2303') {
		print("Dominio no registrado en EURid\n");
		exit();
	} elsif ($error->{'num'} eq '2201') {
		print <<BODY;
		
################################################################################
# EURID WHOIS
################################################################################

La informaci�n de este dominio s�lo esta disponible en la web del registro.
Por favor visita su web:

<a href="http://www1.whois.eu/whois/GetDomainStatus.htm?domainName=$nom" target="_blank">WHOIS EURid</a>

BODY
		exit();
	} else {
		print Dumper($error);
		exit();
	}
}

my $dominiInfo = $response->{'resData'}->{'domain:infData'};
my $handles = {'registrant' => $dominiInfo->{'domain:registrant'}};
$log->log("Resultado: ". $dominiInfo->{'domain:name'});
foreach(@{$dominiInfo->{'domain:contact'}}) {
	$handles->{$_->{'type'}}=$_->{'content'};
}			
my $dns_str = '';
foreach(@{$dominiInfo->{'domain:ns'}->{'domain:hostAttr'}}) {
	$dns_str.=$_->{'domain:hostName'}."\n";
}

my ($error, $response, $msg) = EURid::Actions::Contact::info($client, $handles->{'registrant'});
my $cr = $response->{'resData'}->{'contact:infData'};
if (ref($cr->{'contact:postalInfo'}->{'contact:addr'}->{'contact:street'}) eq 'ARRAY') {
	$cr->{'contact:postalInfo'}->{'contact:addr'}->{'contact:street'} = 
		join ("\n            ", @{$cr->{'contact:postalInfo'}->{'contact:addr'}->{'contact:street'}});
}
my ($error, $response, $msg) = EURid::Actions::Contact::info($client, $handles->{'tech'});
my $ct = $response->{'resData'}->{'contact:infData'};
if (ref($ct->{'contact:postalInfo'}->{'contact:addr'}->{'contact:street'}) eq 'ARRAY') {
	$ct->{'contact:postalInfo'}->{'contact:addr'}->{'contact:street'} = 
		join ("\n            ", @{$ct->{'contact:postalInfo'}->{'contact:addr'}->{'contact:street'}});
}
my $body = <<BODY;
################################################################################
# EURID WHOIS
################################################################################

___[ DOMINIO ]__________________________________________________________________
Nombre:           $dominiInfo->{'domain:name'}
Fecha creaci�n:   $dominiInfo->{'domain:crDate'}
Fecha expiraci�n: $dominiInfo->{'domain:exDate'}

___[ TITULAR ]__________________________________________________________________
Nombre:     $cr->{'contact:postalInfo'}->{'contact:name'} ($cr->{'contact:email'})
Organiz.:   $cr->{'contact:postalInfo'}->{'contact:org'}
Handle:     $handles->{'registrant'}
Direcci�n:  $cr->{'contact:postalInfo'}->{'contact:addr'}->{'contact:street'}
            $cr->{'contact:postalInfo'}->{'contact:addr'}->{'contact:pc'}, $cr->{'contact:postalInfo'}->{'contact:addr'}->{'contact:city'}
            $cr->{'contact:postalInfo'}->{'contact:addr'}->{'contact:cc'}
Tel�fono:   $cr->{'contact:voice'}
Fax:        $cr->{'contact:fax'}

___[ CONTACTO T�CNICO ]_________________________________________________________
Nombre:     $ct->{'contact:postalInfo'}->{'contact:name'} ($ct->{'contact:email'})
Organiz.:   $ct->{'contact:postalInfo'}->{'contact:org'}
Handle:     $handles->{'tech'}
Direcci�n:  $ct->{'contact:postalInfo'}->{'contact:addr'}->{'contact:street'}
            $ct->{'contact:postalInfo'}->{'contact:addr'}->{'contact:pc'}, $ct->{'contact:postalInfo'}->{'contact:addr'}->{'contact:city'}
            $ct->{'contact:postalInfo'}->{'contact:addr'}->{'contact:cc'}
Tel�fono:   $ct->{'contact:voice'}
Fax:        $ct->{'contact:fax'}

___[ SERVIDORES DNS ]___________________________________________________________
$dns_str

BODY

print($body); 

1;
container.php (application/x-php, 1.9 KB)
<?php header('Content-Type: text/html; charset=UTF-8'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
  <head>
       <meta http-equiv="content-type" content="text/html; charset=utf-8">
       <title>UBILIBET :: Whois Search</title>
       <style type="text/css">
          body { font: 11px "Courier New"; }
       </style>
  </head>
  <body>
		<pre><?php
			require_once "include/captcha.php";
			$res = captcha::check();
			if (!$res) die('C�digo de validaci�n no v�lido');
			
			require_once 'lib.php';
			$nom =  isset($_REQUEST['nom'])? addslashes($_REQUEST['nom']):false;
			$ext = isset($_REQUEST['ext'])? addslashes($_REQUEST['ext']):false;
			if (!$nom || !$ext)  die();
			$nom = strtolower(trim($nom));
			
			require_once 'include/idn.php';
			error_reporting(E_ALL);
			$IDN = new idna_convert();
			$nom = $IDN->encode($nom);
			switch(strtolower($ext)) {
				case 'es':
				case 'com.es':
				case 'nom.es':
				case 'org.es':
				case 'edu.es':
				case 'gob.es':
				    $cmd = escapeshellcmd('/home/httpd/bin/esnic/whois.pl ' . EscapeShellCmd("$nom $ext"));
					break;
				case 'eu':
					$cmd = escapeshellcmd('/home/httpd/bin/eurid/whois.pl ' . EscapeShellCmd($nom));
					break;
				default:
					$cmd = escapeshellcmd('whois ' . EscapeShellCmd("$nom.$ext"));
			}
            $msg = date("d/m/T\tH:i:s\t") . " Ejecutando: " . $cmd . "\n";
            file_put_contents('/var/log/whois.log',$msg,FILE_APPEND);

            $pipe = '';
			ob_start();
				passthru($cmd,$retval);
				$pipe=ob_get_contents ();
				$pipe=ob_get_contents ();
			ob_end_clean();
			print($pipe);

            $msg = date("d/m/T\tH:i:s\t") . " Resultado: " . $retval . "\n" . $pipe . "\n----- ----- -----\n";
            file_put_contents('/var/log/whois.log',$msg,FILE_APPEND);

     	?>
     	</pre>
   </body>
</html>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.