. * * ------------------------------------------------------------------------ * DESCRIPTION: * ------------------------------------------------------------------------ * This library tells the PHP4 session handler to write to a MySQL database * instead of creating individual files for each session. * * Create a new database in MySQL called "sessions" like so: * * CREATE TABLE sessions ( * sesskey char(32) not null, * expiry int(11) unsigned not null, * value text not null, * PRIMARY KEY (sesskey) * ); * * ------------------------------------------------------------------------ * INSTALLATION: * ------------------------------------------------------------------------ * Make sure you have MySQL support compiled into PHP4. Then copy this * script to a directory that is accessible by the rest of your PHP * scripts. * * ------------------------------------------------------------------------ * USAGE: * ------------------------------------------------------------------------ * Include this file in your scripts before you call session_start(), you * don't have to do anything special after that. */ $SESS_DBHOST = "scottflodin.duckdns.org"; /* database server hostname */ $SESS_DBUSER = "scottflodin"; /* database user */ $SESS_DBPASS = "nidolf"; /* database password */ $SESS_DBNAME = "totalca_main"; /* database name */ $SESS_DBHOST = "localhost"; /* database server hostname */ $SESS_DBUSER = "totalca"; /* database user */ $SESS_DBPASS = "j5#8Cu4a"; /* database password */ $SESS_DBNAME = "totalca_main"; /* database name */ $SESS_DBH = ""; $SESS_LIFE = (3600 * 24 * 365); // (1 hour) * (24 hours) * (365 days) session_set_cookie_params($SESS_LIFE); function sess_open($save_path, $session_name) { global $SESS_DBHOST, $SESS_DBNAME, $SESS_DBUSER, $SESS_DBPASS, $SESS_DBH; if (! $SESS_DBH = mysql_connect($SESS_DBHOST, $SESS_DBUSER, $SESS_DBPASS)) { echo "
  • Can't connect to $SESS_DBHOST as $SESS_DBUSER"; echo "
  • MySQL Error: ", mysql_error() . ' - SESSION duck'; die; } if (! mysql_select_db($SESS_DBNAME, $SESS_DBH)) { echo "
  • Unable to select database $SESS_DBNAME" . ' - SESSION duck'; die; } return true; } function sess_close() { return true; } function sess_read($key) { global $SESS_DBH, $SESS_LIFE; $qry = "SELECT value FROM sessions WHERE sesskey = '".$key."'"; $qid = mysql_query($qry, $SESS_DBH); if (list($value) = mysql_fetch_row($qid)) { return $value; } return false; } function sess_write($key, $val) { global $SESS_DBH, $SESS_LIFE; $expiry = time() + $SESS_LIFE; $value = addslashes($val); $qry = "INSERT INTO sessions VALUES ('$key', $expiry, '$value')"; $qid = mysql_query($qry, $SESS_DBH); if (! $qid) { $qry = "UPDATE sessions SET expiry = $expiry, value = '".$value."' WHERE sesskey = '".$key."'"; $qid = mysql_query($qry, $SESS_DBH); } return $qid; } function sess_destroy($key) { global $SESS_DBH; $qry = "DELETE FROM sessions WHERE sesskey = '".$key."'"; $qid = mysql_query($qry, $SESS_DBH); session_unset(); // FLODIN added 2004_09_20 global $session_expired; // FLODIN added 2005_07_26 $session_expired = 1; // FLODIN added 2004_09_20 return $qid; } function sess_gc($maxlifetime) { global $SESS_DBH; $qry = "DELETE FROM sessions WHERE expiry < " . time(); //$qid = mysql_query($qry, $SESS_DBH); //return mysql_affected_rows($SESS_DBH); } session_set_save_handler( "sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc"); ?> California Politics and People | TotalCapitol
    JUMP TO: Assembly | Senate | Congress | State Executives
    Tip: Click column headings to change order


    U.S. CONGRESS

    Dist.
    Tendency*
    Voter registration
    Dem.   Rep.   Other
    Officeholder


    *Sources:
    District tendency categories provided by California Target Book
    Candidate and cash on-hand data from news reports and Secretary of State
    - // STRIPE FORM