Exemplo n.º 1
0
<?php

require_once 'common.php';
require_once 'externals.php';
require_session();
if (isset($_POST['annotations'])) {
    // user clicked specialise without saving the annotations
    annotate();
}
$filename = $_SESSION['filename'];
$plfile = $_SESSION['plfile'];
$annfile = $_SESSION['annfile'];
function get_opt_and_save($name)
{
    $_SESSION[$name] = isset($_POST[$name]) ? 'on' : 'off';
    return $_SESSION[$name];
}
// have to do it this way since there's no difference between a disabled
// checkbox and an uncheck one. This way all options don't revert to off
// when you disable watch mode.
if (get_opt_and_save('watch') == 'on') {
    $watch_opts = array('enabled' => true, 'builtins' => get_opt_and_save('watch_builtins'), 'connectives' => get_opt_and_save('watch_connectives'), 'infunfold' => get_opt_and_save('watch_infunfold'), 'infmemo' => get_opt_and_save('watch_infmemo'), 'backprop' => get_opt_and_save('watch_backprop'));
} else {
    $watch_opts = array('enabled' => false);
}
$_SESSION['logging'] = $logging = $_POST['logging'];
$_SESSION['goal'] = $goal = $_POST['goal'];
$spec = isset($_POST['submit']) && $_POST['submit'] == 'Create GX' ? 2 : 1;
$tempdir = get_directory();
$file = fopen("{$tempdir}/{$filename}", "w");
fwrite($file, $_SESSION['plfile']);
Exemplo n.º 2
0
function get_operations_by_name($path, $parent_id = -1)
{
    global $operation_by_name_stmt;
    $names = preg_split('/\\//', $path, 2);
    $current = $names[0];
    $remaining = $names[1];
    preg_match('/^(?P<name>.*)\\((?P<count>.*)\\)$/', $current, $matches);
    $name = $matches['name'];
    $count = $matches['count'];
    $operation_by_name_stmt->bindParam('parent', $parent_id);
    $operation_by_name_stmt->bindParam('name', $name);
    $operation_by_name_stmt->execute();
    $ops_array = array();
    while ($op = $operation_by_name_stmt->fetch(PDO::FETCH_ASSOC)) {
        $ops_array[] = $op;
    }
    $operation_by_name_stmt->closeCursor();
    $result = array();
    $i = 0;
    foreach ($ops_array as $op) {
        if ($count == '*' || intval($count) == $i) {
            if ($remaining == '') {
                $result[] = annotate($op);
            } else {
                $more_ops = get_operations_by_name($remaining, intval($op['id']));
                $result = array_merge($result, $more_ops);
            }
        }
        $i++;
    }
    return $result;
}