- /* Otherwise, report an error. */
- $errTitle = sprintf( _("Error opening %s"), $default_pref );
- if (!file_exists($default_pref)) {
- $errString = $errTitle . "<br>\n" .
- _("Default preference file not found!") . "<br>\n" .
- _("Please contact your system administrator and report this error.") . "<br>\n";
- include_once( '../functions/display_messages.php' );
- logout_error( $errString, $errTitle );
- exit;
- } else if (!@copy($default_pref, $filename)) {
- $user_data = posix_getpwuid(posix_getuid());
- $uid = $user_data['name'];
- $errString = $errTitle . '<br>' .
- _("Could not create initial preference file!") . "<br>\n" .
- sprintf( _("%s should be writable by user %s"), $data_dir, $uid ) .
- "<br>\n" . _("Please contact your system administrator and report this error.") . "<br>\n";
- include_once( '../functions/display_messages.php' );
+ /* If no legacies, check where we'd expect it to be located:
+ * under config/ */
+ if (!@file_exists($default_pref)) {
+ $default_pref = SM_PATH . 'config/default_pref';
+ }
+
+ /* If a default_pref file found, try to copy it, if none found,
+ * try to create an empty one. If that fails, report an error.
+ */
+ if (
+ ( is_readable($default_pref) && !@copy($default_pref, $filename) ) ||
+ !@touch($filename)
+ ) {
+ $uid = 'that the web server is running as';
+ if (function_exists('posix_getuid')){
+ $user_data = posix_getpwuid(posix_getuid());
+ $uid = $user_data['name'];
+ }
+ $errTitle = _("Could not create initial preference file!");
+ $errString = $errTitle . "\n" .
+ sprintf( _("%s should be writable by the user %s."), $data_dir, $uid ) . "\n" .
+ _("Please contact your system administrator and report this error.") ;