-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade.php
36 lines (33 loc) · 1.41 KB
/
upgrade.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
<?php
/*****************************************************************************************
** REDCap is only available through ACADMEMIC USER LICENSE with Vanderbilt University
******************************************************************************************/
// Turn off error reporting
error_reporting(0);
// Prevent caching
header("Expires: 0");
header("cache-control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
// Find the highest numbered REDCap version folder in this directory
$files = array();
$dh = opendir(dirname(__FILE__));
while (($filename = readdir($dh)) !== false)
{
if (substr($filename, 0, 8) == "redcap_v")
{
// Store version and numerical represetation of version in array to determine highest
$this_version = substr($filename, 8);
list ($v1, $v2, $v3) = explode(".", $this_version, 3);
$this_version_numerical = sprintf("%02d%02d%02d", $v1, $v2, $v3);
$files[$this_version_numerical] = $this_version;
}
}
if (empty($files))
{
exit("No REDCap directories found. Please install the REDCap software and try again.");
}
// Find the highest numbered key from the array and get its value
ksort($files, SORT_NUMERIC);
$upgrade_to_version = array_pop($files);
// Call the file in the REDCap version directory
include dirname(__FILE__) . DIRECTORY_SEPARATOR . "redcap_v" . $upgrade_to_version . DIRECTORY_SEPARATOR . "upgrade.php";