explanation of php code

Discussion in 'PHP' started by makhan, Jun 16, 2007.

  1. #1
    Can someone please explain this php code. I would be grateful


    <?php
    // --------------- file tape2matlab2php.php

    // NOTE: if web-server and matlab server are NOT located on the same mashine please use share name.

    $path_data ="\MB_data\Field_Signals\";
    $path_out_file ="MB_dataout";
    $path_descr ="MB_datadesc";
    $path_MB_def ="MB_dataMB_def";
    $path_HDF ="MB_dataout";

    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> Transforming module for Motionbase </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD>

    <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#000080" VLINK="#000080" ALINK="#0000FF">
    <?php

    if (!isset($mode)) {
    $mode="init";
    }
    switch ($mode) {
    case 'init':
    include('inc_init_page.php');
    break;
    case 'run':
    ?>
    <form action="/cgi-bin/matweb.exe" method="POST">
    <input type="hidden" name="mlmfile" value="Tape2coord">
    <input type="hidden" name="dfname" value=" <?PHP echo $dfname ?>" >
    <input type="hidden" name="path_descr" value=" <?PHP echo $path_descr ?>" >
    <input type="hidden" name="path_data" value=" <?PHP echo $path_data ?>" >
    <input type="hidden" name="path_out_file" value=" <?PHP echo $path_out_file ?>" >
    <input type="hidden" name="path_HDF" value=" <?PHP echo $path_HDF ?>" >
    <p><input type="submit" name="Submit" value="Execute"></p>
    </form>
    <?PHP
    break;
    default:
    echo "/tape.php?mode='init'";
    break;
    }
    ?>
    </BODY>
    </HTML>
     
    makhan, Jun 16, 2007 IP
  2. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #2
    from what i can see if $_GET['mode'] ($mode with register_globals) == init and if so then then includes a page, if it == run then it displays a form. if neither, echo "/tape.php?mode='init'"; (whatever that does.... other than output /tape.php?mode='init' to the screen.) shitty code if ya ask me but that's what happens when coders are lazy.
     
    ansi, Jun 16, 2007 IP
  3. makhan

    makhan Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks man, So is it possible if I run this php script on my webserver . Where I am passing some inputs from the flash and this script pass those inputs to the matweb.exe program as its doing in this case.( My point is does it require any user interaction)
     
    makhan, Jun 16, 2007 IP
  4. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #4
    im not quite sure. based on what you have shown it requires them to submit a form if $_GET['mode'] == run
     
    ansi, Jun 16, 2007 IP
    dankenpo likes this.
  5. makhan

    makhan Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Is it possible to submit a form automatically, without user having to press the button( in general not in this example)
     
    makhan, Jun 16, 2007 IP