コード例 #1
0
function reset2()
{
    system("clear");
    echo "Remove databases\n";
    $q = new mysql();
    echo "Remove database settings\n";
    $q->DELETE_DATABASE("artica_backup");
    echo "Remove database events\n";
    $q->DELETE_DATABASE("artica_events");
    echo "Remove database Proxy\n";
    $q = new mysql_squid_builder();
    $q->QUERY_SQL("DROP DATABASE `squidlogs`");
    echo "Remove Artica settings Proxy\n";
    $unix = new unix();
    $files = $unix->DirFiles("/etc/artica-postfix/settings/Daemons");
    while (list($filename, $value) = each($files)) {
        $fulename = "/etc/artica-postfix/settings/Daemons/{$filename}";
        echo "Removing {$filename}\n";
        @unlink($fulename);
    }
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/ProxyUseArticaDB", 1);
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/StatsPerfsSquidAnswered", 1);
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/CacheManagement2", 1);
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnablePHPFPM", 0);
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnableArticaFrontEndToNGninx", 0);
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnableArticaFrontEndToApache", 1);
    @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnableNginx", 0);
    echo "Restarting Web Console...\n";
    system('/etc/init.d/artica-webconsole restart');
    system("clear");
    echo "All data has been erased..\n";
    echo "Type Enter key to exit\n";
    $answer = trim(strtolower(fgets(STDIN)));
    die;
}
コード例 #2
0
function removedatabase()
{
    $q = new mysql();
    if (!$q->DATABASE_EXISTS("ocsweb")) {
        $q->DELETE_DATABASE("ocsweb");
    }
}
コード例 #3
0
function removedb()
{
    $q = new mysql();
    $q->DELETE_DATABASE("zarafa");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    $sock->getFrameWork("zarafa.php?removeidb=yes");
    $sock->getFrameWork("cmd.php?zarafa-restart-server=yes");
}
コード例 #4
0
function CheckUninstall()
{
    $sql = "SELECT * FROM joomla_users WHERE install=-1";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    $q = new mysql();
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        unset($arrayconfig);
        $GLOBALS["joom_servername"] = $ligne["servername"];
        set_status('{checking}');
        $q->DELETE_DATABASE($ligne["databasename"]);
        DeleteMysqlAdmin($ligne["databasename"]);
        $u = new user($uid);
        $arrayconfig["password"] = $u->password;
        $root = $u->homeDirectory . "/www/{$ligne["servername"]}";
        $arrayconfig["root"] = $root;
        shell_exec("/bin/rm -rf {$root} >/dev/null 2>&1");
        $sql = "DELETE FROM joomla_users WHERE servername='{$GLOBALS["joom_servername"]}'";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    shell_exec("/usr/share/artica-postfix/bin/artica-install --reload-apache-groupware");
}
コード例 #5
0
ファイル: exec.wordpress.php プロジェクト: brucewu16899/1.6.x
function duplicate_wordpress($servername)
{
    $unix = new unix();
    $q = new mysql();
    $free = new freeweb($servername);
    $WORKING_DIRECTORY = $free->www_dir;
    if ($free->groupware_duplicate == null) {
        build_progress("{$servername}: {duplicate} {$servername} no duplicate set...", 42);
        sleep(2);
        return false;
    }
    $free2 = new freeweb($free->groupware_duplicate);
    if ($free2->mysql_database == null) {
        echo "Fatal: {$free->groupware_duplicate} did not have any such DB set, try to find it..\n";
        $free2->mysql_database = $free2->CreateDatabaseName();
        echo "Fatal: {$free->groupware_duplicate} = {$free2->mysql_database}\n";
    }
    if (!$q->DATABASE_EXISTS($free2->mysql_database, true)) {
        build_progress("{$servername}: {duplicate} {$free->groupware_duplicate} did not have any database...", 42);
        sleep(2);
        return false;
    }
    $srcdir = $free2->www_dir;
    $Mysqlpassword = null;
    $cp = $unix->find_program("cp");
    $rm = $unix->find_program("rm");
    if (@is_link($WORKING_DIRECTORY)) {
        $WORKING_DIRECTORY = @readlink($WORKING_DIRECTORY);
    }
    if (is_dir($WORKING_DIRECTORY)) {
        build_progress("{$servername}: {removing} {$WORKING_DIRECTORY}...", 42);
        sleep(2);
        shell_exec("{$rm} -rf {$WORKING_DIRECTORY}/*");
    }
    @mkdir($WORKING_DIRECTORY, 0755, true);
    build_progress("{$servername}: {installing} {from} {$srcdir}...", 42);
    shell_exec("{$cp} -rf {$srcdir}/* {$WORKING_DIRECTORY}/");
    $wordpressDB = $free->mysql_database;
    if ($wordpressDB == null) {
        $wordpressDB = $free->CreateDatabaseName();
    }
    if ($q->DATABASE_EXISTS($wordpressDB)) {
        build_progress("{$servername}: {remove_database} {$wordpressDB}...", 42);
        sleep(2);
        if (!$q->DELETE_DATABASE($wordpressDB)) {
            build_progress("{$servername}: {remove_database} {$wordpressDB} {failed}...", 42);
            return false;
        }
        if (!$q->CREATE_DATABASE($wordpressDB, true)) {
            build_progress("{$servername}: {create_database} {$wordpressDB} {failed}...", 42);
            return false;
        }
    }
    if (!$q->DATABASE_EXISTS($wordpressDB)) {
        if (!$q->CREATE_DATABASE($wordpressDB, true)) {
            build_progress("{$servername}: {create_database} {$wordpressDB} {failed}...", 42);
            return false;
        }
    }
    build_progress("{$servername}: {backup_database} {from} {$free2->mysql_database}...", 42);
    $mysqldump = $unix->find_program("mysqldump");
    $q = new mysql();
    if ($q->mysql_password != null) {
        $Mysqlpassword = "******" . $unix->shellEscapeChars($q->mysql_password);
    }
    $t = time();
    $TMP_FILE = $unix->FILE_TEMP();
    $cmdline = trim("{$mysqldump} --add-drop-table --single-transaction --force --insert-ignore -S /var/run/mysqld/mysqld.sock -u {$q->mysql_admin}{$Mysqlpassword} {$free2->mysql_database} >{$TMP_FILE} 2>&1");
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmdline}\n";
    }
    $results = array();
    exec($cmdline, $results);
    while (list($num, $ligne) = each($results)) {
        echo "{$ligne}\n";
        if (preg_match("#ERROR\\s+([0-9]+)#", $ligne)) {
            build_progress("{$servername}: {restore_database} {to} {$wordpressDB} {failed}..", 42);
            sleep(3);
            return false;
        }
    }
    build_progress("{$servername}: {restore_database} {to} {$wordpressDB}..", 42);
    $mysqlbin = $unix->find_program("mysql");
    $cmd = "{$mysqlbin} --batch --force -S /var/run/mysqld/mysqld.sock -u {$q->mysql_admin}{$Mysqlpassword} --database={$wordpressDB} <{$TMP_FILE} 2>&1";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmd}\n";
    }
    exec($cmd, $results);
    while (list($num, $ligne) = each($results)) {
        echo "{$ligne}\n";
        if (preg_match("#ERROR\\s+([0-9]+)#", $ligne)) {
            build_progress("{$servername}: {restore_database} {to} {$wordpressDB} {failed}..", 42);
            sleep(3);
            return false;
        }
    }
    build_progress("{$servername}: {restore_database} {to} {$wordpressDB}..{done}", 42);
    @unlink($TMP_FILE);
    if (!scan($WORKING_DIRECTORY)) {
        build_progress("{$servername}: {install} {failed}", 42);
        sleep(3);
        return false;
    }
    $proto = "http";
    if ($free->useSSL == 1) {
        $proto = "https";
    }
    $sql = "UPDATE `wp_options` SET `option_value`='{$proto}://{$servername}' WHERE `option_name`='siteurl'";
    $q->QUERY_SQL($sql, $wordpressDB);
    if (!$q->ok) {
        echo $q->mysql_error;
        build_progress("{$servername}: {install} {failed}", 42);
        sleep(3);
        return false;
    }
    $sql = "UPDATE `wp_options` SET `option_value`='{$proto}://{$servername}' WHERE `option_name`='home'";
    $q->QUERY_SQL($sql, $wordpressDB);
    if (!$q->ok) {
        echo $q->mysql_error;
        build_progress("{$servername}: {install} {failed}", 42);
        sleep(3);
        return false;
    }
    $free->groupware_duplicate = null;
    $free->CreateSite(true);
    return true;
}
コード例 #6
0
 public function writeconfigfile()
 {
     $unix = new unix();
     $q = new mysql();
     $firstinstall = false;
     if ($this->rebuildb) {
         writelogs("[{$this->servername}] DELETE_DATABASE", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
         $q->DELETE_DATABASE($this->database, true);
         writelogs("[{$this->servername}] CREATE_DATABASE", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
         $q = new mysql();
         $q->CREATE_DATABASE($this->database, true);
     }
     if ($GLOBALS["REINSTALL"]) {
         $q->DELETE_DATABASE($this->database);
         $q->CREATE_DATABASE($this->database, true);
     }
     if (!$q->DATABASE_EXISTS($this->database)) {
         writelogs("[{$this->servername}] DATABASE DOES NOT EXISTS Create e new one", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
         echo "Starting......: " . date("H:i:s") . " Apache \"{$this->servername}\" create database {$this->database}\n";
         $q->CREATE_DATABASE($this->database, true);
     } else {
         echo "Starting......: " . date("H:i:s") . " Apache \"{$this->servername}\" create {$this->database} OK\n";
     }
     if (!$q->DATABASE_EXISTS($this->database)) {
         echo "Starting......: " . date("H:i:s") . " Apache \"{$this->servername}\" create database {$this->database} FAILED\n";
     }
     if (!$this->testtables()) {
         $mysql = $unix->find_program("mysql");
         if (is_file("{$this->www_dir}/install/sql/groupoffice.sql")) {
             $cmd = "{$mysql} -u {$q->mysql_admin} -p\"{$q->mysql_password}\" --batch --database={$this->database} < {$this->www_dir}/install/sql/groupoffice.sql";
             writelogs("[{$this->servername}] \"{$this->servername}\" Creating tables....", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
             writelogs("[{$this->servername}] {$cmd}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
             echo "Starting......: " . date("H:i:s") . " Apache {$cmd}\n";
             exec($cmd, $talesexec);
             while (list($num, ) = each($talesexec)) {
                 writelogs("[{$this->servername}] \"{$this->servername}\" {$ligne}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
             }
             if (!$this->testtables()) {
                 writelogs("[{$this->servername}] \"{$this->servername}\" Creating tables FAILED", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
                 $firstinstall = true;
             }
         } else {
             writelogs("[{$this->servername}] \"{$this->servername}\" {$this->www_dir}/install/sql/groupoffice.sql no such file !!!!!", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
         }
     } else {
         writelogs("[{$this->servername}] \"{$this->servername}\" {$ligne} tables OK", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
     }
     if ($q->mysql_server == "localhost") {
         $q->mysql_server = "127.0.0.1";
     }
     $gpoffice[] = "<?php";
     $gpoffice[] = "\$config['enabled']=true;";
     $gpoffice[] = "\$config['id']=\"groupoffice\";";
     $gpoffice[] = "\$config['debug']=false;";
     $gpoffice[] = "\$config['debug_log']=false;";
     $gpoffice[] = "\$config['info_log']=\"/home/{$this->servername}/log/info.log\";";
     $gpoffice[] = "\$config['debug_display_errors']=False;";
     $gpoffice[] = "\$config['log']=True;";
     $gpoffice[] = "\$config['language']=\"en\";";
     $gpoffice[] = "\$config['default_country']=\"NL\";";
     $gpoffice[] = "\$config['default_timezone']=\"Europe/Berlin\";";
     $gpoffice[] = "\$config['default_currency']=\"€\";";
     $gpoffice[] = "\$config['default_date_format']=\"dmY\";";
     $gpoffice[] = "\$config['default_date_separator']=\"-\";";
     $gpoffice[] = "\$config['default_time_format']=\"G:i\";";
     $gpoffice[] = "\$config['default_sort_name']=\"last_name\";";
     $gpoffice[] = "\$config['default_first_weekday']=\"1\";";
     $gpoffice[] = "\$config['default_decimal_separator']=\",\";";
     $gpoffice[] = "\$config['default_thousands_separator']=\".\";";
     $gpoffice[] = "\$config['theme']=\"Default\";";
     $gpoffice[] = "\$config['allow_themes']=true;";
     $gpoffice[] = "\$config['allow_password_change']=true;";
     $gpoffice[] = "\$config['allow_profile_edit']=true;";
     $gpoffice[] = "\$config['allow_registration']=false;";
     $gpoffice[] = "\$config['registration_fields']=\"title_initials,sex,birthday,address,home_phone,fax,cellular,company,department,function,work_address,work_phone,work_fax,homepage\";";
     $gpoffice[] = "\$config['required_registration_fields']=\"company,address\";";
     $gpoffice[] = "\$config['allow_duplicate_email']=false;";
     $gpoffice[] = "\$config['auto_activate_accounts']=false;";
     $gpoffice[] = "\$config['notify_admin_of_registration']=true;";
     $gpoffice[] = "\$config['register_modules_read']=\"summary,email,calendar,tasks,addressbook,files,notes,emailportlet,log,dav,tools,settings,groups,links,blacklist,mailings,bookmarks,sieve,comments,users,search,modules\";";
     $gpoffice[] = "\$config['register_modules_write']=\"summary,email,calendar,tasks,addressbook,files,notes,emailportlet,log,dav,tools,settings,groups,links,blacklist,mailings,bookmarks,sieve,comments,users,search,modules\";";
     $gpoffice[] = "\$config['allowed_modules']=\"\";";
     $gpoffice[] = "\$config['register_user_groups']=\"\";";
     $gpoffice[] = "\$config['register_visible_user_groups']=\",\";";
     $gpoffice[] = "\$config['host']=\"/\";";
     $gpoffice[] = "\$config['force_login_url']=false;";
     $gpoffice[] = "\$config['full_url']=\"http://{$this->servername}/\";";
     $gpoffice[] = "\$config['title']=\"{$this->servername}\";";
     $gpoffice[] = "\$config['webmaster_email']=\"webmaster@example.com\";";
     $gpoffice[] = "\$config['help_link']=\"http://www.group-office.com/wiki/\";";
     $gpoffice[] = "\$config['root_path']=\"{$this->www_dir}/\";";
     $gpoffice[] = "\$config['tmpdir']=\"/tmp/\";";
     $gpoffice[] = "\$config['max_users']=\"0\";";
     $gpoffice[] = "\$config['quota']=\"0\";";
     $gpoffice[] = "\$config['db_type']=\"mysql\";";
     $gpoffice[] = "\$config['db_host']=\"{$q->mysql_server}\";";
     $gpoffice[] = "\$config['db_name']=\"{$this->database}\";";
     $gpoffice[] = "\$config['db_user']=\"{$q->mysql_admin}\";";
     $gpoffice[] = "\$config['db_pass']=\"{$q->mysql_password}\";";
     $gpoffice[] = "\$config['db_port']=\"{$q->mysql_port}\";";
     $gpoffice[] = "\$config['db_socket']=\"\";";
     $gpoffice[] = "\$config['db_auto_increment_increment']=\"1\";";
     $gpoffice[] = "\$config['db_auto_increment_offset']=\"1\";";
     $gpoffice[] = "\$config['file_storage_path']=\"/home/{$this->servername}/\";";
     $gpoffice[] = "\$config['max_file_size']=\"10000000\";";
     $gpoffice[] = "\$config['smtp_server']=\"127.0.0.1\";";
     $gpoffice[] = "\$config['smtp_port']=\"25\";";
     $gpoffice[] = "\$config['smtp_username']=\"\";";
     $gpoffice[] = "\$config['smtp_password']=\"\";";
     $gpoffice[] = "\$config['smtp_encryption']=\"\";";
     $gpoffice[] = "\$config['smtp_local_domain']=\"\";";
     $gpoffice[] = "\$config['restrict_smtp_hosts']=\"\";";
     $gpoffice[] = "\$config['max_attachment_size']=\"10000000\";";
     $gpoffice[] = "\$config['cmd_zip']=\"/usr/bin/zip\";";
     $gpoffice[] = "\$config['cmd_unzip']=\"/usr/bin/unzip\";";
     $gpoffice[] = "\$config['cmd_tar']=\"/bin/tar\";";
     $gpoffice[] = "\$config['cmd_chpasswd']=\"/usr/sbin/chpasswd\";";
     $gpoffice[] = "\$config['cmd_sudo']=\"/usr/bin/sudo\";";
     $gpoffice[] = "\$config['cmd_xml2wbxml']=\"/usr/bin/xml2wbxml\";";
     $gpoffice[] = "\$config['cmd_wbxml2xml']=\"/usr/bin/wbxml2xml\";";
     $gpoffice[] = "\$config['cmd_tnef']=\"/usr/bin/tnef\";";
     $gpoffice[] = "\$config['cmd_php']=\"php\";";
     $gpoffice[] = "\$config['phpMyAdminUrl']=\"\";";
     $gpoffice[] = "\$config['allow_unsafe_scripts']=\"\";";
     $gpoffice[] = "\$config['default_password_length']=\"6\";";
     $gpoffice[] = "\$config['session_inactivity_timeout']=\"0\";";
     $gpoffice[] = "\$config['callto_template']=\"callto:{phone}\";";
     $gpoffice[] = "\$config['disable_flash_upload']=false;";
     $gpoffice[] = "\$config['disable_security_token_check']=false;";
     $gpoffice[] = "\$config['nav_page_size']=\"50\";";
     $ldap = new clladp();
     $gpoffice[] = "\$config['ldap_host']='{$ldap->ldap_host}';";
     $gpoffice[] = "\$config['ldap_port']='{$ldap->ldap_port}';";
     $gpoffice[] = "\$config['ldap_user']='******';";
     $gpoffice[] = "\$config['ldap_pass']='******';";
     if ($this->uid != null) {
         $ct = new user($this->uid);
         $dn = "ou={$ct->ou},dc=organizations,{$ldap->suffix}";
         $dnusers = "ou=users,{$dn}";
         $dngroups = "ou=groups,{$dn}";
     } else {
         $dn = "dc=organizations,{$ldap->suffix}";
         $dnusers = "{$dn}";
         $dngroups = "{$dn}";
     }
     $gpoffice[] = "\$config['ldap_basedn']='{$dn}';";
     $gpoffice[] = "\$config['ldap_peopledn']='{$dnusers}';";
     $gpoffice[] = "\$config['ldap_groupsdn']='{$dngroups}';";
     $gpoffice[] = "\$config['ldap_tls']=false;";
     $gpoffice[] = "\$config['ldap_auth_dont_update_profiles']=True;";
     //set to true if you don't want ldap to overwrite the Group-Office user profile on each login
     $gpoffice[] = "\$config['ldap_use_uid_with_email_domain']='';";
     //leave empty to use the default mapping. Set to a domain name to use username@example.com as e-mail address.
     $gpoffice[] = "?>";
     @file_put_contents("{$this->www_dir}/config.php", @implode("\n", $gpoffice));
     $mapping[] = "<?php";
     $mapping[] = "\$mapping=array(";
     $mapping[] = "\t\t\t\t\t\t'username'\t=> 'uid',";
     $mapping[] = "\t\t\t\t\t\t'password'\t=> 'userpassword',";
     $mapping[] = "\t\t\t\t\t\t'first_name'\t=> 'givenname',";
     $mapping[] = "\t\t\t\t\t\t'middle_name'\t=> 'middlename',";
     $mapping[] = "\t\t\t\t\t\t'last_name'\t=> 'sn',";
     $mapping[] = "\t\t\t\t\t\t'initials'\t=> 'initials',";
     $mapping[] = "\t\t\t\t\t\t'title'\t=> 'title',";
     $mapping[] = "\t\t\t\t\t\t'sex'\t\t=> 'gender',";
     $mapping[] = "\t\t\t\t\t\t'birthday'\t=> 'birthday',";
     $mapping[] = "\t\t\t\t\t\t'email'\t=> 'mail',";
     $mapping[] = "\t\t\t\t\t\t'company'\t=> 'o',";
     $mapping[] = "\t\t\t\t\t\t'department'\t=> 'ou',";
     $mapping[] = "\t\t\t\t\t\t'function'\t=> 'businessrole',";
     $mapping[] = "\t\t\t\t\t\t'home_phone'\t=> 'homephone',";
     $mapping[] = "\t\t\t\t\t\t'work_phone'\t=> 'telephonenumber',";
     $mapping[] = "\t\t\t\t\t\t'fax'\t\t=> 'homefacsimiletelephonenumber',";
     $mapping[] = "\t\t\t\t\t\t'cellular'\t=> 'mobile',";
     $mapping[] = "\t\t\t\t\t\t'country'\t=> 'homecountryname',";
     $mapping[] = "\t\t\t\t\t\t'state'\t=> 'homestate',";
     $mapping[] = "\t\t\t\t\t\t'city'\t=> 'homelocalityname',";
     $mapping[] = "\t\t\t\t\t\t'zip'\t\t=> 'homepostalcode',";
     $mapping[] = "\t\t\t\t\t\t'address'\t=> 'homepostaladdress',";
     $mapping[] = "\t\t\t\t\t\t'homepage'\t=> 'homeurl',";
     $mapping[] = "\t\t\t\t\t\t'work_address'=> 'postaladdress',";
     $mapping[] = "\t\t\t\t\t\t'work_zip'\t=> 'postalcode',";
     $mapping[] = "\t\t\t\t\t\t'work_country'=> 'c',";
     $mapping[] = "\t\t\t\t\t\t'work_state'\t=> 'st',";
     $mapping[] = "\t\t\t\t\t\t'work_city'\t=> 'l',";
     $mapping[] = "\t\t\t\t\t\t'work_fax'\t=> 'facsimiletelephonenumber',";
     $mapping[] = "\t\t\t\t\t\t'currency'\t=> 'gocurrency',";
     $mapping[] = "\t\t\t\t\t\t'max_rows_list'\t=> 'gomaxrowslist',";
     $mapping[] = "\t\t\t\t\t\t'timezone'\t=> 'gotimezone',";
     $mapping[] = "\t\t\t\t\t\t'start_module'=> 'gostartmodule',";
     $mapping[] = "\t\t\t\t\t\t'theme'\t=> 'gotheme',";
     $mapping[] = "\t\t\t\t\t\t'language'\t=> 'golanguage',";
     $mapping[] = "\t\t\t);";
     $mapping[] = "";
     @file_put_contents("{$this->www_dir}/ldapauth.config.php", @implode("\n", $mapping));
     if ($this->rebuildb) {
         $this->autoinstall();
     } else {
         if ($firstinstall) {
             $this->autoinstall();
         }
     }
 }
コード例 #7
0
function updatev2_manu()
{
    $sock = new sockets();
    $unix = new unix();
    $t = time();
    $GLOBALS["TEMP_PATH"] = $unix->TEMP_DIR();
    $ManualArticaDBPath = $sock->GET_INFO("ManualArticaDBPath");
    $ArticaDbReplicate = $sock->GET_INFO("ArticaDbReplicate");
    if ($ManualArticaDBPath == null) {
        $ManualArticaDBPath = "/home/manualupdate/articadb.tar.gz";
    }
    $ArticaDBPath = $sock->GET_INFO("ArticaDBPath");
    if ($ArticaDBPath == null) {
        $ArticaDBPath = "/opt/articatech";
    }
    if (!is_numeric($ArticaDbReplicate)) {
        $ArticaDbReplicate = 0;
    }
    $tar = $unix->find_program("tar");
    updatev2_progress(80, "{installing}...");
    if ($GLOBALS["VERBOSE"]) {
        echo "uncompressing {$ManualArticaDBPath}\n";
    }
    @mkdir($ArticaDBPath, 0755, true);
    updatev2_progress(85, "{stopping_service}...");
    shell_exec("/etc/init.d/artica-postfix stop articadb");
    updatev2_progress(95, "{extracting_package}...");
    shell_exec("{$tar} -xf {$ManualArticaDBPath} -C {$ArticaDBPath}/");
    updatev2_progress(96, "{cleaning}...");
    if ($ArticaDbReplicate == 1) {
        @copy("/usr/share/artica-postfix/ressources/logs/web/cache/CATZ_ARRAY", "/home/articatechdb.version");
        @copy("{$ManualArticaDBPath}", "/home/articadb.tar.gz");
        @chmod("/home/articadb.tar.gz", 0755);
        @chmod("/home/articatechdb.version", 0755);
    }
    @unlink($ManualArticaDBPath);
    updatev2_progress(89, "{starting_service}...");
    if ($GLOBALS["VERBOSE"]) {
        echo "starting Articadb\n";
    }
    shell_exec("/etc/init.d/artica-postfix start articadb");
    updatev2_progress(90, "{checking}");
    $q = new mysql();
    if (!$q->DATABASE_EXISTS("catz")) {
        updatev2_progress(95, "Removing old database catz");
        $q->DELETE_DATABASE("catz");
    }
    updatev2_progress(99, "{finish}");
    $took = $unix->distanceOfTimeInWords($t, time());
    $LOCAL_VERSION = @file_get_contents("{$ArticaDBPath}/VERSION");
    squid_admin_mysql(2, "New Artica Database statistics {$LOCAL_VERSION} updated took:{$took}", "");
    // ufdbguard_admin_events("New Artica Database statistics $LOCAL_VERSION updated took:$took.",__FUNCTION__,__FILE__,__LINE__,"ufbd-artica");
    updatev2_progress(100, "{done}");
    $q->QUERY_SQL("TRUNCATE TABLE `catztemp`");
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $cmd = trim("{$nohup} {$php5} /usr/share/artica-postfix/exec.squid.visited.sites.php --schedule-id={$GLOBALS["SCHEDULE_ID"]} >/dev/null 2>&1 &");
    shell_exec($cmd);
    return true;
}
コード例 #8
0
function remove($servername)
{
    $apache = new vhosts();
    $GLOBALS["ADDLOG"] = "{$GLOBALS["ARTICALOGDIR"]}/{$servername}.log";
    $confs = $apache->SearchHosts($servername);
    events(__FUNCTION__ . ":: Check {$servername}");
    events(__FUNCTION__ . ":: remove files and directories");
    if (is_dir("/usr/share/artica-groupware/domains/{$servername}")) {
        shell_exec("/bin/rm -rf /usr/share/artica-groupware/domains/{$servername}");
    }
    $server_database = str_replace(" ", "_", $servername);
    $server_database = str_replace(".", "_", $servername);
    $server_database = str_replace("-", "_", $server_database);
    $q = new mysql();
    if ($q->DATABASE_EXISTS($server_database)) {
        $q->DELETE_DATABASE($server_database);
    }
    $flaseuser["root"] = true;
    $flaseuser["admin"] = true;
    $flaseuser["manager"] = true;
    $sql = "DELETE FROM `mysql`.`db` WHERE `db`.`Db` = '{$server_database}'";
    $q->QUERY_SQL($sql, "mysql");
    events(__FUNCTION__ . ":: removing ldap branch {$confs["dn"]}");
    $ldap = new clladp();
    if ($ldap->ExistsDN($confs["dn"])) {
        $ldap->ldap_delete($confs["dn"]);
    }
    events(__FUNCTION__ . ":: restarting HTTP service...");
    shell_exec("/etc/init.d/artica-postfix restart apache-groupware &");
}
コード例 #9
0
function rebuild_zarafa()
{
    $q = new mysql();
    $q->DELETE_DATABASE("zarafa");
    shell_exec("/etc/init.d/artica-postfix restart zarafa");
}
コード例 #10
0
function xstart()
{
    $unix = new unix();
    $php = $unix->LOCATE_PHP5_BIN();
    if (!is_file("/opt/influxdb/influxd")) {
        build_progress("{InstallingBigDataEngine}...", 10);
        system("{$php} /usr/share/artica-postfix/exec.influxdb.php --install");
    }
    if (!is_file("/opt/influxdb/influxd")) {
        $php = $unix->LOCATE_PHP5_BIN();
        build_progress("{InstallingBigDataEngine} {failed}...", 10);
    }
    build_progress("Removing old code....", 10);
    $toDelete["squid.cache.perf.stats.php"] = true;
    $toDelete["system.cpustats.php"] = true;
    $toDelete["exec.logfile_daemon-parse.php"] = true;
    $toDelete["exec.squid.stats.members.hours.php"] = true;
    $toDelete["exec.squid.hourly.tables.php"] = true;
    $toDelete["exec.squidstream.php"] = true;
    $toDelete["exec.sarg.php"] = true;
    $toDelete["exec.sarg-web.php"] = true;
    $toDelete["exec.squid-users-rttsize.php"] = true;
    $toDelete["exec.squid.stats.notcached-week.php"] = true;
    $toDelete["squid.traffic.panel.php"] = true;
    $toDelete["squid.rrt-yesterday.php"] = true;
    $toDelete["exec.squid.whitelist.ntlm.php"] = true;
    $toDelete["squid.rtt.php"] = true;
    $toDelete["exec.squid.stats.central.php"] = true;
    $toDelete["exec.squid.stats.php"] = true;
    $toDelete["{ipto}"] = true;
    $toDelete["exec.firewall.php"] = true;
    $toDelete["stats.admin.events.php"] = true;
    $toDelete["exec.squid.stats.totals.php"] = true;
    $toDelete["exec.mysar.php"] = true;
    $toDelete["exec.admin.status.postfix.flow.php"] = true;
    $toDelete["exec.squid.stats.mime.parser.php"] = true;
    $toDelete["exec.dansguardian.last.php"] = true;
    $toDelete["exec.squid.stats.month.php"] = true;
    $toDelete["exec.dansguardian.last.php"] = true;
    $toDelete["exec.squid.stats.familyday.php"] = true;
    $toDelete["exec.squid.stats.usersday.php"] = true;
    $toDelete["exec.squid.stats.quotaday.php"] = true;
    $toDelete["exec.squid.stats.protos.php"] = true;
    $toDelete["exec.squid-searchwords.php"] = true;
    $toDelete["exec.squid.words.parsers.php"] = true;
    $toDelete["exec.squid.visited.sites.php"] = true;
    $toDelete["exec.squid.reports-scheduled.php"] = true;
    $toDelete["exec.squid.hourly.tables.php"] = true;
    $toDelete["exec.squid.quotasbuild.php"] = true;
    $toDelete["exec.squid.cmdline.finduser.php"] = true;
    $toDelete["exec.squid.reports-scheduled.php"] = true;
    $toDelete["exec.squid.stats.categorize-table.php"] = true;
    $toDelete["exec.squid.stats.month.php"] = true;
    $toDelete["exec.squid.stats.not-categorized.php"] = true;
    $toDelete["exec.squid.stats.recategorize.missed.php"] = true;
    $toDelete["exec.squid.stats.recategorize.php"] = true;
    $toDelete["exec.squid.stats.uid-month.php"] = true;
    $toDelete["exec.squid.stats.usersday.php"] = true;
    $toDelete["exec.squid.logs.import.php"] = true;
    $toDelete["exec.squid.stats.quotaday.php"] = true;
    $toDelete["exec.squid.cache.optimize.php"] = true;
    $toDelete["squid.statistics.visited.day.php"] = true;
    $toDelete["squid.traffic.statistics.days.php"] = true;
    $toDelete["squid.traffic.statistics.days.graphs.php"] = true;
    $toDelete["squid.statistics.visited.day.php"] = true;
    $toDelete["squid.stats.repair.day.php"] = true;
    $toDelete["squid.stats.category.php"] = true;
    $toDelete["squid.statistics.query.categories.php"] = true;
    $toDelete["squid.statistics.querytable.php"] = true;
    $toDelete["exec.squid.stats.proto.parser.php"] = true;
    $toDelete["exec.squid.stats.central.php"] = true;
    $toDelete["exec.squid.stats.protos.php"] = true;
    $toDelete["exec.squid.stats.month.php"] = true;
    $toDelete["exec.squid.stats.members.hours.php"] = true;
    $toDelete["exec.squid.stats.recategorize.missed.php"] = true;
    $toDelete["exec.squid.stats.global.categories.php"] = true;
    $toDelete["exec.squid.stats.totals.php"] = true;
    $toDelete["exec.squid.stats.year.php"] = true;
    $toDelete["exec.squid-rrd.php"] = true;
    $toDelete["exec.squid.stats.quota-week.parser.php"] = true;
    $toDelete["exec.squid.stats.notcached-week.php"] = true;
    $toDelete["exec.squid.stats.uid-month.php"] = true;
    $toDelete["exec.squid.stats.usersday.php"] = true;
    $toDelete["exec.squid.stats.familyday.php"] = true;
    $toDelete["exec.squid.stats.days.websites.php"] = true;
    $toDelete["exec.squid.stats.days.cached.php"] = true;
    $toDelete["exec.squid.stats.blocked.week.php"] = true;
    $toDelete["exec.squid.stats.repair.php"] = true;
    $toDelete["exec.getent.php"] = true;
    $toDelete["squid.stats.filetypes.php"] = true;
    $toDelete["exec.netdiscover.php"] = true;
    $toDelete["miniadm.MembersTrack.category.php"] = true;
    $toDelete["miniadm.MembersTrack.cronozoom.php"] = true;
    $toDelete["miniadm.MembersTrack.sitename.php"] = true;
    $toDelete["miniadm.webstats.php"] = true;
    $toDelete["sarg.events.php"] = true;
    $toDelete["squid.blocked.statistics.days.php"] = true;
    $toDelete["squid.blocked.statistics.php"] = true;
    $toDelete["squid.blocked.statistics.week.php"] = true;
    $toDelete["squid.members.statistics.php"] = true;
    $toDelete["squid.statistics.central.php"] = true;
    $toDelete["squid.graphs.php"] = true;
    $toDelete["squid.client-plugins.php"] = true;
    $toDelete["exec.cache.pages.php"] = true;
    while (list($filepath, $table) = each($toDelete)) {
        $filepath = "/usr/share/artica-postfix/{$filepath}";
        if (is_file($filepath)) {
            echo "Remove {$filepath}\n";
            @unlink($filepath);
        }
    }
    $Files["/etc/cron.hourly/SquidHourlyTables.sh"] = true;
    $Files["/bin/artica-firewall.sh"] = true;
    $Files["/etc/init.d/tproxy"] = true;
    $Files["/usr/share/artica-postfix/bin/netdiscover"] = true;
    $Files["/usr/share/artica-postfix/bin/install/rrd/yorel"] = true;
    $Files["/usr/share/artica-postfix/bin/install/rrd/yorel-create"] = true;
    $Files["/usr/share/artica-postfix/bin/install/rrd/yorel_cron"] = true;
    $Files["/usr/share/artica-postfix/bin/install/rrd/yorel-upd"] = true;
    while (list($filepath, $table) = each($Files)) {
        if (is_file($filepath)) {
            echo "Removing {$filepath}\n";
            @unlink($filepath);
        }
    }
    build_progress("Removing old code....", 15);
    $artica_events_delete["dnsperfs"] = true;
    $artica_events_delete["dnsperfs_week"] = true;
    $artica_events_delete["sys_loadvg"] = true;
    $artica_events_delete["sys_mem"] = true;
    $artica_events_delete["sys_loadvg"] = true;
    $artica_events_delete["squid_rqs_days"] = true;
    $artica_events_delete["squid_cache_perfs"] = true;
    $artica_events_delete["cpustats"] = true;
    @file_put_contents("/etc/artica-postfix/settings/Daemons/EnableStreamCache", 0);
    build_progress("List old tables...", 20);
    cleanother();
    $LIST_TABLES_HOURS = LIST_TABLES_HOURS();
    $LIST_TABLES_RTTZ_WORKSHOURS = LIST_TABLES_RTTZ_WORKSHOURS();
    $LIST_TABLES_CACHE_DAY = LIST_TABLES_CACHE_DAY();
    $LIST_TABLES_WORKSHOURS = LIST_TABLES_WORKSHOURS();
    $LIST_TABLES_SIZEHOURS = LIST_TABLES_SIZEHOURS();
    $LIST_TABLES_dansguardian_events = LIST_TABLES_dansguardian_events();
    $LIST_TABLES_RTTD = LIST_TABLES_RTTD();
    $LIST_TABLES_week = LIST_TABLES_week();
    $MQUOTASIZE = LIST_TABLES_gen("%_MQUOTASIZE");
    $WQUOTASIZE = LIST_TABLES_gen("%_WQUOTASIZE");
    $quotaday = LIST_TABLES_gen("quotaday_%");
    $visited = LIST_TABLES_gen("%_visited");
    $quotamonth = LIST_TABLES_gen("quotamonth_%");
    $DAYS = LIST_TABLES_gen("%_day");
    $CATFAM = LIST_TABLES_gen("%_catfam");
    $WWWUSERS = LIST_TABLES_gen("www_%");
    $GCACHES = LIST_TABLES_gen("%_gcache");
    $_not_cached = LIST_TABLES_gen("%_not_cached");
    $members = LIST_TABLES_gen("%_members");
    $dcache = LIST_TABLES_gen("%_dcache");
    $family = LIST_TABLES_gen("%_family");
    $proto = LIST_TABLES_gen("%_proto");
    $_cacheperfs = LIST_TABLES_gen("%_cacheperfs");
    $UserSizeD = LIST_TABLES_gen("UserSizeD_%");
    $blocked_days = LIST_TABLES_gen("%_blocked_days");
    $squidmemory = LIST_TABLES_gen("squidmemory_%");
    $squidmemoryM = LIST_TABLES_gen("squidmemoryM_%");
    $blocked_week = LIST_TABLES_gen("%_blocked_week");
    $hours1 = LIST_TABLES_gen("hour_%");
    $hours2 = LIST_TABLES_gen("squidhour_%");
    $hours3 = LIST_TABLES_gen("sizehour_%");
    $visited = LIST_TABLES_gen("%_visited");
    $squidlogs["UserSizeRTT"] = true;
    $squidlogs["visited_sites"] = true;
    $squidlogs["MySQLStats"] = true;
    while (list($num, $table) = each($LIST_TABLES_HOURS)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($LIST_TABLES_RTTZ_WORKSHOURS)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($LIST_TABLES_CACHE_DAY)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($LIST_TABLES_WORKSHOURS)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($LIST_TABLES_SIZEHOURS)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($LIST_TABLES_dansguardian_events)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($LIST_TABLES_RTTD)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($LIST_TABLES_week)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($MQUOTASIZE)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($WQUOTASIZE)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($quotaday)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($visited)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($quotamonth)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($DAYS)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($CATFAM)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($WWWUSERS)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($GCACHES)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($_not_cached)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($members)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($family)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($proto)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($_cacheperfs)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($UserSizeD)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($blocked_days)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($squidmemory)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($squidmemoryM)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($blocked_week)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($hours1)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($hours2)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($hours3)) {
        $squidlogs[$num] = true;
    }
    while (list($num, $table) = each($visited)) {
        $squidlogs[$num] = true;
    }
    $q = new mysql_squid_builder();
    while (list($tablename, $none) = each($squidlogs)) {
        if (!$q->TABLE_EXISTS($tablename)) {
            continue;
        }
        if ($q->COUNT_ROWS($table) == 0) {
            $q->QUERY_SQL("DROP TABLE `{$tablename}`");
            continue;
        }
        build_progress("Backup table/remove {$tablename}", 25);
        echo "Backup {$tablename}\n";
        if (!backup_squidlogs($tablename)) {
            continue;
        }
        $q->QUERY_SQL("DROP TABLE `{$tablename}`");
    }
    while (list($filename, $none) = each($toDelete)) {
        if (is_file("/share/artica-postfix/{$filename}")) {
            build_progress("Removing {$filename}", 50);
            @unlink("/usr/share/artica-postfix/{$filename}");
        }
    }
    $q = new mysql();
    while (list($tablename, $none) = each($artica_events_delete)) {
        if (!$q->TABLE_EXISTS($tablename, "artica_events")) {
            continue;
        }
        build_progress("Backup table {$tablename}", 60);
        if ($q->COUNT_ROWS($table, "artica_events") == 0) {
            $q->QUERY_SQL("DROP TABLE `{$tablename}`", "artica_events");
            continue;
        }
        $q->QUERY_SQL("DROP TABLE `{$tablename}`", "artica_events");
    }
    $users = new usersMenus();
    if ($users->POSTFIX_INSTALLED) {
        $q = new mysql();
        if ($q->DATABASE_EXISTS("postfixlog")) {
            $q->DELETE_DATABASE("postfixlog");
        }
        if ($q->DATABASE_EXISTS("syslogstore")) {
            $q->DELETE_DATABASE("syslogstore");
        }
    }
    build_progress("{reconfigure_proxy_service}", 70);
    system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
    build_progress("{restarting} BigData Database", 80);
    system("/etc/init.d/influx-db restart --force");
    build_progress("{restarting} Watchdog", 90);
    system("/etc/init.d/artica-status restart --force");
    build_progress("{restarting} Watchdog", 95);
    system("/etc/init.d/squid-tail restart");
    build_progress("{restarting} Watchdog", 98);
    system("/etc/init.d/cache-tail restart");
    @file_put_contents("/etc/artica-postfix/settings/Daemons/UpgradeTov10", 1);
    build_progress("{done}", 100);
}
コード例 #11
0
function remove_database()
{
    $q = new mysql();
    $unix = new unix();
    $sock = new sockets();
    $ZarafaDedicateMySQLServer = $sock->GET_INFO("ZarafaDedicateMySQLServer");
    if (!is_numeric($ZarafaDedicateMySQLServer)) {
        $ZarafaDedicateMySQLServer = 0;
    }
    if ($ZarafaDedicateMySQLServer == 1) {
        shell_exec($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.zarafa-db.php --remove-database");
        return;
    }
    $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR();
    $q->DELETE_DATABASE("zarafa");
    if (!$q->ok) {
        echo "Error while removing zarafa database...{$q->mysql_error}\n";
        return;
    }
    if (!is_dir($MYSQL_DATA_DIR)) {
        echo "Failed to locate {$MYSQL_DATA_DIR}\n";
        return;
    }
    if (is_file("/etc/artica-postfix/ZARFA_FIRST_INSTALL")) {
        @unlink("/etc/artica-postfix/ZARFA_FIRST_INSTALL");
    }
    $kill = $unix->find_program("kill");
    $pidof = $unix->find_program("pidof");
    $zarafa_server = $unix->find_program("zarafa-server");
    shell_exec("{$kill} -9 `{$pidof} {$zarafa_server}` >/dev/null 2>&1");
    echo "Starting zarafa..............: remove {$MYSQL_DATA_DIR}/ib_logfile*\n";
    shell_exec("/bin/rm -f {$MYSQL_DATA_DIR}/ib_logfile*");
    shell_exec("/bin/rm -f {$MYSQL_DATA_DIR}/ibdata*");
    echo "Starting zarafa..............: remove {$MYSQL_DATA_DIR}/zarafa*\n";
    shell_exec("/bin/rm -rf {$MYSQL_DATA_DIR}/zarafa");
    echo "Starting zarafa..............: restart MySQL\n";
    mysql_admin_mysql(1, "Restarting MySQL service...", null, __FILE__, __LINE__);
    shell_exec("/etc/init.d/mysql restart --force --framework=" . __FILE__ . " >/tmp/zarafa_removedb 2>&1");
    echo "Starting zarafa..............: restart Zarafa server\n";
    shell_exec("/etc/init.d/zarafa-server restart >>/tmp/zarafa_removedb 2>&1");
    $unix->send_email_events("Success removing zarafa databases", "removed {$MYSQL_DATA_DIR}/ib_logfile*\nremoved {$MYSQL_DATA_DIR}/ibdata*\nremoved {$MYSQL_DATA_DIR}/zarafa\n\n" . @file_get_contents("/tmp/zarafa_removedb"), "mailbox");
}
コード例 #12
0
ファイル: exec.freeweb.php プロジェクト: articatech/artica
function remove_host($hostname)
{
    $freeweb = new freeweb($hostname);
    if (is_dir("/var/www/{$hostname}")) {
        shell_exec("/bin/rm -rf /var/www/{$hostname}");
    }
    if ($freeweb->IsGroupWareFromArtica()) {
        $freeweb->delete();
        return;
    }
    if ($freeweb->WebCopyID > 0) {
        $freeweb->delete();
        return;
    }
    $mysql_database = $freeweb->mysql_database;
    $q = new mysql();
    if ($q->DATABASE_EXISTS($mysql_database)) {
        $q->DELETE_DATABASE($mysql_database);
    }
    if ($freeweb->groupware == "POWERADMIN") {
        $freeweb->delete();
        return;
    }
    if ($freeweb->groupware == "ARKEIA") {
        $freeweb->delete();
        return;
    }
    if ($freeweb->groupware == "UPDATEUTILITY") {
        $freeweb->delete();
        return;
    }
    if ($freeweb->groupware == "SARG") {
        $freeweb->delete();
        return;
    }
    if ($hostname == "_default_") {
        $freeweb->delete();
        return;
    }
    if ($freeweb->Forwarder == 0) {
        $freeweb->delete();
        return;
    }
    if (is_dir($freeweb->WORKING_DIRECTORY)) {
        shell_exec("/bin/rm -rf {$freeweb->WORKING_DIRECTORY}");
    }
    $freeweb->delete();
}
コード例 #13
0
ファイル: exec.articadb.php プロジェクト: brucewu16899/1.6.x
function build()
{
    $sock = new sockets();
    $ArticaDBPath = $sock->GET_INFO("ArticaDBPath");
    if ($ArticaDBPath == null) {
        $ArticaDBPath = "/opt/articatech";
    }
    if (!is_dir("{$ArticaDBPath}/data/catz")) {
        return;
    }
    $f[] = "[client] ";
    $f[] = "#password\t= your_password ";
    $f[] = "#port\t\t= 3306 ";
    $f[] = "socket\t\t= /var/run/mysqld/articadb.sock ";
    $f[] = " ";
    $f[] = " ";
    $f[] = "[mysqld] ";
    $f[] = "#port\t\t= 3306 ";
    $f[] = "socket\t\t= /var/run/mysqld/articadb.sock ";
    $f[] = "skip-external-locking";
    $f[] = "skip-networking ";
    $f[] = "skip-innodb";
    $f[] = "skip-slave-start";
    $f[] = "default-storage-engine = MYISAM ";
    $f[] = "default_tmp_storage_engine = MYISAM ";
    $f[] = "key_buffer_size = 16M ";
    $f[] = "max_allowed_packet = 1M ";
    $f[] = "query_cache_type = 1";
    $f[] = "query_cache_size = 35M";
    $f[] = "max_heap_table_size=40M";
    $f[] = "tmp_table_size=8M";
    $f[] = "table_open_cache = 180 ";
    $f[] = "sort_buffer_size = 256K ";
    $f[] = "read_buffer_size = 1M ";
    $f[] = "read_rnd_buffer_size = 256K ";
    $f[] = "net_buffer_length = 128K ";
    $f[] = "thread_stack = 128K ";
    $f[] = "thread_cache_size=8";
    $f[] = "table_open_cache=70";
    $f[] = "max_connections=20";
    $f[] = "server-id\t= 1 ";
    $f[] = "#log-bin=mysql-bin ";
    $f[] = "#binlog_format=mixed ";
    $f[] = "#binlog_direct_non_transactional_updates=TRUE ";
    $f[] = "tmpdir={$ArticaDBPath}/tmp";
    $f[] = "open_files_limit=2048";
    $f[] = " ";
    $f[] = " ";
    $f[] = "[mysqldump] ";
    $f[] = "quick ";
    $f[] = "max_allowed_packet = 16M ";
    $f[] = " ";
    $f[] = "[mysql] ";
    $f[] = "no-auto-rehash ";
    $f[] = "#safe-updates ";
    $f[] = " ";
    $f[] = "[myisamchk] ";
    $f[] = "key_buffer_size = 8M ";
    $f[] = "sort_buffer_size = 8M ";
    $f[] = " ";
    $f[] = "[mysqlhotcopy] ";
    $f[] = "interactive-timeout ";
    $f[] = "";
    @file_put_contents("{$ArticaDBPath}/my.cnf", @implode("\n", $f));
    @mkdir("{$ArticaDBPath}/mysql/etc", 0755, true);
    @mkdir("{$ArticaDBPath}/tmp", 0755, true);
    shell_exec("/bin/ln -sf {$ArticaDBPath}/data {$ArticaDBPath}/mysql/data");
    shell_exec("/bin/ln -sf {$ArticaDBPath}/my.cnf {$ArticaDBPath}/mysql/etc/my.cnf");
    @unlink("{$ArticaDBPath}/data/data");
    $q = new mysql();
    if ($q->DATABASE_EXISTS("catz")) {
        $q->DELETE_DATABASE("catz");
    }
    echo "Starting......: " . date("H:i:s") . " ArticaDBst configuration done...\n";
}
コード例 #14
0
ファイル: exec.pdns.php プロジェクト: BillTheBest/1.6.x
function rebuild_database($nollop = false)
{
    $unix = new unix();
    $MYSQL_DATA_DIR = $unix->MYSQL_DATA_DIR();
    echo "Starting......: " . date("H:i:s") . " PowerDNS destroy database and recreate it\n";
    $q = new mysql();
    $q->DELETE_DATABASE("powerdns");
    $rm = $unix->find_program("rm");
    if (is_dir("{$MYSQL_DATA_DIR}/powerdns")) {
        echo "Starting......: " . date("H:i:s") . " PowerDNS removing {$MYSQL_DATA_DIR}/powerdns\n";
        shell_exec("{$rm} -rf {$MYSQL_DATA_DIR}/powerdns");
    }
    checkMysql($nollop);
    shell_exec("/etc/init.d/artica-postfix restart pdns");
}
コード例 #15
0
function clean_events()
{
    $q = new mysql();
    $unix = new unix();
    $rm = $unix->find_program("rm");
    $nohup = $unix->find_program("nohup");
    $TABLES = $q->LIST_TABLES_EVENTS_SYSTEM();
    while (list($tablename, $line) = each($TABLES)) {
        echo "DROP {$tablename}\n";
        $q->QUERY_SQL("DROP TABLE `{$tablename}`", "artica_events");
    }
    $datadir = $unix->MYSQL_DATA_DIR();
    shell_exec("{$rm} -f {$datadir}/artica_events/*.BAK");
    if (is_dir("{$datadir}/syslogstore")) {
        $q->DELETE_DATABASE("syslogstore");
        shell_exec("{$rm} -f {$datadir}/syslogstore/*.BAK");
    }
    $files = $unix->DirFiles("{$datadir}/artica_events", "TaskSq[0-9]+\\.MYI");
    while (list($file, $line) = each($files)) {
        $file = str_replace(".MYI", "", $file);
        $q->QUERY_SQL("DROP TABLE `{$file}`", "artica_events");
    }
    $q->QUERY_SQL("TRUNCATE TABLE `nmap_events`", "artica_events");
    $q->QUERY_SQL("TRUNCATE TABLE `nmap_events`", "artica_events");
    $q->QUERY_SQL("TRUNCATE TABLE `avgreports`", "artica_events");
    $q->QUERY_SQL("TRUNCATE TABLE `events`", "artica_events");
    $q->QUERY_SQL("TRUNCATE TABLE `dhcpd_logs`", "artica_events");
    $q->QUERY_SQL("TRUNCATE TABLE `update_events`", "artica_events");
    shell_exec("{$nohup} /etc/init.d/mysql restart --framework=" . __FILE__ . " >/dev/null 2>&1 &");
    shell_exec($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.mysql.start.php --engines --verbose --framework=" . __FILE__ . " 2>&1 &");
}
コード例 #16
0
function clean_squid_stats_dbs()
{
    $sock = new sockets();
    $DisableArticaProxyStatistics = $sock->GET_INFO("DisableArticaProxyStatistics");
    $CleanArticaSquidDatabases = $sock->GET_INFO("CleanArticaSquidDatabases");
    if (!is_numeric($DisableArticaProxyStatistics)) {
        $DisableArticaProxyStatistics = 0;
    }
    if (!is_numeric($CleanArticaSquidDatabases)) {
        $CleanArticaSquidDatabases = 0;
    }
    if (!$GLOBALS["FORCE"]) {
        if ($CleanArticaSquidDatabases == 0) {
            echo "Option is not activated...\n";
            return;
        }
    }
    $q = new mysql_squid_builder();
    $tables = $q->LIST_TABLES_DAYS();
    $rows = 0;
    $count_tables = 0;
    while (list($num, $table) = each($tables)) {
        $rows = $rows + $q->COUNT_ROWS($table);
        if ($GLOBALS["VERBOSE"]) {
            echo " Delete table {$table} {$rows} rows \n";
        }
        $count_tables++;
        $q->DELETE_TABLE($table);
    }
    $tables = $q->LIST_TABLES_DAYS_BLOCKED();
    while (list($num, $table) = each($tables)) {
        $rows = $rows + $q->COUNT_ROWS($table);
        if ($GLOBALS["VERBOSE"]) {
            echo " Delete table {$table} {$rows} rows \n";
        }
        $count_tables++;
        $q->DELETE_TABLE($table);
    }
    $tables = $q->LIST_TABLES_MEMBERS();
    while (list($num, $table) = each($tables)) {
        $rows = $rows + $q->COUNT_ROWS($table);
        if ($GLOBALS["VERBOSE"]) {
            echo " Delete table {$table} {$rows} rows \n";
        }
        $count_tables++;
        $q->DELETE_TABLE($table);
    }
    $tables = $q->LIST_TABLES_MONTH();
    while (list($num, $table) = each($tables)) {
        $rows = $rows + $q->COUNT_ROWS($table);
        if ($GLOBALS["VERBOSE"]) {
            echo " Delete table {$table} {$rows} rows \n";
        }
        $count_tables++;
        $q->DELETE_TABLE($table);
    }
    $tables = $q->LIST_TABLES_WEEKS();
    while (list($num, $table) = each($tables)) {
        $rows = $rows + $q->COUNT_ROWS($table);
        if ($GLOBALS["VERBOSE"]) {
            echo " Delete table {$table} {$rows} rows \n";
        }
        $count_tables++;
        $q->DELETE_TABLE($table);
    }
    $q = new mysql_catz();
    $tables = $q->LIST_TABLES_CATEGORIES();
    while (list($num, $table) = each($tables)) {
        $rows = $rows + $q->COUNT_ROWS($table);
        if ($GLOBALS["VERBOSE"]) {
            echo " Delete table {$table} {$rows} rows \n";
        }
        $count_tables++;
        $q->DELETE_TABLE($table);
    }
    $q = new mysql();
    if ($q->DATABASE_EXISTS("catz")) {
        $q->DELETE_DATABASE("catz");
    }
    if ($count_tables > 0) {
        mysql_admin_mysql(1, "Restarting MySQL service...", null, __FILE__, __LINE__);
        shell_exec("/etc/init.d/mysql restart");
    }
    $sock->TOP_NOTIFY("{$count_tables} statistics tables as been deleted with {$rows} rows", "info");
    //print_r($tables);
}
コード例 #17
0
function multi_delete($ID)
{
    $unix = new unix();
    $rm = $unix->find_program("rm");
    echo "Deleting......: zarafa-server instance id:{$ID}..\n";
    echo "Deleting......: zarafa-server disable instance\n";
    $q = new mysql();
    $q->QUERY_SQL("UPDATE zarafamulti SET enabled=0 WHERE ID='{$ID}'", "artica_backup");
    echo "Deleting......: zarafa-server stopping instance\n";
    multi_stop($ID);
    $zarafa = new zarafamulti($ID);
    echo "Deleting......: zarafa-server removing directory {$zarafa->attachment_path}\n";
    if (is_dir($zarafa->attachment_path)) {
        recursive_remove_directory($zarafa->attachment_path);
    }
    echo "Deleting......: zarafa-server removing directory /etc/zarafa-{$ID}\n";
    if (is_dir("/etc/zarafa-{$ID}")) {
        recursive_remove_directory("/etc/zarafa-{$ID}");
    }
    $database = "zarafa{$ID}";
    echo "Deleting......: zarafa-server removing database {$database}\n";
    if ($zarafa->mysql_instance_id > 0) {
        $q = new mysql_multi($zarafa->mysql_instance_id);
        $q->QUERY_SQL_NO_BASE("DROP DATABASE `{$database}`");
    } else {
        $q = new mysql();
        $q->DELETE_DATABASE($database);
    }
    echo "Deleting......: zarafa-server removing entry\n";
    $q = new mysql();
    $q->QUERY_SQL("DELETE FROM zarafamulti WHERE ID={$ID}", "artica_backup");
    if ($zarafa->PostfixInstance != null) {
        echo "Deleting......: zarafa-server reconfigure {$zarafa->PostfixInstance} postfix instance \n";
        $sock = new sockets();
        $sock->getFrameWork("postfix.php?reconfigure-single-instance={$zarafa->PostfixInstance}");
    }
    echo "Deleting......: zarafa-server done...\n";
}