logo       Dave's Online Memory You: 54.81.195.240         Saturday Nov 18, 2017   12:04AM PST
\n"; for($i = 0; $i < $columns; $i++ ) { $n = mysql_field_name($fields,$i); echo ""; } echo "\n"; } /////////////////////////////////////////////////////////////// // label_header_row // purpose: draw html table header row // args : array with labels for cells // returns: nothing // globals: none /////////////////////////////////////////////////////////////// function label_header_row($labels) { echo "\n"; foreach ( $labels as $l ) { echo ""; } echo "\n"; } /////////////////////////////////////////////////////////////// // header_row // purpose: create html header row from result // args : handle to query results // returns: nothing // globals: none /////////////////////////////////////////////////////////////// function header_row($results) { echo "\n"; $count = mysql_num_fields($results); for($i = 0; $i < $count; $i++ ) { $n = mysql_field_name($results,$i); echo ""; } echo "\n"; } /////////////////////////////////////////////////////////////// // print_results // purpose: create html table with query results // args : handle to results // returns: nothing // globals: none /////////////////////////////////////////////////////////////// function print_results($results) { $count = mysql_num_fields($results); while ($row = mysql_fetch_array($results)) { echo "\n"; for($i = 0; $i < $count; $i++ ) { echo " \n"; // foreach($row as $r) { // echo " \n"; } echo "\n"; } } /////////////////////////////////////////////////////////////// // query_ican // purpose: connect to db, make query, print table w/results // args : query // returns: nothing // globals: $dbh,$results,$rows (indirectly: $db,$host,$user,$pw) /////////////////////////////////////////////////////////////// function query_ican($query) { global $dbh,$results,$rows; doquery($query); echo "

Query:

$query

$rows matching items found.

could not connect to the server: ". mysql_error(). ""); mysql_select_db($database,$dbh) or die("
could not select database: ". mysql_error(). "
"); return $dbh; } /////////////////////////////////////////////////////////////// // doquery // purpose: make a database query // args : query string, app info structure (see invinit() above) // returns: an array w/result info // $r[rows] - number of rows in result // $r[columns] - number of columns in result table // $r[fields][] - field names in result table // $r[data][] - array: rows of data // globals: none // notes : encapsulates error checking and cleanup // for use on small(ish) datasets. all results in memory. // db connection already closed on return. // example : $rows_cols = doquery("select * from sw",invinit()); /////////////////////////////////////////////////////////////// function doquery($q,$app) { $dbh = dbopen($app["host"],$app["db"],$app["user"],$app["pw"]); $results = mysql_query($q,$dbh) or die("
Error while searching: " . mysql_error(). "
"); if(!is_resource($results)) return false; $r['rows'] = mysql_num_rows($results); if($r['rows'] < 1) return false; $r['columns'] = mysql_num_fields($results); for($i = 0; $i < $r['columns']; $i++ ) { $r['fields'][$i] = mysql_field_name($results,$i); } for($i = 0; $i < $r['rows']; $i++ ) { $r['data'][$i] = mysql_fetch_array($results); } mysql_close($dbh); return $r; } /////////////////////////////////////////////////////////////// // query_as_text // purpose: make a database query, print as text // args : query string, app info structure (see invinit() above) // returns: nothing // globals: none // notes : // example : /////////////////////////////////////////////////////////////// function query_as_text($q,$app) { $r = doquery($q,$app); echo "
\n";
	for($i=0;$i<$r['rows'];$i++) {
		foreach ( $r['data'][$i] as $col ) {
			echo "$col\t";
		}
		echo "\n";
	}
	echo "
\n"; } /////////////////////////////////////////////////////////////// // query_as_table // purpose: make a database query, print as html table // args : query string, app info structure (see invinit() above) // returns: nothing // globals: none // notes : FIXME!!! need a way to apply formatting... // and alternating bgcolor, maybe? // example : /////////////////////////////////////////////////////////////// function query_as_table($q,$app) { $r = doquery($q,$app); $found = ($r['rows'] == NULL) ? "no" : $r['rows'] ; echo "

