Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php5 security setting?

Status
Not open for further replies.

nshenry03

Technical User
Feb 9, 2006
60
US
I'm trying to use exec() to convert a .doc to a .html using abiword but the output is garbled (strange characters) (it works when running the same command from the server itself). I was wondering if there was a security setting that I need to look into, or if maybe the document isn't fully uploaded before the conversion begins (If so, how do I make sure that it is fully uploaded first)

Sorry, I'm modifying some older code that is above my skill, but I would like to get this function to work.

Code:
 $this->_convertFileTypes = array(".doc" => "abiword --to={TARGET} {SOURCE}");

Code:
 function convert()
    {
        GLOBAL $settings;

        if (file_exists($settings->_contentDir . $this->_dir . "index.html"))
            return true;

        if (!in_array($this->_fileType, array_keys($settings->_convertFileTypes)))
            return false;

        $source = $settings->_contentDir . $this->_dir . $this->getFileName();
        $target = $settings->_contentDir . $this->_dir . "index.html";
    //  $source = str_replace("/", "\\", $source);
    //  $target = str_replace("/", "\\", $target);

        $command = $settings->_convertFileTypes[$this->_fileType];
        $command = str_replace("{SOURCE}", "\"$source\"", $command);
        $command = str_replace("{TARGET}", "$target", $command);

        $output = array();
        $res = 0;
        exec($command, $output, $res);

        $myFile = "/mydms/content/log/testFile.txt";
        $fh = fopen($myFile, 'a') or die("can't open file");
        fwrite($fh, $command);
        fwrite($fh, $res);
        fclose($fh);


        if ($res != 0)
        {
            print (implode("\n", $output));
            return false;
        }
        return true;
    }
 
sorry, using:
PHP 5.1.6
Apache 2.0.55
AbiWord 2.4.5
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top