static function getServiceDetails($list) { $ps = lxshell_output("ps", "ax"); $run = Service__linux::getRunLevel(); $rclist = lscandir_without_dot("__path_real_etc_root/rc{$run}.d/"); foreach ($list as &$__l) { $__l['install_state'] = 'dull'; $__l['state'] = 'off'; $__l['boot_state'] = 'off'; if (lxfile_exists("__path_real_etc_root/init.d/{$__l['servicename']}")) { $__l['install_state'] = 'on'; } else { continue; } if (self::checkServiceInRc($rclist, $__l['servicename'])) { $__l['boot_state'] = 'on'; } if ($__l['grepstring']) { if (preg_match("/[\\/ ]{$__l['grepstring']}/i", $ps)) { $__l['state'] = 'on'; } } else { $ret = lxshell_return("/etc/init.d/{$__l['servicename']}", "status"); if ($ret) { $__l['state'] = 'off'; } else { $__l['state'] = 'on'; } } } return $list; }
static function get_vps_ipadress() { $out = lxshell_output("vzlist", "-a", '-H', '-o', 'ip'); $list = explode("\n", $out); $total = null; foreach ($list as $l) { $l = trim($l); $l = trim($l, "-"); if (csa($l, "Warning")) { continue; } if (!$l) { continue; } $res = explode(" ", $l); $total = lx_merge_good($total, $res); } return $total; }
static function readSubscribeList($listname) { $var = explode('@', $listname); $mailpath = mmail__qmail::getDir($var[1]); $list = lxshell_output("/usr/bin/ezmlm-list", "{$mailpath}/{$var[0]}"); $list = explode("\n", $list); $res = null; foreach ($list as $r) { if (!$r) { continue; } $r = trim($r); //$re['nname'] = "{$r}___$listname"; $re['nname'] = $r; $re['address'] = $r; $res[] = $re; } return $res; }
static function getAspnetVersion() { //print("\nI am here\n"); //$r=exec("c:\regASPVer.vbs"); //$cm="cmd /K CD C:\Dir"; //print("\n INASP VER \n"); $stout = lxshell_output("cscript", "-b", "C:\\Program Files\\lxlabs\\kloxo\\bin\\regASPVer.vbs"); //print("\n".$strOut."\n"); //print($r."\n"); //$r = system('cscript.exe c:\regASPVer.vbs.vbs', $a); //cscript.exe regASPVer.vbs //regASPVer.vbs /*foreach($a as $b) { $res['version'] = "aab"; $res['sss'] = 'ab'; $ret[] = $res; }*/ return $stout; }
static function readMailqueue() { lxfile_unix_chmod("__path_program_root/bin/misc/qmHandle", "0755"); $res = lxshell_output("__path_program_root/bin/misc/qmHandle", "-l"); $list = array('subject', 'to', 'from', 'date', 'size'); //$res = lfile_get_contents("a.txt"); $res = explode("\n", $res); //dprintr($res); $i = 0; foreach ($res as $r) { $r = trim($r); if (!$r) { $i++; continue; } if (is_numeric($r[0])) { list($nname, $s, $ss) = explode(" ", $r); $ret[$i]['nname'] = $nname; if (cse($ss, 'R)')) { $ret[$i]['type'] = 'remote'; } else { $ret[$i]['type'] = 'local'; } continue; } foreach ($list as $l) { $ul = ucfirst($l); if (csb($r, "{$ul}:")) { $ret[$i][$l] = strfrom($r, "{$ul}:"); if ($l === 'size') { $ret[$i][$l] = strtil($ret[$i][$l], " bytes"); $ret[$i][$l] = trim($ret[$i][$l]); } } } } return $ret; }
} if ($gen->nonsslport) { $nonsslport = $gen->nonsslport; } } } $list = lfile("htmllib/filecore/lighttpd.conf"); $ret = lxshell_return("__path_php_path", "../bin/common/misc/checktotalmemory.php"); if ($ret === 15) { $user = "******"; } else { $user = "******"lxlabs\""; } $phpcgi_num = 1; $out = lxshell_output("/usr/local/lxlabs/ext/php/bin/php_cgi", "-v"); $lightout = lxshell_output("/usr/local/lxlabs/ext/lxlighttpd/sbin/kloxo.httpd", "-v"); $php_st = null; if (csa($lightout, "1.4.") && csa($out, "cgi-fcgi") && $sgbl->isKloxo() && $ret === 15) { $php_st .= "fastcgi.server = (\".php\" => \n"; $php_st .= "\t\t(( \"socket\" => \"/usr/local/lxlabs/{$sgbl->__var_program_name}/etc/php_socket.socket\",\n"; $php_st .= "\t\t \"bin-path\" => \"/usr/local/lxlabs/ext/php/bin/php_cgi\",\n"; $php_st .= "\t\t \"min-procs\" => 0,\n"; $php_st .= "\t\t \"max-procs\" => {$phpcgi_num},\n"; $php_st .= "\t\t \"bin-environment\" => (\n"; $php_st .= "\t\t\t \"PHP_FCGI_CHILDREN\" => \"0\",\n"; $php_st .= "\t\t\t \"PHP_FCGI_MAX_REQUESTS\" => \"100000000\" ),\n"; $php_st .= "\t\t \"max-load-per-proc\" => 10000,\n"; $php_st .= "\t\t \"idle-timeout\" => 3\n"; $php_st .= "\t\t ))\n"; $php_st .= "\t\t)\n"; } else {
function get_vpsid_from_ipaddress($ip) { static $res; if (!$res) { $res = lxshell_output('vzlist', '-H', '-o', 'vpsid,ip'); } $list = explode("\n", $res); foreach ($list as $l) { $l = trimSpaces($l); if (csa($l, $ip)) { list($vpsid) = explode(" ", $l); return $vpsid; } } return 0; }
public function createWindowsConfig() { $memory = $this->getRealMemory(); if (trim(lxshell_output("uname", "-r")) === "2.6.16.33-xen0") { $vifnamestring = null; } else { $vifnamestring = "vifname=vif{$this->main->vifname},"; } if (!$this->isUnlimited($this->main->priv->uplink_usage) && $this->main->priv->uplink_usage > 0) { $ratestring = "rate = {$this->main->priv->uplink_usage}KB/s,"; } else { $ratestring = null; } $mac = $this->main->macaddress; if (!char_search_beg($mac, "aa:00")) { $mac = "aa:00:{$mac}"; } $count = count($this->main->vmipaddress_a); // Big bug workaround. the first vif seems to be ignored. Need to be fixed later. $vifnamestring = "vifname=vif{$this->main->vifname},"; //$vif[] = "'type=ioemu, $vifnamestring $ratestring mac=$mac:00'"; for ($i = 1; $i <= $count; $i++) { $hex = get_double_hex($i); $h = base_convert($i, 10, 36); $bridgestring = null; if ($this->main->networkbridge && $this->main->networkbridge !== '--automatic--') { $bridgestring = ",bridge={$this->main->networkbridge}"; } $vifnamestring = "vifname=vif{$this->main->vifname}{$h},"; $vif[] = "'type=ioemu, {$vifnamestring} {$ratestring} mac={$mac}:{$hex} {$bridgestring}'"; } $vif = implode(", ", $vif); $vif = "vif = [ {$vif} ]\n"; $string = null; $string .= "import os, re\n"; $string .= "arch = os.uname()[4]\n"; $string .= "if re.search('64', arch):\n"; $string .= " arch_libdir = 'lib64'\n"; $string .= "else:\n"; $string .= " arch_libdir = 'lib'\n"; $string .= "name = '{$this->main->nname}'\n"; $string .= "kernel = '/usr/lib/xen/boot/hvmloader'\n"; $string .= "builder='hvm'\n"; if ($this->main->isBlankWindows()) { $string .= "boot='d'\n"; } else { $string .= "boot='c'\n"; } $string .= "memory = {$memory}\n"; $string .= $vif; $string .= "device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'\n"; $string .= "vnc=1\n"; $string .= "sdl=0\n"; $string .= $this->addVcpu(); $string .= "vnclisten='0.0.0.0'\n"; $string .= "vncpasswd='{$this->main->realpass}'\n"; if ($this->main->isBlankWindows()) { $string .= "disk = [ 'file:/home/wincd.img,hdc:cdrom,r', 'phy:{$this->main->maindisk},ioemu:hda,w']\n"; $string .= "acpi=1\n"; } else { $string .= "disk = [ 'phy:{$this->main->maindisk},ioemu:hda,w']\n"; $string .= "acpi=1\n"; } $string .= "vncunused=0\n"; $string .= "vncdisplay={$this->main->vncdisplay}\n"; if ($this->main->text_xen_config) { $string .= "{$this->main->text_xen_config}\n"; } lxfile_mkdir($this->main->configrootdir); lfile_put_contents("{$this->main->configrootdir}/{$this->main->nname}.cfg", $string); }
function find_hop($l) { global $global_dontlogshell; $global_dontlogshell = true; $out = lxshell_output("ping -c 1 {$l}"); $list = explode("\n", $out); foreach ($list as $l) { $l = trim($l); if (csb($l, "rtt")) { continue; } $l = trimSpaces($l); $ll = explode(" ", $l); $lll = explode("/", $ll[3]); return round($lll[1], 1); } }
function lxfile_get_uncompressed_size($file) { global $global_dontlogshell; $tmp = $global_dontlogshell; $global_dontlogshell = true; $out = lxshell_output("gzip", "-l", $file); if (csa($out, "not in")) { return 0; } $out = trim($out); if (!$out) { return 0; } $out = explode("\n", $out); $out = trimSpaces($out[1]); $out = explode(" ", $out); $global_dontlogshell = $tmp; return $out[1]; }
function os_get_default_ethernet() { $res = lxshell_output("route", "-n"); $re = explode("\n", $res); foreach ($re as $r) { if (csb($r, "0.0.0.0")) { $r = trimSpaces($r); $o = explode(" ", $r); return trim($o[7]); } } return null; }
function lxshell_getzipcontent($path) { return lxshell_output("c:/Progra~1/7-zip/7z.exe", "l", $path); }
function syncAddFile($domainname) { global $gbl, $sgbl, $login, $ghtml; $dnsfile = "{$sgbl->__path_mara_chroot}/{$sgbl->__path_mara_path}/{$domainname}"; $nameduser = $sgbl->__var_programuser_dns; $fdata = null; //$fdata .= "\$TTL\t\t{$this->main->ttl}\n"; $nameserver = null; $dnsdata = null; foreach ($this->main->dns_record_a as $dns) { if ($dns->ttype === "ns") { $nameserver = $dns->param; $dnsdata .= "{$domainname}. NS {$dns->param}. \n"; } } $ddate = date("Ymd"); $v = rand(0, 99); if ($v < 10) { $v = "0{$v}"; } $ddate = "{$ddate}{$v}"; //$string .= "% SOA {$nameserver}. {$this->main->__var_email}@% 1 10800 3600 604800 86400 \n"; $string = null; $fdata .= $string; $starvalue = null; $fdata .= $dnsdata; foreach ($this->main->dns_record_a as $k => $o) { switch ($o->ttype) { case "ns": //$tmp = "{$domainname} IN NS $o->param. \n"; //$fdata .= $tmp; break; case "mx": $v = $o->priority; $tmp = "{$domainname}. MX {$v} {$o->param}. \n"; $fdata .= $tmp; break; case "a": $key = $o->hostname; $value = $o->param; if ($key === '*') { $starvalue = "* A {$value}"; break; } if ($key !== "__base__") { $key = "{$key}.{$domainname}."; } else { $key = "{$domainname}."; } $tmp = "{$key}\t\t A {$value} \n"; $fdata .= $tmp; break; case "cn": case "cname": $key = $o->hostname; $value = $o->param; $key .= ".{$domainname}."; if ($value !== "__base__") { $value = "{$value}.{$domainname}."; } else { $value = "{$domainname}."; } if ($key === '*') { $starvalue = "*\t\tCNAME {$value}\n"; break; } $tmp = "{$key} CNAME {$value}\n"; $fdata .= $tmp; break; case "txt": $key = $o->hostname; $value = $o->param; if ($o->param === null) { continue; } if ($key !== "__base__") { $key = "{$key}.{$domainname}."; } else { $key = "{$domainname}."; } $value = str_replace("<%domain>", $domainname, $value); $tmp = "{$key} TXT \"{$value}\"\n"; $fdata .= $tmp; break; } } //$fdata .= $starvalue; dprint($dnsfile); $tmpfile = lx_tmp_file($dnsfile); lfile_put_contents($tmpfile, $fdata); $ret = 0; if ($ret) { $out = lxshell_output("named-checkzone", $domainname, $tmpfile); log_log("error", $out); $out = str_replace($tmpfile, "", $out); unlink($tmpfile); throw new lxException("dns_conflict", 'dns', $out); return; } unlink($tmpfile); lfile_put_contents($dnsfile, $fdata); lxfile_unix_chown($dnsfile, $nameduser); }
static function getDetailedInfo($name) { $ret = lxshell_output("rpm", "-qi", $name); return $ret; }
static function getRunLevel() { $v = trim(lxshell_output("runlevel")); $v = explode(" ", $v); return $v[1]; }
static function getDiskUsage() { $cont = lxshell_output("df", "-P"); $result = self::parseDiskUsage($cont); return $result; }