Exemple #1
0
 public static function _make_url_embed_image($matches)
 {
     $in = $matches[1];
     $in = trim($in);
     $error = false;
     $forumImage = false;
     $in = str_replace(' ', '%20', $in);
     $inline = ')';
     $scheme = '[a-z\\d+\\-.]';
     // generated with regex generation file in the develop folder
     $exp_url = "[a-z]{$scheme}*:/{2}(?:(?:[a-z0-9\\-._~!\$&'({$inline}*+,;=:@|]+|%[\\dA-F]{2})+|[0-9.]+|\\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\\])(?::\\d*)?(?:/(?:[a-z0-9\\-._~!\$&'({$inline}*+,;=:@|]+|%[\\dA-F]{2})*)*(?:\\?(?:[a-z0-9\\-._~!\$&'({$inline}*+,;=:@/?|]+|%[\\dA-F]{2})*)?(?:\\#(?:[a-z0-9\\-._~!\$&'({$inline}*+,;=:@/?|]+|%[\\dA-F]{2})*)?";
     $inline = ')';
     $www_url = "www\\.(?:[a-z0-9\\-._~!\$&'({$inline}*+,;=:@|]+|%[\\dA-F]{2})+(?::\\d*)?(?:/(?:[a-z0-9\\-._~!\$&'({$inline}*+,;=:@|]+|%[\\dA-F]{2})*)*(?:\\?(?:[a-z0-9\\-._~!\$&'({$inline}*+,;=:@/?|]+|%[\\dA-F]{2})*)?(?:\\#(?:[a-z0-9\\-._~!\$&'({$inline}*+,;=:@/?|]+|%[\\dA-F]{2})*)?";
     // Localy uploaded photo
     $instance = erLhcoreClassSystem::instance();
     $instance->wwwDir();
     if (preg_match('#^' . $instance->wwwDir() . '/var/forum/[a-zA-Z0-9_\\-.\\/\\\\]*$#i', $in)) {
         $forumImage = true;
         // Checking urls
     } elseif (!preg_match('#^' . $exp_url . '$#i', $in) && !preg_match('#^' . $www_url . '$#i', $in)) {
         return '[img]' . $in . '[/img]';
     }
     // Try to cope with a common user error... not specifying a protocol but only a subdomain
     if ($forumImage == false && !preg_match('#^[a-z0-9]+://#i', $in)) {
         $in = 'http://' . $in;
     }
     return "<div class=\"img_embed\"><img src=\"" . htmlspecialchars($in) . "\" alt=\"\" /></div>";
 }
 public function __get($variable)
 {
     switch ($variable) {
         case 'data':
             $this->data = unserialize($this->value);
             return $this->data;
             break;
         case 'data_value':
             $this->data_value = $this->data;
             return $this->data_value;
             break;
         case 'current_value':
             switch ($this->type) {
                 case self::SITE_ACCESS_PARAM_ON:
                     $this->current_value = null;
                     if ($this->value != '') {
                         $this->current_value = isset($this->data[erLhcoreClassSystem::instance()->SiteAccess]) ? $this->data[erLhcoreClassSystem::instance()->SiteAccess] : null;
                     }
                     return $this->current_value;
                     break;
                 case self::SITE_ACCESS_PARAM_OFF:
                     $this->current_value = $this->value;
                     return $this->current_value;
                     break;
                 default:
                     break;
             }
             $this->data = unserialize($this->value);
             return $this->data;
             break;
         default:
             break;
     }
 }
Exemple #3
0
 /**
  * This function should be used then value can be override by siteAccess
  * or user language has influence to returned value
  *
  * */
 public function getDirLanguage($attribute = 'dir_language')
 {
     $value = null;
     if ($this->hasSetting('site', $attribute)) {
         $value = $this->getSetting('site', $attribute);
     }
     $siteAccess = erLhcoreClassSystem::instance()->SiteAccess;
     if ($siteAccess == 'site_admin') {
         $valueOverride = $this->getSetting('site_access_options', $siteAccess);
         if (key_exists($attribute, $valueOverride)) {
             // User has not changed default site access language. So just return current value.
             if (erLhcoreClassModelUserSetting::getSetting('user_language', $valueOverride['locale']) == $valueOverride['locale']) {
                 return $valueOverride[$attribute];
             } else {
                 // User has changed default siteaccess language, we need to check does ltr or rtl matches
                 foreach ($this->getSetting('site', 'available_site_access') as $siteaccess) {
                     // Loop untill we find our locate siteaccess and check it's language direction
                     $siteAccessOptions = $this->getSetting('site_access_options', $siteaccess);
                     if ($siteAccessOptions['locale'] == erLhcoreClassModelUserSetting::getSetting('user_language', $valueOverride['locale'])) {
                         return $siteAccessOptions[$attribute];
                     }
                 }
             }
         }
     } else {
         $value = $this->getOverrideValue('site', $attribute);
     }
     return $value;
 }
 public function __get($param)
 {
     switch ($param) {
         case 'name_support':
             return trim($this->name . ' ' . $this->surname);
             break;
         case 'user_groups_id':
             $userGroups = erLhcoreClassModelGroupUser::getList(array('filter' => array('user_id' => $this->id)));
             $this->user_groups_id = array();
             if (!empty($userGroups)) {
                 foreach ($userGroups as $userGroup) {
                     $this->user_groups_id[] = $userGroup->group_id;
                 }
             }
             return $this->user_groups_id;
             break;
         case 'lastactivity':
             $db = ezcDbInstance::get();
             $stmt = $db->prepare('SELECT last_activity FROM lh_userdep WHERE user_id = :user_id LIMIT 1');
             $stmt->bindValue(':user_id', $this->id, PDO::PARAM_INT);
             $stmt->execute();
             $this->lastactivity = (int) $stmt->fetchColumn();
             return $this->lastactivity;
             break;
         case 'has_photo':
             return $this->filename != '';
             break;
         case 'photo_path':
             $this->photo_path = ($this->filepath != '' ? erLhcoreClassSystem::instance()->wwwDir() : erLhcoreClassSystem::instance()->wwwImagesDir()) . '/' . $this->filepath . $this->filename;
             return $this->photo_path;
             break;
         case 'file_path_server':
             return $this->filepath . $this->filename;
             break;
         case 'lastactivity_front':
             $this->lastactivity_front = '';
             if ($this->lastactivity > 0) {
                 $this->lastactivity_front = date(erLhcoreClassModule::$dateDateHourFormat);
             }
             return $this->lastactivity_front;
             break;
         case 'lastactivity_ago':
             $this->lastactivity_ago = '';
             if ($this->lastactivity > 0) {
                 $periods = array("s.", "m.", "h.", "d.", "w.", "m.", "y.", "dec.");
                 $lengths = array("60", "60", "24", "7", "4.35", "12", "10");
                 $difference = time() - $this->lastactivity;
                 for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) {
                     $difference /= $lengths[$j];
                 }
                 $difference = round($difference);
                 $this->lastactivity_ago = "{$difference} {$periods[$j]}";
             }
             return $this->lastactivity_ago;
             break;
         default:
             break;
     }
 }
 public function __get($var)
 {
     switch ($var) {
         case 'has_file':
             return $this->has_file = $this->file_name != '';
             break;
         case 'file_path_server':
             return $this->file_path_server = 'var/' . $this->file_path . $this->file_name;
             break;
         case 'file_path_dir':
             return $this->file_path_server = 'var/' . $this->file_path;
             break;
         case 'pdftoimg_path':
             return $this->pdftoimg_path = 'var/' . $this->file_path . 'img/';
             break;
         case 'pdf_file_path_server':
             return $this->pdf_file_path_server = 'var/' . $this->file_path . $this->pdf_file;
             break;
         case 'file_name_upload_pdf':
             $nameParts = explode('.', $this->file_name_upload);
             array_pop($nameParts);
             return $this->file_name_upload_pdf = implode('.', $nameParts) . '.pdf';
             break;
         case 'pages_pdf':
             $this->pages_pdf = array();
             if ($this->pages_pdf_count) {
                 $links = array();
                 $i = 1;
                 while ($i <= $this->pages_pdf_count) {
                     $links[] = $this->pdftoimg_path . $this->id . '-' . $i . '.png';
                     $i++;
                 }
                 $this->pages_pdf = $links;
             }
             return $this->pages_pdf;
             break;
         case 'pdftoimg_url_path':
             return $this->pdftoimg_url_path = erLhcoreClassSystem::instance()->wwwDir() . '/var/' . $this->file_path . 'img/';
             break;
         case 'pages_pdf_url':
             $this->pages_pdf_url = array();
             if ($this->pages_pdf_count) {
                 $baseDir = erLhcoreClassSystem::instance()->wwwDir();
                 foreach ($this->pages_pdf as $img) {
                     $this->pages_pdf_url[] = $baseDir . '/' . $img;
                 }
             }
             return $this->pages_pdf_url;
             break;
         case 'book_data':
             return array('baseImagesDesgin' => erLhcoreClassDesign::design('images/BookReader/images') . '/', 'baseImg' => $this->id . '-', 'numLeafs' => $this->pages_pdf_count, 'bookTitle' => $this->name, 'urlPath' => $this->pdftoimg_url_path);
             break;
         default:
             break;
     }
 }
