Skip to content

Instantly share code, notes, and snippets.

@hnnesv
Last active December 13, 2015 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnnesv/4984433 to your computer and use it in GitHub Desktop.
Save hnnesv/4984433 to your computer and use it in GitHub Desktop.
Tool for HIMMS Showcase 2013 - Execute a service command via a web endpoint.
<?php
if (!isset($_GET["type"])) {
echo "1";
} else {
$type = $_GET["type"];
$cmd = "false";
if ($type == "clockset") {
#date format MMDDhhmm[[CC]YY][.ss]
$date = $_GET["date"];
#see the setclock.sh script
$cmd = "echo $date > /tmp/clockset";
#or if you're running apache as root...
#(which is usually a bad idea)
#$cmd = "date $date";
} else if ($type == "cleanopenmrs") {
$cmd = "mysql openmrs -u root -pPASSWORD -e \"update encounter set voided='1';\"";
} else if ($type == "cleanopenxds") {
$cmd = "export PGPASSWORD=\"openxds\" && psql openxds -U openxds < /home/jembi/openxds/misc/create_database_schema_postgres.sql";
}
$output = null;
$returnValue = 1;
exec($cmd, $output, $returnValue);
echo "$returnValue";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment