function __xenimport_parse_config($file)
{
    $list = lfile_trim($file);
    foreach ($list as $l) {
        if (!csa($l, "=")) {
            continue;
        }
        list($var, $val) = explode("=", $l);
        $var = trim($var);
        $val = trim($val);
        switch ($var) {
            case "memory":
                $ret['memory'] = $val;
                break;
            case "name":
                $ret['name'] = strtolower(trim($val, '"'));
                break;
            case "ipaddr":
                $val = trim($val, '"');
                $ret['ipaddress'] = trim($val);
                break;
            case "hostname":
                $val = trim($val, '"');
                $ret['hostname'] = trim($val);
                break;
            case "disk":
                __xenimport_parsedisk($ret, $val);
                break;
        }
    }
    return $ret;
}
Exemple #2
0
function convert_tree_to_frm_o()
{
    global $gbl, $sgbl, $login, $ghtml;
    $cid = $ghtml->node;
    if (!csa($cid, "&")) {
        return null;
    }
    $cid = trim($cid, "/&");
    $dlist = explode("&", $cid);
    $i = 0;
    $ghtml->__title_function = false;
    $ghtml->__resource_class = false;
    foreach ((array) $dlist as $d) {
        //if (csa($d, "_s_vv_p_")) {
        if (csb($d, "__title_")) {
            $ghtml->__title_function = $d;
            continue;
        }
        if (csb($d, "__resource_")) {
            $ghtml->__resource_class = $d;
            continue;
        }
        $ghtml->__resource_class = false;
        if (csa($d, "-")) {
            list($class, $name) = getClassAndName($d);
            $frmo[$i]['class'] = $class;
            $frmo[$i]['nname'] = $name;
        } else {
            $frmo[$i]['class'] = $d;
        }
        $i++;
    }
    $ghtml->__http_vars['frm_o_o'] = $frmo;
}
 static function getEachfileqouta($file, $domainname, $oldtime, $newtime)
 {
     $fp = @fopen($file, "r");
     print "Opening File name is :{$file}\n";
     error_reporting(0);
     if (!$fp) {
         return 0;
     }
     $fsize = filesize($file);
     print "Here U are in Mail log file Size is:{$fsize}\n";
     if ($fsize <= 5) {
         return 0;
     }
     $total = 0;
     $ret = FindRightPosition($fp, $fsize, $oldtime, $newtime, array("ftpusertraffic__pureftp", "getTimeFromString"));
     if ($ret < 0) {
         dprint("Could not find position\n");
         return null;
     }
     $total = 0;
     while (!feof($fp)) {
         $string = fgets($fp);
         if (csa($string, $domainname)) {
             $total += self::LogConvertString($string);
         }
         if (self::getTimeFromString($string) > $newtime) {
             break;
         }
     }
     $total = $total / (1024 * 1024);
     $total = round($total, 1);
     fclose($fp);
     dprint("Returning Total From OUT SIDE This File: for {$domainname} {$total} \n");
     return $total;
 }
Exemple #4
0
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']);
    }
}
 static function getVersion($list, $name)
 {
     foreach ($list as $v) {
         if (csb($v, $name) || csa($v, " {$name} ")) {
             $ret[] = $v;
         }
     }
     return implode(", ", $ret);
 }
 function check_xen_dirlocation()
 {
     $diro = getFirstFromList($this->main->__t_new_xen_location_a_list);
     $dirlocation = $diro->nname;
     if (!csb($dirlocation, "lvm:")) {
         return;
     }
     $dirlocation = fix_vgname($dirlocation);
     $ret = exec_with_all_closed_output("vgdisplay -c {$dirlocation}");
     if (!csa($ret, ":")) {
         throw new lxException("the_lvm_doesnt_exist", 'nname', $dirlocation);
     }
 }
 function log_error_messages($throwflag = true)
 {
     if (mysql_errno()) {
         dprint(mysql_error());
         if (mysql_errno() === 1007 && csa($this->main->dbname, "_")) {
             log_message("Mysql Db {$this->main->dbname} already exists. and also has an underscore... Will treat this as the main db..");
             log_error(mysql_error());
             return true;
         }
         if ($throwflag) {
             throw new lxException('mysql_error', '', mysql_error());
         }
     }
 }
 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;
 }
Exemple #9
0
function print_a_right_button($something, $ttype, $id, $pos)
{
    global $gbl, $login, $ghtml, $gdata;
    $name = $gdata[$id][0];
    $url = $gdata[$id][1];
    $icon = $gdata[$id][2];
    if (csa($url, "javascript")) {
        $onclickstring = "onClick=\"{$url}\"";
    } else {
        $onclickstring = "onClick=\"top.mainframe.location='{$url}';\"";
    }
    $skindir = $login->getSkinDir();
    ?>
 
	
	<table border="0" cellspacing=0 cellpadding=0 style='font-size:11;color:#004466;height:34;width:73;background:url(<?php 
    echo $skindir;
    ?>
/right_btn.gif);' OnMouseOver="style.cursor='pointer'; top.mainframe.changeContent('help','<?php 
    echo $name;
    ?>