Found " . $found . " matches.

"; for($i=0;$i<$r['columns'];$i++) { echo ""; } echo "\n\n"; for($i=0;$i<$r['rows'];$i++) { $line = $r['data'][$i]; echo "\n\n"; for($j=0;$j<$r['columns'];$j++) { if( ($i % 2) == 1) { echo ""; } else { echo ""; } } echo "\n\n"; } echo "
" . $r['fields'][$i] . "
$line[$j]  $line[$j]  
\n"; } /////////////////////////////////////////////////////////////// // getfields // purpose: get array of field names from a db table // args : table name, app info (see invinit, above) // returns: array w/field names as strings // globals: none /////////////////////////////////////////////////////////////// function getfields($table,$app) { $q = "show fields from $table"; $r = doquery($q,$app); $i=0; foreach ($r['data'] as $row) { $ary[$i++] = $row[0]; } return $ary; } /////////////////////////////////////////////////////////////// // errmsg // purpose: display error message // args : msg - error message to display // returns: nothing // globals: none // notes : expects the page (header, body tag, etc.) to have // already been drawn. simply finishes the page. /////////////////////////////////////////////////////////////// function errmsg($msg) { echo "
Error: $msg
"; } /////////////////////////////////////////////////////////////// // infoexit // purpose: display message and quit // args : app info, msg - message to display // returns: nothing // globals: none // notes : expects the page (header, body tag, etc.) to have // already been drawn. simply finishes the page. /////////////////////////////////////////////////////////////// function infoexit($app,$msg) { echo "
$msg
"; include $app['footer']; exit; } /////////////////////////////////////////////////////////////// // errexit // purpose: display error message and quit // args : msg - error message to display // returns: nothing // globals: none // notes : expects the page (header, body tag, etc.) to have // already been drawn. simply finishes the page. /////////////////////////////////////////////////////////////// function errexit($msg) { echo "
Error: $msg
"; include $app['footer']; exit; } /////////////////////////////////////////////////////////////// // debug // purpose: print debugging info // args : $msg - what to print // returns: nothing // globals: none // notes : /////////////////////////////////////////////////////////////// function debug($msg) { echo "
DEBUG:$msg
\n"; } /////////////////////////////////////////////////////////////// // tableformstyle // purpose: create a style for tables used to draw forms // args : none // returns: nothing // globals: none // notes : /////////////////////////////////////////////////////////////// function tableformstyle() { echo " "; } /////////////////////////////////////////////////////////////// // tableform // purpose: create a form from a table // args : string: table name, app info (see invinit above) // returns: nothing // globals: none // notes : /////////////////////////////////////////////////////////////// function tableform($tbl,$app) { $fields = getfields($tbl,$app); tableformstyle(); echo ""; foreach($fields as $field) { echo " "; } echo "
$field
"; } /////////////////////////////////////////////////////////////// // select_host // purpose: create html select element from computer table values // args : $hostid - int rec #, $app - app info (see invinit above) // returns: nothing // globals: none // notes : $host returned from form. "" if nothing selected. // $hostid selected unless < 0. /////////////////////////////////////////////////////////////// function select_host ($hostid,$app) { echo " \n"; } /////////////////////////////////////////////////////////////// // select_software // purpose: create html select element from sw table values // args : $swid - rec #, $app - app info (see invinit above) // returns: nothing // globals: none // notes : $sw returned from form. "" if nothing selected. // $swid selected unless < 0. /////////////////////////////////////////////////////////////// function select_software ($swid,$app) { echo " \n"; } /////////////////////////////////////////////////////////////// // select_account // purpose: create html select element from account table values // args : $accountid - int rec #, $app - app info (see invinit above) // returns: nothing // globals: none // notes : $account returned from form. "" if nothing selected. // $accountid selected unless < 0. /////////////////////////////////////////////////////////////// function select_account ($accountid,$app) { echo " \n"; } /////////////////////////////////////////////////////////////// // invnavbar // purpose: display navigation bar for inventory web app // args : none // returns: nothing // globals: none // notes : /////////////////////////////////////////////////////////////// function invnavbar() { echo "
Computers Software Software Inventory Accounts All Tables Login Logout
"; } /////////////////////////////////////////////////////////////// // backupnavbar // purpose: display navigation bar for backup web app // args : none // returns: nothing // globals: none // notes : /////////////////////////////////////////////////////////////// function backupnavbar() { echo "
Backups Tapes View Tables Login Logout
"; } /////////////////////////////////////////////////////////////// // newpage // purpose: create new page for the app // args : $app - app info (see above) // returns: nothing // globals: $PHP_AUTH_USER: user name obtained from web browser // $PHP_AUTH_PW: user password obtained from web browser // notes : uses http basic authentication /////////////////////////////////////////////////////////////// function newpage($app) { global $title,$PHP_AUTH_USER,$PHP_AUTH_PW; if( !isset($PHP_AUTH_USER) || ! ckpwd(getID($PHP_AUTH_USER),$PHP_AUTH_PW)) { authenticate(); } include_once $app['header']; include_once $app['footer']; } /////////////////////////////////////////////////////////////// // authenticate // purpose: force web browser to authenticate // args : $app - app info (see above) // returns: nothing // globals: $PHP_AUTH_USER,$PHP_AUTH_PW // notes : must be called before headers are output! /////////////////////////////////////////////////////////////// function authenticate($app) { if(!isadmin($app)) { Header( "WWW-Authenticate: Basic realm=\"Biometrics Computer Inventory\""); Header( "HTTP/1.0 401 Unauthorized"); include_once $app['header']; errmsg("You must enter a valid login ID and password to access this information."); include_once $app['footer']; exit; } // header ("Location: sw.php"); } /////////////////////////////////////////////////////////////// // logout // purpose: cause web browser to clear authentication cache // args : app info // returns: nothing // globals: none // notes : must be called before headers are output! /////////////////////////////////////////////////////////////// function logout($app) { Header( "WWW-Authenticate: Basic realm=\"Biometrics Computer Inventory\""); Header( "HTTP/1.0 401 Unauthorized"); include $app['header']; echo "

