static function checkIfUserExists($name, $id) { if (posix_getpwnam($name)) { $username = $name; $list = lfile("/etc/passwd"); $comment = null; foreach ($list as $l) { $l = trim($l); if (csb($l, "{$username}:")) { $useri = explode(":", $l); $comment = $useri[4]; break; } } //dprint($comment . "Hello\n"); if ($comment === uuser::getUserDescription($id)) { log_error("User {$name} Already Exists. But is of the same domain"); return true; } else { log_error("User {$name} Already Exists. But is of NOT of the same domain"); throw new lxexception("User_Exist", 'web_s_uuser_nname', $name); } } return false; }
static function readProcessList() { $list = lscandir("/proc"); foreach ($list as $pid) { if (is_numeric($pid) && $pid[0] != ".") { $cmdlinearr = lfile("/proc/" . $pid . "/cmdline"); $return[$pid]['nname'] = $pid; if (!$cmdlinearr) { unset($return[$pid]); continue; } $cmdline = $cmdlinearr[0]; $cmdline = preg_replace('+\\0+i', " ", $cmdline); $return[$pid]["command"] = substr($cmdline, 0, 100); if (csa($cmdline, "display.php") && csa($cmdline, "kloxo")) { unset($return[$pid]); continue; } $arr = lfile("/proc/" . $return[$pid]["nname"] . "/status"); foreach ($arr as $a) { if (csb($a, "State:")) { $a = trim($a); $a = strtil($a, "("); $a = strfrom($a, "State:"); $a = trim($a); $return[$pid]["state"] = $a; $return[$pid]["state"] = $return[$pid]["state"] === "S" ? "ZZ" : $return[$pid]["state"]; } if (csa($a, "Uid")) { $uidarr = explode(":", $a); $value = trimSpaces($uidarr[1]); $uidarr2 = explode(" ", $value); $uid = trim($uidarr2[1]); $pwd = posix_getpwuid($uid); $username = $pwd['name']; $return[$pid]["username"] = $username; } if (csa($a, "VmSize")) { $uidarr = explode(":", $a); $uidarr = trimSpaces($uidarr[1]); $uidarr = strtilfirst($uidarr, " "); $return[$pid]['memory'] = round($uidarr / 1024, 2); } } } } return $return; }
function find_loadavg() { $list = lfile("/proc/vz/vestat"); foreach ($list as $l) { if (csa($l, "Version")) { continue; } if (csa($l, "VEID")) { continue; } $l = trimSpaces($l); $load = explode(" ", $l); $cpu = $load[1] + $load[2] + $load[3]; execRrdCpuusage("openvz-{$load['0']}", $cpu); } }
if (!isset($list['default-port']) && !lxfile_exists("__path_slave_db")) { initProgram('admin'); $gen = $login->getObject('general')->portconfig_b; if ($gen) { if ($gen->isOn('nonsslportdisable_flag')) { $nonsslhash = ""; } if ($gen->sslport) { $sslport = $gen->sslport; } 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";
static function docreatestatsConf($inp, $outp, $domain, $stats_name, $stats_password) { global $gbl, $sgbl, $login, $ghtml; $filecontents = lfile($inp); foreach ($filecontents as &$f) { if (preg_match("/_lx_domain_name_/", $f)) { $f = preg_replace("/_lx_domain_name_/", $domain, $f); } if (preg_match("/_lx__path_httpd_root/", $f)) { $f = preg_replace("/_lx__path_httpd_root/", $sgbl->__path_httpd_root, $f); } $regexdom = str_replace('.', '\\.', $domain); $regexdom .= "\$"; if (preg_match("/_lxregex_domain_name_/", $f)) { $f = preg_replace("/_lxregex_domain_name_/", $regexdom, $f); } if (preg_match("/_lx_authentic_user/", $f)) { $f = preg_replace("/_lx_authentic_user/", $stats_name, $f); } if (preg_match("/_lx_dns_lookup_/", $f)) { $f = preg_replace("/_lx_dns_lookup_/", "1", $f); } $st_pro = "0"; if ($stats_password) { $st_pro = "1"; } if (preg_match("/_lx_stats_protect/", $f)) { $f = preg_replace("/_lx_stats_protect/", $st_pro, $f); } } $filecontents = implode("", $filecontents); lxfile_mkdir(dirname($outp)); lfile_put_contents($outp, $filecontents); lxfile_generic_chmod($outp, "0744"); }
function remove_line($filename, $pattern) { $list = lfile($filename); foreach ($list as $k => $l) { if (csa($l, $pattern)) { unset($list[$k]); } } lfile_put_contents($filename, implode("", $list)); }
function lfile_trim($arg) { $list = lfile($arg); foreach ($list as &$s) { $s = trim($s); } return $list; }
function os_getCpuNum() { $list = lfile("/proc/cpuinfo"); $i = 0; foreach ($list as $l) { if (csa($l, "processor")) { $i++; } } return $i; }
static function pserverInfo() { global $gbl, $sgbl, $login, $ghtml; $osdet = findOperatingSystem(); $path = "/proc/meminfo"; $data = lfile($path); $res = self::parse_data($data); $unit = 1024; $ret['priv_s_memory'] = $res['memtotal'] / $unit; $ret['used_s_memory'] = ($res['memtotal'] - $res['memfree']) / $unit; $ret['priv_s_swap'] = $res['swaptotal'] / $unit; $ret['used_s_swap'] = ($res['swaptotal'] - $res['swapfree']) / $unit; $ret['used_s_membuffers'] = $res['buffers'] / $unit; $ret['used_s_memcached'] = $res['cached'] / $unit; // This is a hack to show the actual non-kloxo memory on openvz. if ($sgbl->isKloxo()) { if (lxfile_exists("/proc/user_beancounters")) { $ret['used_s_memory'] -= 20; } } foreach ($ret as &$vvv) { $vvv = round($vvv); } $path = "/proc/cpuinfo"; $data = lfile($path); $processornum = 0; foreach ($data as $v) { if (!trim($v)) { continue; } $d = explode(':', $v); $d[0] = trim($d[0]); $d[1] = trim($d[1]); if ($d[0] === 'processor') { $processornum = $d[1]; continue; } if ($d[0] === 'model name') { $cpu[$processornum]['used_s_cpumodel'] = $d[1]; } if ($d[0] === 'cpu MHz') { $cpu[$processornum]['used_s_cpuspeed'] = round($d[1] / 100) / 10 . "GHz"; } if ($d[0] === 'cache size') { $cpu[$processornum]['used_s_cpucache'] = $d[1]; } } $ret['disk'] = diskusage__linux::getDiskUsage(); $ret['lvm'] = vg_complete(); $ret['cpu'] = $cpu; $ret['osdet'] = $osdet; return $ret; }
static function getcontentsof($file) { $fileName = ""; $fileName = explode('-', basename($file)); //dprint("$file"); $contents = lfile($file); //dprint_r($contents); $result1 = array(); $i = 0; foreach ($contents as $row) { if (!csa($row, "=")) { continue; } $value = explode("=", trim($row)); $value[1] = trim($value[1], "\""); $value[1] = trim($value[1], "'"); switch ($value[0]) { case "DEVICE": $result['devname'] = $value[1]; break; case "IPADDR": $result['ipaddr'] = $value[1]; break; case "NETMASK": $result['netmask'] = $value[1]; break; case "ONBOOT": $result['status'] = $value[1]; break; case "GATEWAY": $result['gateway'] = $value[1]; break; case "USERCTL": $result['userctl'] = $value[1]; break; case "PEERDNS": $result['peerdns'] = $value[1]; break; case "TYPE": $result['itype'] = $value[1]; break; case "IPV6INIT": $result['ipv6init'] = $value[1]; break; case "BOOTPROTO": $result['bproto'] = $value[1]; break; } } if (!isset($result['devname'])) { $result['devname'] = $fileName[1]; } if (!isset($result['status'])) { $result['status'] = "yes"; } if (!isset($result['gateway'])) { $result['gateway'] = null; } if (!isset($result['userctl'])) { $result['userctl'] = null; } if (!isset($result['netmask'])) { $result['netmask'] = null; } if (!isset($result['peerdns'])) { $result['peerdns'] = null; } if (!isset($result['itype'])) { $result['itype'] = null; } if (!isset($result['ipv6init'])) { $result['ipv6init'] = null; } if (!isset($result['bproto'])) { $result['bproto'] = null; } return $result; }
function save_non_existant_image($path) { global $gbl, $sgbl, $login, $ghtml; return; #[FIXME] // We need only the form images, and the normal non form action images need not be saved. if (!csa($path, "list") && !csa($path, "form")) { return; } if ($sgbl->dbg <= 1) { return; } if (lfile_exists(getreal($path))) { return; } $cont = null; $icon = $login->getSpecialObject('sp_specialplay')->icon_name; $file = "__path_program_htmlbase/{$icon}.missing_image.txt"; if (lfile_exists($file)) { $cont = lfile($file); foreach ($cont as $k => &$__c) { $__c = trim($__c); if (!$__c) { unset($cont[$k]); } } } $cont = array_push_unique($cont, $path); $cont = implode("\n", $cont); $cont .= "\n"; lfile_put_contents($file, $cont); }
<div class="errorblock"> <img src="<?php echo lfile('images/' . $typeString[$error["number"]] . '.png'); ?> " alt="<?php echo ucfirst($typeString[$error["number"]]); ?> " class="erroricon" /> <div class="metainfo"> <span style="font-weight: bold;"><?php echo $error["file"]; ?> </span> on line <span style="font-weight: bold;"><?php echo $error["line"]; ?> </span> </div> <div class="errorheader"><?php echo ucfirst($typeString[$error["number"]]); ?> </div> <?php echo $error["message"]; ?> <div class="endfloat"></div> <?php if (Options::debugMode()) { ?> <hr /> <div class="backtrace"> <table>
<?php include_once "htmllib/lib/include.php"; if ($sgbl->isHyperVm()) { exit(10); } if (lxfile_exists("/proc/user_beancounters")) { $list = lfile("/proc/user_beancounters"); foreach ($list as $l) { $l = trimSpaces($l); if (!csb($l, "privvmpages")) { continue; } $d = explode(" ", $l); $mem = $d[3] / 256; } exit(11); } else { if (lxfile_exists("/proc/xen")) { exit(11); } else { $mem = pserver__linux::getTotalMemory(); $mem += 200; } } if ($mem < 180) { exit(15); } exit(11);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <title>CMS-library Test</title> <link type="text/css" rel="stylesheet" media="screen, projection" href="<?php echo lfile('phperrorhandler.css'); ?> " title="Normal" /> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta name="title" content="CMS-library Test" /> <meta name="creator" content="Michiel Helvensteijn" /> </head> <body> <?php Debug::variable($_SERVER['PATH_INFO'], '$_SERVER[\'PATH_INFO\']'); Debug::string(Request::get('mode'), 'mode'); Debug::string(Request::get('path'), 'path'); $factory = new Factory('tree'); foreach ($factory->get_all() as $type) { Object::prepareDatabase($type); } if (Options::debugMode()) { Database::printQueries(); } // CMS::output("whatever"); ?> <?php PhpErrorHandler::printErrors();
<?php include "common.php"; if ($g_login) { include_once "lib/define.php"; include_once "htmllib/phplib/common.inc"; include_once "lib/common.inc"; initprogram(); if (!$login->isAdmin()) { print "Not Admin"; exit(0); } if (if_demo()) { print "Demo... Not Showing.."; exit; } } $list = lfile("__path_program_etc/livetranscript.txt"); foreach ($list as $l) { if (preg_match("/:\\s+lx/", $l)) { continue; } print $l . " <br> "; }