* * 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 ;. * * @package OpenEMR * @author Roberto Vasquez * @author Scott Wakefield * @link http://www.open-emr.org * **/ // Warning. If you set $allow_multisite_setup to true, this is a potential security vulnerability. // Recommend setting it back to false (or removing this setup.php script entirely) after you // are done with the multisite procedure. $allow_multisite_setup = false; // Warning. If you set $allow_cloning_setup to true, this is a potential security vulnerability. // Recommend setting it back to false (or removing this setup.php script entirely) after you // are done with the cloning setup procedure. $allow_cloning_setup = false; if (!$allow_cloning_setup && !empty($_REQUEST['clone_database'])) { die("To turn on support for cloning setup, need to edit this script and change \$allow_cloning_setup to true. After you are done setting up the cloning, ensure you change \$allow_cloning_setup back to false or remove this script altogether"); } $COMMAND_LINE = php_sapi_name() == 'cli'; require_once (dirname(__FILE__) . '/library/authentication/password_hashing.php'); require_once dirname(__FILE__) . '/library/classes/Installer.class.php'; //turn off PHP compatibility warnings ini_set("session.bug_compat_warn","off"); $state = isset($_POST["state"]) ? ($_POST["state"]) : ''; // Make this true for IPPF. $ippf_specific = false; // If this script was invoked with no site ID, then ask for one. if (!$COMMAND_LINE && empty($_REQUEST['site'])) { echo "\n"; echo "\n"; echo "OpenEMR Setup Tool\n"; echo "\n"; echo "\n"; echo "\n"; echo "

Optional Site ID Selection

\n"; echo "

Most OpenEMR installations support only one site. If that is " . "true for you then ignore the rest of this text and just click Continue.

\n"; echo "

Otherwise please enter a unique Site ID here.

\n"; echo "

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.

\n"; echo "

If each site will have its own host/domain name, then use that " . "name as the Site ID (e.g. www.example.com).

\n"; echo "

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.

\n"; echo "

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.

\n"; echo "
" . "Site ID:  " . "

\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."); } ?> OpenEMR Setup Tool OpenEMR Setup

Congratulations! OpenEMR is now installed.

  • Access controls (php-GACL) are installed for fine-grained security, and can be administered in OpenEMR's admin->acl menu.
  • Reviewing /config.php is a good idea. This file contains some settings that you may want to change.
  • There's much information and many extra tools bundled within the OpenEMR installation directory. Please refer to openemr/Documentation. Many forms and other useful scripts can be found at openemr/contrib.
  • To ensure a consistent look and feel through out the application using Firefox is recommended.
  • The OpenEMR project home page, documentation, and forums can be found at http://www.open-emr.org
  • We pursue grants to help fund the future development of OpenEMR. To apply for these grants, we need to estimate how many times this program is installed and how many practices are evaluating or using this software. It would be awesome if you would email us at president@oemr.org if you have installed this software. The more details about your plans with this software, the better, but even just sending us an email stating you just installed it is very helpful.

We recommend you print these instructions for future reference.

