Exemplo n.º 1
0
 static function getServiceDetails($list)
 {
     $ps = lxshell_output("ps", "ax");
     $run = Service__linux::getRunLevel();
     $rclist = lscandir_without_dot("__path_real_etc_root/rc{$run}.d/");
     foreach ($list as &$__l) {
         $__l['install_state'] = 'dull';
         $__l['state'] = 'off';
         $__l['boot_state'] = 'off';
         if (lxfile_exists("__path_real_etc_root/init.d/{$__l['servicename']}")) {
             $__l['install_state'] = 'on';
         } else {
             continue;
         }
         if (self::checkServiceInRc($rclist, $__l['servicename'])) {
             $__l['boot_state'] = 'on';
         }
         if ($__l['grepstring']) {
             if (preg_match("/[\\/ ]{$__l['grepstring']}/i", $ps)) {
                 $__l['state'] = 'on';
             }
         } else {
             $ret = lxshell_return("/etc/init.d/{$__l['servicename']}", "status");
             if ($ret) {
                 $__l['state'] = 'off';
             } else {
                 $__l['state'] = 'on';
             }
         }
     }
     return $list;
 }
Exemplo n.º 2
0
function do_server_stuff()
{
    global $gbl, $sgbl, $login, $ghtml;
    if (if_demo()) {
        return;
    }
    try {
        timed_execution();
        if ($sgbl->is_this_master()) {
            $schour = null;
            $scminute = null;
            $timefile = "../etc/conf/scavenge_time.conf";
            if (lxfile_exists($timefile)) {
                $readvalue = file_get_contents($timefile);
                $readvalue = explode(" ", $readvalue);
                $schour = $readvalue['0'];
                $scminute = $readvalue['1'];
            }
            log_log("cron_exec", "Initialize Scavenge Cronjob");
            if ($schour) {
                cron_exec($schour, $scminute, "exec_scavenge");
            } else {
                cron_exec("03", "35", "exec_scavenge");
            }
        }
    } catch (exception $e) {
        print "Caught Exception: ";
        print $e->getMessage();
        print "\n";
    }
}
Exemplo n.º 3
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.º 4
0
 function get()
 {
     if (!lxfile_exists("__path_program_root/session/{$this->nname}")) {
         $this->dbaction = 'add';
         return;
     }
     $rmt = lfile_get_json_unserialize("__path_program_root/session/{$this->nname}");
     $this->modify($rmt, 'clean');
     $this->dbaction = 'clean';
 }
Exemplo n.º 5
0
function change_lxadmin_to_kloxo_directory($dir)
{
    if (!lxfile_exists($dir)) {
        return;
    }
    $list = lscandir_without_dot_or_underscore($dir);
    foreach ($list as $l) {
        change_lxadmin_to_kloxo("{$dir}/{$l}");
    }
}
Exemplo n.º 6
0
function collectdata_main()
{
    if (lxfile_exists("/proc/xen") && lxfile_exists("/usr/sbin/xm")) {
        vps__xen::find_traffic();
        vps__xen::find_cpuusage();
    }
    if (lxfile_exists("/proc/vz")) {
        vps__openvz::find_traffic();
        vps__openvz::find_cpuusage();
        vps__openvz::find_memoryusage();
    }
}
Exemplo n.º 7
0
 function dbactionAdd()
 {
     global $gbl, $sgbl, $login, $ghtml;
     lxfile_mkdir("__path_client_root/{$this->main->nname}");
     lxfile_mkdir("__path_client_root/{$this->main->nname}/__backup");
     lxfile_generic_chown("__path_client_root/{$this->main->nname}", "lxlabs");
     lxfile_generic_chown("__path_client_root/{$this->main->nname}/__backup", "lxlabs");
     if (lxfile_exists("__path_customer_root/{$this->main->getPathFromName()}")) {
         throw new lxException("directory_already_exists", '', '');
     }
     $ret = $this->createUser();
     $this->setupDefaultDomain();
     return $ret;
 }
