register and login email process looping indefinitely

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muppetjones
    New Member
    • Feb 2008
    • 11

    register and login email process looping indefinitely

    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:

    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
    [code=javascript]
    /*************** *************** ****
    Filename: ajax.js
    Date: 02.25.08
    *************** *************** ****/

    /***** CREATE XMLHTTP OBJECT *****/
    function request() {
    var browser = navigator.appNa me; // 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.XMLHT TP"); // -- 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(param s,use) {
    http.open("POST ", url, true);
    http.setRequest Header("Content-type", "applicatio n/x-www-form-urlencoded");
    http.setRequest Header("Content-length", params.length);
    http.setRequest Header("Connect ion", "close");
    http.onreadysta techange = eval(use);
    http.send(param s);
    }

    /*************** *************** *************** *************** *************** *****
    ***** USE FUNCTIONS *************** *************** *************** *************** *
    *************** *************** *************** *************** *************** *****/

    /***** FORM *****/
    function form_response() {
    var vobj = "v"+obj;
    if(http.readySt ate == 4) {
    if(http.status == 200) {
    var data = http.responseTe xt.split(",");
    if(data[0] == 2) { // no data -- do nothing
    } else if(data[0] == 0) { // good data -- show check
    document.getEle mentById(vobj). innerHTML = "<img class=\"form_im g\" src=\"../images/yes.png\"/>";
    } else { // bad data -- show x and response
    document.getEle mentById(vobj). innerHTML = data[1]+" <img class=\"form_im g\" src=\"../images/no.png\"/>";
    }
    } else {
    document.getEle mentById(vobj). innerHTML = "No server response.";
    //document.getEle mentsByName(obj )[0].className = "maybe";
    }
    } else {
    document.getEle mentById(vobj). innerHTML = 'Checking...';
    //document.getEle mentsByName(obj )[0].className = "maybe";
    }
    }

    /***** REGISTER *****/
    function register_respon se() {
    obj = 'message'; // set div id
    var msg = '';
    if(http.readySt ate == 4) {
    if(http.status == 200) {
    var data = http.responseTe xt;
    document.getEle mentById(obj).i nnerHTML = data;
    } else {
    document.getEle mentById(obj).i nnerHTML = "Unable to complete request.";
    }
    } else {
    document.getEle mentById(obj).i nnerHTML = "Working";
    }
    }


    /*************** *************** *************** *************** *************** *****
    ***** CHECK FUNCTIONS *************** *************** *************** **************
    *************** *************** *************** *************** *************** *****/

    /* EMAIL */
    function check_email() {
    url = "../Scripts/form_check.php" ;
    obj = "email";
    if(document.get ElementsByName( obj)[0].value != '') {
    var params = "object="+obj+" &data="+documen t.getElementsBy Name(obj)[0].value;
    send_post(param s,"form_respons e"); }
    }

    /* USR */
    function check_usr() {
    url = "../Scripts/form_check.php" ;
    obj = "usr";
    if(document.get ElementsByName( obj)[0].value != '') {
    var params = "object="+obj+" &data="+documen t.getElementsBy Name(obj)[0].value;
    send_post(param s,"form_respons e"); }
    }

    /* FIRST */
    function check_first() {
    url = "../Scripts/form_check.php" ;
    obj = "first";
    if(document.get ElementsByName( obj)[0].value != '') {
    var params = "object="+obj+" &data="+documen t.getElementsBy Name(obj)[0].value;
    send_post(param s,"form_respons e"); }
    }

    /* LAST */
    function check_last() {
    url = "../Scripts/form_check.php" ;
    obj = "last";
    if(document.get ElementsByName( obj)[0].value != '') {
    var params = "object="+obj+" &data="+documen t.getElementsBy Name(obj)[0].value;
    send_post(param s,"form_respons e"); }
    }

    /* PASSWORD */
    function check_password( ) {
    url = "../Scripts/form_check.php" ;
    obj = "password";
    if(document.get ElementsByName( obj)[0].value != '') {
    var params = "object="+obj+" &data="+documen t.getElementsBy Name(obj)[0].value;
    send_post(param s,"form_respons e"); }
    }
    function check_confirm() {
    url = "../Scripts/form_check.php" ;
    obj = "confirm";
    obj2 = "password";
    if(document.get ElementsByName( obj)[0].value != '') {
    var params = "object="+obj+" &data="+documen t.getElementsBy Name(obj)[0].value+
    "&data2="+docum ent.getElements ByName(obj2)[0].value;
    send_post(param s,"form_respons e"); }
    }

    /* REGISTER */
    function register() {
    url = "../Scripts/register.php";

    if(document.get ElementsByName( 'usr')[0].value != 0 &&
    document.getEle mentsByName('em ail')[0].value != 0 &&
    document.getEle mentsByName('fi rst')[0].value != 0 &&
    document.getEle mentsByName('la st')[0].value != 0) {
    params = "usr="+document .getElementsByN ame('usr')[0].value+
    "&email="+docum ent.getElements ByName('email')[0].value+
    "&first="+docum ent.getElements ByName('first')[0].value+
    "&last="+docume nt.getElementsB yName('last')[0].value;
    send_post(param s,"register_res ponse");
    }
    }

    /* LOGIN */
    function login() {
    url = "../Scripts/login.php";

    if(document.get ElementsByName( 'name')[0].value != 0 &&
    document.getEle mentsByName('pa ssword')[0].value != 0) {
    params = "name="+documen t.getElementsBy Name('name')[0].value+
    "&password="+do cument.getEleme ntsByName('pass word')[0].value;

    send_post(param s,"register_res ponse");
    }
    }
    [/code]


    form_check.php
    [code=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($_P OST['data'])) {
    $return = "1,Existing user name"; }
    else {
    $return = "0,Availabl e 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,Availabl e 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,Password s match"; }
    else {
    $return = "1,Password s don't match"; }
    break;
    default:
    break;
    }

    echo $return;

    ?>
    [/code]

    I'll have to put the last two files in the following post.
  • muppetjones
    New Member
    • Feb 2008
    • 11

    #2
    UsrDBphp

    Here's UsrDB.php

    [CODE=php]
    <?php

    /*************** *************** ****
    Filename: UsrDB.php
    Date: 02.25.08
    *************** *************** ****/

    require_once('B asicDB.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($sy s,$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,Lo gOUT,etc.), and message
    output: TRUE / FALSE
    */
    public function write_log($inst ruction,&$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($in put_array['usr']); // SECURE user input
    $first = $this->mysql_safe($in put_array['first']);
    $last = $this->mysql_safe($in put_array['last']);
    $email = $this->mysql_safe($in put_array['email']);
    $msg = '';
    $row;

    $query = sprintf("INSERT INTO usr (usr_name,usr_f name,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_passwor d(); // 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_gr p,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("Reg ister",$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_add r,ses_php,ses_d ate,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($e mail) {
    $email = $this->mysql_safe($em ail); // 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($us r); // 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_arg s() == 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

    ?>
    [/CODE]
    Last edited by muppetjones; Mar 4 '08, 05:35 PM. Reason: Didn't show up

    Comment

    • muppetjones
      New Member
      • Feb 2008
      • 11

      #3
      BasicDB.php
      [code=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($sy s) {
      $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("Err or",$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,$ps wd); // OPEN mysql connection
      if(!$link) { // IF no connection
      $this->err("db_connec t(): 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_connec t(): 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_l ist
      input: mysql query string (select)
      output: query result (false on fail, array of single field on success) */
      public function select_simple_l ist($query) {
      return $this->result($query, 0,1); // CALL result function
      } // END select_simple_l ist

      /*************** *************** *************** *************** ***********
      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($qu ery,$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_affect ed_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_ro ws($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_ass oc($result); // --SAVE the query result
      }
      mysql_free_resu lt($result); // FREE the result
      }

      mysql_close($li nk); // 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($val ue) {
      $link = $this->db_connect() ; // GET a database link
      if (get_magic_quot es_gpc()) { $value = stripslashes($v alue); } // IF gmqg is turned on, USE it
      if (!is_numeric($v alue)) { // IF its not a number
      $value = "\"" . mysql_real_esca pe_string($valu e,$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_quot es_gpc()) { $value = stripslashes($v alue); } // IF gmqg is turned on, USE it
      if (!is_numeric($v alue)) { // IF its not a number
      $value = mysql_real_esca pe_string($valu e,$link); } // --ESCAPE the string
      return $value; // --RETURN our safe string
      } // END mysql_safe

      } // END CLASS

      ?>
      [/code]

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        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

        Comment

        • muppetjones
          New Member
          • Feb 2008
          • 11

          #5
          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.
          Attached Files
          Last edited by muppetjones; Mar 4 '08, 06:50 PM. Reason: Added files

          Comment

          • eddierosenthal
            New Member
            • Jan 2008
            • 11

            #6
            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?

            Comment

            Working...