Exemplo n.º 1
0
 function main()
 {
     global $gbl, $sgbl, $login, $ghtml;
     global $argv;
     initProgram('admin');
     $login->loadAllObjects('vps');
     $this->bserver_l = $login->getList('centralbackupserver');
     $list = $login->getList('vps');
     foreach ($this->bserver_l as $bso) {
         $bso->setMyselfUp();
     }
     $opt = parse_opt($argv);
     if (!isset($opt['newarg'])) {
         $mess = "\n\nThe architecture of centralized backup has been completely rewritten, and now we have per slave backup-server; you will need to supply --newarg=true for this to work. ";
         $mess .= "More info at http://wiki.lxcenter.org/.";
         print $mess;
         log_log("centralbackup_flag", $mess);
         send_mail_to_admin("Central Backup Failed", $mess);
         exit;
     }
     $this->stopvps = opt_get_single_flag($opt, 'stopvps');
     //$stopxen = opt_get_single_flag($opt, 'stopxen');
     //$stopopenvz = opt_get_single_flag($opt, 'stopopenvz');
     foreach ($list as $l) {
         $this->backup_one_vps($l);
     }
     foreach ((array) $this->global_list as $k => $s) {
         //$res = rl_exec_get(null, $k, 'remove_scpid', array($backupiddsa));
     }
 }
