XMailforum is a readonly knowledge archive now.

Registering as a new user or answering posts is not possible anymore.

Might the force be with you, to find here what you are looking for.

2019-09-20 - hschneider, Admin

Cookie Disclaimer: This forum uses only essential, anonymous session cookies (xmailforum*), nothing to be scared of.

XMail Forum -> Xqm 1.36, Xqm/cmd 0.93, Agent 1.24 Released!

Reply to this topicStart new topicStart Poll

> Xqm 1.36, Xqm/cmd 0.93, Agent 1.24 Released!, Download now!
fonsy
Posted: Sep 3 2003, 11:55 PM
Quote Post


Newbie
*

Group: Members
Posts: 22
Member No.: 165
Joined: 29-March 02



QUOTE (hschneider @ Sep 3 2003, 04:55 PM)
I see ... e.g. you can call xqm/cmd on the bsd machine by a CGI, sending its output to your Win2K machine.

I think about in first place.

The problem is that machine is only a mail server. Does not have apache, and no other services.

It did not want to resign to leave the maximum of resources for XMail.

In any case, I already solved it, at least at the moment (Very little *or nothing* elegant way).

I studied the protocol which you use between the agent and the XQM, putting proxy in the middle, and modifying an old ASP that it had for another thing.

query, soon query_status 1, hoping the 0 and to request query_result, parse the string ___NEXT___.

I think that it will work to me, while does not make an update of the agent.

I believe, I already saying, but I do not get tired to say it. You have done one of greatest XMail utilities, and port it to FreeBSD a great favor! :-)
PMUsers WebsiteICQMSN
Top
fonsy
Posted: Sep 4 2003, 05:19 AM
Quote Post


Newbie
*

Group: Members
Posts: 22
Member No.: 165
Joined: 29-March 02



QUOTE (fonsy @ Sep 4 2003, 12:55 AM)
QUOTE (hschneider @ Sep 3 2003, 04:55 PM)
I see ... e.g. you can call xqm/cmd on the bsd machine by a CGI, sending its output to your Win2K machine.

I think about in first place.

The problem is that machine is only a mail server. Does not have apache, and no other services.
[...]

In case of anyone are in seemed situation:

In order to make it more portable, and works as much in Windows as in UNIX, I passed it to PHP.

The final configuration:

Using CRON or AT (UNIX or Windows), Xqm-cmd does "query" every x minutes / hours.

The PHP file, requests the result of that query, but without updating it. Thus it goes very fast.

