diff --git a/gatherling/action.php b/gatherling/action.php index 96303ba8..12add708 100644 --- a/gatherling/action.php +++ b/gatherling/action.php @@ -27,11 +27,11 @@ $message = "Your series $player_series doesn't have an upcoming event.
"; $nameMostRecent = $series->mostRecentEvent()->name; if (is_null($nameMostRecent) || $nameMostRecent == '') { - $createLink = 'event.php?mode=Create Next Event&name=' . $series->name . ' 1.00'; + $createLink = 'event.php?mode=Create Next Event&name='.$series->name.' 1.00'; } else { - $createLink = 'event.php?mode=Create Next Event&name=' . $nameMostRecent; + $createLink = 'event.php?mode=Create Next Event&name='.$nameMostRecent; } - $message = $message . "Create one or set the series as inactive."; + $message = $message."Create one or set the series as inactive."; } } $recent = $series->mostRecentEvent(); @@ -83,12 +83,12 @@ $message = "You have an unreported match in $event->name vs. "; if ($event->decklistsVisible()) { $opp_entry = Entry::findByEventAndPlayer($event->id, $oppplayer->name); - $message = $message . $oppplayer->linkTo($event->client) . ' (' . $opp_entry->deck->linkTo() . ').'; + $message = $message.$oppplayer->linkTo($event->client).' ('.$opp_entry->deck->linkTo().').'; } else { - $message = $message . $oppplayer->linkTo($event->client) . '.'; + $message = $message.$oppplayer->linkTo($event->client).'.'; } if ($match->player_reportable_check() == true) { - $message = $message . ' (Report Result)'; + $message = $message.' (Report Result)'; } } } elseif ($match->result != 'BYE' && $match->verification == 'failed') { @@ -101,8 +101,8 @@ $oppplayer = new Player($opp); if ($match->player_reportable_check() == true) { - $message = "The reported result wasn't consistent with your opponent's, please resubmit $event->name vs. " . $oppplayer->linkTo() . '.'; - $message = $message . '(Report Result)'; + $message = "The reported result wasn't consistent with your opponent's, please resubmit $event->name vs. ".$oppplayer->linkTo().'.'; + $message = $message.'(Report Result)'; } else { $message = "You have an unreported match in $match->eventname."; } diff --git a/gatherling/admin/clean_decks.php b/gatherling/admin/clean_decks.php index 72bf4f4f..ee2295e0 100644 --- a/gatherling/admin/clean_decks.php +++ b/gatherling/admin/clean_decks.php @@ -28,7 +28,7 @@ if ($deck != null || $deck->id != 0) { if ($deck->playername == null) { $totalHangingDecks++; - echo '' . $deck->name . ' Deck ID: ' . $deck->id . " is a hanging deck and will be deleted.
\n"; + echo ''.$deck->name.' Deck ID: '.$deck->id." is a hanging deck and will be deleted.
\n"; $deck->delete(); } } diff --git a/gatherling/admin/db-upgrade.php b/gatherling/admin/db-upgrade.php index b4f90079..1e3c7cf3 100644 --- a/gatherling/admin/db-upgrade.php +++ b/gatherling/admin/db-upgrade.php @@ -13,7 +13,7 @@ // If this fails with foreign key errors, execute `ALTER SCHEMA DEFAULT CHARACTER SET latin1;` -require_once __DIR__ . '/../lib.php'; +require_once __DIR__.'/../lib.php'; // Try to connect multiple times in case the MySQL container is still starting up in the test environment. $db = null; @@ -90,14 +90,14 @@ function upgrade_db($new_version, $text, $func) function redirect_deck_update($latest_id = 0) { $url = explode('?', $_SERVER['REQUEST_URI']); - $url = $url[0] . '?deckupdate=' . $latest_id; + $url = $url[0].'?deckupdate='.$latest_id; echo "Continue"; echo ""; exit(0); } if (isset($_GET['deckupdate'])) { - $deckquery = do_query('SELECT id FROM decks WHERE id > ' . intval($_GET['deckupdate'])); + $deckquery = do_query('SELECT id FROM decks WHERE id > '.intval($_GET['deckupdate'])); $timestart = time(); while ($deckid = $deckquery->fetch_array()) { flush(); diff --git a/gatherling/admin/infobot.php b/gatherling/admin/infobot.php index 3c0cf9bd..c2e8de0b 100644 --- a/gatherling/admin/infobot.php +++ b/gatherling/admin/infobot.php @@ -2,7 +2,7 @@ use Gatherling\Player; -require_once __DIR__ . '/../lib.php'; +require_once __DIR__.'/../lib.php'; if (strncmp($_SERVER['HTTP_USER_AGENT'], 'infobot', 7) != 0) { exit("You're not infobot!"); diff --git a/gatherling/admin/removeDecks.php b/gatherling/admin/removeDecks.php index dea41719..e4809e79 100644 --- a/gatherling/admin/removeDecks.php +++ b/gatherling/admin/removeDecks.php @@ -19,7 +19,7 @@ if ($deck != null || $deck->id != 0) { if ($deck->playername == null) { $totalHangingDecks++; - echo '' . $deck->name . ' Deck ID: ' . $deck->id . " is a hanging deck and will be deleted.
\n"; + echo ''.$deck->name.' Deck ID: '.$deck->id." is a hanging deck and will be deleted.
\n"; $deck->delete(); } } diff --git a/gatherling/admin/updateDecks.php b/gatherling/admin/updateDecks.php index ac0f7b92..bdcbe856 100644 --- a/gatherling/admin/updateDecks.php +++ b/gatherling/admin/updateDecks.php @@ -32,14 +32,14 @@ if ($result2) { $db = Database::getConnection(); $stmt = $db->prepare('UPDATE decks SET playername = ?, format = ?, deck_colors = ?, created_date = ? WHERE id = ?'); - echo 'Playername: ' . $deck->playername . '
Format: ' . $deck->format . '
Color String: ' . $deck->deck_color_str . "
\n"; + echo 'Playername: '.$deck->playername.'
Format: '.$deck->format.'
Color String: '.$deck->deck_color_str."
\n"; $stmt->bind_param('ssssd', $deck->playername, $deck->format, $deck->deck_color_str, $deck->created_date, $deck->id); $stmt->execute() or exit($stmt->error); - echo '' . $deck->name . ' Deck ID: ' . $deck->id . ' Sucessfully updated
'; + echo ''.$deck->name.' Deck ID: '.$deck->id.' Sucessfully updated
'; $successUpdatedDecks++; //if ($decksChecked > 10) { die; } } else { - echo $deck->id . ' Has no data in entries, missing playername, no player association. Deck will be deleted
'; + echo $deck->id.' Has no data in entries, missing playername, no player association. Deck will be deleted
'; $failedUpdatedDecks++; $deck->delete(); } diff --git a/gatherling/authdebug.php b/gatherling/authdebug.php index 2eb6ad7a..3594fd79 100644 --- a/gatherling/authdebug.php +++ b/gatherling/authdebug.php @@ -1,7 +1,7 @@ ['identify', 'email']]; $authUrl = $provider->getAuthorizationUrl($options); $_SESSION['oauth2state'] = $provider->getState(); - header('Location: ' . $authUrl); + header('Location: '.$authUrl); } function store_token($token) diff --git a/gatherling/authlib.php b/gatherling/authlib.php index c017803e..a1dc8b42 100644 --- a/gatherling/authlib.php +++ b/gatherling/authlib.php @@ -1,13 +1,13 @@ $CONFIG['DISCORD_CLIENT_ID'], 'clientSecret' => $CONFIG['DISCORD_CLIENT_SECRET'], - 'redirectUri' => $CONFIG['base_url'] . 'auth.php', + 'redirectUri' => $CONFIG['base_url'].'auth.php', ]); function load_cached_token() @@ -24,7 +24,7 @@ function get_user_guilds($token) { global $provider; - $guildsRequest = $provider->getAuthenticatedRequest('GET', $provider->getResourceOwnerDetailsUrl($token) . '/guilds', $token); + $guildsRequest = $provider->getAuthenticatedRequest('GET', $provider->getResourceOwnerDetailsUrl($token).'/guilds', $token); return $provider->getParsedResponse($guildsRequest); } @@ -33,10 +33,10 @@ function debug_info($token) { // Show some token details echo '

