本文整理汇总了PHP中deleteUsers函数的典型用法代码示例。如果您正苦于以下问题:PHP deleteUsers函数的具体用法?PHP deleteUsers怎么用?PHP deleteUsers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deleteUsers函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUser
function createUser($user, $pass, $link, $clear = true)
{
if ($clear) {
deleteUsers($link);
}
$sql = "INSERT INTO web500_users (user, pass) VALUES ('{$user}', '{$pass}')";
$res = mysql_query($sql, $link);
return mysql_affected_rows() > 0;
}
示例2: index
public function index()
{
/*
UserCake (Via CupCake) Version: 2.0.2
http://usercake.com
*/
$baseURL = getcwd();
require_once "{$baseURL}/application/third_party/user_cake/models/config.php";
if (!securePage($_SERVER['PHP_SELF'])) {
die;
}
//Forms posted
if (!empty($_POST)) {
if (!empty($_POST['delete'])) {
$deletions = $_POST['delete'];
if ($deletion_count = deleteUsers($deletions)) {
$successes[] = lang("ACCOUNT_DELETIONS_SUCCESSFUL", array($deletion_count));
} else {
$errors[] = lang("SQL_ERROR");
}
} else {
$errors[] = lang("NO_SELECTION_TO_DELETE_USER");
}
}
$userData = fetchAllUsers();
//Fetch information for all users
require_once "{$baseURL}/application/third_party/user_cake/models/header.php";
echo "\r\n<body>\r\n<div id='wrapper'>\r\n<div id='top'><div id='logo'></div></div>\r\n<div id='content'>\r\n<h1>UserCake (Via CupCake)</h1>\r\n<h2>Admin Users</h2>\r\n<div id='left-nav'>";
include "{$baseURL}/application/third_party/user_cake/left-nav.php";
echo "\r\n</div>\r\n<div id='main'>";
echo resultBlock($errors, $successes);
echo "\r\n<form name='adminUsers' action='" . $_SERVER['PHP_SELF'] . "' method='post'>\r\n<table class='admin'>\r\n<tr>\r\n<th>Delete</th><th>Username</th><th>Display Name</th><th>Title</th><th>Last Sign In</th>\r\n</tr>";
//Cycle through users
foreach ($userData as $v1) {
echo "\r\n\t<tr>\r\n\t<td><input type='checkbox' name='delete[" . $v1['id'] . "]' id='delete[" . $v1['id'] . "]' value='" . $v1['id'] . "'></td>\r\n\t<td><a href='" . str_replace('index.php/', '', site_url('admin_user')) . "?id=" . $v1['id'] . "'>" . $v1['user_name'] . "</a></td>\r\n\t<td>" . $v1['display_name'] . "</td>\r\n\t<td>" . $v1['title'] . "</td>\r\n\t<td>\r\n\t";
//Interprety last login
if ($v1['last_sign_in_stamp'] == '0') {
echo "Never";
} else {
echo date("j M, Y", $v1['last_sign_in_stamp']);
}
echo "\r\n\t</td>\r\n\t</tr>";
}
echo "\r\n</table>\r\n<input type='submit' name='Submit' value='Delete' />\r\n</form>\r\n</div>\r\n<div id='bottom'></div>\r\n</div>\r\n</body>\r\n</html>";
}
示例3: resultBlock
<?php
/*
UserCake Version: 2.0.2
http://usercake.com
*/
require_once __DIR__ . "/models/config.php";
if (!securePage($_SERVER['PHP_SELF'])) {
die;
}
//Forms posted
if (!empty($_POST)) {
$deletions = $_POST['delete'];
if ($deletion_count = deleteUsers($deletions)) {
$successes[] = lang("ACCOUNT_DELETIONS_SUCCESSFUL", array($deletion_count));
} else {
$errors[] = lang("SQL_ERROR");
}
}
$userData = fetchAllUsers();
//Fetch information for all users
require_once __DIR__ . "/models/header.php";
echo "\n<body>\n<div id='wrapper'>\n<div id='top'><div id='logo'></div></div>\n<div id='content'>\n<h1>" . $websiteName . "</h1>\n<h2>Admin Users</h2>\n<div id='left-nav'>";
include __DIR__ . "/left-nav.php";
echo "\n</div>\n<div id='main'>";
echo resultBlock($errors, $successes);
echo "\n<form name='adminUsers' action='" . $_SERVER['PHP_SELF'] . "' method='post'>\n<table class='admin'>\n<tr>\n<th>Delete</th><th>Username</th><th>Display Name</th><th>Title</th><th>Last Sign In</th>\n</tr>";
//Cycle through users
foreach ($userData as $v1) {
echo "\n\t<tr>\n\t<td><input type='checkbox' name='delete[" . $v1['id'] . "]' id='delete[" . $v1['id'] . "]' value='" . $v1['id'] . "'></td>\n\t<td><a href='admin_user.php?id=" . $v1['id'] . "'>" . $v1['user_name'] . "</a></td>\n\t<td>" . $v1['display_name'] . "</td>\n\t<td>" . $v1['title'] . "</td>\n\t<td>\n\t";
//Interprety last login
示例4: redirectMsg
redirectMsg('./users.php?' . $ruta, __('Errors ocurred while trying to update users', 'galleries') . '<br />' . $errors, 1);
die;
} else {
redirectMsg('./users.php?' . $ruta, __('Users updated successfully!', 'galleries'), 0);
die;
}
}
$op = rmc_server_var($_REQUEST, 'op', '');
switch ($op) {
case 'new':
formUsers();
break;
case 'edit':
formUsers(1);
break;
case 'save':
saveUsers();
break;
case 'saveedit':
saveUsers(1);
break;
case 'delete':
deleteUsers();
break;
case 'block':
blockUsers();
break;
default:
showUsers();
break;
}
示例5: syncUsers
function syncUsers()
{
global $_CB_database, $_CB_Backend_Title, $ueConfig, $_PLUGINS;
$_CB_Backend_Title = array(0 => array('fa fa-wrench', CBTxt::T('CB Tools: Synchronize users: Results')));
// Try extending time, as unziping/ftping took already quite some... :
@set_time_limit(240);
$_PLUGINS->loadPluginGroup('user');
$messages = $_PLUGINS->trigger('onBeforeSyncUser', array(true));
foreach ($messages as $msg) {
if ($msg) {
echo '<div class="form-group cb_form_line clearfix">' . $msg . '</div>';
}
}
// 0a. delete user table for bad rows
$sql = "DELETE FROM #__users WHERE id = 0";
$_CB_database->setQuery($sql);
try {
$_CB_database->query();
} catch (RuntimeException $e) {
print '<div class="form-group cb_form_line clearfix text-danger">' . sprintf(CBTxt::T('SQL error %s'), $e->getMessage()) . '</div>';
return;
}
$affected = $_CB_database->getAffectedRows();
if ($affected) {
print '<div class="form-group cb_form_line clearfix text-warning">' . sprintf(CBTxt::T('Deleted %s not allowed user id 0 entry.'), $affected) . '</div>';
}
// 0b. delete comprofiler table for bad rows
$sql = "DELETE FROM #__comprofiler WHERE id = 0";
$_CB_database->setQuery($sql);
try {
$_CB_database->query();
} catch (RuntimeException $e) {
print '<div class="form-group cb_form_line clearfix text-danger">' . sprintf(CBTxt::T('SQL error %s'), $e->getMessage()) . '</div>';
return;
}
$affected = $_CB_database->getAffectedRows();
if ($affected) {
print '<div class="form-group cb_form_line clearfix text-warning">' . sprintf(CBTxt::T('Deleted %s not allowed user id 0 entry.'), $affected) . '</div>';
}
// 1. add missing comprofiler entries, guessing naming depending on CB's name style:
switch ($ueConfig['name_style']) {
case 2:
// firstname + lastname:
$sql = "INSERT IGNORE INTO #__comprofiler(id,user_id,lastname,firstname) " . " SELECT id,id, SUBSTRING_INDEX(name,' ',-1), " . "SUBSTRING( name, 1, length( name ) - length( SUBSTRING_INDEX( name, ' ', -1 ) ) -1 ) " . " FROM #__users";
break;
case 3:
// firstname + middlename + lastname:
$sql = "INSERT IGNORE INTO #__comprofiler(id,user_id,middlename,lastname,firstname) " . " SELECT id,id,SUBSTRING( name, INSTR( name, ' ' ) +1," . " length( name ) - INSTR( name, ' ' ) - length( SUBSTRING_INDEX( name, ' ', -1 ) ) -1 )," . " SUBSTRING_INDEX(name,' ',-1)," . " IF(INSTR(name,' '),SUBSTRING_INDEX( name, ' ', 1 ),'') " . " FROM #__users";
break;
default:
// name only:
$sql = "INSERT IGNORE INTO #__comprofiler(id,user_id) SELECT id,id FROM #__users";
break;
}
$_CB_database->setQuery($sql);
try {
$_CB_database->query();
} catch (RuntimeException $e) {
print '<div class="form-group cb_form_line clearfix text-danger">' . sprintf(CBTxt::T('SQL error %s'), $e->getMessage()) . '</div>';
return;
}
$affected = $_CB_database->getAffectedRows();
if ($affected) {
print '<div class="form-group cb_form_line clearfix text-warning">' . sprintf(CBTxt::T('Added %s new entries to Community Builder from users Table.'), $affected) . '</div>';
}
$sql = "UPDATE #__comprofiler SET `user_id`=`id`";
$_CB_database->setQuery($sql);
try {
$_CB_database->query();
} catch (RuntimeException $e) {
print '<div class="form-group cb_form_line clearfix text-danger">' . sprintf(CBTxt::T('SQL error %s'), $e->getMessage()) . '</div>';
return;
}
$affected = $_CB_database->getAffectedRows();
if ($affected) {
print '<div class="form-group cb_form_line clearfix text-warning">' . sprintf(CBTxt::T('Fixed %s existing entries in Community Builder: fixed wrong user_id.'), $affected) . '</div>';
}
// 2. remove excessive comprofiler entries (e.g. if admin used mambo/joomla delete user function:
$sql = "SELECT c.id FROM #__comprofiler c LEFT JOIN #__users u ON u.id = c.id WHERE u.id IS NULL";
$_CB_database->setQuery($sql);
try {
$users = $_CB_database->loadResultArray();
} catch (RuntimeException $e) {
print '<div class="form-group cb_form_line clearfix text-danger">' . sprintf(CBTxt::T('SQL error %s'), $e->getMessage()) . '</div>';
return;
}
if (count($users)) {
print '<div class="form-group cb_form_line clearfix text-warning">' . sprintf(CBTxt::T('Removing %s entries from Community Builder missing in users Table.'), count($users)) . '</div>';
$msg = deleteUsers($users, true);
print '<div class="form-group cb_form_line clearfix">' . $msg . '</div>';
}
print '<div class="form-group cb_form_line clearfix text-success">' . CBTxt::T('Joomla User Table and Joomla Community Builder User Table now in sync!') . '</div>';
$messages = $_PLUGINS->trigger('onAfterSyncUser', array(true));
foreach ($messages as $msg) {
if ($msg) {
echo '<div class="form-group cb_form_line clearfix">' . $msg . '</div>';
}
}
}
示例6: var_dump
case 15:
//获取批量用户---不分页(默认返回10个)
var_dump(getUsers());
break;
case 16:
//获取批量用户----分页
$cursor = readCursor("userfile.txt");
var_dump(getUsersForPage(10, $cursor));
break;
case 17:
//删除单个用户
var_dump(deleteUser("zhangsan"));
break;
case 18:
//删除批量用户
var_dump(deleteUsers(2));
break;
case 19:
//修改昵称
var_dump(editNickname("zhangsan", "小A"));
break;
case 20:
//添加好友----
var_dump(addFriend("zhangsan", "lisi"));
break;
case 21:
//删除好友
var_dump(deleteFriend("zhangsan", "lisi"));
break;
case 22:
//查看好友
示例7: syncUsers
function syncUsers()
{
global $_CB_database, $ueConfig, $_PLUGINS;
// Try extending time, as unziping/ftping took already quite some... :
@set_time_limit(240);
$_PLUGINS->loadPluginGroup('user');
$messages = $_PLUGINS->trigger('onBeforeSyncUser', true);
foreach ($messages as $msg) {
if ($msg) {
echo "<p>" . $msg . "</p>";
}
}
// 0a. delete user table for bad rows
$sql = "DELETE FROM #__users WHERE id = 0";
$_CB_database->setQuery($sql);
if (!$_CB_database->query()) {
print "<font color=red>" . sprintf(CBTxt::T('SQL error %s'), $_CB_database->stderr(true)) . "</font><br />";
return;
}
$affected = $_CB_database->getAffectedRows();
if ($affected) {
print "<p><font color='orange'>" . sprintf(CBTxt::T('Deleted %s not allowed user id 0 entry.'), $affected) . "</font></p>";
}
// 0b. delete comprofiler table for bad rows
$sql = "DELETE FROM #__comprofiler WHERE id = 0";
$_CB_database->setQuery($sql);
if (!$_CB_database->query()) {
print "<font color=red>" . sprintf(CBTxt::T('SQL error %s'), $_CB_database->stderr(true)) . "</font><br />";
return;
}
$affected = $_CB_database->getAffectedRows();
if ($affected) {
print "<p><font color='orange'>" . sprintf(CBTxt::T('Deleted %s not allowed user id 0 entry.'), $affected) . "</font></p>";
}
// 1. add missing comprofiler entries, guessing naming depending on CB's name style:
switch ($ueConfig['name_style']) {
case 2:
// firstname + lastname:
$sql = "INSERT IGNORE INTO #__comprofiler(id,user_id,lastname,firstname) " . " SELECT id,id, SUBSTRING_INDEX(name,' ',-1), " . "SUBSTRING( name, 1, length( name ) - length( SUBSTRING_INDEX( name, ' ', -1 ) ) -1 ) " . " FROM #__users";
break;
case 3:
// firstname + middlename + lastname:
$sql = "INSERT IGNORE INTO #__comprofiler(id,user_id,middlename,lastname,firstname) " . " SELECT id,id,SUBSTRING( name, INSTR( name, ' ' ) +1," . " length( name ) - INSTR( name, ' ' ) - length( SUBSTRING_INDEX( name, ' ', -1 ) ) -1 )," . " SUBSTRING_INDEX(name,' ',-1)," . " IF(INSTR(name,' '),SUBSTRING_INDEX( name, ' ', 1 ),'') " . " FROM #__users";
break;
default:
// name only:
$sql = "INSERT IGNORE INTO #__comprofiler(id,user_id) SELECT id,id FROM #__users";
break;
}
$_CB_database->setQuery($sql);
if (!$_CB_database->query()) {
print "<font color=red>" . sprintf(CBTxt::T('SQL error %s'), $_CB_database->stderr(true)) . "</font><br />";
return;
}
$affected = $_CB_database->getAffectedRows();
if ($affected) {
print "<p><font color='orange'>" . sprintf(CBTxt::T('Added %s new entries to Community Builder from users Table.'), $affected) . "</font></p>";
}
$sql = "UPDATE #__comprofiler SET `user_id`=`id`";
$_CB_database->setQuery($sql);
if (!$_CB_database->query()) {
print "<font color=red>" . sprintf(CBTxt::T('SQL error %s'), $_CB_database->stderr(true)) . "</font><br />";
return;
}
$affected = $_CB_database->getAffectedRows();
if ($affected) {
print "<p><font color='orange'>" . sprintf(CBTxt::T('Fixed %s existing entries in Community Builder: fixed wrong user_id.'), $affected) . "</font></p>";
}
// 2. remove excessive comprofiler entries (e.g. if admin used mambo/joomla delete user function:
$sql = "SELECT c.id FROM #__comprofiler c LEFT JOIN #__users u ON u.id = c.id WHERE u.id IS NULL";
$_CB_database->setQuery($sql);
$users = $_CB_database->loadResultArray();
if ($_CB_database->getErrorNum()) {
print "<font color=red>" . sprintf(CBTxt::T('SQL error %s'), $_CB_database->stderr(true)) . "</font><br />";
return;
}
if (count($users)) {
print "<p><font color='orange'>" . sprintf(CBTxt::T('Removing %s entries from Community Builder missing in users Table.'), count($users)) . "</font></p>";
$msg = deleteUsers($users, true);
print "<p>" . $msg . "</p>";
}
print "<font color=green>" . CBTxt::T('Joomla/Mambo User Table and Joomla/Mambo Community Builder User Table now in sync!') . "</font>";
$messages = $_PLUGINS->trigger('onAfterSyncUser', true);
foreach ($messages as $msg) {
if ($msg) {
echo "<p>" . $msg . "</p>";
}
}
}
示例8: index
public function index()
{
/*
UserCake (Via CupCake) Version: 2.0.2
http://usercake.com
*/
global $baseURL;
require_once "{$baseURL}/application/third_party/user_cake/models/config.php";
if (!securePage($_SERVER['PHP_SELF'])) {
die;
}
$userId = $_GET['id'];
//Check if selected user exists
if (!userIdExists($userId)) {
header("Location: " . str_replace('index.php/', '', site_url('admin_users')));
die;
}
$userdetails = fetchUserDetails(NULL, NULL, $userId);
//Fetch user details
//Forms posted
if (!empty($_POST)) {
//Delete selected account
if (!empty($_POST['delete'])) {
$deletions = $_POST['delete'];
if ($deletion_count = deleteUsers($deletions)) {
$successes[] = lang("ACCOUNT_DELETIONS_SUCCESSFUL", array($deletion_count));
} else {
$errors[] = lang("SQL_ERROR");
}
} else {
//Update display name
if ($userdetails['display_name'] != $_POST['display']) {
$displayname = trim($_POST['display']);
//Validate display name
if (displayNameExists($displayname)) {
$errors[] = lang("ACCOUNT_DISPLAYNAME_IN_USE", array($displayname));
} elseif (minMaxRange(5, 25, $displayname)) {
$errors[] = lang("ACCOUNT_DISPLAY_CHAR_LIMIT", array(5, 25));
} elseif (!ctype_alnum($displayname)) {
$errors[] = lang("ACCOUNT_DISPLAY_INVALID_CHARACTERS");
} else {
if (updateDisplayName($userId, $displayname)) {
$successes[] = lang("ACCOUNT_DISPLAYNAME_UPDATED", array($displayname));
} else {
$errors[] = lang("SQL_ERROR");
}
}
} else {
$displayname = $userdetails['display_name'];
}
//Activate account
if (isset($_POST['activate']) && $_POST['activate'] == "activate") {
if (setUserActive($userdetails['activation_token'])) {
$successes[] = lang("ACCOUNT_MANUALLY_ACTIVATED", array($displayname));
} else {
$errors[] = lang("SQL_ERROR");
}
}
//Update email
if ($userdetails['email'] != $_POST['email']) {
$email = trim($_POST["email"]);
//Validate email
if (!isValidEmail($email)) {
$errors[] = lang("ACCOUNT_INVALID_EMAIL");
} elseif (emailExists($email)) {
$errors[] = lang("ACCOUNT_EMAIL_IN_USE", array($email));
} else {
if (updateEmail($userId, $email)) {
$successes[] = lang("ACCOUNT_EMAIL_UPDATED");
} else {
$errors[] = lang("SQL_ERROR");
}
}
}
//Update title
if ($userdetails['title'] != $_POST['title']) {
$title = trim($_POST['title']);
//Validate title
if (minMaxRange(1, 50, $title)) {
$errors[] = lang("ACCOUNT_TITLE_CHAR_LIMIT", array(1, 50));
} else {
if (updateTitle($userId, $title)) {
$successes[] = lang("ACCOUNT_TITLE_UPDATED", array($displayname, $title));
} else {
$errors[] = lang("SQL_ERROR");
}
}
}
//Remove permission level
if (!empty($_POST['removePermission'])) {
$remove = $_POST['removePermission'];
if ($deletion_count = removePermission($remove, $userId)) {
$successes[] = lang("ACCOUNT_PERMISSION_REMOVED", array($deletion_count));
} else {
$errors[] = lang("SQL_ERROR");
}
}
if (!empty($_POST['addPermission'])) {
$add = $_POST['addPermission'];
if ($addition_count = addPermission($add, $userId)) {
//.........这里部分代码省略.........