clone_database)) { echo "

The initial OpenEMR user is '".$installer->iuser."' and the password is '".$installer->iuserpass."'

"; echo "

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.

conffile (change the 'config' variable to 0), and re-run this script.
\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 \n \n
\n
\n
\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
\n \n \n"; if ($inst != 2) { echo "\n"; echo ""; echo ""; } echo ""; // Include a "source" site ID drop-list and a checkbox to indicate // if cloning its database. When checked, do not display initial user // and group stuff below. $dh = opendir($OE_SITES_BASE); if (!$dh) die("Cannot read directory '$OE_SITES_BASE'."); $siteslist = array(); while (false !== ($sfname = readdir($dh))) { if (substr($sfname, 0, 1) == '.') continue; if ($sfname == 'CVS' ) continue; if ($sfname == $site_id ) continue; $sitedir = "$OE_SITES_BASE/$sfname"; if (!is_dir($sitedir) ) continue; if (!is_file("$sitedir/sqlconf.php")) continue; $siteslist[$sfname] = $sfname; } closedir($dh); // If this is not the first site... if (!empty($siteslist)) { ksort($siteslist); echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; } echo ""; echo " "; echo ""; echo "
MYSQL SERVER:
Server Host: (If you run MySQL and Apache/PHP on the same computer, then leave this as 'localhost'. If they are on separate computers, then enter the IP address of the computer running MySQL.)
Server Port: (This is the MySQL port. The default port for MySQL is 3306.)
Database Name: (This is the name of the OpenEMR database in MySQL - 'openemr' is the recommended)
Login Name: (This is the name of the OpenEMR login name in MySQL - 'openemr' is the recommended)
Password: (This is the Login Password for when PHP accesses MySQL - it should be at least 8 characters long and composed of both numbers and letters)
Name for Root Account: (This is name for MySQL root account. For localhost, it is usually ok to leave it 'root'.)
Root Pass: (This is your MySQL root password. For localhost, it is usually ok to leave it blank.)
User Hostname: (If you run Apache/PHP and MySQL on the same computer, then leave this as 'localhost'. If they are on separate computers, then enter the IP address of the computer running Apache/PHP.)
UTF-8 Collation: " . "" . "
 (This is the collation setting for mysql. Leave as 'General' if you are not sure. If the language you are planning to use in OpenEMR is in the menu, then you can select it. Otherwise, just select 'General'.)
 
Source Site: (The site directory that will be a model for the new site.)
Clone Source Database: (Clone the source site's database instead of creating a fresh one.)
OPENEMR USER:
Initial User:(This is the login name of user that will be created for you. Limit this to one word.)
Initial User Password:(This is the password for the initial user account above.)
Initial User's First Name:(This is the First name of the 'initial user'.)
Initial User's Last Name:(This is the Last name of the 'initial user'.)
Initial Group:(This is the group that will be created for your users. This should be the name of your practice.)
 



"; 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 \n "; if ($allow_cloning_setup) { echo ""; } echo "
\n

\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 \n \n \n \n
\n

\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 "
  • Your php.ini file can be found at ".$phpINIfile."
  • \n"; $gotFileFlag = 1; } } echo "
  • ","To ensure proper functioning of OpenEMR you must make sure that PHP settings include:"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
    SettingRequired valueCurrent value
    short_open_tag Off", ini_get('short_open_tag')?'On':'Off', "
    display_errors Off", ini_get('display_errors')?'On':'Off', "
    register_globals Off", ini_get('register_globals')?'On':'Off', "
    max_input_vars at least 3000", ini_get('max_input_vars'), "
    max_execution_time at least 60", ini_get('max_execution_time'), "
    max_input_time at least 90", ini_get('max_input_time'), "
    post_max_size at least 30M", ini_get('post_max_size'), "
    memory_limit at least 128M", ini_get('memory_limit'), "
    "; echo "
  • "; echo "
  • In order to take full advantage of the patient documents capability you must make sure that settings in php.ini file include \"file_uploads = On\", that \"upload_max_filesize\" is appropriate for your use and that \"upload_tmp_dir\" is set to a correct value that will work on your system.
  • \n"; if (!$gotFileFlag) { echo "
  • If you are having difficulty finding your php.ini file, then refer to the 'INSTALL' manual for suggestions.
  • \n"; } echo "
"; echo "
We recommend you print these instructions for future reference.

"; echo "Next step will configure Apache web server."; echo "
\n \n \n \n \n
\n

\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 \n \n \n \n
\n

\n"; break; case 0: default: echo "

Welcome to OpenEMR. This utility will step you through the installation and configuration of OpenEMR for your practice.

\n"; echo "
  • Before proceeding, be sure that you have a properly installed and configured MySQL server available, and a PHP configured webserver.
  • \n"; echo "
  • Detailed installation instructions can be found in the 'INSTALL' manual file.
  • \n"; Echo "
  • If you are upgrading from a previous version, do NOT use this script. Please read the 'Upgrading' section found in the 'INSTALL' manual file.
"; if ($checkPermissions) { echo "

We will now ensure correct file and directory permissions before starting installation:

\n"; echo "Ensuring following files are world-writable...
\n"; $errorWritable = 0; foreach ($writableFileList as $tempFile) { if (is_writable($tempFile)) { echo "'".realpath($tempFile)."' file is ready.
\n"; } else { echo "

UNABLE to open file '".realpath($tempFile)."' for writing.
\n"; echo "(configure file permissions; see below for further instructions)

\n"; $errorWritable = 1; } } if ($errorWritable) { echo "

You can't proceed until all above files are ready (world-writable).
\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 "

" . "

\n"; break; } echo "
Ensuring following directories have proper permissions...
\n"; $errorWritable = 0; foreach ($writableDirList as $tempDir) { if (is_writable($tempDir)) { echo "'".realpath($tempDir)."' directory is ready.
\n"; } else { echo "

UNABLE to open directory '".realpath($tempDir)."' for writing by web server.
\n"; echo "(configure directory permissions; see below for further instructions)

\n"; $errorWritable = 1; } } if ($errorWritable) { echo "

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 "

" . "

\n"; break; } echo "
All required files and directories have been verified. Click to continue installation.
\n"; } else { echo "
Click to continue installation.
\n"; } echo "
" . "" . "

"; } } ?>