예제 #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();
}
예제 #2
0
}
add("<h3>form_submit_receiver</h3>");
if ($_POST["textfield1"]) {
    add("<p>textfield1: " . htmlspecialchars($_POST["textfield1"]) . "</p>");
    add("<hr>");
}
if ($_POST["textarea1"]) {
    add("<p>textarea1: " . htmlspecialchars($_POST["textarea1"]) . "</p>");
    add("<hr>");
}
if ($_FILES["file1"]["size"]) {
    do_file($_FILES["file1"]);
    add("<hr>");
}
if ($_FILES["file2"]["size"]) {
    do_file($_FILES["file2"]);
    add("<hr>");
}
// or formelem via get
if ($_GET["textfield1"]) {
    add("<p>textarea1: " . htmlspecialchars($_GET["textfield1"]) . "</p>");
    add("<hr>");
}
$req_headers = getallheaders();
$async = $req_headers["X-Requested-With"] || $_GET["async"];
if ($async) {
    $callback = $_GET["callback"];
    if ($callback) {
        echo $callback . "('";
        // would need to escape ' in $res
    }
예제 #3
0
    $str = str_replace("\n", '\\n', $str);
    return $str;
}
function do_file($file)
{
    global $xpaths;
    try {
        $content = file_get_contents($file);
        if (!$content) {
            return;
        }
        $xml = new SimpleXMLElement($content);
        if (!$xml) {
            return;
        }
        foreach ($xpaths as $xpath) {
            $nodes = $xml->xpath($xpath);
            foreach ($nodes as $node) {
                $fs = fs($node);
                if ($fs) {
                    print 'gettext("' . fs($node) . '");' . "\n";
                }
            }
        }
    } catch (Exception $e) {
        return;
    }
}
for ($an = 1; $arg = $_SERVER["argv"][$an]; $an++) {
    do_file($arg);
}