function show($data = '')
 {
     // make sure a template has been set
     if (empty($this->conf['template'])) {
         echo DCO_FORM_NO_TEMPLATE;
         return false;
     }
     // check if data was passed
     $this->setData($data);
     // make sure we have a fields array
     if (!isset($this->conf['fields']) || !is_array($this->conf['fields'])) {
         $this->conf['fields'] = array();
     }
     // render form
     $form = new xoxSimpleTemplate('', $this->conf['template']);
     $form->setVar('error', $this->error);
     foreach ($this->dco as $key => $value) {
         if (isset($this->conf['fields'][$key])) {
             $this->conf['fields'][$key]->set($value);
             $form->setVar($key, $this->conf['fields'][$key]->get());
             $form->setVar($key . '_class', $this->conf['fields'][$key]->validated || $this->error == '' ? DCO_FORM_TITLE_CLASS : DCO_FORM_ERROR_CLASS);
         } else {
             $form->setVar($key, $value);
         }
     }
     foreach ($this->conf['data'] as $key => $value) {
         if (isset($this->conf['fields'][$key])) {
             $this->conf['fields'][$key]->set($value);
             $form->setVar($key, $this->conf['fields'][$key]->get());
             $form->setVar($key . '_class', $this->conf['fields'][$key]->validated || $this->error == '' ? DCO_FORM_TITLE_CLASS : DCO_FORM_ERROR_CLASS);
         } else {
             $form->setVar($key, $value);
         }
     }
     // copy fieldnames and classes
     foreach ($this->conf['fields'] as $key => $field) {
         #$form->setVar($field->name.'_class',($field->validated||$this->error=='')?DCO_FORM_TITLE_CLASS:DCO_FORM_ERROR_CLASS);
         if (!empty($field->title)) {
             $form->setVar('ls_' . $field->name, $field->title);
         }
     }
     if (is_array($data) && !empty($data['_tostring'])) {
         return $form->show(true);
     } else {
         $form->show();
     }
     return true;
 }
 function send($to = '')
 {
     $this->error = '';
     /*
      * check if newsletter and issue are set
      */
     if (!is_object($this->c_newsletter) || !is_object($this->c_issue)) {
         $this->error = 'No valid newsletter issue set';
         $this->log->error($this->error);
         return false;
     }
     /*
      * check if text or html messages are set
      */
     $message = $this->composeText();
     $html = $this->composeHtml();
     if (empty($message) && empty($html)) {
         $this->error = 'No content set';
         $this->log->error($this->error);
         return false;
     }
     /*
      * now prepare email
      */
     $from_name = $this->c_newsletter->sender_name;
     $from_address = $this->c_newsletter->getSender();
     if (empty($from_address)) {
         $this->error = 'No valid sender address set';
         $this->log->error($this->error);
         return false;
     }
     $reply_name = $from_name;
     $reply_address = $this->c_newsletter->getReply();
     if (empty($reply_address)) {
         $reply_address = $from_address;
     }
     $error_delivery_name = $from_name;
     $error_delivery_address = $this->c_newsletter->getReturn();
     if (empty($error_delivery_address)) {
         if (empty($GLOBALS['tnl_error_email'])) {
             $error_delivery_address = $from_address;
         } else {
             $error_delivery_address = $GLOBALS['tnl_error_email'];
         }
     }
     if (empty($to)) {
         $to = $this->c_newsletter->getSubscribers();
     } elseif (!is_array($to)) {
         $to = array($to);
     }
     /*array(
     			array(
     				'UID' => '0000001',
     				"address"=>"*****@*****.**",
     				"name"=>"Peter Gabriel"
     			),
     			array(
     				'UID' => '0000002',
     				"address"=>"*****@*****.**",
     				"name"=>"Paul Simon"
     			),
     			array(
     				'UID' => '0000003',
     				"address"=>"*****@*****.**",
     				"name"=>"Mary Chain"
     			)
     		);*/
     $subject = $this->c_issue->title;
     switch (XOX_MAILER_TYPE) {
         case 'pickup':
             $email_message = new pickup_message_class();
             $email_message->dir_sep = '/';
             $email_message->mailroot_directory = XOX_APP_BASE . '/jobs';
             $email_message->pickup_file_prefix = date('YmdHis') . '_';
             $email_message->pickup_file_postfix = '.eml';
             break;
         case 'sendmail':
             $email_message = new sendmail_message_class();
             $email_message->delivery_mode = SENDMAIL_DELIVERY_DEFAULT;
             /*  Mode of delivery of the message. Supported modes are:
              *  SENDMAIL_DELIVERY_DEFAULT     - Default mode
              *  SENDMAIL_DELIVERY_INTERACTIVE - Deliver synchronously waiting for remote server response.
              *  SENDMAIL_DELIVERY_BACKGROUND  - Deliver asynchronously without waiting for delivery success response.
              *  SENDMAIL_DELIVERY_QUEUE       - Leave message on the queue to be delivered later when the queue is run
              *  SENDMAIL_DELIVERY_DEFERRED    - Queue without even performing database lookup maps.
              */
             $email_message->bulk_mail_delivery_mode = SENDMAIL_DELIVERY_QUEUE;
             /*  Mode of delivery of the message when the class is set to the bulk mail delivery mode */
             $email_message->sendmail_arguments = "";
             /* Additional sendmail command line arguments */
             break;
         case 'qmail':
         case 'smtp':
         case 'mail':
         default:
             $email_message = new email_message_class();
             break;
     }
     echo "<table style='font-size:11px'><tr><td><b>From</b></td><td>{$from_address}, {$from_name}</td></tr>";
     echo "<tr><td><b>Reply-To</b></td><td>{$reply_address}, {$reply_name}</td></tr>";
     echo "<tr><td><b>Errors-To</b></td><td>{$error_delivery_address}, {$error_delivery_name}</td></tr>";
     if (count($to) < 100) {
         foreach ($to as $subscriber) {
             echo '<tr><td><b>To</b></td><td>' . $subscriber->email . '</td></tr>';
         }
     } else {
         echo '<tr><td></td><td><b>Massenmailing</b></td></tr>';
     }
     echo '</table>';
     /*
      *  For faster queueing use qmail...
      *
      *  require_once("qmail_message.php");
      *  $email_message=new qmail_message_class;
      *
      *  or sendmail in queue only delivery mode
      *
      *  require_once("sendmail_message.php");
      *  $email_message=sendmail_message_class;
      *  $email_message->delivery_mode=SENDMAIL_DELIVERY_QUEUE;
      *
      *  Always call the SetBulkMail function to hint the class to optimize
      *  its behaviour to make deliveries to many users more efficient.
      */
     $email_message->SetBulkMail(1);
     $email_message->SetEncodedEmailHeader("From", $from_address, $from_name);
     $email_message->SetEncodedEmailHeader("Reply-To", $reply_address, $reply_name);
     /*
      *	Set the Return-Path header to define the envelope sender address
      *	to which bounced messages are delivered.
      *  If you are using Windows, you need to use the smtp_message_class
      *	to set the return-path address.
      */
     if (!XOX_LOCAL_MODE) {
         $email_message->SetHeader("Return-Path", $error_delivery_address);
     }
     $email_message->SetEncodedEmailHeader("Errors-To", $error_delivery_address, $error_delivery_name);
     $email_message->SetEncodedHeader("Subject", $subject);
     // make sure text is not cached for personalization
     $email_message->cache_body = 0;
     // create copy for text only
     $email_text = $email_message;
     /* Create empty parts for the parts that will be personalized for each recipient. */
     $email_message->CreateQuotedPrintableTextPart($message, "", $text_part);
     $email_message->CreateQuotedPrintableHTMLPart($html, "", $html_part);
     $email_text->CreateQuotedPrintableTextPart($message, "", $text_only_part);
     /*
      *  Multiple alternative parts are gathered in multipart/alternative parts.
      *  It is important that the fanciest part, in this case the HTML part,
      *  is specified as the last part because that is the way that HTML capable
      *  mail programs will show that part and not the text version part.
      */
     $alternative_parts = array($text_part, $html_part);
     $email_message->AddAlternativeMultipart($alternative_parts);
     /* Add the empty part wherever it belongs in the message. */
     $email_text->AddPart($text_only_part);
     /* Iterate personalization for each recipient. */
     $count_to = count($to);
     if (MAILTEST_ACTIVE && $count_to > MAILTEST_MAX_MAILS) {
         $count_to = MAILTEST_MAX_MAILS;
     }
     $tmp = new xoxSimpleTemplate('', '', '', '\\{\\$', '\\}');
     $tmp->setVar('DOMAINID', $this->c_newsletter->domain_id);
     $tmp->setVar('ISSUEID', $this->c_issue->id);
     set_time_limit(60);
     for ($recipient = 0; $recipient < $count_to; $recipient++) {
         $error = '';
         #### MAILTEST ####
         if (MAILTEST_ACTIVE && $count_to > 20) {
             $testemail = array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**');
             $to[$recipient]->email = $testemail[rand(0, 11)];
             #$to[$recipient]->email = sprintf("*****@*****.**",rand(0,3));
         }
         /* Personalize the recipient address. */
         $to_address = $to[$recipient]->email;
         $to_name = $to[$recipient]->displayname;
         $textonly = $to[$recipient]->config == 'text';
         //$email_class &= ( $textonly ) ? $email_text : $email_message;
         $email_class = $textonly ? $email_text : $email_message;
         if (XOX_MAILER_TYPE == 'pickup') {
             $email_class->pickup_file_prefix = sprintf("%s_%05d_%05d_%05d_%07s_%s_", date('YmdHis'), $this->c_issue->id, $this->mail_counter + 1, $to[$recipient]->uid, $to[$recipient]->mode_data, $to[$recipient]->mode_id == 1 ? 'N' : 'X');
         }
         $email_class->SetEncodedEmailHeader("To", $to_address, $to_name);
         /* Do we really need to personalize the message body?
          * If not, let the class reuse the message body defined for the first recipient above.
          */
         if (!$email_class->cache_body) {
             /* Create a personalized body part. */
             $fingerprint = dechex($this->c_issue->id) . "g" . dechex($to[$recipient]->uid);
             if (MAILTEST_ACTIVE) {
                 $fingerprint .= "g" . $to[$recipient]->mode_data;
             }
             $tmp->setVar('USERID', $fingerprint);
             $tmp->setVar('USEREMAIL', $to[$recipient]->email);
             $tmp->setVar('USERNAME', $to[$recipient]->displayname);
             $tmp->setVar('USERSALUT', $to[$recipient]->_details['gender']);
             $tmp->setVar('USERFNAME', $to[$recipient]->_details['firstname']);
             $tmp->setVar('USERLNAME', $to[$recipient]->_details['lastname']);
             $tmp->setVar('USERCOMPANY', $to[$recipient]->_details['company']);
             $tmp->setVar('USERSTREET', $to[$recipient]->_details['street']);
             $tmp->setVar('USERCOUNTRY', $to[$recipient]->_details['country']);
             $tmp->setVar('USERZIP', $to[$recipient]->_details['zip']);
             $tmp->setVar('USERCITY', $to[$recipient]->_details['city']);
             $tmp->setVar('USERTEL', $to[$recipient]->_details['telephone']);
             $tmp->setVar('USERFAX', $to[$recipient]->_details['fax']);
             $tmp->setVar('USERMOB', $to[$recipient]->_details['mobile']);
             if ($to[$recipient]->isExpert()) {
                 $tmp->setVar('EXPERTS', '<td align="center" nowrap><a href="http://www.bay-as.de/index.php?id=189&fluid=' . $fingerprint . '" style="font-size:12px; font-family:Arial, Helvetica, sans-serif; text-decoration:none; color:#ffffff;">&nbsp;&nbsp;&nbsp;<font color="white">BAYAS experts</font><b style="font-size:15px">&nbsp;&nbsp;&nbsp;</b></a></td><td width="1" bgcolor="#ffffff"><img src="http://www.bay-as.de/fileadmin/images/punkt.gif" height="18" width="1"></td>');
                 $tmp->setVar('BAYPOINTS', $to[$recipient]->getBayPoints());
             } else {
                 $tmp->setVar('EXPERTS', '');
                 $tmp->setVar('BAYPOINTS', '');
             }
             #$message="Hello ".strtok($to_name," ").",\n\nThis message is just to let you know that Manuel Lemos' e-mail sending class is working as expected for sending personalized messages.\n\nThank you,\n$from_name";
             $tmp->parsed_template = $message;
             $email_class->CreateQuotedPrintableTextPart($tmp->show(true), "", $user_text_part);
             if (!$textonly) {
                 $tmp->parsed_template = $html;
                 $email_class->CreateQuotedPrintableHTMLPart($tmp->show(true), "", $user_html_part);
             }
             /* Make the personalized replace the initially empty part */
             if (!$textonly) {
                 $email_class->ReplacePart($text_part, $user_text_part);
                 $email_class->ReplacePart($html_part, $user_html_part);
             } else {
                 $email_class->ReplacePart($text_only_part, $user_text_part);
             }
         }
         /* Send the message checking for eventually acumulated errors */
         #if ( !XOX_LOCAL_MODE ) {
         $this->error = $email_class->Send();
         if ($this->mail_counter++ % 50 == 0) {
             set_time_limit(60);
         }
         $this->log->log(strlen($this->error), sprintf('Versand an: %05d %05d %05d %s [%s] : %s : %s', $this->mail_counter, $to[$recipient]->id, $to[$recipient]->uid, $to[$recipient]->displayname, $to[$recipient]->email, $to[$recipient]->mode_data . ($to[$recipient]->mode_id == 2 ? '*' : ' '), $this->error));
         if (strlen($this->error)) {
             $this->mailerror++;
             //echo "\n\nERROR: $this->error<br>\n\n";
             if ($this->mailerror >= $this->error_break && $this->mailerror == $this->mail_counter) {
                 break;
             }
         }
         #}
     }
     /* When you are done with bulk mailing call the SetBulkMail function
      * again passing 0 to tell the all deliveries were done.
      */
     $email_message->SetBulkMail(0);
     $email_text->SetBulkMail(0);
     if (strlen($this->error)) {
         return false;
     }
     return true;
 }
             } else {
                 echo '<script language="javascript">document.location.href=\'' . $jumpurl . '\';</script>';
                 if (defined('LANG_XOX_BROWSER_REDIRECT')) {
                     echo sprintf(LANG_XOX_BROWSER_REDIRECT, $jumpurl);
                 }
             }
             $render = FALSE;
         } else {
             $error = ERROR_XOX_LOGIN_FAILED;
         }
     }
 }
 // only render loginpage if desired
 if ($render) {
     if (defined('LANG_XOX_LOGIN_TEMPLATE')) {
         $form_login = new xoxSimpleTemplate('', LANG_XOX_LOGIN_TEMPLATE);
         if (isset($error)) {
             $form_login->setVar('error', $error);
         }
         if (isset($login_vars)) {
             $form_login->setVar($login_vars);
         }
         $form_login->setVar('inp_username', $inp_username);
         $form_login->show();
     } else {
         echo '<div id="login_area">';
         if (isset($error)) {
             echo '<p align="center" class="serror">' . $error . '</p>';
         }
         $form_login = '******';
         $form_login .= '<td nowrap valign="middle" align="right"><label for="inp_username">' . LANG_XOX_LOGIN_USERNAME . '</label>&nbsp;</td>';