$params['tag_keywords'] = prepare_input($_POST['tag_keywords']); } if (isset($_POST['tag_description'])) { $params['tag_description'] = prepare_input($_POST['tag_description']); } if (isset($_POST['page_title'])) { $params['page_title'] = prepare_input($_POST['page_title']); } if (isset($_POST['page_text'])) { $params['page_text'] = prepare_input($_POST['page_text'], false, 'low'); } if (isset($_POST['menu_link'])) { $params['menu_link'] = prepare_input($_POST['menu_link']); } $params['menu_id'] = isset($_POST['menu_id']) ? prepare_input($_POST['menu_id']) : '0'; $params['page_key'] = create_seo_url(prepare_input($_POST['page_title'])); $params['language_id'] = isset($_POST['language_id']) ? prepare_input($_POST['language_id']) : ''; $params['finish_publishing'] = isset($_POST['finish_publishing']) && check_date($_POST['finish_publishing']) ? prepare_input($_POST['finish_publishing']) : '0000-00-00'; if ($objPage->PageCreate($params, $copy_to_other_langs)) { $msg = draw_success_message(_PAGE_CREATED, false); $objSession->SetMessage('notice', $msg); header('location: index.php?admin=pages' . (Application::Get('type') != '' ? '&type=' . Application::Get('type') : '') . '&mg_language_id=' . $params['language_id']); exit; } else { $msg = draw_important_message($objPage->error, false); } } if ($msg == '') { $msg = draw_message(_ALERT_REQUIRED_FILEDS, false); } }
/** * Updates current page * @param $params - set of fields */ public function PageUpdate($params = array()) { if (isset($this->page['id'])) { if (strtolower(SITE_MODE) == 'demo') { $this->error = _OPERATION_BLOCKED; return false; } else { // Get input parameters if (isset($params['id'])) { $this->page['id'] = $params['id']; } if (isset($params['content_type'])) { $this->page['content_type'] = $params['content_type']; } if (isset($params['link_url'])) { $this->page['link_url'] = trim($params['link_url']); } if (isset($params['link_target'])) { $this->page['link_target'] = $params['link_target']; } if (isset($params['system_page'])) { $this->page['system_page'] = trim($params['system_page']); } if (isset($params['page_title'])) { $this->page['page_title'] = trim($params['page_title']); } if (isset($params['page_key'])) { $this->page['page_key'] = $params['page_key']; } if (isset($params['page_text'])) { $this->page['page_text'] = $params['page_text']; } if (isset($params['menu_id'])) { $this->page['menu_id'] = $params['menu_id']; } if (isset($params['menu_link'])) { $this->page['menu_link'] = $params['menu_link']; } if (isset($params['is_published'])) { $this->page['is_published'] = $params['is_published']; } if (isset($params['comments_allowed'])) { $this->page['comments_allowed'] = $params['comments_allowed']; } if (isset($params['show_in_search'])) { $this->page['show_in_search'] = $params['show_in_search']; } if (isset($params['date_updated'])) { $this->page['date_updated'] = $params['date_updated']; } if (isset($params['finish_publishing'])) { $this->page['finish_publishing'] = $params['finish_publishing']; } if (isset($params['priority_order'])) { $this->page['priority_order'] = $params['priority_order']; } if (isset($params['access_level'])) { $this->page['access_level'] = $params['access_level']; } if (isset($params['tag_title'])) { $this->page['tag_title'] = $params['tag_title']; } if (isset($params['tag_keywords'])) { $this->page['tag_keywords'] = $params['tag_keywords']; } if (isset($params['tag_description'])) { $this->page['tag_description'] = $params['tag_description']; } // Menu link cannot be more then 40 characters if ($this->page_id != 'home' && $this->page_id != 'public_home' && strlen($this->page['menu_link']) > 40) { $this->error = _PAGE_LINK_TOO_LONG; return false; } else { if ($this->page['page_title'] == '') { $this->error = _PAGE_HEADER_EMPTY; return false; } else { if ($this->page['content_type'] == 'link' && $this->page['link_url'] == '') { $this->error = str_replace('_FIELD_', '<b>' . _LINK . '</b>', _FIELD_CANNOT_BE_EMPTY); $this->focusOnField = 'link_url'; return false; } else { if (Application::Get('type') == 'system' && $this->page['system_page'] == '') { $this->error = str_replace('_FIELD_', '<b>' . _LINK_PARAMETER . '</b>', _FIELD_CANNOT_BE_EMPTY); $this->focusOnField = 'system_page'; return false; } else { if (!check_integer($this->page['priority_order']) || $this->page['priority_order'] < 0) { $this->error = str_replace('_FIELD_', '<b>' . _ORDER . '</b>', _FIELD_MUST_BE_NUMERIC_POSITIVE); $this->focusOnField = 'priority_order'; return false; } else { if (strlen($this->page['tag_title']) > 255) { $msg_text = str_replace('_FIELD_', '<b>TITLE</b>', _FIELD_LENGTH_ALERT); $msg_text = str_replace('_LENGTH_', '255', $msg_text); $this->error = $msg_text; $this->focusOnField = 'tag_title'; return false; } else { if (strlen($this->page['tag_keywords']) > 512) { $msg_text = str_replace('_FIELD_', '<b>KEYWORDS</b>', _FIELD_LENGTH_ALERT); $msg_text = str_replace('_LENGTH_', '512', $msg_text); $this->error = $msg_text; $this->focusOnField = 'tag_keywords'; return false; } else { if (strlen($this->page['tag_description']) > 512) { $msg_text = str_replace('_FIELD_', '<b>DESCRIPTION</b>', _FIELD_LENGTH_ALERT); $msg_text = str_replace('_LENGTH_', '512', $msg_text); $this->error = $msg_text; $this->focusOnField = 'tag_description'; return false; } } } } } } } } $sql = 'UPDATE ' . TABLE_PAGES . ' SET content_type = \'' . $this->page['content_type'] . '\', link_url = \'' . encode_text($this->page['link_url']) . '\', link_target = \'' . encode_text($this->page['link_target']) . '\', page_title = \'' . encode_text($this->page['page_title']) . '\', page_key = \'' . $this->page['page_key'] . '\', page_text = \'' . encode_text($this->page['page_text']) . '\', menu_id = ' . (int) $this->page['menu_id'] . ', menu_link = \'' . encode_text($this->page['menu_link']) . '\', tag_title = \'' . encode_text($this->page['tag_title']) . '\', tag_keywords = \'' . encode_text($this->page['tag_keywords']) . '\', tag_description = \'' . encode_text($this->page['tag_description']) . '\', comments_allowed = ' . (int) $this->page['comments_allowed'] . ', show_in_search = ' . (int) $this->page['show_in_search'] . ', date_updated = \'' . ($this->page['date_updated'] = date('Y-m-d H:i:s')) . '\', finish_publishing = \'' . $this->page['finish_publishing'] . '\', is_published = ' . (int) $this->page['is_published'] . ', access_level = \'' . $this->page['access_level'] . '\', priority_order = ' . (int) $this->page['priority_order'] . ' ' . (Application::Get('type') == 'system' ? ', system_page=\'' . create_seo_url($this->page['system_page']) . '\'' : '') . ' WHERE id = \'' . (int) $this->page['id'] . '\''; if (database_void_query($sql)) { return true; } else { $this->error = _TRY_LATER; return false; } } } else { $this->error = _PAGE_UNKNOWN; return false; } }