Line #0 : <?php // familygpslookup.php - incorporate all phases of family/fammember select and feedback in one self calling php file
Line #1 : require 'age.php';
Line #2 : // require 'branch.php';
Line #3 : require 'famside.php';
Line #4 : require 'childfamid.php';
Line #5 : require 'fam2mfn.php';
Line #6 : require 'toyl.php';
Line #7 : require_once 'login.php';
Line #8 : require_once 'fmpick.php';
Line #9 : require_once 'fampick.php';
Line #10 : require_once 'fmphoto.php';
Line #11 :
Line #12 : $famid = $indid = $out = $famout = $fileout = $ind_id = $fam_id = '';
Line #13 : $familydir = 'http://www.gystdoit.com/family/';
Line #14 : $imgpre = '<img src="../family/';
Line #15 : $imgsfx = '" width=100 >';
Line #16 : $dir = '../family';
Line #17 : $files = scandir($dir,1);
Line #18 : $filecount = count($files);
Line #19 :
Line #20 : $passedparams = $_SERVER['QUERY_STRING'];
Line #21 : $qstring = explode( "=",$passedparams);
Line #22 : if ($qstring[0]=='family') {
Line #23 : $qfamid = $qstring[1];
Line #24 : $passedparams = "search for family FAM_ID: $qfamid";
Line #25 : } elseif ($qstring[0]=='member') {
Line #26 : $qindid = $qstring[1];
Line #27 : $passedparams = "search for member IND_ID: $qindid";
Line #28 : }
Line #29 :
Line #30 : //$famid = (isset($qfamid)) ? $qfamid : sanitizeString($_POST['famid']);
Line #31 :
Line #32 : if (isset($_POST['famid']))
Line #33 : { $famid = sanitizeString($_POST['famid']);
Line #34 : $link = mysqli_connect($hn, $un, $pw, $db);
Line #35 :
Line #36 : /* check connection */
Line #37 : if (mysqli_connect_errno()) {
Line #38 : printf("Connect failed: %s\n", mysqli_connect_error());
Line #39 : exit();
Line #40 : }
Line #41 : /* create a prepared statement */
Line #42 : if ($stmt = mysqli_prepare($link, "SELECT fam_id, surname,father_id,father,mother_id,mother,wed_date,photo from family WHERE fam_id=?")) {
Line #43 :
Line #44 : mysqli_stmt_bind_param($stmt, "s",$famid);
Line #45 : mysqli_stmt_execute($stmt);
Line #46 : mysqli_stmt_bind_result($stmt, $fam_id, $surname, $father_id, $father, $mother_id, $mother, $wed_date,$photo );
Line #47 : mysqli_stmt_fetch($stmt);
Line #48 : mysqli_stmt_close($stmt);
Line #49 :
Line #50 : echo $str;
Line #51 :
Line #52 : $logo = <<<_END3
Line #53 : <img src="../family/family.jpg" height="80" vspace="5" hspace="20" />
Line #54 : _END3;
Line #55 :
Line #56 :
Line #57 : $portraitname = 'Children of ' . $father . '<br> and ' . $mother;
Line #58 : $portrait = '../family/' . $surname . '_' . $fam_id . '_portrait.svg';
Line #59 : if ( $wed_date == '0000-00-00' ) {
Line #60 : $age = ' ';
Line #61 : $wed_date = '';
Line #62 : } else {
Line #63 : $spousedied = '0000-00-00';
Line #64 : $age = age( $wed_date , $spousedied);
Line #65 : $age = $age . ' Years';
Line #66 : }
Line #67 : $famtype = famside( $fam_id);
Line #68 : if ($famtype == 'D') {
Line #69 : $border = 'purple';
Line #70 : } else {
Line #71 : $border = ($famtype == 'F') ? 'red' : 'blue';
Line #72 : }
Line #73 :
Line #74 :
Line #75 : $branch = substr( $fam_id,0,1);
Line #76 : $branchoutline = '<a href="../family/Branch_' . $branch . '_outline.htm" > Branch Outline </a>';
Line #77 : $branchname = $branchfam[$branch];
Line #78 : $famancestrychart = '<a href="../family/FTD_' . $branchname . '_' . $branch . '.svg" > Family Ancestry Chart </a>';
Line #79 : $mfn = fam2mfn( $fam_id );
Line #80 :
Line #81 : $dadphoto = $imgpre . fmphoto( $father_id ) . $imgsfx;
Line #82 : $momphoto = $imgpre . fmphoto( $mother_id ) . $imgsfx;
Line #83 : if ( strlen($photo) > 10 ) {
Line #84 : $couplepic = $imgpre . $photo . $imgsfx . '<br><br> ';
Line #85 : } else {
Line #86 : $couplepic = '';
Line #87 : }
Line #88 :
Line #89 : // get image files related to either father and mother
Line #90 :
Line #91 : $colcount = 0;
Line #92 : //$fileout = '<table border=1><tr><td>';
Line #93 : $fileout = '';
Line #94 : $indsearch = '_' . str_replace( '.','-',$father_id);
Line #95 : for ($i=0; $i <$filecount; $i++) {
Line #96 : if ( strpos($files[$i] ,$indsearch) > 0) {
Line #97 : $colcount++;
Line #98 : $pathfile = '../family/' . $files[$i];
Line #99 : $fileout = $fileout . ' <a href="' . $pathfile . '">' . $imgpre . $pathfile . $imgsfx . '</a>';
Line #100 : // $fileout = $fileout . ' <td> <a href="' . $pathfile . '">' . $imgpre . $pathfile . $imgsfx . '</a></td> ';
Line #101 : if ( $colcount = 4 ) {
Line #102 : $colcount = 0;
Line #103 : // $fileout = $fileout . "</tr><tr> \n";
Line #104 : }
Line #105 : }
Line #106 : }
Line #107 : // $fileout = $fileout . '</td></tr></table>';
Line #108 :
Line #109 : $indsearch = '_' . str_replace( '.','-',$mother_id);
Line #110 : for ($i=0; $i <$filecount; $i++) {
Line #111 : if ( strpos($files[$i] ,$indsearch) > 0) {
Line #112 : $colcount++;
Line #113 : $pathfile = $dir . '/' . $files[$i];
Line #114 : $fileout = $fileout . ' <a href="' . $pathfile . '">' . $imgpre . $pathfile . $imgsfx . '</a> ';
Line #115 : if ( $colcount = 4 ) {
Line #116 : $colcount = 0;
Line #117 : // $fileout = $fileout . "<br> \n";
Line #118 : }
Line #119 : }
Line #120 : }
Line #121 : // $fileout = $fileout . '</td></tr></table>';
Line #122 :
Line #123 : $indsearch = '_' . $fam_id . '_';
Line #124 : for ($i=0; $i <$filecount; $i++) {
Line #125 : if ( strpos($files[$i] ,$indsearch) > 0) {
Line #126 : $colcount++;
Line #127 : $pathfile = $dir . '/' . $files[$i];
Line #128 : $fileout = $fileout . ' <a href="' . $pathfile . '">' . $imgpre . $pathfile . $imgsfx . '</a> ';
Line #129 : if ( $colcount = 4 ) {
Line #130 : $colcount = 0;
Line #131 : // $fileout = $fileout . "<br> \n";
Line #132 : }
Line #133 : }
Line #134 : }
Line #135 : // $fileout = $fileout . '</td></tr></table>';
Line #136 :
Line #137 : $famout = $famout . '<table border="5" style="border-color:' . $border . '" >';
Line #138 :
Line #139 : $famout = $famout . sprintf("<tr><th>Branch </th><td> <i> %s </i> <br><br><i> %s </i> <br><br><i> %s </i> </td></tr> \n", $branchoutline, $famancestrychart,$mfn );
Line #140 :
Line #141 : $famout = $famout . sprintf("<tr><th>ID </th><td> Fam ID: <i> %s </i> <br><br> Father: <i> %s </i> <br /><br /> Mother: <i> %s </i></td></tr> \n", $fam_id, $father_id, $mother_id );
Line #142 :
Line #143 : $famout = $famout . sprintf("<tr><th>Name </th> <td>Father: <b> %s </b> <br /><br /> Mother: <b> %s </b></td></tr> \n", $father, $mother );
Line #144 :
Line #145 : $famout = $famout . sprintf("<tr><th> Married </th> <td><i> %s </i> %s <i> %s </i> </td></tr> \n", $wed_date,$logo, $age );
Line #146 :
Line #147 : $famout = $famout . sprintf( "<tr><th> Photo </th> <td> %s <br /> %s %s </td></tr> \n", $couplepic,$dadphoto, $momphoto );
Line #148 :
Line #149 :
Line #150 : if ( $portrait) $famout = $famout . sprintf(" <tr><th> Portrait </th> <td> <a href=\" %s \"> %s </a></td></tr> \n", $portrait, $portraitname);
Line #151 :
Line #152 : $famout = $famout . '</table><br>' . $passedparams;
Line #153 :
Line #154 :
Line #155 : }
Line #156 :
Line #157 : /* close connection */
Line #158 : mysqli_close($link);
Line #159 :
Line #160 : } else {
Line #161 : $famout = ' not selected ';
Line #162 : }
Line #163 :
Line #164 :
Line #165 : if (isset($_POST['indid']))
Line #166 : { $indid = sanitizeString($_POST['indid']);
Line #167 : $link = mysqli_connect($hn, $un, $pw, $db);
Line #168 :
Line #169 : /* check connection */
Line #170 : if (mysqli_connect_errno()) {
Line #171 : printf("Connect failed: %s\n", mysqli_connect_error());
Line #172 : exit();
Line #173 : }
Line #174 : /* create a prepared statement */
Line #175 : if ($stmt = mysqli_prepare($link, "SELECT fam_id , ind_id , given , married , born, died, male , photo , obit FROM fam_member WHERE ind_id=?")) {
Line #176 :
Line #177 : /* bind parameters for markers */
Line #178 : mysqli_stmt_bind_param($stmt, "s",$indid);
Line #179 :
Line #180 : /* execute query */
Line #181 : mysqli_stmt_execute($stmt);
Line #182 :
Line #183 : /* bind result variables */
Line #184 : mysqli_stmt_bind_result($stmt, $fam_id , $ind_id , $given , $married , $born , $died, $male , $photo , $obit );
Line #185 :
Line #186 : /* fetch value */
Line #187 : mysqli_stmt_fetch($stmt);
Line #188 :
Line #189 : echo $str;
Line #190 :
Line #191 : $gender = ( $male == 'F' ) ? 'Female' : 'Male';
Line #192 : $portraitname = $portrait = '';
Line #193 : $pos = strpos($ind_id, '.0'); // if nonblood use married name for portrait
Line #194 : if ( $pos ) {
Line #195 : if ($male == "T") {
Line #196 : $fullname = explode( " ",$given);
Line #197 : $surname = $fullname[ count($fullname) - 1 ];
Line #198 : $portraitname = 'Children of ' . $given;
Line #199 : $portrait = '../family/' . $surname . '_' . $fam_id . '_portrait.svg';
Line #200 : }
Line #201 : if ($married) {
Line #202 : $fullname = explode( " ",$married);
Line #203 : $surname = $fullname[ count($fullname) - 1 ];
Line #204 : $portraitname = 'Children of ' . $married;
Line #205 : $portrait = '../family/' . $surname . '_' . $fam_id . '_portrait.svg';
Line #206 : }
Line #207 : } else {
Line #208 : $fullname = explode( " ",$given);
Line #209 : $surname = $fullname[ count($fullname) - 1 ];
Line #210 : $portraitname = 'Siblings of ' . $given;
Line #211 : $portrait = '../family/' . $surname . '_' . $fam_id . '_portrait.svg';
Line #212 :
Line #213 : if ($male == "T") {
Line #214 : $fullname = explode( " ",$given);
Line #215 : $surname = $fullname[ count($fullname) - 1 ];
Line #216 : $childportraitname = 'Children of ' . $given;
Line #217 : $childfamid = childfamid( $ind_id);
Line #218 : $childportrait = '../family/' . $surname . '_' . $childfamid . '_portrait.svg';
Line #219 : } else {
Line #220 : $fullname = explode( " ",$married);
Line #221 : $surname = $fullname[ count($fullname) - 1 ];
Line #222 : $childportraitname = 'Children of ' . $given;
Line #223 : $childfamid = childfamid( $ind_id);
Line #224 : $childportrait = '../family/' . $surname . '_' . $childfamid . '_portrait.svg';
Line #225 : }
Line #226 : }
Line #227 : if ( $born == '0000-00-00' ) {
Line #228 : $age = ' ';
Line #229 : $born = '';
Line #230 : $birthsign = '';
Line #231 : } else {
Line #232 : $age = age( $born , $died);
Line #233 : $sborn = str_replace('-','',$born);
Line #234 : $sdied = str_replace('-','',$died);
Line #235 : $birthsign = toyl2($sborn,$sdied);
Line #236 : }
Line #237 :
Line #238 : $famtype = famside( $ind_id);
Line #239 :
Line #240 : if ($famtype == 'D') {
Line #241 : $border = 'purple';
Line #242 : } else {
Line #243 : $border = ($famtype == 'F') ? 'red' : 'blue';
Line #244 : }
Line #245 : $branch = substr( $fam_id,0,1);
Line #246 : $branchoutline = '<a href="../family/Branch_' . $branch . '_outline.htm" > Branch </a>';
Line #247 : $branchname = $branchfam[$branch];
Line #248 : $famancestrychart = '<a href="../family/FTD_' . $branchname . '_' . $branch . '.svg" > Family Ancestry Chart </a>';
Line #249 :
Line #250 : $mfn2 = fam2mfn( $ind_id );
Line #251 :
Line #252 : if ($ind_id) {
Line #253 : $dir = '../family';
Line #254 : $files = scandir($dir,1);
Line #255 : $filecount = count($files);
Line #256 : $colcount = 0;
Line #257 : //$fileout = '<table border=1><tr><td>';
Line #258 : $fileout ='';
Line #259 : $indsearch = '_' . str_replace( '.','-',$ind_id);
Line #260 :
Line #261 : for ($i=0; $i <$filecount; $i++) {
Line #262 : if ( strpos($files[$i] ,$indsearch) > 0) {
Line #263 : $colcount++;
Line #264 : $fmfile =$files[$i];
Line #265 : $fname = explode('.',$fmfile);
Line #266 : $fext = $fname[1];
Line #267 : $pathfile = '../family/' . $fmfile;
Line #268 : $fileout = $fileout . ' <a href="' . $pathfile . '"> ';
Line #269 : if ($fext =='jpg') {
Line #270 : $fileout = $fileout . '<img src="' . $pathfile . '" height="100"></a> ' ;
Line #271 : } else {
Line #272 : $fileout = $fileout . $fmfile . '</a> ' ;
Line #273 : }
Line #274 : if ( $colcount = 4 ) {
Line #275 : $colcount = 0;
Line #276 : }
Line #277 : }
Line #278 : }
Line #279 : }
Line #280 :
Line #281 : $out = $out . '<table border="5" style="border-color:' . $border . '" >';
Line #282 :
Line #283 : $out = $out . sprintf("<tr><th>Branch </th><td> <i> %s </i> <br /> <br /> <i> %s </i> <br /> <br /> <i> %s </i> </td></tr> \n", $branchoutline,$famancestrychart, $mfn2 );
Line #284 :
Line #285 : $out = $out . sprintf("<tr><th> ID </th><td> Fam: <i> %s </i> <br /><br /> Individual: <i> %s </i></td></tr> \n", $fam_id , $ind_id );
Line #286 :
Line #287 : $out = $out . sprintf("<tr><th>Given </th> <td><h2> %s </h2> </td></tr> \n", $given );
Line #288 :
Line #289 : if ( $married) $out = $out . sprintf("<tr><th> Married </th> <td><h2> %s </h2> </tr> \n", $married);
Line #290 :
Line #291 : $out = $out . sprintf("<tr><th> Dates </th> <td> Birth: <i> %s </i> ", $born );
Line #292 :
Line #293 : if ( $died != '0000-00-00') {
Line #294 : $out = $out . sprintf(" <br><br> Died: <i style='color:red;'> %s </i></td></tr> </tr> \n" , $died);
Line #295 : $out = $out . sprintf(" <tr><th> Obituary </th> <td> <a href='../family/%s '> %s </td></tr> \n", $obit, $obit);
Line #296 : }
Line #297 : else
Line #298 : { $out = $out . "</td></tr> \n";
Line #299 : }
Line #300 :
Line #301 : $out = $out . sprintf("<tr><th> Age </th> <td> <h3> %s </h3> </td></tr> \n", $age );
Line #302 : $out = $out . sprintf("<tr><th> Photo </th> <td> <img src='../family/%s ' height=100 > <h4> %s </h4> </td></tr> \n", $photo, $photo );
Line #303 :
Line #304 : if (file_exists($portrait)) $out = $out . sprintf(" <tr><th> Portrait </th> <td> <a href=' %s '> %s </a> \n", $portrait, $portraitname );
Line #305 :
Line #306 : $out = $out . sprintf(" <br /> <br /> <a href=' %s '> %s </a> \n", $childportrait, $childportraitname);
Line #307 :
Line #308 :
Line #309 : $out = $out . sprintf("<tr><th> Gender </th> <td> <h3> %s </h3> </td></tr> \n", $gender );
Line #310 :
Line #311 : $out = $out . "</td></tr></table> </td><td> ";
Line #312 :
Line #313 : $out = $out . sprintf(" %s \n", $birthsign );
Line #314 :
Line #315 : $out = $out . "</td><td><b>$fileout</b> </td></tr></table> \n";
Line #316 :
Line #317 :
Line #318 : /* close statement */
Line #319 : mysqli_stmt_close($stmt);
Line #320 : }
Line #321 :
Line #322 : /* close connection */
Line #323 : mysqli_close($link);
Line #324 :
Line #325 : } else {
Line #326 : $out = ' not selected ';
Line #327 : }
Line #328 :
Line #329 :
Line #330 : echo <<<_END
Line #331 : <html>
Line #332 : <head>
Line #333 : <title>Family GPS Lookup </title>
Line #334 : <link rel="stylesheet" type="text/css" href="SPC.CSS" />
Line #335 : </head>
Line #336 : <body>
Line #337 :
Line #338 : <TABLE BORDER=1 > <TR><TD>
Line #339 :
Line #340 :
Line #341 :
Line #342 : <form method="post" action="familygpslookup.php">
Line #343 :
Line #344 :
Line #345 : <TABLE BORDER=1 >
Line #346 : <TR><TH> Family </TH>
Line #347 : </TR>
Line #348 : <TR>
Line #349 : <TD> Family ID <input type="text" name="famid" class="famid" size="7">
Line #350 : </TD>
Line #351 : </TR><TR>
Line #352 : <TD> $fampicklist
Line #353 : </TD>
Line #354 : </TR><TR>
Line #355 : <TD> <h2> Family GPS</h2>
Line #356 :
Line #357 : </TD>
Line #358 : </TR> <tr><TH> Family Member </TH></tr>
Line #359 : <tr><td> Individual ID <input type="text" name="indid" class="indid" size="7">
Line #360 : </td>
Line #361 : </TR><TR>
Line #362 : <td> $picklist
Line #363 : </td>
Line #364 : </TR><TR>
Line #365 : <td> <input type="submit" value="Search">
Line #366 : </td></tr>
Line #367 : </TABLE>
Line #368 :
Line #369 : <i>Search Family and/or
Line #370 : <br>Family Member table
Line #371 : <br>on ID number </i>
Line #372 : </form>
Line #373 :
Line #374 : <button onclick="document.getElementById('famsearch').style.display='none'; ">Hide Family</button>
Line #375 : <button onclick="document.getElementById('famsearch').style.display='block'; ">Show Family</button><br />
Line #376 : <button onclick="document.getElementById('indsearch').style.display='none'; ">Hide Member</button>
Line #377 : <button onclick="document.getElementById('indsearch').style.display='block'; ">Show Member</button>
Line #378 : </TD><TD>
Line #379 :
Line #380 :
Line #381 : <TABLE BORDER=1 ><TR><TH> Family </TH><TH> Family Member </TH>
Line #382 : </TR>
Line #383 : <TR><TD id="famsearch"> <b>$famout</b> </TD><TD id="indsearch"> <b>$out</b> </TD>
Line #384 : </TR></TABLE>
Line #385 :
Line #386 : </TD></TR></TABLE><br>
Line #387 : <b>$passedparams</b>
Line #388 : </body>
Line #389 : </html>
Line #390 : _END;
Line #391 :
Line #392 : function sanitizeString($var)
Line #393 : {
Line #394 : $var = stripslashes($var);
Line #395 : $var = strip_tags($var);
Line #396 : $var = htmlentities($var);
Line #397 : return $var;
Line #398 : }
Line #399 :
Line #400 : ?>