コード例 #1
0
ファイル: signOut.php プロジェクト: necktwi/ferry
        $liveDBTable = getLiveTable($tid);
        foreach ($liveDBTable['dbtUpdates'] as $key => &$update) {
            if ($update['data']['swallowedBy'][$_SESSION['uid']]) {
                unset($update['data']['swallowedBy'][$_SESSION['uid']]);
            }
            if (count($sdbtu['data']['swallowedBy']) == count($liveDBTable['usersData']) - 1) {
                unset($liveDBTable['dbtUpdates'][$key]);
            }
        }
        if ($liveDBTable['usersData'][$_SESSION['uid']] and count($liveDBTable['usersData']) == 1) {
            $liveDBTable = null;
            closeLiveTable($tid, $liveDBTable);
            removeLiveTable($tid);
        } else {
            unset($liveDBTable['usersData'][$_SESSION['uid']]);
            closeLiveTable($tid, $liveDBTable);
        }
    }
}
//Destroy session log
$slKey = $key;
$slSemId = sem_get($slKey);
$slShmId = shm_attach($slKey, 1000000);
$sa = sem_acquire($slSemId);
$sessionLog = shm_get_var($slShmId, $slKey);
unset($sessionLog[$_SESSION['uid']]);
$spv = shm_put_var($slShmId, $slKey, $sessionLog);
$sr = sem_release($slSemId);
//$mysql_close = mysql_close();
$session_destroy = session_destroy();
echo "<status>signedOut</status>";
コード例 #2
0
ファイル: dbTableExecuter.php プロジェクト: necktwi/ferry
function computeSourceCells($formula, $dbTable, $ccid, $crid, $cpid, &$aPSCs, $sciri, &$dbtUpdate)
{
    function getCells($cid, $ri, $tid, &$liveDBTable, &$sCs, &$tp, &$dbtUpdate, $sciri, $dbTable, $ccid)
    {
        $cid = $cid == 'index' ? $ccid : $cid;
        if ($cid[0] == '/') {
            foreach ($liveDBTable['cells'][$ri] as $ci => $cell) {
                if (preg_match($cid, $ci)) {
                    array_push($sCs, $ci . "," . ($ri != 'tHR' ? $liveDBTable['cells'][$ri][$liveDBTable['priCol']]['innerHTML'] : "") . ($tid != $dbTable ? "," . $tid : ''));
                    $tp[$ri][$ci]['f']['ee'][] = $tid == $dbTable ? $sciri : $sciri . "," . $dbTable;
                    $dbtUpdate['tables'][$tid]['cells'][$ri][$ci]['f']['ee'] = $tp[$ri][$ci]['f']['ee'] = true_array_unique($tp[$ri][$ci]['f']['ee']);
                }
            }
        } elseif ($cid[0] == '*') {
            array_push($sCs, "index," . ($ri != 'tHR' ? $liveDBTable['cells'][$ri][$liveDBTable['priCol']]['innerHTML'] : "") . "," . ($tid != $dbTable ? "," . $tid : ''));
        } elseif (count($cids = split('~', $cid)) > 1) {
            $rangeE = FALSE;
            foreach ($liveDBTable['cells']['tHR'] as $ci => $cell) {
                if (($ci == $cids[0] or $rangeS) and !$rangeE) {
                    $rangeS = true;
                    if ($ci == $cids[1]) {
                        $rangeE = true;
                    }
                    $rcells[] = $ci;
                }
            }
            if ($rangeE) {
                foreach ($rcells as $rci => $ci) {
                    array_push($sCs, $ci . "," . ($ri != 'tHR' ? $liveDBTable['cells'][$ri][$liveDBTable['priCol']]['innerHTML'] : "") . ($tid != $dbTable ? "," . $tid : ''));
                    $tp[$ri][$ci]['f']['ee'][] = $tid == $dbTable ? $sciri : $sciri . "," . $dbTable;
                    $dbtUpdate['tables'][$tid]['cells'][$ri][$ci]['f']['ee'] = $tp[$ri][$ci]['f']['ee'] = true_array_unique($tp[$ri][$ci]['f']['ee']);
                }
            }
        } elseif ($cid != '') {
            if (isset($liveDBTable['cells'][$ri][$cid])) {
                array_push($sCs, $cid . "," . ($ri != 'tHR' ? $liveDBTable['cells'][$ri][$liveDBTable['priCol']]['innerHTML'] : "") . ($tid != $dbTable ? "," . $tid : ''));
                $tp[$ri][$cid]['f']['ee'][] = $tid == $dbTable ? $sciri : $sciri . "," . $dbTable;
                $dbtUpdate['tables'][$tid]['cells'][$ri][$cid]['f']['ee'] = $tp[$ri][$cid]['f']['ee'] = true_array_unique($tp[$ri][$cid]['f']['ee']);
            }
        }
    }
    $fx = $formula;
    $sCs = array();
    $matches = array();
    preg_match_all('/[0-9a-zA-Z_~]+\\([0-9a-zA-Z_~*]*\\)\\([0-9a-zA-Z_]*\\)/i', $formula, $matches);
    foreach ($matches[0] as $key => &$match) {
        $ml = strlen($match);
        $rstart = strpos($match, '(', 0);
        $rend = strpos($match, ')', 0);
        $rid = substr($match, $rstart + 1, $rend - $rstart - 1);
        $tstart = strpos($match, '(', $rstart + 1);
        $tid = substr($match, $tstart + 1, $ml - $tstart - 2);
        if ($_SESSION['tables'][$tid]) {
            $liveDBTable = getLiveTable($tid);
            $tp = getTableFromFile($tid);
            if ($ca = $aPSCs[$tid]) {
                foreach ($ca as $i => $c) {
                    $c[1] = $c[1] ? rowWithPid($liveDBTable, $c[1]) : 'tHR';
                    foreach ($tp[$c[1]][$c[0]]['f']['ee'] as $e => $ee) {
                        if ($ee == $sciri or $ee == $sciri . "," . $dbTable) {
                            unset($tp[$c[1]][$c[0]]['f']['ee'][$e]);
                            $dbtUpdate['tables'][$tid]['cells'][$c[1]][$c[0]]['f']['ee'] = $tp[$c[1]][$c[0]]['f']['ee'] = true_array_unique($tp[$c[1]][$c[0]]['f']['ee']);
                            break;
                        }
                    }
                }
                unset($aPSCs[$tid]);
            }
            $rid = substr($match, $rstart + 1, $rend - $rstart - 1);
            $cid = substr($match, 0, $rstart);
            if ($rid[0] == '/') {
                foreach ($liveDBTable['cells'] as $ri => $row) {
                    if (preg_match($rid, $row[$liveDBTable['priCol']])) {
                        getCells($cid, $ri, $tid, $liveDBTable, $sCs, $tp, $dbtUpdate, $sciri, $dbTable, $ccid);
                    }
                }
            } elseif ($rid[0] == '*') {
                getCells($cid, 'tHR', $tid, $liveDBTable, $sCs, $tp, $dbtUpdate, $sciri, $dbTable, $ccid);
            } elseif (count($rids = split('~', $rid)) > 1) {
                $rangeE = FALSE;
                foreach ($liveDBTable['cells'] as $ri => $row) {
                    if (($row[$liveDBTable['priCol']]['innerHTML'] == $rids[0] or $rangeS) and !$rangeE) {
                        $rangeS = true;
                        if ($row[$liveDBTable['priCol']]['innerHTML'] == $rids[1]) {
                            $rangeE = true;
                        }
                        $rrows[] = $ri;
                    }
                }
                if ($rangeE) {
                    foreach ($rrows as $kei => $ri) {
                        getCells($cid, $ri, $tid, $liveDBTable, $sCs, $tp, $dbtUpdate, $sciri, $dbTable, $ccid);
                    }
                }
            } elseif ($rid != '') {
                getCells($cid, rowWithPid($liveDBTable, $rid), $tid, $liveDBTable, $sCs, $tp, $dbtUpdate, $sciri, $dbTable, $ccid);
            } elseif ($rid == '') {
                getCells($cid, rowWithPid($liveDBTable, $cpid), $tid, $liveDBTable, $sCs, $tp, $dbtUpdate, $sciri, $dbTable, $ccid);
            }
            putTableInFile($tp, $tid);
            closeLiveTable($liveDBTable);
        }
        $k = 0;
        $formula = str_replace($match, 'var' . $k++, $formula);
    }
    $liveDBTable = getLiveTable($dbTable);
    $tp = getTableFromFile($dbTable);
    if ($ca = $aPSCs[$dbTable]) {
        foreach ($ca as $i => $c) {
            $c[1] = $c[1] ? rowWithPid($liveDBTable, $c[1]) : 'tHR';
            foreach ($tp[$c[1]][$c[0]]['f']['ee'] as $e => $ee) {
                if ($ee == $sciri or $ee == $sciri . "," . $dbTable) {
                    unset($tp[$c[1]][$c[0]]['f']['ee'][$e]);
                    $dbtUpdate['tables'][$dbTable]['cells'][$c[1]][$c[0]]['f']['ee'] = $tp[$c[1]][$c[0]]['f']['ee'] = true_array_unique($tp[$c[1]][$c[0]]['f']['ee']);
                    break;
                }
            }
        }
        unset($aPSCs[$dbTable]);
    }
    foreach ($liveDBTable['cells']['tHR'] as $colName => $column) {
        $start = 0;
        $start = strpos($formula, $colName, $start);
        while ($start > -1) {
            if (preg_match("/[^a-zA-Z0-9_]/", $formula[$start - 1]) or !$formula[$start - 1]) {
                $pst = $start;
                $start += strlen($colName);
                if ($formula[$pst - 1] != ';' and ($formula[$start] != '=' or $formula[$start + 1] == '=') and (preg_match("/[^a-zA-Z0-9_]/", $formula[$start]) or !$formula[$start])) {
                    $cid = $colName;
                    $row = '';
                    unset($col2);
                    if ($formula[$start++] == '~') {
                        foreach ($liveDBTable['cells']['tHR'] as $col2 => $column2) {
                            if (strpos($formula, $col2, $start) == $start) {
                                $colName2 = $col2;
                                break;
                            }
                        }
                    }
                    if ($col2 and $colName2 or !($col2 or $colName2)) {
                        $cid = $colName2 ? $cid . '~' . $colName2 : $cid;
                        $j = $start;
                        unset($rid);
                        while ($formula[$start - 1] == '(' and $formula[$j] != '' and $formula[$j] != ')') {
                            $rid .= $formula[$j++];
                        }
                        if ($rid) {
                            $start = ++$j;
                            if (count($rids = split('~', $rid)) > 1) {
                                $rangeE = FALSE;
                                $rrows = array();
                                foreach ($liveDBTable['cells'] as $ri => $row) {
                                    if (($row[$liveDBTable['priCol']]['innerHTML'] == $rids[0] or $rangeS) and !$rangeE) {
                                        $rangeS = true;
                                        if ($row[$liveDBTable['priCol']]['innerHTML'] == $rids[1]) {
                                            $rangeE = true;
                                        }
                                        $rrows[] = $ri;
                                    }
                                }
                                if ($rangeE) {
                                    foreach ($rrows as $kei => $ri) {
                                        getCells($cid, $ri, $dbTable, $liveDBTable, $sCs, $tp, $dbtUpdate, $sciri, $dbTable, $ccid);
                                    }
                                }
                            } elseif ($rid[0] == '/') {
                                foreach ($liveDBTable['cells'] as $ri => $row) {
                                    if (preg_match($rid, $row[$liveDBTable['priCol']])) {
                                        getCells($cid, $ri, $dbTable, $liveDBTable, $sCs, $tp, $dbtUpdate, $sciri, $dbTable, $ccid);
                                    }
                                }
                            } elseif ($rid == '*') {
                                getCells($cid, 'tHR', $dbTable, $liveDBTable, $sCs, $tp, $dbtUpdate, $sciri, $dbTable, $ccid);
                            } elseif ($rid != '' and $rid != ' ') {
                                getCells($cid, rowWithPid($liveDBTable, $rid), $dbTable, $liveDBTable, $sCs, $tp, $dbtUpdate, $sciri, $dbTable, $ccid);
                            }
                        } else {
                            getCells($cid, $crid, $dbTable, $liveDBTable, $sCs, $tp, $dbtUpdate, $sciri, $dbTable, $ccid);
                        }
                    }
                    $start = strpos($formula, $colName, $start);
                }
            } else {
                $start = strpos($formula, $colName, $start);
            }
        }
    }
    putTableInFile($tp, $dbTable);
    closeLiveTable($liveDBTable);
    foreach ($aPSCs as $tid => $ca) {
        $liveDBTable = getLiveTable($tid);
        $tp = getTableFromFile($tid);
        foreach ($ca as $i => $c) {
            $c[1] = $c[1] ? $c[1] : 'tHR';
            foreach ($tp[$c[1]][$c[0]]['f']['ee'] as $e => $ee) {
                if ($ee == $sciri or $ee == $sciri . "," . $dbTable) {
                    unset($tp[$c[1]][$c[0]]['f']['ee'][$e]);
                    $dbtUpdate['tables'][$tid]['cells'][$c[1]][$c[0]]['f']['ee'] = $tp[$c[1]][$c[0]]['f']['ee'] = true_array_unique($tp[$c[1]][$c[0]]['f']['ee']);
                    break;
                }
            }
        }
        putTableInFile($tp, $tid);
        closeLiveTable($liveDBTable);
        unset($aPSCs[$tid]);
    }
    $sCs = true_array_unique($sCs);
    return $sCs;
}
コード例 #3
0
ファイル: dbTableExecuterForm.php プロジェクト: necktwi/ferry
    </head>
    <body>
        <div id="dbTableExecuterBdy" class="gdgBody">
            <?php 
if (!$userAuthorizationInfo) {
    if ($result || $liveDBTable['liveD']) {
        if (!$authorizeTransit and !$sm) {
            echo "<span>U r not authorized to view the table ~:|~</span>";
        } else {
            include 'dbTableExecuterOpener.php';
        }
    } else {
        if (tableAllowed($dbTable)) {
            include 'dbTableExecuterCreator.php';
        } else {
            echo "<span class='display' id='dbTableExecuter'>Table don exist n u r not authorized to create table with this name.</span></body></html>";
        }
    }
} else {
    echo $userAuthorizationInfo;
}
?>
        </div>
    </body>
</html>

<?php 
/* $spv=shm_put_var($dbtShmId, $dbtKey, $liveDBTable);
  $sr=sem_release($dbtSemId); */
closeLiveTable($dbTable, &$liveDBTable);
include "db_logout.php";