Ejemplo n.º 1
0
 function setQuota()
 {
     if (!is_unlimited($this->main->priv->totaldisk_usage)) {
         $disk = $this->main->priv->totaldisk_usage * 1024;
         os_set_quota($this->main->username, $disk);
     } else {
         os_set_quota($this->main->username, 0);
     }
 }
Ejemplo n.º 2
0
 static function addform($parent, $class, $typetd = null)
 {
     $standard_port = array("HTTP:80", "FTP:21", "SSH:22", "SMTP:25", "DNS:53", "POP3:110", "IMAP:143", "Mysql:3306");
     $list = $parent->getList('monitorport');
     foreach ($list as $p) {
         $key = array_search("{$p->portname}:{$p->portnumber}", $standard_port);
         if ($key !== false) {
             unset($standard_port[$key]);
         }
     }
     if ($typetd['val'] === 'standard') {
         $vlist['portnumber'] = array('s', $standard_port);
     } else {
         $vlist['portnumber'] = null;
         $vlist['portname'] = null;
     }
     $clp = $parent->getClientParentO();
     if (!is_unlimited($clp->priv->monitorport_num) && $clp->used->monitorport_num >= $clp->priv->monitorport_num) {
         throw new lxException("mon_port_exceeded", "nname");
     }
     $ret['variable'] = $vlist;
     $ret['action'] = 'add';
     return $ret;
 }
Ejemplo n.º 3
0
 /**
  * Checks if a resource is no limited.
  * 
  * This is a wrapper method for deprecate the global
  * function is_unlimited on lxlib.php
  * 
  * @see $this->isUnlimited() lxlib.php
  * 
  * @author Ángel Guzmán Maeso <*****@*****.**>
  * 
  * @access private
  * @param string $resource The name resource property to check
  * @return boolean True if $resource is 'unlimited' or 'na' string
  */
 private function isUnlimited($resource)
 {
     return is_unlimited($resource);
 }
