function postAdd()
 {
     $parent = $this->getParentO();
     $nname = $this->username;
     if (exists_in_db($parent->__masterserver, 'mysqldb', $nname)) {
         throw new lxException('databaseuser_already_exists', 'dbname', '');
     }
 }
示例#2
0
 function postAdd()
 {
     $parent = $this->getParentO();
     $nname = $this->username;
     $pp = $this->getRealClientParentO();
     $this->syncserver = $pp->mysqldbsyncserver;
     $this->fixSyncServer();
     if (exists_in_db($parent->__masterserver, 'mysqldbuser', $nname)) {
         throw new lxException('databaseuser_already_exists', 'dbname', '');
     }
 }
示例#3
0
 static function add($parent, $class, $param)
 {
     $param['nname'] = strtolower($param['nname']);
     if (exists_in_db(null, 'domain', $param['nname'])) {
         throw new lxException('domain_already_exists_as_virtual', 'nname', $param['nname']);
     }
     validate_domain_name($param['nname']);
     if ($parent->isClient()) {
     } else {
         $param['real_clparent_f'] = $parent->nname;
     }
     return $param;
 }
示例#4
0
 static function add($parent, $class, $param)
 {
     if ($parent->isClient()) {
         $param['nname'] = "{$param['nname']}@{$param['real_clparent_f']}";
         $param['syncserver'] = $parent->mmailsyncserver;
     } else {
         $param['nname'] = "{$param['nname']}@{$parent->nname}";
         $param['syncserver'] = $parent->syncserver;
     }
     if (!validate_email($param['nname'])) {
         throw new lxException("invalid_email_id", 'nname');
     }
     // Not needed. The child will automatically inherit the syncserver.
     //$param['syncserver'] = $parent->syncserver;
     $param['nname'] = trim($param['nname']);
     //$param['parent_clname'] = "mmail-{$param['real_clparent_f']}";
     if (exists_in_db(null, "mailforward", $param['nname'])) {
         throw new lxException("forward_with_same_id_exists", 'nname', $param['nname']);
     }
     $param = parent::add($parent, $class, $param);
     return $param;
 }
示例#5
0
 function consistencyNotExisting($trulist, $real)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $sql = new Sqlite(null, get_table_from_class($this->getParentClass()));
     $res = $sql->getRowsWhere("nname = '{$this->getParentName()}'");
     if ($trulist && $this->__parent_o->dbaction !== 'add' && !$res) {
         $this->AddMEssageOnlyIfClientDomain("<font color=red> <b> (Parent {$this->getParentName()} Does Not Exist. Will be Not be Restored).</font> </b> ");
         return false;
     } else {
         $extra = null;
         if ($trulist) {
             $extra = " Will be Restored";
         }
         $this->AddMEssageOnlyIfClientDomain("<font color=blue> <b> (Does Not Exist.{$extra}).</font> </b> ");
     }
     if ($this->extraRestore()) {
         $sgbl->__var_objectrestorelist[] = $this;
     }
     // This is to ensure that if the syncserver of say mmail gets switched, and if one of the mailaccounts doesn't exist in the db, then the syncserver is properly got from the parent. Most of the objects directly inherit their syncservers from their parnet. But this code needs some more analysis.
     $this->inheritSyncServer($this->__parent_o);
     $this->__var_checked = true;
     $this->dbaction = 'add';
     if ($real) {
         if ($gbl->__var_list_flag) {
             if ($this->isCoreBackup()) {
                 print "{$this->get__table()}:{$this->nname} under {$this->__parent_o->nname} Doesn't Exist....\n";
             }
         } else {
             if ($this->isCoreBackup()) {
                 print "{$this->get__table()}:{$this->nname} under {$this->__parent_o->nname} Doesn't exist... Restoring.....\n";
             }
             $this->consistencySwitchServer();
             if ($this->syncserver && $this->isSync() && !csa($this->syncserver, ",")) {
                 if (!exists_in_db($this->__masterserver, 'pserver', $this->syncserver)) {
                     throw new lxException("server_{$this->syncserver}_doesnt_exist", '', $this->get__table());
                 }
             }
             $this->dbaction = 'add';
         }
     }
     return true;
 }
