コード例 #1
0
 /**
  * Sends a message out via SMTP according to the server, ip, etc. preferences
  * as set up on the class.  Takes in a QEmailMessage object.
  *
  * Will throw a QEmailException exception on any error.
  *
  * @param QEmailMessage $objMessage Message to Send
  * @return void
  */
 public static function Send(QEmailMessage $objMessage)
 {
     $objResource = null;
     if (QEmailServer::$TestMode) {
         // Open up a File Resource to the TestModeDirectory
         $strArray = explode(' ', microtime());
         $strFileName = sprintf('%s/email_%s%s.txt', QEmailServer::$TestModeDirectory, $strArray[1], substr($strArray[0], 1));
         $objResource = fopen($strFileName, 'w');
         if (!$objResource) {
             throw new QEmailException(sprintf('Unable to open Test SMTP connection to: %s', $strFileName));
         }
         // Clear the Read Buffer
         if (!feof($objResource)) {
             fgets($objResource, 4096);
         }
         // Write the Connection Command
         fwrite($objResource, sprintf("telnet %s %s\r\n", QEmailServer::$SmtpServer, QEmailServer::$SmtpPort));
     } else {
         $objResource = fsockopen(QEmailServer::$SmtpServer, QEmailServer::$SmtpPort);
         if (!$objResource) {
             throw new QEmailException(sprintf('Unable to open SMTP connection to: %s %s', QEmailServer::$SmtpServer, QEmailServer::$SmtpPort));
         }
     }
     // Connect
     $strResponse = null;
     if (!QEmailServer::$TestMode && !feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Iterate through all "220-" responses (stop at "220 ")
         while (substr($strResponse, 0, 3) == "220" && substr($strResponse, 0, 4) != "220 ") {
             if (!feof($objResource)) {
                 $strResponse = fgets($objResource, 4096);
             }
         }
         // Check for a "220" response
         if (strpos($strResponse, "220") === false || strpos($strResponse, "220") != 0) {
             throw new QEmailException(sprintf('Error Response on Connect: %s', $strResponse));
         }
     }
     // Send: EHLO
     fwrite($objResource, sprintf("EHLO %s\r\n", QEmailServer::$OriginatingServerIp));
     if (!QEmailServer::$TestMode && !feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Iterate through all "250-" responses (stop at "250 ")
         while (substr($strResponse, 0, 3) == "250" && substr($strResponse, 0, 4) != "250 ") {
             if (!feof($objResource)) {
                 $strResponse = fgets($objResource, 4096);
             }
         }
         // Check for a "250" response
         if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
             throw new QEmailException(sprintf('Error Response on EHLO: %s', $strResponse));
         }
     }
     // Send Authentication
     if (QEmailServer::$AuthPlain) {
         fwrite($objResource, "AUTH PLAIN " . base64_encode(QEmailServer::$SmtpUsername . "" . QEmailServer::$SmtpUsername . "" . QEmailServer::$SmtpPassword) . "\r\n");
         if (!QEmailServer::$TestMode && !feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
             if (strpos($strResponse, "235") === false || strpos($strResponse, "235") != 0) {
                 throw new QEmailException(sprintf('Error in response from AUTH PLAIN: %s', $strResponse));
             }
         }
     }
     if (QEmailServer::$AuthLogin) {
         fwrite($objResource, "AUTH LOGIN\r\n");
         if (!QEmailServer::$TestMode && !feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
             if (strpos($strResponse, "334") === false || strpos($strResponse, "334") != 0) {
                 throw new QEmailException(sprintf('Error in response from AUTH LOGIN: %s', $strResponse));
             }
         }
         fwrite($objResource, base64_encode(QEmailServer::$SmtpUsername) . "\r\n");
         if (!QEmailServer::$TestMode && !feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
             if (strpos($strResponse, "334") === false || strpos($strResponse, "334") != 0) {
                 throw new QEmailException(sprintf('Error in response from AUTH LOGIN: %s', $strResponse));
             }
         }
         fwrite($objResource, base64_encode(QEmailServer::$SmtpPassword) . "\r\n");
         if (!QEmailServer::$TestMode && !feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
             if (strpos($strResponse, "235") === false || strpos($strResponse, "235") != 0) {
                 throw new QEmailException(sprintf('Error in response from AUTH LOGIN: %s', $strResponse));
             }
         }
     }
     // Setup MAIL FROM line
     $strAddressArray = QEmailServer::GetEmailAddresses($objMessage->From);
     if (count($strAddressArray) != 1) {
         throw new QEmailException(sprintf('Not a valid From address: %s', $objMessage->From));
     }
     // Send: MAIL FROM line
     fwrite($objResource, sprintf("MAIL FROM: <%s>\r\n", $strAddressArray[0]));
     if (!QEmailServer::$TestMode && !feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "250" response
         if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
             throw new QEmailException(sprintf('Error Response on MAIL FROM: %s', $strResponse));
         }
     }
     // Setup RCPT TO line(s)
     $strAddressToArray = QEmailServer::GetEmailAddresses($objMessage->To);
     if (!$strAddressToArray) {
         throw new QEmailException(sprintf('Not a valid To address: %s', $objMessage->To));
     }
     $strAddressCcArray = QEmailServer::GetEmailAddresses($objMessage->Cc);
     if (!$strAddressCcArray) {
         $strAddressCcArray = array();
     }
     $strAddressBccArray = QEmailServer::GetEmailAddresses($objMessage->Bcc);
     if (!$strAddressBccArray) {
         $strAddressBccArray = array();
     }
     $strAddressCcBccArray = array_merge($strAddressCcArray, $strAddressBccArray);
     $strAddressArray = array_merge($strAddressToArray, $strAddressCcBccArray);
     // Send: RCPT TO line(s)
     foreach ($strAddressArray as $strAddress) {
         fwrite($objResource, sprintf("RCPT TO: <%s>\r\n", $strAddress));
         if (!QEmailServer::$TestMode && !feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
             // Check for a "250" response
             if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
                 throw new QEmailException(sprintf('Error Response on RCPT TO: %s', $strResponse));
             }
         }
     }
     // Send: DATA
     fwrite($objResource, "DATA\r\n");
     if (!QEmailServer::$TestMode && !feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "354" response
         if (strpos($strResponse, "354") === false || strpos($strResponse, "354") != 0) {
             throw new QEmailException(sprintf('Error Response on DATA: %s', $strResponse));
         }
     }
     // Send: Required Headers
     fwrite($objResource, sprintf("Date: %s\r\n", QDateTime::NowToString(QDateTime::FormatRfc822)));
     fwrite($objResource, sprintf("To: %s\r\n", $objMessage->To));
     fwrite($objResource, sprintf("From: %s\r\n", $objMessage->From));
     // Send: Optional Headers
     if ($objMessage->Subject) {
         fwrite($objResource, sprintf("Subject: %s\r\n", $objMessage->Subject));
     }
     if ($objMessage->Cc) {
         fwrite($objResource, sprintf("Cc: %s\r\n", $objMessage->Cc));
     }
     // Send: Content-Type Header (if applicable)
     $semi_random = md5(time());
     $strBoundary = sprintf('==qcodo_qemailserver_multipart_boundary____x%sx', $semi_random);
     // Send: Other Headers (if any)
     foreach ($objArray = $objMessage->HeaderArray as $strKey => $strValue) {
         fwrite($objResource, sprintf("%s: %s\r\n", $strKey, $strValue));
     }
     // if we are adding an html or files to the message we need these headers.
     if ($objMessage->HasFiles || $objMessage->HtmlBody) {
         fwrite($objResource, "MIME-Version: 1.0\r\n");
         fwrite($objResource, sprintf("Content-Type: multipart/mixed;\r\n boundary=\"%s\"\r\n", $strBoundary));
         fwrite($objResource, sprintf("This is a multipart message in MIME format.\r\n\r\n", $strBoundary));
         fwrite($objResource, sprintf("--%s\r\n", $strBoundary));
     }
     $strAltBoundary = sprintf('==qcodo_qemailserver_alternative_boundary____x%sx', $semi_random);
     // Send: Body
     // Setup Encoding Type (use QEmailServer if specified, otherwise default to QApplication's)
     if (!($strEncodingType = QEmailServer::$EncodingType)) {
         $strEncodingType = QApplication::$EncodingType;
     }
     if ($objMessage->HtmlBody) {
         fwrite($objResource, sprintf("Content-Type: multipart/alternative;\r\n boundary=\"%s\"\r\n\r\n", $strAltBoundary));
         fwrite($objResource, sprintf("--%s\r\n", $strAltBoundary));
         fwrite($objResource, sprintf("Content-Type: text/plain; charset=\"%s\"\r\n", $strEncodingType));
         fwrite($objResource, sprintf("Content-Transfer-Encoding: 7bit\r\n\r\n"));
         fwrite($objResource, $objMessage->Body);
         fwrite($objResource, "\r\n\r\n");
         fwrite($objResource, sprintf("--%s\r\n", $strAltBoundary));
         fwrite($objResource, sprintf("Content-Type: text/html; charset=\"%s\"\r\n", $strEncodingType));
         //				fwrite($objResource, sprintf("Content-Transfer-Encoding: quoted-printable\r\n\r\n"));
         fwrite($objResource, sprintf("Content-Transfer-Encoding: 7bit\r\n\r\n"));
         fwrite($objResource, $objMessage->HtmlBody);
         fwrite($objResource, "\r\n\r\n");
         fwrite($objResource, sprintf("--%s--\r\n", $strAltBoundary));
     } elseif ($objMessage->HasFiles) {
         fwrite($objResource, sprintf("Content-Type: multipart/alternative;\r\n boundary=\"%s\"\r\n\r\n", $strAltBoundary));
         fwrite($objResource, sprintf("--%s\r\n", $strAltBoundary));
         fwrite($objResource, sprintf("Content-Type: text/plain; charset=\"%s\"\r\n", $strEncodingType));
         fwrite($objResource, sprintf("Content-Transfer-Encoding: 7bit\r\n\r\n"));
         fwrite($objResource, $objMessage->Body);
         fwrite($objResource, "\r\n\r\n");
         fwrite($objResource, sprintf("--%s--\r\n", $strAltBoundary));
     } else {
         fwrite($objResource, sprintf("Content-Type: text/plain; charset=\"%s\"\r\n", $strEncodingType));
         fwrite($objResource, sprintf("Content-Transfer-Encoding: 7bit\r\n\r\n"));
         fwrite($objResource, "\r\n" . $objMessage->Body);
     }
     // Send: File Attachments
     if ($objMessage->HasFiles) {
         foreach ($objArray = $objMessage->FileArray as $objFile) {
             fwrite($objResource, sprintf("--%s\r\n", $strBoundary));
             fwrite($objResource, sprintf("Content-Type: %s;\r\n", $objFile->MimeType));
             fwrite($objResource, sprintf("      name=\"%s\"\r\n", $objFile->FileName));
             fwrite($objResource, "Content-Transfer-Encoding: base64\r\n");
             fwrite($objResource, sprintf("Content-Length: %s\r\n", strlen($objFile->EncodedFileData)));
             fwrite($objResource, "Content-Disposition: attachment;\r\n");
             fwrite($objResource, sprintf("      filename=\"%s\"\r\n\r\n", $objFile->FileName));
             fwrite($objResource, $objFile->EncodedFileData);
             //					foreach (explode("\n", $objFile->EncodedFileData) as $strLine) {
             //						$strLine = trim($strLine);
             //						fwrite($objResource, $strLine . "\r\n");
             //					}
         }
     }
     // close a message with these boundaries if the message had files or had html
     if ($objMessage->HasFiles || $objMessage->HtmlBody) {
         fwrite($objResource, sprintf("\r\n\r\n--%s--\r\n", $strBoundary));
     }
     // send end of file attachments...
     // Send: Message End
     fwrite($objResource, "\r\n.\r\n");
     if (!QEmailServer::$TestMode && !feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "250" response
         if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
             throw new QEmailException(sprintf('Error Response on MAIL FROM: %s', $strResponse));
         }
     }
     // Send: QUIT
     fwrite($objResource, "QUIT\r\n");
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
     }
     // Close the Resource
     fclose($objResource);
 }
コード例 #2
0
ファイル: email.php プロジェクト: kmcelhinney/qcodo
	
	For obvious reasons, this page is non-functional.  To view the commented out source,
	please click on <b>View Source</b> at the top right of the page.

<?php 
// We want to define our email SMTP server (it defaults to "localhost")
// This would typically be done in prepend.inc, and its value should probably be a constant
// that is defined in _configuration.inc
QEmailServer::$SmtpServer = 'mx.acme.com';
// Create a new message
// Note that you can list multiple addresses and that Qcodo supports Bcc and Cc
$objMessage = new QEmailMessage();
$objMessage->From = 'ACME Reporting Service <*****@*****.**>';
$objMessage->To = 'John Doe <*****@*****.**>, Jane Doe <*****@*****.**>';
$objMessage->Bcc = '*****@*****.**';
$objMessage->Subject = 'Report for ' . QDateTime::NowToString(QDateTime::FormatDisplayDate);
// Setup Plaintext Message
$strBody = "Dear John and Jane Doe,\r\n\r\n";
$strBody .= "You have new reports to review.  Please go to the ACME Portal at http://portal.acme.com/ to review.\r\n\r\n";
$strBody .= "Regards,\r\nACME Reporting Service";
$objMessage->Body = $strBody;
// Also setup HTML message (optional)
$strBody = 'Dear John and Jane Doe,<br/><br/>';
$strBody .= '<b>You have new reports to review.</b>  Please go to the <a href="http://portal.acme.com/">ACME Portal</a> to review.<br/><br/>';
$strBody .= 'Regards,<br/><b>ACME Reporting Service</b>';
$objMessage->HtmlBody = $strBody;
// Add random/custom email headers
$objMessage->SetHeader('x-application', 'ACME Reporting Service v1.2a');
// Send the Message (Commented out for obvious reasons)
//	QEmailServer::Send($objMessage);
// Note that you can also shortcut the Send command to one line for simple messages (similar to PHP's mail())
コード例 #3
0
 /**
  * Given the way this object is set up, it will return two-index string array containing the correct
  * SMTP Message Header and Message Body for this object.
  * 
  * This will make changes, cleanup and any additional setup to the HeaderArray in order to complete its task
  * 
  * @param string $strEncodingType the encoding type to use (if null, then it uses QApplication's)
  * @param QDateTime $dttSendDate the optional QDateTime to use for the Date field or NULL if you want to use Now()
  * @return string[] index 0 is the Header and index 1 is the Body
  */
 public function CalculateMessageHeaderAndBody($strEncodingType = null, QDateTime $dttSendDate = null)
 {
     // Setup Headers
     $this->RemoveHeader('Message-Id');
     $this->SetHeader('From', $this->From);
     $this->SetHeader('To', $this->To);
     if ($dttSendDate) {
         $this->SetHeader('Date', $dttSendDate->ToString(QDateTime::FormatRfc822));
     } else {
         $this->SetHeader('Date', QDateTime::NowToString(QDateTime::FormatRfc822));
     }
     // Setup Encoding Type (default to QApplication's if not specified)
     if (!$strEncodingType) {
         $strEncodingType = QApplication::$EncodingType;
     }
     // Additional "Optional" Headers
     if ($this->Subject) {
         $strSubject = self::QuotedPrintableEncode($this->Subject);
         $strSubject = str_replace('?', '=3F', $strSubject);
         $this->SetHeader('Subject', sprintf("=?%s?Q?%s?=", $strEncodingType, $strSubject));
     }
     if ($this->Cc) {
         $this->SetHeader('Cc', $this->Cc);
     }
     // Setup for MIME and Content Encoding
     $strBoundaryArray = $this->SetupMimeHeaders($strEncodingType);
     $strBoundary = $strBoundaryArray[0];
     $strAltBoundary = $strBoundaryArray[1];
     // Generate MessageHeader
     $strHeader = $this->CalculateMessageHeader();
     // Generate MessageBody
     $strBody = $this->CalculateMessageBody($strEncodingType, $strBoundary, $strAltBoundary);
     return array($strHeader, $strBody);
 }
