habe eine mozrepl-Applikation gefunden - die mit PHP läuft.
Hier; http://www.codediesel.com/tools/peeking-inside-firefox-using-mozrepl/
Hab die Codeschnippel mal installiert - auf einer opensuse 12.2
das hier:
- Code: Select all
<?php
require_once('socketHelper.php');
/* Commands to send to MozRepl */
$commands=<<<EOD
repl.whereAmI()
content.location.href = 'http://google.com'
repl.quit()
EOD;
$firefox_socket = new SocketHelper;
if(!$firefox_socket->connect()) exit;
foreach(explode("\n",$commands) as $command){
if($command=='')continue; //Skip blank lines
echo $firefox_socket->send_command($command);
}
?>
und den folgenden Code - eine Klasse die die Socketarbeit übernimmt.
- Code: Select all
<?php
/* socketHelper.php */
class SocketHelper
{
private $address = "127.0.0.1";
private $port = "4242";
private $socket = null;
public function connect()
{
$this->socket=socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
if(!$this->socket){
socket_strerror($this->socket)."\n";
return false;
}
$result=socket_connect($this->socket,$this->address,$this->port);
if(!$result){
socket_strerror($result)."\n";
socket_close($this->socket);
return false;
}
$this->read();
return true;
}
/** Send a command to MozRepl */
public function send_command($command){
$command.="\n";
socket_write($this->socket,$command);
return $this->read();
}
/*
Read from the Socket until we get a "repl>" prompt,
or loop forever.
*/
private function read(){
$response = '';
while(1){
$chunk = socket_read($this->socket,65536,PHP_BINARY_READ);
if($chunk === false){
echo "Error reading from socket\n";
break;
}
if($chunk === "") break; //No more data
if(preg_match('|^(.*)\s*repl\d*>\s*$|s',$chunk,$match)){
$response .= $match[1];
break;
}
$response .= $chunk;
}
return $response;
}
}
?>
die Resultate im Terminal
- Code: Select all
martin@linux-wyee:~> cd php
martin@linux-wyee:~/php> php moz1.php
PHP Fatal error: Call to undefined function socket_create() in /home/martin/php/socketHelper.php on line 14
martin@linux-wyee:~/php>
Also - ich denk dass ich da noch was vergessen hab - da istnoch was falsch;
Mozilla selber - da ist Javascript auf on und ausserdem hoert der Mozrepl dort auf port 4242
hab ich denn noch was vergessen ?!?
unleash