function createFile()
{
    $filename = basename($_POST["filename"]);
    $filename = preg_replace("/[^A-Za-z0-9_\\- ]/", "", $filename);
    if (!$filename) {
        displayFileList("Invalid filename - please try again");
        return;
    }
    $filename .= ".txt";
    $filepath = PATH_TO_FILES . "/{$filename}";
    if (file_exists($filepath)) {
        displayFileList("The file {$filename} already exists!");
    } else {
        if (file_put_contents($filepath, "") === false) {
            die("Couldn't create file");
        }
        chmod($filepath, 0666);
        displayEditForm("{$filename}");
    }
}
Beispiel #2
0
    // Display file list. For each file found, create edit link to it
    while ($filename = $dir->read()) {
        $filepath = PATH_TO_FILES . "/{$filename}";
        if ($filename != "." && $filename != ".." && !is_dir($filepath) && strrchr($filename, ".") == ".txt") {
            echo '<tr><td><a href="edit.php?filename=' . urlencode($filename) . '">' . $filename . '</a></td>';
            echo '<td>' . filesize($filepath) . '</td>';
            echo '<td>' . date("M j, Y H:i:s", filemtime($filepath)) . '</td></tr>';
        }
    }
    $dir->close();
    echo '</table>';
}
//---------------------- END FUNCTIONS -------------------------------
$status_message = '';
if (isset($_GET['status_message'])) {
    $status_message = $_GET['status_message'];
}
displayFileList($status_message);
?>
  <h3>...or create a new file:</h3>
  <form action="edit.php" method="post">
    <div style="width: 30em;">
      <label for="filename">Filename</label>
      <input type="text" name="filename" id="filename"
             style="width: 50%;" value="" /><span>&nbsp;.txt</span>
       <input type="submit" name="createFile" value="Create File" />
    </div>
  </form>

<?php 
include './includes/footer.html';
Beispiel #3
0
    // print_r($filelist);  //  Uncomment for debugging
}
$all_files = false;
$single_file = false;
$total = count($filelist);
if (isset($_GET['f']) === true) {
    $single_file = $_GET['f'];
}
if (isset($_GET['a']) === true) {
    $all_files = true;
}
//  Display the output
if ($total > 0) {
    if ($all_files === false && $single_file === false) {
        displayFileTotal();
        displayFileList();
    } else {
        if ($single_file !== false) {
            displaySingleFile($single_file);
            processFile($single_file, false);
            displaySummary();
        } else {
            if ($all_files !== false) {
                displayFileTotal();
                foreach ($filelist as $key => $value) {
                    processFile($value, true);
                }
                displaySummary();
            }
        }
    }
Beispiel #4
0
function displayFiles($uid, $pid)
{
    ?>
    <table>
        <?php 
    displayFileList($uid, $pid, 'draft');
    ?>
        <?php 
    displayFileList($uid, $pid, 'solution');
    ?>
        <?php 
    displayFileList($uid, $pid, 'misc');
    ?>
        <?php 
    displayFileList($uid, $pid, 'postprod');
    ?>
    </table>
    <p style="padding-top: .5em;"><a href='#' id='toggleFiles'>Show Older Files</a></p>
<?php 
}