ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Kid in a Candy Store

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Kid in a Candy Store

    They finally (after 4 years of begging) installed PHP on my development box today. YEAAAAA!!

    It's nice to be able to get into the development of PHP again! Something outside of internet programming anyway.

    I really do feel like a kid in a candy store again... I just need to find the iSeries DB2 connectivity section to start playing with.

    I can't wait...

    -R

    PS: Any suggestions, links, PDFs, examples or otherwise are totally welcome!

    (I'm going to be blogging about my trek on here)

  • #2
    Re: Kid in a Candy Store

    cool i can wait to read bout it....
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Kid in a Candy Store

      You CAN? --- LOL thanks!

      Comment


      • #4
        Re: Kid in a Candy Store

        Try Wordpress. It's what I run my site on: http://www.wordpress.org

        It's written in PHP and can be customized through plug-ins. I'd love to try running WP on an iSeries box. Maybe I will if I get a better machine someday....
        Jonas Temple
        Got FROG?
        Got Tadpole? No, because it's not done yet! Stay tuned....

        01010111 01100001 01110011 01110011 01110101 01110000 00100000 01100100 01101111 01100111 00111111

        Comment


        • #5
          Re: Kid in a Candy Store

          here's a fairly simple app using the i5_ functions:
          Code:
          <? 
          error_reporting (E_ALL ^ E_NOTICE);
          session_start();
          
          header('Cache-Control: no-store, no-cache, must-revalidate');
          header('Pragma: no-cache');
          include_once('../i5Toolkit_library/Toolkit_classes.php');
          include_once('menuAction.php');
          $_SESSION['KillIt'] = False;
          
          performMenuAction();
          
          $conn = i5_connect('127.0.0.1',$_SESSION['AppUsr'],$_SESSION['AppPass']);
          $file = i5_open("TTLIB/MENUMAST", I5_OPEN_READ, $conn);
          if (!$file) die("Error opening MENUMAST file");
          
          $secfile = i5_open("TTLIB/SECUSRDET",I5_OPEN_READ, $conn);
          if (!$secfile) die("Error opening SECUSRDET file");
          
          $fields = i5_list_fields($file);
          $key[] = $_SESSION['Menu'];
          
          $seckeys[0] = strtoupper($_SESSION['AppUsr']);
          $seckeys[1] = $_SESSION['Menu'];
          
          i5_seek($file,"=",$key);
          $row = i5_fetch_assoc($file,I5_READ_SEEK);
          
          $menu_title = $row['TITLE'];
          include_once('../header.php');
          
          if ($_SESSION['KillIt'] == True) 
          {
          	session_destroy(); ?>
          	
          	 	<script type="text/javascript">
          	 	//window.open('','_parent','');
          		//window.close();
          		this.close();
          		//self.close();
          	 	</script>
          	 	<?
          };
          ?>
          <center><h1><? echo $menu_title ?></h1></center>
          
          <?
          //$browser = get_browser();
          $browser = stristr($_SERVER['HTTP_USER_AGENT'],"Firefox");
          if ($browser) {
          	$web_browser = "Firefox";
          } else {
          	$browser = stristr($_SERVER['HTTP_USER_AGENT'],"Opera");
          	if ($browser) {
          		$web_browser = "Opera";
          	} else {
          		$web_browser = "IE";
          	}
          }
          
          if ($web_browser == "IE") { 
          	$_SESSION['table_class'] = "menuTableIE";
          	$_SESSION['row_class'] = "menuTRIE";
          	$_SESSION['th_class'] = "menuTHIE";
          	$_SESSION['form_class'] = "menuFormIE";
          	$_SESSION['menu_button_class'] = "menuButtonIE";
          	$_SESSION['menu_button_MO_class'] = "menuButtonMouseOverIE";
          	$_SESSION['submit_button_class'] = "submitButtonIE";
          	$_SESSION['submit_button_MO_class'] = "submitButtonMouseOverIE";
          	} else { 
          		$_SESSION['table_class'] = "menuTableMz";
          		$_SESSION['row_class'] = "menuTRMz";
          		$_SESSION['th_class'] = "menuTHMz";
          		$_SESSION['form_class'] = "menuFormMz";
             	    $_SESSION['menu_button_class'] = "menuButtonMz";
          	    $_SESSION['menu_button_MO_class'] = "menuButtonMouseOverMz";
           	    $_SESSION['submit_button_class'] = "submitButtonMz";
          	    $_SESSION['submit_button_MO_class'] = "submitButtonMouseOverMz";
          	} 
          ?>
          <table align="center" width="100%" class="<? echo $_SESSION['table_class'] ?>">
          <? 
          
          while ($row)
          { 
            $seckeys[2] = $row['OPTION'];
            i5_seek($secfile,"=",$seckeys);
            $secrow = i5_fetch_assoc($secfile, I5_READ_SEEK);
            if (($secrow != null and $secrow != false) or $row['OPTION'] == 90) {
            
            ?>
          	<tr class="<? echo $_SESSION['row_class'] ?>">
          		<td class="<? echo $_SESSION['th_class'] ?>"><center>
          			<form name="<? echo $row['OPTION'] ?>" method="POST" action="menu.php" 
            				class="<? echo $_SESSION['form_class'] ?>">
          				<input type="hidden" name="menu" value="<? echo $row['MENU'] ?>">
          				<input type="submit" name="<? echo $row['OPTION'] ?>" value=
          				"<? echo $row['OPTTEXT'] ?>" class="<? echo $_SESSION['menu_button_class'] ?>"
          				onmouseover="javascript: this.className='<? echo $_SESSION['menu_button_MO_class'] ?>';" 
          				onmouseout="javascript: this.className='<? echo $_SESSION['menu_button_class'] ?>';">
          				<input type="hidden" name="option" value="<? echo $row['OPTION'] ?>">
          			</form></center>
          		</td>
          	</tr>	
          	<? 
            }
          	$row = i5_fetch_assoc($file,I5_READ_KEYNEXTEQ);
          }?>
          
          </table>
          <?
          if ($_SESSION['Menu'] != "MAIN") {
          	?>
          	<table align="center" width="100%" class="<? echo $_SESSION['table_class'] ?>">
          	<tr>
          		<td colspan="2" width="100%">&nbsp</td>
          	</tr>
          	<tr>
          	<!-- <td width="25%">&nbsp</td> -->
          	<th colspan="2" style="padding-left: 200px;" class="<? echo $_SESSION['th_class'] ?>">
          	<center>
          		<form name="goback" method="POST" action="menu.php" 
            				class="<? echo $_SESSION['form_class'] ?>">
          			<input type="submit" name="return" style="width: 250px; height: 20px;" value=
          				"Return To Main" class="<? echo $_SESSION['menu_button_class'] ?>"
          				onmouseover="javascript: this.className='<? echo $_SESSION['menu_button_MO_class'] ?>';" 
          				onmouseout="javascript: this.className='<? echo $_SESSION['menu_button_class'] ?>';">
          		</form>
          	</center>
          	</th>
          	</table><?
          }
          include_once('../footer.php'); 
          
          i5_close($conn);
          ?>
          </body>
          </html>
          menuAction.php file
          Code:
          <?
           
          function performMenuAction() 
          {
            if (isset($_POST['return'])) {
            	$_SESSION['Action'] = "menu.php";
            	$_SESSION['Menu'] = "MAIN";
            	$_SESSION['SaveMenu'] = "MAIN";
          	$continueto = $_SESSION['Action'];
          	header("Location: $continueto");
          	exit();		
            }
          	$connMenu = i5_connect('127.0.0.1',$_SESSION['AppUsr'],$_SESSION['AppPass']);
          	$fileMenu = i5_open("TTLIB/MENUMAST", I5_OPEN_READ, $connMenu);
          	$menu = $_POST['menu'];
          	$menu_option = $_POST['option'];
          	if ($menu_option == null) return;
          	if ($menu_option == 90) {
          		$_SESSION['KillIt'] = True;
          		return;
          	};
          	// $keys[] = null;
           	$keys[] = $menu;
           	$keys[] = $menu_option;
           	$_SESSION['SaveMenu'] = $menu;
           	$_SESSION['SaveOption'] = $menu_option;
          	i5_seek($fileMenu,"=",$keys);
          	$rowMenu = i5_fetch_assoc($fileMenu,I5_READ_SEEK);
          	//$_SESSION['Action'] = "menu.php";
          	
            if ($rowMenu['SUBMENU'] <> ' ' AND $rowMenu['SUBMENU'] <> null) 
            { $i = 0 ;
            } else {
            	if ($rowMenu['PGM'] <> ' ' AND $rowMenu['PGM'] <> null) 
            	{ $i = 1;
            		} else {
            			if ($rowMenu['CMD'] <> ' ' AND $rowMenu['CMD'] <> null) 
            			{ $i = 2;
            				} else {
            					if ($rowMenu['SCRIPT'] <> ' ' and $rowMenu['SCRIPT'] <> null){
            						$i = 3;
            					} else {
            					$i = 4;
            						}
            				}
            			}
            };
            switch ($i){
            	case 0:
            		$_SESSION['Menu'] = $rowMenu['SUBMENU'];
            		$_SESSION['SaveMenu'] = $rowMenu['SUBMENU'];
            		$_SESSION['Action'] = "menu.php";
            		break;
            		
            	case 1:
            		$_SESSION['Pgm'] = $rowMenu['PGM'];
            		$_SESSION['Submit'] = $rowMenu['SBMJOB'];
            		$_SESSION['JobName'] = $rowMenu['JOBNAME'];
            		$_SESSION['Parm1']	= $rowMenu['PARM1'];
            		$_SESSION['Parm1Len'] = $rowMenu['P1LEN'];
            		$_SESSION['Parm2'] = $rowMenu['PARM2'];
            		$_SESSION['Parm2Len'] = $rowMenu['P2LEN'];
            		$_SESSION['Parm3'] = $rowMenu['PARM3'];
            		$_SESSION['Parm3Len'] = $rowMenu['P3LEN'];
            		$_SESSION['Parm4'] = $rowMenu['PARM4'];
            		$_SESSION['Parm4Len'] = $rowMenu['P4LEN'];
            		$_SESSION['Parm5'] = $rowMenu['PARM5'];
            		$_SESSION['Parm5Len'] = $rowMenu['P5LEN'];
            		$_SESSION['Parm6'] = $rowMenu['PARM6'];
            		$_SESSION['Parm6Len'] = $rowMenu['P6LEN'];
            		$_SESSION['Parm7'] = $rowMenu['PARM7'];
            		$_SESSION['Parm7Len'] = $rowMenu['P7LEN'];
            		$_SESSION['Parm8'] = $rowMenu['PARM8'];
            		$_SESSION['Parm8Len'] = $rowMenu['P8LEN'];
            		$_SESSION['Parm9'] = $rowMenu['PARM9'];
            		$_SESSION['Parm9Len'] = $rowMenu['P9LEN'];
            		$_SESSION['Parm10'] = $rowMenu['PARM10'];
            		$_SESSION['Parm10Len'] = $rowMenu['P10LEN'];
            		$_SESSION['Hold'] = $rowMenu['HOLD'];
            		$_SESSION['JobD'] = $rowMenu['JOBD'];
            		$_SESSION['Action'] = "programcall.php";
            		break;
            		
            	Case 2:
            		$_SESSION['Menu'] = $_POST['menu'];
            		$_SESSION['Cmd'] = $rowMenu['CMD'];
            		$_SESSION['Action'] = "commandcall.php";
            		break;
            		
            	Case 3:
            		$_SESSION['Menu'] = $_POST['menu'];
            		$_SESSION['SaveMenu'] = $_POST['menu'];
            		$_SESSION['Action'] = $rowMenu['SCRIPT'];
            		break;
            		
            	Case 4:	
            		break;
            }		
            
          
            $continueto = $_SESSION['Action'];
            header("Location: $continueto");
            exit();		
            
          } ?>
          I'm not anti-social, I just don't like people -Tommy Holden

          Comment


          • #6
            Re: Kid in a Candy Store

            I"ve done PHP off the iSeries for a while. We finally got PHP up and running yesterday and I can't believe how easily it connects with DB2. Thinking it would be much more difficult is one of the reasons I've stuck with CGIDEV2 and didn't dive right into PHP. Now I think I'll dive!
            Your friends list is empty!

            Comment


            • #7
              Re: Kid in a Candy Store

              michael keep us in the loop please.
              (will never use PHP on our box)

              Have a great weekend

              Jamie
              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment


              • #8
                Re: Kid in a Candy Store

                I'm currently installing PHP on a new box I'm working on ... had issues with the Pre-Requisites but finishing up that install today. Have to uninstall Zend Core and reinstall it after that. Hopefully things will go well and I'll have PHP going this weekend.

                Comment

                Working...
                X