<tr><td> <div class=input1> <table border=0 cellpadding=2 cellspacing=0><tr height=36px><td width=35px valign=top> <img src="fid.gif" <?php /*"monkey.gif" height=32*/ ?> ></td><td> <font color=000055><b><?php echo $_GET["studyid"]; ?> </b> : </font> <?php /* Subject: <font color=800000> */ $conn = @mysql_connect("localhost", "root", "mysqlrootpassword") or die("error: could not connect to db"); mysql_select_db("cdfi", $conn) or die("error: could not select db: " . mysql_error()); $study = read_study_table($_GET["studyid"]); $editon = 0; if (isset($_GET["edit"]) && $_GET["edit"] == 1) { $editon = 1; } $editoff = 0; if (isset($_GET["edit"]) && $_GET["edit"] == 0) { $editoff = 1; } // edit if the desc or subj is blank, but only if user did not say to cancel changes // OR edit if clicked Edit if (!$editoff && (!strlen($study["description"]) || !strlen($study["subject"])) || $editon) { ?> <br> <div style="margin-left:8px; margin-top:5px; margin-bottom:5px; border-style:solid; border-color:#008000; padding:3px; width:100%; border-radius:4pt; background-color:#DDEEDD"> <form name="study_info" action="update_studies_table_info.php" method="post">
function process_fid_dir($fulldirname, $dirname) { global $fulldir; global $fullstudyid; list($protocol, $runno) = split('[_.]', $dirname); // e.g.: epidw _ 01 // skip spuls; note that most sems are just setting power and so aren't useful //if ($protocol != 'epidw' && $protocol != 'gems' && strncmp($protocol, 'T1map2', 6) && $protocol != 'sems') // return; $dataname = $protocol . "_" . $runno; // rebuild last part without 'data/' prefix //print_r($a); $procparname = $fulldirname . "/procpar"; //$fulldir."/".$a['DATA'].".fid/procpar"; $fd = fopen($procparname, "r"); if ($fd == false) { //echo "could not open: ".$procparname; return; } else { /* echo "opened: ".$procparname; */ } $procvals = read_procpar($fd); fclose($fd); // make sure row not already uploaded first: use studyid (s_200xxxxx/mark) and dataname (epidw_xx) // DECISION: for now, allow same study (same studyid+dataname) to be uploaded (which means one uploaded // from 'Upload Fid' and one from 'Discover Data'. So, a duplicate would be same studyid+dataname and // also fulldir is not blank, which means this data has been discovered before: // REMINDER: studyid field in database is constructed from procpar studyid + '/' + operator !!! $fullstudyid = $procvals['studyid'] . "/" . $procvals['operator']; $check = "SELECT id,pathname FROM fid_files WHERE deleted='N' AND studyid=\"" . $fullstudyid . "\" AND dataname=\"" . $dataname . "\""; $q = mysql_query($check) or die("discover_this: mysql select error: " . mysql_error()); if (mysql_error() != "") { echo "mysql select error: " . mysql_error(); exit; } if (mysql_num_rows($q) > 0) { //echo "discover data found that studyid=".$procvals['studyid'].", dataname=".$dataname." is already in the database... "; while ($row = mysql_fetch_array($q, MYSQL_ASSOC)) { if ($row['pathname'] != "") { //echo "skipping because fulldir is not blank\n"; return; } } //echo "adding again.\n"; } $sql = "INSERT INTO fid_files (when_uploaded,exp_date,shots,consecutive,num_images,num_slices,time_run,comment,studyid,dataname,pathname,run_type,run_no,n_no,tr_s,te_s,orient,slice_thickness,slice_offset,gap,mtx_ro,mtx_pe,fov_ro,fov_pe,ms_intlv,gain,power,rfcoil,fatsat,ky_order,fract_ky,epi_pc) VALUES ("; $sql .= "NOW()"; $sql .= ", \"" . $procvals['exp_date'] . "\""; $sql .= ", " . $procvals['nseg']; $sql .= ", \"" . $procvals['consec'] . "\""; $sql .= ", " . $procvals['num_images']; $sql .= ", " . $procvals['num_slices']; $sql .= ", \"" . $procvals['time_run'] . "\""; $sql .= ", \"" . mysql_escape_string($procvals['comment']) . "\""; $sql .= ", \"" . $fullstudyid . "\""; // no subject in procpar! : $sql .= ", \"" . $procvals['subject'] . "\""; $sql .= ", \"" . $dataname . "\""; $sql .= ", \"" . $fulldir . "\""; $sql .= ", \"" . $protocol . "\""; $sql .= ", \"" . $runno . "\""; $sql .= ", \"" . $procvals['actionid'] . "\""; //a['ID'] . "\""; $sql .= ", " . $procvals['tr']; $sql .= ", " . $procvals['te']; $sql .= ", \"" . $procvals['orient'] . "\""; $sql .= ", " . $procvals['thk']; $sql .= ", " . $procvals['pss0']; $sql .= ", " . $procvals['gap']; $sql .= ", " . $procvals['np']; $sql .= ", " . $procvals['nv']; $sql .= ", " . $procvals['lro']; $sql .= ", " . $procvals['lpe']; $sql .= ", \"" . $procvals['ms_intlv'] . "\""; $sql .= ", " . $procvals['gain']; $sql .= ", " . $procvals['tpwr1']; $sql .= ", \"" . $procvals['rfcoil'] . "\""; $sql .= ", \"" . $procvals['fatsat'] . "\""; $sql .= ", \"" . $procvals['ky_order'] . "\""; $sql .= ", " . (int) $procvals['fract_ky']; $sql .= ", \"" . $procvals['epi_pc'] . "\""; $sql .= ")"; //echo "\n".$sql."\n"; //echo $n." = "; print_r($a); echo "\n"; $q = mysql_query($sql) or die("discover_this: mysql insert error : " . mysql_error()); $errstr = mysql_error(); if ($errstr != "") { echo "mysql insert error: " . $errstr; exit; } else { } //echo "insert successful ? " . mysql_insert_id() . "\n\n"; // make sure studies table has this study $d["studyid"] = $fullstudyid; $dirparts = explode("/", $fulldir); $d["description"] = $dirparts[count($dirparts) - 1]; $d["subject"] = ""; $d["notes"] = ""; $data = read_study_table($fullstudyid); if ($data["notfound"] == 0) { if (strlen($data["description"])) { $d["description"] = $data["description"]; } $d["subject"] = $data["subject"]; $d["notes"] = $data["notes"]; } add_or_update_study($d); }
<table border=0 cellpadding=0 cellspacing=2 width=100%> <tr class=colheads><td>Subject</td><td>Exp. Date</td><td width=80>Runs</td><td>Description</td><td>Study/Account</td> </tr> <?php //--------- // limiting by LENGTH(pathname)>0 selects only 'discovered' data $q = mysql_query("SELECT *,count(*) as numepis FROM fid_files WHERE deleted='N' AND LENGTH(pathname)>0 GROUP BY studyid DESC"); if (!$q) { echo "query error: " . mysql_error(); } else { $i = 1; $bgs = array("#d8d8e8", "#e4eAe4"); //$bgs = array("#c8c8d8","#c8d8c8"); while ($row = mysql_fetch_array($q, MYSQL_ASSOC)) { $studydata = read_study_table($row["studyid"]); /*if (!strlen($row["comment"]))*/ $row["comment"] = $studydata["description"]; $row["subject"] = $studydata["subject"]; if (strlen($filter) && $row["subject"] != $filter) { continue; } $b = $bgs[$i]; // yellow = FFFF40 green == CCFFCC from phpmyadmin, was using BBFFBB for green though echo "<tr bgcolor=" . $b . " onmouseover=\"setPointer(this,'over','#000000','#FFFF40');\" onmouseout=\"setPointer(this,'out','" . $b . "','#CCFFCC');\""; echo " onmousedown=\"select_row('" . $row["studyid"] . "');\""; echo ">\n"; //echo "<td class=row".$i."> <a class=invlink href=\"javascript:select_row(\"".$row["studyid"]."\")\">"; //echo $row["client_ip"].": ".$row["filename"]."</a></td>\n"; echo "<td align=center>" . $row["subject"] . "</td>\n"; //echo "<td align=center>".$row["shots"]."</td>\n";