本文整理汇总了PHP中utf8_is_valid函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_is_valid函数的具体用法?PHP utf8_is_valid怎么用?PHP utf8_is_valid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_is_valid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _preSaveEntry
protected function _preSaveEntry(array &$entry, array $data, $action)
{
$iaAcl = $this->_iaCore->factory('acl');
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
$entry['id'] = $iaAcl->obtainFreeId();
$entry['assignable'] = $data['visible'];
$entry['visible'] = $data['visible'];
if (iaCore::ACTION_ADD == $action) {
if (empty($data['name'])) {
$this->addMessage('error_usergroup_incorrect');
} else {
$entry['name'] = strtolower(iaSanitize::paranoid($data['name']));
if (!iaValidate::isAlphaNumericValid($entry['name'])) {
$this->addMessage('error_usergroup_incorrect');
} elseif ($this->_iaDb->exists('`name` = :name', array('name' => $entry['name']))) {
$this->addMessage('error_usergroup_exists');
}
}
}
foreach ($this->_iaCore->languages as $iso => $title) {
if (empty($data['title'][$iso])) {
$this->addMessage(iaLanguage::getf('error_lang_title', array('lang' => $this->_iaCore->languages[$iso])), false);
} elseif (!utf8_is_valid($data['title'][$iso])) {
$data['title'][$iso] = utf8_bad_replace($data['title'][$iso]);
}
}
if (!$this->getMessages()) {
foreach ($this->_iaCore->languages as $iso => $title) {
iaLanguage::addPhrase('usergroup_' . $entry['name'], $data['title'][$iso], $iso);
}
}
return !$this->getMessages();
}
示例2: _preSaveEntry
protected function _preSaveEntry(array &$entry, array $data, $action)
{
parent::_preSaveEntry($entry, $data, $action);
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
if (!utf8_is_valid($entry['title'])) {
$entry['title'] = utf8_bad_replace($entry['title']);
}
if (empty($entry['title'])) {
$this->addMessage('title_is_empty');
}
if (!utf8_is_valid($entry['body'])) {
$entry['body'] = utf8_bad_replace($entry['body']);
}
if (empty($entry['body'])) {
$this->addMessage('body_is_empty');
}
if (empty($entry['date_added'])) {
$entry['date_added'] = date(iaDb::DATETIME_FORMAT);
}
$entry['alias'] = $this->getHelper()->titleAlias(empty($entry['alias']) ? $entry['title'] : $entry['alias']);
if (!empty($data['owner'])) {
if ($memberId = $this->_iaCore->iaDb->one_bind('id', '`username` = :name OR `fullname` = :name', array('name' => iaSanitize::sql($_POST['owner'])), iaUsers::getTable())) {
$entry['member_id'] = $memberId;
} else {
$this->addMessage('incorrect_owner_specified');
}
} else {
$entry['member_id'] = iaUsers::getIdentity()->id;
}
if ($this->getMessages()) {
return false;
}
unset($entry['owner']);
if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
$iaPicture = $this->_iaCore->factory('picture');
$path = iaUtil::getAccountDir();
$file = $_FILES['image'];
$token = iaUtil::generateToken();
$info = array('image_width' => 1000, 'image_height' => 750, 'thumb_width' => 250, 'thumb_height' => 250, 'resize_mode' => iaPicture::CROP);
if ($image = $iaPicture->processImage($file, $path, $token, $info)) {
if ($entry['image']) {
$iaPicture = $this->_iaCore->factory('picture');
$iaPicture->delete($entry['image']);
}
$entry['image'] = $image;
}
}
unset($entry['tags']);
return true;
}
示例3: _preSaveEntry
protected function _preSaveEntry(array &$entry, array $data, $action)
{
parent::_preSaveEntry($entry, $data, $action);
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
if (!utf8_is_valid($entry['title'])) {
$entry['title'] = utf8_bad_replace($entry['title']);
}
if (empty($entry['title'])) {
$this->addMessage('title_is_empty');
}
if (!utf8_is_valid($entry['body'])) {
$entry['body'] = utf8_bad_replace($entry['body']);
}
if (empty($entry['body'])) {
$this->addMessage('body_is_empty');
}
if (empty($entry['date_added'])) {
$entry['date_added'] = date(iaDb::DATETIME_FORMAT);
}
$entry['alias'] = $this->getHelper()->titleAlias(empty($entry['alias']) ? $entry['title'] : $entry['alias']);
if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
$this->_iaCore->loadClass(iaCore::CORE, 'picture');
$iaImage = $this->_iaCore->factoryPlugin($this->getPluginName(), iaCore::ADMIN, 'image');
$imageData = json_decode($entry['image-data'], true);
$path = iaUtil::getAccountDir();
$file = $_FILES['image'];
$token = iaUtil::generateToken();
$info = array('image_width' => $this->_iaCore->get('portfolio_image_width'), 'image_height' => $this->_iaCore->get('portfolio_image_height'), 'crop_width' => $imageData['width'], 'crop_height' => $imageData['height'], 'thumb_width' => $this->_iaCore->get('portfolio_thumbnail_width'), 'thumb_height' => $this->_iaCore->get('portfolio_thumbnail_height'), 'positionX' => $imageData['x'], 'positionY' => $imageData['y'], 'position' => 'LT', 'resize' => 'after_crop', 'resize_mode' => iaImage::CROP);
if ($image = $iaImage->processFolioImage($file, $path, $token, $info)) {
if ($entry['image']) {
$iaImage = $this->_iaCore->factory('picture');
$iaImage->delete($entry['image']);
}
$entry['image'] = $image;
}
}
if (empty($entry['image'])) {
$this->addMessage('invalid_image_file');
}
if ($this->getMessages()) {
return false;
}
unset($entry['image-src']);
unset($entry['image-data']);
return true;
}
示例4: utf8_strip_invalid
function utf8_strip_invalid($str, $replacement = true)
{
if (utf8_is_valid($str)) {
return $str;
}
# about 30 % overhead for bad strings but 2.5 times as fast
# for good strings
preg_match_all('/(?:
[\\x00-\\x7E]+ # ASCII
| [\\xC2-\\xDF][\\x80-\\xBF] # non-overlong 2-byte
| \\xE0[\\xA0-\\xBF][\\x80-\\xBF] # excluding overlongs
| [\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2} # straight 3-byte
| \\xED[\\x80-\\x9F][\\x80-\\xBF] # excluding surrogates
| \\xF0[\\x90-\\xBF][\\x80-\\xBF]{2} # planes 1-3
| [\\xF1-\\xF3][\\x80-\\xBF]{3} # planes 4-15
| \\xF4[\\x80-\\x8F][\\x80-\\xBF]{2} # plane 16
)+/xS', $replacement ? '_' . $str . '_' : $str, $mm, PREG_PATTERN_ORDER);
return $replacement ? subStr(implode("�", $mm[0]), 1, -1) : implode('', $mm[0]);
}
示例5: _postSaveEntry
protected function _postSaveEntry(array &$entry, array $data, $action)
{
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
foreach ($this->_iaCore->languages as $code => $language) {
$title = utf8_is_valid($data['title'][$code]) ? $data['title'][$code] : utf8_bad_replace($data['title'][$code]);
iaLanguage::addPhrase('usergroup_' . $entry['name'], $title, $code);
}
// copy privileges
$copyFrom = isset($data['copy_from']) ? (int) $data['copy_from'] : 0;
if ($copyFrom) {
$this->_iaDb->setTable('acl_privileges');
$rows = $this->_iaDb->all(iaDb::ALL_COLUMNS_SELECTION, "`type_id` = '{$copyFrom}' AND `type` = 'group'");
foreach ($rows as $key => &$row) {
$row['type_id'] = $entry['id'];
unset($rows[$key]['id']);
}
$this->_iaDb->insert($rows);
$this->_iaDb->resetTable();
}
}
示例6: _postSaveEntry
protected function _postSaveEntry(array &$entry, array $data, $action)
{
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
foreach ($this->_iaCore->languages as $code => $language) {
$title = iaSanitize::tags($data['title'][$code]);
utf8_is_valid($title) || ($title = utf8_bad_replace($title));
iaLanguage::addPhrase('usergroup_' . $entry['name'], $title, $code);
}
// copy privileges
if ($data['copy_from']) {
$this->_iaDb->setTable('acl_privileges');
$where = '`type_id` = :id AND `type` = :type';
$this->_iaDb->bind($where, array('id' => (int) $data['copy_from'], 'type' => 'group'));
$rows = $this->_iaDb->all(iaDb::ALL_COLUMNS_SELECTION, $where);
foreach ($rows as $key => &$row) {
$row['type_id'] = $this->getEntryId();
unset($rows[$key]['id']);
}
$this->_iaDb->insert($rows);
$this->_iaDb->resetTable();
}
}
示例7: _preSaveEntry
protected function _preSaveEntry(array &$entry, array $data, $action)
{
parent::_preSaveEntry($entry, $data, $action);
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
if (!utf8_is_valid($entry['title'])) {
$entry['title'] = utf8_bad_replace($entry['title']);
}
if (empty($entry['title'])) {
$this->addMessage('title_is_empty');
}
if (!utf8_is_valid($entry['body'])) {
$entry['body'] = utf8_bad_replace($entry['body']);
}
if (empty($entry['body'])) {
$this->addMessage('body_is_empty');
}
if (empty($entry['date_added'])) {
$entry['date_added'] = date(iaDb::DATETIME_FORMAT);
}
$entry['alias'] = $this->getHelper()->titleAlias(empty($entry['alias']) ? $entry['title'] : $entry['alias']);
if ($this->getMessages()) {
return false;
}
if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
$iaPicture = $this->_iaCore->factory('picture');
$path = iaUtil::getAccountDir();
$file = $_FILES['image'];
$token = iaUtil::generateToken();
$info = array('image_width' => 1000, 'image_height' => 750, 'thumb_width' => 250, 'thumb_height' => 250, 'resize_mode' => iaPicture::CROP);
if ($image = $iaPicture->processImage($file, $path, $token, $info)) {
if ($entry['image']) {
$iaPicture = $this->_iaCore->factory('picture');
$iaPicture->delete($entry['image']);
}
$entry['image'] = $image;
}
}
return true;
}
示例8: strlen
}
} else {
$error = true;
$messages[] = iaLanguage::get('error_gb_email');
}
// checking email
if (isset($_POST['aurl']) && !empty($_POST['aurl']) && 'http://' != $_POST['aurl']) {
$entry['author_url'] = $_POST['aurl'];
if (!iaValidate::isUrl($entry['author_url'])) {
$error = true;
$messages[] = iaLanguage::get('error_url');
}
}
// checking body
$entry['body'] = $_POST['message'];
if (!utf8_is_valid($entry['body'])) {
$entry['body'] = utf8_bad_replace($entry['body']);
}
$length = utf8_is_ascii($entry['body']) ? strlen($entry['body']) : utf8_strlen($entry['body']);
if ($iaCore->get('gb_min_chars') > 0) {
if ($length < $iaCore->get('gb_min_chars')) {
$error = true;
$messages[] = iaLanguage::getf('error_min_gb', array('length' => $iaCore->get('gb_min_chars')));
}
}
if ($iaCore->get('gb_max_chars') > 0) {
if ($length > $iaCore->get('gb_max_chars')) {
$error = true;
$messages[] = iaLanguage::getf('error_max_gb', array('length' => $iaCore->get('gb_max_chars')));
}
}
示例9: parsePost
public function parsePost(array $fields, $previousValues = null)
{
$iaCore =& $this->iaCore;
$error = false;
$messages = array();
$invalidFields = array();
$item = array();
$data =& $_POST;
// access to the data source by link
if (iaCore::ACCESS_ADMIN == $this->iaCore->getAccessType()) {
if (isset($data['sponsored'])) {
$item['sponsored'] = (int) $data['sponsored'];
$item['sponsored_plan_id'] = $item['sponsored'] ? (int) $data['plan_id'] : 0;
$item['sponsored_start'] = $item['sponsored'] ? date(iaDb::DATETIME_SHORT_FORMAT) : null;
$item['sponsored_end'] = $item['sponsored'] ? $data['sponsored_end'] : null;
}
if (isset($data['featured'])) {
$item['featured'] = (int) $data['featured'];
if ($item['featured']) {
if (isset($data['featured_end']) && $data['featured_end']) {
$item['featured_start'] = date(iaDb::DATETIME_SHORT_FORMAT);
$item['featured_end'] = iaSanitize::html($data['featured_end']);
} else {
$error = true;
$messages[] = iaLanguage::get('featured_status_finished_date_is_empty');
$invalidFields[] = 'featured_end';
}
} else {
$item['featured_start'] = null;
$item['featured_end'] = null;
}
}
if (isset($data['status'])) {
$item['status'] = iaSanitize::html($data['status']);
}
if (isset($data['date_added'])) {
$time = strtotime($data['date_added']);
if (!$time) {
$error = true;
$messages[] = iaLanguage::get('added_date_is_incorrect');
} elseif ($time > time()) {
$error = true;
$messages[] = iaLanguage::get('future_date_specified_for_added_date');
} else {
$item['date_added'] = date(iaDb::DATETIME_SHORT_FORMAT, $time);
}
}
if (isset($data['owner'])) {
if (empty($data['owner'])) {
$error = true;
$messages[] = iaLanguage::get('owner_is_not_specified');
} else {
if ($memberId = $iaCore->iaDb->one_bind('id', '`username` = :name OR `fullname` = :name', array('name' => iaSanitize::sql($_POST['owner'])), iaUsers::getTable())) {
$item['member_id'] = $memberId;
} else {
$error = true;
$messages[] = iaLanguage::get('incorrect_owner_specified');
}
}
}
if (isset($data['locked'])) {
$item['locked'] = (int) $data['locked'];
}
}
// the code block below filters fields based on parent/dependent structure
$activeFields = array();
$parentFields = array();
foreach ($fields as $field) {
$activeFields[$field['name']] = $field;
if (iaField::RELATION_PARENT == $field['relation']) {
$parentFields[$field['name']] = $field['children'];
}
}
foreach ($parentFields as $fieldName => $dependencies) {
if (isset($data[$fieldName])) {
$value = $data[$fieldName];
foreach ($dependencies as $dependentFieldName => $values) {
if (!in_array($value, $values)) {
unset($activeFields[$dependentFieldName]);
}
}
}
}
//
$iaCore->factory('util');
iaUtil::loadUTF8Functions('validation', 'bad');
foreach ($activeFields as $fieldName => $field) {
isset($data[$fieldName]) || ($data[$fieldName] = '');
// Check the UTF-8 is well formed
if (!is_array($data[$fieldName]) && !utf8_is_valid($data[$fieldName])) {
$data[$fieldName] = utf8_bad_replace($data[$fieldName]);
}
if ($field['extra_actions']) {
if (false === eval($field['extra_actions'])) {
continue;
// make possible to stop further processing of this field by returning FALSE
}
}
if (in_array($field['type'], array(self::TEXT, self::TEXTAREA, self::NUMBER, self::RADIO, self::CHECKBOX, self::COMBO))) {
if ($field['required']) {
//.........这里部分代码省略.........
示例10: valid
/**
* Tests a string as to whether it's valid UTF-8 and supported by the Unicode standard.
*
* Note: this function has been modified to simple return true or false.
*
* @param string $str UTF-8 encoded string.
*
* @return boolean true if valid
*
* @author <hsivonen@iki.fi>
* @see http://hsivonen.iki.fi/php-utf8/
* @see compliant
* @since 2.0
*/
public static function valid($str)
{
require_once __DIR__ . '/phputf8/utils/validation.php';
return utf8_is_valid($str);
}
示例11: valid
/**
* Tests a string as to whether it's valid UTF-8 and supported by the Unicode standard.
*
* Note: this function has been modified to simple return true or false.
*
* @param string $str UTF-8 encoded string.
*
* @return boolean true if valid
*
* @author <hsivonen@iki.fi>
* @see http://hsivonen.iki.fi/php-utf8/
* @see compliant
* @since 1.3.0
*/
public static function valid($str)
{
if (!function_exists('utf8_is_valid')) {
require_once __DIR__ . '/phputf8/utils/validation.php';
}
return utf8_is_valid($str);
}
示例12: _preSaveEntry
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();
}
示例13: _preSaveEntry
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 = '';
//.........这里部分代码省略.........
示例14: array
}
if ($entry['member_id'] != iaUsers::getIdentity()->id) {
return iaView::errorPage(iaView::ERROR_FORBIDDEN);
}
}
if (isset($_POST['data-blog-entry'])) {
$result = false;
$messages = array();
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
$entry['title'] = $_POST['title'];
utf8_is_valid($entry['title']) || ($entry['title'] = utf8_bad_replace($entry['title']));
if (empty($entry['title'])) {
$messages[] = iaLanguage::get('title_is_empty');
}
$entry['body'] = $_POST['body'];
utf8_is_valid($entry['body']) || ($entry['body'] = utf8_bad_replace($entry['body']));
if (empty($entry['body'])) {
$messages[] = iaLanguage::getf('field_is_empty', array('field' => iaLanguage::get('body')));
}
$entry['alias'] = $iaBlog->titleAlias(empty($_POST['alias']) ? $entry['title'] : $_POST['alias']);
if (!$messages) {
if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) {
$iaPicture = $iaCore->factory('picture');
$info = array('image_width' => 1000, 'image_height' => 750, 'thumb_width' => 250, 'thumb_height' => 250, 'resize_mode' => iaPicture::CROP);
if ($image = $iaPicture->processImage($_FILES['image'], iaUtil::getAccountDir(), iaUtil::generateToken(), $info)) {
if ($entry['image']) {
$iaPicture = $iaCore->factory('picture');
$iaPicture->delete($entry['image']);
}
$entry['image'] = $image;
}
示例15: utf8_is_valid
/**
* Detect whether a string contains non-ascii multibyte sequences in the UTF-8 range
* @param $str string input string
* @return boolean
*/
static function utf8_is_valid($str)
{
require_once './lib/pkp/lib/phputf8/utils/validation.php';
return utf8_is_valid($str);
}