public function UpdateAllUsers() { $members = $this->GetAllCorpMembers(); // From API. Returns an array(CharID, Name, StartDate, Title, LastGameLogin, Location, Ship, Roles) $ceoid = $this->GetCEOFromAPI(); // From API. CEO character ID $corps = $this->GetAllCorporations(true); // From DB. Returns an array(CorporationID, Name, Ticker) of allowed corps. $users = $this->GetAllUsers(false, false); // From DB. Registered users. if (empty($members) || empty($ceoid)) { return false; } else { $res = array(); foreach ($users as $user) { $corpid = $this->GetCorpIDFromAPI($user->ID); $corpmember = false; foreach ($members as $member) { if ($member["CharID"] == $user->CharID) { $corpmember = true; break; } } if ($corpmember) { $user->IsAlly = false; if ($user->IsGuest == true || $user->IsAlly == true) { $user->IsGuest = false; $res[] = array($user->Name, "Promoted to Member"); } if ($user->IsCEO() && $user->CharID != $ceoid) { if ($user->HasPortalRole(User::MDYN_CEO) == true) { $user->PortalRoles = BigNumber::Subtract($user->PortalRoles, User::MDYN_CEO); } $user->Title = $member["Title"]; $res[] = array($user->Name, "Demoted from CEO"); } elseif (!$user->IsCEO() && $user->CharID == $ceoid) { if ($user->HasPortalRole(User::MDYN_CEO) == false) { $user->PortalRoles = BigNumber::Add($user->PortalRoles, User::MDYN_CEO); } $user->Title = $member["Title"]; $res[] = array($user->Name, "Promoted to CEO"); } if ($user->Title != $member["Title"]) { $user->Title = $member["Title"]; if (empty($user->Title)) { $res[] = array($user->Name, "Title Removed"); } else { $res[] = array($user->Name, "Title Changed to " . $user->Title); } } if (BigNumber::Compare($user->EVERoles, $member["GameRoles"]) != 0) { if ($user->HasEVERole(User::EVE_Director) == true && BigNumber::Compare(BigNumber::BitwiseAnd($member["GameRoles"], User::EVE_Director), "0") == 0) { $res[] = array($user->Name, "Demoted from Director"); } elseif ($user->HasEVERole(User::EVE_Director) == false && BigNumber::Compare(BigNumber::BitwiseAnd($member["GameRoles"], User::EVE_Director), "0") != 0) { $res[] = array($user->Name, "Promoted to Director"); } else { $res[] = array($user->Name, "Roles Changed"); } $user->EVERoles = $member["GameRoles"]; } } else { $rolestokeep = "0"; if ($user->HasPortalRole(User::MDYN_HonoraryMember)) { $rolestokeep = BigNumber::Add($rolestokeep, User::MDYN_HonoraryMember); } elseif ($user->HasPortalRole(User::MDYN_AllyLeader)) { $rolestokeep = BigNumber::Add($rolestokeep, User::MDYN_AllyLeader); } $user->Title = ""; $user->EVERoles = "0"; $user->PortalRoles = $rolestokeep; $ally = false; foreach ($corps as $corp) { if ($corp["CorporationID"] == $corpid) { $ally = true; break; } } if ($ally) { if ($user->IsAlly == false) { $user->IsGuest = false; $user->IsAlly = true; $res[] = array($user->Name, "Changed to Ally"); } } else { if ($user->IsAlly == true) { $user->IsGuest = true; $user->IsAlly = false; $res[] = array($user->Name, "Demoted to Guest from Ally"); } } if (!$ally && $user->IsGuest == false) { $user->IsGuest = true; $user->IsAlly = false; $res[] = array($user->Name, "Demoted to Guest"); } } // Check corporation $raw = $this->APIQuery("http://api.eve-online.com/corp/CorporationSheet.xml.aspx", "CorporationID", $corpid); if (!empty($raw)) { $xml = new SimpleXMLElement($raw); $corpname = $xml->result->corporationName; $corpticker = $xml->result->ticker; if ($corpid != $user->CorporationID || $corpname != $user->CorporationName || $corpticker != $user->CorporationTicker) { $user->CorporationID = $corpid; $user->CorporationName = $corpname; $user->CorporationTicker = $corpticker; $res[] = array($user->Name, "Updated Corporation Info"); } } } // Update database foreach ($users as $user) { if ($user->ID != 3) { $this->CoreSQL("UPDATE users SET CorporationID=" . $user->CorporationID . ", CorporationName='" . $this->SQLEscape($user->CorporationName) . "', CorporationTicker='" . $this->SQLEscape($user->CorporationTicker) . "', IsAlly=" . ($user->IsAlly ? 1 : 0) . ", IsGuest=" . ($user->IsGuest ? 1 : 0) . ", Title='" . $this->SQLEscape($user->Title) . "', EVERoles=" . $user->EVERoles . ", PortalRoles=" . $user->PortalRoles . " WHERE id=" . $user->ID . " LIMIT 1"); } if ($user->ID == $this->CurrentUser()->ID) { @session_start(); $cuser = $_SESSION["user"]; $cuser->IsAlly = $user->IsAlly; $cuser->IsGuest = $user->IsGuest; $cuser->Title = $user->Title; $cuser->EVERoles = $user->EVERoles; $cuser->PortalRoles = $user->PortalRoles; $cuser->CorporationID = $user->CorporationID; $cuser->CorporationName = $user->CorporationName; $cuser->CorporationTicker = $user->CorporationTicker; $_SESSION["user"] = $cuser; } } return $res; } }