function wpc_client_rul_submit_all($update_or_delete, $address, $address_logout) { global $wpdb, $rul_db_addresses; $address = trim($address); $address_logout = trim($address_logout); // Open the informational div $rul_process_submit = '<div id="message" class="updated fade">' . "\n"; // Code for closing the informational div $rul_process_close = '</div>' . "\n"; // ---------------------------------- // Process the rule changes // ---------------------------------- // Since we never actually, remove the "all" entry, here we just make its value empty if ($update_or_delete == 'Delete') { $update = $wpdb->update($rul_db_addresses, array('rul_url' => '', 'rul_url_logout' => ''), array('rul_type' => 'all')); if ($update === false) { $rul_process_submit .= '<p><strong>****' . __('ERROR: Unknown database problem removing URL for "all other users" ', WPC_CLIENT_TEXT_DOMAIN) . '****</strong></p>' . "\n"; } else { $rul_process_submit .= '<p>' . __('Successfully removed URL for "all other users" ', WPC_CLIENT_TEXT_DOMAIN) . '</p>' . "\n"; } } elseif ($update_or_delete == 'Update') { $address = wpc_client_rul_safe_redirect($address); $address_logout = wpc_client_rul_safe_redirect($address_logout); if ('' != $address && !$address || '' != $address_logout && !$address_logout) { $rul_process_submit .= '<p><strong>****' . __('ERROR: Non-local or invalid URL submitted ', WPC_CLIENT_TEXT_DOMAIN) . '****</strong></p>' . "\n"; } else { $update = $wpdb->update($rul_db_addresses, array('rul_url' => $address, 'rul_url_logout' => $address_logout), array('rul_type' => 'all')); if ($update === false) { $rul_process_submit .= '<p><strong>****' . __('ERROR: Unknown database problem updating URL for "all other users" ', WPC_CLIENT_TEXT_DOMAIN) . '****</strong></p>' . "\n"; } else { $rul_process_submit .= '<p>' . __('Successfully updated URL for "all other users"', WPC_CLIENT_TEXT_DOMAIN) . '</p>' . "\n"; } } } // Close the informational div $rul_process_submit .= $rul_process_close; // We've made it this far, so success! return $rul_process_submit; }
$rul_process_close = ' </div>' . "\n"; $usernames = $_POST['rul_username']; $addresses = $_POST['rul_usernameaddress']; $logout = $_POST['rul_logout_usernameaddress']; if ($usernames && $addresses) { $rul_submit_success = true; $rul_usernames_updated = array(); $rul_username_keys = array_keys($usernames); $rul_username_loop = 0; // Loop through all submitted usernames foreach ($usernames as $username) { $i = $rul_username_keys[$rul_username_loop]; if (username_exists($username)) { // Check to see whether it matches the "local URL" test $address = wpc_client_rul_safe_redirect($addresses[$i]); $lgt = isset($logout[$i]) ? wpc_client_rul_safe_redirect($logout[$i]) : ''; if (!$address) { $rul_submit_success = false; $rul_process_submit .= '<p><strong>****' . __('ERROR: Non-local or invalid URL submitted for user ', WPC_CLIENT_TEXT_DOMAIN) . $username . '****</strong></p>' . "\n"; } else { // Update the existing entry or insert a new one $sql = "REPLACE INTO {$wpdb->prefix}wpc_client_login_redirects SET rul_url = '%s', rul_type = 'user', rul_value = '%s', rul_url_logout='%s'"; $rul_update_username = $wpdb->query($wpdb->prepare($sql, $address, $username, $lgt)); if (!$rul_update_username) { $rul_submit_success = false; $rul_process_submit .= '<p><strong>****' . __('ERROR: Unknown error updating user-specific URL for user ', WPC_CLIENT_TEXT_DOMAIN) . $username . '****</strong></p>' . "\n"; } } // Make a note that we've updated this username $rul_usernames_updated[] = $username; } elseif ($username != -1) {