Пример #1
0
 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 function movePhoto($attr, $isLocal = false, $localFile = false)
 {
     $this->deletePhoto($attr);
     if ($this->id != null) {
         $dir = 'var/storagetheme/' . date('Y') . 'y/' . date('m') . '/' . date('d') . '/' . $this->id . '/';
         erLhcoreClassChatEventDispatcher::getInstance()->dispatch('theme.edit.' . $attr . '_path', array('dir' => &$dir, 'storage_id' => $this->id));
         erLhcoreClassFileUpload::mkdirRecursive($dir);
         if ($isLocal == false) {
             $this->{$attr} = erLhcoreClassSearchHandler::moveUploadedFile('AbstractInput_' . $attr, $dir . '/', '.');
         } else {
             $this->{$attr} = erLhcoreClassSearchHandler::moveLocalFile($localFile, $dir . '/', '.');
         }
         $this->{$attr . '_path'} = $dir;
     } else {
         $this->{$attr . '_pending'} = true;
     }
 }
Пример #3
0
<?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']);
Пример #4
0
 public static function storeCollectedInformation($form, $collectedInformation)
 {
     $formCollected = new erLhAbstractModelFormCollected();
     $formCollected->ip = erLhcoreClassIPDetect::getIP();
     $formCollected->ctime = time();
     $formCollected->form_id = $form->id;
     $formCollected->identifier = isset($_POST['identifier']) ? $_POST['identifier'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
     $formCollected->saveThis();
     // Finish collect information
     foreach ($collectedInformation as $fieldName => &$params) {
         if ($params['definition']['type'] == 'file') {
             $dir = 'var/storageform/' . date('Y') . 'y/' . date('m') . '/' . date('d') . '/' . $formCollected->id . '/';
             erLhcoreClassChatEventDispatcher::getInstance()->dispatch('form.fill.file_path', array('path' => &$dir, 'storage_id' => $formCollected->id));
             erLhcoreClassFileUpload::mkdirRecursive($dir);
             $file = erLhcoreClassSearchHandler::moveUploadedFile($params['definition']['name'], $dir);
             $params['filename'] = $file;
             $params['filepath'] = $dir;
             erLhcoreClassChatEventDispatcher::getInstance()->dispatch('form.fill.store_file', array('file_params' => &$params));
         }
     }
     $formCollected->content = serialize($collectedInformation);
     $formCollected->saveThis();
     // Inform user about filled form
     erLhcoreClassChatMail::informFormFilled($formCollected, array('email' => self::$mainEmail));
 }