Exemplo n.º 8
0
function installapp_data_update()
{
    print fill_string("Fetch current InstallApp version", 50);
    $string = file_get_contents("http://download.lxcenter.org/download/installapp/version.list");
    $rmt = unserialize($string);
    if (!$rmt) {
        throw new lxexception(" could_not_get_application_version_list", '', "");
    }
    print " OK ";
    $remver = $rmt->applist['installapp'];
    print "version is {$remver}\n";
    if (lxfile_exists("/home/kloxo/httpd/installappdata")) {
        print fill_string("Fetch local InstallApp version", 50);
        $loc = get_local_application_version_list();
        $locver = $loc->applist['installapp'];
        print " OK version is {$locver}\n";
        if ($remver != $locver) {
            print fill_string("New installapp found", 50);
            print " OK\n";
        }
    }
    print fill_string("Checking for old installappdata.zip", 50);
    if (lxfile_exists("/tmp/installappdata.zip")) {
        lxfile_rm("/tmp/installappdata.zip");
    }
    print " OK\n";
    print fill_string("Downloading InstallApp data...", 50);
    system("cd /tmp ; wget -q http://download.lxcenter.org/download/installapp/installappdata.zip");
    if (!lxfile_exists("/tmp/installappdata.zip")) {
        print " ERROR\n";
        print "Could not download data from LxCenter.\nAborted.\n\n";
        return;
    }
    print " OK\n";
    print fill_string("Remove old InstallApp data", 50);
    //      lxfile_rm_rec("__path_kloxo_httpd_root/installappdata");
    //      lxfile_mkdir("__path_kloxo_httpd_root/installappdata");
    lxfile_rm_rec("/home/kloxo/httpd/installappdata");
    lxfile_mkdir("/home/kloxo/httpd/installapp");
    lxfile_mkdir("/home/kloxo/httpd/installappdata");
    print " OK\n";
    print fill_string("Unpack new InstallApp data", 50);
    //      lxshell_unzip("lxlabs", "__path_kloxo_httpd_root/installappdata/", "/tmp/installappdata.zip");
    system("cd /home/kloxo/httpd/installappdata ; unzip -qq /tmp/installappdata.zip");
    print " OK\n";
    print fill_string("Remove downloaded InstallApp data zip file", 50);
    lxfile_rm("/tmp/installappdata.zip");
    print " OK\n";
}
Exemplo n.º 9
0
 static function generateGraph($oldtime, $newtime)
 {
     global $global_dontlogshell;
     $oldv = $global_dontlogshell;
     $global_dontlogshell = true;
     $list = lscandir_without_dot("__path_httpd_root");
     foreach ($list as $l) {
         if (!lxfile_exists("__path_httpd_root/{$l}/stats")) {
             continue;
         }
         $total = webtraffic::getEachwebfilequota("__path_httpd_root/{$l}/stats/{$l}-custom_log", $oldtime, $newtime);
         execRrdSingle("webtraffic", "ABSOLUTE", $l, $total * 1024 * 1024);
     }
     $global_dontlogshell = $oldv;
 }
Exemplo n.º 10
0
function lxfile_rm_rec($file)
{
    $obj = new COM("Scripting.FilesystemObject");
    $file = expand_real_root($file);
    $file = remove_extra_slash($file);
    $list = explode("/", $file);
    if (count($list) <= 2) {
        throw new lxException('recursive_removal_low_level_directories_not_allowed', '');
    }
    if (lxfile_exists($file)) {
        if (is_dir($file)) {
            $obj->deleteFolder($file);
        } else {
            $obj->deleteFile($file);
        }
    }
}
Exemplo n.º 11
0
function scavenge_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    log_scavenge("Fix log dir");
    passthru("{$sgbl->__path_php_path} ../bin/common/fixlogdir.php");
    log_scavenge("### Starting Scavenge");
    initProgramlib('admin');
    uploadStatsLxCenter();
    if (lxfile_exists("../etc/conf/scavenge_time.conf")) {
        log_scavenge("Found scavenge_time.conf");
    }
    log_scavenge("Collect Traffic");
    passthru("{$sgbl->__path_php_path} ../bin/gettraffic.php");
    log_scavenge("Collect Quota");
    passthru("{$sgbl->__path_php_path} ../bin/collectquota.php");
    log_scavenge("Schedule backups");
    passthru("{$sgbl->__path_php_path} ../bin/common/schedulebackup.php");
    log_scavenge("Clear Sessions");
    passthru("{$sgbl->__path_php_path} ../bin/common/clearsession.php");
    log_scavenge("Self backup");
    passthru("{$sgbl->__path_php_path} ../bin/common/mebackup.php");
    log_scavenge("Check Cluster Disk Quota");
    checkClusterDiskQuota();
    $driverapp = $gbl->getSyncClass(null, 'localhost', 'web');
    if ($driverapp === 'lighttpd') {
        log_scavenge("Restarting lighttpd");
        system("service lighttpd restart");
    }
    log_scavenge("InstallApp update");
    passthru("{$sgbl->__path_php_path} ../bin/installapp-update.phps");
    log_scavenge("Watchdog checks");
    $rs = get_all_pserver();
    foreach ($rs as $r) {
        watchdog::addDefaultWatchdog($r);
    }
    log_scavenge("Collect LxGuard info");
    lxguard::collect_lxguard();
    log_scavenge("Fix MySQL root password");
    fix_all_mysql_root_password();
    log_scavenge("Auto update Kloxo");
    auto_update();
    log_scavenge("### End Scavenge");
    // Wait at least 60 seconds before ending the scavenge
    sleep(60);
}
Exemplo n.º 12
0
 function dbactionAdd()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $dir = $this->main->__var_full_directory;
     $dir = expand_real_root($dir);
     $pass = $this->main->realpass;
     if (!$pass) {
         $pass = randomString(8);
     }
     lxshell_input("{$pass}\n{$pass}\n", "pure-pw", "useradd", $this->main->nname, "-u", $this->main->__var_username, "-d", $dir, "-m");
     if (!lxfile_exists($dir)) {
         lxfile_mkdir($dir);
         lxfile_unix_chown($dir, $this->main->__var_username);
     }
     $this->setQuota();
     // If the user is added is fully formed, this makes sure that all his properties are synced.
     $this->toggleStatus();
 }
Exemplo n.º 13
0
 function createDiruserfile()
 {
     $dir = '__path_httpd_root/' . $this->main->getParentName() . '/__dirprotect';
     $dirfile = $dir . '/' . $this->main->getFileName();
     $chownug = $this->main->__var_username . ':apache';
     if (!lxfile_exists($dir)) {
         lxuser_mkdir($chownug, $dir);
         lxfile_generic_chmod($dir, '0750');
     }
     lxfile_rm($dirfile);
     if ($this->main->status == 'on') {
         $fstr = '';
         foreach ($this->main->diruser_a as $v) {
             $fstr .= $v->nname . ':' . crypt($v->param) . "\n";
         }
         lxuser_put_contents($chownug, $dirfile, $fstr);
         lxfile_generic_chmod($dirfile, '0750');
     }
 }
Exemplo n.º 14
0
 function updateform($subaction, $param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $list = array("client");
     if ($sgbl->isHyperVm()) {
         $list = lx_array_merge(array($list, array("vps")));
     }
     $vlist['class'] = array('s', $list);
     $vlist['description'] = null;
     $vlist['url'] = null;
     $ipt = "img/custom/{$this->nname}.gif";
     if (lxfile_exists($ipt)) {
         $vlist['image'] = array('I', array('width' => 20, 'height' => 20, 'value' => $ipt));
     } else {
         $vlist['image'] = array('M', "No Image");
     }
     $vlist['upload'] = array('F', null);
     return $vlist;
 }
Exemplo n.º 15
0
function setFixUserlogoDomainPages()
{
    global $gbl, $sgbl, $login, $ghtml;
    $login->loadAllObjects('client');
    $list = $login->getList('client');
    foreach ($list as $c) {
        $clname = $c->getPathFromName('nname');
        $cdir = "/home/{$clname}";
        $dlist = $c->getList('domaina');
        foreach ((array) $dlist as $l) {
            $web = $l->nname;
            // If there is no images directory so need to create that first
            if (!lxfile_exists("{$cdir}/{$web}/images")) {
                lxfile_mkdir("{$cdir}/{$web}/images");
            }
            system("cp -rf /home/kloxo/httpd/user-logo.png {$cdir}/{$web}/images/logo.png");
            log_cleanup("- User logo for domain pages moved to -> {$cdir}/{$web}/images/logo.png");
        }
    }
}
Exemplo n.º 16
0
 static function readAuthorizedKey($username)
 {
     $p = os_get_home_dir($username);
     if ($p === '/tmp' && $username) {
         lxfile_mkdir("/home/{$username}");
         lxshell_return("usermod", "-d", "/home/{$username}", $username);
         lxfile_unix_chown_rec("/home/{$username}", "{$username}:{$username}");
         $p = "/home/{$username}";
     }
     if (!$p) {
         return;
     }
     $f = "{$p}/.ssh/authorized_keys";
     if (lxfile_exists("{$f}2")) {
         $s = lfile_get_contents("{$f}2");
         $s = "\n{$s}\n";
         lfile_put_contents($f, $s, FILE_APPEND);
         lunlink("{$f}2");
     }
     return lfile_get_contents($f);
 }
Exemplo n.º 17
0
 function syncSpamUserPref()
 {
     global $gbl, $sgbl, $ghtml;
     // The parent can be either a domain or a user. CHeck for the @ sign.
     if (csa($this->main->nname, "@")) {
         list($user, $domain) = explode("@", $this->main->nname);
     } else {
         $domain = $this->main->nname;
         $user = null;
     }
     $sysuser = mmail__qmail::getUserGroup($domain);
     // --- issue #578/#721 - missing in version 6.1.6
     //	$mailpath = "/home/lxadmin/mail";
     $mailpath = mmail__qmail::getDir($domain);
     if ($user) {
         //	$prefpath = "$mailpath/domains/{$domain}/{$user}/.bogopref.cf";
         $prefpath = "{$mailpath}/{$user}/.bogopref.cf";
     } else {
         return;
     }
     $prefdir = dirname($prefpath);
     if (!lxfile_exists(dirname($prefpath))) {
         lxuser_mkdir($sysuser, dirname($prefpath));
     }
     $wname = fix_nname_to_be_variable($this->main->nname);
     $fdata = null;
     $cutoff = $this->main->spam_hit / 10 + 0.2;
     $fdata .= "spam_cutoff  {$cutoff}\n";
     $fdata .= "spam_subject_tag={$this->main->subject_tag}\n";
     $fdata .= "wordlist R,user,{$wname}.wordlist.db,1\n";
     $fdata .= "wordlist R,system,wordlist.db,2\n";
     $fdata .= "wordlist R,system,kloxo.wordlist.db,3\n";
     lxuser_put_contents($sysuser, $prefpath, $fdata);
     if (!lxfile_real("/var/bogofilter/{$wname}.wordlist.db")) {
         new_process_cmd($sysuser, null, "bogofilter -d /var/bogofilter/ --wordlist=R,user,{$wname}.wordlist.db,1  -n < /etc/my.cnf");
     }
     lxfile_touch("/var/bogofilter/wordlist.db");
     // Using generic because spamassasin is used on windows too. Or at least can be used.
     //lxfile_generic_chown("/var/bogofilter", mmail__qmail::getUserGroup($domain));
 }
