static function getweb_usage($name, $customer_name, $oldtime, $newtime, $d) { global $gbl, $sgbl, $login, $ghtml; $web_home = "{$sgbl->__path_httpd_root}"; $log_path = "{$web_home}/{$name}/stats"; $processedir = "{$sgbl->__path_customer_root}/{$customer_name}/__processed_stats/"; lxfile_mkdir($processedir); $dir1 = "{$log_path}/"; $files = lscandir_without_dot($dir1); $total = 0; foreach ($files as $file) { if (!strstr($file, "gz")) { $total += self::getEachwebfilequota("{$dir1}/{$file}", $oldtime, $newtime); $stat = stat("{$dir1}/{$file}"); if ($stat['size'] >= 50 * 1024 * 1024) { if (isOn($d->remove_processed_stats)) { lxfile_rm("{$dir1}/{$file}"); } else { lxfile_mv("{$dir1}/{$file}", getNotexistingFile($processedir, $file)); } } } } return $total; }
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"); }
function updateUpdate($param) { lxfile_mkdir("img/custom"); if ($_FILES['upload']['tmp_name']) { lxfile_rm("img/custom/{$this->nname}.gif"); lxfile_mv($_FILES['upload']['tmp_name'], "img/custom/{$this->nname}.gif"); lxfile_generic_chmod("img/custom/{$this->nname}.gif", "0755"); } return $param; }
function create_dev() { if (lxfile_exists("/sbin/udevd")) { lxfile_mv("/sbin/udevd", "/sbin/udevd.back"); } lxshell_return('tar', '-C', '/dev', '-xzf', '../file/centos-5/vps-dev.tgz'); lxshell_return('/sbin/MAKEDEV', 'pty'); lxshell_return('/sbin/MAKEDEV', 'tty'); lxshell_return('/sbin/MAKEDEV', 'loop'); lxshell_return('/sbin/MAKEDEV', 'random'); lxshell_return('/sbin/MAKEDEV', 'urandom'); }
static function findTotalQuota($list, $oldtime, $newtime) { global $gbl, $sgbl, $login, $ghtml; if (!isset($oldtime)) { return null; } $processfile = '/var/log/kloxo/pureftpd.log'; $processedir = "/var/log/kloxo"; foreach ($list as $d) { $tlist[$d] = self::getftp_usage($processfile, $d, $oldtime, $newtime); } $stat = stat($processfile); if ($stat['size'] >= 25 * 1024 * 1024) { lxfile_mv($processfile, getNotexistingFile($processedir, basename($processfile))); } return $tlist; }
static function findTotaltrafficUsage($list, $oldtime, $newtime) { global $gbl, $sgbl, $login, $ghtml; if (!isset($oldtime)) { return null; } $file = '/var/log/lxiptraffic.log'; $processedir = "/var/log/"; $processfile = $file; lxshell_return("__path_php_path", "../bin/sisinfoc.php"); foreach ($list as $d) { $tlist[$d->nname] = self::get_usage($processfile, $d->vpsid, $oldtime, $newtime); } self::iptables_delete(); self::iptables_delete(); self::iptables_create(); $stat = stat($file); if ($stat['size'] >= 10 * 1024 * 1024) { lxfile_mv($file, getNotexistingFile($processedir, basename($file))); } return $tlist; }
static function findTotaltrafficUsage($list, $oldtime, $newtime) { global $gbl, $sgbl, $login, $ghtml; if (!isset($oldtime)) { return null; } $file = '/var/log/lxinterfacetraffic.log'; $processedir = "/var/log/"; $processfile = $file; lxshell_return("__path_php_path", "../bin/common/iptraffic.php"); $globaliplist = null; foreach ($list as $d) { foreach ($d->viflist as $iface) { $tlist[$d->nname] = self::get_usage($processfile, $iface, $oldtime, $newtime); $globalifacelist[] = $iface; } } lfile_put_contents("__path_program_etc/xeninterface.list", implode("\n", $globalifacelist)); $stat = stat($file); if ($stat['size'] >= 10 * 1024 * 1024) { lxfile_mv($file, getNotexistingFile($processedir, basename($file))); } return $tlist; }
function updateupload_Logo($param) { global $gbl, $sgbl, $login, $ghtml; $progname = $sgbl->__var_program_name; $parent = $this->getParentO(); $imgname = $parent->getClName(); $param['specialplay_b-logo_image'] = "/img/logo/{$imgname}.gif"; $param['specialplay_b-logo_image_loading'] = "/img/logo/{$imgname}-loading.gif"; make_sure_directory_is_lxlabs("__path_program_htmlbase/img/logo"); if ($_FILES['logo_image_f']['tmp_name']) { lxfile_mv($_FILES['logo_image_f']['tmp_name'], "__path_program_htmlbase" . $param['specialplay_b-logo_image']); } else { lxfile_cp("__path_program_htmlbase/img/{$progname}-logo.gif", "__path_program_htmlbase" . $param['specialplay_b-logo_image']); } if ($_FILES['logo_image_loading_f']['tmp_name']) { lxfile_mv($_FILES['logo_image_loading_f']['tmp_name'], "__path_program_htmlbase" . $param['specialplay_b-logo_image_loading']); } else { lxfile_cp("__path_program_htmlbase/img/{$progname}-splash.gif", "__path_program_htmlbase" . $param['specialplay_b-logo_image_loading']); } $tsp = $parent->getObject("sp_childspecialplay"); $tsp->specialplay_b->logo_image = $param['specialplay_b-logo_image']; $tsp->specialplay_b->logo_image_loading = $param['specialplay_b-logo_image_loading']; $tsp->setUpdateSubaction('upload_logo'); $this->setUpdateSubaction('upload_logo'); return $param; }
function updateApplicableToSlaveToo() { global $gbl, $sgbl, $login, $ghtml, $osversion; print "Download 3rdparty\n"; // Fixes #303 and #304 download_thirdparty(); print "Installing binaries\n"; lxfile_cp("__path_program_root/cexe/lxxen", "/usr/bin"); lxfile_cp("__path_program_root/cexe/lxopenvz", "/usr/bin"); print "Fixing binaries permissions\n"; lxfile_generic_chmod("/usr/bin/lxopenvz", "6755"); lxfile_generic_chmod("/usr/bin/lxxen", "6755"); print "Install missing rpm packages if any"; install_if_package_not_exist("rrdtool"); print "-rrdtool-"; install_if_package_not_exist("ntfsprogs"); print "-ntfsprogs-"; install_if_package_not_exist("parted"); print "-parted-"; install_if_package_not_exist("kpartx"); print "-kpartx-"; install_if_package_not_exist("dhcp"); print "-dhcp-"; install_if_package_not_exist("openssl"); print "-openssl-"; install_if_package_not_exist("openssl-devel"); print "-openssl-devel-\n"; system("chkconfig dhcpd on"); print "Enable dhcpd at system startup\n"; if (lxfile_exists("/etc/xen")) { lxfile_mkdir("/etc/xen/hypervm"); if (!lxfile_exists("/boot/hypervm-xen-vmlinuz")) { system("cd /boot ; ln -sf vmlinuz-2.6-xen hypervm-xen-vmlinuz; ln -sf initrd-2.6-xen.img hypervm-xen-initrd.img"); } $list = lscandir_without_dot("/etc/xen/auto"); foreach ($list as $l) { $dir = strtil($l, ".cfg"); lunlink("/etc/xen/auto/{$l}"); if (lxfile_exists("/home/xen/{$dir}/{$l}")) { lxfile_symlink("/home/xen/{$dir}/{$l}", "/etc/xen/auto/{$l}"); } } } if (lxfile_exists("/var/log/loadvg.log")) { lunlink("/var/log/loadvg.log"); } if (lxfile_exists("/etc/vz")) { lxfile_cp("__path_program_root/file/sysfile/openvz/ve-vps.basic.conf-sample", "/etc/vz/conf"); print "Set NEIGHBOUR_DEVS=all to vz.conf\n"; vps__openvz::staticChangeConf("/etc/vz/vz.conf", "NEIGHBOUR_DEVS", "all"); } print "Fixing openvz repo\n"; // add openvz.repo lxfile_cp("../file/openvz.repo", "/etc/yum.repos.d/openvz.repo"); print "Fixing lxcenter repo\n"; // add lxcenter.repo $osversion = find_os_version(); print "- Your OS {$osversion}\n"; $cont = our_file_get_contents("../file/lxcenter.repo"); $cont = str_replace("%distro%", $osversion, $cont); our_file_put_contents("/etc/yum.repos.d/lxcenter.repo", $cont); print "Fix RHN\n"; fix_rhn_sources_file(); print "Fix ipconntrack\n"; fix_ipconntrack(); if (lxfile_exists("/home/hypervm/xen/template")) { print "Check Xen windows-lxblank.img template\n"; system("echo hypervm-windows > /home/hypervm/xen/template/windows-lxblank.img"); } print "Fix memory graph\n"; memoryGraphFix(); print "Fix permission of closeallinput\n"; lxfile_unix_chmod("../cexe/closeallinput", "0755"); print "Fix LxEtc\n"; installLxetc(); print "Check binaries\n"; system("cp ../sbin/lxrestart /usr/sbin/"); system("chown root:root /usr/sbin/lxrestart"); system("chmod 755 /usr/sbin/lxrestart"); system("chmod ug+s /usr/sbin/lxrestart"); system("chmod 777 /tmp"); system("chmod o+t /tmp"); print "Create script dir\n"; copy_script(); if (!lxfile_exists("/usr/local/lxlabs/kloxo/")) { print "Remove /usr/local/lxlabs/kloxo/ as it should not be here!\n"; system("rmdir /usr/local/lxlabs/kloxo/httpdocs/ >/dev/null 2>&1"); system("rmdir /usr/local/lxlabs/kloxo/ >/dev/null 2>&1"); } if (!lxfile_exists("/var/named/chroot/etc/kloxo.named.conf")) { if (lxfile_exists("/var/named/chroot/etc/lxadmin.named.conf")) { remove_line("/var/named/chroot/etc/named.conf", "lxadmin.named.conf"); $pattern = 'include "/etc/kloxo.named.conf";'; $file = "/var/named/chroot/etc/named.conf"; $comment = "//Kloxo"; @addLineIfNotExistInside($file, $pattern, $comment); @lxfile_mv("/var/named/chroot/etc/lxadmin.named.conf", "/var/named/chroot/etc/kloxo.named.conf"); } } }
static function switchProgramPre($old, $new) { // issue #589 - Change httpd config structure if ($new === 'apache') { lxfile_cp("/etc/sysconfig/httpd", "/etc/sysconfig/httpd.bck"); $ret = lxshell_return("yum", "-y", "install", "httpd", "mod_ssl"); if ($ret) { throw new lxexception('install_httpd_failed', 'parent'); } lxfile_rm("/etc/sysconfig/httpd"); lxfile_mv("/etc/sysconfig/httpd.bck", "/etc/sysconfig/httpd"); lxshell_return("service", "lighttpd", "stop"); lxshell_return("rpm", "-e", "--nodeps", "lighttpd"); lunlink("/etc/init.d/lighttpd"); lxshell_return("chkconfig", "httpd", "on"); } else { $ret = lxshell_return("yum", "-y", "install", "lighttpd", "lighttpd-fastcgi"); if ($ret) { throw new lxexception('install_lighttpd_failed', 'parent'); } lxfile_unix_chmod("/etc/init.d/lighttpd", "0755"); lxshell_return("service", "httpd", "stop"); lxshell_return("rpm", "-e", "--nodeps", "httpd"); lxshell_return("chkconfig", "lighttpd", "on"); } if ($new === 'apache') { // addLineIfNotExistInside("/etc/httpd/conf/httpd.conf", "Include /etc/httpd/conf/kloxo/kloxo.conf", ""); lxshell_return("__path_php_path", "../bin/misc/installsuphp.php"); //lxshell_return("__path_php_path", "../bin/fix/fixfrontpage.php"); } else { lxfile_mkdir("/etc/lighttpd/"); lxfile_mkdir("/etc/lighttpd/conf/kloxo"); lxfile_cp("../file/lighttpd/lighttpd.conf", "/etc/lighttpd/lighttpd.conf"); // lxfile_cp("../file/lighttpd/conf/kloxo/kloxo.conf", "/etc/lighttpd/conf/kloxo/kloxo.conf"); // lxfile_cp("../file/lighttpd/conf/kloxo/webmail.conf", "/etc/lighttpd/conf/kloxo/webmail.conf"); lxfile_cp("../file/lighttpd/etc_init.d", "/etc/init.d/lighttpd"); lxfile_unix_chmod("/etc/init.d/lighttpd", "0755"); lxfile_mkdir("/home/kloxo/httpd/lighttpd"); lxfile_unix_chown("/home/kloxo/httpd/lighttpd", "apache"); } }
/** * Moves file or directory and set owner * * @param string $username file or directory owner * @param string $src path to the file or directory * @param string $dst new path to the file or directory * @return bool TRUE on success or FALSE on failure. */ function lxuser_mv($username, $src, $dst) { if (!lxfile_mv($src, $dst)) { return false; } if (!lxfile_generic_chown($dst, $username)) { lxfile_mv($dst, $src); return false; } return true; }
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"); }
static function rotateLog($processedir, $file) { $stat = stat($file); if ($stat['size'] >= 10 * 1024 * 1024) { lxfile_mv($file, getNotexistingFile($processedir, basename($file))); createRestartFile("syslog"); } $list = lscandir_without_dot($processedir); foreach ($list as $k) { $file = "{$processedir}/{$k}"; $stat = stat($file); if ($stat['mtime'] < time() - 10 * 24 * 3600) { dprint("deleting old log {$file}\n"); lxfile_rm($file); } } }
function updateupload_Logo($param) { global $gbl, $sgbl, $login, $ghtml; $progname = $sgbl->__var_program_name; $parent = $this->getParentO(); $imgname = $parent->getClName(); // $param['specialplay_b-logo_image'] = "/img/logo/$imgname.gif"; // $param['specialplay_b-logo_image_loading'] = "/img/logo/$imgname-loading.gif"; // make_sure_directory_is_lxlabs("__path_program_htmlbase/img/logo"); $param['specialplay_b-logo_image'] = "/img/user-logo.png"; $fullpath_logo_image = __path_program_htmlbase . $param['specialplay_b-logo_image']; // temporary only for admin - 6.1.7 if ($_FILES['logo_image_f']['tmp_name']) { lxfile_mv($_FILES['logo_image_f']['tmp_name'], $fullpath_logo_image); } /* else { lxfile_cp("__path_program_htmlbase/img/$progname-logo.gif", "__path_program_htmlbase" . $param['specialplay_b-logo_image']); } */ lxfile_cp($fullpath_logo_image, "/usr/local/lxlabs/kloxo/file/user-logo.png"); // must chown to lxlabs for successful display on 'Upload Logo' lxfile_unix_chown($fullpath_logo_image, "lxlabs"); passthru("lxphp.exe /usr/local/lxlabs/kloxo/bin/fix/fix-userlogo.php --select=all"); /* if ($_FILES['logo_image_loading_f']['tmp_name']) { lxfile_mv($_FILES['logo_image_loading_f']['tmp_name'], "__path_program_htmlbase" .$param['specialplay_b-logo_image_loading']); } else { lxfile_cp("__path_program_htmlbase/img/$progname-splash.gif", "__path_program_htmlbase" . $param['specialplay_b-logo_image_loading']); } */ $tsp = $parent->getObject("sp_childspecialplay"); $tsp->specialplay_b->logo_image = $param['specialplay_b-logo_image']; // $tsp->specialplay_b->logo_image_loading = $param['specialplay_b-logo_image_loading']; $tsp->setUpdateSubaction('upload_logo'); $this->setUpdateSubaction('upload_logo'); return $param; }
function doBeforeUpdate() { global $gbl, $sgbl, $login, $ghtml; $program = $sgbl->__var_program_name; // 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"); } // Project issue #1079 // Install yum-plugin-replace (New since Kloxo 6.1.14) $ret = install_if_package_not_exist("yum-plugin-replace"); if ($ret) { print "Installed RPM package yum-plugin-replace\n"; } // Project issue #1079 // Replace lxphp package (New since Kloxo 6.1.14) $ret = replace_rpm_package("lxphp", "kloxo-core-php"); if ($ret) { print "Replaced RPM package lxphp with kloxo-core-php\n"; } // 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"); } // Project issue #1081 // Remove lxrestart if (lxfile_exists("/usr/sbin/lxrestart")) { log_cleanup("- Deleting lxrestart from /usr/sbin/ (not in use anymore)"); lxfile_rm('/usr/sbin/lxrestart'); } if (lxfile_exists('/usr/local/lxlabs/' . $program . '/cexe/lxrestart')) { log_cleanup("- Deleting lxrestart from cexe (not in use anymore)"); lxfile_rm('/usr/local/lxlabs/' . $program . '/cexe/lxrestart'); } if (lxfile_exists('/usr/local/lxlabs/' . $program . '/src/lxrestart.c')) { log_cleanup("- Deleting lxrestart.c from src (not in use anymore)"); lxfile_rm('/usr/local/lxlabs/' . $program . '/src/lxrestart.c'); } // Clean Source dir if (lxfile_exists('/usr/local/lxlabs/' . $program . '/src/lxrestart')) { log_cleanup("- Clean the sources dir - remove lxrestart"); lxfile_rm('/usr/local/lxlabs/' . $program . '/src/lxrestart'); } if (lxfile_exists('/usr/local/lxlabs/' . $program . '/src/closeallinput')) { log_cleanup("- Clean the sources dir - remove closeallinput"); lxfile_rm('/usr/local/lxlabs/' . $program . '/src/closeallinput'); } if (lxfile_exists('/usr/local/lxlabs/' . $program . '/src/lxexec')) { log_cleanup("- Clean the sources dir - remove lxexec"); lxfile_rm('/usr/local/lxlabs/' . $program . '/src/lxexec'); } if (lxfile_exists('/usr/local/lxlabs/' . $program . '/src/lxphpsu')) { log_cleanup("- Clean the sources dir - remove lxphpsu"); lxfile_rm('/usr/local/lxlabs/' . $program . '/src/lxphpsu'); } if (lxfile_exists('/usr/local/lxlabs/' . $program . '/src/lxsuexec')) { log_cleanup("- Clean the sources dir - remove lxsuexec"); lxfile_rm('/usr/local/lxlabs/' . $program . '/src/lxsuexec'); } // DT18022014 - Cleanup the mess. if (lxfile_exists('/usr/local/lxlabs/' . $program . '/httpdocs/live/common.php')) { log_cleanup("- Remove live dir (not in use)"); lxfile_rm_rec('/usr/local/lxlabs/' . $program . '/httpdocs/live'); lxfile_rm('/usr/local/lxlabs/' . $program . '/etc/phplive.db'); } }
function dbactionUpdate($subaction) { // issue #571 - add httpd-worker and httpd-event for suphp // issue #566 - Mod_ruid2 on Kloxo // issue #567 - httpd-itk for kloxo // lxshell_return("service", "httpd", "stop"); // system("/etc/init.d/httpd stop"); $ret = lxshell_return("service", "httpd", "stop"); if ($ret) { throw new lxexception('httpd_stop_failed', 'parent'); } //-- old structure system("rm -rf /etc/httpd/conf/kloxo"); system("rm -rf /home/httpd/conf"); //-- new structure lxfile_mkdir("/home/apache/conf"); lxfile_mkdir("/home/apache/conf/defaults"); lxfile_mkdir("/home/apache/conf/domains"); lxfile_mkdir("/home/apache/conf/redirects"); lxfile_mkdir("/home/apache/conf/webmails"); lxfile_mkdir("/home/apache/conf/wildcards"); lxfile_mkdir("/home/apache/conf/exclusive"); //--- some vps include /etc/httpd/conf.d/swtune.conf system("rm -f /etc/httpd/conf.d/swtune.conf"); if (!lfile_exists("/etc/httpd/conf.d/~lxcenter.conf")) { copy("/usr/local/lxlabs/kloxo/file/apache/~lxcenter.conf", "/etc/httpd/conf.d/~lxcenter.conf"); copy("/usr/local/lxlabs/kloxo/file/centos-5/httpd.conf", "/etc/httpd/conf/httpd.conf"); } lxfile_rm("/etc/sysconfig/httpd"); $t = $this->main->php_type; $a = $this->main->apache_optimize; $m = $this->main->mysql_convert; $f = $this->main->fix_chownchmod; if ($f === 'fix-ownership') { system("lphp.exe /usr/local/lxlabs/kloxo/bin/fix/fix-chownchmod.php --select=chown"); // setFixChownChmod('chown'); } else { if ($f === 'fix-permissions') { system("lphp.exe /usr/local/lxlabs/kloxo/bin/fix/fix-chownchmod.php --select=chmod"); // setFixChownChmod('chmod'); } else { if ($f === 'fix-ALL') { system("lphp.exe /usr/local/lxlabs/kloxo/bin/fix/fix-chownchmod.php --select=all"); // setFixChownChmod('all'); } } } if ($m === 'to-myisam') { system("lphp.exe /usr/local/lxlabs/kloxo/bin/fix/mysql-convert.php --engine=myisam"); // setMysqlConvert('myisam'); } else { if ($m === 'to-innodb') { system("lphp.exe /usr/local/lxlabs/kloxo/bin/fix/mysql-convert.php --engine=innodb"); // setMysqlConvert('innodb'); } } //--- don't use '=== true' but '!== false' if (strpos($t, 'mod_php') !== false) { lxfile_mv("/etc/httpd/conf.d/php.nonconf", "/etc/httpd/conf.d/php.conf"); lxfile_mv("/etc/httpd/conf.d/fastcgi.conf", "/etc/httpd/conf.d/fastgi.nonconf"); lxfile_mv("/etc/httpd/conf.d/fcgid.conf", "/etc/httpd/conf.d/fcgid.nonconf"); lxfile_mv("/etc/httpd/conf.d/ruid2.conf", "/etc/httpd/conf.d/ruid2.nonconf"); lxfile_mv("/etc/httpd/conf.d/suphp.conf", "/etc/httpd/conf.d/suphp.nonconf"); // lxfile_cp("../file/httpd.prefork", "/etc/sysconfig/httpd"); // lxfile_rm("/etc/sysconfig/httpd"); // use > that equal to lxfile_rm + echo >> system("echo 'HTTPD=/usr/sbin/httpd' >/etc/sysconfig/httpd"); if ($t === 'mod_php') { // nothing } else { if ($t === 'mod_php_ruid2') { system("yum -y install mod_ruid2"); system("yum -y update mod_ruid2"); lxfile_mv("/etc/httpd/conf.d/ruid2.nonconf", "/etc/httpd/conf.d/ruid2.conf"); lxfile_cp("../file/ruid2.conf", "/etc/httpd/conf.d/ruid2.conf"); } else { if ($t === 'mod_php_itk') { system("echo 'HTTPD=/usr/sbin/httpd.itk' >/etc/sysconfig/httpd"); } } } } else { if (strpos($t, 'suphp') !== false) { system("yum -y install mod_suphp"); system("yum -y update mod_suphp"); lxfile_mv("/etc/httpd/conf.d/php.conf", "/etc/httpd/conf.d/php.nonconf"); lxfile_mv("/etc/httpd/conf.d/fastcgi.conf", "/etc/httpd/conf.d/fastgi.nonconf"); lxfile_mv("/etc/httpd/conf.d/fcgid.conf", "/etc/httpd/conf.d/fcgid.nonconf"); lxfile_mv("/etc/httpd/conf.d/ruid2.conf", "/etc/httpd/conf.d/ruid2.nonconf"); lxfile_mv("/etc/httpd/conf.d/suphp.nonconf", "/etc/httpd/conf.d/suphp.conf"); lxfile_cp("../file/suphp.conf", "/etc/httpd/conf.d/suphp.conf"); lxfile_cp("../file/etc_suphp.conf", "/etc/suphp.conf"); // lxfile_rm("/etc/sysconfig/httpd"); if ($t === 'suphp') { system("echo 'HTTPD=/usr/sbin/httpd' >/etc/sysconfig/httpd"); } else { if ($t === 'suphp_worker') { system("echo 'HTTPD=/usr/sbin/httpd.worker' >/etc/sysconfig/httpd"); } else { if ($t === 'suphp_event') { system("echo 'HTTPD=/usr/sbin/httpd.event' >/etc/sysconfig/httpd"); } } } } else { if (strpos($t, 'suexec') !== false) { // work in progress... } } } //--- change to ~lxcenter.conf from the first idea // lxfile_cp("../file/mpm.conf", "/etc/httpd/conf.d/mpm.conf"); // Fixed issue #515 - returned due to accidentally deleted // enough handle by fix-chownchmod // lxfile_generic_chmod("/home/admin", "0770"); // change to 'stop-start' instead 'restart' because problem when change prefork/worker/event/itk to other // createRestartFile("httpd"); // lxshell_return("service", "httpd", "start"); // system("/etc/init.d/httpd start"); $ret = lxshell_return("service", "httpd", "start"); if ($ret) { throw new lxexception('httpd_start_failed', 'parent'); } if ($a === 'optimize') { system("lphp.exe /usr/local/lxlabs/kloxo/bin/fix/apache-optimize.php --select=optimize"); } }
static function fixErrorLogbad($list) { global $gbl, $sgbl, $login, $ghtml; $file = "/home/kloxo/httpd/lighttpd/error.log"; $fp = lfopen($file); if (!$fp) { return; } while (!feof($fp)) { $s = fgets($fp); foreach ($list as $l) { if (csa($s, $l)) { $out[$l] .= $s; } } } foreach ($out as $k => $v) { lfile_put_contents("/home/httpd/{$k}/stats/{$k}-error_log", $v, FILE_APPEND); } fclose($fp); $fp = getNotexistingFile(dirname($file), $file); lxfile_mv($file, $nfile); }
function fix_secure_log() { log_cleanup("Fix secure log"); log_cleanup("- Fix process"); lxfile_mv("/var/log/secure", "/var/log/secure.lxback"); lxfile_cp("../file/linux/syslog.conf", "/etc/syslog.conf"); createRestartFile('syslog'); }
function dbactionUpdate($subaction) { switch ($subaction) { case "enable": case "disable": case "toggle_status": $this->ToggleStatus(); break; case "password": $this->changeAdminPass(); $this->changeUserPass(); break; case "shell_access": $this->shellModify(); break; case "change_totaldisk_usage": $this->setQuota(); break; case "createuser": return $this->createuser(); break; case "skeleton": $file = "__path_client_root/{$this->main->nname}/skeleton.zip"; lxfile_mv($this->main->__skeletion_tmp, $file); lxfile_generic_chown($file, "lxlabs"); break; case "default_domain": $this->setupDefaultDomain(); break; case "ssh_authorized_keys": sshconfig::writeAuthorizedKeys($this->main->username, $this->main->ssh_authorized_keys_f); break; } }