Exemple #6
0
 /**
  * Set's chat language
  * 
  * Detects chats languages, operator and visitor and translates recent chat messages
  * 
  * @param erLhcoreClassModelChat $chat
  * 
  * @param string $visitorLanguage | Optional
  * 
  * @param string $operatorLanguage | Optional
  * 
  * @return void || Exception
  * */
 public static function setChatLanguages(erLhcoreClassModelChat $chat, $visitorLanguage, $operatorLanguage)
 {
     $originalLanguages = array('chat_locale' => $chat->chat_locale, 'chat_locale_to' => $chat->chat_locale_to);
     $supportedLanguages = self::getSupportedLanguages(true);
     $db = ezcDbInstance::get();
     $data = array();
     if (key_exists($visitorLanguage, $supportedLanguages)) {
         $chat->chat_locale = $data['chat_locale'] = $visitorLanguage;
     } else {
         // We take few first messages from visitor and try to detect language
         $stmt = $db->prepare('SELECT msg FROM lh_msg WHERE chat_id = :chat_id AND user_id = 0 ORDER BY id ASC LIMIT 3 OFFSET 0');
         $stmt->bindValue(':chat_id', $chat->id);
         $stmt->execute();
         $rows = $stmt->fetchAll(PDO::FETCH_COLUMN);
         foreach ($rows as &$row) {
             $row = preg_replace('#\\[translation\\](.*?)\\[/translation\\]#is', '', $row);
         }
         $msgText = substr(implode("\n", $rows), 0, 500);
         $languageCode = self::detectLanguage($msgText);
         $chat->chat_locale = $data['chat_locale'] = $languageCode;
     }
     if (key_exists($operatorLanguage, $supportedLanguages)) {
         $chat->chat_locale_to = $data['chat_locale_to'] = $operatorLanguage;
     } else {
         // We need to detect opetator language, basically we just take back office language and try to find a match
         $languageCode = substr(erLhcoreClassSystem::instance()->Language, 0, 2);
         if (key_exists($languageCode, $supportedLanguages)) {
             $chat->chat_locale_to = $data['chat_locale_to'] = $languageCode;
         } else {
             throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('chat/translation', 'We could not detect operator language'));
         }
     }
     if ($chat->chat_locale == $chat->chat_locale_to) {
         throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('chat/translation', 'Detected operator and visitor languages matches, please choose languages manually'));
     }
     // Because chat data can be already be changed we modify just required fields
     $stmt = $db->prepare('UPDATE lh_chat SET chat_locale_to = :chat_locale_to, chat_locale =:chat_locale WHERE id = :chat_id');
     $stmt->bindValue(':chat_id', $chat->id, PDO::PARAM_INT);
     $stmt->bindValue(':chat_locale_to', $data['chat_locale_to'], PDO::PARAM_STR);
     $stmt->bindValue(':chat_locale', $data['chat_locale'], PDO::PARAM_STR);
     $stmt->execute();
     // We have to translate only if our languages are different
     if ($originalLanguages['chat_locale'] != $chat->chat_locale || $originalLanguages['chat_locale_to'] != $chat->chat_locale_to) {
         // And now we can translate all chat messages
         self::translateChatMessages($chat);
     }
     return $data;
 }
 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);
     }
 }
        if ($form->hasValidData('module') && $form->module != '') {
            $input->module = $form->module;
        } else {
            $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('system/languages', 'Please enter module name');
        }
        if ($form->hasValidData('view') && $form->view != '') {
            $input->view = $form->view;
        } else {
            $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('system/languages', 'Please enter view name');
        }
        if (empty($Errors)) {
            erLhcoreClassSiteaccessGenerator::updateSiteAccess($input);
            // Clean cache
            $CacheManager = erConfigClassLhCacheConfig::getInstance();
            $CacheManager->expireCache();
            // Redirect for change to take effect
            erLhcoreClassModule::redirect('system/languages', '/(updated)/true/(sa)/' . $input->siteaccess);
            exit;
        } else {
            $tpl->set('errors', $Errors);
        }
    }
}
$cfgSite = erConfigClassLhConfig::getInstance();
$tpl->set('locales', $cfgSite->getSetting('site', 'available_site_access'));
$tpl->set('current_site_access', erLhcoreClassSystem::instance()->SiteAccess);
$tpl->set('input', $input);
$tpl->set('currentUser', $currentUser);
$tpl->set('tab', $tab);
$Result['content'] = $tpl->fetch();
$Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('system/configuration'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('system/languages', 'Languages configuration')));
Exemple #9
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);
     }
 }
    public static function processProActiveInvitation(erLhcoreClassModelChatOnlineUser &$item, $params = array())
    {
        $referrer = self::getHost($item->referrer);
        $session = erLhcoreClassAbstract::getSession();
        $appendTag = '';
        $q = $session->createFindQuery('erLhAbstractModelProactiveChatInvitation');
        if (isset($params['tag']) && $params['tag'] != '') {
            $appendTag = 'AND (' . $q->expr->eq('tag', $q->bindValue($params['tag'])) . ' OR tag = \'\')';
        } else {
            $appendTag = 'AND (tag = \'\')';
        }
        $q->where($q->expr->lte('time_on_site', $q->bindValue($item->time_on_site)) . ' AND ' . $q->expr->lte('pageviews', $q->bindValue($item->pages_count)) . '
				AND (' . $q->expr->eq('siteaccess', $q->bindValue(erLhcoreClassSystem::instance()->SiteAccess)) . ' OR siteaccess = \'\')
				AND (' . $q->expr->eq('identifier', $q->bindValue($item->identifier)) . ' OR identifier = \'\')
				' . $appendTag . '
				AND (' . $q->expr->eq('dep_id', $q->bindValue($item->dep_id)) . ' OR dep_id = 0)
				AND (' . $q->expr->like($session->database->quote(trim($referrer)), 'concat(referrer,\'%\')') . ' OR referrer = \'\')')->orderBy('position ASC')->limit(1);
        $messagesToUser = $session->find($q);
        if (!empty($messagesToUser)) {
            $message = array_shift($messagesToUser);
            // Use default message if first time visit or returning message is empty
            if ($item->total_visits == 1 || $message->message_returning == '') {
                $item->operator_message = $message->message;
            } else {
                if ($item->chat !== false && $item->chat->nick != '') {
                    $nick = $item->chat->nick;
                } elseif ($message->message_returning_nick != '') {
                    $nick = $message->message_returning_nick;
                } else {
                    $nick = '';
                }
                $item->operator_message = str_replace('{nick}', $nick, $message->message_returning);
            }
            $item->operator_user_proactive = $message->operator_name;
            $item->invitation_id = $message->id;
            $item->invitation_seen_count = 0;
            $item->requires_email = $message->requires_email;
            $item->requires_username = $message->requires_username;
            $item->requires_phone = $message->requires_phone;
            $item->invitation_count++;
            $item->store_chat = true;
            $item->invitation_assigned = true;
            $item->last_visit = time();
            if ($message->show_random_operator == 1) {
                $item->operator_user_id = erLhcoreClassChat::getRandomOnlineUserID(array('operators' => explode(',', trim($message->operator_ids))));
            }
            $message->executed_times += 1;
            $message->updateThis();
            erLhcoreClassChatEventDispatcher::getInstance()->dispatch('onlineuser.proactive_triggered', array('message' => &$message, 'ou' => &$item));
        }
    }
 public static function processAutoResponder(erLhcoreClassModelChat $chat)
 {
     $session = erLhcoreClassAbstract::getSession();
     $q = $session->createFindQuery('erLhAbstractModelAutoResponder');
     $q->where('(' . $q->expr->eq('siteaccess', $q->bindValue(erLhcoreClassSystem::instance()->SiteAccess)) . ' OR siteaccess = \'\') AND (' . $q->expr->eq('dep_id', $q->bindValue($chat->dep_id)) . ' OR dep_id = 0)')->orderBy('position ASC')->limit(1);
     $messagesToUser = $session->find($q);
     if (!empty($messagesToUser)) {
         $message = array_shift($messagesToUser);
         return $message;
     }
     return false;
 }
            // Redirect user
            erLhcoreClassModule::redirect('chat/chatwidgetchat', '/' . $chat->id . '/' . $chat->hash . $modeAppend . '/(cstarted)/online_chat_started_cb');
            flush();
            session_write_close();
            if (function_exists('fastcgi_finish_request')) {
                fastcgi_finish_request();
            }
            erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chat_started', array('chat' => &$chat));
            exit;
        }
    } else {
        // Show errors only if user is not switching form mode and not swithing language
        if ($Params['user_parameters_unordered']['switchform'] != 'true' && !isset($_POST['switchLang'])) {
            $tpl->set('errors', $Errors);
        } elseif (isset($_POST['switchLang'])) {
            $Result['additional_post_message'] = 'lhc_lang:' . erLhcoreClassSystem::instance()->WWWDirLang;
        }
    }
}
$tpl->set('start_data_fields', $startDataFields);
$definition = array('name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'value' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'type' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string', null, FILTER_REQUIRE_ARRAY), 'size' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string', null, FILTER_REQUIRE_ARRAY), 'req' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string', null, FILTER_REQUIRE_ARRAY), 'sh' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string', null, FILTER_REQUIRE_ARRAY), 'hattr' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string', null, FILTER_REQUIRE_ARRAY));
$form = new ezcInputForm(INPUT_GET, $definition);
if ($form->hasValidData('name') && !empty($form->name)) {
    $inputData->name_items = $form->name;
}
if ($form->hasValidData('value') && !empty($form->value)) {
    $inputData->value_items = $form->value;
}
if ($form->hasValidData('hattr') && !empty($form->hattr)) {
    $inputData->hattr = $form->hattr;
}
			<form action="<?php 
    echo erLhcoreClassDesign::baseurl('system/languages');
    ?>
" method="post">
    				<?php 
    include erLhcoreClassDesign::designtpl('lhkernel/csfr_token.tpl.php');
    ?>
    				
    				<div class="form-group">
        				<label><?php 
    echo erTranslationClassLhTranslation::getInstance()->getTranslation('system/languages', 'Language');
    ?>
</label> 
        				<select name="language" class="form-control">
        					<?php 
    $userLanguage = erLhcoreClassModelUserSetting::getSetting('user_language', erLhcoreClassSystem::instance()->Language);
    foreach (erLhcoreClassSiteaccessGenerator::getLanguages() as $language) {
        ?>
        						<option value="<?php 
        echo $language['locale'];
        ?>
" <?php 
        $userLanguage == $language['locale'] ? print 'selected="selected"' : '';
        ?>
><?php 
        echo $language['locale'];
        ?>
</option>
        					<?php 
    }
    ?>
Exemple #14
0
 /**
  * Open, parse, and return the template file.
  *
  * @param $file string the template file name
  */
 function fetch($fileTemplate = null)
 {
     $instance = erLhcoreClassSystem::instance();
     $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80;
     if (!$fileTemplate) {
         $fileTemplate = $this->file;
     }
     if ($this->cacheEnabled == true && key_exists(md5($fileTemplate . $instance->WWWDirLang . $instance->Language . $port), $this->cacheTemplates)) {
         try {
             return $this->fetchExecute($this->cacheTemplates[md5($fileTemplate . $instance->WWWDirLang . $instance->Language . $port)]);
         } catch (Exception $e) {
         }
     }
     $cfg = erConfigClassLhConfig::getInstance();
     $file = erLhcoreClassDesign::designtpl($fileTemplate);
     if ($this->templatecompile == true) {
         $contentFile = php_strip_whitespace($file);
         // Compile templates - 3 level of inclusions
         for ($i = 0; $i < 9; $i++) {
             $Matches = array();
             preg_match_all('/<\\?php(\\s*)include_once\\(erLhcoreClassDesign::designtpl\\(\'([a-zA-Z0-9-\\.-\\/\\_]+)\'\\)\\)(.*?)\\?\\>/i', $contentFile, $Matches);
             foreach ($Matches[2] as $key => $Match) {
                 $contentFile = str_replace($Matches[0][$key], php_strip_whitespace(erLhcoreClassDesign::designtpl($Match)), $contentFile);
             }
             //Compile templates inclusions first level.
             $Matches = array();
             preg_match_all('/<\\?php(\\s*)include\\(erLhcoreClassDesign::designtpl\\(\'([a-zA-Z0-9-\\.-\\/\\_]+)\'\\)\\)(.*?)\\?\\>/i', $contentFile, $Matches);
             foreach ($Matches[2] as $key => $Match) {
                 $contentFile = str_replace($Matches[0][$key], php_strip_whitespace(erLhcoreClassDesign::designtpl($Match)), $contentFile);
             }
         }
         //Compile image css paths. Etc..
         $Matches = array();
         preg_match_all('/<\\?php echo erLhcoreClassDesign::design\\(\'([a-zA-Z0-9-\\.-\\/\\_]+)\'\\)(.*?)\\?\\>/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $Match) {
             $contentFile = str_replace($Matches[0][$key], erLhcoreClassDesign::design($Match), $contentFile);
         }
         //Compile translations, pure translations
         $Matches = array();
         preg_match_all('/<\\?php echo erTranslationClassLhTranslation::getInstance\\(\\)->getTranslation\\(\'(.*?)\',\'(.*?)\'\\)(.*?)\\?\\>/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $TranslateContent) {
             $contentFile = str_replace($Matches[0][$key], erTranslationClassLhTranslation::getInstance()->getTranslation($TranslateContent, $Matches[2][$key]), $contentFile);
         }
         //Translations used in logical conditions
         $Matches = array();
         preg_match_all('/erTranslationClassLhTranslation::getInstance\\(\\)->getTranslation\\(\'(.*?)\',\'(.*?)\'\\)/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $TranslateContent) {
             $contentFile = str_replace($Matches[0][$key], '\'' . erTranslationClassLhTranslation::getInstance()->getTranslation($TranslateContent, $Matches[2][$key]) . '\'', $contentFile);
         }
         // Compile url addresses
         $Matches = array();
         preg_match_all('/<\\?php echo erLhcoreClassDesign::baseurl\\((.*?)\\)(.*?)\\?\\>/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $contentFile = str_replace($Matches[0][$key], erLhcoreClassDesign::baseurl(trim($UrlAddress, '\'')), $contentFile);
         }
         // Compile url direct addresses
         $Matches = array();
         preg_match_all('/<\\?php echo erLhcoreClassDesign::baseurldirect\\((.*?)\\)(.*?)\\?\\>/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $contentFile = str_replace($Matches[0][$key], erLhcoreClassDesign::baseurldirect(trim($UrlAddress, '\'')), $contentFile);
         }
         // Compile url direct addresses
         $Matches = array();
         preg_match_all('/<\\?php echo erLhcoreClassDesign::baseurlsite\\(\\)(.*?)\\?\\>/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $contentFile = str_replace($Matches[0][$key], erLhcoreClassDesign::baseurlsite(), $contentFile);
         }
         // Compile css url addresses
         $Matches = array();
         preg_match_all('/<\\?php echo erLhcoreClassDesign::designCSS\\((.*?)\\)(.*?)\\?\\>/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $contentFile = str_replace($Matches[0][$key], erLhcoreClassDesign::designCSS(trim($UrlAddress, '\'')), $contentFile);
         }
         // Compile css url addresses
         $Matches = array();
         preg_match_all('/<\\?php echo erLhcoreClassDesign::designJS\\((.*?)\\)(.*?)\\?\\>/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $contentFile = str_replace($Matches[0][$key], erLhcoreClassDesign::designJS(trim($UrlAddress, '\'')), $contentFile);
         }
         // Compile url addresses in logical operations
         $Matches = array();
         preg_match_all('/erLhcoreClassDesign::baseurl\\((.*?)\\)/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $contentFile = str_replace($Matches[0][$key], '\'' . erLhcoreClassDesign::baseurl(trim($UrlAddress, '\'')) . '\'', $contentFile);
         }
         // Compile url addresses in logical operations
         $Matches = array();
         preg_match_all('/erLhcoreClassDesign::baseurldirect\\((.*?)\\)/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $contentFile = str_replace($Matches[0][$key], '\'' . erLhcoreClassDesign::baseurldirect(trim($UrlAddress, '\'')) . '\'', $contentFile);
         }
         // Compile config settings, direct output
         $Matches = array();
         preg_match_all('/<\\?php echo erConfigClassLhConfig::getInstance\\(\\)->getSetting\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?),(\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)(.*?)\\?\\>/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $valueConfig = erConfigClassLhConfig::getInstance()->getSetting($Matches[2][$key], $Matches[5][$key]);
             $valueReplace = '';
             if (is_bool($valueConfig)) {
                 $valueReplace = $valueConfig == false ? 'false' : 'true';
             } elseif (is_integer($valueConfig)) {
                 $valueReplace = $valueConfig;
             } elseif (is_array($valueConfig)) {
                 $valueReplace = var_export($valueConfig, true);
             } else {
                 $valueReplace = $valueConfig;
             }
             $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
         }
         // Compile config settings
         $Matches = array();
         preg_match_all('/erConfigClassLhConfig::getInstance\\(\\)->getSetting\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?),(\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $valueConfig = erConfigClassLhConfig::getInstance()->getSetting($Matches[2][$key], $Matches[5][$key]);
             $valueReplace = '';
             if (is_bool($valueConfig)) {
                 $valueReplace = $valueConfig == false ? 'false' : 'true';
             } elseif (is_integer($valueConfig)) {
                 $valueReplace = $valueConfig;
             } elseif (is_array($valueConfig)) {
                 $valueReplace = var_export($valueConfig, true);
             } else {
                 $valueReplace = '\'' . $valueConfig . '\'';
             }
             $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
         }
         // Compile override config settings, used in title, description override
         $Matches = array();
         preg_match_all('/<\\?php echo erConfigClassLhConfig::getInstance\\(\\)->getOverrideValue\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?),(\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)(.*?)\\?\\>/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $valueConfig = erConfigClassLhConfig::getInstance()->getOverrideValue($Matches[2][$key], $Matches[5][$key]);
             $valueReplace = '';
             if (is_bool($valueConfig)) {
                 $valueReplace = $valueConfig == false ? 'false' : 'true';
             } elseif (is_integer($valueConfig)) {
                 $valueReplace = $valueConfig;
             } elseif (is_array($valueConfig)) {
                 $valueReplace = var_export($valueConfig, true);
             } else {
                 $valueReplace = $valueConfig;
             }
             $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
         }
         // Compile override config settings
         $Matches = array();
         preg_match_all('/erConfigClassLhConfig::getInstance\\(\\)->getOverrideValue\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?),(\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $valueConfig = erConfigClassLhConfig::getInstance()->getOverrideValue($Matches[2][$key], $Matches[5][$key]);
             $valueReplace = '';
             if (is_bool($valueConfig)) {
                 $valueReplace = $valueConfig == false ? 'false' : 'true';
             } elseif (is_integer($valueConfig)) {
                 $valueReplace = $valueConfig;
             } elseif (is_array($valueConfig)) {
                 $valueReplace = var_export($valueConfig, true);
             } else {
                 $valueReplace = '\'' . $valueConfig . '\'';
             }
             $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
         }
         $Matches = array();
         preg_match_all('/<\\?php echo erConfigClassLhConfig::getInstance\\(\\)->getDirLanguage\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)(.*?)\\?\\>/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $valueConfig = erConfigClassLhConfig::getInstance()->getDirLanguage($Matches[2][$key]);
             $valueReplace = '';
             if (is_bool($valueConfig)) {
                 $valueReplace = $valueConfig == false ? 'false' : 'true';
             } elseif (is_integer($valueConfig)) {
                 $valueReplace = $valueConfig;
             } elseif (is_array($valueConfig)) {
                 $valueReplace = var_export($valueConfig, true);
             } else {
                 $valueReplace = $valueConfig;
             }
             $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
         }
         // Compile config settings
         $Matches = array();
         preg_match_all('/erConfigClassLhConfig::getInstance\\(\\)->getDirLanguage\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $var) {
             $valueConfig = erConfigClassLhConfig::getInstance()->getDirLanguage($Matches[2][$key]);
             $valueReplace = '';
             if (is_bool($valueConfig)) {
                 $valueReplace = $valueConfig == false ? 'false' : 'true';
             } elseif (is_integer($valueConfig)) {
                 $valueReplace = $valueConfig;
             } elseif (is_array($valueConfig)) {
                 $valueReplace = var_export($valueConfig, true);
             } else {
                 $valueReplace = '\'' . $valueConfig . '\'';
             }
             $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
         }
         if ($this->cacheDbVariables == true) {
             // Compile config completely
             $Matches = array();
             preg_match_all('/<\\?php echo erLhcoreClassModelChatConfig::fetch\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)->current_value(.*?)\\?\\>/i', $contentFile, $Matches);
             foreach ($Matches[1] as $key => $UrlAddress) {
                 $valueConfig = erLhcoreClassModelChatConfig::fetch($Matches[2][$key])->current_value;
                 $contentFile = str_replace($Matches[0][$key], $valueConfig, $contentFile);
             }
             // Compile config settings in php scripts
             $Matches = array();
             preg_match_all('/erLhcoreClassModelChatConfig::fetch\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)->current_value/i', $contentFile, $Matches);
             foreach ($Matches[1] as $key => $UrlAddress) {
                 $valueConfig = erLhcoreClassModelChatConfig::fetch($Matches[2][$key])->current_value;
                 $valueReplace = '';
                 $valueReplace = '\'' . str_replace("'", "\\'", $valueConfig) . '\'';
                 $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
             }
             // Compile config settings in php scripts
             $Matches = array();
             preg_match_all('/erLhcoreClassModelChatConfig::fetch\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)->data_value/i', $contentFile, $Matches);
             foreach ($Matches[1] as $key => $UrlAddress) {
                 $valueConfig = erLhcoreClassModelChatConfig::fetch($Matches[2][$key])->data_value;
                 $valueReplace = var_export($valueConfig, true);
                 $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
             }
             // Compile config settings array
             $Matches = array();
             preg_match_all('/erLhcoreClassModelChatConfig::fetch\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)->data\\[\'([a-zA-Z0-9-\\.-\\/\\_]+)\'\\]/i', $contentFile, $Matches);
             foreach ($Matches[1] as $key => $UrlAddress) {
                 $valueConfig = erLhcoreClassModelChatConfig::fetch($Matches[2][$key])->data[$Matches[4][$key]];
                 $valueReplace = '';
                 $valueReplace = '\'' . str_replace("'", "\\'", $valueConfig) . '\'';
                 $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
             }
         }
         // Compile content language
         $contentFile = str_replace('<?php echo erLhcoreClassSystem::instance()->ContentLanguage?>', erLhcoreClassSystem::instance()->ContentLanguage, $contentFile);
         // Compile siteaccess
         $contentFile = str_replace('erLhcoreClassSystem::instance()->SiteAccess', '\'' . erLhcoreClassSystem::instance()->SiteAccess . '\'', $contentFile);
         // Atomoc template compilation to avoid concurent request compiling and writing to the same file
         $fileName = 'cache/compiledtemplates/' . md5(time() . rand(0, 1000) . microtime() . $file . $instance->WWWDirLang . $instance->Language . $port) . '.php';
         file_put_contents($fileName, erLhcoreClassTemplate::strip_html($contentFile));
         $file = 'cache/compiledtemplates/' . md5($file . $instance->WWWDirLang . $instance->Language . $port) . '.php';
         rename($fileName, $file);
         $this->cacheTemplates[md5($fileTemplate . $instance->WWWDirLang . $instance->Language . $port)] = $file;
         $this->storeCache();
     }
     return $this->fetchExecute($file);
 }
