}
        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();
    }
}
exit;
Exemplo n.º 2
0
        $data['port'] = '';
    }
    if ($form->hasValidData('use_smtp') && $form->use_smtp == true) {
        $data['use_smtp'] = 1;
    } else {
        $data['use_smtp'] = 0;
    }
    if ($form->hasValidData('username')) {
        $data['username'] = $form->username;
    } else {
        $data['username'] = '';
    }
    if ($form->hasValidData('password')) {
        $data['password'] = $form->password;
    } else {
        $data['password'] = '';
    }
    $smtpData->value = serialize($data);
    $smtpData->saveThis();
    if (isset($_POST['StoreSMTPSettingsTest'])) {
        try {
            erLhcoreClassChatMail::sendTestMail($currentUser->getUserData());
        } catch (Exception $e) {
            $tpl->set('errors', array($e->getMessage()));
        }
    }
    $tpl->set('updated', 'done');
}
$tpl->set('smtp_data', $data);
$Result['content'] = $tpl->fetch();
$Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('system/configuration'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('system/htmlcode', 'System configuration')), array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('system/smtp', 'SMTP settings')));
    $tpl->set('forceoffline', true);
}
$tpl->set('leaveamessage', $leaveamessage);
if (isset($_POST['StartChat']) && $disabled_department === false) {
    // Validate post data
    $Errors = erLhcoreClassChatValidator::validateStartChat($inputData, $startDataFields, $chat, $additionalParams);
    if (count($Errors) == 0 && !isset($_POST['switchLang'])) {
        $chat->setIP();
        erLhcoreClassModelChat::detectLocation($chat);
        $statusGeoAdjustment = erLhcoreClassChat::getAdjustment(erLhcoreClassModelChatConfig::fetch('geoadjustment_data')->data_value, $inputData->vid);
        if ($statusGeoAdjustment['status'] == 'hidden') {
            // This should never happen
            exit('Chat not available in your country');
        }
        if (isset($additionalParams['offline']) && $additionalParams['offline'] == true || $statusGeoAdjustment['status'] == 'offline') {
            erLhcoreClassChatMail::sendMailRequest($inputData, $chat, array('chatprefill' => isset($chatPrefill) ? $chatPrefill : false));
            if (isset($chatPrefill) && $chatPrefill instanceof erLhcoreClassModelChat) {
                erLhcoreClassChatValidator::updateInitialChatAttributes($chatPrefill, $chat);
            }
            erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chat_offline_request', array('input_data' => $inputData, 'chat' => $chat, 'prefill' => array('chatprefill' => isset($chatPrefill) ? $chatPrefill : false)));
            $Result['parent_messages'][] = 'lh_callback:offline_request_cb';
            $tpl->set('request_send', true);
        } else {
            $chat->time = time();
            $chat->status = 0;
            $chat->hash = erLhcoreClassChat::generateHash();
            $chat->referrer = isset($_POST['URLRefer']) ? $_POST['URLRefer'] : '';
            $chat->session_referrer = isset($_POST['r']) ? $_POST['r'] : '';
            if (empty($chat->nick)) {
                $chat->nick = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Visitor');
            }
Exemplo n.º 4
0
 public static function storeCollectedInformation($form, $collectedInformation)
 {
     $formCollected = new erLhAbstractModelFormCollected();
     $formCollected->ip = erLhcoreClassIPDetect::getIP();
     $formCollected->ctime = time();
     $formCollected->form_id = $form->id;
     $formCollected->identifier = isset($_POST['identifier']) ? $_POST['identifier'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
     $formCollected->saveThis();
     // Finish collect information
     foreach ($collectedInformation as $fieldName => &$params) {
         if ($params['definition']['type'] == 'file') {
             $dir = 'var/storageform/' . date('Y') . 'y/' . date('m') . '/' . date('d') . '/' . $formCollected->id . '/';
             erLhcoreClassChatEventDispatcher::getInstance()->dispatch('form.fill.file_path', array('path' => &$dir, 'storage_id' => $formCollected->id));
             erLhcoreClassFileUpload::mkdirRecursive($dir);
             $file = erLhcoreClassSearchHandler::moveUploadedFile($params['definition']['name'], $dir);
             $params['filename'] = $file;
             $params['filepath'] = $dir;
             erLhcoreClassChatEventDispatcher::getInstance()->dispatch('form.fill.store_file', array('file_params' => &$params));
         }
     }
     $formCollected->content = serialize($collectedInformation);
     $formCollected->saveThis();
     // Inform user about filled form
     erLhcoreClassChatMail::informFormFilled($formCollected, array('email' => self::$mainEmail));
 }
Exemplo n.º 5
0
            $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Invalid captcha code, please enable Javascript!');
        }
    } else {
        // Captcha validation
        if (!$form->hasValidData($nameField) || $form->{$nameField} == '' || $form->{$nameField} < time() - 600) {
            $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Invalid captcha code, please enable Javascript!');
        }
    }
    // Dynamic URL has higher priority
    if ($dynamic_url != '') {
        $item_new->url = $dynamic_url;
    }
    if (count($Errors) == 0) {
        $item_new->active = 0;
        $item_new->saveThis();
        erLhcoreClassChatMail::sendMailFAQ($item_new);
        $item_new = new erLhcoreClassFaq();
        $tpl->set('success', true);
        if (isset($_SESSION[erLhcoreClassIPDetect::getIP()]['form'])) {
            unset($_SESSION[erLhcoreClassIPDetect::getIP()]['form']);
        }
    } else {
        $tpl->set('errors', $Errors);
    }
    $tpl->set('edittab', true);
}
$tpl->set('items', $items);
$tpl->set('item_new', $item_new);
$tpl->set('pages', $pages);
$Result['content'] = $tpl->fetch();
$Result['pagelayout'] = 'widget';
 public static function createCustomer($instance)
 {
     $originalSiteAccess = erLhcoreClassSystem::instance()->SiteAccess;
     if ($instance->locale != '') {
         erLhcoreClassSystem::instance()->setSiteAccessByLocale($instance->locale);
     }
     $password = erLhcoreClassModelForgotPassword::randomPassword(10);
     $chat_box_hash = erLhcoreClassModelForgotPassword::randomPassword(10);
     $searchArray = array('{email_replace}', '{password_hash}', '{export_hash_chats}', '{chat_box_hash}', '{chat_box_hash_length}');
     $cfg = erConfigClassLhConfig::getInstance();
     $replaceArray = array($instance->email, sha1($password . $cfg->getSetting('site', 'secrethash') . sha1($password)), erLhcoreClassModelForgotPassword::randomPassword(10), $chat_box_hash, strlen($chat_box_hash));
     $db = ezcDbInstance::get();
     self::deleteDatabase($instance->id);
     self::createDatabase($instance->id);
     $db->query('USE ' . $cfg->getSetting('db', 'database_user_prefix') . $instance->id);
     $sql = file_get_contents('extension/instance/doc/db_3.sql');
     $sql = str_replace($searchArray, $replaceArray, $sql);
     $db->query($sql);
     $dbPostUpdate = ltrim(erLhcoreClassDesign::design('db_post_update/db.sql'), '/');
     if (file_exists($dbPostUpdate)) {
         $db->query(file_get_contents($dbPostUpdate));
     }
     // Insert default user language
     if ($instance->locale != '') {
         $stm = $db->prepare("INSERT INTO `lh_users_setting` (`user_id`, `identifier`, `value`) VALUES (1,'user_language',:value)");
         $stm->bindValue(':value', $instance->locale);
         $stm->execute();
     } else {
         $stm = $db->prepare("INSERT INTO `lh_users_setting` (`user_id`, `identifier`, `value`) VALUES (1,'user_language',:value)");
         $stm->bindValue(':value', 'en_EN');
         $stm->execute();
     }
     $tpl = erLhcoreClassTemplate::getInstance('lhinstance/email.tpl.php');
     $tpl->setArray(array('instance' => $instance, 'email' => $instance->email, 'password' => $password));
     $mail = new PHPMailer();
     $mail->CharSet = 'UTF-8';
     $mail->Sender = $mail->From = $cfg->getSetting('site', 'seller_mail');
     $mail->FromName = $cfg->getSetting('site', 'seller_title');
     $mail->Subject = $cfg->getSetting('site', 'seller_title');
     $mail->AddReplyTo($cfg->getSetting('site', 'seller_mail'), $cfg->getSetting('site', 'seller_title'));
     $mail->Body = $tpl->fetch();
     $mail->AddAddress($instance->email);
     erLhcoreClassChatMail::setupSMTP($mail);
     $mail->Send();
     $mail->ClearAddresses();
     // Dispatch event for listeners
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('instance.registered.created', array('instance' => $instance));
     $db->query('USE ' . $cfg->getSetting('db', 'database'));
     // Activate instance
     $sql = "UPDATE lhc_instance_client SET status = 1 WHERE id = {$instance->id}";
     $db->query($sql);
     if ($instance->locale != '') {
         erLhcoreClassSystem::instance()->setSiteAccess($originalSiteAccess);
     }
 }
Exemplo n.º 7
0
 public static function newChatInformWorkflow($options = array(), &$chat)
 {
     $chat->nc_cb_executed = 1;
     $chat->updateThis();
     if (in_array('mail', $options['options'])) {
         erLhcoreClassChatMail::sendMailUnacceptedChat($chat);
     }
     if (in_array('xmp', $options['options'])) {
         erLhcoreClassXMP::sendXMPMessage($chat);
     }
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.new_chat', array('chat' => &$chat));
     // Execute callback if it exists
     $extensions = erConfigClassLhConfig::getInstance()->getSetting('site', 'extensions');
     $instance = erLhcoreClassSystem::instance();
     foreach ($extensions as $ext) {
         $callbackFile = $instance->SiteDir . '/extension/' . $ext . '/callbacks/new_chat.php';
         if (file_exists($callbackFile)) {
             include $callbackFile;
         }
     }
 }
Exemplo n.º 8
0
 public static function closeChatCallback($chat, $operator = false)
 {
     $extensions = erConfigClassLhConfig::getInstance()->getSetting('site', 'extensions');
     $instance = erLhcoreClassSystem::instance();
     foreach ($extensions as $ext) {
         $callbackFile = $instance->SiteDir . '/extension/' . $ext . '/callbacks/close_chat.php';
         if (file_exists($callbackFile)) {
             include $callbackFile;
         }
     }
     erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.close', array('chat' => &$chat, 'user_data' => $operator));
     if (($dep = $chat->department) !== false && $dep->inform_close == 1) {
         erLhcoreClassChatMail::informChatClosed($chat, $operator);
     }
 }
Exemplo n.º 9
0
        $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('permission/request', 'Please choose a user!');
    } else {
        $userRecipient = erLhcoreClassModelUser::fetch($form->UserID);
    }
    if ($userRecipient !== false && $userRecipient->rec_per_req == 0) {
        $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('permission/request', 'This user can not receive permision request!');
    }
    if ($form->hasValidData('Permissions') && $form->Permissions != '') {
        $permissionsCombinations = explode(',', $form->Permissions);
        $permissionsRequestedData = array();
        foreach ($permissionsCombinations as $combination) {
            list($module, $function) = explode('_f_', $combination);
            $moduleName = erLhcoreClassModules::getModuleName($module);
            erLhcoreClassChatEventDispatcher::getInstance()->dispatch('lhpermission.getmodulename', array('module' => $module, 'name' => &$moduleName));
            $functionName = erLhcoreClassModules::getFunctionName($module, $function);
            $permissionsRequestedData[] = $moduleName . ' - ' . $functionName;
        }
        $tpl->set('permission', $form->Permissions);
    } else {
        $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('permission/request', 'Permissions were not provided');
    }
    if (empty($Errors)) {
        erLhcoreClassChatMail::sendMailRequestPermission($userRecipient, $currentUser->getUserData(), implode("\n", $permissionsRequestedData));
        $tpl->set('requested', true);
    } else {
        $tpl->set('errors', $Errors);
    }
}
$tpl->set('users', erLhcoreClassModelUser::getUserList(array('limit' => 100, 'filter' => array('rec_per_req' => 1))));
$Result['content'] = $tpl->fetch();
$Result['pagelayout'] = 'popup';
Exemplo n.º 10
0
            $host = $_SERVER['HTTP_HOST'];
            $adminEmail = erConfigClassLhConfig::getInstance()->getSetting('site', 'site_admin_email');
            $UserData = erLhcoreClassUser::getSession()->load('erLhcoreClassModelUser', $userID);
            $hash = erLhcoreClassModelForgotPassword::randomPassword(40);
            erLhcoreClassModelForgotPassword::setRemindHash($UserData->id, $hash);
            $mail = new PHPMailer();
            $mail->CharSet = "UTF-8";
            $mail->From = $adminEmail;
            $mail->FromName = erConfigClassLhConfig::getInstance()->getSetting('site', 'title');
            $mail->Subject = erTranslationClassLhTranslation::getInstance()->getTranslation('user/forgotpassword', 'Password remind');
            // HTML body
            $body = erTranslationClassLhTranslation::getInstance()->getTranslation('user/forgotpassword', 'Click this link and You will be sent a new password') . ' </br><a href="http://' . $host . erLhcoreClassDesign::baseurl('user/remindpassword') . '/' . $hash . '">Restore password</a>';
            // Plain text body
            $text_body = erTranslationClassLhTranslation::getInstance()->getTranslation('user/forgotpassword', 'Click this link and You will be sent a new password') . ' - http://' . $host . erLhcoreClassDesign::baseurl('user/remindpassword') . '/' . $hash;
            $mail->Body = $body;
            $mail->AltBody = $text_body;
            $mail->AddAddress($UserData->email, $UserData->username);
            erLhcoreClassChatMail::setupSMTP($mail);
            $mail->Send();
            $mail->ClearAddresses();
            $tpl = erLhcoreClassTemplate::getInstance('lhuser/forgotpasswordsent.tpl.php');
        } else {
            erLhcoreClassModule::redirect('user/forgotpassword');
            exit;
        }
    } else {
        $tpl->set('errors', $Errors);
    }
}
$Result['content'] = $tpl->fetch();
$Result['pagelayout'] = 'login';
 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();
 }