Token details:

'; - echo 'Token: ' . $token->getToken() . '
'; - echo 'Refresh token: ' . $token->getRefreshToken() . '
'; - echo 'Expires: ' . $token->getExpires() . ' - '; - echo($token->hasExpired() ? 'expired' : 'not expired') . '
'; + echo 'Token: '.$token->getToken().'
'; + echo 'Refresh token: '.$token->getRefreshToken().'
'; + echo 'Expires: '.$token->getExpires().' - '; + echo($token->hasExpired() ? 'expired' : 'not expired').'
'; echo 'Values:
'; foreach ($token->getValues() as $key => $value) { echo "$key=$value
"; diff --git a/gatherling/bootstrap.php b/gatherling/bootstrap.php index 7063c6bf..e16a324a 100644 --- a/gatherling/bootstrap.php +++ b/gatherling/bootstrap.php @@ -10,12 +10,12 @@ function autoload($class_name) $names = explode('\\', $class_name); if ($names[0] == 'Gatherling') { $class_name = $names[1]; - if (file_exists('models/' . $class_name . '.php')) { - require_once 'models/' . $class_name . '.php'; - } elseif (file_exists('../models/' . $class_name . '.php')) { - require_once '../models/' . $class_name . '.php'; - } elseif (file_exists('gatherling/models/' . $class_name . '.php')) { - require_once 'gatherling/models/' . $class_name . '.php'; + if (file_exists('models/'.$class_name.'.php')) { + require_once 'models/'.$class_name.'.php'; + } elseif (file_exists('../models/'.$class_name.'.php')) { + require_once '../models/'.$class_name.'.php'; + } elseif (file_exists('gatherling/models/'.$class_name.'.php')) { + require_once 'gatherling/models/'.$class_name.'.php'; } } } @@ -23,13 +23,13 @@ function autoload($class_name) spl_autoload_register('autoload'); // Fix for MAGIC_QUOTES_GPC -if (file_exists(__DIR__ . '/vendor/autoload.php')) { - include_once __DIR__ . '/vendor/autoload.php'; +if (file_exists(__DIR__.'/vendor/autoload.php')) { + include_once __DIR__.'/vendor/autoload.php'; } else { - include_once __DIR__ . '/../vendor/autoload.php'; + include_once __DIR__.'/../vendor/autoload.php'; } -if (file_exists(__DIR__ . '/config.php')) { +if (file_exists(__DIR__.'/config.php')) { require_once 'config.php'; } else { $CONFIG = $_ENV; diff --git a/gatherling/deckdl.php b/gatherling/deckdl.php index c28be0be..afccc0bb 100644 --- a/gatherling/deckdl.php +++ b/gatherling/deckdl.php @@ -30,17 +30,17 @@ foreach ($deck->maindeck_cards as $card => $qty) { // Æ to AE litigation $card = normaliseCardName($card); - $content .= $qty . ' ' . $card . "\r\n"; + $content .= $qty.' '.$card."\r\n"; } $content .= "\r\nSideboard\r\n"; foreach ($deck->sideboard_cards as $card => $qty) { $card = normaliseCardName($card); - $content .= $qty . ' ' . $card . "\r\n"; + $content .= $qty.' '.$card."\r\n"; } -$filename = preg_replace('/ /', '_', $deck->name) . '.txt'; +$filename = preg_replace('/ /', '_', $deck->name).'.txt'; header('Content-type: text/plain'); header("Content-Disposition: attachment; filename=$filename"); echo $content; diff --git a/gatherling/email.php b/gatherling/email.php index 9ac88f5c..37914711 100644 --- a/gatherling/email.php +++ b/gatherling/email.php @@ -21,7 +21,7 @@ function sendEmail($to, $subj, $msg): bool $headers = []; $headers[] = 'Accept: application/json'; - $headers[] = 'Api-Key: ' . $CONFIG['brevo_api_key']; + $headers[] = 'Api-Key: '.$CONFIG['brevo_api_key']; $headers[] = 'Content-Type: application/json'; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); diff --git a/gatherling/event.php b/gatherling/event.php index 640422a6..60199458 100644 --- a/gatherling/event.php +++ b/gatherling/event.php @@ -164,7 +164,7 @@ function content() $newevent->number = $oldevent->number + 1; $newevent->format = $oldevent->format; - $newevent->start = strftime('%Y-%m-%d %H:%M:00', strtotime($oldevent->start) + (86400 * 7)); + $newevent->start = date('Y-m-d H:i:00', strtotime($oldevent->start) + (86400 * 7)); $newevent->kvalue = $oldevent->kvalue; $newevent->finalized = 0; $newevent->prereg_allowed = $oldevent->prereg_allowed; @@ -219,7 +219,7 @@ function content() $newevent->number = 1; $newevent->format = $oldevent->format; - $newevent->start = strftime('%Y-%m-%d %H:%M:00', strtotime($oldevent->start) + (86400 * 7)); + $newevent->start = date('Y-m-d H:i:00', strtotime($oldevent->start) + (86400 * 7)); $newevent->kvalue = $oldevent->kvalue; $newevent->finalized = 0; $newevent->prereg_allowed = $oldevent->prereg_allowed; @@ -529,11 +529,11 @@ function eventForm(Event $event = null, bool $forcenew = false) $hour = $datearr[4]; $minutes = $datearr[5]; } else { - $year = strftime('Y', time()); - $month = strftime('B', time()); - $day = strftime('Y', time()); - $hour = strftime('H', time()); - $minutes = strftime('M', time()); + $year = date('Y', time()); + $month = date('n', time()); + $day = date('j', time()); + $hour = date('H', time()); + $minutes = date('i', time()); } if ($edit) { diff --git a/gatherling/index.php b/gatherling/index.php index 308d2f06..cf95ca78 100644 --- a/gatherling/index.php +++ b/gatherling/index.php @@ -7,59 +7,47 @@ use Gatherling\Player; include 'lib.php'; -$version = Database::single_result('SELECT version FROM db_version LIMIT 1'); -if ($version < 51) { - require 'outofservice.php'; - return; -} - -print_header('Home'); ?> - -
-
Gatherling
-