');"  <?php 
    echo $onclickstring;
    ?>
 onmouseout="changeContent('help','helparea')">
        <tr>
            <td valign=bottom width=17 height=34 align=left style='padding-bottom:5;padding-left:6'>
            <img height=8 width=8 src='/img/image/<?php 
    echo $login->getSpecialObject('sp_specialplay')->icon_name;
    ?>
/button/<?php 
    echo $icon;
    ?>
'></td>
        <td valign=bottom width=53 style='padding-left:3;padding-bottom:3;' align=left><b><?php 
    echo $name;
    ?>
 </font> </b></td>
    </tr>
    </table>

	<?php 
}
 static function getFtpList($username = null)
 {
     $list = process__linux::readProcessList();
     $ret = null;
     foreach ($list as $l) {
         if (!csa($l['command'], "pure-ftp")) {
             continue;
         }
         dprintr($l);
         $r['pid'] = $l['nname'];
         $r['nname'] = $r['pid'];
         if ($username && $username !== $l['username']) {
             continue;
         }
         $r['account'] = $username;
         $r['state'] = $l['state'];
         $ret[] = $r;
     }
     return $ret;
 }
 static function readSingleMail($name)
 {
     $ret['message'] = lxshell_output("__path_program_root/bin/misc/qmHandle", "-m{$name}");
     $oldtime = time() - 7200;
     $newtime = time() - 500;
     $fp = fopen("/var/log/kloxo/maillog", "r");
     $fsize = lxfile_size("/var/log/kloxo/maillog");
     $ot = date("Y-m-d:H-i");
     dprint("Start time: {$ot}\n");
     $res = FindRightPosition($fp, $fsize, $oldtime, $newtime, array("mailtraffic", "getTimeFromOriginalQmailString"));
     if ($res < 0) {
         $ret['log'] = null;
         return $ret;
     }
     //$s = fgets($fp);
     dprint("here {$s}\n");
     takeToStartOfLine($fp);
     takeToStartOfLine($fp);
     //$s = fgets($fp);
     dprint("here {$s}\n");
     $delivery = null;
     while (!feof($fp)) {
         $s = fgets($fp);
         if (!$delivery) {
             if (csa($s, "starting delivery") && csa($s, "msg {$name}")) {
                 $delivery = preg_replace("/.*delivery ([^:]*):.*/", "\$1", $s);
                 $delivery = trim($delivery);
                 dprint("Deliver num: {$delivery}*\n");
                 continue;
             }
         } else {
             dprint("{$s}\n");
             if (csa($s, "delivery {$delivery}:")) {
                 dprint("{$s}\n");
                 $ret['log'] = $s;
                 break;
             }
         }
     }
     return $ret;
 }
Exemple #12
0
function print_a_right_button($something, $ttype, $id, $pos)
{
    global $gbl, $login, $ghtml, $gdata;
    $name = $gdata[$id][0];
    $url = $gdata[$id][1];
    $icon = $gdata[$id][2];
    if (csa($url, "javascript")) {
        $onclickstring = "onClick=\"{$url}\"";
    } else {
        $onclickstring = "onClick=\"top.mainframe.location='{$url}';\"";
    }
    $skindir = $login->getSkinDir();
    ?>
<td>
<table class="headertabletabsright" style="background: url(<?php 
    echo $skindir;
    ?>
right_btn.gif);" OnMouseOver="style.cursor='pointer';" <?php 
    echo $onclickstring;
    ?>
>
    <tr>
        <td valign="bottom" width="17" height="34" align="left" style="padding-bottom: 5px; padding-left: 6px;">
            <img height="8" width="8" src="/img/image/<?php 
    echo $login->getSpecialObject('sp_specialplay')->icon_name;
    ?>
/button/<?php 
    echo $icon;
    ?>
">
        </td>
        <td valign="bottom" width="53" style="padding-left: 3px; padding-bottom: 3px;" align="left"><b><?php 
    echo $name;
    ?>
</b>
        </td>
    </tr>
