As we have seen since the very beginning, Rebol has the amazing power of being able to execute code remotely. Behind the scene, it will transparently load the script from the server and execute it on your machine as if the web storage was an extension of your disk space.
Since it is not a script executed by a server, how can you control the access to it by users ? And what if your web server does not have Rebol hosting ? Well use PHP.
Before we dwelve into php, you should know about another amazing Rebol script feature: the capability of being embedded in the web medium. For example browse to this html page:.

If you look at the source this a standard htlml page:
<html>
<head>
</head>
<body>
<pre>
Rebol [
Title: "rebol script embedded in html"
Author-Url: <a href=http://reboltutorial.com/blog/protect-rebol-script-with-php/>http://reboltutorial.com/blog/protect-rebol-script-with-php/</a>
Script-Url: <a href=http://reboltutorial.com/source/rebolscriptembedded.html>http://reboltutorial.com/source/rebolscript.html</a>
Date: 24-Aug-2009
Purpose: {
demo of rebol script embedded in html
}
]
ask "You're successfull!"
</pre>
</body>
</html>
Still you can execute it by typing in Rebol’s Console:
do http://reboltutorial.com/source/rebolscriptembedded.html
This should be successfull:

So protecting your script in PHP while still being nicely accessible through the web browser should now be easy:
<?php
$username = $_GET['user'];
$password = $_GET['password'];
if ($username=="user") {
if ($password=="password") {
include("rebolscriptembedded.html");
}
else
{
echo "<html>
<header>
</header>
<body>
<div class='rebol'>
<pre>
Rebol []
print {http://reboltutorial.com/source/protect.php?user=user&password=password}
ask {Password not entered correctly please try again.}
</pre>
</div>
</body>
</html>";
}
} else
{
echo "<html>
<header>
</header>
<body>
<div class='rebol'>
<pre>
Rebol []
print {http://reboltutorial.com/source/protect.php?user=user&password=password}
ask {User not entered correctly please try again.}
</pre>
</div>
</body>
</html>";
}
?> In the php script above, remark how Rebol’s strings blend nicely within PHP as you can use curly braces {} to delimit Rebol’s string instead of quotes so that you can avoid ugly escape characters. Also, as Hostilefork puts it the “benefit of using an asymmetric symbol is that REBOL can handle embedded braces as long as they match up”. It’s also more readible when you have to handle “‘”, you can write {’} or {”} in rebol instead.
As for behavior, if the credentials are correct, php will return the embedded rebol script, if not, it will print a message to Rebol’s Console or output a nice html message in your browser. If you navigate to http://reboltutorial.com/source/protect.php, the result will be:

If you execute http://reboltutorial.com/source/protect.php in Rebol’s Console, you will get a failure message:

If you enter login and password by navigating to http://reboltutorial.com/source/protect.php?user=user&password=password, you will get the same nice html page as already seen:

If you execute http://reboltutorial.com/source/protect.php?user=user&password=password in Rebol’s Console, you will get a successfull message:

This model is kind of Easy Distributed Web Service.

















