Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 03-13-2011, 10:32 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
3.7 Using a PHP gateway to access your site
The problem with using this setup is that your website's port will change periodically. To combat this problem, I've written a PHP script for Era's website which allows you to visit http://graalcenter.org/ and be redirected to the current site. It also redirects requests for specific pages, so that you can link to http://graalcenter.org/some/random/page and know that it will always work.

The PHP code I used for this PHP gateway is:

index.php
PHP Code:
<?php
$fh 
fopen("port.txt""r");
$port fread($fhfilesize("port.txt"));
fclose($fh);

header("Location: http://server.era.graalcenter.org:" $port "/" $_GET['go']);
?>
update.php
PHP Code:
<?php
$pass 
"change_me";
$ip "50.23.136.183"// get this from statistics.graal.us

if ($_SERVER['REMOTE_ADDR'] != $ip || $_GET['pass'] != $pass) {
    die(
"**** off");
}

$fh fopen("port.txt""w") or die("aa");
fwrite($fh$_GET['port']) or die("bb");
fclose($fh);
?>
.htaccess
Quote:
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?go=$1 [QSA,L]
Be sure to change the password and the redirect URL. You can then enable it in http_listensocket.

4. Conclusion
I think I've covered everything. The script is attached as a ZIP file to the post above. If you have any questions, feel free to ask. Comments are also welcome.

You can see an example of Grattpd in action at http://graalcenter.org/ (note that the site is unfinished).
__________________

Last edited by cbk1994; 03-13-2011 at 10:46 PM.. Reason: fixing stray line break
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:50 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.