</table>
</td>
<?php 
}
Exemple #13
0
 function updateform($subaction, $param)
 {
     if (csa($subaction, "ssl_")) {
         $this->slave_id = "localhost";
         $vlist['slave_id'] = array('s', get_all_pserver());
         return $vlist;
     }
     if ($this->isOn('upload_status')) {
         $string = null;
         $res = openssl_x509_read($this->text_crt_content);
         $ar = openssl_x509_parse($res);
         $string .= "{$ar['name']} {$ar['subject']['CN']}";
         $vlist['upload'] = array('M', $string);
         $vlist['text_crt_content'] = null;
         $vlist['text_key_content'] = null;
         $vlist['text_ca_content'] = null;
     } else {
         $vlist['nname'] = array('M', $this->certname);
         $vlist["ssl_data_b_s_commonName_r"] = null;
         $vlist["ssl_data_b_s_countryName_r"] = null;
         $vlist["ssl_data_b_s_stateOrProvinceName_r"] = null;
         $vlist["ssl_data_b_s_localityName_r"] = null;
         $vlist["ssl_data_b_s_organizationName_r"] = null;
         $vlist["ssl_data_b_s_organizationalUnitName_r"] = null;
         $vlist["ssl_data_b_s_emailAddress_r"] = null;
         $this->convertToUnmodifiable($vlist);
         $vlist['text_csr_content'] = null;
         $vlist['text_crt_content'] = null;
         $vlist['text_key_content'] = null;
     }
     /*
     	if ($this->getParentO()->isAdmin()) {
     		$vlist['__m_message_pre'] = 'sslcert_updateform_update_pre_admin';
     	} else {
     		$vlist['__m_message_pre'] = 'sslcert_updateform_update_pre_client';
     	}
     */
     $vlist['__v_button'] = array();
     return $vlist;
 }
 static function getEachfileqouta($file, $iface, $oldtime, $newtime)
 {
     $fp = @fopen($file, "r");
     print "Opening File name is :{$file}\n";
     error_reporting(0);
     if (!$fp) {
         return 0;
     }
     $fsize = filesize($file);
     print "Here U are in Mail log file Size is:{$fsize}\n";
     if ($fsize <= 5) {
         return 0;
     }
     $total = 0;
     $ret = FindRightPosition($fp, $fsize, $oldtime, $newtime, array("vpstraffic__xen", "getTimeFromString"));
     if ($ret < 0) {
         dprint("Could not find position\n");
         return;
     }
     $total = 0;
     while (!feof($fp)) {
         $string = fgets($fp);
         if (csa($string, $iface)) {
             //$total += self::LogConvertString($string);
             $incoming += self::getFromString($string, 4);
             $outgoing += self::getFromString($string, 5);
             $total += self::getFromString($string, 5);
             $total += self::getFromString($string, 4);
         }
         if (self::getTimeFromString($string) > $newtime) {
             break;
         }
     }
     $incoming = self::roundupValue($incoming);
     $outgoing = self::roundupValue($outgoing);
     $total = self::roundupValue($total);
     fclose($fp);
     dprint("Returning Total From OUT SIDE This File: for {$iface} {$total} \n");
     return array('total' => $total, 'incoming' => $incoming, 'outgoing' => $outgoing);
 }
 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;
     }
     $sysuser = mmail__qmail::getUserGroup($domain);
     // --- 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}/.bogopref.cf";
         $prefpath = "{$mailpath}/{$user}/.bogopref.cf";
     } else {
         return;
     }
     $prefdir = dirname($prefpath);
     if (!lxfile_exists(dirname($prefpath))) {
         lxuser_mkdir($sysuser, dirname($prefpath));
     }
     $wname = fix_nname_to_be_variable($this->main->nname);
     $fdata = null;
     $cutoff = $this->main->spam_hit / 10 + 0.2;
     $fdata .= "spam_cutoff  {$cutoff}\n";
     $fdata .= "spam_subject_tag={$this->main->subject_tag}\n";
     $fdata .= "wordlist R,user,{$wname}.wordlist.db,1\n";
     $fdata .= "wordlist R,system,wordlist.db,2\n";
     $fdata .= "wordlist R,system,kloxo.wordlist.db,3\n";
     lxuser_put_contents($sysuser, $prefpath, $fdata);
     if (!lxfile_real("/var/bogofilter/{$wname}.wordlist.db")) {
         new_process_cmd($sysuser, null, "bogofilter -d /var/bogofilter/ --wordlist=R,user,{$wname}.wordlist.db,1  -n < /etc/my.cnf");
     }
     lxfile_touch("/var/bogofilter/wordlist.db");
     // Using generic because spamassasin is used on windows too. Or at least can be used.
     //lxfile_generic_chown("/var/bogofilter", mmail__qmail::getUserGroup($domain));
 }