Exemplo n.º 2
0
function mebackup_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    $progname = $sgbl->__var_program_name;
    $cprogname = ucfirst($progname);
    initProgram('admin');
    lxfile_mkdir("__path_program_home/selfbackup/self/__backup");
    $backup = $login->getObject('general')->selfbackupparam_b;
    $dbf = $sgbl->__var_dbf;
    $pass = trim(lfile_get_contents("__path_program_root/etc/conf/{$progname}.pass"));
    $vd = createTempDir("/tmp", "mebackup");
    $docf = "{$vd}/mebackup.dump";
    // Issue #671 - Fixed backup-restore issue
    //	exec("exec mysqldump --add-drop-table -u $progname -p$pass $dbf > $docf");
    system("exec mysqldump --add-drop-table -u {$progname} -p{$pass} {$dbf} > {$docf}");
    $string = @date('Y-M-d') . '-' . time();
    $bfile = "{$sgbl->__path_program_home}/selfbackup/self/__backup/{$progname}-scheduled-masterselfbackup-{$string}.zip";
    lxshell_zip($vd, $bfile, array("mebackup.dump"));
    lxfile_tmp_rm_rec($vd);
    if ($backup && $backup->isOn('selfbackupflag')) {
        try {
            lxbackup::upload_to_server($bfile, basename($bfile), $backup);
        } catch (Exception $e) {
            print "Sending warning to {$login->contactemail} ..\n";
            lx_mail(null, $login->contactemail, "{$cprogname} Self Database Backup Upload Failed on " . date('Y-M-d') . " at " . date('H') . " Hours", "{$cprogname} Backup upload Failed due to {$e->getMessage()}\n");
        }
    }
    $backup->rm_last_number = 20;
    $backup->nname = 'masterselfbackup';
    lxbackup::clear_extra_backups('selfbackup', 'self', $backup);
}
Exemplo n.º 3
0
function lpanel_main()
{
    global $gbl, $login, $ghtml;
    initProgram();
    init_language();
    print_meta_lan();
    $gbl->__navigmenu = null;
    $gbl->__navig = null;
    $skincolor = $login->getSkinColor();
    // This should be called only in display.php, and not anywhere else. It doesn't matter anyway, since both lpanel.php, AND header.php never allows any modification to be carried out. Also, the display.php automatically deletes the login info, so if you click on any link on the header or the lpanel, you will automatically logged out.
    //check_if_disabled_and_exit();
    $imgbordermain = "{$login->getSkinDir()}/top_line_medium.gif";
    if ($gbl->isOn('show_help')) {
        $background = "{$login->getSkinDir()}/top_line_dark.gif";
        $border = null;
    } else {
        $background = null;
    }
    $ghtml->print_include_jscript('left_panel');
    print "<body topmargin=0 leftmargin=0 style='background-color:#fafafa'>";
    //$ghtml->lpanel_beginning();
    try {
        //$ghtml->xp_panel($login);
        //print_ext_tree($login);
        $ghtml->tab_vheight();
    } catch (exception $e) {
        print "The Resource List could not gathered....{$e->getMessage()}<br> \n";
    }
}
Exemplo n.º 4
0
function updatecleanup_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    $program = $sgbl->__var_program_name;
    $opt = parse_opt($argv);
    if ($opt['type'] === 'master') {
        initProgram('admin');
        $flg = "__path_program_start_vps_flag";
        if (!lxfile_exists($flg)) {
            set_login_skin_to_feather();
        }
    } else {
        $login = new Client(null, null, 'update');
    }
    print "Executing UpdateCleanup. This can take a long time. Please be patient\n";
    log_log("update", "Executing Updatecleanup");
    //
    // Cleanup old lxlabs.repo file
    //
    print "Fixing Repo's\n";
    if (lxfile_exists("/etc/yum.repos.d/lxcenter.repo")) {
        if (lxfile_exists("/etc/yum.repos.d/lxlabs.repo")) {
            lxfile_mv("/etc/yum.repos.d/lxlabs.repo", "/etc/yum.repos.d/lxlabs.repo.lxsave");
            system("rm -f /etc/yum.repos.d/lxlabs.repo");
        }
    }
    if (lxfile_exists("CVS")) {
        print "Found Development version, we just go on.\n";
        //		exit;
    }
    if ($opt['type'] === 'master') {
        $sgbl->slave = false;
        if (!is_secondary_master()) {
            print "Update database\n";
            updateDatabaseProperly();
            print "Fix Extra database issues\n";
            fixExtraDB();
            print "Update extra issues\n";
            doUpdateExtraStuff();
            print "Get Driver info\n";
            lxshell_return("__path_php_path", "../bin/common/driverload.php");
        }
        print "Starting Update all slaves\n";
        update_all_slave();
        print "Fix main {$program} databasefile\n";
        cp_dbfile();
    } else {
        $sgbl->slave = true;
    }
    if (!is_secondary_master()) {
        print "Starting update cleanups\n";
        updatecleanup();
    }
    lxfile_touch("__path_program_start_vps_flag");
}
Exemplo n.º 5
0
function switchserver_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    //sleep(60);
    initProgram("admin");
    if ($argc === 1) {
        print "Usage: {$argv['0']} --class= --name= --v-syncserver= \n";
        exit;
    }
    try {
        $opt = parse_opt($argv);
        $param = get_variable($opt);
        dprintr($param);
        $class = $opt['class'];
        $name = $opt['name'];
        if (lx_core_lock("{$class}-{$name}.switchserver")) {
            exit;
        }
        $object = new $class(null, 'localhost', $name);
        $object->get();
        if ($object->dbaction === 'add') {
            throw new lxException("no_object", '', '');
            exit;
        }
        if (!$object->syncserver) {
            print "No_synserver...\n";
            throw new lxException("no_syncserver", '', '');
            exit;
        }
        if ($param['syncserver'] === $object->syncserver) {
            print "No Change...\n";
            throw new lxException("no_change", '', '');
            exit;
        }
        $driverapp_old = $gbl->getSyncClass('localhost', $object->syncserver, $object->get__table());
        $driverapp_new = $gbl->getSyncClass('localhost', $param['syncserver'], $object->get__table());
        if ($driverapp_new !== $driverapp_old) {
            //throw new lxException ("the_drivers_are_different_in_two_servers", '', '');
        }
        $object->doupdateSwitchserver($param);
    } catch (exception $e) {
        print $e->getMessage();
        /// hcak ahck... Chnage only the olddelete variable which is the mutex used for locking in the process of switch. The problem is we want to totally bail out if the switchserver fails. The corect way would be save after reverting the syncserve to the old value, but that's a bit risky. So we just use a hack to change only the olddeleteflag; Not a real hack.. This is the better way.
        $message = "{$e->getMessage()}";
        write_to_object($object, $message, $param['syncserver']);
        $fullmesage = "Switch of {$object->get__table()}:{$object->nname} to {$object->syncserver} failed due to {$e->getMessage()}";
        log_switch($fullmesage);
        mail($login->contactemail, "Switch Failed:", "{$fullmesage}\n");
        print "\n";
        exit;
    }
    mail($login->contactemail, "Switch Succeeded", "Switch Succeeded {$object->get__table()}:{$object->nname} to {$param['syncserver']}\n");
}
Exemplo n.º 6
0
function header_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    initProgram();
    init_language();
    print_meta_lan();
    if ($login->isDefaultSkin()) {
        print_header_old_default();
    } else {
        print_header();
    }
}
Exemplo n.º 7
0
function driverload_main()
{
    global $argv, $gbl, $sgbl, $login, $ghtml;
    initProgram('admin');
    $p = parse_opt($argv);
    if (isset($p['clear-existing'])) {
        $sq = new Sqlite(null, "driver");
        $sq->rawQuery("delete from driver");
    }
    $list = $login->getList('pserver');
    foreach ($list as $l) {
        $l->getandWriteModuleDriver();
    }
}
Exemplo n.º 8
0
function schedulebackup_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    $progname = $sgbl->__var_program_name;
    initProgram('admin');
    $login->loadAllBackups();
    $list = $login->lxbackup_l;
    foreach ($list as $l) {
        $l->backupstage = 'done';
        $l->setUpdateSubaction();
        $l->write();
        if ($l->parent_clname !== $login->getClName() && !$l->priv->isOn('backupschedule_flag')) {
            continue;
        }
        if ($l->getParentClass() === 'domain') {
            continue;
        }
        if (!$l->backupschedule_type) {
            continue;
        }
        if ($l->backupschedule_type === 'disabled') {
            continue;
        }
        if ($l->backupschedule_type === 'weekly' && date('D') !== 'Sun') {
            continue;
        }
        if ($l->backupschedule_type === 'monthly' && date('d') !== '01') {
            continue;
        }
        /*
        	try {
        		$param['backup_to_file_f'] = "$progname-scheduled";
        		$param['upload_to_ftp'] = $l->upload_to_ftp;
        		$backup = $l;
        		$object = $l->getParentO();
        		$backup->doupdateBackup($param);
        		$backup->backupstage = 'done';
        	} catch (exception $e) {
        		$mess = "{$e->__full_message}\n";
        		$backup->backupstage = "Failed due to: $mess";
        		lx_mail($progname, $object->contactemail, "Backup Failed..", "Backup Failed for $object->nname with the Message $mess");
        	}
        */
        $class = $l->getParentClass();
        $name = $l->getParentName();
        $fname = "{$progname}-scheduled";
        print "Scheduling for {$class} {$name}\n";
        lxshell_return("__path_php_path", "../bin/common/backup.php", "--class={$class}", "--name={$name}", "--v-backup_file_name={$fname}");
    }
}
Exemplo n.º 9
0
function header_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    initProgram();
    initLanguage();
    initLanguageCharset();
    // Load default skin or feather skin
    if ($login->isDefaultSkin()) {
        include_once "lib/default_header.php";
        CreateDefaultHeaderMenu();
    } else {
        print_header();
    }
}
Exemplo n.º 10
0
function install_main()
{
    global $gbl, $login, $ghtml;
    try {
        initProgram("admin");
        ob_end_flush();
        create_servername();
        add_client_template();
        add_customer_reseller();
        add_domain_list();
        $login->was();
    } catch (Exception $e) {
        print $e->getMessage();
        print "\\n\n\n\n\n\n\n\n\n\nn\n";
    }
    print "\n";
}
Exemplo n.º 11
0
function header_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    initProgram();
    init_language();
    print_open_head_tag();
    print_meta_tags();
    print_meta_css();
    if ($login->isDefaultSkin()) {
        print "<!-- Default Theme -->\n";
        print_header_default();
    } else {
        print_close_head_tag();
        print "<!-- Feather Theme -->\n";
        print_header_feather();
    }
    print "</body>\n</html>\n";
}
Exemplo n.º 12
0
function database_main()
{
    global $argc, $argv;
    global $gbl, $login, $ghtml;
    initProgram('admin');
    if ($argv[1] == 'exec') {
        $db = new Sqlite(null, 'client');
        $res = $db->rawQuery($argv[2]);
        foreach ($res as &$r) {
            foreach ($r as $k => &$__r) {
                if (csb($k, "ser_")) {
                    $__r = unserialize(base64_decode($__r));
                }
            }
        }
        print_r($res);
        exit;
    }
}
Exemplo n.º 13
0
function commandline_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    global $argv;
    initProgram('admin');
    $must = array('action');
    $p = parse_opt($argv);
    $pk = array_keys($p);
    foreach ($must as $m) {
        if (!array_search_bool($m, $pk)) {
            print "Need action, class and name\n";
            exit;
        }
    }
    $func = "__cmd_desc_{$p['action']}";
    try {
        $list = $func($p);
        if ($list) {
            if (isset($p['output-type'])) {
                if ($p['output-type'] === 'json') {
                    $out = json_encode($list);
                    print $out;
                } else {
                    if ($p['output-type'] === 'serialize') {
                        $out = serialize($list);
                        print $out;
                    }
                }
            } else {
                foreach ($list as $l) {
                    print "{$l}\n";
                }
            }
        } else {
            print "{$p['action']} succesfully executed\n";
        }
        exit(0);
    } catch (exception $e) {
        print $e->__full_message;
        print "\n";
        exit(8);
    }
}
Exemplo n.º 14
0
function logout_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    initProgram();
    clear_all_cookie();
    $cl = $login->getList("ssession");
    Utmp::updateUtmp($gbl->c_session->nname, $login, "Logout");
    $gbl->c_session->delete();
    $gbl->c_session->was();
    if ($gbl->c_session->ssl_param) {
        $ghtml->print_redirect($gbl->c_session->ssl_param['backurl']);
    } else {
        if ($gbl->c_session->consuming_parent) {
            $ret = $gbl->getSessionV('return_url');
            $ghtml->print_redirect($ret);
        } else {
            $ghtml->print_redirect_self("/login/");
        }
    }
}
Exemplo n.º 15
0
function lpanel_main()
{
    global $gbl, $login, $ghtml;
    initProgram();
    init_language();
    print_open_head_tag();
    print_meta_tags();
    print_meta_css();
    print_meta_css_lpanel();
    $gbl->__navigmenu = null;
    $gbl->__navig = null;
    $catched = false;
    $ghtml->print_include_jscript('left_panel');
    $ghtml->print_jscript_source("/htmllib/js/lpanel-tabs.js");
    try {
        $ghtml->tab_vheight();
    } catch (exception $e) {
        print_close_head_tag();
        print "<body>\n";
        print "The Resource List could not gathered....{$e->getMessage()}<br> \n";
        $catched = true;
    }
    if (!$catched) {
        print_close_head_tag();
        print "<body>\n";
    }
    // The div id's tabs1 script markup tree-div tab-content are generated from lpanel-tabs.js
    print "<div class=\"lpanelmain\" id=\"tabs1\">\n";
    print "<div id=\"script\" class=\"lpanelnormal tab-content\">\n";
    print "<br>\n";
    $ghtml->xp_panel($login);
    print "</div>\n";
    print "<div id=\"markup\" class=\"tab-content\">\n";
    print "<div id=\"tree-div\" class=\"lpaneltree\">\n";
    print "</div>\n";
    print "</div>\n";
    print "</div>\n";
    print "</body>\n";
    print "</html>\n";
}
Exemplo n.º 16
0
function monitor_child()
{
    global $gbl, $sgbl, $login, $ghtml;
    global $global_reminder;
    initProgram('admin');
    $login->loadAllObjects('client');
    $login->loadAllObjects('vps');
    $cllist = $login->getList('client');
    $vpslist = $login->getList('vps');
    $clist = lx_array_merge(array($cllist, $vpslist));
    foreach ($clist as $c) {
        $downlist = null;
        $mlist = $c->getList('monitorserver');
        if (!$mlist) {
            continue;
        }
        foreach ($mlist as $ml) {
            $plist = $ml->getList('monitorport');
            $eidlist = $ml->getList('emailalert');
            $nidlist = $c->getList('emailalert');
            $rlist = lx_array_merge(array($nidlist, $eidlist));
            $portlist = process_port($rlist, $plist);
            if ($portlist) {
                $text = file_get_contents("../file/mailalert.txt");
                $text = str_replace("%port%", implode(" ", $portlist), $text);
                $text = str_replace("%server%", $ml->servername, $text);
                foreach ($rlist as $eid) {
                    if (time() - $eid->last_sent > $eid->period * 60) {
                        log_message("Sending mail to {$eid->emailid} about {$ml->servername} at " . time());
                        $global_reminder[$eid->emailid][] = array("s", $text);
                        $eid->last_sent = time();
                        $eid->setUpdateSubaction();
                        $eid->write();
                    }
                }
            }
        }
    }
}
Exemplo n.º 17
0
function init_main($admin_pass)
{
    global $gbl, $sgbl, $login, $ghtml;
    try {
        add_admin($admin_pass);
        initProgram("admin");
        create_servername();
        //create_default_template();
        $login->was();
        createDnsTemplate();
        Ticket::createWelcomeTicket();
        /*
        	if (lxfile_exists("__path_program_etc/license.txt")) {
        		decodeAndStoreLicense();
        		$login->license_o->write();
        		$login->write();
        	}
        */
    } catch (Exception $e) {
        print $e->getMessage();
        print "\\n\n\n\n\n\n\n\n\n\nn\n";
    }
    print "\n";
}
Exemplo n.º 18
0
function backup_main()
{
    global $argc, $argv;
    global $gbl, $login, $ghtml;
    $gbl->__restore_flag = true;
    if ($argc === 1) {
        print "Usage: {$argv['0']} --restore/--list --accounts='domain-<domain1.com>,client-<client1>,domain-<domain2.com>' <backup-file> [--switchserverlist='oldserver1:newserver1,oldserver2:newserver2']\n Use --accounts=all to restore everything.\n";
        exit;
    }
    initProgram("admin");
    $object = $login;
    $opt = parse_opt($argv);
    if (isset($opt['class']) && isset($opt['name'])) {
        $object = new $opt['class'](null, null, $opt['name']);
        $object->get();
        if ($object->dbaction === 'add') {
            log_error("{$opt['class']} doesnt exist");
            print "{$opt['class']} doesnt exist\n";
            exit;
        }
    }
    $class = $opt['class'];
    $name = $opt['name'];
    if (lx_core_lock("{$class}-{$name}.restore")) {
        print "Another Restore for the same class is happening..\n";
        exit;
    }
    $backup = $object->getObject('lxbackup');
    if (isset($opt['switchserverlist'])) {
        $sq = new Sqlite(null, "pserver");
        $serverlist = $sq->getTable();
        $serverlist = get_namelist_from_arraylist($serverlist);
        $server = $opt['switchserverlist'];
        $list = explode(",", $server);
        foreach ($list as $l) {
            if (!$l) {
                continue;
            }
            $q = explode(":", $l);
            $rlist[$q[0]] = $q[1];
            if (!array_search_bool($q[1], $serverlist)) {
                print "The server {$q[1]} doesn't exist in the server system here\n";
                exit;
            }
        }
        $param['switchserverlist'] = $rlist;
        dprint("\n");
    } else {
        $param['switchserverlist'] = null;
    }
    /*
    	if (!testAllServersWithMessage()) {
    		$backup->restorestage = "Failed due to: could not connect to slave servers";
    		clearLxbackup($backup);
    		exit;
    	}
    */
    $file = $opt['final'];
    //$param = get_variable($opt);
    if (isset($opt['list'])) {
        $gbl->__var_list_flag = true;
        $param['_accountselect'] = null;
    } else {
        if (isset($opt['restore'])) {
            $gbl->__var_list_flag = false;
            if (!isset($opt['accounts'])) {
                print "Restore option needs accounts that are to be restored. --accounts='domain-domain.com,client:clientname'... Use --list to find out all the domain/clients in the backup archive.\n";
                clearLxbackup($backup);
                exit;
            }
            $account = $opt['accounts'];
            //$account = str_replace(":", "_s_vv_p_", $account);
            $account = str_replace(":", "-", $account);
            $accountlist = explode(",", $account);
            $param['_accountselect'] = $accountlist;
        } else {
            print "Usage: {$argv['0']} <--list/--restore --accounts=> <filename>\n";
            clearLxbackup($backup);
            exit;
        }
    }
    if (isset($opt['priority']) && $opt['priority'] === 'low') {
        sleep(20);
    }
    dprintr($param);
    //dprint($file);
    try {
        $backup->doUpdateRestore($file, $param);
        $backup->restorestage = 'done';
    } catch (exception $e) {
        log_error("Restore Failed. Reason: {$e->__full_message} \n");
        print "Restore Failed. Reason: {$e->__full_message} \n";
        $mess = $e->__full_message;
        mail($object->contactemail, "Restore Failed..", "Restore Failed for {$object->nname} with the Message {$mess}");
        $backup->restorestage = "Restore failed due to {$mess}";
    }
    clearLxbackup($backup);
}
Exemplo n.º 19
0
<?php

