diff -uNr moodle.orig/lib/excel/OLEwriter.php moodle/lib/excel/OLEwriter.php
--- moodle.orig/lib/excel/OLEwriter.php	2003-09-26 05:18:02.000000000 +0100
+++ moodle/lib/excel/OLEwriter.php	2006-10-05 13:57:30.000000000 +0100
@@ -32,6 +32,9 @@
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+// paulo.matos: MDL-7176 only affects when in safe_mode because /tmp is used
+require_once("../../config.php");
+
 /**
 * Class for creating OLE streams for Excel Spreadsheets
 *
@@ -122,11 +125,13 @@
 */
     function _initialize()
     {
+        global $CFG;
         $OLEfile = $this->_OLEfilename;
  
         if(($OLEfile == '-') or ($OLEfile == ''))
         {
-            $this->_tmp_filename = tempnam("/tmp", "OLEwriter");
+            // paulo.matos: MDL-7176
+            $this->_tmp_filename = tempnam($CFG->dataroot."/temp", "OLEwriter");
             $fh = fopen($this->_tmp_filename,"wb");
             if ($fh == false) {
                 die("Can't create temporary file.");
