function createExtraVariables() { if ($this->ttype === 'forward') { return; } $this->__var_addonlist = $this->getParentO()->getList('addondomain'); $spam = $this->getObject('spam'); $this->__var_spam_status = $spam->status; $master = null; if ($this->dbaction === 'add' || $this->dbaction === 'syncadd') { try { $master = $this->getFromList('mailaccount', "postmaster@{$this->nname}"); } catch (exception $e) { $this->__var_password = "******"; } if ($master) { $this->__var_password = $master->realpass; } } if (!$this->systemuser) { $dom = $this->getParentO(); $web = $dom->getObject('web'); $this->systemuser = $web->username; } if (cse($this->subaction, 'backup')) { $this->createMailaccountList(); } }
function printProperty($class, $type) { $r = new ReflectionClass($class); foreach ($r->getProperties() as $s) { $istr = getModeFromType($type); if (!csb($s->name, $istr)) { continue; } $descr = get_classvar_description($class, $s->name); $name = strfrom($s->name, $istr); if (csa($descr[0], "q")) { continue; } if (cse($name, "_f")) { continue; } if (cse($name, "_l")) { continue; } if (cse($name, "_o")) { continue; } printf("%35s %s\n", $name, $descr['help']); } }
function find_cpuusage() { $out = lxshell_output("xm", "list"); $list = explode("\n", $out); foreach ($list as $l) { $l = trimSpaces($l); $val = explode(" ", $l); if (!cse($val[0], ".vm")) { continue; } execRrdCpuusage("{$val['0']}", $val[5]); } }
static function add($parent, $class, $param) { if (!cse($param['nname'], ".aux")) { $param['nname'] .= ".aux"; } if (!$parent->isAdmin()) { $param['nname'] = "{$parent->nname}_{$param['nname']}"; } $param['cpstatus'] = 'on'; $param['status'] = 'on'; $param['realpass'] = $param['password']; $param['password'] = crypt($param['password']); return $param; }
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; }
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; }
function doReverseDns() { addLineIfNotExistInside("__path_named_chroot/etc/named.conf", "include \"/etc/lxreverse.conf\";", "//added by hypervm"); list($base, $end) = reversedns::getBaseEnd($this->main->nname, $this->main->__var_rdnsrange); $ddate = date("Ymd"); $v = rand(0, 99); if ($v < 10) { $v = "0{$v}"; } $ddate = "{$ddate}{$v}"; $string = null; $string .= "\$TTL 86400\n"; $string .= "@ IN SOA {$this->main->__var_revdns1}. root.{$this->main->__var_revdns1}. (\n"; $string .= "{$ddate} ; serial\n"; $string .= "28800 ; refresh\n"; $string .= "14400 ; retry\n"; $string .= "1814400 ; expire\n"; $string .= "86400 ; default_tt\n"; $string .= ")\n"; $string .= " IN NS {$this->main->__var_revdns1}.\n"; if ($this->main->__var_revdns2) { $string .= " IN NS {$this->main->__var_revdns2}.\n"; } $result = $this->main->__var_reverse_list; $result = $result[$base]; $this->main->end = $end; $result = merge_array_object_not_deleted($result, $this->main); foreach ($result as $k => $v) { $v['reversename'] = trim($v['reversename']); if (!cse($v['reversename'], ".")) { $v['reversename'] .= "."; } $string .= "{$v['end']}\tIN PTR {$v['reversename']}\n"; } lfile_put_contents("__path_named_realpath/{$base}.in-addr.arpa", $string); $this->createMainFile(); }
function getGreeter($nicklist, $nick) { foreach ($nicklist as $n) { $n = trim($n); if (!$n) { continue; } if ($n === $nick) { continue; } if ($n === 'Myself') { continue; } if (cse($n, "|aw")) { continue; } return "Connected...<br><br> <> Type your message to start the conference. <br>"; } return "Connected...<br><br> <Leave Message> I am not available now. Please leave a message. <br>"; }
function updateform($subaction, $param) { global $gbl, $sgbl, $login, $ghtml; $gen = $login->getObject('general')->generalmisc_b; switch ($subaction) { case "dialogsize": $vlist['dialogsize'] = null; return $vlist; case "boxposopen": $vlist['title_class'] = null; $vlist['title_open'] = null; $vlist['title_name'] = null; return $vlist; case "boxpos": $vlist['title_class'] = null; $vlist['title_open'] = null; $vlist['title_name'] = null; $vlist['page'] = null; return $vlist; case "addshortcut": $vlist['shortcut'] = null; return $vlist; case "resendwelcome": $vlist['extra_email_f'] = null; $vlist['password'] = null; $vlist['__v_updateall_button'] = array(); return $vlist; case "disable_per": if ($this->islogin()) { throw new lxException('you_cannot_set_your_own_limit', ''); } $vlist['disable_per'] = array('s', array('off', '95', '100', '110', '120', '130')); return $vlist; case "miscinfo": $vlist['nname'] = array('M', $this->nname); $vlist['realname'] = ""; $vlist['add_address'] = ""; $vlist['add_city'] = ""; $vlist['add_country'] = ""; $vlist['add_telephone'] = ""; $vlist['add_fax'] = ""; return $vlist; case "limit_s": case "limit": if ($this->islogin()) { throw new lxException('you_cannot_set_your_own_limit', ''); } if (cse($this->get__table(), "template")) { $class = strtil($this->get__table(), "template"); $vlist = getQuotaListForClass($class); } else { $vlist = $this->getQuotaVariableList(); } // This is patently wrong. In update, the object is inititialized properly and we are suppsed to get the quota for the specific type of object and not for the class.... Changing it to $this. $sgbl->method = 'post'; //$vlist['__v_updateall_button'] = array(); return $vlist; case "change_plan": $parent = $this->getParentO(); $ttlist = $parent->getTemplateList("resourceplan", false); $this->newresourceplan = $this->resourceplan_used; if (!$ttlist) { $vlist['newresourceplan'] = array("M", "No Plan in Parent"); } else { $vlist['newresourceplan'] = array("A", $ttlist); } //$vlist['__v_updateall_button'] = array(); return $vlist; case "password": if ($this->isLogin() || $this->is__table('auxiliary') && $this->getParentO()->isAuxiliary()) { $vlist['old_password_f'] = ""; } $vlist['password'] = ""; $vlist['__v_updateall_button'] = array(); return $vlist; } return parent::updateform($subaction, $param); }
function print_resource($tree, $object, $cgi_o_o, $toplevelobject, $depth, $alistflag, $func, $childobjectflag = false, $showurlflag = true) { global $gbl, $sgbl, $login, $ghtml; $bgcolor = null; $path = get_image_path() . "/button/"; $bpath = get_image_path() . "/button/"; $class = $object->getClass(); if (!$tree) { $tree = createTreeObject('name', null, null, null, null, null, null); $level = -1; } else { $level = 1; } $cnl = $object->{$func}(); $alist = null; if ($level != -1) { if ($childobjectflag) { $url = $this->getFullUrl("a=show&o={$class}", $cgi_o_o); $num = count($cgi_o_o); $cgi_o_o[$num]['class'] = $class; } else { $urlname = $object->nname; $url = $this->getFullUrl("a=show&l[class]={$class}&l[nname]={$urlname}", $cgi_o_o); $num = count($cgi_o_o); $cgi_o_o[$num]['class'] = $class; $cgi_o_o[$num]['nname'] = $object->nname; } $open = 'false'; $alist = null; } else { $url = $this->getFullUrl("a=show", $cgi_o_o); $alist = $object->createShowAlist($alist); $open = 'true'; } $list = $object->createShowTypeList(); foreach ($list as $k => $v) { $type = $object->{$k}; $vtype = $k; } if ($childobjectflag) { $img = $this->get_image($path, $class, "show", ".gif"); } else { $img = $this->get_image($path, $class, "{$vtype}_v_{$type}", ".gif"); } if (isset($object->status) && $object->status) { if ($object->isOn('status')) { $hstr = "and is Enabled"; $status = 'on'; } else { $hstr = "and is Disabled"; $status = 'off'; } $stimg = $this->get_image($path, $class, "status_v_" . $status, ".gif"); $imgstr = "<img height=8 width=8 src={$stimg}>"; } else { $imgstr = null; $hstr = null; } $homeimg = $this->get_image($path, $class, "show", ".gif"); if ($childobjectflag) { $name = $ghtml->get_class_description($class); $name = $name[2]; } else { $name = $object->getId(); } $help = "{$class} <font color=blue> {$name} </font> is of Type {$type} {$hstr}"; $alt = lx_strip_tags($help); $inputstr = null; if (!$showurlflag) { $url = null; } $imgstr = "{$inputstr} <img src={$img} width=14 height=14> {$imgstr} {$name}"; if (isset($object->__v_message)) { $imgstr .= " " . $object->__v_message; } $pttr = createTreeObject($name, $img, $imgstr, $url, $open, $help, $alt); $tree->addToList('tree', $pttr); $childdepth = 1; $ppp = $object; //dprintr($depth); if ($object !== $toplevelobject) { while ($ppp = $ppp->getParentO()) { if ($ppp === $toplevelobject) { break; } $childdepth++; } if ($depth && $childdepth >= $depth) { return; } } //print("$treename.add($total, $level, '<img src=$img width=14 height=14> $imgstr $name', '$url', '', 'mainframe', '', '', $open, '$help', '$alt');\n"); if ($alist && $alistflag) { $open = 'false'; $imgstr = "<img src={$homeimg} width=14 height=14> <font color=#5958aa> <b> Functions </b></font> "; $ttr = createTreeObject($name, '', $imgstr, $url, $open, $help, $alt); $pttr->addToList('tree', $ttr); //print("$treename.add($total, $level + 1, '<img src=$homeimg width=14 height=14> <font color=#5958aa> <b> Functions </b></font> ', '', '', 'mainframe', '$homeimg', '$homeimg', $open, '$help', '$alt');\n"); $this->print_resourcelist($ttr, $alist, null); $open = 'true'; } foreach ((array) $cnl as $v) { $name = $object->getChildNameFromDes($v); if (cse($v, "_o")) { $c = null; if ($object->isRealChild($name)) { $c = $object->getObject($name); } if ($c) { $this->print_resource($pttr, $c, $cgi_o_o, $toplevelobject, $depth, $alistflag, $func, true, $showurlflag); } continue; } $img = $this->get_image($path, $name, "list", ".gif"); $url = $this->getFullUrl("a=list&c={$name}"); $desc = $this->get_class_description($name); $printname = get_plural($desc[2]); $help = "Click to Show {$printname}"; $alt = $help; $npttr = $pttr; if ($object === $toplevelobject) { $open = 'true'; $gbl->__navigmenu[$level + 2] = array('show', $object); $gbl->__navig[$level + 2] = $this->get_post_from_get($url, $__tpath, $__tpost); $imgstr = "<img src={$img} width=20 height=20>{$printname}"; if (!$showurlflag) { $url = null; } $npttr = createTreeObject($name, $homeimg, $imgstr, $url, $open, $help, $alt); $pttr->addToList('tree', $npttr); //print("$treename.add($total, 0, '<img src=$img width=20 height=20>$printname ', '$url', '', 'mainframe', '$img', '$img', $open, '$help', '$alt');\n"); if ($alistflag) { $open = 'false'; $imgstr = 'Functions'; $nttr = createTreeObject($name, $homeimg, $imgstr, $url, $open, $help, $alt); $npttr->addToList('tree', $nttr); //print("$treename.add($total, $lv, 'Functions', '$url', '', 'mainframe', '', '', $open, '$help', '$alt');\n"); $lalist = exec_class_method($name, 'createListAlist', $object, $name); $this->print_resourcelist($nttr, $lalist, null); } } $open = 'true'; $filtername = $object->getFilterVariableForThis($name); $pagesize = (int) $login->issetHpFilter($filtername, 'pagesize') ? $login->gethpfilter($filtername, 'pagesize') : exec_class_method($class, "perPage"); if (isset($sgbl->__var_main_resource) && $sgbl->__var_main_resource) { $cl = $object->getList($name); $count = count($cl); $halfflag = false; } else { $halfflag = true; $cl = $object->getVirtualList($name, $count); } if ($object->isVirtual($name)) { continue; } if ($cl) { //Setting $prev to -ll; this is done to initialize prev. if ($object === $toplevelobject && $login->getSpecialObject('sp_specialplay')->isOn('lpanel_group_resource') && $alistflag) { $prev = "-ll"; foreach ($cl as $c) { if ($c->nname[0] != $prev[0]) { $imgstr = "<b>{$c->nname[0]} ....</b> "; $ttr = createTreeObject($name, $homeimg, $imgstr, $url, $open, $help, $alt); $npttr->addToList('tree', $ttr); //print("$treename.add($total, $oldlv, '<b>{$c->nname[0]} ....</b> ', '', '', 'mainframe', '$img', '$img', false, '$help');\n"); } $prev = $c->nname; $this->print_resource($ttr, $c, $cgi_o_o, $toplevelobject, $depth, $alistflag, $func, false, $showurlflag); } } else { foreach ($cl as $c) { $this->print_resource($npttr, $c, $cgi_o_o, $toplevelobject, $depth, $alistflag, $func, false, $showurlflag); } } if ($halfflag && $count > $pagesize) { $url = $ghtml->getFullUrl("a=list&c={$name}", $cgi_o_o); $ttr = createTreeObject($name, $homeimg, "More (Showing {$pagesize} of {$count})", $url, $open, $help, $alt); $npttr->addToList('tree', $ttr); } } } // At the top client Make all the children virtual.. This assures that after viewing resources, the cache doesn't hogg the system. return $tree; }
function createNewcertificate() { global $gbl, $sgbl, $login, $ghtml; foreach ($this->ssl_data_b as $key => $value) { if (!cse($key, "_r")) { continue; } $nk = strtil($key, "_r"); $temp[$nk] = $value; } foreach ($temp as $key => $t) { if ($key === "countryName") { $l = explode(":", $t); $name = $l[0]; } else { $name = $t; } $ltemp[$key] = $name; } $config['private_key_bits'] = 1024; $privkey = openssl_pkey_new($config); openssl_pkey_export($privkey, $text_key_content); $csr = openssl_csr_new($ltemp, $privkey); openssl_csr_export($csr, $text_csr_content); $sscert = openssl_csr_sign($csr, null, $privkey, 3650); openssl_x509_export($sscert, $text_crt_content); $this->text_key_content = $text_key_content; $this->text_csr_content = $text_csr_content; $this->text_crt_content = $text_crt_content; }
function get_classvar_description($class, $var = null) { global $gbl, $sgbl, $login, $ghtml; global $g_language_desc; global $g_language_mes; //$var = fix_nname_to_be_variable($var); if (csb($var, "__")) { $dvar = $var; } else { if ($var) { $dvar = "__desc_{$var}"; } else { $dvar = "__desc"; } } $rvar = strfrom($dvar, "__desc_"); $rvar = strfrom($rvar, "__acdesc_"); $class = strtolower($class); $ret = get_real_class_variable($class, $dvar); if (!$ret) { return null; } $ret['help'] = $ret[2]; if (cse($dvar, "_o") || cse($dvar, "_l")) { return $ret; } if (!$g_language_desc) { return $ret; } /* if ($login->getSpecialObject('sp_specialplay')->isCoreLanguage()) { return $ret; } */ $k = trim($ret[2], "_\n "); if (isset($g_language_desc->__description[$k])) { $ret[2] = $g_language_desc->__description[$k][0]; if (isset($g_language_mes->__helpvar[$rvar])) { $ret['help'] = $g_language_mes->__helpvar[$rvar]; } else { if (isset($g_language_mes->__help[$dvar])) { $ret['help'] = $g_language_desc->__help[$k]; } else { $ret['help'] = $ret[2]; } } } return $ret; }
function __ac_desc_graph($object) { global $gbl, $sgbl, $login, $ghtml; $subaction = $ghtml->frm_subaction; $selflist = $object->getSelfList(); if (!$ghtml->frm_c_graph_time) { $ghtml->frm_c_graph_time = '1d'; } $object->createShowPropertyList($alist); $object->createShowAlist($alist, $subaction); $nalist = null; if (!isset($alist['property'])) { $alist['property'] = array(); } $nalist = lx_merge_good($nalist, $alist['property']); remove_if_older_than_a_minute_dir("__path_program_htmlbase/tmp/"); $ghtml->print_tab_block($nalist); if ($selflist) { $ghtml->printShowSelectBox($selflist); } if (cse($ghtml->frm_subaction, 'base')) { $core = strtil($ghtml->frm_subaction, "base"); $ghtml->__http_vars['frm_subaction'] = "{$core}traffic"; $subaction = "{$core}traffic"; } $galist = $object->createGraphList(); $ghtml->print_tab_block($galist); $graphtlist = array('1h' => '1h', '12h' => '12h', '1d' => '1d', '2d' => '2d', '1week' => '1week', '1month' => '1month'); $gtlistsec = array('1h' => 3600, '12h' => 12 * 3600, '1d' => 24 * 3600, '2d' => 2 * 24 * 3600, '1week' => 7 * 24 * 3600, '1month' => 30 * 24 * 3600, '1year' => 365 * 24 * 3600); $ghtml->printGraphSelect($graphtlist); lxfile_mkdir("__path_program_htmlbase/tmp"); $tmpgraph = ltempnam("__path_program_htmlbase/tmp/", "graph"); $object->setUpdateSubaction("graph_{$subaction}"); $time = $ghtml->frm_c_graph_time; $object->rrdtime = $gtlistsec[$time]; try { $object->createExtraVariables(); $file = rl_exec_set(null, $object->syncserver, $object); } catch (lxException $e) { $ghtml->print_curvy_table_start(); print "Graph Failed due to {$e->getMessage()} {$e->value}"; $ghtml->print_curvy_table_end(); $object->dbaction = 'clean'; return; } $object->dbaction = 'clean'; lfile_put_contents($tmpgraph, $file); $tmpgraph = basename($tmpgraph); print "<img src=/tmp/{$tmpgraph}>"; }
static function baseinitThisList($parent, $class, $type) { global $gbl, $sgbl, $login, $ghtml; $rlist = $parent->createShowRlist(""); $class = $parent->get__table(); $resourceout = null; if ($rlist) { $j = 0; foreach ($rlist as $k => $v) { if ($k === 'priv') { $vlist = $parent->getQuotaVariableList(); $vlist = lx_array_merge(array($vlist, $parent->getDeadQuotaVariableList())); foreach ($vlist as $nk => $nv) { // Why am I skipping hardquota?. OK it screws up vps graph if ($parent->isHardQuota($nk)) { continue; } if ($type === 'permission') { if (!cse($nk, "_flag")) { continue; } if ($login->getSpecialObject('sp_specialplay')->isOn('dont_show_disabled_permission')) { if (!$parent->priv->isOn($nk)) { continue; } } } else { if (cse($nk, "_flag")) { continue; } } $desc = get_classvar_description($class, $nk); if (is_array($parent->priv->{$nk})) { foreach ($parent->priv->{$nk} as $nnk => $nnv) { $resourceout[$j]['vv'] = $nk; $resourceout[$j]['nname'] = $j; $resourceout[$j]['shortdescr'] = getNthToken($desc[2], 0); $sh = getNthToken($desc[2], 0); $ln = getNthToken($desc[2], 1); $resourceout[$j]['descr'] = "_lxspan:{$sh}:{$ln}:"; $resourceout[$j]['resourceused'] = $parent->used->{$nk}[$nnk]; $resourceout[$j]['resourcepriv'] = $parent->priv->{$nk}[$nnk]; $j++; } continue; } if (isset($parent->used)) { $vresourceused = $parent->used->{$nk}; } else { $vresourceused = '-'; } if (cse($nk, "_flag")) { $vresourcepriv = $parent->priv->{$nk}; } else { if ($parent->priv->{$nk} === "0") { continue; } if ($parent->showPrivInResource()) { $vresourcepriv = $parent->priv->{$nk}; } else { $vresourcepriv = '-'; } } if (cse($nk, 'last_usage')) { $vresourcepriv = '-'; } if ($parent->isDeadQuotaVariable($nk)) { $vresourcepriv = "-"; } $resourceout[$j]['vv'] = $nk; $resourceout[$j]['nname'] = $j; $resourceout[$j]['shortdescr'] = getNthToken($desc[2], 0); $sh = getNthToken($desc[2], 0); $ln = getNthToken($desc[2], 1); $resourceout[$j]['descr'] = "_lxspan:{$sh}:{$ln}:"; $resourceout[$j]['resourceused'] = $vresourceused; $resourceout[$j]['resourcepriv'] = $vresourcepriv; $j++; } } else { $resourceout[$j]['vv'] = $v[0]; $resourceout[$j]['nname'] = $j; $resourceout[$j]['shortdescr'] = getNthToken($v[1], 0); $sh = getNthToken($v[1], 0); $ln = getNthToken($v[1], 1); $resourceout[$j]['descr'] = "_lxspan:{$sh}:{$ln}:"; $resourceout[$j]['resourceused'] = $v[2]; $resourceout[$j]['resourcepriv'] = $v[3]; $j++; } } } return $resourceout; }
<?php include_once "htmllib/lib/include.php"; $list = lscandir_without_dot_or_underscore("/home/kloxo/httpd/ssl/"); foreach ($list as $l) { if (cse($l, ".crt")) { $newlist[] = basename($l, ".crt"); } else { continue; } } foreach ($newlist as $n) { lxfile_cp("/usr/local/lxlabs/kloxo/file/program.crt", "/home/kloxo/httpd/ssl/{$n}.crt"); lxfile_cp("/usr/local/lxlabs/kloxo/file/program.key", "/home/kloxo/httpd/ssl/{$n}.key"); // lxfile_cp("/usr/local/lxlabs/lxadmin/httpdocs/htmllib/filecore/program.ca", "/home/kloxo/httpd/ssl/$n.ca"); lxfile_cp("/usr/local/lxlabs/kloxo/httpdocs/htmllib/filecore/program.ca", "/home/kloxo/httpd/ssl/{$n}.ca"); }
function __get($var) { if (cse($var, '_num')) { $this->{$var} = '0'; return $this->{$var}; } return "-"; }
function updateSkeleton($param) { $key_file_tmp = $_FILES['skeletonarchive_f']['tmp_name']; $key_file = $_FILES['skeletonarchive_f']['name']; if (!cse($key_file, ".zip")) { throw new lxException("skeleton_should_be_zip", 'skeletonarchive_f'); } $this->skeletonarchive = $key_file; $this->__skeletion_tmp = $key_file_tmp; $this->setUpdateSubaction('skeleton'); // Don't ever return the param. In the param the skeletonarchive is null and thus the value will be set to that. //return $param; }
function do_desc_add($object, $class, $param) { global $gbl, $sgbl, $login, $ghtml; $quotaclass = exec_class_method($class, "getquotaclass", $class); $numvar = "{$quotaclass}_num"; $qobject = $object->getClientParentO(); dprint($qobject->getClname()); if ($qobject->isQuotaVariable($numvar)) { if (isQuotaGreaterThanOrEq($qobject->used->{$numvar}, $qobject->priv->{$numvar})) { throw new lxException("Quota Exceeded for {$class}", 'nname', $numvar); } } /* $list = $qobject->getQuotaVariableList(); foreach((array) $list as $l => $v) { if (csb($l, "{$class}_m_")) { $license = strtil(strfrom($l, "_n_"), "_num"); $licvar = strtil(strfrom($l, "_m_"), "_n_"); if (isset($param[$licvar]) && $param[$licvar] === $license) { if (isQuotaGreaterThanOrEq($qobject->used->$l, $qobject->priv->$l)) { throw new lxException("Quota Exceeded for $class $licvar.$license", 'nname', $numvar); } } } } */ // Setting it here itself so that the add can override if necessary. This is done in tickets, where the parent is always the admin. $param['parent_clname'] = $object->getClName(); // In the case of mailaccount, the real parent is mmail, while the object is added to client. if (isset($param['real_clparent_f'])) { $parent_class = exec_class_method($class, 'defaultParentClass', $object); $param['parent_clname'] = createParentName($parent_class, $param['real_clparent_f']); } $param = exec_class_method($class, 'Add', $object, $class, $param); // First loop to create a unique nname if applicable.... FOr the 'unique-nname-creation' to work in the second loop, the variables must be resolved before that... So this extra looping... foreach ($param as $k => $v) { if (csb($k, "__v_") || csb($k, "__m_")) { continue; } $object->resolve_class_differences($class, $k, $dclass, $dk); } foreach ($param as $k => $v) { if (csb($k, "__v_") || csb($k, "__m_")) { continue; } $object->resolve_class_heirarchy($class, $k, $dclass, $dk); $object->resolve_class_differences($class, $k, $ddclass, $ddk); $nnamevar = get_real_class_variable($ddclass, "__rewrite_nname_const"); if ($nnamevar) { $nnamelist = null; foreach ($nnamevar as $n) { $nnamelist[] = $param[$n]; } $nparam[$dclass]['nname'] = implode($sgbl->__var_nname_impstr, $nnamelist); } $nparam[$dclass][$dk] = $v; } // First Pass foreach ($nparam as $k => $v) { if (csa($k, "_s_")) { continue; } if ($k === 'priv') { $olist[$k] = new priv(null, null, $nparam[$class]['nname']); check_priv($object, $class, $olist[$k], $v); continue; } if ($k === 'used') { $olist[$k] = new Used(null, null, $nparam[$class]['nname']); $olist[$k]->create($v); continue; } if ($k === 'listpriv') { //$olist[$k] = new listpriv($object->__masterserver, null, $class . "_s_vv_p_" . $nparam[$class]['nname']); $olist[$k] = new listpriv($object->__masterserver, null, $class . "-" . $nparam[$class]['nname']); check_listpriv($object, $class, $olist[$k], $v); continue; } if (csa($k, "_b")) { $olist[$k] = new $k($object->__masterserver, null, $nparam[$class]['nname']); } else { $olist[$k] = new $k($object->__masterserver, null, $v['nname']); } $olist[$k]->inheritSyncServer($object); $olist[$k]->initThisDef(); $olist[$k]->create($v); // The createsyncclass needs the syncserver variable to be set. Which may not be available. So we have to run this again. if ($olist[$k]->hasDriverClass()) { $olist[$k]->createSyncClass(); } } // The main object has to inherit the masterserver here itself, so that its children will inherit it later when they are added through addobject. if (!cse($class, "_a") && exec_class_method($class, "isDatabase") && exists_in_db($object->__masterserver, $class, $olist[$class]->nname)) { // If the parent is getting added too, then that means we are in the client add page, and thus the variable is vps_name, domain_name rather than nname. if ($object->dbaction === 'add') { $vname = "{$class}_name"; } else { $vname = "nname"; } throw new lxException("{$olist[$class]->nname}+already+exists+in+{$class}.", $vname, $class); } //Second Pass... foreach ($nparam as $k => $v) { if (!csa($k, "_s_") && !csa($k, "-")) { continue; } $clist = explode("_s_", $k); $k = $clist[1]; $cl = $clist[0]; $nolist[$k] = new $k($object->__masterserver, null, $v['nname']); $nolist[$k]->inheritSyncServer($olist[$cl]); $nolist[$k]->initThisDef(); $nolist[$k]->create($v); // The createsyncclass needs the syncserver variable to be set. Which may not be available. So we have to run this again. if ($nolist[$k]->hasDriverClass()) { $nolist[$k]->createSyncClass(); } $olist[$cl]->addObject($k, $nolist[$k]); } foreach ($olist as $k => $v) { if (cse($k, "_b") || $k === 'used' || $k === 'priv' || $k === 'listpriv') { $olist[$class]->{$k} = $v; continue; } if ($k != $class) { $olist[$class]->addObject($k, $v); continue; } } if (isset($param['__v_priv'])) { $olist[$class]->priv = $param['__v_priv']; } if (isset($param['__v_listpriv'])) { $olist[$class]->listpriv = $param['__v_listpriv']; } //$olist[$class]->parent_clname = $object->getClName(); $rparent = $object; $olist[$class]->__parent_o = $rparent; $olist[$class]->postAdd(); $rparent->addToList($class, $olist[$class]); $olist[$class]->superPostAdd(); //dprintr($object); notify_admin("add", $object, $olist[$class]); do_actionlog($login, $olist[$class], "add", ""); //This shouldn't happen here. This should be done only after the synctosystem since, the sync can fail and the write may not happen at all. //$olist[$class]->changeUsedFromParentAll(); dprint($olist[$class]->getParentO()); }
function fixResourcePlan() { global $gbl, $sgbl, $login, $ghtml; $login->loadAllObjects('resourceplan'); $list = $login->getList('resourceplan'); foreach ($list as $l) { $qv = getQuotaListForClass('client'); $write = false; foreach ($qv as $k => $v) { if ($k === 'centralbackup_flag') { if (!isset($l->priv->centralbackup_flag)) { $l->priv->centralbackup_flag = $l->centralbackup_flag; $write = true; } continue; } if (!isset($l->priv->{$k})) { if (cse($k, "_flag")) { if (is_default_quota_flag_on($k)) { $l->priv->{$k} = 'on'; $write = true; } } } } if ($write) { $l->setUpdateSubaction(); $l->write(); $write = false; } } }
static function continueForm($parent, $class, $param, $continueaction) { global $gbl, $sgbl, $login, $ghtml; /* if(!eregi("^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$", $param['nname'])) { throw new lxException('invalid_domain_name', 'nname'); } */ if (!cse($param['nname'], ".vm")) { $param['nname'] .= ".vm"; } $param['nname'] = strtolower($param['nname']); if ($param['one_ipaddress_f']) { full_validate_ipaddress($param['one_ipaddress_f']); } /* if (!preg_match("/[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+]/i", $param['nname'])) { throw new lxException('domain_name_invalid', 'nname'); } */ if (isOn($param['send_welcome_f'])) { if (!$param['contactemail']) { throw new lxexception("sending_welcome_needs_contactemail", array('contactemail', 'send_welcome_f'), ''); } if (!validate_email($param['contactemail'])) { throw new lxexception("contactemail_is_not_valid_email_address", 'contactemail', ''); } } if ($param['resourceplan_f'] === 'continue_without_plan') { $vlist['__c_subtitle_quota'] = 'Quota'; $qvlist = getQuotaListForClass('vps'); $vlist = lx_merge_good($vlist, $qvlist); $ret['param'] = $param; $ret['variable'] = $vlist; $ret['action'] = "Add"; } else { $template = getFromAny(array($login, $parent), 'resourceplan', $param['resourceplan_f']); $param['use_resourceplan_f'] = 'on'; if (!$template) { throw new lxexception("the_template_doesnt_exist", 'resourceplan_f', $param['resourceplan_f']); } $ret['action'] = 'addnow'; $ret['param'] = $param; return $ret; } return $ret; }
function getToArray($object) { $col = $this->getColumnTypes(); //dprint_r($array); foreach ($col as $key => $val) { if (csb($key, "coma_")) { $cvar = substr($key, 5); $value = $object->{$cvar}; if (cse($key, "_list")) { $namelist = $value; } else { $namelist = get_namelist_from_objectlist($value); } $ret[$key] = implode(",", $namelist); dprint("in COma {$key} {$ret[$key]}<br> "); $ret[$key] = ",{$ret[$key]},"; } else { if (csb($key, "ser_")) { $cvar = substr($key, 4); $value = $object->{$cvar}; if ($value && isset($value->driverApp)) { unset($value->driverApp); } if (cse($key, "_a")) { if ($value) { foreach ($value as $kk => $vv) { unset($value[$kk]->__parent_o); } } } $ret[$key] = base64_encode(serialize($object->{$cvar})); //$ret[$key] = serialize($object->$cvar); } else { if (csb($key, "priv_q_") || csb($key, "used_q_")) { $qob = strtil($key, "_q_"); $qkey = strfrom($key, "_q_"); if ($object->get__table() === 'uuser') { } $ret[$key] = $object->{$qob}->{$qkey}; } else { if (!isset($object->{$key})) { $object->{$key} = null; } if (csb($key, "text_")) { $string = str_replace("\\", '\\\\', $object->{$key}); } else { $string = $object->{$key}; } $ret[$key] = str_replace("'", "\\'", $string); //$ret[$key] = $object->$key; } } } } return $ret; }
function deleteSpecific() { //$this->notifyObjects('delete'); //lxfile_rm_rec("__path_program_home/domain/$this->nname/"); $ftplist = $this->getParentO()->getList('ftpuser'); foreach ($ftplist as $k => $v) { if (cse($v->nname, "@{$this->nname}")) { $v->delete(); continue; } if ($v->nname === $this->nname) { $v->delete(); continue; } } }
function __ajax_desc_tree() { global $gbl, $sgbl, $login, $ghtml; $object = $gbl->__c_object; $icondir = get_image_path('/button/'); $rclist = $object->getResourceChildList(); $cid = $ghtml->node; if ($object->hasFileResource()) { $u = "a=show&k[class]=ffile&k[nname]=/"; $u = $ghtml->getFullUrl($u); $v = createClName('ffile', '/'); $ret[] = array('text' => "File", 'icon' => "{$icondir}/ffile_show.gif", 'hrefTarget' => 'mainframe', 'href' => $u, 'id' => "{$cid}&{$v}"); } if ($ghtml->__resource_class) { $c = strfrom($ghtml->__resource_class, "__resource_"); if (cse($c, "_l")) { $clname = $object->getChildNameFromDes($c); $list = $object->getList($clname, $totalcount); foreach ($list as $o) { $u = "a=show&k[class]={$o->getClass()}&k[nname]={$o->nname}"; $u = $ghtml->getFullUrl($u); $ret[] = array('text' => basename($o->nname), 'icon' => "{$icondir}/{$o->getClass()}_list.gif", 'hrefTarget' => 'mainframe', 'href' => $u, 'id' => "{$cid}&{$o->getClName()}"); } } else { if (cse($c, "_o")) { $clname = $object->getChildNameFromDes($c); $o = $object->getObject($clname); $u = "a=show&o={$o->getClass()}"; $u = $ghtml->getFullUrl($u); $ret[] = array('text' => $o->getClass(), 'icon' => "{$icondir}/{$o->getClass()}_show.gif", 'hrefTarget' => 'mainframe', 'href' => $u, 'id' => "{$cid}&{$o->getClass()}"); } } return $ret; } if ($ghtml->__title_function) { $t = $ghtml->__title_function; $alist = $object->createShowAlist($alist); foreach ($alist as $k => $v) { if (csb($k, "__title")) { if ($k !== $t) { if ($insidetitle) { $insidetitle = false; break; } continue; } $insidetitle = true; continue; } if ($insidetitle) { $url = $ghtml->getFullUrl($v); if ($ghtml->is_special_url($url)) { continue; } $urlinfo = $ghtml->getUrlInfo($url); $ret[] = array('text' => $urlinfo['description']['desc'], 'icon' => $urlinfo['image'], 'hrefTarget' => 'mainframe', 'leaf' => true, 'href' => $url, 'id' => "&end"); } } return $ret; } if ($object->hasFunctions()) { $alist = $object->createShowAlist($alist); foreach ($alist as $k => $v) { if (!csb($k, "__title")) { continue; } $title = strfrom($k, "__title_"); if ($title === 'mailaccount') { continue; } if ($title === 'custom') { continue; } $icon = "{$icondir}/__title_{$title}.gif"; if (!lxfile_exists("__path_program_htmlbase/{$icon}")) { //lfile_put_contents("title.img", "$title.gif\n", FILE_APPEND); $icon = null; } $ret[] = array('text' => $v, 'icon' => $icon, 'hrefTarget' => '', 'href' => null, 'id' => "{$cid}&{$k}"); } } foreach ($rclist as $c) { $clname = $object->getChildNameFromDes($c); $desc = get_description($clname); $desc = get_plural($desc); $url = $ghtml->getFullUrl("a=list&c={$clname}"); $ret[] = array('text' => $desc, 'icon' => "{$icondir}/{$clname}_list.gif", 'hrefTarget' => 'mainframe', 'href' => $url, 'id' => "{$cid}&__resource_{$c}"); } return $ret; }
print_time("include"); include_once "htmllib/phplib/lib/lxclass.php"; include_once "htmllib/lib/commonfslib.php"; include_once "htmllib/lib/objectactionlib.php"; include_once "htmllib/lib/commandlinelib.php"; include_once "lib/sgbl.php"; include_once "lib/gbl.php"; include_once "htmllib/lib/lib.php"; include_once "htmllib/phplib/lxlib.php"; include_once "htmllib/phplib/common.inc"; include_once "htmllib/lib/remotelib.php"; include_once "htmllib/phplib/lib/lxdb.php"; include_once "lib/define.php"; include_once "lib/driver_define.php"; include_once "lib/sgbl.php"; include_once "lib/common.inc"; //include_once "htmllib/lib/xmlinclude.php"; // This is the program specific common lib. There is no need dump everything htmllib/lib/lib.php which has become too large. include_once "lib/programlib.php"; if (lxfile_exists("../etc/classdefine")) { $list = lscandir_without_dot("../etc/classdefine"); foreach ($list as $l) { if (cse($l, "phps")) { include_once "../etc/classdefine/{$l}"; } } } if (WindowsOs()) { include_once "htmllib/lib/lxcomlib.php"; } //print_time("include", "include");
function createShowAlist(&$alist, $subaction = null) { global $gbl, $sgbl, $login, $ghtml; $this->fixParentClName(); if (!cse($this->get__table(), "template")) { //$alist['__title_main'] = $this->getTitleWithSync(); /* $alist['action'][] = "a=update&sa=backup"; $alist['action'][] = "a=updateform&sa=restore"; */ } else { //$alist['__title_main'] = $login->getKeywordUc('resource'); } if ($this->get__table() === 'dnstemplate') { //$alist[] = 'a=updateform&sa=ipaddress'; } else { } return $alist; }
$param = ticket::add($client, 'ticket', $param); $tick = new Ticket(null, null, $param['nname']); $tick->create($param); $tick->postAdd(); $tick->was(); } else { $m = "There is no user with your from address in the system."; $m .= "-------------------\n.........{$content}"; mail($smallfrom, "HelpDesk Failed", $m); } exit; } $ticketid = $matches[2]; $pclass = "client"; $pname = $matches[1]; if (cse($pname, ".vm")) { $pclass = "vps"; } /* if (!csa($matches[1], "-")) { $pclass = "client"; $pname = $matches[1]; } else { $pp = explode("-", $matches[1]); $pclass = $pp[0]; $pname = $pp[1]; } */ $pobject = new $pclass(null, null, $pname); $pobject->get(); $tick = new Ticket(null, null, $ticketid);
static function doupdateLicense() { global $gbl, $sgbl, $login, $ghtml; $rmt = new Remote(); $rmt->program_name = $sgbl->__var_program_name; $var = base64_encode(serialize($rmt)); if (!$login->isLteAdmin()) { throw new lxException("not_admin", ''); } $license = $login->getObject('license'); $license->parent_clname = $login->getClName(); $prilist = $login->getQuotaVariableList(); foreach ($prilist as $k => $v) { if (cse($k, "_flag")) { $login->priv->{$k} = 'On'; } else { if (cse($k, "_usage")) { $login->priv->{$k} = 'Unlimited'; } else { if (cse($k, "_num")) { $login->priv->{$k} = 'Unlimited'; } } } } $login->setUpdateSubaction(); $login->write(); $lic = $license->licensecom_b; $def = array("vps_num" => "Unlimited", "client_num" => "Unlimited", "pserver_num" => "Unlimited", "vps_num" => "Unlimited"); $list = array("maindomain_num", "domain_num", "pserver_num", "vps_num"); foreach ($list as $l) { $licv = "lic_{$l}"; $lic->{$licv} = $def[$l]; } $license->setUpdateSubaction(); $license->write(); }
function importVps() { global $gbl, $sgbl, $login, $ghtml; $objlist = null; if ($this->main->__var_vps_driver === 'openvz') { if (!lxfile_exists("/etc/vz/conf")) { throw new lxException("no_vz_conf_directory", ''); } $list = lscandir_without_dot_or_underscore("/etc/vz/conf"); foreach ($list as $l) { if (!cse($l, ".conf")) { continue; } if ($l === '0.conf') { continue; } $object = vps__openvz::createVpsObject($this->main->nname, $l); $objlist[$object->nname] = $object; } } else { lxshell_return("chkconfig", "xendomains", "on"); //lxshell_return("service", "xendomains", "restart"); $imdriver = $this->main->__var_xenimportdriver; $importdriverfile = "{$sgbl->__path_program_htmlbase}/lib/xenimport/xenimport__{$imdriver}.php"; if (!lxfile_exists($importdriverfile)) { throw new lxException("could_not_find_xen_import_driver_file", ''); } include_once $importdriverfile; if (!function_exists("__xenimport_get_data")) { throw new lxException("no_xenimport_function", ''); } $data = __xenimport_get_data(); foreach ((array) $data as $input) { $object = vps__xen::createVpsObject($this->main->nname, $input); $objlist[$object->nname] = $object; } } return $objlist; }
function setHistory() { global $gbl, $sgbl, $login, $ghtml; $ac = array('addform', 'updateform', 'list', 'show'); if (!array_search_bool(strtolower($ghtml->__http_vars['frm_action']), $ac)) { return; } //$histlist = $this->getSessionV("lx_history_var"); $histlist = $login->dskhistory; $buttonpath = null; $url = "/display.php?{$ghtml->get_get_from_current_post(array('Search', 'frm_hpfilter'))}"; $description = $ghtml->getActionDetails($url, null, $buttonpath, $path, $post, $file, $name, $image, $__t_identity); if ($file === 'ffile') { return; } if ($file === 'dskshortcut_a') { return; } if (cse($file, 'installapp')) { return; } unset($histlist[$url]); $histlist[$url] = time(); while (count($histlist) > 20) { array_shift($histlist); } //$this->setSessionV("lx_history_var", $histlist); $login->dskhistory = $histlist; $login->setUpdateSubaction(); $login->write(); }
function doReverseDns() { global $sgbl; $this->main->nname = strtoupper($this->main->nname); addLineIfNotExistInside("__path_named_chroot/etc/named.conf", "include \"/etc/lxreverse.conf\";", "//added by hypervm"); list($base, $end) = reversedns::getBaseEnd($this->main->nname, $this->main->__var_rdnsrange); if (reversedns::isIPV6($this->main->nname)) { $isv6 = true; } else { $isv6 = false; } $ddate = date("Ymd"); // We read the last serial from the zone file // default to 0 on error if ($isv6) { $version = $this->getNewSerial("{$sgbl->__path_named_realpath}/" . $base . "ip6.arpa", $ddate); } else { $version = $this->getNewSerial("{$sgbl->__path_named_realpath}/" . $base . "in-addr.arpa", $ddate); } if ($version < 10) { $version = "0" . $version; } $ddate = "{$ddate}{$version}"; $string = null; $string .= "\$TTL 3600\n"; if ($isv6) { $string .= "\$ORIGIN " . $base . "IP6.ARPA.\n"; } else { $string .= "\$ORIGIN {$base}.IN-ADDR.ARPA.\n"; } $string .= "@ IN SOA {$this->main->__var_revdns1}. root.{$this->main->__var_revdns1}. (\n"; $string .= "{$ddate} ; serial\n"; $string .= "18800 ; refresh\n"; $string .= "14400 ; retry\n"; $string .= "1814400 ; expire\n"; $string .= "3600 ; default_tt\n"; $string .= ")\n"; $string .= " IN NS {$this->main->__var_revdns1}.\n"; if ($this->main->__var_revdns2) { $string .= " IN NS {$this->main->__var_revdns2}.\n"; } $result = $this->main->__var_reverse_list; $result = $result[$base]; $this->main->end = $end; $result = merge_array_object_not_deleted($result, $this->main); foreach ($result as $key => $val) { $val['reversename'] = trim($val['reversename']); if (!cse($val['reversename'], ".")) { $val['reversename'] .= "."; } if ($isv6) { $string .= reversedns::createDottedRevedIPV6($val['end']) . "\t IN PTR {$val['reversename']}\n"; } else { $string .= "{$val['end']}\tIN PTR {$val['reversename']}\n"; } } if ($isv6) { lfile_put_contents("__path_named_realpath/" . $base . "ip6.arpa", $string); } else { lfile_put_contents("__path_named_realpath/{$base}.in-addr.arpa", $string); } $this->createMainFile(); }