ob_start();
initProgram();
init_language();
check_if_disabled_and_exit();
$gbl->__inside_ajax = true;
// We need to convert the tree format to frm_o_o.
if ($ghtml->frm_action === 'tree') {
    convert_tree_to_frm_o();
}
createPrincipleObject();
$cgi_action = "__ajax_desc_{$ghtml->frm_action}";
//sleep(6);
$ret = $cgi_action();
while (@ob_end_clean()) {
}
print json_encode($ret);
flush();
function convert_tree_to_frm_o()
{
    global $gbl, $sgbl, $login, $ghtml;
    $cid = $ghtml->node;
    if (!csa($cid, "&")) {
        return null;
    }
    $cid = trim($cid, "/&");
    $dlist = explode("&", $cid);
    $i = 0;
    $ghtml->__title_function = false;
    $ghtml->__resource_class = false;
Exemplo n.º 20
0
 static function process_paypal($list)
 {
     initProgram('admin');
     $sq = new Sqlite(null, 'paymentdetail');
     $r = paymentdetail__paypal::createPaymentDetail($list);
     if (self::checkIftransactionExists($r['transactionid'])) {
         log_log("paypal_billing", "Transactionid {$r['transactionid']} already exists\n");
         return;
     }
     $i = 0;
     while (true) {
         $r['nname'] = implode("___", array($r['client'], $r['month'], $i));
         if (!$sq->getRowsWhere("nname = '{$r['nname']}'")) {
             break;
         }
         $i++;
     }
     $r['parent_clname'] = createParentName('client', $r['client']);
     $cl = new Client(null, null, $r['client']);
     $cl->get();
     if (!$cl->isOn('status')) {
         $cl->updateEnable(null);
         $cl->was();
     }
     $payp = new paymentDetail(null, null, $r['nname']);
     $r['complete_detail'] = $list;
     $r['paymentgw'] = 'paypal';
     $payp->create($r);
     $payp->write();
     log_log("paypal_billing", "saved the payment detail {$p->nname}");
 }
Exemplo n.º 21
0
function updatecleanup_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    $program = $sgbl->__var_program_name;
    $opt = parse_opt($argv);
    if ($opt['type'] === 'master') {
        initProgram('admin');
        $flg = "__path_program_start_vps_flag";
        if (!lxfile_exists($flg)) {
            set_login_skin_to_feather();
        }
    } else {
        $login = new Client(null, null, 'update');
    }
    log_cleanup("*** Executing Update (cleanup) - BEGIN ***");
    //
    // Check for lxlabs yum repo file and if exists
    // Change to lxcenter repo file
    //
    if (lxfile_exists("/etc/yum.repos.d/lxlabs.repo")) {
        log_cleanup("- Deleting old lxlabs yum repo");
        lxfile_mv("/etc/yum.repos.d/lxlabs.repo", "/etc/yum.repos.d/lxlabs.repo.lxsave");
        exec("rm -f /etc/yum.repos.d/lxlabs.repo");
        log_cleanup("- Removed lxlabs.repo");
        log_cleanup("- Installing lxcenter.repo");
        exec("wget -O /etc/yum.repos.d/lxcenter.repo http://download.lxcenter.org/lxcenter.repo");
        log_cleanup("- Installing yum-protectbase plugin");
        exec("yum install -y -q yum-protectbase");
    }
    // Fix #388 - phpMyAdmin config.inc.php permission
    $correct_perm = "0644";
    $check_perm = substr(decoct(fileperms("/usr/local/lxlabs/{$program}/httpdocs/thirdparty/phpMyAdmin/config.inc.php")), 2);
    if ($check_perm != $correct_perm) {
        lxfile_unix_chmod("/usr/local/lxlabs/{$program}/httpdocs/thirdparty/phpMyAdmin/config.inc.php", "0644");
    }
    //
    if (lxfile_exists(".svn")) {
        log_cleanup("- SVN Found... Exiting");
        exit;
    }
    if ($opt['type'] === 'master') {
        $sgbl->slave = false;
        if (!is_secondary_master()) {
            updateDatabaseProperly();
            fixDataBaseIssues();
            doUpdates();
            lxshell_return("__path_php_path", "../bin/common/driverload.php");
        }
        update_all_slave();
        cp_dbfile();
    } else {
        $sgbl->slave = true;
    }
    if (!is_secondary_master()) {
        updatecleanup();
    }
    if ($opt['type'] === 'master') {
        lxfile_touch("__path_program_start_vps_flag");
    }
    // issue #716 -- [beta] Unresolved dependency on Apache version
    // --- remove httpd-itk rpm (from webtatic.repo or others) because may conflict with
    // httpd 2.2.21 that include mpm itk beside mpm worker and event
    exec("rpm -q httpd-itk | grep -i 'not installed'", $out, $ret);
    // --- not work with !$ret
    if ($ret !== 0) {
        log_cleanup("Remove httpd-itk rpm package");
        log_cleanup("- Remove httpd-itk");
        exec("rpm -e httpd-itk --nodeps");
        exec("rpm -q httpd | grep -i 'not installed'", $out2, $ret2);
        if ($ret2 === 0) {
            log_cleanup("- Reinstall httpd");
            exec("yum reinstall httpd -y");
        }
    }
    // MR -- mysql not start after kloxo slave install
    log_cleanup("Preparing MySQL service");
    log_cleanup("- MySQL activated");
    exec("chkconfig mysqld on");
    log_cleanup("- MySQL restarted");
    exec("service mysqld restart");
    // MR -- importance for update from 6.1.6 or previous where change apache/lighttpd structure
    // or others for next version
    $slist = array("httpd*", "lighttpd*", "bind*", "djbdns*", "pure-ftpd*", "php*", "vpopmail", "courier-imap-toaster", "courier-authlib-toaster", "qmail", "safecat", "spamassassin", "bogofilter", "ezmlm-toaster", "autorespond-toaster", "clamav-toaster");
    setUpdateServices($slist);
    // MR -- use this trick for qmail non-daemontools based
    log_cleanup("Preparing some services again");
    log_cleanup("- courier-imap enabled and restart queue");
    exec("chkconfig courier-imap on");
    createRestartFile("courier-imap");
    log_cleanup("- qmail enabled and restart queue");
    exec("chkconfig qmail on");
    createRestartFile("qmail");
    $fixapps = array("dns", "web", "php", "mail", "ftpuser", "vpop");
    setUpdateConfigWithVersionCheck($fixapps, $opt['type']);
    // --- for anticipate change xinetd listing
    exec("service xinetd restart");
}
Exemplo n.º 22
0
function run_mail_to_ticket()
{
    global $gbl, $sgbl, $login, $ghtml;
    if (!$sgbl->is_this_master()) {
        return;
    }
    if (!$login) {
        initProgram('admin');
    }
    $ob = $login->getObject('ticketconfig');
    if (!$ob->isOn('mail_enable')) {
        return;
    }
    $portstring = null;
    $sslstring = null;
    if ($ob->isOn('mail_ssl_flag')) {
        $portstring = "and port 995";
        $sslstring = "with ssl";
    }
    $string = <<<FTC
set postmaster "postmaster"
set bouncemail
set properties ""
poll {$ob->mail_server} with proto POP3 {$portstring} user '{$ob->mail_account}' password '{$ob->mail_password}' is root here mda "lphp.exe ../bin/common/mailtoticket.php" options fetchall {$sslstring}
FTC;
    $tmp = lx_tmp_file("fetch");
    lfile_put_contents($tmp, $string);
    lxfile_generic_chown($tmp, "root:root");
    lxfile_generic_chmod($tmp, "0710");
    //system("pkill -f fetchmail");
    //sleep(10);
    exec_with_all_closed("fetchmail -d0 -e 15 -f {$tmp}; rm {$tmp}");
    //sleep(20);
    //lunlink($tmp);
}
Exemplo n.º 23
0
function filltraffictable()
{
    global $gbl, $login, $ghtml;
    initProgram('admin');
    $login->loadAllObjects('client');
    $clist = $login->getList('client');
    $t = "";
    // Fake domain to store the time the last stats finding was done.
    $laccessdom = new Domain(null, null, '__last_access_domain_');
    try {
        $laccess = $laccessdom->getFromList('domaintraffic', '__last_access_domain_');
    } catch (exception $e) {
        dprint("not getting\n");
        $laccess = null;
    }
    if (!$laccess) {
        $laccess = new Domaintraffic(null, null, '__last_access_domain_');
        $oldtime = 0;
        $laccess->parent_clname = 'domain-__last_access_domain_';
        $laccess->dbaction = 'add';
    } else {
        $oldtime = $laccess->timestamp;
    }
    if ($oldtime && time() - $oldtime > 12 * 3600 * 24) {
        $oldtime = time() - 12 * 3600 * 24;
        $laccess->timestamp = $oldtime;
        $laccess->setUpdateSubaction();
        $laccess->write();
    }
    foreach ($clist as $c) {
        $domlist = $c->getList('domain');
        foreach ((array) $domlist as $domain) {
            if (!$domain->isDomainVirtual()) {
                continue;
            }
            $web = $domain->getObject('web');
            $mmail = $domain->getObject('mmail');
            $globaldomlist[$domain->nname] = $domain;
            $weblist[$web->syncserver][] = $domain;
            $mmaillist[$mmail->syncserver][] = $mmail;
        }
    }
    $flag = 0;
    if ($oldtime == 0) {
        // 8 days back
        $oldtime = @mktime(00, 01, 00, date("n"), date("j") - 10, date("Y"));
        // Start of Jan
        //$oldtime  =  mktime( 00 , 01, 00 , 1 ,1, date("Y"));
        $flag = 1;
    }
    // $newtime =   mktime( 00 , 01, 00 , date("n")  , date("j")  ,date("Y"));
    $newtime = time();
    $old = $oldtime;
    $new = $newtime;
    if ($newtime - $oldtime >= 19 * 60 * 60) {
        if ($flag == 1) {
            $old = @mktime(00, 01, 00, @date("n"), @date("j"), @date("Y"));
            $timearray[0] = $newtime . "-" . $old;
            $newtime = $old;
        }
        $j = 0;
        for ($i = $newtime; $i >= $oldtime; $i -= 24 * 60 * 60) {
            if ($j > 0) {
                $timearray[] = $new . "-" . $i;
            }
            $new = $i;
            $j++;
        }
        if ($flag != 1) {
            $timearray[] = "{$new}-{$oldtime}";
        }
        $timearray = array_reverse($timearray);
        foreach ($timearray as $t1) {
            $t = explode("-", $t1);
            $newtime = $t[0];
            $oldtime = $t[1];
            if ($newtime - $oldtime < 4 * 60 * 60) {
                continue;
            }
            $o = @strftime("%c", $oldtime);
            $n = @strftime("%c", $newtime);
            print "\n\n{$o}  to ... {$n}\n\n";
            findtraffic($weblist, $mmaillist, $globaldomlist, $oldtime, $newtime);
            $laccess->timestamp = $newtime;
            $laccess->setUpdateSubaction();
            $laccess->write();
        }
        // This is the time at which this was run last time.
        $laccess->timestamp = time();
        $laccess->setUpdateSubaction();
        $laccess->write();
    } else {
        dprint("Less than a day:");
        dprint("\n\n\n\n");
    }
}
Exemplo n.º 24
0
function help_main()
{
    global $gbl, $login, $ghtml;
    initProgram();
    print_help_header();
    $gbl->__c_object = null;
    $ghtml->print_middle_start();
    print "<table height=100% valign=top cellspacing=0 cellpadding=0> <tr valign=top> <td width=200 height=100% bgcolor=#acacff align=center>";
    print "<table> <tr height=10> <td > </td></tr>";
    print "<tr> <td ><a href=/htmllib/mibin/help.php?frm_action=tutorial> Tutorial </a> </td></tr>";
    print " <tr> <td ><a href=/htmllib/mibin/help.php?frm_action=faq> FAQ </a> </td></tr>";
    print "</td></tr></table>";
    print " </td> <td >&nbsp;  </td> <td > ";
    //print_alternate_header();
    __ac_desc_show();
    print "</td> </tr> </table> ";
    $ghtml->print_end();
}
Exemplo n.º 25
0
function display_init()
{
    global $gbl, $sgbl, $login, $ghtml;
    initProgram();
    initLanguage();
    if ($sgbl->is_this_slave()) {
        print "This is a Slave Server. You control it at the Master Server.\n";
        exit;
    }
    // The only thing that gets modified when the dbaction is not a modify action, is the ssession table. Other tables should get modified only inside non-form actions.
    if (isModifyAction() && isUpdating()) {
        $ghtml->print_redirect_back('system_is_updating_itself', '');
        exit;
    }
    try {
        do_display_init();
        main_system_lock();
        print_navigation($gbl->__navig);
        if (if_demo()) {
            //$url = $ghtml->get_get_from_current_post(null);
            //log_clicks($url);
        }
        print_warning();
        password_contact_check();
    } catch (Exception $e) {
        log_log("redirect_error", "exception");
        $gbl->setSessionV('__tmp_redirect_var', $ghtml->__http_vars);
        $gbl->c_session->write();
        if (is_array($e->variable)) {
            $evlist = implode(",", $e->variable);
        } else {
            $evlist = $e->variable;
        }
        $ghtml->print_redirect_back($e->getMessage(), $evlist, $e->value);
        exit;
    }
    //license_check();
    if ($ghtml->frm_filter) {
        $filtername = $gbl->__c_object->getFilterVariableForThis($ghtml->frm_o_cname);
        $list[$filtername] = $ghtml->frm_filter;
        $login->setupHpFilter($list);
        $login->setUpdateSubaction();
    }
    if ($ghtml->frm_hpfilter) {
        //dprintr($ghtml->frm_hpfilter);
        $login->setupHpFilter($ghtml->frm_hpfilter);
        $login->setUpdateSubaction();
    }
}
Exemplo n.º 26
0
function filltraffictable()
{
    global $gbl, $login, $ghtml;
    initProgram('admin');
    $t = "";
    // Fake domain to store the time the last stats finding was done.
    $laccessdom = new Vps(null, null, '__last_access_domain_');
    try {
        $laccess = $laccessdom->getFromList('vpstraffic', '__last_access_domain_');
    } catch (exception $e) {
        dprint("not getting\n");
        $laccess = null;
    }
    if (!$laccess) {
        $laccess = new Vpstraffic(null, null, '__last_access_domain_');
        $oldtime = 0;
        $laccess->parent_clname = 'vps-__last_access_domain_';
        $laccess->dbaction = 'add';
    } else {
        $oldtime = $laccess->timestamp;
    }
    if ($oldtime && time() - $oldtime > 5 * 3600 * 24) {
        $oldtime = time() - 5 * 3600 * 24;
        $laccess->timestamp = $oldtime;
        $laccess->setUpdateSubaction();
        $laccess->write();
    }
    $flag = 0;
    if ($oldtime == 0) {
        // 8 days back
        $oldtime = @mktime(00, 01, 00, date("n"), date("j") - 2, date("Y"));
        // Start of Jan
        //$oldtime  =  mktime( 00 , 01, 00 , 1 ,1, date("Y"));
        $flag = 1;
    }
    // $newtime =   mktime( 00 , 01, 00 , date("n")  , date("j")  ,date("Y"));
    $newtime = time();
    $old = $oldtime;
    $new = $newtime;
    if ($newtime - $oldtime <= 19 * 60 * 60) {
        dprint("Less than a day:");
        dprint("\n\n\n\n");
        return;
    }
    $j = 0;
    for ($i = $newtime; $i >= $oldtime; $i -= 24 * 60 * 60) {
        if ($j > 0) {
            $timearray[] = $new . "-" . $i;
        }
        $new = $i;
        $j++;
    }
    if ($flag != 1) {
        $timearray[] = $new . "-" . $oldtime;
    }
    $timearray = array_reverse($timearray);
    foreach ($timearray as $t1) {
        $t = explode("-", $t1);
        $newtime = $t[0];
        $oldtime = $t[1];
        if ($newtime - $oldtime < 4 * 60 * 60) {
            continue;
        }
        $o = @strftime("%c", $oldtime);
        $n = @strftime("%c", $newtime);
        print "\n\n{$o}  to ... {$n}\n\n";
        findtraffic($oldtime, $newtime);
        // Write every time, otherwise, the traffic calculation breaks off in the middle, it will be left inconsistent.
        $laccess->timestamp = $newtime;
        $laccess->setUpdateSubaction();
        $laccess->write();
    }
    // This is the time at which this was run last time.
    $laccess->timestamp = time();
    $laccess->setUpdateSubaction();
    $laccess->write();
}
Exemplo n.º 27
0
function convert_ipaddress()
{
    global $gbl, $sgbl, $login, $ghtml;
    initProgram('admin');
    $login->loadAllVps();
    $vpslist = $login->getList('vps');
    foreach ($vpslist as $vps) {
        if (isset($vps->vmipaddress_a) && is_array($vps->vmipaddress_a)) {
            continue;
        }
        $iplist = $vps->getList('vpsipaddress');
        $vpsinternalip = null;
        foreach ($iplist as $ip) {
            $internalip = new vmipaddress_a(null, null, $ip->ipaddress);
            $vpsinternalip[$internalip->nname] = $internalip;
        }
        $vps->vmipaddress_a = $vpsinternalip;
        $vps->setUpdateSubaction();
        $vps->write();
    }
}
Exemplo n.º 28
0
function main_main()
{
    global $gbl, $login, $ghtml;
    initProgram();
    domainshow();
    /*
    if ($gbl->isOn('split_frame')) {
    	$gbl->setSessionV('split_frame', 'off');
    } else {
    	$gbl->setSessionV('split_frame', 'on');
    }
    $gbl->c_session->write();
    */
}
Exemplo n.º 29
0
<?php