Thank you. Your credentials are cleared.

"; include $app['footer']; exit; } /////////////////////////////////////////////////////////////// // ckcred // purpose: is current client logged in as admin? // args : $app: app info - (see above) // $u - session user, $p - session password // returns: true if admin, false otherwise // globals: none // notes : see app info fields for more info. /////////////////////////////////////////////////////////////// function ckcred($app,$suser,$spwd) { if( isset($suser) && $suser == $app['adminuser'] && isset($spwd) && $spwd == $app['adminpwd'] ) { $app['suser'] = $suser; $app['spwd'] = $spwd; session_register("app","suser","spwd"); return true; } return false; } /////////////////////////////////////////////////////////////// // isadmin // purpose: is current client logged in as admin? // args : $app: app info - (see above) // returns: true if admin, false otherwise // globals: $PHP_AUTH_USER,$PHP_AUTH_PW // notes : see app info fields for more info. /////////////////////////////////////////////////////////////// function isadmin($app) { global $PHP_AUTH_USER,$PHP_AUTH_PW; if( isset($PHP_AUTH_USER) && isset($PHP_AUTH_PW) && ( $app['adminpwd'] == $PHP_AUTH_PW ) && ( $app['adminuser'] == $PHP_AUTH_USER ) ) { return true; } return false; } /////////////////////////////////////////////////////////////// // loginform // purpose: display login form // args : username and password // returns: nothing // globals: none // notes : /////////////////////////////////////////////////////////////// function loginform($suser,$spwd) { echo '
User:     Password:
'; } /////////////////////////////////////////////////////////////// // logoutform // purpose: display logout form // args : app info // returns: nothing // globals: none // notes : /////////////////////////////////////////////////////////////// function logoutform($app) { echo '
' . $app['suser'] . '
'; } function nocacheheader() { header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 } //------------------------------------------------------------ // HTML functions // these just spit out html tags to surround the incoming text //------------------------------------------------------------ function h1($arg) { echo "\n

