G’Day everyone!
Well, I’ve returned back here to the guru’s to ask for wisdom yet again. I’m having a weird problem trying to get some of my PHP scripts to play nice with a PHP proxy script that followed me home one day. And when I say weird, I mean like
- :huh: WEirD :crazy: - type weird.
OK, so this is the situation:
I have one proxy I downloaded from a site.[INDENT]LINK.
[/INDENT]It’s a pretty good proxy script actually, I haven’t had any problems with it except this small problem. So if your looking for a PHP proxy script try this one. It’s good as long as you don’t ‘tinker with it’ too much.
And here is a script I wrote which I use to manage my protection on each page of my site which I want to be a username&password only section:
Please excuse the poor quality of this php code, I’m still just a beginning at PHP trying to learn how it works, if you makes you feel better there is no actually sensitive information on my site being hidden by this script.[INDENT]** protect.php**
[/INDENT]
<?php
$user = $_COOKIE['user'];
$pass = $_COOKIE['pass'];
$link = mysql_connect('localhost', '*-username removed for security-*', '*-password removed for security-*', 'useraccounts');
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('useraccounts', $link);
if (!$db_selected)
{
die ('Can\'t use foo : ' . mysql_error());
}
$sql = "SELECT * FROM `useraccounts` WHERE username = '$user' LIMIT 10";
$result = mysql_query($sql,$link);
if(mysql_num_rows($result)==1)
{
$sql = "SELECT * FROM `useraccounts` WHERE username = '$user' AND pass = '$pass' LIMIT 10";
$result = mysql_query($sql,$link);
if(mysql_num_rows($result)==1)
{
}
if(mysql_num_rows($result)==0)
{
header('Location: ../mainpage.htm');
}
}
else
{
if(mysql_num_rows($result)==0)
{
header('Location: ../mainpage.htm');
}
if(mysql_num_rows($result)>1)
{
header('Location: ../mainpage.htm');
}
}
?>
Now, what I usually do when I want a page to be protected is just type
include '*-directory-*/protect.php'
at the top of any .php page. But this won’t work on the page of the proxy. For some reason unbeknownst to me, when the protect.php script is put at the top of the proxy script (the index.php file in the zip), the code at the top of my protect script which gets the stored user and password information put there when someone logins - doesn’t work!!!:puzzled: The actual function $_COOKIE[‘something’] doesn’t work, it returns instead of say ‘admin’, just ‘’… nothing.
$user = $_COOKIE['user'];
$pass = $_COOKIE['pass'];
// All four of these $user, $pass, $_COOKIE['user'], $_COOKIE['pass'] return a value of
nothing, even though the same script when run on the same computer at the same
time just included on a different page, will return the value stored in these cookies.
So please everyone! Any advice, words of wisdom, random thought waves, conceptual ideas and theorized solutions, you might have. DO TELL!
Because as some say: I’m up a creek, without a paddle
or as they say around these parts: I’M F***! (It’s a little more commonly used in Australia then the other one^).
Again any help would be appreciated.