App = $App; $this->Session = $this->App->useSession(); $this->Friend = $this->Session->getFriend(); $this->IsCommitter = $this->Friend->getIsCommitter(); } /** * isBlocked * * @ returns a bool indicating block status of the given IP. */ public function isBlocked(){ $rvalue = FALSE; $subnet = $this->App->getRemoteIPAddress(); //test if we have something that looks like an ip if ( preg_match('/[1-9]{1,3}\.(([0-9]{1,3}\.?){3})/', $subnet )) { if ($this->IsCommitter) { //strip last address chunk, and replace with 0 $this->Subnet = substr_replace($subnet,'.0',strrpos($subnet,'.') ); $sql = "SELECT /* USE MASTER */ COUNT(1) AS BlockCount,ExpiryDateTime FROM Attacks WHERE Subnet= " . $this->App->returnQuotedString($this->Subnet); $rs = $this->App->infra_sql($sql); $myrow = mysql_fetch_assoc($rs); if ($myrow['BlockCount'] > 0) { //stash the expiry time $this->Expiry = $myrow['ExpiryDateTime']; $rvalue = TRUE; } } } return $rvalue; } /** * getExpiry * * @ returns the value stashed in isBlocked. */ public function getExpiry(){ return $this->Expiry; } /** * whyBlocked * * @ returns a string which attempts to explain why you are blocked. */ public function whyBlocked() { //by default someone else was doing something they shouldn't have $rvalue = " due to apparent abuse from your network. Contact webmaster@eclipse.org for asstisance, or wait for the block to expire."; //did you try to login? $sql = "SELECT /* USE MASTER */ COUNT(1) AS RecordCount, UserID FROM UserSSHTrustedSubnets WHERE Subnet= " . $this->App->returnQuotedString($this->Subnet) ." AND AuthReplyEmail IS NULL" ; $rs = $this->App->infra_sql($sql); $myrow = mysql_fetch_assoc($rs); if ($myrow['RecordCount'] > 0) { //caused by the same user? if (strcasecmp($myrow['UserID'], $this->Friend->getUID()) == 0) { $rvalue = " due to a login from a new network. Please check your email for the unblock message."; } else { $rvalue = " due to another committers login from a new network. Either wait for them to respond to the unlock mail or contact webmaster@eclipse.org ."; } } return $rvalue; } }