$arg

\n"; } function h2($arg) { echo "\n

$arg

\n"; } function h3($arg) { echo "\n

$arg

\n"; } function h4($arg) { echo "\n

$arg

\n"; } function h5($arg) { echo "\n
$arg
\n"; } function h6($arg) { echo "\n
$arg
\n"; } function b($arg) { echo "\n$arg\n"; } function i($arg) { echo "\n$arg\n"; } function hr() { echo "\n
\n"; } //------------------------------------------------------------ // OLD -- // | // V //------------------------------------------------------------ /////////////////////////////////////////////////////////////// // table_header_row // purpose: create html table header row from table field names. // args : $tbl - table name // returns: nothing // globals: $db, $dbh /////////////////////////////////////////////////////////////// function table_header_row($tbl) { global $dbh,$db; $fields = mysql_list_fields($db,$tbl,$dbh); $columns = mysql_num_fields($fields); echo "
$n
$l
$n
$row[$i]  $r
"; header_row($results); print_results($results); echo "
\n"; mysql_close($dbh); } function ican_query($q) { $dbh = mysql_connect("localhost","nobody","") or die("
could not connect to the server: ". mysql_error(). "
"); mysql_select_db("ican",$dbh) or die("
could not connect to the database: ". mysql_error(). "
"); $results = mysql_query($q,$dbh) or die("
Error searching the directory: " . mysql_error(). "
"); $rows = mysql_num_rows($results); echo "

Query:

$q

$rows matching items found.