Exemplo n.º 18
0
 function dbactionUpdate($subaction)
 {
     if (if_demo()) {
         throw new lxException("demo", $v);
     }
     if ($this->main->ssh_port && !($this->main->ssh_port > 0)) {
         throw new lxException('invalid_ssh_port', 'ssh_port', '');
     }
     dprint($this->main->ssh_port);
     $this->main->ssh_port = trim($this->main->ssh_port);
     if (!$this->main->ssh_port) {
         $port = "22";
     } else {
         $port = $this->main->ssh_port;
     }
     if (lxfile_exists("/etc/fedora-release")) {
         $str = lfile_get_contents("../file/template/sshd_config-fedora-2");
     } else {
         $str = lfile_get_contents("../file/template/sshd_config");
     }
     $str = str_replace("%ssh_port%", $port, $str);
     if ($this->main->isOn('without_password_flag')) {
         $wt = 'without-password';
     } else {
         $wt = 'yes';
     }
     if ($this->main->isOn('disable_password_flag')) {
         $pwa = 'no';
     } else {
         $pwa = 'yes';
     }
     $str = str_replace("%permit_root_login%", $wt, $str);
     $str = str_replace("%permit_password%", $pwa, $str);
     $ret = lfile_put_contents("/etc/ssh/sshd_config", $str);
     if (!$ret) {
         throw new lxException('could_not_write_config_file', '', '');
     }
     exec_with_all_closed("/etc/init.d/sshd restart");
 }
Exemplo n.º 19
0
function add_line_to_secondary_mycnf($master, $slavepass)
{
    global $gbl, $sgbl, $login, $ghtml;
    if (!lxfile_exists("/etc/secondary_master.copy.my.cnf")) {
        lxfile_cp("/etc/my.cnf", "/etc/secondary_master.copy.my.cnf");
    }
    $list = lfile_trim("/etc/my.cnf");
    foreach ($list as $k => $l) {
        if (check_if_skip($l)) {
            continue;
        }
        $ll[] = $l;
        if ($l == '[mysqld]') {
            $ll[] = "server-id=2";
            $ll[] = "master-host={$master}";
            $ll[] = "master-user=lxlabsslave";
            $ll[] = "master-password={$slavepass}";
        }
    }
    lfile_put_contents("/etc/my.cnf", implode("\n", $ll));
    system("service mysqld restart");
}
Exemplo n.º 20
0
 function syncSpamUserPref()
 {
     global $gbl, $sgbl, $ghtml;
     // The parent can be either a domain or a user. CHeck for the @ sign.
     if (csa($this->main->nname, "@")) {
         list($user, $domain) = explode("@", $this->main->nname);
     } else {
         $domain = $this->main->nname;
         $user = null;
     }
     // --- issue #578/#721 - missing in version 6.1.6
     //	$mailpath = "/home/lxadmin/mail";
     $mailpath = mmail__qmail::getDir($domain);
     if ($user) {
         //	$prefpath = "$mailpath/domains/{$domain}/{$user}/user_prefs";
         $prefpath = "{$mailpath}/{$user}/user_prefs";
     } else {
         return;
     }
     if (!lxfile_exists(dirname($prefpath))) {
         lxfile_mkdir(dirname($prefpath));
         lxfile_generic_chown(dirname($prefpath), "lxpopuser:lxpopgroup");
     }
     $fdata = null;
     $fdata .= "required_score  " . $this->main->spam_hit . "\n";
     $fdata .= "ok_locales   all\n";
     $fdata .= "rewrite_header Subject  {$this->main->subject_tag}\n";
     foreach ((array) $this->main->wlist_a as $wlist) {
         $fdata .= "whitelist_from   " . $wlist->nname . "\n";
     }
     $fdata .= "#***********************************\n";
     foreach ((array) $this->main->blist_a as $blist) {
         $fdata .= "blocklist_from   " . $blist->nname . "\n";
     }
     lxfile_rm($prefpath);
     lfile_write_content($prefpath, $fdata, "lxpopuser:lxpopgroup");
 }