Ejemplo n.º 4
0
    function xp_panel($object)
    {
        global $gbl, $sgbl, $login, $ghtml;
        $skincolor = $login->getSkinColor();
        $skin_name = basename($login->getSkinDir());
        if (csa($skin_name, "_")) {
            $skin_name = substr($skin_name, 0, strrpos($skin_name, "_"));
        }
        $skin_name = str_replace("_", " ", $skin_name);
        $icon_name = $login->getSpecialObject('sp_specialplay')->icon_name;
        $cl = $login->getResourceChildList();
        $qlist = $object->getList('resource');
        $skinget = $login->getSkinDir();
        ?>
	<script language="javascript" type="text/javascript" src="/htmllib/js/xpmenu/ua.js"></script>
	<script language="javascript" type="text/javascript" src="/htmllib/js/xpmenu/PanelBarOrig.js"></script>
	<script language="javascript" type="text/javascript">
		function drawMenu()
		{
			var iCntr = 0;
			var objMenu;
			var strId, strLbl;
			if (this.open) {
				visib = 'visibile';
				disp = 'block';
				menuclass = "menuHeaderExpanded";
				image = '<?php 
        echo $skinget;
        ?>
/minus.gif';
			} else {
				visib = 'hidden';
				disp = 'none';
				menuclass = "menuHeaderCollapsed";
				image = '<?php 
        echo $skinget;
        ?>
/plus.gif';
			}

			document.write("<table  border=\"0\" cellspacing=\"0\"" + " cellpadding=\"0\" style=\"padding:0 0 0 0;\" width=\"100%\">");
			document.write("<tr style=\"background:url('<?php 
        echo $skinget;
        ?>
/expand.gif')\" onMouseover=\"this.style.background='url(<?php 
        echo $skinget;
        ?>
/onexpand.gif)'\" onMouseout=\"this.style.background='url(<?php 
        echo $skinget;
        ?>
/expand.gif)'\"><td style=\"width:180px;vertical-align: center; \"><font style='font-weight:bold'>&nbsp;" + this.label + "</font></td><td class=" + menuclass + " id=\"" + this.id + "\"" + "onclick=\"toggle(this)\">");
			document.write("&nbsp;<img id=" + this.id + "_image src=" + image + "></td></tr>");
			document.write("</table>");
			document.write("<div style=\"display: " + disp + "; visibility: " + visib + ";\"" + " class=\"menuItems\" id=\"" + this.id + "_child" + "\">");
			document.write("<table border=0 style='background:white' border=0 cellspacing=1 cellpadding=0 width=100%>");
			for (iCntr = 0; iCntr < this.smcount; iCntr++) {
				this.submenu[iCntr].render();
			}
			document.write("</table></div>");
		}
		function toggle(pobjSrc)
		{
			var strCls = pobjSrc.className;
			var strId = pobjSrc.id;
			var objTmp, child;

			if (pobjSrc.id != _currMenu) {
				objTmp = document.getElementById(_currMenu);
			}

			child = document.getElementById(strId + "_child");
			ichild = document.getElementById(strId + "_image");
			if (child.style.visibility == "hidden") {
				pobjSrc.className = "menuHeaderExpanded";
				child.style.visibility = "visible";
				child.style.display = "block";
				ichild.src = "<?php 
        echo $skinget;
        ?>
/minus.gif";
			} else {
				pobjSrc.className = "menuHeaderCollapsed";
				child.style.visibility = "hidden";
				child.style.display = "none";
				ichild.src = "<?php 
        echo $skinget;
        ?>
/plus.gif";
			}
			_currMenu = pobjSrc.id;
		}

	</script>

	<script language="javascript">
		var objTmp;
			<?php 
        if (!$login->getSpecialObject('sp_specialplay')->isOn('disable_quickaction')) {
            $class = $login->getQuickClass();
            if ($class) {
                print "xpreso = createMenu('Quick Actions', '', true);";
                $rdesc = print_quick_action($class);
                print "createSubMenu(xpreso, '{$rdesc}', '', '', '', '', '');\n";
            }
        }
        $url = $this->getFullUrl("a=list&c=ndskshortcut");
        print "xxpFav = createMenu('<font color=#003360>Favorites<a href=\"{$url}\" target=mainframe>  [edit] </a>', '', true);";
        $rdesc = print_favorites();
        print "createSubMenu(xxpFav, '{$rdesc}', '', '', '', '', '');\n";
        if ($login->isLte('reseller')) {
            print "xxpDescr = createMenu('<font color=#003360>Usage', '', true);";
            $rdesc = null;
            foreach ((array) $qlist as $or) {
                if (!cse($or->vv, "usage") && !cse($or->vv, "_num")) {
                    continue;
                }
                if (cse($or->vv, "last_usage")) {
                    continue;
                }
                if (is_unlimited($or->resourcepriv)) {
                    $limit = "&#8734;";
                } else {
                    $limit = $or->display('resourcepriv');
                }
                $array = array("traffic_usage", "totaldisk_usage", "client_num", "maindomain_num", "vps_num");
                if (!array_search_bool($or->vv, $array)) {
                    continue;
                }
                $rdesc .= "<tr align=left style=\"border-width:1 ;background:url({$skinget}/a.gif)\" > <td > <img width=15 height=15 src=/img/image/collage/button/state_v_{$or->display('state')}.gif> {$or->shortdescr} </td> <td nowrap> {$or->display('resourceused')} </td> <td align=left> {$limit}&nbsp;</td> </tr>";
            }
            print "createSubMenu(xxpDescr, '{$rdesc}', '', '', '', '', '');\n";
        }
        $forumurl = "http://forum.lxcenter.org";
        if (!$login->isAdmin() && isset($login->getObject('general')->generalmisc_b->forumurl)) {
            $forumurl = $login->getObject('general')->generalmisc_b->forumurl;
        }
        ?>

		setTheme("XPClassic.css", null, null);
		initialize(<?php 
        echo $sgbl->__var_lpanelwidth - 20;
        ?>
);

	</script>


			<?php 
    }
Ejemplo n.º 5
0
 function createShowAlist(&$alist, $subaction = null)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $alist['__title_administer'] = $login->getKeywordUc('administration');
     // Very special case, when he is a customer without any add vps flag, then there are no top row buttons at all.
     if ($this->isAdmin()) {
         $alist[] = "a=list&c=actionlog";
     }
     if ($this->isLogin() && $login->isAuxiliary()) {
         $alist['__v_dialog_pas'] = "******";
     } else {
         $alist['__v_dialog_apas'] = "******";
     }
     $alist['__v_dialog_info'] = "a=updateForm&sa=information";
     if ($this->isAdmin()) {
         $alist[] = 'o=lxupdate&a=show';
     }
     if (!$this->isAuxiliary()) {
         $alist[] = "a=list&c=blockedip";
     }
     if ($this->isAdmin()) {
         $alist[] = "a=list&c=auxiliary";
     }
     if ($this->isAdmin()) {
         $alist[] = "a=list&c=custombutton";
     }
     if ($this->isAdmin()) {
         //$turl = "a=show&l[class]=ffile&l[nname]=xentemplate";
         $turl = "n=xenostemplate&a=show&l[class]=ffile&l[nname]=/";
         $alist[] = create_simpleObject(array('url' => "{$turl}", 'purl' => "a=updateform&sa=xentemplate", 'target' => "", '__internal' => true));
         $turl = "n=openvzostemplate&a=show&l[class]=ffile&l[nname]=/";
         $alist[] = create_simpleObject(array('url' => "{$turl}", 'purl' => "a=updateform&sa=openvztemplate", 'target' => "", '__internal' => true));
     }
     if (!$this->isLogin()) {
         $alist[] = "a=update&sa=dologin";
     }
     $alist[] = "a=list&c=emailalert";
     if ($this->canSeePserver()) {
         $alist[] = "a=list&c=pserver";
     }
     if (!$this->isAdmin()) {
         $alist[] = "a=updateForm&sa=pserver";
     }
     if ($this->isAdmin() && !$this->isAuxiliary()) {
         $alist[] = "a=list&c=datacenter";
         $alist[] = "a=list&c=centralbackupserver";
         $alist[] = "a=list&c=sslcert";
     }
     if (!$this->isLogin()) {
         $alist['__v_dialog_limit'] = "a=updateForm&sa=limit";
         $alist['__v_dialog_plan'] = "a=updateForm&sa=change_plan";
     }
     $alist['__title_virtual'] = $login->getKeywordUc('resource');
     if ($this->isAdmin()) {
         $alist[] = "a=list&c=ippool";
     }
     if ($this->priv->isOn('vps_add_flag')) {
         $this->getListActions($alist, 'resourceplan');
         //$this->getListActions($alist, 'clienttemplate');
         //$this->getListActions($alist, 'vpstemplate');
     }
     $alist[] = "a=list&c=vps";
     $alist[] = "a=list&c=all_vps";
     if (!$this->isCustomer()) {
         $this->getListActions($alist, 'client');
     }
     if ($this->isAdmin()) {
         //$alist[] = "a=updateform&sa=multivpscreate";
         $revc = $login->getObject('general')->reversedns_b;
         if ($revc && $revc->isOn('enableflag')) {
             $alist[] = "a=list&c=reversedns";
         }
         $alist[] = "a=list&c=all_dns";
     }
     if (!$this->isLogin()) {
         //Both wall and message not done through message board.
         //$alist[] = 'a=updateForm&sa=message';
     }
     // Client Traffic history. Doesn't know if I should add the history of HIS clients too, or just use the traffic for the domains under him. So hashing for the present.
     //$alist[] = 'a=list&c=domaintraffichistory';
     $alist['__title_misc'] = $login->getKeywordUc('help');
     $this->getListActions($alist, 'utmp');
     $this->getTicketMessageUrl($alist);
     //$this->getLxclientActions($alist);
     if (!$this->isLogin() && !$this->isLteAdmin() && csb($this->nname, "demo_")) {
         $alist[] = "o=sp_specialplay&a=updateform&sa=demo_status";
     }
     if ($this->isAdmin()) {
         //$alist[] = "a=list&c=blockedip";
         //$alist[] = "o=general&a=updateForm&sa=attempts";
         //$alist[] = "a=list&c=module";
     } else {
     }
     if ($this->isAdmin()) {
         $alist[] = "a=list&c=monitorserver";
     } else {
         if (is_unlimited($this->priv->monitorport_num) || $this->priv->monitorport_num > 0) {
             $alist[] = "a=list&c=monitorserver";
         }
     }
     if ($this->isAdmin()) {
         $so = $this->getFromList('pserver', 'localhost');
         $this->getAlistFromChild($so, $alist);
     }
     $alist['__title_advanced'] = $login->getKeywordUc('advanced');
     if ($this->isAdmin()) {
         //$alist['__v_dialog_tick'] = "a=updateform&sa=ticketconfig&o=ticketconfig";
         //$alist[] = "o=general&c=helpdeskcategory_a&a=list";
         $alist['__v_dialog_sca'] = "o=general&a=updateform&sa=scavengetime";
         $alist['__v_dialog_gen'] = "o=general&a=updateform&sa=generalsetting";
         $alist['__v_dialog_main'] = "o=general&a=updateform&sa=maintenance";
         $alist['__v_dialog_self'] = "o=general&a=updateform&sa=selfbackupconfig";
         //$alist['__v_dialog_ssh'] = "o=general&a=updateform&sa=ssh_config";
         //$alist['__v_dialog_ipcheck'] = "o=general&a=updateform&sa=session_config";
         $alist['__v_dialog_download'] = "o=general&a=updateform&sa=download_config";
         $alist['__v_dialog_forc'] = "a=updateform&sa=forcedeletepserver";
         $alist['__v_dialog_hack'] = "o=general&a=updateform&sa=hackbuttonconfig";
         $alist['__v_dialog_rev'] = "o=general&a=updateform&sa=reversedns";
         $alist['__v_dialog_cust'] = "o=general&a=updateform&sa=customaction";
         $alist['__v_dialog_orph'] = "a=updateform&sa=deleteorphanedvps";
         $alist['__v_dialog_lxc'] = "o=general&a=updateform&sa=kloxo_config";
         //$alist[] = "a=show&o=ostemplatelist";
         $alist[] = "a=list&c=customaction";
     }
     if (!$this->isAdmin()) {
         $alist[] = "a=updateform&sa=ostemplatelist";
     }
     if ($this->canHaveChild()) {
         $alist['__v_dialog_ch'] = "o=sp_childspecialplay&a=updateform&sa=skin";
     }
     $alist['__v_dialog_not'] = "a=updateform&sa=update&o=notification";
     $alist['__v_dialog_misc'] = "a=updateform&sa=miscinfo";
     if ($this->isAdmin()) {
         $alist[] = "o=general&a=updateform&sa=portconfig";
     }
     if (!$this->isLogin() && !$this->isLteAdmin() && csb($this->nname, "demo_")) {
         $alist['__v_dialog_demo'] = "o=sp_specialplay&a=updateform&sa=demo_status";
     }
     if (!$this->isLogin()) {
         $alist['__v_dialog_disa'] = "a=updateform&sa=disable_per";
     }
     if ($login->priv->isOn('logo_manage_flag') && $this->isLogin()) {
         $alist['__v_dialog_uplo'] = "o=sp_specialplay&a=updateForm&sa=upload_logo";
     }
     if (!$this->isLogin()) {
         $alist['__v_dialog_resend'] = "a=updateform&sa=resendwelcome";
     }
     if (!$this->isLogin()) {
         $alist[] = "a=updateForm&sa=changeowner";
     }
     if ($this->isLogin()) {
         $alist['__v_dialog_login'] = "******";
     }
     if ($this->isAdmin()) {
         $alist[] = "a=updateform&sa=license&o=license";
     }
     $this->getCustomButton($alist);
     return $alist;
 }
