<?irev $_SERVER variables ?>

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dickey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Wed Apr 08, 2009 11:54 pm

<?irev $_SERVER variables ?>

Post by dickey » Fri Dec 18, 2009 3:17 am

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: <?irev $_SERVER variables ?>

Post by FourthWorld » Fri Dec 18, 2009 9:13 am

Wouldn't $PATH_TRANSLATED give you what you're after?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dickey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Wed Apr 08, 2009 11:54 pm

Re: <?irev $_SERVER variables ?>

Post by dickey » Fri Dec 18, 2009 1:22 pm

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
Last edited by dickey on Fri Dec 18, 2009 9:09 pm, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: <?irev $_SERVER variables ?>

Post by FourthWorld » Fri Dec 18, 2009 6:18 pm

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. :)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dickey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Wed Apr 08, 2009 11:54 pm

Re: <?irev $_SERVER variables ?>

Post by dickey » Fri Dec 18, 2009 9:54 pm

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

Post Reply