Hi John -- could you please indicate what happens when you interpret this file? Do you get a different name for the output file? Is there a syntax error in the php? Thanks. --le ----- Original Message ----- From: "John J. Boyer" <john.boyer@xxxxxxxxxxxxxxxx> To: <programmingblind@xxxxxxxxxxxxx> Sent: Saturday, October 17, 2009 4:52 AM Subject: Please, a little help with php I am using php 5.1.6. The file pasted below used to work on a server with a different version. What is wrong with the definition of $outputFile? Thanks much. -------------------- # Notice: undefined index filename, look for $outputFile <html> <head> <title>louis-on-the-Web: Download Translation</title> </head> <body> <?php $maintainer = "john.boyer@xxxxxxxxxxxxxxxxx"; # define(PREFIX, "/usr/local"); # Setup the Environment # putenv("LD_LIBRARY_PATH=/usr/local/lib/apache2:/lib:/usr/lib:/usr/local/lib:/home/johnb/bin"); # Clean up userFiles directory. $currentTime = time (); $dir = opendir ('userFiles'); if ($dir) { while (false !== ($fileName = readdir ($dir))) { if (substr ($fileName, 0, 1) != ".") { $filePath = "userFiles/" . $fileName; $timeDif = $currentTime - filemtime ($filePath); if ($timeDif > 7200) { #$command = "rm -rf " . $filePath; #shell_exec ($command); rmdir ($filePath); } } } closedir ($dir); } # Done with cleanup. if (!is_uploaded_file ($_FILES["inFile"]["tmp_name"])) { print "<p>File upload error: "; print '<a href="translate.html">Try again.</a></p>'; exit (); } # $uniqueId = $_SERVER['UNIQUE_ID']; # The above line may not work, so $uniqueId = 'u' . time (); $userDir = "userFiles/" . $uniqueId; mkdir ($userDir, 0777); chdir ($userDir); $userFile = pathinfo ($_FILES['inFile']['name']); $inputFile = $userFile['basename']; $outputFile = $userFile['filename'] . ".brl"; if (!move_uploaded_file ($_FILES["inFile"]["tmp_name"], $inputFile)) { print "<p>Could not process uploaded file. "; print '<a href="translate.html">Try again.</a></p>'; exit (1); } chmod ($inputFile, 0777); $configFile = $userDir . "/user.cfg"; $optionName = $_POST['commandOption']; $command = "/usr/local/bin/xml2brl" . $optionName . ' -l -f ' . $configFile . ' "' . $inputFile . '" "' . $outputFile . '"'; if (!is_uploaded_file ($_FILES["configFile"]["tmp_name"])) { $configHandle = fopen ($configFile, "w"); fwrite ($configHandle, "# User Configuration\n"); fwrite ($configHandle, "outputFormat\n"); if ($_POST['cellsPerLine'] != "") fwrite ($configHandle, "cellsPerLine " . $_POST['cellsPerLine'] . "\n"); if ($_POST['linesPerPage'] != "") fwrite ($configHandle, "linesPerPage " . $_POST['linesPerPage'] . "\n"); if ($_POST['interpoint'] != "") fwrite ($configHandle, "interpoint " . $_POST['interpoint'] . "\n"); if (strpos ($_POST['literaryTextTable'], ".dic") !== false) fwrite ($configHandle, "hyphenate yes\n"); fwrite ($configHandle, "translation\n"); if ($_POST['literaryTextTable'] != "") fwrite ($configHandle, "literaryTextTable " . $_POST['literaryTextTable'] . "\n"); fwrite ($configHandle, "# " . $command . "\n"); fclose ($configHandle); } else move_uploaded_file ($_FILES["configFile"]["tmp_name"], $configFile); shell_exec($command); $dir = opendir ($userDir); while (false !== ($fileName = readdir ($dir))) { $fileType = pathinfo ($fileName); if ($fileType['extension'] == "log") { print "<pre>"; readfile ($userDir . "/" . $fileName); print "</pre>"; } else if ($fileType['extension'] == "sem") { $message = "# " . $fileName . "\n" . file_get_contents ($userDir . "/" . $fileName); mail ($maintainer, "louis-on-the-Web, semantic-action entries", $message); } } if (file_exists ($outputFile)) { chmod ($outputFile, 0777); $downloadLink = '<a href="' . $outputFile . '">Download Translation</a>'; print "<p>$downloadLink</p>"; } else { print "<p>Translation failed. "; print '<a href="translate.html">Try again.</a></p>'; } if ($_POST['userName'] != "" || $_POST['email'] != "" || $_POST['comments'] != "") { $message = "User " . $_POST['userName'] . " at " . $_POST['email'] . " made comments " . $_POST['comments']; mail ($maintainer, "louis-on-the-Web, User Feedback", $message); } ?> </body> </html> -- John J. boyer; President, Chief Software Developer Abilitiessoft, Inc. http://www.abilitiessoft.com Madison, Wisconsin USA Developing software for people with disabilities __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind