function DeleteRating($ratingid) { $sqlstring = "delete from ratings where rating_id = '{$ratingid}'"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); ?> <span class="message">Rating deleted</span><?php }
function GetOrderInfo($DBConn) { if (!isset($_GET['OrderID'])) { echo "OrderID is required!"; return false; } $QueryString = 'select LName, FName, Address, City, State, Zip, HasMeal, BoothName, Days from orders where OrderID="' . $_GET['OrderID'] . '"'; if (isset($_GET['IncludeEvent'])) { $QueryString = $QueryString . ' and EventID="' . $_GET['IncludeEvent'] . '"'; } elseif (isset($_GET['ExcludeEvent'])) { $QueryString = $QueryString . ' and EventID!="' . $_GET['ExcludeEvent'] . '"'; } $QueryString = $QueryString . ";"; $OrderQuery = MySQLQuery($DBConn, $QueryString); if ($OrderQuery['Result'] == false) { echo $OrderQuery['Query']; return false; } if (mysqli_num_rows($OrderQuery['Query']) != 1) { echo "No orders match that ID"; return false; } $Data = mysqli_fetch_assoc($OrderQuery['Query']); return $Data; }
function GMCancelCmpst($var, $gm) { global $tbl_sys_msg; $gm_name = mysql_escape_string($gm); $id = intval($var["id"]); $qs = "update tbl_gm_compensate_action set action_state=2 where gca_uId = '{$id}' and gm = '{$gm_name}'"; $result = MySQLQuery($qs, "GMS"); $qs = "select action_id, reason, server_id from tbl_gm_compensate_action where gca_uId = '{$id}'"; $result = MySQLQuery($qs, "GMS"); $row = mysql_fetch_row($result); $action_id = intval($row[0]); if ($action_id < 10) { $action_str = "000" . $action_id; } elseif ($action_id < 100) { $action_str = "00" . $action_id; } elseif ($action_id < 1000) { $action_str = "0" . $action_id; } if (LogGMCommand($gm_name, $var["action_name"] . "." . $action_str, $row[1], $row[2])) { PrintNotice($tbl_sys_msg["success"]); BackAndRefresh($tbl_sys_msg["success"]); return true; } return false; }
function RoleToUser($var, $gm) { global $page_main; if ($var["serverindex"] == null || $var["serverindex"] == "") { echo "<script src='/js/checkbox.js' type='text/javascript'></script>\n"; form($var, $gm); checkbox(true, false); echo "</form>\n"; ReturnAndBack(); $ret = eachServerFrame($var, $gm); ReturnAndBack(); return $ret; } $serverid = $var["serverindex"]; $role_names = $var["role_name"]; $role_names = implode("','", explode(",", $role_names)); $qs = "select distinct us.us_uId, us.us_sName from tbl_char_static cs, tbl_char c, tbl_user_static us where cs.cs_uId = c.cs_uId and cs.us_uId = us.us_uId and c.c_sName in ('" . $role_names . "');"; $result = MySQLQuery($qs, "Game", $serverid); echo "<table class='list_table'>\n"; echo "<tr><th>" . $page_main["user_id"] . "</th><th>" . $page_main["user_name"] . "</th></tr>\n"; while ($row = mysql_fetch_row($result)) { printf("<tr" . ($i++ % 2 == 0 ? "" : " class='even'") . "><td>%s</td><td><input type='checkbox' flag='user' onclick='Checkbox(this);' value='%s'/>%s</td></tr>\n", $row[0], $row[1], $row[1]); } echo "</table>\n"; return true; }
function GetGMMgrInfo($var, $gm) { if ($var["serverindex"] == null || $var["serverindex"] == "") { $js_src = <<<_js_src <script type="text/javascript"> <!--// function DelGMMmr(obj,id,game_id) { \tdocument.form1.action = "/cgi-bin/gm_tools/FrameWork.php"; \tdocument.form1.action_name.value = '89'; \tdocument.form1.target = "block"; \tdocument.form1.id.value = id; \tdocument.form1.game_id.value = game_id; \tdocument.form1.serverid.value = \$(obj).parents(".panel").attr("id").substring(4); \tdocument.form1.submit(); } function ChangeGMLevel(obj,id,game_id) {\t \tdocument.form1.action = "/lib/gm_tools/ChangeGMLevel.php"; \tdocument.form1.target = "block"; \tdocument.form1.id.value = id; \tdocument.form1.game_id.value = game_id; \tdocument.form1.serverid.value = \$(obj).parents(".panel").attr("id").substring(4); \tdocument.form1.submit(); \t } </script> _js_src; echo $js_src . "\n"; form($var, $gm); echo "<input type='hidden' name='id'/>\n"; echo "<input type='hidden' name='game_id'/>\n"; $ret = eachServerFrame($var, $gm); echo "</form>\n"; ReturnAndBack(); return $ret; } else { $serverid = intval($var["serverindex"]); } global $page_main, $tbl_sys_msg; $query_string = "select username,gv_uLevel, us_uGameID from tbl_gm_validate"; $result = MySQLQuery($query_string, "Game", $serverid); echo "<table class='list_table'>\n"; printf("<tr><th>%s</th><th>%s</th><th>%s</th></tr>\n", $page_main["user_name"], $tbl_sys_msg["level"], $tbl_sys_msg["act"]); while ($row = mysql_fetch_row($result)) { $func_str = ""; if (hasAuth(89, $gm)) { $func_str .= sprintf("<input type=button value=\"%s\" onclick=\"DelGMMmr(this,'%s',%d)\"/>", $tbl_sys_msg["delete"], $row[0], $row[2]); } if (hasAuth(96, $gm)) { $func_str .= sprintf("<input type=button value=\"%s\" onclick=\"ChangeGMLevel(this,'%s',%d)\"/>", $tbl_sys_msg["edit"], $row[0], $row[2]); } printf("<tr" . ($i % 2 == 0 ? "" : " class='even'") . "><td>%s</td><td>%d</td><td>%s</td></tr>\n", $row[0], $row[1], $func_str); } echo "</table>\n"; return true; }
function SwitchInstance($id) { $sqlstring = "select instance_name from instance where instance_id = {$id}"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $instancename = $row['instance_name']; $_SESSION['instanceid'] = $id; $_SESSION['instancename'] = $instancename; //echo "Switched instance to $id"; }
function GetFriends($var, $gm) { global $tbl_role_all_detail; echo "<h1>{$tbl_role_all_detail['16']}</h1>\n"; ReturnAndBack(); Reload(); $role_id = ArgRoleId(); echo "<table class='list_table'>\n"; echo sprintf("<tr><td>{$tbl_role_all_detail['18']}</td></tr>\n", ArgRoleName() . "(" . $role_id . ")"); echo "</table>\n"; global $tbl_role_friends, $tbl_camp, $tbl_class, $tbl_sex, $tbl_sys_msg; $serverid = $var["serverid"]; if (!$role_id) { return true; } echo "<h1>" . $tbl_role_friends[0] . "</h1>\n"; echo "<table class='list_table'>\n"; printf("<tr><th>%s</th><th>%s</th><th style='width:100px;'>%s</th><th style='width:100px;'>%s</th><th style='width:100px;'>%s</th><th style='width:100px;'>%s</th></tr>\n", $tbl_role_friends[1][0], $tbl_role_friends[1][1], $tbl_role_friends[1][2], $tbl_role_friends[1][3], $tbl_role_friends[1][4], $tbl_role_friends[1][5]); $rs = MySQLQuery("select c.c_sName, cs.cs_uCamp, cs.cs_uClass, cb.cb_uLevel, cs.cs_uSex, fc.fc_sName from tbl_player_friends pf, tbl_friends_class fc, tbl_char c, tbl_char_basic cb, tbl_char_static cs where pf.fc_uId = fc.fc_uId and pf.cs_uId = fc.cs_uId and pf.pf_uFriendId = c.cs_uId and fc.fc_uId<>2 and pf.cs_uId='{$role_id}' and cb.cs_uId = c.cs_uId and cs.cs_uId = c.cs_uId", "Game", $serverid); while ($row = mysql_fetch_row($rs)) { if ($row[5] == UTF82Local($tbl_role_friends[1][6])) { $row[5] = $tbl_role_friends[1][6]; } printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $row[5], $row[0], $tbl_camp[$row[1]], $tbl_class[$row[2]], $row[3], $tbl_sex[$row[4]]); } echo "</table>\n"; echo "<h1>" . $tbl_role_friends[2] . "</h1>\n"; echo "<table class='list_table'>\n"; printf("<tr><th>%s</th><th style='width:100px;'>%s</th><th style='width:100px;'>%s</th><th style='width:100px;'>%s</th><th style='width:100px;'>%s</th></tr>\n", $tbl_role_friends[3][0], $tbl_role_friends[3][1], $tbl_role_friends[3][2], $tbl_role_friends[3][3], $tbl_role_friends[3][4]); $rs = MySQLQuery("select c.c_sName, cs.cs_uCamp, cs.cs_uClass, cb.cb_uLevel, cs.cs_uSex from tbl_player_friends pf, tbl_char c, tbl_char_basic cb, tbl_char_static cs where pf.pf_uFriendId = c.cs_uId and pf.cs_uId='{$role_id}' and pf.fc_uId=2 and cb.cs_uId = c.cs_uId and cs.cs_uId = c.cs_uId", "Game", $serverid); while ($row = mysql_fetch_row($rs)) { printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $row[0], $tbl_camp[$row[1]], $tbl_class[$row[2]], $row[3], $tbl_sex[$row[4]]); } echo "</table>\n"; echo "<h1>" . $tbl_role_friends[4] . "</h1>\n"; echo "<table class='list_table'>\n"; printf("<tr><th>%s</th><th>%s</th><th>%s</th></tr>\n", $tbl_role_friends[5][0], $tbl_role_friends[5][1], $tbl_role_friends[5][2]); $rs = MySQLQuery("select fg.fg_sName,gm1.gm_uIdentity,count(*) from tbl_group_manager gm1,tbl_group_manager gm2,tbl_friends_group fg where gm1.cs_uId='{$role_id}' and gm1.fg_uId = gm2.fg_uId and gm1.fg_uId = fg.fg_uId group by gm2.fg_uId", "Game", $serverid); while ($row = mysql_fetch_row($rs)) { printf("<tr><td>%s</td><td>%s</td><td>%d</td></tr>\n", $row[0], $tbl_role_friends[5][3][intval($row[1])], $row[2]); } echo "</table>\n"; echo "<h1>" . $tbl_role_friends[6] . "</h1>\n"; echo "<table class='list_table'>\n"; printf("<tr><th>%s</th><th>%s</th><th>%s</th></tr>\n", $tbl_role_friends[7][0], $tbl_role_friends[7][1], $tbl_role_friends[7][2]); $rs = MySQLQuery("select t.t_sName, mt1.mt_sPosition, count(*) from tbl_member_tong mt1, tbl_tong t, tbl_member_tong mt2 where mt1.t_uId = t.t_uId and t.t_uId = mt2.t_uId and mt1.cs_uId = '{$role_id}' group by t.t_uId", "Game", $serverid); while ($row = mysql_fetch_row($rs)) { global $tbl_tong_pos; printf("<tr><td>%s</td><td>%s</td><td>%d</td></tr>\n", $row[0], $tbl_tong_pos[intval($row[1])], $row[2]); } echo "</table>\n"; return true; }
function GetModalityList($withdesc = false) { $sqlstring = "select * from modalities order by mod_desc"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $modalities[] = $row['mod_code']; $descriptions[] = $row['mod_code']; } if ($withdesc) { return array($modalities, $descriptions); } else { return $modalities; } }
function GetTongDetail($var, $gm) { $id = intval($var["id"]); $serverid = intval($var["serverid"]); $query_string = "select t_sName, c.c_sName, t_uCamp, t.t_uId, t_dtCreateTime, t_uHonor, t_uLevel, t_uMoney, t_uResource, t_sPurpose, t_uDepotId, count(mt.cs_uId), ifnull(wz_uId, 0), ifnull(wz.wzs_uIndex, 0) from tbl_tong t left join tbl_war_zone_station wz on t.t_uId = wz.t_uId, tbl_member_tong mt, tbl_member_tong o, tbl_char c where o.t_uId=t.t_uId and o.mt_sPosition=5 and o.cs_uId=c.cs_uId and t.t_uId=mt.t_uId and t.t_uId='{$id}' group by t.t_uId"; $result = MySQLQuery($query_string, "Game", $serverid); $tbl_content = array(); while ($row = mysql_fetch_row($result)) { $tbl_size = count($tbl_content); $tbl_content[$tbl_size] = $row; } RetTongDetail($tbl_content[0], $var); return true; }
function SendEmail($emailbody, $emailsubject, $emailto) { $sqlstring = "select user_email from users where user_email <> ''"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $numrows = mysql_num_rows($result); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $emailto = $row['user_email']; /* send the email */ if (!SendGmail($emailto, $emailsubject, $emailbody, 1, 0)) { return "System error. Unable to send email!"; } else { return "Message send successfully to {$numrows} recipients"; } } }
function Main() { $now = Date("Y-m-d H:i:s"); P($now . "==============================\n"); global $tbl_gm_db, $tbl_serv_db, $tbl_game_server; $str = "("; $qs = "select * from tbl_channel_word"; $result = MySQLQuery($qs, "GMS"); $words = array(); while ($row = mysql_fetch_row($result)) { array_push($words, "lcc.lcc_sMsg like '%" . $row[0] . "%'"); } $str .= implode(" or ", $words); $str .= ")"; P("Number of Check Word: " . count($words) . "\n"); $qs = "select gv_value from tbl_gm_variable where gv_name = 'ChannelChatStemp'"; $result = MySQLQuery($qs, "GMS"); if ($row = mysql_fetch_row($result)) { P("Last updated at: " . $row[0] . "\n"); $str .= " and lcc.lcc_dtChatTime > '" . $row[0] . "' and lcc.lcc_dtChatTime <= '" . $now . "'"; } $qs = "update tbl_gm_variable set gv_value = '" . $now . "' where gv_name = 'ChannelChatStemp'"; MySQLQuery($qs, "GMS"); foreach ($tbl_serv_db as $key => $dbinfo) { P("Server: " . $key . "\t"); $insert = array(); $qs = "select lcc.cs_uId,lcc.lcc_dtChatTime,{$key} as serv_id,lcc.lcc_sMsg,lcc.lcc_sChannelName from tbl_log_channel_chat lcc where " . $str; $result = MySQLQuery($qs, "GameLog", $key); while ($row = mysql_fetch_row($result)) { $qs = "select c.c_sName, us.us_sName from tbl_char c, tbl_char_static cs, tbl_user_static us where c.cs_uId = cs.cs_uId and cs.us_uId = us.us_uId and cs.cs_uId = " . $row[0]; $rs = MySQLQuery($qs, "Game", $key); if ($r = mysql_fetch_row($rs)) { $row[0] = $r[0]; $user_name = $r[1]; } else { $row[0] = "[" . $row[0] . "]"; } array_push($insert, "insert into tbl_channel_chat values('" . $row[0] . "','" . $row[3] . "','" . $row[1] . "','" . Local2UTF8($row[4]) . "'," . $row[2] . ",'" . $user_name . "')"); } P("Number of Chat: " . count($insert) . "\n"); foreach ($insert as $query) { MySQLQuery($query, "GMS"); } } }
function ViewDetails($requestid) { $sqlstring = "select * from data_requests where request_id = $requestid"; $result = MySQLQuery($sqlstring,__FILE__,__LINE__); $fields_num = mysql_num_fields($result); for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); $fields[] = $field->name; } ?><div style="column-count 3; -moz-column-count:3; -webkit-column-count:3"><? $row = mysql_fetch_array($result, MYSQL_ASSOC); foreach ($fields as $f) { if (($f != 'req_results') && (stripos($f,'password') === false)) { echo "<b>$f</b> - " . $row[$f] . "<br>"; } } echo "</div><pre><b>Request results</b><br>" . $row['req_results'] . "</pre>"; }
function SearchTaskInfo($var, $gm) { global $tbl_list_task; $serverid = $var["serverid"]; $role_id = ArgRoleId(); if (!$role_id) { return true; } $query_string = "select q_sName,q_state,FROM_UNIXTIME(q_tAcceptTime),FROM_UNIXTIME(q_tFinishTime) from tbl_quest where cs_uId=" . $role_id . " and q_sName = '" . UTF82Local($var["quest_name"]) . "'"; $result = MySQLQuery($query_string . " order by q_tAcceptTime", "Game", $serverid); $tbl_content = array(); while ($row = mysql_fetch_row($result)) { $row[1] = $tbl_list_task[intval($row[1])]; $tbl_size = count($tbl_content); $tbl_content[$tbl_size] = $row; } if (!IsDownload($var)) { RetGetTaskInfo($tbl_content, $role_name, $role_id); return true; } return true; }
function GetMoneyCorrencyLimit($var, $gm) { if ($var["serverindex"] == null || $var["serverindex"] == "") { $js_src = <<<_js_src <script type="text/javascript"> <!--// function DelMoneyCorrencyLimit(money_func,obj) { \tdocument.form1.target = "block"; \tdocument.form1.action_name.value = '93'; \tdocument.form1.money_func.value = money_func; \tdocument.form1.serverid.value = \$(obj).parents(".panel").attr("id").substring(4); \tdocument.form1.submit(); } </script> _js_src; echo $js_src; form($var, $gm); echo "<input type='hidden' name='money_func'/>\n"; echo "</form>\n"; $ret = eachServerFrame($var, $gm); ReturnAndBack(); return $ret; } else { $serverid = intval($var["serverindex"]); } $query_string = "select mcl_sFunName,mcl_sModule from tbl_money_corrency_limit"; $result = MySQLQuery($query_string, "Game", $serverid); $tbl_content = array(); while ($row = mysql_fetch_row($result)) { $tbl_size = count($tbl_content); $tbl_content[$tbl_size] = $row; } RetMoneyCorrencyLimit($tbl_content, $var); return true; }
function ViewReport($datestart, $dateend, $modality, $studysite) { if ($modality == "") { $sqlstring = "select c.uid, c.subject_id, c.gender, c.birthdate, d.*, a.* from studies a left join enrollment b on a.enrollment_id = b.enrollment_id left join subjects c on b.subject_id = c.subject_id left join projects d on b.project_id = d.project_id where a.study_datetime > '$datestart' and a.study_datetime < '$dateend' and a.study_site = '$studysite' order by study_datetime"; } else { $sqlstring = "select c.uid, c.subject_id, c.gender, c.birthdate, d.*, a.* from studies a left join enrollment b on a.enrollment_id = b.enrollment_id left join subjects c on b.subject_id = c.subject_id left join projects d on b.project_id = d.project_id where a.study_modality = '$modality' and a.study_datetime > '$datestart' and a.study_datetime < '$dateend' order by study_datetime"; } //echo $sqlstring; ?> <b>Imaging studies from <?php echo $datestart; ?> to <?php echo $dateend; ?> </b> <br> <br> <table class="graydisplaytable"> <tr> <th>UID</th> <th>Study</th> <th>Sex</th> <th>BirthDate</th> <th>Study Description</th> <th>Project</th> <th>Study date</th> <th>Radiological Read?</th> <th>Read date</th> <th>Read findings</th> </tr> <? $result = MySQLQuery($sqlstring, __FILE__, __LINE__); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $uid = $row['uid']; $gender = $row['gender']; $subjectid = $row['subject_id']; $subjectdob = $row['birthdate']; $studyid = $row['study_id']; $studynum = $row['study_num']; $studydesc = $row['study_desc']; $studydatetime = $row['study_datetime']; $studyradreaddone = $row['study_doradread']; $studyradreaddate = $row['study_radreaddate']; $studyradreadfindings = $row['studyradreadfindings']; $project = $row['project_name'] . " (" . $row['project_costcenter'] . ")"; ?> <tr> <td><a href="subjects.php?id=<?php echo $subjectid; ?> "><?php echo $uid; ?> </a></td> <td><a href="studies.php?id=<?php echo $studyid; ?> "><?php echo $uid; echo $studynum; ?> </a></td> <td><?php echo $gender; ?> </td> <td><?php echo $subjectdob; ?> </td> <td><?php echo $studydesc; ?> </td> <td><?php echo $project; ?> </td> <td><?php echo $studydatetime; ?> </td> <td><?php echo $studyradreaddone; ?> </td> <td><?php echo $studyradreaddate; ?> </td> <td><?php echo $studyradreadfindings; ?> </td> </tr> <? } ?> </table> <? }
function DisplayUserList() { $urllist['Administration'] = "admin.php"; $urllist['User List'] = "adminusers.php"; $urllist['Add User'] = "******"; NavigationBar("Admin", $urllist); ?> <table class="graydisplaytable"> <thead> <tr> <th>Username</th> <th>Full name</th> <th>Email</th> <th>Login type</th> <!--<th>Instance</th>--> <th>Last Login</th> <th>Login Count</th> <th>Enabled</th> <th>Admin</th> </tr> </thead> <tbody> <?php $sqlstring = "select * from users a left join user_instance b on a.user_id = b.user_id where b.instance_id = '" . $_SESSION['instanceid'] . "' order by username"; //PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $id = $row['user_id']; $username = $row['username']; $fullname = $row['user_fullname']; $email = $row['user_email']; $login_type = $row['login_type']; //$instancename = $row['instance_name']; $lastlogin = $row['user_lastlogin']; $logincount = $row['user_logincount']; $enabled = $row['user_enabled']; $isadmin = $row['user_isadmin']; ?> <tr> <td><a href="adminusers.php?action=editform&id=<?php echo $id; ?> "><?php echo $username; ?> </td> <td><?php echo $fullname; ?> </td> <td><?php echo $email; ?> </td> <td><?php echo $login_type; ?> </td> <!--<td class="tiny"><?php echo $instancename; ?> </td>--> <td><?php echo $lastlogin; ?> </td> <td><?php echo $logincount; ?> </td> <td> <?php if ($enabled) { ?> <a href="adminusers.php?action=disable&id=<?php echo $id; ?> "><img src="images/checkedbox16.png"></a><?php } else { ?> <a href="adminusers.php?action=enable&id=<?php echo $id; ?> "><img src="images/uncheckedbox16.png"></a><?php } ?> </td> <td> <?php if ($isadmin) { ?> <a href="adminusers.php?action=notadmin&id=<?php echo $id; ?> "><img src="images/checkedbox16.png"></a><?php } else { ?> <a href="adminusers.php?action=makeadmin&id=<?php echo $id; ?> "><img src="images/uncheckedbox16.png"></a><?php } ?> </td> <!--<td><?php if ($enabled) { echo "✔"; } ?> </td> <td><?php if ($isadmin) { echo "✔"; } ?> </td> --> </tr> <?php } ?> <tr><td colspan="8" align="center">The Following users are unaffiliated with an instance</td></tr> <?php $sqlstring = "select a.* from users a left join user_instance b on a.user_id = b.user_id where b.instance_id = '' or b.instance_id is null order by username"; //PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $id = $row['user_id']; $username = $row['username']; $fullname = $row['user_fullname']; $email = $row['user_email']; $login_type = $row['login_type']; $instancename = $row['instance_name']; $lastlogin = $row['user_lastlogin']; $logincount = $row['user_logincount']; $enabled = $row['user_enabled']; $isadmin = $row['user_isadmin']; ?> <tr> <td><a href="adminusers.php?action=editform&id=<?php echo $id; ?> "><?php echo $username; ?> </td> <td><?php echo $fullname; ?> </td> <td><?php echo $email; ?> </td> <td><?php echo $login_type; ?> </td> <td class="tiny"><?php echo $instancename; ?> </td> <td><?php echo $lastlogin; ?> </td> <td><?php echo $logincount; ?> </td> <td> <?php if ($enabled) { ?> <a href="adminusers.php?action=disable&id=<?php echo $id; ?> "><img src="images/checkedbox16.png"></a><?php } else { ?> <a href="adminusers.php?action=enable&id=<?php echo $id; ?> "><img src="images/uncheckedbox16.png"></a><?php } ?> </td> <td> <?php if ($isadmin) { ?> <a href="adminusers.php?action=notadmin&id=<?php echo $id; ?> "><img src="images/checkedbox16.png"></a><?php } else { ?> <a href="adminusers.php?action=makeadmin&id=<?php echo $id; ?> "><img src="images/uncheckedbox16.png"></a><?php } ?> </td> <!--<td><?php if ($enabled) { echo "✔"; } ?> </td> <td><?php if ($isadmin) { echo "✔"; } ?> </td> --> </tr> <?php } ?> </tbody> </table> <?php }
function DisplayProjectProtocolList($projectid) { ?> <table class="graydisplaytable" width="100%"> <thead> <tr> <th>Protocol group<br><span class="tiny">MODALITY - group name</span></th> <th>Criteria</th> <!--<th>Per session quantity</th>--> <th>Total quantity</th> <th> </th> </tr> </thead> <tbody> <form action="adminprojectprotocols.php" method="post"> <input type="hidden" name="action" value="addprotocol"> <input type="hidden" name="projectid" value="<?php echo $projectid; ?> "> <tr> <td style="border-bottom: solid 2px gray"><select name="protocolgroupid" required> <option value="">(Select protocol group)</option> <?php $sqlstring = "select * from protocol_group order by protocolgroup_modality, protocolgroup_name"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $pgid = $row['protocolgroup_id']; $name = $row['protocolgroup_name']; $modality = strtoupper($row['protocolgroup_modality']); echo "<option value='{$pgid}'>{$modality} - {$name}</option>"; } ?> </select></td> <td style="border-bottom: solid 2px gray"> <input type="radio" name="criteria" value="required" checked>Required<br> <!--<input type="radio" name="criteria" value="recommended">Recommended<br> <input type="radio" name="criteria" value="conditional">Conditional--> </td> <!--<td style="border-bottom: solid 2px gray"><input type="number" name="numpersession" style="width: 50px"></td>--> <td style="border-bottom: solid 2px gray"><input type="number" name="numtotal" style="width: 50px"></td> <td style="border-bottom: solid 2px gray"><input type="submit" value="Add"></td> </tr> </form> <?php $sqlstring = "select * from project_protocol a left join protocol_group b on a.protocolgroup_id = b.protocolgroup_id where a.project_id = {$projectid}"; //PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $projectprotocolid = $row['projectprotocol_id']; //$projectid = $row['project_id']; $protocolgroupid = $row['protocolgroup_id']; $criteria = $row['pp_criteria']; $numpersession = $row['pp_perstudyquantity']; $numtotal = $row['pp_perprojectquantity']; $name = $row['protocolgroup_name']; $modality = strtoupper($row['protocolgroup_modality']); ?> <tr style="<?php echo $style; ?> "> <td><a href="adminmodalities.php?action=editprotocolgroups&id=<?php echo $protocolgroupid; ?> " target="_top"><?php echo $modality; ?> </a> - <?php echo $name; ?> </td> <td><?php echo $criteria; ?> </td> <td><?php echo $numpersession; ?> </td> <td><?php echo $numtotal; ?> </td> <td><a href="adminprojectprotocols.php?action=deleteprotocol&projectprotocolid=<?php echo $projectprotocolid; ?> &projectid=<?php echo $projectid; ?> " style="color: darkred">X</a></td> </tr> <?php } ?> </tbody> </table> <?php }
function ViewGroup($id, $measures, $columns, $groupmeasures) { $urllist['Group List'] = "groups.php"; NavigationBar("Groups", $urllist,0,'','','',''); /* get the general group information */ $sqlstring = "select * from groups where group_id = $id"; $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $row = mysql_fetch_array($result, MYSQL_ASSOC); $groupname = $row['group_name']; $grouptype = $row['group_type']; ?> <script> $(document).ready(function() { $("#studytable").tablesorter(); } ); </script> <div align="center"><span style="color:darkblue;font-size:15pt;font-weight:bold"><?php echo $groupname; ?> </span> - <i><?php echo $grouptype; ?> </i> level group</div> <br><br> <? /* (subject level) group statistics */ $totalage = 0; $numage = 0; $totalweight = 0; $numweight = 0; $n = 0; //print_r(get_defined_vars()); /* ------------------ subject group type ------------------- */ if ($grouptype == "subject") { /* get the actual group data (subject level) */ $sqlstring = "select a.subjectgroup_id, b.*, (datediff(now(), birthdate)/365.25) 'age' from group_data a left join subjects b on a.data_id = b.subject_id where a.group_id = $id"; $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $subjectid = $row['subject_id']; $name = $row['name']; $birthdate = $row['birthdate']; $age = $row['age']; $gender = $row['gender']; $ethnicity1 = $row['ethnicity1']; $ethnicity2 = $row['ethnicity2']; $weight = $row['weight']; $handedness = $row['handedness']; $education = $row['education']; $uid = $row['uid']; /* do some demographics calculations */ $n++; if ($age > 0) { $totalage += $age; $numage++; $ages[] = $age; } if ($weight > 0) { $totalweight += $weight; $numweight++; $weights[] = $weight; } $genders{$gender}++; $educations{$education}++; $ethnicity1s{$ethnicity1}++; $ethnicity2s{$ethnicity2}++; $handednesses{$handedness}++; } if ($numage > 0) { $avgage = $totalage/$numage; } else { $avgage = 0; } if (count($ages) > 0) { $varage = sd($ages); } else { $varage = 0; } if ($numweight > 0) { $avgweight = $totalweight/$numweight; } else { $avgweight = 0; } if (count($weights) > 0) { $varweight = sd($weights); } else { $varweight = 0; } ?> <table> <tr> <td valign="top" style="padding-right:20px"> <? DisplayDemographicsTable($n,$avgage,$varage,$genders,$ethnicity1s,$ethnicity2s,$educations,$handednesses,$avgweight,$varweight); ?> </td> </tr> <tr> <td valign="top" style="padding-right:20px"> <details> <summary>SQL</summary> <?php echo PrintSQL($sqlstring); ?> </details> </td> </tr> <tr> <td valign="top"> <form action="groups.php" method="post"> <input type="hidden" name="id" value="<?php echo $id; ?> "> <input type="hidden" name="action" value="removegroupitem"> <table class="smallgraydisplaytable"> <th>Initials</th> <th>UID</th> <th>Age<br><span class="tiny">current</span></th> <th>Sex</th> <th>Ethnicity 1</th> <th>Ethnicity 2</th> <th>Weight</th> <th>Handedness</th> <th>Education</th> <th>Alt UIDs</th> <th>Remove<br>from group</th> <? /* reset the result pointer to 0 to iterate through the results again */ mysql_data_seek($result,0); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $itemid = $row['subjectgroup_id']; $subjectid = $row['subject_id']; $name = $row['name']; $birthdate = $row['birthdate']; $age = $row['age']; $gender = $row['gender']; $ethnicity1 = $row['ethnicity1']; $ethnicity2 = $row['ethnicity2']; $weight = $row['weight']; $handedness = $row['handedness']; $education = $row['education']; $uid = $row['uid']; /* get list of alternate subject UIDs */ $altuids = GetAlternateUIDs($subjectid); $parts = explode("^",$name); $name = substr($parts[1],0,1) . substr($parts[0],0,1); ?> <tr> <td><?php echo $name; ?> </td> <td><a href="subjects.php?id=<?php echo $subjectid; ?> "><?php echo $uid; ?> </a></td> <? if ($age <= 0) {$color = "red";} else {$color="black";} ?> <td style="color:<?php echo $color; ?> "><?php echo number_format($age, 1); ?> Y</td> <? if (!in_array(strtoupper($gender),array('M','F','O'))) {$color = "red";} else {$color="black";} ?> <td style="color:<?php echo $color; ?> "><?php echo $gender; ?> </td> <td><?php echo $ethnicitiy1; ?> </td> <td><?php echo $ethnicitiy1; ?> </td> <td><?php echo number_format($weight, 1); ?> kg</td> <td><?php echo $handedness; ?> </td> <td><?php echo $education; ?> </td> <td><?php echo implode(', ', $altuids); ?> </td> <!--<td><a href="groups.php?action=removegroupitem&itemid=<?php echo $itemid; ?> &id=<?php echo $id; ?> " style="color:red">X</a></td>--> <td><input type="checkbox" name="itemid[]" value="<?php echo $itemid; ?> "></td> </tr> <? } ?> <tr> <td colspan="100" align="right"> <input type="submit" value="Remove"> </form> </td> </tr> </table> </td> </tr> </table> <? } /* ------------------ study group type ------------------- */ if ($grouptype == "study") { $csv = ""; /* get the demographics (study level) */ $sqlstring = "select c.enroll_subgroup,d.*, (datediff(b.study_datetime, d.birthdate)/365.25) 'age' from group_data a left join studies b on a.data_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.group_id = $id group by d.uid order by d.uid,b.study_num"; $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $studyid = $row['study_id']; $studynum = $row['study_num']; $studydesc = $row['study_desc']; $studyalternateid = $row['study_alternateid']; $studymodality = $row['study_modality']; $studydatetime = $row['study_datetime']; $studyoperator = $row['study_operator']; $studyperformingphysician = $row['study_performingphysician']; $studysite = $row['study_site']; $studyinstitution = $row['study_institution']; $studynotes = $row['study_notes']; $subgroup = $row['enroll_subgroup']; $subjectid = $row['subject_id']; $name = $row['name']; $birthdate = $row['birthdate']; $age = $row['age']; $gender = $row['gender']; $ethnicity1 = $row['ethnicity1']; $ethnicity2 = $row['ethnicity2']; $weight = $row['weight']; $handedness = $row['handedness']; $education = $row['education']; $uid = $row['uid']; $subjectids[] = $subjectid; /* do some demographics calculations */ $n++; if ($age > 0) { $totalage += $age; $numage++; $ages[] = $age; } if ($weight > 0) { $totalweight += $weight; $numweight++; $weights[] = $weight; } $genders{$gender}++; $educations{$education}++; $ethnicity1s{$ethnicity1}++; $ethnicity2s{$ethnicity2}++; $handednesses{$handedness}++; } if ($numage > 0) { $avgage = $totalage/$numage; } else { $avgage = 0; } if (count($ages) > 0) { $varage = sd($ages); } else { $varage = 0; } if ($numweight > 0) { $avgweight = $totalweight/$numweight; } else { $avgweight = 0; } if (count($weights) > 0) { $varweight = sd($weights); } else { $varweight = 0; } if ($measures == "all") { $sqlstringD = "select a.subject_id, b.enrollment_id, c.*, d.measure_name from measures c join measurenames d on c.measurename_id = d.measurename_id left join enrollment b on c.enrollment_id = b.enrollment_id join subjects a on a.subject_id = b.subject_id where a.subject_id in (" . implode2(",", $subjectids) . ")"; //PrintSQL($sqlstringD); $resultD = MySQLQuery($sqlstringD,__FILE__,__LINE__); if ($groupmeasures == "byvalue") { $mnames = array('ANTDX','AVDDX','AX1Com1_Code','AX1Com2_Code','AX1Com3_Code','AX1Com4_Code','AX1Com5_Code','AX1Com6_Code','AX1Com7_Code','AX1Pri_Code','AXIIDX','BRDDX','DPNDX','DSM-Axis','DSM-Axis1','DSM-Axis2','DSM-Axis295.3','DSM-Axis304.3','DSM-AxisV71.09','DSM_IV_TR','DXGROUP_1','DX_GROUP','MiniDxn','MiniDxnFollowUp','NARDX','OBCDX','PARDX','ProbandGroup','Psychosis','relnm1','SAsubtype','SCZDX','status','SubjectType','SZTDX'); while ($rowD = mysql_fetch_array($resultD, MYSQL_ASSOC)) { $subjectid = $rowD['subject_id']; $measurename = $rowD['measure_name']; if (in_array($measurename,$mnames)) { if ($rowD['measure_type'] == 's') { $value = strtolower(trim($rowD['measure_valuestring'])); } else { $value = strtolower(trim($rowD['measure_valuenum'])); } if (is_numeric(substr($value,0,6))) { //echo "$value --6--> "; $value = substr($value,0,6); //echo "$value<br>"; } elseif (is_numeric(substr($value,0,5))) { //echo "$value --5--> "; $value = substr($value,0,5); //echo "$value<br>"; } elseif (is_numeric(substr($value,0,4))) { $value = substr($value,0,4); } elseif (is_numeric(substr($value,0,3))) { $value = substr($value,0,3); } elseif (is_numeric(substr($value,1,5))) { $value = substr($value,1,5); } elseif (substr($value,0,3) == "xxx") { $value = "xxx"; } $measuredata[$subjectid][$value] = 1; $measurenames[] = $value; } } $measurenames = array_unique($measurenames); natsort($measurenames); } else { while ($rowD = mysql_fetch_array($resultD, MYSQL_ASSOC)) { if ($rowD['measure_type'] == 's') { $measuredata[$rowD['subject_id']][$rowD['measure_name']]['value'][] = $rowD['measure_valuestring']; } else { $measuredata[$rowD['subject_id']][$rowD['measure_name']]['value'][] = $rowD['measure_valuenum']; } $measuredata[$rowD['subject_id']][$rowD['measure_name']]['notes'][] = $rowD['measure_notes']; $measurenames[] = $rowD['measure_name']; //$i++; } $measurenames = array_unique($measurenames); natcasesort($measurenames); } //PrintVariable($measurenames, 'MeasureNames'); //PrintVariable($measuredata, 'MeasureData'); } /* setup the CSV header */ if ($columns == "min") { $csv = "UID"; } else { $csv = "Initials,UID,AgeAtStudy,Sex,Ethnicity,Race,SubGroup,Weight,Handedness,Education,AltUIDs,StudyID,Description,AltStudyID,Modality,StudyDate,Operator,Physician,Site"; } ?> <table> <tr> <td valign="top" style="padding-right:20px"> <? DisplayDemographicsTable($n,$avgage,$varage,$genders,$ethnicity1s,$ethnicity2s,$educations,$handednesses,$avgweight,$varweight); ?> </td> </tr> <tr> <td valign="top" style="padding-right:20px"> <details> <summary>SQL</summary> <?php echo PrintSQL($sqlstring); ?> </details> </td> </tr> <tr> <td valign="top"> <a href="groups.php?action=viewgroup&id=<?php echo $id; ?> &measures=all">Include measures</a><br> <a href="groups.php?action=viewgroup&id=<?php echo $id; ?> &measures=all&columns=min">Include measures and only UID</a><br> <a href="groups.php?action=viewgroup&id=<?php echo $id; ?> &measures=all&columns=min&groupmeasures=byvalue">Include measures and only UID and group measures by value</a> <br><br> <span class="tiny">Click columns to sort. May be slow for large tables</span> <form action="groups.php" method="post"> <input type="hidden" name="id" value="<?php echo $id; ?> "> <input type="hidden" name="action" value="removegroupitem"> <table id="studytable" class="tablesorter"> <thead> <tr> <? if ($columns != "min") { ?> <th>Initials</th> <? } ?> <th>UID</th> <? if ($columns != "min") { ?> <th>Age<br><span class="tiny">at study</span></th> <th>Sex</th> <th>Ethnicities</th> <th>SubGroup</th> <th>Weight</th> <th>Handedness</th> <th>Education</th> <th>Alt UIDs</th> <th>Study ID</th> <th>Description</th> <th>Alternate Study ID</th> <th>Modality</th> <th>Date/time</th> <th>Operator</th> <th>Physician</th> <th>Site</th> <? } ?> <? if (count($measurenames) > 0) { foreach ($measurenames as $measurename) { echo "<th>$measurename</th>"; $csv .= ",\"$measurename\""; } } ?> <th>Remove<br>from group</th> </tr> </thead> <tbody> <? /* reset the result pointer to 0 to iterate through the results again */ $sqlstring = "select a.subjectgroup_id, c.enroll_subgroup, b.*, d.*, (datediff(b.study_datetime, d.birthdate)/365.25) 'age' from group_data a left join studies b on a.data_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.group_id = $id order by d.uid,b.study_num"; $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); //mysql_data_seek($result,0); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $studyid = $row['study_id']; $studynum = $row['study_num']; $studydesc = $row['study_desc']; $studyalternateid = $row['study_alternateid']; $studymodality = $row['study_modality']; $studydatetime = $row['study_datetime']; $studyoperator = $row['study_operator']; $studyperformingphysician = $row['study_performingphysician']; $studysite = $row['study_site']; $studyinstitution = $row['study_institution']; $studynotes = $row['study_notes']; $subgroup = $row['enroll_subgroup']; $itemid = $row['subjectgroup_id']; $subjectid = $row['subject_id']; $name = $row['name']; $birthdate = $row['birthdate']; $age = $row['age']; $gender = $row['gender']; $ethnicity1 = $row['ethnicity1']; $ethnicity2 = $row['ethnicity2']; $weight = $row['weight']; $handedness = $row['handedness']; $education = $row['education']; $uid = $row['uid']; /* get list of alternate subject UIDs */ $altuids = GetAlternateUIDs($subjectid); $parts = explode("^",$name); $name = substr($parts[1],0,1) . substr($parts[0],0,1); if ($columns == "min") { $csv .= "\n\"$uid\""; } else { $csv .= "\n\"$name\",\"$uid\",\"$age\",\"$gender\",\"$ethnicity1\",\"$ethnicity2\",\"$subgroup\",\"$weight\",\"$handedness\",\"$education\",\"" . implode2(', ',$altuids) . "\",\"$uid$studynum\",\"$studydesc\",\"$studyalternateid\",\"$studymodality\",\"$studydatetime\",\"$studyoperator\",\"$studyperformingphysician\",\"$studysite\""; } ?> <tr> <? if ($columns != "min") { ?> <td><?php echo $name; ?> </td> <? } ?> <td><a href="subjects.php?id=<?php echo $subjectid; ?> "><?php echo $uid; ?> </a></td> <? if ($columns != "min") { ?> <? if ($age <= 0) {$color = "red";} else {$color="black";} ?> <td style="color:<?php echo $color; ?> "><?php echo number_format($age, 1); ?> Y</td> <? if (!in_array(strtoupper($gender),array('M','F','O'))) {$color = "red";} else {$color="black";} ?> <td style="color:<?php echo $color; ?> "><?php echo $gender; ?> </td> <td style="font-size:8pt"><?php echo $ethnicity1; ?> <?php echo $ethnicity2; ?> </td> <td style="font-size:8pt"><?php echo $subgroup; ?> </td> <? if ($weight <= 0) {$color = "red";} else {$color="black";} ?> <td style="color:<?php echo $color; ?> "><?php echo number_format($weight, 1); ?> kg</td> <td><?php echo $handedness; ?> </td> <td><?php echo $education; ?> </td> <td style="font-size:8pt"><?php echo implode2(', ', $altuids); ?> </td> <td><a href="studies.php?id=<?php echo $studyid; ?> "><?php echo $uid; echo $studynum; ?> </a></td> <td style="font-size:8pt"><?php echo $studydesc; ?> </td> <td><?php echo $studyalternateid; ?> </td> <td><?php echo $studymodality; ?> </td> <td><?php echo $studydatetime; ?> </td> <td><?php echo $studyoperator; ?> </td> <td><?php echo $studyperformingphysician; ?> </td> <td style="font-size:8pt"><?php echo $studysite; ?> </td> <? } ?> <? if (count($measurenames) > 0) { if ($groupmeasures == "byvalue") { foreach ($measurenames as $measurename) { $csv .= ",\"" . $measuredata[$subjectid][$measurename] . "\""; ?> <td class="seriesrow"> <? if (isset($measuredata[$subjectid][$measurename])) { echo $measuredata[$subjectid][$measurename]; } ?> </td> <? } } else { foreach ($measurenames as $measure) { $csv .= ",\"" . $measuredata[$subjectid][$measure]['value'] . "\""; ?> <td class="seriesrow"> <? if (isset($measuredata[$subjectid][$measure]['value'])) { foreach ($measuredata[$subjectid][$measure]['value'] as $value) { echo "$value<br>"; } } ?> </td> <? } } } ?> <!--<td><a href="groups.php?action=removegroupitem&itemid=<?php echo $itemid; ?> &id=<?php echo $id; ?> " style="color:red">X</a></td>--> <td><input type="checkbox" name="itemid[]" value="<?php echo $itemid; ?> "></td> </tr> <? } ?> <tr> <td colspan="100" align="right"> <input type="submit" value="Remove"> </form> </td> </tr> </tbody> </table> </td> </tr> </table> <? /* ---------- generate csv file ---------- */ $filename = $groupname . "_" . GenerateRandomString(10) . ".csv"; file_put_contents("/tmp/" . $filename, $csv); ?> <div width="50%" align="center" style="background-color: #FAF8CC; padding: 5px;"> Download .csv file <a href="download.php?type=file&filename=<?php echo "/tmp/{$filename}"; ?> "><img src="images/download16.png"></a> </div> <? } /* ------------------ series group type ------------------- */ if ($grouptype == "series") { /* get a distinct list of modalities... then get a list of series for each modality */ $sqlstring = "select distinct(modality) from group_data where group_id = $id order by modality"; $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $modalities[] = $row['modality']; } foreach ($modalities as $modality) { $modality = strtolower($modality); /* get the demographics (series level) */ $sqlstring = "select b.*,c.enroll_subgroup, e.*, (datediff(b.series_datetime, e.birthdate)/365.25) 'age' from group_data a left join ".$modality."_series b on a.data_id = b.".$modality."series_id left join studies c on b.study_id = c.study_id left join enrollment d on c.enrollment_id = d.enrollment_id left join subjects e on d.subject_id = e.subject_id where a.group_id = 3 and a.modality = '".$modality."' and e.subject_id is not null group by e.uid"; $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $studyid = $row['study_id']; $studynum = $row['study_num']; $studydesc = $row['study_desc']; $studyalternateid = $row['study_alternateid']; $studymodality = $row['study_modality']; $studydatetime = $row['study_datetime']; $studyoperator = $row['study_operator']; $studyperformingphysician = $row['study_performingphysician']; $studysite = $row['study_site']; $studyinstitution = $row['study_institution']; $studynotes = $row['study_notes']; $subgroup = $row['enroll_subgroup']; $subjectid = $row['subject_id']; $name = $row['name']; $birthdate = $row['birthdate']; $age = $row['age']; $gender = $row['gender']; $ethnicity1 = $row['ethnicity1']; $ethnicity2 = $row['ethnicity2']; $weight = $row['weight']; $handedness = $row['handedness']; $education = $row['education']; $uid = $row['uid']; /* do some demographics calculations */ $n++; if ($age > 0) { $totalage += $age; $numage++; $ages[] = $age; } if ($weight > 0) { $totalweight += $weight; $numweight++; $weights[] = $weight; } $genders{$gender}++; $educations{$education}++; $ethnicity1s{$ethnicity1}++; $ethnicity2s{$ethnicity2}++; $handednesses{$handedness}++; } } /* calculate some stats */ if ($numage > 0) { $avgage = $totalage/$numage; } else { $avgage = 0; } if (count($ages) > 0) { $varage = sd($ages); } else { $varage = 0; } if ($numweight > 0) { $avgweight = $totalweight/$numweight; } else { $avgweight = 0; } if (count($weights) > 0) { $varweight = sd($weights); } else { $varweight = 0; } ?> <table> <tr> <td valign="top" style="padding-right:20px"> <? DisplayDemographicsTable($n,$avgage,$varage,$genders,$ethnicity1s,$ethnicity2s,$educations,$handednesses,$avgweight,$varweight); ?> </td> <td valign="top" style="padding-right:20px"> <details> <summary>SQL</summary> <?php echo PrintSQL($sqlstring); ?> </details> </td> <td valign="top"> <table class="smallgraydisplaytable"> <th>Initials</th> <th>UID</th> <th>Age<br><span class="tiny">at study</span></th> <th>Sex</th> <th>Ethnicities</th> <th>SubGroup</th> <th>Weight</th> <th>Handedness</th> <th>Education</th> <th>Alt UIDs</th> <th>Study ID</th> <th>Description/Protocol</th> <th>Modality</th> <th>Date/time</th> <th>Series #</th> <th>Remove<br>from group</th> <? /* get a distinct list of modalities... then get a list of series for each modality */ /* reset the result pointer to 0 to iterate through the results again */ foreach ($modalities as $modality) { $modality = strtolower($modality); /* get the demographics (series level) */ $sqlstring = "select b.*, c.study_num, e.*, (datediff(b.series_datetime, e.birthdate)/365.25) 'age' from group_data a left join ".$modality."_series b on a.data_id = b.".$modality."series_id left join studies c on b.study_id = c.study_id left join enrollment d on c.enrollment_id = d.enrollment_id left join subjects e on d.subject_id = e.subject_id where a.group_id = 3 and a.modality = '".$modality."' and e.subject_id is not null"; //print "[$sqlstring]<br>"; $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); mysql_data_seek($result,0); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $seriesdesc = $row['series_desc']; $seriesprotocol = $row['series_protocol']; $seriesdatetime = $row['series_datetime']; $seriesnum = $row['series_num']; $studynum = $row['study_num']; $seriesmodality = strtoupper($modality); $itemid = $row['subjectgroup_id']; $subjectid = $row['subject_id']; $name = $row['name']; $birthdate = $row['birthdate']; $age = $row['age']; $gender = $row['gender']; $ethnicity1 = $row['ethnicity1']; $ethnicity2 = $row['ethnicity2']; $weight = $row['weight']; $handedness = $row['handedness']; $education = $row['education']; $uid = $row['uid']; /* get list of alternate subject UIDs */ $altuids = GetAlternateUIDs($subjectid); $parts = explode("^",$name); $name = substr($parts[1],0,1) . substr($parts[0],0,1); ?> <tr> <td><?php echo $name; ?> </td> <td><a href="subjects.php?id=<?php echo $subjectid; ?> "><?php echo $uid; ?> </a></td> <? if ($age <= 0) {$color = "red";} else {$color="black";} ?> <td style="color:<?php echo $color; ?> "><?php echo number_format($age, 1); ?> Y</td> <? if (!in_array(strtoupper($gender),array('M','F','O'))) {$color = "red";} else {$color="black";} ?> <td style="color:<?php echo $color; ?> "><?php echo $gender; ?> </td> <td style="font-size:8pt"><?php echo $ethnicitiy1; ?> <?php echo $ethnicitiy1; ?> </td> <td style="font-size:8pt"><?php echo $subgroup; ?> </td> <? if ($weight <= 0) {$color = "red";} else {$color="black";} ?> <td style="color:<?php echo $color; ?> "><?php echo number_format($weight, 1); ?> kg</td> <td><?php echo $handedness; ?> </td> <td><?php echo $education; ?> </td> <td style="font-size:8pt"><?php echo implode2(', ', $altuids); ?> </td> <td><a href="studies.php?id=<?php echo $studyid; ?> "><?php echo $uid; echo $studynum; ?> </a></td> <td style="font-size:8pt"><?php echo $seriesdesc; ?> <?php echo $seriesprotocol; ?> </td> <td><?php echo $seriesmodality; ?> </td> <td style="font-size:8pt"><?php echo $seriesdatetime; ?> </td> <td><?php echo $seriesnum; ?> </td> <td><a href="groups.php?action=removegroupitem&itemid=<?php echo $itemid; ?> &id=<?php echo $id; ?> " style="color:red">X</a></td> </tr> <? } } ?> </table> </td> </tr> </table> <? } }
function Validate($k) { $k = mysql_real_escape_string($k); if (trim($k) == "") { return 0; } /* check if the key exists in the users_pending table */ $sqlstring = "select * from users_pending where emailkey = '{$k}'"; //echo "$sqlstring<br>"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result, MYSQL_ASSOC); $userpendingid = $row['user_id']; $username = $row['username']; $password = $row['password']; $fullname = $row['user_fullname']; $institution = $row['user_institution']; $country = $row['user_country']; $email = $row['user_email']; } else { return 0; } /* if no errors were found so far, insert the row, with the user disabled */ $sqlstring = "insert into users (username, password, login_type, user_fullname, user_institution, user_country, user_email, user_enabled) values ('{$username}','{$password}','Standard','{$fullname}','{$institution}','{$country}','{$email}',1)"; //PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $userid = mysql_insert_id(); $sqlstring = "delete from users_pending where user_id = {$userpendingid}"; //PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); /* insert a row into the instance permissions for the default instance */ $sqlstring = "insert into user_instance (user_id, instance_id) values ({$userid}, (select instance_id from instance where instance_default = 1))"; //PrintSQL($sqlstring); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $body = "<b>Your NiDB account on " . $GLOBALS['cfg']['siteurl'] . " account is active and you are joined to the main instance</b><br><br>Login now: " . $GLOBALS['cfg']['siteurl'] . "/login.php<br><br>Follow these steps to join other instances<ol><li>Login to NiDB: " . $GLOBALS['cfg']['siteurl'] . "/login.php<li>Click your username at the top of the page<li>Find the instance you want to join on the list of available instances<li>The owner of the instance will receive notification that you want to join<li>You will receive a notifiication of the owners response to your join request</ol><br><br>"; /* send the email */ SendGmail($email, 'Your NiDB account has been acitvated', $body, 0); return 1; }
<?php require_once 'header.php'; ?> <section id="slider"><!--slider--> <div class="container"> <div class="row"> <div class="col-sm-12"> <div id="slider-carousel" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> </ol> <div class="carousel-inner"> <?php $SQL = "SELECT * FROM tblbanner WHERE banner_status='1'"; $result = MySQLQuery($SQL); $i = 1; while ($row = mysql_fetch_array($result)) { ?> <div class="item <?php if ($i == 1) { echo "active"; } ?> "> <div class="col-sm-12"> <img src="admin/images/<?php echo $row['banner_image']; ?> " height="500" class="girl img-responsive" alt="" /> </div>
function GetAlternateUIDs($subjectid, $enrollmentid) { $sqlstring = "select * from subject_altuid where subject_id = '{$subjectid}' and enrollment_id = '{$enrollmentid}' order by altuid"; //$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>"); $result = MySQLQuery($sqlstring, __FILE__, __LINE__); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $isprimary = $row['isprimary']; if ($isprimary) { $altuids[] = '*' . $row['altuid']; } else { $altuids[] = $row['altuid']; } } return $altuids; }
function UploadNonDICOM($equipmentid, $siteid, $projectid, $instanceid, $dataformat, $matchidonly, $transactionid) { $equipmentid = mysql_real_escape_string($equipmentid); $siteid = mysql_real_escape_string($siteid); $projectid = mysql_real_escape_string($projectid); $instanceid = mysql_real_escape_string($instanceid); $dataformat = mysql_real_escape_string($dataformat); $matchidonly = mysql_real_escape_string($matchidonly); $transactionid = mysql_real_escape_string($transactionid); /* get the instanceRowID */ $sqlstring = "select instance_id from instance where instance_id = '{$instanceid}' or instance_uid = '{$instanceid}'"; //echo "[[$sqlstring]]"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $instanceRowID = $row['instance_id']; /* get the projectRowID */ $sqlstring = "select project_id from projects where project_id = '{$projectid}' or project_uid = '{$projectid}'"; //echo "[[$sqlstring]]"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $projectRowID = $row['project_id']; /* get the siteRowID */ $sqlstring = "select site_id from nidb_sites where site_id = '{$siteid}' or site_uid = '{$siteid}'"; //echo "[[$sqlstring]]"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $siteRowID = $row['site_id']; /* get next import ID */ $sqlstring = "insert into import_requests (import_transactionid, import_datatype, import_datetime, import_status, import_equipment, import_siteid, import_projectid, import_instanceid, import_uuid, import_anonymize, import_permanent, import_matchidonly) values ('{$transactionid}', '{$dataformat}',now(),'uploading','{$equipmentid}','{$siteRowID}','{$projectRowID}', '{$instanceRowID}', '{$uuid}','{$anonymize}','{$permanent}','{$matchidonly}')"; //echo "[[$sqlstring]]"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $uploadID = mysql_insert_id(); $numfiles = 0; //echo "I'm still here\n"; $savepath = $GLOBALS['cfg']['uploadedpath'] . "/{$uploadID}"; $behsavepath = $GLOBALS['cfg']['uploadedpath'] . "/{$uploadID}/beh"; /* go through all the files and save them */ if (isset($_FILES['files'])) { mkdir($savepath, 0777, true); chmod($savepath, 0777); foreach ($_FILES['files']['name'] as $i => $name) { if (move_uploaded_file($_FILES['files']['tmp_name'][$i], "{$savepath}/{$name}")) { //echo "RECEIVED $name\n"; $numfiles++; chmod("{$savepath}/{$name}", 0777); $success = 1; } else { echo "ERROR {$name}\n"; $success = 0; } /* record this received file in the import_received table */ //$sqlstring = "insert into import_received (import_transactionid, import_uploadid, import_filename, import_filesize, import_datetime, import_destination, import_success, import_userid, import_instanceid, import_projectid, import_siteid, import_route) values ('$transactionid', '$uploadID', '$name', '$filesize', now(), '$savepath/$name', '$success', '" . $GLOBALS['userid'] . "', '$instanceRowID', '$projectRowID', '$siteRowID', 'api.php-uploadnondicom')"; $sqlstring = "insert into import_received (import_transactionid, import_uploadid, import_filename, import_filesize, import_datetime, import_success, import_userid, import_instanceid, import_projectid, import_siteid, import_route) values ('{$transactionid}', '{$uploadID}', '{$name}', '{$filesize}', now(), '{$success}', '" . $GLOBALS['userid'] . "', '{$instanceRowID}', '{$projectRowID}', '{$siteRowID}', 'api.php-uploadnondicom')"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); } } /* go through all the beh files and save them */ if (isset($_FILES['behs'])) { mkdir($behsavepath, 0777, true); chmod($behsavepath, 0777); foreach ($_FILES['behs']['name'] as $i => $name) { if (move_uploaded_file($_FILES['behs']['tmp_name'][$i], "{$behsavepath}/{$name}")) { //echo "RECEIVED $name\n"; $numfiles++; chmod("{$behsavepath}/{$name}", 0777); $success = 1; } else { echo "ERROR {$name}\n"; $success = 0; } /* record this received file in the import_received table */ //$sqlstring = "insert into import_received (import_transactionid, import_uploadid, import_filename, import_filesize, import_datetime, import_destination, import_success, import_userid, import_instanceid, import_projectid, import_siteid, import_route) values ('$transactionid', '$uploadID', '$name', '$filesize', now(), '$savepath/$name', '$success', '" . $GLOBALS['userid'] . "', '$instanceRowID', '$projectRowID', '$siteRowID', 'api.php-uploadnondicom')"; $sqlstring = "insert into import_received (import_transactionid, import_uploadid, import_filename, import_filesize, import_datetime, import_success, import_userid, import_instanceid, import_projectid, import_siteid, import_route) values ('{$transactionid}', '{$uploadID}', '{$name}', '{$filesize}', now(), '{$success}', '" . $GLOBALS['userid'] . "', '{$instanceRowID}', '{$projectRowID}', '{$siteRowID}', 'api.php-uploadnondicom')"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); } } $sqlstring = "update import_requests set import_status = 'pending' where importrequest_id = {$uploadID}"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); echo "NiDB: Successfully received {$numfilessuccess} of {$numfilestotal} files and {$numbehsuccess} of {$numbehtotal} beh files"; }
function RearchiveSubjects($studyids, $matchidonly) { /* get list of subjects from the studyids */ $sqlstring = "select subject_id, uid from subjects where subject_id in (select subject_id from enrollment where enrollment_id in (select enrollment_id from studies where study_id in (" . implode(',', $studyids) . ") ))"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $ids[] = $row['subject_id']; $uids[] = $row['uid']; } /* delete all information about this subject from the database */ foreach ($ids as $id) { if ($matchidonly) { $sqlstring = "insert into fileio_requests (fileio_operation, data_type, data_id, username, requestdate) values ('rearchiveidonly', 'subject', {$id},'" . $GLOBALS['username'] . "', now())"; } else { $sqlstring = "insert into fileio_requests (fileio_operation, data_type, data_id, username, requestdate) values ('rearchive', 'subject', {$id},'" . $GLOBALS['username'] . "', now())"; } $result = MySQLQuery($sqlstring, __FILE__, __LINE__); } ?> <div align="center" class="message">Subjects [<?php echo implode(', ', $uids); ?> ] queued for re-archiving</div> <?php }
function ProcessRequest($r, $username) { $downloadimaging = $r['downloadimaging']; $downloadbeh = $r['downloadbeh']; $downloadqc = $r['downloadqc']; $ip = getenv('REMOTE_ADDR'); $modality = $r['modality']; $destinationtype = $r['destination']; $nfsdir = $r['nfsdir']; $realnfsdir = "/mount" . $r['nfsdir']; $seriesids = $r['seriesid']; $enrollmentids = $r['enrollmentid']; $remoteftpusername = $r['remoteftpusername']; $remoteftppassword = $r['remoteftppassword']; $remoteftpserver = $r['remoteftpserver']; $remoteftpport = $r['remoteftpport']; $remoteftppath = $r['remoteftppath']; $remotenidbserver = $r['remotenidbserver']; $remotenidbusername = $r['remotenidbusername']; $remotenidbpassword = $r['remotenidbpassword']; $remoteinstanceid = $r['remoteinstanceid']; $remotesiteid = $r['remotesiteid']; $remoteprojectid = $r['remoteprojectid']; $publicdownloaddesc = $r['publicdownloaddesc']; $publicdownloadreleasenotes = $r['publicdownloadreleasenotes']; $publicdownloadpassword = $r['publicdownloadpassword']; $publicdownloadshareinternal = $r['publicdownloadshareinternal']; $publicdownloadregisterrequired = $r['publicdownloadregisterrequired']; $publicdownloadexpire = $r['publicdownloadexpire']; $preserveseries = $r['preserveseries']; $filetype = $r['filetype']; $gzip = $r['gzip']; $anonymize = $r['anonymize']; $dirformat = $r['dirformat']; $timepoints = $r['timepoints']; $behformat = $r['behformat']; $behdirnameroot = $r['behdirnameroot']; $behdirnameseries = $r['behdirnameseries']; $subjectmeta = $r['subjectmeta']; $subjectdata = $r['subjectdata']; $subjectphenotype = $r['subjectphenotype']; $subjectforms = $r['subjectforms']; $studymeta = $r['studymeta']; $studydata = $r['studydata']; $seriesmeta = $r['seriesmeta']; $seriesdata = $r['seriesdata']; $allsubject = $r['allsubject']; $downloadimaging = $r['downloadimaging']; $downloadbeh = $r['downloadbeh']; $downloadqc = $r['downloadqc']; //echo "<pre>"; //print_r($r); //echo "</pre>"; if (!$downloadbeh) { $behformat = "behnone"; } if (($seriesids == "") && ($enrollmentids == "")) { echo "You didn't select any series or subjects to download/export! Go back and select something<br>"; exit(0); } if ($destinationtype == "nfs") { if ($nfsdir == "") { echo "NFS destination directory was blank! go back and enter a destination directory<br>"; exit(0); } if (strpos($nfsdir," ") != false) { echo "Destination directory cannot contain spaces. You must choose a different destination directory that does not have spaces<br>"; exit(0); } if ((file_exists("$realnfsdir") == false) || ($nfsdir == "/")) { echo "Invalid NFS destination directory! go back and enter a valid destination directory<br>"; exit(0); } clearstatcache(); $perms = substr(sprintf('%o', fileperms($realnfsdir)),-3); if ($perms != "777"){ echo "Incorrect permissions [$perms] on destination directory [$realnfsdir]. Should be 777.<br>Set permissions to read/write for everyone by typing 'chmod -R 777 $nfsdir' at the command line in the parent directory of your destination<br>"; exit(0); } } $requestingip = $ip; //$destinationtype = $destination; ?> <table> <tr><td align="right"><b>Your IP</b></td><td> <? echo $requestingip; ?></td></tr> <tr><td align="right"><b>Username</b></td><td> <? echo $username; ?></td></tr> <tr><td align="right"><b>Destination Type</b></td><td> <? echo $destinationtype; ?></td></tr> <? if ($destinationtype == "remoteftp") { ?> <tr><td align="right"><b>FTP username</b></td><td> <? echo $remoteftpusername; ?></td></tr> <tr><td align="right"><b>FTP Password</b></td><td> <? echo $remoteftppassword; ?></td></tr> <tr><td align="right"><b>FTP Server</b></td><td> <? echo $remoteftpserver; ?></td></tr> <tr><td align="right"><b>FTP Port</b></td><td> <? echo $remoteftpport; ?></td></tr> <!--<tr><td align="right"><b>Is sFTP?</b></td><td> <? if ($remoteftpsecure) echo "Y"; else echo "N"; ?></td></tr>--> <? } if ($destinationtype == "remotenidb") { ?> <tr><td align="right"><b>NiDB username</b></td><td> <? echo $remotenidbusername; ?></td></tr> <tr><td align="right"><b>NiDB Password</b></td><td> <? echo $remotenidbpassword; ?></td></tr> <tr><td align="right"><b>NiDB Server</b></td><td> <? echo $remotenidbserver; ?></td></tr> <tr><td align="right"><b>NiDB Instance ID</b></td><td> <? echo $remoteinstanceid; ?></td></tr> <tr><td align="right"><b>NiDB Site ID</b></td><td> <? echo $remotesiteid; ?></td></tr> <tr><td align="right"><b>NiDB Project ID</b></td><td> <? echo $remoteprojectid; ?></td></tr> <? } if ($filetype == "dicom") { ?> <tr> <td align="right"><b>Anonymize?</b></td><td> <? if ($anonymize == 0) { echo " None"; } if ($anonymize == 1) { echo " Light"; } if ($anonymize == 2) { echo " Full"; } ?> </td> </tr> <? } ?> <tr><td align="right"><b>Preserve series #?</b></td><td> <? if ($preserveseries) echo "Y"; else echo "N"; ?></td></tr> </table> <br><br> The following data will be transferred<br><br> <table width="100%" class="smalldisplaytable"> <tr> <td><b>UID</b></td> <td><b>Study Date</b></td> <td><b>'scanid'</b></td> <td><b>Series #</b></td> <td><b>New directory/series #</b></td> <td><b>Format</b></td> <td><b>Data size (bytes)</b></td> <td><b>Destination</b></td> </tr> <? /* get the next group ID */ $sqlstring = "select max(req_groupid) 'max' from data_requests"; $result = MySQLQuery($sqlstring,__FILE__,__LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $groupid = $row['max'] + 1; /* if this is a public download, create the row in the public_download table, and get the ID */ if ($destinationtype == "publicdownload") { $sqlstring = "insert into public_downloads (pd_createdby, pd_desc, pd_notes, pd_password, pd_shareinternal, pd_registerrequired, pd_expiredays, pd_status) values ('$username', '$publicdownloaddesc', '$publicdownloadreleasenotes', sha1('$publicdownloadpassword'), '$publicdownloadshareinternal', '$publicdownloadregisterrequired', '$publicdownloadexpire', 'started')"; $result = MySQLQuery($sqlstring,__FILE__,__LINE__); $publicDownloadRowID = mysql_insert_id(); } $i = 1; /* get information from the database based on the series IDs provided */ $totalunzipsize = 0; $sqlstrings = array(); $modality = strtolower($modality); if ($destinationtype == 'export') { if ($enrollmentids == "") { $seriesidlist = implode2(",", $seriesids); $sqlstrings[$modality] = "select a.*, b.*, d.project_name, d.project_costcenter, e.uid from " . $modality . "_series a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join projects d on c.project_id = d.project_id left join subjects e on e.subject_id = c.subject_id where " . $modality . "series_id in ($seriesidlist) order by uid, study_num, series_num"; } else { /* set all of the download options */ $preserveseries = 1; $filetype = 'export'; //$dirformat = ''; /* if only seriesids have been selected, thats the only data that will be exported */ /* get enrollment IDs from the series IDs */ $seriesidlist = implode2(",", $seriesids); $sqlstring = "select distinct(b.enrollment_id) from " . $modality . "_series a left join studies b on a.study_id = b.study_id where a.series_id in ($seriesidlist)"; //PrintSQL($sqlstring); $enrollmentidlist = implode2(",", $enrollmentids); /* get modality list from studies table */ $sqlstring = "select distinct(study_modality) 'study_modality' from studies where enrollment_id in ($enrollmentidlist)"; $result = MySQLQuery($sqlstring, __FILE__ , __LINE__); $numseries = mysql_num_rows($result); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $modalities[] = strtolower($row['study_modality']); } //print_r($modalities); /* loop through all modalities and do the following: */ foreach ($modalities as $modality) { $sqlstrings[$modality] = "select a.*, b.*, d.project_name, d.project_costcenter, e.uid from " . $modality . "_series a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join projects d on c.project_id = d.project_id left join subjects e on e.subject_id = c.subject_id where b.enrollment_id in ($enrollmentidlist) order by uid, study_num, series_num"; } } } else { $seriesidlist = implode2(",", $seriesids); $sqlstrings[$modality] = "select a.*, b.*, d.project_name, d.project_costcenter, e.uid from " . $modality . "_series a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join projects d on c.project_id = d.project_id left join subjects e on e.subject_id = c.subject_id where " . $modality . "series_id in ($seriesidlist) order by uid, study_num, series_num"; } $numseries = 0; foreach ($sqlstrings as $modality => $sqlstring) { //PrintSQL($sqlstring); echo "(A) $remotenidbserver, $remotenidbusername, $remotenidbpassword, $remoteinstanceid, $remotesiteid, $remoteprojectid<br>"; $result = MySQLQuery($sqlstring, __FILE__ , __LINE__); //PrintSQLTable($result); $numseries += mysql_num_rows($result); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "(B) $remotenidbserver, $remotenidbusername, $remotenidbpassword, $remoteinstanceid, $remotesiteid, $remoteprojectid<br>"; $safe = true; /* go through the list and populate the request table */ $series_id = $row[$modality . 'series_id']; $series_desc = $row['series_desc']; $series_altdesc = $row['series_altdesc']; $series_num = $row['series_num']; $study_id = $row['study_id']; $study_num = $row['study_num']; $study_datetime = $row['study_datetime']; $uid = $row['uid']; $series_size = $row['series_size']; $project_name = $row['project_name']; $project_costcenter = $row['project_costcenter']; if (($img_format == "dicom") && ($destinationtype == "remoteftp")) { $safe = false; } $currentstudyid = $study_id; if ($preserveseries) { $run = $series_num; } else { //echo "current: $currentstudyid... last: $laststudyid<br>"; if ($laststudyid != $currentstudyid) { $run = 1; } else { $run++; } } $remoteftpport = 21; $remoteftpsecure = 0; switch ($dirformat) { case "datetime": $newdir = date("Ymd_His",strtotime($study_datetime)); break; case "datetimeshortid": $newdir = date("Ymd_His",strtotime($study_datetime)) . "_$uid" . $study_num; break; case "datetimelongid": $newdir = date("Ymd_His",strtotime($study_datetime)) . "_$uid" . "_$project_costcenter" . "_$study_num"; break; case "shortid": $newdir = $uid . $study_num; break; case "longid": $newdir = $uid . "_$project_costcenter" . "_$study_num"; break; } $timepoint = $timepoints[$series_id]; if ($safe) { $totalseriessize += $series_size; $sqlstringA = "insert into data_requests (req_username, req_ip, req_groupid, req_modality, req_downloadimaging, req_downloadbeh, req_downloadqc, req_destinationtype, req_nfsdir, req_seriesid, req_filetype, req_gzip, req_anonymize, req_preserveseries, req_dirformat, req_timepoint, req_ftpusername, req_ftppassword, req_ftpserver, req_ftpport, req_ftppath, req_nidbserver, req_nidbusername, req_nidbpassword, req_nidbinstanceid, req_nidbsiteid, req_nidbprojectid, req_downloadid, req_behonly, req_behformat, req_behdirrootname, req_behdirseriesname, req_date) values ('$username', '$ip', $groupid, '$modality', '$downloadimaging', '$downloadbeh', '$downloadqc', '$destinationtype', '$nfsdir', $series_id, '$filetype', '$gzip', '$anonymize', '$preserveseries', '$dirformat', '$timepoint', '$remoteftpusername', '$remoteftppassword', '$remoteftpserver', '$remoteftpport', '$remoteftppath', '$remotenidbserver', '$remotenidbusername', sha1('$remotenidbpassword'), '$remoteinstanceid' , '$remotesiteid', '$remoteprojectid', '$publicDownloadRowID', '$behonly', '$behformat', '$behdirnameroot','$behdirnameseries', now())"; //PrintSQL($sqlstringA); $resultA = MySQLQuery($sqlstringA, __FILE__ , __LINE__); ?> <tr> <td><?php echo $uid; ?> </td> <td><?php echo $study_datetime; ?> </td> <td><?php echo $uid; echo $study_num; ?> </td> <td><?php echo $series_num; ?> </td> <td><?php echo $newdir; ?> /<?php echo $run; ?> </td> <td><?php echo $filetype; ?> </td> <td align="right"><?php echo number_format($series_size); ?> </td> <td><?php echo $nfsdir; ?> </td> </tr> <? } else { ?> <tr style="background-color: lightyellow"> <td style="color: red"><? echo $studyscanid; ?></td> <td style="color: red"><? echo $studyscannerid; ?></td> <td style="color: red"><? echo $seriesnumber; ?></td> <td colspan="4" align="center" style="color: red">Can not send DICOM data directly to a remote FTP site</td> </tr> <? } $laststudyid = $currentstudyid; echo "(C) $remotenidbserver, $remotenidbusername, $remotenidbpassword, $remoteinstanceid, $remotesiteid, $remoteprojectid<br>"; } } ?> <tr> <td colspan="6" style="border-top: 1px solid #AAAAAA"><?php echo $numseries; ?> series</td> <td colspan="3" style="border-top: 1px solid #AAAAAA"><?php echo number_format($totalseriessize); ?> bytes</td> </tr> </table> <br><br> Your batch job has been queued, expect the data to be copied within half an hour. Copying may take longer due to network traffic, server load, or file size <? if (($destinationtype == "localftp") || ($destinationtype == "export")) { ?> Your data has been queued for FTP download.<br><br> <div align="center"> <table><tr><td style="border: solid yellow 1pt; background-color:lightyellow"> Use the following information to login to the FTP server and download your data:<br> <pre> Server/Host: <?php echo $GLOBALS['cfg']['localftphostname']; ?> Login: <?php echo $GLOBALS['cfg']['localftpusername']; ?> Password: <?php echo $GLOBALS['cfg']['localftppassword']; ?> Port: 21 </pre> </td></tr></table></div> <? } echo "<br><br>"; }
function DeleteEnrollments($enrollmentids) { echo "<tt style='font-size:8pt'>"; foreach ($enrollmentids as $id) { $sqlstring = "delete from enrollment where enrollment_id = '$id'"; //PrintSQL($sqlstring); $result = MySQLQuery($sqlstring,__FILE__,__LINE__); echo "Deleted $id: " . mysql_affected_rows() . " altered rows<br>"; } echo "</tt>"; }
function DisplayResults($analysisid, $studyid) { ?> Results for this analysis<br><br> <table class="smalldisplaytable"> <?php if ($studyid == "") { $sqlstring2 = "select a.*, d.result_name from analysis_results a left join analysis b on a.analysis_id = b.analysis_id left join pipelines c on b.pipeline_id = c.pipeline_id left join analysis_resultnames d on d.resultname_id = a.result_nameid where a.analysis_id = {$analysisid} order by d.result_name"; } else { $sqlstring2 = "select a.*, d.result_name from analysis_results a left join analysis b on a.analysis_id = b.analysis_id left join pipelines c on b.pipeline_id = c.pipeline_id left join analysis_resultnames d on d.resultname_id = a.result_nameid where b.study_id = {$studyid} and a.analysis_id = {$analysisid} order by d.result_name"; } $result2 = MySQLQuery($sqlstring2, __FILE__, __LINE__); while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) { //$step = $row['analysis_step']; $pipelinename = $row2['pipeline_name']; $type = $row2['result_type']; $size = $row2['result_size']; $name = $row2['result_name']; $text = $row2['result_text']; $value = $row2['result_value']; $units = $row2['result_units']; $filename = $row2['result_filename']; $swversion = $row2['result_softwareversion']; $important = $row2['result_isimportant']; $lastupdate = $row2['result_lastupdate']; if (strpos($units, '^') !== false) { $units = str_replace('^', '<sup>', $units); $units .= '</sup>'; } if ($important) { $bold = 'bold'; } else { $bold = 'normal'; } ?> <tr style="font-weight: <?php echo $bold; ?> "> <td><?php echo $name; ?> </td> <td align="right"> <?php switch ($type) { case "v": echo "{$value}"; break; case "f": echo $filename; break; case "t": echo $text; break; case "h": echo $filename; break; case "i": ?> <img src="preview.php?image=/mount<?php echo $filename; ?> " style="max-width:800px"> <?php break; } ?> </td> <td style="padding-left:0px"><?php echo $units; ?> </td> <!--<td><?php echo $size; ?> </td>--> <td><?php echo $swversion; ?> </td> <td nowrap><?php echo $lastupdate; ?> </td> </tr> <?php } ?> </table> <?php }
function DisplayPipelineForm($type, $id) { if ($id == "" && $type == "edit") { ?> <div class="error"><b>Error</b> - pipeline ID blank</div><?php return; } $level = 0; /* populate the fields if this is an edit */ if ($type == "edit") { $sqlstring = "select a.*, b.username from pipelines a left join users b on a.pipeline_admin = b.user_id where a.pipeline_id = {$id}"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); $row = mysqli_fetch_array($result, MYSQLI_ASSOC); $title = $row['pipeline_name']; $pipeline_status = $row['pipeline_status']; $pipeline_statusmessage = $row['pipeline_statusmessage']; $pipeline_laststart = $row['pipeline_laststart']; $pipeline_lastfinish = $row['pipeline_lastfinish']; $pipeline_lastcheck = $row['pipeline_lastcheck']; $desc = $row['pipeline_desc']; $numproc = $row['pipeline_numproc']; $submithost = $row['pipeline_submithost']; $queue = $row['pipeline_queue']; $remove = $row['pipeline_removedata']; $version = $row['pipeline_version']; $directory = $row['pipeline_directory']; $usetmpdir = $row['pipeline_usetmpdir']; $tmpdir = $row['pipeline_tmpdir']; $pipelinenotes = $row['pipeline_notes']; $pipelinegroup = $row['pipeline_group']; $resultscript = $row['pipeline_resultsscript']; $deplevel = $row['pipeline_dependencylevel']; $depdir = $row['pipeline_dependencydir']; $deplinktype = $row['pipeline_deplinktype']; $completefiles = $row['pipeline_completefiles']; $dependency = $row['pipeline_dependency']; $groupid = $row['pipeline_groupid']; $dynamicgroupid = $row['pipeline_dynamicgroupid']; $level = $row['pipeline_level']; $owner = $row['username']; $ishidden = $row['pipeline_ishidden']; $isenabled = $row['pipeline_enabled']; //echo "<pre>"; //print_r($GLOBALS); //echo "</pre>"; if ($owner == $GLOBALS['username'] || $GLOBALS['issiteadmin']) { $readonly = false; } else { $readonly = true; } $formaction = "update"; $formtitle = "{$title}"; $submitbuttonlabel = "Update Pipeline Info"; } else { $formaction = "add"; $formtitle = "Add new pipeline"; $submitbuttonlabel = "Add Pipeline Info"; $remove = "0"; $level = 1; $directory = "/home/" . $GLOBALS['username'] . "/onrc/data"; $readonly = false; } if ($readonly) { $disabled = "disabled"; } else { $disabled = ""; } if ($numproc == "") { $numproc = 1; } //$urllist['Analysis'] = "analysis.php"; $urllist['Pipelines'] = "pipelines.php"; $urllist[$title] = "pipelines.php?action=editpipeline&id={$id}"; NavigationBar("Analysis", $urllist); ?> <script type="text/javascript"> $(document).ready(function() { /* default action */ <?php if ($level == 1) { ?> $('.level0').hide(); $('.level1').show(); $('.level2').hide(); <?php } elseif ($level == 0) { ?> $('.level0').show(); $('.level1').hide(); $('.level2').hide(); <?php } else { ?> $('.level0').hide(); $('.level1').show(); $('.level2').show(); <?php } ?> /* click events */ $('#level0').click(function() { if($('#level0').is(':checked')) { $('.level0').show("highlight",{},1000); $('.level1').hide(); $('.level2').hide(); } }); $('#level1').click(function() { if($('#level1').is(':checked')) { $('.level0').hide(); $('.level1').show("highlight",{},1000); $('.level2').hide(); } }); $('#level2').click(function() { if($('#level2').is(':checked')) { $('.level0').hide(); $('.level1').show(); $('.level2').show("highlight",{},1000); } }); }); function AlphaNumeric(e) { var key; var keychar; if (window.event) key = window.event.keyCode; else if (e) key = e.which; else return true; keychar = String.fromCharCode(key); keychar = keychar.toLowerCase(); // control keys if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) return true; // alphas and numbers else if ((("abcdefghijklmnopqrstuvwxyz0123456789_").indexOf(keychar) > -1)) return true; else return false; } </script> <fieldset style="border: 3px solid #999; border-radius:5px"> <legend style="background-color: #3B5998; color:white; padding:5px 10px; border-radius:5px">Status</legend> <table class="entrytable" style="border:0px"> <tr> <td class="label" valign="top">Enabled</td> <td valign="middle"> <?php if ($isenabled) { ?> <a href="pipelines.php?action=disable&returnpage=pipeline&id=<?php echo $id; ?> "><img src="images/checkedbox16.png"title="Pipeline enabled, click to disable"></a><?php } else { ?> <a href="pipelines.php?action=enable&returnpage=pipeline&id=<?php echo $id; ?> "><img src="images/uncheckedbox16.png" title="Pipeline disabled, click to enable"></a><?php } ?> </td> </tr> <tr> <td class="label" valign="top">Status<br><br></td> <td valign="top" style="font-size: 10pt"> <b>Status</b> <?php echo $pipeline_status; ?> <?php if ($pipeline_status == "running") { ?> (<a href="pipelines.php?action=reset&id=<?php echo $info['id']; ?> " style="color: darkred" title="Reset the status if you KNOW the pipeline has stopped running... ie, it hasn't updated the status in a couple days">reset</a>)<?php } ?> <br> <b>Status message</b> <?php echo $pipeline_statusmessage; ?> <br> <b>Last start</b> <?php echo $pipeline_laststart; ?> <br> <b>Last finish</b> <?php echo $pipeline_lastfinish; ?> <br> <b>Last check</b> <?php echo $pipeline_lastcheck; ?> <br> </td> </tr> </table> </fieldset> <br> <fieldset style="border: 3px solid #999; border-radius:5px"> <legend style="background-color: #3B5998; color:white; padding:5px 10px; border-radius:5px"> <b><?php echo $formtitle; ?> </b> version <?php echo $version; ?> </legend> <table> <tr> <td style="padding-right:40px"> <table class="entrytable" style="border:0px"> <form method="post" action="pipelines.php"> <input type="hidden" name="action" value="<?php echo $formaction; ?> "> <input type="hidden" name="id" value="<?php echo $id; ?> "> <tr> <td class="label" valign="top">Title</td> <td valign="top"> <input type="text" name="pipelinetitle" value="<?php echo $title; ?> " maxlength="50" size="60" onKeyPress="return AlphaNumeric(event)" <?php if ($type == "edit") { echo "readonly style='background-color: #EEE; border: 1px solid gray; color: #888'"; } ?> > </td> </tr> <tr> <td class="label" valign="top">Description</td> <td valign="top"><input type="text" <?php echo $disabled; ?> name="pipelinedesc" value="<?php echo $desc; ?> " size="60"></td> </tr> <tr> <td class="label" valign="top">Stats level</td> <td valign="top"> <!--<input type="radio" name="level" id="level0" value="0" <?php echo $disabled; ?> <?php if ($level == 0) { echo "checked"; } ?> >One-shot <span class="tiny">Runs only once. No associated data</span><br>--> <input type="radio" name="level" id="level1" value="1" <?php echo $disabled; ?> <?php if ($level == 1) { echo "checked"; } ?> >First <span class="tiny">subject level</span><br> <input type="radio" name="level" id="level2" value="2" <?php echo $disabled; ?> <?php if ($level == 2) { echo "checked"; } ?> >Second <span class="tiny">group level</span><br> </td> </tr> <tr> <td class="label" valign="top">Group</td> <td valign="top"> <input type="text" name="pipelinegroup" list="grouplist" <?php echo $disabled; ?> value="<?php echo $pipelinegroup; ?> " maxlength="255" size="60"> </td> <datalist id="grouplist"> <?php $sqlstring = "select distinct(pipeline_group) 'pipeline_group' from pipelines"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $pgroup = $row['pipeline_group']; echo "<option value='{$pgroup}'>"; } ?> </datalist> </tr> <tr> <td class="label" valign="top">Directory <img src="images/help.gif" title="<b>Directory</b><br><br>A directory called <b>Title</b> (same name as this analysis) will be created inside this directory and will contain the analyses for this pipeline.<br><br>If blank, the analyses for this pipeline will be written to the default pipeline directory: <span style='color: #E8FFFF'>[<?php echo $GLOBALS['cfg']['analysisdir']; ?> ]</span>"></td> <td valign="top"> <input type="text" name="pipelinedirectory" <?php echo $disabled; ?> value="<?php echo $directory; ?> " maxlength="255" size="60" <?php if ($type == "edit") { echo "readonly style='background-color: #EEE; border: 1px solid gray; color: #888'"; } ?> > </td> </tr> <tr class="level1"> <td class="label" valign="top">Concurrent processes <img src="images/help.gif" title="<b>Concurrent processes</b><br><br>This is the number of concurrent jobs allowed to be submitted to the cluster at a time. This number is separate from the number of slots available in the cluster queue, which specified in the grid engine setup"></td> <td valign="top"><input type="number" name="pipelinenumproc" <?php echo $disabled; ?> value="<?php echo $numproc; ?> " min="1" max="350"></td> </tr> <tr> <td class="label" valign="top">Submit host <img src="images/help.gif" title="<b>Submit host</b><br><br>The hostname of the SGE head node to submit to. If blank, the default submit host is used (<?php echo $GLOBALS['cfg']['clustersubmithost']; ?> )"></td> <td valign="top"><input type="text" name="pipelinesubmithost" <?php echo $disabled; ?> value="<?php echo $submithost; ?> "></td> </tr> <tr> <td class="label" valign="top">Queue name <img src="images/help.gif" title="<b>Queue name</b><br><br>The sun grid (SGE) queue to submit to"></td> <td valign="top"><input type="text" name="pipelinequeue" <?php echo $disabled; ?> value="<?php echo $queue; ?> " required></td> </tr> <tr> <td class="label" valign="top">Use temporary directory <img src="images/help.gif" title="<b>Use tmp directory</b><br><br>This option will copy all data into the temporary directory first, process it there, and copy it back to its final location"></td> <td valign="top"><input type="checkbox" name="pipelineusetmpdir" <?php echo $disabled; ?> value="1" <?php if ($usetmpdir == "1") { echo "checked"; } ?> > <input type="text" name="pipelinetmpdir" <?php echo $disabled; ?> value="<?php echo $tmpdir; ?> " size="56"><br> <span class="tiny">Usually <tt>/tmp</tt>. Check with your sysadmin</span></td> </tr> <!--<tr class="level1"> <td class="label" valign="top">Data download</td> <td valign="top"> <input type="radio" name="dataand" value="0" <?php echo $disabled; ?> <?php if ($dataand == 0) { echo "checked"; } ?> >or <span class="tiny">download any of the data specified below</span><br> <input type="radio" name="dataand" value="1" <?php echo $disabled; ?> <?php if ($dataand == 1) { echo "checked"; } ?> >and <span class="tiny">only download data if all of the series specified exist in the study</span><br> <input type="radio" name="dataand" value="-1" <?php echo $disabled; ?> <?php if ($dataand == -1) { echo "checked"; } ?> >none <span class="tiny">no data download. only use if the pipeline has a dependency</span> </td> </tr>--> <!--<tr class="level1"> <td class="label" valign="top">Remove downloaded data?</td> <td valign="top" title="<b>Remove downloaded data</b><br><br>Deletes all downloaded (raw) data after analysis is complete. Assumes that the analsysis will have copied or converted the necessary data and no longer needs it"><input type="checkbox" name="pipelineremovedata" value="1" <?php if ($remove) { echo "checked"; } ?> ></td> </tr>--> <tr> <td class="label" valign="top">Successful files <img src="images/help.gif" title="<b>Successful files</b><br><br>The analysis is marked as successful if ALL of the files specified exist at the end of the analysis. If left blank, the analysis will always be marked as successful"></td> <td valign="top"><textarea name="completefiles" <?php echo $disabled; ?> rows="5" cols="60"><?php echo $completefiles; ?> </textarea><br> <span class="tiny">Comma seperated list of files (relative paths)</span></td> </tr> <tr> <td class="label" valign="top">Results script <img src="images/help.gif" title="<b>Results script</b><br><br>This script will be executed last and can be re-run separate from the analysis pipeline. The results script would often be used to create thumbnails of images and parse text files, and reinsert those results back into the database. The same pipeline variables available in the script command section below are available here to be passed as parameters to the results script"></td> <td valign="top"> <textarea name="pipelineresultsscript" rows="3" cols="60"><?php echo $resultscript; ?> </textarea> </td> </tr> <tr class="level1"> <td class="label" valign="top">Pipeline dependency<br> </td> <td valign="top"> <table class="entrytable"> <tr> <td valign="top" align="right" style="font-size:10pt; font-weight:bold;color: #555;">Dependency</td> <td valign="top"> <select name="dependency[]" <?php echo $disabled; ?> multiple="multiple" size="7"> <option value="">(No dependency)</option> <?php $sqlstring = "select * from pipelines order by pipeline_name"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $d_name = $row['pipeline_name']; $d_id = $row['pipeline_id']; $d_ver = $row['pipeline_version']; /* get the number of analyses in the pipeline */ $sqlstringA = "select count(*) 'count' from analysis where pipeline_id = {$d_id} and analysis_status = 'complete'"; $resultA = MySQLiQuery($sqlstringA, __FILE__, __LINE__); $rowA = mysqli_fetch_array($resultA, MYSQLI_ASSOC); $nummembers = $rowA['count']; if (in_array($d_id, explode(",", $dependency))) { $selected = "selected"; } else { $selected = ""; } if ($id != $d_id) { ?> <option value="<?php echo $d_id; ?> " <?php echo $selected; ?> ><?php echo $d_name; ?> [<?php echo $nummembers; ?> ]</option> <?php } } ?> </select> </td> </tr> <tr> <td valign="top" align="right" style="font-size:10pt; font-weight:bold;color: #555;">Criteria</td> <td valign="top"> <input type="radio" name="deplevel" value="study" <?php echo $disabled; ?> <?php if ($deplevel == "study" || $deplevel == "") { echo "checked"; } ?> > study <span class="tiny">use dependencies from same study</span><br> <input type="radio" name="deplevel" value="subject" <?php echo $disabled; ?> <?php if ($deplevel == "subject") { echo "checked"; } ?> > subject <span class="tiny">use dependencies from same subject (other studies)</span> </td> </tr> <tr> <td valign="top" align="right" style="font-size:10pt; font-weight:bold;color: #555;">Directory</td> <td valign="top"> <input type="radio" name="depdir" value="root" <?php echo $disabled; ?> <?php if ($depdir == "root" || $depdir == "") { echo "checked"; } ?> > root directory <img src="images/help.gif" title="copies all files into the analysis root directory <code>{analysisrootdir}/*</code>"><br> <input type="radio" name="depdir" value="subdir" <?php echo $disabled; ?> <?php if ($depdir == "subdir") { echo "checked"; } ?> > sub-directory <img src="images/help.gif" title="copies dependency into a subdirectory of the analysis <code>{analysisrootdir}/<i>DependencyName</i>/*</code>"> </td> </tr> <tr> <td valign="top" align="right" style="font-size:10pt; font-weight:bold;color: #555;">Linking type</td> <td valign="top"> <input type="radio" name="deplinktype" value="hardlink" <?php echo $disabled; ?> <?php if ($deplinktype == "hardlink" || $deplinktype == "") { echo "checked"; } ?> > hard link<br> <input type="radio" name="deplinktype" value="softlink" <?php echo $disabled; ?> <?php if ($deplinktype == "softlink") { echo "checked"; } ?> > soft link<br> <input type="radio" name="deplinktype" value="regularcopy" <?php echo $disabled; ?> <?php if ($deplinktype == "regularcopy") { echo "checked"; } ?> > Regular copy<br> </td> </tr> </table> </td> </tr> <tr class="level1"> <td class="label" valign="top">Group(s) <img src="images/help.gif" title="Perform this analysis ONLY<br>on the studies in the specified groups"><br> <span class="level2" style="color:darkred; font-size:8pt; font-weight:normal"> Second level must have<br> at least one group.<br>Group(s) must be identical to<br>first level <b>dependency's</b> group(s)</span> </td> <td valign="top"> <select name="groupid[]" <?php echo $disabled; ?> multiple="multiple" size="7"> <option value="">(No group)</option> <?php $sqlstring = "select * from groups where group_type = 'study' order by group_name"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $g_name = $row['group_name']; $g_id = $row['group_id']; /* get the number of members of the group */ $sqlstringA = "select count(*) 'count' from group_data where group_id = {$g_id}"; $resultA = MySQLiQuery($sqlstringA, __FILE__, __LINE__); $rowA = mysqli_fetch_array($resultA, MYSQLI_ASSOC); $nummembers = $rowA['count']; if (in_array($g_id, explode(",", $groupid))) { $selected = "selected"; } else { $selected = ""; } ?> <option value="<?php echo $g_id; ?> " <?php echo $selected; ?> ><?php echo $g_name; ?> [<?php echo $nummembers; ?> ]</option> <?php } ?> </select> </td> </tr> <tr> <td class="label" valign="top">Notes<br><span class="tiny">Any information about the analysis</span></td> <td valign="top"><textarea name="pipelinenotes" <?php echo $disabled; ?> rows="8" cols="60"><?php echo $pipelinenotes; ?> </textarea></td> </tr> <tr> <td class="label" valign="top">Hidden?</td> <td valign="top" title="<b>Hidden</b><br><br>Useful to hide a pipeline from the main pipeline list. The pipeline still exists, but it won't show up"><input type="checkbox" name="pipelineishidden" value="1" <?php if ($ishidden) { echo "checked"; } ?> ></td> </tr> <tr> <td colspan="2" align="center"> <br> <input type="submit" <?php echo $disabled; ?> value="<?php echo $submitbuttonlabel; ?> "> </td> </tr> </form> </table> </td> <?php if ($formaction == "update") { ?> <td valign="top"> <?php /* gather statistics about the analyses */ $sqlstring = "select sum(timestampdiff(second, analysis_clusterstartdate, analysis_clusterenddate)) 'cluster_time' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status = 'complete'"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $totaltime = $row['cluster_time']; $totaltime = number_format($totaltime / 60 / 60, 2); $sqlstring = "select sum(timestampdiff(second, analysis_clusterstartdate, analysis_clusterenddate)) 'cluster_timesuccess' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status = 'complete' and analysis_iscomplete = 1"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $totaltimesuccess = $row['cluster_timesuccess']; $totaltimesuccess = number_format($totaltimesuccess / 60 / 60, 2); $sqlstring = "select count(*) 'numcomplete' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status = 'complete'"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numcomplete = $row['numcomplete']; $sqlstring = "select count(*) 'numcompletesuccess' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status = 'complete' and analysis_iscomplete = 1"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numcompletesuccess = $row['numcompletesuccess']; $sqlstring = "select count(*) 'numprocessing' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status = 'processing'"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numprocessing = $row['numprocessing']; $sqlstring = "select count(*) 'numpending' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status = 'pending'"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numpending = $row['numpending']; /* get mean processing times */ $sqlstring = "select analysis_id, timestampdiff(second, analysis_startdate, analysis_enddate) 'analysis_time', timestampdiff(second, analysis_clusterstartdate, analysis_clusterenddate) 'cluster_time' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status <> ''"; //PrintSQL($sqlstring); $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { //$analysis_id = $row['analysis_id']; $analysistimes[] = $row['analysis_time']; $clustertimes[] = $row['cluster_time']; } if (count($clustertimes) == 0) { $clustertimes[] = 0; } if (count($analysistimes) == 0) { $analysistimes[] = 0; } ?> <table class="twocoltable"> <tr> <th colspan="2">Analysis Statistics</th> </tr> <tr> <td>Processing Complete<br><span style="font-weight: normal">Total CPU time</span></td> <td><a href="pipelines.php?action=viewanalyses&id=<?php echo $id; ?> "><?php echo $numcomplete; ?> </a><br><?php echo $totaltime; ?> hours</td> </tr> <tr> <td>Successfuly Completed<br><span style="font-weight: normal">Total CPU time</span></td> <td><a href="pipelines.php?action=viewanalyses&id=<?php echo $id; ?> "><?php echo $numcompletesuccess; ?> </a><br><?php echo $totaltimesuccess; ?> hours</td> </tr> <tr> <td>Processing</td> <td><a href="pipelines.php?action=viewanalyses&id=<?php echo $id; ?> "><?php echo $numprocessing; ?> </a></td> </tr> <tr> <td>Pending</td> <td><a href="pipelines.php?action=viewanalyses&id=<?php echo $id; ?> "><?php echo $numpending; ?> </a></td> </tr> </tr> <td>Setup Time</td> <td><?php echo number_format(min($analysistimes), 1); ?> - <?php echo number_format(max($analysistimes), 1); ?> seconds <br>Mean: <?php echo number_format(mean($analysistimes), 1); ?> seconds</td> </tr> <tr> <td>Cluster Time</td> <td><?php echo number_format(min($clustertimes) / 60 / 60, 2); ?> - <?php echo number_format(max($clustertimes) / 60 / 60, 2); ?> hours <br>Mean: <?php echo number_format(mean($clustertimes) / 60 / 60, 2); ?> hours</td> </tr> <tr> <td colspan="2"> <!-- display performance by hostname --> <details> <summary style="color: #3B5998"> Computing Performance </summary> <table class="smallgraydisplaytable"> <tr> <th colspan="3">Computing performance<br><span class="tiny">Successful analyses only</span></th> </tr> <tr> <td><b>Hostname</b></td> <td><b>Avg CPU</b></td> <td><b>Count</b></td> </tr> <?php $sqlstring = "SELECT avg(timestampdiff(second, analysis_clusterstartdate, analysis_clusterenddate)) 'avgcpu', count(analysis_hostname) 'count', analysis_hostname FROM `analysis` WHERE pipeline_id = {$id} and analysis_iscomplete = 1 group by analysis_hostname order by analysis_hostname"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $cpuhrs = number_format($row['avgcpu'] / 60 / 60, 2); $count = $row['count']; $hostname = $row['analysis_hostname']; ?> <tr> <td><?php echo $hostname; ?> </td> <td><?php echo $cpuhrs; ?> hrs</td> <td><?php echo $count; ?> </td> </tr> <?php } ?> </table> </details> </td> </tr> </table> <br> <br> <script> function GetNewPipelineName(){ var newname = prompt("Please enter a name for the new pipeline","<?php echo $title; ?> "); if (newname != null){ $("#newname").attr("value", newname); document.copypipeline.submit(); } } </script> <details> <summary style="color: #3B5998"> Pipeline Operations </summary> <br> <a href="pipelines.php?action=viewpipeline&id=<?php echo $id; ?> "><img src="images/printer16.png" border="0"> Print view</a> <span class="tiny">(and previous pipeline versions)</span><br><br> <a href="pipelines.php?action=viewanalyses&id=<?php echo $id; ?> "><img src="images/preview.gif"> View analyses</a><br><br> <a href="pipelines.php?action=viewfailedanalyses&id=<?php echo $id; ?> " title="View all imaging studies which did not meet the data criteria, and therefore the pipeline did not attempt to run the analysis"><img src="images/preview.gif"> View ignored studies</a><br><br> <form action="pipelines.php" method="post" name="copypipeline"> <input type="hidden" name="action" value="copy"> <input type="hidden" name="id" value="<?php echo $id; ?> "> <input type="hidden" name="newname" id="newname" value="<?php echo $id; ?> "> <img src="images/copy16.gif"> <input type="button" value="Copy to new pipeline..." onClick="GetNewPipelineName();"><br><br> </form> <?php if (!$readonly) { ?> Change pipeline owner to: <form> <input type="hidden" name="action" value="changeowner"> <input type="hidden" name="id" value="<?php echo $id; ?> "> <select name="newuserid"> <?php $sqlstring = "select * from users where user_enabled = 1 order by username"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $userid = $row['user_id']; $username = $row['username']; $userfullname = $row['user_fullname']; if ($userfullname != "") { $userfullname = "[{$userfullname}]"; } ?> <option value="<?php echo $userid; ?> "><?php echo $username; ?> <?php echo $userfullname; ?> </option><?php } ?> </select> <input type="submit" value="Change"> </form> <a href="pipelines.php?action=detach$id=<?php echo $id; ?> " onclick="return confirm('Are you sure you want to completely detach this pipeline?')" title="This will completely inactivate the pipeline and remove all analyses from the pipeline control. Since the data will no longer be under pipeline control, all analysis results will be deleted. All analysis data will be moved to the directory you specify"><img src="images/disconnect16.png"> Detach entire pipeline</a><br><br> <a href="pipelines.php?action=resetanalyses&id=<?php echo $id; ?> " onclick="return confirm('Are you sure you want to reset the analyses for this pipeline?')" title="This will remove any entries in the database for studies which were not analyzed. If you change your data specification, you will want to reset the analyses. This option does not remove existing analyses, it only removes the flag set for studies that indicates the study has been checked for the specified data"><img src="images/reset16.png"> Reprocess ignored studies</a><br><br> <a href="pipelines.php?action=delete&id=<?php echo $id; ?> " onclick="return confirm('Are you sure you want to delete this pipeline?')"><img src="images/delete16.png"> Delete this pipeline</a> <?php } ?> </details> <br> <span style="color:#555; font-size:11pt; font-weight: bold">Where is my data?</span><br><br> <span style="background-color: #ddd; padding:5px; font-family: monospace; border-radius:3px"> <?php if ($directory != "") { echo $directory; } else { echo $GLOBALS['cfg']['analysisdir']; } ?> /<i>UID</i>/<i>StudyNum</i>/<?php echo $title; ?> </span> </td> <?php } ?> </tr> </table> </fieldset> <?php if ($type == "edit") { ?> <br><br> <script> function addParam(value,id){ var TheTextBox = document.getElementById(id); TheTextBox.value = TheTextBox.value + ' ' + value; } </script> <fieldset style="border: 3px solid #999; border-radius:5px"> <legend style="background-color: #3B5998; color:white; padding:5px 10px; border-radius:5px"> Pipeline specification </legend> <form method="post" action="pipelines.php" name="stepsform" id="stepsform"> <input type="hidden" name="action" value="updatepipelinedef"> <input type="hidden" name="id" value="<?php echo $id; ?> "> <?php if ($level == 1 || $level == 2 && $dependency == '') { ?> <br> <style> td.dataheader { padding: 5px; border-bottom: 2px solid #999; background-color: #eee; text-align: center } </style> <div style="text-align:left; font-size:12pt; font-weight: bold; color:#214282;" class="level1">Data</div> <br> <table class="level1" cellspacing="0" cellpadding="0"> <tr style="color:#444; font-size:10pt;"> <td class="dataheader"><b>Enabled</b></td> <td class="dataheader"><b>Optional</b></td> <td class="dataheader"><b>Order</b></td> <td class="dataheader"><b>Protocol</b></td> <td class="dataheader"><b>Modality</b></td> <td class="dataheader"><b>Where's the data coming from?</b> <img src="images/help.gif" title="<b>Data Source</b><br>All analyses are run off of the study level. If you want data from this subject, but the data was collected in a different study, select the Subject data level. For example, the subject has been scanned on three different dates, but only one of them has"></td> <td class="dataheader"><b>Subject linkage</b> <img src="images/help.gif" title="<b>Data Level</b><br>Only use this option if your data is coming from the subject level"></td> </tr> <?php $neworder = 1; /* display all other rows, sorted by order */ $sqlstring = "select * from pipeline_data_def where pipeline_id = {$id} and pipeline_version = {$version} order by pdd_order + 0"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $pipelinedatadef_id = $row['pipelinedatadef_id']; $dd_order = $row['pdd_order']; $dd_seriescriteria = $row['pdd_seriescriteria']; $dd_protocol = $row['pdd_protocol']; $dd_modality = $row['pdd_modality']; $dd_dataformat = $row['pdd_dataformat']; $dd_imagetype = $row['pdd_imagetype']; $dd_gzip = $row['pdd_gzip']; $dd_location = $row['pdd_location']; $dd_useseries = $row['pdd_useseries']; $dd_preserveseries = $row['pdd_preserveseries']; $dd_usephasedir = $row['pdd_usephasedir']; $dd_behformat = $row['pdd_behformat']; $dd_behdir = $row['pdd_behdir']; $dd_numboldreps = $row['pdd_numboldreps']; $dd_enabled = $row['pdd_enabled']; $dd_assoctype = $row['pdd_assoctype']; $dd_optional = $row['pdd_optional']; $dd_datalevel = $row['pdd_level']; $dd_numimagescriteria = $row['pdd_numimagescriteria']; //PrintVariable($row); ?> <script> $(document).ready(function() { $('.row<?php echo $neworder; ?> ').mouseover(function() { $('.row<?php echo $neworder; ?> ').css('background-color','#eee'); }) .mouseout(function() { $('.row<?php echo $neworder; ?> ').css('background-color',''); }); }); </script> <tr class="row<?php echo $neworder; ?> "> <td width="10" valign="top" style="padding: 5px;" align="center"> <input class="small" type="checkbox" name="dd_enabled[<?php echo $neworder; ?> ]" value="1" <?php if ($dd_enabled) { echo "checked"; } ?> > </td> <td valign="top" style="padding: 5px" align="center"> <input type="checkbox" name="dd_optional[<?php echo $neworder; ?> ]" value="1" <?php if ($dd_optional) { echo "checked"; } ?> > </td> <td style="padding: 5px" valign="top"> <input class="small" type="text" name="dd_order[<?php echo $neworder; ?> ]" size="2" maxlength="3" value="<?php echo $neworder; ?> "> </td> <td valign="top" style="padding: 5px"> <input class="small" type="text" name="dd_protocol[<?php echo $neworder; ?> ]" size="50" value='<?php echo $dd_protocol; ?> ' title='Enter exact protocol name(s). Use quotes if entering a protocol with spaces or entering more than one protocol: "Task1" "Task 2" "Etc". Use multiple protocol names ONLY if you do not expect the protocols to occur in the same study'> </td> <td id="row<?php echo $neworder; ?> " valign="top" style="padding: 5px"> <select class="small" name="dd_modality[<?php echo $neworder; ?> ]"> <option value="">(Select modality)</option> <?php $sqlstringA = "select * from modalities order by mod_desc"; $resultA = MySQLiQuery($sqlstringA, __FILE__, __LINE__); while ($rowA = mysqli_fetch_array($resultA, MYSQLI_ASSOC)) { $mod_code = $rowA['mod_code']; $mod_desc = $rowA['mod_desc']; /* check if the modality table exists */ $sqlstring2 = "show tables from " . $GLOBALS['cfg']['mysqldatabase'] . " like '" . strtolower($mod_code) . "_series'"; //echo $sqlstring2; $result2 = MySQLiQuery($sqlstring2, __FILE__, __LINE__); if (mysqli_num_rows($result2) > 0) { /* if the table does exist, allow the user to search on it */ if ($mod_code == $dd_modality) { $selected = "selected"; } else { $selected = ""; } ?> <option value="<?php echo $mod_code; ?> " <?php echo $selected; ?> ><?php echo $mod_code; ?> </option> <?php } } ?> </select> </td> <td valign="top" style="font-size:8pt; padding: 5px" align="left"> <select name="dd_datalevel[<?php echo $neworder; ?> ]"> <option value="">(select data level) <option value="study" <?php if ($dd_datalevel == "study" || $dd_datalevel == "") { echo "selected"; } ?> >Study <option value="subject" <?php if ($dd_datalevel == "subject") { echo "selected"; } ?> >Subject </select> </td> <td valign="top" style="font-size:8pt; padding: 5px" align="left"> <select name="dd_studyassoc[<?php echo $neworder; ?> ]"> <option value="">(select study link) <option value="nearestintime" <?php if ($dd_assoctype == "nearestintime" || $dd_assoctype == "") { echo "selected"; } ?> >Nearest in time <option value="samestudytype" <?php if ($dd_assoctype == "samestudytype") { echo "selected"; } ?> >Same study type </select> </td> </tr> <tr class="row<?php echo $neworder; ?> "> <td valign="top" colspan="7" style="padding-left:25px"> <details class="level1" style="padding:0px;margin:0px"> <summary style="padding:0px; font-size:9pt">Options</summary> <table class="entrytable" style="background-color: #EEE; border-radius:4px; border: 1px solid #999"> <tr> <td class="label">Data format</td> <td> <select class="small" name="dd_dataformat[<?php echo $neworder; ?> ]"> <option value="native" <?php if ($dd_dataformat == "native") { echo "selected"; } ?> >Native</option> <option value="dicom" <?php if ($dd_dataformat == "dicom") { echo "selected"; } ?> >DICOM</option> <option value="nifti3d" <?php if ($dd_dataformat == "nifti3d") { echo "selected"; } ?> >Nifti 3D</option> <option value="nifti4d" <?php if ($dd_dataformat == "nifti4d") { echo "selected"; } ?> >Nifti 4D</option> <option value="analyze3d" <?php if ($dd_dataformat == "analyze3d") { echo "selected"; } ?> >Analyze 3D</option> <option value="analyze4d" <?php if ($dd_dataformat == "analyze4d") { echo "selected"; } ?> >Analyze 4D</option> </select> </td> </tr> <tr> <td class="label">Image type</td> <td><input class="small" type="text" name="dd_imagetype[<?php echo $neworder; ?> ]" size="30" value="<?php echo $dd_imagetype; ?> "></td> </tr> <tr> <td class="label">g-zip</td> <td><input class="small" type="checkbox" name="dd_gzip[<?php echo $neworder; ?> ]" value="1" <?php if ($dd_gzip) { echo "checked"; } ?> ></td> </tr> <tr> <td class="label">Directory <img src="images/help.gif" title="<b>Tip:</b> choose a directory called 'data/<i>taskname</i>'. If converting data or putting into a new directory structure, this data directory can be used as a staging area and can then be deleted later in your script"><br><span class="tiny">Relative to analysis root</span></td> <td><input class="small" type="text" name="dd_location[<?php echo $neworder; ?> ]" size="30" value="<?php echo $dd_location; ?> "></td> </tr> <tr> <td class="label">Criteria <img src="images/help.gif" title="<b>All</b> - All matching series will be downloaded<br><b>First</b> - Only the lowest numbered series will be downloaded<br><b>Last</b> - Only the highest numbered series will be downloaded<br><b>Largest</b> - Only one series with the most number of volumes or slices will be downloaded<br><b>Smallest</b> - Only one series with the least number of volumes or slices will be downloaded"></td> <td> <select class="small" name="dd_seriescriteria[<?php echo $neworder; ?> ]"> <option value="all" <?php if ($dd_seriescriteria == "all") { echo "selected"; } ?> >All</option> <option value="first" <?php if ($dd_seriescriteria == "first") { echo "selected"; } ?> >First</option> <option value="last" <?php if ($dd_seriescriteria == "last") { echo "selected"; } ?> >Last</option> <option value="largestsize" <?php if ($dd_seriescriteria == "largestsize") { echo "selected"; } ?> >Largest</option> <option value="smallestsize" <?php if ($dd_seriescriteria == "smallestsize") { echo "selected"; } ?> >Smallest</option> <option value="usesizecriteria" <?php if ($dd_seriescriteria == "usesizecriteria") { echo "selected"; } ?> >Use size criteria below</option> </select> </td> </tr> <tr> <td class="label">Number of BOLD reps <img src="images/help.gif" title="<b>Must be an integer or a criteria:</b><ul><li><i>N</i> (exactly N)<li>> <i>N</i> (greater than)<li>>= <i>N</i> (greater than or equal to)<li>< <i>N</i> (less than)<li><= <i>N</i> (less than or equal to)<li>~ <i>N</i> (not)</ul>"></td> <td><input type="text" name="dd_numboldreps[<?php echo $neworder; ?> ]" value="<?php echo $dd_numboldreps; ?> "></td> </tr> <tr> <td class="label">Use series directories <img src="images/help.gif" title="<b>Tip:</b> If you plan to download multiple series with the same name, you will want to use series directories. This option will place each series into its own directory (data/task/1, data/task/2, etc)"></td> <td><input class="small" type="checkbox" name="dd_useseriesdirs[<?php echo $neworder; ?> ]" value="1" <?php if ($dd_useseries) { echo "checked"; } ?> ></td> </tr> <tr> <td class="label">Preserve series numbers <img src="images/help.gif" title="If data is placed in a series directory, check this box to preserve the original series number. Otherwise the series number directories will be sequential starting at 1, regardless of the orignal series number"></td> <td><input class="small" type="checkbox" name="dd_preserveseries[<?php echo $neworder; ?> ]" value="1" <?php if ($dd_preserveseries) { echo "checked"; } ?> ></td> </tr> <tr> <td class="label">Phase encoding direction <img src="images/help.gif" title="<b>Phase Encoding Direction</b> If selected, it will write the data to a subdirectory corresponding to the acquired phase encoding direction: AP, PA, RL, LR, COL, ROW, unknownPE"></td> <td><input class="small" type="checkbox" name="dd_usephasedir[<?php echo $neworder; ?> ]" value="1" <?php if ($dd_usephasedir) { echo "checked"; } ?> ></td> </tr> <tr> <td class="label">Behavioral data directory format</td> <td> <select class="small" name="dd_behformat[<?php echo $neworder; ?> ]"> <option value="behnone" <?php if ($dd_behformat == "behnone") { echo "selected"; } ?> >Don't download behavioral data</option> <option value="behroot" <?php if ($dd_behformat == "behroot") { echo "selected"; } ?> >Place in root (file.log)</option> <option value="behrootdir" <?php if ($dd_behformat == "behrootdir") { echo "selected"; } ?> >Place in directory in root (beh/file.log)</option> <option value="behseries" <?php if ($dd_behformat == "behseries") { echo "selected"; } ?> >Place in series (2/file.log)</option> <option value="behseriesdir" <?php if ($dd_behformat == "behseriesdir") { echo "selected"; } ?> >Place in directory in series (2/beh/file.log)</option> </select> </td> </tr> <tr> <td class="label">Behavioral data directory name</td> <td><input class="small" type="text" name="dd_behdir[<?php echo $neworder; ?> ]" value="<?php echo $dd_behdir; ?> "></td> </tr> </table> <br> </details> </td> </tr> <?php $neworder++; } for ($ii = 0; $ii < 5; $ii++) { ?> <script> $(document).ready(function() { $('.row<?php echo $neworder; ?> ').mouseover(function() { $('.row<?php echo $neworder; ?> ').css('background-color','#eee'); }) .mouseout(function() { $('.row<?php echo $neworder; ?> ').css('background-color',''); }); }); </script> <tr class="row<?php echo $neworder; ?> "> <td width="10" valign="top" style="padding: 5px;" align="center"> <input class="small" type="checkbox" name="dd_enabled[<?php echo $neworder; ?> ]" value="1"> </td> <td valign="top" style="padding: 5px" align="center"> <input type="checkbox" name="dd_optional[<?php echo $neworder; ?> ]" value="1"> </td> <td style="padding: 5px" valign="top"> <input class="small" type="text" name="dd_order[<?php echo $neworder; ?> ]" size="2" maxlength="3" value="<?php echo $neworder; ?> "> </td> <td valign="top" style="padding: 5px"> <input class="small" type="text" name="dd_protocol[<?php echo $neworder; ?> ]" size="50" title='Enter exact protocol name(s). Use quotes if entering a protocol with spaces or entering more than one protocol: "Task1" "Task 2" "Etc". Use multiple protocol names ONLY if you do not expect the protocols to occur in the same study'> </td> <td valign="top" style="padding: 5px"> <select class="small" name="dd_modality[<?php echo $neworder; ?> ]"> <option value="">(Select modality)</option> <?php $sqlstringA = "select * from modalities order by mod_desc"; $resultA = MySQLiQuery($sqlstringA, __FILE__, __LINE__); while ($rowA = mysqli_fetch_array($resultA, MYSQLI_ASSOC)) { $mod_code = $rowA['mod_code']; $mod_desc = $rowA['mod_desc']; /* check if the modality table exists */ $sqlstring2 = "show tables from " . $GLOBALS['cfg']['mysqldatabase'] . " like '" . strtolower($mod_code) . "_series'"; //echo $sqlstring2; $result2 = MySQLiQuery($sqlstring2, __FILE__, __LINE__); if (mysqli_num_rows($result2) > 0) { ?> <option value="<?php echo $mod_code; ?> "><?php echo $mod_code; ?> </option> <?php } } ?> </select> </td> <td valign="top" style="font-size:8pt; padding: 5px" align="left"> <select name="dd_datalevel[<?php echo $neworder; ?> ]"> <option value="">(select data level) <option value="study" selected>Study <option value="subject">Subject </select> </td> <td valign="top" style="font-size:8pt; padding: 5px" align="left"> <select name="dd_studyassoc[<?php echo $neworder; ?> ]"> <option value="">(select study link) <option value="nearestintime" selected>Nearest in time <option value="samestudytype">Same study type </select> </td> </tr> <tr class="row<?php echo $neworder; ?> "> <td valign="top" colspan="7" style="padding-left:25px"> <details class="level1" style="padding:0px;margin:0px"> <summary style="padding:0px; font-size:9pt">Options</summary> <table class="entrytable" style="background-color: #EEE; border-radius:4px; border: 1px solid #999"> <tr> <td class="label">Data format</td> <td> <select class="small" name="dd_dataformat[<?php echo $neworder; ?> ]"> <option value="native" selected>Native</option> <option value="dicom">DICOM</option> <option value="nifti3d">Nifti 3D</option> <option value="nifti4d">Nifti 4D</option> <option value="analyze3d">Analyze 3D</option> <option value="analyze4d">Analyze 4D</option> </select> </td> </tr> <tr> <td class="label">Image type</td> <td><input class="small" type="text" name="dd_imagetype[<?php echo $neworder; ?> ]" size="30"></td> </tr> <tr> <td class="label">g-zip</td> <td><input class="small" type="checkbox" name="dd_gzip[<?php echo $neworder; ?> ]" value="1"></td> </tr> <tr> <td class="label">Directory <img src="images/help.gif" title="<b>Tip:</b> choose a directory called 'data/<i>taskname</i>'. If converting data or putting into a new directory structure, this data directory can be used as a staging area and can then be deleted later in your script"><br><span class="tiny">Relative to analysis root</span></td> <td><input class="small" type="text" name="dd_location[<?php echo $neworder; ?> ]" size="30"></td> </tr> <tr> <td class="label">Criteria <img src="images/help.gif" title="<b>All</b> - All matching series will be downloaded<br><b>First</b> - Only the lowest numbered series will be downloaded<br><b>Last</b> - Only the highest numbered series will be downloaded<br><b>Largest</b> - Only one series with the most number of volumes or slices will be downloaded<br><b>Smallest</b> - Only one series with the least number of volumes or slices will be downloaded"></td> <td> <select class="small" name="dd_seriescriteria[<?php echo $neworder; ?> ]"> <option value="all" selected>All</option> <option value="first">First</option> <option value="last">Last</option> <option value="largestsize">Largest</option> <option value="smallestsize">Smallest</option> <option value="usesizecriteria">Use size criteria below</option> </select> </td> </tr> <tr> <td class="label">Number of BOLD reps <img src="images/help.gif" title="<b>Must be an integer or a criteria:</b><ul><li><i>N</i> (exactly N)<li>> <i>N</i> (greater than)<li>>= <i>N</i> (greater than or equal to)<li>< <i>N</i> (less than)<li><= <i>N</i> (less than or equal to)<li>~ <i>N</i> (not)</ul>"></td> <td><input type="text" name="dd_numboldreps[<?php echo $neworder; ?> ]"></td> </tr> <tr> <td class="label">Use series directories <img src="images/help.gif" title="<b>Tip:</b> If you plan to download multiple series with the same name, you will want to use series directories. This option will place each series into its own directory (data/task/1, data/task/2, etc)"</td> <td><input class="small" type="checkbox" name="dd_useseriesdirs[<?php echo $neworder; ?> ]" value="1"></td> </tr> <tr> <td class="label">Preserve series numbers <img src="images/help.gif" title="If data is placed in a series directory, check this box to preserve the original series number. Otherwise the series number directories will be sequential starting at 1, regardless of the orignal series number"></td> <td><input class="small" type="checkbox" name="dd_preserveseries[<?php echo $neworder; ?> ]" value="1"></td> </tr> <tr> <td class="label">Phase encoding direction <img src="images/help.gif" title="<b>Phase Encoding Direction</b> If selected, it will write the data to a subdirectory corresponding to the acquired phase encoding direction: AP, PA, RL, LR, COL, ROW, noPE"></td> <td><input class="small" type="checkbox" name="dd_usephasedir[<?php echo $neworder; ?> ]" value="1"></td> </tr> <tr> <td class="label">Behavioral data directory format</td> <td> <select class="small" name="dd_behformat[<?php echo $neworder; ?> ]"> <option value="behnone" selected>Don't download behavioral data</option> <option value="behroot">Place in root (file.log)</option> <option value="behrootdir">Place in directory in root (beh/file.log)</option> <option value="behseries">Place in series (2/file.log)</option> <option value="behseriesdir">Place in directory in series (2/beh/file.log)</option> </select> </td> </tr> <tr> <td class="label">Behavioral data directory name</td> <td><input class="small" type="text" name="dd_behdir[<?php echo $neworder; ?> ]"></td> </tr> </table> <br> </details> </td> </tr> <?php $neworder++; ?> <?php } ?> </table> <?php } /* end of the check to display the data specs */ ?> <br><br> <div style="text-align:left; font-size:12pt; font-weight: bold; color:#214282;">Main Script Commands<br><span class="tiny" style="font-weight:normal">Ctrl+S to save</span></div> <br><br> <style type="text/css" media="screen"> #commandlist { position: relative; width: 1000px; height: 700px; top: 0; right: 0; bottom: 0; left: 0; } #supplementcommandlist { position: relative; width: 1000px; height: 300px; top: 0; right: 0; bottom: 0; left: 0; } </style> </b> <table> <tr> <td valign="top"> <textarea name="commandlist" style="font-weight:normal"><?php $sqlstring = "select * from pipeline_steps where pipeline_id = {$id} and pipeline_version = {$version} and ps_supplement <> 1 order by ps_order + 0"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $pipelinestep_id = $row['pipelinestep_id']; $ps_desc = $row['ps_description']; $ps_order = $row['ps_order']; $ps_command = $row['ps_command']; $ps_workingdir = $row['ps_workingdir']; $ps_enabled = $row['ps_enabled']; $ps_logged = $row['ps_logged']; if ($ps_enabled == 1) { $enabled = ""; } else { $enabled = "#"; } if ($ps_logged == 1) { $logged = ""; } else { $logged = "{NOLOG}"; } echo "{$enabled}{$ps_command} # {$logged} {$ps_desc}\n"; } ?> </textarea> <div id="commandlist" style="border: 1px solid #666; font-weight: normal"></div> </td> <td valign="top" align="center"> <b>Available pipeline variables</b><br> <span class="tiny">Click variable to insert at current editor location</span> <br><br> <table> <tr><td class="pipelinevariable" onclick="insertText('{analysisrootdir}');" title="Full path to the root directory of the analysis">{analysisrootdir}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{subjectuid}');" title="Example: S1234ABC">{subjectuid}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{studynum}');" title="Example: 1">{studynum}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{uidstudynum}');" title="Example: S1234ABC1">{uidstudynum}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{pipelinename}');" title="<?php echo $title; ?> ">{pipelinename}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{studydatetime}');" title="YYYYMMDDHHMMSS">{studydatetime}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{first_ext_file}');" title="Expands to first file found with extenstion. Replace ext with the extension">{first_ext_file}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{first_n_ext_files}');" title="Finds first file with extension">{first_n_ext_files}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{last_ext_file}');" title="Finds last file (alphabetically) with extension">{last_ext_file}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{all_ext_files}');" title="Finds all files matching the extension">{all_ext_files}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{command}');" title="Full command, excluding comment">{command}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{workingdir}');" title="Not dynamic, not changed at run-time">{workingdir}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{description}');" title="The description (comment)">{description}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{analysisid}');" title="Analysis ID">{analysisid}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{NOLOG}');" title="Insert in the comment and the line will not be logged. Useful if the command is using the > or >> operators to write to a file">{NOLOG}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{NOCHECKIN}');" title="Insert in the comment and the step will not be reported. Useful for command line for-loops">{NOCHECKIN}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{subjectuids}');" title="Space separated list of UIDs. For group analyses">{subjectuids}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{studydatetimes}');" title="Space separated list of datetimes, ordered by datetime. For group analyses">{studydatetimes}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{analysisgroupid}');" title="Group analysis ID">{analysisgroupid}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{uidstudynums}');" title="Space separated list of uidstudynums for all groups">{uidstudynums}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{numsubjects}');" title="Number of subjects from all groups">{numsubjects}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{groups}');" title="Space separated list of groups">{groups}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{numsubjects_groupname}');" title="Number of subjects (sessions) in the group specified">{numsubjects_groupname}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{uidstudynums_groupname}');" title="Space separated list of uidstudynums for the group specified">{uidstudynums_groupname}</td></tr> </table> <br><br> <span class="editoroptions" onClick="toggleWrap()">Toggle text wrap</span> </td> </tr> <tr> <td colspan="6" align="left"> <?php $sqlstring2 = "select * from pipeline_steps where pipeline_id = {$id} and pipeline_version = {$version} and ps_supplement = 1 order by ps_order + 0"; $result2 = MySQLiQuery($sqlstring2, __FILE__, __LINE__); if (mysqli_num_rows($result2) > 0) { $open = "open"; } else { $open = ""; } ?> <details <?php echo $open; ?> > <summary style="text-align:left; font-size:12pt; font-weight: bold; color:#214282;">Supplementary script commands</summary> <br> <div id="supplementcommandlist" style="border: 1px solid #666; font-weight: normal"></div> <textarea name="supplementcommandlist"><?php while ($row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC)) { $pipelinestep_id = $row2['pipelinestep_id']; $ps_desc = $row2['ps_description']; $ps_order = $row2['ps_order']; $ps_command = $row2['ps_command']; $ps_workingdir = $row2['ps_workingdir']; $ps_enabled = $row2['ps_enabled']; $ps_logged = $row2['ps_logged']; if ($ps_enabled == 1) { $enabled = ""; } else { $enabled = "#"; } if ($ps_logged == 1) { $logged = ""; } else { $logged = "{NOLOG}"; } echo "{$enabled}{$ps_command} # {$logged} {$ps_desc}\n"; } ?> </textarea> <span class="editoroptions" onClick="toggleWrap2()">Toggle text wrap</span> </details> </td> </tr> <tr> <td colspan="6" align="center"> <br><br> <input type="submit" <?php echo $disabled; ?> value="Update Pipeline Definition Only"> </td> </tr> </form> </table> </fieldset> <script src="scripts/aceeditor/ace.js" type="text/javascript" charset="utf-8"></script> <script> var editor = ace.edit("commandlist"); var textarea = $('textarea[name="commandlist"]').hide(); editor.setFontSize(12); editor.getSession().setMode("ace/mode/sh"); editor.getSession().setUseWrapMode(false); editor.getSession().setValue(textarea.val()); <?php if ($readonly) { ?> editor.setReadOnly(); <?php } ?> editor.getSession().on('change', function(){ textarea.val(editor.getSession().getValue()); }); editor.setTheme("ace/theme/xcode"); function insertText(text) { editor.insert(text); } function toggleWrap() { if (editor.getSession().getUseWrapMode()) { editor.getSession().setUseWrapMode(false); } else { editor.getSession().setUseWrapMode(true); } } $(window).bind('keydown', function(event) { if (event.ctrlKey || event.metaKey) { switch (String.fromCharCode(event.which).toLowerCase()) { case 's': event.preventDefault(); //alert('ctrl-s'); document.getElementById('stepsform').submit(); break; } } }); var editor2 = ace.edit("supplementcommandlist"); var textarea2 = $('textarea[name="supplementcommandlist"]').hide(); editor2.setFontSize(12); editor2.getSession().setMode("ace/mode/sh"); editor2.getSession().setUseWrapMode(false); editor2.getSession().setValue(textarea2.val()); <?php if ($readonly) { ?> editor2.setReadOnly(); <?php } ?> editor2.getSession().on('change', function(){ textarea2.val(editor2.getSession().getValue()); }); editor2.setTheme("ace/theme/xcode"); function insertText2(text) { editor2.insert(text); } function toggleWrap2() { if (editor2.getSession().getUseWrapMode()) { editor2.getSession().setUseWrapMode(false); } else { editor2.getSession().setUseWrapMode(true); } }; </script> <br><br> <br><br> <?php } }
function GetBackEquip($var, $gm) { global $tbl_sys_msg, $page_main, $tbl_role_equip_info; $js_str = <<<_js_str \t<script type="text/javascript" src="/js/page.js"></script> \t<script type="text/javascript"> \tfunction getback(){ \t\tdocument.form1.target = "_block"; \t\tdocument.form1.action_name.value="166"; \t\tdocument.form1.submit(); \t} \t</script> _js_str; $server_id = $var["serverid"]; $item_id = $var["item_id"]; $event_id = $var["event_id"]; $str = " order by le_uId desc limit 1"; if ($event_id != null || $event_id != "") { $str = " and le_uId <= {$event_id}" . $str; } $allowe = HasAuth(166, $gm); $qs = "select lcs_uId, le.le_dtDateTime, let.let_uEventType, le.le_uId from tbl_log_item_del lid, tbl_log_player_giver lpg, tbl_log_event le, tbl_log_event_type let where le.le_uId = lid.le_uId and let.le_uId = lid.le_uId and lid.le_uId = lpg.le_uId and lis_uId = {$item_id}"; $rs = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($rs)) { global $tbl_event_type; $desc = ShowVirWealthLog_Desc($row[2], $row[3], $server_id); echo "<table class='list_table'>\n"; printf("<tr><td style='width:120px;'>%s</td><td style='width:250px;'>%s</td><td>%s</td></tr>\n", $row[1], $tbl_event_type[$row[2]], $desc); echo "</table>\n"; $role_id = $row[0]; $role_name = GetRoleName($role_id, $server_id); if ($role_name == "-") { $allowe = false; } } else { //$allowe = false; } printf($js_str, $tbl_sys_msg["reason"]) . "\n"; form($var, $gm); $style = <<<_style <style> .equip { \twidth: 230px; \tborder: 1px solid #ccc; \tpadding:10px; \tfloat:left; } .equip div{ \tfloat:left; } .equip .head, .equip .binding, .equip .durability, .equip .armor, .equip .armor .armor_item, .equip .advance, .equip .advance_item, .equip .intensify, .equip .intensify .intensify_item, .equip .equip_info .armor_item, .equip .JingLing { \twidth: 230px; } .equip .head .name { \tfloat:left; } .equip .head .level, .equip .equip_info .weapon_speed, .equip .intensify .intensify_total, .equip .advance .advance_times, .equip .addation, .equip .JingLingSkill { \tfloat:right; \ttext-align:right; \tclear: right; } .equip .binding, .equip .durability { \ttext-align:right; } .equip .armor .armor_item .armor_name, .equip .advance .advance_item .advance_name, .equip .intensify .intensify_name, .equip .equip_info .armor_item .armor_name { \twidth: 80px; } .equip .armor .armor_item .armor_value,.equip .advance .advance_item .advance_value,.equip .intensify .intensify_value,.equip .equip_info .armor_item .armor_value { \twidth: 30px; } .equip .armor, .equip .advance, .equip .intensify, .equip .JingLing { \tmargin-top: 5px; } </style> _style; echo $style; echo "<div class='equip'>\n"; $qs = "select * from tbl_log_item_static where lis_uId = {$item_id}"; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $item_type = $row[1]; $item_name = Local2UTF8($row[2]); } else { return false; } $attr = array(); $attr["Static"] = array(); $attr["ShieldAttr"] = array(); $attr["Advance"] = array(); $attr["Armor1"] = array(); $attr["Armor2"] = array(); $attr["Armor3"] = array(); $attr["Armor4"] = array(); $attr["Intensify"] = array(); $attr["InTensifyAddAttr"] = array(); $attr["Durability"] = array(); $attr["Binding"] = array(); $attr["SuperAddation"] = array(); switch ($item_type) { case 5: //weapon $qs = "select * from tbl_log_item_weapon where lis_uId = {$item_id}" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["Static"] = $row; $level = $row[2]; $intensify = $row[7]; $inten = $row[8]; $DPS = $row[4]; $speed = $row[5]; $rate = $row[6]; $min_attack = intval($DPS * $speed * (1 - $rate * 0.01)); $max_attack = intval($DPS * $speed * (1 + $rate * 0.01)); $equip_info = "<div class='weapon_attack'>" . sprintf($tbl_role_equip_info[1][0][0], $min_attack, $max_attack) . "<br/>" . sprintf($tbl_role_equip_info[1][0][2], $DPS) . "</div>\n<div class='weapon_speed'>" . sprintf($tbl_role_equip_info[1][0][1], $speed) . "</div>\n"; } break; case 6: //armor //armor case 9: //Jewelry $qs = "select * from tbl_log_item_armor where lis_uId = {$item_id}" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["Static"] = $row; $level = $row[2]; $intensify = $row[8]; $inten = $row[9]; $equip_info = "<div class='armor_item'><div class='armor_name'>" . $tbl_role_equip_info[1][1][0] . "</div><div class='armor_value'>+" . $row[4] . "</div></div>\n"; $equip_info .= "<div class='armor_item'><div class='armor_name'>" . $tbl_role_equip_info[1][1][1] . "</div><div class='armor_value'>+" . $row[5] . "</div></div>\n"; $equip_info .= "<div class='armor_item'><div class='armor_name'>" . $tbl_role_equip_info[1][1][2] . "</div><div class='armor_value'>+" . $row[6] . "</div></div>\n"; } break; case 7: //shield $qs = "select * from tbl_log_item_shield where lis_uId = {$item_id}" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["Static"] = $row; $level = $row[2]; $intensify = $row[4]; $inten = $row[5]; } $qs = "select * from tbl_log_item_shield_Attr where lis_uId = {$item_id}" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["ShieldAttr"] = $row; } break; case 8: //ring $qs = "select * from tbl_log_item_ring where lis_uId = {$item_id}" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["Static"] = $row; $level = $row[2]; $intensify = $row[6]; $inten = $row[7]; $DPS = $row[4]; $equip_info = "<div class='ring_attack'>" . sprintf($tbl_role_equip_info[1][2][0], $DPS) . "</div>\n"; } break; } $addation = 0; $qs = "select * from tbl_log_item_equip_superaddation where lis_uId = {$item_id}"; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["SuperAddation"] = $row; $addation = $row[2]; } $addation_rate = 0; $addation_time = ""; $addation_desc = ""; switch ($addation) { case 1: $addation_rate = 10; break; case 2: $addation_rate = 21; break; case 3: $addation_rate = 33; break; case 4: $addation_rate = 46; break; case 5: $addation_rate = 60; break; case 6: $addation_rate = 75; break; case 7: $addation_rate = 91; break; case 8: $addation_rate = 108; break; } if ($addation > 0) { $addation_time = " +" . $addation; $addatiom_desc = "<div class='addation'>(" . $tbl_role_equip_info[6] . $addation_rate . "%)</div>\n"; } $inten_times = 0; $qs = "select * from tbl_log_item_equip_intensify where lis_uId = {$item_id}" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["Intensify"] = $row; $inten_times = $row[11]; $inten_totle = $row[15]; $suit_info = Lan_Equip_GetSuitInfo(Local2UTF8($row[13]), $row[17]); $suit_name = $suit_info["name"]; if ($row[7]) { $inten_info .= "<div class='intensify_item'>\n<div class='intensify_name'>" . Lan_Equip_GetPropertyName(Local2UTF8($row[7])) . "</div>\n<div class='intensify_value'>+" . $row[8] . "</div>\n" . ($addation == 0 ? "" : "<div class='addation'>(+" . ceil($addation_rate * $row[8] / 100) . ")</div>\n") . "</div>\n"; } if ($row[9]) { $inten_info .= "<div class='intensify_item'>\n<div class='intensify_name'>" . Lan_Equip_GetPropertyName(Local2UTF8($row[9])) . "</div>\n<div class='intensify_value'>+" . $row[10] . "</div>\n" . ($addation == 0 ? "" : "<div class='addation'>(+" . ceil($addation_rate * $row[10] / 100) . ")</div>\n") . "</div>\n"; } } if ($suit_name != "") { $suit_name .= "<br/>"; } echo "<div class='head'>\n<div class='name'>" . $suit_name . Lan_Item_GetDisplayName($item_name, $item_tupe, false) . $addation_time . "</div>\n<div class='level'>" . $level . $tbl_role_equip_info[7] . "</div>\n" . $addatiom_desc . "</div>\n"; $qs = "select * from tbl_log_item_binding where lis_uId = {$item_id}" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { if ($row[2] > 0) { global $tbl_item_is_binding; echo "<div class='binding'>" . $tbl_item_is_binding[$row[2]] . "</div>\n"; } $row[2] = 2; $attr["Binding"] = $row; } $qs = "select * from tbl_log_item_equip_durability where lis_uId = {$item_id}" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["Durability"] = $row; echo "<div class='durability'>" . sprintf($tbl_role_equip_info[0], $row[3], $row[2]) . "</div>\n"; } echo "<div class='equip_info'>\n{$equip_info}</div>\n"; echo "<div class='armor'>\n"; $qs = "select * from tbl_log_item_equip_armor where lis_uId = {$item_id} and liea_uIndex = 1" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["Armor" . $row[4]] = $row; echo "<div class='armor_item'>\n"; $armor = Lan_Equip_GetArmorPiece(Local2UTF8($row[2])); echo "<div class='armor_name'>" . $armor[1] . "</div>\n"; echo "<div class='armor_value'>+" . $armor[2] * $row[3] . "</div>\n"; if ($armor[0] > 1) { echo "<div class='aromr_time'>(" . $row[3] . "/" . $armor[0] . ")</div>\n"; } echo "</div>\n"; } $qs = "select * from tbl_log_item_equip_armor where lis_uId = {$item_id} and liea_uIndex = 2" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["Armor" . $row[4]] = $row; echo "<div class='armor_item'>\n"; $armor = Lan_Equip_GetArmorPiece(Local2UTF8($row[2])); echo "<div class='armor_name'>" . $armor[1] . "</div>\n"; echo "<div class='armor_value'>+" . $armor[2] * $row[3] . "</div>\n"; if ($armor[0] > 1) { echo "<div class='aromr_time'>(" . $row[3] . "/" . $armor[0] . ")</div>\n"; } echo "</div>\n"; } $qs = "select * from tbl_log_item_equip_armor where lis_uId = {$item_id} and liea_uIndex = 3" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["Armor" . $row[4]] = $row; echo "<div class='armor_item'>\n"; $armor = Lan_Equip_GetArmorPiece(Local2UTF8($row[2])); echo "<div class='armor_name'>" . $armor[1] . "</div>\n"; echo "<div class='armor_value'>+" . $armor[2] * $row[3] . "</div>\n"; if ($armor[0] > 1) { echo "<div class='aromr_time'>(" . $row[3] . "/" . $armor[0] . ")</div>\n"; } echo "</div>\n"; } $qs = "select * from tbl_log_item_equip_armor where lis_uId = {$item_id} and liea_uIndex = 4" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["Armor" . $row[4]] = $row; echo "<div class='armor_item'>\n"; $armor = Lan_Equip_GetArmorPiece(Local2UTF8($row[2])); echo "<div class='armor_name'>" . $armor[1] . "</div>\n"; echo "<div class='armor_value'>+" . $armor[2] * $row[3] . "</div>\n"; if ($armor[0] > 1) { echo "<div class='aromr_time'>(" . $row[3] . "/" . $armor[0] . ")</div>\n"; } echo "</div>\n"; } echo "</div>\n"; $qs = "select * from tbl_log_item_equip_advance where lis_uId = {$item_id}" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["Advance"] = $row; echo "<div class='advance'>\n"; $advance_name = Local2UTF8($row[16]); $advance_cur_tiems = $row[2]; $advance_tot_tiems = $row[3]; if ($advance_tot_tiems > 0) { echo "<div class='advance_item'>\n<div class='advance_name'>" . sprintf($tbl_role_equip_info[2], $advance_name) . "</div>\n<div class='advance_value'>" . $advance_cur_tiems . "/" . $advance_tot_tiems . "</div>\n<div class='advance_times'>" . sprintf($tbl_role_equip_info[5], $row[11]) . "</div>\n</div>\n"; } if ($row[12] != 0) { echo "<div class='advance_item'>\n<div class='advance_name'>" . Lan_Equip_GetPropertyName(Local2UTF8($row[17])) . "</div>\n<div class='advance_value'>+" . $row[12] . "</div>\n" . ($addation == 0 ? "" : "<div class='addation'>(+" . ceil($addation_rate * $row[12] / 100) . ")</div>\n") . "</div>\n"; } if ($row[13] != 0) { echo "<div class='advance_item'>\n<div class='advance_name'>" . Lan_Equip_GetPropertyName(Local2UTF8($row[18])) . "</div>\n<div class='advance_value'>+" . $row[13] . "</div>\n" . ($addation == 0 ? "" : "<div class='addation'>(+" . ceil($addation_rate * $row[13] / 100) . ")</div>\n") . "</div>\n"; } if ($row[14] != 0) { echo "<div class='advance_item'>\n<div class='advance_name'>" . Lan_Equip_GetPropertyName(Local2UTF8($row[19])) . "</div>\n<div class='advance_value'>+" . $row[14] . "</div>\n" . ($addation == 0 ? "" : "<div class='addation'>(+" . ceil($addation_rate * $row[14] / 100) . ")</div>\n") . "</div>\n"; } if ($row[15] != 0) { echo "<div class='advance_item'>\n<div class='advance_name'>" . Lan_Equip_GetPropertyName(Local2UTF8($row[20])) . "</div>\n<div class='advance_value'>+" . $row[15] . "</div>\n" . ($addation == 0 ? "" : "<div class='addation'>(+" . ceil($addation_rate * $row[15] / 100) . ")</div>\n") . "</div>\n"; } $JingLingType = Local2UTF8($row[9]); $JingLingSkill = $row[8]; echo "</div>\n"; } global $tbl_item_inten_soul; $qs = "select * from tbl_log_item_equip_intensifyAddAttr where lis_uId = {$item_id}" . $str; $result = MySQLQuery($qs, "Log", $server_id); if ($row = mysql_fetch_row($result)) { $attr["InTensifyAddAttr"] = $row; if ($row[2]) { $inten_info .= "<div class='intensify_item'>\n<div class='intensify_name'>" . Lan_Equip_GetPropertyName(Local2UTF8($row[2])) . "</div>\n<div class='intensify_value'>+" . $row[3] . "</div>\n" . ($addation == 0 ? "" : "<div class='addation'>(+" . ceil($addation_rate * $row[3] / 100) . ")</div>\n") . "</div>\n"; } if ($row[4]) { $inten_info .= "<div class='intensify_item'>\n<div class='intensify_name'>" . Lan_Equip_GetPropertyName(Local2UTF8($row[4])) . "</div>\n<div class='intensify_value'>+" . $row[5] . "</div>\n" . ($addation == 0 ? "" : "<div class='addation'>(+" . ceil($addation_rate * $row[5] / 100) . ")</div>\n") . "</div>\n"; } if ($row[6]) { $inten_info .= "<div class='intensify_item'>\n<div class='intensify_name'>" . Lan_Equip_GetPropertyName(Local2UTF8($row[6])) . "</div>\n<div class='intensify_value'>+" . $row[7] . "</div>\n" . ($addation == 0 ? "" : "<div class='addation'>(+" . ceil($addation_rate * $row[7] / 100) . ")</div>\n") . "</div>\n"; } if ($row[8]) { $inten_info .= "<div class='intensify_item'>\n<div class='intensify_name'>" . Lan_Equip_GetPropertyName(Local2UTF8($row[8])) . "</div>\n<div class='intensify_value'>+" . $row[9] . "</div>\n" . ($addation == 0 ? "" : "<div class='addation'>(+" . ceil($addation_rate * $row[9] / 100) . ")</div>\n") . "</div>\n"; } if ($row[10]) { $inten_info .= "<div class='intensify_item'>\n<div class='intensify_name'>" . Lan_Equip_GetPropertyName(Local2UTF8($row[10])) . "</div>\n<div class='intensify_value'>+" . $row[11] . "</div>\n" . ($addation == 0 ? "" : "<div class='addation'>(+" . ceil($addation_rate * $row[11] / 100) . ")</div>\n") . "</div>\n"; } if ($row[12]) { $inten_info .= "<div class='intensify_item'>\n<div class='intensify_name'>" . Lan_Equip_GetPropertyName(Local2UTF8($row[12])) . "</div>\n<div class='intensify_value'>+" . $row[13] . "</div>\n" . ($addation == 0 ? "" : "<div class='addation'>(+" . ceil($addation_rate * $row[13] / 100) . ")</div>\n") . "</div>\n"; } } echo "<div class='intensify'>\n"; echo "<div class='intensify_item'>\n"; if ($intensify > 0) { echo "<div class='intensify_name'>" . sprintf($tbl_role_equip_info[3], $tbl_item_inten_soul[Local2base64($inten)]) . "</div>\n<div class='intensify_value'>{$inten_times}/{$intensify}</div>\n"; } if ($inten_totle) { echo "<div class='intensify_total'>" . sprintf($tbl_role_equip_info[4], $inten_totle) . "</div>\n"; } echo "</div>\n"; echo $inten_info; echo "<div class='intensify_item'>\n"; if ($suit_info["name"] != null) { echo $suit_info["name"] . "\n"; } echo "<div style='margin-left: 10px'>\n"; if ($suit_info["part"] != null) { foreach ($suit_info["part"] as $part) { echo $suit_info["name"] . $part . "<br/>\n"; } } if ($suit_info["desc"] != null) { foreach ($suit_info["desc"] as $i => $desc) { printf($tbl_role_equip_info[8], $i); echo $desc . "<br/>\n"; } } echo "</div>\n"; if ($suit_info["talent"] != null) { echo "<div>" . $tbl_role_equip_info[9] . $suit_info["talent"] . "</div>\n"; } echo "</div>\n"; echo "</div>\n"; global $tbl_JingLing_type; echo "<div class='JingLing'><div>" . $tbl_JingLing_type[UTF82Base64($JingLingType)] . "</div>"; if ($JingLingSkill > 0) { echo "<div class='JingLingSkill'>" . Lan_Equip_GetSkillName($JingLingType, $JingLingSkill) . "</div>"; } echo "</div>\n"; echo "</div>\n"; echo "</div>\n"; if ($allowe) { $attrstr = $item_name . "," . $item_type . "," . $item_id . ";"; $attrstr .= attrtostr($attr["Static"]) . ";"; $attrstr .= attrtostr($attr["ShieldAttr"]) . ";"; $attrstr .= attrtostr($attr["Advance"]) . ";"; $attrstr .= attrtostr($attr["Armor1"]) . ";"; $attrstr .= attrtostr($attr["Armor2"]) . ";"; $attrstr .= attrtostr($attr["Armor3"]) . ";"; $attrstr .= attrtostr($attr["Armor4"]) . ";"; $attrstr .= attrtostr($attr["Intensify"]) . ";"; $attrstr .= attrtostr($attr["InTensifyAddAttr"]) . ";"; $attrstr .= attrtostr($attr["Durability"]) . ";"; $attrstr .= ",,2,;"; $attrstr .= attrtostr($attr["SuperAddation"]) . ";"; echo "<input type='hidden' name='attr' value='{$attrstr}'/>\n"; echo "<table style='float: left; margin-left: 20px;'>\n"; echo "<tr><th>" . $page_main["role_name"] . "</th><td><input type='text' name='role_name' value='{$role_name}'" . ($role_name == "" ? "" : " readonly=\"readonly\"") . " /></td></tr>\n"; echo "<tr><th>" . $tbl_sys_msg["reason"] . "</th><td><textarea name='reason' style='width:300px;'></textarea></td></tr>\n"; echo "<tr><th> </th><td><input type='button' onclick='getback()' value='" . $tbl_sys_msg["submit"] . "' /></td></tr>\n"; echo "</table>\n"; } echo "</form>\n"; return true; }
function DisplaySingleTransaction($transactionid) { $sqlstring = "select * from import_requests where import_transactionid = {$transactionid}"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $groupids[] = $row['importrequest_id']; } $grouplist = implode2(',', $groupids); $sqlstring = "select *, timediff(max(importstartdate), min(importstartdate)) 'importtime', date_format(max(importstartdate), '%b %e, %Y %T') 'maximportdatetime', date_format(studydatetime_orig, '%b %e, %Y %T') 'studydatetime', date_format(seriesdatetime_orig, '%b %e, %Y %T') 'seriesdatetime', count(*) 'numfiles' from importlogs where importgroupid in ({$grouplist}) group by stationname_orig, studydatetime_orig, seriesnumber_orig order by studydatetime_orig desc, seriesdatetime_orig"; //$sqlstring = "select * from importlogs where importgroupid in ($grouplist)"; ?> <style> .text { position:relative; width:20px; height:170px; /*border:1px solid rgba(0,0,0,0.5);*/ /*border-radius:7px; */ /*margin:20px auto; */ /*background-color:rgb(255,255,255); */ /*box-shadow:inset 0 0 10px rgba(0,0,0,0.6), 0 0 10px rgba(0,0,0,0.6);*/ } .text span { position:absolute; width:170px; line-height:20px; left:0; top:100%; transform:rotate(-90deg); -webkit-transform:rotate(-90deg); transform-origin:0 0; -webkit-transform-origin:0 0; text-align:left; vertical-align: middle; } </style> <table class="smallgraydisplaytable"> <thead> <tr> <th valign="bottom">Initials</th> <th>Patient ID</th> <!--<th>Institution</th>--> <th>Equipment</th> <th>Modality</th> <th>Study date</th> <th>Series date</th> <th>Series Num</th> <th>Num files</th> <th> </th> <th>New UID</th> <th>Study Num</th> <th>Project</th> <th>Import time<br><span class="tiny">HH:MM:SS</span></th> <th>Import complete</th> <th><div class="text"><span style="font-size:10pt; font-weight:normal;">Created subject</span></div></th> <th><div class="text"><span style="font-size:10pt; font-weight:normal;">Created family</span></div></th> <th><div class="text"><span style="font-size:10pt; font-weight:normal;">Created enrollment</span></div></th> <th><div class="text"><span style="font-size:10pt; font-weight:normal;">Created study</span></div></th> <th><div class="text"><span style="font-size:10pt; font-weight:normal;">Created series</span></div></th> <th><div class="text"><span style="font-size:10pt; font-weight:normal;">Overwrote existing data</span></div></th> </tr> </thead> <tbody> <?php $result = MySQLQuery($sqlstring, __FILE__, __LINE__); //PrintSQLTable($result,"importlog.php?action=displaylog",$orderby,8); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $patientid = $row['patientid_orig']; $patientname = $row['patientname_orig']; $institution = $row['institution_orig']; $equipment = $row['stationname_orig']; $modality = $row['modality_orig']; //$studydatetime = date('M j g:ia',strtotime($row['studydatetime_orig'])); $studydatetime = $row['studydatetime']; //$seriesdatetime = date('M j g:ia',strtotime($row['seriesdatetime_orig'])); $seriesdatetime = $row['seriesdatetime']; $seriesnum = $row['seriesnumber_orig']; $numfiles = $row['numfiles']; $importtime = $row['importtime']; $minimportdatetime = $row['minimportdatetime']; $maximportdatetime = $row['maximportdatetime']; $subjectid = $row['subjectid']; $newuid = $row['subject_uid']; $newstudynum = $row['study_num']; $project = $row['project_number']; $subjectcreated = $row['subject_created']; $familycreated = $row['family_created']; $enrollmentcreated = $row['enrollment_created']; $studycreated = $row['study_created']; $seriescreated = $row['series_created']; $overwroteexisting = $row['overwrote_existing']; /* fix patient name, to only show initials */ $parts = preg_split("/(\\s\\s+|\\^)/", $patientname); //print_r($parts); $displayname = ''; foreach ($parts as $part) { $displayname = substr($part, 0, 1) . $displayname; } if ($subjectcreated) { $subjectcreated = "✓"; } else { $subjectcreated = ""; } if ($familycreated) { $familycreated = "✓"; } else { $familycreated = ""; } if ($enrollmentcreated) { $enrollmentcreated = "✓"; } else { $enrollmentcreated = ""; } if ($studycreated) { $studycreated = "✓"; } else { $studycreated = ""; } if ($seriescreated) { $seriescreated = "✓"; } else { $seriescreated = ""; } if ($overwroteexisting) { $overwroteexisting = "✓"; } else { $overwroteexisting = ""; } ?> <tr> <td><?php echo $displayname; ?> </td> <td title="PatientID (from file)"><?php echo $patientid; ?> </td> <!--<td style="font-size:8pt"><?php echo $institution; ?> </td>--> <td style="font-size:8pt"><?php echo $equipment; ?> </td> <td><?php echo $modality; ?> </td> <td title="Study date/time" style="font-size:8pt; white-space: nowrap;"><?php echo $studydatetime; ?> </td> <td title="Series date/time" style="font-size:8pt; white-space: nowrap;"><?php echo $seriesdatetime; ?> </td> <td title="Series number"><?php echo $seriesnum; ?> </td> <td title="Number of files"><?php echo $numfiles; ?> </td> <td style="font-size:16pt; padding-left:20px; padding-right:20px; color:darkred; -webkit-transform:scale(1.5,1);">➙</td> <td><a href="subjects.php?id=<?php echo $subjectid; ?> "><?php echo $newuid; ?> </a></td> <td title="Study number"><?php echo $newstudynum; ?> </td> <td title="Project number"><?php echo $project; ?> </td> <td title="Import time" style="font-size:8pt;"><?php echo $importtime; ?> </td> <td title="Import completed date/time" style="font-size:8pt;"><?php echo $maximportdatetime; ?> </td> <td title="Subject created"><?php echo $subjectcreated; ?> </td> <td title="Family created"><?php echo $familycreated; ?> </td> <td title="Enrollment created"><?php echo $enrollmentcreated; ?> </td> <td title="Study created"><?php echo $studycreated; ?> </td> <td title="Series created"><?php echo $seriescreated; ?> </td> <td title="Overwrote existing"><?php echo $overwroteexisting; ?> </td> </tr> <?php } ?> </tbody> </table> <?php }
<!-- menu --> <table width="100%" cellspacing="0" cellpadding="0" style="background-color: 3b5998; padding:10px; border-bottom: 2px solid #35486D"> <tr> <td width="250px"> <form method="post" action="index.php" id="instanceform"> <input type="hidden" name="action" value="switchinstance"> <span style="font-size: 16pt; color: white; font-weight: normal; -webkit-font-smoothing: antialiased;"><?php echo $_SESSION['instancename']; ?> </span> <select name="instanceid" style="background-color: #3B5998; border: 1px solid #526FAA; width: 20px; color: white" title="Switch instance" onChange="instanceform.submit()"> <option value="">Select Instance...</option> <? $sqlstring = "select * from instance where instance_id in (select instance_id from user_instance where user_id = (select user_id from users where username = '******'username'] . "')) order by instance_name"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $instance_id = $row['instance_id']; $instance_name = $row['instance_name']; ?> <option value="<?php echo $instance_id; ?> "><?php echo $instance_name; ?> </option> <? } ?> </select>