The Applications page is accessed from Monitor | Applications.
The Demo applications included in Zend Server for IBM i are a convenient tool for gaining insight into how you can use the Zend 5250 Bridge API to extend your applications into a Web based environment.
There are several ways to view the Demo page:
A detailed list of the 5250 Bridge API functions that were used in order to create the Demo Applications can be found in the Working with the 5250 Bridge API section.
The source code for the Demo Applications can be found in /usr/local/zendsvr/5250/demos. A convenient way for developers to view the source files is by opening them in your Zend Studio IDE.
See Opening Files in Zend Studio for more information on how to view the code in Zend Studio for Eclipse.
Alternatively, you can view the content of the files from your preferred green screen emulation using the following commands:
To view the code that generates the demo open index.php in the Green screen emulation using option 5 for each directory.
The Zend 5250 Emulator provides browser access to i/OS resources and applications equivalent to an IBM© 5250 terminal without having to deploy telnet or terminal client applications.
The two Demo Applications demonstrate how the Zend 5250 Bridge API can be used to create interactive web-applications for 5250 programs. Clicking one of the demo application links open a new browser Window.
These demo applications were written in PHP using the Zend 5250 Bridge Procedural API Functions using functions to organize the code and HTML for the display.
Note:
The sample application code is located in: /usr/local/zendsvr/250/demos.
For more information about the Demo Applications and how you can recreate this functionality in your environment see: Working with the Demo Applications.
Subfile Demo - The Subfile Demo demonstrates how you can use the 5250 Bridge API to recreate IBM i resources in a Web based environment without using the 5250 emulation client look and feel. This provides a way to extend your IBM i resources to the Web and provide a more user friendly application especially for users who are not familiar with working in an IBM i environment. Another advantage of this method is that you can control the layout of the screen and choose to add or remove information, input fields and buttons. The demo itself is based on a sample application with limited functionality.
Subfile Extended Demo - The Extended Subfile Demo shows how you can use the 5250 Bridge API recreate IBM i resources in a web based environment without using the 5250 emulation client look and feel. This like the Subfile Demo, provides a way to extend your IBM i resources to the web and provide a more user friendly application and in addition demonstrates how you can improve the layout using HTML and AJAX. The demo itself is based on a sample application with limited functionality.
This Zend Navigator Demo Application shows the usage of PHP toolkit for IBM i functions. The source code for this application can be found in /usr/local/zendsvr/apaches2/htdocs/ Zend_Navigator_Demo. The main file is called login.php. The demo application has the following options:
Logon - This option allows you to logon to IBM i with a valid System i user profile.
Active Jobs - This option allows you to view all active jobs. You can use the "Load Subsystem" filter to view jobs in selected subsystems. Clicking on a job line will display some job details and job log.
Spooled Files - This option allows you to view current user spooled files. You can use the 'Load User' user filter to display other users' spooled files. Clicking in a spooled file line will display the spooled file content. Some spooled file details and spooled file options such as DELETE, HOLD/RELEASE or display spooled file content, will be displayed in PDF format.
System Value - This option displays a full list of all IBM i system values.
User Profiles - This option allows you to view all user profiles on your server. Clicking on a user profile line will display some user details and user status options, and will allow you to enable or disable selected user profile statuses.
Database files - This option allows you to view all database files on your server. Selecting a library from the drop-down list and clicking a file will display all data in the file. Click the 'File Description' button in the file display to see more information on the file.
The additional PHP demo scripts will help IBM i developers get started with PHP. These examples include the actual PHP code and the rendered result as follows:
Name |
Code |
Result in Browser |
Hello World |
<?php echo "Hello, World!"; ?> |
Hello, World! |
SQL Access |
<html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $conn_resource = db2_connect("*LOCAL", "", ""); if (!$conn_resource) { echo "Connection failed. SQL Err:"; echo db2_conn_error(); echo "<br>"; echo db2_conn_errormsg(); exit(); } echo "Executing SQL statement: SELECT * FROM ZENDSVR.SP_CUST WHERE CUST_ID > 1220 FOR FETCH ONLY"."<br>", "<br>"; /* Construct the SQL statement */ $sql = "SELECT * FROM ZENDSVR.SP_CUST WHERE CUST_ID > ? FOR FETCH ONLY"; /* Prepare, bind and execute the DB2 SQL statement */ $stmt= db2_prepare($conn_resource, $sql); $lower_limit = 1220; //from the CUST_ID value $flds = db2_num_fields($stmt); if($flds > 0 ) { //show Table Header (analyze result set) echo "<table border=1>"; echo "<tr>"; for($i=0; $i<$flds; $i++) { echo '<td width="20%">'; $aa = db2_field_name($stmt, $i); echo $aa; echo "</td>"; }
echo "</tr>"; //Execute statement , uses a binding of parameters db2_bind_param($stmt, 1, "lower_limit", DB2_PARAM_IN); $result = db2_execute($stmt); if (!$result) { echo 'The db2 execute failed. '; echo 'SQLSTATE value: ' . db2_stmt_error(); echo ' Message: ' . db2_stmt_errormsg(); } else { while ($row = db2_fetch_array($stmt)) { echo "<tr>"; for($i=0; $i<$flds; $i++){ echo '<td width="20%">'; echo $row[$i] . ' '; echo "</td>"; } echo "</tr>"; } } echo "</table>"; } ?> |
|
SQL Access using Zend Framework DB2 adapter |
<html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php require_once 'Zend/Db/Adapter/Db2.php'; $config = array( 'dbname' => '*LOCAL', 'username' => '', 'password' => '', 'os'=>'i5', 'driver_options'=> array("i5_commit" =>DB2_I5_TXN_READ_UNCOMMITTED, "autocommit"=>DB2_AUTOCOMMIT_OFF, "i5_lib"=>'ZENDSVR'));
$conn = new Zend_Db_Adapter_Db2($config); echo "Executing SQL statement: SELECT * FROM ZENDSVR.SP_CUST WHERE CUST_ID > 1220 FOR FETCH ONLY"."<br>", "<br>"; /* Construct the SQL statement */ $sql = "SELECT * FROM ZENDSVR.SP_CUST WHERE CUST_ID > ? FOR FETCH ONLY"; $lower_limit = 1220; //from the CUST_ID value /* Prepare, bind and execute the DB2 SQL statement */ $stmt = $conn->query($sql, $lower_limit); echo '<table border="1">'; $i = 0; while (($row = $stmt->fetch(Zend_Db::FETCH_ASSOC)) !== false) { if($i == 0){ $ColumnNames = ShowTableHeader($row); }
ShowTableRow($ColumnNames, $row ); $i++; } echo '</table>'; exit(); function ShowTableHeader( $row ) { $flds = count( $row ); if ($flds > 0) { $fieldNames = array_keys($row); echo '<tr>'; foreach ($fieldNames as $field) { echo "<td>{$field}</td>"; } echo '</tr>'; }
return $fieldNames; } function ShowTableRow($ColumnNames , $row ) { echo '<tr>'; foreach ($ColumnNames as $ColumnName) { if(trim($row[$ColumnName]) === ''){ echo "<td> </td>"; } else { echo "<td>{$row[$ColumnName]}</td>"; } } echo '</tr>'; } ?> |
|
SQL Access to MYSQL database |
<html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $conn_resource = mysql_connect("localhost", "root", ""); if (!$conn_resource) { echo "Connection failed. SQL Err:"; echo mysql_error(); exit(); } $db = mysql_select_db("mysql", $conn_resource); if(!$db) { echo "database did not select. SQL Err:"; echo mysql_error(); exit(); } echo "Executing SQL statement: select * from user"; echo "<br><br>"; $query = "select * from user"; $stmt = mysql_query($query, $conn_resource); if(!is_resource($stmt)){ echo "query failed. "; echo mysql_error(); exit(); } echo '<table border="1">'; $FirstFetch = true; while ( ($row = mysql_fetch_assoc($stmt)) !== false){ if($FirstFetch ){ $ColumnNames = ShowTableHeader( $row ); $FirstFetch = false; } ShowTableRow($ColumnNames , $row ); } echo '</table>'; function ShowTableHeader( $row ) { $flds = count( $row ); if ($flds > 0) { $fieldNames = array_keys($row); echo '<tr>'; foreach ($fieldNames as $field) { echo "<td>{$field}</td>"; } echo '</tr>'; } return $fieldNames; } function ShowTableRow($ColumnNames , $row ) { echo '<tr>'; foreach ($ColumnNames as $ColumnName) { if(trim($row[$ColumnName]) === ''){ echo "<td> </td>"; } else { echo "<td>{$row[$ColumnName]}</td>"; } } echo '</tr>'; } ?> |
|
Program Call |
#Valid code value is 1 or 2. <?php $user = ''; $password = ''; $conn_resource = i5_connect('127.0.0.1',$user,$password ); if($conn_resource === false){ echo "Connection failed. SQL Err:" . i5_errno(); echo "<br>"; echo i5_errormsg(); exit(); } $desc = array ( array ("name"=>"CODE", "io"=>I5_INOUT, "type" => I5_TYPE_CHAR, "length"=> "10"), array ("name"=>"DESC", "io"=>I5_INOUT, "type" => I5_TYPE_CHAR, "length"=> "10") ); $prog = i5_program_prepare("ZENDSVR/COMMONPGM", $desc); if ($prog === FALSE) { $errorTab = i5_error(); echo "Program prepare failed <br>\n"; var_dump($errorTab); die(); } /* Execute Program */ $paramin = array ("CODE"=>$_POST["code"],"DESC"=>" "); $paramout = array("CODE"=>"var1","DESC"=>"var2"); $ret = i5_program_call($prog, $paramin, $paramout); if ($ret === FALSE) { $errorTab = i5_error(); echo "FAIL : i5_program_call failure code <br>"; var_dump($errorTab); die(); }
echo "The return values are: <br>", "Code: ", $var1, "<br> Description: ", $var2,"<br>"; // Close program call i5_program_close($prog); // Close connection i5_close($conn_resource); ?> |
|
LDAP |
<?php if( isset( $_POST['server']) ) $server = $_POST['server'];
if(isset( $_POST['user'])) $username = $_POST['user']; if( isset( $_POST['pass']) ) $password = $_POST['pass'];
$serverURL = "ldap://". $server ."/"; $ds = ldap_connect( $serverURL ); //try to connect as anonimus if($username === NULL || password == NULL){ $anonymous = ldap_bind( $ds ); if ( !$anonymous ) { // test failed, try to connect with user/password echo "LDAP bind as anonimus failed. Try to connect with User & Password ..."; exit(); } }
$login = ldap_bind( $ds, $username, $password ); if($login){ echo "LDAP bind for user $username successful..."; } else { echo "LDAP bind for user $username failed..."; }
?> |
|
|
Related Links: Working with the Zend 5250 Bridge Introduction to the PHP Toolkit for IBM i |
|
|
|