"; $count = mysql_num_fields($results); for($i = 0; $i < $count; $i++ ) { $n = mysql_field_name($results,$i); echo ""; } echo "\n"; while ($row = mysql_fetch_array($results)) { echo "\n"; // foreach($row as $r) { // echo " \n"; for($i = 0; $i < $count; $i++ ) { echo " \n"; } echo "\n"; } echo "
$n
$r$row[$i]  
\n"; mysql_close($dbh); } /////////////////////////////////////////////////////////////// // select_pretitle // purpose: create html select element from pretitle table values // args : none // returns: nothing // globals: $row, $results // notes : /////////////////////////////////////////////////////////////// function select_pretitle() { global $row, $results; echo "\n"; } /////////////////////////////////////////////////////////////// // select_posttitle // purpose: create html select element from posttitle table values // args : none // returns: nothing // globals: $row, $results // notes : /////////////////////////////////////////////////////////////// function select_posttitle() { global $row, $results; echo "\n"; } /////////////////////////////////////////////////////////////// // select_profession // purpose: create html select element from posttitle table values // args : none // returns: nothing // globals: $row, $results // notes : /////////////////////////////////////////////////////////////// function select_profession () { global $row, $results; echo "\n"; } /////////////////////////////////////////////////////////////// // select_team // purpose: create html select element from team table values // args : none // returns: nothing // globals: $row, $results // notes : /////////////////////////////////////////////////////////////// function select_team () { global $row, $results; echo "\n"; } /////////////////////////////////////////////////////////////// // select_role // purpose: create html select element from role table values // args : none // returns: nothing // globals: $row, $results // notes : /////////////////////////////////////////////////////////////// function select_role () { global $row, $results; echo "\n"; } /////////////////////////////////////////////////////////////// // select_state // purpose: create html select element from state table values // args : none // returns: nothing // globals: $row, $results // notes : /////////////////////////////////////////////////////////////// function select_state () { global $row, $results; echo "\n"; } /////////////////////////////////////////////////////////////// // select_country // purpose: create html select element from country table values // args : none // returns: nothing // globals: $row, $results // notes : /////////////////////////////////////////////////////////////// function select_country () { global $row, $results; echo "\n"; } /////////////////////////////////////////////////////////////// // select_contacttype // purpose: create html select element from contacttype table values // args : none // returns: nothing // globals: $row, $results // notes : /////////////////////////////////////////////////////////////// function select_contacttype () { global $row, $results; echo "\n"; } /////////////////////////////////////////////////////////////// // select_level // purpose: create html select element from level table values // args : none // returns: nothing // globals: $row, $results // notes : /////////////////////////////////////////////////////////////// function select_level () { global $row, $results; echo "\n"; } /////////////////////////////////////////////////////////////// // select_active // purpose: create html select element from active table values // args : none // returns: nothing // globals: $row, $results // notes : /////////////////////////////////////////////////////////////// function select_active () { global $row, $results; echo " "; } /////////////////////////////////////////////////////////////// // select_region // purpose: create html select element from region table values // args : none // returns: nothing // globals: $row, $results // notes : /////////////////////////////////////////////////////////////// function select_region () { global $row, $results; echo "\n"; } /////////////////////////////////////////////////////////////// // field2criteria // purpose: create criteria line from field name // args : $field - field name, $crit - criteria, $cmp - comparison operator // returns: string // globals: none // notes : differs based on field's table /////////////////////////////////////////////////////////////// function field2criteria($field,$crit,$cmp) { $tail = ($cmp == " LIKE ") ? "$cmp '%$crit%' \n" : "$cmp '$crit' \n"; switch ($field) { case "Region": $s = " region.Region $tail"; break; case "PostTitle": $s = " titles.Title $tail"; break; default: $s = " member.$field $tail"; break; } return $s; } /////////////////////////////////////////////////////////////// // gettitles // purpose: given user id, retrieve all posttitles // args : $id - member record id // returns: $s - string of titles // globals: $host,$db,$user,$pw,$dbh,$rows,$results // notes : /////////////////////////////////////////////////////////////// function gettitles($id) { global $host,$db,$user,$pw,$dbh,$rows,$results; $query = "select posttitle.PostTitle as title from posttitle left join titles on (posttitle.ID = titles.Title) where titles.member = '$id' "; doquery($query); for ( $i = 0,$s=""; $i < $rows; $i++ ) { $s .= mysql_result($results,$i) . " "; } return $s; } /////////////////////////////////////////////////////////////// // ckpwd // purpose: check user password against database // args : username (email), password to check // returns: success - 1, failure - 0 // subroutines do their own reporting and die on error. // globals: none // notes : password sent & stored in the clear /////////////////////////////////////////////////////////////// function ckpwd($u,$p) { $r = doquery("select Password from access where User = '$u'"); if($r){ $sp = mysql_result($r,0); return ($p == $sp) ? 1 : 0; } return 0; } /////////////////////////////////////////////////////////////// // ckmd5pwd // purpose: check hashed user password against database // args : username, md5 hashed password to check // returns: success - 1, failure - 0 // subroutines do their own reporting and die on error. // globals: none // notes : password sent & stored in the clear /////////////////////////////////////////////////////////////// function ckmd5pwd($u,$p) { $r = doquery("select Password from access where User = '$u'"); if($r){ $sp = mysql_result($r,0); return ($p == md5($sp)) ? 1 : 0; } else { return 0; } } /////////////////////////////////////////////////////////////// // getID // purpose: get user member ID given his login (email address) // args : $email - email address from login // returns: 1 - success, 0 - failure // globals: none // notes : error handling done in doquery subroutine call /////////////////////////////////////////////////////////////// function getID($email) { if($email == "") return NULL; $r = doquery("select ID from member where Email = '$email'"); if($r) { return mysql_result($r,0); } else { return NULL; } } /////////////////////////////////////////////////////////////// // getaccesslevel // purpose: look up user access level in db // args : user's id from member table // returns: access level as int // globals: none // notes : /////////////////////////////////////////////////////////////// function getaccesslevel($uid) { if($uid == "") return NULL; $result = doquery("select AccessLevel from access where User = '$uid'"); return mysql_result($result,0); } /////////////////////////////////////////////////////////////// // dopage // purpose: generate page // args : page content - in toto // returns: nothing // globals: none // notes : /////////////////////////////////////////////////////////////// function dopage($page) { include_once("lib/header.html"); include_once( "lib/menu.php" ); echo $page; include_once( "lib/footer.html" ); } /////////////////////////////////////////////////////////////// // errpage // purpose: generate page w/error message // args : error message // returns: nothing // globals: none // notes : /////////////////////////////////////////////////////////////// function errpage($errmsg) { include_once("lib/header.html"); include_once( "lib/menu.php" ); echo "
Error:
$errmsg
"; include_once( "lib/footer.html" ); } /////////////////////////////////////////////////////////////// // mkbtn // purpose: create navbar button // args : button text // returns: nothing // globals: none // notes : uses blank button in lib dir /////////////////////////////////////////////////////////////// function mkbtn($text) { echo ""; } /////////////////////////////////////////////////////////////// // doadd // purpose: insert record into a table // args : $app app info,$table db table,$vars - array of form var's // returns: nothing // globals: none // notes : // usage : doadd(invinit(),"computers",$HTTP_POST_VARS); /////////////////////////////////////////////////////////////// function doadd($app,$table,$vars) { $query = "insert into " . $table . " values ( "; $fields = getfields($table,$app); $count = count($fields); for($i=0;$i<$count;$i++) { $f = $fields[$i]; if($f == "ID") { $v = "NULL"; } else { $v = "'" . $vars[$f] . "'"; } if($i == 0) { $query .= $v; } else { $query .= "," . $v; } } $query .= " )"; debug("query: $query"); query_as_table($query,$app); } /////////////////////////////////////////////////////////////// // doupdate // purpose: edit existing record in a table // args : $app app info,$table db table,$vars - array of form var's // returns: nothing // globals: none // notes : // usage : doupdate($app,"computers",$HTTP_POST_VARS); /////////////////////////////////////////////////////////////// function doupdate($app,$table,$vars) { $query = "update " . $table . " set "; $fields = getfields($table,$app); $count = count($fields); for($i=0;$i<$count;$i++) { $f = $fields[$i]; if($i == 0) { $query .= $f . " = '" . $vars[$f] . "'"; } else { $query .= ", " . $f . " = '" . $vars[$f] . "'"; } } $query .= " where ID = " . $vars['ID']; query_as_table($query,$app); } /////////////////////////////////////////////////////////////// // enjoy // purpose: display a short sig line: // enjoy, // ...dave // args : none // returns: nothing // globals: none // notes : /////////////////////////////////////////////////////////////// function enjoy() { echo '