Exemplo n.º 12
0
 public static function autoInformVisitor($minutesTimeout)
 {
     if ($minutesTimeout > 0) {
         $items = erLhcoreClassChat::getList(array('limit' => 10, 'filterlt' => array('last_op_msg_time' => time() - 1 * 60), 'filter' => array('has_unread_op_messages' => 1, 'unread_op_messages_informed' => 0)));
         // Update chats instantly
         foreach ($items as $item) {
             $item->has_unread_op_messages = 0;
             $item->unread_op_messages_informed = 1;
             $item->updateThis();
         }
         // Now inform visitors
         foreach ($items as $item) {
             erLhcoreClassChatMail::informVisitorUnreadMessage($item);
         }
     }
 }
 /**
  * Sends expire mail
  */
 public static function sendExpireMail(erLhcoreClassModelInstance $instance, $expireOption)
 {
     $cfg = erConfigClassLhConfig::getInstance();
     $originalSiteAccess = erLhcoreClassSystem::instance()->SiteAccess;
     if ($instance->locale != '') {
         erLhcoreClassSystem::instance()->setSiteAccessByLocale($instance->locale);
     }
     $tpl = erLhcoreClassTemplate::getInstance('lhinstance/expire_options_mails/' . $expireOption['template']);
     $tpl->setArray(array('instance' => $instance, 'email' => $instance->email, 'client_attributes_array' => $instance->client_attributes_array));
     $mail = new PHPMailer();
     $mail->CharSet = 'UTF-8';
     $mail->Sender = $mail->From = $cfg->getSetting('site', 'seller_mail');
     $mail->FromName = $cfg->getSetting('site', 'seller_title');
     $mail->Subject = $expireOption['mail']['subject'];
     $mail->AddReplyTo($cfg->getSetting('site', 'seller_mail'), $cfg->getSetting('site', 'seller_title'));
     $mail->Body = $tpl->fetch();
     $mail->AddAddress($instance->email);
     erLhcoreClassChatMail::setupSMTP($mail);
     $mail->Send();
     $mail->ClearAddresses();
 }