コード例 #4
0
ファイル: NarroLanguage.class.php プロジェクト: Jobava/narro
 /**
  * Returns a tmx file
  * @param QQCondition $objLangCondition e.g. QQ::In(QQN::NarroText()->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId());
  * @return a tmx file, formatted as a string
  */
 public static function GetTmx($objLangCondition)
 {
     $tmx = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE tmx SYSTEM "tmx13.dtd"><tmx />');
     $tmx->addAttribute('version', '1.3');
     $header = $tmx->addChild('header');
     // mandatory
     $header->addAttribute('creationtool', "Narro");
     $header->addAttribute('creationtoolversion', NARRO_VERSION);
     $header->addAttribute('segtype', "sentence");
     $header->addAttribute('o-tmf', "ABCTransMem");
     $header->addAttribute('adminlang', NarroLanguage::SOURCE_LANGUAGE_CODE);
     $header->addAttribute('srclang', NarroLanguage::SOURCE_LANGUAGE_CODE);
     $header->addAttribute('datatype', "PlainText");
     // optional
     $header->addAttribute('creationdate', QDateTime::NowToString('YYYYMMDDThhmmssZ'));
     if (QApplication::$User) {
         $header->addAttribute('creationid', QApplication::$User->Username);
     }
     $header->addAttribute('changedate', "19970314T023401Z");
     $header->addAttribute('o-encoding', "utf-8");
     $body = $tmx->addChild('body');
     $strQuery = NarroText::GetQueryStatement($objQueryBuilder, QQ::AndCondition(QQ::IsNotNull(QQN::NarroText()->NarroSuggestionAsText->SuggestionId), $objLangCondition), array(QQ::ExpandAsArray(QQN::NarroText()->NarroSuggestionAsText)), array(), false);
     $objDbResult = NarroText::GetDatabase()->Query($strQuery);
     $intRowCount = $objDbResult->CountRows();
     $intLastTextId = 0;
     while ($objDbRow = $objDbResult->GetNextRow()) {
         $objText = NarroText::InstantiateDbRow($objDbRow, null, $objQueryBuilder->ExpandAsArrayNodes, null, $objQueryBuilder->ColumnAliasArray);
         if ($intLastTextId != $objText->TextId) {
             $intLastTextId = $objText->TextId;
             $tu = $body->addChild('tu');
             $tu->addAttribute('tuid', $objText->TextId);
             $tu->addAttribute('datatype', 'Text');
             // $tu->addAttribute('usagecount', $objText->CountNarroContextsAsText());
             // $objLastContext = NarroContext::QuerySingle(QQ::Equal(QQN::NarroContext()->TextId, $objText->TextId), array(QQ::OrderBy(QQN::NarroContext()->Created, 0)));
             // if ($objLastContext && $objLastContext->Created instanceof QDateTime)
             // $tu->addAttribute('lastusagedate', $objLastContext->Created->qFormat('YYYYMMDDThhmmssZ'));
             $tuv = $tu->addChild('tuv');
             $tuv->addAttribute('xml:lang', NarroLanguage::SOURCE_LANGUAGE_CODE);
             $seg = $tuv->addChild('seg');
             $tuv->seg = $objText->TextValue;
             if ($objText->Created instanceof QDateTime) {
                 $tuv->addAttribute('creationdate', $objText->Created->qFormat('YYYYMMDDThhmmssZ'));
             }
             if ($objText->Modified instanceof QDateTime) {
                 $tuv->addAttribute('changedate', $objText->Modified->qFormat('YYYYMMDDThhmmssZ'));
             }
         }
         foreach ($objText->_NarroSuggestionAsTextArray as $objSuggestion) {
             /* @var $objSuggestion NarroSuggestion */
             $tuv = $tu->addChild('tuv');
             $tuv->addAttribute('xml:lang', $objSuggestion->Language->LanguageCode);
             $seg = $tuv->addChild('seg');
             $tuv->seg = $objSuggestion->SuggestionValue;
             if ($objSuggestion->Created instanceof QDateTime) {
                 $tuv->addAttribute('creationdate', $objSuggestion->Created->qFormat('YYYYMMDDThhmmssZ'));
             }
             if ($objSuggestion->Modified instanceof QDateTime) {
                 $tuv->addAttribute('changedate', $objSuggestion->Modified->qFormat('YYYYMMDDThhmmssZ'));
             }
             if ($objSuggestion->User instanceof NarroUser) {
                 $tuv->addAttribute('creationid', $objSuggestion->User->RealName);
             }
             // $tuv->addAttribute('usagecount', $objSuggestion->CountNarroContextInfosAsValidSuggestion());
             // $objLastContextInfo = NarroContextInfo::QuerySingle(QQ::Equal(QQN::NarroContextInfo()->ValidSuggestionId, $objSuggestion->SuggestionId), array(QQ::OrderBy(QQN::NarroContextInfo()->Created, 0)));
             // if ($objLastContextInfo && $objLastContextInfo->Created instanceof QDateTime)
             // $tuv->addAttribute('lastusagedate', $objLastContextInfo->Created->qFormat('YYYYMMDDThhmmssZ'));
         }
     }
     return $tmx->asXML();
 }
