From a84f9a81b9c9f58248e9a43594997ec4d27a07de Mon Sep 17 00:00:00 2001
From: Nicolas Rochelemagne <nicolas.rochelemagne@cpanel.net>
Date: Thu, 29 Mar 2012 11:26:03 -0500
Subject: [PATCH 3/9] update default config

---
 libs/Atmail/Config.php.default |   72 ++++++++++++++++++++++++++++++----------
 1 files changed, 54 insertions(+), 18 deletions(-)

diff --git a/libs/Atmail/Config.php.default b/libs/Atmail/Config.php.default
index 26cf7b0..ca7df44 100644
--- a/libs/Atmail/Config.php.default
+++ b/libs/Atmail/Config.php.default
@@ -1,4 +1,32 @@
 <?php
+$uid = posix_getuid();
+$user_info = posix_getpwuid($uid);
+$homedir = $user_info['dir'];
+$dbName = $homedir . '/etc/atmail/atmail.db';
+
+if (!file_exists($dbName)) {
+	include_once('/usr/local/cpanel/base/3rdparty/atmailopen/libs/PEAR/DB.php');
+
+	if ( !file_exists($homedir . "/etc/atmail/tmp") ) {
+		mkdir($homedir . "/etc/atmail/tmp", 0750, true);
+	}
+
+    $schema = '/usr/local/cpanel/base/3rdparty/atmailopen/install/atmail.sqlite';
+
+    $db = DB::connect("sqlite:///$dbName");
+
+    if (DB::isError($db)) {
+        $errors['db_connect_error'] = $db->getDebugInfo();
+    } else {
+        $query = file_get_contents($schema);
+        $res = sqlite_exec($query, $db->connection);
+        if ($res === false) {
+            $errors['table_create_error'] = sqlite_last_error($db->connection);
+            unlink($dbName);
+        }
+    }
+}
+
 
 $pref = array (
   'debug_sql' => 0,
@@ -33,7 +61,7 @@ You will be unable to receive or send any messages once you have exhausted your
   'filter_awl_purge_medium' => '14',
   'filter_awl_purge_low' => '7',
   'filter_uridns_support' => '1',
-  'openssl_path' => '/usr/bin/openssl',
+  'openssl_path' => '',
   'filter_spf_support' => '1',
   'smtpauth_password' => '',
   'smtpauth_username' => '',
@@ -45,7 +73,7 @@ You will be unable to receive or send any messages once you have exhausted your
   'debug_imap_file_size_limit' => 10000,
   'atmail_root' => '/mail',
   'memory_limit' => 128,
-  'error_log' => 'logs/error_log',
+  'error_log' => $homedir . '/etc/atmail/error_log',
   'smtp_max_rcpt' => '100',
   'ispell_german' => '',
   'imap_idle' => '60',
@@ -73,7 +101,7 @@ USER IS OVER THE QUOTA - The users email quota has exceeded. The message could n
   'Price' => '',
   'mail_group_support' => '1',
   'pop3_ip' => '0',
-  'allow_VideoMail' => '1',
+  'allow_VideoMail' => '0',
   'videomail_server' => 'video.atmail.com',
   'websync_permissions' => 'All Users',
   'imapfolder_cache' => '0',
@@ -82,7 +110,7 @@ USER IS OVER THE QUOTA - The users email quota has exceeded. The message could n
   'remote_max_parallel' => '20',
   'logo_big_img' => 'imgs/about.png',
   'allow_Language' => '1',
-  'mailserver_auth' => '1',
+  'mailserver_auth' => 0,
   'disclaimer' => 'html/disclaimer.html',
   'downloadid' => '',
   'allow_HtmlEditor' => '1',
@@ -95,7 +123,7 @@ USER IS OVER THE QUOTA - The users email quota has exceeded. The message could n
   'smtp_throttle' => '1',
   'ldap_chserver' => '1',
   'pallow_Country' => '1',
-  'install_type' => 'server',
+  'install_type' => 'standalone',
   'sql_host' => 'localhost',
   'allow_EmailEncoding' => 1,
   'version' => '1.05',
@@ -127,7 +155,7 @@ USER IS OVER THE QUOTA - The users email quota has exceeded. The message could n
   'filter_required_hits_reject' => '10',
   'filter_report_safe_enable' => '1',
   'ispell_catalan' => '',
-  'sql_table' => 'atmail',
+  'sql_table' => $dbName,
   'filter_bayes_min_ham_num' => '200',
   'smtp_type' => NULL,
   'allow_Mobile' => '1',
@@ -178,7 +206,7 @@ For additional information about the email service contact the Administrator $pr
   'IMAP' => '1',
   'pallow_City' => '1',
   'mailserver' => '',
-  'user_dir' => '/var/www/html/atmailopen',
+  'user_dir' => $homedir . '/etc/atmail',
   'GlobalAbook' => '0',
   'allow_DateFormat' => '1',
   'pallow_State' => '1',
@@ -194,7 +222,7 @@ For additional information about the email service contact the Administrator $pr
   'allow_DisplayImages' => '1',
   'allow_EmailForwarding' => '1',
   'timezone' => 'east',
-  'allow_Signup' => '1',
+  'allow_Signup' => 0,
   'install_size' => 'normal',
   'allow_TimeZone' => '1',
   'ispell_french' => '',
@@ -216,9 +244,9 @@ For additional information about the email service contact the Administrator $pr
   'ispell_russian' => '',
   'pop3_max' => '40',
   'allow_Advanced' => 1,
-  'sql_type' => 'mysql',
+  'sql_type' => 'sqlite',
   'smtp_auth' => '1',
-  'install_dir' => '',
+  'install_dir' => '/usr/local/cpanel/base/3rdparty/atmailopen',
   'filter_attach_check' => '1',
   'ldap_local' => NULL,
   'websync_enable_shared' => '1',
@@ -285,7 +313,7 @@ For additional information about the email service contact the Administrator $pr
 </table>
 </body></html>',
   'filter_required_hits' => '4',
-  'smtphost' => 'mail.iinet.net.au',
+  'smtphost' => 'localhost',
   'error_nouser' => 'Email Message Error -
 
 ********** Sorry, the message could not be delivered **********
@@ -302,7 +330,7 @@ For additional information about the email service contact the Administrator $pr
   'ispell_japanese' => '',
   'websync_log_support' => '1',
   'pallow_LastName' => '1',
-  'sql_user' => 'root',
+  'sql_user' => '',
   'allow_LDAP' => '0',
   'allow_LDAPsearch' => '0',
   'pop3_max_perip' => '5',
@@ -329,7 +357,7 @@ For additional information about the email service contact the Administrator $pr
   'aspell_dir' => '',
   'use_php_pspell' => 0,
   'imap_functions' => '',
-  'installed' => 0,
+  'installed' => 1,
   'log_purge_days' => '30',
   'filter_auto_dl_spam' => '1',
   'use_mailparse_ext' => NULL,
@@ -339,6 +367,18 @@ For additional information about the email service contact the Administrator $pr
 
 );
 
+if (is_executable('/usr/bin/gpg') ) {
+	$pref['gpg_path'] = '/usr/bin/gpg';
+} else if ( is_executable('/usr/local/bin/gpg') ) {
+	$pref['gpg_path'] = '/usr/local/bin/gpg';
+}
+
+if (is_executable('/usr/bin/aspell') ) {
+	$pref['aspell_path'] = '/usr/bin/aspell';
+} else if ( is_executable('/usr/local/bin/aspell') ) {
+	$pref['aspell_path'] = '/usr/local/bin/aspell';
+}
+
 $settings = array (
   'NewWindow' => '0',
   'VlinkColor' => '#000033',
@@ -402,11 +442,7 @@ $groups = array (
   )
 );
 
-$reg = array (
-  'serial' => '',
-  'expiry' => '',
-  'downloadid' => '',
-);
+$reg = NULL;
 
 $language = array (
   'english' => 'English',
-- 
1.7.5

