Beispiel #1
0
 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     $entry = array('name' => iaUtil::checkPostParam('name'), 'item' => iaUtil::checkPostParam('item'), 'collapsible' => iaUtil::checkPostParam('collapsible'), 'collapsed' => iaUtil::checkPostParam('collapsed'), 'tabview' => iaUtil::checkPostParam('tabview'), 'tabcontainer' => iaUtil::checkPostParam('tabcontainer'));
     iaUtil::loadUTF8Functions('ascii', 'bad', 'validation');
     if (iaCore::ACTION_ADD == $action) {
         if (!utf8_is_ascii($entry['name'])) {
             $this->addMessage('ascii_required');
         } else {
             $entry['name'] = strtolower($entry['name']);
         }
         if (!$this->getMessages() && !preg_match('/^[a-z0-9\\-_]{2,50}$/', $entry['name'])) {
             $this->addMessage('name_is_incorrect');
         }
         if (empty($data['item'])) {
             $this->addMessage('at_least_one_item_should_be_checked');
         }
         $entry['order'] = $this->_iaDb->getMaxOrder(iaField::getTableGroups()) + 1;
     }
     foreach ($this->_iaCore->languages as $code => $language) {
         if ($data['titles'][$code]) {
             if (!utf8_is_valid($data['titles'][$code])) {
                 $data['titles'][$code] = utf8_bad_replace($data['titles'][$code]);
             }
         } else {
             $this->addMessage($language['title'] . ': ' . iaLanguage::get('title_incorrect'), false);
         }
         if ($data['description'][$code]) {
             if (!utf8_is_valid($data['description'][$code])) {
                 $data['description'][$code] = utf8_bad_replace($data['description'][$code]);
             }
         }
     }
     return !$this->getMessages();
 }
     $itemData[iaPlan::SPONSORED_PLAN_ID] = (int) $_POST['plan_id'];
 }
 if (isset($_POST['username'])) {
     if ($iaDb->exists('`username` = :value', array('value' => $_POST['username']), iaUsers::getTable())) {
         $error = true;
         $messages[] = iaLanguage::get('username_already_exists');
     }
 }
 if (isset($_POST['email'])) {
     if ($iaDb->exists('`email` = :value', array('value' => $_POST['email']), iaUsers::getTable())) {
         $error = true;
         $messages[] = iaLanguage::get('error_duplicate_email');
     }
 }
 if (!$error) {
     $itemData['password'] = iaUtil::checkPostParam('password');
     $itemData['disable_fields'] = isset($_POST['disable_fields']) ? (int) $_POST['disable_fields'] : 0;
     // check password
     if (!$itemData['disable_fields']) {
         if (!$itemData['password']) {
             $error = true;
             $messages[] = iaLanguage::get('error_password_empty');
         } else {
             if ($_POST['password'] != $_POST['password2']) {
                 $error = true;
                 $messages[] = iaLanguage::get('error_password_match');
             }
         }
     } else {
         $itemData['password'] = '';
     }
Beispiel #3
0
 private function _resetPage(&$iaView)
 {
     if (isset($_POST['reset'])) {
         if ($options = iaUtil::checkPostParam('options', array())) {
             if (in_array(iaUsers::getItemName(), $options)) {
                 $iaUsers = $this->_iaCore->factory('users');
                 $currentMember = $this->_iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds(iaUsers::getIdentity()->id), iaUsers::getTable());
                 $this->getHelper()->truncate(iaUsers::getTable());
                 $this->_iaDb->insert($currentMember, null, iaUsers::getTable());
                 $options = array_diff($options, array($iaUsers->getItemName()));
             }
             foreach ($options as $option) {
                 $this->_iaCore->startHook('phpDbControlBeforeReset', array('option' => $option));
             }
             $this->addMessage('reset_success');
         } else {
             $this->_error = true;
             $this->addMessage('reset_choose_table');
         }
     } else {
         $iaView->setMessages(iaLanguage::get('reset_backup_alert'), iaView::ALERT);
     }
     $resetOptions = array('members' => iaLanguage::get('reset') . ' ' . iaLanguage::get('members'));
     $this->_iaCore->startHook('phpAdminDatabaseBeforeAll', array('reset_options' => &$resetOptions));
     $iaView->assign('options', $resetOptions);
 }
