Click to See Complete Forum and Search --> : Script Help!


Jick
08-07-2003, 10:23 AM
I did a search on the forums and on the internet and found nothing for what I'm looking for. I want a script that will allow just me to login with my pass and then on my pages I could have some sort of include or something so it would show my online status. So I would login with my pass and then on my pages is would change from offline to online. When ever I'm not logged in it shows offline and when ever I am logged in it shows online. I think it would also need to have sessions so it would keep me loged in. I would also need a logout button. Is this possible? If so is there anybody that would be willing to help me do this? I don't have any money other wise I would pay someone to help me do it! Thanks. :)

brendandonhue
08-08-2003, 07:57 AM
Does it have to use sessions? It could be done with cookies or flatfile. Are you building a new script for the login and everything, or are you using an already existing one (such as Pyro's)?

Jick
08-08-2003, 08:35 AM
I'll probably try to impliment Pyro's so I don't have to build my own which could take quite a while considering my intelligence level when it comes to PHP! Lol... :p

In response to your sessions question. No. It dosn't have to use them. I'm willing to do it whatever way would be eaiser. The only resin I'm doing the login part in the first place is because I'm under the impression that you would have to do it that way other wise the server would never be accurate about my status since I have a dinamic IP address which would not allow for it to just say I'm online if my IP comes to that page. I would greatly appreciate any help. :D

brendandonhue
08-08-2003, 08:41 AM
Untested code but something like this might work with Pyro's script
<?php
$Offline = "Currently Offline";
$Online = "Currently Online";
if (!isset($verified)) { die($Offline); }
if (!$verified) { die($Offline); }
else {echo $Online; }
?>

Jick
08-09-2003, 02:01 AM
Ok, assuming that the script brendandonhue gave me goes in the "passwordreader.php" file of Pyro's code, where do I put it in there? Something like this:
<?PHP
$user = 'yourencryptedusername';
$pass = 'yourencryptedpassword';
$offline = "Currently Offline";
$online = "Currently Online";

if(md5($_POST['username']) == $user && md5($_POST['password']) == $pass)
{
setcookie ("verified", true);
header ("Location:http://www.yoursite.com/dir/page.htm");
}
else
{
echo ("Incorrect Password");
}
if (!isset($verified)) { die($offline); }
if (!$verified) { die($offline); }
else
{
echo $online;
}
?>
Let me know if it's wrong and how to fix it and also if I even have it in the right file! :p

Jick
08-09-2003, 11:25 AM
I really need help with this. I just need to know if it's in the right file and if I put it in there right. Just look at my last post. :(

brendandonhue
08-09-2003, 01:07 PM
You can put it on any page you want, it should show your online status. Anywhere within your domain anyway.

Jick
08-09-2003, 01:21 PM
Ohh so I could put it in a file of it's own and as long as it's in the same dir as the login script it should work? Thats all I would need and then I could put an include on the pages I want to display it on?

brendandonhue
08-09-2003, 03:59 PM
Assuming there are no errors in my script, then yes you could do that.

Jick
08-10-2003, 01:22 PM
Ok, I had some help from one of my freinds. I got it working exactally how I want it to. You can try it out here:

http://kd7pyo.infinitypages.com/status/

Enter test/test for the username and password. As you can see it works fine. One thing I noticed is if you enter a custom status message with quotes or apostrifys it will put slashes like this:

"/test/"
don/'t

I'm not sure what is wrong. Can someone go and look and see whats wrong? This birthday boy would greatly appreciate it! :D

Here is my (process.php) file that takes and outputs the custom message if you enter one:
<?
IF ($user == "")
{
echo "The (<b>Username</b>) feild needs to be filled in.<br><a title='Go Back' href='http://kd7pyo.infinitypages.com/status/'>Go Back</a>";
exit;
}
IF ($pass == "")
{
echo "The (<b>Password</b>) feild needs to be filled in.<br><a title='Go Back' href='http://kd7pyo.infinitypages.com/status/'>Go Back</a>";
exit;
}
IF ($stat == "Custom" and $customtext == "")
{
echo "The (<b>Custom</b>) feild needs to be filled in.<br><a title='Go Back' href='http://kd7pyo.infinitypages.com/status/'>Go Back</a>";
exit;
}
IF ($stat == "Custom")
{
$stat = $customtext;
}
IF ($user == "test" and $pass == "test")
{
echo "Your status has been changed to: (<b>$stat</b>).<br><a title='Go Back' href='http://kd7pyo.infinitypages.com/status/'>Go Back</a>";
$openit = fopen("status.txt", "w");
fwrite($openit, "$stat");
}
else
{
echo "Sorry, you have entered a wrong username and/or password.<br><a title='Go Back' href='http://kd7pyo.infinitypages.com/status/'>Go Back</a>";
}
?>

pyro
08-10-2003, 05:20 PM
Look into stripslashes() (http://forums.webdeveloper.com/showthread.php?s=&threadid=11768&highlight=password)