function striptags($var, $decode = true) { if (is_array($var)) { return array_map(array('Format', 'striptags'), $var, array_fill(0, count($var), $decode)); } return strip_tags($decode ? Format::htmldecode($var) : $var); }
function searchable($value) { $value = preg_replace(array('`<br(\\s*)?/?>`i', '`</div>`i'), "\n", $value); $value = Format::htmldecode(Format::striptags($value)); return Format::searchable($value); }
function send($to, $subject, $message, $options = null) { global $ost; //Get the goodies require_once PEAR_DIR . 'Mail.php'; // PEAR Mail package require_once PEAR_DIR . 'Mail/mime.php'; // PEAR Mail_Mime packge //do some cleanup $to = preg_replace("/(\r\n|\r|\n)/s", '', trim($to)); $subject = preg_replace("/(\r\n|\r|\n)/s", '', trim($subject)); //We're decoding html entities here becasuse we only support plain text for now - html support comming. $body = Format::htmldecode(preg_replace("/(\r\n|\r)/s", "\n", trim($message))); /* Message ID - generated for each outgoing email */ $messageId = sprintf('<%s%d-%s>', Misc::randCode(6), time(), $this->getEmail() ? $this->getEmail()->getEmail() : '@osTicketMailer'); $headers = array('From' => $this->getFromAddress(), 'To' => $to, 'Subject' => $subject, 'Date' => date('D, d M Y H:i:s O'), 'Message-ID' => $messageId, 'X-Mailer' => 'osTicket Mailer'); //Set bulk/auto-response headers. if ($options && ($options['autoreply'] or $options['bulk'])) { $headers += array('X-Autoreply' => 'yes', 'X-Auto-Response-Suppress' => 'ALL, AutoReply', 'Auto-Submitted' => 'auto-replied'); if ($options['bulk']) { $headers += array('Precedence' => 'bulk'); } else { $headers += array('Precedence' => 'auto_reply'); } } if ($options) { if (isset($options['inreplyto']) && $options['inreplyto']) { $headers += array('In-Reply-To' => $options['inreplyto']); } if (isset($options['references']) && $options['references']) { if (is_array($options['references'])) { $headers += array('References' => implode(' ', $options['references'])); } else { $headers += array('References' => $options['references']); } } } $mime = new Mail_mime(); $mime->setTXTBody($body); //XXX: Attachments if ($attachments = $this->getAttachments()) { foreach ($attachments as $attachment) { if ($attachment['file_id'] && ($file = AttachmentFile::lookup($attachment['file_id']))) { $mime->addAttachment($file->getData(), $file->getType(), $file->getName(), false); } elseif ($attachment['file'] && file_exists($attachment['file']) && is_readable($attachment['file'])) { $mime->addAttachment($attachment['file'], $attachment['type'], $attachment['name']); } } } //Desired encodings... $encodings = array('head_encoding' => 'quoted-printable', 'text_encoding' => 'base64', 'html_encoding' => 'base64', 'html_charset' => 'utf-8', 'text_charset' => 'utf-8', 'head_charset' => 'utf-8'); //encode the body $body = $mime->get($encodings); //encode the headers. $headers = $mime->headers($headers, true); if ($smtp = $this->getSMTPInfo()) { //Send via SMTP $mail = mail::factory('smtp', array('host' => $smtp['host'], 'port' => $smtp['port'], 'auth' => $smtp['auth'], 'username' => $smtp['username'], 'password' => $smtp['password'], 'timeout' => 20, 'debug' => false)); $result = $mail->send($to, $headers, $body); if (!PEAR::isError($result)) { return $messageId; } $alert = sprintf("Unable to email via SMTP:%s:%d [%s]\n\n%s\n", $smtp['host'], $smtp['port'], $smtp['username'], $result->getMessage()); $this->logError($alert); } //No SMTP or it failed....use php's native mail function. $mail = mail::factory('mail'); return PEAR::isError($mail->send($to, $headers, $body)) ? false : $messageId; }
function getSearchable() { // <br> -> \n $body = preg_replace(array('`<br(\\s*)?/?>`i', '`</div>`i'), "\n", $this->body); $body = Format::htmldecode(Format::striptags($body)); return Format::searchable($body); }
static function fromVars($vars) { // Try and lookup by email address $user = static::lookupByEmail($vars['email']); if (!$user) { $name = $vars['name']; if (!$name) { list($name) = explode('@', $vars['email'], 2); } $user = User::create(array('name' => Format::htmldecode(Format::sanitize($name, false)), 'created' => new SqlFunction('NOW'), 'updated' => new SqlFunction('NOW'), 'default_email' => UserEmail::ensure($vars['email']))); // Is there an organization registered for this domain list($mailbox, $domain) = explode('@', $vars['email'], 2); if (isset($vars['org_id'])) { $user->set('org_id', $vars['org_id']); } elseif ($org = Organization::forDomain($domain)) { $user->setOrganization($org, false); } try { $user->save(true); $user->emails->add($user->default_email); // Attach initial custom fields $user->addDynamicData($vars); } catch (OrmException $e) { return null; } } return $user; }
static function fromVars($vars, $update = false) { // Try and lookup by email address $user = static::lookupByEmail($vars['email']); if (!$user) { $name = $vars['name']; if (!$name) { list($name) = explode('@', $vars['email'], 2); } $user = User::create(array('name' => Format::htmldecode(Format::sanitize($name, false)), 'created' => new SqlFunction('NOW'), 'updated' => new SqlFunction('NOW'), 'default_email' => UserEmail::ensure($vars['email']))); // Is there an organization registered for this domain list($mailbox, $domain) = explode('@', $vars['email'], 2); if (isset($vars['org_id'])) { $user->set('org_id', $vars['org_id']); } elseif ($org = Organization::forDomain($domain)) { $user->setOrganization($org, false); } try { $user->save(true); $user->emails->add($user->default_email); // Attach initial custom fields $user->addDynamicData($vars); } catch (OrmException $e) { return null; } } elseif ($update) { $errors = array(); $user->updateInfo($vars, $errors, true); } /* INICIO Anthony Parisi */ if (isset($_SESSION["crmEmail"])) { $mysqli = new mysqli("localhost", "root", "ip15x0", "vtigercrm600"); $sqlUser = $mysqli->query("SELECT MAX(id) FROM `vtigercrm600`.vtiger_modtracker_detail;"); $resUser = $sqlUser->fetch_array(); $mysqli->query("UPDATE `vtigercrm600`.`vtiger_contactdetails` SET `mobile` = '" . $_SESSION["crmPhone"] . "' WHERE UPPER(`vtiger_contactdetails`.`email`) = UPPER('" . $_SESSION["crmEmail"] . "');"); $mysqli->query("INSERT INTO `vtigercrm600`.vtiger_modtracker_detail(id,fieldname,prevalue,postvalue) VALUES('" . $resUser[0] . "','email',NULL,'" . $_SESSION["crmPhone"] . "');"); unset($_SESSION["crmEmail"]); unset($_SESSION["crmPhone"]); } /* FIN */ return $user; }