protected function cargar_jasper()
 {
     if (!defined("JAVA_HOSTS")) {
         define("JAVA_HOSTS", "127.0.0.1:8081");
     }
     //Incluimos la libreria JavaBridge
     require_once "3ros/JavaBridge/java/Java.inc";
     //Creamos una variable que va a contener todas las librerías java presentes
     $path_libs = toba_dir() . '/php/3ros/JasperReports';
     $classpath = '';
     try {
         $archivos = toba_manejador_archivos::get_archivos_directorio($path_libs, '|.*\\.jar$|', true);
         foreach ($archivos as $archivo) {
             $classpath .= "file:{$archivo};";
         }
     } catch (toba_error $et) {
         toba::logger()->error($et->getMessage());
         //No se encontro el directorio, asi que no agrega nada al path y sigue el comportamiento que tenia con opendir
     }
     try {
         //Añadimos las librerías
         java_require($classpath);
         //Creamos el objeto JasperReport que permite obtener el reporte
         $this->jasper = new JavaClass("net.sf.jasperreports.engine.JasperFillManager");
     } catch (JavaException $ex) {
         $trace = new Java("java.io.ByteArrayOutputStream");
         $ex->printStackTrace(new Java("java.io.PrintStream", $trace));
         print "java stack trace: {$trace}\n";
     } catch (java_ConnectException $e) {
         toba::logger()->error($e->getMessage());
         throw new toba_error_usuario('No es posible generar el reporte, el servlet Jasper no se encuentra corriendo');
     }
 }
Beispiel #2
0
 public function go()
 {
     $fopcfg = dirname(__FILE__) . '/fop_config.xml';
     $tmppdf = tempnam('/tmp', 'FOP');
     if (!extension_loaded('java')) {
         $tmpxml = tempnam('/tmp', 'FOP');
         $tmpxsl = tempnam('/tmp', 'FOP');
         file_put_contents($tmpxml, $this->xml);
         file_put_contents($tmpxsl, $this->xsl);
         exec("fop -xml {$tmpxml} -xsl {$tmpxsl} -pdf {$tmppdf} 2>&1");
         @unlink($tmpxml);
         @unlink($tmpxsl);
     } else {
         $xml = new DOMDocument();
         $xml->loadXML($this->xml);
         $xsl = new DOMDocument();
         $xsl->loadXML($this->xsl);
         $proc = new XSLTProcessor();
         $proc->importStyleSheet($xsl);
         $java_library_path = 'file:/usr/share/fop/lib/fop.jar;file:/usr/share/fop/lib/FOPWrapper.jar';
         try {
             java_require($java_library_path);
             $j_fwc = new JavaClass("FOPWrapper");
             $j_fw = $j_fwc->getInstance($fopcfg);
             $j_fw->run($proc->transformToXML($xml), $tmppdf);
         } catch (JavaException $ex) {
             $trace = new Java("java.io.ByteArrayOutputStream");
             $ex->printStackTrace(new Java("java.io.PrintStream", $trace));
             print "java stack trace: {$trace}\n";
         }
     }
     return $tmppdf;
 }
Beispiel #3
0
 function loadObject($gateway)
 {
     $CI =& get_instance();
     $this->object_loaded = TRUE;
     define("JAVA_HOSTS", $gateway['url'] . ':' . $gateway['port']);
     if (!@(include_once $CI->config->item('java_include_path') . "JavaBridge/java/Java.inc")) {
         require_once $CI->config->item('java_include_path') . "JavaBridge/java/Java.inc";
     }
     java_require($CI->config->item('java_include_path') . "java/lib");
     $this->ECCOClient = new Java("com.edgil.ecco.eccoapi.ECCOClient", "PHPTestECCO", $CI->config->item('java_include_path') . "java/ecco/data/ECCO.properties");
     // define ECCOStatusCodes object for ECCO Constants...
     $this->ECCOStatusCodes = new Java("com.edgil.ecco.eccoapi.ECCOStatusCodes");
     $this->pass = array("C", "h", "a", "n", "g", "e", "I", "t");
     $this->alias = array("e", "d", "g", "i", "l", "c", "a");
 }
