+ * ;; activate the PHPDebugger in the php.ini
+ * auto_prepend_file=PHPDebugger.php
+ *
+ *
+ * - Debug your PHP scripts as usual.
+ *
+ *
+ * @category java
+ * @package pdb
+ * @author Jost Boekemeier
+ * @license GPL+Classpath exception
+ * @version 7.0
+ * @link http://php-java-bridge.sf.net/phpdebugger
+ */
+
+
+/** @access private */
+define ("PDB_DEBUG", 0);
+set_time_limit (0);
+if(!function_exists("token_get_all")) {
+ dl("tokenizer.so");
+}
+
+if ($pdb_script_orig = $pdb_script = pdb_getDebugHeader("X_JAVABRIDGE_INCLUDE", $_SERVER)) {
+ if ($pdb_script!="@") {
+ if (($_SERVER['REMOTE_ADDR']=='127.0.0.1') || (($pdb_script = realpath($pdb_script)) && (!strncmp($_SERVER['DOCUMENT_ROOT'], $pdb_script, strlen($_SERVER['DOCUMENT_ROOT']))))) {
+ if(pdb_getDebugHeader("X_JAVABRIDGE_INCLUDE", $_SERVER)>=10) { // include Java.inc as well
+ require_once("Java.inc");
+ }
+ chdir (dirname ($pdb_script));
+ $_SERVER['SCRIPT_FILENAME'] = $pdb_script; // set to the original script filename
+ } else {
+ trigger_error("illegal access: ".$pdb_script_orig, E_USER_ERROR);
+ unset($pdb_script);
+ }
+ }
+}
+
+
+
+if (!class_exists("pdb_Parser")) {
+ /**
+ * The PHP parser
+ * @access private
+ */
+ class pdb_Parser {
+ const BLOCK = 1;
+ const STATEMENT = 2;
+ const EXPRESSION = 3;
+ const FUNCTION_BLOCK = 4; // BLOCK w/ STEP() as last statement
+
+ private $scriptName, $content;
+ private $code;
+ private $output;
+ private $line, $currentLine;
+ private $beginStatement, $inPhp, $inDQuote;
+
+ /**
+ * Create a new PHP parser
+ * @param string the script name
+ * @param string the script content
+ * @access private
+ */
+ public function __construct($scriptName, $content) {
+ $this->scriptName = $scriptName;
+ $this->content = $content;
+ $this->code = token_get_all($content);
+ $this->output = "";
+ $this->line = $this->currentLine = 0;
+ $this->beginStatement = $this->inPhp = $this->inDQuote = false;
+ }
+
+ private function toggleDQuote($chr) {
+ if ($chr == '"') $this->inDQuote = !$this->inDQuote;
+ }
+
+ private function each() {
+ $next = each ($this->code);
+ if ($next) {
+ $cur = current($this->code);
+ if (is_array($cur)) {
+ $this->currentLine = $cur[2] + ($cur[1][0] == "\n" ? substr_count($cur[1], "\n") : 0);
+ if ($this->isWhitespace($cur)) {
+ $this->write($cur[1]);
+ return $this->each();
+ }
+ }
+ else
+ $this->toggleDQuote($cur);
+ }
+ return $next;
+ }
+
+ private function write($code) {
+ //echo "write:::".$code."\n";
+ $this->output.=$code;
+ }
+
+ private function writeInclude($once) {
+ $name = "";
+ while(1) {
+ if (!$this->each()) die("parse error");
+ $val = current($this->code);
+ if (is_array($val)) {
+ $name.=$val[1];
+ } else {
+ if ($val==';') break;
+ $name.=$val;
+ }
+ }
+ if (PDB_DEBUG == 2)
+ $this->write("EVAL($name);");
+ else
+ $this->write("eval('?>'.pdb_startInclude($name, $once)); pdb_endInclude();");
+ }
+
+ private function writeCall() {
+ while(1) {
+ if (!$this->each()) die("parse error");
+ $val = current($this->code);
+ if (is_array($val)) {
+ $this->write($val[1]);
+ } else {
+ $this->write($val);
+ if ($val=='{') break;
+ }
+ }
+ $scriptName = addslashes($this->scriptName);
+ $this->write("\$__pdb_CurrentFrame=pdb_startCall(\"$scriptName\", {$this->currentLine});");
+ }
+
+ private function writeStep($pLevel) {
+ $token = current($this->code);
+ if ($this->inPhp && !$pLevel && !$this->inDQuote && $this->beginStatement && !$this->isWhitespace($token) && ($this->line != $this->currentLine)) {
+ $line = $this->line = $this->currentLine;
+ $scriptName = addslashes($this->scriptName);
+ if (PDB_DEBUG == 2)
+ $this->write(";STEP($line);");
+ else
+ $this->write(";pdb_step(\"$scriptName\", $line, pdb_getDefinedVars(get_defined_vars(), (isset(\$this) ? \$this : NULL)));");
+ }
+ }
+
+ private function writeNext() {
+ $this->next();
+ $token = current($this->code);
+ if (is_array($token)) $token = $token[1];
+ $this->write($token);
+ }
+
+ private function nextIs($chr) {
+ $i = 0;
+ while(each($this->code)) {
+ $cur = current($this->code);
+ $i++;
+ if (is_array($cur)) {
+ switch ($cur[0]) {
+ case T_COMMENT:
+ case T_DOC_COMMENT:
+ case T_WHITESPACE:
+ break; /* skip */
+ default:
+ while($i--) prev($this->code);
+ return false; /* not found */
+ }
+ } else {
+ while($i--) prev($this->code);
+ return $cur == $chr; /* found */
+ }
+ }
+ while($i--) prev($this->code);
+ return false; /* not found */
+ }
+
+ private function nextTokenIs($ar) {
+ $i = 0;
+ while(each($this->code)) {
+ $cur = current($this->code);
+ $i++;
+ if (is_array($cur)) {
+ switch ($cur[0]) {
+ case T_COMMENT:
+ case T_DOC_COMMENT:
+ case T_WHITESPACE:
+ break; /* skip */
+ default:
+ while($i--) prev($this->code);
+ return (in_array($cur[0], $ar));
+ }
+ } else {
+ break; /* not found */
+ }
+ }
+ while($i--) prev($this->code);
+ return false; /* not found */
+ }
+
+ private function isWhitespace($token) {
+ $isWhitespace = false;
+ switch($token[0]) {
+ case T_COMMENT:
+ case T_DOC_COMMENT:
+ case T_WHITESPACE:
+ $isWhitespace = true;
+ break;
+ }
+ return $isWhitespace;
+ }
+ private function next() {
+ if (!$this->each()) trigger_error("parse error", E_USER_ERROR);
+ }
+
+ private function parseBlock () {
+ $this->parse(self::BLOCK);
+ }
+ private function parseFunction () {
+ $this->parse(self::FUNCTION_BLOCK);
+ }
+ private function parseStatement () {
+ $this->parse(self::STATEMENT);
+ }
+ private function parseExpression () {
+ $this->parse(self::EXPRESSION);
+ }
+
+ private function parse ($type) {
+ pdb_Logger::debug("parse:::$type");
+
+ $this->beginStatement = true;
+ $pLevel = 0;
+
+ do {
+ $token = current($this->code);
+ if (!is_array($token)) {
+ pdb_Logger::debug(":::".$token);
+ if (!$pLevel && $type==self::FUNCTION_BLOCK && $token=='}') $this->writeStep($pLevel);
+ $this->write($token);
+ if ($this->inPhp && !$this->inDQuote) {
+ $this->beginStatement = false;
+ switch($token) {
+ case '(':
+ $pLevel++;
+ break;
+ case ')':
+ if (!--$pLevel && $type==self::EXPRESSION) return;
+ break;
+ case '{':
+ $this->next();
+ $this->parseBlock();
+ break;
+ case '}':
+ if (!$pLevel) return;
+ break;
+ case ';':
+ if (!$pLevel) {
+ if ($type==self::STATEMENT) return;
+ $this->beginStatement = true;
+ }
+ break;
+ }
+ }
+ } else {
+ pdb_Logger::debug(":::".$token[1].":(".token_name($token[0]).')');
+
+ if ($this->inDQuote) {
+ $this->write($token[1]);
+ continue;
+ }
+
+ switch($token[0]) {
+
+ case T_OPEN_TAG:
+ case T_START_HEREDOC:
+ case T_OPEN_TAG_WITH_ECHO:
+ $this->beginStatement = $this->inPhp = true;
+ $this->write($token[1]);
+ break;
+
+ case T_END_HEREDOC:
+ case T_CLOSE_TAG:
+ $this->writeStep($pLevel);
+
+ $this->write($token[1]);
+ $this->beginStatement = $this->inPhp = false;
+ break;
+
+ case T_FUNCTION:
+ $this->write($token[1]);
+ $this->writeCall();
+ $this->next();
+ $this->parseFunction();
+ $this->beginStatement = true;
+ break;
+
+ case T_ELSE:
+ $this->write($token[1]);
+ if ($this->nextIs('{')) {
+ $this->writeNext();
+ $this->next();
+
+ $this->parseBlock();
+ } else {
+ $this->next();
+
+ /* create an artificial block */
+ $this->write('{');
+ $this->beginStatement = true;
+ $this->writeStep($pLevel);
+ $this->parseStatement();
+ $this->write('}');
+
+ }
+ if ($type==self::STATEMENT) return;
+
+ $this->beginStatement = true;
+ break;
+
+ case T_DO:
+ $this->writeStep($pLevel);
+ $this->write($token[1]);
+ if ($this->nextIs('{')) {
+ $this->writeNext();
+ $this->next();
+
+ $this->parseBlock();
+ $this->next();
+
+ } else {
+ $this->next();
+
+ /* create an artificial block */
+ $this->write('{');
+ $this->beginStatement = true;
+ $this->writeStep($pLevel);
+ $this->parseStatement();
+ $this->next();
+ $this->write('}');
+ }
+ $token = current($this->code);
+ $this->write($token[1]);
+
+ if ($token[0]!=T_WHILE) trigger_error("parse error", E_USER_ERROR);
+ $this->next();
+ $this->parseExpression();
+
+ if ($type==self::STATEMENT) return;
+
+ $this->beginStatement = true;
+ break;
+
+ case T_CATCH:
+ case T_IF:
+ case T_ELSEIF:
+ case T_FOR:
+ case T_FOREACH:
+ case T_WHILE:
+ $this->writeStep($pLevel);
+
+ $this->write($token[1]);
+ $this->next();
+
+ $this->parseExpression();
+
+ if ($this->nextIs('{')) {
+ $this->writeNext();
+ $this->next();
+
+ $this->parseBlock();
+
+
+ } else {
+ $this->next();
+ /* create an artificial block */
+ $this->write('{');
+ $this->beginStatement = true;
+ $this->writeStep($pLevel);
+ $this->parseStatement();
+ $this->write('}');
+ }
+
+ if ($this->nextTokenIs(array(T_ELSE, T_ELSEIF, T_CATCH))) {
+ $this->beginStatement = false;
+ } else {
+ if ($type==self::STATEMENT) return;
+ $this->beginStatement = true;
+ }
+ break;
+
+ case T_REQUIRE_ONCE:
+ case T_INCLUDE_ONCE:
+ case T_INCLUDE:
+ case T_REQUIRE:
+ $this->writeStep($pLevel);
+ $this->writeInclude((($token[0]==T_REQUIRE_ONCE) || ($token[0]==T_INCLUDE_ONCE)) ? 1 : 0);
+
+ if ($type==self::STATEMENT) return;
+
+ $this->beginStatement = true;
+ break;
+
+ case T_CLASS:
+ $this->write($token[1]);
+ $this->writeNext();
+ if ($this->nextIs('{')) {
+ $this->writeNext();
+ $this->next();
+ $this->parseBlock();
+ $this->beginStatement = true;
+ } else {
+ $this->writeNext();
+ $this->beginStatement = false;
+ }
+ break;
+
+ case T_CASE:
+ case T_DEFAULT:
+ case T_PUBLIC:
+ case T_PRIVATE:
+ case T_PROTECTED:
+ case T_STATIC:
+ case T_CONST:
+ case T_GLOBAL:
+ case T_ABSTRACT:
+ $this->write($token[1]);
+ $this->beginStatement = false;
+ break;
+
+ default:
+ $this->writeStep($pLevel);
+ $this->write($token[1]);
+ $this->beginStatement = false;
+ break;
+
+ }
+ }
+ } while($this->each());
+ }
+
+ /**
+ * parse the given PHP script
+ * @return the parsed PHP script
+ * @access private
+ */
+ public function parseScript() {
+ do {
+ $this->parseBlock();
+ } while($this->each());
+
+ return $this->output;
+ }
+ }
+}
+
+/**
+ * @access private
+ */
+class pdb_Logger {
+ const FATAL = 1;
+ const INFO = 2;
+ const VERBOSE = 3;
+ const DEBUG = 4;
+
+ private static $logLevel = 0;
+ private static $logFileName;
+
+ private static function println($msg, $level) {
+ if (!self::$logLevel) self::$logLevel=PDB_DEBUG?self::DEBUG:self::INFO;
+ if ($level <= self::$logLevel) {
+ static $file = null;
+ if(!isset(self::$logFileName)) {
+ self::$logFileName = $_SERVER['HOME'].DIRECTORY_SEPARATOR."pdb_PHPDebugger.inc.log";
+ }
+ if (!$file) $file = fopen(self::$logFileName, "ab") or die("fopen");
+ fwrite($file, time().": ");
+ fwrite($file, $msg."\n");
+ fflush($file);
+ }
+ }
+
+ public static function logFatal($msg) {
+ self::println($msg, self::FATAL);
+ }
+ public static function logInfo($msg) {
+ self::println($msg, self::INFO);
+ }
+ public static function logMessage($msg) {
+ self::println($msg, self::VERBOSE);
+ }
+ public static function logDebug($msg) {
+ self::println($msg, self::DEBUG);
+ }
+ public static function debug($msg) {
+ self::logDebug($msg);
+ }
+ public static function log($msg) {
+ self::logMessage($msg);
+ }
+ public static function setLogLevel($level) {
+ self::$logLevel=$level;
+ }
+ public static function setLogFileName($name) {
+ self::$logFileName = $name;
+ }
+}
+
+/**
+ * @access private
+ */
+class pdb_Environment {
+ public $filename, $stepNext;
+ public $vars, $line, $firstLine;
+ public $parent;
+
+ public function __construct($parent, $filename, $stepNext, $firstLine) {
+ $this->parent = $parent;
+ $this->filename = $filename;
+ $this->stepNext = $stepNext;
+ $this->firstLine = $firstLine;
+ $this->line = -1;
+ }
+
+ public function update ($line, &$vars) {
+ $this->line = $line;
+ $this->vars = &$vars;
+ }
+ public function __toString() {
+ return "pdb_Environment: {$this->filename}, {$this->firstLine} - {$this->line}";
+ }
+}
+
+/**
+ * @access private
+ */
+abstract class pdb_Message {
+ public $session;
+
+ public abstract function getType();
+
+ public function __construct($session) {
+ $this->session = $session;
+ }
+
+ public function serialize() {
+ $this->session->out->writeShort($this->getType());
+ }
+
+ private static $messages = array();
+ public static function register($message) {
+ pdb_Message::$messages[$message->getType()] = $message;
+ }
+ public function getMessageById($id) {
+ $message = pdb_Message::$messages[$id];
+ return $message;
+ }
+ public function getMessage() {
+ $id = $this->session->in->readShort();
+ $message = $this->getMessageById($id);
+ if (!$message) trigger_error("invalid message: $id", E_USER_ERROR);
+ $message->deserialize();
+ return $message;
+ }
+
+ protected function handleContinueProcessFile($message) {
+ $code = $this->session->parseCode($this->currentFrame->filename, file_get_contents($this->currentFrame->filename));
+ if (PDB_DEBUG) pdb_Logger::debug( "parse file:::" . $code ."\n");
+ if (!PDB_DEBUG) ob_start();
+ self::doEval ($code);
+ $output = $this->getMessageById(pdb_OutputNotification::TYPE);
+ if(!PDB_DEBUG) $output->setOutput(ob_get_contents());
+ if(!PDB_DEBUG) ob_end_clean();
+ $output->serialize();
+ $this->status = 42; //FIXME
+ $this->getMessageById(pdb_DebugScriptEndedNotification::TYPE)->serialize();
+ return true;
+ }
+ private static function doEval($__pdb_Code) {
+ return eval ("?>".$__pdb_Code);
+ }
+ protected function handleStep($message) {
+ return false;
+ }
+ protected function handleGo($message) {
+ foreach ($this->session->allFrames as $frame) {
+ $frame->stepNext = false;
+ }
+ return true; // exit
+ }
+ public function handleRequests () {
+ $this->ignoreInterrupt = false;
+
+ $this->serialize();
+ while(1) {
+ $message = $this->getMessage();
+ switch ($message->getType()) {
+ case pdb_SetProtocolRequest::TYPE:
+ $message->ack();
+ break;
+ case pdb_StartRequest::TYPE:
+ $message->ack();
+ $this->getMessageById(pdb_StartProcessFileNotification::TYPE)->serialize();
+ break;
+ case pdb_ContinueProcessFileNotification::TYPE:
+ if ($this->handleContinueProcessFile($message)) return pdb_ContinueProcessFileNotification::TYPE;
+ break;
+ case pdb_AddBreakpointRequest::TYPE:
+ $message->ack();
+ break;
+ case pdb_RemoveBreakpointRequest::TYPE:
+ $message->ack();
+ break;
+ case pdb_RemoveAllBreakpointsRequest::TYPE:
+ $message->ack();
+ break;
+ case pdb_GetCallStackRequest::TYPE:
+ $message->ack();
+ break;
+ case pdb_GetCWDRequest::TYPE:
+ $message->ack();
+ break;
+ case pdb_GetVariableValueRequest::TYPE:
+ $message->ack();
+ break;
+ case pdb_AddFilesRequest::TYPE:
+ $message->ack();
+ break;
+ case pdb_FileContentExtendedRequest::TYPE:
+ $message->ack();
+ break;
+ case pdb_MsgEvalRequest::TYPE:
+ $message->ack();
+ break;
+ case pdb_GoRequest::TYPE:
+ $message->ack();
+ if ($this->handleGo($message)) return pdb_GoRequest::TYPE;
+ break;
+ case pdb_StepOverRequest::TYPE:
+ $message->ack();
+ if ($this->handleStep($message)) return pdb_StepOverRequest::TYPE;
+ break;
+ case pdb_StepIntoRequest::TYPE:
+ $message->ack();
+ if ($this->handleStep($message)) return pdb_StepIntoRequest::TYPE;
+ break;
+ case pdb_StepOutRequest::TYPE:
+ $message->ack();
+ if ($this->handleStep($message)) return pdb_StepOutRequest::TYPE;
+ break;
+ case pdb_End::TYPE:
+ $this->session->end();
+ default: trigger_error("protocol error: $message", E_USER_ERROR);
+ }
+ }
+ }
+}
+/**
+ * @access private
+ */
+abstract class pdb_MessageRequest extends pdb_Message {
+ public abstract function ack();
+}
+
+/**
+ * @access private
+ */
+class pdb_Serializer {
+ private $serial;
+ private $depth;
+
+ private function doSerialize ($o, $depth) {
+ $serial = &$this->serial;
+
+ switch(gettype($o)) {
+ case 'object':
+ $serial.="O:";
+ $serial.=strlen(get_class($o));
+ $serial.=":\"";
+ $serial.=get_class($o);
+ $serial.="\":";
+ $serial.=count((array)$o);
+
+ if ($depth <= $this->depth) {
+ $serial.=":{";
+ foreach((array)$o as $k=>$v) {
+ $serial.=serialize($k);
+ $this->doSerialize($v, $depth+1);
+ }
+ $serial.="}";
+ } else {
+ $serial .= ";";
+ }
+ break;
+
+ case 'array':
+ $serial.="a:";
+ $serial.=count($o);
+
+ if ($depth <= $this->depth) {
+ $serial.=":{";
+ foreach($o as $k=>$v) {
+ $serial.=serialize($k);
+ $this->doSerialize($v, $depth+1);
+ }
+ $serial.="}";
+ } else {
+ $serial.=";";
+ }
+ break;
+ default:
+ $serial.=serialize($o);
+ break;
+ }
+ }
+
+ public function serialize ($obj, $depth) {
+ $this->serial = "";
+ $this->depth = $depth;
+
+ $this->doSerialize ($obj, 1);
+
+ return $this->serial;
+ }
+}
+
+/**
+ * @access private
+ */
+class pdb_DebugSessionStart extends pdb_Message {
+ const TYPE = 2005;
+
+ public $status;
+ public $end;
+
+ private $breakFirstLine;
+ private $enable;
+ public $uri;
+ public $query;
+ public $options;
+
+ public $in, $out;
+ private $outputNotification;
+
+ public $lines;
+ public $breakpoints;
+
+ public $currentTopLevelFrame, $currentFrame;
+ public $allFrames; // should be a weak map so that frames could be gc'ed
+
+ public $ignoreInterrupt;
+
+ public $serializer;
+
+ public $includedScripts;
+
+ public function getType() {
+ return self::TYPE;
+ }
+ public function __construct($options) {
+ parent::__construct($this);
+ $this->end = true;
+ if (isset($_SERVER["SCRIPT_FILENAME"]) && isset($_SERVER["QUERY_STRING"])&&!extension_loaded("Zend Debugger")) {
+ $filename = $uri = $_SERVER["SCRIPT_FILENAME"];
+ $queryStr = $_SERVER["QUERY_STRING"];
+ } else {
+ $this->enable = false;
+ return;
+ }
+
+ $params = explode('&', $queryStr);
+ $args = array();
+ for ($i=0; $i", htmlspecialchars($key, ENT_COMPAT))); + $this->write(sprintf("
", htmlspecialchars($key, ENT_COMPAT,"ISO-8859-1"))); } function writePairBegin_n($key) { $this->write(sprintf("
",$key));
diff --git a/legacy/server/META-INF/java/SimpleParser.inc b/legacy/server/META-INF/java/SimpleParser.inc
index 24b314c..b1b9970 100644
--- a/legacy/server/META-INF/java/SimpleParser.inc
+++ b/legacy/server/META-INF/java/SimpleParser.inc
@@ -62,7 +62,7 @@ class java_ParserString {
*/
class java_ParserTag {
public $n, $strings;
- function java_ParserTag() {
+ function __construct() {
$this->strings = array();
$this->n = 0;
}
@@ -78,7 +78,7 @@ class java_SimpleParser {
public $tag, $buf, $len, $s;
public $type;
- function java_SimpleParser($handler) {
+ function __construct($handler) {
$this->handler = $handler;
$this->tag = array(new java_ParserTag(), new java_ParserTag(), new java_ParserTag());
$this->len = $this->SLEN;
diff --git a/legacy/server/META-INF/services/javax.script.ScriptEngineFactory b/legacy/server/META-INF/services/javax.script.ScriptEngineFactory
index 21d0319..5dd16c8 100644
--- a/legacy/server/META-INF/services/javax.script.ScriptEngineFactory
+++ b/legacy/server/META-INF/services/javax.script.ScriptEngineFactory
@@ -1,9 +1,9 @@
# list of script engine factories
#
-# php => php.java.script.PhpScriptEngineFactory
-# php-invocable => php.java.script.InvocablePhpScriptEngineFactory
-# php-interactive => php.java.script.InteractivePhpScriptEngineFactory
+# php => io.soluble.pjb.script.PhpScriptEngineFactory
+# php-invocable => io.soluble.pjb.script.InvocablePhpScriptEngineFactory
+# php-interactive => io.soluble.pjb.script.InteractivePhpScriptEngineFactory
-php.java.script.PhpScriptEngineFactory
-php.java.script.InvocablePhpScriptEngineFactory
-php.java.script.InteractivePhpScriptEngineFactory
+io.soluble.pjb.script.PhpScriptEngineFactory
+io.soluble.pjb.script.InvocablePhpScriptEngineFactory
+io.soluble.pjb.script.InteractivePhpScriptEngineFactory
diff --git a/src/main/java/io/soluble/pjb/bridge/JavaBridgeRunner.java b/src/main/java/io/soluble/pjb/bridge/JavaBridgeRunner.java
index dc20637..9c11be4 100644
--- a/src/main/java/io/soluble/pjb/bridge/JavaBridgeRunner.java
+++ b/src/main/java/io/soluble/pjb/bridge/JavaBridgeRunner.java
@@ -63,6 +63,8 @@ public class JavaBridgeRunner extends HttpServer {
protected static JavaBridgeRunner runner;
protected final ContextServer contextServer;
+ private boolean directoryIndexEnabled = true;
+
protected JavaBridgeRunner(String serverPort, boolean isSecure) throws IOException {
super(serverPort, isSecure);
@@ -165,6 +167,19 @@ public static synchronized JavaBridgeRunner getRequiredInstance() throws IOExcep
return runner;
}
+ /**
+ * Enable listing of directory index, if a directory is served.
+ */
+ public void enableDirectoryIndex() {
+ directoryIndexEnabled = true;
+ }
+
+ /**
+ * Disable listing of directory index, if a directory is served.
+ */
+ public void disableDirectoryIndex() {
+ directoryIndexEnabled = false;
+ }
/**
* Create a server socket.
@@ -248,7 +263,7 @@ protected void doPut(HttpRequest req, HttpResponse res) throws IOException {
* @throws IOException
*/
protected boolean showDirectory(String fullName, File f, int length, HttpRequest req, HttpResponse res) throws IOException {
- if (!f.isDirectory()) return false;
+ // assert f.isDirectory()
ByteArrayOutputStream xout = new ByteArrayOutputStream();
try (PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(xout, Util.UTF8)))) {
out.println("");
@@ -370,7 +385,7 @@ protected boolean handleScriptContent(String name, String params, File f, int le
}
/**
- * Display a simple text file
+ * Display a simple text file.
*
* @param name
* @param f The full name as a file
@@ -446,10 +461,21 @@ protected void handleDoGet(HttpRequest req, HttpResponse res) throws IOException
long l = f.length();
if (l >= Integer.MAX_VALUE) throw new IOException("file " + name + " too large");
int length = (int) l;
- if (showDirectory(name, f, length, req, res)) return;
- if (handleScriptContent(name, params, f, length, req, res)) return;
- showTextFile(name, params, f, length, req, res, (!name.endsWith(".html")) || "show".equals(params));
- return;
+ if (f.isDirectory()) {
+ if (directoryIndexEnabled) {
+ showDirectory(name, f, length, req, res);
+ } else {
+ // TODO: What now? 404? 403? setStatus is not implemented in the HttpResponse object
+ // of this internal http server
+ }
+ return;
+ } else { // assert !f.isDirectory()
+ // TODO: Here comes a BUG: handleScriptContent(...) does nothing but return true,
+ // hence showTextFile(...) is never called; will comment it out for now
+ // if (handleScriptContent(name, params, f, length, req, res)) return;
+ showTextFile(name, params, f, length, req, res, (!name.endsWith(".html")) || "show".equals(params));
+ return;
+ }
}
if (cache != null && name.endsWith("Java.inc")) {
res.setContentLength(cache.length);
@@ -466,7 +492,7 @@ protected void handleDoGet(HttpRequest req, HttpResponse res) throws IOException
out.write(buf);
return;
} catch (SecurityException e) {/*ignore*/
- } catch (Exception e) {
+ } catch (IOException | IllegalAccessException | IllegalArgumentException | NoSuchFieldException e) {
Util.printStackTrace(e);
}
}
diff --git a/src/main/java/io/soluble/pjb/bridge/JavaInc.java b/src/main/java/io/soluble/pjb/bridge/JavaInc.java
index e579cba..854941e 100644
--- a/src/main/java/io/soluble/pjb/bridge/JavaInc.java
+++ b/src/main/java/io/soluble/pjb/bridge/JavaInc.java
@@ -72,9 +72,9 @@ public class JavaInc {
"}\n"+
"function java_virtual($path,$return=false) {\n"+
"$req=java_context()->getHttpServletRequest();\n"+
-"$req=new java(\"io.soluble.pjb.servlet.VoidInputHttpServletRequest\",$req);\n"+
+"$req=new java(\"php.java.servlet.VoidInputHttpServletRequest\",$req);\n"+
"$res=java_context()->getHttpServletResponse();\n"+
-"$res=new java(\"io.soluble.pjb.servlet.RemoteHttpServletResponse\",$res);\n"+
+"$res=new java(\"php.java.servlet.RemoteHttpServletResponse\",$res);\n"+
"$req->getRequestDispatcher($path)->include($req,$res);\n"+
"if ($return) return $res->getBufferContents();\n"+
"echo $res->getBufferContents();\n"+
@@ -149,7 +149,7 @@ public class JavaInc {
"else define(\"JAVA_PREFER_VALUES\",0);\n"+
"class java_SimpleFactory {\n"+
"public $client;\n"+
-"function java_SimpleFactory($client) {\n"+
+"function __construct($client) {\n"+
"$this->client=$client;\n"+
"}\n"+
"function getProxy($result,$signature,$exception,$wrap) {\n"+
@@ -208,7 +208,7 @@ public class JavaInc {
"class java_CacheEntry {\n"+
"public $fmt,$signature,$factory,$java;\n"+
"public $resultVoid;\n"+
-"function java_CacheEntry($fmt,$signature,$factory,$resultVoid) {\n"+
+"function __construct($fmt,$signature,$factory,$resultVoid) {\n"+
"$this->fmt=$fmt;\n"+
"$this->signature=$signature;\n"+
"$this->factory=$factory;\n"+
@@ -220,7 +220,7 @@ public class JavaInc {
"public $exception;\n"+
"public $factory,$val;\n"+
"public $signature;\n"+
-"function java_Arg($client) {\n"+
+"function __construct($client) {\n"+
"$this->client=$client;\n"+
"$this->factory=$client->simpleFactory;\n"+
"}\n"+
@@ -266,8 +266,8 @@ public class JavaInc {
"public $idx;\n"+
"public $type;\n"+
"public $counter;\n"+
-"function java_CompositeArg($client,$type) {\n"+
-"parent::java_Arg($client);\n"+
+"function __construct($client,$type) {\n"+
+"parent::__construct($client);\n"+
"$this->type=$type;\n"+
"$this->val=array();\n"+
"$this->counter=0;\n"+
@@ -288,8 +288,8 @@ public class JavaInc {
"}\n"+
"class java_ApplyArg extends java_CompositeArg {\n"+
"public $m,$p,$v,$n;\n"+
-"function java_ApplyArg($client,$type,$m,$p,$v,$n) {\n"+
-"parent::java_CompositeArg($client,$type);\n"+
+"function __construct($client,$type,$m,$p,$v,$n) {\n"+
+"parent::__construct($client,$type);\n"+
"$this->m=$m;\n"+
"$this->p=$p;\n"+
"$this->v=$v;\n"+
@@ -305,7 +305,7 @@ public class JavaInc {
"$proxyFactory,$iteratorProxyFacroty,\n"+
"$arrayProxyFactory,$exceptionProxyFactory,$throwExceptionProxyFactory;\n"+
"public $arg;\n"+
-"public $asyncCtx,$cancelProxyCreationCounter;\n"+
+"public $asyncCtx,$cancelProxyCreationTag;\n"+
"public $globalRef;\n"+
"public $stack;\n"+
"public $defaultCache=array(),$asyncCache=array(),$methodCache;\n"+
@@ -314,7 +314,7 @@ public class JavaInc {
"public $cachedJavaPrototype;\n"+
"public $sendBuffer,$preparedToSendBuffer;\n"+
"public $inArgs;\n"+
-"function java_Client() {\n"+
+"function __construct() {\n"+
"$this->RUNTIME=array();\n"+
"$this->RUNTIME[\"NOTICE\"]='***USE echo java_inspect(jVal) OR print_r(java_values(jVal)) TO SEE THE CONTENTS OF THIS JAVA OBJECT!***';\n"+
"$this->parser=new java_Parser($this);\n"+
@@ -328,7 +328,7 @@ public class JavaInc {
"$this->cachedJavaPrototype=new java_JavaProxyProxy($this);\n"+
"$this->simpleArg=new java_Arg($this);\n"+
"$this->globalRef=new java_GlobalRef();\n"+
-"$this->asyncCtx=$this->cancelProxyCreationCounter=0;\n"+
+"$this->asyncCtx=$this->cancelProxyCreationTag=0;\n"+
"$this->methodCache=$this->defaultCache;\n"+
"$this->inArgs=false;\n"+
"}\n"+
@@ -649,7 +649,7 @@ public class JavaInc {
"register_shutdown_function(\"java_shutdown\");\n"+
"class java_GlobalRef {\n"+
"public $map;\n"+
-"function java_GlobalRef() {\n"+
+"function __construct() {\n"+
"$this->map=array();\n"+
"}\n"+
"function add($object) {\n"+
@@ -665,7 +665,7 @@ public class JavaInc {
"public $parser,$handler;\n"+
"public $level,$event;\n"+
"public $buf;\n"+
-"function java_NativeParser($handler) {\n"+
+"function __construct($handler) {\n"+
"$this->handler=$handler;\n"+
"$this->parser=xml_parser_create();\n"+
"xml_parser_set_option($this->parser,XML_OPTION_CASE_FOLDING,0);\n"+
@@ -711,7 +711,7 @@ public class JavaInc {
"}\n"+
"class java_Parser {\n"+
"public $parser;\n"+
-"function java_Parser($handler) {\n"+
+"function __construct($handler) {\n"+
"if(function_exists(\"xml_parser_create\")) {\n"+
"$this->parser=new java_NativeParser($handler);\n"+
"$handler->RUNTIME[\"PARSER\"]=\"NATIVE\";\n"+
@@ -755,7 +755,7 @@ public class JavaInc {
"class java_EmptyChannel {\n"+
"protected $handler;\n"+
"private $res;\n"+
-"function java_EmptyChannel($handler) {\n"+
+"function __construct($handler) {\n"+
"$this->handler=$handler;\n"+
"}\n"+
"function shutdownBrokenConnection () {}\n"+
@@ -808,7 +808,7 @@ public class JavaInc {
"}\n"+
"abstract class java_SocketChannel extends java_EmptyChannel {\n"+
"public $peer,$host;\n"+
-"function java_SocketChannel($peer,$host) {\n"+
+"function __construct($peer,$host) {\n"+
"$this->peer=$peer;\n"+
"$this->host=$host;\n"+
"}\n"+
@@ -847,7 +847,7 @@ public class JavaInc {
"}\n"+
"class java_SocketHandler {\n"+
"public $protocol,$channel;\n"+
-"function java_SocketHandler($protocol,$channel) {\n"+
+"function __construct($protocol,$channel) {\n"+
"$this->protocol=$protocol;\n"+
"$this->channel=$channel;\n"+
"}\n"+
@@ -898,7 +898,7 @@ public class JavaInc {
"$this->protocol->handler->read(1)\n"+
"or $this->protocol->handler->shutdownBrokenConnection(\"Broken local connection handle\");\n"+
"}\n"+
-"function java_SimpleHttpHandler($protocol,$ssl,$host,$port) {\n"+
+"function __construct($protocol,$ssl,$host,$port) {\n"+
"$this->cookies=array();\n"+
"$this->protocol=$protocol;\n"+
"$this->ssl=$ssl;\n"+
@@ -1020,8 +1020,8 @@ public class JavaInc {
"fgets($this->socket,3);\n"+
"fclose($this->socket);\n"+
"}\n"+
-"function java_SimpleHttpTunnelHandler($protocol,$ssl,$host,$port) {\n"+
-"parent::java_SimpleHttpHandler($protocol,$ssl,$host,$port);\n"+
+"function __construct($protocol,$ssl,$host,$port) {\n"+
+"parent::__construct($protocol,$ssl,$host,$port);\n"+
"$this->open();\n"+
"}\n"+
"function read($size) {\n"+
@@ -1227,7 +1227,7 @@ public class JavaInc {
"$java=file_exists(ini_get(\"extension_dir\").\"/JavaBridge.jar\")?ini_get(\"extension_dir\").\"/JavaBridge.jar\":(java_get_base().\"/JavaBridge.jar\");\n"+
"if (!file_exists($java))\n"+
"throw new java_IOException(\"Could not find $java in \".getcwd().\". Download it from http://sf.net/projects/php-java-bridge/files/Binary%20package/php-java-bridge_\".JAVA_PEAR_VERSION.\"/exploded/JavaBridge.jar/download and try again.\");\n"+
-"$java_cmd=\"java -Dio.soluble.pjb.bridge.daemon=true -jar \\\"${java}\\\" INET_LOCAL:$channelName 0\";\n"+
+"$java_cmd=\"java -Dphp.java.bridge.daemon=true -jar \\\"${java}\\\" INET_LOCAL:$channelName 0\";\n"+
"if (!$again)\n"+
"throw new java_ConnectException(\"No Java back end! Please run it with: $java_cmd. Error message: $errstr ($errno)\");\n"+
"if (!java_checkCliSapi())\n"+
@@ -1254,7 +1254,7 @@ public class JavaInc {
"return $this->createHttpHandler();\n"+
"}\n"+
"}\n"+
-"function java_Protocol ($client) {\n"+
+"function __construct ($client) {\n"+
"$this->client=$client;\n"+
"$this->handler=$this->createHandler();\n"+
"}\n"+
@@ -1352,7 +1352,7 @@ public class JavaInc {
"}\n"+
"function writeString($name) {\n"+
"$this->client->currentArgumentsFormat.=$format=\" \",htmlspecialchars($key,ENT_COMPAT)));\n"+
+"$this->write(sprintf(\" \",htmlspecialchars($key,ENT_COMPAT,\"ISO-8859-1\")));\n"+
"}\n"+
"function writePairBegin_n($key) {\n"+
"$this->write(sprintf(\" \",$key));\n"+
@@ -1422,7 +1422,7 @@ public class JavaInc {
"}\n"+
"class java_ParserTag {\n"+
"public $n,$strings;\n"+
-"function java_ParserTag() {\n"+
+"function __construct() {\n"+
"$this->strings=array();\n"+
"$this->n=0;\n"+
"}\n"+
@@ -1432,7 +1432,7 @@ public class JavaInc {
"public $handler;\n"+
"public $tag,$buf,$len,$s;\n"+
"public $type;\n"+
-"function java_SimpleParser($handler) {\n"+
+"function __construct($handler) {\n"+
"$this->handler=$handler;\n"+
"$this->tag=array(new java_ParserTag(),new java_ParserTag(),new java_ParserTag());\n"+
"$this->len=$this->SLEN;\n"+
@@ -1609,6 +1609,10 @@ public class JavaInc {
"function java_values($object) {\n"+
"return java_values_internal($object);\n"+
"}\n"+
+"function java_reset() {\n"+
+"$client=__javaproxy_Client_getClient();\n"+
+"return $client->invokeMethod(0,\"reset\",array());\n"+
+"}\n"+
"function java_inspect_internal($object) {\n"+
"if(!$object instanceof java_JavaType) throw new java_IllegalArgumentException($object);\n"+
"$client=__javaproxy_Client_getClient();\n"+
@@ -1656,6 +1660,9 @@ public class JavaInc {
"}\n"+
"function java_require($arg) {\n"+
"trigger_error('java_require() not supported anymore. Please use tomcat or jee hot deployment instead',E_USER_WARNING);\n"+
+"$client=__javaproxy_Client_getClient();\n"+
+"return $client->invokeMethod(0,\"updateJarLibraryPath\",\n"+
+"array($arg,ini_get(\"extension_dir\")));\n"+
"}\n"+
"function java_get_lifetime ()\n"+
"{\n"+
@@ -1718,7 +1725,7 @@ public class JavaInc {
"public $__signature;\n"+
"public $__client;\n"+
"public $__tempGlobalRef;\n"+
-"function java_JavaProxy($java,$signature){\n"+
+"function __construct($java,$signature){\n"+
"$this->__java=$java;\n"+
"$this->__signature=$signature;\n"+
"$this->__client=__javaproxy_Client_getClient();\n"+
@@ -1764,7 +1771,7 @@ public class JavaInc {
"}\n"+
"class java_objectIterator implements Iterator {\n"+
"private $var;\n"+
-"function java_ObjectIterator($javaProxy) {\n"+
+"function __construct($javaProxy) {\n"+
"$this->var=java_cast ($javaProxy,\"A\");\n"+
"}\n"+
"function rewind() {\n"+
@@ -1883,7 +1890,7 @@ public class JavaInc {
"}\n"+
"}\n"+
"class Java extends java_AbstractJava {\n"+
-"function Java() {\n"+
+"function __construct() {\n"+
"$client=$this->__client=__javaproxy_Client_getClient();\n"+
"$args=func_get_args();\n"+
"$name=array_shift($args);\n"+
@@ -1896,7 +1903,7 @@ public class JavaInc {
"case 'boolean': array_push($args2,$val); $sig.='@b'; break;\n"+
"case 'integer': array_push($args2,$val); $sig.='@i'; break;\n"+
"case 'double': array_push($args2,$val); $sig.='@d'; break;\n"+
-"case 'string': array_push($args2,htmlspecialchars($val,ENT_COMPAT)); $sig.='@s'; break;\n"+
+"case 'string': array_push($args2,htmlspecialchars($val,ENT_COMPAT,\"ISO-8859-1\")); $sig.='@s'; break;\n"+
"case 'array':$sig=\"~INVALID\"; break;\n"+
"case 'object':\n"+
"if($val instanceof java_JavaType) {\n"+
@@ -1959,7 +1966,7 @@ public class JavaInc {
"case 'boolean': array_push($args2,$val); $sig.='@b'; break;\n"+
"case 'integer': array_push($args2,$val); $sig.='@i'; break;\n"+
"case 'double': array_push($args2,$val); $sig.='@d'; break;\n"+
-"case 'string': array_push($args2,htmlspecialchars($val,ENT_COMPAT)); $sig.='@s'; break;\n"+
+"case 'string': array_push($args2,htmlspecialchars($val,ENT_COMPAT,\"ISO-8859-1\")); $sig.='@s'; break;\n"+
"case 'array':$sig=\"~INVALID\"; break;\n"+
"case 'object':\n"+
"if($val instanceof java_JavaType) {\n"+
@@ -2004,7 +2011,7 @@ public class JavaInc {
"}\n"+
"}\n"+
"class java_InternalJava extends Java {\n"+
-"function java_InternalJava($proxy) {\n"+
+"function __construct($proxy) {\n"+
"$this->__delegate=$proxy;\n"+
"$this->__java=$proxy->__java;\n"+
"$this->__signature=$proxy->__signature;\n"+
@@ -2012,7 +2019,7 @@ public class JavaInc {
"}\n"+
"}\n"+
"class java_class extends Java {\n"+
-"function java_class() {\n"+
+"function __construct() {\n"+
"$this->__client=__javaproxy_Client_getClient();\n"+
"$args=func_get_args();\n"+
"$name=array_shift($args);\n"+
@@ -2028,7 +2035,7 @@ public class JavaInc {
"public $__delegate;\n"+
"public $__signature;\n"+
"public $__hasDeclaredExceptions;\n"+
-"function java_exception() {\n"+
+"function __construct() {\n"+
"$this->__client=__javaproxy_Client_getClient();\n"+
"$args=func_get_args();\n"+
"$name=array_shift($args);\n"+
@@ -2069,7 +2076,7 @@ public class JavaInc {
"}\n"+
"class JavaException extends java_exception {}\n"+
"class java_InternalException extends JavaException {\n"+
-"function java_InternalException($proxy,$exception) {\n"+
+"function __construct($proxy,$exception) {\n"+
"$this->__delegate=$proxy;\n"+
"$this->__java=$proxy->__java;\n"+
"$this->__signature=$proxy->__signature;\n"+
@@ -2078,7 +2085,7 @@ public class JavaInc {
"}\n"+
"}\n"+
"class java_JavaProxyProxy extends Java {\n"+
-"function java_JavaProxyProxy($client) {\n"+
+"function __construct($client) {\n"+
"$this->__client=$client;\n"+
"}\n"+
"}\n"+
diff --git a/src/main/java/io/soluble/pjb/bridge/Util.java b/src/main/java/io/soluble/pjb/bridge/Util.java
index 620dd41..e7ee159 100644
--- a/src/main/java/io/soluble/pjb/bridge/Util.java
+++ b/src/main/java/io/soluble/pjb/bridge/Util.java
@@ -176,15 +176,17 @@ private Util() {}
* Useful if you have non-pure java libraries (=libraries which
* use the Java Native Interface to load native dll's or shared
* libraries).
+ * LEGACY-CODE: no usages
*/
+ @Deprecated
public static final String DEFAULT_EXT_DIRS[] = {"/usr/share/java/ext", "/usr/java/packages/lib/ext"};
- //TODO: platform neutrality
/**
* Set to true if the VM is gcj, false otherwise
+ * LEGACY-CODE: no usages
*/
- public static final boolean IS_GNU_JAVA = checkVM();
- //TODO: drop GNU Java support
+ @Deprecated
+ public static final boolean IS_GNU_JAVA = false; //- checkVM();
/**
* The name of the extension, usually "JavaBridge" or "MonoBridge"
diff --git a/src/main/java/io/soluble/pjb/bridge/http/ChunkedInputStream.java b/src/main/java/io/soluble/pjb/bridge/http/ChunkedInputStream.java
index 14d115f..34314ef 100644
--- a/src/main/java/io/soluble/pjb/bridge/http/ChunkedInputStream.java
+++ b/src/main/java/io/soluble/pjb/bridge/http/ChunkedInputStream.java
@@ -50,15 +50,12 @@ private static int[] getAscii() {
for (int i = 48; i < 58; i++) {
ascii[i] = i - 48;
}
- ;
for (int i = 65; i < 71; i++) {
ascii[i] = i - 55;
}
- ;
for (int i = 97; i < 103; i++) {
ascii[i] = i - 87;
}
- ;
return ascii;
}
@@ -78,6 +75,7 @@ public ChunkedInputStream(InputStream in) {
/**
* {@inheritDoc}
*/
+ @Override
public int read(byte[] buf, int pos, int len) throws IOException {
int c, i;
int count;
@@ -106,15 +104,14 @@ public int read(byte[] buf, int pos, int len) throws IOException {
remaining = new byte[packetLen];
remainLen = 0;
- for (c = 0; (i = in.read(remaining, c, packetLen - c)) > 0; c += i)
- ;
+ for (c = 0; (i = in.read(remaining, c, packetLen - c)) > 0; c += i) {
+ }
if ((c != packetLen)) throw new IOException("read chunked");
- for (c = 0; (i = in.read(rn, c, 2 - c)) > 0; c += i)
- ;
+ for (c = 0; (i = in.read(rn, c, 2 - c)) > 0; c += i) {
+ }
if ((c != 2)) throw new IOException("read \r\n");
-
// store remaining
if (len >= packetLen) {
count = packetLen;
diff --git a/src/main/java/io/soluble/pjb/bridge/http/HttpResponse.java b/src/main/java/io/soluble/pjb/bridge/http/HttpResponse.java
index 67afdb5..8385028 100644
--- a/src/main/java/io/soluble/pjb/bridge/http/HttpResponse.java
+++ b/src/main/java/io/soluble/pjb/bridge/http/HttpResponse.java
@@ -41,7 +41,7 @@
*/
public class HttpResponse {
- private HashMap headers;
+ private final HashMap headers;
private OutputStream outputStream;
private boolean headersWritten;
@@ -56,6 +56,7 @@ public HttpResponse(OutputStream outputStream) {
this.headers = new HashMap();
this.outputStream = new BufferedOutputStream(outputStream) {
+ @Override
public void write(byte buf[], int pos, int len) throws IOException {
if (!headersWritten) {
headersWritten = true;
diff --git a/src/main/java/io/soluble/pjb/bridge/http/WriterOutputStream.java b/src/main/java/io/soluble/pjb/bridge/http/WriterOutputStream.java
index 9fd3dd8..db08183 100644
--- a/src/main/java/io/soluble/pjb/bridge/http/WriterOutputStream.java
+++ b/src/main/java/io/soluble/pjb/bridge/http/WriterOutputStream.java
@@ -31,39 +31,30 @@
/**
* A PrintWriter backed by an OutputStream.
- *
* @author jostb
+ *
*/
public class WriterOutputStream extends DefaultCharsetWriterOutputStream {
protected String charsetName = Util.DEFAULT_ENCODING;
- private boolean written = false;
/**
* The encoding used for char[] -> byte[] conversion
- *
* @param charsetName
*/
public void setEncoding(String charsetName) {
- if (written) throw new IllegalStateException("setEncoding");
this.charsetName = charsetName;
}
-
/**
* Create a new PhpScriptWriter.
- *
* @param out The OutputStream
*/
public WriterOutputStream(Writer out) {
super(out);
}
-
- /**
- * {@inheritDoc}
- */
+ /**{@inheritDoc}*/
public void write(byte b[], int off, int len) throws IOException {
- written = true;
- String s = new String(b, off, len, charsetName);
+ String s = new String (b, off, len, charsetName);
out.write(s);
}
-}
+}
\ No newline at end of file
diff --git a/src/main/resources/META-INF/java/Java.inc b/src/main/resources/META-INF/java/Java.inc
index 47dbe7c..5cc52af 100644
--- a/src/main/resources/META-INF/java/Java.inc
+++ b/src/main/resources/META-INF/java/Java.inc
@@ -70,9 +70,9 @@ trigger_error('Please use getHttpServletResponse();
-$res=new java("io.soluble.pjb.servlet.RemoteHttpServletResponse",$res);
+$res=new java("php.java.servlet.RemoteHttpServletResponse",$res);
$req->getRequestDispatcher($path)->include($req,$res);
if ($return) return $res->getBufferContents();
echo $res->getBufferContents();
@@ -147,7 +147,7 @@ if ($java_ini=get_cfg_var("java.prefer_values")) define("JAVA_PREFER_VALUES",$ja
else define("JAVA_PREFER_VALUES",0);
class java_SimpleFactory {
public $client;
-function java_SimpleFactory($client) {
+function __construct($client) {
$this->client=$client;
}
function getProxy($result,$signature,$exception,$wrap) {
@@ -206,7 +206,7 @@ trigger_error("Unchecked exception detected: ".java_truncate($result->__toString
class java_CacheEntry {
public $fmt,$signature,$factory,$java;
public $resultVoid;
-function java_CacheEntry($fmt,$signature,$factory,$resultVoid) {
+function __construct($fmt,$signature,$factory,$resultVoid) {
$this->fmt=$fmt;
$this->signature=$signature;
$this->factory=$factory;
@@ -218,7 +218,7 @@ public $client;
public $exception;
public $factory,$val;
public $signature;
-function java_Arg($client) {
+function __construct($client) {
$this->client=$client;
$this->factory=$client->simpleFactory;
}
@@ -264,8 +264,8 @@ public $parentArg;
public $idx;
public $type;
public $counter;
-function java_CompositeArg($client,$type) {
-parent::java_Arg($client);
+function __construct($client,$type) {
+parent::__construct($client);
$this->type=$type;
$this->val=array();
$this->counter=0;
@@ -286,8 +286,8 @@ $this->factory=$this->client->simpleFactory;
}
class java_ApplyArg extends java_CompositeArg {
public $m,$p,$v,$n;
-function java_ApplyArg($client,$type,$m,$p,$v,$n) {
-parent::java_CompositeArg($client,$type);
+function __construct($client,$type,$m,$p,$v,$n) {
+parent::__construct($client,$type);
$this->m=$m;
$this->p=$p;
$this->v=$v;
@@ -303,7 +303,7 @@ public $simpleFactory,
$proxyFactory,$iteratorProxyFacroty,
$arrayProxyFactory,$exceptionProxyFactory,$throwExceptionProxyFactory;
public $arg;
-public $asyncCtx,$cancelProxyCreationCounter;
+public $asyncCtx,$cancelProxyCreationTag;
public $globalRef;
public $stack;
public $defaultCache=array(),$asyncCache=array(),$methodCache;
@@ -312,7 +312,7 @@ public $currentCacheKey,$currentArgumentsFormat;
public $cachedJavaPrototype;
public $sendBuffer,$preparedToSendBuffer;
public $inArgs;
-function java_Client() {
+function __construct() {
$this->RUNTIME=array();
$this->RUNTIME["NOTICE"]='***USE echo java_inspect(jVal) OR print_r(java_values(jVal)) TO SEE THE CONTENTS OF THIS JAVA OBJECT!***';
$this->parser=new java_Parser($this);
@@ -326,7 +326,7 @@ $this->throwExceptionProxyFactory=new java_ThrowExceptionProxyFactory($this);
$this->cachedJavaPrototype=new java_JavaProxyProxy($this);
$this->simpleArg=new java_Arg($this);
$this->globalRef=new java_GlobalRef();
-$this->asyncCtx=$this->cancelProxyCreationCounter=0;
+$this->asyncCtx=$this->cancelProxyCreationTag=0;
$this->methodCache=$this->defaultCache;
$this->inArgs=false;
}
@@ -647,7 +647,7 @@ $client->protocol->keepAlive();
register_shutdown_function("java_shutdown");
class java_GlobalRef {
public $map;
-function java_GlobalRef() {
+function __construct() {
$this->map=array();
}
function add($object) {
@@ -663,7 +663,7 @@ class java_NativeParser {
public $parser,$handler;
public $level,$event;
public $buf;
-function java_NativeParser($handler) {
+function __construct($handler) {
$this->handler=$handler;
$this->parser=xml_parser_create();
xml_parser_set_option($this->parser,XML_OPTION_CASE_FOLDING,0);
@@ -709,7 +709,7 @@ sprintf("protocol error: %s. Check the back end log for details.",$this->buf));
}
class java_Parser {
public $parser;
-function java_Parser($handler) {
+function __construct($handler) {
if(function_exists("xml_parser_create")) {
$this->parser=new java_NativeParser($handler);
$handler->RUNTIME["PARSER"]="NATIVE";
@@ -753,7 +753,7 @@ return $compatibility;
class java_EmptyChannel {
protected $handler;
private $res;
-function java_EmptyChannel($handler) {
+function __construct($handler) {
$this->handler=$handler;
}
function shutdownBrokenConnection () {}
@@ -806,7 +806,7 @@ $this->checkE();
}
abstract class java_SocketChannel extends java_EmptyChannel {
public $peer,$host;
-function java_SocketChannel($peer,$host) {
+function __construct($peer,$host) {
$this->peer=$peer;
$this->host=$host;
}
@@ -845,7 +845,7 @@ function keepAlive() { $this->keepAliveSC(); $this->checkE(); fclose ($this->pee
}
class java_SocketHandler {
public $protocol,$channel;
-function java_SocketHandler($protocol,$channel) {
+function __construct($protocol,$channel) {
$this->protocol=$protocol;
$this->channel=$channel;
}
@@ -896,7 +896,7 @@ $this->protocol->client->sendBuffer=null;
$this->protocol->handler->read(1)
or $this->protocol->handler->shutdownBrokenConnection("Broken local connection handle");
}
-function java_SimpleHttpHandler($protocol,$ssl,$host,$port) {
+function __construct($protocol,$ssl,$host,$port) {
$this->cookies=array();
$this->protocol=$protocol;
$this->ssl=$ssl;
@@ -1018,8 +1018,8 @@ fgets($this->socket,JAVA_RECV_SIZE);
fgets($this->socket,3);
fclose($this->socket);
}
-function java_SimpleHttpTunnelHandler($protocol,$ssl,$host,$port) {
-parent::java_SimpleHttpHandler($protocol,$ssl,$host,$port);
+function __construct($protocol,$ssl,$host,$port) {
+parent::__construct($protocol,$ssl,$host,$port);
$this->open();
}
function read($size) {
@@ -1225,7 +1225,7 @@ if (!$peer) {
$java=file_exists(ini_get("extension_dir")."/JavaBridge.jar")?ini_get("extension_dir")."/JavaBridge.jar":(java_get_base()."/JavaBridge.jar");
if (!file_exists($java))
throw new java_IOException("Could not find $java in ".getcwd().". Download it from http://sf.net/projects/php-java-bridge/files/Binary%20package/php-java-bridge_".JAVA_PEAR_VERSION."/exploded/JavaBridge.jar/download and try again.");
-$java_cmd="java -Dio.soluble.pjb.bridge.daemon=true -jar \"${java}\" INET_LOCAL:$channelName 0";
+$java_cmd="java -Dphp.java.bridge.daemon=true -jar \"${java}\" INET_LOCAL:$channelName 0";
if (!$again)
throw new java_ConnectException("No Java back end! Please run it with: $java_cmd. Error message: $errstr ($errno)");
if (!java_checkCliSapi())
@@ -1252,7 +1252,7 @@ return $this->createSimpleHandler($defaultChannel);
return $this->createHttpHandler();
}
}
-function java_Protocol ($client) {
+function __construct ($client) {
$this->client=$client;
$this->handler=$this->createHandler();
}
@@ -1350,7 +1350,7 @@ $this->flush();
}
function writeString($name) {
$this->client->currentArgumentsFormat.=$format=" ",htmlspecialchars($key,ENT_COMPAT)));
+$this->write(sprintf(" ",htmlspecialchars($key,ENT_COMPAT,"ISO-8859-1")));
}
function writePairBegin_n($key) {
$this->write(sprintf(" ",$key));
@@ -1420,7 +1420,7 @@ return substr($this->string,$this->off,$this->length);
}
class java_ParserTag {
public $n,$strings;
-function java_ParserTag() {
+function __construct() {
$this->strings=array();
$this->n=0;
}
@@ -1430,7 +1430,7 @@ public $SLEN=256;
public $handler;
public $tag,$buf,$len,$s;
public $type;
-function java_SimpleParser($handler) {
+function __construct($handler) {
$this->handler=$handler;
$this->tag=array(new java_ParserTag(),new java_ParserTag(),new java_ParserTag());
$this->len=$this->SLEN;
@@ -1607,6 +1607,10 @@ return $client->globalRef->get($client->invokeMethod(0,"unwrapClosure",array($ob
function java_values($object) {
return java_values_internal($object);
}
+function java_reset() {
+$client=__javaproxy_Client_getClient();
+return $client->invokeMethod(0,"reset",array());
+}
function java_inspect_internal($object) {
if(!$object instanceof java_JavaType) throw new java_IllegalArgumentException($object);
$client=__javaproxy_Client_getClient();
@@ -1654,6 +1658,9 @@ return java_cast_internal($object,$type);
}
function java_require($arg) {
trigger_error('java_require() not supported anymore. Please use __java=$java;
$this->__signature=$signature;
$this->__client=__javaproxy_Client_getClient();
@@ -1762,7 +1769,7 @@ return "";
}
class java_objectIterator implements Iterator {
private $var;
-function java_ObjectIterator($javaProxy) {
+function __construct($javaProxy) {
$this->var=java_cast ($javaProxy,"A");
}
function rewind() {
@@ -1881,7 +1888,7 @@ $args=func_get_args(); return $this->__call("offsetUnset",$args);
}
}
class Java extends java_AbstractJava {
-function Java() {
+function __construct() {
$client=$this->__client=__javaproxy_Client_getClient();
$args=func_get_args();
$name=array_shift($args);
@@ -1894,7 +1901,7 @@ switch(gettype($val=$args[$i])) {
case 'boolean': array_push($args2,$val); $sig.='@b'; break;
case 'integer': array_push($args2,$val); $sig.='@i'; break;
case 'double': array_push($args2,$val); $sig.='@d'; break;
-case 'string': array_push($args2,htmlspecialchars($val,ENT_COMPAT)); $sig.='@s'; break;
+case 'string': array_push($args2,htmlspecialchars($val,ENT_COMPAT,"ISO-8859-1")); $sig.='@s'; break;
case 'array':$sig="~INVALID"; break;
case 'object':
if($val instanceof java_JavaType) {
@@ -1957,7 +1964,7 @@ switch(gettype($val=$args[$i])) {
case 'boolean': array_push($args2,$val); $sig.='@b'; break;
case 'integer': array_push($args2,$val); $sig.='@i'; break;
case 'double': array_push($args2,$val); $sig.='@d'; break;
-case 'string': array_push($args2,htmlspecialchars($val,ENT_COMPAT)); $sig.='@s'; break;
+case 'string': array_push($args2,htmlspecialchars($val,ENT_COMPAT,"ISO-8859-1")); $sig.='@s'; break;
case 'array':$sig="~INVALID"; break;
case 'object':
if($val instanceof java_JavaType) {
@@ -2002,7 +2009,7 @@ return $retval;
}
}
class java_InternalJava extends Java {
-function java_InternalJava($proxy) {
+function __construct($proxy) {
$this->__delegate=$proxy;
$this->__java=$proxy->__java;
$this->__signature=$proxy->__signature;
@@ -2010,7 +2017,7 @@ $this->__client=$proxy->__client;
}
}
class java_class extends Java {
-function java_class() {
+function __construct() {
$this->__client=__javaproxy_Client_getClient();
$args=func_get_args();
$name=array_shift($args);
@@ -2026,7 +2033,7 @@ public $__serialID,$__java,$__client;
public $__delegate;
public $__signature;
public $__hasDeclaredExceptions;
-function java_exception() {
+function __construct() {
$this->__client=__javaproxy_Client_getClient();
$args=func_get_args();
$name=array_shift($args);
@@ -2067,7 +2074,7 @@ return $this->__delegate->__toExceptionString($this->getTraceAsString());
}
class JavaException extends java_exception {}
class java_InternalException extends JavaException {
-function java_InternalException($proxy,$exception) {
+function __construct($proxy,$exception) {
$this->__delegate=$proxy;
$this->__java=$proxy->__java;
$this->__signature=$proxy->__signature;
@@ -2076,7 +2083,7 @@ $this->__hasDeclaredExceptions=$exception;
}
}
class java_JavaProxyProxy extends Java {
-function java_JavaProxyProxy($client) {
+function __construct($client) {
$this->__client=$client;
}
}
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index c4fdc97..e03265f 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -18,6 +18,16 @@
\";\n"+
-"$this->write(sprintf($format,htmlspecialchars($name,ENT_COMPAT)));\n"+
+"$this->write(sprintf($format,htmlspecialchars($name,ENT_COMPAT,\"ISO-8859-1\")));\n"+
"}\n"+
"function writeBoolean($boolean) {\n"+
"$this->client->currentArgumentsFormat.=$format=\"";
-$this->write(sprintf($format,htmlspecialchars($name,ENT_COMPAT)));
+$this->write(sprintf($format,htmlspecialchars($name,ENT_COMPAT,"ISO-8859-1")));
}
function writeBoolean($boolean) {
$this->client->currentArgumentsFormat.=$format="