Ejemplo n.º 6
0
function isQuotaGreaterThan($used, $priv)
{
    if (is_unlimited($priv)) {
        return false;
    }
    if (is_unlimited($used)) {
        return true;
    }
    if (isOn($priv)) {
        return false;
    }
    if (isOn($used)) {
        return true;
    }
    return $used > $priv ? true : false;
}
Ejemplo n.º 7
0
 function getAnyErrorMessage()
 {
     global $gbl, $sgbl, $login, $ghtml;
     if ($sgbl->isKloxo() && $this->isAdmin()) {
         if (!is_unlimited($this->priv->maindomain_num) && $this->priv->maindomain_num - $this->used->maindomain_num < 6) {
             $ghtml->__http_vars['frm_smessage'] = 'warn_license_limit';
             $ghtml->__http_vars['frm_m_smessage_data'] = 'maindomain_num';
         }
     }
     if ($this->isAdmin()) {
         $v = db_get_value("sshconfig", "localhost", "without_password_flag");
         $vv = db_get_value("sshconfig", "localhost", "config_flag");
         $this->__t_check_var = $v;
         $this->__t_check_vvar = $vv;
         if (!$this->isOn('__t_check_var') && !$this->isOn('__t_check_vvar')) {
             //$ghtml->__http_vars['frm_emessage'] = "ssh_root_password_access";
         }
         if ($sgbl->isKloxo()) {
             $v = db_get_value("servermail", "localhost", "myname");
             if ($sgbl->isKloxo() && !$v) {
                 $ghtml->__http_vars['frm_emessage'] = "mail_server_name_not_set";
             }
         }
         if (!$gbl->getSessionV('__v_error_not_first_time')) {
             $v = db_get_value("lxguard", "localhost", "configure_flag");
             $this->__t_check_var = $v;
             if (!$this->isOn('__t_check_var')) {
                 $ghtml->__http_vars['frm_emessage'] = "lxguard_not_configured";
             }
         }
     }
     parent::getAnyErrorMessage();
     $gbl->setSessionV('__v_error_not_first_time', 1);
 }
