Hi all. This is a rather mystifying, major problem, that I'm hoping someone can help with. Here's the situation.
I'm about ready (or so I thought) to launch a web application I built (a student job board), and it's working perfectly from my office. HOWEVER, whenever I try to login from home, the login, and any page which makes a db call, takes at least 3 minutes to execute!!!!! On campus, it works just as I'd expect, but off campus it's horrible.
Here's the code which is being executed on the login page. The functions being called from the auth class I use are in the attached file, auth.txt.
I'm using ADOdb for connecting to the database.
include_once("_classes/authentication/auth.inc.php");
$auth = new Auth;
$auth->checkDomain($SERVER_NAME);
if ($auth->doLogin($username,$password,"postgres") == true) {
session_start();
session_register("sess_allow");
$sess_allow = "true";
session_register("sess_user_id");
$sess_user_id = $auth->usr_info['user_id'];
session_register("sess_user");
$sess_user = $auth->usr_info['username'];
session_register("sess_email");
$sess_email = $auth->usr_info['email'];
session_register("sess_user_type");
$sess_user_type = $auth->usr_info['type'];
session_register("sess_clearance");
$sess_clearance = $auth->usr_info['clearance'];
header("Location:select_app.php");
} else {
die("Illegal call");
}
When the page is loaded first (ie. the login form comes up) it's fine. But when I submit, it takes at least 3 minutes to process.
I set up two tests, whereby I mimicked the query from the login page on a test page. The difference between the two is in test_1.php I have set $conn->debug = 1 and in test_2.php I've not set $conn->debug at all.
The following is the code being executed in both files (with the exception of the $conn->debug difference noted above) when the form is submitted:
include_once("classes/adodb/adodb.inc.php"); // load code common to ADOdb
include_once("classes/adodb/def_files/srv_def.inc.php"); // load server name definition
include_once("classes/adodb/def_files/pg.inc.php"); // load db type definition
include_once("classes/adodb/def_files/db_name.inc.php"); // load db name definition
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; // set ADOdb fetch mode
define ("webapps_user","*****"); // define username to query user info tables
define ("webapps_pass","*****"); // define password to query user info tables
$conn->debug = 1; // this is 1 in test_1.php and not set at all in test_2.php
$conn = &ADONewConnection(db_type); // create adodb connection class and database type
$conn->PConnect (db_server,webapps_user,webapps_pass,db_name);
define ("username",trim($username)); // define user username
define ("password",trim($password)); // define user password
$rs = $conn->Execute("select u.user_id, u.username, u.email, u.clearance, ut.type from users u, user_types ut where u.username = '".username."' and u.password = '".password."' and u.clearance = ut.clearance");
if ($rs->RecordCount() == 1) {
session_start();
session_register("sess_allow");
$sess_allow = "true";
session_register("sess_user_id");
$sess_user_id = $rs->fields['user_id'];
session_register("sess_user");
$sess_user = $rs->fields['username'];
session_register("sess_email");
$sess_email = $rs->fields['email'];
session_register("sess_user_type");
$sess_user_type = $rs->fields['type'];
session_register("sess_clearance");
$sess_clearance = $rs->fields['clearance'];
echo $sess_user." logged in!";
} else {
die("invalid login");
}
So, in these two examples since using or not using conn->$debug=1 seems to make the difference, I assumed this was the problem with the login script, but I've opened up every single file that is involved in the login, and $conn->debug=1 is always commented out.
However, that said, I find it very strange that it works just fine on campus, but horribly off-campus. That would seem to indicate to me that it could be something with the way that the server the database resides on is, or is not, accepting connections from outside the university's network.
However that said, if that that were the case it would make sense that setting or not setting $conn->debug = 1 in test_1.php and test_2.php wouldn't make a lick of difference, and both would be miserably slow in executing their database calls.
Does anyone have any idea what might be causing this? I'm desparate and really hoping someone can offer some insight.
Additionally, I just decided to see if I could access the database through phpPgAdmin, and while I can click on the database name and get the full list of tables, and then click on "browse" or "select" the queries execute no problem, however if I click on "properties" for a table, or click on that table name in the menu at the left, both which would bring up the properties of said table, the query takes a very long time to execute. Again, on campus this all works fine. Thought this might provide some additional info.
Thanks,
Pablo