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 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 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"; }
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'); } }
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"); }
function dbactionDelete() { // $wname = fix_nname_to_be_variable($this->main->nname); lxfile_rm("/var/bogofilter/{$wname}.wordlist.db"); }
function lxfile_mv($src, $dst) { global $gbl, $sgbl, $login, $ghtml; $src = expand_real_root($src); $dst = expand_real_root($dst); if (is_dir($dst)) { $base = basename($src); $dst = $dst . "/{$base}"; } if ($sgbl->dbg > 0) { log_filesys("Moving {$src} {$dst}"); } if (!lxfile_cp($src, $dst)) { lxfile_rm($src); return true; } return false; }
public function setInternalParam($mountpoint) { $name = $this->main->ostemplate; if ($this->main->isWindows()) { return; } if (!$mountpoint) { return; } if ($name === 'unknown') { return; } $name = strtolower($name); $mountpoint = expand_real_root($mountpoint); $result = $this->getScriptS($name); dprint("Distro Name {$name}, Scripts: \n"); dprintr($result); $init = strtilfirst($name, "-"); dprint("File is {$init}.inittab\n"); if (lxfile_exists("../file/sysfile/inittab/{$init}.inittab")) { dprint("Copying {$init}.inittab\n"); $content = lfile_get_contents("../file/sysfile/inittab/{$init}.inittab"); if ($this->main->text_inittab) { $content .= "\n{$this->main->text_inittab}"; } lfile_put_contents("{$mountpoint}/etc/inittab", $content); } $iplist = get_namelist_from_objectlist($this->main->vmipaddress_a); if ($this->main->mainipaddress) { $main_ip = $this->main->mainipaddress; $iplist = array_remove($iplist, $main_ip); } else { $main_ip = array_shift($iplist); } if ($this->main->networknetmask) { $main_netmask = $this->main->networknetmask; } else { $main_netmask = "255.255.255.0"; } $iplist = implode(" ", $iplist); $ipadd = $result['ADD_IP']; $sethostname = $result['SET_HOSTNAME']; $setuserpass = $result['SET_USERPASS']; $ipdel = $result['DEL_IP']; if ($this->main->networkgateway) { $gw = $this->main->networkgateway; } else { $gw = os_get_network_gateway(); } $gwn = strtil($gw, '.') . '.0'; $hostname = $this->main->hostname; if (!$hostname) { $hostname = os_get_hostname(); } if ($result['STARTUP_SCRIPT'] != 'systemd') { $name = createTempDir("{$mountpoint}/tmp", 'xen-scripts'); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/functions", $name); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$ipadd}", $name); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$sethostname}", $name); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$setuserpass}", $name); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$ipdel}", $name); $basepath = strfrom($name, $mountpoint); lfile_put_contents("{$name}/tmpfile.sh", "source /{$basepath}/functions\nsource /{$basepath}/{$ipdel}\n"); $delipstring = "IPDELALL=yes chroot {$mountpoint} bash /{$basepath}/tmpfile.sh"; log_shell($delipstring); log_shell(system($delipstring, $ret1) . ":return {$ret1}"); putenv("VE_STATE=stopped"); lfile_put_contents("{$name}/tmpfile.sh", "source /{$basepath}/functions\n source /{$basepath}/{$ipadd}\n"); $string = "IPDELALL=yes MAIN_NETMASK={$main_netmask} MAIN_IP_ADDRESS={$main_ip} IP_ADDR=\"{$iplist}\" NETWORK_GATEWAY={$gw} NETWORK_GATEWAY_NET={$gwn} chroot {$mountpoint} bash /{$basepath}/tmpfile.sh"; log_shell($string); log_shell(system($string, $ret1) . ":return {$ret1}"); lfile_put_contents("{$name}/tmpfile.sh", "source /{$basepath}/functions\n source /{$basepath}/{$sethostname}\n"); $string = "HOSTNM={$hostname} chroot {$mountpoint} bash /{$basepath}/tmpfile.sh"; log_shell($string); log_shell(system($string, $ret1) . ":return {$ret1}"); if ($this->main->subaction === 'rebuild' || $this->main->dbaction === 'add' || $this->main->isOn('__var_rootpassword_changed') && $this->main->rootpassword) { $rootpass = "******"; lfile_put_contents("{$name}/tmpfile.sh", "source /{$basepath}/functions\n source /{$basepath}/{$setuserpass}\n"); $string = "USERPW={$rootpass} chroot {$mountpoint} bash /{$basepath}/tmpfile.sh"; log_shell($string); log_shell(system($string)); } lxfile_rm_rec($name); } else { if ($result['STARTUP_SCRIPT'] == 'systemd') { $script_dir = createTempDir("{$mountpoint}", "hypervm-runonce"); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/functions", $script_dir); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$ipadd}", $script_dir); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$sethostname}", $script_dir); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$setuserpass}", $script_dir); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$ipdel}", $script_dir); $basepath = strfrom($script_dir, $mountpoint); $startupdir = 'lib/systemd/system'; $startupscript = 'fedora-startup.service'; $setrootpass = ''; if ($this->main->subaction === 'rebuild' || $this->main->dbaction === 'add' || $this->main->isOn('__var_rootpassword_changed') && $this->main->rootpassword) { $rootpass = "******"; $setrootpass = "******"; } $run_once_script = "#!/bin/bash\n" . "source {$basepath}/functions\n" . '(' . "IPDELALL=yes source {$basepath}/{$ipdel}" . " & IPDELALL=yes VE_STATE=stopped MAIN_NETMASK={$main_netmask} MAIN_IP_ADDRESS={$main_ip} IP_ADDR=\"{$iplist}\" NETWORK_GATEWAY={$gw} NETWORK_GATEWAY_NET={$gwn} source {$basepath}/{$ipadd}" . " & HOSTNM={$hostname} source {$basepath}/{$sethostname}" . "{$setrootpass})\n" . "service fedora-startup disable\nrm -f /{$startupdir}/{$startupscript}\nrm -rf {$basepath}"; lfile_put_contents("{$script_dir}/hypervm-runonce.sh", $run_once_script); lxfile_cp_rec("__path_program_root/bin/xen-dists/scripts/{$startupscript}", "{$mountpoint}/{$startupdir}"); lfile_put_contents("{$mountpoint}/{$startupdir}/{$startupscript}", lfile_get_contents("{$mountpoint}/{$startupdir}/{$startupscript}") . "ExecStart={$basepath}/hypervm-runonce.sh\n"); system("ln -s /lib/systemd/system/fedora-startup.service {$mountpoint}/etc/systemd/system/multi-user.target.wants/fedora-startup.service"); system("chmod 755 {$script_dir}/hypervm-runonce.sh"); } } if ($this->main->nameserver) { $nlist = explode(" ", $this->main->nameserver); $nstring = null; foreach ($nlist as $l) { $nstring .= "nameserver {$l}\n"; } lfile_put_contents("{$mountpoint}/etc/resolv.conf", $nstring); } if ($this->main->timezone) { lxfile_rm("{$mountpoint}/etc/localtime"); $cmdstring = "ln -sf ../usr/share/zoneinfo/{$this->main->timezone} {$mountpoint}/etc/localtime"; log_log("localtime", $cmdstring); do_exec_system('__system__', "/", $cmdstring, $out, $err, $ret, null); //lxfile_cp("/usr/share/zoneinfo/{$this->main->timezone}", "$mountpoint/etc/localtime"); } lunlink("{$mountpoint}/etc/sysconfig/network-scripts/ifcfg-venet0"); lunlink("{$mountpoint}/etc/sysconfig/network-scripts/ifcfg-venet0:0"); $this->main->doKloxoInit($mountpoint); }
function delDomain() { global $gbl, $sgbl, $login, $ghtml; // Very important. If the nname is null, then the 'rm -rf' command will delete all the domains. // So please be carefule here. Must find a better way to delete stuff. if (!$this->main->nname) { return; } // MR -- don't need updateMainConfFile() for new structure but directly delete domain config file // $this->updateMainConfFile(); $plist = array('domains', 'redirects', 'wildcards', 'exclusive'); $bpath = "/home/apache/conf"; foreach ($plist as $k => $v) { lxfile_rm("{$bpath}/{$v}/{$this->main->nname}.conf"); } $this->main->deleteDir(); self::createSSlConf($this->main->__var_ipssllist, $this->main->__var_domainipaddress); }
function updatecleanup() { setPrepareKloxo(); // Fixes #303 and #304 installThirdparty(); install_gd(); install_bogofilter(); setInitialPhpMyAdmin(); setInitialAdminAccount(); setInitialKloxoPhp(); installWebmail(); installAwstats(); setRemoveOldDirs(); setInitialBinary(); log_cleanup("Remove lighttpd errorlog"); log_cleanup("- Remove process"); remove_lighttpd_error_log(); log_cleanup("Fix the secure logfile"); log_cleanup("- Fix process"); call_with_flag("fix_secure_log"); log_cleanup("Clean hosts.deny"); log_cleanup("- Clean process"); call_with_flag("remove_host_deny"); log_cleanup("Turn off mouse daemon"); log_cleanup("- Turn off process"); system("chkconfig gpm off"); if (lxfile_exists("phpinfo.php")) { log_cleanup("Remove phpinfo.php"); log_cleanup("- Remove process"); lxfile_rm("phpinfo.php"); } setInitialBind(); log_cleanup("Killing gettraffic system process"); log_cleanup("- Killing process"); lxshell_return("pkill", "-f", "gettraffic"); setCheckPackages(); copy_script(); install_xcache(); log_cleanup("Install Kloxo service"); log_cleanup("- Install process"); lxfile_unix_chmod("/etc/init.d/kloxo", "0755"); system("chkconfig kloxo on"); setJailshellSystem(); log_cleanup("Set /home permission to 0755"); log_cleanup("- Set process"); lxfile_unix_chmod("/home", "0755"); setExecuteCentos5Script(); fix_rhn_sources_file(); setInitialApacheConfig(); setInitialPureftpConfig(); setInstallMailserver(); log_cleanup("Enable xinetd service"); log_cleanup("- Enable process"); call_with_flag("enable_xinetd"); fix_suexec(); if (!lxfile_exists("/usr/bin/php-cgi")) { log_cleanup("Initialize php-cgi binary"); log_cleanup("- Initialize process"); lxfile_cp("/usr/bin/php", "/usr/bin/php-cgi"); } setSomePermissions(); setInitialLighttpdConfig(); setInitialNobodyScript(); setSomeScript(); log_cleanup("Install /etc/init.d/djbdns service file"); log_cleanup("- Install process"); lxfile_cp("../file/djbdns.init", "/etc/init.d/djbdns"); removeOtherDrivers(); log_cleanup("Remove cache dir"); log_cleanup("- Remove process"); lxfile_rm_rec("__path_program_root/cache"); log_cleanup("Restart syslog service"); log_cleanup("- Restart process"); createRestartFile('syslog'); log_cleanup("Initialize awstats dirdata"); log_cleanup("- Initialize process"); lxfile_mkdir("/home/kloxo/httpd/awstats/dirdata"); setInitialLogrotate(); installRoundCube(); installHorde(); installChooser(); log_cleanup("Remove old lxlabs ssh key"); log_cleanup("- Remove process"); remove_ssh_self_host_key(); setInitialServer(); setDefaultPages(); installInstallApp(); setFreshClam(); changeMailSoftlimit(); }
static function getMetaData($file) { global $gbl, $sgbl, $login, $ghtml; $progname = $sgbl->__var_program_name; if (!lxfile_exists($file)) { throw new lxException('could_not_find_file', '', $file); } $tmpdir = lxbackup::createTmpDirIfitDoesntExist($file, false); print_time("create_tmp_dir", "Creating Tmp Directory"); $filename = recursively_get_file($tmpdir, "{$progname}.file"); // KLoxo has to recognize lxadmin's backup file. if (!$filename && $sgbl->isKloxoForRestore()) { $filename = recursively_get_file($tmpdir, "lxadmin.file"); } $rem = unserialize(file_get_contents($filename)); $bugfix = $tmpdir . $progname . ".file"; lxfile_rm($bugfix); $bugfix = $tmpdir . $progname . ".metadata"; lxfile_rm($bugfix); lxfile_tmp_rm_rec($tmpdir); lxfile_rm_rec($tmpdir); if (!$rem) { throw new lxException('backupfile_corrupted', ''); } return $rem; }
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 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 createIniFile() { $pclass = $this->main->getParentClass(); $ver = find_php_version(); //dprintr($this->main->phpini_flag_b); $this->initString($ver); //dprintr($this->main->phpini_flag_b); $header = lfile_get_contents("../file/phpini/php.ini.template-{$ver}"); $cont = lfile_get_contents("../file/phpini/php.ini.temp"); $htcont = lfile_get_contents("../file/phpini/htaccesstemp"); $vlist = array("enable_zend_val", "enable_ioncube_val", "enable_xcache_val"); $l1 = $this->main->getInheritedList(); $l2 = $this->main->getLocalList(); $l3 = $this->main->getExtraList(); $ll = lx_array_merge(array($l1, $l2, $l3)); $list = array_unique($ll); foreach ($list as $l) { $vl = strtil($l, "_flag") . "_val"; if (array_search_bool($vl, $vlist)) { continue; } list($cont, $htcont) = $this->replacestr(array($cont, $htcont), $l); } foreach ($vlist as $vl) { list($cont) = $this->replacestr(array($cont), $vl); } /* list($cont) = $this->replacestr(array($cont), 'enable_zend_val'); list($cont) = $this->replacestr(array($cont), 'enable_ioncube_val'); list($cont) = $this->replacestr(array($cont), 'enable_xcache_val'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'register_global_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'output_compression_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'display_error_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'file_uploads_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'upload_max_filesize'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'log_errors_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'upload_tmp_dir_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'output_buffering_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'register_argc_argv_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'magic_quotes_gpc_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'variables_order_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'magic_quotes_runtime_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'magic_quotes_sybase_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'gpc_order_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'extension_dir_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'enable_dl_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'mysql_allow_persistent_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'disable_functions_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'max_execution_time_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'max_input_time_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'memory_limit_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'post_max_size_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'register_long_arrays_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'allow_url_fopen_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'allow_url_include_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'session_save_path_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'cgi_force_redirect_flag'); list($cont, $htcont) = $this->replacestr(array($cont, $htcont), 'safe_mode_flag'); */ $stlist[] = "###Start Kloxo PHP config Area"; $stlist[] = "###Start Lxdmin Area"; $stlist[] = "###Start Kloxo Area"; $stlist[] = "###Start Lxadmin PHP config Area"; $endlist[] = "###End Kloxo PHP config Area"; $endlist[] = "###End Kloxo Area"; $endlist[] = "###End Lxadmin PHP config Area"; $endstring = $endlist[0]; $startstring = $stlist[0]; if ($pclass === 'pserver') { $file = "/etc/php.ini"; if (!lxfile_exists("__path_kloxo_back_phpini")) { lxfile_cp("/etc/php.ini", "__path_kloxo_back_phpini"); } $this->enableDisableModule("enable_xcache_flag", "xcache"); $htfile = null; $extrafile = "/etc/custom.php.ini"; $extrastring = lfile_get_contents("/etc/custom.php.ini"); $cont = "{$extrastring}\n{$cont}"; } else { $dname = $this->main->getParentName(); $elogfile = "/home/{$this->main->__var_customer_name}/__processed_stats/{$this->main->getParentName()}.phplog"; $file = "__path_httpd_root/{$this->main->getParentName()}/php.ini"; $extrafile = "__path_httpd_root/{$this->main->getParentName()}/custom.php.ini"; $extrastring = lfile_get_contents($extrafile); $htfile = "{$this->main->__var_docrootpath}/.htaccess"; $ht1file = "/home/httpd/{$this->main->getParentName()}/kloxoscript/.htaccess"; $htcont = "php_value error_log {$elogfile}\n{$htcont}"; $htcont = "<Ifmodule mod_php4.c>\n{$htcont}\n</Ifmodule>\n<Ifmodule mod_php5.c>\n{$htcont}\n</Ifmodule>\n"; file_put_between_comments($stlist, $endlist, $startstring, $endstring, $htfile, $htcont); file_put_between_comments($stlist, $endlist, $startstring, $endstring, $ht1file, $htcont); lxfile_unix_chown($htfile, "{$this->main->__var_web_user}:apache"); $adminbasedir = trim($this->main->__var_extrabasedir); if (!$this->main->isOn('__var_disable_openbasedir')) { $cont = "open_basedir = /home/{$this->main->__var_customer_name}:{$adminbasedir}:/tmp:/usr/share/pear:/home/httpd/{$dname}:/var/lib/php/session:/home/kloxo/httpd/script:/home/httpd/{$dname}/kloxoscript/\n{$cont}"; } $cont = "error_log = {$elogfile}\n{$cont}"; $cont = "{$extrastring}\n{$cont}"; } lxfile_rm($file); lfile_put_contents($file, "{$header}\n{$cont}\n"); createRestartFile($this->main->__var_webdriver); }
function lxfile_rm_content($dir) { $username = "******"; $dir = expand_real_root($dir); $list = lscandir_without_dot($dir); foreach ($list as $l) { lxfile_rm("{$dir}/{$l}"); } }
function lxguard_main($clearflag = false) { include_once "htmllib/lib/lxguardincludelib.php"; lxfile_mkdir("__path_home_root/lxguard"); $lxgpath = "__path_home_root/lxguard"; $file = "/var/log/secure"; $fp = fopen($file, "r"); $fsize = filesize($file); $newtime = time(); $oldtime = time() - 60 * 10; $rmt = lfile_get_unserialize("{$lxgpath}/hitlist.info"); if ($rmt) { $oldtime = max((int) $oldtime, (int) $rmt->ddate); } $ret = FindRightPosition($fp, $fsize, $oldtime, $newtime, "getTimeFromSysLogString"); $list = lfile_get_unserialize("{$lxgpath}/access.info"); if ($ret) { parse_sshd_and_ftpd($fp, $list); lfile_put_serialize("{$lxgpath}/access.info", $list); } get_total($list, $total); //dprintr($list['192.168.1.11']); dprintr($total); $deny = get_deny_list($total); $hdn = lfile_get_unserialize("{$lxgpath}/hostdeny.info"); $deny = lx_array_merge(array($deny, $hdn)); $string = null; foreach ($deny as $k => $v) { if (csb($k, "127")) { continue; } $string .= "ALL : {$k}\n"; } dprint($string); $stlist[] = "###Start Program Hostdeny config Area"; $stlist[] = "###Start Lxdmin Area"; $stlist[] = "###Start Kloxo Area"; $stlist[] = "###Start Lxadmin Area"; $endlist[] = "###End Program HostDeny config Area"; $endlist[] = "###End Kloxo Area"; $endlist[] = "###End Lxadmin Area"; $startstring = $stlist[0]; $endstring = $endlist[0]; file_put_between_comments($stlist, $endlist, $startstring, $endstring, "/etc/hosts.deny", $string); if ($clearflag) { lxfile_rm("{$lxgpath}/access.info"); $rmt = new Remote(); $rmt->hl = $total; $rmt->ddate = time(); lfile_put_serialize("{$lxgpath}/hitlist.info", $rmt); } return $list; }
function createIniFile() { $pclass = $this->main->getParentClass(); $ver = find_php_version(); $this->initString($ver); $header = lfile_get_contents("../file/phpini/php.ini.template-{$ver}"); $cont = lfile_get_contents("../file/phpini/php.ini.temp"); $htcont = lfile_get_contents("../file/phpini/htaccesstemp"); $vlist = array("enable_zend_val", "enable_ioncube_val", "enable_xcache_val"); $l1 = $this->main->getInheritedList(); $l2 = $this->main->getLocalList(); $l3 = $this->main->getExtraList(); $ll = lx_array_merge(array($l1, $l2, $l3)); $list = array_unique($ll); foreach ($list as $l) { $vl = strtil($l, "_flag") . "_val"; if (array_search_bool($vl, $vlist)) { continue; } list($cont, $htcont) = $this->replacestr(array($cont, $htcont), $l); } foreach ($vlist as $vl) { list($cont) = $this->replacestr(array($cont), $vl); } $stlist[] = "###Start Kloxo PHP config Area"; $stlist[] = "###Start Lxdmin Area"; $stlist[] = "###Start Kloxo Area"; $stlist[] = "###Start Lxadmin PHP config Area"; $endlist[] = "###End Kloxo PHP config Area"; $endlist[] = "###End Kloxo Area"; $endlist[] = "###End Lxadmin PHP config Area"; $endstring = $endlist[0]; $startstring = $stlist[0]; if ($pclass === 'pserver') { $file = "/etc/php.ini"; if (!lxfile_exists("__path_kloxo_back_phpini")) { lxfile_cp("/etc/php.ini", "__path_kloxo_back_phpini"); } $this->enableDisableModule("enable_xcache_flag", "xcache"); $htfile = null; $extrafile = "/etc/custom.php.ini"; if (lxfile_exists($extrafile)) { $extrastring = lfile_get_contents($extrafile); $cont = "{$extrastring}\n{$cont}"; } else { $cont = "{$cont}"; } } else { $dname = $this->main->getParentName(); $elogfile = "/home/{$this->main->__var_customer_name}/__processed_stats/{$this->main->getParentName()}.phplog"; $file = "__path_httpd_root/{$this->main->getParentName()}/php.ini"; $extrafile = "__path_httpd_root/{$this->main->getParentName()}/custom.php.ini"; if (lxfile_exists($extrafile)) { $extrastring = lfile_get_contents($extrafile); } else { $extrastring = ""; } // ToDo #590 - disable appear on .htaccess // REVERT - back to enable because mod_php tend to share-based php.ini // and some parameters of domain specific must be declare inside .htaccess $htfile = "{$this->main->__var_docrootpath}/.htaccess"; $ht1file = "/home/{$this->main->__var_customer_name}/kloxoscript/.htaccess"; $htcont = "php_value error_log \"{$elogfile}\"\n{$htcont}"; $htcont = str_replace("\n", "\n\t", $htcont); $htcont = str_replace($htcont, "\t" . $htcont, $htcont); $htcont = "\n<Ifmodule mod_php4.c>\n{$htcont}\n</Ifmodule>\n\n<Ifmodule mod_php5.c>\n{$htcont}\n</Ifmodule>\n"; file_put_between_comments("{$this->main->__var_web_user}:apache", $stlist, $endlist, $startstring, $endstring, $htfile, $htcont); file_put_between_comments("{$this->main->__var_web_user}:apache", $stlist, $endlist, $startstring, $endstring, $ht1file, $htcont); lxfile_unix_chown($htfile, "{$this->main->__var_web_user}:apache"); // MR --- set the same like AddOpenBaseDir() on web__apachelib.php $clname = $this->main->__var_customer_name; $adminbasedir = trim($this->main->__var_extrabasedir); if ($adminbasedir) { $adminbasedir .= ":"; } if (!$this->main->isOn('__var_disable_openbasedir')) { $path = "{$adminbasedir}"; $path .= "/home/{$clname}:"; $path .= "/home/{$clname}/kloxoscript:"; $path .= "/home/httpd/{$dname}:"; $path .= "/home/httpd/{$dname}/httpdocs:"; $path .= "/tmp:"; $path .= "/usr/share/pear:"; $path .= "/var/lib/php/session:"; $path .= "/home/kloxo/httpd/script"; $cont = "open_basedir = \"{$path}\"\n\n{$cont}"; } $cont = "error_log = \"{$elogfile}\"\n{$cont}"; $cont = "{$extrastring}\n{$cont}"; } lxfile_rm($file); lfile_put_contents($file, "{$header}\n{$cont}\n"); createRestartFile($this->main->__var_webdriver); }
function syncCreateConf() { global $gbl, $sgbl, $login, $ghtml; global $global_shell_error; if_demo_throw_exception('cron'); $conf_file = "__path_cron_root/{$this->main->username}"; $list = array('minute', 'hour', 'weekday', 'ddate', 'month'); $tfile = lx_tmp_file($conf_file); $cmd = null; if ($this->main->__var_mailto) { $cmd .= "MAILTO={$this->main->__var_mailto}\n"; } $result = $this->main->__var_cron_list; foreach ($result as &$__r) { foreach ($list as $l) { $__r[$l] = unserialize(base64_decode($__r["ser_{$l}"])); } } $result = merge_array_object_not_deleted($result, $this->main); //dprintr($result); foreach ((array) $result as $v) { if ($v['ttype'] === 'simple') { $v['weekday'] = array('--all--'); $v['month'] = array('--all--'); $v['ddate'] = array('--all--'); if ($v['simple_cron'] === 'every-day') { $v['hour'] = $v['cron_day_hour']; $v['minute'] = 0; } if ($v['simple_cron'] === 'every-hour') { $v['hour'] = array('--all--'); $v['minute'] = 0; } if ($v['simple_cron'] === 'every-minute') { $v['hour'] = array('--all--'); $v['minute'] = array('--all--'); } } else { foreach ($v["weekday"] as &$___tq) { if (is_numeric($___tq)) { $___tq -= 1; } } } foreach ($list as $l) { $v[$l] = $this->getCronString($v[$l]); } if (!$v['minute']) { $v['minute'] = 0; } $cmd .= implode("\t", array($v['minute'], $v['hour'], $v['ddate'], $v['month'], $v['weekday'], $v['command'])); $cmd .= "\n"; } lfile_put_contents($tfile, $cmd); if (!posix_getpwnam($this->main->username)) { lxfile_rm("/var/spool/cron/{$this->main->username}"); return; } $ret = lxshell_return("crontab", "-u", $this->main->username, $tfile); if ($ret) { // Why exactly was a throw removed? backup/restore? //throw new lxException("adding_cron_failed", "", $global_shell_error); $gbl->setWarning('adding_cron_failed', '', $global_shell_error); $data = lfile_get_contents($tfile); log_log("cron_error", $data); } lunlink($tfile); }
function doKloxoInit($mountpoint) { if (lxfile_exists("{$mountpoint}/usr/local/lxlabs/kloxo/")) { lfile_put_contents("{$mountpoint}/usr/local/lxlabs/kloxo/etc/authorized_keys", $this->text_public_key); if ($this->isOn('__var_kloxo_remote_i_flag')) { lfile_put_contents("{$mountpoint}/usr/local/lxlabs/kloxo/etc/remote_installapp", $this->__var_kloxo_iapp_url); } else { lxfile_rm("{$mountpoint}/usr/local/lxlabs/kloxo/etc/remote_installapp"); } } if (lxfile_exists("{$mountpoint}/usr/local/lxlabs/lxadmin/")) { lfile_put_contents("{$mountpoint}/usr/local/lxlabs/lxadmin/etc/authorized_keys", $this->text_public_key); if ($this->isOn('__var_kloxo_remote_i_flag')) { lfile_put_contents("{$mountpoint}/usr/local/lxlabs/lxadmin/etc/remote_installapp", $this->__var_kloxo_iapp_url); } else { lxfile_rm("{$mountpoint}/usr/local/lxlabs/lxadmin/etc/remote_installapp"); } } }
function dbactionDelete() { global $gbl, $sgbl, $login, $ghtml; $dnsfile = "{$sgbl->__path_mara_chroot}/{$sgbl->__path_mara_path}/{$this->main->nname}"; lxfile_rm($dnsfile); foreach ((array) $this->main->__var_addonlist as $d) { $dnsfile = "{$sgbl->__path_mara_chroot}/{$sgbl->__path_mara_path}/{$d->nname}"; lxfile_rm($dnsfile); } $this->syncCreateConf(); }
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"); } }
function doUpdateExtraStuff() { global $gbl, $sgbl, $login, $ghtml; lxfile_mkdir("__path_program_etc/flag"); print "Check database password\n"; $a = null; fix_mysql_root_password('localhost'); $dbadmin = new Dbadmin(null, 'localhost', "mysql___localhost"); $dbadmin->get(); $pass = $dbadmin->dbpassword; $a['mysql']['dbpassword'] = $pass; slave_save_db("dbadmin", $a); print "Check the core database\n"; parse_sql_data(); if (call_with_flag("convertIpaddressToComa")) { print "Converted IP addresses in database\n"; } if (call_with_flag("fixExtraDB")) { print "- Fixed\n"; } print "Set OS template permissions\n"; if (is_openvz()) { lxfile_unix_chmod_rec("/vz/template/cache/", "0755"); } else { lxfile_unix_chmod_rec("/home/hypervm/xen/template/", "0755"); } call_with_flag("dofixParentClname"); print "Get License\n"; // ToDo: Why is this called this way.... passthru("{$sgbl->__path_php_path} htmllib/lbin/getlicense.php"); if (is_openvz()) { print "Check OpenVZ resources\n"; if (call_with_flag("fixOpenVZResource")) { print "- Fixed\n"; } } if (move_clients_to_client()) { print "Renamed clients directory to client.\n"; } print "Checking backup dirs\n"; if (!add_vps_backup_dir()) { print "- Everything is fine.\n"; } print "Fix IP POOL\n"; lxshell_return("__path_php_path", "../bin/fix/fixippool.php"); if (call_with_flag("fix_ipaddress_column_type")) { print "Fixed IP address column in database\n"; } if (call_with_flag("fix_vmipaddress")) { print "Fixed VM IP addresses in database\n"; } print "Checking HIB template\n"; get_kloxo_ostemplate(); if (db_get_value("client", "admin", "contactemail")) { print "Set admin email\n"; save_admin_email(); } // Unknown usage within HyperVM, anyone can tell what this is doing? $file = "__path_program_root/etc/fixed_interface_template_sql"; if (lxfile_exists($file)) { lxfile_touch($file); print "Check Interface Template (database)\n"; system("mysql -u hypervm -p`cat ../etc/conf/hypervm.pass` hypervm1_0 < ../file/interface/interface_template.sql"); } if (lxfile_exists("/etc/init.d/libvirtd")) { print "Make sure libvirtd is not started after reboot\n"; system("chkconfig libvirtd off 2>/dev/null"); } if (is_openvz()) { print "Checking for Base default OS template\n"; $OSTemplateDir = "/vz/template/cache"; $defaultOSTemplate = "centos-6-x86.tar.gz"; $defaultOSTemplateName = "centos-6-x86"; if (!lxfile_exists($OSTemplateDir)) { lxfile_mkdir($OSTemplateDir); } if (!lxfile_real("{$OSTemplateDir}/{$defaultOSTemplate}")) { lxfile_rm("{$OSTemplateDir}/{$defaultOSTemplate}"); system("cd {$OSTemplateDir}/ ; wget http://download.hypervm-ng.org/download/openvztemplates/base/{$defaultOSTemplate}"); system("rm {$OSTemplateDir}/index.html* 2>/dev/null"); system("rm {$OSTemplateDir}/robots.txt* 2>/dev/null"); } // Added in HyperVM 2.1.0 if (lxfile_exists("/usr/sbin/vztmpl-dl")) { print "Checking for latest version of {$defaultOSTemplateName} at OpenVZ.org website\n"; $res = system("/usr/sbin/vztmpl-dl --update {$defaultOSTemplateName} 2>/dev/null"); dprint("res: {$res}\n"); } } else { if (!lxfile_real("/home/hypervm/xen/template/centos-6-x86-pygrub-sda-latest.tar.gz")) { system("mkdir -p /home/hypervm/xen/template ; cd /home/hypervm/xen/template/ ; rm centos-6-i386.tar.gz; rm centos-5-i386.tar.gz; rm centos-5-i386-afull.tar.gz; rm centos-6-x86-pygrub-sda-latest.tar.gz; wget http://download.hypervm-ng.org/download/xentemplates/base/centos-6-x86-pygrub-sda-latest.tar.gz"); system("rm /home/hypervm/xen/template/index.html* 2>/dev/null"); system("rm /home/hypervm/xen/template/robots.txt* 2>/dev/null"); } } print "Check for old critical database password bug\n"; if (critical_change_db_pass()) { print "- Fixed critical database password bug!!!\n"; } else { print "- Good! Already bug free :-)\n"; } if (lxfile_exists("/etc/yum.repos.d/lxlabs.repo")) { print "Delete old repo's\n"; lxfile_mv("/etc/yum.repos.d/lxlabs.repo", "/etc/yum.repos.d/lxlabs.repo.lxsave"); system("rm -f /etc/yum.repos.d/lxlabs.repo"); print "Removed lxlabs.repo\n"; } }
function dbactionDelete() { global $gbl, $sgbl, $login, $ghtml; $this->checkForEthBase(); $dev = explode("-", $this->main->devname); if (count($dev) >= 2) { $actualname = implode(":", $dev); } else { $actualname = $this->main->devname; } $ipaddrfile = "{$sgbl->__path_real_etc_root}/sysconfig/network-scripts/ifcfg-" . $actualname; lxshell_return("ifdown", $actualname); lxfile_rm($ipaddrfile); createRestartFile($this->main->__var_dnsdriver); }
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"); } }
function dbactionDelete() { global $gbl, $sgbl, $login, $ghtml; $dnsfile = "/var/dnscache/root/servers/{$this->main->nname}"; $tinyfile = "/var/tinydns/root/kloxo/{$this->main->nname}.data"; lxfile_rm($dnsfile); lxfile_rm($tinyfile); foreach ((array) $this->main->__var_addonlist as $d) { $dnsfile = "/var/dnscache/root/servers/{$d->nname}"; $tinyfile = "/var/tinydns/root/kloxo/{$d->nname}.data"; lxfile_rm($dnsfile); lxfile_rm($tinyfile); } $this->syncCreateConf(); }
function uploadDirect() { $filename = "{$this->main->getFullPath()}/{$this->main->upload_file_name}"; check_file_if_owned_by_and_throw($filename, $this->main->__username_o); dprintr($this->main->upload_overwrite_f); if (lfile_exists($filename)) { if (!$this->main->isOn('upload_overwrite_f')) { throw new lxexception('file_exists_upload', 'upload_name_f'); } else { lxfile_rm($filename); } } dprintr($this->main); getFromFileserv($this->main->__var_upload_tmp_server, $this->main->__var_upload_filepass, $filename); return $filename; }
// include_once "htmllib/lib/include.php"; if (!$sgbl->is_this_slave()) { $pass = slave_get_db_pass(); $res = mysql_connect("localhost", "root", $pass); if (!$res) { print "Could not connect to MySQL as root. Please login via webinterface, go to admin home -> reset mysql password and reset the password and run this again.\n"; exit; } } lxshell_return("service", "lxadmin", "stop"); lxshell_return("chkconfig", "lxadmin", "off"); lxfile_rm("/etc/init.d/lxadmin"); lxfile_mkdir("/usr/local/lxlabs/kloxo"); chdir("/usr/local/lxlabs/kloxo/"); lxfile_rm("kloxo-current.zip"); system("wget http://download.lxcenter.org/download/kloxo/production/kloxo/kloxo-current.zip"); system("unzip -oq kloxo-current.zip"); lxfile_rm_rec("/usr/local/lxlabs/kloxo/etc/"); lxfile_cp_rec("/usr/local/lxlabs/lxadmin/etc/", "/usr/local/lxlabs/kloxo/etc/"); if (!$sgbl->is_this_slave()) { system("service mysqld stop"); if (!lxfile_exists("/var/lib/mysql/kloxo/")) { lxfile_cp_rec("/var/lib/mysql/lxadmin4_2", "/var/lib/mysql/kloxo"); } lxfile_unix_chown_rec("/var/lib/mysql/kloxo", "mysql:mysql"); system("service mysqld start"); sleep(10); chdir("/usr/local/lxlabs/lxadmin/httpdocs/"); passthru("lphp.exe ../bin/kloxo-db.php"); }