Beispiel #4
0
 // process mandatory hook
 $iaCore->startHook('editItemSetSystemDefaults', array('item' => &$ad));
 if (isset($_POST['save'])) {
     $error = false;
     $messages = array();
     $errorFields = array();
     iaCore::util();
     if (!defined('IA_NOUTF')) {
         iaUtf8::loadUTF8Core();
         iaUtf8::loadUTF8Util('ascii', 'validation', 'bad', 'utf8_to_ascii');
     }
     $fields = $iaFields->getAllFields(true, '', $iaAd->getItemName());
     if ($fields) {
         list($data, $error, $messages, $errorFields) = iaField::parsePost($fields, $ad, true);
     }
     $data['status'] = iaUtil::checkPostParam('status', iaCore::STATUS_ACTIVE);
     if (!$error) {
         if (iaCore::ACTION_ADD == $pageAction) {
             $data['id'] = $iaAd->insert($data);
             $messages[] = iaLanguage::get('ad_added');
         } else {
             $data['id'] = $ad['id'];
             $iaAd->update($data);
             $messages[] = iaLanguage::get('saved');
         }
         $ad = $iaAd->getById($data['id']);
         $iaView->setMessages($messages, $error ? iaView::ERROR : iaView::SUCCESS);
         $goto = array('add' => $baseUrl . 'add/', 'list' => $baseUrl, 'stay' => $baseUrl . 'edit/?id=' . $data['id']);
         iaUtil::post_goto($goto);
     }
     $iaView->setMessages($messages, $error ? iaView::ERROR : iaView::SUCCESS);
Beispiel #5
0
 protected function _preSaveEntry(array &$entry, array $data, $action)
 {
     $entry = array('name' => iaSanitize::alias(iaUtil::checkPostParam('name')), 'item' => iaUtil::checkPostParam('item'), 'default' => iaUtil::checkPostParam('default'), 'lang_values' => iaUtil::checkPostParam('lang_values'), 'text_default' => iaSanitize::html(iaUtil::checkPostParam('text_default')), 'type' => iaUtil::checkPostParam('type'), 'annotation' => iaUtil::checkPostParam('annotation'), 'fieldgroup_id' => (int) iaUtil::checkPostParam('fieldgroup_id'), 'text_length' => (int) iaUtil::checkPostParam('text_length', 255), 'length' => iaUtil::checkPostParam('length', false), 'title' => iaUtil::checkPostParam('title'), 'pages' => iaUtil::checkPostParam('pages', array()), 'required' => iaUtil::checkPostParam('required'), 'use_editor' => (int) iaUtil::checkPostParam('use_editor'), 'empty_field' => iaSanitize::html(iaUtil::checkPostParam('empty_field')), 'url_nofollow' => (int) iaUtil::checkPostParam('url_nofollow'), 'groups' => iaUtil::checkPostParam('groups'), 'searchable' => (int) iaUtil::checkPostParam('searchable'), 'adminonly' => (int) iaUtil::checkPostParam('adminonly'), 'for_plan' => (int) iaUtil::checkPostParam('for_plan'), 'required_checks' => iaUtil::checkPostParam('required_checks'), 'extra_actions' => iaUtil::checkPostParam('extra_actions'), 'link_to' => (int) iaUtil::checkPostParam('link_to'), 'values' => '', 'relation' => iaUtil::checkPostParam('relation', iaField::RELATION_REGULAR), 'parents' => isset($data['parents']) && is_array($data['parents']) ? $data['parents'] : array(), 'children' => isset($data['children']) && is_array($data['children']) ? $data['children'] : array(), 'status' => iaUtil::checkPostParam('status', iaCore::STATUS_ACTIVE));
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad');
     if (!$this->_iaDb->exists(iaDb::convertIds($entry['fieldgroup_id']), null, iaField::getTableGroups())) {
         $entry['fieldgroup_id'] = 0;
     }
     foreach ($this->_iaCore->languages as $code => $language) {
         if (!empty($entry['annotation'][$code])) {
             if (!utf8_is_valid($entry['annotation'][$code])) {
                 $entry['annotation'][$code] = utf8_bad_replace($entry['annotation'][$code]);
             }
         }
         if (!empty($entry['title'][$code])) {
             if (!utf8_is_valid($entry['title'][$code])) {
                 $entry['title'][$code] = utf8_bad_replace($entry['title'][$code]);
             }
         } else {
             $this->addMessage(iaLanguage::getf('field_is_empty', array('field' => $language['title'] . ' ' . iaLanguage::get('title'))), false);
             break;
         }
     }
     if (iaCore::ACTION_ADD == $action) {
         $entry['name'] = trim(strtolower(iaSanitize::paranoid($entry['name'])));
         if (empty($entry['name'])) {
             $this->addMessage('field_name_incorrect');
         }
     } else {
         unset($entry['name']);
     }
     $fieldTypes = $this->_iaDb->getEnumValues(iaField::getTable(), 'type');
     if ($fieldTypes['values'] && !in_array($entry['type'], $fieldTypes['values'])) {
         $this->addMessage('field_type_invalid');
     } else {
         if (!$entry['length']) {
             $entry['length'] = iaField::DEFAULT_LENGTH;
         }
         switch ($entry['type']) {
             case iaField::TEXT:
                 if (empty($entry['text_length'])) {
                     $entry['text_length'] = 255;
                 }
                 $entry['length'] = min(255, max(1, $entry['text_length']));
                 $entry['default'] = $entry['text_default'];
                 break;
             case iaField::TEXTAREA:
                 $entry['default'] = '';
                 break;
             case iaField::COMBO:
             case iaField::RADIO:
             case iaField::CHECKBOX:
                 if (!empty($data['values']) && is_array($data['values'])) {
                     $keys = array();
                     $lang_values = array();
                     $multiDefault = explode('|', iaUtil::checkPostParam('multiple_default'));
                     $_keys = iaUtil::checkPostParam('keys');
                     $_values = iaUtil::checkPostParam('values');
                     $_langValues = iaUtil::checkPostParam('lang_values');
                     foreach ($_keys as $index => $key) {
                         if (trim($key) == '') {
                             $key = $index + 1;
                             $_keys[$index] = $key;
                         }
                         if (isset($_values[$index]) && trim($_values[$index]) != '') {
                             $values[$key] = $_values[$index];
                             $keys[$key] = $key;
                         } else {
                             unset($_keys[$index], $_values[$index]);
                         }
                         if ($_langValues) {
                             foreach ($this->_iaCore->languages as $code => $language) {
                                 if ($code != $this->_iaCore->iaView->language) {
                                     if (!isset($_values[$index])) {
                                         unset($_langValues[$code][$index]);
                                     } elseif (!isset($_langValues[$code][$index]) || trim($_langValues[$code][$index]) == '') {
                                         $lang_values[$code][$key] = $values[$key];
                                     } else {
                                         $lang_values[$code][$key] = $_langValues[$code][$index];
                                     }
                                 }
                             }
                         }
                     }
                     // delete default values if not exists in values
                     foreach ($multiDefault as $index => $default) {
                         if (!in_array($default, $values)) {
                             unset($multiDefault[$index]);
                         } else {
                             $k = array_search($default, $values);
                             $multiDefault[$index] = $k;
                         }
                     }
                     $multiDefault = array_values($multiDefault);
                     if (iaField::CHECKBOX == $entry['type']) {
                         $multiDefault = implode(',', $multiDefault);
                     } elseif (isset($multiDefault[0])) {
                         // multiple default is available for checkboxes only
                         $_POST['multiple_default'] = $multiDefault = $multiDefault[0];
                     } else {
                         $_POST['multiple_default'] = $multiDefault = '';
                     }
                     $entry['default'] = $multiDefault;
                     $entry['keys'] = $keys;
                     $entry['values'] = $values;
                     $entry['lang_values'] = $lang_values;
                 } else {
                     $this->addMessage('one_value');
                 }
                 break;
             case iaField::STORAGE:
                 if (!empty($data['file_types'])) {
                     $entry['file_types'] = str_replace(' ', '', iaUtil::checkPostParam('file_types'));
                     $entry['length'] = (int) iaUtil::checkPostParam('max_files', 5);
                 } else {
                     $this->addMessage('error_file_type');
                 }
                 break;
             case iaField::DATE:
                 $entry['timepicker'] = (int) iaUtil::checkPostParam('timepicker');
                 break;
             case iaField::URL:
                 $entry['url_nofollow'] = (int) iaUtil::checkPostParam('url_nofollow');
                 break;
             case iaField::IMAGE:
                 $entry['length'] = 1;
                 $entry['image_height'] = (int) iaUtil::checkPostParam('image_height');
                 $entry['image_width'] = (int) iaUtil::checkPostParam('image_width');
                 $entry['thumb_height'] = (int) iaUtil::checkPostParam('thumb_height');
                 $entry['thumb_width'] = (int) iaUtil::checkPostParam('thumb_width');
                 $entry['file_prefix'] = iaUtil::checkPostParam('file_prefix');
                 $entry['resize_mode'] = iaUtil::checkPostParam('resize_mode');
                 break;
             case iaField::NUMBER:
                 $entry['length'] = (int) iaUtil::checkPostParam('number_length', 8);
                 $entry['default'] = iaUtil::checkPostParam('number_default');
                 break;
             case iaField::PICTURES:
                 $entry['length'] = (int) iaUtil::checkPostParam('pic_max_images', 5);
                 $entry['file_prefix'] = iaUtil::checkPostParam('pic_file_prefix');
                 $entry['image_height'] = (int) iaUtil::checkPostParam('pic_image_height');
                 $entry['image_width'] = (int) iaUtil::checkPostParam('pic_image_width');
                 $entry['thumb_height'] = (int) iaUtil::checkPostParam('pic_thumb_height');
                 $entry['thumb_width'] = (int) iaUtil::checkPostParam('pic_thumb_width');
                 $entry['resize_mode'] = iaUtil::checkPostParam('pic_resize_mode');
                 break;
             case iaField::TREE:
                 $parsedTree = $this->_parseTreeNodes(iaUtil::checkPostParam('nodes'));
                 $entry['values'] = $parsedTree[0];
                 $entry['tree_nodes'] = $parsedTree[1];
                 $entry['timepicker'] = (int) iaUtil::checkPostParam('multiple');
         }
         unset($entry['text_length'], $entry['text_default'], $entry['nodes'], $entry['multiple']);
     }
     if (!$entry['adminonly'] && empty($entry['pages']) && 'transactions' != $entry['item']) {
         $this->addMessage('mark_at_least_one_page');
     }
     $entry['required'] = (int) iaUtil::checkPostParam('required');
     if ($entry['required']) {
         $entry['required_checks'] = iaUtil::checkPostParam('required_checks');
     }
     $entry['extra_actions'] = iaUtil::checkPostParam('extra_actions');
     if ($entry['searchable']) {
         if (isset($data['show_as']) && $entry['type'] != iaField::NUMBER && in_array($data['show_as'], array(iaField::COMBO, iaField::RADIO, iaField::CHECKBOX))) {
             $entry['show_as'] = $data['show_as'];
         } elseif ($entry['type'] == iaField::NUMBER && !empty($data['_values'])) {
             $entry['sort_order'] = 'asc' == $data['sort_order'] ? $data['sort_order'] : 'desc';
             $entry['_numberRangeForSearch'] = $data['_values'];
         }
     }
     $this->_iaCore->startHook('phpAdminFieldsEdit', array('field' => &$entry));
     return !$this->getMessages();
 }
            			}*/
    }
    $iaView->assign($output);
}
if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
    if (iaCore::ACTION_EDIT == $pageAction && isset($iaCore->requestPath[0])) {
        if (iaCore::ACTION_EDIT == $pageAction && !isset($iaCore->requestPath[0])) {
            return iaView::errorPage(iaView::ERROR_NOT_FOUND);
        }
        iaBreadcrumb::replaceEnd(iaLanguage::get('edit'));
        $guestbook = array('status' => iaCore::STATUS_ACTIVE);
        if (iaCore::ACTION_EDIT == $pageAction) {
            $id = (int) $iaCore->requestPath[0];
            $guestbook = $iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($id));
        }
        $guestbook = array('id' => isset($id) ? $id : 0, 'author_name' => iaUtil::checkPostParam('author_name', $guestbook), 'email' => iaUtil::checkPostParam('email', $guestbook), 'member_id' => iaUtil::checkPostParam('member_id', $guestbook), 'author_url' => iaUtil::checkPostParam('author_url', $guestbook), 'body' => iaUtil::checkPostParam('body', $guestbook), 'status' => iaUtil::checkPostParam('status', $guestbook), 'avatar' => iaUtil::checkPostParam('avatar', $guestbook), 'date' => iaUtil::checkPostParam('date', $guestbook));
        if (isset($_POST['save'])) {
            iaUtil::loadUTF8Functions('ascii', 'validation', 'bad');
            $error = false;
            $messages = array();
            $guestbook['avatar'] = iaSanitize::html($guestbook['avatar']);
            if (utf8_is_valid($guestbook['author_name'])) {
                $guestbook['author_name'] = utf8_bad_replace($guestbook['author_name']);
            }
            if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
                $iaPicture = $iaCore->factory('picture');
                $info = array('image_width' => 500, 'image_height' => 500, 'thumb_width' => 150, 'thumb_height' => 150, 'resize_mode' => iaPicture::CROP);
                if ($image = $iaPicture->processImage($_FILES['image'], '', iaUtil::generateToken(), $info)) {
                    empty($guestbook['avatar']) || $iaPicture->delete($guestbook['avatar']);
                    // already has an assigned image
                    $guestbook['avatar'] = $image;