static function convertfile($oldtime, $newtime) { global $gbl, $sgbl, $login, $ghtml; $file = '/var/log/kloxo/maillog'; if (!lxfile_real($file)) { return null; } $fp = fopen($file, "r"); $fsize = filesize($file); $ret = FindRightPosition($fp, $fsize, $oldtime, $newtime, array("mailtraffic", "getTimeFromOriginalQmailString")); if ($ret < 0) { dprint("Could not find position\n"); return; } $totstring = null; $count = 0; while (!feof($fp)) { $count++; if ($count > 1000000) { break; } $string = fgets($fp); $totstring .= $string; if (self::getTimeFromOriginalQmailString($string) > $newtime) { break; } } fclose($fp); $convertfile = tempnam("/tmp/", "mail_log"); $convertfile_source = tempnam("/tmp/", "mail_log_source"); lfile_put_contents($convertfile_source, $totstring); system("perl {$sgbl->__path_kloxo_httpd_root}/awstats/tools/maillogconvert.pl standard < {$convertfile_source} > {$convertfile}"); lunlink($convertfile_source); return $convertfile; }
function core_installWithVersion($path, $file, $ver) { global $sgbl; $prgm = $sgbl->__var_program_name; lxfile_mkdir("/var/cache/{$prgm}"); if (!lxfile_real("/var/cache/{$prgm}/{$file}.{$ver}.zip")) { while (lxshell_return("unzip", "-t", "/var/cache/{$prgm}/{$file}.{$ver}.zip")) { system("cd /var/cache/{$prgm}/ ; rm -f {$file}*.zip; wget download.lxcenter.org/download/{$file}.{$ver}.zip"); } system("cd {$path} ; unzip -oq /var/cache/{$prgm}/{$file}.{$ver}.zip"); } }
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)); }
function get_kloxo_ostemplate() { $ver = getHIBversion(); if (!$ver) { return; } if (is_openvz()) { if (lxfile_exists("/vz/template/cache")) { if (!lxfile_real("/vz/template/cache/centos-5-i386-hostinabox{$ver}.tar.gz")) { system("cd /vz/template/cache/ ;rm -f centos-?-i386-lxadmin*.tar.gz ; rm -f centos-?-i386-hostinabox*.tar.gz; wget download.lxcenter.org/download/openvztemplates/base/centos-5-i386-hostinabox{$ver}.tar.gz"); } } } else { if (lxfile_exists("/home/hypervm/xen/template/")) { if (!lxfile_nonzero("/home/hypervm/xen/template/centos-5-i386-hostinabox{$ver}.tar.gz")) { system("cd /home/hypervm/xen/template/ ; rm -f centos-?-i386-lxadmin*.tar.gz; rm -f centos-?-i386-hostinabox*.tar.gz; wget download.lxcenter.org/download/xentemplates/base/centos-5-i386-hostinabox{$ver}.tar.gz"); } } } }
function lxfile_nonzero($file) { return lxfile_real($file); }
public function doRealCreate() { global $gbl, $sgbl, $login, $ghtml; $nname = $this->main->nname; lx_core_lock("{$nname}.create"); $this->createRootPath(); lxfile_mkdir($this->main->configrootdir); $this->setDhCP(); if ($this->main->isWindows()) { $templatefile = "__path_program_home/xen/template/{$this->main->ostemplate}"; } else { $templatefile = "__path_program_home/xen/template/{$this->main->ostemplate}.tar.gz"; } $this->main->getOsTemplateFromMaster($templatefile); if (!lxfile_real($templatefile)) { log_error("could not create vm. Could not download {$templatefile}"); lfile_put_contents("__path_program_root/tmp/{$nname}.createfailed", "Could not download {$templatefile}"); exit; } $size = 0; if ($this->main->isWindows()) { $size = lxfile_size($templatefile); $size = $size / (1024 * 1024); } try { $this->createConfig(); $this->setMemoryUsage(); $this->setCpuUsage(); $this->setSwapUsage(); $this->createSwap(); $this->createDisk($size); } catch (Exception $e) { log_error("could not create vm. Error was {$e->getMessage()}"); lfile_put_contents("__path_program_root/tmp/{$nname}.createfailed", "{$e->getMessage()}"); exit; } if (!$this->main->isWindows()) { $mountpoint = $this->mount_this_guy(); lxshell_return("tar", "-C", $mountpoint, "--numeric-owner", "-xpzf", $templatefile); $this->setInternalParam($mountpoint); $this->copyKernelModules(); lxfile_cp("../file/sysfile/xen/fstab", "{$mountpoint}/etc/fstab"); lunlink("{$mountpoint}/etc/mtab"); } else { if (!$this->main->isBlankWindows()) { $templatefile = expand_real_root($templatefile); lxshell_return("parted", "-s", $this->main->maindisk, "mklabel", "msdos"); $this->runParted(); $partition = $this->getPartition(); lxshell_return("ntfsfix", $partition); //lxshell_return("dd", "if=$templatefile", "of={$this->main->maindisk}"); lxshell_return("ntfsclone", "--restore-image", "--force", "-O", $partition, $templatefile); $this->kpart_remove(); $this->expandPartitionToImage(); //lxshell_return("ntfsclone", "-O", $loop, $templatefile); //lo_remove($loop); } } $this->main->status = 'On'; try { $this->toggleStatus(); } catch (Exception $e) { } $this->postCreate(); }
exit(0); } $lic = $login->getObject('license')->licensecom_b; if ($lic->isOn('lic_livesupport_flag')) { $licid = $lic->lic_livesupport_name; } else { print "Couldn't find license for the live support\n"; $ht = trim(`hostname`); dprint($ht); if ($ht !== 'self.lxlabs.com') { exit; } } } } if (!lxfile_real($g_db_file)) { $tlink = lsqlite_open($g_db_file); @sqlite_query($tlink, "drop table phpchat;"); @sqlite_query($tlink, "drop table channel;"); sqlite_query($tlink, "CREATE TABLE phpchat (username, id, tijd, commando);"); sqlite_query($tlink, "CREATE TABLE channel (user, id, channel);"); sqlite_close($tlink); } $list = file("http://lxlabs.com/live/channel/{$chanbase}.conf"); $extra_url = ""; foreach ($list as $l) { $l = trim($l); $l = preg_replace("/\\s+/", " ", $l); $v = explode(" ", $l); $extra_url .= "&{$v['0']}={$v['1']}"; ${$v}[0] = $v[1];
function os_create_system_user($basename, $password, $id, $shell, $dir = "/tmp") { dprint("In Create User {$basename}, {$id} {$password} {$shell}"); $i = null; $name = $basename; while (true) { try { $ret = uuser__linux::checkIfUserExists($name, $id); if ($ret) { return $name; } else { break; } } catch (exception $e) { $i++; $name = "{$basename}{$i}"; } } $ret = lxshell_return("useradd", "-m", "-c", uuser::getUserDescription($id), "-d", $dir, "-s", $shell, "-p", $password, $name); if ($ret) { // --- issue #638 - installation fails if 'admin' group already exists if (!lxfile_real("/var/cache/kloxo/kloxo-install-firsttime.flg")) { throw new lxexception("could_not_create_user", '', $name); } } return $name; }
function setUpOsTemplateDownloadParam() { if ($this->isLocalhost()) { return; } if (!lxfile_real($this->getFullPathOstemplate())) { return; } $this->__var_ost_md5 = lmd5_file($this->getFullPathOstemplate()); $this->__var_ostemplatefileserv = cp_fileserv($this->getFullPathOstemplate()); $this->__var_masterip = getOneIPForLocalhost($this->syncserver); }
function setInitialPureftpConfig() { log_cleanup("Initialize PureFtp service"); log_cleanup("- Initialize process"); if (lxfile_exists("/etc/xinetd.d/pure-ftpd")) { log_cleanup("- Remove /etc/xinetd.d/pure-ftpd service file"); @lxfile_rm("/etc/xinetd.d/pure-ftpd"); } if (!lxfile_exists("/etc/xinetd.d/pureftp")) { log_cleanup("- Install /etc/xinetd.d/pureftp TCP Wrapper file"); lxfile_cp("../file/xinetd.pureftp", "/etc/xinetd.d/pureftp"); } if (!lxfile_real("/etc/pki/pure-ftpd/pure-ftpd.pem")) { log_cleanup("- Install pure-ftpd ssl/tls key"); lxfile_mkdir("/etc/pki/pure-ftpd/"); lxfile_cp("../file/program.pem", "/etc/pki/pure-ftpd/pure-ftpd.pem"); } if (!lxfile_exists("/etc/pure-ftpd/pureftpd.pdb")) { log_cleanup("Make pure-ftpd user database"); lxfile_touch("/etc/pure-ftpd/pureftpd.passwd"); lxshell_return("pure-pw", "mkdb"); } if (lxfile_exists("/etc/rc.d/init.d/pure-ftpd")) { log_cleanup("- Turn off and remove pure-ftpd service"); @exec("chkconfig pure-ftpd off 2>/dev/null"); // MR --- chkconfig off not enough because can restart with 'service pure-ftpd start' @lxfile_rm("/etc/rc.d/init.d/pure-ftpd"); } if (!lxfile_exists("/etc/pure-ftpd/pureftpd.passwd")) { log_cleanup("- Initialize /etc/pure-ftpd/pureftpd.passwd password database"); lxfile_cp("/etc/pureftpd.passwd", "/etc/pure-ftpd/pureftpd.passwd"); lxshell_return("pure-pw", "mkdb"); createRestartFile("xinetd"); } log_cleanup("- Restart xinetd service for pureftp"); call_with_flag("restart_xinetd_for_pureftp"); }