本文整理汇总了PHP中validate_data函数的典型用法代码示例。如果您正苦于以下问题:PHP validate_data函数的具体用法?PHP validate_data怎么用?PHP validate_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
public function main($id, $mode)
{
global $data, $config, $error, $submit;
$timezone = $config['board_timezone'];
$data = array('username' => utf8_normalize_nfc(request_var('username', '', true)), 'password' => request_var('password', '', true), 'password_confirm' => request_var('password_confirm', '', true), 'email' => request_var('email', ''), 'email_confirm' => request_var('email_confirm', ''), 'tz' => request_var('tz', (double) $timezone));
if ($submit) {
$error = validate_data($data, array('username' => array(array('string', false, $config['min_username_chars'], $config['max_username_chars']), array('username', '')), 'password' => array(array('string', false, $config['min_password_chars'], $config['max_password_chars'])), 'password_confirm' => array('string', false, $config['min_password_chars'], $config['max_password_chars']), 'email' => array(array('string', false, 6, 60), array('email')), 'email_confirm' => array('string', false, 6, 60), 'tz' => array('num', -14, 14)));
if (!sizeof($error)) {
if ($data['password'] != $data['password_confirm']) {
$error[] = 'PASSWORD_MATCH_ERROR';
}
if ($data['email'] != $data['email_confirm']) {
$error[] = 'EMAIL_MATCH_ERROR';
}
}
if (!sizeof($error)) {
if ($config['activation_required'] == USER_ACTIVATION_SELF || $config['activation_required'] == USER_ACTIVATION_ADMIN) {
$data['group_id'] = INACTIVE_USERS;
} else {
$data['group_id'] = REGISTERED_USERS;
}
if (user_add($data) !== false) {
/**
* @todo registration ok
*/
} else {
/**
* @todo registration failed
*/
}
}
}
}
示例2: main
function main($id, $mode)
{
global $db, $config, $request, $template, $user;
global $phpbb_root_path, $phpbb_admin_path, $phpEx;
$this->page_title = $user->lang['SFS_CONTROL'];
$this->tpl_name = 'stopforumspam_body';
add_form_key('sfs');
$allow_sfs = $this->allow_sfs();
if ($request->is_set_post('submit')) {
// Test if form key is valid
if (!check_form_key('sfs')) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (!function_exists('validate_data')) {
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
}
$check_row = array('sfs_threshold' => $request->variable('sfs_threshold', 0));
$validate_row = array('sfs_threshold' => array('num', false, 1, 99));
$error = validate_data($check_row, $validate_row);
// Replace "error" strings with their real, localised form
$error = array_map(array($user, 'lang'), $error);
if (!sizeof($error)) {
// Set the options the user configured
$this->set_options();
trigger_error($user->lang['SFS_SETTINGS_SUCCESS'] . adm_back_link($this->u_action));
}
}
$template->assign_vars(array('ERROR' => isset($error) ? sizeof($error) ? implode('<br />', $error) : '' : '', 'ALLOW_SFS' => $config['allow_sfs'] ? true : false, 'CURL_ACTIVE' => !empty($allow_sfs) ? '' : '<br /><span class="error">' . $user->lang['LOG_SFS_NEED_CURL'] . '</span>', 'SFS_THRESHOLD' => (int) $config['sfs_threshold'], 'SFS_BAN_IP' => $config['sfs_ban_ip'] ? true : false, 'SFS_LOG_MESSAGE' => $config['sfs_log_message'] ? true : false, 'SFS_DOWN' => $config['sfs_down'] ? true : false, 'SFS_BY_NAME' => $config['sfs_by_name'] ? true : false, 'SFS_BY_EMAIL' => $config['sfs_by_email'] ? true : false, 'SFS_BY_IP' => $config['sfs_by_ip'] ? true : false, 'SFS_BAN_REASON' => $config['sfs_ban_reason'] ? true : false, 'SFS_VERSION' => $config['sfs_version'], 'U_ACTION' => $this->u_action));
}
示例3: import_users_from_file
/**
* Import users into database from a file located on the server.
* Function registered as service.
* @param string The csv (only csv) file containing users tom import
* @param string Security key (as found in configuration file)
* @return string Error message
*/
function import_users_from_file($filepath, $security_key)
{
global $_configuration;
$errors_returned = array(0 => 'success', 1 => 'file import does not exist', 2 => 'no users to import', 3 => 'wrong datas in file', 4 => 'security error');
// Check whether this script is launch by server and security key is ok.
if (empty($_SERVER['REMOTE_ADDR']) || $_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'] || $security_key != $_configuration['security_key']) {
return $errors_returned[4];
}
// Libraries
require_once 'import.lib.php';
// Check is users file exists.
if (!is_file($filepath)) {
return $errors_returned[1];
}
// Get list of users
$users = parse_csv_data($filepath);
if (count($users) == 0) {
return $errors_returned[2];
}
// Check the datas for each user
$errors = validate_data($users);
if (count($errors) > 0) {
return $errors_returned[3];
}
// Apply modifications in database
save_data($users);
return $errors_returned[0];
// Import successfull
}
示例4: validate_profile_info
/**
* Validate changes to their colour
*
* @param object $event The event object
* @return null
* @access public
*/
public function validate_profile_info($event)
{
$array = $event['error'];
if (!function_exists('validate_data')) {
include $this->root_path . 'includes/functions_user.' . $this->php_ext;
}
$validate_array = array('user_colour' => array('string', true, 3, 6));
$error = validate_data($event['data'], $validate_array);
$event['error'] = array_merge($array, $error);
}
示例5: email
/**
* Check email
*
* @return object
*/
public function email()
{
$data = array('email' => $this->request->variable('email', '', true));
$error = validate_data($data, array('email' => array(array('string', false, 6, 60), array('user_email'))));
$error = $this->set_error($error);
if (sizeof($error)) {
return new Response(implode('<br>', $error));
}
return new Response($this->user->lang('EMAIL_GOOD'));
}
示例6: main
function main($id, $mode)
{
global $db, $user, $auth, $template, $cache, $request;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$this->config = $config;
$this->request = $request;
$user->add_lang('acp/common');
$user->add_lang_ext('v12mike/postoftheday', 'acp/info_acp_postoftheday');
$this->tpl_name = 'acp_postoftheday';
$this->page_title = $user->lang['POTD_EXT'];
add_form_key('acp_postoftheday');
if ($request->is_set_post('submit')) {
if (!check_form_key('acp_postoftheday')) {
trigger_error('FORM_INVALID');
}
if (!function_exists('validate_data')) {
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
}
$check_row = array('post_of_the_day_how_many_today' => $request->variable('post_of_the_day_how_many_today', 0));
$validate_row = array('post_of_the_day_how_many_today' => array('num', false, 0, 20));
$error = validate_data($check_row, $validate_row);
// Replace "error" strings with their real, localised form
$error = array_map(array($user, 'lang'), $error);
if (!sizeof($error)) {
$check_row = array('post_of_the_day_how_many_this_week' => $request->variable('post_of_the_day_how_many_this_week', 0));
$validate_row = array('post_of_the_day_how_many_this_week' => array('num', false, 0, 20));
$error = validate_data($check_row, $validate_row);
// Replace "error" strings with their real, localised form
$error = array_map(array($user, 'lang'), $error);
}
if (!sizeof($error)) {
$check_row = array('post_of_the_day_how_many_this_month' => $request->variable('post_of_the_day_how_many_this_month', 0));
$validate_row = array('post_of_the_day_how_many_this_month' => array('num', false, 0, 20));
$error = validate_data($check_row, $validate_row);
// Replace "error" strings with their real, localised form
$error = array_map(array($user, 'lang'), $error);
}
if (!sizeof($error)) {
$check_row = array('post_of_the_day_how_many_this_year' => $request->variable('post_of_the_day_how_many_this_year', 0));
$validate_row = array('post_of_the_day_how_many_this_year' => array('num', false, 0, 20));
$error = validate_data($check_row, $validate_row);
// Replace "error" strings with their real, localised form
$error = array_map(array($user, 'lang'), $error);
}
if (!sizeof($error)) {
$config->set('post_of_the_day_how_many_today', $request->variable('post_of_the_day_how_many_today', 0));
$config->set('post_of_the_day_how_many_this_week', $request->variable('post_of_the_day_how_many_this_week', 0));
$config->set('post_of_the_day_how_many_this_month', $request->variable('post_of_the_day_how_many_this_month', 0));
$config->set('post_of_the_day_how_many_this_year', $request->variable('post_of_the_day_how_many_this_year', 0));
$config->set('post_of_the_day_location', $request->variable('post_of_the_day_location', true));
trigger_error($user->lang['POTD_SAVED'] . adm_back_link($this->u_action));
}
}
$template->assign_vars(array('POTD_ERROR' => isset($error) ? sizeof($error) ? implode('<br />', $error) : '' : '', 'HOWMANY_TODAY' => !empty($this->config['post_of_the_day_how_many_today']) ? $this->config['post_of_the_day_how_many_today'] : 0, 'HOWMANY_THIS_WEEK' => !empty($this->config['post_of_the_day_how_many_this_week']) ? $this->config['post_of_the_day_how_many_this_week'] : 0, 'HOWMANY_THIS_MONTH' => !empty($this->config['post_of_the_day_how_many_this_month']) ? $this->config['post_of_the_day_how_many_this_month'] : 0, 'HOWMANY_THIS_YEAR' => !empty($this->config['post_of_the_day_how_many_this_year']) ? $this->config['post_of_the_day_how_many_this_year'] : 0, 'LOCATION' => !empty($this->config['post_of_the_day_location']) ? true : false, 'POTD_VERSION' => $this->config['post_of_the_day_version'], 'U_ACTION' => $this->u_action));
}
示例7: process_form
/**
* {@inheritdoc}
*/
public function process_form($request, $template, $user, $row, &$error)
{
$row['avatar'] = $request->variable('avatar_gravatar_email', '');
$row['avatar_width'] = $request->variable('avatar_gravatar_width', 0);
$row['avatar_height'] = $request->variable('avatar_gravatar_height', 0);
if (empty($row['avatar'])) {
return false;
}
if (!function_exists('validate_data')) {
require $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
}
$validate_array = validate_data(array('email' => $row['avatar']), array('email' => array(array('string', false, 6, 60), array('email'))));
$error = array_merge($error, $validate_array);
if (!empty($error)) {
return false;
}
// Make sure getimagesize works...
if (function_exists('getimagesize') && ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0)) {
/**
* default to the minimum of the maximum allowed avatar size if the size
* is not or only partially entered
*/
$row['avatar_width'] = $row['avatar_height'] = min($this->config['avatar_max_width'], $this->config['avatar_max_height']);
$url = $this->get_gravatar_url($row);
if (($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) && ($image_data = getimagesize($url)) === false) {
$error[] = 'UNABLE_GET_IMAGE_SIZE';
return false;
}
if (!empty($image_data) && ($image_data[0] <= 0 || $image_data[1] <= 0)) {
$error[] = 'AVATAR_NO_SIZE';
return false;
}
$row['avatar_width'] = $row['avatar_width'] && $row['avatar_height'] ? $row['avatar_width'] : $image_data[0];
$row['avatar_height'] = $row['avatar_width'] && $row['avatar_height'] ? $row['avatar_height'] : $image_data[1];
}
if ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) {
$error[] = 'AVATAR_NO_SIZE';
return false;
}
if ($this->config['avatar_max_width'] || $this->config['avatar_max_height']) {
if ($row['avatar_width'] > $this->config['avatar_max_width'] || $row['avatar_height'] > $this->config['avatar_max_height']) {
$error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $row['avatar_width'], $row['avatar_height']);
return false;
}
}
if ($this->config['avatar_min_width'] || $this->config['avatar_min_height']) {
if ($row['avatar_width'] < $this->config['avatar_min_width'] || $row['avatar_height'] < $this->config['avatar_min_height']) {
$error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $row['avatar_width'], $row['avatar_height']);
return false;
}
}
return array('avatar' => $row['avatar'], 'avatar_width' => $row['avatar_width'], 'avatar_height' => $row['avatar_height']);
}
示例8: main
function main($id, $mode)
{
global $karmamod, $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
$submit = isset($_POST['submit']) ? true : false;
$error = $data = array();
$s_hidden_fields = '';
$data = array('enable' => $karmamod->config['enabled'] ? request_var('enable', (bool) $karmamod->config['user_enabled']) : (bool) $karmamod->config['enabled'], 'notify_email' => $karmamod->config['notify_email'] ? request_var('notify_email', (bool) $karmamod->config['user_notify_email']) : (bool) $karmamod->config['notify_email'], 'notify_pm' => $karmamod->config['notify_pm'] ? request_var('notify_pm', (bool) $karmamod->config['user_notify_pm']) : (bool) $karmamod->config['notify_pm'], 'notify_jabber' => $karmamod->config['notify_jabber'] ? request_var('notify_jabber', (bool) $karmamod->config['user_notify_jabber']) : (bool) $karmamod->config['notify_jabber'], 'toplist' => request_var('toplist', (bool) $karmamod->config['toplist']), 'toplist_users' => request_var('toplist_users', (int) $karmamod->config['toplist_users']), 'comments_per_page' => request_var('comments_per_page', (int) $user->data['user_karma_comments_per_page']), 'comments_self' => request_var('comments_self', (bool) $karmamod->config['comments_self']), 'karma_comments_sk' => request_var('comments_sk', !empty($user->data['user_karma_comments_sortby_type']) ? $user->data['user_karma_comments_sortby_type'] : 't'), 'karma_comments_sd' => request_var('comments_sd', !empty($user->data['user_karma_comments_sortby_dir']) ? $user->data['user_karma_comments_sortby_dir'] : 'd'), 'karma_comments_st' => request_var('comments_st', !empty($user->data['user_karma_comments_show_days']) ? $user->data['user_karma_comments_show_days'] : 0));
if ($submit) {
if ($karmamod->config['comments']) {
// Check that comments sort orders has only one symbol at value
$error = validate_data($data, array('karma_comments_sk' => array('string', false, 1, 1), 'karma_comments_sd' => array('string', false, 1, 1)));
}
if (!sizeof($error)) {
$sql_ary = array('user_karma_enable' => $data['enable'], 'user_karma_notify_email' => $data['notify_email'], 'user_karma_notify_pm' => $data['notify_pm'], 'user_karma_notify_jabber' => $data['notify_jabber'], 'user_karma_toplist' => $data['toplist'], 'user_karma_toplist_users' => $data['toplist_users'], 'user_karma_comments_per_page' => $data['comments_per_page'], 'user_karma_comments_self' => $data['comments_self'], 'user_karma_comments_sortby_type' => $data['karma_comments_sk'], 'user_karma_comments_sortby_dir' => $data['karma_comments_sd'], 'user_karma_comments_show_days' => $data['karma_comments_st']);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
meta_refresh(3, $this->u_action);
$message = $user->lang['UCP_KARMA_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
trigger_error($message);
}
// Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
}
// Comments ordering options
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
$limit_comments_days = array(0 => $user->lang['KARMA_ALL_COMMENTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_comments_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['KARMA_SORT_TIME'], 'p' => $user->lang['KARMA_SORT_POST'], 'o' => $user->lang['KARMA_SORT_TOPIC'], 'f' => $user->lang['KARMA_SORT_FORUM']);
$sort_by_comments_sql = array('a' => 'u.username_clean', 't' => 'k.karma_time', 'p' => 'k.post_id', 'o' => 'k.topic_id', 'f' => 'k.forum_id');
$s_limit_comments_days = '<select name="comments_st">';
foreach ($limit_comments_days as $day => $text) {
$selected = $data['karma_comments_st'] == $day ? ' selected="selected"' : '';
$s_limit_comments_days .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>';
}
$s_limit_comments_days .= '</select>';
$s_sort_comments_key = '<select name="comments_sk">';
foreach ($sort_by_comments_text as $key => $text) {
$selected = $data['karma_comments_sk'] == $key ? ' selected="selected"' : '';
$s_sort_comments_key .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>';
}
$s_sort_comments_key .= '</select>';
$s_sort_comments_dir = '<select name="comments_sd">';
foreach ($sort_dir_text as $key => $value) {
$selected = $data['karma_comments_sd'] == $key ? ' selected="selected"' : '';
$s_sort_comments_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
}
$s_sort_comments_dir .= '</select>';
$template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'S_ENABLE' => $data['enable'], 'S_NOTIFY_EMAIL' => $data['notify_email'], 'S_NOTIFY_PM' => $data['notify_pm'], 'S_NOTIFY_JABBER' => $data['notify_jabber'], 'S_TOPLIST' => $data['toplist'], 'S_COMMENTS_SELF' => $karmamod->config['comments_self'] ? true : false, 'TOPLIST_USERS' => $data['toplist_users'], 'COMMENTS_PER_PAGE' => $data['comments_per_page'], 'S_COMMENTS_SORT_DAYS' => $s_limit_comments_days, 'S_COMMENTS_SORT_KEY' => $s_sort_comments_key, 'S_COMMENTS_SORT_DIR' => $s_sort_comments_dir, 'S_ENABLE_SELECT' => $karmamod->config['enabled_ucp'] ? true : false, 'S_NOTIFY_EMAIL_SELECT' => $karmamod->config['notify_email'] && $config['email_enable'] ? true : false, 'S_NOTIFY_PM_SELECT' => $karmamod->config['notify_pm'] && $config['allow_privmsg'] ? true : false, 'S_NOTIFY_JABBER_SELECT' => $karmamod->config['notify_jabber'] && $config['jab_enable'] ? true : false, 'S_TOPLIST_SELECT' => $karmamod->config['toplist'] ? true : false, 'S_COMMENTS_SELECT' => $karmamod->config['comments'] ? true : false));
$template->assign_vars(array('L_TITLE' => $user->lang['UCP_KARMA'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => $this->u_action));
$this->tpl_name = 'karma_ucp';
$this->page_title = 'UCP_KARMA';
}
示例9: process_form
/**
* {@inheritdoc}
*/
public function process_form($request, $template, $user, $row, &$error)
{
if (!$this->can_upload()) {
return false;
}
if (!class_exists('fileupload')) {
include $this->phpbb_root_path . 'includes/functions_upload.' . $this->php_ext;
}
$upload = new \fileupload('AVATAR_', $this->allowed_extensions, $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false);
$url = $request->variable('avatar_upload_url', '');
$upload_file = $request->file('avatar_upload_file');
if (!empty($upload_file['name'])) {
$file = $upload->form_upload('avatar_upload_file', $this->mimetype_guesser);
} else {
if (!empty($this->config['allow_avatar_remote_upload']) && !empty($url)) {
if (!preg_match('#^(http|https|ftp)://#i', $url)) {
$url = 'http://' . $url;
}
if (!function_exists('validate_data')) {
require $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
}
$validate_array = validate_data(array('url' => $url), array('url' => array('string', true, 5, 255)));
$error = array_merge($error, $validate_array);
if (!empty($error)) {
return false;
}
$file = $upload->remote_upload($url, $this->mimetype_guesser);
} else {
return false;
}
}
$prefix = $this->config['avatar_salt'] . '_';
$file->clean_filename('avatar', $prefix, $row['id']);
$destination = $this->config['avatar_path'];
// Adjust destination path (no trailing slash)
if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') {
$destination = substr($destination, 0, -1);
}
$destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) {
$destination = '';
}
// Move file and overwrite any existing image
$file->move_file($destination, true);
if (sizeof($file->error)) {
$file->remove();
$error = array_merge($error, $file->error);
return false;
}
return array('avatar' => $row['id'] . '_' . time() . '.' . $file->get('extension'), 'avatar_width' => $file->get('width'), 'avatar_height' => $file->get('height'));
}
示例10: main
function main($id, $mode)
{
global $db, $config, $request, $template, $user;
global $phpbb_root_path, $phpbb_admin_path, $phpEx;
$this->page_title = $user->lang['SFS_CONTROL'];
$this->tpl_name = 'stopforumspam_body';
add_form_key('sfs');
$allow_sfs = $this->allow_sfs();
// Get saved settings.
$sql = 'SELECT * FROM ' . CONFIG_TEXT_TABLE . "\n\t\t\t\tWHERE config_name = 'sfs_settings'";
$result = $db->sql_query($sql);
$settings = $db->sql_fetchfield('config_value');
$db->sql_freeresult($result);
if (!empty($settings)) {
$settings = unserialize($settings);
} else {
// Default settings in case something went wrong with the install.
$settings = array('allow_sfs' => $allow_sfs, 'sfs_threshold' => 5, 'sfs_ban_ip' => 0, 'sfs_log_message' => 0, 'sfs_down' => 0, 'sfs_by_name' => 1, 'sfs_by_email' => 1, 'sfs_by_ip' => 1, 'sfs_ban_reason' => 1);
}
if ($request->is_set_post('submit')) {
// Test if form key is valid
if (!check_form_key('sfs')) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (!function_exists('validate_data')) {
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
}
$check_row = array('sfs_threshold' => $request->variable('sfs_threshold', 0));
$validate_row = array('sfs_threshold' => array('num', false, 1, 99));
$error = validate_data($check_row, $validate_row);
// Replace "error" strings with their real, localised form
$error = array_map(array($user, 'lang'), $error);
if (!sizeof($error)) {
$settings = array('allow_sfs' => !empty($allow_sfs) ? $request->variable('allow_sfs', 0) : false, 'sfs_threshold' => $request->variable('sfs_threshold', 0), 'sfs_ban_ip' => $request->variable('sfs_ban_ip', 0), 'sfs_log_message' => $request->variable('sfs_log_message', 0), 'sfs_down' => $request->variable('sfs_down', 0), 'sfs_by_name' => $request->variable('sfs_by_name', 0), 'sfs_by_email' => $request->variable('sfs_by_email', 0), 'sfs_by_ip' => $request->variable('sfs_by_ip', 0), 'sfs_ban_reason' => $request->variable('sfs_ban_reason', 0));
$sql_settings = serialize($settings);
$sql_settings = $db->sql_escape($sql_settings);
$sql = 'UPDATE ' . CONFIG_TEXT_TABLE . "\n\t\t\t\t\t\tSET config_value = '{$sql_settings}'\n\t\t\t\t\t\tWHERE config_name = 'sfs_settings'";
$success = $db->sql_query($sql);
if ($success === false) {
trigger_error($user->lang['SFS_SETTINGS_ERROR'] . adm_back_link($this->u_action), E_USER_ERROR);
} else {
trigger_error($user->lang['SFS_SETTINGS_SUCCESS'] . adm_back_link($this->u_action));
}
}
}
$template->assign_vars(array('ERROR' => isset($error) ? sizeof($error) ? implode('<br />', $error) : '' : '', 'ALLOW_SFS' => !empty($settings['allow_sfs']) ? true : false, 'CURL_ACTIVE' => !empty($allow_sfs) ? '' : '<br /><span class="error">' . $user->lang['LOG_SFS_NEED_CURL'] . '</span>', 'SFS_THRESHOLD' => !empty($settings['sfs_threshold']) ? $settings['sfs_threshold'] : 1, 'SFS_BAN_IP' => !empty($settings['sfs_ban_ip']) ? true : false, 'SFS_LOG_MESSAGE' => !empty($settings['sfs_log_message']) ? true : false, 'SFS_DOWN' => !empty($settings['sfs_down']) ? true : false, 'SFS_BY_NAME' => !empty($settings['sfs_by_name']) ? true : false, 'SFS_BY_EMAIL' => !empty($settings['sfs_by_email']) ? true : false, 'SFS_BY_IP' => !empty($settings['sfs_by_ip']) ? true : false, 'SFS_BAN_REASON' => !empty($settings['sfs_ban_reason']) ? true : false, 'SFS_VERSION' => $config['sfs_version'], 'U_ACTION' => $this->u_action));
}
示例11: run_tool
/**
* Run Tool
*
* Does the actual stuff we want the tool to do after submission
*/
function run_tool(&$error)
{
global $config, $db, $user;
if (!check_form_key('change_password')) {
$error[] = 'FORM_INVALID';
return;
}
$user_req = utf8_normalize_nfc(request_var('user_req', '', true));
if (!$user_req) {
$error[] = 'NO_USER';
return;
}
$sql = 'SELECT user_id, username, user_type FROM ' . USERS_TABLE . '
WHERE ' . (!is_numeric($user_req) ? 'username_clean = \'' . $db->sql_escape(utf8_clean_string($user_req)) . '\'' : 'user_id = ' . (int) $user_req);
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$user_id = (int) $row['user_id'];
$username = $row['username'];
if (!$user_id) {
$error[] = 'NO_USER';
return;
}
$user->add_lang('ucp');
if (!function_exists('validate_data')) {
include PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT;
}
$data = array('new_password' => request_var('new_password', '', true), 'password_confirm' => request_var('password_confirm', '', true));
if ($data['new_password'] != $data['password_confirm']) {
$error[] = 'NEW_PASSWORD_ERROR';
return;
}
$error = validate_data($data, array('new_password' => array('password'), 'password_confirm' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars'])));
if (!empty($error)) {
return;
}
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array('user_password' => phpbb_hash($data['new_password']))) . ' WHERE user_id = ' . $user_id);
add_log('admin', 'LOG_USER_NEW_PASSWORD', $user_req);
trigger_error(sprintf($user->lang['CHANGE_PASSWORD_SUCCESS'], append_sid(PHPBB_ROOT_PATH . 'memberlist.' . PHP_EXT, 'mode=viewprofile&u=' . $user_id), $username));
}
示例12: check_required_params
private static function check_required_params($params)
{
foreach ($params as $param => $validation) {
if (is_int($param)) {
$param = $validation;
unset($validation);
}
if (is_int(strpos($param, '['))) {
$param = '[' . str_replace_limit('[', '][', $param);
} else {
$param = "[{$param}]";
}
$data = isset_array($param, Request::$params);
if (!empty($validation)) {
if (!validate_data($data, $validation)) {
return false;
}
} elseif ($data === null) {
return false;
}
}
return true;
}
示例13: main
function main($id, $mode)
{
global $db, $user, $auth, $template, $cache, $request;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$this->config = $config;
$this->request = $request;
$user->add_lang('acp/common');
$user->add_lang_ext('rmcgirr83/topfive', 'acp/info_acp_topfive');
$this->tpl_name = 'acp_topfive';
$this->page_title = $user->lang['TOPFIVE_MOD'];
add_form_key('acp_topfive');
if ($request->is_set_post('submit')) {
if (!check_form_key('acp_topfive')) {
trigger_error('FORM_INVALID');
}
if (!function_exists('validate_data')) {
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
}
$check_row = array('top_five_how_many' => $request->variable('top_five_how_many', 0));
$validate_row = array('top_five_how_many' => array('num', false, 5, 100));
$error = validate_data($check_row, $validate_row);
// Replace "error" strings with their real, localised form
$error = array_map(array($user, 'lang'), $error);
if (!sizeof($error)) {
$config->set('top_five_how_many', $request->variable('top_five_how_many', 0));
$config->set('top_five_ignore_inactive_users', $request->variable('top_five_ignore_inactive_users', true));
$config->set('top_five_ignore_founder', $request->variable('top_five_ignore_founder', true));
$config->set('top_five_show_admins_mods', $request->variable('top_five_show_admins_mods', true));
$config->set('top_five_location', $request->variable('top_five_location', true));
$config->set('top_five_active', $request->variable('top_five_active', true));
$cache->destroy('_top_five_newest_users');
$cache->destroy('_top_five_posters');
trigger_error($user->lang['TF_SAVED'] . adm_back_link($this->u_action));
}
}
$template->assign_vars(array('TF_ERROR' => isset($error) ? sizeof($error) ? implode('<br />', $error) : '' : '', 'HOWMANY' => !empty($this->config['top_five_how_many']) ? $this->config['top_five_how_many'] : 0, 'IGNORE_INACTIVE' => !empty($this->config['top_five_ignore_inactive_users']) ? true : false, 'IGNORE_FOUNDER' => !empty($this->config['top_five_ignore_founder']) ? true : false, 'SHOW_ADMINS_MODS' => !empty($this->config['top_five_show_admins_mods']) ? true : false, 'LOCATION' => !empty($this->config['top_five_location']) ? true : false, 'ACTIVE' => !empty($this->config['top_five_active']) ? true : false, 'TF_VERSION' => $this->config['top_five_version'], 'U_ACTION' => $this->u_action));
}
示例14: update_ucp_personal_data
public function update_ucp_personal_data($event)
{
$data = $event['data'];
$data['ajaxshoutbox_format'] = $this->request->variable('ajaxshoutbox_format', $this->user->data['user_ajaxshoutbox_format']);
$event['data'] = $data;
if ($event['submit']) {
$error = validate_data($data, array('ajaxshoutbox_format' => array('timezone')));
if (sizeof($error) > 0) {
if (isset($event['error'])) {
$event['error'] = array_merge($event['error'], $error);
} else {
// 3.1.3 and lower don't provide us with $error.
// Set submit to false instead.
$event['submit'] = false;
}
}
}
$dateformat_options = '';
foreach ($this->user->lang['dateformats'] as $format => $null) {
if (strpos($format, '|') === 0) {
continue;
}
$dateformat_options .= '<option value="' . $format . '"' . ($format == $data['ajaxshoutbox_format'] ? ' selected="selected"' : '') . '>';
$dateformat_options .= $this->user->format_date(time(), $format, false) . (strpos($format, '|') !== false ? $this->user->lang['VARIANT_DATE_SEPARATOR'] . $this->user->format_date(time(), $format, true) : '');
$dateformat_options .= '</option>';
}
$s_custom = false;
$dateformat_options .= '<option value="custom"';
if (!isset($this->user->lang['dateformats'][$data['ajaxshoutbox_format']])) {
$dateformat_options .= ' selected="selected"';
$s_custom = true;
}
$dateformat_options .= '>' . $this->user->lang['CUSTOM_DATEFORMAT'] . '</option>';
$this->user->add_lang_ext("paul999/ajaxshoutbox", "ajax_shoutbox");
$this->template->assign_vars(array('S_SHOUTBOX_DATEFORMAT_OPTIONS' => $dateformat_options, 'AJAXSHOUTBOX_DATE_FORMAT' => $data['ajaxshoutbox_format'], 'A_AJAXSHOUTBOX_DATE_FORMAT' => addslashes($data['ajaxshoutbox_format'])));
return $event;
}
示例15: main
//.........这里部分代码省略.........
if (sizeof($forum_id_ary)) {
sync('forum', 'forum_id', $forum_id_ary);
}
$sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE forum_id = {$new_forum_id}";
$result = $db->sql_query($sql, 3600);
$forum_info = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
add_log('admin', 'LOG_USER_MOVE_POSTS', $user_row['username'], $forum_info['forum_name']);
add_log('user', $user_id, 'LOG_USER_MOVE_POSTS_USER', $forum_info['forum_name']);
trigger_error($user->lang['USER_POSTS_MOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
break;
}
$data = array();
// Handle registration info updates
$var_ary = array('user' => (string) $user_row['username'], 'user_founder' => (int) ($user_row['user_type'] == USER_FOUNDER ? 1 : 0), 'user_email' => (string) $user_row['user_email'], 'email_confirm' => (string) '', 'user_password' => (string) '', 'password_confirm' => (string) '', 'warnings' => (int) $user_row['user_warnings']);
// Get the data from the form. Use data from the database if no info is provided
foreach ($var_ary as $var => $default) {
$data[$var] = request_var($var, $default);
}
// We use user within the form to circumvent auto filling
$data['username'] = $data['user'];
unset($data['user']);
// Validation data
$var_ary = array('password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'user_password' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'warnings' => array('num'));
// Check username if altered
if ($data['username'] != $user_row['username']) {
$var_ary += array('username' => array(array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username', $user_row['username'])));
}
// Check email if altered
if ($data['user_email'] != $user_row['user_email']) {
$var_ary += array('user_email' => array(array('string', false, 6, 60), array('email', $user_row['user_email'])), 'email_confirm' => array('string', true, 6, 60));
}
$error = validate_data($data, $var_ary);
if ($data['user_password'] && $data['password_confirm'] != $data['user_password']) {
$error[] = 'NEW_PASSWORD_ERROR';
}
if ($data['user_email'] != $user_row['user_email'] && $data['email_confirm'] != $data['user_email']) {
$error[] = 'NEW_EMAIL_ERROR';
}
// Which updates do we need to do?
$update_warning = $user_row['user_warnings'] != $data['warnings'] ? true : false;
$update_username = $user_row['username'] != $data['username'] ? $data['username'] : false;
$update_password = $data['user_password'] && $user_row['user_password'] != md5($data['user_password']) ? true : false;
$update_email = $data['user_email'] != $user_row['user_email'] ? $data['user_email'] : false;
if (!sizeof($error)) {
$sql_ary = array();
if ($user_row['user_type'] != USER_FOUNDER || $user->data['user_type'] == USER_FOUNDER) {
if ($update_warning) {
$sql_ary['user_warnings'] = $data['warnings'];
}
if ($user_row['user_type'] == USER_FOUNDER && !$data['user_founder'] || $user_row['user_type'] != USER_FOUNDER && $data['user_founder']) {
$sql_ary['user_type'] = $data['user_founder'] ? USER_FOUNDER : USER_NORMAL;
}
}
if ($update_username !== false) {
$sql_ary['username'] = $update_username;
add_log('user', $user_id, 'LOG_USER_UPDATE_NAME', $user_row['username'], $update_username);
}
if ($update_email !== false) {
$sql_ary += array('user_email' => $update_email, 'user_email_hash' => crc32(strtolower($update_email)) . strlen($update_email));
add_log('user', $user_id, 'LOG_USER_UPDATE_EMAIL', $user_row['username'], $user_row['user_email'], $update_email);
}
if ($update_password) {
$sql_ary += array('user_password' => md5($data['user_password']), 'user_passchg' => time());
$user->reset_login_keys($user_id);