View MC Group Profile
- Register Group with Captcha
- View Group Profile
- Edit Group Profile
- MC (Microcommunity) Search and Match
- MC (Microcommunity) Search and Match — Security
- MC (Microcommunity) Search and Match — JavaScript
- MC (Microcommunity) Search and Match — Form
- MC (Microcommunity) Search and Match — PHP
- MC Questionnaire
- Microcommunity (MC) Registration Script — Enter Questionnaire Data in Database
- MC Search and Match Profile and Account Management
- Login to MC Search and Match Profile and Account Management
- Logout of MC Search and Match Profile and Account Management
- MC Questionnaire Login
- MC Questionnaire Info
- Delete Group Account
- Forgot User Name
- Forgot Password
- Form to Send Private Message
- Send Private Message
- Private Message Outbox
- Private Message Inbox
- Delete Private Message from Inbox
- Delete Private Message from Outbox
- Private Message Logout
- Private Message Session Monitoring
- MC (Microcommunity) Search and Match Session Monitoring
- Configure File for Database Connection
- Captcha Script for Registration and Login
This script is called view-profile.php
The first section is at the start of the script. First, we use the checkid.php script to ensure that the session id variable is set, and send the user to register-with-captcha.php if it is not. Then we put the session variable 'username' into $U—we will be checking that it is set in a second. Then we define a named constant '_NODIRECTACCESS'. We include the config.php file (in the includes folder) which uses the PHP defined() function to check on this constant. If it is not set, we are thrown out of the config.php file like yesterday's trash.
Next we check if the session variables 'groupname', 'username', and 'userid' are set. If not, we are sent to the login-to-mc.php script. We make sure $U is still equal to the session variable 'username', that it is not an empty string, and that it's at least 6 characters long or . . . you guessed it . . . the login script. We make sure the session id is set and send them away if not.
Next come the PHP arrays that are used for display purposes. Then we have the JavaScript browser sniffers and the Mac Safari display tweaking, run from the onload event.
The opt() function is for data display purposes. Check this out:
$a=htmlentities(stripslashes($row['Pets']), ENT_QUOTES);$e=$Pets;$x=opt($a,$e);
echo "<td colspan='2' style='text-align:left'>Pets: ".$x."</td></tr><br>";
As you can see, the opt() function requires 2 parameters, $a and $e. The $a variable gets the value of the Pets field in the db table, while $e gets the name of the PHP array we will reference. You can see those arrays in their entirety below. So the opt() function now uses the PHP substr() function to strip the comma from the beginning and end of the $a value gotten from the db.
Why do all the table fields in the records that refer to the Preferences section of the search form have commas fore and aft? Because when the searches happen, a search for all 2 values would also find 12, 22, 32, 42, and 52 as field values, (e.g., 'Smoking not an issue' in the Smoking_Drinking options of the form is immune since it has only 5 elements, but what about the Religion options in the form, with 61 elements?). Looking for ,2 or 2, is no good since the 2 could be at the front or end of the string, and, as we showed, looking for 2 is no good either. But looking for ,2, works fine, as long as the data follows the rules.
The rules are that if a record has ,3,7,8, as its field value for example for Religion, signifying that the group has at least 1 member of the Assemblies of God, Buddhist, and Catholic religions, a search for ,3, or ,7, or ,8, would do fine, and if their field has ,2,6,11,22,48,52, searching in the field for the criterion ,2, should succeed at getting ,2, only but not ,22, or ,52, . This type of field configuration works fine. At first one would imagine that an array of numbers in string form would look like 2,6,11,22,48,52 since in the opt() function we explode it into an array and ,2,6,11,22,48,52, will mess up. But $a=substr($a,1,strlen($a)-2) takes care of the problem since searches need ,2,6,11,22,48,52, but data display needs these numbers as individual array elements.
So we explode the string (e.g., ,2,6,11,22,48,52,) after getting the fore and aft commas dumped, into the $c[] array. Since $e holds the name of the PHP array we need, $e[$c[$i]] gets the array element value where $c[$i] is the element number corresponding to the 2nd, 6th, 11th, 22nd, 48th, and 52nd array element as $i increments in the loop. $x gets the values (which are strings found in the PHP arrays below, not numbers) all concatenated together with commas and spaces where appropriate. The final substr() gets the ", " dumped off the end of $x—there are no more array values to display.
The code block after the opt() function is for displaying all the data in the db which correspond to the user whose username was found in a session variable. Security measures are in place—we use htmlentities() and stripslashes() functions to make sure the data from the MySQL database table is safely displayed, even though the data was thoroughly sanitized on the way into the db. Note the style applied to the columns: 'width:143px;max-width:143px;min-width:143px;word-wrap:break-word;'. This forces decent data display even if the data contains long words wider than their <TD> container.
We've already described the opt() function's use for data display purposes. The Preferences part of record display uses this.
After the display code block, onclick="goback() is used in an HTML button input tag to run a JavaScript function which does only this: window.location ="register-for-mc.php", which is the MC Search and Match Profile and Account Management script.
<?php
include_once"checkid.php";
$U=$_SESSION['username'];
define('_NODIRECTACCESS', TRUE);
include_once"includes/config.php";
if (!isset($_SESSION['groupname']) || !isset($_SESSION['userid']) || !isset($_SESSION['username']) || $_SESSION['username']<>$U || !isset($U) || $U=="" || strlen($U)<6 || !isset($_SESSION['sessionid'])){echo '<script language="javascript">alert("Please login."); window.location = "login-to-mc.php";</script>';}
$Smoking_Drinking=array('No preference','Prefer nonsmokers','Smoking not an issue','Prefer nondrinkers','Drinking not an issue');
$Preferred_Housing_Type=array('No preference','Row houses','Apartments','Mobile homes','Manufactured homes','Condominium','Co-op','Hotel','Motel','Farm','Rural','City','Suburbs','Retirement community','Gated community','Pocket neighborhoods');
$Willing_to_relocate=array('No preference','Yes, anywhere','Yes, up to 1000 miles','Yes, up to 500 miles','Yes, up to 200 miles','Yes, up to 100 miles','Yes, up to 50 miles','Yes, up to 10 miles','Yes, up to 2 miles','No');
$MC_type_sought=array('No preference','With children','Without children','Children not an issue','Singles MC','Married MC','Mixed MC','Marital status not an issue');
$Open_to_be_in_mixed_race_MC=array('No preference','Prefer to be in MC of my own race','Prefer to be in MC with racial diversity','Race not an issue');
$Sexuality=array('No preference','Prefer not to answer','Open to be in mixed sexual preference MC','Prefer to be in MC of my own sexual preference','Prefer to be in MC with sexual preference diversity','Sexual preference not an issue');
$Religious_Openness=array('No preference','Open to be in mixed religion MC','Prefer to be in MC of my own religion','Prefer to be in MC with religious diversity','Religion not an issue','Prefer not to answer');
$Religion=array('No preference','Agnostic','Apostolic or New Apostolic','Assemblies of God','Atheist','Baha\'I','Baptist','Buddhist','Catholic','Christian Reform','Christian Science','Christian no denomination supplied','Church of God','Church of the Brethren','Church of the Nazarene','Churches of Christ','Congregational or United Church of Christ','Deity','Disciples of Christ','Druid','Eckankar','Episcopalian or Anglican','Ethical Culture','Evangelical or Born Again','Foursquare Gospel','Full Gospel','Fundamentalist','Hindu','Holiness or Holy','Humanist','Independent Christian Church','Jehovah\'s Witness','Jewish','Lutheran','Mennonite','Methodist or Wesleyan','Mormon or Latter Day Saints','Muslim','Native American','New Age','No religion','Nondenominational','Orthodox Eastern','Other unclassified','Pagan','Pentecostal or Charismatic','Presbyterian','Protestant no denomination supplied','Quaker','Rastafarian','Reformed or Dutch Reform','Salvation Army','Santeria','Scientologist','Secular','Seventh Day Adventist','Sikh','Spiritualist','Taoist','Unitarian or Universalist','Wiccan');
$Childrearing_Style_and_Preferences=array('No preference','Liberal or permissive','Authoritative','Authoritarian','Liberal and authoritative mix','Liberal and authoritarian mix','Authoritative and authoritarian mix');
$Pets=array('No preference','Have dogs','Have cats','Have birds','Have other pets','Have barking dogs','Have screeching birds','Tolerant of neighbors\' pet sounds','Not tolerant of neighbors\' pet sounds');
$Personal_Entertainment=array('No preference','Tolerant of neighbors\' loud music or TV','Not tolerant of neighbors\' loud music or TV');
$Housing_Interested_in_Common_Shared_Space_for=array('No preference','Cooking','Laundry','Exercise','Childcare','Eldercare','Home schooling','Meetings','Entertainment','Not interested in common space');
$Employment=array('No preference','Management, business, and financial','Professional and related','Office and administrative support','Service','Installation, maintenance, and repair','Transportation and material moving','Construction and extraction','Production','Sales and related','Farming, fishing, and forestry','Armed forces','Part-time','Temporary','Retired','Unemployed','Independently wealthy');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>View MC Profile</TITLE>
<meta name="description" content="View MC Profile">
<meta name="keywords" content="View MC Profile,View Profile,mc,profile,account,mc account,view account,javascript, dhtml, DHTML">
<style type="text/css">
BODY {margin-left:0; margin-right:0; margin-top:0;text-align:left}
td {font:normal 13px Verdana; color:black;text-align:right;padding:0 6px 0 6px}
h1 {font:bold 28px Verdana; color:black;text-align:center}
h2 {font:bold 24px Verdana;text-align:center}
h3 {font:bold 15px Verdana;}
#t {margin:100px 0 0 0;border:2px solid blue;background-color:#ddd;width:900px}
#j {margin:-607px 0 0 0;}
#b {position:absolute;left:50%;top:60px;margin:0 0 0 -300px;width:600px'}
</style>
<script language="javascript">
mactest=(navigator.userAgent.indexOf("Mac")!=-1)
Netscape=(navigator.appName.indexOf("Netscape") != -1)
msafari=(navigator.userAgent.indexOf("Safari")!= -1)
wsafari=0; if(!mactest&&msafari){wsafari=1;msafari=0}
is_opera = 0; if(window.opera){is_opera=1}
is_ie_mac = 0; is_ie=0;if(document.all){is_ie=1}
if(is_ie&&mactest){is_ie_mac=1}
function fixwidth(){if(mactest&&msafari&&!is_ie_mac){e=document.getElementById('j');e.style.marginTop='-470px';}
if(mactest&&!msafari&&is_ie_mac){alert("This browser is dead. Please use Firefox or Safari.");}
}
</script>
</head>
<body onload="fixwidth()">
<center><h1>View Membership Data</h1></center>
<center>
<?php
function opt($a,$e){
$a=substr($a,1,strlen($a)-2);
$c=explode(",",$a);$x="";
for ($i=0;$i<count($c);$i++) {$x=$x.$e[$c[$i]].", ";}
return substr($x,0,-2);}
$result = mysql_query("SELECT * FROM mc_members WHERE username = '$U'") or die(mysql_error());
$row = mysql_fetch_array($result);
echo "<center><div id='t'><table border='2' id='j'>";
echo "<tr><th colspan='5' style='text-align:center'><b>".htmlentities(stripslashes($row['username']), ENT_QUOTES)."'s Membership</b></th></tr> <BR>";
echo "<tr><th colspan='5' style='text-align:center;background-color:#aaa'> </th></tr><BR>";
echo "<tr><th colspan='5' style='text-align:center;background-color:#eee'><b>Profile:</b></th></tr><BR>";
echo "<tr><td colspan='5' style='text-align:center'><b>Group Name: ".htmlentities(stripslashes($row['groupname']), ENT_QUOTES)."</b></td></tr><br>";
echo "<tr><td colspan='5' style='text-align:center'><b>Location: ".htmlentities(stripslashes($row['city']), ENT_QUOTES).", ";
echo htmlentities(stripslashes($row['state']), ENT_QUOTES)." ";
echo htmlentities(stripslashes($row['zip']), ENT_QUOTES)."</b></td></tr><br>";
echo "<tr><td colspan='5' style='text-align:center'>ID: ".htmlentities(stripslashes($row['id']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td colspan='5' style='text-align:center'>User Name: ".htmlentities(stripslashes($row['username']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td colspan='5' style='text-align:center'>Email Address: ".htmlentities(stripslashes($row['email']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td colspan='5' style='text-align:center'>IP: ".htmlentities(stripslashes($row['ip']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td colspan='5' style='text-align:center'>Signup Date: ".htmlentities(stripslashes($row['signup_date']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><th colspan='5' style='text-align:center;background-color:#aaa'> </th></tr><BR>";
echo "<tr><th colspan='5' style='text-align:center;background-color:#eee'>Group Configuration:</th></tr><BR>";
echo "<tr><td style='text-align:center;width:147px;max-width:147px;min-width:147px;word-wrap:break-word;'><b>Males</b></td><td style='text-align:center;width:147px;max-width:147px;min-width:147px;word-wrap:break-word;'><b>Females</b></td><td style='width:143px;max-width:143px;min-width:143px;word-wrap:break-word;'>Childless: ".htmlentities(stripslashes($row['childless']), ENT_QUOTES)."</td><td style='width:143px;max-width:143px;min-width:143px;word-wrap:break-word;'>White: ".htmlentities(stripslashes($row['white']), ENT_QUOTES)."</td><td style='width:230px;max-width:230px;min-width:230px;word-wrap:break-word;'>Allergies: ".htmlentities(stripslashes($row['allergies']), ENT_QUOTES)."</td></tr><BR>";
echo "<tr><td>0-3 yr: ".htmlentities(stripslashes($row['males03']), ENT_QUOTES)."</td><td>0-3 years old: ".htmlentities(stripslashes($row['females03']), ENT_QUOTES)."</td><td>Empty Nesters: ".htmlentities(stripslashes($row['emptynesters']), ENT_QUOTES)."</td><td>Black: ".htmlentities(stripslashes($row['black']), ENT_QUOTES)."</td><td>Chronic: ".htmlentities(stripslashes($row['chronic']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td>4-7 years old: ".htmlentities(stripslashes($row['males47']), ENT_QUOTES)."</td><td>4-7 years old: ".htmlentities(stripslashes($row['females47']), ENT_QUOTES)."</td><td>Widows: ".htmlentities(stripslashes($row['widows']), ENT_QUOTES)."</td><td>Asian: ".htmlentities(stripslashes($row['asian']), ENT_QUOTES)."</td><td>Mental: ".htmlentities(stripslashes($row['mental']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td>8-11 years old: ".htmlentities(stripslashes($row['males811']), ENT_QUOTES)."</td><td>8-11 years old: ".htmlentities(stripslashes($row['females811']), ENT_QUOTES)."</td><td>Widowers: ".htmlentities(stripslashes($row['widowers']), ENT_QUOTES)."</td><td>Hispanic: ".htmlentities(stripslashes($row['hispanic']), ENT_QUOTES)."</td><td>Disabilities: ".htmlentities(stripslashes($row['disabilities']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td>12-14 years old: ".htmlentities(stripslashes($row['males1214']), ENT_QUOTES)."</td><td>12-14 years old: ".htmlentities(stripslashes($row['females1214']), ENT_QUOTES)."</td><td>Married: ".htmlentities(stripslashes($row['married']), ENT_QUOTES)."</td><td>Hawaiian: ".htmlentities(stripslashes($row['hawaiian']), ENT_QUOTES)."</td><td>Need Ramps: ".htmlentities(stripslashes($row['ramps']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td>15-17 years old: ".htmlentities(stripslashes($row['males1517']), ENT_QUOTES)."</td><td>15-17 years old: ".htmlentities(stripslashes($row['females1517']), ENT_QUOTES)."</td><td>Living Together: ".htmlentities(stripslashes($row['livingtogether']), ENT_QUOTES)."</td><td>Mixed: ".htmlentities(stripslashes($row['mixed']), ENT_QUOTES)."</td><td>Willing to do Eldercare: ".htmlentities(stripslashes($row['willingeldercare']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td>18-23 years old: ".htmlentities(stripslashes($row['males1823']), ENT_QUOTES)."</td><td>18-23 years old: ".htmlentities(stripslashes($row['females1823']), ENT_QUOTES)."</td><td>Separated: ".htmlentities(stripslashes($row['separated']), ENT_QUOTES)."</td><td>Criminal: ".htmlentities(stripslashes($row['criminal']), ENT_QUOTES)."</td><td>Available to do Eldercare: ".htmlentities(stripslashes($row['availableeldercare']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td>24-34 years old: ".htmlentities(stripslashes($row['males2434']), ENT_QUOTES)."</td><td>24-34 years old: ".htmlentities(stripslashes($row['females2434']), ENT_QUOTES)."</td><td>Divorced: ".htmlentities(stripslashes($row['divorced']), ENT_QUOTES)."</td><td>Home Schooled: ".htmlentities(stripslashes($row['homeschooled']), ENT_QUOTES)."</td><td>Need Eldercare: ".htmlentities(stripslashes($row['needeldercare']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td>35-49 years old: ".htmlentities(stripslashes($row['males3549']), ENT_QUOTES)."</td><td>35-49 years old: ".htmlentities(stripslashes($row['females3549']), ENT_QUOTES)."</td><td>Engaged: ".htmlentities(stripslashes($row['engaged']), ENT_QUOTES)."</td><td>Public Schools: ".htmlentities(stripslashes($row['publicschools']), ENT_QUOTES)."</td><td>Willing to do Childcare: ".htmlentities(stripslashes($row['willingchildcare']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td>50-65 years old: ".htmlentities(stripslashes($row['males5065']), ENT_QUOTES)."</td><td>50-65 years old: ".htmlentities(stripslashes($row['females5065']), ENT_QUOTES)."</td><td>Single: ".htmlentities(stripslashes($row['single']), ENT_QUOTES)."</td><td>Private Schools: ".htmlentities(stripslashes($row['privateschools']), ENT_QUOTES)."</td><td>Available to do Childcare: ".htmlentities(stripslashes($row['availablechildcare']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td>66-79 years old: ".htmlentities(stripslashes($row['males6679']), ENT_QUOTES)."</td><td>66-79 years old: ".htmlentities(stripslashes($row['females6679']), ENT_QUOTES)."</td><td>Gay Males: ".htmlentities(stripslashes($row['gaymales']), ENT_QUOTES)."</td><td>Religious Schools: ".htmlentities(stripslashes($row['religiousschools']), ENT_QUOTES)."</td><td>Need Childcare: ".htmlentities(stripslashes($row['needchildcare']), ENT_QUOTES)."</td></tr><br>";
echo "<tr><td>80+ years old: ".htmlentities(stripslashes($row['males80']), ENT_QUOTES)."</td><td>80+ years old: ".htmlentities(stripslashes($row['females80']), ENT_QUOTES)."</td><td>Lesbian: ".htmlentities(stripslashes($row['lesbian']), ENT_QUOTES)."</td><td>Special Schools: ".htmlentities(stripslashes($row['specialschools']), ENT_QUOTES)."</td><td> </td></tr><br>";
echo "<tr><th style='text-align:center' colspan='5'><b>Preferences</b></th></tr><BR>";
$a=htmlentities(stripslashes($row['Smoking_Drinking']), ENT_QUOTES);$e=$Smoking_Drinking;$x=opt($a,$e);
echo "<tr><td colspan='3' style='text-align:left'>Smoking and Drinking: ".$x."</td>";
$a=htmlentities(stripslashes($row['Preferred_Housing_Type']), ENT_QUOTES);$e=$Preferred_Housing_Type;$x=opt($a,$e);
echo "<td colspan='2' style='text-align:left'>Preferred Housing Type: ".$x."</td></tr><br>";
$a=htmlentities(stripslashes($row['Willing_to_relocate']), ENT_QUOTES);$e=$Willing_to_relocate;$x=opt($a,$e);
echo "<tr><td colspan='3' style='text-align:left'>Willing to Relocate: ".$x."</td>";
$a=htmlentities(stripslashes($row['MC_type_sought']), ENT_QUOTES);$e=$MC_type_sought;$x=opt($a,$e);
echo "<td colspan='2' style='text-align:left'>MC Type Sought: ".$x."</td></tr><br>";
$a=htmlentities(stripslashes($row['Open_to_be_in_mixed_race_MC']), ENT_QUOTES);$e=$Open_to_be_in_mixed_race_MC;$x=opt($a,$e);
echo "<tr><td colspan='3' style='text-align:left'>Open to be in Mixed Race MC: ".$x."</td>";
$a=htmlentities(stripslashes($row['Sexuality']), ENT_QUOTES);$e=$Sexuality;$x=opt($a,$e);
echo "<td colspan='2' style='text-align:left'>Sexuality: ".$x."</td></tr><br>";
$a=htmlentities(stripslashes($row['Religious_Openness']), ENT_QUOTES);$e=$Religious_Openness;$x=opt($a,$e);
echo "<tr><td colspan='3' style='text-align:left'>Religious Openness: ".$x."</td>";
$a=htmlentities(stripslashes($row['Religion']), ENT_QUOTES);$e=$Religion;$x=opt($a,$e);
echo "<td colspan='2' style='text-align:left'>Religion: ".$x."</td></tr><br>";
$a=htmlentities(stripslashes($row['Childrearing_Style_and_Preferences']), ENT_QUOTES);$e=$Childrearing_Style_and_Preferences;$x=opt($a,$e);
echo "<tr><td colspan='3' style='text-align:left'>Childrearing Style and Preferences: ".$x."</td>";
$a=htmlentities(stripslashes($row['Pets']), ENT_QUOTES);$e=$Pets;$x=opt($a,$e);
echo "<td colspan='2' style='text-align:left'>Pets: ".$x."</td></tr><br>";
$a=htmlentities(stripslashes($row['Personal_Entertainment']), ENT_QUOTES);$e=$Personal_Entertainment;$x=opt($a,$e);
echo "<tr><td colspan='3' style='text-align:left'>Personal Entertainment: ".$x."</td>";
$a=htmlentities(stripslashes($row['Housing_Interested_in_Common_Shared_Space_for']), ENT_QUOTES);$e=$Housing_Interested_in_Common_Shared_Space_for;$x=opt($a,$e);
echo "<td colspan='2' style='text-align:left'>Housing—Interested in Common Shared Space for: ".$x."</td></tr><br>";
$a=htmlentities(stripslashes($row['Employment']), ENT_QUOTES);$e=$Employment;$x=opt($a,$e);
echo "<tr><td colspan='5' style='text-align:left'>Employment: ".$x."</td></tr><br></table></div>";
mysql_close();
?>
</center>
<br><br>
<div id='b'><form>
<input type="button" style='width:600px' value="Return to MC Search and Match Profile and Account Management" onclick="goback()">
</form></div>
<script language="javascript">
function goback(){window.location ="register-for-mc.php";}
</script>
</body>
</html>