mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
make sure sql ary is filled before executing the query
git-svn-id: file:///svn/phpbb/trunk@5723 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
c92e1c12a0
commit
1096b13c7e
3 changed files with 34 additions and 18 deletions
|
@ -1217,28 +1217,38 @@ class acp_profile
|
||||||
$where_sql[] = $key . ' = ' . ((is_string($value)) ? "'" . $db->sql_escape($value) . "'" : (int) $value);
|
$where_sql[] = $key . ' = ' . ((is_string($value)) ? "'" . $db->sql_escape($value) . "'" : (int) $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!sizeof($where_sql))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT $check_key
|
$sql = "SELECT $check_key
|
||||||
FROM $table
|
FROM $table
|
||||||
WHERE " . implode(' AND ', $where_sql);
|
WHERE " . implode(' AND ', $where_sql);
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
$row = $db->sql_fetchrow($result);
|
||||||
if (!$db->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
if (!$row)
|
||||||
|
{
|
||||||
$sql_ary = array_merge($where_fields, $sql_ary);
|
$sql_ary = array_merge($where_fields, $sql_ary);
|
||||||
|
|
||||||
|
if (sizeof($sql_ary))
|
||||||
|
{
|
||||||
$db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql_ary));
|
$db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql_ary));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$db->sql_freeresult($result);
|
if (sizeof($sql_ary))
|
||||||
|
{
|
||||||
$sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql_ary) . '
|
$sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||||
WHERE ' . implode(' AND ', $where_sql);
|
WHERE ' . implode(' AND ', $where_sql);
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package module_install
|
* @package module_install
|
||||||
|
|
|
@ -678,10 +678,13 @@ class acp_users
|
||||||
add_log('user', $user_id, 'LOG_USER_NEW_PASSWORD', $user_row['username']);
|
add_log('user', $user_id, 'LOG_USER_NEW_PASSWORD', $user_row['username']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sizeof($sql_ary))
|
||||||
|
{
|
||||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||||
WHERE user_id = ' . $user_id;
|
WHERE user_id = ' . $user_id;
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo adjust every data based in the number of user warnings
|
* @todo adjust every data based in the number of user warnings
|
||||||
|
|
|
@ -179,10 +179,13 @@ class ucp_profile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sizeof($sql_ary))
|
||||||
|
{
|
||||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||||
WHERE user_id = ' . $user->data['user_id'];
|
WHERE user_id = ' . $user->data['user_id'];
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
// Need to update config, forum, topic, posting, messages, etc.
|
// Need to update config, forum, topic, posting, messages, etc.
|
||||||
if ($username != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange'])
|
if ($username != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange'])
|
||||||
|
|
Loading…
Add table
Reference in a new issue