Exemplo n.º 21
0
function add_line_to_master_mycnf()
{
    global $gbl, $sgbl, $login, $ghtml;
    $dbf = $sgbl->__var_dbf;
    if (!lxfile_exists("/etc/primary_master.copy.my.cnf")) {
        lxfile_cp("/etc/my.cnf", "/etc/primary_master.copy.my.cnf");
    }
    $v = lfile_get_contents("/etc/my.cnf");
    if (csa($v, "binlog-do-db")) {
        print "Line already exists in /etc/my.cnf\n";
        return;
    }
    $list = lfile_trim("/etc/my.cnf");
    foreach ($list as $k => $l) {
        $ll[] = $l;
        if ($l == '[mysqld]') {
            $ll[] = "log-bin=mysql-bin";
            $ll[] = "binlog-do-db={$dbf}";
            $ll[] = "server-id=1";
        }
    }
    lfile_put_contents("/etc/my.cnf", implode("\n", $ll));
    system("service mysqld restart");
}
Exemplo n.º 22
0
    system("useradd dnslog");
}
if (!posix_getpwnam('dnscache')) {
    system("useradd dnscache");
}
if (!posix_getpwnam('axfrdns')) {
    system("useradd axfrdns");
}
if (!lxfile_exists("/var/tinydns")) {
    system("tinydns-conf tinydns dnslog /var/tinydns 127.0.0.1");
}
if (!lxfile_exists("/var/axfrdns")) {
    system("axfrdns-conf axfrdns dnslog /var/axfrdns /var/tinydns 0.0.0.0");
}
//  Project issue #949 - Hardcode 0.0.0.0
//  $list = os_get_allips();
//
//  $out = implode("/", $list);
//
$out = "0.0.0.0\n";
//
//  Kloxo development version has this file refactored
//  LxCenter DT05022014
//
lfile_put_contents("/var/tinydns/env/IP", "{$out}");
if (!lxfile_exists("/var/dnscache")) {
    system("dnscache-conf dnscache dnslog /var/dnscache 127.0.0.1");
}
lfile_put_contents("/var/axfrdns/tcp", ":allow");
system("cd /var/axfrdns;  /usr/local/bin/tcprules tcp.cdb tcp.tmp < tcp");
lfile_put_contents("/var/dnscache/env/IP", "127.0.0.1");
Exemplo n.º 23
0
 function newDir()
 {
     $rpath = $this->main->fullpath;
     $name = $this->main->newfolder_f;
     $path = "{$rpath}/{$name}";
     if (lxfile_exists($path)) {
         throw new lxexception('file_exists', '');
     }
     lxfile_mkdir($path);
     return $path;
 }
Exemplo n.º 24
0
function add_vps_backup_dir()
{
    if (lxfile_exists("__path_program_home/vps")) {
        print "VPS backupdir already exist...\n";
        return;
    }
    $sq = new Sqlite(null, 'vps');
    $res = $sq->getTable(array('nname'));
    foreach ($res as $r) {
        lxfile_mkdir("__path_program_home/vps/{$r['nname']}/__backup");
        $vpsbackupdirname = $r['nname'];
        print "Backup dir created for {$vpsbackupdirname} \n";
    }
}
Exemplo n.º 25
0
    }
}
foreach ($list as &$l) {
    $l = preg_replace("/__cgi_or_fcgi__/", $php_st, $l);
    $l = preg_replace("/__program_name__/", $sgbl->__var_program_name, $l);
    $l = preg_replace("/__program_disable_nonssl__/", $nonsslhash, $l);
    $l = preg_replace("/__program_port__/", $nonsslport, $l);
    $l = preg_replace("/__program_sslport__/", $sslport, $l);
    $l = preg_replace("/__program_user__/", $user, $l);
}
lfile_put_contents("../file/lighttpd.conf", implode("", $list));
$pemfile = "__path_program_root/etc/program.pem";
$cafile = "__path_program_root/etc/program.ca";
if (!lxfile_exists($pemfile)) {
    lxfile_cp("__path_program_htmlbase/htmllib/filecore/program.pem", $pemfile);
    lxfile_generic_chown($pemfile, "lxlabs");
}
// Merged from 6.1.x/kloxo/bin/common/misc/fixlighty.php	(revision 472)
lxfile_touch("__path_program_root/log/lighttpd_error.log");
lxfile_touch("__path_program_root/log/access_log");
lxfile_generic_chmod("__path_program_root/log", "0700");
lxfile_generic_chown("__path_program_root/log", "lxlabs:lxlabs");
lxfile_generic_chmod("__path_program_root/log/lighttpd_error.log", "0644");
lxfile_generic_chmod("__path_program_root/log/access_log", "0644");
lxfile_generic_chown("__path_program_root/log/lighttpd_error.log", "lxlabs:root");
lxfile_generic_chown("__path_program_root/log/access_log", "lxlabs:root");
//
if (!lxfile_exists($cafile)) {
    lxfile_cp("__path_program_htmlbase/htmllib/filecore/program.ca", $cafile);
    lxfile_generic_chown($cafile, "lxlabs");
}
Exemplo n.º 26
0
function move_clients_to_client()
{
    if (lxfile_exists("__path_program_home/client")) {
        return;
    }
    print "Rename clients folder to client\n";
    lxfile_mv_rec("__path_program_home/clients", "__path_program_home/client");
}
Exemplo n.º 27
0
 function getAndUnzipSkeleton($ip, $filepass, $dir)
 {
     $oldir = getcwd();
     // File may be a variable path.
     dprintr($filepass);
     $file = $filepass['file'];
     // The thing is this needs to be executed even on secondary master and then the primary master would be down.
     // So if we cannot connect back, we just continue. Skeleton is not an important thing.
     try {
         getFromFileserv($ip, $filepass, "{$dir}/{$file}");
     } catch (exception $e) {
         return;
     }
     lxfile_generic_chown("{$dir}/{$file}", $this->username);
     lxshell_unzip($this->username, $dir, "{$dir}/{$file}");
     lunlink("{$dir}/{$file}");
     $this->replaceVariables("{$dir}/index.html");
     // --- also copy /home/kloxo/httpd/user-logo.png to each domain path
     if (lxfile_exists("../file/user-logo.png")) {
         lxfile_cp("../file/user-logo.png", "{$dir}/images/logo.png");
     }
 }