Ejemplo n.º 8
0
 function collectVariableQuota($vlist)
 {
     static $count = 0;
     global $gbl, $sgbl, $login, $ghtml;
     $count++;
     foreach ($vlist as $var => $val) {
         $fv[$var] = 0;
         $func = "getQuota{$var}";
         $tvv = "__var_{$var}";
         if ($this->isHardQuota($var)) {
             $fv[$var] = $this->priv->{$var};
         } else {
             if ($this->isRealQuotaVariable($var)) {
                 if (isset($sgbl->{$tvv})) {
                     dprint("{$tvv}\n");
                     $qq = $sgbl->{$tvv};
                     $fv[$var] = $qq[$this->getClName()];
                 } else {
                     $fv[$var] = $this->used->{$var};
                 }
             }
         }
     }
     $cnlist = $this->getQuotaChildList();
     $totalchildlist = $this->getChildList();
     //dprintr($cnlist);
     foreach ($vlist as $var => $val) {
         if (!$this->isQuotaVariable($var)) {
             continue;
         }
         if (cse($var, "_a_num")) {
             $cvar = strtil($var, "_num");
             $listvar = $cvar;
             if (array_search_bool($listvar, $totalchildlist)) {
                 $childlist = $this->{$cvar};
                 $num = count($childlist);
                 $fv[$var] = $num;
             }
         } else {
             if (cse($var, "_num")) {
                 $cvar = strtil($var, "_num");
                 $listvar = $cvar . "_l";
                 //dprint(" before {$this->nname} {$var} \n");
                 if (array_search_bool($listvar, $totalchildlist)) {
                     $childlist = $this->getList($cvar);
                     if (!$this->isVirtual($cvar)) {
                         $num = $this->countRightParent($childlist);
                         //dprint(" {$this->nname}  {$var}  {$num} \n");
                         $fv[$var] = $num;
                     }
                 }
             }
         }
     }
     foreach ((array) $cnlist as $c) {
         if (cse($c, "_o")) {
             $name = $this->getChildNameFromDes($c);
             $ob = null;
             if ($this->isRealChild($name)) {
                 $ob = $this->getObject($name);
             }
             if ($ob) {
                 $res = $ob->collectVariableQuota($vlist);
                 foreach ($res as $var => $v) {
                     $fv[$var] += $v;
                 }
             }
         } else {
             if (cse($c, "_l")) {
                 $name = $this->getChildNameFromDes($c);
                 $list = $this->getList($name);
                 if (!$this->isVirtual($name)) {
                     foreach ((array) $list as $l) {
                         $res = $l->collectVariableQuota($vlist);
                         foreach ($res as $var => $v) {
                             if (cse($var, "_flag")) {
                                 continue;
                             }
                             //dprint("Collected  {$this->nname}   {$var}  {$v} \n");
                             $fv[$var] += $v;
                         }
                     }
                 }
             }
         }
     }
     foreach ($vlist as $var => $val) {
         $list = $this->getQuotaAddList($var);
         dprintr($list);
         if (!$list) {
             continue;
         }
         $fv[$var] = 0;
         foreach ($list as $k => $v) {
             $fv[$var] += $fv[$v];
         }
     }
     if ($this->isClass('domaina') && $this->nname === 'boxtrapper.com') {
         //dprintr($fv);
     }
     $rexceeded = false;
     foreach ($fv as $var => $v) {
         if ($this->isdeadQuotaVariable($var)) {
             print "Dead Quota: In {$this->getClName()} {$var} equals {$v}\n";
             if ($this->used->{$var} !== $v) {
                 $this->used->{$var} = $v;
                 $this->setUpdateSubaction('collectquotaupdate');
             }
             continue;
         }
         if (!$this->isQuotaVariable($var)) {
             continue;
         }
         /* never Happens. Only Priv is no checked for flag...
         		if (cse($var, "_flag")) {
         			// Thi is also done in distributeChildQuota.
         			if (!$this->priv->isOn($var) && $this->used->isOn($var)) {
         				print("In {$this->nname} {$var} is enabled and limit is disabled , Disabling.\n");
         				$this->used->$var = 'off';
         				$this->setUpdateSubaction("enable_{$var}");
         			}
         			continue;
         		}
         	*/
         print "In {$this->getClName()} {$var} equals {$v} and limit is {$this->priv->{$var}}\n";
         if ($this->used->{$var} != $v) {
             $this->used->{$var} = $v;
             $this->setUpdateSubaction('collectquotaupdate');
         }
         if ($this->isLxclient() && !$this->isHardQuota($var) && !is_unlimited($this->priv->{$var}) && cse($var, "_usage")) {
             $per = $this->used->{$var} / $this->priv->{$var};
             $per *= 100;
             if (cse($var, "_num")) {
                 $exce = 100;
             } else {
                 $exce = 95;
             }
             //dprint("In {$this->nname} per is {$per}... {$general->dpercentage}\n");
             if ($per > $exce) {
                 $this->state = 'exceed';
                 $per = round($per);
                 if (!$sgbl->__var_just_db) {
                     $msg = "Warning: The Account {$this->nname} is using {$per}% of quota for {$var}.\n Limit: {$this->priv->{$var}}\nUsed: {$this->used->{$var}}\n";
                     $this->notifyAll($msg, false);
                 }
             }
             if ($this->disable_per && !$this->isOff('disable_per') && $per > $this->disable_per) {
                 dprint("In {$this->nname} {$var} rexceeded... \n");
                 $rexceeded = true;
             }
         }
     }
     if ($rexceeded) {
         // Updatedisable will disable only if itsn't already disabled. Thus it will avoid unnecessary synctosystems.
         $this->updateDisable(null, 'quota');
         $msg = "The Account {$this->nname} has been disabled due to overquota";
         if (!$sgbl->__var_just_db) {
             $this->notifyAll($msg);
         }
         print "{$msg}\n";
     } else {
         $this->state = 'ok';
         $this->updateEnable(null, 'quota');
     }
     return $fv;
 }