コード例 #5
0
 /**
  * Sends a message out via SMTP according to the server, ip, etc. preferences
  * as set up on the class.  Takes in a QEmailMessage object.
  *
  * Will throw a QEmailException exception on any error.
  *
  * @param QEmailMessage $objMessage Message to Send
  * @return void
  */
 public static function Send(QEmailMessage $objMessage)
 {
     $objResource = null;
     if (QEmailServer::$TestMode) {
         // Open up a File Resource to the TestModeDirectory
         $strArray = split(' ', microtime());
         $strFileName = sprintf('%s/email_%s%s.txt', QEmailServer::$TestModeDirectory, $strArray[1], substr($strArray[0], 1));
         $objResource = fopen($strFileName, 'w');
         if (!$objResource) {
             throw new QEmailException(sprintf('Unable to open Test SMTP connection to: %s', $strFileName));
         }
         // Clear the Read Buffer
         if (!feof($objResource)) {
             fgets($objResource, 4096);
         }
         // Write the Connection Command
         fwrite($objResource, sprintf("telnet %s %s\r\n", QEmailServer::$SmtpServer, QEmailServer::$SmtpPort));
     } else {
         $objResource = fsockopen(QEmailServer::$SmtpServer, QEmailServer::$SmtpPort);
         if (!$objResource) {
             throw new QEmailException(sprintf('Unable to open SMTP connection to: %s %s', QEmailServer::$SmtpServer, QEmailServer::$SmtpPort));
         }
     }
     // Connect
     $strResponse = null;
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "220" response
         if (strpos($strResponse, "220") === false || strpos($strResponse, "220") != 0) {
             throw new QEmailException(sprintf('Error Response on Connect: %s', $strResponse));
         }
     }
     // Send: EHLO
     fwrite($objResource, sprintf("EHLO %s\r\n", QEmailServer::$OriginatingServerIp));
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Iterate through all "250-" responses (stop at "250 ")
         while (substr($strResponse, 0, 3) == "250" && substr($strResponse, 0, 4) != "250 ") {
             if (!feof($objResource)) {
                 $strResponse = fgets($objResource, 4096);
             }
         }
         // Check for a "250" response
         if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
             throw new QEmailException(sprintf('Error Response on EHLO: %s', $strResponse));
         }
     }
     // Send Authentication
     if (QEmailServer::$AuthPlain) {
         fwrite($objResource, "AUTH PLAIN " . base64_encode(QEmailServer::$SmtpUsername . "" . QEmailServer::$SmtpUsername . "" . QEmailServer::$SmtpPassword) . "\r\n");
         if (!feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
         }
         if (strpos($strResponse, "235") === false || strpos($strResponse, "235") != 0) {
             throw new QEmailException(sprintf('Error in response from AUTH PLAIN: %s', $strResponse));
         }
     }
     if (QEmailServer::$AuthLogin) {
         fwrite($objResource, "AUTH LOGIN\r\n");
         if (!feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
         }
         if (strpos($strResponse, "334") === false || strpos($strResponse, "334") != 0) {
             throw new QEmailException(sprintf('Error in response from AUTH LOGIN: %s', $strResponse));
         }
         fwrite($objResource, base64_encode(QEmailServer::$SmtpUsername) . "\r\n");
         if (!feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
         }
         if (strpos($strResponse, "334") === false || strpos($strResponse, "334") != 0) {
             throw new QEmailException(sprintf('Error in response from AUTH LOGIN: %s', $strResponse));
         }
         fwrite($objResource, base64_encode(QEmailServer::$SmtpPassword) . "\r\n");
         if (!feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
         }
         if (strpos($strResponse, "235") === false || strpos($strResponse, "235") != 0) {
             throw new QEmailException(sprintf('Error in response from AUTH LOGIN: %s', $strResponse));
         }
     }
     // Setup MAIL FROM line
     $strAddressArray = QEmailServer::GetEmailAddresses($objMessage->From);
     if (count($strAddressArray) != 1) {
         throw new QEmailException(sprintf('Not a valid From address: %s', $objMessage->From));
     }
     // Send: MAIL FROM line
     fwrite($objResource, sprintf("MAIL FROM: %s\r\n", $strAddressArray[0]));
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "250" response
         if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
             throw new QEmailException(sprintf('Error Response on MAIL FROM: %s', $strResponse));
         }
     }
     // Setup RCPT TO line(s)
     $strAddressToArray = QEmailServer::GetEmailAddresses($objMessage->To);
     if (!$strAddressToArray) {
         throw new QEmailException(sprintf('Not a valid To address: %s', $objMessage->To));
     }
     $strAddressCcArray = QEmailServer::GetEmailAddresses($objMessage->Cc);
     if (!$strAddressCcArray) {
         $strAddressCcArray = array();
     }
     $strAddressBccArray = QEmailServer::GetEmailAddresses($objMessage->Bcc);
     if (!$strAddressBccArray) {
         $strAddressBccArray = array();
     }
     $strAddressCcBccArray = array_merge($strAddressCcArray, $strAddressBccArray);
     $strAddressArray = array_merge($strAddressToArray, $strAddressCcBccArray);
     // Send: RCPT TO line(s)
     foreach ($strAddressArray as $strAddress) {
         fwrite($objResource, sprintf("RCPT TO: %s\r\n", $strAddress));
         if (!feof($objResource)) {
             $strResponse = fgets($objResource, 4096);
             // Check for a "250" response
             if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
                 throw new QEmailException(sprintf('Error Response on RCPT TO: %s', $strResponse));
             }
         }
     }
     // Send: DATA
     fwrite($objResource, "DATA\r\n");
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "354" response
         if (strpos($strResponse, "354") === false || strpos($strResponse, "354") != 0) {
             throw new QEmailException(sprintf('Error Response on DATA: %s', $strResponse));
         }
     }
     // Send: Required Headers
     fwrite($objResource, sprintf("Date: %s\r\n", QDateTime::NowToString(QDateTime::FormatRfc822)));
     fwrite($objResource, sprintf("To: %s\r\n", $objMessage->To));
     fwrite($objResource, sprintf("From: %s\r\n", $objMessage->From));
     // Send: Optional Headers
     if ($objMessage->Subject) {
         fwrite($objResource, sprintf("Subject: %s\r\n", $objMessage->Subject));
     }
     if ($objMessage->Cc) {
         fwrite($objResource, sprintf("Cc: %s\r\n", $objMessage->Cc));
     }
     // Send: Content-Type Header (if applicable)
     $strBoundary = 'qcodo_qemailserver_multipart_boundary____';
     if ($objMessage->HtmlBody) {
         fwrite($objResource, sprintf("Content-Type: multipart/alternative; boundary=\"%s\"\r\n", $strBoundary));
     }
     // Send: Other Headers (if any)
     foreach ($objArray = $objMessage->HeaderArray as $strKey => $strValue) {
         fwrite($objResource, sprintf("%s: %s\r\n", $strKey, $strValue));
     }
     // Send: Body
     fwrite($objResource, "\r\n");
     if ($objMessage->HtmlBody) {
         fwrite($objResource, sprintf("--%s\r\n", $strBoundary));
         fwrite($objResource, sprintf("Content-Type: text/plain; charset=%s\r\n\r\n", QApplication::$EncodingType));
         fwrite($objResource, $objMessage->Body);
         fwrite($objResource, "\r\n\r\n\r\n");
         fwrite($objResource, sprintf("--%s\r\n", $strBoundary));
         fwrite($objResource, sprintf("Content-Type: text/html; charset=%s\r\n\r\n", QApplication::$EncodingType));
         fwrite($objResource, $objMessage->HtmlBody);
         fwrite($objResource, "\r\n\r\n\r\n");
         fwrite($objResource, sprintf("--%s--\r\n", $strBoundary));
     } else {
         fwrite($objResource, $objMessage->Body);
     }
     // Send: Message End
     fwrite($objResource, "\r\n.\r\n");
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
         // Check for a "250" response
         if (strpos($strResponse, "250") === false || strpos($strResponse, "250") != 0) {
             throw new QEmailException(sprintf('Error Response on MAIL FROM: %s', $strResponse));
         }
     }
     // Send: QUIT
     fwrite($objResource, "QUIT\r\n");
     if (!feof($objResource)) {
         $strResponse = fgets($objResource, 4096);
     }
     // Close the Resource
     fclose($objResource);
 }
