<?php
// enter attribute data when selected from survey.php
include("config.php");
include($baseDir . "common/_func.php");
//if user is not logged in, redirect to homepage
if(!isset($uID)){header("Location: http://www.netvis.org");exit;}
//if user is logged in as demo, redirect to homepage
demoRedirect($username);
if(!isset($name_exist)){
$name_exist=FALSE;
}
if(!isset($name_unique)){
$name_unique=FALSE;
}
// if current is not registered
if(!session_is_registered("current") || $current=="0"){
// define variables
$array_variables = array("netname","netnum","age","sex","known","distance","media","other","comm","close","otherMatrix","otherMatrixText","otherText","otherScale","otherScale1","otherScale2","otherScale3","otherScale4","otherScale5","geodis");
for($i=0; $i<count($array_variables); $i++){
$array_variable=$array_variables[$i];
if(!isset(${$array_variable})){
${$array_variable}=FALSE;
}
}
$geo=$geodis;
$error_netname=$netname;
$error_netnum=$netnum;
$error_age=$age;
$error_sex=$sex;
$error_known=$known;
$error_distance=$distance;
$error_media=$media;
$error_other=$other;
$error_comm=$comm;
$error_close=$close;
$error_otherMatrix=$otherMatrix;
$error_otherMatrixText=$otherMatrixText;
$error_otherText=$otherText;
$error_otherScale=$otherScale;
$error_otherScale1=$otherScale1;
$error_otherScale2=$otherScale2;
$error_otherScale3=$otherScale3;
$error_otherScale4=$otherScale4;
$error_otherScale5=$otherScale5;
//replace bad characters in network name
$netname=removeSpaces($netname);
//determine whether network name was entered or unique
$sqlNetworks="SELECT * FROM networks WHERE uID=$uID AND netname=\"$netname\"";
$resultNetworks=mysql_query($sqlNetworks) or die(sqlError($sqlNetworks));
//if netnames are not unique, assign error variables
if(mysql_num_rows($resultNetworks)!=0 || $netname=="EnterNameHere" || $netname==""){
$error=1;
//set error message about network name
$error_message = "<script>function confirmError(){if(window.confirm (\"Please return to survey.php and enter a unique name for your social network \")){document.location=\"survey.php\"}else{document.location=\"survey.php\"}}javascript:confirmError()</script>";
echo "$error_message";
exit;
}
//determine whether network number was entered
if($netnum=="0" || $netnum==""){
$error=2;
//set error message about network name
$error_message = "<script>function confirmError(){if(window.confirm (\"Please return to survey.php and enter a number greater than zero for your social network \")){document.location=\"survey.php\"}else{document.location=\"survey.php\"}}javascript:confirmError()</script>";
echo "$error_message";
exit;
}
//determine whether matrices were entered
if($error_comm==FALSE && $error_close==FALSE && $error_otherMatrix==FALSE){
$error=4;
//set error message about network name
$error_message = "<script>function confirmError(){if(window.confirm (\"Please return to survey.php and enter at least one attribute for your social network \")){document.location=\"survey.php\"}else{document.location=\"survey.php\"}}javascript:confirmError()</script>";
echo "$error_message";
exit;
}
//code for all possible combinations of matrices
if($error_comm=="1") {
$display_matrix=1;
$start_matrix=1;
}
if($error_close=="1") {
$display_matrix=2;
$start_matrix=2;
}
if($error_otherMatrix=="1") {
$display_matrix=3;
$start_matrix=3;
}
if($error_comm=="1" && $error_close=="1") {
$display_matrix=4;
$start_matrix=1;
}
if($error_comm=="1" && $error_otherMatrix=="1") {
$display_matrix=5;
$start_matrix=1;
}
if($error_close=="1" && $error_otherMatrix=="1") {
$display_matrix=6;
$start_matrix=2;
}
if($error_comm=="1" && $error_close=="1" && $error_otherMatrix=="1") {
$display_matrix=7;
$start_matrix=1;
}
//determine whether network is ego or complete
switch($dataset){
case 1:
$ego=1;
break;
case 2:
$ego=0;
break;
}
$sql= "INSERT INTO networks SET ".
"uID='$uID',".
"datetime=\"".date("Y-m-d G:i:s")."\",".
"netname='$netname',".
"netnum='$netnum',".
"upload=0, distance=$geodis, ego=$ego, split=0, reverse=1, discussion=0";
mysql_query($sql) or die(sqlError($sql));
//if ego network, enter people db values
if($ego=="1"){
$sqlUser= "SELECT * FROM user WHERE uID=$uID";
$resultUser=mysql_query($sqlUser);
$rowUser=mysql_fetch_array($resultUser);
$name=$rowUser['fname'] . " " . substr($rowUser['lname'],0,1);
//replace bad characters in names
$name=removeSpaces($name);
$sqlPeople="INSERT INTO people SET ".
"uID=\"$uID\",".
"datetime=\"".date("Y-m-d G:i:s")."\",".
"network=\"".$netname."\",".
"name=\"".$name."\",".
"age=".$rowUser['age'].",".
"sex=".$rowUser['sex']."";
mysql_query($sqlPeople) or die(sqlError($sqlPeople));
//indicate number of people to ask questions about
$peoples=$netnum;
}else{
$peoples=$netnum+1;
}
session_register("current");
$current=1;
}
if(!isset($geodis)){
$geodis=FALSE;
}
if($geodis=="1"){
if(!isset($geodis_complete)){
$geodis_complete=FALSE;
}
if($geodis_complete=="1"){
// define variables
$array_variables = array("city","state","country","zip","timezone","daylight","latitude","longitude","otherMatrix","otherMatrixText","otherText","otherScale");
for($i=0; $i<count($array_variables); $i++){
$array_variable=$array_variables[$i];
if(!isset(${$array_variable})){
${$array_variable}=FALSE;
}
}
$error_city=$city;
$error_state=$state;
$error_country=$country;
$error_zip=$zip;
$error_timezone=$timezone;
$error_daylight=$daylight;
$error_latitude=$latitude;
$error_longitude=$longitude;
$error_otherMatrix=$otherMatrix;
$error_otherMatrixText=$otherMatrixText;
$error_otherText=$otherText;
$error_otherScale=$otherScale;
$error_otherScale1=$otherScale1;
$error_otherScale2=$otherScale2;
$error_otherScale3=$otherScale3;
$error_otherScale4=$otherScale4;
$error_otherScale5=$otherScale5;
//code for all possible combinations of matrices
if($error_comm=="1") {
$display_matrix=1;
$start_matrix=1;
}
if($error_close=="1") {
$display_matrix=2;
$start_matrix=2;
}
if($error_otherMatrix=="1") {
$display_matrix=3;
$start_matrix=3;
}
if($error_comm=="1" && $error_close=="1") {
$display_matrix=4;
$start_matrix=1;
}
if($error_comm=="1" && $error_otherMatrix=="1") {
$display_matrix=5;
$start_matrix=1;
}
if($error_close=="1" && $error_otherMatrix=="1") {
$display_matrix=6;
$start_matrix=2;
}
if($error_comm=="1" && $error_close=="1" && $error_otherMatrix=="1") {
$display_matrix=7;
$start_matrix=1;
}
}else{
header("Location: survey_geo.php");
exit;
}
}
//cycle through until number of people to ask questions about has been reached
if($current <= $peoples){
if(!isset(${"name".$current})){
${"name".$current}=NULL;
}
$name_current=${"name".$current};
//replace bad characters in name
$name_current=removeSpaces($name_current);
//determine whether people name was entered
if($name_current){
$name_exist="0";
//determine whether people name was unique
$sqlPeople="SELECT * FROM people WHERE uID=$uID AND network=\"$error_netname\" AND name=\"$name_current\"";
$resultPeople=mysql_query($sqlPeople) or die(sqlError($sqlPeople));
$rowPeople=mysql_fetch_array($resultPeople);
if(mysql_num_rows($resultPeople)=="0"){
$name_unique="0";
}else{
$name_unique="1";
}
}else{
$name_exist="1";
}
if($current>=1 && $name_exist=="0" && $name_unique=="0"){
// define variables
$array_variables = array("age","sex","known","distance","other","ftf","pho","ema","im","city","state","country","zip","timezone","daylight","latitude","longitude");
for($i=0; $i<count($array_variables); $i++){
$array_variable=$array_variables[$i].$current;
if(!isset(${$array_variable})){
${$array_variable}=FALSE;
}
}
$sqlPeople = "INSERT INTO people SET ".
"uID=\"$uID\",".
"datetime=\"".date("Y-m-d G:i:s")."\",".
"network=\"$error_netname\",".
"name='$name_current'";
if($error_age!=FALSE){
$sqlPeople.= ",age='${"age".$current}'";
}
if($error_sex!=FALSE){
$sqlPeople.= ",sex='${"sex".$current}'";
}
if($error_known!=FALSE){
$sqlPeople.= ",known='${"known".$current}'";
}
if($error_distance!=FALSE){
$sqlPeople.= ",distance='${"distance".$current}'";
}
if($error_other!=FALSE){
$sqlPeople.= ",other='${"other".$current}'";
}
if($error_media!=FALSE){
$sqlPeople.= ",ftf='${"ftf".$current}'";
}
if($error_media!=FALSE){
$sqlPeople.= ",pho='${"pho".$current}'";
}
if($error_media!=FALSE){
$sqlPeople.= ",ema='${"ema".$current}'";
}
if($error_media!=FALSE){
$sqlPeople.= ",im='${"im".$current}'";
}
if($error_city!=FALSE){
$sqlPeople.= ",city='${"city".$current}'";
}
if($error_state!=FALSE){
$sqlPeople.= ",state='${"state".$current}'";
}
if($error_country!=FALSE){
$sqlPeople.= ",country='${"country".$current}'";
}
if($error_zip!=FALSE){
$sqlPeople.= ",zip='${"zip".$current}'";
}
if($error_timezone!=FALSE){
$sqlPeople.= ",timezone='${"timezone".$current}'";
}
if($error_daylight!=FALSE){
$sqlPeople.= ",daylight='${"daylight".$current}'";
}
if($error_latitude!=FALSE){
$sqlPeople.= ",latitude='${"latitude".$current}'";
}
if($error_longitude!=FALSE){
$sqlPeople.= ",longitude='${"longitude".$current}'";
}
;
mysql_query($sqlPeople) or die(sqlError($sqlPeople));
}
if($name_exist=="0" && $name_unique=="0"){
$current++;
}
if($current==$peoples){
header("Location: survey_matrix.php");
exit;
}
include($baseDir . "common/_javascript.php");
include($baseDir . "common/_header.php");
?>
<center>
<table width=700 border=0 cellspacing=0 cellpadding=1 bordercolor=#006699>
<tr bgcolor=#CCCCCC align=center>
<td nowrap bgcolor=#FFFFFF height=22>
<div align='left'><a href='logout.php'><font color=#006699>Home</font></a>
> <a href="socialnetworks.php"><font color=#006699>Social
Networks</font></a> > Data</div>
</td>
<td nowrap bgcolor=#FFFFFF height=22>
<div align='right'>
<?php
include($baseDir . "common/_options.php");
?>
</div>
</td>
</tr>
</table>
<form method=post action="<?php echo $PHP_SELF?>" name="form">
<center>
<table width="700" border="1" cellspacing="0" cellpadding="1">
<font size='+2'>Please describe the <?php writeNumber($current) ?> relationship in your <?php echo $error_netname ?> social network</font>
<tr>
<td bgcolor=#006699 width="11%"><font color=#FFFFFF>#
<?php echo $current?>
</font></td>
<td bgcolor=#006699 width='42%'>
<div align=center><font color=#FFFFFF>Name (First Name and Last Initial)</font>
</div>
</td>
<td bgcolor=#eeeeee width='47%'>
<input onKeyPress='if(window.event.keyCode==13) {
document.forms[0].jsenabled.value = "T";document.forms[0].submit();return false; }'
maxlength=64 size=32 name="name<?php echo $current ?>">
<?
if($name_exist=="1"){
echo "<font color=#ff0000><br>(Required Field)</font>";
$name_exist=0;
}
if($name_unique=="1"){
echo "<font color=#ff0000><br>(Enter Unique Name)</font>";
$name_unique=0;
}
?>
</td>
</tr>
<?php
// if age was selected, then display on page
if($error_age!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"> <font color=\"#FFFFFF\">Age </font></td>
<td bgcolor=#CCCCCC width=\"47%\"><input type=\"hidden\" name=\"age\" value=1>
<input maxlength=4 size=4 name=\"age$current\">
years
</td>
</tr>
";
}
// if sex was selected, then display on page
if($error_sex!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"> <font color=\"#FFFFFF\">Sex</font></td>
<td bgcolor=#CCCCCC width=\"47%\"><input type=\"hidden\" name=\"sex\" value=1>
<input type=radio name=\"sex$current\" value=1>
Male
<input type=radio name=\"sex$current\" value=2>
Female </td>
</tr>
";
}
// if known was selected, then display on page
if($error_known!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"><font color=\"#FFFFFF\">How long have you
known him/her?</font></td>
<td bgcolor=#eeeeee width=\"47%\"><input type=\"hidden\" name=\"comm\" value=1>
<input type=radio name=\"known$current\" value=1>
< 1 month<br>
<input type=radio name=\"known$current\" value=2>
< 3 months<br>
<input type=radio name=\"known$current\" value=3>
< 6 months<br>
<input type=radio name=\"known$current\" value=4>
< 1 year<br>
<input type=radio name=\"known$current\" value=5>
< 2 years<br>
<input type=radio name=\"known$current\" value=6>
< 3 years<br>
<input type=radio name=\"known$current\" value=7>
3+ years</td>
</tr>
";
}
// if distance was selected, then display on page
if($error_distance!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"><font color=\"#FFFFFF\">How
close to you does he/she live?</font></td>
<td bgcolor=#CCCCCC width=\"47%\"><input type=\"hidden\" name=\"close\" value=1>
<input type=radio name=\"distance$current\" value=1>
Same building<br>
<input type=radio name=\"distance$current\" value=2>
Same neighborhood<br>
<input type=radio name=\"distance$current\" value=3>
Same town<br>
<input type=radio name=\"distance$current\" value=4>
Same state<br>
<input type=radio name=\"distance$current\" value=5>
Same country<br>
<input type=radio name=\"distance$current\" value=6>
Further away</td>
</tr>
";
}
// if media was selected, then display on page
if($error_media!=FALSE) {
echo "
<tr valign=\"center\">
<td valign=\"center\" colspan=3>
<table border=\"0\" cellpadding=\"2\">
<tr valign=\"center\" bgcolor=#006699>
<td valign=\"center\" colspan=\"8\" align=center>
<div align=\"left\"><font color=\"#FFFFFF\">How frequently do you communicate with this person using these modes of communication?</font></div>
</td>
</tr>
<tr valign=\"center\" bgcolor=#006699>
<td valign=\"center\" width=30% align=center></td>
<td valign=\"center\" width=10% align=center><font color=\"#FFFFFF\">Never</font></td>
<td valign=\"center\" width=10% align=center><font color=\"#FFFFFF\">Every
few months</font></td>
<td valign=\"center\" width=10% align=center><font color=\"#FFFFFF\">Every
few weeks</font></td>
<td valign=\"center\" width=10% align=center><font color=\"#FFFFFF\">1-2
days a week</font></td>
<td valign=\"center\" width=10% align=center><font color=\"#FFFFFF\">3-5
days a week</font></td>
<td valign=\"center\" width=10% align=center><font color=\"#FFFFFF\">About
once a day</font></td>
<td valign=\"center\" width=10% align=center><font color=\"#FFFFFF\">Several
times a day</font></td>
</tr>
<tr valign=\"center\" bgcolor=\"#CCCCCC\">
<td valign=\"center\" > a. In person</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ftf$current\" value=1>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ftf$current\" value=2>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ftf$current\" value=3>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ftf$current\" value=4>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ftf$current\" value=5>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ftf$current\" value=6>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ftf$current\" value=7>
</td>
</tr>
<tr valign=\"center\" bgcolor=\"#CCCCCC\">
<td valign=\"center\" >b. By phone</td>
<td valign=\"center\" align=center>
<input type=radio name=\"pho$current\" value=1>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"pho$current\" value=2>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"pho$current\" value=3>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"pho$current\" value=4>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"pho$current\" value=5>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"pho$current\" value=6>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"pho$current\" value=7>
</td>
</tr>
<tr valign=\"center\" bgcolor=\"#CCCCCC\">
<td valign=\"center\" > c. By e-mail</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ema$current\" value=1>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ema$current\" value=2>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ema$current\" value=3>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ema$current\" value=4>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ema$current\" value=5>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ema$current\" value=6>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"ema$current\" value=7>
</td>
</tr>
<tr valign=\"center\" bgcolor=\"#CCCCCC\">
<td valign=\"center\"> d. By instant messaging </td>
<td valign=\"center\" align=center>
<input type=radio name=\"im$current\" value=1>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"im$current\" value=2>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"im$current\" value=3>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"im$current\" value=4>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"im$current\" value=5>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"im$current\" value=6>
</td>
<td valign=\"center\" align=center>
<input type=radio name=\"im$current\" value=7>
</td>
</tr>
</table>
</td>
</tr>
";
}
// if city was selected, then display on page
if($error_city!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"> <font color=\"#FFFFFF\">City</font></td>
<td bgcolor=#CCCCCC width=\"47%\"><input type=\"hidden\" name=\"city\" value=1>
<input maxlength=25 size=25 name=\"city$current\">
</td>
</tr>
";
}
// if state was selected, then display on page
if($error_state!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"> <font color=\"#FFFFFF\">State </font></td>
<td bgcolor=#CCCCCC width=\"47%\"><input type=\"hidden\" name=\"state\" value=1>
<input maxlength=25 size=25 name=\"state$current\">
</td>
</tr>
";
}
// if country was selected, then display on page
if($error_country!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"> <font color=\"#FFFFFF\">Country </font></td>
<td bgcolor=#CCCCCC width=\"47%\"><input type=\"hidden\" name=\"country\" value=1>
<input maxlength=25 size=25 name=\"country$current\">
</td>
</tr>
";
}
// if zip was selected, then display on page
if($error_zip!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"> <font color=\"#FFFFFF\">ZIP CODE </font></td>
<td bgcolor=#CCCCCC width=\"47%\"><input type=\"hidden\" name=\"zip\" value=1>
<input maxlength=11 size=11 name=\"zip$current\">
</td>
</tr>
";
}
// if timezone was selected, then display on page
if($error_timezone!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"> <font color=\"#FFFFFF\">Time Zone (GMT = 0) </font></td>
<td bgcolor=#CCCCCC width=\"47%\"><input type=\"hidden\" name=\"timezone\" value=1>
<input maxlength=3 size=3 name=\"timezone$current\">
</td>
</tr>
";
}
// if daylight was selected, then display on page
if($error_daylight!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"> <font color=\"#FFFFFF\">Daylight Savings</font></td>
<td bgcolor=#CCCCCC width=\"47%\"><input type=\"hidden\" name=\"daylight\" value=1>
<input type=radio name=\"daylight$current\" value=1>Yes
<input type=radio name=\"daylight$current\" value=2>No
</td>
</tr>
";
}
// if latitude was selected, then display on page
if($error_latitude!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"> <font color=\"#FFFFFF\">Latitude </font></td>
<td bgcolor=#CCCCCC width=\"47%\"><input type=\"hidden\" name=\"latitude\" value=1>
<input maxlength=5 size=5 name=\"latitude$current\">
</td>
</tr>
";
}
// if longitude was selected, then display on page
if($error_longitude!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"> <font color=\"#FFFFFF\">Longitude </font></td>
<td bgcolor=#CCCCCC width=\"47%\"><input type=\"hidden\" name=\"longitude\" value=1>
<input maxlength=5 size=5 name=\"longitude$current\">
</td>
</tr>
";
}
// if other was selected, then display on page
if($error_other!=FALSE) {
echo "
<tr>
<td bgcolor=#006699 colspan=\"2\"><font color=\"#FFFFFF\">$error_otherText</font></td>
<td bgcolor=#eeeeee width=\"47%\"><input type=\"text\" name=\"otherText\" size=\"50\"></td>
</tr>
";
}
?>
<tr valign=center>
<td valign=center colspan=3>
</table>
</center>
<center><br>
<table width=700 border=0 cellspacing=0 cellpadding=1>
<tr>
<td align=center>
<a class=smalltext onClick='document.forms[0].jsenabled.value = "T";document.forms[0].submit(); return false;' href="<?php echo $PHP_SELF ?>"><img alt="Submit" src="<?php echo $url . "/img/submit.gif"; ?>" border=0 width="59" height="17"></a>
</td>
</tr>
<input type="hidden" value="F" name="jsenabled">
<input type="hidden" value="9" name="process">
</form>
</table>
</center>
<br>
<SCRIPT LANGUAGE="JavaScript">
form.name<?php echo $current ?>.focus()
</SCRIPT>
<?php
include($baseDir . "common/_footer.php");
}
?>