Beispiel #4
0
 function search($pQuery)
 {
     global $gBitSystem;
     $this->mResults = array();
     $this->mHits = 0;
     if (!empty($pQuery) && $this->verifySearchIndex()) {
         parent::search($pQuery);
         // use java wddx
         $query = $pQuery;
         java_require(LUCENE_PKG_PATH . 'indexer/lucene.jar;' . LUCENE_PKG_PATH . 'indexer');
         $obj = new Java("org.bitweaver.lucene.SearchEngine");
         $result = $obj->search($this->getField('index_path'), "OR", $query, $this->getField('index_fields'));
         if ($meta = $result->get('meta_data')) {
             $this->mHits = (string) $meta->get('hits');
         } else {
             $this->mHits = 0;
         }
         $this->mResults = $result->get('rows');
     }
     return count($this->mResults);
 }
Beispiel #5
0
function java_set_library_path($arg)
{
    return java_require($arg);
}
Beispiel #6
0
 static function validate_login_ntlm($username, $password)
 {
     if (!function_exists("java_get_base")) {
         require "lib/java/java.php";
     }
     if (!function_exists("java_require")) {
         sys_log_message_alert("login", sprintf("{t}%s is not compiled / loaded into PHP.{/t}", "PHP/Java Bridge"));
         return false;
     }
     java_require("jcifs-1.3.8_tb.jar");
     $conf = new JavaClass("jcifs.Config");
     $conf->setProperty("jcifs.smb.client.responseTimeout", "5000");
     $conf->setProperty("jcifs.resolveOrder", "LMHOSTS,DNS");
     $conf->setProperty("jcifs.smb.client.soTimeout", "10000");
     $conf->setProperty("jcifs.smb.lmCompatibility", "0");
     $conf->setProperty("jcifs.smb.client.useExtendedSecurity", false);
     $auth = sys_get_header("Authorization");
     $session = new JavaClass("jcifs.smb.SmbSession");
     $result = new Java("jcifs.smb.NtlmPasswordAuthentication", "", $username, $password);
     $username = $result->getUsername();
     if (SETUP_AUTH_NTLM_SHARE) {
         $w = new Java("jcifs.smb.SmbFile", SETUP_AUTH_NTLM_SHARE, $result);
         $message = $w->canListFiles();
         if ($message == "Invalid access to memory location.") {
             header("Location: index.php");
             exit;
         }
     } else {
         $message = $session->logon(SETUP_AUTH_HOSTNAME_NTLM, $result);
     }
     if ($message != "" or $username == "") {
         sys_log_message_alert("login", sprintf("{t}Login failed from %s.{/t} (ntlm) ({t}Username{/t}: %s, %s)", _login_get_remoteaddr(), $username, $message));
         return false;
     }
     $_SERVER["REMOTE_USER"] = modify::strip_ntdomain($username);
     if (empty($_REQUEST["folder"])) {
         $_REQUEST["redirect"] = 1;
     }
     return true;
 }
        throw new JavaException("java.lang.Exception", "bleh!");
        // not reached
        echo "ERROR.\n";
        exit(3);
    }
    function c2($b)
    {
        echo "c2: {$b}\n";
        return $b;
    }
    function c3($e)
    {
        echo "c3: {$e}\n";
        return 2;
    }
}
$here = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
if (!$here) {
    $here = getcwd();
}
java_require("{$here}/callback.jar");
$c = new c();
$closure = java_closure($c, null, java("Callback"));
$callbackTest = new java('Callback$Test', $closure);
if ($callbackTest->test()) {
    echo "test okay\n";
    exit(0);
} else {
    echo "test failed\n";
    exit(1);
}
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$here = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
if (!$here) {
    $here = getcwd();
}
java_require("{$here}/numberTest.jar");
$test = new java('NumberTest');
print "getInteger() = ";
echo $test->getInteger();
echo "<br>\n";
print "getPrimitiveInt() = ";
echo $test->getPrimitiveInt();
echo "<br>\n";
print "getFloat() = ";
echo $test->getFloat();
echo "<br>\n";
print "getPrimitiveFloat() = ";
echo $test->getPrimitiveFloat();
echo "<br>\n";
print "getDouble() = ";
echo $test->getDouble();
echo "<br>\n";
print "getPrimitiveDouble() = ";
echo $test->getPrimitiveDouble();
echo "<br>\n";
print "getBigDecimal() = ";
echo $test->getBigDecimal();
echo "<br>\n";
<?php

session_start();
?>