コード例 #6
0
<?php

require_once '../qcubed.inc.php';
QApplication::CheckRemoteAdmin();
echo "<h2>Unattended Plugin Installer</h2>";
echo "<p><em>" . QDateTime::NowToString(QDateTime::FormatDisplayDateTime) . "</em></p>";
$directory = __INCLUDES__ . '/tmp/plugin.install';
$arrFiles = QFolder::listFilesInFolder($directory, false, "/\\.zip\$/i");
if (sizeof($arrFiles) > 0) {
    foreach ($arrFiles as $strFile) {
        echo "<h2>Installing " . $strFile . "</h2>";
        $fullFilePath = $directory . '/' . $strFile;
        try {
            $pluginFolder = QPluginInstaller::installPluginFromZip($fullFilePath);
            if ($pluginFolder) {
                list($strStatus, $strLog) = QPluginInstaller::installFromExpanded($pluginFolder);
                unlink($fullFilePath);
                echo nl2br($strLog);
            }
        } catch (Exception $e) {
            echo '<div class="error">Error installing the plugin: ' . $e->getMessage() . '</div>';
        }
    }
} else {
    echo "<p>No plugin zip files found in the unattended install directory: " . $directory . "</p>";
    echo "<p>Download new plugins from the <a target='_blank' href='" . QPluginInstaller::ONLINE_PLUGIN_REPOSITORY . "'>" . "Online repository of QCubed plugins</a></p>";
}
コード例 #7
0
function LogTime($strSection)
{
    global $__fltTime;
    file_put_contents('/tmp/trace.txt', QDateTime::NowToString(QDateTime::FormatIso) . ' - ' . $strSection . ' - ' . (microtime(true) - $__fltTime) . "\r\n", FILE_APPEND);
    $__fltTime = microtime(true);
}
コード例 #8
0
ファイル: CreditCardPayment.class.php プロジェクト: alcf/chms
 /**
  * This will submit a NVP Request to paypal and return the repsonse
  * or NULL if there was a connection error.
  * 
  * @param string[] $strNvpRequestArray a structured array containing the NVP Request
  * @return string[] a structured array based on the NVP Response, or NULL if there was a connection error
  */
 protected static function PaymentGatewaySubmitRequest($strNvpRequestArray)
 {
     $strLogFile = 'paypal_' . QDateTime::NowToString('YYYY-MM-DD');
     $strLogHash = substr(md5(microtime()), 0, 8);
     $objCurl = curl_init();
     curl_setopt($objCurl, CURLOPT_URL, PAYPAL_ENDPOINT);
     curl_setopt($objCurl, CURLOPT_VERBOSE, false);
     // Turning off the server and peer verification (TrustManager Concept)
     curl_setopt($objCurl, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($objCurl, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($objCurl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($objCurl, CURLOPT_POST, true);
     // Add Credentials to NVP-based Request for submitting to server
     $strNvpRequestArray['PARTNER'] = PAYPAL_PARTNER;
     $strNvpRequestArray['USER'] = PAYPAL_USER;
     $strNvpRequestArray['VENDOR'] = PAYPAL_VENDOR;
     $strNvpRequestArray['PWD'] = PAYPAL_PASSWORD;
     $strNvpRequest = self::FormatNvp($strNvpRequestArray);
     // First, we Sanitize NVP Request for Logging and then log it
     $strNvpRequestToLog = $strNvpRequestArray;
     $strNvpRequestToLog['PARTNER'] = 'xxxxx';
     $strNvpRequestToLog['USER'] = '******';
     $strNvpRequestToLog['VENDOR'] = 'xxxxx';
     $strNvpRequestToLog['PWD'] = 'xxxxx';
     if (array_key_exists('ACCT', $strNvpRequestToLog)) {
         $intLength = strlen($strNvpRequestToLog['ACCT']);
         $strNvpRequestToLog['ACCT'] = str_repeat('x', $intLength - 4) . substr($strNvpRequestToLog['ACCT'], $intLength - 4);
     }
     QLog::Log($strLogHash . ' - ' . self::FormatNvp($strNvpRequestToLog), QLogLevel::Normal, $strLogFile);
     // Setting the entire NvpRequest as POST FIELD to curl
     curl_setopt($objCurl, CURLOPT_POSTFIELDS, $strNvpRequest);
     // Getting response from server
     $strResponse = @curl_exec($objCurl);
     curl_close($objCurl);
     if ($strResponse) {
         $arrToReturn = self::DeformatNvp($strResponse);
         QLog::Log($strLogHash . ' - ' . var_export($arrToReturn, true), QLogLevel::Normal, $strLogFile);
         return $arrToReturn;
     } else {
         QLog::Log($strLogHash . ' - ' . 'ERROR', QLogLevel::Normal, $strLogFile);
         return null;
     }
 }
コード例 #9
0
 protected static function DrawInfo(Zend_Pdf_Page $objPage, $objPersonOrHousehold, $intYear, $intQuarter, $intY, $intPageNumber, $intTotalPages)
 {
     $intXRight = 8 * 72;
     $objPage->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 12);
     self::DrawTextRight($objPage, $intXRight, $intY, 'Giving Receipt');
     $intY -= 13.2;
     $objPage->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
     if ($intQuarter) {
         $strQuarter = '';
         switch ($intQuarter) {
             case 1:
                 $strQuarter = '1st Quarter';
                 break;
             case 2:
                 $strQuarter = '2nd Quarter';
                 break;
             case 3:
                 $strQuarter = '3rd Quarter';
                 break;
         }
         self::DrawTextRight($objPage, $intXRight, $intY, 'Reflects ' . $intYear . ' Gifts for ' . $strQuarter);
     } else {
         self::DrawTextRight($objPage, $intXRight, $intY, 'Reflects ' . $intYear . ' Gifts');
     }
     $intY -= 15;
     $objPage->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_ITALIC), 8);
     self::DrawTextRight($objPage, $intXRight, $intY, 'Receipt generated on ' . QDateTime::NowToString('MMMM D, YYYY'));
     $intY -= 10;
     $objPage->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_ITALIC), 8);
     self::DrawTextRight($objPage, $intXRight, $intY, sprintf('Page %s of %s', $intPageNumber, $intTotalPages));
 }