enjoy!
...dave

'; } /////////////////////////////////////////////////////////////// // dave // purpose: display a short sig line: // ...dave // args : none // returns: nothing // globals: none // notes : /////////////////////////////////////////////////////////////// function dave() { echo '

...dave

'; } /////////////////////////////////////////////////////////////// // updated // purpose: display last update info // updated: jan 1 2004 // ...dave // args : date (as string) // returns: nothing // globals: none // notes : /////////////////////////////////////////////////////////////// function updated($date_string) { echo '

updated: '.$date_string.'
...dave

'; } // -------------- end of functions ------------------------------ /////////////////////////////////////////////////////////////// // functionTemplate // purpose: FUNCTION TEMPLATE // args : // returns: nothing // globals: $globalvar // notes : /////////////////////////////////////////////////////////////// function functionTemplate($arg) { global $globalvar; echo " "; } ?>

Warning!
Note: While the vast majority of this material is suitable for the consumption of children, some of it is not.
Potentially offensive material present: Sex, nudity, and adult language.
If such things offend you, please DO NOT view these pages.

Here's my collection; culled from years of email and newsgroup postings. This collection has been haphazardly assembled and moved from machine to machine; from unix to mac to windows to unix, etc.

Here it sat for many years until Allen Day copied the data files and started building another interface. Have a look, it's at http://www.theprawn.com/quotes/. He's pulled it into a database, so one can do some more complex searches. Special thanks to Allen for getting me to finally finish something I started half a dozen years ago.


If you know part of a quote, type in what you know (shorter the better). Or, if you're looking for quotes on a particular topic, try searching by category.

Peruse, add to email, whatever... hope they're useful or entertaining for you, too.

...dave

Search by category (love, money, government), or by the text of a quote ("by any other name", "give me liberty").
    quote     category