Exemple #15
0
{
    ezcBase::autoload($className);
}
ezcBase::addClassRepository(dirname(__FILE__) . '/', dirname(__FILE__) . '/lib/autoloads');
$input = new ezcConsoleInput();
$helpOption = $input->registerOption(new ezcConsoleOption('s', 'siteaccess', ezcConsoleInput::TYPE_STRING));
$cronjobPartOption = $input->registerOption(new ezcConsoleOption('c', 'cronjob', ezcConsoleInput::TYPE_STRING));
$cronjobPathOption = $input->registerOption(new ezcConsoleOption('p', 'path', ezcConsoleInput::TYPE_STRING));
$extensionPartOption = $input->registerOption(new ezcConsoleOption('e', 'extension', ezcConsoleInput::TYPE_STRING));
try {
    $input->process();
} catch (ezcConsoleOptionException $e) {
    die($e->getMessage());
}
ezcBaseInit::setCallback('ezcInitDatabaseInstance', 'erLhcoreClassLazyDatabaseConfiguration');
$instance = erLhcoreClassSystem::instance();
$instance->SiteAccess = $helpOption->value;
$instance->SiteDir = dirname(__FILE__) . '/';
$cfgSite = erConfigClassLhConfig::getInstance();
$defaultSiteAccess = $cfgSite->getSetting('site', 'default_site_access');
$optionsSiteAccess = $cfgSite->getSetting('site_access_options', $helpOption->value);
$instance->Language = $optionsSiteAccess['locale'];
$instance->ThemeSite = $optionsSiteAccess['theme'];
$instance->WWWDirLang = '/' . $helpOption->value;
// php cron.php -s site_admin -c cron/workflow
// php cron.php -s site_admin -e customstatus -c cron/customcron
if ($extensionPartOption->value) {
    include_once 'extension/' . $extensionPartOption->value . '/modules/lh' . $cronjobPartOption->value . '.php';
} else {
    include_once 'modules/lh' . $cronjobPartOption->value . '.php';
}
Exemple #16
0
 public static function getModule($module)
 {
     $cfg = erConfigClassLhConfig::getInstance();
     self::$moduleCacheEnabled = $cfg->getSetting('site', 'modulecompile');
     // Because each siteaccess can have different extension cache key has to have this
     $siteAccess = erLhcoreClassSystem::instance()->SiteAccess;
     if (self::$cacheInstance === null) {
         self::$cacheInstance = CSCacheAPC::getMem();
     }
     if (self::$moduleCacheEnabled === true) {
         if (($cacheModules = self::$cacheInstance->restore('moduleFunctionsCache_' . $module . '_' . $siteAccess . '_version_' . self::$cacheVersionSite)) !== false) {
             return $cacheModules;
         }
         $cacheWriter = new erLhcoreClassCacheStorage('cache/cacheconfig/');
         if (($cacheModules = $cacheWriter->restore('moduleFunctionsCache_' . $module . '_' . $siteAccess)) == false) {
             $cacheModules = array();
         }
         if (count($cacheModules) > 0) {
             self::$cacheInstance->store('moduleFunctionsCache_' . $module . '_' . $siteAccess . '_version_' . self::$cacheVersionSite, $cacheModules);
             return $cacheModules;
         }
     }
     $extensions = $cfg->getOverrideValue('site', 'extensions');
     $ViewListCompiled = array();
     // Is it core module
     if (file_exists('modules/lh' . $module . '/module.php')) {
         include 'modules/lh' . $module . '/module.php';
         foreach ($ViewList as $view => $params) {
             $ViewList[$view]['script_path'] = 'modules/lh' . $module . '/' . $view . '.php';
         }
         $ViewListCompiled = array_merge($ViewListCompiled, $ViewList);
     }
     // Is it extension module
     foreach ($extensions as $extension) {
         if (file_exists('extension/' . $extension . '/modules/lh' . $module . '/module.php')) {
             include 'extension/' . $extension . '/modules/lh' . $module . '/module.php';
             foreach ($ViewList as $view => $params) {
                 $ViewList[$view]['script_path'] = 'extension/' . $extension . '/modules/lh' . $module . '/' . $view . '.php';
             }
             $ViewListCompiled = array_merge($ViewListCompiled, $ViewList);
         }
     }
     if (count($ViewListCompiled) > 0) {
         if (self::$moduleCacheEnabled === true) {
             $cacheWriter->store('moduleFunctionsCache_' . $module . '_' . $siteAccess, $ViewListCompiled);
             self::$cacheInstance->store('moduleFunctionsCache_' . $module . '_' . $siteAccess . '_version_' . self::$cacheVersionSite, $ViewListCompiled);
         }
         return $ViewListCompiled;
     }
     // Module does not exists
     return false;
 }
