Exemple #1
1
 function __construct($header)
 {
     //TODO use https when loggin in
     // use ssh for login
     //		$host = "https://" . OLIV_SSH_HOST . "/" . OLIV_BASE . "index.php";
     $host = "http://" . system::OLIV_SSH_HOST() . "/" . system::OLIV_BASE() . "index.php";
     // load login content xml
     $this->content = OLIVModule::load_content($header);
     // select template for logged of not logged
     if (status::OLIV_USER()) {
         $header->param->template = "logged";
         $this->content->username = OLIVUser::getName(status::OLIV_USER());
         if (status::OLIV_SU()) {
             $this->content->su = status::OLIV_SU();
         } else {
             $this->content->user_groups = OLIVUser::getGroupName(status::OLIV_USER());
         }
     } else {
         // check if wrong login
         if (argv::action() == "login") {
             $header->param->template = "incorrect";
         }
     }
     // load correct template
     $this->template = OLIVModule::load_template($header);
 }
Exemple #2
0
 public function page($page, $template)
 {
     if ($page->structure()) {
         // set parameters for stylesheet display
         $template->stylesheet->setParameter("", "lang", status::lang());
         $template->stylesheet->setParameter("", "user", status::OLIV_USER());
         // start stylesheet processor
         return $template->stylesheet->transformToXML($page->structure());
     }
 }
Exemple #3
0
function olivini_writeFile($iniArray, $path, $file, $lang)
{
    $headerString = "; creaded by oliv\n";
    $headerString .= "; timestamp " . time() . "\n";
    $headerString .= "; user " . status::OLIV_USER() . "\n";
    // convert array to string
    $iniString = olivini_array2string($iniArray);
    // create file name
    $file = "{$lang}.{$file}.ini";
    // get complete path to session
    $path = session_path($path . $file);
    // write string to file
    if ($iniString) {
        if (!($handle = fopen($path, 'w'))) {
            OLIVError::fire("olivini_writeFile -> can't open {$path} to write");
            return FALSE;
        }
        // insert header
        fwrite($handle, $headerString);
        if (!fwrite($handle, $iniString)) {
            OLIVError::fire("olivini_writeFile -> can't write to {$path}");
            return FALSE;
        } else {
            fclose($handle);
        }
        return TRUE;
    }
    return FALSE;
}
Exemple #4
0
    $user = $_SESSION['user'] = "";
}
// change user login state
switch (argv::action()) {
    case 'login':
        if (OLIVUser::checkPassword(argv::login(), argv::password())) {
            $user = argv::login();
            // remove login parameters
            argv::remove('action');
            argv::remove('login');
            argv::remove('password');
        }
        break;
    case 'logout':
        $user = "";
        break;
    default:
        break;
}
// set user status
$_SESSION['user'] = $user;
status::set('OLIV_USER', $_SESSION['user']);
// set superuser state
if (OLIVUser::superUser(status::OLIV_USER())) {
    status::set('OLIV_SU', TRUE);
} else {
    status::set('OLIV_SU', FALSE);
}
//echoall(system::getAll());
//echoall(status::getAll());
//------------------------------------------------------------------------------
Exemple #5
0
 private static function checkAccess($access, $strict = FALSE)
 {
     $owner = "";
     $group = "";
     $rights = "000";
     $ownRight = "";
     $groupRight = "";
     $allRight = "";
     //echoall($access);
     //------------------------------------------------------------------------------
     // get requested rights
     $owner = (string) $access->attributes()->owner;
     $group = (string) $access->attributes()->group;
     $rights = (string) $access->attributes()->access;
     $ownRight = intval(substr($rights, 0, 1));
     $groupRight = intval(substr($rights, 1, 1));
     $allRight = intval(substr($rights, 2, 1));
     //------------------------------------------------------------------------------
     // get user rights
     $userRight = OLIVUser::getRight(status::OLIV_USER());
     $userOwner = $userRight->getName();
     $userGroup = OLIVUser::getGroup(status::OLIV_USER());
     //echoall($group);
     //------------------------------------------------------------------------------
     // no rights requested
     // reset rights
     $r = $w = $x = 0;
     // if no rights found, check strict parameter
     if (!$ownRight and !$groupRight and !$allRight) {
         if (!$strict) {
             $r = $w = $x = 1;
         } else {
             $r = $w = $x = 0;
         }
     }
     //print_r($userGroup->asXML());
     //------------------------------------------------------------------------------
     // give all rights if superuser
     if (status::OLIV_SU()) {
         $r = $w = $x = 1;
     }
     //------------------------------------------------------------------------------
     // check owner
     if (status::OLIV_USER()) {
         if ($owner == $userOwner) {
             if ($ownRight & 4) {
                 $r = 1;
             }
             if ($ownRight & 2) {
                 $w = 1;
             }
             if ($ownRight & 1) {
                 $x = 1;
             }
         }
     }
     //------------------------------------------------------------------------------
     // check group
     if ($userGroup) {
         if ($group == (string) $userGroup->{$group}->getName()) {
             if ($groupRight & 4) {
                 $r = 1;
             }
             if ($groupRight & 2) {
                 $w = 1;
             }
             if ($groupRight & 1) {
                 $x = 1;
             }
         }
     }
     //------------------------------------------------------------------------------
     // check all rights
     if ($access) {
         if ($allRight & 4) {
             $r = 1;
         }
         if ($allRight & 2) {
             $w = 1;
         }
         if ($allRight & 1) {
             $x = 1;
         }
     }
     return array("r" => $r, "w" => $w, "x" => $x);
 }