Exemple #16
0
function print_header_feather()
{
    global $gbl, $sgbl, $login, $ghtml;
    $lightskincolor = $login->getLightSkinColor();
    print "<body>\n";
    print "<div id=statusbar  style='background:#{$lightskincolor};scroll:auto;height:26;width:100%;border-bottom:4px solid #b1cfed;margin:2 2 2 2:vertical-align:top;text-align:top'>\n";
    $alist[] = "a=show";
    $alist = $login->createShowAlist($alist);
    $gbl->__c_object = $login;
    print "<table cellpadding=0 cellspacing=0>\n<tr>\n";
    $count = 0;
    $icount = 0;
    foreach ($alist as $k => $v) {
        if (csa($k, "__title")) {
            $count++;
            continue;
        }
        $icount++;
        if ($icount > 8) {
            continue;
        }
        $v = $ghtml->getFullUrl($v);
        $ghtml->print_div_button_on_header(null, true, $k, $v);
    }
    print "<td nowrap style='width:40px'></td>\n";
    $v = "a=list&c=ndskshortcut";
    $v = $ghtml->getFullUrl($v);
    $ghtml->print_div_button_on_header(null, true, 0, $v);
    $ghtml->print_toolbar();
    print "<td width=100%></td>\n";
    $v = $ghtml->getFullUrl("a=list&c=ssessionlist");
    $ghtml->print_div_button_on_header(null, true, $k, $v);
    $v = create_simpleObject(array('url' => "javascript:top.mainframe.logOut()", 'purl' => '&a=updateform&sa=logout', 'target' => null));
    $ghtml->print_div_button_on_header(null, true, $k, $v);
    print "</tr>\n</table>\n";
    print "</div>\n";
}
 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");
 }
Exemple #18
0
 static function add($parent, $class, $param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if ($login->isAdmin() && isset($param['nomodifyname']) && $param['nomodifyname'] === 'on') {
     } else {
         if (!$parent->isAdmin()) {
             $param['nname'] = self::getDbName($parent->nname, $param['nname']);
         } else {
             $param['nname'] = substr($param['nname'], 0, 15);
         }
     }
     if (csa($param['dbpassword'], "'")) {
         throw new lxexception("password_cannot_contain_single_quote", '', "");
     }
     $param['username'] = $param['nname'];
     $param['dbname'] = $param['nname'];
     $param['dbtype'] = strtil($class, "db");
     /*
     	if (!check_if_many_server()) {
     		$param['syncserver'] = 'localhost';
     	}
     */
     return $param;
 }
 function showRawPrint($subaction = null)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!$subaction) {
         return;
     }
     $class = $subaction;
     $var = "{$subaction}_show_list";
     $alist = exec_class_method($subaction, "get_full_alist");
     foreach ($alist as $k => $a) {
         if ($ghtml->is_special_url($a)) {
             $alist[$k] = $a->purl;
         }
     }
     $dst = null;
     foreach ((array) $this->{$var} as $k => $v) {
         if (!csa($v, "__title")) {
             $dst[] = base64_decode($v);
         } else {
             $dst[] = $v;
         }
     }
     $ghtml->print_fancy_select($class, $alist, $dst);
 }
