Example #1
0
 public static function getOutArray()
 {
     if (self::$outArray == null) {
         $tpl = new erLhcoreClassTemplate();
         $smileys = explode('||', $tpl->fetch('lhbbcode/smiley.tpl.php'));
         self::$outArray = $smileys;
     }
     return self::$outArray;
 }
Example #2
0
 public static function validateSendMail(erLhAbstractModelEmailTemplate &$sendMail, &$chat, $params = array())
 {
     $Errors = array();
     $validationFields = array();
     $validationFields['Message'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw');
     $validationFields['Subject'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw');
     $validationFields['FromName'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw');
     $validationFields['FromEmail'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email');
     $validationFields['ReplyEmail'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email');
     $validationFields['RecipientEmail'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email');
     $form = new ezcInputForm(INPUT_POST, $validationFields);
     $Errors = array();
     if (isset($params['archive_mode']) && $params['archive_mode'] == true) {
         $messages = array_reverse(erLhcoreClassChat::getList(array('limit' => 100, 'sort' => 'id DESC', 'filter' => array('chat_id' => $chat->id)), 'erLhcoreClassModelChatArchiveMsg', erLhcoreClassModelChatArchiveRange::$archiveMsgTable));
     } else {
         $messages = array_reverse(erLhcoreClassModelmsg::getList(array('limit' => 100, 'sort' => 'id DESC', 'filter' => array('chat_id' => $chat->id))));
     }
     // Fetch chat messages
     $tpl = new erLhcoreClassTemplate('lhchat/messagelist/plain.tpl.php');
     $tpl->set('chat', $chat);
     $tpl->set('messages', $messages);
     $sendMail->content = str_replace(array('{user_chat_nick}', '{messages_content}'), array($chat->nick, $tpl->fetch()), $sendMail->content);
     if ($form->hasValidData('Message')) {
         $sendMail->content = str_replace('{additional_message}', $form->Message, $sendMail->content);
     }
     $sendMail->content = erLhcoreClassBBCode::parseForMail($sendMail->content);
     if ($form->hasValidData('FromEmail')) {
         $sendMail->from_email = $form->FromEmail;
     }
     if ($form->hasValidData('ReplyEmail')) {
         $sendMail->reply_to = $form->ReplyEmail;
     }
     if ($form->hasValidData('FromName')) {
         $sendMail->from_name = $form->FromName;
     }
     if ($form->hasValidData('Subject')) {
         $sendMail->subject = $form->Subject;
     }
     if ($form->hasValidData('RecipientEmail')) {
         $sendMail->recipient = $form->RecipientEmail;
     } else {
         $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendmail', 'Please enter recipient e-mail!');
     }
     if (empty($sendMail->from_email)) {
         $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendmail', 'From e-mail is missing!');
     }
     if (empty($sendMail->reply_to)) {
         $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendmail', 'Reply e-mail is missing!');
     }
     if (empty($sendMail->subject)) {
         $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendmail', 'Subject is missing!');
     }
     return $Errors;
 }
            $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/edit', 'Wrong email address');
        }
        if (!isset($_SERVER['HTTP_X_CSRFTOKEN']) || !isset($_POST['csfr_token']) || $_POST['csfr_token'] != $_SERVER['HTTP_X_CSRFTOKEN']) {
            $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/edit', 'Invalid CSRF token!');
        }
        if (empty($Errors)) {
            $tpl = erLhcoreClassTemplate::getInstance('lhchat/sendmail.tpl.php');
            $mailTemplate = erLhAbstractModelEmailTemplate::fetch(3);
            erLhcoreClassChatMail::prepareSendMail($mailTemplate);
            $mailTemplate->recipient = $form->email;
            $messages = array_reverse(erLhcoreClassModelmsg::getList(array('customfilter' => array('user_id != -1'), 'limit' => 500, 'sort' => 'id DESC', 'filter' => array('chat_id' => $chat->id))));
            // Fetch chat messages
            $tpl = new erLhcoreClassTemplate('lhchat/messagelist/plain.tpl.php');
            $tpl->set('chat', $chat);
            $tpl->set('messages', $messages);
            $mailTemplate->content = str_replace(array('{user_chat_nick}', '{messages_content}'), array($chat->nick, $tpl->fetch()), $mailTemplate->content);
            erLhcoreClassChatMail::sendMail($mailTemplate, $chat);
            echo json_encode(array('error' => 'false'));
            exit;
        } else {
            $tpl = erLhcoreClassTemplate::getInstance('lhkernel/validation_error.tpl.php');
            $tpl->set('errors', $Errors);
            echo json_encode(array('error' => 'true', 'result' => $tpl->fetch()));
            exit;
        }
    } else {
        $tpl = erLhcoreClassTemplate::getInstance('lhchat/sendchat.tpl.php');
        $tpl->set('chat', $chat);
        echo $tpl->fetch();
    }
}
Example #4
0
                    if ($form->hasValidData('AdminEmail')) {
                        $tpl->set('admin_email', $form->AdminEmail);
                    }
                    $tpl->set('admin_name', $form->AdminName);
                    $tpl->set('admin_surname', $form->AdminSurname);
                    $tpl->set('admin_departament', $form->DefaultDepartament);
                    $tpl->set('errors', $Errors);
                    $tpl->setFile('lhinstall/install3.tpl.php');
                }
            } else {
                $tpl->setFile('lhinstall/install3.tpl.php');
            }
            break;
        case '4':
            $tpl->setFile('lhinstall/install4.tpl.php');
            break;
        default:
            $tpl->setFile('lhinstall/install1.tpl.php');
            break;
    }
    $Result['content'] = $tpl->fetch();
    $Result['pagelayout'] = 'install';
    $Result['path'] = array(array('title' => 'Live helper chat installation'));
} catch (Exception $e) {
    echo "Make sure that &quot;cache/*&quot; is writable and then <a href=\"" . erLhcoreClassDesign::baseurl('install/install') . "\">try again</a>";
    echo "<pre>";
    print_r($e);
    echo "</pre>";
    exit;
    exit;
}
Example #5
0
 public function chatExportJSON(erLhcoreClassModelChat $chat)
 {
     $tpl = new erLhcoreClassTemplate('lhexport/json.tpl.php');
     $tpl->set('chat', $chat);
     return $tpl->fetch();
 }
 public function addSMSMessageSend($number)
 {
     $this->sms_left -= $number;
     $this->sms_processed += $number;
     if ($this->soft_limit_in_effect == true && $this->soft_warning_send == 0) {
         $this->soft_warning_send = 1;
         // Send mail to global administrator
         $mail = new PHPMailer(true);
         $mail->CharSet = "UTF-8";
         $mail->Subject = erTranslationClassLhTranslation::getInstance()->getTranslation('instance/edit', 'Instance has reached soft SMS limit') . ' - ' . $this->id;
         $mail->AddReplyTo($this->email, (string) $this->address);
         $tpl = new erLhcoreClassTemplate();
         $tpl->set('instance', $this);
         // Remove new line characters
         $content = str_replace("\n", "", $tpl->fetch('lhinstance/mail/phone_soft_limit.tpl.php'));
         // Replace br with new line characters
         $content = str_replace("<br/>", "\n", $content);
         $mail->Body = $content;
         $mail->AddAddress(erConfigClassLhConfig::getInstance()->getSetting('site', 'support_mail'));
         erLhcoreClassChatMail::setupSMTP($mail);
         try {
             $mail->Send();
         } catch (Exception $e) {
         }
         $mail->ClearAddresses();
         // Send mail to instance admin
         $mail = new PHPMailer(true);
         $mail->CharSet = "UTF-8";
         $mail->Subject = erTranslationClassLhTranslation::getInstance()->getTranslation('instance/edit', 'You have reached soft SMS limit');
         $mail->AddReplyTo($this->email, (string) $this->address);
         $tpl = new erLhcoreClassTemplate();
         $tpl->set('instance', $this);
         // Remove new line characters
         $content = str_replace("\n", "", $tpl->fetch('lhinstance/mail/phone_soft_limit_user.tpl.php'));
         // Replace br with new line characters
         $content = str_replace("<br/>", "\n", $content);
         $mail->Body = $content;
         $mail->AddAddress($this->email);
         erLhcoreClassChatMail::setupSMTP($mail);
         try {
             $mail->Send();
         } catch (Exception $e) {
         }
         $mail->ClearAddresses();
     }
     if ($this->hard_limit_in_effect == true && $this->hard_warning_send == 0) {
         $this->hard_warning_send = 1;
         // Send mail to global administrator
         $mail = new PHPMailer(true);
         $mail->CharSet = "UTF-8";
         $mail->Subject = erTranslationClassLhTranslation::getInstance()->getTranslation('instance/edit', 'Instance has reached hard SMS limit') . ' - ' . $this->id;
         $mail->AddReplyTo($this->email, (string) $this->address);
         $tpl = new erLhcoreClassTemplate();
         $tpl->set('instance', $this);
         // Remove new line characters
         $content = str_replace("\n", "", $tpl->fetch('lhinstance/mail/phone_hard_limit.tpl.php'));
         // Replace br with new line characters
         $content = str_replace("<br/>", "\n", $content);
         $mail->Body = $content;
         $mail->AddAddress(erConfigClassLhConfig::getInstance()->getSetting('site', 'support_mail'));
         erLhcoreClassChatMail::setupSMTP($mail);
         try {
             $mail->Send();
         } catch (Exception $e) {
         }
         $mail->ClearAddresses();
         // Send mail to instance admin
         $mail = new PHPMailer(true);
         $mail->CharSet = "UTF-8";
         $mail->Subject = erTranslationClassLhTranslation::getInstance()->getTranslation('instance/edit', 'You have reached hard SMS limit');
         $mail->AddReplyTo($this->email, (string) $this->address);
         $tpl = new erLhcoreClassTemplate();
         $tpl->set('instance', $this);
         // Remove new line characters
         $content = str_replace("\n", "", $tpl->fetch('lhinstance/mail/phone_hard_limit_user.tpl.php'));
         // Replace br with new line characters
         $content = str_replace("<br/>", "\n", $content);
         $mail->Body = $content;
         $mail->AddAddress($this->email);
         erLhcoreClassChatMail::setupSMTP($mail);
         try {
             $mail->Send();
         } catch (Exception $e) {
         }
         $mail->ClearAddresses();
     }
     $this->saveToInstanceThis();
 }