function EditIgnoreList() { global $CFG, $dbConn; // Are they coming for the first time, submitting via form, or submitting via link? if (isset($_REQUEST['submit'])) { // Submitting via form, so remove any empty elements from the array and save it. $aUsernames = (array) $_REQUEST['ignorelist']; foreach ($aUsernames as $k => $v) { if (empty($v)) { unset($aUsernames[$k]); } } // Validate the usernames, and submit it to the database if everything's okay. $aError = ValidateIgnoreList($aUsernames); } else { if ($_REQUEST['action'] == 'add') { // Submitting via link, so store the ID of the user we're adding to our Ignore list. $iUserID = (int) $_REQUEST['userid']; // Make sure they're not trying to ignore themself. if ($iUserID == $_SESSION['userid']) { Msg('You can\'t ignore yourself.'); } // Get our new ignorant's username, verifying we have a valid user ID, // and get our current Ignore list for use later on. $dbConn->query("SELECT their.username, our.ignorelist FROM citizen AS their LEFT JOIN citizen AS our ON 1 WHERE their.id={$iUserID} AND our.id={$_SESSION['userid']}"); list($strUsername, $strIgnoreList) = $dbConn->getresult(); // Is the user ID we have an invalid one? if (!$strUsername) { // Yes. Give the user an error message. ListError(); } // Store our current Ignore list (if it exists) into an array for easy manipulation. if ($strIgnoreList) { $aIgnoreList = explode(',', $strIgnoreList); } // Add our new ignorant's ID to the Ignore list array. $aIgnoreList[] = $iUserID; // Remove any duplicates. $aIgnoreList = array_unique($aIgnoreList); // Put our updated Ignore list array into a plaintext string for use in our SQL query. $strIgnoreList = implode(',', $aIgnoreList); // Save the new Ignore list to the member's record. $dbConn->query("UPDATE citizen SET ignorelist='{$strIgnoreList}' WHERE id={$_SESSION['userid']}"); // Update the user's live Ignore list. $_SESSION['ignorelist'] = $aIgnoreList; // Remove the new ignorant from our Buddy list. RemoveBuddy($iUserID); // Show them the success page. ListSuccess('Ignore'); } else { if ($_REQUEST['action'] == 'remove') { // Removing via link, so store the ID of the user we're removing from our Ignore list. $iUserID = (int) $_REQUEST['userid']; // Remove the ignorant. if (RemoveIgnorant($iUserID)) { // Show them the success page. ListSuccess('Ignore'); } else { // Give the user an error message. ListError(); } } else { // Coming for the first time, so grab the Ignore list from profile. $dbConn->query("SELECT ignorelist FROM citizen WHERE id={$_SESSION['userid']}"); list($strIgnoreList) = $dbConn->getresult(); // Get the usernames of the users (if any) in the Ignore list. if ($strIgnoreList) { $dbConn->query("SELECT id, username FROM citizen WHERE id IN ({$strIgnoreList}) ORDER BY username ASC"); while (list($iUserID, $strUsername) = $dbConn->getresult()) { // Store the username in the usernames array. $aUsernames[$iUserID] = $strUsername; } } } } } // Template require "./skins/{$CFG['skin']}/usercp/ignorelist.tpl.php"; // Send the page. exit; }
} else { if (key_exists('action', $_GET) && $_GET['action'] == 6) { Buddy_Outcome(); } else { if (key_exists('action', $_GET) && $_GET['action'] == 7) { Buddy_Request(); } else { if (key_exists('action', $_GET) && $_GET['action'] == 8 && $_GET['buddy_id']) { $buddy_id = intval($_GET['buddy_id']); $buddy = LoadBuddy($buddy_id); if ($buddy['request_from'] == $GlobalUser['player_id']) { RemoveBuddy($buddy_id); SendMessage($buddy['request_to'], loca("BUDDY_LIST"), loca("BUDDY_CONFIRM"), va(loca("BUDDY_MSG_DELETED"), $GlobalUser['oname']), 0); } if ($buddy['request_to'] == $GlobalUser['player_id']) { RemoveBuddy($buddy_id); SendMessage($buddy['request_from'], loca("BUDDY_LIST"), loca("BUDDY_CONFIRM"), va(loca("BUDDY_MSG_DELETED"), $GlobalUser['oname']), 0); } Buddy_Home(); } else { Buddy_Home(); } } } } } } } } echo "</center>\n"; echo "</div>\n";