示例#1
0
<?php

define('ROOT_PATH', '');
require_once ROOT_PATH . 'functions.php';
restrictAccess('a');
//xuca
if (posted("directory")) {
    $directory = $_POST["directory"];
    if (is_dir($directory)) {
        require_class("fileToStr", "qParser");
        $f = new fileToStr();
        $qp = new qParser();
        echo "Processing directory {$directory}:<br>";
        foreach (glob($directory . '/*.*') as $file) {
            echo " " . $file . " parsed:<br><textarea>" . $qp->parse($f->convert($file, $file)) . "</textarea><br><br>";
            ob_flush();
            flush();
        }
    } else {
        echo "{$directory} is not a valid directory.";
    }
}
?>
<form action="bulk_file_process.php" method="POST">
<b>Add All Files From Directory:</b>
<input type="text" name="directory"/>
</form>
示例#2
0
文件: input.php 项目: t-web/doeqs_new
 $qp = new qParser();
 $error = false;
 if (posted("copypaste")) {
     $unparsed = $qp->parse($_POST["copypaste"]);
 } elseif (filed("fileupload")) {
     require_class("fileToStr");
     $fs = new fileToStr();
     if (is_array($_FILES["fileupload"]["tmp_name"])) {
         //for multiple-supporting browsers
         foreach ($_FILES["fileupload"]["tmp_name"] as $ind => $tmp_name) {
             $name = $_FILES["fileupload"]["name"][$ind];
             echo "File <b>{$name}</b>: ";
             if ($name == '' || $tmp_name == '') {
                 echo "No file.";
             } else {
                 $unparsed .= $qp->parse($fs->convert($name, $tmp_name));
             }
             echo "<br>";
         }
     } else {
         $unparsed = $qp->parse($fs->convert($_FILES["fileupload"]["name"], $_FILES["fileupload"]["tmp_name"]));
     }
 } else {
     err("Invalid form input");
     $error = true;
 }
 if ($error == false) {
     if (str_replace(array("\n", "\r", " ", "\t", "_"), '', $unparsed) != '') {
         echo "<br>Below, in the copy-paste section, are what remains in the document after finding and removing all the questions we could find. Edit it so we can parse the rest.";
     } else {
         echo "<br>No unparsed question text found. This may mean that we parsed every question, in which case yay! Or, there might have been an error, in which case :(";