increment database version for previous theme bug fix
[openemr.git] / setup.php
blobea584e937e4594ad75907c9f32c182c2ad7cf84c
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 $COMMAND_LINE = php_sapi_name() == 'cli';
8 require_once dirname(__FILE__) . '/library/classes/Installer.class.php';
10 //turn off PHP compatibility warnings
11 ini_set("session.bug_compat_warn","off");
13 $state = $_POST["state"];
15 // Make this true for IPPF.
16 $ippf_specific = false;
18 // If this script was invoked with no site ID, then ask for one.
19 if (!$COMMAND_LINE && empty($_REQUEST['site'])) {
20 echo "<html>\n";
21 echo "<head>\n";
22 echo "<title>OpenEMR Setup Tool</title>\n";
23 echo "<link rel='stylesheet' href='interface/themes/style_blue.css'>\n";
24 echo "</head>\n";
25 echo "<body>\n";
26 echo "<p><b>Optional Site ID Selection</b></p>\n";
27 echo "<p>Most OpenEMR installations support only one site. If that is " .
28 "true for you then ignore the rest of this text and just click Continue.</p>\n";
29 echo "<p>Otherwise please enter a unique Site ID here.</p>\n";
30 echo "<p>A Site ID is a short identifier with no spaces or special " .
31 "characters other than periods or dashes. It is case-sensitive and we " .
32 "suggest sticking to lower case letters for ease of use.</p>\n";
33 echo "<p>If each site will have its own host/domain name, then use that " .
34 "name as the Site ID (e.g. www.example.com).</p>\n";
35 echo "<p>The site ID is used to identify which site you will log in to. " .
36 "If it is a hostname then it is taken from the hostname in the URL. " .
37 "Otherwise you must append \"?site=<i>siteid</i>\" to the URL used for " .
38 "logging in.</p>\n";
39 echo "<p>It is OK for one of the sites to have \"default\" as its ID. This " .
40 "is the ID that will be used if it cannot otherwise be determined.</p>\n";
41 echo "<form method='post'><input type='hidden' name='state' value='0'>" .
42 "Site ID: <input type='text' name='site' value='default'>&nbsp;" .
43 "<input type='submit' value='Continue'><br></form><br>\n";
44 echo "</body></html>\n";
45 exit();
48 // Support "?site=siteid" in the URL, otherwise assume "default".
49 $site_id = 'default';
50 if (!$COMMAND_LINE && !empty($_REQUEST['site'])) {
51 $site_id = trim($_REQUEST['site']);
54 // Die if site ID is empty or has invalid characters.
55 if (empty($site_id) || preg_match('/[^A-Za-z0-9\\-.]/', $site_id))
56 die("Site ID '$site_id' contains invalid characters.");
58 //If having problems with file and directory permission
59 // checking, then can be manually disabled here.
60 $checkPermissions = True;
62 $installer = new Installer( $_REQUEST );
63 global $OE_SITE_DIR; // The Installer sets this
65 $docsDirectory = "$OE_SITE_DIR/documents";
66 $billingDirectory = "$OE_SITE_DIR/edi";
67 $billingDirectory2 = "$OE_SITE_DIR/era";
69 $billingLogDirectory = dirname(__FILE__)."/library/freeb";
70 $lettersDirectory = "$OE_SITE_DIR/letter_templates";
71 $gaclWritableDirectory = dirname(__FILE__)."/gacl/admin/templates_c";
72 $requiredDirectory1 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/compiled";
73 $requiredDirectory2 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/cache";
75 //These are files and dir checked before install for
76 // correct permissions.
77 if (is_dir($OE_SITE_DIR)) {
78 $writableFileList = array($installer->conffile);
79 $writableDirList = array($docsDirectory, $billingDirectory, $billingDirectory2, $lettersDirectory, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
81 else {
82 $writableFileList = array();
83 $writableDirList = array($OE_SITES_BASE, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
86 // Include the sqlconf file if it exists yet.
87 $config = 0;
88 if (file_exists($OE_SITE_DIR)) {
89 include_once($installer->conffile);
91 else if ($state > 3) {
92 // State 3 should have created the site directory if it is missing.
93 die("Internal error, site directory is missing.");
97 <HTML>
98 <HEAD>
99 <TITLE>OpenEMR Setup Tool</TITLE>
100 <LINK REL=STYLESHEET HREF="interface/themes/style_sky_blue.css">
102 <style>
103 .noclone { }
104 </style>
106 <script type="text/javascript" src="library/js/jquery.js"></script>
108 <script language="javascript">
109 // onclick handler for "clone database" checkbox
110 function cloneClicked() {
111 var cb = document.forms[0].clone_database;
112 $('.noclone').css('display', cb.checked ? 'none' : 'block');
114 </script>
116 </HEAD>
117 <BODY>
119 <span class="title">OpenEMR Setup</span>
120 <br><br>
121 <span class="text">
123 <?php
124 if (strtolower(ini_get('register_globals')) != 'off' && (bool) ini_get('register_globals')) {
125 echo "It appears that you have register_globals enabled in your php.ini\n" .
126 "configuration file. This causes unacceptable security risks. You must\n" .
127 "turn it off before continuing with installation.\n";
128 exit();
132 <?php
133 if ($state == 7) {
136 <p>Congratulations! OpenEMR is now installed.</p>
138 <ul>
139 <li>Access controls (php-GACL) are installed for fine-grained security, and can be administered in
140 OpenEMR's admin->acl menu.</li>
141 <li>Reviewing <?php echo $OE_SITE_DIR; ?>/config.php is a good idea. This file
142 contains some settings that you may want to change.</li>
143 <li>There's much information and many extra tools bundled within the OpenEMR installation directory.
144 Please refer to openemr/Documentation. Many forms and other useful scripts can be found at openemr/contrib.</li>
145 <li>To ensure a consistent look and feel through out the application using
146 <a href='http://www.mozilla.org/products/firefox/'>Firefox</a> is recommended.</li>
147 <li>The OpenEMR project home page and wiki can be found at <a href = "http://www.oemr.org" target="_blank">http://www.oemr.org</a></li>
148 <li>The OpenEMR forums can be found at <a href = "http://sourceforge.net/projects/openemr" target="_blank">http://sourceforge.net/projects/openemr</a></li>
149 <li>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 <a href="mailto:drbowen@openmedsoftware.org">drbowen@openmedsoftware.org</a> 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.</li>
150 </ul>
152 We recommend you print these instructions for future reference.
153 </p>
154 <?php if (empty($installer->clone_database)) {
155 echo "<p><b>The initial OpenEMR user is '".$installer->iuser."' and the password is '".$installer->iuserpass."'</b></p>";
156 echo "<p>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.</p>";
157 } ?>
159 <a href='./?site=<?php echo $site_id; ?>'>Click here to start using OpenEMR. </a>
160 </p>
162 <?php
163 exit();
167 <?php
169 $inst = $_POST["inst"];
171 if (($config == 1) && ($state < 4)) {
172 echo "OpenEMR has already been installed. If you wish to force re-installation, then edit $installer->conffile (change the 'config' variable to 0), and re-run this script.<br>\n";
174 else {
175 switch ($state) {
177 case 1:
178 echo "<b>Step $state</b><br><br>\n";
179 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
180 <span class='title'> <br />NOTE: clicking on \"Continue\" may delete or cause damage to data on your system. Before you continue please backup your data.</span>
181 <br><br>\n
182 <FORM METHOD='POST'>\n
183 <INPUT TYPE='HIDDEN' NAME='state' VALUE='2'>\n
184 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
185 <LABEL FOR='inst1'><INPUT TYPE='RADIO' ID='inst1' NAME='inst' VALUE='1' checked>Have setup create the database</label><br>\n
186 <LABEL FOR='inst2'><INPUT TYPE='RADIO' ID='inst2' NAME='inst' VALUE='2'>I have already created the database</label><br>\n
187 <br>\n
188 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
189 break;
191 case 2:
192 echo "<b>Step $state</b><br><br>\n";
193 echo "Now you need to supply the MySQL server information and path information. Detailed instructions on each item can be found in the <a href='INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.
194 <br><br>\n
195 <FORM METHOD='POST'>
196 <INPUT TYPE='HIDDEN' NAME='state' VALUE='3'>
197 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
198 <INPUT TYPE='HIDDEN' NAME='inst' VALUE='$inst'>
199 <TABLE>\n
200 <TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>MYSQL SERVER:</font></TD></TR>
201 <TR VALIGN='TOP'><TD><span class='text'>Server Host: </span></TD><TD><INPUT TYPE='TEXT' VALUE='localhost' NAME='server' SIZE='30'></TD><TD><span class='text'>(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.)</span><br></TD></TR>
202 <TR VALIGN='TOP'><TD><span class='text'>Server Port: </span></TD><TD><INPUT TYPE='TEXT' VALUE='3306' NAME='port' SIZE='30'></TD><TD><span class='text'>(This is the MySQL port. The default port for MySQL is 3306.)</span><br></TD></TR>
203 <TR VALIGN='TOP'><TD><span class='text'>Database Name: </span></TD><TD><INPUT TYPE='TEXT' VALUE='openemr' NAME='dbname' SIZE='30'></TD><TD><span class='text'>(This is the name of the OpenEMR database in MySQL - 'openemr' is the recommended)</span><br></TD></TR>
204 <TR VALIGN='TOP'><TD><span class='text'>Login Name: </span></TD><TD><INPUT TYPE='TEXT' VALUE='openemr' NAME='login' SIZE='30'></TD><TD><span class='text'>(This is the name of the OpenEMR login name in MySQL - 'openemr' is the recommended)</span><br></TD></TR>
205 <TR VALIGN='TOP'><TD><span class='text'>Password: </span></TD><TD><INPUT TYPE='PASSWORD' VALUE='' NAME='pass' SIZE='30'></TD><TD><span class='text'>(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)</span><br></TD></TR>\n";
206 if ($inst != 2) {
207 echo "<TR VALIGN='TOP'><TD><span class='text'>Name for Root Account: </span></TD><TD><INPUT TYPE='TEXT' VALUE='root' NAME='root' SIZE='30'></TD><TD><span class='text'>(This is name for MySQL root account. For localhost, it is usually ok to leave it 'root'.)</span><br></TD></TR>
208 <TR VALIGN='TOP'><TD><span class='text'>Root Pass: </span></TD><TD><INPUT TYPE='PASSWORD' VALUE='' NAME='rootpass' SIZE='30'></TD><TD><span class='text'>(This is your MySQL root password. For localhost, it is usually ok to leave it blank.)</span><br></TD></TR>\n";
209 echo "<TR VALIGN='TOP'><TD><span class='text'>User Hostname: </span></TD><TD><INPUT TYPE='TEXT' VALUE='localhost' NAME='loginhost' SIZE='30'></TD><TD><span class='text'>(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.)</span><br></TD></TR>";
210 echo "<TR VALIGN='TOP'><TD><span class='text'>UTF-8 Collation: </span></TD><TD colspan='2'>" .
211 "<select name='collate'>" .
212 "<option value='utf8_bin' >Bin</option>" .
213 "<option value='utf8_czech_ci' >Czech</option>" .
214 "<option value='utf8_danish_ci' >Danish</option>" .
215 "<option value='utf8_esperanto_ci' >Esperanto</option>" .
216 "<option value='utf8_estonian_ci' >Estonian</option>" .
217 "<option value='utf8_general_ci' selected>General</option>" .
218 "<option value='utf8_hungarian_ci' >Hungarian</option>" .
219 "<option value='utf8_icelandic_ci' >Icelandic</option>" .
220 "<option value='utf8_latvian_ci' >Latvian</option>" .
221 "<option value='utf8_lithuanian_ci'>Lithuanian</option>" .
222 "<option value='utf8_persian_ci' >Persian</option>" .
223 "<option value='utf8_polish_ci' >Polish</option>" .
224 "<option value='utf8_roman_ci' >Roman</option>" .
225 "<option value='utf8_romanian_ci' >Romanian</option>" .
226 "<option value='utf8_slovak_ci' >Slovak</option>" .
227 "<option value='utf8_slovenian_ci' >Slovenian</option>" .
228 "<option value='utf8_spanish2_ci' >Spanish2 (Traditional)</option>" .
229 "<option value='utf8_spanish_ci' >Spanish (Modern)</option>" .
230 "<option value='utf8_swedish_ci' >Swedish</option>" .
231 "<option value='utf8_turkish_ci' >Turkish</option>" .
232 "<option value='utf8_unicode_ci' >Unicode (German, French, Russian, Armenian, Greek)</option>" .
233 "<option value='' >None (Do not force UTF-8)</option>" .
234 "</select>" .
235 "</TD></TR><TR VALIGN='TOP'><TD>&nbsp;</TD><TD colspan='2'><span class='text'>(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'.)</span><br></TD></TR>";
237 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
239 // Include a "source" site ID drop-list and a checkbox to indicate
240 // if cloning its database. When checked, do not display initial user
241 // and group stuff below.
242 $dh = opendir($OE_SITES_BASE);
243 if (!$dh) die("Cannot read directory '$OE_SITES_BASE'.");
244 $siteslist = array();
245 while (false !== ($sfname = readdir($dh))) {
246 if (substr($sfname, 0, 1) == '.') continue;
247 if ($sfname == 'CVS' ) continue;
248 if ($sfname == $site_id ) continue;
249 $sitedir = "$OE_SITES_BASE/$sfname";
250 if (!is_dir($sitedir) ) continue;
251 if (!is_file("$sitedir/sqlconf.php")) continue;
252 $siteslist[$sfname] = $sfname;
254 closedir($dh);
255 // If this is not the first site...
256 if (!empty($siteslist)) {
257 ksort($siteslist);
258 echo "<tr valign='top'>\n";
259 echo " <td class='text'>Source Site: </td>\n";
260 echo " <td class='text'><select name='source_site_id'>";
261 foreach ($siteslist as $sfname) {
262 echo "<option value='$sfname'";
263 if ($sfname == 'default') echo " selected";
264 echo ">$sfname</option>";
266 echo "</select></td>\n";
267 echo " <td class='text'>(The site directory that will be a model for the new site.)</td>\n";
268 echo "</tr>\n";
269 echo "<tr valign='top'>\n";
270 echo " <td class='text'>Clone Source Database: </td>\n";
271 echo " <td class='text'><input type='checkbox' name='clone_database' onclick='cloneClicked()' /></td>\n";
272 echo " <td class='text'>(Clone the source site's database instead of creating a fresh one.)</td>\n";
273 echo "</tr>\n";
276 echo "<TR VALIGN='TOP' class='noclone'><TD COLSPAN=2><font color='red'>OPENEMR USER:</font></TD></TR>";
277 echo "<TR VALIGN='TOP' class='noclone'><TD><span class='text'>Initial User:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='iuser' VALUE='admin'></TD><TD><span class='text'>(This is the login name of user that will be created for you. Limit this to one word.)</span></TD></TR>
278 <TR VALIGN='TOP' class='noclone'><TD><span class='text'>Initial User Password:</span></TD><TD><INPUT SIZE='30' TYPE='PASSWORD' NAME='iuserpass' VALUE=''></TD><TD><span class='text'>(This is the password for the initial user account above.)</span></TD></TR>
279 <TR VALIGN='TOP' class='noclone'><TD><span class='text'>Initial User's Name:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='iuname' VALUE='Administrator'></TD><TD><span class='text'>(This is the real name of the 'initial user'.)</span></TD></TR>
280 <TR VALIGN='TOP' class='noclone'><TD><span class='text'>Initial Group:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='igroup' VALUE='Default'></TD><TD><span class='text'>(This is the group that will be created for your users. This should be the name of your practice.)</span></TD></TR>
282 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
284 echo "</TABLE>
285 <br>
286 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
287 break;
289 case 3:
291 // Form Validation
292 // (applicable if not cloning from another database)
293 if (empty($installer->clone_database)) {
294 if ( ! $installer->login_is_valid() ) {
295 echo "ERROR. Please pick a proper 'Login Name'.<br>\n";
296 echo "Click Back in browser to re-enter.<br>\n";
297 break;
299 if ( ! $installer->iuser_is_valid() ) {
300 echo "ERROR. The 'Initial User' field can only contain one word and no spaces.<br>\n";
301 echo "Click Back in browser to re-enter.<br>\n";
302 break;
304 if ( ! $installer->user_password_is_valid() ) {
305 echo "ERROR. Please pick a proper 'Initial User Password'.<br>\n";
306 echo "Click Back in browser to re-enter.<br>\n";
307 break;
310 if ( ! $installer->password_is_valid() ) {
311 echo "ERROR. Please pick a proper 'Password'.<br>\n";
312 echo "Click Back in browser to re-enter.<br>\n";
313 break;
316 echo "<b>Step $state</b><br><br>\n";
317 echo "Configuring OpenEMR...<br><br>\n";
319 // Skip below if database shell has already been created.
320 if ($inst != 2) {
322 echo "Connecting to MySQL Server...\n";
323 flush();
324 if ( ! $installer->root_database_connection() ) {
325 echo "ERROR. Check your login credentials.\n";
326 echo $installer->error_message;
327 break;
329 else {
330 echo "OK.<br>\n";
331 flush();
335 // Only pertinent if cloning another installation database
336 if ( ! empty($installer->clone_database)) {
338 echo "Dumping source database...";
339 flush();
340 if ( ! $installer->create_dumpfiles() ) {
341 echo $installer->error_message;
342 break;
344 else {
345 echo " OK.<br>\n";
346 flush();
350 // Only pertinent if mirroring another installation directory
351 if ( ! empty($installer->source_site_id)) {
353 echo "Creating site directory...";
354 if ( ! $installer->create_site_directory() ) {
355 echo $installer->error_message;
356 break;
358 else {
359 echo "OK.<BR>";
360 flush();
364 // Skip below if database shell has already been created.
365 if ($inst != 2) {
366 echo "Creating database...\n";
367 flush();
368 if ( ! $installer->create_database() ) {
369 echo "ERROR. Check your login credentials.\n";
370 echo $installer->error_message;
371 break;
372 } else {
373 echo "OK.<br>\n";
374 flush();
377 echo "Creating user with permissions for database...\n";
378 flush();
379 if ( ! $installer->grant_privileges() ) {
380 echo "ERROR when granting privileges to the specified user.\n";
381 echo $installer->error_message;
382 break;
383 } else {
384 echo "OK.<br>\n";
385 flush();
388 echo "Reconnecting as new user...\n";
389 flush();
390 $installer->disconnect();
391 } else {
393 echo "Connecting to MySQL Server...\n";
395 if ( ! $installer->user_database_connection() ) {
396 echo "ERROR. Check your login credentials.\n";
397 echo $installer->error_message;
398 break;
400 else {
401 echo "OK.<br>\n";
402 flush();
405 // Load the database files
406 $dump_results = $installer->load_dumpfiles();
407 if ( ! $dump_results ) {
408 echo $installer->error_message;
409 break;
410 } else {
411 echo $dump_results;
412 flush();
415 echo "Writing SQL configuration...\n";
416 flush();
417 if ( ! $installer->write_configuration_file() ) {
418 echo $installer->error_message;
419 break;
421 else {
422 echo "OK.<br>\n";
423 flush();
426 // Only pertinent if not cloning another installation database
427 if (empty($installer->clone_database)) {
429 echo "Setting version indicators...\n";
430 flush();
431 if ( ! $installer->add_version_info() ) {
432 echo "ERROR.\n";
433 echo $installer->error_message;;
434 break;
436 else {
437 echo "OK<br>\n";
438 flush();
441 echo "Writing global configuration defaults...\n";
442 flush();
443 if ( ! $installer->insert_globals() ) {
444 echo "ERROR.\n";
445 echo $installer->error_message;;
446 break;
448 else {
449 echo "OK<br>\n";
450 flush();
453 echo "Adding Initial User...\n";
454 flush();
455 if ( ! $installer->add_initial_user() ) {
456 echo $installer->error_message;
457 break;
459 echo "OK<br>\n";
460 flush();
463 if ( ! empty($installer->clone_database) ) {
464 // Database was cloned, skip ACL setup.
465 echo "Click 'continue' for further instructions.";
466 $next_state = 7;
468 else {
469 echo "\n<br>Next step will install and configure access controls (php-GACL).<br>\n";
470 $next_state = 4;
473 echo "
474 <FORM METHOD='POST'>\n
475 <INPUT TYPE='HIDDEN' NAME='state' VALUE='$next_state'>
476 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
477 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>
478 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>
479 <INPUT TYPE='HIDDEN' NAME='iuname' VALUE='$installer->iuname'>
480 <INPUT TYPE='HIDDEN' NAME='clone_database' VALUE='$installer->clone_database'>
481 <br>\n
482 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
484 break;
485 case 4:
486 echo "<b>Step $state</b><br><br>\n";
487 echo "Installing and Configuring Access Controls (php-GACL)...<br><br>";
489 if ( ! $installer->install_gacl() ) {
490 echo $installer->error_message;
491 break;
493 else {
494 // display the status information for gacl setup
495 echo $installer->debug_message;
498 echo "Gave the '$installer->iuser' user (password is '$installer->iuserpass') administrator access.<br><br>";
500 echo "Done installing and configuring access controls (php-GACL).<br>";
501 echo "Next step will configure PHP.";
503 echo "<br><FORM METHOD='POST'>\n
504 <INPUT TYPE='HIDDEN' NAME='state' VALUE='5'>\n
505 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
506 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
507 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
508 <br>\n
509 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
511 break;
513 case 5:
514 echo "<b>Step $state</b><br><br>\n";
515 echo "Configuration of PHP...<br><br>\n";
516 echo "We recommend making the following changes to your PHP installation, which can normally be done by editing the php.ini configuration file:\n";
517 echo "<ul>";
518 $gotFileFlag = 0;
519 if (version_compare(PHP_VERSION, '5.2.4', '>=')) {
520 $phpINIfile = php_ini_loaded_file();
521 if ($phpINIfile) {
522 echo "<li><font color='green'>Your php.ini file can be found at ".$phpINIfile."</font></li>\n";
523 $gotFileFlag = 1;
526 echo "<li>To ensure proper functioning of OpenEMR you must make sure that settings in php.ini file include \"short_open_tag = On\", \"display_errors = Off\", \"register_globals = Off\", \"magic_quotes_gpc = On\", \"max_execution_time\" set to at least 60, \"max_input_time\" set to at least 90, \"post_max_size\" set to at least 30M, and \"memory_limit\" set to at least \"128M\".</li>\n";
527 echo "<li>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.</li>\n";
528 if (!$gotFileFlag) {
529 echo "<li>If you are having difficulty finding your php.ini file, then refer to the <a href='INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual for suggestions.</li>\n";
531 echo "</ul>";
533 echo "<br>We recommend you print these instructions for future reference.<br><br>";
534 echo "Next step will configure Apache web server.";
536 echo "<br><FORM METHOD='POST'>\n
537 <INPUT TYPE='HIDDEN' NAME='state' VALUE='6'>\n
538 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
539 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
540 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
541 <br>\n
542 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
544 break;
546 case 6:
547 echo "<b>Step $state</b><br><br>\n";
548 echo "Configuration of Apache web server...<br><br>\n";
549 echo "The \"".realpath($docsDirectory)."\", \"".realpath($billingDirectory)."\" and \"".realpath($billingDirectory2)."\" directories contain patient information, and
550 it is important to secure these directories. This can be done by placing pertinent .htaccess
551 files in these directories or by pasting the below to end of your apache configuration file:<br>
552 &nbsp;&nbsp;&lt;Directory ".realpath($docsDirectory)."&gt;<br>
553 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
554 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
555 &nbsp;&nbsp;&lt;/Directory&gt;<br>
556 &nbsp;&nbsp;&lt;Directory ".realpath($billingDirectory)."&gt;<br>
557 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
558 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
559 &nbsp;&nbsp;&lt;/Directory&gt;<br>
560 &nbsp;&nbsp;&lt;Directory ".realpath($billingDirectory2)."&gt;<br>
561 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
562 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
563 &nbsp;&nbsp;&lt;/Directory&gt;<br><br>";
565 echo "If you are having difficulty finding your apache configuration file, then refer to the <a href='INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual for suggestions.<br><br>\n";
566 echo "<br>We recommend you print these instructions for future reference.<br><br>";
567 echo "Click 'continue' for further instructions.";
569 echo "<br><FORM METHOD='POST'>\n
570 <INPUT TYPE='HIDDEN' NAME='state' VALUE='7'>\n
571 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
572 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
573 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
574 <br>\n
575 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
577 break;
579 case 0:
580 default:
581 echo "<p>Welcome to OpenEMR. This utility will step you through the installation and configuration of OpenEMR for your practice.</p>\n";
582 echo "<ul><li>Before proceeding, be sure that you have a properly installed and configured MySQL server available, and a PHP configured webserver.</li>\n";
584 echo "<li>Detailed installation instructions can be found in the <a href='INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.</li>\n";
586 Echo "<li>If you are upgrading from a previous version, do NOT use this script. Please read the 'Upgrading' section found in the <a href='INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.</li></ul>";
588 if ($checkPermissions) {
589 echo "<p>We will now ensure correct file and directory permissions before starting installation:</p>\n";
590 echo "<FONT COLOR='green'>Ensuring following files are world-writable...</FONT><br>\n";
591 $errorWritable = 0;
592 foreach ($writableFileList as $tempFile) {
593 if (is_writable($tempFile)) {
594 echo "'".realpath($tempFile)."' file is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
596 else {
597 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open file '".realpath($tempFile)."' for writing.<br>\n";
598 echo "(configure file permissions; see below for further instructions)</p>\n";
599 $errorWritable = 1;
602 if ($errorWritable) {
603 echo "<p><FONT COLOR='red'>You can't proceed until all above files are ready (world-writable).</FONT><br>\n";
604 echo "In linux, recommend changing file permissions with the 'chmod 666 filename' command.<br>\n";
605 echo "Fix above file permissions and then click the 'Check Again' button to re-check files.<br>\n";
606 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p>" .
607 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'></FORM><br>\n";
608 break;
611 echo "<br><FONT COLOR='green'>Ensuring following directories have proper permissions...</FONT><br>\n";
612 $errorWritable = 0;
613 foreach ($writableDirList as $tempDir) {
614 if (is_writable($tempDir)) {
615 echo "'".realpath($tempDir)."' directory is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
617 else {
618 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open directory '".realpath($tempDir)."' for writing by web server.<br>\n";
619 echo "(configure directory permissions; see below for further instructions)</p>\n";
620 $errorWritable = 1;
623 if ($errorWritable) {
624 echo "<p><FONT COLOR='red'>You can't proceed until all directories are ready.</FONT><br>\n";
625 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.<br>\n";
626 echo "Fix above directory permissions and then click the 'Check Again' button to re-check directories.<br>\n";
627 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p>" .
628 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'></FORM><br>\n";
629 break;
632 echo "<br>All required files and directories have been verified. Click to continue installation.<br>\n";
634 else {
635 echo "<br>Click to continue installation.<br>\n";
638 echo "<FORM METHOD='POST'><INPUT TYPE='HIDDEN' NAME='state' VALUE='1'>" .
639 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>" .
640 "<INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
646 </span>
648 </BODY>
649 </HTML>