Automatic Script

 
Post new topic   Reply to topic    Aprelium Forum Index -> Networking Issues
View previous topic :: View next topic  
Author Message
Melinga
-


Joined: 30 Aug 2002
Posts: 5

PostPosted: Fri Aug 30, 2002 4:10 pm    Post subject: Automatic Script Reply with quote

Anyone know where I may find a good and simple script (either php or cgi) that i may run that will write to a online.htm or offline.htm file from my internet site when I need it. So instead of having to post my IP address to people they can just go to my main site on the net and see if I'm online or offline. Hope this make sense :roll:

Any idea's would be appreceated.
Back to top View user's profile Send private message
J. Patrick
-


Joined: 26 Aug 2002
Posts: 42
Location: Pittsburgh, PA USA

PostPosted: Sat Aug 31, 2002 12:12 am    Post subject: i know an ez way Reply with quote

hey i also had this problem when i started working with webservers and it doesn't require an advanced PHP or CGI script in fact I got a good one working in minutes using simple JavaScript.

here is how it works;
1) make a file called server_status.js
2) put var server_status = "online"; in that file
3) save this file and put it in your webservers main directory
4) now get a free host or some host somewhere else
5) login to your account on that host and edit your index.html file
6) in that file put this code
----------------------------------
Code for index.html
----------------------------------
<html><head>
<script language="JavaScript">
<!--
var server_status = "offline";
// -->
</script>
<script language="JavaScript" src="url/ip to server_status.js file"><script>
<script language="JavaScript">
<!--
if(server_status == "offline")
{
document.write("My server is offline. Try again later.");
}
if(server_status == "online")
{
document.write("Reirecting you. Please wait.");
location.href = "the url/ip to your server homepage";
}
// -->
</script>

OK basicaly this is how it works someone goes to your homepage on the freehost or whatever and the variable is set to offline by default. If the server is offline it won't be able to get the JS file thus the variable will stay as "offline" if the server is on the variable will become "online". Then 2 simple if statements will decide what to do. This is very easy to customize if you know some JavaScript and works very well with a url redirector to hide your long host url.

If you want to know of a good nice url redirector i can recomend http://smartdots.com which gives u almost domain addresses or http://dot.tk (you.tk) both are 100% free.

I would recomend this script to anyone who can't leave their pc on 24/7 or to someone who uses dailup.
Back to top View user's profile Send private message Send e-mail AIM Address
Melinga
-


Joined: 30 Aug 2002
Posts: 5

PostPosted: Sat Aug 31, 2002 1:35 am    Post subject: Doesn't work Reply with quote

This sounds like a good script but it doesn't work. Where it says url to the script I would still have to put the current IP address in wouldn't I? Otherwise how does it find the script? Also tried it out using the IP but nothing shows up on the screen. :cry:
Back to top View user's profile Send private message
J. Patrick
-


Joined: 26 Aug 2002
Posts: 42
Location: Pittsburgh, PA USA

PostPosted: Sat Aug 31, 2002 6:36 am    Post subject: Reply with quote

sorry if i didn't make it clear enough

the server_status.js file is hosted on your pc/abyss webserver
the index.html file is hosted on a free host or other website
ie. geocities.com/you/index.html

the javascript coding works like this in the index.html
the page opens and it makes a variable called server_status the same variable in the server_status.js file except the variable is set to "offline"

then you call the server_status.js from your abyss server or whatever server you are using. If your server is on the file will be sent to the page if not it will ingore this and doing nothing with it. If the server is on and the file is sent to the page it changes the variable server_status from "offline" to "online" if the server is turned off or cannot be reached (ie it can't find the server_status.js file) then server_status will stay at "offline".

then a some simple if statements see if the server is offline or online if it is online it redirects them to the server and if the server is offline it says "Try again later."

I also forgot to tell you one more thing at the top of the index.html page make sure to add the meta tag that tells the page NOT to cache the reason for this is so if your server is online someone will cache the page and it will cache the JS file and if your server goes down someone can load the JS from their cache and they will be sent to your server but it will obvoiusly be off. I'm sorry that I don't have the no-cache code right here with me but when I find it i will post it here along with an example.
Back to top View user's profile Send private message Send e-mail AIM Address
J. Patrick
-


Joined: 26 Aug 2002
Posts: 42
Location: Pittsburgh, PA USA

PostPosted: Sat Aug 31, 2002 7:17 am    Post subject: Reply with quote

ok i got a working example up and u can copy and paste my code.
first the examples
a working example of the server being "online" http://www.geocities.com/j_patrick14/index.html

an example of the server being offline
http://www.geocities.com/j_patrick14/offline.html

if u view my sorce u will see i linked to a file on the geocities server i am not home right now and couldn't remember what i really named my server_status.js file :(

and i made 2 files to show u that when the url can't be reached as in file offline.html it will display that message.

here is the "full" coding for it all

-----------------------------------------------------
index.html (put on another server like geocities)
-----------------------------------------------------

<html><head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<script language="JavaScript">
<!--
var server_status = "offline";
// -->
</script>
<script language="JavaScript" src="http://your-ip-address-here/server_status.js"></script>
<script>
if(server_status == "offline")
{
document.write("My server is offline. Try again later.");
}
if(server_status == "online")
{
document.write("Reirecting you. Please wait.");
location.href = 'http://your-ip-address-here/';
}
</script>
</head></html>

if you don't use your ip address to access your server then you can use whatever address you use to access your server.(i would recomend your ip) All should work unless it is a url redirector without path forwarding.

-----------------------------------------------
server_status.js (put on your abyss or whatever server)
-----------------------------------------------

var server_status = 'online';

-----------------------------------------------
again i am sorry if i confused you somehow the first time :)
and i also found my javascript had an error in it but i have copied and pasted my working code for it here and it should work on geocities.com

