Click to See Complete Forum and Search --> : help modifying mjdimick's script so that.....


sciguyryan
09-12-2003, 02:51 PM
on refresh it checks the ip of the user and, depending on weather the ip has changed or not it leaves it alone if it is the same and changes it if is not.

heres the ciode i have been given by mjdimick(please note it's not for me it's for the under 12's website discussed on the general forum a while back...)

<?PHP
$user = $_POST['user'];
$pass = $_POST['pass'];
$stat = $_POST['stat'];
$customtext = $_POST['customtext'];

if ((empty($user)) || (empty($pass)) || (empty($stat))) {
echo "All fields must be filled in.<br><a title='Go Back' href='login.php'>Go Back</a>";
exit;
}
if ($stat == "Custom") {
$stat = "$customtext";
}
else {
$stat = "$stat";
}
if (($user == "yourusernamehere") and ($pass == "yourpasswordhere")) {
echo "Your status has been changed to: (<b>$stat</b>).<br><a title='Go Back' href='login.php'>Go Back</a>";
$openit = fopen("status.txt", "w");
flock ($openit, LOCK_EX); #lock the file
fwrite($openit, "$stat");
flock($openit, LOCK_UN); #release the file
}
else {
echo "Sorry, you have entered a wrong username and/or password.<br><a title='Go Back' href='login.php'>Go Back</a>";
}
?>


if you could modify this we at the development site would be most greatfull.

thanks in advance.

pyro
09-12-2003, 03:23 PM
<insert people taking credit for other people work (http://forums.webdeveloper.com/showthread.php?s=&threadid=16853#post88251) rant here>

You are going to need to explain what you need a bit better, please... Not sure what it is that you want the script to do...

sciguyryan
09-12-2003, 04:17 PM
0k sorry,

you and mjdimick wrote this script a while ago. at the moment it displays your status the problem is that once your ip changes it will not work. now to my question.... how could we make it so that the ip in the php changes when the users changes. i'm not even sure that is possible but, if it is could you alter the code for me?

thanks in advance.

AdamGundry
09-12-2003, 04:22 PM
As far as I can see, there is no IP address in the PHP code. It simply updates status whenever you login to it, regardless of what your IP address is.

Adam

P.S. I know this was discussed in the dev site, I guess I should have responded sooner.

pyro
09-12-2003, 04:48 PM
As Adam pointed out, this script has nothing to do with IP addresses. It simply allows a user to change their status, ie whether it says they are online, offline or a custom status.

Jick
09-12-2003, 11:25 PM
What Sciguyryan is trying to say is, we were trying to modify this script so you don't have to login so all you have to do is just go to the page and it will read your IP and then if it matches the one in the file then it would display "Online". But my only problem with this is that it would not work with dynamic IP's (dynamic IP's are more common than static Ip's) so what we are trying to figure out is if it is possible for the script to work with dynamic Ip addresses? :D

sciguyryan
09-13-2003, 02:46 AM
but, to no effect.... as you can probably see....:D

pyro
09-13-2003, 09:44 AM
Yeah, you are probably going to want to use cookies (http://us2.php.net/manual/en/function.setcookie.php) for this, rather than the IP addresses, as with dynamic IP's, you'd have to use an IP block, which would mean that a fair number of other people could trigger the script by logging on to your site.