function add_line_to_master_mycnf()
{
    global $gbl, $sgbl, $login, $ghtml;
    $dbf = $sgbl->__var_dbf;
    if (!lxfile_exists("/etc/primary_master.copy.my.cnf")) {
        lxfile_cp("/etc/my.cnf", "/etc/primary_master.copy.my.cnf");
    }
    $v = lfile_get_contents("/etc/my.cnf");
    if (csa($v, "binlog-do-db")) {
        print "Line already exists in /etc/my.cnf\n";
        return;
    }
    $list = lfile_trim("/etc/my.cnf");
    foreach ($list as $k => $l) {
        $ll[] = $l;
        if ($l == '[mysqld]') {
            $ll[] = "log-bin=mysql-bin";
            $ll[] = "binlog-do-db={$dbf}";
            $ll[] = "server-id=1";
        }
    }
    lfile_put_contents("/etc/my.cnf", implode("\n", $ll));
    system("service mysqld restart");
}
Exemple #21
0
            $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 {
    if ($sgbl->isKloxo() && !$sgbl->isDebug()) {
        $php_st .= "cgi.assign\t=\t\t\t\t\t\t   (\".php\" => \"/usr/local/lxlabs/kloxo/file/phpsuexec.sh\" )\n";
Exemple #22
0
 function isQuotaVariableSpecific($var)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if ($var === 'frontpage_flag') {
         $v = db_get_value("pserver", $this->syncserver, "osversion");
         if (csa($v, " 5")) {
             return false;
         }
         $driverapp = $gbl->getSyncClass(null, $this->syncserver, 'web');
         if ($driverapp === 'lighttpd') {
             return false;
         }
     }
     return true;
 }
Exemple #23
0
 function createShowRlist($subaction)
 {
     //$l = $this->pserverInfo();
     global $gbl, $sgbl, $login, $ghtml;
     static $rlist;
     if ($rlist) {
         return $rlist;
     }
     if ($sgbl->isHyperVm()) {
         $rlist = $this->getVpsRam();
     }
     $driverapp = $gbl->getSyncClass($this->__masterserver, $this->__readserver, 'pserver');
     $l = rl_exec_get($this->__masterserver, $this->__readserver, array("pserver__{$driverapp}", "pserverInfo"));
     $osdet = $l['osdet'];
     if ($this->osversion !== $osdet['version']) {
         $this->osversion = $osdet['version'];
         $this->setUpdateSubaction();
     }
     $lvm = $l['lvm'];
     foreach ((array) $lvm as $k => $c) {
         $rlist[] = array('lvm', "{$c['nname']}", $c['used'], $c['total']);
     }
     $disk = $l['disk'];
     foreach ($disk as $k => $c) {
         $c['nname'] = str_replace(":", "_", $c['nname']);
         if (csa($c['nname'], "mapper")) {
             $c['nname'] = strfrom($c['nname'], "/dev/mapper/");
         }
         $rlist[] = array('disk', "{$c['mountedon']} ({$c['nname']})", $c['used'], $c['kblock']);
     }
     /// Rlist takes an array...
     $rlist[] = array('memory_usage', "Memory:Memory Usage (MB)", $l['used_s_memory'], $l['priv_s_memory']);
     $rlist[] = array('membuffers_usage', "Buffers:Memory Buffers Usage (MB)", $l['used_s_membuffers'] . ' MB', '-');
     $rlist[] = array('memcached_usage', "Cached:Memory Cached Usage (MB)", $l['used_s_memcached'] . ' MB', '-');
     if (isset($l['used_s_swap'])) {
         $rlist[] = array('swap_usage', "Swap:Swap Usage (MB)", $l['used_s_swap'], $l['priv_s_swap']);
     }
     if (isset($l['used_s_virtual'])) {
         $rlist[] = array('Virtual Memory', "Virtual:Virtual Memory Usage (MB)", $l['used_s_virtual'], $l['priv_s_virtual']);
     }
     $rlist[] = array('Server Traffic', "Traffic:Server Traffic", $this->used->server_traffic_usage, '-');
     $rlist[] = array('Server Traffic', "Traffic:Server Traffic For Last Month", $this->used->server_traffic_last_usage, '-');
     $cpu = $l['cpu'];
     foreach ($cpu as $k => $c) {
         //$rlist[] = array('cpu', "CPU$k Model (speed)",  "{$c['used_s_cpumodel']} ({$c['used_s_cpuspeed']})", '-');
         $rlist[] = array('cpu', "CPU{$k} speed", "{$c['used_s_cpuspeed']}", '-');
     }
     return $rlist;
 }
Exemple #24
0
 static function readMaillog()
 {
     $date = time() - 24 * 3600 * 2;
     $logfile = "/var/log/kloxo/maillog";
     $fp = fopen($logfile, "r");
     $fsize = lxfile_size($logfile);
     FindRightPosition($fp, $fsize, $date, time(), array("mailtraffic", "getTimeFromOriginalQmailString"));
     while (!feof($fp)) {
         $s = fgets($fp);
         $s = trim($s);
         if (!csa($s, "lx-sending")) {
             continue;
         }
         $v = strfrom($s, "mail for");
         $id = $v;
         if (!isset($total[$id])) {
             $total[$id] = 1;
         } else {
             $total[$id]++;
         }
     }
     return $total;
 }
Exemple #25
0
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;
}
Exemple #26
0
 function updateChangeNname($param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $this->__real_nname = $this->nname;
     $this->nname = $param['nname'];
     $this->nname = trim($this->nname);
     if ($this->is__table('vps')) {
         if (!cse($this->nname, ".vm")) {
             $this->nname .= ".vm";
         }
         if (csa($this->nname, '-')) {
             throw new lxexception('name_cannot_contain_dash', 'nname', '');
         }
         if (csa($this->nname, ' ')) {
             throw new lxexception('name_cannot_contain_space', 'nname', '');
         }
     }
     $sq = new Sqlite(null, $this->get__table());
     $res = $sq->rawQuery("select * from {$this->get__table()} where nname = '{$this->nname}'");
     if ($res) {
         throw new lxException('already_exists', 'nname', $this->nname);
     }
     $gbl->__this_redirect = '/display.php?frm_action=resource';
     return $param;
 }
Exemple #27
0
 public function getScriptS($name)
 {
     $v = $name;
     while (true) {
         $v = strtil($v, "-");
         if (!$v) {
             $v = 'default';
             break;
         }
         dprint("Checking for conf {$v}\n");
         if (lxfile_exists("__path_program_root/bin/xen-dists/{$v}.conf")) {
             break;
         }
         if (!csa($v, "-")) {
             $v = "default";
             break;
         }
     }
     $file = "__path_program_root/bin/xen-dists/{$v}.conf";
     $list = lfile_trim($file);
     foreach ($list as $l) {
         if (char_search_beg($l, "#")) {
             continue;
         }
         if (csa($l, "=")) {
             $v = explode("=", $l);
             $result[$v[0]] = $v[1];
         }
     }
     return $result;
 }