The code of the PHP is here: (I'm only test it on Windows, at this moment...)

CODE

<?

//Valores iniciales.
//Initial values


//IP del XQM-Agent
//XQM-Agent IP
$IP = "192.168.100.7";

//Puerto TCP del XQM-Agent
//XQM-Agent TCP Port
$Puerto = 8000;

//Error de TimeOUT en segundos
//TimeOUT error in seconds
$TimeOUT = 60;

//Retorno de carro y avance de línea
//Carrier return and line feed
$CrLf = chr(13).chr(10);
$Cr = chr(13);
$Lf = chr(10);

$Resultado = "";

$XML = "";
$Cabecera = "";

//Establecer conexión.
//Make conection
$XQM_Agent = fsockopen($IP, $Puerto, &$NroError, &$TextoError, $TimeOUT);

//Comprobar la conexión.
//Check if conected.
if(!$XQM_Agent) {
   echo "No se pudo establacer conexión!\n<br>(".$NroError.") ".$TextoError."<br>";
   exit();
}    


//Código XML
$XML = "<?xml version='1.0'?>".Chr(10);
$XML = $XML."<methodCall>".Chr(10);
$XML = $XML."<methodName>query_result</methodName>".Chr(10);
$XML = $XML."<params>".Chr(10);
$XML = $XML."</params>".Chr(10);
$XML = $XML."</methodCall>";

//Cabecera de la petición.
//Petition header.
$Cabecera = "POST /RPC2 HTTP/1.0".$CrLf;
$Cabecera = $Cabecera."Host: ".$IP.":".$Puerto.$CrLf;
$Cabecera = $Cabecera."User-Agent: Script chorra".$CrLf;
$Cabecera = $Cabecera."Content-Type: text/xml".$CrLf;
$Cabecera = $Cabecera."Content-Length: ".strlen($XML).$CrLf;


//Enviar la petición
//Send petition
fputs($XQM_Agent, $Cabecera.$CrLf.$XML.$CrLf);

//Guardar la respuesta en un buffer
//Save response in buffer.
$Buffer = fgets($XQM_Agent, 32);

//Si es la respuesta esperada, todo Ok.
//If is the waiting for answer, all Ok.
if ($Buffer='HTTP/1.0 200 OK'){

//Esperar por la respuesta (Cabecera + XML)
//Wait for response (Header and XML)
while ($Buffer = fgets($XQM_Agent,128)){

 //Ir acumulando la respuesta.
 //Accumulating responses.
        $Respuesta = $Respuesta.$Buffer;
}

}else{
//Si la respuesta no es la esperada, detener el proceso.
//If the answer we do not like, stop the process.
echo "<br>\nError de conexión...<br>\n".$Buffer;

}

//Cerrar la conexión.
//Close conection.
fclose($XQM_Agent);

//Separar la Cabecera y el XML, reutilizando las variables anteriores.
//Split Header and XML, reusing the previous variables.
list($Cabecera, $XML) = split ("\r\n\r",$Respuesta,2);

/*

Ya se que, llegados a este punto, se podría hacer una búsqueda
vulgar en el texto, y extraer el campo *string* "a lo macho"...

Pero ya que hemos llegado hasta aquí, por qué no hacerlo bien? :-)


I already know, once we are at this point, we can made a vulgar
search in the text, and extract the *string* field "a lo macho"...  

But since we have arrived up to here, why not to do it well? :-)

*/

//Limpiar el XML.
//Clean XML.
$XML=trim($XML);

//El parse elimina los CrLf que son separadores en *string*. Hay que reemplazarlos.
//Parser eliminates the CrLf that is delimiting in *string* field. Is necessary to replace them.

//Quitar primero cualquier \n que no esté en *string*
//Clear first any \n that is not in *string*
$XML=trim(ereg_replace(">\n",">", $XML));

//Reemplazar los \n en *string*, por el asterisco (*)
//Replace \n in *string*, by the asterisk (*)
$XML=ereg_replace("\n","*", $XML);


//Usar el parser del XML para interpretar la respuesta del XQM-Agent.
//Use XML parser to interpret the answer of the XQM-Agent.
$Parser = xml_parser_create();
xml_parser_set_option($Parser,XML_OPTION_CASE_FOLDING,0);
xml_parser_set_option($Parser,XML_OPTION_SKIP_WHITE,1);
xml_parse_into_struct($Parser,$XML,$Valores,$Campos);
xml_parser_free($Parser);

//Buscar el campo 'string'
//Find 'string' field
foreach ($Campos as $Campo=>$Valor) {
if ($Campo == "string") {

 //Obtener el valor del campo
 //Get field value
 $Resultado = $Valores[$Valor[0]]["value"];

} else {

 continue;

}
}

//Guardar la información en un array.
//Save information on array.
$Mensajes = split ("__NEXT__",urldecode($Resultado));



//Aquí insertar el código apropiado...
//Insert here your code.


//Ejemplo:
//Sample

$Planos = array("<",">");
$Codigos = array("&lt;","&gt;");

foreach ($Mensajes as $Mensaje) {

List ($Tipo, $Fecha, $Remitente, $Destinatario, $Asunto, $Fichero, $Tamaño, $Diagnostico) = explode('*', substr($Mensaje,1,strlen($Mensaje)-1));

if (!$Tipo == ""){


 echo "\n<hr>";
 echo "\n<br>Tipo: ".$Tipo;
 echo "\n<br>Fecha: ".$Fecha;
 echo "\n<br>Remitente: ".str_replace($Planos, $Codigos, $Remitente);
 echo "\n<br>Destinatario: ".str_replace($Planos, $Codigos, $Destinatario);
 echo "\n<br>Asunto: ".quoted_printable_decode($Asunto);
 echo "\n<br>Fichero: ".$Fichero;
 echo "\n<br>Tamaño: ".$Tamaño;
 echo "\n<br>Diagnostico: ".$Diagnostico;
}
}

?>
PMUsers WebsiteICQMSN
Top
hschneider
Posted: Sep 4 2003, 05:49 AM
Quote Post


No - I'm not an answering script ...
Group Icon

Group: Admin
Posts: 6631
Member No.: 195
Joined: 19-June 02



>... to request query_result, parse the string ___NEXT___.
I see y... you're a real HACKER :-)

> I think that it will work to me, while does not make an update of the agent.
The protocol is XML RPC, which is standardized. IT will never be touched by any update. Maybe its data content will change some day, but you see it is easy to parse.

>I believe, I already saying, but I do not get tired to say it. You have done one of >greatest XMail utilities, and port it to FreeBSD a great favor! :-)

