-
Notifications
You must be signed in to change notification settings - Fork 8
/
update.php
42 lines (40 loc) · 1.16 KB
/
update.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
if (strtoupper(substr(php_uname('s'), 0, 3)) === 'WIN') {
$osextn = ".exe";
$osstrt = "";
} else {
$osextn = "";
$osstrt = "./";
}
$cmd = $osstrt . "blastdbcmd" . $osextn . " -version";
exec($cmd, $output);
$old_version = $output[0];
$old_v = preg_replace("/[^.0-9]+/", "", $old_version);
$host = 'ftp.ncbi.nlm.nih.gov';
$user = 'anonymous';
$password = 'anonymous';
$ftpConn = ftp_connect($host);
$login = ftp_login($ftpConn, $user, $password);
$blast_exe_dir = "/blast/executables/LATEST";
if ((!$ftpConn) || (!$login)) {
ftp_close($ftpConn);
echo 'NA';
}
ftp_chdir($ftpConn, $blast_exe_dir);
$dir = ftp_nlist($ftpConn, '');
$n = count($dir);
for ($i = 0; $i < $n; $i++) {
if (preg_match("/src.tar.gz$/i", $dir[$i]) == 1) {
$new_src = $dir[$i];
}
}
$new_version = ltrim($new_src, 'ncbi-blast-');
$new_version = rtrim($new_version, '-src.tar.gz');
ftp_close($ftpConn);
$new_v = preg_replace("/[^.0-9]+/", "", $new_version);
if ($new_v > $old_v) {
echo "<b>NEW:</b> <a href='ftp://ftp.ncbi.nlm.nih.gov/blast/executables/LATEST' title='Download'>Blast v$new_version</a>";
} else {
echo "You are running the latest version!";
}
?>