Exemple #28
0
 function print_menulist($name, $alist, $base, $type)
 {
     global $gbl, $sgbl, $login, $ghtml;
     foreach ((array) $alist as $k => $a) {
         if (is_array($a)) {
             continue;
             if ($k === 'home') {
                 continue;
             }
             if ($this->is_special_url($a)) {
                 continue;
             }
             if (csb($k, "__title")) {
                 continue;
             }
             $desc = get_plural($k);
             $menuimg = "/img/image/" . $login->getSpecialObject('sp_specialplay')->icon_name . "/button/browse.gif";
             $endimg = "/img/right_point.gif";
             $desc = "<font style=font-weight:bold>{$desc}</font>";
             $mnu = $this->getMenuDescrString($menuimg, $desc, $endimg);
             print "window.{$name}{$k} = new Menu(\"{$mnu}\", 100);\n";
             foreach ($a as $nk => $nv) {
                 $nv = $this->getFullUrl($nv, $base);
                 $this->print_pmenu("{$name}{$k}", $nv);
             }
         }
     }
     print "window.{$name} = new Menu('{$name}',130);\n";
     if ($type === 'slist') {
         $aa = $this->getFullUrl('a=show', $base);
         $this->print_pmenu($name, $aa);
     }
     foreach ((array) $alist as $k => $a) {
         if (!strcmp($k, 'home')) {
             continue;
         }
         if ($this->is_special_variable($a)) {
             continue;
         }
         if (csb($k, "__title")) {
             continue;
         }
         if (is_array($a)) {
             continue;
         } else {
             // Hack hack...  NOt showing addforms in the top Menu... Also not showing in the tree view..
             if (csa(strtolower($a), "addform") || csa(strtolower($a), 'update') && !csa(strtolower($a), 'updateform')) {
                 continue;
             }
             if (!csb($k, "__v_")) {
                 $a = $this->getFullUrl($a, $base);
                 $this->print_pmenu($name, $a);
             }
         }
     }
 }