Thanks! wub.gif


--------------------
Bye,
Harald


-- Download XMail Queue Manager 1.46 NOW: XMail Server Tools
-- Cross platform remote queue management!
-- Message analyzing on the fly!
-- Builtin diagnostics knowledge base!
-- Manages multiple mail queues!

Sponsored by
CD-Produktion und DVD-Produktion and Homestaging Saarland - Immobilien schneller verkaufen in der Region Saarland, Rheinland-Pfalz und Luxembourg
PMEmail PosterUsers Website
Top
fonsy
  Posted: Sep 4 2003, 06:09 AM
Quote Post


Newbie
*

Group: Members
Posts: 22
Member No.: 165
Joined: 29-March 02



QUOTE

I see y... you're a real HACKER :-)

Jajajajajajajajaja
Nothing else far from the truth...

The truth is that I have been as much time as teacher on networking, that almost I can't remember what is programming!

QUOTE

The protocol is XML RPC, which is standardized. IT will never be touched by any update. Maybe its data content will change some day, but you see it is easy to parse.

That sounds very good! :-)
PMUsers WebsiteICQMSN
Top
hschneider
Posted: Sep 4 2003, 09:33 AM
Quote Post


No - I'm not an answering script ...
Group Icon

Group: Admin
Posts: 6631
Member No.: 195
Joined: 19-June 02



To make things complete, here a complete listing of the Agent's RPCs:

CODE

   def version(self):
       return(VERSION)
   
   def versionstring(self):
       return('XQM_Agent '+VERSION+'/' + sys.platform)
   
   def platform(self):
       return(sys.platform)
   
   def ping(self):
       return('ALIVE')
   
   def preflight(self):
       self.Server.queue.preflight()
       return(0)
   
   def server_start(self):
       self.Server.start()
       return(0)
       
   def server_stop(self,force=0):
       self.Server.stop(force)
       return(0)
       
   def server_restart(self,async=0):
       self.Server.restart(async)
       return(0)
   
   def server_status(self,verbose=0):
       return(self.Server.status(verbose))
       
   def query(self):
       self.qresult = ''
       t = TRun(self.qstatus, self.Server.queue.query2, self._listadd)
       #self.Server.queue.query2(self._listadd)
       return()
       
   def query_status(self):
       return(self.qstatus.value)
   
   def query_result(self):
       if self.qstatus.value == 0:
           return(self.qresult)
       else:
           return('')

   def query_stop(self):
       self.Server.queue.stop_query()
       return()
       
   def lastquery(self):
       return(self.Server.queue.lastquery)

   def inspect(self, file):
       m = xmaillib.Spoolfile(file)
       return(urllib.quote(m.content + '__SLOG__' + m.slog))
   
   def remove(self, file):
       self.Server.queue.remove(file)
       return()

   def removeall_mess(self):
       self.Server.queue.removeall_mess()
       return()    

   def removeall_rsnd(self):
       self.Server.queue.removeall_rsnd()
       return()  
   
   def removeall_froz(self):
       self.Server.queue.removeall_froz()
       return()  

   def defrost(self, file):
       self.Server.queue.defrost(file)
       return()    

   def defrostall(self):
       self.Server.queue.defrostall()
       return()      

   def flush(self, server='127.0.0.1', port='6017'):
       try:
           return(self.Server.queue.flush(self.ctrl_host,self.ctrl_port))
       except:
           return('No CTRL access !')
   
   def stat(self):
       return("%s\n%s\n%s\n%s" % self.Server.queue.stat())



--------------------
Bye,
Harald


-- Download XMail Queue Manager 1.46 NOW: XMail Server Tools
-- Cross platform remote queue management!
-- Message analyzing on the fly!
-- Builtin diagnostics knowledge base!
-- Manages multiple mail queues!

Sponsored by
CD-Produktion und DVD-Produktion and Homestaging Saarland - Immobilien schneller verkaufen in der Region Saarland, Rheinland-Pfalz und Luxembourg
PMEmail PosterUsers Website
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
« Next Oldest | XMail Queue Manager | Next Newest »

Reply to this topicStart new topicStart Poll