<?php 
echo "hello";
//java_require("/usr/lib/jvm/java-7-openjdk-i386/jre/lib/ext/calculator.jar");
//require_once("java/Java.inc");
require_once "http://127.0.0.1:8081/JavaBridge/java/Java.inc";
echo "hello1.5";
java_require("calculator.jar");
//java("demo.rfc.test.RpcConsumer")->main();
java_require("demo.jar");
$CA = new Java("calculator.CalculatorBean");
//$RC = new Java("calculator.test.RpcConsumer2");
$RC = new Java("demo.rpc.test.RpcConsumer2");
$RC->test();
$session = java_session();
if (is_null(java_values($calcinstance = $session->get("calculatorInstance")))) {
    $session->put("calculatorInstance", $calcinstance = new Java("calculator.CalculatorBean"));
}
echo "hello2";
$result = 0;
$opr = "none";
$term_1 = 0;
$term_2 = 0;
if (isset($_POST['operationName'])) {
    $opr = $_POST['operationName'];
}
if (isset($_POST['term1Name'])) {
<?php

define("JAVA_PREFER_VALUES", true);
require_once "java/Java.inc";
$system = new java("java.lang.System");
$t1 = $system->currentTimeMillis();
$here = getcwd();
// load scheme interpreter
// try to load local ~/lib/kawa.jar, otherwise load it from sf.net
try {
    java_require("kawa.jar");
} catch (JavaException $e) {
    java_require("http://php-java-bridge.sourceforge.net/kawa.jar");
}
$s = new java("kawa.standard.Scheme");
for ($i = 0; $i < 100; $i++) {
    $res = java_cast($s->eval("\n\n(letrec\n ((f (lambda(v)\n       (if \n\t   (= v 0)\n\t   1\n\t (*\n\t  (f\n\t   (- v 1))\n\t  v)))))\n (f {$i}))\n\n"), "D");
    if ($ex = java_last_exception_get()) {
        $res = $ex->toString();
    }
    java_last_exception_clear();
    echo "fact({$i}) ==> {$res}\n";
}
$t2 = $system->currentTimeMillis();
$delta = ($t2 - $t1) / 1000.0;
$now = new java("java.sql.Timestamp", $system->currentTimeMillis());
echo "Evaluation took {$delta} s -- at: {$now}\n";
Beispiel #11
0
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$Array = new JavaClass("java.lang.reflect.Array");
$testobj = $Array->newInstance(new JavaClass("java.lang.String"), array(2, 2, 2, 2, 2, 2));
$testobj[0][0][0][0][0][1] = 1;
$testobj[0][0][0][0][1][0] = 2;
$testobj[0][0][0][1][0][0] = 3;
$testobj[0][0][1][0][0][0] = 4;
$testobj[0][1][0][0][0][0] = 5;
$testobj[1][0][0][0][0][0] = 6;
$here = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
if (!$here) {
    $here = getcwd();
}
java_require("{$here}/array6.jar");
$array6 = new java("Array6");
$success = java_values($array6->check($testobj));
var_dump(java_values($testobj[0][0][0][0]));
if (!$success) {
    echo "ERROR\n";
    exit(1);
}
echo "test okay\n";
exit(0);
Beispiel #12
0
$prms['init'] = $_GET['init'];
if (is_array($parameters) && count($parameters) > 0) {
    foreach ($parameters as $ky => $vl) {
        $prms['prompt' . $ky] = $_GET['prompt' . $ky] = $vl;
    }
}
unset($_GET['parameters']);
$inetreportsfiles = isset($sess_usertype_short) && (trim($sess_usertype_short) == 'OA' || trim($sess_usertype_short) == 'OU') ? $inetreportsfiles . '/adminrpt' : $inetreportsfiles . '/userrpt';
//
// pr($_GET); exit;
set_time_limit(0);
/*$params = http_build_query($prms);
echo "<iframe src='http://localhost:9000/?".$params."' width='730px' height='467px' style='overflow:hidden;' />";
exit;*/
require_once "http://localhost:8080/JavaBridge/java/Java.inc";
java_require("{$inetcorehome}/ClearReports.jar;{$inetcorehome}/ReportViewer.jar;{$inetcorehome}/CCLib.jar;{$javalib}/mysql-connector-java-5.1.10.jar");
/*
 * Helper function to get the request property bag from the
 * get and post parameters
*/
function clearreports_get_request_properties($get, $post)
{
    $p = new Java("java.util.Properties");
    foreach ($post as $key => $val) {
        $p->put($key, $val);
    }
    foreach ($get as $key => $val) {
        $p->put($key, $val);
    }
    // Add the client language that the browser has sent.  Useful for
    // multi-language reports.
        if (!checkdate($bloques[2], $bloques[1], $bloques[3])) {
            return false;
        }
    } else {
        return false;
    }
    return true;
}
function isint($mixed)
{
    return preg_match('/^\\d*$/', $mixed) == 1;
}
//error_reporting(E_ERROR);
require_once "JasperReports.php";
include "phpjasper/Java.inc";
java_require(dirname(__FILE__) . "/phpjasper/drivers.jar");
$dir = dirname(__FILE__) . "/phpjasper/Pool/";
$URLBASE = $SYS["BASE"] . "/Apps/JasperReports//phpjasper/Pool/";
/*
try {*/
foreach ($_GET as $var => $dat) {
    $dati = urldecode($dat);
    $dato = str_replace("\\'", "'", $dati);
    //$dato = $dat;
    if ($var != "rewrite" && $var != "petition") {
        if ($var == "ROOT") {
            $atomParam = array();
            $atomParam["paraname"] = "ROOT";
            $atomParam["paratype"] = "Cadena";
            $atomParam["value"] = $SYS["ROOT"];
            $P[] = $atomParam;
Beispiel #14
0
<?php

include_once "java/Java.inc";
$here = getcwd();
java_require("{$here}/hashSetFactory.jar");
$hash = java("HashSetFactory")->getSet();
$hash->add(1);
$hash->add(3);
foreach ($hash as $key => $val) {
    echo "{$key}=>{$val}\n";
}
<?php 
require_once "http://127.0.0.1:8081/JavaBridge/java/Java.inc";
java_require("calculator.jar");
java_require("rpc.jar");
class JavaHandler
{
    function get()
    {
        echo "hello Java Handler here";
        $CA = new Java("calculator.CalculatorBean");
        $session = java_session();
        if (is_null(java_values($calcinstance = $session->get("calculatorInstance")))) {
            $session->put("calculatorInstance", $calcinstance = new Java("calculator.CalculatorBean"));
        }
        echo "<br>after calcultator";
        echo "<br>session from java = " . java_values($calcinstance = $session->get("calculatorInstance"));
        if (eregi('^/java/rpc/*', $_SERVER['REQUEST_URI'])) {
            $RPC = new Java("rpc.test.RpcConsumer");
            $RPC->test();
            echo "<br> RPC Service on 8082 ";
        }
    }
    function post_xhr()
    {
        if (eregi('^/login/*', $_SERVER['REQUEST_URI'])) {
        }
    }
}
#!/usr/bin/php

<?php 
//
// this test must be called twice with a standalone or J2EE back end
//
include_once "java/Java.inc";
$rc = false;
for ($i = 0; $i < 100; $i++) {
    @java_reset();
    $here = getcwd();
    java_require("{$here}/arrayToString.jar");
    $Thread = new JavaClass("java.lang.Thread");
    $loader = $Thread->currentThread()->getContextClassLoader();
    $Class = new JavaClass("java.lang.Class");
    $class = $Class->forName("ArrayToString", false, $loader);
    $class2 = $loader->loadClass("ArrayToString");
    $System = new JavaClass("java.lang.System");
    $hc1 = java_values($System->identityHashCode($class));
    $hc2 = java_values($System->identityHashCode($class2));
    $rc = $hc1 == $hc2;
    if (!$rc) {
        $Util = new JavaClass("php.java.bridge.Util");
        $vm_name = $Util->VM_NAME;
        echo "ERROR: {$hc1}, {$hc2}\n";
        echo "Dynamic loading not available in this VM.\n";
        echo "Responsible VM: {$vm_name}\n";
        break;
    }
}
if ($rc) {
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
function x1($s1, $o1)
{
    echo "c1: {$s1}, {$o1}\n";
    return 1;
}
function c2($b)
{
    return !java_values($b);
}
$here = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
if (!$here) {
    $here = getcwd();
}
java_require("{$here}/../tests.php5/callback.jar");
$closure = java_closure(null, array("c1" => "x1"), java("Callback"));
$callbackTest = new java('Callback$Test', $closure);
if ($callbackTest->test()) {
    echo "test okay\n";
    exit(0);
} else {
    echo "test failed\n";
    exit(1);
}
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$here = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
if (!$here) {
    $here = getcwd();
}
java_require("{$here}/binaryData.jar");
$binaryData = new Java("BinaryData");
echo java_inspect($binaryData);
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$here = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
if (!$here) {
    $here = getcwd();
}
// must succeed
echo "must succeed\n";
java_require("{$here}/noClassDefFound.jar;{$here}/doesNotExist.jar");
$v = new java("NoClassDefFound");
$v->call(null);
<?php

require_once "java/Java.inc";
java_require("itext.jar");
try {
    $document = new java("com.lowagie.text.Document");
    $out = new java("java.io.ByteArrayOutputStream");
    $pdfWriter = java("com.lowagie.text.pdf.PdfWriter")->getInstance($document, $out);
    $document->open();
    $font = java("com.lowagie.text.FontFactory")->getFont(java("com.lowagie.text.FontFactory")->HELVETICA, 24, java("com.lowagie.text.Font")->BOLDITALIC, new java("java.awt.Color", 0, 0, 255));
    $paragraph = new java("com.lowagie.text.Paragraph", "Hello World", $font);
    $document->add($paragraph);
    $document->close();
    $pdfWriter->close();
    // print the generated document
    header("Content-type: application/pdf");
    header("Content-Disposition: attachment; filename=HelloWorld.pdf");
    echo java_values($out->toByteArray());
} catch (JavaException $e) {
    echo "Exception occured: ";
    echo $e;
    echo "<br>\n";
}
<?php

include_once "java/Java.inc";
$here = getcwd();
java_require("{$here}");
class cg
{
    function toString()
    {
        return "cg";
    }
}
class TestClosure
{
    function f()
    {
        return new java("java.lang.String", "hello");
    }
}
class TestClosure1
{
    function g()
    {
        return new cg();
    }
}
$c1 = java_closure(new TestClosure(), null, java("TestClosure"));
echo $c1->f();
$c1 = java_closure(new TestClosure1(), null, java("TestClosure1"));
echo $c1->g();
/**
* Provides a jikes based automatic build system using jikes and the php java bridge
* Just call this method at the start of your script, and it will ensure that
* all modified java files will be compiled, and the neccessary libraries are
* in your classpath.
* Params:
* $src_path - The base directory where the java files reside
* $target_path - [Optional] Target directory for class files
* $extra_classpath - [Optional] additional jar files / classpaths used in the project.
* Paths separated by ';'
*/
function java_autoproject($src_path, $target_path = '', $extra_classpath = '', $extra_lib_dirs = '')
{
    if ($target_path == '') {
        $target_path = $src_path;
    }
    $compiled_count = 0;
    $ecp = '';
    if ($extra_classpath != '') {
        $ec = explode(';', $extra_classpath);
        foreach ($ec as $cp) {
            $cpl = '';
            $cpl = @realpath($cp);
            if ($cpl == '') {
                $cpl = getcwd() . '/' . $cp;
            }
            $ecp .= $cpl . ':';
        }
    }
    if ($extra_lib_dirs != '') {
        $libdirs = explode(';', $extra_lib_dirs);
        foreach ($libdirs as $libdir) {
            $glibdir = '';
            $glibdir = @realpath($libdir);
            if ($glibdir == '') {
                $glibdir = getcwd() . '/' . $libdir;
            }
            $ecp .= ':' . implode(':', dir_pattern_scan($glibdir, '\\.jar$', '/', 1));
        }
    }
    if ($ecp != '') {
        $extra_classpath = strtr($ecp, ':;', ';;');
    }
    if ($extra_classpath != '') {
        $cp = $target_path . ";{$extra_classpath}";
    } else {
        $cp = $target_path;
    }
    try {
        $compiled_count = jikes_compile($src_path, $target_path, true, $ecp, $extra_lib_dirs);
        if ($compiled_count > 0) {
            java_invalidate_library_path($cp);
        }
    } catch (JavaCompilationException $jce) {
        echo $jce;
    }
    java_require($cp);
    return $compiled_count;
}
Beispiel #23
0
function callReport($nomReport, $arrParam)
{
    global $SYS;
    require_once "Java.inc";
    //java_require(dirname(__FILE__)."/jfreechart-1.0.1.jar");
    java_require(dirname(__FILE__) . "/drivers.jar");
    //java_require("/usr/share/java/postgresql-jdbc3.jar");
    try {
        copy("{$SYS["ROOT"]}/JasperReports/phpjasper/Pool/{$nomReport}.jrxml", "/tmp/{$nomReport}.jrxml");
        $jcm = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager");
        $report = $jcm->compileReport("/tmp/{$nomReport}.jrxml");
        $jfm = new JavaClass("net.sf.jasperreports.engine.JasperFillManager");
        $Conn = new Java("org.altic.jasperReports.JdbcConnection");
        $Conn->setDriver("org.postgresql.Driver");
        $Conn->setConnectString("jdbc:mysql://{$_SERVER["SERVER_NAME"]}:3306/{$SYS["mysql"]["DBNAME"]}");
        // Parche tonto
        // 		$Conn->setConnectString("jdbc:postgresql://localhost:5432/{$_SESSION['dbname']}"); //
        $Conn->setUser("ascore");
        $Conn->setPassword("ascore");
        if ($Conn->getConnection()) {
            $parameters = new Java("java.util.HashMap");
            /* PARAMETROS */
            foreach ($arrParam as $n => $v) {
                // Tendré que comprobar el tipo, pasar ad_reference_id por parámetro
                if (isset($v['type'])) {
                    if ($v['type'] == "Date") {
                        $ts1 = text_to_int($v['value']);
                        $JAVA_PAR = new Java("java.util.Date", date("Y", $ts1) - 1900, date("m", $ts1) - 1, date("d", $ts1));
                        $parameters->put($n, $JAVA_PAR);
                    } else {
                        if ($v['type'] == "Integer") {
                            $JAVA_PAR = new Java("java.lang.Integer", $v['value']);
                            //die( "NOMBRE PARAM: $n ; VALOR: {$v['value']} <br />");
                            $parameters->put($n, $JAVA_PAR);
                        } else {
                            if ($v['type'] == "Boolean") {
                                $JAVA_PAR = new Java("java.lang.Boolean", $v['value']);
                                $parameters->put($n, $JAVA_PAR);
                            } else {
                                if ($v['type'] == "Double") {
                                    $JAVA_PAR = new Java("java.lang.Double", $v['value']);
                                    $parameters->put($n, $JAVA_PAR);
                                } else {
                                    $parameters->put($n, $v['value']);
                                }
                            }
                        }
                    }
                } else {
                    $parameters->put($n, $v['value']);
                }
            }
            $parameters->put("REPORT_DIR", "/tmp/tmp/");
            $print = $jfm->fillReport($report, $parameters, $Conn->getConnection());
            $listaPag = $print->getPages();
            $numPag = $listaPag->size();
            if ($numPag == '0') {
                // Mostramos mensaje, el documento no contiene páginas (Usar div similar al session caducada)
                $_SESSION['msgDocInfo'] = "El documento no tiene p&aacute;ginas.";
            } else {
                $filem = time();
                $finalname = "/tmp/{$filem}.pdf";
                $jem = new JavaClass("net.sf.jasperreports.engine.JasperExportManager");
                $jem->exportReportToPdfFile($print, $finalname);
                while (ob_end_clean()) {
                }
                if (file_exists($finalname)) {
                    header('Content-type: application/pdf');
                    header("Content-Disposition: attachment; filename=\"{$finalname}\"");
                    readfile($finalname);
                }
                die;
            }
        } else {
            echo "ERRORS";
        }
    } catch (JavaException $ex) {
        /*$trace = new Java("java.io.ByteArrayOutputStream");
        		$ex->printStackTrace(new Java("java.io.PrintStream", $trace));
        		print "java stack trace: $trace\n";*/
        ob_end_clean();
        echo "<pre>ERROR<br>";
        echo "Cause: " . $ex->getCause() . "<br>";
        echo "Message: " . $ex->getMessage() . "</pre>";
    }
}
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$here = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
if (!$here) {
    $here = getcwd();
}
java_require("{$here}/testClass.jar");
/* See PR1616498 */
try {
    $obj = new Java("TestClass");
    $cls = $obj->getClass();
    $name = $cls->getName();
    $objname = $obj->getName();
    //this fails in 3.1.8 due to a cache problem
} catch (JavaException $e) {
    echo "test failed";
    exit(1);
}
echo "test okay\n";
exit(0);
<?php

include_once "java/Java.inc";
$here = getcwd();
try {
    java_require("{$here}/testCoerceArray.jar");
    $t1 = new java("TestCoerceArray");
    $t2 = new java("TestCoerceArray");
    echo java("TestCoerceArray")->f(array($t1, $t2));
    echo "\n";
} catch (Exception $e) {
    echo "test failed\n";
    exit(1);
}
exit(0);
            die("ERROR: Incorrect {$WAS_HOME}.");
        }
        $name = "RMIdocument";
        java_require("{$WAS_HOME}/lib/;{$clientJar}");
        $server = array("java.naming.factory.initial" => "com.ibm.websphere.naming.WsnInitialContextFactory", "java.naming.provider.url" => "iiop://{$HOST}:2809");
        break;
    case SERVER::SUN:
        echo "sun. Loading: {$app_server}/lib\n";
        if (!java_values($props['java.vm.vendor']->toLowerCase()->startsWith("sun"))) {
            echo "WARNING: You need to run this example with the SUN VM\n";
        }
        if (!is_dir($app_server)) {
            die("ERROR: Incorrect {$app_server}.");
        }
        $name = "RMIdocument";
        java_require("{$app_server}/lib/;{$clientJar}");
        $server = array("java.naming.factory.initial" => "com.sun.jndi.cosnaming.CNCtxFactory", "java.naming.provider.url" => "iiop://{$HOST}:3700");
        break;
}
try {
    $doc = createDocument($name, $server);
} catch (JavaException $e) {
    echo "Could not create remote document. Have you deployed documentBean.jar?\n";
    echo $e->getCause() . "\n";
    exit(1);
}
/* add pages to the remote document */
$doc->addPage(new java("Page", 0, "this is page 1"));
$doc->addPage(new java("Page", 0, "this is page 2"));
/* and print a summary */
print $doc->analyze() . "\n";
Beispiel #27
0
<?php

include_once "java/Java.inc";
include "../php_java_lib/JspTag.php";
$session = java_session();
$here = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
if (!$here) {
    $here = getcwd();
}
java_require("{$here}/fooTag.jar");
$attributes = array("att1" => "98.5", "att2" => "92.3", "att3" => "107.7");
$pc = new java_PageContext($session);
$tag = new java_Tag($pc, "FooTag", $attributes);
if ($tag->start()) {
    do {
        $pc->getPageContext()->getOut()->print("member:: ");
        $pc->getPageContext()->getOut()->println($pc->getPageContext()->getAttribute("member"));
    } while ($tag->repeat());
}
$tag->end();
Beispiel #28
0
 /**
  *  Choose the Dieselpoint index to use for this query.
  *
  *  @param mixed (string) Filesystem path to the dieselpoint index to open.
  *               (object) Java Object from ({@link WFDieselSearch::index()})
  */
 function setIndex($index)
 {
     try {
         if (!defined('DIESELPOINT_JAR_FILES')) {
             throw new Exception("DIESELPOINT_JAR_FILES must be defined, usually in your webapp.conf file.");
         }
         java_require(DIESELPOINT_JAR_FILES);
         if (is_string($index)) {
             $Index = new JavaClass("com.dieselpoint.search.Index");
             $this->index = $Index->getInstance($index);
         } else {
             $this->index = $index;
         }
         $this->searcher = new Java("com.dieselpoint.search.Searcher", $this->index);
     } catch (JavaException $e) {
         $this->handleJavaException($e);
     }
 }
<?php

include_once "java/Java.inc";
$here = getcwd();
java_require("{$here}/testClosureCache.jar");
function toString()
{
    return "ccl";
}
$tc = new Java("TestClosureCache");
"ichild::ccl" == $tc->proc1(java_closure(null, null, java('TestClosureCache$IChild'))) || die(1);
"iface::ccl" == $tc->proc1(java_closure(null, null, java('TestClosureCache$IFace'))) || die(2);
echo "test okay\n";
<?php

include_once "java/Java.inc";
$passwd = "hello";
try {
    java_require("mail.jar");
    // mail.jar is not part of the standard jdk
    $password = new java("java.lang.String", "{$passwd}");
    $algorithm = java("java.security.MessageDigest")->getInstance("md5");
    $algorithm->reset();
    $algorithm->update($password->getBytes());
    $encrypted = $algorithm->digest();
    $out = new java("java.io.ByteArrayOutputStream");
    java_inspect(java("javax.mail.internet.MimeUtility"));
    $encoder = java("javax.mail.internet.MimeUtility")->encode($out, "base64");
    $encoder->write($encrypted);
    $encoder->flush();
    echo new java("java.lang.String", $out->toByteArray());
    echo "\n";
    exit(0);
} catch (Exception $e) {
    echo "Echo invocation failed: {$e}\n";
    //print_r ($e->getTrace());
    exit(1);
}
?>