Exemple #29
0
    function printSelectObjectTable($name_list, $parent, $class, $blist = array(), $display = null)
    {
        global $gbl, $sgbl, $login, $ghtml;
        print_time("{$class}.objecttable");
        if ($this->frm_accountselect !== null) {
            $sellist = explode(',', $this->frm_accountselect);
        } else {
            $sellist = null;
        }
        $classdesc = $this->get_class_description($class, $display);
        $unique_name = trim($parent->nname) . trim($class) . trim($display) . trim($classdesc[2]);
        $unique_name = fix_nname_to_be_variable($unique_name);
        $filtername = $parent->getFilterVariableForThis($class);
        $fil = $this->frm_hpfilter;
        $sortdir = null;
        $sortby = null;
        if (isset($fil[$filtername]['sortby'])) {
            $sortby = $fil[$filtername]['sortby'];
        }
        if (isset($fil[$filtername]['sortdir'])) {
            $sortdir = $fil[$filtername]['sortdir'];
        }
        $pagesize = '99999';
        $iconpath = get_image_path() . "/button";
        $nlcount = count($name_list) + 1;
        $imgheadleft = $login->getSkinDir() . "/top_lt.gif";
        $imgheadleft2 = $login->getSkinDir() . "/top_lt.gif";
        $imgheadright = $login->getSkinDir() . "/top_rt.gif";
        $imgheadbg = $login->getSkinDir() . "/top_bg.gif";
        $imgbtnbg = $login->getSkinDir() . "/btn_bg.gif";
        $imgtablerowhead = $login->getSkinDir() . "/tablerow_head.gif";
        $imgtablerowheadselect = $login->getSkinDir() . "/top_line_medium.gif";
        $imgbtncrv = $login->getSkinDir() . "/btn_crv.gif";
        $imgtopline = $login->getSkinDir() . "/top_line.gif";
        $classdesc = $this->get_class_description($class);
        $unique_name = trim($parent->nname) . trim($class) . trim($classdesc[2]);
        $unique_name = fix_nname_to_be_variable($unique_name);
        //dprint("-- ".$unique_name. " --", 2);
        ?>
<br />
      <script> var ckcount<?php 
        echo $unique_name;
        ?>
 ; </script>
<?php 
        $tsortby = $sortby;
        if (!$sortby) {
            $tsortby = exec_class_method($class, "defaultSort");
        }
        if (!$sortdir) {
            $sortdir = exec_class_method($class, "defaultSortDir");
        }
        //print_time("objecttable");
        $obj_list = $parent->getVirtualList($class, $total_num, $tsortby, $sortdir);
        //print_time("objecttable", 'objecttable');
        if (!$sellist) {
            //$total_num = $this->display_count($obj_list, $display) ;
        }
        ?>

    <table width=100%> <tr> <td align=center>
    <table cellspacing=2 cellpadding=2 width=97% align=center>
    <tr><td class=rowpoint></td><td colspan= <?php 
        echo $nlcount;
        ?>
>
    <table cellpadding=0 cellspacing=0 border=0 width=100%>
    <tr><td valign=bottom ></td>
    <td>
    <?php 
        if (isset($ghtml->__http_vars['frm_hpfilter'][$filtername]['pagenum'])) {
            $cgi_pagenum = $ghtml->__http_vars['frm_hpfilter'][$filtername]['pagenum'];
        } else {
            $cgi_pagenum = 1;
        }
        if (!$sellist) {
            $this->print_next_previous($parent, $class, "top", $cgi_pagenum, $total_num, $pagesize);
        }
        ?>
    </td>
    <td align=right valign=bottom >

    <?php 
        if (!$sellist) {
            ?>
            <table cellpadding="0" cellspacing="0" border="0" height="27" >

            <tr><td><img src="<?php 
            echo $imgheadleft;
            ?>
"></td><td nowrap valign=middle background="<?php 
            echo $imgheadbg;
            ?>
"><b><font color="#ffffff"><?php 
            echo get_plural($classdesc[2]);
            ?>
 under <?php 
            echo $parent->display("nname");
            ?>
 </b> <?php 
            echo $this->print_machine($parent);
            ?>
 <b>  (<?php 
            echo $total_num;
            ?>
)</b></font></td><td><img src="<?php 
            echo $imgheadright;
            ?>
"></td></tr>
            </table>
            </td>
            </tr>

            <tr><td colspan=3><table cellpadding=0 cellspacing=0 border=0 width=100% height=35 background="<?php 
            echo $imgbtnbg;
            ?>
">
            <tr><td><img src="<?php 
            echo $imgbtncrv;
            ?>
"></td><td width=80% align=left > <table width=100% cellpadding=0 cellspacing=0 border=0><tr><td valign=bottom><?php 
            $this->print_list_submit($class, $blist, $unique_name);
            ?>
</td></tr></table></td><td width=15% align=right><b><font color="#ffffff"><?php 
            $this->print_search($parent, $class);
            ?>
</font></b></td></tr>
            </table>
            </td></tr>
    </td></tr><tr><td height=2 colspan=2></td></tr></table>

        <?php 
        } else {
            $descr = $this->getActionDescr($_SERVER['PHP_SELF'], $this->__http_vars, $class, $var, $identity);
            ?>
<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td width=70% valign=bottom><table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td width=100% height=2 background="<?php 
            echo $imgtopline;
            ?>
"></td></tr></table></td><td align=right><table cellpadding=0 cellspacing=0 border=0 width=100% ><tr><td><img src="<?php 
            echo $imgheadleft;
            ?>
"></td><td nowrap width=100% background="<?php 
            echo $imgheadbg;
            ?>
" ><b><font color="#ffffff">  Confirm <?php 
            echo $descr[1];
            ?>
:  </b><?php 
            echo get_plural($classdesc[2]);
            ?>
 from <?php 
            echo $parent->display("nname");
            ?>
</font></td><td><img src="<?php 
            echo $imgheadright;
            ?>
"></td></tr></table></td></tr></table>

    </td></tr><tr><td height=0 colspan=2></td></tr></table>

        <?php 
        }
        ?>

<!--    </td></tr><tr><td height=2 colspan=2></td></tr></table> -->
    <tr><td bgcolor="#ffffff"></td>
 <?php 
        $imguparrow = get_general_image_path() . "/button/uparrow.gif";
        $imgdownarrow = get_general_image_path() . "/button/downarrow.gif";
        foreach ($name_list as $name => $width) {
            $desc = "__desc_{$name}";
            $descr[$name] = get_classvar_description($class, $desc);
            if (!$descr[$name]) {
                print "Cannot access static variable {$class}::{$desc}";
                exit(0);
            }
            if (csa($descr[$name][2], ':')) {
                $_tlist = explode(':', $descr[$name][2]);
                $descr[$name][2] = $_tlist[0];
            }
            foreach ($descr[$name] as &$d) {
                if ($this->is_special_url($d)) {
                    continue;
                }
                if (strstr($d, "%v") !== false) {
                    $d = str_replace("[%v]", $classdesc[2], $d);
                }
            }
            if ($width === "100%") {
                $wrapstr = "wrap";
            } else {
                $wrapstr = "nowrap";
            }
            if ($sortby && $sortby === $name) {
                $wrapstr .= " background={$imgtablerowheadselect}";
                print "<td width={$width} {$wrapstr} ><table cellpadding=0 cellspacing=0 border=0> <tr> <td rowspan=2 {$wrapstr}>";
            } else {
                $wrapstr .= " background={$imgtablerowhead}";
                print "<td width={$width} {$wrapstr} class=col>";
            }
            ?>
        <b><?php 
            $this->print_sortby($parent, $class, $unique_name, $name, $descr[$name]);
            ?>
 </b></font>

        <?php 
            $imgarrow = $sortdir === "desc" ? $imgdownarrow : $imguparrow;
            if ($sortby && $sortby === $name) {
                print "</td> <td width=15><img src=" . $imgarrow . " ></td><td ></td></tr></table>";
            }
            ?>
 </td>

 <?php 
        }
        $count = 0;
        $rowcount = 0;
        ?>
    <td width=10 background=<?php 
        echo $imgtablerowhead;
        ?>
 >   <form name="formselectall<?php 
        echo $unique_name;
        ?>
" value=hello> <input type=checkbox name="selectall<?php 
        echo $unique_name;
        ?>
" value=on <?php 
        if ($sellist) {
            echo "checked disabled";
        }
        ?>
 onclick="javascript:calljselectall<?php 
        echo $unique_name;
        ?>
 ()"></form> </td>
    <?php 
        print "</tr> ";
        print_time('loop');
        $n = 1;
        foreach ((array) $obj_list as $okey => $obj) {
            $checked = '';
            // Fix This.
            if ($sellist) {
                $checked = "checked disabled";
                if (!array_search_bool($obj->nname, $sellist)) {
                    continue;
                }
            }
            $imgpointer = get_general_image_path() . "/button/pointer.gif";
            $imgblank = get_general_image_path() . "/button/blank.gif";
            ?>

        <script> loadImage('<?php 
            echo $imgpointer;
            ?>
') </script>
        <script> loadImage('<?php 
            echo $imgblank;
            ?>
') </script>

            <tr id=tr<?php 
            echo $unique_name . $rowcount;
            ?>
 class=tablerow<?php 
            echo $count;
            ?>
 onmouseover=" swapImage('imgpoint<?php 
            echo $rowcount;
            ?>
','','<?php 
            echo $imgpointer;
            ?>
',1);" onmouseout="swapImgRestore();">
        <td id=td<?php 
            echo $unique_name . $rowcount;
            ?>
 width=5 class=rowpoint><img name=imgpoint<?php 
            echo $rowcount;
            ?>
 src="<?php 
            echo $imgblank;
            ?>
"></td>
        <?php 
            $colcount = 1;
            foreach ($name_list as $name => $width) {
                $this->printObjectElement($parent, $class, $classdesc, $obj, $name, $width, $descr, $colcount . "_" . $rowcount);
                $colcount++;
            }
            $basename = basename($obj->nname);
            $selectshowbase = $this->frm_selectshowbase;
            // issue #609
            //      $ret = strfrom($parent->nname, $selectshowbase);
            $ret = str_replace('//', '/', strfrom($parent->nname, $selectshowbase));
            print " <td width=10 >";
            print "<a class=button href=\"javascript:callSetSelectFolder('/{$ret}/{$basename}')\">";
            print " Select </a>";
            print "</tr> ";
            if ($count === 0) {
                $count = 1;
            } else {
                $count = 0;
            }
            $rowcount++;
            if (!$sellist) {
                if ($n === $pagesize * $cgi_pagenum) {
                    break;
                }
            }
            $n++;
        }
        print_time('loop', "loop{$n}");
        print "<tr><td></td><td colspan={$nlcount}>";
        if (!$rowcount) {
            if ($ghtml->frm_searchstring) {
                ?>
            <table width=95%> <tr align=center> <td width=100%> <b>  No Matches Found  </b> </td> </tr> </table>
            <?php 
            } else {
                ?>
            <table width=95%> <tr align=center> <td width=100%> <b>  No <?php 
                echo get_plural($classdesc[2]);
                ?>
  under <?php 
                echo $parent->nname;
                ?>
   </b> </td> </tr> </table>
            <?php 
            }
        }
        print "</td></tr>";
        print "<tr><td class=rowpoint></td><td colspan=" . $nlcount . " >\n    <table cellpadding=0 cellspacing=0 border=0 width=100%>\n    <tr height=1 style='background:url({$imgtopline})'><td></td></tr>\n    <tr><td>";
        ?>
<script>ckcount<?php 
        echo $unique_name;
        ?>
 = <?php 
        echo $rowcount . ";  ";
        ?>
function calljselectall<?php 
        echo $unique_name;
        ?>
(){
    jselectall(document.formselectall<?php 
        echo $unique_name;
        ?>
.selectall<?php 
        echo $unique_name;
        ?>
,ckcount<?php 
        echo $unique_name;
        ?>
,'<?php 
        echo $unique_name;
        ?>
')
}
</script>


<?php 
        print "<table> <tr> <td >";
        print "<a class=button href=\"javascript:window.close()\"> Cancel </a> &nbsp; &nbsp;  ";
        print "</td> <td width=30> &nbsp; </td> <td >";
        print "</td> </tr> </table> ";
        print "</td></tr></table></tr></table></td> </tr> </table>";
        //else {
        //
        //      $this->print_list_submit($blist);
        //  }
        //print_time("$class.objecttable", "$class.objecttable");
        /// Important. This is to make sure that the session saving etc doesn't take place. We just need a plain and clean window without any saving. If this happens the current url gets added to the sessiona and redirection will screw up.
        exit;
    }
 static function checkIfBaseAddress($name)
 {
     return !csa($name, "-");
 }