Exemplo n.º 28
0
function get_file_type($file, &$stat)
{
    if (is_link($file)) {
        $dst = readlink($file);
        if ($dst[0] !== '/') {
            $dst = dirname($file) . "/" . $dst;
        }
        if (!lxfile_exists($dst)) {
            $stat['ttype'] = "brokenlink";
            $stat['linkto'] = $dst;
            return;
        }
        if (is_dir($dst)) {
            $stat['ttype'] = "dirlink";
            $stat['linkto'] = $dst;
            return;
        }
        $stat['ttype'] = "filelink";
        $stat['linkto'] = $dst;
        return;
    }
    if (is_dir($file)) {
        $stat['ttype'] = "directory";
        return;
    }
    $list = pathinfo($file);
    $ext = null;
    if (isset($list['extension'])) {
        $ext = $list['extension'];
    }
    if ($ext === "zip") {
        $stat['ttype'] = "zip";
        return;
    }
    if ($ext === "tgz" || $ext === "tar.gz" || $ext === "gz") {
        $stat['ttype'] = "tgz";
        return;
    }
    if ($ext === "tar") {
        $stat['ttype'] = "tgz";
        return;
    }
    $stat['ttype'] = "file";
}
Exemplo n.º 29
0
function add_vps_backup_dir()
{
    $sq = new Sqlite(null, 'vps');
    $res = $sq->getTable(array('nname'));
    if (isset($res)) {
        foreach ($res as $r) {
            if (!lxfile_exists("__path_program_home/vps/{$r['nname']}/__backup")) {
                lxfile_mkdir("__path_program_home/vps/{$r['nname']}/__backup");
                $vpsbackupdirname = $r['nname'];
                print "- Backup dir created for {$vpsbackupdirname} \n";
            }
        }
        return true;
    }
    return false;
}
Exemplo n.º 30
0
 function createShowAlist(&$alist, $subaction = null)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if ($subaction === 'config') {
         return $this->createShowAlistConfig($alist);
     }
     $server = null;
     if ($this->isAdmin()) {
         $server = "Servers: {$this->getUSlashP("pserver_num")}";
     }
     $alist['__title_administer'] = $login->getKeywordUc('administration');
     if ($this->isLte('reseller')) {
         //$alist[] = "a=list&c=all_domain";
         $alist[] = create_simpleObject(array('url' => "a=list&c=all_domain", 'purl' => "a=updateform&sa=all_resource", '__internal' => true, 'target' => ""));
     }
     $alist[] = "a=list&c=actionlog";
     if ($this->isAdmin()) {
         $alist[] = 'a=list&c=pserver';
         /*
         if (check_if_many_server()) {
         	$this->getListActions($alist, 'pserver'); 
         } else {
         	$alist[] = 'k[class]=pserver&k[nname]=localhost&a=show';
         }
         */
     }
     if ($this->isLte('reseller')) {
         $alist[] = "a=list&c=client";
     }
     if ($this->isLte('reseller')) {
         $alist[] = "a=list&c=resourceplan";
     }
     $this->getTicketMessageUrl($alist);
     //$alist[] = "a=list&c=ssession";
     if ($login->priv->isOn('can_change_password_flag')) {
         if ($this->isLogin() && $login->isAuxiliary()) {
             $alist['__v_dialog_pass'] = "******";
         } else {
             $alist['__v_dialog_pass'] = "******";
         }
     }
     if ($this->isAdmin()) {
         $alist[] = "a=list&c=custombutton";
     }
     $alist['__v_dialog_info'] = "a=updateform&sa=information";
     if ($this->priv->isOn('webhosting_flag')) {
         if ($this->priv->isOn('cron_manage_flag') && $this->isCustomer()) {
             $alist[] = "a=list&c=cron";
         }
     }
     if (!$this->isLogin()) {
         $alist['__v_dialog_limit'] = "a=updateform&sa=limit";
         $alist['__v_dialog_plan'] = "a=updateform&sa=change_plan";
     }
     if ($this->isAdmin() && !lxfile_exists("/proc/user_beancounters") && !lxfile_exists("/proc/xen")) {
         $alist[] = "a=list&c=reversedns";
     }
     if (!$this->isAdmin()) {
         if (!$this->isLogin()) {
             $alist['__v_dialog_dnstem'] = "a=updateform&sa=dnstemplatelist";
         }
         if (check_if_many_server()) {
             if ($this->isLte('reseller')) {
                 $alist[] = "a=updateForm&sa=pserver_s";
             }
         } else {
             //$alist[] = "a=updateForm&sa=pserver_s";
             //$alist[] = "a=updateForm&sa=ipaddress";
         }
     }
     if ($this->isAdmin()) {
         //$alist[] = 'k[class]=pserver&k[nname]=localhost&o=lxupdate&a=updateform&sa=lxupdateinfo';
         $alist[] = 'o=lxupdate&a=show';
     }
     //$alist[] = "a=updateform&sa=generate_csr";
     $dbadminUrl = "/thirdparty/phpMyAdmin/";
     //$alist[] = create_simpleObject(array('url' => "$dbadminUrl", 'purl' => "c=mysqldb&a=updateform&sa=phpmyadmin", 'target' => "target='_blank'"));
     if (!$this->isLogin()) {
         $alist[] = "a=update&sa=dologin";
     }
     if ($this->priv->isOn('webhosting_flag')) {
         $alist['__title_resource'] = $login->getKeywordUc('resource');
     }
     $alist[] = "a=updateform&sa=update&o=domaindefault";
     $alist[] = "a=list&c=auxiliary";
     /*
     	if (!$this->isAuxiliary()) {
     		$alist[] = "a=list&c=auxiliary";
     	}
     */
     $alist[] = "a=list&c=utmp";
     if ($login->isAdmin()) {
         $alist['__v_dialog_shell'] = "a=updateform&sa=shell_access";
     }
     if (check_if_many_server()) {
         if (!$this->isLogin() && !$this->isAdmin()) {
             $alist[] = "a=updateForm&sa=domainpserver";
         }
     }
     if ($this->isAdmin()) {
         if ($this->priv->isOn("dns_manage_flag")) {
             $alist[] = "c=dnstemplate&a=list";
         }
     }
     //$alist[] = "a=list&c=domain";
     if ($this->isAdmin()) {
         if (lxfile_exists("/var/installatron")) {
             $alist[] = create_simpleObject(array('url' => "/installatron/", 'purl' => 'a=updateform&sa=installatron', 'target' => ""));
         }
     }
     if ($this->priv->isOn('webhosting_flag')) {
         if (lxfile_exists("/var/installatron")) {
             if (!$this->isAdmin()) {
                 if ($this->isLogin()) {
                     $alist[] = create_simpleObject(array('url' => "/installatron/", 'purl' => 'a=updateform&sa=installatron', 'target' => ""));
                 } else {
                     $alist[] = "a=updateform&sa=installatron";
                 }
             }
         }
         if ($login->priv->isOn('backup_flag')) {
             $alist[] = "a=show&o=lxbackup";
         }
         $alist[] = "a=list&c=ipaddress";
         if ($this->getList('ipaddress')) {
             $alist[] = "a=list&c=sslcert";
         }
         if ($this->isCustomer()) {
             $alist[] = "a=list&c=ftpuser";
             $alist[] = 'a=list&c=ftpsession';
             $alist[] = "a=show&l[class]=ffile&l[nname]=/";
             $alist['__v_dialog_defd'] = "a=updateform&sa=default_domain";
             $alist[] = "a=show&o=sshclient";
             $alist[] = "a=list&c=traceroute";
             $this->getListActions($alist, 'mysqldb');
             $this->getMysqlDbAdmin($alist);
             //$this->getListActions($alist, 'mssqldb');
         }
         if ($login->priv->isOn('domain_add_flag')) {
             $alist[] = "a=addform&c=domain";
         }
     }
     /// List dns tempate only for admin... From now onwards.
     if (!$this->isLogin()) {
         //Both wall and message not done through message board.
         //$alist[] = 'a=updateForm&sa=message';
     }
     // Client Traffic history. Doesn't know if I should add the history of HIS clients too, or just use the traffic for the domains under him. So hashing for the present.
     //$alist[] = 'a=list&c=domaintraffichistory';
     //$this->getListActions($alist, 'ticket');
     //$web = $this->getObject('web');
     //$ip = getFQDNforServer($web->syncserver);
     //$ip = getFQDNforServer('localhost');
     //$alist[] = create_simpleObject(array('url' => "http://$ip/~$this->username/", 'purl' => 'a=updateform&sa=site_preview&l[class]=domain&l[nname]=$this->nname', 'target' => "target='_blank'"));
     //$this->getLxclientActions($alist);
     if ($this->isAdmin()) {
         //$alist[] = "a=list&c=blockedip";
         //$alist[] = "o=general&a=updateForm&sa=attempts";
         //$alist[] = "a=list&c=module";
     } else {
     }
     if ($this->isNotCustomer()) {
         $alist['__title_domain_rec'] = $login->getKeywordUc('domain');
         $alist[] = "a=list&c=ftpuser";
         $this->getListActions($alist, 'mysqldb');
         $this->getMysqlDbAdmin($alist);
         $alist[] = "a=show&l[class]=ffile&l[nname]=/";
         $alist['__v_dialog_defd'] = "a=updateform&sa=default_domain";
         //$alist[] = "a=show&o=sshclient";
         $alist[] = "a=list&c=cron";
         $alist[] = "a=list&c=traceroute";
         //$this->getListActions($alist, 'mssqldb');
     }
     if (!$this->isAdmin() && !$this->isDisabled("shell")) {
         $alist[] = "a=list&c=sshauthorizedkey";
     }
     if ($this->isCustomer()) {
         $this->getDomainAlist($alist);
     }
     if ($this->isAdmin()) {
         if ($this->isDomainOwnerMode()) {
             $this->getDomainAlist($alist);
         } else {
             $so = $this->getFromList('pserver', 'localhost');
             $this->getAlistFromChild($so, $alist);
         }
     } else {
         if ($this->isLte('reseller') && $this->isDomainOwnerMode()) {
             $this->getDomainAlist($alist);
         }
     }
     $this->getCustomButton($alist);
     $alist['__title_advanced'] = $login->getKeywordUc('advanced');
     if ($this->isAdmin()) {
         //$alist['__v_dialog_tick'] = "a=updateform&sa=ticketconfig&o=ticketconfig";
         //$alist[] = "o=general&c=helpdeskcategory_a&a=list";
         $alist['__v_dialog_sca'] = "o=general&a=updateform&sa=scavengetime";
         $alist['__v_dialog_gen'] = "o=general&a=updateform&sa=generalsetting";
         $alist['__v_dialog_main'] = "o=general&a=updateform&sa=maintenance";
         $alist['__v_dialog_self'] = "o=general&a=updateform&sa=selfbackupconfig";
         //$alist['__v_dialog_ssh'] = "o=general&a=updateform&sa=ssh_config";
         //$alist['__v_dialog_ipcheck'] = "o=general&a=updateform&sa=session_config";
         $alist['__v_dialog_download'] = "o=general&a=updateform&sa=download_config";
         $alist['__v_dialog_forc'] = "a=updateform&sa=forcedeletepserver";
         if ($sgbl->isHyperVm()) {
             $alist['__v_dialog_hack'] = "o=general&a=updateform&sa=hackbuttonconfig";
             $alist['__v_dialog_rev'] = "o=general&a=updateform&sa=reversedns";
             $alist['__v_dialog_cust'] = "o=general&a=updateform&sa=customaction";
             $alist['__v_dialog_orph'] = "a=updateform&sa=deleteorphanedvps";
             $alist['__v_dialog_lxc'] = "o=general&a=updateform&sa=kloxo_config";
             //$alist[] = "a=show&o=ostemplatelist";
             $alist[] = "a=list&c=customaction";
         } else {
             $alist[] = "o=genlist&c=dirindexlist_a&a=list";
         }
     }
     if ($sgbl->isHyperVm()) {
         if (!$this->isAdmin()) {
             $alist[] = "a=updateform&sa=ostemplatelist";
         }
     }
     $alist['__v_dialog_misc'] = "a=updateform&sa=miscinfo";
     // temporary, only for admin - on 6.1.7
     if ($this->isAdmin()) {
         if ($login->priv->isOn('logo_manage_flag') && $this->isLogin()) {
             $alist['__v_dialog_uplo'] = "o=sp_specialplay&a=updateForm&sa=upload_logo";
         }
         if ($this->canHaveChild()) {
             $alist['__v_dialog_ch'] = "o=sp_childspecialplay&a=updateform&sa=skin";
         }
     }
     $alist['__v_dialog_misc'] = "a=updateform&sa=miscinfo";
     if ($this->isAdmin()) {
         $alist[] = "o=general&a=updateform&sa=portconfig";
     }
     if (!$this->isLogin() && !$this->isLteAdmin() && csb($this->nname, "demo_")) {
         $alist['__v_dialog_demo'] = "o=sp_specialplay&a=updateform&sa=demo_status";
     }
     // temporary, only for admin - on 6.1.7
     if ($this->isAdmin()) {
         if ($login->priv->isOn('can_set_disabled_flag')) {
             $alist[] = 'a=updateform&sa=disable_skeleton';
         }
     }
     $alist[] = "a=list&c=blockedip";
     $alist[] = "a=show&o=notification";
     if (!$this->isLogin()) {
         $alist['__v_dialog_disa'] = "a=updateform&sa=disable_per";
     }
     // temporary, only for admin
     if ($this->isAdmin()) {
         if ($login->priv->isOn('logo_manage_flag') && $this->isLogin()) {
             $alist['__v_dialog_uplo'] = "o=sp_specialplay&a=updateForm&sa=upload_logo";
         }
     }
     if (!$this->isLogin()) {
         $alist['__v_dialog_resend'] = "a=updateform&sa=resendwelcome";
     }
     if (!$this->isLogin()) {
         $alist[] = "a=updateForm&sa=changeowner";
     }
     if ($this->isLogin()) {
         $alist['__v_dialog_login'] = "******";
     }
     if ($this->isAdmin()) {
         $alist[] = "a=updateform&sa=license&o=license";
     }
     return $alist;
 }