function roudncube_save()
{
    $ou = $_GET["ou"];
    $roundcube = new roundcube($ou);
    $roundcube->roundcubeWebsites[$ou]["servername"] = $_GET["roundcubeservername"];
    $roundcube->Save();
    $sock = new sockets();
    $sock->getfile('ApacheGroupWareRestart');
}
function ROUNDCUBE_INSTALL($servername, $root, $hash = array())
{
    $srcfolder = ROUNDCUBE_SRC_FOLDER();
    $sock = new sockets();
    $ldap = new clladp();
    $EnablePostfixMultiInstance = $sock->GET_INFO("EnablePostfixMultiInstance");
    $RC_VERSION = RC_VERSION($root);
    $RC_VERSION_EX = explode(".", $RC_VERSION);
    $MAJOR = intval($RC_VERSION[0]);
    echo "Starting......: " . date("H:i:s") . " Roundcube {$servername} v{$RC_VERSION} Major {$MAJOR}\n";
    $GLOBALS["ADDLOG"] = "{$GLOBALS["ARTICALOGDIR"]}/{$servername}.log";
    if ($root == null) {
        events("Starting install roundcube Unable to stat root dir");
        return false;
    }
    if (!is_dir($srcfolder)) {
        events("Starting install roundcube Unable to stat SRC");
        return false;
    }
    $sql_file = "{$srcfolder}/SQL/mysql.initial.sql";
    if (!is_file($sql_file)) {
        events("Starting install roundcube Unable to stat {$srcfolder}");
        return false;
    }
    $user = $hash["wwwmysqluser"][0];
    $mysql_password = $hash[strtolower("WWWMysqlPassword")][0];
    $server_database = str_replace(".", "_", $servername);
    $server_database = str_replace("-", "_", $server_database);
    events("Starting install roundcube sub-system mysql database {$server_database}...");
    if ($user == null) {
        events("Starting install roundcube Unable to stat Mysql username");
        return false;
    }
    if ($mysql_password == null) {
        events("Starting install roundcube Unable to stat Mysql password");
        return false;
    }
    @mkdir($root, 0755, true);
    events("Starting install roundcube sub-system mysql database {$server_database}...");
    $q = new mysql();
    $q->CREATE_DATABASE($server_database);
    if (!$q->DATABASE_EXISTS($server_database)) {
        events("Starting install roundcube unable to create MYSQL Database");
        return false;
    }
    events("Starting setting permissions on Database with user {$user}");
    echo "Starting......: " . date("H:i:s") . " Roundcube {$servername} set permissions on Database with user {$user}\n";
    $q->PRIVILEGES($user, $mysql_password, $server_database);
    events("Starting install roundcube installing source code");
    echo "Starting......: " . date("H:i:s") . " Roundcube {$servername} installing source code\n";
    shell_exec("/bin/rm -rf {$root}/*");
    shell_exec("/bin/cp -rf {$srcfolder}/* {$root}/");
    if ($q->mysql_password != null) {
        $password = "******";
    } else {
        events("Starting install roundcube installing tables datas with null password");
    }
    $files[] = $sql_file;
    $files[] = "{$srcfolder}/SQL/mysql.update.sql";
    while (list($num, $line) = each($files)) {
        events("Starting install roundcube installing tables {$server_database}/{$num}");
        $cmd = "mysql --port={$q->mysql_port} --skip-column-names --database={$server_database} --silent --xml ";
        $cmd = $cmd . " --user={$q->mysql_admin}{$password} <{$line}";
        shell_exec($cmd);
        events("Starting install roundcube installing datas {$server_database}/{$num}");
        $cmd = "mysql --port={$q->mysql_port} --skip-column-names --database={$server_database} --silent --xml ";
        $cmd = $cmd . " --user={$q->mysql_admin}{$password} <{$sql_datas}";
        shell_exec($cmd);
    }
    if (is_file("{$root}/plugins/subscriptions_option/subscriptions_option.php")) {
        $subscriptions_option = 1;
    }
    $q->checkRoundCubeTables($server_database);
    $conf[] = "<?php";
    $conf[] = "\$rcmail_config = array();";
    $conf[] = "\$rcmail_config[\"db_dsnw\"] = \"mysql://{$q->mysql_admin}:{$q->mysql_password}@{$q->mysql_server}/{$server_database}\";";
    $conf[] = "\$rcmail_config[\"db_dsnr\"] = \"\";";
    $conf[] = "\$rcmail_config[\"db_max_length\"] = 512000;  // 500K";
    $conf[] = "\$rcmail_config[\"db_persistent\"] = FALSE;";
    $conf[] = "\$rcmail_config[\"db_table_users\"] = \"users\";";
    $conf[] = "\$rcmail_config[\"db_table_identities\"] = \"identities\";";
    $conf[] = "\$rcmail_config[\"db_table_contacts\"] = \"contacts\";";
    $conf[] = "\$rcmail_config[\"db_table_session\"] = \"session\";";
    $conf[] = "\$rcmail_config[\"db_table_cache\"] = \"cache\";";
    $conf[] = "\$rcmail_config[\"db_table_messages\"] = \"messages\";";
    $conf[] = "\$rcmail_config[\"db_sequence_users\"] = \"user_ids\";";
    $conf[] = "\$rcmail_config[\"db_sequence_identities\"] = \"identity_ids\";";
    $conf[] = "\$rcmail_config[\"db_sequence_contacts\"] = \"contact_ids\";";
    $conf[] = "\$rcmail_config[\"db_sequence_cache\"] = \"cache_ids\";";
    $conf[] = "\$rcmail_config[\"db_sequence_messages\"] = \"message_ids\";";
    $conf[] = "?>";
    events("Starting install roundcube saving {$root}/config/db.inc.php");
    echo "Starting......: " . date("H:i:s") . " Roundcube {$servername} db.inc.php OK\n";
    @file_put_contents("{$root}/config/db.inc.php", @implode("\n", $conf));
    unset($conf);
    $wwwmultismtpsender = $hash["wwwmultismtpsender"][0];
    $WWWEnableAddressBook = $hash["wwwenableaddressbook"][0];
    events("OU={$hash["OU"][0]} EnablePostfixMultiInstance={$EnablePostfixMultiInstance}, SMTP={$wwwmultismtpsender}");
    $conf[] = "<?php";
    $conf[] = "\$rcmail_config = array();";
    $conf[] = "\$rcmail_config['debug_level'] =1;";
    $conf[] = "\$rcmail_config['enable_caching'] = TRUE;";
    $conf[] = "\$rcmail_config['message_cache_lifetime'] = '10d';";
    $conf[] = "\$rcmail_config['auto_create_user'] = TRUE;";
    $conf[] = "\$rcmail_config['default_host'] = '127.0.0.1';";
    $conf[] = "\$rcmail_config['default_port'] = 143;";
    if ($EnablePostfixMultiInstance == 1) {
        if (trim($wwwmultismtpsender) != null) {
            $conf[] = "// SMTP server used for sending mails.";
            $conf[] = "\$rcmail_config['smtp_server'] = '{$wwwmultismtpsender}';";
            $conf[] = "\$rcmail_config['smtp_port'] = 25;";
        }
    } else {
        $conf[] = "\$rcmail_config['smtp_server'] = '127.0.0.1';";
        $conf[] = "\$rcmail_config['smtp_port'] = 25;";
    }
    $conf[] = "\$rcmail_config['smtp_user'] = '';";
    $conf[] = "\$rcmail_config['smtp_pass'] = '';";
    $conf[] = "\$rcmail_config['smtp_auth_type'] = '';";
    $conf[] = "\$rcmail_config['smtp_helo_host'] = '';";
    $conf[] = "\$rcmail_config['smtp_log'] = TRUE;";
    $conf[] = "\$rcmail_config['username_domain'] = '';";
    $conf[] = "\$rcmail_config['mail_domain'] = '';";
    $conf[] = "\$rcmail_config['virtuser_file'] = '';";
    $conf[] = "\$rcmail_config['virtuser_query'] = '';";
    $conf[] = "\$rcmail_config['list_cols'] = array('subject', 'from', 'date', 'size');";
    $conf[] = "\$rcmail_config['skin_path'] = 'skins/default/';";
    $conf[] = "\$rcmail_config['skin_include_php'] = FALSE;";
    $conf[] = "#LOGS";
    $conf[] = "\$rcmail_config['log_driver'] ='syslog';";
    $conf[] = "\$rcmail_config['syslog_id'] = 'roundcube-{$servername}';";
    $conf[] = "\$rcmail_config['temp_dir'] = 'temp/';";
    $conf[] = "\$rcmail_config['log_dir'] = 'logs/';";
    $conf[] = "\$rcmail_config['session_lifetime'] = 10;";
    $conf[] = "\$rcmail_config['ip_check'] = false;";
    $conf[] = "\$rcmail_config['double_auth'] = false;";
    $conf[] = "\$rcmail_config['des_key'] = 'NIbXC7RaFsZvQTV5NWBbQd9H';";
    $conf[] = "\$rcmail_config['locale_string'] = 'us';";
    $conf[] = "\$rcmail_config['date_short'] = 'D H:i';";
    $conf[] = "\$rcmail_config['date_long'] = 'd.m.Y H:i';";
    $conf[] = "\$rcmail_config['date_today'] = 'H:i';";
    $conf[] = "\$rcmail_config['useragent'] = 'RoundCube Webmail/0.1-rc2';";
    $conf[] = "\$rcmail_config['product_name'] = 'RoundCube Webmail for {$hash["OU"][0]}';";
    $conf[] = "\$rcmail_config['imap_root'] = null;";
    $conf[] = "\$rcmail_config['drafts_mbox'] = 'Drafts';";
    $conf[] = "\$rcmail_config['junk_mbox'] = 'Junk';";
    $conf[] = "\$rcmail_config['sent_mbox'] = 'Sent';";
    $conf[] = "\$rcmail_config['trash_mbox'] = 'Trash';";
    $conf[] = "\$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash');";
    $conf[] = "\$rcmail_config['protect_default_folders'] = TRUE;";
    $conf[] = "\$rcmail_config['skip_deleted'] = TRUE;";
    $conf[] = "\$rcmail_config['read_when_deleted'] = TRUE;";
    $conf[] = "\$rcmail_config['flag_for_deletion'] = TRUE;";
    $conf[] = "\$rcmail_config['enable_spellcheck'] = TRUE;";
    $conf[] = "\$rcmail_config['spellcheck_uri'] = '';";
    $conf[] = "\$rcmail_config['spellcheck_languages'] = NULL;";
    $conf[] = "\$rcmail_config['generic_message_footer'] = '';";
    $conf[] = "\$rcmail_config['mail_header_delimiter'] = NULL;";
    $conf[] = "";
    if ($WWWEnableAddressBook == 1) {
        $conf[] = "\$rcmail_config['ldap_public']['{$hash["OU"][0]}'] = array(";
        $conf[] = "\t'name'          => '{$hash["OU"][0]}',";
        $conf[] = "\t'hosts'         => array('{$ldap->ldap_host}'),";
        $conf[] = "\t'port'          => {$ldap->ldap_port},";
        $conf[] = "\t'base_dn'       => 'ou={$hash["OU"][0]},dc=organizations,{$ldap->suffix}',";
        $conf[] = "\t'bind_dn'       => 'cn={$ldap->ldap_admin},{$ldap->suffix}',";
        $conf[] = "\t'bind_pass'     => '{$ldap->ldap_password}',";
        $conf[] = "\t'ldap_version'  => 3,       // using LDAPv3";
        $conf[] = "\t'search_fields' => array('mail', 'cn','uid','givenName','DisplayName'),  // fields to search in";
        $conf[] = "\t'name_field'    => 'cn',    // this field represents the contact's name";
        $conf[] = "\t'email_field'   => 'mail',  // this field represents the contact's e-mail";
        $conf[] = "\t'surname_field' => 'sn',    // this field represents the contact's last name";
        $conf[] = "\t'firstname_field' => 'gn',  // this field represents the contact's first name";
        $conf[] = "\t'scope'         => 'sub',   // search mode: sub|base|list";
        $conf[] = "\t'LDAP_Object_Classes' => array( 'person', 'inetOrgPerson', 'userAccount'),";
        $conf[] = "\t'filter'        => 'givenName=*',      // used for basic listing (if not empty) and will be &'d with search queries. ex: (status=act)";
        $conf[] = "\t'fuzzy_search'  => true);   // server allows wildcard search";
    }
    $conf[] = "// enable composing html formatted messages (experimental)";
    $conf[] = "\$rcmail_config['enable_htmleditor'] = TRUE;";
    $conf[] = "\$rcmail_config['dont_override'] =array('index_sort','trash_mbox','sent_mbox','junk_mbox','drafts_mbox','subscriptions_option');";
    $conf[] = "\$rcmail_config['javascript_config'] = array('read_when_deleted', 'flag_for_deletion');";
    $conf[] = "\$rcmail_config['include_host_config'] = FALSE;";
    $conf[] = "";
    $conf[] = "";
    $conf[] = "/***** these settings can be overwritten by user's preferences *****/";
    $conf[] = "";
    $conf[] = "// show up to X items in list view";
    $conf[] = "\$rcmail_config['pagesize'] = 40;";
    $conf[] = "";
    $conf[] = "// use this timezone to display date/time";
    $conf[] = "\$rcmail_config['timezone'] = intval(date('O'))/100 - date('I');";
    $conf[] = "";
    $conf[] = "// is daylight saving On?";
    $conf[] = "\$rcmail_config['dst_active'] = (bool)date('I');";
    $conf[] = "";
    $conf[] = "// prefer displaying HTML messages";
    $conf[] = "\$rcmail_config['prefer_html'] = TRUE;";
    $conf[] = "";
    $conf[] = "// show pretty dates as standard";
    $conf[] = "\$rcmail_config['prettydate'] = TRUE;";
    $conf[] = "";
    $conf[] = "// default sort col";
    $conf[] = "\$rcmail_config['message_sort_col'] = 'date';";
    $conf[] = "";
    $conf[] = "// default sort order";
    $conf[] = "\$rcmail_config['message_sort_order'] = 'DESC';";
    $conf[] = "";
    $conf[] = "// save compose message every 300 seconds (5min)";
    $conf[] = "\$rcmail_config['draft_autosave'] = 300;";
    $conf[] = "";
    $conf[] = "/***** PLUGINS for Roundcube V3 *****/";
    $conf[] = "\$rcmail_config['plugins'] = array();";
    ROUNDCUBE_CONTEXTMENU($root);
    if (is_file("{$root}/plugins/contextmenu/contextmenu.php")) {
        $conf[] = "\$rcmail_config['plugins'][] = 'contextmenu';";
    }
    if ($subscriptions_option == 1) {
        $conf[] = "\$rcmail_config['plugins'][] = 'subscriptions_option';";
    }
    $NAB = new roundcube_globaladdressbook($servername);
    if ($NAB->enabled == 1) {
        ROUNDCUBE_GLOBALADDRESSBOOK();
        if (is_file("{$root}/plugins/globaladdressbook/globaladdressbook.php")) {
            echo "Starting......: " . date("H:i:s") . " Roundcube {$servername} Enable Global AddressBook \n";
            $conf[] = "\$rcmail_config['plugins'][] = 'globaladdressbook';";
            $nab_conf = $NAB->BuildConfig();
            @file_put_contents("{$root}/plugins/globaladdressbook/config.inc.php", $nab_conf);
            shell_exec("/bin/chmod -R 770 {$root}/plugins/globaladdressbook");
            shell_exec("/bin/chmod 660 {$root}/plugins/globaladdressbook/*.php");
            chmod("{$root}/plugins/globaladdressbook/config.inc.php", 0755);
        }
    }
    $roundcube_class = new roundcube();
    $roundcube_class->root_path = $root;
    if ($MAJOR < 1) {
        if (!is_file("{$root}/plugins/msglistcols/msglistcols.php")) {
            $roundcube_class->plugin_install($root, "msglistcols");
        }
        if (!is_file("{$root}/plugins/sticky_notes/sticky_notes.php")) {
            $roundcube_class->plugin_install($root, "sticky_notes");
        }
        if (!is_file("{$root}/plugins/jqueryui/jqueryui.php")) {
            $roundcube_class->plugin_install($root, "jqueryui");
        }
        if (!is_file("{$root}/plugins/dkimstatus/dkimstatus.php")) {
            $roundcube_class->plugin_install($root, "dkimstatus");
        }
        if (!is_file("{$root}/plugins/fail2ban/fail2ban.php")) {
            $roundcube_class->plugin_install($root, "fail2ban");
        }
        if (is_file("{$root}/plugins/msglistcols/msglistcols.php")) {
            $conf[] = "\$rcmail_config['plugins'][] = 'msglistcols';";
        }
        if (is_file("{$root}/plugins/dkimstatus/dkimstatus.php")) {
            $conf[] = "\$rcmail_config['plugins'][] = 'dkimstatus';";
        }
        //if(is_file("$root/plugins/fail2ban/fail2ban.php")){$conf[]="\$rcmail_config['plugins'][] = 'fail2ban';";}
        if ($roundcube_class->plugin_password($root, $hash["OU"][0])) {
            if (is_file("{$root}/plugins/dkimstatus/dkimstatus.php")) {
                $conf[] = "\$rcmail_config['plugins'][] = 'password';";
            }
        }
        if (is_file("{$root}/plugins/jqueryui/jqueryui.php")) {
            $conf[] = "\$rcmail_config['plugins'][] = 'jqueryui';";
            $roundcube_class->plugin_jqueryui($root);
            if (is_file("{$root}/plugins/sticky_notes/sticky_notes.php")) {
                $conf[] = "\$rcmail_config['plugins'][] = 'sticky_notes';";
            }
        }
    }
    $roundcube_class->db_inc_php();
    $conf[] = "";
    $conf[] = "";
    $conf[] = "// don't let users set pagesize to more than this value if set";
    $conf[] = "\$rcmail_config['max_pagesize'] = 200;";
    $conf[] = "\$rcmail_config['create_default_folders'] = TRUE;";
    $conf[] = "";
    $conf[] = "";
    $conf[] = "// end of config file";
    $conf[] = "?>";
    @file_put_contents("{$root}/config/main.inc.php", @implode("\n", $conf));
    $sock = new sockets();
    $EnablePostfixMultiInstance = $sock->GET_INFO("EnablePostfixMultiInstance");
    if ($EnablePostfixMultiInstance == 1) {
        echo "Starting......: " . date("H:i:s") . " Roundcube {$servername} Postfix Multi Instance Enabled \n";
        $smtp = $hash[strtolower("WWWMultiSMTPSender")][0];
        $tbl = @explode("\n", @file_get_contents("{$root}/config/main.inc.php"));
        while (list($i, $line) = each($tbl)) {
            if (preg_match("#rcmail_config.+?smtp_server#", $line)) {
                echo "Starting......: " . date("H:i:s") . " Roundcube {$servername} Postfix change line {$i} to {$smtp}\n";
                $tbl[$i] = "\$rcmail_config['smtp_server'] = '{$smtp}';";
            }
        }
        @file_put_contents("{$root}/config/main.inc.php", @implode("\n", $tbl));
    }
}
Beispiel #3
0
function main_save_roundcube_settings()
{
    $round = new roundcube();
    while (list($num, $line) = each($_GET)) {
        $round->roundCubeArray[$num] = $line;
    }
    $round->Save();
}
Beispiel #4
0
function APP_ROUNDCUBE()
{
    $round = new roundcube();
    $round->https_port = $_GET["APP_ROUNDCUBE"];
    $round->Save();
}
Beispiel #5
0
function build()
{
    $unix = new unix();
    $rm = $unix->find_program("rm");
    if (is_dir("/usr/share/roundcube/plugins/remember_me")) {
        shell_exec("{$rm} -rf /usr/share/roundcube/plugins/remember_me");
    }
    $r = new roundcube();
    $conf = $r->RoundCubeConfig();
    if (is_file("/var/log/lighttpd/roundcube-access.log")) {
        @unlink("/var/log/lighttpd/roundcube-access.log");
    }
    if (is_file("/var/log/lighttpd/roundcube-error.log")) {
        @unlink("/var/log/lighttpd/roundcube-error.log");
    }
    $users = new usersMenus();
    $roundcube_folder = $users->roundcube_folder;
    if (!@file_put_contents("{$roundcube_folder}/config/main.inc.php", $conf)) {
        echo "Starting......: Roundcube saving main.inc.php failed.\n";
    } else {
        echo "Starting......: Roundcube saving main.inc.php Success.\n";
    }
    echo "Starting......: Roundcube building main configuration done.\n";
    RoundCubeHacks();
}
Beispiel #6
0
function verifyTables()
{
    $mysqlfile = "/usr/share/roundcube/SQL/mysql.initial.sql";
    $mysqlupdatefile = "/usr/share/roundcube/SQL/mysql.update.sql";
    if (!is_file($mysqlfile)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [{$roundcube->database}] {$mysqlfile} no such file !!\n";
        }
        return null;
    }
    $q = new mysql();
    $users = new usersMenus();
    $f = RoundCubeMysqlTablesList();
    $unix = new unix();
    $mysqlbin = $unix->find_program("mysql");
    $roundcube = new roundcube();
    $cmdline = "{$mysqlbin} " . $roundcube->MYSQL_CMDLINES;
    $verif = true;
    while (list($num, $table) = each($f)) {
        if (!$roundcube->TABLE_EXISTS($table, $GLOBALS["MYSQL_DB"])) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [{$roundcube->database}] \"{$table}\" no such table\n";
            }
            $verif = false;
        }
    }
    if (!$verif) {
        $initial = $cmdline . " {$roundcube->database} < " . $mysqlfile;
        shell_exec($initial);
        if (is_file($mysqlupdatefile)) {
            $update = $cmdline . " {$roundcube->database} < {$mysqlupdatefile}";
            shell_exec($update);
        }
        return;
    }
    unset($f);
    $f[] = "contactgroupmembers";
    $f[] = "contactgroups";
    $verif = true;
    $roundcube = new roundcube();
    while (list($num, $table) = each($f)) {
        if (!$roundcube->TABLE_EXISTS($table)) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [{$roundcube->database}] \"{$table}\" no such table\n";
            }
            $verif = false;
        }
    }
    if (!$verif) {
        $update = $cmdline . " {$roundcube->database} < {$mysqlupdatefile}";
        $roundcube->QUERY_SQL($update, $GLOBALS["MYSQL_DB"]);
        shell_exec($update);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$update}\n";
        }
        return;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} DB: [{$roundcube->database}]: All are ok, nothing to do...\n";
    }
}
Beispiel #7
0
function build(){
	$r=new roundcube();
	$conf=$r->RoundCubeConfig();
	$users=new usersMenus();
	$roundcube_folder=$users->roundcube_folder;
	if(!@file_put_contents("$roundcube_folder/config/main.inc.php",$conf)){
		echo "Starting......: Roundcube saving main.inc.php failed.\n";
	}else{
		echo "Starting......: Roundcube saving main.inc.php Success.\n";
	}	
	
	echo "Starting......: Roundcube building main configuration done.\n";
	RoundCubeHacks();
}