Ejemplo n.º 9
0
 function enablePhp()
 {
     global $gbl, $sgbl, $login, $ghtml;
     $string = null;
     if (!$this->main->priv->isOn('php_flag')) {
         return null;
     }
     if ($this->isRailsDocroot()) {
         return;
     }
     $fcgi_proc = 1;
     if ($this->main->priv->phpfcgiprocess_num > 0) {
         $fcgi_proc = $this->main->priv->phpfcgiprocess_num;
     }
     if (is_unlimited($this->main->priv->phpfcgiprocess_num)) {
         $fcgi_proc = "1";
     }
     if ($this->main->isOn('fcgi_children')) {
         $maxprocstring = "\t\t\"max-procs\" => 1,\n";
         $fcgichildstring = "\t\t\t\"PHP_FCGI_CHILDREN\" => \"{$fcgi_proc}\",\n";
     } else {
         $maxprocstring = "\t\t\"max-procs\" => {$fcgi_proc},\n";
         $fcgichildstring = "\t\t\t\"PHP_FCGI_CHILDREN\" => \"0\",\n";
     }
     $phprc = null;
     lxfile_unix_chown("/home/httpd/{$this->main->nname}", "{$this->main->username}:apache");
     lxfile_unix_chmod("/home/httpd/{$this->main->nname}", "0775");
     if (!lxfile_exists("/home/httpd/{$this->main->nname}/php.ini")) {
         lxfile_cp("/etc/php.ini", "/home/httpd/{$this->main->nname}/php.ini");
     }
     $phprc = "\t\t\t\"PHPRC\" => \"/home/httpd/{$this->main->nname}\",\n";
     if (!lxfile_exists("/var/tmp/lighttpd")) {
         lxfile_mkdir("/var/tmp/lighttpd");
         lxfile_unix_chown("/var/tmp/lighttpd", "apache:apache");
         lxfile_unix_chmod("/var/tmp/lighttpd", "0770");
     }
     // --- for 'disable' client
     if (!$this->main->isOn('status')) {
         $string .= "\tcgi.assign = ( \".php\" => \"/home/httpd/nobody.sh\" )\n\n";
         return $string;
     }
     if ($this->main->priv->isOn('phpfcgi_flag')) {
         $uid = os_get_uid_from_user($this->main->username);
         $gid = os_get_gid_from_user($this->main->username);
         $string .= "\tfastcgi.server = ( \".php\" => ";
         $string .= "(( \"socket\" => \"/var/tmp/lighttpd/php.socket.{$this->main->nname}.\" + var.PID,\n";
         $string .= "\t\t\"bin-path\" => \"/usr/bin/lxsuexec\",\n";
         $string .= "\t\t\"min-procs\" => 0,\n";
         $string .= $maxprocstring;
         $string .= "\t\t\"bin-environment\" => (\n";
         $string .= "\t\t\t\"MUID\" => \"{$uid}\",\n";
         $string .= "\t\t\t\"GID\" => \"{$gid}\",\n";
         $string .= $phprc;
         $string .= "\t\t\t\"TARGET\" => \"/usr/bin/php-cgi\",\n";
         $string .= "\t\t\t\"NON_RESIDENT\" => \"0\",\n";
         $string .= $fcgichildstring;
         $string .= "\t\t\t\"PHP_FCGI_MAX_REQUESTS\" => \"100000000\" ),\n";
         $string .= "\t\t\"max-load-per-proc\" => 1000,\n";
         $string .= "\t\t\"idle-timeout\" => 3 ";
         $string .= "))\n";
         $string .= "\t)\n\n";
     } else {
         $string .= "\tcgi.assign = ( \".php\" => \"/home/httpd/{$this->main->nname}/phpsuexec.sh\", \n";
         $string .= "\t\t\".pl\" => \"/home/httpd/{$this->main->nname}/perlsuexec.sh\" )\n\n";
     }
     return $string;
 }
