Ejemplo n.º 1
0
function run($name, $cmdline_input)
{
    //		$cmdline_input = ""; // run the test very quickly
    global $prefix;
    $filename = "{$prefix}/{$name}.php";
    // run it in php first
    $time = run_php($filename, $cmdline_input);
    print "PHP: {$name}: {$time}";
    if ($time > 30 or $time < 20) {
        print " - Test outside time range\n";
    }
    print "\n";
    // run it with phc
    $time = run_phc($filename, $name, $cmdline_input);
    print "phc: {$name}: {$time}\n";
}
Ejemplo n.º 2
0
function run($name, $cmdline_input)
{
    global $date;
    $filename = "{$name}.php";
    // run it in php first
    $time = run_php($filename, $cmdline_input);
    print "PHP: " . basename($name) . ": {$time}";
    print "\n";
    $php_res = fopen("results/php_{$date}.txt", "a");
    fwrite($php_res, basename($name) . "     " . $time . "\n");
    fclose($php_res);
    // run it with phc
    $time = run_phc($filename, $name, $cmdline_input);
    print "phc: " . basename($name) . ": {$time}\n";
    $phc_res = fopen("results/phc_{$date}.txt", "a");
    fwrite($phc_res, basename($name) . "     " . $time . "\n");
    fclose($phc_res);
}
Ejemplo n.º 3
0
function run_php($dest = false)
{
    if ($dest) {
        # if it has a : it must be a full URL, redirect
        if (strpos($dest, ':')) {
            redirect($dest);
            exit;
        }
        # if it starts with './' then it's a relative URL, redirect
        if (substr($dest, 0, 2) == './') {
            redirect(ereg_replace('/[^/]*$', substr($dest, 1), this_url()));
            exit;
        }
        # otherwise, it's a normal basename, display that content
        $basename = $dest;
    } else {
        # no dest arg
        $basename = $_SERVER['REDIRECT_URL'];
        $basename = ereg_replace('.*/', '', $basename);
        $basename = ereg_replace('\\.html$', '', $basename);
        if ($basename == '') {
            $basename = 'index';
        }
    }
    $html_file = "{$basename}.html";
    $php_file = "{$basename}.php";
    $html_exists = file_exists($html_file);
    $php_exists = file_exists($php_file);
    # cms_get can return one of:
    # 1) false to indicate that there's no cms content for this basename
    # 2) a string to request a soft/full redirect just like foo_main()
    # 3) a hash of key/value pairs to be added to the template
    if (function_exists('cms_get')) {
        $cms_content = cms_get($basename);
        if (is_string($cms_content)) {
            run_php($cms_content);
            return;
        }
    }
    if ($php_exists) {
        # files can return a basename or URL of a page to be run/displayed
        $other = file_run($php_file);
        if ($other) {
            run_php($other);
            return;
        }
    } elseif ($html_exists) {
        readfile($html_file);
        exit;
    } elseif (!$cms_content) {
        header('HTTP/1.0 404 File Not Found');
        if (file_exists('404.php') || file_exists('404.html')) {
            run_php('404');
            return;
        } else {
            echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>404</title></head><body><h1>404 File Not Found</h1></body></html>';
        }
    }
    $data =& $GLOBALS['wfpl_template'];
    $data['basename'] = $basename;
    if ($cms_content) {
        foreach ($cms_content as $name => $value) {
            $data[$name] .= $value;
        }
    }
    if (file_exists("{$basename}.css")) {
        $data['css_link'] = "{$basename}.css";
    }
    if (file_exists("template.html")) {
        $template = parse_template_file("template.html");
        if ($html_exists) {
            $subs = parse_template_file($html_file);
            $template = merge_templates($template, $subs);
        }
    } elseif ($html_exists) {
        $template = parse_template_file("{$html_file}");
    }
    if ($template) {
        print fill_template($data, $template);
    }
}