Code: Select all
<?php
//error_reporting(E_ALL);
$PageTitle="{$_GET[DirName]} File Settings";
$HeaderTitle="{$_GET[DirName]} File Settings.";
$Current = getcwd();
require("header.php");
//This function takes text from the text file and outputs it. The root of my problems lie in what $TheFile should be, but isn't.
function FillTextArea($TheFile, $DirectoryName){
$ThePath = "/directories/" . "$DirectoryName/" . "$TheFile";
$Open = fopen($TheFile, "r");
if ($Open){
print("Sucess");
$Data = implode('', file("$ThePath"));
print($Data);
fclose($Open);
} else {
print("Not working");
}
}
//Here I'm just making it easy to get it into a print() function
$FTA = FillTextArea();
//Beginning the form
print ("<form name="MasterForm" method="POST" action="HandleForm.php">");
//Here we go. DirName was passed through a get function, it all depends on what the user chose for a directory.
$DirName = $_GET['DirName'];
$PictureArray = array();
$DescArray = array();
if ($handle = opendir("./directories/$DirName")) {
while (false !== ($file = readdir($handle))) {
//I only want .txt files returned. In retrospect, I didn't need to add the first two statements.
if ($file != "." && $file != ".." && eregi(".+\.txt", $file)) {
//There's two types of text files. Example: totalBuilding.txt and just Building.txt. Below tests the former.
if (eregi("total", $file)){
//Just counting the number of text files to have a preset number when the text input loads.
$PictureArray[] = $file;
$TotalPictures = count($PictureArray);
print("<FONT FACE="Tahoma" SIZE="2">{$file}'s number of pictures: </FONT><input type="text" name="text$file" value="$TotalPictures" size=1><BR>");
} else {
//Obviously, if it's the plain text file, I want a text area made. My hopes are to have the original text from the text file in the text area when it loads.
echo "<FONT FACE="Tahoma" SIZE="2">{$file}'s number of pictures: </FONT><textarea name="textarea$file" cols="40" rows="8">$FTA</textarea><BR>";
}
}
}
closedir($handle);
}
print ("</FORM>");
require("footer.php");
?>I hope someone can help me out. Thanks.
-ben