Welcome to Gatherling! The place for player-run Magic Online tournaments. Report bugs or give feedback on the Discord.

-
- -
- -
-
Active Events
- -
- -
-
Upcoming Events
- -
- -
-
Gatherling Statistics
- -
- -
- -
-
- -
-
-
Recent Winners
- -
- -
- -
- +
+
Gatherling
+

Welcome to Gatherling! The place for player-run Magic Online tournaments. Report bugs or give feedback on the Discord.

+
+
+
+
Active Events
+ +
+
+
Upcoming Events
+ +
+
+
Gatherling Statistics
+ +
+
+
+
+ +
+
+
Recent Winners
+ +
+
+
+ {$name}"; ?> - - - Round + +
+ + + Round
- + '; $result->close(); } + +if (basename(__FILE__) == basename($_SERVER['PHP_SELF'])) { + main(); +} diff --git a/gatherling/lib.php b/gatherling/lib.php index f6b30dc9..044a107c 100644 --- a/gatherling/lib.php +++ b/gatherling/lib.php @@ -32,6 +32,7 @@ function page($title, $contents): string print_header($title); echo $contents; print_footer(); + return ob_get_clean(); } @@ -47,18 +48,18 @@ function theme_file($name) { global $CONFIG; if (Player::isLoggedIn()) { - $user_dir = 'styles/' . Player::getSessionPlayer()->theme . '/'; - if (file_exists($user_dir . $name)) { - return $user_dir . $name; + $user_dir = 'styles/'.Player::getSessionPlayer()->theme.'/'; + if (file_exists($user_dir.$name)) { + return $user_dir.$name; } } $theme_dir = "styles/{$CONFIG['style']}/"; $default_dir = 'styles/Chandra/'; - if (file_exists($theme_dir . $name)) { - return $theme_dir . $name; + if (file_exists($theme_dir.$name)) { + return $theme_dir.$name; } - return $default_dir . $name; + return $default_dir.$name; } function print_header($title, $enable_vue = false, $js = null, $extra_head_content = '') @@ -75,7 +76,7 @@ function print_header($title, $enable_vue = false, $js = null, $extra_head_conte echo " \n"; echo " \n"; echo " {$CONFIG['site_name']} | {$title}\n"; - echo ' \n"; + echo ' \n"; echo " \n"; echo " \n"; if ($enable_vue) { @@ -240,7 +241,7 @@ function image_tag($filename, $extra_attr = null) $tag .= "{$key}=\"{$value}\" "; } } - $tag .= 'src="' . theme_file("images/{$filename}") . '" />'; + $tag .= 'src="'.theme_file("images/{$filename}").'" />'; return $tag; } @@ -386,7 +387,7 @@ function json_headers() header('Cache-Control: no-cache'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Access-Control-Allow-Origin: *'); - header('HTTP_X_USERNAME: ' . Player::loginName()); + header('HTTP_X_USERNAME: '.Player::loginName()); } function not_allowed($reason) diff --git a/gatherling/models/Database.php b/gatherling/models/Database.php index e9b07f1f..9818e3f0 100644 --- a/gatherling/models/Database.php +++ b/gatherling/models/Database.php @@ -42,7 +42,7 @@ public static function getConnection() self::single_result($sql); $db_selected = $instance->select_db($CONFIG['db_database']); if (!$db_selected) { - exit('Error creating database: ' . mysqli_error($instance) . "\n"); + exit('Error creating database: '.mysqli_error($instance)."\n"); } } @@ -60,7 +60,7 @@ public static function getPDOConnection() if (!isset($pdo_instance)) { global $CONFIG; $pdo_instance = new PDO( - 'mysql:hostname=' . $CONFIG['db_hostname'] . ';port=3306;dbname=' . $CONFIG['db_database'], + 'mysql:hostname='.$CONFIG['db_hostname'].';port=3306;dbname='.$CONFIG['db_database'], $CONFIG['db_username'], $CONFIG['db_password'] ); diff --git a/gatherling/models/Deck.php b/gatherling/models/Deck.php index 346982dc..e888f00f 100644 --- a/gatherling/models/Deck.php +++ b/gatherling/models/Deck.php @@ -218,7 +218,7 @@ public function getColorImages() $str = ''; foreach ($count as $color => $n) { if ($n > 0) { - $str = $str . image_tag("mana{$color}.png"); + $str = $str.image_tag("mana{$color}.png"); } } @@ -623,7 +623,7 @@ public function save() $db->rollback(); $db->autocommit(true); - throw new Exception('Entry for ' . $this->playername . ' in ' . $this->eventname . ' not found'); + throw new Exception('Entry for '.$this->playername.' in '.$this->eventname.' not found'); } } else { $stmt = $db->prepare('UPDATE decks SET archetype = ?, name = ?, format = ?, tribe = ?, deck_colors = ?, notes = ? WHERE id = ?'); @@ -635,7 +635,7 @@ public function save() $db->rollback(); $db->autocommit(true); - throw new Exception('Can\'t update deck ' . $this->id); + throw new Exception('Can\'t update deck '.$this->id); } $format = new Format($this->format); } @@ -873,7 +873,7 @@ public function save() $db->rollback(); $db->autocommit(true); - throw new Exception('Can\'t update deck ' . $this->id); + throw new Exception('Can\'t update deck '.$this->id); } $this->deck_contents_cache = implode('|', array_merge( @@ -932,9 +932,9 @@ public function save() // Autonamer Function if ($this->name == 'Temp') { if ($format->tribal) { - $this->name = strtoupper($this->deck_color_str) . ' ' . $this->tribe; + $this->name = strtoupper($this->deck_color_str).' '.$this->tribe; } else { - $this->name = strtoupper($this->deck_color_str) . ' ' . $this->archetype; + $this->name = strtoupper($this->deck_color_str).' '.$this->archetype; } $stmt = $db->prepare('UPDATE decks set name = ? WHERE id = ?'); $stmt->bind_param('ss', $this->name, $this->id); @@ -1005,17 +1005,17 @@ public function calculateHashes() sort($cards, SORT_STRING); $maindeckStr = ''; foreach ($cards as $cardname) { - $maindeckStr .= $this->maindeck_cards[$cardname] . $cardname; + $maindeckStr .= $this->maindeck_cards[$cardname].$cardname; } $this->deck_hash = sha1($maindeckStr); $sideboardStr = ''; $cards = array_keys($this->sideboard_cards); sort($cards, SORT_STRING); foreach ($cards as $cardname) { - $sideboardStr .= $this->sideboard_cards[$cardname] . $cardname; + $sideboardStr .= $this->sideboard_cards[$cardname].$cardname; } $this->sideboard_hash = sha1($sideboardStr); - $this->whole_hash = sha1($maindeckStr . '' . $sideboardStr); + $this->whole_hash = sha1($maindeckStr.''.$sideboardStr); $db = Database::getConnection(); $stmt = $db->prepare('UPDATE decks SET sideboard_hash = ?, deck_hash = ?, whole_hash = ? where id = ?'); $stmt->bind_param('sssd', $this->sideboard_hash, $this->deck_hash, $this->whole_hash, $this->id); diff --git a/gatherling/models/Decksearch.php b/gatherling/models/Decksearch.php index cc7dafaa..87981a99 100644 --- a/gatherling/models/Decksearch.php +++ b/gatherling/models/Decksearch.php @@ -111,7 +111,7 @@ public function searchByFormat($format) public function searchByPlayer($player) { $sql = 'SELECT id FROM decks WHERE playername LIKE ?'; - $results = Database::list_result_single_param($sql, 's', '%' . $player . '%'); + $results = Database::list_result_single_param($sql, 's', '%'.$player.'%'); if (count($results) > 0) { $this->_results['player'] = $results; } else { @@ -240,7 +240,7 @@ public function idsToSortedInfo($id_arr) //sanitize the id_arr to protect against sql injection. $id_arr = array_filter(array_map('intval', $id_arr)); - $query = 'SELECT id, archetype, name, playername, format, created_date from decks WHERE id IN (' . implode(',', $id_arr) . ') ORDER BY DATE(`created_date`) DESC'; + $query = 'SELECT id, archetype, name, playername, format, created_date from decks WHERE id IN ('.implode(',', $id_arr).') ORDER BY DATE(`created_date`) DESC'; $stmt = $db->prepare($query); $stmt->execute(); $stmt->bind_result($id, $archetype, $name, $playername, $format, $created_date); @@ -327,9 +327,9 @@ private function _recordString() } if ($draws == 0) { - return $wins . '-' . $losses; + return $wins.'-'.$losses; } else { - return $wins . '-' . $losses . '-' . $draws; + return $wins.'-'.$losses.'-'.$draws; } } } diff --git a/gatherling/models/Entry.php b/gatherling/models/Entry.php index 273f935c..7cde29c1 100644 --- a/gatherling/models/Entry.php +++ b/gatherling/models/Entry.php @@ -93,7 +93,7 @@ public function __construct($event_id, $playername) $stmt->bind_result($deckid, $this->medal, $this->ignored, $this->drop_round, $this->initial_byes, $this->initial_seed); if ($stmt->fetch() == null) { - throw new Exception('Entry for ' . $playername . ' in ' . $event_id . ' not found'); + throw new Exception('Entry for '.$playername.' in '.$event_id.' not found'); } $stmt->close(); @@ -128,9 +128,9 @@ public function recordString() } if ($draws == 0) { - return $wins . '-' . $losses; + return $wins.'-'.$losses; } else { - return $wins . '-' . $losses . '-' . $draws; + return $wins.'-'.$losses.'-'.$draws; } } @@ -203,9 +203,9 @@ public function removeEntry() public function createDeckLink() { - // creates a link to enter a deck list once a player is registered for the event + // creates a link to enter a deck list once a player is registered for the event if ($this->canCreateDeck(Player::loginName())) { - return '[Create Deck]'; + return '[Create Deck]'; } else { return '(no deck entered)'; } @@ -227,7 +227,7 @@ public function setInitialByes($byeqty) $db->rollback(); $db->autocommit(true); - throw new Exception('Entry for ' . $this->player->name . ' in ' . $this->event->name . ' not found'); + throw new Exception('Entry for '.$this->player->name.' in '.$this->event->name.' not found'); } $db->commit(); $db->autocommit(true); @@ -244,7 +244,7 @@ public function setInitialSeed($byeqty) $db->rollback(); $db->autocommit(true); - throw new Exception('Entry for ' . $this->player->name . ' in ' . $this->event->name . ' not found'); + throw new Exception('Entry for '.$this->player->name.' in '.$this->event->name.' not found'); } $db->commit(); $db->autocommit(true); diff --git a/gatherling/models/Event.php b/gatherling/models/Event.php index 22598516..b0a4a518 100644 --- a/gatherling/models/Event.php +++ b/gatherling/models/Event.php @@ -137,7 +137,7 @@ public function __construct($name) $this->client ); if ($stmt->fetch() == null) { - throw new Exception('Event ' . $name . ' not found in DB'); + throw new Exception('Event '.$name.' not found in DB'); } } @@ -496,7 +496,7 @@ public function setFinalists($win, $sec, $t4 = null, $t8 = null) public function getTrophyImageLink() { return "id}\" class=\"borderless\">\n" - . self::trophy_image_tag($this->name) . "\n\n"; + .self::trophy_image_tag($this->name)."\n\n"; } /** @@ -1048,7 +1048,7 @@ public function findNext() public function makeLink($text) { - return '{$text}"; + return '{$text}"; } public function linkTo() @@ -1058,7 +1058,7 @@ public function linkTo() public function linkReport() { - return '{$this->name}"; + return '{$this->name}"; } public static function count() @@ -1356,8 +1356,8 @@ private function getByeProxyName() { $byeNum = 0; while (true) { - if (is_null(Player::findByName('BYE' . $byeNum))) { - return 'BYE' . $byeNum; + if (is_null(Player::findByName('BYE'.$byeNum))) { + return 'BYE'.$byeNum; } $byeNum++; } @@ -1893,7 +1893,7 @@ function to_english($structure, $rounds, $isfinals) $ret = to_english($this->mainstruct, $this->mainrounds, false); if ($this->finalrounds > 0) { - $ret = $ret . ' followed by ' . to_english($this->finalstruct, $this->finalrounds, true); + $ret = $ret.' followed by '.to_english($this->finalstruct, $this->finalrounds, true); } return $ret; diff --git a/gatherling/models/Format.php b/gatherling/models/Format.php index 8043424c..000920b3 100644 --- a/gatherling/models/Format.php +++ b/gatherling/models/Format.php @@ -136,7 +136,7 @@ public function __construct($name) $this->is_meta_format ); if ($stmt->fetch() == null) { - throw new Exception('Format ' . $name . ' not found in DB'); + throw new Exception('Format '.$name.' not found in DB'); } $stmt->close(); $this->card_banlist = $this->getBanList(); @@ -1508,7 +1508,7 @@ public static function getCardNameFromPartialDFC($cardname) { // this is used to return the name of the card as it appears in the database // otherwise the ban list will have cards on it like rOnCoR, RONCOR, rONCOR, etc - return Database::single_result_single_param('SELECT name FROM cards WHERE name LIKE ?', 's', $cardname . '/%'); + return Database::single_result_single_param('SELECT name FROM cards WHERE name LIKE ?', 's', $cardname.'/%'); } public function insertNewLegalSet($cardsetName) diff --git a/gatherling/models/MaxWeightMatching.php b/gatherling/models/MaxWeightMatching.php index 087e53cc..fb79c109 100644 --- a/gatherling/models/MaxWeightMatching.php +++ b/gatherling/models/MaxWeightMatching.php @@ -57,7 +57,7 @@ public function __construct($edges, $maxcardinality = false) $this->endpoint = []; $arrayRange = range(0, 2 * $this->nedge - 1); - foreach ($arrayRange as $p) { // BAKERT range is one higher in python so -1 here and everywhere else we use range(). + foreach ($arrayRange as $p) { $this->endpoint[] = $this->edges[$this->floorintdiv($p, 2)][$p % 2]; } @@ -120,7 +120,7 @@ public function assignLabel($w, $t, $p) } $b = $this->inblossom[$w]; assert($this->label[$w] == 0 && $this->label[$b] == 0); - $this->label[$w] = $this->label[$b] = $t; // BAKERT issue ??? + $this->label[$w] = $this->label[$b] = $t; $this->labelend[$w] = $this->labelend[$b] = $p; $this->bestedge[$w] = $this->bestedge[$b] = -1; if ($t == 1) { @@ -274,7 +274,7 @@ public function addBlossom($base, $k) } } if ($DEBUG) { - $DEBUG("blossomchilds[$b]=" . $this->arr_repr($this->blossomchilds[$b])); + $DEBUG("blossomchilds[$b]=".$this->arr_repr($this->blossomchilds[$b])); } } @@ -282,7 +282,7 @@ public function expandBlossom($b, $endstage) { global $DEBUG; if ($DEBUG) { - $DEBUG("expandBlossom($b,$endstage) " . $this->arr_repr($this->blossomchilds[$b])); + $DEBUG("expandBlossom($b,$endstage) ".$this->arr_repr($this->blossomchilds[$b])); } foreach ($this->blossomchilds[$b] as $s) { $this->blossomparent[$s] = -1; @@ -396,7 +396,7 @@ public function augmentBlossom($b, $v) $this->mate[$this->endpoint[$p]] = $p ^ 1; $this->mate[$this->endpoint[$p ^ 1]] = $p; if ($DEBUG) { - $DEBUG('PAIR(a) ' . $this->endpoint[$p] . ' ' . $this->endpoint[$p ^ 1] . ' (k=' . $this->floorintdiv($p, 2) . ')'); + $DEBUG('PAIR(a) '.$this->endpoint[$p].' '.$this->endpoint[$p ^ 1].' (k='.$this->floorintdiv($p, 2).')'); } } $this->blossomchilds[$b] = array_merge(array_slice($this->blossomchilds[$b], $i), array_slice($this->blossomchilds[$b], 0, $i)); @@ -441,7 +441,7 @@ public function augmentMatching($k) $this->mate[$j] = $this->labelend[$bt]; $p = $this->labelend[$bt] ^ 1; if ($DEBUG) { - $DEBUG("PAIR(c) $s $t (k=" . $this->floorintdiv($p, 2) . ')'); + $DEBUG("PAIR(c) $s $t (k=".$this->floorintdiv($p, 2).')'); } } } @@ -520,7 +520,7 @@ public function checkDelta2() } } if ($DEBUG && ($this->bestedge[$v] != -1 || $bk != -1) && ($this->bestedge[$v] == -1 || $bd != $this->slack($this->bestedge[$v]))) { - $DEBUG('v=' . $v . ' bk=' . $bk . ' bd=' . $bd . ' $this->bestedge[$v]=' . $this->bestedge[$v] . ' slack=' . $this->slack($this->bestedge[$v])); + $DEBUG('v='.$v.' bk='.$bk.' bd='.$bd.' $this->bestedge[$v]='.$this->bestedge[$v].' slack='.$this->slack($this->bestedge[$v])); } assert(($bk == -1 && $this->bestedge[$v] == -1) || ($this->bestedge[$v] != -1 && $bd == $this->slack($this->bestedge[$v]))); } @@ -563,7 +563,7 @@ public function checkDelta3() } } if ($DEBUG && $bd != $tbd) { - $DEBUG("bk=$bk tbk=$tbk bd=" . $this->arr_repr($bd) . ' tbd=' . $this->arr_repr($tbd)); + $DEBUG("bk=$bk tbk=$tbk bd=".$this->arr_repr($bd).' tbd='.$this->arr_repr($tbd)); } assert($bd == $tbd); } @@ -605,12 +605,12 @@ public function arr_repr($arr) } } - return rtrim($s, ', ') . ']'; + return rtrim($s, ', ').']'; } public function print_arr($arr) { - echo $this->arr_repr($arr) . "\n"; + echo $this->arr_repr($arr)."\n"; } public function main() @@ -737,7 +737,7 @@ public function main() assert(($kslack % 2) == 0); $d = $this->floorintdiv($kslack, 2); } else { - $d = $kslack / 2; // ORIGINALLY SINGLE SLASH DIVISION IN PYTHON SO NOT CONVERTED TO INTDIV BAKERT + $d = $kslack / 2; // ORIGINALLY SINGLE SLASH DIVISION IN PYTHON SO NOT CONVERTED TO INTDIV } if ($deltatype == -1 || $d < $delta) { $delta = $d; diff --git a/gatherling/models/Player.php b/gatherling/models/Player.php index 1b05bfe7..0cf2b8de 100644 --- a/gatherling/models/Player.php +++ b/gatherling/models/Player.php @@ -61,7 +61,7 @@ public function __construct($name) $this->mtgo_username ); if ($stmt->fetch() == null) { - throw new Exception('Player ' . $name . ' is not found.'); + throw new Exception('Player '.$name.' is not found.'); } $stmt->close(); } @@ -851,7 +851,7 @@ public function getRatingRecord($format = 'Composite', $date = '3000-01-01 00:00 $stmt->fetch(); $stmt->close(); - return $wins . '-' . $losses; + return $wins.'-'.$losses; } public function getMaxRating($format = 'Composite') @@ -912,9 +912,9 @@ public function getRecord() } if ($draws == 0) { - return $wins . '-' . $losses; + return $wins.'-'.$losses; } else { - return $wins . '-' . $losses . '-' . $draws; + return $wins.'-'.$losses.'-'.$draws; } } @@ -940,9 +940,9 @@ public function getRecordVs($opponent) } if ($draws == 0) { - return $wins . '-' . $losses; + return $wins.'-'.$losses; } else { - return $wins . '-' . $losses . '-' . $draws; + return $wins.'-'.$losses.'-'.$draws; } } @@ -1382,13 +1382,13 @@ public function gameName($game = null, $html = true) $name = $this->name; if ($game == 'mtgo' && !empty($this->mtgo_username)) { - $name = ' ' . $this->mtgo_username; + $name = ' '.$this->mtgo_username; } elseif ($game == 'arena' && !empty($this->mtga_username)) { - $name = ' ' . $this->mtga_username; + $name = ' '.$this->mtga_username; } elseif ($game == 'paper' && !empty($this->discord_handle)) { - $name = ' ' . $this->discord_handle; + $name = ' '.$this->discord_handle; } elseif ($game == 'gatherling') { - $name = ' ' . $this->name; + $name = ' '.$this->name; } return $name; diff --git a/gatherling/models/Ratings.php b/gatherling/models/Ratings.php index 918981d3..e0716b85 100644 --- a/gatherling/models/Ratings.php +++ b/gatherling/models/Ratings.php @@ -94,7 +94,7 @@ public function calcCompositeRating() public function calcRatingByFormat($format) { $db = Database::getConnection(); - $searchString = '%' . $format . '%'; + $searchString = '%'.$format.'%'; $stmt = $db->prepare("SELECT name, start FROM events WHERE finalized = '1' AND format LIKE ? ORDER BY start"); $stmt->bind_param('s', $searchString); @@ -128,7 +128,7 @@ public function calcOtherRating() $notlike = ''; foreach ($this->ratingNames as $format) { - $notlike = $notlike . ' AND format NOT LIKE "%' . $format . '%" '; + $notlike = $notlike.' AND format NOT LIKE "%'.$format.'%" '; } $result = $db->query("SELECT name, start diff --git a/gatherling/models/Series.php b/gatherling/models/Series.php index 277c23f5..a32ba218 100644 --- a/gatherling/models/Series.php +++ b/gatherling/models/Series.php @@ -66,7 +66,7 @@ public function __construct($name) $this->discord_require_membership ); if ($stmt->fetch() == null) { - throw new Exception('Series ' . $name . ' not found in DB'); + throw new Exception('Series '.$name.' not found in DB'); } $stmt->close(); @@ -945,7 +945,7 @@ public static function seasonStandings($series, $season) foreach ($seasonevents as $evname) { $shortname = preg_replace("/^{$series->name} /", '', $evname); - $reportlink = 'eventreport.php?event=' . urlencode($evname); + $reportlink = 'eventreport.php?event='.urlencode($evname); echo "{$shortname}"; } echo ''; diff --git a/gatherling/models/SetScraper.php b/gatherling/models/SetScraper.php index 68b4407b..58ca6c0f 100644 --- a/gatherling/models/SetScraper.php +++ b/gatherling/models/SetScraper.php @@ -6,13 +6,13 @@ class SetScraper { public static function getSetList() { - // gets a list of sets from magicthegathering.io + // gets a list of sets from magicthegathering.io $url = 'https://mtgjson.com/api/v5/SetList.json'; $options = [ 'http' => [ 'method' => 'GET', - 'header' => "Accept-language: en\r\n" . + 'header' => "Accept-language: en\r\n". "User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10\r\n", // i.e. An iPad ], ]; diff --git a/gatherling/outofservice.php b/gatherling/outofservice.php deleted file mode 100644 index 72f1890c..00000000 --- a/gatherling/outofservice.php +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - Gatherling.com | Out of Service - - - -
-
-
-
-

Gatherling is TEMPORARILY out of service for maintenance.

-
-
- - diff --git a/gatherling/player.php b/gatherling/player.php index 69d648f1..ab3ccf2e 100644 --- a/gatherling/player.php +++ b/gatherling/player.php @@ -547,8 +547,8 @@ function print_preRegistration() } foreach ($available_events as $event) { - echo '{$event->name}"; - echo '' . time_element(strtotime($event->start), time()) . ''; + echo '{$event->name}"; + echo '
' . time_element(strtotime($event->start), time()) . ''; if ($event->is_full()) { echo 'This event is currently at capacity.'; diff --git a/gatherling/prereg.php b/gatherling/prereg.php index 9dbac258..b7b74412 100644 --- a/gatherling/prereg.php +++ b/gatherling/prereg.php @@ -48,7 +48,7 @@ header('Location: auth.php'); } - require __DIR__ . '/authlib.php'; + require __DIR__.'/authlib.php'; global $provider; $token = load_cached_token(); diff --git a/gatherling/ratings.php b/gatherling/ratings.php index 23ada9ad..29bf4414 100644 --- a/gatherling/ratings.php +++ b/gatherling/ratings.php @@ -152,7 +152,7 @@ function currentThrough($format) $stmt->bind_result($name); $stmt->fetch(); $stmt->close(); - $date = strftime('%Y-%m-%d', strtotime($start)); + $date = date('Y-m-d', strtotime($start)); echo "Ratings current through {$date} - {$name}"; } diff --git a/gatherling/series.php b/gatherling/series.php index 6bc8c61a..12773fcb 100644 --- a/gatherling/series.php +++ b/gatherling/series.php @@ -25,7 +25,7 @@ function series($series_name) if (strtotime($mostRecentEvent->start) + (86400 * 7 * 4) < time() && !$nextEvent) { return; } - $next_event_start = $nextEvent ? date('F j h:i a', strtotime($nextEvent->start) - minutes(30)) . " registration" : "Not scheduled yet"; + $next_event_start = $nextEvent ? time_element(strtotime($nextEvent->start), time()) : "Not scheduled yet"; $format_name = $nextEvent ? $nextEvent->format : $mostRecentEvent-> format; ?>
diff --git a/gatherling/util/insertcardset.php b/gatherling/util/insertcardset.php index f7e0a3af..65454a41 100644 --- a/gatherling/util/insertcardset.php +++ b/gatherling/util/insertcardset.php @@ -152,14 +152,14 @@ function insertCard($card, $set, $rarity, $stmt) { $typeline = implode(' ', $card->types); if (isset($card->subtypes) && count($card->subtypes) > 0) { - $typeline = $typeline . ' - ' . implode(' ', $card->subtypes); + $typeline = $typeline.' - '.implode(' ', $card->subtypes); } $name = normaliseCardName($card->name); echo ''; - echo ''; + echo ''; foreach (['manaCost', 'convertedManaCost', 'type', 'rarity'] as $attr) { if (isset($card->{$attr})) { - echo "'; + echo "'; } } echo '
Name:' . $name . '
Name:'.$name.'
{$attr}:" . $card->{$attr} . '
{$attr}:".$card->{$attr}.'
Card Colors:'; diff --git a/gatherling/util/scryfallsync.php b/gatherling/util/scryfallsync.php index 5f2b6902..48be2b07 100644 --- a/gatherling/util/scryfallsync.php +++ b/gatherling/util/scryfallsync.php @@ -2,7 +2,7 @@ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); -require_once __DIR__ . '/../lib.php'; +require_once __DIR__.'/../lib.php'; function info($text, $newline = true) { @@ -170,10 +170,10 @@ function insertCard($card, $set, $typeline, $stmt) $name = $card->name; $name = normaliseCardName($name); echo ''; - echo ''; + echo ''; foreach (['manaCost', 'convertedManaCost', 'type', 'rarity'] as $attr) { if (isset($card->{$attr})) { - echo "'; + echo "'; } } echo '
Name:' . $name . '
Name:'.$name.'
{$attr}:" . $card->{$attr} . '
{$attr}:".$card->{$attr}.'
Card Colors:'; diff --git a/gatherling/util/time.php b/gatherling/util/time.php index 16c964c3..51165266 100644 --- a/gatherling/util/time.php +++ b/gatherling/util/time.php @@ -2,7 +2,7 @@ function time_element($datetime, $now): string { - return ''; + return ''; } function human_date($datetime, $now): string @@ -19,19 +19,20 @@ function human_date($datetime, $now): string } $suffix = $datetime > $now ? 'from now' : 'ago'; $INTERVALS = [ - 'week' => 60 * 60 * 24 * 7, - 'day' => 60 * 60 * 24, - 'hour' => 60 * 60, + 'week' => 60 * 60 * 24 * 7, + 'day' => 60 * 60 * 24, + 'hour' => 60 * 60, 'minute' => 60, 'second' => 1, ]; foreach ($INTERVALS as $interval => $duration) { if ($elapsed > $duration) { - return pluralize(intdiv($elapsed, $duration), $interval) . " $suffix"; + return pluralize(intdiv($elapsed, $duration), $interval)." $suffix"; } } } -function pluralize($n, $noun): string { - return $n . ' ' . $noun . ($n != 1 ? 's' : ''); +function pluralize($n, $noun): string +{ + return $n.' '.$noun.($n != 1 ? 's' : ''); } diff --git a/gatherling/util/updateDefaultFormats.php b/gatherling/util/updateDefaultFormats.php index 50a04551..6be7beda 100644 --- a/gatherling/util/updateDefaultFormats.php +++ b/gatherling/util/updateDefaultFormats.php @@ -2,7 +2,7 @@ namespace Gatherling; -require_once __DIR__ . '/../lib.php'; +require_once __DIR__.'/../lib.php'; if (PHP_SAPI != 'cli' && $_SERVER['REQUEST_METHOD'] == 'GET') { // unauthorized POST is okay ini_set('max_execution_time', 300); diff --git a/tests/EventsTest.php b/tests/EventsTest.php index 2b61c197..e798eef3 100644 --- a/tests/EventsTest.php +++ b/tests/EventsTest.php @@ -26,7 +26,7 @@ public function testSeriesCreation() $series = new Series(''); $series->name = 'Test'; $series->active = true; - $series->start_time = '00:00' . ':00'; + $series->start_time = '00:00'.':00'; $series->start_day = 'Friday'; $series->save(); } @@ -107,7 +107,7 @@ public function testEventCreation($series) public function testRegistration($event) { for ($i = 0; $i < 10; $i++) { - $event->addPlayer('testplayer' . $i); + $event->addPlayer('testplayer'.$i); } // 8 players have expressed interest in the event. $this->assertEquals(10, count($event->getEntries())); diff --git a/tests/TimeTest.php b/tests/TimeTest.php index 03914146..6916f600 100644 --- a/tests/TimeTest.php +++ b/tests/TimeTest.php @@ -11,26 +11,26 @@ final class TimeTest extends TestCase public function testHumanDate() { $now = strtotime('2024-08-29T12:00:00-07:00'); - $this->assertEquals("just now", human_date($now, $now)); + $this->assertEquals('just now', human_date($now, $now)); $recently = strtotime('2024-08-29T11:30:00-07:00'); - $this->assertEquals("30 minutes ago", human_date($recently, $now)); + $this->assertEquals('30 minutes ago', human_date($recently, $now)); $soon = strtotime('2024-08-29T12:15:00-07:00'); - $this->assertEquals("15 minutes from now", human_date($soon, $now)); + $this->assertEquals('15 minutes from now', human_date($soon, $now)); $yesterday = strtotime('2024-08-28T09:30:00-07:00'); - $this->assertEquals("1 day ago", human_date($yesterday, $now)); + $this->assertEquals('1 day ago', human_date($yesterday, $now)); $lastMonth = strtotime('2024-07-28T09:30:00-07:00'); - $this->assertEquals("Jul 28th", human_date($lastMonth, $now)); + $this->assertEquals('Jul 28th', human_date($lastMonth, $now)); $aFewWeeks = strtotime('2024-08-02T09:30:00-07:00'); - $this->assertEquals("3 weeks ago", human_date($aFewWeeks, $now)); + $this->assertEquals('3 weeks ago', human_date($aFewWeeks, $now)); $longAgo = strtotime('2023-11-01T09:30:00-07:00'); - $this->assertEquals("Nov 1st", human_date($longAgo, $now)); + $this->assertEquals('Nov 1st', human_date($longAgo, $now)); $nextMonth = strtotime('2024-09-30T09:30:00-07:00'); - $this->assertEquals("Sep 30th", human_date($nextMonth, $now)); + $this->assertEquals('Sep 30th', human_date($nextMonth, $now)); $farFuture = strtotime('2026-08-28T09:30:00-07:00'); - $this->assertEquals("Aug 2026", human_date($farFuture, $now)); + $this->assertEquals('Aug 2026', human_date($farFuture, $now)); // New York time is Gatherling's "home" time. $differsNewYorkAndLosAngeles = strtotime('2024-06-13T23:30:00-07:00'); - $this->assertEquals("Jun 14th", human_date($differsNewYorkAndLosAngeles, $now)); + $this->assertEquals('Jun 14th', human_date($differsNewYorkAndLosAngeles, $now)); } public function testTimeElement()