} return false; } /** * TODO - remove constants and use * plain php config */ define("JAVA_PEAR_VERSION", "6.2.1"); if (!defined("JAVA_SEND_SIZE")) { define("JAVA_SEND_SIZE", 8192); } if (!defined("JAVA_RECV_SIZE")) { define("JAVA_RECV_SIZE", 8192); } if (!defined("JAVA_HOSTS")) { if (!java_defineHostFromInitialQuery(java_get_base())) { if ($java_ini = get_cfg_var("java.hosts")) { define("JAVA_HOSTS", $java_ini); } else { define("JAVA_HOSTS", "127.0.0.1:8080"); } } } if (!defined("JAVA_SERVLET")) { if (!(($java_ini = get_cfg_var("java.servlet")) === false)) { define("JAVA_SERVLET", $java_ini); } else { define("JAVA_SERVLET", 1); } } if (!defined("JAVA_LOG_LEVEL")) {
/** * * @param string $name * @param boolean $again * @return \Soluble\Japha\Bridge\Driver\Pjb621\SocketHandler * @throws Exception\ConnectException * @throws Exception\IOException */ public function createSimpleHandler($name, $again = true) { $channelName = $name; $errno = null; $errstr = null; if (is_numeric($channelName)) { $peer = @pfsockopen($host = "127.0.0.1", $channelName, $errno, $errstr, 5); } else { $type = $channelName[0]; list($host, $channelName) = explode(":", $channelName); $peer = pfsockopen($host, $channelName, $errno, $errstr, 20); if (!$peer) { throw new Exception\ConnectException("No Java server at {$host}:{$channelName}. Error message: {$errstr} ({$errno})"); } } 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 Exception\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 -Dphp.java.bridge.daemon=true -jar \"{$java}\" INET_LOCAL:{$channelName} 0"; if (!$again) { throw new Exception\ConnectException("No Java back end! Please run it with: {$java_cmd}. Error message: {$errstr} ({$errno})"); } if (!java_checkCliSapi()) { trigger_error("This PHP SAPI requires a JEE or SERVLET back end. Start it,define ('JAVA_SERVLET',true); define('JAVA_HOSTS',...); and try again.", E_USER_ERROR); } system($java_cmd); return $this->createSimpleHandler($name, false); } stream_set_timeout($peer, -1); $handler = new SocketHandler($this, new SocketChannelP($peer, $host)); $compatibility = java_getCompatibilityOption($this->client); $this->write("{$compatibility}"); $this->serverName = "127.0.0.1:{$channelName}"; return $handler; }
function java_get_default_channel() { return 9676; } function java_get_base() { $ar = get_required_files(); $arLen = sizeof($ar); if ($arLen > 0) { $thiz = $ar[$arLen - 1]; return dirname($thiz); } else { return "java/"; } } $JAVA_BASE = java_get_base(); class java_RuntimeException extends Exception { } class java_IllegalStateException extends java_RuntimeException { } class java_IllegalArgumentException extends java_RuntimeException { function __construct($ob) { parent::__construct("illegal argument: " . gettype($ob)); } } function java_autoload_function($x) {