Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/patientapps_beta/api/.api/ |
Upload File : |
<?php
/*
-- available generic procedure guides
status - missing, beta, release
version (date)
url of payload.zip for this procedure - json and images
*/
global $db2;
$db2 = new database_my2('mysql://sii_pai:Y2hvcmU4OWtBcHV0@aries.hostz.org/pkp');
$db2->Open();
$debug = isset($_GET['debug']) ? $_GET['debug'] : '';
$debug = $debug == 'whatsup';
if ($debug) {
$content = GenerateMasterJson($db2, 'main');
ReturnJson($content);
}
if (!defined('LOAD_ONLY') ) {
$content = getMasterJson($db2);
header('Content-type: application/json');
echo $content;
}
function getMasterJson($db, $collection = 'main') {
$path = dirname(dirname(__DIR__)) . '/storage';
$filename = "$path/collection_{$collection}";
if (file_exists($filename)) {
$info = stat($filename);
$lastupdate = $info['mtime'];
if ($lastupdate > time() - 600) {
$content = UpdateFile($db, $collection, $filename);
} else {
$content = file_get_contents($filename);
}
} else {
$content = UpdateFile($db, $collection, $filename);
}
return $content;
}
function UpdateFile($db, $collection, $filename) {
$result = GenerateMasterJson($db, $collection);
$x = json_encode($result);
file_put_contents($filename, $x);
chmod($filename, 0666);
return $x;
}
function __load(&$ITEM, &$PARAM) {
$collection = $ITEM['collection'];
$isListed = $collection != 'unlisted';
$procedure = strtolower($ITEM['procedure_code']);
if (isset($PARAM[$procedure])) {
if ($isListed) $PARAM[$procedure] = TRUE;
} else {
$PARAM[$procedure] = $isListed;
}
}
function GenerateMasterJson($db, $collection) {
global $debug;
// get unlisted first, then listed in collection
$sql = 'select collection,procedure_code from pai_collection where collection in (%s, %s)';
$procedurelist = $db->query($sql, [$collection, 'unlisted'], '__load', []);
DbErr2($db);
$download_folder = DOWNLOAD_FOLDER;
$source = (strpos(HOST, 'beta.') !== FALSE) ? 1 : 0;
$procs = [];
foreach($procedurelist as $abbr => $isListed) {
if ($debug && substr($abbr, 0, 3) != 'pai') continue;
$filename = "{$download_folder}/{$abbr}.json";
if (file_exists($filename)) {
$fileinfo = getDocumentInfo($filename);
$node = [
'abbr' => $abbr,
'name' => $fileinfo->short, // short title
'title' => $fileinfo->title, // long title
'generic' => $isListed ? 1 : 0, // shown in app when no Procedure Code entered
'version' => $fileinfo->version,
'size' => $fileinfo->size,
'location' => $source,
];
$procs[] = $node;
}
}
usort($procs, function($a, $b) {
return strcasecmp($a['name'], $b['name']);
});
$result = [
'languages' => [
1 => [
'name' => 'English',
'theme' => 'l2r',
'flag' => '-',
]
],
'snapshot' => time(), // time this json file was created. Expires in 24hr.
'default' => '207282', // this is the procedure that will be the default when nothing is specified
'procedures' => $procs,
];
return $result;
}