Exemple #1
0
 function replace_keywords($text, $object)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $text = str_replace("%name%", "{$object->nname}\n", $text);
     $text = str_replace("%clientname%", $object->getParentName() . "\n", $text);
     $text = str_replace("%password%", $object->realpass, $text);
     if ($sgbl->isKloxo()) {
         $text = str_replace("%default_domain%", $object->default_domain, $text);
     }
     if (csa($text, "%ipaddress%")) {
         $db = new Sqlite($this->__masterserver, 'ipaddress');
         $iplist = $db->getRowsWhere("syncserver = 'localhost'");
         $text = str_replace("%ipaddress%", getFQDNforServer('localhost'), $text);
     }
     if (csa($text, "%masterserver%")) {
         $db = new Sqlite($this->__masterserver, 'ipaddress');
         $iplist = $db->getRowsWhere("syncserver = 'localhost'");
         $text = str_replace("%masterserver%", getFQDNforServer('localhost'), $text);
     }
     $string = null;
     foreach ($this->priv as $k => $v) {
         if ($this->isQuotaVariable($k)) {
             $var = get_v_descr($this, $k);
             $var = get_form_variable_name($var);
             $string .= "{$var}: {$v}\n";
         }
     }
     $text = str_replace("%quota%", $string, $text);
     $tlist = explode("\n", $text);
     $inside = false;
     $match = false;
     foreach ($tlist as $tl) {
         $tl = trim($tl);
         if (csb($tl, "<%class:")) {
             $inside = true;
             $classname = strfrom($tl, "<%class:");
             $classname = strtil($classname, "%>");
             if ($classname === $this->get__table()) {
                 $match = true;
             }
             continue;
         }
         if ($inside) {
             if (csb($tl, "<%/class%>")) {
                 if ($match) {
                     $total[] = $object->fillWelcomeMessage(implode("\n", $textinside));
                 }
                 $inside = false;
                 $textinside = null;
             } else {
                 $textinside[] = $tl;
             }
             continue;
         }
         $total[] = $tl;
     }
     return implode("\n", $total);
 }
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;
        }
    }
}