goodluck

-Patrick
Back to top View user's profile Send private message Send e-mail AIM Address
Melinga
-


Joined: 30 Aug 2002
Posts: 5

PostPosted: Sat Aug 31, 2002 11:02 am    Post subject: Still Confused?? Reply with quote

If you have 'http://your-ip-address-here' it isn't going to work because my ip address changes all the time? I have gotten hold of a PHP script that seems to work but having a bit of a problem changing the IP. What happens is you call this php script, it writes either online or offline. I can send it to you if you like to see what you think?
Back to top View user's profile Send private message
J. Patrick
-


Joined: 26 Aug 2002
Posts: 42
Location: Pittsburgh, PA USA

PostPosted: Sat Aug 31, 2002 5:49 pm    Post subject: Reply with quote

ok there is a simple way to fix this.

http://dyndns.org

you can signup for an address like you.homeip.net or one of many others.

all you do is signup for the Dynamic DNS service not static IP they clearly show which is which in the control panel.

when u have your address (you.whatever.com) you can download a program they have that whenever you connect to the internet or reboot your computer it sends your IP to their server and changes it if your IP changed.
So then your IP will always be correct and instead of putting your IP address in the script above put your new address (you.whetever.com).

Also in your address you can directly access files such as your-ip/picture.gif
can be found at you.whatever.com/picture.gif same goes for directories.

I have never used this service but heard it works great for people who don't have static IP's
Back to top View user's profile Send private message Send e-mail AIM Address
DLashley
-


Joined: 18 Dec 2002
Posts: 207
Location: New York, NY

PostPosted: Thu Dec 19, 2002 6:12 am    Post subject: Reply with quote

Well, if it's going to work - the "server_status.js" file would have to go in the "htdocs" folder (or a subfolder of that folder), so the "your-ip-address-here/" part should be the web URL which points to that file instead, right?

I signed up for a free Dynamic DNS account with http://no-ip.com - got myself a URL (http://myname.no-ip.com) , which points to my IP# (dynamic), and brings up my web page. If you do that, and use that URL instead - it should work. :)
_________________
DLashley
Back to top View user's profile Send private message Visit poster's website
DLashley
-


Joined: 18 Dec 2002
Posts: 207
Location: New York, NY

PostPosted: Wed Mar 03, 2004 4:15 am    Post subject: Re: Doesn't work Reply with quote

Melinga wrote:
This sounds like a good script but it doesn't work. Where it says url to the script I would still have to put the current IP address in wouldn't I? Otherwise how does it find the script? Also tried it out using the IP but nothing shows up on the screen. :cry:


I have it working with Dynamic DNS and URL Forwarding/Cloaking!!!
Looky here: http://radioactiveonline.tk/

I have URL Forwarding (with Cloaking) from http://www.dot.tk/ pointing to my free home page (comes with Earthlink ISP) located at http://home.mindspring.com/~dlashley/ - where I have the "index.html" file uploaded. The JS on the "index.html" page points to my Dynamic DNS URL: http://radioactiveonline.tk (on my server), and looks for "server_status.js". If I'm offline, it sends me back to http://home.mindspring.com/~dlashley/ but if I'm online, it sends me to http://radioactiveonline.no-ip.com/ (all URL's are cloaked by the "http://radioactiveonline.tk" URL, so you only ever see "http://radioactiveonline.tk" in the browser address line). Cool, huh? 8)

It works fine, but I hate the banner popup that dot.tk has. Need to find a URL Forwarding/Cloaking URL that is banner free (if that's possible).

Great script/tutorial! Thanks so much! :D


P.S. All of this is running on my laptop with FireDaemon running Abyss Web Server as a service. My desktop PC is running another domain, but I have it turned off at the moment.
_________________
DLashley
Back to top View user's profile Send private message Visit poster's website
DLashley
-


Joined: 18 Dec 2002
Posts: 207
Location: New York, NY

PostPosted: Wed Mar 03, 2004 6:18 am    Post subject: Reply with quote

YAY! Found a way to remove the dot.tk banner! Did a search on http://www.google.com, and found out how to disable the banner:

1) Login to your mydot.tk account on dot.tk
2) Click on "Dot TK Linker Promo" under "My Marketing" on the left side of the screen.
3) Click continue at the bottom
4) Select the "no banner" radio button
5) Click continue at the bottom

That's all! IT WORKS!!! :D

Got this info here
_________________
DLashley
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Networking Issues All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group