while ($z = $q->fetchAssoc()) { $aData['users'][$z['id']] = array('name' => $z['name'], 'email' => $z['email'], 'institute' => $z['institute']); } // Finally, get the actual disease data (ID, symbol, name). $q = $_DB->query('SELECT id, symbol, name FROM ' . TABLE_DISEASES . ' AS d INNER JOIN ' . TABLE_GEN2DIS . ' AS g2d ON (d.id = g2d.diseaseid) ORDER BY d.id', array(), false); while ($z = $q->fetchAssoc()) { $aData['diseases'][$z['id']] = array('symbol' => $z['symbol'], 'name' => $z['name']); } $sData = serialize($aData); $sPOSTVars .= '&data=' . rawurlencode($sData); // Send setting for wiki indexing. $bAllowIndex = $_DB->query('SELECT MAX(allow_index_wiki) FROM ' . TABLE_GENES)->fetchColumn(); $sPOSTVars .= '&allow_index_wiki=' . (int) $bAllowIndex; } // Contact upstream. $aOutput = lovd_php_file($_SETT['update_URL'] . $sURLVars, false, ltrim($sPOSTVars, '&')); // Check if output is valid. $sUpdates = !is_array($aOutput) ? '' : implode("\n", $aOutput); $sNow = date('Y-m-d H:i:s'); if (preg_match('/^Package\\s*:\\s*LOVD\\nVersion\\s*:\\s*' . $_SETT['system']['version'] . '(\\nReleased\\s*:\\s*[0-9]{4}\\-[0-9]{2}\\-[0-9]{2})?$/', $sUpdates)) { // No update available. $_DB->query('UPDATE ' . TABLE_STATUS . ' SET update_checked_date = ?, update_version = ?, update_level = 0, update_description = "", update_released_date = NULL', array($sNow, $_SETT['system']['version'])); $_STAT['update_checked_date'] = $sNow; $_STAT['update_version'] = $_SETT['system']['version']; $_STAT['update_released_date'] = ''; $_STAT['update_level'] = 0; $_STAT['update_description'] = ''; } elseif (preg_match('/^Package\\s*:\\s*LOVD\\nVersion\\s*:\\s*([1-9]\\.[0-9](\\.[0-9])?(\\-[0-9a-z-]{2,11})?)(\\nReleased\\s*:\\s*[0-9]{4}\\-[0-9]{2}\\-[0-9]{2})?$/', $sUpdates, $aUpdates) && is_array($aUpdates)) { // Weird version conflict? // FIXME; shouldn't we check maybe if the given version *IS* actually newer? Maybe it's just a non-registered release? lovd_writeLog('Error', 'CheckUpdate', 'Version conflict while parsing upstream server output: current version (' . $_SETT['system']['version'] . ') > ' . $aUpdates[1]);
function lovd_getUDForGene($sBuild, $sGene) { // Retrieves an UD for any given gene and genome build. // In principle, any build is supported, but we'll check against the available builds supported in LOVD. global $_CONF, $_SETT; if (!$sBuild || !is_string($sBuild) || !isset($_SETT['human_builds'][$sBuild])) { return false; } if (!$sGene || !is_string($sGene)) { return false; } $sUD = ''; // Let's get the mapping information. $sJSONResponse = implode("\n", lovd_php_file(str_replace('/services', '', $_CONF['mutalyzer_soap_url']) . '/json/getGeneLocation?build=' . $sBuild . '&gene=' . $sGene)); // If this is false, Mutalyzer returned a HTTP 500. On screen you'd get a reason and error message perhaps, but file_get_contents() just returns false. if ($sJSONResponse && ($aResponse = json_decode($sJSONResponse, true))) { $sChromosome = $_SETT['human_builds'][$sBuild]['ncbi_sequences'][substr($aResponse['chromosome_name'], 3)]; $nStart = $aResponse['start'] - ($aResponse['orientation'] == 'forward' ? 5000 : 2000); $nEnd = $aResponse['stop'] + ($aResponse['orientation'] == 'forward' ? 2000 : 5000); $sJSONResponse = implode("\n", lovd_php_file(str_replace('/services', '', $_CONF['mutalyzer_soap_url']) . '/json/sliceChromosome?chromAccNo=' . $sChromosome . '&start=' . $nStart . '&end=' . $nEnd . '&orientation=' . ($aResponse['orientation'] == 'forward' ? 1 : 2))); if ($sJSONResponse && ($aResponse = json_decode($sJSONResponse, true))) { $sResponse = !is_array($aResponse) ? $aResponse : implode('', $aResponse); $sUD = $sResponse; } } return $sUD; }
if (ON_WINDOWS) { $sHost = ini_get('SMTP') ? ini_get('SMTP') : 'localhost'; $nPort = ini_get('smtp_port') ? ini_get('smtp_port') : '25'; if ($f = @fsockopen($sHost, $nPort, $nError, $sError, 5)) { $bSMTP = true; fclose($f); } } else { $sPath = ini_get('sendmail_path') ? ini_get('sendmail_path') : '/usr/sbin/sendmail'; $sPath = substr($sPath, 0, strpos($sPath . ' ', ' ')); $bSMTP = is_executable($sPath); } $sSMTP = '<IMG src="gfx/mark_' . (int) $bSMTP . '.png" alt="" width="11" height="11"> ' . ($bSMTP ? 'R' : 'No r') . 'esponse from mail server (recommended' . ($bSMTP ? '' : ', please check your PHP configuration') . ')'; // 2012-02-01; 3.0-beta-02; Check for "MultiViews" or Apache's mod_rewrite, or anything some other webserver may have that does the same. $aResultNoExt = @lovd_php_file(lovd_getInstallURL() . 'setup'); $aResultExt = @lovd_php_file(lovd_getInstallURL() . 'setup.php'); $bMultiViews = !(!$aResultNoExt && $aResultExt); $sMultiViews = '<IMG src="gfx/mark_' . (int) $bMultiViews . '.png" alt="" width="11" height="11"> MultiViews, mod_rewrite or equivalent : ' . ($bMultiViews ? 'en' : 'dis') . 'abled (required)'; // FIXME; link to manual? if (!$bPHP || !$bPHPFunctions || !$bMySQL || !$bInnoDB || !$bMultiViews) { // Failure! lovd_showInfoTable('One or more requirements are not met!<BR>I will now bluntly refuse to install.<BR><BR>' . $sPHP . '<BR>' . $sPHPRequirements . $sMySQL . '<BR>' . $sInnoDB . '<BR>' . $sSMTP . '<BR>' . $sMultiViews, 'stop'); $_T->printFooter(); exit; } else { // Success! lovd_showInfoTable('System check for requirements all OK!<BR><BR>' . $sPHP . '<BR>' . $sPHPRequirements . $sMySQL . '<BR>' . $sInnoDB . '<BR>' . $sSMTP . '<BR>' . $sMultiViews, 'success'); } print ' The installation of LOVD consists of ' . (count($aInstallSteps) - 1) . ' simple steps. This installer will create the LOVD tables in the MySQL database, create the Administrator account and will help you configure LOVD. Installation and initial configuration of LOVD should be simple for a relatively experienced computer user.<BR> <BR>
if (ACTION == 'done') { // We were supposedly done before. Don't reload. $oPB->setMessage('Done.'); } else { $oPB->setMessage('Done, reloading...'); $oPB->redirectTo(CURRENT_PATH . '?done', 1); } die(' </BODY>' . "\n" . '</HTML>'); } elseif (!$aVariants) { // Failed query, $oPB->setMessage('Error, did not get proper response from database.'); die(' </BODY>' . "\n" . '</HTML>'); } else { // Proceed. $sVariants = json_encode($aVariants); $aResponse = lovd_php_file($sURL, false, 'variants=' . $sVariants); if ($aResponse) { $sResponse = implode($aResponse); } if (!$aResponse || !$sResponse) { $oPB->setMessage('Error, did not get proper response from remote source.'); die(' </BODY>' . "\n" . '</HTML>'); } $aFrequencies = @json_decode($sResponse, true); if ($aFrequencies === false || $aFrequencies === NULL) { $oPB->setMessage('Error, could not decode response from remote source: ' . htmlspecialchars($sResponse)); die(' </BODY>' . "\n" . '</HTML>'); } // Reply received, now go through results to update the database. // NOTE that you might not receive the same number of results that you // sent; variants that are not found in the WGS install will not be
} else { // Check answer! $response = recaptcha_check_answer('6Le0JQQAAAAAAB-iLSVi81tR5s8zTajluFFxkTPL', $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']); if (!$response->is_valid) { lovd_errorAdd('', 'Registration authentication failed. Please try again by filling in the two words that you see in the image at the bottom of the form.'); $sCAPTCHAerror = $response->error; } } // This function checks the given data for use by spammers. if (!lovd_error()) { $sRequest = 'http://www.stopforumspam.com/api?ip=' . $_SERVER['REMOTE_ADDR']; foreach (explode("\r\n", $_POST['email']) as $sEmail) { $sRequest .= '&email[]=' . $sEmail; } $sRequest .= '&username='******'username'] . '&f=json'; $aOutput = lovd_php_file($sRequest); if ($aOutput) { $aStopSpamResponse = array('success' => 0, 'ip' => array(array('appears' => 0, 'lastseen' => '', 'frequency' => 0, 'confidence' => 0)), 'email' => array(array('appears' => 0, 'lastseen' => '', 'frequency' => 0, 'confidence' => 0)), 'username' => array(array('appears' => 0, 'lastseen' => '', 'frequency' => 0, 'confidence' => 0))); $aStopSpamEmailTemplate = $aStopSpamResponse['email'][0]; $aOutput = json_decode(implode('', $aOutput), true); $aStopSpamResponse = array_replace_recursive($aStopSpamResponse, $aOutput); // Since we might have sent multiple email addresses, we need to apply the array_replace() on each email result. foreach ($aStopSpamResponse['email'] as $nKey => $aEmail) { if ($nKey) { // Key [0] has already been replaced, of course. $aStopSpamResponse['email'][$nKey] = array_replace($aStopSpamEmailTemplate, $aEmail); } } if ($aStopSpamResponse['success']) { $nFrequency = $aStopSpamResponse['ip'][0]['frequency'] + $aStopSpamResponse['username'][0]['frequency']; $nConfidence = max($aStopSpamResponse['ip'][0]['confidence'], $aStopSpamResponse['username'][0]['confidence']);
define('PAGE_TITLE', 'Search other public LOVDs for variant #' . $nID); define('LOG_EVENT', 'VariantGlobalSearch'); $_T->printHeader(false); $_T->printTitle(); lovd_isAuthorized('variant', $nID); lovd_requireAUTH(LEVEL_OWNER); require ROOT_PATH . 'class/object_genome_variants.php'; $zData = new LOVD_GenomeVariant(); $zData = $zData->loadEntry($nID); // Request data. $sSearchPosition = 'chr' . $zData['chromosome'] . ':' . $zData['position_g_start']; if ($zData['position_g_end'] != $zData['position_g_start']) { $sSearchPosition .= '_' . $zData['position_g_end']; } $sSignature = $_DB->query('SELECT signature FROM ' . TABLE_STATUS)->fetchColumn(); $aData = lovd_php_file($_SETT['upstream_URL'] . 'search.php?position=' . $sSearchPosition . '&build=' . $_CONF['refseq_build'] . '&ignore_signature=' . md5($sSignature)); if (empty($aData)) { // No data found. lovd_showInfoTable('This variant was not found in any other public LOVDs.'); $_T->printFooter(); exit; } print 'The variant has been found in the following public LOVDs. Click the entry for which you want to see more information.<BR><BR>' . "\n"; print '<TABLE class="data" cellpadding="0" cellspacing="1" width="100%">' . "\n" . ' <TR>' . "\n" . ' <TH>Genome build</TH>' . "\n" . ' <TH>Gene</TH>' . "\n" . ' <TH>Transcript</TH>' . "\n" . ' <TH>Position</TH>' . "\n" . ' <TH>DNA change</TH>' . "\n" . ' <TH>DB-ID</TH>' . "\n" . ' <TH>LOVD location</TH>' . "\n" . ' </TR>' . "\n"; $aHeaders = explode("\"\t\"", trim(array_shift($aData), '"')); // Remove all-zero DBIDs from the array. $aDataCleaned = array(); foreach ($aData as $sHit) { $aHit = array_combine($aHeaders, explode("\"\t\"", trim($sHit, '"'))); if (!preg_match('/_0?00000$/', $aHit['variant_id'])) { $aDataCleaned[] = $sHit;
} if ($sType && substr($sType, 0, 5) != 'text/') { // Not all systems report the regular files as "text/plain"; also reported was "text/x-pascal; charset=us-ascii". lovd_errorAdd('import', 'The upload file is not a tab-delimited text file and cannot be imported. It seems to be of type "' . htmlspecialchars($sType) . '".'); } else { $fInput = @fopen($_FILES['import']['tmp_name'], 'r'); if (!$fInput) { lovd_errorAdd('import', 'Cannot open file after it was received by the server.'); } else { // Check mode, we take no default if we don't understand the answer. if (empty($_POST['mode']) || !isset($aModes[$_POST['mode']])) { lovd_errorAdd('mode', 'Please select the import mode from the list of options.'); } // Open the file using file() to check the line endings, then check the encodings, try to use as little memory as possible. // Reading the entire file in memory, because we need to detect the encoding and possibly convert. $aData = lovd_php_file($_FILES['import']['tmp_name']); // Fix encoding problems. if ($_POST['charset'] == 'auto' || !isset($aCharSets[$_POST['charset']])) { // Auto detect charset, it's not given. // FIXME; Should we ever allow more encodings? $sEncoding = mb_detect_encoding(implode("\n", $aData), array('UTF-8', 'ISO-8859-1'), true); if (!$sEncoding) { // Could not be detected. lovd_errorAdd('charset', 'Could not autodetect the file\'s character encoding. Please select the character encoding from from the list of options.'); } elseif ($sEncoding != 'UTF-8') { // Is not UTF-8, and for sure has special chars. $aData = utf8_encode_array($aData); } } elseif ($_POST['charset'] == 'ISO-8859-1') { $aData = utf8_encode_array($aData); }
} // Testing connection to file on LOVD.nl. print "\n================================================================================\nOpening remote file over HTTP, using " . ($bFopenWrappers ? 'our file() since wrapper is enabled' : 'fsockopen() fallback since wrapper is disabled') . ", should return large positive number:\n"; var_dump(strlen(implode("\n", lovd_php_file('http://www.lovd.nl/mirrors/lrg/LRG_list.txt')))); // Testing connection to HGNC. print "\n================================================================================\nContacting HGNC over HTTP, using " . ($bFopenWrappers ? 'our file() since wrapper is enabled' : 'fsockopen() fallback since wrapper is disabled') . ", should return IVD gene data:\n"; var_dump(lovd_php_file('http://rest.genenames.org/search/symbol/IVD', false, '', 'Accept: application/json')); // Testing connection to Mutalyzer. $sURL = str_replace('/services', '', $_CONF['mutalyzer_soap_url']) . '/json/getGeneLocation?build=' . $_CONF['refseq_build'] . '&gene=IVD'; print "\n================================================================================\nContacting Mutalyzer over HTTPS, using fsockopen() fallback, should return IVD mapping data:\n"; var_dump(lovd_php_file($sURL)); print "\n================================================================================\nContacting Mutalyzer over HTTPS, using non-context file() call, should " . (!$bFopenWrappers ? 'fail since fopen wrappers are off' : ($bProxy && !$bProxyCanBeBypassed ? 'fail since the proxy is ignored' : 'return IVD mapping data')) . ":\n"; var_dump(file($sURL, FILE_IGNORE_NEW_LINES)); // Checking SNI_server_name / peer_name. print "\n================================================================================\nContacting LOVD server over HTTPS, using our file() wrapper, testing SNI_server_name vs peer_name settings, should " . (!$bFopenWrappers ? 'fail since fopen wrappers are off' : 'return a large positive number') . ":\n"; var_dump(strlen(implode("\n", lovd_php_file('https://grenada.lumc.nl/')))); // Now checking LOVD's Mutalyzer's SOAP implementation. $bSOAPWSDLCacheEnabled = ini_get('soap.wsdl_cache_enabled'); $bSOAPWSDLCacheTTL = ini_get('soap.wsdl_cache_ttl'); print "\n================================================================================\n SOAP TESTS\n================================================================================\nWSDLCacheEnabled : {$bSOAPWSDLCacheEnabled}\nWSDLCacheTTL : {$bSOAPWSDLCacheTTL}"; // The original class (with minor modifications for PHP 5.6.0.). class LOVD_SoapClientOri extends SoapClient { // This class provides a wrapper around SoapClient such that the proxy settings // are respected and SoapClient options are handled in just one place. function __construct() { // Initiate Soap Client. global $_CONF; $sHostname = parse_url($_CONF['mutalyzer_soap_url'], PHP_URL_HOST); // Mutalyzer's Apache server doesn't like SSL requests coming in through a proxy, if these settings are not configured.
if (empty($sFileID) || empty($_POST['transcript_id']) || empty($_POST['protein_id'])) { lovd_errorAdd('symbol', 'This gene or transcript does not seem to be configured correctly, we currently can\'t generate a human-readable reference sequence file using this gene.'); } // Check on avoidance of selection lists. if (!empty($_POST['symbol']) && !lovd_isAuthorized('gene', $_POST['symbol'])) { lovd_errorAdd('symbol', 'You do not have rights to run this script for this gene!'); } } if (!lovd_error()) { // All fields filled in, go ahead. // Read file into an array. $sFileID = substr($sFileID, 0, 2) == 'UD' ? str_replace('services', 'Reference/', $_CONF['mutalyzer_soap_url']) . $sFileID . '.gb' : 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=' . $sFileID . '&rettype=gb'; // FIXME: Since Mutalyzer only allows for https communication since Sept 2014, lovd_php_file()'s socket communication doesn't work. // 2014-10-02; 3.0-12; Modified lovd_php_file() to allow http(s) communication through PHP's file() as long as there's allow_url_fopen and no POST. // This is a temporary fix, depends on a PHP setting, and does not work with proxies at the moment (although than can be fixed with providing a context to file()). $aGenBank = lovd_php_file($sFileID); if (!$aGenBank) { lovd_errorAdd('symbol', 'We couldn\'t retrieve the reference sequence file for this gene. Please try again later.'); } else { // Select mRNA and CDS field based on transcript and protein id's. // First you want to find the mRNA and CDS field corresponding to the provided transcript_id and protein_id. $aTranscriptID = array(); $nTranscriptID = 0; $nProteinID = 0; $bGene = false; $bGeneFound = false; $bmRNA = false; $bCDS = false; $nRNAField = 0; $nCDSField = 0; // Go through the array until you found the mRNA and CDS field numbers