Ejemplo n.º 10
0
 function createShowAlist(&$alist, $subaction = null)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $revc = $login->getObject('general')->reversedns_b;
     $hackbutton = $login->getObject('general')->hackbuttonconfig_b;
     static $status;
     static $reason;
     if (isUpdating()) {
         $ghtml->print_redirect_back('system_is_updating_itself', '');
     }
     if ($ghtml->frm_action === 'show') {
     } else {
         $status = $this->status;
     }
     $this->setIId();
     if (!$status) {
         try {
             $status = $this->getStatusForThis();
             dprint($status);
         } catch (Exception $e) {
             if (if_demo()) {
                 $status = 'on';
             } else {
                 print "Could not get Status: Reason: {$e->getMessage()}";
                 exit;
             }
         }
     }
     if (csa($status, ":")) {
         $st = explode(":", $status);
         $status = array_shift($st);
         $reason = implode(" ", $st);
         $reason = str_replace("\n", " ", $reason);
     }
     if ($status !== $this->status) {
         dprint("Status in Db not the same as Status of the system, resetting db");
         $this->status = $status;
         $this->setUpdateSubaction();
     }
     if ($this->status === 'create') {
         $alist['__v_message'] = "<b> VM is being Created... Please Wait.. </b> \n";
         $alist['__v_refresh'] = true;
         return;
     }
     if ($this->status === 'createfailed') {
         $alist['__v_message'] = "<b> VM creation has failed. Reason: {$reason} </b>\n";
         $alist['__v_refresh'] = true;
         return;
     }
     if ($this->checkIfLockedForAction('restore')) {
         $alist['__v_message'] = 'The VM is getting restored, please wait...';
         $alist['__v_refresh'] = true;
         return $alist;
     }
     if ($this->checkIfLockedForAction('rebuild')) {
         $alist['__v_message'] = 'The VM is getting rebuilt, please wait...';
         $alist['__v_refresh'] = true;
         return $alist;
     }
     if ($this->checkIfLockedForAction('switchserver')) {
         $alist['__v_message'] = 'The VM is being migrated, please wait...';
         $alist['__v_refresh'] = true;
         return $alist;
     }
     if ($this->checkIfLockedForAction('livemigrate')) {
         $alist['__v_message'] = 'The VPS is being Migrated Live. The CP is inactive, but your VPS is running Normally.';
         $alist['__v_refresh'] = true;
         return $alist;
     }
     if ($this->status === 'deleted') {
         $alist['__v_message'] = "The VM {$this->getIid}() Doesn't Exist on {$this->syncserver}. If you have migrated the vps, you can manually change the server in the database using the below, Or restore from backup. </b>";
         $alist['__v_refresh'] = true;
         $alist['__title_main'] = $login->getKeywordUc('resource');
         $alist['__v_dialog_csync'] = "a=updateform&sa=changesyncserver";
         $alist['__var_backup_flag'] = "a=show&o=lxbackup";
         $alist[] = "a=updateform&sa=rebuild";
         return null;
     }
     /*
     	if ($this->getObject('lxbackup')->backupstage === 'doing') { 
     		$alist['__v_message'] = 'The VM is getting backed up, please wait...';
     		$alist['__v_refresh'] = true;
     		return $alist;
     	}
     */
     $this->makeSureTheUserExists();
     $this->makeSureTheMacAddressExists();
     $this->makeSureVifExists();
     if ($subaction === 'config') {
         return $this->createShowAlistConfig($alist);
     }
     if ($subaction === 'graph') {
         $alist['__title_graph'] = $login->getKeywordUc('graph');
         return $alist;
     }
     $alist['__title_administer'] = $login->getKeywordUc('administration');
     if ($this->getParentO()->isClass('client')) {
         if (!$this->isLogin()) {
             if ($login->priv->isOn('vps_limit_flag')) {
                 $alist['__v_dialog_limit'] = "a=updateForm&sa=limit";
                 $alist['__v_dialog_plan'] = "a=updateForm&sa=change_plan";
             }
         }
     }
     $alist['__v_dialog_info'] = "a=updateForm&sa=information";
     $alist['__v_dialog_pass'] = "******";
     if (!$this->isWindows()) {
         //$alist[] = "a=show&n=browsebackup&l[class]=ffile&l[nname]=/";
         $bslave = $this->getBackupServer();
         if (!is_disabled_or_null($bslave) && $this->priv->isOn('centralbackup_flag')) {
             $alist[] = "a=show&n=browsebackup";
         }
     }
     if (!$this->isLogin()) {
         $alist[] = "a=update&sa=dologin";
     }
     $alist['__title_console'] = $login->getKeywordUc('console');
     //$alist[] = "a=show&o=sshclient";
     if ($this->isWindows()) {
         $alist[] = "a=show&o=vncviewer";
     } else {
         $alist[] = "a=show&o=consolessh";
         $alist[] = "a=list&c=sshauthorizedkey";
     }
     if (!$this->isXen()) {
         $alist[] = "a=updateform&sa=commandcenter";
     }
     $alist[] = "a=list&c=blockedip";
     $alist['__v_dialog_netw'] = "a=updateform&sa=network";
     $alist[] = "a=list&c=traceroute";
     if (!$this->isWindows()) {
         $alist['__v_dialog_main'] = "a=updateform&sa=mainipaddress";
     }
     if (!$this->isXen()) {
         $alist['__v_dialog_fixdev'] = "a=updateform&sa=fixdev";
     }
     if ($hackbutton && $hackbutton->isOn('nobackup') && !$this->isWindows()) {
         vps::$__desc_backup_num = array("", "", "backup:number_of_backups", "number_of_backups");
     } else {
         if ($this->priv->isOn('backup_flag')) {
             $alist[] = "a=show&o=lxbackup";
         }
     }
     if ($login->isAdmin()) {
         $alist['__title_action'] = $login->getKeywordUc('action');
     }
     if ($login->priv->isOn("rebuildvps_flag")) {
         $alist['__v_dialog_rebuild'] = "a=updateform&sa=rebuild";
     }
     if (!$this->isWindows()) {
         $alist[] = "a=updateform&sa=recovervps";
     }
     if (!$this->isWindows()) {
         if ($login->isAdmin()) {
             $alist['__v_dialog_sw'] = "a=updateform&sa=switchserver";
         }
         if ($login->isAdmin() && !$this->isXen()) {
             $alist['__v_dialog_live'] = "a=updateform&sa=livemigrate";
         }
     }
     if ($login->isAdmin()) {
         $alist['__v_dialog_tem'] = "a=updateform&sa=createtemplate";
         $alist['__v_dialog_clone'] = "a=updateform&sa=clonevps";
     }
     if (!$this->isWindows()) {
         $alist['__title_resource'] = $login->getKeywordUc('resource');
     }
     if (!$this->isLogin() && $login->priv->isOn('ip_manage_flag')) {
         $alist[] = "a=list&c=vmipaddress_a";
     }
     if (!$this->isWindows()) {
         $alist['__v_dialog_root'] = "a=updateform&sa=rootpassword";
         $alist[] = "a=show&l[class]=ffile&l[nname]=/";
         $alist['__v_dialog_time'] = "a=updateform&sa=timezone";
         if ($this->isOn('kloxo_flag') && $login->priv->isOn('rebuildvps_flag')) {
             $alist['__v_dialog_inst'] = "a=updateform&sa=installkloxo";
         }
     }
     $alist['__title_power'] = $login->getKeywordUc('power');
     $alist[] = "a=update&sa=boot";
     $alist[] = "a=update&sa=poweroff";
     $alist[] = "a=update&sa=reboot";
     if ($this->isXen()) {
         $alist[] = "a=updateform&sa=mount";
     }
     if ($this->isXen()) {
         $alist[] = "a=updateform&sa=hardpoweroff";
     }
     $alist[] = "a=list&c=emailalert";
     if (!$this->isXen()) {
         $alist[] = "a=list&c=openvzqos";
     }
     //$this->getLxclientActions($alist);
     /*
     if ($this->priv->isOn('backup_flag')) {
     	$alist[] = "a=show&o=lxbackup";
     }
     */
     $alist['__title_misc'] = "Extra";
     $this->getListActions($alist, 'vpstraffichistory');
     $this->getListActions($alist, 'utmp');
     $this->getTicketMessageUrl($alist);
     if ($hackbutton && $hackbutton->isOn('nomonitor')) {
     } else {
         if (is_unlimited($this->priv->monitorport_num) || $this->priv->monitorport_num) {
             $alist[] = "a=list&c=monitorserver";
         }
     }
     if ($this->priv->isOn('managereversedns_flag')) {
         if ($revc && $revc->isOn('enableflag')) {
             $alist[] = "a=list&c=reversedns";
         }
     }
     if ($this->priv->isOn('managedns_flag')) {
         if ($revc && $revc->isOn('forwardenableflag')) {
             $alist[] = "a=list&c=dns";
         }
     }
     $alist['__title_advanced'] = "Advanced";
     if (!$this->isLogin()) {
         $alist[] = "a=updateform&sa=disable_per";
     }
     if ($login->isAdmin() && !$this->isXen()) {
         $alist[] = "a=updateForm&sa=changenname";
     }
     if (!$this->isLogin()) {
         $alist[] = "a=updateform&sa=resendwelcome";
     }
     if ($login->isAdmin()) {
         $alist[] = "a=updateForm&sa=changelocation";
         $alist[] = "a=updateform&sa=createuser";
     }
     if ($this->isXen() && !$this->isLogin()) {
         $alist[] = "a=updateform&sa=append_xen_config";
     }
     $alist[] = "a=updateform&sa=append_inittab";
     if ($login->isAdmin()) {
         $alist[] = "a=updateform&sa=ostemplatelist";
     }
     //if ($this->isXen() && $this->ostemplate === 'unknown') {
     if ($this->isXen() && $login->isAdmin()) {
         $alist[] = "a=updateForm&sa=changeosimagename";
     }
     if (!$this->isLogin()) {
         if ($login->isNotCustomer()) {
             // Disabling change owner for the present.
             $alist[] = "a=updateForm&sa=changeowner";
         }
     }
     if ($this->isXen()) {
         $alist[] = "a=updateform&sa=macaddress";
     }
     $alist[] = "a=show&o=notification";
     $alist[] = "a=updateform&sa=miscinfo";
     if ($this->isLogin()) {
         $alist[] = "o=sp_specialplay&a=updateform&sa=login_options";
     }
     $this->getCustomButton($alist);
     return $alist;
 }