示例#6
0
文件: lxdb.php 项目: soar-team/kloxo
 function doupdateSwitchserver($param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $this->checkNotSame($param, array("syncserver"));
     if (!exists_in_db($this->__masterserver, 'pserver', $param['syncserver'])) {
         throw new lxException("does_not_exist", "syncserver", $param['syncserver']);
     }
     $this->__var_bc_backupextra_stopvpsflag = 'on';
     if ($this->extraBackup()) {
         $file = $this->backMeUpThere();
         $this->subaction = null;
     }
     $oldsyncserver = $this->syncserver;
     $this->olddeleteflag = 'done';
     try {
         $cloned = clone $this;
         $this->AddToThere($param['syncserver']);
         $this->was();
         if ($this->extraBackup()) {
             dprint("Got the backed up file...\n");
             dprint("{$oldsyncserver}\n");
             dprintr($file);
             $this->restoreMeUpThere($oldsyncserver, $file);
         }
         //$this->makeDnsChanges($param['syncserver']);
         $this->UpdateHeirarchy();
         $this->was();
         // There is a problem here. Teh __list_list will get cleared with one was. Then it is the getlist called from inside the deletefromhere that should fill it up again.
         $cloned->DeleteFromHere($oldsyncserver);
         $cloned->was();
     } catch (exception $e) {
         throw $e;
     }
 }
示例#7
0
 function updateChangeRealName($param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $this->__real_nname = $this->nname;
     $namereal = str_replace(" ", "_", $param['realname']);
     $namereal = strtolower($namereal);
     $nname = "{$namereal}___{$this->getParentO()->getClName()}";
     if (exists_in_db(null, 'resourceplan', $nname)) {
         throw new lxException('already_exists', 'realname');
     }
     $this->nname = $nname;
     $gbl->__this_redirect = $ghtml->getFullUrl("goback=1&a=show&l[class]=resourceplan&l[nname]={$nname}");
     return $param;
 }
示例#8
0
 static function add($parent, $class, $param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if ($class === 'subdomain') {
         $param['nname'] = "{$param['nname']}.{$param['subdomain_parent']}";
     }
     validate_domain_name($param['nname']);
     lxclient::fixpserver_list($param);
     $param['nname'] = strtolower($param['nname']);
     if (exists_in_db(null, 'addondomain', $param['nname'])) {
         throw new lxException('domain_already_exists_as_pointer', 'parent');
     }
     $param['web-nname'] = $param['nname'];
     $param['dns-nname'] = $param['nname'];
     $param['dns-zone_type'] = 'master';
     $param['mmail-nname'] = $param['nname'];
     // the uuser is two steps removed from the main object (domain), and thus the automatic nname creation doesn't seem to work. So we have to do it here.
     /*
     $param['realpass'] = $param['password'];
     $param['password'] = crypt($param['password']);
     */
     return $param;
 }
示例#9
0
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());
}
示例#10
0
function __ac_desc_continue($object)
{
    global $gbl, $sgbl, $login, $ghtml;
    $cname = $ghtml->frm_o_cname;
    $numvar = $cname . "_num";
    if ($object->isQuotaVariable($numvar)) {
        if (isQuotaGreaterThan($object->used->{$numvar}, $object->priv->{$numvar})) {
            throw new lxException("Quota Exceeded for {$cname}", $numvar);
        }
    }
    $param = $ghtml->createCurrentParam($cname);
    $continueaction = $ghtml->frm_continueaction;
    $ret = exec_class_method($cname, 'continueForm', $object, $cname, $param, $continueaction);
    if ($ret['action'] === 'addnow') {
        __ac_desc_add($object, $ret['param']);
        return;
    }
    $alist = exec_class_method($cname, "createListAlist", $object, $cname);
    if ($alist) {
        $ghtml->print_tab_block($alist);
    }
    $ghtml->print_message();
    //dprintr($param);
    $string[] = $ghtml->object_variable_startblock($object, $cname, "Continue Add {$cname}");
    $string[] = $ghtml->object_inherit_classpath();
    $string[] = $ghtml->object_variable_hidden("frm_o_cname", $cname);
    $tparam = $ret['param'];
    $vlist = $ret['variable'];
    if (isset($tparam['nname']) && exists_in_db($object->__masterserver, $cname, $tparam['nname'])) {
        throw new lxException("{$tparam['nname']}+already+exists+in+{$cname}.", "nname");
    }
    $param = null;
    foreach ($tparam as $k => $v) {
        $param["frm_" . $cname . "_c_" . $k] = $v;
    }
    $string[] = $ghtml->object_variable_hiddenlist($param);
    $string[] = create_xml($object, $cname, $ret);
    $pre = $post = null;
    if (isset($vlist['__m_message_pre'])) {
        $pre = $vlist['__m_message_pre'];
    }
    if (isset($vlist['__m_message_post'])) {
        $post = $vlist['__m_message_post'];
    }
    $ghtml->print_information('pre', 'continueform', "", $continueaction, $pre);
    $ghtml->xml_print_page($string);
    $ghtml->print_information('post', 'continueform', "", $continueaction, $post);
}