Exemple #17
0
 public static function designJS($files)
 {
     $debugOutput = erConfigClassLhConfig::getInstance()->getSetting('site', 'debug_output');
     $items = explode(';', $files);
     if ($debugOutput == true) {
         $logString = '';
         $debug = ezcDebug::getInstance();
     }
     $filesToCompress = '';
     $instance = erLhcoreClassSystem::instance();
     $extensions = erConfigClassLhConfig::getInstance()->getOverrideValue('site', 'extensions');
     foreach ($items as $path) {
         $fileFound = false;
         /**
          * Check extension folders first
          * */
         foreach ($extensions as $ext) {
             $fileDir = $instance->SiteDir . '/extension/' . $ext . '/design/' . $ext . 'theme/' . $path;
             if (file_exists($fileDir)) {
                 $fileContent = file_get_contents($fileDir);
                 // normalize line feeds
                 $script = str_replace(array("\r\n", "\r"), "\n", $fileContent);
                 // remove multiline comments
                 $script = preg_replace('!(?:\\n|\\s|^)/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $script);
                 $script = preg_replace('!(?:;)/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', ';', $script);
                 // remove whitespace from start & end of line + singelline comment + multiple linefeeds
                 $script = preg_replace(array('/\\n\\s+/', '/\\s+\\n/', '#\\n\\s*//.*#', '/\\n+/'), "\n", $script);
                 $filesToCompress .= $script . "\n";
                 $fileFound = true;
                 if ($debugOutput == true) {
                     $logString .= "<b>Found IN - " . $fileDir . "</b><br/>";
                 }
                 break;
             } else {
                 if ($debugOutput == true) {
                     $logString .= "Not found IN - " . $fileDir . "<br/>";
                 }
             }
         }
         if ($fileFound == false) {
             foreach ($instance->ThemeSite as $designDirectory) {
                 $fileDir = $instance->SiteDir . 'design/' . $designDirectory . '/' . $path;
                 if (file_exists($fileDir)) {
                     $fileContent = file_get_contents($fileDir);
                     // normalize line feeds
                     $script = str_replace(array("\r\n", "\r"), "\n", $fileContent);
                     // remove multiline comments
                     $script = preg_replace('!(?:\\n|\\s|^)/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $script);
                     $script = preg_replace('!(?:;)/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', ';', $script);
                     // remove whitespace from start & end of line + singelline comment + multiple linefeeds
                     $script = preg_replace(array('/\\n\\s+/', '/\\s+\\n/', '#\\n\\s*//.*#', '/\\n+/'), "\n", $script);
                     $filesToCompress .= $script . "\n";
                     $fileFound = true;
                     if ($debugOutput == true) {
                         $logString .= "<b>Found IN - " . $fileDir . "</b><br/>";
                     }
                     break;
                 } else {
                     if ($debugOutput == true) {
                         $logString .= "Not found IN - " . $fileDir . "<br/>";
                     }
                 }
             }
         }
     }
     $sys = erLhcoreClassSystem::instance()->SiteDir;
     $fileName = md5($filesToCompress . $instance->WWWDirLang . $instance->Language);
     $file = $sys . 'cache/compiledtemplates/' . $fileName . '.js';
     if (!file_exists($file)) {
         file_put_contents($file, $filesToCompress);
     }
     if ($debugOutput == true) {
         $debug->log($logString, 0, array("source" => "shop", "erLhcoreClassDesign" => "designJS - {$path}"));
     }
     return $instance->wwwDir() . '/cache/compiledtemplates/' . $fileName . '.js';
 }
Exemple #18
0
 public static function setSiteAccess($siteaccess)
 {
     $cfgSite = erConfigClassLhConfig::getInstance();
     $availableSiteaccess = $cfgSite->getSetting('site', 'available_site_access');
     $defaultSiteAccess = $cfgSite->getSetting('site', 'default_site_access');
     if ($defaultSiteAccess != $siteaccess && in_array($siteaccess, $availableSiteaccess)) {
         $optionsSiteAccess = $cfgSite->getSetting('site_access_options', $siteaccess);
         erLhcoreClassSystem::instance()->Language = $optionsSiteAccess['locale'];
         erLhcoreClassSystem::instance()->ThemeSite = $optionsSiteAccess['theme'];
         erLhcoreClassSystem::instance()->ContentLanguage = $optionsSiteAccess['content_language'];
         erLhcoreClassSystem::instance()->WWWDirLang = '/' . $siteaccess;
         erLhcoreClassSystem::instance()->SiteAccess = $siteaccess;
     } else {
         $optionsSiteAccess = $cfgSite->getSetting('site_access_options', $defaultSiteAccess);
         erLhcoreClassSystem::instance()->SiteAccess = $defaultSiteAccess;
         erLhcoreClassSystem::instance()->Language = $optionsSiteAccess['locale'];
         erLhcoreClassSystem::instance()->ThemeSite = $optionsSiteAccess['theme'];
         erLhcoreClassSystem::instance()->WWWDirLang = '';
         erLhcoreClassSystem::instance()->ContentLanguage = $optionsSiteAccess['content_language'];
     }
     erTranslationClassLhTranslation::getInstance()->initLanguage();
 }
var nodejshelperHostConnect = '<?php 
echo $nodeJsHelperSettings['host'];
echo $nodeJsHelperSettings['port'];
?>
';
var nodejshelperConfig = {online_timeout:<?php 
echo (int) erLhcoreClassModelChatConfig::fetch('sync_sound_settings')->data['online_timeout'];
?>
,use_publish_notifications:<?php 
echo $nodeJsHelperSettings['use_publish_notifications'] == true ? 'true' : 'false';
?>
,path:'<?php 
echo $nodeJsHelperSettings['path'];
?>
',is_admin:<?php 
echo erLhcoreClassSystem::instance()->SiteAccess == 'site_admin' ? 'true' : 'false';
?>
,instance_id:'<?php 
echo $nodeJsHelperSettings['instance_id'];
?>
',secure:<?php 
echo $nodeJsHelperSettings['secure'] == true ? 'true' : 'false';
?>
,'typer':'','sync':<?php 
echo isset($Result['chat']) && $Result['chat']->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT ? 'true' : 'false';
?>
,'synctimeout':5};
<?php

// For IE to support headers if chat is installed on different domain
header('P3P: CP="NOI ADM DEV COM NAV OUR STP"');
$visitorName = erLhcoreClassChatbox::getVisitorName();
$cache = CSCacheAPC::getMem();
$themeID = isset($Params['user_parameters_unordered']['theme']) && (int) $Params['user_parameters_unordered']['theme'] > 0 ? (int) $Params['user_parameters_unordered']['theme'] : 0;
if ($themeID == 0) {
    $defaultTheme = erLhcoreClassModelChatConfig::fetch('default_theme_id')->current_value;
    if ($defaultTheme > 0) {
        $themeID = $defaultTheme;
    }
}
$cacheKey = md5('chatbox_version_' . $cache->getCacheVersion('chatbox_' . (string) $Params['user_parameters_unordered']['identifier']) . '_theme_' . $themeID . '_identifier_' . (string) $Params['user_parameters_unordered']['identifier'] . '_hash_' . (string) $Params['user_parameters_unordered']['hashchatbox'] . $visitorName . '_height_' . (int) $Params['user_parameters_unordered']['chat_height'] . '_sound_' . (int) $Params['user_parameters_unordered']['sound'] . '_mode_' . (string) $Params['user_parameters_unordered']['mode'] . '_siteaccess_' . erLhcoreClassSystem::instance()->SiteAccess);
if (($Result = $cache->restore($cacheKey)) === false) {
    $referer = '';
    $tpl = erLhcoreClassTemplate::getInstance('lhchatbox/chatwidget.tpl.php');
    $tpl->set('chatbox_chat_height', !is_null($Params['user_parameters_unordered']['chat_height']) && (int) $Params['user_parameters_unordered']['chat_height'] > 0 ? (int) $Params['user_parameters_unordered']['chat_height'] : 220);
    if ($Params['user_parameters_unordered']['sound'] !== null && is_numeric($Params['user_parameters_unordered']['sound'])) {
        erLhcoreClassModelUserSetting::setSetting('chat_message', (int) $Params['user_parameters_unordered']['sound'] == 1 ? 1 : 0);
    }
    $chatbox = erLhcoreClassChatbox::getInstance((string) $Params['user_parameters_unordered']['identifier'], (string) $Params['user_parameters_unordered']['hashchatbox']);
    $tpl->set('chatbox', $chatbox);
    $tpl->set('referer', $referer);
    if (isset($_GET['URLReferer'])) {
        $referer = $_GET['URLReferer'];
        $tpl->set('referer', $referer);
    }
    if (isset($_POST['URLRefer'])) {
        $referer = $_POST['URLRefer'];
        $tpl->set('referer', $_POST['URLRefer']);
,
    disabledGeo : <?php 
    echo isset($disableByGeoAdjustment) && $disableByGeoAdjustment == true ? 'true' : 'false';
    ?>
,
    checkOperatorMessage : <?php 
    echo $check_operator_messages == true ? 'true' : 'false';
    ?>
,
	offset_data : '',
	lang: '<?php 
    echo erLhcoreClassSystem::instance()->WWWDirLang;
    ?>
',
	langDefault: '/<?php 
    echo erLhcoreClassSystem::instance()->SiteAccess;
    ?>
',
	is_dragging : false,
	online_tracked : false,
    urlopen : function(){   
    	return "<?php 
    echo erLhcoreClassModelChatConfig::fetch('explicit_http_mode')->current_value;
    ?>
//<?php 
    echo $_SERVER['HTTP_HOST'];
    echo erLhcoreClassDesign::baseurlsite();
    ?>
"+this.lang+"/chat/startchat<?php 
    $leaveamessage == true ? print '/(leaveamessage)/true' : '';
    $theme !== false ? print '/(theme)/' . $theme->id : '';
Exemple #22
0
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         $sysConfiguration = erLhcoreClassSystem::instance();
         $urlCfgDefault = ezcUrlConfiguration::getInstance();
         $urlCfgDefault->basedir = $sysConfiguration->WWWDir;
         $urlCfgDefault->script = $sysConfiguration->IndexFile;
         $urlCfgDefault->unorderedDelimiters = array('(', ')');
         $urlCfgDefault->orderedParameters = array();
         $urlCfgDefault->unorderedParameters = array();
         $urlCfgDefault->addOrderedParameter('siteaccess');
         $urlCfgDefault->addOrderedParameter('module');
         $urlCfgDefault->addOrderedParameter('function');
         $cfgSite = erConfigClassLhConfig::getInstance();
         $urlInstance = new erLhcoreClassURL(($cfgSite->getSetting('site', 'force_virtual_host', false) === false ? 'index.php' : '') . $sysConfiguration->RequestURI, $urlCfgDefault);
         $siteaccess = $urlInstance->getParam('siteaccess');
         $availableSiteaccess = $cfgSite->getSetting('site', 'available_site_access');
         $defaultSiteAccess = $cfgSite->getSetting('site', 'default_site_access');
         if ($defaultSiteAccess != $siteaccess && in_array($siteaccess, $availableSiteaccess)) {
             $optionsSiteAccess = $cfgSite->getSetting('site_access_options', $siteaccess);
             $sysConfiguration->Language = $siteaccess == 'site_admin' ? erLhcoreClassModelUserSetting::getSetting('user_language', $optionsSiteAccess['locale'], false, true) : $optionsSiteAccess['locale'];
             $sysConfiguration->ThemeSite = $optionsSiteAccess['theme'];
             $sysConfiguration->ContentLanguage = $optionsSiteAccess['content_language'];
             $sysConfiguration->WWWDirLang = '/' . $siteaccess;
             $sysConfiguration->SiteAccess = $siteaccess;
             if ($optionsSiteAccess['locale'] != 'en_EN') {
                 $urlInstance->setParam('module', $urlInstance->getParam('module'));
                 $urlInstance->setParam('function', $urlInstance->getParam('function'));
             }
             if (isset($_POST['switchLang']) && in_array($_POST['switchLang'], $availableSiteaccess)) {
                 $optionsSiteAccessOverride = $cfgSite->getSetting('site_access_options', $_POST['switchLang']);
                 $sysConfiguration->Language = $optionsSiteAccessOverride['locale'];
                 $sysConfiguration->SiteAccess = $_POST['switchLang'];
                 if ($defaultSiteAccess != $sysConfiguration->SiteAccess) {
                     $sysConfiguration->WWWDirLang = '/' . $sysConfiguration->SiteAccess;
                 } else {
                     $sysConfiguration->WWWDirLang = '';
                 }
             }
         } else {
             $optionsSiteAccess = $cfgSite->getSetting('site_access_options', $defaultSiteAccess);
             // Falling back
             $sysConfiguration->SiteAccess = $defaultSiteAccess;
             $sysConfiguration->Language = $siteaccess == 'site_admin' ? erLhcoreClassModelUserSetting::getSetting('user_language', $optionsSiteAccess['locale'], false, true) : $optionsSiteAccess['locale'];
             $sysConfiguration->ThemeSite = $optionsSiteAccess['theme'];
             $sysConfiguration->ContentLanguage = $optionsSiteAccess['content_language'];
             if (isset($_POST['switchLang']) && in_array($_POST['switchLang'], $availableSiteaccess)) {
                 $optionsSiteAccessOverride = $cfgSite->getSetting('site_access_options', $_POST['switchLang']);
                 $sysConfiguration->Language = $optionsSiteAccessOverride['locale'];
                 $sysConfiguration->SiteAccess = $_POST['switchLang'];
                 if ($defaultSiteAccess != $sysConfiguration->SiteAccess) {
                     $sysConfiguration->WWWDirLang = '/' . $sysConfiguration->SiteAccess;
                 }
             }
             // To reset possition counter
             $urlCfgDefault->removeOrderedParameter('siteaccess');
             $urlCfgDefault->removeOrderedParameter('module');
             $urlCfgDefault->removeOrderedParameter('function');
             // Reinit parameters
             $urlCfgDefault->addOrderedParameter('module');
             $urlCfgDefault->addOrderedParameter('function');
             //Apply default configuration
             $urlInstance->applyConfiguration($urlCfgDefault);
             if ($optionsSiteAccess['locale'] != 'en_EN') {
                 $urlInstance->setParam('module', $urlInstance->getParam('module'));
                 $urlInstance->setParam('function', $urlInstance->getParam('function'));
             }
         }
         self::$instance = $urlInstance;
     }
     return self::$instance;
 }
Exemple #23
0
 public static function getModuleFile($disableCacheManually = false)
 {
     $cfg = erConfigClassLhConfig::getInstance();
     $cacheEnabled = $cfg->getSetting('site', 'modulecompile');
     if ($cacheEnabled === false || $disableCacheManually === true) {
         return self::$currentModule[self::$currentView]['script_path'];
     } else {
         $instance = erLhcoreClassSystem::instance();
         $cacheKey = md5(self::$currentModuleName . '_' . self::$currentView . '_' . $instance->WWWDirLang . '_' . $instance->Language);
         if (($cacheModules = self::$cacheInstance->restore('moduleCache_' . self::$currentModuleName . '_version_' . self::$cacheVersionSite)) !== false && key_exists($cacheKey, $cacheModules)) {
             return $cacheModules[$cacheKey];
         }
         $cacheWriter = new erLhcoreClassCacheStorage('cache/cacheconfig/');
         if (($cacheModules = $cacheWriter->restore('moduleCache_' . self::$currentModuleName)) == false) {
             $cacheWriter->store('moduleCache_' . self::$currentModuleName, array());
             $cacheModules = array();
         }
         if (key_exists($cacheKey, $cacheModules)) {
             self::$cacheInstance->store('moduleCache_' . self::$currentModuleName . '_version_' . self::$cacheVersionSite, $cacheModules);
             return $cacheModules[$cacheKey];
         }
         $file = self::$currentModule[self::$currentView]['script_path'];
         $contentFile = php_strip_whitespace($file);
         $Matches = array();
         preg_match_all('/erTranslationClassLhTranslation::getInstance\\(\\)->getTranslation\\(\'(.*?)\',\'(.*?)\'\\)/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $TranslateContent) {
             $contentFile = str_replace($Matches[0][$key], '\'' . erTranslationClassLhTranslation::getInstance()->getTranslation($TranslateContent, $Matches[2][$key]) . '\'', $contentFile);
         }
         $Matches = array();
         preg_match_all('/erLhcoreClassDesign::baseurl\\((.*?)\\)/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $contentFile = str_replace($Matches[0][$key], '\'' . erLhcoreClassDesign::baseurl(trim($UrlAddress, '\'')) . '\'', $contentFile);
         }
         // Compile additional JS
         $Matches = array();
         preg_match_all('/erLhcoreClassDesign::designJS\\(\'(.*?)\'\\)/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $contentFile = str_replace($Matches[0][$key], '\'' . erLhcoreClassDesign::designJS(trim($UrlAddress, '\'')) . '\'', $contentFile);
         }
         $Matches = array();
         preg_match_all('/erLhcoreClassDesign::baseurldirect\\((.*?)\\)/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $contentFile = str_replace($Matches[0][$key], '\'' . erLhcoreClassDesign::baseurldirect(trim($UrlAddress, '\'')) . '\'', $contentFile);
         }
         $contentFile = str_replace('erLhcoreClassSystem::instance()->SiteAccess', '\'' . erLhcoreClassSystem::instance()->SiteAccess . '\'', $contentFile);
         $Matches = array();
         preg_match_all('/erConfigClassLhConfig::getInstance\\(\\)->getSetting\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?),(\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)/i', $contentFile, $Matches);
         foreach ($Matches[1] as $key => $UrlAddress) {
             $valueConfig = erConfigClassLhConfig::getInstance()->getSetting($Matches[2][$key], $Matches[5][$key]);
             $valueReplace = '';
             if (is_bool($valueConfig)) {
                 $valueReplace = $valueConfig == false ? 'false' : 'true';
             } elseif (is_integer($valueConfig)) {
                 $valueReplace = $valueConfig;
             } elseif (is_array($valueConfig)) {
                 $valueReplace = var_export($valueConfig, true);
             } else {
                 $valueReplace = '\'' . $valueConfig . '\'';
             }
             $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
         }
         if (self::$cacheDbVariables === true) {
             // Compile config settings
             $Matches = array();
             preg_match_all('/erLhcoreClassModelChatConfig::fetch\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)->current_value/i', $contentFile, $Matches);
             foreach ($Matches[1] as $key => $UrlAddress) {
                 $valueConfig = erLhcoreClassModelChatConfig::fetch($Matches[2][$key])->current_value;
                 $valueReplace = '';
                 $valueReplace = '\'' . str_replace("'", "\\'", $valueConfig) . '\'';
                 $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
             }
             // Compile config settings in php scripts
             $Matches = array();
             preg_match_all('/erLhcoreClassModelChatConfig::fetch\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)->data_value/i', $contentFile, $Matches);
             foreach ($Matches[1] as $key => $UrlAddress) {
                 $valueConfig = erLhcoreClassModelChatConfig::fetch($Matches[2][$key])->data_value;
                 $valueReplace = var_export($valueConfig, true);
                 $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
             }
             // Compile config settings array
             $Matches = array();
             preg_match_all('/erLhcoreClassModelChatConfig::fetch\\((\\s?)\'([a-zA-Z0-9-\\.-\\/\\_]+)\'(\\s?)\\)->data\\[\'([a-zA-Z0-9-\\.-\\/\\_]+)\'\\]/i', $contentFile, $Matches);
             foreach ($Matches[1] as $key => $UrlAddress) {
                 $valueConfig = erLhcoreClassModelChatConfig::fetch($Matches[2][$key])->data[$Matches[4][$key]];
                 $valueReplace = '';
                 $valueReplace = '\'' . str_replace("'", "\\'", $valueConfig) . '\'';
                 $contentFile = str_replace($Matches[0][$key], $valueReplace, $contentFile);
             }
         }
         $fileCompiled = 'cache/compiledtemplates/' . md5($file . $instance->WWWDirLang . '_' . $instance->Language) . '.php';
         // Atomoc template compilation to avoid concurent request compiling and writing to the same file
         $fileTemp = 'cache/cacheconfig/' . md5(time() . microtime() . rand(0, 1000) . $file . $instance->WWWDirLang . '_' . $instance->Language) . '.php';
         file_put_contents($fileTemp, $contentFile);
         // Atomic file write
         rename($fileTemp, $fileCompiled);
         $cacheModules[$cacheKey] = $fileCompiled;
         $cacheWriter->store('moduleCache_' . self::$currentModuleName, $cacheModules);
         self::$cacheInstance->store('moduleCache_' . self::$currentModuleName . '_version_' . self::$cacheVersionSite, $cacheModules);
         return $fileCompiled;
     }
 }
 public function run()
 {
     $dispatcher = erLhcoreClassChatEventDispatcher::getInstance();
     // Attatch event listeners
     $dispatcher->listen('user.edit.photo_path', array($this, 'userEditPhotoPath'));
     $dispatcher->listen('chat.getstatus', array($this, 'getStatus'));
     $dispatcher->listen('file.storescreenshot.screenshot_path', array($this, 'screenshotPath'));
     $dispatcher->listen('file.uploadfile.file_path', array($this, 'screenshotPath'));
     $dispatcher->listen('file.uploadfileadmin.file_path', array($this, 'screenshotPath'));
     $dispatcher->listen('file.new.file_path', array($this, 'newFilePath'));
     // Themes listeners
     $dispatcher->listen('theme.edit.logo_image_path', array($this, 'themeStoragePath'));
     $dispatcher->listen('theme.edit.need_help_image_path', array($this, 'themeStoragePath'));
     $dispatcher->listen('theme.edit.offline_image_path', array($this, 'themeStoragePath'));
     $dispatcher->listen('theme.edit.online_image_path', array($this, 'themeStoragePath'));
     $dispatcher->listen('theme.edit.copyright_image_path', array($this, 'themeStoragePath'));
     $dispatcher->listen('theme.edit.operator_image_path', array($this, 'themeStoragePath'));
     $dispatcher->listen('theme.edit.popup_image_path', array($this, 'themeStoragePath'));
     $dispatcher->listen('theme.edit.close_image_path', array($this, 'themeStoragePath'));
     $dispatcher->listen('theme.edit.restore_image_path', array($this, 'themeStoragePath'));
     $dispatcher->listen('theme.edit.minimize_image_path', array($this, 'themeStoragePath'));
     // Permissions
     $dispatcher->listen('feature.can_use_forms', array($this, 'canUseForms'));
     $dispatcher->listen('form.index', array($this, 'canUseForms'));
     $dispatcher->listen('form.embedcode', array($this, 'canUseForms'));
     // Canned messages
     $dispatcher->listen('chat.cannedmsg', array($this, 'canUseCannedMessages'));
     $dispatcher->listen('chat.newcannedmsg', array($this, 'canUseCannedMessages'));
     // FAQ
     $dispatcher->listen('faq.list', array($this, 'canUseFAQ'));
     $dispatcher->listen('faq.view', array($this, 'canUseFAQ'));
     // SugarCRM
     $dispatcher->listen('sugarcrm.createorupdatelead', array($this, 'canUseSugarCRM'));
     // Browse offers
     $dispatcher->listen('browseoffer.index', array($this, 'canUseBO'));
     $dispatcher->listen('browseoffer.htmlcode', array($this, 'canUseBO'));
     $dispatcher->listen('feature.can_use_browse_offers', array($this, 'canUseBO'));
     // Questionary
     $dispatcher->listen('questionary.edit', array($this, 'canUseQuestionary'));
     $dispatcher->listen('questionary.list', array($this, 'canUseQuestionary'));
     $dispatcher->listen('questionary.new', array($this, 'canUseQuestionary'));
     // Chatbox
     $dispatcher->listen('chatbox.list', array($this, 'canUseChatbox'));
     $dispatcher->listen('chatbox.configuration', array($this, 'canUseChatbox'));
     // Statistic
     $dispatcher->listen('chat.statistic', array($this, 'canUseStatistic'));
     // Pro active
     $dispatcher->listen('feature.can_use_proactive', array($this, 'canUseProactive'));
     // Auto responder
     $dispatcher->listen('feature.can_use_autoresponder', array($this, 'canUseAutoresponder'));
     $dispatcher->listen('chat.geoadjustment', array($this, 'canUseGeoAdjustment'));
     // Block users
     $dispatcher->listen('chat.blockedusers', array($this, 'canUseBlock'));
     // XMPP send message action
     $dispatcher->listen('xml.send_xmp_message', array($this, 'xmppSendMessage'));
     // Automated hosting overrides mail sending parameters
     $dispatcher->listen('chatmail.setup_smtp', array($this, 'setupSMTP'));
     // temporary path
     $dispatcher->listen('theme.temppath', array($this, 'tempStoragePath'));
     // Disable database variables cache
     $dispatcher->listen('tpl.new', array($this, 'changeTemplateSettings'));
     // Forms module listener
     $dispatcher->listen('form.fill.file_path', array($this, 'formFillPath'));
     $dispatcher->listen('xmp.configuration', array($this, 'canUseXMPP'));
     // Translation config
     $dispatcher->listen('translation.get_config', array($this, 'getTranslationConfig'));
     // Check can user create a new operators
     $dispatcher->listen('user.new_user', array($this, 'canNewUserCanBeCreated'));
     $dispatcher->listen('user.edit_user', array($this, 'canUserBeSaved'));
     $dispatcher->listen('chat.sendnotice', array($this, 'canSendNotice'));
     $dispatcher->listen('chat.chatcheckoperatormessage', array($this, 'proactiveIsEnabled'));
     $instanceCustomer = erLhcoreClassInstance::getInstance();
     if (is_object($instanceCustomer)) {
         erLhcoreClassModule::$cacheDbVariables = false;
         // Disable cache expire for customers, only through command line possible
         erConfigClassLhCacheConfig::getInstance()->setExpiredInRuntime(true);
         erLhcoreClassModule::$defaultTimeZone = $instanceCustomer->time_zone;
         erLhcoreClassModule::$dateFormat = $instanceCustomer->date_format;
         erLhcoreClassModule::$dateHourFormat = $instanceCustomer->date_hour_format;
         erLhcoreClassModule::$dateDateHourFormat = $instanceCustomer->date_date_hour_format;
         // Check one logged user per account
         if ($instanceCustomer->one_per_account == 1) {
             // Set instance policy regarding how many operators can be looged under same account
             erLhcoreClassUser::$oneLoginPerAccount = $instanceCustomer->one_per_account == 1;
         }
         $cfgSite = erConfigClassLhConfig::getInstance();
         $sysConfiguration = erLhcoreClassSystem::instance();
         $defaultSiteAccess = $cfgSite->getSetting('site', 'default_site_access');
         // Perhaps we need to change default siteaccess
         if ($sysConfiguration->SiteAccess != 'site_admin' && $sysConfiguration->SiteAccess == $defaultSiteAccess && !isset($_POST['switchLang']) && $instanceCustomer->siteaccess != '' && $instanceCustomer->siteaccess != $sysConfiguration->SiteAccess) {
             $optionsSiteAccessOverride = $cfgSite->getSetting('site_access_options', $instanceCustomer->siteaccess);
             $sysConfiguration->Language = $optionsSiteAccessOverride['locale'];
             $sysConfiguration->SiteAccess = $instanceCustomer->siteaccess;
             $sysConfiguration->ContentLanguage = $optionsSiteAccessOverride['content_language'];
             $sysConfiguration->ThemeSite = $optionsSiteAccessOverride['theme'];
             if ($defaultSiteAccess != $sysConfiguration->SiteAccess) {
                 $sysConfiguration->WWWDirLang = '/' . $sysConfiguration->SiteAccess;
             }
         }
     }
 }
    },
    isOnline : <?php 
    echo $isOnlineHelp == true ? 'true' : 'false';
    ?>