Ejemplo n.º 11
0
function check_priv($parent, $class, $pvar, $v)
{
    if (cse($class, "template")) {
        foreach ($v as $pk => $pv) {
            $pvar->{$pk} = $pv;
        }
        return;
    }
    $parent = $parent->getClientParentO();
    foreach ($v as $pk => $pv) {
        if (cse($pk, "_time")) {
            $pvar->{$pk} = $pv;
            continue;
        }
        if (!$parent->isQuotaVariable($pk) && !$parent->isDeadQuotaVariable($pk)) {
            continue;
        }
        if (cse($pk, "_flag")) {
            if ($parent->priv->isOn($pk)) {
                $pvar->{$pk} = $pv;
                continue;
            }
            if (isOn($pv)) {
                throw new lxException("Parent Doesnt Have Permission for {$pk}", "frm_{$class}_c_priv_s_{$pk}", null);
            }
            $pvar->{$pk} = $pv;
            continue;
        }
        if (cse($pk, "_num") || cse($pk, "_usage")) {
            $tmp = $pv;
            if ($tmp < 0) {
                throw new lxException('has_to_be_greater_than_zero', "priv_s_{$pk}");
            }
            if (is_unlimited($parent->priv->{$pk})) {
                if (isHardQuotaVariableInClass($class, $pk)) {
                    $parent->used->{$pk} -= $pvar->{$pk};
                    $parent->used->{$pk} += $pv;
                    $parent->setUpdateSubaction();
                }
                $pvar->{$pk} = $pv;
                continue;
            }
            if (is_unlimited($pv)) {
                $desc = getNthToken(get_v_descr($parent, $pk), 2);
                if (!$desc) {
                    $desc = $pk;
                }
                throw new lxException("quota_exceeded", "priv_s_{$pk}", $desc);
            }
            if (isHardQuotaVariableInClass($class, $pk)) {
                $parent->used->{$pk} -= $pvar->{$pk};
            }
            dprintr($parent->used);
            if ($tmp > $parent->getEffectivePriv($pk, $class)) {
                dprint("After throw");
                $desc = getNthToken(get_v_descr($parent, $pk), 1);
                if (!$desc) {
                    $desc = $pk;
                }
                throw new lxException("quota_exceeded", "priv_s_{$pk}", $desc);
            }
            dprint("No throw.. {$tmp} <br> ");
            if (isHardQuotaVariableInClass($class, $pk)) {
                $parent->used->{$pk} += $pv;
                $parent->setUpdateSubaction();
            }
            $pvar->{$pk} = $pv;
        }
    }
}
Ejemplo n.º 12
0
 function syncNewquota()
 {
     if (!is_unlimited($this->main->priv->disk_usage)) {
         lxshell_return("setquota", "-ur", "-F", "vfsv0", $this->main->nname, "0", $this->main->priv->disk_usage, "200", "0", "0", "-a", "ext3");
     }
 }
Ejemplo n.º 13
0
 static function privdisplay($name, $var, $value)
 {
     // We have to divide by 1024 * 1024 because prividsplay deals in MBs while we have got bytes.
     if ($name === 'sizeper') {
         $value = round($value / (1024 * 1024), 2);
     }
     if (array_search_bool($name, array('sizeper', 'disk_usage', "maildisk_usage", "memory_usage", "backup_num", "traffic_usage", "traffic_last_usage", "swap_usage", "guarmem_usage", "realmem_usage", "disk", "lvm", "mysqldb_usage", "clientdisk_usage", "totaldisk_usage"))) {
         if ($value === '-' || is_unlimited($value)) {
             return $value;
         }
         return getGBOrMB($value);
     }
     return $value;
 }