We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -56,10 +56,11 @@ |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | public function compareTo(Distance $d) { |
59 | - if ($this->equals($d)===true) |
|
60 | - return 0; |
|
61 | - else if ($d->getTurns() > $this->getTurns()) |
|
62 | - return -1; |
|
59 | + if ($this->equals($d)===true) { |
|
60 | + return 0; |
|
61 | + } else if ($d->getTurns() > $this->getTurns()) { |
|
62 | + return -1; |
|
63 | + } |
|
63 | 64 | return 1; |
64 | 65 | } |
65 | 66 |
@@ -91,8 +91,7 @@ discard block |
||
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
94 | - } |
|
95 | - else if($this->pieceID==self::KING) { |
|
94 | + } else if($this->pieceID==self::KING) { |
|
96 | 95 | for($i = -1; $i < 2; $i++) { |
97 | 96 | for($j = -1; $j < 2; $j++) { |
98 | 97 | if($i!=0 || $j!=0) { |
@@ -114,8 +113,7 @@ discard block |
||
114 | 113 | $this->addMove($this->x+2, $this->y, $board, $moves, $hasMoved, $attackingCheck); |
115 | 114 | } |
116 | 115 | } |
117 | - } |
|
118 | - else if($this->pieceID==self::QUEEN) { |
|
116 | + } else if($this->pieceID==self::QUEEN) { |
|
119 | 117 | $moveX = $this->x; |
120 | 118 | $moveY = $this->y; |
121 | 119 | while($this->addMove(--$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Left |
@@ -140,8 +138,7 @@ discard block |
||
140 | 138 | $moveX = $this->x; |
141 | 139 | $moveY = $this->y; |
142 | 140 | while($this->addMove(++$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left |
143 | - } |
|
144 | - else if($this->pieceID==self::ROOK) { |
|
141 | + } else if($this->pieceID==self::ROOK) { |
|
145 | 142 | $moveX = $this->x; |
146 | 143 | $moveY = $this->y; |
147 | 144 | while($this->addMove(--$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Left |
@@ -154,8 +151,7 @@ discard block |
||
154 | 151 | $moveX = $this->x; |
155 | 152 | $moveY = $this->y; |
156 | 153 | while($this->addMove($moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Down |
157 | - } |
|
158 | - else if($this->pieceID==self::BISHOP) { |
|
154 | + } else if($this->pieceID==self::BISHOP) { |
|
159 | 155 | $moveX = $this->x; |
160 | 156 | $moveY = $this->y; |
161 | 157 | while($this->addMove(--$moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left |
@@ -168,8 +164,7 @@ discard block |
||
168 | 164 | $moveX = $this->x; |
169 | 165 | $moveY = $this->y; |
170 | 166 | while($this->addMove(++$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left |
171 | - } |
|
172 | - else if($this->pieceID==self::KNIGHT) { |
|
167 | + } else if($this->pieceID==self::KNIGHT) { |
|
173 | 168 | $moveX = $this->x-1; |
174 | 169 | $moveY = $this->y-2; |
175 | 170 | $this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck);//2up-left |
@@ -96,8 +96,9 @@ discard block |
||
96 | 96 | if (empty($login)) { return null; } |
97 | 97 | $db = new SmrMySqlDatabase(); |
98 | 98 | $db->query('SELECT account_id FROM account WHERE login = '.$db->escapeString($login).' LIMIT 1'); |
99 | - if($db->nextRecord()) |
|
100 | - return self::getAccount($db->getField('account_id'),$forceUpdate); |
|
99 | + if($db->nextRecord()) { |
|
100 | + return self::getAccount($db->getField('account_id'),$forceUpdate); |
|
101 | + } |
|
101 | 102 | $return = null; |
102 | 103 | return $return; |
103 | 104 | } |
@@ -232,10 +233,10 @@ discard block |
||
232 | 233 | $this->template = $row['template']; |
233 | 234 | $this->colourScheme = $row['colour_scheme']; |
234 | 235 | |
235 | - if(empty($this->hofName)) |
|
236 | - $this->hofName=$this->login; |
|
237 | - } |
|
238 | - else { |
|
236 | + if(empty($this->hofName)) { |
|
237 | + $this->hofName=$this->login; |
|
238 | + } |
|
239 | + } else { |
|
239 | 240 | throw new AccountNotFoundException('Account ID '.$accountID.' does not exist!'); |
240 | 241 | } |
241 | 242 | } |
@@ -257,8 +258,7 @@ discard block |
||
257 | 258 | 'Reason' => $this->db->getField('reason'), |
258 | 259 | 'ReasonID' => $this->db->getInt('reason_id') |
259 | 260 | ); |
260 | - } |
|
261 | - else { |
|
261 | + } else { |
|
262 | 262 | return false; |
263 | 263 | } |
264 | 264 | } |
@@ -314,15 +314,18 @@ discard block |
||
314 | 314 | if ($curr_ip != 'unknown' && $curr_ip != 'unknown...' && $curr_ip != 'unknown, unknown') { |
315 | 315 | $curr_ip = $fi.'.'.$se.'.'.$th.'.'.$fo; |
316 | 316 | $host = gethostbyaddr($curr_ip); |
317 | - } else $host = 'unknown'; |
|
317 | + } else { |
|
318 | + $host = 'unknown'; |
|
319 | + } |
|
318 | 320 | |
319 | 321 | // save...first make sure there isn't one for these keys (someone could double click and get error) |
320 | 322 | $this->db->query('REPLACE INTO account_has_ip (account_id, time, ip, host) VALUES ('.$this->db->escapeNumber($this->account_id).', '.$this->db->escapeNumber(TIME).', '.$this->db->escapeString($curr_ip).', '.$this->db->escapeString($host).')'); |
321 | 323 | } |
322 | 324 | |
323 | 325 | public function updateLastLogin() { |
324 | - if($this->last_login == TIME) |
|
325 | - return; |
|
326 | + if($this->last_login == TIME) { |
|
327 | + return; |
|
328 | + } |
|
326 | 329 | $this->last_login = TIME; |
327 | 330 | $this->hasChanged = true; |
328 | 331 | $this->update(); |
@@ -333,8 +336,9 @@ discard block |
||
333 | 336 | } |
334 | 337 | |
335 | 338 | public function setLoggingEnabled($bool) { |
336 | - if($this->logging==$bool) |
|
337 | - return; |
|
339 | + if($this->logging==$bool) { |
|
340 | + return; |
|
341 | + } |
|
338 | 342 | $this->logging=$bool; |
339 | 343 | $this->hasChanged = true; |
340 | 344 | $this->update(); |
@@ -383,12 +387,14 @@ discard block |
||
383 | 387 | |
384 | 388 | public function getHOF(array $typeList = null) { |
385 | 389 | $this->getHOFData(); |
386 | - if($typeList==null) |
|
387 | - return $this->HOF; |
|
390 | + if($typeList==null) { |
|
391 | + return $this->HOF; |
|
392 | + } |
|
388 | 393 | $hof=$this->HOF; |
389 | 394 | foreach($typeList as $type) { |
390 | - if(!isset($hof[$type])) |
|
391 | - return 0; |
|
395 | + if(!isset($hof[$type])) { |
|
396 | + return 0; |
|
397 | + } |
|
392 | 398 | $hof = $hof[$type]; |
393 | 399 | } |
394 | 400 | return $hof; |
@@ -396,10 +402,11 @@ discard block |
||
396 | 402 | |
397 | 403 | function getRankName() { |
398 | 404 | $rankings = Globals::getUserRanking(); |
399 | - if(isset($rankings[$this->getRank()])) |
|
400 | - return $rankings[$this->getRank()]; |
|
401 | - else |
|
402 | - return end($rankings); |
|
405 | + if(isset($rankings[$this->getRank()])) { |
|
406 | + return $rankings[$this->getRank()]; |
|
407 | + } else { |
|
408 | + return end($rankings); |
|
409 | + } |
|
403 | 410 | } |
404 | 411 | |
405 | 412 | public function getScore() { |
@@ -415,15 +422,17 @@ discard block |
||
415 | 422 | |
416 | 423 | public function &getIndividualScores(SmrPlayer $player = null) { |
417 | 424 | $gameID=0; |
418 | - if($player!=null) |
|
419 | - $gameID = $player->getGameID(); |
|
425 | + if($player!=null) { |
|
426 | + $gameID = $player->getGameID(); |
|
427 | + } |
|
420 | 428 | if(!isset($this->individualScores[$gameID])) { |
421 | 429 | $this->individualScores[$gameID] = array(); |
422 | 430 | foreach(self::USER_RANKINGS_SCORE as $statScore) { |
423 | - if($player==null) |
|
424 | - $stat = $this->getHOF($statScore[0]); |
|
425 | - else |
|
426 | - $stat = $player->getHOF($statScore[0]); |
|
431 | + if($player==null) { |
|
432 | + $stat = $this->getHOF($statScore[0]); |
|
433 | + } else { |
|
434 | + $stat = $player->getHOF($statScore[0]); |
|
435 | + } |
|
427 | 436 | $this->individualScores[$gameID][]=array('Stat'=>$statScore[0],'Score'=>pow($stat*$statScore[1],self::USER_RANKINGS_EACH_STAT_POW)*$statScore[2]); |
428 | 437 | } |
429 | 438 | } |
@@ -432,16 +441,19 @@ discard block |
||
432 | 441 | |
433 | 442 | public function getRank() { |
434 | 443 | $rank = ceil(pow($this->getScore(),self::USER_RANKINGS_TOTAL_SCORE_POW)/self::USER_RANKINGS_RANK_BOUNDARY); |
435 | - if($rank<1) |
|
436 | - $rank=1; |
|
437 | - if($rank > $this->maxRankAchieved) |
|
438 | - $this->updateMaxRankAchieved($rank); |
|
444 | + if($rank<1) { |
|
445 | + $rank=1; |
|
446 | + } |
|
447 | + if($rank > $this->maxRankAchieved) { |
|
448 | + $this->updateMaxRankAchieved($rank); |
|
449 | + } |
|
439 | 450 | return $rank; |
440 | 451 | } |
441 | 452 | |
442 | 453 | protected function updateMaxRankAchieved($rank) { |
443 | - if($rank <= $this->maxRankAchieved) |
|
444 | - throw new Exception('Trying to set max rank achieved to a lower value: ' . $rank); |
|
454 | + if($rank <= $this->maxRankAchieved) { |
|
455 | + throw new Exception('Trying to set max rank achieved to a lower value: ' . $rank); |
|
456 | + } |
|
445 | 457 | $delta = $rank - $this->maxRankAchieved; |
446 | 458 | if($this->hasReferrer()) { |
447 | 459 | $this->getReferrer()->increaseSmrRewardCredits($delta * CREDITS_PER_DOLLAR); |
@@ -488,12 +500,15 @@ discard block |
||
488 | 500 | } |
489 | 501 | |
490 | 502 | public function decreaseTotalSmrCredits($totalCredits) { |
491 | - if($totalCredits==0) |
|
492 | - return; |
|
493 | - if($totalCredits<0) |
|
494 | - throw new Exception('You cannot use negative total credits'); |
|
495 | - if($totalCredits>$this->getTotalSmrCredits()) |
|
496 | - throw new Exception('You do not have that many credits in total to use'); |
|
503 | + if($totalCredits==0) { |
|
504 | + return; |
|
505 | + } |
|
506 | + if($totalCredits<0) { |
|
507 | + throw new Exception('You cannot use negative total credits'); |
|
508 | + } |
|
509 | + if($totalCredits>$this->getTotalSmrCredits()) { |
|
510 | + throw new Exception('You do not have that many credits in total to use'); |
|
511 | + } |
|
497 | 512 | |
498 | 513 | $rewardCredits=$this->rewardCredits; |
499 | 514 | $credits=$this->credits; |
@@ -502,10 +517,11 @@ discard block |
||
502 | 517 | $credits+=$rewardCredits; |
503 | 518 | $rewardCredits=0; |
504 | 519 | } |
505 | - if($this->credits==0 && $this->rewardCredits==0) |
|
506 | - $this->db->query('REPLACE INTO account_has_credits (account_id, credits_left, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).','.$this->db->escapeNumber($rewardCredits).')'); |
|
507 | - else |
|
508 | - $this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).', reward_credits='.$this->db->escapeNumber($rewardCredits).' WHERE '.$this->SQL.' LIMIT 1'); |
|
520 | + if($this->credits==0 && $this->rewardCredits==0) { |
|
521 | + $this->db->query('REPLACE INTO account_has_credits (account_id, credits_left, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).','.$this->db->escapeNumber($rewardCredits).')'); |
|
522 | + } else { |
|
523 | + $this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).', reward_credits='.$this->db->escapeNumber($rewardCredits).' WHERE '.$this->SQL.' LIMIT 1'); |
|
524 | + } |
|
509 | 525 | $this->credits=$credits; |
510 | 526 | $this->rewardCredits=$rewardCredits; |
511 | 527 | } |
@@ -521,48 +537,59 @@ discard block |
||
521 | 537 | } |
522 | 538 | |
523 | 539 | public function setSmrCredits($credits) { |
524 | - if($this->getSmrCredits()==$credits) |
|
525 | - return; |
|
526 | - if($this->credits==0 && $this->rewardCredits==0) |
|
527 | - $this->db->query('REPLACE INTO account_has_credits (account_id, credits_left) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')'); |
|
528 | - else |
|
529 | - $this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1'); |
|
540 | + if($this->getSmrCredits()==$credits) { |
|
541 | + return; |
|
542 | + } |
|
543 | + if($this->credits==0 && $this->rewardCredits==0) { |
|
544 | + $this->db->query('REPLACE INTO account_has_credits (account_id, credits_left) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')'); |
|
545 | + } else { |
|
546 | + $this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1'); |
|
547 | + } |
|
530 | 548 | $this->credits=$credits; |
531 | 549 | } |
532 | 550 | |
533 | 551 | public function increaseSmrCredits($credits) { |
534 | - if($credits==0) |
|
535 | - return; |
|
536 | - if($credits<0) |
|
537 | - throw new Exception('You cannot gain negative credits'); |
|
552 | + if($credits==0) { |
|
553 | + return; |
|
554 | + } |
|
555 | + if($credits<0) { |
|
556 | + throw new Exception('You cannot gain negative credits'); |
|
557 | + } |
|
538 | 558 | $this->setSmrCredits($this->getSmrCredits()+$credits); |
539 | 559 | } |
540 | 560 | |
541 | 561 | public function decreaseSmrCredits($credits) { |
542 | - if($credits==0) |
|
543 | - return; |
|
544 | - if($credits<0) |
|
545 | - throw new Exception('You cannot use negative credits'); |
|
546 | - if($credits>$this->getSmrCredits()) |
|
547 | - throw new Exception('You cannot use more credits than you have'); |
|
562 | + if($credits==0) { |
|
563 | + return; |
|
564 | + } |
|
565 | + if($credits<0) { |
|
566 | + throw new Exception('You cannot use negative credits'); |
|
567 | + } |
|
568 | + if($credits>$this->getSmrCredits()) { |
|
569 | + throw new Exception('You cannot use more credits than you have'); |
|
570 | + } |
|
548 | 571 | $this->setSmrCredits($this->getSmrCredits()-$credits); |
549 | 572 | } |
550 | 573 | |
551 | 574 | public function setSmrRewardCredits($credits) { |
552 | - if($this->getSmrRewardCredits()==$credits) |
|
553 | - return; |
|
554 | - if($this->credits==0 && $this->rewardCredits==0) |
|
555 | - $this->db->query('REPLACE INTO account_has_credits (account_id, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')'); |
|
556 | - else |
|
557 | - $this->db->query('UPDATE account_has_credits SET reward_credits='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1'); |
|
575 | + if($this->getSmrRewardCredits()==$credits) { |
|
576 | + return; |
|
577 | + } |
|
578 | + if($this->credits==0 && $this->rewardCredits==0) { |
|
579 | + $this->db->query('REPLACE INTO account_has_credits (account_id, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')'); |
|
580 | + } else { |
|
581 | + $this->db->query('UPDATE account_has_credits SET reward_credits='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1'); |
|
582 | + } |
|
558 | 583 | $this->rewardCredits=$credits; |
559 | 584 | } |
560 | 585 | |
561 | 586 | public function increaseSmrRewardCredits($credits) { |
562 | - if($credits==0) |
|
563 | - return; |
|
564 | - if($credits<0) |
|
565 | - throw new Exception('You cannot gain negative reward credits'); |
|
587 | + if($credits==0) { |
|
588 | + return; |
|
589 | + } |
|
590 | + if($credits<0) { |
|
591 | + throw new Exception('You cannot gain negative reward credits'); |
|
592 | + } |
|
566 | 593 | $this->setSmrRewardCredits($this->getSmrRewardCredits()+$credits); |
567 | 594 | } |
568 | 595 | |
@@ -598,8 +625,9 @@ discard block |
||
598 | 625 | } |
599 | 626 | |
600 | 627 | public function hasOldAccountID($dbName=false) { |
601 | - if($dbName===false) |
|
602 | - return count($this->getOldAccountIDs())!=0; |
|
628 | + if($dbName===false) { |
|
629 | + return count($this->getOldAccountIDs())!=0; |
|
630 | + } |
|
603 | 631 | return $this->getOldAccountID($dbName)!=0; |
604 | 632 | } |
605 | 633 | |
@@ -678,8 +706,9 @@ discard block |
||
678 | 706 | } |
679 | 707 | |
680 | 708 | public function setFontSize($size) { |
681 | - if($this->fontSize==$size) |
|
682 | - return; |
|
709 | + if($this->fontSize==$size) { |
|
710 | + return; |
|
711 | + } |
|
683 | 712 | $this->fontSize = $size; |
684 | 713 | $this->hasChanged = true; |
685 | 714 | $this->update(); |
@@ -692,8 +721,9 @@ discard block |
||
692 | 721 | |
693 | 722 | // sets the extra CSS file linked in preferences |
694 | 723 | public function setCssLink($link) { |
695 | - if($this->cssLink==$link) |
|
696 | - return; |
|
724 | + if($this->cssLink==$link) { |
|
725 | + return; |
|
726 | + } |
|
697 | 727 | $this->cssLink = $link; |
698 | 728 | $this->hasChanged = true; |
699 | 729 | $this->update(); |
@@ -704,10 +734,12 @@ discard block |
||
704 | 734 | } |
705 | 735 | |
706 | 736 | public function setTemplate($template) { |
707 | - if($this->template==$template) |
|
708 | - return; |
|
709 | - if(!in_array($template,array_keys(Globals::getAvailableTemplates()))) |
|
710 | - throw new Exception('Template not allowed: '.$template); |
|
737 | + if($this->template==$template) { |
|
738 | + return; |
|
739 | + } |
|
740 | + if(!in_array($template,array_keys(Globals::getAvailableTemplates()))) { |
|
741 | + throw new Exception('Template not allowed: '.$template); |
|
742 | + } |
|
711 | 743 | $this->db->query('UPDATE account SET template = ' . $this->db->escapeString($template) . ' WHERE '.$this->SQL.' LIMIT 1'); |
712 | 744 | $this->template = $template; |
713 | 745 | $colourSchemes = Globals::getAvailableColourSchemes($template); |
@@ -719,10 +751,12 @@ discard block |
||
719 | 751 | } |
720 | 752 | |
721 | 753 | public function setColourScheme($colourScheme) { |
722 | - if($this->colourScheme==$colourScheme) |
|
723 | - return; |
|
724 | - if(!in_array($colourScheme,array_keys(Globals::getAvailableColourSchemes($this->getTemplate())))) |
|
725 | - throw new Exception('Colour scheme not allowed: '.$colourScheme); |
|
754 | + if($this->colourScheme==$colourScheme) { |
|
755 | + return; |
|
756 | + } |
|
757 | + if(!in_array($colourScheme,array_keys(Globals::getAvailableColourSchemes($this->getTemplate())))) { |
|
758 | + throw new Exception('Colour scheme not allowed: '.$colourScheme); |
|
759 | + } |
|
726 | 760 | $this->colourScheme = $colourScheme; |
727 | 761 | $this->hasChanged = true; |
728 | 762 | $this->update(); |
@@ -747,8 +781,9 @@ discard block |
||
747 | 781 | } |
748 | 782 | |
749 | 783 | public function setHofName($name) { |
750 | - if($this->hofName==$name) |
|
751 | - return; |
|
784 | + if($this->hofName==$name) { |
|
785 | + return; |
|
786 | + } |
|
752 | 787 | $this->hofName = $name; |
753 | 788 | $this->hasChanged = true; |
754 | 789 | $this->update(); |
@@ -759,8 +794,9 @@ discard block |
||
759 | 794 | } |
760 | 795 | |
761 | 796 | public function setIrcNick($nick) { |
762 | - if($this->ircNick==$nick) |
|
763 | - return; |
|
797 | + if($this->ircNick==$nick) { |
|
798 | + return; |
|
799 | + } |
|
764 | 800 | $this->ircNick = $nick; |
765 | 801 | $this->hasChanged = true; |
766 | 802 | $this->update(); |
@@ -788,8 +824,9 @@ discard block |
||
788 | 824 | } |
789 | 825 | |
790 | 826 | public function setShortDateFormat($format) { |
791 | - if($this->dateShort==$format) |
|
792 | - return; |
|
827 | + if($this->dateShort==$format) { |
|
828 | + return; |
|
829 | + } |
|
793 | 830 | $this->dateShort = $format; |
794 | 831 | $this->hasChanged = true; |
795 | 832 | $this->update(); |
@@ -800,8 +837,9 @@ discard block |
||
800 | 837 | } |
801 | 838 | |
802 | 839 | public function setShortTimeFormat($format) { |
803 | - if($this->timeShort==$format) |
|
804 | - return; |
|
840 | + if($this->timeShort==$format) { |
|
841 | + return; |
|
842 | + } |
|
805 | 843 | $this->timeShort = $format; |
806 | 844 | $this->hasChanged = true; |
807 | 845 | $this->update(); |
@@ -812,16 +850,18 @@ discard block |
||
812 | 850 | } |
813 | 851 | |
814 | 852 | protected function setValidationCode($code) { |
815 | - if($this->validation_code == $code) |
|
816 | - return; |
|
853 | + if($this->validation_code == $code) { |
|
854 | + return; |
|
855 | + } |
|
817 | 856 | $this->validation_code=$code; |
818 | 857 | $this->hasChanged=true; |
819 | 858 | $this->update(); |
820 | 859 | } |
821 | 860 | |
822 | 861 | public function setValidated($bool) { |
823 | - if($this->validated == $bool) |
|
824 | - return; |
|
862 | + if($this->validated == $bool) { |
|
863 | + return; |
|
864 | + } |
|
825 | 865 | $this->validated = $bool; |
826 | 866 | $this->hasChanged = true; |
827 | 867 | $this->update(); |
@@ -894,8 +934,9 @@ discard block |
||
894 | 934 | } |
895 | 935 | |
896 | 936 | protected function setPasswordReset($passwordReset) { |
897 | - if($this->passwordReset == $passwordReset) |
|
898 | - return; |
|
937 | + if($this->passwordReset == $passwordReset) { |
|
938 | + return; |
|
939 | + } |
|
899 | 940 | $this->passwordReset=$passwordReset; |
900 | 941 | $this->hasChanged=true; |
901 | 942 | $this->update(); |
@@ -906,8 +947,9 @@ discard block |
||
906 | 947 | } |
907 | 948 | |
908 | 949 | public function setDisplayShipImages($yesNo) { |
909 | - if($this->images == $yesNo) |
|
910 | - return; |
|
950 | + if($this->images == $yesNo) { |
|
951 | + return; |
|
952 | + } |
|
911 | 953 | $this->images = $yesNo; |
912 | 954 | $this->hasChanged = true; |
913 | 955 | $this->update(); |
@@ -918,8 +960,9 @@ discard block |
||
918 | 960 | } |
919 | 961 | |
920 | 962 | public function setUseAJAX($bool) { |
921 | - if($this->useAJAX == $bool) |
|
922 | - return; |
|
963 | + if($this->useAJAX == $bool) { |
|
964 | + return; |
|
965 | + } |
|
923 | 966 | $this->useAJAX=$bool; |
924 | 967 | $this->hasChanged=true; |
925 | 968 | $this->update(); |
@@ -930,8 +973,9 @@ discard block |
||
930 | 973 | } |
931 | 974 | |
932 | 975 | public function setDefaultCSSEnabled($bool) { |
933 | - if($this->defaultCSSEnabled == $bool) |
|
934 | - return; |
|
976 | + if($this->defaultCSSEnabled == $bool) { |
|
977 | + return; |
|
978 | + } |
|
935 | 979 | $this->defaultCSSEnabled=$bool; |
936 | 980 | $this->hasChanged=true; |
937 | 981 | $this->update(); |
@@ -941,8 +985,7 @@ discard block |
||
941 | 985 | if($hotkeyType!==false) { |
942 | 986 | if(isset($this->hotkeys[$hotkeyType])) { |
943 | 987 | return $this->hotkeys[$hotkeyType]; |
944 | - } |
|
945 | - else { |
|
988 | + } else { |
|
946 | 989 | return array(); |
947 | 990 | } |
948 | 991 | } |
@@ -950,8 +993,9 @@ discard block |
||
950 | 993 | } |
951 | 994 | |
952 | 995 | public function setHotkey($hotkeyType,$binding) { |
953 | - if($this->getHotkeys($hotkeyType) == $binding) |
|
954 | - return; |
|
996 | + if($this->getHotkeys($hotkeyType) == $binding) { |
|
997 | + return; |
|
998 | + } |
|
955 | 999 | $this->hotkeys[$hotkeyType] = $binding; |
956 | 1000 | $this->hasChanged=true; |
957 | 1001 | $this->update(); |
@@ -966,26 +1010,31 @@ discard block |
||
966 | 1010 | } |
967 | 1011 | |
968 | 1012 | public function setMessageNotifications($messageTypeID,$num) { |
969 | - if($this->getMessageNotifications($messageTypeID) == $num) |
|
970 | - return; |
|
1013 | + if($this->getMessageNotifications($messageTypeID) == $num) { |
|
1014 | + return; |
|
1015 | + } |
|
971 | 1016 | $this->messageNotifications[$messageTypeID]=$num; |
972 | 1017 | $this->hasChanged=true; |
973 | 1018 | $this->update(); |
974 | 1019 | } |
975 | 1020 | |
976 | 1021 | public function increaseMessageNotifications($messageTypeID,$num) { |
977 | - if($num==0) |
|
978 | - return; |
|
979 | - if($num<0) |
|
980 | - throw new Exception('You cannot increase by a negative amount'); |
|
1022 | + if($num==0) { |
|
1023 | + return; |
|
1024 | + } |
|
1025 | + if($num<0) { |
|
1026 | + throw new Exception('You cannot increase by a negative amount'); |
|
1027 | + } |
|
981 | 1028 | $this->setMessageNotifications($messageTypeID, $this->getMessageNotifications($messageTypeID) + $num); |
982 | 1029 | } |
983 | 1030 | |
984 | 1031 | public function decreaseMessageNotifications($messageTypeID,$num) { |
985 | - if($num==0) |
|
986 | - return; |
|
987 | - if($num<0) |
|
988 | - throw new Exception('You cannot decrease by a negative amount'); |
|
1032 | + if($num==0) { |
|
1033 | + return; |
|
1034 | + } |
|
1035 | + if($num<0) { |
|
1036 | + throw new Exception('You cannot decrease by a negative amount'); |
|
1037 | + } |
|
989 | 1038 | $this->setMessageNotifications($messageTypeID, $this->getMessageNotifications($messageTypeID) - $num); |
990 | 1039 | } |
991 | 1040 | |
@@ -994,8 +1043,9 @@ discard block |
||
994 | 1043 | } |
995 | 1044 | |
996 | 1045 | public function setCenterGalaxyMapOnPlayer($bool) { |
997 | - if($this->centerGalaxyMapOnPlayer == $bool) |
|
998 | - return; |
|
1046 | + if($this->centerGalaxyMapOnPlayer == $bool) { |
|
1047 | + return; |
|
1048 | + } |
|
999 | 1049 | $this->centerGalaxyMapOnPlayer=$bool; |
1000 | 1050 | $this->hasChanged=true; |
1001 | 1051 | $this->update(); |
@@ -1010,8 +1060,9 @@ discard block |
||
1010 | 1060 | } |
1011 | 1061 | |
1012 | 1062 | public function setMailBanned($time) { |
1013 | - if($this->mailBanned == $time) |
|
1014 | - return; |
|
1063 | + if($this->mailBanned == $time) { |
|
1064 | + return; |
|
1065 | + } |
|
1015 | 1066 | $this->mailBanned=$time; |
1016 | 1067 | $this->hasChanged=true; |
1017 | 1068 | } |
@@ -1065,53 +1116,59 @@ discard block |
||
1065 | 1116 | |
1066 | 1117 | public function setPoints($numPoints,$lastUpdate=false) { |
1067 | 1118 | $numPoints = max($numPoints,0); |
1068 | - if($this->getPoints()==$numPoints) |
|
1069 | - return; |
|
1070 | - if ($this->points==0) |
|
1071 | - $this->db->query('INSERT INTO account_has_points (account_id, points, last_update) VALUES ('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($numPoints).', '.$this->db->escapeNumber($lastUpdate?$lastUpdate:TIME).')'); |
|
1072 | - else if($numPoints<=0) |
|
1073 | - $this->db->query('DELETE FROM account_has_points WHERE '.$this->SQL.' LIMIT 1'); |
|
1074 | - else |
|
1075 | - $this->db->query('UPDATE account_has_points SET points = '.$this->db->escapeNumber($numPoints).($lastUpdate ? ', last_update = '.$this->db->escapeNumber(TIME) : '').' WHERE '.$this->SQL.' LIMIT 1'); |
|
1119 | + if($this->getPoints()==$numPoints) { |
|
1120 | + return; |
|
1121 | + } |
|
1122 | + if ($this->points==0) { |
|
1123 | + $this->db->query('INSERT INTO account_has_points (account_id, points, last_update) VALUES ('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($numPoints).', '.$this->db->escapeNumber($lastUpdate?$lastUpdate:TIME).')'); |
|
1124 | + } else if($numPoints<=0) { |
|
1125 | + $this->db->query('DELETE FROM account_has_points WHERE '.$this->SQL.' LIMIT 1'); |
|
1126 | + } else { |
|
1127 | + $this->db->query('UPDATE account_has_points SET points = '.$this->db->escapeNumber($numPoints).($lastUpdate ? ', last_update = '.$this->db->escapeNumber(TIME) : '').' WHERE '.$this->SQL.' LIMIT 1'); |
|
1128 | + } |
|
1076 | 1129 | $this->points=$numPoints; |
1077 | 1130 | } |
1078 | 1131 | |
1079 | 1132 | public function removePoints($numPoints,$lastUpdate=false) { |
1080 | - if($numPoints>0) |
|
1081 | - $this->setPoints($this->getPoints()-$numPoints,$lastUpdate); |
|
1133 | + if($numPoints>0) { |
|
1134 | + $this->setPoints($this->getPoints()-$numPoints,$lastUpdate); |
|
1135 | + } |
|
1082 | 1136 | } |
1083 | 1137 | |
1084 | 1138 | public function addPoints($numPoints,SmrAccount $admin,$reasonID,$suspicion) { |
1085 | 1139 | //do we have points |
1086 | 1140 | $this->setPoints($this->getPoints() + $numPoints,TIME); |
1087 | 1141 | $totalPoints = $this->getPoints(); |
1088 | - if ($totalPoints < 10) |
|
1089 | - return false;//leave scripts its only a warning |
|
1090 | - elseif ($totalPoints < 20) |
|
1091 | - $days = 2; |
|
1092 | - elseif ($totalPoints < 30) |
|
1093 | - $days = 4; |
|
1094 | - elseif ($totalPoints < 50) |
|
1095 | - $days = 7; |
|
1096 | - elseif ($totalPoints < 75) |
|
1097 | - $days = 15 ; |
|
1098 | - elseif ($totalPoints < 100) |
|
1099 | - $days = 30; |
|
1100 | - elseif ($totalPoints < 125) |
|
1101 | - $days = 60; |
|
1102 | - elseif ($totalPoints < 150) |
|
1103 | - $days = 120; |
|
1104 | - elseif ($totalPoints < 175) |
|
1105 | - $days = 240; |
|
1106 | - elseif ($totalPoints < 200) |
|
1107 | - $days = 480; |
|
1108 | - else |
|
1109 | - $days = 0; //Forever/indefinite |
|
1142 | + if ($totalPoints < 10) { |
|
1143 | + return false; |
|
1144 | + } |
|
1145 | + //leave scripts its only a warning |
|
1146 | + elseif ($totalPoints < 20) { |
|
1147 | + $days = 2; |
|
1148 | + } elseif ($totalPoints < 30) { |
|
1149 | + $days = 4; |
|
1150 | + } elseif ($totalPoints < 50) { |
|
1151 | + $days = 7; |
|
1152 | + } elseif ($totalPoints < 75) { |
|
1153 | + $days = 15 ; |
|
1154 | + } elseif ($totalPoints < 100) { |
|
1155 | + $days = 30; |
|
1156 | + } elseif ($totalPoints < 125) { |
|
1157 | + $days = 60; |
|
1158 | + } elseif ($totalPoints < 150) { |
|
1159 | + $days = 120; |
|
1160 | + } elseif ($totalPoints < 175) { |
|
1161 | + $days = 240; |
|
1162 | + } elseif ($totalPoints < 200) { |
|
1163 | + $days = 480; |
|
1164 | + } else { |
|
1165 | + $days = 0; |
|
1166 | + } |
|
1167 | + //Forever/indefinite |
|
1110 | 1168 | |
1111 | 1169 | if($days==0) { |
1112 | 1170 | $expireTime = 0; |
1113 | - } |
|
1114 | - else { |
|
1171 | + } else { |
|
1115 | 1172 | $expireTime = TIME + $days * 86400; |
1116 | 1173 | } |
1117 | 1174 | $this->banAccount($expireTime,$admin,$reasonID,$suspicion); |
@@ -1166,26 +1223,30 @@ discard block |
||
1166 | 1223 | $player->update(); |
1167 | 1224 | } |
1168 | 1225 | $this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account closed by ' . $admin->getLogin() . '.'); |
1169 | - if($removeExceptions!==false) |
|
1170 | - $this->db->query('DELETE FROM account_exceptions WHERE ' . $this->SQL); |
|
1226 | + if($removeExceptions!==false) { |
|
1227 | + $this->db->query('DELETE FROM account_exceptions WHERE ' . $this->SQL); |
|
1228 | + } |
|
1171 | 1229 | } |
1172 | 1230 | |
1173 | 1231 | public function unbanAccount(SmrAccount $admin = null,$currException=false) { |
1174 | 1232 | $adminID = 0; |
1175 | - if($admin!==null) |
|
1176 | - $adminID = $admin->getAccountID(); |
|
1233 | + if($admin!==null) { |
|
1234 | + $adminID = $admin->getAccountID(); |
|
1235 | + } |
|
1177 | 1236 | $this->db->query('DELETE FROM account_is_closed WHERE ' . $this->SQL . ' LIMIT 1'); |
1178 | 1237 | $this->db->query('INSERT INTO account_has_closing_history |
1179 | 1238 | (account_id, time, admin_id, action) |
1180 | 1239 | VALUES(' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber(TIME) . ', ' . $this->db->escapeNumber($adminID) . ', ' . $this->db->escapeString('Opened') . ')'); |
1181 | 1240 | $this->db->query('UPDATE player SET last_turn_update = GREATEST(' . $this->db->escapeNumber(TIME) . ', last_turn_update) WHERE ' . $this->SQL); |
1182 | - if($admin!==null) |
|
1183 | - $this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account reopened by ' . $admin->getLogin() . '.'); |
|
1184 | - else |
|
1185 | - $this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account automatically reopened.'); |
|
1186 | - if($currException!==false) |
|
1187 | - $this->db->query('REPLACE INTO account_exceptions (account_id, reason) |
|
1241 | + if($admin!==null) { |
|
1242 | + $this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account reopened by ' . $admin->getLogin() . '.'); |
|
1243 | + } else { |
|
1244 | + $this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account automatically reopened.'); |
|
1245 | + } |
|
1246 | + if($currException!==false) { |
|
1247 | + $this->db->query('REPLACE INTO account_exceptions (account_id, reason) |
|
1188 | 1248 | VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeString($currException) . ')'); |
1249 | + } |
|
1189 | 1250 | } |
1190 | 1251 | |
1191 | 1252 | public function getToggleAJAXHREF() { |
@@ -359,8 +359,7 @@ discard block |
||
359 | 359 | public static function getPlotCourseHREF($fromSector = false, $toSector = false) { |
360 | 360 | if($fromSector === false && $toSector === false) { |
361 | 361 | return self::$AVAILABLE_LINKS['PlotCourse'] = SmrSession::getNewHREF(create_container('skeleton.php','course_plot.php')); |
362 | - } |
|
363 | - else { |
|
362 | + } else { |
|
364 | 363 | return SmrSession::getNewHREF(create_container('course_plot_processing.php','',array('from'=>$fromSector,'to'=>$toSector))); |
365 | 364 | } |
366 | 365 | } |
@@ -392,8 +391,7 @@ discard block |
||
392 | 391 | public static function getAllianceHREF($allianceID = null) { |
393 | 392 | if ($allianceID > 0) { |
394 | 393 | return self::getAllianceMotdHREF($allianceID); |
395 | - } |
|
396 | - else { |
|
394 | + } else { |
|
397 | 395 | return self::getAllianceListHREF(); |
398 | 396 | } |
399 | 397 | } |
@@ -126,8 +126,7 @@ discard block |
||
126 | 126 | $amount = $this->getHardware($hardwareTypeID); |
127 | 127 | if ($amount > 0) { |
128 | 128 | $this->db->query('REPLACE INTO ship_has_hardware (account_id, game_id, hardware_type_id, amount, old_amount) VALUES(' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeNumber($hardwareTypeID) . ', ' . $this->db->escapeNumber($amount) . ', ' . $this->db->escapeNumber($this->getOldHardware($hardwareTypeID)) . ')'); |
129 | - } |
|
130 | - else { |
|
129 | + } else { |
|
131 | 130 | $this->db->query('DELETE FROM ship_has_hardware WHERE ' . $this->SQL . ' AND hardware_type_id = ' . $this->db->escapeNumber($hardwareTypeID)); |
132 | 131 | } |
133 | 132 | } |
@@ -181,8 +180,9 @@ discard block |
||
181 | 180 | } |
182 | 181 | |
183 | 182 | public function isCloaked() { |
184 | - if(!$this->hasCloak()) |
|
185 | - return false; |
|
183 | + if(!$this->hasCloak()) { |
|
184 | + return false; |
|
185 | + } |
|
186 | 186 | if(!isset($this->isCloaked)) { |
187 | 187 | $this->db->query('SELECT 1 FROM ship_is_cloaked WHERE ' . $this->SQL . ' LIMIT 1'); |
188 | 188 | $this->isCloaked = $this->db->getNumRows()>0; |
@@ -1,17 +1,21 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function checkPortTradeable(&$port,&$player) { |
4 | - if($port->getSectorID()!=$player->getSectorID()) |
|
5 | - return 'That port is not in this sector!'; |
|
4 | + if($port->getSectorID()!=$player->getSectorID()) { |
|
5 | + return 'That port is not in this sector!'; |
|
6 | + } |
|
6 | 7 | |
7 | - if(!$port->exists()) |
|
8 | - return 'There is no port in this sector!'; |
|
8 | + if(!$port->exists()) { |
|
9 | + return 'There is no port in this sector!'; |
|
10 | + } |
|
9 | 11 | |
10 | - if($player->getRelation($port->getRaceID()) <= RELATIONS_WAR) |
|
11 | - return 'We will not trade with our enemies!'; |
|
12 | + if($player->getRelation($port->getRaceID()) <= RELATIONS_WAR) { |
|
13 | + return 'We will not trade with our enemies!'; |
|
14 | + } |
|
12 | 15 | |
13 | - if($port->getReinforceTime() > TIME) |
|
14 | - return 'We are still repairing damage caused during the last raid.'; |
|
16 | + if($port->getReinforceTime() > TIME) { |
|
17 | + return 'We are still repairing damage caused during the last raid.'; |
|
18 | + } |
|
15 | 19 | |
16 | 20 | return true; |
17 | 21 | } |
@@ -55,39 +59,43 @@ discard block |
||
55 | 59 | if (abs($port_off_rel) > abs($trader_off_rel)) { |
56 | 60 | // get a random number between |
57 | 61 | // (port_off) and (100 +/- $trader_off_rel) |
58 | - if (100 + $trader_off_rel < $port_off) |
|
59 | - $offer_modifier = mt_rand(100 + $trader_off_rel, $port_off); |
|
60 | - else |
|
61 | - $offer_modifier = mt_rand($port_off, 100 + $trader_off_rel); |
|
62 | + if (100 + $trader_off_rel < $port_off) { |
|
63 | + $offer_modifier = mt_rand(100 + $trader_off_rel, $port_off); |
|
64 | + } else { |
|
65 | + $offer_modifier = mt_rand($port_off, 100 + $trader_off_rel); |
|
66 | + } |
|
62 | 67 | |
63 | 68 | $container['offered_price'] = round($container['ideal_price'] * $offer_modifier / 100); |
64 | 69 | } |
70 | + } else { |
|
71 | + $container['overall_number_of_bargains'] = mt_rand(2, 5); |
|
72 | + } |
|
65 | 73 | } |
66 | - else |
|
67 | - $container['overall_number_of_bargains'] = mt_rand(2, 5); |
|
68 | -} |
|
69 | 74 | |
70 | 75 | function get_amount() { |
71 | 76 | global $var, $_REQUEST; |
72 | 77 | |
73 | 78 | // retrieve amount |
74 | - if (isset($var['amount'])) |
|
75 | - $amount = $var['amount']; |
|
76 | - else if (isset($_REQUEST['amount'])) |
|
77 | - $amount = $_REQUEST['amount']; |
|
78 | - else |
|
79 | - $amount = 0; |
|
79 | + if (isset($var['amount'])) { |
|
80 | + $amount = $var['amount']; |
|
81 | + } else if (isset($_REQUEST['amount'])) { |
|
82 | + $amount = $_REQUEST['amount']; |
|
83 | + } else { |
|
84 | + $amount = 0; |
|
85 | + } |
|
80 | 86 | |
81 | 87 | // only numbers |
82 | - if (!is_numeric($amount)) |
|
83 | - create_error('You must actually enter a number!'); |
|
88 | + if (!is_numeric($amount)) { |
|
89 | + create_error('You must actually enter a number!'); |
|
90 | + } |
|
84 | 91 | |
85 | 92 | // we take as it is but round it |
86 | 93 | $amount = floor($amount); |
87 | 94 | |
88 | 95 | // no negative amounts are allowed |
89 | - if ($amount <= 0) |
|
90 | - create_error('You must actually enter an amount > 0!'); |
|
96 | + if ($amount <= 0) { |
|
97 | + create_error('You must actually enter an amount > 0!'); |
|
98 | + } |
|
91 | 99 | |
92 | 100 | return $amount; |
93 | 101 | } |
@@ -96,23 +104,26 @@ discard block |
||
96 | 104 | global $_REQUEST,$var; |
97 | 105 | |
98 | 106 | // we get it from form |
99 | - if (isset($_REQUEST['bargain_price'])) |
|
100 | - $price = $_REQUEST['bargain_price']; |
|
101 | - else if (isset($var['bargain_price'])) |
|
102 | - $price = $var['bargain_price']; |
|
103 | - else |
|
104 | - $price = 0; |
|
107 | + if (isset($_REQUEST['bargain_price'])) { |
|
108 | + $price = $_REQUEST['bargain_price']; |
|
109 | + } else if (isset($var['bargain_price'])) { |
|
110 | + $price = $var['bargain_price']; |
|
111 | + } else { |
|
112 | + $price = 0; |
|
113 | + } |
|
105 | 114 | |
106 | 115 | // only numbers |
107 | - if (!is_numeric($price)) |
|
108 | - create_error('You must actually enter a number!'); |
|
116 | + if (!is_numeric($price)) { |
|
117 | + create_error('You must actually enter a number!'); |
|
118 | + } |
|
109 | 119 | |
110 | 120 | // we take as it is but round it |
111 | 121 | $price = floor($price); |
112 | 122 | |
113 | 123 | // no negative amounts are allowed |
114 | - if ($price < 0) |
|
115 | - create_error('No negative prices are allowed!'); |
|
124 | + if ($price < 0) { |
|
125 | + create_error('No negative prices are allowed!'); |
|
126 | + } |
|
116 | 127 | |
117 | 128 | return $price; |
118 | 129 | } |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | public function nextRecord() { |
43 | - if(!$this->dbResult) |
|
44 | - $this->error('No resource to get record from.'); |
|
43 | + if(!$this->dbResult) { |
|
44 | + $this->error('No resource to get record from.'); |
|
45 | + } |
|
45 | 46 | |
46 | 47 | if($this->dbRecord = $this->dbResult->fetch_assoc()) { |
47 | 48 | return true; |
@@ -56,9 +57,10 @@ discard block |
||
56 | 57 | } |
57 | 58 | |
58 | 59 | public function getBoolean($name) { |
59 | - if($this->dbRecord[$name] == 'TRUE') |
|
60 | - return true; |
|
61 | -// if($this->dbRecord[$name] == 'FALSE') |
|
60 | + if($this->dbRecord[$name] == 'TRUE') { |
|
61 | + return true; |
|
62 | + } |
|
63 | + // if($this->dbRecord[$name] == 'FALSE') |
|
62 | 64 | return false; |
63 | 65 | // throw new Exception('Field is not a boolean'); |
64 | 66 | } |
@@ -91,8 +93,9 @@ discard block |
||
91 | 93 | |
92 | 94 | public function getObject($name,$compressed=false) { |
93 | 95 | $object = $this->getField($name); |
94 | - if($compressed===true) |
|
95 | - $object = gzuncompress($object); |
|
96 | + if($compressed===true) { |
|
97 | + $object = gzuncompress($object); |
|
98 | + } |
|
96 | 99 | return unserialize($object); |
97 | 100 | } |
98 | 101 | |
@@ -134,38 +137,43 @@ discard block |
||
134 | 137 | |
135 | 138 | public function escape($escape,$autoQuotes=true,$quotes=true) { |
136 | 139 | if(is_bool($escape)) { |
137 | - if($autoQuotes) |
|
138 | - return $this->escapeBoolean($escape); |
|
139 | - else |
|
140 | - return $this->escapeBoolean($escape,$quotes); |
|
140 | + if($autoQuotes) { |
|
141 | + return $this->escapeBoolean($escape); |
|
142 | + } else { |
|
143 | + return $this->escapeBoolean($escape,$quotes); |
|
144 | + } |
|
141 | 145 | } |
142 | 146 | if(is_numeric($escape)) { |
143 | 147 | return $this->escapeNumber($escape); |
144 | 148 | } |
145 | 149 | if(is_string($escape)) { |
146 | - if($autoQuotes) |
|
147 | - return $this->escapeString($escape); |
|
148 | - else |
|
149 | - return $this->escapeString($escape,$quotes); |
|
150 | + if($autoQuotes) { |
|
151 | + return $this->escapeString($escape); |
|
152 | + } else { |
|
153 | + return $this->escapeString($escape,$quotes); |
|
154 | + } |
|
150 | 155 | } |
151 | 156 | if(is_array($escape)) { |
152 | 157 | return $this->escapeArray($escape,$autoQuotes,$quotes); |
153 | 158 | } |
154 | 159 | if(is_object($escape)) { |
155 | - if($autoQuotes) |
|
156 | - return $this->escapeObject($escape); |
|
157 | - else |
|
158 | - return $this->escapeObject($escape,$quotes); |
|
160 | + if($autoQuotes) { |
|
161 | + return $this->escapeObject($escape); |
|
162 | + } else { |
|
163 | + return $this->escapeObject($escape,$quotes); |
|
164 | + } |
|
159 | 165 | } |
160 | 166 | } |
161 | 167 | |
162 | 168 | public function escapeString($string,$quotes=true,$nullable=false) { |
163 | - if($nullable===true && ($string===null || $string==='')) |
|
164 | - return 'NULL'; |
|
165 | - if($string===true) |
|
166 | - $string = 'TRUE'; |
|
167 | - else if($string===false) |
|
168 | - $string = 'FALSE'; |
|
169 | + if($nullable===true && ($string===null || $string==='')) { |
|
170 | + return 'NULL'; |
|
171 | + } |
|
172 | + if($string===true) { |
|
173 | + $string = 'TRUE'; |
|
174 | + } else if($string===false) { |
|
175 | + $string = 'FALSE'; |
|
176 | + } |
|
169 | 177 | if(is_array($string)) { |
170 | 178 | $escapedString = ''; |
171 | 179 | foreach($string as $value) { |
@@ -187,14 +195,14 @@ discard block |
||
187 | 195 | $string = ''; |
188 | 196 | if($escapeIndividually) { |
189 | 197 | foreach($array as $value) { |
190 | - if(is_array($value)) |
|
191 | - $string .= $this->escapeArray($value,$autoQuotes,$quotes,$implodeString,$escapeIndividually).$implodeString; |
|
192 | - else |
|
193 | - $string .= $this->escape($value, $autoQuotes, $quotes).$implodeString; |
|
198 | + if(is_array($value)) { |
|
199 | + $string .= $this->escapeArray($value,$autoQuotes,$quotes,$implodeString,$escapeIndividually).$implodeString; |
|
200 | + } else { |
|
201 | + $string .= $this->escape($value, $autoQuotes, $quotes).$implodeString; |
|
202 | + } |
|
194 | 203 | } |
195 | 204 | $string = substr($string,0,-1); |
196 | - } |
|
197 | - else { |
|
205 | + } else { |
|
198 | 206 | $string = $this->escape(implode($implodeString,$array), $autoQuotes, $quotes); |
199 | 207 | } |
200 | 208 | return $string; |
@@ -217,17 +225,20 @@ discard block |
||
217 | 225 | } |
218 | 226 | |
219 | 227 | public function escapeBoolean($bool,$quotes=true) { |
220 | - if($bool===true) |
|
221 | - return $this->escapeString('TRUE',$quotes); |
|
222 | - else if($bool===false) |
|
223 | - return $this->escapeString('FALSE',$quotes); |
|
224 | - else |
|
225 | - throw new Exception('Not a boolean!'); //TEST |
|
228 | + if($bool===true) { |
|
229 | + return $this->escapeString('TRUE',$quotes); |
|
230 | + } else if($bool===false) { |
|
231 | + return $this->escapeString('FALSE',$quotes); |
|
232 | + } else { |
|
233 | + throw new Exception('Not a boolean!'); |
|
234 | + } |
|
235 | + //TEST |
|
226 | 236 | } |
227 | 237 | |
228 | 238 | public function escapeObject($object,$compress=false,$quotes=true,$nullable=false) { |
229 | - if($compress===true) |
|
230 | - return $this->escapeBinary(gzcompress(serialize($object))); |
|
239 | + if($compress===true) { |
|
240 | + return $this->escapeBinary(gzcompress(serialize($object))); |
|
241 | + } |
|
231 | 242 | return $this->escapeString(serialize($object),$quotes,$nullable); |
232 | 243 | } |
233 | 244 |
@@ -74,8 +74,7 @@ discard block |
||
74 | 74 | $this->name = $db->getField('location_name'); |
75 | 75 | $this->processor = $db->getField('location_processor'); |
76 | 76 | $this->image = $db->getField('location_image'); |
77 | - } |
|
78 | - else { |
|
77 | + } else { |
|
79 | 78 | throw new Exception('Cannot find location: '.$locationTypeID); |
80 | 79 | } |
81 | 80 | } |
@@ -134,8 +133,7 @@ discard block |
||
134 | 133 | if($bool===true) { |
135 | 134 | $this->db->query('INSERT IGNORE INTO location_is_fed (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')'); |
136 | 135 | $this->fed = true; |
137 | - } |
|
138 | - else if($bool===false) { |
|
136 | + } else if($bool===false) { |
|
139 | 137 | $this->db->query('DELETE FROM location_is_fed WHERE ' . $this->SQL . ' LIMIT 1'); |
140 | 138 | $this->fed = false; |
141 | 139 | } |
@@ -150,13 +148,13 @@ discard block |
||
150 | 148 | } |
151 | 149 | |
152 | 150 | public function setBank($bool) { |
153 | - if($this->bank===$bool) |
|
154 | - return; |
|
151 | + if($this->bank===$bool) { |
|
152 | + return; |
|
153 | + } |
|
155 | 154 | if($bool===true) { |
156 | 155 | $this->db->query('INSERT INTO location_is_bank (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')'); |
157 | 156 | $this->bank = true; |
158 | - } |
|
159 | - else if($bool===false) { |
|
157 | + } else if($bool===false) { |
|
160 | 158 | $this->db->query('DELETE FROM location_is_bank WHERE ' . $this->SQL . ' LIMIT 1'); |
161 | 159 | $this->bank = false; |
162 | 160 | } |
@@ -171,13 +169,13 @@ discard block |
||
171 | 169 | } |
172 | 170 | |
173 | 171 | public function setBar($bool) { |
174 | - if($this->bar===$bool) |
|
175 | - return; |
|
172 | + if($this->bar===$bool) { |
|
173 | + return; |
|
174 | + } |
|
176 | 175 | if($bool===true) { |
177 | 176 | $this->db->query('INSERT IGNORE INTO location_is_bar (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')'); |
178 | 177 | $this->bar = true; |
179 | - } |
|
180 | - else if($bool===false) { |
|
178 | + } else if($bool===false) { |
|
181 | 179 | $this->db->query('DELETE FROM location_is_bar WHERE ' . $this->SQL . ' LIMIT 1'); |
182 | 180 | $this->bar = false; |
183 | 181 | } |
@@ -192,13 +190,13 @@ discard block |
||
192 | 190 | } |
193 | 191 | |
194 | 192 | public function setHQ($bool) { |
195 | - if($this->HQ===$bool) |
|
196 | - return; |
|
193 | + if($this->HQ===$bool) { |
|
194 | + return; |
|
195 | + } |
|
197 | 196 | if($bool===true) { |
198 | 197 | $this->db->query('INSERT IGNORE INTO location_is_hq (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')'); |
199 | 198 | $this->HQ = true; |
200 | - } |
|
201 | - else if($bool===false) { |
|
199 | + } else if($bool===false) { |
|
202 | 200 | $this->db->query('DELETE FROM location_is_hq WHERE ' . $this->SQL . ' LIMIT 1'); |
203 | 201 | $this->HQ = false; |
204 | 202 | } |
@@ -213,13 +211,13 @@ discard block |
||
213 | 211 | } |
214 | 212 | |
215 | 213 | public function setUG($bool) { |
216 | - if($this->UG===$bool) |
|
217 | - return; |
|
214 | + if($this->UG===$bool) { |
|
215 | + return; |
|
216 | + } |
|
218 | 217 | if($bool===true) { |
219 | 218 | $this->db->query('INSERT INTO location_is_ug (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')'); |
220 | 219 | $this->UG = true; |
221 | - } |
|
222 | - else if($bool===false) { |
|
220 | + } else if($bool===false) { |
|
223 | 221 | $this->db->query('DELETE FROM location_is_ug WHERE ' . $this->SQL . ' LIMIT 1'); |
224 | 222 | $this->UG = false; |
225 | 223 | } |
@@ -245,18 +243,21 @@ discard block |
||
245 | 243 | } |
246 | 244 | |
247 | 245 | public function addHardwareSold($hardwareTypeID) { |
248 | - if($this->isHardwareSold($hardwareTypeID)) |
|
249 | - return; |
|
246 | + if($this->isHardwareSold($hardwareTypeID)) { |
|
247 | + return; |
|
248 | + } |
|
250 | 249 | $this->db->query('SELECT * FROM hardware_type WHERE hardware_type_id = ' . $this->db->escapeNumber($hardwareTypeID) . ' LIMIT 1'); |
251 | - if(!$this->db->nextRecord()) |
|
252 | - throw new Exception('Invalid hardware type id given'); |
|
250 | + if(!$this->db->nextRecord()) { |
|
251 | + throw new Exception('Invalid hardware type id given'); |
|
252 | + } |
|
253 | 253 | $this->db->query('INSERT INTO location_sells_hardware (location_type_id,hardware_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ',' . $this->db->escapeNumber($hardwareTypeID) . ')'); |
254 | 254 | $this->hardwareSold[$hardwareTypeID] = $this->db->getField('hardware_name'); |
255 | 255 | } |
256 | 256 | |
257 | 257 | public function removeHardwareSold($hardwareTypeID) { |
258 | - if(!$this->isHardwareSold($hardwareTypeID)) |
|
259 | - return; |
|
258 | + if(!$this->isHardwareSold($hardwareTypeID)) { |
|
259 | + return; |
|
260 | + } |
|
260 | 261 | $this->db->query('DELETE FROM location_sells_hardware WHERE ' . $this->SQL . ' AND hardware_type_id = ' . $this->db->escapeNumber($hardwareTypeID) . ' LIMIT 1'); |
261 | 262 | unset($this->hardwareSold[$hardwareTypeID]); |
262 | 263 | } |
@@ -274,24 +275,28 @@ discard block |
||
274 | 275 | |
275 | 276 | public function isShipSold($shipTypeID=false) { |
276 | 277 | $ships = $this->getShipsSold(); |
277 | - if($shipTypeID===false) |
|
278 | - return count($ships)!=0; |
|
278 | + if($shipTypeID===false) { |
|
279 | + return count($ships)!=0; |
|
280 | + } |
|
279 | 281 | return isset($ships[$shipTypeID]); |
280 | 282 | } |
281 | 283 | |
282 | 284 | public function addShipSold($shipTypeID) { |
283 | - if($this->isShipSold($shipTypeID)) |
|
284 | - return; |
|
285 | + if($this->isShipSold($shipTypeID)) { |
|
286 | + return; |
|
287 | + } |
|
285 | 288 | $ship = AbstractSmrShip::getBaseShip(Globals::getGameType(SmrSession::getGameID()), $shipTypeID); |
286 | - if($ship===false) |
|
287 | - throw new Exception('Invalid ship type id given'); |
|
289 | + if($ship===false) { |
|
290 | + throw new Exception('Invalid ship type id given'); |
|
291 | + } |
|
288 | 292 | $this->db->query('INSERT INTO location_sells_ships (location_type_id,ship_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ',' . $this->db->escapeNumber($shipTypeID) . ')'); |
289 | 293 | $this->shipsSold[$shipTypeID] = $ship; |
290 | 294 | } |
291 | 295 | |
292 | 296 | public function removeShipSold($shipTypeID) { |
293 | - if(!$this->isShipSold($shipTypeID)) |
|
294 | - return; |
|
297 | + if(!$this->isShipSold($shipTypeID)) { |
|
298 | + return; |
|
299 | + } |
|
295 | 300 | $this->db->query('DELETE FROM location_sells_ships WHERE ' . $this->SQL . ' AND ship_type_id = ' . $this->db->escapeNumber($shipTypeID) . ' LIMIT 1'); |
296 | 301 | unset($this->shipsSold[$shipTypeID]); |
297 | 302 | } |
@@ -300,32 +305,37 @@ discard block |
||
300 | 305 | if(!isset($this->weaponsSold)) { |
301 | 306 | $this->weaponsSold = array(); |
302 | 307 | $this->db->query('SELECT * FROM location_sells_weapons JOIN weapon_type USING (weapon_type_id) WHERE ' . $this->SQL); |
303 | - while($this->db->nextRecord()) |
|
304 | - $this->weaponsSold[$this->db->getInt('weapon_type_id')] = SmrWeapon::getWeapon($this->db->getInt('weapon_type_id'), false, $this->db); |
|
308 | + while($this->db->nextRecord()) { |
|
309 | + $this->weaponsSold[$this->db->getInt('weapon_type_id')] = SmrWeapon::getWeapon($this->db->getInt('weapon_type_id'), false, $this->db); |
|
310 | + } |
|
305 | 311 | } |
306 | 312 | return $this->weaponsSold; |
307 | 313 | } |
308 | 314 | |
309 | 315 | public function isWeaponSold($weaponTypeID=false) { |
310 | 316 | $weapons = $this->getWeaponsSold(); |
311 | - if($weaponTypeID===false) |
|
312 | - return count($weapons)!=0; |
|
317 | + if($weaponTypeID===false) { |
|
318 | + return count($weapons)!=0; |
|
319 | + } |
|
313 | 320 | return isset($weapons[$weaponTypeID]); |
314 | 321 | } |
315 | 322 | |
316 | 323 | public function addWeaponSold($weaponTypeID) { |
317 | - if($this->isWeaponSold($weaponTypeID)) |
|
318 | - return; |
|
324 | + if($this->isWeaponSold($weaponTypeID)) { |
|
325 | + return; |
|
326 | + } |
|
319 | 327 | $weapon = SmrWeapon::getWeapon($weaponTypeID); |
320 | - if($weapon===false) |
|
321 | - throw new Exception('Invalid weapon type id given'); |
|
328 | + if($weapon===false) { |
|
329 | + throw new Exception('Invalid weapon type id given'); |
|
330 | + } |
|
322 | 331 | $this->db->query('INSERT INTO location_sells_weapons (location_type_id,weapon_type_id) values (' . $this->db->escapeNumber($this->getTypeID()). ',' . $this->db->escapeNumber($weaponTypeID) . ')'); |
323 | 332 | $this->weaponsSold[$weaponTypeID] = $weapon; |
324 | 333 | } |
325 | 334 | |
326 | 335 | public function removeWeaponSold($weaponTypeID) { |
327 | - if(!$this->isWeaponSold($weaponTypeID)) |
|
328 | - return; |
|
336 | + if(!$this->isWeaponSold($weaponTypeID)) { |
|
337 | + return; |
|
338 | + } |
|
329 | 339 | $this->db->query('DELETE FROM location_sells_weapons WHERE ' . $this->SQL . ' AND weapon_type_id = ' . $this->db->escapeNumber($weaponTypeID) . ' LIMIT 1'); |
330 | 340 | unset($this->weaponsSold[$weaponTypeID]); |
331 | 341 | } |
@@ -336,8 +346,7 @@ discard block |
||
336 | 346 | if($this->getTypeID()==LOCATION_TYPE_FEDERAL_HQ) { |
337 | 347 | $linkedLocations[] = SmrLocation::getLocation(LOCATION_TYPE_FEDERAL_BEACON); |
338 | 348 | $linkedLocations[] = SmrLocation::getLocation(LOCATION_TYPE_FEDERAL_MINT); |
339 | - } |
|
340 | - else { |
|
349 | + } else { |
|
341 | 350 | $raceID = $this->getRaceID(); |
342 | 351 | $linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_BEACONS+$raceID); |
343 | 352 | $linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_SHIPS+$raceID); |
@@ -100,8 +100,7 @@ discard block |
||
100 | 100 | $this->userID = $userInfo->getId(); |
101 | 101 | $this->email = $userInfo->getEmail(); |
102 | 102 | $this->valid = true; |
103 | - } |
|
104 | - else if($loginType == self::TWITTER) { |
|
103 | + } else if($loginType == self::TWITTER) { |
|
105 | 104 | if (session_status() === PHP_SESSION_NONE) { |
106 | 105 | session_start(); |
107 | 106 | } |
@@ -118,8 +117,7 @@ discard block |
||
118 | 117 | $this->email = $userInfo->email; |
119 | 118 | $this->valid = true; |
120 | 119 | } |
121 | - } |
|
122 | - else if($loginType == self::GOOGLE) { |
|
120 | + } else if($loginType == self::GOOGLE) { |
|
123 | 121 | if(self::getOpenIdObj()->validate()) { |
124 | 122 | if(strripos(self::getOpenIdObj()->identity, self::$OPEN_ID_IDENTITIES[$loginType]) === 0) { |
125 | 123 | $this->userID=self::getOpenIdObj()->identity; |