Beispiel #1
0
function convert_auth($sqlite_db, $min)
{
    $sqlite_db->query("begin transaction;");
    $sqlite_db->query("DELETE FROM authors");
    $handle = fopen("db/author", "r");
    while (!feof($handle)) {
        $buffer = Trim(fgets($handle, 4096), "\n\r");
        if (empty($buffer[0])) {
            continue;
        }
        $fields = explode(chr(9), $buffer);
        $id = $fields[0];
        $names = explode(",", $fields[1]);
        $last_name = utf(trim($names[0]));
        $first_name = utf(trim($names[1]));
        $middle_name = utf(trim($fields[2]));
        $full_name = trim(trim($last_name . " " . $first_name) . " " . $middle_name);
        $letter = letter($full_name);
        $numb = $fields[5];
        echo "Auth: " . $letter . " - " . $id . " - " . $full_name . "\n";
        $sql = "INSERT INTO authors (id, number, letter, full_name, first_name, middle_name, last_name) VALUES(?,?,?,?,?,?,?)";
        $insert = $sqlite_db->prepare($sql);
        $insert->execute(array($id, $numb, $letter, $full_name, $first_name, $middle_name, $last_name));
    }
    fclose($handle);
    $sqlite_db->query("commit;");
}
Beispiel #2
0
function localQ($tri_s3ql)
{
    $query = S3QLAction($tri_s3ql);
    ##Now force the RDF output
    $format = $tri_s3ql['format'];
    $data = $query;
    $db = $tri_s3ql['db'];
    if (is_array($query[0])) {
        $cols = array_keys($query[0]);
        $letter = letter($tri_s3ql['from']);
        $z = compact('data', 'cols', 'format', 'db', 'letter');
        $answer = outputFormat($z);
    } else {
        $answer = array();
    }
    return $answer;
}
Beispiel #3
0
function URIinfo($uid, $user_id, $key, $db, $timer = array())
{
    $uid_info = uid($uid);
    $element = $GLOBALS['s3codes'][substr($uid, 0, 1)];
    $local_info = s3info($element, ereg_replace('^' . letter($uid), '', $uid), $db);
    #echo $uid.'<pre>';print_r($local_info);exit;
    if (is_array($local_info) && !empty($local_info)) {
        $uid_info['Did'] = $GLOBALS['Did'];
        $uid_info['uid'] = $uid;
        $element_info = $local_info;
        $letter = strtoupper(substr($element, 0, 1));
        $info = include_all(compact('elements', 'letter', 'element_info', 'user_id', 'db', 'key', 'timer'));
        $info['remote_uri'] = 0;
        #echo '<pre>';print_r($info);exit;
    }
    if ($uid_info['Did'] == $GLOBALS['Did'] || $uid_info['Did'] == S3DB_URI_BASE) {
        if (is_array($local_info) && !empty($local_info)) {
            $uid = str_replace(S3DB_URI_BASE . '/', '', $uid_info['uid']);
            $uid_info['Did'] = $GLOBALS['Did'];
            $uid_info['uid'] = $uid;
            $element_info = s3info($element, ereg_replace('^' . letter($uid), '', $uid), $db);
            $letter = strtoupper(substr($element, 0, 1));
            $info = include_all(compact('elements', 'letter', 'element_info', 'user_id', 'db', 'key'));
            $info['remote_uri'] = 0;
        } else {
            $info = false;
        }
        #echo 'loca'.$uid;exit;
        #$info = URI($uid_info['uid'], $user_id, $db);
        #$info['remote_uri']=0;
    } else {
        #echo 'ola'.$uid;exit;
        $key = $key != '' ? $key : get_user_key($user_id, $db);
        #echo $user_id;exit;
        $info = remoteURI($letter . $uid_info['uid'], $key, $user_id, $db);
        #echo '<pre>';print_r($info);exit;
        $info['remote_uri'] = 1;
        if (!is_array($info) || empty($info)) {
            $info = URI($uid, $user_id, $db);
        }
        if (!is_array($info)) {
            $info = false;
        }
    }
    #echo '<pre>';print_r($info);exit;
    return $info;
}
Beispiel #4
0
// $sql = "SELECT ". $sqlSelect ." FROM ". $sqlFrom ." ".$sqlWHERE." LIMIT 9";
// $stmt = $pdo->prepare($sql);
// $stmt->execute();
// $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
$results = sqlRequest($sqlSelect, $sqlFrom, $sqlWHERE, " LIMIT 9", $bindArray);
$viewMain = "";
$view = "";
foreach ($results as $key => $row) {
    //  var_dump($row);
    if ($key < 3) {
        $viewMain .= "<li><a href='single.php?news_id=" . $row["news_id"] . "'><dl><dt>";
        $viewMain .= "<img src='admin/files/" . $row["news_url"] . "' alt=''></dt><dd><div class='sub'>";
        $viewMain .= "<span class='catIcon " . $row["cat_slug"] . "'>" . $row["cat_name"] . "</span>";
        $viewMain .= "<span class='date'>" . $row["create_date"] . "</span></div>";
        $viewMain .= "<h2>" . $row["news_title"] . "</h2>";
        $viewMain .= "<p class='detail'>" . letter(htmlspecialchars_decode($row["news_detail"]), 100) . "</p>";
        $viewMain .= "</dd></dl></a></li>";
    } else {
        $view .= "<li><a href='single.php?news_id=" . $row["news_id"] . "'>";
        $view .= "<span class='catIcon " . $row["cat_slug"] . "'>" . $row["cat_name"] . "</span>";
        $view .= "<figure><img src='admin/files/" . $row["news_url"] . "' alt=''></figure>";
        $view .= "<div class='itemContent'><p class='title'>" . $row["news_title"] . "</p>";
        $view .= "<p class='date'>" . $row["create_date"] . "</p></div></a></li>";
    }
}
// table閉じタグで終了
$pdo = null;
include "header.php";
?>
<div id="contents">
<?php 
Beispiel #5
0
$complete = $_REQUEST['display'] == 'complete' ? true : false;
if ($format == '') {
    $format = 'html';
}
#If no query is provided, expect a UID.
#Reading the UID should return a letter, C, I, R, S, U or P and a number.
#queries will be only on exact ID
if ($uid == '') {
    $letter = 'U';
    $t = $GLOBALS['s3codes'][$letter];
    $ID = $user_id;
    $element_info = $user_info;
    $data[0] = include_all(compact('letter', 'info', 'element_info', 'user_id', 'db', 'key'));
    $data[0]['uid'] = $GLOBALS['Did'] . ($letter != 'U' ? '|U' . $user_id : '') . '|' . $letter . $ID;
} else {
    $letter = letter($uid);
    $t = $GLOBALS['s3codes'][$letter];
    $uid_info = uid($uid);
    $ID = substr($uid_info['uid'], 1, strlen($uid_info['uid']));
    if ($ID != '' && $letter != '') {
        $element_info = URIinfo($uid, $user_id, $key, $db);
        #Find the appropriate table information from each table where to look for the UID
        #User_id does not need to check if there is permissions to perform the query, all others need permission
        if (!is_array($element_info)) {
            echo formatReturn($GLOBALS['error_codes']['something_does_not_exist'], 'UID ' . $uid . ' does not exist', $format, '');
            exit;
        }
        if (!$element_info['view']) {
            echo formatReturn($GLOBALS['error_codes']['no_permission_message'], 'User does not have permission on uid ' . $uid, $format, '');
            exit;
            #echo ($no_permission_message.'<message>user does not have permission on uid '.$uid.' </message>');
Beispiel #6
0
}
#When the result is an array, rules or any other, run display to give values as tab delimited
#if(is_array($s3qlOut))
#echo '<pre>';print_r($s3qlOut);
$data = $s3qlOut;
$letter = letter($s3ql['from']);
$t = $GLOBALS['s3codes'][$letter];
$t = $GLOBALS['plurals'][$t];
#if($s3ql['select']!='*'){
#$toreplace = array_keys($GLOBALS['s3map'][$t]);
#$replacements = array_values($GLOBALS['s3map'][$t]);
#$s3ql['select'] = str_replace($toreplace, $replacements, $s3ql['select']);
#$s3ql_out=ereg_replace(' ', '', $s3ql['select']);#take out all the spaces
#$returnFields = explode(',', $s3ql_out);
#}
$letter = letter($s3ql['from']);
$pack = compact('s3qlOut', 'data', 's3ql', 'letter', 'returnFields', 't', 'format', 'db');
#echo '<pre>';print_r($pack);
echo completeDisplay($pack);
exit;
#finish key valid
function readInputMessage($query)
{
    #echo '<pre>';print_r($$_SERVER[]);
    #echo $query;exit;
    $xml = $query;
    ##When value brings tags, they will be parsed along with the rest of the xml. Avoid that by encoding it first.
    #echo $xml;exit;
    ereg('<value>(.*)</value>', $xml, $val);
    #echo '<pre>';print_r($val);
    if ($val[1] != '') {
Beispiel #7
0
function deleteCoreResource($uid, $user_id, $db)
{
    #function deleteCoreResource performs very simple deleteResource queries - given a uid, it retrieves a table and the correct numeric id to delete.
    $s3codes = $GLOBALS['s3codes'];
    $s3tables = $GLOBALS['s3tables'];
    $s3ids = $GLOBALS['s3ids'];
    $messages = $GLOBALS['message'];
    $uid_info = uid($uid);
    $letter = letter($uid);
    $table = $s3codes[$letter];
    if ($table == '') {
        return substr($uid_info['uid'], 0, strlen($uid_info['uid'])) . ' is not a valid resource identifyer';
    }
    #map resource to the right table
    $table_id = $s3ids[$table];
    $table = $s3tables[$table];
    #numeric id
    $num_id = ltrim(str_replace($GLOBALS['Did'] . '/', '', $uid), $letter);
    #$sql = "delete from s3db_".$table." where ".$table_id." = '".$num_id."'";
    switch ($letter) {
        case 'I':
            #also, for every item there is a "has UID" statement that needs to be deleted. But the rule is being deleted when the collection is deleted (from item). So items and statemnts need to be deleted first
            if ($num_id != '') {
                $SQL = "select statement_id from s3db_statement where rule_id in (select rule_id from s3db_rule where verb = 'has UID' and object = 'UID') and resource_id = '" . $num_id . "'";
                $db->query($SQL);
                if ($db->next_record()) {
                    $stat2delete = $db->f('statement_id');
                    $sql1 = "delete from s3db_statement where statement_id = '" . $stat2delete . "'";
                    $db->query($sql1);
                    $sql2 = "delete from s3db_permission where uid = 'S" . $stat2delete . "' or shared_with = 'S" . $stat2delete . "'";
                    #echo $sql2.'<BR>';
                    $db->query($sql2);
                }
            }
            $instance_info = URI($uid, $user_id, $db);
            $s3ql = compact('user_id', 'db');
            $s3ql['select'] = '*';
            $s3ql['from'] = 'statements';
            $s3ql['where']['value'] = $num_id;
            $stats_to_delete = S3QLaction($s3ql);
            if (is_array($stats_to_delete)) {
                foreach ($stats_to_delete as $sInd => $stat_info) {
                    if ($stat_info['object_id'] == $instance_info['resource_class_id'] && $stat_info['delete']) {
                        $s3ql = compact('user_id', 'db');
                        $s3ql['delete'] = 'statement';
                        $s3ql['where']['statement_id'] = $stat_info['statement_id'];
                        S3QLaction($s3ql);
                    }
                }
            }
            break;
        case 'C':
            #remove also the rule "hasUID"
            if ($num_id != '') {
                $rule_has_UID_sql = "delete from s3db_rule where subject_id = '" . $num_id . "' and object='UID' and verb='has UID'";
                $db->query($rule_has_UID_sql, __LINE__, __FILE__);
            }
            break;
    }
    #after dependencies are deleted, delete the resource
    $sql = "delete from s3db_" . $table . " where " . $table_id . " = '" . $num_id . "'";
    #echo $sql.'<BR>';
    $db->query($sql);
    ##Now delete this id in the permissions table
    #
    if ($uid != '') {
        $deleteSQL = "delete from s3db_permission where uid='" . $uid . "' or shared_with = '" . $uid . "'";
        $db->query($deleteSQL);
    }
    $dbdata = get_object_vars($db);
    if ($dbdata['Errno'] == 0) {
        return True;
    } else {
        return False;
    }
}
Beispiel #8
0
include "header.php";
?>

<div id="contents">
    <?php 
include "sidebar.php";
?>
    <div id="main">
        <p class="pankuzu"><a href="">ホーム</a> > <a href="archive.php?cat_id=<?php 
echo $cat_id;
?>
"><?php 
echo $pankuzu;
?>
</a> > <?php 
echo letter($title, 30);
?>
</p>
        <article class="articleArea">
            <figure><img src="admin/files/<?php 
echo $imgurl;
?>
" alt=""></figure>
            <h2><?php 
echo $title;
?>
</h2>
            <div class="artInfo">
                <div><span class="catIcon <?php 
echo $cat_slug;
?>
Beispiel #9
0
function simpleQueryUID($shared_with_query, $element, $db)
{
    ##Create 150408 for performing faster queries
    $shared_with_query = array_unique($shared_with_query);
    $str_ids = '';
    for ($i = 0; $i < count($shared_with_query); $i++) {
        $uidletter = strtoupper(substr($element, 0, 1));
        $swletter = letter($shared_with_query[$i]);
        if ($id == '') {
            $uid = $GLOBALS['regexp'] . " '^" . $uidletter . "'";
        } else {
            $uid = $GLOBALS['regexp'] . " '^" . $uidletter . "(" . $id . ")\$'";
        }
        $score = array('D' => 0, 'G' => 1, 'U' => 2, 'P' => 3, 'C' => 4, 'R' => 4, 'I' => 5, 'S' => 6);
        $jump = $score[$uidletter] - $score[$swletter];
        #Added 120508 for enabling query on items of project
        if ($jump > 1) {
            $middleQuery = '';
            switch ($uidletter) {
                case 'I':
                    $middleQuery = simpleQueryUID($shared_with_query, 'collection', $db);
                    $middleQuery = str_replace("id = '", "shared_with = 'C", $middleQuery['str_ids']);
                    break;
                case 'S':
                    $middleQuery = simpleQueryUID($shared_with_query, 'rule', $db);
                    $middleQuery = str_replace("id = '", "shared_with = 'R", $middleQuery['str_ids']);
                    break;
            }
        }
        if ($score[$swletter] < $score[$uidletter]) {
            $id_query = "select * from s3db_permission where uid " . $uid . " and shared_with = '" . $shared_with_query[$i] . "'";
            if ($middleQuery != '') {
                $id_query .= "or (" . $middleQuery . ")";
            }
            $db->query($id_query, __FILE__, __LINE__);
            #echo $id_query;
            #echo '<pre>';print_r($db);
            while ($db->next_record()) {
                if ($i != count($shared_with_query) - 1) {
                    if ($id != '') {
                        $id .= '|';
                    }
                    $id .= $db->f('id');
                } else {
                    if ($finalUID != '') {
                        $finalUID .= ' or ';
                    }
                    $finalUID .= $GLOBALS['s3ids'][$element] . " = '" . $db->f('id') . "'";
                    $array_ids[$db->f('id')] = $db->f('permission_level');
                    #$str_ids = ($str_ids=='')?($db->f('id')):('|'.$db->f('id'));
                    $str_ids .= $str_ids == '' ? " id = '" . $db->f('id') . "'" : " or id = '" . $db->f('id') . "'";
                }
            }
        } else {
            $tmp = $shared_with_query[$i];
            $shared_with = $uid;
            $uid = $tmp;
            $id_query = "select substr(shared_with,2,length(shared_with)) as shared_with_num,permission_level from s3db_permission where shared_with " . $shared_with . " and uid = '" . $uid . "'";
            $db->query($id_query, __FILE__, __LINE__);
            #echo $id_query;
            #echo '<pre>';print_r($db);
            while ($db->next_record()) {
                if ($i != count($shared_with_query) - 1) {
                    if ($sw != '') {
                        $sw .= '|';
                    }
                    $sw .= $db->f('shared_with_num');
                } else {
                    if ($finalUID != '') {
                        $finalUID .= ' or ';
                    }
                    $finalUID .= $GLOBALS['s3ids'][$element] . " = '" . $db->f('shared_with_num') . "'";
                    $array_ids[$db->f('shared_with_num')] = $db->f('permission_level');
                    #$str_ids = ($str_ids=='')?($db->f('id')):('|'.$db->f('id'));
                    $str_ids .= $str_ids == '' ? " substr(shared_with,2,length(shared_with)) = '" . $db->f('shared_with_num') . "'" : " or substr(shared_with,2,length(shared_with)) = '" . $db->f('shared_with_num') . "'";
                }
            }
        }
    }
    #echo '<pre>';print_r($array_ids);exit;
    ###$GLOBALS['s3ids'][$element]
    #Now through the query into the main CORE table
    if ($finalUID != '') {
        $finalUID = " and (" . $finalUID . ")";
        $return = compact('finalUID', 'str_ids', 'array_ids');
        return $return;
    } else {
        return False;
    }
    #echo $tmpQuery;exit;
}
Beispiel #10
0
function selectQuery($D)
{
    global $timer;
    extract($D);
    if ($s3ql['from'] == 'deployment') {
        $data[0] = array('mothership' => $GLOBALS['s3db_info']['deployment']['mothership'], 'deployment_id' => $GLOBALS['s3db_info']['deployment']['Did'], 'self' => '1', 'description' => $GLOBALS['s3db_info']['server']['site_intro'], 'url' => S3DB_URI_BASE, 'message' => 'Successfully connected to deployment ' . $GLOBALS['s3db_info']['deployment']['Did'] . '. Please provice a key to query the data (for example: ' . ($_SERVER['https'] == 'on' ? 'https://' : 'http://') . $def . S3DB_URI_BASE . '/URI.php?key=xxxxxxxx. For syntax specification and instructions refer to http://s3db.org/');
        #return $data;
    }
    #echo '<pre>';print_r($s3ql);
    if (in_array($s3ql['from'], array_keys($GLOBALS['plurals']))) {
        $s3ql['from'] = $GLOBALS['plurals'][$s3ql['from']];
    }
    #echo '<pre>';print_r($s3ql);exit;
    if ($s3ql['from'] == 'classes') {
        $s3ql['from'] = 'collections';
    }
    if ($s3ql['from'] == 'instances') {
        $s3ql['from'] = 'items';
    }
    if ($s3ql['from'] == 'keys' && $_SESSION['db'] == '') {
        return formatReturn($GLOBALS['error_codes']['not_a_query'], 'Access keys cannot be queried in the API.', $s3ql['format'], '');
        exit;
    }
    if (eregi('^t', $s3ql['shared'])) {
        $shared = true;
        #shared being set to true will tell s3ql that he should not only retrieved uid native to the upstream resource being queried, but those that propagate toward it
        $s3ql = array_delete($s3ql, 'shared');
    }
    if ($s3ql['from'] == 'permission' && $user_id != 1) {
        return formatReturn($GLOBALS['error_codes']['no_permission_message'], 'User cannot query permissions.', $s3ql['format'], '');
        exit;
    }
    if (eregi('^t', $s3ql['shared'])) {
        $shared = true;
        #shared being set to true will tell s3ql that he should not only retrieved uid native to the upstream resource being queried, but those that propagate toward it
        $s3ql = array_delete($s3ql, 'shared');
    }
    if (eregi('complete', $s3ql['display'])) {
        $complete = true;
        #complete will tell s3ql that dictionary terms should be added to the output
        $s3ql = array_delete($s3ql, 'display');
    }
    $target = $s3ql['from'];
    $letter = strtoupper(substr($s3ql['from'], 0, 1));
    $table = strval($target);
    $element = $target;
    $cols = $GLOBALS['dbstruct'][$target];
    $element_id = $s3ql['where'][$GLOBALS['s3ids'][$element]];
    if ($table != '' && !in_array($table, array_keys($GLOBALS['dbstruct']))) {
        return formatReturn($GLOBALS['error_codes']['not_a_query'], 'Not a valid query.', '', $s3ql['format']);
    }
    #manage data in select
    #echo '<pre>';print_r($s3ql);
    #array_keys contains the things to replace and array_values the replacements
    if ($s3ql['select'] != '' && $s3ql['select'] != '*') {
        $s3ql_out = ereg_replace(' ', '', $s3ql['select']);
        #take out all the spaces
        $returnFields = explode(',', $s3ql_out);
        if (!ereg($GLOBALS['s3ids'][$element], $s3ql['select'])) {
            if (ereg('count|max|min', $s3ql['select'])) {
                $SQLfun = ereg_replace("\\(.*\\)", "", $select);
                $SQLfun = ereg_replace("count as count", "count", $SQLfun);
                $s3ql['select'] = '*';
            } else {
                $s3ql['select'] .= ',' . $GLOBALS['s3ids'][$element];
            }
        }
        ##Because of the new code, will also have to add the parent ids to the query
        #$parents = $GLOBALS['inherit'][$GLOBALS['s3ids'][$element]];
        $parents = $GLOBALS['inherit'][$GLOBALS['COREids'][$GLOBALS['singulars'][$element]]];
        ##duuuhhh
        if (is_array($parents)) {
            foreach ($parents as $p) {
                if (!in_array($p, $returnFields)) {
                    $s3ql['select'] .= ',' . str_replace($toreplace, $replacements, $p);
                }
            }
        }
    } else {
        $s3ql['select'] = '*';
    }
    #echo $s3ql['select'];exit;
    #echo '<pre>';print_r($s3ql);exit;
    $toreplace = array_keys($GLOBALS['s3map'][$target]);
    $replacements = array_values($GLOBALS['s3map'][$target]);
    #to replace query str with replacements, remove the spaces and explode by commas
    $select = explode(',', str_replace(' ', '', $s3ql['select']));
    foreach ($select as $s_key => $str_select) {
        if (in_array($str_select, $toreplace)) {
            $select[$s_key] = $replacements[array_search($str_select, $toreplace)];
        }
    }
    #echo '<pre>';print_r($select);exit;
    $s3ql['select'] = implode(',', array_unique($select));
    #$s3ql['select'] = str_replace($toreplace, $replacements, $s3ql['select']);
    #echo '<pre>';print_r($s3ql['select']);
    $select = urldecode($s3ql['select']);
    $select = eregi_replace('uid', $GLOBALS['s3ids'][$element] . ' as uid', $select);
    $select = eregi_replace('uri', $GLOBALS['s3ids'][$element] . ' as uri', $select);
    $select = eregi_replace('(,).*permissionOnResource', '', $select);
    #echo $P['out'].$P['SQLfun'];
    if ($select == $SQLfun) {
        $SQLfun = '';
    }
    #$s3ql_where_keys = str_replace(array('item_id', 'collection_id'), array('instance_id', 'class_id'), array_keys($s3ql['where']));
    #$s3ql['where'] = array_combine($s3ql_where_keys, $s3ql['where']);
    #transofrmt s3ql and get the return Fields
    $tranformed = S3QLselectTransform(compact('s3ql', 'db', 'user_id'));
    extract($tranformed);
    #anything that is queried must also go come out in the select
    if ($s3ql['where'] && $select != '*') {
        foreach ($s3ql['where'] as $more_outputs => $more_value) {
            if (!substr($select, $more_outputs)) {
                $select .= "," . str_replace($toreplace, $replacements, $more_outputs);
            }
        }
    }
    ##for statements, select must find file_name a well so that it is transofmred into a link
    if ($letter == 'S' && !ereg('file_name', $select)) {
        $select .= ',file_name';
    }
    $s3ql['select'] = $select;
    if ($timer) {
        $timer->setMarker('queryInterpreted');
    }
    #If there is any sort of S3 UID in the query, check its score when compared to the from
    $score = array('D' => '7', 'G' => '6', 'U' => '5', 'P' => '4', 'C' => '3', 'R' => '3', 'I' => '2', 'S' => '1');
    $fromScore = $score[strtoupper(substr($target, 0, 1))];
    $s3Ids = array_merge($GLOBALS['COREids'], array('rulelog' => 'rule_id', 'statementlog' => 'statement_id'));
    #echo '<pre>';print_r($s3ql);
    $shared_with_query = array();
    foreach ($s3Ids as $COREelement => $COREelement_id) {
        if ($s3ql['where'][$COREelement_id] != '' && !ereg('^~|regexp', $s3ql['where'][$COREelement_id])) {
            $id_name = $COREelement_id;
            $id_letter = strtoupper(substr($id_name, 0, 1));
            $whereScore[strtoupper(substr($id_name, 0, 1)) . $s3ql['where'][$COREelement_id]] = $score[strtoupper(substr($id_name, 0, 1))];
            #when idNameScore is < $fromScore, then we know: we are trying to query all resources that can view another particular resource (for example,all users that can view project x
            #echo $id_name;exit;
            $uid = strtoupper(substr($COREelement, 0, 1)) . $s3ql['where'][$COREelement_id];
            $uid_info = uid($uid);
            #Use URIinfo to find all data about this resource
            $element_info = URIinfo($uid, $user_id, $key, $db, $timer);
            $WhereInfo[$uid_info['uid']] = $element_info;
            if (!is_array($element_info)) {
                return formatReturn($GLOBALS['error_codes']['something_does_not_exist'], $uid . ' does not exist', $s3ql['format'], '');
                exit;
            } elseif ($id_letter != strtoupper(substr($element, 0, 1))) {
                ##Shared_with is any UID that can eb shared with any of the elements being requested (for example, Collection_id is shared_with Project, but Project_id is not shared  with Project
                array_push($shared_with_query, $uid);
                #do permissions on this uid propagate?
                #echo '<pre>';print_r($whereScore);exit;
            } else {
                $self_id = $s3ql['where'][$COREelement_id];
                if (!$element_info['view']) {
                    return formatReturn($GLOBALS['error_codes']['no_permission_message'], 'User does not have permission on ' . $uid, $s3ql['format'], '');
                    exit;
                }
            }
        }
    }
    #echo '<pre>';print_r($WhereInfo);exit;
    if ($self_id != '') {
        $data[0] = $element_info;
        if (ereg('^(U|G)$', $letter) && count($WhereInfo) == 2) {
            $whereId = array_diff(array_keys($WhereInfo), array($letter . $self_id));
            $D = array('shared_with' => $letter . $self_id, 'uid' => $whereId[0], 'strictsharedwith' => 1, 'strictuid' => 1, 'db' => $db, 'user_id' => $user_id, 'stream' => 'upstream', 'timer' => $timer);
            ##Look for shared_with in uid instead of uid in shared_with
            #echo 'ola';exit;
            #$data[0]['permissionOnResource']=permission4Resource($D);
            $p = array('shared_with' => $letter . $self_id, 'uid' => $whereId[0]);
            $hasP = has_permission($p, $db);
            $effective_permission_resource = permission4resource(array('user_id' => $self_id, 'shared_with' => $letter . $self_id, 'db' => $db, 'uid' => $whereId[0], 'strictsharedwith' => 1, 'strictuid' => 1, 'timer' => $timer, 'toFindInfo' => $WhereInfo[$whereId[0]]));
            if ($hasP || $effective_permission_resource != '') {
                $data[0]['permissionOnResource'] = $effective_permission_resource;
                $data[0]['assigned_permissionOnEntity'] = $hasP != "" ? $hasP : '---';
                $data[0]['effective_permissionOnEntity'] = $effective_permission_resource;
            } else {
                return array();
            }
        }
    } else {
        #echo 'ola';exit;
        #start building the query:
        $user_query = "select " . $select . " from s3db_" . $GLOBALS['s3tables'][$table];
        if (!user_is_admin($user_id, $db)) {
            $cols = array_diff($cols, array('account_pwd', 'account_phone', 'account_email', 'project_folder'));
        }
        #remove a few cols from query
        if ($timer) {
            $timer->setMarker('user is admin check');
        }
        #echo $user_id;exit;
        ##	echo $user_query;exit;
        #now add some constrains necessary due to the type of resource
        if (!(user_is_admin($user_id, $db) && $s3ql['where']['status'] == 'I')) {
            if (ereg('projects|classes|instances|rules|statements', $target)) {
                $status = "status!='I' and ";
            }
        }
        $user_query_const .= " where " . $status . $GLOBALS['s3ids'][$target] . "!='0'";
        ###
        #Filter query according to the element being requested
        $user_query_const .= filterByElement($s3ql, $user_id, $db);
        if ($user_query_const) {
            $user_query .= $user_query_const;
        } else {
            exit;
        }
        if ($timer) {
            $timer->setMarker('query filter');
        }
        if ($shared && !empty($shared_with_query) && strtoupper(substr($target, 0, 1)) != 'U') {
            #the "shared with" are the upstream resources being queried. These may or not be in  the permissions table (if the are remote). This basically finds not only elements that were created within a certain uid (for example Ix of Cx), but those that were later shared with that uid (for example Iy created within Cy but later shared with Iy)
            $uidQuery = simpleQueryUID($shared_with_query, $element, $db);
            if ($uidQuery) {
                extract($uidQuery);
                if (!ereg('G', $letter)) {
                    #query groups has a special syntax, it is already included in the query
                    $user_query .= $finalUID;
                }
                ##IS IT INCREASING THE QUERY TIME ABSURDELLY?
            }
            #else { #Go on with the regular query
            #		return formatReturn($GLOBALS['error_codes']['no_results'], 'Your query on '.$target.' did not return any results', $format,'');
            #	}
            if ($timer) {
                $timer->setMarker('Query to find shared UID');
            }
        }
        #now constrainthe query to resources that user cann access. Check for inherited permissions and direct permissions. Project is connected to deployment, rule and class to project, and so on. (see S3DB third report for the schema)
        #Fetch the cols of what is to be returned. Check for SqL functions. This will only affect the output
        if ($s3ql['select'] != '') {
            $out = urldecode($s3ql['select']);
            $SQLfun = ereg_replace("\\(.*\\)", "", $out);
            $SQLfun = ereg_replace("count as count", "count", $SQLfun);
            $P['out'] . $P['SQLfun'];
            if ($out == $SQLfun) {
                $SQLfun = '';
            } else {
                $extracol = $out;
            }
        }
        #echo $SQLfun;
        #Extract from the s3ql the value that are part of the syntax and assume the rest are the SQL extras (limit, creted_by, etc)
        $syntax = array('key', 'select', 'from', 'where', 'format');
        foreach ($s3ql as $i => $value) {
            if (!in_array($i, $syntax) && $value != '') {
                $SQLextra[$i] = ' ' . ereg_replace('_', ' ', $i) . ' ' . $value;
            }
        }
        #echo '<pre>';print_r($SQLextra);exit;
        #if there is orderby, move to the beginnign of the array
        if ($SQLextra['order_by'] != '') {
            $SQLextra = array_merge(array('order_by' => $SQLextra['order_by']), $SQLextra);
        }
        if (is_array($SQLextra)) {
            foreach ($SQLextra as $key => $value) {
                $query_extra .= $value;
            }
        }
        #Put in $P the values of what is queried, add to cols, if not already there, whatever is queried. Check if there are regular expressions anywhere. equalit will be replace by the regular expression
        $cols = $GLOBALS['dbstruct'][$table];
        foreach ($cols as $col) {
            if ($s3ql['where'][$col] != '') {
                if (!in_array($col, $GLOBALS['COREids']) && $col != $GLOBALS['COREids'][$element]) {
                    $user_query_fields .= ' and ' . $col . '  ' . parse_regexp($s3ql['where'][$col]);
                }
                $P[$col] = parse_regexp($s3ql['where'][$col]);
            }
        }
        #when the default query is performed, that is, not shared ids are requested, the query is faster is core_id are added
        if (!$shared) {
            if (is_array($s3ql['where']) && !empty($s3ql['where'])) {
                foreach ($s3ql['where'] as $q_field => $q_value) {
                    if (in_array($q_field, $GLOBALS['COREids']) || $q_field == $GLOBALS['COREids'][$element]) {
                        $sql_col = str_replace($toreplace, $replacements, $q_field);
                        if (!ereg('U|G', $letter)) {
                            ## Users and groups do not have the reousrce in the users table
                            $user_query_fields .= ' and ' . $sql_col . ' ' . parse_regexp($q_value);
                        } else {
                            #Because users queries do not include the parent_id in the talbe itself, they will involve a query in perm table
                            #$u_uid=letter($q_field).$q_value;
                        }
                    }
                }
            }
        }
        #glue them together.
        $user_query .= $user_query_fields . $query_extra;
        if ($timer) {
            $timer->setMarker('done building query');
        }
        ###Finally perform the query on whatever table is specified
        #$user_query = "select * from s3db_resource where resource_class_id = '389';";
        #if($_REQUEST['su3d']){
        #echo $user_query;
        #$timer->display();
        #exit;
        #}
        ##run it
        #complete query on LOCAL resources
        $db->query($user_query, __LINE__, __FILE__);
        $dbdata = get_object_vars($db);
        if ($timer) {
            $timer->setMarker('done with query');
        }
        if ($dbdata['Errno'] != '0') {
            return formatReturn($GLOBALS['error_codes']['something_went_wrong'], $dbdata['Error'], $format, '');
        }
        #put it in a nice structured variable
        $cols = $GLOBALS['dbstruct'][$target];
        if (is_array($returnFields) && $extracol == '') {
            $cols = array_unique(array_merge($cols, $returnFields));
        }
        #echo '<pre>';print_r($cols);
        while ($db->next_record()) {
            #echo '<pre>';print_r($db);
            $resultStr .= "\$data[] = Array(";
            if ($extracol != '') {
                $resultStr .= "'" . $extracol . "'=>'" . $db->f($SQLfun) . "',";
            }
            foreach ($cols as $col) {
                $resultStr .= "'" . $col . "'=>'" . addslashes($db->f($col)) . "'";
                if ($col != end($cols)) {
                    $resultStr .= ",";
                }
                if ($col == $GLOBALS['s3ids'][$target]) {
                    $retrieved['ids_str'] .= $retrieved['ids_str'] == '' ? $db->f($col) : '|' . $db->f($col);
                }
            }
            $resultStr .= ");";
        }
        #echo $resultStr;
        #evaluate the long string
        eval($resultStr);
        if (is_array($data)) {
            $data = array_filter($data);
        }
        if ($timer) {
            $timer->setMarker('query results captured');
        }
        #more often than not, a query is made that retrieves all rules/collection data; this data can be reused for permission migration
        if ($user_query_fields == "" && $SQLextra == "") {
            $all_data[letter($target)] = $data;
        }
        #BEFORE outputting data, are there any remote resources where the user is allowed?
        $ucode = strtoupper(substr($element, 0, 1));
        $ucode_and_id = $ucode . $element_id;
        ##Added ability to search locally on april 15 2008 to optimize queries
        ###Added ability to seeek permissions from file on jan 12 2009 to speed permissiosn query
        if (!ereg('users|groups|projects|keys|rulelog|statementlog|permission', $s3ql['from']) && !ereg('true|1', $s3ql['where']['local'])) {
            #REMOTE USERS< GROUPS< PROJECTS ARE INSERTED INTO DEPLOYMENT,M NO NEED TO FIND THEM AGAIN
            ##Added ability to search locally on april 15 to optimize queries
            ###Added ability to seeek permissions from file on jan 12 2009 to speed permissiosn query
            list($remoteIDS, $local_not_native) = remotePermissions(compact('s3ql', 'self_id', 'uidQuery', 'permissionsQuery', 'user_id', 'db', 'timer', 'shared_with_query', 'user_self_query', 'letter'));
            if ($timer) {
                $timer->setMarker('remote permisions queried');
            }
            ##NOTE: Local_not_native data need to be retrieve as well
            if (is_array($remoteIDS) && !empty($remoteIDS)) {
                foreach ($remoteIDS as $rem_id) {
                    #$rem_uid = substr($rem_id['uid'],1,strlen($rem_id['uid']));
                    $rem_uid = $rem_id['uid'];
                    $rem_resource_data = URIinfo($rem_uid, $user_id, $s3ql['key'], $db);
                    #echo '<pre>';print_r($rem_resource_data);exit;
                    if (is_array($rem_resource_data)) {
                        $rem_resource_data['shared_with'] = $rem_id['shared_with'];
                        $rem_resource_data['uid'] = $rem_id['uid'];
                        $rem_resource_data['permission_level'] = $rem_id['permission_level'];
                    }
                    #echo '<pre>';print_r($rem_resource_data);exit;
                    #concatenate them in the results; THIS SHOWS ONLY REMOTE RESOURCES THAT ARE AVAILABLE AT THE MOMENT!
                    if (is_array($s3ql['where'])) {
                        foreach ($s3ql['where'] as $query_field => $query_value) {
                            if ($query_value != $rem_resource_data[$query_field]) {
                                if (!in_array($query_field, $GLOBALS['COREids'])) {
                                    $rem_resource_data = array();
                                }
                            }
                        }
                    }
                    if (is_array($data) && is_array($rem_resource_data)) {
                        array_push($data, $rem_resource_data);
                    } elseif (is_array($rem_resource_data) && !empty($rem_resource_data)) {
                        $data[] = $rem_resource_data;
                    }
                }
                if ($timer) {
                    $timer->setMarker('Remote data retrieved');
                }
            }
        }
        if (is_array($data)) {
            $data = array_filter($data);
        }
        #now we're ready to display the data
        $pack = compact('data', 'whereScore', 'WhereInfo', 'fromScore', 's3ql', 'key', 'target', 'db', 'user_id', 'cols', 'returnFields', 's3ql_out', 'target', 'uidQuery', 'timer', 'shared_with_query', 'all_data', 'letter', 'model');
        if (!ereg('keys|accesslog|rulelog|statementlog|permission', $s3ql['from'])) {
            $data = includeAllData($pack);
        }
    }
    ##if complete was requested, let's retrieve every link and distribute accordingly rather that querying by uid, would would take much longer
    if ($complete) {
        $alluid = array();
        foreach ($data as $kuid => $data_info) {
            array_push($alluid, $letter . $data_info[$GLOBALS['s3ids'][$element]]);
        }
        include_once S3DB_SERVER_ROOT . '/s3dbcore/dictionary.php';
        $s3qlL = compact('user_id', 'db');
        $s3qlL['from'] = 'links';
        $formatL = 'array';
        $links = query_user_dictionaries($s3qlL, $db, $user_id, $formatL);
        if (is_array($links) && !empty($links)) {
            foreach ($links as $moreData) {
                if ($moreData['uid'] != '') {
                    $foundIt = array_search($moreData['uid'], $alluid);
                    if ($foundIt) {
                        $data[$foundIt]['links'][$moreData['relation']] = $moreData['value'];
                    }
                    #$data[$moreData['uid']]['links'][$moreData['relation']]=$moreData['value'];
                }
            }
        }
        if ($timer) {
            $timer->setMarker('Dictionary data included!');
        }
    }
    if (is_array($data) && !empty($data)) {
        $data = array_combine(range(0, count($data) - 1), $data);
        return $data;
    } else {
        #$emptycols = array(array_combine($cols, array_fill(1,count($cols), '')));
        #echo '<pre>';print_r($emptycols);exit;
        return array();
        #return formatReturn($GLOBALS['error_codes']['no_results'], 'Your query returned no results', $format,'');
    }
}
Beispiel #11
0
                    <dt>
                    <?php 
    echo date('Y年n月j日', strtotime($value["create_date"]));
    ?>
                    <span class="tagCat">
                    <?php 
    echo getCat($value["news_cat"]);
    ?>
</span>
                    </dt>
                    <dd>
                        <a href="news.php?news_id=<?php 
    echo $value["news_id"];
    ?>
"><?php 
    echo letter($value["news_title"], 10);
    ?>
</a>
                    </dd>
            <?php 
}
?>
            </dl>
            <p class="more"><a href="newsList.php">ニュース一覧を見る</a></p>
        </div>
    </section>
    <section class="featureArea">
        <h3>FEATURE<br><span>特徴</span></h3>
        <div class="featureContent">
            <ul>
                <li><figure><img src="images/point1.png" alt="一流職人によるチーズ作り指導"></figure></li>
Beispiel #12
0
function class_triples($triples, $root, $specified_id, $specified_id_info, $s3Types, $user_id, $db, $inputs, $s3db = array(), $fork = 0, $nest = 0)
{
    $s3idNames = $GLOBALS['COREids'];
    ##this is the else, but since we re returninng...
    foreach ($s3Types[$root] as $k => $a_class) {
        $uid_p = letter($specified_id) . $specified_id_info[$specified_id];
        #each class has a descriptive statement
        $a_class_id = $s3idNames[$a_class];
        $a_class_letter = strtoupper(substr($a_class, 0, 1));
        $a_class_type = $GLOBALS['s3codes'][$a_class_letter];
        $s3ql = compact('user_id', 'db');
        $s3ql['select'] = '*';
        $s3ql['from'] = $GLOBALS['plurals'][$a_class];
        $s3ql['where'][$specified_id] = $specified_id_info[$specified_id];
        if (ereg('(rule|statement)', $a_class_type)) {
            $s3ql['where']['object'] = "!=UID";
        }
        $subClasses = S3QLaction($s3ql);
        #find them, output them.
        #$verbs=array();
        $s3db[$uid_p][letter($a_class)] = $subClasses;
        #triples for teh rdf api
        $subClassTriples = rdf_encode($subClasses, letter($GLOBALS['plurals'][$a_class]), 'array', $db, $namespaces, $subClasses);
        if (!empty($subClassTriples)) {
            $triples = array_merge($triples, $subClassTriples);
        }
        if (is_array($subClasses) && is_array($s3Types[$a_class])) {
            ##prepare triples for the rdf-api
            foreach ($subClasses as $subSub => $subSubInfo) {
                if ($inputs['all'] == 1 || $a_class == 'collection' && $subSubInfo['name'] == 's3dbVerb') {
                    $triples = class_triples($triples, $a_class, $a_class_id, $subSubInfo, $s3Types, $user_id, $db, $s3db, $fork, $nest = 1);
                }
            }
        }
        $nest = 0;
        $fork++;
    }
    return $triples;
}
Beispiel #13
0
function rootIDinfo($s3idNames, $REQUESTdat, $argv, $user_id, $key, $db)
{
    if (!in_array('uid', array_keys($REQUESTdat))) {
        $specified_id = array_intersect($s3idNames, array_keys($REQUESTdat));
    } else {
        $specified_id = $GLOBALS['COREletterInv'][letter($REQUESTdat['uid'])];
    }
    #echo '<pre>';print_r($REQUESTdat);exit;
    if (count($specified_id) != '1') {
        if (is_array($argv)) {
            $inData = array_diff($argv, array($key, 'rdf.php'));
        }
        if (is_array($inData)) {
            foreach ($inData as $key => $value) {
                list($idname[], $id[]) = explode('=', $value);
            }
            $specified_id = array_intersect($s3idNames, $idname);
        }
        if (count($specified_id) != '1') {
            echo $GLOBALS['messages']['something_missing'] . "<message>Please specify 1 and only 1 id for the root of the ontology</message>";
            exit;
        } else {
            $inData = array_combine($idname, $id);
            $rootID = $id[0];
            $specified_id = $idname[0];
        }
    } else {
        $inData = $REQUESTdat;
        $specified_id = array_combine(array('0'), $specified_id);
        $specified_id = $specified_id[0];
        $rootID = $REQUESTdat[$specified_id];
        if ($rootID == '') {
            $rootID = ereg_replace('^' . letter($REQUESTdat['uid']), '', $REQUESTdat['uid']);
            $specified_id = $GLOBALS['COREletterInv'][letter($REQUESTdat['uid'])];
        }
    }
    $specified_id_type = array_search($specified_id, $s3idNames);
    $letter = strtoupper(substr($specified_id, 0, 1));
    $specified_id_info = URIinfo($letter . $rootID, $user_id, $key, $db);
    return compact('letter', 'specified_id', 'specified_id_type', 'specified_id_info', 'inData', 'rootID');
}
Beispiel #14
0
function triplize_data($data, $letter, $namespaces, $db = array(), $user_id, $collected_data = array())
{
    #any more namespaces?
    $usedNS = array('' => $GLOBALS['URI'], 'dc' => 'http://purl.org/dc/terms/', 's3db' => 'http://www.s3db.org/core#', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#');
    if ($namespaces) {
        foreach ($namespaces as $nInfo) {
            if ($nInfo['qname'] && $nInfo['url']) {
                if (!in_array($nInfo['qname'], array_keys($usedNS))) {
                    #define($nInfo['qname'], $nInfo['url']);
                    if (!ereg('(\\#|\\/)$', $nInfo['url'])) {
                        $nInfo['url'] = $nInfo['url'] . '#';
                    }
                    $usedNS[$nInfo['qname']] = $nInfo['url'];
                }
            }
        }
    }
    ##without a letter, we need to know what type of data is this - dictionary data?
    if (!$letter || !ereg('D|P|S|I|C|R|U|G', $letter)) {
        foreach ($data as $d => $tuple) {
            if ($tuple['link_id']) {
                #good, this is actual links - do not reify them
                #what will be the URI of the uid?
                $D = S3DB_URI_BASE;
                $property = $tuple['relation'];
                $value = $tuple['value'];
                $nsV = "";
                $termV = "";
                $nsP = "";
                $termP = "";
                list($nsP, $termP) = explode(":", $tuple['relation']);
                list($nsV, $termV) = explode(":", $tuple['value']);
                $s = $D . '/' . $tuple['uid'];
                $triple['s'] = $s;
                if ($nsP && $termP) {
                    if ($usedNS[$nsP] != "") {
                        $triple['p'] = str_replace($nsP . ":", eregi("#\$", $usedNS[$nsP]) ? $usedNS[$nsP] : $usedNS[$nsP] . "#", $property);
                        $triple['p_type'] = 'uri';
                    }
                }
                if ($nsV && $termV) {
                    if ($usedNS[$nsV] != "") {
                        $triple['o'] = str_replace($nsV . ':', eregi("#\$", $usedNS[$nsV]) ? $usedNS[$nsV] : $usedNS[$nsV] . "#", $value);
                        $triple['o_type'] = 'uri';
                    }
                } else {
                    $triple['o'] = $value;
                    if (ereg('^http', $value)) {
                        $triple['o_type'] = 'uri';
                    } else {
                        $triple['o_type'] = 'literal';
                    }
                }
            }
            if ($triple) {
                $triples[] = $triple;
            }
        }
    } else {
        #put data in the triple structure required by the parser
        foreach ($data as $ind => $res_data) {
            #which element are we trying to retrieve?
            $ID = $res_data[$GLOBALS['COREletterInv'][$letter]];
            $D = S3DB_URI_BASE;
            $s = $D . '/' . $letter . $ID;
            foreach ($res_data as $property => $value) {
                $nsV = "";
                $termV = "";
                $nsP = "";
                $termP = "";
                list($nsP, $termP) = explode(":", $property);
                list($nsV, $termV) = explode(":", $value);
                if (!empty($value)) {
                    if (@in_array($property, @array_keys($GLOBALS['propertyURI'][$letter]))) {
                        $p = $GLOBALS['propertyURI'][$letter][$property];
                        if (in_array($property, array_keys($GLOBALS['pointer']))) {
                            $o = $D . '/' . letter($GLOBALS['pointer'][$property]) . $value;
                            $otype = 'uri';
                        } elseif (in_array($property, $GLOBALS['COREids'])) {
                            $o = $D . '/' . letter($property) . $value;
                            $otype = 'uri';
                        } elseif ($property == 'value' && !empty($collected_data) && $collected_data[$res_data['rule_id']]['object_id'] != "") {
                            $o = $D . '/I' . $value;
                            $otype = 'uri';
                        } elseif ($property == 'value' && !empty($db) && RuleHasObjectId($ID, $db)) {
                            $o = $D . '/I' . $value;
                            $otype = 'uri';
                        } else {
                            $o = $value;
                            $otype = 'literal';
                        }
                        $triple['s'] = $s;
                        $triple['p'] = $p;
                        $triple['o'] = $o;
                        $triple['s_type'] = 'uri';
                        $triple['o_type'] = $otype;
                        $triples[] = $triple;
                    } elseif ($nsP && $termP) {
                        #replace nsP by the corresponding namespace and build a triple
                        if ($usedNS[$nsP] != "") {
                            $triple['s'] = $s;
                            $triple['s_type'] = 'uri';
                            $triple['p'] = str_replace($nsP . ":", eregi("#\$", $usedNS[$nsP]) ? $usedNS[$nsP] : $usedNS[$nsP] . "#", $property);
                        }
                        if ($nsV && $termV) {
                            if ($usedNS[$nsV] != "") {
                                $triple['o'] = str_replace($nsV . ':', eregi("#\$", $usedNS[$nsV]) ? $usedNS[$nsV] : $usedNS[$nsV] . "#", $value);
                                $triple['o_type'] = 'uri';
                            }
                        } else {
                            $triple['o'] = $value;
                            if (ereg('^http', $value)) {
                                $triple['o_type'] = 'uri';
                            } else {
                                $triple['o_type'] = 'literal';
                            }
                        }
                        if ($triple) {
                            $triples[] = $triple;
                        }
                    }
                }
            }
            if ($letter == 'S') {
                ##Outputalso a statment for the unserialized statement where subject is item_id, pred is rule, object is value
                if (!empty($collected_data) && !empty($collected_data[$data[$ind]['rule_id']]) && $collected_data[$data[$ind]['rule_id']]['object_id']) {
                    $obj = $D . '/I' . $data[$ind]['value'];
                    $objType = 'uri';
                } elseif (!empty($db) && RuleHasObjectId($ID, $db)) {
                    $obj = $D . '/I' . $data[$ind]['value'];
                    $objType = 'uri';
                } else {
                    $obj = $data[$ind]['value'];
                    $objType = 'literal';
                }
                $triple['s'] = $D . '/I' . $data[$ind]['item_id'];
                $triple['p'] = $D . '/R' . $data[$ind]['rule_id'];
                $triple['o'] = $obj;
                $triple['s_type'] = 'uri';
                $triple['o_type'] = $objType;
                $triples[] = $triple;
            }
            #And for every element that is part of the core, output a statement that mentions where in the ontology they belong
            $triple['s'] = $D . '/' . $letter . $ID;
            $triple['p'] = $usedNS['rdf'] . "type";
            $triple['o'] = $usedNS['s3db'] . $GLOBALS['N3Names'][$GLOBALS['s3codes'][$letter]];
            $triple['s_type'] = 'uri';
            $triple['o_type'] = 'uri';
            $triples[] = $triple;
        }
    }
    return $triples;
}
Beispiel #15
0
function permissionPropagation($Z)
{
    #NEW NEW
    extract($Z);
    $model = 'nsy';
    ##Seems to be working; requires further testing
    ##This vector is an indication of what propagates from the user
    $X = user_centric_propagation_list($user_id, $db);
    ##If $X includes roles, percolate the user allowed list to those roles
    if (is_array($X)) {
        foreach ($X as $X_uid => $X_pl) {
            if (substr($X_uid, 0, 1) == 'U') {
                $role = substr($X_uid, 1, strlen($X_uid));
                $roles[] = role_propagation_list($role, $db, $X_pl);
            }
        }
    }
    ##Now merge all the roles into X
    if (is_array($roles)) {
        foreach ($roles as $r => $role_X) {
            foreach ($role_X as $uid1 => $pl1) {
                if ($X[$uid1]) {
                    $tmp = s3dbMerge(array($X[$uid1], $pl1));
                    $X[$uid1] = $tmp;
                } else {
                    $X[$uid1] = $pl1;
                }
            }
        }
    }
    ##FIRST: Colect every relation from the permissions table
    #According to the amount of data that needs to be discovered to build the matrix, the bottom up, top-down,or middle point approach will be selected.
    if ($toFind != letter($toFind)) {
        $Hlist = bottom_up_propagation_list($toFind, $db, $X);
    } elseif ($toFind == letter($toFind) && !$shared_with_query) {
        $X = user_centric_propagation_list($user_id, $db);
        #Find the initial propagation list by finding all of the resources in the class of the requested resource
        if (is_array($X)) {
            $starter = array_keys($X);
        }
        $Hlist = top_down_propagation_list($toFind, $starter, $db, $toFindInfo);
    } elseif ($shared_with_query) {
        #when a uid is specified, propagation will only occur form that point onwards
        $Hlist = array();
        foreach ($shared_with_query as $up) {
            $Hlist = bottom_up_propagation_list($up, $db, $X, $Hlist);
        }
        $Hlist = top_down_propagation_list($toFind, $shared_with_query, $db, $Hlist);
    }
    #now find the vector that will be used to propagate the permissions: the one captured from downtream finding permissions the user may have;
    #if(is_array($Hlist))
    if (is_array($X)) {
        #convert pl to the right model
        $model_p = str_split($model);
        foreach ($X as $key_id => $key_pl) {
            $X[$key_id] = str_ireplace(array('0', '1', '2'), $model_p, $key_pl);
        }
        if (is_array($X) && is_array($Hlist)) {
            $result = s3dbPercolate($Hlist, $X, $toFind, $result = array(), $u = 1, $state = 3, $model);
        }
    } else {
        $result = $X;
    }
    if (is_array($result)) {
        if ($model == '012') {
            foreach ($result as $a => $b) {
                $result[$a] = str_ireplace(array('n', 's', 'y'), array('0', '1', '2'), $b);
            }
        } elseif ($model == 'nsy') {
            foreach ($result as $a => $b) {
                $result[$a] = str_ireplace(array('0', '1', '2'), array('n', 's', 'y'), $b);
            }
        }
    }
    if ($timer) {
        $timer->setMarker('Permissions percolated for ' . $toFind);
    }
    #$timer->display();
    return $result;
}
Beispiel #16
0
<html>
<body>
<?php 
require_once 'functions.php';
$as = digits(23);
//echo(int) $as.'dfs'.'<br>';
$a = letter('123');
//echo(int) $a.'asd'.'<br>';
$b = checklength('adfdkzisdmfjk', 3, 9);
//echo(int) $b.'sd'.'<br>';
$d = checkmail('asd-432', 'CA');
//echo(int)$d.'fcxgxd'.'<br>';
$check = checkurl('http//www.someone.co');
//echo(int) $check.'sdg'.'<br.';
$emails = checkemail('*****@*****.**');
//echo(int) $emails.'sdaerg'.'<br>';
$pass = checkpassword('rishu-23');
echo (int) $pass . '<br>';
?>

</body>
</html>