Ejemplo n.º 1
0
function do_dir($dir)
{
    $d = dir($dir);
    while (false !== ($entry = $d->read())) {
        if ($entry == '.' || $entry == '..') {
            continue;
        }
        $entry = $dir . '/' . $entry;
        if (is_dir($entry)) {
            // if a directory, go through it
            do_dir($entry);
        } else {
            // if file, parse only if extension is matched
            $pi = pathinfo($entry);
            if (isset($pi['extension']) && in_array($pi['extension'], $GLOBALS['extensions'])) {
                do_file($entry);
            }
        }
    }
    $d->close();
}
Ejemplo n.º 2
0
    foreach ($_SERVER['argv'] as $index => $argv) {
        $argv = str_replace('\\\\', '\\', $argv);
        $_SERVER['argv'][$index] = $argv;
        $explode = explode('=', $argv, 2);
        if (count($explode) == 2) {
            $extra[$explode[0]] = trim($explode[1], '"');
            unset($_SERVER['argv'][$index]);
        }
    }
    $_SERVER['argv'] = array_merge($_SERVER['argv'], $extra);
    if (array_key_exists('path', $_SERVER['argv'])) {
        $GLOBALS['OCPORTAL_PATH'] = $_SERVER['argv']['path'];
    }
}
require dirname(__FILE__) . '/php.php';
$files = do_dir($OCPORTAL_PATH, true, true);
$files[] = 'phpstub.php';
$classes = array();
$global = array();
global $TO_USE;
//$files=array($OCPORTAL_PATH.'/sources/global2.php'); For debugging
foreach ($files as $filename) {
    if (!isset($_GET['debug'])) {
        if (strpos($filename, '_custom') !== false) {
            continue;
        }
    }
    if (basename($filename, '.php') == 'tempcode__runtime') {
        continue;
    }
    if (basename($filename, '.php') == 'tempcode_compiler__runtime') {
Ejemplo n.º 3
0
/**
 * Output the file selection page.
 *
 * @param  SHORT_TEXT	The password previously given to authorise our editing.
 */
function do_get_path($given_password)
{
    // Just to test a connection if one was requested
    $test = open_up_ftp_connection();
    if (is_string($test)) {
        echo '<h1 class="main_page_title">An FTP error occurred</h1>';
        echo '<p>' . code_editor_escape_html($test) . '</p>';
        return;
    }
    code_editor_do_header('gui');
    $files = do_dir('');
    sort($files);
    $paths = implode('', $files);
    foreach ($_POST as $key => $val) {
        $_key = code_editor_escape_html($key);
        $_val = code_editor_escape_html($val);
        echo <<<END
<input type="hidden" name="{$_key}" value="{$_val}" />
END;
    }
    echo <<<END
\t<h1 class="main_page_title">ocPortal Code Editor</h1>
\t<p>
\t\tNew File: <input type="text" name="path_new" />
\t</p>
\t<p>
\t\tOR, existing file: <select name="path">{$paths}</select>
\t</p>
\t<p class="proceed_button">
\t\t<input type="submit" value="Edit file" />
\t</p>
END;
}
Ejemplo n.º 4
0
} else {
    $FUNCTION_SIGNATURES = array();
}
// To get it started
if (isset($_GET['test'])) {
    $GLOBALS['API'] = 1;
    $GLOBALS['CHECKS'] = 1;
    $tests = get_tests();
    $parsed = parse(lex('<' . '?php' . "\n" . $tests[$_GET['test']] . "\n"));
    check($parsed);
} elseif (!isset($_GET['to_use']) && !isset($_SERVER['argv'][1])) {
    $avoid = array();
    if (isset($_GET['avoid'])) {
        $avoid = explode(',', $_GET['avoid']);
    }
    $files = do_dir($OCPORTAL_PATH . (isset($_GET['subdir']) ? '/' . $_GET['subdir'] : ''), true, false, $avoid);
    $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
    foreach ($files as $i => $to_use) {
        if ($i <= $start) {
            continue;
        }
        // Set to largest number we know so far work
        if (strpos(file_get_contents($to_use), '/*CQC: No check*/') !== false) {
            echo 'SKIP: ' . $to_use;
            continue;
        }
        check(parse_file($to_use, false, false, $i, count($files)));
    }
} else {
    $_to_use = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : $_GET['to_use'];
    if (isset($_SERVER['argv']) && array_key_exists('single', $_SERVER['argv'])) {
Ejemplo n.º 5
0
function do_dir($dir, $no_custom = false, $orig_priority = false, $avoid = NULL)
{
    $out = array();
    $_dir = $dir == '' ? '.' : $dir;
    $dh = opendir($_dir);
    if ($dh) {
        while (($file = readdir($dh)) !== false) {
            if (!is_null($avoid) && in_array($file, $avoid)) {
                continue;
            }
            if ((strpos($file, '_custom') !== false || $file == 'exports' || $file == '_tests' || $file == 'ocworld') && $no_custom) {
                continue;
            }
            if ($file[0] != '.') {
                if (is_file($_dir . DIRECTORY_SEPARATOR . $file)) {
                    if (substr($file, -4, 4) == '.php') {
                        $path = $dir . ($dir != '' ? DIRECTORY_SEPARATOR : '') . $file;
                        if ($orig_priority) {
                            $alt = str_replace('_custom', '', $path);
                        } else {
                            $alt = str_replace('modules/', 'modules_custom/', str_replace('sources/', 'sources_custom/', $path));
                        }
                        if ($alt == $path || !file_exists($alt)) {
                            $out[] = $path;
                        }
                    }
                } elseif (is_dir($_dir . DIRECTORY_SEPARATOR . $file)) {
                    $out = array_merge($out, do_dir($dir . ($dir != '' ? DIRECTORY_SEPARATOR : '') . $file, $no_custom, $orig_priority));
                }
            }
        }
    }
    return $out;
}