Example #1
0
     $sql = sql_connect($config['db']);
     if (!empty($_POST['references'])) {
         $entry['references'] = preg_replace('/&(#x?[0-9a-f]+);/', '&\\1', htmlentities(html_entity_decode($_POST['references']), ENT_QUOTES, 'ISO8859-1'));
     }
     $result = sql_query('SELECT prefix, id FROM sequence WHERE geneid=' . intval($_POST['geneid']) . ';', $sql);
     if (!strlen($r = sql_last_error($sql)) && sql_num_rows($result) == 0) {
         if (($locus = getlocus(intval($_POST['geneid']))) !== false && !empty($locus['accession']) && !empty($locus['start']) && !empty($locus['end']) && !empty($locus['locus'])) {
             $prefix = floor(((intval(date('Y', time())) - 2007) * 12 + intval(date('m', time())) - 1) / 1.5);
             $result = sql_query('INSERT INTO locus (prefix, id, name, locus_type, phenotype, pathway, functions, comments, evidence, sources, status, author) SELECT ' . $prefix . ', CASE WHEN max(id)>=1 THEN max(id)+1 ELSE 1 END, \'' . $locus['locus'] . '\',' . (!empty($locus['locus_type']) ? intval($locus['locus_type']) : 'NULL') . ',' . (!empty($locus['phenotype']) ? '\'' . addslashes($locus['phenotype']) . '\'' : 'NULL') . ',' . (!empty($locus['pathway']) ? '\'' . addslashes($locus['pathway']) . '\'' : 'NULL') . ',' . (!empty($locus['desc']) ? '\'' . addslashes($locus['desc']) . '\'' : 'NULL') . ',' . (!empty($locus['comment']) ? '\'' . addslashes($locus['comment']) . '\'' : 'NULL') . ',\'' . (!empty($pmid_ref) ? 'TAS' : 'NAS') . '\',' . (!empty($entry['references']) ? '\'' . addslashes($entry['references']) . '\'' : 'NULL') . ',1,\'UniPrime Web\' FROM locus WHERE prefix=' . $prefix . ';', $sql);
             if (!strlen($r = sql_last_error($sql))) {
                 $result = sql_query('SELECT prefix, id FROM locus WHERE name=\'' . $locus['locus'] . '\' AND status=1;', $sql);
                 if (!strlen($r = sql_last_error($sql)) && sql_num_rows($result) == 1) {
                     $row = sql_fetch_row($result);
                     $locus['locus'] = array('prefix' => $row[0], 'id' => $row[1]);
                     $locus['type'] = 1;
                     addSequence($locus, $sql);
                     header('Location: ' . $config['server'] . '/locus/L' . decoct($row[0]) . '.' . decoct($row[1]));
                     exit;
                 } else {
                     $msg = _("General error: entry unknown");
                 }
             } else {
                 $msg = _("Entry invalid, check your data");
             }
         } else {
             $msg = _("Unknown GeneID");
         }
     } else {
         $msg = _("This locus is already in the database");
     }
 }
Example #2
0
 if (!empty($_POST['seq_comments'])) {
     $entry['comments'] = ucfirst(preg_replace('/&(#x?[0-9a-f]+);/', '&\\1', htmlentities(html_entity_decode($_POST['seq_comments']), ENT_QUOTES, 'ISO8859-1')));
 }
 if (!empty($_POST['seq_references'])) {
     $entry['references'] = preg_replace('/&(#x?[0-9a-f]+);/', '&\\1', htmlentities(html_entity_decode($_POST['seq_references']), ENT_QUOTES, 'ISO8859-1'));
 }
 if (!empty($_POST['accession'])) {
     $entry['accession'] = preg_replace('/[^\\d\\w\\.]/', '', strtoupper($_POST['accession']));
     if (intval($_POST['start']) > intval($_POST['end'])) {
         $entry['end'] = intval($_POST['start']);
         $entry['start'] = intval($_POST['end']);
     } else {
         $entry['start'] = intval($_POST['start']);
         $entry['end'] = intval($_POST['end']);
     }
     $msg = addSequence($entry, $sql);
     if (empty($msg)) {
         header('Location: ' . $config['server'] . '/locus/' . $matches[0]);
         exit(0);
     }
 } else {
     $prefix = floor(((intval(date('Y', time())) - 2007) * 12 + intval(date('m', time())) - 1) / 1.5);
     $entry['name'] = preg_replace('/&(#x?[0-9a-f]+);/', '&\\1', htmlentities(html_entity_decode($_POST['name']), ENT_QUOTES, 'ISO8859-1'));
     $entry['sequence'] = preg_replace('/[^\\w]/', '', strtoupper($_POST['sequence']));
     if (!empty($_POST['alias'])) {
         $entry['alias'] = preg_replace('/&(#x?[0-9a-f]+);/', '&\\1', htmlentities(html_entity_decode($_POST['alias']), ENT_QUOTES, 'ISO8859-1'));
     }
     if (!empty($_POST['location'])) {
         $entry['location'] = preg_replace('/[^\\d\\w\\.\\-\\_\\(\\)]/', '', $_POST['location']);
     }
     $entry['strand'] = intval($_POST['strand']);