*
* LICENSE: This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be usefull,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY OF FITNESS FOR A PARTICULAR PURPOSE, See the
* GNU General Public License for more details.
* You should have received a copy of the CNU General Public License
* along with this program. If not, see Optional Site ID Selection Most OpenEMR installations support only one site. If that is " .
"true for you then ignore the rest of this text and just click Continue. Otherwise please enter a unique Site ID here. A Site ID is a short identifier with no spaces or special " .
"characters other than periods or dashes. It is case-sensitive and we " .
"suggest sticking to lower case letters for ease of use. If each site will have its own host/domain name, then use that " .
"name as the Site ID (e.g. www.example.com). The site ID is used to identify which site you will log in to. " .
"If it is a hostname then it is taken from the hostname in the URL. " .
"Otherwise you must append \"?site=siteid\" to the URL used for " .
"logging in. It is OK for one of the sites to have \"default\" as its ID. This " .
"is the ID that will be used if it cannot otherwise be determined. Congratulations! OpenEMR is now installed.
We recommend you print these instructions for future reference.
The initial OpenEMR user is '".$installer->iuser."' and the password is '".$installer->iuserpass."' If you edited the PHP or Apache configuration files during this installation process, then we recommend you restart your Apache server before following below OpenEMR link.
Click here to start using OpenEMR.
Welcome to OpenEMR. This utility will step you through the installation and configuration of OpenEMR for your practice. We will now ensure correct file and directory permissions before starting installation: UNABLE to open file '".realpath($tempFile)."' for writing. You can't proceed until all above files are ready (world-writable).
\n";
echo "\n";
exit();
}
// Support "?site=siteid" in the URL, otherwise assume "default".
$site_id = 'default';
if (!$COMMAND_LINE && !empty($_REQUEST['site'])) {
$site_id = trim($_REQUEST['site']);
}
// Die if site ID is empty or has invalid characters.
if (empty($site_id) || preg_match('/[^A-Za-z0-9\\-.]/', $site_id))
die("Site ID '".htmlspecialchars($site_id,ENT_NOQUOTES)."' contains invalid characters.");
// If multisite is turned off, then only allow default for site.
if (!$allow_multisite_setup && $site_id != 'default') {
die("To turn on support for multisite setup, need to edit this script and change \$allow_multisite_setup to true. After you are done setting up the cloning, ensure you change \$allow_multisite_setup back to false or remove this script altogether");
}
//If having problems with file and directory permission
// checking, then can be manually disabled here.
$checkPermissions = True;
$installer = new Installer( $_REQUEST );
global $OE_SITE_DIR; // The Installer sets this
$docsDirectory = "$OE_SITE_DIR/documents";
$billingDirectory = "$OE_SITE_DIR/edi";
$billingDirectory2 = "$OE_SITE_DIR/era";
$lettersDirectory = "$OE_SITE_DIR/letter_templates";
$gaclWritableDirectory = dirname(__FILE__)."/gacl/admin/templates_c";
$requiredDirectory1 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/compiled";
$requiredDirectory2 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/cache";
$zendModuleConfigFile = dirname(__FILE__)."/interface/modules/zend_modules/config/application.config.php";
//These are files and dir checked before install for
// correct permissions.
if (is_dir($OE_SITE_DIR)) {
$writableFileList = array($installer->conffile,$zendModuleConfigFile);
$writableDirList = array($docsDirectory, $billingDirectory, $billingDirectory2, $lettersDirectory, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
}
else {
$writableFileList = array();
$writableDirList = array($OE_SITES_BASE, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
}
// Include the sqlconf file if it exists yet.
$config = 0;
if (file_exists($OE_SITE_DIR)) {
include_once($installer->conffile);
}
else if ($state > 3) {
// State 3 should have created the site directory if it is missing.
die("Internal error, site directory is missing.");
}
?>
\n";
}
else {
switch ($state) {
case 1:
echo "Step $state
\n";
echo "Now I need to know whether you want me to create the database on my own or if you have already created the database for me to use. For me to create the database, you will need to supply the MySQL root password.\n
NOTE: clicking on \"Continue\" may delete or cause damage to data on your system. Before you continue please backup your data.
\n
\n";
break;
case 2:
echo "Step $state
\n";
echo "Now you need to supply the MySQL server information and path information. Detailed instructions on each item can be found in the 'INSTALL' manual file.
\n
";
break;
case 3:
// Form Validation
// (applicable if not cloning from another database)
$pass_step2_validation = TRUE;
$error_step2_message = "ERROR at ";
if ( ! $installer->char_is_valid($_REQUEST['server'])) {
$pass_step2_validation = FALSE;
$error_step2_message .= "Database Server Host, ";
}
if ( ! $installer->char_is_valid($_REQUEST['port'])) {
$pass_step2_validation = FALSE;
$error_step2_message .= "Database Server Port, ";
}
if ( ! $installer->databaseNameIsValid($_REQUEST['dbname'])) {
$pass_step2_validation = FALSE;
$error_step2_message .= "Database Name, ";
}
if (! $installer->collateNameIsValid($_REQUEST['collate'])) {
$pass_step2_validation = false;
$error_step2_message .= "Collation Name, ";
}
if ( ! $installer->char_is_valid($_REQUEST['login'])) {
$pass_step2_validation = FALSE;
$error_step2_message .= "Database Login Name, ";
}
if ( ! $installer->char_is_valid($_REQUEST['pass'])) {
$pass_step2_validation = FALSE;
$error_step2_message .= "Database Login Password, ";
}
if (!$pass_step2_validation) {
die($error_step2_message);
}
if (empty($installer->clone_database)) {
if ( ! $installer->login_is_valid() ) {
echo "ERROR. Please pick a proper 'Login Name'.
\n";
echo "Click Back in browser to re-enter.
\n";
break;
}
if ( ! $installer->iuser_is_valid() ) {
echo "ERROR. The 'Initial User' field can only contain one word and no spaces.
\n";
echo "Click Back in browser to re-enter.
\n";
break;
}
if ( ! $installer->user_password_is_valid() ) {
echo "ERROR. Please pick a proper 'Initial User Password'.
\n";
echo "Click Back in browser to re-enter.
\n";
break;
}
}
if ( ! $installer->password_is_valid() ) {
echo "ERROR. Please pick a proper 'Password'.
\n";
echo "Click Back in browser to re-enter.
\n";
break;
}
echo "Step $state
\n";
echo "Configuring OpenEMR...
\n";
// Skip below if database shell has already been created.
if ($inst != 2) {
echo "Connecting to MySQL Server...\n";
flush();
if ( ! $installer->root_database_connection() ) {
echo "ERROR. Check your login credentials.\n";
echo $installer->error_message;
break;
}
else {
echo "OK.
\n";
flush();
}
}
// Only pertinent if cloning another installation database
if ($allow_cloning_setup && !empty($installer->clone_database)) {
echo "Dumping source database...";
flush();
if ( ! $installer->create_dumpfiles() ) {
echo $installer->error_message;
break;
}
else {
echo " OK.
\n";
flush();
}
}
// Only pertinent if mirroring another installation directory
if ( ! empty($installer->source_site_id)) {
echo "Creating site directory...";
if ( ! $installer->create_site_directory() ) {
echo $installer->error_message;
break;
}
else {
echo "OK.
";
flush();
}
}
// Skip below if database shell has already been created.
if ($inst != 2) {
echo "Creating database...\n";
flush();
if ( ! $installer->create_database() ) {
echo "ERROR. Check your login credentials.\n";
echo $installer->error_message;
break;
} else {
echo "OK.
\n";
flush();
}
echo "Creating user with permissions for database...\n";
flush();
if ( ! $installer->grant_privileges() ) {
echo "ERROR when granting privileges to the specified user.\n";
echo $installer->error_message;
break;
} else {
echo "OK.
\n";
flush();
}
echo "Reconnecting as new user...\n";
flush();
$installer->disconnect();
} else {
echo "Connecting to MySQL Server...\n";
}
if ( ! $installer->user_database_connection() ) {
echo "ERROR. Check your login credentials.\n";
echo $installer->error_message;
break;
}
else {
echo "OK.
\n";
flush();
}
// Load the database files
$dump_results = $installer->load_dumpfiles();
if ( ! $dump_results ) {
echo $installer->error_message;
break;
} else {
echo $dump_results;
flush();
}
echo "Writing SQL configuration...\n";
flush();
if ( ! $installer->write_configuration_file() ) {
echo $installer->error_message;
break;
}
else {
echo "OK.
\n";
flush();
}
// Only pertinent if not cloning another installation database
if (empty($installer->clone_database)) {
echo "Setting version indicators...\n";
flush();
if ( ! $installer->add_version_info() ) {
echo "ERROR.\n";
echo $installer->error_message;;
break;
}
else {
echo "OK
\n";
flush();
}
echo "Writing global configuration defaults...\n";
flush();
if ( ! $installer->insert_globals() ) {
echo "ERROR.\n";
echo $installer->error_message;;
break;
}
else {
echo "OK
\n";
flush();
}
echo "Adding Initial User...\n";
flush();
if ( ! $installer->add_initial_user() ) {
echo $installer->error_message;
break;
}
echo "OK
\n";
flush();
}
if ($allow_cloning_setup && !empty($installer->clone_database)) {
// Database was cloned, skip ACL setup.
echo "Click 'continue' for further instructions.";
$next_state = 7;
}
else {
echo "\n
Next step will install and configure access controls (php-GACL).
\n";
$next_state = 4;
}
echo "
\n";
break;
case 4:
echo "Step $state
\n";
echo "Installing and Configuring Access Controls (php-GACL)...
";
if ( ! $installer->install_gacl() ) {
echo $installer->error_message;
break;
}
else {
// display the status information for gacl setup
echo $installer->debug_message;
}
echo "Gave the '$installer->iuser' user (password is '$installer->iuserpass') administrator access.
";
echo "Done installing and configuring access controls (php-GACL).
";
echo "Next step will configure PHP.";
echo "
\n";
break;
case 5:
echo "Step $state
\n";
echo "Configuration of PHP...
\n";
echo "We recommend making the following changes to your PHP installation, which can normally be done by editing the php.ini configuration file:\n";
echo "";
$gotFileFlag = 0;
if (version_compare(PHP_VERSION, '5.2.4', '>=')) {
$phpINIfile = php_ini_loaded_file();
if ($phpINIfile) {
echo "
";
echo "
";
echo " ";
echo "Setting Required value Current value \n";
echo "short_open_tag Off ", ini_get('short_open_tag')?'On':'Off', " \n";
echo "display_errors Off ", ini_get('display_errors')?'On':'Off', " \n";
echo "register_globals Off ", ini_get('register_globals')?'On':'Off', " \n";
echo "max_input_vars at least 3000 ", ini_get('max_input_vars'), " \n";
echo "max_execution_time at least 60 ", ini_get('max_execution_time'), " \n";
echo "max_input_time at least 90 ", ini_get('max_input_time'), " \n";
echo "post_max_size at least 30M ", ini_get('post_max_size'), " \n";
echo "memory_limit at least 128M ", ini_get('memory_limit'), "
We recommend you print these instructions for future reference.
";
echo "Next step will configure Apache web server.";
echo "
\n";
break;
case 6:
echo "Step $state
\n";
echo "Configuration of Apache web server...
\n";
echo "The \"".preg_replace("/${site_id}/","*",realpath($docsDirectory))."\", \"".preg_replace("/${site_id}/","*",realpath($billingDirectory))."\" and \"".preg_replace("/${site_id}/","*",realpath($billingDirectory2))."\" directories contain patient information, and
it is important to secure these directories. Additionally, some settings are required for the Zend Framework to work in OpenEMR. This can be done by pasting the below to end of your apache configuration file:
<Directory \"".realpath(dirname(__FILE__))."\">
AllowOverride FileInfo
</Directory>
<Directory \"".realpath(dirname(__FILE__))."/sites\">
AllowOverride None
</Directory>
<Directory \"".preg_replace("/${site_id}/","*",realpath($docsDirectory))."\">
order deny,allow
Deny from all
</Directory>
<Directory \"".preg_replace("/${site_id}/","*",realpath($billingDirectory))."\">
order deny,allow
Deny from all
</Directory>
<Directory \"".preg_replace("/${site_id}/","*",realpath($billingDirectory2))."\">
order deny,allow
Deny from all
</Directory>
";
echo "If you are having difficulty finding your apache configuration file, then refer to the 'INSTALL' manual for suggestions.
\n";
echo "
We recommend you print these instructions for future reference.
";
echo "Click 'continue' for further instructions.";
echo "
\n";
break;
case 0:
default:
echo "
";
if ($checkPermissions) {
echo "
\n";
$errorWritable = 0;
foreach ($writableFileList as $tempFile) {
if (is_writable($tempFile)) {
echo "'".realpath($tempFile)."' file is ready.
\n";
}
else {
echo "
\n";
echo "(configure file permissions; see below for further instructions)
\n";
echo "In linux, recommend changing file permissions with the 'chmod 666 filename' command.
\n";
echo "Fix above file permissions and then click the 'Check Again' button to re-check files.
\n";
echo "
UNABLE to open directory '".realpath($tempDir)."' for writing by web server.
\n";
echo "(configure directory permissions; see below for further instructions)
You can't proceed until all directories are ready.
\n";
echo "In linux, recommend changing owners of these directories to the web server. For example, in many linux OS's the web server user is 'apache', 'nobody', or 'www-data'. So if 'apache' were the web server user name, could use the command 'chown -R apache:apache directory_name' command.
\n";
echo "Fix above directory permissions and then click the 'Check Again' button to re-check directories.
\n";
echo "