register and login email process looping indefinitely | Newbie | | Join Date: Feb 2008
Posts: 11
| |
I'm really new to the whole networking side of things, so I don't know the backend very well. I wrote a series of PHP/AJAX scripts to allow a user to create a login account, but apparently my script is doing much much more than I imagined as I received an email from my admin this morning: Quote:
Your script located at .....Scripts/form_check.php has been moved to your account root. This script generated over 7000 emails that bounced back and forth on our server for an hour, which drive the load on this machine to inappropriate levels. Every time this script runs, it also core dumps on the server:
-rw------- 1 squeez7 squeez7 24M Mar 3 21:47 core.14811
-rw------- 1 squeez7 squeez7 24M Mar 3 21:51 core.15255
I think a core dump means my program had a fatal error, and I know my program is supposed to email me when there is an error. Granted, I was debugging the script last night, but I had no idea this was going on! Especially as my mailing code is the same code I have used before without issue.
I'm scared to run this code again even to test it, but I've been over it a million times, and I still have no clue what is causing this.
I would really appreciate any help!!!
List of scripts: - ajax.js
- form_check.php
- UsrDB.php
- BasicDB.php
Here are my scripts:
ajax.js -
/**********************************
-
Filename: ajax.js
-
Date: 02.25.08
-
**********************************/
-
-
/***** CREATE XMLHTTP OBJECT *****/
-
function request() {
-
var browser = navigator.appName; // get browser
-
var req = false;
-
if(browser == "Microsoft Internet Explorer") { // IE
-
try {
-
req = new ActiveXObject("Msm12.XMLHTTP"); // -- Msm12
-
} catch(err1) {
-
try {
-
req = new ActiveXObject("Microsoft.XMLHTTP"); // -- Microsoft
-
} catch(err2) {
-
req = false; // FAIL!
-
}
-
}
-
} else {
-
try {
-
req = new XMLHttpRequest(); // not IE
-
} catch(err) {
-
req = false;
-
}
-
}
-
-
return req;
-
}
-
-
var http = request(); // CREATE XMLHTTP object
-
-
var obj; // other variables
-
var obj2;
-
var url;
-
-
/***** SEND AJAX REQUEST *******/
-
function send_post(params,use) {
-
http.open("POST", url, true);
-
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
-
http.setRequestHeader("Content-length", params.length);
-
http.setRequestHeader("Connection", "close");
-
http.onreadystatechange = eval(use);
-
http.send(params);
-
}
-
-
/********************************************************************************
-
***** USE FUNCTIONS *************************************************************
-
********************************************************************************/
-
-
/***** FORM *****/
-
function form_response() {
-
var vobj = "v"+obj;
-
if(http.readyState == 4) {
-
if(http.status == 200) {
-
var data = http.responseText.split(",");
-
if(data[0] == 2) { // no data -- do nothing
-
} else if(data[0] == 0) { // good data -- show check
-
document.getElementById(vobj).innerHTML = "<img class=\"form_img\" src=\"../images/yes.png\"/>";
-
} else { // bad data -- show x and response
-
document.getElementById(vobj).innerHTML = data[1]+" <img class=\"form_img\" src=\"../images/no.png\"/>";
-
}
-
} else {
-
document.getElementById(vobj).innerHTML = "No server response.";
-
//document.getElementsByName(obj)[0].className = "maybe";
-
}
-
} else {
-
document.getElementById(vobj).innerHTML = 'Checking...';
-
//document.getElementsByName(obj)[0].className = "maybe";
-
}
-
}
-
-
/***** REGISTER *****/
-
function register_response() {
-
obj = 'message'; // set div id
-
var msg = '';
-
if(http.readyState == 4) {
-
if(http.status == 200) {
-
var data = http.responseText;
-
document.getElementById(obj).innerHTML = data;
-
} else {
-
document.getElementById(obj).innerHTML = "Unable to complete request.";
-
}
-
} else {
-
document.getElementById(obj).innerHTML = "Working";
-
}
-
}
-
-
-
/********************************************************************************
-
***** CHECK FUNCTIONS ***********************************************************
-
********************************************************************************/
-
-
/* EMAIL */
-
function check_email() {
-
url = "../Scripts/form_check.php";
-
obj = "email";
-
if(document.getElementsByName(obj)[0].value != '') {
-
var params = "object="+obj+"&data="+document.getElementsByName(obj)[0].value;
-
send_post(params,"form_response"); }
-
}
-
-
/* USR */
-
function check_usr() {
-
url = "../Scripts/form_check.php";
-
obj = "usr";
-
if(document.getElementsByName(obj)[0].value != '') {
-
var params = "object="+obj+"&data="+document.getElementsByName(obj)[0].value;
-
send_post(params,"form_response"); }
-
}
-
-
/* FIRST */
-
function check_first() {
-
url = "../Scripts/form_check.php";
-
obj = "first";
-
if(document.getElementsByName(obj)[0].value != '') {
-
var params = "object="+obj+"&data="+document.getElementsByName(obj)[0].value;
-
send_post(params,"form_response"); }
-
}
-
-
/* LAST */
-
function check_last() {
-
url = "../Scripts/form_check.php";
-
obj = "last";
-
if(document.getElementsByName(obj)[0].value != '') {
-
var params = "object="+obj+"&data="+document.getElementsByName(obj)[0].value;
-
send_post(params,"form_response"); }
-
}
-
-
/* PASSWORD */
-
function check_password() {
-
url = "../Scripts/form_check.php";
-
obj = "password";
-
if(document.getElementsByName(obj)[0].value != '') {
-
var params = "object="+obj+"&data="+document.getElementsByName(obj)[0].value;
-
send_post(params,"form_response"); }
-
}
-
function check_confirm() {
-
url = "../Scripts/form_check.php";
-
obj = "confirm";
-
obj2 = "password";
-
if(document.getElementsByName(obj)[0].value != '') {
-
var params = "object="+obj+"&data="+document.getElementsByName(obj)[0].value+
-
"&data2="+document.getElementsByName(obj2)[0].value;
-
send_post(params,"form_response"); }
-
}
-
-
/* REGISTER */
-
function register() {
-
url = "../Scripts/register.php";
-
-
if(document.getElementsByName('usr')[0].value != 0 &&
-
document.getElementsByName('email')[0].value != 0 &&
-
document.getElementsByName('first')[0].value != 0 &&
-
document.getElementsByName('last')[0].value != 0) {
-
params = "usr="+document.getElementsByName('usr')[0].value+
-
"&email="+document.getElementsByName('email')[0].value+
-
"&first="+document.getElementsByName('first')[0].value+
-
"&last="+document.getElementsByName('last')[0].value;
-
send_post(params,"register_response");
-
}
-
}
-
-
/* LOGIN */
-
function login() {
-
url = "../Scripts/login.php";
-
-
if(document.getElementsByName('name')[0].value != 0 &&
-
document.getElementsByName('password')[0].value != 0) {
-
params = "name="+document.getElementsByName('name')[0].value+
-
"&password="+document.getElementsByName('password')[0].value;
-
-
send_post(params,"register_response");
-
}
-
}
-
form_check.php -
<?php
-
-
/**********************************
-
Filename: form_check.php
-
Date: 02.25.08
-
**********************************/
-
-
require_once("../Classes/Sys.php");
-
require_once("../Classes/Usr.php");
-
require_once("../Classes/UsrDB.php");
-
-
session_start();
-
header("Cache-control: private");
-
-
$db = new UsrDB($_SESSION['sys'],$_SESSION['usr']);
-
-
$return = "1,Invalid data";
-
-
if($_POST['data'] == '') {
-
echo "2,No data";
-
}
-
-
switch($_POST['object']) {
-
case "usr":
-
if($db->verify_usr($_POST['data'])) {
-
$return = "1,Existing user name"; }
-
else {
-
$return = "0,Available user name"; }
-
break;
-
case "email":
-
$find = "/[\w\d\_\-\.]*\@[\w\d\_\-\.]*\.(com|edu|gov|net|co)/";
-
if(!preg_match($find,$_POST['data'])) {
-
$return = "1,Invalid email"; }
-
else {
-
if($db->verify_email($_POST['data'])) {
-
$return = "1,Existing email"; }
-
else {
-
$return = "0,Available email"; }
-
}
-
break;
-
case "first":
-
case "last":
-
$find = "/[^a-zA-Z]/";
-
if(preg_match($find,$_POST['data'])) {
-
$return = "1,Invalid string"; }
-
else {
-
$return = "0,Valid string"; }
-
break;
-
case "password":
-
$find = "/\s/";
-
if(preg_match($find,$_POST['data'])) {
-
$return = "1,Invalid password"; }
-
else {
-
$return = "0,Valid password"; }
-
break;
-
case "confirm":
-
if($_POST['data'] == $_POST['data2']) {
-
$return = "0,Passwords match"; }
-
else {
-
$return = "1,Passwords don't match"; }
-
break;
-
default:
-
break;
-
}
-
-
echo $return;
-
-
?>
-
I'll have to put the last two files in the following post.
| | Newbie | | Join Date: Feb 2008
Posts: 11
| | | re: register and login email process looping indefinitely
Here's UsrDB.php -
<?php
-
-
/**********************************
-
Filename: UsrDB.php
-
Date: 02.25.08
-
**********************************/
-
-
require_once('BasicDB.php');
-
-
class UsrDB extends BasicDB {
-
-
/* CLASS VARIABLES */
-
protected $group; // denotes project & permissions set
-
private $system; // instance of the system class
-
private $user; // instance of the user class
-
private $webmaster; // email to send error messages to
-
private $date; // date
-
private $day; // day
-
private $time; // time
-
-
/* PUBLIC FUNCTIONS */
-
-
/***********************************************************************
-
***** CONSTRUCTOR & DESTRUCTOR *****************************************
-
***********************************************************************/
-
-
/***********************************************************************
-
Constructor
-
input: instance of the system and user classes
-
output: none */
-
public function __construct($sys,$usr) {
-
$this->system = $sys; // System class
-
$this->user = $usr; // Usr class
-
$this->group = $this->system->group(); // GET system group
-
$this->day = date("Y:m:d");
-
$this->time = date("H:i:s");
-
$this->date = $day."::".$time;
-
$this->webmaster = "webmaster@------.com";
-
} // END Constructor
-
-
public function __destruct() { }
-
-
-
/***********************************************************************
-
***** ERROR HANDLING FUNCTIONS *****************************************
-
***********************************************************************/
-
-
/***********************************************************************
-
Write_log($m)
-
input: instruction (Error,LogIN,LogOUT,etc.), and message
-
output: TRUE / FALSE
-
*/
-
public function write_log($instruction,&$msg) {
-
/* LOG MESSAGE QUERY */
-
$query = sprintf("INSERT INTO log (ses_id, log_date, log_time, log_msg, log_instruction)
-
VALUES ( '%s', '%s', '%s', '%s', '%s' )", // CREATE mysql query
-
$this->system->id(),
-
$this->day,
-
$this->time,
-
$msg,
-
$instruction);
-
if(!$this->insert($query)) { // IF our query has errors
-
$to = $this->webmaster;
-
$subj = "[".$this->group."] Error";
-
$msg = "Function: write_log\n".
-
"Problem: Unable to write to database\n".
-
"Date: ".$this->date."\n".
-
"User: ".$this->user->name();
-
$from = "From: ".$this->webmaster;
-
mail($to,$subj,$msg,$from); // --NOTIFY the webmaster
-
return false; // --RETURN FALSE
-
}
-
-
return true; // RETURN true
-
} // END log_err
-
-
-
/***********************************************************************
-
***** USRDB METHODS ****************************************************
-
***********************************************************************/
-
-
/***login removed for space */
-
-
/***********************************************************************
-
logout()
-
input: none
-
output: none
-
result: */
-
public function logout() {
-
$this->system->__destruct(); // KILL system instance
-
unset($this->system); // UNSET system instance
-
$this->write_log("Log","OUT ".$this->user->name()); // LOG log out
-
} // END logout
-
-
/***********************************************************************
-
register()
-
input: array of user name, first & last name, and email
-
output: true if success, false if fail */
-
public function register($input_array) {
-
$usr = $this->mysql_safe($input_array['usr']); // SECURE user input
-
$first = $this->mysql_safe($input_array['first']);
-
$last = $this->mysql_safe($input_array['last']);
-
$email = $this->mysql_safe($input_array['email']);
-
$msg = '';
-
$row;
-
-
$query = sprintf("INSERT INTO usr (usr_name,usr_fname,usr_lname,usr_email)
-
VALUES (%s,%s,%s,%s)", // QUERY add user
-
$usr,
-
$first,
-
$last,
-
$email);
-
if(!$this->insert($query)) { return false; } // RUN query, FALSE if bad
-
-
$query = sprintf("SELECT usr_id FROM usr WHERE usr_name = %s",$usr); // QUERY get user id
-
if(!($row = $this->select($query))) { return false; } // RUN query, FALSE if bad
-
$id = $row['usr_id']; // SAVE user id
-
-
$password = $this->random_password(); // CREATE random password
-
$query = sprintf("INSERT INTO pswd (p_pswd,usr_id) VALUES ('%s',%d)", // QUERY add encrypted password
-
sha1($password),
-
$id);
-
if(!$this->insert($query)) { return false; } // RUN query, FALSE if bad
-
-
$query = sprintf("INSERT INTO usr_grp (usr_id,usrg_grp,usrg_rank) ". // QUERY insert user into group
-
"VALUES (%d,'%s',%d)",
-
$id,
-
$this->group,
-
1);
-
if(!$this->insert($query)) { return false; } // RUN query, FALSE if bad
-
-
$query = sprintf("INSERT INTO usr_meta (usr_id) VALUES (%d)", // QUERY add user row in meta table
-
$id);
-
if(!$this->insert($query)) { return false; } // RUN query, FALSE if bad
-
-
$this->welcome($email,$usr,$password); // SEND welcome email with password
-
$this->write_log("Register",$usr); // LOG register
-
-
return true;
-
} // END register
-
-
/***********************************************************************
-
session()
-
input: none
-
output: TRUE / FALSE */
-
public function session() {
-
if(!$this->system->verify_id() || !$this->system->verify_ip()) { // IF we still have the same creds
-
$this->logout(); // --LOGOUT
-
return false; } // --RETURN false
-
-
// Add session to database
-
$query = sprintf("INSERT INTO session (usr_id,ses_grp,ses_ip,ses_addr,ses_php,ses_date,ses_time)
-
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s' )", // QUERY add session data
-
$this->user->id(),
-
$this->group,
-
$this->system->ip(),
-
$this->system->addr(),
-
$this->system->id(),
-
$this->day,
-
$this->time);
-
if(!$this->insert($query)) { return false; } // RUN query, FALSE if bad
-
return true; // RETURN true
-
} // END session
-
-
/***********************************************************************
-
welcome
-
input: email, user name, password
-
output: welcome email and password email */
-
public function welcome($email,$usr,$password) {
-
$to = $email;
-
$subj = "Welcome to ".$this->group;
-
$from = "From: ".$this->webmaster;
-
$msg = "
-
Dear $usr,
-
***nice message here ***
-
-
";
-
mail($to,$subj,$msg,$from); // SEND welcome email
-
mail($to,$subj,$password,$from); // SEND password email
-
return true; // RETURN true
-
} // END welcome
-
-
-
/***********************************************************************
-
***** VERIFY FUNCTIONS *************************************************
-
***********************************************************************/
-
-
/***********************************************************************
-
verify_email
-
input: email
-
output: true | false */
-
public function verify_email($email) {
-
$email = $this->mysql_safe($email); // SECURE user input
-
$query = sprintf("SELECT usr_id FROM usr WHERE usr_email = %s", // QUERY check if email is in database
-
$email);
-
if(!($row = $this->select($query))) { return false; } // RUN query, FALSE if not
-
else { return true; } // TRUE if it is
-
}
-
-
/***********************************************************************
-
verify_usr
-
input: user name
-
output: true | false */
-
public function verify_usr($usr) {
-
$usr = $this->mysql_safe($usr); // SECURE user input
-
$query = sprintf("SELECT usr_id FROM usr WHERE usr_name = %s", // QUERY check if user name is in database
-
$usr);
-
if(!($row = $this->select($query))) { return false; } // RUN query, FALSE if not
-
else { return true; } // TRUE if it is
-
}
-
-
/***********************************************************************
-
***** UPDATE FUNCTIONS *************************************************
-
***********************************************************************/
-
-
// removed for space
-
-
/***********************************************************************
-
***** GET FUNCTIONS ****************************************************
-
***********************************************************************/
-
-
/***********************************************************************
-
get_list()
-
input: desired attribute, minimum rank (opt)
-
output: array of user names */
-
public function get_user_list() { return $this->get_list("usr_name"); } // ALIAS for get_list USER
-
public function get_email_list() { return $this->get_list("usr_email"); } // ALIAS for get_list EMAIL
-
public function get_list() {
-
$val = func_get_arg(0); // SAVE desired attribute
-
if(func_num_args() == 2) { // IF more input
-
$min_rank = func_get_arg(1); } // --SAVE desired rank
-
else { $min_rank = 1; } // ELSE get all ranks
-
$query = sprintf("SELECT %s FROM usr WHERE usr_rank >= %d", // QUERY get all rows
-
$val,
-
$min_rank);
-
if(!($list = $this->select_simple_list($query))) { return false; } // SAVE rows as a array, FALSE on fail
-
return $list; // RETURN array
-
} // END get_list
-
-
/***********************************************************************
-
random_password()
-
input: none
-
output: password generated */
-
public function random_password() {
-
// CREATE character arrays
-
$letters = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
-
$numbers = array('1','2','3','4','5','6','7','8','9','0');
-
$symbols = array('!','@','#','$','%','^','&','*','(',')','<','>','.','?','/',':','{ ','} ',',','.','; ','|','+','=','~');
-
$length = 10;
-
$password = '';
-
-
for($i = 0; $i <= $length; $i++) { // LOOP for given length
-
$set = mt_rand(0,2); // CHOOSE which array to use
-
if($set == 0) { // IF letters
-
$char = mt_rand(1,count($letters)); // --GENERATE a random value
-
$char--; // --DECREMENT (to fit in array index)
-
$password .= $letters[$char]; // --ADD to password
-
} else if($set == 1) { // IF numbers
-
$char = mt_rand(1,count($numbers)); // --see above
-
$char--;
-
$password .= $numbers[$char];
-
} else if($set == 2) { // IF symbols
-
$char = mt_rand(1,count($symbols)); // -- see above
-
$char--;
-
$password .= $symbols[$char];
-
} else { }
-
}
-
-
return $password; // RETURN password
-
} // END random_password
-
-
} // END CLASS
-
-
?>
-
| | Newbie | | Join Date: Feb 2008
Posts: 11
| | | re: register and login email process looping indefinitely
BasicDB.php -
<?php
-
-
/**********************************
-
Filename: BasicDB.php
-
Date: 02.25.08
-
**********************************/
-
-
class BasicDB {
-
-
/* CLASS VARIABLES */
-
private $date; // Date in Y:m:d::H:i:s form
-
private $day; // Day in Y:m:d form
-
private $system; // instance of the system class
-
private $time; // Time in H:i:s form
-
private $webmaster; // Email to send error notifications to
-
-
/* CLASS FUNCTIONS */
-
-
/***********************************************************************
-
***** CONSTRUCTOR & DESTRUCTOR *****************************************
-
***********************************************************************/
-
-
/***********************************************************************
-
Constructor
-
input: instance of the system class
-
output: none */
-
public function __construct($sys) {
-
$this->day = date("Y:m:d");
-
$this->time = date("H:i:s");
-
$this->date = $day."::".$time;
-
$this->system = $sys;
-
$this->webmaster = "webmaster@-------.com";
-
} // END Constructor
-
-
/***********************************************************************
-
***** ERROR HANDLING FUNCTIONS *****************************************
-
***********************************************************************/
-
-
/***********************************************************************
-
$this->err($msg)
-
input: error message
-
output: email to the webmaster
-
write to log */
-
public function err($msg) {
-
$to = $this->webmaster; // assign To:
-
$subj = "[".$this->group."] Error"; // assign Subject:
-
$msg .= "\n".$this->date; // assign Message:
-
$from = "From: ".$this->webmaster; // assign From:
-
mail($to,$subj,$msg,$from); // send mail
-
$this->write_log("Error",$msg); // log error
-
} // END $this->err()
-
-
/***********************************************************************
-
***** MYSQL FUNCTIONS **************************************************
-
***********************************************************************/
-
-
/***********************************************************************
-
DB_connect()
-
input: none
-
output: link resource */
-
public function db_connect() {
-
-
/* Squeeze of Lime server info*/
-
$server = "----------";
-
$usr = '----------';
-
$pswd = '----------';
-
$db = '----------';
-
-
// opening db connection
-
$link = mysql_connect($server,$usr,$pswd); // OPEN mysql connection
-
if(!$link) { // IF no connection
-
$this->err("db_connect(): Unable to connect to db."); // --REPORT error
-
return false; // --RETURN false
-
} else { } // ELSE continue
-
-
$dbselect = mysql_select_db($db, $link); // SELECT database
-
if(!$dbselect) { // IF no selection
-
$this->err("db_connect(): Unable to select db."); // --REPORT error
-
return false; // --RETURN false
-
} else { } // ELSE continue
-
-
return $link; // RETURN link resource
-
} // END db_connect()
-
-
-
/***********************************************************************
-
insert
-
input: mysql query string (insert, delete, or update)
-
output: query result (false on fail, true on success) */
-
public function insert($query) {
-
return $this->result($query,1,0); // CALL result function
-
}
-
-
/***********************************************************************
-
select
-
input: mysql query string (select)
-
output: query result (false on fail, single result on success) */
-
public function select($query) {
-
return $this->result($query,0,0); // CALL result function
-
} // END select
-
-
/***********************************************************************
-
select_simple_list
-
input: mysql query string (select)
-
output: query result (false on fail, array of single field on success) */
-
public function select_simple_list($query) {
-
return $this->result($query,0,1); // CALL result function
-
} // END select_simple_list
-
-
/***********************************************************************
-
result
-
input: mysql query string, boolean, boolean
-
output: */
-
public function result($query,$insert,$list) {
-
$count = 0; // RESET count
-
$link = $this->db_connect(); // GET a database link
-
$data; // INITIALIZE variable
-
-
if(!$link) { // IF we still don't connect
-
$msg = "Function: check_result\n". // --CREATE error message
-
"Problem: ".mysql_error()."\n".
-
"Date: ".$this->date."\n";
-
$this->err($msg); // --REPORT error
-
$this->logout(); // --LOGOUT
-
return false; } // --RETURN FALSE
-
-
$count = 0; // RESET count
-
$result = mysql_query($query,$link); // QUERY database
-
if(!$result) { // IF no result,
-
$msg = "Function: check_result\n". // --CREATE error message
-
"Problem: ".mysql_error()."\n".
-
"Date: ".$this->date."\n".
-
"Query: $query";
-
$this->err($msg); // --REPORT error
-
$this->logout(); // --LOGOUT
-
return false; } // --RETURN FALSE
-
-
if($insert) { // IF an insert type query
-
if(mysql_affected_rows() == 0) { // --CHECK for affected rows
-
return false; } // --NONE? return false
-
$data = true; // --OTHERWISE return true
-
} else { // ELSE a select type query
-
if(mysql_num_rows($result) == 0) { // --CHECK for number of rows
-
return false; } // --NONE? return false
-
else if($list) { // --ELSE IF we want a list
-
while($row = mysql_fetch_row($result)) { // --LOOP through the rows returned
-
$data[] = $row[0]; } // --SAVE first value in array
-
} else { // --ELSE we want a single value
-
$data = mysql_fetch_assoc($result); // --SAVE the query result
-
}
-
mysql_free_result($result); // FREE the result
-
}
-
-
mysql_close($link); // CLOSE database link
-
return $data; // RETURN our query data (if good result)
-
}
-
-
-
/***********************************************************************
-
***** SAFE FUNCTIONS ***************************************************
-
***********************************************************************/
-
-
/***********************************************************************
-
Mysql_safe($val)
-
input: a string
-
output: a safe, mysql 'executable' version of the string, in quotes
-
note: (adapted from php.net) */
-
public function mysql_safe($value) {
-
$link = $this->db_connect(); // GET a database link
-
if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // IF gmqg is turned on, USE it
-
if (!is_numeric($value)) { // IF its not a number
-
$value = "\"" . mysql_real_escape_string($value,$link) . "\""; } // --ESCAPE and put in quotes
-
return $value; // --RETURN our safe string
-
} // END mysql_safe
-
-
/***********************************************************************
-
Mysql_safe_nq($val)
-
input: a string
-
output: a safe, mysql 'executable' version of the string, W/O quotes
-
note: (adapted from php.net) */
-
public function mysql_safe_nq($value) {
-
$link = $this->db_connect(); // GET a database link
-
if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // IF gmqg is turned on, USE it
-
if (!is_numeric($value)) { // IF its not a number
-
$value = mysql_real_escape_string($value,$link); } // --ESCAPE the string
-
return $value; // --RETURN our safe string
-
} // END mysql_safe
-
-
} // END CLASS
-
-
?>
-
|  | Moderator | | Join Date: Jul 2006 Location: The Netherlands
Posts: 4,139
| | | re: register and login email process looping indefinitely
I don't think you developed this package yourself, otherwise you would have some clue as to where the problem lies or could even be pinpointed.
In my opinion you downloaded this package from one of the many sites like ringsworld who provide free scripts.
Ronald
| | Newbie | | Join Date: Feb 2008
Posts: 11
| | | re: register and login email process looping indefinitely
Actually, I wrote the whole thing. This is the second version -- the first being a PHP4 version, but I now added in AJAX and the updated OOP handling in PHP (which is still not very good).
I don't know where the problem is because I don't know what would cause a core dump. And since I'm not getting the emails designed to help me debug the system, I have no idea where I'm going wrong.
What I don't understand is that I haven't really changed the emailing system (the err function in BasicDB), so I should be getting emails -- but neither my emails nor my registration emails are coming through. I did change hosts since the last working version, but I wouldn't expect that to effect why the emails are causing server issues instead of being sent out. Again, I really just don't know what is going on behind the scense. I have been all over this code, debugging it through messages returned in javascript alerts at one point =) (for the errors returned from the ajax-called php).
I am the programmer for this code, though -- I wrote every line and commented it all. The problem is I fear to test it anymore lest my admin suspend my account, I have no idea what causes a core dump, and I can't get to my debugging messages.
I would really appreciate some help if anyone has a chance.
Attached are the four files. For easier use, I deleted most of the tabs that aligned the comments (as is seen in the code pasted above). If anyone wants them, I have the files with the comments aligned on the right with tab=4 in Notepad2.
| | Newbie | | Join Date: Jan 2008
Posts: 11
| | | re: register and login email process looping indefinitely Quote:
Originally Posted by muppetjones Actually, I wrote the whole thing. This is the second version -- the first being a PHP4 version, but I now added in AJAX and the updated OOP handling in PHP (which is still not very good).
I don't know where the problem is because I don't know what would cause a core dump. And since I'm not getting the emails designed to help me debug the system, I have no idea where I'm going wrong.
What I don't understand is that I haven't really changed the emailing system (the err function in BasicDB), so I should be getting emails -- but neither my emails nor my registration emails are coming through. I did change hosts since the last working version, but I wouldn't expect that to effect why the emails are causing server issues instead of being sent out. Again, I really just don't know what is going on behind the scense. I have been all over this code, debugging it through messages returned in javascript alerts at one point =) (for the errors returned from the ajax-called php).
I am the programmer for this code, though -- I wrote every line and commented it all. The problem is I fear to test it anymore lest my admin suspend my account, I have no idea what causes a core dump, and I can't get to my debugging messages.
I would really appreciate some help if anyone has a chance.
Attached are the four files. For easier use, I deleted most of the tabs that aligned the comments (as is seen in the code pasted above). If anyone wants them, I have the files with the comments aligned on the right with tab=4 in Notepad2. I didn't see what happens to the obj after it is used - is it or could it be destroyed
or moved?
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,358 network members.
|