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 mebackup_main() { global $gbl, $sgbl, $login, $ghtml; $progname = $sgbl->__var_program_name; $cprogname = ucfirst($progname); initProgram('admin'); lxfile_mkdir("__path_program_home/selfbackup/self/__backup"); $backup = $login->getObject('general')->selfbackupparam_b; $dbf = $sgbl->__var_dbf; $pass = trim(lfile_get_contents("__path_program_root/etc/conf/{$progname}.pass")); $vd = createTempDir("/tmp", "mebackup"); $docf = "{$vd}/mebackup.dump"; // Issue #671 - Fixed backup-restore issue // exec("exec mysqldump --add-drop-table -u $progname -p$pass $dbf > $docf"); system("exec mysqldump --add-drop-table -u {$progname} -p{$pass} {$dbf} > {$docf}"); $string = @date('Y-M-d') . '-' . time(); $bfile = "{$sgbl->__path_program_home}/selfbackup/self/__backup/{$progname}-scheduled-masterselfbackup-{$string}.zip"; lxshell_zip($vd, $bfile, array("mebackup.dump")); lxfile_tmp_rm_rec($vd); if ($backup && $backup->isOn('selfbackupflag')) { try { lxbackup::upload_to_server($bfile, basename($bfile), $backup); } catch (Exception $e) { print "Sending warning to {$login->contactemail} ..\n"; lx_mail(null, $login->contactemail, "{$cprogname} Self Database Backup Upload Failed on " . date('Y-M-d') . " at " . date('H') . " Hours", "{$cprogname} Backup upload Failed due to {$e->getMessage()}\n"); } } $backup->rm_last_number = 20; $backup->nname = 'masterselfbackup'; lxbackup::clear_extra_backups('selfbackup', 'self', $backup); }
static function MakeSureDirectoryExists($name) { if (!lxfile_exists($name)) { lxfile_mkdir($name); lxfile_generic_chown($name, "lxlabs"); } }
function fixlogdir_main() { global $gbl, $sgbl, $login, $ghtml; $progname = $sgbl->__var_program_name; $logl = lscandir_without_dot("../log"); lxfile_mkdir("../processed_log"); @lunlink("../log/access_log"); @lunlink("/usr/local/lxlabs/ext/php/error.log"); $dir = getNotexistingFile("../processed_log", "proccessed"); system("mv ../log ../processed_log/{$dir}"); mkdir("../log"); $list = lscandir_without_dot("../processed_log"); foreach ($list as $l) { remove_directory_if_older_than_a_day("../processed_log/{$l}", 6); } foreach ($logl as $l) { lxfile_touch("../log/{$l}"); } lxfile_generic_chown_rec("../log", "lxlabs:lxlabs"); // // Related to Issue #15 // lxfile_generic_chmod_rec("../log", "0640"); lxfile_generic_chmod_rec("../processed_log", "0640"); lxfile_generic_chmod("../log", "0700"); lxfile_generic_chmod("../processed_log", "0700"); lxfile_generic_chmod("../log/lighttpd_error.log", "0644"); lxfile_generic_chmod("../log/access_log", "0644"); lxfile_generic_chown("../log/lighttpd_error.log", "lxlabs:root"); lxfile_generic_chown("../log/access_log", "lxlabs:root"); // os_restart_program(); }
function lxfile_disk_free_space($dir) { $dir = expand_real_root($dir); lxfile_mkdir($dir); $ret = disk_free_space($dir); $ret = round($ret / (1024 * 1024), 1); log_shell("Disk Space {$dir} {$ret}"); return $ret; }
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 __xenimport_get_data() { lxfile_mkdir("/home/oldxenconfig-hypervm"); $list = lscandir_without_dot("/etc/xen/oldxen"); foreach ($list as $l) { $vm[] = __xenimport_parse_config("/etc/xen/oldxen/{$l}"); //lxfile_mv("/etc/xen/$l", "/home/oldxenconfig-hypervm"); lunlink("/etc/xen/auto/{$l}"); } dprintr($vm); return $vm; }
function create_main() { global $argc, $argv; global $gbl, $sgbl, $login, $ghtml; $opt = parse_opt($argv); if (file_exists('/usr/local/lxlabs/.git')) { $opt['development_found'] = '1'; } lxfile_mkdir("{$sgbl->__path_program_etc}/conf"); lxfile_mkdir("{$sgbl->__path_program_root}/pid"); lxfile_mkdir("{$sgbl->__path_program_root}/log"); lxfile_mkdir("{$sgbl->__path_httpd_root}"); os_create_program_service(); if (isset($opt['admin-password'])) { $admin_pass = $opt['admin-password']; } else { $admin_pass = '******'; } if ($opt['install-type'] == 'master') { if (!isset($opt['development_found'])) { create_mysql_db('master', $opt, $admin_pass); create_database(); create_general(); add_admin($admin_pass); create_servername(); lxshell_return("__path_php_path", "../bin/collectquota.php"); } else { print "Development GIT version found. Skipping creation from scratch of HyperVM-NG.\n"; } print "Updating the system. Will take a while\n"; system("/usr/local/lxlabs/ext/php/php ../bin/common/updatecleanup-main.php --type=master"); } else { if ($opt['install-type'] == 'slave') { if (!isset($opt['development_found'])) { init_slave($admin_pass); } else { print "Development GIT version found. Skipping creation from scratch of HyperVM-NG.\n"; } print "Updating the system. Will take a while\n"; system("/usr/local/lxlabs/ext/php/php ../bin/common/updatecleanup-main.php --type=slave"); } else { print "Unknown Install type\n"; flush(); } } system("rm -f /etc/sysconfig/network-scripts/ifcfg-*-range*"); //system("$sgbl->__path_php_path ../bin/misc/fixcentos5xen.php"); //os_fix_some_permissions(); system("cp ../sbin/lxxen ../sbin/lxopenvz /usr/bin"); system("chmod 4755 /usr/bin/lxxen /usr/bin/lxopenvz"); //os_set_iis_ftp_root_path(); }
function __xenimport_get_data() { lxfile_mkdir("/home/oldxenconfig-hypervm"); $list = lscandir_without_dot("/home/xen"); foreach ($list as $l) { if (!cse($l, ".vm")) { continue; } $vm[] = __xenimport_parse_config("/home/xen/{$l}/{$l}.cfg"); //lxfile_mv("/etc/xen/$l", "/home/oldxenconfig-hypervm"); } dprintr($vm); return $vm; }
function createVirtualHost() { $string = null; foreach ($this->main->__var_domlist as $v) { $string .= "\$HTTP[\"host\"] =~ \"^{$v}\" {\n"; $string .= "server.document-root = \"/usr/local/lxlabs/kloxo/httpdocs/webdisk/\"\n"; $string .= "cgi.assign = ( \".php\" => \"/home/httpd/{$v}/davsuexec.sh\" )\n"; $string .= $this->getDirprotectCore($v); $string .= "}\n\n\n"; lxfile_mkdir("__path_httpd_root/{$v}/__davuser/"); lxfile_touch("__path_httpd_root/{$v}/__davuser/davuser"); } return $string; }
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 write() { lxfile_mkdir("__path_program_root/session"); if ($this->isDeleted()) { lunlink("__path_program_root/session/{$this->nname}"); } else { foreach ($this as $k => $v) { if (is_object($v)) { continue; } $array[$k] = $v; } lfile_put_json_serialize("__path_program_root/session/{$this->nname}", $array); } }
function create_main() { global $argc, $argv; global $gbl, $sgbl, $login, $ghtml; $opt = parse_opt($argv); lxfile_mkdir("{$sgbl->__path_program_etc}/conf"); lxfile_mkdir("{$sgbl->__path_program_root}/pid"); lxfile_mkdir("{$sgbl->__path_program_root}/log"); lxfile_mkdir("{$sgbl->__path_httpd_root}"); os_fix_lxlabs_permission(); os_create_program_service(); os_create_kloxo_service_once(); if (isset($opt['admin-password'])) { $admin_pass = $opt['admin-password']; } else { $admin_pass = '******'; } if ($opt['install-type'] == 'master') { create_mysql_db('master', $opt, $admin_pass); create_database(); create_general(); init_main($admin_pass); lxshell_return("__path_php_path", "../bin/collectquota.php"); print "This will take a long time... Please wait...\n"; system("/usr/local/lxlabs/ext/php/php ../bin/common/tmpupdatecleanup.php --type=master"); } else { if ($opt['install-type'] == 'slave') { init_slave($admin_pass); print "This will take a long time... Please wait...\n"; system("/usr/local/lxlabs/ext/php/php ../bin/common/tmpupdatecleanup.php --type=slave"); } else { if ($opt['install-type'] == 'supernode') { $sgbl->__path_sql_file = $sgbl->__path_sql_file_supernode; $sgbl->__var_dbf = $sgbl->__path_supernode_db; $sgbl->__path_admin_pass = $sgbl->__path_super_pass; $sgbl->__var_admin_user = $sgbl->__var_super_user; create_mysql_db('super', $opt, $admin_pass); init_supernode($admin_pass); print "\n"; } else { print "Unknown Install type\n"; flush(); } } } os_create_default_slave_driver_db(); os_fix_some_permissions(); }
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(); }
function __xenimport_get_data() { lxfile_mkdir("/home/oldxenconfig-hypervm"); $list = lscandir_without_dot("/etc/hypervm/"); foreach ($list as $l) { if (!csb($l, "xm")) { continue; } if (csb($l, "xmexample")) { continue; } $vm[] = __xenimport_parse_config("/etc/xen/{$l}"); //lxfile_mv("/etc/xen/$l", "/home/oldxenconfig-hypervm"); lunlink("/etc/xen/auto/{$l}"); } dprintr($vm); return $vm; }
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"); } } }
function add_admin($pass) { global $gbl, $sgbl, $login, $ghtml; $client = new Client(null, null, 'admin'); $login = $client; $client->initThisDef(); $client->priv->pserver_num = 'Unlimited'; $client->priv->maindomain_num = 'Unlimited'; $client->priv->vps_num = 'Unlimited'; $client->priv->client_num = 'Unlimited'; $client->ddate = time(); $ddb = new Sqlite(null, "client"); if (!$ddb->existInTable("nname", 'admin')) { if ($sgbl->dbg > 0) { $pass = '******'; $res['contacemail'] = '*****@*****.**'; } $res['password'] = crypt($pass); $res['cttype'] = 'admin'; $res['cpstatus'] = 'on'; if (if_demo()) { $res['email'] = "*****@*****.**"; } $client->create($res); $client->driverApp = new client__sync(null, null, 'admin'); $client->was(); lxfile_mkdir("__path_client_root/{$client->nname}"); lxfile_generic_chown("__path_client_root/{$client->nname}", "lxlabs"); } $notif = new Notification(null, null, $client->getClName()); $notif->initThisDef(); $notif->dbaction = 'add'; $notif->text_newaccountmessage = lfile_get_contents("__path_program_root/file/welcome.txt"); $notif->parent_clname = $client->getClName(); $notif->write(); $display = new sp_SpecialPlay(null, null, $client->getClName()); $display->initThisDef(); $display->parent_clname = $client->getClName(); $display->dbaction = 'add'; $display->write(); }
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); }
function createUser() { global $gbl, $sgbl, $login, $ghtml; global $global_shell_out, $global_shell_error, $global_shell_ret; return; $mn = $this->main; $passwd = $mn->password; lxfile_mkdir("__path_httpd_root/" . $mn->getParentName()); $cmd = "useradd"; $shell = fix_disabled($this->main->shell, $sgbl->__var_noaccess_shell); $ret = lxshell_return($cmd, "-m", '-c', uuser::getUserDescription($this->main->getParentName()), "-k", "__path_program_root/file/user-skel/", "-d", "{$mn->getParentName()}/", "-s", $shell, "-p", $passwd, $mn->nname); if ($ret) { // Error... Do a lot of stuff; log_error($global_shell_out); throw new lxexception('user_create', 'web_s_uuser_s_nname', $this->main->nname); } /* if($mn->quota != "Unlimited"){ lxshell_return("setquota", "-ur", "-F", "vfsv0" , $mn->nname, "0", $mn->quota,"200", "0" ,"0", "-a" , "ext3"); } */ return 1; }
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 dbactionAdd() { $Flag = 0; //$iisid = $this->main->__var_iisid; $name = $this->main->nname; $path = $this->main->path; //$Dir = new COM("IIS://localhost/W3SVC/$iisid/ROOT/"); //$Dir->AuthAnonymous = False; //$Dir->setInfo(); $domname = $this->main->getParentName(); $dir = "__path_httpd_root/{$domname}/dirprotect/"; $authuserfile = "{$dir}/{$this->main->getFileName()}"; lxfile_mkdir($dir); $reauthstr = expand_real_root($authuserfile); $content = "AuthName {$this->main->authname}\n"; $content .= "AuthUserFile {$reauthstr}\n"; $content .= "Require valid-user\n"; $path = "__path_httpd_root/{$domname}/httpdocs/www/{$this->main->path}"; dprint(expand_real_root($path)); lfile_put_contents("{$path}/.htlxaccess", $content); lxfile_mkdir($dir); //lfile_put_contents($path . "/.htpasswd", $fstr); $this->createUser(); }
function getFromRemote($p) { $filepass = $this->main->filepass; getFromRemote($this->main->pasteserver_realip, $filepass[$p], $this->main->fullpath, $p); return; $bp = basename($p); if ($filepass[$p]['type'] === 'dir') { $tfile = lx_tmp_file("__path_tmp", "lx_{$bp}"); getFromFileserv($this->main->pasteserver, $this->main->filepass[$p], $tfile); lxfile_mkdir("{$this->main->fullpath}/{$bp}"); lxshell_unzip("__system__", "{$this->main->fullpath}/{$bp}", $tfile); lunlink($tfile); } else { getFromFileserv($this->main->pasteserver, $this->main->filepass[$p], "{$this->main->fullpath}/{$bp}"); } }
function checkRestart() { if (if_demo()) { return; } $res = lscandir_without_dot("__path_program_etc/.restart"); if ($res === false) { dprint(".restart does not exist... Creating\n"); lxfile_mkdir("__path_program_etc/.restart"); lxfile_generic_chown("__path_program_etc/.restart", "lxlabs"); } foreach ((array) $res as $r) { if (csb($r, "._restart_")) { $cmd = strfrom($r, "._restart_"); } lunlink("__path_program_etc/.restart/{$r}"); dprint("Restarting {$cmd}\n"); // THe 3,4 etc are the tcp ports of this program, and it should be closed, else some programs will grab it. //exec("/etc/init.d/$cmd restart </dev/null >/dev/null 2>&1 3</dev/null 4</dev/null 5</dev/null 6</dev/null &"); switch ($cmd) { case 'lxcollectquota': exec_justdb_collectquota(); break; case 'openvz_tc': exec_openvz_tc(); break; default: exec_with_all_closed("/etc/init.d/{$cmd} restart"); break; } } }
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; }
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"; } }
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"); } }
static function localfixDatabaseServers($list) { $string = <<<STRIN \$i++; \$cfg['Servers'][\$i]['host'] = '__hostname__'; \$cfg['Servers'][\$i]['port'] = ''; \$cfg['Servers'][\$i]['socket'] = ''; \$cfg['Servers'][\$i]['connect_type'] = 'tcp'; \$cfg['Servers'][\$i]['extension'] = 'mysql'; \$cfg['Servers'][\$i]['compress'] = FALSE; \$cfg['Servers'][\$i]['controluser'] = ''; \$cfg['Servers'][\$i]['controlpass'] = ''; \$cfg['Servers'][\$i]['auth_type'] = 'cookie'; \$cfg['Servers'][\$i]['user'] = ''; \$cfg['Servers'][\$i]['password'] = ''; \$cfg['Servers'][\$i]['only_db'] = ''; \$cfg['Servers'][\$i]['verbose'] = ''; \$cfg['Servers'][\$i]['pmadb'] = ''; // 'phpmyadmin' - see scripts/create_tables.sql \$cfg['Servers'][\$i]['bookmarktable'] = ''; // 'pma_bookmark' \$cfg['Servers'][\$i]['relation'] = ''; // 'pma_relation' \$cfg['Servers'][\$i]['table_info'] = ''; // 'pma_table_info' \$cfg['Servers'][\$i]['table_coords'] = ''; // 'pma_table_coords' \$cfg['Servers'][\$i]['pdf_pages'] = ''; // 'pma_pdf_pages' \$cfg['Servers'][\$i]['column_info'] = ''; // 'pma_column_info' \$cfg['Servers'][\$i]['history'] = ''; // 'pma_history' \$cfg['Servers'][\$i]['verbose_check'] = TRUE; \$cfg['Servers'][\$i]['AllowRoot'] = TRUE; \$cfg['Servers'][\$i]['AllowDeny']['order'] = ''; \$cfg['Servers'][\$i]['AllowDeny']['rules'] = array(); STRIN; $fstring = "<?php\n\n\$i = 0;\n"; foreach ($list as $l) { $nstring = str_replace("__hostname__", $l, $string); $fstring .= $nstring; } $fstring .= <<<STRIN \t\$cfg['ServerDefault'] = 1; // Default server (0 = no default server) \t\$cfg['Server'] = ''; \tunset(\$cfg['Servers'][0]); STRIN; $fstring .= "\n\n"; lxfile_mkdir("__path_program_etc/thirdparty/"); lfile_put_contents("__path_program_etc/thirdparty/phpmyadmin_servers.inc", $fstring); }
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; }
function do_upgrade($upversion) { global $gbl, $sgbl, $login, $ghtml; if (file_exists(".git")) { print "Development system.. Not upgrading --> exit!...\n"; exit; } $maj = $sgbl->__ver_major; $program = $sgbl->__var_program_name; $programfile = "{$program}-" . $upversion . ".zip"; lxfile_rm_rec("__path_program_htmlbase/help"); lxfile_mkdir("help"); lxfile_rm_rec("__path_program_htmlbase/htmllib/script"); lxfile_rm_rec("__path_program_root/pscript"); $saveddir = getcwd(); lxfile_rm_rec("__path_program_htmlbase/download"); lxfile_mkdir("download"); chdir("download"); print "Downloading {$programfile}.....\n"; download_source("/{$program}/{$programfile}"); print "Download Done....\n"; $host = `hostname`; $host = trim($host); lxshell_unzip("../..", $programfile); chdir($saveddir); }
function execRrdCpuusage($filename, $tot) { $tot = round($tot); $file = "__path_program_root/data/cpu/{$filename}.rrd"; lxfile_mkdir("__path_program_root/data/cpu"); if (!lxfile_exists($file)) { lxshell_return("rrdtool", 'create', $file, 'DS:cpu:DERIVE:800:0:112500', 'RRA:AVERAGE:0.5:1:600', 'RRA:AVERAGE:0.5:6:700', 'RRA:AVERAGE:0.5:24:775', 'RRA:AVERAGE:0.5:288:797'); } lxshell_return("rrdtool", "update", $file, "N:{$tot}"); }