public static function formatFilter($validAttributes) { $definition = array(); foreach ($validAttributes as $attributeType => $attributes) { foreach ($attributes as $userAttribute => $definitionField) { $definition[$userAttribute] = $definitionField['validator']; } } $form = new ezcInputForm(INPUT_GET, $definition); $filter = array(); foreach ($validAttributes as $attributeType => $attributes) { foreach ($attributes as $userAttribute => $definitionField) { if ($form->hasValidData($userAttribute)) { if ($definitionField['type'] == 'filter') { $filter['filter'][$definitionField['field']] = $form->{$userAttribute}; } elseif ($definitionField['type'] == 'general') { $filter[$definitionField['field']] = $form->{$userAttribute}; } } } } $filter['limit'] = isset($filter['limit']) ? $filter['limit'] : 20; $filter['offset'] = isset($filter['offset']) ? $filter['offset'] : 0; $filter['smart_select'] = true; return $filter; }
public static function validateAdminTheme(erLhAbstractModelAdminTheme &$clickform) { $definition = array('Name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'header_content' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'header_css' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'static_content_name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'static_content_hash' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'static_js_content_name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'static_js_content_hash' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'static_css_content_name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'static_css_content_hash' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY)); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); $currentUser = erLhcoreClassUser::instance(); if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('icclicktocallform/form', 'Invalid CSRF token!'); } if (!$form->hasValidData('Name') || $form->Name == '') { $Errors['Name'] = erTranslationClassLhTranslation::getInstance()->getTranslation('icclicktocallform/form', 'Please enter a name'); } else { $clickform->name = $form->Name; } if ($form->hasValidData('header_content')) { $clickform->header_content = $form->header_content; } if ($form->hasValidData('header_css')) { $clickform->header_css = $form->header_css; } $resourcesArray = array('static_content', 'static_js_content', 'static_css_content'); $supportedExtensions = array('zip', 'doc', 'docx', 'ttf', 'pdf', 'xls', 'ico', 'gif', 'xlsx', 'jpg', 'jpeg', 'png', 'bmp', 'rar', '7z', 'css', 'js', 'eot', 'woff', 'woff2', 'svg'); // Validate resources foreach ($resourcesArray as $resource) { if ($form->hasValidData($resource . '_hash') && !empty($form->{$resource . '_hash'})) { $customFields = $currentStaticResources = $clickform->{$resource . '_array'}; foreach ($form->{$resource . '_hash'} as $key => $customFieldType) { if (!erLhcoreClassSearchHandler::isFile($resource . '_file_' . $key, $supportedExtensions) && !isset($currentStaticResources[$key]['file'])) { $Errors[$resource . '_file_' . $key] = erTranslationClassLhTranslation::getInstance()->getTranslation('icclicktocallform/form', 'File not chosen for') . (isset($form->{$resource . '_name'}[$key]) ? ' - ' . htmlspecialchars($form->{$resource . '_name'}[$key]) : ''); } } // If there is no errors upload files if (empty($Errors)) { foreach ($form->{$resource . '_hash'} as $key => $customFieldType) { $customFields[$key]['name'] = $form->{$resource . '_name'}[$key]; $customFields[$key]['hash'] = $key; if (erLhcoreClassSearchHandler::isFile($resource . '_file_' . $key, $supportedExtensions)) { // Check there is already uploaded file and remove it $clickform->removeResource($resource, $key); // Store new file if required $dir = 'var/storageadmintheme/' . date('Y') . 'y/' . date('m') . '/' . date('d') . '/' . $clickform->id . '/'; erLhcoreClassChatEventDispatcher::getInstance()->dispatch('admintheme.filedir', array('dir' => &$dir, 'storage_id' => $clickform->id)); erLhcoreClassFileUpload::mkdirRecursive($dir); $customFields[$key]['file'] = erLhcoreClassSearchHandler::moveUploadedFile($resource . '_file_' . $key, $dir . '/', '.'); $customFields[$key]['file_dir'] = $dir; } } $clickform->{$resource} = json_encode($customFields, JSON_HEX_APOS); } } else { $clickform->{$resource} = ''; } } return $Errors; }
public static function validateSendMail(erLhAbstractModelEmailTemplate &$sendMail, &$chat, $params = array()) { $Errors = array(); $validationFields = array(); $validationFields['Message'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'); $validationFields['Subject'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'); $validationFields['FromName'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'); $validationFields['FromEmail'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'); $validationFields['ReplyEmail'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'); $validationFields['RecipientEmail'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'); $form = new ezcInputForm(INPUT_POST, $validationFields); $Errors = array(); if (isset($params['archive_mode']) && $params['archive_mode'] == true) { $messages = array_reverse(erLhcoreClassChat::getList(array('limit' => 100, 'sort' => 'id DESC', 'filter' => array('chat_id' => $chat->id)), 'erLhcoreClassModelChatArchiveMsg', erLhcoreClassModelChatArchiveRange::$archiveMsgTable)); } else { $messages = array_reverse(erLhcoreClassModelmsg::getList(array('limit' => 100, 'sort' => 'id DESC', 'filter' => array('chat_id' => $chat->id)))); } // Fetch chat messages $tpl = new erLhcoreClassTemplate('lhchat/messagelist/plain.tpl.php'); $tpl->set('chat', $chat); $tpl->set('messages', $messages); $sendMail->content = str_replace(array('{user_chat_nick}', '{messages_content}'), array($chat->nick, $tpl->fetch()), $sendMail->content); if ($form->hasValidData('Message')) { $sendMail->content = str_replace('{additional_message}', $form->Message, $sendMail->content); } $sendMail->content = erLhcoreClassBBCode::parseForMail($sendMail->content); if ($form->hasValidData('FromEmail')) { $sendMail->from_email = $form->FromEmail; } if ($form->hasValidData('ReplyEmail')) { $sendMail->reply_to = $form->ReplyEmail; } if ($form->hasValidData('FromName')) { $sendMail->from_name = $form->FromName; } if ($form->hasValidData('Subject')) { $sendMail->subject = $form->Subject; } if ($form->hasValidData('RecipientEmail')) { $sendMail->recipient = $form->RecipientEmail; } else { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendmail', 'Please enter recipient e-mail!'); } if (empty($sendMail->from_email)) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendmail', 'From e-mail is missing!'); } if (empty($sendMail->reply_to)) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendmail', 'Reply e-mail is missing!'); } if (empty($sendMail->subject)) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendmail', 'Subject is missing!'); } return $Errors; }
public static function validateSurvey(erLhAbstractModelSurveyItem &$surveyItem, erLhAbstractModelSurvey $survey) { $definition = array('StarsValue' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1, 'max_range' => $survey->max_stars))); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if (!$form->hasValidData('StarsValue')) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Please choose a star'); } else { $surveyItem->stars = $form->StarsValue; } return $Errors; }
public static function validateSurvey(erLhAbstractModelSurveyItem &$surveyItem, erLhAbstractModelSurvey $survey) { include erLhcoreClassDesign::designtpl('lhsurvey/forms/fields_names.tpl.php'); $definition = array(); for ($i = 0; $i < 16; $i++) { foreach ($sortOptions as $keyOption => $sortOption) { if ($survey->{$keyOption . '_pos'} == $i && $survey->{$keyOption . '_enabled'}) { if ($sortOption['type'] == 'stars') { $definition[$sortOption['field'] . 'Evaluate'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1, 'max_range' => $survey->{$sortOption}['field'])); } elseif ($sortOption['type'] == 'question') { $definition[$sortOption['field'] . 'Question'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'); } elseif ($sortOption['type'] == 'question_options') { $definition[$sortOption['field'] . 'EvaluateOption'] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1)); } } } } $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); for ($i = 0; $i < 16; $i++) { foreach ($sortOptions as $keyOption => $sortOption) { if ($survey->{$keyOption . '_pos'} == $i && $survey->{$keyOption . '_enabled'}) { if ($sortOption['type'] == 'stars') { if (!$form->hasValidData($sortOption['field'] . 'Evaluate')) { if ($survey->{$keyOption . '_req'} == 1) { $Errors[] = '"' . htmlspecialchars(trim($survey->{$keyOption . '_title'})) . '" : ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'is required'); } } else { $surveyItem->{$sortOption['field']} = $form->{$sortOption['field'] . 'Evaluate'}; } } elseif ($sortOption['type'] == 'question') { if (!$form->hasValidData($sortOption['field'] . 'Question') || $form->{$sortOption['field'] . 'Question'} == '' && $survey->{$keyOption . '_req'} == 1) { // @todo Make possible to choose field type in the future $Errors[] = '"' . htmlspecialchars(trim($survey->{$keyOption})) . '" : ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'is required'); } else { $surveyItem->{$sortOption['field']} = $form->{$sortOption['field'] . 'Question'}; } } elseif ($sortOption['type'] == 'question_options') { if (!$form->hasValidData($sortOption['field'] . 'EvaluateOption')) { if ($survey->{$keyOption . '_req'} == 1) { $Errors[] = '"' . htmlspecialchars(trim($survey->{$sortOption['field']})) . '" : ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'is required'); } } else { $surveyItem->{$sortOption['field']} = $form->{$sortOption['field'] . 'EvaluateOption'}; } } } } } erLhcoreClassChatEventDispatcher::getInstance()->dispatch('survey.validate', array('survey' => &$survey, 'survey_item' => &$surveyItem, 'errors' => &$Errors)); return $Errors; }
public static function validateChatbox(&$chatbox) { $definition = array('ManagerName' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'ChatboxName' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Identifier' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'ActiveChatbox' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean')); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if (!$form->hasValidData('ManagerName') || $form->ManagerName == '') { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('faq/view', 'Please enter a manager name!'); } else { $chatbox->chat->nick = $form->ManagerName; } if (!$form->hasValidData('ChatboxName') || $form->ChatboxName == '') { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('faq/view', 'Please enter a chatbox name!'); } else { $chatbox->name = $form->ChatboxName; } if (!$form->hasValidData('Identifier') || $form->Identifier == '') { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('faq/view', 'Please enter a chatbox identifier!'); } else { $chatbox->identifier = $form->Identifier; } if ($form->hasValidData('ActiveChatbox') && $form->ActiveChatbox == true) { $chatbox->active = 1; } else { $chatbox->active = 0; } return $Errors; }
public function __construct($inputSource, $definition, $characterEncoding = null, $inputData = null, $useOverride = false) { if (($returnValue = ezcInputForm::validateDefinition($definition)) !== true) { throw new ezcInputFormInvalidDefinitionException($returnValue[1]); } $this->definition = $definition; $this->inputSource = $inputSource; $this->inputData = $inputData; if ($inputData === null || count($inputData) == 0) { $this->parseInput(); } else { $this->parseInputFromData($useOverride); } }
public static function validateFaq(&$faq) { $definition = array('answer' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'question' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'URL' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Email' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'), 'Identifier' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'ActiveFAQ' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean')); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if (!$form->hasValidData('answer') || $form->answer == '') { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('faq/view', 'Please enter answer!'); } else { $faq->answer = $form->answer; } if ($form->hasValidData('Identifier') && $form->Identifier != '') { if (mb_strlen($form->Identifier) <= 10) { $faq->identifier = $form->Identifier; } else { $faq->identifier = $form->Identifier; $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('faq/view', 'Identifier has to be shorter than 10 characters!'); } } else { $faq->identifier = ''; } if ($form->hasValidData('Email')) { $faq->email = $form->Email; } else { $faq->email = ''; } if (!$form->hasValidData('question') || $form->question == '') { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('faq/view', 'Please enter question!'); } else { $faq->question = $form->question; } if ($form->hasValidData('URL')) { $faq->url = $form->URL; } else { $faq->url = ''; } if ($form->hasValidData('ActiveFAQ') && $form->ActiveFAQ == true) { $faq->active = 1; } else { $faq->active = 0; } return $Errors; }
public static function validateXMPPAccount(erLhcoreClassModelXMPPAccount &$xmppAccount) { $definition = array('username' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'password' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'user_id' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1)), 'sendmessage' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean')); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); // Username is available only for new accounts if ($xmppAccount->id == 0) { if (!$form->hasValidData('username') || $form->username == '') { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('xmppservice/operatorvalidator', 'Please enter a username'); } else { if (strpos($form->username, 'visitor') === false) { if (preg_match('/[^a-z_0-9]/i', $form->username)) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('xmppservice/operatorvalidator', 'Not allowed characters detected'); } elseif ($form->username != 'admin') { $subdomain = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionXmppservice')->settings['subdomain']; $xmppAccount->username = $form->username . ($subdomain != '' ? '.' . $subdomain : '') . '@' . erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionXmppservice')->settings['xmpp_host']; } else { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('xmppservice/operatorvalidator', 'Admin is reserved username and can not be used'); } } else { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('xmppservice/operatorvalidator', 'Username cannot start with visitor keyword'); } } } if ($xmppAccount->id == 0) { if (!$form->hasValidData('password') || $form->password == '') { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('xmppservice/operatorvalidator', 'Please enter a password'); } else { $xmppAccount->password = $form->password; } } else { if ($form->hasValidData('password') && $form->password != '') { $xmppAccount->password = $form->password; } } if ($form->hasValidData('user_id')) { $xmppAccount->user_id = $form->user_id; } else { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('xmppservice/operatorvalidator', 'Please choose opeator id!'); } if ($form->hasValidData('sendmessage') && $form->sendmessage == true) { $xmppAccount->sendmessage = 1; } else { $xmppAccount->sendmessage = 0; } return $Errors; }
<?php $tpl = erLhcoreClassTemplate::getInstance('lhuser/autologinconfig.tpl.php'); $autologinData = erLhcoreClassModelChatConfig::fetch('autologin_data'); $data = (array) $autologinData->data; if (isset($_POST['StoreAutologinSettings'])) { $definition = array('secret_hash' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'enabled' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean')); if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect('user/autologinconfig'); exit; } $Errors = array(); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); try { if ($form->hasValidData('secret_hash') && strlen($form->secret_hash) >= 10) { $data['secret_hash'] = $form->secret_hash; } else { throw new Exception('Please enter secret hash'); } if ($form->hasValidData('enabled') && $form->enabled == true) { $data['enabled'] = 1; } else { $data['enabled'] = 0; } $autologinData->value = serialize($data); $autologinData->saveThis(); $CacheManager = erConfigClassLhCacheConfig::getInstance(); $CacheManager->expireCache(); $tpl->set('updated', 'done'); } catch (Exception $e) {
<?php if (!isset($_SERVER['HTTP_X_CSRFTOKEN']) || !$currentUser->validateCSFRToken($_SERVER['HTTP_X_CSRFTOKEN'])) { echo json_encode(array('error' => 'true', 'result' => 'Invalid CSFR Token')); exit; } $archive = new erLhcoreClassModelChatArchiveRange(); $definition = array('id' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1))); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if (!$form->hasValidData('id')) { echo json_encode(array('error' => 'true', 'result' => 'Invalid archive ID')); exit; } else { $archiveChat = erLhcoreClassModelChatArchiveRange::fetch($form->id); $status = $archiveChat->process(); $tpl = erLhcoreClassTemplate::getInstance('lhchatarchive/archivechats.tpl.php'); $tpl->set('status', $status); $tpl->set('archive', $archiveChat); $status['result'] = $tpl->fetch(); echo json_encode($status); } exit;
<?php if (!isset($_SERVER['HTTP_X_CSRFTOKEN']) || !$currentUser->validateCSFRToken($_SERVER['HTTP_X_CSRFTOKEN'])) { echo json_encode(array('error' => 'true', 'result' => 'Invalid CSRF Token')); exit; } $definition = array('data' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'unsafe_raw')); $form = new ezcInputForm(INPUT_POST, $definition); $Chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']); $errorTpl = erLhcoreClassTemplate::getInstance('lhkernel/validation_error.tpl.php'); if (erLhcoreClassChat::hasAccessToRead($Chat)) { if ($form->hasValidData('data')) { $errors = array(); erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.before_save_remarks', array('chat' => &$Chat, 'errors' => &$errors)); if (empty($errors)) { $Chat->remarks = $form->data; $Chat->saveThis(); echo json_encode(array('error' => 'false')); exit; } else { $errorTpl->set('errors', $errors); echo json_encode(array('error' => 'true', 'result' => $errorTpl->fetch())); exit; } } else { $errorTpl->set('errors', array(erTranslationClassLhTranslation::getInstance()->getTranslation('chat/adminchat', 'Form data not valid'))); echo json_encode(array('error' => 'true', 'result' => $errorTpl->fetch())); exit; } } else { $errorTpl->set('errors', array(erTranslationClassLhTranslation::getInstance()->getTranslation('chat/adminchat', 'Has no access to this chat')));
<?php $tpl = erLhcoreClassTemplate::getInstance('lhsystem/timezone.tpl.php'); $cfgSite = erConfigClassLhConfig::getInstance(); $timezone = $cfgSite->getSetting('site', 'time_zone'); $date_format = $cfgSite->getSetting('site', 'date_format'); $date_hour_format = $cfgSite->getSetting('site', 'date_hour_format'); $date_date_hour_format = $cfgSite->getSetting('site', 'date_date_hour_format'); if (isset($_POST['StoreTimeZoneSettings'])) { $definition = array('TimeZone' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'DateFormat' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'DateFullFormat' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'DateHourFormat' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')); if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect('system/timezone'); exit; } $form = new ezcInputForm(INPUT_POST, $definition); if ($form->hasValidData('TimeZone')) { $timezone = $form->TimeZone; } else { $timezone = ''; } if ($form->hasValidData('DateFormat')) { $date_format = $form->DateFormat; } else { $date_format = ''; } if ($form->hasValidData('DateFullFormat')) { $date_date_hour_format = $form->DateFullFormat; } else { $date_date_hour_format = ''; } if ($form->hasValidData('DateHourFormat')) {
<?php $tpl = erLhcoreClassTemplate::getInstance('lhdocshare/configuration.tpl.php'); $docSharer = erLhcoreClassModelChatConfig::fetch('doc_sharer'); $data = (array) $docSharer->data; if (isset($_POST['StoreConfiguration'])) { $definition = array('LibreOfficePath' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'SupportedExtensions' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'PdftoppmPath' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'HttpUserName' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'HttpGroupName' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'BackgroundProcess' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'MaxFileSize' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 2)), 'PdftoppmLimit' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 0))); $Errors = array(); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect('docshare/configuration'); exit; } if ($form->hasValidData('LibreOfficePath')) { $data['libre_office_path'] = $form->LibreOfficePath; } else { $data['libre_office_path'] = '/usr/bin/libreoffice'; } if ($form->hasValidData('PdftoppmPath')) { $data['pdftoppm_path'] = $form->PdftoppmPath; } else { $data['pdftoppm_path'] = '/usr/bin/pdftoppm'; } if ($form->hasValidData('PdftoppmLimit')) { $data['pdftoppm_limit'] = $form->PdftoppmLimit; } else { $data['pdftoppm_limit'] = '0'; } if ($form->hasValidData('HttpUserName')) { $data['http_user_name'] = $form->HttpUserName;
if (isset($_POST['SaveAction'])) { erLhcoreClassModule::redirect('questionary/list'); exit; } else { $tpl->set('updated', true); } } else { $tpl->set('errors', $Errors); } } // Voting tab actions $Option = (int) $Params['user_parameters_unordered']['option_id'] > 0 ? erLhcoreClassModelQuestionOption::fetch((int) $Params['user_parameters_unordered']['option_id']) : new erLhcoreClassModelQuestionOption(); if (isset($_POST['UpdateO'])) { $tab = 'voting'; $definition = array('Option' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Priority' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int')); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect(); exit; } if (!$form->hasValidData('Option') || $form->Option == '') { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/edit', 'Please enter an option!'); } if ($form->hasValidData('Priority')) { $Option->priority = $form->Priority; } else { $Option->priority = 0; } if (count($Errors) == 0) { $Option->option_name = $form->Option;
$Instance->reseller_secret_hash = $form->ResellerSecretHash; } if ($form->hasValidData('ResellerRequest')) { $Instance->reseller_request = $form->ResellerRequest; } if ($form->hasValidData('Reseller') && $form->Reseller == true) { $Instance->is_reseller = $form->Reseller; } else { $Instance->is_reseller = false; } $Instance->saveThis(); $tpl->set('updated', true); } if (isset($_POST['Update_departament']) || isset($_POST['Save_departament'])) { $definition = array('Address' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'ClientTitle' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Email' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'), 'Suspended' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'Terminate' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'Request' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'RequestUsed' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int'), 'Expires' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'AttrInt1' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int'), 'AttrInt2' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int'), 'AttrInt3' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int')); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if ($form->hasValidData('Address')) { $Instance->address = $form->Address; } if ($form->hasValidData('ClientTitle')) { $Instance->client_title = $form->ClientTitle; } if ($form->hasValidData('Email')) { $Instance->email = $form->Email; } else { $Errors[] = 'Please enter valid e-mail'; } if ($form->hasValidData('Request')) { $Instance->request = $form->Request; }
/** * Constructs a new ezcInputForm for $inputSource with $definition. * * This method constructs a new ezcInputForm with three parameters. The * $inputSource parameter selects the input source and should be one of the * constants INPUT_GET, INPUT_POST or INPUT_COOKIE. The $definition * parameter is an array of ezcInputFormDefinitionElement items and * determines which input variables make up this form (see the example at * the top of this class). The last parameter, $characterEncoding is the * character encoding to use while retrieving input variable data. This * parameter has currently no function as it will depend on PHP 6 * functionality which does not exist yet in the input filter extension. * * @throws ezcInputFormVariableMissingException when one of the required * input variables is missing. * @throws ezcInputFormInvalidDefinitionException when the definition array * is invalid or when the input source was invalid. * * @param int $inputSource * @param array(ezcInputFormDefinitionElement) $definition * @param string $characterEncoding */ public function __construct($inputSource, $definition, $characterEncoding = null) { if (($returnValue = ezcInputForm::validateDefinition($definition)) !== true) { throw new ezcInputFormInvalidDefinitionException($returnValue[1]); } $this->definition = $definition; $this->inputSource = $inputSource; $this->parseInput(); }
<?php $tpl = erLhcoreClassTemplate::getInstance('lhuser/new.tpl.php'); $UserData = new erLhcoreClassModelUser(); $UserDepartaments = isset($_POST['UserDepartament']) ? $_POST['UserDepartament'] : array(); $show_all_pending = 0; if (isset($_POST['Update_account'])) { $definition = array('Password' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Password1' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Email' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'), 'Name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Surname' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Username' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'UserDisabled' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'HideMyStatus' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'UserInvisible' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'showAllPendingEnabled' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'JobTitle' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'UserTimeZone' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'DefaultGroup' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', null, FILTER_REQUIRE_ARRAY), 'Skype' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'XMPPUsername' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')); if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect('user/new'); exit; } $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if (!$form->hasValidData('Email')) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/new', 'Wrong email address'); } if (!$form->hasValidData('Name') || $form->Name == '') { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/new', 'Please enter a name'); } if ($form->hasValidData('Surname') && $form->Surname != '') { $UserData->surname = $form->Surname; } else { $UserData->surname = ''; } if ($form->hasValidData('JobTitle') && $form->JobTitle != '') { $UserData->job_title = $form->JobTitle; } else { $UserData->job_title = ''; } if ($form->hasValidData('UserTimeZone') && $form->UserTimeZone != '') {
* */ $cannedMessage = new erLhcoreClassModelCannedMsg(); if (is_numeric($Params['user_parameters_unordered']['msg']) && $Params['user_parameters_unordered']['action'] == '') { $cannedMessage = erLhcoreClassModelCannedMsg::fetch($Params['user_parameters_unordered']['msg']); if ($cannedMessage->user_id != $UserData->id) { erLhcoreClassModule::redirect('user/account', '#canned'); exit; } } if (isset($_POST['Cancel_canned_action'])) { erLhcoreClassModule::redirect('user/account', '#canned'); exit; } if (isset($_POST['Save_canned_action'])) { $definition = array('Message' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Position' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 0)), 'Delay' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 0)), 'AutoSend' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean')); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if (!$form->hasValidData('Message') || $form->Message == '') { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg', 'Please enter canned message'); } if ($form->hasValidData('Position')) { $cannedMessage->position = $form->Position; } if ($form->hasValidData('Delay')) { $cannedMessage->delay = $form->Delay; } if ($form->hasValidData('AutoSend') && $form->AutoSend == true) { $cannedMessage->auto_send = 1; } else { $cannedMessage->auto_send = 0; }
$chat->last_msg_id = $msg->id; $chat->last_user_msg_time = time(); $chat->saveThis(); erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chat_started', array('chat' => &$chat, 'msg' => $messageInitial)); erLhcoreClassChat::updateDepartmentStats($chat->department); $Result = erLhcoreClassModule::reRun(erLhcoreClassDesign::baseurlRerun('chat/chatwidgetchat') . '/' . $chat->id . '/' . $chat->hash . $modeAppendTheme . '/(cstarted)/chat_started_by_invitation_cb'); return true; } else { $tpl->set('errors', $Errors); } } $tpl->set('start_data_fields', $startDataFields); // User this only if not post if (!ezcInputForm::hasPostData()) { $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), 'value_items_admin' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'via_hidden' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', 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('sh') && !empty($form->sh)) { $inputData->value_show = $form->sh; } if ($form->hasValidData('req') && !empty($form->req)) { $inputData->values_req = $form->req; } if ($form->hasValidData('value') && !empty($form->value)) { $inputData->value_items = $form->value; } if ($form->hasValidData('hattr') && !empty($form->hattr)) { $inputData->hattr = $form->hattr; }
} $chat->last_msg_id = $msg->id; $chat->last_user_msg_time = time(); $chat->saveThis(); erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chat_started', array('chat' => &$chat)); // Redirect user erLhcoreClassModule::redirect('chat/chatwidgetchat/' . $chat->id . '/' . $chat->hash . $modeAppendTheme . '/(cstarted)/chat_started_by_invitation_cb'); exit; } else { $tpl->set('errors', $Errors); } } // User this only if not post if (!ezcInputForm::hasPostData()) { $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('sh') && !empty($form->sh)) { $inputData->value_show = $form->sh; } if ($form->hasValidData('req') && !empty($form->req)) { $inputData->values_req = $form->req; } if ($form->hasValidData('value') && !empty($form->value)) { $inputData->value_items = $form->value; } if ($form->hasValidData('hattr') && !empty($form->hattr)) { $inputData->hattr = $form->hattr; }
$tpl->setFile('lhinstall/install3.tpl.php'); } else { $tpl->set('db_username', $form->DatabaseUsername); $tpl->set('db_password', $form->DatabasePassword); $tpl->set('db_host', $form->DatabaseHost); $tpl->set('db_port', $form->DatabasePort); $tpl->set('db_name', $form->DatabaseDatabaseName); $tpl->set('errors', $Errors); $tpl->setFile('lhinstall/install2.tpl.php'); } break; case '3': $Errors = array(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $definition = array('AdminUsername' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'unsafe_raw'), 'AdminPassword' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'unsafe_raw'), 'AdminPassword1' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'unsafe_raw'), 'AdminEmail' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'validate_email'), 'AdminName' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'AdminSurname' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'DefaultDepartament' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'string')); $form = new ezcInputForm(INPUT_POST, $definition); if (!$form->hasValidData('AdminUsername') || $form->AdminUsername == '') { $Errors[] = 'Please enter admin username'; } if ($form->hasValidData('AdminUsername') && $form->AdminUsername != '' && strlen($form->AdminUsername) > 40) { $Errors[] = 'Maximum 40 characters for admin username'; } if (!$form->hasValidData('AdminPassword') || $form->AdminPassword == '') { $Errors[] = 'Please enter admin password'; } if ($form->hasValidData('AdminPassword') && $form->AdminPassword != '' && strlen($form->AdminPassword) > 40) { $Errors[] = 'Maximum 40 characters for admin password'; } if ($form->hasValidData('AdminPassword') && $form->AdminPassword != '' && strlen($form->AdminPassword) <= 40 && $form->AdminPassword1 != $form->AdminPassword) { $Errors[] = 'Passwords missmatch'; }
<?php $tpl = erLhcoreClassTemplate::getInstance('lhsystem/smtp.tpl.php'); $smtpData = erLhcoreClassModelChatConfig::fetch('smtp_data'); $data = (array) $smtpData->data; if (isset($_POST['StoreSMTPSettings']) || isset($_POST['StoreSMTPSettingsTest'])) { $definition = array('host' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'username' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'password' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'port' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'use_smtp' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean')); if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect('system/smtp'); exit; } $Errors = array(); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if ($form->hasValidData('host')) { $data['host'] = $form->host; } else { $data['host'] = ''; } if ($form->hasValidData('port')) { $data['port'] = $form->port; } else { $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;
public static function renderInputTypeFile($params) { $downloadLink = ''; if (ezcInputForm::hasPostData()) { if (!erLhcoreClassSearchHandler::isFile($params['name']) && (isset($params['required']) && $params['required'] == 'required')) { self::$errors[] = (isset($params['name_literal']) ? $params['name_literal'] : $params['name']) . ' ' . erTranslationClassLhTranslation::getInstance()->getTranslation('form/fill', 'is required'); } elseif (erLhcoreClassSearchHandler::isFile($params['name'])) { self::$collectedInfo[$params['name']] = array('definition' => $params, 'value' => $_FILES[$params['name']]); } } else { if (isset(self::$collectedInfo[$params['name']]['value'])) { $valueContent = self::$collectedInfo[$params['name']]['value']; $downloadLink = "<a href=\"http://" . $_SERVER['HTTP_HOST'] . erLhcoreClassDesign::baseurl('form/download') . '/' . self::$collectedObject->id . '/' . self::$collectedObject->hash . '/' . $params['name'] . "\">Download (" . htmlspecialchars($valueContent['name']) . ")</a>"; } } return "{$downloadLink}<input type=\"file\" name=\"{$params['name']}\" />"; }
<?php if (ezcInputForm::hasGetData()) { $form = new ezcInputForm(INPUT_GET, $definition); foreach ($definition as $name => $dummy) { $propertyName = "property_{$name}"; $propertyWarningName = "warning_{$name}"; if ($form->hasValidData($name)) { ${$propertyName} = $form->{$name}; } else { ${$propertyName} = htmlspecialchars($form->getUnsafeRawData($name)); ${$propertyWarningName} = '[invalid]'; } } }
erLhcoreClassModule::redirect('user/userlist'); exit; } else { $tpl->set('updated', true); } } else { $tpl->set('errors', $Errors); } } if (isset($_POST['UpdatePending_account'])) { if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect('user/account'); exit; } $definition = array('showAllPendingEnabled' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean')); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if ($form->hasValidData('showAllPendingEnabled') && $form->showAllPendingEnabled == true) { erLhcoreClassModelUserSetting::setSetting('show_all_pending', 1, $UserData->id); } else { erLhcoreClassModelUserSetting::setSetting('show_all_pending', 0, $UserData->id); } $tpl->set('account_updated', 'done'); $tpl->set('tab', 'tab_pending'); } if (isset($_POST['UpdateDepartaments_account'])) { if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect('user/userlist'); exit; } $globalDepartament = array();
<?php $tpl = erLhcoreClassTemplate::getInstance('lhtheme/import.tpl.php'); if (ezcInputForm::hasPostData()) { if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect('theme/import'); exit; } if (erLhcoreClassSearchHandler::isFile('themefile', array('json'))) { $dir = 'var/tmpfiles/'; erLhcoreClassChatEventDispatcher::getInstance()->dispatch('theme.temppath', array('dir' => &$dir)); erLhcoreClassFileUpload::mkdirRecursive($dir); $filename = erLhcoreClassSearchHandler::moveUploadedFile('themefile', $dir); $content = file_get_contents($dir . $filename); unlink($dir . $filename); $data = json_decode($content); if ($data !== null) { $widgetTheme = new erLhAbstractModelWidgetTheme(); $data = (array) $data; $imgData = array(); if (isset($data['logo_image_data'])) { $imgData['logo_image'] = $data['logo_image_data']; unset($data['logo_image_data']); } if (isset($data['need_help_image_data'])) { $imgData['need_help_image'] = $data['need_help_image_data']; unset($data['need_help_image_data']); } if (isset($data['online_image_data'])) { $imgData['online_image'] = $data['online_image_data']; unset($data['online_image_data']);
public static function validateNickChange(&$chat) { $definition = array('Email' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'), 'UserNick' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'UserPhone' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if (!$form->hasValidData('Email') && $_POST['Email'] != '') { $Errors['email'] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Please enter a valid email address'); } elseif ($form->hasValidData('Email')) { $chat->email = $form->Email; } if ($form->hasValidData('UserNick') && $form->UserNick != '' && strlen($form->UserNick) > 50) { $Errors['nick'] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Maximum 50 characters'); } if ($form->hasValidData('UserPhone')) { $chat->phone = $form->UserPhone; } if ($form->hasValidData('UserNick') && $form->UserNick != '') { $chat->nick = $form->UserNick; } else { $Errors['nick'] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Please enter your name'); } return $Errors; }
<?php $tpl = erLhcoreClassTemplate::getInstance('lhchat/geoadjustment.tpl.php'); $geoData = erLhcoreClassModelChatConfig::fetch('geoadjustment_data'); $data = (array) $geoData->data; if (isset($_POST['SaveGeoAdjustment'])) { $definition = array('use_geo_adjustment' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'AvailableFor' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'OtherCountries' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'HideFor' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'OtherStatus' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'RestStatus' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'), 'ApplyWidget' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean')); if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect('xmp/configuration'); exit; } $Errors = array(); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if ($form->hasValidData('use_geo_adjustment')) { $data['use_geo_adjustment'] = true; } else { $data['use_geo_adjustment'] = false; } if ($data['use_geo_adjustment']) { if ($form->hasValidData('AvailableFor')) { $data['available_for'] = $form->AvailableFor; } else { $data['available_for'] = ''; } if ($form->hasValidData('OtherCountries')) { $data['other_countries'] = $form->OtherCountries; } else { $data['other_countries'] = ''; } if ($form->hasValidData('HideFor')) {
/** * Override * */ try { $chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']); } catch (Exception $e) { $chat = false; } if ((int) erLhcoreClassModelChatConfig::fetch('disable_send')->current_value == 1) { exit; } if (is_object($chat) && $chat->hash == $Params['user_parameters']['hash'] && ($chat->status == erLhcoreClassModelChat::STATUS_ACTIVE_CHAT || erLhcoreClassChat::canReopen($chat, true))) { if (ezcInputForm::hasPostData()) { $definition = array('email' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email')); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if (!$form->hasValidData('email')) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/edit', 'Wrong email address'); } if (!isset($_SERVER['HTTP_X_CSRFTOKEN']) || !isset($_POST['csfr_token']) || $_POST['csfr_token'] != $_SERVER['HTTP_X_CSRFTOKEN']) { $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/edit', 'Invalid CSRF token!'); } if (empty($Errors)) { $tpl = erLhcoreClassTemplate::getInstance('lhchat/sendmail.tpl.php'); $mailTemplate = erLhAbstractModelEmailTemplate::fetch(3); erLhcoreClassChatMail::prepareSendMail($mailTemplate); $mailTemplate->recipient = $form->email; $messages = array_reverse(erLhcoreClassModelmsg::getList(array('customfilter' => array('user_id != -1'), 'limit' => 500, 'sort' => 'id DESC', 'filter' => array('chat_id' => $chat->id)))); // Fetch chat messages $tpl = new erLhcoreClassTemplate('lhchat/messagelist/plain.tpl.php');