tld = "com" // Not sure what I need here yet $this->seller = ""; $this->registrar = ""; $this->reset_search_settings(); $this->bucket = new Nameboy_Domain_Bucket; // [2] (insert initialization code here) } // reset_search_settings - Clear the part of the session that // contains the search parameters // The idea is that the search form retains the previous search // settings unless this function is called before displaying it. function reset_search_settings() { unset($this->searchid); unset($this->primary); unset($this->secondary); $this->tld = "com"; unset($this->convey); unset($this->convey_subcat); unset($this->domix); unset($this->dorhyme); $this->forsale = "yes"; $this->page = 1; unset($this->hyphens); $this->selecteddomains = array(); // [2] search parameter settings (those that appear in the search // form) should be initialized here } // A cheapo debugging function function dump() { echo "\nSearchid: $this->searchid
Primary: $this->primary
Secondary: $this->secondary
Page: $page
Hyphens: $this->hyphens\n"; } } // // Session storage functions // // (each-page code to set up the session is still further down) function boy_session_open($savepath, $sessionname) { return TRUE; } function boy_session_close() { return TRUE; } function boy_session_read($sid) { $qresult = mysql_query("SELECT data FROM sessions WHERE sid='$sid';"); if ( ! $qresult ) { error_log("Error getting session in boy_session_read: " . mysql_error(), 0); return FALSE; } $resultarr = mysql_fetch_row($qresult); return $resultarr[0]; } function boy_session_write($sid, $data) { $curtime = time(); $qdata = str_replace("'", "\'", $data); $qresult = mysql_query("REPLACE INTO sessions VALUES ('$sid', '$qdata', $curtime);"); if ( ! $qresult ) { error_log("Error creating/updating session in boy_session_write: " . mysql_error(), 0); } return TRUE; } function boy_session_destroy($sid) { // we'll probably never use this one, but... mysql_query("DELETE FROM sessions WHERE sid='$sid';"); return TRUE; } function boy_session_garbagecollect($maxlife) { $deltime = time() - $maxlife; $rq = mysql_query("DELETE FROM sessions WHERE time < $deltime;"); if ( ! $rq ) { error_log("Error deleting sessions in boy_session_garbagecollect: " . mysql_error(), 0); } return TRUE; } // // Grab the existing session, or create one if necessary // function nameboy_setup_session() { global $HTTP_COOKIE_VARS; global $boysession; if ( ! isset($boysession) ) { // This is a new session $boysession = new Nameboy_Session_Data; $log_statustag = "new"; } else { $log_statustag = "old"; } // log format is: // [unix timestamp] [session id] [new/old] [cookieid] [request uri] $logcookie = isset($boycookie) ? $boycookie : "-"; error_log(sprintf("%d %s %s %s %s\n", time(), session_id(), $log_statustag, $logcookie, $SCRIPT_URL), 3, "/vol/log/session_log"); // // Automatic user login // if ( ! isset($boysession->login) && ($HTTP_COOKIE_VARS["boylogin"] != "") && ($HTTP_COOKIE_VARS["boylogin"] != " ") ) { include_once("includes/account.inc"); $id = do_automatic_userlogin($HTTP_COOKIE_VARS["boylogin"]); if ( $id ) { // use auto-login feature because we've already verified the // password in do_automatic_userlogin() if ( ! open_existing_account($id, "", TRUE) ) { error_log(__FILE__ . ": open_existing_account() failed during auto-login: '$errmsg' (this shouldn't happen)", 0); } } // id else { error_log(__FILE__ . ": do_automatic_userlogin() failed; bad login cookie (".$HTTP_COOKIE_VARS["boylogin"].")?", 0); } } return $boysession; } // nameboy_setup_session if ( ! isset($NAMEBOY_SESSION_INITIALIZED) || (!$NAMEBOY_SESSION_INITIALIZED) ) { // Set up MySQL handling of the session info session_set_save_handler("boy_session_open", "boy_session_close", "boy_session_read", "boy_session_write", "boy_session_destroy", "boy_session_garbagecollect"); init_db(); // Start up the session itself // seems the session_start/session_register stuff can't be in // a function. session_start(); session_register("boysession"); $boysession = nameboy_setup_session(); } // // Update the current session object with parameters that were passed // in to the script. Parameters that weren't passed in to this page // retain their old value. // if ( isset($dosearch) && $dosearch=="yes" ) { unset($boysession->dorhyme); unset($boysession->forsale); unset($boysession->hyphens); } if ( isset($searchid) ) { $boysession->searchid = $searchid; } if ( isset($primary) ) { $boysession->primary = $primary; } if ( isset($secondary) ) { $boysession->secondary = $secondary; } if ( isset($tld) ) { $boysession->tld = $tld; } if ( isset($convey) ) { $boysession->convey = $convey; } if ( isset($convey_subcat) ) { $boysession->convey_subcat = $convey_subcat; } if ( isset($domix) ) { $boysession->domix = $domix; } if ( isset($dorhyme) ) { $boysession->dorhyme = $dorhyme; } if ( isset($forsale) ) { $boysession->forsale = $forsale; } if ( isset($page) ) { $boysession->page = $page; } if ( isset($resultsperpage) ) { $boysession->resultsperpage = $resultsperpage; } if ( isset($hyphens) ) { $boysession->hyphens = $hyphens; } // [3] $NAMEBOY_SESSION_INITIALIZED = TRUE; ?>