,
    disabledGeo : <?php 
    echo isset($disableByGeoAdjustment) && $disableByGeoAdjustment == true ? 'true' : 'false';
    ?>
,
    checkOperatorMessage : <?php 
    echo $check_operator_messages == true ? 'true' : 'false';
    ?>
,
	offset_data : '',
	lang: '<?php 
    echo erLhcoreClassSystem::instance()->WWWDirLang;
    ?>
',
	is_dragging : false,
	online_tracked : false,
    urlopen : function(){   
    	return "<?php 
    echo erLhcoreClassModelChatConfig::fetch('explicit_http_mode')->current_value;
    ?>
//<?php 
    echo $_SERVER['HTTP_HOST'];
    echo erLhcoreClassDesign::baseurlsite();
    ?>
"+this.lang+"/chat/startchat<?php 
    $leaveamessage == true ? print '/(leaveamessage)/true' : '';
    $theme !== false ? print '/(theme)/' . $theme->id : '';
 public function __get($var)
 {
     switch ($var) {
         case 'left_menu':
             $this->left_menu = '';
             return $this->left_menu;
             break;
         case 'logo_image_url':
         case 'minimize_image_url':
         case 'restore_image_url':
         case 'close_image_url':
         case 'popup_image_url':
         case 'operator_image_url':
         case 'copyright_image_url':
         case 'need_help_image_url':
         case 'online_image_url':
         case 'offline_image_url':
             $attr = str_replace('_url', '', $var);
             $this->{$var} = false;
             if ($this->{$attr} != '') {
                 $this->{$var} = ($this->{$attr . '_path'} != '' ? erLhcoreClassSystem::instance()->wwwDir() : erLhcoreClassSystem::instance()->wwwImagesDir()) . '/' . $this->{$attr . '_path'} . $this->{$attr};
             }
             return $this->{$var};
             break;
         case 'need_help_image_url_img':
         case 'online_image_url_img':
         case 'offline_image_url_img':
         case 'logo_image_url_img':
         case 'copyright_image_url_img':
         case 'operator_image_url_img':
         case 'popup_image_url_img':
         case 'close_image_url_img':
         case 'restore_image_url_img':
         case 'minimize_image_url_img':
             $attr = str_replace('_url_img', '', $var);
             $this->{$var} = false;
             if ($this->{$attr} != '') {
                 $this->{$var} = '<img src="' . ($this->{$attr . '_path'} != '' ? erLhcoreClassSystem::instance()->wwwDir() : erLhcoreClassSystem::instance()->wwwImagesDir()) . '/' . $this->{$attr . '_path'} . $this->{$attr} . '"/>';
             }
             return $this->{$var};
             break;
         default:
             break;
     }
 }
    public static function processInvitation($params)
    {
        $referrer = self::getHost($params['r']);
        $session = erLhcoreClassAbstract::getSession();
        $matchStringURL = '';
        if ($params['l'] != '') {
            $parts = parse_url($params['l']);
            if (isset($parts['path'])) {
                $matchStringURL = $parts['path'];
            }
            if (isset($parts['query'])) {
                $matchStringURL .= '?' . $parts['query'];
            }
        }
        $q = $session->createFindQuery('erLhAbstractModelBrowseOfferInvitation');
        $q->where('active = 1 AND (' . $q->expr->eq('siteaccess', $q->bindValue(erLhcoreClassSystem::instance()->SiteAccess)) . ' OR siteaccess = \'\')
				AND (' . $q->expr->eq('identifier', $q->bindValue($params['identifier'])) . ')
				AND (' . $q->expr->like($session->database->quote(trim($referrer)), 'concat(referrer,\'%\')') . ' OR referrer = \'\')
				AND (' . $q->expr->lOr($q->expr->eq('url', $q->bindValue('')), $q->expr->eq('url', $q->bindValue(trim($matchStringURL))), $q->expr->lAnd($q->expr->eq('is_wildcard', $q->bindValue(1)), $q->expr->like($session->database->quote(trim($matchStringURL)), 'concat(left(url,length(url)-1),\'%\')'))) . ')')->orderBy('priority ASC')->limit(1);
        $messagesToUser = $session->find($q);
        if (!empty($messagesToUser)) {
            return array_shift($messagesToUser);
        }
        return false;
    }
 public static function getParams($params = array())
 {
     $uparams = isset($params['uparams']) ? $params['uparams'] : array();
     $fieldsObjects = (include 'lib/core/lh' . $params['module'] . '/searchattr/' . $params['module_file'] . '.php');
     $fields = $fieldsObjects['filterAttributes'];
     $orderOptions = $fieldsObjects['sortAttributes'];
     foreach ($fields as $key => $field) {
         $definition[$key] = $field['validation_definition'];
     }
     foreach ($uparams as $key => &$value) {
         if (!is_array($value)) {
             $value = urldecode($value);
         }
     }
     $inputParams = new stdClass();
     $inputFrom = new stdClass();
     $form = new erLhcoreClassInputForm(INPUT_GET, $definition, null, $uparams, isset($params['use_override']) ? $params['use_override'] : false);
     $Errors = array();
     foreach ($fields as $key => $field) {
         $inputParams->{$key} = null;
         $inputFrom->{$key} = null;
         if ($form->hasValidData($key) && ($field['required'] == false && $field['valid_if_filled'] == false || $field['type'] == 'combobox' || $field['required'] == true && $field['type'] == 'text' && $form->{$key} != '')) {
             if (isset($field['datatype']) && $field['datatype'] == 'date_ymd') {
                 $dateTemp = $form->{$key};
                 if (self::isValidDateFormat($dateTemp) == false) {
                     continue;
                 }
             }
             $inputParams->{$key} = $form->{$key};
             $inputFrom->{$key} = $form->{$key};
             if (isset($field['depend_fields'])) {
                 foreach ($field['depend_fields'] as $depend) {
                     if (!$form->hasValidData($depend) && !key_exists($depend, $Errors)) {
                         $Errors[$depend] = $fields[$depend]['trans'] . ' is required';
                     }
                 }
             }
         } elseif ($field['required'] == true) {
             $Errors[$key] = $field['trans'] . ' is required';
         } elseif (isset($field['valid_if_filled']) && $field['valid_if_filled'] == true && $form->hasValidData($key) && $form->{$key} != '') {
             $inputFrom->{$key} = $form->{$key};
             $inputParams->{$key} = $form->{$key};
             if (isset($field['depend_fields'])) {
                 foreach ($field['depend_fields'] as $depend) {
                     if (!$form->hasValidData($depend) && !key_exists($depend, $Errors)) {
                         $Errors[$depend] = $fields[$depend]['trans'] . ' is required';
                     }
                 }
             }
         } elseif (isset($field['valid_if_filled']) && $field['valid_if_filled'] == true && isset($_GET[$key]) && $_GET[$key] != '') {
             $Errors[$key] = $field['trans'] . ' is filled incorrectly!';
             $inputFrom->{$key} = $_GET[$key];
         } elseif (isset($field['depend_fields'])) {
             // No value, we can clean dependence fields
             foreach ($field['depend_fields'] as $depend) {
                 $inputFrom->{$depend} = null;
                 $inputParams->{$depend} = null;
             }
         }
     }
     $filter = array();
     if (isset($params['format_filter']) && count($Errors) == 0) {
         foreach ($fields as $key => $field) {
             if ($field['filter_type'] !== false && $inputParams->{$key} != '' || $inputParams->{$key} === 0) {
                 if ($field['filter_type'] == 'filter') {
                     if (is_bool($inputParams->{$key}) && $inputParams->{$key} == true) {
                         $filter[$field['filter_type']][$field['filter_table_field']] = 1;
                     } else {
                         $filter[$field['filter_type']][$field['filter_table_field']] = $inputParams->{$key};
                     }
                 } elseif ($field['filter_type'] == 'filterin_remote') {
                     $args = array();
                     foreach ($field['filter_in_args'] as $fieldInput) {
                         $args[] = $inputParams->{$fieldInput};
                     }
                     $filter['filterin'][$key] = call_user_func_array($field['filter_in_generator'], $args);
                     if (count($filter['filterin'][$key]) == 0) {
                         $filter['filterin'][$key] = array(-1);
                     }
                     if (isset($field['depend_fields'])) {
                         foreach ($field['depend_fields'] as $depend) {
                             if ($inputFrom->{$depend} == -1) {
                                 unset($filter['filterin'][$key]);
                             }
                         }
                     }
                 } elseif ($field['filter_type'] == 'filtergte') {
                     if (isset($field['datatype']) && $field['datatype'] == 'date') {
                         $dateFormated = self::formatDateToTimestamp($inputParams->{$key});
                         if ($dateFormated != false) {
                             $filter['filtergte'][$field['filter_table_field']] = $dateFormated;
                         }
                     } elseif (isset($field['datatype']) && $field['datatype'] == 'date_ymd') {
                         $dateFormated = self::formatDateToDateYmd($inputParams->{$key});
                         if ($dateFormated != false) {
                             $filter['filtergte'][$field['filter_table_field']] = $dateFormated;
                         }
                     } else {
                         $filter['filtergte'][$field['filter_table_field']] = $inputParams->{$key};
                     }
                 } elseif ($field['filter_type'] == 'filterlte') {
                     if (isset($field['range_from']) && isset($filter['filtergte'][$fields[$field['range_from']]['filter_table_field']]) && $filter['filtergte'][$fields[$field['range_from']]['filter_table_field']] == $inputParams->{$key}) {
                         unset($filter['filtergte'][$fields[$field['range_from']]['filter_table_field']]);
                         $filter['filter'][$field['filter_table_field']] = $inputParams->{$key};
                     } else {
                         if (isset($field['datatype']) && $field['datatype'] == 'date') {
                             $dateFormated = self::formatDateToTimestamp($inputParams->{$key});
                             if ($dateFormated != false) {
                                 $filter['filterlte'][$field['filter_table_field']] = $dateFormated;
                             }
                         } elseif (isset($field['datatype']) && $field['datatype'] == 'date_ymd') {
                             $dateFormated = self::formatDateToDateYmd($inputParams->{$key});
                             if ($dateFormated != false) {
                                 $filter['filterlte'][$field['filter_table_field']] = $dateFormated;
                             }
                         } else {
                             $filter['filterlte'][$field['filter_table_field']] = $inputParams->{$key};
                         }
                     }
                 } elseif ($field['filter_type'] == 'filter_join') {
                     $filter['filterin'][$field['filter_table_field']] = $inputParams->{$key};
                     $filter['filter_join'][$field['join_table_name']] = $field['join_attributes'];
                     $filter['filter_having'][] = 'COUNT(*) = ' . count($inputParams->{$key});
                     $filter['filter_group'][] = $field['group_by_field'];
                 } elseif ($field['filter_type'] == 'filter_map') {
                     $mapObject = call_user_func($field['class'] . '::fetch', $inputParams->{$key});
                     $filter['filter'][$mapObject->field] = $mapObject->status;
                 } elseif ($field['filter_type'] == 'like') {
                     $filter['filterlike'][$field['filter_table_field']] = $inputParams->{$key};
                 } elseif ($field['filter_type'] == 'filterkeyword') {
                     if (isset($field['filter_transform_to_search']) && $field['filter_transform_to_search'] == true) {
                         $filter['filterkeyword'][$field['filter_table_field']] = erLhcoreClassCharTransform::transformToSearch($inputParams->{$key});
                     } else {
                         $filter['filterkeyword'][$field['filter_table_field']] = $inputParams->{$key};
                     }
                 } elseif ($field['filter_type'] == 'filterin') {
                     if ($field['datatype'] == 'transaction_types') {
                         $filterInData = array();
                         foreach ($inputParams->{$key} as $typeId) {
                             if (erLhcoreClassModelLingbidTransactionLog::isValidType($typeId)) {
                                 $filterInData[] = $typeId;
                             }
                         }
                         if (!empty($filterInData)) {
                             $filter['filterin'][$field['filter_table_field']] = $filterInData;
                         }
                     } else {
                         $filter['filterin'][$field['filter_table_field']] = $inputParams->{$key};
                     }
                 } elseif ($field['filter_type'] == 'filter_work_types') {
                     $filter['filter_keywords'][] = 'work_type_' . $inputParams->{$key};
                 } elseif ($field['filter_type'] == 'filter_topic_types') {
                     $filter['filter_keywords'][] = 'topic_type_' . $inputParams->{$key};
                 } elseif ($field['filter_type'] == 'filterbetween') {
                     $parts = explode('_', $inputParams->{$key});
                     if (is_numeric($parts[0])) {
                         $filter['filtergte'][$field['filter_table_field']] = (int) $parts[0];
                     }
                     if (is_numeric($parts[1])) {
                         $filter['filterlte'][$field['filter_table_field']] = (int) $parts[1];
                     }
                 } elseif ($field['filter_type'] == 'filter_languages') {
                     $filter['filter_keywords'][] = 'language_' . $inputParams->{$key};
                 } elseif ($field['filter_type'] == 'user_expert_type') {
                     if ($inputParams->{$key} == erLhcoreClassModelUser::USER_EXPERT_TYPE_BOTH) {
                         $filter['filter']['is_worker'] = 1;
                         $filter['filter']['is_employer'] = 1;
                     } elseif ($inputParams->{$key} == erLhcoreClassModelUser::USER_EXPERT_TYPE_WORKER) {
                         $filter['filter']['is_worker'] = 1;
                         $filter['filter']['is_employer'] = 0;
                     } elseif ($inputParams->{$key} == erLhcoreClassModelUser::USER_EXPERT_TYPE_EMPLOYER) {
                         $filter['filter']['is_employer'] = 1;
                         $filter['filter']['is_worker'] = 0;
                     }
                 } elseif ($field['filter_type'] == 'user_status') {
                     if ($inputParams->{$key} == 1) {
                         $filter['filter'][$field['filter_table_field']] = 1;
                     } elseif ($inputParams->{$key} == 2) {
                         $filter['filter'][$field['filter_table_field']] = 0;
                     }
                 } elseif ($field['filter_type'] == 'filterkeyword_blogpost') {
                     $locale = strtolower(erLhcoreClassSystem::instance()->Language);
                     $tableFields = explode(',', $field['filter_table_fields']);
                     foreach ($tableFields as $tableField) {
                         $filter['filterseqor'][$tableField . '_' . $locale] = $inputParams->{$key};
                     }
                 } elseif ($field['filter_type'] == 'filtertag_blogpost') {
                     $locale = strtolower(erLhcoreClassSystem::instance()->Language);
                     $tableField = $field['filter_table_field'] . '_' . $locale;
                     $filter['filterseq'][$tableField] = $inputParams->{$key};
                 } elseif ($field['filter_type'] == 'filterseq') {
                     $filter[$field['filter_type']][$field['filter_table_field']] = $inputParams->{$key};
                 }
             }
         }
         if (isset($currentOrder['as_append'])) {
             foreach ($currentOrder['as_append'] as $key => $appendSelect) {
                 if (isset($currentOrder['replace_params'])) {
                     $returnObj = call_user_func($currentOrder['param_call_func'], $inputParams->{$currentOrder['param_call_name_attr']});
                     foreach ($currentOrder['replace_params'] as $attrObj => $targetString) {
                         $appendSelect = str_replace($targetString, $returnObj->{$attrObj}, $appendSelect);
                     }
                 }
                 $filter['as_append'] = $appendSelect . ' AS ' . $key;
             }
         }
         if (!isset($orderOptions['disabled'])) {
             $keySort = key_exists($inputParams->{$orderOptions['field']}, $orderOptions['options']) ? $inputParams->{$orderOptions['field']} : $orderOptions['default'];
             $currentOrder = $orderOptions['options'][$keySort];
             $filter['sort'] = $currentOrder['sort_column'];
             $inputFrom->sortby = $keySort;
             if (key_exists($inputParams->{$orderOptions['field']}, $orderOptions['options']) && $orderOptions['default'] != $inputParams->{$orderOptions['field']}) {
                 $inputParams->sortby = $keySort;
             } else {
                 // Standard sort mode does not need any append in URL
                 if (isset($inputParams->sortby)) {
                     unset($inputParams->sortby);
                 }
             }
         }
     }
     return array('errors' => $Errors, 'input_form' => $inputFrom, 'input' => $inputParams, 'filter' => $filter);
 }
 private function translateFromXML($context, $string, $params = array())
 {
     $sys = erLhcoreClassSystem::instance()->SiteDir;
     $reader = new ezcTranslationTsBackend($sys . '/translations/' . $this->languageCode);
     $reader->setOptions(array('format' => 'translation.ts'));
     $manager = new ezcTranslationManager($reader);
     $ContextTranslation = $manager->getContext($this->languageCode, $context);
     return $ContextTranslation->getTranslation($string, $params);
 }
 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;
         }
     }
 }