/** * function to get the status of the invite sent to the user * @param: $contact */ function getMailMessage($name) { $query=0; $query=mysqlquery("select * from vl_emails_outgoing where lower(name)='".strtolower($name)."'"); if(mysqlnumrows($query)) { return mysqlresult($query,0,'description'); } }
/** * OPERATIONS STAFF FUNCTIONS */ function getSubordinateOperationsStaff($supervisor) { $query=0; $query=mysqlquery("select id from vl_users where reportsTo='$supervisor'"); if(mysqlnumrows($query)) { $staff=array(); while($q=mysqlfetcharray($query)) { $staff[]=$q["id"]; } return $staff; } }
/** * function to reset a user's password * @param: $email */ function resetPassword($email) { global $datetime,$borrowercentralCuser,$home_domain; $query=0; $query=mysqlquery("select * from vl_users where email='$email'"); if(mysqlnumrows($query)) { //reset the password and mail the user $newPassword=0; $newPassword=generatePassword(); //now reset the password mysqlquery("update vl_users set xp='".borrowercentralcSimpleEncrypt($newPassword)."', password='******' where email='$email'"); //inform the user by email //subject $subject=0; $subject="Password Reset"; //variables $password=0; $password=$newPassword; //the message $message=0; $message=" Your password has been reset. Your new password is: $password To preserve your privacy, we recommend that you login and change your password. Kind regards, System Team"; //mail the user sendPlainEmail($email,$subject,$message); } }
<td style="padding:0px 0px 0px 5px"><input type="text" name="suspectedTreatmentFailureValue" id="suspectedTreatmentFailureValue" value="<?php echo $suspectedTreatmentFailureValue; ?> " class="search_pre" size="7" maxlength="10" /></td> <td align="right">Sample Type:</td> <td style="padding:0px 0px 0px 5px"> <select name="suspectedTreatmentFailureSampleTypeID" id="suspectedTreatmentFailureSampleTypeID" class="search"> <? $query=0; $query=mysqlquery("select * from vl_appendix_sampletype order by position"); if($suspectedTreatmentFailureSampleTypeID) { echo "<option value=\"$suspectedTreatmentFailureSampleTypeID\" selected=\"selected\">".getDetailedTableInfo2("vl_appendix_sampletype","id='$suspectedTreatmentFailureSampleTypeID' limit 1","appendix")."</option>"; } else { echo "<option value=\"\" selected=\"selected\">Select Sample Type</option>"; } if(mysqlnumrows($query)) { while($q=mysqlfetcharray($query)) { echo "<option value=\"$q[id]\">$q[appendix]</option>"; } } ?> </select> </td> </tr> </table> </div> </fieldset> </td> </tr> <? //if(!getDetailedTableInfo2("vl_samples_verify","sampleID='$modify'","outcome")) { ?> <tr>
<tr> <td class="<?php echo $count < mysqlnumrows($query) ? "vl_tdstandard" : "vl_tdnoborder"; ?> "> <div><?php echo $q["logDetails"]; ?> </div> <div class="vls_grey" style="padding:5px 0px 0px 0px"><strong>Warning Type:</strong> <?php echo $warningType; ?> </div> </td> <td class="<?php echo $count < mysqlnumrows($query) ? "vl_tdstandard" : "vl_tdnoborder"; ?> "><?php echo getFormattedTimeLessS($q["created"]); ?> </td> </tr> <? } } ?> </table> </div> </td> </tr> <tr>
<? } ?> <input name="act" type="hidden" id="act" value="asampletype"> <input name="option" type="hidden" id="option" value="<?php echo $task; ?> "> </td> </tr> </table> </form> <? $query=0; $query=mysqlquery("select * from vl_appendix_sampletype order by position"); $num=0; $num=mysqlnumrows($query); if($num) { ?> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="vl"> <tr> <td style="padding:5px 0px" align="center"> <div style="height: 200px; border: 1px solid #ccccff; overflow: auto"> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="vl"> <tr> <td class="vl_tdsub" width="1%"><strong>#</strong></td> <td class="vl_tdsub" width="60%"><strong>Appendix</strong></td> <td class="vl_tdsub" width="10%"><strong>Samples</strong></td> <td class="vl_tdsub" width="29%"> </td> </tr> <? $count=0;
/** * function to fix repeated samples in the VL database */ function fixDuplicateSampleIDs() { global $datetime,$trailSessionUser; //get any duplicate sample IDs $query=0; $query=mysqlquery("select vlSampleID,count(id) num from vl_samples group by vlSampleID having num>1 order by num desc"); if(mysqlnumrows($query)) { while($q=mysqlfetcharray($query)) { //query where vlSampleID=$q[vlSampleID] $queryS=0; $queryS=mysqlquery("select * from vl_samples where vlSampleID='$q[vlSampleID]' order by created"); $count=0; while($qS=mysqlfetcharray($queryS)) { $count+=1; //only change the 2nd vlSampleID onwards if($count>1) { $vlSampleArray=0; $vlSampleArray=explode("/",trim($q["vlSampleID"])); $sampleLength1=0; $sampleLength1=strlen($vlSampleArray[0]); $sampleLength2=0; $sampleLength2=strlen(($vlSampleArray[0]/1)+($count-1)); $sampleLengthFinal=0; $sampleLengthFinal=abs($sampleLength1-$sampleLength2); $vlSample1=0; $vlSample1=($vlSampleArray[0]/1)+($count-1); switch($sampleLengthFinal) { case "5": $vlSample1="00000".$vlSample1; break; case "4": $vlSample1="0000".$vlSample1; break; case "3": $vlSample1="000".$vlSample1; break; case "2": $vlSample1="00".$vlSample1; break; case "1": $vlSample1="0".$vlSample1; break; } $vlSampleID=0; $vlSampleID=$vlSample1."/".$vlSampleArray[1]; //update vl_samples mysqlquery("update vl_samples set vlSampleID='$vlSampleID' where id='$qS[id]'"); } } } } }
/** * function to get specific countries from a region * @param: $region e.g. africa, south america etc */ function loadCountriesFromRegion($region,$companyID) { if($region) { global $user; $theUserID=0; //ensure $user is not a visitor if(substr($user,0,7)!="visitor") { $theUserID=getUserID($user); } //get the towns first $query=0; $query=mysqlquery("select distinct countryID,country from vl_countries where region='$region' order by country"); if(mysqlnumrows($query)) { $return=0; $return=" <table width=\"100%\" border=\"0\"> <tr> <td colspan=\"2\">Select the markets covered:</td> </tr>"; $q=array(); while($q=mysqlfetcharray($query)) { $return.=" <tr> <td width=\"1%\"><input type=\"checkbox\" name=\"marketscoveredUnique[]\" value=\"$q[countryID]\" ".(checkMarketAgainstProvider($theUserID,$q["countryID"],$companyID)?"checked":"")."></td> <td width=\"99%\">$q[country]</td> </tr>"; } $return.="</table>"; return $return; } else { $return=0; $return="No countries found in database!"; return $return; } } }
function isDateInDB($date) { $query=0; $query=mysqlquery("select * from vl_calendar where eventDate='$date'"); if(mysqlnumrows($query)) { return 1; } }
/** * get data for removal * @param: $query */ function getRemovedData($query) { //removed data $removedData=""; //get the table name, usually the 3rd word in the query $wordInQuery=array(); $wordInQuery=explode(" ",$query); $tableName=0; $tableName=$wordInQuery[2]; //get fields in table $tableQuery=0; $tableQuery=mysqlquery("desc $tableName"); if(mysqlnumrows($tableQuery)) { $fieldsInTable=array(); while($row=mysqlfetcharray($tableQuery)) { $fieldsInTable[]=$row["Field"]; } } //switch statement from "delete from" to "select * from" $newQuery=0; $newQuery=preg_replace("/delete from/is","select * from",$query); //ran the select query $selectQuery=0; $selectQuery=mysqlquery($newQuery); if(mysqlnumrows($selectQuery) && count($fieldsInTable)) { for($i=0;$i<count($fieldsInTable);$i++) { $removedData.="$fieldsInTable[$i]::".mysqlresult($selectQuery,0,"$fieldsInTable[$i]").($i<(count($fieldsInTable)-1)?"|":""); } } //return return $removedData; }
} //should we send the password to an email? if($remindEmail) { resetPassword($remindEmail); go("/sentreminder/$remindEmail/"); } if($login && $email && $pass) { //validate $email=validate($email); //authenticate $u=0; $u=mysqlquery("select * from vl_users where lower(email)='".strtolower($email)."'"); if(mysqlnumrows($u)) { while($un=mysqlfetcharray($u)) { if(strtolower($email)==strtolower($un["email"])) { //email authentic if(vlSimpleDecrypt($un["xp"])==hash("sha256",$pass)) { //has this account been de-activated? if(!$un["active"]) { go("/login/in/"); } else { //register session variables $_SESSION["VLEMAIL"]=$email; //log mysqlquery("update vl_users set lastLogin='******' where email='$_SESSION[VLEMAIL]'"); //redirect go("/dashboard/welcome/"); }
/** * function to change a user's setting * @param: $userID * @param: $setting * @param: $value */ function alterUserSetting($userID,$setting,$value) { //globals global $datetime,$trailSessionUser; //does user have a setting account? $query=0; $query=mysqlquery("select * from vl_users_settings where userID='$userID'"); if(mysqlnumrows($query)) { //log table change logTableChange("vl_users_settings","$setting",getDetailedTableInfo2("vl_users_settings","userID='$userID'","id"),getDetailedTableInfo2("vl_users_settings","userID='$userID'","$setting"),$value); //update mysqlquery("update vl_users_settings set $setting='$value' where userID='$userID'"); } else { //insert mysqlquery("insert into vl_users_settings (userID,$setting,created,createdby) values ('$userID','$value','$datetime','$trailSessionUser')"); } }
/** * load image */ function loadImage($url) { //get the corresponding file $query=0; $query=mysqlquery("select * from vl_filenames where fileurl='$url'"); if(mysqlnumrows($query)) { //file missing if(!is_file(mysqlresult($query,0,'filepath'))) { //return db ref return "sys.viewfile.php?wR=".mysqlresult($query,0,'id'); } else { $rand=0; $rand=rand(1,5); switch($rand) { case 5: return "sys.viewfile.php?wR=".mysqlresult($query,0,'id'); break; case 4: case 3: case 2: case 1: default: return $url; break; } } } else { return $url; } }
/** * function to match data * @param: $table * @param: $option * @param: $info */ function matchData($table,$comparefields,$returnfield,$searchterm,$options) { if($searchterm) { $ha=array(); $ha=explode(",",$comparefields); //iterations foreach($ha as $h) { //trim $h=trim($h); //query $query=0; $query=mysqlquery("select $returnfield,match($h) against('$searchterm' in boolean mode) as score from $table where $options and (match($h) against('$searchterm' in boolean mode) or $h like '%$searchterm%') order by score desc limit 1"); if(!mysqlerror()) { if(mysqlnumrows($query)) { return mysqlresult($query,0,$returnfield); } } } } }
//how many pages are there? if($numberPages>1) { echo "<tr><td style=\"padding:0px 0px 10px 0px\" class=\"vls_grey\"><strong>Pages:</strong> ".displayPagesLinks("/verify/".($approvedstatus=="search"?"search/$encryptedSample":$approvedstatus)."/pg/",1,$numberPages,($pg?$pg:1),$default_radius)."</td></tr>"; } $numberOfRelevantSamples=0; $numberOfRelevantSamples=getDetailedTableInfo3("vl_samples","verified=0","count(id)","num"); $resultsPending=0; $resultsPending=$numberOfRelevantSamples; $resultsProcessed=0; $resultsProcessed=getDetailedTableInfo3("vl_samples"," verified=1","count(id)","num"); $resultsSearch=0; $resultsSearch=mysqlnumrows($query); ?> <tr> <td> <table border="0" cellspacing="0" cellpadding="0"> <tr> <? if($approvedstatus=="pending") { ?> <td class="bluetab_active"><?php echo "Pending (" . number_format((double) $resultsPending) . ")"; ?> </td> <? } else { ?> <td class="bluetab_inactive"><a href="/verify/pending/"> <?php echo "Pending (" . number_format((double) $resultsPending) . ")"; ?>
/** * update application number */ function XloadFacilityFromFormName($formnumber,$formName,$fieldID,$facilityIDField) { //validate $formnumber=validate($formnumber); $formName=validate($formName); $fieldID=validate($fieldID); $facilityIDField=validate($facilityIDField); $objResponse = new vlDCResponse(); //reference number $refNumber=0; $refNumber=getDetailedTableInfo2("vl_forms_clinicalrequest","formNumber='$formnumber' limit 1","refNumber"); //facility ID $facilityID=0; $facilityID=getDetailedTableInfo2("vl_forms_clinicalrequest_dispatch","refNumber='$refNumber' limit 1","facilityID"); if($facilityID) { //load facilities $facilities=0; $facilities="<select name=\"$fieldID\" id=\"$fieldID\" class=\"search\" onchange=\"getHubDistrict(),checkForHubDistrict(), loadArtHistory(document.$formName.artNumber,document.$formName.facilityID.value)\">"; $query=0; $query=mysqlquery("select * from vl_facilities where facility!='' order by facility"); $facilities.="<option value=\"$facilityID\" selected=\"selected\">".getDetailedTableInfo2("vl_facilities","id='$facilityID' limit 1","facility")."</option>"; if(mysqlnumrows($query)) { while($q=mysqlfetcharray($query)) { $facilities.="<option value=\"$q[id]\">$q[facility]</option>"; } } $facilities.="</select>"; //load responses $objResponse->addAssign("$facilityIDField","innerHTML",$facilities); $objResponse->addScript("checkForHubDistrict()"); $objResponse->addScript("loadArtHistory(document.$formName.artNumber,'$facilityID')"); } return $objResponse->getXML(); }