コード例 #10
0
ファイル: batch.php プロジェクト: alcf/chms
 protected function Form_Create()
 {
     $this->objBatch = PaypalBatch::Load(QApplication::PathInfo(0));
     if (!$this->objBatch) {
         QApplication::Redirect('/stewardship/paypal');
     }
     $this->strPageTitle .= $this->objBatch->Number;
     $this->dtgTransactions = new QDataGrid($this);
     $this->dtgTransactions->SetDataBinder('dtgTransactions_Bind');
     $this->dtgTransactions->AddColumn(new QDataGridColumn('Date Captured', '<?= $_ITEM[0]; ?>', 'Width=150px', 'HtmlEntities=false', 'VerticalAlign=top'));
     $this->dtgTransactions->AddColumn(new QDataGridColumn('Total Amount Charged', '<?= $_ITEM[1]; ?>', 'Width=150px', 'VerticalAlign=top'));
     $this->dtgTransactions->AddColumn(new QDataGridColumn('Transaction Code', '<?= $_ITEM[2]; ?>', 'Width=120px', 'VerticalAlign=top'));
     $this->dtgTransactions->AddColumn(new QDataGridColumn('Account Funding', '<?= $_ITEM[3]; ?>', 'Width=330px', 'HtmlEntities=false', 'VerticalAlign=top', 'FontSize=10px'));
     $this->dtgTransactions->AddColumn(new QDataGridColumn('Funding Amount', '<?= $_ITEM[4]; ?>', 'Width=150px', 'HtmlEntities=false', 'VerticalAlign=top', 'FontSize=10px'));
     $this->dtgFunding = new QDataGrid($this);
     $this->dtgFunding->SetDataBinder('dtgFunding_Bind');
     $this->dtgFunding->AddColumn(new QDataGridColumn('Fund', '<?= $_ITEM[0]; ?>', 'Width=340px', 'HtmlEntities=false'));
     $this->dtgFunding->AddColumn(new QDataGridColumn('Account Number', '<?= $_ITEM[1]; ?>', 'Width=200px'));
     $this->dtgFunding->AddColumn(new QDataGridColumn('Amount', '<?= $_ITEM[2]; ?>', 'HtmlEntities=false', 'Width=380px', 'HtmlEntities=false'));
     $this->dtgUnaccounted = new CreditCardPaymentDataGrid($this);
     $this->dtgUnaccounted->MetaAddColumn('DateCaptured', 'Width=200px');
     $this->dtgUnaccounted->MetaAddColumn('AmountCharged', 'Html=<?= QApplication::DisplayCurrency($_ITEM->AmountCharged); ?>', 'Width=150px');
     $this->dtgUnaccounted->MetaAddColumn('TransactionCode', 'Width=500px');
     $this->dtgUnaccounted->SortColumnIndex = 0;
     $this->dtgUnaccounted->SetDataBinder('dtgUnaccounted_Bind');
     $this->dtgUnaccounted->NoDataHtml = 'Good!  There are no unaccounted-for credit card transaction entries in this PayPal batch.';
     $this->pxyEditFundDonationLineItem = new QControlProxy($this);
     $this->pxyEditFundDonationLineItem->AddAction(new QClickEvent(), new QAjaxAction('pxyEditFundDonationLineItem_Click'));
     $this->pxyEditFundDonationLineItem->AddAction(new QClickEvent(), new QTerminateAction());
     $this->pxyEditFundSignupPayment = new QControlProxy($this);
     $this->pxyEditFundSignupPayment->AddAction(new QClickEvent(), new QAjaxAction('pxyEditFundSignupPayment_Click'));
     $this->pxyEditFundSignupPayment->AddAction(new QClickEvent(), new QTerminateAction());
     $this->lblInstructionHtml = new QLabel($this);
     $this->lblInstructionHtml->TagName = 'p';
     $this->lblInstructionHtml->HtmlEntities = false;
     $this->dtxDateCredited = new QDateTimeTextBox($this);
     $this->dtxDateCredited->Name = 'Date to Credit Stewardship Contributions';
     $this->dtxDateCredited->Text = QDateTime::NowToString('MMMM D YYYY');
     $this->dtxDateCredited->Required = true;
     $this->btnPost = new QButton($this);
     $this->btnPost->Text = 'Post to NOAH';
     $this->btnPost->CssClass = 'primary';
     $this->btnPost->CausesValidation = $this->dtxDateCredited;
     $this->btnSplit = new QButton($this);
     $this->btnSplit->Text = 'Split This Batch';
     $this->btnSplit->CssClass = 'alternate';
     $this->btnSplit->SetCustomStyle('float', 'right');
     $this->btnSplit->AddAction(new QClickEvent(), new QAjaxAction('btnSplit_Click'));
     $this->dlgEditFund = new QDialogBox($this);
     $this->dlgEditFund->MatteClickable = false;
     $this->dlgEditFund->HideDialogBox();
     $this->dlgEditFund->Template = dirname(__FILE__) . '/dlgEditFund.tpl.php';
     $this->lblDialogFund = new QLabel($this->dlgEditFund);
     $this->lblDialogFund->Text = 'Please specify the appropriate Stewardship Funding Account for this line item.';
     $this->lblDialogFund->Visible = false;
     $this->lstDialogFund = new QListBox($this->dlgEditFund);
     $this->lstDialogFund->Name = 'Stewardship Fund';
     $this->lstDialogFund->AddItem('- Select One -', null);
     $this->lstDialogFund->Required = true;
     foreach (StewardshipFund::LoadArrayByActiveFlag(true, QQ::OrderBy(QQN::StewardshipFund()->Name)) as $objFund) {
         $this->lstDialogFund->AddItem($objFund->Name, $objFund->Id);
     }
     $this->lstDialogFund->AddItem('- Other (Non-Donation)... -', -1);
     $this->lstDialogFund->AddAction(new QChangeEvent(), new QAjaxAction('lstDialogFund_Change'));
     $this->lstDialogFund->Visible = false;
     $this->txtDialogOther = new QTextBox($this->dlgEditFund);
     $this->txtDialogOther->Name = 'Non-Donation Funding Account';
     $this->txtDialogOther->Visible = false;
     $this->lblDialogSplitFund = new QLabel($this->dlgEditFund);
     $this->lblDialogSplitFund->Visible = false;
     $this->lstDialogSplitFund = array();
     $this->txtDialogSplitOther = array();
     $this->txtDialogSplitAmount = array();
     $this->lblDialogSplitFundTitle = array();
     for ($i = 0; $i < 2; $i++) {
         $this->lblDialogSplitFundTitle[$i] = new QLabel($this->dlgEditFund);
         $this->lblDialogSplitFundTitle[$i]->HtmlEntities = false;
         $this->lblDialogSplitFundTitle[$i]->Text = '<h4>Line Item ' . ($i + 1) . '</h4>';
         $this->lblDialogSplitFundTitle[$i]->Visible = false;
         $this->lstDialogSplitFund[$i] = new QListBox($this->dlgEditFund);
         $this->lstDialogSplitFund[$i]->Name = 'Stewardship Fund';
         $this->lstDialogSplitFund[$i]->AddItem('- Select One -', null);
         $this->lstDialogSplitFund[$i]->Required = true;
         foreach (StewardshipFund::LoadArrayByActiveFlag(true, QQ::OrderBy(QQN::StewardshipFund()->Name)) as $objFund) {
             $this->lstDialogSplitFund[$i]->AddItem($objFund->Name, $objFund->Id);
         }
         $this->lstDialogSplitFund[$i]->AddItem('- Other (Non-Donation)... -', -1);
         $this->lstDialogSplitFund[$i]->ActionParameter = $i;
         $this->lstDialogSplitFund[$i]->AddAction(new QChangeEvent(), new QAjaxAction('lstDialogSplitFund_Change'));
         $this->lstDialogSplitFund[$i]->Visible = false;
         $this->txtDialogSplitOther[$i] = new QTextBox($this->dlgEditFund);
         $this->txtDialogSplitOther[$i]->Name = 'Non-Donation Funding Account';
         $this->txtDialogSplitOther[$i]->Visible = false;
         $this->txtDialogSplitAmount[$i] = new QFloatTextBox($this->dlgEditFund);
         $this->txtDialogSplitAmount[$i]->Name = 'Funding Amount';
         $this->txtDialogSplitAmount[$i]->Visible = false;
     }
     $this->rbtnUpdateFundSelection = new QRadioButtonList($this->dlgEditFund);
     $this->rbtnUpdateFundSelection->AddItem('Change Stewardship Funding Account of the Line Item', 1);
     $this->rbtnUpdateFundSelection->AddItem('Split this Line Item into two separate Funding Accounts', 2);
     $this->rbtnUpdateFundSelection->HtmlBefore = 'Select how you would like to update this Stewardship Fund';
     $this->rbtnUpdateFundSelection->AddAction(new QChangeEvent(), new QAjaxAction('rbtnUpdateFundSelection_Change'));
     $this->btnDialogSave = new QButton($this->dlgEditFund);
     $this->btnDialogSave->CssClass = 'primary';
     $this->btnDialogSave->Text = 'Update';
     $this->btnDialogSave->CausesValidation = QCausesValidation::SiblingsAndChildren;
     $this->btnDialogSave->AddAction(new QClickEvent(), new QAjaxAction('btnDialogSave_Click'));
     $this->btnDialogCancel = new QLinkButton($this->dlgEditFund);
     $this->btnDialogCancel->CssClass = 'cancel';
     $this->btnDialogCancel->Text = 'Cancel';
     $this->btnDialogCancel->AddAction(new QClickEvent(), new QAjaxAction('btnDialogCancel_Click'));
     $this->btnDialogCancel->AddAction(new QClickEvent(), new QTerminateAction());
     $this->dlgSplit = new QDialogBox($this);
     $this->dlgSplit->MatteClickable = false;
     $this->dlgSplit->HideDialogBox();
     $this->dlgSplit->Template = dirname(__FILE__) . '/dlgSplit.tpl.php';
     $this->lstSplitItem = new QListBox($this->dlgSplit);
     $this->lstSplitItem->Name = 'Transaction Split Point';
     $this->lstSplitItem->AddItem('- Select One -', null);
     $this->lstSplitItem->Required = true;
     foreach ($this->objBatch->GetCreditCardPaymentArray(QQ::OrderBy(QQN::CreditCardPayment()->DateCaptured)) as $objPayment) {
         $this->lstSplitItem->AddItem('After ' . $objPayment->DateCaptured->ToString('MMM D YYYY h:mm z'), $objPayment->Id);
     }
     $this->txtSplitNameCurrent = new QTextBox($this->dlgSplit);
     $this->txtSplitNameCurrent->Name = 'Batch Number/Title for Original Batch';
     $this->txtSplitNameCurrent->Text = $this->objBatch->Number . ' (1)';
     $this->txtSplitNameNew = new QTextBox($this->dlgSplit);
     $this->txtSplitNameNew->Name = 'Batch Number/Title for New Batch';
     $this->txtSplitNameNew->Text = $this->objBatch->Number . ' (2)';
     $this->btnSplitSave = new QButton($this->dlgSplit);
     $this->btnSplitSave->CssClass = 'primary';
     $this->btnSplitSave->Text = 'Split';
     $this->btnSplitSave->CausesValidation = QCausesValidation::SiblingsAndChildren;
     $this->btnSplitSave->AddAction(new QClickEvent(), new QAjaxAction('btnSplitSave_Click'));
     $this->btnSplitCancel = new QLinkButton($this->dlgSplit);
     $this->btnSplitCancel->CssClass = 'cancel';
     $this->btnSplitCancel->Text = 'Cancel';
     $this->btnSplitCancel->AddAction(new QClickEvent(), new QAjaxAction('btnSplitCancel_Click'));
     $this->btnSplitCancel->AddAction(new QClickEvent(), new QTerminateAction());
     $this->Transactions_Refresh();
 }