include_once "htmllib/lib/include.php";
$global_dontlogshell = true;
exit_if_another_instance_running();
// Selfbackup
passthru("{$sgbl->__path_php_path} ../bin/common/mebackup.php");
passthru("{$sgbl->__path_php_path} ../bin/gettraffic.php");
passthru("{$sgbl->__path_php_path} ../bin/collectquota.php");
passthru("{$sgbl->__path_php_path} ../bin/common/schedulebackup.php");
passthru("{$sgbl->__path_php_path} ../bin/fix/fixippool.php");
passthru("{$sgbl->__path_php_path} ../bin/common/clearsession.php");
initProgram('admin');
checkClusterDiskQuota();
// If auto-update is on check for new HyperVM Version when
// the update day is reached
auto_update();
// Rotate HyperVM logs
passthru("{$sgbl->__path_php_path} ../bin/common/fixlogdir.php");
Exemplo n.º 30
0
function switchserver_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    //sleep(60);
    initProgram("admin");
    if ($argc === 1) {
        print "Usage: {$argv['0']} --class= --name= --v-syncserver= \n";
        exit;
    }
    try {
        $opt = parse_opt($argv);
        $param = get_variable($opt);
        dprintr($param);
        $class = $opt['class'];
        $name = $opt['name'];
        if (lx_core_lock("{$class}-{$name}.livemigrate")) {
            exit;
        }
        $object = new $class(null, 'localhost', $name);
        $object->get();
        if ($object->dbaction === 'add') {
            throw new lxException("no_object", '', '');
            exit;
        }
        if (!$object->syncserver) {
            print "No_synserver...\n";
            throw new lxException("no_syncserver", '', '');
            exit;
        }
        if ($param['syncserver'] === $object->syncserver) {
            print "No Change...\n";
            throw new lxException("no_change", '', '');
            exit;
        }
        $driverapp_old = $gbl->getSyncClass('localhost', $object->syncserver, $object->getClass());
        $driverapp_new = $gbl->getSyncClass('localhost', $param['syncserver'], $object->getClass());
        $oldserver = $object->syncserver;
        $newserver = $param['syncserver'];
        if ($driverapp_new !== $driverapp_old) {
            throw new lxException("the_drivers_are_different_in_two_servers", '', '');
        }
        $actualserver = getFQDNforServer($newserver);
        setup_ssh_channel($oldserver, $newserver, $actualserver);
        $ssh_port = db_get_value("sshconfig", $newserver, "ssh_port");
        if (!$ssh_port) {
            $ssh_port = "22";
        }
        $res = rl_exec_get(null, $oldserver, "exec_vzmigrate", array($object->vpsid, $actualserver, $ssh_port));
        list($ret, $error) = $res;
        if ($ret !== 0) {
            throw new lxException("vzmigrate_failed_due_to:{$error}", '', '');
        }
        $object->olddeleteflag = 'done';
        $object->syncserver = $newserver;
        $object->username = null;
        $object->makeSureTheUserExists();
        $object->setUpdateSubaction();
        $object->write();
    } catch (exception $e) {
        print $e->getMessage();
        /// hcak ahck... Chnage only the olddelete variable which is the mutex used for locking in the process of switch. The problem is we want to totally bail out if the switchserver fails. The corect way would be save after reverting the syncserve to the old value, but that's a bit risky. So we just use a hack to change only the olddeleteflag; Not a real hack.. This is the better way.
        $message = "{$e->getMessage()}";
        $message = str_replace("'", "", $message);
        write_to_object($object, $message, $param['syncserver']);
        $fullmesage = "Switch of {$object->getClass()}:{$object->nname} to {$param['syncserver']} failed due to {$e->getMessage()}";
        log_switch($fullmesage);
        mail($login->contactemail, "Switch Failed:", "{$fullmesage}\n");
        print "\n";
        exit;
    }
    mail($login->contactemail, "Switch Succeeded", "Switch Succeeded {$object->getClass()}:{$object->nname} to {$param['syncserver']}\n");
}