Page 1 of 1

<?irev $_SERVER variables ?>

Posted: Fri Dec 18, 2009 3:17 am
by dickey
Hello all,

The iRev server variable $_SERVER resembles the server variables (globals) of the same name in PHP, and contains many similar elements within it's array - with several notable exceptions.

I often use $_SERVER['PHP_SELF' ], $_SERVER['SCRIPT_FILENAME' ], and particularly $_SERVER['SCRIPT_NAME'] as a means of referring or submitting a form to the currently executing script in PHP.

Code: Select all

  <?php
    $script = $_SERVER['SCRIPT_NAME'];
    // then elsewhere in the script when defining a form...
    <form action="<?php echo $script; ?>" method="post">
      // form content here...
    </form>
Perhaps such vars will be supported by iRev in time - however no current mention of them or similar in http://samples.on-rev.com/irev-engine-notes.txt.

Can you can post or refer a script to itself in iRev using another technique?

Any assistance greatly appreciated.

Merry Christmas, Andrew

Re: <?irev $_SERVER variables ?>

Posted: Fri Dec 18, 2009 9:13 am
by FourthWorld
Wouldn't $PATH_TRANSLATED give you what you're after?

Re: <?irev $_SERVER variables ?>

Posted: Fri Dec 18, 2009 1:22 pm
by dickey
Hello and thanks Richard,

You know I read the http://samples.on-rev.com/irev-engine-notes.txt file, and completely missed $_SERVER["PATH_TRANSLATED"]. Well - it is the silly season.

Richard, you are of course correct $_SERVER["PATH_TRANSLATED"] is the simile of the PHP functions I referred to earlier and with some filtering worked well. You don't require the full path just the file name to successfully post or link to the current script.

The following code demonstrates the method in an iRev context:

Code: Select all

<?rev 
  if $_POST["name"] is not empty
  then
  put $_POST["name"]
  end if
?>
<html>
  <body>
    <p>
      <?rev
        put $_SERVER["PATH_TRANSLATED"] into tScriptPath
        put tScriptPath
        replace "/" with space in tScriptPath
        put the last word of tScriptPath into tTargetScript
      ?>
    </p>
    <form method="post" action="<?rev put tTargetScript ?>">
      <input name="name" type="text"><br />
      <input type="submit" value="submit">
    </form>
  </body>
</html>
Once again, thank you for posting Richard and Merry Christmas - Andrew

Re: <?irev $_SERVER variables ?>

Posted: Fri Dec 18, 2009 6:18 pm
by FourthWorld
Glad that worked out, Andrew. Man, it IS the silly season: I spent an hour yesterday trying to find out why my standalone that uses a custom plist wasn't working, only to discover I'd accidentally deleted one of the tag's "<" characters.

Must be time for us to take a holiday break. :)

Re: <?irev $_SERVER variables ?>

Posted: Fri Dec 18, 2009 9:54 pm
by dickey
Hello Richard,

Your story says it all. Despite our years and years of experience in programming, it still has a way of punishing you whenever your concentration wanes a little. In that respect the 'Silly Season' can strike anytime (usually accompanied by a double dose of frustration - and visions of a new career in an entirely different field). As you note, miss a simple tag and as my buddies and I say you spend some time in the 'time tunnel' (a reference to a late 60's US sitcom, re-run every now and then) never sure when you will make it home (find a solution).

I second your vote for a holiday.

Thanks again, Andrew