function export($filename = '')
 {
     $search = array('"', "'", "", "\n", "\r", "");
     //\x08\\x09, not required
     $replace = array('\\"', "\\'", '\\0', '\\n', '\\r', '\\Z');
     // use a function to generate the ini file
     // use a diff fn to generate the sql dump
     // use the zipfile class to package the ini file and the sql dump
     $sql_dump = "INSERT INTO `languages` VALUES ('{$this->code}', '{$this->characterSet}', '{$this->direction}', '{$this->regularExpression}', '{$this->nativeName}', '{$this->englishName}', {$this->status});\r\n\r\n";
     $sql_dump .= "INSERT INTO `language_text` VALUES ";
     $sql = "SELECT * FROM %slanguage_text WHERE language_code='%s' ORDER BY variable, term";
     $rows_text = queryDB($sql, array(TABLE_PREFIX, $this->code));
     if (count($rows_text) > 0) {
         foreach ($rows_text as $row) {
             $row['text'] = str_replace($search, $replace, $row['text']);
             $row['context'] = str_replace($search, $replace, $row['context']);
             $sql_dump .= "('{$this->code}', '{$row['variable']}', '{$row['term']}', '{$row['text']}', '{$row['revised_date']}', '{$row['context']}'),\r\n";
         }
     } else {
         $this->msg->addError('LANG_EMPTY');
     }
     $sql_dump = substr($sql_dump, 0, -3) . ";";
     $readme = 'This is an ATutor language pack. Use the administrator Language section to import this language pack or manually import the contents of the SQL file into your [table_prefix]language_text table, where `table_prefix` should be replaced with your correct ATutor table prefix as defined in ./include/config.inc.php . Additional Language Packs can be found on http://atutor.ca .';
     require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zipfile->add_file($sql_dump, 'language_text.sql');
     $zipfile->add_file($readme, 'readme.txt');
     $zipfile->add_file($this->getXML(), 'language.xml');
     if ($filename) {
         $fp = fopen($filename, 'wb+');
         fwrite($fp, $zipfile->get_file(), $zipfile->get_size());
     } else {
         $version = str_replace('.', '_', VERSION);
         $zipfile->send_file('atutor_' . $version . '_' . $this->code);
     }
 }
         }
         // any files mathcing the $elem key correspond to this profile
         if (strpos($file, $elem) !== false) {
             $store_some[$dir_ . '/' . $val . '/' . $file] = $file;
         }
     }
     closedir($dir);
     // clean it up
     // The dir pointer is closed lets add to the zip
     foreach ($store_some as $val_ => $e) {
         $zipfile->add_file(file_get_contents($val_), $e);
     }
 }
 $zipfile->close();
 if ($file_handle = fopen($dir_ . '/bundle.log', "w")) {
     if (!fwrite($file_handle, $zipfile->get_file())) {
     }
 } else {
 }
 fclose($file_handle);
 $mail->From = $_config['contact_email'];
 $mail->addAddress($_POST['email_add']);
 $mail->Subject = _AT('log_file_bundle');
 $mail->Body = _AT('see_attached');
 $mail->AddAttachment($dir_ . '/bundle.log');
 // clean up the file at the redirection point
 if (!$mail->Send()) {
     $msg->addError('SENDING_ERROR');
     /* Make sure the tmp bundle file never exists past the lifetime of the bundle manager page */
     unlink($dir_ . '/bundle.log');
     header('Location: ' . $_SERVER['PHP_SELF']);
 function export($filename = '')
 {
     //		$search  = array('"', "'", "\x00", "\x0a", "\x0d", "\x1a"); //\x08\\x09, not required
     //		$replace = array('\"', "\'", '\0', '\n', '\r', '\Z');
     // use a function to generate the ini file
     // use a diff fn to generate the sql dump
     // use the zipfile class to package the ini file and the sql dump
     global $addslashes;
     $sql_dump = "INSERT INTO `languages` VALUES ('{$this->code}', '{$this->characterSet}', '{$this->regularExpression}', '{$this->nativeName}', '{$this->englishName}', {$this->status});\r\n\r\n";
     $sql_dump .= "INSERT INTO `language_text` VALUES ";
     $languageTextDAO = new LanguageTextDAO();
     $rows = $languageTextDAO->getAllByLang($this->code);
     if (is_array($rows)) {
         foreach ($rows as $row) {
             //				$row['text']    = str_replace($search, $replace, $row['text']);
             //				$row['context'] = str_replace($search, $replace, $row['context']);
             $row['text'] = $addslashes($row['text']);
             $row['context'] = $addslashes($row['context']);
             $sql_dump .= "('{$this->code}', '{$row['variable']}', '{$row['term']}', '{$row['text']}', '{$row['revised_date']}', '{$row['context']}'),\r\n";
         }
     } else {
         $this->msg->addError('LANG_EMPTY');
         return;
     }
     $sql_dump = substr($sql_dump, 0, -3) . ";";
     $readme = 'This is an AChecker language pack. Use the administrator Language section to import this language pack or manually import the contents of the SQL file into your [table_prefix]language_text table, where `table_prefix` should be replaced with your correct AChecker table prefix as defined in ./include/config.inc.php .';
     require AC_INCLUDE_PATH . 'classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zipfile->add_file($sql_dump, 'language_text.sql');
     $zipfile->add_file($readme, 'readme.txt');
     $zipfile->add_file($this->getXML(), 'language.xml');
     if ($filename) {
         $fp = fopen($filename, 'wb+');
         fwrite($fp, $zipfile->get_file(), $zipfile->get_size());
     } else {
         $version = str_replace('.', '_', VERSION);
         $zipfile->send_file('achecker_' . $version . '_' . $this->code);
     }
 }